diff --git a/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionDefendAddExe.java b/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionDefendAddExe.java index 6418bc8..3cef6af 100644 --- a/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionDefendAddExe.java +++ b/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionDefendAddExe.java @@ -67,6 +67,9 @@ public class SafetyEnvironmentalInspectionDefendAddExe { BeanUtils.copyProperties(cmd, safetyEnvironmentalInspectionDefendE); safetyEnvironmentalInspectionDefendE.init(); SafetyEnvironmentalInspectionDO inspectionDO = safetyEnvironmentalInspectionRepository.getByInspectionId(cmd.getInspectionId()); + if (inspectionDO == null) { + throw new BizException("检查任务不存在"); + } Integer type = 3; if (inspectionDO != null && !ObjectUtils.isEmpty(inspectionDO.getDefendFlag()) && inspectionDO.getDefendFlag() == 1){ type = 6; @@ -89,6 +92,9 @@ public class SafetyEnvironmentalInspectionDefendAddExe { // 增加待申辩人 // 查找发起人,作为申辩信息审核人 List initiator = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), 1); + if (initiator == null || initiator.isEmpty()) { + throw new BizException("未找到检查发起人"); + } SafetyEnvironmentalInspectionUserE inspectionUserE = new SafetyEnvironmentalInspectionUserE(); inspectionUserE.init(cmd.getInspectionId(), 0, 4, initiator.get(0).getCorpId(), initiator.get(0).getDepartmentId(), initiator.get(0).getUserId()); safetyEnvironmentalInspectionUserGateway.add(inspectionUserE); @@ -132,6 +138,9 @@ public class SafetyEnvironmentalInspectionDefendAddExe { //TODO 站内信 给发起人发归档信息 // 查找发起人,作为归档人 List initiator = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), 1); + if (initiator == null || initiator.isEmpty()) { + throw new BizException("未找到检查发起人"); + } Map sendParamsPigeonhole = new HashMap<>(); sendParamsPigeonhole.put("checkTitle", inspectionDO.getProjectName()); messageNoticeExe.messageNotice(initiator.get(0).getUserId(), messageTemplateConfig.getCheckInitiatorApplyAcceptancePass(), sendParamsPigeonhole); @@ -139,6 +148,9 @@ public class SafetyEnvironmentalInspectionDefendAddExe { } // 完成当前确认人的待办 List affirmList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), type, ssoUser.getUserId()); + if (affirmList == null || affirmList.isEmpty()) { + throw new BizException("当前用户无可确认的检查记录"); + } messageNoticeExe.sendMessageCompleteEvent(affirmList.get(0).getId()); } } diff --git a/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUpdateExe.java b/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUpdateExe.java index 5af01f7..00c7aef 100644 --- a/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUpdateExe.java +++ b/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUpdateExe.java @@ -270,7 +270,9 @@ public class SafetyEnvironmentalInspectionUpdateExe { } List userList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), 1); // 完成重新发起待办 - messageNoticeExe.sendMessageCompleteEvent(userList.get(0).getId()); + if (userList != null && !userList.isEmpty()) { + messageNoticeExe.sendMessageCompleteEvent(userList.get(0).getId()); + } } } catch (Exception e) { log.error("报错了", e); @@ -441,7 +443,9 @@ public class SafetyEnvironmentalInspectionUpdateExe { } List userList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), 4); // 完成申辩待办 - messageNoticeExe.sendMessageCompleteEvent(userList.get(0).getId()); + if (userList != null && !userList.isEmpty()) { + messageNoticeExe.sendMessageCompleteEvent(userList.get(0).getId()); + } } catch (Exception e) { log.error("报错了", e); throw new RuntimeException(e); @@ -504,12 +508,16 @@ public class SafetyEnvironmentalInspectionUpdateExe { List initiator = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), 1); Map sendParamsPigeonhole = new HashMap<>(); sendParamsPigeonhole.put("checkTitle", inspectionDO.getProjectName()); - messageNoticeExe.messageNotice(initiator.get(0).getUserId(), messageTemplateConfig.getCheckInitiatorApplyAcceptancePass(), sendParamsPigeonhole); + if (initiator != null && !initiator.isEmpty()) { + messageNoticeExe.messageNotice(initiator.get(0).getUserId(), messageTemplateConfig.getCheckInitiatorApplyAcceptancePass(), sendParamsPigeonhole); + } } List userList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), 4); // 完成申辩待办 - messageNoticeExe.sendMessageCompleteEvent(userList.get(0).getId()); + if (userList != null && !userList.isEmpty()) { + messageNoticeExe.sendMessageCompleteEvent(userList.get(0).getId()); + } } } diff --git a/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUserUpdateExe.java b/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUserUpdateExe.java index e678f66..9c3b55c 100644 --- a/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUserUpdateExe.java +++ b/web-app/src/main/java/com/zcloud/key/project/command/inspection/SafetyEnvironmentalInspectionUserUpdateExe.java @@ -60,6 +60,9 @@ public class SafetyEnvironmentalInspectionUserUpdateExe { SafetyEnvironmentalInspectionUserDO inspectionUserDO = new SafetyEnvironmentalInspectionUserDO(); BeanUtils.copyProperties(inspectionUserE, inspectionUserDO); SafetyEnvironmentalInspectionDO inspectionDO = safetyEnvironmentalInspectionRepository.getByInspectionId(cmd.getInspectionId()); + if (inspectionDO == null) { + throw new BizException("检查任务不存在"); + } // 没有申辩过的安全环保检查 safetyEnvironmentalInspectionUser 下一步type 是2 否则 下一步type是 Integer type = 2; if (inspectionDO != null && !ObjectUtils.isEmpty(inspectionDO.getDefendFlag()) && inspectionDO.getDefendFlag() == 1){ @@ -69,6 +72,9 @@ public class SafetyEnvironmentalInspectionUserUpdateExe { // 修改自己的检查信息 safetyEnvironmentalInspectionUserRepository.verifyEdit(inspectionUserDO); List verifyUserList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), type, ssoUser.getUserId()); + if (verifyUserList == null || verifyUserList.isEmpty()) { + throw new BizException("当前用户无可核实的检查记录"); + } if (cmd.getStatus() == 1){ // 如果通过 // 查询是否所有人都核实, @@ -97,7 +103,8 @@ public class SafetyEnvironmentalInspectionUserUpdateExe { sendParams.put("initiatorName", inspectionDO.getCreateName()); sendParams.put("checkTitle", inspectionDO.getProjectName()); messageNoticeExe.messageNotice(inspectionDO.getCreateId(), messageTemplateConfig.getCheckInitiatorApplyCheckNotPass(), sendParams); - messageNoticeExe.sendMessageAddEvent(inspectionDO.getCreateId(), "您有一条【安全环保检查】待处理","检查任务核实不通过,请您尽快处理。", inspectionDO.getId(), userList.get(0).getId()); + Long todoId = userList != null && !userList.isEmpty() ? userList.get(0).getId() : inspectionDO.getId(); + messageNoticeExe.sendMessageAddEvent(inspectionDO.getCreateId(), "您有一条【安全环保检查】待处理","检查任务核实不通过,请您尽快处理。", inspectionDO.getId(), todoId); List verifyComList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), type); for (SafetyEnvironmentalInspectionUserDO verifyCom : verifyComList){ messageNoticeExe.sendMessageCompleteEvent(verifyCom.getId()); diff --git a/web-app/src/main/java/com/zcloud/key/project/command/query/hidden/HiddenPenaltyQueryExe.java b/web-app/src/main/java/com/zcloud/key/project/command/query/hidden/HiddenPenaltyQueryExe.java index 6165f41..e994b72 100644 --- a/web-app/src/main/java/com/zcloud/key/project/command/query/hidden/HiddenPenaltyQueryExe.java +++ b/web-app/src/main/java/com/zcloud/key/project/command/query/hidden/HiddenPenaltyQueryExe.java @@ -1,6 +1,7 @@ package com.zcloud.key.project.command.query.hidden; import com.alibaba.cola.dto.PageResponse; +import com.jjb.saas.framework.auth.utils.AuthContext; import com.zcloud.gbscommon.utils.PageQueryHelper; import com.zcloud.key.project.command.convertor.hidden.HiddenPenaltyCoConvertor; import com.zcloud.key.project.dto.clientobject.hidden.HiddenPenaltyCO; @@ -23,6 +24,7 @@ public class HiddenPenaltyQueryExe { public PageResponse execute(HiddenPenaltyPageQry qry) { Map params = PageQueryHelper.toHashMap(qry); + params.put("currentUserId", AuthContext.getUserId()); PageResponse pageResponse = hiddenPenaltyRepository.listPage(params); List cos = hiddenPenaltyCoConvertor.converDOsToCOs(pageResponse.getData()); return PageResponse.of(cos, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex()); diff --git a/web-app/src/main/java/com/zcloud/key/project/command/query/inspection/SafetyEnvironmentalInspectionQueryExe.java b/web-app/src/main/java/com/zcloud/key/project/command/query/inspection/SafetyEnvironmentalInspectionQueryExe.java index 423db13..e9a3b92 100644 --- a/web-app/src/main/java/com/zcloud/key/project/command/query/inspection/SafetyEnvironmentalInspectionQueryExe.java +++ b/web-app/src/main/java/com/zcloud/key/project/command/query/inspection/SafetyEnvironmentalInspectionQueryExe.java @@ -2,6 +2,8 @@ package com.zcloud.key.project.command.query.inspection; import com.alibaba.cola.dto.PageResponse; import com.alibaba.cola.exception.BizException; +import com.jjb.saas.framework.auth.model.SSOUser; +import com.jjb.saas.framework.auth.utils.AuthContext; import com.zcloud.gbscommon.excelEntity.SafetyEnvironmentalInspectionExportEntity; import com.zcloud.gbscommon.excelEntity.UserExcelExportEntity; import com.zcloud.gbscommon.utils.ExcelUtils; @@ -127,11 +129,46 @@ public class SafetyEnvironmentalInspectionQueryExe { */ public PageResponse execute(SafetyEnvironmentalInspectionPageQry safetyEnvironmentalInspectionPageQry) { Map params = PageQueryHelper.toHashMap(safetyEnvironmentalInspectionPageQry); + fillPendingUserParams(params, safetyEnvironmentalInspectionPageQry); PageResponse pageResponse = safetyEnvironmentalInspectionRepository.listPage(params); List examCenterCOS = safetyEnvironmentalInspectionCoConvertor.converDOsToCOs(pageResponse.getData()); return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex()); } + private void fillPendingUserParams(Map params, SafetyEnvironmentalInspectionPageQry qry) { + List currentPendingTypeList = resolveCurrentPendingTypeList(qry); + if (currentPendingTypeList == null || currentPendingTypeList.isEmpty()) { + return; + } + SSOUser ssoUser = AuthContext.getCurrentUser(); + if (ssoUser == null || ssoUser.getUserId() == null) { + return; + } + params.put("currentPendingTypeList", currentPendingTypeList); + params.put("currentPendingUserId", ssoUser.getUserId()); + params.put("onlyCurrentPendingUser", true); + } + + private List resolveCurrentPendingTypeList(SafetyEnvironmentalInspectionPageQry qry) { + if (qry == null || qry.getStatusList() == null || qry.getStatusList().size() != 1) { + return null; + } + Integer status = qry.getStatusList().get(0); + if (status == null) { + return null; + } + if (status == 1) { + return Arrays.asList(2, 5); + } + if (status == 2) { + return Arrays.asList(3, 6); + } + if (status == 7) { + return Collections.singletonList(4); + } + return null; + } + public void export(Long[] ids, HttpServletResponse httpServletResponse) { if (ids == null || ids.length == 0){ throw new BizException("请勾选要导出的数据"); diff --git a/web-app/src/main/java/com/zcloud/key/project/command/query/project/KeyProjectQueryExe.java b/web-app/src/main/java/com/zcloud/key/project/command/query/project/KeyProjectQueryExe.java index 92dbbc8..31b51b0 100644 --- a/web-app/src/main/java/com/zcloud/key/project/command/query/project/KeyProjectQueryExe.java +++ b/web-app/src/main/java/com/zcloud/key/project/command/query/project/KeyProjectQueryExe.java @@ -25,7 +25,7 @@ import com.zcloud.key.project.persistence.repository.project.KeyProjectRepositor import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; -import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -256,8 +256,14 @@ public class KeyProjectQueryExe { - // 处罚管理数量(相关方未反馈的罚款处罚) - Long penaltyCount = hiddenPenaltyRepository.countByUserId(id); + // 处罚管理数量:直接复用处罚管理列表口径,统计未处罚数据 + Map penaltyParams = new HashMap<>(); + penaltyParams.put("pageIndex", 1); + penaltyParams.put("pageSize", 1); + penaltyParams.put("fineFlag", "0"); + penaltyParams.put("currentUserId", id); + int pCount = hiddenPenaltyRepository.listPage(penaltyParams).getTotalCount(); + Long penaltyCount = (long) pCount; // 处罚反馈数量 Long feedbackCount = hiddenPenaltyRepository.countFeedbackByUserId(id); diff --git a/web-infrastructure/src/main/resources/mapper/HiddenPenaltyMapper.xml b/web-infrastructure/src/main/resources/mapper/HiddenPenaltyMapper.xml index f16d369..47c6956 100644 --- a/web-infrastructure/src/main/resources/mapper/HiddenPenaltyMapper.xml +++ b/web-infrastructure/src/main/resources/mapper/HiddenPenaltyMapper.xml @@ -65,6 +65,9 @@ AND hp.fine_flag = #{params.fineFlag} + + AND (hp.create_id = #{params.currentUserId} OR hp.penalized_user_id = #{params.currentUserId}) + AND hp.penalty_desc LIKE CONCAT('%', #{params.penaltyDesc}, '%') @@ -219,10 +222,22 @@ LEFT JOIN hidden_penalty hp ON hp.hidden_id = h.hidden_id AND hp.delete_enum = 'FALSE' WHERE h.delete_enum = 'FALSE' AND h.state = 3 - AND kpp.user_id = #{userId} AND (h.source NOT IN (2, 3) OR i.inspection_id IS NOT NULL) AND (h.source != 1 OR aa.ai_alarm_id IS NOT NULL) - AND hp.id IS NULL + AND ( + ( + hp.id IS NULL + AND kpp.user_id = #{userId} + ) + OR + ( + hp.id IS NOT NULL + AND hp.penalized_user_id = #{userId} + AND hp.fine_flag = 0 + AND hp.feedback_status = 0 + AND hp.edit_flag = 0 + ) + ) diff --git a/web-infrastructure/src/main/resources/mapper/ai/AiAlarmMapper.xml b/web-infrastructure/src/main/resources/mapper/ai/AiAlarmMapper.xml index 841c537..f36ae22 100644 --- a/web-infrastructure/src/main/resources/mapper/ai/AiAlarmMapper.xml +++ b/web-infrastructure/src/main/resources/mapper/ai/AiAlarmMapper.xml @@ -14,7 +14,16 @@ xgfd.name as xgf_master_department_name from ai_alarm aa - left join key_project kp on kp.key_project_id = aa.key_project_id + left join ( + select kp1.* + from key_project kp1 + inner join ( + select key_project_id, max(id) as id + from key_project + where delete_enum = 'FALSE' + group by key_project_id + ) kp_latest on kp_latest.id = kp1.id + ) kp on kp.key_project_id = aa.key_project_id left join user xgfu on xgfu.id = kp.xgf_master_user_id left join department xgfd on xgfd.id = xgfu.department_id @@ -43,7 +52,16 @@ h.hidden_id as hidden_uuid from ai_alarm aa - left join key_project kp on kp.key_project_id = aa.key_project_id + left join ( + select kp1.* + from key_project kp1 + inner join ( + select key_project_id, max(id) as id + from key_project + where delete_enum = 'FALSE' + group by key_project_id + ) kp_latest on kp_latest.id = kp1.id + ) kp on kp.key_project_id = aa.key_project_id left join user xgfu on xgfu.id = kp.xgf_master_user_id left join department xgfd on xgfd.id = xgfu.department_id left join hidden h on h.foreign_key = aa.ai_alarm_id and h.delete_enum = 'FALSE' @@ -63,7 +81,16 @@ h.hidden_id as hidden_uuid from ai_alarm aa - left join key_project kp on kp.key_project_id = aa.key_project_id + left join ( + select kp1.* + from key_project kp1 + inner join ( + select key_project_id, max(id) as id + from key_project + where delete_enum = 'FALSE' + group by key_project_id + ) kp_latest on kp_latest.id = kp1.id + ) kp on kp.key_project_id = aa.key_project_id left join user xgfu on xgfu.id = kp.xgf_master_user_id left join department xgfd on xgfd.id = xgfu.department_id left join hidden h on h.foreign_key = aa.ai_alarm_id and h.delete_enum = 'FALSE' diff --git a/web-infrastructure/src/main/resources/mapper/inspection/SafetyEnvironmentalInspectionMapper.xml b/web-infrastructure/src/main/resources/mapper/inspection/SafetyEnvironmentalInspectionMapper.xml index bd1ebf2..b495fb2 100644 --- a/web-infrastructure/src/main/resources/mapper/inspection/SafetyEnvironmentalInspectionMapper.xml +++ b/web-infrastructure/src/main/resources/mapper/inspection/SafetyEnvironmentalInspectionMapper.xml @@ -10,7 +10,17 @@ MAX(type) AS max_type FROM safety_environmental_inspection_user WHERE delete_enum = 'FALSE' - AND type IN (2, 5) + + + AND type IN + + #{type} + + + + AND type IN (2, 5) + + GROUP BY inspection_id ) @@ -40,10 +50,16 @@ AND iu.delete_enum = 'FALSE' AND iu.type = mt.max_type AND iu.STATUS = 0 + + AND iu.user_id = #{params.currentPendingUserId} + left join user showu on showu.id = iu_show.user_id left join corp_info indc on indc.id = i.inspected_corpinfo_id left join user xmu on xmu.id = i.xgf_master_user_id where i.delete_enum = 'FALSE' + + and iu.user_id is not null + and i.place LIKE CONCAT('%', #{params.place}, '%')