wit-park-backend/hbt-safety-supervision/hbt-safety-supervision-biz/src/main/resources/mapper/HazardousOperationMapper.xml

110 lines
6.1 KiB
XML

<?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.hbt.safety.supervision.mapper.HazardousOperationMapper">
<resultMap type="com.hbt.safety.supervision.pojo.HazardousOperation" id="HazardousOperationResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="operationLevel" column="operation_level" />
<result property="enterpriseId" column="enterprise_id" />
<result property="operationContent" column="operation_content" />
<result property="operationLongitude" column="operation_longitude" />
<result property="operationLatitude" column="operation_latitude" />
<result property="operationType" column="operation_type" />
<result property="operationStart" column="operation_start" />
<result property="operationEnd" column="operation_end" />
<result property="operationSite" column="operation_site" />
</resultMap>
<sql id="selectHazardousOperationVo">
select id, name, operation_longitude, operation_latitude, operation_type, operation_start, operation_end, operation_site from hazardous_operation
</sql>
<select id="selectHazardousOperationList" parameterType="com.hbt.safety.supervision.pojo.HazardousOperation" resultMap="HazardousOperationResult">
<include refid="selectHazardousOperationVo"/>
</select>
<sql id="selectHazardousOperation">
select distinct(a.id) id, a.name name, a.operation_level operationLevel, a.enterprise_id enterpriseId, a.operation_content operationContent, a.operation_type operationType, a.operation_start operationStart, a.operation_end operationEnd,a.operation_site operationSite,
e.name
from hazardous_operation as a
left join enterprise_information as e on a.enterprise_id = e.id
</sql>
<select id="selectHazardousOperationById" parameterType="Integer" resultMap="HazardousOperationResult">
<include refid="selectHazardousOperation"/>
where a.id = #{id}
</select>
<insert id="insertHazardousOperation" parameterType="com.hbt.safety.supervision.pojo.HazardousOperation">
insert into hazardous_operation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="name != null">name,</if>
<if test="operationLevel != null">operation_level,</if>
<if test="enterpriseId != null">enterprise_id,</if>
<if test="operationContent != null">operation_content,</if>
<if test="operationLongitude != null">operation_longitude,</if>
<if test="operationLatitude != null">operation_latitude,</if>
<if test="operationType != null">operation_type,</if>
<if test="operationStart != null">operation_start,</if>
<if test="operationEnd != null">operation_end,</if>
<if test="operationSite != null">operation_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="name != null">#{name},</if>
<if test="operationLevel != null">#{operationLevel},</if>
<if test="enterpriseId != null">#{enterpriseId},</if>
<if test="operationContent != null">#{operationContent},</if>
<if test="operationLongitude != null">#{operationLongitude},</if>
<if test="operationLatitude != null">#{operationLatitude},</if>
<if test="operationType != null">#{operationType},</if>
<if test="operationStart != null">#{operationStart},</if>
<if test="operationEnd != null">#{operationEnd},</if>
<if test="operationSite != null">#{operationSite},</if>
</trim>
</insert>
<update id="updateHazardousOperation" parameterType="com.hbt.safety.supervision.pojo.HazardousOperation">
update hazardous_operation
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="operationLevel != null">operation_level = #{operationLevel},</if>
<if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
<if test="operationContent != null">operation_content = #{operationContent},</if>
<if test="operationLongitude != null">operation_longitude = #{operationLongitude},</if>
<if test="operationLatitude != null">operation_latitude = #{operationLatitude},</if>
<if test="operationType != null">operation_type = #{operationType},</if>
<if test="operationStart != null">operation_start = #{operationStart},</if>
<if test="operationEnd != null">operation_end = #{operationEnd},</if>
<if test="operationSite != null">operation_site = #{operationSite},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteHazardousOperationById" parameterType="Integer">
delete from hazardous_operation where id = #{id}
</delete>
<delete id="deleteHazardousOperationByIds" parameterType="String">
delete from hazardous_operation where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectHazardousOperations" resultType="com.hbt.safety.supervision.pojo.HazardousOperation">
select id,operation_type operationType,operation_start operationStart ,operation_end operationEnd,enterprise_id enterpriseId from hazardous_operation
</select>
<select id="hazardousOperationManagement" resultType="HazardousOperation">
select name,operation_start operationStart ,operation_end operationEnd from hazardous_operation
</select>
<select id="hazardousOperationVariationTendency" resultType="java.util.Date">
select operation_end from hazardous_operation where DATE_FORMAT(operation_start,'%Y-%m-%d') >= DATE_FORMAT(#{yearAgo},'%Y-%m-%d')
</select>
</mapper>