StatisticsApiController.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package com.goafanti.order.controller;
  2. import java.io.IOException;
  3. import java.util.List;
  4. import javax.servlet.http.HttpServletResponse;
  5. import com.goafanti.common.utils.excel.NewExcelUtil;
  6. import com.goafanti.order.bo.InputOrderSalesSource;
  7. import com.goafanti.order.bo.OutOrderSalesSource;
  8. import com.goafanti.order.service.OrderStatisticsService;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.beans.factory.annotation.Value;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestMethod;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import com.goafanti.common.bo.Result;
  15. import com.goafanti.common.controller.CertifyApiController;
  16. import com.goafanti.order.bo.InputProjectStatistics;
  17. import com.goafanti.order.bo.InputProvincialStatistics;
  18. import com.goafanti.order.service.ProjectStatisticsService;
  19. @RestController
  20. @RequestMapping(value = "/api/admin/statistis")
  21. public class StatisticsApiController extends CertifyApiController {
  22. @Value(value = "${upload.path}")
  23. private String uploadPath = null;
  24. @Autowired
  25. private ProjectStatisticsService projectStatisticsService;
  26. @Autowired
  27. private OrderStatisticsService orderStatisticsService;
  28. /**
  29. * 项目汇总列表
  30. */
  31. @RequestMapping(value="/selectTaskList" ,method = RequestMethod.GET)
  32. public Result selectTaskList(InputProjectStatistics ps){
  33. Result res=new Result();
  34. res.setData(projectStatisticsService.selectTaskList( ps));
  35. return res;
  36. }
  37. /**
  38. * 项目汇总列表导出xls
  39. * @throws IOException
  40. */
  41. @RequestMapping(value = "/exporTaskList", method = RequestMethod.GET)
  42. public Result exporTaskList(HttpServletResponse response,InputProjectStatistics ib) throws IOException{
  43. Result res=new Result();
  44. try {
  45. projectStatisticsService.exporTaskList( response, ib);
  46. } catch (Exception e) {
  47. res.getError().add(buildError("格式不正确"));
  48. e.printStackTrace();
  49. return res;
  50. }
  51. res.data(1);
  52. return res;
  53. }
  54. /**
  55. * 项目省份统计列表
  56. */
  57. @RequestMapping(value="/selectProvincialStatistics" ,method = RequestMethod.GET)
  58. public Result selectProvincialStatistics(InputProvincialStatistics is){
  59. Result res=new Result();
  60. res.setData(projectStatisticsService.selectProvincialStatistics( is));
  61. return res;
  62. }
  63. /**
  64. * 项目省份统计列表导出xls
  65. * @throws IOException
  66. */
  67. @RequestMapping(value = "/exporProvincialList", method = RequestMethod.GET)
  68. public Result exporProvincialList(InputProvincialStatistics ib){
  69. Result res=new Result();
  70. return projectStatisticsService.exporProvincialList( ib);
  71. }
  72. /**
  73. * 订单销售来源统计
  74. */
  75. @RequestMapping(value="/orderSalesSource" ,method = RequestMethod.GET)
  76. public Result orderSalesSource(InputOrderSalesSource in){
  77. Result res=new Result();
  78. res.setData(orderStatisticsService.orderSalesSource( in));
  79. return res;
  80. }
  81. /**
  82. * 订单销售来源统计
  83. */
  84. @RequestMapping(value="/orderSalesSource/export" ,method = RequestMethod.GET)
  85. public Result orderSalesSourceExport(InputOrderSalesSource in){
  86. List<OutOrderSalesSource> list =orderStatisticsService.orderSalesSource( in);
  87. NewExcelUtil<OutOrderSalesSource> excelUtil=new NewExcelUtil<>(OutOrderSalesSource.class);
  88. StringBuffer str=new StringBuffer("搜索条件=》");
  89. if (in.getDepName()!=null)str=str.append("部门:").append(in.getDepName()).append(";");
  90. if(in.getProvinceName()!=null)str=str.append("省份:").append(in.getProvinceName()).append(";");
  91. if (in.getSort()!=null)str=str.append("排序:").append(in.getSort()==1?"签单数":"签单金额").append(";");
  92. if (in.getStartDate()!=null &&in.getEndDate()!=null)str=str.append("时间:").append(in.getStartDate()).append("~")
  93. .append(in.getEndDate()).append(";");
  94. return excelUtil.exportExcel(list,"订单销售来源统计表",uploadPath,str.toString());
  95. }
  96. }