|
|
@@ -94,8 +94,8 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
|
|
|
@Autowired
|
|
|
private RemoteTsdbProxyService remoteTsdbProxyService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private DmpProductAttributeMapper dmpProductAttributeMapper;
|
|
|
|
|
|
@Autowired
|
|
|
@@ -152,9 +152,9 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
map1.put("commandValue", commandValue);
|
|
|
map.put("params", map1);
|
|
|
|
|
|
- if(categoryType == 3){
|
|
|
+ if (categoryType == 3) {
|
|
|
return remoteTransferService.deviceControl(productCode, gatewayUuid, JSON.toJSONString(map), tenantId, commandUserId, commandUserName);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return remoteTransferService.deviceControl(productCode, deviceUuid, JSON.toJSONString(map), tenantId, commandUserId, commandUserName);
|
|
|
}
|
|
|
|
|
|
@@ -190,7 +190,7 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
throw new BusinessException("设备uuid“deviceUuid“不能为空!");
|
|
|
}
|
|
|
|
|
|
- if(categoryType == 1){
|
|
|
+ if (categoryType == 1) {
|
|
|
DmpTopicResponseVO add = new DmpTopicResponseVO();
|
|
|
add.setTopic("/usky/devices/" + deviceUuid + "/add");
|
|
|
add.setPublisher("普通设备");
|
|
|
@@ -218,9 +218,9 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
controlResponse.setSubscriber("物联网平台");
|
|
|
controlResponse.setRemarks("普通设备返回给物联网平台的命令响应");
|
|
|
responseVOList.add(controlResponse);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
String gatewayUuid = requestVO.getGatewayUuid();
|
|
|
- if(categoryType == 2){
|
|
|
+ if (categoryType == 2) {
|
|
|
gatewayUuid = requestVO.getDeviceUuid();
|
|
|
}
|
|
|
|
|
|
@@ -282,7 +282,7 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
// responseVOList.add(controlResponse);
|
|
|
|
|
|
} else {
|
|
|
- if(categoryType == 1){
|
|
|
+ if (categoryType == 1) {
|
|
|
switch (topicType) {
|
|
|
case "add":
|
|
|
/*if (StringUtils.isBlank(productCode)) {
|
|
|
@@ -374,9 +374,9 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
default:
|
|
|
throw new BusinessException("topicType参数错误!");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
String gatewayUuid = requestVO.getGatewayUuid();
|
|
|
- if(categoryType == 2){
|
|
|
+ if (categoryType == 2) {
|
|
|
gatewayUuid = requestVO.getDeviceUuid();
|
|
|
}
|
|
|
switch (topicType) {
|
|
|
@@ -541,7 +541,7 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
dmpDeviceInfo.setTenantId(SecurityUtils.getTenantId());
|
|
|
dmpDeviceInfo.setServiceStatus(1);
|
|
|
if (StringUtils.isBlank(dmpDeviceInfo.getDeviceUuid())) {
|
|
|
- dmpDeviceInfo.setDeviceUuid(UUIDUtils.uuid());
|
|
|
+ dmpDeviceInfo.setDeviceUuid(UUIDUtils.uuid().substring(0, 16));
|
|
|
}
|
|
|
this.save(dmpDeviceInfo);
|
|
|
|
|
|
@@ -598,32 +598,32 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deviceStatus(){
|
|
|
+ public void deviceStatus() {
|
|
|
log.info("设备状态 start");
|
|
|
deviceOperate.updateDeviceStatus();
|
|
|
log.info("设备状态 end");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateDeviceStatus(LastInnerQueryVO queryVO){
|
|
|
+ public void updateDeviceStatus(LastInnerQueryVO queryVO) {
|
|
|
List<LastInnerResultVO> list = remoteTsdbProxyService.queryLastDeviceData(queryVO);
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- for(int i=0;i<list.size();i++){
|
|
|
- if(Objects.nonNull(list.get(i).getMetrics())){
|
|
|
+ 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("realtime").toString())).atZone(ZoneOffset.ofHours(8)).toLocalDateTime();
|
|
|
- String date = lTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
+ } else {
|
|
|
+ updateWrapper.set(DmpDeviceStatus::getDeviceStatus, 2) // 设备离线
|
|
|
+ .set(DmpDeviceStatus::getLastOnlineTime, lTime)
|
|
|
+ .eq(DmpDeviceStatus::getDeviceUuid, deviceuuid);
|
|
|
|
|
|
}
|
|
|
dmpDeviceStatusService.update(updateWrapper);
|
|
|
@@ -1000,9 +1000,9 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<DmpDeviceInfo> gatewayDeviceList(){
|
|
|
+ public List<DmpDeviceInfo> gatewayDeviceList() {
|
|
|
LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(DmpDeviceInfo::getCategoryType,2)
|
|
|
+ queryWrapper.eq(DmpDeviceInfo::getCategoryType, 2)
|
|
|
.eq(DmpDeviceInfo::getDeleteFlag, 0)
|
|
|
.eq(DmpDeviceInfo::getTenantId, SecurityUtils.getTenantId())
|
|
|
.orderByDesc(DmpDeviceInfo::getId);
|