<?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.HzzWpsMapper">
    <select id="querySupervision" resultType="com.goldenwater.hzz.domain.WpsDTO">
        SELECT hw.GUID AS "guid", hw.SM_ID AS "smId", hw.SUPERVISION AS "supervision",
               TO_CHAR(hw.START_DATE,'YYYY-MM-DD HH24:MI:SS') AS "startDate",
               TO_CHAR(hw.END_DATE,'YYYY-MM-DD HH24:MI:SS') AS "endDate",
               wrp.S_PROJECT_NAME AS "sProjectName"
        FROM HZZ_WPS hw LEFT JOIN GW_RIVER_PROJECT wrp ON hw.SM_ID=wrp.GUID
        WHERE 1=1
        <if test="sProjectName != null and sProjectName != ''">AND wrp.S_PROJECT_NAME LIKE '%'||#{sProjectName}||'%'</if>
        <if test="startDate != null and startDate != ''">AND hw.START_DATE&gt;=TO_DATE(#{startDate},'YYYY-MM-DD HH24:MI:SS')</if>
        <if test="endDate != null and endDate != ''">AND hw.END_DATE&lt;=TO_DATE(#{endDate},'YYYY-MM-DD HH24:MI:SS')</if>
        ORDER BY hw.START_DATE DESC
    </select>
    <select id="queryXmList" resultType="com.goldenwater.hzz.domain.WpsDTO">SELECT GUID AS "guid",S_PROJECT_NAME AS "sProjectName" FROM GW_RIVER_PROJECT</select>
    <insert id="insertShxmDc">INSERT INTO HZZ_WPS(GUID,SM_ID,SUPERVISION,START_DATE,END_DATE) VALUES(#{guid},#{smId},#{supervision},TO_DATE(#{startDate},'YYYY-MM-DD HH24:MI:SS'),TO_DATE(#{endDate},'YYYY-MM-DD HH24:MI:SS'))</insert>
    <insert id="insertShxmFiles" parameterType="java.util.List">INSERT ALL <foreach collection="list" item="item">INTO HZZ_WPS_FILE(GUID,WPS_ID,URL) VALUES(#{item.guid},#{item.wpsId},#{item.url})</foreach> SELECT 1 FROM DUAL</insert>
    <update id="updateShxmDc">UPDATE HZZ_WPS SET SM_ID=#{smId},SUPERVISION=#{supervision},START_DATE=TO_DATE(#{startDate},'YYYY-MM-DD HH24:MI:SS'),END_DATE=TO_DATE(#{endDate},'YYYY-MM-DD HH24:MI:SS') WHERE GUID=#{guid}</update>
    <delete id="deleteShxmDcFiles">DELETE FROM HZZ_WPS_FILE WHERE WPS_ID=#{guid}</delete>
    <delete id="deleteShxmDc">DELETE FROM HZZ_WPS WHERE GUID=#{guid}</delete>
</mapper>
