Quellcode durchsuchen

硬盘检测与磁盘空间日志增加代码提交

jingyuanchao vor 1 Jahr
Ursprung
Commit
8fcd4e91fc

+ 19 - 10
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotDvrDiskServiceImpl.java

@@ -9,10 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xunmei.common.core.constant.CacheConstants;
-import com.xunmei.common.core.domain.iot.domain.IotAlarmDefenceArea;
-import com.xunmei.common.core.domain.iot.domain.IotDevice;
-import com.xunmei.common.core.domain.iot.domain.IotDvrDisk;
-import com.xunmei.common.core.domain.iot.domain.IotDvrHardDiskDetection;
+import com.xunmei.common.core.domain.iot.domain.*;
 import com.xunmei.common.core.enums.CategoryDataEnum;
 import com.xunmei.common.core.utils.IDHelper;
 import com.xunmei.common.redis.utils.RedisUtils;
@@ -29,6 +26,7 @@ import com.xunmei.system.api.enums.DataType;
 import com.xunmei.system.api.util.LogUtils;
 import com.xunmei.system.api.vo.SysOrgVO;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -58,6 +56,8 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
     private NorthErrorService northErrorService;
     @Autowired
     private IIotDeviceService iotDeviceService;
+    @Autowired
+    private IotDvrDiskLogService diskLogService;
 
 
     @Override
@@ -74,13 +74,15 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
                 continue;
             }
             final Optional<IotDvrDisk> first = list.stream().filter(disk -> ObjectUtil.equal(disk.getDiskIndex(), String.valueOf(index))).findFirst();
-            if (first.isPresent()) {
-                final IotDvrDisk iotDvrDisk = first.get();
-                iotDvrDisk.setState((Integer) map.get("state"));
-                iotDvrDisk.setStateUpdateTime(videoRecorderHardDiskDetection.getCheckTime());
-                iotDvrDisk.setUpdateTime(LocalDateTime.now());
-                diskArrayList.add(iotDvrDisk);
+            if (!first.isPresent()) {
+                LogUtils.STATUS_INFO_DISKS.error("硬盘检测上报消息处理磁盘状态时未找到对应磁盘,主机code:{},磁盘号:{}",equipmentCode,index);
+                continue;
             }
+            final IotDvrDisk iotDvrDisk = first.get();
+            iotDvrDisk.setState((Integer) map.get("state"));
+            iotDvrDisk.setStateUpdateTime(videoRecorderHardDiskDetection.getCheckTime());
+            iotDvrDisk.setUpdateTime(LocalDateTime.now());
+            diskArrayList.add(iotDvrDisk);
         }
         updateBatchById(diskArrayList);
     }
@@ -119,6 +121,13 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
             wrapper.in(IotDvrDisk::getOrgId, orgIdLIst);
             this.remove(wrapper);
             this.saveOrUpdateBatch(dvrdisks);
+            for (IotDvrDisk dvrdisk : dvrdisks) {
+                final IotDvrDiskLog diskLog = new IotDvrDiskLog();
+                BeanUtils.copyProperties(dvrdisk, diskLog, "id");
+                diskLog.setIotDvrDiskId(dvrdisk.getId());
+                diskLogService.save(diskLog);
+            }
+
         }
     }
 

+ 2 - 1
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotDvrHardDiskDetectionServiceImpl.java

@@ -191,9 +191,10 @@ public class IotDvrHardDiskDetectionServiceImpl extends ServiceImpl<IotDvrHardDi
         this.saveOrUpdate(videoRecorderHardDiskDetection);
         videoRecorderHardDiskDetectionLogService.saveOrUpdate(videoRecorderHardDiskDetectionLog);
         try {
+            LogUtils.STATUS_INFO_DISKS.info("硬盘检测上报状态消息,开始处理对应盘符状态.....");
             iotDvrDiskService.updateStatusByDiskDetection(videoRecorderHardDiskDetection);
         } catch (Exception e) {
-            LogUtils.STATUS_INFO_DISKS.error("硬盘检测处理处理磁盘状态时发生异常!内容:{}",e.getMessage());
+            LogUtils.STATUS_INFO_DISKS.error("硬盘检测处理处理对应盘符状态时发生异常!内容:{}",e.getMessage());
             throw new RuntimeException(e);
         }