From 0414ddb0b2b3a7199ae6181a770f97ac140dbd73 Mon Sep 17 00:00:00 2001 From: zhangf <1603559716@qq.com> Date: 星期三, 08 五月 2024 16:46:22 +0800 Subject: [PATCH] spi统计 --- incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml | 215 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 207 insertions(+), 8 deletions(-) diff --git a/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml index 9b6c808..94ea4c4 100644 --- a/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml +++ b/incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml @@ -14,8 +14,22 @@ </resultMap> <select id="selectAccidentReportList" resultMap="AccidentReportInfoPageDOResult"> - select id,`accident_express_id`,`accident_type`,`accident_grade` , status from accident_report where del_flag = 0 - <if test="query.status != null and query.status != ''">and `status` = #{query.status}</if> + SELECT + a.id, + a.`accident_express_id`, + a.`accident_type`, + a.`accident_grade`, + a.`status`, + b.accident_name as accidentName, + b.accident_department_id as accidentDepartmentId, + b.occurrence_place as occurrencePlace, + b.occurrence_time as occurrenceTime + FROM + accident_report a + LEFT JOIN accident_express b ON a.accident_express_id = b.id + WHERE + a.del_flag = 0 + <if test="query.status != null and query.status != ''">and a.`status` = #{query.status}</if> </select> <insert id="addAccidentReport" parameterType="com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo" @@ -47,6 +61,7 @@ <if test="accidentHandling != null and accidentHandling != ''">accident_handling,</if> <if test="fillInUserUid != null ">fill_in_user_uid,</if> <if test="fillInTime != null ">fill_in_time,</if> + <if test="fillInUserName != null and fillInUserName != ''">fill_in_user_name,</if> <if test="relevantPersonnelRecords != null and relevantPersonnelRecords != ''">relevant_personnel_records,</if> <if test="otherMaterials != null and otherMaterials != ''">other_materials,</if> </trim> @@ -75,6 +90,7 @@ <if test="accidentHandling != null and accidentHandling != ''">#{accidentHandling},</if> <if test="fillInUserUid != null ">#{fillInUserUid},</if> <if test="fillInTime != null ">#{fillInTime},</if> + <if test="fillInUserName != null and fillInUserName != ''">#{fillInUserName},</if> <if test="relevantPersonnelRecords != null and relevantPersonnelRecords != ''">#{relevantPersonnelRecords},</if> <if test="otherMaterials != null and otherMaterials != ''">#{otherMaterials},</if> </trim> @@ -100,18 +116,44 @@ <result column="rectification_measures" property="rectificationMeasures"/> <result column="accident_handling" property="accidentHandling"/> <result column="fill_in_user_uid" property="fillInUserUid"/> + <result column="fill_in_user_name" property="fillInUserName"/> <result column="fill_in_time" property="fillInTime"/> <result column="relevant_personnel_records" property="relevantPersonnelRecords"/> <result column="other_materials" property="otherMaterials"/> </resultMap> <select id="selectAccidentReportById" resultMap="AccidentReportInfoDetailDOResult"> - select id ,status ,`accident_express_id`,`accident_type`,`accident_grade`,`economic_loss`,minor_injury_num ,serious_injury_num , - `death_num`,`accident_cause`,`report_deadline`,`accident_level`,accident_delay_apply ,comprehensive_analysis_direct , - `comprehensive_analysis_indirect`,`rectification_measures`,`accident_handling`,`fill_in_user_uid`,fill_in_time, - `relevant_personnel_records`,`other_materials` - from accident_report - where del_flag = 0 and id = #{id} + SELECT + a.id, + a.STATUS, + a.`accident_express_id`, + a.`accident_type`, + a.`accident_grade`, + a.`economic_loss`, + a.minor_injury_num, + a.serious_injury_num, + a.`death_num`, + a.`accident_cause`, + a.`report_deadline`, + a.`accident_level`, + a.accident_delay_apply, + a.comprehensive_analysis_direct, + a.`comprehensive_analysis_indirect`, + a.`rectification_measures`, + a.`accident_handling`, + a.`fill_in_user_uid`, + a.fill_in_time, + a.fill_in_user_name, + a.`relevant_personnel_records`, + a.`other_materials`, + b.accident_name AS accidentName, + b.accident_department_id AS accidentDepartmentId, + b.occurrence_place AS occurrencePlace, + b.occurrence_time AS occurrenceTime + FROM + accident_report a + LEFT JOIN accident_express b ON a.accident_express_id = b.id + WHERE a.del_flag = 0 and a.id = #{id} </select> <update id="updateAccidentReport" parameterType="com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo"> @@ -138,6 +180,7 @@ <if test="accidentHandling != null and accidentHandling != ''">accident_handling = #{accidentHandling},</if> <if test="fillInUserUid != null ">fill_in_user_uid = #{fillInUserUid},</if> <if test="fillInTime != null ">fill_in_time = #{fillInTime},</if> + <if test="fillInUserName != null and fillInUserName != ''">fill_in_user_name = #{fillInUserName},</if> <if test="relevantPersonnelRecords != null and relevantPersonnelRecords != ''">relevant_personnel_records = #{relevantPersonnelRecords},</if> <if test="otherMaterials != null and otherMaterials != ''">other_materials = #{otherMaterials},</if> </trim> @@ -147,4 +190,160 @@ <update id="deleteAccidentReportById"> update accident_report set del_flag = 1 where id = #{id} </update> + + + <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentReportCount" + id="emergencyDrillExecuteCountChart"> + <result column="num" property="num"/> + <result column="name" property="name"/> + <result column="minorInjuryNum" property="minorInjuryNum"/> + <result column="seriousInjuryNum" property="seriousInjuryNum"/> + <result column="deathNum" property="deathNum"/> + <result column="economicLoss" property="economicLoss"/> + </resultMap> + <select id="selectByTimeAndType" resultMap="emergencyDrillExecuteCountChart"> + SELECT + accident_level AS `name`, + count( 0 ) AS num, + sum( economic_loss ) AS economicLoss, + sum( minor_injury_num ) AS minorInjuryNum, + sum( serious_injury_num ) AS seriousInjuryNum, + sum( death_num ) AS deathNum + FROM + `accident_report` + WHERE + del_flag = 0 + AND gmt_create <![CDATA[ >= ]]> #{query.startTime} + AND gmt_create <![CDATA[ <= ]]> #{query.endTime} + <if test="query.level != null and query.level != ''" >and accident_level = #{query.level}</if> + GROUP BY + accident_level + </select> + + <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentReportCountRPC" + id="accidentReportCountRPC"> + <result column="time" property="time"/> + <result column="num" property="num"/> + <result column="level" property="level"/> + <result column="minorInjuryNum" property="minorInjuryNum"/> + <result column="seriousInjuryNum" property="seriousInjuryNum"/> + <result column="deathNum" property="deathNum"/> + <result column="economicLoss" property="economicLoss"/> + </resultMap> + <select id="getCountForRPCByDeptIdAndMonth" resultMap="accidentReportCountRPC"> + SELECT + DATE_FORMAT( a.gmt_create, '%m' ) as time, + a.accident_level AS `level`, + count( 0 ) AS num, + sum( a.economic_loss ) AS economicLoss, + sum( a.minor_injury_num ) AS minorInjuryNum, + sum( a.serious_injury_num ) AS seriousInjuryNum, + sum( a.death_num ) AS deathNum + FROM + `accident_report` a + INNER JOIN `accident_express` b ON a.accident_express_id = b.id + AND b.accident_department_id = #{deptId} + WHERE + a.del_flag = 0 + AND a.gmt_create <![CDATA[ >= ]]> #{startTime} + AND a.gmt_create <![CDATA[ <= ]]> #{endTime} + GROUP BY + DATE_FORMAT( a.gmt_create, '%Y-%m' ), + a.accident_level, + DATE_FORMAT( a.gmt_create, '%m' ) + </select> + + <select id="getCountForRPCByDeptIdAndDay" resultMap="accidentReportCountRPC"> + SELECT + DATE_FORMAT( a.gmt_create, '%d' ) as time, + a.accident_level AS `level`, + count( 0 ) AS num, + sum( a.economic_loss ) AS economicLoss, + sum( a.minor_injury_num ) AS minorInjuryNum, + sum( a.serious_injury_num ) AS seriousInjuryNum, + sum( a.death_num ) AS deathNum + FROM + `accident_report` a + INNER JOIN `accident_express` b ON a.accident_express_id = b.id + AND b.accident_department_id = #{deptId} + WHERE + a.del_flag = 0 + AND a.gmt_create <![CDATA[ >= ]]> #{startTime} + AND a.gmt_create <![CDATA[ <= ]]> #{endTime} + GROUP BY + DATE_FORMAT( a.gmt_create, '%Y-%m-%d' ), + a.accident_level, + DATE_FORMAT( a.gmt_create, '%d' ) + </select> + + <select id="getAccidentCountByDeptIdsAndTime" resultType="com.gkhy.safePlatform.incidentManage.entity.AccidentResultCountDO"> + SELECT + count( 0 ) AS accidentCount, + sum( a.economic_loss ) AS economicLoss, + sum( a.minor_injury_num ) AS minorInjuryCount, + sum( a.serious_injury_num ) AS seriousInjuryCount, + sum( a.death_num ) AS deathCount, + a.accident_level AS accidentLevel, + DATE_FORMAT( a.gmt_create, '%m' ) AS month, + DATE_FORMAT( a.gmt_create, '%Y' ) AS year, + b.accident_department_id AS deptId + FROM + `accident_report` a + INNER JOIN `accident_express` b ON a.accident_express_id = b.id + WHERE + a.del_flag = 0 + AND b.accident_department_id IN + <foreach collection="deptIds" item="deptId" open="(" close=")" separator=","> + #{deptId} + </foreach> + AND DATE( a.gmt_create ) BETWEEN #{startTime} + AND #{endTime} + GROUP BY + a.accident_level, + DATE_FORMAT( a.gmt_create, '%Y-%m' ), + DATE_FORMAT( a.gmt_create, '%m' ), + DATE_FORMAT( a.gmt_create, '%Y' ), + b.accident_department_id + </select> + <select id="getAccidentCountByDeptIdAndTime" resultType="com.gkhy.safePlatform.incidentManage.entity.AccidentResultCountDO"> + SELECT + count( 0 ) AS accidentCount, + sum( a.economic_loss ) AS economicLoss, + sum( a.minor_injury_num ) AS minorInjuryCount, + sum( a.serious_injury_num ) AS seriousInjuryCount, + sum( a.death_num ) AS deathCount, + a.accident_level AS accidentLevel, + DATE_FORMAT( a.gmt_create, '%m' ) AS month + FROM + `accident_report` a + INNER JOIN `accident_express` b ON a.accident_express_id = b.id + WHERE + a.del_flag = 0 + AND b.accident_department_id = #{deptId} + AND DATE( a.gmt_create ) BETWEEN #{startTime} + AND #{endTime} + GROUP BY + a.accident_level, + DATE_FORMAT( a.gmt_create, '%Y-%m' ), + DATE_FORMAT( a.gmt_create, '%m' ) + </select> + + <select id="getCountByAccidentGrade" resultType="com.gkhy.safePlatform.incidentManage.entity.AccidentStatisticCountDO"> + SELECT + a.accident_grade, + count( id ) count + FROM + accident_report a + WHERE + a.del_flag = 0 + <if test="year != null"> + AND YEAR ( a.gmt_create ) = #{year} + </if> + <if test="month != null"> + AND MONTH ( a.gmt_create ) = #{month} + </if> + GROUP BY + a.accident_grade + </select> + </mapper> -- Gitblit v1.9.2