Newer
Older
huludao / src / main / resources / mapper / RiverManage / RiverChiefInformationDao.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.RiverManage.RiverChiefInformationDao" >
  <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.RiverChiefInformation" >
    <id column="Serial" property="serial" jdbcType="BIGINT" />
    <result column="Information_No" property="informationNo" jdbcType="VARCHAR" />
    <result column="Chief_User_No" property="chiefUserNo" jdbcType="VARCHAR" />
    <result column="River_Pics_No" property="riverPicsNo" jdbcType="VARCHAR" />
    <result column="Chief_Information" property="chiefInformation" jdbcType="NVARCHAR" />
    <result column="Chief_Duty" property="chiefDuty" jdbcType="NVARCHAR" />
    <result column="Chief_Responsibility" property="riverPicsNo" jdbcType="NVARCHAR" />
    <result column="Create_User_No" property="createUserNo" jdbcType="VARCHAR" />
    <result column="Create_Time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="Update_User_No" property="updateUserNo" jdbcType="VARCHAR" />
    <result column="Update_Time" property="updateTime" jdbcType="TIMESTAMP" />
  </resultMap>

  <select id="selectRiverChiefInformationList" resultType="com.newfiber.api.pc.model.River.RiverChiefInformation" parameterType="com.newfiber.api.pc.model.River.RiverChiefInformation" >
    select
      r.Serial serial,r.Information_No informationNo,r.Chief_User_No chiefUserNo,r.Chief_Information chiefInformation,
      r.Chief_Duty chiefDuty,r.Chief_Responsibility chiefResponsibility,r.River_Pics_No riverPicsNo,
    DATE_FORMAT(r.Create_Time,'%Y-%m-%d %T') time,DATE_FORMAT(r.Update_Time,'%Y-%m-%d %T') updateDateTime,
      b.River_Name riverName,b.River_Grade riverGrade,a.Division_Name divisionName,i.Chief_Grade chiefGrade,i.Chief_Grade_Zn chiefGradeZn,
      b.River_Grade_Zn riverGradeZn,
      o.user_name 'chiefUserName',
      o.phone_num 'phone',
      f.user_name 'createUserName',
      n.user_name 'updateUserName'
      from river_chief_information r
      inner join river_chief i
      on i.Chief_User_No = r.Chief_User_No
      inner join river_info_basis b
      on b.River_No = i.River_No
      inner join huludao_main.sys_user_info o
      on o.User_No = r.Chief_User_No
      left join huludao_main.sys_user_info f
      on f.User_No = r.Create_User_No
      left join huludao_main.sys_user_info n
      on n.User_No = r.Update_User_No
      inner join administrative_division a
      on a.Division_No = b.Division_No
      where 1=1
      <if test="informationNo != null and informationNo != ''">
        and r.Information_No = #{informationNo,jdbcType=VARCHAR}
      </if>
      <if test="chiefUserNo != null and chiefUserNo != ''">
        and r.Chief_User_No = #{chiefUserNo,jdbcType=VARCHAR}
      </if>
      <if test="riverName != null and riverName != ''">
        and b.River_Name like '%${riverName}%'
      </if>
      <if test="createTime != null and createTime != ''">
        and r.Create_Time between #{createTime} and #{endTime}
      </if>
      <if test="pageNo != null" >
        order by r.Serial limit #{pageNo},#{pageSize}
      </if>
  </select>

  <delete id="deleteRiverChiefInformation" parameterType="java.util.List" >
    delete from river_chief_information
    where Information_No in
    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
      #{item}
    </foreach>
  </delete>

  <insert id="addRiverChiefInformation" parameterType="com.newfiber.api.pc.model.River.RiverChiefInformation" >
    insert into river_chief_information
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="informationNo != null">
        Information_No,
      </if>
      <if test="chiefUserNo != null" >
        Chief_User_No,
      </if>
      <if test="chiefInformation != null" >
        Chief_Information,
      </if>
      <if test="chiefDuty != null" >
        Chief_Duty,
      </if>
      <if test="chiefResponsibility != null" >
        Chief_Responsibility,
      </if>
      <if test="riverPicsNo != null" >
        River_Pics_No,
      </if>
      <if test="createUserNo != null" >
        Create_User_No,
      </if>
      <if test="riverGrade != null" >
        River_Grade,
      </if>
      <if test="riverGradeZn != null" >
        River_Grade_Zn,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="informationNo != null">
        #{informationNo,jdbcType=VARCHAR},
      </if>
      <if test="chiefUserNo != null" >
        #{chiefUserNo,jdbcType=VARCHAR},
      </if>
      <if test="chiefInformation != null" >
        #{chiefInformation,jdbcType=NVARCHAR},
      </if>
      <if test="chiefDuty != null" >
        #{chiefDuty,jdbcType=NVARCHAR},
      </if>
      <if test="chiefResponsibility != null" >
        #{chiefResponsibility,jdbcType=NVARCHAR},
      </if>
      <if test="riverPicsNo != null" >
        #{riverPicsNo,jdbcType=VARCHAR},
      </if>
      <if test="createUserNo != null" >
        #{createUserNo,jdbcType=VARCHAR},
      </if>
      <if test="riverGrade != null" >
        #{riverGrade,jdbcType=INTEGER},
      </if>
      <if test="riverGradeZn != null" >
        #{riverGradeZn,jdbcType=NVARCHAR},
      </if>
    </trim>
  </insert>

  <select id="countRiverChiefInformation" parameterType="com.newfiber.api.pc.model.River.RiverChiefInformation" resultType="java.lang.Integer" >
    select count(DISTINCT r.Serial)
      from river_chief_information r
      inner join river_chief i
      on i.Chief_User_No = r.Chief_User_No
      inner join river_info_basis b
      on b.River_No = i.River_No
      inner join huludao_main.sys_user_info o
      on o.User_No = r.Chief_User_No
      inner join huludao_main.sys_user_info f
      on f.User_No = r.Chief_User_No
      left join huludao_main.sys_user_info n
      on n.User_No = r.Chief_User_No
      inner join administrative_division a
      on a.Division_No = b.Division_No
      where 1=1
      <if test="informationNo != null and informationNo != ''">
        and r.Information_No = #{informationNo,jdbcType=VARCHAR}
      </if>
      <if test="chiefUserNo != null and chiefUserNo != ''">
        and r.Chief_User_No = #{chiefUserNo,jdbcType=VARCHAR}
      </if>
      <if test="riverName != null and riverName != ''">
        and b.River_Name like '%${riverName}%'
      </if>
      <if test="createTime != null and createTime != ''">
        and r.Create_Time between #{createTime} and #{endTime}
      </if>
  </select>

  <update id="updateRiverChiefInformation" parameterType="com.newfiber.api.pc.model.River.RiverChiefInformation" >
    update river_chief_information
    <set>
      <if test="chiefInformation != null" >
        Chief_Information = #{chiefInformation,jdbcType=NVARCHAR},
      </if>
      <if test="chiefDuty != null" >
        Chief_Duty = #{chiefDuty,jdbcType=NVARCHAR},
      </if>
      <if test="chiefResponsibility != null" >
        Chief_Responsibility = #{chiefResponsibility,jdbcType=NVARCHAR},
      </if>
      <if test="riverPicsNo != null" >
        River_Pics_No = #{riverPicsNo,jdbcType=VARCHAR},
      </if>
      <if test="updateUserNo != null" >
        Update_User_No = #{updateUserNo,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null" >
        Update_Time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="riverGrade != null " >
        River_Grade = #{riverGrade,jdbcType=INTEGER},
      </if>
      <if test="riverGradeZn != null" >
        River_Grade_Zn = #{riverGradeZn,jdbcType=NVARCHAR},
      </if>
    </set>
    where Information_No = #{informationNo,jdbcType=INTEGER}
  </update>

  <select id="selectUserNoUserNameByRiverGrade" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverChiefInformation" >
    select r.Chief_User_No,
      o.user_name 'chiefUserName'
      from river_chief_information r
      inner join huludao_main.sys_user_info o
      on o.User_No = r.Chief_User_No
      where 1=1
      and r.Chief_User_No not in
      (select v.Chief_User_No
      from river_chief v
      inner join river_info_basis b
      on b.River_No = v.River_No )
      and r.River_Grade = #{riverGrade,jdbcType=INTEGER}
  </select>
</mapper>