AppPageReportController.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. package com.huaxu.controller;
  2. import com.huaxu.dto.MonthRevenueDto;
  3. import com.huaxu.dto.generalView.DeviceWaterSupply;
  4. import com.huaxu.model.AjaxMessage;
  5. import com.huaxu.model.ResultStatus;
  6. import com.huaxu.service.AppPageReportService;
  7. import com.huaxu.service.RevenueService;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiOperation;
  10. import io.swagger.annotations.ApiParam;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RequestMethod;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import java.math.BigDecimal;
  17. import java.time.LocalDate;
  18. import java.util.HashMap;
  19. import java.util.List;
  20. import java.util.Map;
  21. /**
  22. * @description
  23. * @auto wangbo
  24. * @data 2021/3/18 10:50
  25. */
  26. @RestController
  27. @RequestMapping("/appPageReport")
  28. @Api(tags = "App总览报表")
  29. public class AppPageReportController {
  30. @Autowired
  31. private RevenueService revenueService;
  32. @Autowired
  33. private AppPageReportService appPageReportService;
  34. /**
  35. * @Author wangbo
  36. * @Description App生产总览数据-本月数据
  37. * @param companyOrgId 公司ID
  38. * @return
  39. */
  40. @RequestMapping(value = "getProductionDataForSameMonth",method = RequestMethod.GET)
  41. @ApiOperation(value = "App总览——生产数据(本月)")
  42. public AjaxMessage<Map<String,Object>> getProductionDataForMonth(
  43. @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  44. List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,1);
  45. List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,1);
  46. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,1);
  47. Map<String,Object> map = new HashMap<String,Object>();
  48. map.put("intake", supplyWaterList);
  49. map.put("making", makingWaterList);
  50. map.put("seller", sellerWaterList);
  51. appPageReportService.CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
  52. return new AjaxMessage<>(ResultStatus.OK,map);
  53. }
  54. /**
  55. * @Author wangbo
  56. * @Description App生产总览数据-本年数据
  57. * @param companyOrgId 公司ID
  58. * @return
  59. */
  60. @RequestMapping(value = "getProductionDataForSameYear",method = RequestMethod.GET)
  61. @ApiOperation(value = "App总览——生产数据(本年)")
  62. public AjaxMessage<Map<String,Object>> getProductionDataForSameYear(
  63. @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  64. LocalDate localDate = LocalDate.now();
  65. List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,localDate.getMonthValue());
  66. List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,localDate.getMonthValue());
  67. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,localDate.getMonthValue());
  68. Map<String,Object> map = new HashMap<String,Object>();
  69. map.put("intake", supplyWaterList);
  70. map.put("making", makingWaterList);
  71. map.put("seller", sellerWaterList);
  72. appPageReportService.CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
  73. return new AjaxMessage<>(ResultStatus.OK,map);
  74. }
  75. /**
  76. * @Author wangbo
  77. * @Description App生产总览数据-近一年数据
  78. * @param companyOrgId 公司ID
  79. * @return
  80. */
  81. @RequestMapping(value = "getProductionDataFor12Month",method = RequestMethod.GET)
  82. @ApiOperation(value = "App总览——生产数据(近一年)")
  83. public AjaxMessage<Map<String,Object>> getProductionDataFor12Month(
  84. @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  85. List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,12);
  86. List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,12);
  87. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,12);
  88. Map<String,Object> map = new HashMap<String,Object>();
  89. map.put("intake", supplyWaterList);
  90. map.put("making", makingWaterList);
  91. map.put("seller", sellerWaterList);
  92. appPageReportService.CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
  93. return new AjaxMessage<>(ResultStatus.OK,map);
  94. }
  95. @RequestMapping(value = "getProductionComparisonForSameMonth",method = RequestMethod.GET)
  96. @ApiOperation(value = "App总览——生产数据-取水环比(本月)")
  97. public AjaxMessage<Object> getProductionComparisonForSameMonth(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  98. LocalDate now = LocalDate.now();
  99. LocalDate last = now.minusMonths(1);
  100. List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, now.getYear(),now.getMonthValue(),1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
  101. List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),last.getMonthValue(),1, last.getYear(),last.getMonthValue(),last.getDayOfMonth());
  102. List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, now.getYear(),now.getMonthValue(),1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
  103. List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),last.getMonthValue(),1, last.getYear(),last.getMonthValue(),last.getDayOfMonth());
  104. Map<String,Object> map = new HashMap<String,Object>();
  105. map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
  106. map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
  107. List<DeviceWaterSupply> sameSellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,2);
  108. map.put("sellerComparison", sameSellerWaterList.get(0).getAmount().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerWaterList.get(0).getAmount().multiply(new BigDecimal(100)).divide(sameSellerWaterList.get(1).getAmount(),2));
  109. return new AjaxMessage<>(ResultStatus.OK,map);
  110. }
  111. @RequestMapping(value = "getProductionComparisonForSameYear",method = RequestMethod.GET)
  112. @ApiOperation(value = "App总览——生产数据-取水环比、供水环比、售水环比(本年)")
  113. public AjaxMessage<Object> getProductionComparisonForSameYear(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  114. LocalDate now = LocalDate.now();
  115. LocalDate last = now.minusYears(1);
  116. List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, now.getYear(),1,1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
  117. List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),1,1, last.getYear(),12,31);
  118. List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, now.getYear(),1,1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
  119. List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),1,1, last.getYear(),12,31);
  120. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,now.getMonthValue()+12);
  121. BigDecimal sameSellerAmount = new BigDecimal(0);
  122. BigDecimal lastSellerAmount = new BigDecimal(0);
  123. for( int i =0 ;i<sellerWaterList.size(); i++){
  124. if(i>=12){
  125. sameSellerAmount = sameSellerAmount.add(sellerWaterList.get(i).getAmount());
  126. }
  127. else{
  128. lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
  129. }
  130. }
  131. Map<String,Object> map = new HashMap<String,Object>();
  132. map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
  133. map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
  134. map.put("sellerComparison", lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,2));
  135. return new AjaxMessage<>(ResultStatus.OK,map);
  136. }
  137. @RequestMapping(value = "getProductionComparisonForLast12Month",method = RequestMethod.GET)
  138. @ApiOperation(value = "App总览——生产数据-取水环比、供水环比、售水环比(近一年)")
  139. public AjaxMessage<Object> getProductionComparisonForLast12Month(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  140. LocalDate now = LocalDate.now();
  141. LocalDate last = now.minusMonths(11);
  142. List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),last.getMonthValue(),last.getDayOfMonth(), now.getYear(),now.getMonthValue(),now.getDayOfMonth());
  143. List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),last.getMonthValue(),last.getDayOfMonth(),now.getYear(),now.getMonthValue(),now.getDayOfMonth());
  144. LocalDate last2 = last.minusDays(1);
  145. LocalDate last3 = last2.minusMonths(11);
  146. List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last3.getYear(),last2.getMonthValue(),last2.getDayOfMonth(), last.getYear(),12,31);
  147. List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),1,1, last.getYear(),12,31);
  148. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,24);
  149. BigDecimal sameSellerAmount = new BigDecimal(0);
  150. BigDecimal lastSellerAmount = new BigDecimal(0);
  151. for( int i =0 ;i<sellerWaterList.size(); i++){
  152. if(i>=12){
  153. sameSellerAmount = sameSellerAmount.add(sellerWaterList.get(i).getAmount());
  154. }
  155. else{
  156. lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
  157. }
  158. }
  159. Map<String,Object> map = new HashMap<String,Object>();
  160. map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
  161. map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
  162. map.put("sellerComparison",lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,2));
  163. return new AjaxMessage<>(ResultStatus.OK,map);
  164. }
  165. /**
  166. * @Author wangbo
  167. * @Description App 营业总览数据-本月应收实收回收率普通用户用量大用户用量数据
  168. * @param companyOrgId 公司ID
  169. * @return
  170. */
  171. @RequestMapping(value = "getBusinessDataForSameMonth",method = RequestMethod.GET)
  172. @ApiOperation(value = "App总览——营业总览应收实收回收率普通用户用量大用户用量数据(本月)")
  173. public AjaxMessage<Map<String,Object>> getSameMonthBusinessData(
  174. @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  175. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,1);
  176. BigDecimal sum = sellerWaterList.get(0).getGeneralUserAmount().add(sellerWaterList.get(0).getBigUserAmount());
  177. BigDecimal generalRate =sum.compareTo(BigDecimal.ZERO)==0?BigDecimal.ZERO:sellerWaterList.get(0).getGeneralUserAmount().multiply(new BigDecimal(100)).divide(sum,2);
  178. Map<String,Object> map = new HashMap<String,Object>();
  179. map.put("totalReceivable", sellerWaterList.get(0).getReceivableAmount());
  180. map.put("totalReceived", sellerWaterList.get(0).getReceivedAmount());
  181. map.put("amount",sellerWaterList);
  182. map.put("generalUser",sellerWaterList.get(0).getGeneralUserAmount());
  183. map.put("bigUser",sellerWaterList.get(0).getBigUserAmount());
  184. map.put("generalUserRate",generalRate);
  185. map.put("bigUserRate",new BigDecimal(100).subtract(generalRate));
  186. map.put("recoveryRate", sellerWaterList.get(0).getReceivableAmount().compareTo(BigDecimal.ZERO)==0? 0 : sellerWaterList.get(0).getReceivedAmount().multiply(new BigDecimal(100)).divide(sellerWaterList.get(0).getReceivableAmount(),2));
  187. return new AjaxMessage<>(ResultStatus.OK,map);
  188. }
  189. /**
  190. * @Author wangbo
  191. * @Description App 营业总览数据-本月应收实收回收率数据
  192. * @param companyOrgId 公司ID
  193. * @return
  194. */
  195. @RequestMapping(value = "getBusinessDataForSameYear",method = RequestMethod.GET)
  196. @ApiOperation(value = "App总览——营业总览应收实收回收率普通用户用量大用户用量数据(本年)")
  197. public AjaxMessage<Map<String,Object>> getBusinessDataForSameYear(
  198. @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  199. LocalDate now = LocalDate.now();
  200. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,now.getMonthValue());
  201. BigDecimal totalReceivableAmount = new BigDecimal(0);
  202. BigDecimal totalReceivedAmount = new BigDecimal(0);
  203. BigDecimal totalGeneralUser = new BigDecimal(0);
  204. BigDecimal totalBigUser = new BigDecimal(0);
  205. for(DeviceWaterSupply amount: sellerWaterList){
  206. totalReceivableAmount =totalReceivableAmount.add(amount.getReceivableAmount());
  207. totalReceivedAmount=totalReceivedAmount.add(amount.getReceivedAmount());
  208. totalGeneralUser=totalGeneralUser.add(amount.getGeneralUserAmount());
  209. totalBigUser=totalBigUser.add(amount.getBigUserAmount());
  210. }
  211. BigDecimal sum =totalBigUser.add(totalGeneralUser);
  212. BigDecimal generalRate =sum.compareTo(BigDecimal.ZERO)==0?BigDecimal.ZERO:totalGeneralUser.multiply(new BigDecimal(100)).divide(sum,2);
  213. Map<String,Object> map = new HashMap<String,Object>();
  214. map.put("totalReceivable", totalReceivableAmount);
  215. map.put("totalReceived",totalReceivedAmount);
  216. map.put("amountDetails",sellerWaterList);
  217. map.put("generalUser",totalGeneralUser);
  218. map.put("bigUser",totalBigUser);
  219. map.put("generalUserRate",generalRate);
  220. map.put("bigUserRate",new BigDecimal(100).subtract(generalRate));
  221. map.put("recoveryRate", totalReceivableAmount.compareTo(BigDecimal.ZERO)==0? 0 : totalReceivedAmount.multiply(new BigDecimal(100)).divide(totalReceivableAmount,2));
  222. return new AjaxMessage<>(ResultStatus.OK,map);
  223. }
  224. /**
  225. * @Author wangbo
  226. * @Description App 营业总览数据-近一年应收实收回收率数据
  227. * @param companyOrgId 公司ID
  228. * @return
  229. */
  230. @RequestMapping(value = "getBusinessDataForLast12Month",method = RequestMethod.GET)
  231. @ApiOperation(value = "App总览——营业总览应收实收回收率普通用户用量大用户用量数据(近一年)")
  232. public AjaxMessage<Map<String,Object>> getBusinessDataForLast12Month(
  233. @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  234. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,12);
  235. BigDecimal totalReceivableAmount = new BigDecimal(0);
  236. BigDecimal totalReceivedAmount = new BigDecimal(0);
  237. BigDecimal totalGeneralUser = new BigDecimal(0);
  238. BigDecimal totalBigUser = new BigDecimal(0);
  239. for(DeviceWaterSupply amount: sellerWaterList){
  240. totalReceivableAmount =totalReceivableAmount.add(amount.getReceivableAmount());
  241. totalReceivedAmount=totalReceivedAmount.add(amount.getReceivedAmount());
  242. totalGeneralUser=totalGeneralUser.add(amount.getGeneralUserAmount());
  243. totalBigUser=totalBigUser.add(amount.getBigUserAmount());
  244. }
  245. BigDecimal sum =totalBigUser.add(totalGeneralUser);
  246. BigDecimal generalRate =sum.compareTo(BigDecimal.ZERO)==0?BigDecimal.ZERO:totalGeneralUser.multiply(new BigDecimal(100)).divide(sum,2);
  247. Map<String,Object> map = new HashMap<String,Object>();
  248. map.put("totalReceivable", totalReceivableAmount);
  249. map.put("totalReceived",totalReceivedAmount);
  250. map.put("amountDetails",sellerWaterList);
  251. map.put("generalUser",totalGeneralUser);
  252. map.put("bigUser",totalBigUser);
  253. map.put("generalUserRate",generalRate);
  254. map.put("bigUserRate",new BigDecimal(100).subtract(generalRate));
  255. map.put("recoveryRate", totalReceivableAmount.compareTo(BigDecimal.ZERO)==0? 0 : totalReceivedAmount.multiply(new BigDecimal(100)).divide(totalReceivableAmount,2));
  256. return new AjaxMessage<>(ResultStatus.OK,map);
  257. }
  258. @RequestMapping(value = "getSellerComparisonForSameMonth",method = RequestMethod.GET)
  259. @ApiOperation(value = "App总览——营收数据-应收实收环比(本月)")
  260. public AjaxMessage<Object> getSellerComparisonForSameMonth(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  261. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,2);
  262. BigDecimal receivableComparison = sellerWaterList.get(1).getReceivableAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivableAmount().multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivableAmount(),2);
  263. BigDecimal receivedComparison = sellerWaterList.get(1).getReceivedAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivedAmount().multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivedAmount(),2);
  264. Map<String,Object> map = new HashMap<String,Object>();
  265. map.put("receivableComparison",receivableComparison);
  266. map.put("receivedComparison",receivedComparison);
  267. return new AjaxMessage<>(ResultStatus.OK,map);
  268. }
  269. @RequestMapping(value = "getSellerComparisonForSameYear",method = RequestMethod.GET)
  270. @ApiOperation(value = "App总览——营收数据-应收实收环比(本年)")
  271. public AjaxMessage<Object> getSellerComparisonForSameYear(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  272. LocalDate now = LocalDate.now();
  273. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,12+now.getMonthValue());
  274. BigDecimal receivedSameYearComparison = new BigDecimal(0);
  275. BigDecimal receivedLastYearComparison = new BigDecimal(0);
  276. BigDecimal receivableSameYearComparison = new BigDecimal(0);
  277. BigDecimal receivableLastYearComparison = new BigDecimal(0);
  278. for(int i=0 ;i<sellerWaterList.size();i++){
  279. if(i>=12){
  280. receivedSameYearComparison = receivedSameYearComparison.add(sellerWaterList.get(i).getReceivedAmount());
  281. receivableSameYearComparison =receivableSameYearComparison.add(sellerWaterList.get(i).getReceivableAmount());
  282. }
  283. else{
  284. receivedLastYearComparison = receivedLastYearComparison.add(sellerWaterList.get(i).getReceivedAmount());
  285. receivableLastYearComparison =receivableLastYearComparison.add(sellerWaterList.get(i).getReceivableAmount());
  286. }
  287. }
  288. BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.multiply(new BigDecimal(100)).divide(receivedLastYearComparison,2);
  289. BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.multiply(new BigDecimal(100)).divide(receivableLastYearComparison,2);
  290. Map<String,Object> map = new HashMap<String,Object>();
  291. map.put("receivableComparison",receivableComparison);
  292. map.put("receivedComparison",receivedComparison);
  293. return new AjaxMessage<>(ResultStatus.OK,map);
  294. }
  295. @RequestMapping(value = "getSellerComparisonForLast12Month",method = RequestMethod.GET)
  296. @ApiOperation(value = "App总览——营收数据-应收实收环比(本年)")
  297. public AjaxMessage<Object> getSellerComparisonForLast12Month(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
  298. BigDecimal receivedSameYearComparison = new BigDecimal(0);
  299. BigDecimal receivedLastYearComparison = new BigDecimal(0);
  300. BigDecimal receivableSameYearComparison = new BigDecimal(0);
  301. BigDecimal receivableLastYearComparison = new BigDecimal(0);
  302. List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,24);
  303. for(int i=0;i<sellerWaterList.size();i++){
  304. if(i>=12){
  305. receivedSameYearComparison = receivedSameYearComparison.add(sellerWaterList.get(i).getReceivedAmount());
  306. receivableSameYearComparison =receivableSameYearComparison.add(sellerWaterList.get(i).getReceivableAmount());
  307. }
  308. else{
  309. receivedLastYearComparison = receivedLastYearComparison.add(sellerWaterList.get(i).getReceivedAmount());
  310. receivableLastYearComparison =receivableLastYearComparison.add(sellerWaterList.get(i).getReceivableAmount());
  311. }
  312. }
  313. BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.multiply(new BigDecimal(100)).divide(receivedLastYearComparison,2);
  314. BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.multiply(new BigDecimal(100)).divide(receivableLastYearComparison,2);
  315. Map<String,Object> map = new HashMap<String,Object>();
  316. map.put("receivableComparison",receivableComparison);
  317. map.put("receivedComparison",receivedComparison);
  318. return new AjaxMessage<>(ResultStatus.OK,map);
  319. }
  320. }