| 
					
				 | 
			
			
				@@ -1,96 +1,130 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ruoyi.qdtl.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.core.util.StrUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.json.JSONUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.common.core.redis.RedisCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.common.utils.DateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ruoyi.qdtl.mapper.TlMonitorMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.qdtl.domain.CameraData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.qdtl.domain.MonitorStatic; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.qdtl.domain.TlMonitor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.qdtl.mapper.TlMonitorMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.qdtl.service.ITlMonitorService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 监控设备管理Service业务层处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @author ruoyi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @date 2022-03-02 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-public class TlMonitorServiceImpl implements ITlMonitorService  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class TlMonitorServiceImpl implements ITlMonitorService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private TlMonitorMapper tlMonitorMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RedisCache redisCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 查询监控设备管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param id 监控设备管理主键 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 监控设备管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public TlMonitor selectTlMonitorById(Long id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TlMonitor selectTlMonitorById(Long id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return tlMonitorMapper.selectTlMonitorById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 查询监控设备管理列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param tlMonitor 监控设备管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 监控设备管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public List<TlMonitor> selectTlMonitorList(TlMonitor tlMonitor) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<TlMonitor> selectTlMonitorList(TlMonitor tlMonitor) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return tlMonitorMapper.selectTlMonitorList(tlMonitor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 新增监控设备管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param tlMonitor 监控设备管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public int insertTlMonitor(TlMonitor tlMonitor) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public int insertTlMonitor(TlMonitor tlMonitor) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         tlMonitor.setCreateTime(DateUtils.getNowDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return tlMonitorMapper.insertTlMonitor(tlMonitor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 修改监控设备管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param tlMonitor 监控设备管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public int updateTlMonitor(TlMonitor tlMonitor) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public int updateTlMonitor(TlMonitor tlMonitor) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         tlMonitor.setUpdateTime(DateUtils.getNowDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return tlMonitorMapper.updateTlMonitor(tlMonitor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 批量删除监控设备管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param ids 需要删除的监控设备管理主键 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public int deleteTlMonitorByIds(Long[] ids) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public int deleteTlMonitorByIds(Long[] ids) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return tlMonitorMapper.deleteTlMonitorByIds(ids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 删除监控设备管理信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param id 监控设备管理主键 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public int deleteTlMonitorById(Long id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public int deleteTlMonitorById(Long id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return tlMonitorMapper.deleteTlMonitorById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<MonitorStatic> queryMonitorStatic() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取区域的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String regionsCache = redisCache.getCacheObject("tl:http:/api/resource/v1/regions"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<MonitorStatic> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StrUtil.isNotBlank(regionsCache)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            JSONArray regionsArray = JSONUtil.parseObj(regionsCache).getJSONObject("data").getJSONArray("list"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (Object o : regionsArray) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                MonitorStatic monitorStatic = new MonitorStatic(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                JSONObject jsonObject = JSONUtil.parseObj(o); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (StrUtil.contains(jsonObject.getStr("name"), "镇")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    monitorStatic.setIndexCode(jsonObject.getStr("indexCode")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    monitorStatic.setName(jsonObject.getStr("name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    list.add(monitorStatic); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 获取摄像头数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String camerasCache = redisCache.getCacheObject("tl:http:/api/resource/v1/cameras"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<CameraData> cameraData = JSONUtil.toList(JSONUtil.parseObj(camerasCache).getJSONObject("data").getJSONArray("list"), CameraData.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, Long> collect = cameraData.stream().collect(Collectors.groupingBy(CameraData::getUnitIndexCode, Collectors.counting())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (MonitorStatic monitorStatic : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                monitorStatic.setNum(collect.getOrDefault(monitorStatic.getIndexCode(), 0L)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |