|
|
|
@ -145,6 +145,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R updateInfo(@Valid EmInfoAddVo em_info, String isModel, String modelName, Integer modelType) { |
|
|
|
|
this.validEmInfo(em_info); |
|
|
|
|
if (this.updateById(em_info.getInfo())) { |
|
|
|
|
getStationCodeStoreRedis(); |
|
|
|
|
if (isModel.equals(EquipmentContants.isModelEnum.yes.getValue())) { |
|
|
|
@ -496,9 +497,13 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void validEmInfo(EmInfoAddVo em_info) { |
|
|
|
|
EmInfoEntity info = em_info.getInfo(); |
|
|
|
|
// 验证设备名称
|
|
|
|
|
List<EmInfoEntity> existName = this.list( |
|
|
|
|
Wrappers.<EmInfoEntity>lambdaQuery().eq(EmInfoEntity::getName, em_info.getInfo().getName()).eq(EmInfoEntity::getDepartment, em_info.getInfo().getDepartment()) |
|
|
|
|
Wrappers.<EmInfoEntity>lambdaQuery() |
|
|
|
|
.eq(EmInfoEntity::getName, info.getName()) |
|
|
|
|
.eq(EmInfoEntity::getDepartment, info.getDepartment()) |
|
|
|
|
.ne(Func.isNotEmpty(info.getId()),EmInfoEntity::getId,info.getId()) |
|
|
|
|
); |
|
|
|
|
Assert.isTrue(CollectionUtil.isEmpty(existName),()-> { |
|
|
|
|
throw new ServiceException("设备名称已存在"); |
|
|
|
@ -506,24 +511,25 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
|
|
|
|
|
// 验证设备序号
|
|
|
|
|
if(Func.isNotEmpty(em_info.getInfo().getEmIndex())) { |
|
|
|
|
List<EmInfoEntity> exist = super.list(Wrappers.<EmInfoEntity>lambdaQuery() |
|
|
|
|
.eq(EmInfoEntity::getDepartment, em_info.getInfo().getDepartment()) |
|
|
|
|
.eq(EmInfoEntity::getEmIndex, em_info.getInfo().getEmIndex()) |
|
|
|
|
.eq(EmInfoEntity::getDepartment, info.getDepartment()) |
|
|
|
|
.eq(EmInfoEntity::getEmIndex, info.getEmIndex()) |
|
|
|
|
.ne(Func.isNotEmpty(info.getId()),EmInfoEntity::getId,info.getId()) |
|
|
|
|
); |
|
|
|
|
Assert.isTrue(CollectionUtil.isEmpty(exist),() -> { |
|
|
|
|
throw new ServiceException("该设备序号已存在,设备新增失败"); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
// 查询设备编码设备实例是否已存在
|
|
|
|
|
if(Func.isNotEmpty(em_info.getInfo().getNumber())) { |
|
|
|
|
if(Func.isNotEmpty(info.getNumber()) && Func.isEmpty(info.getId())) { |
|
|
|
|
R<Boolean> existResult = deviceClient.isDeviceCodeExist(em_info.getInfo().getNumber()); |
|
|
|
|
Assert.isTrue(existResult.isSuccess() && !existResult.getData(),() -> { |
|
|
|
|
throw new ServiceException("该设备编码在设备实例中找到对应记录,保存失败!"); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
// 验证设备编号是否已存在
|
|
|
|
|
EmInfoEntity emInfoEntity = this.baseMapper.selectEmInfoByCode(em_info.getInfo().getNumber()); |
|
|
|
|
Assert.isTrue(ObjectUtil.isEmpty(emInfoEntity),() -> { |
|
|
|
|
throw new ServiceException("设备编号已存在"); |
|
|
|
|
}); |
|
|
|
|
// EmInfoEntity emInfoEntity = this.baseMapper.selectEmInfoByCode(em_info.getInfo().getNumber());
|
|
|
|
|
// Assert.isTrue(ObjectUtil.isEmpty(emInfoEntity),() -> {
|
|
|
|
|
// throw new ServiceException("设备编号已存在");
|
|
|
|
|
// });
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|