diff --git a/device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java b/device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java index 81f85e7c51325ef424ece0be9b039e4f27f22d50..ecb632623d90d76f2c419fa6b5e73cea1a6f340d 100644 --- a/device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java +++ b/device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java @@ -116,6 +116,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D if (ObjectUtils.isEmpty(deviceEntity)) throw new AppException("褰撳墠璁惧涓嶅瓨鍦紒"); if (deviceEntity.getDeviceStatus() != DeviceStatusEnum.鏈縺娲�.getValue()) throw new AppException("褰撳墠璁惧宸叉縺娲伙紒"); deviceEntity.setDeviceStatus(DeviceStatusEnum.绂荤嚎.getValue()); + deviceEntity.setEnabled(EnabledEnum.鍚敤.getValue()); this.update(deviceEntity, context); PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); ProductEntity productEntity = productService.get(deviceEntity.getProductId()); @@ -308,12 +309,19 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D throw new AppException("璁惧缂栫爜閲嶅锛�"); } - - if (!ObjectUtils.isEmpty(entity.getPlatformCode())) { - PlatformEntity platformEntity = platformService.selectOne(new PlatformQuery().platformSn(entity.getPlatformCode())); - if (!ObjectUtils.isEmpty(platformEntity)) { - entity.setPlatformId(platformEntity.getId()); - entity.setPlatformName(platformEntity.getPlatformName()); + if (!ObjectUtils.isEmpty(entity.getProductId())) { + ProductEntity productEntity = productService.get(entity.getProductId()); + if (!ObjectUtils.isEmpty(productEntity)) { + entity.setProductId(productEntity.getId()); + entity.setProductCode(productEntity.getProductCode()); + entity.setProductName(productEntity.getProductName()); + //鏍规嵁浜у搧鏌ヨ骞冲彴 + if(!ObjectUtils.isEmpty(productEntity.getPlatformId())){ + PlatformEntity platformEntity = platformService.get(productEntity.getPlatformId()); + entity.setPlatformId(platformEntity.getId()); + entity.setPlatformCode(platformEntity.getPlatformSn()); + entity.setPlatformName(platformEntity.getPlatformName()); + } } } @@ -322,10 +330,28 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D if (!ObjectUtils.isEmpty(productEntity)) { entity.setProductId(productEntity.getId()); entity.setProductName(productEntity.getProductName()); + //鏍规嵁浜у搧鏌ヨ骞冲彴 + if(!ObjectUtils.isEmpty(productEntity.getPlatformId())){ + PlatformEntity platformEntity = platformService.get(productEntity.getPlatformId()); + entity.setPlatformId(platformEntity.getId()); + entity.setPlatformCode(platformEntity.getPlatformSn()); + entity.setPlatformName(platformEntity.getPlatformName()); + } + } + } + + + if (!ObjectUtils.isEmpty(entity.getPlatformCode())) { + PlatformEntity platformEntity = platformService.selectOne(new PlatformQuery().platformSn(entity.getPlatformCode())); + if (!ObjectUtils.isEmpty(platformEntity)) { + entity.setPlatformId(platformEntity.getId()); + entity.setPlatformName(platformEntity.getPlatformName()); } } super.saveBefore(entity, context); } + + } \ No newline at end of file