<?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.nantian.cloud.jljc.mapper.TSuperviseTaskMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.TSuperviseTask">
        <id column="id" property="id"/>
        <result column="industry" property="industry"/>
        <result column="locate" property="locate"/>
        <result column="monitor_id" property="monitorId"/>
        <result column="monitored_ent" property="monitoredEnt"/>
        <result column="task_name" property="taskName"/>
        <result column="task_state" property="taskState"/>
        <result column="inspectors" property="inspectors"/>
        <result column="address" property="address"/>
        <result column="postcode" property="postcode"/>
        <result column="date" property="date"/>
        <result column="userid" property="userid"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="dept_id" property="deptId"/>
        <result column="type" property="type"/>
        <result column="notification" property="notification"/>
        <result column="select_capacity" property="selectCapacity"/>
        <result column="comprehensive_energy" property="comprehensiveEnergy"/>
        <result column="unit_energy" property="unitEnergy"/>
        <result column="insite_supervision" property="insiteSupervision"/>
        <result column="interview_transcripts" property="interviewTranscripts"/>
        <result column="epc" property="epc"/>
        <result column="remark" property="remark"/>
        <result column="inspectorsid" property="inspectorsid"/>
        <result column="source" property="source"/>
        <result column="note" property="note"/>
        <result column="organization_id" property="organizationId"/>
        <result column="tce" property="tce"/>
        <result column="task_handle" property="taskHandle"/>
        <result column="task_transmit" property="taskTransmit"/>
        <result column="scene_file" property="sceneFile"/>
        <result column="year" property="year"/>

        <result column="industry_name" property="industryName"/>
        <result column="locate_name" property="locateName"/>
        <result column="group_leader" property="groupLeader"/>
        <result column="time_limit" property="timeLimit"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, industry, locate, monitor_id, monitored_ent, task_name, task_state, inspectors, address, postcode, date,
        userid, update_time, del_flag, dept_id, type, notification, select_capacity, comprehensive_energy, unit_energy,
        insite_supervision, interview_transcripts, epc, remark, inspectorsid, source,year, note, organization_id, tce,
         task_handle, task_transmit, scene_file,group_leader,time_limit
    </sql>

    <select id="getPageCom" resultType="com.nantian.cloud.jljc.entity.EnterpriseInfo">
        select  e.*, d.meaning as regionName, t.name_samr as typeName, k.name as industryName, l.level as energyConsumeLevelName,
                case e.field_code
                when '100' then '工业'
                when '200' then '交通运输、仓储和邮政业'
                when '300' then '住宿和餐饮业'
                when '400' then '批发和零售业'
                when '500' then '教育'
                else '其他' end AS fieldName,
                (select industry from t_supervise_task where e.enterprise_code = epc order by id desc limit 0,1) productIndustry
        from enterprise_info e
        left join dict_region d on d.id=e.region_code
        left join dict_enterprise_type t on t.id=e.type_code
        left join trade_kind k on k.code=e.industry_code
        left join energy_level l on l.id=e.energy_consume_level
        where e.del_flag='1'
        <if test="query.code != null and query.code != '' ">
            and e.enterprise_code = #{query.code}
        </if>
        <if test="query.name != null and query.name != '' ">
            and e.cmp_name like concat("%",#{query.name},"%")
        </if>
        <if test="query.area != null and query.area != '' ">
            and e.region_code like concat("%",#{query.area},"%")
        </if>
        <if test="query.industry != null and query.industry != '' ">
            and e.industry_code = #{query.industry}
        </if>
    </select>

    <!--    TSuperviseTask  企业名称monitoredEnt、企业信用代码epc、行业industry、地区locate、监察编号monitorId、任务名称taskName、任务状态taskState-->
    <!--    查询条件Query （企业名称name、企业信用编码code、地区pArea area、行业pIndustry industry、监察编号num、任务名称item、任务状态state）-->
    <select id="getPageScope" resultType="com.nantian.cloud.jljc.vo.TSuperviseTaskOrganizationVo">
        select distinct tt.id, tt.industry, tt.locate, tt.monitor_id, tt.monitored_ent, tt.task_name, tt.task_state, tt.inspectorsid, tt.inspectors, tt.address,
        tt.postcode, tt.date,tt.userid, tt.update_time, tt.del_flag, tt.dept_id, tt.type, tt.select_capacity, tt.unit_energy,
        tt.insite_supervision, tt.interview_transcripts, tt.note, tt.notification, tt.comprehensive_energy, tt.source, tt.scene_file,tt.group_leader,
        case when tt.insite_supervision != '' or f1>0 then 'true' else 'false' end inspectionStatus,
        case when tt.interview_transcripts != ''or f2>0 then 'true' else 'false' end investigationStatus,
        case when tt.note != '' or f3>0 then 'true' else 'false' end noteStatus,
        case when tt.notification != '' or f4>0 then 'true' else 'false' end notificationStatus,
        case when f5>0 then 'true' else 'false' end comprehensiveEnergyStatus,
        tt.epc, tt.remark, tt.locateName, tt.industryName, tt.organization_id, tt.tce, tt.task_handle, tt.task_transmit,
        tt.organizationName, tt.organizationCode, tt.organizationAreaCode, tt.organizationAreaName,tt.organizationState, tt.organizationRemarks,
        tt.organizationAddress, tt.organizationFax,tt.organizationPostcode, tt.organizationContact, tt.organizationTelephone, tt.report_type
        from(
            select substring(t.monitor_id,6,4) tyear, t.id, t.industry, t.locate, t.monitor_id, t.monitored_ent, t.task_name, t.task_state, t.inspectorsid, t.inspectors, t.address,
            t.postcode, t.date,t.userid, t.update_time, t.del_flag, t.dept_id, t.type, t.source, t.scene_file,t.group_leader,t.report_type,
            IFNULL(t.select_capacity,'') as select_capacity, IFNULL( t.unit_energy,'') as unit_energy, IFNULL(t.insite_supervision,'') as insite_supervision,
            IFNULL(t.interview_transcripts,'') as interview_transcripts, IFNULL(t.note,'') as note, IFNULL(t.notification,'') as notification, IFNULL(t.comprehensive_energy,'') as comprehensive_energy,
            t.epc, t.remark, d.meaning as locateName, k.name as industryName, t.organization_id, t.tce, t.task_handle, t.task_transmit,
            o.name as organizationName, o.code as organizationCode, o.area_code as organizationAreaCode, od.meaning as organizationAreaName,
            o.state as organizationState, o.remarks as organizationRemarks, o.address as organizationAddress, o.fax as organizationFax,
            o.postcode as organizationPostcode, o.contact as organizationContact, o.telephone as organizationTelephone,
            (select count(*) from t_supervision_inspection where monitor_id = t.monitor_id)f1,
            (select count(*) from t_supervision_investigation where monitor_id = t.monitor_id)f2,
            (select count(*) from t_supervision_note where monitor_id = t.monitor_id)f3,
            (select count(*) from t_supervision_notification where monitor_id = t.monitor_id)f4,
            (select count(*) from t_supervision_comprehensive_energy where monitor_id = t.monitor_id)f5
            from t_supervise_task t
            left join dict_region d on d.id=t.locate
            left join trade_kind k on k.code=t.industry
            left join t_supervision_organization o on t.organization_id = o.id and o.del_flag = "1"
            left join dict_region od on o.area_code = od.id
            where t.del_flag = "1"
            <if test="query.id != null and query.id != ''">
                and t.inspectorsid = concat("%",#{query.id},"%")
            </if>
            <if test="query.industry != null and query.industry != ''">
                and t.industry = #{query.industry}
            </if>
            <if test="query.area != null and query.area != ''">
                and t.locate like concat("%",#{query.area},"%")
            </if>
            <if test="query.num != null and query.num != ''">
                and t.monitor_id like concat("%",#{query.num},"%")
            </if>
            <if test="query.year != null and query.year != ''">
                and t.monitor_id like concat("%",#{query.year},"%")
            </if>
            <if test="query.name != null and query.name != ''">
                and t.monitored_ent like concat("%",#{query.name},"%")
            </if>
            <if test="query.code != null and query.code != ''">
                and t.epc = #{query.code}
            </if>
            <if test="query.item != null and query.item != ''">
                and t.task_name like concat("%",#{query.item},"%")
            </if>
            <if test="query.source != null and query.source != ''">
                and t.source like concat("%",#{query.source},"%")
            </if>
            <if test="query.state != null and query.state != ''">
                and t.task_state = #{query.state}
            </if>
            <if test="query.type != null and query.type != ''">
                and t.type = #{query.type}
            </if>
            order by t.id desc
        ) tt
    </select>

    <!-- 企业端   TSuperviseTask  企业名称monitoredEnt、企业信用代码epc、行业industry、地区locate、监察编号monitorId、任务名称taskName、任务状态taskState-->
    <!--    查询条件Query （企业名称name、企业信用编码code、地区pArea area、行业pIndustry industry、监察编号num、任务名称item、任务状态state）-->
    <select id="getTSuperviseTask" resultType="com.nantian.cloud.jljc.vo.TSuperviseTaskOrganizationVo">
        select  tt.id, tt.industry, tt.locate, tt.monitor_id, tt.monitored_ent, tt.task_name, tt.task_state, tt.inspectorsid, tt.inspectors, tt.address,
        tt.postcode, tt.date,tt.userid, tt.update_time, tt.del_flag, tt.dept_id, tt.type, tt.select_capacity, tt.unit_energy,
        tt.insite_supervision, tt.interview_transcripts, tt.note, tt.notification, tt.comprehensive_energy, tt.source, tt.scene_file, tt.group_leader,
        case when tt.insite_supervision != '' or f1>0 then 'true' else 'false' end inspectionStatus,
        case when tt.interview_transcripts != ''or f2>0 then 'true' else 'false' end investigationStatus,
        case when tt.note != '' or f3>0 then 'true' else 'false' end noteStatus,
        case when tt.notification != '' or f4>0 then 'true' else 'false' end notificationStatus,
        case when f5>0 then 'true' else 'false' end comprehensiveEnergyStatus,
        tt.epc, tt.remark, tt.locateName, tt.industryName, tt.organization_id, tt.tce, tt.task_handle, tt.task_transmit,
        tt.organizationName, tt.organizationCode, tt.organizationAreaCode, tt.organizationAreaName,tt.organizationState, tt.organizationRemarks,
        tt.organizationAddress, tt.organizationFax,tt.organizationPostcode, tt.organizationContact, tt.organizationTelephone
        from(
            select substring(t.monitor_id,6,4) tyear, t.id, t.industry, t.locate, t.monitor_id, t.monitored_ent, t.task_name, t.task_state, t.inspectorsid, t.inspectors, t.address,
            t.postcode, t.date,t.userid, t.update_time, t.del_flag, t.dept_id, t.type, t.source, t.scene_file,
            IFNULL(t.select_capacity,'') as select_capacity, IFNULL( t.unit_energy,'') as unit_energy, IFNULL(t.insite_supervision,'') as insite_supervision,
            IFNULL(t.interview_transcripts,'') as interview_transcripts, IFNULL(t.note,'') as note, IFNULL(t.notification,'') as notification, IFNULL(t.comprehensive_energy,'') as comprehensive_energy,
            t.epc, t.remark, d.meaning as locateName, k.name as industryName, t.organization_id, t.tce, t.task_handle, t.task_transmit,t.group_leader,
            o.name as organizationName, o.code as organizationCode, o.area_code as organizationAreaCode, od.meaning as organizationAreaName,
            o.state as organizationState, o.remarks as organizationRemarks, o.address as organizationAddress, o.fax as organizationFax,
            o.postcode as organizationPostcode, o.contact as organizationContact, o.telephone as organizationTelephone,
            (select count(*) from t_supervision_inspection where monitor_id = t.monitor_id)f1,
            (select count(*) from t_supervision_investigation where monitor_id = t.monitor_id)f2,
            (select count(*) from t_supervision_note where monitor_id = t.monitor_id)f3,
            (select count(*) from t_supervision_notification where monitor_id = t.monitor_id)f4,
            (select count(*) from t_supervision_comprehensive_energy where monitor_id = t.monitor_id)f5
            from t_supervise_task t
            left join dict_region d on d.id=t.locate
            left join trade_kind k on k.code=t.industry
            left join t_supervision_organization o on t.organization_id = o.id and o.del_flag = "1"
            left join dict_region od on o.area_code = od.id
            where t.del_flag = "1"
            <if test="query.industry != null and query.industry != ''">
                and t.industry = #{query.industry}
            </if>
            <if test="query.area != null and query.area != ''">
                and t.locate = #{query.area}
            </if>
            <if test="query.num != null and query.num != ''">
                and t.monitor_id like concat("%",#{query.num},"%")
            </if>
            <if test="query.name != null and query.name != ''">
                and t.monitored_ent like concat("%",#{query.name},"%")
            </if>
            <if test="query.code != null and query.code != ''">
                and t.epc = #{query.code}
            </if>
            <if test="query.item != null and query.item != ''">
                and t.task_name like concat("%",#{query.item},"%")
            </if>
            <if test="query.source != null and query.source != ''">
                and t.source like concat("%",#{query.source},"%")
            </if>
            <if test="query.state != null and query.state != ''">
                and t.task_state = #{query.state}
            </if>
            <if test="query.type != null and query.type != ''">
                and t.type = #{query.type}
            </if>
            order by t.update_time desc
        ) tt order by tt.tyear desc
    </select>

    <select id="haveTaskRelease" resultType="com.nantian.cloud.jljc.entity.TSuperviseTask">
        select
        <include refid="Base_Column_List"></include>
        from t_supervise_task
        where del_flag = "1" and task_state in (1,2) and type = '1' and epc = #{epc}
    </select>

    <select id="getTaskById" resultType="com.nantian.cloud.jljc.vo.TSuperviseTaskOrganizationVo">
         select t.id, t.industry, t.locate, t.monitor_id, t.monitored_ent,t.year, t.task_name, t.task_state, t.inspectorsid, t.inspectors, t.address, t.source, t.scene_file,t.group_leader,t.time_limit,
                t.postcode, t.date,t.userid, t.update_time, t.del_flag, t.dept_id, t.type, IFNULL(t.notification,'') as notification, IFNULL(t.select_capacity,'') as select_capacity,
                IFNULL(t.comprehensive_energy,'') as comprehensive_energy,IFNULL( t.unit_energy,'') as unit_energy, IFNULL(t.insite_supervision,'') as insite_supervision, IFNULL(t.interview_transcripts,'') as interview_transcripts,
                t.epc, t.remark, d.meaning as locateName, k.name as industryName, t.organization_id, t.tce, IFNULL(t.note,'') as note, t.task_handle, t.task_transmit,
                o.name as organizationName, o.code as organizationCode, o.area_code as organizationAreaCode, od.meaning as organizationAreaName,
                o.state as organizationState, o.remarks as organizationRemarks, o.address as organizationAddress, o.fax as organizationFax,
                o.postcode as organizationPostcode, o.contact as organizationContact, o.telephone as organizationTelephone
        from t_supervise_task t
        left join dict_region d on d.id=t.locate
        left join trade_kind k on k.code=t.industry
        left join t_supervision_organization o on t.organization_id = o.id
        left join dict_region od on o.area_code = od.id
        where t.id = #{id}
    </select>
    <update id="updateTask" parameterType="com.nantian.cloud.jljc.entity.TSuperviseTask">
        update t_supervise_task
        <set>
            <if test="notification != null and notification !=''">`notification` ='', </if>
            <if test="insiteSupervision != null and insiteSupervision !=''">`insite_supervision` ='', </if>
            <if test="interviewTranscripts != null and interviewTranscripts !=''">`interview_transcripts` ='', </if>
            <if test="note != null and note !=''">`note` ='', </if>
            <if test="sceneFile != null and sceneFile !=''">`scene_file` ='', </if>
        </set>
        where id=#{id}
    </update>


    <!--工业硅-->
    <select id="getSuperviseTaskSummary1" resultType="java.util.Map">
        select  tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.limitStandard, tt.calculationResults, tt.evaluate, tt.remark
        from(
            select  DISTINCT IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,0) as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce, IFNULL(e1.product_name,'') as productName,IFNULL(i.production ,'') as production,
            IFNULL(e2.unit_product_limit_standard,'') as limitStandard, IFNULL(e2.calculation_results,'') as calculationResults,
            case when e2.calculation_results is null then '' when CONVERT(e2.calculation_results,DECIMAL(10,4)) > CONVERT(e2.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end evaluate,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.pid = e1.id and e2.code = #{query.id}
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = #{query.id}
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.calculationResults != ''
    </select>


    <!-- 粉磨站、熟料、水泥(全流程)一定会有的数据是电力消耗量；最后拿电力消耗量进行筛选-->
    <select id="getSuperviseTaskSummary2" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity,tt.r1, tt.r2, tt.r3, tt.r4, tt.cr1, tt.ev1, tt.cr2, tt.ev2, tt.cr3, tt.ev3, tt.cr4, tt.ev4, tt.cr5, tt.ev5,
        tt.limit1, tt.limit2, tt.limit3, tt.limit4, tt.limit5, tt.remark
        from(
            select DISTINCT IFNULL(e0.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e11.design_capacity,'') as designCapacity,
            IFNULL(ROUND(i1.calculation_results/10000,4),'') as r1,IFNULL(ROUND(i2.calculation_results/10000,4),'') as r2,
            IFNULL(i3.calculation_results,0)+IFNULL(i4.calculation_results,0) as r3, IFNULL(ROUND(i5.calculation_results/10000,4),'') as r4,
            IFNULL(e1.calculation_results,'') as cr1, case when e1.calculation_results is null then '' when CONVERT(e1.calculation_results,DECIMAL(10,4)) > CONVERT(e1.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end ev1,
            IFNULL(e2.calculation_results,'') as cr2, case when e2.calculation_results is null then '' when CONVERT(e2.calculation_results,DECIMAL(10,4)) > CONVERT(e2.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end ev2,
            IFNULL(e3.calculation_results,'') as cr3, case when e3.calculation_results is null then '' when CONVERT(e3.calculation_results,DECIMAL(10,4)) > CONVERT(e3.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end ev3,
            IFNULL(e4.calculation_results,'') as cr4, case when e4.calculation_results is null then '' when CONVERT(e4.calculation_results,DECIMAL(10,4)) > CONVERT(e4.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end ev4,
            IFNULL(e5.calculation_results,'') as cr5, case when e5.calculation_results is null then '' when CONVERT(e5.calculation_results,DECIMAL(10,4)) > CONVERT(e5.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end ev5,
            IFNULL(e1.unit_product_limit_standard,'') as limit1, IFNULL(e2.unit_product_limit_standard,'') as limit2, IFNULL(e3.unit_product_limit_standard,'') as limit3,
            IFNULL(e4.unit_product_limit_standard,'') as limit4, IFNULL(e5.unit_product_limit_standard,'') as limit5,
            <![CDATA[ case when e0.year like '%&%' then concat('监察周期为：',replace(e0.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e11 on e11.monitor_id = t.monitor_id and e11.del_flag = "1" and e11.tce = "0" and e11.code = #{query.id2}
            left join t_supervision_unit_energy e0 on e0.monitor_id = t.monitor_id and e0.del_flag = "1" and e0.tce = "0" and e0.code = #{query.id}
            left join t_supervision_unit_item i1 on i1.unit_energy_id = e0.id and i1.del_flag = "1" and i1.tce="2" and i1.old_code like 'PCL' and i1.codes = #{query.id}
            left join t_supervision_unit_item i2 on i2.unit_energy_id = e0.id and i2.del_flag = "1" and i2.tce="2" and i2.old_code like 'PC'  and i2.codes = #{query.id}
            left join t_supervision_unit_item i3 on i3.unit_energy_id = e0.id and i3.del_flag = "1" and i3.tce="2" and i3.old_code like 'qcl' and i3.codes = #{query.id}
            left join t_supervision_unit_item i4 on i4.unit_energy_id = e0.id and i4.del_flag = "1" and i4.tce="2" and i4.old_code like 'qc'  and i4.codes = #{query.id}
            left join t_supervision_unit_item i5 on i5.unit_energy_id = e0.id and i5.del_flag = "1" and i5.tce="2" and i5.old_code like 'ecl' and i5.codes = #{query.id}
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "1" and e1.old_code like 'ekcl' and e1.code =  #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code like 'QKCL' and e2.code =  #{query.id}
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code like 'QKS'  and e3.code =  #{query.id}
            left join t_supervision_unit_energy e4 on e4.monitor_id = t.monitor_id and e4.del_flag = "1" and e4.tce = "1" and e4.old_code like 'EKCL' and e4.code =  #{query.id}
            left join t_supervision_unit_energy e5 on e5.monitor_id = t.monitor_id and e5.del_flag = "1" and e5.tce = "1" and e5.old_code like 'EKS'  and e5.code =  #{query.id}
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e0.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.r3 != 0
    </select>


    <!--建筑卫陶-->
    <select id="getSuperviseTaskSummary3" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.production, tt.productName, tt.limitStandard, tt.calculationResults, tt.evaluate, tt.remark
        from(
            select DISTINCT IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,0) as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce, IFNULL(i1.production,'') as production, IFNULL(e1.product_name,'') as productName,
            IFNULL(e2.unit_product_limit_standard,'') as limitStandard, IFNULL(e2.calculation_results,'') as calculationResults,
            case  when e2.calculation_results is null then '' when CONVERT(e2.calculation_results,DECIMAL(10,4)) >  CONVERT(e2.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end evaluate,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.code = #{query.id}
            left join t_supervision_unit_item i1 on i1.unit_energy_id = e1.id and i1.del_flag = "1" and i1.tce="2" and i1.codes = #{query.id}
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.designCapacity != 0
    </select>


    <!--黄磷-->
    <select id="getSuperviseTaskSummary4_1" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.m1, tt.r1, tt.m2, tt.r2, tt.m3, tt.r3,
        case when (tt.r1 is null and tt.r2 is null and tt.r3 is null) then '' when (tt.r1 = '' and tt.r2 ='' and tt.r3 ='') then ''
        when (CONVERT(tt.r1,DECIMAL(10,4)) > CONVERT(tt.m1,DECIMAL(10,4)) or CONVERT(tt.r2,DECIMAL(10,4)) > CONVERT(tt.m2,DECIMAL(10,4)) or CONVERT(tt.r3,DECIMAL(10,4)) > CONVERT(tt.m3,DECIMAL(10,4))) then '2' else '1' end evaluate, remark
        from (
            select  DISTINCT IFNULL(e0.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName,
            IFNULL(e0.design_capacity,0) as designCapacity,IFNULL(e0.unit_product_energy,'') as tce,IFNULL(q.annotation,'') as productName,
            case when i.production != '/' then i.production when i.calculation_results != '/' then i.calculation_results else '' end production,
            case when e1.unit_product_limit_standard is not null then e1.unit_product_limit_standard when e2.unit_product_limit_standard is not null then e2.unit_product_limit_standard when e3.unit_product_limit_standard is not null then e3.unit_product_limit_standard else '' end m1,
            case when e1.calculation_results is not null then e1.calculation_results when e2.calculation_results is not null then e2.calculation_results when e3.calculation_results is not null then e3.calculation_results else '' end r1,
            IFNULL(e4.unit_product_limit_standard,'') as m2, IFNULL(e4.calculation_results,'') as r2,
            IFNULL(e5.unit_product_limit_standard,'') as m3, IFNULL(e5.calculation_results,'') as r3,
            <![CDATA[ case when e0.year like '%&%' then concat('监察周期为：',replace(e0.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e0 on e0.monitor_id = t.monitor_id and e0.del_flag = "1" and e0.tce = "0" and e0.code = #{query.id}
            left join t_supervision_unit_item i on i.unit_energy_id = e0.id and i.del_flag = "1" and i.tce="2" and i.codes = #{query.id}
            left join t_supervision_quota q on q.code = #{query.id}
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "1" and e1.old_code = 'EPZD' and e1.code = #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'E1'   and e2.code = #{query.id}
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'E2'   and e3.code = #{query.id}
            left join t_supervision_unit_energy e4 on e4.monitor_id = t.monitor_id and e4.del_flag = "1" and e4.tce = "1" and e4.old_code = 'QPZD' and e4.code = #{query.id}
            left join t_supervision_unit_energy e5 on e5.monitor_id = t.monitor_id and e5.del_flag = "1" and e5.tce = "1" and e5.old_code = 'QPLD' and e5.code = #{query.id}
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e0.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.designCapacity != 0
    </select>


    <!--磷化工（磷酸一铵、磷酸二铵）-->
    <select id="getSuperviseTaskSummary4_2" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.m1, tt.r1,
        case when tt.r1 is null then '' when tt.r1 = '' then '' when CONVERT(tt.r1,DECIMAL(10,4)) > CONVERT(tt.m1,DECIMAL(10,4)) then '2' else '1' end evaluate, tt.remark
        from (
            select  DISTINCT IFNULL(e0.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName,
            IFNULL(e0.design_capacity,0) as designCapacity, IFNULL(e0.unit_product_energy,'') as tce,IFNULL(q.annotation,'') as productName,
            case when i.production != '/' then i.production when i.calculation_results != '/' then i.calculation_results else '' end production,
            case when e1.unit_product_limit_standard is not null then e1.unit_product_limit_standard when e2.unit_product_limit_standard is not null then e2.unit_product_limit_standard when e3.unit_product_limit_standard is not null then e3.unit_product_limit_standard else '' end m1,
            case when e1.calculation_results is not null then e1.calculation_results when e2.calculation_results is not null then e2.calculation_results when e3.calculation_results is not null then e3.calculation_results else '' end r1,
            <![CDATA[ case when e0.year like '%&%' then concat('监察周期为：',replace(e0.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e0 on e0.monitor_id = t.monitor_id and e0.del_flag = "1" and e0.tce = "0" and e0.code = #{query.id}
            left join t_supervision_unit_item i on i.unit_energy_id = e0.id and i.del_flag = "1" and i.tce="2" and i.codes = #{query.id}
            left join t_supervision_quota q on q.code = #{query.id}
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "1" and e1.old_code = 'EPZD' and e1.code = #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'E1'   and e2.code = #{query.id}
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'E2'   and e3.code = #{query.id}
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e0.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.designCapacity != 0
    </select>


    <!--电解铝-->
    <select id="getSuperviseTaskSummary5" resultType="java.util.Map">
        select tt.monitorId, tt.unit, tt.region, tt.epcName, tt.num, GROUP_CONCAT(DISTINCT tt.modelNum) modelNum, tt.designCapacity,
        sum(tt.p1) p1, sum(tt.p2) p2, sum(tt.p3) p3, sum(tt.p4) p4, sum(tt.cr1) cr1, sum(tt.ev1) ev1, sum(tt.cr2) cr2, sum(tt.ev2) ev2, sum(tt.cr3) cr3, sum(tt.ev3) ev3, sum(tt.cr4) cr4, sum(tt.ev4) ev4,
        tt.limit1, tt.limit2, tt.limit3, tt.limit4, tt.remark
        from (
            select  DISTINCT t.monitor_id monitorId, IFNULL(e0.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName,
            IFNULL(e0.line_number,'-') as num, IFNULL(e0.electrolyzer_specifications,'') as modelNum, IFNULL(e0.design_capacity,0) as designCapacity,
            case when i1.production != '/' then i1.production when i1.calculation_results != '/' then i1.calculation_results else '' end p1,
            case when i2.production != '/' then i2.production when i2.calculation_results != '/' then i2.calculation_results else '' end p2,
            IFNULL(c.unit_energy_consumption,'') as p3,
            case when i3.production != '/' then i3.production when i3.calculation_results != '/' then i3.calculation_results else '' end p4,
            IFNULL(e1.calculation_results,'') as cr1, case when e1.calculation_results is null then '' when CONVERT(e1.calculation_results,DECIMAL(10,4)) > CONVERT(e1.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end ev1,
            IFNULL(e2.calculation_results,'') as cr2, case when e2.calculation_results is null then '' when CONVERT(e2.calculation_results,DECIMAL(10,4)) > CONVERT(e2.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end ev2,
            IFNULL(e3.calculation_results,'') as cr3, case when e3.calculation_results is null then '' when CONVERT(e3.calculation_results,DECIMAL(10,4)) > CONVERT(e3.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end ev3,
            IFNULL(e4.calculation_results,'') as cr4, case when e4.calculation_results is null then '' when CONVERT(e4.calculation_results,DECIMAL(10,4)) > CONVERT(e4.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end ev4,
            IFNULL(e1.unit_product_limit_standard,'') as limit1, IFNULL(e2.unit_product_limit_standard,'') as limit2, IFNULL(e3.unit_product_limit_standard,'') as limit3, IFNULL(e4.unit_product_limit_standard,'') as limit4,
            <![CDATA[ case when e0.year like '%&%' then concat('监察周期为：',replace(e0.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e0 on e0.monitor_id = t.monitor_id and e0.del_flag = "1" and e0.tce = "0" and e0.code in (${query.num})
            left join t_supervision_unit_item i1 on i1.unit_energy_id = e0.id and i1.del_flag = "1" and i1.tce="2" and i1.old_code = 'Ply' and i1.codes = e0.code
            left join t_supervision_unit_item i2 on i2.unit_energy_id = e0.id and i2.del_flag = "1" and i2.tce="2" and i2.old_code = 'PAI' and i2.codes = e0.code
            left join t_supervision_unit_item i3 on i3.unit_energy_id = e0.id and i3.del_flag = "1" and i3.tce="2" and i3.old_code = 'Qj'  and i3.codes = e0.code
            left join t_supervision_unit_energy_comprehensive c on c.unit_energy_id = e0.id and c.del_flag = "1" and c.energy_name like '%外购电%' and c.code = e0.code
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "1" and e1.old_code = 'Wj'  and e1.pid = e0.id
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'Wzj' and e2.pid = e0.id
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'Dl'  and e3.pid = e0.id
            left join t_supervision_unit_energy e4 on e4.monitor_id = t.monitor_id and e4.del_flag = "1" and e4.tce = "1" and e4.old_code = 'Ez'  and e4.pid = e0.id
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e0.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.p1 != '' or tt.p2 != '' or tt.p3 != '' group by tt.epcName, tt.num
    </select>

    <!--钢铁企业单位产品-->
    <select id="getSuperviseTaskSummary6" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.production, tt.tce,
        tt.p1, tt.r1, tt.m1, tt.p2, tt.r2, tt.m2, tt.p3, tt.r3, tt.m3, tt.p4, tt.r4, tt.m4, tt.p5, tt.r5, tt.m5, tt.r6, tt.m6, tt.r7, tt.m7,
        tt.limit1, tt.limit2, tt.limit3, tt.limit4, tt.limit5, tt.limit6, tt.remark
        from (
            select DISTINCT case when a2.design_capacity_unit is not null then a2.design_capacity_unit  when a3.design_capacity_unit is not null then a3.design_capacity_unit
            when a4.design_capacity_unit is not null then a4.design_capacity_unit when a5.design_capacity_unit is not null then a5.design_capacity_unit else '' end unit,
            IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(a5.design_capacity,'') as designCapacity,IFNULL(i5.production,'') as production, IFNULL(t.tce,'') as tce,
            '' as p1, '' as r1, '' as m1,
            IFNULL(i2.production,'') as p2,
            IFNULL(e2.calculation_results,'') as r2,
            case when e2.calculation_results is null then '' when CONVERT(e2.calculation_results,DECIMAL(10,4)) > CONVERT(e2.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end m2,
            IFNULL(i3.production,'') as p3,
            IFNULL(e3.calculation_results,'') as r3,
            case when e3.calculation_results is null then '' when CONVERT(e3.calculation_results,DECIMAL(10,4)) > CONVERT(e3.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end m3,
            IFNULL(i4.production,'') as p4,
            IFNULL(e4.calculation_results,'') as r4,
            case when e4.calculation_results is null then '' when CONVERT(e4.calculation_results,DECIMAL(10,4)) > CONVERT(e4.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end m4,
            IFNULL(i5.production,'') as p5,
            IFNULL(e5.calculation_results,'') as r5,
            case when e5.calculation_results is null then '' when CONVERT(e5.calculation_results,DECIMAL(10,4)) > CONVERT(e5.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end m5,
            '' as r6, '' as m6, '' as r7, '' as m7,
            '' as limit1, IFNULL(e2.unit_product_limit_standard,'') as limit2, IFNULL(e3.unit_product_limit_standard,'') as limit3, IFNULL(e4.unit_product_limit_standard,'') as limit4,
            IFNULL(e5.unit_product_limit_standard,'') as limit5, '' as limit6,
            <![CDATA[ case when a2.year like '%&%' then concat('监察周期为：',replace(a2.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy a2 on a2.monitor_id = t.monitor_id and a2.del_flag = "1" and a2.tce = "0" and a2.code = 318
            left join t_supervision_unit_energy a3 on a3.monitor_id = t.monitor_id and a3.del_flag = "1" and a3.tce = "0" and a3.code = 319
            left join t_supervision_unit_energy a4 on a4.monitor_id = t.monitor_id and a4.del_flag = "1" and a4.tce = "0" and a4.code = 320
            left join t_supervision_unit_energy a5 on a5.monitor_id = t.monitor_id and a5.del_flag = "1" and a5.tce = "0" and a5.code = 321
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'EG1' and e2.code = 318
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'EG2' and e3.code = 319
            left join t_supervision_unit_energy e4 on e4.monitor_id = t.monitor_id and e4.del_flag = "1" and e4.tce = "1" and e4.old_code = 'EG3' and e4.code = 320
            left join t_supervision_unit_energy e5 on e5.monitor_id = t.monitor_id and e5.del_flag = "1" and e5.tce = "1" and e5.old_code = 'EG4' and e5.code = 321
            left join t_supervision_unit_item i2 on i2.unit_energy_id = a2.id and i2.del_flag = "1" and i2.tce="2" and i2.codes = 318
            left join t_supervision_unit_item i3 on i3.unit_energy_id = a3.id and i3.del_flag = "1" and i3.tce="2" and i3.codes = 319
            left join t_supervision_unit_item i4 on i4.unit_energy_id = a4.id and i4.del_flag = "1" and i4.tce="2" and i4.codes = 320
            left join t_supervision_unit_item i5 on i5.unit_energy_id = a5.id and i5.del_flag = "1" and i5.tce="2" and i5.codes = 321
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and a2.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.r1 != '' or tt.r2 != '' or tt.r3 != '' or tt.r4 != '' or tt.r5 != '' or tt.r6 != ''
    </select>


    <!--再生铅-->
    <select id="getSuperviseTaskSummary7" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.productName, tt.production, tt.limitStandard, tt.calculationResults, tt.evaluate, tt.remark
        from (
            select  DISTINCT IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,IFNULL(e1.product_name,'') as productName, IFNULL(i.production ,'') as production,
            IFNULL(e2.unit_product_limit_standard,'') as limitStandard, IFNULL(e2.calculation_results,'') as calculationResults,
            case when e2.calculation_results is null then '' when CONVERT(e2.calculation_results,DECIMAL(10,4)) > CONVERT(e2.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end evaluate,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.code = #{query.id}
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = #{query.id}
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.calculationResults != ''
    </select>

    <!-- 铁合金-->
    <select id="getSuperviseTaskSummary8" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.m1, tt.r1, tt.m2, tt.r2, tt.evaluate, tt.remark
        from (
            select  DISTINCT IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,IFNULL(i.product_name,'') as productName,IFNULL(i.ref_modulus ,'') as production,
            IFNULL(e2.unit_product_limit_standard,'') as m1, IFNULL(e2.calculation_results,'') as r1,
            IFNULL(e3.unit_product_limit_standard,'') as m2, IFNULL(e3.calculation_results,'') as r2,
            case e1.evaluation_criteria when '1' then '三级' when '2' then '二级' when '3' then '一级' else '' end evaluate,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'DTHJ' and e2.code = #{query.id}
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'ETHJ' and e3.code = #{query.id}
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = #{query.id}
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.r1 != '' or tt.r2 != ''  or tt.production != ''
    </select>


    <!--铅冶炼-->
    <select id="getSuperviseTaskSummary9" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, case when tt.process like '%粗铅%' then '粗铅' else tt.productName end productName, tt.production, tt.process, tt.m1, tt.r1,tt.evaluate, tt.remark
        from (
            select  DISTINCT IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,IFNULL(e1.product_name,'') as productName,IFNULL(i2.production ,'') as production, IFNULL(e1.product_name,'') as process,
            IFNULL(e2.unit_product_limit_standard,'') as m1, IFNULL(e2.calculation_results,'') as r1,
            case when e2.calculation_results is null then '' when CONVERT(e2.calculation_results,DECIMAL(10,4)) > CONVERT(e2.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end evaluate,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.code =  #{query.id}
            left join t_supervision_unit_item i1 on i1.unit_energy_id = e1.id and i1.del_flag = "1" and i1.tce="2" and i1.codes =  #{query.id}
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "0" and e3.code =  #{query.id2}
            left join t_supervision_unit_item i2 on i2.unit_energy_id = e3.id and i2.del_flag = "1" and i2.tce="2" and i2.codes =  #{query.id2}
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
		) tt where tt.r1 != ''
    </select>


    <!--铜冶炼 （1）555同一个监察数据, 有多条汇总数据-->
    <select id="getSuperviseTaskSummary10_1" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.process, tt.m1, tt.r1, '' as m2, '' as r2,
        case when tt.r1 is null then '' when tt.r1 = '' then '' when CONVERT(tt.r1,DECIMAL(10,4)) > CONVERT(tt.m1,DECIMAL(10,4)) then '2' else '1' end evaluate, tt.remark
        from (
            select t.monitor_id, IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,'粗铜-阳极铜' as productName,IFNULL(i.production ,'') as production, IFNULL(e1.product_name,'') as process,
            IFNULL(e2.unit_product_limit_standard,'') as m1, IFNULL(e2.calculation_results,'') as r1,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = 555
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'Epy' and e2.code = 555
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = 555
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
            union
            select t.monitor_id, IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,'杂铜-阳极铜' as productName,IFNULL(i.production ,'') as production, IFNULL(e1.product_name,'') as process,
            IFNULL(e2.unit_product_limit_standard,'') as m1, IFNULL(e2.calculation_results,'') as r1,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = 555
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'Ey' and e2.code = 555
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = 555
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.r1 != '' or tt.production != '' ORDER BY tt.monitor_id DESC
    </select>

    <!--铜冶炼 （2）557同一个监察数据, 有多条汇总数据-->
    <select id="getSuperviseTaskSummary10_2" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.process, tt.m1, tt.r1, '' as m2, '' as r2,
        case when tt.r1 is null then '' when tt.r1 = '' then '' when CONVERT(tt.r1,DECIMAL(10,4)) > CONVERT(tt.m1,DECIMAL(10,4)) then '2' else '1' end evaluate, tt.remark
        from (
            select t.monitor_id, IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,'杂铜-阴极铜' as productName,IFNULL(i.production ,'') as production, IFNULL(e1.product_name,'') as process,
            IFNULL(e2.unit_product_limit_standard,'') as m1, IFNULL(e2.calculation_results,'') as r1,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = 557
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'Ezy' and e2.code = 557
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = 557
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
            union
            select t.monitor_id, IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,'粗铜-阴极铜' as productName,IFNULL(i.production ,'') as production, IFNULL(e1.product_name,'') as process,
            IFNULL(e2.unit_product_limit_standard,'') as m1, IFNULL(e2.calculation_results,'') as r1, 
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = 557
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'Ecy' and e2.code = 557
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = 557
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.r1 != '' or tt.production != '' ORDER BY tt.monitor_id DESC
    </select>

    <!--铜冶炼 （3）549对标信息需计算, 从548获取数据计算-->
    <select id="getSuperviseTaskSummary10_3" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.process, tt.m1, tt.r1, tt.m2, tt.r2,
        case when (tt.r1 is null and tt.r2 is null) then '' when (tt.r1 = '' and tt.r2 ='') then ''
        when (CONVERT(tt.r1,DECIMAL(10,4)) > CONVERT(tt.m1,DECIMAL(10,4)) or CONVERT(tt.r2,DECIMAL(10,4)) > CONVERT(tt.m2,DECIMAL(10,4))) then '2' else '1' end evaluate, tt.remark
        from (
            select  DISTINCT IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,IFNULL(q.remark,'') as productName,IFNULL(i.production ,'') as production, IFNULL(e1.product_name,'') as process,
            IFNULL(e2.unit_product_limit_standard,'') as m1,
            IFNULL( ROUND((e2.calculation_results*a1.production + a3.calculation_results*a2.production) / a1.production,2),'') as r1,
            IFNULL(e3.unit_product_limit_standard,'') as m2, IFNULL(e3.calculation_results,'') as r2,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = 549
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'ec1' and e2.code = 549
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'Ez'  and e3.code = 549
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = 549
            left join t_supervision_unit_item a1 on a1.unit_energy_id = e1.id and a1.del_flag = "1" and a1.old_code = 'Pc1' and a1.codes = 549
            left join t_supervision_unit_item a2 on a2.unit_energy_id = e1.id and a2.del_flag = "1" and a2.old_code = 'Pb'  and a2.codes = 549
            left join t_supervision_unit_energy b on b.monitor_id = t.monitor_id and b.del_flag = "1" and b.tce = "0" and b.code = 548
            left join t_supervision_unit_item a3 on a3.unit_energy_id = b.id  and a3.del_flag = "1" and a3.old_code = 'ERN' and a3.codes = 548
            left join t_supervision_quota q on q.code = 549
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.r1 != '' or tt.r2!='' or tt.production != ''
    </select>

    <!--铜冶炼 （4）546对标信息需计算, 从549或550获取数据计算-->
    <select id="getSuperviseTaskSummary10_4" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.process, tt.m1, tt.r1, tt.m2, tt.r2,
        case when (tt.r1 is null and tt.r2 is null) then '' when (tt.r1 = '' and tt.r2 ='') then ''
        when (CONVERT(tt.r1,DECIMAL(10,4)) > CONVERT(tt.m1,DECIMAL(10,4)) or CONVERT(tt.r2,DECIMAL(10,4)) > CONVERT(tt.m2,DECIMAL(10,4))) then '2' else '1' end evaluate, tt.remark
        from (
            select  DISTINCT IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,IFNULL(q.remark,'') as productName,IFNULL(a.production ,'') as production, IFNULL(e1.product_name,'') as process,
            IFNULL(e2.unit_product_limit_standard,'') as m1,
            case when b1.calculation_results is not null or b1.calculation_results!='' then IFNULL(ROUND((b1.calculation_results*a1.production+e2.calculation_results*a2.production)/a2.production,2),'')
                 when c1.calculation_results is not null or c1.calculation_results!='' then IFNULL(ROUND((((c1.calculation_results*c2.production+d1.calculation_results*c3.production)/c2.production)*a1.production+e2.calculation_results*a2.production)/a2.production,2),'')
                 else '' end r1,
            IFNULL(e3.unit_product_limit_standard,'') as m2, IFNULL(e3.calculation_results,'') as r2,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = 546
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'Epy' and e2.code = 546
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'Ez'  and e3.code = 546
            left join t_supervision_unit_item a on a.unit_energy_id = e1.id and a.del_flag = "1" and a.tce="2" and a.codes = 546
            left join t_supervision_unit_item a1 on a1.unit_energy_id = e1.id and a1.del_flag = "1" and a1.old_code = 'm3' and a1.codes = 546
            left join t_supervision_unit_item a2 on a2.unit_energy_id = e1.id and a2.del_flag = "1" and a2.old_code = 'Py' and a2.codes = 546
            left join t_supervision_unit_energy b on b.monitor_id = t.monitor_id and b.del_flag = "1" and b.tce = "0" and b.code = 550
            left join t_supervision_unit_item b1 on b1.unit_energy_id = b.id  and b1.del_flag = "1" and b1.old_code = 'ec2' and b1.codes = 550
            left join t_supervision_unit_energy c on c.monitor_id = t.monitor_id and c.del_flag = "1" and c.tce = "0" and c.code = 549
            left join t_supervision_unit_item c1 on c1.unit_energy_id = e1.id and c1.del_flag = "1" and c1.old_code = 'ec1' and c1.codes = 549
            left join t_supervision_unit_item c2 on c2.unit_energy_id = e1.id and c2.del_flag = "1" and c2.old_code = 'Pc1' and c2.codes = 549
            left join t_supervision_unit_item c3 on c3.unit_energy_id = e1.id and c3.del_flag = "1" and c3.old_code = 'Pb'  and c3.codes = 549
            left join t_supervision_unit_energy d on d.monitor_id = t.monitor_id and d.del_flag = "1" and d.tce = "0"   and d.code   = 548
            left join t_supervision_unit_item d1 on d1.unit_energy_id = d.id  and d1.del_flag = "1" and d1.old_code = 'ERN' and d1.codes = 548
            left join t_supervision_quota q on q.code = 546
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.r1 != '' or tt.r2!='' or tt.production != ''
    </select>

    <!--铜冶炼 （5）547同一个监察数据, 有多条汇总数据；547对标信息需计算, 从546获取数据计算-->
    <select id="getSuperviseTaskSummary10_5" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.process, tt.m1, tt.r1, tt.m2, tt.r2,
        case when (tt.r1 is null and tt.r2 is null) then '' when (tt.r1 = '' and tt.r2 ='') then ''
        when (CONVERT(tt.r1,DECIMAL(10,4)) > CONVERT(tt.m1,DECIMAL(10,4)) or CONVERT(tt.r2,DECIMAL(10,4)) > CONVERT(tt.m2,DECIMAL(10,4))) then '2' else '1' end evaluate, tt.remark
        from (
            select t.monitor_id, IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,'阳极铜-阴极铜' as productName,IFNULL(i.production ,'') as production, IFNULL(e1.product_name,'') as process,
            IFNULL(e2.unit_product_limit_standard,'') as m1, IFNULL(e2.calculation_results,'') as r1,
            IFNULL(e3.unit_product_limit_standard,'') as m2, IFNULL(e3.calculation_results,'') as r2,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = 547
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'Epd' and e2.code = 547
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'Ez1' and e3.code = 547
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = 547
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
            union
            select t.monitor_id, IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,'阳极铜-阴极铜' as productName,IFNULL(i.production ,'') as production, IFNULL(e1.product_name,'') as process,
            IFNULL(e2.unit_product_limit_standard,'') as m1, IFNULL(e2.calculation_results,'') as r1,
            IFNULL(e3.unit_product_limit_standard,'') as m2, IFNULL(e3.calculation_results,'') as r2,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = 547
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'E'   and e2.code = 547
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'Ez2' and e3.code = 547
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = 547
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.r1 != '' or tt.production != '' ORDER BY tt.monitor_id DESC
    </select>

    <!--铜冶炼 （6）550、554-->
    <select id="getSuperviseTaskSummary10_6" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.process, tt.m1, tt.r1, tt.m2, tt.r2,
        case when (tt.r1 is null and tt.r2 is null) then '' when (tt.r1 = '' and tt.r2 ='') then ''
        when (CONVERT(tt.r1,DECIMAL(10,4)) > CONVERT(tt.m1,DECIMAL(10,4)) or CONVERT(tt.r2,DECIMAL(10,4)) > CONVERT(tt.m2,DECIMAL(10,4))) then '2' else '1' end evaluate, tt.remark
        from (
            select  DISTINCT IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,IFNULL(q.remark,'') as productName,IFNULL(i.production ,'') as production, IFNULL(e1.product_name,'') as process,
            case when e2.unit_product_limit_standard is not null then e2.unit_product_limit_standard when e3.unit_product_limit_standard is not null then e3.unit_product_limit_standard else ''end m1,
            case when e2.unit_product_limit_standard is not null then e2.calculation_results when e3.unit_product_limit_standard is not null then e3.calculation_results else '' end r1,
            IFNULL(e4.unit_product_limit_standard,'') as m2, IFNULL(e4.calculation_results,'') as r2,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.old_code = 'Epc2' and e2.code = #{query.id}
            left join t_supervision_unit_energy e3 on e3.monitor_id = t.monitor_id and e3.del_flag = "1" and e3.tce = "1" and e3.old_code = 'ec2'  and e3.code = #{query.id}
            left join t_supervision_unit_energy e4 on e4.monitor_id = t.monitor_id and e4.del_flag = "1" and e4.tce = "1" and e4.old_code = 'Ez'   and e4.code = #{query.id}
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = #{query.id}
            left join t_supervision_quota q on q.code = #{query.id}
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        )tt where tt.r1 != '' or tt.r2!='' or tt.production != ''
    </select>

    <!--锌冶炼-->
    <select id="getSuperviseTaskSummary11" resultType="java.util.Map">
        select tt.unit, tt.region, tt.epcName, tt.designCapacity, tt.tce, tt.productName, tt.production, tt.process1, tt.process2, tt.m1, tt.r1, tt.evaluate, tt.remark
        from (
            select  DISTINCT IFNULL(e1.design_capacity_unit,'') as unit,IFNULL(r.meaning2,'') as region, IFNULL(info.cmp_name,'') as epcName, IFNULL(e1.design_capacity,'') as designCapacity,
            IFNULL(e1.unit_product_energy,'') as tce,IFNULL(e1.product_name,'') as productName,IFNULL(i.production ,'') as production, IFNULL(h2.name,'') as process1,
            IFNULL(h1.name,'') as process2,IFNULL(e2.unit_product_limit_standard,'') as m1, IFNULL(e2.calculation_results,'') as r1,
            case when e2.calculation_results is null then '' when CONVERT(e2.calculation_results,DECIMAL(10,4)) > CONVERT(e2.unit_product_limit_standard,DECIMAL(10,4)) then  "2" else "1" end evaluate,
            <![CDATA[ case when e1.year like '%&%' then concat('监察周期为：',replace(e1.year,'&','至')) else '' end remark ]]>
            from t_supervise_task  t
            left join enterprise_info info on info.enterprise_code = t.epc and info.del_flag="1"
            left join dict_region r on r.id like concat(left(info.region_code,4),"00")
            left join t_supervision_unit_energy e1 on e1.monitor_id = t.monitor_id and e1.del_flag = "1" and e1.tce = "0" and e1.code = #{query.id}
            left join t_supervision_unit_energy e2 on e2.monitor_id = t.monitor_id and e2.del_flag = "1" and e2.tce = "1" and e2.code = #{query.id}
            left join t_supervision_unit_item i on i.unit_energy_id = e1.id and i.del_flag = "1" and i.tce="2" and i.codes = #{query.id}
            left join h_kind h1 on h1.code = e1.code
            left join h_kind h2 on h2.code = h1.pcode
            where t.del_flag = "1"
            <if test="query.name!=null and query.name!=''">
                and info.cmp_name like concat("%", #{query.name},"%")
            </if>
            <if test="query.code!=null and query.code!=''">
                and info.enterprise_code like concat("%", #{query.code},"%")
            </if>
            <if test="query.area!=null and query.area!='' and query.area!='53'">
                and info.region_code like concat(#{query.area},"%")
            </if>
            <if test="query.year!=null and query.year!=''">
                and e1.year like concat( "%",#{query.year},"%")
            </if>
            <if test="query.type!=null and query.type!=''">
                and t.type like concat("%", #{query.type},"%")
            </if>
            <if test="query.source!=null and query.source!=''">
                and t.source like concat("%", #{query.source},"%")
            </if>
        ) tt where tt.r1 != ''
    </select>
    <select id="taskInfo" resultType="java.util.Map">
        select * from t_supervise_task where monitor_id = #{query.monitorId} and del_flag = "1"
    </select>
    <select id="totalByTask" resultType="java.util.Map">
        select count(a.monitor_id) taskNum, sum(a.jnjcState) noCompleteNum, count(a.monitor_id)-sum(a.jnjcState) completeNum
		from(
			select tt.monitor_id, tt.year, tt.epc, tt.type, tt.task_state,
			case when type='2' then case when n1+n2+n3+n4+n5>=1 then 1 else 0 end else n6 end jnjcState
			from (
				select monitor_id, substring(monitor_id,6,4) as year, epc, type, task_state,
				case when insite_supervision is not null or (select count(*) from t_supervision_inspection where monitor_id = t.monitor_id)>0 then 0 else 1 end n1,
				case when interview_transcripts is not null or (select count(*) from t_supervision_investigation where monitor_id = t.monitor_id)>0 then 0 else 1 end n2,
				case when note is not null or (select count(*) from t_supervision_note where monitor_id = t.monitor_id)>0 then 0 else 1 end n3,
				case when notification is not null or (select count(*) from t_supervision_notification where monitor_id = t.monitor_id)>0 then 0 else 1 end n4,
				case when (select count(*) from t_supervision_comprehensive_energy where monitor_id = t.monitor_id)>0 then 0 else 1 end n5,
				case when task_state = '3' then 0 else 1 end n6
				from t_supervise_task t
                <trim prefix="where" prefixOverrides="and">
                    <if test="query.year!=null and query.year!=''">
                        and monitor_id like concat("%",#{query.year},"%")
                    </if>
                    <if test="query.area!=null and query.area!=''">
                        and t.locate like concat(#{query.area},'%')
                     </if>
                </trim>
			)tt
		)a
    </select>

    <select id="pageByWX" resultType="java.util.Map">
        select a.monitorId, a.cmp, a.epc, a.type, a.area, a.trade, a.inspectorsid, a.inspectors, a.transmit, a.handle, a.address, a.remark,
        case when a.jnjcState >= 1 then '未完成' else '已完成' end jnjcState
        from(
            select IFNULL(tt.monitor_id,'') monitorId,  IFNULL(tt.monitored_ent,'') cmp, IFNULL(tt.epc,'') epc, IFNULL(tt.typeName,'') type,
            IFNULL(tt.meaning,'') area, IFNULL(tt.name,'') trade, IFNULL(tt.inspectorsid,'') inspectorsid, IFNULL(tt.inspectors,'') inspectors,
            IFNULL(tt.task_transmit,'') transmit, IFNULL(tt.task_handle,'') handle, IFNULL(tt.address,'') address, IFNULL(tt.remark,'') remark,
            case when type='2' then n1+n2+n3+n4+n5 else n6 end jnjcState, tt.locate
            from(
                select t.monitor_id, t.monitored_ent, t.epc, d.meaning, k.name, t.type, t.locate,
                case when t.type = '1' then '书面监察' else '现场监察' end typeName,
                t.inspectorsid, t.inspectors, t.address, t.remark, t.task_transmit, t.task_handle,
                case when t.insite_supervision is not null or (select count(*) from t_supervision_inspection where monitor_id = t.monitor_id)>0 then 0 else 1 end n1,
                case when t.interview_transcripts is not null or (select count(*) from t_supervision_investigation where monitor_id = t.monitor_id)>0 then 0 else 1 end n2,
                case when t.note is not null or (select count(*) from t_supervision_note where monitor_id = t.monitor_id)>0 then 0 else 1 end n3,
                case when t.notification is not null or (select count(*) from t_supervision_notification where monitor_id = t.monitor_id)>0 then 0 else 1 end n4,
                case when (select count(*) from t_supervision_comprehensive_energy where monitor_id = t.monitor_id)>0 then 0 else 1 end n5,
                case when t.task_state = '3' then 0 else 1 end n6
                from t_supervise_task t
                left join dict_region d on d.id=t.locate
                left join trade_kind k on k.code=t.industry
                left join t_supervision_organization o on t.organization_id = o.id and o.del_flag = "1"
                left join dict_region od on o.area_code = od.id
                where t.del_flag = "1"
                <if test="query.industry != null and query.industry != ''">
                    and t.industry like concat(#{query.industry},"%")
                </if>
                <if test="query.tradeArr != null and query.tradeArr !=''">
                    and k.name like concat("%",#{query.tradeArr},"%")
                </if>
                <if test="query.area != null and query.area != ''">
                    and t.locate like concat(#{query.area},"%")
                </if>
                <if test="query.num != null and query.num != ''">
                    and t.monitor_id like concat("%",#{query.num},"%")
                </if>
                <if test="query.year != null and query.year != ''">
                    and t.monitor_id like concat("%",#{query.year},"%")
                </if>
                <if test="query.name != null and query.name != ''">
                    and t.monitored_ent like concat("%",#{query.name},"%")
                </if>
                <if test="query.type != null and query.type != ''">
                    and t.type = #{query.type}
                </if>
            ) tt
        )a order by a.locate asc
    </select>

    <select id="noticeListByJnjc" resultType="java.util.Map">
        select e.enterprise_code epc, e.cmp_name cmpName, mo.monitor_id monitorId,
        case when mo.type = '2' then '现场监察'  when mo.type = '1' then '书面监察' else '' end type,
        mo.source, mo.inspectors, mo.inspectorscode, mo.noComplete
        from(
            select tt.monitor_id, tt.year, tt.epc, tt.type, tt.task_state, tt.source, tt.inspectorsid, tt.inspectors, tt.inspectorscode,
            case when type='2' then n1+n2+n3+n4+n5 else n6 end noComplete
            from (
                select t.monitor_id, substring(t.monitor_id,6,4) as year, t.epc, t.type, t.task_state, t.source, t.inspectorsid, t.inspectors,
                case when t.insite_supervision is not null or (select count(*) from t_supervision_inspection where monitor_id = t.monitor_id)>0 then 0 else 1 end n1,
                case when t.interview_transcripts is not null or (select count(*) from t_supervision_investigation where monitor_id = t.monitor_id)>0 then 0 else 1 end n2,
                case when t.note is not null or (select count(*) from t_supervision_note where monitor_id = t.monitor_id)>0 then 0 else 1 end n3,
                case when t.notification is not null or (select count(*) from t_supervision_notification where monitor_id = t.monitor_id)>0 then 0 else 1 end n4,
                case when (select count(*) from t_supervision_comprehensive_energy where monitor_id = t.monitor_id)>0 then 0 else 1 end n5,
                case when t.task_state = '3' then 0 else 1 end n6,
                (select GROUP_CONCAT(code) from t_supervision_person where t.inspectorsid like concat(id,",%") or t.inspectorsid like concat("%,",id,",%") or t.inspectorsid like concat("%,",id)) inspectorscode
                from t_supervise_task t
                where monitor_id like concat('%',#{query.year},'%')
            )tt
        )mo left join enterprise_info e on mo.epc = e.enterprise_code
        where mo.noComplete != '0'
        <if test="deptId!='530000'.toString() and inspectorsid!=null and inspectorsid!='' ">
            and mo.inspectorscode like concat("%",#{inspectorsid},"%")
        </if>
        <if test="query.area!=null and query.area!=''">
            and e.region_code like concat(#{query.area},'%')
        </if>
        order by e.cmp_name desc
    </select>

    <select id="jnjcSummary" resultType="java.util.Map">
		select IFNULL(count(mo.monitor_id),0) jnjcSum, IFNULL(sum(mo.noComplete),0) noComplete, IFNULL(count(mo.monitor_id)- sum(mo.noComplete),0) complete
		from(
            select tt.monitor_id, tt.year, tt.epc, tt.type, tt.task_state, tt.source, tt.locate, tt.industry,
            case when type='2' then case when n1+n2+n3+n4+n5>=1 then 1 else 0 end else n6 end noComplete
            from (
                select t.monitor_id, substring(t.monitor_id,6,4) as year, t.epc, t.type, t.task_state, t.source,t.locate, t.industry,
                case when t.insite_supervision is not null or (select count(*) from t_supervision_inspection where monitor_id = t.monitor_id)>0 then 0 else 1 end n1,
                case when t.interview_transcripts is not null or (select count(*) from t_supervision_investigation where monitor_id = t.monitor_id)>0 then 0 else 1 end n2,
                case when t.note is not null or (select count(*) from t_supervision_note where monitor_id = t.monitor_id)>0 then 0 else 1 end n3,
                case when t.notification is not null or (select count(*) from t_supervision_notification where monitor_id = t.monitor_id)>0 then 0 else 1 end n4,
                case when (select count(*) from t_supervision_comprehensive_energy where monitor_id = t.monitor_id)>0 then 0 else 1 end n5,
                case when t.task_state = '3' then 0 else 1 end n6
                from t_supervise_task t
                where t.del_flag='1'and t.monitor_id like concat('%',#{query.year},'%')
            )tt
        )mo
        <trim prefix="where" prefixOverrides="and">
            <if test="query.area!=null and query.area!=''">
                and mo.locate like concat(#{query.area},'%')
            </if>
            <if test="query.industry != null and query.industry !=''">
                and mo.industry like concat(#{query.industry},"%")
            </if>
        </trim>
    </select>

    <select id="jnjcPersonal" resultType="java.util.Map">
        select IFNULL(count(mo.monitor_id),0) jnjcSum, IFNULL(sum(mo.noComplete),0) noComplete, IFNULL(count(mo.monitor_id)- sum(mo.noComplete),0) complete
		from(
            select tt.monitor_id, tt.year, tt.epc, tt.type, tt.task_state, tt.source, tt.locate, tt.industry, tt.inspectorsid, tt.inspectors, tt.inspectorscode,
            case when type='2' then case when n1+n2+n3+n4+n5>=1 then 1 else 0 end else n6 end noComplete
            from (
                select t.monitor_id, substring(t.monitor_id,6,4) as year, t.epc, t.type, t.task_state, t.source,t.locate, t.industry, t.inspectorsid, t.inspectors,
                case when t.insite_supervision is not null or (select count(*) from t_supervision_inspection where monitor_id = t.monitor_id)>0 then 0 else 1 end n1,
                case when t.interview_transcripts is not null or (select count(*) from t_supervision_investigation where monitor_id = t.monitor_id)>0 then 0 else 1 end n2,
                case when t.note is not null or (select count(*) from t_supervision_note where monitor_id = t.monitor_id)>0 then 0 else 1 end n3,
                case when t.notification is not null or (select count(*) from t_supervision_notification where monitor_id = t.monitor_id)>0 then 0 else 1 end n4,
                case when (select count(*) from t_supervision_comprehensive_energy where monitor_id = t.monitor_id)>0 then 0 else 1 end n5,
                case when t.task_state = '3' then 0 else 1 end n6,
				(select GROUP_CONCAT(code) from t_supervision_person where t.inspectorsid like concat(id,",%") or t.inspectorsid like concat("%,",id,",%") or t.inspectorsid like concat("%,",id)) inspectorscode
                from t_supervise_task t
                where t.del_flag='1' and t.monitor_id like concat('%',#{query.year},'%')
            )tt
        )mo where mo.inspectorscode like concat("%",#{query.id},"%")
    </select>
    <select id="isExistMonitorId" resultType="java.lang.Integer">
        SELECT COUNT(*) FROM t_supervise_task WHERE FIND_IN_SET(#{monitorId},monitor_id) and del_flag='1'
    </select>
    <select id="getHistoryData" resultType="java.util.Map">
        select IFNULL(id,'') id, IFNULL(industry,'') industry, IFNULL(monitored_id,'') monitored_id, IFNULL(monitored_ent,'') monitored_ent, IFNULL(design_capacity,'') design_capacity, IFNULL(column_1,'') column_1,
        IFNULL(column_2,'') column_2, IFNULL(column_3,'') column_3, IFNULL(column_4,'') column_4, IFNULL(column_5,'') column_5, IFNULL(column_6,'') column_6, IFNULL(column_7,'') column_7,
        IFNULL(column_8,'') column_8, IFNULL(column_9,'') column_9, IFNULL(column_10,'') column_10, IFNULL(column_11,'') column_11, IFNULL(column_12,'') column_12
        from t_supervise_history_data where industry = (select industry from t_supervise_history_columns where item = #{query.item}) and monitored_id like concat('%',#{query.year},'%')
        <if test="query.name!=null and query.name!=''">
           and monitored_ent like concat('%',#{query.name},'%')
        </if>
        <if test="query.code!=null and query.code!=''">
            and epc like concat('%',#{query.code},'%')
        </if>
    </select>
    <select id="getHistoryColumns" resultType="java.lang.String">
        select table_columns from t_supervise_history_columns where item = #{item}
    </select>

</mapper>
