<?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.dbcapp.mapper.record.ConfigureDataCollectMapper">
    <resultMap id="BaseResultMap" type="com.nantian.cloud.dbcapp.entity.ConfigureDataCollect">
        <id column="id" property="id" />
        <result column="enterpriseCode" property="enterpriseCode" />
        <result column="dataCode" property="dataCode" />
        <result column="collectItemName" property="collectItemName" />
        <result column="processCode" property="processCode" />
        <result column="processUnitCode" property="processUnitCode" />
        <result column="equipmentCode" property="equipmentCode" />
        <result column="equipmentUnitCode" property="equipmentUnitCode" />
        <result column="energyClassCode" property="energyClassCode" />
        <result column="energyTypeCode" property="energyTypeCode" />
        <result column="dataUsageCode" property="dataUsageCode" />
        <result column="inputType" property="inputType" />
        <result column="dataValueMax" property="dataValueMax" />
        <result column="dataValueMin" property="dataValueMin" />
        <result column="statType" property="statType" />
        <result column="collectSystemName" property="collectSystemName" />
        <result column="scope" property="scope" />
        <result column="state" property="state" />
        <result column="remark" property="remark" />
        <result column="uploadedCountry" property="uploadedCountry" />
        <result column="digest" property="digest" />
        <result column="quoted" property="quoted" />
        <result column="quotedByCollect" property="quotedByCollect" />
    </resultMap>
    <select id="getList" resultType="java.util.Map">
        SELECT *
        FROM configure_data_collect
        <trim prefix="where" prefixOverrides="and">
            <if test="epc!=null">
                and enterpriseCode = #{epc}
            </if>
            <if test="collectItemName!=null">
               and  collectItemName like concat("%",#{collectItemName},"%")

            </if>
            <if test="collectItemName==null">
                and (collectItemName like '%产量%' OR collectItemName like '%系数%')
            </if>
        </trim>
        limit #{page.current},#{page.size}
    </select>
    <select id="getListData" resultType="java.util.Map">
        SELECT *
        FROM configure_data_collect
        <trim prefix="where" prefixOverrides="and">
            <if test="epc!=null">
                and enterpriseCode = #{epc}
            </if>
            <if test="collectItemName!=null">
                and  collectItemName like concat("%",#{collectItemName},"%")
            </if>
        </trim>
    </select>
    <select id="getListDataNew" resultType="java.util.Map">
        SELECT *
        FROM configure_data_collect_new_data
        <trim prefix="where" prefixOverrides="and">
            <if test="epc!=null">
                and enterpriseCode = #{epc}
            </if>
            <if test="collectItemName!=null">
                and  collectItemName like concat("%",#{collectItemName},"%")
            </if>
        </trim>
    </select>
    <select id="getListDataNewMap" resultType="com.nantian.cloud.dbcapp.entity.ConfigureDataCollect">
        SELECT *
        FROM configure_data_collect_new_data
        <trim prefix="where" prefixOverrides="and">
            <if test="epc!=null">
                and enterpriseCode = #{epc}
            </if>
            <if test="collectItemName!=null">
                and  collectItemName like concat("%",#{collectItemName},"%")
            </if>
        </trim>
    </select>
    <select id="getTotal" resultType="java.lang.Integer">
        SELECT IFNULL(count(*),0)
        FROM configure_data_collect
        <trim prefix="where" prefixOverrides="and">
            <if test="epc!=null">
                and enterpriseCode = #{epc}
            </if>
            <if test="collectItemName!=null">
                and  collectItemName like concat("%",#{collectItemName},"%")
            </if>
            <if test="collectItemName==null">
                and (collectItemName like '%产量%' OR collectItemName like '%系数%')
            </if>
        </trim>
    </select>
    <select id="getAssistList" resultType="java.util.Map">
        SELECT *
        FROM t_unit_assist
        <trim prefix="where" prefixOverrides="and">
            <if test="epc!=null">
                and enterpriseCode = #{epc}
            </if>
        </trim>
    </select>

    <update id="updateByepc">
        UPDATE configure_data_collect a
        set a.isEnable=#{query.isEnable}
        where a.enterpriseCode=#{query.enterpriseCode} and  a.dataCode=#{query.dataCode}
    </update>

    <insert id="saveData" >
        INSERT into configure_data_collect_new_data (enterpriseCode,dataCode,collectItemName,processCode,
        processUnitCode,equipmentCode,equipmentUnitCode,energyClassCode,energyTypeCode,dataUsageCode,inputType,
        dataValueMax,dataValueMin,statType,collectSystemName,scope,state,remark,uploadedCountry,digest,quoted,quotedByCollect) values
         (#{data.enterpriseCode},#{data.dataCode},#{data.collectItemName},#{data.processCode},#{data.processUnitCode},
         #{data.equipmentCode},#{data.equipmentUnitCode},#{data.energyClassCode},#{data.energyTypeCode},#{data.dataUsageCode},
         #{data.inputType},#{data.dataValueMax},#{data.dataValueMin},#{data.statType},#{data.collectSystemName}
         ,#{data.scope},#{data.state},#{data.remark},#{data.uploadedCountry},#{data.digest},#{data.quoted},#{data.quotedByCollect})
    </insert>


</mapper>
