广州市综治平台后端
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
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
package cn.huge.module.mediate.controller.client;
 
import cn.huge.base.common.constant.GzRegionBaseEnum;
import cn.huge.base.common.utils.DateUtils;
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.module.mediate.service.CaseInfoService;
import cn.huge.module.mediate.service.JudicInfoService;
import cn.huge.module.mediate.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
 
/**
 * @title: 公共参数-id工具接口api-mediate服务专用
 * @description: 公共参数-id工具接口api-mediate服务专用
 * @company: hugeinfo
 * @author: liyj
 * @time: 2022-04-29 10:12:39
 * @version: 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/api/client/mediateUtils")
public class MediateUtilsController {
 
    @Autowired(required = false)
    private HttpServletRequest request;
 
    @Autowired
    private CaseInfoService caseInfoService;
    @Autowired
    private JudicInfoService judicInfoService;
 
 
    /**
     * 公共id-获取时间Id,后四位常量
     * @url {ctx}/api/client/mediateUtils/getNewTimeId
     * @return Object
     */
    @GetMapping("/getNewTimeId")
    public Object getNewTimeId() {
        try {
            return ReturnSucUtils.getRepInfo(MediateIdUtils.getNewTimeId());
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
 
    /**
     * 案件id-获取时间Id,后四位常量
     * @url {ctx}/api/client/mediateUtils/getNewTimeCaseId
     * @return Object
     */
    @GetMapping("/getNewTimeCaseId")
    public Object getNewTimeCaseId() {
        try {
            return ReturnSucUtils.getRepInfo(CaseIdUtils.getNewTimeId());
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 生成新的调解案号
     * @url {ctx}/api/client/mediateUtils/createCaseNo
     * @param area 区
     * @return Object
     */
    @GetMapping("/createCaseNo")
    public Object createCaseNo(@RequestParam(value = "area") String area) {
        try {
            // 判断是否需要查询数据库获取初始化序号
            if (CaseNoUtils.getFlag(area)){
                // 查询数据库已存在多少,初始化序号
                String caseNoPrefix = CaseNoUtils.getSign(area);
                String newCaseNo = caseInfoService.getNewCaseNo(caseNoPrefix);
                if(StringUtils.isBlank(newCaseNo)){
                    newCaseNo = "0";
                }
                String numStr = newCaseNo.replace(caseNoPrefix, "").replace("号", "");
                int noCount = Integer.parseInt(numStr);
                // 设置初始化序号
                CaseNoUtils.setCount(area, noCount);
                // 设置不需要查询
                CaseNoUtils.setFlag(area, false);
            }
            return ReturnSucUtils.getRepInfo(CaseNoUtils.getCaseNo(area));
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 从startNo(包括startNo)开始生成新的调解案号
     * @url {ctx}/api/client/mediateUtils/setCaseNoByStartNo
     * @return Object
     */
    @GetMapping("/setCaseNoByStartNo")
    public Object setCaseNoByStartNo(@RequestParam(value = "area") String area, @RequestParam(value = "startNo") int startNo) {
        try {
            CaseNoUtils.setCount(area, startNo);
            CaseNoUtils.setFlag(area, false);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 生成新的事项编号
     * @url {ctx}/api/client/mediateUtils/createCaseRef
     * @return Object
     */
    @GetMapping("/createCaseRef")
    public Object createCaseRef(@RequestParam(value = "area") String area) {
        try {
            // 判断是否需要查询数据库获取初始化序号
            if (CaseRefUtils.getFlag(area)){
                // 查询数据库已存在多少,初始化序号
                String caseRsfSign = CaseRefUtils.getSign(area);
                String newCaseRef = caseInfoService.getNewCaseRef(caseRsfSign);
                int refCount = 0;
                if(StringUtils.isBlank(newCaseRef)){
                    refCount = 0;
                }else {
                    if (newCaseRef.indexOf("-") != -1) {
                        String[] numStrs = newCaseRef.split("-");
                        refCount = Integer.parseInt(numStrs[2]) + 1;
                    }else {
                        refCount = 0;
                    }
                }
                // 设置初始化序号
                CaseRefUtils.setCount(area, refCount);
                // 设置不需要查询
                CaseRefUtils.setFlag(area, false);
            }
            // 获取事项编号
            return ReturnSucUtils.getRepInfo(CaseRefUtils.getCaseRsf(area));
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 从startNo(包括startNo)开始生成新的事项编号
     * @url {ctx}/api/client/mediateUtils/setCaseNoByStartRef
     * @return Object
     */
    @GetMapping("/setCaseNoByStartRef")
    public Object setCaseNoByStartRef(@RequestParam(value = "area") String area, @RequestParam(value = "startRef") int startRef) {
        try {
            CaseRefUtils.setCount(area, startRef);
            CaseRefUtils.setFlag(area, false);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 司法确认id-获取时间Id,后四位常量
     * @url {ctx}/api/client/mediateUtils/getNewTimeJudicId
     * @return Object
     */
    @GetMapping("/getNewTimeJudicId")
    public Object getNewTimeJudicId() {
        try {
            return ReturnSucUtils.getRepInfo(JudicIdUtils.getNewTimeId());
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 生成新的调解案号
     * @url {ctx}/api/client/mediateUtils/createJudicNo
     * @param custId 客户编号
     * @return Object
     */
    @GetMapping("/createJudicNo")
    public Object createJudicNo(@RequestParam(value = "custId") String custId) {
        try {
            if (JudicNoUtils.JUDIC_NO_FALG){
                int year = DateUtils.getYear(new Date());
                String judicNoPrefix = "(" + year + ")司法确认";
                String newJudicNo = judicInfoService.getNewJudicNo(judicNoPrefix, custId);
                if(StringUtils.isBlank(newJudicNo)){
                    newJudicNo = "0";
                }
                String numStr = newJudicNo.replace(judicNoPrefix, "").replace("号", "");
                int num = Integer.parseInt(numStr);
                JudicNoUtils.JUDIC_NO_SIGN = num;
                JudicNoUtils.JUDIC_NO_FALG = false;
            }
            return ReturnSucUtils.getRepInfo(JudicNoUtils.getJudicNo());
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 从startNo(包括startNo)开始生成新的司法确认号
     * @url {ctx}/api/client/mediateUtils/setJudicByStartNo
     * @return Object
     */
    @GetMapping("/setJudicByStartNo")
    public Object setJudicByStartNo(@RequestParam(value = "startNo") int startNo) {
        try {
            JudicNoUtils.JUDIC_NO_SIGN = startNo-1;
            JudicNoUtils.JUDIC_NO_FALG = false;
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
}