Sfoglia il codice sorgente

App总览-营业数据-营收实收

wangbo 4 anni fa
parent
commit
1996aaa08e

+ 49 - 19
sms_water/src/main/java/com/huaxu/controller/AppPageReportController.java

@@ -29,12 +29,10 @@ import java.util.Map;
 @RequestMapping("/appPageReport")
 @Api(tags = "App总览报表")
 public class AppPageReportController {
-
-    @Autowired
-    private AppPageReportService appPageReportService;
-
     @Autowired
     private RevenueService revenueService;
+    @Autowired
+    private AppPageReportService appPageReportService;
 
     /**
      * @Author wangbo
@@ -107,22 +105,14 @@ public class AppPageReportController {
         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());
-
         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));
-
         map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
-
         List<DeviceWaterSupply> sameSellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,2);
-        BigDecimal comparison = sameSellerWaterList.get(0).getAmount().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerWaterList.get(0).getAmount().multiply(new BigDecimal(100)).divide(sameSellerWaterList.get(1).getAmount(),2);
-        map.put("sellerComparison",comparison);
+        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));
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -137,10 +127,8 @@ public class AppPageReportController {
         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>=12){
                 sameSellerAmount = sameSellerAmount.add(sellerWaterList.get(i).getAmount());
@@ -149,10 +137,9 @@ public class AppPageReportController {
                 lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
             }
         }
-        BigDecimal comparison = lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? 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);
+        map.put("sellerComparison", lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,2));
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -182,13 +169,56 @@ public class AppPageReportController {
                 lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
             }
         }
-        BigDecimal comparison = lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? 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);
+        map.put("sellerComparison",lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,2));
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
 
+    /**
+     * @Author wangbo
+     * @Description App 营业总览数据-本月应收实收回收率数据
+     * @param companyOrgId 公司ID
+     * @return
+     */
+    @RequestMapping(value = "getBusinessDataForSameMonth",method = RequestMethod.GET)
+    @ApiOperation(value = "App总览——生产数据(本月)")
+    public AjaxMessage<Map<String,Object>> getSameMonthBusinessData(
+            @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
+        Map<String,Object> map = new HashMap<String,Object>();
+        List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,1);
+        map.put("totalReceivable", sellerWaterList.get(0).getAmount());
+        map.put("totalReceived", sellerWaterList.get(0).getAmount2());
+        map.put("amount",sellerWaterList);
+        map.put("rate", sellerWaterList.get(0).getAmount().compareTo(BigDecimal.ZERO)==0? 0 : sellerWaterList.get(0).getAmount2().multiply(new BigDecimal(100)).divide(sellerWaterList.get(0).getAmount(),2));
+        return new AjaxMessage<>(ResultStatus.OK,map);
+    }
+
+    /**
+     * @Author wangbo
+     * @Description App 营业总览数据-本月应收实收回收率数据
+     * @param companyOrgId 公司ID
+     * @return
+     */
+    @RequestMapping(value = "getBusinessDataForSameYear",method = RequestMethod.GET)
+    @ApiOperation(value = "App总览——生产数据(本年)")
+    public AjaxMessage<Map<String,Object>> getBusinessDataForSameYear(
+            @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
+        LocalDate now = LocalDate.now();
+        Map<String,Object> map = new HashMap<String,Object>();
+        List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,now.getMonthValue());
+        BigDecimal totalReceivableAmount = new BigDecimal(0);
+        BigDecimal totalReceivedAmount = new BigDecimal(0);
+        for(DeviceWaterSupply amount: sellerWaterList){
+            totalReceivableAmount.add(amount.getAmount());
+            totalReceivedAmount.add(amount.getAmount2());
+        }
+        map.put("totalReceivable", totalReceivableAmount);
+        map.put("totalReceived",totalReceivedAmount);
+        map.put("amountDetails",sellerWaterList);
+        map.put("rate", sellerWaterList.get(0).getAmount().compareTo(BigDecimal.ZERO)==0? 0 : sellerWaterList.get(0).getAmount2().multiply(new BigDecimal(100)).divide(sellerWaterList.get(0).getAmount(),2));
+        return new AjaxMessage<>(ResultStatus.OK,map);
+    }
 
 }

+ 3 - 0
sms_water/src/main/java/com/huaxu/dto/generalView/DeviceWaterSupply.java

@@ -31,6 +31,9 @@ public class DeviceWaterSupply implements Serializable {
     @ApiModelProperty("量")
     @JsonSerialize(using = BigDecimalJsonSerializer.class)
     private BigDecimal amount = BigDecimal.ZERO;
+    @ApiModelProperty("量2")
+    @JsonSerialize(using = BigDecimalJsonSerializer.class)
+    private BigDecimal amount2 = BigDecimal.ZERO;
     @ApiModelProperty("日期")
     private LocalDate date;
     @ApiModelProperty("日期格式化")

+ 3 - 0
sms_water/src/main/java/com/huaxu/service/AppPageReportService.java

@@ -11,6 +11,9 @@ public interface AppPageReportService {
     //App数据总览-生产数据-前N个月的售水量
     List<DeviceWaterSupply> deviceSellerWaterReportForMonth(Integer companyOrgId,Integer month);
 
+    //App数据总览-营收数据-前N个月的营收金额
+    List<DeviceWaterSupply> deviceSellerAmountReportForMonth(Integer companyOrgId,Integer month);
+
     //App数据总览-生产数据-前N个月的去取水量(水源:4)
     //前N个月的去制水量(水厂:3)
     List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId,String sceneType, Integer parmType,Integer month);

+ 33 - 6
sms_water/src/main/java/com/huaxu/service/impl/AppPageReportServiceImpl.java

@@ -3,7 +3,6 @@ package com.huaxu.service.impl;
 
 import com.huaxu.dao.HomePageReportMapper;
 
-import com.huaxu.dao.RevenueMapper;
 import com.huaxu.dto.MonthRevenueDto;
 import com.huaxu.dto.generalView.DeviceWaterSupply;
 import com.huaxu.model.LoginUser;
@@ -69,7 +68,6 @@ public class AppPageReportServiceImpl implements AppPageReportService {
         return deviceWaterSupplies;
     }
 
-
     /**
      * App 总览 前N个月的取水量、制水量
      * @param companyOrgId
@@ -82,11 +80,8 @@ public class AppPageReportServiceImpl implements AppPageReportService {
         LoginUser loginUser = UserUtil.getCurrentUser();
         String tenantId = loginUser.getTenantId();
         LocalDate localDate = LocalDate.now();
-
         List<DeviceWaterSupply> deviceWaterSupplies = homePageReportMapper.getDeviceWaterForMonth(companyOrgId,sceneType,parmType ,tenantId,loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList(),month);
-
         BigDecimal AmountCountMonth = monitorDataReportService.getAmountCount(companyOrgId,null, sceneType, parmType,2 );
-
         DeviceWaterSupply deviceWaterSupplyMonth = new DeviceWaterSupply();
         deviceWaterSupplyMonth.setOrderNo(1);
         deviceWaterSupplyMonth.setAmount(AmountCountMonth!=null?AmountCountMonth.divide(new BigDecimal("10000")):BigDecimal.ZERO);
@@ -101,7 +96,6 @@ public class AppPageReportServiceImpl implements AppPageReportService {
             if (i == deviceWaterSupplies.size()
                     || newLocalDate.getMonthValue() != deviceWaterSupplies.get(i).getMonth().intValue()
                     || newLocalDate.getYear() != deviceWaterSupplies.get(i).getYear().intValue()) {
-
                 DeviceWaterSupply deviceWaterSupply = new DeviceWaterSupply();
                 deviceWaterSupply.setOrderNo(i + 1);
                 deviceWaterSupply.setAmount(BigDecimal.ZERO);
@@ -188,6 +182,39 @@ public class AppPageReportServiceImpl implements AppPageReportService {
         return comparison;
     }
 
+    /**
+     * App 总览 前N个月的应收实收金额
+     * @param companyOrgId
+     * @return
+     */
+    @Override
+    public List<DeviceWaterSupply> deviceSellerAmountReportForMonth(Integer companyOrgId,Integer month) {
+        LocalDate localDate = LocalDate.now();
+        List<DeviceWaterSupply> deviceWaterSupplies = new ArrayList<DeviceWaterSupply>();
+        List<MonthRevenueDto> sellerWater = revenueService.selectOverviewRevenue(companyOrgId,month);
+        for (int i = 0; i < month; i++) {
+            LocalDate newLocalDate = localDate.plusMonths(-i);
+            MonthRevenueDto revenue = findRevenue(sellerWater,newLocalDate);
+            DeviceWaterSupply deviceWaterSupply = new DeviceWaterSupply();
+            deviceWaterSupply.setOrderNo(i+1);
+            deviceWaterSupply.setYear(newLocalDate.getYear());
+            deviceWaterSupply.setMonth(newLocalDate.getMonthValue());
+            deviceWaterSupply.setDate(newLocalDate);
+            deviceWaterSupply.setDateLabel(newLocalDate.getYear()+"-"+newLocalDate.getMonthValue());
+            if(revenue == null){
+                deviceWaterSupply.setAmount(BigDecimal.ZERO);
+                deviceWaterSupply.setAmount2(BigDecimal.ZERO);
+            }
+            else{
+                deviceWaterSupply.setAmount(new BigDecimal(revenue.getReceivableTotalAmount()));
+                deviceWaterSupply.setAmount2(new BigDecimal(revenue.getReceivedTotalAmount()));
+            }
+            deviceWaterSupplies.add(i, deviceWaterSupply);
+        }
+        deviceWaterSupplies.sort(Comparator.comparing(DeviceWaterSupply::getOrderNo).reversed());
+        return deviceWaterSupplies;
+    }
+
     public MonthRevenueDto findRevenue(List<MonthRevenueDto> sellerWater,LocalDate localDate) {
         String dateString = String.format("%s-%s", localDate.getYear(),new DecimalFormat("#00").format(localDate.getMonthValue()));
         for (MonthRevenueDto revenue : sellerWater) {

+ 9 - 4
sms_water/src/main/resources/mapper/RevenueMapper.xml

@@ -99,7 +99,10 @@
 
     <!--App总览-生产-售水量(本月,本年)-->
     <select id="selectOverviewRevenue" resultType="com.huaxu.dto.MonthRevenueDto">
-        select date_format(t1.collect_date, '%Y-%m' ) collect_date_string,sum(METER_READING_USAGE) meter_reading_usage
+        select date_format(t1.collect_date, '%Y-%m' ) collect_date_string,
+        sum(METER_READING_USAGE) meter_reading_usage,
+        sum(RECEIVABLE_TOTAL_AMOUNT) receivable_total_amount,
+        sum(RECEIVED_TOTAL_AMOUNT) received_total_amount
         from sms_month_revenue t1
         where t1.collect_date>=date_sub(date_format(curdate(), '%y-%m-1' ), interval #{months}-1 month)
         <if test="tenantId != null and tenantId != ''">
@@ -122,9 +125,12 @@
 
     <!--App总览-生产数据-按时间段查询(环比)-->
     <select id="selectRevenueByDate" resultType="com.huaxu.dto.MonthRevenueDto">
-        select date_format(t1.collect_date, '%Y-%m' ) collect_date_string,sum(METER_READING_USAGE) meter_reading_usage
+        select date_format(t1.collect_date, '%Y-%m' ) collect_date_string,
+        sum(METER_READING_USAGE) meter_reading_usage,
+        sum(RECEIVABLE_TOTAL_AMOUNT) receivable_total_amount,
+        sum(RECEIVED_TOTAL_AMOUNT) received_total_amount
         from sms_month_revenue t1
-        where t1.collect_date>=date_format(#{startDate}, '%y-%m-1' ) and t1.collect_date &lt; date_format(#{endDate}, '%y-%m-1')
+        where t1.collect_date>=date_format(#{startDate}, '%y-%m-1' ) and t1.collect_date &lt;= date_format(#{endDate}, '%y-%m-1')
         <if test="tenantId != null and tenantId != ''">
             and t1.tenant_id=#{tenantId}
         </if>
@@ -142,5 +148,4 @@
         group by collect_date_string
         order by collect_date_string
     </select>
-
 </mapper>