<?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.pwt.system.mapper.PwtConfigMapper">
    
    <resultMap type="PwtConfig" id="PwtConfigResult">
        <result property="id"    column="id"    />
        <result property="websiteEnabled"    column="website_enabled"    />
        <result property="systemName"    column="system_name"    />
        <result property="systemIp"    column="system_ip"    />
        <result property="systemPort"    column="system_port"    />
        <result property="adminExpireTime"    column="admin_expire_time"    />
        <result property="lastBackupTime"    column="last_backup_time"    />
        <result property="chargeSoc"    column="charge_soc"    />
        <result property="cloudEnabled"    column="cloud_enabled"    />
        <result property="cloudAddress"    column="cloud_address"    />
        <result property="cloudAccount"    column="cloud_account"    />
        <result property="cloudPassword"    column="cloud_password"    />
        <result property="agreementType"    column="agreement_type"    />
        <result property="vehicleCidr"    column="vehicle_cidr"    />
        <result property="robotIp"    column="robot_ip"    />
        <result property="robotPort"    column="robot_port"    />
        <result property="robotNo"    column="robot_no"    />
        <result property="scannerIp"    column="scanner_ip"    />
        <result property="scannerPort"    column="scanner_port"    />
        <result property="rfidIp"    column="rfid_ip"    />
        <result property="rfidPort"    column="rfid_port"    />
        <result property="charger1Ip"    column="charger1_ip"    />
        <result property="charger1Port"    column="charger1_port"    />
        <result property="charger1No"    column="charger1_no"    />
        <result property="charger1Time"    column="charger1_time"    />
        <result property="charger1Emg"    column="charger1_emg"    />
        <result property="charger2Ip"    column="charger2_ip"    />
        <result property="charger2Port"    column="charger2_port"    />
        <result property="charger2No"    column="charger2_no"    />
        <result property="charger2Time"    column="charger2_time"    />
        <result property="charger2Emg"    column="charger2_emg"    />
        <result property="charger3Ip"    column="charger3_ip"    />
        <result property="charger3Port"    column="charger3_port"    />
        <result property="charger3No"    column="charger3_no"    />
        <result property="charger3Time"    column="charger3_time"    />
        <result property="charger3Emg"    column="charger3_emg"    />
        <result property="charger4Ip"    column="charger4_ip"    />
        <result property="charger4Port"    column="charger4_port"    />
        <result property="charger4No"    column="charger4_no"    />
        <result property="charger4Time"    column="charger4_time"    />
        <result property="charger4Emg"    column="charger4_emg"    />
        <result property="charger5Ip"    column="charger5_ip"    />
        <result property="charger5Port"    column="charger5_port"    />
        <result property="charger5No"    column="charger5_no"    />
        <result property="charger5Time"    column="charger5_time"    />
        <result property="charger5Emg"    column="charger5_emg"    />
        <result property="charger6Ip"    column="charger6_ip"    />
        <result property="charger6Port"    column="charger6_port"    />
        <result property="charger6No"    column="charger6_no"    />
        <result property="charger6Time"    column="charger6_time"    />
        <result property="charger6Emg"    column="charger6_emg"    />
        <result property="charger7Ip"    column="charger7_ip"    />
        <result property="charger7Port"    column="charger7_port"    />
        <result property="charger7No"    column="charger7_no"    />
        <result property="charger7Time"    column="charger7_time"    />
        <result property="charger7Emg"    column="charger7_emg"    />
        <result property="charger8Ip"    column="charger8_ip"    />
        <result property="charger8Port"    column="charger8_port"    />
        <result property="charger8No"    column="charger8_no"    />
        <result property="charger8Time"    column="charger8_time"    />
        <result property="charger8Emg"    column="charger8_emg"    />
        <result property="isAutoChangeWarehouse" column="is_auto_change_warehouse"/>
    </resultMap>

    <sql id="selectPwtConfigVo">
        select id, website_enabled, system_name, system_ip, system_port, admin_expire_time,last_backup_time,
        charge_soc, cloud_enabled, cloud_address, cloud_account, cloud_password, agreement_type,
        vehicle_cidr, robot_ip, robot_port, robot_no, scanner_ip, scanner_port, rfid_ip, rfid_port,
        charger1_ip, charger1_port, charger1_no, charger1_time, charger1_emg, charger2_ip, charger2_port, charger2_no, charger2_time, charger2_emg,
        charger3_ip, charger3_port, charger3_no, charger3_time, charger3_emg, charger4_ip, charger4_port, charger4_no, charger4_time, charger4_emg,
        charger5_ip, charger5_port, charger5_no, charger5_time, charger5_emg, charger6_ip, charger6_port, charger6_no, charger6_time, charger6_emg,
        charger7_ip, charger7_port, charger7_no, charger7_time, charger7_emg, charger8_ip, charger8_port, charger8_no, charger8_time, charger8_emg,
        is_auto_change_warehouse from pwt_config
    </sql>

    <select id="selectPwtConfigList" parameterType="PwtConfig" resultMap="PwtConfigResult">
        <include refid="selectPwtConfigVo"/>
        <where>  
            <if test="systemName != null  and systemName != ''"> and system_name like concat('%', #{systemName}, '%')</if>
        </where>
    </select>
    
    <select id="selectPwtConfigById" parameterType="Long" resultMap="PwtConfigResult">
        <include refid="selectPwtConfigVo"/>
        where id = #{id}
    </select>
        
    <update id="updatePwtConfig" parameterType="PwtConfig">
        update pwt_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="websiteEnabled != null">website_enabled = #{websiteEnabled},</if>
            <if test="systemName != null">system_name = #{systemName},</if>
            <if test="systemIp != null">system_ip = #{systemIp},</if>
            <if test="systemPort != null">system_port = #{systemPort},</if>
            <if test="adminExpireTime != null">admin_expire_time = #{adminExpireTime},</if>
            <if test="lastBackupTime != null">last_backup_time = #{lastBackupTime},</if>
            <if test="chargeSoc != null">charge_soc = #{chargeSoc},</if>
            <if test="cloudEnabled != null">cloud_enabled = #{cloudEnabled},</if>
            <if test="cloudAddress != null">cloud_address = #{cloudAddress},</if>
            <if test="cloudAccount != null">cloud_account = #{cloudAccount},</if>
            <if test="cloudPassword != null">cloud_password = #{cloudPassword},</if>
            <if test="agreementType != null">agreement_type = #{agreementType},</if>
            <if test="vehicleCidr != null">vehicle_cidr = #{vehicleCidr},</if>
            <if test="robotIp != null">robot_ip = #{robotIp},</if>
            <if test="robotPort != null">robot_port = #{robotPort},</if>
            <if test="robotNo != null">robot_no = #{robotNo},</if>
            <if test="scannerIp != null">scanner_ip = #{scannerIp},</if>
            <if test="scannerPort != null">scanner_port = #{scannerPort},</if>
            <if test="rfidIp != null">rfid_ip = #{rfidIp},</if>
            <if test="rfidPort != null">rfid_port = #{rfidPort},</if>
            <if test="charger1Ip != null">charger1_ip = #{charger1Ip},</if>
            <if test="charger1Port != null">charger1_port = #{charger1Port},</if>
            <if test="charger1No != null">charger1_no = #{charger1No},</if>
            <if test="charger1Time != null">charger1_time = #{charger1Time},</if>
            <if test="charger1Emg != null">charger1_emg = #{charger1Emg},</if>
            <if test="charger2Ip != null">charger2_ip = #{charger2Ip},</if>
            <if test="charger2Port != null">charger2_port = #{charger2Port},</if>
            <if test="charger2No != null">charger2_no = #{charger2No},</if>
            <if test="charger2Time != null">charger2_time = #{charger2Time},</if>
            <if test="charger2Emg != null">charger2_emg = #{charger2Emg},</if>
            <if test="charger3Ip != null">charger3_ip = #{charger3Ip},</if>
            <if test="charger3Port != null">charger3_port = #{charger3Port},</if>
            <if test="charger3No != null">charger3_no = #{charger3No},</if>
            <if test="charger3Time != null">charger3_time = #{charger3Time},</if>
            <if test="charger3Emg != null">charger3_emg = #{charger3Emg},</if>
            <if test="charger4Ip != null">charger4_ip = #{charger4Ip},</if>
            <if test="charger4Port != null">charger4_port = #{charger4Port},</if>
            <if test="charger4No != null">charger4_no = #{charger4No},</if>
            <if test="charger4Time != null">charger4_time = #{charger4Time},</if>
            <if test="charger4Emg != null">charger4_emg = #{charger4Emg},</if>
            <if test="charger5Ip != null">charger5_ip = #{charger5Ip},</if>
            <if test="charger5Port != null">charger5_port = #{charger5Port},</if>
            <if test="charger5No != null">charger5_no = #{charger5No},</if>
            <if test="charger5Time != null">charger5_time = #{charger5Time},</if>
            <if test="charger5Emg != null">charger5_emg = #{charger5Emg},</if>
            <if test="charger6Ip != null">charger6_ip = #{charger6Ip},</if>
            <if test="charger6Port != null">charger6_port = #{charger6Port},</if>
            <if test="charger6No != null">charger6_no = #{charger6No},</if>
            <if test="charger6Time != null">charger6_time = #{charger6Time},</if>
            <if test="charger6Emg != null">charger6_emg = #{charger6Emg},</if>
            <if test="charger7Ip != null">charger7_ip = #{charger7Ip},</if>
            <if test="charger7Port != null">charger7_port = #{charger7Port},</if>
            <if test="charger7No != null">charger7_no = #{charger7No},</if>
            <if test="charger7Time != null">charger7_time = #{charger7Time},</if>
            <if test="charger7Emg != null">charger7_emg = #{charger7Emg},</if>
            <if test="charger8Ip != null">charger8_ip = #{charger8Ip},</if>
            <if test="charger8Port != null">charger8_port = #{charger8Port},</if>
            <if test="charger8No != null">charger8_no = #{charger8No},</if>
            <if test="charger8Time != null">charger8_time = #{charger8Time},</if>
            <if test="charger8Emg != null">charger8_emg = #{charger8Emg},</if>
        </trim>
        where id = #{id}
    </update>
    <update id="changeAutoChangeWarehouse">
        update pwt_config set is_auto_change_warehouse = #{isAutoChangeWarehouse}
        where id = #{id}
    </update>
    <select id="getIsAutoChangeWarehouse" resultType="boolean">
        select is_auto_change_warehouse from pwt_config where id = #{id}
    </select>

</mapper>