Newer
Older
huludao / src / main / resources / mapper / RiverManage / PatrolDaysConfigDao.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.PatrolDaysConfigDao" >
  <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.PatrolDaysConfig" >
    <id column="Serial" property="serial" jdbcType="BIGINT" />
    <result column="River_No" property="riverNo" jdbcType="VARCHAR" />
    <result column="Chief_User_No" property="chiefUserNo" jdbcType="VARCHAR" />
    <result column="Patrol_Days" property="patrolDays" jdbcType="INTEGER" />
    <result column="Create_User_No" property="createUserNo" jdbcType="VARCHAR" />
    <result column="Update_User_No" property="updateUserNo" jdbcType="VARCHAR" />
    <result column="Create_Time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="Update_Time" property="updateTime" jdbcType="TIMESTAMP" />
  </resultMap>

  <sql id="Base_Column_List">
    Serial, River_No, Chief_User_No, Patrol_Days, Create_User_No, Create_Time, Update_User_No,
    Update_Time
  </sql>

  <select id="selectPatrolDaysConfigList" resultType="com.newfiber.api.pc.model.River.PatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig" >
    select
      r.Serial serial,r.River_No riverNo,r.Chief_User_No chiefUserNo,r.Patrol_Days patrolDays,
      r.Create_User_No createUserNo,r.Update_User_No updateUserNo,
    DATE_FORMAT(r.Create_Time,'%Y-%m-%d %T') createTime,DATE_FORMAT(r.Update_Time,'%Y-%m-%d %T') updateDateTime,
      b.River_Name riverName,
      i.user_name 'userName',
      o.user_name 'createUserName',
      k.user_name 'updateUserName'
      from patrol_days_config r
      inner join huludao_main.sys_user_info i
      on i.User_No = r.Chief_User_No
      inner join huludao_main.sys_user_info o
      on o.User_No = r.Create_User_No
      left join huludao_main.sys_user_info k
      on k.User_No = r.Update_User_No
      inner join river_info_basis b
      on b.River_No= r.River_No
      where 1=1
      <if test="list != null and list.size > 0">
        and r.Chief_User_No in
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
          #{item}
        </foreach>
      </if>
      <if test="list == null">
        and r.Chief_User_No = 'ewrwe123132'
      </if>
      <if test="riverName != null and riverName != ''">
        and b.River_Name like '%${riverName}%'
      </if>
      <if test="riverGrade != null and riverGrade != ''">
        and b.River_Grade = #{riverGrade,jdbcType=INTEGER}
      </if>
      <if test="startTime != null">
        and r.Create_Time between #{startTime} and #{endTime}
      </if>
      <if test="pageNo != null" >
        order by r.Serial limit #{pageNo},#{pageSize}
      </if>
  </select>

  <delete id="deletePatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig" >
    delete from patrol_days_config
      where Serial = #{serial,jdbcType=INTEGER}
  </delete>

  <insert id="addPatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig" >
    insert into patrol_days_config
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="riverNo != null" >
        River_No,
      </if>
      <if test="chiefUserNo != null" >
        Chief_User_No,
      </if>
      <if test="patrolDays != null" >
        Patrol_Days,
      </if>
      <if test="createUserNo != null" >
        Create_User_No,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="riverNo != null" >
        #{riverNo,jdbcType=VARCHAR},
      </if>
      <if test="chiefUserNo != null" >
        #{chiefUserNo,jdbcType=VARCHAR},
      </if>
      <if test="patrolDays != null" >
        #{patrolDays,jdbcType=INTEGER},
      </if>
      <if test="createUserNo != null" >
        #{createUserNo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <select id="countPatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig" resultType="java.lang.Integer" >
    select count(DISTINCT r.Serial)
      from patrol_days_config r
      inner join huludao_main.sys_user_info i
      on i.User_No = r.Chief_User_No
      inner join huludao_main.sys_user_info o
      on o.User_No = r.Create_User_No
      left join huludao_main.sys_user_info k
      on k.User_No = r.Update_User_No
      inner join river_info_basis b
      on b.River_No= r.River_No
      where 1=1
      <if test="list != null and list.size > 0">
        and r.Chief_User_No in
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
          #{item}
        </foreach>
      </if>
      <if test="list == null">
        and r.Chief_User_No = 'ewrwe123132'
      </if>
      <if test="riverName != null and riverName != ''">
        and b.River_Name like '%${riverName}%'
      </if>
      <if test="riverGrade != null and riverGrade != ''">
        and b.River_Grade = #{riverGrade,jdbcType=INTEGER}
      </if>
      <if test="startTime != null">
        and r.Create_Time between #{startTime} and #{endTime}
      </if>
  </select>

  <update id="updatePatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig" >
    update patrol_days_config
    <set >
      <if test="patrolDays != null" >
        Patrol_Days = #{patrolDays,jdbcType=INTEGER},
      </if>
      <if test="updateUserNo != null" >
        Update_User_No = #{updateUserNo,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null" >
        Update_Time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where Serial = #{serial,jdbcType=INTEGER}
  </update>

  <select id="selectPatrolDaysConfigByRiverNo" resultType="com.newfiber.api.pc.model.River.PatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig">
    select r.Serial serial,r.River_No riverNo,r.Chief_User_No chiefUserNo,r.Patrol_Days patrolDays,
      r.Create_User_No createUserNo,r.Update_User_No updateUserNo,
    DATE_FORMAT(r.Create_Time,'%Y-%m-%d %T') Create_Time,DATE_FORMAT(r.Update_Time,'%Y-%m-%d %T') updateDateTime
      from patrol_days_config r
      where 1=1
      <if test="riverNo != null and riverNo != ''">
        and r.River_No = #{riverNo,jdbcType=VARCHAR}
      </if>
      <if test="chiefUserNo != null and chiefUserNo != ''">
        and r.Chief_User_No = #{chiefUserNo,jdbcType=VARCHAR}
      </if>
  </select>

  <select id="selectPatrolDaysByListUserNo" resultType="com.newfiber.api.pc.model.River.PatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig">
    select r.Patrol_Days patrolDays
      from patrol_days_config r
      inner join river_info_basis b
      on b.River_No = r.River_No
      inner join river_chief rc on rc.Chief_User_No = r.Chief_User_No
      where 1=1
      <if test="list != null and list.size > 0">
        and r.Chief_User_No in
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
          #{item}
        </foreach>
      </if>
      <if test="riverGrade != null">
        and rc.Chief_Grade = #{riverGrade,jdbcType=INTEGER}
      </if>
  </select>

  <select id="selectPatrolDaysByUser" resultType="com.newfiber.api.pc.model.River.PatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig">
    select r.Patrol_Days patrolDays
    from patrol_days_config r
    inner join river_info_basis b
    on b.River_No = r.River_No
    where 1=1
    <if test="userNo != null">
      and r.Chief_User_No = #{userNo}
    </if>
    <if test="riverGrade != null">
      and b.River_Grade = #{riverGrade,jdbcType=INTEGER}
    </if>
  </select>

  <select id="selectPatrolDaysByUserNo" resultType="com.newfiber.api.pc.model.River.PatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig">
    select r.Patrol_Days patrolDays
    from patrol_days_config r
    where 1=1
    <if test="riverNo != null and riverNo != ''">
      and r.River_No = #{riverNo,jdbcType=INTEGER}
    </if>
  </select>

  <select id="selectByCode" resultType="com.newfiber.api.pc.model.River.PatrolDaysConfig" parameterType="com.newfiber.api.pc.model.River.PatrolDaysConfig">
    select <include refid="Base_Column_List" />
    from patrol_days_config
    where 1=1
    <if test="code != null and code != ''">
      and Chief_User_No = #{code,jdbcType=INTEGER}
    </if>
  </select>
</mapper>