integrated_traffic/src/main/resources/mybatis/datasource/hiddenDangerCheckStandard/CustomHiddenMapper.xml

3076 lines
113 KiB
XML
Raw Normal View History

2024-01-31 16:53:07 +08:00
<?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.hiddenDangerCheckStandard.CustomHiddenMapper">
<!--表名 -->
<sql id="tableName">
BUS_HIDDENDANGERCHECKSTANDARD_HIDDEN
</sql>
<!--数据字典表名 -->
<sql id="dicTableName">
SYS_DICTIONARIES
</sql>
<!-- 字段 -->
<sql id="Field">
f.SOURCE,
f.CHECK_CATEGORY,
f.CHECK_CATEGORY_NAME,
f.CHECK_ITEM,
f.CHECK_ITEM_NAME,
f.CHECK_CONTENT,
f.CHECK_STANDARD,
f.REFERENCE_BASIS,
f.HIDDENDESCR,
f.HIDDENPART,
f.CREATOR,
f.CREATTIME,
f.RECTIFYDESCR,
f.RECTIFICATIONTYPE,
f.RECTIFICATIONOR,
f.RECTIFICATIONTIME,
f.HIDDENLEVEL,
f.STATE,
f.CHECKDEPT,
f.CHECKOR,
f.CHECKTIME,
f.CHECKDESCR,
f.ISQUALIFIED,
f.ISDELETE,
f.CORPINFO_ID,
f.HIDDENFINDDEPT,
f.RECTIFICATIONDEADLINE,
f.RECTIFICATIONDEPT,
f.HIDDEN_ID,
f.CHECKRECORD_ID,
f.RECORDITEM_ID,
2024-01-31 16:55:54 +08:00
f.CUSTOM_ITEM_ID,
2024-01-31 16:53:07 +08:00
f.REVIEWOR,
f.REVIEWTIME,
f.REVIEWDEPT,
f.LONGITUDE,
f.LATITUDE,
f.HAVESCHEME,
f.HAVEPLAN,
f.HIDDENTYPE,
f.HIDDENTYPE1,
f.HIDDENTYPE2,
f.HIDDENTYPE3,
f.HIDDENTYPE_NAME,
f.ISCONFIRM,
f.CUSTOM_ID,
f.OPERATTIME,
f.HIDDEN_CATEGORY
</sql>
<!-- 字段用于新增 -->
<sql id="Field2">
SOURCE,
2024-02-01 16:46:11 +08:00
CHECK_CATEGORY,
2024-01-31 16:53:07 +08:00
CHECK_CATEGORY_NAME,
CHECK_ITEM,
CHECK_ITEM_NAME,
CHECK_CONTENT,
CHECK_STANDARD,
REFERENCE_BASIS,
HIDDENDESCR,
HIDDENPART,
CREATOR,
CREATTIME,
RECTIFYDESCR,
RECTIFICATIONTYPE,
RECTIFICATIONOR,
RECTIFICATIONTIME,
HIDDENLEVEL,
STATE,
CHECKDEPT,
CHECKOR,
CHECKTIME,
CHECKDESCR,
ISQUALIFIED,
ISDELETE,
CORPINFO_ID,
HIDDENFINDDEPT,
RECTIFICATIONDEADLINE,
RECTIFICATIONDEPT,
HIDDEN_ID,
CHECKRECORD_ID,
RECORDITEM_ID,
2024-01-31 16:55:54 +08:00
CUSTOM_ITEM_ID,
2024-01-31 16:53:07 +08:00
REVIEWOR,
REVIEWTIME,
REVIEWDEPT,
LONGITUDE,
LATITUDE,
HAVESCHEME,
HIDDENTYPE,
HIDDENTYPE1,
HIDDENTYPE2,
HIDDENTYPE3,
HIDDENTYPE_NAME,
ISCONFIRM,
CUSTOM_ID,
OPERATTIME,
HIDDEN_CATEGORY
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{SOURCE},
2024-02-01 16:46:11 +08:00
#{CHECK_CATEGORY},
2024-01-31 16:53:07 +08:00
#{CHECK_CATEGORY_NAME},
#{CHECK_ITEM},
#{CHECK_ITEM_NAME},
#{CHECK_CONTENT},
#{CHECK_STANDARD},
#{REFERENCE_BASIS},
#{HIDDENDESCR},
#{HIDDENPART},
#{CREATOR},
#{CREATTIME},
#{RECTIFYDESCR},
#{RECTIFICATIONTYPE},
#{RECTIFICATIONOR},
#{RECTIFICATIONTIME},
#{HIDDENLEVEL},
#{STATE},
#{CHECKDEPT},
#{CHECKOR},
#{CHECKTIME},
#{CHECKDESCR},
#{ISQUALIFIED},
#{ISDELETE},
#{CORPINFO_ID},
#{HIDDENFINDDEPT},
#{RECTIFICATIONDEADLINE},
#{RECTIFICATIONDEPT},
#{HIDDEN_ID},
#{CHECKRECORD_ID},
#{RECORDITEM_ID},
2024-01-31 16:55:54 +08:00
#{CUSTOM_ITEM_ID},
2024-01-31 16:53:07 +08:00
#{REVIEWOR},
#{REVIEWTIME},
#{REVIEWDEPT},
#{LONGITUDE},
#{LATITUDE},
#{HAVESCHEME},
#{HIDDENTYPE},
#{HIDDENTYPE1},
#{HIDDENTYPE2},
#{HIDDENTYPE3},
#{HIDDENTYPE_NAME},
#{ISCONFIRM},
#{CUSTOM_ID},
#{OPERATTIME},
#{HIDDEN_CATEGORY}
</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'
where
HIDDEN_ID = #{HIDDEN_ID}
</delete>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
RECTIFICATIONOR = #{RECTIFICATIONOR},
RECTIFICATIONDEPT= #{RECTIFICATIONDEPT}
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 修改信息 -->
<update id="editInfo" parameterType="pd">
update
<include refid="tableName"></include>
set
<if test="CHECK_CATEGORY != null and CHECK_CATEGORY != ''">
CHECK_CATEGORY = #{CHECK_CATEGORY},
</if>
<if test="CHECK_CATEGORY_NAME != null and CHECK_CATEGORY_NAME != ''">
CHECK_CATEGORY_NAME = #{CHECK_CATEGORY_NAME},
</if>
<if test="CHECK_ITEM != null and CHECK_ITEM != ''">
CHECK_ITEM = #{CHECK_ITEM},
</if>
<if test="CHECK_ITEM_NAME != null and CHECK_ITEM_NAME != ''">
CHECK_ITEM_NAME = #{CHECK_ITEM_NAME},
</if>
<if test="CHECK_CONTENT != null and CHECK_CONTENT != ''">
CHECK_CONTENT = #{CHECK_CONTENT},
</if>
<if test="CHECK_STANDARD != null and CHECK_STANDARD != ''">
CHECK_STANDARD = #{CHECK_STANDARD},
</if>
<if test="REFERENCE_BASIS != null and REFERENCE_BASIS != ''">
REFERENCE_BASIS = #{REFERENCE_BASIS},
</if>
<if test="HIDDEN_CATEGORY != null and HIDDEN_CATEGORY != ''">
HIDDEN_CATEGORY = #{HIDDEN_CATEGORY},
</if>
<if test="LEVEL != null and LEVEL != ''">
LEVEL = #{LEVEL},
</if>
<if test="HIDDENTYPE1 != null and HIDDENTYPE1 != ''">
HIDDENTYPE1 = #{HIDDENTYPE1},
HIDDENTYPE2 = #{HIDDENTYPE2},
HIDDENTYPE3 = #{HIDDENTYPE3},
HIDDENTYPE_NAME = #{HIDDENTYPE_NAME},
</if>
HIDDENDESCR = #{HIDDENDESCR},
HIDDENPART = #{HIDDENPART},
<if test="RECTIFYDESCR != null and RECTIFYDESCR != ''">
RECTIFYDESCR = #{RECTIFYDESCR},
</if>
RECTIFICATIONTYPE = #{RECTIFICATIONTYPE},
HIDDENLEVEL = #{HIDDENLEVEL},
CHECKDEPT = #{CHECKDEPT},
CHECKTIME = #{CHECKTIME},
CHECKDESCR = #{CHECKDESCR},
ISQUALIFIED = #{ISQUALIFIED},
RECTIFICATIONDEADLINE = #{RECTIFICATIONDEADLINE},
HIDDEN_ID = HIDDEN_ID,
RECTIFICATIONOR = #{RECTIFICATIONOR},
RECTIFICATIONDEPT= #{RECTIFICATIONDEPT}
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<update id="changeState" parameterType="pd">
update
<include refid="tableName"></include>
set
STATE = #{STATE},
OPERATTIME = #{OPERATTIME}
<if test="BUHEGE != null and BUHEGE != ''"><!-- 关键词检索 -->
,RECTIFYDESCR = null
,RECTIFICATIONTIME = null
</if>
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<update id="editISCONFIRM" parameterType="pd">
update
<include refid="tableName"></include>
set
ISCONFIRM = #{ISCONFIRM},
RECTIFICATIONDEPT = #{RECTIFICATIONDEPT},
RECTIFICATIONOR = #{RECTIFICATIONOR},
RECTIFICATIONDEADLINE = #{RECTIFICATIONDEADLINE}
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<update id="editHIDDENLEVEL" parameterType="pd">
update
<include refid="tableName"></include>
set
HIDDENLEVEL = #{HIDDENLEVEL}
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 提交隐患 -->
<update id="submit" parameterType="pd">
update
<include refid="tableName"></include>
set
STATE = (case when RECTIFICATIONTYPE = '2' and STATE='0' then '1' when RECTIFICATIONTYPE = '1' then '4' else STATE end)
where
CHECKRECORD_ID = #{CHECKRECORD_ID} and ISDELETE = '0'
</update>
<!-- 提交清单隐患 -->
<update id="submitList" parameterType="pd">
update
<include refid="tableName"></include>
set
STATE = (case RECTIFICATIONTYPE when '2' then '1' when '1' then '4' end)
<if test="CHECKRECORD_ID != null and CHECKRECORD_ID != ''">
, CHECKRECORD_ID = #{CHECKRECORD_ID}
</if>
where
CUSTOM_ID = #{CUSTOM_ID}
and (
RECORDITEM_ID is null or RECORDITEM_ID = ''
)
and (
2024-01-31 16:55:54 +08:00
CUSTOM_ITEM_ID is null or CUSTOM_ITEM_ID = ''
2024-01-31 16:53:07 +08:00
)
and ISDELETE = '0'
and STATE = '0'
</update>
<select id="listHiddenAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where ( f.CHECKRECORD_ID = #{CHECKRECORD_ID} or CUSTOM_ID = #{CUSTOM_ID} ) and f.ISDELETE = '0' and f.STATE = '1'
</select>
<!-- 查询清单检查记录中的隐患 -->
<select id="getHiddenByRecord" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where f.CHECKRECORD_ID = #{CHECKRECORD_ID} and f.ISDELETE = '0' and f.STATE = '1'
</select>
<!-- 查询清单检查-立即处理清单 -->
<select id="listAtOnceHidden" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where
( f.CHECKRECORD_ID = #{CHECKRECORD_ID} or CUSTOM_ID = #{CUSTOM_ID} )
and f.ISDELETE = '0'
and f.STATE = '4'
and f.RECTIFICATIONTYPE = '1'
</select>
<!-- 整改 -->
<update id="rectify" parameterType="pd">
update
<include refid="tableName"></include>
set
RECTIFYDESCR = #{RECTIFYDESCR},
RECTIFICATIONTIME = #{RECTIFICATIONTIME},
<!-- REVIEWOR = #{REVIEWOR}, -->
<!-- REVIEWDEPT = #{REVIEWDEPT}, -->
HAVESCHEME = #{HAVESCHEME},
OPERATTIME = #{OPERATTIME},
HAVEPLAN = #{HAVEPLAN},
STATE = '3'
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 复查 -->
<update id="review" parameterType="pd">
update
<include refid="tableName"></include>
set
<if test="ISPASS != null and ISPASS != ''"><!-- 关键词检索 -->
<if test="ISPASS == 1"><!-- 关键词检索 -->
STATE = '3',
REVIEWTIME = #{REVIEWTIME},
CHECKDEPT = #{CHECKDEPT}
</if>
<if test="ISPASS == 0"><!-- 关键词检索 -->
STATE = '1',
RECTIFYDESCR = null,
RECTIFICATIONTIME = null,
REJECTREASON = #{REJECTREASON},
HAVESCHEME = null,
HAVEPLAN = null
</if>
</if>
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 验收 -->
<update id="check" parameterType="pd">
update
<include refid="tableName"></include>
set
<!-- CHECKOR = #{CHECKOR}, -->
CHECKTIME = #{CHECKTIME},
OPERATTIME = #{OPERATTIME},
<!-- CHECKDESCR = #{CHECKDESCR}, -->
<!-- ISQUALIFIED = #{ISQUALIFIED}, -->
STATE = '4'
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 定时修改过期隐患 -->
<update id="editDeadline" parameterType="pd">
update
<include refid="tableName"></include> f
set
STATE = '-1'
where
f.RECTIFICATIONDEADLINE != ''
and
DATE_FORMAT( f.RECTIFICATIONDEADLINE,'%Y-%m-%d') &lt; DATE_FORMAT( NOW(),'%Y-%m-%d')
and
f.ISDELETE = '0'
and
f.STATE = '1'
</update>
<!-- 查询昨日过期隐患。发短信 -->
<select id="getYestoday" parameterType="pd" resultType="pd">
SELECT
<include refid="Field"></include>
FROM
<include refid="tableName"></include> f
WHERE
f.RECTIFICATIONDEADLINE != ''
AND TO_DAYS( NOW( ) ) - TO_DAYS( f.RECTIFICATIONDEADLINE ) = 1
AND f.ISDELETE = '0'
AND f.STATE = '-1'
</select>
<!-- 通过ID获取数据 -->
<select id="findById" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>,
cr.NAME CREATORNAME,
re.NAME RECTIFICATIONORNAME,
ch.NAME CHECKORNAME,
crd.NAME HIDDENFINDDEPTNAME,
red.NAME RECTIFICATIONDEPTNAME,
chd.NAME CHECKDEPTNAME,
lv.NAME HIDDENLEVELNAME,
bc.LIST_NAME,
Bb.NAME as HIDDEN_CATEGORY_NAME,
bri.RISK_UNIT_ID
from
<include refid="tableName"></include> f
left join sys_user cr on cr.USER_ID = f.CREATOR
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join sys_user ch on ch.USER_ID = f.CHECKOR
left join oa_department crd on crd.DEPARTMENT_ID = f.HIDDENFINDDEPT
left join oa_department red on red.DEPARTMENT_ID = f.RECTIFICATIONDEPT
left join oa_department chd on chd.DEPARTMENT_ID = f.CHECKDEPT
left join bus_checkrecord bc on bc.CHECKRECORD_ID = f.CHECKRECORD_ID and bc.ISDELETE = 0
left join <include refid="dicTableName"></include> lv on f.HIDDENLEVEL = lv.BIANMA
left join SYS_DICTIONARIES Bb on f.HIDDEN_CATEGORY = Bb.DICTIONARIES_ID
left join bus_recorditem br on br.RECORDITEM_ID = f.RECORDITEM_ID
left join bus_riskpoint bri on bri.RISKPOINT_ID = br.RISKPOINT_ID
where
f.HIDDEN_ID = #{HIDDEN_ID}
</select>
<!-- 列表 -->
<select id="datalistPage" parameterType="page" resultType="pd">
select
<include refid="Field"></include>,
cr.NAME CREATORNAME,
re.NAME RECTIFICATIONORNAME,
ch.NAME CHECKORNAME,
rev.NAME REVIEWORNAME,
crd.NAME HIDDENFINDDEPTNAME,
red.NAME RECTIFICATIONDEPTNAME,
chd.NAME CHECKDEPTNAME,
lv.NAME HIDDENLEVELNAME,
lci.RISKPOINT_ID,
(select group_concat(chr.NAME) from BUS_HIDDENCHECK bh left join sys_user chr on chr.USER_ID=bh.USER_ID where bh.HIDDEN_ID=f.HIDDEN_ID ) CHECKNAME,
(select group_concat(bh.USER_ID) from BUS_HIDDENCHECK bh where bh.HIDDEN_ID=f.HIDDEN_ID ) CHECKUSERS,
(select group_concat(bh.USER_ID) from BUS_HIDDENCHECK bh where bh.HIDDEN_ID=f.HIDDEN_ID and bh.STATUS = 0 ) UNCHECKUSERS
from
<include refid="tableName"></include> f
left join sys_user cr on cr.USER_ID = f.CREATOR
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join sys_user ch on ch.USER_ID = f.CHECKOR
left join sys_user rev on rev.USER_ID = f.REVIEWOR
left join oa_department crd on crd.DEPARTMENT_ID = f.HIDDENFINDDEPT
left join oa_department red on red.DEPARTMENT_ID = f.RECTIFICATIONDEPT
left join oa_department chd on chd.DEPARTMENT_ID = f.CHECKDEPT
2024-01-31 16:55:54 +08:00
left join BUS_LIST_CHECKITEM lci on f.CUSTOM_ITEM_ID = lci.LISTCHECKITEM_ID
2024-01-31 16:53:07 +08:00
left join
<include refid="dicTableName"></include> lv
on f.HIDDENLEVEL = lv.BIANMA
<if test="pd.APPSERACH != null and pd.APPSERACH != ''">
left join BUS_HIDDENCHECK bhc on bhc.HIDDEN_ID = f.HIDDEN_ID and bhc.USER_ID = #{pd.SELFUSERID}
</if>
where f.ISDELETE = '0' and f.STATE != '0'
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
and
(
2024-02-01 16:46:11 +08:00
<!-- f.CHECK_CONTENT LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
2024-01-31 16:53:07 +08:00
or-->
f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
)
</if>
<if test="pd.APPSERACH != null and pd.APPSERACH != ''">
and( f.CREATOR = #{pd.SELFUSERID} or f.RECTIFICATIONOR = #{pd.SELFUSERID} or bhc.USER_ID = #{pd.SELFUSERID})
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 关键词检索 -->
and f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%')
</if>
<if test="pd.ISQUALIFIED != null and pd.ISQUALIFIED != ''"><!-- 关键词检索 -->
and f.ISQUALIFIED = #{pd.ISQUALIFIED}
</if>
<if test="pd.HIDDENLEVEL != null and pd.HIDDENLEVEL != ''"><!-- 关键词检索 -->
and f.HIDDENLEVEL = #{pd.HIDDENLEVEL}
</if>
<if test="pd.STARTTIME != null and pd.STARTTIME != ''"><!-- 关键词检索 -->
and f.CREATTIME &gt;= #{pd.STARTTIME}
</if>
<if test="pd.ENDTIME != null and pd.ENDTIME != ''">
and f.CREATTIME &lt;= #{pd.ENDTIME}
</if>
<if test="pd.STATE != null and pd.STATE !='' and pd.STATE != 0 and pd.STATE != 99" >
and f.STATE = #{pd.STATE}
</if>
<if test="pd.STATE != null and pd.STATE !='' and pd.STATE == 99" > <!-- BI页面未整改点进来之后 状态搜索框不搜索数据 数据显示未整改和已过期状态-->
and f.STATE in ('1','-1')
</if>
<!-- <if test="pd.SELF_USER_ID != null and pd.SELF_USER_ID != ''">-->
<!-- and f.CREATOR = #{pd.SELF_USER_ID}-->
<!-- </if>-->
<if test="pd.CREATORNAME != null and pd.CREATORNAME != ''">
and cr.NAME LIKE CONCAT(CONCAT('%', #{pd.CREATORNAME}),'%')
</if>
<if test="pd.DISPOSESTATE != null and pd.DISPOSESTATE != ''"><!-- 关键词检索 -->
<if test="pd.DISPOSESTATE==1"><!-- 发现/整改 -->
<if test="pd.ISMAIN != null and pd.ISMAIN != ''">
<choose>
<when test="pd.ISMAIN == 1">
AND f.CORPINFO_ID = #{pd.CORPINFO_ID}
</when>
<otherwise>
and (f.RECTIFICATIONOR = #{pd.SELFUSERID}
or f.CREATOR = #{pd.SELFUSERID})
</otherwise>
</choose>
</if>
and f.STATE in('1','-1')
</if>
<if test="pd.DISPOSESTATE==2"><!-- 整改 -->
<if test="pd.ISMAIN != null and pd.ISMAIN != ''">
<choose>
<when test="pd.ISMAIN == 1">
AND f.CORPINFO_ID = #{pd.CORPINFO_ID}
</when>
<otherwise>
and f.RECTIFICATIONOR = #{pd.SELFUSERID}
</otherwise>
</choose>
</if>
and f.STATE in('1','-1')
</if>
<if test="pd.DISPOSESTATE==3"><!-- 验收 -->
and f.STATE = '3'
<if test="pd.ISMAIN != null and pd.ISMAIN != ''">
<choose>
<when test="pd.ISMAIN == 1">
AND f.CORPINFO_ID = #{pd.CORPINFO_ID}
</when>
<otherwise>
and
(
select count(1)
from BUS_HIDDENCHECK bh
where
bh.HIDDEN_ID=f.HIDDEN_ID
and bh.USER_ID=#{pd.SELFUSERID}
and bh.STATUS=0
)>0
</otherwise>
</choose>
</if>
</if>
<if test="pd.DISPOSESTATE==4"><!-- 已验收 -->
and f.STATE = '4'
<choose>
<when test="pd.ISMAIN == 1">
AND f.CORPINFO_ID = #{pd.CORPINFO_ID}
</when>
<otherwise>
<choose>
<when test="pd.isIndex != null and pd.isIndex != '' and pd.isIndex == 1">
and f.CREATOR = #{pd.SELF_USER_ID}
</when>
<otherwise>
and (
f.RECTIFICATIONOR = #{pd.SELFUSERID}
or f.CREATOR = #{pd.SELFUSERID}
or (
select count(1)
from BUS_HIDDENCHECK bh
where
bh.HIDDEN_ID=f.HIDDEN_ID
and bh.USER_ID=#{pd.SELFUSERID}
)>0
)
</otherwise>
</choose>
</otherwise>
</choose>
</if>
<if test="pd.DISPOSESTATE==5"><!-- 已超时APP使用不判断ISMAIN -->
<choose>
<when test="pd.isIndex != null and pd.isIndex != '' and pd.isIndex == 1">
and f.RECTIFICATIONOR = #{pd.SELFUSERID}
</when>
<otherwise>
and (
f.RECTIFICATIONOR = #{pd.SELFUSERID}
or f.CREATOR = #{pd.SELFUSERID}
)
</otherwise>
</choose>
and f.STATE = '-1'
</if>
<if test="pd.DISPOSESTATE==-1"><!-- 所有 -->
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 关键词检索 -->
and
f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<choose>
<when test='pd.ISMAIN != null and pd.ISMAIN != "" and pd.ISMAIN == "1"'>
<if test="pd.DEPT_IDS != null and pd.DEPT_IDS != ''">
and
f.HIDDENFINDDEPT in
<foreach item="item" index="index"
collection="pd.DEPT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>
</if>
</when>
<otherwise>
<choose>
<when test='pd.ISSUPERVISE != null and pd.ISSUPERVISE != "" and pd.ISSUPERVISE == "1"'>
<choose>
<when test="pd.DEPT_IDS != null and pd.DEPT_IDS != ''">
and
f.HIDDENFINDDEPT in
<foreach item="item" index="index"
collection="pd.DEPT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>
</when>
<otherwise>
and
(f.HIDDENFINDDEPT in (
select
SUB_DEPARTMENT_ID
from
oa_supervision_department osd
where
osd.SUP_DEPARTMENT_ID = #{pd.DEPARTMENT_ID}
and osd.ISDELETE = '0'
and osd.CORPINFO_ID = #{pd.CORPINFO_ID}
) or f.RECTIFICATIONDEPT in (
select
SUB_DEPARTMENT_ID
from
oa_supervision_department osd
where
osd.SUP_DEPARTMENT_ID = #{pd.DEPARTMENT_ID}
and osd.ISDELETE = '0'
and osd.CORPINFO_ID = #{pd.CORPINFO_ID}
) )
</otherwise>
</choose>
</when>
<when test='pd.ISLEADER != null and pd.ISLEADER != "" and pd.ISLEADER == "1"'>
<choose>
<when test="pd.DEPT_IDS != null and pd.DEPT_IDS != ''">
and
f.HIDDENFINDDEPT in
<foreach item="item" index="index"
collection="pd.DEPT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>
</when>
<otherwise>
and
(f.HIDDENFINDDEPT in
<foreach item="item" index="index"
collection="pd.DEPARTMENT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>) or (f.RECTIFICATIONDEPT in
<foreach item="item" index="index"
collection="pd.DEPARTMENT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>)
</otherwise>
</choose>
</when>
<when test="pd.DEPARTMENT_ID != null and pd.DEPARTMENT_ID != ''">
and (f.HIDDENFINDDEPT=#{pd.DEPARTMENT_ID} or f.RECTIFICATIONDEPT = #{pd.DEPARTMENT_ID})
</when>
<otherwise>
</otherwise>
</choose>
</otherwise>
</choose>
<if test="pd.STATE != null and pd.STATE != '' and pd.STATE != 99"><!-- 关键词检索 -->
and
f.STATE = #{pd.STATE}
</if>
</if>
</if>
<!-- <if test="pd.DEPARTMENT_ID != null and pd.DEPARTMENT_ID != ''">关键词检索
and f.HIDDENFINDDEPT = #{pd.DEPARTMENT_ID}
</if> -->
<!-- 由BI页跳转过来参数 -->
<if test="pd.IS_DAY != null and pd.IS_DAY != ''"><!-- 由BI页跳转过来参数 -->
and
TO_DAYS(f.CREATTIME) = TO_DAYS(NOW())
</if>
<if test="pd.IS_WEEK != null and pd.IS_WEEK != ''"><!-- 由BI页跳转过来参数 -->
and
YEARWEEK(DATE_FORMAT(f.CREATTIME,'%Y-%m-%d'),1) = YEARWEEK(NOW(),1)
</if>
<if test="pd.IS_XUN != null and pd.IS_XUN != ''"><!-- 由BI页跳转过来参数 -->
<if test="pd.STARTTIME != null and pd.STARTTIME != ''"><!-- 由BI页跳转过来参数 -->
and f.CREATTIME &gt;= #{pd.STARTTIME}
</if>
<if test="pd.ENDTIME != null and pd.ENDTIME != ''">
and f.CREATTIME &lt;= #{pd.ENDTIME}
</if>
</if>
<if test="pd.IS_MONTH != null and pd.IS_MONTH != ''"><!-- 由BI页跳转过来参数 -->
and
DATE_FORMAT(f.CREATTIME,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
</if>
<if test="pd.IS_QUARTER != null and pd.IS_QUARTER != ''"><!-- 由BI页跳转过来参数 -->
and f.CREATTIME BETWEEN #{pd.STARTTIME} and #{pd.ENDTIME}
</if>
<if test="pd.IS_YEAR != null and pd.IS_YEAR != ''"><!-- 由BI页跳转过来参数 -->
and
YEAR(f.CREATTIME)=YEAR(NOW())
</if>
<if test="pd.BISTATE != null and pd.BISTATE != ''"><!-- 由BI页跳转过来参数 -->
<choose>
<when test='pd.BISTATE=="1"'>
and f.STATE != '0'
</when>
<when test='pd.BISTATE=="2"'>
and f.STATE != '4'
</when>
<when test='pd.BISTATE=="3"'>
and f.STATE = '4'
</when>
</choose>
</if>
<if test="pd.ANALYSIS != null and pd.ANALYSIS != ''"><!-- 持续改进用字段 -->
and not exists (select 1 from BUS_RISKPOINT_ANALYSIS ra where ra.HIDDEN_ID = f.HIDDEN_ID)
</if>
<if test="pd.RECTIFICATIONDEPT != null and pd.RECTIFICATIONDEPT != ''">
and f.RECTIFICATIONDEPT = #{pd.RECTIFICATIONDEPT}
</if>
order by f.CREATTIME desc
</select>
<select id="listAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>,
cr.NAME CREATORNAME,
re.NAME RECTIFICATIONORNAME,
ch.NAME CHECKORNAME,
rev.NAME REVIEWORNAME,
crd.NAME HIDDENFINDDEPTNAME,
red.NAME RECTIFICATIONDEPTNAME,
chd.NAME CHECKDEPTNAME,
lv.NAME HIDDENLEVELNAME,
2024-02-01 22:37:47 +08:00
(select group_concat(chr.NAME) from BUS_HIDDENDANGERCHECKSTANDARD_HIDDENCHECK bh left join sys_user chr on chr.USER_ID=bh.USER_ID where bh.HIDDEN_ID=f.HIDDEN_ID ) CHECKNAME
2024-01-31 16:53:07 +08:00
from
<include refid="tableName"></include> f
left join sys_user cr on cr.USER_ID = f.CREATOR
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join sys_user ch on ch.USER_ID = f.CHECKOR
left join sys_user rev on rev.USER_ID = f.REVIEWOR
left join oa_department crd on crd.DEPARTMENT_ID = f.HIDDENFINDDEPT
left join oa_department red on red.DEPARTMENT_ID = f.RECTIFICATIONDEPT
left join oa_department chd on chd.DEPARTMENT_ID = f.CHECKDEPT
left join
<include refid="dicTableName"></include> lv
on f.HIDDENLEVEL = lv.BIANMA
where f.ISDELETE = '0' and f.STATE != '0'
<if test="SOURCE != null and SOURCE != ''">
and f.SOURCE=#{SOURCE}
</if>
<if test="IS_CANCEL != null and IS_CANCEL != ''"><!-- 是否作废 -->
and f.CHECKRECORD_ID is null
</if>
<if test="CORPINFO_ID != null and CORPINFO_ID != ''">
and f.CORPINFO_ID = #{CORPINFO_ID}
</if>
<if test="FIND_CHECKRECORD_ID != null and FIND_CHECKRECORD_ID != ''">
and f.CHECKRECORD_ID=#{CHECKRECORD_ID}
</if>
<if test="KEYWORDS != null and KEYWORDS != ''"><!-- 关键词检索 -->
and
(
f.CHECK_CONTENT LIKE CONCAT(CONCAT('%', #{KEYWORDS}),'%')
or
f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{KEYWORDS}),'%')
)
</if>
<if test="HIDDENDESCR != null and HIDDENDESCR != ''"><!-- 关键词检索 -->
and f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{HIDDENDESCR}),'%')
</if>
<if test="ISQUALIFIED != null and ISQUALIFIED != ''"><!-- 关键词检索 -->
and f.ISQUALIFIED = #{ISQUALIFIED}
</if>
<if test="DEPARTMENT_ID != null and DEPARTMENT_ID != ''"><!-- 关键词检索 -->
and f.HIDDENFINDDEPT = #{DEPARTMENT_ID}
</if>
<if test="HIDDENLEVEL != null and HIDDENLEVEL != ''"><!-- 关键词检索 -->
and f.HIDDENLEVEL = #{HIDDENLEVEL}
</if>
<if test="STARTTIME != null and STARTTIME != ''"><!-- 关键词检索 -->
and f.CREATTIME &gt;= #{STARTTIME}
</if>
<if test="ENDTIME != null and ENDTIME != ''">
and f.CREATTIME &lt;= #{ENDTIME}
</if>
<if test="STATE != null and STATE !='' and STATE != 0" >
and f.STATE = #{STATE}
</if>
<if test="SELF_USER_ID != null and SELF_USER_ID != ''">
and f.CREATOR = #{SELF_USER_ID}
</if>
<if test="DISPOSESTATE != null and DISPOSESTATE != ''"><!-- 关键词检索 -->
<if test="DISPOSESTATE==2"><!-- 整改 -->
and f.RECTIFICATIONOR = #{SELFUSERID}
and f.STATE in('1','-1')
</if>
<if test="DISPOSESTATE==3"><!-- 验收 -->
and f.STATE = '3'
and (select count(1) from BUS_HIDDENCHECK bh where bh.USER_ID=#{SELFUSERID} and bh.HIDDEN_ID=f.HIDDEN_ID and bh.STATUS=0)>0
</if>
<if test="DISPOSESTATE==4"><!-- 已验收 -->
and f.STATE = '4'
and (f.RECTIFICATIONOR = #{SELFUSERID} or f.CREATOR = #{SELFUSERID} or (select count(1) from BUS_HIDDENCHECK bh where bh.USER_ID=#{SELFUSERID} and bh.HIDDEN_ID=f.HIDDEN_ID)>0)
</if>
<if test="DISPOSESTATE==-1"><!-- 所有 -->
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
and
f.CORPINFO_ID = #{CORPINFO_ID}
</if>
<if test="STATE != null and STATE != ''"><!-- 关键词检索 -->
and
f.STATE = #{STATE}
</if>
</if>
</if>
<if test="HIDDEN_IDS != null and HIDDEN_IDS != ''"><!-- 关键词检索 -->
and
(
f.HIDDEN_ID in
<foreach item="item" index="index" collection="HIDDEN_IDS" open="(" separator="," close=")">
#{item}
</foreach>
)
</if>
<if test="DEPT_IDS != null and DEPT_IDS != ''">
and
f.HIDDENFINDDEPT in
<foreach item="item" index="index"
collection="DEPT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>
</if>
order by f.STATE ,f.CREATTIME desc
</select>
<select id="listAllToPrint" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>,
cr.NAME CREATORNAME,
re.NAME RECTIFICATIONORNAME,
ch.NAME CHECKORNAME,
rev.NAME REVIEWORNAME,
crd.NAME HIDDENFINDDEPTNAME,
red.NAME RECTIFICATIONDEPTNAME,
chd.NAME CHECKDEPTNAME,
lv.NAME HIDDENLEVELNAME,
( SELECT max( bh.CHECK_TIME ) FROM BUS_HIDDENCHECK bh WHERE bh.HIDDEN_ID = f.HIDDEN_ID ) CHECK_TIME,
(select group_concat(chr.NAME) from BUS_HIDDENCHECK bh left join sys_user chr on chr.USER_ID=bh.USER_ID where bh.HIDDEN_ID=f.HIDDEN_ID ) CHECKNAME
from
<include refid="tableName"></include> f
left join sys_user cr on cr.USER_ID = f.CREATOR
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join sys_user ch on ch.USER_ID = f.CHECKOR
left join sys_user rev on rev.USER_ID = f.REVIEWOR
left join oa_department crd on crd.DEPARTMENT_ID = f.HIDDENFINDDEPT
left join oa_department red on red.DEPARTMENT_ID = f.RECTIFICATIONDEPT
left join oa_department chd on chd.DEPARTMENT_ID = f.CHECKDEPT
left join
<include refid="dicTableName"></include> lv
on f.HIDDENLEVEL = lv.BIANMA
where f.ISDELETE = '0' and f.STATE != '0'
<if test="SOURCE != null and SOURCE != ''">
and f.SOURCE=#{SOURCE}
</if>
<if test="IS_CANCEL != null and IS_CANCEL != ''"><!-- 是否作废 -->
and f.CHECKRECORD_ID is null
</if>
<if test="CORPINFO_ID != null and CORPINFO_ID != ''">
and f.CORPINFO_ID = #{CORPINFO_ID}
</if>
<if test="FIND_CHECKRECORD_ID != null and FIND_CHECKRECORD_ID != ''">
and f.CHECKRECORD_ID=#{CHECKRECORD_ID}
</if>
<if test="KEYWORDS != null and KEYWORDS != ''"><!-- 关键词检索 -->
and
(
f.CHECK_CONTENT LIKE CONCAT(CONCAT('%', #{KEYWORDS}),'%')
or
f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{KEYWORDS}),'%')
)
</if>
<if test="HIDDENDESCR != null and HIDDENDESCR != ''"><!-- 关键词检索 -->
and f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{HIDDENDESCR}),'%')
</if>
<if test="ISQUALIFIED != null and ISQUALIFIED != ''"><!-- 关键词检索 -->
and f.ISQUALIFIED = #{ISQUALIFIED}
</if>
<if test="DEPARTMENT_ID != null and DEPARTMENT_ID != ''"><!-- 关键词检索 -->
and f.HIDDENFINDDEPT = #{DEPARTMENT_ID}
</if>
<if test="HIDDENLEVEL != null and HIDDENLEVEL != ''"><!-- 关键词检索 -->
and f.HIDDENLEVEL = #{HIDDENLEVEL}
</if>
<if test="STARTTIME != null and STARTTIME != ''"><!-- 关键词检索 -->
and f.CREATTIME &gt;= #{STARTTIME}
</if>
<if test="ENDTIME != null and ENDTIME != ''">
and f.CREATTIME &lt;= #{ENDTIME}
</if>
<if test="STATE != null and STATE !='' and STATE != 0" >
and f.STATE = #{STATE}
</if>
<if test="SELF_USER_ID != null and SELF_USER_ID != ''">
and f.CREATOR = #{SELF_USER_ID}
</if>
<if test="DISPOSESTATE != null and DISPOSESTATE != ''"><!-- 关键词检索 -->
<if test="DISPOSESTATE==2"><!-- 整改 -->
and f.RECTIFICATIONOR = #{SELFUSERID}
and f.STATE in('1','-1')
</if>
<if test="DISPOSESTATE==3"><!-- 验收 -->
and f.STATE = '3'
and (select count(1) from BUS_HIDDENCHECK bh where bh.USER_ID=#{SELFUSERID} and bh.HIDDEN_ID=f.HIDDEN_ID and bh.STATUS=0)>0
</if>
<if test="DISPOSESTATE==4"><!-- 已验收 -->
and f.STATE = '4'
and (f.RECTIFICATIONOR = #{SELFUSERID} or f.CREATOR = #{SELFUSERID} or (select count(1) from BUS_HIDDENCHECK bh where bh.USER_ID=#{SELFUSERID} and bh.HIDDEN_ID=f.HIDDEN_ID)>0)
</if>
<if test="DISPOSESTATE==-1"><!-- 所有 -->
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
and
f.CORPINFO_ID = #{CORPINFO_ID}
</if>
<if test="STATE != null and STATE != ''"><!-- 关键词检索 -->
and
f.STATE = #{STATE}
</if>
</if>
</if>
<if test="HIDDEN_IDS != null and HIDDEN_IDS != ''"><!-- 关键词检索 -->
and
(
f.HIDDEN_ID in
<foreach item="item" index="index" collection="HIDDEN_IDS" open="(" separator="," close=")">
#{item}
</foreach>
)
</if>
order by f.CREATTIME desc
</select>
<!-- 批量删除 -->
<delete id="deleteAll" parameterType="String">
update
<include refid="tableName"></include>
set
ISDELETE = '1'
where
HIDDEN_ID in
<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- 批量修改 -->
<delete id="updateAll" parameterType="pd">
update
<include refid="tableName"></include>
set
CHECKRECORD_ID = #{CHECKRECORD_ID}
<if test="STATE != null and STATE != ''">
,STATE = #{STATE}<!-- 未提交隐患,不计入统计,列表内不可看 -->
</if>
where STATE = 0
and HIDDEN_ID in
<foreach item="item" index="index" collection="IDS" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- 删除-->
<delete id="deleteByKey" parameterType="pd">
update
<include refid="tableName"></include>
set
ISDELETE = '1'
where
FOREIGN_ID = #{FOREIGN_ID}
and SOURCE = #{SOURCE}
</delete>
<delete id="deleteForEmis" parameterType="pd">
delete from
<include refid="tableName"></include>
where
HIDDEN_ID = #{HIDDEN_ID}
</delete>
<!-- 批量删除 -->
<update id="deleteArray" parameterType="pd">
update
<include refid="tableName"></include>
set
ISDELETE = '1'
where
HIDDEN_ID in
<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<!-- 按日统计 -->
<select id="hiddenStatisticsByDay" parameterType="pd" resultType="pd">
SELECT
d.date,IFNULL(f.count,0) as count
FROM
v_dates d
left join (SELECT
DATE_FORMAT( t.CREATTIME, '%Y-%m-%d') AS CREATTIME,
count(1) as count
FROM
BUS_HIDDEN t
WHERE t.ISDELETE = '0' and t.STATE != '0' and
t.HIDDENLEVEL = #{HIDDENLEVEL} and t.CORPINFO_ID=#{CORPINFO_ID}
<if test="USER_ID != null and USER_ID != ''"><!-- 关键词检索 -->
and
t.CREATOR = #{USER_ID}
</if>
GROUP BY
DATE_FORMAT( t.CREATTIME, '%Y-%m-%d') ) f on f.CREATTIME = d.date
WHERE
d.date BETWEEN #{START_DAY} AND #{END_DAY}
ORDER BY
d.date desc
</select>
<!-- 总数统计 -->
<select id="hiddenStatisticsAll" parameterType="pd" resultType="pd">
SELECT
t.STATE,
count(1) as count
FROM
BUS_HIDDEN t
WHERE
t.CORPINFO_ID=#{CORPINFO_ID} and t.ISDELETE = '0' and t.STATE != '0'
<if test="USER_ID != null and USER_ID != ''"><!-- 关键词检索 -->
and
t.CREATOR = #{USER_ID}
</if>
GROUP BY
t.STATE
</select>
<!-- 根据用户ID获取发现隐患信息 -->
<select id="getCountByCreatorId" parameterType="pd" resultType="pd">
SELECT
f.CREATOR,f.STATE
FROM
BUS_HIDDEN f
WHERE f.ISDELETE = '0' and f.STATE != '0' and f.HIDDENLEVEL = 'hiddenLevel0001'
<!-- <if test="DEPARTMENT_IDS != null and DEPARTMENT_IDS != ''">关键词检索
and
(
f.REVIEWDEPT in
<foreach item="item" index="index" collection="DEPARTMENT_IDS" open="(" separator="," close=")">
#{item}
</foreach>
or f.REVIEWOR = #{SELFUSERID}
)
</if>
<if test="SELFUSERID != null and SELFUSERID != ''">关键词检索
and
f.CREATOR = #{SELFUSERID}
</if> -->
<if test="APPSELFUSERID != null and APPSELFUSERID != ''">
and
f.CREATOR = #{APPSELFUSERID}
</if>
<choose>
<when test='ISMAIN != null and ISMAIN != "" and ISMAIN == "1"'>
<if test="DEPT_IDS != null and DEPT_IDS != ''">
and
f.HIDDENFINDDEPT in
<foreach item="item" index="index"
collection="DEPT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>
</if>
</when>
<otherwise>
<choose>
<when test='ISSUPERVISE != null and ISSUPERVISE != "" and ISSUPERVISE == "1"'>
<choose>
<when test="DEPT_IDS != null and DEPT_IDS != ''">
and
f.HIDDENFINDDEPT in
<foreach item="item" index="index"
collection="DEPT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>
</when>
<otherwise>
and
f.HIDDENFINDDEPT in (
select
SUB_DEPARTMENT_ID
from
oa_supervision_department osd
where
osd.SUP_DEPARTMENT_ID = #{DEPARTMENT_ID}
and osd.ISDELETE = '0'
and osd.CORPINFO_ID = #{CORPINFO_ID}
)
</otherwise>
</choose>
</when>
<when test="DEPARTMENT_ID != null and DEPARTMENT_ID != ''">
and f.HIDDENFINDDEPT=#{DEPARTMENT_ID}
</when>
<otherwise>
</otherwise>
</choose>
</otherwise>
</choose>
<if test="CORPINFO_ID != null and CORPINFO_ID != ''">
and f.CORPINFO_ID =#{CORPINFO_ID}
</if>
</select>
<!--根据用户ID获取隐患信息 -->
<select id="getCountByRectifiCationorId" parameterType="pd" resultType="pd">
SELECT
f.CREATOR,f.STATE
FROM
BUS_HIDDEN f
WHERE f.ISDELETE = '0' and f.STATE != '0' and f.HIDDENLEVEL = 'hiddenLevel0001'
<if test="DEPARTMENT_IDS != null and DEPARTMENT_IDS != ''"><!-- 关键词检索 -->
and
(
f.RECTIFICATIONDEPT in
<foreach item="item" index="index" collection="DEPARTMENT_IDS" open="(" separator="," close=")">
#{item}
</foreach>
or f.RECTIFICATIONOR = #{SELFUSERID}
)
</if>
<if test="SELFUSERID != null and SELFUSERID != ''">
and f.RECTIFICATIONOR = #{SELFUSERID}
</if>
<if test="CORPINFO_ID != null and CORPINFO_ID != ''">
and f.CORPINFO_ID =#{CORPINFO_ID}
</if>
</select>
<!--根据用户ID获取待验收隐患-->
<select id="getCountByCheckorId" parameterType="pd" resultType="pd">
SELECT
f.CREATOR,f.STATE
FROM
BUS_HIDDEN f
WHERE f.ISDELETE = '0' and f.STATE != '0'
<!-- <if test="DEPARTMENT_IDS != null and DEPARTMENT_IDS != ''">关键词检索
and
(
f.CHECKDEPT in
<foreach item="item" index="index" collection="DEPARTMENT_IDS" open="(" separator="," close=")">
#{item}
</foreach>
or f.CHECKOR = #{SELFUSERID}
)
</if> -->
<if test="SELFUSERID != null and SELFUSERID != ''">
and (select count(1) from BUS_HIDDENCHECK bh where bh.USER_ID=#{SELFUSERID} and bh.HIDDEN_ID=f.HIDDEN_ID and bh.STATUS=0)>0
</if>
<if test="CORPINFO_ID != null and CORPINFO_ID != ''">
and f.CORPINFO_ID =#{CORPINFO_ID}
</if>
</select>
<!--根据企业ID获取驾驶舱隐患统计信息 -->
<select id="getBICount" parameterType="pd" resultType="pd">
SELECT
<include refid="Field"></include>
FROM
BUS_HIDDEN f
WHERE f.ISDELETE = '0' and f.STATE != '0' and f.HIDDENLEVEL = 'hiddenLevel0001'
<if test="CORPINFO_ID != null and CORPINFO_ID != ''">
and f.CORPINFO_ID =#{CORPINFO_ID}
</if>
<if test="userId != null and userId != ''">
and f.CREATOR =#{userId}
</if>
<if test="IS_DAY != null and IS_DAY != ''"><!-- 关键词检索 -->
and
TO_DAYS(f.CREATTIME) = TO_DAYS(NOW())
</if>
<if test="IS_WEEK != null and IS_WEEK != ''"><!-- 关键词检索 -->
and
YEARWEEK(DATE_FORMAT(f.CREATTIME,'%Y-%m-%d'),1) = YEARWEEK(NOW(),1)
</if>
<if test="IS_XUN != null and IS_XUN != ''"><!-- 关键词检索 -->
<if test="STARTTIME != null and STARTTIME != ''"><!-- 关键词检索 -->
and f.CREATTIME &gt;= #{STARTTIME}
</if>
<if test="ENDTIME != null and ENDTIME != ''">
and f.CREATTIME &lt;= #{ENDTIME}
</if>
</if>
<if test="IS_MONTH != null and IS_MONTH != ''"><!-- 关键词检索 -->
and
DATE_FORMAT(f.CREATTIME,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
</if>
<if test="IS_QUARTER != null and IS_QUARTER != ''"><!-- 关键词检索 -->
and f.CREATTIME BETWEEN #{STARTTIME} and #{ENDTIME}
</if>
<if test="IS_YEAR != null and IS_YEAR != ''"><!-- 关键词检索 -->
and
YEAR(f.CREATTIME)=YEAR(NOW())
</if>
</select>
<!-- 清单其他隐患 -->
<select id="getOtherHidden" parameterType="pd" resultType="pd">
SELECT
<include refid="Field"></include>
FROM
2024-02-01 08:37:20 +08:00
<include refid="tableName"></include> f
2024-01-31 16:53:07 +08:00
WHERE f.ISDELETE = '0'
and f.SOURCE = '3'
<if test="STATE != null and STATE != ''"><!-- 关键词检索 -->
and
f.STATE = #{STATE}
</if>
<if test="USER_ID != null and USER_ID != ''"><!-- 关键词检索 -->
and
f.CREATOR = #{USER_ID}
</if>
<if test="CUSTOM_ID != null and CUSTOM_ID != ''"><!-- 关键词检索 -->
and
f.CUSTOM_ID = #{CUSTOM_ID}
</if>
<if test="CHECKRECORD_ID != null and CHECKRECORD_ID != ''"><!-- 关键词检索 -->
and
f.CHECKRECORD_ID = #{CHECKRECORD_ID}
</if>
<if test="IS_DAY != null and IS_DAY != ''"><!-- 关键词检索 -->
and
TO_DAYS(f.CREATTIME) = TO_DAYS(NOW())
</if>
<if test="IS_WEEK != null and IS_WEEK != ''"><!-- 关键词检索 -->
and
YEARWEEK(DATE_FORMAT(f.CREATTIME,'%Y-%m-%d')) = YEARWEEK(NOW())
</if>
<if test="IS_XUN != null and IS_XUN != ''"><!-- 关键词检索 -->
<if test="BEGINTIME != null and BEGINTIME != ''"><!-- 关键词检索 -->
and f.CREATTIME &gt;= #{BEGINTIME}
</if>
<if test="ENDTIME != null and ENDTIME != ''">
and f.CREATTIME &lt;= #{ENDTIME}
</if>
</if>
<if test="IS_MONTH != null and IS_MONTH != ''"><!-- 关键词检索 -->
and
DATE_FORMAT(f.CREATTIME,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
</if>
<if test="IS_QUARTER != null and IS_QUARTER != ''"><!-- 关键词检索 -->
and
QUARTER(f.CREATTIME) = QUARTER(NOW())
</if>
<if test="IS_HALFYEAR != null and IS_HALFYEAR != ''">
AND
CONVERT(concat(DATE_FORMAT(f.CREATTIME, '%Y'), INTERVAL(CONVERT(MONTH(f.CREATTIME),SIGNED),7,13) ),SIGNED) =
CONVERT(concat(DATE_FORMAT(NOW(), '%Y'), INTERVAL(CONVERT(MONTH(NOW()),SIGNED),7,13) ),SIGNED)
</if>
<if test="IS_YEAR != null and IS_YEAR != ''"><!-- 关键词检索 -->
and
YEAR(f.CREATTIME)=YEAR(NOW())
</if>
ORDER BY f.CREATTIME
</select>
<!-- -->
<select id="getCountByHiddenType" parameterType="pd" resultType="pd">
SELECT
HIDDENTYPE2,
COUNT(1) AS count
FROM
BUS_HIDDEN
WHERE
CORPINFO_ID = #{CORPINFO_ID}
<choose>
<when test='ISMAIN != null and ISMAIN != "" and ISMAIN == "1"'>
<if test="DEPT_IDS != null and DEPT_IDS != ''">
and
HIDDENFINDDEPT in
<foreach item="item" index="index"
collection="DEPT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>
</if>
</when>
<otherwise>
<choose>
<when test='ISSUPERVISE != null and ISSUPERVISE != "" and ISSUPERVISE == "1"'>
<choose>
<when test="DEPT_IDS != null and DEPT_IDS != ''">
and
HIDDENFINDDEPT in
<foreach item="item" index="index"
collection="DEPT_IDS" open="(" separator="," close=")">
'${item}'
</foreach>
</when>
<otherwise>
and
HIDDENFINDDEPT in (
select
SUB_DEPARTMENT_ID
from
oa_supervision_department osd
where
osd.SUP_DEPARTMENT_ID = #{DEPARTMENT_ID}
and osd.ISDELETE = '0'
and osd.CORPINFO_ID = #{CORPINFO_ID}
)
</otherwise>
</choose>
</when>
<when test="DEPARTMENT_ID != null and DEPARTMENT_ID != ''">
and HIDDENFINDDEPT=#{DEPARTMENT_ID}
</when>
<otherwise>
</otherwise>
</choose>
</otherwise>
</choose>
GROUP BY
HIDDENTYPE2
</select>
<select id="getHiddenNum" parameterType="pd" resultType="pd">
<if test="TYPE != null and TYPE != ''">
<if test="TYPE==1"><!-- 所有 -->
SELECT
count( 1 ) NUMBER,
DATE_FORMAT( h.CREATTIME, '%Y-%m' ) TIME
FROM
bus_hidden h
WHERE
h.ISDELETE = '0'
AND h.CORPINFO_ID = #{CORPINFO_ID}
AND h.state != '0'
AND h.HIDDENLEVEL = 'hiddenLevel0001'
AND DATE_FORMAT( h.CREATTIME, '%Y-%m' ) &gt;= #{TIME}
AND DATE_FORMAT( h.CREATTIME, '%Y-%m' ) &lt;= DATE_FORMAT( NOW(), '%Y-%m' )
GROUP BY
DATE_FORMAT( h.CREATTIME, '%Y-%m' )
ORDER BY
DATE_FORMAT( h.CREATTIME, '%Y-%m' )
</if>
<if test="TYPE==2"><!-- 未整改 -->
SELECT
count( 1 ) NUMBER,
DATE_FORMAT( h.CREATTIME, '%Y-%m' ) TIME
FROM
bus_hidden h
WHERE
h.ISDELETE = '0'
AND h.CORPINFO_ID = #{CORPINFO_ID}
AND h.STATE in('1','-1')
AND h.HIDDENLEVEL = 'hiddenLevel0001'
AND DATE_FORMAT( h.CREATTIME, '%Y-%m' ) &gt;= #{TIME}
AND DATE_FORMAT( h.CREATTIME, '%Y-%m' ) &lt;= DATE_FORMAT( NOW(), '%Y-%m' )
GROUP BY
DATE_FORMAT( h.CREATTIME, '%Y-%m' )
ORDER BY
DATE_FORMAT( h.CREATTIME, '%Y-%m' )
</if>
<if test="TYPE==3"><!-- 已整改 -->
SELECT
count( 1 ) NUMBER,
DATE_FORMAT( h.CREATTIME, '%Y-%m' ) TIME
FROM
bus_hidden h
WHERE
h.ISDELETE = '0'
AND h.CORPINFO_ID = #{CORPINFO_ID}
AND h.HIDDENLEVEL = 'hiddenLevel0001'
AND h.STATE in('3')
AND DATE_FORMAT( h.CREATTIME, '%Y-%m' ) &gt;= #{TIME}
AND DATE_FORMAT( h.CREATTIME, '%Y-%m' ) &lt;= DATE_FORMAT( NOW(), '%Y-%m' )
GROUP BY
DATE_FORMAT( h.CREATTIME, '%Y-%m' )
ORDER BY
DATE_FORMAT( h.CREATTIME, '%Y-%m' )
</if>
<if test="TYPE==4"><!-- 已验收 -->
SELECT
count( 1 ) NUMBER,
DATE_FORMAT( h.CREATTIME, '%Y-%m' ) TIME
FROM
bus_hidden h
WHERE
h.ISDELETE = '0'
AND h.CORPINFO_ID = #{CORPINFO_ID}
AND h.HIDDENLEVEL = 'hiddenLevel0001'
AND h.STATE in('4')
AND DATE_FORMAT( h.CREATTIME, '%Y-%m' ) &gt;= #{TIME}
AND DATE_FORMAT( h.CREATTIME, '%Y-%m' ) &lt;= DATE_FORMAT( NOW(), '%Y-%m' )
GROUP BY
DATE_FORMAT( h.CREATTIME, '%Y-%m' )
ORDER BY
DATE_FORMAT( h.CREATTIME, '%Y-%m' )
</if>
</if>
</select>
<select id="listAllRoll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>,
cr.NAME CREATORNAME,
re.NAME RECTIFICATIONORNAME,
ch.NAME CHECKORNAME,
rev.NAME REVIEWORNAME,
crd.NAME HIDDENFINDDEPTNAME,
red.NAME RECTIFICATIONDEPTNAME,
chd.NAME CHECKDEPTNAME,
lv.NAME HIDDENLEVELNAME,
(select group_concat(chr.NAME) from BUS_HIDDENCHECK bh left join sys_user chr on chr.USER_ID=bh.USER_ID where bh.HIDDEN_ID=f.HIDDEN_ID ) CHECKNAME
from
<include refid="tableName"></include> f
left join sys_user cr on cr.USER_ID = f.CREATOR
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join sys_user ch on ch.USER_ID = f.CHECKOR
left join sys_user rev on rev.USER_ID = f.REVIEWOR
left join oa_department crd on crd.DEPARTMENT_ID = f.HIDDENFINDDEPT
left join oa_department red on red.DEPARTMENT_ID = f.RECTIFICATIONDEPT
left join oa_department chd on chd.DEPARTMENT_ID = f.CHECKDEPT
left join
<include refid="dicTableName"></include> lv
on f.HIDDENLEVEL = lv.BIANMA
where f.ISDELETE = '0' and f.STATE != '0'
and DATE_SUB( CURDATE(), INTERVAL 30 DAY ) &lt;= f.CREATTIME
and f.HIDDENDESCR is not null
<choose>
<when test='ISSUPERVISE != null and ISSUPERVISE != "" and ISSUPERVISE == "1"'>
and
f.HIDDENFINDDEPT in (
select
SUB_DEPARTMENT_ID
from
oa_supervision_department osd
where
osd.SUP_DEPARTMENT_ID = #{DEPARTMENT_ID}
and osd.ISDELETE = '0'
and osd.CORPINFO_ID = #{CORPINFO_ID}
)
</when>
<otherwise>
and f.HIDDENFINDDEPT=#{DEPARTMENT_ID}
</otherwise>
</choose>
order by f.CREATTIME desc
</select>
<!-- 绩效得分 -->
<select id="getDeptExamine" parameterType="pd" resultType="pd" >
SELECT
d.DEPARTMENT_ID,
ifnull(un.user_count,0) as user_count,
(select count( 1 ) from BUS_HIDDEN h where h.ISDELETE=0 and h.HIDDENFINDDEPT=d.DEPARTMENT_ID and h.CREATTIME LIKE CONCAT(CONCAT('%', #{MONTH}),'%') ) as hidden_count,
(select count( 1 ) from BUS_HIDDEN h where h.ISDELETE=0 and h.RECTIFICATIONDEPT=d.DEPARTMENT_ID and h.RECTIFICATIONTIME LIKE CONCAT(CONCAT('%', #{MONTH}),'%') ) as rectify_count
FROM
OA_DEPARTMENT d
LEFT JOIN
( SELECT count( 1 ) as user_count,u.DEPARTMENT_ID FROM SYS_USER u WHERE u.ISDELETE = 0 group by u.DEPARTMENT_ID) un on un.DEPARTMENT_ID = d.DEPARTMENT_ID
where
d.ISDELETE = 0
</select>
<!-- 绩效得分 -->
<select id="getUserExamine" parameterType="pd" resultType="pd" >
SELECT
u.USER_ID,
(select count( 1 ) from BUS_HIDDEN h where h.ISDELETE=0 and h.CREATOR=u.USER_ID and h.CREATTIME LIKE CONCAT(CONCAT('%', #{MONTH}),'%') ) as hidden_count,
(select count( 1 ) from BUS_HIDDEN h where h.ISDELETE=0 and h.RECTIFICATIONOR=u.USER_ID and h.RECTIFICATIONTIME LIKE CONCAT(CONCAT('%', #{MONTH}),'%') ) as rectify_count
FROM
SYS_USER u
where
u.ISDELETE = 0
</select>
<select id="getDeptIndexData" parameterType="pd" resultType="pd" >
SELECT
(select count( 1 ) from BUS_CHECKRECORD h
left join SYS_USER u on h.CREATOR=u.NAME and u.CORPINFO_ID = #{CORPINFO_ID} and u.ISDELETE=0
where h.ISDELETE=0 and h.CORPINFO_ID = #{CORPINFO_ID} and u.DEPARTMENT_ID=d.DEPARTMENT_ID
and YEAR(h.CREATTIME)=YEAR(NOW())) as check_count,
(select count( 1 ) from BUS_HIDDEN h where h.ISDELETE=0 and h.HIDDENFINDDEPT=d.DEPARTMENT_ID
and YEAR(h.CREATTIME)=YEAR(NOW())) as hidden_count,
(select count( 1 ) from BUS_HIDDENCHECK h where h.DEPARTMENT_ID=d.DEPARTMENT_ID and h.STATUS = '1'
and YEAR(h.CHECK_TIME)=YEAR(NOW())) as rectify_count
FROM
OA_DEPARTMENT d
where
d.DEPARTMENT_ID = #{DEPARTMENT_ID}
</select>
<select id="getSuperviseDeptIndexData" parameterType="pd" resultType="pd" >
SELECT
(select count( 1 ) from BUS_CHECKRECORD h
left join SYS_USER u on h.CREATOR=u.NAME and u.CORPINFO_ID = #{CORPINFO_ID} and u.ISDELETE=0
left join BUS_LISTMANAGER l on l.CUSTOM_ID=h.CUSTOM_ID
where h.ISDELETE=0 and h.CORPINFO_ID = #{CORPINFO_ID} and u.DEPARTMENT_ID=d.DEPARTMENT_ID and u.DEPARTMENT_ID!=l.DEPARTMENT_ID
and YEAR(h.CREATTIME)=YEAR(NOW())) as check_count,
(select count( 1 ) from BUS_HIDDEN h
left join BUS_LISTMANAGER l on l.CUSTOM_ID=h.CUSTOM_ID
where h.ISDELETE=0 and h.STATE>0 and h.HIDDENFINDDEPT=d.DEPARTMENT_ID and h.HIDDENFINDDEPT!=l.DEPARTMENT_ID
and YEAR(h.CREATTIME)=YEAR(NOW())) as hidden_count,
(select count( 1 ) from BUS_HIDDEN h
left join BUS_LISTMANAGER l on l.CUSTOM_ID=h.CUSTOM_ID
where h.ISDELETE=0 and h.STATE=4 and h.HIDDENFINDDEPT=d.DEPARTMENT_ID and h.HIDDENFINDDEPT!=l.DEPARTMENT_ID
and YEAR(h.CREATTIME)=YEAR(NOW())) as rectify_count
FROM
OA_DEPARTMENT d
where
d.DEPARTMENT_ID = #{DEPARTMENT_ID}
</select>
<select id="getUserIndexData" parameterType="pd" resultType="pd" >
SELECT
u.USER_ID,
(select count( 1 ) from BUS_CHECKRECORD h where h.ISDELETE=0 and h.CREATOR=u.NAME and h.CORPINFO_ID = #{CORPINFO_ID}
and YEAR(h.CREATTIME)=YEAR(NOW())) as check_count,
(select count( 1 ) from BUS_HIDDEN h where h.ISDELETE=0 and h.CREATOR=u.USER_ID
and YEAR(h.CREATTIME)=YEAR(NOW())) as hidden_count,
(select count( 1 ) from BUS_HIDDENCHECK h where h.USER_ID=u.USER_ID and h.STATUS = '1'
and YEAR(h.CHECK_TIME)=YEAR(NOW())) as rectify_count
FROM
SYS_USER u
where
u.USER_ID = #{USER_ID}
</select>
<!-- 列表(全部) -->
<select id="listAllForDiagnosis" parameterType="pd" resultType="pd">
select
f.*,
u.NAME as USER_NAME,
d.NAME as DEPARTMENT_NAME,
(select t.FILEPATH from bus_imgfiles t where t.TYPE = 3 and t.FOREIGN_KEY = f.HIDDEN_ID and t.FILEPATH not like '%.mp4' limit 1) as HD_IMGS,
(select t.FILEPATH from bus_imgfiles t where t.TYPE = 4 and t.FOREIGN_KEY = f.HIDDEN_ID limit 1) as ZG_IMGS
from
<include refid="tableName"></include> f
left join SYS_USER u on u.USER_ID = f.CREATOR
left join OA_DEPARTMENT d on d.DEPARTMENT_ID = f.HIDDENFINDDEPT
where f.STATE != 0 and f.ISDELETE = '0'
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
and f.CORPINFO_ID=#{CORPINFO_ID}
</if>
<if test="MONTH != null and MONTH != ''"><!-- 关键词检索 -->
and DATE_FORMAT(f.CREATTIME,'%Y-%m')=#{MONTH}
</if>
order by CREATTIME desc
</select>
<!-- 查询未对接数据 -->
<select id="listForDocking" parameterType="pd" resultType="pd" >
SELECT
h.*,
FROM
BUS_HIDDEN h
WHERE
h.CORPINFO_ID = #{CORPINFO_ID}
and h.IS_DOCKING is null
and h.ISDELETE = 0
</select>
<select id="findByMainId" resultType="com.zcloud.entity.PageData">
select
f.*,
u.NAME as USER_NAME,
d.NAME as DEPARTMENT_NAME,
(select t.FILEPATH from bus_imgfiles t where t.TYPE = 3 and t.FOREIGN_KEY = f.HIDDEN_ID and t.FILEPATH not like '%.mp4' limit 1) as HD_IMGS,
(select t.FILEPATH from bus_imgfiles t where t.TYPE = 4 and t.FOREIGN_KEY = f.HIDDEN_ID limit 1) as ZG_IMGS
from
<include refid="tableName"></include> f
left join SYS_USER u on u.USER_ID = f.CREATOR
left join OA_DEPARTMENT d on d.DEPARTMENT_ID = f.HIDDENFINDDEPT
where f.STATE != 0 and f.ISDELETE = '0'
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
and f.CORPINFO_ID=#{CORPINFO_ID}
</if>
<if test="MONTH != null and MONTH != ''"><!-- 关键词检索 -->
and DATE_FORMAT(f.CREATTIME,'%Y-%m')=#{MONTH}
</if>
order by CREATTIME desc
</select>
<select id="anaysis" resultType="com.zcloud.entity.PageData">
2024-02-01 16:46:11 +08:00
select count(1) as num, a.STATE from bus_hiddendangercheckstandard_hidden a where a.ISDELETE = '0'
2024-01-31 16:53:07 +08:00
<if test="ids != null and ids.size != 0">
and a.CUSTOM_ID in
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
'${item}'
</foreach>
</if>
group by a.STATE
</select>
<select id="findByKey" parameterType="pd" resultType="com.zcloud.entity.PageData">
select
a.NAME as HIDDEN_CREATOR_NAME, f.*
from
<include refid="tableName"></include> f
left join sys_user a on a.USER_ID = f.CREATOR
where f.ISDELETE = '0'and f.FOREIGN_ID = #{FOREIGN_ID}
</select>
<select id="findByQue" parameterType="pd" resultType="com.zcloud.entity.PageData">
select
conUser.NAME as conUserName,f.*
from
<include refid="tableName"></include> f
left join sys_user conUser on conUser.USER_ID = f.CONFIRM_USER
where f.ISDELETE = '0'and f.HIDDEN_ID = #{HIDDEN_ID}
</select>
<select id="findByYin" parameterType="pd" resultType="com.zcloud.entity.PageData">
select
re.NAME as RECTIFICATIONORNAME, f.*
from
<include refid="tableName"></include> f
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
where f.ISDELETE = '0'and f.HIDDEN_ID = #{HIDDEN_ID}
</select>
<!-- 通过隐患发现人、整改人、整改负责人获取数据 -->
<select id="findByTs" parameterType="pd" resultType="com.zcloud.entity.PageData">
select
<include refid="Field"></include>,
ts.TYPE as TSTYPE,
conUser.name as tsname
from
<include refid="tableName"></include> f
left join bus_hiddenexamine ts on ts.HIDDEN_ID = f.HIDDEN_ID
left join sys_user conUser on conUser.USER_ID = f.CONFIRM_USER
where f.STATE in ('7','8') and f.ISDELETE = '0'and f.HIDDEN_ID = #{HIDDEN_ID}
GROUP BY f.HIDDEN_ID
</select>
<!--通过安全环保检查ID获取隐患-->
<select id="findByInspectionId" parameterType="pd" resultType="com.zcloud.entity.PageData">
select
f.HIDDEN_ID
from
<include refid="tableName"></include> f
where
f.FOREIGN_ID = #{INSPECTION_ID}
</select>
<!-- 列表(全部) -->
<select id="listAllInspection" parameterType="pd" resultType="com.zcloud.entity.PageData">
select
f.HIDDENDESCR,
f.CREATTIME,
f.HIDDENPART,
hr.HIDDENREGION HIDDENPART_NAME,
f.HIDDENLEVEL,
lv.NAME HIDDENLEVEL_NAME,
f.HIDDENTYPE,
ht.NAME HIDDENTYPE_NAME,
f.HIDDENTYPE2,
ht2.NAME HIDDENTYPE2_NAME,
f.LONGITUDE,
f.LATITUDE,
f.HIDDENFINDDEPT,
crd.NAME HIDDENFINDDEPT_NAME,
f.CREATOR,
cr.NAME CREATOR_NAME,
f.HIDDEN_ID,
f.ISRELEVANT,
f.POSITIONDESC
from
<include refid="tableName"></include> f
left join bus_hiddenregion hr on hr.HIDDENREGION_ID = f.HIDDENPART
left join <include refid="dicTableName"></include> lv on f.HIDDENLEVEL = lv.BIANMA
left join <include refid="dicTableName"></include> ht on f.HIDDENTYPE = ht.BIANMA
left join <include refid="dicTableName"></include> ht2 on f.HIDDENTYPE2 = ht2.BIANMA and ht2.PARENT_ID = '18c0a9aea6e54feab9f4ab3f46e0bc86'
left join oa_department crd on crd.DEPARTMENT_ID = f.HIDDENFINDDEPT
left join sys_user cr on cr.USER_ID = f.CREATOR
where f.ISDELETE = '0'
<if test="FOREIGN_ID != null and FOREIGN_ID !=''" >
and f.FOREIGN_ID = #{FOREIGN_ID}
</if>
<if test="KEYWORDS != null and KEYWORDS != ''"><!-- 关键词检索 -->
and
(
f.CHECK_CONTENT LIKE CONCAT(CONCAT('%', #{KEYWORDS}),'%')
or
f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{KEYWORDS}),'%')
or
c.CORP_NAME LIKE CONCAT(CONCAT('%', #{KEYWORDS}),'%')
)
</if>
<if test="DEPT_PROVINCE != null and DEPT_PROVINCE != ''">
and c.PROVINCE = #{DEPT_PROVINCE}
</if>
<if test="DEPT_CITY != null and DEPT_CITY != ''">
and c.CITY = #{DEPT_CITY}
</if>
<if test="DEPT_COUNTRY != null and DEPT_COUNTRY != ''">
and c.COUNTRY = #{DEPT_COUNTRY}
</if>
<if test="DEPT_VILLAGE != null and DEPT_VILLAGE != ''">
and c.VILLAGE = #{DEPT_VILLAGE}
</if>
<if test="DEPARTMENT_ID != null and DEPARTMENT_ID != ''">
and c.CORP_OF_TYPE in (select CORPTYPE_ID from BUS_CORPTYPETODEPT ctod where ctod.DEPARTMENT_ID=#{DEPARTMENT_ID})
</if>
<if test="COUNTRY != null and COUNTRY != ''">
and c.COUNTRY = #{COUNTRY}
</if>
<if test="VILLAGE != null and VILLAGE != ''">
and c.VILLAGE = #{VILLAGE}
</if>
<if test="CORP_OF_TYPE != null and CORP_OF_TYPE != ''">
and c.CORP_OF_TYPE = #{CORP_OF_TYPE}
</if>
<if test="STARTTIME != null and STARTTIME != ''"><!-- 关键词检索 -->
and f.RECTIFICATIONDEADLINE &gt;= #{STARTTIME}
</if>
<if test="ENDTIME != null and ENDTIME != ''">
and f.RECTIFICATIONDEADLINE &lt;= #{ENDTIME}
</if>
<if test="STATE != null and STATE !='' and STATE != 0" >
and f.STATE = #{STATE}
</if>
<if test="HIDDENLEVEL != null and HIDDENLEVEL !=''" >
and f.HIDDENLEVEL = #{HIDDENLEVEL}
</if>
order by f.CREATTIME ASC
</select>
<!--根据用户ID获取待确认隐患-->
<select id="getCountByConfirmId" parameterType="pd" resultType="com.zcloud.entity.PageData">
SELECT
f.CREATOR,f.STATE
FROM
BUS_HIDDEN f
WHERE f.ISDELETE = '0' and f.STATE = '-2'
and HIDDENLEVEL not in ('jdyh001','hiddenLevel2002')
<if test="SELFUSERID != null and SELFUSERID != ''">
and f.CONFIRM_USER = #{SELFUSERID}
</if>
<if test="CORPINFO_ID != null and CORPINFO_ID != ''">
and f.CORPINFO_ID = #{CORPINFO_ID}
</if>
</select>
<!--根据用户ID获取待确认隐患-->
<select id="getCountSpecialByhId" parameterType="pd" resultType="com.zcloud.entity.PageData">
SELECT
f.CREATOR,f.STATE,exa.TYPE
FROM
BUS_HIDDENEXAMINE exa
left join BUS_HIDDEN f on exa.HIDDEN_ID = f.HIDDEN_ID
LEFT JOIN sys_user confirmUser on confirmUser.USER_ID = f.CONFIRM_USER <!-- 隐患确认人 -->
LEFT JOIN bus_hiddencheck hch on hch.HIDDEN_ID = f.HIDDEN_ID
left join bus_hidden_user bhu on bhu.HIDDEN_ID = f.HIDDEN_ID
WHERE
f.ISDELETE = '0'
and f.state != '0'
and exa.TYPE in ('1','2')
and exa.STATE = '-1'
<if test="roleLevel != null and roleLevel != ''"><!-- 权限显示 -->
<choose>
<when test='roleLevel == "0" '>
</when>
<when test='roleLevel == "1"'>
<if test="supDeparIds != null and supDeparIds != ''">
and (confirmUser.DEPARTMENT_ID in (${supDeparIds}) or bhu.DEPARTMENT_ID in (${supDeparIds}) or f.RECTIFICATIONDEPT in (${supDeparIds}) or hch.DEPARTMENT_ID in (${supDeparIds}))
</if>
</when>
<when test='roleLevel == "2"'>
<if test="SELFUSERID != null and SELFUSERID != ''">
and (bhu.USER_ID = #{SELFUSERID} or f.CONFIRM_USER = #{SELFUSERID} or f.RECTIFICATIONOR = #{SELFUSERID} or f.CHECKOR = #{SELFUSERID} )
</if>
</when>
</choose>
</if>
<if test="userId != null and userId != ''"><!-- 隐患确认人 -->
and f.CONFIRM_USER = #{userId}
</if>
and f.state != '0'
and f.state not in ('100','101','102')
and f.CORPINFO_ID = #{CORPINFO_ID}
</select>
<!-- 获取其他没有验收的隐患 -->
<select id="listOtherNotAccept" parameterType="pd" resultType="pd">
select
f.HIDDEN_ID
from
<include refid="tableName"></include> f
where f.ISDELETE = '0'
<if test="ACCEPTSTEP == 6">
and f.STATE != '4' and f.STATE != '8'
</if>
<if test="ACCEPTSTEP == 7">
and (f.STATE != '4' OR (f.STATE = '4' AND f.FINAL_CHECK IS NULL))
</if>
<if test="ACCEPTSTEP == 7">
and (f.STATE != '4' OR (f.STATE = '4' AND f.FINAL_CHECK IS NULL)) and f.STATE != '8'
</if>
and f.FOREIGN_ID = #{INSPECTION_ID} and f.HIDDEN_ID != #{HIDDEN_ID}
</select>
<!-- 列表 -->
<select id="listGwjdatalistPage" parameterType="page" resultType="com.zcloud.entity.PageData">
select
f.*
,lv.NAME HIDDENLEVELNAME
,re.NAME as RECTIFICATIONORNAME
,confirmUser.NAME as confirmUserName
,hiddenType.NAME as hiddenTypeName
,hiddenType2.NAME as hiddenTypeName2
,hregion.HIDDENREGION as hregionName
,(select count(1) from BUS_HIDDENEXAMINE eax where eax.HIDDEN_ID = f.HIDDEN_ID and eax.STATE = '-1') as exaCount
from
<include refid="tableName"></include> f
LEFT JOIN sys_user confirmUser on confirmUser.USER_ID = f.CONFIRM_USER <!-- 隐患确认人 -->
left join <include refid="dicTableName"></include> lv on f.HIDDENLEVEL = lv.BIANMA
left join <include refid="dicTableName"></include> hiddenType on f.HIDDENTYPE = hiddenType.BIANMA <!-- 隐患类型-->
left join <include refid="dicTableName"></include> hiddenType2 on f.HIDDENTYPE2 = hiddenType2.BIANMA <!-- 隐患类型-->
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join bus_hiddenregion hregion on hregion.HIDDENREGION_ID = f.HIDDENPART
left join bus_hiddendangercheckstandard_custom list on list.CUSTOM_ID = f.CUSTOM_ID
LEFT JOIN bus_hiddencheck hch on hch.HIDDEN_ID = f.HIDDEN_ID
left join bus_hidden_user bhu on bhu.HIDDEN_ID = f.HIDDEN_ID
<if test='pd.ArrayDATA_IDS !=null and pd.ArrayDATA_IDS !=""'>
left JOIN (select USER_ID from sys_USER where DEPARTMENT_ID in(${pd.ArrayDATA_IDS})) userfind on userfind.USER_ID = f.CREATOR
</if>
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 (confirmUser.DEPARTMENT_ID in (${pd.supDeparIds}) or bhu.DEPARTMENT_ID in (${pd.supDeparIds}) or f.RECTIFICATIONDEPT in (${pd.supDeparIds}) or hch.DEPARTMENT_ID in (${pd.supDeparIds}))
</when>
<when test="pd.roleLevel == '2'">
and (bhu.USER_ID =#{pd.loginUserId} or f.CONFIRM_USER = #{pd.loginUserId} or f.RECTIFICATIONOR = #{pd.loginUserId} or f.CHECKOR = #{pd.loginUserId} )
</when>
</choose>
</if>
and f.state not in ('0' ,'100','101','10')
and f.HIDDENLEVEL not in('hiddenLevel2002','jdyh001')
<if test='pd.CORPINFO_ID != null and pd.CORPINFO_ID != "" '>
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test='pd.stateConfirm != null and pd.stateConfirm != "" and pd.stateConfirm == "1"'><!-- 未确认确认隐患 -->
and f.state = '-2'
</if>
<if test='pd.stateConfirm != null and pd.stateConfirm != "" and pd.stateConfirm == "2"'><!-- 确认确认隐患 -->
and f.state != '-2'
</if>
<if test="pd.keySource != null and pd.keySource != '' "><!-- 隐患来源 -->
<if test='pd.keySource == "2"'>
and f.SOURCE in ('2','3')
</if>
<if test='pd.keySource != "2"'>
and f.SOURCE = #{pd.keySource}
</if>
</if>
<if test="pd.SOURCE != null and pd.SOURCE != '' "><!-- 隐患来源 -->
and f.SOURCE in ('2','3')
</if>
<if test="pd.keyHiddenDescr != null and pd.keyHiddenDescr != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.keyHiddenDescr}),'%'))
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%'))
</if>
<if test="pd.keyFindUserName != null and pd.keyFindUserName != ''"><!-- 隐患发现人 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.keyFindUserName}),'%') )
</if>
<if test="pd.keyFindUserDept != null and pd.keyFindUserDept != ''"><!-- 隐患发现部门 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.DEPARTMENT_ID = #{pd.keyFindUserDept} )
</if>
<if test="pd.keyHiddenType != null and pd.keyHiddenType != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE = #{pd.keyHiddenType}
</if>
<if test="pd.keyHiddenType2 != null and pd.keyHiddenType2 != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE2 = #{pd.keyHiddenType2}
</if>
<if test="pd.keyHiddenPart != null and pd.keyHiddenPart != ''"><!-- 隐患部位 -->
and f.HIDDENPART = #{pd.keyHiddenPart}
</if>
<if test="pd.keyHiddenlevel != null and pd.keyHiddenlevel != ''"><!-- 隐患级别 -->
and f.HIDDENLEVEL = #{pd.keyHiddenlevel}
</if>
<if test='pd.CONFIRM_USER != null and pd.CONFIRM_USER != "" and pd.roleLevel != "1"'><!-- 隐患确认人 -->
and f.CONFIRM_USER = #{pd.CONFIRM_USER}
</if>
<!-- <if test="pd.keyFindStateTime != null and pd.keyFindStateTime != ''">&lt;!&ndash; 隐患发现时间 &ndash;&gt;-->
<!-- and f.DISCOVERYTIME >= #{pd.keyFindStateTime}-->
<!-- </if>-->
<if test="pd.STARTTIME != null and pd.STARTTIME != ''"><!-- 关键词检索 -->
and f.DISCOVERYTIME >= #{pd.STARTTIME}
</if>
<if test="pd.ENDTIME != null and pd.ENDTIME != ''">
and f.DISCOVERYTIME &lt;= #{pd.ENDTIME}
</if>
<!-- <if test="pd.keyFindEndTime != null and pd.keyFindEndTime != ''">&lt;!&ndash; 隐患发现时间 &ndash;&gt;-->
<!-- and f.DISCOVERYTIME &lt;= #{pd.keyFindEndTime}-->
<!-- </if>-->
<if test="pd.keyConfirmUser != null and pd.keyConfirmUser != ''"><!-- 确认人 -->
and (confirmUser.NAME LIKE CONCAT(CONCAT('%', #{pd.keyConfirmUser}),'%'))
</if>
<if test="pd.keyMajor != null and pd.keyMajor != ''"><!-- 重大隐患 -->
and (lv.PARENT_ID = '5ff9daf78e9a4fb1b40d77980656799d' or lv.DICTIONARIES_ID='5ff9daf78e9a4fb1b40d77980656799d' )
</if>
<if test="pd.keyHiddenSpecialType != null and pd.keyHiddenSpecialType != ''">
and f.HIDDEN_ID in (select hex.HIDDEN_ID from bus_hiddenexamine hex
where hex.TYPE = #{pd.keyHiddenSpecialType} and hex.STATE ='1' )
</if>
<if test="pd.RECTIFICATIONOR != null and pd.RECTIFICATIONOR != ''"><!-- 整改人 -->
and f.RECTIFICATIONOR = #{pd.RECTIFICATIONOR}}
</if>
<!--<if test="pd.ArrayDATA_IDS != null and pd.ArrayDATA_IDS != ''">
or (list.DEPARTMENT_ID in (${pd.ArrayDATA_IDS})
)
</if>-->
group by f.HIDDEN_ID
order by FIELD ( f.STATE, '1', '7','-2', '11', '12', '13', '14', '15', '101', '102' ) desc,
f.STATE + 0 asc,
f.CREATTIME desc
</select>
<!-- 忽略隐患列表 -->
<select id="listIgnoredatalistPage" parameterType="page" resultType="com.zcloud.entity.PageData">
select
f.*
,lv.NAME HIDDENLEVELNAME
,re.NAME as RECTIFICATIONORNAME
,confirmUser.NAME as confirmUserName
,hiddenType.NAME as hiddenTypeName
,hiddenType2.NAME as hiddenTypeName2
,hregion.HIDDENREGION as hregionName
,(select count(1) from BUS_HIDDENEXAMINE eax where eax.HIDDEN_ID = f.HIDDEN_ID and eax.STATE = '-1') as exaCount
from
<include refid="tableName"></include> f
LEFT JOIN sys_user confirmUser on confirmUser.USER_ID = f.CONFIRM_USER <!-- 隐患确认人 -->
left join <include refid="dicTableName"></include> lv on f.HIDDENLEVEL = lv.BIANMA
left join <include refid="dicTableName"></include> hiddenType on f.HIDDENTYPE = hiddenType.BIANMA <!-- 隐患类型-->
left join <include refid="dicTableName"></include> hiddenType2 on f.HIDDENTYPE2 = hiddenType2.BIANMA <!-- 隐患类型-->
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join bus_hiddenregion hregion on hregion.HIDDENREGION_ID = f.HIDDENPART
left join bus_hiddendangercheckstandard_custom list on list.CUSTOM_ID = f.CUSTOM_ID
left join bus_hidden_user bhu on bhu.HIDDEN_ID = f.HIDDEN_ID
<if test='pd.ArrayDATA_IDS !=null and pd.ArrayDATA_IDS !=""'>
left JOIN (select USER_ID from sys_USER where DEPARTMENT_ID in(${pd.ArrayDATA_IDS})) userfind on userfind.USER_ID = f.CREATOR
</if>
LEFT JOIN bus_hiddencheck hch on hch.HIDDEN_ID = f.HIDDEN_ID
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 (confirmUser.DEPARTMENT_ID in (${pd.supDeparIds}) or bhu.DEPARTMENT_ID in (${pd.supDeparIds}) or f.RECTIFICATIONDEPT in (${pd.supDeparIds}) or hch.DEPARTMENT_ID in (${pd.supDeparIds}))
</when>
<when test='pd.roleLevel == "2"'>
and (bhu.USER_ID =#{pd.loginUserId} or f.CONFIRM_USER = #{pd.loginUserId} or f.RECTIFICATIONOR = #{pd.loginUserId} or f.CHECKOR = #{pd.loginUserId} )
</when>
</choose>
</if>
and f.state not in ('0')
and f.state >= '4'
and f.HIDDENLEVEL not in('hiddenLevel2002','jdyh001')
<if test='pd.CORPINFO_ID != null and pd.CORPINFO_ID != "" '>
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test="pd.keySource != null and pd.keySource != '' "><!-- 隐患来源 -->
<if test='pd.keySource == "2"'>
and f.SOURCE in ('2','3')
</if>
<if test='pd.keySource != "2"'>
and f.SOURCE = #{pd.keySource}
</if>
</if>
<if test="pd.SOURCE != null and pd.SOURCE != '' "><!-- 隐患来源 -->
and f.SOURCE in ('2','3')
</if>
<if test="pd.keyHiddenDescr != null and pd.keyHiddenDescr != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.keyHiddenDescr}),'%'))
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%'))
</if>
<if test="pd.keyFindUserName != null and pd.keyFindUserName != ''"><!-- 隐患发现人 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.keyFindUserName}),'%') )
</if>
<if test="pd.keyFindUserDept != null and pd.keyFindUserDept != ''"><!-- 隐患发现部门 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.DEPARTMENT_ID = #{pd.keyFindUserDept} )
</if>
<if test="pd.keyHiddenType != null and pd.keyHiddenType != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE = #{pd.keyHiddenType}
</if>
<if test="pd.keyHiddenType2 != null and pd.keyHiddenType2 != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE2 = #{pd.keyHiddenType2}
</if>
<if test="pd.keyHiddenPart != null and pd.keyHiddenPart != ''"><!-- 隐患部位 -->
and f.HIDDENPART = #{pd.keyHiddenPart}
</if>
<if test="pd.keyHiddenlevel != null and pd.keyHiddenlevel != ''"><!-- 隐患级别 -->
and f.HIDDENLEVEL = #{pd.keyHiddenlevel}
</if>
<if test='pd.CONFIRM_USER != null and pd.CONFIRM_USER != "" and pd.roleLevel != "1"'><!-- 隐患确认人 -->
and (f.CONFIRM_USER = #{pd.CONFIRM_USER} or f.CREATOR = #{pd.CONFIRM_USER} or bhu.USER_ID = #{pd.CONFIRM_USER})
</if>
<if test="pd.STARTTIME != null and pd.STARTTIME != ''"><!-- 关键词检索 -->
and f.DISCOVERYTIME >= #{pd.STARTTIME}
</if>
<if test="pd.ENDTIME != null and pd.ENDTIME != ''">
and f.DISCOVERYTIME &lt;= #{pd.ENDTIME}
</if>
<if test="pd.keyConfirmUser != null and pd.keyConfirmUser != ''"><!-- 确认人 -->
and (confirmUser.NAME LIKE CONCAT(CONCAT('%', #{pd.keyConfirmUser}),'%'))
</if>
<if test="pd.keyMajor != null and pd.keyMajor != ''"><!-- 重大隐患 -->
and (lv.PARENT_ID = '5ff9daf78e9a4fb1b40d77980656799d' or lv.DICTIONARIES_ID='5ff9daf78e9a4fb1b40d77980656799d' )
</if>
<if test="pd.keyHiddenSpecialType != null and pd.keyHiddenSpecialType != ''">
and f.HIDDEN_ID in (select hex.HIDDEN_ID from bus_hiddenexamine hex
where hex.TYPE = #{pd.keyHiddenSpecialType} and hex.STATE ='1' )
</if>
<if test="pd.RECTIFICATIONOR != null and pd.RECTIFICATIONOR != ''"><!-- 整改人 -->
and f.RECTIFICATIONOR = #{pd.RECTIFICATIONOR}}
</if>
group by f.HIDDEN_ID
order by f.CREATTIME desc,f.STATE + 0 asc
</select>
<!-- 安全环保检查归档后的隐患列表 -->
<select id="hiddenInspectionlistPage" parameterType="page" resultType="com.zcloud.entity.PageData">
select
iou.NAME INSPECTION_ORIGINATOR_NAME,
ild.NAME INSPECTION_LEADDEPARTMENT_NAME,
iod.NAME INSPECTION_DEPARTMENT_NAME,
isd.NAME INSPECTED_DEPARTMENT_NAME,
isu.NAME INSPECTED_SITEUSER_NAME,
isu.USER_ID INSPECTED_SITEUSER_ID,
se.INSPECTION_STATUS,
se.INSPECTION_ID,
se.INSPECTED_DEPARTMENT_ID,
se.INSPECTION_SUBJECT,
f.HIDDENDESCR,
f.CREATOR,
c.NAME CREATOR_NAME,
f.CONFIRM_USER,
hcu.NAME CONFIRM_USER_NAME,
f.RECTIFICATIONOR,
f.CHECKOR,
f.STATE HIDDEN_STATUS,
f.FINAL_CHECK,
f.FINAL_CHECKOR,
f.FINAL_CHECKTIME,
f.FINAL_CHECKDESCR,
isa.INSPECTION_ASSESS_ID,
isa.ASSESS_SCORE,
isa.ASSESS_PENALTY_AMOUNT,
f.HIDDEN_ID
from
<include refid="tableName"></include> f
LEFT JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL se ON se.INSPECTION_ID = f.FOREIGN_ID
LEFT JOIN sys_user iou ON iou.USER_ID = se.INSPECTION_ORIGINATOR_ID
LEFT JOIN oa_department iod ON iod.DEPARTMENT_ID = iou.DEPARTMENT_ID
LEFT JOIN oa_department ild ON ild.DEPARTMENT_ID = se.INSPECTION_LEADDEPARTMENT_ID
LEFT JOIN OA_DEPARTMENT isd ON isd.DEPARTMENT_ID = se.INSPECTED_DEPARTMENT_ID
LEFT JOIN SYS_USER isu ON isu.USER_ID = se.INSPECTED_SITEUSER_ID
LEFT JOIN sys_user c on c.USER_ID = f.CREATOR
left join <include refid="dicTableName"></include> lv on f.HIDDENLEVEL = lv.BIANMA
LEFT JOIN sys_user hcu on hcu.USER_ID = f.CONFIRM_USER
LEFT JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL_ASSESS isa on isa.HIDDEN_ID = f.HIDDEN_ID and isa.ISDELETE = '0'
LEFT JOIN sys_user confirmUser on confirmUser.USER_ID = f.CONFIRM_USER <!-- 隐患确认人 -->
left join bus_hidden_user bhu on bhu.HIDDEN_ID = f.HIDDEN_ID
LEFT JOIN bus_hiddencheck hch on hch.HIDDEN_ID = f.HIDDEN_ID
where f.ISDELETE = '0' and f.SOURCE IN ('1','2') and f.STATE != '100'
<if test="pd.roleLevel != null and pd.roleLevel != ''"><!-- 权限显示 -->
<choose>
<when test='pd.roleLevel == "0"'>
</when>
<when test='pd.roleLevel == "1"'>
and (confirmUser.DEPARTMENT_ID in (${pd.supDeparIds}) or bhu.DEPARTMENT_ID in (${pd.supDeparIds}) or f.RECTIFICATIONDEPT in (${pd.supDeparIds}) or hch.DEPARTMENT_ID in (${pd.supDeparIds}))
</when>
<when test='pd.roleLevel == "2"'>
and (bhu.USER_ID =#{pd.loginUserId} or f.CONFIRM_USER = #{pd.loginUserId} or f.RECTIFICATIONOR = #{pd.loginUserId} or f.CHECKOR = #{pd.loginUserId} )
</when>
</choose>
</if>
<if test="pd.CREATOR_NAME != '' and pd.CREATOR_NAME != null">
and c.NAME LIKE CONCAT(CONCAT('%', #{pd.CREATOR_NAME}),'%')
</if>
<if test='pd.CORPINFO_ID != null and pd.CORPINFO_ID != "" '>
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test="pd.INSPECTION_SUBJECT != null and pd.INSPECTION_SUBJECT != ''"><!-- 检查题目 -->
and se.INSPECTION_SUBJECT = #{pd.INSPECTION_SUBJECT,jdbcType=VARCHAR}
</if>
<if test="pd.INSPECTED_DEPARTMENT_NAME != null and pd.INSPECTED_DEPARTMENT_NAME != ''"><!-- 被检查单位 -->
and isd.NAME LIKE CONCAT(CONCAT('%', #{pd.INSPECTED_DEPARTMENT_NAME}),'%')
</if>
<if test="pd.INSPECTION_DEPARTMENT_NAME != null and pd.INSPECTION_DEPARTMENT_NAME != ''"><!-- 检查部门 -->
and iod.NAME LIKE CONCAT(CONCAT('%', #{pd.INSPECTION_DEPARTMENT_NAME}),'%')
</if>
<if test="pd.INSPECTION_ORIGINATOR_NAME != null and pd.INSPECTION_ORIGINATOR_NAME != ''"><!-- 检查发起人 -->
and iou.NAME LIKE CONCAT(CONCAT('%', #{pd.INSPECTION_ORIGINATOR_NAME}),'%')
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%')
</if>
<if test='pd.HIDDEN_STATUS != null and pd.HIDDEN_STATUS != ""'><!-- 分公司内隐患处理状态 -->
and f.STATE = #{pd.HIDDEN_STATUS}
</if>
<if test='pd.INSPECTION_ID != null and pd.INSPECTION_ID != ""'><!-- 安全环保检查ID -->
and f.FOREIGN_ID = #{pd.INSPECTION_ID}
</if>
<if test='pd.INSPECTION_STATUS != null and pd.INSPECTION_STATUS != ""'> <!-- 安全、环保检查隐患处理状态 -->
<choose>
<when test="pd.INSPECTION_STATUS == '3-7'">
and se.INSPECTION_STATUS in ('3','4','5','6','7')
</when>
<otherwise>
and se.INSPECTION_STATUS = #{pd.INSPECTION_STATUS}
</otherwise>
</choose>
</if>
<if test='pd.INSPECTION_ASSESS_ID != null and pd.INSPECTION_ASSESS_ID != ""'> <!-- 安全、环保检查隐患考评状态 -->
<choose>
<when test="pd.INSPECTION_ASSESS_ID == 1">
and isa.INSPECTION_ASSESS_ID IS NOT NULL
</when>
<otherwise>
and isa.INSPECTION_ASSESS_ID IS NULL
</otherwise>
</choose>
</if>
<!--
<if test='pd.stateConfirm != null and pd.stateConfirm != "" and pd.stateConfirm == "1"'>&lt;!&ndash; 未确认确认隐患 &ndash;&gt;
and f.state = '-2'
</if>
<if test='pd.stateConfirm != null and pd.stateConfirm != "" and pd.stateConfirm == "2"'>&lt;!&ndash; 确认确认隐患 &ndash;&gt;
and f.state != '-2'
</if>
<if test="pd.keyFindUserName != null and pd.keyFindUserName != ''">&lt;!&ndash; 隐患发现人 &ndash;&gt;
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.keyFindUserName}),'%') )
</if>
<if test="pd.keyFindUserDept != null and pd.keyFindUserDept != ''">&lt;!&ndash; 隐患发现部门 &ndash;&gt;
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.DEPARTMENT_ID = #{pd.keyFindUserDept} )
</if>
<if test="pd.keyHiddenType != null and pd.keyHiddenType != ''">&lt;!&ndash; 隐患类型 &ndash;&gt;
and f.HIDDENTYPE = #{pd.keyHiddenType}
</if>
<if test="pd.keyHiddenType2 != null and pd.keyHiddenType2 != ''">&lt;!&ndash; 隐患类型 &ndash;&gt;
and f.HIDDENTYPE2 = #{pd.keyHiddenType2}
</if>
<if test="pd.keyHiddenPart != null and pd.keyHiddenPart != ''">&lt;!&ndash; 隐患部位 &ndash;&gt;
and f.HIDDENPART = #{pd.keyHiddenPart}
</if>
<if test="pd.keyHiddenlevel = 'hiddenLevel2002'">&lt;!&ndash; 隐患级别 &ndash;&gt;
and f.HIDDENLEVEL in ('hiddenLevel2001','hiddenLevel2002')
</if>
<if test="pd.CONFIRM_USER != null and pd.CONFIRM_USER != ''">&lt;!&ndash; 隐患确认人 &ndash;&gt;
and f.CONFIRM_USER = #{pd.CONFIRM_USER}
</if>
<if test="pd.keyFindStateTime != null and pd.keyFindStateTime != ''">&lt;!&ndash; 隐患发现时间 &ndash;&gt;
and f.DISCOVERYTIME >= #{pd.keyFindStateTime}
</if>
<if test="pd.keyFindEndTime != null and pd.keyFindEndTime != ''">&lt;!&ndash; 隐患发现时间 &ndash;&gt;
and f.DISCOVERYTIME &lt;= #{pd.keyFindEndTime}
</if>
<if test="pd.keyConfirmUser != null and pd.keyConfirmUser != ''">&lt;!&ndash; 确认人 &ndash;&gt;
and (confirmUser.NAME LIKE CONCAT(CONCAT('%', #{pd.keyConfirmUser}),'%'))
</if>
<if test="pd.keyMajor != null and pd.keyMajor != ''">&lt;!&ndash; 重大隐患 &ndash;&gt;
and (lv.PARENT_ID = '5ff9daf78e9a4fb1b40d77980656799d' or lv.DICTIONARIES_ID='5ff9daf78e9a4fb1b40d77980656799d' )
</if>
<if test="pd.keyHiddenSpecialType != null and pd.keyHiddenSpecialType != ''">
and f.HIDDEN_ID in (select hex.HIDDEN_ID from bus_hiddenexamine hex
where hex.TYPE = #{pd.keyHiddenSpecialType} and hex.STATE ='1' )
</if>
<if test="pd.RECTIFICATIONOR != null and pd.RECTIFICATIONOR != ''">&lt;!&ndash; 整改人 &ndash;&gt;
and f.RECTIFICATIONOR = #{pd.RECTIFICATIONOR}}
</if>
-->
GROUP BY f.HIDDEN_ID
ORDER BY f.CREATTIME desc,f.STATE + 0 asc
</select>
<!-- 获取其他没有指派完成的隐患 -->
<select id="listOtherNotAssign" parameterType="pd" resultType="com.zcloud.entity.PageData">
select
f.HIDDEN_ID
from
<include refid="tableName"></include> f
where f.ISDELETE = '0' and f.STATE in ('101','102')
and f.FOREIGN_ID = #{INSPECTION_ID} and f.HIDDEN_ID != #{HIDDEN_ID}
</select>
<!--新的只针对pc安全环保检查-->
<select id="listOtherNotAccept4pc" parameterType="pd" resultType="com.zcloud.entity.PageData">
select
f.HIDDEN_ID
from
<include refid="tableName"></include> f
where f.ISDELETE = '0'
AND ( f.FINAL_CHECK != '1' OR f.FINAL_CHECK IS NULL )
and f.FOREIGN_ID = #{INSPECTION_ID} and f.HIDDEN_ID != #{HIDDEN_ID}
</select>
<!-- 列表 -->
<select id="getListForTianzhangdatalistPage" parameterType="page" resultType="com.zcloud.entity.PageData">
SELECT
f.HIDDEN_ID,
f.SOURCE,
f.HIDDENDESCR,
f.RECTIFICATIONTYPE,
f.HIDDENLEVEL,
f.CONFIRM_USER,
f.CONFIRM_TIME,
f.HIDDENPART,
hcdic.HIDDENREGION as HREGIONNAME,
f.RECTIFICATIONTIME,
f.RECTIFICATIONOR,
lv.NAME HIDDENLEVELNAME,
f.DISCOVERYTIME,
f.STATE,
f.CREATOR,
ch.NAME CHECKORNAME,
zg.name RECTIFICATIONORNAME,
confirmUser.name confirmUserName,
f.CHECKTIME,
(select group_concat(chr.NAME) from BUS_HIDDENCHECK bh left join sys_user chr on chr.USER_ID=bh.USER_ID where bh.HIDDEN_ID=f.HIDDEN_ID ) CHECKNAME
FROM
bus_hidden f
LEFT JOIN bus_hiddenregion hcdic on hcdic.HIDDENREGION_ID = f.HIDDENPART
left join SYS_DICTIONARIES lv on f.HIDDENLEVEL = lv.BIANMA
left join sys_user ch on ch.USER_ID = f.CHECKOR <!-- CHECKOR是隐患表里的验收人 -->
LEFT JOIN bus_hiddencheck hch on hch.HIDDEN_ID = f.HIDDEN_ID
left join bus_hidden_user bhu on bhu.HIDDEN_ID = f.HIDDEN_ID
left join sys_user bhuUser on bhuUser.user_id = bhu.user_id
left join sys_user zg on zg.USER_ID = f.RECTIFICATIONOR
LEFT JOIN sys_user confirmUser on confirmUser.USER_ID = f.CONFIRM_USER <!-- 隐患确认人 -->
WHERE
1 = 1
and f.ISDELETE = '0'
<if test="pd.roleLevel != null and pd.roleLevel != ''"><!-- 权限显示 -->
<choose>
<when test='pd.roleLevel == "0"'>
</when>
<when test='pd.roleLevel == "1"'>
and (confirmUser.DEPARTMENT_ID in (${pd.supDeparIds}) or bhuUser.DEPARTMENT_ID in (${pd.supDeparIds}) or f.RECTIFICATIONDEPT in (${pd.supDeparIds}) or hch.DEPARTMENT_ID in (${pd.supDeparIds}))
</when>
<when test='pd.roleLevel == "2"'>
and (f.CREATOR = #{pd.loginUserId} or f.RECTIFICATIONOR = #{pd.loginUserId} or f.CONFIRM_USER= #{pd.loginUserId} or bhu.USER_ID =#{pd.loginUserId} or f.CHECKOR = #{pd.loginUserId} or hch.USER_ID = #{pd.loginUserId})
</when>
</choose>
</if>
and (f.STATE not in ('0','7','8','100','101','102','5') )
and f.HIDDENLEVEL != 'hiddenLevel2002' and f.HIDDENLEVEL != 'hiddenLevel1001' and f.HIDDENLEVEL != 'jdyh001'
<if test='pd.queryUserId != null and pd.queryUserId != "" and pd.roleLevel !="1" and pd.roleLevel !="2" and pd.roleLevel !="0" '> <!-- 是否查询与自己有关的信息-->
and (
f.HIDDEN_ID in(select fh.HIDDEN_ID from bus_hidden_user fh where fh.USER_ID = #{pd.queryUserId})
or f.CONFIRM_USER = #{pd.queryUserId}
or f.RECTIFICATIONOR = #{pd.queryUserId}
or f.HIDDEN_ID in(select ch.HIDDEN_ID from bus_hiddencheck ch where ch.USER_ID = #{pd.queryUserId})
)
</if>
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 企业ID -->
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test="pd.RECTIFICATIONORNAME != null and pd.RECTIFICATIONORNAME != ''"><!-- 隐患描述 -->
and (zg.name LIKE CONCAT(CONCAT('%', #{pd.RECTIFICATIONORNAME}),'%'))
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%'))
</if>
<if test="pd.keySource != null and pd.keySource != '' "><!-- 隐患来源 -->
<if test='pd.keySource == "2"'>
and f.SOURCE in ('2','3')
</if>
<if test='pd.keySource != "2"'>
and f.SOURCE = #{pd.keySource}
</if>
</if>
<if test="pd.HIDDENFIND_NAME != null and pd.HIDDENFIND_NAME != ''"><!-- 隐患发现人 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.HIDDENFIND_NAME}),'%') )
</if>
<if test="pd.STARTTIME != null and pd.STARTTIME != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME <![CDATA[ >= ]]> CONCAT_WS(' ', #{pd.STARTTIME}, '00:00')
</if>
<if test="pd.ENDTIME != null and pd.ENDTIME != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME <![CDATA[ <= ]]> CONCAT_WS(' ', #{pd.ENDTIME}, '23:59')
</if>
<if test="pd.confirmUserName != null and pd.confirmUserName != ''"><!-- 隐患确认人 -->
and f.CONFIRM_USER in (
select cu.USER_ID from sys_user cu where
(
cu.USERNAME LIKE CONCAT(CONCAT('%',#{ pd.confirmUserName}),'%')
or
cu.NAME LIKE CONCAT(CONCAT('%', #{pd.confirmUserName}),'%')
or
cu.PHONE LIKE CONCAT(CONCAT('%', #{pd.confirmUserName}),'%')
)
and cu.CORPINFO_ID = #{pd.CORPINFO_ID}
)
</if>
<if test="pd.CHECKNAME != null and pd.CHECKNAME != ''"><!-- 验收人 -->
and f.HIDDEN_ID in (
SELECT
yhc.HIDDEN_ID
FROM
bus_hiddencheck yhc
LEFT JOIN sys_user yuser ON yuser.USER_ID = yhc.USER_ID AND yuser.CORPINFO_ID = #{pd.CORPINFO_ID}
where (
yuser.USERNAME LIKE CONCAT(CONCAT('%',#{ pd.CHECKNAME}),'%')
or
yuser.NAME LIKE CONCAT(CONCAT('%', #{pd.CHECKNAME}),'%')
or
yuser.PHONE LIKE CONCAT(CONCAT('%', #{pd.CHECKNAME}),'%')
)
)
</if>
<if test="pd.HIDDENLEVEL != null and pd.HIDDENLEVEL != ''">
and f.HIDDENLEVEL = #{pd.HIDDENLEVEL}
</if>
<if test="pd.HIDDENLEVEL != null and pd.HIDDENLEVEL != ''">
and f.HIDDENLEVEL = #{pd.HIDDENLEVEL}
</if>
<if test="pd.STATE != null and pd.STATE != ''">
and f.STATE = #{pd.STATE}
</if>
<if test="pd.keyHiddenPart != null and pd.keyHiddenPart != ''"><!-- 隐患部位 -->
and f.HIDDENPART = #{pd.keyHiddenPart}
</if>
<if test="pd.keyFindUserName != null and pd.keyFindUserName != ''"><!-- 隐患发现人 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.keyFindUserName}),'%') )
</if>
<if test="pd.keyFindUserDept != null and pd.keyFindUserDept != ''"><!-- 隐患发现部门 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.DEPARTMENT_ID = #{pd.keyFindUserDept} )
</if>
<if test="pd.keyHiddenType != null and pd.keyHiddenType != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE = #{pd.keyHiddenType}
</if>
<if test="pd.keyHiddenType2 != null and pd.keyHiddenType2 != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE2 = #{pd.keyHiddenType2}
</if>
group by f.HIDDEN_ID
order by f.CREATTIME desc,f.STATE + 0 asc
</select>
<update id="updateDocking" parameterType="pd" >
update
BUS_HIDDEN
set
IS_DOCKING = 1
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 只用与修改隐患状态 -->
<update id="editStateInspection" parameterType="pd">
update
<include refid="tableName"></include>
set
STATE = #{STATE}
where
FOREIGN_ID = #{INSPECTION_ID} and SOURCE = #{INSPECTION_SOURCE}
</update>
<!-- 修改信息 -->
<update id="editInformation" parameterType="pd">
update
<include refid="tableName"></include>
set
<if test="POSITIONDESC != null and POSITIONDESC != ''">
POSITIONDESC = #{POSITIONDESC}
</if>
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<update id="editstate" parameterType="pd">
update
<include refid="tableName"></include>
set
STATE = #{STATE}
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 修改 -->
<update id="confirmHidden" parameterType="pd">
update
<include refid="tableName"></include>
set
STATE = #{STATE},
CONFIRM_USER = #{CONFIRM_USER},
CONFIRM_TIME = #{CONFIRM_TIME},
RECTIFICATIONDEPT = #{RECTIFICATIONDEPT},
RECTIFICATIONOR = #{RECTIFICATIONOR},
RECTIFICATIONDEADLINE = #{RECTIFICATIONDEADLINE},
HIDDENLEVEL = #{HIDDENLEVEL}
<if test="CHECKOR != null and CHECKOR != ''">
,CHECKOR = #{CHECKOR}
</if>
<if test="CHECKDEPT != null and CHECKDEPT != ''">
,CHECKDEPT = #{CHECKDEPT}
</if>
<if test="CHECKTIME != null and CHECKTIME != ''">
,CHECKTIME = #{CHECKTIME}
</if>
<if test="RECTIFICATIONTYPE != null and RECTIFICATIONTYPE != ''">
,RECTIFICATIONTYPE = #{RECTIFICATIONTYPE}
</if>
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 安全环保检查隐患指派 -->
<update id="assign" parameterType="pd">
update
<include refid="tableName"></include>
set
STATE = #{STATE},
CONFIRM_USER = #{CONFIRM_USER},
CONFIRM_TIME = #{CONFIRM_TIME},
RECTIFICATIONTYPE = #{RECTIFICATIONTYPE},
RECTIFICATIONDEADLINE = #{RECTIFICATIONDEADLINE},
ISCONFIRM = #{ISCONFIRM},
RECTIFICATIONDEPT = #{RECTIFICATIONDEPT},
RECTIFICATIONOR = #{RECTIFICATIONOR},
CHECKDEPT = #{CHECKDEPT},
CHECKOR = #{CHECKOR},
HIDDEN_ID = HIDDEN_ID
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 验收 -->
<update id="finalcheck" parameterType="pd">
update
<include refid="tableName"></include>
set
FINAL_CHECK = #{FINAL_CHECK},
FINAL_CHECKOR = #{FINAL_CHECKOR},
FINAL_CHECKTIME = #{FINAL_CHECKTIME},
FINAL_CHECKDESCR = #{FINAL_CHECKDESCR}
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 修改隐患信息 -->
<update id="confirmUpdate" parameterType="pd">
update
<include refid="tableName"></include>
set
<if test="RECTIFICATIONDEPT != null and RECTIFICATIONDEPT != ''">
RECTIFICATIONDEPT = #{RECTIFICATIONDEPT},
</if>
<if test="RECTIFICATIONOR != null and RECTIFICATIONOR != ''">
RECTIFICATIONOR = #{RECTIFICATIONOR},
</if>
<if test="RECTIFICATIONDEADLINE != null and RECTIFICATIONDEADLINE != ''">
RECTIFICATIONDEADLINE = #{RECTIFICATIONDEADLINE},
</if>
<if test="CONFIRM_USER != null and CONFIRM_USER != ''">
CONFIRM_USER = #{CONFIRM_USER},
</if>
<if test="CONFIRM_TIME != null and CONFIRM_TIME != ''">
CONFIRM_TIME = #{CONFIRM_TIME},
</if>
<if test="STATE != null and STATE != ''">
STATE = #{STATE},
</if>
<if test="HIDDENLEVEL != null and HIDDENLEVEL != ''">
HIDDENLEVEL = #{HIDDENLEVEL}
</if>
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 修改隐患状态,-->
<update id="updateStateByHidden" parameterType="pd">
update
<include refid="tableName"></include>
set
STATE = #{STATE}
where
HIDDEN_ID = #{HIDDEN_ID}
</update>
<!-- 重大隐患核实列表 -->
<select id="verifydatalistPage" parameterType="page" resultType="com.zcloud.entity.PageData">
select
f.*
,lv.NAME HIDDENLEVELNAME
,re.NAME as RECTIFICATIONORNAME
,confirmUser.NAME as confirmUserName
,hiddenType.NAME as hiddenTypeName
,hiddenType2.NAME as hiddenTypeName2
,hregion.HIDDENREGION as hregionName
,(select count(1) from BUS_HIDDENEXAMINE eax where eax.HIDDEN_ID = f.HIDDEN_ID and eax.STATE = '-1') as exaCount
from
<include refid="tableName"></include> f
LEFT JOIN sys_user confirmUser on confirmUser.USER_ID = f.CONFIRM_USER <!-- 隐患确认人 -->
left join <include refid="dicTableName"></include> lv on f.HIDDENLEVEL = lv.BIANMA
left join <include refid="dicTableName"></include> hiddenType on f.HIDDENTYPE = hiddenType.BIANMA <!-- 隐患类型-->
left join <include refid="dicTableName"></include> hiddenType2 on f.HIDDENTYPE2 = hiddenType2.BIANMA <!-- 隐患类型-->
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join bus_hiddenregion hregion on hregion.HIDDENREGION_ID = f.HIDDENPART
left join bus_hiddendangercheckstandard_custom list on list.CUSTOM_ID = f.CUSTOM_ID
<if test='pd.ArrayDATA_IDS !=null and pd.ArrayDATA_IDS !=""'>
left JOIN (select USER_ID from sys_USER where DEPARTMENT_ID in(${pd.ArrayDATA_IDS})) userfind on userfind.USER_ID = f.CREATOR
</if>
where f.ISDELETE = '0'
and f.state not in ('0')
and f.STATE = '11'
<if test="pd.STATE != null and pd.STATE != ''">
and f.STATE = #{pd.STATE}
</if>
<if test='pd.CORPINFO_ID != null and pd.CORPINFO_ID != "" '>
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test='pd.stateConfirm != null and pd.stateConfirm != "" and pd.stateConfirm == "1"'><!-- 未确认确认隐患 -->
and f.state = '-2'
</if>
<if test='pd.stateConfirm != null and pd.stateConfirm != "" and pd.stateConfirm == "2"'><!-- 确认确认隐患 -->
and f.state != '-2'
</if>
<if test="pd.keySource != null and pd.keySource != '' "><!-- 隐患来源 -->
<if test='pd.keySource == "2"'>
and f.SOURCE in ('2','3')
</if>
<if test='pd.keySource != "2"'>
and f.SOURCE = #{pd.keySource}
</if>
</if>
<if test="pd.SOURCE != null and pd.SOURCE != '' "><!-- 隐患来源 -->
and f.SOURCE in ('2','3')
</if>
<if test="pd.keyHiddenDescr != null and pd.keyHiddenDescr != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.keyHiddenDescr}),'%'))
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%'))
</if>
<if test="pd.keyFindUserName != null and pd.keyFindUserName != ''"><!-- 隐患发现人 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.keyFindUserName}),'%') )
</if>
<if test="pd.keyFindUserDept != null and pd.keyFindUserDept != ''"><!-- 隐患发现部门 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.DEPARTMENT_ID = #{pd.keyFindUserDept} )
</if>
<if test="pd.keyHiddenType != null and pd.keyHiddenType != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE = #{pd.keyHiddenType}
</if>
<if test="pd.keyHiddenType2 != null and pd.keyHiddenType2 != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE2 = #{pd.keyHiddenType2}
</if>
<if test="pd.keyHiddenPart != null and pd.keyHiddenPart != ''"><!-- 隐患部位 -->
and f.HIDDENPART = #{pd.keyHiddenPart}
</if>
<if test="pd.keyHiddenlevel = 'hiddenLevel2002'"><!-- 隐患级别 -->
and f.HIDDENLEVEL in ('jdyh001','hiddenLevel2002')
</if>
<if test="pd.CONFIRM_USER != null and pd.CONFIRM_USER != ''"><!-- 隐患确认人 -->
and f.CONFIRM_USER = #{pd.CONFIRM_USER}
</if>
<if test="pd.keyFindStateTime != null and pd.keyFindStateTime != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME >= #{pd.keyFindStateTime}
</if>
<if test="pd.keyFindEndTime != null and pd.keyFindEndTime != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME &lt;= #{pd.keyFindEndTime}
</if>
<if test="pd.keyConfirmUser != null and pd.keyConfirmUser != ''"><!-- 确认人 -->
and (confirmUser.NAME LIKE CONCAT(CONCAT('%', #{pd.keyConfirmUser}),'%'))
</if>
<if test="pd.keyMajor != null and pd.keyMajor != ''"><!-- 重大隐患 -->
and (lv.PARENT_ID = '5ff9daf78e9a4fb1b40d77980656799d' or lv.DICTIONARIES_ID='5ff9daf78e9a4fb1b40d77980656799d' )
</if>
<if test="pd.keyHiddenSpecialType != null and pd.keyHiddenSpecialType != ''">
and f.HIDDEN_ID in (select hex.HIDDEN_ID from bus_hiddenexamine hex
where hex.TYPE = #{pd.keyHiddenSpecialType} and hex.STATE ='1' )
</if>
<if test="pd.RECTIFICATIONOR != null and pd.RECTIFICATIONOR != ''"><!-- 整改人 -->
and f.RECTIFICATIONOR = #{pd.RECTIFICATIONOR}}
</if>
<!--<if test="pd.ArrayDATA_IDS != null and pd.ArrayDATA_IDS != ''">
or (list.DEPARTMENT_ID in (${pd.ArrayDATA_IDS})
)
</if>-->
order by f.CREATTIME desc,f.STATE + 0 asc
</select>
<!-- 重大隐患列表 -->
<select id="majordatalistPage" parameterType="page" resultType="com.zcloud.entity.PageData">
select
f.*
,lv.NAME HIDDENLEVELNAME
,re.NAME as RECTIFICATIONORNAME
,confirmUser.NAME as confirmUserName
,hiddenType.NAME as hiddenTypeName
,hiddenType2.NAME as hiddenTypeName2
,hregion.HIDDENREGION as hregionName
,(select count(1) from BUS_HIDDENEXAMINE eax where eax.HIDDEN_ID = f.HIDDEN_ID and eax.STATE = '-1') as exaCount
from
<include refid="tableName"></include> f
LEFT JOIN sys_user confirmUser on confirmUser.USER_ID = f.CONFIRM_USER <!-- 隐患确认人 -->
left join <include refid="dicTableName"></include> lv on f.HIDDENLEVEL = lv.BIANMA
left join <include refid="dicTableName"></include> hiddenType on f.HIDDENTYPE = hiddenType.BIANMA <!-- 隐患类型-->
left join <include refid="dicTableName"></include> hiddenType2 on f.HIDDENTYPE2 = hiddenType2.BIANMA <!-- 隐患类型-->
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join bus_hiddenregion hregion on hregion.HIDDENREGION_ID = f.HIDDENPART
left join bus_hiddendangercheckstandard_custom list on list.CUSTOM_ID = f.CUSTOM_ID
LEFT JOIN bus_hiddencheck hch on hch.HIDDEN_ID = f.HIDDEN_ID
left join bus_hidden_user bhu on bhu.HIDDEN_ID = f.HIDDEN_ID
<if test='pd.ArrayDATA_IDS !=null and pd.ArrayDATA_IDS !=""'>
left JOIN (select USER_ID from sys_USER where DEPARTMENT_ID in(${pd.ArrayDATA_IDS})) userfind on userfind.USER_ID = f.CREATOR
</if>
where f.ISDELETE = '0'
<if test="pd.supDeparIds != null and pd.supDeparIds != '' and pd.supDeparIds !='ALL' and pd.supDeparIds !='NOT'">
or (confirmUser.DEPARTMENT_ID in (${pd.supDeparIds}) or bhu.DEPARTMENT_ID in (${pd.supDeparIds}) or f.RECTIFICATIONDEPT in (${pd.supDeparIds}) or hch.DEPARTMENT_ID in (${pd.supDeparIds}))
</if>
and f.state not in ('0')
<if test='pd.VERIFYSTATE == 10'>
and f.STATE != '11' and f.STATE = '-2'
</if>
<if test="pd.STATE != null and pd.STATE != ''">
and f.STATE = #{pd.STATE}
</if>
<if test='pd.CORPINFO_ID != null and pd.CORPINFO_ID != "" '>
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test='pd.stateConfirm != null and pd.stateConfirm != "" and pd.stateConfirm == "1"'><!-- 未确认确认隐患 -->
and f.state = '-2'
</if>
<if test='pd.stateConfirm != null and pd.stateConfirm != "" and pd.stateConfirm == "2"'><!-- 确认确认隐患 -->
and f.state != '-2'
</if>
<if test="pd.keySource != null and pd.keySource != '' "><!-- 隐患来源 -->
<if test='pd.keySource == "2"'>
and f.SOURCE in ('2','3')
</if>
<if test='pd.keySource != "2"'>
and f.SOURCE = #{pd.keySource}
</if>
</if>
<if test="pd.SOURCE != null and pd.SOURCE != '' "><!-- 隐患来源 -->
and f.SOURCE in ('2','3')
</if>
<if test="pd.keyHiddenDescr != null and pd.keyHiddenDescr != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.keyHiddenDescr}),'%'))
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%'))
</if>
<if test="pd.keyFindUserName != null and pd.keyFindUserName != ''"><!-- 隐患发现人 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.keyFindUserName}),'%') )
</if>
<if test="pd.keyFindUserDept != null and pd.keyFindUserDept != ''"><!-- 隐患发现部门 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.DEPARTMENT_ID = #{pd.keyFindUserDept} )
</if>
<if test="pd.keyHiddenType != null and pd.keyHiddenType != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE = #{pd.keyHiddenType}
</if>
<if test="pd.keyHiddenType2 != null and pd.keyHiddenType2 != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE2 = #{pd.keyHiddenType2}
</if>
<if test="pd.keyHiddenPart != null and pd.keyHiddenPart != ''"><!-- 隐患部位 -->
and f.HIDDENPART = #{pd.keyHiddenPart}
</if>
<if test="pd.keyHiddenlevel = 'hiddenLevel2002'"><!-- 隐患级别 -->
and f.HIDDENLEVEL in ('jdyh001','hiddenLevel2002')
</if>
<if test="pd.CONFIRM_USER != null and pd.CONFIRM_USER != ''"><!-- 隐患确认人 -->
and f.CONFIRM_USER = #{pd.CONFIRM_USER}
</if>
<if test="pd.keyFindStateTime != null and pd.keyFindStateTime != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME >= #{pd.keyFindStateTime}
</if>
<if test="pd.keyFindEndTime != null and pd.keyFindEndTime != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME &lt;= #{pd.keyFindEndTime}
</if>
<if test="pd.keyConfirmUser != null and pd.keyConfirmUser != ''"><!-- 确认人 -->
and (confirmUser.NAME LIKE CONCAT(CONCAT('%', #{pd.keyConfirmUser}),'%'))
</if>
<if test="pd.keyMajor != null and pd.keyMajor != ''"><!-- 重大隐患 -->
and (lv.PARENT_ID = '5ff9daf78e9a4fb1b40d77980656799d' or lv.DICTIONARIES_ID='5ff9daf78e9a4fb1b40d77980656799d' )
</if>
<if test="pd.keyHiddenSpecialType != null and pd.keyHiddenSpecialType != ''">
and f.HIDDEN_ID in (select hex.HIDDEN_ID from bus_hiddenexamine hex
where hex.TYPE = #{pd.keyHiddenSpecialType} and hex.STATE ='1' )
</if>
<if test="pd.RECTIFICATIONOR != null and pd.RECTIFICATIONOR != ''"><!-- 整改人 -->
and f.RECTIFICATIONOR = #{pd.RECTIFICATIONOR}}
</if>
<!--<if test="pd.ArrayDATA_IDS != null and pd.ArrayDATA_IDS != ''">
or (list.DEPARTMENT_ID in (${pd.ArrayDATA_IDS})
)
</if>-->
order by f.CREATTIME desc,f.STATE + 0 asc
</select>
<!-- 重大隐患列表 -->
<select id="majormanagelistPage" parameterType="page" resultType="com.zcloud.entity.PageData">
select
f.*
,lv.NAME HIDDENLEVELNAME
,re.NAME as RECTIFICATIONORNAME
,confirmUser.NAME as confirmUserName
,hiddenType.NAME as hiddenTypeName
,hiddenType2.NAME as hiddenTypeName2
,hregion.HIDDENREGION as hregionName
,(select count(1) from BUS_HIDDENEXAMINE eax where eax.HIDDEN_ID = f.HIDDEN_ID and eax.STATE = '-1') as exaCount
from
<include refid="tableName"></include> f
LEFT JOIN sys_user confirmUser on confirmUser.USER_ID = f.CONFIRM_USER <!-- 隐患确认人 -->
left join <include refid="dicTableName"></include> lv on f.HIDDENLEVEL = lv.BIANMA
left join <include refid="dicTableName"></include> hiddenType on f.HIDDENTYPE = hiddenType.BIANMA <!-- 隐患类型-->
left join <include refid="dicTableName"></include> hiddenType2 on f.HIDDENTYPE2 = hiddenType2.BIANMA <!-- 隐患类型-->
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join bus_hiddenregion hregion on hregion.HIDDENREGION_ID = f.HIDDENPART
left join bus_hiddendangercheckstandard_custom list on list.CUSTOM_ID = f.CUSTOM_ID
<if test='pd.ArrayDATA_IDS !=null and pd.ArrayDATA_IDS !=""'>
left JOIN (select USER_ID from sys_USER where DEPARTMENT_ID in(${pd.ArrayDATA_IDS})) userfind on userfind.USER_ID = f.CREATOR
</if>
where f.ISDELETE = '0'
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
<if test='pd.majorhiddenstate == 13'>
and f.STATE <![CDATA[ >= ]]> 13
</if>
<if test="pd.rectification != null and pd.rectification != ''"><!-- 是否是整改-->
and f.state in ('13','14','15')
</if>
<if test="pd.STATE != null and pd.STATE != ''">
and f.STATE = #{pd.STATE}
</if>
<if test="pd.keySource != null and pd.keySource != ''"><!-- 隐患来源 -->
<if test='pd.keySource == "2"'>
and f.SOURCE in ('2','3')
</if>
<if test='pd.keySource != "2"'>
and f.SOURCE = #{pd.keySource}
</if>
</if>
<if test="pd.SOURCE != null and pd.SOURCE != '' "><!-- 隐患来源 -->
and f.SOURCE in ('2','3')
</if>
<if test="pd.keyHiddenDescr != null and pd.keyHiddenDescr != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.keyHiddenDescr}),'%'))
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%'))
</if>
<if test="pd.keyFindUserName != null and pd.keyFindUserName != ''"><!-- 隐患发现人 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.keyFindUserName}),'%') )
</if>
<if test="pd.keyFindUserDept != null and pd.keyFindUserDept != ''"><!-- 隐患发现部门 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.DEPARTMENT_ID = #{pd.keyFindUserDept} )
</if>
<if test="pd.keyHiddenType != null and pd.keyHiddenType != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE = #{pd.keyHiddenType}
</if>
<if test="pd.keyHiddenType2 != null and pd.keyHiddenType2 != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE2 = #{pd.keyHiddenType2}
</if>
<if test="pd.keyHiddenPart != null and pd.keyHiddenPart != ''"><!-- 隐患部位 -->
and f.HIDDENPART = #{pd.keyHiddenPart}
</if>
<if test='pd.keyHiddenlevel == "hiddenLevel2002"'><!-- 隐患级别 -->
and f.HIDDENLEVEL = 'hiddenLevel2002'
</if>
<if test='pd.keyHiddenlevel == "jdyh001"'><!-- 隐患级别 -->
and f.HIDDENLEVEL = 'jdyh001'
</if>
<if test="pd.CONFIRM_USER != null and pd.CONFIRM_USER != ''"><!-- 隐患确认人 -->
and f.CONFIRM_USER = #{pd.CONFIRM_USER}
</if>
<if test="pd.keyFindStateTime != null and pd.keyFindStateTime != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME <![CDATA[ >= ]]> CONCAT_WS(' ',#{pd.keyFindStateTime}, '00:00')
</if>
<if test="pd.keyFindEndTime != null and pd.keyFindEndTime != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME <![CDATA[ <= ]]> CONCAT_WS(' ',#{pd.keyFindEndTime}, '23:59')
</if>
<if test="pd.keyConfirmUser != null and pd.keyConfirmUser != ''"><!-- 确认人 -->
and (confirmUser.NAME LIKE CONCAT(CONCAT('%', #{pd.keyConfirmUser}),'%'))
</if>
<if test="pd.keyMajor != null and pd.keyMajor != ''"><!-- 重大隐患 -->
and (lv.PARENT_ID = '5ff9daf78e9a4fb1b40d77980656799d' or lv.DICTIONARIES_ID='5ff9daf78e9a4fb1b40d77980656799d' )
</if>
<if test="pd.keyHiddenSpecialType != null and pd.keyHiddenSpecialType != ''">
and f.HIDDEN_ID in (select hex.HIDDEN_ID from bus_hiddenexamine hex
where hex.TYPE = #{pd.keyHiddenSpecialType} and hex.STATE ='1' )
</if>
<!-- <if test="pd.RECTIFICATIONOR != null and pd.RECTIFICATIONOR != ''">&lt;!&ndash; 整改人 &ndash;&gt;-->
<!-- and f.RECTIFICATIONOR = #{pd.RECTIFICATIONOR}-->
<!-- </if>-->
order by f.CREATTIME desc,f.STATE + 0 asc
</select>
<!-- 通过ID获取数据 -->
<select id="findByEmisId" parameterType="pd" resultType="com.zcloud.entity.PageData">
select
*,
cr.NAME CREATORNAME,
re.NAME RECTIFICATIONORNAME,
ch.NAME CHECKORNAME,
crd.NAME HIDDENFINDDEPTNAME,
red.NAME RECTIFICATIONDEPTNAME,
chd.NAME CHECKDEPTNAME,
lv.NAME HIDDENLEVELNAME,
bc.LIST_NAME,
lv.NAME HIDDENLEVELNAME,
ht.NAME HIDDENTYPENAME,
hiddenType2.NAME HIDDENTYPENAME2,
conUser.NAME as conUserName,
hregion.HIDDENREGION as hregionName,
hregionDept.NAME as hregionDeptName,
hregion.HIDDENREGION as hregionName,
od.DEPARTMENT_ID as confirmDept,
-- fc.NAME FINAL_CHECKOR_NAME,
isa.INSPECTION_ASSESS_ID,
siu.NAME as acceptName,
isa.ASSESS_SCORE,
isa.ASSESS_PENALTY_AMOUNT
from
bus_hidden_emis f
left join sys_user cr on cr.USER_ID = f.CREATOR
left join sys_user re on re.USER_ID = f.RECTIFICATIONOR
left join sys_user ch on ch.USER_ID = f.CHECKOR
left join sys_user conUser on conUser.USER_ID = f.CONFIRM_USER
left join oa_department crd on crd.DEPARTMENT_ID = f.HIDDENFINDDEPT
left join oa_department red on red.DEPARTMENT_ID = f.RECTIFICATIONDEPT
left join oa_department chd on chd.DEPARTMENT_ID = f.CHECKDEPT
left join bus_checkrecord bc on bc.CHECKRECORD_ID = f.CHECKRECORD_ID and bc.ISDELETE = 0
left join <include refid="dicTableName"></include> lv on f.HIDDENLEVEL = lv.BIANMA
left join <include refid="dicTableName"></include> ht on f.HIDDENTYPE = ht.BIANMA
left join <include refid="dicTableName"></include> hiddenType2 on f.HIDDENTYPE2 = hiddenType2.BIANMA <!-- 隐患类型-->
left join bus_hiddenregion hregion on hregion.HIDDENREGION_ID = f.HIDDENPART
left join oa_department hregionDept on hregionDept.DEPARTMENT_ID = conUser.DEPARTMENT_ID
left join sys_user su on su.USER_ID = f.CONFIRM_USER
left join oa_department od on od.DEPARTMENT_ID = su.DEPARTMENT_ID
-- LEFT JOIN sys_user fc ON fc.USER_ID = f.FINAL_CHECKOR
LEFT JOIN sys_user siu ON siu.USER_ID = f.CHECKOR
LEFT JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL_ASSESS isa ON isa.HIDDEN_ID = f.HIDDEN_ID and isa.ISDELETE = '0'
where
f.HIDDEN_ID = #{HIDDEN_ID}
</select>
<!-- 列表 -->
<select id="getListForemisdatalistPage" parameterType="page" resultType="com.zcloud.entity.PageData">
SELECT
f.HIDDEN_ID,
f.SOURCE,
f.HIDDENDESCR,
f.RECTIFICATIONTYPE,
f.HIDDENLEVEL,
f.CONFIRM_USER,
f.CONFIRM_TIME,
f.HIDDENPART,
hcdic.HIDDENREGION as HREGIONNAME,
f.RECTIFICATIONTIME,
f.RECTIFICATIONOR,
lv.NAME HIDDENLEVELNAME,
f.DISCOVERYTIME,
f.STATE,
f.CREATOR,
ch.NAME CHECKORNAME,
(select group_concat(chr.NAME) from BUS_HIDDENCHECK bh left join sys_user chr on chr.USER_ID=bh.USER_ID where bh.HIDDEN_ID=f.HIDDEN_ID ) CHECKNAME
FROM
bus_hidden_emis f
LEFT JOIN bus_hiddenregion hcdic on hcdic.HIDDENREGION_ID = f.HIDDENPART
left join SYS_DICTIONARIES lv on f.HIDDENLEVEL = lv.BIANMA
left join sys_user ch on ch.USER_ID = f.CHECKOR
LEFT JOIN bus_hiddencheck hch on hch.HIDDEN_ID = f.HIDDEN_ID
left join bus_hidden_user bhu on bhu.HIDDEN_ID = f.HIDDEN_ID
left join sys_user bhuUser on bhuUser.user_id = bhu.user_id
LEFT JOIN sys_user confirmUser on confirmUser.USER_ID = f.CONFIRM_USER <!-- 隐患确认人 -->
WHERE
1 = 1
and f.ISDELETE = '0'
<if test="pd.roleLevel != null and pd.roleLevel != ''"><!-- 权限显示 -->
<choose>
<when test='pd.roleLevel == "0"'>
</when>
<when test='pd.roleLevel == "1"'>
and (confirmUser.DEPARTMENT_ID in (${pd.supDeparIds}) or bhuUser.DEPARTMENT_ID in (${pd.supDeparIds}) or f.RECTIFICATIONDEPT in (${pd.supDeparIds}) or hch.DEPARTMENT_ID in (${pd.supDeparIds}))
</when>
<when test='pd.roleLevel == "2"'>
and (f.CREATOR = #{pd.loginUserId} or f.RECTIFICATIONOR = #{pd.loginUserId} or f.CONFIRM_USER= #{pd.loginUserId} or bhu.USER_ID =#{pd.loginUserId})
</when>
</choose>
</if>
and (f.STATE not in ('0','7','8','100','101','102','5') )
and f.HIDDENLEVEL != 'hiddenLevel2002' and f.HIDDENLEVEL != 'hiddenLevel1001' and f.HIDDENLEVEL != 'jdyh001'
<if test='pd.queryUserId != null and pd.queryUserId != "" and pd.roleLevel !="1" and pd.roleLevel !="2" and pd.roleLevel !="0" '> <!-- 是否查询与自己有关的信息-->
and (
f.HIDDEN_ID in(select fh.HIDDEN_ID from bus_hidden_user fh where fh.USER_ID = #{pd.queryUserId}
or f.CONFIRM_USER = #{pd.queryUserId}
or f.RECTIFICATIONOR = #{pd.queryUserId}
or f.HIDDEN_ID in(select ch.HIDDEN_ID from bus_hiddencheck ch where ch.USER_ID = #{pd.queryUserId})
))
</if>
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 企业ID -->
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and (f.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%'))
</if>
<if test="pd.keySource != null and pd.keySource != '' "><!-- 隐患来源 -->
<if test='pd.keySource == "2"'>
and f.SOURCE in ('2','3')
</if>
<if test='pd.keySource != "2"'>
and f.SOURCE = #{pd.keySource}
</if>
</if>
<if test="pd.HIDDENFIND_NAME != null and pd.HIDDENFIND_NAME != ''"><!-- 隐患发现人 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.HIDDENFIND_NAME}),'%') )
</if>
<if test="pd.STARTTIME != null and pd.STARTTIME != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME <![CDATA[ >= ]]> CONCAT_WS(' ', #{pd.STARTTIME}, '00:00')
</if>
<if test="pd.ENDTIME != null and pd.ENDTIME != ''"><!-- 隐患发现时间 -->
and f.DISCOVERYTIME <![CDATA[ <= ]]> CONCAT_WS(' ', #{pd.ENDTIME}, '23:59')
</if>
<if test="pd.confirmUserName != null and pd.confirmUserName != ''"><!-- 隐患确认人 -->
and f.CONFIRM_USER in (
select cu.USER_ID from sys_user cu where
(
cu.USERNAME LIKE CONCAT(CONCAT('%',#{ pd.confirmUserName}),'%')
or
cu.NAME LIKE CONCAT(CONCAT('%', #{pd.confirmUserName}),'%')
or
cu.PHONE LIKE CONCAT(CONCAT('%', #{pd.confirmUserName}),'%')
)
and cu.CORPINFO_ID = #{pd.CORPINFO_ID}
)
</if>
<if test="pd.CHECKNAME != null and pd.CHECKNAME != ''"><!-- 验收人 -->
and f.HIDDEN_ID in (
SELECT
yhc.HIDDEN_ID
FROM
bus_hiddencheck yhc
LEFT JOIN sys_user yuser ON yuser.USER_ID = yhc.USER_ID AND yuser.CORPINFO_ID = #{pd.CORPINFO_ID}
where (
yuser.USERNAME LIKE CONCAT(CONCAT('%',#{ pd.CHECKNAME}),'%')
or
yuser.NAME LIKE CONCAT(CONCAT('%', #{pd.CHECKNAME}),'%')
or
yuser.PHONE LIKE CONCAT(CONCAT('%', #{pd.CHECKNAME}),'%')
)
)
</if>
<if test="pd.HIDDENLEVEL != null and pd.HIDDENLEVEL != ''">
and f.HIDDENLEVEL = #{pd.HIDDENLEVEL}
</if>
<if test="pd.HIDDENLEVEL != null and pd.HIDDENLEVEL != ''">
and f.HIDDENLEVEL = #{pd.HIDDENLEVEL}
</if>
<if test="pd.STATE != null and pd.STATE != ''">
and f.STATE = #{pd.STATE}
</if>
<if test="pd.keyHiddenPart != null and pd.keyHiddenPart != ''"><!-- 隐患部位 -->
and f.HIDDENPART = #{pd.keyHiddenPart}
</if>
<if test="pd.keyFindUserName != null and pd.keyFindUserName != ''"><!-- 隐患发现人 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.NAME LIKE CONCAT(CONCAT('%', #{pd.keyFindUserName}),'%') )
</if>
<if test="pd.keyFindUserDept != null and pd.keyFindUserDept != ''"><!-- 隐患发现部门 -->
and f.HIDDEN_ID in (select hfu.HIDDEN_ID from BUS_HIDDEN_USER hfu LEFT JOIN sys_user user on user.USER_ID = hfu.USER_ID where user.DEPARTMENT_ID = #{pd.keyFindUserDept} )
</if>
<if test="pd.keyHiddenType != null and pd.keyHiddenType != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE = #{pd.keyHiddenType}
</if>
<if test="pd.keyHiddenType2 != null and pd.keyHiddenType2 != ''"><!-- 隐患类型 -->
and f.HIDDENTYPE2 = #{pd.keyHiddenType2}
</if>
group by f.HIDDEN_ID
order by f.CREATTIME desc,f.STATE + 0 asc
</select>
<insert id="saveForEmis" parameterType="pd">
INSERT INTO bus_hidden_emis(
2024-02-01 16:46:11 +08:00
HIDDEN_ID,,CHECK_CATEGORY_NAM,CHECK_CATEGORY_NAME,CHECK_ITEM,CHECK_ITEM_NAME,LEVEL,CHECK_CONTENT,HIDDENDESCR,HIDDENPART,CREATOR,
2024-01-31 16:53:07 +08:00
CREATTIME,RECTIFYDESCR,RECTIFICATIONTYPE,RECTIFICATIONDEPT,RECTIFICATIONOR,RECTIFICATIONDEADLINE,
RECTIFICATIONTIME,HIDDENLEVEL,STATE,CHECKDEPT,CHECKOR,CHECKTIME,CHECKDESCR,ISQUALIFIED,ISDELETE,CORPINFO_ID,
2024-01-31 16:55:54 +08:00
HIDDENFINDDEPT,CHECKRECORD_ID,RECORDITEM_ID,CUSTOM_ITEM_ID,REJECTREASON,REVIEWOR,REVIEWTIME,REVIEWDEPT,HAVESCHEME,
2024-01-31 16:53:07 +08:00
LONGITUDE,LATITUDE,CUSTOM_ID,HIDDENTYPE,ISCONFIRM,CONFIRM_USER,CONFIRM_TIME,DISCOVERYTIME,INVESTMENT_FUNDS,
HIDDENTYPE2,POSITIONDESC,ISRELEVANT,EMIS_RES
) SELECT
2024-02-01 16:46:11 +08:00
HIDDEN_ID,SOURCE,CHECK_CATEGORY,CHECK_CATEGORY_NAME,CHECK_ITEM,CHECK_ITEM_NAME,LEVEL,CHECK_CONTENT,HIDDENDESCR,HIDDENPART,CREATOR,CREATTIME,RECTIFYDESCR,
2024-01-31 16:53:07 +08:00
RECTIFICATIONTYPE,RECTIFICATIONDEPT,RECTIFICATIONOR,RECTIFICATIONDEADLINE,RECTIFICATIONTIME,HIDDENLEVEL,STATE,CHECKDEPT,CHECKOR,CHECKTIME,
2024-01-31 16:55:54 +08:00
CHECKDESCR,ISQUALIFIED,ISDELETE,CORPINFO_ID,HIDDENFINDDEPT,CHECKRECORD_ID,RECORDITEM_ID,CUSTOM_ITEM_ID,REJECTREASON,REVIEWOR,REVIEWTIME,REVIEWDEPT,
2024-01-31 16:53:07 +08:00
HAVESCHEME,LONGITUDE,LATITUDE,CUSTOM_ID,HIDDENTYPE,ISCONFIRM,CONFIRM_USER,CONFIRM_TIME,DISCOVERYTIME,INVESTMENT_FUNDS,HIDDENTYPE2,
POSITIONDESC,ISRELEVANT,#{resXML}
FROM bus_hidden where
HIDDEN_ID = #{HIDDEN_ID}
</insert>
</mapper>