提交 d4e0aa78 作者: 925993793@qq.com

平台专题:统战部风险分析页面接口封装

上级 91213800
...@@ -23,6 +23,7 @@ public class Constants { ...@@ -23,6 +23,7 @@ public class Constants {
public static final String SUBJECT_INDEX = "subjectdatabase"; public static final String SUBJECT_INDEX = "subjectdatabase";
//es 采集库索引 //es 采集库索引
public static final String COLLECT_INDEX = "basedata"; public static final String COLLECT_INDEX = "basedata";
public static final String COLLECT_MIDDLE_INDEX = "middlesubjectdatabase";
//专题事件脉络展示 伪事件脉络 的资讯数量阈值 //专题事件脉络展示 伪事件脉络 的资讯数量阈值
public static final int FAKE_NUM = 6; public static final int FAKE_NUM = 6;
......
package com.zzsn.event.controller.common; package com.zzsn.event.controller.common;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -9,6 +10,7 @@ import com.zzsn.event.entity.Subject; ...@@ -9,6 +10,7 @@ import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.SysDictItem; import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.es.EsService; import com.zzsn.event.es.EsService;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.util.CalculateUtil;
import com.zzsn.event.util.DateUtil; import com.zzsn.event.util.DateUtil;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.Label; import com.zzsn.event.vo.es.Label;
...@@ -18,10 +20,9 @@ import org.apache.commons.collections4.MapUtils; ...@@ -18,10 +20,9 @@ import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.time.ZoneId;
import java.util.HashMap; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -46,6 +47,8 @@ public class StatisticalAnalysisController { ...@@ -46,6 +47,8 @@ public class StatisticalAnalysisController {
private ClbLabelService clbLabelService; private ClbLabelService clbLabelService;
@Autowired @Autowired
private InformationService informationService; private InformationService informationService;
@Autowired
private CommonService commonService;
/** /**
* 概述分析 * 概述分析
...@@ -92,7 +95,7 @@ public class StatisticalAnalysisController { ...@@ -92,7 +95,7 @@ public class StatisticalAnalysisController {
} }
} }
//补充数据 //补充数据
supplyData(countList,bindLabelList,labelMap); supplyData(countList, bindLabelList, labelMap);
overviewAnalysisVO.setInfoCount(totalCount); overviewAnalysisVO.setInfoCount(totalCount);
overviewAnalysisVO.setCountList(countList); overviewAnalysisVO.setCountList(countList);
return Result.OK(overviewAnalysisVO); return Result.OK(overviewAnalysisVO);
...@@ -201,10 +204,10 @@ public class StatisticalAnalysisController { ...@@ -201,10 +204,10 @@ public class StatisticalAnalysisController {
public Result<?> dataSource(@RequestBody InfoDataSearchCondition searchCondition) { public Result<?> dataSource(@RequestBody InfoDataSearchCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>(); List<CountVO> dataList = new ArrayList<>();
List<Label> bindLabelList = bindLabelList(searchCondition.getSubjectId()); List<Label> bindLabelList = bindLabelList(searchCondition.getSubjectId());
Map<String, Label> labelMap = bindLabelList.stream().collect(Collectors.toMap(label-> label.getLabelMark() + "-"+label.getRelationId(), label -> label)); Map<String, Label> labelMap = bindLabelList.stream().collect(Collectors.toMap(label -> label.getLabelMark() + "-" + label.getRelationId(), label -> label));
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) { if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
List<String> includeValues = new ArrayList<>(); List<String> includeValues = new ArrayList<>();
bindLabelList.forEach(e -> includeValues.add(e.getLabelMark() + "-" +e.getRelationId())); bindLabelList.forEach(e -> includeValues.add(e.getLabelMark() + "-" + e.getRelationId()));
searchCondition.setIncludeValues(includeValues.toArray(new String[0])); searchCondition.setIncludeValues(includeValues.toArray(new String[0]));
dataList = esService.groupByInfoSourceTag(searchCondition); dataList = esService.groupByInfoSourceTag(searchCondition);
} else { } else {
...@@ -226,8 +229,6 @@ public class StatisticalAnalysisController { ...@@ -226,8 +229,6 @@ public class StatisticalAnalysisController {
} }
/** /**
* 资讯数量top的信息源统计 * 资讯数量top的信息源统计
* *
...@@ -375,4 +376,104 @@ public class StatisticalAnalysisController { ...@@ -375,4 +376,104 @@ public class StatisticalAnalysisController {
} }
} }
} }
/*--------------------------------------------以下为【统战部】风险评估页面接口---------------------------------------------------------*/
/**
* 单个国家统计
*
* @param subjectId 专题id
* @param country 国家名称
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/6/7
*/
@GetMapping("/singleCcountryStatistic")
public Result<?> singleCountryStatistic(@RequestParam String subjectId, @RequestParam String country,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) {
Map<String, Object> map = esService.singleCountryStatistic(subjectId, country, startTime, endTime);
return Result.OK(map);
}
/**
* 按国家统计
*
* @param subjectId 专题id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/6/7
*/
@GetMapping("/countryStatistic")
public Result<?> countryStatistic(@RequestParam String subjectId,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) {
List<CountVO> countVOS = esService.countryStatistic(subjectId, startTime, endTime);
return Result.OK(countVOS);
}
/**
* 按风险统计
*
* @param subjectId 专题id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/6/7
*/
@GetMapping("/riskTypeStatistic")
public Result<?> riskTypeStatistic(@RequestParam String subjectId,
@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) {
List<CountVO> countVOS = esService.riskTypeStatistic(subjectId, startTime, endTime);
return Result.OK(countVOS);
}
@GetMapping("/monthStatistic")
public Result<?> monthStatistic(@RequestParam String subjectId) {
DateTime startDateTime = cn.hutool.core.date.DateUtil.offsetMonth(new Date(), -13);
String startTime = startDateTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().withDayOfMonth(1).toLocalDate().atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
String endTime = cn.hutool.core.date.DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
List<CountVO> countVOS = esService.groupByMonth(subjectId, startTime, endTime);
List<String> months = DateUtil.getMonthsBetween(startTime, endTime);
for (String month : months) {
boolean exist = countVOS.stream().anyMatch(e -> month.equals(e.getName()));
if (!exist) {
CountVO countVO = new CountVO();
countVO.setName(month);
countVO.setValue(0L);
countVOS.add(countVO);
}
}
countVOS.sort(Comparator.comparing(CountVO::getName));
for (int i = 1; i < countVOS.size(); i++) {
CountVO before = countVOS.get(i - 1);
CountVO current = countVOS.get(i);
if (before.getValue() == 0) {
current.setPercentage("0");
} else {
long subtract = current.getValue() - before.getValue();
String divide = CalculateUtil.divide(String.valueOf(subtract), String.valueOf(before.getValue()), 2);
current.setPercentage(divide);
}
}
countVOS.remove(0);
return Result.OK(countVOS);
}
@GetMapping("/sourceStatistic")
public Result<?> sourceStatistic(@RequestParam String subjectId) {
Map<String, Integer> map = new HashMap<>();
map.put("sourceType", 4);
List<String> subjectIds = new ArrayList<>();
subjectIds.add(subjectId);
Map<String, Integer> sourceCountMap = commonService.bindSourceCount(subjectIds);
map.put("sourceNum", sourceCountMap.get(subjectId));
int collectCount = esService.currentCollectCount(subjectId);
map.put("collectNum", collectCount);
return Result.OK(map);
}
} }
...@@ -2,6 +2,7 @@ package com.zzsn.event.util; ...@@ -2,6 +2,7 @@ package com.zzsn.event.util;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
...@@ -135,6 +136,27 @@ public class DateUtil { ...@@ -135,6 +136,27 @@ public class DateUtil {
return dateList; return dateList;
} }
public static List<String> getMonthsBetween(String startDateStr, String endDateStr) {
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
LocalDate startDate = LocalDate.parse(startDateStr, dateFormatter);
LocalDate endDate = LocalDate.parse(endDateStr, dateFormatter);
List<String> months = new ArrayList<>();
YearMonth startYearMonth = YearMonth.from(startDate);
YearMonth endYearMonth = YearMonth.from(endDate);
for (YearMonth yearMonth = startYearMonth;
!yearMonth.isAfter(endYearMonth);
yearMonth = yearMonth.plusMonths(1)) {
months.add(yearMonth.format(monthFormatter));
}
return months;
}
public static String format(Date d, String format){ public static String format(Date d, String format){
if (d == null) { if (d == null) {
return ""; return "";
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论