| 
					
				 | 
			
			
				@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.toolkit.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.google.common.collect.Lists; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.usky.common.core.bean.CommonPage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.usky.common.core.exception.BusinessException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.usky.common.core.util.Arith; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -26,6 +27,7 @@ import java.time.Instant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.ZoneId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.concurrent.atomic.AtomicInteger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -116,6 +118,58 @@ public class DemPoliceInfoServiceImpl extends AbstractCrudService<DemPoliceInfoM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return this.ToCommonPage(page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Map<String, List<AlertStatisticsVO>> getAlertStatisticsByHouse(String startTime, String endTime, String streetTown) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date startTime1 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date endTime1 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            startTime1 = simpleDateFormat.parse(startTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            endTime1 = simpleDateFormat.parse(endTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BusinessException("时间格式错误"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QueryWrapper<DemPoliceInfo> queryWrapper = new QueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queryWrapper.select("HOUR(filing_time) monthTime", "COUNT(id) as aCount", "case_type as aType") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .between("filing_time", startTime1, endTime1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq("street_town", streetTown) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .groupBy("monthTime", "case_type"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, List<AlertStatisticsVO>> typeMap = enhanceList(this.listMaps(queryWrapper)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date maxDate = getMaxDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date minDate = getMinDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AtomicInteger distanceOfTwoDate = new AtomicInteger(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Optional.ofNullable(maxDate) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .ifPresent(md -> distanceOfTwoDate.set(DateUtils.getDistanceOfTwoDateNew(minDate, maxDate))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        perfect(typeMap, 24, distanceOfTwoDate.get(), 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        collectByThree(typeMap, distanceOfTwoDate.get()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return typeMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<Map<String, Object>> warningInstanceScatterer(String streetTown) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        IPage<DemPoliceInfo> page = new Page<>(1, 500); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LambdaQueryWrapper<DemPoliceInfo> queryWrapper = Wrappers.lambdaQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queryWrapper.select(DemPoliceInfo::getAddress, DemPoliceInfo::getGisX, DemPoliceInfo::getGisY, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                DemPoliceInfo::getId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(StringUtils.isNotBlank(streetTown), DemPoliceInfo::getStreetTown, streetTown) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(DemPoliceInfo::getQuenchTime, "") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .orderByDesc(DemPoliceInfo::getId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        page = this.page(page, queryWrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isNotEmpty(page.getRecords())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < page.getRecords().size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String, Object> map = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("id", page.getRecords().get(i).getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("address", page.getRecords().get(i).getAddress()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("longitude", page.getRecords().get(i).getGisX()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("latitude", page.getRecords().get(i).getGisY()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                list.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<String> getFireType() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<FireLevelRatioVO> list = new ArrayList<>(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -133,6 +187,23 @@ public class DemPoliceInfoServiceImpl extends AbstractCrudService<DemPoliceInfoM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .map(FireLevelRatioVO::getFireType).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void collectByThree(Map<String, List<AlertStatisticsVO>> map, Integer distanceOfTwoDate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (String type : map.keySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<AlertStatisticsVO> list = map.get(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<List<AlertStatisticsVO>> partition = Lists.partition(list, 3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<AlertStatisticsVO> thList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (List<AlertStatisticsVO> threeList : partition) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double sum = threeList.stream().mapToDouble(AlertStatisticsVO::getNumber).sum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                AlertStatisticsVO alertStatisticsVO = new AlertStatisticsVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                alertStatisticsVO.setType(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                alertStatisticsVO.setMonth(String.valueOf(partition.indexOf(threeList))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                alertStatisticsVO.setAvg(Arith.div(sum, distanceOfTwoDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                thList.add(alertStatisticsVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put(type, thList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public AlertStatisticsVO getAsV(Date startTime, Date endTime, String type, String streetTown) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         AlertStatisticsVO alertStatisticsVo = new AlertStatisticsVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LambdaQueryWrapper<DemPoliceInfo> queryWrapper = Wrappers.lambdaQuery(); 
			 |