AppPageReportController.java 26 KB

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