From 386a470e13ac2478f09cab39bc5c1086433df82b Mon Sep 17 00:00:00 2001 From: wxc <191104855@qq.com> Date: Sun, 10 Nov 2024 18:32:19 +0800 Subject: [PATCH] =?UTF-8?q?fit:=20=E8=AE=A4=E5=AE=9A=E5=8A=9E=E7=BB=93?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E6=89=93=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/1109.sql | 19 ++++ .../constants/enums/FlowNodeEnum.java | 2 +- .../constants/enums/NegativeLevelEnum.java | 34 ++++++ .../constants/enums/OrderEnum.java | 12 ++ .../ProfilePoliceController.java | 1 - .../controller/system/DepartController.java | 9 +- .../controller/work/NegativeController.java | 62 ++++++++-- .../flow/action/ApplyCompletionAction.java | 3 + .../action/ConfirmationCompletionAction.java | 106 ++++++++++++++++++ .../flow/action/FirstApproveAction.java | 77 ------------- .../supervision/flow/action/SaveAction.java | 3 +- .../com/biutag/supervision/job/DepartJob.java | 71 ++++++++---- .../java/com/biutag/supervision/job/Job.java | 2 +- .../com/biutag/supervision/job/ScoreJob.java | 79 +++++++++++++ .../mapper/NegativeBlameMapper.java | 14 +++ .../mapper/NegativeScorePoliceMapper.java | 8 ++ .../mapper/SupDictContentMapper.java | 9 ++ .../pojo/domain/NegativeDetail.java | 3 + .../supervision/pojo/domain/NegativeVo.java | 12 ++ .../dto/flow/ConfirmationCompletionData.java | 42 +++++++ .../supervision/pojo/dto/flow/VerifyData.java | 23 +++- .../pojo/entity/DepartNegativeRate.java | 2 - .../pojo/entity/NegativeScorePolice.java | 34 ++++++ .../supervision/pojo/entity/SupDepart.java | 3 + .../pojo/model/NegativeWorkModel.java | 2 + .../pojo/param/NegativeQueryParam.java | 4 + .../vo/NegativeConfirmationCompletionVo.java | 65 +++++++++++ .../service/DepartNegativeRateService.java | 5 + .../service/NegativeBlameService.java | 12 ++ .../service/NegativeQueryService.java | 9 +- .../service/NegativeScorePoliceService.java | 18 +++ .../supervision/service/NegativeService.java | 29 ++++- .../supervision/service/SupDepartService.java | 17 +-- .../supervision/service/SupPoliceService.java | 2 +- .../biutag/supervision/util/ScoreRule.java | 33 ++++++ src/main/resources/application-local.yml | 6 +- .../resources/mapper/NegativeWorkMapper.xml | 5 +- .../resources/mapper/SupDictContentMapper.xml | 15 +++ .../supervision/tools/GenCodeTests.java | 2 +- 39 files changed, 714 insertions(+), 140 deletions(-) create mode 100644 sql/1109.sql create mode 100644 src/main/java/com/biutag/supervision/constants/enums/NegativeLevelEnum.java create mode 100644 src/main/java/com/biutag/supervision/constants/enums/OrderEnum.java create mode 100644 src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java delete mode 100644 src/main/java/com/biutag/supervision/flow/action/FirstApproveAction.java create mode 100644 src/main/java/com/biutag/supervision/job/ScoreJob.java create mode 100644 src/main/java/com/biutag/supervision/mapper/NegativeScorePoliceMapper.java create mode 100644 src/main/java/com/biutag/supervision/pojo/dto/flow/ConfirmationCompletionData.java create mode 100644 src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java create mode 100644 src/main/java/com/biutag/supervision/pojo/vo/NegativeConfirmationCompletionVo.java create mode 100644 src/main/java/com/biutag/supervision/service/NegativeScorePoliceService.java create mode 100644 src/main/java/com/biutag/supervision/util/ScoreRule.java create mode 100644 src/main/resources/mapper/SupDictContentMapper.xml diff --git a/sql/1109.sql b/sql/1109.sql new file mode 100644 index 0000000..95ba330 --- /dev/null +++ b/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; \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/constants/enums/FlowNodeEnum.java b/src/main/java/com/biutag/supervision/constants/enums/FlowNodeEnum.java index 3ca8ecf..b8b61c9 100644 --- a/src/main/java/com/biutag/supervision/constants/enums/FlowNodeEnum.java +++ b/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"), diff --git a/src/main/java/com/biutag/supervision/constants/enums/NegativeLevelEnum.java b/src/main/java/com/biutag/supervision/constants/enums/NegativeLevelEnum.java new file mode 100644 index 0000000..4b05743 --- /dev/null +++ b/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; + } + +} diff --git a/src/main/java/com/biutag/supervision/constants/enums/OrderEnum.java b/src/main/java/com/biutag/supervision/constants/enums/OrderEnum.java new file mode 100644 index 0000000..3576baf --- /dev/null +++ b/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; +} diff --git a/src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java b/src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java index 375326a..481e3f2 100644 --- a/src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfilePoliceController.java +++ b/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> list(DepartPoliceQueryParam param) { Date beginTime = DateUtil.parse("1949", "YYYY"); diff --git a/src/main/java/com/biutag/supervision/controller/system/DepartController.java b/src/main/java/com/biutag/supervision/controller/system/DepartController.java index 031e174..1785a38 100644 --- a/src/main/java/com/biutag/supervision/controller/system/DepartController.java +++ b/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 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> treeAll() { + return Result.success(departService.buildTreeAll()); + } + @GetMapping("second") public Result> seconds() { List supDeparts = departService.listByLevel(List.of(DepartLevelEnum.SECOND_CATEGORY.getValue(), DepartLevelEnum.SECOND.getValue())); diff --git a/src/main/java/com/biutag/supervision/controller/work/NegativeController.java b/src/main/java/com/biutag/supervision/controller/work/NegativeController.java index 54dd3c1..4ae2de4 100644 --- a/src/main/java/com/biutag/supervision/controller/work/NegativeController.java +++ b/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> 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 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 blames = blameService.list(id).stream().map(blame -> { + List problems = negativeProblemRelationService.list(id, blame.getBlameId()); + List 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); + } + } diff --git a/src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java b/src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java index 9f62f95..60f8b11 100644 --- a/src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/ApplyCompletionAction.java @@ -84,6 +84,9 @@ public class ApplyCompletionAction implements Action { List 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) diff --git a/src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java b/src/main/java/com/biutag/supervision/flow/action/ConfirmationCompletionAction.java new file mode 100644 index 0000000..6e4a503 --- /dev/null +++ b/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 updateWrapper = new LambdaUpdateWrapper() + .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 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() + .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 updateWrapper = new LambdaUpdateWrapper() + .eq(NegativeWork::getId, workId) + .set(NegativeWork::getStatus, WorkStatusEnum.done.name()) + .set(NegativeWork::getUpdateTime, LocalDateTime.now()); + workService.update(updateWrapper); + } + +} diff --git a/src/main/java/com/biutag/supervision/flow/action/FirstApproveAction.java b/src/main/java/com/biutag/supervision/flow/action/FirstApproveAction.java deleted file mode 100644 index cbef37c..0000000 --- a/src/main/java/com/biutag/supervision/flow/action/FirstApproveAction.java +++ /dev/null @@ -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() - .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() - .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() - .set(NegativeWork::getUpdateTime, LocalDateTime.now()) - .set(NegativeWork::getStatus, WorkStatusEnum.done.name()) - .eq(NegativeWork::getId, workId)); - } - - -} \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/flow/action/SaveAction.java b/src/main/java/com/biutag/supervision/flow/action/SaveAction.java index 92aedb2..7a14eb8 100644 --- a/src/main/java/com/biutag/supervision/flow/action/SaveAction.java +++ b/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 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()) diff --git a/src/main/java/com/biutag/supervision/job/DepartJob.java b/src/main/java/com/biutag/supervision/job/DepartJob.java index 60419de..170ffdf 100644 --- a/src/main/java/com/biutag/supervision/job/DepartJob.java +++ b/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 departs = departService.list(new LambdaQueryWrapper().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 list = departs.stream().map(depart -> { - DepartNegativeRate rate = new DepartNegativeRate(); - rate.setMonth(month); - rate.setDepartId(depart.getId()); - - int sum = businessDepartService.list(new LambdaQueryWrapper().between(BusinessDepart::getDate, beginTime, endTime) - .eq(BusinessDepart::getDepartId, depart.getId())).stream().mapToInt(BusinessDepart::getNumber).sum(); - long count = negativeService.count(new LambdaQueryWrapper().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 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 departs = departService.list(new LambdaQueryWrapper().eq(SupDepart::getLevel, 3) + .eq(SupDepart::getStatisticsGroupId, groupId)); + List 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().between(BusinessDepart::getDate, beginTime, endTime) + .eq(BusinessDepart::getDepartId, depart.getId())).stream().mapToInt(BusinessDepart::getNumber).sum(); + long count = negativeService.count(new LambdaQueryWrapper().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().eq(DepartNegativeRate::getMonth, month) + .in(DepartNegativeRate::getDepartId, list.stream().map(DepartNegativeRate::getDepartId).toList())); + departNegativeRateService.saveBatch(list); + } + + } + } diff --git a/src/main/java/com/biutag/supervision/job/Job.java b/src/main/java/com/biutag/supervision/job/Job.java index f4a8816..c5f0c99 100644 --- a/src/main/java/com/biutag/supervision/job/Job.java +++ b/src/main/java/com/biutag/supervision/job/Job.java @@ -84,7 +84,7 @@ public class Job { public void updateBaseData() { List 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); diff --git a/src/main/java/com/biutag/supervision/job/ScoreJob.java b/src/main/java/com/biutag/supervision/job/ScoreJob.java new file mode 100644 index 0000000..846d4ff --- /dev/null +++ b/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 negativeBlames = blameMapper.selectVerifyTrue(); + String formula = "%s + (1 * %s) + (1 * %s)"; + List 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 problems = problemRelationService.list(blame.getNegativeId(), blame.getBlameId()); + List 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); + } + + } + +} diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java index d5b38f6..37715d9 100644 --- a/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java +++ b/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 { + /** + * 查询时间段内 所有已核实的问题数量 + * @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 selectVerifyTrue(); } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeScorePoliceMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeScorePoliceMapper.java new file mode 100644 index 0000000..3d89117 --- /dev/null +++ b/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 { + +} \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/mapper/SupDictContentMapper.java b/src/main/java/com/biutag/supervision/mapper/SupDictContentMapper.java index 4df70ab..a976b9a 100644 --- a/src/main/java/com/biutag/supervision/mapper/SupDictContentMapper.java +++ b/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 { + @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 codes); + } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/domain/NegativeDetail.java b/src/main/java/com/biutag/supervision/pojo/domain/NegativeDetail.java index 285fe50..7b43b21 100644 --- a/src/main/java/com/biutag/supervision/pojo/domain/NegativeDetail.java +++ b/src/main/java/com/biutag/supervision/pojo/domain/NegativeDetail.java @@ -41,4 +41,7 @@ public class NegativeDetail { // 最大限时 private Long maxDuration; + // 认定办结 + private Boolean confirmationCompletionFlag = false; + } diff --git a/src/main/java/com/biutag/supervision/pojo/domain/NegativeVo.java b/src/main/java/com/biutag/supervision/pojo/domain/NegativeVo.java index 66da6da..2737e53 100644 --- a/src/main/java/com/biutag/supervision/pojo/domain/NegativeVo.java +++ b/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 blames = new ArrayList<>(); + private List blameLeaders = new ArrayList<>(); + // 办结佐证材料 private List files = new ArrayList<>(); @@ -188,4 +198,6 @@ public class NegativeVo { private List fileClasses = new ArrayList<>(); + private List scorePolices = new ArrayList<>(); + } diff --git a/src/main/java/com/biutag/supervision/pojo/dto/flow/ConfirmationCompletionData.java b/src/main/java/com/biutag/supervision/pojo/dto/flow/ConfirmationCompletionData.java new file mode 100644 index 0000000..5b751b4 --- /dev/null +++ b/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 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; + + } + +} diff --git a/src/main/java/com/biutag/supervision/pojo/dto/flow/VerifyData.java b/src/main/java/com/biutag/supervision/pojo/dto/flow/VerifyData.java index ad30aff..cb7b7e0 100644 --- a/src/main/java/com/biutag/supervision/pojo/dto/flow/VerifyData.java +++ b/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 blames = new ArrayList<>(); + private List blameLeaders = new ArrayList<>(); + private List 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 assistTime = new ArrayList<>(); + // 问题类型 + private List problems; + + private String type; + + } + + @Setter + @Getter + public static class BlameLeader { + + private List blameIdCodes = new ArrayList<>(); + // 责任领导 @NotBlank private String leadName; @@ -192,11 +208,6 @@ public class VerifyData { @NotBlank private String leadProtectRightsCode; - // 问题类型 - private List problems; - - private String type; - } @Setter diff --git a/src/main/java/com/biutag/supervision/pojo/entity/DepartNegativeRate.java b/src/main/java/com/biutag/supervision/pojo/entity/DepartNegativeRate.java index 64ffeea..eb2c711 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/DepartNegativeRate.java +++ b/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; // 月份 diff --git a/src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java b/src/main/java/com/biutag/supervision/pojo/entity/NegativeScorePolice.java new file mode 100644 index 0000000..623bdad --- /dev/null +++ b/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; + +} \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java b/src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java index a2bc7c0..58532fa 100644 --- a/src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java +++ b/src/main/java/com/biutag/supervision/pojo/entity/SupDepart.java @@ -81,4 +81,7 @@ public class SupDepart { private Boolean firstHost; + // + private String statisticsGroupId; + } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/model/NegativeWorkModel.java b/src/main/java/com/biutag/supervision/pojo/model/NegativeWorkModel.java index 2052e39..55b10a7 100644 --- a/src/main/java/com/biutag/supervision/pojo/model/NegativeWorkModel.java +++ b/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; + } diff --git a/src/main/java/com/biutag/supervision/pojo/param/NegativeQueryParam.java b/src/main/java/com/biutag/supervision/pojo/param/NegativeQueryParam.java index 3b2c3ac..92135e7 100644 --- a/src/main/java/com/biutag/supervision/pojo/param/NegativeQueryParam.java +++ b/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; + } diff --git a/src/main/java/com/biutag/supervision/pojo/vo/NegativeConfirmationCompletionVo.java b/src/main/java/com/biutag/supervision/pojo/vo/NegativeConfirmationCompletionVo.java new file mode 100644 index 0000000..39c9a0b --- /dev/null +++ b/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 negativeLevels = List.of(new NegativeLevel(NegativeLevelEnum.GENERAL_IMPACT), new NegativeLevel(NegativeLevelEnum.SERIOUS_IMPACT), new NegativeLevel(NegativeLevelEnum.SIGNIFICANT_IMPACT)); + + private List 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 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(); + } + } +} diff --git a/src/main/java/com/biutag/supervision/service/DepartNegativeRateService.java b/src/main/java/com/biutag/supervision/service/DepartNegativeRateService.java index c60a1ff..6164484 100644 --- a/src/main/java/com/biutag/supervision/service/DepartNegativeRateService.java +++ b/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 { + public DepartNegativeRate get(String departId, String month) { + return getOne(new LambdaQueryWrapper().eq(DepartNegativeRate::getDepartId, departId).eq(DepartNegativeRate::getMonth, month)); + } + } diff --git a/src/main/java/com/biutag/supervision/service/NegativeBlameService.java b/src/main/java/com/biutag/supervision/service/NegativeBlameService.java index cfb94e5..0508303 100644 --- a/src/main/java/com/biutag/supervision/service/NegativeBlameService.java +++ b/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().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); + } + } diff --git a/src/main/java/com/biutag/supervision/service/NegativeQueryService.java b/src/main/java/com/biutag/supervision/service/NegativeQueryService.java index 9f750c1..6c26cfa 100644 --- a/src/main/java/com/biutag/supervision/service/NegativeQueryService.java +++ b/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 page = negativeService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper); long l = System.currentTimeMillis(); List list = page.getRecords().stream().map(item -> { diff --git a/src/main/java/com/biutag/supervision/service/NegativeScorePoliceService.java b/src/main/java/com/biutag/supervision/service/NegativeScorePoliceService.java new file mode 100644 index 0000000..bd214cb --- /dev/null +++ b/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 { + + public List list(String negativeId) { + return list(new LambdaQueryWrapper().eq(NegativeScorePolice::getNegativeId, negativeId)); + } + +} diff --git a/src/main/java/com/biutag/supervision/service/NegativeService.java b/src/main/java/com/biutag/supervision/service/NegativeService.java index 796b903..6e28a3c 100644 --- a/src/main/java/com/biutag/supervision/service/NegativeService.java +++ b/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 { private final FileClassService fileClassService; + private final NegativeScorePoliceService negativeScorePoliceService; + public NegativeDetail get(String id, Integer workId) { Negative negative = getById(id); - List blameVos = blameService.list(id); + List flows = negativeHistoryService.listByNegativeId(id); AtomicReference flowKey = new AtomicReference<>(negative.getFlowKey()); List files = fileService.list(id); @@ -85,7 +88,21 @@ public class NegativeService extends ServiceImpl { String involveProblemLables = JSON.readValueForList(negative.getInvolveProblem(), Map.class).stream().map(item -> String.valueOf(item.get("dictLabel"))).collect(Collectors.joining(" ")); vo.setInvolveProblemLables(involveProblemLables); } + List blameVos = blameService.list(id); vo.setBlames(blameVos); + if (!blameVos.isEmpty()) { + List blameLeaders = blameVos.stream().map(Blame::getLeadIdCode).filter(StrUtil::isNotBlank).collect(Collectors.toSet()) + .stream().map(leaderIdCode -> { + VerifyData.BlameLeader blameLeader = new VerifyData.BlameLeader(); + List 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 { 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 scorePolices = negativeScorePoliceService.list(id); + vo.setScorePolices(scorePolices); + } return detail; } diff --git a/src/main/java/com/biutag/supervision/service/SupDepartService.java b/src/main/java/com/biutag/supervision/service/SupDepartService.java index 8905553..0dfc066 100644 --- a/src/main/java/com/biutag/supervision/service/SupDepartService.java +++ b/src/main/java/com/biutag/supervision/service/SupDepartService.java @@ -35,19 +35,13 @@ public class SupDepartService extends ServiceImpl { return page(Page.of(param.getCurrent(), param.getSize()), queryWrapper); } - public List listByEnabled() { + public List listEnabledLevel3() { return list(new LambdaQueryWrapper() .notIn(SupDepart::getLevel, List.of(4, 5)) .eq(SupDepart::getStatus, StatusEnum.ENABLE.getValue()) .orderByAsc(SupDepart::getOrderNo)); } - public List listAllByEnabled() { - return list(new LambdaQueryWrapper() - .eq(SupDepart::getStatus, StatusEnum.ENABLE.getValue()) - .orderByAsc(SupDepart::getOrderNo)); - } - public List listByLevel(List levels) { return list(new LambdaQueryWrapper().in(SupDepart::getLevel, levels).eq(SupDepart::getStatus, StatusEnum.ENABLE.getValue()).orderByAsc(SupDepart::getOrderNo)); } @@ -67,7 +61,7 @@ public class SupDepartService extends ServiceImpl { return nodes; } - private void getAllNodeRecursive(List departIds, List treeList, List nodes) { + public void getAllNodeRecursive(List departIds, List treeList, List nodes) { treeList.forEach(item -> { if (departIds.contains(item.getId())) { getAllNodeRecursive(item, nodes); @@ -109,7 +103,8 @@ public class SupDepartService extends ServiceImpl { public List buildTreeAll() { // 所有有效的数据 - List departs = listAllByEnabled(); + List departs = list(new LambdaQueryWrapper() + .orderByAsc(SupDepart::getOrderNo)); return buildTreeAll(departs); } @@ -137,7 +132,7 @@ public class SupDepartService extends ServiceImpl { * @return */ public List buildTreeByFirstHost() { - List departs = listByEnabled(); + List departs = listEnabledLevel3(); Map> childMap = new HashMap<>(); List tree = new ArrayList<>(); for (SupDepart depart : departs) { @@ -161,7 +156,7 @@ public class SupDepartService extends ServiceImpl { */ public List buildTreeByAuth() { // 所有有效的数据 - List departs = listByEnabled(); + List departs = listEnabledLevel3(); return buildTreeByAuth(departs); } diff --git a/src/main/java/com/biutag/supervision/service/SupPoliceService.java b/src/main/java/com/biutag/supervision/service/SupPoliceService.java index 333bf19..556d8b5 100644 --- a/src/main/java/com/biutag/supervision/service/SupPoliceService.java +++ b/src/main/java/com/biutag/supervision/service/SupPoliceService.java @@ -65,7 +65,7 @@ public class SupPoliceService extends ServiceImpl { public List listLeaderByDepartId(String departId) { List departIds = departService.getAllNodeIds(List.of(departId)); - return list(new LambdaQueryWrapper().in(SupPolice::getOrgId, departIds).isNotNull(SupPolice::getPhone)); + return list(new LambdaQueryWrapper().in(SupPolice::getOrgId, departIds).isNotNull(SupPolice::getPhone).orderByDesc(SupPolice::getPosition)); } public Boolean exists(String departId) { diff --git a/src/main/java/com/biutag/supervision/util/ScoreRule.java b/src/main/java/com/biutag/supervision/util/ScoreRule.java new file mode 100644 index 0000000..a07d83e --- /dev/null +++ b/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; + } + +} diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 7c967c0..506acbc 100644 --- a/src/main/resources/application-local.yml +++ b/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参数,支持多个 diff --git a/src/main/resources/mapper/NegativeWorkMapper.xml b/src/main/resources/mapper/NegativeWorkMapper.xml index fbbbccf..dc7df38 100644 --- a/src/main/resources/mapper/NegativeWorkMapper.xml +++ b/src/main/resources/mapper/NegativeWorkMapper.xml @@ -5,10 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + select * from sup_dict_problem_type where code in + + #{ code } + + order by score desc LIMIT 1 + + + \ No newline at end of file diff --git a/src/test/java/com/biutag/supervision/tools/GenCodeTests.java b/src/test/java/com/biutag/supervision/tools/GenCodeTests.java index b542460..82c9f21 100644 --- a/src/test/java/com/biutag/supervision/tools/GenCodeTests.java +++ b/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;