|
@@ -40,16 +40,17 @@ 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;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
-import sun.net.dns.ResolverConfiguration;
|
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -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";
|
|
|
|
|
|
|
|
@@ -425,50 +429,9 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
|
|
|
@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<LastInnerResultVO> list = remoteTsdbProxyService.last(queryVO);
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- for(int i=0;i<list.size();i++){
|
|
|
- if(Objects.nonNull(list.get(i).getMetrics())){
|
|
|
- String deviceuuid = list.get(i).getDeviceuuid();
|
|
|
- LocalDateTime lTime = Instant.ofEpochMilli(Long.valueOf(list.get(i).getMetrics().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
|