|
@@ -541,6 +541,10 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
throw new BusinessException("新增设备信息'" + dmpDeviceInfo.getDeviceId() + "'失败,设备信息已存在");
|
|
throw new BusinessException("新增设备信息'" + dmpDeviceInfo.getDeviceId() + "'失败,设备信息已存在");
|
|
|
}
|
|
}
|
|
|
List<DmpProductInfo> list = baseMapper.getProductInfo(dmpDeviceInfo.getProductCode());
|
|
List<DmpProductInfo> list = baseMapper.getProductInfo(dmpDeviceInfo.getProductCode());
|
|
|
|
|
+ int count = 0;
|
|
|
|
|
+ if(dmpDeviceInfo.getTenantId() != null){
|
|
|
|
|
+ count = baseMapper.sysTenantCount(dmpDeviceInfo.getTenantId());
|
|
|
|
|
+ }
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
dmpDeviceInfo.setDeviceType(list.get(0).getDeviceType());
|
|
dmpDeviceInfo.setDeviceType(list.get(0).getDeviceType());
|
|
|
dmpDeviceInfo.setProductId(list.get(0).getId());
|
|
dmpDeviceInfo.setProductId(list.get(0).getId());
|
|
@@ -566,8 +570,24 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
dmpDeviceStatus.setProductCode(dmpDeviceInfo.getProductCode());
|
|
dmpDeviceStatus.setProductCode(dmpDeviceInfo.getProductCode());
|
|
|
dmpDeviceStatus.setDeviceUuid(dmpDeviceInfo.getDeviceUuid());
|
|
dmpDeviceStatus.setDeviceUuid(dmpDeviceInfo.getDeviceUuid());
|
|
|
dmpDeviceStatusService.save(dmpDeviceStatus);
|
|
dmpDeviceStatusService.save(dmpDeviceStatus);
|
|
|
|
|
+ } else if(count > 0){ //子系统同步到平台
|
|
|
|
|
+ dmpDeviceInfo.setDeviceType(Integer.valueOf(""));
|
|
|
|
|
+ dmpDeviceInfo.setProductId(Integer.valueOf(""));
|
|
|
|
|
+ dmpDeviceInfo.setCreatedBy(SecurityUtils.getUsername());
|
|
|
|
|
+ dmpDeviceInfo.setCreatedTime(LocalDateTime.now());
|
|
|
|
|
+ dmpDeviceInfo.setServiceStatus(1);
|
|
|
|
|
+ this.save(dmpDeviceInfo);
|
|
|
|
|
+
|
|
|
|
|
+ DmpDeviceStatus dmpDeviceStatus = new DmpDeviceStatus();
|
|
|
|
|
+ dmpDeviceStatus.setDeviceId(dmpDeviceInfo.getDeviceId());
|
|
|
|
|
+ dmpDeviceStatus.setProductId(Integer.valueOf(""));
|
|
|
|
|
+ dmpDeviceStatus.setDeviceStatus(2);
|
|
|
|
|
+ dmpDeviceStatus.setLastOfflineTime(LocalDateTime.now());
|
|
|
|
|
+ dmpDeviceStatus.setProductCode("");
|
|
|
|
|
+ dmpDeviceStatus.setDeviceUuid(dmpDeviceInfo.getDeviceUuid());
|
|
|
|
|
+ dmpDeviceStatusService.save(dmpDeviceStatus);
|
|
|
} else {
|
|
} else {
|
|
|
- throw new BusinessException("新增设备信息'" + dmpDeviceInfo.getDeviceId() + "'失败,无对应产品信息");
|
|
|
|
|
|
|
+ throw new BusinessException("新增设备信息'" + dmpDeviceInfo.getDeviceId() + "'失败,无对应产品信息或租户Id");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -580,10 +600,21 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
|
|
|
}
|
|
}
|
|
|
this.updateById(dmpDeviceInfo);
|
|
this.updateById(dmpDeviceInfo);
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void bindSubsystemDevice(DmpDeviceInfo dmpDeviceInfo) {
|
|
|
|
|
+ dmpDeviceInfo.setUpdatedBy(SecurityUtils.getUsername());
|
|
|
|
|
+ dmpDeviceInfo.setUpdatedTime(LocalDateTime.now());
|
|
|
|
|
+ if (checkNameUnique(dmpDeviceInfo)) {
|
|
|
|
|
+ throw new BusinessException("修改设备信息'" + dmpDeviceInfo.getDeviceId() + "'失败,设备信息已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ this.updateById(dmpDeviceInfo);
|
|
|
|
|
+
|
|
|
LambdaUpdateWrapper<DmpDeviceStatus> updateWrapper = Wrappers.lambdaUpdate();
|
|
LambdaUpdateWrapper<DmpDeviceStatus> updateWrapper = Wrappers.lambdaUpdate();
|
|
|
updateWrapper.set(DmpDeviceStatus::getProductId,dmpDeviceInfo.getProductId())
|
|
updateWrapper.set(DmpDeviceStatus::getProductId,dmpDeviceInfo.getProductId())
|
|
|
.set(DmpDeviceStatus::getProductCode,dmpDeviceInfo.getProductCode())
|
|
.set(DmpDeviceStatus::getProductCode,dmpDeviceInfo.getProductCode())
|
|
|
- .eq(DmpDeviceStatus::getDeviceId, dmpDeviceInfo.getDeviceId());
|
|
|
|
|
|
|
+ .eq(DmpDeviceStatus::getDeviceUuid, dmpDeviceInfo.getDeviceUuid());
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|