添加消息通知和统计功能

main
zhangyue 2026-05-21 14:27:45 +08:00
parent af28851a3a
commit 1284a61eaa
17 changed files with 161 additions and 9 deletions

View File

@ -1,6 +1,8 @@
package com.zcloud.key.project.command.hidden;
import com.alibaba.cola.exception.BizException;
import com.zcloud.key.project.command.project.MessageNoticeExe;
import com.zcloud.key.project.domain.config.MessageTemplateConfig;
import com.zcloud.key.project.domain.gateway.hidden.HiddenGateway;
import com.zcloud.key.project.domain.model.hidden.HiddenE;
import com.zcloud.key.project.dto.hidden.HiddenAddCmd;
@ -9,6 +11,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.Map;
/**
* web-app
@ -20,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
@AllArgsConstructor
public class HiddenAddExe {
private final HiddenGateway hiddenGateway;
private final MessageNoticeExe messageNoticeExe;
private final MessageTemplateConfig messageTemplateConfig;
@Transactional(rollbackFor = Exception.class)
public boolean execute(HiddenAddCmd cmd) {
@ -29,6 +36,11 @@ public class HiddenAddExe {
boolean res = false;
try {
res = hiddenGateway.add(hiddenE);
Map<String, Object> sendParams = new HashMap<>();
messageNoticeExe.messageNotice(hiddenE.getRectificationUserId(), messageTemplateConfig.getHiddenDangerRectifyPersonApplyRectifyPass(), sendParams);
messageNoticeExe.sendMessageAddEvent(hiddenE.getRectificationUserId(), "由您负责处置隐患的摄像头发现隐患,请及时整改。","隐患待整改", hiddenE.getId(), hiddenE.getId());
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -142,7 +142,7 @@ public class SafetyEnvironmentalInspectionAddExe {
}
hiddenAddCmd.setForeignKey(safetyEnvironmentalInspectionE.getInspectionId());
hiddenAddCmd.setState(1);
// hiddenAddCmd.setRectificationCorpId(safetyEnvironmentalInspectionE.getXgfMasterCorpId());
hiddenAddCmd.setRectificationCorpId(safetyEnvironmentalInspectionE.getInspectedCorpinfoId());
// hiddenAddCmd.setRectificationDepartmentId(safetyEnvironmentalInspectionE.getXgfMasterDepartmentId());
hiddenAddCmd.setRectificationUserId(safetyEnvironmentalInspectionE.getXgfMasterUserId());
hiddenAddCmd.setAcceptCorpId(ssoUser.getTenantId());

View File

@ -115,6 +115,8 @@ public class SafetyEnvironmentalInspectionDefendAddExe {
safetyEnvironmentalInspectionUserGateway.add(hiddenRectificationUser);
//TODO 站内信 给隐患整改人发送隐患整改待处理
Map<String, Object> sendParamsHidden = new HashMap<>();
sendParamsHidden.put("checkTitle", inspectionDO.getProjectName());
sendParamsHidden.put("hiddenNumber", inspectionDO.getHiddenNumber());
messageNoticeExe.messageNotice(inspectionDO.getXgfMasterUserId(), messageTemplateConfig.getHiddenDangerRectifyPersonApplyRectify(), sendParamsHidden);
messageNoticeExe.sendMessageAddEvent(inspectionDO.getXgfMasterUserId(), "您有一条安全检查任务的待整改隐患,请及时整改。","待整改", inspectionDO.getId(), hiddenRectificationUser.getId());

View File

@ -167,7 +167,7 @@ public class SafetyEnvironmentalInspectionUpdateExe {
}
hiddenAddCmd.setForeignKey(safetyEnvironmentalInspectionE.getInspectionId());
hiddenAddCmd.setState(1);
// hiddenAddCmd.setRectificationCorpId(safetyEnvironmentalInspectionE.getXgfMasterCorpId());
hiddenAddCmd.setRectificationCorpId(safetyEnvironmentalInspectionE.getInspectedCorpinfoId());
// hiddenAddCmd.setRectificationDepartmentId(safetyEnvironmentalInspectionE.getXgfMasterDepartmentId());
hiddenAddCmd.setRectificationUserId(safetyEnvironmentalInspectionE.getXgfMasterUserId());
hiddenAddCmd.setAcceptCorpId(ssoUser.getTenantId());
@ -337,7 +337,7 @@ public class SafetyEnvironmentalInspectionUpdateExe {
}
hiddenAddCmd.setForeignKey(safetyEnvironmentalInspectionE.getInspectionId());
hiddenAddCmd.setState(1);
hiddenAddCmd.setRectificationCorpId(safetyEnvironmentalInspectionE.getXgfMasterCorpId());
hiddenAddCmd.setRectificationCorpId(safetyEnvironmentalInspectionE.getInspectedCorpinfoId());
hiddenAddCmd.setRectificationDepartmentId(safetyEnvironmentalInspectionE.getXgfMasterDepartmentId());
hiddenAddCmd.setRectificationUserId(safetyEnvironmentalInspectionE.getXgfMasterUserId());
hiddenAddCmd.setAcceptCorpId(ssoUser.getTenantId());

View File

@ -50,5 +50,10 @@ public class CorpStatisticsCO implements Serializable {
@ApiModelProperty(value = "移动摄像头idList")
private List<String> mobileCameraIdList;
@ApiModelProperty(value = "在线固定视频监控数")
private Integer onlineFixedCameraCount;
@ApiModelProperty(value = "在线移动视频监控数")
private Integer onlineMobileCameraCount;
}

View File

@ -51,5 +51,10 @@ public class KeyProjectStatisticsCO implements Serializable {
@ApiModelProperty(value = "移动摄像头idList")
private List<String> mobileCameraIdList;
@ApiModelProperty(value = "在线固定视频监控数")
private Integer onlineFixedCameraCount;
@ApiModelProperty(value = "在线移动视频监控数")
private Integer onlineMobileCameraCount;
}

View File

@ -18,6 +18,8 @@ public class XgfCorpStatisticsCO implements Serializable {
//企业id
@ApiModelProperty(value = "辖区单位企业id")
private Long jurisdictionCorpinfoId;
@ApiModelProperty(value = "辖区单位名称")
private String corpinfoName;
@ApiModelProperty(value = "重点作业总数")
private Integer totalProjectCount;
@ -47,5 +49,9 @@ public class XgfCorpStatisticsCO implements Serializable {
@ApiModelProperty(value = "移动摄像头idList")
private List<String> mobileCameraIdList;
@ApiModelProperty(value = "在线固定视频监控数")
private Integer onlineFixedCameraCount;
@ApiModelProperty(value = "在线移动视频监控数")
private Integer onlineMobileCameraCount;
}

View File

@ -35,10 +35,13 @@ public class HiddenPageQry extends PageQuery {
private String rectificationUserName;
private List<Integer> stateList;
private Long xgfCorpinfoId;
private Long findCorpinfoId;
private Integer state;
private Long rectificationCorpId;
private String menuPath;
}

View File

@ -40,6 +40,8 @@ public class SafetyEnvironmentalInspectionPageQry extends PageQuery {
private String year;
private String menuPath;
private Long corpinfoId;
private String keyProjectId;
private Long inspectedCorpinfoId;

View File

@ -49,5 +49,7 @@ public class MessageTemplateConfig {
private String checkInitiatorApplyAcceptancePass;
// 重点作业-检查发起人-验收未通过
private String checkInitiatorApplyAcceptanceNotPass;
// 重点作业-AI报警处置人-隐患待整改
private String hiddenDangerRectifyPersonApplyRectifyPass;
}

View File

@ -26,6 +26,7 @@ public class HiddenGatewayImpl implements HiddenGateway {
HiddenDO d = new HiddenDO();
BeanUtils.copyProperties(hiddenE, d);
hiddenRepository.save(d);
hiddenE.setId(d.getId());
return true;
}

View File

@ -47,5 +47,10 @@ public class CorpStatisticsDO implements Serializable {
@ApiModelProperty(value = "移动摄像头idList")
private String mobileCameraIdList;
@ApiModelProperty(value = "在线固定视频监控数")
private Integer onlineFixedCameraCount;
@ApiModelProperty(value = "在线移动视频监控数")
private Integer onlineMobileCameraCount;
}

View File

@ -51,5 +51,10 @@ public class KeyProjectStatisticsDO implements Serializable {
@ApiModelProperty(value = "移动摄像头idList")
private String mobileCameraIdList;
@ApiModelProperty(value = "在线固定视频监控数")
private Integer onlineFixedCameraCount;
@ApiModelProperty(value = "在线移动视频监控数")
private Integer onlineMobileCameraCount;
}

View File

@ -17,6 +17,9 @@ public class XgfCorpStatisticsDO implements Serializable {
//企业id
@ApiModelProperty(value = "企业id")
private Long jurisdictionCorpinfoId;
//企业名称
@ApiModelProperty(value = "企业名称")
private String corpinfoName;
@ApiModelProperty(value = "重点作业总数")
private Integer totalProjectCount;
@ -46,5 +49,10 @@ public class XgfCorpStatisticsDO implements Serializable {
@ApiModelProperty(value = "移动摄像头idList")
private String mobileCameraIdList;
@ApiModelProperty(value = "在线固定视频监控数")
private Integer onlineFixedCameraCount;
@ApiModelProperty(value = "在线移动视频监控数")
private Integer onlineMobileCameraCount;
}

View File

@ -43,6 +43,9 @@
<if test="params.endTime != null and params.endTime != ''">
and h.create_time &lt;= #{params.endTime}
</if>
<if test="params.keyProjectId != null and params.keyProjectId != ''">
and i.key_project_id = #{params.keyProjectId}
</if>
<if test="params.projectName != null and params.projectName != ''">
and (
kp.project_name LIKE CONCAT('%', #{params.projectName}, '%')
@ -72,6 +75,13 @@
kp2.xgf_corpinfo_id = #{params.xgfCorpinfoId}
)
</if>
<if test="params.findCorpinfoId != null">
and hf.find_corp_id = #{params.findCorpinfoId}
</if>
<if test="params.rectificationCorpId != null">
and h.rectification_corp_id = #{params.rectificationCorpId}
</if>
<if test="params.hiddenFindUserName != null and params.hiddenFindUserName != ''">
and EXISTS (
SELECT 1 FROM hidden_find_user hf2

View File

@ -211,17 +211,36 @@
COUNT(DISTINCT CASE WHEN kp.apply_status = 6 THEN kp.id END) AS completeCount,
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,
COUNT(DISTINCT CASE WHEN kpc.camera_type = 2 AND c.is_online = 1 THEN kpc.camera_id END) AS onlineMobileCameraCount,
COUNT(DISTINCT sei.id) AS inspectCount,
COUNT(DISTINCT h.id) AS hazardCount,
COALESCE(hz.hazardCount, 0) AS hazardCount,
GROUP_CONCAT(DISTINCT CASE WHEN kpc.camera_type = 1 THEN kpc.camera_id END) AS fixedCameraIdList,
GROUP_CONCAT(DISTINCT CASE WHEN kpc.camera_type = 2 THEN kpc.camera_id END) AS mobileCameraIdList
FROM corp_info cp
LEFT JOIN key_project kp
ON cp.id = kp.jurisdiction_corpinfo_id AND kp.delete_enum = 'FALSE' AND kp.apply_status NOT IN (0,1)
ON cp.id = kp.jurisdiction_corpinfo_id AND kp.delete_enum = 'FALSE' AND kp.apply_status != 0
left join key_project_camera kpc on kp.key_project_id = kpc.key_project_id AND kpc.delete_enum = 'FALSE'
LEFT JOIN camera c ON c.camera_id = kpc.camera_id
left join safety_environmental_inspection sei on cp.id = sei.corp_id AND sei.delete_enum = 'FALSE' and
sei.status != 0
left join hidden h on cp.id = h.tenant_id AND h.delete_enum = 'FALSE'
LEFT JOIN (
SELECT
hfu.find_corp_id,
COUNT(DISTINCT h.id) AS hazardCount
FROM
hidden_find_user hfu
INNER JOIN hidden h ON h.hidden_id = hfu.hidden_id
AND h.delete_enum = 'FALSE'
LEFT JOIN safety_environmental_inspection hi ON hi.inspection_id = h.foreign_key
AND hi.STATUS IN (3, 5)
AND h.source IN (2, 3)
WHERE
hfu.delete_enum = 'FALSE'
AND (h.source NOT IN (2, 3) OR hi.inspection_id IS NOT NULL)
GROUP BY
hfu.find_corp_id
) hz ON hz.find_corp_id = cp.id
WHERE cp.delete_enum = 'FALSE'
AND cp.use_flag = 1
AND cp.type IN (0, 1, 2, 6)
@ -239,12 +258,15 @@
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,
COUNT(DISTINCT CASE WHEN kpc.camera_type = 2 AND c.is_online = 1 THEN kpc.camera_id END) AS onlineMobileCameraCount,
COUNT(DISTINCT sei.id) AS inspectCount,
COUNT(DISTINCT h.id) AS hazardCount,
GROUP_CONCAT(DISTINCT CASE WHEN kpc.camera_type = 1 THEN kpc.camera_id END) AS fixedCameraIdList,
GROUP_CONCAT(DISTINCT CASE WHEN kpc.camera_type = 2 THEN kpc.camera_id END) AS mobileCameraIdList
from key_project kp
left join key_project_camera kpc on kp.key_project_id = kpc.key_project_id AND kpc.delete_enum = 'FALSE'
LEFT JOIN camera c ON c.camera_id = kpc.camera_id
left join safety_environmental_inspection sei on kp.key_project_id = sei.key_project_id AND sei.delete_enum = 'FALSE' and sei.status != 0
left join hidden h on sei.inspection_id = h.foreign_key AND h.delete_enum = 'FALSE'
where kp.delete_enum = 'FALSE'
@ -257,7 +279,65 @@
ORDER BY kp.apply_status asc, kp.create_time DESC
</select>
<select id="xgfCorpStatistics" resultType="com.zcloud.key.project.persistence.dataobject.project.XgfCorpStatisticsDO">
SELECT
cp.id AS jurisdiction_corpinfo_id,
cp.corp_name AS corpinfoName,
COUNT(distinct kp.id) AS totalProjectCount,
COUNT(DISTINCT CASE WHEN kp.apply_status in (2,3,4,5) THEN kp.id END) AS startCount,
COUNT(DISTINCT CASE WHEN kp.apply_status = 6 THEN kp.id END) AS completeCount,
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,
COUNT(DISTINCT CASE WHEN kpc.camera_type = 2 AND c.is_online = 1 THEN kpc.camera_id END) AS onlineMobileCameraCount,
COUNT(DISTINCT sei.id) AS inspectCount,
COALESCE(hz.hazardCount, 0) AS hazardCount,
GROUP_CONCAT(DISTINCT CASE WHEN kpc.camera_type = 1 THEN kpc.camera_id END) AS fixedCameraIdList,
GROUP_CONCAT(DISTINCT CASE WHEN kpc.camera_type = 2 THEN kpc.camera_id END) AS mobileCameraIdList
FROM corp_info cp
LEFT JOIN key_project kp
ON cp.id = kp.jurisdiction_corpinfo_id AND kp.delete_enum = 'FALSE' AND kp.apply_status != 0
left join key_project_camera kpc on kp.key_project_id = kpc.key_project_id AND kpc.delete_enum = 'FALSE'
LEFT JOIN camera c ON c.camera_id = kpc.camera_id
left join safety_environmental_inspection sei on cp.id = sei.corp_id AND sei.delete_enum = 'FALSE' and sei.inspected_corpinfo_id = #{params.xgfCorpinfoId} and
sei.status != 0
LEFT JOIN (
SELECT
hfu.find_corp_id,
COUNT(DISTINCT h.id) AS hazardCount
FROM
hidden_find_user hfu
INNER JOIN hidden h ON h.hidden_id = hfu.hidden_id
AND h.delete_enum = 'FALSE'
LEFT JOIN safety_environmental_inspection hi ON hi.inspection_id = h.foreign_key
AND hi.STATUS IN (3, 5)
AND h.source IN (2, 3)
WHERE
hfu.delete_enum = 'FALSE'
AND (h.source NOT IN (2, 3) OR hi.inspection_id IS NOT NULL) and h.rectification_corp_id = #{params.xgfCorpinfoId}
GROUP BY
hfu.find_corp_id
) hz ON hz.find_corp_id = cp.id
where kp.delete_enum = 'FALSE'
AND cp.use_flag = 1
<if test="params.jurisdictionCorpinfoIdList != null and params.jurisdictionCorpinfoIdList.size() > 0">
and kp.jurisdiction_corpinfo_id in
<foreach collection="params.jurisdictionCorpinfoIdList" item="corpinfoId" open="(" separator="," close=")">
#{corpinfoId}
</foreach>
</if>
<if test="params.corpName != null and params.corpName != ''">
and cp.corp_name like CONCAT('%', #{params.corpName}, '%')
</if>
and kp.xgf_corpinfo_id = #{params.xgfCorpinfoId}
GROUP BY cp.id
order by cp.corp_order ASC,cp.create_time desc
</select>
<!--<select id="xgfCorpStatistics" resultType="com.zcloud.key.project.persistence.dataobject.project.XgfCorpStatisticsDO">
select kp.id,
kp.jurisdiction_corpinfo_id as jurisdictionCorpinfoId,
COUNT(distinct kp.id) AS totalProjectCount,
@ -289,7 +369,7 @@
order by cp.corp_order ASC,cp.create_time desc
</select>
</select>-->
<select id="listAll" resultType="com.zcloud.key.project.persistence.dataobject.project.KeyProjectDO">
SELECT kp.*,

View File

@ -50,6 +50,9 @@
<if test="params.createName != null and params.createName != ''">
and creu.name LIKE CONCAT('%', #{params.createName}, '%')
</if>
<if test="params.inspectedCorpinfoId != null">
and i.inspected_corpinfo_id = #{params.inspectedCorpinfoId}
</if>
<if test="params.inspectionDepartmentId != null and params.inspectionDepartmentId != ''">
and iu.department_id = #{params.inspectionDepartmentId}
</if>
@ -59,6 +62,9 @@
<if test="params.timeEnd != null and params.timeEnd != ''">
and i.time_start &lt;= #{params.timeEnd}
</if>
<if test="params.keyProjectId != null and params.keyProjectId != ''">
and i.key_project_id = #{params.keyProjectId}
</if>
<if test="params.year != null and params.year != ''">
and YEAR(STR_TO_DATE(i.create_time, '%Y-%m-%d %H:%i:%s')) = #{params.year}
</if>
@ -77,7 +83,7 @@
</if>
<if test="params.noStatusList != null and params.noStatusList.size() > 0">
and i.status not in
<foreach item="st" collection="params.noStatusList" separator="," open="(" close=")" >
<foreach item="nst" collection="params.noStatusList" separator="," open="(" close=")" >
#{nst}
</foreach>
</if>