wangbo 3 years ago
parent
commit
ffa9ce1359

+ 13 - 0
sms_water/src/main/java/com/huaxu/controller/AppPageReportController.java

@@ -41,13 +41,18 @@ public class AppPageReportController {
     @ApiOperation(value = "App总览——生产数据(本月)")
     public AjaxMessage<Map<String,Object>> getProductionDataForMonth(
             @ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Integer companyOrgId){
+        LocalDate localDate = LocalDate.now();
         List<DeviceWaterSupply> intakeWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水源",4,1);
         List<DeviceWaterSupply> makingWaterList = appPageReportService.deviceWaterReportForMonth(companyOrgId,"水厂",3,1);
         List<DeviceWaterSupply> sellerWaterList = appPageReportService.deviceSellerWaterReportForMonth(companyOrgId,1);
+        List<DeviceWaterSupply> intakeDayList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水源",4, localDate.getDayOfMonth());
+        List<DeviceWaterSupply> makingDayList = appPageReportService.deviceWaterReportForDay(companyOrgId,"水厂",3, localDate.getDayOfMonth());
         Map<String,Object> map = new HashMap<String,Object>();
         map.put("intake", intakeWaterList);
         map.put("making", makingWaterList);
         map.put("seller", sellerWaterList);
+        map.put("intakeDetail",intakeDayList);
+        map.put("makingkeDetail",makingDayList);
         appPageReportService.CalculationNrw(intakeWaterList,makingWaterList,sellerWaterList,map);
         return new AjaxMessage<>(ResultStatus.OK,map);
     }
@@ -367,6 +372,9 @@ public class AppPageReportController {
     public AjaxMessage<Object> getSceneAmountForSameMonth(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Long companyOrgId){
         Map<String,Object> map = new HashMap<String,Object>();
         List<Map<String,Object>> amount = appPageReportService.findSceneAmount(companyOrgId,1);
+        map.put("bigmeter","-");
+        map.put("generalmeter","-");
+        amount.add(map);
         return new AjaxMessage<>(ResultStatus.OK,amount);
     }
 
@@ -376,13 +384,18 @@ public class AppPageReportController {
         Map<String,Object> map = new HashMap<String,Object>();
         LocalDate now = LocalDate.now();
         List<Map<String,Object>> amount = appPageReportService.findSceneAmount(companyOrgId,now.getMonthValue());
+        map.put("bigmeter","-");
+        map.put("generalmeter","-");
         return new AjaxMessage<>(ResultStatus.OK,amount);
     }
 
     @RequestMapping(value = "getSceneAmountForLast12Month",method = RequestMethod.GET)
     @ApiOperation(value = "App总览——资产情况近一年")
     public AjaxMessage<Object> getSceneAmountForLast12Month(@ApiParam(value = "公司id,总公司传空值") @RequestParam(required = false) Long companyOrgId){
+        Map<String,Object> map = new HashMap<String,Object>();
         List<Map<String,Object>> amount = appPageReportService.findSceneAmount(companyOrgId,12);
+        map.put("bigmeter","-");
+        map.put("generalmeter","-");
         return new AjaxMessage<>(ResultStatus.OK,amount);
     }
 }

+ 11 - 16
sms_water/src/main/java/com/huaxu/dao/HomePageReportMapper.java

@@ -41,22 +41,17 @@ public interface HomePageReportMapper {
                                                  @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("startDay")Integer startDay,
-                                                 @Param("endYear")Integer endYear,
-                                                 @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);
+                                                 @Param("day")Integer day);
+
+//    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,

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

@@ -20,8 +20,7 @@ public interface AppPageReportService {
     //前N个月的去制水量(水厂:3)
     List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId,String sceneType, Integer parmType,Integer month);
 
-    //App数据总览-生产数据-环比-查询时间段内的取水量供水量
-    List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer endYear, Integer endMonth);
+    List<DeviceWaterSupply> deviceWaterReportForDay(Integer companyOrgId,String sceneType, Integer parmType,Integer day);
 
     BigDecimal CalculationComparison(List<DeviceWaterSupply> sameWaterList, List<DeviceWaterSupply> lastWaterList);
 

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

@@ -121,19 +121,45 @@ public class AppPageReportServiceImpl implements AppPageReportService {
     }
 
     @Override
-    public List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer endYear, Integer endMonth) {
+    public List<DeviceWaterSupply> deviceWaterReportForDay(Integer companyOrgId, String sceneType, Integer parmType, Integer day) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         String tenantId = loginUser.getTenantId();
-        List<DeviceWaterSupply> deviceWaterSupplyList = homePageReportMapper.getDeviceWaterForMonth(companyOrgId,
-                sceneType,parmType ,
-                tenantId,loginUser.getType(),
-                loginUser.getPermissonType(),
-                loginUser.getProgramItemList(),
-                startYear,
-                startMonth,
-                endYear,
-                endMonth);
-        return deviceWaterSupplyList;
+        LocalDate localDate = LocalDate.now();
+        List<DeviceWaterSupply> deviceWaterSupplies = homePageReportMapper.getDeviceWaterForDay(companyOrgId,sceneType,parmType ,tenantId,loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList(),day);
+        BigDecimal AmountCountMonth = monitorDataReportService.getAmountCount(companyOrgId,null, sceneType, parmType,1);
+        DeviceWaterSupply deviceWaterSupplyDay = new DeviceWaterSupply();
+        deviceWaterSupplyDay.setOrderNo(1);
+        deviceWaterSupplyDay.setAmount(AmountCountMonth!=null?AmountCountMonth.divide(new BigDecimal("10000")):BigDecimal.ZERO);
+        deviceWaterSupplyDay.setYear(localDate.getYear());
+        deviceWaterSupplyDay.setMonth(localDate.getMonthValue());
+        deviceWaterSupplyDay.setDay(localDate.getDayOfMonth());
+        deviceWaterSupplyDay.setDate(localDate);
+        deviceWaterSupplyDay.setDateLabel(localDate.getYear()+"-"+localDate.getMonthValue()+"-"+localDate.getDayOfMonth());
+        deviceWaterSupplies.add(0, deviceWaterSupplyDay);
+        for (int i = 1; i < day; i++) {
+            LocalDate newLocalDate = localDate.plusDays(-i );
+            if (i == deviceWaterSupplies.size()
+                    || newLocalDate.getDayOfMonth() != deviceWaterSupplies.get(i).getDay().intValue()
+                    || 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);
+                deviceWaterSupply.setYear(newLocalDate.getYear());
+                deviceWaterSupply.setMonth(newLocalDate.getMonthValue());
+                deviceWaterSupply.setDay(newLocalDate.getDayOfMonth());
+                deviceWaterSupply.setDate(newLocalDate);
+                deviceWaterSupply.setDateLabel(newLocalDate.getYear()+"-"+newLocalDate.getMonthValue());
+                deviceWaterSupplies.add(i, deviceWaterSupply);
+            } else {
+                deviceWaterSupplies.get(i).setOrderNo(i + 1);
+                deviceWaterSupplies.get(i).setDate(newLocalDate);
+                deviceWaterSupplies.get(i).setDateLabel(newLocalDate.getYear()+"-"+newLocalDate.getMonthValue());
+            }
+        }
+        deviceWaterSupplies.sort(Comparator.comparing(DeviceWaterSupply::getOrderNo).reversed());
+
+        return deviceWaterSupplies;
     }
 
     /**

+ 55 - 13
sms_water/src/main/resources/mapper/HomePageReportMapper.xml

@@ -441,14 +441,13 @@
         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_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*12 + r.month >=  year(CURDATE())*12 + month(CURDATE()) + 1 - #{month}
         and r.year*12 + r.month &lt; year(CURDATE())*12 + month(CURDATE()) + 1
+        <if test="companyOrgId != null">
+            and s.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">
                 and ( s.DEPT_ORG_ID in
@@ -481,22 +480,67 @@
     </select>
 
 
-    <!--查询时间段内的取水量供水量-->
-    <select id="getDeviceWaterForMonth" 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_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}-->
+<!--        and dp.PARM_TYPE = #{parmType} and st.SCENE_TYPE_NAME = #{sceneType}-->
+<!--        and r.year*12 + r.month >= #{startYear}*12 + #{startMonth}-->
+<!--        and r.year*12 + r.month &lt;= #{endYear}*12 + #{endMonth}-->
+<!--        <if test="companyOrgId != null">-->
+<!--            and s.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">-->
+<!--                and ( s.DEPT_ORG_ID in-->
+<!--                <foreach collection="programItems" item="item" open="(" close=")" separator=",">-->
+<!--                    #{item.orgId}-->
+<!--                </foreach>-->
+<!--                or-->
+<!--                s.COMPANY_ORG_ID in-->
+<!--                <foreach collection="programItems" item="item" open="(" close=")" separator=",">-->
+<!--                    #{item.orgId}-->
+<!--                </foreach>-->
+<!--                )-->
+<!--            </if>-->
+<!--            <if test="permissonType == 4 or permissonType == 3">-->
+<!--                and s.DEPT_ORG_ID in-->
+<!--                <foreach collection="programItems" item="item" open="(" close=")" separator=",">-->
+<!--                    #{item.orgId}-->
+<!--                </foreach>-->
+<!--            </if>-->
+<!--            <if test="permissonType == 1">-->
+<!--                and s.COMPANY_ORG_ID in-->
+<!--                <foreach collection="programItems" item="item" open="(" close=")" separator=",">-->
+<!--                    #{item.orgId}-->
+<!--                </foreach>-->
+<!--                and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)-->
+<!--            </if>-->
+<!--        </if>-->
+<!--        group by r.year,r.month,r.day-->
+<!--        order by r.year desc,r.month desc,r.day desc-->
+<!--    </select>-->
+
+    <select id="getDeviceWaterForDay" 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_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}
+        left join sms_month_report r on r.DEVICE_ID= dp.DEVICE_ID and r.ATTRIBUTE_ID = dp.ATTRIBUTE_ID
+        where  st.`STATUS`=1 and dp.`STATUS`=1  and s.ENABLE_STATE = 1 and dp.TENANT_ID=#{tenantId}
+        and r.COLLECT_DATE >= DATE_SUB(CURDATE(),INTERVAL #{day}-1 day)
+        and dp.PARM_TYPE = #{parmType} and st.SCENE_TYPE_NAME = #{sceneType}
         <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*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
@@ -527,6 +571,4 @@
         group by r.year,r.month,r.day
         order by r.year desc,r.month desc,r.day desc
     </select>
-
-
 </mapper>