|
|
@@ -28,6 +28,7 @@ import com.xunmei.system.api.enums.NetStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -67,9 +68,8 @@ public class IotDeviceDetectionServiceImpl extends ServiceImpl<IotDeviceDetectio
|
|
|
error = (ReceiveErrorDto) map.get("error");
|
|
|
if (error.getSuccess()) {
|
|
|
SysOrg org = (SysOrg) map.get("org");
|
|
|
- SysDevice device = (SysDevice) map.get("device");
|
|
|
- MediatorCategory category = (MediatorCategory) map.get("category");
|
|
|
- Map<String, Object> objectMap = this.buildEntityDto(networkDeviceDetectionEditDto, org, device, category);
|
|
|
+ IotDevice device = (IotDevice) map.get("device");
|
|
|
+ Map<String, Object> objectMap = this.buildEntityDto(networkDeviceDetectionEditDto, org, device);
|
|
|
this.saveDataInfo(objectMap, networkDeviceDetectionEditDto);
|
|
|
}
|
|
|
return error;
|
|
|
@@ -77,11 +77,11 @@ public class IotDeviceDetectionServiceImpl extends ServiceImpl<IotDeviceDetectio
|
|
|
public void saveDataInfo(Map<String, Object> objectMap, NetworkDeviceDetectionEditDto networkDeviceDetectionEditDto) {
|
|
|
IotDeviceDetection networkDeviceDetection = (IotDeviceDetection) objectMap.get("networkDeviceDetection");
|
|
|
IotDeviceDetectionLog networkDeviceDetectionLog = (IotDeviceDetectionLog) objectMap.get("networkDeviceDetectionLog");
|
|
|
- SysDevice device = (SysDevice) objectMap.get("device");
|
|
|
+ IotDevice device = (IotDevice) objectMap.get("device");
|
|
|
try {
|
|
|
this.saveOrUpdate(networkDeviceDetection);
|
|
|
networkDeviceDetectionLogService.saveOrUpdate(networkDeviceDetectionLog);
|
|
|
- //deviceDao.saveOrUpdate(device);
|
|
|
+ iIotDeviceService.updateById(device);
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
}
|
|
|
@@ -109,13 +109,13 @@ public class IotDeviceDetectionServiceImpl extends ServiceImpl<IotDeviceDetectio
|
|
|
map.put("error", error);
|
|
|
return map;
|
|
|
}
|
|
|
- MediatorCategory category = categoryService.getById(device.getCategoryId());
|
|
|
+ /*MediatorCategory category = categoryService.getById(device.getCategoryId());
|
|
|
if (ObjectUtil.isNull(category)) {
|
|
|
error.setSuccess(false);
|
|
|
error.setErrorMsg("设备类型不存在");
|
|
|
map.put("error", error);
|
|
|
return map;
|
|
|
- }
|
|
|
+ }*/
|
|
|
if (networkDeviceDetectionEditDto.getNetStatus() != 0 && networkDeviceDetectionEditDto.getNetStatus() != 1 && networkDeviceDetectionEditDto.getNetStatus() != 2) {
|
|
|
error.setSuccess(false);
|
|
|
error.setErrorMsg("参数非法:netStatus不正确");
|
|
|
@@ -124,7 +124,7 @@ public class IotDeviceDetectionServiceImpl extends ServiceImpl<IotDeviceDetectio
|
|
|
}
|
|
|
map.put("org", org);
|
|
|
map.put("device", device);
|
|
|
- map.put("category", category);
|
|
|
+ //map.put("category", category);
|
|
|
map.put("error", error);
|
|
|
return map;
|
|
|
} else {
|
|
|
@@ -134,7 +134,7 @@ public class IotDeviceDetectionServiceImpl extends ServiceImpl<IotDeviceDetectio
|
|
|
|
|
|
}
|
|
|
|
|
|
- private Map<String, Object> buildEntityDto(NetworkDeviceDetectionEditDto networkDeviceDetectionEditDto, SysOrg org, SysDevice device, MediatorCategory category) {
|
|
|
+ private Map<String, Object> buildEntityDto(NetworkDeviceDetectionEditDto networkDeviceDetectionEditDto, SysOrg org, IotDevice device) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
IotDeviceDetection networkDeviceDetection = new IotDeviceDetection();
|
|
|
|
|
|
@@ -147,24 +147,28 @@ public class IotDeviceDetectionServiceImpl extends ServiceImpl<IotDeviceDetectio
|
|
|
networkDeviceDetection = old;
|
|
|
}else{
|
|
|
networkDeviceDetection.setId(IDHelper.id());
|
|
|
+ networkDeviceDetection.setCreateTime(LocalDateTime.now());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.notEqual(networkDeviceDetection.getState(),networkDeviceDetectionEditDto.getNetStatus())){
|
|
|
+ networkDeviceDetection.setStateUpdateTime(LocalDateTime.now());
|
|
|
}
|
|
|
networkDeviceDetection.setEquipmentName(networkDeviceDetectionEditDto.getEquipmentName());
|
|
|
networkDeviceDetection.setUpdateTime(DateUtils.toLocalDateTime(networkDeviceDetectionEditDto.getUpdateTime()));
|
|
|
switch (networkDeviceDetectionEditDto.getNetStatus()) {
|
|
|
case 0:
|
|
|
- networkDeviceDetection.setStatus(NetStatus.NORMAL.ordinal());
|
|
|
- device.setOnline(DeviceOnlineStatus.ONLINE.ordinal());
|
|
|
+ networkDeviceDetection.setState(NetStatus.NORMAL.ordinal());
|
|
|
+ device.setNetStatus(DeviceOnlineStatus.ONLINE.ordinal());
|
|
|
break;
|
|
|
case 1:
|
|
|
- networkDeviceDetection.setStatus(NetStatus.ABNORMAL.ordinal());
|
|
|
- device.setOnline(DeviceOnlineStatus.NA.ordinal());
|
|
|
+ networkDeviceDetection.setState(NetStatus.ABNORMAL.ordinal());
|
|
|
+ device.setNetStatus(DeviceOnlineStatus.NA.ordinal());
|
|
|
break;
|
|
|
case 2:
|
|
|
- networkDeviceDetection.setStatus(NetStatus.INTERRUPT.ordinal());
|
|
|
- device.setOnline(DeviceOnlineStatus.OFFLINE.ordinal());
|
|
|
+ networkDeviceDetection.setState(NetStatus.INTERRUPT.ordinal());
|
|
|
+ device.setNetStatus(DeviceOnlineStatus.OFFLINE.ordinal());
|
|
|
break;
|
|
|
default:
|
|
|
- device.setOnline(DeviceOnlineStatus.UNKNOW.ordinal());
|
|
|
+ device.setNetStatus(DeviceOnlineStatus.UNKNOW.ordinal());
|
|
|
break;
|
|
|
}
|
|
|
if (networkDeviceDetection.getUpdateTime() == null) {
|