<?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.emergency.repository.EmergencyDrillExecuteInfoRepository">
|
|
<resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoPageDO"
|
id="emergencyDrillExecuteInfoPageDOResult">
|
<id column="id" property="id" jdbcType="BIGINT"/>
|
<result column="status" property="status"/>
|
<result column="drill_record_date" property="drillRecordDate"/>
|
<result column="drill_plan_id" property="drillPlanId"/>
|
<result column="record_user_uid" property="recordUserUid"/>
|
<result column="process_desc" property="processDesc"/>
|
</resultMap>
|
|
<select id="selectEmergencyDrillExecuteList" resultMap="emergencyDrillExecuteInfoPageDOResult">
|
SELECT
|
a.id,
|
a.drill_plan_id,
|
b.drill_name as drillName,
|
b.drill_address as drillAddress,
|
b.drill_way as drillWay,
|
b.drill_level as drillLevel,
|
b.drill_plan_date as drillPlanDate,
|
a.`drill_record_date`,
|
c.`name` as emergencyPlanName
|
FROM
|
emergency_drill_execute a
|
LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
|
LEFT JOIN emergency_plan c ON b.plan_id = c.id
|
WHERE
|
a.del_flag = 0
|
<if test="query.status != null">and a.status = #{query.status}</if>
|
</select>
|
|
<insert id="addEmergencyDrillExecute" parameterType="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfo"
|
keyProperty="id" useGeneratedKeys="true">
|
insert into emergency_drill_execute
|
<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="status != null ">status,</if>
|
<if test="drillRecordDate != null ">drill_record_date,</if>
|
<if test="drillPlanId != null ">drill_plan_id,</if>
|
<if test="recordUserUid != null ">record_user_uid,</if>
|
<if test="recordUserName != null and recordUserName != ''">`record_user_name`,</if>
|
<if test="processDesc != null and processDesc != ''">`process_desc`,</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="status != null ">#{status},</if>
|
<if test="drillRecordDate != null ">#{drillRecordDate},</if>
|
<if test="drillPlanId != null ">#{drillPlanId},</if>
|
<if test="recordUserUid != null ">#{recordUserUid},</if>
|
<if test="recordUserName != null and recordUserName != ''">#{recordUserName},</if>
|
<if test="processDesc != null and processDesc != ''">#{processDesc},</if>
|
</trim>
|
</insert>
|
|
|
<resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoDetailDO"
|
id="emergencyDrillExecuteInfoDetailDOResult">
|
<id column="id" property="id" jdbcType="BIGINT"/>
|
<result column="status" property="status"/>
|
<result column="drill_record_date" property="drillRecordDate"/>
|
<result column="drill_plan_id" property="drillPlanId"/>
|
<result column="record_user_uid" property="recordUserUid"/>
|
<result column="record_user_name" property="recordUserName"/>
|
<result column="process_desc" property="processDesc"/>
|
</resultMap>
|
|
<select id="selectEmergencyDrillExecuteById" resultMap="emergencyDrillExecuteInfoDetailDOResult">
|
SELECT
|
a.id,
|
a.`status`,
|
a.`drill_record_date`,
|
a.`drill_plan_id`,
|
a.`record_user_uid`,
|
a.record_user_name,
|
a.process_desc,
|
b.drill_name AS drillName
|
FROM
|
emergency_drill_execute a
|
LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
|
WHERE
|
a.del_flag = 0
|
AND a.id = #{id}
|
</select>
|
|
<update id="updateEmergencyDrillExecute" parameterType="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfo">
|
update emergency_drill_execute
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="gmtModitify != null ">gmt_moditify = #{gmtModitify},</if>
|
<if test="updateUid != null ">update_uid = #{updateUid},</if>
|
<if test="status != null ">status = #{status},</if>
|
<if test="drillRecordDate != null ">drill_record_date=#{drillRecordDate},</if>
|
<if test="drillPlanId != null ">drill_plan_id=#{drillPlanId},</if>
|
<if test="recordUserUid != null ">record_user_uid=#{recordUserUid},</if>
|
<if test="recordUserName != null and recordUserName != ''">record_user_name = #{recordUserName},</if>
|
<if test="processDesc != null and processDesc != ''">process_desc=#{processDesc},</if>
|
|
</trim>
|
where id = #{id}
|
</update>
|
|
<update id="deleteEmergencyDrillExecute">
|
update emergency_drill_execute set del_flag = 1 where id = #{id}
|
</update>
|
|
<update id="updateStatusById">
|
update emergency_drill_execute set status = 1 where id = #{drillExecuteId}
|
</update>
|
|
<select id="selectEmergencyDrillExecuteIntervalTime" resultType="java.lang.Integer">
|
SELECT datediff( now( ), ( SELECT max( gmt_create ) FROM `emergency_drill_execute` ) )
|
</select>
|
|
<resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountData"
|
id="emergencyDrillExecuteCountChart">
|
<result column="num" property="num"/>
|
<result column="name" property="name"/>
|
</resultMap>
|
|
<select id="selectByMonthAndDept" resultMap="emergencyDrillExecuteCountChart">
|
SELECT
|
count( 0 ) AS num,
|
DATE_FORMAT( a.gmt_create, '%Y-%m' ) AS `name`
|
FROM
|
`emergency_drill_execute` a
|
LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
|
WHERE
|
a.del_flag = 0
|
AND a.gmt_create <![CDATA[ >= ]]> #{startTime}
|
AND a.gmt_create <![CDATA[ <= ]]> #{endTime}
|
<if test="deptIds != null " >
|
and b.department_id in
|
<foreach item="id" collection="deptIds" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
GROUP BY
|
DATE_FORMAT( a.gmt_create, '%Y-%m' )
|
</select>
|
|
<select id="selectByYearAndDept" resultMap="emergencyDrillExecuteCountChart">
|
SELECT
|
count( 0 ) AS num,
|
DATE_FORMAT( a.gmt_create, '%Y' ) AS `name`
|
FROM
|
`emergency_drill_execute` a
|
LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
|
WHERE
|
a.del_flag = 0
|
AND a.gmt_create <![CDATA[ >= ]]> #{startTime}
|
AND a.gmt_create <![CDATA[ <= ]]> #{endTime}
|
<if test="deptIds != null " >
|
and b.department_id in
|
<foreach item="id" collection="deptIds" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
GROUP BY
|
DATE_FORMAT( a.gmt_create, '%Y' )
|
</select>
|
|
|
<resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountRPC"
|
id="emergencyDrillExecuteCountRPC">
|
<result column="num" property="num"/>
|
<result column="name" property="name"/>
|
</resultMap>
|
<select id="selectByDayAndDept" resultMap="emergencyDrillExecuteCountRPC">
|
SELECT
|
count( 0 ) AS num,
|
DATE_FORMAT( a.gmt_create, '%d' ) AS `name`
|
FROM
|
`emergency_drill_execute` a
|
LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
|
WHERE
|
a.del_flag = 0
|
AND a.gmt_create <![CDATA[ >= ]]> #{startTime}
|
AND a.gmt_create <![CDATA[ <= ]]> #{endTime}
|
<if test="deptIds != null " >
|
and b.department_id in
|
<foreach item="id" collection="deptIds" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
GROUP BY
|
DATE_FORMAT( a.gmt_create, '%Y-%m-%d' ),
|
DATE_FORMAT( a.gmt_create, '%d' )
|
</select>
|
|
<select id="selectByMonthAndDeptForIntegerMonth" resultMap="emergencyDrillExecuteCountRPC">
|
SELECT
|
count( 0 ) AS num,
|
DATE_FORMAT( a.gmt_create, '%m' ) AS `name`
|
FROM
|
`emergency_drill_execute` a
|
LEFT JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
|
WHERE
|
a.del_flag = 0
|
AND a.gmt_create <![CDATA[ >= ]]> #{startTime}
|
AND a.gmt_create <![CDATA[ <= ]]> #{endTime}
|
<if test="deptIds != null " >
|
and b.department_id in
|
<foreach item="id" collection="deptIds" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
GROUP BY
|
DATE_FORMAT( a.gmt_create, '%Y-%m' ),
|
DATE_FORMAT( a.gmt_create, '%m' )
|
</select>
|
|
|
<select id="selectEmergencyDrillExecuteIntervalTimeByDeptId" resultType="java.lang.String">
|
SELECT
|
DATE_FORMAT( max( a.gmt_create ), '%Y-%m-%d %H:%i:%s' ) AS lastTime
|
FROM
|
`emergency_drill_execute` a
|
INNER JOIN emergency_drill_plan b ON a.drill_plan_id = b.id
|
AND b.department_id = #{deptId}
|
</select>
|
|
</mapper>
|