<?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.map.MapEightMapper">


	<select id="getCorpinfoIds" parameterType="string" resultType="string" >
		SELECT CORPINFO_ID FROM bus_corp_info WHERE ISDELETE = '0' AND AREA IN
		<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
			#{item}
		</foreach>
	</select>

	<select id="getEcharts" resultType="map">
		SELECT
		t.click_date clickDate,
		IFNULL(h.dhzyCount,0) dhzyCount,
		IFNULL(h.dbzyCount,0) dbzyCount,
		IFNULL(h.yxgjzyCount,0) yxgjzyCount,
		IFNULL(h.gczyCount,0) gczyCount,
		IFNULL(h.dzzyCount,0) dzzyCount,
		IFNULL(h.lsydCount, 0) lsydCount
		FROM
		(
		SELECT
		a.click_date
		FROM
		(
		SELECT
		CURDATE() AS click_date UNION ALL
		SELECT
		date_sub( CURDATE(), INTERVAL 1 DAY ) AS click_date UNION ALL
		SELECT
		date_sub( CURDATE(), INTERVAL 2 DAY ) AS click_date UNION ALL
		SELECT
		date_sub( CURDATE(), INTERVAL 3 DAY ) AS click_date UNION ALL
		SELECT
		date_sub( CURDATE(), INTERVAL 4 DAY ) AS click_date
		) a
		) t
		LEFT JOIN (
		SELECT
		s.CREATTIME,
		SUM( s.cutroadCount ) dhzyCount,
		sum( s.blindboardCount ) dbzyCount,
		SUM( s.breakgroundCount ) yxgjzyCount,
		SUM( s.highworkCount ) gczyCount,
		SUM( s.hoistingCount ) dzzyCount,
		SUM( s.electricityCount ) lsydCount
		FROM
		(
		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		count( 1 ) cutroadCount,
		'0' blindboardCount,
		'0' breakgroundCount,
		'0' highworkCount,
		'0' hoistingCount,
		'0' electricityCount
		FROM
		bus_hotwork_cfd
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
			#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL

		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' AS hotworkapplicationCount,
		count( 1 ) blindboardCount,
		'0' confinedspaceCount,
		'0' highworkCount,
		'0' hoistingCount,
		'0' electricityCount
		FROM
		bus_blindboard
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL

		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' cutroadCount,
		'0' blindboardCount,
		count( 1 ) confinedspaceCount,
		'0' highworkCount,
		'0' hoistingCount,
		'0' electricityCount
		FROM
		bus_confinedspace
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL

		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' hotworkapplicationCount,
		'0' blindboardCount,
		'0' confinedspaceCount,
		count( 1 ) highworkCount,
		'0' hoistingCount,
		'0' electricityCount
		FROM
		bus_highwork
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL


		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' hotworkapplicationCount,
		'0' blindboardCount,
		'0' confinedspaceCount,
		'0' highworkCount,
		count( 1 ) hoistingCount,
		'0' electricityCount
		FROM
		bus_hoisting
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL


		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' hotworkapplicationCount,
		'0' blindboardCount,
		'0' confinedspaceCount,
		'0' highworkCount,
		'0' hoistingCount,
		count( 1 ) electricityCount
		FROM
		bus_electricity
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' )

		) s
		GROUP BY
		s.CREATTIME
		) h ON h.CREATTIME = t.click_date
		order by t.click_date
		</select>


	<!-- 获取高危作业统计数据 -->
	<!--  申请数[COUNTAPPLY]，审批中[COUNTAPPROVE]，归档[COUNTARCHIVE]	-->
	<select id="statisticsHighRiskWorkByState" parameterType="pd" resultType="pd">
		SELECT
			SUM(f.COUNTAPPLY) COUNTAPPLY,SUM(f.COUNTAPPROVE) COUNTAPPROVE,SUM(f.COUNTARCHIVE) COUNTARCHIVE
		FROM (
			SELECT
              COUNT( CASE WHEN f.APPLY_STATUS > 0 THEN f.HOTWORK_ID END ) COUNTAPPLY,
              COUNT( CASE WHEN f.APPLY_STATUS > 0 AND f.APPLY_STATUS != 8 THEN f.HOTWORK_ID END ) COUNTAPPROVE,
              COUNT( CASE WHEN f.APPLY_STATUS = 8 THEN f.HOTWORK_ID END ) COUNTARCHIVE
        FROM bus_hotwork_cfd f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.ELECTRICITY_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in  ('0','5')  then f.ELECTRICITY_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '5' then f.ELECTRICITY_ID end) COUNTARCHIVE
		FROM bus_electricity f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.BLINDBOARD_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6') then f.BLINDBOARD_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.BLINDBOARD_ID end) COUNTARCHIVE
		FROM bus_blindboard f
		WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.HIGHWORK_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6') then f.HIGHWORK_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.HIGHWORK_ID end) COUNTARCHIVE
		FROM bus_highwork f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.CONFINEDSPACE_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6')  then f.CONFINEDSPACE_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.CONFINEDSPACE_ID end) COUNTARCHIVE
		FROM bus_confinedspace f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.HOISTING_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6') then f.HOISTING_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.HOISTING_ID end) COUNTARCHIVE
		FROM bus_hoisting f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		) f
	</select>


	<!-- 作业实时情况展示 -->
	<select id="realTimeHighRiskWorklistPage" parameterType="page" resultType="pd">
		SELECT * FROM
			(SELECT
		f.HOTWORK_ID ID,
		f.CHECK_NO WORK_NUMBER,
		'动火作业' WORK_TYPE,
		CASE
		f.APPLY_STATUS
		WHEN 0 THEN
		'动火作业待提交'
		WHEN 1 THEN
		'作业负责人待审核'
		WHEN 2 THEN
		'所在单位待审核'
		WHEN 4 THEN
		'安全管理部门待审核'
		WHEN 5 THEN
		'动火审批人待审核'
		WHEN 6 THEN
		'班长待验票'
		WHEN 7 THEN
		'待验收'
		END STATUS_NAME,
		CASE WHEN f.APPLY_STATUS = 0 THEN
		IFNULL(
		GROUP_CONCAT(
		REPLACE ( u1.NAME, '/', ',' )),
		IFNULL( qu1.`NAME`, '' ))
		WHEN f.APPLY_STATUS = 1 THEN
		IFNULL(
		GROUP_CONCAT(
		REPLACE ( u1.NAME, '/', ',' )),
		IFNULL( qu1.`NAME`, '' ))
		WHEN f.APPLY_STATUS = 2 THEN
		IFNULL(
		GROUP_CONCAT(
		REPLACE ( u2.NAME, '/', ',' )),
		IFNULL( qu2.`NAME`, '' ))

		WHEN f.APPLY_STATUS = 4 THEN
		IFNULL(
		GROUP_CONCAT(
		REPLACE ( u3.NAME, '/', ',' )),
		IFNULL( qu3.`NAME`, '' ))

		WHEN f.APPLY_STATUS = 5 THEN
		IFNULL(
		GROUP_CONCAT(
		REPLACE ( u4.NAME, '/', ',' )),
		IFNULL( qu4.`NAME`, '' ))
		WHEN f.APPLY_STATUS = 6 THEN
		IFNULL(
		GROUP_CONCAT(
		REPLACE ( u5.NAME, '/', ',' )),
		IFNULL( qu5.`NAME`, '' ))
		WHEN f.APPLY_STATUS = 7 THEN
		IFNULL(
		GROUP_CONCAT(
		REPLACE ( u6.NAME, '/', ',' )),
		IFNULL( qu6.`NAME`, '' ))
		ELSE
		IFNULL(
		GROUP_CONCAT(
		REPLACE ( u6.NAME, '/', ',' )),
		IFNULL( qu6.`NAME`, '' ))
		END USER_NAME,
		DATE_FORMAT( ifnull( f.OPERATTIME, f.CREATTIME ), '%Y-%m-%d %H:%i:%s' ) OPERATTIME
		FROM
		bus_hotwork_cfd f
		LEFT JOIN sys_user u1 ON u1.USER_ID = f.CONFIRM_USER_ID
		LEFT JOIN `qa-gwj-regulatory`.sys_user qu1 ON qu1.USER_ID = f.CONFIRM_USER_ID
		LEFT JOIN sys_user u2 ON u2.USER_ID = f.LEADER_USER_ID
		LEFT JOIN `qa-gwj-regulatory`.sys_user qu2 ON qu2.USER_ID = f.LEADER_USER_ID
		LEFT JOIN sys_user u3 ON u3.USER_ID = f.AUDIT_USER_ID
		LEFT JOIN `qa-gwj-regulatory`.sys_user qu3 ON qu3.USER_ID = f.AUDIT_USER_ID
		LEFT JOIN sys_user u4 ON u4.USER_ID = f.APPROVE_USER_ID
		LEFT JOIN `qa-gwj-regulatory`.sys_user qu4 ON qu4.USER_ID = f.APPROVE_USER_ID
		LEFT JOIN sys_user u5 ON u5.USER_ID = f.MONITOR_USER_ID
		LEFT JOIN `qa-gwj-regulatory`.sys_user qu5 ON qu5.USER_ID = f.MONITOR_USER_ID
		LEFT JOIN sys_user u6 ON u6.USER_ID = f.ACCEPT_USER_ID
		LEFT JOIN `qa-gwj-regulatory`.sys_user qu6 ON qu6.USER_ID = f.ACCEPT_USER_ID
		WHERE
		f.ISDELETE = '0'
		AND f.APPLY_STATUS >= 0
		AND f.APPLY_STATUS != 8
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>
		GROUP BY f.HOTWORK_ID
			UNION ALL
		SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
		FROM
		(SELECT
		f.electricity_ID ID,
		f.CHECK_NO WORK_NUMBER,
		'临时用电作业' WORK_TYPE,
		case f.APPLY_STATUS
		when '0' then '待提交'
		when '1' then '作业负责人待审核'
		when '2' then '用电单位待审核'
		when '3' then '配送电单位待审核'
		when '4' then '待验收'
		when '-2' then '已打回'
		when '-3' then '已打回'
		when '-4' then '已打回'
		when '-5' then '已打回'
		END STATUS_NAME,
		case f.APPLY_STATUS
		when '0' then f.APPLY_USER_ID
		when '1' then f.CONFIRM_USER_ID
		when '2' then f.AUDIT_USER_ID
		when '3' then f.APPROVE_USER_ID
		when '4' then f.ACCEPT_USER_ID
		when '-1' then f.APPLY_USER_ID
		when '-2' then f.APPLY_USER_ID
		when '-3' then f.APPLY_USER_ID
		when '-4' then f.APPLY_USER_ID
		when '-5' then f.APPLY_USER_ID
		END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
		FROM bus_electricity f WHERE f.ISDELETE = '0' AND f.APPLY_STATUS != '5'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

		) f
		LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
		UNION ALL
		SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
		FROM
		(SELECT
		f.blindboard_ID ID,
		f.CHECK_NO WORK_NUMBER,
		'盲板作业' WORK_TYPE,
		case f.APPLY_STATUS
		when '0' then '待提交'
		when '1' then '作业负责人待审核'
		when '4' then '所在单位待审核'
		when '5' then '待验收'
		when '-2' then '已打回'
		when '-5' then '已打回'
		when '-6' then '已打回'
		END STATUS_NAME,
		case f.APPLY_STATUS
		when '0' then f.APPLY_USER_ID
		when '1' then f.CONSTRUCTION_USER_ID
		when '4' then f.LEADER_USER_ID
		when '5' then f.ACCEPT_USER_ID
		when '-2' then APPLY_USER_ID
		when '-5' then APPLY_USER_ID
		when '-6' then APPLY_USER_ID
		END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
		FROM bus_blindboard f
		WHERE f.ISDELETE = '0' AND f.APPLY_STATUS != '6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

		) f
		LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
		UNION ALL
		SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
		FROM
		(SELECT
		f.HIGHWORK_ID ID,
		f.CHECK_NO WORK_NUMBER,
		'高处作业' WORK_TYPE,
		case f.APPLY_STATUS
		when '0' then '待提交'
		when '1' then '作业负责人待审核'
		when '2' then '所在单位待审核'
		when '3' then '审核部门待审核'
		when '4' then '审批部门待审核'
		when '5' then '待验收'
		when '-2' then '已打回'
		when '-3' then '已打回'
		when '-4' then '已打回'
		when '-5' then '已打回'
		when '-6' then '已打回'
		END STATUS_NAME,
		case f.APPLY_STATUS
		when '0' then f.CREATOR
		when '1' then f.CONSTRUCTION_USER_ID
		when '2' then f.LEADER_USER_ID
		when '3' then f.AUDIT_USER_ID
		when '4' then f.APPROVE_USER_ID
		when '5' then f.ACCEPT_USER_ID
		when '-2' then f.CREATOR
		when '-3' then f.CREATOR
		when '-4' then f.CREATOR
		when '-5' then f.CREATOR
		when '-6' then f.CREATOR
		END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
		FROM bus_highwork f WHERE f.ISDELETE = '0' AND f.APPLY_STATUS !='6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

		) f
		LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
		UNION ALL
		SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
		FROM
		(SELECT
		f.confinedspace_ID ID,
		f.CHECK_NO WORK_NUMBER,
		'有限空间作业' WORK_TYPE,
		case f.APPLY_STATUS
		when '1' then '作业负责人待审核'
		when '4' then '所在单位待审核'
		when '5' then '待验收'
		when '-4' then '作业负责人审核打回'
		when '-5' then '所在单位审核打回'
		when '-6' then '验收打回'
		END STATUS_NAME,
		case f.APPLY_STATUS
		when '1' then f.CONFIRM_USER_ID
		when '4' then f.APPROVE_USER_ID
		when '5' then f.ACCEPT_USER_ID
		when '-4' then f.CREATOR
		when '-5' then f.CREATOR
		when '-6' then f.CREATOR
		END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
		FROM bus_confinedspace f WHERE f.ISDELETE = '0' AND f.APPLY_STATUS != '6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>
		) f
		LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
		UNION ALL
		SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
		FROM
		(SELECT
		f.hoisting_ID ID,
		f.CHECK_NO WORK_NUMBER,
		'吊装作业' WORK_TYPE,
		case f.APPLY_STATUS
		when '0' then '待提交'
		when '1' then '作业指挥待审核'
		when '2' then '所在单位待审核'
		when '3' then '审核部门待审核'
		when '4' then '审批部门待审核'
		when '5' then '待验收'
		when '-2' then '已打回'
		when '-3' then '已打回'
		when '-4' then '已打回'
		when '-5' then '已打回'
		when '-6' then '已打回'
		END STATUS_NAME,
		case f.APPLY_STATUS
		when '0' then f.CREATOR
		when '1' then f.LEADER_USER_ID
		when '2' then f.CONSTRUCTION_USER_ID
		when '3' then f.AUDIT_USER_ID
		when '4' then f.APPROVE_USER_ID
		when '5' then f.ACCEPT_USER_ID
		when '-2' then f.CREATOR
		when '-3' then f.CREATOR
		when '-4' then f.CREATOR
		when '-5' then f.CREATOR
		when '-6' then f.CREATOR
		END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
		FROM bus_hoisting f
		WHERE f.ISDELETE = '0'  AND f.APPLY_STATUS !='6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>
		) f
				LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
			) f
		ORDER BY f.OPERATTIME DESC
	</select>


	<!--动火-->
	<select id="getHOTWORKHighRiskWorkLocation" parameterType="pd" resultType="pd">
		SELECT
				'HOTWORK' TYPE,
				f.HOTWORKAPPLICATION_ID id,
				CONCAT_WS("", '动火作业 编号：', f.JOB_NUMBER) NAME,
				f.WORK_LONGITUDE LONGITUDE,
				f.WORK_LATITUDE LATITUDE,
				'./bi/images/map/hotwork.png' IMAGE_FILE,
				f.CORPINFO_ID,
				f.JOB_NUMBER as MAP_POINT_NAME
			 FROM bus_hotworkapplication f
			 WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
			   AND f.STATE >= 0 and f.STATE != 11
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--临时用电-->
	<select id="getELECTRICITYHighRiskWorkLocation" parameterType="pd" resultType="pd">
		SELECT
			'ELECTRICITY' TYPE,
			f.ELECTRICITY_ID id,
			CONCAT_WS("", '临时用电作业 编号：', f.CHECK_NO) NAME,
			f.WORK_LONGITUDE LONGITUDE,
			f.WORK_LATITUDE LATITUDE,
			'./bi/images/map/electricity.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO as MAP_POINT_NAME
		FROM bus_electricity f WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
			AND f.APPLY_STATUS NOT IN ('3','4')
			AND date_format(now(),'%Y-%m-%d %H:%i') >= f.WORK_START_DATE AND f.WORK_END_DATE >= date_format(now(),'%Y-%m-%d %H:%i')
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--盲板作业-->
	<select id="getBLINDBOARDHighRiskWorkLocation" parameterType="pd" resultType="pd">
			SELECT
		'BLINDBOARD' TYPE,
		f.BLINDBOARD_ID id,
		CONCAT_WS("", '盲板作业 编号：', f.CHECK_NO) NAME,
		bb.LONGITUDE LONGITUDE,
		bb.LATITUDE LATITUDE,
		'./bi/images/map/blindboard.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO as MAP_POINT_NAME
	FROM bus_blindboard f
	left join bus_blindboardinfo bb on bb.BLINDBOARD_ID = f.BLINDBOARD_ID
	WHERE f.ISDELETE = '0' AND bb.LONGITUDE IS NOT NULL AND bb.LATITUDE IS NOT NULL
		AND f.APPLY_STATUS NOT IN ('3','4')
		AND date_format(now(),'%Y-%m-%d %H:%i') >= bb.BOARD_INSTALL_TIME AND bb.BOARD_DISASSEMBLE_TIME >= date_format(now(),'%Y-%m-%d %H:%i')
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--高处作业-->
	<select id="getHIGHWORKHighRiskWorkLocation" parameterType="pd" resultType="pd">
		SELECT
				'HIGHWORK' TYPE,
				f.HIGHWORK_ID id,
				CONCAT_WS("", '高处作业 编号：', f.CHECK_NO) NAME,
				f.WORK_LONGITUDE LONGITUDE,
				f.WORK_LATITUDE LATITUDE,
				'./bi/images/map/highwork.png' IMAGE_FILE,
				f.CORPINFO_ID,
				f.CHECK_NO as MAP_POINT_NAME
			FROM bus_highwork f WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
				AND f.APPLY_STATUS NOT IN ('4','5','55','-5')
				AND date_format(now(),'%Y-%m-%d %H:%i') >= f.WORK_START_DATE AND f.WORK_END_DATE >= date_format(now(),'%Y-%m-%d %H:%i')
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--动火-->
	<select id="findByIdHOTWORK" parameterType="pd" resultType="pd">
		select
		f.APPLY_USER_ID,
		f.JOB_NUMBER,
		f.APPLICATION_DATE,
		f.JOB_TYPE_INDEX,
		f.HOT_WORK_POSITION,
		f.HOT_WORK_LEVEL_INDEX,
		f.HOT_WORK_METHOD_ID,
		f.JOB_CONTENT,
		f.HOT_WORK_TIME_START,
		f.HOT_WORK_TIME_END,
		f.CREATOR,
		f.CREATTIME,
		f.OPERATOR,
		f.OPERATTIME,
		f.STATE,
		f.ISDELETE,
		f.WORK_LONGITUDE,
		f.WORK_LATITUDE,
		f.CORPINFO_ID,
		f.IS_SAFETY_DIRECTOR,
		f.IS_GAS_TESTING,
		f.SPARE,
		f.HOTWORKAPPLICATION_ID,
		u.NAME CREATORNAME,
		d.NAME DEPARTMENTNAME,
		p.name as HOT_WORK_METHOD_NAME
		from
		BUS_HOTWORKAPPLICATION f
		left join sys_user u on f.CREATOR = u.USER_ID
		left join oa_department d on d.DEPARTMENT_ID = u.DEPARTMENT_ID
		left join sys_dictionaries p on f.HOT_WORK_METHOD_ID = p.DICTIONARIES_ID
		where
		f.HOTWORKAPPLICATION_ID = #{HOTWORKAPPLICATION_ID}
	</select>

	<!-- 列表(全部) -->
	<select id="listAlldelayed" parameterType="pd" resultType="pd">
		select
		f.HOTWORKAPPLICATION_ID,
		f.USER_ID,
		f.CREATOR,
		f.CREATTIME,
		f.FILEPATH,
		f.ISDELETE,
		f.TIME,
		f.HOTWORKAPPLICATIONDELAYED_ID
		,u.NAME userName
		from
		BUS_HOTWORKAPPLICATIONDELAYED f
		left join SYS_USER u on u.USER_ID = f.USER_ID
		where  f.HOTWORKAPPLICATION_ID = #{HOTWORKAPPLICATION_ID}
		ORDER BY f.CREATTIME desc
	</select>

	<select id="listAllcuoshiHOTWORK" parameterType="pd" resultType="pd">
		select
		f.HOTWORKAPPLICATION_ID,
		f.CONTENT,
		f.CORPINFO_ID,
		f.CREATE_USER_ID,
		f.CREATE_DEPARTMENT_ID,
		f.ISDELETE,
		f.OPERATOR,
		f.OPERATTIME,
		f.CREATTIME,
		f.CREATOR,
		f.HOTWORKSAFETYMETHODRECORD_ID
		from
		BUS_HOTWORKSAFETYMETHODRECORD f
		where f.ISDELETE = '0'
		AND f.HOTWORKAPPLICATION_ID = #{HOTWORKAPPLICATION_ID}
		ORDER BY f.OPERATTIME
	</select>

	<!-- 动火措施列表 -->
	<select id="listAllMeasuresHOTWORK" parameterType="pd" resultType="pd">
		select
		f.*
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			,eo.STATUS
		</if>
		from
		BUS_HOISTING_MEASURES f
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			left join BUS_HOISTINGTOMEASURES eo on eo.HOISTING_MEASURES_ID = f.HOISTING_MEASURES_ID
		</if>
		where f.ISDELETE = '0'
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			and eo.HOISTING_ID = #{HOISTING_ID}
		</if>
		GROUP BY f.HOISTING_MEASURES_ID
		ORDER BY f.SORT ASC
	</select>

	<!-- 列表(全部) -->
	<select id="listAll" parameterType="pd" resultType="pd">
		select
		f.HOTWORKAPPLICATION_ID,
		f.USER_ID,
		f.CREATOR,
		f.CREATTIME,
		f.FILEPATH,
		f.ISDELETE,
		f.TIME,
		f.HOTWORKAPPLICATIONDELAYED_ID
		,u.NAME userName
		from
		BUS_HOTWORKAPPLICATIONDELAYED f
		left join SYS_USER u on u.USER_ID = f.USER_ID
		where 1=1
		<if test="HOTWORKAPPLICATION_ID != null and HOTWORKAPPLICATION_ID != ''"><!-- 关键词检索 -->
			and( f.HOTWORKAPPLICATION_ID = #{HOTWORKAPPLICATION_ID})
		</if>
		ORDER BY f.CREATTIME desc
	</select>

	<select id="getList" parameterType="pd" resultType="pd">
		SELECT
		f.*
		,dept.NAME as deptName
		,u.NAME as userName
		,su.USERNAME as userName2
		, u.USERNAME as userPhone
		,dept.DEPARTMENT_ID DEPARTMENT_ID
		,su.USER_TYPE USER_TYPE
		,reuser.NAME as REGULATORY_USER_NAME
		,redept.NAME  as REGULATORY_DEPT_NAME
		from
		BUS_HOTWORKAPPLICATIONUSER f
		left join SYS_USER u on u.USER_ID = f.USER_ID
		left join bus_specialuser su on su.SPECIALUSER_ID = f.USER_ID
		left join oa_department dept on dept.DEPARTMENT_ID = u.DEPARTMENT_ID
		left join `qa-gwj-regulatory`.SYS_USER reuser on reuser.USER_ID = f.USER_ID and reuser.USERNAME != 'admin'
		left join `qa-gwj-regulatory`.SYS_DEPARTMENT redept on redept.DEPARTMENT_ID = reuser.DEPARTMENT_ID
		WHERE
		f.ISDELETE = '0'
		and f.FOREIGN_KEY=  #{HOTWORKAPPLICATION_ID}
	</select>

	<!-- 列表(全部) -->
	<select id="listAllMeasures" parameterType="pd" resultType="pd">
		SELECT
			f.BUS_HOTWORK_MEASURES_ID,
			f.PROTECTIVE_MEASURES,
			f.QUESTION1,
            f.QUESTION2,
            f.QUESTION3,
            f.QUESTION4,
            f.ISDELETE,
            f.ORDERBY,
			hwtm.ANSWER1,
			hwtm.ANSWER2,
			hwtm.ANSWER3,
			hwtm.ANSWER4

		FROM
		     BUS_HOTWORK_MEASURES f
		LEFT JOIN BUS_HOTWORKTOMEASURES hwtm on f.BUS_HOTWORK_MEASURES_ID = hwtm.BUS_HOTWORK_MEASURES_ID and hwtm.HOTWORKAPPLICATION_ID = #{HOTWORKAPPLICATION_ID}
		WHERE f.ISDELETE = '0'
		oRDER BY f.ORDERBY
	</select>

	<!-- 动火查询数据列表 -->
	<select id="listAllHOTWORK" parameterType="pd" resultType="pd">
		select
		f.HOTWORK_ID,
		f.ANALYZE_TIME,
		f.ANALYZE_PLACE,
		f.ANALYZE_RESULT,
		f.ANALYZE_USER,
		f.ISDELETE,
		f.HOTWORKGAS_ID
		from
		BUS_HOTWORKGAS f
		where f.HOTWORK_ID = #{HOTWORK_ID}
	</select>

	<!--临时用电-->
	<select id="findByIdELECTRICITY" parameterType="pd" resultType="pd">
		select
		IFNULL(GROUP_CONCAT(REPLACE(su.SPECIALUSER_ID,'/',',')),'') as WORK_OPERATOR_ID,
		IFNULL(GROUP_CONCAT(REPLACE(su.USERNAME,'/',',')),'') as WORK_OPERATOR_NAME,
		IFNULL(GROUP_CONCAT(REPLACE(su.SPECIAL_NUMBER,'/',',')),'') as WORK_OPERATOR_NUMBER,
		f.ELECTRICITY_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.CREATTIME,
		f.CREATOR,
		f.OPERATTIME,
		f.OPERATOR,
		f.CHECK_NO,
		f.WORK_CONTENT,
		f.WORK_START_DATE,
		f.WORK_END_DATE,
		f.CONFIRM_DEPARTMENT_ID,
		f.CONFIRM_USER_ID,
		f.CONFIRM_USER_SIGNER_PATH,
		f.CONFIRM_USER_SIGNER_TIME,
		f.APPROVE_DEPARTMENT_ID,
		f.APPROVE_USER_ID,
		f.APPROVE_USER_SIGNER_PATH,
		f.APPROVE_USER_SIGNER_TIME,
		f.OTHER_PROTECTIVE_MEASURES,
		f.ACCEPT_DEPARTMENT_ID,
		f.ACCEPT_USER_ID,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER_ID,
		f.WORK_PLACE,
		f.ELECTRICITY_UNIT,
		f.WORK_LONGITUDE,
		f.WORK_LATITUDE,
		f.EQUIPMENT_POWER,
		f.CONFIRM_DEPARTMENT_NAME,
		f.CONFIRM_USER_NAME,
		f.WORK_DEPARTMENT_ID,
		f.WORK_USER_ID,
		f.WORK_DEPARTMENT_NAME,
		f.WORK_USER_NAME,
		f.WORK_USER_SIGNER_PATH,
		f.WORK_USER_SIGNER_TIME,
		f.ASSURE_DEPARTMENT_ID,
		f.ASSURE_USER_ID,
		f.ASSURE_DEPARTMENT_NAME,
		f.ASSURE_USER_NAME,
		f.ASSURE_USER_SIGNER_PATH,
		f.ASSURE_USER_SIGNER_TIME,
		f.APPROVE_DEPARTMENT_NAME,
		f.APPROVE_USER_NAME,
		f.APPLY_STATUS,
		f.CHECK_STATUS,
		f.ACCESS_POINT,
		f.RISK_ANALYSIS,
		f.SECURITY_CONFIDANT,
		f.METERING_BILL,
		f.ACCEPT_DEPARTMENT_NAME,
		f.ACCEPT_USER_NAME,
		f.ACCEPT_TIME,
		f.APPLY_DEPARTMENT_NAME,
		f.APPLY_USER_NAME,
		f.ACCEPT_RESULT_NAME
		from
		bus_electricity f

		left join BUS_ELECTRICITY_OPERATOR eo on eo.ELECTRICITY_ID = f.ELECTRICITY_ID and eo.ISDELETE = '0'
		left join BUS_SPECIALUSER su on su.SPECIALUSER_ID = eo.SPECIALUSER

		where
		f.ELECTRICITY_ID = #{ELECTRICITY_ID}
	</select>

	<!-- 临时用电措施列表-->
	<select id="listAllMeasuresELECTRICITY" parameterType="pd" resultType="pd">
		select
		f.*
		<if test="ELECTRICITY_ID != null and ELECTRICITY_ID != '' and APPLY_STATUS != null and APPLY_STATUS != '' and (APPLY_STATUS != '1' or APPLY_STATUS != 1)">
			,eo.STATUS
		</if>
		from
		BUS_ELECTRICITY_MEASURES f
		<if test="ELECTRICITY_ID != null and ELECTRICITY_ID != '' and APPLY_STATUS != null and APPLY_STATUS != '' and (APPLY_STATUS != '1' or APPLY_STATUS != 1)">
			left join BUS_ELECTRICITYTOMEASURES eo on eo.BUS_ELECTRICITY_MEASURES_ID = f.BUS_ELECTRICITY_MEASURES_ID
		</if>
		where f.ISDELETE = '0'
		<if test="ELECTRICITY_ID != null and ELECTRICITY_ID != '' and APPLY_STATUS != null and APPLY_STATUS != '' and (APPLY_STATUS != '1' or APPLY_STATUS != 1)">
			and eo.ELECTRICITY_ID = #{ELECTRICITY_ID}
		</if>
		ORDER BY f.SORT ASC
	</select>

	<!--盲板作业-->
	<select id="findByIdBLINDBOARD" parameterType="pd" resultType="pd">
		select
		f.*,
		i.BOARD_MATERIAL,
		i.BOARD_SPECIFICATION,
		i.BOARD_NO,
		i.BOARD_INSTALL_TIME,
		i.BOARD_DISASSEMBLE_TIME,
		i.BOARD_INSTALL_USER,
		i.BOARD_DISASSEMBLE_USER,
		i.BOARD_PATH,
		i.BOARD_HARM,
		i.BOARD_MEASURES,
		i.BOARD_SIGNER_PATH,
		i.BOARD_SIGNER_TIME,
		i.BLINDBOARDINFO_ID,
		i.CONFIRM_SIGNER_PATH,
		i.CONFIRM_SIGNER_TIME,
		i.CONFIRM_OPINION,
		i.APPROVE_SIGNER_PATH,
		i.APPROVE_SIGNER_TIME,
		i.APPROVE_OPINION,
		i.BOARD_INSTALL_CUSTODY_USER,
		i.BOARD_DISASSEMBLE_CUSTODY_USER,
		ad.NAME as APPLY_DEPARTMENT_NAME,
		au.NAME as APPLY_USER_NAME,

		cd.NAME as CONSTRUCTION_DEPARTMENT_NAME,
		cu.NAME as CONSTRUCTION_USER_NAME,

		prd.NAME as PRODUCTION_DEPARTMENT_NAME,
		pru.NAME as PRODUCTION_USER_NAME,

		sd.NAME as SAFETY_DEPARTMENT_NAME,
		su.NAME as SAFETY_USER_NAME,

		ld.NAME as LEADER_DEPARTMENT_NAME,
		lu.NAME as LEADER_USER_NAME,

		acd.NAME as ACCEPT_DEPARTMENT_NAME,
		acu.NAME as ACCEPT_USER_NAME
		from
		bus_blindboard f
		left join BUS_BLINDBOARDINFO i on i.BLINDBOARD_ID = f.BLINDBOARD_ID

		left join OA_DEPARTMENT ad on ad.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID
		left join SYS_USER au on au.USER_ID = f.APPLY_USER_ID

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONSTRUCTION_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONSTRUCTION_USER_ID

		left join OA_DEPARTMENT prd on prd.DEPARTMENT_ID = f.PRODUCTION_DEPARTMENT_ID
		left join SYS_USER pru on pru.USER_ID = f.PRODUCTION_USER_ID

		left join OA_DEPARTMENT sd on sd.DEPARTMENT_ID = f.SAFETY_DEPARTMENT_ID
		left join SYS_USER su on su.USER_ID = f.SAFETY_USER_ID

		left join OA_DEPARTMENT ld on ld.DEPARTMENT_ID = f.LEADER_DEPARTMENT_ID
		left join SYS_USER lu on lu.USER_ID = f.LEADER_USER_ID

		left join OA_DEPARTMENT acd on acd.DEPARTMENT_ID = f.ACCEPT_DEPARTMENT_ID
		left join SYS_USER acu on acu.USER_ID = f.ACCEPT_USER_ID
		where
		f.BLINDBOARD_ID = #{BLINDBOARD_ID}
	</select>

	<!--盲板作业根据id获取经纬度-->
	<select id="findByIdJWD" parameterType="pd" resultType="pd">
		select
		f.ISDELETE,
		f.CREATTIME,
		f.CREATOR,
		f.OPERATTIME,
		f.OPERATOR,
		f.BOARD_MATERIAL,
		f.BOARD_SPECIFICATION,
		f.BOARD_NO,
		f.BOARD_INSTALL_TIME,
		f.BOARD_DISASSEMBLE_TIME,
		f.BOARD_INSTALL_USER,
		f.BOARD_DISASSEMBLE_USER,
		f.BOARD_INSTALL_CUSTODY_USER,
		f.BOARD_DISASSEMBLE_CUSTODY_USER,
		f.CORPINFO_APPROVER,
		f.OPERATION_UNIT_PERSONCHARGE,
		f.BOARD_PATH,
		f.BOARD_HARM,
		f.BOARD_MEASURES,
		f.BOARD_SIGNER_PATH,
		f.BOARD_SIGNER_TIME,
		f.BLINDBOARD_ID,
		f.BLINDBOARDINFO_ID,
		f.WORK_PLACE,
		f.LATITUDE,
		f.LONGITUDE,
		f.CONFIRM_SIGNER_PATH,
		f.CONFIRM_SIGNER_TIME,
		f.CONFIRM_OPINION,
		f.WORK_UNIT_MANAGER_DEPARTMENT_ID,
		f.BRANCH_APPROVER_DEPARTMENT_ID
		from
		BUS_BLINDBOARDINFO f
		where
		f.BLINDBOARDINFO_ID = #{BLINDBOARDINFO_ID}
	</select>

	<!-- 盲板图片查询(全部) -->
	<select id="listAllBLINDBOARD" parameterType="pd" resultType="pd">
		select
		f.FILEPATH,
		f.TYPE,
		f.FOREIGN_KEY,
		f.IMGFILES_ID
		from
		BUS_IMGFILES f
		where 1=1
		<if test="TYPE != null and TYPE != ''"><!-- 关键词检索 -->
			and
			f.TYPE=#{TYPE}
		</if>
		<if test="FOREIGN_KEY != null and FOREIGN_KEY != ''"><!-- 关键词检索 -->
			and
			f.FOREIGN_KEY=#{FOREIGN_KEY}
		</if>
	</select>

	<!--高处作业-->
	<select id="findByIdHIGHWORK" parameterType="pd" resultType="pd">
		select
		f.CHECK_NO,
		f.BELONGING_CORP,
		f.WORK_PLACE,
		f.WORK_LONGITUDE,
		f.WORK_LATITUDE,
		f.WORK_CONTENT,
		f.WORK_START_DATE,
		f.WORK_END_DATE,
		f.WORK_HEIGHT,
		f.GUARDIAN_DEPARTMENT_ID,
		f.GUARDIAN_USER_ID,
		f.APPLY_STATUS,
		f.CONSTRUCTION_DEPARTMENT_ID,
		f.CONSTRUCTION_USER_ID,
		f.CONSTRUCTION_USER_SIGNER_PATH,
		f.CONSTRUCTION_USER_SIGNER_TIME,
		f.AUDIT_DEPARTMENT_ID,
		f.AUDIT_USER_ID,
		f.AUDIT_USER_SIGNER_PATH,
		f.AUDIT_USER_SIGNER_TIME,
		f.APPROVE_DEPARTMENT_ID,
		f.APPROVE_USER_ID,
		f.APPROVE_USER_SIGNER_PATH,
		f.APPROVE_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.CONSTRUCTION_CONTENT,
		f.AUDIT_CONTENT,
		f.APPROVE_CONTENT,
		f.ACCEPT_CONTENT,
		f.OTHER_PROTECTIVE_MEASURES,
		f.HAZARD_IDENTIFICATION,
		f.WORK_CORP,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER,
		f.ISDELETE,
		f.CREATOR,
		f.CREATTIME,
		f.OPERATOR,
		f.OPERATTIME,
		f.CORPINFO_ID,
		f.HIGHWORK_ID,
		c.NAME as BELONGING_CORP_NAME,

		gd.NAME as GUARDIAN_DEPARTMENT_NAME,
		gu.NAME as GUARDIAN_USER_NAME,

		IFNULL(GROUP_CONCAT(REPLACE(su.SPECIALUSER_ID,'/',',')),'') as WORK_OPERATOR_ID,
		IFNULL(GROUP_CONCAT(REPLACE(su.USERNAME,'/',',')),'') as WORK_OPERATOR_NAME,
		IFNULL(GROUP_CONCAT(REPLACE(su.SPECIAL_NUMBER,'/',',')),'') as WORK_OPERATOR_NUMBER,

		cd.NAME as CONSTRUCTION_DEPARTMENT_NAME,
		cu.NAME as CONSTRUCTION_USER_NAME,

		aud.NAME as AUDIT_DEPARTMENT_NAME,
		auu.NAME as AUDIT_USER_NAME,

		apd.NAME as APPROVE_DEPARTMENT_NAME,
		apu.NAME as APPROVE_USER_NAME,

		acd.NAME as ACCEPT_DEPARTMENT_NAME,
		acu.NAME as ACCEPT_USER_NAME
		from
		bus_highwork f
		left join OA_DEPARTMENT c on c.DEPARTMENT_ID = f.BELONGING_CORP

		left join OA_DEPARTMENT gd on gd.DEPARTMENT_ID = f.GUARDIAN_DEPARTMENT_ID
		left join SYS_USER gu on gu.USER_ID = f.GUARDIAN_USER_ID

		left join BUS_HIGHWORK_OPERATOR ho on ho.HIGHWORK_ID = f.HIGHWORK_ID and ho.ISDELETE = '0'
		left join BUS_SPECIALUSER su on su.SPECIALUSER_ID = ho.SPECIALUSER

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONSTRUCTION_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONSTRUCTION_USER_ID

		left join OA_DEPARTMENT aud on aud.DEPARTMENT_ID = f.AUDIT_DEPARTMENT_ID
		left join SYS_USER auu on auu.USER_ID = f.AUDIT_USER_ID

		left join OA_DEPARTMENT apd on apd.DEPARTMENT_ID = f.APPROVE_DEPARTMENT_ID
		left join SYS_USER apu on apu.USER_ID = f.APPROVE_USER_ID

		left join OA_DEPARTMENT acd on acd.DEPARTMENT_ID = f.ACCEPT_DEPARTMENT_ID
		left join SYS_USER acu on acu.USER_ID = f.ACCEPT_USER_ID
		where
		f.HIGHWORK_ID = #{HIGHWORK_ID}
	</select>

	<!-- 高处作业措施查询 -->
	<select id="listAllMeasuresHIGHWORK" parameterType="pd" resultType="pd">
		select
		f.*
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			,eo.STATUS
		</if>
		from
		BUS_HIGHWORK_MEASURES f
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			left join BUS_HIGHWORKTOMEASURES eo on eo.HIGHWORK_MEASURES_ID = f.HIGHWORK_MEASURES_ID
		</if>
		where f.ISDELETE = '0'
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			and eo.HIGHWORK_ID = #{HIGHWORK_ID}
		</if>
		ORDER BY f.SORT ASC
	</select>

	<!--有限空间作业-->
	<select id="findByIdCONFINEDSPACE" parameterType="pd" resultType="pd">
	select
		f.CONFINEDSPACE_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.CREATTIME,
		f.CREATOR,
		f.OPERATTIME,
		f.OPERATOR,
		f.WORK_PERMIT_NUMBER,
		f.WORK_START_DATE,
		f.WORK_END_DATE,
		f.CONFIRM_DEPARTMENT_ID,
		f.CONFIRM_USER_ID,
		f.CONFIRM_USER_SIGNER_PATH,
		f.CONFIRM_USER_SIGNER_TIME,
		f.COMPLETION_ACCEPTANCE_MANAGEMENT_DEPARTMENT_ID,
		f.COMPLETION_ACCEPTANCE_MANAGEMENT_ID,
		f.EMERGENCY_EQUIPMENT_NUMBER,
		f.EMERGENCY_EQUIPMENT,
		f.COMPLETION_ACCEPTANCE_MANAGEMENT_TIME,
		f.COMPLETION_ACCEPTANCE_TIME,
		f.MANAGEMENT_UNIT_TIME,
		f.JOB_SITE_MANAGER_TIME,
		f.APPLY_STATUS,
		f.COMPLETION_ACCEPTANCE_MANAGEMENT_OPINION_IMG,
		f.WORK_UNIT_MANAGER_TIME,
		f.COMPLETION_ACCEPTANCE_MANAGEMENT_OPINION,
		f.COMPLETION_ACCEPTANCE_IMG,
		f.COMPLETION_ACCEPTANCE_OPINION,
		f.MANAGEMENT_UNIT_IMG,
		f.MANAGEMENT_UNIT_OPINION,
		f.JOB_SITE_MANAGER_IMG,
		f.JOB_SITE_MANAGER_OPINION,
		f.WORK_UNIT_MANAGER_OPINION,
		f.WORK_UNIT_MANAGER_IMG,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER_ID,
		f.RESTRICTED_SPACE_ID ,
		f.SAFTETY,
		f.HARM,
		f.MAIN_MEDIUM,
		f.SAMPLING_ANALYST_DEPARTMENT_ID,
		f.SAMPLING_ANALYST_ID,
		f.GUARDIAN,
		f.GUARDIAN_DEPARTMENT_ID,
		f.GUARDIAN_USER_ID,
		f.GUARDIAN_USER_SIGNER_PATH,
		f.GUARDIAN_USER_SIGNER_TIME,
		f.GUARDIAN_CONTENT,
		f.MAJOR_RISK_FACTORS ,
		f.WORKER ,
		f.CONTENTS_OF_HOMEWORK,
		f.WORK_LONGITUDE,
		f.WORK_LATITUDE,
		f.WORK_UNIT_ID,
		f.WORK_UNIT_MANAGER_ID,
		f.WORK_UNIT_MANAGER_DEPARTMENT_ID,
		f.WORK_LOCATION,
		f.COMPLETION_ACCEPTANCE_ID,
		f.COMPLETION_ACCEPTANCE_DEPARTMENT_ID ,
		f.JOB_SITE_MANAGER_ID ,
		f.JOB_SITE_MANAGER_DEPARTMENT_ID,
		f.WORKING_TIME,
		f.MANAGEMENT_UNIT_DEPARTMENT_ID,
		f.MANAGEMENT_UNIT_ID,
		a.NAME as APPLY_DEPARTMENT_NAME,
		b.NAME as WORK_UNIT_NAME,
		c.NAME as RESTRICTED_SPACE_NAME,
		c.NUMBER as RESTRICTED_SPACE_NUMBER,
		d.NAME as SAMPLING_ANALYST_DEPARTMENT_NAME,
		e.NAME as SAMPLING_ANALYST_NAME,
		g.NAME as WORK_UNIT_MANAGER_DEPARTMENT_NAME,
		h.NAME as WORK_UNIT_MANAGER_NAME,
		i.NAME as JOB_SITE_MANAGER_DEPARTMENT_NAME,
		j.NAME as JOB_SITE_MANAGER_NAME,
		k.NAME as MANAGEMENT_UNIT_DEPARTMENT_NAME,
		l.NAME as MANAGEMENT_UNIT_NAME,
		m.NAME as COMPLETION_ACCEPTANCE_DEPARTMENT_NAME,
		n.NAME as COMPLETION_ACCEPTANCE_NAME,
		p.NAME as COMPLETION_ACCEPTANCE_MANAGEMENT_DEPARTMENT_NAME,
		q.NAME as COMPLETION_ACCEPTANCE_MANAGEMENT_NAME
		from
		bus_confinedspace f
		left join OA_DEPARTMENT a on a.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID
		left join OA_DEPARTMENT b on b.DEPARTMENT_ID = f.WORK_UNIT_ID
		left join BUS_LIMITSPACE c on c.LIMITSPACE_ID=f.RESTRICTED_SPACE_ID
		left join OA_DEPARTMENT d on d.DEPARTMENT_ID = f.SAMPLING_ANALYST_DEPARTMENT_ID
		left join SYS_USER e on e.USER_ID = f.SAMPLING_ANALYST_ID
		left join OA_DEPARTMENT g on g.DEPARTMENT_ID = f.WORK_UNIT_MANAGER_DEPARTMENT_ID
		left join SYS_USER h on h.USER_ID = f.WORK_UNIT_MANAGER_ID
		left join OA_DEPARTMENT i on i.DEPARTMENT_ID = f.JOB_SITE_MANAGER_DEPARTMENT_ID
		left join SYS_USER j on j.USER_ID = f.JOB_SITE_MANAGER_ID
		left join OA_DEPARTMENT k on k.DEPARTMENT_ID = f.MANAGEMENT_UNIT_DEPARTMENT_ID
		left join SYS_USER l on l.USER_ID = f.MANAGEMENT_UNIT_ID
		left join OA_DEPARTMENT m on m.DEPARTMENT_ID = f.COMPLETION_ACCEPTANCE_DEPARTMENT_ID
		left join SYS_USER n on n.USER_ID = f.COMPLETION_ACCEPTANCE_ID
		left join OA_DEPARTMENT p on p.DEPARTMENT_ID = f.COMPLETION_ACCEPTANCE_MANAGEMENT_DEPARTMENT_ID
		left join SYS_USER q on  q.USER_ID = f.COMPLETION_ACCEPTANCE_MANAGEMENT_ID
		where
		f.CONFINEDSPACE_ID = #{CONFINEDSPACE_ID}
	</select>


	<!-- 有限空间作业措施查询 -->
	<select id="listAllMeasuresCONFINEDSPACE" parameterType="pd" resultType="pd">
		select
		f.*
		<if test="APPLY_STATUS != '2' and APPLY_STATUS != 2">
			,eo.STATUS,eo.ANSWER1,eo.ANSWER2,eo.ANSWER3,eo.STATUS
		</if>
		from
		BUS_CONFINEDSPACE_MEASURES f
		<if test="APPLY_STATUS != '2' and APPLY_STATUS != 2">
			left join BUS_CONFINEDSPACETOMEASURES eo on eo.BUS_CONFINEDSPACE_MEASURES_ID = f.BUS_CONFINEDSPACE_MEASURES_ID
		</if>
		where f.ISDELETE = '0'
		<if test="APPLY_STATUS != '2' and APPLY_STATUS != 2">
			and eo.CONFINEDSPACE_ID = #{CONFINEDSPACE_ID}
		</if>
	</select>

	<!--有限空间作业-->
	<select id="listAllCONFINEDSPACE" parameterType="pd" resultType="pd">
		select
		f.CONFINEDSPACE_ID,
		f.ANALYZE_TIME,
		f.ANALYZE_PLACE,
		f.ANALYZE_USER,
		f.HARMFUL_MATERIALS,
		f.COMBUSTIBLE_GAS,
		f.OXYGEN_CONTENT,
		f.ISDELETE,
		f.CONFINEDSPACEGAS_ID
		from
		BUS_CONFINEDSPACEGAS f
		where f.ISDELETE = '0' and f.CONFINEDSPACE_ID = #{CONFINEDSPACE_ID}
	</select>


	<!--吊装作业-->
	<select id="findByIdHOISTING" parameterType="pd" resultType="pd">
		select
				f.APPLY_STATUS,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.CREATOR,
		f.CREATTIME,
		f.OPERATOR,
		f.OPERATTIME,
		f.NUMBERING,
		f.HOISTING_LOCATION,
		f.WORK_LONGITUDE,
		f.WORK_LATITUDE,
		f.HOISTING_EQUIPMENT,
		f.LIFTING_OPERATION_MANAGER_DEPARTMENT_ID,
		f.LIFTING_OPERATION_MANAGER_ID,
		f.SAFETY_GUARDIAN_DEPARTMENT_ID,
		f.SAFETY_GUARDIAN_ID,
		f.JOB_START_TIME,
		f.JOB_END_TIME,
		f.COMMANDER_ID,
		f.HOISTING_WORK_CONTENT,
		f.LIFTING_WEIGHT,
		f.CONSTRUCTION_JOB_MANAGER_DEPARTMENT_ID,
		f.CONSTRUCTION_JOB_MANAGER_ID,
		f.CONSTRUCTION_JOB_MANAGER_OPINION,
		f.CONSTRUCTION_JOB_MANAGER_SIGNER_PATH,
		f.CONSTRUCTION_JOB_MANAGER_SIGNER_TIME,
		f.WORK_UNIT_MANAGER_DEPARTMENT_ID,
		f.WORK_UNIT_MANAGER_ID,
		f.WORK_UNIT_MANAGER_OPINION,
		f.WORK_UNIT_MANAGER_SIGNER_PATH,
		f.WORK_UNIT_MANAGER_SIGNER_TIME,
		f.BRANCH_APPROVER_DEPARTMENT_ID,
		f.BRANCH_APPROVER_ID,
		f.BRANCH_APPROVER_OPINION,
		f.BRANCH_APPROVER_SIGNER_PATH,
		f.BRANCH_APPROVER_SIGNER_TIME,
		f.ACCEPTANCE_DEPARTMENT_ID,
		f.ACCEPTOR_ID,
		f.ACCEPTOR_OPINION,
		f.ACCEPTOR_SIGNER_PATH,
		f.ACCEPTOR_SIGNER_TIME,
		f.OTHER_PROTECTIVE_MEASURES,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER_ID,
		f.HOISTING_ID,
		ad.NAME as APPLY_DEPARTMENT_NAME,
		au.NAME as APPLY_USER_NAME,

		ld.NAME as LIFTING_OPERATION_MANAGER_DEPARTMENT_NAME,
		lu.NAME as LIFTING_OPERATION_MANAGER_NAME,

		sgd.NAME as SAFETY_GUARDIAN_DEPARTMENT_NAME,
		sgu.NAME as SAFETY_GUARDIAN_NAME,

		IFNULL(GROUP_CONCAT(REPLACE(su.SPECIALUSER_ID,'/',',')),'') as CRANE_DRIVER_ID,
		IFNULL(GROUP_CONCAT(REPLACE(su.USERNAME,'/',',')),'') as CRANE_DRIVER_NAME,
		IFNULL(GROUP_CONCAT(REPLACE(su.SPECIAL_NUMBER,'/',',')),'') as CRANE_DRIVER_NUMBER,

		sc.USERNAME as COMMANDER_NAME,
		sc.SPECIAL_NUMBER as COMMANDER_NUMBER,

		cd.NAME as CONSTRUCTION_JOB_MANAGER_DEPARTMENT_NAME,
		cu.NAME as CONSTRUCTION_JOB_MANAGER_NAME,

		aud.NAME as WORK_UNIT_MANAGER_DEPARTMENT_NAME,
		auu.NAME as WORK_UNIT_MANAGER_NAME,

		apd.NAME as BRANCH_APPROVER_DEPARTMENT_NAME,
		apu.NAME as BRANCH_APPROVER_NAME,

		acpd.NAME as ACCEPTANCE_DEPARTMENT_NAME,
		acpu.NAME as ACCEPTOR_NAME
		from
		bus_hoisting f
		left join OA_DEPARTMENT ad on ad.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID
		left join SYS_USER au on au.USER_ID = f.APPLY_USER_ID

		left join OA_DEPARTMENT ld on ld.DEPARTMENT_ID = f.LIFTING_OPERATION_MANAGER_DEPARTMENT_ID
		left join SYS_USER lu on lu.USER_ID = f.LIFTING_OPERATION_MANAGER_ID

		left join OA_DEPARTMENT sgd on sgd.DEPARTMENT_ID = f.SAFETY_GUARDIAN_DEPARTMENT_ID
		left join SYS_USER sgu on sgu.USER_ID = f.SAFETY_GUARDIAN_ID

		left join BUS_HOISTING_OPERATOR ho on ho.HOISTING_ID = f.HOISTING_ID and ho.ISDELETE = '0'
		left join BUS_SPECIALUSER su on su.SPECIALUSER_ID = ho.SPECIALUSER

		left join BUS_SPECIALUSER sc on sc.SPECIALUSER_ID = f.COMMANDER_ID

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONSTRUCTION_JOB_MANAGER_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONSTRUCTION_JOB_MANAGER_ID

		left join OA_DEPARTMENT aud on aud.DEPARTMENT_ID = f.WORK_UNIT_MANAGER_DEPARTMENT_ID
		left join SYS_USER auu on auu.USER_ID = f.WORK_UNIT_MANAGER_ID

		left join OA_DEPARTMENT apd on apd.DEPARTMENT_ID = f.BRANCH_APPROVER_DEPARTMENT_ID
		left join SYS_USER apu on apu.USER_ID = f.BRANCH_APPROVER_ID

		left join OA_DEPARTMENT acpd on acpd.DEPARTMENT_ID = f.ACCEPTANCE_DEPARTMENT_ID
		left join SYS_USER acpu on acpu.USER_ID = f.ACCEPTOR_ID
		where
		f.HOISTING_ID = #{HOISTING_ID}
	</select>


	<!-- 吊装作业措施查询 -->
	<select id="listAllMeasuresHOISTING" parameterType="pd" resultType="pd">
		select
		f.*
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			,eo.STATUS
		</if>
		from
		BUS_HOISTING_MEASURES f
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			left join BUS_HOISTINGTOMEASURES eo on eo.HOISTING_MEASURES_ID = f.HOISTING_MEASURES_ID
		</if>
		where f.ISDELETE = '0'
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			and eo.HOISTING_ID = #{HOISTING_ID}
		</if>
		GROUP BY f.HOISTING_MEASURES_ID
		ORDER BY f.SORT ASC
	</select>



	<select id="getEchartsOrder" resultType="map">
		SELECT
		t.click_date clickDate,
		IFNULL(h.dhzyCount,0) dhzyCount,
		IFNULL(h.dbzyCount,0) dbzyCount,
		IFNULL(h.yxgjzyCount,0) yxgjzyCount,
		IFNULL(h.gczyCount,0) gczyCount,
		IFNULL(h.dzzyCount,0) dzzyCount,
		IFNULL(h.lsydCount, 0) lsydCount,
		IFNULL(h.dtzyCount,0) dtzyCount,
		IFNULL(h.dlzyCount, 0) dlzyCount
		FROM
		(
		SELECT
		a.click_date
		FROM
		(
		SELECT
		CURDATE() AS click_date UNION ALL
		SELECT
		date_sub( CURDATE(), INTERVAL 1 DAY ) AS click_date UNION ALL
		SELECT
		date_sub( CURDATE(), INTERVAL 2 DAY ) AS click_date UNION ALL
		SELECT
		date_sub( CURDATE(), INTERVAL 3 DAY ) AS click_date UNION ALL
		SELECT
		date_sub( CURDATE(), INTERVAL 4 DAY ) AS click_date
		) a
		) t
		LEFT JOIN (
		SELECT
		s.CREATTIME,
		SUM( s.hotworkapplicationCount ) dhzyCount,
		sum( s.blindboardCount ) dbzyCount,
		SUM( s.confinedspaceCount ) yxgjzyCount,
		SUM( s.highworkCount ) gczyCount,
		SUM( s.hoistingCount ) dzzyCount,
		SUM( s.electricityCount ) lsydCount,
		SUM( s.breakgroundCount ) dtzyCount,
		SUM( s.cutroadCount ) dlzyCount
		FROM
		(
		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		count( 1 ) hotworkapplicationCount,
		'0' blindboardCount,
		'0' confinedspaceCount,
		'0' highworkCount,
		'0' hoistingCount,
		'0' electricityCount,
		'0' breakgroundCount,
		'0' cutroadCount
		FROM
		bus_hotworkapplication
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and STATE != 0
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL
		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' AS hotworkapplicationCount,
		count( 1 ) blindboardCount,
		'0' confinedspaceCount,
		'0' highworkCount,
		'0' hoistingCount,
		'0' electricityCount,
		'0' breakgroundCount,
		'0' cutroadCount
		FROM
		bus_blindboard
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL


		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' cutroadCount,
		'0' blindboardCount,
		count( 1 ) confinedspaceCount,
		'0' highworkCount,
		'0' hoistingCount,
		'0' electricityCount,
		'0' breakgroundCount,
		'0' cutroadCount
		FROM
		bus_confinedspace
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL


		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' hotworkapplicationCount,
		'0' blindboardCount,
		'0' confinedspaceCount,
		count( 1 ) highworkCount,
		'0' hoistingCount,
		'0' electricityCount,
		'0' breakgroundCount,
		'0' cutroadCount
		FROM
		bus_highwork
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL


		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' hotworkapplicationCount,
		'0' blindboardCount,
		'0' confinedspaceCount,
		'0' highworkCount,
		count( 1 ) hoistingCount,
		'0' electricityCount,
		'0' breakgroundCount,
		'0' cutroadCount
		FROM
		bus_hoisting
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL


		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' hotworkapplicationCount,
		'0' blindboardCount,
		'0' confinedspaceCount,
		'0' highworkCount,
		'0' hoistingCount,
		count( 1 ) electricityCount,
		'0' breakgroundCount,
		'0' cutroadCount
		FROM
		bus_electricity
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' )UNION ALL


		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' hotworkapplicationCount,
		'0' blindboardCount,
		'0' confinedspaceCount,
		'0' highworkCount,
		'0' hoistingCount,
		'0' electricityCount,
		count(1) breakgroundCount,
		'0' cutroadCount
		FROM
		bus_breakground
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) UNION ALL


		SELECT
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' ) CREATTIME,
		'0' hotworkapplicationCount,
		'0' blindboardCount,
		'0' confinedspaceCount,
		'0' highworkCount,
		'0' hoistingCount,
		'0' electricityCount,
		'0' breakgroundCount,
		count(1) cutroadCount
		FROM
		bus_cutroad
		WHERE
		DATE_SUB( CURDATE(), INTERVAL 4 DAY )&lt;= STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		and ISDELETE = '0'
		and APPLY_STATUS != '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="array!= null and array.size>0">
			AND CORPINFO_ID IN
			<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		GROUP BY
		STR_TO_DATE( CREATTIME, '%Y-%m-%d' )
		) s
		GROUP BY
		s.CREATTIME
		) h ON h.CREATTIME = t.click_date
		order by t.click_date
	</select>


	<!--  申请数[COUNTAPPLY]，审批中[COUNTAPPROVE]，归档[COUNTARCHIVE]	-->
	<select id="statisticsHighRiskWorkByStateOrder"  parameterType="pd" resultType="pd">
		SELECT
		SUM(f.COUNTAPPLY) COUNTAPPLY,SUM(f.COUNTAPPROVE) COUNTAPPROVE,SUM(f.COUNTARCHIVE) COUNTARCHIVE
		FROM (
		SELECT
		COUNT( CASE WHEN f.STATE > 0 THEN f.HOTWORKAPPLICATION_ID END ) COUNTAPPLY,
		COUNT( CASE WHEN f.STATE >0 and  f.STATE != 11 THEN f.HOTWORKAPPLICATION_ID END ) COUNTAPPROVE,
		COUNT( CASE WHEN f.STATE = 11 THEN f.HOTWORKAPPLICATION_ID END ) COUNTARCHIVE
		FROM bus_hotworkapplication f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.ELECTRICITY_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in  ('0','5')  then f.ELECTRICITY_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '5' then f.ELECTRICITY_ID end) COUNTARCHIVE
		FROM bus_electricity f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.BLINDBOARD_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6') then f.BLINDBOARD_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.BLINDBOARD_ID end) COUNTARCHIVE
		FROM bus_blindboard f
		WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.HIGHWORK_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6') then f.HIGHWORK_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.HIGHWORK_ID end) COUNTARCHIVE
		FROM bus_highwork f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.CONFINEDSPACE_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6')  then f.CONFINEDSPACE_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.CONFINEDSPACE_ID end) COUNTARCHIVE
		FROM bus_confinedspace f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.HOISTING_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6') then f.HOISTING_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.HOISTING_ID end) COUNTARCHIVE
		FROM bus_hoisting f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.BREAKGROUND_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6')  then f.BREAKGROUND_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.BREAKGROUND_ID end) COUNTARCHIVE
		FROM bus_breakground f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		UNION ALL
		SELECT
		COUNT(case when f.APPLY_STATUS != '0' then f.CUTROAD_ID end) COUNTAPPLY,
		COUNT(case when f.APPLY_STATUS not in ('0','6')  then f.CUTROAD_ID end) COUNTAPPROVE,
		COUNT(case when f.APPLY_STATUS = '6' then f.CUTROAD_ID end) COUNTARCHIVE
		FROM bus_cutroad f WHERE f.ISDELETE = '0'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
		) f
	</select>


	<select id="realTimeHighRiskWorklistPageOrder" parameterType="page" resultType="pd">
		SELECT * FROM
			(SELECT
				f.HOTWORKAPPLICATION_ID ID,
				f.JOB_NUMBER WORK_NUMBER,
				'动火作业' WORK_TYPE,
				case f.STATE
				 when 1 then '动火单位负责人确认'
				 when 2 then '项目发包单位签发'
				 when 3 then '现场管辖单位负责人'
				 when 4 then '动火许可签发单位'
				 when 5 then '安全总监审批'
				 when 6 then '现场负责人'
				 when 7 then '动火前'
				 when 8 then '现场负责人确认'
				 when 9 then '动火后'
				 when 10 then '延时监火'
				 when 11 then '归档'
				 when 21 then '动火操作人'
				 when 22 then '监护人'
				 when 24 then '气体检测人'
				 when -1 then '审核不通过'
				 when -2 then '特级动火不通过'
				 when -3 then '未完成 关闭归档'
				 when -4 then '延期'
				 when -5 then '已打回'
				 when -6 then '超期'
				 when 30 then '动火负责人确认'
				 when 31 then '项目主管初审'
				 when 32 then '项目监管部门负责人'
				 when 33 then '分公司安全总监审批'
				 when 34 then '分公司主要负责人'
				 when 35 then '安全监督部初审'
				 when 36 then '安委会办公室'
				 when 37 then '安全总监审批'
				END STATUS_NAME,
			    IF(f.STATE = 10,IFNULL(od.`NAME`,IFNULL(GROUP_CONCAT(REPLACE(u.NAME,'/',',')),IFNULL(qu.`NAME`,''))),IFNULL(GROUP_CONCAT(REPLACE(u.NAME,'/',',')),IFNULL(qu.`NAME`,''))) USER_NAME,
 				<!--IFNULL(GROUP_CONCAT(REPLACE(u.NAME,'/',',')),IFNULL(qu.`NAME`,'')) USER_NAME,-->
				DATE_FORMAT(ifnull(f.OPERATTIME,f.CREATTIME),'%Y-%m-%d %H:%i:%s') OPERATTIME
			 FROM bus_hotworkapplication f
				LEFT JOIN bus_hotworkapplicationuser hu ON hu.FOREIGN_KEY = f.HOTWORKAPPLICATION_ID AND hu.STATE = f.STATE
				LEFT JOIN sys_user u ON u.USER_ID = hu.USER_ID
			    LEFT JOIN oa_department od ON od.DEPARTMENT_ID = hu.USER_ID
				LEFT JOIN `qa-gwj-regulatory`.sys_user qu on qu.USER_ID = hu.USER_ID
			 WHERE f.ISDELETE = '0' AND f.STATE >= 0 and f.STATE != 11
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

			 GROUP BY f.HOTWORKAPPLICATION_ID
			UNION ALL
			SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
				FROM
				(SELECT
					f.electricity_ID ID,
					f.CHECK_NO WORK_NUMBER,
					'临时用电作业' WORK_TYPE,
					case f.APPLY_STATUS
						when '0' then '待提交'
						when '1' then '作业负责人待审核'
					   	when '2' then '用电单位待审核'
							when '3' then '配送电单位待审核'
							when '4' then '待验收'
					   	when '-2' then '已打回'
							when '-3' then '已打回'
							when '-4' then '已打回'
							when '-5' then '已打回'
					END STATUS_NAME,
					case f.APPLY_STATUS
					   	when '0' then f.APPLY_USER_ID
					   	when '1' then f.CONFIRM_USER_ID
					   	when '2' then f.AUDIT_USER_ID
					   	when '3' then f.APPROVE_USER_ID
							when '4' then f.ACCEPT_USER_ID
					   	when '-1' then f.APPLY_USER_ID
							when '-2' then f.APPLY_USER_ID
							when '-3' then f.APPLY_USER_ID
							when '-4' then f.APPLY_USER_ID
							when '-5' then f.APPLY_USER_ID
					END NEXT_USER_ID,
		            ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
					 FROM bus_electricity f WHERE f.ISDELETE = '0' AND f.APPLY_STATUS != '5'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

				) f
				LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
			UNION ALL
			SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
				FROM
				(SELECT
					f.blindboard_ID ID,
					f.CHECK_NO WORK_NUMBER,
					'盲板作业' WORK_TYPE,
					case f.APPLY_STATUS
					 when '0' then '待提交'
					 when '1' then '作业负责人待审核'
					 when '4' then '所在单位待审核'
					 when '5' then '待验收'
					 when '-2' then '已打回'
					 when '-5' then '已打回'
					 when '-6' then '已打回'
					END STATUS_NAME,
					case f.APPLY_STATUS
					 when '0' then f.APPLY_USER_ID
					 when '1' then f.CONSTRUCTION_USER_ID
					 when '4' then f.LEADER_USER_ID
					 when '5' then f.ACCEPT_USER_ID
					 when '-2' then APPLY_USER_ID
					 when '-5' then APPLY_USER_ID
					 when '-6' then APPLY_USER_ID
					END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
					 FROM bus_blindboard f
					 WHERE f.ISDELETE = '0' AND f.APPLY_STATUS != '6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

				) f
				LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
			UNION ALL
			SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
				FROM
				(SELECT
					f.HIGHWORK_ID ID,
					f.CHECK_NO WORK_NUMBER,
					'高处作业' WORK_TYPE,
					case f.APPLY_STATUS
					 when '0' then '待提交'
					 when '1' then '作业负责人待审核'
					 when '2' then '所在单位待审核'
					 when '3' then '审核部门待审核'
					 when '4' then '审批部门待审核'
					 when '5' then '待验收'
					 when '-2' then '已打回'
					 when '-3' then '已打回'
					 when '-4' then '已打回'
					 when '-5' then '已打回'
					 when '-6' then '已打回'
					END STATUS_NAME,
					case f.APPLY_STATUS
					 when '0' then f.CREATOR
					 when '1' then f.CONSTRUCTION_USER_ID
					 when '2' then f.LEADER_USER_ID
					 when '3' then f.AUDIT_USER_ID
					 when '4' then f.APPROVE_USER_ID
					 when '5' then f.ACCEPT_USER_ID
					 when '-2' then f.CREATOR
					 when '-3' then f.CREATOR
					 when '-4' then f.CREATOR
					 when '-5' then f.CREATOR
					 when '-6' then f.CREATOR
					END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
					 FROM bus_highwork f WHERE f.ISDELETE = '0' AND f.APPLY_STATUS !='6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

				) f
				LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
			UNION ALL
		SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
		FROM
		(SELECT
		f.confinedspace_ID ID,
		f.CHECK_NO WORK_NUMBER,
		'有限空间作业' WORK_TYPE,
		case f.APPLY_STATUS
		when '1' then '作业负责人待审核'
		when '4' then '所在单位待审核'
		when '5' then '待验收'
		when '-4' then '作业负责人审核打回'
		when '-5' then '所在单位审核打回'
		when '-6' then '验收打回'
		END STATUS_NAME,
		case f.APPLY_STATUS
		when '1' then f.CONFIRM_USER_ID
		when '4' then f.APPROVE_USER_ID
		when '5' then f.ACCEPT_USER_ID
		when '-4' then f.CREATOR
		when '-5' then f.CREATOR
		when '-6' then f.CREATOR
		END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
		FROM bus_confinedspace f WHERE f.ISDELETE = '0' AND f.APPLY_STATUS != '6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>
		) f
		LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
			UNION ALL
			SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
				FROM
				(SELECT
					f.hoisting_ID ID,
					f.CHECK_NO WORK_NUMBER,
					'吊装作业' WORK_TYPE,
					case f.APPLY_STATUS
					 when '0' then '待提交'
					 when '1' then '作业指挥待审核'
					 when '2' then '所在单位待审核'
					 when '3' then '审核部门待审核'
					 when '4' then '审批部门待审核'
					 when '5' then '待验收'
					 when '-2' then '已打回'
					 when '-3' then '已打回'
					 when '-4' then '已打回'
					 when '-5' then '已打回'
					 when '-6' then '已打回'
					END STATUS_NAME,
					case f.APPLY_STATUS
					 when '0' then f.CREATOR
					 when '1' then f.LEADER_USER_ID
					 when '2' then f.CONSTRUCTION_USER_ID
					 when '3' then f.AUDIT_USER_ID
					 when '4' then f.APPROVE_USER_ID
					 when '5' then f.ACCEPT_USER_ID
					 when '-2' then f.CREATOR
					 when '-3' then f.CREATOR
					 when '-4' then f.CREATOR
					 when '-5' then f.CREATOR
					 when '-6' then f.CREATOR
					END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
					 FROM bus_hoisting f
					  WHERE f.ISDELETE = '0'  AND f.APPLY_STATUS !='6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

				) f
				LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID

			UNION ALL
			SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
				FROM
				(SELECT
					f.BREAKGROUND_ID ID,
					f.CHECK_NO WORK_NUMBER,
					'动土作业' WORK_TYPE,
					case f.APPLY_STATUS
					 when '0' then '待提交'
					 when '1' then '作业负责人待审核'
					 when '2' then '所在单位待审核'
					 when '3' then '有关部门待审核'
					 when '4' then '审批部门待审核'
					 when '5' then '待验收'
					 when '-2' then '已打回'
					 when '-3' then '已打回'
					 when '-4' then '已打回'
					 when '-5' then '已打回'
					 when '-6' then '已打回'
					END STATUS_NAME,
					case f.APPLY_STATUS
					 when '0' then f.CREATOR
					 when '1' then f.CONSTRUCTION_USER_ID
					 when '2' then f.PRODUCTION_USER_ID
					 when '3' then f.SAFETY_USER_ID
					 when '4' then f.LEADER_USER_ID
					 when '5' then f.ACCEPT_USER_ID
					 when '-2' then f.CREATOR
					 when '-3' then f.CREATOR
					 when '-4' then f.CREATOR
					 when '-5' then f.CREATOR
					 when '-6' then f.CREATOR
					END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
					 FROM bus_breakground f
					  WHERE f.ISDELETE = '0'  AND f.APPLY_STATUS !='6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

				) f
				LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID

			UNION ALL
			SELECT f.ID, f.WORK_NUMBER, f.WORK_TYPE, f.STATUS_NAME, u.NAME USER_NAME, f.OPERATTIME
				FROM
				(SELECT
					f.CUTROAD_ID ID,
					f.CHECK_NO WORK_NUMBER,
					'断路作业' WORK_TYPE,
					case f.APPLY_STATUS
					 when '0' then '待提交'
					 when '1' then '作业负责人待审核'
					 when '2' then '所在单位待审核'
					 when '3' then '消防、安全管理部门待审核'
					 when '4' then '审批部门待审核'
					 when '5' then '待验收'
					 when '-2' then '已打回'
					 when '-3' then '已打回'
					 when '-4' then '已打回'
					 when '-5' then '已打回'
					 when '-6' then '已打回'
					END STATUS_NAME,
					case f.APPLY_STATUS
					 when '0' then f.CREATOR
					 when '1' then f.CONSTRUCTION_USER_ID
					 when '2' then f.PRODUCTION_USER_ID
					 when '3' then f.SAFETY_USER_ID
					 when '4' then f.LEADER_USER_ID
					 when '5' then f.ACCEPT_USER_ID
					 when '-2' then f.CREATOR
					 when '-3' then f.CREATOR
					 when '-4' then f.CREATOR
					 when '-5' then f.CREATOR
					 when '-6' then f.CREATOR
					END NEXT_USER_ID,
		ifnull(f.OPERATTIME,f.CREATTIME) OPERATTIME
					 FROM bus_cutroad f
					  WHERE f.ISDELETE = '0'  AND f.APPLY_STATUS !='6'
		<if test="pd.CORPINFO_ID!= null and pd.CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.ids!= null and pd.ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="pd.ids" open="(" separator="," close=")">
				#{pd.ids[${index}]}
			</foreach>
		</if>

				) f
				LEFT JOIN sys_user u ON u.USER_ID = f.NEXT_USER_ID
			) f
		ORDER BY f.OPERATTIME DESC
	</select>

	<!--临时用电-->
	<select id="getELECTRICITYHighRiskWorkLocationOrder" parameterType="pd" resultType="pd">
		SELECT
		'ELECTRICITY' TYPE,
		f.ELECTRICITY_ID id,
		CONCAT_WS("", '临时用电作业 编号：', f.CHECK_NO) NAME,
		f.WORK_LONGITUDE LONGITUDE,
		f.WORK_LATITUDE LATITUDE,
		'./bi/images/map/electricity.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO as MAP_POINT_NAME
		FROM bus_electricity f WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
		AND f.APPLY_STATUS != '5'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

    <!--盲板作业-->
	<select id="getBLINDBOARDHighRiskWorkLocationOrder" parameterType="pd" resultType="pd">
				SELECT
		'BLINDBOARD' TYPE,
		f.BLINDBOARD_ID id,
		CONCAT_WS("", '盲板作业 编号：', f.CHECK_NO) NAME,
		f.WORK_LONGITUDE LONGITUDE,
		f.WORK_LATITUDE LATITUDE,
		'./bi/images/map/blindboard.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO as MAP_POINT_NAME
	FROM bus_blindboard f
	WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
		AND f.APPLY_STATUS != '6'
		AND date_format(now(),'%Y-%m-%d %H:%i') >= f.CREATTIME AND (f.ACCEPT_USER_SIGNER_TIME >= date_format(now(),'%Y-%m-%d %H:%i') OR f.ACCEPT_USER_SIGNER_TIME IS NULL)
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--高处作业-->
	<select id="getHIGHWORKHighRiskWorkLocationOrder" parameterType="pd" resultType="pd">
		SELECT
		'HIGHWORK' TYPE,
		f.HIGHWORK_ID id,
		CONCAT_WS("", '高处作业 编号：', f.CHECK_NO) NAME,
		f.WORK_LONGITUDE LONGITUDE,
		f.WORK_LATITUDE LATITUDE,
		'./bi/images/map/highwork.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO as MAP_POINT_NAME
		FROM bus_highwork f WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
		AND f.APPLY_STATUS != '6'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--有限空间作业-->
	<select id="getCONFINEDSPACEHighRiskWorkLocationOrder" parameterType="pd" resultType="pd">
		SELECT
		'CONFINEDSPACE' TYPE,
		f.CONFINEDSPACE_ID id,
		CONCAT_WS("", '有限空间作业 编号：', f.CHECK_NO) NAME,
		f.WORK_LONGITUDE LONGITUDE,
		f.WORK_LATITUDE LATITUDE,
		'./bi/images/map/confinedspace.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO as MAP_POINT_NAME
		FROM bus_confinedspace f WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
		AND f.APPLY_STATUS != '6'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--吊装作业-->
	<select id="getHOISTINGHighRiskWorkLocationOrder" parameterType="pd" resultType="pd">
		SELECT
		'HOISTING' TYPE,
		f.HOISTING_ID id,
		CONCAT_WS("", '吊装作业 编号：', f.CHECK_NO) NAME,
		f.WORK_LONGITUDE LONGITUDE,
		f.WORK_LATITUDE LATITUDE,
		'./bi/images/map/hoisting.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO as MAP_POINT_NAME
		FROM bus_hoisting f WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
		AND f.APPLY_STATUS !='6'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--动土作业-->
	<select id="getBREAKGROUNDHighRiskWorkLocationOrder" parameterType="pd" resultType="pd">
		SELECT
		'BREAKGROUND' TYPE,
		f.BREAKGROUND_ID id,
		CONCAT_WS("", '动土作业 编号：', f.CHECK_NO) NAME,
		f.WORK_LONGITUDE LONGITUDE,
		f.WORK_LATITUDE LATITUDE,
		'./bi/images/map/hoisting.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO as MAP_POINT_NAME
		FROM bus_breakground f WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
		AND f.APPLY_STATUS !='6'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--断路作业-->
	<select id="getCUTROADHighRiskWorkLocationOrder" parameterType="pd" resultType="pd">
		SELECT
		'CUTROAD' TYPE,
		f.CUTROAD_ID id,
		CONCAT_WS("", '断路作业 编号：', f.CHECK_NO) NAME,
		f.WORK_LONGITUDE LONGITUDE,
		f.WORK_LATITUDE LATITUDE,
		'./bi/images/map/hoisting.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO as MAP_POINT_NAME
		FROM bus_cutroad f WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
		AND f.APPLY_STATUS !='6'
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>

	<!--临时用电-->
	<select id="findByIdELECTRICITYOrder" parameterType="pd" resultType="pd">
		select
		f.CORPINFO_ID,
		f.ISDELETE,
		f.CREATTIME,
		f.CREATOR,
		f.OPERATTIME,
		f.OPERATOR,
		f.CHECK_NO,
		f.WORK_CONTENT,
		f.WORK_START_DATE,
		f.WORK_END_DATE,
		f.CONFIRM_DEPARTMENT_ID,
		f.CONFIRM_USER_ID,
		f.CONFIRM_USER_SIGNER_PATH,
		f.CONFIRM_USER_SIGNER_TIME,
		f.AUDIT_DEPARTMENT_ID,
		f.AUDIT_USER_ID,
		f.AUDIT_USER_SIGNER_PATH,
		f.AUDIT_USER_SIGNER_TIME,
		f.APPROVE_DEPARTMENT_ID,
		f.APPROVE_USER_ID,
		f.APPROVE_USER_SIGNER_PATH,
		f.APPROVE_USER_SIGNER_TIME,
		f.APPLY_STATUS,
		IFNULL(f.CONFIRM_CONTENT,'无') as CONFIRM_CONTENT,
		IFNULL(f.AUDIT_CONTENT,'无') as AUDIT_CONTENT,
		IFNULL(f.APPROVE_CONTENT,'无') as APPROVE_CONTENT,
		f.OTHER_PROTECTIVE_MEASURES,
		f.ACCEPT_DEPARTMENT_ID,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		IFNULL(f.ACCEPT_CONTENT,'无') as ACCEPT_CONTENT,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER_ID,
		f.WORK_PLACE,
		f.ALLOW_POWER,
		f.WORK_VOLTAGE,
		f.RATED_POWER,
		f.WORK_USER,
		f.CARD_NO,
		f.GUARDIAN,
		f.SPECIAL_WORK,
		f.RISK_IDENTIFICATION,
		f.CONFESS_USER,
		f.ACCEPT_CONFESS_USER,
		f.EDUCATE_USER,
		f.ACCEPT_EDUCATE_USER,
		f.ANALYZE_DEPARTMENT_ID,
		f.ANALYZE_USER_ID,
		f.ELECTRICITY_USER,
		f.LEADER_CARD_NO,
		f.ELECTRICITY_ID,
		f.GUARDIAN_DEPARTMENT_ID,
		f.GUARDIAN_USER_ID,
		f.GUARDIAN_USER_SIGNER_PATH,
		f.GUARDIAN_USER_SIGNER_TIME,
		f.CONFESS_DEPARTMENT_ID,
		f.CONFESS_USER_ID,
		f.CONFESS_USER_SIGNER_PATH,
		f.CONFESS_USER_SIGNER_TIME,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME,
		f.WORK_LATITUDE,
		f.WORK_LONGITUDE,

		ad.NAME as APPLY_DEPARTMENT_NAME,
		au.NAME as APPLY_USER_NAME,

		cd.NAME as CONFIRM_DEPARTMENT_NAME,
		cu.NAME as CONFIRM_USER_NAME,

		aud.NAME as AUDIT_DEPARTMENT_NAME,
		auu.NAME as AUDIT_USER_NAME,

		apd.NAME as APPROVE_DEPARTMENT_NAME,
		apu.NAME as APPROVE_USER_NAME,

		acd.NAME as ACCEPT_DEPARTMENT_NAME,
		acu.NAME as ACCEPT_USER_NAME,

		anad.NAME as ANALYZE_DEPARTMENT_NAME,
		anau.NAME as ANALYZE_USER_NAME,

		ac.NAME as CONFESS_DEPARTMENT_NAME,
		accu.NAME as CONFESS_USER_NAME,

		aac.NAME as ACCEPT_CONFESS_DEPARTMENT_NAME,
		aacu.NAME as ACCEPT_CONFESS_USER_NAME,

		bc.NAME as GUARDIAN_DEPARTMENT_NAME,
		bcu.NAME as GUARDIAN_USER_NAME
		from
		bus_electricity f
		left join OA_DEPARTMENT bc on bc.DEPARTMENT_ID = f.GUARDIAN_DEPARTMENT_ID
		left join SYS_USER bcu on bcu.USER_ID = f.GUARDIAN_USER_ID

		left join OA_DEPARTMENT aac on aac.DEPARTMENT_ID = f.ACCEPT_CONFESS_DEPARTMENT_ID
		left join SYS_USER aacu on aacu.USER_ID = f.ACCEPT_CONFESS_USER_ID

		left join OA_DEPARTMENT ac on ac.DEPARTMENT_ID = f.CONFESS_DEPARTMENT_ID
		left join SYS_USER accu on accu.USER_ID = f.CONFESS_USER_ID

		left join OA_DEPARTMENT ad on ad.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID
		left join SYS_USER au on au.USER_ID = f.APPLY_USER_ID

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONFIRM_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONFIRM_USER_ID

		left join OA_DEPARTMENT aud on aud.DEPARTMENT_ID = f.AUDIT_DEPARTMENT_ID
		left join SYS_USER auu on auu.USER_ID = f.AUDIT_USER_ID

		left join OA_DEPARTMENT apd on apd.DEPARTMENT_ID = f.APPROVE_DEPARTMENT_ID
		left join SYS_USER apu on apu.USER_ID = f.APPROVE_USER_ID

		left join OA_DEPARTMENT acd on acd.DEPARTMENT_ID = f.ACCEPT_DEPARTMENT_ID
		left join SYS_USER acu on acu.USER_ID = f.ACCEPT_USER_ID

		left join OA_DEPARTMENT anad on anad.DEPARTMENT_ID = f.ANALYZE_DEPARTMENT_ID
		left join SYS_USER anau on anau.USER_ID = f.ANALYZE_USER_ID
		where
		f.ELECTRICITY_ID = #{ELECTRICITY_ID}
	</select>

	<!-- 临时用电措施列表-->
	<select id="listAllMeasuresELECTRICITYOrder" parameterType="pd" resultType="pd">
		select
		f.*
			,eo.STATUS,eo.CONFIRM_NAME

		from
		bus_ELECTRICITY_MEASURES f

			left join bus_ELECTRICITYTOMEASURES eo on eo.BUS_ELECTRICITY_MEASURES_ID = f.BUS_ELECTRICITY_MEASURES_ID

		where f.ISDELETE = '0'

			and eo.ELECTRICITY_ID = #{ELECTRICITY_ID}

		order by f.ORDER
	</select>

	<!-- 临时用电-->
	<select id="listAllGasELECTRICTITYOrder" parameterType="pd" resultType="pd">
		select
		f.ELECTRICITY_ID,
		f.ANALYZE_TIME,
		f.ANALYZE_PLACE,
		f.ANALYZE_RESULT,
		f.ANALYZE_USER,
		f.ISDELETE,
		f.ELECTRICITYGAS_ID
		from
		bus_ELECTRICITYGAS f
		where f.ISDELETE = '0' and f.ELECTRICITY_ID = #{ELECTRICITY_ID}
		ORDER BY f.ANALYZE_TIME desc
	</select>



	<!--盲板作业-->
	<select id="findByIdBLINDBOARDOrder" parameterType="pd" resultType="pd">
				select
		f.*,
		i.*,
		ad.NAME as APPLY_DEPARTMENT_NAME,
		au.NAME as APPLY_USER_NAME,

		cd.NAME as CONSTRUCTION_DEPARTMENT_NAME,
		cu.NAME as CONSTRUCTION_USER_NAME,

		prd.NAME as PRODUCTION_DEPARTMENT_NAME,
		pru.NAME as PRODUCTION_USER_NAME,

		sd.NAME as SAFETY_DEPARTMENT_NAME,
		su.NAME as SAFETY_USER_NAME,

		ld.NAME as LEADER_DEPARTMENT_NAME,
		lu.NAME as LEADER_USER_NAME,

		acd.NAME as ACCEPT_DEPARTMENT_NAME,
		acu.NAME as ACCEPT_USER_NAME
		from
		bus_blindboard f
		left join bus_BLINDBOARDINFO i on i.BLINDBOARD_ID = f.BLINDBOARD_ID

		left join OA_DEPARTMENT ad on ad.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID
		left join SYS_USER au on au.USER_ID = f.APPLY_USER_ID

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONSTRUCTION_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONSTRUCTION_USER_ID

		left join OA_DEPARTMENT prd on prd.DEPARTMENT_ID = f.PRODUCTION_DEPARTMENT_ID
		left join SYS_USER pru on pru.USER_ID = f.PRODUCTION_USER_ID

		left join OA_DEPARTMENT sd on sd.DEPARTMENT_ID = f.SAFETY_DEPARTMENT_ID
		left join SYS_USER su on su.USER_ID = f.SAFETY_USER_ID

		left join OA_DEPARTMENT ld on ld.DEPARTMENT_ID = f.LEADER_DEPARTMENT_ID
		left join SYS_USER lu on lu.USER_ID = f.LEADER_USER_ID

		left join OA_DEPARTMENT acd on acd.DEPARTMENT_ID = f.ACCEPT_DEPARTMENT_ID
		left join SYS_USER acu on acu.USER_ID = f.ACCEPT_USER_ID
		where
		f.BLINDBOARD_ID = #{BLINDBOARD_ID}
	</select>

	<!--盲板作业根据id获取经纬度-->
	<select id="findByIdJWDOrder" parameterType="pd" resultType="pd">
		select
		f.*
		from
		bus_BLINDBOARDINFO f
		where
		f.BLINDBOARDINFO_ID = #{BLINDBOARDINFO_ID}
	</select>

	<!-- 列表(全部) -->
	<select id="listAllMeasuresBLINDBOARDOrder" parameterType="pd" resultType="pd">
		select
		f.*
		,eo.STATUS,eo.CONFIRM_NAME
		from
		bus_BLINDBOARD_MEASURES f
			left join bus_BLINDBOARDTOMEASURES eo on eo.BUS_BLINDBOARD_MEASURES_ID = f.BUS_BLINDBOARD_MEASURES_ID
		where f.ISDELETE = '0'
			and eo.BLINDBOARD_ID = #{BLINDBOARD_ID}
		order by f.ORDER
	</select>

	<!--高处作业-->
	<select id="findByIdHIGHWORKOrder" parameterType="pd" resultType="pd">
		select
		f.CORPINFO_ID,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER,
		f.ISDELETE,
		f.CREATTIME,
		f.CREATOR,
		f.OPERATTIME,
		f.OPERATOR,
		f.CHECK_NO,
		f.PROJECT_MANAGER,
		f.WORK_CONTENT,
		f.WORK_START_DATE,
		f.WORK_END_DATE,
		f.CONSTRUCTION_DEPARTMENT_ID,
		f.CONSTRUCTION_USER_ID,
		f.CONSTRUCTION_USER_SIGNER_PATH,
		f.CONSTRUCTION_USER_SIGNER_TIME,
		f.AUDIT_DEPARTMENT_ID,
		f.AUDIT_USER_ID,
		f.AUDIT_USER_SIGNER_PATH,
		f.AUDIT_USER_SIGNER_TIME,
		f.APPROVE_DEPARTMENT_ID,
		f.APPROVE_USER_ID,
		f.APPROVE_USER_SIGNER_PATH,
		f.APPROVE_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.APPLY_STATUS,
		IFNULL(f.CONSTRUCTION_CONTENT,'无') as CONSTRUCTION_CONTENT,
		IFNULL(f.AUDIT_CONTENT,'无') as AUDIT_CONTENT,
		IFNULL(f.APPROVE_CONTENT,'无') as APPROVE_CONTENT,
		IFNULL(f.ACCEPT_CONTENT,'无') as ACCEPT_CONTENT,
		f.OTHER_PROTECTIVE_MEASURES,
		f.HAZARD_IDENTIFICATION,
		f.BELONGING_CORP,
		f.WORK_CORP,
		f.WORK_PLACE,
		f.LEADER_DEPARTMENT_ID,
		f.LEADER_USER_ID,
		IFNULL(f.LEADER_CONTENT,'无') as LEADER_CONTENT,
		f.LEADER_USER_SIGNER_PATH,
		f.LEADER_USER_SIGNER_TIME,
		f.CONFESS_USER,
		f.ACCEPT_CONFESS_USER,
		f.SPECIAL_WORK,
		f.GUARDIAN_USER,
		f.WORK_HIGH,
		f.WORK_LEVEL,
		f.HIGHWORK_ID,
		f.GUARDIAN_DEPARTMENT_ID,
		f.GUARDIAN_USER_ID,
		f.GUARDIAN_USER_SIGNER_PATH,
		f.GUARDIAN_USER_SIGNER_TIME,
		f.CONFESS_DEPARTMENT_ID,
		f.CONFESS_USER_ID,
		f.CONFESS_USER_SIGNER_PATH,
		f.CONFESS_USER_SIGNER_TIME,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME,
		f.WORK_LATITUDE,
		f.WORK_LONGITUDE,

		ad.NAME as APPLY_DEPARTMENT_NAME,
		getFullName(ad.DEPARTMENT_ID) APPLY_DEPARTMENT_ALL,

		cd.NAME as CONSTRUCTION_DEPARTMENT_NAME,
		cu.NAME as CONSTRUCTION_USER_NAME,

		ld.NAME as LEADER_DEPARTMENT_NAME,
		lu.NAME as LEADER_USER_NAME,

		aud.NAME as AUDIT_DEPARTMENT_NAME,
		auu.NAME as AUDIT_USER_NAME,

		apd.NAME as APPROVE_DEPARTMENT_NAME,
		apu.NAME as APPROVE_USER_NAME,

		acd.NAME as ACCEPT_DEPARTMENT_NAME,
		acu.NAME as ACCEPT_USER_NAME,

		ac.NAME as CONFESS_DEPARTMENT_NAME,
		accu.NAME as CONFESS_USER_NAME,

		aac.NAME as ACCEPT_CONFESS_DEPARTMENT_NAME,
		aacu.NAME as ACCEPT_CONFESS_USER_NAME,

		bc.NAME as GUARDIAN_DEPARTMENT_NAME,
		bcu.NAME as GUARDIAN_USER_NAME
		from
		bus_highwork f

		left join OA_DEPARTMENT bc on bc.DEPARTMENT_ID = f.GUARDIAN_DEPARTMENT_ID
		left join SYS_USER bcu on bcu.USER_ID = f.GUARDIAN_USER_ID

		left join OA_DEPARTMENT aac on aac.DEPARTMENT_ID = f.ACCEPT_CONFESS_DEPARTMENT_ID
		left join SYS_USER aacu on aacu.USER_ID = f.ACCEPT_CONFESS_USER_ID

		left join OA_DEPARTMENT ac on ac.DEPARTMENT_ID = f.CONFESS_DEPARTMENT_ID
		left join SYS_USER accu on accu.USER_ID = f.CONFESS_USER_ID

		left join OA_DEPARTMENT ad on ad.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONSTRUCTION_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONSTRUCTION_USER_ID

		left join OA_DEPARTMENT ld on ld.DEPARTMENT_ID = f.LEADER_DEPARTMENT_ID
		left join SYS_USER lu on lu.USER_ID = f.LEADER_USER_ID

		left join OA_DEPARTMENT aud on aud.DEPARTMENT_ID = f.AUDIT_DEPARTMENT_ID
		left join SYS_USER auu on auu.USER_ID = f.AUDIT_USER_ID

		left join OA_DEPARTMENT apd on apd.DEPARTMENT_ID = f.APPROVE_DEPARTMENT_ID
		left join SYS_USER apu on apu.USER_ID = f.APPROVE_USER_ID

		left join OA_DEPARTMENT acd on acd.DEPARTMENT_ID = f.ACCEPT_DEPARTMENT_ID
		left join SYS_USER acu on acu.USER_ID = f.ACCEPT_USER_ID
		where
		f.HIGHWORK_ID = #{HIGHWORK_ID}
	</select>

	<!-- 高处作业措施查询 -->
	<select id="listAllMeasuresHIGHWORKOrder" parameterType="pd" resultType="pd">
		select
		f.*
			,eo.STATUS,eo.CONFIRM_NAME
		from
		bus_HIGHWORK_MEASURES f
			left join bus_HIGHWORKTOMEASURES eo on eo.BUS_HIGHWORK_MEASURES_ID = f.HIGHWORK_MEASURES_ID
		where f.ISDELETE = '0'
			and eo.HIGHWORK_ID = #{HIGHWORK_ID}
		order by f.ORDER
	</select>


	<!--吊装作业-->
	<select id="findByIdHOISTINGOrder" parameterType="pd" resultType="pd">
		select
		f.CORPINFO_ID,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER,
		f.ISDELETE,
		f.CREATTIME,
		f.CREATOR,
		f.OPERATTIME,
		f.OPERATOR,
		f.CHECK_NO,
		f.PROJECT_MANAGER,
		f.WORK_CONTENT,
		f.WORK_START_DATE,
		f.WORK_END_DATE,
		f.CONSTRUCTION_DEPARTMENT_ID,
		f.CONSTRUCTION_USER_ID,
		f.CONSTRUCTION_USER_SIGNER_PATH,
		f.CONSTRUCTION_USER_SIGNER_TIME,
		f.AUDIT_DEPARTMENT_ID,
		f.AUDIT_USER_ID,
		f.AUDIT_USER_SIGNER_PATH,
		f.AUDIT_USER_SIGNER_TIME,
		f.APPROVE_DEPARTMENT_ID,
		f.APPROVE_USER_ID,
		f.APPROVE_USER_SIGNER_PATH,
		f.APPROVE_USER_SIGNER_TIME,
		f.APPLY_STATUS,
		IFNULL(f.CONSTRUCTION_CONTENT,'无') as CONSTRUCTION_CONTENT,
		IFNULL(f.AUDIT_CONTENT,'无') as AUDIT_CONTENT,
		IFNULL(f.APPROVE_CONTENT,'无') as APPROVE_CONTENT,
		f.OTHER_PROTECTIVE_MEASURES,
		f.WORK_USER,
		f.WORK_PLACE,
		f.TOOL_NAME,
		f.PART_WEIGHT,
		f.LEADER_DEPARTMENT_ID,
		f.LEADER_USER_ID,
		IFNULL(f.LEADER_CONTENT,'无') as LEADER_CONTENT,
		f.LEADER_USER_SIGNER_PATH,
		f.LEADER_USER_SIGNER_TIME,
		f.CONFESS_USER,
		f.ACCEPT_CONFESS_USER,
		f.WORK_LEVEL,
		f.ACCEPT_DEPARTMENT_ID,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		IFNULL(f.ACCEPT_CONTENT,'无') as ACCEPT_CONTENT,
		f.HAZARD_IDENTIFICATION,
		f.GUARDIAN_USER,
		f.SISUO_USER,
		f.HOISTING_ID,
		f.GUARDIAN_DEPARTMENT_ID,
		f.GUARDIAN_USER_ID,
		f.GUARDIAN_USER_SIGNER_PATH,
		f.GUARDIAN_USER_SIGNER_TIME,
		f.CONFESS_DEPARTMENT_ID,
		f.CONFESS_USER_ID,
		f.CONFESS_USER_SIGNER_PATH,
		f.CONFESS_USER_SIGNER_TIME,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME,
		f.SPECIAL_WORK,
		ad.NAME as APPLY_DEPARTMENT_NAME,
		getFullName(ad.DEPARTMENT_ID) APPLY_DEPARTMENT_ALL,

		ld.NAME as LEADER_DEPARTMENT_NAME,
		lu.NAME as LEADER_USER_NAME,

		cd.NAME as CONSTRUCTION_DEPARTMENT_NAME,
		cu.NAME as CONSTRUCTION_USER_NAME,

		aud.NAME as AUDIT_DEPARTMENT_NAME,
		auu.NAME as AUDIT_USER_NAME,

		apd.NAME as APPROVE_DEPARTMENT_NAME,
		apu.NAME as APPROVE_USER_NAME,

		acd.NAME as ACCEPT_DEPARTMENT_NAME,
		acu.NAME as ACCEPT_USER_NAME,

		ac.NAME as CONFESS_DEPARTMENT_NAME,
		accu.NAME as CONFESS_USER_NAME,

		aac.NAME as ACCEPT_CONFESS_DEPARTMENT_NAME,
		aacu.NAME as ACCEPT_CONFESS_USER_NAME,

		bc.NAME as GUARDIAN_DEPARTMENT_NAME,
		bcu.NAME as GUARDIAN_USER_NAME
		from
		bus_HOISTING f

		left join OA_DEPARTMENT bc on bc.DEPARTMENT_ID = f.GUARDIAN_DEPARTMENT_ID
		left join SYS_USER bcu on bcu.USER_ID = f.GUARDIAN_USER_ID

		left join OA_DEPARTMENT aac on aac.DEPARTMENT_ID = f.ACCEPT_CONFESS_DEPARTMENT_ID
		left join SYS_USER aacu on aacu.USER_ID = f.ACCEPT_CONFESS_USER_ID

		left join OA_DEPARTMENT ac on ac.DEPARTMENT_ID = f.CONFESS_DEPARTMENT_ID
		left join SYS_USER accu on accu.USER_ID = f.CONFESS_USER_ID
		left join OA_DEPARTMENT ad on ad.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID

		left join OA_DEPARTMENT ld on ld.DEPARTMENT_ID = f.LEADER_DEPARTMENT_ID
		left join SYS_USER lu on lu.USER_ID = f.LEADER_USER_ID

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONSTRUCTION_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONSTRUCTION_USER_ID

		left join OA_DEPARTMENT aud on aud.DEPARTMENT_ID = f.AUDIT_DEPARTMENT_ID
		left join SYS_USER auu on auu.USER_ID = f.AUDIT_USER_ID

		left join OA_DEPARTMENT apd on apd.DEPARTMENT_ID = f.APPROVE_DEPARTMENT_ID
		left join SYS_USER apu on apu.USER_ID = f.APPROVE_USER_ID

		left join OA_DEPARTMENT acd on acd.DEPARTMENT_ID = f.ACCEPT_DEPARTMENT_ID
		left join SYS_USER acu on acu.USER_ID = f.ACCEPT_USER_ID
		where
		f.HOISTING_ID = #{HOISTING_ID}
	</select>


	<!-- 吊装作业措施查询 -->
	<select id="listAllMeasuresHOISTINGOrder" parameterType="pd" resultType="pd">
		select
		f.*
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			,eo.STATUS		,eo.ANSWER1,eo.CONFIRM_NAME
		</if>
		from
		bus_HOISTING_MEASURES f
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			left join bus_HOISTINGTOMEASURES eo on eo.BUS_HOISTING_MEASURES_ID = f.HOISTING_MEASURES_ID
		</if>
		where f.ISDELETE = '0'
		<if test="APPLY_STATUS != '1' and APPLY_STATUS != 1">
			and eo.HOISTING_ID = #{HOISTING_ID}
		</if>
		order by f.ORDER
	</select>

	<!-- 动土作业 -->
	<select id="findByIdBREAKGROUNDOrder" parameterType="pd" resultType="pd">
		select
		f.CORPINFO_ID,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER_ID,
		f.ISDELETE,
		f.CREATTIME,
		f.CREATOR,
		f.OPERATTIME,
		f.OPERATOR,
		f.CHECK_NO,
		f.PROJECT_MANAGER,
		f.WORK_CONTENT,
		f.WORK_START_DATE,
		f.WORK_END_DATE,
		f.WORK_PLACE,
		f.CONSTRUCTION_DEPARTMENT_ID,
		f.CONSTRUCTION_USER_ID,
		f.CONSTRUCTION_USER_SIGNER_PATH,
		f.CONSTRUCTION_USER_SIGNER_TIME,
		f.PRODUCTION_DEPARTMENT_ID,
		f.PRODUCTION_USER_ID,
		f.PRODUCTION_USER_SIGNER_PATH,
		f.PRODUCTION_USER_SIGNER_TIME,
		f.SAFETY_DEPARTMENT_ID,
		f.SAFETY_USER_ID,
		f.SAFETY_USER_SIGNER_PATH,
		f.SAFETY_USER_SIGNER_TIME,
		f.LEADER_DEPARTMENT_ID,
		f.LEADER_USER_ID,
		f.LEADER_USER_SIGNER_PATH,
		f.LEADER_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.APPLY_STATUS,
		f.WORK_NO,
		IFNULL(f.CONSTRUCTION_CONTENT,'无') as CONSTRUCTION_CONTENT,
		IFNULL(f.PRODUCTION_CONTENT,'无') as PRODUCTION_CONTENT,
		IFNULL(f.SAFETY_CONTENT,'无') as SAFETY_CONTENT,
		IFNULL(f.LEADER_CONTENT,'无') as LEADER_CONTENT,
		IFNULL(f.ACCEPT_CONTENT,'无') as ACCEPT_CONTENT,
		f.OTHER_PROTECTIVE_MEASURES,
		f.HAZARD_IDENTIFICATION,
		f.CONFESS_USER,
		f.ACCEPT_CONFESS_USER,
		f.SPECIAL_WORK,
		f.GUARDIAN_USER,
		f.JOB_CONTENT,
		f.APPLY_USER_SIGNER_PATH,
		f.APPLY_USER_SIGNER_TIME,
		f.CONTENT_IMG_PATH,
		f.GUARDIAN_DEPARTMENT_ID,
		f.GUARDIAN_USER_ID,
		f.GUARDIAN_USER_SIGNER_PATH,
		f.GUARDIAN_USER_SIGNER_TIME,
		f.CONFESS_DEPARTMENT_ID,
		f.CONFESS_USER_ID,
		f.CONFESS_USER_SIGNER_PATH,
		f.CONFESS_USER_SIGNER_TIME,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME,

		f.BREAKGROUND_ID,
		ad.NAME as APPLY_DEPARTMENT_NAME,
		au.NAME as APPLY_USER_NAME,

		cd.NAME as CONSTRUCTION_DEPARTMENT_NAME,
		cu.NAME as CONSTRUCTION_USER_NAME,

		prd.NAME as PRODUCTION_DEPARTMENT_NAME,
		pru.NAME as PRODUCTION_USER_NAME,

		sd.NAME as SAFETY_DEPARTMENT_NAME,
		su.NAME as SAFETY_USER_NAME,

		ld.NAME as LEADER_DEPARTMENT_NAME,
		lu.NAME as LEADER_USER_NAME,

		acd.NAME as ACCEPT_DEPARTMENT_NAME,
		acu.NAME as ACCEPT_USER_NAME,

		ac.NAME as CONFESS_DEPARTMENT_NAME,
		accu.NAME as CONFESS_USER_NAME,

		aac.NAME as ACCEPT_CONFESS_DEPARTMENT_NAME,
		aacu.NAME as ACCEPT_CONFESS_USER_NAME,

		bc.NAME as GUARDIAN_DEPARTMENT_NAME,
		bcu.NAME as GUARDIAN_USER_NAME
		from
		bus_BREAKGROUND f

		left join OA_DEPARTMENT bc on bc.DEPARTMENT_ID = f.GUARDIAN_DEPARTMENT_ID
		left join SYS_USER bcu on bcu.USER_ID = f.GUARDIAN_USER_ID

		left join OA_DEPARTMENT aac on aac.DEPARTMENT_ID = f.ACCEPT_CONFESS_DEPARTMENT_ID
		left join SYS_USER aacu on aacu.USER_ID = f.ACCEPT_CONFESS_USER_ID

		left join OA_DEPARTMENT ac on ac.DEPARTMENT_ID = f.CONFESS_DEPARTMENT_ID
		left join SYS_USER accu on accu.USER_ID = f.CONFESS_USER_ID

		left join OA_DEPARTMENT ad on ad.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID
		left join SYS_USER au on au.USER_ID = f.APPLY_USER_ID

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONSTRUCTION_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONSTRUCTION_USER_ID

		left join OA_DEPARTMENT prd on prd.DEPARTMENT_ID = f.PRODUCTION_DEPARTMENT_ID
		left join SYS_USER pru on pru.USER_ID = f.PRODUCTION_USER_ID

		left join OA_DEPARTMENT sd on sd.DEPARTMENT_ID = f.SAFETY_DEPARTMENT_ID
		left join SYS_USER su on su.USER_ID = f.SAFETY_USER_ID

		left join OA_DEPARTMENT ld on ld.DEPARTMENT_ID = f.LEADER_DEPARTMENT_ID
		left join SYS_USER lu on lu.USER_ID = f.LEADER_USER_ID

		left join OA_DEPARTMENT acd on acd.DEPARTMENT_ID = f.ACCEPT_DEPARTMENT_ID
		left join SYS_USER acu on acu.USER_ID = f.ACCEPT_USER_ID
		where
		f.BREAKGROUND_ID = #{BREAKGROUND_ID}
	</select>

	<!-- 动土作业措施查询 -->
	<select id="listAllMeasuresBREAKGROUNDOrder" parameterType="pd" resultType="pd">
		select
		f.*
		<if test="APPLY_STATUS != null and APPLY_STATUS != '0' and APPLY_STATUS != 0">
			,eo.STATUS,eo.ANSWER,eo.CONFIRM_NAME
		</if>
		from
		bus_BREAKGROUND_MEASURES f
		<if test="APPLY_STATUS != null and APPLY_STATUS != '0' and APPLY_STATUS != 0">
			left join bus_BREAKGROUNDTOMEASURES eo on eo.BUS_BREAKGROUND_MEASURES_ID = f.BUS_BREAKGROUND_MEASURES_ID
		</if>
		where f.ISDELETE = '0'
		<if test="APPLY_STATUS != null and APPLY_STATUS != '0' and APPLY_STATUS != 0">
			and eo.BREAKGROUND_ID = #{BREAKGROUND_ID}
		</if>
		order by f.ORDER
	</select>


	<!-- 断路作业 -->
	<select id="findByIdCUTROADOrder" parameterType="pd" resultType="pd">
		select
		f.CORPINFO_ID,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER_ID,
		f.ISDELETE,
		f.CREATTIME,
		f.CREATOR,
		f.OPERATTIME,
		f.OPERATOR,
		f.CHECK_NO,
		f.PROJECT_MANAGER,
		f.WORK_CONTENT,
		f.WORK_START_DATE,
		f.WORK_END_DATE,
		f.CONSTRUCTION_DEPARTMENT_ID,
		f.CONSTRUCTION_USER_ID,
		f.CONSTRUCTION_USER_SIGNER_PATH,
		f.CONSTRUCTION_USER_SIGNER_TIME,
		f.PRODUCTION_DEPARTMENT_ID,
		f.PRODUCTION_USER_ID,
		f.PRODUCTION_USER_SIGNER_PATH,
		f.PRODUCTION_USER_SIGNER_TIME,
		f.SAFETY_DEPARTMENT_ID,
		f.SAFETY_USER_ID,
		f.SAFETY_USER_SIGNER_PATH,
		f.SAFETY_USER_SIGNER_TIME,
		f.LEADER_DEPARTMENT_ID,
		f.LEADER_USER_ID,
		f.LEADER_USER_SIGNER_PATH,
		f.LEADER_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.APPLY_STATUS,
		f.WORK_NO,
		IFNULL(f.CONSTRUCTION_CONTENT,'无') as CONSTRUCTION_CONTENT,
		IFNULL(f.PRODUCTION_CONTENT,'无') as PRODUCTION_CONTENT,
		IFNULL(f.SAFETY_CONTENT,'无') as SAFETY_CONTENT,
		IFNULL(f.LEADER_CONTENT,'无') as LEADER_CONTENT,
		IFNULL(f.ACCEPT_CONTENT,'无') as ACCEPT_CONTENT,
		f.OTHER_PROTECTIVE_MEASURES,
		f.HAZARD_IDENTIFICATION,
		f.CONFESS_USER,
		f.ACCEPT_CONFESS_USER,
		f.SPECIAL_WORK,
		f.GUARDIAN_USER,
		f.JOB_CONTENT,
		f.APPLY_USER_SIGNER_PATH,
		f.APPLY_USER_SIGNER_TIME,
		f.CONTENT_IMG_PATH,
		f.WORK_REASON,
		f.OTHER_DEPT,
		f.CUTROAD_ID,
		f.GUARDIAN_DEPARTMENT_ID,
		f.GUARDIAN_USER_ID,
		f.GUARDIAN_USER_SIGNER_PATH,
		f.GUARDIAN_USER_SIGNER_TIME,
		f.CONFESS_DEPARTMENT_ID,
		f.CONFESS_USER_ID,
		f.CONFESS_USER_SIGNER_PATH,
		f.CONFESS_USER_SIGNER_TIME,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME,
		ad.NAME as APPLY_DEPARTMENT_NAME,
		au.NAME as APPLY_USER_NAME,

		cd.NAME as CONSTRUCTION_DEPARTMENT_NAME,
		cu.NAME as CONSTRUCTION_USER_NAME,

		prd.NAME as PRODUCTION_DEPARTMENT_NAME,
		pru.NAME as PRODUCTION_USER_NAME,

		sd.NAME as SAFETY_DEPARTMENT_NAME,
		su.NAME as SAFETY_USER_NAME,

		ld.NAME as LEADER_DEPARTMENT_NAME,
		lu.NAME as LEADER_USER_NAME,

		acd.NAME as ACCEPT_DEPARTMENT_NAME,
		acu.NAME as ACCEPT_USER_NAME,

		ac.NAME as CONFESS_DEPARTMENT_NAME,
		accu.NAME as CONFESS_USER_NAME,

		aac.NAME as ACCEPT_CONFESS_DEPARTMENT_NAME,
		aacu.NAME as ACCEPT_CONFESS_USER_NAME,

		bc.NAME as GUARDIAN_DEPARTMENT_NAME,
		bcu.NAME as GUARDIAN_USER_NAME
		from
		bus_CUTROAD f
		left join OA_DEPARTMENT bc on bc.DEPARTMENT_ID = f.GUARDIAN_DEPARTMENT_ID
		left join SYS_USER bcu on bcu.USER_ID = f.GUARDIAN_USER_ID

		left join OA_DEPARTMENT aac on aac.DEPARTMENT_ID = f.ACCEPT_CONFESS_DEPARTMENT_ID
		left join SYS_USER aacu on aacu.USER_ID = f.ACCEPT_CONFESS_USER_ID

		left join OA_DEPARTMENT ac on ac.DEPARTMENT_ID = f.CONFESS_DEPARTMENT_ID
		left join SYS_USER accu on accu.USER_ID = f.CONFESS_USER_ID

		left join OA_DEPARTMENT ad on ad.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID
		left join SYS_USER au on au.USER_ID = f.APPLY_USER_ID

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONSTRUCTION_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONSTRUCTION_USER_ID

		left join OA_DEPARTMENT prd on prd.DEPARTMENT_ID = f.PRODUCTION_DEPARTMENT_ID
		left join SYS_USER pru on pru.USER_ID = f.PRODUCTION_USER_ID

		left join OA_DEPARTMENT sd on sd.DEPARTMENT_ID = f.SAFETY_DEPARTMENT_ID
		left join SYS_USER su on su.USER_ID = f.SAFETY_USER_ID

		left join OA_DEPARTMENT ld on ld.DEPARTMENT_ID = f.LEADER_DEPARTMENT_ID
		left join SYS_USER lu on lu.USER_ID = f.LEADER_USER_ID

		left join OA_DEPARTMENT acd on acd.DEPARTMENT_ID = f.ACCEPT_DEPARTMENT_ID
		left join SYS_USER acu on acu.USER_ID = f.ACCEPT_USER_ID
		where
		f.CUTROAD_ID = #{CUTROAD_ID}
	</select>

	<!-- 断路作业措施查询 -->
	<select id="listAllMeasuresCUTROADOrder" parameterType="pd" resultType="pd">
		select
		f.*
		<if test="APPLY_STATUS != null and APPLY_STATUS != '0' and APPLY_STATUS != 0">
			,eo.STATUS,eo.CONFIRM_NAME
		</if>
		from
		bus_CUTROAD_MEASURES f
		<if test="APPLY_STATUS != null and APPLY_STATUS != '0' and APPLY_STATUS != 0">
			left join bus_CUTROADTOMEASURES eo on eo.BUS_CUTROAD_MEASURES_ID = f.BUS_CUTROAD_MEASURES_ID
		</if>
		where f.ISDELETE = '0'
		<if test="APPLY_STATUS != null and APPLY_STATUS != '0' and APPLY_STATUS != 0">
			and eo.CUTROAD_ID = #{CUTROAD_ID}
		</if>
		order by f.ORDER
	</select>

	<select id="getListDongHuo" resultType="string">
		select
	  		`NAME`
		from
			sys_dictionaries
		where
			DICTIONARIES_ID in
		<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
			#{item}
		</foreach>
	</select>

	<!--（新）动火作业-->
	<select id="getHOTWORKHighRiskWorkLocationCfd" parameterType="pd" resultType="pd">
		SELECT
		'HOTWORK' TYPE,
		f.HOTWORK_ID id,
		CONCAT_WS("", '动火作业 编号：', f.CHECK_NO ) NAME,
		f.WORK_LONGITUDE LONGITUDE,
		f.WORK_LATITUDE LATITUDE,
		'./bi/images/map/hotwork.png' IMAGE_FILE,
		f.CORPINFO_ID,
		f.CHECK_NO,
		f.CHECK_NO AS MAP_POINT_NAME
		FROM bus_hotwork_cfd f
		WHERE f.ISDELETE = '0' AND f.WORK_LONGITUDE IS NOT NULL AND f.WORK_LATITUDE IS NOT NULL
		AND f.APPLY_STATUS not in ('-99','8','-98','-2','-4','-5','-6','-7','-8')
		<if test="CORPINFO_ID!= null and CORPINFO_ID!=''">
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="ids!= null and ids.size()>0">
			AND  f.CORPINFO_ID IN
			<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>


	<!-- 通过ID获取数据 -->
	<select id="findByELECTRICTITYAcceptuserId" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.ELECTRICITY_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID
		from
		bus_ELECTRICITY_ACCEPTUSER f
		where
		f.ELECTRICITY_ID = #{ELECTRICITY_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_USER_ID = #{ACCEPT_USER_ID}
		order by f.ACCEPT_USER_SIGNER_TIME asc
	</select>

	<select id="findByELECTRICTITYAcceptuserIds" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.ELECTRICITY_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME
		from
		bus_ELECTRICITY_ACCEPTUSER f
		where
		f.ELECTRICITY_ID = #{ELECTRICITY_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_CONFESS_USER_ID = #{ACCEPT_CONFESS_USER_ID}
		order by f.ACCEPT_CONFESS_USER_SIGNER_TIME asc
	</select>

	<!-- 通过ID获取数据 -->
	<select id="findByBLINDBOARDAcceptuserId" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.BLINDBOARD_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID
		from
		bus_BLINDBOARD_ACCEPTUSER f
		where
		f.BLINDBOARD_ID = #{BLINDBOARD_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_USER_ID = #{ACCEPT_USER_ID}
		order by f.ACCEPT_USER_SIGNER_TIME ASC
	</select>
	<select id="findByBLINDBOARDAcceptuserIds" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.BLINDBOARD_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME
		from
		bus_BLINDBOARD_ACCEPTUSER f
		where
		f.BLINDBOARD_ID = #{BLINDBOARD_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_CONFESS_USER_ID = #{ACCEPT_CONFESS_USER_ID}
		order by f.ACCEPT_CONFESS_USER_SIGNER_TIME ASC
	</select>

	<!-- 通过ID获取数据 -->
	<select id="findByCUTROADAcceptuserId" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.CUTROAD_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID
		from
		bus_CUTROAD_ACCEPTUSER f
		where
		f.CUTROAD_ID = #{CUTROAD_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_USER_ID = #{ACCEPT_USER_ID}
		order by f.ACCEPT_USER_SIGNER_TIME asc
	</select>
	<select id="findByCUTROADAcceptuserIds" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.CUTROAD_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME
		from
		bus_CUTROAD_ACCEPTUSER f
		where
		f.CUTROAD_ID = #{CUTROAD_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_CONFESS_USER_ID = #{ACCEPT_CONFESS_USER_ID}
		order by f.ACCEPT_CONFESS_USER_SIGNER_TIME asc
	</select>

	<!-- 通过ID获取数据 -->
	<select id="findByBREAKGROUNDAcceptuserId" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.BREAKGROUND_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID
		from
		bus_BREAKGROUND_ACCEPTUSER f
		where
		f.BREAKGROUND_ID = #{BREAKGROUND_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_USER_ID = #{ACCEPT_USER_ID}
		order by f.ACCEPT_USER_SIGNER_TIME ASC
	</select>
	<select id="findByBREAKGROUNDAcceptuserIds" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.BREAKGROUND_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME
		from
		bus_BREAKGROUND_ACCEPTUSER f
		where
		f.BREAKGROUND_ID = #{BREAKGROUND_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_CONFESS_USER_ID = #{ACCEPT_CONFESS_USER_ID}
		order by f.ACCEPT_CONFESS_USER_SIGNER_TIME ASC
	</select>

	<!-- 通过ID获取数据 -->
	<select id="findByHIGHWORKAcceptuserId" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.HIGHWORK_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID
		from
		bus_HIGHWORK_ACCEPTUSER f
		where
		f.HIGHWORK_ID = #{HIGHWORK_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_USER_ID = #{ACCEPT_USER_ID}
		order by f.ACCEPT_USER_SIGNER_TIME asc
	</select>
	<select id="findByHIGHWORKAcceptuserIds" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.HIGHWORK_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME
		from
		bus_HIGHWORK_ACCEPTUSER f
		where
		f.HIGHWORK_ID = #{HIGHWORK_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_CONFESS_USER_ID = #{ACCEPT_CONFESS_USER_ID}
		order by f.ACCEPT_CONFESS_USER_SIGNER_TIME asc
	</select>

	<!-- 通过ID获取数据 -->
	<select id="findByHOISTINGAcceptuserId" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.HOISTING_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID
		from
		bus_HOISTING_ACCEPTUSER f
		where
		f.HOISTING_ID = #{HOISTING_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_USER_ID = #{ACCEPT_USER_ID}
		order by f.ACCEPT_USER_SIGNER_TIME asc
	</select>
	<select id="findByHOISTINGAcceptuserIds" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.HOISTING_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME
		from
		bus_HOISTING_ACCEPTUSER f
		where
		f.HOISTING_ID = #{HOISTING_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_CONFESS_USER_ID = #{ACCEPT_CONFESS_USER_ID}
		order by f.ACCEPT_CONFESS_USER_SIGNER_TIME asc
	</select>

	<select id="findByIdCONFINEDSPACEOrder" parameterType="pd" resultType="pd">
		select
		f.CORPINFO_ID,
		f.ISDELETE,
		f.CREATTIME,
		f.CREATOR,
		f.OPERATTIME,
		f.OPERATOR,
		f.CHECK_NO,
		f.WORK_CONTENT,
		replace(f.WORK_START_DATE,'-','/') as WORK_START_DATE,
		replace(f.WORK_END_DATE,'-','/') as WORK_END_DATE,
		f.CONFIRM_DEPARTMENT_ID,
		f.CONFIRM_USER_ID,
		f.CONFIRM_USER_SIGNER_PATH,
		f.CONFIRM_USER_SIGNER_TIME,
		f.AUDIT_DEPARTMENT_ID,
		f.AUDIT_USER_ID,
		f.AUDIT_USER_SIGNER_PATH,
		f.AUDIT_USER_SIGNER_TIME,
		f.APPROVE_DEPARTMENT_ID,
		f.APPROVE_USER_ID,
		f.APPROVE_USER_SIGNER_PATH,
		f.APPROVE_USER_SIGNER_TIME,
		f.APPLY_STATUS,
		IFNULL(f.CONFIRM_CONTENT,'无') as CONFIRM_CONTENT,
		IFNULL(f.AUDIT_CONTENT,'无') as AUDIT_CONTENT,
		IFNULL(f.APPROVE_CONTENT,'无') as APPROVE_CONTENT,
		f.OTHER_PROTECTIVE_MEASURES,
		f.ACCEPT_DEPARTMENT_ID,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		IFNULL(f.ACCEPT_CONTENT,'无') as ACCEPT_CONTENT,
		f.APPLY_DEPARTMENT_ID,
		f.APPLY_USER_ID,
		f.BELONG_CORP,
		f.LIMITSPACE_ID,
		f.WORK_USER,
		IFNULL(f.SPECIAL_WORK,'无') as SPECIAL_WORK,
		f.RISK_IDENTIFICATION,
		f.MEDIUM_NAME,
		f.EDUCATE_USER,
		f.ANALYZE_DEPARTMENT_ID,
		f.ANALYZE_USER_ID,
		f.GUARDIAN_DEPARTMENT_ID,
		f.GUARDIAN_USER_ID,
		f.GUARDIAN_USER_SIGNER_PATH,
		f.GUARDIAN_USER_SIGNER_TIME,
		IFNULL(f.GUARDIAN_CONTENT,'无') as GUARDIAN_CONTENT,
		f.CONFESS_USER,
		f.ACCEPT_CONFESS_USER,
		f.GUARDIAN_USER,
		f.CONFINEDSPACE_ID,
		f.CONFESS_DEPARTMENT_ID,
		f.CONFESS_USER_ID,
		f.CONFESS_USER_SIGNER_PATH,
		f.CONFESS_USER_SIGNER_TIME,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME,
		f.WORK_LATITUDE,
		f.WORK_LONGITUDE,
		(SELECT replace(a.ANALYZE_TIME,'-','/') from bus_CONFINEDSPACEGAS a where a.ISDELETE = '0'
		AND a.CONFINEDSPACE_ID = f.CONFINEDSPACE_ID
		ORDER BY
		a.ANALYZE_TIME DESC LIMIT 1) as ANALYZE_TIME,
		sp.NAME as LIMITSPACE_NAME,

		ad.NAME as APPLY_DEPARTMENT_NAME,
		au.NAME as APPLY_USER_NAME,

		cd.NAME as CONFIRM_DEPARTMENT_NAME,
		cu.NAME as CONFIRM_USER_NAME,

		gd.NAME as GUARDIAN_DEPARTMENT_NAME,
		gu.NAME as GUARDIAN_USER_NAME,

		aud.NAME as AUDIT_DEPARTMENT_NAME,
		auu.NAME as AUDIT_USER_NAME,

		apd.NAME as APPROVE_DEPARTMENT_NAME,
		apu.NAME as APPROVE_USER_NAME,

		acd.NAME as ACCEPT_DEPARTMENT_NAME,
		acu.NAME as ACCEPT_USER_NAME,

		anad.NAME as ANALYZE_DEPARTMENT_NAME,
		anau.NAME as ANALYZE_USER_NAME,

		ac.NAME as CONFESS_DEPARTMENT_NAME,
		accu.NAME as CONFESS_USER_NAME,

		aac.NAME as ACCEPT_CONFESS_DEPARTMENT_NAME,
		aacu.NAME as ACCEPT_CONFESS_USER_NAME
		from
		bus_CONFINEDSPACE f
		left join bus_confinedspacegaswh b on b.CONFINEDSPACE_ID = f.CONFINEDSPACE_ID
		left join bus_LIMITSPACE sp on sp.LIMITSPACE_ID=f.LIMITSPACE_ID

		left join OA_DEPARTMENT aac on aac.DEPARTMENT_ID = f.ACCEPT_CONFESS_DEPARTMENT_ID
		left join SYS_USER aacu on aacu.USER_ID = f.ACCEPT_CONFESS_USER_ID

		left join OA_DEPARTMENT ac on ac.DEPARTMENT_ID = f.CONFESS_DEPARTMENT_ID
		left join SYS_USER accu on accu.USER_ID = f.CONFESS_USER_ID

		left join OA_DEPARTMENT ad on ad.DEPARTMENT_ID = f.APPLY_DEPARTMENT_ID
		left join SYS_USER au on au.USER_ID = f.APPLY_USER_ID

		left join OA_DEPARTMENT cd on cd.DEPARTMENT_ID = f.CONFIRM_DEPARTMENT_ID
		left join SYS_USER cu on cu.USER_ID = f.CONFIRM_USER_ID

		left join OA_DEPARTMENT gd on gd.DEPARTMENT_ID = f.GUARDIAN_DEPARTMENT_ID
		left join SYS_USER gu on gu.USER_ID = f.GUARDIAN_USER_ID

		left join OA_DEPARTMENT aud on aud.DEPARTMENT_ID = f.AUDIT_DEPARTMENT_ID
		left join SYS_USER auu on auu.USER_ID = f.AUDIT_USER_ID

		left join OA_DEPARTMENT apd on apd.DEPARTMENT_ID = f.APPROVE_DEPARTMENT_ID
		left join SYS_USER apu on apu.USER_ID = f.APPROVE_USER_ID

		left join OA_DEPARTMENT acd on acd.DEPARTMENT_ID = f.ACCEPT_DEPARTMENT_ID
		left join SYS_USER acu on acu.USER_ID = f.ACCEPT_USER_ID

		left join OA_DEPARTMENT anad on anad.DEPARTMENT_ID = f.ANALYZE_DEPARTMENT_ID
		left join SYS_USER anau on anau.USER_ID = f.ANALYZE_USER_ID
		where
		f.CONFINEDSPACE_ID = #{CONFINEDSPACE_ID}
	</select>

	<select id="listAllMeasuresCONFINEDSPACEOrder"  parameterType="pd" resultType="pd">
		select
		f.*
		,eo.CONFIRM_NAME as CONFIRM_NAME
		,eo.STATUS,eo.ANSWER1,eo.ANSWER2,eo.ANSWER3
		from
		bus_CONFINEDSPACE_MEASURES f
		left join bus_CONFINEDSPACETOMEASURES eo on eo.BUS_CONFINEDSPACE_MEASURES_ID = f.BUS_CONFINEDSPACE_MEASURES_ID
		where f.ISDELETE = '0'
		and eo.CONFINEDSPACE_ID = #{CONFINEDSPACE_ID}
		ORDER BY f.ORDER
	</select>

	<select id="listAllCONFINEDSPACEOrder" parameterType="pd" resultType="pd">
		select
		f.CONFINEDSPACE_ID,
		f.ANALYZE_TIME,
		f.ANALYZE_PLACE,
		f.ANALYZE_USER,
		f.HARMFUL_MATERIALS,
		f.COMBUSTIBLE_GAS,
		f.OXYGEN_CONTENT,
		f.ISDELETE,
		f.DATA1,
		f.DATA2,
		f.DATA3,
		f.DATA4,
		f.CONFINEDSPACEGAS_ID
		from
		bus_CONFINEDSPACEGAS f
		where f.ISDELETE = '0' and f.CONFINEDSPACE_ID = #{CONFINEDSPACE_ID}
		ORDER BY f.ANALYZE_TIME desc
	</select>


	<!-- 通过ID获取数据 -->
	<select id="findByIdCONFINEDSPACEAcceptuser" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.CONFINEDSPACE_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_USER_ID,
		f.ACCEPT_USER_SIGNER_PATH,
		f.ACCEPT_USER_SIGNER_TIME,
		f.ACCEPT_DEPARTMENT_ID
		from
		bus_CONFINEDSPACE_ACCEPTUSER f
		where
		f.CONFINEDSPACE_ID = #{CONFINEDSPACE_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_USER_ID = #{ACCEPT_USER_ID}
		order by f.ACCEPT_USER_SIGNER_TIME ASC
	</select>
	<select id="findByIdCONFINEDSPACEAcceptusers" parameterType="pd" resultType="pd">
		select
		f.ACCEPT_CONFESS_ID,
		f.CONFINEDSPACE_ID,
		f.CORPINFO_ID,
		f.ISDELETE,
		f.OPERATTIME,
		f.OPERATOR,
		f.ACCEPT_CONFESS_DEPARTMENT_ID,
		f.ACCEPT_CONFESS_USER_ID,
		f.ACCEPT_CONFESS_USER_SIGNER_PATH,
		f.ACCEPT_CONFESS_USER_SIGNER_TIME
		from
		bus_CONFINEDSPACE_ACCEPTUSER f
		where
		f.CONFINEDSPACE_ID = #{CONFINEDSPACE_ID} and f.CORPINFO_ID = #{CORPINFO_ID} and f.ACCEPT_CONFESS_USER_ID = #{ACCEPT_CONFESS_USER_ID}
		order by f.ACCEPT_CONFESS_USER_SIGNER_TIME ASC
	</select>

	<!-- 通过ID获取气体检测数据 -->
	<select id="findByIdCONFINEDSPACEGasWH" parameterType="pd" resultType="pd">
		select
		f.CONFINEDSPACE_ID,
		f.GAS_NAME1,
		f.GAS_STANDARD1,
		f.GAS_NAME2,
		f.GAS_STANDARD2,
		f.GAS_NAME3,
		f.GAS_STANDARD3,
		f.GAS_NAME4,
		f.GAS_STANDARD4,
		f.CONFINEDSPACEGASWH_ID,
		f.OPERATTIME
		from
		bus_CONFINEDSPACEGASWH f
		where
		f.CONFINEDSPACE_ID = #{CONFINEDSPACE_ID}
	</select>
</mapper>
