Browse Source

fit: 认定办结问题打分

main
wxc 1 year ago
parent
commit
386a470e13
  1. 19
      sql/1109.sql
  2. 2
      src/main/java/com/biutag/supervision/constants/enums/FlowNodeEnum.java
  3. 34
      src/main/java/com/biutag/supervision/constants/enums/NegativeLevelEnum.java
  4. 12
      src/main/java/com/biutag/supervision/constants/enums/OrderEnum.java
  5. 1
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java
  6. 9
      src/main/java/com/biutag/supervision/controller/system/DepartController.java
  7. 62
      src/main/java/com/biutag/supervision/controller/work/NegativeController.java
  8. 3
      src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java
  9. 106
      src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java
  10. 77
      src/main/java/com/biutag/supervision/flow/action/FirstApproveAction.java
  11. 3
      src/main/java/com/biutag/supervision/flow/action/SaveAction.java
  12. 71
      src/main/java/com/biutag/supervision/job/DepartJob.java
  13. 2
      src/main/java/com/biutag/supervision/job/Job.java
  14. 79
      src/main/java/com/biutag/supervision/job/ScoreJob.java
  15. 14
      src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java
  16. 8
      src/main/java/com/biutag/supervision/mapper/NegativeScorePoliceMapper.java
  17. 9
      src/main/java/com/biutag/supervision/mapper/SupDictContentMapper.java
  18. 3
      src/main/java/com/biutag/supervision/pojo/domain/NegativeDetail.java
  19. 12
      src/main/java/com/biutag/supervision/pojo/domain/NegativeVo.java
  20. 42
      src/main/java/com/biutag/supervision/pojo/dto/flow/ConfirmationCompletionData.java
  21. 23
      src/main/java/com/biutag/supervision/pojo/dto/flow/VerifyData.java
  22. 2
      src/main/java/com/biutag/supervision/pojo/entity/DepartNegativeRate.java
  23. 34
      src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java
  24. 3
      src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java
  25. 2
      src/main/java/com/biutag/supervision/pojo/model/NegativeWorkModel.java
  26. 4
      src/main/java/com/biutag/supervision/pojo/param/NegativeQueryParam.java
  27. 65
      src/main/java/com/biutag/supervision/pojo/vo/NegativeConfirmationCompletionVo.java
  28. 5
      src/main/java/com/biutag/supervision/service/DepartNegativeRateService.java
  29. 12
      src/main/java/com/biutag/supervision/service/NegativeBlameService.java
  30. 9
      src/main/java/com/biutag/supervision/service/NegativeQueryService.java
  31. 18
      src/main/java/com/biutag/supervision/service/NegativeScorePoliceService.java
  32. 29
      src/main/java/com/biutag/supervision/service/NegativeService.java
  33. 17
      src/main/java/com/biutag/supervision/service/SupDepartService.java
  34. 2
      src/main/java/com/biutag/supervision/service/SupPoliceService.java
  35. 33
      src/main/java/com/biutag/supervision/util/ScoreRule.java
  36. 6
      src/main/resources/application-local.yml
  37. 5
      src/main/resources/mapper/NegativeWorkMapper.xml
  38. 15
      src/main/resources/mapper/SupDictContentMapper.xml
  39. 2
      src/test/java/com/biutag/supervision/tools/GenCodeTests.java

19
sql/1109.sql

@ -0,0 +1,19 @@
truncate statistics_group ;
INSERT INTO `negative`.`statistics_group`(`groupId`, `name`, `level`, `remark`, `type`, `pid`, `flag`, `sort`) VALUES (4, '局属单位', 1, NULL, 'oneLevel', NULL, '0', 2);
INSERT INTO `negative`.`statistics_group`(`groupId`, `name`, `level`, `remark`, `type`, `pid`, `flag`, `sort`) VALUES (3, '分县市局', 1, '二级机构对比', 'oneLevel', NULL, '0', 3);
INSERT INTO `negative`.`statistics_group`(`groupId`, `name`, `level`, `remark`, `type`, `pid`, `flag`, `sort`) VALUES (10, '派出所', 2, '三级机构对比', '', NULL, '1', 4);
INSERT INTO `negative`.`statistics_group`(`groupId`, `name`, `level`, `remark`, `type`, `pid`, `flag`, `sort`) VALUES (11, '交警大队', 2, '三级机构对比', NULL, NULL, '0', 5);
INSERT INTO `negative`.`statistics_group`(`groupId`, `name`, `level`, `remark`, `type`, `pid`, `flag`, `sort`) VALUES (13, '刑侦大队', 2, NULL, NULL, NULL, '0', 6);
INSERT INTO `negative`.`statistics_group`(`groupId`, `name`, `level`, `remark`, `type`, `pid`, `flag`, `sort`) VALUES (14, '禁毒大队', 2, NULL, NULL, NULL, '0', 7);
INSERT INTO `negative`.`statistics_group`(`groupId`, `name`, `level`, `remark`, `type`, `pid`, `flag`, `sort`) VALUES (15, '治安大队', 2, NULL, NULL, NULL, '0', 8);
INSERT INTO `negative`.`statistics_group`(`groupId`, `name`, `level`, `remark`, `type`, `pid`, `flag`, `sort`) VALUES (16, '人境大队', 2, NULL, NULL, NULL, '0', 9);
INSERT INTO `negative`.`statistics_group`(`groupId`, `name`, `level`, `remark`, `type`, `pid`, `flag`, `sort`) VALUES (12, '其他', 2, '三级机构对比', NULL, NULL, '0', 10);
update sup_depart set statistics_group_id = 10 where short_name like '%派出所' and `level` = 3;
update sup_depart set statistics_group_id = 12 where pid = '2623' and short_name like '%大队' and `level` = 3;
update sup_depart set statistics_group_id = 14 where short_name = '禁毒大队' and `level` = 3;
update sup_depart set statistics_group_id = 15 where short_name = '治安大队' and `level` = 3;
update sup_depart set statistics_group_id = 16 where short_name = '人境大队' and `level` = 3;
-- 其他
update sup_depart set statistics_group_id = 12 where statistics_group_id is null and `level` = 3;

2
src/main/java/com/biutag/supervision/constants/enums/FlowNodeEnum.java

@ -14,7 +14,7 @@ public enum FlowNodeEnum {
SECOND_DISTRIBUTE("second_distribute"),
THREE_SIGN("three_sign"),
VERIFY("verify"),
SECOND_APPROVE("first_approve"),
SECOND_APPROVE("second_approve"),
FIRST_APPROVE("first_approve"),
SECOND_EXTENSION_APPROVE("first_approve"),
FIRST_EXTENSION_APPROVE("first_approve"),

34
src/main/java/com/biutag/supervision/constants/enums/NegativeLevelEnum.java

@ -0,0 +1,34 @@
package com.biutag.supervision.constants.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author wxc
* @date 2024/11/8
*/
@Getter
@AllArgsConstructor
public enum NegativeLevelEnum {
GENERAL_IMPACT("一般影响", "1", 0.0),
SERIOUS_IMPACT("严重影响", "2", 0.2),
SIGNIFICANT_IMPACT("重大影响", "3", 0.5);
private String lable;
private String value;
private Double score;
public static Double getScore(String value) {
for (NegativeLevelEnum negativeLevelEnum : values()) {
if (negativeLevelEnum.value.equals(value)) {
return negativeLevelEnum.score;
}
}
return 0.0;
}
}

12
src/main/java/com/biutag/supervision/constants/enums/OrderEnum.java

@ -0,0 +1,12 @@
package com.biutag.supervision.constants.enums;
/**
* @author wxc
* @date 2024/11/8
*/
public enum OrderEnum {
// 正序
ascending,
// 倒叙
descending;
}

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

@ -52,7 +52,6 @@ public class ProfilePoliceController {
private final NegativeBlameService negativeBlameService;
private final NegativeService negativeService;
@GetMapping
public Result<Page<PoliceNegativeModel>> list(DepartPoliceQueryParam param) {
Date beginTime = DateUtil.parse("1949", "YYYY");

9
src/main/java/com/biutag/supervision/controller/system/DepartController.java

@ -18,6 +18,7 @@ import jakarta.validation.ValidationException;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -79,7 +80,8 @@ public class DepartController {
if (policeService.exists(id)) {
throw new RuntimeException("该单位下还有警务人员,请移除后再删除");
}
return Result.success(departService.removeById(id));
List<String> orgIds = departService.getAllNodeIds(id);
return Result.success(departService.removeBatchByIds(orgIds));
}
@GetMapping("tree")
@ -87,6 +89,11 @@ public class DepartController {
return Result.success(departService.buildTreeByAuth());
}
@GetMapping("treeAll")
public Result<List<DepartTree>> treeAll() {
return Result.success(departService.buildTreeAll());
}
@GetMapping("second")
public Result<List<DepartTree>> seconds() {
List<SupDepart> supDeparts = departService.listByLevel(List.of(DepartLevelEnum.SECOND_CATEGORY.getValue(), DepartLevelEnum.SECOND.getValue()));

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

@ -1,30 +1,31 @@
package com.biutag.supervision.controller.work;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.common.validation.AddGroup;
import com.biutag.supervision.common.validation.EditGroup;
import com.biutag.supervision.flow.FlowService;
import com.biutag.supervision.mapper.SupDictContentMapper;
import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.domain.NegativeDetail;
import com.biutag.supervision.pojo.dto.ActionDto;
import com.biutag.supervision.pojo.dto.NegativeDto;
import com.biutag.supervision.pojo.entity.Negative;
import com.biutag.supervision.pojo.entity.NegativeTask;
import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.pojo.param.NegativeQueryParam;
import com.biutag.supervision.pojo.vo.NegativeConfirmationCompletionVo;
import com.biutag.supervision.pojo.vo.NegativeQueryVo;
import com.biutag.supervision.service.NegativeQueryService;
import com.biutag.supervision.service.NegativeService;
import com.biutag.supervision.service.NegativeTaskService;
import com.biutag.supervision.service.*;
import com.biutag.supervision.util.JSON;
import jakarta.validation.Valid;
import com.biutag.supervision.util.ScoreRule;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;
@RequiredArgsConstructor
@RequestMapping("negative")
@ -39,6 +40,10 @@ public class NegativeController {
private final NegativeTaskService negativeTaskService;
private final NegativeBlameService blameService;
private final DepartNegativeRateService departNegativeRateService;
@GetMapping
public Result<Page<NegativeQueryVo>> list(NegativeQueryParam queryParam) {
return Result.success(negativeQueryService.page(queryParam));
@ -102,4 +107,47 @@ public class NegativeController {
return Result.success(negativeService.remove(id));
}
private final SupDictContentMapper supDictContentMapper;
private final NegativeProblemRelationService negativeProblemRelationService;
@GetMapping("completion/{id}")
public Result<NegativeConfirmationCompletionVo> completionInfo(@PathVariable String id) {
Negative negative = negativeService.getById(id);
LocalDateTime endTime = negative.getDiscoveryTime();
LocalDateTime beginTime = endTime.minusYears(1);
String month = LocalDateTime.now().minusMonths(1).format(DateTimeFormatter.ofPattern("yyyy-MM"));
DepartNegativeRate rate = departNegativeRateService.get(negative.getInvolveDepartId(), month);
List<NegativeConfirmationCompletionVo.Blame> blames = blameService.list(id).stream().map(blame -> {
List<NegativeProblemRelation> problems = negativeProblemRelationService.list(id, blame.getBlameId());
List<String> codes = problems.stream().map(NegativeProblemRelation::getThreeLevelCode).toList();
if (codes.isEmpty()) {
throw new RuntimeException("数据异常");
}
SupDictProblemType problemType = supDictContentMapper.selectOneByMaxScore(codes);
NegativeConfirmationCompletionVo.Blame b = new NegativeConfirmationCompletionVo.Blame();
b.setProblems(problems);
b.setBlameId(blame.getBlameId());
b.setBlameName(blame.getBlameName());
b.setBlameEmpNo(blame.getBlameEmpNo());
b.setBlameIdCode(blame.getBlameIdCode());
b.setBaseScore(problemType.getScore());
int frequency = blameService.countByTrue(blame.getBlameIdCode(), problemType.getParentCode(), beginTime, endTime);
b.setFrequency(frequency);
b.setFrequencyScore(ScoreRule.getFrequencyScore(frequency));
if (Objects.nonNull(rate)) {
b.setIncidenceRate(rate.getIncidenceRate());
}
return b;
}).toList();
NegativeConfirmationCompletionVo completionVo = new NegativeConfirmationCompletionVo();
completionVo.setBlames(blames);
return Result.success(completionVo);
}
}

3
src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java

@ -84,6 +84,9 @@ public class ApplyCompletionAction implements Action {
List<NegativeBlame> negativeBlames = verifyData.getBlames().stream().map(item -> {
NegativeBlame negativeBlame = new NegativeBlame();
BeanUtil.copyProperties(item, negativeBlame);
VerifyData.BlameLeader blameLeader = verifyData.getBlameLeaders().stream()
.filter(leader -> leader.getBlameIdCodes().contains(item.getBlameIdCode())).findFirst().get();
BeanUtil.copyProperties(blameLeader, negativeBlame);
negativeBlame
.setBlameId(IdUtil.fastSimpleUUID())
.setNegativeId(negativeId)

106
src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java

@ -0,0 +1,106 @@
package com.biutag.supervision.flow.action;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.biutag.supervision.common.UserContextHolder;
import com.biutag.supervision.constants.enums.*;
import com.biutag.supervision.pojo.dto.ActionDto;
import com.biutag.supervision.pojo.dto.flow.ConfirmationCompletionData;
import com.biutag.supervision.pojo.entity.Negative;
import com.biutag.supervision.pojo.entity.NegativeApprove;
import com.biutag.supervision.pojo.entity.NegativeScorePolice;
import com.biutag.supervision.pojo.entity.NegativeWork;
import com.biutag.supervision.pojo.model.UserAuth;
import com.biutag.supervision.service.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author wxc
* @date 2024/11/8
*/
@RequiredArgsConstructor
@Component
public class ConfirmationCompletionAction implements Action {
private final NegativeService negativeService;
private final NegativeScorePoliceService negativeScorePoliceService;
private final NegativeWorkService workService;
private final NegativeApproveService approveService;
@Override
public void next(ActionDto actionDto) {
ConfirmationCompletionData completionData = BeanUtil.toBean(actionDto.getData(), ConfirmationCompletionData.class);
String negativeId = actionDto.getNegativeId();
updateNegative(negativeId, completionData);
addNegativeScorePolice(negativeId, completionData);
updateApprove(negativeId, completionData.getCompletionComment(), actionDto.getWorkId());
doneWork(actionDto.getWorkId());
}
public void updateNegative(String negativeId, ConfirmationCompletionData completionData) {
LambdaUpdateWrapper<Negative> updateWrapper = new LambdaUpdateWrapper<Negative>()
.eq(Negative::getId, negativeId)
.set(Negative::getProcessingStatus, ProcessingStatusEnum.completed.name())
.set(Negative::getVerifySituation, completionData.getVerifySituation())
.set(Negative::getVerifyFileSituation, completionData.getVerifyFileSituation())
.set(Negative::getCompleteDate, LocalDateTime.now())
.set(Negative::getFlowKey, FlowNodeEnum.COMPLETED.getKey())
.set(Negative::getUpdTime, LocalDateTime.now());
negativeService.update(updateWrapper);
}
public void addNegativeScorePolice(String negativeId, ConfirmationCompletionData completionData) {
String formula = "%s + (1 * %s) + (1 * %s)";
Negative negative = negativeService.getById(negativeId);
List<NegativeScorePolice> scorePolices = completionData.getBlames().stream().map(blame -> {
NegativeScorePolice negativeScorePolice = new NegativeScorePolice()
.setNegativeId(negativeId)
.setIdCode(blame.getBlameIdCode())
.setDiscoveryTime(negative.getDiscoveryTime())
.setIdCode(blame.getBlameIdCode());
String expression = String.format(formula,
blame.getBaseScore(),
NegativeLevelEnum.getScore(blame.getNegativeLevel()),
blame.getFrequencyScore());
negativeScorePolice.setExpression(expression);
double calculate = NumberUtil.calculate(expression);
double score = NumberUtil.roundHalfEven(calculate, 2).doubleValue();
negativeScorePolice.setScore(score);
negativeScorePolice.setCreateTime(LocalDateTime.now());
return negativeScorePolice;
}).toList();
negativeScorePoliceService.saveBatch(scorePolices);
}
public void updateApprove(String negativeId, String comments, Integer workId) {
UserAuth user = UserContextHolder.getCurrentUser();
Negative negative = negativeService.getById(negativeId);
NegativeWork work = workService.getById(workId);
approveService.update(new LambdaUpdateWrapper<NegativeApprove>()
.set(NegativeApprove::getState, ApproveStateEnum.approved.name())
.set(NegativeApprove::getComments, comments)
.set(NegativeApprove::getHandlerDepartId, work.getDepartId())
.set(NegativeApprove::getHandlerDepartName, work.getDepartName())
.set(NegativeApprove::getHandlerUserName, user.getUserName())
.set(NegativeApprove::getHandlerName, user.getNickName())
.set(NegativeApprove::getUpdateTime, LocalDateTime.now())
.eq(NegativeApprove::getNegativeId, negativeId)
.eq(NegativeApprove::getActionKey, negative.getFlowKey()));
}
public void doneWork(Integer workId) {
LambdaUpdateWrapper<NegativeWork> updateWrapper = new LambdaUpdateWrapper<NegativeWork>()
.eq(NegativeWork::getId, workId)
.set(NegativeWork::getStatus, WorkStatusEnum.done.name())
.set(NegativeWork::getUpdateTime, LocalDateTime.now());
workService.update(updateWrapper);
}
}

77
src/main/java/com/biutag/supervision/flow/action/FirstApproveAction.java

@ -1,77 +0,0 @@
package com.biutag.supervision.flow.action;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.biutag.supervision.common.UserContextHolder;
import com.biutag.supervision.constants.enums.ApproveStateEnum;
import com.biutag.supervision.constants.enums.ProcessingStatusEnum;
import com.biutag.supervision.constants.enums.WorkStatusEnum;
import com.biutag.supervision.pojo.dto.ActionDto;
import com.biutag.supervision.pojo.dto.flow.ApproveData;
import com.biutag.supervision.pojo.entity.Negative;
import com.biutag.supervision.pojo.entity.NegativeApprove;
import com.biutag.supervision.pojo.entity.NegativeWork;
import com.biutag.supervision.pojo.model.UserAuth;
import com.biutag.supervision.service.NegativeApproveService;
import com.biutag.supervision.service.NegativeService;
import com.biutag.supervision.service.NegativeWorkService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* 市局审批通过
*/
@RequiredArgsConstructor
@Component
public class FirstApproveAction implements Action {
private final NegativeService negativeService;
private final NegativeWorkService workService;
private final NegativeApproveService approveService;
@Override
public void next(ActionDto actionDto) {
ApproveData approveData = BeanUtil.toBean(actionDto.getData(), ApproveData.class);
updateNegative(actionDto.getNegativeId(), actionDto.getNextFlowKey());
updateApprove(actionDto.getNegativeId(), actionDto.getActionKey(), actionDto.getWorkId(), approveData.getComments());
doneWork(actionDto.getWorkId());
}
public void updateNegative(String negativeId, String nextFlowKey) {
negativeService.update(new LambdaUpdateWrapper<Negative>()
.set(Negative::getFlowKey, nextFlowKey)
.set(Negative::getProcessingStatus, ProcessingStatusEnum.completed.name())
.set(Negative::getCompleteDate, LocalDateTime.now())
.set(Negative::getUpdTime, LocalDateTime.now())
.eq(Negative::getId, negativeId));
}
public void updateApprove(String negativeId, String actionKey, Integer workId, String comments) {
UserAuth user = UserContextHolder.getCurrentUser();
NegativeWork work = workService.getById(workId);
approveService.update(new LambdaUpdateWrapper<NegativeApprove>()
.set(NegativeApprove::getState, ApproveStateEnum.approved.name())
.set(NegativeApprove::getComments, comments)
.set(NegativeApprove::getHandlerDepartId, work.getDepartId())
.set(NegativeApprove::getHandlerDepartName, work.getDepartName())
.set(NegativeApprove::getHandlerUserName, user.getUserName())
.set(NegativeApprove::getHandlerName, user.getNickName())
.set(NegativeApprove::getUpdateTime, LocalDateTime.now())
.eq(NegativeApprove::getNegativeId, negativeId)
.eq(NegativeApprove::getActionKey, actionKey));
}
public void doneWork(Integer workId) {
workService.update(new LambdaUpdateWrapper<NegativeWork>()
.set(NegativeWork::getUpdateTime, LocalDateTime.now())
.set(NegativeWork::getStatus, WorkStatusEnum.done.name())
.eq(NegativeWork::getId, workId));
}
}

3
src/main/java/com/biutag/supervision/flow/action/SaveAction.java

@ -6,7 +6,6 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.biutag.supervision.constants.enums.InspectCaseEnum;
import com.biutag.supervision.constants.enums.IsRectifyEnum;
import com.biutag.supervision.constants.enums.ProcessingStatusEnum;
import com.biutag.supervision.pojo.dto.ActionDto;
import com.biutag.supervision.pojo.dto.flow.VerifyData;
import com.biutag.supervision.pojo.entity.Negative;
@ -75,6 +74,8 @@ public class SaveAction implements Action {
List<NegativeBlame> negativeBlames = verifyData.getBlames().stream().map(item -> {
NegativeBlame negativeBlame = new NegativeBlame();
BeanUtil.copyProperties(item, negativeBlame);
VerifyData.BlameLeader blameLeader = verifyData.getBlameLeaders().stream().filter(leader -> leader.getBlameIdCodes().contains(item.getBlameIdCode())).findFirst().get();
BeanUtil.copyProperties(blameLeader, negativeBlame);
negativeBlame.setNegativeId(negativeId)
.setBlameId(IdUtil.fastSimpleUUID())
.setCrtTime(LocalDateTime.now())

71
src/main/java/com/biutag/supervision/job/DepartJob.java

@ -9,6 +9,8 @@ import com.biutag.supervision.pojo.entity.DepartNegativeRate;
import com.biutag.supervision.pojo.entity.Negative;
import com.biutag.supervision.pojo.entity.SupDepart;
import com.biutag.supervision.service.*;
import com.biutag.supervision.util.ScoreRule;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
@ -16,6 +18,8 @@ import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.List;
/**
@ -61,27 +65,54 @@ public class DepartJob {
}
/**
* 每月1-10号零点更新
* 每月1号零点更新
*/
@Scheduled(cron = "0 0 1 * * ?")
//@Scheduled(cron = "0 0 1 * * ?")
// @PostConstruct
public void updateDepartNegativeRate() {
String month = "2024-10";
List<SupDepart> departs = departService.list(new LambdaQueryWrapper<SupDepart>().eq(SupDepart::getLevel, 3));
LocalDateTime beginTime = LocalDateTime.of(2024, 10, 1, 0, 0, 0);
LocalDateTime endTime = LocalDateTime.of(2024, 10, 31, 0, 0, 0);
List<DepartNegativeRate> list = departs.stream().map(depart -> {
DepartNegativeRate rate = new DepartNegativeRate();
rate.setMonth(month);
rate.setDepartId(depart.getId());
int sum = businessDepartService.list(new LambdaQueryWrapper<BusinessDepart>().between(BusinessDepart::getDate, beginTime, endTime)
.eq(BusinessDepart::getDepartId, depart.getId())).stream().mapToInt(BusinessDepart::getNumber).sum();
long count = negativeService.count(new LambdaQueryWrapper<Negative>().between(Negative::getDiscoveryTime, beginTime, endTime)
.eq(Negative::getInvolveDepartId, depart.getId())
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue())));
rate.setIncidenceRate(sum == 0 ? 0 : NumberUtil.div(count, sum));
return rate;
}).toList();
departNegativeRateService.saveOrUpdateBatch(list);
// 10 派出所
// 11 交警大队
// 13 刑侦大队
// 14 禁毒大队
// 15 治安大队
// 16 人境大队
// 12 其他
List<String> groupIds = List.of("10", "11", "13", "14", "15", "16", "12");
int year = 2024;
int month = 9;
LocalDateTime beginTime = LocalDateTime.of(year, month, 1, 0, 0, 0).minusMonths(2);
LocalDateTime endTime = LocalDateTime.of(year, month, 1, 0, 0, 0).with(TemporalAdjusters.lastDayOfMonth())
.withHour(23).withMinute(59).withSecond(59);
for (String groupId : groupIds) {
List<SupDepart> departs = departService.list(new LambdaQueryWrapper<SupDepart>().eq(SupDepart::getLevel, 3)
.eq(SupDepart::getStatisticsGroupId, groupId));
List<DepartNegativeRate> list = departs.stream().map(depart -> {
DepartNegativeRate rate = new DepartNegativeRate();
rate.setMonth(LocalDate.of(year, month, 1).format(DateTimeFormatter.ofPattern("yyyy-MM")));
rate.setDepartId(depart.getId());
int sum = businessDepartService.list(new LambdaQueryWrapper<BusinessDepart>().between(BusinessDepart::getDate, beginTime, endTime)
.eq(BusinessDepart::getDepartId, depart.getId())).stream().mapToInt(BusinessDepart::getNumber).sum();
long count = negativeService.count(new LambdaQueryWrapper<Negative>().between(Negative::getDiscoveryTime, beginTime, endTime)
.eq(Negative::getInvolveDepartId, depart.getId())
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue())));
rate.setIncidenceRate(sum == 0 ? 0 : NumberUtil.div(count, sum));
return rate;
}).toList();
if (list.isEmpty()) {
continue;
}
// 单位平均问题发生率
Double incidenceRateTied = NumberUtil.div(list.stream().mapToDouble(DepartNegativeRate::getIncidenceRate).sum(), list.size());
list.forEach(item -> {
item.setIncidenceRateTied(incidenceRateTied);
item.setIncidenceFactor(ScoreRule.getIncidenceFactor(item.getIncidenceRate(), incidenceRateTied));
});
departNegativeRateService.remove(new LambdaQueryWrapper<DepartNegativeRate>().eq(DepartNegativeRate::getMonth, month)
.in(DepartNegativeRate::getDepartId, list.stream().map(DepartNegativeRate::getDepartId).toList()));
departNegativeRateService.saveBatch(list);
}
}
}

2
src/main/java/com/biutag/supervision/job/Job.java

@ -84,7 +84,7 @@ public class Job {
public void updateBaseData() {
List<Date> happenTime = new ArrayList<>();
Date start = Date.from(LocalDateTime.now().minusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0).atZone(ZoneId.systemDefault()).toInstant());
Date end = Date.from(LocalDateTime.now().minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0).atZone(ZoneId.systemDefault()).toInstant());
Date end = Date.from(LocalDateTime.now().minusDays(1).withHour(23).withMinute(59).withSecond(59).atZone(ZoneId.systemDefault()).toInstant());
happenTime.add(start);
happenTime.add(end);
businessDepartService.generate(happenTime);

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

@ -0,0 +1,79 @@
package com.biutag.supervision.job;
import cn.hutool.core.util.NumberUtil;
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 org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author wxc
* @date 2024/11/10
*/
@RequiredArgsConstructor
@Component
public class ScoreJob {
private final NegativeScorePoliceService negativeScorePoliceService;
private final NegativeBlameMapper blameMapper;
private final NegativeBlameService blameService;
private final NegativeService negativeService;
private final NegativeProblemRelationService problemRelationService;
private final SupDictContentMapper supDictContentMapper;
@Scheduled(fixedRate = 6000000)
public void updateScore() {
System.out.println("updateScore-------------------------------------------------");
List<NegativeBlame> negativeBlames = blameMapper.selectVerifyTrue();
String formula = "%s + (1 * %s) + (1 * %s)";
List<NegativeScorePolice> scorePolices = negativeBlames.stream().map(blame -> {
Negative negative = negativeService.getById(blame.getNegativeId());
NegativeScorePolice negativeScorePolice = new NegativeScorePolice()
.setNegativeId(blame.getNegativeId())
.setIdCode(blame.getBlameIdCode())
.setDiscoveryTime(negative.getDiscoveryTime())
.setIdCode(blame.getBlameIdCode());
List<NegativeProblemRelation> problems = problemRelationService.list(blame.getNegativeId(), blame.getBlameId());
List<String> codes = problems.stream().map(NegativeProblemRelation::getThreeLevelCode).toList();
if (codes.isEmpty()) {
throw new RuntimeException("数据异常");
}
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(),
NegativeLevelEnum.GENERAL_IMPACT.getScore(),
ScoreRule.getFrequencyScore(frequency));
negativeScorePolice.setExpression(expression);
double calculate = NumberUtil.calculate(expression);
double score = NumberUtil.roundHalfEven(calculate, 2).doubleValue();
negativeScorePolice.setScore(score);
negativeScorePolice.setCreateTime(LocalDateTime.now());
return negativeScorePolice;
}).toList();
if (!scorePolices.isEmpty()) {
negativeScorePoliceService.saveBatch(scorePolices);
}
}
}

14
src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java

@ -4,10 +4,24 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.NegativeBlame;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.List;
public interface NegativeBlameMapper extends BaseMapper<NegativeBlame> {
/**
* 查询时间段内 所有已核实的问题数量
* @param idCode
* @param beginTime
* @param endTime
* @return
*/
@Select("select count(DISTINCT n.id) from negative n left join negative_blame nb on n.id = nb.negativeId left join negative_problem_relation pr on pr.negativeId = n.id and pr.blameId = nb.blameId where n.checkStatus in ('1', '2') and n.discoveryTime BETWEEN #{beginTime} and #{endTime} and nb.blameIdCode = #{idCode} and pr.twoLevelCode = #{twoLevelCode}")
int selectCountByTrue(String idCode, String twoLevelCode, LocalDateTime beginTime, LocalDateTime endTime);
@Select("select DISTINCT nb.* from negative_blame nb left join negative n on nb.negativeId = n.id left join negative_score_police sp on " +
"sp.negative_id = nb.negativeId and sp.id_code = nb.blameIdCode left join negative_problem_relation pr on pr.negativeId = nb.negativeId and pr.blameId = nb.blameId " +
"where n.checkStatus in ('1', '2') and n.processing_status = 'completed' and sp.negative_id is null and pr.threeLevelCode is not null")
List<NegativeBlame> selectVerifyTrue();
}

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

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

9
src/main/java/com/biutag/supervision/mapper/SupDictContentMapper.java

@ -2,7 +2,16 @@ package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.SupDictProblemType;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface SupDictContentMapper extends BaseMapper<SupDictProblemType> {
@Select("select max(pt.score) from negative_problem_relation r left join sup_dict_problem_type pt on r.threeLevelCode = pt.code " +
"where r.negativeId = #{negativeId} and r.blameId = #{blameId}")
Double selectMaxScore(String negativeId, String blameId);
SupDictProblemType selectOneByMaxScore(List<String> codes);
}

3
src/main/java/com/biutag/supervision/pojo/domain/NegativeDetail.java

@ -41,4 +41,7 @@ public class NegativeDetail {
// 最大限时
private Long maxDuration;
// 认定办结
private Boolean confirmationCompletionFlag = false;
}

12
src/main/java/com/biutag/supervision/pojo/domain/NegativeVo.java

@ -1,7 +1,9 @@
package com.biutag.supervision.pojo.domain;
import com.biutag.supervision.pojo.dto.flow.VerifyData;
import com.biutag.supervision.pojo.entity.FileClass;
import com.biutag.supervision.pojo.entity.NegativeFile;
import com.biutag.supervision.pojo.entity.NegativeScorePolice;
import com.biutag.supervision.pojo.entity.NegativeThingFile;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
@ -178,9 +180,17 @@ public class NegativeVo {
// 通报期数
private String reportNumber;
// 核查办理情况
private String verifySituation;
// 佐证材料情况
private String verifyFileSituation;
// 涉及人员
private List<Blame> blames = new ArrayList<>();
private List<VerifyData.BlameLeader> blameLeaders = new ArrayList<>();
// 办结佐证材料
private List<NegativeFile> files = new ArrayList<>();
@ -188,4 +198,6 @@ public class NegativeVo {
private List<FileClass> fileClasses = new ArrayList<>();
private List<NegativeScorePolice> scorePolices = new ArrayList<>();
}

42
src/main/java/com/biutag/supervision/pojo/dto/flow/ConfirmationCompletionData.java

@ -0,0 +1,42 @@
package com.biutag.supervision.pojo.dto.flow;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
/**
* @author wxc
* @date 2024/11/8
*/
@Setter
@Getter
public class ConfirmationCompletionData {
// 核查办理情况
private String verifySituation;
// 佐证材料情况
private String verifyFileSituation;
// 认定办结意见
private String completionComment;
private List<Blame> blames = new ArrayList<>();
@Setter
@Getter
public static class Blame {
private String blameIdCode;
// 严重等级
private String negativeLevel;
private Double baseScore = 0.0;
private Double frequencyScore = 0.0;
}
}

23
src/main/java/com/biutag/supervision/pojo/dto/flow/VerifyData.java

@ -3,6 +3,7 @@ package com.biutag.supervision.pojo.dto.flow;
import com.biutag.supervision.pojo.vo.FileVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
@ -47,8 +48,11 @@ public class VerifyData {
// 涉及单位
private String involveDepartId;
@Size(min = 1)
private List<Blame> blames = new ArrayList<>();
private List<BlameLeader> blameLeaders = new ArrayList<>();
private List<FileVo> files = new ArrayList<>();
@Setter
@ -91,7 +95,6 @@ public class VerifyData {
private String inspectCaseName;
// 督察措施
@NotBlank
private String superviseMeasuresCode;
@ -144,6 +147,19 @@ public class VerifyData {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
private List<LocalDateTime> assistTime = new ArrayList<>();
// 问题类型
private List<Problem> problems;
private String type;
}
@Setter
@Getter
public static class BlameLeader {
private List<String> blameIdCodes = new ArrayList<>();
// 责任领导
@NotBlank
private String leadName;
@ -192,11 +208,6 @@ public class VerifyData {
@NotBlank
private String leadProtectRightsCode;
// 问题类型
private List<Problem> problems;
private String type;
}
@Setter

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

@ -1,7 +1,6 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
@ -9,7 +8,6 @@ import lombok.Setter;
@Getter
public class DepartNegativeRate {
//
private String departId;
// 月份

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

@ -0,0 +1,34 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
@Accessors(chain = true)
@Setter
@Getter
public class NegativeScorePolice {
private String negativeId;
private String idCode;
//
@TableField("score")
private Double score;
// 问题发现时间
@TableField("discovery_time")
private LocalDateTime discoveryTime;
//
@TableField("create_time")
private LocalDateTime createTime;
// 计算公式
private String expression;
}

3
src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java

@ -81,4 +81,7 @@ public class SupDepart {
private Boolean firstHost;
//
private String statisticsGroupId;
}

2
src/main/java/com/biutag/supervision/pojo/model/NegativeWorkModel.java

@ -90,4 +90,6 @@ public class NegativeWorkModel {
// 是否能申请延期 true = 能 false = 不能
private Boolean extensionApplyFlag;
private String checkStatusName;
}

4
src/main/java/com/biutag/supervision/pojo/param/NegativeQueryParam.java

@ -56,4 +56,8 @@ public class NegativeQueryParam extends BasePage {
// 是否延期
private Boolean extensionFlag;
// 排序
private String order;
private String orderProp;
}

65
src/main/java/com/biutag/supervision/pojo/vo/NegativeConfirmationCompletionVo.java

@ -0,0 +1,65 @@
package com.biutag.supervision.pojo.vo;
import com.biutag.supervision.constants.enums.NegativeLevelEnum;
import com.biutag.supervision.pojo.entity.NegativeProblemRelation;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
/**
* 认定办结 赋分
* @author wxc
* @date 2024/11/8
*/
@Setter
@Getter
public class NegativeConfirmationCompletionVo {
private List<NegativeLevel> negativeLevels = List.of(new NegativeLevel(NegativeLevelEnum.GENERAL_IMPACT), new NegativeLevel(NegativeLevelEnum.SERIOUS_IMPACT), new NegativeLevel(NegativeLevelEnum.SIGNIFICANT_IMPACT));
private List<Blame> blames = new ArrayList<>();
@Setter
@Getter
public static class Blame {
private String blameId;
private String blameName;
private String blameIdCode;
private Double baseScore = 0.0;
// 涉及警号
private String blameEmpNo;
// 问题发生频次
private Integer frequency;
// 问题发生频次系数
private Double frequencyScore = 0.0;
// 问题发生率
private Double incidenceRate = 0.0;
// 问题发生率系数
private Double incidenceRateScore = -0.15;
private List<NegativeProblemRelation> problems = new ArrayList<>();
}
@Setter
@Getter
@AllArgsConstructor
public static class NegativeLevel {
private String value;
private Double score;
public NegativeLevel(NegativeLevelEnum levelEnum) {
this.value = levelEnum.getValue();
this.score = levelEnum.getScore();
}
}
}

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

@ -1,5 +1,6 @@
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.pojo.entity.DepartNegativeRate;
import com.biutag.supervision.mapper.DepartNegativeRateMapper;
@ -8,4 +9,8 @@ import org.springframework.stereotype.Service;
@Service
public class DepartNegativeRateService extends ServiceImpl<DepartNegativeRateMapper, DepartNegativeRate> {
public DepartNegativeRate get(String departId, String month) {
return getOne(new LambdaQueryWrapper<DepartNegativeRate>().eq(DepartNegativeRate::getDepartId, departId).eq(DepartNegativeRate::getMonth, month));
}
}

12
src/main/java/com/biutag/supervision/service/NegativeBlameService.java

@ -9,6 +9,7 @@ import com.biutag.supervision.mapper.NegativeBlameMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
@RequiredArgsConstructor
@ -32,4 +33,15 @@ public class NegativeBlameService extends ServiceImpl<NegativeBlameMapper, Negat
return remove(new LambdaQueryWrapper<NegativeBlame>().eq(NegativeBlame::getNegativeId, negativeId));
}
/**
* 查询时间段内 所有已核实的问题数量
* @param idCode
* @param beginTime
* @param endTime
* @return
*/
public int countByTrue(String idCode, String twoLevelCode, LocalDateTime beginTime, LocalDateTime endTime) {
return baseMapper.selectCountByTrue(idCode, twoLevelCode, beginTime, endTime);
}
}

9
src/main/java/com/biutag/supervision/service/NegativeQueryService.java

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.common.UserContextHolder;
import com.biutag.supervision.constants.AppConstants;
import com.biutag.supervision.constants.enums.DepartLevelEnum;
import com.biutag.supervision.constants.enums.OrderEnum;
import com.biutag.supervision.constants.enums.ProcessingStatusEnum;
import com.biutag.supervision.constants.enums.RoleCodeEnum;
import com.biutag.supervision.pojo.entity.Negative;
@ -54,8 +55,7 @@ public class NegativeQueryService {
.eq(StrUtil.isNotBlank(param.getBusinessTypeCode()), Negative::getBusinessTypeCode, param.getBusinessTypeCode())
.eq(StrUtil.isNotBlank(param.getCheckStatus()), Negative::getCheckStatus, param.getCheckStatus())
.in(!param.getCheckStatusList().isEmpty(), Negative::getCheckStatus, param.getCheckStatusList())
.eq(StrUtil.isNotBlank(param.getIsRectifyCode()), Negative::getIsRectifyCode, param.getIsRectifyCode())
.orderByDesc(Negative::getCrtTime);
.eq(StrUtil.isNotBlank(param.getIsRectifyCode()), Negative::getIsRectifyCode, param.getIsRectifyCode());
if (param.getHappenTime().size() == 2) {
queryWrapper.between(Negative::getHappenTime, param.getHappenTime().get(0), param.getHappenTime().get(1));
}
@ -110,6 +110,11 @@ public class NegativeQueryService {
queryWrapper.eq(Negative::getExtensionApplyFlag, true).or().isNull(Negative::getExtensionDays);
}
}
// 排序
queryWrapper.orderBy("crtTime".equals(param.getOrderProp()), OrderEnum.ascending.name().equals(param.getOrder()), Negative::getCrtTime)
.orderBy("discoveryTime".equals(param.getOrderProp()), OrderEnum.ascending.name().equals(param.getOrder()), Negative::getDiscoveryTime);;
// 最后更新时间
queryWrapper.orderByDesc(Negative::getUpdTime);
Page<Negative> page = negativeService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper);
long l = System.currentTimeMillis();
List<NegativeQueryVo> list = page.getRecords().stream().map(item -> {

18
src/main/java/com/biutag/supervision/service/NegativeScorePoliceService.java

@ -0,0 +1,18 @@
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.pojo.entity.NegativeScorePolice;
import com.biutag.supervision.mapper.NegativeScorePoliceMapper;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class NegativeScorePoliceService extends ServiceImpl<NegativeScorePoliceMapper, NegativeScorePolice> {
public List<NegativeScorePolice> list(String negativeId) {
return list(new LambdaQueryWrapper<NegativeScorePolice>().eq(NegativeScorePolice::getNegativeId, negativeId));
}
}

29
src/main/java/com/biutag/supervision/service/NegativeService.java

@ -20,6 +20,7 @@ import com.biutag.supervision.pojo.domain.NegativeVo;
import com.biutag.supervision.pojo.dto.ActionDto;
import com.biutag.supervision.pojo.dto.NegativeDto;
import com.biutag.supervision.pojo.dto.flow.FirstDistributeData;
import com.biutag.supervision.pojo.dto.flow.VerifyData;
import com.biutag.supervision.pojo.dto.jwdc.NegativeApiDto;
import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.util.JSON;
@ -66,9 +67,11 @@ public class NegativeService extends ServiceImpl<NegativeMapper, Negative> {
private final FileClassService fileClassService;
private final NegativeScorePoliceService negativeScorePoliceService;
public NegativeDetail get(String id, Integer workId) {
Negative negative = getById(id);
List<Blame> blameVos = blameService.list(id);
List<NegativeHistory> flows = negativeHistoryService.listByNegativeId(id);
AtomicReference<String> flowKey = new AtomicReference<>(negative.getFlowKey());
List<NegativeFile> files = fileService.list(id);
@ -85,7 +88,21 @@ public class NegativeService extends ServiceImpl<NegativeMapper, Negative> {
String involveProblemLables = JSON.readValueForList(negative.getInvolveProblem(), Map.class).stream().map(item -> String.valueOf(item.get("dictLabel"))).collect(Collectors.joining(" "));
vo.setInvolveProblemLables(involveProblemLables);
}
List<Blame> blameVos = blameService.list(id);
vo.setBlames(blameVos);
if (!blameVos.isEmpty()) {
List<VerifyData.BlameLeader> blameLeaders = blameVos.stream().map(Blame::getLeadIdCode).filter(StrUtil::isNotBlank).collect(Collectors.toSet())
.stream().map(leaderIdCode -> {
VerifyData.BlameLeader blameLeader = new VerifyData.BlameLeader();
List<Blame> blames = blameVos.stream().filter(blameObj -> leaderIdCode.equals(blameObj.getLeadIdCode())).toList();
// 取第一个
Blame blame = blames.get(0);
BeanUtil.copyProperties(blame, blameLeader);
blameLeader.setBlameIdCodes(blames.stream().map(Blame::getBlameIdCode).toList());
return blameLeader;
}).toList();
vo.setBlameLeaders(blameLeaders);
}
vo.setThingFiles(thingFiles);
vo.setFiles(files);
@ -126,6 +143,16 @@ public class NegativeService extends ServiceImpl<NegativeMapper, Negative> {
negative.getExtensionDays(),
negative.getFlowKey()));
}
// 判断当前是否 是认定办结环节
if (Objects.nonNull(workId)) {
Boolean confirmationCompletionFlag = (ApprovalFlowEnum.SECOND_APPROVAL.getValue().equals(negative.getApprovalFlow()) && FlowNodeEnum.SECOND_APPROVE.getKey().equals(negative.getFlowKey()))
|| (ApprovalFlowEnum.THREE_APPROVAL.getValue().equals(negative.getApprovalFlow()) && FlowNodeEnum.FIRST_APPROVE.getKey().equals(negative.getFlowKey()));
detail.setConfirmationCompletionFlag(confirmationCompletionFlag);
}
if (ProcessingStatusEnum.completed.name().equals(negative.getProcessingStatus())) {
List<NegativeScorePolice> scorePolices = negativeScorePoliceService.list(id);
vo.setScorePolices(scorePolices);
}
return detail;
}

17
src/main/java/com/biutag/supervision/service/SupDepartService.java

@ -35,19 +35,13 @@ public class SupDepartService extends ServiceImpl<SupDepartMapper, SupDepart> {
return page(Page.of(param.getCurrent(), param.getSize()), queryWrapper);
}
public List<SupDepart> listByEnabled() {
public List<SupDepart> listEnabledLevel3() {
return list(new LambdaQueryWrapper<SupDepart>()
.notIn(SupDepart::getLevel, List.of(4, 5))
.eq(SupDepart::getStatus, StatusEnum.ENABLE.getValue())
.orderByAsc(SupDepart::getOrderNo));
}
public List<SupDepart> listAllByEnabled() {
return list(new LambdaQueryWrapper<SupDepart>()
.eq(SupDepart::getStatus, StatusEnum.ENABLE.getValue())
.orderByAsc(SupDepart::getOrderNo));
}
public List<SupDepart> listByLevel(List<Integer> levels) {
return list(new LambdaQueryWrapper<SupDepart>().in(SupDepart::getLevel, levels).eq(SupDepart::getStatus, StatusEnum.ENABLE.getValue()).orderByAsc(SupDepart::getOrderNo));
}
@ -67,7 +61,7 @@ public class SupDepartService extends ServiceImpl<SupDepartMapper, SupDepart> {
return nodes;
}
private void getAllNodeRecursive(List<String> departIds, List<DepartTree> treeList, List<DepartTree> nodes) {
public void getAllNodeRecursive(List<String> departIds, List<DepartTree> treeList, List<DepartTree> nodes) {
treeList.forEach(item -> {
if (departIds.contains(item.getId())) {
getAllNodeRecursive(item, nodes);
@ -109,7 +103,8 @@ public class SupDepartService extends ServiceImpl<SupDepartMapper, SupDepart> {
public List<DepartTree> buildTreeAll() {
// 所有有效的数据
List<SupDepart> departs = listAllByEnabled();
List<SupDepart> departs = list(new LambdaQueryWrapper<SupDepart>()
.orderByAsc(SupDepart::getOrderNo));
return buildTreeAll(departs);
}
@ -137,7 +132,7 @@ public class SupDepartService extends ServiceImpl<SupDepartMapper, SupDepart> {
* @return
*/
public List<DepartTree> buildTreeByFirstHost() {
List<SupDepart> departs = listByEnabled();
List<SupDepart> departs = listEnabledLevel3();
Map<String, List<DepartTree>> childMap = new HashMap<>();
List<DepartTree> tree = new ArrayList<>();
for (SupDepart depart : departs) {
@ -161,7 +156,7 @@ public class SupDepartService extends ServiceImpl<SupDepartMapper, SupDepart> {
*/
public List<DepartTree> buildTreeByAuth() {
// 所有有效的数据
List<SupDepart> departs = listByEnabled();
List<SupDepart> departs = listEnabledLevel3();
return buildTreeByAuth(departs);
}

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

@ -65,7 +65,7 @@ public class SupPoliceService extends ServiceImpl<SupPoliceMapper, SupPolice> {
public List<SupPolice> listLeaderByDepartId(String departId) {
List<String> departIds = departService.getAllNodeIds(List.of(departId));
return list(new LambdaQueryWrapper<SupPolice>().in(SupPolice::getOrgId, departIds).isNotNull(SupPolice::getPhone));
return list(new LambdaQueryWrapper<SupPolice>().in(SupPolice::getOrgId, departIds).isNotNull(SupPolice::getPhone).orderByDesc(SupPolice::getPosition));
}
public Boolean exists(String departId) {

33
src/main/java/com/biutag/supervision/util/ScoreRule.java

@ -0,0 +1,33 @@
package com.biutag.supervision.util;
/**
* @author wxc
* @date 2024/11/9
*/
public class ScoreRule {
public static Double getFrequencyScore(Integer frequency) {
if (frequency == 2) {
return 0.1;
}
if (frequency >= 3) {
return 0.3;
}
return 0.0;
}
public static Double getIncidenceFactor(Double incidenceRate, Double incidenceRateTied) {
double b = incidenceRateTied * 0.8;
double b1 = incidenceRateTied * 1.2;
// 中等问题发生率 :平均问题发生率 × 0.8 < 问题发生率 ≤ 平均问题发生率 × 1.2
if (b < incidenceRate && incidenceRate <= b1) {
return 0.0;
}
// 高问题发生率 问题发生率 > 平均问题发生率 × 1.2
if (incidenceRate > b1) {
return 0.15;
}
return -0.15;
}
}

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参数,支持多个

5
src/main/resources/mapper/NegativeWorkMapper.xml

@ -5,10 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.biutag.supervision.mapper.NegativeWorkMapper">
<select id="queryPage" resultType="com.biutag.supervision.pojo.model.NegativeWorkModel">
select w.id, w.negative_id, w.depart_id work_depart_id, n.originId, n.happenTime, n.discoveryTime, n.problemSources, n.thingDesc, n.contactPhone,
n.responderName, n.businessTypeCode, n.businessTypeName, n.policeTypeName, n.policeType, n.involveDepartName, n.involveDepartId, n.processing_status,
n.flow_key, n.first_distribute_time, n.max_sign_duration, n.max_handle_duration, n.extension_days,
n.handle_second_depart_id, n.handle_second_depart_name, n.handle_three_depart_id, n.handle_three_depart_name, n.involveProblem, n.extension_apply_flag
select w.id, w.negative_id, w.depart_id work_depart_id, n.*
from negative_work w
left join negative n on w.negative_id = n.id
${ew.getCustomSqlSegment}

15
src/main/resources/mapper/SupDictContentMapper.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.biutag.supervision.mapper.SupDictContentMapper">
<select id="selectOneByMaxScore">
select * from sup_dict_problem_type where code in
<foreach collection="codes" item="code" open="(" separator="," close=")">
#{ code }
</foreach>
order by score desc LIMIT 1
</select>
</mapper>

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_negative_rate";
String tableName = "negative_score_police";
String tableSchema = "negative";
boolean genMapper = true;
boolean genService = true;

Loading…
Cancel
Save