广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
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
package cn.huge.module.cases.controller.wechat;
 
import cn.huge.base.common.utils.GuavaCacheUtils;
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.base.config.CurrentUser;
import cn.huge.module.cases.domain.dto.CaseInfoWeChatDTO;
import cn.huge.module.cases.domain.dto.RegisterSaveDTO;
import cn.huge.module.cases.service.CaseInfoService;
import cn.huge.module.client.api.impl.UtilsClientImpl;
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.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
 
/**
 * @title: 纠纷信息主表接口api-web端
 * @description: 纠纷信息主表接口api-web端
 * @company: hugeinfo
 * @author: wangwh
 * @time: 2024-08-27 10:00:57
 * @version: 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/api/wechat/caseInfo")
public class CaseInfoWechatController {
 
    @Autowired(required = false)
    private HttpServletRequest request;
 
    @Autowired
    private CaseInfoService service;
    @Autowired
    private UtilsClientImpl utilsClient;
 
    /**
    * 获取请求URL参数
    * @return Map<String, Object>
    */
    private Map<String, Object> getParameter(){
        Map<String, Object> terms = Maps.newHashMap();
        // 人员类型,1:我是申请方,2:我是被申请方
        String personType = request.getParameter("personType");
        if (StringUtils.isNotBlank(personType)){
            terms.put("personType", personType);
        }
 
        // 事项进度,1:来访登记,2:事件流转,3:办理反馈,4:结案申请,5:当事人评价,6:结案归档
        String process = request.getParameter("process");
        if (StringUtils.isNotBlank(process)){
            terms.put("process", process);
        }
        // 办理进度,1:待受理,2:化解中,3:已结案,4:不予受理
        String processStatus = request.getParameter("processStatus");
        if (StringUtils.isNotBlank(processStatus)){
            terms.put("infoProcess", processStatus);
        }
 
        return terms;
    }
 
    /**
    * 条件分页查询
    * @url {ctx}/api/wechat/caseInfo/pageCard
    * @param page 页码
    * @param size 每页数量
    * @return Object
     * @CurrentUser String userId,
    */
    @GetMapping("/pageCard")
    public Object pageCard( @CurrentUser String userId,@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
        try {
            Map<String, Object> terms = getParameter();
            Sort sort = Sort.by(Sort.Direction.DESC, "create_time");
            PageRequest pageRequest = PageRequest.of(page-1, size, sort);
            Page<CaseInfoWeChatDTO> caseInfoPage = service.pageQueryWechat(userId,pageRequest, terms);
            return ReturnSucUtils.getRepInfo( "处理成功", caseInfoPage);
        } catch (Exception e) {
            log.error("Controller接口[CaseInfoWechatController.pageCard]请求异常:"+e, e);
            return ReturnFailUtils.getRepInfo();
        }
    }
 
 
    /**
     * 小程序端-纠纷登记-保存纠纷信息-正常案件
     * @url {ctx}/api/wechat/caseInfo/caseRegister
     * @param registerSaveDTO 实体对象
     *  @CurrentUser String userId,
     */
    @PostMapping("/caseRegister")
    public Object caseRegister(@CurrentUser String userId, @RequestBody RegisterSaveDTO registerSaveDTO) {
        try {
            Object caseRegister = GuavaCacheUtils.getCache("caseRegister"+userId);
            if(ObjectUtils.isNotEmpty(caseRegister)){
                log.info("caseRegister is exist {}",caseRegister);
                return ReturnSucUtils.getRepInfo(caseRegister);
            }else{
                if(ObjectUtils.isEmpty(registerSaveDTO.getId())){
                    registerSaveDTO.setId(utilsClient.getNewTimeCaseId());
                }
                GuavaCacheUtils.putCache("caseRegister"+userId,registerSaveDTO.getId());
            }
            String caseId = service.caseRegisterWechat(registerSaveDTO, userId);
            return ReturnSucUtils.getRepInfo(caseId);
        } catch (Exception e) {
            log.error("Controller接口[CaseInfoWechatController.caseRegister]请求异常:"+e, e);
            return ReturnFailUtils.getRepInfo(e.getMessage());
        }
    }
 
    /**
     * 小程序端-查看案件详情
     * @url {ctx}/api/wechat/caseInfo/getCaseInfo
     */
    @GetMapping("/getCaseInfo")
    public Object getCaseInfo(@RequestParam(value = "id") String id) {
        try {
            return ReturnSucUtils.getRepInfo(service.getCaseInfoWechat(id));
        } catch (Exception e) {
            log.error("Controller接口[CaseInfoWechatController.caseInfo]请求异常:"+e, e);
            return ReturnFailUtils.getRepInfo(e.getMessage());
        }
    }
}