<?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.dy.pipIrrGlobal.daoSe.SeIssueReportMapper"> 
 | 
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeIssueReport"> 
 | 
    <!--@mbg.generated--> 
 | 
    <!--@Table se_issue_report--> 
 | 
    <id column="id" jdbcType="BIGINT" property="id" /> 
 | 
    <result column="content" jdbcType="VARCHAR" property="content" /> 
 | 
    <result column="images" jdbcType="JAVA_OBJECT" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" property="images" /> 
 | 
    <result column="audios" jdbcType="JAVA_OBJECT" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" property="audios" /> 
 | 
    <result column="videos" jdbcType="JAVA_OBJECT" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" property="videos" /> 
 | 
    <result column="lng" jdbcType="DECIMAL" property="lng" /> 
 | 
    <result column="lat" jdbcType="DECIMAL" property="lat" /> 
 | 
    <result column="client_id" jdbcType="BIGINT" property="clientId" /> 
 | 
    <result column="report_time" jdbcType="TIMESTAMP" property="reportTime" /> 
 | 
    <result column="phone" jdbcType="VARCHAR" property="phone" /> 
 | 
    <result column="state" jdbcType="TINYINT" property="state" /> 
 | 
  </resultMap> 
 | 
  <sql id="Base_Column_List"> 
 | 
    <!--@mbg.generated--> 
 | 
    id, content, images, audios, videos, lng, lat, client_id, report_time, phone, `state` 
 | 
  </sql> 
 | 
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> 
 | 
    <!--@mbg.generated--> 
 | 
    select  
 | 
    <include refid="Base_Column_List" /> 
 | 
    from se_issue_report 
 | 
    where id = #{id,jdbcType=BIGINT} 
 | 
  </select> 
 | 
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> 
 | 
    <!--@mbg.generated--> 
 | 
    delete from se_issue_report 
 | 
    where id = #{id,jdbcType=BIGINT} 
 | 
  </delete> 
 | 
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeIssueReport"> 
 | 
    <!--@mbg.generated--> 
 | 
    insert into se_issue_report (id, content, images,  
 | 
      audios, videos, lng,  
 | 
      lat, client_id, report_time,  
 | 
      phone, `state`) 
 | 
    values (#{id,jdbcType=BIGINT}, #{content,jdbcType=VARCHAR}, #{images,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      #{audios,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, #{videos,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, #{lng,jdbcType=DECIMAL}, 
 | 
      #{lat,jdbcType=DECIMAL}, #{clientId,jdbcType=BIGINT}, #{reportTime,jdbcType=TIMESTAMP},  
 | 
      #{phone,jdbcType=VARCHAR}, #{state,jdbcType=TINYINT}) 
 | 
  </insert> 
 | 
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeIssueReport"> 
 | 
    <!--@mbg.generated--> 
 | 
    insert into se_issue_report 
 | 
    <trim prefix="(" suffix=")" suffixOverrides=","> 
 | 
      <if test="id != null"> 
 | 
        id, 
 | 
      </if> 
 | 
      <if test="content != null"> 
 | 
        content, 
 | 
      </if> 
 | 
      <if test="images != null"> 
 | 
        images, 
 | 
      </if> 
 | 
      <if test="audios != null"> 
 | 
        audios, 
 | 
      </if> 
 | 
      <if test="videos != null"> 
 | 
        videos, 
 | 
      </if> 
 | 
      <if test="lng != null"> 
 | 
        lng, 
 | 
      </if> 
 | 
      <if test="lat != null"> 
 | 
        lat, 
 | 
      </if> 
 | 
      <if test="clientId != null"> 
 | 
        client_id, 
 | 
      </if> 
 | 
      <if test="reportTime != null"> 
 | 
        report_time, 
 | 
      </if> 
 | 
      <if test="phone != null"> 
 | 
        phone, 
 | 
      </if> 
 | 
      <if test="state != null"> 
 | 
        `state`, 
 | 
      </if> 
 | 
    </trim> 
 | 
    <trim prefix="values (" suffix=")" suffixOverrides=","> 
 | 
      <if test="id != null"> 
 | 
        #{id,jdbcType=BIGINT}, 
 | 
      </if> 
 | 
      <if test="content != null"> 
 | 
        #{content,jdbcType=VARCHAR}, 
 | 
      </if> 
 | 
      <if test="images != null"> 
 | 
        #{images,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      </if> 
 | 
      <if test="audios != null"> 
 | 
        #{audios,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      </if> 
 | 
      <if test="videos != null"> 
 | 
        #{videos,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      </if> 
 | 
      <if test="lng != null"> 
 | 
        #{lng,jdbcType=DECIMAL}, 
 | 
      </if> 
 | 
      <if test="lat != null"> 
 | 
        #{lat,jdbcType=DECIMAL}, 
 | 
      </if> 
 | 
      <if test="clientId != null"> 
 | 
        #{clientId,jdbcType=BIGINT}, 
 | 
      </if> 
 | 
      <if test="reportTime != null"> 
 | 
        #{reportTime,jdbcType=TIMESTAMP}, 
 | 
      </if> 
 | 
      <if test="phone != null"> 
 | 
        #{phone,jdbcType=VARCHAR}, 
 | 
      </if> 
 | 
      <if test="state != null"> 
 | 
        #{state,jdbcType=TINYINT}, 
 | 
      </if> 
 | 
    </trim> 
 | 
  </insert> 
 | 
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeIssueReport"> 
 | 
    <!--@mbg.generated--> 
 | 
    update se_issue_report 
 | 
    <set> 
 | 
      <if test="content != null"> 
 | 
        content = #{content,jdbcType=VARCHAR}, 
 | 
      </if> 
 | 
      <if test="images != null"> 
 | 
        images = #{images,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      </if> 
 | 
      <if test="audios != null"> 
 | 
        audios = #{audios,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      </if> 
 | 
      <if test="videos != null"> 
 | 
        videos = #{videos,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      </if> 
 | 
      <if test="lng != null"> 
 | 
        lng = #{lng,jdbcType=DECIMAL}, 
 | 
      </if> 
 | 
      <if test="lat != null"> 
 | 
        lat = #{lat,jdbcType=DECIMAL}, 
 | 
      </if> 
 | 
      <if test="clientId != null"> 
 | 
        client_id = #{clientId,jdbcType=BIGINT}, 
 | 
      </if> 
 | 
      <if test="reportTime != null"> 
 | 
        report_time = #{reportTime,jdbcType=TIMESTAMP}, 
 | 
      </if> 
 | 
      <if test="phone != null"> 
 | 
        phone = #{phone,jdbcType=VARCHAR}, 
 | 
      </if> 
 | 
      <if test="state != null"> 
 | 
        `state` = #{state,jdbcType=TINYINT}, 
 | 
      </if> 
 | 
    </set> 
 | 
    where id = #{id,jdbcType=BIGINT} 
 | 
  </update> 
 | 
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeIssueReport"> 
 | 
    <!--@mbg.generated--> 
 | 
    update se_issue_report 
 | 
    set content = #{content,jdbcType=VARCHAR}, 
 | 
      images = #{images,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      audios = #{audios,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      videos = #{videos,jdbcType=JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, 
 | 
      lng = #{lng,jdbcType=DECIMAL}, 
 | 
      lat = #{lat,jdbcType=DECIMAL}, 
 | 
      client_id = #{clientId,jdbcType=BIGINT}, 
 | 
      report_time = #{reportTime,jdbcType=TIMESTAMP}, 
 | 
      phone = #{phone,jdbcType=VARCHAR}, 
 | 
      `state` = #{state,jdbcType=TINYINT} 
 | 
    where id = #{id,jdbcType=BIGINT} 
 | 
  </update> 
 | 
  
 | 
  <!--根据指定条件获取农户问题上报数量--> 
 | 
  <select id="getIssueReportsCount" resultType="java.lang.Long"> 
 | 
    SELECT COUNT(*) AS recordCount 
 | 
    FROM se_issue_report rpt 
 | 
        LEFT JOIN se_client cli ON cli.id = rpt.client_id 
 | 
        LEFT JOIN se_report_reply rpy ON rpy.report_id = rpt.id 
 | 
    <where> 
 | 
      AND rpt.state != 3 
 | 
  
 | 
      <if test="clientId != null"> 
 | 
        AND rpt.client_id = #{clientId} 
 | 
      </if> 
 | 
  
 | 
      <if test="clientName != null and clientName != ''"> 
 | 
        AND cli.name like CONCAT('%', #{clientName}, '%') 
 | 
      </if> 
 | 
  
 | 
      <if test="content != null and content != ''"> 
 | 
        AND rpt.content like CONCAT('%', #{content}, '%') 
 | 
      </if> 
 | 
  
 | 
      <if test="timeStart != null and timeStop != null "> 
 | 
        AND rpt.report_time BETWEEN #{timeStart} AND #{timeStop} 
 | 
      </if> 
 | 
  
 | 
      <if test="state != null"> 
 | 
        AND rpt.state = #{state} 
 | 
      </if> 
 | 
    </where> 
 | 
  </select> 
 | 
  
 | 
  <!--根据指定条件获取农户问题上报--> 
 | 
  <select id="getIssueReports" resultType="com.dy.pipIrrGlobal.voSe.VoIssueReport_temp" > 
 | 
    SELECT 
 | 
        rpt.id AS issueReportId, 
 | 
        cli.name AS clientName, 
 | 
        rpt.phone, 
 | 
        rpt.report_time AS reportTime, 
 | 
        rpt.content, 
 | 
        rpt.images, 
 | 
        rpt.audios, 
 | 
        rpt.videos, 
 | 
        rpy.reply_time AS replyTime, 
 | 
        rpt.state AS stateId, 
 | 
        CASE 
 | 
            WHEN rpt.state = 1 THEN '未受理' 
 | 
            WHEN rpt.state = 2 THEN '已受理' 
 | 
        END AS state 
 | 
    FROM se_issue_report rpt 
 | 
        LEFT JOIN se_client cli ON cli.id = rpt.client_id 
 | 
        LEFT JOIN se_report_reply rpy ON rpy.report_id = rpt.id 
 | 
    <where> 
 | 
      AND rpt.state != 3 
 | 
  
 | 
      <if test="clientId != null"> 
 | 
        AND rpt.client_id = #{clientId} 
 | 
      </if> 
 | 
  
 | 
      <if test="clientName != null and clientName != ''"> 
 | 
        AND cli.name like CONCAT('%', #{clientName}, '%') 
 | 
      </if> 
 | 
  
 | 
      <if test="content != null and content != ''"> 
 | 
        AND rpt.content like CONCAT('%', #{content}, '%') 
 | 
      </if> 
 | 
  
 | 
      <if test="timeStart != null and timeStop != null "> 
 | 
        AND rpt.report_time BETWEEN #{timeStart} AND #{timeStop} 
 | 
      </if> 
 | 
  
 | 
      <if test="state != null"> 
 | 
        AND rpt.state = #{state} 
 | 
      </if> 
 | 
    </where> 
 | 
    ORDER BY rpt.report_time DESC 
 | 
    <trim prefix="limit "> 
 | 
      <if test="start != null and count != null"> 
 | 
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} 
 | 
      </if> 
 | 
    </trim> 
 | 
  </select> 
 | 
  
 | 
  <!--根据上报ID及农户ID获取未删除的上报,删除上报判断使用--> 
 | 
  <select id="getReport" resultType="com.dy.pipIrrGlobal.pojoSe.SeIssueReport"> 
 | 
    SELECT * FROM se_issue_report WHERE state != 3 AND id = #{issueReportId} AND client_id = #{clientId} 
 | 
  </select> 
 | 
  
 | 
  <!--逻辑删除一个农户问题上报--> 
 | 
  <update id="deleteIssueReport"> 
 | 
    UPDATE se_issue_report SET state = 3 WHERE id = #{issueReportId} 
 | 
  </update> 
 | 
</mapper> 
 |