| package com.dy.pipIrrRemote.report; | 
|   | 
| import com.dy.common.mw.protocol.p206V1.CommonV1; | 
| import com.dy.common.webUtil.QueryResultVo; | 
| import com.dy.pipIrrGlobal.daoRm.*; | 
| import com.dy.pipIrrGlobal.voRm.VoOnHour; | 
| import com.dy.pipIrrGlobal.voRm.VoOpenCloseValve; | 
| import com.dy.pipIrrGlobal.voRm.VoTiming; | 
| import com.dy.pipIrrGlobal.voRm.VoWork; | 
| import com.dy.pipIrrRemote.report.qo.OnHourQO; | 
| import com.dy.pipIrrRemote.report.qo.OpenCloseValveQO; | 
| import lombok.RequiredArgsConstructor; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.apache.dubbo.common.utils.PojoUtils; | 
| import org.springframework.stereotype.Service; | 
|   | 
| import java.util.List; | 
| import java.util.Map; | 
|   | 
| /** | 
|  * @author ZhuBaoMin | 
|  * @date 2024-07-23 16:02 | 
|  * @LastEditTime 2024-07-23 16:02 | 
|  * @Description 各类数据报服务类 | 
|  */ | 
|   | 
| @Slf4j | 
| @Service | 
| @RequiredArgsConstructor | 
| public class ReportSv { | 
|     // 阀控器整点报DAO | 
|     private final RmOnHourReportHistoryMapper rmOnHourReportHistoryMapper; | 
|     private final RmOnHourReportLastMapper rmOnHourReportLastMapper; | 
|   | 
|     // 阀控器开关阀报DAO | 
|     private final RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper; | 
|     private final RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper; | 
|   | 
|     // 阀控器定时报DAO | 
|     private final RmTimingReportHistoryMapper rmTimingReportHistoryMapper; | 
|     private final RmTimingReportLastMapper rmTimingReportLastMapper; | 
|   | 
|     // 工作报DAO | 
|     private final RmWorkReportHistoryMapper rmWorkReportHistoryMapper; | 
|     private final RmWorkReportLastMapper rmWorkReportLastMapper; | 
|   | 
|     /** | 
|      * 根据指定条件获取整点报历史记录 | 
|      * @param qo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoOnHour>> getOnHourReportsHistory(OnHourQO qo) { | 
|         qo.completionTime(); | 
|   | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
|         Long itemTotal = rmOnHourReportHistoryMapper.getOnHourReportsCount_history(params); | 
|   | 
|         QueryResultVo<List<VoOnHour>> rsVo = new QueryResultVo<>() ; | 
|         rsVo.pageSize = qo.pageSize ; | 
|         rsVo.pageCurr = qo.pageCurr ; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|         rsVo.obj = rmOnHourReportHistoryMapper.getOnHourReports_history(params); | 
|         return rsVo ; | 
|     } | 
|   | 
|     /** | 
|      * 根据指定条件获取整点报最新记录 | 
|      * @param qo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoOnHour>> getOnHourReportsLast(OnHourQO qo) { | 
|         qo.completionTime(); | 
|   | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
|         Long itemTotal = rmOnHourReportLastMapper.getOnHourReportsCount_last(params); | 
|   | 
|         QueryResultVo<List<VoOnHour>> rsVo = new QueryResultVo<>() ; | 
|         rsVo.pageSize = qo.pageSize ; | 
|         rsVo.pageCurr = qo.pageCurr ; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|         rsVo.obj = rmOnHourReportLastMapper.getOnHourReports_last(params); | 
|         return rsVo ; | 
|     } | 
|   | 
|     /** | 
|      * 根据指定条件获取开关阀报历史记录 | 
|      * @param qo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoOpenCloseValve>> getOpenCloseValveReports_history(OpenCloseValveQO qo) { | 
|         //下面由completionTimeNoEmpty()改为completionTime()原因, | 
|         //开关阀记录中开阀时间和关阀时间有时不会同时有值,可能其中任一个是null值,如果用时间条件查询,则这样的记录就查不出来了。 | 
|         //如果要缩小所查询记录的范围(数量),则可从记录ID上设备一个范围。 | 
|         //qo.completionTimeNoEmpty() ; | 
|         qo.completionTime() ; | 
|   | 
|   | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
|         Long itemTotal = rmOpenCloseValveHistoryMapper.getOpenCloseValveReportsCount_history(params); | 
|   | 
|         QueryResultVo<List<VoOpenCloseValve>> rsVo = new QueryResultVo<>() ; | 
|         rsVo.pageSize = qo.pageSize ; | 
|         rsVo.pageCurr = qo.pageCurr ; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|         List<VoOpenCloseValve> list = rmOpenCloseValveHistoryMapper.getOpenCloseValveReports_history(params); | 
|         if (list != null && list.size() > 0) { | 
|             for (VoOpenCloseValve vo : list) { | 
|                 vo.setOpenType(CommonV1.openCloseValveType(vo.getOpType()==null?(byte)100:vo.getOpType())); | 
|                 if(vo.getClType() != null) { | 
|                     vo.setCloseType(CommonV1.openCloseValveType(vo.getClType() == null ? (byte) 100 : vo.getClType())); | 
|                 }else{ | 
|                     vo.setCloseType(""); | 
|                 } | 
|             } | 
|         } | 
|         rsVo.obj = list; | 
|         return rsVo ; | 
|     } | 
|   | 
|     /** | 
|      * 根据指定条件获取开关阀报最新记录 | 
|      * @param qo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoOpenCloseValve>> getOpenCloseValveReports_last(OpenCloseValveQO qo) { | 
|         qo.completionTime() ; | 
|   | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
|         Long itemTotal = rmOpenCloseValveLastMapper.getOpenCloseValveReportsCount_last(params); | 
|   | 
|         QueryResultVo<List<VoOpenCloseValve>> rsVo = new QueryResultVo<>() ; | 
|         rsVo.pageSize = qo.pageSize ; | 
|         rsVo.pageCurr = qo.pageCurr ; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|         List<VoOpenCloseValve> list = rmOpenCloseValveLastMapper.getOpenCloseValveReports_last(params); | 
|         if (list != null && list.size() > 0) { | 
|             for (VoOpenCloseValve vo : list) { | 
|                 vo.setOpenType(CommonV1.openCloseValveType(vo.getOpType()==null?(byte)100:vo.getOpType())); | 
|                 if(vo.getClType() != null){ | 
|                     vo.setCloseType(CommonV1.openCloseValveType(vo.getClType()==null?(byte)100:vo.getClType())); | 
|                 }else{ | 
|                     vo.setCloseType(""); | 
|                 } | 
|             } | 
|         } | 
|         rsVo.obj = list; | 
|         return rsVo ; | 
|     } | 
|   | 
|     /** | 
|      * 根据指定条件获取定时报历史记录 | 
|      * @param qo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoTiming>> getTimingReportsHistory(OnHourQO qo) { | 
|         qo.completionTime() ; | 
|   | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
|         Long itemTotal = rmTimingReportHistoryMapper.getTimingReportsCount_history(params); | 
|   | 
|         QueryResultVo<List<VoTiming>> rsVo = new QueryResultVo<>() ; | 
|         rsVo.pageSize = qo.pageSize ; | 
|         rsVo.pageCurr = qo.pageCurr ; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|         rsVo.obj = rmTimingReportHistoryMapper.getTimingReports_history(params); | 
|         return rsVo ; | 
|     } | 
|   | 
|     /** | 
|      * 根据指定条件获取定时报最新记录 | 
|      * @param qo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoTiming>> getTimingReportsLast(OnHourQO qo) { | 
|         qo.completionTime() ; | 
|   | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
|         Long itemTotal = rmTimingReportLastMapper.getTimingReportsCount_last(params); | 
|   | 
|         QueryResultVo<List<VoTiming>> rsVo = new QueryResultVo<>() ; | 
|         rsVo.pageSize = qo.pageSize ; | 
|         rsVo.pageCurr = qo.pageCurr ; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|         rsVo.obj = rmTimingReportLastMapper.getTimingReports_last(params); | 
|         return rsVo ; | 
|     } | 
|   | 
|     /** | 
|      * 根据指定条件获取工作报历史记录 | 
|      * @param qo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoWork>> getWorkReportsHistory(OnHourQO qo) { | 
|         qo.completionTime() ; | 
|   | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
|         Long itemTotal = rmWorkReportHistoryMapper.getWorkReportsCount_history(params); | 
|   | 
|         QueryResultVo<List<VoWork>> rsVo = new QueryResultVo<>() ; | 
|         rsVo.pageSize = qo.pageSize ; | 
|         rsVo.pageCurr = qo.pageCurr ; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|         rsVo.obj = rmWorkReportHistoryMapper.getWorkReports_history(params); | 
|         return rsVo ; | 
|     } | 
|   | 
|     /** | 
|      * 根据指定条件获取工作报最新记录 | 
|      * @param qo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoWork>> getWorkReportsLast(OnHourQO qo) { | 
|         qo.completionTime() ; | 
|   | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); | 
|         Long itemTotal = rmWorkReportLastMapper.getWorkReportsCount_last(params); | 
|   | 
|         QueryResultVo<List<VoWork>> rsVo = new QueryResultVo<>() ; | 
|         rsVo.pageSize = qo.pageSize ; | 
|         rsVo.pageCurr = qo.pageCurr ; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|         rsVo.obj = rmWorkReportLastMapper.getWorkReports_last(params); | 
|         return rsVo ; | 
|     } | 
| } |