Browse Source

fit: 个人风险指数赋分

main
wxc 1 year ago
parent
commit
9c49e569c9
  1. 14
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfileDepartController.java
  2. 13
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java
  3. 39
      src/main/java/com/biutag/supervision/controller/sensitivePerception/RiskPersonalController.java
  4. 16
      src/main/java/com/biutag/supervision/controller/work/NegativeController.java
  5. 65
      src/main/java/com/biutag/supervision/job/ScoreJob.java
  6. 8
      src/main/java/com/biutag/supervision/mapper/NegativeScoreDepartMapper.java
  7. 8
      src/main/java/com/biutag/supervision/mapper/RiskPersonalMapper.java
  8. 5
      src/main/java/com/biutag/supervision/pojo/domain/ProfileDepart.java
  9. 40
      src/main/java/com/biutag/supervision/pojo/entity/NegativeScoreDepart.java
  10. 1
      src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java
  11. 71
      src/main/java/com/biutag/supervision/pojo/entity/RiskPersonal.java
  12. 2
      src/main/java/com/biutag/supervision/pojo/entity/SupPolice.java
  13. 4
      src/main/java/com/biutag/supervision/pojo/model/DepartNegativeModel.java
  14. 3
      src/main/java/com/biutag/supervision/pojo/model/PoliceNegativeModel.java
  15. 27
      src/main/java/com/biutag/supervision/pojo/param/RiskPersonalQueryParam.java
  16. 7
      src/main/java/com/biutag/supervision/pojo/vo/NegativeQueryVo.java
  17. 10
      src/main/java/com/biutag/supervision/service/BusinessDepartService.java
  18. 20
      src/main/java/com/biutag/supervision/service/NegativeScoreDepartService.java
  19. 290
      src/main/java/com/biutag/supervision/service/NegativeScoreService.java
  20. 138
      src/main/java/com/biutag/supervision/service/ProfilePoliceService.java
  21. 11
      src/main/java/com/biutag/supervision/service/RiskPersonalService.java
  22. 33
      src/main/java/com/biutag/supervision/service/ScoreService.java
  23. 2
      src/main/java/com/biutag/supervision/service/SupPoliceService.java
  24. 10
      src/main/resources/mapper/ProfilePoliceMapper.xml
  25. 2
      src/test/java/com/biutag/supervision/tools/GenCodeTests.java

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

@ -15,15 +15,18 @@ import com.biutag.supervision.pojo.dto.common.BarItem;
import com.biutag.supervision.pojo.dto.common.PieItem; import com.biutag.supervision.pojo.dto.common.PieItem;
import com.biutag.supervision.pojo.entity.*; import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.pojo.model.DepartNegativeModel; import com.biutag.supervision.pojo.model.DepartNegativeModel;
import com.biutag.supervision.pojo.model.PoliceNegativeModel;
import com.biutag.supervision.pojo.param.DepartNegativeQueryParam; import com.biutag.supervision.pojo.param.DepartNegativeQueryParam;
import com.biutag.supervision.service.*; import com.biutag.supervision.service.*;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@ -34,6 +37,7 @@ import java.util.stream.Collectors;
* @author wxc * @author wxc
* @date 2024/10/31 * @date 2024/10/31
*/ */
@Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("profile/depart") @RequestMapping("profile/depart")
@RestController @RestController
@ -44,6 +48,7 @@ public class ProfileDepartController {
private final SupPoliceService policeService; private final SupPoliceService policeService;
private final NegativeService negativeService; private final NegativeService negativeService;
private final BusinessDepartService businessDepartService; private final BusinessDepartService businessDepartService;
private final NegativeScoreService negativeScoreService;
@GetMapping @GetMapping
public Result<Page<DepartNegativeModel>> list(DepartNegativeQueryParam param) { public Result<Page<DepartNegativeModel>> list(DepartNegativeQueryParam param) {
@ -54,6 +59,12 @@ public class ProfileDepartController {
endTime = param.getCrtTime().get(1); endTime = param.getCrtTime().get(1);
} }
Page<DepartNegativeModel> page = profileDepartMapper.queryDepartNegative(Page.of(param.getCurrent(), param.getSize()), beginTime, endTime, param.getDepartName(), param.getDepartId()); Page<DepartNegativeModel> page = profileDepartMapper.queryDepartNegative(Page.of(param.getCurrent(), param.getSize()), beginTime, endTime, param.getDepartName(), param.getDepartId());
long l = System.currentTimeMillis();
for (DepartNegativeModel item : page.getRecords()) {
List<Object> result = negativeScoreService.calculateDepartScore(beginTime, endTime, item.getDepartId());
item.setScore((BigDecimal) result.get(0));
}
log.info("风险指数计算耗时:{}s", (System.currentTimeMillis() - l) / 1000);
return Result.success(page); return Result.success(page);
} }
@ -147,6 +158,9 @@ public class ProfileDepartController {
profileDepart.setProblemTypeRadarData(problemTypeRadarData); profileDepart.setProblemTypeRadarData(problemTypeRadarData);
// 突出问题排名 // 突出问题排名
profileDepart.setProblemTypeBarList(profileDepartMapper.selectThirdProblemType(departId, beginTime, endTime)); profileDepart.setProblemTypeBarList(profileDepartMapper.selectThirdProblemType(departId, beginTime, endTime));
List<Object> result = negativeScoreService.calculateDepartScore(beginTime, endTime, departId);
profileDepart.setScore((BigDecimal) result.get(0));
profileDepart.setExpression(result.get(1).toString());
return Result.success(profileDepart); return Result.success(profileDepart);
} }

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

@ -20,6 +20,7 @@ import com.biutag.supervision.pojo.model.PoliceNegativeModel;
import com.biutag.supervision.pojo.param.DepartPoliceQueryParam; import com.biutag.supervision.pojo.param.DepartPoliceQueryParam;
import com.biutag.supervision.service.*; import com.biutag.supervision.service.*;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -37,12 +38,13 @@ import java.util.stream.Collectors;
* @author wxc * @author wxc
* @date 2024/10/31 * @date 2024/10/31
*/ */
@Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("profile/police") @RequestMapping("profile/police")
@RestController @RestController
public class ProfilePoliceController { public class ProfilePoliceController {
private final ProfilePoliceService profilePoliceService; private final ScoreService profilePoliceService;
private final ProfilePoliceMapper profilePoliceMapper; private final ProfilePoliceMapper profilePoliceMapper;
private final SupPoliceService policeService; private final SupPoliceService policeService;
@ -50,6 +52,7 @@ public class ProfilePoliceController {
private final NegativeBlameService negativeBlameService; private final NegativeBlameService negativeBlameService;
private final NegativeService negativeService; private final NegativeService negativeService;
private final NegativeScoreService negativeScoreService;
@GetMapping @GetMapping
public Result<Page<PoliceNegativeModel>> list(DepartPoliceQueryParam param) { public Result<Page<PoliceNegativeModel>> list(DepartPoliceQueryParam param) {
@ -60,6 +63,12 @@ public class ProfilePoliceController {
endTime = param.getCrtTime().get(1); endTime = param.getCrtTime().get(1);
} }
Page<PoliceNegativeModel> page = profilePoliceMapper.queryPoliceNegative(Page.of(param.getCurrent(), param.getSize()), beginTime, endTime, param.getName(),param.getEmpNo(), param.getDepartId()); Page<PoliceNegativeModel> page = profilePoliceMapper.queryPoliceNegative(Page.of(param.getCurrent(), param.getSize()), beginTime, endTime, param.getName(),param.getEmpNo(), param.getDepartId());
long l = System.currentTimeMillis();
for (PoliceNegativeModel item : page.getRecords()) {
List<Object> result = negativeScoreService.calculatePoliceScore(beginTime, endTime, item.getIdCode());
item.setScore((BigDecimal) result.get(0));
}
log.info("风险指数计算耗时:{}s", (System.currentTimeMillis() - l) / 1000);
return Result.success(page); return Result.success(page);
} }
@ -142,7 +151,7 @@ public class ProfilePoliceController {
profilePolice.setProblemTypeRadarIndicator(problemTypeRadarIndicator); profilePolice.setProblemTypeRadarIndicator(problemTypeRadarIndicator);
profilePolice.setProblemTypeRadarData(problemTypeRadarData); profilePolice.setProblemTypeRadarData(problemTypeRadarData);
List<Object> result = profilePoliceService.getPoliceScore(beginTime, endTime, idCode); List<Object> result = negativeScoreService.calculatePoliceScore(beginTime, endTime, idCode);
profilePolice.setScore((BigDecimal) result.get(0)); profilePolice.setScore((BigDecimal) result.get(0));
profilePolice.setExpression(result.get(1).toString()); profilePolice.setExpression(result.get(1).toString());
return Result.success(profilePolice); return Result.success(profilePolice);

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

@ -0,0 +1,39 @@
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.RiskPersonal;
import com.biutag.supervision.pojo.param.RiskPersonalQueryParam;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
/**
* @author wxc
* @date 2024/11/12
*/
@Slf4j
@RequiredArgsConstructor
@RequestMapping("risk/personal")
@RestController
public class RiskPersonalController {
private final RiskPersonalService riskPersonalService;
@GetMapping
public Result<Page<RiskPersonal>> list(RiskPersonalQueryParam param) {
LambdaQueryWrapper<RiskPersonal> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StrUtil.isNotBlank(param.getName()), RiskPersonal::getName, param.getName())
.eq(StrUtil.isNotBlank(param.getGender()), RiskPersonal::getGender, param.getGender())
.eq(Objects.nonNull(param.getAge()), RiskPersonal::getAge, param.getAge())
.eq(StrUtil.isNotBlank(param.getControlDepartId()), RiskPersonal::getControlDepartId, param.getControlDepartId());
return Result.success(riskPersonalService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper));
}
}

16
src/main/java/com/biutag/supervision/controller/work/NegativeController.java

@ -40,8 +40,6 @@ public class NegativeController {
private final NegativeTaskService negativeTaskService; private final NegativeTaskService negativeTaskService;
private final NegativeBlameService blameService;
private final DepartNegativeRateService departNegativeRateService; private final DepartNegativeRateService departNegativeRateService;
@GetMapping @GetMapping
@ -115,12 +113,6 @@ public class NegativeController {
public Result<Boolean> remove(@PathVariable String id) { public Result<Boolean> remove(@PathVariable String id) {
return Result.success(negativeService.remove(id)); return Result.success(negativeService.remove(id));
} }
private final SupDictContentMapper supDictContentMapper;
private final NegativeProblemRelationService negativeProblemRelationService;
@GetMapping("completion/{id}") @GetMapping("completion/{id}")
public Result<NegativeConfirmationCompletionVo> completionInfo(@PathVariable String id) { public Result<NegativeConfirmationCompletionVo> completionInfo(@PathVariable String id) {
Negative negative = negativeService.getById(id); Negative negative = negativeService.getById(id);
@ -159,4 +151,12 @@ public class NegativeController {
return Result.success(completionVo); return Result.success(completionVo);
} }
private final NegativeScoreService negativeScoreService;
@PostMapping("score/calculate")
public Result<Void> calculateScore() {
negativeScoreService.updateNegativeScore();
return Result.success();
}
} }

65
src/main/java/com/biutag/supervision/job/ScoreJob.java

@ -1,23 +1,10 @@
package com.biutag.supervision.job; package com.biutag.supervision.job;
import cn.hutool.core.util.NumberUtil; import com.biutag.supervision.service.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.biutag.supervision.constants.enums.NegativeLevelEnum;
import com.biutag.supervision.mapper.NegativeBlameMapper;
import com.biutag.supervision.mapper.SupDictContentMapper;
import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.service.NegativeBlameService;
import com.biutag.supervision.service.NegativeProblemRelationService;
import com.biutag.supervision.service.NegativeScorePoliceService;
import com.biutag.supervision.service.NegativeService;
import com.biutag.supervision.util.ScoreRule;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.List;
/** /**
* @author wxc * @author wxc
* @date 2024/11/10 * @date 2024/11/10
@ -26,56 +13,10 @@ import java.util.List;
@Component @Component
public class ScoreJob { public class ScoreJob {
private final NegativeScorePoliceService negativeScorePoliceService; private final NegativeScoreService negativeScoreService;
private final NegativeBlameMapper blameMapper;
private final NegativeBlameService blameService;
private final NegativeService negativeService;
private final NegativeProblemRelationService problemRelationService; // @Scheduled(fixedRate = 600000)
private final SupDictContentMapper supDictContentMapper;
@Scheduled(fixedRate = 600000)
public void updateScore() { public void updateScore() {
System.out.println("updateScore-------------------------------------------------");
List<NegativeBlame> negativeBlames = blameMapper.selectVerifyTrue();
String formula = "%s + (%s * %s) + (%s * %s)";
negativeBlames.forEach(blame -> {
Negative negative = negativeService.getById(blame.getNegativeId());
NegativeScorePolice negativeScorePolice = new NegativeScorePolice()
.setNegativeId(blame.getNegativeId())
.setIdCode(blame.getBlameIdCode())
.setDiscoveryTime(negative.getDiscoveryTime())
.setIdCode(blame.getBlameIdCode())
.setBusinessTypeCode(negative.getBusinessTypeCode())
.setCreateTime(LocalDateTime.now());
List<NegativeProblemRelation> problems = problemRelationService.list(blame.getNegativeId(), blame.getBlameId());
List<String> codes = problems.stream().map(NegativeProblemRelation::getThreeLevelCode).toList();
if (codes.isEmpty()) {
return;
}
SupDictProblemType problemType = supDictContentMapper.selectOneByMaxScore(codes);
LocalDateTime endTime = negative.getDiscoveryTime();
LocalDateTime beginTime = endTime.minusYears(1);
int frequency = blameService.countByTrue(blame.getBlameIdCode(), problemType.getParentCode(), beginTime, endTime);
String expression = String.format(formula,
problemType.getScore(),
problemType.getScore(),
NegativeLevelEnum.GENERAL_IMPACT.getScore(),
problemType.getScore(),
ScoreRule.getFrequencyScore(frequency));
double calculate = NumberUtil.calculate(expression);
double score = NumberUtil.roundHalfEven(calculate, 2).doubleValue();
negativeScorePolice.setScore(score)
.setExpression(expression);
negativeScorePoliceService.remove(new LambdaQueryWrapper<NegativeScorePolice>().eq(NegativeScorePolice::getNegativeId, negative.getId()).eq(NegativeScorePolice::getIdCode, blame.getBlameIdCode()));
negativeScorePoliceService.save(negativeScorePolice);
});
} }

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

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

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

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

5
src/main/java/com/biutag/supervision/pojo/domain/ProfileDepart.java

@ -6,6 +6,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -17,6 +18,10 @@ import java.util.List;
@Getter @Getter
public class ProfileDepart { public class ProfileDepart {
private BigDecimal score;
private String expression;
private DepartInfo departInfo = new DepartInfo(); private DepartInfo departInfo = new DepartInfo();
private NegativeInfo negativeInfo = new NegativeInfo(); private NegativeInfo negativeInfo = new NegativeInfo();
private List<PieItem> problemSourcesList = new ArrayList<>(); private List<PieItem> problemSourcesList = new ArrayList<>();

40
src/main/java/com/biutag/supervision/pojo/entity/NegativeScoreDepart.java

@ -0,0 +1,40 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class NegativeScoreDepart {
//
@TableId(value = "negative_id")
private String negativeId;
private String departId;
//
@TableField("discovery_time")
private LocalDateTime discoveryTime;
//
@TableField("create_time")
private LocalDateTime createTime;
//
@TableField("business_type_code")
private String businessTypeCode;
//
@TableField("score")
private Double score;
//
@TableField("expression")
private String expression;
}

1
src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java

@ -31,7 +31,6 @@ public class NegativeScorePolice {
// 计算公式 // 计算公式
private String expression; private String expression;
// 业务类型
private String businessTypeCode; private String businessTypeCode;
} }

71
src/main/java/com/biutag/supervision/pojo/entity/RiskPersonal.java

@ -0,0 +1,71 @@
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 lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class RiskPersonal {
// 主键
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
// 姓名
@TableField("name")
private String name;
// 性别男1女2
@TableField("gender")
private String gender;
// 年龄
@TableField("age")
private Integer age;
// 大标签预览
@TableField("tags")
private String tags;
// 证件号码
@TableField("id_code")
private String idCode;
// 手机号
@TableField("mobile_number")
private String mobileNumber;
// 风险指数
@TableField("risk_score")
private Integer riskScore;
// 管控部门编号
@TableField("control_depart_id")
private String controlDepartId;
// 管控部门名称
@TableField("control_depart_name")
private String controlDepartName;
// 管控时间
@TableField("control_time")
private LocalDateTime controlTime;
// 创建时间
@TableField("create_time")
private LocalDateTime createTime;
// 异常信息
@TableField("error_msg")
private String errorMsg;
// 逻辑删除键0-未删1已删
@TableField("del")
private Boolean del;
}

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

@ -147,4 +147,6 @@ public class SupPolice {
// 警员角色 // 警员角色
private String policeRole; private String policeRole;
private Integer sortId;
} }

4
src/main/java/com/biutag/supervision/pojo/model/DepartNegativeModel.java

@ -3,6 +3,8 @@ package com.biutag.supervision.pojo.model;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.math.BigDecimal;
/** /**
* @author wxc * @author wxc
* @date 2024/11/1 * @date 2024/11/1
@ -24,4 +26,6 @@ public class DepartNegativeModel {
private Integer verifyPoliceSize; private Integer verifyPoliceSize;
// 查实问题数 // 查实问题数
private Integer verifySize; private Integer verifySize;
private BigDecimal score;
} }

3
src/main/java/com/biutag/supervision/pojo/model/PoliceNegativeModel.java

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
/** /**
@ -29,4 +30,6 @@ public class PoliceNegativeModel {
private Integer verifySize; private Integer verifySize;
private String departName; private String departName;
private String parentDepartName; private String parentDepartName;
private BigDecimal score;
} }

27
src/main/java/com/biutag/supervision/pojo/param/RiskPersonalQueryParam.java

@ -0,0 +1,27 @@
package com.biutag.supervision.pojo.param;
import lombok.Getter;
import lombok.Setter;
/**
* @author wxc
* @date 2024/11/12
*/
@Setter
@Getter
public class RiskPersonalQueryParam extends BasePage {
private String name;
// 性别男1女2
private String gender;
// 年龄
private Integer age;
// 手机号
private String mobileNumber;
private String controlDepartId;
}

7
src/main/java/com/biutag/supervision/pojo/vo/NegativeQueryVo.java

@ -182,4 +182,11 @@ public class NegativeQueryVo {
// 当前处理对象 // 当前处理对象
private String currentProcessingObject; private String currentProcessingObject;
// 专项督察
private String specialSupervision;
// 通报期数
private String reportNumber;
} }

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

@ -2,14 +2,12 @@ package com.biutag.supervision.service;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.mapper.*; import com.biutag.supervision.mapper.*;
import com.biutag.supervision.pojo.entity.BusinessDepart; import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.pojo.entity.BusinessLog;
import com.biutag.supervision.pojo.entity.GBaseAJJBXX;
import com.biutag.supervision.pojo.entity.GBaseJJD;
import com.biutag.supervision.pojo.model.BusinessPoliceModel; import com.biutag.supervision.pojo.model.BusinessPoliceModel;
import com.biutag.supervision.pojo.model.DataRightsComfortModel; import com.biutag.supervision.pojo.model.DataRightsComfortModel;
import com.biutag.supervision.pojo.param.BusinessQueryParam; import com.biutag.supervision.pojo.param.BusinessQueryParam;
@ -279,4 +277,8 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
} }
return result; 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));
}
} }

20
src/main/java/com/biutag/supervision/service/NegativeScoreDepartService.java

@ -0,0 +1,20 @@
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.mapper.NegativeScoreDepartMapper;
import com.biutag.supervision.pojo.entity.NegativeScoreDepart;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class NegativeScoreDepartService extends ServiceImpl<NegativeScoreDepartMapper, NegativeScoreDepart> {
public List<NegativeScoreDepart> list(Date beginTime, Date endTime) {
return list(new LambdaQueryWrapper<NegativeScoreDepart>()
.between(NegativeScoreDepart::getDiscoveryTime, beginTime, endTime));
}
}

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

@ -0,0 +1,290 @@
package com.biutag.supervision.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.biutag.supervision.constants.enums.BusinessTypeEnum;
import com.biutag.supervision.constants.enums.NegativeLevelEnum;
import com.biutag.supervision.mapper.NegativeBlameMapper;
import com.biutag.supervision.mapper.SupDictContentMapper;
import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.util.ScoreRule;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
/**
* @author wxc
* @date 2024/11/12
*/
@RequiredArgsConstructor
@Service
public class NegativeScoreService {
private final NegativeScorePoliceService negativeScorePoliceService;
private final NegativeScoreDepartService negativeScoreDepartService;
private final NegativeBlameMapper blameMapper;
private final NegativeBlameService blameService;
private final NegativeService negativeService;
private final NegativeProblemRelationService problemRelationService;
private final SupDictContentMapper supDictContentMapper;
private AtomicBoolean flag = new AtomicBoolean(false);
public void updateNegativeScore() {
if (flag.get()) {
throw new RuntimeException("风险指数正在计算中");
}
flag.set(true);
System.out.println("calculateScore-------------------------------------------------");
List<NegativeBlame> negativeBlames = blameMapper.selectVerifyTrue();
String formula = "%s + (%s * %s) + (%s * %s)";
List<NegativeScoreDepart> scoreDeparts = new ArrayList<>();
negativeScorePoliceService.remove(new LambdaQueryWrapper<>());
negativeScoreDepartService.remove(new LambdaQueryWrapper<>());
negativeBlames.forEach(blame -> {
Negative negative = negativeService.getById(blame.getNegativeId());
NegativeScorePolice negativeScorePolice = new NegativeScorePolice()
.setNegativeId(blame.getNegativeId())
.setIdCode(blame.getBlameIdCode())
.setDiscoveryTime(negative.getDiscoveryTime())
.setIdCode(blame.getBlameIdCode())
.setBusinessTypeCode(negative.getBusinessTypeCode())
.setCreateTime(LocalDateTime.now());
List<NegativeProblemRelation> problems = problemRelationService.list(blame.getNegativeId(), blame.getBlameId());
List<String> codes = problems.stream().map(NegativeProblemRelation::getThreeLevelCode).toList();
if (codes.isEmpty()) {
return;
}
SupDictProblemType problemType = supDictContentMapper.selectOneByMaxScore(codes);
LocalDateTime endTime = negative.getDiscoveryTime();
LocalDateTime beginTime = endTime.minusYears(1);
int frequency = blameService.countByTrue(blame.getBlameIdCode(), problemType.getParentCode(), beginTime, endTime);
String expression = String.format(formula,
problemType.getScore(),
problemType.getScore(),
NegativeLevelEnum.GENERAL_IMPACT.getScore(),
problemType.getScore(),
ScoreRule.getFrequencyScore(frequency));
double calculate = NumberUtil.calculate(expression);
double score = NumberUtil.roundHalfEven(calculate, 2).doubleValue();
negativeScorePolice.setScore(score)
.setExpression(expression);
negativeScorePoliceService.save(negativeScorePolice);
NegativeScoreDepart scoreDepart = scoreDeparts.stream().filter(item -> item.getNegativeId().equals(negative.getId())).findFirst().orElse(null);
if (Objects.isNull(scoreDepart)) {
scoreDepart = new NegativeScoreDepart();
BeanUtil.copyProperties(negativeScorePolice, scoreDepart);
scoreDepart.setDepartId(negative.getInvolveDepartId());
scoreDeparts.add(scoreDepart);
} else if (scoreDepart.getScore() < score) {
scoreDepart.setScore(score);
}
});
if (!scoreDeparts.isEmpty()) {
negativeScoreDepartService.saveBatch(scoreDeparts);
}
flag.set(false);
System.out.println("calculateScore-------------------------------------------------End");
}
private final BusinessPoliceService businessPoliceService;
private final BusinessDepartService businessDepartService;
private final SupPoliceService policeService;
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
public double calculateBusinessWeight(Double totalScore, Double score) {
if (totalScore == 0) {
return 0.0;
}
return NumberUtil.div(score, totalScore);
}
// 平均问题数 = 单个业务问题数 / 业务涉及人数
public double calculateAvgNumber(int size, int policeSize) {
if (policeSize == 0) {
return 0;
}
return NumberUtil.div(size, policeSize);
}
// 业务标准差 = 根号(sum((个人问题数 - 平均问题数)²) / 业务涉及人数)
public double calculateSd(double[] diffNumber, int policeSize) {
if (policeSize == 0) {
return 0;
}
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) {
return 0;
}
List<BusinessPolice> businessPolices = businessPoliceService.list(beginTime, endTime, businessTypeCode);
// 总业务量
int totalBusinessSize = businessPolices.stream().mapToInt(BusinessPolice::getNumber).sum();
// 平均问题发生率
double avgRate = totalBusinessSize == 0? 0: NumberUtil.div(businessScorePolice.size(), totalBusinessSize);
// 个人问题数
long personSize = businessScorePolice.stream().filter(item -> police.getIdCode().equals(item.getIdCode())).count();
// 个人业务量
long personBusinessSize = businessPolices.stream().filter(item -> police.getName().equals(item.getPoliceName()) && police.getEmpNo().equals(item.getEmpNo())).count();
// 个人问题发生率
double personRate = personBusinessSize == 0? 0: NumberUtil.div(personSize, personBusinessSize);
return NumberUtil.div(personRate - avgRate, sd);
}
public double calculateDiff1ByDepart(List<NegativeScoreDepart> businessScoreDeparts, String departId, Date beginTime, Date endTime, String businessTypeCode, double sd) {
if (sd == 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);
}
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
public double calculateDiff2(long personalSize, double avgNumber, double sd) {
if (sd == 0) {
return 0;
}
return NumberUtil.div(personalSize - avgNumber, sd);
}
public double calculateBusinessScore(double diff, long personalSize) {
if (personalSize == 0) {
return 0;
}
return 50 + (diff * 15);
}
// 平均问题数 = 单个业务问题数 / 业务涉及人数
// 业务标准差 = sum((个人问题数 - 平均问题数)²) / 业务涉及人数
// 业务差异值1 = (问题发生率 - 平均问题发生率) / 业务标准差
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
// 业务风险指数 = 50 + (业务差异值 * 15)
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
// 个人风险指数 = sum(业务风险指数 * 业务权重)
/**
* 个人风险指数
* @param beginTime
* @param endTime
* @param idCode
* @return
*/
public List<Object> calculatePoliceScore(Date beginTime, Date endTime, String idCode) {
List<NegativeScorePolice> scorePolices = negativeScorePoliceService.list(beginTime, endTime);
Double totalScore = scorePolices.stream().mapToDouble(NegativeScorePolice::getScore).sum();
SupPolice police = policeService.getByIdCode(idCode);
List<String> expressionArr = new ArrayList<>();
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> {
List<NegativeScorePolice> businessScorePolice = scorePolices.stream().filter(item -> item.getBusinessTypeCode().equals(businessTypeEnum.getValue())).toList();
// 业务涉及人数
int policeSize = businessScorePolice.stream().map(NegativeScorePolice::getIdCode).collect(Collectors.toSet()).size();
// 业务问题数
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);
// 业务差异值
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);
} else {
diff = calculateDiff2(personalSize, avgNumber, sd);
}
// 业务风险指数
double businessScore = calculateBusinessScore(diff, personalSize);
// 业务权重
Double score = businessScorePolice.stream().mapToDouble(NegativeScorePolice::getScore).sum();
double businessWeight = calculateBusinessWeight(totalScore, score);
expressionArr.add(String.format("(%s * %s)", businessScore, businessWeight));
return NumberUtil.mul(businessScore, businessWeight);
}).sum();
BigDecimal score = NumberUtil.roundHalfEven(policeScore, 2);
String expression = String.join(" + ", expressionArr);
return List.of(score, expression);
}
/**
* 单位风险指数
* @param beginTime
* @param endTime
* @param departId
* @return
*/
public List<Object> calculateDepartScore(Date beginTime, Date endTime, String departId) {
List<NegativeScoreDepart> scoreDeparts = negativeScoreDepartService.list(beginTime, endTime);
Double totalScore = scoreDeparts.stream().mapToDouble(NegativeScoreDepart::getScore).sum();
List<String> expressionArr = new ArrayList<>();
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> {
List<NegativeScoreDepart> businessScoreDeparts = scoreDeparts.stream().filter(item -> item.getBusinessTypeCode().equals(businessTypeEnum.getValue())).toList();
// 业务涉及人数
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 diff;
if (businessTypeEnum.getBusinessVolume()) {
diff = calculateDiff1ByDepart(businessScoreDeparts, departId, beginTime, endTime, businessTypeEnum.getValue(), sd);
} else {
diff = calculateDiff2(personalSize, avgNumber, sd);
}
// 业务风险指数
double businessScore = calculateBusinessScore(diff, personalSize);
// 业务权重
Double score = businessScoreDeparts.stream().mapToDouble(NegativeScoreDepart::getScore).sum();
double businessWeight = calculateBusinessWeight(totalScore, score);
expressionArr.add(String.format("(%s * %s)", businessScore, businessWeight));
return NumberUtil.mul(businessScore, businessWeight);
}).sum();
BigDecimal score = NumberUtil.roundHalfEven(policeScore, 2);
String expression = String.join(" + ", expressionArr);
return List.of(score, expression);
}
}

138
src/main/java/com/biutag/supervision/service/ProfilePoliceService.java

@ -1,138 +0,0 @@
package com.biutag.supervision.service;
import cn.hutool.core.util.NumberUtil;
import com.biutag.supervision.constants.enums.BusinessTypeEnum;
import com.biutag.supervision.pojo.entity.BusinessPolice;
import com.biutag.supervision.pojo.entity.NegativeScorePolice;
import com.biutag.supervision.pojo.entity.SupPolice;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
*
* @author wxc
* @date 2024/11/11
*/
// 平均问题数 = 总问题数 / 业务涉及人数
// 业务标准差 = sum((个人问题数 - 平均问题数)²) / 业务涉及人数
// 业务差异值1 = (问题发生率 - 平均问题发生率) / 业务标准差
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
// 业务风险指数 = 50 + (业务差异值 * 15)
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
// 个人风险指数 = sum(业务风险指数 * 业务权重)
@RequiredArgsConstructor
@Service
public class ProfilePoliceService {
private final NegativeScorePoliceService negativeScorePoliceService;
private final BusinessPoliceService businessPoliceService;
private final SupPoliceService policeService;
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
public double getBusinessWeight(Double totalScore, List<NegativeScorePolice> businessScorePolice) {
if (totalScore == 0) {
return 0.0;
}
Double score = businessScorePolice.stream().mapToDouble(NegativeScorePolice::getScore).sum();
return NumberUtil.div(score, totalScore);
}
// 平均问题数 = 单个业务问题数 / 业务涉及人数
public double getAvgNumber(int size, int policeSize) {
if (policeSize == 0) {
return 0;
}
return NumberUtil.div(size, policeSize);
}
// 业务标准差 = 根号(sum((个人问题数 - 平均问题数)²) / 业务涉及人数)
public double getSd(List<NegativeScorePolice> businessScorePolice, double avgNumber, int policeSize) {
if (policeSize == 0) {
return 0;
}
Map<String, List<NegativeScorePolice>> group = businessScorePolice.stream().collect(Collectors.groupingBy(NegativeScorePolice::getIdCode));
return Math.sqrt(group.values().stream().mapToDouble(val -> Math.pow(val.size() - avgNumber, 2)).sum() / policeSize);
}
// 业务差异值1 = (个人问题发生率 - 平均问题发生率) / 业务标准差
// 平均问题发生率 = 总问题数 / 总业务量
// 个人问题发生率 = 个人问题数 / 个人业务量
public double getDiff1(List<NegativeScorePolice> businessScorePolice, SupPolice police, Date beginTime, Date endTime, String businessTypeCode, double sd) {
if (sd == 0) {
return 0;
}
List<BusinessPolice> businessPolices = businessPoliceService.list(beginTime, endTime, businessTypeCode);
// 总业务量
int totalBusinessSize = businessPolices.stream().mapToInt(BusinessPolice::getNumber).sum();
// 平均问题发生率
double avgRate = totalBusinessSize == 0? 0: NumberUtil.div(businessScorePolice.size(), totalBusinessSize);
// 个人问题数
long personSize = businessScorePolice.stream().filter(item -> police.getIdCode().equals(item.getIdCode())).count();
// 个人业务量
long personBusinessSize = businessPolices.stream().filter(item -> police.getName().equals(item.getPoliceName()) && police.getEmpNo().equals(item.getEmpNo())).count();
// 个人问题发生率
double personRate = personBusinessSize == 0? 0: NumberUtil.div(personSize, personBusinessSize);
return NumberUtil.div(personRate - avgRate, sd);
}
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
public double getDiff2(List<NegativeScorePolice> businessScorePolice, String idCode, double avgNumber, double sd) {
if (sd == 0) {
return 0;
}
long size = businessScorePolice.stream().filter(item -> idCode.equals(item.getIdCode())).count();
return NumberUtil.div(size - avgNumber, sd);
}
public double getBusinessScore(double diff) {
return 50 + (diff * 15);
}
// 平均问题数 = 单个业务问题数 / 业务涉及人数
// 业务标准差 = sum((个人问题数 - 平均问题数)²) / 业务涉及人数
// 业务差异值1 = (问题发生率 - 平均问题发生率) / 业务标准差
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
// 业务风险指数 = 50 + (业务差异值 * 15)
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
// 个人风险指数 = sum(业务风险指数 * 业务权重)
public List<Object> getPoliceScore(Date beginTime, Date endTime, String idCode) {
List<NegativeScorePolice> scorePolices = negativeScorePoliceService.list(beginTime, endTime);
Double totalScore = scorePolices.stream().mapToDouble(NegativeScorePolice::getScore).sum();
SupPolice police = policeService.getByIdCode(idCode);
List<String> expressionArr = new ArrayList<>();
double policeScore = Arrays.stream(BusinessTypeEnum.values()).mapToDouble(businessTypeEnum -> {
List<NegativeScorePolice> businessScorePolice = scorePolices.stream().filter(item -> item.getBusinessTypeCode().equals(businessTypeEnum.getValue())).toList();
// 业务涉及人数
int policeSize = businessScorePolice.stream().map(NegativeScorePolice::getIdCode).collect(Collectors.toSet()).size();
// 平均问题数
double avgNumber = getAvgNumber(businessScorePolice.size(), policeSize);
// 业务标准差
double sd = getSd(businessScorePolice, avgNumber, policeSize);
// 业务差异值
double diff;
if (businessTypeEnum.getBusinessVolume()) {
diff = getDiff1(businessScorePolice, police, beginTime, endTime, businessTypeEnum.getValue(), sd);
} else {
diff = getDiff2(businessScorePolice, idCode, avgNumber, sd);
}
// 业务风险指数
double businessScore = getBusinessScore(diff);
// 业务权重
double businessWeight = getBusinessWeight(totalScore, businessScorePolice);
expressionArr.add(String.format("(%s * %s)", businessScore, businessWeight));
return NumberUtil.mul(businessScore, businessWeight);
}).sum();
BigDecimal score = NumberUtil.roundHalfEven(policeScore, 2);
String expression = String.join(" + ", expressionArr);
return List.of(score, expression);
}
}

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

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

33
src/main/java/com/biutag/supervision/service/ScoreService.java

@ -0,0 +1,33 @@
package com.biutag.supervision.service;
import cn.hutool.core.util.NumberUtil;
import com.biutag.supervision.constants.enums.BusinessTypeEnum;
import com.biutag.supervision.pojo.entity.BusinessPolice;
import com.biutag.supervision.pojo.entity.NegativeScorePolice;
import com.biutag.supervision.pojo.entity.SupPolice;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
*
* @author wxc
* @date 2024/11/11
*/
// 平均问题数 = 总问题数 / 业务涉及人数
// 业务标准差 = sum((个人问题数 - 平均问题数)²) / 业务涉及人数
// 业务差异值1 = (问题发生率 - 平均问题发生率) / 业务标准差
// 业务差异值2 = (问题数 - 平均问题数) / 业务标准差
// 业务风险指数 = 50 + (业务差异值 * 15)
// 业务权重 = 单个业务风险指数 / 总业务风险指数之和
// 个人风险指数 = sum(业务风险指数 * 业务权重)
@RequiredArgsConstructor
@Service
public class ScoreService {
}

2
src/main/java/com/biutag/supervision/service/SupPoliceService.java

@ -50,7 +50,7 @@ public class SupPoliceService extends ServiceImpl<SupPoliceMapper, SupPolice> {
} }
} }
queryWrapper.apply(StrUtil.isNotBlank(param.getRoleId()), String.format("find_in_set( '%s', u.role_id) > 0", param.getRoleId())); queryWrapper.apply(StrUtil.isNotBlank(param.getRoleId()), String.format("find_in_set( '%s', u.role_id) > 0", param.getRoleId()));
queryWrapper.orderByAsc("d.level").orderByDesc("p.position").orderByAsc("p.person_status"); queryWrapper.orderByAsc("d.level").orderByDesc("p.position").orderByDesc("p.sort_id").orderByAsc("p.person_status");
return baseMapper.queryPage(Page.of(param.getCurrent(), param.getSize()), queryWrapper); return baseMapper.queryPage(Page.of(param.getCurrent(), param.getSize()), queryWrapper);
} }

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

@ -14,17 +14,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.person_type, p.person_type,
d.short_name depart_name, d.short_name depart_name,
d1.short_name parent_depart_name, d1.short_name parent_depart_name,
count( DISTINCT n.id ) verify_size count( DISTINCT n.negative_id ) verify_size
FROM FROM
sup_police p sup_police p
LEFT JOIN sup_depart d ON p.org_id = d.id LEFT JOIN sup_depart d ON p.org_id = d.id
LEFT JOIN sup_depart d1 ON d.pid = d1.id and d1.level >= 2 LEFT JOIN sup_depart d1 ON d.pid = d1.id and d1.level >= 2
LEFT JOIN negative_blame nb ON p.id_code = nb.blameIdCode LEFT JOIN negative_score_police n ON p.id_code = n.id_code
LEFT JOIN negative n ON nb.negativeId = n.id
AND n.checkStatus IN ( '1', '2' )
AND n.discoveryTime BETWEEN #{beginTime} AND #{endTime}
WHERE WHERE
1 = 1 n.id_code is not null
AND n.discovery_time BETWEEN #{beginTime} AND #{endTime}
<if test="name != null and name != ''"> <if test="name != null and name != ''">
AND p.name like concat('%', #{name}, '%') AND p.name like concat('%', #{name}, '%')
</if> </if>

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

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

Loading…
Cancel
Save