|
@@ -40,6 +40,7 @@ import com.usky.iot.service.BaseFacilityDeviceService;
|
|
|
import com.usky.iot.service.DmpDeviceInfoService;
|
|
|
import com.usky.iot.service.DmpDeviceStatusService;
|
|
|
import com.usky.iot.service.DmpProductAttributeService;
|
|
|
+import com.usky.iot.service.config.DeviceOperate;
|
|
|
import com.usky.iot.service.enums.TopicInfo;
|
|
|
import com.usky.iot.service.vo.*;
|
|
|
import com.usky.transfer.RemoteTransferService;
|
|
@@ -97,6 +98,9 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
@Autowired
|
|
|
private DmpProductAttributeMapper dmpProductAttributeMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DeviceOperate deviceOperate;
|
|
|
+
|
|
|
private static final String ALARM_HTTP_URL = "/service-alarm/baseAlarm/alarmInfo";
|
|
|
|
|
|
|
|
@@ -422,50 +426,11 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
return null != one && !Objects.equals(one.getId(), id);
|
|
|
}
|
|
|
|
|
|
- @Async
|
|
|
+ @Override
|
|
|
public void deviceStatus(){
|
|
|
- log.info("定时同步设备状态数据 start");
|
|
|
- LastInnerQueryVO queryVO = new LastInnerQueryVO();
|
|
|
- List<String> deviceuuidList = new ArrayList<>();
|
|
|
- LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.select(DmpDeviceInfo::getDeviceUuid)
|
|
|
- .eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
- .ne(DmpDeviceInfo::getServiceStatus,3)
|
|
|
- .orderByDesc(DmpDeviceInfo::getId);
|
|
|
- List<DmpDeviceInfo> devList = this.list(queryWrapper);
|
|
|
- if(CollectionUtils.isNotEmpty(devList)){
|
|
|
- int count = devList.size();
|
|
|
- for (int i = 0; i < devList.size(); i++) {
|
|
|
- deviceuuidList.add(devList.get(i).getDeviceUuid());
|
|
|
- }
|
|
|
- }
|
|
|
- queryVO.setDeviceuuid(deviceuuidList);
|
|
|
-
|
|
|
- List<Map<String,Object>> list = remoteTsdbProxyService.getAllDeviceRealTime();
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- for(int i=0;i<list.size();i++){
|
|
|
- String deviceuuid = list.get(i).get("deviceuuid").toString();
|
|
|
- LocalDateTime lTime = Instant.ofEpochMilli(Long.valueOf(list.get(i).get("time").toString())).atZone(ZoneOffset.ofHours(8)).toLocalDateTime();
|
|
|
- String date = lTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
- String currentDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
- LambdaUpdateWrapper<DmpDeviceStatus> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
- if(date.equals(currentDate)){
|
|
|
- updateWrapper.set(DmpDeviceStatus::getDeviceStatus,1) //设备在线
|
|
|
- .set(DmpDeviceStatus::getLastOnlineTime,lTime)
|
|
|
- .eq(DmpDeviceStatus::getDeviceUuid,deviceuuid);
|
|
|
-
|
|
|
- }else{
|
|
|
- updateWrapper.set(DmpDeviceStatus::getDeviceStatus,2) //设备离线
|
|
|
- .set(DmpDeviceStatus::getLastOnlineTime,lTime)
|
|
|
- .eq(DmpDeviceStatus::getDeviceUuid,deviceuuid);
|
|
|
-
|
|
|
- }
|
|
|
- dmpDeviceStatusService.update(updateWrapper);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- log.info("定时同步设备状态数据 end");
|
|
|
+ log.info("设备状态 start");
|
|
|
+ deviceOperate.updateDeviceStatus();
|
|
|
+ log.info("设备状态 end");
|
|
|
}
|
|
|
|
|
|
@Override
|