|
@@ -1,13 +1,8 @@
|
|
|
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.HomePageReportService;
|
|
|
-import com.huaxu.service.RevenueService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
@@ -17,9 +12,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @description
|
|
@@ -33,58 +30,97 @@ public class AppPageReportController {
|
|
|
@Autowired
|
|
|
private AppPageReportService appPageReportService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RevenueService revenueService;
|
|
|
-
|
|
|
/**
|
|
|
- * App生产总览数据-本月数据
|
|
|
- * @param companyOrgId
|
|
|
+ * @Author wangbo
|
|
|
+ * @Description App生产总览数据-本月数据
|
|
|
+ * @param companyOrgId 公司ID
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "getProductionDataForSameMonth",method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "App总览——生产数据(本月)")
|
|
|
- public AjaxMessage<List<DeviceWaterSupply>> getProductionDataForMonth(
|
|
|
+ public AjaxMessage<Map<String,Object>> getProductionDataForMonth(
|
|
|
@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
|
|
|
- List<DeviceWaterSupply> result = new ArrayList<DeviceWaterSupply>();
|
|
|
- result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,1));
|
|
|
- result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,1));
|
|
|
- result.addAll(appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,1));
|
|
|
- return new AjaxMessage<>(ResultStatus.OK,result);
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
+ 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);
|
|
|
+ CalculationWaterData(supplyWaterList,makingWaterList,sellerWaterList,map);
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK,map);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
- * App生产总览数据-本年数据
|
|
|
- * @param companyOrgId
|
|
|
+ * @Author wangbo
|
|
|
+ * @Description App生产总览数据-本年数据
|
|
|
+ * @param companyOrgId 公司ID
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "getProductionDataForSameYear",method = RequestMethod.GET)
|
|
|
- @ApiOperation(value = "App总览——生产数据(本月)")
|
|
|
- public AjaxMessage<List<DeviceWaterSupply>> getProductionDataForSameYear(
|
|
|
+ @ApiOperation(value = "App总览——生产数据(本年)")
|
|
|
+ public AjaxMessage<Map<String,Object>> getProductionDataForSameYear(
|
|
|
@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
- List<DeviceWaterSupply> result = new ArrayList<DeviceWaterSupply>();
|
|
|
- result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,localDate.getMonthValue()));
|
|
|
- result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,localDate.getMonthValue()));
|
|
|
- result.addAll(appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,localDate.getMonthValue()));
|
|
|
- return new AjaxMessage<>(ResultStatus.OK,result);
|
|
|
- }
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
+ 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);
|
|
|
+ CalculationWaterData(supplyWaterList,makingWaterList,sellerWaterList,map);
|
|
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK,map);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * App生产总览数据-近一年数据
|
|
|
- * @param companyOrgId
|
|
|
+ * @Author wangbo
|
|
|
+ * @Description App生产总览数据-近一年数据
|
|
|
+ * @param companyOrgId 公司ID
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "getProductionDataFor12Month",method = RequestMethod.GET)
|
|
|
- @ApiOperation(value = "App总览——生产数据(本月)")
|
|
|
- public AjaxMessage<List<DeviceWaterSupply>> getProductionDataFor12Month(
|
|
|
+ @ApiOperation(value = "App总览——生产数据(近一年)")
|
|
|
+ public AjaxMessage<Map<String,Object>> getProductionDataFor12Month(
|
|
|
@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
|
|
|
- List<DeviceWaterSupply> result = new ArrayList<DeviceWaterSupply>();
|
|
|
- result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,12));
|
|
|
- result.addAll(appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,12));
|
|
|
- result.addAll(appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,12));
|
|
|
- return new AjaxMessage<>(ResultStatus.OK,result);
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
+ 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);
|
|
|
+ CalculationWaterData(supplyWaterList,makingWaterList,sellerWaterList,map);
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK,map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author wangbo
|
|
|
+ * @Description 计算产销差
|
|
|
+ * @param makingWaterList 制水量数据
|
|
|
+ * @param sellerWaterList 售水量数据
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void CalculationWaterData(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);
|
|
|
+
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|