Browse Source

Merge remote-tracking branch 'origin/master'

main
parent
commit
dded18dc60
  1. 13
      sql/1114.sql
  2. 2
      src/main/java/com/biutag/supervision/constants/AppConstants.java
  3. 10
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ModelController.java
  4. 43
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfileDepartController.java
  5. 86
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java
  6. 55
      src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskClueController.java
  7. 7
      src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskPersonalController.java
  8. 58
      src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskScoreRuleController.java
  9. 15
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ScoreController.java
  10. 7
      src/main/java/com/biutag/supervision/mapper/ModelClassMapper.java
  11. 8
      src/main/java/com/biutag/supervision/mapper/RiskModelTaskClueMapper.java
  12. 8
      src/main/java/com/biutag/supervision/mapper/RiskScoreRuleMapper.java
  13. 9
      src/main/java/com/biutag/supervision/pojo/domain/NegativeInfo.java
  14. 7
      src/main/java/com/biutag/supervision/pojo/domain/ProfilePolice.java
  15. 17
      src/main/java/com/biutag/supervision/pojo/domain/RiskPersonalDetail.java
  16. 2
      src/main/java/com/biutag/supervision/pojo/entity/Model.java
  17. 85
      src/main/java/com/biutag/supervision/pojo/entity/RiskModelTaskClue.java
  18. 58
      src/main/java/com/biutag/supervision/pojo/entity/RiskScoreRule.java
  19. 22
      src/main/java/com/biutag/supervision/pojo/model/ModelClassModel.java
  20. 29
      src/main/java/com/biutag/supervision/pojo/param/RiskModelTaskClueQueryParam.java
  21. 4
      src/main/java/com/biutag/supervision/pojo/vo/MenuTree.java
  22. 2
      src/main/java/com/biutag/supervision/pojo/vo/ModelTree.java
  23. 45
      src/main/java/com/biutag/supervision/pojo/vo/RiskScoreRuleTree.java
  24. 6
      src/main/java/com/biutag/supervision/service/BusinessDepartService.java
  25. 1
      src/main/java/com/biutag/supervision/service/ModelClassService.java
  26. 121
      src/main/java/com/biutag/supervision/service/ModelClueService.java
  27. 5
      src/main/java/com/biutag/supervision/service/ModelService.java
  28. 205
      src/main/java/com/biutag/supervision/service/NegativeScoreService.java
  29. 11
      src/main/java/com/biutag/supervision/service/RiskModelTaskClueService.java
  30. 50
      src/main/java/com/biutag/supervision/service/RiskScoreRuleService.java
  31. 2
      src/main/java/com/biutag/supervision/support/ModelClueDistributionAware.java
  32. 6
      src/main/resources/application-local.yml
  33. 2
      src/main/resources/mapper/ProfilePoliceMapper.xml
  34. BIN
      src/main/resources/static/templates/【工作机制】个人极端暴力风险数字督察灵敏感知体系风险赋分及预警处置机制.doc
  35. 41
      src/test/java/com/biutag/supervision/tools/ExcelTest.java
  36. 2
      src/test/java/com/biutag/supervision/tools/GenCodeTests.java
  37. 26
      src/test/java/com/biutag/supervision/tools/HdtExcelDto.java

13
sql/1114.sql

@ -0,0 +1,13 @@
CREATE TABLE `risk_score_rule` (
`id` int NOT NULL AUTO_INCREMENT,
`pid` int DEFAULT NULL,
`risk_name` varchar(255) COMMENT '风险因素',
`score` varchar(255) COMMENT '分值',
`rule_desc` text COLLATE utf8mb4_general_ci COMMENT '规则描述',
`weight` int DEFAULT NULL COMMENT '权重',
`status` tinyint DEFAULT NULL COMMENT '状态',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`sort_id` int DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 COMMENT='个人极端赋分规则';

2
src/main/java/com/biutag/supervision/constants/AppConstants.java

@ -2,7 +2,7 @@ package com.biutag.supervision.constants;
public class AppConstants {
public static final int MENU_ROOT_ID = 0;
public static final Integer TREE_ROOT_ID = 0;
// 单位
public static final String DICT_CONTENT_ROOT_PARENT_CODE = "-1";

10
src/main/java/com/biutag/supervision/controller/sensitivePerception/ModelController.java

@ -3,12 +3,12 @@ package com.biutag.supervision.controller.sensitivePerception;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.mapper.ModelClassMapper;
import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.pojo.entity.ModelClass;
import com.biutag.supervision.pojo.model.ModelClassModel;
import com.biutag.supervision.pojo.param.ModelQueryParam;
import com.biutag.supervision.pojo.vo.ModelTree;
import com.biutag.supervision.service.ModelClassService;
import com.biutag.supervision.service.ModelService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@ -24,7 +24,7 @@ public class ModelController {
private final ModelService modelService;
private final ModelClassService modelClassService;
private final ModelClassMapper modelClassMapper;
@GetMapping
public Result<Page<Model>> list(ModelQueryParam queryParam) {
@ -39,13 +39,14 @@ public class ModelController {
@GetMapping("tree")
public Result<List<ModelTree>> tree() {
List<ModelClass> modelClasses = modelClassService.list();
List<ModelClassModel> modelClasses = modelClassMapper.selectListAll();
List<Model> models = modelService.list();
List<ModelTree> list = new ArrayList<>();
list.addAll(modelClasses.stream().map(item -> {
ModelTree node = new ModelTree();
node.setValue(item.getId());
node.setLabel(item.getName());
node.setSize(item.getSize());
node.setType("modelClass");
List<ModelTree> children = models.stream().filter(model -> item.getId().equals(model.getClassId())).map(ModelTree::of).toList();
node.setChildren(children);
@ -57,7 +58,6 @@ public class ModelController {
@PostMapping
public Result<Boolean> add(@RequestBody Model model) {
return Result.success(modelService.saveModel(model));
}

43
src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfileDepartController.java

@ -63,6 +63,8 @@ public class ProfileDepartController {
return Result.success(page);
}
private final NegativeScoreDepartService negativeScoreDepartService;
@GetMapping("{departId}")
public Result<ProfileDepart> profile(@PathVariable String departId, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date beginTime, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
if (Objects.isNull(beginTime)) {
@ -80,10 +82,11 @@ public class ProfileDepartController {
profileDepart.getDepartInfo().setMainRole(polices.stream().filter(item -> "正职".equals(item.getPosition())).findFirst().map(SupPolice::getName).orElse(null));
profileDepart.getDepartInfo().setDeputyRole(polices.stream().filter(item -> "副职".equals(item.getPosition())).map(SupPolice::getName).toList());
List<Negative> list = negativeService.list(new LambdaQueryWrapper<Negative>().eq(Negative::getInvolveDepartId, departId)
.between(Negative::getDiscoveryTime, beginTime, endTime)
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue())));
List<String> negativeIds = list.stream().map(Negative::getId).toList();
List<NegativeScoreDepart> list = negativeScoreDepartService.list(new LambdaQueryWrapper<NegativeScoreDepart>()
.eq(NegativeScoreDepart::getDepartId, departId)
.between(NegativeScoreDepart::getDiscoveryTime, beginTime, endTime));
List<String> negativeIds = list.stream().map(NegativeScoreDepart::getNegativeId).toList();
int negativePoliceSize = negativeIds.isEmpty() ? 0 : profileDepartMapper.countByNegativeIdsAndPersonTypes(negativeIds, List.of(PersonTypeEnum.police.getValue()));
profileDepart.getDepartInfo().setNegativePoliceSize(negativePoliceSize);
int negativeAuxSize = negativeIds.isEmpty() ? 0 : profileDepartMapper.countByNegativeIdsAndPersonTypes(negativeIds, List.of(PersonTypeEnum.aux.getValue(), PersonTypeEnum.xj.getValue()));
@ -96,42 +99,32 @@ public class ProfileDepartController {
.eq(BusinessDepart::getBusinessType, BusinessTypeEnum.JCJ_110.getValue())
.eq(BusinessDepart::getDepartId, departId))
.stream().mapToInt(BusinessDepart::getNumber).sum();
int jcj110Size = negativeService.list(new LambdaQueryWrapper<Negative>()
.between(Negative::getDiscoveryTime, beginTime, endTime)
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.JCJ_110.getValue())
.eq(Negative::getInvolveDepartId, departId)
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size();
int jcj122BusinessSize = businessDepartService.list(new LambdaQueryWrapper<BusinessDepart>()
.between(BusinessDepart::getDate, beginTime, endTime)
.eq(BusinessDepart::getBusinessType, BusinessTypeEnum.JCJ_122.getValue())
.eq(BusinessDepart::getDepartId, departId))
.stream().mapToInt(BusinessDepart::getNumber).sum();
int jcj122Size = negativeService.list(new LambdaQueryWrapper<Negative>()
.between(Negative::getDiscoveryTime, beginTime, endTime)
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.JCJ_122.getValue())
.eq(Negative::getInvolveDepartId, departId)
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size();
int zfbaBusinessSize = businessDepartService.list(new LambdaQueryWrapper<BusinessDepart>()
.between(BusinessDepart::getDate, beginTime, endTime)
.eq(BusinessDepart::getBusinessType, BusinessTypeEnum.ZFBA.getValue())
.eq(BusinessDepart::getDepartId, departId))
.stream().mapToInt(BusinessDepart::getNumber).sum();
int zfbaSize = negativeService.list(new LambdaQueryWrapper<Negative>()
.between(Negative::getDiscoveryTime, beginTime, endTime)
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.ZFBA.getValue())
.eq(Negative::getInvolveDepartId, departId)
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size();
profileDepart.getNegativeInfo().setJcj110Size(jcj110Size).setJcj110BusinessSize(jcj110BusinessSize)
.setJcj122Size(jcj122Size)
profileDepart.getNegativeInfo()
.setJcj110Size(list.stream().filter(item -> BusinessTypeEnum.JCJ_110.getValue().equals(item.getBusinessTypeCode())).count())
.setJcj110BusinessSize(jcj110BusinessSize)
.setJcj122Size(list.stream().filter(item -> BusinessTypeEnum.JCJ_122.getValue().equals(item.getBusinessTypeCode())).count())
.setJcj122BusinessSize(jcj122BusinessSize)
.setZfbaBusinessSize(zfbaBusinessSize).setZfbaSize(zfbaSize);
.setZfbaBusinessSize(zfbaBusinessSize)
.setZfbaSize(list.stream().filter(item -> BusinessTypeEnum.ZFBA.getValue().equals(item.getBusinessTypeCode())).count());
List<Negative> negatives = negativeService.listByIds(negativeIds);
// 问题来源占比
Map<String, List<Negative>> problemSourcesGroup = list.stream().collect(Collectors.groupingBy(Negative::getProblemSourcesCode));
Map<String, List<Negative>> problemSourcesGroup = negatives.stream().collect(Collectors.groupingBy(Negative::getProblemSourcesCode));
List<PieItem> problemSourcesList = problemSourcesGroup.keySet().stream().map(key -> new PieItem(Optional.ofNullable(ProblemSourcesEnum.get(key)).map(ProblemSourcesEnum::getLabel).orElse(key), problemSourcesGroup.get(key).size())).toList();
profileDepart.setProblemSourcesList(problemSourcesList);
// 业务类型占比
Map<String, List<Negative>> businessTypeGroup = list.stream().collect(Collectors.groupingBy(Negative::getBusinessTypeCode));
Map<String, List<Negative>> businessTypeGroup = negatives.stream().collect(Collectors.groupingBy(Negative::getBusinessTypeCode));
List<PieItem> businessTypeList = businessTypeGroup.keySet().stream().map(key -> new PieItem(Optional.ofNullable(BusinessTypeEnum.get(key)).map(BusinessTypeEnum::getLabel).orElse(key),
businessTypeGroup.get(key).size())).toList();
profileDepart.setBusinessTypeList(businessTypeList);

86
src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java

@ -1,6 +1,7 @@
package com.biutag.supervision.controller.sensitivePerception;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -13,9 +14,7 @@ import com.biutag.supervision.pojo.domain.ProfileDepart;
import com.biutag.supervision.pojo.domain.ProfilePolice;
import com.biutag.supervision.pojo.dto.common.BarItem;
import com.biutag.supervision.pojo.dto.common.PieItem;
import com.biutag.supervision.pojo.entity.BusinessPolice;
import com.biutag.supervision.pojo.entity.Negative;
import com.biutag.supervision.pojo.entity.NegativeBlame;
import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.pojo.model.PoliceNegativeModel;
import com.biutag.supervision.pojo.param.DepartPoliceQueryParam;
import com.biutag.supervision.service.*;
@ -66,6 +65,9 @@ public class ProfilePoliceController {
return Result.success(page);
}
private final NegativeScorePoliceService negativeScorePoliceService;
private final NegativeProblemRelationService negativeProblemRelationService;
@GetMapping("{idCode}")
public Result<ProfilePolice> profile(@PathVariable String idCode, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date beginTime, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
if (Objects.isNull(beginTime)) {
@ -77,6 +79,8 @@ public class ProfilePoliceController {
ProfilePolice profilePolice = new ProfilePolice();
profilePolice.setPoliceInfo(policeService.getByIdCode(idCode));
List<NegativeScorePolice> negatives = negativeScorePoliceService.list(new LambdaQueryWrapper<NegativeScorePolice>().between(NegativeScorePolice::getDiscoveryTime, beginTime, endTime).eq(NegativeScorePolice::getIdCode, idCode));
int jcj110BusinessSize = businessPoliceService.list(new LambdaQueryWrapper<BusinessPolice>()
.between(BusinessPolice::getDate, beginTime, endTime)
.eq(BusinessPolice::getBusinessType, BusinessTypeEnum.JCJ_110.getValue())
@ -84,12 +88,6 @@ public class ProfilePoliceController {
.eq(BusinessPolice::getPoliceName, profilePolice.getPoliceInfo().getName()))
.stream().mapToInt(BusinessPolice::getNumber).sum();
Set<String> negativeIds = negativeBlameService.list(new LambdaQueryWrapper<NegativeBlame>().eq(NegativeBlame::getBlameIdCode, idCode)).stream().map(NegativeBlame::getNegativeId).collect(Collectors.toSet());
int jcj110Size = negativeIds.isEmpty() ? 0 : negativeService.list(new LambdaQueryWrapper<Negative>()
.between(Negative::getDiscoveryTime, beginTime, endTime)
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.JCJ_110.getValue())
.in(Negative::getId, negativeIds)
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size();
int jcj122BusinessSize = businessPoliceService.list(new LambdaQueryWrapper<BusinessPolice>()
.between(BusinessPolice::getDate, beginTime, endTime)
.eq(BusinessPolice::getBusinessType, BusinessTypeEnum.JCJ_122.getValue())
@ -97,11 +95,6 @@ public class ProfilePoliceController {
.eq(BusinessPolice::getPoliceName, profilePolice.getPoliceInfo().getName()))
.stream().mapToInt(BusinessPolice::getNumber).sum();
int jcj122Size = negativeIds.isEmpty() ? 0 : negativeService.list(new LambdaQueryWrapper<Negative>()
.between(Negative::getDiscoveryTime, beginTime, endTime)
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.JCJ_122.getValue())
.in(Negative::getId, negativeIds)
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size();
int zfbaBusinessSize = businessPoliceService.list(new LambdaQueryWrapper<BusinessPolice>()
.between(BusinessPolice::getDate, beginTime, endTime)
@ -109,46 +102,51 @@ public class ProfilePoliceController {
.eq(BusinessPolice::getEmpNo, profilePolice.getPoliceInfo().getEmpNo())
.eq(BusinessPolice::getPoliceName, profilePolice.getPoliceInfo().getName()))
.stream().mapToInt(BusinessPolice::getNumber).sum();
int zfbaSize = negativeIds.isEmpty() ? 0 : negativeService.list(new LambdaQueryWrapper<Negative>()
.between(Negative::getDiscoveryTime, beginTime, endTime)
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.ZFBA.getValue())
.in(Negative::getId, negativeIds)
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size();
profilePolice.getNegativeInfo().setJcj110BusinessSize(jcj110BusinessSize).setJcj110Size(jcj110Size)
.setJcj122BusinessSize(jcj122BusinessSize).setJcj122Size(jcj122Size)
.setZfbaBusinessSize(zfbaBusinessSize).setZfbaSize(zfbaSize);
List<Negative> list = negativeIds.isEmpty() ? new ArrayList<>() : negativeService.list(new LambdaQueryWrapper<Negative>()
.between(Negative::getDiscoveryTime, beginTime, endTime)
.in(Negative::getId, negativeIds)
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue())));
profilePolice.getNegativeInfo()
.setScore(NumberUtil.round(negatives.stream().mapToDouble(NegativeScorePolice::getScore).sum(), 2).doubleValue())
.setJcj110BusinessSize(jcj110BusinessSize)
.setSize(negatives.size())
.setJcj110Size(negatives.stream().filter(item -> BusinessTypeEnum.JCJ_110.getValue().equals(item.getBusinessTypeCode())).count())
.setJcj122BusinessSize(jcj122BusinessSize)
.setJcj122Size(negatives.stream().filter(item -> BusinessTypeEnum.JCJ_122.getValue().equals(item.getBusinessTypeCode())).count())
.setZfbaBusinessSize(zfbaBusinessSize)
.setZfbaSize(negatives.stream().filter(item -> BusinessTypeEnum.ZFBA.getValue().equals(item.getBusinessTypeCode())).count());
Set<String> negativeIds = negatives.stream().map(NegativeScorePolice::getNegativeId).collect(Collectors.toSet());
List<Negative> list = negatives.isEmpty() ? new ArrayList<>() : negativeService.list(new LambdaQueryWrapper<Negative>()
.in(Negative::getId, negativeIds));
// 问题来源占比
Map<String, List<Negative>> problemSourcesGroup = list.stream().collect(Collectors.groupingBy(Negative::getProblemSourcesCode));
List<PieItem> problemSourcesList = problemSourcesGroup.keySet().stream().map(key -> new PieItem(Optional.ofNullable(ProblemSourcesEnum.get(key)).map(ProblemSourcesEnum::getLabel).orElse(key),
List<PieItem> problemSourcesList = problemSourcesGroup.keySet().stream()
.map(key -> new PieItem(Optional.ofNullable(ProblemSourcesEnum.get(key)).map(ProblemSourcesEnum::getLabel).orElse(key),
problemSourcesGroup.get(key).size())).toList();
profilePolice.setProblemSourcesList(problemSourcesList);
// 业务类型占比
Map<String, List<Negative>> businessTypeGroup = list.stream().collect(Collectors.groupingBy(Negative::getBusinessTypeCode));
List<PieItem> businessTypeList = businessTypeGroup.keySet().stream().map(key -> new PieItem(Optional.ofNullable(BusinessTypeEnum.get(key)).map(BusinessTypeEnum::getLabel).orElse(key)
, businessTypeGroup.get(key).size())).toList();
profilePolice.setBusinessTypeList(businessTypeList);
// 风险问题构成 雷达图
List<BarItem> problemTypeBarList = profilePoliceMapper.selectProblemType(idCode, beginTime, endTime);
int max = problemTypeBarList.stream().mapToInt(BarItem::getValue).max().getAsInt();
List<ProfileDepart.RadarIndicatorItem> problemTypeRadarIndicator = problemTypeBarList.stream().map(item -> {
ProfileDepart.RadarIndicatorItem radarIndicatorItem = new ProfileDepart.RadarIndicatorItem();
radarIndicatorItem.setMax(max);
radarIndicatorItem.setName(item.getLabel());
return radarIndicatorItem;
}).toList();
List<Integer> problemTypeRadarData = problemTypeBarList.stream().map(BarItem::getValue).toList();
profilePolice.setProblemTypeRadarIndicator(problemTypeRadarIndicator);
profilePolice.setProblemTypeRadarData(problemTypeRadarData);
// 问题类型占比
if (!negativeIds.isEmpty()) {
List<String> blameIds = negativeBlameService.list(new LambdaQueryWrapper<NegativeBlame>()
.in(NegativeBlame::getNegativeId, negativeIds)
.eq(NegativeBlame::getBlameIdCode, idCode))
.stream().map(NegativeBlame::getBlameId).toList();
if (!blameIds.isEmpty()) {
List<NegativeProblemRelation> problemRelations = negativeProblemRelationService.list(new LambdaQueryWrapper<NegativeProblemRelation>()
.in(NegativeProblemRelation::getBlameId, blameIds)
.in(NegativeProblemRelation::getNegativeId, negativeIds));
Map<String, List<NegativeProblemRelation>> groups = problemRelations.stream().collect(Collectors.groupingBy(NegativeProblemRelation::getThreeLevelContent));
List<PieItem> problemTypeList = groups.keySet().stream().map(key -> new PieItem(key, groups.get(key).size())).toList();
profilePolice.setProblemTypeList(problemTypeList);
}
}
List<Object> result = negativeScoreService.calculatePoliceScore(beginTime, endTime, idCode);
profilePolice.setScore((BigDecimal) result.get(0));
profilePolice.setExpression(result.get(1).toString());
profilePolice.setRemarks(result.get(2).toString());
// 雷达图
profilePolice.setBusinessTypeRadarIndicator(Arrays.stream(BusinessTypeEnum.values())
.map(item -> new ProfileDepart.RadarIndicatorItem().setName(item.getLabel()).setMax(100)).toList());
profilePolice.setBusinessTypeScoreRadarData((List<Double>) result.get(3));
profilePolice.setBusinessTypeWeightRadarData((List<Double>) result.get(4));
return Result.success(profilePolice);
}

55
src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskClueController.java

@ -0,0 +1,55 @@
package com.biutag.supervision.controller.sensitivePerception;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.pojo.entity.RiskModelTaskClue;
import com.biutag.supervision.pojo.param.RiskModelTaskClueQueryParam;
import com.biutag.supervision.service.ModelService;
import com.biutag.supervision.service.RiskModelTaskClueService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author wxc
* @date 2024/11/14
*/
@RequiredArgsConstructor
@RequestMapping("risk/clues")
@RestController
public class RiskClueController {
private final RiskModelTaskClueService riskModelTaskClueService;
private final ModelService modelService;
@GetMapping
public Result<Page<RiskModelTaskClue>> page(RiskModelTaskClueQueryParam param) {
LambdaQueryWrapper<RiskModelTaskClue> queryWrapper = new LambdaQueryWrapper<>();
if (Objects.nonNull(param.getRiskScoreRuleId()) && !param.getRiskScoreRuleId().isEmpty()) {
List<Model> models = modelService.list(new LambdaQueryWrapper<Model>().in(Model::getRiskScoreRuleId, param.getRiskScoreRuleId()));
if (models.isEmpty()) {
return Result.success(new Page<RiskModelTaskClue>().setRecords(new ArrayList<>()).setTotal(0));
}
queryWrapper.in(RiskModelTaskClue::getModelId, models.stream().map(Model::getId).collect(Collectors.toSet()));
}
if (Objects.nonNull(param.getEventTime()) && param.getEventTime().size() == 2) {
queryWrapper.between(RiskModelTaskClue::getEventTime, param.getEventTime().get(0), param.getEventTime().get(1));
}
queryWrapper.like(StrUtil.isNotBlank(param.getName()), RiskModelTaskClue::getName, param.getName())
.like(StrUtil.isNotBlank(param.getIdCode()), RiskModelTaskClue::getIdCode, param.getIdCode())
.like(StrUtil.isNotBlank(param.getThingDesc()), RiskModelTaskClue::getThingDesc, param.getThingDesc());
queryWrapper.orderByDesc(RiskModelTaskClue::getCreateTime);
return Result.success(riskModelTaskClueService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper));
}
}

7
src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskPersonalController.java

@ -10,6 +10,7 @@ import com.biutag.supervision.service.RiskPersonalService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -36,4 +37,10 @@ public class RiskPersonalController {
return Result.success(riskPersonalService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper));
}
@GetMapping("{id}")
public Result<Page<RiskPersonal>> list(@PathVariable Integer id) {
return Result.success();
}
}

58
src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskScoreRuleController.java

@ -0,0 +1,58 @@
package com.biutag.supervision.controller.sensitivePerception;
import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.entity.RiskScoreRule;
import com.biutag.supervision.pojo.vo.RiskScoreRuleTree;
import com.biutag.supervision.service.RiskScoreRuleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author wxc
* @date 2024/11/14
*/
@RequiredArgsConstructor
@RequestMapping("risk/scoreRule")
@RestController
public class RiskScoreRuleController {
private final RiskScoreRuleService riskScoreRuleService;
@GetMapping("tree")
public Result<List<RiskScoreRuleTree>> list() {
return Result.success(riskScoreRuleService.buildTree());
}
@PostMapping
public Result<Boolean> add(@RequestBody RiskScoreRule scoreRule) {
scoreRule.setCreateTime(LocalDateTime.now());
scoreRule.setUpdateTime(LocalDateTime.now());
if (scoreRule.getPid() == 0) {
scoreRule.setLevel(1);
} else {
scoreRule.setLevel(2);
}
return Result.success(riskScoreRuleService.save(scoreRule));
}
@PutMapping
public Result<Boolean> update(@RequestBody RiskScoreRule scoreRule) {
scoreRule.setUpdateTime(LocalDateTime.now());
if (scoreRule.getPid() == 0) {
scoreRule.setLevel(1);
} else {
scoreRule.setLevel(2);
}
return Result.success(riskScoreRuleService.updateById(scoreRule));
}
@DeleteMapping("{id}")
public Result<Boolean> update(@PathVariable Integer id) {
return Result.success(riskScoreRuleService.removeById(id));
}
}

15
src/main/java/com/biutag/supervision/controller/sensitivePerception/ScoreController.java

@ -3,11 +3,9 @@ package com.biutag.supervision.controller.sensitivePerception;
import com.biutag.supervision.mapper.DepartScoreMapper;
import com.biutag.supervision.mapper.PoliceScoreMapper;
import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.entity.DepartScore;
import com.biutag.supervision.pojo.entity.PoliceScore;
import com.biutag.supervision.pojo.entity.SupDepart;
import com.biutag.supervision.pojo.entity.SupPolice;
import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.service.NegativeScoreService;
import com.biutag.supervision.service.RiskPersonalService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
@ -75,4 +73,13 @@ public class ScoreController {
return Result.success("success");
}
private final RiskPersonalService riskPersonalService;
@RequestMapping("personal")
public Result<String> updatePersonalScore() {
List<RiskPersonal> riskPersonals = riskPersonalService.list();
return Result.success("success");
}
}

7
src/main/java/com/biutag/supervision/mapper/ModelClassMapper.java

@ -2,7 +2,14 @@ package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.ModelClass;
import com.biutag.supervision.pojo.model.ModelClassModel;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface ModelClassMapper extends BaseMapper<ModelClass> {
@Select("select mc.id, mc.name, mc.sort, count(m.id) size from model_class mc left join model m on mc.id = m.class_id GROUP BY mc.id, mc.name, mc.sort order by sort")
List<ModelClassModel> selectListAll();
}

8
src/main/java/com/biutag/supervision/mapper/RiskModelTaskClueMapper.java

@ -0,0 +1,8 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.RiskModelTaskClue;
public interface RiskModelTaskClueMapper extends BaseMapper<RiskModelTaskClue> {
}

8
src/main/java/com/biutag/supervision/mapper/RiskScoreRuleMapper.java

@ -0,0 +1,8 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.RiskScoreRule;
public interface RiskScoreRuleMapper extends BaseMapper<RiskScoreRule> {
}

9
src/main/java/com/biutag/supervision/pojo/domain/NegativeInfo.java

@ -15,12 +15,15 @@ public class NegativeInfo {
private long size;
// 110接处警
private Double score;
private Integer jcj110BusinessSize;
private Integer jcj110Size;
private Long jcj110Size;
// 122接处警
private Integer jcj122BusinessSize;
private Integer jcj122Size;
private Long jcj122Size;
// 执法办案
private Integer zfbaBusinessSize;
private Integer zfbaSize;
private Long zfbaSize;
}

7
src/main/java/com/biutag/supervision/pojo/domain/ProfilePolice.java

@ -26,9 +26,10 @@ public class ProfilePolice {
private SupPolice policeInfo = new SupPolice();
private NegativeInfo negativeInfo = new NegativeInfo();
private List<PieItem> problemSourcesList = new ArrayList<>();
private List<PieItem> businessTypeList = new ArrayList<>();
private List<PieItem> problemTypeList = new ArrayList<>();
// 雷达图
private List<ProfileDepart.RadarIndicatorItem> problemTypeRadarIndicator = new ArrayList<>();
private List<Integer> problemTypeRadarData = new ArrayList<>();
private List<ProfileDepart.RadarIndicatorItem> businessTypeRadarIndicator = new ArrayList<>();
private List<Double> businessTypeScoreRadarData = new ArrayList<>();
private List<Double> businessTypeWeightRadarData = new ArrayList<>();
}

17
src/main/java/com/biutag/supervision/pojo/domain/RiskPersonalDetail.java

@ -0,0 +1,17 @@
package com.biutag.supervision.pojo.domain;
import com.biutag.supervision.pojo.entity.RiskPersonal;
import lombok.Getter;
import lombok.Setter;
/**
* @author wxc
* @date 2024/11/14
*/
@Setter
@Getter
public class RiskPersonalDetail {
private RiskPersonal riskPersonal;
}

2
src/main/java/com/biutag/supervision/pojo/entity/Model.java

@ -91,4 +91,6 @@ public class Model {
@TableField("model_sql")
private String modelSql;
private Integer riskScoreRuleId;
}

85
src/main/java/com/biutag/supervision/pojo/entity/RiskModelTaskClue.java

@ -0,0 +1,85 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class RiskModelTaskClue {
// 主键
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
// 模型id
@TableField("model_id")
private Integer modelId;
// 姓名
@TableField("name")
private String name;
// 证件号码
@TableField("id_code")
private String idCode;
// 预警内容
@TableField("thing_desc")
private String thingDesc;
// 状态 默认 0-未分发 1-已分发 2-已处理
@TableField("distribution_state")
private Boolean distributionState;
// 任务ID
@TableField("task_id")
private Integer taskId;
// 问题id
@TableField("negative_id")
private String negativeId;
// 原始id
@TableField("source_id")
private String sourceId;
// 案件id,“,”分割
@TableField("case_ids")
private String caseIds;
// 风险原因
@TableField("risk_reason")
private String riskReason;
// 数据详情 JSON
@TableField("data")
private String data;
// 分数
@TableField("score")
private Integer score;
// 发生时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("event_time")
private LocalDateTime eventTime;
// 创建时间
@TableField("create_time")
private LocalDateTime createTime;
// 修改时间
@TableField("update_time")
private LocalDateTime updateTime;
// 逻辑删除键0-未删1已删
@TableField("del")
private Boolean del;
}

58
src/main/java/com/biutag/supervision/pojo/entity/RiskScoreRule.java

@ -0,0 +1,58 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class RiskScoreRule {
//
@TableId(type = IdType.AUTO)
private Integer id;
//
@TableField("pid")
private Integer pid;
// 风险因素
@TableField("risk_name")
private String riskName;
// 分值
@TableField("score")
private String score;
// 规则描述
@TableField("rule_desc")
private String ruleDesc;
// 权重
@TableField("weight")
private Integer weight;
// 状态
@TableField("status")
private Boolean status;
// 更新时间
@TableField("update_time")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm")
private LocalDateTime updateTime;
// 创建时间
@TableField("create_time")
private LocalDateTime createTime;
private Integer sortId;
private Integer level;
}

22
src/main/java/com/biutag/supervision/pojo/model/ModelClassModel.java

@ -0,0 +1,22 @@
package com.biutag.supervision.pojo.model;
import lombok.Getter;
import lombok.Setter;
/**
* @author wxc
* @date 2024/11/13
*/
@Setter
@Getter
public class ModelClassModel {
private Integer id;
private String name;
private Integer sort;
private Integer size;
}

29
src/main/java/com/biutag/supervision/pojo/param/RiskModelTaskClueQueryParam.java

@ -0,0 +1,29 @@
package com.biutag.supervision.pojo.param;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author wxc
* @date 2024/11/14
*/
@Setter
@Getter
public class RiskModelTaskClueQueryParam extends BasePage {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private List<Date> eventTime = new ArrayList<>();
private String name;
private String idCode;
private String thingDesc;
private List<Integer> riskScoreRuleId = new ArrayList<>();
}

4
src/main/java/com/biutag/supervision/pojo/vo/MenuTree.java

@ -46,13 +46,13 @@ public class MenuTree {
// 是否打开新页面 默认为false
private Boolean openNewPage;
@JsonFormat(pattern = "YYYY-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private List<MenuTree> children;
public static List<MenuTree> buildTree(List<Menu> list) {
return buildTree(list, AppConstants.MENU_ROOT_ID);
return buildTree(list, AppConstants.TREE_ROOT_ID);
}
public static List<MenuTree> buildTree(List<Menu> list, Integer pid) {

2
src/main/java/com/biutag/supervision/pojo/vo/ModelTree.java

@ -21,6 +21,8 @@ public class ModelTree {
private String type;
private Integer size;
private List<ModelTree> children = new ArrayList<>();
public static ModelTree of(Model model) {

45
src/main/java/com/biutag/supervision/pojo/vo/RiskScoreRuleTree.java

@ -0,0 +1,45 @@
package com.biutag.supervision.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* @author wxc
* @date 2024/11/14
*/
@Setter
@Getter
public class RiskScoreRuleTree {
private Integer id;
private Integer pid;
// 风险因素
private String riskName;
// 分值
private String score;
// 规则描述
private String ruleDesc;
// 权重
private Integer weight;
// 状态
private Boolean status;
// 更新时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime updateTime;
private Integer sortId;
private List<RiskScoreRuleTree> children = new ArrayList<>();
}

6
src/main/java/com/biutag/supervision/service/BusinessDepartService.java

@ -278,7 +278,9 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
return result;
}
public List<BusinessDepart> list(Date beginTime, Date endTime, String businessType) {
return list(new LambdaQueryWrapper<BusinessDepart>().between(BusinessDepart::getDate, beginTime, endTime).eq(BusinessDepart::getBusinessType, businessType));
public List<BusinessDepart> list(Date beginTime, Date endTime, String departId, String businessType) {
return list(new LambdaQueryWrapper<BusinessDepart>().between(BusinessDepart::getDate, beginTime, endTime)
.eq(BusinessDepart::getDepartId, departId)
.eq(BusinessDepart::getBusinessType, businessType));
}
}

1
src/main/java/com/biutag/supervision/service/ModelClassService.java

@ -8,4 +8,5 @@ import org.springframework.stereotype.Service;
@Service
public class ModelClassService extends ServiceImpl<ModelClassMapper, ModelClass> {
}

121
src/main/java/com/biutag/supervision/service/ModelClueService.java

@ -24,10 +24,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
@ -202,23 +199,18 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
if (!Objects.isNull(model) && model.getModelSql() != null) {
modelClues.addAll(getModelClueBySql(model.getModelSql(), modelId));
}
System.out.println("测试10");
if (!modelClues.isEmpty()) {
List<ModelClue> result = new ArrayList<>();
for (ModelClue modelClue : modelClues) {
modelClue.setModelId(modelId);
modelClue.setCreateTime(LocalDateTime.now());
System.out.println("测试12");
if (modelClue.getInvolveDepartName() != null && !modelClue.getInvolveDepartName().isEmpty()) {
System.out.println("测试13");
result.add(modelClue);
}
}
System.out.println("测试14");
modelClueMapper.insert(result);
modelClueRecordMapper.insert(new ModelClueRecord().setModelId(modelId).setSize(result.size()).setCreateTime(LocalDateTime.now()).setState("success"));
} else {
System.out.println("测试15");
modelClueRecordMapper.insert(new ModelClueRecord().setModelId(modelId).setSize(0).setCreateTime(LocalDateTime.now()).setState("fail").setErrMsg("数据为空"));
}
}
@ -252,7 +244,7 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
List<String> uniqueKeys = modelClues.stream().map(ModelClue::getUniqueKey).filter(k -> k != null && !k.isEmpty()).toList();
List<String> oldUniqueKeys = new ArrayList<>();
// 无需更新状态的模型
if (modelId != 19 && modelId != 27 && modelId != 28 && modelId != 30) {
if (modelId != 19 && modelId != 26 && modelId != 27 && modelId != 28 && modelId != 30 && modelId != 100) {
oldUniqueKeys = this.listObjs(new LambdaQueryWrapper<ModelClue>().select(ModelClue::getUniqueKey).ne(ModelClue::getDistributionState, "2").eq(ModelClue::getModelId, modelId), String::valueOf);
List<String> changeStatusIds = oldUniqueKeys.stream().filter(item -> !uniqueKeys.contains(item)).toList();
if (!changeStatusIds.isEmpty()) {
@ -273,34 +265,27 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
return new ArrayList<>();
}
List<ModelClue> needsInsertModelClues = modelClues.stream().filter(item -> needsInsertIds.contains(item.getUniqueKey())).toList();
System.out.println("needsInsertModelClues:" + needsInsertModelClues.size());
String newSql = generateNewSql(sql, needsInsertIds, modelId);
System.out.println("开始查询新sql" + newSql);
List<Map<String, Object>> allData = modelClueDataMapper.selectByUniqueKeys(newSql);
if (modelId == 26) {
filterDataForModel26(allData);
}
System.out.println("查询新sql完成,结果数量:" + allData.size());
String originalFieldName = getKeyFieldName(sql);
System.out.println("originalFieldName:" + originalFieldName);
for (ModelClue modelClue : needsInsertModelClues) {
for (Map<String, Object> data : allData) {
String keyColumn = (String) data.get(originalFieldName);
System.out.println("测试1:" + keyColumn + "测试" + modelClue.getUniqueKey());
if (Objects.equals(keyColumn, modelClue.getUniqueKey())) {
System.out.println("测试2");
modelClue.setData(JSONObject.toJSONString(data));
modelClue.setDistributionState("0");
System.out.println("测试3");
SupExternalDepart supExternalDepart = supExternalDepartMapper.selectOne(new LambdaQueryWrapper<SupExternalDepart>().eq(SupExternalDepart::getExternalId, modelClue.getInvolveDepartId()).last("LIMIT 1"));
System.out.println("测试4"+modelClue.getInvolveDepartId());
if (supExternalDepart != null && supExternalDepart.getInternalShortName() != null && !supExternalDepart.getInternalShortName().isEmpty()) {
System.out.println("测试5");
modelClue.setInvolveDepartName(supExternalDepart.getInternalShortName());
modelClue.setInvolveDepartId(supExternalDepart.getInternalId());
}
System.out.println("测试6");
setPerson(modelId, modelClue, data);
System.out.println("测试7");
generateThingDesc(modelId, modelClue, data);
System.out.println("测试8");
break;
}
}
@ -308,6 +293,54 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
return needsInsertModelClues;
}
private static void filterDataForModel26(List<Map<String, Object>> allData) {
List<Map<String, Object>> filteredData = allData.stream().filter(map -> map.get("ajbh") != null).toList();
Map<String, List<Map<String, Object>>> groupedData = filteredData.stream().collect(Collectors.groupingBy(map -> (String) map.get("ajbh")));
allData.clear();
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) {
String ajbh = entry.getKey();
List<Map<String, Object>> records = entry.getValue();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String earliestJRSJ = null;
LocalDateTime earliestDateTime = LocalDateTime.MIN;
for (Map<String, Object> record : records) {
String jrsj = (String) record.get("jrsj");
LocalDateTime dateTime = LocalDateTime.parse(jrsj, formatter);
if (earliestJRSJ == null || !dateTime.isAfter(earliestDateTime)) {
earliestJRSJ = jrsj;
earliestDateTime = dateTime;
}
}
String latestLKSJ = null;
LocalDateTime latestDateTime = LocalDateTime.MIN;
for (Map<String, Object> record : records) {
String lksj = (String) record.get("lksj");
LocalDateTime dateTime = LocalDateTime.parse(lksj, formatter);
if (latestLKSJ == null || dateTime.isAfter(latestDateTime)) {
latestLKSJ = lksj;
latestDateTime = dateTime;
}
}
if (earliestJRSJ != null && latestLKSJ != null) {
Duration duration = Duration.between(earliestDateTime, latestDateTime);
if (duration.toHours() >= 3) {
continue;
}
Map<String, Object> newRecord = new HashMap<>();
newRecord.put("ajbh", ajbh);
newRecord.put("jrsj", earliestJRSJ);
newRecord.put("lksj", latestLKSJ);
for (String key : records.get(0).keySet()) {
if (!key.equals("jrsj") && !key.equals("lksj")) {
newRecord.put(key, records.get(0).get(key));
}
}
allData.add(newRecord);
}
}
System.out.println("模型26筛选后的alldata数量:" + allData.size());
}
private void setPerson(Integer modelId, ModelClue modelClue, Map<String, Object> data) {
// 执法区域人员表
if (modelId == 3) {
@ -486,23 +519,22 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
+ ",未录入反馈人员身份证信息。");
} else if (modelId == 26) { // 26号模型:执法办案场所进出时间过短
if (data.get("lksj") != null && !data.get("lksj").equals("")) {
modelClue.setThingDesc("发现执法场所人员“" + data.get("xm")
+ "”(身份证号" + data.get("zjhm")
+ "),于" + getDateMinuteString(data.get("jrsj"))
+ "进入" + modelClue.getInvolveDepartName()
+ "执法办案区,于" + getDateMinuteString(data.get("lksj"))
+ "离开,停留时长" + calculateMinutesBetween(data.get("djsj"), data.get("lksj"))
+ ",存在间隔时间过短的异常。");
modelClue.setThingDesc("发现" + modelClue.getInvolveDepartName() + "办理的被处以刑事打处的嫌疑人员“"
+ data.get("xm") + "”(身份证号:" + data.get("zjhm")
+ "),其于" + getDateMinuteString(data.get("jrsj"))
+ "登记进入" + modelClue.getInvolveDepartName()
+ "执法办案区,但仅停留" + calculateMinutesBetween(data.get("jrsj"), data.get("lksj"))
+ "后便予以离开,少于3小时,与正常开展流程办理刑事案件所需时长相违背,存在疑似不如实登记执法办案场所的异常问题。");
}
} else if (modelId == 27) { // 27号模型:盗窃车内财物警情结警性质变动的异常数据
modelClue.setThingDesc("发现" + modelClue.getInvolveDepartName() + "受理的接警单"
+ modelClue.getUniqueKey() + ",报警日期为" + getDateMinuteString(data.get("bjsj"))
+ ",接警性质为“" + data.get("ysjqxzmc") + "”,结警性质为“" + data.get("jqxzmc")
+ ",存在盗窃车内财物警情结警性质变动的异常情况。");
} else if (modelId == 28) { // 28号模型:盗窃车内财物超过5000元的数据
} else if (modelId == 28) { // 28号模型:盗窃车内财物超过2000元的数据
modelClue.setThingDesc("发现" + modelClue.getInvolveDepartName() + "受理的接警单"
+ modelClue.getUniqueKey() + ",报警日期为" + getDateMinuteString(data.get("bjsj"))
+ ",接警性质为“" + data.get("ysjqxzmc") + "”,金额超过5000元。报警内容为:“" + data.get("bjnr")
+ ",接警性质为“" + data.get("ysjqxzmc") + "”,金额超过2000元。报警内容为:“" + data.get("bjnr")
+ "”。");
} else if (modelId == 29) { // 29号模型:案件降格处理的异常数据
modelClue.setThingDesc("发现" + modelClue.getInvolveDepartName() + "受理的接警单"
@ -518,6 +550,14 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
"发现" + modelClue.getInvolveDepartName() + "受理的“" + data.get("AJMC")
+ "”(【" + data.get("AJBZmc") + "】编号:" + getAjbh(data)
+ "),未扣押任何财物,存在疑似涉案财物未按要求录入的问题。");
} else if (modelId == 100) { // 100号模型:散油实时预警
modelClue.setInvolvePoliceName((String) data.get("gmrxm"));
modelClue.setThingDesc(
"发现" + data.get("gmrxm") + "(身份证号:" + data.get("zjhm") + ")于"
+ getDateMinuteString(data.get("gmsj")) + "在"
+ data.get("fjmc") + modelClue.getInvolveDepartName() + "管辖的" + data.get("dwmc")
+ "购买了" + data.get("gmsl") + "升" + data.get("gmyt")
+ ",产生了" + data.get("yjlx") + ",请予以重点关注。");
}
}
@ -894,9 +934,13 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
}
newModelClue.setData(JSONObject.toJSONString(map));
newModelClue.setDistributionState("0");
Long count = (Long) map.get("num");
BigDecimal result = BigDecimal.valueOf(count).divide(BigDecimal.valueOf(250), 3, RoundingMode.HALF_UP);
newModelClue.setThingDesc(
"灵敏感知系统发现" + newModelClue.getInvolveDepartName() + "民警" + xzdzrr
+ "的管控人数为" + map.get("num") + "人。");
"发现" + newModelClue.getInvolveDepartName() + "民警" + xzdzrr
+ ",其在重点人员管控系统中的管控人数为" + count
+ "人,即使每个重点人员只见一次,其工作日(采取每年250天)必须每日完成管控"
+ result +"个。");
modelClues.add(newModelClue);
}
}
@ -950,9 +994,7 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
List<String> uniqueKeys = modelClues1.stream().map(ModelClue::getUniqueKey).filter(k -> k != null && !k.isEmpty()).toList();
if (!uniqueKeys.isEmpty()) {
String newSql = "SELECT a.* FROM dwd_asj_zhtx_jjd a LEFT JOIN dwd_asj_sjjhygx_jjcjxxb b ON b.BARLXDH = a.bjdh WHERE a.jjdbh IN " + "(" + uniqueKeys.stream().map(k -> "'" + k + "'").collect(Collectors.joining(",")) + ");";
System.out.println("测试2开始查询数据库 newSql");
List<Map<String, Object>> allData = modelClueDataMapper.selectByUniqueKeys(newSql);
System.out.println("测试2查询数据库newSql记录条数:" + allData.size());
for (ModelClue modelClue : modelClues1) {
for (Map<String, Object> data : allData) {
String keyColumn = (String) data.get("jjdbh");
@ -1070,7 +1112,18 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分");
return formatter.format(localDateTime);
} catch (Exception exx) {
log.info("日期转换异常{}", time, ex);
try {
time = String.valueOf(param);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date parse = sdf.parse(time);
Instant instant = parse.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分");
return formatter.format(localDateTime);
} catch (Exception exxx) {
log.info("日期转换异常{}", time, ex);
}
}
}
}

5
src/main/java/com/biutag/supervision/service/ModelService.java

@ -1,5 +1,6 @@
package com.biutag.supervision.service;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.common.UserContextHolder;
@ -24,7 +25,7 @@ public class ModelService extends ServiceImpl<ModelMapper, Model> {
}
public boolean saveModel(Model model) {
if (DistributionMethodEnum.NEGATIVE_DISTRIBUTE.getValue().equals(model.getDistributionMethod())) {
if (StrUtil.isNotBlank(model.getDistributionCycle()) && DistributionMethodEnum.NEGATIVE_DISTRIBUTE.getValue().equals(model.getDistributionMethod())) {
String expression = DistributionCycleEnum.day.name().equals(model.getDistributionCycle()) ? ExpressionBuilder.build(model.getDistributionCycleTime()) :
ExpressionBuilder.build(model.getDistributionCycleTime(), model.getDistributionCycleDayOfWeek());
model.setDistributionCycleExpression(expression);
@ -39,7 +40,7 @@ public class ModelService extends ServiceImpl<ModelMapper, Model> {
}
public boolean updateModel(Model model) {
if (DistributionMethodEnum.NEGATIVE_DISTRIBUTE.getValue().equals(model.getDistributionMethod())) {
if (StrUtil.isNotBlank(model.getDistributionCycle()) && DistributionMethodEnum.NEGATIVE_DISTRIBUTE.getValue().equals(model.getDistributionMethod())) {
String expression = DistributionCycleEnum.day.name().equals(model.getDistributionCycle()) ? ExpressionBuilder.build(model.getDistributionCycleTime()) :
ExpressionBuilder.build(model.getDistributionCycleTime(), model.getDistributionCycleDayOfWeek());
model.setDistributionCycleExpression(expression);

205
src/main/java/com/biutag/supervision/service/NegativeScoreService.java

@ -11,7 +11,6 @@ import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.util.ScoreRule;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@ -116,90 +115,77 @@ public class NegativeScoreService {
System.out.println("calculateScore-------------------------------------------------End");
}
private final BusinessPoliceService businessPoliceService;
private final BusinessDepartService businessDepartService;
private final SupPoliceService policeService;
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
public double calculateBusinessWeight(Double totalScore, Double score) {
public double calculateBusinessWeight(Double score, Double totalScore) {
if (totalScore == 0) {
return 0.0;
}
log.info("业务权重 = {} / {}", score, totalScore);
return NumberUtil.div(score, totalScore);
}
// 平均问题数 = 单个业务问题数 / 业务涉及人数
public double calculateAvgNumber(int size, int policeSize) {
if (policeSize == 0) {
// 平均问题发生率 = 单个业务问题加权数 / 单位总业务量
public double calculateAvgNumber(double businessWeightScore, int totalBusinessSize) {
if (totalBusinessSize == 0) {
log.info("平均问题发生率 = 0");
return 0;
}
return NumberUtil.div(size, policeSize);
log.info("平均问题发生率 = {} / {}", businessWeightScore, totalBusinessSize);
return NumberUtil.div(businessWeightScore, totalBusinessSize);
}
// 业务标准差 = 根号(sum((个人问题数 - 平均问题数)²) / 业务涉及人数)
public double calculateSd(double[] diffNumber, int policeSize) {
public double calculateSd1(double[] diffNumber, int policeSize) {
if (policeSize == 0) {
log.info("业务标准差 = 0");
return 0;
}
log.info("业务标准差 = 根号({}) / {}", Arrays.stream(diffNumber).mapToObj(val -> String.format("(%s)²", val)).collect(Collectors.joining(" + ")), policeSize);
return Math.sqrt(Arrays.stream(diffNumber).map(val -> Math.pow(val, 2)).sum() / policeSize);
}
// 业务差异值1 = (个人问题发生率 - 平均问题发生率) / 业务标准差
// 平均问题发生率 = 总问题数 / 总业务量
// 个人问题发生率 = 个人问题数 / 个人业务量
public double calculateDiff1(List<NegativeScorePolice> businessScorePolice, SupPolice police, Date beginTime, Date endTime, String businessTypeCode, double sd) {
if (sd == 0) {
// 业务标准差 = 根号(sum((个人问题数 - 平均问题数)²) / 业务涉及人数)
public double calculateSd2(double[] diffNumber, int policeSize) {
if (policeSize == 0) {
log.info("业务标准差 = 0");
return 0;
}
List<BusinessDepart> businessDeparts = businessDepartService.list(beginTime, endTime, businessTypeCode);
// 总业务量
int totalBusinessSize = businessDeparts.stream().mapToInt(BusinessDepart::getNumber).sum();
// 平均问题发生率
double avgRate = totalBusinessSize == 0? 0: NumberUtil.div(businessScorePolice.size(), totalBusinessSize);
// 个人问题数
long personSize = businessScorePolice.stream().filter(item -> police.getOrgId().equals(item.getIdCode())).count();
// 单位业务量
long departBusinessSize = businessDeparts.stream().filter(item -> police.getOrgId().equals(item.getDepartId())).count();
// 个人问题发生率
double personRate = departBusinessSize == 0? 0: NumberUtil.div(personSize, departBusinessSize);
return NumberUtil.div(personRate - avgRate, sd);
log.info("业务标准差 = 根号({}) / {}", Arrays.stream(diffNumber).mapToObj(val -> String.format("(%s)²", val)).collect(Collectors.joining(" + ")), policeSize);
return Math.sqrt(Arrays.stream(diffNumber).map(val -> Math.pow(val, 2)).sum() / policeSize);
}
public double calculateDiff1ByDepart(List<NegativeScoreDepart> businessScoreDeparts, String departId, Date beginTime, Date endTime, String businessTypeCode, double sd) {
// 业务差异值1 = (个人问题发生率 - 平均问题发生率) / 业务标准差
// 平均问题发生率 = 总问题数 / 总业务量
// 个人问题发生率 = 个人问题数 / 个人业务量
public double calculateDiff1(double personalRate, double avgNumber, double sd) {
if (sd == 0) {
log.info("业务差异值(发生率) = 0");
return 0;
}
List<BusinessDepart> businessDeparts = businessDepartService.list(beginTime, endTime, businessTypeCode);
// 总业务量
int totalBusinessSize = businessDeparts.stream().mapToInt(BusinessDepart::getNumber).sum();
// 平均问题发生率
double avgRate = totalBusinessSize == 0? 0: NumberUtil.div(businessScoreDeparts.size(), totalBusinessSize);
// 个人问题数
long personSize = businessScoreDeparts.stream().filter(item -> departId.equals(item.getDepartId())).count();
// 个人业务量
long personBusinessSize = businessDeparts.stream().filter(item -> departId.equals(item.getDepartId())).count();
// 个人问题发生率
double personRate = personBusinessSize == 0? 0: NumberUtil.div(personSize, personBusinessSize);
return NumberUtil.div(personRate - avgRate, sd);
log.info("业务差异值(发生率) = ({} - {}) / {}", personalRate, avgNumber, sd);
return NumberUtil.div(personalRate - avgNumber, sd);
}
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
public double calculateDiff2(long personalSize, double avgNumber, double sd) {
// 业务差异值2 = (加权问题数 - 平均问题数) / 业务标准差
public double calculateDiff2(double personalScore, double avgNumber, double sd) {
if (sd == 0) {
return 0;
}
return NumberUtil.div(personalSize - avgNumber, sd);
log.info("业务差异值(数量) = ({} - {}) / {}", personalScore, avgNumber, sd);
return NumberUtil.div(personalScore - avgNumber, sd);
}
public double calculateBusinessScore(double diff, long personalSize) {
public double calculateBusinessScore(double diff, double personalSize) {
if (personalSize == 0) {
return 0;
}
return 50 + (diff * 15);
log.info("单个业务风险指数 = 50 + ({} * 5)", diff);
return 50 + (diff * 5);
}
private final SupDepartService departService;
@ -227,49 +213,85 @@ public class NegativeScoreService {
Double totalScore = scorePolices.stream().mapToDouble(NegativeScorePolice::getScore).sum();
List<String> expressionArr = new ArrayList<>();
StringBuilder remarks = new StringBuilder();
List<Double> scores = new ArrayList<>();
List<Double> weights = new ArrayList<>();
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> {
log.info("业务 【{}】 开始-------------------------------------------------------------------", businessTypeEnum.getLabel());
List<NegativeScorePolice> businessScorePolice = scorePolices.stream().filter(item -> item.getBusinessTypeCode().equals(businessTypeEnum.getValue())).toList();
// 业务加权问题总数
double businessWeightScore = businessScorePolice.stream().mapToDouble(NegativeScorePolice::getScore).sum();
log.info("业务加权问题数 = {}", businessWeightScore);
// 业务涉及人数
int policeSize = businessScorePolice.stream().map(NegativeScorePolice::getIdCode).collect(Collectors.toSet()).size();
remarks.append(String.format("业务设计人数 %s", policeSize));
// 业务问题数
int businessSize = businessScorePolice.size();
//---------------------------------------------------------
// 平均问题数
double avgNumber = calculateAvgNumber(businessSize, policeSize);
// 差值集合 = 个人问题数 - 平均问题数
Map<String, List<NegativeScorePolice>> group = businessScorePolice.stream().collect(Collectors.groupingBy(NegativeScorePolice::getIdCode));
double[] diffNumbers = group.values().stream().mapToDouble(val -> val.size() - avgNumber).toArray();
// 业务标准差
double sd = calculateSd(diffNumbers, policeSize);
log.info("业务标准差为:{}", sd);
log.info("业务涉及人数 = {}", policeSize);
// 业务加权问题数(风险指数)
double personalScore = businessScorePolice.stream().filter(item -> idCode.equals(item.getIdCode())).mapToDouble(NegativeScorePolice::getScore).sum();
log.info("个人业务加权问题数 = {}", personalScore);
// 业务差异值
double diff;
long personalSize = businessScorePolice.stream().filter(item -> idCode.equals(item.getIdCode())).count();
if (businessTypeEnum.getBusinessVolume()) {
diff = calculateDiff1(businessScorePolice, police, beginTime, endTime, businessTypeEnum.getValue(), sd);
if (false) {
String departId = depart.getId();
// 如果是4级单位 则找他上级单位
if (depart.getLevel() == 4) {
departId = departService.getById(depart.getPid()).getId();
}
List<BusinessDepart> businessDeparts = businessDepartService.list(beginTime, endTime, departId, businessTypeEnum.getValue());
// 单位总业务量
int totalBusinessSize = businessDeparts.stream().mapToInt(BusinessDepart::getNumber).sum();
log.info("单位总业务量 = {}", totalBusinessSize);
// 平均加权问题发生率
double avgNumber = calculateAvgNumber(businessWeightScore, totalBusinessSize);
log.info("平均加权问题发生率 = {}", avgNumber);
Map<String, List<NegativeScorePolice>> group = businessScorePolice.stream().collect(Collectors.groupingBy(NegativeScorePolice::getIdCode));
double[] diffNumbers = group.values().stream().mapToDouble(val -> {
if (totalBusinessSize == 0) {
return -avgNumber;
}
return (val.stream().mapToDouble(NegativeScorePolice::getScore).sum() / totalBusinessSize) - avgNumber;
}).toArray();
// 业务标准差
double sd = calculateSd1(diffNumbers, policeSize);
double rate = personalScore / totalBusinessSize;
log.info("个人问题发生率 = {} / {}", personalScore, totalBusinessSize);
log.info("个人问题发生率 = {}", rate);
diff = calculateDiff1(personalScore / totalBusinessSize, avgNumber, sd);
} else {
diff = calculateDiff2(personalSize, avgNumber, sd);
remarks.append(String.format("业务涉及人数 %s", policeSize));
// 业务平均加权问题数
double avgNumber = calculateAvgNumber(businessWeightScore, policeSize);
// 差值集合 = 个人问题数 - 平均问题数
Map<String, List<NegativeScorePolice>> group = businessScorePolice.stream().collect(Collectors.groupingBy(NegativeScorePolice::getIdCode));
double[] diffNumbers = group.values().stream().mapToDouble(val -> val.stream().mapToDouble(NegativeScorePolice::getScore).sum() - avgNumber).toArray();
// 业务标准差
double sd = calculateSd2(diffNumbers, policeSize);
log.info("业务标准差为 = {}", sd);
diff = calculateDiff2(personalScore, avgNumber, sd);
}
log.info("业务差异值为:{}", diff);
log.info("业务差异值为 = {}", diff);
// 业务风险指数
double businessScore = calculateBusinessScore(diff, personalSize);
log.info("业务风险指数:{}", businessScore);
double businessScore = calculateBusinessScore(diff, personalScore);
// 业务权重
Double score = businessScorePolice.stream().mapToDouble(NegativeScorePolice::getScore).sum();
double businessWeight = calculateBusinessWeight(totalScore, score);
double businessWeight = calculateBusinessWeight(score, totalScore);
expressionArr.add(String.format("(%s * %s)", businessScore, businessWeight));
remarks.append(String.format("%s:", businessTypeEnum.getLabel())).append("\n");
remarks.append(String.format("业务涉及人数 %s", policeSize)).append("\n");
remarks.append(String.format("业务问题数 %s", businessSize)).append("\n");
remarks.append(String.format("平均问题数 %s", avgNumber)).append("\n");
remarks.append(String.format("业务标准差 %s", sd)).append("\n");
remarks.append(String.format("业务问题数 %s", businessWeightScore)).append("\n");
remarks.append(String.format("业务差异值 %s", diff)).append("\n");
log.info("业务风险指数 = {}", businessScore);
log.info("业务权重 = {}", businessWeight);
log.info("单个业务风险指数 = {} * {}", businessScore, businessWeight);
log.info("单个业务结束-------------------------------------------------------------------", businessTypeEnum.getLabel());
scores.add(NumberUtil.round(businessScore, 2).doubleValue());
weights.add(NumberUtil.round(businessWeight * 100, 2).doubleValue());
return NumberUtil.mul(businessScore, businessWeight);
}).sum();
BigDecimal score = NumberUtil.roundHalfEven(policeScore, 2);
String expression = String.join(" + ", expressionArr);
return List.of(score, expression, remarks);
return List.of(score, expression, remarks, scores, weights);
}
/**
@ -288,35 +310,46 @@ public class NegativeScoreService {
StringBuilder remarks = new StringBuilder();
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> {
List<NegativeScoreDepart> businessScoreDeparts = scoreDeparts.stream().filter(item -> item.getBusinessTypeCode().equals(businessTypeEnum.getValue())).toList();
// 业务加权问题数
double businessWeightScore = businessScoreDeparts.stream().mapToDouble(NegativeScoreDepart::getScore).sum();
// 业务涉及人数
int departSize = businessScoreDeparts.stream().map(NegativeScoreDepart::getDepartId).collect(Collectors.toSet()).size();
// 当前部门问题数
long personalSize = businessScoreDeparts.stream().filter(item -> departId.equals(item.getDepartId())).count();
// 平均问题数
double avgNumber = calculateAvgNumber(businessScoreDeparts.size(), departSize);
// 差值集合 = 个人问题数 - 平均问题数
Map<String, List<NegativeScoreDepart>> group = businessScoreDeparts.stream().collect(Collectors.groupingBy(NegativeScoreDepart::getDepartId));
double[] diffNumbers = group.values().stream().mapToDouble(val -> val.size() - avgNumber).toArray();
// 业务标准差
double sd = calculateSd(diffNumbers, departSize);
// 业务加权问题数(风险指数)
double personalScore = businessScoreDeparts.stream().filter(item -> departId.equals(item.getDepartId())).mapToDouble(NegativeScoreDepart::getScore).sum();
// 业务差异值
double diff;
if (businessTypeEnum.getBusinessVolume()) {
diff = calculateDiff1ByDepart(businessScoreDeparts, departId, beginTime, endTime, businessTypeEnum.getValue(), sd);
if (false) {
List<BusinessDepart> businessDeparts = businessDepartService.list(beginTime, endTime, departId, businessTypeEnum.getValue());
// 总业务量
int totalBusinessSize = businessDeparts.stream().mapToInt(BusinessDepart::getNumber).sum();
// 平均加权问题发生率
double avgNumber = calculateAvgNumber(businessWeightScore, totalBusinessSize);
Map<String, List<NegativeScoreDepart>> group = businessScoreDeparts.stream().collect(Collectors.groupingBy(NegativeScoreDepart::getDepartId));
double[] diffNumbers = group.values().stream().mapToDouble(val -> val.stream().mapToDouble(NegativeScoreDepart::getScore).sum() - avgNumber).toArray();
// 业务标准差
double sd = calculateSd1(diffNumbers, departSize);
log.info("");
diff = calculateDiff1(personalScore, avgNumber, sd);
} else {
// 当前部门问题数
long personalSize = businessScoreDeparts.stream().filter(item -> departId.equals(item.getDepartId())).count();
// 平均问题数
double avgNumber = calculateAvgNumber(businessScoreDeparts.size(), departSize);
// 差值集合 = 个人问题数 - 平均问题数
Map<String, List<NegativeScoreDepart>> group = businessScoreDeparts.stream().collect(Collectors.groupingBy(NegativeScoreDepart::getDepartId));
double[] diffNumbers = group.values().stream().mapToDouble(val -> val.size() - avgNumber).toArray();
// 业务标准差
double sd = calculateSd2(diffNumbers, departSize);
diff = calculateDiff2(personalSize, avgNumber, sd);
}
// 业务风险指数
double businessScore = calculateBusinessScore(diff, personalSize);
double businessScore = calculateBusinessScore(diff, personalScore);
// 业务权重
Double score = businessScoreDeparts.stream().mapToDouble(NegativeScoreDepart::getScore).sum();
double businessWeight = calculateBusinessWeight(totalScore, score);
double businessWeight = calculateBusinessWeight(score, totalScore);
expressionArr.add(String.format("(%s * %s)", businessScore, businessWeight));
remarks.append(String.format("%s:", businessTypeEnum.getLabel())).append("\n");
remarks.append(String.format("业务涉及人数 %s", departSize)).append("\n");
remarks.append(String.format("当前部门问题数 %s", personalSize)).append("\n");
remarks.append(String.format("平均问题数 %s", avgNumber)).append("\n");
remarks.append(String.format("业务标准差 %s", sd)).append("\n");
remarks.append(String.format("业务差异值 %s", diff)).append("\n");
return NumberUtil.mul(businessScore, businessWeight);
}).sum();

11
src/main/java/com/biutag/supervision/service/RiskModelTaskClueService.java

@ -0,0 +1,11 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.RiskModelTaskClue;
import com.biutag.supervision.mapper.RiskModelTaskClueMapper;
import org.springframework.stereotype.Service;
@Service
public class RiskModelTaskClueService extends ServiceImpl<RiskModelTaskClueMapper, RiskModelTaskClue> {
}

50
src/main/java/com/biutag/supervision/service/RiskScoreRuleService.java

@ -0,0 +1,50 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.constants.AppConstants;
import com.biutag.supervision.mapper.RiskScoreRuleMapper;
import com.biutag.supervision.pojo.entity.RiskScoreRule;
import com.biutag.supervision.pojo.vo.RiskScoreRuleTree;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class RiskScoreRuleService extends ServiceImpl<RiskScoreRuleMapper, RiskScoreRule> {
public List<RiskScoreRuleTree> buildTree() {
List<RiskScoreRule> scoreRules = list(new LambdaQueryWrapper<RiskScoreRule>().orderByAsc(RiskScoreRule::getSortId));
Map<Integer, List<RiskScoreRuleTree>> childMap = new HashMap<>();
List<RiskScoreRuleTree> tree = new ArrayList<>();
for (RiskScoreRule rule: scoreRules) {
RiskScoreRuleTree node = new RiskScoreRuleTree();
BeanUtils.copyProperties(rule, node);
List<RiskScoreRuleTree> children = childMap.computeIfAbsent(node.getPid(), k -> new ArrayList<>());
children.add(node);
Integer pid = node.getPid();
if (AppConstants.TREE_ROOT_ID.equals(pid)) {
tree.add(node);
}
}
for (RiskScoreRuleTree node : tree) {
buildTreeRecursive(node, childMap);
}
return tree;
}
private static RiskScoreRuleTree buildTreeRecursive(RiskScoreRuleTree node, Map<Integer, List<RiskScoreRuleTree>> childMap) {
List<RiskScoreRuleTree> children = childMap.get(node.getId());
if (children != null) {
node.getChildren().addAll(children.stream()
.map(childNode -> buildTreeRecursive(childNode, childMap))
.toList());
}
return node;
}
}

2
src/main/java/com/biutag/supervision/support/ModelClueDistributionAware.java

@ -51,7 +51,7 @@ public class ModelClueDistributionAware {
log.info("新增模型【{}】分发任务", model.getModelName());
String expression = model.getDistributionCycleExpression();
if (StrUtil.isBlank(expression)) {
throw new RuntimeException("分发周期配置[expression]为空");
return;
}
if (taskMap.containsKey(model.getId())) {
remove(model.getId());

6
src/main/resources/application-local.yml

@ -19,9 +19,9 @@ spring:
port: 6379
password: 123456
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#mybatis-plus:
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
fdfs:
tracker-list: #TrackerList参数,支持多个

2
src/main/resources/mapper/ProfilePoliceMapper.xml

@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="departGroupId != null and departGroupId != ''">
AND d.statistics_group_id = #{departGroupId}
</if>
AND pc.score > 0
<if test="name != null and name != ''">
AND p.name like concat('%', #{name}, '%')
</if>

BIN
src/main/resources/static/templates/【工作机制】个人极端暴力风险数字督察灵敏感知体系风险赋分及预警处置机制.doc

Binary file not shown.

41
src/test/java/com/biutag/supervision/tools/ExcelTest.java

@ -0,0 +1,41 @@
package com.biutag.supervision.tools;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.biutag.supervision.pojo.dto.DataCaseVerifImportDto;
import com.biutag.supervision.pojo.entity.SupDepart;
import jakarta.validation.ConstraintViolation;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author wxc
* @date 2024/11/13
*/
public class ExcelTest {
public void test() throws FileNotFoundException {
File file = new File("");
ExcelReader excelReader = EasyExcel.read(new FileInputStream(file), HdtExcelDto.class, new ReadListener<DataCaseVerifImportDto>() {
@Override
public void invoke(DataCaseVerifImportDto data, AnalysisContext analysisContext) {
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
}).build();
}
}

2
src/test/java/com/biutag/supervision/tools/GenCodeTests.java

@ -25,7 +25,7 @@ public class GenCodeTests {
@Test
public void genEntity() throws TemplateException, IOException {
String tableName = "depart_score";
String tableName = "risk_model_task_clue";
String tableSchema = "negative";
boolean genMapper = true;
boolean genService = true;

26
src/test/java/com/biutag/supervision/tools/HdtExcelDto.java

@ -0,0 +1,26 @@
package com.biutag.supervision.tools;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* @author wxc
* @date 2024/11/13
*/
@Setter
@Getter
public class HdtExcelDto {
@ExcelProperty("姓名")
private String departId;
@ExcelProperty("部门")
private String departName;
@ExcelProperty("姓名")
private LocalDateTime discoveryTime;
}
Loading…
Cancel
Save