广州市综治平台后端
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
package cn.huge.module.casebook.controller.web;
 
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.base.config.CurrentUser;
import cn.huge.module.casebook.domain.dto.CaseBookPageDTO;
import cn.huge.module.casebook.domain.po.CasebookInfo;
import cn.huge.module.casebook.service.CasebookInfoService;
import cn.huge.module.client.api.impl.CustClientImpl;
import cn.huge.module.cust.dto.CtUserDTO;
import cn.huge.module.mediate.constant.CaseBaseConsts;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
/**
 * @title: dyh_casebook_info接口api-web端
 * @description: dyh_casebook_info接口api-web端
 * @company: hugeinfo
 * @author: liyj
 * @time: 2024-10-26 12:31:22
 * @version: 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/api/web/caseBook")
public class CaseBookWebController {
 
    @Autowired(required = false)
    private HttpServletRequest request;
 
    @Autowired
    private CasebookInfoService casebookInfoService;
    @Autowired
    private CustClientImpl custClient;
 
    /**
     * 案件导入-导入草稿
     * @url {ctx}/api/web/caseBook/pageImportDraft
     * @param page 页码
     * @param size 每页数量
     * @param sortType 排序方式(1:正序;2:倒序)
     * @return Object
     */
    @GetMapping("/pageImportDraft")
    public Object pageImportDraft(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size
            , @RequestParam(value = "sortType") int sortType, @CurrentUser String userId) {
        try {
            // 查询条件
            Map<String, Object> terms = Maps.newHashMap();
            // 导入时间区间
            String importStart = request.getParameter("importStart");
            String importEnd = request.getParameter("importEnd");
            if(StringUtils.isNotBlank(importStart) && StringUtils.isNotBlank(importEnd)) {
                terms.put("importStart", importStart);
                terms.put("importEnd", importEnd);
            }
            // 纠纷发生时间区间
            String occurStart = request.getParameter("occurStart");
            String occurEnd = request.getParameter("occurEnd");
            if(StringUtils.isNotBlank(occurStart) && StringUtils.isNotBlank(occurEnd)) {
                terms.put("occurStart", occurStart);
                terms.put("occurEnd", occurEnd);
            }
            // 申请方
            String plaintiffs = request.getParameter("plaintiffs");
            if (StringUtils.isNotBlank(plaintiffs)){
                terms.put("plaintiffs", plaintiffs);
            }
            // 被申请方
            String defendants = request.getParameter("defendants");
            if (StringUtils.isNotBlank(defendants)){
                terms.put("defendants", defendants);
            }
            // 调解员
            String mediator = request.getParameter("mediator");
            if (StringUtils.isNotBlank(mediator)){
                terms.put("mediator", mediator);
            }
            // 化解结果
            String mediResult = request.getParameter("mediResult");
            if (StringUtils.isNotBlank(mediResult)){
                terms.put("mediResult", mediResult);
            }
            // 纠纷类型
            String caseType = request.getParameter("caseType");
            if (StringUtils.isNotBlank(caseType)){
                terms.put("caseType", caseType);
            }
            // 协助调解员
            String assistMediator = request.getParameter("assistMediator");
            if (StringUtils.isNotBlank(assistMediator)){
                terms.put("assistMediator", assistMediator);
            }
            CtUserDTO loginUser = custClient.clientGetUserAll(userId);
            terms.put("inputUnitId", loginUser.getUnitId());
            // 排序
            Sort sort = null;
            if(sortType == 1) {
                sort = Sort.by(Sort.Direction.DESC, "t1.create_time");
            }
            if (sortType == 1){
                sort = Sort.by(Sort.Direction.ASC, "t1.create_time");
            }
            PageRequest pageRequest = PageRequest.of(page-1, size, sort);
            Page<CaseBookPageDTO> caseBookPageDTOPage = casebookInfoService.pageImportDraft(pageRequest, terms);
            return ReturnSucUtils.getRepInfo(caseBookPageDTOPage);
        } catch (Exception e) {
            log.error("[CaseBookWebController.pageImportDraft]请求失败,异常信息:"+e, e);
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
    * 案件导入-导入成功
    * @url {ctx}/api/web/caseBook/pageImportSuc
    * @param page 页码
    * @param size 每页数量
    * @param sortType 排序方式(1:正序;2:倒序)
    * @return Object
    */
    @GetMapping("/pageImportSuc")
    public Object pageImportSuc(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size
            , @RequestParam(value = "sortType") int sortType, @CurrentUser String userId) {
        try {
            // 查询条件
            Map<String, Object> terms = Maps.newHashMap();
            // 转入时间区间
            String importStart = request.getParameter("importStart");
            String importEnd = request.getParameter("importEnd");
            if(StringUtils.isNotBlank(importStart) && StringUtils.isNotBlank(importEnd)) {
                terms.put("importStart", importStart);
                terms.put("importEnd", importEnd);
            }
            // 纠纷发生时间区间
            String occurStart = request.getParameter("occurStart");
            String occurEnd = request.getParameter("occurEnd");
            if(StringUtils.isNotBlank(occurStart) && StringUtils.isNotBlank(occurEnd)) {
                terms.put("occurStart", occurStart);
                terms.put("occurEnd", occurEnd);
            }
            // 申请方
            String plaintiffs = request.getParameter("plaintiffs");
            if (StringUtils.isNotBlank(plaintiffs)){
                terms.put("plaintiffs", plaintiffs);
            }
            // 被申请方
            String defendants = request.getParameter("defendants");
            if (StringUtils.isNotBlank(defendants)){
                terms.put("defendants", defendants);
            }
            // 调解员
            String mediator = request.getParameter("mediator");
            if (StringUtils.isNotBlank(mediator)){
                terms.put("mediator", mediator);
            }
            // 化解结果
            String mediResult = request.getParameter("mediResult");
            if (StringUtils.isNotBlank(mediResult)){
                terms.put("mediResult", mediResult);
            }
            // 纠纷类型
            String caseType = request.getParameter("caseType");
            if (StringUtils.isNotBlank(caseType)){
                terms.put("caseType", caseType);
            }
            // 协助调解员
            String assistMediator = request.getParameter("assistMediator");
            if (StringUtils.isNotBlank(assistMediator)){
                terms.put("assistMediator", assistMediator);
            }
            CtUserDTO loginUser = custClient.clientGetUserAll(userId);
            terms.put("inputUnitId", loginUser.getUnitId());
            // 排序
            Sort sort = null;
            if(sortType == 1) {
                sort = Sort.by(Sort.Direction.DESC, "t1.create_time");
            }
            if (sortType == 1){
                sort = Sort.by(Sort.Direction.ASC, "t1.create_time");
            }
            PageRequest pageRequest = PageRequest.of(page-1, size, sort);
            Page<CaseBookPageDTO> caseBookPageDTOPage = casebookInfoService.pageImportSuc(pageRequest, terms);
            return ReturnSucUtils.getRepInfo(caseBookPageDTOPage);
        } catch (Exception e) {
            log.error("[CaseBookWebController.pageImportSuc]请求失败,异常信息:"+e, e);
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
    * 案件导入-导入操作
    * @url {ctx}/api/web/caseBook/inputCaseByExcel
    * @return Object
    */
    @GetMapping("/inputCaseByExcel")
    public Object inputCaseByExcel(@RequestParam(value = "fileId") String fileId, @CurrentUser String userId) {
        try {
            return casebookInfoService.inputCaseByExcel(fileId, userId, request);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
    * 案件导入-删除草稿
    * @url {ctx}/api/web/caseBook/deleteDraft
    * @return Object
    */
    @PostMapping("/deleteDraft")
    public Object deleteDraft(@RequestBody List<String> idList, @CurrentUser String userId) {
        try {
            casebookInfoService.deleteDraft(idList);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
    * 案件导入-草稿转入正式案件
    * @url {ctx}/api/web/caseBook/importToCase
    * @return Object
    */
    @PostMapping("/importToCase")
    public Object importToCase(@RequestBody List<String> idList, @CurrentUser String userId) {
        try {
            casebookInfoService.importToCase(idList, userId);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 案件导入-全部草稿转入正式案件
     * @url {ctx}/api/web/caseBook/importToCaseAll
     * @return Object
     */
    @GetMapping("/importToCaseAll")
    public Object importToCaseAll(@CurrentUser String userId) {
        try {
            // 查询条件
            Map<String, Object> terms = Maps.newHashMap();
            // 导入时间区间
            String importStart = request.getParameter("importStart");
            String importEnd = request.getParameter("importEnd");
            if(StringUtils.isNotBlank(importStart) && StringUtils.isNotBlank(importEnd)) {
                terms.put("importStart", importStart);
                terms.put("importEnd", importEnd);
            }
            // 纠纷发生时间区间
            String occurStart = request.getParameter("occurStart");
            String occurEnd = request.getParameter("occurEnd");
            if(StringUtils.isNotBlank(occurStart) && StringUtils.isNotBlank(occurEnd)) {
                terms.put("occurStart", occurStart);
                terms.put("occurEnd", occurEnd);
            }
            // 申请方
            String plaintiffs = request.getParameter("plaintiffs");
            if (StringUtils.isNotBlank(plaintiffs)){
                terms.put("plaintiffs", plaintiffs);
            }
            // 被申请方
            String defendants = request.getParameter("defendants");
            if (StringUtils.isNotBlank(defendants)){
                terms.put("defendants", defendants);
            }
            // 调解员
            String mediator = request.getParameter("mediator");
            if (StringUtils.isNotBlank(mediator)){
                terms.put("mediator", mediator);
            }
            // 化解结果
            String mediResult = request.getParameter("mediResult");
            if (StringUtils.isNotBlank(mediResult)){
                terms.put("mediResult", mediResult);
            }
            // 纠纷类型
            String caseType = request.getParameter("caseType");
            if (StringUtils.isNotBlank(caseType)){
                terms.put("caseType", caseType);
            }
            // 协助调解员
            String assistMediator = request.getParameter("assistMediator");
            if (StringUtils.isNotBlank(assistMediator)){
                terms.put("assistMediator", assistMediator);
            }
            CtUserDTO loginUser = custClient.clientGetUserAll(userId);
            terms.put("inputUnitId", loginUser.getUnitId());
            // 查询
            casebookInfoService.importToCaseAll(terms, userId);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            log.error("[CaseBookWebController.importToCaseAll]请求失败,异常信息:"+e, e);
            return ReturnFailUtils.getRepInfo();
        }
    }
 
}