integrated_traffic/src/main/resources/mybatis/datasource/comprehensive/TrafficSecurityCommitmentMa...

191 lines
5.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.zcloud.mapper.datasource.comprehensive.TrafficSecurityCommitmentMapper">
<!--表名 -->
<sql id="tableName">
BUS_TRAFFIC_SECURITY_COMMITMENT
</sql>
<!--数据字典表名 -->
<sql id="dicTableName">
SYS_DICTIONARIES
</sql>
<!-- 字段 -->
<sql id="Field">
f.SECURITYCOMMITMENT_ID,
f.COMMITMENTNAME,
f.COMPLETIONSTATUS,
f.VALIDSTATUS,
f.OPERATINGCOMPANY,
f.OPERATINGTYPE,
f.EXPIRYDATE,
f.PRACTITIONER,
f.ATTACHMENT_ROUTE,
f.USER_ID,
f.CONTENT,
f.ISDELETE,
f.DELETOR,
f.DELETORNAME,
f.DELETETIME,
f.CREATOR,
f.CREATORNAME,
f.CREATETIME,
f.OPERATOR,
f.OPERATORNAME,
f.OPERATTIME
</sql>
<!-- 字段用于新增 -->
<sql id="Field2">
SECURITYCOMMITMENT_ID,
COMMITMENTNAME,
COMPLETIONSTATUS,
VALIDSTATUS,
OPERATINGCOMPANY,
OPERATINGTYPE,
EXPIRYDATE,
PRACTITIONER,
ATTACHMENT_ROUTE,
USER_ID,
CONTENT,
ISDELETE,
DELETOR,
DELETORNAME,
DELETETIME,
CREATOR,
CREATORNAME,
CREATETIME,
OPERATOR,
OPERATORNAME,
OPERATTIME
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{SECURITYCOMMITMENT_ID},
#{COMMITMENTNAME},
#{COMPLETIONSTATUS},
#{VALIDSTATUS},
#{OPERATINGCOMPANY},
#{OPERATINGTYPE},
#{EXPIRYDATE},
#{PRACTITIONER},
#{ATTACHMENT_ROUTE},
#{USER_ID},
#{CONTENT},
#{ISDELETE},
#{DELETOR},
#{DELETORNAME},
#{DELETETIME},
#{CREATOR},
#{CREATORNAME},
#{CREATETIME},
#{OPERATOR},
#{OPERATORNAME},
#{OPERATTIME}
</sql>
<!-- 新增-->
<insert id="save" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field2"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
OPERATOR = #{OPERATOR},
OPERATORNAME = #{OPERATORNAME},
OPERATTIME = #{OPERATTIME},
EXPIRYDATE = #{EXPIRYDATE},
CONTENT = #{CONTENT},
ATTACHMENT_ROUTE=#{ATTACHMENT_ROUTE}
<if test="VALIDSTATUS != null">
, VALIDSTATUS = #{VALIDSTATUS}
</if>
where SECURITYCOMMITMENT_ID = #{SECURITYCOMMITMENT_ID}
</update>
<!-- 删除-->
<delete id="delete" parameterType="pd">
update
<include refid="tableName"></include>
set
ISDELETE = '1',
DELETOR = #{DELETOR},
DELETETIME = #{DELETETIME}
where
SECURITYCOMMITMENT_ID = #{SECURITYCOMMITMENT_ID}
</delete>
<!--列表-->
<select id="datalistPage" parameterType="page" resultType="pd">
SELECT
u.NAME,
u.USER_ID,
i.CORP_NAME,
c.COMMITMENTNAME,
c.COMPLETIONSTATUS,
c.VALIDSTATUS,
c.EXPIRYDATE,
c.CREATETIME,
c.OPERATTIME,
c.CONTENT,
c.ISDELETE,
c.ATTACHMENT_ROUTE,
c.SECURITYCOMMITMENT_ID
FROM
sys_user u
left JOIN bus_corp_info i ON u.CORPINFO_ID = i.CORPINFO_ID
left JOIN BUS_TRAFFIC_SECURITY_COMMITMENT c ON u.USER_ID = c.USER_ID and c.ISDELETE !='1'
WHERE
u.ISDELETE = '0'
and (c.ISDELETE='0' or c.ISDELETE is null )
AND u.ISMAIN != '1'
AND ( c.VALIDSTATUS != '2' OR c.VALIDSTATUS IS NULL )
<if test="pd.COMMITMENTNAME != null and pd.COMMITMENTNAME != ''">
and c.COMMITMENTNAME like CONCAT('%',#{pd.COMMITMENTNAME},'%')
</if>
<if test="pd.COMPLETIONSTATUS != null and pd.COMPLETIONSTATUS != ''">
and COALESCE(c.COMPLETIONSTATUS, '0') = #{pd.COMPLETIONSTATUS}
</if>
<if test="pd.VALIDSTATUS != null and pd.VALIDSTATUS != ''">
and COALESCE(c.VALIDSTATUS, '0') = #{pd.VALIDSTATUS}
</if>
</select>
<select id="findById" resultType="com.zcloud.entity.PageData" parameterType="com.zcloud.entity.PageData">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where
f.SECURITYCOMMITMENT_ID = #{SECURITYCOMMITMENT_ID}
</select>
<select id="datalistPageUser" parameterType="page" resultType="pd">
select
f.*,
i.CORP_NAME,
u.NAME
from
<include refid="tableName"></include> f
left join bus_corp_info i on f.OPERATINGCOMPANY = i.CORPINFO_ID
left join sys_user u on f.USER_ID = u.USER_ID
where f.ISDELETE = '0'
<if test="pd.USER_ID != null and pd.USER_ID != ''">
and f.USER_ID = #{pd.USER_ID}
</if>
</select>
</mapper>