<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.JiLinImportUser" name="execl导入">
    <insert id="saveImportUserJob" parameterType="map">
        insert into jl_grid_user_import
        (
        file_name,
        orginal_obs_key,
        orginal_obs_url,
        orginal_obs_upload_fail_reason,
        job_status,
        office_id,
        create_by,
        create_time
        )
        values
        (
        #{fileName},
        #{orginalObsKey},
        #{orginalObsUrl},
        #{orginalObsUploadFailReason},
        #{jobStatus},
        #{officeId},
        #{createBy},
        #{createTime}
        )
    </insert>
    <select id="selectUserImportPage" parameterType="page" resultType="map">
        select a.* from (select
          id jobId,
          file_name fileName,
          create_time createTime,
          job_status jobStatus,
          deal_result_message dealResultMessage,
          deal_result dealResult,
          error_obs_key errorObsKey
        from
          jl_grid_user_import
        where
          create_by = #{params.userId}
          AND create_time &gt; #{params.sevenDaysBefore}
        <if test="params.fileName != null and params.fileName != ''">
            AND file_name like  concat('%',#{params.fileName},"%")
        </if>
        <if test="params.jobStatus != null and params.jobStatus != '' ">
            AND job_status = #{params.jobStatus}
        </if>
        <if test="params.importTimeStar != null and params.importTimeStar != ''">
            AND create_time  &gt;=  #{params.importTimeStar}
        </if>
        <if test="params.importTimeEnd != null and params.importTimeEnd !=''">
            AND create_time  &lt;=  #{params.importTimeEnd}
        </if>
        order by create_time desc) a
    </select>

    <select id="findFirstOne"  resultType="map">
        select
        id id,
        file_name fileName,
        job_status jobStatus,
        deal_result dealResult,
        orginal_obs_key orginalObsKey,
        create_by createBy,
        office_id officeId
        from
        jl_grid_user_import
        where
        job_status = 0
        order by create_time asc limit 1
    </select>

    <update id="updateFileTask" parameterType="map">
        UPDATE jl_grid_user_import
        <set>
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="orginalObsKey != null">orginal_obs_key = #{orginalObsKey},</if>
            <if test="orginalObsUrl != null">orginal_obs_url = #{orginalObsUrl},</if>
            <if test="errorObsKey != null">error_obs_key = #{errorObsKey},</if>
            <if test="errorObsUrl != null">error_obs_url = #{errorObsUrl},</if>
            <if test="orginalObsUploadFailReason != null">orginal_obs_upload_fail_reason = #{orginalObsUploadFailReason},</if>
            <if test="orginalObsDownloadFailReason != null">orginal_obs_download_fail_reason = #{orginalObsDownloadFailReason},</if>
            <if test="errorObsUploadFailReason != null">error_obs_upload_fail_reason = #{errorObsUploadFailReason},</if>
            <if test="jobStatus != null">job_status = #{jobStatus},</if>
            <if test="dealTime != null">deal_time = #{dealTime},</if>
            <if test="dealResult != null">deal_result = #{dealResult},</if>
            <if test="dealResultMessage != null">deal_result_message = #{dealResultMessage},</if>
            <if test="officeId != null">office_id = #{officeId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </set>
        WHERE id = #{id}
    </update>
</mapper>
