wangbo 4 vuotta sitten
vanhempi
commit
b7879e4786

+ 28 - 62
sms_water/src/main/java/com/huaxu/controller/AppPageReportController.java

@@ -41,14 +41,14 @@ public class AppPageReportController {
     @ApiOperation(value = "App总览——生产数据(本月)")
     public AjaxMessage<Map<String,Object>> getProductionDataForMonth(
             @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
-        List<DeviceWaterSupply> supplyWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,1);
+        List<DeviceWaterSupply> intakeWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,1);
         List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,1);
         List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,1);
         Map<String,Object> map = new HashMap<String,Object>();
-        map.put("intake", supplyWaterList);
+        map.put("intake", intakeWaterList);
         map.put("making", makingWaterList);
         map.put("seller", sellerWaterList);
-        appPageReportService.CalculationNrw(supplyWaterList,makingWaterList,sellerWaterList,map);
+        appPageReportService.CalculationNrw(intakeWaterList,makingWaterList,sellerWaterList,map);
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -63,7 +63,6 @@ public class AppPageReportController {
     public AjaxMessage<Map<String,Object>> getProductionDataForSameYear(
             @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
         LocalDate localDate = LocalDate.now();
-
         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());
@@ -102,17 +101,14 @@ public class AppPageReportController {
     @ApiOperation(value = "App总览——生产数据-取水环比(本月)")
     public AjaxMessage<Object> getProductionComparisonForSameMonth(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
         LocalDate now = LocalDate.now();
-        LocalDate last = now.minusMonths(1);
+        List<DeviceWaterSupply> intakeComparisonList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,2);
+        List<DeviceWaterSupply> makingComparisonList =  appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,2);
+        List<DeviceWaterSupply> sellerComparisonList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,2);
 
-        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<String,Object> map = new HashMap<String,Object>();
-        map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
-        map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
-        List<DeviceWaterSupply> sameSellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,2);
-        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(),3));
+        map.put("intakeComparison",appPageReportService.CalculationComparison2(intakeComparisonList,1));
+        map.put("makingComparison",appPageReportService.CalculationComparison2(makingComparisonList,1));
+        map.put("sellerComparison", appPageReportService.CalculationComparison2(sellerComparisonList,1));
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -120,27 +116,14 @@ public class AppPageReportController {
     @ApiOperation(value = "App总览——生产数据-取水环比、供水环比、售水环比(本年)")
     public AjaxMessage<Object> getProductionComparisonForSameYear(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
         LocalDate now = LocalDate.now();
-        LocalDate last = now.minusYears(1);
-
-        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>=12){
-                sameSellerAmount = sameSellerAmount.add(sellerWaterList.get(i).getAmount());
-            }
-            else{
-                lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
-            }
-        }
+        List<DeviceWaterSupply> intakeComparisonList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,now.getMonthValue()+12);
+        List<DeviceWaterSupply> makingComparisonList =  appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,now.getMonthValue()+12);
+        List<DeviceWaterSupply> sellerComparisonList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,now.getMonthValue()+12);
+
         Map<String,Object> map = new HashMap<String,Object>();
-        map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
-        map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
-        map.put("sellerComparison", lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,3));
+        map.put("intakeComparison",appPageReportService.CalculationComparison2(intakeComparisonList,2));
+        map.put("makingComparison",appPageReportService.CalculationComparison2(makingComparisonList,2));
+        map.put("sellerComparison", appPageReportService.CalculationComparison2(sellerComparisonList,2));
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -148,33 +131,16 @@ public class AppPageReportController {
     @ApiOperation(value = "App总览——生产数据-取水环比、供水环比、售水环比(近一年)")
     public AjaxMessage<Object> getProductionComparisonForLast12Month(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
         LocalDate now = LocalDate.now();
-        LocalDate last = now.minusMonths(11);
-
 
-        List<DeviceWaterSupply> sameMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last.getYear(),last.getMonthValue(),last.getDayOfMonth(), now.getYear(),now.getMonthValue(),now.getDayOfMonth());
-        List<DeviceWaterSupply> sameSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),last.getMonthValue(),last.getDayOfMonth(),now.getYear(),now.getMonthValue(),now.getDayOfMonth());
-        LocalDate last2 = last.minusDays(1);
-        LocalDate last3 = last2.minusMonths(11);
-        List<DeviceWaterSupply> lastMakingWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, last3.getYear(),last2.getMonthValue(),last2.getDayOfMonth(), last.getYear(),12,31);
-        List<DeviceWaterSupply> lastSupplyWaterList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, last.getYear(),1,1, last.getYear(),12,31);
 
-        List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,24);
+        List<DeviceWaterSupply> intakeComparisonList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,24);
+        List<DeviceWaterSupply> makingComparisonList =  appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,24);
+        List<DeviceWaterSupply> sellerComparisonList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,24);
 
-        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());
-            }
-            else{
-                lastSellerAmount = lastSellerAmount.add(sellerWaterList.get(i).getAmount());
-            }
-        }
         Map<String,Object> map = new HashMap<String,Object>();
-        map.put("intakeComparison",appPageReportService.CalculationComparison(sameMakingWaterList,lastMakingWaterList));
-        map.put("makingComparison",appPageReportService.CalculationComparison(sameSupplyWaterList,lastSupplyWaterList));
-        map.put("sellerComparison",lastSellerAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameSellerAmount.multiply(new BigDecimal(100)).divide(lastSellerAmount,3));
+        map.put("intakeComparison",appPageReportService.CalculationComparison2(intakeComparisonList,3));
+        map.put("makingComparison",appPageReportService.CalculationComparison2(makingComparisonList,3));
+        map.put("sellerComparison", appPageReportService.CalculationComparison2(sellerComparisonList,3));
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
 
@@ -308,8 +274,8 @@ public class AppPageReportController {
     public AjaxMessage<Object> getSellerComparisonForSameMonth(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
 
         List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerAmountReportForMonth(companyOrgId,2);
-        BigDecimal receivableComparison = sellerWaterList.get(1).getReceivableAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivableAmount().multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivableAmount(),3);
-        BigDecimal receivedComparison = sellerWaterList.get(1).getReceivedAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivedAmount().multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivedAmount(),3);
+        BigDecimal receivableComparison = sellerWaterList.get(1).getReceivableAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivableAmount().subtract(sellerWaterList.get(1).getReceivableAmount()).multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivableAmount(),3);
+        BigDecimal receivedComparison = sellerWaterList.get(1).getReceivedAmount().compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:sellerWaterList.get(0).getReceivedAmount().subtract(sellerWaterList.get(1).getReceivedAmount()).multiply(new BigDecimal(100)).divide(sellerWaterList.get(1).getReceivedAmount(),3);
         Map<String,Object> map = new HashMap<String,Object>();
         map.put("receivableComparison",receivableComparison);
         map.put("receivedComparison",receivedComparison);
@@ -337,8 +303,8 @@ public class AppPageReportController {
             }
         }
 
-        BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.multiply(new BigDecimal(100)).divide(receivedLastYearComparison,3);
-        BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.multiply(new BigDecimal(100)).divide(receivableLastYearComparison,3);
+        BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.subtract(receivedLastYearComparison).multiply(new BigDecimal(100)).divide(receivedLastYearComparison,3);
+        BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.subtract(receivableLastYearComparison).multiply(new BigDecimal(100)).divide(receivableLastYearComparison,3);
         Map<String,Object> map = new HashMap<String,Object>();
         map.put("receivableComparison",receivableComparison);
         map.put("receivedComparison",receivedComparison);
@@ -365,8 +331,8 @@ public class AppPageReportController {
                 receivableLastYearComparison =receivableLastYearComparison.add(sellerWaterList.get(i).getReceivableAmount());
             }
         }
-        BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.multiply(new BigDecimal(100)).divide(receivedLastYearComparison,3);
-        BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.multiply(new BigDecimal(100)).divide(receivableLastYearComparison,3);
+        BigDecimal receivedComparison = receivedLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivedSameYearComparison.subtract(receivedLastYearComparison).multiply(new BigDecimal(100)).divide(receivedLastYearComparison,3);
+        BigDecimal receivableComparison = receivableLastYearComparison.compareTo(BigDecimal.ZERO)==0 ?BigDecimal.ZERO:receivableSameYearComparison.subtract(receivableLastYearComparison).multiply(new BigDecimal(100)).divide(receivableLastYearComparison,3);
         Map<String,Object> map = new HashMap<String,Object>();
         map.put("receivableComparison",receivableComparison);
         map.put("receivedComparison",receivedComparison);

+ 0 - 5
sms_water/src/main/java/com/huaxu/dao/AppReportMonitorMapper.java

@@ -36,9 +36,4 @@ public interface AppReportMonitorMapper {
                                              @Param("permissonType")Integer permissonType,
                                              @Param("programItems")List<ProgramItem> programItems);
 
-
-
-
-
-
 }

+ 10 - 0
sms_water/src/main/java/com/huaxu/dao/HomePageReportMapper.java

@@ -48,6 +48,16 @@ public interface HomePageReportMapper {
                                                  @Param("endMonth")Integer endMonth,
                                                  @Param("endDay")Integer endDay);
 
+    List<DeviceWaterSupply> getDeviceWaterForMonth(@Param("companyOrgId")Integer companyOrgId,
+                                                 @Param("sceneType")String sceneType, @Param("parmType")Integer parmType,
+                                                 @Param("tenantId")String tenantId, @Param("userType")String userType,
+                                                 @Param("permissonType")Integer permissonType,
+                                                 @Param("programItems")List<ProgramItem> programItems,
+                                                 @Param("startYear")Integer startYear,
+                                                 @Param("startMonth")Integer startMonth,
+                                                 @Param("endYear")Integer endYear,
+                                                 @Param("endMonth")Integer endMonth);
+
     CompanyCount countSceneByType(@Param("companyOrgId")Integer companyOrgId,
                                         @Param("tenantId")String tenantId, @Param("userType")String userType,
                                         @Param("permissonType")Integer permissonType,

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

@@ -21,10 +21,12 @@ public interface AppPageReportService {
     List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId,String sceneType, Integer parmType,Integer month);
 
     //App数据总览-生产数据-环比-查询时间段内的取水量供水量
-    List<DeviceWaterSupply> deviceWaterReportForDay(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer startDay, Integer endYear, Integer endMonth, Integer endDay) ;
+    List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer endYear, Integer endMonth);
 
     BigDecimal CalculationComparison(List<DeviceWaterSupply> sameWaterList, List<DeviceWaterSupply> lastWaterList);
 
+    BigDecimal CalculationComparison2(List<DeviceWaterSupply> comparisonList, int type);
+
     List<Map<String,Object>> findSceneAmount(Long companyOrgId,Integer months);
 
     void CalculationNrw(List<DeviceWaterSupply> supplyWaterList, List<DeviceWaterSupply> makingWaterList,List<DeviceWaterSupply> sellerWaterList,Map<String,Object> map);

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

@@ -121,20 +121,18 @@ public class AppPageReportServiceImpl implements AppPageReportService {
     }
 
     @Override
-    public List<DeviceWaterSupply> deviceWaterReportForDay(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer startDay, Integer endYear, Integer endMonth, Integer endDay) {
+    public List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer endYear, Integer endMonth) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         String tenantId = loginUser.getTenantId();
-        List<DeviceWaterSupply> deviceWaterSupplyList = homePageReportMapper.getDeviceWaterForDay(companyOrgId,
+        List<DeviceWaterSupply> deviceWaterSupplyList = homePageReportMapper.getDeviceWaterForMonth(companyOrgId,
                 sceneType,parmType ,
                 tenantId,loginUser.getType(),
                 loginUser.getPermissonType(),
                 loginUser.getProgramItemList(),
                 startYear,
                 startMonth,
-                startDay,
                 endYear,
-                endMonth,
-                endDay);
+                endMonth);
         return deviceWaterSupplyList;
     }
 
@@ -183,7 +181,36 @@ public class AppPageReportServiceImpl implements AppPageReportService {
         for(DeviceWaterSupply water : lastWaterList){
             lastWaterAmount = lastWaterAmount.add(water.getAmount());
         }
-        BigDecimal comparison = lastWaterAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameWaterAmount.multiply(new BigDecimal(100)).divide(lastWaterAmount,2);
+        BigDecimal comparison = lastWaterAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameWaterAmount.subtract(lastWaterAmount).multiply(new BigDecimal(100)).divide(lastWaterAmount,2);
+        return comparison;
+    }
+
+    public BigDecimal CalculationComparison2(List<DeviceWaterSupply> comparisonList, int type){
+
+        BigDecimal sameWaterAmount = new BigDecimal(0);
+        BigDecimal lastWaterAmount = new BigDecimal(0);
+        for(int i =0; i<comparisonList.size(); i++){
+            if(type == 1){
+                if(i==0){
+                    lastWaterAmount = lastWaterAmount.add(comparisonList.get(0).getAmount());
+                }
+                else {
+                    sameWaterAmount = sameWaterAmount.add(comparisonList.get(1).getAmount());
+                }
+            }
+            else if(type == 2 || type ==3) {
+
+                if(i>=12){
+                    sameWaterAmount = sameWaterAmount.add(comparisonList.get(i).getAmount());
+                }
+                else{
+                    lastWaterAmount = lastWaterAmount.add(comparisonList.get(i).getAmount());
+                }
+            }
+        }
+
+
+        BigDecimal comparison = lastWaterAmount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : sameWaterAmount.subtract(lastWaterAmount).multiply(new BigDecimal(100)).divide(lastWaterAmount,2);
         return comparison;
     }
 
@@ -224,10 +251,14 @@ public class AppPageReportServiceImpl implements AppPageReportService {
             if(revenue == null){
                 deviceWaterSupply.setReceivableAmount(BigDecimal.ZERO);
                 deviceWaterSupply.setReceivedAmount(BigDecimal.ZERO);
+                deviceWaterSupply.setGeneralUserAmount(BigDecimal.ZERO);
+                deviceWaterSupply.setBigUserAmount(BigDecimal.ZERO);
             }
             else{
                 deviceWaterSupply.setReceivableAmount(new BigDecimal(revenue.getReceivableTotalAmount()));
                 deviceWaterSupply.setReceivedAmount(new BigDecimal(revenue.getReceivedTotalAmount()));
+                deviceWaterSupply.setGeneralUserAmount(new BigDecimal(revenue.getGeneralUserUsage()));
+                deviceWaterSupply.setBigUserAmount(new BigDecimal(revenue.getBigUserUsage()));
             }
             deviceWaterSupplies.add(i, deviceWaterSupply);
         }

+ 5 - 5
sms_water/src/main/resources/mapper/HomePageReportMapper.xml

@@ -481,22 +481,22 @@
     </select>
 
 
-    <!--查询时间段内的取水量供水量(精确到天)-->
-    <select id="getDeviceWaterForDay" resultType="com.huaxu.dto.generalView.DeviceWaterSupply">
+    <!--查询时间段内的取水量供水量-->
+    <select id="getDeviceWaterForMonth" resultType="com.huaxu.dto.generalView.DeviceWaterSupply">
         select
         r.year,r.month,r.day,
         sum(r.SUM_VALUE)/10000 as "amount"
         from sms_scene_type st
         left join sms_scene s on s.SCENE_TYPE_ID =st.id
         left join sms_device_parm dp on s.id=dp.PARENT_SCENE_ID
-        left join sms_month_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
+        left join sms_year_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
         where  dp.`STATUS`=1  and s.ENABLE_STATE = 1 and dp.TENANT_ID=#{tenantId}
         <if test="companyOrgId != null">
             and s.COMPANY_ORG_ID = #{companyOrgId}
         </if>
         and dp.PARM_TYPE = #{parmType} and st.SCENE_TYPE_NAME = #{sceneType}
-        and r.year*365 + r.month*30 +r.day >= #{startYear}*365 + #{startMonth} *30 + #{startDay}
-        and r.year*365 + r.month*30 +r.day &lt;= #{endYear}*365 + #{endMonth} *30 + #{endDay}
+        and r.year*12 + r.month >= #{startYear}*12 + #{startMonth}
+        and r.year*12 + r.month &lt;= #{endYear}*12 + #{endMonth}
         <if test="userType!=null and userType!=-999 and userType!=-9999 and  programItems != null and programItems.size() > 0">
             <if test="permissonType == 5 or permissonType == 2">
                 and ( s.DEPT_ORG_ID in