fix(): 重点作业数据查询、处罚列表和检查任务处理

dev
lishiwei 2026-07-02 19:15:12 +08:00
parent d452d31d8d
commit 3be9130520
10 changed files with 159 additions and 22 deletions

View File

@ -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<SafetyEnvironmentalInspectionUserDO> 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<SafetyEnvironmentalInspectionUserDO> initiator = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), 1);
if (initiator == null || initiator.isEmpty()) {
throw new BizException("未找到检查发起人");
}
Map<String, Object> 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<SafetyEnvironmentalInspectionUserDO> affirmList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), type, ssoUser.getUserId());
if (affirmList == null || affirmList.isEmpty()) {
throw new BizException("当前用户无可确认的检查记录");
}
messageNoticeExe.sendMessageCompleteEvent(affirmList.get(0).getId());
}
}

View File

@ -270,7 +270,9 @@ public class SafetyEnvironmentalInspectionUpdateExe {
}
List<SafetyEnvironmentalInspectionUserDO> 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<SafetyEnvironmentalInspectionUserDO> 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<SafetyEnvironmentalInspectionUserDO> initiator = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), 1);
Map<String, Object> 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<SafetyEnvironmentalInspectionUserDO> userList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), 4);
// 完成申辩待办
messageNoticeExe.sendMessageCompleteEvent(userList.get(0).getId());
if (userList != null && !userList.isEmpty()) {
messageNoticeExe.sendMessageCompleteEvent(userList.get(0).getId());
}
}
}

View File

@ -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<SafetyEnvironmentalInspectionUserDO> 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<SafetyEnvironmentalInspectionUserDO> verifyComList = safetyEnvironmentalInspectionUserRepository.listAllByInspectionId(cmd.getInspectionId(), type);
for (SafetyEnvironmentalInspectionUserDO verifyCom : verifyComList){
messageNoticeExe.sendMessageCompleteEvent(verifyCom.getId());

View File

@ -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<HiddenPenaltyCO> execute(HiddenPenaltyPageQry qry) {
Map<String, Object> params = PageQueryHelper.toHashMap(qry);
params.put("currentUserId", AuthContext.getUserId());
PageResponse<HiddenPenaltyDO> pageResponse = hiddenPenaltyRepository.listPage(params);
List<HiddenPenaltyCO> cos = hiddenPenaltyCoConvertor.converDOsToCOs(pageResponse.getData());
return PageResponse.of(cos, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());

View File

@ -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<SafetyEnvironmentalInspectionCO> execute(SafetyEnvironmentalInspectionPageQry safetyEnvironmentalInspectionPageQry) {
Map<String, Object> params = PageQueryHelper.toHashMap(safetyEnvironmentalInspectionPageQry);
fillPendingUserParams(params, safetyEnvironmentalInspectionPageQry);
PageResponse<SafetyEnvironmentalInspectionDO> pageResponse = safetyEnvironmentalInspectionRepository.listPage(params);
List<SafetyEnvironmentalInspectionCO> examCenterCOS = safetyEnvironmentalInspectionCoConvertor.converDOsToCOs(pageResponse.getData());
return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
}
private void fillPendingUserParams(Map<String, Object> params, SafetyEnvironmentalInspectionPageQry qry) {
List<Integer> 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<Integer> 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("请勾选要导出的数据");

View File

@ -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<String, Object> 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);

View File

@ -65,6 +65,9 @@
<if test="params.fineFlag != null and params.fineFlag != ''">
AND hp.fine_flag = #{params.fineFlag}
</if>
<if test="params.currentUserId != null">
AND (hp.create_id = #{params.currentUserId} OR hp.penalized_user_id = #{params.currentUserId})
</if>
<if test="params.penaltyDesc != null and params.penaltyDesc != ''">
AND hp.penalty_desc LIKE CONCAT('%', #{params.penaltyDesc}, '%')
</if>
@ -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
)
)
</select>
<select id="countFeedbackByUserId" resultType="java.lang.Long">

View File

@ -100,8 +100,8 @@
juruser.name as jurisdictionUserName,
xgfci.corp_name AS xgfCorpinfoName,
xgfuser.name as xgfUserName,
count(h.hidden_id) AS uncheckHiddenCount,
count(sei.inspection_id) AS unFinishInspectionCount
count(DISTINCT h.hidden_id) AS uncheckHiddenCount,
count(DISTINCT sei.inspection_id) AS unFinishInspectionCount
FROM key_project kp
LEFT JOIN department fpd ON kp.master_department_id = fpd.id AND fpd.delete_enum = 'FALSE'
LEFT JOIN department ci ON kp.jurisdiction_department_id = ci.id AND ci.delete_enum = 'FALSE'
@ -114,6 +114,13 @@
left join hidden h on h.foreign_key = sei.inspection_id and h.delete_enum = 'FALSE' and h.state != 3
<where>
kp.delete_enum = 'FALSE'
AND NOT EXISTS (
SELECT 1
FROM key_project kp_latest
WHERE kp_latest.delete_enum = 'FALSE'
AND kp_latest.key_project_id = kp.key_project_id
AND kp_latest.id > kp.id
)
<!-- projectName 模糊查询判空 -->
<if test="params.projectName != null and params.projectName != ''">
AND kp.project_name LIKE CONCAT('%', #{params.projectName}, '%')
@ -253,10 +260,10 @@
</select>
<select id="keyProjectStatistics" resultType="com.zcloud.key.project.persistence.dataobject.project.KeyProjectStatisticsDO">
select kp.id,
select MAX(kp.id) as id,
kp.key_project_id as keyProjectId,
kp.project_name as projectName,
kp.project_id as projectId,
MAX(kp.project_name) as projectName,
MAX(kp.project_id) as projectId,
COUNT(DISTINCT CASE WHEN kpc.camera_type = 1 THEN kpc.camera_id END) AS fixedCameraCount,
COUNT(DISTINCT CASE WHEN kpc.camera_type = 2 THEN kpc.camera_id END) AS mobileCameraCount,
COUNT(DISTINCT CASE WHEN kpc.camera_type = 1 AND c.is_online = 1 THEN kpc.camera_id END) AS onlineFixedCameraCount,
@ -279,13 +286,13 @@
GROUP BY key_project_id
) sei_stat ON kp.key_project_id = sei_stat.key_project_id
where kp.delete_enum = 'FALSE'
and kp.apply_status != 0
and kp.apply_status in (0,1,2,4,5,6)
and kp.jurisdiction_corpinfo_id = #{params.jurisdictionCorpinfoId}
<if test="params.projectName != null and params.projectName != ''">
AND kp.project_name like concat('%',#{params.projectName},'%')
</if>
GROUP BY kp.id
ORDER BY kp.apply_status asc, kp.create_time DESC
GROUP BY kp.key_project_id
ORDER BY MAX(kp.apply_status) asc, MAX(kp.create_time) DESC
</select>

View File

@ -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
<where>
@ -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'

View File

@ -10,7 +10,17 @@
MAX(type) AS max_type
FROM safety_environmental_inspection_user
WHERE delete_enum = 'FALSE'
AND type IN (2, 5)
<choose>
<when test="params.currentPendingTypeList != null and params.currentPendingTypeList.size() > 0">
AND type IN
<foreach item="type" collection="params.currentPendingTypeList" separator="," open="(" close=")">
#{type}
</foreach>
</when>
<otherwise>
AND type IN (2, 5)
</otherwise>
</choose>
GROUP BY inspection_id
)
@ -40,10 +50,16 @@
AND iu.delete_enum = 'FALSE'
AND iu.type = mt.max_type
AND iu.STATUS = 0
<if test="params.currentPendingUserId != null">
AND iu.user_id = #{params.currentPendingUserId}
</if>
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'
<if test="params.onlyCurrentPendingUser != null and params.onlyCurrentPendingUser and params.currentPendingUserId != null">
and iu.user_id is not null
</if>
<if test="params.place != null and params.place != ''">
and i.place LIKE CONCAT('%', #{params.place}, '%')
</if>