فهرست منبع

硬盘检测代码提交

jingyuanchao 1 سال پیش
والد
کامیت
2e3d49cdbe

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

@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xunmei.common.core.constant.CacheConstants;
-import com.xunmei.common.core.domain.R;
 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.IotDvrDiskLog;
@@ -23,7 +22,6 @@ import com.xunmei.mediator.api.video.service.IotDvrDiskLogService;
 import com.xunmei.mediator.api.video.service.IotDvrDiskService;
 import com.xunmei.mediator.util.CheckDataUtil;
 import com.xunmei.mediator.util.RedisCheckRepeatDataUtil;
-import com.xunmei.system.api.domain.iot.IotDeviceInfo;
 import com.xunmei.system.api.domain.north.NorthError;
 import com.xunmei.system.api.dto.DataPageDto;
 import com.xunmei.system.api.dto.DvrDiskPageDto;
@@ -37,6 +35,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.Duration;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -76,7 +76,7 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
         final List<Map> mapList = JSON.parseArray(detailInfo, Map.class);
         List<IotDvrDisk> diskArrayList = new ArrayList<>();
         for (Map map : mapList) {
-            final Integer index = (Integer) map.get("diskSerialNum");
+            final String index = (String) map.get("diskSerialNum");
             if (ObjectUtil.isNull(index)) {
                 continue;
             }
@@ -88,14 +88,14 @@ public class IotDvrDiskServiceImpl extends ServiceImpl<IotDvrDiskMapper, IotDvrD
             final IotDvrDisk iotDvrDisk = first.get();
             iotDvrDisk.setState((Integer) map.get("state"));
             iotDvrDisk.setDiskName((String) map.get("name"));
-            Integer totalBytes = (Integer) map.get("totalBytes");
+            Long totalBytes = (Long) map.get("totalBytes");
             Integer availableBytes = (Integer) map.get("availableBytes");
             Integer originState = (Integer) map.get("originState");
             //Integer freeBytes = (Integer) map.get("freeBytes");
 
             iotDvrDisk.setOriginState(originState);
-            iotDvrDisk.setAvailable(availableBytes/1024/1024);
-            iotDvrDisk.setTotal(totalBytes/1024/1024);
+            iotDvrDisk.setAvailable(new BigDecimal(availableBytes).divide(BigDecimal.valueOf(1024 * 1024), 2, RoundingMode.HALF_UP).intValue());
+            iotDvrDisk.setTotal(new BigDecimal(totalBytes).divide(BigDecimal.valueOf(1024 * 1024), 2, RoundingMode.HALF_UP).intValue());
             iotDvrDisk.setStateUpdateTime(videoRecorderHardDiskDetection.getCheckTime());
             iotDvrDisk.setUpdateTime(LocalDateTime.now());
             diskArrayList.add(iotDvrDisk);

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

@@ -78,9 +78,12 @@ public class IotDvrHardDiskDetectionServiceImpl extends ServiceImpl<IotDvrHardDi
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Object execute(WebsocketExecuteReq req) {
         try {
-            VideoRecorderHardDiskDetectionReq recorderHardDiskDetectionReq = (VideoRecorderHardDiskDetectionReq) req.getData();
+            String jsonString = JSON.toJSONString(req.getData());
+            VideoRecorderHardDiskDetectionReq recorderHardDiskDetectionReq = JSON.parseObject(jsonString, VideoRecorderHardDiskDetectionReq.class);
+
             VideoRecorderHardDiskDetectionEditDto dto = new VideoRecorderHardDiskDetectionEditDto();
             dto.setEquipmentCode(recorderHardDiskDetectionReq.getDvsCode());
             dto.setCheckStatus(recorderHardDiskDetectionReq.getCheckStatus());
@@ -91,7 +94,7 @@ public class IotDvrHardDiskDetectionServiceImpl extends ServiceImpl<IotDvrHardDi
             SysOrg sysOrg = iotServerInfoService.selectOrgByToken(token);
             dto.setOrganizationGuid(sysOrg.getCode());
 
-            return saveData(dto, "");
+            return saveData(dto, req.getId());
         } catch (IllegalAccessException e) {
             throw new RuntimeException(e);
         }
@@ -110,6 +113,7 @@ public class IotDvrHardDiskDetectionServiceImpl extends ServiceImpl<IotDvrHardDi
     public Map<String, Object> checkVideoRecorderHardDiskDetectionEditDto(VideoRecorderHardDiskDetectionEditDto videoRecorderHardDiskDetectionEditDto) throws IllegalAccessException {
         List<String> filds = new ArrayList<>();
         filds.add("id");
+        filds.add("equipmentName");
         ReceiveErrorDto error = CheckDataUtil.checkObjFieldIsNull(videoRecorderHardDiskDetectionEditDto, filds);
         Map<String, Object> map = new HashMap<>();
         if (error.getSuccess()) {