IHcFtpFileDAO.xml 11.7 KB
<?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="IHcFtpFileDAO">
	<insert id="insertFileData2Table" parameterType="String">
		$value$ 		
	</insert>
	<insert id="insertFileData2TableFailed" parameterType="String">
		$value$ 		
	</insert>

	<select id="calltaskfunction" parameterType="Map">
		{ call ${functionname}()}
    </select>

<!--

        <select id="calltaskfunctionwithparam" parameterMap="Map">
            { call ${functionname}(?,?)}
        </select>
-->
    <insert id="saveTaskRunLog"
    >

        insert into
        hc_ftp_tasklog(logid,taskid,u_or_d,state,serverfilename,localfilename,filelength)
        values(#{logid},#{taskid},#{uord},#{state},#{serverfilename},#{localfilename},#{filelength})
    </insert>

    <update id="updateTaskRunLog"
    >
        update hc_ftp_tasklog set update_date=SYSDATE()
        <if test="state !=null and state != ''">,state = #{state}
        </if>
        where logid=#{logid}
    </update>


    <insert id="saveTaskRunDetailLog">
        insert into
        hc_ftp_tasklog_detail(id,logid,taskid,state,tnum,begin,end,data,havedown,remark,SERVERFILENAME,LOCALFILENAME)
        values(#{id},#{logid},#{taskid},#{state},#{tnum},#{begin},#{end},#{data},#{havedown},#{remark},#{serverfilename},#{localfilename})
    </insert>


            <insert id="addFtpItem" parameterType="Map">
                insert into hc_ftp_task(taskid,
                taskname,
                file_name,
                u_or_d,
                tnum,
                taskcron,
                errphone,
                fileseq,
                upnull,
                preflag,
                prefunction,
                afterflag,
                afterfunction,
                deal_class)
                values(#{taskId},
                #{taskName},
                #{fileName},
                #{uOrD},
                #{tNum},
                #{taskCron},
                #{errPhone},
                #{fileSeq},
                #{upNull},
                #{preFlag},
                #{preFunction},
                #{afterFlag},
                #{afterFunction},
                #{dealClass}
                )
            </insert>



            <select id="queryTaskDetailInfo" parameterType="long"
                resultType="Map">
                select * from hc_ftp_tasklog_detail
                where detailid=#{value}
            </select>
            <select id="queryFtpUserInfo" parameterType="long" resultType="Map">
                select ftp_userid,machine_id,username,pwd,ip,port,
                state,
                to_char(update_date,'yyyy-mm-dd hh24:mi:ss') updatedate,
                to_char(create_date,'yyyy-mm-dd hh24:mi:ss') createdate,
                remark
                from CEP_FTP_TASKUSER
                where ftp_userid=#{value}
            </select>


            <select id="execConfigSql" parameterType="String" resultType="String">
                $value$
            </select>


            <select id="queryFtpItemsCount" parameterType="Map"
                resultType="Integer">
                SELECT count(1)
                FROM hc_ftp_task A
                WHERE A.STATE = 'A'

            </select>
            <!-- 查询文件下载上传列表(配置项) -->
            <select id="queryFtpItems" parameterType="Map" resultType="Map">
            <![CDATA[
                select * from (
                 SELECT @rownum :=@rownum+1 as rn,A.TASKID,
                       A.TASKNAME,
                       A.FILE_NAME,
                       A.U_OR_D,
                       A.RUN_STATE,
                       A.RUN_FLAG,
                       A.TNUM,
                       A.TASKCRON,
                       A.ERRPHONE,
                       A.FILESEQ,
                       A.UPNULL,
                       A.PREFLAG,
                       A.PREFUNCTION,
                       A.AFTERFLAG,
                       A.AFTERFUNCTION,
                       A.DEAL_CLASS,
                       A.CREATE_DATE
                  FROM hc_ftp_task A
                 WHERE A.STATE = 'A') A1
                 where  1 = 1 limit #{curPage},#{pageSize}
            ]]>
            </select>
           <!-- <select id="newCreateTaskId" resultType="long">
                    <![CDATA[
                    SELECT seq_cep_taskid.NEXTVAL  AS taskId from dual
                    ]]>
            </select>-->

            <!-- 根据taskId 查询FtpItem 信息 -->
            <select id="queryFtpItemByTaskId" parameterType="Map"
                resultType="Map">
                SELECT A.TASKID,
                A.TASKNAME,
                A.FILE_NAME,
                A.U_OR_D,
                A.RUN_STATE,
                A.RUN_FLAG,
                A.TNUM,
                A.TASKCRON,
                A.ERRPHONE,
                A.FILESEQ,
                A.UPNULL,
                A.PREFLAG,
                A.PREFUNCTION,
                A.AFTERFLAG,
                A.AFTERFUNCTION,
                A.DEAL_CLASS,
                A.CREATE_DATE
                FROM hc_ftp_task A
                WHERE A.STATE = 'A'
                and A.TASKID = #{taskId}
            </select>
            <!-- 根据任务名称搜素 -->
            <select id="searchFtpItemByTaskName" parameterType="Map"
                resultType="Map">
            <![CDATA[
                SELECT A.TASKID,
                A.TASKNAME,
                A.FILE_NAME,
                A.U_OR_D,
                A.RUN_STATE,
                A.RUN_FLAG,
                A.TNUM,
                A.TASKCRON,
                A.ERRPHONE,
                A.FILESEQ,
                A.UPNULL,
                A.PREFLAG,
                A.PREFUNCTION,
                A.AFTERFLAG,
                A.AFTERFUNCTION,
                A.DEAL_CLASS,
                A.CREATE_DATE
                FROM hc_ftp_task A
                WHERE A.STATE = 'A'
                and A.TASKNAME like '%' || #{taskName} || '%'
                and rownum < 1000
            ]]>
            </select>
            <!-- 修改ftp配置信息 -->
            <update id="updateFtpItemByTaskId" parameterType="Map">
                update hc_ftp_task sft
                set update_date = SYSDATE()
                <if test="taskName !=null and taskName != ''">,sft.taskname = #{taskName}
                </if>
                <if test="fileName !=null and fileName != ''">,sft.file_name = #{fileName}
                </if>
                <if test="uOrD !=null and uOrD != ''">,sft.u_or_d = #{uOrD}</if>
                <if test="runState !=null and runState != ''">,sft.run_state = #{runState}
                </if>
                <if test="runFlag !=null and runFlag != ''">,sft.run_flag = #{runFlag}</if>
                <if test="tNum !=null and tNum != ''">,sft.tnum = #{tNum}</if>
                <if test="taskCron !=null and taskCron != ''">,sft.taskcron = #{taskCron}
                </if>
                <if test="errPhone !=null and errPhone != ''">,sft.errphone = #{errPhone}
                </if>
                <if test="fileSeq !=null and fileSeq != ''">,sft.fileseq = #{fileSeq}</if>
                <if test="upNull !=null and upNull != ''">,sft.upnull = #{upNull}</if>
                <if test="preFlag !=null and preFlag != ''">,sft.preflag = #{preFlag}</if>
                <if test="preFunction !=null and preFunction != ''">,sft.prefunction = #{preFunction}
                </if>
                <if test="afterFlag !=null and afterFlag != ''">,sft.afterflag = #{afterFlag}		</if>
                <if test="afterFunction !=null and afterFunction != ''">,sft.afterfunction = #{afterFunction}
                </if>
                <if test="dealClass !=null and dealClass != ''">,sft.deal_class = #{dealClass}
                </if>
                where sft.state = 'A'
                and sft.taskid = #{taskId}
            </update>

            <!-- 修改ftp配置信息 -->
            <update id="updateFtpItemRunState" parameterType="Map">
                update
                hc_ftp_task sft
                set update_date = SYSDATE(),sft.run_state= #{runState}
                where sft.run_state = #{oldRunState}
            </update>

            <!-- 删除ftp配置信息 -->
            <update id="deleteFtpItemByTaskId" parameterType="Map">
                update
                hc_ftp_task sft
                set sft.state = 'R'
                where sft.state = 'A'
                and sft.taskid in
                <foreach collection="taskIds" open="(" close=")"
                         separator=","  item="item">
                            #{item}
                </foreach>
            </update>
            <!-- 根据taskids 获取将要操作的ftp配置信息 -->
            <select id="queryFtpItemsByTaskIds" parameterType="Map" resultType="Map">
                SELECT
                A.TASKID,
                A.TASKNAME,
                A.FILE_NAME,
                A.U_OR_D,
                A.RUN_STATE,
                A.RUN_FLAG,
                A.TNUM,
                A.TASKCRON,
                A.ERRPHONE,
                A.FILESEQ,
                A.UPNULL,
                A.PREFLAG,
                A.PREFUNCTION,
                A.AFTERFLAG,
                A.AFTERFUNCTION,
                A.DEAL_CLASS
                FROM hc_ftp_task A
                WHERE A.STATE = 'A'
                AND A.TASKID in
                <foreach open="(" close=")"
                         separator="," collection="taskIds" item="item">
                            #{item}
                </foreach>
            </select>
            <!-- 查询FTPItem的属性信息 -->
            <select id="queryFtpItemAttrsByTaskId" parameterType="Map"
                resultType="Map">
                SELECT A.TASKID, A.ITEM_SPEC_ID, A.VALUE
                FROM hc_ftp_task_attr A
                WHERE A.TASKID = #{taskId}
            </select>
            <!-- 保存FTPItem的属性信息 -->
            <insert id="addFtpItemAttrs" parameterType="Map">
                insert into
                hc_ftp_task_attr(taskid,item_spec_id,value)
                values(#{taskId},#{itemSpecId},#{value})
            </insert>
            <!-- 查询没有下载过的文件名 -->
            <select id="queryFileNamesWithOutFtpLog" parameterType="Map"
                resultType="Map">
                <![CDATA[
                SELECT #{fileNames} AS fileNames FROM DUAL
                 where #{fileNames} not in
                       (select sfl.file_name from hc_ftp_log sfl where sfl.taskId = #{taskId})
                ]]>
            </select>

            <insert id="addDownloadFileName" parameterType="Map">
                <selectKey keyProperty="logid" resultType="long">
                    <![CDATA[
                    SELECT seq_cep_taskid.NEXTVAL  AS logid from dual
                    ]]>
                </selectKey>
            insert into hc_ftp_log(
            log_id,
            taskid,
            file_name,
            tfs_file_name
            )
            values(
            #{logid},
            #{taskId},
            #{fileName},
            #{tfsFileName}
            )
            </insert>


            <select id="queryItemSpec" parameterType="Map" resultType="Map">
                select a.item_spec_cd as ITEM_SPEC_CD, a.domain as DOMAIN, a.name as NAME, a.describes as DESCRIBES, a.create_date as CREATE_DATE
                from hc_ftp_item_spec a
                where a.status_cd = '0'
                <if test="domain != null and domain !='' "> and a.domain = #{domain}</if>
                <if test="name != null and name !='' "> and a.name = #{name}</if>
                <if test="itemSpecCd != null and itemSpecCd !='' "> and a.item_spec_cd = #{itemSpecCd}
                </if>
            </select>
</mapper>