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 depList = (List) 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; } } }