<?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.tofly.watermeter.mapper.FileMapper">

    <resultMap id="fileMap" type="com.tofly.watermeter.entity.File">
        <id property="id" column="ID"/>
        <result property="tableName" column="TABLE_NAME"/>
        <result property="tableId" column="TABLE_ID"/>
        <result property="filePath" column="FILE_PATH"/>
        <result property="statusFlag" column="STATUS_FLAG"/>
        <result property="fileName" column="FILE_NAME"/>
        <result property="otherName" column="OTHER_NAME"/>
        <result property="fileFormat" column="FILE_FORMAT"/>
        <result property="fileSize" column="FILE_SIZE"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"></association>
    </resultMap>

    <select id="getMaxId" resultType="java.lang.Integer">
        SELECT nvl(MAX(ID), 0) + 1
        FROM TF_YWPN_FILE_W
    </select>

    <insert id="saveManul">
        INSERT INTO TF_YWPN_FILE_W(ID, FILE_PATH, FILE_NAME, OTHER_NAME, TABLE_NAME, FILE_FORMAT, FILE_SIZE,
                                   CREATE_TIME, CREATE_USER)
        VALUES (#{localFile.id}, #{localFile.filePath}, #{localFile.fileName}, #{localFile.otherName},
                #{localFile.tableName}, #{localFile.fileFormat},
                #{localFile.fileSize}, #{localFile.createTime}, #{localFile.createUser})
    </insert>


    <update id="updateCbFileId" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
            UPDATE TF_YWPN_READMETERHIS_W
            SET FILEID = #{item.fileid}
            WHERE SOLE_SIGN = #{item.soleSign}
        </foreach>
    </update>
</mapper>
