提交 09ba7a9b 作者: yanxin

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

...@@ -93,7 +93,7 @@ public class SubjectManageController { ...@@ -93,7 +93,7 @@ public class SubjectManageController {
private KafkaTemplate<String, String> kafkaTemplate; private KafkaTemplate<String, String> kafkaTemplate;
@Autowired @Autowired
private PythonUtil pythonUtil; private PythonUtil pythonUtil;
@Autowired(required = false) @Autowired
private RemoteModelService remoteModelService; private RemoteModelService remoteModelService;
...@@ -585,7 +585,11 @@ public class SubjectManageController { ...@@ -585,7 +585,11 @@ public class SubjectManageController {
public Result<?> configScoreModel(@RequestBody ScoreModelVo scoreModelVo) { public Result<?> configScoreModel(@RequestBody ScoreModelVo scoreModelVo) {
scoreModelService.addOrUpdate(scoreModelVo, 1); scoreModelService.addOrUpdate(scoreModelVo, 1);
//调用接口,重新打分 //调用接口,重新打分
CompletableFuture.runAsync(() -> remoteModelService.reScoreRequest(scoreModelVo.getSubjectId(), "1887695061047672834")); CompletableFuture.runAsync(() -> {
String subjectId = scoreModelVo.getSubjectId();
remoteModelService.reScoreRequest(subjectId, "1887695061047672834");
log.info("专题-{},通用打分配置修改,重新打分请求发送成功",subjectId);
});
return Result.OK(); return Result.OK();
} }
......
...@@ -714,7 +714,7 @@ public class EsService { ...@@ -714,7 +714,7 @@ public class EsService {
* @date 2024/5/6 * @date 2024/5/6
*/ */
public IPage<SpecialInformation> pageListByCondition(InfoDataSearchCondition searchCondition, List<String> subjectIdList) throws IOException { public IPage<SpecialInformation> pageListByCondition(InfoDataSearchCondition searchCondition, List<String> subjectIdList) throws IOException {
SearchRequest searchRequest = new SearchRequest(EsIndexUtil.getIndexYear(Constants.SUBJECT_INDEX)); SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//设置分页参数 //设置分页参数
Integer pageNo = searchCondition.getPageNo(); Integer pageNo = searchCondition.getPageNo();
...@@ -1652,7 +1652,7 @@ public class EsService { ...@@ -1652,7 +1652,7 @@ public class EsService {
*/ */
private List<CountVO> groupByTerm(InfoDataSearchCondition searchCondition, String groupName, String field, boolean sort) { private List<CountVO> groupByTerm(InfoDataSearchCondition searchCondition, String groupName, String field, boolean sort) {
List<CountVO> list = new ArrayList<>(); List<CountVO> list = new ArrayList<>();
SearchRequest searchRequest = new SearchRequest(EsIndexUtil.getIndexYear(Constants.SUBJECT_INDEX)); SearchRequest searchRequest = new SearchRequest(EsIndexUtil.getIndexLatelyTwoYear(Constants.SUBJECT_INDEX));
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.trackTotalHits(true); searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(0); searchSourceBuilder.size(0);
...@@ -1867,7 +1867,7 @@ public class EsService { ...@@ -1867,7 +1867,7 @@ public class EsService {
//获取es查询结果 //获取es查询结果
private SearchHits getEsResult(SearchSourceBuilder searchSourceBuilder, BoolQueryBuilder boolQuery, String subjectId) { private SearchHits getEsResult(SearchSourceBuilder searchSourceBuilder, BoolQueryBuilder boolQuery, String subjectId) {
SearchRequest searchRequest = new SearchRequest(EsIndexUtil.getIndexYear(Constants.SUBJECT_INDEX)); SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
//默认最大数量是10000,设置为true后,显示准确数量 //默认最大数量是10000,设置为true后,显示准确数量
searchSourceBuilder.trackTotalHits(true); searchSourceBuilder.trackTotalHits(true);
//未删除 //未删除
...@@ -2039,7 +2039,7 @@ public class EsService { ...@@ -2039,7 +2039,7 @@ public class EsService {
buildSplitWordShouldQuery(boolQuery, searchInfo, "origin", searchAccuracy); buildSplitWordShouldQuery(boolQuery, searchInfo, "origin", searchAccuracy);
} }
} }
allBoolQuery.should(boolQuery); allBoolQuery.must(boolQuery);
} }
} }
......
package com.zzsn.event.service.impl; package com.zzsn.event.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -21,6 +22,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder; ...@@ -21,6 +22,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
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.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -73,6 +75,9 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -73,6 +75,9 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
@Autowired @Autowired
private PythonUtil pythonUtil; private PythonUtil pythonUtil;
@Value("${clb.subject.default.processing.advanceMonth}")
private Integer defaultAdvanceMonth;
//关键词默认分类 //关键词默认分类
private static final String KEYWORDS_TYPE_ID = "1476498704680194050"; private static final String KEYWORDS_TYPE_ID = "1476498704680194050";
//默认项目 //默认项目
...@@ -132,12 +137,22 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -132,12 +137,22 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
return false; return false;
} }
//判断时间范围是否增加(新时间范围完全包含旧时间范围 标识增加),增加则校验通过,反之不通过 //判断时间范围是否增加(新时间范围完全包含旧时间范围 标识增加),增加则校验通过,反之不通过
if (!(subjectSimpleVO.getTimeEnable().before(subjectDetailVO.getTimeEnable()) && subjectSimpleVO.getTimeDisable().after(subjectDetailVO.getTimeDisable()))) { Date timeEnable = subjectSimpleVO.getTimeEnable();
Date timeDisable = subjectSimpleVO.getTimeDisable();
Date oldTimeEnable = subjectDetailVO.getTimeEnable();
if (oldTimeEnable == null) {
oldTimeEnable = DateUtil.offsetMonth(firstOpenTime, -defaultAdvanceMonth);
}
Date oldTimeDisable = subjectDetailVO.getTimeDisable();
if (oldTimeDisable == null) {
oldTimeDisable = new Date();
}
if (!((timeEnable != null && timeEnable.before(oldTimeEnable)) && (timeDisable != null && timeDisable.after(oldTimeDisable)))) {
return false; return false;
} }
//判断关键词配置是否变化 //判断关键词配置是否变化
List<SearchWordVO> keywordsNew = subjectSimpleVO.getKeywords();
List<SearchWordVO> keywordsOld = subjectDetailVO.getKeywords(); List<SearchWordVO> keywordsOld = subjectDetailVO.getKeywords();
List<SearchWordVO> keywordsNew = subjectSimpleVO.getKeywords();
boolean judgeKeyword = judgeKeyword(keywordsNew, keywordsOld); boolean judgeKeyword = judgeKeyword(keywordsNew, keywordsOld);
if (judgeKeyword) { if (judgeKeyword) {
return false; return false;
...@@ -169,7 +184,8 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -169,7 +184,8 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (oldMap.containsKey(searchWordVO.getId())) { if (oldMap.containsKey(searchWordVO.getId())) {
SearchWordVO old = oldMap.get(searchWordVO.getId()); SearchWordVO old = oldMap.get(searchWordVO.getId());
if (!(old.getSearchInfo().equals(searchWordVO.getSearchInfo()) if (!(old.getSearchInfo().equals(searchWordVO.getSearchInfo())
&& old.getSearchLogicRelationship().equals(searchWordVO.getSearchLogicRelationship()) && ((old.getSearchLogicRelationship() == null && searchWordVO.getSearchLogicRelationship() == null)
|| old.getSearchLogicRelationship().equals(searchWordVO.getSearchLogicRelationship()))
&& old.getSearchScope().equals(searchWordVO.getSearchScope()))) { && old.getSearchScope().equals(searchWordVO.getSearchScope()))) {
flag = true; flag = true;
} }
...@@ -194,7 +210,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -194,7 +210,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
* @author lkg * @author lkg
* @date 2025/2/5 * @date 2025/2/5
*/ */
private boolean judgeInfoSource(String subjectId,SubjectSourceTagVO subjectSourceTagVO,List<String> infoSourceWebSiteNames,List<String> infoSourceIds){ private boolean judgeInfoSource(String subjectId, SubjectSourceTagVO subjectSourceTagVO, List<String> infoSourceWebSiteNames, List<String> infoSourceIds) {
boolean flag = false; boolean flag = false;
LambdaQueryWrapper<SubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<SubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectInfoSourceMap::getSubjectId, subjectId); queryWrapper.eq(SubjectInfoSourceMap::getSubjectId, subjectId);
...@@ -225,7 +241,10 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -225,7 +241,10 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
} else { } else {
//判断 信息源绑定是否变化 //判断 信息源绑定是否变化
Set<String> sourceIdSet = mapList.stream().filter(e -> e.getType() == 1).map(SubjectInfoSourceMap::getSourceId).collect(Collectors.toSet()); Set<String> sourceIdSet = mapList.stream().filter(e -> e.getType() == 1).map(SubjectInfoSourceMap::getSourceId).collect(Collectors.toSet());
Set<String> sourceColumnSet = infoSourceService.directSourceColumnSet(infoSourceWebSiteNames); Set<String> sourceColumnSet = new HashSet<>();
if (CollectionUtils.isNotEmpty(infoSourceWebSiteNames)) {
sourceColumnSet = infoSourceService.directSourceColumnSet(infoSourceWebSiteNames);
}
sourceColumnSet.addAll(infoSourceIds); sourceColumnSet.addAll(infoSourceIds);
if (!sourceIdSet.equals(sourceColumnSet)) { if (!sourceIdSet.equals(sourceColumnSet)) {
flag = true; flag = true;
......
...@@ -72,7 +72,7 @@ public class HttpUtil { ...@@ -72,7 +72,7 @@ public class HttpUtil {
* @param charset 编码格式 * @param charset 编码格式
* @return 页面内容 * @return 页面内容
*/ */
public static String doGet(String url, Map<String, String> params, String charset) { public static String doGet(String url, Map<String, String> params, Map<String,String> headers,String charset) {
if (StringUtils.isBlank(url)) { if (StringUtils.isBlank(url)) {
return null; return null;
} }
...@@ -89,6 +89,13 @@ public class HttpUtil { ...@@ -89,6 +89,13 @@ public class HttpUtil {
url += "?" + EntityUtils.toString(new UrlEncodedFormEntity(pairs, charset)); url += "?" + EntityUtils.toString(new UrlEncodedFormEntity(pairs, charset));
} }
HttpGet httpGet = new HttpGet(url); HttpGet httpGet = new HttpGet(url);
if (!CollectionUtils.isEmpty(headers)) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
httpGet.setHeader(key, value);
}
}
CloseableHttpResponse response = httpClient.execute(httpGet); CloseableHttpResponse response = httpClient.execute(httpGet);
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != 200) { if (statusCode != 200) {
......
...@@ -3,6 +3,8 @@ package com.zzsn.event.util; ...@@ -3,6 +3,8 @@ package com.zzsn.event.util;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.zzsn.event.vo.log.Source;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,6 +20,7 @@ import java.util.Map; ...@@ -18,6 +20,7 @@ import java.util.Map;
* @author lkg * @author lkg
* @date 2025/1/23 * @date 2025/1/23
*/ */
@Slf4j
@Service @Service
public class PythonUtil { public class PythonUtil {
...@@ -106,8 +109,19 @@ public class PythonUtil { ...@@ -106,8 +109,19 @@ public class PythonUtil {
public void clearDuplicateHistory(String subjectId) { public void clearDuplicateHistory(String subjectId) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("subjectId", subjectId); params.put("subjectId", subjectId);
Map<String,String> headers = new HashMap<>();
headers.put("Content-Type", "application/json;charset=UTF-8");
headers.put("Accept", "application/json");
headers.put("Authorization", "!0gwY$5S@5V&A_+XEu)");
try { try {
HttpUtil.doGet(clearDuplicateHistoryUrl, params, "UTF-8"); String response = HttpUtil.doGet(clearDuplicateHistoryUrl, params, headers, "UTF-8");
JSONObject jsonObject = JSONObject.parseObject(response);
String isHandleSuccess = jsonObject.getString("isHandleSuccess");
if (isHandleSuccess.equals("true")) {
log.info("专题-{},清空数据,调用python接口清空去重服务历史数据请求发送成功",subjectId);
} else {
log.info("python清空去重服务历史数据接口异常");
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; ...@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.sql.Date; import java.util.Date;
import java.util.List; import java.util.List;
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论