AppReportController.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package com.ydtech.modules.admin.controller;
  2. import com.ydtech.core.page.HttpResult;
  3. import com.ydtech.exception.SystemException;
  4. import com.ydtech.modules.admin.model.dto.AllpremiumDto;
  5. import com.ydtech.modules.admin.model.dto.EmployeeIncreaseReportAllDto;
  6. import com.ydtech.modules.admin.model.dto.PremiumReportAllDto;
  7. import com.ydtech.modules.admin.model.dto.RevenueReportAllDto;
  8. import com.ydtech.modules.admin.model.vo.ReportQueryVo;
  9. import com.ydtech.modules.admin.service.AppReportService;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import lombok.RequiredArgsConstructor;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.*;
  16. @Api(tags = "app统计报表功能")
  17. @RestController
  18. @RequestMapping("/app/reporet")
  19. @RequiredArgsConstructor
  20. public class AppReportController {
  21. @Autowired
  22. private AppReportService appReportService;
  23. @ApiOperation(value = "保费报表")
  24. @PostMapping(value = "/premiumReport")
  25. public HttpResult<PremiumReportAllDto> premiumReport(@RequestBody ReportQueryVo reportQueryVo) {
  26. getListHttpResult(reportQueryVo);
  27. try{
  28. return appReportService.premiumReport(reportQueryVo);
  29. }catch (Exception e){
  30. return HttpResult.error("查询失败"+e.getMessage());
  31. }
  32. }
  33. /**
  34. * @version
  35. * @author: hxl
  36. * @Date: 2024/6/5 15:58
  37. * @Description: 参数验证
  38. */
  39. private static void getListHttpResult(ReportQueryVo reportQueryVo) {
  40. if(StringUtils.isBlank(reportQueryVo.getSearchType())){
  41. new SystemException("查询类型(1.年2.月3.日)searchtype不能为空");
  42. }
  43. //年
  44. if("1".equals(reportQueryVo.getSearchType())){
  45. if(StringUtils.isBlank(reportQueryVo.getSearchYear())){
  46. new SystemException("查询类型为(1.年)时searchYear不能为空");
  47. }
  48. }
  49. if("2".equals(reportQueryVo.getSearchType())){
  50. if(StringUtils.isBlank(reportQueryVo.getSearchMonth()) || StringUtils.isBlank(reportQueryVo.getSearchYear()) ){
  51. new SystemException("查询类型为(3.月)时searchYear,searchMonth不能为空");
  52. }
  53. }
  54. if("3".equals(reportQueryVo.getSearchType())){
  55. if(StringUtils.isBlank(reportQueryVo.getSearchDay()) || StringUtils.isBlank(reportQueryVo.getSearchMonth()) || StringUtils.isBlank(reportQueryVo.getSearchYear())){
  56. new SystemException("查询类型为(3.日)时searchYear,searchMonth,searchDay不能为空");
  57. }
  58. }
  59. }
  60. @ApiOperation(value = "增员报表")
  61. @PostMapping(value = "/employeeIncreaseReport")
  62. public HttpResult<EmployeeIncreaseReportAllDto> employeeIncreaseReport(@RequestBody ReportQueryVo reportQueryVo) {
  63. getListHttpResult(reportQueryVo);
  64. try{
  65. return appReportService.employeeIncreaseReport(reportQueryVo);
  66. }catch (Exception e){
  67. return HttpResult.error("查询失败"+e.getMessage());
  68. }
  69. }
  70. @ApiOperation(value = "收入报表")
  71. @PostMapping(value = "/revenueReport")
  72. public HttpResult<RevenueReportAllDto> revenueReport(@RequestBody ReportQueryVo reportQueryVo) {
  73. getListHttpResult(reportQueryVo);
  74. try{
  75. return appReportService.revenueReport(reportQueryVo);
  76. }catch (Exception e){
  77. return HttpResult.error("查询失败"+e.getMessage());
  78. }
  79. }
  80. @ApiOperation(value = "获取年度数据")
  81. @GetMapping(value = "/getAllpremium")
  82. public HttpResult<AllpremiumDto> getAllpremium(String year) {
  83. if(StringUtils.isBlank(year)){
  84. return HttpResult.error("年度year不能为空!!!");
  85. }
  86. try{
  87. return HttpResult.ok(appReportService.getAllpremium(year));
  88. }catch (Exception e){
  89. return HttpResult.error("查询失败"+e.getMessage());
  90. }
  91. }
  92. }