提交 022b1c6c 作者: yanxin

事件分析删除内容回退

上级 34747ca4
package com.zzsn.event.controller;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.clb.common.model.task.dto.titr.KeyWordsDTO;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.*;
import com.zzsn.event.service.*;
import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.ObjectUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.CompletableFuture;
/**
* 事件后台管理
*
* @author lkg
* @date 2024/4/8
*/
@Slf4j
@Api(tags = "事件后台管理")
@RestController
@RequestMapping("/manage")
public class EventManageController {
@Autowired
private IEventService eventService;
@Autowired
private LabelEntityService labelEntityService;
@Autowired
private IXxlJobInfoService iXxlJobInfoService;
@Autowired
private ISubjectInfoSourceMapService subjectInfoSourceMapService;
@Autowired
private ICustomerDataPermissionMapService customerDataPermissionMapService;
@Autowired
private ISysUserDataPermissionService sysUserDataPermissionService;
@Autowired
private IKeyWordsService keyWordsService;
@Autowired
private RedisUtil redisUtil;
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Value(("${serviceProject.url:}"))
private String SERVICE_PROJECT_URL;
/**
* 分页列表-后台管理
*
* @param eventName 事件名称
* @param eventType 事件分类id
* @param facePublic 是否公开(0-未公开;1-已公开)
* @param publishStatus 发布状态(0-未发布;1-已发布)
* @param startTime 开始时间
* @param endTime 结束时间
* @param order 排序字段
* @param orderType 排序方式
* @param pageNo 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/8
*/
@ApiOperation(value = "事件-分页列表查询", notes = "事件-分页列表查询")
@GetMapping(value = "/pageList")
public Result<?> pageList(@RequestParam(name = "eventName", required = false) String eventName,
@RequestParam(name = "eventType", required = false) Integer eventType,
@RequestParam(name = "facePublic", required = false) Integer facePublic,
@RequestParam(name = "publishStatus", required = false) Integer publishStatus,
@RequestParam(name = "startTime", required = false) String startTime,
@RequestParam(name = "endTime", required = false) String endTime,
@RequestParam(name = "order", required = false) String order,
@RequestParam(name = "orderType", defaultValue = "asc") String orderType,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
IPage<EventManageVO> pageList = eventService.pageList(eventName, eventType, facePublic, publishStatus, startTime, endTime, order, orderType, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 地域信息-树型结构
*
* @param type 类别(1-国际;2-国内)
* @author lkg
* @date 2024/4/10
*/
@GetMapping("/regionTree")
public Result<?> regionTree(@RequestParam Integer type) {
List<LabelTypeVO> nodes = labelEntityService.regionTree(type);
return Result.OK(nodes);
}
/**
* 通过id查询
*
* @param id 事件id
* @return
*/
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id") String id) {
EventVO eventVO = eventService.queryInfo(id);
return Result.OK(eventVO);
}
private void updateStatus(String eventId, Integer status) {
eventService.update(Wrappers.<Event>lambdaUpdate().eq(Event::getId, eventId).set(Event::getStatus, status));
CompletableFuture.runAsync(() -> {
Event event = eventService.getById(eventId);
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, event.getEventCode())
.set(XxlJobInfo::getTriggerStatus, status));
//关键词
KeywordsVO keywordsVO = keyWordsService.keywordInfoByEventId(eventId);
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, keywordsVO.getWordsCode())
.set(XxlJobInfo::getTriggerStatus, status));
if (1==status){
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
}
});
}
/**
* 1.7 发布
*
* @return
*/
@PostMapping(value = "/publish")
public Result<?> publish(@RequestBody Event event) {
Event byId = eventService.getById(event.getId());
byId.setUpdateTime(new Date());
byId.setPublishDate(event.getPublishDate());
byId.setPublishStatus(event.getPublishStatus());
eventService.updateById(byId);
return Result.OK();
}
/**
* 项目列表
*
* @author lkg
* @date 2024/4/29
*/
@GetMapping("/projectList")
public Result<?> projectList() {
//获取当前登录用户
UserVo currentUser = UserUtil.getLoginUser();
Integer category = currentUser.getCategory();
String userId = null;
String customerId = null;
/*if (category.equals(Constants.COMMON_USER)) {
userId = currentUser.getUserId();
} else if (category.equals(Constants.ADMIN_USER)) {
customerId = currentUser.getCustomerId();
}*/
List<Node> projectList = eventService.projectList(userId, customerId);
return Result.OK(projectList);
}
/**
* 2.1 专题信息源绑定
*/
@PostMapping("/infoSourceBind")
public Object infoSourceBind(@RequestBody SubjectPage subjectPage) {
try {
JSONObject params = ObjectUtil.objectToJSONObject(subjectPage);
String url = SERVICE_PROJECT_URL + "event/infoSource/infoSourceBind";
return HttpUtil.doPost(url, params, 10000);
} catch (Exception e) {
return null;
}
}
/**
* 2.2 查询信息源组的绑定列表
*/
@GetMapping("/bindList")
public Object bindList(InfoSourceVo infoSourceVo,
@RequestParam(name = "ynBind") Integer ynBind,
@RequestParam(name = "groupId") String groupId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
String url = SERVICE_PROJECT_URL + "event/infoSource/bindList";
Map<String, String> params = ObjectUtil.objectToMap(infoSourceVo);
params.put("ynBind", ynBind.toString());
params.put("groupId", groupId);
params.put("pageNo", pageNo.toString());
params.put("pageSize", pageSize.toString());
return HttpUtil.doGet(url, params, null,"utf-8");
}
/**
* 2.3 关键词类别
*/
@GetMapping("/keywordsType/rootListNoPage")
public Object keywordsList(@RequestParam(name = "contain", defaultValue = "false") Boolean contain,
@RequestParam(name = "subjectId", defaultValue = "0") String subjectId) {
String url = SERVICE_PROJECT_URL + "event/keywordsType/rootListNoPage";
Map<String, String> params = new HashMap<>();
params.put("contain", contain.toString());
params.put("subjectId", subjectId);
return HttpUtil.doGet(url, params, null,"utf-8");
}
/**
* 2.4 专题关键词绑定
*/
@PostMapping("/keyWordsBind")
public Object keyWordsBind(@RequestBody SubjectPage subjectPage) {
try {
JSONObject params = ObjectUtil.objectToJSONObject(subjectPage);
String url = SERVICE_PROJECT_URL + "event/keyWordsBind";
return HttpUtil.doPost(url, params, 10000);
} catch (Exception e) {
return null;
}
}
/**
* 2.5 专题关键词绑定
*/
@PostMapping("/keyWordsEdit")
public Object keyWordsEdit(@RequestBody SubjectKeywordsMap subjectKeywordsMap) {
try {
JSONObject params = ObjectUtil.objectToJSONObject(subjectKeywordsMap);
String url = SERVICE_PROJECT_URL + "event/keyWords/edit";
return HttpUtil.doPost(url, params, 10000);
} catch (Exception e) {
return null;
}
}
/**
* 2.6 标签查询
*/
@PostMapping("/label/treeList")
public Object labelTreeList(@RequestBody SubjectKeywordsMap subjectKeywordsMap) {
try {
JSONObject params = ObjectUtil.objectToJSONObject(subjectKeywordsMap);
String url = SERVICE_PROJECT_URL + "event/label/treeList";
return HttpUtil.doPost(url, params, 10000);
} catch (Exception e) {
return null;
}
}
/**
* 2.7 专题绑定的搜索引擎列表
*
* @return
*/
@ApiOperation(value = "专题绑定的搜索引擎列表", notes = "专题绑定的搜索引擎列表")
@GetMapping(value = "/bindSearchEngineList")
public Object bindSearchEngineList(SearchEnginesVo searchEnginesVo) {
String url = SERVICE_PROJECT_URL + "event/bindSearchEngineList";
Map<String, String> params = new HashMap<>();
params.put("searchEnginesVo", searchEnginesVo.toString());
params.put("subjectId", searchEnginesVo.getSubjectId());
if (searchEnginesVo.getType() != null) {
params.put("type", searchEnginesVo.getType().toString());
}
return HttpUtil.doGet(url, params, null,"utf-8");
}
/**
* 2.8 专题搜索引擎绑定
*
* @param subjectPage
* @return
*/
@ApiOperation(value = "专题搜索引擎绑定", notes = "专题搜索引擎绑定")
@PostMapping(value = "/searchEngineBind")
public Object searchEngineBind(@RequestBody SubjectPage subjectPage) {
try {
JSONObject params = ObjectUtil.objectToJSONObject(subjectPage);
String url = SERVICE_PROJECT_URL + "event/searchEngineBind";
return HttpUtil.doPost(url, params, 10000);
} catch (Exception e) {
return null;
}
}
/**
* 2.9 专题绑定的信息源组列表
*
* @param id
* @return
*/
@ApiOperation(value = "专题绑定/排除的信息源组列表", notes = "专题绑定/排除的信息源组列表")
@GetMapping(value = "/bindInfoSourceList")
public Object bindInfoSourceList(@RequestParam(name = "id") String id) {
String url = SERVICE_PROJECT_URL + "event/bindInfoSourceList";
Map<String, String> params = new HashMap<>();
params.put("id", id);
return HttpUtil.doGet(url, params, null,"utf-8");
}
/**
* 2.10 专题信息源绑定删除
*
* @param subjectPage
* @return
*/
@ApiOperation(value = "专题信息源绑定删除", notes = "专题信息源绑定删除")
@PostMapping(value = "/deleteBindInfoSource")
public Object deleteBindInfoSource(@RequestBody SubjectPage subjectPage) {
try {
JSONObject params = ObjectUtil.objectToJSONObject(subjectPage);
;
String url = SERVICE_PROJECT_URL + "event/deleteBindInfoSource";
return HttpUtil.doPost(url, params, 10000);
} catch (Exception e) {
return null;
}
}
/**
* 2.11 专题与信息源关联编辑
*
* @param subjectInfoSourceMap
* @return
*/
@ApiOperation(value = "专题与信息源关联表-编辑", notes = "专题与信息源关联表-编辑")
@PostMapping(value = "/SubjectInfoSourceMap/edit")
public Result<?> edit(@RequestBody SubjectInfoSourceMap subjectInfoSourceMap) {
subjectInfoSourceMapService.updateMain(subjectInfoSourceMap);
return Result.OK("编辑成功!");
}
/**
* 2.12 信息源组类别列表查询
*
* @param contain
* @param subjectId
* @return
*/
@ApiOperation(value = "信息源组类别-列表查询", notes = "信息源组类别-列表查询")
@GetMapping(value = "/groupType/rootListNoPage")
public Object queryPageListNoPage(@RequestParam(name = "contain", defaultValue = "false") Boolean contain,
@RequestParam(name = "keywords", required = false) String keywords,
@RequestParam(name = "subjectId", defaultValue = "0") String subjectId) {
String url = SERVICE_PROJECT_URL + "event/groupType/rootListNoPage";
Map<String, String> params = new HashMap<>();
params.put("contain", contain.toString());
params.put("keywords", keywords);
params.put("subjectId", subjectId);
return HttpUtil.doGet(url, params, null,"utf-8");
}
/**
* 2.13 专题绑定的关键词组列表
*
* @param id
* @return
*/
@ApiOperation(value = "专题绑定的关键词组列表", notes = "专题绑定的关键词组列表")
@GetMapping(value = "/bindKeyWordsList")
public Object bindKeyWordsList(@RequestParam(name = "id") String id) {
String url = SERVICE_PROJECT_URL + "event/bindKeyWordsList";
Map<String, String> params = new HashMap<>();
params.put("id", id);
return HttpUtil.doGet(url, params, null,"utf-8");
}
/**
* 2.14 删除专题关键词绑定
*
* @param subjectPage
* @return
*/
@ApiOperation(value = "删除专题关键词绑定", notes = "删除专题关键词绑定")
@PostMapping(value = "/deleteKeyWordsBind")
public Object deleteKeyWordsBind(@RequestBody SubjectPage subjectPage) {
try {
JSONObject params = ObjectUtil.objectToJSONObject(subjectPage);
String url = SERVICE_PROJECT_URL + "event/deleteKeyWordsBind";
return HttpUtil.doPost(url, params, 10000);
} catch (Exception e) {
return null;
}
}
/**
* 2.15 关键词管理-分页列表查询
*
* @param keyWords
* @param pageNo
* @param pageSize
* @return
*/
@ApiOperation(value = "关键词管理-分页列表查询", notes = "关键词管理-分页列表查询")
@GetMapping(value = "/keyWords/listByTypeId")
public Object queryPageListByTypeId(KeyWords keyWords,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "wordsName", required = false) String wordsName,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(name = "keyWordsTypeId", defaultValue = "0") String keyWordsTypeId,
@RequestParam(name = "search", defaultValue = "false") Boolean search,
@RequestParam(name = "subjectId", defaultValue = "0") String subjectId) {
String url = SERVICE_PROJECT_URL + "event/keyWords/listByTypeId";
Map<String, String> params = new HashMap<>();
keyWords.setWordsName(wordsName);
params.put("wordsName", wordsName);
params.put("pageNo", pageNo.toString());
params.put("pageSize", pageSize.toString());
params.put("keyWordsTypeId", keyWordsTypeId);
params.put("subjectId", subjectId);
params.put("search", search.toString());
return HttpUtil.doGet(url, params, null,"utf-8");
}
/**
* 模型信息列表
*
* @author lkg
* @date 2024/4/11
*/
@GetMapping("/modelList")
public Result<?> modelList() {
List<ModelVO> modelVOS = eventService.modelList();
return Result.OK(modelVOS);
}
/**
* 算法模型信息列表
*
* @param subjectId 专题id
* @param type 类型id
* @author lkg
* @date 2024/4/11
*/
@GetMapping("/algorithmModelList")
public Object algorithmModelList(@RequestParam String subjectId, @RequestParam Integer type) {
String url = SERVICE_PROJECT_URL + "event/listNoPage";
Map<String, String> params = new HashMap<>();
params.put("subjectId", subjectId);
params.put("type", type.toString());
return HttpUtil.doGet(url, params, null,"utf-8");
}
/**
* 模型绑定
*
* @author lkg
* @date 2024/4/11
*/
@PostMapping("/modelBind")
public Object modelBind(@RequestBody SubjectPage subjectPage) {
try {
JSONObject params = ObjectUtil.objectToJSONObject(subjectPage);
String url = SERVICE_PROJECT_URL + "event/modelBind";
return HttpUtil.doPost(url, params, 10000);
} catch (Exception e) {
return null;
}
}
/**
* 分页列表-新平台管理
*
* @param subjectCondition 筛选条件
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/28
*/
@GetMapping("/newPlatPageList")
public Result<?> newPlatPageList(SubjectCondition subjectCondition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<EventNewPlatVO> pageList = eventService.newPlatPageList(subjectCondition, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 1.2 添加
*
* @param eventParam
* @return
*/
@PostMapping(value = "/add")
public Result<?> add(@RequestBody AddEventParam eventParam) {
KeywordsVO keywordsVO = eventParam.getKeywordsVO();
if (keywordsVO != null) {
UserVo currentUser = UserUtil.getLoginUser();
eventParam.setCreateBy(currentUser.getUsername());
Event event = eventService.saveMain(eventParam);
//新增关键词
KeyWords keyWords = keyWordsService.saveKeyword(event, keywordsVO.getKeyword(), keywordsVO.getExclusionWord());
CompletableFuture.runAsync(() -> {
//插入xxlJob
iXxlJobInfoService.eventInsert(event);
//关键词入缓存
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keyWords, redisKeywordDTO);
redisKeywordDTO.setStartTime(event.getStartTime());
redisKeywordDTO.setEndTime(event.getEndTime());
redisKeywordDTO.setSearchEngines(new ArrayList<>(Constants.DEFAULT_SEARCH_ENGINE.values()));
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keyWords.getWordsCode(), redisKeywordDTO);
//插入xxljob
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
});
return Result.OK();
} else {
return Result.FAIL(500, "关键词不能为空");
}
}
/**
* 1.3 编辑
*
* @param addEventParam
* @return
*/
@PostMapping(value = "/edit")
public Result<?> edit(@RequestBody AddEventParam addEventParam) {
//关键词
KeywordsVO keywordsVO = addEventParam.getKeywordsVO();
if (keywordsVO != null) {
UserVo currentUser = UserUtil.getLoginUser();
addEventParam.setUpdateTime(new Date());
addEventParam.setUpdateBy(currentUser.getUsername());
eventService.updateMain(addEventParam);
keyWordsService.update(Wrappers.<KeyWords>lambdaUpdate().eq(KeyWords::getId, keywordsVO.getId())
.set(KeyWords::getKeyWord, keywordsVO.getKeyword())
.set(KeyWords::getExclusionWord, keywordsVO.getExclusionWord()));
CompletableFuture.runAsync(() -> {
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keywordsVO, redisKeywordDTO);
redisKeywordDTO.setKeyWord(keywordsVO.getKeyword());
redisKeywordDTO.setStartTime(addEventParam.getStartTime());
redisKeywordDTO.setEndTime(addEventParam.getEndTime());
redisKeywordDTO.setSearchEngines(new ArrayList<>(Constants.DEFAULT_SEARCH_ENGINE.values()));
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO);
//为了立即响应,关键词编辑时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
});
return Result.OK();
} else {
return Result.FAIL(500, "关键词不能为空");
}
}
/**
* 启用
*
* @param eventId 事件id
* @author lkg
* @date 2024/9/12
*/
@GetMapping("/enable")
public Result<?> enable(@RequestParam String eventId) {
updateStatus(eventId, 1);
return Result.OK();
}
/**
* 启用
*
* @param eventId 事件id
* @author lkg
* @date 2024/9/12
*/
@GetMapping("/disable")
public Result<?> disable(@RequestParam String eventId) {
updateStatus(eventId, 0);
return Result.OK();
}
/**
* 通过id删除
*
* @param id 事件id
* @return
*/
@GetMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id") String id) {
eventService.deleteMain(id);
CompletableFuture.runAsync(() -> {
EventVO eventVO = eventService.queryInfo(id);
iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode());
//删除关键词
KeywordsVO keywordsVO = eventVO.getKeywordsVO();
if (keywordsVO != null) {
String wordsCode = keywordsVO.getWordsCode();
keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode));
redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode);
iXxlJobInfoService.deleteByInfosourceCode(wordsCode);
//todo 是否删除对应的资讯数据
}
});
return Result.OK();
}
/**
* 批量删除
*
* @param ids 事件id,多个用逗号隔开
* @author lkg
* @date 2024/12/17
*/
@GetMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids") String ids) {
String[] idArr = ids.split(",");
//删除
for (String id : idArr) {
eventService.deleteMain(id);
}
//异步删除关联关系
CompletableFuture.runAsync(() -> {
for (String id : idArr) {
EventVO eventVO = eventService.queryInfo(id);
iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode());
//删除关键词
KeywordsVO keywordsVO = eventVO.getKeywordsVO();
if (keywordsVO != null) {
String wordsCode = keywordsVO.getWordsCode();
keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode));
redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode);
iXxlJobInfoService.deleteByInfosourceCode(wordsCode);
}
}
});
//todo 是否删除对应的资讯数据
return Result.OK();
}
/**
* @param event 条件封装
* @描述 查询事件列表
* @作者 hejinyu
* @创建时间 2024/12/26
**/
@PostMapping("/listAll")
public Result<?> listAll(@RequestBody Event event) {
LambdaQueryWrapper<Event> queryWrapper = Wrappers.lambdaQuery();
setListAllQueryWrapper(event, queryWrapper);
List<Event> list = eventService.list(queryWrapper);
return Result.OK(list);
}
/**
* @param event 条件封装
* @param pageNo
* @param pageSize
* @描述 查询事件列表(分页,产业链关联事件时查询用)
* @作者 hejinyu
* @创建时间 2024/12/26
**/
@PostMapping("/pageListAll")
public Result<?> pageListAll(@RequestBody Event event, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
LambdaQueryWrapper<Event> queryWrapper = Wrappers.lambdaQuery();
setListAllQueryWrapper(event, queryWrapper);
Page<Event> page = new Page<>(pageNo, pageSize);
IPage<Event> pageList = eventService.page(page, queryWrapper);
return Result.OK(pageList);
}
private void setListAllQueryWrapper(@RequestBody Event event, LambdaQueryWrapper<Event> queryWrapper) {
String eventType = event.getEventType();
String startDate = event.getStartDate();
String endDate = event.getEndDate();
String keyword = event.getKeyword();
queryWrapper.eq(StringUtils.isNotEmpty(eventType), Event::getEventType, eventType);
if (StringUtils.isNotEmpty(startDate)) {
queryWrapper.ge(Event::getCreateTime, startDate);
}
if (StringUtils.isNotEmpty(endDate)) {
queryWrapper.le(Event::getCreateTime, endDate);
}
if (StringUtils.isNotEmpty(keyword)) {
queryWrapper.and(q -> {
q.eq(Event::getEventType, keyword).or().like(Event::getEventName, keyword).or().eq(Event::getEventDescribe, keyword);
});
}
}
}
package com.zzsn.event.controller;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.clb.common.model.task.dto.titr.KeyWordsDTO;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.KeyWords;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IKeyWordsService;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* 平台事件管理页
*
* @author lkg
* @date 2024/5/7
*/
@RestController
@RequestMapping("/manage")
public class PlatEventManageController {
@Autowired
private IEventService eventService;
@Autowired
private IXxlJobInfoService iXxlJobInfoService;
@Autowired
private IKeyWordsService keyWordsService;
@Autowired
private RedisUtil redisUtil;
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
/**
* 分页列表-新平台管理
*
* @param subjectCondition 筛选条件
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/28
*/
@GetMapping("/pageList")
public Result<?> newPlatPageList(SubjectCondition subjectCondition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<EventNewPlatVO> pageList = eventService.newPlatPageList(subjectCondition, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 1.2 添加
*
* @param eventParam
* @return
*/
@PostMapping(value = "/add")
public Result<?> add(@RequestBody AddEventParam eventParam) {
KeywordsVO keywordsVO = eventParam.getKeywordsVO();
if (keywordsVO != null) {
UserVo currentUser = UserUtil.getLoginUser();
eventParam.setCreateBy(currentUser.getUsername());
Event event = eventService.saveMain(eventParam);
//新增关键词
KeyWords keyWords = keyWordsService.saveKeyword(event, keywordsVO.getKeyword(), keywordsVO.getExclusionWord());
CompletableFuture.runAsync(() -> {
//插入xxlJob
iXxlJobInfoService.eventInsert(event);
//关键词入缓存
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keyWords, redisKeywordDTO);
redisKeywordDTO.setStartTime(event.getStartTime());
redisKeywordDTO.setEndTime(event.getEndTime());
redisKeywordDTO.setSearchEngines(new ArrayList<>(Constants.DEFAULT_SEARCH_ENGINE.values()));
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keyWords.getWordsCode(), redisKeywordDTO);
//插入xxljob
iXxlJobInfoService.keyWordsInsert(redisKeywordDTO);
//为了立即响应,关键词新增时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
});
return Result.OK();
} else {
return Result.FAIL(500, "关键词不能为空");
}
}
/**
* 1.3 编辑
*
* @param addEventParam
* @return
*/
@PostMapping(value = "/edit")
public Result<?> edit(@RequestBody AddEventParam addEventParam) {
//关键词
KeywordsVO keywordsVO = addEventParam.getKeywordsVO();
if (keywordsVO != null) {
UserVo currentUser = UserUtil.getLoginUser();
addEventParam.setUpdateTime(new Date());
addEventParam.setUpdateBy(currentUser.getUsername());
eventService.updateMain(addEventParam);
keyWordsService.update(Wrappers.<KeyWords>lambdaUpdate().eq(KeyWords::getId, keywordsVO.getId())
.set(KeyWords::getKeyWord, keywordsVO.getKeyword())
.set(KeyWords::getExclusionWord, keywordsVO.getExclusionWord()));
CompletableFuture.runAsync(() -> {
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keywordsVO, redisKeywordDTO);
redisKeywordDTO.setKeyWord(keywordsVO.getKeyword());
redisKeywordDTO.setStartTime(addEventParam.getStartTime());
redisKeywordDTO.setEndTime(addEventParam.getEndTime());
redisKeywordDTO.setSearchEngines(new ArrayList<>(Constants.DEFAULT_SEARCH_ENGINE.values()));
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO);
//为了立即响应,关键词编辑时放入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
});
return Result.OK();
} else {
return Result.FAIL(500, "关键词不能为空");
}
}
/**
* 启用
*
* @param eventId 事件id
* @author lkg
* @date 2024/9/12
*/
@GetMapping("/enable")
public Result<?> enable(@RequestParam String eventId) {
updateStatus(eventId, 1);
return Result.OK();
}
/**
* 启用
*
* @param eventId 事件id
* @author lkg
* @date 2024/9/12
*/
@GetMapping("/disable")
public Result<?> disable(@RequestParam String eventId) {
updateStatus(eventId, 0);
return Result.OK();
}
/**
* 通过id删除
*
* @param id 事件id
* @return
*/
@GetMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id") String id) {
eventService.deleteMain(id);
CompletableFuture.runAsync(() -> {
EventVO eventVO = eventService.queryInfo(id);
iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode());
//删除关键词
KeywordsVO keywordsVO = eventVO.getKeywordsVO();
if (keywordsVO != null) {
String wordsCode = keywordsVO.getWordsCode();
keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode));
redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode);
iXxlJobInfoService.deleteByInfosourceCode(wordsCode);
//todo 是否删除对应的资讯数据
}
});
return Result.OK();
}
/**
* 批量删除
*
* @param ids 事件id,多个用逗号隔开
* @author lkg
* @date 2024/12/17
*/
@GetMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids") String ids) {
String[] idArr = ids.split(",");
//删除
for (String id : idArr) {
eventService.deleteMain(id);
}
//异步删除关联关系
CompletableFuture.runAsync(() -> {
for (String id : idArr) {
EventVO eventVO = eventService.queryInfo(id);
iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode());
//删除关键词
KeywordsVO keywordsVO = eventVO.getKeywordsVO();
if (keywordsVO != null) {
String wordsCode = keywordsVO.getWordsCode();
keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode));
redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode);
iXxlJobInfoService.deleteByInfosourceCode(wordsCode);
}
}
});
//todo 是否删除对应的资讯数据
return Result.OK();
}
private void updateStatus(String eventId, Integer status) {
eventService.update(Wrappers.<Event>lambdaUpdate().eq(Event::getId, eventId).set(Event::getStatus, status));
CompletableFuture.runAsync(() -> {
Event event = eventService.getById(eventId);
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, event.getEventCode())
.set(XxlJobInfo::getTriggerStatus, status));
//关键词
KeywordsVO keywordsVO = keyWordsService.keywordInfoByEventId(eventId);
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, keywordsVO.getWordsCode())
.set(XxlJobInfo::getTriggerStatus, status));
if (1 == status) {
kafkaTemplate.send(Constants.EVENT_SUBJECT_MODEL, event.getEventCode());
}
});
}
/**
* @param event 条件封装
* @描述 查询事件列表
* @作者 hejinyu
* @创建时间 2024/12/26
**/
@PostMapping("/listAll")
public Result<?> listAll(@RequestBody Event event) {
LambdaQueryWrapper<Event> queryWrapper = Wrappers.lambdaQuery();
setListAllQueryWrapper(event, queryWrapper);
List<Event> list = eventService.list(queryWrapper);
return Result.OK(list);
}
/**
* @param event 条件封装
* @param pageNo
* @param pageSize
* @描述 查询事件列表(分页,产业链关联事件时查询用)
* @作者 hejinyu
* @创建时间 2024/12/26
**/
@PostMapping("/pageListAll")
public Result<?> pageListAll(@RequestBody Event event, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
LambdaQueryWrapper<Event> queryWrapper = Wrappers.lambdaQuery();
setListAllQueryWrapper(event, queryWrapper);
Page<Event> page = new Page<>(pageNo, pageSize);
IPage<Event> pageList = eventService.page(page, queryWrapper);
return Result.OK(pageList);
}
private void setListAllQueryWrapper(@RequestBody Event event, LambdaQueryWrapper<Event> queryWrapper) {
String eventType = event.getEventType();
String startDate = event.getStartDate();
String endDate = event.getEndDate();
String keyword = event.getKeyword();
queryWrapper.eq(StringUtils.isNotEmpty(eventType), Event::getEventType, eventType);
if (StringUtils.isNotEmpty(startDate)) {
queryWrapper.ge(Event::getCreateTime, startDate);
}
if (StringUtils.isNotEmpty(endDate)) {
queryWrapper.le(Event::getCreateTime, endDate);
}
if (StringUtils.isNotEmpty(keyword)) {
queryWrapper.and(q -> {
q.eq(Event::getEventType, keyword).or().like(Event::getEventName, keyword).or().eq(Event::getEventDescribe, keyword);
});
}
}
}
package com.zzsn.event.controller.eventExtract;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.EventExtract;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.EventExtractService;
import com.zzsn.event.vo.EventExtractVO;
import com.zzsn.event.vo.SubjectDataVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* @author lkg
* @date 2024/9/7
*/
@Api(tags = "挖掘的事件管理")
@RestController
@RequestMapping("/extract")
public class EventExtractController {
@Autowired
private EventExtractService eventExtractService;
@Autowired
private EsService esService;
/**
* 伪事件信息分页列表
*
* @param taskId 任务id
* @param searchWord 搜索词
* @param eventName 事件名称
* @param eventType 事件分类
* @param startTime 开始时间
* @param endTime 结束时间
* @param checkStatus 审核状态(2-不通过;1-通过;0-待审核)
* @param column 排序字段
* @param sortType 排序方式
* @param pageNo 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/9/9
*/
@GetMapping("/pageList")
public Result<?> pageList(@RequestParam(name = "taskId") String taskId,
@RequestParam(name = "searchWord", required = false) String searchWord,
@RequestParam(name = "eventName", required = false) String eventName,
@RequestParam(name = "startTime", required = false) String startTime,
@RequestParam(name = "endTime", required = false) String endTime,
@RequestParam(name = "eventType", required = false) String eventType,
@RequestParam(name = "checkStatus", required = false) Integer checkStatus,
@RequestParam(name = "column", required = false) String column,
@RequestParam(name = "sortType", required = false) String sortType,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
IPage<EventExtractVO> page = eventExtractService.pageList(taskId, searchWord, eventName, startTime, endTime,
eventType, checkStatus, column, sortType, pageNo, pageSize);
return Result.OK(page);
}
/**
* 伪事件来源资讯详情
*
* @param relatedIds 来源资讯id,多个逗号隔开
* @author lkg
* @date 2024/9/13
*/
@GetMapping("/dataInfoList")
public Result<?> dataInfoList(@RequestParam List<String> relatedIds) {
List<SubjectDataVo> subjectDataVos = esService.listByIds(relatedIds);
return Result.OK(subjectDataVos);
}
/**
* 审核
*
* @param eventExtract 伪事件信息
* @author lkg
* @date 2024/9/13
*/
@PostMapping("/modify")
public Result<?> modify(@RequestBody EventExtract eventExtract) {
eventExtractService.updateById(eventExtract);
return Result.OK();
}
/**
* 删除
*
* @param id 主键id
* @author lkg
* @date 2024/9/9
*/
@GetMapping("/delete")
public Result<?> delete(@RequestParam String id) {
eventExtractService.update(Wrappers.<EventExtract>lambdaUpdate().set(EventExtract::getDeleteStatus, 1)
.eq(EventExtract::getId, id));
return Result.OK();
}
}
package com.zzsn.event.controller.eventExtract;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.EventExtractTask;
import com.zzsn.event.service.EventExtractTaskService;
import com.zzsn.event.service.OtherDataService;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.EventExtractTaskVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
* 事件抽取任务
*
* @author lkg
* @date 2024/9/13
*/
@RestController
@RequestMapping("/extract/task")
public class EventExtractTaskController {
@Autowired
private EventExtractTaskService eventExtractTaskService;
@Autowired
private OtherDataService otherDataService;
/**
* 事件抽取任务信息分页列表
*
* @param projectId 项目id
* @param searchWord 搜索词
* @param taskName 任务名称
* @param startTime 开始时间
* @param endTime 结束时间
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/9/13
*/
@GetMapping("/pageList")
public Result<?> pageList(@RequestParam(required = false) String projectId,
@RequestParam(required = false) String searchWord,
@RequestParam(required = false) String taskName,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize) {
IPage<EventExtractTaskVO> page = eventExtractTaskService.pageList(projectId, searchWord, taskName, startTime, endTime, pageNo, pageSize);
return Result.OK(page);
}
/**
* 查看详情
*
* @param id 任务id
* @author lkg
* @date 2024/9/14
*/
@GetMapping("/queryInfo")
public Result<?> queryInfo(@RequestParam String id){
EventExtractTask eventExtractTask = eventExtractTaskService.getById(id);
return Result.OK(eventExtractTask);
}
/**
* 新增/编辑
*
* @param eventExtractTask 事件抽取任务信息
* @author lkg
* @date 2024/9/13
*/
@PostMapping("/modify")
public Result<?> modify(@RequestBody EventExtractTask eventExtractTask) {
UserVo currentUser = UserUtil.getLoginUser();
eventExtractTask.setCreateBy(currentUser.getUsername());
eventExtractTask.setCreateTime(new Date());
eventExtractTaskService.saveOrUpdate(eventExtractTask);
return Result.OK();
}
/**
* 开启
*
* @param id 任务id
* @author lkg
* @date 2024/9/14
*/
@GetMapping("/open")
public Result<?> open(@RequestParam String id) {
eventExtractTaskService.update(Wrappers.<EventExtractTask>lambdaUpdate().set(EventExtractTask::getTaskStatus, 1)
.eq(EventExtractTask::getId, id));
return Result.OK();
}
/**
* 关闭
*
* @param id 任务id
* @author lkg
* @date 2024/9/14
*/
@GetMapping("/close")
public Result<?> close(@RequestParam String id) {
eventExtractTaskService.update(Wrappers.<EventExtractTask>lambdaUpdate().set(EventExtractTask::getTaskStatus, 0)
.eq(EventExtractTask::getId, id));
return Result.OK();
}
/**
* 删除
*
* @param id 任务id
* @author lkg
* @date 2024/9/13
*/
@GetMapping("/delete")
public Result<?> delete(@RequestParam String id) {
eventExtractTaskService.update(Wrappers.<EventExtractTask>lambdaUpdate().eq(EventExtractTask::getId, id)
.set(EventExtractTask::getDeleteStatus, 1));
return Result.OK();
}
/**
* 项目信息列表
*
* @author lkg
* @date 2024/9/14
*/
@GetMapping("/projectList")
public Result<?> projectList() {
List<Node> nodes = otherDataService.projectList();
return Result.OK(nodes);
}
/**
* 栏目信息列表
*
* @author lkg
* @date 2024/9/14
*/
@GetMapping("/columnList")
public Result<?> columnList() {
List<Node> nodes = otherDataService.columnList(null);
return Result.OK(nodes);
}
}
package com.zzsn.event.controller.plat;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.CustomerDataPermissionMap;
import com.zzsn.event.entity.SubjectType;
import com.zzsn.event.entity.SubjectTypeMap;
import com.zzsn.event.entity.SysUserDataPermission;
import com.zzsn.event.service.ICustomerDataPermissionMapService;
import com.zzsn.event.service.ISubjectTypeMapService;
import com.zzsn.event.service.ISubjectTypeService;
import com.zzsn.event.service.ISysUserDataPermissionService;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.tree.TreeUtil;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 事件后台管理-事件分类
*
* @author lkg
* @date 2024/4/29
*/
@Slf4j
@Api(tags = "-事件分类")
@RestController
@RequestMapping("/plat/manage/subjectType")
public class EventTypeController {
@Autowired
private ISubjectTypeService subjectTypeService;
@Autowired
private ISubjectTypeMapService subjectTypeMapService;
@Autowired
private ICustomerDataPermissionMapService customerDataPermissionMapService;
@Autowired
private ISysUserDataPermissionService sysUserDataPermissionService;
/**
* 事件分类列表-树型结构
*
* @author lkg
* @date 2024/4/28
*/
@GetMapping("/list")
public Result<?> typeList(@RequestParam(defaultValue = "2") Integer category) {
List<Node> nodes = subjectTypeService.enableList(category);
List<Node> tree = TreeUtil.tree(nodes, "0");
return Result.OK(tree);
}
/**
* 新增专题分类
*
* @param subjectType 专题分类
* @author lkg
* @date 2024/4/29
*/
@PostMapping("/add")
public Result<?> addSubjectType(@RequestBody SubjectType subjectType) {
UserVo currentUser = UserUtil.getLoginUser();
String pid = subjectType.getPid();
if (!"0".equals(pid)) {
int count = subjectTypeMapService.count(new LambdaQueryWrapper<SubjectTypeMap>().eq(SubjectTypeMap::getTypeId, pid));
if (count > 0) {
return Result.FAIL(501, "当前分类下存在专题");
}
}
subjectType.setCustomerId(currentUser.getCustomerId());
subjectTypeService.add(subjectType);
//权限
if (currentUser.getCategory().equals(Constants.ADMIN_USER)) {
customerDataPermissionMapService.save(new CustomerDataPermissionMap().setCustomerId(currentUser.getCustomerId()).setPermissionId(subjectType.getId()).setCategory(Constants.PERMISSION_SUBJECT));
}
if (currentUser.getCategory().equals(Constants.COMMON_USER)) {
sysUserDataPermissionService.save(new SysUserDataPermission().setUserId(currentUser.getUserId()).setPermissionId(subjectType.getId()).setCategory(Constants.PERMISSION_SUBJECT));
customerDataPermissionMapService.save(new CustomerDataPermissionMap().setCustomerId(currentUser.getCustomerId()).setPermissionId(subjectType.getId()).setCategory(Constants.PERMISSION_SUBJECT));
}
return Result.OK();
}
/**
* 编辑
*
* @param subjectType 专题分类
* @author lkg
* @date 2024/4/29
*/
@PostMapping("/edit")
public Result<?> edit(@RequestBody SubjectType subjectType){
subjectTypeService.edit(subjectType);
return Result.OK();
}
/**
* 删除
*
* @param id 专题分类id
* @author lkg
* @date 2024/4/29
*/
@GetMapping("/delete")
public Result<?> delete(@RequestParam String id){
int count = subjectTypeMapService.count(new LambdaQueryWrapper<SubjectTypeMap>().eq(SubjectTypeMap::getTypeId, id));
if (count > 0) {
return Result.FAIL(501, "当前分类下存在专题");
}
//删除数据权限关系
customerDataPermissionMapService.remove(Wrappers.<CustomerDataPermissionMap>lambdaQuery().eq(CustomerDataPermissionMap::getPermissionId, id));
sysUserDataPermissionService.remove(Wrappers.<SysUserDataPermission>lambdaQuery().eq(SysUserDataPermission::getPermissionId, id));
subjectTypeService.delete(id);
return Result.OK();
}
}
package com.zzsn.event.controller.plat;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Event;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.CommonService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IInfoSourceService;
import com.zzsn.event.service.ISubjectTypeService;
import com.zzsn.event.util.*;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.DisplayInfo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 平台事件管理页
*
* @author lkg
* @date 2024/5/7
*/
@Slf4j
@Api(tags = "平台事件管理")
@RestController
@RequestMapping("/plat/manage")
public class PlatEventManageController {
@Autowired
private IEventService eventService;
@Autowired
private ISubjectTypeService subjectTypeService;
@Autowired
private IInfoSourceService infoSourceService;
@Autowired
private EsService esService;
@Autowired
private EsOpUtil esOpUtil;
/**
* 事件页左侧树
*
* @author lkg
* @date 2024/4/29
*/
@GetMapping("/leftTypeTree")
public Result<?> leftTree() {
List<SubjectTreeVO> tree = subjectTypeService.eventAndTypeTree();
return Result.OK(tree);
}
/**
* 事件页左侧树
*
* @author lkg
* @date 2024/4/29
*/
@GetMapping("/leftCustomerTree")
public Result<?> leftCustomerTree() {
//获取当前登录用户
UserVo currentUser = UserUtil.getLoginUser();
Integer category = currentUser.getCategory();
String userId = null;
String customerId = null;
if (category.equals(Constants.COMMON_USER)) {
userId = currentUser.getUserId();
} else if (category.equals(Constants.ADMIN_USER)) {
customerId = currentUser.getCustomerId();
}
List<SubjectTreeVO> tree = subjectTypeService.subjectAndCustomerTree(userId, customerId);
return Result.OK(tree);
}
/**
* 分页列表-新平台管理
*
* @param subjectCondition 筛选条件
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/28
*/
@GetMapping("/newPlatPageList")
public Result<?> newPlatPageList(SubjectCondition subjectCondition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
//获取当前登录用户
UserVo currentUser = UserUtil.getLoginUser();
Integer category = currentUser.getCategory();
if (category.equals(Constants.COMMON_USER)) {
subjectCondition.setUserId(currentUser.getUserId());
} else if (category.equals(Constants.ADMIN_USER)) {
subjectCondition.setCustomerId(currentUser.getCustomerId());
}
IPage<EventNewPlatVO> pageList = eventService.newPlatPageList(subjectCondition, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 分页列表-新平台管理
*
* @param subjectCondition 筛选条件
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/28
*/
@GetMapping("/newPlatCustomerPageList")
public Result<?> newPlatCustomerPageList(SubjectCondition subjectCondition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
//获取当前登录用户
UserVo currentUser = UserUtil.getLoginUser();
Integer category = currentUser.getCategory();
if (category.equals(Constants.COMMON_USER)) {
subjectCondition.setUserId(currentUser.getUserId());
subjectCondition.setCustomerId(currentUser.getCustomerId());
} else if (category.equals(Constants.ADMIN_USER)) {
if (StringUtils.isEmpty(subjectCondition.getCustomerId()) || "0".equals(subjectCondition.getCustomerId())) {
subjectCondition.setCustomerId(currentUser.getCustomerId());
}
}
if ("0".equals(subjectCondition.getCustomerId())) {
subjectCondition.setCustomerId(null);
}
IPage<EventNewPlatVO> pageList = eventService.newPlatCustomerPageList(subjectCondition, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 专题绑定的信息源
*
* @param infoSourceCondition 筛选条件
* @param subjectId 专题id/专题分类id
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/5/7
*/
@GetMapping(value = "/bindInfoSourceList")
public Result<?> bindInfoSourceList(InfoSourceCondition infoSourceCondition,
@RequestParam(name = "subjectId", defaultValue = "0") String subjectId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
List<String> subjectIdList = new ArrayList<>();
if (!"0".equals(subjectId)) {
//查询类别id的所有明细id
if (StringUtils.isNotEmpty(subjectId)) {
List<String> typeIds = subjectTypeService.belowIdList(subjectId, null);
subjectIdList = eventService.selectSubjectByTypeIds(null, typeIds);
}
subjectIdList.add(subjectId);
}
IPage<InfoSourceVo> pageList = infoSourceService.bindInfoSourceList(infoSourceCondition, subjectIdList, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 专题直接绑定信息源-批量
*
* @param directBindInfoVO 参数封装
* @author lkg
* @date 2024/4/24
*/
@PostMapping("/directBindInfoSource")
public Result<?> directBindInfoSource(@RequestBody DirectBindInfoVO directBindInfoVO) {
eventService.directBindInfoSource(directBindInfoVO);
return Result.OK();
}
/**
* 专题直接解绑信息源-批量
*
* @param directBindInfoVO 参数封装
* @author lkg
* @date 2024/4/24
*/
@PostMapping("/directRemoveInfoSource")
public Result<?> directRemoveInfoSource(@RequestBody DirectBindInfoVO directBindInfoVO) {
eventService.directRemoveInfoSource(directBindInfoVO);
return Result.OK();
}
/**
* 专题直接屏蔽的信息源列表(不包括专题屏蔽的信息源组下的信息源)
*
* @param infoSourceCondition 筛选条件
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/30
*/
@GetMapping("/unBindInfoSourceList")
public Result<?> unBindInfoSourceList(InfoSourceCondition infoSourceCondition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
IPage<InfoSourceVo> pageList = infoSourceService.unBindSourcePageList(infoSourceCondition, pageNo, pageSize);
return Result.OK(pageList);
}
/**
* 删除专题下已屏蔽的信息源(即恢复绑定关系)
*
* @param subjectId 专题id
* @param sourceId 信息源id
* @author lkg
* @date 2024/4/30
*/
@GetMapping("/removeUnBindInfoSource")
public Result<?> removeUnBindInfoSource(@RequestParam String subjectId, @RequestParam String sourceId) {
eventService.removeUnBindInfoSource(subjectId, sourceId);
return Result.OK();
}
/**
* 专题关联信息源采集量统计-导出excel
*
* @param subjectId 专题id/专题分类id
* @param startDate 开始时间
* @param endDate 结束时间
* @author lkg
*/
@GetMapping("/exportStatisticsExcel")
public void exportStatisticsExcel(@RequestParam(name = "subjectId") String subjectId,
@RequestParam(name = "startDate") String startDate,
@RequestParam(name = "endDate") String endDate,
HttpServletResponse response) {
List<String> subjectIdList = new ArrayList<>();
try {
UserVo currentUser = UserUtil.getLoginUser();
String userId = null;
if (currentUser.getCategory().equals(Constants.COMMON_USER)) {
userId = currentUser.getUserId();
}
//查询类别id的所有明细id
if (StringUtils.isNotEmpty(subjectId) && !"0".equals(subjectId)) {
List<String> typeIds = subjectTypeService.belowIdList(subjectId, null);
subjectIdList = eventService.selectSubjectByTypeIds(userId, typeIds);
}
subjectIdList.add(subjectId);
List<List<String>> statistics = eventService.subjectStatistics(subjectIdList, startDate, endDate);
List<String> dateList = DateUtil.betweenDate(startDate, endDate);
List<String> headers = Stream.of("信息源id", "网站名称", "栏目名称", "栏目地址", "时间段内采集总量").collect(Collectors.toList());
headers.addAll(dateList);
XSSFWorkbook workbook = new XSSFWorkbook();
ExcelExportUtil.exportExcelData(workbook, 0, headers, statistics, "信息源采集信息汇总");
String name = "statisticsExcel.xls";
setResponseHeader(response, name);
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 事件对应采集库的资讯分页列表
*
* @param eventDataCondition 筛选条件
* @param sourceId 信息源id
* @param pageNo 当前页
* @param pageSize 返回条数
* @param column 排序字段
* @param order 排序方式
* @param isAll 是否全部
* @param video 是否视频
* @param crawler 采集器
* @param isSubject 是否专题
* @param source 来源(类别/客户)
* @author lkg
* @date 2024/5/6
*/
/* @GetMapping("/collectPageList")
public Result<?> collectPageList(InfoDataSearchCondition eventDataCondition,
@RequestParam(name = "sourceId", defaultValue = "") String sourceId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(name = "column", defaultValue = "common") String column,
@RequestParam(name = "order", defaultValue = "desc") String order,
@RequestParam(name = "isAll", defaultValue = "0") String isAll,
@RequestParam(name = "video", defaultValue = "") String video,
@RequestParam(name = "crawler", defaultValue = "") String crawler,
@RequestParam(name = "isSubject", defaultValue = "0") String isSubject,
@RequestParam(name = "source", defaultValue = "type") String source) {
UserVo currentUser = UserUtil.getLoginUser();
String userId = null;
String tenantId = currentUser.getCustomerId();
if (currentUser.getCategory().equals(Constants.COMMON_USER)) {
userId = currentUser.getUserId();
}
IPage<EventDataVO> pageList = esService.collectPageList(eventDataCondition, sourceId, pageNo, pageSize, column, order, isAll, video, crawler, userId, tenantId, isSubject, source);
return Result.OK(pageList);
}*/
/**
* 事件对应专题库的资讯分页列表
*
* @param subjectInfoVo 筛选条件
* @param userId 用户id
* @param video 是否视频
* @param pageNo 当前页
* @param isCustomer 是否客户
* @param pageSize 返回条数
* @param column 排序字段
* @param order 排序方式
* @param crawler 采集器
* @param isSubject 是否换题
* @param labelIds 关联的标签id
* @param labelTypeIds 企业标签id
* @param relationIds 企业信用代码
* @param sourceId 信息源id
* @author lkg
* @date 2024/5/6
*/
/*@GetMapping("/subjectPageList")
public Result<?> subjectPageList(InfoDataSearchCondition subjectInfoVo,
@RequestParam(name = "userId", defaultValue = "") String userId,
@RequestParam(name = "video", defaultValue = "") String video,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "isCustomer", defaultValue = "0") Integer isCustomer,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(name = "column", defaultValue = "common") String column,
@RequestParam(name = "order", defaultValue = "desc") String order,
@RequestParam(name = "crawler", defaultValue = "") String crawler,
@RequestParam(name = "isSubject", defaultValue = "1") String isSubject,
@RequestParam(name = "labelIds", required = false) String labelIds,
@RequestParam(name = "labelTypeIds", required = false) String labelTypeIds,
@RequestParam(name = "relationIds", required = false) String relationIds,
@RequestParam(name = "sourceId", required = false) String sourceId) throws Exception {
List<String> socialCreditCodeList = new ArrayList<>();
if (StringUtils.isNotEmpty(relationIds)) {
socialCreditCodeList = Arrays.asList(relationIds.split(","));
} else if (StringUtils.isNotEmpty(labelTypeIds)) {
socialCreditCodeList = eventService.codesByLabels(Arrays.asList(labelTypeIds.split(",")));
}
IPage<DisplayInfo> pageList = esService.subjectPageList(userId, subjectInfoVo, video, pageNo, pageSize, column, order, crawler, isSubject, labelIds, socialCreditCodeList, sourceId, isCustomer);
return Result.OK(pageList);
}*/
/**
* 专题绑定的关键词组-分页列表
*
* @param id 题id/专题分类id
* @author lkg
* @date 2024/5/7
*/
@GetMapping(value = "/bindKeyWordsList")
public Result<?> bindKeyWordsList(@RequestParam String id,
@RequestParam(required = false) String groupName,
@RequestParam(required = false) String wordName,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize) {
List<String> subjectIdList = new ArrayList<>();
try {
if (StringUtils.isNotEmpty(id) && !"0".equals(id)) {
List<String> typeIds = subjectTypeService.belowIdList(id, null);
subjectIdList = eventService.selectSubjectByTypeIds(null, typeIds);
}
subjectIdList.add(id);
} catch (Exception e) {
e.printStackTrace();
}
IPage<KeyWordsPage> page = eventService.bindKeyWordsList(subjectIdList, groupName, wordName, pageNo, pageSize);
return Result.OK(page);
}
/**
* 通过id查询(采集库)
*
* @param id 资讯id
* @param index 索引名称
* @author lkg
* @date 2024/5/8
*/
@GetMapping(value = "/collectionQueryById")
public Result<?> collectionQueryById(@RequestParam String id, @RequestParam String index) {
DisplayInfo info = (DisplayInfo) esOpUtil.getInfoById(index, id, DisplayInfo.class);
if (StringUtils.isNotEmpty(info.getContentWithTag())) {
String contentNoTag = Utility.TransferHTML2TextWithImg(info.getContentWithTag());
String contentNoTag2 = Utility.dealImg(contentNoTag);
info.setContent(contentNoTag2);
info.setContentWithTag(null);
}
info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate()));
return Result.OK(info);
}
/**
* 通过id查询(专题库)
*
* @param id 资讯id
* @param index 索引名称
* @author lkg
* @date 2024/5/8
*/
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam String id, @RequestParam String index) {
DisplayInfo displayInfo = (DisplayInfo) esOpUtil.getInfoById(index, id, DisplayInfo.class);
addReadNum(displayInfo,index);
if (StringUtils.isNotEmpty(displayInfo.getContentWithTag())) {
String contentNoTag = Utility.TransferHTML2TextWithImg(displayInfo.getContentWithTag());
String contentNoTag2 = Utility.dealImg(contentNoTag);
displayInfo.setContent(contentNoTag2);
}
displayInfo.setPublishDate(EsDateUtil.esFieldDateMapping(displayInfo.getPublishDate()));
return Result.OK(displayInfo);
}
private void addReadNum(DisplayInfo displayInfo,String index){
if (displayInfo != null) {
if (displayInfo.getReadNum() == 0) {
displayInfo.setReadNum(1L);
} else {
displayInfo.setReadNum(displayInfo.getReadNum() + 1);
}
esOpUtil.docUpdateById(index, displayInfo.getId(), JSON.toJSONString(displayInfo));
}
}
private void setResponseHeader(HttpServletResponse response, String name) {
try {
try {
name = new String(name.getBytes(), "ISO8859-1");
} catch (Exception e) {
e.printStackTrace();
}
response.setContentType("application/octet-stream;charset=ISO8859-1");
response.setHeader("Content-Disposition", "attachment;filename=" + name);
response.setHeader("Pargam", "no-cache");
response.setHeader("Cache-Control", "no-cache");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param event 条件封装
* @描述 查询事件列表
* @作者 hejinyu
* @创建时间 2024/12/26
**/
@PostMapping("/listAll")
public Result<?> listAll(@RequestBody Event event) {
LambdaQueryWrapper<Event> queryWrapper = Wrappers.lambdaQuery();
setListAllQueryWrapper(event, queryWrapper);
List<Event> list = eventService.list(queryWrapper);
return Result.OK(list);
}
/**
* @param event 条件封装
* @param pageNo
* @param pageSize
* @描述 查询事件列表(分页,产业链关联事件时查询用)
* @作者 hejinyu
* @创建时间 2024/12/26
**/
@PostMapping("/pageListAll")
public Result<?> pageListAll(@RequestBody Event event, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
LambdaQueryWrapper<Event> queryWrapper = Wrappers.lambdaQuery();
setListAllQueryWrapper(event, queryWrapper);
Page<Event> page = new Page<>(pageNo, pageSize);
IPage<Event> pageList = eventService.page(page, queryWrapper);
return Result.OK(pageList);
}
private void setListAllQueryWrapper(@RequestBody Event event, LambdaQueryWrapper<Event> queryWrapper) {
String eventType = event.getEventType();
String startDate = event.getStartDate();
String endDate = event.getEndDate();
String keyword = event.getKeyword();
queryWrapper.eq(StringUtils.isNotEmpty(eventType), Event::getEventType, eventType);
if (StringUtils.isNotEmpty(startDate)) {
queryWrapper.ge(Event::getCreateTime, startDate);
}
if (StringUtils.isNotEmpty(endDate)) {
queryWrapper.le(Event::getCreateTime, endDate);
}
if (StringUtils.isNotEmpty(keyword)) {
queryWrapper.and(q -> {
q.eq(Event::getEventType, keyword).or().like(Event::getEventName, keyword).or().eq(Event::getEventDescribe, keyword);
});
}
}
}
...@@ -10,10 +10,8 @@ import com.zzsn.event.entity.Event; ...@@ -10,10 +10,8 @@ import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.KeyWords; import com.zzsn.event.entity.KeyWords;
import com.zzsn.event.service.IEventService; import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IKeyWordsService; import com.zzsn.event.service.IKeyWordsService;
import com.zzsn.event.service.ISubjectInfoSourceMapService;
import com.zzsn.event.service.LabelEntityService; import com.zzsn.event.service.LabelEntityService;
import com.zzsn.event.util.RedisUtil; import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.UserUtil; import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo; import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
...@@ -44,7 +42,7 @@ import java.util.concurrent.CompletableFuture; ...@@ -44,7 +42,7 @@ import java.util.concurrent.CompletableFuture;
@Api(tags = "事件后台管理") @Api(tags = "事件后台管理")
@RestController @RestController
@RequestMapping("/plat/manage") @RequestMapping("/plat/manage")
public class EventManageController { public class NewEventManageController {
@Autowired @Autowired
private IEventService eventService; private IEventService eventService;
...@@ -116,11 +114,11 @@ public class EventManageController { ...@@ -116,11 +114,11 @@ public class EventManageController {
* @param id 事件id * @param id 事件id
* @return * @return
*/ */
@GetMapping(value = "/queryById") /*@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id") String id) { public Result<?> queryById(@RequestParam(name = "id") String id) {
EventVO eventVO = eventService.queryInfo(id); EventVO eventVO = eventService.queryInfo(id);
return Result.OK(eventVO); return Result.OK(eventVO);
} }*/
/** /**
......
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* Description: 客户-数据权限关系表
* Author: EDY
* Date: 2023/8/1
*/
@Data
@TableName("customer_data_permission_map")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="customer_data_permission_map-客户-数据权限关系表", description="客户-数据权限关系表")
public class CustomerDataPermissionMap {
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键id")
private String id;
@ApiModelProperty(value = "客户id")
private String customerId;
@ApiModelProperty(value = "数据权限id")
private String permissionId;
@ApiModelProperty(value = "数据权限类型(project-项目;subject-专题;group-信息源组;keyword-关键词组;channel-栏目)")
private String category;
@ApiModelProperty(value = "创建人")
private String createBy;
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 挖掘到的事件
* @TableName event_extract
*/
@Data
@TableName("event_extract")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="event_extract对象", description="挖掘事件")
public class EventExtract implements Serializable {
/**ID*/
@TableId(value = "id",type = IdType.ASSIGN_ID)
private String id;
/**
* 唯一id
*/
@TableField("unique_id")
private String uniqueId;
/**
* 名称
*/
@TableField("event_name")
private String eventName;
/**
* 事件类型
*/
@TableField("event_type")
private String eventType;
/**
* 开始时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("start_time")
private Date startTime;
/**
* 结束时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("end_time")
private Date endTime;
/**
* 自定义事件标签
*/
@TableField("event_label")
private String eventLabel;
/**
* 事件描述
*/
@TableField("event_describe")
private String eventDescribe;
/**
* 事件来源资讯id,多个逗号隔开
*/
@TableField("related_id")
private String relatedId;
/**
* 项目id
*/
@TableField("project_id")
private String projectId;
/**
* 任务id
*/
@TableField("task_id")
private String taskId;
/**
* 审核状态(2-不通过;1-通过;0-待审核)
*/
@TableField("check_status")
private Integer checkStatus;
/**
* 删除状态(1-删除;0-未删除)
*/
@TableField("delete_status")
private Integer deleteStatus;
/**
* 抽取时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("extract_time")
private Date extractTime;
/**
* 创建人id
*/
@TableField("create_by")
private String createBy;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("create_time")
private Date createTime;
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 事件抽取任务表
* @TableName event_extract_task
*/
@Data
@TableName("event_extract_task")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="event_extract_task对象", description="挖掘事件任务")
public class EventExtractTask implements Serializable {
/**
* 任务id
*/
@TableId(value = "id",type = IdType.ASSIGN_ID)
private String id;
/**
* 任务名称
*/
@TableField("task_name")
private String taskName;
/**
* 项目id
*/
@TableField("project_id")
private String projectId;
/**
* 栏目id,多个用逗号隔开
*/
@TableField("column_id")
private String columnId;
/**
* 数据状态(0:未审核 1:审核通过 3:暂定 4:删除)
*/
@TableField("data_status")
private Integer dataStatus;
/**
* 数据开始时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("start_time")
private Date startTime;
/**
* 数据结束时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("end_time")
private Date endTime;
/**
* 任务状态(1-开启;0-关闭)
*/
@TableField("task_status")
private Integer taskStatus;
/**
* 最近一次执行时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("last_update_time")
private Date lastUpdateTime;
/**
* 删除状态(1-删除;0-未删除)
*/
@TableField("delete_status")
private Integer deleteStatus;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@TableField("create_time")
private Date createTime;
/**
* 创建人
*/
@TableField("create_by")
private String createBy;
}
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @author lkg
* @description: 用户数据权限
* @date 2022/6/20 11:59
*/
@Data
@TableName("sys_user_data_permission")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="sys_user_data_permission对象", description="用户数据权限表")
public class SysUserDataPermission implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**用户id*/
@Excel(name = "用户id", width = 15)
@ApiModelProperty(value = "用户id")
private String userId;
/**权限id*/
@Excel(name = "权限id", width = 15)
@ApiModelProperty(value = "权限id")
private String permissionId;
/**权限类别*/
@Excel(name = "权限类别", width = 15)
@ApiModelProperty(value = "权限类别")
private String category;
}
...@@ -3,6 +3,7 @@ package com.zzsn.event.es; ...@@ -3,6 +3,7 @@ package com.zzsn.event.es;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -1257,7 +1258,30 @@ public class EsService { ...@@ -1257,7 +1258,30 @@ public class EsService {
return data; return data;
} }
public List<SubjectDataVo> listByIds(List<String> ids) {
List<SubjectDataVo> dataList = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//创建查询对象
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.termsQuery("id", ids));
searchSourceBuilder.query(boolQuery);
searchRequest.source(searchSourceBuilder);
try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
SearchHit[] hits = searchResponse.getHits().getHits();
if (hits != null && hits.length > 0) {
for (SearchHit hit : hits) {
String sourceAsString = hit.getSourceAsString();
SubjectDataVo subjectDataVo = JSONObject.parseObject(sourceAsString, SubjectDataVo.class);
dataList.add(subjectDataVo);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return dataList;
}
/** /**
* 来源占比-专题分析页 * 来源占比-专题分析页
* *
......
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.CustomerDataPermissionMap;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CustomerDataPermissionMapMapper extends BaseMapper<CustomerDataPermissionMap> {
}
package com.zzsn.event.mapper;
import com.zzsn.event.entity.EventExtract;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.vo.EventExtractVO;
import com.zzsn.event.vo.EventFrontVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author lenovo
* @description 针对表【event_extract(事件)】的数据库操作Mapper
* @createDate 2024-09-07 18:00:28
* @Entity com.zzsn.event.entity.EventExtract
*/
@Mapper
public interface EventExtractMapper extends BaseMapper<EventExtract> {
/**
* 伪事件信息列表
*
* @param searchWord 搜索词
* @param eventName 事件名称
* @param eventType 时间分类
* @param startTime 开始时间
* @param endTime 结束时间
* @param checkStatus 审核状态(2-不通过;1-通过;0-待审核)
* @param offset 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/9/9
*/
List<EventExtractVO> pageList(@Param("taskId") String taskId, @Param("searchWord") String searchWord,
@Param("eventName") String eventName,
@Param("startTime") String startTime, @Param("endTime") String endTime,
@Param("eventType") String eventType, @Param("checkStatus") Integer checkStatus,
@Param("column") String column, @Param("sortType") String sortType,
@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
/**
* 伪事件信息总数量
*
* @param searchWord 搜索词
* @param eventName 事件名称
* @param eventType 时间分类
* @param startTime 开始时间
* @param endTime 结束时间
* @param checkStatus 审核状态(2-不通过;1-通过;0-待审核)
* @author lkg
* @date 2024/9/9
*/
Long totalCount(@Param("taskId") String taskId, @Param("searchWord") String searchWord,
@Param("eventName") String eventName,
@Param("startTime") String startTime, @Param("endTime") String endTime,
@Param("eventType") String eventType, @Param("checkStatus") Integer checkStatus);
/**
* 自动追踪事件列表-门户
*
* @param projectId 项目id
* @param eventName 事件名称
* @param eventTypes 事件分类id集合
* @param offset 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/9/9
*/
List<EventFrontVO> frontDigPageList(@Param("projectId") String projectId, @Param("eventName") String eventName,
@Param("eventTypes") List<String> eventTypes,
@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
/**
* 自动追踪事件总数量-门户
*
* @param projectId 项目id
* @param eventName 事件名称
* @param eventTypes 事件分类id集合
* @author lkg
* @date 2024/9/9
*/
Long frontDigTotalCount(@Param("projectId") String projectId, @Param("eventName") String eventName,
@Param("eventTypes") List<String> eventTypes);
}
package com.zzsn.event.mapper;
import com.zzsn.event.entity.EventExtractTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.vo.EventExtractTaskVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author lenovo
* @description 针对表【event_extract_task(事件抽取任务表)】的数据库操作Mapper
* @createDate 2024-09-13 11:31:47
* @Entity com.zzsn.event.entity.EventExtractTask
*/
@Mapper
public interface EventExtractTaskMapper extends BaseMapper<EventExtractTask> {
/**
* 事件抽取任务信息列表
*
* @param projectId 项目id
* @param searchWord 搜索词
* @param taskName 任务名称
* @param startTime 开始时间
* @param endTime 结束时间
* @param offset 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/9/13
*/
List<EventExtractTaskVO> pageList(@Param("projectId") String projectId, @Param("searchWord") String searchWord,
@Param("taskName") String taskName, @Param("startTime") String startTime, @Param("endTime") String endTime,
@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
/**
* 事件抽取任务信息总数量
*
* @param projectId 项目id
* @param searchWord 搜索词
* @param taskName 任务名称
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2024/9/13
*/
Long totalCount(@Param("projectId") String projectId, @Param("searchWord") String searchWord,
@Param("taskName") String taskName, @Param("startTime") String startTime, @Param("endTime") String endTime);
}
...@@ -2,6 +2,7 @@ package com.zzsn.event.mapper; ...@@ -2,6 +2,7 @@ package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.Event; import com.zzsn.event.entity.Event;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -160,7 +161,34 @@ public interface EventMapper extends BaseMapper<Event> { ...@@ -160,7 +161,34 @@ public interface EventMapper extends BaseMapper<Event> {
*/ */
List<EventNewPlatVO> newPlatPageList(@Param("subjectCondition") SubjectCondition subjectCondition, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize); List<EventNewPlatVO> newPlatPageList(@Param("subjectCondition") SubjectCondition subjectCondition, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
/**
* 总数量(专题分类)-新平台管理
*
* @param subjectCondition 筛选条件
* @author lkg
* @date 2024/4/28
*/
Integer newPlatCount(@Param("subjectCondition") SubjectCondition subjectCondition);
/**
* 分页列表(客户)-新平台管理
*
* @param subjectCondition 筛选条件
* @param offset 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/30
*/
List<EventNewPlatVO> newPlatCustomerPageList(@Param("subjectCondition") SubjectCondition subjectCondition, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
/**
* 总数量(客户)-新平台管理
*
* @param subjectCondition 筛选条件
* @author lkg
* @date 2024/4/28
*/
Integer newPlatCustomerCount(@Param("subjectCondition") SubjectCondition subjectCondition);
/** /**
* 热点事件列表-前10 * 热点事件列表-前10
...@@ -236,6 +264,62 @@ public interface EventMapper extends BaseMapper<Event> { ...@@ -236,6 +264,62 @@ public interface EventMapper extends BaseMapper<Event> {
*/ */
List<EventVO> eventList(@Param("eventIdList") List<String> eventIdList); List<EventVO> eventList(@Param("eventIdList") List<String> eventIdList);
/**
* 专题绑定关键词数量
*
* @param idList 专题id集合
* @author lkg
* @date 2024/4/28
*/
List<SubjectPage> bindKeywordCountList(@Param("idList") List<String> idList);
/**
* 专题绑定的信息源集合
*
* @param subjectIds 专题id
* @author lkg
* @date 2024/4/24
*/
List<SubjectSourceVO> bindSourceList(@Param("subjectIds") List<String> subjectIds);
/**
* 专题绑定的信息源集合
*
* @param subjectIds 专题id
* @author lkg
* @date 2024/4/24
*/
List<SubjectSourceVO> excludeSourceList(@Param("subjectIds") List<String> subjectIds);
/**
* 项目列表
*
* @param userId 用户id
* @param customerId 客户id
* @author lkg
* @date 2024/4/29
*/
List<Node> projectList(@Param("userId") String userId, @Param("customerId") String customerId);
/**
* 分类下的事件id集合
*
* @param userId 用户id
* @param typeIds 分类id集合
* @author lkg
* @date 2024/5/6
*/
List<String> selectSubjectByTypeIds(@Param("userId") String userId, @Param("typeIds") List<String> typeIds);
/**
* 用户下的事件id集合
*
* @param userId 用户id
* @param customerId 客户id
* @author lkg
* @date 2024/5/6
*/
List<String> selectSubjectWithCustomer(@Param("userId") String userId, @Param("customerId") String customerId);
/** /**
* 专题绑定关键词的id集合 * 专题绑定关键词的id集合
...@@ -245,4 +329,70 @@ public interface EventMapper extends BaseMapper<Event> { ...@@ -245,4 +329,70 @@ public interface EventMapper extends BaseMapper<Event> {
* @date 2024/5/6 * @date 2024/5/6
*/ */
List<String> bindKeyWordsIdList(@Param("subjectIds") List<String> subjectIds); List<String> bindKeyWordsIdList(@Param("subjectIds") List<String> subjectIds);
/**
* 专题绑定模型信息列表
*
* @param subjectIds 专题id集合
* @author lkg
* @date 2024/5/6
*/
List<LabelModelVo> selectLabelModelBySubjectId(@Param("subjectIds") List<String> subjectIds);
/**
* 企业标签下的企业信用代码集合
*
* @param labelIds 企业标签id集合
* @author lkg
* @date 2024/5/6
*/
List<String> codesByLabels(@Param("labelIds") List<String> labelIds);
/**
* 判断信息源是否在专题绑定的信息源组下
*
* @param subjectId 专题id
* @param sourceId 信息源id
* @author lkg
* @date 2024/4/24
*/
int ynBelowBindGroup(@Param("subjectId") String subjectId, @Param("sourceId") String sourceId);
/**
* 判断信息源是否在专题排除的信息源组下
*
* @param subjectId 专题id
* @param sourceId 信息源id
* @author lkg
* @date 2024/4/24
*/
int ynBelowExcludeGroup(@Param("subjectId") String subjectId, @Param("sourceId") String sourceId);
/**
* 专题绑定关键词信息-分页列表
*
* @param subjectIds 专题id集合
* @param groupName 词组名称
* @param wordName 关键词名称
* @param offset 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/5/7
*/
List<KeyWordsPage> bindKeyWordsList(@Param("subjectIds") List<String> subjectIds,
@Param("groupName") String groupName, @Param("wordName") String wordName,
@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
/**
* 专题绑定关键词信息-总数量
*
* @param subjectIds 专题id集合
* @param groupName 词组名称
* @param wordName 关键词名称
* @author lkg
* @date 2024/5/7
*/
Long bindKeyWordsCount(@Param("subjectIds") List<String> subjectIds, @Param("groupName") String groupName, @Param("wordName") String wordName);
} }
package com.zzsn.event.mapper;
import com.zzsn.event.util.tree.Node;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 其他数据
*
* @author lkg
* @date 2024/9/13
*/
@Mapper
public interface OtherDataMapper {
/**
* 栏目集合
*
* @param columnIds 栏目id集合
* @author lkg
* @date 2024/9/13
*/
List<Node> columnList(@Param("columnIds") List<String> columnIds);
/**
* 项目集合
*
* @author lkg
* @date 2024/9/13
*/
List<Node> projectList();
}
...@@ -32,6 +32,25 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> { ...@@ -32,6 +32,25 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
List<Node> enableList(@Param("category") Integer category,@Param("username") String createBy); List<Node> enableList(@Param("category") Integer category,@Param("username") String createBy);
/** /**
* 可用的专题和客户列表
*
* @param userId 用户id
* @param customerId 客户id
* @author lkg
* @date 2024/4/30
*/
List<SubjectTreeVO> subjectAndCustomerTree(@Param("userId") String userId, @Param("customerId") String customerId);
/**
* 可用客户信息列表
*
* @param customerId 客户id
* @author lkg
* @date 2024/4/30
*/
List<SubjectTreeVO> enableCustomerList(@Param("customerId") String customerId);
/**
* 更新分类是否有子节点状态 * 更新分类是否有子节点状态
* *
* @param id 分类id * @param id 分类id
...@@ -102,4 +121,6 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> { ...@@ -102,4 +121,6 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
* @date 2024/12/20 * @date 2024/12/20
*/ */
Integer typeBindEventCount(@Param("typeIds") List<String> typeIds); Integer typeBindEventCount(@Param("typeIds") List<String> typeIds);
List<SubjectTreeVO> eventAndTypeTree();
} }
package com.zzsn.event.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzsn.event.entity.SysUserDataPermission;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lkg
* @description:
* @date 2022/6/20 14:10
*/
@Mapper
public interface SysUserDataPermissionMapper extends BaseMapper<SysUserDataPermission> {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzsn.event.mapper.EventExtractMapper">
<resultMap id="BaseResultMap" type="com.zzsn.event.entity.EventExtract">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="eventName" column="event_name" jdbcType="VARCHAR"/>
<result property="eventType" column="event_type" jdbcType="INTEGER"/>
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
<result property="eventLabel" column="event_label" jdbcType="VARCHAR"/>
<result property="eventDescribe" column="event_describe" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="pageList" resultType="com.zzsn.event.vo.EventExtractVO">
select t2.type_name,t1.id,t1.event_name,t1.event_type,t1.event_label,t1.extract_time,t1.check_status,t1.related_id
from event_extract t1
inner join event_category t2 on t1.event_type =t2.id
where t1.task_id = #{taskId} and t1.delete_status = 0
<if test="eventName!=null and eventName != ''">
and t1.event_name like CONCAT('%',#{eventName},'%')
</if>
<if test="eventType!=null and eventType != ''">
and t1.event_type = #{eventType}
</if>
<if test="startTime!=null and startTime != ''">
and t1.extract_time >= #{startTime}
</if>
<if test="endTime!=null and endTime != ''">
and t1.extract_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="searchWord != null and searchWord != ''">
and CONCAT_WS(',',t1.event_name,t1.event_label,t2.type_name) like concat('%',concat(#{searchWord},'%'))
</if>
<if test="checkStatus != null">
and t1.check_status = #{checkStatus}
</if>
<choose>
<when test="column != null and column != ''">
order by ${column}
<if test="sortType != null and sortType != ''">
${sortType}
</if>
</when>
<otherwise>
order by t1.extract_time desc
</otherwise>
</choose>
limit #{offset}, #{pageSize}
</select>
<select id="totalCount" resultType="Long">
select count(1) from event_extract t1
inner join event_category t2 on t1.event_type =t2.id
where t1.task_id = #{taskId} and t1.delete_status = 0
<if test="eventName!=null and eventName != ''">
and t1.event_name like CONCAT('%',#{eventName},'%')
</if>
<if test="eventType!=null and eventType != ''">
and t1.event_type = #{eventType}
</if>
<if test="startTime!=null and startTime != ''">
and t1.extract_time >= #{startTime}
</if>
<if test="endTime!=null and endTime != ''">
and t1.extract_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="searchWord != null and searchWord != ''">
and CONCAT_WS(',',t1.event_name,t1.event_label,t2.type_name) like concat('%',concat(#{searchWord},'%'))
</if>
<if test="checkStatus != null">
and t1.check_status = #{checkStatus}
</if>
</select>
<select id="frontDigPageList" resultType="com.zzsn.event.vo.EventFrontVO">
select t2.type_name,t1.id,t1.event_name,t1.extract_time as publishDate
from event_extract t1
inner join event_category t2 on t1.event_type =t2.id
where t1.check_status = 1 and t1.delete_status = 0
<if test="projectId!=null and projectId != ''">
and t1.project_id = #{projectId}
</if>
<if test="eventName!=null and eventName != ''">
and t1.event_name like CONCAT('%',#{eventName},'%')
</if>
<if test="eventTypes != null and eventTypes.size() > 0">
and t1.event_type in
<foreach collection="eventTypes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by t1.extract_time desc
limit #{offset}, #{pageSize}
</select>
<select id="frontDigTotalCount" resultType="Long">
select count(1) from event_extract t1
where t1.check_status = 1 and t1.delete_status = 0
<if test="projectId!=null and projectId != ''">
and t1.project_id = #{projectId}
</if>
<if test="eventName!=null and eventName != ''">
and t1.event_name like CONCAT('%',#{eventName},'%')
</if>
<if test="eventTypes != null and eventTypes.size() > 0">
and t1.event_type in
<foreach collection="eventTypes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzsn.event.mapper.EventExtractTaskMapper">
<resultMap id="BaseResultMap" type="com.zzsn.event.entity.EventExtractTask">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="taskName" column="task_name" jdbcType="VARCHAR"/>
<result property="projectId" column="project_id" jdbcType="VARCHAR"/>
<result property="columnId" column="column_id" jdbcType="VARCHAR"/>
<result property="dataStatus" column="data_status" jdbcType="INTEGER"/>
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
<result property="taskStatus" column="task_status" jdbcType="INTEGER"/>
<result property="lastUpdateTime" column="last_update_time" jdbcType="TIMESTAMP"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
</resultMap>
<select id="pageList" resultType="com.zzsn.event.vo.EventExtractTaskVO">
select task.id,task.task_name,task.column_id,task.task_status,task.last_update_time,task.create_time,p.project_name
from event_extract_task task inner join project p on task.project_id = p.id
where task.delete_status = 0
<if test="projectId != null and projectId != ''">
and task.project_id = #{projectId}
</if>
<if test="taskName != null and taskName != ''">
and task.task_name like concat('%',concat(#{taskName},'%'))
</if>
<if test="startTime != null and startTime != ''">
and task.create_time >= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and task.create_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="searchWord != null and searchWord != ''">
and CONCAT_WS(',',task.task_name,p.project_name) like concat('%',concat(#{searchWord},'%'))
</if>
order by task.create_time desc
limit #{offset},#{pageSize}
</select>
<select id="totalCount" resultType="Long">
select count(1) from event_extract_task task inner join project p on task.project_id = p.id
where task.delete_status = 0
<if test="projectId != null and projectId != ''">
and task.project_id = #{projectId}
</if>
<if test="taskName != null and taskName != ''">
and task.task_name like concat('%',concat(#{taskName},'%'))
</if>
<if test="startTime != null and startTime != ''">
and task.create_time >= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and task.create_time <![CDATA[ <= ]]> #{endTime}
</if>
<if test="searchWord != null and searchWord != ''">
and CONCAT_WS(',',task.task_name,p.project_name) like concat('%',concat(#{searchWord},'%'))
</if>
</select>
</mapper>
...@@ -328,6 +328,155 @@ ...@@ -328,6 +328,155 @@
order by d.sort_order,d.create_time desc order by d.sort_order,d.create_time desc
limit #{offset}, #{pageSize} limit #{offset}, #{pageSize}
</select> </select>
<select id="newPlatCount" resultType="Integer">
select count(1) from (
SELECT distinct d.id
from
<choose>
<when test="subjectCondition.userId !=null and subjectCondition.userId != ''">
( select s.* from event s inner join sys_user_data_permission dp
on s.id=dp.permission_id and dp.user_id = #{subjectCondition.userId}
)
</when>
<when test="subjectCondition.customerId !=null and subjectCondition.customerId != ''">
( select s.* from event s inner join customer_data_permission_map m on s.id = m.permission_id
and m.customer_id = #{subjectCondition.customerId}
)
</when>
<otherwise>
event
</otherwise>
</choose>
d
INNER JOIN
(
select stm.subject_id from subject_type_map stm
where 1=1
<if test="subjectCondition.typeIds!=null and subjectCondition.typeIds.size()>0">
and stm.type_id in
<foreach collection="subjectCondition.typeIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
) m
on d.id = m.subject_id
INNER JOIN
(
select psm.subject_id from project_subject_map psm
where 1=1
<if test="subjectCondition.projectId!=null and subjectCondition.projectId != ''">
and psm.id = #{subjectCondition.projectId}
</if>
) n
on d.id = n.subject_id
where 1 = 1
<if test="subjectCondition.id !=null and subjectCondition.id !=''">
and d.id =#{subjectCondition.id}
</if>
<if test="subjectCondition.subjectName!=null and subjectCondition.subjectName != ''">
and d.event_name like CONCAT('%',#{subjectCondition.subjectName},'%')
</if>
<if test="subjectCondition.startTime != null and subjectCondition.startTime != ''">
and d.create_time >= #{subjectCondition.startTime}
</if>
<if test="subjectCondition.endTime != null and subjectCondition.endTime != ''">
and d.create_time <![CDATA[ <= ]]> #{subjectCondition.endTime}
</if>
) x
</select>
<select id="newPlatCustomerPageList" resultType="com.zzsn.event.vo.EventNewPlatVO">
select distinct x.id,x.event_name,x.start_time,x.end_time,st.type_name as subjectTypeName,p.project_name from (
select c.id, c.event_name,c.create_time,c.start_time,c.end_time,c.sort_order
from event c inner join
(
select a.id, b.permission_id
from customer_data_permission_map b
inner join customer a on b.customer_id = a.id and a.status = 1
and a.is_delete = 0 and b.category = 'subject'
<if test="subjectCondition.userId !=null and subjectCondition.userId != ''">
and b.permission_id in
(
select permission_id from sys_user_data_permission where category = 'subject'
and user_id = #{subjectCondition.userId}
)
</if>
) m
on c.id = m.permission_id
where c.status = 1
<if test="subjectCondition.customerId !=null and subjectCondition.customerId != ''">
and m.id = #{subjectCondition.customerId}
</if>
<if test="subjectCondition.id !=null and subjectCondition.id !=''">
and c.id =#{subjectCondition.id}
</if>
<if test="subjectCondition.subjectName!=null and subjectCondition.subjectName != ''">
and c.event_name like CONCAT('%',#{subjectCondition.subjectName},'%')
</if>
<if test="subjectCondition.startTime != null and subjectCondition.startTime != ''">
and c.create_time >= #{subjectCondition.startTime}
</if>
<if test="subjectCondition.endTime != null and subjectCondition.endTime != ''">
and c.create_time <![CDATA[ <= ]]> #{subjectCondition.endTime}
</if>
) x
left join subject_type_map stm on stm.subject_id = x.id
left join subject_type st on stm.type_id = st.id
left join project_subject_map psm on psm.subject_id = x.id
left join project p on psm.project_id = p.id
where 1=1
<if test="subjectCondition.projectId!=null and subjectCondition.projectId != ''">
and p.id = #{subjectCondition.projectId}
</if>
order by x.sort_order, x.create_time desc
limit #{offset},#{pageSize}
</select>
<select id="newPlatCustomerCount" resultType="Integer">
select count(1) from (
select distinct x.id from (
select c.id, c.event_name,c.create_time
from event c inner join
(
select a.id, b.permission_id
from customer_data_permission_map b
inner join customer a on b.customer_id = a.id and a.status = 1
and a.is_delete = 0 and b.category = 'subject'
<if test="subjectCondition.userId !=null and subjectCondition.userId != ''">
and b.permission_id in
(
select permission_id from sys_user_data_permission where category = 'subject'
and user_id = #{subjectCondition.userId}
)
</if>
) m
on c.id = m.permission_id
where c.status = 1
<if test="subjectCondition.customerId !=null and subjectCondition.customerId != ''">
and m.id = #{subjectCondition.customerId}
</if>
<if test="subjectCondition.id !=null and subjectCondition.id !=''">
and c.id =#{subjectCondition.id}
</if>
<if test="subjectCondition.subjectName!=null and subjectCondition.subjectName != ''">
and c.event_name like CONCAT('%',#{subjectCondition.subjectName},'%')
</if>
<if test="subjectCondition.startTime != null and subjectCondition.startTime != ''">
and c.create_time >= #{subjectCondition.startTime}
</if>
<if test="subjectCondition.endTime != null and subjectCondition.endTime != ''">
and c.create_time <![CDATA[ <= ]]> #{subjectCondition.endTime}
</if>
) x
left join subject_type_map stm on stm.subject_id = x.id
left join subject_type st on stm.type_id = st.id
left join project_subject_map psm on psm.subject_id = x.id
left join project p on psm.project_id = p.id
where 1=1
<if test="subjectCondition.projectId!=null and subjectCondition.projectId != ''">
and p.id = #{subjectCondition.projectId}
</if>
) y
</select>
<select id="topEventList" resultType="com.zzsn.event.vo.EventTopVO"> <select id="topEventList" resultType="com.zzsn.event.vo.EventTopVO">
select distinct a.* from( select distinct a.* from(
...@@ -493,6 +642,110 @@ ...@@ -493,6 +642,110 @@
</if> </if>
</select> </select>
<select id="bindKeywordCountList" resultType="com.zzsn.event.vo.SubjectPage">
select subject_id as id , count(1) keyWordsNum from subject_keywords_map where subject_id in
<foreach collection="idList" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
group By subject_id
</select>
<select id="bindSourceList" resultType="com.zzsn.event.vo.SubjectSourceVO">
select distinct x.source_id,x.subject_id from (
select m.source_id,n.subject_id from subject_info_source_map n
inner join info_source_group_map m on n.source_id = m.group_id
where n.type in(2,5)
<if test="subjectIds != null and subjectIds.size() > 0">
and n.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select sm.source_id,sm.subject_id from subject_info_source_map sm where type = 1
<if test="subjectIds != null and subjectIds.size() > 0">
and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
) x
</select>
<select id="excludeSourceList" resultType="com.zzsn.event.vo.SubjectSourceVO">
select distinct x.source_id,x.subject_id from (
select m.source_id,n.subject_id from subject_info_source_map n
inner join info_source_group_map m on n.source_id = m.group_id
where n.type = 4
<if test="subjectIds != null and subjectIds.size() > 0">
and n.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
union
select sm.source_id,sm.subject_id from subject_info_source_map sm where type = 3
<if test="subjectIds != null and subjectIds.size() > 0">
and sm.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
) x
</select>
<select id="projectList" resultType="com.zzsn.event.util.tree.Node">
select s.id,s.project_name as name from project s
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on s.id=dp.permission_id and dp.user_id = #{userId}
</if>
<if test="customerId !=null and customerId != ''">
inner join customer_data_permission_map mp on s.id=mp.permission_id and mp.customer_id = #{customerId}
</if>
where s.is_delete = 0 and s.status = 1
</select>
<select id="selectSubjectByTypeIds" resultType="String">
select distinct a.id from event a
<if test="userId!=null and userId != ''">
inner join sys_user_data_permission b on b.permission_id = a.id and b.category = 'subject' and b.user_id =
#{userId}
</if>
inner join subject_type_map c on c.subject_id = a.id
where 1=1
<if test="typeIds!=null and typeIds.size()>0">
and c.type_id in
<foreach collection="typeIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="selectSubjectWithCustomer" resultType="String">
select distinct a.id
<choose>
<when test="customerId!=null and customerId != ''">
from customer_data_permission_map b
inner join event a on b.permission_id = a.id
inner join subject_type_map c on c.subject_id = b.permission_id
inner join project_subject_map d on b.permission_id = d.subject_id
inner join customer_project_map e on d.project_id = e.project_id
where b.category = 'subject' and b.customer_id = #{customerId}
</when>
<when test="userId!=null and userId != ''">
from sys_user_data_permission b
inner join event a on b.permission_id = a.id
inner join subject_type_map c on c.subject_id = b.permission_id
inner join project_subject_map d on b.permission_id = d.subject_id
inner join customer_project_map e on d.project_id = e.project_id
where b.category = 'subject' and b.user_id = #{userId}
</when>
<otherwise>
from event a
</otherwise>
</choose>
</select>
<select id="bindKeyWordsIdList" resultType="String"> <select id="bindKeyWordsIdList" resultType="String">
select distinct b.id from key_words b select distinct b.id from key_words b
...@@ -507,4 +760,101 @@ ...@@ -507,4 +760,101 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="selectLabelModelBySubjectId" resultType="com.zzsn.event.vo.LabelModelVo">
SELECT distinct a.subject_id,b.id as modelId,b.service_name as modelServiceName,b.label_id as
labelId,c.label_mark,c.label_name,c.label_type
FROM subject_model_map a
inner JOIN clb_algorithm_model b ON a.model_id = b.id and a.sign = 1
LEFT JOIN sys_base_label_type c on c.id = b.label_id
WHERE b.service_name is not null and a.type = 3
<if test="subjectIds != null and subjectIds.size() > 0">
and a.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="codesByLabels" resultType="String">
select e.social_credit_code from sys_base_enterprise e
inner join sys_base_label_type_map m on e.social_credit_code = m.relation_id
where 1=1
<if test="labelIds!=null and labelIds.size()>0">
and m.label_id in
<foreach collection="labelIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
group by e.social_credit_code
</select>
<select id="ynBelowBindGroup" resultType="Integer">
select count(1)
from subject_info_source_map n
left join info_source_group_map m on n.source_id = m.group_id
where n.type in (2, 5)
and n.subject_id = #{subjectId}
and m.source_id = #{sourceId}
</select>
<select id="ynBelowExcludeGroup" resultType="Integer">
select count(1)
from subject_info_source_map n
left join info_source_group_map m on n.source_id = m.group_id
where n.type = 4
and n.subject_id = #{subjectId}
and m.source_id = #{sourceId}
</select>
<select id="bindKeyWordsList" resultType="com.zzsn.event.vo.KeyWordsPage">
select x.* from (
SELECT b.*, d.id as keyWordsTypeId, d.type_name as keyWordTypeNames, a.type as type, a.id as subjectKeyWordId
FROM key_words b
LEFT JOIN subject_keywords_map a ON a.keywords_id = b.id
LEFT JOIN keywords_type_map c ON b.id = c.keywords_id
LEFT JOIN keywords_type d ON d.id = c.type_id
where 1=1
<if test="subjectIds != null and subjectIds.size() > 0">
and a.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
group by b.id
) x
where 1=1
<if test="groupName != null and groupName !=''">
and x.words_name like CONCAT('%',#{groupName},'%')
</if>
<if test="wordName != null and wordName !=''">
and x.key_word like CONCAT('%',#{wordName},'%')
</if>
order by x.create_time desc
limit #{offset},#{pageSize}
</select>
<select id="bindKeyWordsCount" resultType="Long">
select count(1) from (
SELECT b.*, d.id as keyWordsTypeId, d.type_name as keyWordTypeNames, a.type as type, a.id as subjectKeyWordId
FROM key_words b
LEFT JOIN subject_keywords_map a ON a.keywords_id = b.id
LEFT JOIN keywords_type_map c ON b.id = c.keywords_id
LEFT JOIN keywords_type d ON d.id = c.type_id
where 1=1
<if test="subjectIds != null and subjectIds.size() > 0">
and a.subject_id in
<foreach collection="subjectIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
group by b.id
) x
where 1=1
<if test="groupName != null and groupName !=''">
and x.words_name like CONCAT('%',#{groupName},'%')
</if>
<if test="wordName != null and wordName !=''">
and x.key_word like CONCAT('%',#{wordName},'%')
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzsn.event.mapper.OtherDataMapper">
<select id="columnList" resultType="com.zzsn.event.util.tree.Node">
select id,channel_name as name from sys_base_channel where id not in(0,1)
<if test="columnIds != null and columnIds.size() > 0">
and id in
<foreach collection="columnIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by create_time
</select>
<select id="projectList" resultType="com.zzsn.event.util.tree.Node">
select id,project_name as name from project where is_delete = 0 order by create_time
</select>
</mapper>
...@@ -122,4 +122,56 @@ ...@@ -122,4 +122,56 @@
#{typeId} #{typeId}
</foreach> </foreach>
</select> </select>
<select id="subjectAndCustomerTree" resultType="com.zzsn.event.vo.SubjectTreeVO">
select c.id, c.event_name as name, m.id as pid, 'true' as ynSubject,c.start_time,c.end_time
from event c inner join
(
select a.id, b.permission_id
from customer_data_permission_map b
inner join customer a on b.customer_id = a.id and a.status = 1
and a.is_delete = 0 and b.category = 'subject'
<if test="userId !=null and userId != ''">
and b.permission_id in
(
select permission_id from sys_user_data_permission where category = 'subject'
where user_id = #{userId}
)
</if>
) m
on c.id = m.permission_id
where c.status = 1
<if test="customerId !=null and customerId != ''">
and m.id = #{customerId}
</if>
order by c.create_time desc
</select>
<select id="enableCustomerList" resultType="com.zzsn.event.vo.SubjectTreeVO">
select id,customer_name as name,'0' as pid,'false' as ynSubject from customer where status = 1 and is_delete = 0
<if test="customerId!=null and customerId != ''">
and id = #{customerId}
</if>
</select>
<select id="eventAndTypeTree" resultType="com.zzsn.event.vo.SubjectTreeVO">
select x.* from (
select s.id,s.type_name as name,s.pid,'false' as ynSubject,null as startTime,null as endTime,s.create_time
from subject_type s
where s.category = 2 and s.status = 1
union
select n.id,n.name,m.id as pid,'true' as ynSubject,n.start_time,n.end_time,n.create_time from
(
select s.id,s.type_name as name,s.pid from subject_type s
where s.category = 2 and s.status = 1
) m
inner join subject_type_map stm on m.id = stm.type_id
inner join
(
select s.id,s.event_name as name,s.start_time,s.end_time,s.create_time from event s
where s.status = 1
) n on stm.subject_id = n.id
) x
order by x.create_time desc
</select>
</mapper> </mapper>
\ No newline at end of file
package com.zzsn.event.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.EventExtract;
import com.zzsn.event.vo.EventExtractVO;
import com.zzsn.event.vo.EventFrontVO;
/**
* @author lenovo
* @description 针对表【event_extract(事件)】的数据库操作Service
* @createDate 2024-09-07 18:00:28
*/
public interface EventExtractService extends IService<EventExtract> {
/**
* 伪事件信息分页列表
*
* @param taskId 任务id
* @param searchWord 搜索词
* @param eventName 事件名称
* @param eventType 时间分类
* @param startTime 开始时间
* @param endTime 结束时间
* @param checkStatus 审核状态(2-不通过;1-通过;0-待审核)
* @param column 排序字段
* @param sortType 排序方式
* @param pageNo 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/9/9
*/
IPage<EventExtractVO> pageList(String taskId, String searchWord, String eventName, String startTime, String endTime,
String eventType, Integer checkStatus, String column, String sortType, Integer pageNo, Integer pageSize);
/**
* 自动追踪事件分页列表-门户
*
* @param projectId 项目id
* @param eventName 事件名称
* @param eventType 时间分类
* @param pageNo 偏移量
* @param pageSize 返回条数
* @author lkg
* @date 2024/9/9
*/
IPage<EventFrontVO> frontDigPageList(String projectId, String eventName, String eventType, Integer pageNo, Integer pageSize);
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zzsn.event.entity.EventExtractTask;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.vo.EventExtractTaskVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author lenovo
* @description 针对表【event_extract_task(事件抽取任务表)】的数据库操作Service
* @createDate 2024-09-13 11:31:47
*/
public interface EventExtractTaskService extends IService<EventExtractTask> {
/**
* 事件抽取任务信息分页列表
*
* @param projectId 项目id
* @param searchWord 搜索词
* @param taskName 任务名称
* @param startTime 开始时间
* @param endTime 结束时间
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/9/13
*/
IPage<EventExtractTaskVO> pageList(String projectId, String searchWord, String taskName, String startTime, String endTime,
Integer pageNo, Integer pageSize);
}
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.CustomerDataPermissionMap;
/**
* @Description: 客户表
* @Author: jeecg-boot
* @Date: 2021-12-01
* @Version: V1.0
*/
public interface ICustomerDataPermissionMapService extends IService<CustomerDataPermissionMap> {
}
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.Event; import com.zzsn.event.entity.Event;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import java.util.Date; import java.util.Date;
...@@ -94,6 +95,17 @@ public interface IEventService extends IService<Event> { ...@@ -94,6 +95,17 @@ public interface IEventService extends IService<Event> {
Page<EventNewPlatVO> newPlatPageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize); Page<EventNewPlatVO> newPlatPageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize);
/** /**
* 分页列表(客户)-新平台管理
*
* @param subjectCondition 筛选条件
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/4/28
*/
IPage<EventNewPlatVO> newPlatCustomerPageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize);
/**
* 热点事件列表-前10 * 热点事件列表-前10
* *
* @param startTime 开始时间 * @param startTime 开始时间
...@@ -123,7 +135,7 @@ public interface IEventService extends IService<Event> { ...@@ -123,7 +135,7 @@ public interface IEventService extends IService<Event> {
void deleteMain(String id); void deleteMain(String id);
List<StatisticsKeyWordVo> hotWords(String index, String id, Integer number);
/** /**
* 公开且发布的事件信息集合 * 公开且发布的事件信息集合
...@@ -169,6 +181,36 @@ public interface IEventService extends IService<Event> { ...@@ -169,6 +181,36 @@ public interface IEventService extends IService<Event> {
List<EventVO> eventList(List<String> eventIdList); List<EventVO> eventList(List<String> eventIdList);
/** /**
* 项目列表
*
* @param userId 用户id
* @param customerId 客户id
* @author lkg
* @date 2024/4/29
*/
List<Node> projectList(String userId, String customerId);
/**
* 分类下的专题id集合
*
* @param userId 用户id
* @param typeIds 分类id集合
* @author lkg
* @date 2024/5/6
*/
List<String> selectSubjectByTypeIds(String userId, List<String> typeIds);
/**
* 用户下的事件id集合
*
* @param userId 用户id
* @param customerId 客户id
* @author lkg
* @date 2024/5/6
*/
List<String> selectSubjectWithCustomer(String userId, String customerId);
/**
* 专题绑定关键词的id集合 * 专题绑定关键词的id集合
* *
* @param subjectIds 专题id集合 * @param subjectIds 专题id集合
...@@ -176,4 +218,75 @@ public interface IEventService extends IService<Event> { ...@@ -176,4 +218,75 @@ public interface IEventService extends IService<Event> {
* @date 2024/5/6 * @date 2024/5/6
*/ */
List<String> bindKeyWordsIdList(List<String> subjectIds); List<String> bindKeyWordsIdList(List<String> subjectIds);
/**
* 专题绑定模型信息列表
*
* @param subjectIds 专题id集合
* @author lkg
* @date 2024/5/6
*/
List<LabelModelVo> selectLabelModelBySubjectId(List<String> subjectIds);
/**
* 企业标签下的企业信用代码集合
*
* @param labelIds 企业标签id集合
* @author lkg
* @date 2024/5/6
*/
List<String> codesByLabels(List<String> labelIds);
/**
* 专题直接绑定信息源-批量
*
* @param directBindInfoVO 参数封装
* @author lkg
* @date 2024/4/24
*/
void directBindInfoSource(DirectBindInfoVO directBindInfoVO);
/**
* 专题直接解绑信息源-批量
*
* @param directBindInfoVO 参数封装
* @author lkg
* @date 2024/4/24
*/
void directRemoveInfoSource(DirectBindInfoVO directBindInfoVO);
/**
* 删除专题下已屏蔽的信息源(即恢复绑定关系)
*
* @param subjectId 专题id
* @param infoSourceId 信息源id
* @author lkg
* @date 2024/5/7
*/
void removeUnBindInfoSource(String subjectId, String infoSourceId);
/**
* 专题关联信息源时间段内的采集量统计
*
* @param subjectIds 专题id集合
* @param startDate 开始时间
* @param endDate 结束时间
* @author lkg
* @date 2024/5/7
*/
List<List<String>> subjectStatistics(List<String> subjectIds, String startDate, String endDate);
/**
* 专题绑定的关键词组-分页列表
*
* @param subjectIds 专题id集合
* @param groupName 词组名称
* @param wordName 关键词名称
* @param pageNo 当前页
* @param pageSize 返回条数
* @author lkg
* @date 2024/5/7
*/
IPage<KeyWordsPage> bindKeyWordsList(List<String> subjectIds, String groupName, String wordName, Integer pageNo, Integer pageSize);
} }
...@@ -111,4 +111,14 @@ public interface ISubjectTypeService extends IService<SubjectType> { ...@@ -111,4 +111,14 @@ public interface ISubjectTypeService extends IService<SubjectType> {
* @date 2025/1/8 * @date 2025/1/8
*/ */
List<SubjectTypeTreeVO> typeAndBindCountTreeList(Integer category); List<SubjectTypeTreeVO> typeAndBindCountTreeList(Integer category);
/**
* 可用的专题和客户列表
*
* @param customerId 客户id
* @author lkg
* @date 2024/4/30
*/
List<SubjectTreeVO> subjectAndCustomerTree(String userId,String customerId);
List<SubjectTreeVO> eventAndTypeTree();
} }
package com.zzsn.event.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zzsn.event.entity.SysUserDataPermission;
/**
* @author lkg
* @description:
* @date 2022/6/20 14:10
*/
public interface ISysUserDataPermissionService extends IService<SysUserDataPermission> {
}
package com.zzsn.event.service;
import com.zzsn.event.util.tree.Node;
import java.util.List;
/**
* 其他数据
*
* @author lkg
* @date 2024/9/13
*/
public interface OtherDataService {
/**
* 栏目集合
*
* @author lkg
* @date 2024/9/13
*/
List<Node> columnList(List<String> columnIds);
/**
* 项目集合
*
* @author lkg
* @date 2024/9/13
*/
List<Node> projectList();
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.CustomerDataPermissionMap;
import com.zzsn.event.mapper.CustomerDataPermissionMapMapper;
import com.zzsn.event.service.ICustomerDataPermissionMapService;
import org.springframework.stereotype.Service;
/**
* @Description: 客户表
* @Author: jeecg-boot
* @Date: 2021-12-01
* @Version: V1.0
*/
@Service
public class CustomerDataPermissionMapImpl extends ServiceImpl<CustomerDataPermissionMapMapper, CustomerDataPermissionMap> implements ICustomerDataPermissionMapService {
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.EventExtract;
import com.zzsn.event.service.EventExtractService;
import com.zzsn.event.mapper.EventExtractMapper;
import com.zzsn.event.service.IEventCategoryService;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.tree.TreeUtil;
import com.zzsn.event.vo.EventExtractVO;
import com.zzsn.event.vo.EventFrontVO;
import com.zzsn.event.vo.EventManageVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author lenovo
* @description 针对表【event_extract(事件)】的数据库操作Service实现
* @createDate 2024-09-07 18:00:28
*/
@Service
public class EventExtractServiceImpl extends ServiceImpl<EventExtractMapper, EventExtract> implements EventExtractService {
@Autowired
private IEventCategoryService eventCategoryService;
@Override
public IPage<EventExtractVO> pageList(String taskId, String searchWord, String eventName,
String startTime, String endTime, String eventType,
Integer checkStatus, String column, String sortType, Integer pageNo, Integer pageSize) {
int offset = (pageNo - 1) * pageSize;
List<EventExtractVO> pageList = baseMapper.pageList(taskId, searchWord, eventName, startTime, endTime, eventType, checkStatus, column, sortType, offset, pageSize);
Long totalCount = baseMapper.totalCount(taskId, searchWord, eventName, startTime, endTime, eventType, checkStatus);
IPage<EventExtractVO> pageData = new Page<>(pageNo, pageSize, totalCount);
pageData.setRecords(pageList);
return pageData;
}
@Override
public IPage<EventFrontVO> frontDigPageList(String projectId, String eventName, String eventType, Integer pageNo, Integer pageSize) {
int offset = (pageNo - 1) * pageSize;
List<String> eventTypes = new ArrayList<>();
if (StringUtils.isNotEmpty(eventType)) {
List<Node> nodes = eventCategoryService.categoryList();
eventTypes = TreeUtil.belowList(nodes, eventType, true);
}
List<EventFrontVO> pageList = baseMapper.frontDigPageList(projectId, eventName, eventTypes, offset, pageSize);
Long count = baseMapper.frontDigTotalCount(projectId, eventName, eventTypes);
IPage<EventFrontVO> pageData = new Page<>(pageNo, pageSize, count);
pageData.setRecords(pageList);
return pageData;
}
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.EventExtract;
import com.zzsn.event.entity.EventExtractTask;
import com.zzsn.event.mapper.EventExtractTaskMapper;
import com.zzsn.event.service.EventExtractService;
import com.zzsn.event.service.EventExtractTaskService;
import com.zzsn.event.service.OtherDataService;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.EventExtractTaskVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author lenovo
* @description 针对表【event_extract_task(事件抽取任务表)】的数据库操作Service实现
* @createDate 2024-09-13 11:31:47
*/
@Service
public class EventExtractTaskServiceImpl extends ServiceImpl<EventExtractTaskMapper, EventExtractTask>
implements EventExtractTaskService{
@Autowired
private EventExtractService eventExtractService;
@Autowired
private OtherDataService otherDataService;
@Override
public IPage<EventExtractTaskVO> pageList(String projectId, String searchWord, String taskName, String startTime, String endTime, Integer pageNo, Integer pageSize) {
int offset = (pageNo - 1) * pageSize;
Long count = baseMapper.totalCount(projectId, searchWord, taskName, startTime, endTime);
IPage<EventExtractTaskVO> pageData = new Page<>(pageNo, pageSize,count);
if (count > 0) {
List<EventExtractTaskVO> pageList = baseMapper.pageList(projectId, searchWord, taskName, startTime, endTime, offset, pageSize);
List<String> taskIds = new ArrayList<>();
Set<String> columnIds = new HashSet<>();
pageList.forEach(e->{
taskIds.add(e.getId());
String columnId = e.getColumnId();
Collections.addAll(columnIds, columnId.split(","));
});
// 任务数据范围(栏目名称)
List<Node> columnList = otherDataService.columnList(new ArrayList<>(columnIds));
Map<String, Node> columnMap = columnList.stream().collect(Collectors.toMap(Node::getId,Function.identity()));
//任务抽取事件的数量统计
Map<String, List<EventExtract>> map = new HashMap<>();
List<EventExtract> eventExtractList = eventExtractService.list(Wrappers.<EventExtract>lambdaQuery().select(EventExtract::getTaskId, EventExtract::getCheckStatus)
.in(EventExtract::getTaskId, taskIds));
if (CollectionUtils.isNotEmpty(eventExtractList)) {
map = eventExtractList.stream().collect(Collectors.groupingBy(EventExtract::getTaskId));
}
for (EventExtractTaskVO taskVO : pageList) {
//任务抽取事件的数量
String taskId = taskVO.getId();
List<EventExtract> eventExtracts = map.get(taskId);
if (CollectionUtils.isNotEmpty(eventExtracts)) {
long noCheckCount = eventExtracts.stream().filter(e -> e.getCheckStatus() == 0).count();
taskVO.setExtractEventCount(eventExtracts.size());
taskVO.setNoCheckExtractEventCount((int)noCheckCount);
} else {
taskVO.setExtractEventCount(0);
taskVO.setNoCheckExtractEventCount(0);
}
//数据范围
String columnId = taskVO.getColumnId();
StringBuilder stringBuilder = new StringBuilder();
for (String s : columnId.split(",")) {
Node column = columnMap.get(s);
stringBuilder.append(",").append(column.getName());
}
taskVO.setColumnName(stringBuilder.substring(1));
}
pageData.setRecords(pageList);
}
return pageData;
}
}
...@@ -2,12 +2,14 @@ package com.zzsn.event.service.impl; ...@@ -2,12 +2,14 @@ package com.zzsn.event.service.impl;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.constant.Constants; import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.*; import com.zzsn.event.entity.*;
import com.zzsn.event.enums.BindTypeEnum;
import com.zzsn.event.enums.CodePrefixEnum; import com.zzsn.event.enums.CodePrefixEnum;
import com.zzsn.event.es.EsService; import com.zzsn.event.es.EsService;
import com.zzsn.event.mapper.EventMapper; import com.zzsn.event.mapper.EventMapper;
...@@ -91,6 +93,8 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -91,6 +93,8 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
private RestHighLevelClient client; private RestHighLevelClient client;
@Autowired @Autowired
private CommonService commonService; private CommonService commonService;
@Autowired
private EsService esService;
@Override @Override
...@@ -223,6 +227,17 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -223,6 +227,17 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
} }
@Override @Override
public IPage<EventNewPlatVO> newPlatCustomerPageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize) {
int offset = (pageNo - 1) * pageSize;
List<EventNewPlatVO> pageList = baseMapper.newPlatCustomerPageList(subjectCondition, offset, pageSize);
count(pageList);
Integer count = baseMapper.newPlatCustomerCount(subjectCondition);
IPage<EventNewPlatVO> pageData = new Page<>(pageNo, pageSize, count);
pageData.setRecords(pageList);
return pageData;
}
@Override
public List<EventTopVO> topEventList(String projectId, String createBy,String startTime, String endTime, Integer type, Integer pageSize) { public List<EventTopVO> topEventList(String projectId, String createBy,String startTime, String endTime, Integer type, Integer pageSize) {
return baseMapper.topEventList(projectId,createBy,startTime, endTime, type, 0, pageSize); return baseMapper.topEventList(projectId,createBy,startTime, endTime, type, 0, pageSize);
} }
...@@ -373,11 +388,36 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -373,11 +388,36 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
} }
@Override @Override
public List<Node> projectList(String userId, String customerId) {
return baseMapper.projectList(userId, customerId);
}
@Override
public List<String> selectSubjectByTypeIds(String userId, List<String> typeIds) {
return baseMapper.selectSubjectByTypeIds(userId, typeIds);
}
@Override
public List<String> codesByLabels(List<String> labelIds) {
return baseMapper.codesByLabels(labelIds);
}
@Override
public List<LabelModelVo> selectLabelModelBySubjectId(List<String> subjectIds) {
return baseMapper.selectLabelModelBySubjectId(subjectIds);
}
@Override
public List<String> bindKeyWordsIdList(List<String> subjectIds) { public List<String> bindKeyWordsIdList(List<String> subjectIds) {
return baseMapper.bindKeyWordsIdList(subjectIds); return baseMapper.bindKeyWordsIdList(subjectIds);
} }
@Override @Override
public List<String> selectSubjectWithCustomer(String userId, String customerId) {
return baseMapper.selectSubjectWithCustomer(userId, customerId);
}
@Override
public List<EventExcelVO> frontAllList(String projectId, String createBy, List<String> eventIdList,String eventName, public List<EventExcelVO> frontAllList(String projectId, String createBy, List<String> eventIdList,String eventName,
String eventType, String labelField,String labelName, Integer size) { String eventType, String labelField,String labelName, Integer size) {
Integer type = null; Integer type = null;
...@@ -407,6 +447,146 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -407,6 +447,146 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
return baseMapper.frontOwnerList(projectId,createBy,eventIdList,eventName,eventTypes,labelField,labelName,type, size); return baseMapper.frontOwnerList(projectId,createBy,eventIdList,eventName,eventTypes,labelField,labelName,type, size);
} }
@Override
public List<StatisticsKeyWordVo> hotWords(String index, String id, Integer number) {
SubjectDataVo subjectDataVo = esService.queryInfo(index, id);
String content = subjectDataVo.getContent();
List<Map.Entry<String, Integer>> keywordsList = HanlpUtil.extractKeyWordsByText(Jsoup.parse(content).text(), number);
List<StatisticsKeyWordVo> rn = new ArrayList<>();
if (CollectionUtils.isNotEmpty(keywordsList)) {
for (Map.Entry<String, Integer> entry : keywordsList) {
StatisticsKeyWordVo statisticsKeyWordVo = new StatisticsKeyWordVo();
statisticsKeyWordVo.setName(entry.getKey());
statisticsKeyWordVo.setValue(entry.getValue());
rn.add(statisticsKeyWordVo);
}
}
return rn;
}
@Override
public void directBindInfoSource(DirectBindInfoVO directBindInfoVO) {
String subjectId = directBindInfoVO.getSubjectId();
List<String> bindList = directBindInfoVO.getBindList();
Integer type = BindTypeEnum.INFO_SOURCE.getvalue();
for (String infoSourceId : bindList) {
/*
* 1.先删除该信息源在专题下的所有数据
* 2.再判断该信息源在专题已绑定的信息源组下,若不在则新增绑定关系;若在则跳过
*/
LambdaQueryWrapper<SubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectInfoSourceMap::getSourceId, infoSourceId)
.eq(SubjectInfoSourceMap::getSubjectId, subjectId);
iSubjectInfoSourceMapService.remove(queryWrapper);
int num = baseMapper.ynBelowBindGroup(subjectId, infoSourceId);
if (num == 0) {
SubjectInfoSourceMap subjectInfoSourceMap = new SubjectInfoSourceMap();
subjectInfoSourceMap.setSourceId(infoSourceId);
subjectInfoSourceMap.setSubjectId(subjectId);
subjectInfoSourceMap.setType(type);
iSubjectInfoSourceMapService.save(subjectInfoSourceMap);
}
}
}
@Override
public void directRemoveInfoSource(DirectBindInfoVO directBindInfoVO) {
String subjectId = directBindInfoVO.getSubjectId();
List<String> excludeList = directBindInfoVO.getExcludeList();
for (String infoSourceId : excludeList) {
/*
* 1.先删除该信息源在专题下的所有数据
* 2.再判断该信息源在专题已排除的信息源组下,若不在则新增绑定关系;若在则跳过
*/
LambdaQueryWrapper<SubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectInfoSourceMap::getSourceId, infoSourceId)
.eq(SubjectInfoSourceMap::getSubjectId, subjectId);
iSubjectInfoSourceMapService.remove(queryWrapper);
int num = baseMapper.ynBelowExcludeGroup(subjectId, infoSourceId);
if (num == 0) {
SubjectInfoSourceMap subjectInfoSourceMap = new SubjectInfoSourceMap();
subjectInfoSourceMap.setSourceId(infoSourceId);
subjectInfoSourceMap.setSubjectId(subjectId);
subjectInfoSourceMap.setType(BindTypeEnum.EXCLUDE_INFO_SOURCE.getvalue());
iSubjectInfoSourceMapService.save(subjectInfoSourceMap);
}
}
}
@Override
public void removeUnBindInfoSource(String subjectId, String infoSourceId) {
int num = baseMapper.ynBelowExcludeGroup(subjectId, infoSourceId);
if (num == 0) {
LambdaUpdateWrapper<SubjectInfoSourceMap> update = Wrappers.lambdaUpdate();
iSubjectInfoSourceMapService.update(update.eq(SubjectInfoSourceMap::getSubjectId, subjectId)
.eq(SubjectInfoSourceMap::getSourceId, infoSourceId)
.eq(SubjectInfoSourceMap::getType, 3)
.set(SubjectInfoSourceMap::getType, 1));
} else {
LambdaQueryWrapper<SubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectInfoSourceMap::getSourceId, infoSourceId)
.eq(SubjectInfoSourceMap::getSubjectId, subjectId)
.eq(SubjectInfoSourceMap::getType, 3);
iSubjectInfoSourceMapService.remove(queryWrapper);
}
}
@Override
public List<List<String>> subjectStatistics(List<String> subjectIds, String startDate, String endDate) {
List<String> dateList = DateUtil.betweenDate(startDate, endDate);
List<List<String>> dataList = new ArrayList<>();
//专题关联的信息源集合
List<SubjectStatisticsVo> infoSourceList = iSubjectInfoSourceMapService.subjectRealBindInfoSources(subjectIds);
Map<String, Map<String, Long>> stringMapMap = esService.regetFromEs(infoSourceList.stream().map(SubjectStatisticsVo::getId).collect(Collectors.toList()), startDate, endDate);
//封装导出excel需要的数据集合
for (SubjectStatisticsVo subjectStatisticsVo : infoSourceList) {
Map<String, Long> stringLongMap = stringMapMap.get(subjectStatisticsVo.getId());
List<SubjectStatisticsVo> value = new ArrayList<>();
int sum = 0;
if (null != stringLongMap) {
for (String s : stringLongMap.keySet()) {
SubjectStatisticsVo subjectStatisticsVoTemp = new SubjectStatisticsVo();
subjectStatisticsVoTemp.setId(subjectStatisticsVo.getId());
subjectStatisticsVoTemp.setSiteName(subjectStatisticsVo.getSiteName());
subjectStatisticsVoTemp.setDate(s);
int num = Math.toIntExact(stringLongMap.get(s));
subjectStatisticsVoTemp.setCollectCount(num);
value.add(subjectStatisticsVoTemp);
sum += Math.toIntExact(stringLongMap.get(s));
}
}
List<String> list = new ArrayList<>(subjectStatisticsVo.toExcelList());
//信息源在时间段内的采集总量
list.add(String.valueOf(sum));
//信息源采集到数据的日期集合
Set<String> collectDates = value.stream().collect(Collectors.groupingBy(SubjectStatisticsVo::getDate)).keySet();
//信息源未采集到数据的日期集合
List<String> noCollectDates = new ArrayList<>(dateList);
noCollectDates.removeAll(collectDates);
for (String date : noCollectDates) {
SubjectStatisticsVo vo = new SubjectStatisticsVo();
BeanUtils.copyProperties(subjectStatisticsVo, vo);
vo.setCollectCount(0);
vo.setDate(date);
value.add(vo);
}
//根据采集时间排序(正序)
value.sort(Comparator.comparing(SubjectStatisticsVo::getDate));
value.forEach(e -> list.add(String.valueOf(e.getCollectCount())));
dataList.add(list);
}
return dataList;
}
@Override
public IPage<KeyWordsPage> bindKeyWordsList(List<String> subjectIds, String groupName, String wordName, Integer pageNo, Integer pageSize) {
int offset = (pageNo - 1) * pageSize;
List<KeyWordsPage> wordsList = baseMapper.bindKeyWordsList(subjectIds, groupName, wordName, offset, pageSize);
Long count = baseMapper.bindKeyWordsCount(subjectIds, groupName, wordName);
IPage<KeyWordsPage> page = new Page<>(pageNo, pageSize, count);
page.setRecords(wordsList);
return page;
}
private void addRegionMap(String eventId, List<RegionVO> regionList) { private void addRegionMap(String eventId, List<RegionVO> regionList) {
if (CollectionUtils.isNotEmpty(regionList)) { if (CollectionUtils.isNotEmpty(regionList)) {
...@@ -466,6 +646,15 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -466,6 +646,15 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
subjectModelMapService.saveBatch(modelMaps); subjectModelMapService.saveBatch(modelMaps);
} }
//专题实际绑定信息源的集合
private List<SubjectSourceVO> subjectBindSourceList(List<String> subjectIds) {
List<SubjectSourceVO> bindList = baseMapper.bindSourceList(subjectIds);
List<SubjectSourceVO> excludeList = baseMapper.excludeSourceList(subjectIds);
bindList.removeAll(excludeList);
return bindList;
}
//查询每个专题的数量 //查询每个专题的数量
private Map<String, Integer> subjectInfoCountMap(List<String> subjectIdList, List<Integer> checkStatusList) { private Map<String, Integer> subjectInfoCountMap(List<String> subjectIdList, List<Integer> checkStatusList) {
Map<String, Integer> map = new HashMap<>(subjectIdList.size()); Map<String, Integer> map = new HashMap<>(subjectIdList.size());
......
package com.zzsn.event.service.impl;
import com.zzsn.event.mapper.OtherDataMapper;
import com.zzsn.event.service.OtherDataService;
import com.zzsn.event.util.tree.Node;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
*
*
* @author lkg
* @date 2024/9/13
*/
@Service
public class OtherDataServiceImpl implements OtherDataService {
@Resource
private OtherDataMapper otherDataMapper;
@Override
public List<Node> columnList(List<String> columnIds) {
return otherDataMapper.columnList(columnIds);
}
@Override
public List<Node> projectList() {
return otherDataMapper.projectList();
}
}
...@@ -20,10 +20,7 @@ import org.springframework.beans.BeanUtils; ...@@ -20,10 +20,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -114,6 +111,21 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje ...@@ -114,6 +111,21 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
} }
@Override @Override
public List<SubjectTreeVO> subjectAndCustomerTree(String userId,String customerId) {
List<SubjectTreeVO> subjectTreeVOS = baseMapper.enableCustomerList(customerId);
List<SubjectTreeVO> list = baseMapper.subjectAndCustomerTree(userId,customerId);
subjectTreeVOS.addAll(list);
List<SubjectTreeVO> tree = TreeUtil.tree(subjectTreeVOS, "0");
tree.forEach(this::subjectNumCount);
return tree;
}
@Override
public List<SubjectTreeVO> eventAndTypeTree() {
return baseMapper.eventAndTypeTree();
}
@Override
public List<String> researchCenterBelowIdList(String typeId, Integer category) { public List<String> researchCenterBelowIdList(String typeId, Integer category) {
String username = UserUtil.getLoginUser().getUsername(); String username = UserUtil.getLoginUser().getUsername();
List<Node> nodes = baseMapper.enableList(category,username); List<Node> nodes = baseMapper.enableList(category,username);
...@@ -202,7 +214,21 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje ...@@ -202,7 +214,21 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
} }
return sum; return sum;
} }
private void subjectNumCount(SubjectTreeVO subjectTreeVO) {
Boolean ynSubject = subjectTreeVO.getYnSubject();
if (!ynSubject) {
int num = 0;
List<? extends Node> children = subjectTreeVO.getChildren();
if (CollectionUtils.isNotEmpty(children)) {
for (Node node : children) {
SubjectTreeVO subjectTreeNode = (SubjectTreeVO)node;
subjectNumCount(subjectTreeNode);
num = num + 1;
}
subjectTreeVO.setSubjectCount(num);
}
}
}
@Override @Override
public List<SubjectTypeVo> subjectListByType(String parentId) { public List<SubjectTypeVo> subjectListByType(String parentId) {
if (!parentId.equals("0")) { if (!parentId.equals("0")) {
......
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SysUserDataPermission;
import com.zzsn.event.mapper.SysUserDataPermissionMapper;
import com.zzsn.event.service.ISysUserDataPermissionService;
import org.springframework.stereotype.Service;
/**
* @author lkg
* @description:
* @date 2022/6/20 14:10
*/
@Service
public class SysUserDataPermissionServiceImpl extends ServiceImpl<SysUserDataPermissionMapper, SysUserDataPermission> implements ISysUserDataPermissionService {
}
package com.zzsn.event.task;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.entity.EventExtractTask;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.EventExtractTaskService;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.vo.EventDigDataVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
/**
* 事件挖掘任务
*
* @author lkg
* @date 2024/8/30
*/
@Slf4j
@Component
public class EventDigTask {
@Autowired
private EventExtractTaskService eventExtractTaskService;
@Autowired
private EsService esService;
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired
private RedisUtil redisUtil;
private final static String EVENT_DIG_TIME_KEY = "EVENT_DIG_HANDLER_TIME::";
/*@Scheduled(cron = "0 0/5 * * * ?")
public void sendData() {
List<EventExtractTask> extractTaskList = eventExtractTaskService.list(Wrappers.<EventExtractTask>lambdaQuery().eq(EventExtractTask::getDeleteStatus, 0)
.eq(EventExtractTask::getTaskStatus, 1));
for (EventExtractTask eventExtractTask : extractTaskList) {
CompletableFuture.runAsync(() -> {
String taskId = eventExtractTask.getId();
eventExtractTaskService.update(Wrappers.<EventExtractTask>lambdaUpdate().set(EventExtractTask::getLastUpdateTime, new Date())
.eq(EventExtractTask::getId, taskId));
String projectId = eventExtractTask.getProjectId();
String columnId = eventExtractTask.getColumnId();
Integer dataStatus = eventExtractTask.getDataStatus();
String endTime = null;
if (eventExtractTask.getEndTime() != null) {
endTime = DateUtil.dateToString(eventExtractTask.getEndTime());
}
String startTime = DateUtil.dateToString(eventExtractTask.getStartTime());
String redisKey = EVENT_DIG_TIME_KEY + taskId;
Object object = redisUtil.get(redisKey);
if (object != null) {
startTime = object.toString();
}
List<EventDigDataVO> eventDigDataVOS = esService.pageListOfColumn(columnId, dataStatus, startTime, endTime, 120);
if (CollectionUtils.isNotEmpty(eventDigDataVOS)) {
//分批发送
List<List<EventDigDataVO>> partition = ListUtils.partition(eventDigDataVOS, 30);
partition.forEach(e -> {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("taskId", taskId);
dataMap.put("projectId", projectId);
dataMap.put("dataList", e);
kafkaTemplate.send(Constants.EVENT_DIG_SEND_TOPIC, JSON.toJSONString(dataMap));
});
String processDate = eventDigDataVOS.get(eventDigDataVOS.size() - 1).getProcessDate();
if (endTime != null && processDate.compareTo(endTime) >= 0) {
eventExtractTaskService.update(Wrappers.<EventExtractTask>lambdaUpdate().set(EventExtractTask::getTaskStatus, 0)
.eq(EventExtractTask::getId, taskId));
log.info("事件抽取任务-{},数据范围内的资讯已全部处理完,任务状态关闭", taskId);
} else {
//将最新时间存入redis,供下次使用
redisUtil.set(redisKey, processDate);
log.info("事件抽取任务-{},本次kafka推送开始时间为-{},总条数为-{}", taskId, startTime, eventDigDataVOS.size());
}
}
});
}
}*/
}
package com.zzsn.event.util;
import org.springframework.util.StringUtils;
import java.beans.PropertyEditorSupport;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/**
* 类描述:时间操作定义类
*
* @Author: 张代浩
* @Date:2012-12-8 12:15:03
* @Version 1.0
*/
public class DateUtils extends PropertyEditorSupport {
public static ThreadLocal<SimpleDateFormat> date_sdf = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd");
}
};
public static ThreadLocal<SimpleDateFormat> yyyyMMdd = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyyMMdd");
}
};
public static ThreadLocal<SimpleDateFormat> date_sdf_wz = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy年MM月dd日");
}
};
public static ThreadLocal<SimpleDateFormat> time_sdf = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm");
}
};
public static ThreadLocal<SimpleDateFormat> yyyymmddhhmmss = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyyMMddHHmmss");
}
};
public static ThreadLocal<SimpleDateFormat> short_time_sdf = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("HH:mm");
}
};
public static ThreadLocal<SimpleDateFormat> datetimeFormat = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
};
// 以毫秒表示的时间
private static final long DAY_IN_MILLIS = 24 * 3600 * 1000;
private static final long HOUR_IN_MILLIS = 3600 * 1000;
private static final long MINUTE_IN_MILLIS = 60 * 1000;
private static final long SECOND_IN_MILLIS = 1000;
// 指定模式的时间格式
private static SimpleDateFormat getSDFormat(String pattern) {
return new SimpleDateFormat(pattern);
}
/**
* 当前日历,这里用中国时间表示
*
* @return 以当地时区表示的系统当前日历
*/
public static Calendar getCalendar() {
return Calendar.getInstance();
}
/**
* 指定毫秒数表示的日历
*
* @param millis 毫秒数
* @return 指定毫秒数表示的日历
*/
public static Calendar getCalendar(long millis) {
Calendar cal = Calendar.getInstance();
// --------------------cal.setTimeInMillis(millis);
cal.setTime(new Date(millis));
return cal;
}
// ////////////////////////////////////////////////////////////////////////////
// getDate
// 各种方式获取的Date
// ////////////////////////////////////////////////////////////////////////////
/**
* 当前日期
*
* @return 系统当前时间
*/
public static Date getDate() {
return new Date();
}
/**
* 指定毫秒数表示的日期
*
* @param millis 毫秒数
* @return 指定毫秒数表示的日期
*/
public static Date getDate(long millis) {
return new Date(millis);
}
/**
* 时间戳转换为字符串
*
* @param time
* @return
*/
public static String timestamptoStr(Timestamp time) {
Date date = null;
if (null != time) {
date = new Date(time.getTime());
}
return date2Str(date_sdf.get());
}
/**
* 字符串转换时间戳
*
* @param str
* @return
*/
public static Timestamp str2Timestamp(String str) {
Date date = str2Date(str, date_sdf.get());
return new Timestamp(date.getTime());
}
/**
* 字符串转换成日期
*
* @param str
* @param sdf
* @return
*/
public static Date str2Date(String str, SimpleDateFormat sdf) {
if (null == str || "".equals(str)) {
return null;
}
Date date = null;
try {
date = sdf.parse(str);
return date;
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 日期转换为字符串
*
* @param date_sdf 日期格式
* @return 字符串
*/
public static String date2Str(SimpleDateFormat date_sdf) {
Date date = getDate();
if (null == date) {
return null;
}
return date_sdf.format(date);
}
/**
* 格式化时间
*
* @param date
* @param format
* @return
*/
public static String dateformat(String date, String format) {
SimpleDateFormat sformat = new SimpleDateFormat(format);
Date _date = null;
try {
_date = sformat.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return sformat.format(_date);
}
/**
* 日期转换为字符串
*
* @param date 日期
* @param date_sdf 日期格式
* @return 字符串
*/
public static String date2Str(Date date, SimpleDateFormat date_sdf) {
if (null == date) {
return null;
}
return date_sdf.format(date);
}
/**
* 日期转换为字符串
*
* @param format 日期格式
* @return 字符串
*/
public static String getDate(String format) {
Date date = new Date();
if (null == date) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
}
/**
* 指定毫秒数的时间戳
*
* @param millis 毫秒数
* @return 指定毫秒数的时间戳
*/
public static Timestamp getTimestamp(long millis) {
return new Timestamp(millis);
}
/**
* 以字符形式表示的时间戳
*
* @param time 毫秒数
* @return 以字符形式表示的时间戳
*/
public static Timestamp getTimestamp(String time) {
return new Timestamp(Long.parseLong(time));
}
/**
* 系统当前的时间戳
*
* @return 系统当前的时间戳
*/
public static Timestamp getTimestamp() {
return new Timestamp(System.currentTimeMillis());
}
/**
* 当前时间,格式 yyyy-MM-dd HH:mm:ss
*
* @return 当前时间的标准形式字符串
*/
public static String now() {
return datetimeFormat.get().format(getCalendar().getTime());
}
/**
* 指定日期的时间戳
*
* @param date 指定日期
* @return 指定日期的时间戳
*/
public static Timestamp getTimestamp(Date date) {
return new Timestamp(date.getTime());
}
/**
* 指定日历的时间戳
*
* @param cal 指定日历
* @return 指定日历的时间戳
*/
public static Timestamp getCalendarTimestamp(Calendar cal) {
// ---------------------return new Timestamp(cal.getTimeInMillis());
return new Timestamp(cal.getTime().getTime());
}
public static Timestamp gettimestamp() {
Date dt = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowTime = df.format(dt);
Timestamp buydate = Timestamp.valueOf(nowTime);
return buydate;
}
// ////////////////////////////////////////////////////////////////////////////
// getMillis
// 各种方式获取的Millis
// ////////////////////////////////////////////////////////////////////////////
/**
* 系统时间的毫秒数
*
* @return 系统时间的毫秒数
*/
public static long getMillis() {
return System.currentTimeMillis();
}
/**
* 指定日历的毫秒数
*
* @param cal 指定日历
* @return 指定日历的毫秒数
*/
public static long getMillis(Calendar cal) {
// --------------------return cal.getTimeInMillis();
return cal.getTime().getTime();
}
/**
* 指定日期的毫秒数
*
* @param date 指定日期
* @return 指定日期的毫秒数
*/
public static long getMillis(Date date) {
return date.getTime();
}
/**
* 指定时间戳的毫秒数
*
* @param ts 指定时间戳
* @return 指定时间戳的毫秒数
*/
public static long getMillis(Timestamp ts) {
return ts.getTime();
}
// ////////////////////////////////////////////////////////////////////////////
// formatDate
// 将日期按照一定的格式转化为字符串
// ////////////////////////////////////////////////////////////////////////////
/**
* 默认方式表示的系统当前日期,具体格式:年-月-日
*
* @return 默认日期按“年-月-日“格式显示
*/
public static String formatDate() {
return date_sdf.get().format(getCalendar().getTime());
}
/**
* 默认方式表示的系统当前日期,具体格式:yyyy-MM-dd HH:mm:ss
*
* @return 默认日期按“yyyy-MM-dd HH:mm:ss“格式显示
*/
public static String formatDateTime() {
return datetimeFormat.get().format(getCalendar().getTime());
}
/**
* 获取时间字符串
*/
public static String getDataString(SimpleDateFormat formatstr) {
return formatstr.format(getCalendar().getTime());
}
/**
* 指定日期的默认显示,具体格式:年-月-日
*
* @param cal 指定的日期
* @return 指定日期按“年-月-日“格式显示
*/
public static String formatDate(Calendar cal) {
return date_sdf.get().format(cal.getTime());
}
/**
* 指定日期的默认显示,具体格式:年-月-日
*
* @param date 指定的日期
* @return 指定日期按“年-月-日“格式显示
*/
public static String formatDate(Date date) {
return date_sdf.get().format(date);
}
/**
* 指定毫秒数表示日期的默认显示,具体格式:年-月-日
*
* @param millis 指定的毫秒数
* @return 指定毫秒数表示日期按“年-月-日“格式显示
*/
public static String formatDate(long millis) {
return date_sdf.get().format(new Date(millis));
}
/**
* 默认日期按指定格式显示
*
* @param pattern 指定的格式
* @return 默认日期按指定格式显示
*/
public static String formatDate(String pattern) {
return getSDFormat(pattern).format(getCalendar().getTime());
}
/**
* 指定日期按指定格式显示
*
* @param cal 指定的日期
* @param pattern 指定的格式
* @return 指定日期按指定格式显示
*/
public static String formatDate(Calendar cal, String pattern) {
return getSDFormat(pattern).format(cal.getTime());
}
/**
* 指定日期按指定格式显示
*
* @param date 指定的日期
* @param pattern 指定的格式
* @return 指定日期按指定格式显示
*/
public static String formatDate(Date date, String pattern) {
return getSDFormat(pattern).format(date);
}
// ////////////////////////////////////////////////////////////////////////////
// formatTime
// 将日期按照一定的格式转化为字符串
// ////////////////////////////////////////////////////////////////////////////
/**
* 默认方式表示的系统当前日期,具体格式:年-月-日 时:分
*
* @return 默认日期按“年-月-日 时:分“格式显示
*/
public static String formatTime() {
return time_sdf.get().format(getCalendar().getTime());
}
/**
* 指定毫秒数表示日期的默认显示,具体格式:年-月-日 时:分
*
* @param millis 指定的毫秒数
* @return 指定毫秒数表示日期按“年-月-日 时:分“格式显示
*/
public static String formatTime(long millis) {
return time_sdf.get().format(new Date(millis));
}
/**
* 指定日期的默认显示,具体格式:年-月-日 时:分
*
* @param cal 指定的日期
* @return 指定日期按“年-月-日 时:分“格式显示
*/
public static String formatTime(Calendar cal) {
return time_sdf.get().format(cal.getTime());
}
/**
* 指定日期的默认显示,具体格式:年-月-日 时:分
*
* @param date 指定的日期
* @return 指定日期按“年-月-日 时:分“格式显示
*/
public static String formatTime(Date date) {
return time_sdf.get().format(date);
}
// ////////////////////////////////////////////////////////////////////////////
// formatShortTime
// 将日期按照一定的格式转化为字符串
// ////////////////////////////////////////////////////////////////////////////
/**
* 默认方式表示的系统当前日期,具体格式:时:分
*
* @return 默认日期按“时:分“格式显示
*/
public static String formatShortTime() {
return short_time_sdf.get().format(getCalendar().getTime());
}
/**
* 指定毫秒数表示日期的默认显示,具体格式:时:分
*
* @param millis 指定的毫秒数
* @return 指定毫秒数表示日期按“时:分“格式显示
*/
public static String formatShortTime(long millis) {
return short_time_sdf.get().format(new Date(millis));
}
/**
* 指定日期的默认显示,具体格式:时:分
*
* @param cal 指定的日期
* @return 指定日期按“时:分“格式显示
*/
public static String formatShortTime(Calendar cal) {
return short_time_sdf.get().format(cal.getTime());
}
/**
* 指定日期的默认显示,具体格式:时:分
*
* @param date 指定的日期
* @return 指定日期按“时:分“格式显示
*/
public static String formatShortTime(Date date) {
return short_time_sdf.get().format(date);
}
// ////////////////////////////////////////////////////////////////////////////
// parseDate
// parseCalendar
// parseTimestamp
// 将字符串按照一定的格式转化为日期或时间
// ////////////////////////////////////////////////////////////////////////////
/**
* 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
*
* @param src 将要转换的原始字符窜
* @param pattern 转换的匹配格式
* @return 如果转换成功则返回转换后的日期
* @throws ParseException
*/
public static Date parseDate(String src, String pattern) {
Date parse = null;
try {
parse = getSDFormat(pattern).parse(src);
} catch (Exception e) {
e.printStackTrace();
}
return parse;
}
/**
* 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
*
* @param src 将要转换的原始字符窜
* @param pattern 转换的匹配格式
* @return 如果转换成功则返回转换后的日期
* @throws ParseException
*/
public static Calendar parseCalendar(String src, String pattern) {
Date date = parseDate(src, pattern);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal;
}
public static String formatAddDate(String src, String pattern, int amount) {
Calendar cal;
cal = parseCalendar(src, pattern);
cal.add(Calendar.DATE, amount);
return formatDate(cal);
}
/**
* 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
*
* @param src 将要转换的原始字符窜
* @param pattern 转换的匹配格式
* @return 如果转换成功则返回转换后的时间戳
* @throws ParseException
*/
public static Timestamp parseTimestamp(String src, String pattern) throws ParseException {
Date date = parseDate(src, pattern);
return new Timestamp(date.getTime());
}
// ////////////////////////////////////////////////////////////////////////////
// dateDiff
// 计算两个日期之间的差值
// ////////////////////////////////////////////////////////////////////////////
/**
* 计算两个时间之间的差值,根据标志的不同而不同
*
* @param flag 计算标志,表示按照年/月/日/时/分/秒等计算
* @param calSrc 减数
* @param calDes 被减数
* @return 两个日期之间的差值
*/
public static int dateDiff(char flag, Calendar calSrc, Calendar calDes) {
long millisDiff = getMillis(calSrc) - getMillis(calDes);
if (flag == 'y') {
return (calSrc.get(Calendar.YEAR) - calDes.get(Calendar.YEAR));
}
if (flag == 'd') {
return (int) (millisDiff / DAY_IN_MILLIS);
}
if (flag == 'h') {
return (int) (millisDiff / HOUR_IN_MILLIS);
}
if (flag == 'm') {
return (int) (millisDiff / MINUTE_IN_MILLIS);
}
if (flag == 's') {
return (int) (millisDiff / SECOND_IN_MILLIS);
}
return 0;
}
/**
* String类型 转换为Date, 如果参数长度为10 转换格式”yyyy-MM-dd“ 如果参数长度为19 转换格式”yyyy-MM-dd
* HH:mm:ss“ * @param text String类型的时间值
*/
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
try {
if (text.indexOf(":") == -1 && text.length() == 10) {
setValue(DateUtils.date_sdf.get().parse(text));
} else if (text.indexOf(":") > 0 && text.length() == 19) {
setValue(DateUtils.datetimeFormat.get().parse(text));
} else {
throw new IllegalArgumentException("Could not parse date, date format is error ");
}
} catch (ParseException ex) {
IllegalArgumentException iae = new IllegalArgumentException("Could not parse date: " + ex.getMessage());
iae.initCause(ex);
throw iae;
}
} else {
setValue(null);
}
}
public static int getYear() {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(getDate());
return calendar.get(Calendar.YEAR);
}
// 获得本周一0点时间
public static Date getTimesWeekMorning() {
Calendar cal = Calendar.getInstance();
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
return cal.getTime();
}
// 获得本周日24点时间
public static Date getTimesWeekNight() {
Calendar cal = Calendar.getInstance();
cal.setTime(getTimesWeekMorning());
cal.add(Calendar.DAY_OF_WEEK, 7);
return cal.getTime();
}
// 获得本月第一天0点时间
public static Date getTimesMonthMorning() {
Calendar cal = Calendar.getInstance();
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
return cal.getTime();
}
// 获得本月最后一天24点时间
public static Date getTimesMonthNight() {
Calendar cal = Calendar.getInstance();
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
cal.set(Calendar.HOUR_OF_DAY, 24);
return cal.getTime();
}
public static Date getHalfYearStartTime() {
Calendar c = Calendar.getInstance();
int currentMonth = c.get(Calendar.MONTH) + 1;
Date now = null;
try {
if (currentMonth <= 6) {
c.set(Calendar.MONTH, 0);
} else if (currentMonth <= 12) {
c.set(Calendar.MONTH, 6);
}
c.set(Calendar.DATE, 1);
now = c.getTime();
} catch (Exception e) {
e.printStackTrace();
}
return now;
}
public static Date getHalfYearEndTime() {
Calendar c = Calendar.getInstance();
int currentMonth = c.get(Calendar.MONTH) + 1;
Date now = null;
try {
if (currentMonth <= 6) {
c.set(Calendar.MONTH, 5);
c.set(Calendar.DATE, 30);
} else if (currentMonth <= 12) {
c.set(Calendar.MONTH, 11);
c.set(Calendar.DATE, 31);
}
now = c.getTime();
} catch (Exception e) {
e.printStackTrace();
}
return now;
}
// 获得本年第一天的时间
public static Date getCurrentYearStart() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, 0);
cal.set(Calendar.DATE, 1);
return cal.getTime();
}
// 获得本年最后一天的时间
public static Date getCurrentYearEnd() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, 11);
cal.set(Calendar.DATE, 31);
return cal.getTime();
}
}
...@@ -15,7 +15,6 @@ import java.util.List; ...@@ -15,7 +15,6 @@ import java.util.List;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
public class UserVo implements Serializable { public class UserVo implements Serializable {
/** /**
* 登录人id * 登录人id
*/ */
...@@ -121,4 +120,7 @@ public class UserVo implements Serializable { ...@@ -121,4 +120,7 @@ public class UserVo implements Serializable {
/**用户绑定的角色所属的项目的id集合*/ /**用户绑定的角色所属的项目的id集合*/
List<String> projectIds; List<String> projectIds;
private String userId;
private String customerId;
} }
package com.zzsn.event.vo;
import lombok.Getter;
import lombok.Setter;
/**
*
*
* @author lkg
* @date 2024/8/30
*/
@Getter
@Setter
public class EventDigDataVO extends SubjectDataVo{
private String processDate;
}
package com.zzsn.event.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 事件挖掘任务
*
* @author lkg
* @date 2024/9/13
*/
@Getter
@Setter
public class EventExtractTaskVO {
private String id;
private String taskName;
private String projectName;
private String columnId;
private String columnName;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date lastUpdateTime;
private Integer taskStatus;
private Integer extractEventCount;
private Integer noCheckExtractEventCount;
}
package com.zzsn.event.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
*
*
* @author lkg
* @date 2024/4/8
*/
@Data
public class EventExtractVO {
private String id;
private String eventName;
private Integer eventType;
private String typeName;
private String eventLabel;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date extractTime;
private Integer checkStatus;
private String relatedId;
}
...@@ -32,4 +32,8 @@ public class SubjectCondition { ...@@ -32,4 +32,8 @@ public class SubjectCondition {
private Integer facePublic; private Integer facePublic;
/**用户账号*/ /**用户账号*/
private String username; private String username;
private String userId;
private String customerId;
} }
package com.zzsn.event.vo;
import lombok.Data;
/**
* @Description: 3
* @Author: jeecg-boot
* @Date: 2023-08-01
* @Version: V1.0
*/
@Data
public class SubjectInfoSourceLabelTypeVo {
/**信息源组id*/
private String sourceId;
/**专题id*/
private String subjectId;
}
...@@ -20,4 +20,6 @@ public class SubjectTreeVO extends Node { ...@@ -20,4 +20,6 @@ public class SubjectTreeVO extends Node {
private String startTime; private String startTime;
private String endTime; private String endTime;
private String createTime; private String createTime;
private Integer subjectCount;
} }
package com.zzsn.event.xxljob.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 信息源表
* @Author: jeecg-boot
* @Date: 2021-10-15
* @Version: V1.0
*/
@ApiModel(value="info_source对象", description="信息源表")
@Data
@TableName("info_source")
public class InfoSource implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**信息源编码*/
@ApiModelProperty(value = "信息源编码")
private String infoSourceCode;
/**信息源名称*/
@ApiModelProperty(value = "信息源名称")
private String webSiteName;
/**栏目名称*/
@ApiModelProperty(value = "栏目名称")
private String siteName;
/**栏目地址*/
@ApiModelProperty(value = "栏目地址")
private String siteUri;
/**网站重要级别*/
@ApiModelProperty(value = "网站重要级别")
private String siteLevel;
/**国家*/
@ApiModelProperty(value = "国家")
private String country;
/**是否境外*/
@ApiModelProperty(value = "是否境外")
private String ynOther;
/**地区*/
@ApiModelProperty(value = "地区")
private String area;
/**是否需要登录*/
@ApiModelProperty(value = "是否需要登录")
private Integer ynLogin;
/**语种*/
@ApiModelProperty(value = "语种")
private String language;
/**是否公共*/
@ApiModelProperty(value = "是否公共")
private String ynPublic;
/**是否需要翻墙*/
@ApiModelProperty(value = "是否需要翻墙")
private Integer ynAbroad;
/**是否需要代理*/
@ApiModelProperty(value = "是否需要代理")
private Integer ynAgent;
/**动态爬取*/
@ApiModelProperty(value = "动态爬取")
private Integer ynBrowser;
/**调度时间间隔*/
@ApiModelProperty(value = "调度时间间隔")
private String period;
/**调度周期(cron自动生成)*/
@ApiModelProperty(value = "调度周期(cron自动生成)")
private String cron;
/**调度周期说明*/
@ApiModelProperty(value = "调度周期说明")
private String remarkCron;
/**信息源状态*/
@ApiModelProperty(value = "信息源状态")
private Integer status;
/**网站可信度*/
@ApiModelProperty(value = "网站可信度")
private Integer siteReliability;
/**信息源综合评分*/
@ApiModelProperty(value = "信息源综合评分")
private Integer score;
/**爬取深度*/
@ApiModelProperty(value = "爬取深度")
private Integer crawlDepth;
/**爬取方式*/
@ApiModelProperty(value = "爬取方式")
private Integer crawlType;
/**历史数据URL*/
@ApiModelProperty(value = "历史数据URL")
private String hisUriExp;
/**历史数据开始时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "历史数据开始时间")
private Date hisDateStarttime;
/**历史数据结束时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "历史数据结束时间")
private Date hisDateEndtime;
/**创建人*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private String sysOrgCode;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论