提交 81221f3c 作者: obcy

Merge remote-tracking branch 'origin/event_fusion' into event_fusion

package com.zzsn.event.controller.thirdApi;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.service.SubjectSimpleService;
import com.zzsn.event.service.impl.CaiJiCenterHttpService;
import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import lombok.extern.slf4j.Slf4j;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.concurrent.CompletableFuture;
/**
* 研究中心-政策分析-创建专题
*
* @author lkg
* @date 2025/10/11
*/
@Slf4j
@RestController
@RequestMapping("/third/api")
public class SubjectApi {
@Autowired
private SubjectSimpleService subjectSimpleService;
@Autowired
private IXxlJobInfoService xxlJobInfoService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired
private CaiJiCenterHttpService caiJiCenterHttpService;
@Value("${kafka.topic.subject.run:}")
private String SUBJECT_MODEL_KAFKA_CHANNEL;
/**
* 创建专题
*
* @param subjectSimpleVO 参数
* @author lkg
* @date 2025/1/9
*/
@PostMapping("/createSubject")
public Result<?> createSubject(@RequestBody ThirdAddSubjectVO subjectSimpleVO) {
Subject subject = subjectSimpleService.createPolicySubject(subjectSimpleVO);
CompletableFuture.runAsync(() -> {
//插入xxlJob
xxlJobInfoService.subjectInsert(subject);
});
//远程调用,执行采集入库流程
kafkaTemplate.send(SUBJECT_MODEL_KAFKA_CHANNEL, subject.getSubjectCode());
configurationMessageService.bindInfoSourceSend(subject.getId());
configurationMessageService.bindKeyWordsSend(subject.getId(),null);
configurationMessageService.subjectEnterpriseSourceSync(subject.getId());
configurationMessageService.subjectPolicySourceSync(subject.getId());
try {
String res = caiJiCenterHttpService.subjectStatusEdit(subject.getStatus(), subject.getId());
cn.hutool.json.JSONObject entries = JSONUtil.parseObj(res);
//获取code状态码
Integer code = entries.getInt("code");
if (ObjectUtil.isEmpty(code) || code != 200) {
log.error("专题状态同步采集失败{}", res);
}
} catch (Exception e) {
log.error("专题状态同步采集失败{}", e.getMessage(), e);
}
return Result.OK(subject.getId());
}
}
package com.zzsn.event.controller.thirdApi;
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/7/19
*/
@Getter
@Setter
public class ThirdAddSubjectVO {
private String subjectName;
//默认政策分析
private String subjectTypeId = "1976857756188119042";
//默认研究中心
private String projectId = "1476527644425682945";
//默认10分钟调度一次
/**定时单位(1分;2小时;3日;4月)*/
private String unit = "1";
/**定时数值*/
private Integer space = 10;
private String remark;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date timeEnable;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date timeDisable;
private String library;
private Integer subjectType = 1;
private Integer dataSource = 0;
private Integer facePublic = 0;
private Integer status = 1;
/**关键词*/
private String keyword;
/**数据范围(是否是全库) - 采集库全库-1,企业库全库-2,政策库全库-3*/
private String dataScope = "1";
}
package com.zzsn.event.service;
import com.zzsn.event.controller.thirdApi.ThirdAddSubjectVO;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.vo.*;
......@@ -120,4 +121,13 @@ public interface SubjectSimpleService {
* @date 2025/2/6
*/
void clearSubjectData(String subjectId);
/**
* 新增专题-对外【政策分析专用】
*
* @param thirdAddSubjectVO 参数
* @author lkg
* @date 2025/1/14
*/
Subject createPolicySubject(ThirdAddSubjectVO thirdAddSubjectVO);
}
......@@ -849,10 +849,28 @@ public class InformationServiceImpl implements InformationService {
dataCheckLog = DataLifecycleLog.createDataCheckLog(subjectdatabase, operateUser, sourceName, EnumHandlerStatus.TEMPORARY);
}
kafkaTemplate.send("data_lifecycle_log_data_check", JSONUtil.toJsonStr(dataCheckLog));
//其他项目对接逻辑
//央企舆情重大舆情 labelMark = important 说明是重大舆情
try {
if (checkStatus == 1) {
List<Label> labels = subjectdatabase.getLabels();
Optional<Label> important = labels.stream().filter(label -> label.getLabelMark().equals("important")).findAny();
if (important.isPresent()) {
String articleId = subjectdatabase.getId();
Map<String, String> params = new HashMap<>();
params.put("articleId", articleId);
HttpUtil.doGet("http://1.95.72.34:7051/yqyq/majorPublicOpinionSync", params,null, "utf-8");
log.info("央企舆情-重大舆情推送接口调用成功,{}", articleId);
}
}
} catch (Exception e) {
e.printStackTrace();
}
//评价中心审核逻辑
if (subjectdatabase.getSubjectId().equals("1933103248232779778")) {
subjectdatabase.setDbIndex(index);
kafkaTemplate.send("gzjg_information", JSONUtil.toJsonStr(subjectdatabase));
log.info("评价中心数据推送kafka成功,{}", subjectdatabase.getId());
}
});
}
......
package com.zzsn.event.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSON;
......@@ -10,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.controller.thirdApi.ThirdAddSubjectVO;
import com.zzsn.event.entity.*;
import com.zzsn.event.enums.BindTypeEnum;
import com.zzsn.event.enums.CodePrefixEnum;
......@@ -51,7 +51,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
@Autowired
private ISubjectTypeService subjectTypeService;
@Autowired
private IKeyWordsService keywordWordsService;
private IKeyWordsService keywordsService;
@Autowired
private IKeywordsTypeMapService keywordsTypeMapService;
@Autowired
......@@ -115,7 +115,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
scoreModelService.commonModifyByKeyword(subjectId, collect);
}
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectId,null);
configurationMessageService.bindKeyWordsSend(subjectId, null);
//默认绑定tpu流程
List<ClbModelArrangeSubjectMap> tpuList = new ArrayList<>();
ClbModelArrangeSubjectMap tpu = new ClbModelArrangeSubjectMap();
......@@ -196,12 +196,12 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
subjectTypeMap.setSysOrgCode(subject.getSysOrgCode());
subjectTypeMap.setTypeId(subjectTypeId);
subjectTypeMapService.save(subjectTypeMap);
} else if (StringUtils.isNotEmpty(subjectTypeName)){
} else if (StringUtils.isNotEmpty(subjectTypeName)) {
UserVo loginUser = UserUtil.getLoginUser();
LambdaQueryWrapper<SubjectType> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectType::getTypeName, subjectTypeName)
.eq(SubjectType::getCreateBy, loginUser.getUsername())
.eq(SubjectType::getSysOrgCode,"YJZX");
.eq(SubjectType::getSysOrgCode, "YJZX");
SubjectType one = subjectTypeService.getOne(queryWrapper);
if (ObjectUtil.isEmpty(one)) {
SubjectType subjectType = new SubjectType();
......@@ -275,7 +275,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
return false;
}
//判断信息源标签配置是否变化,变化则校验不通过;反之通过
boolean judgeInfoSourceLabel = judgeInfoSourceLabel(subjectId,subjectDetailVO.getDataScope(),subjectParamsCheckVO.getDataScope(), subjectParamsCheckVO.getInfoSourceMainLabelVO());
boolean judgeInfoSourceLabel = judgeInfoSourceLabel(subjectId, subjectDetailVO.getDataScope(), subjectParamsCheckVO.getDataScope(), subjectParamsCheckVO.getInfoSourceMainLabelVO());
//判断定向信息源是否发生变化(前端传参),true 是;false 否
boolean directSourceChange = subjectParamsCheckVO.isDirectSourceChange();
return !judgeInfoSourceLabel && !directSourceChange;
......@@ -322,12 +322,12 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
/**
* 判断信息源配置是否发生变化 true 是;false 否
*
* @param subjectId 专题id
* @param infoSourceMainLabelVO 信息源标签信息(编辑时前端传参)
* @param subjectId 专题id
* @param infoSourceMainLabelVO 信息源标签信息(编辑时前端传参)
* @author lkg
* @date 2025/2/5
*/
private boolean judgeInfoSourceLabel(String subjectId, Integer oldDataScope,Integer newDataScope,InfoSourceMainLabelVO infoSourceMainLabelVO) {
private boolean judgeInfoSourceLabel(String subjectId, Integer oldDataScope, Integer newDataScope, InfoSourceMainLabelVO infoSourceMainLabelVO) {
boolean flag = false;
if (oldDataScope == null) {
oldDataScope = 0;
......@@ -381,7 +381,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
scoreModelService.commonModifyByKeyword(subjectId, collect);
}
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectId,null);
configurationMessageService.bindKeyWordsSend(subjectId, null);
}
}
......@@ -402,7 +402,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
scoreModelService.commonModifyByKeyword(subjectId, collect);
}
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectId,1);
configurationMessageService.bindKeyWordsSend(subjectId, 1);
}
}
......@@ -476,7 +476,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (CollectionUtils.isNotEmpty(list)) {
List<String> keywordIds = list.stream().map(SubjectKeywordsMap::getKeywordsId).collect(Collectors.toList());
//删除关键词
keywordWordsService.removeByIds(keywordIds);
keywordsService.removeByIds(keywordIds);
//删除与关键词组的关联关系
subjectKeywordsMapService.delete(subjectId);
//删除关键词组关联关系
......@@ -499,7 +499,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
public void selected(InfoDataSearchCondition searchCondition) {
//勾选的主题信息列表
List<Label> themeList = searchCondition.getThemeList();
String[] fetchFields = new String[]{"id", "checkStatus","labels"};
String[] fetchFields = new String[]{"id", "checkStatus", "labels"};
searchCondition.setFetchFields(fetchFields);
Map<String, List<SpecialInformation>> updateMap = new HashMap<>();
List<SpecialInformation> informationList = informationService.informationAllList(searchCondition);
......@@ -603,26 +603,55 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
Subject byId = subjectService.getById(subjectId);
String subjectCode = byId.getSubjectCode();
Set<String> keys = redisUtil.keys("*"+subjectCode);
Set<String> keys = redisUtil.keys("*" + subjectCode);
if (CollectionUtil.isNotEmpty(keys)) {
keys.forEach(key -> {
redisUtil.del(key);
});
}
//判断是否需要中断数据处理
String runningList = remoteModelService.isRunningList(byId.getId());
if (runningList.contains(byId.getSubjectCode())){
if (runningList.contains(byId.getSubjectCode())) {
remoteModelService.breakSubjcet(subjectId);
}
} catch (Exception e) {
log.error("专题-{},删除中间库数据、删除专题相关缓存key、中断专题处理、请求发送失败", subjectId, e);
}
log.info("专题-{},删除中间库数据、删除专题相关缓存key、中断专题处理、请求发送成功", subjectId);
}
@Override
public Subject createPolicySubject(ThirdAddSubjectVO thirdAddSubjectVO) {
SubjectPage subjectPage = new SubjectPage();
BeanUtils.copyProperties(thirdAddSubjectVO, subjectPage);
Subject subject = saveMain(subjectPage);
String subjectId = subject.getId();
//关键词绑定
String keyword = thirdAddSubjectVO.getKeyword();
if (StringUtils.isNotBlank(keyword)) {
List<SearchWordVO> keywords = new ArrayList<>();
SearchWordVO searchWord = new SearchWordVO();
searchWord.setSearchScope(1);
searchWord.setSearchInfo(keyword);
searchWord.setSearchLogicRelationship("AND");
searchWord.setBindingType("1");
keywords.add(searchWord);
modifyKeyword(subjectId, subject.getSubjectName(), keywords);
//默认通用打分配置
List<SearchWordVO> collect = keywords.stream().filter(searchWordVO -> !"NOT".equalsIgnoreCase(searchWordVO.getSearchLogicRelationship())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
scoreModelService.commonModifyByKeyword(subjectId, collect);
}
//默认绑定tpu流程
ClbModelArrangeSubjectMap tpu = new ClbModelArrangeSubjectMap();
tpu.setSubjectId(subject.getId());
tpu.setArrangeId("1976894424042553345");
tpu.setType("baseDateToSubject");
clbModelArrangeSubjectMapService.save(tpu);
}
return subject;
}
//目标集合按照另一个集合的顺序排序
private void sortByAnotherList(List<SearchWordVO> list, List<String> anotherList) {
list.sort((o1, o2) -> {
......@@ -666,7 +695,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
addMapIdList.add(searchWordVO);
}
}
handlerSubjectKeywordMap(subjectId, addMapIdList,bindList, retainList, removeIdList);
handlerSubjectKeywordMap(subjectId, addMapIdList, bindList, retainList, removeIdList);
//专题下关键词之间的关系
modifySubjectKeywordsGroupRelation(subjectId, retainList);
}
......@@ -743,7 +772,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
}
//处理专题-关键词绑定关系
private void handlerSubjectKeywordMap(String subjectId, List<SearchWordVO> addMapIdList,List<SubjectKeywordsMap> bindList, List<SearchWordVO> retainList, List<String> removeIdList) {
private void handlerSubjectKeywordMap(String subjectId, List<SearchWordVO> addMapIdList, List<SubjectKeywordsMap> bindList, List<SearchWordVO> retainList, List<String> removeIdList) {
if (CollectionUtils.isNotEmpty(addMapIdList)) {
List<SubjectKeywordsMap> subjectKeywordsMapList = new ArrayList<>();
for (SearchWordVO wordVO : addMapIdList) {
......@@ -806,7 +835,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
String wordsName = subjectName + wordsCode.substring(wordsCode.indexOf("-"));
keyWords.setWordsName(wordsName);
keyWords.setWordsCode(wordsCode);
keywordWordsService.save(keyWords);
keywordsService.save(keyWords);
//关键词组-分类 关系绑定
KeywordsTypeMap keywordsTypeMap = new KeywordsTypeMap();
keywordsTypeMap.setTypeId(KEYWORDS_TYPE_ID);
......@@ -817,12 +846,12 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
wordVO.setWordName(wordsName);
} else {
keyWords.setId(id);
keywordWordsService.updateById(keyWords);
keywordsService.updateById(keyWords);
}
realKeyWordList.add(wordVO);
}
if (CollectionUtils.isNotEmpty(removeIdList)) {
keywordWordsService.removeByIds(removeIdList);
keywordsService.removeByIds(removeIdList);
LambdaQueryWrapper<KeywordsTypeMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.in(KeywordsTypeMap::getKeywordsId, removeIdList);
keywordsTypeMapService.remove(queryWrapper);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论