设备注册后校验模板参数修改及注册后插入检测点cs_line重复校验

This commit is contained in:
guofeihu
2024-06-14 10:02:31 +08:00
parent 563163a5af
commit 25b3da033a

View File

@@ -378,7 +378,11 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
Thread.sleep(1000);
List<CsModelDto> modelList = objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid));
if (CollUtil.isEmpty(modelList)){
throwExceptionAndLog(AccessResponseEnum.MODEL_ERROR, logDto);
try {
throwExceptionAndLog(AccessResponseEnum.MODEL_ERROR, logDto);
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
}
List<CsDataSet> list = csDataSetService.getDataSetData(modelList.get(0).getModelId());
list.forEach(item->{
@@ -388,7 +392,12 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
po.setStatus(1);
po.setClDid(item.getClDev());
po.setDeviceId(vo.getId());
csLinePoList.add(po);
//防止主键重复
QueryWrapper<CsLinePO> qw = new QueryWrapper();
qw.eq("line_id",po.getLineId());
if(csLineService.getBaseMapper().selectList(qw).isEmpty()){
csLinePoList.add(po);
}
});
csLineService.saveBatch(csLinePoList);
//2.生成装置和模板的关系表
@@ -419,7 +428,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
logDto.setResult(0);
logDto.setFailReason(e.getMessage());
csLogsFeignClient.addUserLog(logDto);
throw new BusinessException(e.getMessage());
throw new BusinessException(CommonResponseEnum.FAIL);
}
return "success";
} catch (BusinessException e) {
@@ -469,7 +478,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
throwExceptionAndLog(AccessResponseEnum.DEV_MODEL_NOT_FIND, logDto);
}
String devModel = dictData.getCode();
zhiLianRegister(nDid,"PQV-500");
zhiLianRegister(nDid,devModel);
}
private DeviceLogDTO createLogDto(String operate) {