zhubaomin
2025-04-11 9f3c4a33279f10ed420d604765487558ab0744f0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?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.daoOp.OpeIssueReportMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoOp.OpeIssueReport">
    <!--@mbg.generated-->
    <!--@Table ope_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="inspector_id" jdbcType="BIGINT" property="inspectorId" />
    <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, inspector_id, report_time, phone, 
    `state`
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from ope_issue_report
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ope_issue_report
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoOp.OpeIssueReport">
    <!--@mbg.generated-->
    insert into ope_issue_report (id, content, images, 
      audios, videos, lng, 
      lat, inspector_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}, #{inspectorId,jdbcType=BIGINT}, #{reportTime,jdbcType=TIMESTAMP}, 
      #{phone,jdbcType=VARCHAR}, #{state,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoOp.OpeIssueReport">
    <!--@mbg.generated-->
    insert into ope_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="inspectorId != null">
        inspector_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="inspectorId != null">
        #{inspectorId,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.pojoOp.OpeIssueReport">
    <!--@mbg.generated-->
    update ope_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="inspectorId != null">
        inspector_id = #{inspectorId,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.pojoOp.OpeIssueReport">
    <!--@mbg.generated-->
    update ope_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},
      inspector_id = #{inspectorId,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 ope_issue_report rpt
        LEFT JOIN ba_user us ON us.id = rpt.inspector_id
        LEFT JOIN ope_report_reply rpy ON rpy.report_id = rpt.id
    <where>
      AND rpt.state != 3
 
      <if test="inspectorId != null">
        AND rpt.inspector_id = #{inspectorId}
      </if>
 
      <if test="inspectorName != null and inspectorName != ''">
        AND us.name like CONCAT('%', #{inspectorName}, '%')
      </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.voOp.VoIssueReport_temp">
    SELECT
        rpt.id AS issueReportId,
        us.name AS inspectorName,
        rpt.phone,
        rpt.report_time AS reportTime,
        rpt.content,
        rpt.images,
        rpt.audios,
        rpt.videos,
        rpy.reply_time AS replyTime,
        rpy.reply_content AS replyContent,
        rpy.replier_id AS replyPersonId,
        rpt.state AS stateId,
        CASE
            WHEN rpt.state = 1 THEN '未受理'
            WHEN rpt.state = 2 THEN '已受理'
        END AS state
    FROM ope_issue_report rpt
        LEFT JOIN ba_user us ON us.id = rpt.inspector_id
        LEFT JOIN ope_report_reply rpy ON rpy.report_id = rpt.id
    <where>
      AND rpt.state != 3
 
      <if test="inspectorId != null">
        AND rpt.inspector_id = #{inspectorId}
      </if>
 
      <if test="inspectorName != null and inspectorName != ''">
        AND us.name like CONCAT('%', #{inspectorName}, '%')
      </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.pojoOp.OpeIssueReport">
    SELECT * FROM ope_issue_report WHERE state != 3 AND id = #{issueReportId} AND inspector_id = #{inspectorId}
  </select>
 
  <!--逻辑删除一个农户问题上报-->
  <update id="deleteIssueReport">
    UPDATE ope_issue_report SET state = 3 WHERE id = #{issueReportId}
  </update>
  <!--根据问题上报记录主键获取获取巡检员问题上报记录视图对象-->
  <select id="getIssueReportById" resultType="com.dy.pipIrrGlobal.voOp.VoIssueReport_temp">
    SELECT
      rpt.id AS issueReportId,
      us.name AS inspectorName,
      rpt.phone,
      rpt.report_time AS reportTime,
      rpt.content,
      rpt.images,
      rpt.audios,
      rpt.videos,
      rpy.reply_time AS replyTime,
      rpy.reply_content AS replyContent,
      rpy.replier_id AS replyPersonId,
      rpt.state AS stateId,
      CASE
        WHEN rpt.state = 1 THEN '未受理'
        WHEN rpt.state = 2 THEN '已受理'
        END AS state
    FROM ope_issue_report rpt
           LEFT JOIN ba_user us ON us.id = rpt.inspector_id
           LEFT JOIN ope_report_reply rpy ON rpy.report_id = rpt.id
    where rpt.state != 3 AND rpt.id = #{issueReportId}
  </select>
</mapper>