Newer
Older
huludao / src / main / resources / mapper / Assessment / AssessmentTemplateDao.xml
<?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.newfiber.api.pc.dao.Assessment.AssessmentTemplateDao" >

	<resultMap type="com.newfiber.api.pc.model.Assessment.AssessmentTemplate" id="BaseResultMap">
		<id column="Serial" property="serial" jdbcType="BIGINT"/>
		<result column="Template_No" property="templateNo" jdbcType="VARCHAR"/>
		<result column="Assessment_Content" property="assessmentContent" jdbcType="NVARCHAR"/>
		<result column="Assessment_Type" property="assessmentType" jdbcType="INTEGER"/>
		<result column="Assessment_Type_ZN" property="assessmentTypeZN" jdbcType="NVARCHAR"/>
		<result column="Assessment_Division" property="assessmentDivision" jdbcType="VARCHAR"/>
		<result column="Start_Time" property="startTime" jdbcType="TIMESTAMP"/>
		<result column="End_Time" property="endTime" jdbcType="TIMESTAMP"/>
		<result column="Excellent_Score" property="excellentScore" jdbcType="NUMERIC"/>
		<result column="Good_Score" property="goodScore" jdbcType="NUMERIC"/>
		<result column="Qualified_Score" property="qualifiedScore" jdbcType="NUMERIC"/>
		<result column="Proportion" property="proportion" jdbcType="NUMERIC"/>
		<result column="Create_Time" property="createTime" jdbcType="TIMESTAMP"/>
		<result column="OrderSort" property="orderSort" jdbcType="INTEGER"/>
		<result column="Remark" property="remark" jdbcType="NVARCHAR"/>
		<collection column="Template_No" property="itemList" ofType="com.newfiber.api.pc.model.Assessment.AssessmentItem"
					select="com.newfiber.api.pc.dao.Assessment.AssessmentItemDao.getAssessmentItemList">
		</collection>
	</resultMap>


   <select id="findAll" parameterType="com.newfiber.api.pc.model.Assessment.AssessmentTemplate" resultMap="BaseResultMap">
   SELECT Serial,Template_No,Assessment_Content,Assessment_Type,Assessment_Type_ZN,Assessment_Division,DATE_FORMAT(Start_Time,'%Y-%m-%d %T') sTime,
       DATE_FORMAT(End_Time,'%Y-%m-%d %T') eTime,Excellent_Score,Good_Score,Qualified_Score,Proportion,DATE_FORMAT(Create_Time,'%Y-%m-%d %T') cTime,OrderSort,Remark
   FROM assessment_template
   where 
   		1=1
   		<if test="assessmentDivision != null and assessmentDivision != ''">
  		AND	(Assessment_Division=#{assessmentDivision} or Assessment_Division='0')
   		</if>
   		<if test="startTime != null and endTime == null"> 
   		AND Create_Time &gt; #{startTime}
   		</if>
   		<if test="startTime == null and endTime != null">
   		AND Create_Time &lt; #{endTime}
   		</if>
   		<if test="startTime != null and endTime != null">
   		AND Start_Time between #{startTime} and #{endTime}
   		</if>
       <if test="remark != null">
           and Remark = #{remark}
       </if>
   		order by Create_Time desc
   		<if test="pageSize != 0">
            limit #{pageNo},#{pageSize}
   		</if>
   </select>
   
   <select id="countAssessmentTemplate" parameterType="com.newfiber.api.pc.model.Assessment.AssessmentTemplate" resultType="int" >
   SELECT count(Serial) FROM assessment_template
   where 
   		1=1
   		<if test="assessmentDivision != null">
  		AND	(Assessment_Division=#{assessmentDivision} or Assessment_Division='0')
   		</if>
   		<if test="startTime != null and endTime == null"> 
   		AND Create_Time &gt; #{startTime}
   		</if>
   		<if test="startTime == null and endTime != null">
   		AND Create_Time &lt; #{endTime}
   		</if>
   		<if test="startTime != null and endTime != null">
   		AND Create_Time between #{startTime} and #{endTime}
   		</if>
       <if test="remark != null">
           and Remark = #{remark}
       </if>
   </select>



   <select id="find" parameterType="com.newfiber.api.pc.model.Assessment.AssessmentTemplate" resultMap="BaseResultMap">
   SELECT Serial,Template_No,Assessment_Content,Assessment_Type,Assessment_Type_ZN,Assessment_Division,DATE_FORMAT(Start_Time,'%Y-%m-%d %T') sTime,
   			DATE_FORMAT(End_Time,'%Y-%m-%d %T') eTime,Excellent_Score,Good_Score,Qualified_Score,Proportion,DATE_FORMAT(Create_Time,'%Y-%m-%d %T') cTime,OrderSort,Remark
   FROM assessment_template
   where Serial = #{serial}
   </select>
  
  <delete id="deleteTemplate" parameterType="com.newfiber.api.pc.model.Assessment.AssessmentTemplate" >
    delete from assessment_template
    where Template_No=#{templateNo}
  </delete>
  

  <insert id="insertTemplate" parameterType="com.newfiber.api.pc.model.Assessment.AssessmentTemplate" >
    insert into assessment_template
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="templateNo != null" >
        Template_No,
      </if>
      <if test="assessmentContent != null" >
        Assessment_Content,
      </if>
      <if test="assessmentType != null" >
        Assessment_Type,
      </if>
      <if test=" assessmentTypeZN != null" >
        Assessment_Type_ZN,
      </if>
      <if test=" assessmentDivision != null" >
        Assessment_Division,
      </if>
      <if test="startTime != null" >
        Start_Time,
      </if>  
      <if test="endTime != null" >
        End_Time,
      </if>
      <if test="excellentScore != null" >
        Excellent_Score,
      </if>
      <if test="goodScore != null" >
        Good_Score,
      </if>
      <if test="qualifiedScore != null" >
        Qualified_Score,
      </if>
      <if test="proportion != null" >
        Proportion,
      </if>
      <if test="createTime != null" >
        Create_Time,
      </if>
      <if test="orderSort != null" >
        OrderSort,
      </if>
      <if test="remark != null" >
        Remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="templateNo != null" >
        #{templateNo,jdbcType=VARCHAR},
      </if>
      <if test="assessmentContent != null" >
        #{assessmentContent,jdbcType=NVARCHAR},
      </if>
      <if test="assessmentType != null" >
        #{assessmentType,jdbcType=INTEGER},
      </if>
      <if test="assessmentTypeZN != null" >
        #{assessmentTypeZN,jdbcType=NVARCHAR},
      </if>
      <if test="assessmentDivision != null" >
        #{assessmentDivision,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null" >
        #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null" >
        #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="excellentScore != null" >
        #{excellentScore,jdbcType=NUMERIC},
      </if>
      <if test="goodScore != null" >
        #{goodScore,jdbcType=NUMERIC},
      </if>
      <if test="qualifiedScore != null" >
        #{qualifiedScore,jdbcType=NUMERIC},
      </if>
      <if test="proportion != null" >
        #{proportion,jdbcType=NUMERIC},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="orderSort != null" >
        #{orderSort,jdbcType=INTEGER},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=NVARCHAR},
      </if>
    </trim>
  </insert>
  
  <select id="getRCByDivisionNo" parameterType="java.util.List" resultType="java.lang.String">
	SELECT
		r.Chief_User_No
	FROM
		river_chief r
	INNER JOIN river_info_basis i ON i.River_No = r.River_No
	WHERE
		i.Division_No IN
		<foreach collection="list" index="index" item="item" open="(" separator="," close=")" >
		#{item}
		</foreach>  
  </select>
  
  
</mapper>