提交 6885dd51 作者: 925993793@qq.com

定制专题 通知采集逻辑优化

上级 e134880d
package com.zzsn.event.external.controller; package com.zzsn.event.external.controller;
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
...@@ -20,6 +21,8 @@ import com.zzsn.event.service.CommonService; ...@@ -20,6 +21,8 @@ import com.zzsn.event.service.CommonService;
import com.zzsn.event.service.InformationService; import com.zzsn.event.service.InformationService;
import com.zzsn.event.service.SubjectService; import com.zzsn.event.service.SubjectService;
import com.zzsn.event.service.SubjectSimpleService; import com.zzsn.event.service.SubjectSimpleService;
import com.zzsn.event.service.impl.CaiJiCenterHttpService;
import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.util.HttpUtil; import com.zzsn.event.util.HttpUtil;
import com.zzsn.event.util.ObjectUtil; import com.zzsn.event.util.ObjectUtil;
import com.zzsn.event.util.RedisUtil; import com.zzsn.event.util.RedisUtil;
...@@ -28,6 +31,7 @@ import com.zzsn.event.vo.SubjectDetailVO; ...@@ -28,6 +31,7 @@ import com.zzsn.event.vo.SubjectDetailVO;
import com.zzsn.event.vo.SubjectSimpleVO; import com.zzsn.event.vo.SubjectSimpleVO;
import com.zzsn.event.vo.TranslateVO; import com.zzsn.event.vo.TranslateVO;
import com.zzsn.event.vo.es.DisplayInfo; import com.zzsn.event.vo.es.DisplayInfo;
import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService; import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -35,10 +39,12 @@ import org.apache.commons.lang3.StringUtils; ...@@ -35,10 +39,12 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
...@@ -74,11 +80,19 @@ public class ExternalController { ...@@ -74,11 +80,19 @@ public class ExternalController {
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired @Autowired
SubjectService subjectService; SubjectService subjectService;
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired
private CaiJiCenterHttpService caiJiCenterHttpService;
@Autowired
private ConfigurationMessageService configurationMessageService;
@Value("${caiji.keywordCrawler.url:}") @Value("${caiji.keywordCrawler.url:}")
private String keywordCrawlerUrl; private String keywordCrawlerUrl;
@Value("${translate.url:}") @Value("${translate.url:}")
private String TRANSLATE_URL; private String TRANSLATE_URL;
@Value("${kafka.topic.subject.run:}")
private String SUBJECT_MODEL_KAFKA_CHANNEL;
/** /**
* 创建专题 * 创建专题
...@@ -116,6 +130,46 @@ public class ExternalController { ...@@ -116,6 +130,46 @@ public class ExternalController {
return Result.OK(); return Result.OK();
} }
/**
* 更新状态
*
* @param subject
* @author lkg
* @date 2025/1/9
*/
@PostMapping("/updateStatus")
public Result<?> updateStatus(@RequestBody Subject subject) {
subjectService.updateStatus(subject);
Subject byId = subjectService.getById(subject.getId());
List<XxlJobInfo> list = xxlJobInfoService.list(Wrappers.<XxlJobInfo>lambdaQuery().eq(XxlJobInfo::getInfoSourceCode, byId.getSubjectCode()));
if (CollectionUtils.isNotEmpty(list)) {
xxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate()
.eq(XxlJobInfo::getInfoSourceCode, byId.getSubjectCode())
.set(XxlJobInfo::getTriggerStatus, byId.getStatus()));
} else {
xxlJobInfoService.subjectInsert(byId);
}
if (subject.getStatus() == 1) {
kafkaTemplate.send(SUBJECT_MODEL_KAFKA_CHANNEL, byId.getSubjectCode());
configurationMessageService.bindKeyWordsSend(subject.getId(),1);
}
try {
String res = caiJiCenterHttpService.subjectStatusEdit(subject.getStatus(), subject.getId());
cn.hutool.json.JSONObject entries = JSONUtil.parseObj(res);
//获取code状态码
Integer code = entries.getInt("code");
if (cn.hutool.core.util.ObjectUtil.isEmpty(code) || code != 200) {
log.error("专题状态同步采集失败{}", res);
}
} catch (Exception e) {
log.error("专题状态同步采集失败{}", e.getMessage(), e);
}
return Result.OK();
}
/** /**
* 采集词推荐 * 采集词推荐
* *
......
...@@ -151,7 +151,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -151,7 +151,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (CollectionUtils.isNotEmpty(keywords)) { if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectId, subject.getSubjectName(), keywords); modifyKeyword(subjectId, subject.getSubjectName(), keywords);
//同步配置到采集 //同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectId,1); //configurationMessageService.bindKeyWordsSend(subjectId,1);
//默认绑定tpu流程 //默认绑定tpu流程
ClbModelArrangeSubjectMap tpu = new ClbModelArrangeSubjectMap(); ClbModelArrangeSubjectMap tpu = new ClbModelArrangeSubjectMap();
tpu.setSubjectId(subject.getId()); tpu.setSubjectId(subject.getId());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论