qa-prevention-gwj/src/main/resources/mybatis/datasource/bus/RiskUnitMapper.xml

275 lines
7.2 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.bus.RiskUnitMapper">
<!--表名 -->
<sql id="tableName">
BUS_RISKUNIT
</sql>
<!--数据字典表名 -->
<sql id="dicTableName">
SYS_DICTIONARIES
</sql>
<!-- 字段 -->
<sql id="Field">
f.RISKUNITNAME,
f.CORPINFO_ID,
f.CREATOR,
f.CREATTIME,
f.OPERATOR,
f.OPERATTIME,
f.ISDELETE,
f.RISKUNIT_ID,
f.DEPARTMENT_ID
</sql>
<!-- 字段用于新增 -->
<sql id="Field2">
RISKUNITNAME,
CORPINFO_ID,
CREATOR,
CREATTIME,
OPERATOR,
OPERATTIME,
ISDELETE,
RISKUNIT_ID,
DEPARTMENT_ID
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{RISKUNITNAME},
#{CORPINFO_ID},
#{CREATOR},
#{CREATTIME},
#{OPERATOR},
#{OPERATTIME},
#{ISDELETE},
#{RISKUNIT_ID},
#{DEPARTMENT_ID}
</sql>
<!-- 新增-->
<insert id="save" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field2"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
<!-- 删除-->
<delete id="delete" parameterType="pd">
update
<include refid="tableName"></include>
set
ISDELETE = '1',
OPERATOR = #{OPERATOR},
OPERATTIME = #{OPERATTIME}
where
RISKUNIT_ID = #{RISKUNIT_ID}
</delete>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
RISKUNITNAME = #{RISKUNITNAME},
OPERATOR = #{OPERATOR},
OPERATTIME = #{OPERATTIME},
DEPARTMENT_ID=#{DEPARTMENT_ID},
RISKUNIT_ID = RISKUNIT_ID
where
RISKUNIT_ID = #{RISKUNIT_ID}
</update>
<!-- 通过ID获取数据 -->
<select id="findById" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>,
de.NAME as DEPT_NAME
from
<include refid="tableName"></include> f
left join OA_DEPARTMENT de on de.DEPARTMENT_ID = f.DEPARTMENT_ID
where
f.RISKUNIT_ID = #{RISKUNIT_ID}
</select>
<select id="findByName" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
left join OA_DEPARTMENT de on de.DEPARTMENT_ID = f.DEPARTMENT_ID
where 1=1 and f.ISDELETE = '0'
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
and f.CORPINFO_ID = #{CORPINFO_ID}
</if>
<if test="RISKUNITNAME != null and RISKUNITNAME != ''"><!-- 重名验证专用 -->
AND
f.RISKUNITNAME = #{RISKUNITNAME}
</if>
<if test="DEPARTMENT_ID != null and DEPARTMENT_ID != ''"><!-- 重名验证专用 -->
AND
f.DEPARTMENT_ID = #{DEPARTMENT_ID}
</if>
<if test="DEPARTMENT_NAME != null and DEPARTMENT_NAME != ''"><!-- 重名验证专用 -->
AND
de.NAME = #{DEPARTMENT_NAME}
</if>
</select>
<!-- 列表 -->
<select id="datalistPage" parameterType="page" resultType="pd">
select
<include refid="Field"></include>,
de.NAME as DEPT_NAME,
de.HEADMAN as HEADMAN,
su.NAME as HEADMANNAME,
c.CORP_NAME as CORP_NAME
from
<include refid="tableName"></include> f
left join OA_DEPARTMENT de on de.DEPARTMENT_ID = f.DEPARTMENT_ID
left join bus_corp_info c on c.CORPINFO_ID = de.CORPINFO_ID
left join sys_user su on su.USER_ID = de.HEADMAN
where f.ISDELETE = '0'
<if test="pd.roleLevel != null and pd.roleLevel != ''"><!-- 权限显示 -->
<choose>
<when test='pd.roleLevel == "0"'>
</when>
<when test='pd.roleLevel == "1"'>
and f.DEPARTMENT_ID in (${pd.supDeparIds})
</when>
<when test='pd.roleLevel == "2"'>
and f.CREATOR = #{pd.loginUserId}
</when>
</choose>
</if>
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 关键词检索 -->
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test="pd.DEPARTMENT_ID != null and pd.DEPARTMENT_ID != ''"><!-- 关键词检索 -->
and f. DEPARTMENT_ID=#{pd.DEPARTMENT_ID}
</if>
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
and
(
f.RISKUNITNAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
<!-- or -->
<!-- 字段2 LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%') -->
)
</if>
order by f.OPERATTIME desc
</select>
<!-- 列表(全部) -->
<select id="listAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>,
c.CORP_NAME,
de.NAME as DEPT_NAME
from
<include refid="tableName"></include> f
left join BUS_CORP_INFO c on c.CORPINFO_ID = f.CORPINFO_ID
left join OA_DEPARTMENT de on de.DEPARTMENT_ID = f.DEPARTMENT_ID
where f.ISDELETE = '0'
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
and f.CORPINFO_ID = #{CORPINFO_ID}
</if>
<if test="CHECK_NAME != null and CHECK_NAME != ''"><!-- 重名验证专用 -->
AND
f.RISKUNITNAME = #{CHECK_NAME}
</if>
<if test="DEPARTMENT_ID != null and DEPARTMENT_ID != ''"><!-- 重名验证专用 -->
AND
f.DEPARTMENT_ID = #{DEPARTMENT_ID}
</if>
order by f.OPERATTIME desc
</select>
<!-- 列表(全部) -->
<select id="listonly" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>,
c.CORP_NAME,
de.NAME as DEPT_NAME
from
<include refid="tableName"></include> f
left join BUS_CORP_INFO c on c.CORPINFO_ID = f.CORPINFO_ID
left join OA_DEPARTMENT de on de.DEPARTMENT_ID = f.DEPARTMENT_ID
where f.ISDELETE = '0'
and f.RISKUNIT_ID in
<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
#{item}
</foreach>
<if test="CHECK_NAME != null and CHECK_NAME != ''"><!-- 重名验证专用 -->
AND
f.RISKUNITNAME = #{CHECK_NAME}
</if>
<if test="DEPARTMENT_ID != null and DEPARTMENT_ID != ''"><!-- 重名验证专用 -->
AND
f.DEPARTMENT_ID = #{DEPARTMENT_ID}
</if>
order by f.OPERATTIME desc
</select>
<!-- 列表(首页) -->
<select id="listIndexAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>,
c.CORP_NAME,
de.NAME as DEPT_NAME
from
<include refid="tableName"></include> f
left join BUS_CORP_INFO c on c.CORPINFO_ID = f.CORPINFO_ID
left join OA_DEPARTMENT de on de.DEPARTMENT_ID = f.DEPARTMENT_ID
where f.ISDELETE = '0'
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
and f.CORPINFO_ID = #{CORPINFO_ID}
</if>
<!--group by f.RISKUNITNAME -->
order by f.OPERATTIME desc
</select>
<!-- 批量删除 -->
<delete id="deleteAll" parameterType="String">
update
<include refid="tableName"></include>
set
ISDELETE = '1'
where
RISKUNIT_ID in
<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- 点击风险单元名称 整理详情 -->
<select id="getRisByUnitId" parameterType="page" resultType="pd">
select
f.IDENTIFICATION_ID,
i.PARTSNAME,
f.risk_descr,
f.LEVELID,
f.EME_MEASURES,
f.MEASURES,
f.ACCIDENTS,
f.ACCIDENTS_NAME,
f.EME_MEASURES
FROM
BUS_RISKPOINT f
LEFT JOIN bus_identificationparts i ON f.IDENTIFICATION_ID = i.IDENTIFICATIONPARTS_ID
WHERE
1 = 1
AND f.RISK_UNIT_ID = #{pd.RISK_UNIT_ID}
and f.ISDELETE =0
and i.ISDELETE =0
order by f.OPERATTIME desc
</select>
</mapper>