<?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.TSupervisionUnitItemMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.TSupervisionUnitItem">
        <id column="id" property="id" />
        <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="unit_energy_id" property="unitEnergyId" />
        <result column="remark" property="remark" />
        <result column="code" property="code" />
        <result column="product_name" property="productName" />
        <result column="production" property="production" />
        <result column="unit" property="unit" />
        <result column="calculation_results" property="calculationResults" />
        <result column="codes" property="codes" />
        <result column="tce" property="tce" />
        <result column="sub" property="sub" />
        <result column="ref_modulus" property="refModulus" />
        <result column="result_item" property="resultItem" />
        <result column="input_item" property="inputItem" />
        <result column="unit2" property="unit2" />
        <result column="code2" property="code2" />
        <result column="sort_num" property="sortNum" />
        <result column="old_code" property="oldCode" />
        <result column="line_number" property="lineNumber" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, userid, update_time, del_flag, dept_id, unit_energy_id, remark, code,code2, product_name, production,
         unit,unit2, calculation_results,ref_modulus,codes, tce, sub,bd,result_item,input_item, sort_num, old_code,line_number
    </sql>
    <select id="getByUnitEnergyId" resultType="map">
        SELECT DISTINCT t1.id,t1.year,t2.monitor_id monitoredId,t2.monitored_ent as monitoredEnt,t2.industry,t2.locate,t2.inspectors,t2.source,t3.product_name as productName,t3.calculation_results as calculationResults,t3.unit
from t_supervision_unit_energy t1
JOIN t_supervise_task t2 on t1.monitor_id=t2.monitor_id
JOIN t_supervision_unit_item t3 on t1.id=t3.unit_energy_id
where t3.tce='1' and t2.del_flag='1' and t1.monitor_id=#{monitorId}
    </select>

</mapper>
