提交 26915460 作者: 925993793@qq.com

【第三方-政策分析(研究中心)】新增第三方专题创建接口

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