StatisticsApiController.java 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. package com.goafanti.order.controller;
  2. import com.goafanti.common.bo.Result;
  3. import com.goafanti.common.constant.AFTConstants;
  4. import com.goafanti.common.controller.CertifyApiController;
  5. import com.goafanti.common.utils.excel.NewExcelUtil;
  6. import com.goafanti.core.mybatis.page.Pagination;
  7. import com.goafanti.core.shiro.token.TokenManager;
  8. import com.goafanti.order.bo.*;
  9. import com.goafanti.order.bo.outStatistics.OutOrderSalesSourceAmount;
  10. import com.goafanti.order.service.OrderStatisticsService;
  11. import com.goafanti.order.service.ProjectStatisticsService;
  12. import com.goafanti.order.service.UserStaticticsService;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.beans.factory.annotation.Value;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestMethod;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import javax.servlet.http.HttpServletResponse;
  19. import java.io.IOException;
  20. import java.util.List;
  21. @RestController
  22. @RequestMapping(value = "/api/admin/statistis")
  23. public class StatisticsApiController extends CertifyApiController {
  24. @Value(value = "${upload.path}")
  25. private String uploadPath = null;
  26. @Autowired
  27. private ProjectStatisticsService projectStatisticsService;
  28. @Autowired
  29. private OrderStatisticsService orderStatisticsService;
  30. @Autowired
  31. private UserStaticticsService userStaticticsService;
  32. /**
  33. * 项目汇总列表
  34. * 项目统计表点击弹出得详情列表
  35. */
  36. @RequestMapping(value="/selectTaskList" ,method = RequestMethod.GET)
  37. public Result selectTaskList(InputProjectStatistics ps){
  38. Result res=new Result();
  39. res.setData(projectStatisticsService.selectTaskList(ps));
  40. return res;
  41. }
  42. /**
  43. * 项目汇总列表导出xls
  44. * @throws IOException
  45. */
  46. @RequestMapping(value = "/exporTaskList", method = RequestMethod.GET)
  47. public Result exporTaskList(InputProjectStatistics ib,HttpServletResponse response) {
  48. Result res = res();
  49. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)){
  50. res.getError().add(buildError("权限不足"));
  51. return res;
  52. }
  53. return projectStatisticsService.exporTaskList(ib,response);
  54. }
  55. /**
  56. * 项目省份统计列表
  57. */
  58. @RequestMapping(value="/selectProvincialStatistics" ,method = RequestMethod.GET)
  59. public Result selectProvincialStatistics(InputProvincialStatistics is){
  60. Result res=new Result();
  61. res.setData(projectStatisticsService.selectProvincialStatistics(is));
  62. return res;
  63. }
  64. /**
  65. * 项目省份统计列表导出xls
  66. * @throws IOException
  67. */
  68. @RequestMapping(value = "/exporProvincialList", method = RequestMethod.GET)
  69. public Result exporProvincialList(InputProvincialStatistics ib){
  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. if (in.getSort()==null||in.getSort()==1){
  87. List<OutOrderSalesSource> list = (List<OutOrderSalesSource>) orderStatisticsService.orderSalesSource(in);
  88. NewExcelUtil<OutOrderSalesSource> excelUtil=new NewExcelUtil<>(OutOrderSalesSource.class);
  89. StringBuffer str = getStringBuffer(in);
  90. return excelUtil.exportExcel(list,"订单销售来源统计表",uploadPath,str.toString());
  91. }else if (in.getSort()==0){
  92. List<OutOrderSalesSourceAmount> list = (List<OutOrderSalesSourceAmount>) orderStatisticsService.orderSalesSource(in);
  93. NewExcelUtil<OutOrderSalesSourceAmount> excelUtil=new NewExcelUtil<>(OutOrderSalesSourceAmount.class);
  94. StringBuffer str = getStringBuffer(in);
  95. return excelUtil.exportExcel(list,"订单销售来源统计表",uploadPath,str.toString());
  96. }
  97. return new Result();
  98. }
  99. private StringBuffer getStringBuffer(InputOrderSalesSource in) {
  100. StringBuffer str=new StringBuffer("搜索条件=》");
  101. if (in.getDepName()!=null){
  102. str=str.append("部门:").append(in.getDepName()).append(";");
  103. }
  104. if(in.getProvinceName()!=null){
  105. str=str.append("省份:").append(in.getProvinceName()).append(";");
  106. }
  107. if (in.getSort()!=null){
  108. str=str.append("排序:").append(in.getSort()==1?"签单数":"签单金额").append(";");
  109. }
  110. if (in.getStartDate()!=null && in.getEndDate()!=null){
  111. str=str.append("时间:").append(in.getStartDate()).append("~")
  112. .append(in.getEndDate()).append(";");
  113. }
  114. return str;
  115. }
  116. /**
  117. * 签单客户汇总
  118. */
  119. @RequestMapping(value = "/signSummary",method = RequestMethod.GET)
  120. public Result signSummary(InputSignSummary in){
  121. Result res = new Result();
  122. res.data(userStaticticsService.signSummary(in));
  123. return res;
  124. }
  125. /**
  126. * 签单客户汇总导出
  127. */
  128. @RequestMapping(value = "/signSummary/export",method = RequestMethod.GET)
  129. public Result signSummaryExport(InputSignSummary in){
  130. List<OutSignSummary> list = userStaticticsService.signSummaryList(in);
  131. NewExcelUtil<OutSignSummary> excelUtil=new NewExcelUtil<>(OutSignSummary.class);
  132. return excelUtil.exportExcel(list,"签单客户汇总表",uploadPath);
  133. }
  134. /**
  135. * 签单客户统计表
  136. */
  137. @RequestMapping(value = "/signStatistics",method = RequestMethod.GET)
  138. public Result signStatistics(InputSignStatistics in){
  139. Result res = new Result();
  140. res.data(userStaticticsService.signStatistics(in));
  141. return res;
  142. }
  143. /**
  144. * 签单客户统计表导出
  145. */
  146. @RequestMapping(value = "/signStatistics/export",method = RequestMethod.GET)
  147. public Result signStatisticsExport(InputSignStatistics in){
  148. List<OutSignStatistics> list = userStaticticsService.signStatisticsGetList(in);
  149. NewExcelUtil<OutSignStatistics> excelUtil=new NewExcelUtil<>(OutSignStatistics.class);
  150. return excelUtil.exportExcel(list,"签单客户统计表",uploadPath);
  151. }
  152. /**
  153. * 销售来源订单列表
  154. * @param in
  155. * @return
  156. */
  157. @RequestMapping(value="/signStatistics/orderList", method = RequestMethod.GET)
  158. public Result orderNewList(InputSignStatistics in ){
  159. Result res=new Result();
  160. res.data(userStaticticsService.signStatisticsOrderList(in));
  161. return res;
  162. }
  163. /**
  164. * 订单项目数据统计
  165. * @param in
  166. * @return
  167. */
  168. @RequestMapping(value="/orderProject", method = RequestMethod.GET)
  169. public Result<Pagination<OutOrderProject>> orderProject(InputOrderProject in ){
  170. Result res=new Result();
  171. res.data(userStaticticsService.orderProject(in));
  172. return res;
  173. }
  174. /**
  175. * 订单项目数据统计导出
  176. */
  177. @RequestMapping(value = "/orderProject/export",method = RequestMethod.GET)
  178. public Result orderProjectExport(InputOrderProject in){
  179. in.setPageSize(999999);
  180. in.setPageNo(1);
  181. Pagination<OutOrderProject> p = userStaticticsService.orderProject(in);
  182. List<OutOrderProject> list = (List<OutOrderProject>) p.getList();
  183. NewExcelUtil<OutOrderProject> excelUtil=new NewExcelUtil<>(OutOrderProject.class);
  184. return excelUtil.OrderMergeAndExportExcel(list,"订单项目数据统计表",uploadPath);
  185. // return excelUtil.exportExcel(list,"订单项目数据统计表",uploadPath);
  186. }
  187. }