Sfoglia il codice sorgente

物联总览bug修改

jingyuanchao 1 anno fa
parent
commit
b7d72024a4

+ 5 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/VideoDaysCheckMapper.java

@@ -5,6 +5,9 @@ import com.xunmei.common.core.domain.video.MediatorVideoDaysCheck;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 录像机天数检查 Mapper 接口
@@ -17,4 +20,6 @@ import org.apache.ibatis.annotations.Param;
 public interface VideoDaysCheckMapper extends BaseMapper<MediatorVideoDaysCheck> {
 
     Integer selectExceptionCount(@Param("orgId") Long orgId);
+
+    List<MediatorVideoDaysCheck> selectDataList(@Param("orgPath") String orgPath, @Param("startTime") Date startTime);
 }

+ 37 - 26
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotBoardServiceImpl.java

@@ -5,14 +5,13 @@ import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson2.JSON;
 import com.google.common.collect.Lists;
 import com.xunmei.common.core.constant.CacheConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.iot.domain.IotDvrDisk;
-import com.xunmei.common.core.domain.iot.domain.IotDvrHardDiskDetectionLog;
 import com.xunmei.common.core.domain.iot.domain.IotSensor;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmData;
+import com.xunmei.common.core.domain.video.MediatorVideoDaysCheck;
 import com.xunmei.common.core.domain.video.MediatorVideoIntegrityCheckLog;
 import com.xunmei.common.core.enums.CategoryDataEnum;
 import com.xunmei.common.core.enums.iot.SensorType;
@@ -24,7 +23,7 @@ import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.iot.mapper.IotBoardMapper;
 import com.xunmei.iot.mapper.IotDvrChannelMapper;
 import com.xunmei.iot.mapper.IotDvrDiskMapper;
-import com.xunmei.iot.mapper.IotDvrHardDiskDetectionLogMapper;
+import com.xunmei.iot.mapper.VideoDaysCheckMapper;
 import com.xunmei.iot.service.IIotCommonSensorService;
 import com.xunmei.iot.service.IotAlarmDataService;
 import com.xunmei.iot.service.IotBoardService;
@@ -74,7 +73,7 @@ public class IotBoardServiceImpl implements IotBoardService {
     IotAlarmDataService alarmDataService;
 
     @Resource
-    IotDvrHardDiskDetectionLogMapper dvrHardDiskDetectionLogMapper;
+    VideoDaysCheckMapper videoDaysCheckMapper;
     @Resource
     IotDvrDiskMapper iotDvrDiskMapper;
 
@@ -342,6 +341,24 @@ public class IotBoardServiceImpl implements IotBoardService {
             }
         }
         totalData.setDeviceOverview(deviceOverview);
+        this.sensorData(MAP_VALUE, DEVICE_TYPE, orgPath, totalData);
+        //录像文件自检
+        this.selectVideoCheckSelf(orgVO, now, totalData, channelDataOffsetDay);
+
+        final Date startTime = DateUtil.beginOfDay(DateUtil.offsetDay(now, -channelDataOffsetDay));
+        //录像天数存储
+        this.selectVideoDaysStorage(orgPath, startTime, totalData);
+
+        IotBoardTotalData.VideoDiagnostic videoDiagnostic = videoDiagnosisService.selectVideoDiagnostic(orgPath, startTime);
+        totalData.setVideoDiagnostic(videoDiagnostic);
+
+        totalData.setAirConditionerInfo(new IotBoardTotalData.AirConditionerInfo());
+        totalData.setUpsInfo(new IotBoardTotalData.UpsInfo());
+
+        return totalData;
+    }
+
+    private void sensorData(String MAP_VALUE, String DEVICE_TYPE, String orgPath, IotBoardTotalData totalData) {
         //物联设备最近90天的告警数据
         List<Map<String, String>> alarmCountMap = alarmDataService.selectAlarmCount(orgPath);
         //计算alarmCountMap 所有nums的总和
@@ -370,32 +387,26 @@ public class IotBoardServiceImpl implements IotBoardService {
             sensorDataList.add(sensorData);
         }
         totalData.setSensorDetails(sensorDataList);
-        //录像文件自检
-        this.selectVideoCheckSelf(orgVO, now, totalData, channelDataOffsetDay);
+    }
 
-        final Date startTime = DateUtil.beginOfDay(DateUtil.offsetDay(now, -channelDataOffsetDay));
-        //录像天数存储
-        List<Map<String, String>> videoCheckMap = iotBoardMapper.selectVideoDaysStorage(orgPath,startTime);
-        HashMap<Integer, Integer> hashMap = new LinkedHashMap<>();
-        IotBoardTotalData.RecordingStorage storage = new IotBoardTotalData.RecordingStorage();
-        if (!videoCheckMap.isEmpty()) {
-            for (Map<String, String> map : videoCheckMap) {
-                hashMap.put(Integer.parseInt(map.get("planDays")), Integer.parseInt(map.get(MAP_VALUE)));
-            }
-            String string = videoCheckMap.get(0).get("time");
-            storage.setUpdateTime(DateUtil.parseDateTime(string));
+    private void selectVideoDaysStorage(String orgPath, Date startTime, IotBoardTotalData totalData) {
+        List<MediatorVideoDaysCheck> daysCheckList = videoDaysCheckMapper.selectDataList(orgPath, startTime);
+        IotBoardTotalData.RecordingStorage recordingStorage = new IotBoardTotalData.RecordingStorage();
+        totalData.setRecordingStorage(recordingStorage);
+        if (ObjectUtil.isEmpty(daysCheckList)) {
+            return;
         }
 
-        storage.setHashmap(hashMap);
-        totalData.setRecordingStorage(storage);
+        final Optional<MediatorVideoDaysCheck> optional = daysCheckList.stream().max(Comparator.comparing(MediatorVideoDaysCheck::getUpdateTime));
+        optional.ifPresent(daysCheck -> recordingStorage.setUpdateTime(daysCheck.getUpdateTime()));
+        final List<Integer> list = daysCheckList.stream().map(MediatorVideoDaysCheck::getRealDays).collect(Collectors.toList());
+        final long count = list.stream().filter(d -> 30 <= d && d < 90).count();
+        final long count1 = list.stream().filter(d -> 90 <= d).count();
 
-        IotBoardTotalData.VideoDiagnostic videoDiagnostic = videoDiagnosisService.selectVideoDiagnostic(orgPath, startTime);
-        totalData.setVideoDiagnostic(videoDiagnostic);
-
-        totalData.setAirConditionerInfo(new IotBoardTotalData.AirConditionerInfo());
-        totalData.setUpsInfo(new IotBoardTotalData.UpsInfo());
-
-        return totalData;
+        Map<Integer, Integer> map = new HashMap<>();
+        map.put(30, (int) count);
+        map.put(90, (int) count1);
+        recordingStorage.setHashmap(map);
     }
 
     private void selectVideoCheckSelf(SysOrgVO org, Date now, IotBoardTotalData totalData, Integer channelDataOffsetDay) {

+ 9 - 0
soc-modules/soc-modules-iot/src/main/resources/mapper/VideoDaysCheckMapper.xml

@@ -15,4 +15,13 @@
         where dc.org_id = #{orgId}
           and dc.deleted = 0
     </select>
+
+    <select id="selectDataList" resultType="com.xunmei.common.core.domain.video.MediatorVideoDaysCheck">
+        select c.plan_days, c.real_days,c.update_time
+        from mediator_video_days_check c
+                 inner join sys_org o on o.id = c.org_id
+        where o.deleted = 0
+          and c.update_time >= #{startTime}
+          and org_path like concat(#{orgPath}, '%')
+    </select>
 </mapper>