<?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.goldenwater.hzz.mapper.RuleMapper">
    <select id="getRuleMessage" resultType="com.goldenwater.hzz.domain.RuleExecDTO">
        SELECT A.RULE_CODE AS sysCode, D.MD_NAME AS sysName, A.RULE_TYPE AS sysType,
               D.FILE_PATH AS attc, A.FILE_NUM AS fileNum, A.RULE_PROGRESS AS ruleProgress,
               D.FILE_TITL AS fileTitle, TO_CHAR(D.RELE_DATE,'YYYY-MM-DD') AS rlsTm,
               D.RELE_WIUN_NAME AS releWiunName
        FROM ATT_RULE_EXEC A
        INNER JOIN REL_WORK_RULE_AD B ON A.RULE_CODE=B.rule_code AND B.TO_DATE IS NULL AND B.AD_CODE=#{adCode}
        INNER JOIN REL_MD_OBJ C ON A.GUID=C.OBJ_GUID AND C.TO_DATE IS NULL
        INNER JOIN ATT_MD_BASE D ON C.MD_GUID=D.GUID AND D.TO_DATE IS NULL
        WHERE A.EXPR_DATE IS NULL
        <if test="ruleType != null and ruleType != ''">AND A.RULE_TYPE=#{ruleType}</if>
    </select>
    <select id="getWsnList" resultType="com.goldenwater.hzz.domain.FileWsnDTO">
        SELECT GUID,FILE_NAME AS fileName,FILE_TYPE AS fileType,WH,TO_CHAR(START_DATE,'YYYY-MM-DD HH24:MI:SS') AS startDate,URL AS url,TYPES AS types
        FROM GW_FILE_WSN WHERE TYPES=#{types}
        <if test="fileName != null and fileName != ''">AND FILE_NAME LIKE '%'||#{fileName}||'%'</if>
        <if test="fileType != null and fileType != ''">AND FILE_TYPE=#{fileType}</if>
        <if test="startTime != null and startTime != ''">AND START_DATE&gt;=TO_DATE(#{startTime},'YYYY-MM-DD HH24:MI:SS')</if>
        <if test="endTime != null and endTime != ''">AND START_DATE&lt;=TO_DATE(#{endTime},'YYYY-MM-DD HH24:MI:SS')</if>
        ORDER BY START_DATE DESC
    </select>
    <insert id="insertWsn" parameterType="com.goldenwater.hzz.domain.FileWsnDTO">
        INSERT INTO GW_FILE_WSN(GUID,FILE_NAME,FILE_TYPE,WH,START_DATE,URL,TYPES)
        VALUES(#{guid},#{fileName},#{fileType},#{wh},TO_DATE(#{startDate},'YYYY-MM-DD HH24:MI:SS'),#{url},#{types})
    </insert>
    <update id="updateWsn">UPDATE GW_FILE_WSN SET FILE_NAME=#{fileName},FILE_TYPE=#{fileType},WH=#{wh},START_DATE=TO_DATE(#{startDate},'YYYY-MM-DD HH24:MI:SS'),URL=#{url} WHERE GUID=#{guid}</update>
    <delete id="deleteWsn">DELETE FROM GW_FILE_WSN WHERE GUID=#{guid}</delete>
    <select id="getArticleList" resultType="com.goldenwater.hzz.domain.ArticleDTO">
        SELECT GUID,TITLE,TYPE,PUBMAN AS pubman,TO_CHAR(PUBTIME,'YYYY-MM-DD HH24:MI:SS') AS pubtime,CONTENT
        FROM GW_ARTICLE WHERE 1=1
        <if test="title != null and title != ''">AND TITLE LIKE '%'||#{title}||'%'</if>
        <if test="type != null and type != ''">AND TYPE=#{type}</if>
        <if test="startTime != null and startTime != ''">AND PUBTIME&gt;=TO_DATE(#{startTime},'YYYY-MM-DD HH24:MI:SS')</if>
        <if test="endTime != null and endTime != ''">AND PUBTIME&lt;=TO_DATE(#{endTime},'YYYY-MM-DD HH24:MI:SS')</if>
        ORDER BY PUBTIME DESC
    </select>
    <insert id="addArticle" parameterType="com.goldenwater.hzz.domain.ArticleDTO">INSERT INTO GW_ARTICLE(GUID,TITLE,TYPE,PUBMAN,PUBTIME,CONTENT) VALUES(#{guid},#{title},#{type},#{pubman},TO_DATE(#{pubtime},'YYYY-MM-DD HH24:MI:SS'),#{content})</insert>
    <update id="updateArticle">UPDATE GW_ARTICLE SET TITLE=#{title},TYPE=#{type},CONTENT=#{content} WHERE GUID=#{guid}</update>
    <delete id="deleteArticle">DELETE FROM GW_ARTICLE WHERE GUID=#{guid}</delete>
    <select id="getArticleTop5" resultType="com.goldenwater.hzz.domain.ArticleDTO">
        SELECT GUID,TITLE,TYPE,PUBMAN AS pubman,TO_CHAR(PUBTIME,'YYYY-MM-DD HH24:MI:SS') AS pubtime,CONTENT
        FROM GW_ARTICLE WHERE TYPE=#{type} AND ROWNUM &lt;6 ORDER BY PUBTIME DESC
    </select>
</mapper>
