wangbo 4 лет назад
Родитель
Сommit
6c2bbbaa48

+ 90 - 63
sms_water/src/main/java/com/huaxu/controller/AppPageReportController.java

@@ -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);
     }
 
 

+ 3 - 0
sms_water/src/main/java/com/huaxu/dao/RevenueMapper.java

@@ -46,4 +46,7 @@ public interface RevenueMapper {
      */
     List<MonthRevenueDto> selectOverviewRevenue(MonthRevenueDto monthRevenueDto);
 
+
+    List<MonthRevenueDto> selectRevenueByDate(MonthRevenueDto monthRevenueDto);
+
 }

+ 6 - 0
sms_water/src/main/java/com/huaxu/dto/MonthRevenueDto.java

@@ -44,6 +44,12 @@ public class MonthRevenueDto extends MonthRevenueEntity {
     @JsonIgnore
     private Integer months;
 
+    @ApiModelProperty(value="起始日期",hidden = true)
+    private String startDate;
+
+    @ApiModelProperty(value="截至日期",hidden = true)
+    private String endDate;
+
     @ApiModelProperty(value ="权限",hidden = true)
     @JsonIgnore
     private List<ProgramItem> programItems;

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

@@ -1,8 +1,12 @@
 package com.huaxu.service;
 
+import com.huaxu.dto.MonthRevenueDto;
 import com.huaxu.dto.generalView.DeviceWaterSupply;
 
+import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.util.List;
+import java.util.Map;
 
 public interface AppPageReportService {
 
@@ -16,4 +20,10 @@ public interface AppPageReportService {
     //App数据总览-生产数据-环比-查询时间段内的取水量供水量
     List<DeviceWaterSupply> deviceWaterReportForDay(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer startDay, Integer endYear, Integer endMonth, Integer endDay) ;
 
+    //App数据总览-生产数据-环比
+    //Map<String,Object> getComparison(Integer companyOrgId, LocalDate now, LocalDate last);
+
+    BigDecimal CalculationComparison(List<DeviceWaterSupply> sameWaterList, List<DeviceWaterSupply> lastWaterList);
+
+    void CalculationNrw(List<DeviceWaterSupply> supplyWaterList, List<DeviceWaterSupply> makingWaterList,List<DeviceWaterSupply> sellerWaterList,Map<String,Object> map);
 }

+ 4 - 3
sms_water/src/main/java/com/huaxu/service/RevenueService.java

@@ -38,9 +38,10 @@ public interface RevenueService {
     List<MonthRevenueDto> selectCompanyRevenue();
 
 
-    /**
-     * 查询App总览售水数据
-     */
+    //查询App总览售水数据
     List<MonthRevenueDto> selectOverviewRevenue(Integer companyOrgId,Integer months);
 
+    //查询App总览售水环比
+    List<MonthRevenueDto> selectRevenueByDate(Integer companyOrgId, String startDate, String endDate);
+
 }

+ 76 - 9
sms_water/src/main/java/com/huaxu/service/impl/AppPageReportServiceImpl.java

@@ -1,13 +1,13 @@
 package com.huaxu.service.impl;
 
-import com.huaxu.client.UserCenterClient;
+
 import com.huaxu.dao.HomePageReportMapper;
-import com.huaxu.dao.MonitorDataReportMapper;
+
+import com.huaxu.dao.RevenueMapper;
 import com.huaxu.dto.MonthRevenueDto;
 import com.huaxu.dto.generalView.DeviceWaterSupply;
 import com.huaxu.model.LoginUser;
 import com.huaxu.service.AppPageReportService;
-import com.huaxu.service.HomePageReportService;
 import com.huaxu.service.MonitorDataReportService;
 import com.huaxu.service.RevenueService;
 import com.huaxu.util.UserUtil;
@@ -18,9 +18,7 @@ import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
+import java.util.*;
 
 
 /**
@@ -40,6 +38,8 @@ public class AppPageReportServiceImpl implements AppPageReportService {
     @Resource
     private HomePageReportMapper homePageReportMapper;
 
+//    @Resource
+//    private RevenueMapper revenueMapper;
 
     /**
      * App 总览 前N个月的售水量
@@ -122,10 +122,8 @@ public class AppPageReportServiceImpl implements AppPageReportService {
         deviceWaterSupplies.sort(Comparator.comparing(DeviceWaterSupply::getOrderNo).reversed());
 
         return deviceWaterSupplies;
-
     }
 
-
     @Override
     public List<DeviceWaterSupply> deviceWaterReportForDay(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer startDay, Integer endYear, Integer endMonth, Integer endDay) {
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -144,7 +142,76 @@ public class AppPageReportServiceImpl implements AppPageReportService {
         return deviceWaterSupplyList;
     }
 
-    private MonthRevenueDto findRevenue(List<MonthRevenueDto> sellerWater,LocalDate localDate) {
+//    @Override
+//    public Map<String, Object> getComparison(Integer companyOrgId,LocalDate now, LocalDate last) {
+//
+//        Map<String,Object> map = new HashMap<>();
+//        List<DeviceWaterSupply> sameMakingWaterList = deviceWaterReportForDay(companyOrgId,"水源",4, now.getYear(),now.getMonthValue(),1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
+//
+//        List<DeviceWaterSupply> lastMakingWaterList = deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),last.getMonthValue(),1, last.getYear(),last.getMonthValue(),last.getDayOfMonth());
+//
+//        List<DeviceWaterSupply> sameSupplyWaterList = deviceWaterReportForDay(companyOrgId,"水厂",3, now.getYear(),now.getMonthValue(),1, now.getYear(),now.getMonthValue(),now.getDayOfMonth());
+//
+//        List<DeviceWaterSupply> lastSupplyWaterList = deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),last.getMonthValue(),1, last.getYear(),last.getMonthValue(),last.getDayOfMonth());
+//
+//        map.put("intakeComparison",CalculationComparison(sameMakingWaterList,lastMakingWaterList));
+//
+//        map.put("makingComparison",CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
+//
+//
+//        return map;
+//    }
+
+    /**
+     * @Author wangbo
+     * @Description 计算产销差
+     * @param makingWaterList 制水量数据
+     * @param sellerWaterList 售水量数据
+     * @param map
+     * @return
+     */
+    public 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);
+
+        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("totalIntake",supplyWaterAmount);
+        map.put("totalMaking",makingWaterAmount);
+        map.put("totallSeller",sellerWaterAmount);
+        map.put("nrw",nrw);
+    }
+
+    /**
+     * @Author wangbo
+     * @Description 计算环比
+     * @param sameWaterList 本月数据
+     * @param lastWaterList 上月数据
+     * @return
+     */
+    public 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());
+        }
+        for(DeviceWaterSupply water : lastWaterList){
+            lastWaterAmount = lastWaterAmount.add(water.getAmount());
+        }
+        BigDecimal comparison = lastWaterAmount ==BigDecimal.ZERO ? BigDecimal.ZERO : sameWaterAmount.multiply(new BigDecimal(100)).divide(lastWaterAmount,2);
+        return comparison;
+    }
+
+    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) {
             if (revenue.getCollectDateString().equals(dateString)) {

+ 36 - 0
sms_water/src/main/java/com/huaxu/service/impl/RevenueServiceImpl.java

@@ -130,6 +130,15 @@ public class RevenueServiceImpl implements RevenueService {
         return revenueMapper.selectCompanyRevenue(monthRevenueDto);
     }
 
+
+    /**
+     * wangbo
+     * 查询前N个月的售水数据
+     * @param companyOrgId
+     * @param months
+     * @return
+     */
+
     @Override
     public List<MonthRevenueDto> selectOverviewRevenue(Integer companyOrgId,Integer months) {
 
@@ -145,4 +154,31 @@ public class RevenueServiceImpl implements RevenueService {
         monthRevenueDto.setPermissonType(loginUser.getPermissonType());
         return revenueMapper.selectOverviewRevenue(monthRevenueDto);
     }
+
+    /**
+     * wangbo
+     * 查询售水信息-按时间段
+     * @param companyOrgId
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @Override
+    public List<MonthRevenueDto> selectRevenueByDate(Integer companyOrgId,String startDate,String endDate) {
+
+        MonthRevenueDto monthRevenueDto=new MonthRevenueDto();
+        monthRevenueDto.setCompanyOrgId(companyOrgId);
+        monthRevenueDto.setStartDate(startDate);
+        monthRevenueDto.setEndDate(endDate);
+
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        monthRevenueDto.setTenantId(loginUser.getTenantId());
+        monthRevenueDto.setProgramItems(loginUser.getProgramItemList());
+        monthRevenueDto.setUserType(loginUser.getType());
+        //1是公司,2是公司及以下,3部门,4部门及以下,5自定义
+        monthRevenueDto.setPermissonType(loginUser.getPermissonType());
+        return revenueMapper.selectRevenueByDate(monthRevenueDto);
+    }
+
+
 }

+ 23 - 0
sms_water/src/main/resources/mapper/RevenueMapper.xml

@@ -120,4 +120,27 @@
         order by collect_date_string
     </select>
 
+    <!--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
+        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')
+        <if test="tenantId != null and tenantId != ''">
+            and t1.tenant_id=#{tenantId}
+        </if>
+        <if test="companyOrgId != null and companyOrgId !=''">
+            and t1.company_org_id=#{companyOrgId}
+        </if>
+        <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0">
+            <if test="permissonType == 5 or permissonType == 2 or permissonType == 1">
+                and t1.company_org_id in
+                <foreach collection="programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+            </if>
+        </if>
+        group by collect_date_string
+        order by collect_date_string
+    </select>
+
 </mapper>