forked from gzzfw/backEnd/gz-dyh

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
package cn.huge.module.judic.controller;
 
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.common.utils.JudicNoUtils;
import cn.huge.module.judic.service.JudicInfoService;
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: 公共参数-司法确认号工具接口api-web端
 * @description: 公共参数-司法确认号工具接口api-web端
 * @company: hugeinfo
 * @author: liyj
 * @time: 2022-04-29 10:12:39
 * @version: 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/common/api/judicNoUtils")
public class JudicNoUtilsController {
 
    @Autowired(required = false)
    private HttpServletRequest request;
 
    @Autowired
    private JudicInfoService judicInfoService;
 
 
    /**
     * 生成新的调解案号
     * @url {ctx}/common/api/judicNoUtils/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}/common/api/judicNoUtils/createByStartNo
     * @return Object
     */
    @GetMapping("/createByStartNo")
    public Object createByStartNo(@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();
        }
    }
 
}