|
@@ -1,8 +1,10 @@
|
|
|
package com.huaxu.controller;
|
|
|
+import com.huaxu.dto.MonthRevenueDto;
|
|
|
import com.huaxu.dto.generalView.DeviceWaterSupply;
|
|
|
import com.huaxu.model.AjaxMessage;
|
|
|
import com.huaxu.model.ResultStatus;
|
|
|
import com.huaxu.service.AppPageReportService;
|
|
|
+import com.huaxu.service.RevenueService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
@@ -27,9 +29,13 @@ import java.util.Map;
|
|
|
@RequestMapping("/appPageReport")
|
|
|
@Api(tags = "App总览报表")
|
|
|
public class AppPageReportController {
|
|
|
+
|
|
|
@Autowired
|
|
|
private AppPageReportService appPageReportService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RevenueService revenueService;
|
|
|
+
|
|
|
/**
|
|
|
* @Author wangbo
|
|
|
* @Description App生产总览数据-本月数据
|
|
@@ -44,10 +50,10 @@ public class AppPageReportController {
|
|
|
List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,1);
|
|
|
List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,1);
|
|
|
List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,1);
|
|
|
- map.put("取水量", supplyWaterList);
|
|
|
- map.put("制水量", makingWaterList);
|
|
|
- map.put("售水量", sellerWaterList);
|
|
|
- CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
|
|
|
+ map.put("intake", supplyWaterList);
|
|
|
+ map.put("making", makingWaterList);
|
|
|
+ map.put("seller", sellerWaterList);
|
|
|
+ appPageReportService.CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
|
|
|
return new AjaxMessage<>(ResultStatus.OK,map);
|
|
|
}
|
|
|
|
|
@@ -66,10 +72,10 @@ public class AppPageReportController {
|
|
|
List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,localDate.getMonthValue());
|
|
|
List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,localDate.getMonthValue());
|
|
|
List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,localDate.getMonthValue());
|
|
|
- map.put("取水量", supplyWaterList);
|
|
|
- map.put("制水量", makingWaterList);
|
|
|
- map.put("售水量", sellerWaterList);
|
|
|
- CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
|
|
|
+ map.put("intake", supplyWaterList);
|
|
|
+ map.put("making", makingWaterList);
|
|
|
+ map.put("seller", sellerWaterList);
|
|
|
+ appPageReportService.CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
|
|
|
|
|
|
return new AjaxMessage<>(ResultStatus.OK,map);
|
|
|
}
|
|
@@ -88,75 +94,96 @@ public class AppPageReportController {
|
|
|
List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,12);
|
|
|
List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,12);
|
|
|
List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,12);
|
|
|
- map.put("取水量", supplyWaterList);
|
|
|
- map.put("制水量", makingWaterList);
|
|
|
- map.put("售水量", sellerWaterList);
|
|
|
- CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
|
|
|
+ map.put("intake", supplyWaterList);
|
|
|
+ map.put("making", makingWaterList);
|
|
|
+ map.put("seller", sellerWaterList);
|
|
|
+ appPageReportService.CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
|
|
|
return new AjaxMessage<>(ResultStatus.OK,map);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "getWaterIntakeComparison",method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "getSameMonthComparison",method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "App总览——生产数据-取水环比(本月)")
|
|
|
- public AjaxMessage<Object> getWaterIntakeComparison(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
|
|
|
- LocalDate localDate = LocalDate.now();
|
|
|
- LocalDate lastlocalDate = LocalDate.now();
|
|
|
- List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4,
|
|
|
- localDate.getYear(),localDate.getMonthValue(),1,
|
|
|
- localDate.getYear(),localDate.getMonthValue(),localDate.getDayOfMonth() );
|
|
|
+ public AjaxMessage<Object> getSameMonthComparison(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ LocalDate last = now.minusMonths(-1);
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
|
+ List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, now.getYear(),now.getMonthValue(),1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
|
|
|
|
|
|
- return new AjaxMessage<>(ResultStatus.OK,supplyWaterList);
|
|
|
- }
|
|
|
+ List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),last.getMonthValue(),1, last.getYear(),last.getMonthValue(),last.getDayOfMonth());
|
|
|
|
|
|
+ List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, now.getYear(),now.getMonthValue(),1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
|
|
|
|
|
|
+ List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),last.getMonthValue(),1, last.getYear(),last.getMonthValue(),last.getDayOfMonth());
|
|
|
|
|
|
+ map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
|
|
|
|
|
|
- /**
|
|
|
- * @Author wangbo
|
|
|
- * @Description 计算产销差
|
|
|
- * @param makingWaterList 制水量数据
|
|
|
- * @param sellerWaterList 售水量数据
|
|
|
- * @param map
|
|
|
- * @return
|
|
|
- */
|
|
|
- private void CalculationNrw(List<DeviceWaterSupply> supplyWaterList, List<DeviceWaterSupply> makingWaterList,List<DeviceWaterSupply> sellerWaterList,Map<String,Object> map){
|
|
|
- BigDecimal supplyWaterAmount = new BigDecimal(0);
|
|
|
- BigDecimal makingWaterAmount = new BigDecimal(0);
|
|
|
- BigDecimal sellerWaterAmount = new BigDecimal(0);
|
|
|
+ map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
|
|
|
|
|
|
- for(DeviceWaterSupply water : supplyWaterList){
|
|
|
- supplyWaterAmount = supplyWaterAmount.add(water.getAmount());
|
|
|
- }
|
|
|
- for(DeviceWaterSupply water : makingWaterList){
|
|
|
- makingWaterAmount = makingWaterAmount.add(water.getAmount());
|
|
|
- }
|
|
|
- for(DeviceWaterSupply water : sellerWaterList){
|
|
|
- sellerWaterAmount = sellerWaterAmount.add(water.getAmount());
|
|
|
- }
|
|
|
- BigDecimal nrw = makingWaterAmount ==BigDecimal.ZERO ? BigDecimal.ZERO : makingWaterAmount.subtract(sellerWaterAmount).multiply(new BigDecimal(100)).divide(makingWaterAmount,2);
|
|
|
- map.put("取水总量",supplyWaterAmount);
|
|
|
- map.put("制水总量",makingWaterAmount);
|
|
|
- map.put("售水总量",sellerWaterAmount);
|
|
|
- map.put("产销差",nrw);
|
|
|
+ List<DeviceWaterSupply> sameSellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,2);
|
|
|
+ BigDecimal comparison = sameSellerWaterList.get(0).getAmount() ==BigDecimal.ZERO ? BigDecimal.ZERO : sameSellerWaterList.get(0).getAmount().multiply(new BigDecimal(100)).divide(sameSellerWaterList.get(1).getAmount(),2);
|
|
|
+ map.put("sellerComparison",comparison);
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK,map);
|
|
|
}
|
|
|
- /**
|
|
|
- * @Author wangbo
|
|
|
- * @Description 计算环比
|
|
|
- * @param sameWaterList 本月数据
|
|
|
- * @param lastWaterList 上月数据
|
|
|
- * @return
|
|
|
- */
|
|
|
- private BigDecimal CalculationComparison(List<DeviceWaterSupply> sameWaterList, List<DeviceWaterSupply> lastWaterList){
|
|
|
- BigDecimal sameWaterAmount = new BigDecimal(0);
|
|
|
- BigDecimal lastWaterAmount = new BigDecimal(0);
|
|
|
- for(DeviceWaterSupply water : sameWaterList){
|
|
|
- sameWaterAmount = sameWaterAmount.add(water.getAmount());
|
|
|
+
|
|
|
+ @RequestMapping(value = "getSameYearComparison",method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "App总览——生产数据-取水环比、供水环比、售水环比(本年)")
|
|
|
+ public AjaxMessage<Object> getWaterIntakeComparison(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ LocalDate last = now.minusYears(-1);
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
+ List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, now.getYear(),1,1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
|
|
|
+ List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),1,1, last.getYear(),12,31);
|
|
|
+ List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, now.getYear(),1,1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
|
|
|
+ List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),1,1, last.getYear(),12,31);
|
|
|
+ List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,now.getMonthValue()+12);
|
|
|
+
|
|
|
+ BigDecimal sameSellerAmount = new BigDecimal(0);
|
|
|
+ BigDecimal lastSellerAmount = new BigDecimal(0);
|
|
|
+
|
|
|
+ for( int i =0 ;i<sellerWaterList.size(); i++){
|
|
|
+ if(i<now.getMonthValue()){
|
|
|
+ sameSellerAmount = sameSellerAmount.add(sellerWaterList.get(i).getAmount());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
|
|
|
+ }
|
|
|
}
|
|
|
- for(DeviceWaterSupply water : lastWaterList){
|
|
|
- lastWaterAmount = lastWaterAmount.add(water.getAmount());
|
|
|
+ BigDecimal comparison = lastSellerAmount ==BigDecimal.ZERO ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,2);
|
|
|
+ map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
|
|
|
+ map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
|
|
|
+ map.put("sellerComparison",comparison);
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK,map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "getLast12YearComparison",method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "App总览——生产数据-取水环比、供水环比、售水环比(近一年)")
|
|
|
+ public AjaxMessage<Object> getLast12YearComparison(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ LocalDate last = now.minusYears(-1);
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
+ List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, now.getYear(),1,1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
|
|
|
+ List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),1,1, last.getYear(),12,31);
|
|
|
+ List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, now.getYear(),1,1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
|
|
|
+ List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),1,1, last.getYear(),12,31);
|
|
|
+ List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,now.getMonthValue()+12);
|
|
|
+
|
|
|
+ BigDecimal sameSellerAmount = new BigDecimal(0);
|
|
|
+ BigDecimal lastSellerAmount = new BigDecimal(0);
|
|
|
+
|
|
|
+ for( int i =0 ;i<sellerWaterList.size(); i++){
|
|
|
+ if(i<now.getMonthValue()){
|
|
|
+ sameSellerAmount = sameSellerAmount.add(sellerWaterList.get(i).getAmount());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
|
|
|
+ }
|
|
|
}
|
|
|
- BigDecimal comparison = lastWaterAmount ==BigDecimal.ZERO ? BigDecimal.ZERO : sameWaterAmount.multiply(new BigDecimal(100)).divide(lastWaterAmount,2);
|
|
|
- return comparison;
|
|
|
+ BigDecimal comparison = lastSellerAmount ==BigDecimal.ZERO ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,2);
|
|
|
+ map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
|
|
|
+ map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
|
|
|
+ map.put("sellerComparison",comparison);
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK,map);
|
|
|
}
|
|
|
|
|
|
|