| package com.dy.pipIrrApp.inspect; | 
|   | 
| import com.dy.common.webUtil.QueryResultVo; | 
| import com.dy.pipIrrApp.inspect.qo.QoInspect; | 
| import com.dy.pipIrrGlobal.daoOp.OpeInspectMapper; | 
| import com.dy.pipIrrGlobal.daoOp.OpeTrackMapper; | 
| import com.dy.pipIrrGlobal.pojoOp.OpeInspect; | 
| import com.dy.pipIrrGlobal.pojoOp.OpeTrack; | 
| import com.dy.pipIrrGlobal.voOp.VoInspect; | 
| import com.dy.pipIrrGlobal.voOp.VoTrackPoint; | 
| 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.util.List; | 
| import java.util.Map; | 
|   | 
| /** | 
|  * @author ZhuBaoMin | 
|  * @date 2024-09-24 10:21 | 
|  * @LastEditTime 2024-09-24 10:21 | 
|  * @Description | 
|  */ | 
|   | 
| @Slf4j | 
| @Service | 
| public class InspectSv { | 
|     @Autowired | 
|     private OpeInspectMapper opeInspectMapper; | 
|   | 
|     @Autowired | 
|     private OpeTrackMapper opeTrackMapper; | 
|   | 
|     /** | 
|      * 添加巡检记录 | 
|      * | 
|      * @param po | 
|      * @return | 
|      */ | 
|     public Long addInspect(OpeInspect po) { | 
|         opeInspectMapper.insert(po); | 
|         return po.getId(); | 
|     } | 
|   | 
|     /** | 
|      * 修改巡检记录 | 
|      * | 
|      * @param po | 
|      * @return | 
|      */ | 
|     public Integer updateInspect(OpeInspect po) { | 
|         return opeInspectMapper.updateByPrimaryKeySelective(po); | 
|     } | 
|   | 
|     /** | 
|      * 批量添加巡检轨迹 | 
|      * | 
|      * @param list | 
|      * @return | 
|      */ | 
|     public Integer insertTracks(List<OpeTrack> list) { | 
|         return opeTrackMapper.insertTracks(list); | 
|     } | 
|   | 
|     /** | 
|      * 巡检查询 | 
|      * | 
|      * @param queryVo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoInspect>> getInspects(QoInspect queryVo) { | 
|         //完善查询充值记录的起止时间 | 
|         String timeStart = queryVo.getTimeStart(); | 
|         String timeStop = queryVo.getTimeStop(); | 
|   | 
|         if (timeStart == null || timeStart == "" || timeStop == null || timeStop == "") { | 
|             queryVo.setTimeStart(null); | 
|             queryVo.setTimeStop(null); | 
|         } else { | 
|             timeStart = timeStart + " 00:00:00"; | 
|             queryVo.setTimeStart(timeStart); | 
|             timeStop = timeStop + " 23:59:59"; | 
|             queryVo.setTimeStop(timeStop); | 
|         } | 
|   | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); | 
|   | 
|         Long itemTotal = opeInspectMapper.getInspectsCount(params); | 
|         QueryResultVo<List<VoInspect>> rsVo = new QueryResultVo<>(); | 
|   | 
|         rsVo.pageSize = queryVo.pageSize; | 
|         rsVo.pageCurr = queryVo.pageCurr; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|   | 
|         List<VoInspect> inspects = opeInspectMapper.getInspects(params); | 
|         for (int i = 0; i < inspects.size(); i++) { | 
|             List<OpeTrack> tracks = opeTrackMapper.selectByInspectId(inspects.get(i).getInspectId()); | 
|             inspects.get(i).setTracks(tracks); | 
|         } | 
|         rsVo.obj = inspects; | 
|         return rsVo; | 
|     } | 
|   | 
|     /** | 
|      * 获取指定巡检ID下的全部轨迹点 | 
|      * @param inspectId | 
|      * @return | 
|      */ | 
|     public List<VoTrackPoint> getTrackPointsById(Long inspectId) { | 
|         return opeTrackMapper.getTrackPointsById(inspectId); | 
|     } | 
|   | 
|     /** | 
|      * 更新指定巡检记录的巡检距离 | 
|      * @param inspectId | 
|      * @param distance | 
|      * @return | 
|      */ | 
|     public int updateInspectDistance(Long inspectId, double distance ) { | 
|         return opeInspectMapper.updateInspectDistance(inspectId, distance); | 
|     } | 
|   | 
|     /** | 
|      * 根据巡检员ID获取巡检列表 | 
|      * @param queryVo | 
|      * @return | 
|      */ | 
|     public QueryResultVo<List<VoInspect>> getInstectsByInspectorId(QoInspect queryVo) { | 
|         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); | 
|   | 
|         Long itemTotal = opeInspectMapper.getInstectsCountByInspectorId(params); | 
|   | 
|         QueryResultVo<List<VoInspect>> rsVo = new QueryResultVo<>(); | 
|         rsVo.pageSize = queryVo.pageSize; | 
|         rsVo.pageCurr = queryVo.pageCurr; | 
|   | 
|         rsVo.calculateAndSet(itemTotal, params); | 
|         rsVo.obj = opeInspectMapper.getInstectsByInspectorId(params); | 
|         return rsVo; | 
|     } | 
| } |