|  |  | 
 |  |  | package com.dy.pipIrrStatistics.intake; | 
 |  |  |  | 
 |  |  | import com.dy.common.util.DateTime; | 
 |  |  | import com.dy.common.webUtil.QueryResultVo; | 
 |  |  | import com.dy.pipIrrGlobal.daoRm.RmOnHourReportHistoryMapper; | 
 |  |  | import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper; | 
 |  |  | import com.dy.pipIrrGlobal.daoRm.RmOnHourReportLastMapper; | 
 |  |  | import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveLastMapper; | 
 |  |  | import com.dy.pipIrrGlobal.daoRm.*; | 
 |  |  | import com.dy.pipIrrGlobal.voSt.*; | 
 |  |  | import com.dy.pipIrrStatistics.intake.qo.*; | 
 |  |  | import com.dy.pipIrrGlobal.voSt.VoBatteryVolt; | 
 |  |  | import com.dy.pipIrrGlobal.voSt.VoCumulativeFlow; | 
 |  |  | import com.dy.pipIrrGlobal.voSt.VoIntake; | 
 |  |  | import com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount; | 
 |  |  | import com.dy.pipIrrGlobal.voSt.VoSignalIntensity; | 
 |  |  | import com.dy.pipIrrStatistics.intake.qo.BatteryVoltQO; | 
 |  |  | import com.dy.pipIrrStatistics.intake.qo.CumulativeFlowQO; | 
 |  |  | import com.dy.pipIrrStatistics.intake.qo.IntakeCountValueQO; | 
 |  |  | import com.dy.pipIrrStatistics.intake.qo.CommonQO; | 
 |  |  | import com.dy.pipIrrStatistics.intake.qo.SignalIntensityQO; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.apache.dubbo.common.utils.PojoUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  |  | 
 |  |  | import java.text.DecimalFormat; | 
 |  |  | import java.text.ParseException; | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.time.LocalDate; | 
 |  |  | import java.time.LocalDateTime; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  | import java.util.Optional; | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @author ZhuBaoMin | 
 |  |  | 
 |  |  |     private RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private RmOnHourReportLastMapper rmOnHourReportLastMapper; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper; | 
 |  |  |  | 
 |  |  |     @Value("${rtu.batteryVolt}") | 
 |  |  |     private Double batteryVolt; | 
 |  |  |     @Autowired | 
 |  |  |     private RmIntakeAmountDayMapper rmIntakeAmountDayMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private RmLossDayLastMapper rmLossDayLastMapper; | 
 |  |  |  | 
 |  |  |     @Value("${rtu.signalIntensity.weak}") | 
 |  |  |     private Integer weak; | 
 |  |  | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoIntake>> getNotOnlineIntakes(CommonQO qo) { | 
 |  |  |         DecimalFormat df = new DecimalFormat("0.00"); | 
 |  |  |         /** | 
 |  |  |          * 补齐起止时间,如果开始时间为空,则默认为当前日期 | 
 |  |  |          */ | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null) { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         }else { | 
 |  |  |             timeStart = LocalDate.now() + " 00:00:00"; | 
 |  |  |         } | 
 |  |  |         if(timeStop != null) { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |  | 
 |  |  |         // 生成查询参数 | 
 |  |  |     public QueryResultVo<List<VoIntake>> getNotOnlineIntakes(CommonQO qo, Long idStart, Long idEnd) { | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |         params.put("idStart", idStart) ; | 
 |  |  |         params.put("idEnd", idEnd) ; | 
 |  |  |  | 
 |  |  |         // 获取符合条件的记录数 | 
 |  |  |         Long itemTotal = Optional.ofNullable(rmOnHourReportHistoryMapper.getNotOnlineIntakesCount(params)).orElse(0L); | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 最近未报数的取水口 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoIntakeUnReported>> getUnReportedIntakes(CommonQO qo) { | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
 |  |  |         Long itemTotal = rmOnHourReportLastMapper.getUnReportedIntakesCount(params); | 
 |  |  |  | 
 |  |  |         QueryResultVo<List<VoIntakeUnReported>> rsVo = new QueryResultVo<>() ; | 
 |  |  |         rsVo.pageSize = qo.pageSize ; | 
 |  |  |         rsVo.pageCurr = qo.pageCurr ; | 
 |  |  |  | 
 |  |  |         rsVo.calculateAndSet(itemTotal, params); | 
 |  |  |         rsVo.obj = rmOnHourReportLastMapper.getUnReportedIntakes(params); | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** ok 1 | 
 |  |  |      * 获取累计流量超过指定值的取水口 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |     /** ok 2 | 
 |  |  |      * 获取累计流量低于指定值的取水口 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoBatteryVolt>> getUnderVoltIntakes(BatteryVoltQO qo) { | 
 |  |  |         qo.setBatteryVolt(batteryVolt); | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取从未开过阀的取水口 | 
 |  |  |      * @param qo | 
 |  |  |      * @param idStart | 
 |  |  |      * @param idEnd | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoIntake>> getNeverOpenValveIntakes(CommonQO qo) { | 
 |  |  |  | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null && timeStart != "") { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         } else { | 
 |  |  |             timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |  | 
 |  |  |         if(timeStop != null && timeStop != "") { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         }else { | 
 |  |  |             timeStop = LocalDate.now() + " 23:59:59"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |  | 
 |  |  |     public QueryResultVo<List<VoIntakeUnOpenValve>> getNeverOpenValveIntakes(CommonQO qo, Long idStart, Long idEnd) { | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |         params.put("idStart", idStart) ; | 
 |  |  |         params.put("idEnd", idEnd) ; | 
 |  |  |  | 
 |  |  |         // 获取符合条件的记录数 | 
 |  |  |         Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getNeverOpenValveIntakesCount(params)).orElse(0L); | 
 |  |  |  | 
 |  |  |         QueryResultVo<List<VoIntake>> rsVo = new QueryResultVo<>() ; | 
 |  |  |         QueryResultVo<List<VoIntakeUnOpenValve>> rsVo = new QueryResultVo<>() ; | 
 |  |  |  | 
 |  |  |         rsVo.pageSize = qo.pageSize ; | 
 |  |  |         rsVo.pageCurr = qo.pageCurr ; | 
 |  |  | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoIntakeOpenCount>> getOpenValveGtIntakes(IntakeCountValueQO qo) { | 
 |  |  |  | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null && timeStart != "") { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         } else { | 
 |  |  |             timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |  | 
 |  |  |         if(timeStop != null && timeStop != "") { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         }else { | 
 |  |  |             timeStop = LocalDate.now() + " 23:59:59"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |  | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |  | 
 |  |  | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoIntakeOpenCount>> getOpenValveLtIntakes(IntakeCountValueQO qo) { | 
 |  |  |  | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null && timeStart != "") { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         } else { | 
 |  |  |             timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |  | 
 |  |  |         if(timeStop != null && timeStop != "") { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         }else { | 
 |  |  |             timeStop = LocalDate.now() + " 23:59:59"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |  | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
 |  |  |  | 
 |  |  |         // 获取符合条件的记录数 | 
 |  |  |         Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getOpenValveLtIntakesCount(params)).orElse(0L); | 
 |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据开阀类型获取操作次数 | 
 |  |  |      * @param qo | 
 |  |  |      * @param idStart | 
 |  |  |      * @param idEnd | 
 |  |  |      * @param openType | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public VoCountOfOpenType getCountByOpenType(OpenTypeQO qo) { | 
 |  |  |         /** | 
 |  |  |          * 补齐起止时间,如果开始时间为空,则默认为当前日期 | 
 |  |  |          */ | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null) { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         }else { | 
 |  |  |             timeStart = LocalDate.now() + " 00:00:00"; | 
 |  |  |         } | 
 |  |  |         if(timeStop != null) { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |  | 
 |  |  |         Integer openType = qo.getOpenType(); | 
 |  |  |         String openTypeName = ""; | 
 |  |  |         switch (openType) { | 
 |  |  |             case 1: | 
 |  |  |                 openTypeName = "刷卡开阀"; | 
 |  |  |                 break; | 
 |  |  |             case 3: | 
 |  |  |                 openTypeName = "中心站开阀"; | 
 |  |  |                 break; | 
 |  |  |             case 8: | 
 |  |  |                 openTypeName = "用户远程开阀"; | 
 |  |  |                 break; | 
 |  |  |             case 11: | 
 |  |  |                 openTypeName = "开关阀卡开阀"; | 
 |  |  |                 break; | 
 |  |  |             case 13: | 
 |  |  |                 openTypeName = "开关阀卡开阀"; | 
 |  |  |                 break; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     public List<VoCountOfOpenType> getCountByOpenType(Long idStart, Long idEnd, Integer openType) { | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |         Map<String, Object> params = new HashMap<>() ; | 
 |  |  |         params.put("idStart", idStart); | 
 |  |  |         params.put("idEnd", idEnd); | 
 |  |  |         params.put("openType", openType); | 
 |  |  |  | 
 |  |  |         Integer openTypeCount = Optional.ofNullable(rmOpenCloseValveLastMapper.getCountByOpenType(params)).orElse(0); | 
 |  |  |  | 
 |  |  |         VoCountOfOpenType vo = new VoCountOfOpenType(); | 
 |  |  |         vo.setOpenTypeName(openTypeName); | 
 |  |  |         vo.setOpenTypeCount(openTypeCount); | 
 |  |  |         return vo; | 
 |  |  |         List<VoCountOfOpenType> list = rmOpenCloseValveLastMapper.getCountByOpenType(params) ; | 
 |  |  |         if(list != null){ | 
 |  |  |             for (VoCountOfOpenType vo : list) { | 
 |  |  |                 if (vo.openType != null){ | 
 |  |  |                     switch (vo.openType) { | 
 |  |  |                         case 1: | 
 |  |  |                             vo.openTypeName = "刷卡开阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 3: | 
 |  |  |                             vo.openTypeName = "中心站开阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 8: | 
 |  |  |                             vo.openTypeName = "用户远程开阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 11: | 
 |  |  |                             vo.openTypeName = "巡检卡开阀"; | 
 |  |  |                             break; | 
 |  |  |                         default: | 
 |  |  |                             vo.openTypeName = "未知类型开阀"; | 
 |  |  |                     } | 
 |  |  |                 }else{ | 
 |  |  |                     vo.openTypeName = "未知类型开阀"; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return list ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据关阀类型获取操作次数 | 
 |  |  |      * @param qo | 
 |  |  |      * @param idStart | 
 |  |  |      * @param idEnd | 
 |  |  |      * @param closeType | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public VoCountOfCloseType getCountByCloseType(CloseTypeQo qo) { | 
 |  |  |         /** | 
 |  |  |          * 补齐起止时间,如果开始时间为空,则默认为当前日期 | 
 |  |  |          */ | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null) { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         }else { | 
 |  |  |             timeStart = LocalDate.now() + " 00:00:00"; | 
 |  |  |         } | 
 |  |  |         if(timeStop != null) { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |     public List<VoCountOfCloseType> getCountByCloseType(Long idStart, Long idEnd, Integer closeType) { | 
 |  |  |         Map<String, Object> params = new HashMap<>() ; | 
 |  |  |         params.put("idStart", idStart); | 
 |  |  |         params.put("idEnd", idEnd); | 
 |  |  |         params.put("closeType", closeType); | 
 |  |  |  | 
 |  |  |         Integer closeType = qo.getCloseType(); | 
 |  |  |         String closeTypeName = ""; | 
 |  |  |         switch (closeType) { | 
 |  |  |             case 2: | 
 |  |  |                 closeTypeName = "刷卡关阀"; | 
 |  |  |                 break; | 
 |  |  |             case 4: | 
 |  |  |                 closeTypeName = "中心站关阀"; | 
 |  |  |                 break; | 
 |  |  |             case 5: | 
 |  |  |                 closeTypeName = "欠费关阀"; | 
 |  |  |                 break; | 
 |  |  |             case 6: | 
 |  |  |                 closeTypeName = "流量计故障关阀"; | 
 |  |  |                 break; | 
 |  |  |             case 7: | 
 |  |  |                 closeTypeName = "紧急关阀"; | 
 |  |  |                 break; | 
 |  |  |             case 9: | 
 |  |  |                 closeTypeName = "用户远程关阀"; | 
 |  |  |                 break; | 
 |  |  |             case 10: | 
 |  |  |                 closeTypeName = "开关阀卡关阀"; | 
 |  |  |                 break; | 
 |  |  |             case 12: | 
 |  |  |                 closeTypeName = "黑名单命令关阀"; | 
 |  |  |                 break; | 
 |  |  |             case 13: | 
 |  |  |                 closeTypeName = "远程定时关阀"; | 
 |  |  |                 break; | 
 |  |  |             case 14: | 
 |  |  |                 closeTypeName = "远程定量关阀"; | 
 |  |  |                 break; | 
 |  |  |         List<VoCountOfCloseType> list = rmOpenCloseValveLastMapper.getCountByCloseType(params) ; | 
 |  |  |         if(list != null) { | 
 |  |  |             for (VoCountOfCloseType vo : list) { | 
 |  |  |                 if (vo.closeType != null) { | 
 |  |  |                     switch (vo.closeType) { | 
 |  |  |                         case 2: | 
 |  |  |                             vo.closeTypeName = "刷卡关阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 4: | 
 |  |  |                             vo.closeTypeName = "中心站关阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 5: | 
 |  |  |                             vo.closeTypeName = "欠费关阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 6: | 
 |  |  |                             vo.closeTypeName = "流量计故障关阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 7: | 
 |  |  |                             vo.closeTypeName = "紧急关阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 9: | 
 |  |  |                             vo.closeTypeName = "用户远程关阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 10: | 
 |  |  |                             vo.closeTypeName = "巡检卡关阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 12: | 
 |  |  |                             vo.closeTypeName = "黑名单命令关阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 13: | 
 |  |  |                             vo.closeTypeName = "远程定时关阀"; | 
 |  |  |                             break; | 
 |  |  |                         case 14: | 
 |  |  |                             vo.closeTypeName = "远程定量关阀"; | 
 |  |  |                             break; | 
 |  |  |                         default: | 
 |  |  |                             vo.closeTypeName = "未知关阀类型"; | 
 |  |  |                     } | 
 |  |  |                 }else{ | 
 |  |  |                     vo.closeTypeName = "未知关阀类型"; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |         Integer closeTypeCount = Optional.ofNullable(rmOpenCloseValveLastMapper.getCountByCloseType(params)).orElse(0); | 
 |  |  |  | 
 |  |  |         VoCountOfCloseType vo = new VoCountOfCloseType(); | 
 |  |  |         vo.setCloseTypeName(closeTypeName); | 
 |  |  |         vo.setCloseTypeCount(closeTypeCount); | 
 |  |  |         return vo; | 
 |  |  |         return list ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |         if(timeStart != null && timeStart != "") { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         } else { | 
 |  |  |             timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); | 
 |  |  |             timeStart = LocalDate.now() + " 00:00:00"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |  | 
 |  |  | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |     /** ok 3 | 
 |  |  |      * 指定时间段内用水量超过指定值的取水口 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  | 
 |  |  |     public QueryResultVo<List<VoIntakeAccumulateAmount>> getUseWaterGtValueIntakes(IntakeAmountValueQO qo) { | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null && timeStart != "") { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         } else { | 
 |  |  |             timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); | 
 |  |  |         if(timeStart == null || timeStart.trim().equals("")) { | 
 |  |  |             timeStart = DateTime.yyyy_MM_dd() ; | 
 |  |  |             qo.setTimeStart(timeStart); | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |  | 
 |  |  |         if(timeStop != null && timeStop != "") { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         }else { | 
 |  |  |             timeStop = LocalDate.now() + " 23:59:59"; | 
 |  |  |         if(timeStop == null || timeStop.trim().equals("")) { | 
 |  |  |             timeStop = DateTime.yyyy_MM_dd() ; | 
 |  |  |             qo.setTimeStop(timeStop); | 
 |  |  |         } | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |  | 
 |  |  |         if (qo.getValue() == null){ | 
 |  |  |             qo.setValue(0.0); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
 |  |  |         Long itemTotal = rmOpenCloseValveHistoryMapper.getUseWaterGtValueIntakesCount(params); | 
 |  |  |         Long itemTotal = rmIntakeAmountDayMapper.getUseWaterGtValueIntakesCount(params); | 
 |  |  |  | 
 |  |  |         QueryResultVo<List<VoIntakeAccumulateAmount>> rsVo = new QueryResultVo<>() ; | 
 |  |  |         rsVo.pageSize = qo.pageSize ; | 
 |  |  |         rsVo.pageCurr = qo.pageCurr ; | 
 |  |  |  | 
 |  |  |         rsVo.calculateAndSet(itemTotal, params); | 
 |  |  |         rsVo.obj = rmOpenCloseValveHistoryMapper.getUseWaterGtValueIntakes(params); | 
 |  |  |         rsVo.obj = rmIntakeAmountDayMapper.getUseWaterGtValueIntakes(params); | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |     /** ok 4 | 
 |  |  |      * 指定时间段内消费金额超过指定值的取水口 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  | 
 |  |  |     public QueryResultVo<List<VoIntakeAccumulateAmount>> getExpenseGtValueIntakes(IntakeAmountValueQO qo) { | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null && timeStart != "") { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         } else { | 
 |  |  |             timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); | 
 |  |  |         if(timeStart == null || timeStart.trim().equals("")) { | 
 |  |  |             timeStart = DateTime.yyyy_MM_dd() ; | 
 |  |  |             qo.setTimeStart(timeStart); | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |  | 
 |  |  |         if(timeStop != null && timeStop != "") { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         }else { | 
 |  |  |             timeStop = LocalDate.now() + " 23:59:59"; | 
 |  |  |         if(timeStop == null || timeStop.trim().equals("")) { | 
 |  |  |             timeStop = DateTime.yyyy_MM_dd() ; | 
 |  |  |             qo.setTimeStop(timeStop); | 
 |  |  |         } | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |  | 
 |  |  |         if (qo.getValue() == null){ | 
 |  |  |             qo.setValue(0.0); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
 |  |  |         Long itemTotal = rmOpenCloseValveHistoryMapper.getExpenseGtValueIntakesCount(params); | 
 |  |  |         Long itemTotal = rmIntakeAmountDayMapper.getExpenseGtValueIntakesCount(params); | 
 |  |  |  | 
 |  |  |         QueryResultVo<List<VoIntakeAccumulateAmount>> rsVo = new QueryResultVo<>() ; | 
 |  |  |         rsVo.pageSize = qo.pageSize ; | 
 |  |  |         rsVo.pageCurr = qo.pageCurr ; | 
 |  |  |  | 
 |  |  |         rsVo.calculateAndSet(itemTotal, params); | 
 |  |  |         rsVo.obj = rmOpenCloseValveHistoryMapper.getExpenseGtValueIntakes(params); | 
 |  |  |         rsVo.obj = rmIntakeAmountDayMapper.getExpenseGtValueIntakes(params); | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** ok 4 | 
 |  |  |      * 指定时间段内消费金额超过指定值的取水口 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoIntakeAccumulateAmount>> getUseWaterTimesGtValueIntakes(IntakeCountValueQO qo) { | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart == null || timeStart.trim().equals("")) { | 
 |  |  |             timeStart = DateTime.yyyy_MM_dd() ; | 
 |  |  |             qo.setTimeStart(timeStart); | 
 |  |  |         } | 
 |  |  |         if(timeStop == null || timeStop.trim().equals("")) { | 
 |  |  |             timeStop = DateTime.yyyy_MM_dd() ; | 
 |  |  |             qo.setTimeStop(timeStop); | 
 |  |  |         } | 
 |  |  |         if (qo.getValue() == null){ | 
 |  |  |             qo.setValue(0); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
 |  |  |         Long itemTotal = rmIntakeAmountDayMapper.getUseWaterTimesGtValueIntakesCount(params); | 
 |  |  |  | 
 |  |  |         QueryResultVo<List<VoIntakeAccumulateAmount>> rsVo = new QueryResultVo<>() ; | 
 |  |  |         rsVo.pageSize = qo.pageSize ; | 
 |  |  |         rsVo.pageCurr = qo.pageCurr ; | 
 |  |  |  | 
 |  |  |         rsVo.calculateAndSet(itemTotal, params); | 
 |  |  |         rsVo.obj = rmIntakeAmountDayMapper.getUseWaterTimesGtValueIntakes(params); | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |         if(timeStart != null && timeStart != "") { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         } else { | 
 |  |  |             timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); | 
 |  |  |             timeStart = LocalDate.now() + " 00:00:00"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |  | 
 |  |  | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoIntake>> getHaveOpenNoCloseIntakes(CommonQO qo) { | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null && timeStart != "") { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         } else { | 
 |  |  |             timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |  | 
 |  |  |         if(timeStop != null && timeStop != "") { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         }else { | 
 |  |  |             timeStop = LocalDate.now() + " 23:59:59"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public QueryResultVo<List<VoIntake>> getHaveOpenNoCloseIntakes(IntakeCountValueQO qo) { | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
 |  |  |         Long itemTotal = rmOpenCloseValveHistoryMapper.getHaveOpenNoCloseIntakesCount(params); | 
 |  |  |  | 
 |  |  | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoIntake>> getNoOpenHaveCloseIntakes(CommonQO qo) { | 
 |  |  |         String timeStart = qo.getTimeStart(); | 
 |  |  |         String timeStop = qo.getTimeStop(); | 
 |  |  |         if(timeStart != null && timeStart != "") { | 
 |  |  |             timeStart = timeStart + " 00:00:00"; | 
 |  |  |         } else { | 
 |  |  |             timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); | 
 |  |  |         } | 
 |  |  |         qo.setTimeStart(timeStart); | 
 |  |  |  | 
 |  |  |         if(timeStop != null && timeStop != "") { | 
 |  |  |             timeStop = timeStop + " 23:59:59"; | 
 |  |  |         }else { | 
 |  |  |             timeStop = LocalDate.now() + " 23:59:59"; | 
 |  |  |         } | 
 |  |  |         qo.setTimeStop(timeStop); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public QueryResultVo<List<VoIntake>> getNoOpenHaveCloseIntakes(IntakeCountValueQO qo) { | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
 |  |  |         Long itemTotal = rmOpenCloseValveHistoryMapper.getNoOpenHaveCloseIntakesCount(params); | 
 |  |  |  | 
 |  |  | 
 |  |  |         rsVo.obj = rmOpenCloseValveHistoryMapper.getNoOpenHaveCloseIntakes(params); | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 统计指定月份各天用水量 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoDayIntakeAmount>> getDayIntakeAmount(IntakeAmountQO qo) throws ParseException { | 
 |  |  |         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | 
 |  |  |         String yearMonth = qo.getYearMonth(); | 
 |  |  |         yearMonth = yearMonth + "-01"; | 
 |  |  |         yearMonth = dateFormat.format(dateFormat.parse(yearMonth)); | 
 |  |  |  | 
 |  |  |         Integer year = Integer.parseInt(yearMonth.substring(0,4)); | 
 |  |  |         Integer month = Integer.parseInt(yearMonth.substring(5,7)); | 
 |  |  |         qo.setYear(year); | 
 |  |  |         qo.setMonth(month); | 
 |  |  |  | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |  | 
 |  |  |         // 获取符合条件的记录数 | 
 |  |  |         Long itemTotal = Optional.ofNullable(rmIntakeAmountDayMapper.getDayIntakeAmountCount(params)).orElse(0L); | 
 |  |  |  | 
 |  |  |         QueryResultVo<List<VoDayIntakeAmount>> rsVo = new QueryResultVo<>() ; | 
 |  |  |  | 
 |  |  |         rsVo.pageSize = qo.pageSize ; | 
 |  |  |         rsVo.pageCurr = qo.pageCurr ; | 
 |  |  |  | 
 |  |  |         rsVo.calculateAndSet(itemTotal, params); | 
 |  |  |         rsVo.obj = rmIntakeAmountDayMapper.getDayIntakeAmount(params); | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 统计指定年份各月用水量 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoMonthAmount>> getMonthIntakeAmount(IntakeAmountQO qo) { | 
 |  |  |         Calendar calendar = Calendar.getInstance(); | 
 |  |  |         Integer year = Optional.ofNullable(qo.getYear()).orElse(calendar.get(Calendar.YEAR)); | 
 |  |  |         qo.setYear(year); | 
 |  |  |  | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |  | 
 |  |  |         // 获取符合条件的记录数 | 
 |  |  |         Long itemTotal = Optional.ofNullable(rmIntakeAmountDayMapper.getMonthIntakeAmountCount(params)).orElse(0L); | 
 |  |  |  | 
 |  |  |         QueryResultVo<List<VoMonthAmount>> rsVo = new QueryResultVo<>() ; | 
 |  |  |  | 
 |  |  |         rsVo.pageSize = qo.pageSize ; | 
 |  |  |         rsVo.pageCurr = qo.pageCurr ; | 
 |  |  |  | 
 |  |  |         rsVo.calculateAndSet(itemTotal, params); | 
 |  |  |         rsVo.obj = rmIntakeAmountDayMapper.getMonthIntakeAmount(params); | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 统计指定月份各天漏损量 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoDayLoss>> getDayLossAmount(IntakeAmountQO qo) throws ParseException { | 
 |  |  |         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | 
 |  |  |         String yearMonth = qo.getYearMonth(); | 
 |  |  |         yearMonth = yearMonth + "-01"; | 
 |  |  |         yearMonth = dateFormat.format(dateFormat.parse(yearMonth)); | 
 |  |  |         Integer year = Integer.parseInt(yearMonth.substring(0,4)); | 
 |  |  |         Integer month = Integer.parseInt(yearMonth.substring(5,7)); | 
 |  |  |         qo.setYear(year); | 
 |  |  |         qo.setMonth(month); | 
 |  |  |  | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |  | 
 |  |  |         // 获取符合条件的记录数 | 
 |  |  |         Long itemTotal = Optional.ofNullable(rmLossDayLastMapper.getDayLossAmountCount(params)).orElse(0L); | 
 |  |  |  | 
 |  |  |         QueryResultVo<List<VoDayLoss>> rsVo = new QueryResultVo<>() ; | 
 |  |  |  | 
 |  |  |         rsVo.pageSize = qo.pageSize ; | 
 |  |  |         rsVo.pageCurr = qo.pageCurr ; | 
 |  |  |  | 
 |  |  |         rsVo.calculateAndSet(itemTotal, params); | 
 |  |  |         rsVo.obj = rmLossDayLastMapper.getDayLossAmount(params); | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 统计指定年份各月漏损量 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public QueryResultVo<List<VoMonthAmount>> getMonthLossAmount(IntakeAmountQO qo) { | 
 |  |  |         Calendar calendar = Calendar.getInstance(); | 
 |  |  |         Integer year = Optional.ofNullable(qo.getYear()).orElse(calendar.get(Calendar.YEAR)); | 
 |  |  |         qo.setYear(year); | 
 |  |  |  | 
 |  |  |         // 生成查询参数 | 
 |  |  |         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; | 
 |  |  |  | 
 |  |  |         // 获取符合条件的记录数 | 
 |  |  |         Long itemTotal = Optional.ofNullable(rmLossDayLastMapper.getMonthLossAmountCount(params)).orElse(0L); | 
 |  |  |  | 
 |  |  |         QueryResultVo<List<VoMonthAmount>> rsVo = new QueryResultVo<>() ; | 
 |  |  |  | 
 |  |  |         rsVo.pageSize = qo.pageSize ; | 
 |  |  |         rsVo.pageCurr = qo.pageCurr ; | 
 |  |  |  | 
 |  |  |         rsVo.calculateAndSet(itemTotal, params); | 
 |  |  |         rsVo.obj = rmLossDayLastMapper.getMonthLossAmount(params); | 
 |  |  |         return rsVo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |