fix: 优化生成rptparamindex的报错信息

dev
huangfeng 1 year ago
parent 4a9d4df27c
commit fed269b70a

@ -205,36 +205,39 @@ public class ParamBindServiceImpl implements ParamBindService {
List<Modev> modevList = modevRepository.findByIcdidIsNotNull(); List<Modev> modevList = modevRepository.findByIcdidIsNotNull();
if (!CollectionUtils.isEmpty(modevList)) { if (!CollectionUtils.isEmpty(modevList)) {
for (Modev item : modevList) { for (Modev item : modevList) {
generateOne(item.getId(), item.getIcdid()); generateOne(item);
} }
} }
} }
private void generateOne(Integer eqmid, Integer icdid) throws Exception { private void generateOne(Modev item) throws Exception {
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(icdid); Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getIcdid());
if (!optionalInst.isPresent()) { if (!optionalInst.isPresent()) {
throw new Exception("未找到该ICD逻辑设备实例, eqmid=" + eqmid + ", icdid=" + icdid); throw new Exception("未找到该ICD逻辑设备实例, eqmid=" + item.getId() + ", icdid=" + item.getIcdid());
} }
IcdConfigTypeInst inst = optionalInst.get(); IcdConfigTypeInst inst = optionalInst.get();
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId()); Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
if (!optionalType.isPresent()) { if (!optionalType.isPresent()) {
throw new Exception("未找到该实例对应的ICD配置类型, icdid=" + icdid); throw new Exception("未找到该实例对应的ICD配置类型, icdid=" + item.getIcdid());
} }
IcdConfigType type = optionalType.get(); IcdConfigType type = optionalType.get();
String param = type.getIedName() + type.getLdeviceInst() + "/" + type.getLnClass() String param = type.getIedName() + type.getLdeviceInst() + "/" + type.getLnClass()
+ inst.getInst(); + inst.getInst();
List<IcdConfigTypeAtt> attList = attRepository.findByIcdConfigTypeId(type.getId()); List<IcdConfigTypeAtt> attList = attRepository.findByIcdConfigTypeId(type.getId());
for (IcdConfigTypeAtt att : attList) { for (IcdConfigTypeAtt att : attList) {
if (StringUtils.isNotBlank(att.getColName())) {
String paramindex = param + "$" + att.getLastName(); String paramindex = param + "$" + att.getLastName();
Optional<Rptparamindex> optionalRpt = rptparamindexRepository.findById(paramindex); Optional<Rptparamindex> optionalRpt = rptparamindexRepository.findById(paramindex);
if (!optionalRpt.isPresent()) { if (!optionalRpt.isPresent()) {
throw new Exception("未找到该Rptparamindex对象参引=" + paramindex); throw new Exception(item.getName() + "的字段" + att.getColName() + "对应的属性"
+ att.getDoName() + "未找到该Rptparamindex对象参引=" + paramindex);
} }
Rptparamindex rpt = optionalRpt.get(); Rptparamindex rpt = optionalRpt.get();
rpt.setTablename(type.getTableName()); rpt.setTablename(type.getTableName());
rpt.setColname(att.getColName()); rpt.setColname(att.getColName());
rpt.setEqmid(eqmid); rpt.setEqmid(item.getId());
rptparamindexRepository.save(rpt); rptparamindexRepository.save(rpt);
} }
} }
} }
}

Loading…
Cancel
Save