<?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.zehong.system.mapper.PalletDeviceUploadFailureMapper">

    <resultMap type="PalletDeviceUploadFailure" id="PalletDeviceUploadFailureResult">
        <result property="id"    column="f_id"    />
        <result property="trayId"    column="f_tray_id"    />
        <result property="storeyCode"    column="f_storey_code"    />
        <result property="motherboardCode"    column="f_motherboard_code"    />
        <result property="row"    column="f_row"    />
        <result property="col"    column="f_col"    />
        <result property="index"    column="f_index"    />
        <result property="number"    column="f_number"    />
        <result property="bindingTime"    column="f_binding_time"    />
        <result property="unbindingTime"    column="f_unbinding_time"    />
        <result property="createTime"    column="f_create_time"    />
        <result property="deviceStatus"    column="f_device_status"    />
        <result property="recordYear"    column="f_record_year"    />
        <result property="recordMonth"    column="f_record_month"    />
        <result property="recordDate"    column="f_record_date"    />
        <result property="recordHour"    column="f_record_hour"    />
        <result property="recordMinute"    column="f_record_minute"    />
        <result property="writeTimeStatus"    column="f_write_time_status"    />
        <result property="adjustmentZeroAd"    column="f_adjustment_zero_ad"    />
        <result property="zeroStatus"    column="f_zero_status"    />
        <result property="calibrationAd"    column="f_calibration_ad"    />
        <result property="calibrationAdStatus"    column="f_calibration_status"    />
        <result property="concentration"    column="f_concentration"    />
        <result property="runTimeStatus"    column="f_run_time_status"    />
        <result property="realTimeAd"    column="f_real_time_ad"    />
        <result property="realTimeStatus"    column="f_real_time_ad_status"    />
        <result property="calibrationConcentration"    column="f_calibration_concentration"    />
        <result property="calibrationConcentrationStatus"    column="f_calibration_concentration_status"    />
        <result property="writeSelfCheckStatus"    column="f_write_self_check_status"    />
        <result property="relayStatus"    column="f_relay_status"    />
        <result property="pulseStatus"    column="f_pulse_status"    />
        <result property="moduleStatus"    column="f_module_status"    />
        <result property="simCardStatus"    column="f_sim_card_status"    />
        <result property="networkStatus"    column="f_network_status"    />
        <result property="productStandardInspectionNumber"    column="f_product_standard_inspection_number"    />
        <result property="standardInspectResult"    column="f_standard_inspect_result"    />
        <result property="plateType" column="f_plate_type"/>
    </resultMap>

    <sql id="selectPalletDeviceUploadFailureVo">
        select palDeviceBinding.f_id,
               palDeviceBinding.f_tray_id,
               trayInfo.f_tray_code as trayCode,
               palDeviceBinding.f_storey_code,
               palDeviceBinding.f_motherboard_code,
               palDeviceBinding.f_row,
               palDeviceBinding.f_col,
               palDeviceBinding.f_index,
               palDeviceBinding.f_number,
               palDeviceBinding.f_binding_time,
               palDeviceBinding.f_unbinding_time,
               palDeviceBinding.f_create_time,
               palDeviceBinding.f_device_status,
               palDeviceBinding.f_record_year,
               palDeviceBinding.f_record_month,
               palDeviceBinding.f_record_date,
               palDeviceBinding.f_record_hour,
               palDeviceBinding.f_record_minute,
               palDeviceBinding.f_write_time_status,
               palDeviceBinding.f_adjustment_zero_ad,
               palDeviceBinding.f_zero_status,
               palDeviceBinding.f_calibration_ad,
               palDeviceBinding.f_calibration_status,
               palDeviceBinding.f_concentration,
               palDeviceBinding.f_run_time_status,
               palDeviceBinding.f_real_time_ad,
               palDeviceBinding.f_real_time_ad_status,
               palDeviceBinding.f_calibration_concentration,
               palDeviceBinding.f_calibration_concentration_status,
               palDeviceBinding.f_write_self_check_status,
               palDeviceBinding.f_relay_status,
               palDeviceBinding.f_pulse_status,
               palDeviceBinding.f_module_status,
               palDeviceBinding.f_sim_card_status,
               palDeviceBinding.f_network_status,
               palDeviceBinding.f_product_standard_inspection_number,
               palDeviceBinding.f_standard_inspect_result,
               inspection.f_plate_type
        from t_pallet_device_upload_failure palDeviceBinding
        left join t_tray_info trayInfo  on trayInfo.f_tray_id = palDeviceBinding.f_tray_id
        left join t_product_standard_inspection inspection
                  on inspection.f_product_standard_inspection_number = palDeviceBinding.f_product_standard_inspection_number
    </sql>

    <select id="selectPalletDeviceUploadFailureList" parameterType="PalletDeviceUploadFailure" resultMap="PalletDeviceUploadFailureResult">
        <include refid="selectPalletDeviceUploadFailureVo"/>
        <where>
            <if test="trayId != null "> and f_tray_id = #{trayId}</if>
            <if test="storeyCode != null  and storeyCode != ''"> and f_storey_code = #{storeyCode}</if>
            <if test="motherboardCode != null  and motherboardCode != ''"> and f_motherboard_code = #{motherboardCode}</if>
            <if test="row != null "> and f_row = #{row}</if>
            <if test="col != null "> and f_col = #{col}</if>
            <if test="index != null "> and f_index = #{index}</if>
            <if test="number != null "> and f_number = #{number}</if>
            <if test="bindingTime != null "> and f_binding_time = #{bindingTime}</if>
            <if test="unbindingTime != null "> and f_unbinding_time = #{unbindingTime}</if>
            <if test="createTime != null "> and f_create_time = #{createTime}</if>
            <if test="deviceStatus != null  and deviceStatus != ''"> and f_device_status = #{deviceStatus}</if>
            <if test="recordYear != null  and recordYear != ''"> and f_record_year = #{recordYear}</if>
            <if test="recordMonth != null  and recordMonth != ''"> and f_record_month = #{recordMonth}</if>
            <if test="recordDate != null  and recordDate != ''"> and f_record_date = #{recordDate}</if>
            <if test="recordHour != null  and recordHour != ''"> and f_record_hour = #{recordHour}</if>
            <if test="recordMinute != null  and recordMinute != ''"> and f_record_minute = #{recordMinute}</if>
            <if test="writeTimeStatus != null  and writeTimeStatus != ''"> and f_write_time_status = #{writeTimeStatus}</if>
            <if test="adjustmentZeroAd != null  and adjustmentZeroAd != ''"> and f_adjustment_zero_ad = #{adjustmentZeroAd}</if>
            <if test="zeroStatus != null  and zeroStatus != ''"> and f_zero_status = #{zeroStatus}</if>
            <if test="calibrationAd != null  and calibrationAd != ''"> and f_calibration_ad = #{calibrationAd}</if>
            <if test="calibrationAdStatus != null  and calibrationAdStatus != ''"> and f_calibration_status = #{calibrationAdStatus}</if>
            <if test="concentration != null  and concentration != ''"> and f_concentration = #{concentration}</if>
            <if test="runTimeStatus != null  and runTimeStatus != ''"> and f_run_time_status = #{runTimeStatus}</if>
            <if test="realTimeAd != null "> and f_real_time_ad = #{realTimeAd}</if>
            <if test="realTimeStatus != null  and realTimeStatus != ''"> and f_real_time_ad_status = #{realTimeStatus}</if>
            <if test="calibrationConcentration != null "> and f_calibration_concentration = #{calibrationConcentration}</if>
            <if test="calibrationConcentrationStatus != null  and calibrationConcentrationStatus != ''"> and f_calibration_concentration_status = #{calibrationConcentrationStatus}</if>
            <if test="writeSelfCheckStatus != null "> and f_write_self_check_status = #{writeSelfCheckStatus}</if>
            <if test="relayStatus != null "> and f_relay_status = #{relayStatus}</if>
            <if test="pulseStatus != null "> and f_pulse_status = #{pulseStatus}</if>
            <if test="moduleStatus != null "> and f_module_status = #{moduleStatus}</if>
            <if test="simCardStatus != null "> and f_sim_card_status = #{simCardStatus}</if>
            <if test="networkStatus != null "> and f_network_status = #{networkStatus}</if>
            <if test="productStandardInspectionNumber != null  and productStandardInspectionNumber != ''"> and f_product_standard_inspection_number like concat('%',#{productStandardInspectionNumber},'%') </if>
            <if test="standardInspectResult != null  and standardInspectResult != ''"> and f_standard_inspect_result = #{standardInspectResult}</if>
        </where>
    </select>

    <select id="selectPalletDeviceUploadFailureById" parameterType="Long" resultMap="PalletDeviceUploadFailureResult">
        <include refid="selectPalletDeviceUploadFailureVo"/>
        where palDeviceBinding.f_id = #{id}
    </select>
    <insert id="batchInsertRealTimeData" parameterType="list">
        insert into t_pallet_device_upload_failure
        <trim prefix="(" suffix=")" suffixOverrides=",">
            f_tray_id,
            f_storey_code,
            f_motherboard_code,
            f_row,
            f_col,
            f_index,
            f_number,
            f_binding_time,
            f_unbinding_time,
            f_create_time,
            f_device_status,
            f_record_year,
            f_record_month,
            f_record_date,
            f_record_hour,
            f_record_minute,
            f_write_time_status,
            f_adjustment_zero_ad,
            f_zero_status,
            f_calibration_ad,
            f_calibration_status,
            f_concentration,
            f_run_time_status,
            f_real_time_ad,
            f_real_time_ad_status,
            f_calibration_concentration,
            f_calibration_concentration_status,
            f_write_self_check_status,
            f_relay_status,
            f_pulse_status,
            f_module_status,
            f_sim_card_status,
            f_network_status,
            f_product_standard_inspection_number,
            f_standard_inspect_result
        </trim>
        values
        <foreach collection="list" item="item" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{item.trayId},
                #{item.storeyCode},
                #{item.motherboardCode},
                #{item.row},
                #{item.col},
                #{item.index},
                #{item.number},
                #{item.bindingTime},
                #{item.unbindingTime},
                #{item.createTime},
                #{item.deviceStatus},
                #{item.recordYear},
                #{item.recordMonth},
                #{item.recordDate},
                #{item.recordHour},
                #{item.recordMinute},
                #{item.writeTimeStatus},
                #{item.adjustmentZeroAd},
                #{item.zeroStatus},
                #{item.calibrationAd},
                #{item.calibrationAdStatus},
                #{item.concentration},
                #{item.runTimeStatus},
                #{item.realTimeAd},
                #{item.realTimeStatus},
                #{item.calibrationConcentration},
                #{item.calibrationConcentrationStatus},
                #{item.writeSelfCheckStatus},
                #{item.relayStatus},
                #{item.pulseStatus},
                #{item.moduleStatus},
                #{item.simCardStatus},
                #{item.networkStatus},
                #{item.productStandardInspectionNumber},
                #{item.standardInspectResult}
            </trim>
        </foreach>
    </insert>
    <insert id="batchInsert" parameterType="list">
        insert into t_pallet_device_upload_failure
        <trim prefix="(" suffix=")" suffixOverrides=",">
            f_tray_id,
            f_storey_code,
            f_motherboard_code,
            f_row,
            f_col,
            f_index,
            f_number,
            f_binding_time,
            f_unbinding_time,
            f_create_time,
            f_device_status,
            f_record_year,
            f_record_month,
            f_record_date,
            f_record_hour,
            f_record_minute,
            f_write_time_status,
            f_adjustment_zero_ad,
            f_zero_status,
            f_calibration_ad,
            f_calibration_status,
            f_concentration,
            f_run_time_status,
            f_real_time_ad,
            f_real_time_ad_status,
            f_calibration_concentration,
            f_calibration_concentration_status,
            f_write_self_check_status,
            f_relay_status,
            f_pulse_status,
            f_module_status,
            f_sim_card_status,
            f_network_status,
            f_product_standard_inspection_number,
            f_standard_inspect_result
        </trim>
        values
        <foreach collection="list" item="item" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{item.trayId},
                #{item.storeyCode},
                #{item.motherboardCode},
                #{item.row},
                #{item.col},
                #{item.index},
                #{item.number},
                #{item.bindingTime},
                #{item.unbindingTime},
                #{item.createTime},
                #{item.deviceStatus},
                #{item.recordYear},
                #{item.recordMonth},
                #{item.recordDate},
                #{item.recordHour},
                #{item.recordMinute},
                #{item.writeTimeStatus},
                #{item.adjustmentZeroAd},
                #{item.zeroStatus},
                #{item.calibrationAd},
                #{item.calibrationStatus},
                #{item.concentration},
                #{item.runTimeStatus},
                #{item.realTimeAd},
                #{item.realTimeStatus},
                #{item.calibrationConcentration},
                #{item.calibrationConcentrationStatus},
                #{item.writeSelfCheckStatus},
                #{item.relayStatus},
                #{item.pulseStatus},
                #{item.moduleStatus},
                #{item.simCardStatus},
                #{item.networkStatus},
                #{item.productStandardInspectionNumber},
                #{item.standardInspectResult}
            </trim>
        </foreach>
    </insert>
    <insert id="insertPalletDeviceUploadFailure" parameterType="PalletDeviceUploadFailure" useGeneratedKeys="true" keyProperty="id">
        insert into t_pallet_device_upload_failure
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="trayId != null">f_tray_id,</if>
            <if test="storeyCode != null">f_storey_code,</if>
            <if test="motherboardCode != null">f_motherboard_code,</if>
            <if test="row != null">f_row,</if>
            <if test="col != null">f_col,</if>
            <if test="index != null">f_index,</if>
            <if test="number != null">f_number,</if>
            <if test="bindingTime != null">f_binding_time,</if>
            <if test="unbindingTime != null">f_unbinding_time,</if>
            <if test="createTime != null">f_create_time,</if>
            <if test="deviceStatus != null">f_device_status,</if>
            <if test="recordYear != null">f_record_year,</if>
            <if test="recordMonth != null">f_record_month,</if>
            <if test="recordDate != null">f_record_date,</if>
            <if test="recordHour != null">f_record_hour,</if>
            <if test="recordMinute != null">f_record_minute,</if>
            <if test="writeTimeStatus != null">f_write_time_status,</if>
            <if test="adjustmentZeroAd != null">f_adjustment_zero_ad,</if>
            <if test="zeroStatus != null">f_zero_status,</if>
            <if test="calibrationAd != null">f_calibration_ad,</if>
            <if test="calibrationAdStatus != null">f_calibration_status,</if>
            <if test="concentration != null">f_concentration,</if>
            <if test="runTimeStatus != null">f_run_time_status,</if>
            <if test="realTimeAd != null">f_real_time_ad,</if>
            <if test="realTimeStatus != null">f_real_time_ad_status,</if>
            <if test="calibrationConcentration != null">f_calibration_concentration,</if>
            <if test="calibrationConcentrationStatus != null">f_calibration_concentration_status,</if>
            <if test="writeSelfCheckStatus != null">f_write_self_check_status,</if>
            <if test="relayStatus != null">f_relay_status,</if>
            <if test="pulseStatus != null">f_pulse_status,</if>
            <if test="moduleStatus != null">f_module_status,</if>
            <if test="simCardStatus != null">f_sim_card_status,</if>
            <if test="networkStatus != null">f_network_status,</if>
            <if test="productStandardInspectionNumber != null">f_product_standard_inspection_number,</if>
            <if test="standardInspectResult != null">f_standard_inspect_result,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="trayId != null">#{trayId},</if>
            <if test="storeyCode != null">#{storeyCode},</if>
            <if test="motherboardCode != null">#{motherboardCode},</if>
            <if test="row != null">#{row},</if>
            <if test="col != null">#{col},</if>
            <if test="index != null">#{index},</if>
            <if test="number != null">#{number},</if>
            <if test="bindingTime != null">#{bindingTime},</if>
            <if test="unbindingTime != null">#{unbindingTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="deviceStatus != null">#{deviceStatus},</if>
            <if test="recordYear != null">#{recordYear},</if>
            <if test="recordMonth != null">#{recordMonth},</if>
            <if test="recordDate != null">#{recordDate},</if>
            <if test="recordHour != null">#{recordHour},</if>
            <if test="recordMinute != null">#{recordMinute},</if>
            <if test="writeTimeStatus != null">#{writeTimeStatus},</if>
            <if test="adjustmentZeroAd != null">#{adjustmentZeroAd},</if>
            <if test="zeroStatus != null">#{zeroStatus},</if>
            <if test="calibrationAd != null">#{calibrationAd},</if>
            <if test="calibrationAdStatus != null">#{calibrationAdStatus},</if>
            <if test="concentration != null">#{concentration},</if>
            <if test="runTimeStatus != null">#{runTimeStatus},</if>
            <if test="realTimeAd != null">#{realTimeAd},</if>
            <if test="realTimeStatus != null">#{realTimeStatus},</if>
            <if test="calibrationConcentration != null">#{calibrationConcentration},</if>
            <if test="calibrationConcentrationStatus != null">#{calibrationConcentrationStatus},</if>
            <if test="writeSelfCheckStatus != null">#{writeSelfCheckStatus},</if>
            <if test="relayStatus != null">#{relayStatus},</if>
            <if test="pulseStatus != null">#{pulseStatus},</if>
            <if test="moduleStatus != null">#{moduleStatus},</if>
            <if test="simCardStatus != null">#{simCardStatus},</if>
            <if test="networkStatus != null">#{networkStatus},</if>
            <if test="productStandardInspectionNumber != null">#{productStandardInspectionNumber},</if>
            <if test="standardInspectResult != null">#{standardInspectResult},</if>
         </trim>
    </insert>

    <update id="updatePalletDeviceUploadFailure" parameterType="PalletDeviceUploadFailure">
        update t_pallet_device_upload_failure
        <trim prefix="SET" suffixOverrides=",">
            <if test="trayId != null">f_tray_id = #{trayId},</if>
            <if test="storeyCode != null">f_storey_code = #{storeyCode},</if>
            <if test="motherboardCode != null">f_motherboard_code = #{motherboardCode},</if>
            <if test="row != null">f_row = #{row},</if>
            <if test="col != null">f_col = #{col},</if>
            <if test="index != null">f_index = #{index},</if>
            <if test="number != null">f_number = #{number},</if>
            <if test="bindingTime != null">f_binding_time = #{bindingTime},</if>
            <if test="unbindingTime != null">f_unbinding_time = #{unbindingTime},</if>
            <if test="createTime != null">f_create_time = #{createTime},</if>
            <if test="deviceStatus != null">f_device_status = #{deviceStatus},</if>
            <if test="recordYear != null">f_record_year = #{recordYear},</if>
            <if test="recordMonth != null">f_record_month = #{recordMonth},</if>
            <if test="recordDate != null">f_record_date = #{recordDate},</if>
            <if test="recordHour != null">f_record_hour = #{recordHour},</if>
            <if test="recordMinute != null">f_record_minute = #{recordMinute},</if>
            <if test="writeTimeStatus != null">f_write_time_status = #{writeTimeStatus},</if>
            <if test="adjustmentZeroAd != null">f_adjustment_zero_ad = #{adjustmentZeroAd},</if>
            <if test="zeroStatus != null">f_zero_status = #{zeroStatus},</if>
            <if test="calibrationAd != null">f_calibration_ad = #{calibrationAd},</if>
            <if test="calibrationAdStatus != null">f_calibration_status = #{calibrationAdStatus},</if>
            <if test="concentration != null">f_concentration = #{concentration},</if>
            <if test="runTimeStatus != null">f_run_time_status = #{runTimeStatus},</if>
            <if test="realTimeAd != null">f_real_time_ad = #{realTimeAd},</if>
            <if test="realTimeStatus != null">f_real_time_ad_status = #{realTimeStatus},</if>
            <if test="calibrationConcentration != null">f_calibration_concentration = #{calibrationConcentration},</if>
            <if test="calibrationConcentrationStatus != null">f_calibration_concentration_status = #{calibrationConcentrationStatus},</if>
            <if test="writeSelfCheckStatus != null">f_write_self_check_status = #{writeSelfCheckStatus},</if>
            <if test="relayStatus != null">f_relay_status = #{relayStatus},</if>
            <if test="pulseStatus != null">f_pulse_status = #{pulseStatus},</if>
            <if test="moduleStatus != null">f_module_status = #{moduleStatus},</if>
            <if test="simCardStatus != null">f_sim_card_status = #{simCardStatus},</if>
            <if test="networkStatus != null">f_network_status = #{networkStatus},</if>
            <if test="productStandardInspectionNumber != null">f_product_standard_inspection_number = #{productStandardInspectionNumber},</if>
            <if test="standardInspectResult != null">f_standard_inspect_result = #{standardInspectResult},</if>
        </trim>
        where f_id = #{id}
    </update>

    <delete id="deletePalletDeviceUploadFailureById" parameterType="Long">
        delete from t_pallet_device_upload_failure where f_id = #{id}
    </delete>

    <delete id="deletePalletDeviceUploadFailureByIds" parameterType="String">
        delete from t_pallet_device_upload_failure where f_id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
