package com.ydtech.modules.admin.controller; import com.ydtech.core.page.HttpResult; import com.ydtech.exception.SystemException; import com.ydtech.modules.admin.model.dto.AllpremiumDto; import com.ydtech.modules.admin.model.dto.EmployeeIncreaseReportAllDto; import com.ydtech.modules.admin.model.dto.PremiumReportAllDto; import com.ydtech.modules.admin.model.dto.RevenueReportAllDto; import com.ydtech.modules.admin.model.vo.ReportQueryVo; import com.ydtech.modules.admin.service.AppReportService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @Api(tags = "app统计报表功能") @RestController @RequestMapping("/app/reporet") @RequiredArgsConstructor public class AppReportController { @Autowired private AppReportService appReportService; @ApiOperation(value = "保费报表") @PostMapping(value = "/premiumReport") public HttpResult premiumReport(@RequestBody ReportQueryVo reportQueryVo) { getListHttpResult(reportQueryVo); try{ return appReportService.premiumReport(reportQueryVo); }catch (Exception e){ return HttpResult.error("查询失败"+e.getMessage()); } } /** * @version * @author: hxl * @Date: 2024/6/5 15:58 * @Description: 参数验证 */ private static void getListHttpResult(ReportQueryVo reportQueryVo) { if(StringUtils.isBlank(reportQueryVo.getSearchType())){ new SystemException("查询类型(1.年2.月3.日)searchtype不能为空"); } //年 if("1".equals(reportQueryVo.getSearchType())){ if(StringUtils.isBlank(reportQueryVo.getSearchYear())){ new SystemException("查询类型为(1.年)时searchYear不能为空"); } } if("2".equals(reportQueryVo.getSearchType())){ if(StringUtils.isBlank(reportQueryVo.getSearchMonth()) || StringUtils.isBlank(reportQueryVo.getSearchYear()) ){ new SystemException("查询类型为(3.月)时searchYear,searchMonth不能为空"); } } if("3".equals(reportQueryVo.getSearchType())){ if(StringUtils.isBlank(reportQueryVo.getSearchDay()) || StringUtils.isBlank(reportQueryVo.getSearchMonth()) || StringUtils.isBlank(reportQueryVo.getSearchYear())){ new SystemException("查询类型为(3.日)时searchYear,searchMonth,searchDay不能为空"); } } } @ApiOperation(value = "增员报表") @PostMapping(value = "/employeeIncreaseReport") public HttpResult employeeIncreaseReport(@RequestBody ReportQueryVo reportQueryVo) { getListHttpResult(reportQueryVo); try{ return appReportService.employeeIncreaseReport(reportQueryVo); }catch (Exception e){ return HttpResult.error("查询失败"+e.getMessage()); } } @ApiOperation(value = "收入报表") @PostMapping(value = "/revenueReport") public HttpResult revenueReport(@RequestBody ReportQueryVo reportQueryVo) { getListHttpResult(reportQueryVo); try{ return appReportService.revenueReport(reportQueryVo); }catch (Exception e){ return HttpResult.error("查询失败"+e.getMessage()); } } @ApiOperation(value = "获取年度数据") @GetMapping(value = "/getAllpremium") public HttpResult getAllpremium(String year) { if(StringUtils.isBlank(year)){ return HttpResult.error("年度year不能为空!!!"); } try{ return HttpResult.ok(appReportService.getAllpremium(year)); }catch (Exception e){ return HttpResult.error("查询失败"+e.getMessage()); } } }