提交 093f31fe 作者: obcy

【专题状态变更通知采集】

上级 aa655624
......@@ -2,6 +2,7 @@ package com.zzsn.event.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -14,6 +15,7 @@ import com.zzsn.event.entity.*;
import com.zzsn.event.es.EsService;
import com.zzsn.event.feign.api.RemoteModelService;
import com.zzsn.event.service.*;
import com.zzsn.event.service.impl.CaiJiCenterHttpService;
import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.util.*;
import com.zzsn.event.util.tree.Node;
......@@ -104,6 +106,8 @@ public class SubjectManageController {
@Value("${kafka.topic.subject.run:}")
private String SUBJECT_MODEL_KAFKA_CHANNEL;
@Autowired
private CaiJiCenterHttpService caiJiCenterHttpService;
/**
* 专题列表-资讯转换时使用
......@@ -342,6 +346,19 @@ public class SubjectManageController {
if (subject.getStatus() == 1) {
kafkaTemplate.send(SUBJECT_MODEL_KAFKA_CHANNEL, byId.getSubjectCode());
}
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();
}
......@@ -361,6 +378,17 @@ public class SubjectManageController {
Subject subject = subjectService.getOne(queryWrapper);
xxlJobInfoService.deleteByInfosourceCode(subject.getSubjectCode());
});
try {
String res = caiJiCenterHttpService.delSubject(id);
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();
}
......@@ -383,8 +411,22 @@ public class SubjectManageController {
queryWrapper.eq(Subject::getId, id);
Subject subject = subjectService.getOne(queryWrapper);
xxlJobInfoService.deleteByInfosourceCode(subject.getSubjectCode());
try {
String res = caiJiCenterHttpService.delSubject(id);
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();
}
......
package com.zzsn.event.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Service
public class CaiJiCenterHttpService {
@Value("${caiji.infosourcebind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/infoSourceEdit}")
private String infosourcebindUrl;
@Value("${caiji.keyWordsbind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/keywordEdit}")
private String keyWordsbindUrl;
@Value("${caiji.keyWordsEdit.url:http://1.95.79.85:8823/baseSourceInfo/api/keyword/edit}")
private String keyWordsEditUrl;
@Value("${caiji.allInfosourcebind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/infoSourceSave}")
private String allInfosourcebindUrl;
@Value("${caiji.allKeyWordsBind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/keywordSave}")
private String allKeyWordsBindUrl;
@Value("${caiji.subjectStatusEditUrl.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/editEnable}")
private String subjectStatusEditUrl;
@Value("${caiji.delSubjectUrl.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/delSubject}")
private String delSubjectUrl;
@Value("${caiji.projectCode:zzsn_test}")
private String projectCode;
@Value("${caiji.projectName:克虏宝测试}")
private String projectName;
@Value("${caiji.secretKey:BsEHuAQTifhnMBDni5xjTMkThpmWlNWR3vvYp1rPstQGbE6nmfBX9VhpwrBPWxrU}")
private String secretKey;
public String getProjectCode() {
return projectCode;
}
public String getProjectName() {
return projectName;
}
public String infosourcebindUrl(String jsonBody) {
HttpRequest post = post(infosourcebindUrl,jsonBody);
return post.execute().body();
}
public String keyWordsbindUrl(String jsonBody) {
HttpRequest post = post(keyWordsbindUrl,jsonBody);
return post.execute().body();
}
/**专题关键词配置通知采集*/
public String allKeyWordsBindUrl(String jsonBody) {
log.info("专题关键词配置通知采集{}-{}",allKeyWordsBindUrl,jsonBody);
HttpRequest post = post(allKeyWordsBindUrl,jsonBody);
return post.execute().body();
}
/**专题信息源配置通知采集*/
public String allInfosourcebindUrl(String jsonBody) {
log.info("专题信息源配置通知采集{}-{}",allInfosourcebindUrl,jsonBody);
HttpRequest post = post(allInfosourcebindUrl,jsonBody);
return post.execute().body();
}
/**编辑关键词通知采集*/
public String keyWordsEditUrl(Map<String,Object> map) {
log.info("编辑关键词通知采集{}-{}",keyWordsEditUrl,JSONUtil.toJsonStr(map));
HttpRequest post = post(keyWordsEditUrl,map);
return post.execute().body();
}
/**专题状态通知采集平台*/
public String subjectStatusEdit(Integer status,String subjectId) {
Map<String, Object> map = new HashMap<>();
if (status == 1){
//启用
map.put("subjectSign",subjectId);
map.put("status",0);
}else {
//禁用
map.put("subjectSign",subjectId);
map.put("status",1);
}
log.info("专题状态通知采集平台{}-{}",subjectStatusEditUrl,JSONUtil.toJsonStr(map));
HttpRequest get = get(subjectStatusEditUrl,map);
return get.execute().body();
}
/**专题删除通知采集平台*/
public String delSubject(String subjectId) {
Map<String, Object> map = new HashMap<>();
map.put("subjectSign",subjectId);
log.info("专题删除通知采集平台{}-{}",delSubjectUrl,JSONUtil.toJsonStr(map));
HttpRequest get = get(delSubjectUrl,map);
return get.execute().body();
}
private HttpRequest get(String url,Map<String, Object> map) {
HttpRequest get = HttpUtil.createGet(url);
get.header("Content-Type", "application/json");
get.header("authkey", secretKey);
if (ObjectUtil.isNotEmpty(map)) {
get.form(map);
}
get.timeout(120000);
return get;
}
private HttpRequest post(String url,Map<String, Object> map) {
HttpRequest post = HttpUtil.createPost(url);
post.header("Content-Type", "application/json");
post.header("authkey", secretKey);
if (ObjectUtil.isNotEmpty(map)) {
post.body(JSONUtil.toJsonStr(map));
}
post.timeout(120000);
return post;
}
private HttpRequest post(String url,String jsonBody) {
HttpRequest post = HttpUtil.createPost(url);
post.header("Content-Type", "application/json");
post.header("authkey", secretKey);
if (StrUtil.isNotEmpty(jsonBody)) {
post.body(jsonBody);
}
post.timeout(120000);
return post;
}
}
......@@ -110,26 +110,12 @@ public class ConfigurationMessageService {
@Autowired
private IKeyWordsService keyWordsService;
@Autowired
private CaiJiCenterHttpService caiJiCenterHttpService;
@Autowired
ClbLabelInfoSourceMapService clbLabelInfoSourceMapService;
@Value("${caiji.infosourcebind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/infoSourceEdit}")
private String infosourcebindUrl;
@Value("${caiji.keyWordsbind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/keywordEdit}")
private String keyWordsbindUrl;
@Value("${caiji.keyWordsEdit.url:http://1.95.79.85:8823/baseSourceInfo/api/keyword/edit}")
private String keyWordsEditUrl;
@Value("${caiji.allInfosourcebind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/infoSourceSave}")
private String allInfosourcebindUrl;
@Value("${caiji.allKeyWordsBind.url:http://1.95.79.85:8823/baseSourceInfo/api/subject/keywordSave}")
private String allKeyWordsBindUrl;
@Value("${caiji.projectCode:zzsn_test}")
private String projectCode;
@Value("${caiji.projectName:克虏宝测试}")
private String projectName;
@Value("${caiji.secretKey:BsEHuAQTifhnMBDni5xjTMkThpmWlNWR3vvYp1rPstQGbE6nmfBX9VhpwrBPWxrU}")
private String secretKey;
@Autowired(required = false)
private RemoteModelService remoteModelService;
......@@ -162,7 +148,7 @@ public class ConfigurationMessageService {
infoSourceIds.removeAll(excludeIds);
}
if (infoSourceIds!= null && infoSourceIds.size() > 0) {
HttpUtil.post(infosourcebindUrl,getparam(byId, OptionType.BIND.getValue(),infoSourceIds));
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.BIND.getValue(),infoSourceIds));
}
} else if (MessageType.INFOSOURCE.getCode().equals(idsType)) {
......@@ -175,7 +161,7 @@ public class ConfigurationMessageService {
ids.removeAll(excludeIds);
}
if (ids!= null && ids.size() > 0) {
HttpUtil.post(infosourcebindUrl,getparam(byId, OptionType.BIND.getValue(),ids));
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.BIND.getValue(),ids));
}
} else if (MessageType.INFOSOURCE_LABEL.getCode().equals(idsType)) {
//绑定信息源标签
......@@ -186,7 +172,7 @@ public class ConfigurationMessageService {
}
if (ids!= null && ids.size() > 0) {
HttpUtil.post(infosourcebindUrl,getparam(byId, OptionType.BIND.getValue(),ids));
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.BIND.getValue(),ids));
}
}
} else if (OptionType.UNBIND.getCode().equals(option)) {
......@@ -200,7 +186,7 @@ public class ConfigurationMessageService {
infoSourceIds.removeAll(bindIds);
}
if (CollectionUtil.isNotEmpty(infoSourceIds)) {
HttpUtil.post(infosourcebindUrl,getparam(byId, OptionType.UNBIND.getValue(),infoSourceIds));
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.UNBIND.getValue(),infoSourceIds));
}
}
} else if (MessageType.INFOSOURCE.getCode().equals(idsType)) {
......@@ -210,7 +196,7 @@ public class ConfigurationMessageService {
if (CollectionUtil.isNotEmpty(bindIds)) {
ids.removeAll(bindIds);
}
HttpUtil.post(infosourcebindUrl,getparam(byId, OptionType.UNBIND.getValue(),ids));
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.UNBIND.getValue(),ids));
}
} else if (MessageType.INFOSOURCE_LABEL.getCode().equals(idsType)) {
//解绑信息源标签
......@@ -219,7 +205,7 @@ public class ConfigurationMessageService {
ids.removeAll(bindIds);
}
if (ids!= null && ids.size() > 0) {
HttpUtil.post(infosourcebindUrl,getparam(byId, OptionType.UNBIND.getValue(),ids));
caiJiCenterHttpService.infosourcebindUrl(getparam(byId,OptionType.UNBIND.getValue(),ids));
}
}
}
......@@ -239,9 +225,7 @@ public class ConfigurationMessageService {
old.removeAll(now);
if (CollectionUtil.isNotEmpty(old)) {
String getparam = getparam(byId, OptionType.UNBIND.getValue(), old);
log.info("解绑信息源通知采集{}",getparam);
String post = HttpUtil.post(infosourcebindUrl, getparam);
String post = caiJiCenterHttpService.infosourcebindUrl(getparam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
......@@ -263,7 +247,7 @@ public class ConfigurationMessageService {
if (CollectionUtil.isNotEmpty(bindIds)) {
String getparam = getparam(byId, OptionType.BIND.getValue(), bindIds);
log.info("绑定信息源通知采集{}",getparam);
String post = HttpUtil.post(infosourcebindUrl, getparam);
String post = caiJiCenterHttpService.infosourcebindUrl(getparam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
......@@ -288,8 +272,7 @@ public class ConfigurationMessageService {
if (OptionType.UNBIND.getCode().equals(option)) {
String keyWordsParam = getKeyWordsParam(byId, OptionType.UNBIND.getValue(), keyWords);
log.info("解绑关键词通知采集{}",keyWordsParam);
String post = HttpUtil.post(keyWordsbindUrl, keyWordsParam);
String post = caiJiCenterHttpService.keyWordsbindUrl(keyWordsParam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
......@@ -301,7 +284,7 @@ public class ConfigurationMessageService {
}else {
String keyWordsParam = getKeyWordsParam(byId, OptionType.BIND.getValue(), keyWords);
log.info("绑定关键词通知采集{}",keyWordsParam);
String post = HttpUtil.post(keyWordsbindUrl, keyWordsParam);
String post = caiJiCenterHttpService.keyWordsbindUrl(keyWordsParam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
......@@ -331,9 +314,7 @@ public class ConfigurationMessageService {
keyWordsParam = getKeyWordsParam(byId, null, keyWords);
}
log.info("专题关键词配置通知采集{}-{}",allKeyWordsBindUrl,keyWordsParam);
String post = doPost(allKeyWordsBindUrl, keyWordsParam);
String post = caiJiCenterHttpService.allKeyWordsBindUrl(keyWordsParam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
......@@ -366,9 +347,7 @@ public class ConfigurationMessageService {
getparam = getparam(byId, null, new ArrayList<>());
}
log.info("专题信息源配置通知采集{}-{}",allInfosourcebindUrl,getparam);
String post =doPost(allInfosourcebindUrl, getparam);
String post = caiJiCenterHttpService.allInfosourcebindUrl(getparam);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
......@@ -388,12 +367,11 @@ public class ConfigurationMessageService {
public void sendEditKeyWordsConfigurationMessage(String keyWordId) {
KeyWords byId = keyWordsService.getById(keyWordId);
Map<String,Object> param = new HashMap<>();
param.put("customerSign",projectCode);
param.put("customerName",projectName);
param.put("customerSign",caiJiCenterHttpService.getProjectCode());
param.put("customerName",caiJiCenterHttpService.getProjectName());
param.put("keywordSign",byId.getId());
param.put("collectWordExp",byId.getKeyWord());
log.info("编辑关键词通知采集{}-{}",keyWordsEditUrl,JSONUtil.toJsonStr(param));
String post = doPost(keyWordsEditUrl, JSONUtil.toJsonStr(param));
String post = caiJiCenterHttpService.keyWordsEditUrl(param);
JSONObject entries = JSONUtil.parseObj(post);
//获取code状态码
Integer code = entries.getInt("code");
......@@ -534,8 +512,8 @@ public class ConfigurationMessageService {
Map<String,Object> param = new HashMap<>();
param.put("subjectSign",subject.getId());
param.put("subjectName",subject.getSubjectName());
param.put("customerSign",projectCode);
param.put("customerName",projectName);
param.put("customerSign",caiJiCenterHttpService.getProjectCode());
param.put("customerName",caiJiCenterHttpService.getProjectName());
if (ObjectUtil.isNotNull(subject.getTimeEnable())) {
param.put("startTime", DateUtil.format(subject.getTimeEnable(),"yyyy-MM-dd HH:mm:ss"));
}else {
......@@ -554,8 +532,8 @@ public class ConfigurationMessageService {
List<Map<String,Object>> kw = new ArrayList<>();
param.put("subjectSign",subject.getId());
param.put("subjectName",subject.getSubjectName());
param.put("customerSign",projectCode);
param.put("customerName",projectName);
param.put("customerSign",caiJiCenterHttpService.getProjectCode());
param.put("customerName",caiJiCenterHttpService.getProjectName());
param.put("mode",option);
if (ObjectUtil.isNotNull(subject.getTimeEnable())) {
param.put("startTime", DateUtil.format(subject.getTimeEnable(),"yyyy-MM-dd HH:mm:ss"));
......@@ -584,14 +562,6 @@ public class ConfigurationMessageService {
}
private String doPost(String urlString, String body){
HttpRequest post = HttpUtil.createPost(urlString);
post.body(body);
post.header("Content-Type", "application/json");
post.header("authkey", secretKey);
return post.execute().body();
}
//日期往前推 num 个月
public static LocalDateTime getPreviousMonths(LocalDateTime date , int num) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论