| 
					
				 | 
			
			
				@@ -1,7 +1,9 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.usky.fire.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import ch.qos.logback.core.pattern.FormatInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.core.collection.CollectionUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.usky.common.core.exception.BusinessException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.usky.common.core.util.DateUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -43,6 +45,9 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PatrolInspectionPlanMapper patrolInspectionPlanMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private PatrolInspectionPlanSonMapper patrolInspectionPlanSonMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PatrolInspectionPlanSiteSonService patrolInspectionPlanSiteSonService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -76,6 +81,9 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PatrolInspectionEventService patrolInspectionEventService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private PatrolInspectionAbnormalService patrolInspectionAbnormalService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public Map<String, Object> appPlanStatistics(String currentDate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Integer planSonCount = 0; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -346,6 +354,147 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.updateById(planSon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void addPatrolInspectionAbnormalData(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String datetime1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String datetime2 = LocalDateTime.now().minusHours(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PatrolInspectionPlanSon> list = patrolInspectionPlanSonMapper.selectInspectionPlanSonData(datetime1,datetime2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(list.size() <=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BusinessException("当前时间向前一小时没有漏检记录"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Integer> sonIdlist = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (int i = 0; i < list.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sonIdlist.add(list.get(i).getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LambdaQueryWrapper<PatrolInspectionPlanSiteSon> queryWrapper = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queryWrapper.in(PatrolInspectionPlanSiteSon::getPlanId,sonIdlist) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(PatrolInspectionPlanSiteSon::getInspectionStatus,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PatrolInspectionPlanSiteSon> siteSonList = patrolInspectionPlanSiteSonService.list(queryWrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(CollectionUtils.isNotEmpty(siteSonList)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Integer> siteIdList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Integer> noSonIdList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < siteSonList.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                siteIdList.add(siteSonList.get(i).getSiteId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                noSonIdList.add(siteSonList.get(i).getPlanId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获取巡检地点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LambdaQueryWrapper<PatrolInspectionSite> queryWrapper1 = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            queryWrapper1.in(PatrolInspectionSite::getId,siteIdList) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(PatrolInspectionSite::getEnable,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<PatrolInspectionSite> siteList = patrolInspectionSiteService.list(queryWrapper1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(siteList.size() <= 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new BusinessException("查询巡检地点记录为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获取巡检子计划 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LambdaQueryWrapper<PatrolInspectionPlanSon> planSonQueryWrapper = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            planSonQueryWrapper.in(PatrolInspectionPlanSon::getId,noSonIdList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<PatrolInspectionPlanSon> noPlanSonList = this.list(planSonQueryWrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Integer> planIdList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Integer> personnelList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Integer> areaList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < noPlanSonList.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                planIdList.add(noPlanSonList.get(i).getPlanId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                personnelList.add(noPlanSonList.get(i).getPersonnelId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                areaList.add(noPlanSonList.get(i).getAreaId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获取巡检计划 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<PatrolInspectionPlan> noPlanIdList = patrolInspectionPlanMapper.selectNoPlanList(planIdList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获取巡检人员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LambdaQueryWrapper<PatrolInspectionPersonnel> personnelQueryWrapper = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            personnelQueryWrapper.in(PatrolInspectionPersonnel::getId,personnelList) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(PatrolInspectionPersonnel::getEnable,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<PatrolInspectionPersonnel> inspectionPersonnelList = patrolInspectionPersonnelService.list(personnelQueryWrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(inspectionPersonnelList.size() <= 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new BusinessException("巡检人员信息不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获取巡检区域 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LambdaQueryWrapper<PatrolInspectionArea> queryWrapperOne = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            queryWrapperOne.in(PatrolInspectionArea::getId, areaList) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(PatrolInspectionArea::getEnable,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<PatrolInspectionArea> areaInfoList = patrolInspectionAreaService.list(queryWrapperOne); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(areaInfoList.size() <= 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new BusinessException("巡检区域不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < siteSonList.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                PatrolInspectionAbnormal patrolInspectionAbnormal = new PatrolInspectionAbnormal(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Integer siteId = siteSonList.get(i).getSiteId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Integer planSonId = siteSonList.get(i).getPlanId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (int j = 0; j < siteList.size(); j++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(siteId.equals(siteList.get(j).getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setSiteNubmber(siteList.get(j).getSiteNubmber()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setSiteType(siteList.get(j).getSiteType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setSiteName(siteList.get(j).getSiteName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setLongitude(siteList.get(j).getLongitude()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setLatitude(siteList.get(j).getLatitude()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setSiteId(siteList.get(j).getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setCompanyId(siteList.get(j).getCompanyId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (int j = 0; j < noPlanSonList.size(); j++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(planSonId.equals(noPlanSonList.get(j).getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setPlanId(noPlanSonList.get(j).getPlanId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setPlanSonId(noPlanSonList.get(j).getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setTenantId(noPlanSonList.get(j).getTenantId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setPlanType(noPlanSonList.get(j).getPlanType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Integer planType = noPlanSonList.get(j).getPlanType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String startDate = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String endDate = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (planType.equals(1)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            startDate = df1.format(noPlanSonList.get(j).getInspectionDate()) + "T" + noPlanSonList.get(j).getStartTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            endDate = df1.format(noPlanSonList.get(j).getInspectionDate()) + "T" + noPlanSonList.get(j).getEndTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            startDate = df1.format(noPlanSonList.get(j).getStartDate()) + "T" + noPlanSonList.get(j).getStartTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            endDate = df1.format(noPlanSonList.get(j).getEndDate()) + "T" + noPlanSonList.get(j).getEndTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setStartDate(LocalDateTime.parse(startDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        patrolInspectionAbnormal.setEndDate(LocalDateTime.parse(endDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Integer noAreaId = noPlanSonList.get(j).getAreaId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (int k = 0; k < areaInfoList.size(); k++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(noAreaId.equals(areaInfoList.get(k).getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                patrolInspectionAbnormal.setAreaName(areaInfoList.get(k).getAreaName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Integer noPersonnelId = noPlanSonList.get(j).getPersonnelId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (int k = 0; k < inspectionPersonnelList.size(); k++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(noPersonnelId.equals(inspectionPersonnelList.get(k).getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                patrolInspectionAbnormal.setName(inspectionPersonnelList.get(k).getFullName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                patrolInspectionAbnormal.setPhone(inspectionPersonnelList.get(k).getPhoneNumber()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Integer planId = noPlanSonList.get(j).getPlanId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (int k = 0; k < noPlanIdList.size(); k++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if(planId.equals(noPlanIdList.get(k).getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                patrolInspectionAbnormal.setRouteId(noPlanIdList.get(k).getRouteId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                patrolInspectionAbnormal.setAbnormalStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                patrolInspectionAbnormal.setCreateTime(LocalDateTime.now()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                patrolInspectionAbnormal.setCreator("YT_admin"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                patrolInspectionAbnormalService.save(patrolInspectionAbnormal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<PatrolInspectionSiteVo> planSonSiteDetails(Integer planSonId) { 
			 |