From 2af0687164dc784d048c96c91c664bdfefb52f49 Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期三, 20 七月 2022 11:06:21 +0800 Subject: [PATCH] 事故快报 --- safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java | 12 ++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressDetailRespDTO.java | 2 incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentExpressInfoMapper.xml | 97 ++++++++++++++++++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressPageRespDTO.java | 3 incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java | 11 ++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java | 73 ++++++-------- incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/req/AccidentExpressReqDTO.java | 2 incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentExpressFileInfoMapper.xml | 55 +++++++++++ 8 files changed, 208 insertions(+), 47 deletions(-) diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java index efbc05c..8c3c536 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/enums/AccidentResultCodes.java @@ -5,6 +5,17 @@ ACCIDENT_EXPRESS_NULL("A1001", "事故快报不可为空"), ACCIDENT_EXPRESS_NOT_EXIST("A1002", "事故快报不存在"), + EXPRESS_NAME_NULL("E1001","事故快报名称不能为空"), + EXPRESS_DEPARTMENT_NULL("E1002","事故快报事故部门不能为空"), + EXPRESS_TIME_NULL("E1003","事故快报发生时间不能为空"), + EXPRESS_PLACE_NULL("E1004","事故快报发生地点不能为空"), + EXPRESS_CAUSE_NULL("E1005","事故快报事故原因不能为空"), + EXPRESS_CASUALTIES_NULL("E1006","事故快报是否有伤亡不能为空"), + EXPRESS_BRIEF_PROCESS_NULL("E1007","事故快报事故简要经过不能为空"), + EXPRESS_CASE_PRELIMINARY_ANALYSIS_NULL("E1008","事故快报事故原因初步分析不能为空"), + EXPRESS_EMERGENCY_PRECAUTIONS_NULL("E1009","事故快报应急防范措施不能为空"), + + ERROR("A3000", "未知错误"); diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/req/AccidentExpressReqDTO.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/req/AccidentExpressReqDTO.java index 5231914..1b9df7c 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/req/AccidentExpressReqDTO.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/req/AccidentExpressReqDTO.java @@ -1,6 +1,6 @@ package com.gkhy.safePlatform.incidentManage.model.dto.req; -import com.gkhy.safePlatform.incidentManage.entity.AccidentExpressFileInfoDO; +import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; import java.util.List; diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressDetailRespDTO.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressDetailRespDTO.java index f652867..8a5271f 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressDetailRespDTO.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressDetailRespDTO.java @@ -1,6 +1,7 @@ package com.gkhy.safePlatform.incidentManage.model.dto.resp; +import com.fasterxml.jackson.annotation.JsonFormat; import com.gkhy.safePlatform.incidentManage.entity.AccidentExpressFileInfoDO; import java.util.Date; @@ -20,6 +21,7 @@ private String accidentCause; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date occurrenceTime; private String occurrencePlace; diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressPageRespDTO.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressPageRespDTO.java index f7ebe06..3b8cc9b 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressPageRespDTO.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentExpressPageRespDTO.java @@ -1,6 +1,8 @@ package com.gkhy.safePlatform.incidentManage.model.dto.resp; +import com.fasterxml.jackson.annotation.JsonFormat; + import java.util.Date; import java.util.List; @@ -14,6 +16,7 @@ private String accidentCause; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date occurrenceTime; private String occurrencePlace; diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java index 418db46..90851c2 100644 --- a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java @@ -211,55 +211,42 @@ * @return */ private void checkRequired(AccidentExpressReqDTO AccidentExpressReqDTO) { - /* //名称 - if (StringUtils.isBlank(AccidentExpressReqDTO.getTeamName())) { - throw new EmergencyException(EmergencyResultCodes.TEAM_NAME_NULL); + //名称 + if (StringUtils.isBlank(AccidentExpressReqDTO.getAccidentName())) { + throw new AccidentException(AccidentResultCodes.EXPRESS_NAME_NULL); } - //级别 - if (StringUtils.isBlank(AccidentExpressReqDTO.getTeamLevel())) { - throw new EmergencyException(EmergencyResultCodes.TEAM_LEVEL_NULL); + //部门 + if (AccidentExpressReqDTO.getAccidentDepartmentId()==null) { + throw new AccidentException(AccidentResultCodes.EXPRESS_DEPARTMENT_NULL); } - //负责人 - if (AccidentExpressReqDTO.getPrincipalUid() == null || AccidentExpressReqDTO.getPrincipalUid() == 0) { - throw new EmergencyException(EmergencyResultCodes.TEAM_PRINCIPAL_NULL); + //发生时间 + if (AccidentExpressReqDTO.getOccurrenceTime() == null ) { + throw new AccidentException(AccidentResultCodes.EXPRESS_TIME_NULL); } - //负责人部门 - if (AccidentExpressReqDTO.getPrincipalDepartmentId() == null || AccidentExpressReqDTO.getPrincipalDepartmentId() == 0) { - throw new EmergencyException(EmergencyResultCodes.TEAM_PRINCIPAL_DEPARTMENT_NULL); + //发生地点 + if (StringUtils.isBlank(AccidentExpressReqDTO.getOccurrencePlace())) { + throw new AccidentException(AccidentResultCodes.EXPRESS_PLACE_NULL); } - //负责人手机 - if (StringUtils.isBlank(AccidentExpressReqDTO.getPrincipalPhone())) { - throw new EmergencyException(EmergencyResultCodes.TEAM_PRINCIPAL_PHONE_NULL); + //事故原因 + if (StringUtils.isBlank(AccidentExpressReqDTO.getAccidentCause())) { + throw new AccidentException(AccidentResultCodes.EXPRESS_CAUSE_NULL); } - //固定电话 - if (StringUtils.isBlank(AccidentExpressReqDTO.getTelephoneNumber())) { - throw new EmergencyException(EmergencyResultCodes.TEAM_TELEPHONE_NUMBER_NULL); + //是否有伤亡 + if (AccidentExpressReqDTO.getCasualties()==null) { + throw new AccidentException(AccidentResultCodes.EXPRESS_CASUALTIES_NULL); } - //人员列表如果不为空,则需要验证其中的必填项 - if (!CollectionUtils.isEmpty(AccidentExpressReqDTO.getMemberList())){ - for(AccidentExpressMemberReqDTO AccidentExpressMemberReqDTO : AccidentExpressReqDTO.getMemberList()){ - //工号 - if (StringUtils.isBlank(AccidentExpressMemberReqDTO.getJobNumber())) { - throw new EmergencyException(EmergencyResultCodes.TEAM_USER_JOB_NUMBER_NULL); - } - //名称 - if (StringUtils.isBlank(AccidentExpressMemberReqDTO.getName())) { - throw new EmergencyException(EmergencyResultCodes.TEAM_USER_NAME_NULL); - } - //性别 - if (AccidentExpressMemberReqDTO.getGender()==null) { - throw new EmergencyException(EmergencyResultCodes.TEAM_USER_GENDER_NULL); - } - //手机号码 - if (StringUtils.isBlank(AccidentExpressMemberReqDTO.getPhone())) { - throw new EmergencyException(EmergencyResultCodes.TEAM_USER_PHONE_NULL); - } - //职务 - if (StringUtils.isBlank(AccidentExpressMemberReqDTO.getPosition())) { - throw new EmergencyException(EmergencyResultCodes.TEAM_USER_POSITION_NULL); - } - } - }*/ + //简要经过 + if (StringUtils.isBlank(AccidentExpressReqDTO.getAccidentBriefProcess())) { + throw new AccidentException(AccidentResultCodes.EXPRESS_BRIEF_PROCESS_NULL); + } + //初步分析 + if (StringUtils.isBlank(AccidentExpressReqDTO.getAccidentCausesPreliminaryAnalysis())) { + throw new AccidentException(AccidentResultCodes.EXPRESS_CASE_PRELIMINARY_ANALYSIS_NULL); + } + //应急防范措施 + if (StringUtils.isBlank(AccidentExpressReqDTO.getEmergencyPrecautions())) { + throw new AccidentException(AccidentResultCodes.EXPRESS_EMERGENCY_PRECAUTIONS_NULL); + } } } diff --git a/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentExpressFileInfoMapper.xml b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentExpressFileInfoMapper.xml new file mode 100644 index 0000000..f985f3b --- /dev/null +++ b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentExpressFileInfoMapper.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.gkhy.safePlatform.incidentManage.repository.AccidentExpressFileInfoRepository"> + + <insert id="addAccidentExpressFile"> + insert into accident_express_file + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null ">id,</if> + <if test="delFlag != null ">del_flag,</if> + <if test="gmtCreate != null ">gmt_create,</if> + <if test="gmtModitify != null ">gmt_moditify,</if> + <if test="createUid != null ">create_uid,</if> + <if test="updateUid != null ">update_uid,</if> + <if test="accidentExpressId != null ">accident_express_id,</if> + <if test="fileUrl != null and fileUrl != ''">file_url,</if> + <if test="fileName != null and fileName != ''">file_name</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null ">#{id},</if> + <if test="delFlag != null ">#{delFlag},</if> + <if test="gmtCreate != null ">#{gmtCreate},</if> + <if test="gmtModitify != null ">#{gmtModitify},</if> + <if test="createUid != null ">#{createUid},</if> + <if test="updateUid != null ">#{updateUid},</if> + <if test="accidentExpressId != null ">#{accidentExpressId},</if> + <if test="fileUrl != null and fileUrl != ''">#{fileUrl},</if> + <if test="fileName != null and fileName != ''">#{fileName}</if> + </trim> + </insert> + + <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentExpressFileInfoDO" id="AccidentExpressFileInfoDOResult"> + <id column="id" property="id" jdbcType="BIGINT"/> + <result column="accident_express_id" property="accidentExpressId" /> + <result column="file_url" property="fileUrl" /> + <result column="file_name" property="fileName" /> + </resultMap> + + <select id="selectByAccidentExpressId" resultMap="AccidentExpressFileInfoDOResult"> + select id,`accident_express_id`,`file_url`,`file_name` from accident_express_file where del_flag = 0 and accident_express_id = #{accidentExpressId} + </select> + + <update id = "deleteAccidentExpressFileByIds" > + update accident_express_file set del_flag = 1 where id in + <foreach item="id" collection="ids" open="(" separator="," close=")"> + #{id} + </foreach> + </update> + + <update id="deleteAccidentExpressFileByAccidentExpressId"> + update accident_express_file set del_flag = 1 where accident_express_id = #{accidentExpressId} + </update> + +</mapper> diff --git a/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentExpressInfoMapper.xml b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentExpressInfoMapper.xml index 614dd2e..050c87a 100644 --- a/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentExpressInfoMapper.xml +++ b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentExpressInfoMapper.xml @@ -2,12 +2,103 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="com.gkhy.safePlatform.goalManage.entity.TestTable"> +<mapper namespace="com.gkhy.safePlatform.incidentManage.repository.AccidentExpressInfoRepository"> - <resultMap id="TestTableMap" type="com.gkhy.safePlatform.goalManage.entity.TestTable"> + <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentExpressInfoPageDO" id="AccidentExpressInfoPageDOResult"> <id column="id" property="id" jdbcType="BIGINT"/> - <result property="title" column="title"/> + <result column="gmt_moditify" property="gmtModitify"/> + <result column="create_uid" property="createUid"/> + <result column="accident_cause" property="accidentCause"/> + <result column="occurrence_time" property="occurrenceTime"/> + <result column="occurrence_place" property="occurrencePlace"/> + <result column="accident_department_id" property="accidentDepartmentId"/> + <result column="accident_name" property="accidentName"/> </resultMap> + <select id="selectAccidentExpressList" resultMap="AccidentExpressInfoPageDOResult"> + select id,`gmt_moditify`,`create_uid`,`accident_cause`,`occurrence_time`,occurrence_place ,accident_department_id ,accident_name + from accident_express where del_flag = 0 + <if test="query.accidentName != null and query.accidentName != ''">and `accident_name` like concat('%', #{query.accidentName}, '%')</if> + </select> + <insert id="addAccidentExpress" parameterType="com.gkhy.safePlatform.incidentManage.entity.AccidentExpressInfo" + keyProperty="id" useGeneratedKeys="true"> + insert into accident_express + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null ">id,</if> + <if test="delFlag != null ">del_flag,</if> + <if test="gmtCreate != null ">gmt_create,</if> + <if test="gmtModitify != null ">gmt_moditify,</if> + <if test="createUid != null ">create_uid,</if> + <if test="updateUid != null ">update_uid,</if> + <if test="emergencyPrecautions != null and emergencyPrecautions != ''">emergency_precautions,</if> + <if test="accidentCausesPreliminaryAnalysis != null and accidentCausesPreliminaryAnalysis != ''">accident_causes_preliminary_analysis,</if> + <if test="accidentBriefProcess != null and accidentBriefProcess != ''">accident_brief_process,</if> + <if test="casualties != null ">casualties,</if> + <if test="accidentCause != null and accidentCause != ''">accident_cause,</if> + <if test="occurrenceTime != null ">occurrence_time,</if> + <if test="occurrencePlace != null and occurrencePlace != ''">occurrence_place,</if> + <if test="accidentDepartmentId != null ">accident_department_id,</if> + <if test="accidentName != null and accidentName != ''">accident_name,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null ">#{id},</if> + <if test="delFlag != null ">#{delFlag},</if> + <if test="gmtCreate != null ">#{gmtCreate},</if> + <if test="gmtModitify != null ">#{gmtModitify},</if> + <if test="createUid != null ">#{createUid},</if> + <if test="updateUid != null ">#{updateUid},</if> + <if test="emergencyPrecautions != null and emergencyPrecautions != ''">#{emergencyPrecautions},</if> + <if test="accidentCausesPreliminaryAnalysis != null and accidentCausesPreliminaryAnalysis != ''">#{accidentCausesPreliminaryAnalysis},</if> + <if test="accidentBriefProcess != null and accidentBriefProcess != ''">#{accidentBriefProcess},</if> + <if test="casualties != null ">#{casualties},</if> + <if test="accidentCause != null and accidentCause != ''">#{accidentCause},</if> + <if test="occurrenceTime != null ">#{occurrenceTime},</if> + <if test="occurrencePlace != null and occurrencePlace != ''">#{occurrencePlace},</if> + <if test="accidentDepartmentId != null ">#{accidentDepartmentId},</if> + <if test="accidentName != null and accidentName != ''">#{accidentName},</if> + </trim> + </insert> + + + <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentExpressInfoDetailDO" id="AccidentExpressInfoDetailDOResult"> + <id column="id" property="id" jdbcType="BIGINT"/> + <result column="emergency_precautions" property="emergencyPrecautions"/> + <result column="accident_causes_preliminary_analysis" property="accidentCausesPreliminaryAnalysis"/> + <result column="accident_brief_process" property="accidentBriefProcess"/> + <result column="casualties" property="casualties"/> + <result column="accident_cause" property="accidentCause"/> + <result column="occurrence_time" property="occurrenceTime"/> + <result column="occurrence_place" property="occurrencePlace"/> + <result column="accident_department_id" property="accidentDepartmentId"/> + <result column="accident_name" property="accidentName"/> + </resultMap> + + <select id="selectAccidentExpressById" resultMap="AccidentExpressInfoDetailDOResult"> + select id ,`emergency_precautions`,`accident_causes_preliminary_analysis`,`accident_brief_process`,`casualties`,accident_cause, + occurrence_time ,occurrence_place ,accident_department_id ,accident_name from accident_express + where del_flag = 0 and id = #{id} + </select> + + <update id="updateAccidentExpress" parameterType="com.gkhy.safePlatform.incidentManage.entity.AccidentExpressInfo"> + update accident_express + <trim prefix="SET" suffixOverrides=","> + <if test="gmtModitify != null ">gmt_moditify = #{gmtModitify},</if> + <if test="updateUid != null ">update_uid = #{updateUid},</if> + <if test="emergencyPrecautions != null and emergencyPrecautions != ''">emergency_precautions = #{emergencyPrecautions},</if> + <if test="accidentCausesPreliminaryAnalysis != null and accidentCausesPreliminaryAnalysis != ''"> accident_causes_preliminary_analysis= #{accidentCausesPreliminaryAnalysis},</if> + <if test="accidentBriefProcess != null and accidentBriefProcess != ''">accident_brief_process = #{accidentBriefProcess},</if> + <if test="casualties != null ">casualties = #{casualties},</if> + <if test="accidentCause != null and accidentCause != ''">accident_cause = #{accidentCause},</if> + <if test="occurrenceTime != null ">occurrence_time = #{occurrenceTime},</if> + <if test="occurrencePlace != null and occurrencePlace != ''">occurrence_place = #{occurrencePlace},</if> + <if test="accidentDepartmentId != null ">accident_department_id = #{accidentDepartmentId},</if> + <if test="accidentName != null and accidentName != ''">accident_name = #{accidentName},</if> + </trim> + where id = #{id} + </update> + + <update id="deleteAccidentExpressById"> + update accident_express set del_flag = 1 where id = #{id} + </update> </mapper> diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java index 7f2c413..c06d0bd 100644 --- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java +++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/exception/GlobalExceptionHandler.java @@ -6,6 +6,7 @@ import com.gkhy.safePlatform.commons.exception.BusinessException; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.emergency.excepiton.EmergencyException; +import com.gkhy.safePlatform.incidentManage.exception.AccidentException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.access.AccessDeniedException; @@ -20,6 +21,17 @@ private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + /** + * 事故管理自定义异常 + */ + @ResponseBody + @ExceptionHandler(value = AccidentException.class) + public ResultVO AHandler(AccidentException e) { + logger.warn(e.getMessage()); + return new ResultVO(e.getCode(),e.getMessage()); + } + /** * 应急预案自定义异常 */ -- Gitblit v1.9.2