chengf
2026-01-16 d5b6bebe835f1597f227409feced749dbe811fc1
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
package com.java110.fee.api;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 讼诉情况接口
 * 适配 litigation_info 表
 * @author dev
 * @date 2025-12-24
 */
@RestController
@RequestMapping(value = "/litigationInfo")
public class LitigationInfoApi {
 
    @Autowired
    protected SqlSessionTemplate sqlSessionTemplate;
 
    /**
     * 保存讼诉情况信息
     *
     * @param reqJson 请求参数
     * @return 响应结果
     * @serviceCode /litigationInfo/saveLitigationInfo
     * @path /app/litigationInfo/saveLitigationInfo
     */
    @RequestMapping(value = "/saveLitigationInfo", method = RequestMethod.POST)
    public ResponseEntity<String> saveLitigationInfo(@RequestBody JSONObject reqJson) {
        // 必传参数校验
        Assert.hasKeyAndValue(reqJson, "litigation_date", "请求报文中未包含送诉日期litigation_date");
        Assert.hasKeyAndValue(reqJson, "arrears_period", "请求报文中未包含欠费区间arrears_period");
        Assert.hasKeyAndValue(reqJson, "arrears_amount", "请求报文中未包含欠费金额arrears_amount");
        Assert.hasKeyAndValue(reqJson, "submitter", "请求报文中未包含送件人员submitter");
 
        // 转换为POJO
        LitigationInfoPo po = BeanConvertUtil.covertBean(reqJson, LitigationInfoPo.class);
 
        // 调用Mapper保存方法
        int insert = sqlSessionTemplate.insert("litigationInfoServiceDaoImpl.saveLitigationInfo",
                BeanConvertUtil.beanCovertMap(po));
 
        // 构造响应结果
        JSONObject resJson = new JSONObject();
        if (insert > 0) {
            resJson.put("code", "0000");
            resJson.put("msg", "保存讼诉情况信息成功");
        } else {
            resJson.put("code", "0001");
            resJson.put("msg", "保存讼诉情况信息失败");
        }
        resJson.put("count", insert);
        return ResponseEntity.ok(resJson.toJSONString());
    }
 
    public ResponseEntity<String> saveLitigationInfo(LitigationInfoPo po) {
        // 调用Mapper保存方法
        int insert = sqlSessionTemplate.insert("litigationInfoServiceDaoImpl.saveLitigationInfo",
                BeanConvertUtil.beanCovertMap(po));
 
        // 构造响应结果
        JSONObject resJson = new JSONObject();
        if (insert > 0) {
            resJson.put("code", "0000");
            resJson.put("msg", "保存讼诉情况信息成功");
        } else {
            resJson.put("code", "0001");
            resJson.put("msg", "保存讼诉情况信息失败");
        }
        resJson.put("count", insert);
        return ResponseEntity.ok(resJson.toJSONString());
    }
 
    /**
     * 批量保存讼诉情况信息
     *
     * @param reqJson 请求参数(包含litigationInfoList数组)
     * @return 响应结果
     * @serviceCode /litigationInfo/saveLitigationInfos
     * @path /app/litigationInfo/saveLitigationInfos
     */
    @RequestMapping(value = "/saveLitigationInfos", method = RequestMethod.POST)
    public ResponseEntity<String> saveLitigationInfos(@RequestBody JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "litigationInfoList", "请求报文中未包含批量数据列表");
 
        // 转换批量数据
        List<LitigationInfoPo> poList = BeanConvertUtil.covertBeanList(
                reqJson.getJSONArray("litigationInfoList"), LitigationInfoPo.class);
 
        Map<String, Object> param = BeanConvertUtil.beanCovertMap(reqJson);
        param.put("litigationInfoList", poList);
 
        // 批量插入
        int insert = sqlSessionTemplate.insert("litigationInfoServiceDaoImpl.batchSaveLitigationInfo", param);
 
        JSONObject resJson = new JSONObject();
        resJson.put("code", "0000");
        resJson.put("msg", "批量保存讼诉情况信息成功");
        resJson.put("count", insert);
        return ResponseEntity.ok(resJson.toJSONString());
    }
 
    /**
     * 修改讼诉情况信息
     *
     * @param reqJson 请求参数
     * @return 响应结果
     * @serviceCode /litigationInfo/updateLitigationInfo
     * @path /app/litigationInfo/updateLitigationInfo
     */
    @RequestMapping(value = "/updateLitigationInfo", method = RequestMethod.POST)
    public ResponseEntity<String> updateLitigationInfo(@RequestBody JSONObject reqJson) {
        // 主键校验
        Assert.hasKeyAndValue(reqJson, "id", "请求报文中未包含主键ID");
        // 必传业务参数校验
        Assert.hasKeyAndValue(reqJson, "litigation_date", "请求报文中未包含送诉日期litigation_date");
        Assert.hasKeyAndValue(reqJson, "arrears_period", "请求报文中未包含欠费区间arrears_period");
        Assert.hasKeyAndValue(reqJson, "arrears_amount", "请求报文中未包含欠费金额arrears_amount");
        Assert.hasKeyAndValue(reqJson, "submitter", "请求报文中未包含送件人员submitter");
 
        LitigationInfoPo po = BeanConvertUtil.covertBean(reqJson, LitigationInfoPo.class);
 
        // 调用Mapper修改方法
        int update = sqlSessionTemplate.update("litigationInfoServiceDaoImpl.updateLitigationInfo",
                BeanConvertUtil.beanCovertMap(po));
 
        JSONObject resJson = new JSONObject();
        if (update > 0) {
            resJson.put("code", "0000");
            resJson.put("msg", "修改讼诉情况信息成功");
        } else {
            resJson.put("code", "0001");
            resJson.put("msg", "修改讼诉情况信息失败,未找到对应记录");
        }
        resJson.put("count", update);
        return ResponseEntity.ok(resJson.toJSONString());
    }
 
    /**
     * 删除讼诉情况信息
     *
     * @param reqJson 请求参数
     * @return 响应结果
     * @serviceCode /litigationInfo/deleteLitigationInfo
     * @path /app/litigationInfo/deleteLitigationInfo
     */
    @RequestMapping(value = "/deleteLitigationInfo", method = RequestMethod.POST)
    public ResponseEntity<String> deleteLitigationInfo(@RequestBody JSONObject reqJson) {
        // 必要参数校验
        Assert.hasKeyAndValue(reqJson, "id", "主键ID不能为空");
 
        LitigationInfoPo po = BeanConvertUtil.covertBean(reqJson, LitigationInfoPo.class);
 
        // 调用Mapper删除方法
        int delete = sqlSessionTemplate.delete("litigationInfoServiceDaoImpl.deleteLitigationInfo",
                BeanConvertUtil.beanCovertMap(po));
 
        JSONObject resJson = new JSONObject();
        if (delete > 0) {
            resJson.put("code", "0000");
            resJson.put("msg", "删除讼诉情况信息成功");
        } else {
            resJson.put("code", "0001");
            resJson.put("msg", "删除讼诉情况信息失败,未找到对应记录");
        }
        resJson.put("count", delete);
        return ResponseEntity.ok(resJson.toJSONString());
    }
 
    /**
     * 分页查询讼诉情况信息列表
     *
     * @param litigation_date     送诉日期(可选)
     * @param submitter           送件人员(可选)
     * @param page                页码(默认1)
     * @param row                 每页条数(默认10)
     * @param id                  主键ID(可选)
     * @return 响应结果
     * @serviceCode /litigationInfo/queryLitigationInfo
     * @path /app/litigationInfo/queryLitigationInfo
     */
    @RequestMapping(value = "/queryLitigationInfo", method = RequestMethod.GET)
    public ResponseEntity<String> queryLitigationInfo(
            @RequestParam(value = "litigation_date", required = false) String litigation_date,
            @RequestParam(value = "submitter", required = false) String submitter,
            @RequestParam(value = "page", defaultValue = "1") int page,
            @RequestParam(value = "row", defaultValue = "10") int row,
            @RequestParam(value = "id", required = false) String id) {
 
        // 封装查询参数
        LitigationInfoPo queryPo = new LitigationInfoPo();
        queryPo.setLitigation_date(litigation_date);
        queryPo.setSubmitter(submitter);
        queryPo.setPage((page - 1) * row); // 转换为MySQL分页偏移量
        queryPo.setRow(row);
 
        if (id != null && !id.isEmpty()) {
            queryPo.setId(Integer.parseInt(id));
        }
 
        // 查询列表数据
        List<Map<String, Object>> list = sqlSessionTemplate.selectList(
                "litigationInfoServiceDaoImpl.getLitigationInfo",
                BeanConvertUtil.beanCovertMap(queryPo));
 
        // 查询总数
        Object total = ((HashMap) sqlSessionTemplate.selectOne(
                "litigationInfoServiceDaoImpl.queryLitigationInfoCount",
                BeanConvertUtil.beanCovertMap(queryPo))).get("count");
 
        // 构造分页响应
        JSONObject resJson = new JSONObject();
        resJson.put("code", "0000");
        resJson.put("msg", "查询讼诉情况信息成功");
        resJson.put("page", page);
        resJson.put("row", row);
        resJson.put("total", total);
        resJson.put("data", list);
 
        return ResponseEntity.ok(resJson.toJSONString());
    }
 
    /**
     * 根据ID查询单条讼诉情况信息
     *
     * @param id 主键ID
     * @return 响应结果
     * @serviceCode /litigationInfo/getLitigationInfoById
     * @path /app/litigationInfo/getLitigationInfoById
     */
    @RequestMapping(value = "/getLitigationInfoById", method = RequestMethod.GET)
    public ResponseEntity<String> getLitigationInfoById(@RequestParam(value = "id") Integer id) {
        // 主键校验
        Assert.notNull(id, "主键ID不能为空");
 
        LitigationInfoPo queryPo = new LitigationInfoPo();
        queryPo.setId(id);
 
        // 查询单条数据
        Map<String, Object> result = sqlSessionTemplate.selectOne(
                "litigationInfoServiceDaoImpl.getLitigationInfo",
                BeanConvertUtil.beanCovertMap(queryPo));
 
        JSONObject resJson = new JSONObject();
        if (result != null) {
            resJson.put("code", "0000");
            resJson.put("msg", "查询讼诉情况信息成功");
            resJson.put("data", result);
        } else {
            resJson.put("code", "0001");
            resJson.put("msg", "未找到对应讼诉情况记录");
        }
 
        return ResponseEntity.ok(resJson.toJSONString());
    }
 
    /**
     * 统计讼诉情况信息
     *
     * @param litigation_date     送诉日期(可选)
     * @param submitter           送件人员(可选)
     * @param startCreateTime     开始创建时间(可选,格式:yyyy-MM-dd HH:mm:ss)
     * @param endCreateTime       结束创建时间(可选)
     * @return 响应结果
     * @serviceCode /litigationInfo/queryLitigationInfoStatistics
     * @path /app/litigationInfo/queryLitigationInfoStatistics
     */
    @RequestMapping(value = "/queryLitigationInfoStatistics", method = RequestMethod.GET)
    public ResponseEntity<String> queryLitigationInfoStatistics(
            @RequestParam(value = "litigation_date", required = false) String litigation_date,
            @RequestParam(value = "submitter", required = false) String submitter,
            @RequestParam(value = "startCreateTime", required = false) String startCreateTime,
            @RequestParam(value = "endCreateTime", required = false) String endCreateTime) {
 
        LitigationInfoPo queryPo = new LitigationInfoPo();
        queryPo.setLitigation_date(litigation_date);
        queryPo.setSubmitter(submitter);
        queryPo.setStartCreateTime(startCreateTime);
        queryPo.setEndCreateTime(endCreateTime);
 
        // 统计查询
        Map<String, Object> statistics = sqlSessionTemplate.selectOne(
                "litigationInfoServiceDaoImpl.queryLitigationInfoStatistics",
                BeanConvertUtil.beanCovertMap(queryPo));
 
        JSONObject resJson = new JSONObject();
        resJson.put("code", "0000");
        resJson.put("msg", "统计讼诉情况信息成功");
        resJson.put("data", statistics);
 
        return ResponseEntity.ok(resJson.toJSONString());
    }
 
    /**
     * 配套POJO类(内部类形式,也可抽离为独立类)
     */
    public static class LitigationInfoPo {
        private Integer id;
        private String litigation_date;
        private String arrears_period;
        private Double arrears_amount;
        private Double late_fee;
        private Double acceptance_fee;
        private Double other_fee;
        private Double total_amount; // 数据库自动计算,无需手动赋值
        private String submitter;
        private String create_time;
        private String update_time;
        // 分页参数
        private int page;
        private int row;
        // 统计时间范围参数
        private String startCreateTime;
        private String endCreateTime;
 
        // Getter & Setter
        public Integer getId() {
            return id;
        }
 
        public void setId(Integer id) {
            this.id = id;
        }
 
        public String getLitigation_date() {
            return litigation_date;
        }
 
        public void setLitigation_date(String litigation_date) {
            this.litigation_date = litigation_date;
        }
 
        public String getArrears_period() {
            return arrears_period;
        }
 
        public void setArrears_period(String arrears_period) {
            this.arrears_period = arrears_period;
        }
 
        public Double getArrears_amount() {
            return arrears_amount;
        }
 
        public void setArrears_amount(Double arrears_amount) {
            this.arrears_amount = arrears_amount;
        }
 
        public Double getLate_fee() {
            return late_fee;
        }
 
        public void setLate_fee(Double late_fee) {
            this.late_fee = late_fee;
        }
 
        public Double getAcceptance_fee() {
            return acceptance_fee;
        }
 
        public void setAcceptance_fee(Double acceptance_fee) {
            this.acceptance_fee = acceptance_fee;
        }
 
        public Double getOther_fee() {
            return other_fee;
        }
 
        public void setOther_fee(Double other_fee) {
            this.other_fee = other_fee;
        }
 
        public Double getTotal_amount() {
            return total_amount;
        }
 
        public void setTotal_amount(Double total_amount) {
            this.total_amount = total_amount;
        }
 
        public String getSubmitter() {
            return submitter;
        }
 
        public void setSubmitter(String submitter) {
            this.submitter = submitter;
        }
 
        public String getCreate_time() {
            return create_time;
        }
 
        public void setCreate_time(String create_time) {
            this.create_time = create_time;
        }
 
        public String getUpdate_time() {
            return update_time;
        }
 
        public void setUpdate_time(String update_time) {
            this.update_time = update_time;
        }
 
        public int getPage() {
            return page;
        }
 
        public void setPage(int page) {
            this.page = page;
        }
 
        public int getRow() {
            return row;
        }
 
        public void setRow(int row) {
            this.row = row;
        }
 
        public String getStartCreateTime() {
            return startCreateTime;
        }
 
        public void setStartCreateTime(String startCreateTime) {
            this.startCreateTime = startCreateTime;
        }
 
        public String getEndCreateTime() {
            return endCreateTime;
        }
 
        public void setEndCreateTime(String endCreateTime) {
            this.endCreateTime = endCreateTime;
        }
    }
}