Răsfoiți Sursa

北向动环诊断状态

jiawuxian 1 an în urmă
părinte
comite
0b8386e317

+ 20 - 9
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotAlarmDataServiceImpl.java

@@ -125,18 +125,29 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         if (isAlarm && alarms.size() == 0) {
             //报警中,且表中没有告警数据,则插入数据
             this.saveBatch(list);
-            iotSensor.setState(1);
-            iotSensor.setStateStartTime(LocalDateTime.now());
-            iotSensorMapper.updateById(iotSensor);
+            if (iotSensor.getState() != 1) {
+                iotSensor.setState(1);
+                iotSensor.setStateUpdateTime(LocalDateTime.now());
+                iotSensor.setStateStartTime(LocalDateTime.now());
+                iotSensorMapper.updateById(iotSensor);
+            }
+
         }
-        if (isExpress && !isAlarm && alarms.size() != 0) {
+        if (isExpress && !isAlarm) {
             //报警恢复
-            IotAlarmData iotAlarmData = alarms.get(0);
-            iotAlarmData.setEndTime(LocalDateTime.now());
-            this.updateById(iotAlarmData);
+            if( alarms.size() != 0){
+                IotAlarmData iotAlarmData = alarms.get(0);
+                iotAlarmData.setEndTime(LocalDateTime.now());
 
-            iotSensor.setState(0);
-            iotSensorMapper.updateById(iotSensor);
+                this.updateById(iotAlarmData);
+            }
+
+            if (ObjectUtil.notEqual(iotSensor.getState(),0)) {
+                iotSensor.setStateUpdateTime(LocalDateTime.now());
+                iotSensor.setStateStartTime(LocalDateTime.now());
+                iotSensor.setState(0);
+                iotSensorMapper.updateById(iotSensor);
+            }
         }
 
     }

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

@@ -77,7 +77,7 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
             if (first.isPresent()) {
                 final IotDvrDisk iotDvrDisk = first.get();
                 iotDvrDisk.setState((Integer) map.get("state"));
-                iotDvrDisk.setStateUpdateTime(LocalDateTime.now());
+                iotDvrDisk.setStateUpdateTime(videoRecorderHardDiskDetection.getCheckTime());
                 iotDvrDisk.setUpdateTime(LocalDateTime.now());
                 diskArrayList.add(iotDvrDisk);
             }

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

@@ -24,6 +24,7 @@ import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.dto.protection.ReceiveErrorDto;
 import com.xunmei.system.api.dto.protection.VideoRecorderHardDiskDetectionEditDto;
 import com.xunmei.system.api.enums.AlarmStatus;
+import com.xunmei.system.api.util.LogUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -183,12 +184,18 @@ public class IotDvrHardDiskDetectionServiceImpl extends ServiceImpl<IotDvrHardDi
 
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void saveDataInfo(Map<String, Object> objectMap, VideoRecorderHardDiskDetectionEditDto videoRecorderHardDiskDetectionEditDto) {
         IotDvrHardDiskDetection videoRecorderHardDiskDetection = (IotDvrHardDiskDetection) objectMap.get("videoRecorderHardDiskDetection");
         IotDvrHardDiskDetectionLog videoRecorderHardDiskDetectionLog = (IotDvrHardDiskDetectionLog) objectMap.get("videoRecorderHardDiskDetectionLog");
         this.saveOrUpdate(videoRecorderHardDiskDetection);
         videoRecorderHardDiskDetectionLogService.saveOrUpdate(videoRecorderHardDiskDetectionLog);
-        iotDvrDiskService.updateStatusByDiskDetection(videoRecorderHardDiskDetection);
+        try {
+            iotDvrDiskService.updateStatusByDiskDetection(videoRecorderHardDiskDetection);
+        } catch (Exception e) {
+            LogUtils.STATUS_INFO_DISKS.error("硬盘检测处理处理磁盘状态时发生异常!内容:{}",e.getMessage());
+            throw new RuntimeException(e);
+        }
 
         TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
             @Override