|
|
@@ -37,6 +37,7 @@ import java.time.ZoneOffset;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
@@ -131,7 +132,29 @@ public class ContentScreenJob {
|
|
|
return SpiderContentScreenStatusEnum.PASSED.getCode();
|
|
|
}
|
|
|
|
|
|
- private Integer judgeRoughScreenStatus(Object object) {
|
|
|
+ /**
|
|
|
+ * 规则判断:hardcode
|
|
|
+ */
|
|
|
+ private Integer judgeRoughScreenStatus(JSONObject jsonObject, List<TitleAnalyseConfigDTO.StrategyConfig> strategyConfigs) {
|
|
|
+ if (Objects.isNull(jsonObject) || jsonObject.isEmpty() || Objects.isNull(strategyConfigs) || strategyConfigs.isEmpty()) {
|
|
|
+ return SpiderContentScreenStatusEnum.ABANDONED.getCode();
|
|
|
+ }
|
|
|
+ //全部满足
|
|
|
+ for (TitleAnalyseConfigDTO.StrategyConfig strategyConfig : strategyConfigs) {
|
|
|
+ String strategyName = strategyConfig.getStrategyName();
|
|
|
+ Double minScore = strategyConfig.getMinScore();
|
|
|
+ if (Objects.isNull(strategyName) || strategyName.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ JSONObject resultJson = jsonObject.getJSONObject(strategyName);
|
|
|
+ if (Objects.isNull(resultJson) || resultJson.isEmpty()) {
|
|
|
+ return SpiderContentScreenStatusEnum.ABANDONED.getCode();
|
|
|
+ }
|
|
|
+ Double score = resultJson.getDouble("最终综合得分");
|
|
|
+ if (Objects.isNull(score) || score < minScore) {
|
|
|
+ return SpiderContentScreenStatusEnum.ABANDONED.getCode();
|
|
|
+ }
|
|
|
+ }
|
|
|
return SpiderContentScreenStatusEnum.PASSED.getCode();
|
|
|
}
|
|
|
|
|
|
@@ -209,7 +232,32 @@ public class ContentScreenJob {
|
|
|
return SpiderContentScreenStatusEnum.PASSED.getCode();
|
|
|
}
|
|
|
|
|
|
- private Integer judgePrecisionScreenStatus(Object object) {
|
|
|
+ /**
|
|
|
+ * 文章规则判断:hardcode
|
|
|
+ */
|
|
|
+ private Integer judgePrecisionScreenStatus(JSONObject jsonObject, List<ArticleAnalyseConfigDTO.StrategyConfig> strategyConfigs) {
|
|
|
+ if (Objects.isNull(jsonObject) || jsonObject.isEmpty() || Objects.isNull(strategyConfigs) || strategyConfigs.isEmpty()) {
|
|
|
+ return SpiderContentScreenStatusEnum.ABANDONED.getCode();
|
|
|
+ }
|
|
|
+ for (ArticleAnalyseConfigDTO.StrategyConfig strategyConfig : strategyConfigs) {
|
|
|
+ String strategyName = strategyConfig.getStrategyName();
|
|
|
+ Double minScore = strategyConfig.getMinScore();
|
|
|
+ if (Objects.isNull(strategyName) || strategyName.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(strategyName);
|
|
|
+ if (Objects.isNull(resultJson) || resultJson.isEmpty()) {
|
|
|
+ return SpiderContentScreenStatusEnum.ABANDONED.getCode();
|
|
|
+ }
|
|
|
+ JSONObject finalJson = resultJson.getJSONObject("综合判定");
|
|
|
+ if (Objects.isNull(finalJson) || finalJson.isEmpty()) {
|
|
|
+ return SpiderContentScreenStatusEnum.ABANDONED.getCode();
|
|
|
+ }
|
|
|
+ Double score = finalJson.getDouble("最终综合得分");
|
|
|
+ if (Objects.isNull(score) || score < minScore) {
|
|
|
+ return SpiderContentScreenStatusEnum.ABANDONED.getCode();
|
|
|
+ }
|
|
|
+ }
|
|
|
return SpiderContentScreenStatusEnum.PASSED.getCode();
|
|
|
}
|
|
|
|
|
|
@@ -320,9 +368,9 @@ public class ContentScreenJob {
|
|
|
.toInstant()
|
|
|
.toEpochMilli();
|
|
|
XxlJobLogger.log("titleAnalyseConfigDTO config is " + titleAnalyseConfigDTO);
|
|
|
- List<TitleAnalyseStrategyEnum> titleAnalyseStrategyEnums = TitleAnalyseStrategyEnum.getInstanceByValues(titleAnalyseConfigDTO.getStrategies());
|
|
|
- if (Objects.isNull(titleAnalyseStrategyEnums) || titleAnalyseStrategyEnums.isEmpty()) {
|
|
|
- XxlJobLogger.log("titleAnalyseStrategyEnums is null or empty");
|
|
|
+ List<TitleAnalyseConfigDTO.StrategyConfig> strategies = titleAnalyseConfigDTO.getStrategies();
|
|
|
+ if (Objects.isNull(strategies) || strategies.isEmpty()) {
|
|
|
+ XxlJobLogger.log("strategies is null or empty");
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
List<SpiderContent> contentList = getRoughScreenSpiderContent();
|
|
|
@@ -339,11 +387,18 @@ public class ContentScreenJob {
|
|
|
}
|
|
|
//执行策略
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- for (TitleAnalyseStrategyEnum strategy : titleAnalyseStrategyEnums) {
|
|
|
- TitleAnalyseStrategy titleAnalyseStrategy = titleAnalyseStrategyMap.get(strategy);
|
|
|
+ for (TitleAnalyseConfigDTO.StrategyConfig strategyConfig : strategies) {
|
|
|
+ String strategyName = strategyConfig.getStrategyName();
|
|
|
+ if (StringUtils.isBlank(strategyName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TitleAnalyseStrategy titleAnalyseStrategy = titleAnalyseStrategyMap.get(strategyName);
|
|
|
+ if (Objects.isNull(titleAnalyseStrategy)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
String result = titleAnalyseStrategy.execute();
|
|
|
if (StringUtils.isNotBlank(result)) {
|
|
|
- jsonObject.put(strategy.name(), result);
|
|
|
+ jsonObject.put(strategyName, result);
|
|
|
}
|
|
|
}
|
|
|
if (jsonObject.isEmpty()) {
|
|
|
@@ -352,8 +407,7 @@ public class ContentScreenJob {
|
|
|
content.setUpdateTime(System.currentTimeMillis());
|
|
|
spiderContentMapper.updateByPrimaryKeySelective(content);
|
|
|
} else {
|
|
|
- //TODO
|
|
|
- Integer aiRoughStatus = judgeRoughScreenStatus(jsonObject);
|
|
|
+ Integer aiRoughStatus = judgeRoughScreenStatus(jsonObject, strategies);
|
|
|
content.setAiRoughStatus(aiRoughStatus);
|
|
|
content.setAiRoughResult(jsonObject.toJSONString());
|
|
|
if (aiRoughStatus == SpiderContentScreenStatusEnum.PASSED.getCode()) {
|
|
|
@@ -386,9 +440,9 @@ public class ContentScreenJob {
|
|
|
.toInstant()
|
|
|
.toEpochMilli();
|
|
|
XxlJobLogger.log("articleAnalyseConfigDTO config is " + articleAnalyseConfigDTO);
|
|
|
- List<ArticleAnalyseStrategyEnum> articleAnalyseStrategyEnums = ArticleAnalyseStrategyEnum.getInstanceByValues(articleAnalyseConfigDTO.getStrategies());
|
|
|
- if (Objects.isNull(articleAnalyseStrategyEnums) || articleAnalyseStrategyEnums.isEmpty()) {
|
|
|
- XxlJobLogger.log("articleAnalyseStrategyEnums is null or empty");
|
|
|
+ List<ArticleAnalyseConfigDTO.StrategyConfig> strategies = articleAnalyseConfigDTO.getStrategies();
|
|
|
+ if (Objects.isNull(strategies) || strategies.isEmpty()) {
|
|
|
+ XxlJobLogger.log("strategies is null or empty");
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
List<SpiderContent> contentList = spiderMapperExt.getRoughScreenSpiderContentHasContent();
|
|
|
@@ -405,11 +459,18 @@ public class ContentScreenJob {
|
|
|
}
|
|
|
//执行策略
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- for (ArticleAnalyseStrategyEnum strategy : articleAnalyseStrategyEnums) {
|
|
|
- ArticleAnalyseStrategy articleAnalyseStrategy = articleAnalyseStrategyMap.get(strategy);
|
|
|
+ for (ArticleAnalyseConfigDTO.StrategyConfig strategyConfig : strategies) {
|
|
|
+ String strategyName = strategyConfig.getStrategyName();
|
|
|
+ if (StringUtils.isBlank(strategyName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ArticleAnalyseStrategy articleAnalyseStrategy = articleAnalyseStrategyMap.get(strategyName);
|
|
|
+ if (Objects.isNull(articleAnalyseStrategy)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
String result = articleAnalyseStrategy.execute();
|
|
|
if (StringUtils.isNotBlank(result)) {
|
|
|
- jsonObject.put(strategy.name(), result);
|
|
|
+ jsonObject.put(strategyName, result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -419,8 +480,7 @@ public class ContentScreenJob {
|
|
|
content.setUpdateTime(System.currentTimeMillis());
|
|
|
spiderContentMapper.updateByPrimaryKeySelective(content);
|
|
|
} else {
|
|
|
- //TODO
|
|
|
- Integer aiPrecisionStatus = judgePrecisionScreenStatus(jsonObject);
|
|
|
+ Integer aiPrecisionStatus = judgePrecisionScreenStatus(jsonObject, strategies);
|
|
|
content.setAiPrecisionStatus(aiPrecisionStatus);
|
|
|
content.setAiPrecisionResult(jsonObject.toJSONString());
|
|
|
if (aiPrecisionStatus == SpiderContentScreenStatusEnum.PASSED.getCode()) {
|