qa-prevention-gwj/src/main/resources/mybatis/datasource/inspection/SafetyEnvironmentalMapper.xml

882 lines
37 KiB
XML
Raw Normal View History

2024-02-06 11:02:25 +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.inspection.SafetyEnvironmentalMapper">
<!--表名 -->
<sql id="tableName">
BUS_INSPECTION_SAFETYENVIRONMENTAL
</sql>
<!--数据字典表名 -->
<sql id="dicTableName">
SYS_DICTIONARIES
</sql>
<!-- 字段 -->
<sql id="Field">
f.INSPECTION_LEADDEPARTMENT_ID,
f.INSPECTION_SUBJECT,
f.INSPECTION_SOURCE,
f.INSPECTION_ORIGINATOR_ID,
f.INSPECTED_DEPARTMENT_ID,
f.INSPECTED_SITEUSER_ID,
f.INSPECTED_EXPLAIN,
f.INSPECTED_EXPLAIN_FILENAME,
f.INSPECTED_EXPLAIN_FILEPATH,
f.INSPECTED_SITEUSER_SIGN_IMG,
f.INSPECTED_SITEUSER_SIGN_TIME,
f.INSPECTED_EXPLAIN_REFUSE,
f.INSPECTION_ORIGINATOR_SIGN_IMG,
f.INSPECTION_ORIGINATOR_SIGN_TIME,
f.INSPECTION_TYPE,
f.INSPECTION_TYPE_OTHER,
f.INSPECTION_PLACE,
f.INSPECTION_TIME_START,
f.INSPECTION_TIME_END,
f.INSPECTION_STATUS,
f.ISDELETE,
f.CREATOR,
f.CREATTIME,
f.OPERATOR,
f.OPERATTIME,
f.CORPINFO_ID,
f.INSPECTION_ID
</sql>
<!-- 字段用于新增 -->
<sql id="Field2">
INSPECTION_LEADDEPARTMENT_ID,
INSPECTION_SUBJECT,
INSPECTION_SOURCE,
INSPECTION_ORIGINATOR_ID,
INSPECTED_DEPARTMENT_ID,
INSPECTED_SITEUSER_ID,
INSPECTED_EXPLAIN,
INSPECTED_EXPLAIN_FILENAME,
INSPECTED_EXPLAIN_FILEPATH,
INSPECTED_SITEUSER_SIGN_IMG,
INSPECTED_SITEUSER_SIGN_TIME,
INSPECTED_EXPLAIN_REFUSE,
INSPECTION_ORIGINATOR_SIGN_IMG,
INSPECTION_ORIGINATOR_SIGN_TIME,
INSPECTION_TYPE,
INSPECTION_TYPE_OTHER,
INSPECTION_PLACE,
INSPECTION_TIME_START,
INSPECTION_TIME_END,
INSPECTION_STATUS,
ISDELETE,
CREATOR,
CREATTIME,
OPERATOR,
OPERATTIME,
CORPINFO_ID,
INSPECTION_ID
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{INSPECTION_LEADDEPARTMENT_ID},
#{INSPECTION_SUBJECT},
#{INSPECTION_SOURCE},
#{INSPECTION_ORIGINATOR_ID},
#{INSPECTED_DEPARTMENT_ID},
#{INSPECTED_SITEUSER_ID},
#{INSPECTED_EXPLAIN},
#{INSPECTED_EXPLAIN_FILENAME},
#{INSPECTED_EXPLAIN_FILEPATH},
#{INSPECTED_SITEUSER_SIGN_IMG},
#{INSPECTED_SITEUSER_SIGN_TIME},
#{INSPECTED_EXPLAIN_REFUSE},
#{INSPECTION_ORIGINATOR_SIGN_IMG},
#{INSPECTION_ORIGINATOR_SIGN_TIME},
#{INSPECTION_TYPE},
#{INSPECTION_TYPE_OTHER},
#{INSPECTION_PLACE},
#{INSPECTION_TIME_START},
#{INSPECTION_TIME_END},
#{INSPECTION_STATUS},
#{ISDELETE},
#{CREATOR},
#{CREATTIME},
#{OPERATOR},
#{OPERATTIME},
#{CORPINFO_ID},
#{INSPECTION_ID}
</sql>
<!-- 新增-->
<insert id="save" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field2"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
<!-- 删除-->
<delete id="delete" parameterType="pd">
update
<include refid="tableName"></include>
set
ISDELETE = '1',
OPERATOR = #{OPERATOR},
OPERATTIME = #{OPERATTIME}
where
INSPECTION_ID = #{INSPECTION_ID}
</delete>
<select id="getHiddenCountByDepat" parameterType="pd" resultType="pd">
SELECT
HIDDENLEVEL, count(*) as count
FROM
bus_hidden f
LEFT JOIN sys_user u ON f.CONFIRM_USER = u.user_id
WHERE
1 = 1
and f.STATE = '4'
AND f.CHECKTIME &gt;=#{startTime}
AND f.CHECKTIME &lt; #{endTime}
AND FIND_IN_SET (
u.DEPARTMENT_ID,
queryRecursiveDeptDown ( #{DEPARTMENT_ID} ))
GROUP BY HIDDENLEVEL
</select>
<select id="getHiddenCountByUser" parameterType="pd" resultType="pd">
SELECT
f.HIDDENLEVEL,f.CONFIRM_USER ,count(*) as count
FROM
bus_hidden f
WHERE
1 = 1
and f.STATE = '4'
<if test="corpinfoId != null and corpinfoId != ''">
and f.CORPINFO_ID = #{corpinfoId}
</if>
AND f.CHECKTIME &gt;=#{startTime}
AND f.CHECKTIME &lt; #{endTime}
GROUP BY f.CONFIRM_USER,f.HIDDENLEVEL
</select>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
INSPECTION_LEADDEPARTMENT_ID = #{INSPECTION_LEADDEPARTMENT_ID},
INSPECTION_SUBJECT = #{INSPECTION_SUBJECT},
INSPECTION_ORIGINATOR_ID = #{INSPECTION_ORIGINATOR_ID},
INSPECTED_DEPARTMENT_ID = #{INSPECTED_DEPARTMENT_ID},
INSPECTED_SITEUSER_ID = #{INSPECTED_SITEUSER_ID},
INSPECTED_EXPLAIN = #{INSPECTED_EXPLAIN},
INSPECTED_EXPLAIN_FILENAME = #{INSPECTED_EXPLAIN_FILENAME},
INSPECTED_EXPLAIN_FILEPATH = #{INSPECTED_EXPLAIN_FILEPATH},
INSPECTED_SITEUSER_SIGN_IMG = #{INSPECTED_SITEUSER_SIGN_IMG},
INSPECTED_SITEUSER_SIGN_TIME = #{INSPECTED_SITEUSER_SIGN_TIME},
INSPECTED_EXPLAIN_REFUSE = #{INSPECTED_EXPLAIN_REFUSE},
INSPECTION_ORIGINATOR_SIGN_IMG = #{INSPECTION_ORIGINATOR_SIGN_IMG},
INSPECTION_ORIGINATOR_SIGN_TIME = #{INSPECTION_ORIGINATOR_SIGN_TIME},
INSPECTION_TYPE = #{INSPECTION_TYPE},
INSPECTION_TYPE_OTHER = #{INSPECTION_TYPE_OTHER},
INSPECTION_PLACE = #{INSPECTION_PLACE},
INSPECTION_TIME_START = #{INSPECTION_TIME_START},
INSPECTION_TIME_END = #{INSPECTION_TIME_END},
INSPECTION_STATUS = #{INSPECTION_STATUS},
OPERATOR = #{OPERATOR},
OPERATTIME = #{OPERATTIME},
INSPECTION_ID = INSPECTION_ID
where
INSPECTION_ID = #{INSPECTION_ID}
</update>
<!-- 修改 //执行考评方法时将检查状态改成已归档因为bug6535提出要是隐患考评完毕状态应该是8已归档-->
<update id="edieditsttust" parameterType="pd">
update
<include refid="tableName"></include>
set
INSPECTION_STATUS = '8'
where
INSPECTION_ID = #{INSPECTION_ID}
</update>
<!-- 通过ID获取数据 -->
<select id="findById" parameterType="pd" resultType="pd">
select
es.ASSESS_SCORE,
a.NAME INSPECTION_ORIGINATOR_NAME,
ild.NAME INSPECTION_LEADDEPARTMENT_NAME,
IFNULL(GROUP_CONCAT(REPLACE(siu.NAME,'/',',')),'') AS INSPECTION_USER_NAME,
b.NAME INSPECTED_DEPARTMENT_NAME,
c.NAME INSPECTED_SITEUSER_NAME,
CASE WHEN IFNULL(f.INSPECTION_TYPE_OTHER, '') = '' THEN d.NAME ELSE f.INSPECTION_TYPE_OTHER END INSPECTION_TYPE_NAME,
<include refid="Field"></include>
from
<include refid="tableName"></include> f
LEFT JOIN VI_USER_ALL a ON a.USER_ID = f.INSPECTION_ORIGINATOR_ID
LEFT JOIN VI_DEPARTMENT_ALL ild ON ild.DEPARTMENT_ID = f.INSPECTION_LEADDEPARTMENT_ID
LEFT JOIN OA_DEPARTMENT b ON b.DEPARTMENT_ID = f.INSPECTED_DEPARTMENT_ID
LEFT JOIN SYS_USER c ON c.USER_ID = f.INSPECTED_SITEUSER_ID
LEFT JOIN bus_inspection_safetyenvironmental_inspector si ON si.INSPECTION_ID = f.INSPECTION_ID and si.ISDELETE = '0'
LEFT JOIN VI_USER_ALL siu ON siu.USER_ID = si.INSPECTION_USER_ID
LEFT JOIN bus_inspection_safetyenvironmental_assess es ON es.INSPECTION_ID = f.INSPECTION_ID
<!-- LEFT JOIN SYS_DICTIONARIES d on d.BIANMA = f.INSPECTION_TYPE and FIND_IN_SET(d.DICTIONARIES_ID,queryRecursiveDictDown('60e6481d96e44a5390ff5c347c4d1ffe')) -->
LEFT JOIN sys_dictionaries d ON d.BIANMA = f.INSPECTION_TYPE
where
f.INSPECTION_ID = #{INSPECTION_ID}
</select>
<!-- 列表 -->
<select id="datalistPage" parameterType="page" resultType="pd">
select
h.HIDDENDESCR,
biss.SITUATION,
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,
COUNT(DISTINCT biss.INSPECTION_SITUATION_ID) SITUATION_COUNT,
COUNT(DISTINCT h.HIDDEN_ID) HIDDEN_COUNT,
IFNULL(GROUP_CONCAT(REPLACE(siu.USER_ID,'/',',')),'') AS INSPECTION_USER_ID,
IFNULL(GROUP_CONCAT( DISTINCT siu.NAME),'') AS INSPECTION_USER_NAME,
CASE WHEN IFNULL(f.INSPECTION_TYPE_OTHER, '') = '' THEN d.NAME ELSE f.INSPECTION_TYPE_OTHER END INSPECTION_TYPE_NAME,
<include refid="Field"></include>
from
<include refid="tableName"></include> f
LEFT JOIN bus_hidden h on h.FOREIGN_ID = f.INSPECTION_ID and h.isdelete ='0'
LEFT JOIN vi_user_all iou ON iou.USER_ID = f.INSPECTION_ORIGINATOR_ID
LEFT JOIN OA_DEPARTMENT ild ON ild.DEPARTMENT_ID = f.INSPECTION_LEADDEPARTMENT_ID
LEFT JOIN vi_department_all iod ON iod.DEPARTMENT_ID = iou.DEPARTMENT_ID
LEFT JOIN OA_DEPARTMENT isd ON isd.DEPARTMENT_ID = f.INSPECTED_DEPARTMENT_ID
LEFT JOIN SYS_USER isu ON isu.USER_ID = f.INSPECTED_SITEUSER_ID
LEFT JOIN bus_inspection_safetyenvironmental_inspector si ON si.INSPECTION_ID = f.INSPECTION_ID and si.ISDELETE = '0'
LEFT JOIN vi_user_all siu ON siu.USER_ID = si.INSPECTION_USER_ID
LEFT JOIN sys_dictionaries d ON d.BIANMA = f.INSPECTION_TYPE
LEFT JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL_SITUATION biss on biss.INSPECTION_ID = f.INSPECTION_ID
where f.ISDELETE = '0'
<!-- <if test="pd.supDeparIds != null and pd.supDeparIds != '' and pd.supDeparIds !='ALL' and pd.supDeparIds !='NOT'">-->
<!-- and (f.INSPECTED_DEPARTMENT_ID in (${pd.supDeparIds}) )-->
<!-- </if>-->
<if test="pd.roleLevel != null and pd.roleLevel != ''"><!-- 权限显示 -->
<choose>
<when test='pd.roleLevel == "0"'>
</when>
<when test='pd.roleLevel == "1"'>
and (
<!--被检查单位-->
f.INSPECTED_DEPARTMENT_ID in (${pd.supDeparIds})
<!--被检查单位-->
or ild.DEPARTMENT_ID in (${pd.supDeparIds})
<!--检查发起人单位 新加-->
or iod.DEPARTMENT_ID in (${pd.supDeparIds}))
</when>
<when test='pd.roleLevel == "2"'>
<!--检查发起人INSPECTION_ORIGINATOR_ID--> <!--检查人siu.USER_ID 整改人RECTIFICATIONOR-->
and (f.INSPECTION_ORIGINATOR_ID = #{pd.loginUserId} or (siu.USER_ID in (#{pd.loginUserId}) or h.RECTIFICATIONOR in (#{pd.loginUserId})))
</when>
</choose>
</if>
<!-- <if test="pd.INSPECTION_ORIGINATOR_ID != null and pd.INSPECTION_ORIGINATOR_ID != ''">&lt;!&ndash; 检查发起人 &ndash;&gt;-->
<!-- and f.INSPECTION_ORIGINATOR_ID = #{pd.INSPECTION_ORIGINATOR_ID}-->
<!-- </if>-->
<if test="pd.ARCHIVE_USER_ID != null and pd.ARCHIVE_USER_ID != ''">
and (
f.INSPECTION_ORIGINATOR_ID = #{pd.ARCHIVE_USER_ID}
OR si.INSPECTION_USER_ID = #{pd.ARCHIVE_USER_ID}
OR f.INSPECTED_SITEUSER_ID = #{pd.ARCHIVE_USER_ID}
)
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and h.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%')
</if>
<if test="pd.SITUATION != null and pd.SITUATION != ''"><!-- 检查情况 -->
and biss.SITUATION LIKE CONCAT(CONCAT('%', #{pd.SITUATION}),'%')
</if>
<if test="pd.INSPECTED_DEPARTMENT_ID != null and pd.INSPECTED_DEPARTMENT_ID != ''"><!-- 被检查单位 -->
and isd.DEPARTMENT_ID = #{pd.INSPECTED_DEPARTMENT_ID}
</if>
<if test="pd.INSPECTION_DEPARTMENT_ID != null and pd.INSPECTION_DEPARTMENT_ID != ''"><!-- 检查部门 -->
and iod.DEPARTMENT_ID = #{pd.INSPECTION_DEPARTMENT_ID}
</if>
<if test="pd.INSPECTION_TYPE != null and pd.INSPECTION_TYPE != ''"><!-- 检查类型 -->
and f.INSPECTION_TYPE = #{pd.INSPECTION_TYPE}
</if>
<if test="pd.INSPECTION_SUBJECT != null and pd.INSPECTION_SUBJECT != ''"><!-- 检查题目 -->
and f.INSPECTION_SUBJECT = #{pd.INSPECTION_SUBJECT,jdbcType=VARCHAR}
</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.INSPECTION_TYPE != null and pd.INSPECTION_TYPE != ''"><!-- 检查类型 -->
and f.INSPECTION_TYPE = #{pd.INSPECTION_TYPE}
</if>
<if test="pd.INSPECTION_TIME_START != null and pd.INSPECTION_TIME_START != ''"><!-- 检查时间 -->
and f.INSPECTION_TIME_START &gt;= CONCAT(#{pd.INSPECTION_TIME_START}, ' 00:00')
</if>
<if test="pd.INSPECTION_TIME_END != null and pd.INSPECTION_TIME_END != ''"><!-- 检查时间 -->
and f.INSPECTION_TIME_END &lt;= CONCAT(#{pd.INSPECTION_TIME_END}, ' 23:59')
</if>
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''">
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test="pd.CORPINFO_ID_MAIN != null and pd.CORPINFO_ID_MAIN != ''">
and f.CORPINFO_ID = #{pd.CORPINFO_ID} and f.INSPECTION_SOURCE = '5'
</if>
<if test="pd.INSPECTION_STATUS != null and pd.INSPECTION_STATUS != ''"><!-- 检查状态 -->
<choose>
<when test="pd.INSPECTION_STATUS == '3-7'">
and f.INSPECTION_STATUS in ('3','4','5','6','7','8')
</when>
<otherwise>
and f.INSPECTION_STATUS = #{pd.INSPECTION_STATUS}
</otherwise>
</choose>
</if>
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 被检查单位 -->
and (
isd.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
OR iod.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
)
</if>
GROUP BY f.INSPECTION_ID
ORDER BY
<if test="pd.checkType != null and pd.checkType = '0'">
field(f.INSPECTION_STATUS,'-1') DESC, field(f.INSPECTION_ORIGINATOR_ID,#{pd.loginUserId}) DESC,
</if>
f.CREATTIME DESC
2024-02-06 11:02:25 +08:00
</select>
<!-- 通过ID获取数据 -->
<select id="findByyin" parameterType="pd" resultType="pd">
select
a.NAME INSPECTION_ORIGINATOR_NAME,
ild.NAME INSPECTION_LEADDEPARTMENT_NAME,
IFNULL(GROUP_CONCAT(REPLACE(siu.NAME,'/',',')),'') AS INSPECTION_USER_NAME,
b.NAME INSPECTED_DEPARTMENT_NAME,
c.NAME INSPECTED_SITEUSER_NAME,
u.NAME YINNAME,
CASE WHEN IFNULL(f.INSPECTION_TYPE_OTHER, '') = '' THEN d.NAME ELSE f.INSPECTION_TYPE_OTHER END INSPECTION_TYPE_NAME,
<include refid="Field"></include>
from
<include refid="tableName"></include> f
LEFT JOIN vi_user_all u ON u.USER_ID = f.INSPECTED_SITEUSER_ID
LEFT JOIN VI_USER_ALL a ON a.USER_ID = f.INSPECTION_ORIGINATOR_ID
LEFT JOIN VI_DEPARTMENT_ALL ild ON ild.DEPARTMENT_ID = f.INSPECTION_LEADDEPARTMENT_ID
LEFT JOIN OA_DEPARTMENT b ON b.DEPARTMENT_ID = f.INSPECTED_DEPARTMENT_ID
LEFT JOIN SYS_USER c ON c.USER_ID = f.INSPECTED_SITEUSER_ID
LEFT JOIN bus_inspection_safetyenvironmental_inspector si ON si.INSPECTION_ID = f.INSPECTION_ID and si.ISDELETE = '0'
LEFT JOIN VI_USER_ALL siu ON siu.USER_ID = si.INSPECTION_USER_ID
-- LEFT JOIN SYS_DICTIONARIES d on d.BIANMA = f.INSPECTION_TYPE and FIND_IN_SET(d.DICTIONARIES_ID,queryRecursiveDictDown('60e6481d96e44a5390ff5c347c4d1ffe'))
LEFT JOIN sys_dictionaries d ON d.BIANMA = f.INSPECTION_TYPE
where
f.INSPECTION_ID = #{INSPECTION_ID}
</select>
<!-- 列表(全部) -->
<select id="listAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where f.ISDELETE = '0' and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</select>
<!-- 批量删除 -->
<delete id="deleteAll" parameterType="pd">
update
<include refid="tableName"></include>
set
ISDELETE = '1',
OPERATOR = #{OPERATOR},
OPERATTIME = #{OPERATTIME}
where
INSPECTION_ID in
<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- 列表(根据所选ID获取数据) -->
<select id="findByIds" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where
INSPECTION_ID in
<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<!-- 更新检查进度状态 -->
<update id="editStatus" parameterType="pd">
update
<include refid="tableName"></include>
set
INSPECTION_STATUS = #{INSPECTION_STATUS},
OPERATOR = #{OPERATOR},
OPERATTIME = #{OPERATTIME},
INSPECTION_ID = INSPECTION_ID
where
INSPECTION_ID = #{INSPECTION_ID}
</update>
<!-- 分公司安全环保检查考核分数统计 -->
<select id="statisticsBranch" parameterType="pd" resultType="pd">
SELECT
COUNT(DISTINCT h.HIDDEN_ID) HIDDEN_FIND,
IFNULL(CASE WHEN isa.INSPECTION_ASSESS_ID IS NOT NULL THEN COUNT(DISTINCT isa.INSPECTION_ASSESS_ID) END,0) HIDDEN_ASSESS,
IFNULL(CASE WHEN isa.INSPECTION_ASSESS_ID IS NOT NULL THEN SUM(isa.ASSESS_SCORE) END,0) ASSESS_SCORE
FROM BUS_INSPECTION_SAFETYENVIRONMENTAL se
LEFT JOIN BUS_HIDDEN h ON h.FOREIGN_ID = se.INSPECTION_ID AND h.ISDELETE = '0' AND h.SOURCE IN ('5') AND h.STATE != '100'
LEFT JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL_ASSESS isa on isa.HIDDEN_ID = h.HIDDEN_ID and isa.ISDELETE = '0'
WHERE FIND_IN_SET(se.INSPECTED_DEPARTMENT_ID,queryRecursiveDeptDown(#{DEPARTMENT_ID})) AND se.ISDELETE = '0' AND se.INSPECTION_SOURCE = '5'
<if test="YEAR != null and YEAR != ''"><!-- 检查年份 -->
<choose>
<when test="QUARTER != null and QUARTER != ''">
<choose>
<when test="QUARTER == 1">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-01-01 00:00')
AND se.INSPECTION_TIME_START &lt; CONCAT(#{YEAR}, '-04-01 00:00')
</when>
<when test="QUARTER == 2">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-04-01 00:00')
AND se.INSPECTION_TIME_START &lt; CONCAT(#{YEAR}, '-07-01 00:00')
</when>
<when test="QUARTER == 3">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-07-01 00:00')
AND se.INSPECTION_TIME_START &lt; CONCAT(#{YEAR}, '-10-01 00:00')
</when>
<when test="QUARTER == 4">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-10-01 00:00')
AND se.INSPECTION_TIME_START &lt;= CONCAT(#{YEAR}, '-12-31 23:59')
</when>
</choose>
</when>
<otherwise>
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-01-01 00:00')
AND se.INSPECTION_TIME_START &lt;= CONCAT(#{YEAR}, '-12-31 23:59')
</otherwise>
</choose>
</if>
</select>
<!-- 列表(股份公司安全环保检查考核分数统计) -->
<select id="statisticsJointStock" parameterType="pd" resultType="pd">
SELECT
f.CORPINFO_ID,
f.CORP_NAME INSPECTED_CORP_NAME,
COUNT(h.HIDDEN_ID) HIDDEN_FIND,
CASE WHEN isa.INSPECTION_ASSESS_ID IS NOT NULL THEN COUNT(isa.INSPECTION_ASSESS_ID) END HIDDEN_ASSESS,
CASE WHEN isa.INSPECTION_ASSESS_ID IS NOT NULL THEN SUM(isa.ASSESS_SCORE) END ASSESS_SCORE
FROM BUS_CORP_INFO f
LEFT JOIN OA_DEPARTMENT isd ON isd.CORPINFO_ID = f.CORPINFO_ID
LEFT JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL se ON se.INSPECTED_DEPARTMENT_ID = isd.DEPARTMENT_ID AND se.ISDELETE = '0'
LEFT JOIN BUS_HIDDEN h ON h.FOREIGN_ID = se.INSPECTION_ID AND h.ISDELETE = '0' AND h.SOURCE IN ('4','5') AND h.STATE != '100'
LEFT JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL_ASSESS isa on isa.HIDDEN_ID = h.HIDDEN_ID and isa.ISDELETE = '0'
WHERE f.ISDELETE = '0' AND se.INSPECTION_SOURCE = '4'
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 检查发起人 -->
AND f.CORPINFO_ID = #{CORPINFO_ID}
</if>
<if test="YEAR != null and YEAR != ''"><!-- 检查年份 -->
<choose>
<when test="QUARTER != null and QUARTER != ''">
<choose>
<when test="QUARTER == 1">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-01-01 00:00')
AND se.INSPECTION_TIME_START &lt; CONCAT(#{YEAR}, '-04-01 00:00')
</when>
<when test="QUARTER == 2">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-04-01 00:00')
AND se.INSPECTION_TIME_START &lt; CONCAT(#{YEAR}, '-07-01 00:00')
</when>
<when test="QUARTER == 3">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-07-01 00:00')
AND se.INSPECTION_TIME_START &lt; CONCAT(#{YEAR}, '-10-01 00:00')
</when>
<when test="QUARTER == 4">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-10-01 00:00')
AND se.INSPECTION_TIME_START &lt;= CONCAT(#{YEAR}, '-12-31 23:59')
</when>
</choose>
</when>
<otherwise>
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-01-01 00:00')
AND se.INSPECTION_TIME_START &lt;= CONCAT(#{YEAR}, '-12-31 23:59')
</otherwise>
</choose>
</if>
GROUP BY f.CORPINFO_ID
ORDER BY f.CORP_NAME ASC
</select>
<!-- 申辩数 -->
<select id="checkedCount" parameterType="pd" resultType="pd">
select
COUNT(*) checkedCount
from
<include refid="tableName"></include> f
where f.ISDELETE = '0' and f.INSPECTION_STATUS = '2' and f.INSPECTED_SITEUSER_ID = #{INSPECTED_SITEUSER_ID}
</select>
<!-- 打回数 -->
<select id="repulseCount" parameterType="pd" resultType="pd">
select
COUNT(*) repulseCount
from
<include refid="tableName"></include> f
where f.ISDELETE = '0' and (f.INSPECTION_STATUS = '-1' or f.INSPECTION_STATUS = '-2') and f.INSPECTION_ORIGINATOR_ID = #{INSPECTION_ORIGINATOR_ID}
</select>
<!-- 指派数+验收数3、4、6 -->
<select id="repulseAndCheckCountCount" parameterType="pd" resultType="pd">
SELECT
count( DISTINCT a.INSPECTION_ID ) repulseAndCheckCount
FROM
bus_inspection_safetyenvironmental a
LEFT JOIN bus_hidden b ON b.FOREIGN_ID = a.INSPECTION_ID
LEFT JOIN bus_inspection_safetyenvironmental_inspector i ON i.INSPECTION_ID = a.INSPECTION_ID and i.ISDELETE = '0'
WHERE a.ISDELETE = '0' and b.ISDELETE = '0' and i.ISDELETE = '0'
<!--由于10390 之前有被删除的隐患,现在安全环保检查的隐患不允许删除 -->
<!-- 被检查单位负责人指派隐患 -->
AND ( a.INSPECTED_SITEUSER_ID = #{INSPECTED_SITEUSER_ID} AND a.INSPECTION_STATUS IN ( '3', '4' ) )
<!-- 隐患验收人验收安全环保检查 -->
OR (
a.INSPECTION_STATUS IN ('5','6') <!--由于10390 不需要5.指派完成,7检查已验收 -->
AND b.STATE IN ( '4', '8' )
AND b.SOURCE IN ( '4', '5' ) <!-- 由于5872来源来自监管端需要验收按钮改完后发现提示的条数对不上所以做出修改 -->
and (b.FINAL_CHECK is null or b.FINAL_CHECK = '2')
AND b.CREATOR = #{INSPECTED_SITEUSER_ID}
AND i.INSPECTION_USER_ID = #{INSPECTED_SITEUSER_ID}
)
</select>
<!-- 列表 -->
<select id="pleadlistPage" parameterType="page" resultType="pd">
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,
IFNULL(GROUP_CONCAT(REPLACE(siu.USER_ID,'/',',')),'') AS INSPECTION_USER_ID,
IFNULL(GROUP_CONCAT(REPLACE(siu.NAME,'/',',')),'') AS INSPECTION_USER_NAME,
CASE WHEN IFNULL(f.INSPECTION_TYPE_OTHER, '') = '' THEN d.NAME ELSE f.INSPECTION_TYPE_OTHER END INSPECTION_TYPE_NAME,
<include refid="Field"></include>
from
<include refid="tableName"></include> f
LEFT JOIN vi_user_all iou ON iou.USER_ID = f.INSPECTION_ORIGINATOR_ID
LEFT JOIN OA_DEPARTMENT ild ON ild.DEPARTMENT_ID = f.INSPECTION_LEADDEPARTMENT_ID
LEFT JOIN vi_department_all iod ON iod.DEPARTMENT_ID = iou.DEPARTMENT_ID
LEFT JOIN OA_DEPARTMENT isd ON isd.DEPARTMENT_ID = f.INSPECTED_DEPARTMENT_ID
LEFT JOIN SYS_USER isu ON isu.USER_ID = f.INSPECTED_SITEUSER_ID
LEFT JOIN bus_inspection_safetyenvironmental_inspector si ON si.INSPECTION_ID = f.INSPECTION_ID and si.ISDELETE = '0'
LEFT JOIN vi_user_all siu ON siu.USER_ID = si.INSPECTION_USER_ID
LEFT JOIN sys_dictionaries d ON d.BIANMA = f.INSPECTION_TYPE
where f.ISDELETE = '0'
and exists(select 1 from bus_inspection_safetyenvironmental_explain x where x.INSPECTION_ID = f.INSPECTION_ID and x.INSPECTED_EXPLAIN is not null and x.INSPECTED_EXPLAIN != '')
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 检查发起人 -->
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test="pd.INSPECTION_ORIGINATOR_ID != null and pd.INSPECTION_ORIGINATOR_ID != ''"><!-- 检查发起人 -->
and f.INSPECTION_ORIGINATOR_ID = #{pd.INSPECTION_ORIGINATOR_ID}
</if>
<if test="pd.ARCHIVE_USER_ID != null and pd.ARCHIVE_USER_ID != ''">
and (
f.INSPECTION_ORIGINATOR_ID = #{pd.ARCHIVE_USER_ID}
OR f.INSPECTED_SITEUSER_ID = #{pd.ARCHIVE_USER_ID}
OR EXISTS(select 1 from bus_inspection_safetyenvironmental_inspector sii where sii.INSPECTION_USER_ID = #{pd.ARCHIVE_USER_ID}
and sii.INSPECTION_ID = f.INSPECTION_ID)
)
</if>
<if test="pd.roleLevel != null and pd.roleLevel != ''"><!-- 权限显示 -->
<choose>
<when test='pd.roleLevel == "0"'>
</when>
<when test='pd.roleLevel == "1"'>
and (f.INSPECTED_DEPARTMENT_ID in (${pd.supDeparIds}) )
</when>
<when test='pd.roleLevel == "2"'>
and f.INSPECTION_ORIGINATOR_ID = #{pd.loginUserId}
</when>
</choose>
</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.INSPECTION_TYPE != null and pd.INSPECTION_TYPE != ''"><!-- 检查类型 -->
and f.INSPECTION_TYPE = #{pd.INSPECTION_TYPE}
</if>
<if test="pd.INSPECTION_TIME_START != null and pd.INSPECTION_TIME_START != ''"><!-- 检查时间 -->
and f.INSPECTION_TIME_START &gt;= CONCAT(#{pd.INSPECTION_TIME_START}, ' 00:00')
</if>
<if test="pd.INSPECTION_TIME_END != null and pd.INSPECTION_TIME_END != ''"><!-- 检查时间 -->
and f.INSPECTION_TIME_END &lt;= CONCAT(#{pd.INSPECTION_TIME_END}, ' 23:59')
</if>
<if test="pd.INSPECTION_STATUS != null and pd.INSPECTION_STATUS != ''"><!-- 检查状态 -->
<choose>
<when test="pd.INSPECTION_STATUS == '3-7'">
and f.INSPECTION_STATUS in ('3','4','5','6','7','8')
</when>
<otherwise>
and f.INSPECTION_STATUS = #{pd.INSPECTION_STATUS}
</otherwise>
</choose>
</if>
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 被检查单位 -->
and (
isd.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
OR iod.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
)
</if>
GROUP BY f.INSPECTION_ID
ORDER BY f.CREATTIME DESC
</select>
<!-- 列表 -->
<select id="checklistPage" parameterType="page" resultType="pd">
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,
IFNULL(GROUP_CONCAT(REPLACE(siu.USER_ID,'/',',')),'') AS INSPECTION_USER_ID,
IFNULL(GROUP_CONCAT(REPLACE(siu.NAME,'/',',')),'') AS INSPECTION_USER_NAME,
CASE WHEN IFNULL(f.INSPECTION_TYPE_OTHER, '') = '' THEN d.NAME ELSE f.INSPECTION_TYPE_OTHER END INSPECTION_TYPE_NAME,
<include refid="Field"></include>
from
<include refid="tableName"></include> f
LEFT JOIN vi_user_all iou ON iou.USER_ID = f.INSPECTION_ORIGINATOR_ID
LEFT JOIN OA_DEPARTMENT ild ON ild.DEPARTMENT_ID = f.INSPECTION_LEADDEPARTMENT_ID
LEFT JOIN vi_department_all iod ON iod.DEPARTMENT_ID = iou.DEPARTMENT_ID
LEFT JOIN OA_DEPARTMENT isd ON isd.DEPARTMENT_ID = f.INSPECTED_DEPARTMENT_ID
LEFT JOIN SYS_USER isu ON isu.USER_ID = f.INSPECTED_SITEUSER_ID
LEFT JOIN bus_inspection_safetyenvironmental_inspector si ON si.INSPECTION_ID = f.INSPECTION_ID and si.ISDELETE = '0'
LEFT JOIN vi_user_all siu ON siu.USER_ID = si.INSPECTION_USER_ID
LEFT JOIN sys_dictionaries d ON d.BIANMA = f.INSPECTION_TYPE
where f.ISDELETE = '0'
<if test="pd.INSPECTION_ORIGINATOR_ID != null and pd.INSPECTION_ORIGINATOR_ID != ''"><!-- 检查发起人 -->
and f.INSPECTION_ORIGINATOR_ID = #{pd.INSPECTION_ORIGINATOR_ID}
</if>
<if test="pd.ARCHIVE_USER_ID != null and pd.ARCHIVE_USER_ID != ''">
and (
f.INSPECTION_ORIGINATOR_ID = #{pd.ARCHIVE_USER_ID}
OR f.INSPECTED_SITEUSER_ID = #{pd.ARCHIVE_USER_ID}
OR EXISTS(select 1 from bus_inspection_safetyenvironmental_inspector sii where sii.INSPECTION_USER_ID = #{pd.ARCHIVE_USER_ID}
and sii.INSPECTION_ID = f.INSPECTION_ID)
)
</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.INSPECTION_TYPE != null and pd.INSPECTION_TYPE != ''"><!-- 检查类型 -->
and f.INSPECTION_TYPE = #{pd.INSPECTION_TYPE}
</if>
<if test="pd.INSPECTION_SUBJECT != null and pd.INSPECTION_SUBJECT != ''"><!-- 检查题目 -->
and f.INSPECTION_SUBJECT = #{pd.INSPECTION_SUBJECT,jdbcType=VARCHAR}
</if>
<if test="pd.INSPECTION_TIME_START != null and pd.INSPECTION_TIME_START != ''"><!-- 检查时间 -->
and f.INSPECTION_TIME_START &gt;= CONCAT(#{pd.INSPECTION_TIME_START}, ' 00:00')
</if>
<if test="pd.INSPECTION_TIME_END != null and pd.INSPECTION_TIME_END != ''"><!-- 检查时间 -->
and f.INSPECTION_TIME_END &lt;= CONCAT(#{pd.INSPECTION_TIME_END}, ' 23:59')
</if>
<if test="pd.INSPECTION_STATUS != null and pd.INSPECTION_STATUS != ''"><!-- 检查状态 -->
<choose>
<when test="pd.INSPECTION_STATUS == '3-7'">
and f.INSPECTION_STATUS in ('3','4','5','6','7','8')
</when>
<otherwise>
and f.INSPECTION_STATUS = #{pd.INSPECTION_STATUS}
</otherwise>
</choose>
</if>
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 被检查单位 -->
and (
isd.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
OR iod.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
)
</if>
GROUP BY f.INSPECTION_ID
ORDER BY field(f.INSPECTION_STATUS,'8') ASC, f.CREATTIME DESC
2024-02-06 11:02:25 +08:00
</select>
<select id="statisticsBranchGroupDept" parameterType="pd" resultType="pd">
SELECT
COUNT(DISTINCT h.HIDDEN_ID) HIDDEN_FIND,
IFNULL(CASE WHEN isa.INSPECTION_ASSESS_ID IS NOT NULL THEN COUNT(DISTINCT isa.INSPECTION_ASSESS_ID) END,0) HIDDEN_ASSESS,
IFNULL(CASE WHEN isa.INSPECTION_ASSESS_ID IS NOT NULL THEN SUM(isa.ASSESS_SCORE) END,0) ASSESS_SCORE,
se.INSPECTED_DEPARTMENT_ID
FROM BUS_INSPECTION_SAFETYENVIRONMENTAL se
LEFT JOIN BUS_HIDDEN h ON h.FOREIGN_ID = se.INSPECTION_ID AND h.ISDELETE = '0' AND h.SOURCE IN ('4','5') AND h.STATE != '100'
LEFT JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL_ASSESS isa on isa.HIDDEN_ID = h.HIDDEN_ID and isa.ISDELETE = '0'
WHERE 1=1 AND se.ISDELETE = '0'AND se.INSPECTION_SOURCE = '5'
<if test="YEAR != null and YEAR != ''"><!-- 检查年份 -->
<choose>
<when test="QUARTER != null and QUARTER != ''">
<choose>
<when test="QUARTER == 1">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-01-01 00:00')
AND se.INSPECTION_TIME_START &lt; CONCAT(#{YEAR}, '-04-01 00:00')
</when>
<when test="QUARTER == 2">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-04-01 00:00')
AND se.INSPECTION_TIME_START &lt; CONCAT(#{YEAR}, '-07-01 00:00')
</when>
<when test="QUARTER == 3">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-07-01 00:00')
AND se.INSPECTION_TIME_START &lt; CONCAT(#{YEAR}, '-10-01 00:00')
</when>
<when test="QUARTER == 4">
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-10-01 00:00')
AND se.INSPECTION_TIME_START &lt;= CONCAT(#{YEAR}, '-12-31 23:59')
</when>
</choose>
</when>
<otherwise>
AND se.INSPECTION_TIME_START &gt;= CONCAT(#{YEAR}, '-01-01 00:00')
AND se.INSPECTION_TIME_START &lt;= CONCAT(#{YEAR}, '-12-31 23:59')
</otherwise>
</choose>
</if>
group by se.INSPECTED_DEPARTMENT_ID
</select>
<select id="getHiddenTotal" resultType="java.lang.String">
select
COUNT(DISTINCT h.HIDDEN_ID) HIDDEN_COUNT
from
<include refid="tableName"></include> f
LEFT JOIN bus_hidden h on h.FOREIGN_ID = f.INSPECTION_ID
LEFT JOIN vi_user_all iou ON iou.USER_ID = f.INSPECTION_ORIGINATOR_ID
LEFT JOIN OA_DEPARTMENT ild ON ild.DEPARTMENT_ID = f.INSPECTION_LEADDEPARTMENT_ID
LEFT JOIN vi_department_all iod ON iod.DEPARTMENT_ID = iou.DEPARTMENT_ID
LEFT JOIN OA_DEPARTMENT isd ON isd.DEPARTMENT_ID = f.INSPECTED_DEPARTMENT_ID
LEFT JOIN SYS_USER isu ON isu.USER_ID = f.INSPECTED_SITEUSER_ID
LEFT JOIN bus_inspection_safetyenvironmental_inspector si ON si.INSPECTION_ID = f.INSPECTION_ID and si.ISDELETE = '0'
LEFT JOIN vi_user_all siu ON siu.USER_ID = si.INSPECTION_USER_ID
LEFT JOIN sys_dictionaries d ON d.BIANMA = f.INSPECTION_TYPE
LEFT JOIN BUS_INSPECTION_SAFETYENVIRONMENTAL_SITUATION biss on biss.INSPECTION_ID = f.INSPECTION_ID
where f.ISDELETE = '0'
<!-- <if test="pd.supDeparIds != null and pd.supDeparIds != '' and pd.supDeparIds !='ALL' and pd.supDeparIds !='NOT'">-->
<!-- and (f.INSPECTED_DEPARTMENT_ID in (${pd.supDeparIds}) )-->
<!-- </if>-->
<if test="pd.roleLevel != null and pd.roleLevel != ''"><!-- 权限显示 -->
<choose>
<when test='pd.roleLevel == "0"'>
</when>
<when test='pd.roleLevel == "1"'>
and (f.INSPECTED_DEPARTMENT_ID in (${pd.supDeparIds}) or ild.DEPARTMENT_ID in (${pd.supDeparIds}) or f.INSPECTED_SITEUSER_ID in (${pd.supDeparIds}))
</when>
<when test='pd.roleLevel == "2"'>
and (f.INSPECTION_ORIGINATOR_ID = #{pd.loginUserId} or (siu.USER_ID in (#{pd.loginUserId}) or h.RECTIFICATIONOR in (#{pd.loginUserId})))
</when>
</choose>
</if>
<!-- <if test="pd.INSPECTION_ORIGINATOR_ID != null and pd.INSPECTION_ORIGINATOR_ID != ''">&lt;!&ndash; 检查发起人 &ndash;&gt;-->
<!-- and f.INSPECTION_ORIGINATOR_ID = #{pd.INSPECTION_ORIGINATOR_ID}-->
<!-- </if>-->
<if test="pd.ARCHIVE_USER_ID != null and pd.ARCHIVE_USER_ID != ''">
and (
f.INSPECTION_ORIGINATOR_ID = #{pd.ARCHIVE_USER_ID}
OR si.INSPECTION_USER_ID = #{pd.ARCHIVE_USER_ID}
OR f.INSPECTED_SITEUSER_ID = #{pd.ARCHIVE_USER_ID}
)
</if>
<if test="pd.INSPECTION_SUBJECT != null and pd.INSPECTION_SUBJECT != ''"><!-- 检查题目 -->
and f.INSPECTION_SUBJECT LIKE CONCAT(CONCAT('%', #{pd.INSPECTION_SUBJECT}),'%')
</if>
<if test="pd.HIDDENDESCR != null and pd.HIDDENDESCR != ''"><!-- 隐患描述 -->
and h.HIDDENDESCR LIKE CONCAT(CONCAT('%', #{pd.HIDDENDESCR}),'%')
</if>
<if test="pd.SITUATION != null and pd.SITUATION != ''"><!-- 检查情况 -->
and biss.SITUATION LIKE CONCAT(CONCAT('%', #{pd.SITUATION}),'%')
</if>
<if test="pd.INSPECTED_DEPARTMENT_ID != null and pd.INSPECTED_DEPARTMENT_ID != ''"><!-- 被检查单位 -->
and isd.DEPARTMENT_ID = #{pd.INSPECTED_DEPARTMENT_ID}
</if>
<if test="pd.INSPECTION_DEPARTMENT_ID != null and pd.INSPECTION_DEPARTMENT_ID != ''"><!-- 检查部门 -->
and iod.DEPARTMENT_ID = #{pd.INSPECTION_DEPARTMENT_ID}
</if>
<if test="pd.INSPECTION_TYPE != null and pd.INSPECTION_TYPE != ''"><!-- 检查类型 -->
and f.INSPECTION_TYPE = #{pd.INSPECTION_TYPE}
</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.INSPECTION_TYPE != null and pd.INSPECTION_TYPE != ''"><!-- 检查类型 -->
and f.INSPECTION_TYPE = #{pd.INSPECTION_TYPE}
</if>
<if test="pd.INSPECTION_TIME_START != null and pd.INSPECTION_TIME_START != ''"><!-- 检查时间 -->
and f.INSPECTION_TIME_START &gt;= CONCAT(#{pd.INSPECTION_TIME_START}, ' 00:00')
</if>
<if test="pd.INSPECTION_TIME_END != null and pd.INSPECTION_TIME_END != ''"><!-- 检查时间 -->
and f.INSPECTION_TIME_END &lt;= CONCAT(#{pd.INSPECTION_TIME_END}, ' 23:59')
</if>
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''">
and f.CORPINFO_ID = #{pd.CORPINFO_ID}
</if>
<if test="pd.CORPINFO_ID_MAIN != null and pd.CORPINFO_ID_MAIN != ''">
and f.CORPINFO_ID = #{pd.CORPINFO_ID} and f.INSPECTION_SOURCE = '5'
</if>
<if test="pd.INSPECTION_STATUS != null and pd.INSPECTION_STATUS != ''"><!-- 检查状态 -->
<choose>
<when test="pd.INSPECTION_STATUS == '3-7'">
and f.INSPECTION_STATUS in ('3','4','5','6','7','8')
</when>
<otherwise>
and f.INSPECTION_STATUS = #{pd.INSPECTION_STATUS}
</otherwise>
</choose>
</if>
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 被检查单位 -->
and (
isd.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
OR iod.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
)
</if>
ORDER BY f.CREATTIME DESC
</select>
<!-- 指派数+验收数3、4、6 -->
<select id="repulseAndCheckCountCountV2" parameterType="pd" resultType="pd">
SELECT
count( DISTINCT a.INSPECTION_ID ) repulseAndCheckCount
FROM
bus_inspection_safetyenvironmental a
LEFT JOIN bus_hidden b ON b.FOREIGN_ID = a.INSPECTION_ID
WHERE
a.ISDELETE = '0'
AND (
a.INSPECTION_ORIGINATOR_ID = #{INSPECTED_SITEUSER_ID}
OR a.INSPECTED_SITEUSER_ID = #{INSPECTED_SITEUSER_ID}
OR EXISTS ( SELECT 1 FROM bus_inspection_safetyenvironmental_inspector
sii WHERE sii.INSPECTION_USER_ID = #{INSPECTED_SITEUSER_ID}
AND sii.INSPECTION_ID = a.INSPECTION_ID )
)
AND a.INSPECTION_STATUS IN ( '3', '4', '5', '6', '7', '8' )
and b.creator = #{INSPECTED_SITEUSER_ID} and (b.STATE ='4' or b.STATE ='8')
and (b.FINAL_CHECK is null or b.FINAL_CHECK ='2') and b.ISDELETE = '0'
GROUP BY a.INSPECTION_ID
)
</select>
</mapper>