提交 d86a6f11 作者: 925993793@qq.com

专题配置校验相关接口调试修改

上级 8e77f4a4
......@@ -93,7 +93,7 @@ public class SubjectManageController {
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired
private PythonUtil pythonUtil;
@Autowired(required = false)
@Autowired
private RemoteModelService remoteModelService;
......@@ -585,7 +585,11 @@ public class SubjectManageController {
public Result<?> configScoreModel(@RequestBody ScoreModelVo scoreModelVo) {
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();
}
......
......@@ -714,7 +714,7 @@ public class EsService {
* @date 2024/5/6
*/
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();
//设置分页参数
Integer pageNo = searchCondition.getPageNo();
......@@ -1652,7 +1652,7 @@ public class EsService {
*/
private List<CountVO> groupByTerm(InfoDataSearchCondition searchCondition, String groupName, String field, boolean sort) {
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.trackTotalHits(true);
searchSourceBuilder.size(0);
......@@ -1867,7 +1867,7 @@ public class EsService {
//获取es查询结果
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后,显示准确数量
searchSourceBuilder.trackTotalHits(true);
//未删除
......@@ -2039,7 +2039,7 @@ public class EsService {
buildSplitWordShouldQuery(boolQuery, searchInfo, "origin", searchAccuracy);
}
}
allBoolQuery.should(boolQuery);
allBoolQuery.must(boolQuery);
}
}
......
package com.zzsn.event.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -21,6 +22,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -73,6 +75,9 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
@Autowired
private PythonUtil pythonUtil;
@Value("${clb.subject.default.processing.advanceMonth}")
private Integer defaultAdvanceMonth;
//关键词默认分类
private static final String KEYWORDS_TYPE_ID = "1476498704680194050";
//默认项目
......@@ -132,12 +137,22 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
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;
}
//判断关键词配置是否变化
List<SearchWordVO> keywordsNew = subjectSimpleVO.getKeywords();
List<SearchWordVO> keywordsOld = subjectDetailVO.getKeywords();
List<SearchWordVO> keywordsNew = subjectSimpleVO.getKeywords();
boolean judgeKeyword = judgeKeyword(keywordsNew, keywordsOld);
if (judgeKeyword) {
return false;
......@@ -169,7 +184,8 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (oldMap.containsKey(searchWordVO.getId())) {
SearchWordVO old = oldMap.get(searchWordVO.getId());
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()))) {
flag = true;
}
......@@ -187,14 +203,14 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
/**
* 判断信息源配置是否发生变化 true 是;false 否
*
* @param subjectId 专题id
* @param subjectSourceTagVO 信息源标签信息(编辑时前端传参)
* @param subjectId 专题id
* @param subjectSourceTagVO 信息源标签信息(编辑时前端传参)
* @param infoSourceWebSiteNames 定向信息源名称集合(编辑时前端传参)
* @param infoSourceIds 推荐信息源id集合(编辑时前端传参)
* @param infoSourceIds 推荐信息源id集合(编辑时前端传参)
* @author lkg
* @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;
LambdaQueryWrapper<SubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectInfoSourceMap::getSubjectId, subjectId);
......@@ -225,7 +241,10 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
} else {
//判断 信息源绑定是否变化
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);
if (!sourceIdSet.equals(sourceColumnSet)) {
flag = true;
......
......@@ -72,7 +72,7 @@ public class HttpUtil {
* @param charset 编码格式
* @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)) {
return null;
}
......@@ -89,6 +89,13 @@ public class HttpUtil {
url += "?" + EntityUtils.toString(new UrlEncodedFormEntity(pairs, charset));
}
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);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != 200) {
......
......@@ -3,6 +3,8 @@ package com.zzsn.event.util;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
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.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -18,6 +20,7 @@ import java.util.Map;
* @author lkg
* @date 2025/1/23
*/
@Slf4j
@Service
public class PythonUtil {
......@@ -106,8 +109,19 @@ public class PythonUtil {
public void clearDuplicateHistory(String subjectId) {
Map<String, String> params = new HashMap<>();
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 {
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) {
e.printStackTrace();
}
......
......@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.sql.Date;
import java.util.Date;
import java.util.List;
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论