郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
package com.gkhy.safePlatform.riskCtrl.controller;
 
import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.enums.DepartmentLevelEnum;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepRPCRespDTO;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.riskCtrl.model.dto.req.CreateNewRespSpiReportReqDTO;
import com.gkhy.safePlatform.riskCtrl.service.RiskSpiService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@RestController
@RequestMapping("riskCtrl/spi/report")
public class RiskSpiController {
 
    @Autowired
    private RiskSpiService riskSpiService;
 
    @DubboReference(check = false)
    private AccountDepartmentService departmentService;
 
 
    @PostMapping("/add")
    public Object insertOne(@RequestBody CreateNewRespSpiReportReqDTO createDTO){
        return riskSpiService.saveOneRiskSpiReport(createDTO);
    }
 
    @GetMapping("/month/gen/e")
    public Object generateCompanySpiMonthlyReport(){
        ResultVO resultVO = new ResultVO<>();
        List<DepRPCRespDTO> depList = (List<DepRPCRespDTO>) departmentService.depList().getData();
        if(depList != null && !depList.isEmpty()){
            for(DepRPCRespDTO dep : depList){
                if(dep.getDepLevel().equals(DepartmentLevelEnum.COMPANY.code)){
                    System.out.println("企业ID:"+dep.getDepId()+" ,名称: "+dep.getDepName());
                    resultVO = riskSpiService.generateDepartmentSpiReportMonthlyScheduled(dep.getDepId());
                }
            }
        }
 
        return resultVO;
    }
 
    /**
     * 获取企业级最近12个月的SPI报表
     * @return
     */
    @GetMapping("/e/12month")
    public Object calCompanySpiMonthlyReportRt(){
        ResultVO resultVO = new ResultVO<>();
        Long guotaiCompanyDepId = 1L;
        resultVO = riskSpiService.calSpiValueForLast12Months(guotaiCompanyDepId);
        return resultVO;
    }
 
 
    /**
     * 获取任意部门最近12个月的SPI报表
     * @param depId
     * @return
     */
    @GetMapping("/dep/12month")
    public Object calDepartmentSpiMonthlyReportRt(Long depId){
        ResultVO resultVO = new ResultVO<>();
        if(depId > 0){
            resultVO.setCode(ResultCodes.OK.getCode());
            resultVO = riskSpiService.calSpiValueForLast12Months(depId);
            return resultVO;
        }else {
            resultVO.setCode(ResultCodes.CLIENT_PARAM_ERROR.getCode());
            resultVO.setMsg("参数错误");
            return resultVO;
        }
    }
 
    /**
     * 获取任意部门指定年月份的SPI报表
     * @param depId
     * @param year
     * @param month
     * @return
     */
    @GetMapping("/dep/singleMonth")
    public Object calDepartmentSpiMonthlyReportRt(Long depId,Integer year,Integer month){
        ResultVO resultVO = new ResultVO<>();
        if(depId > 0){
            resultVO.setCode(ResultCodes.OK.getCode());
            resultVO = riskSpiService.getSpiReportByMonth(depId,year,month);
            return resultVO;
        }else {
            resultVO.setCode(ResultCodes.CLIENT_PARAM_ERROR.getCode());
            resultVO.setMsg("参数错误");
            return resultVO;
        }
    }
 
}