提交 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());
}
});
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论