| | |
| | | // 真实的父节点 ID |
| | | Long realParentId; |
| | | for (ProductStructureDto psDto : flatDtoList) { |
| | | if (psDto.getId() == null && psDto.getParentTempId() != null) { |
| | | String parentTempId = psDto.getParentTempId(); |
| | | if (psDto.getId() == null && parentTempId != null && !parentTempId.isEmpty()) { |
| | | ProductStructure child = tempEntityMap.get(psDto.getTempId()); |
| | | if (tempEntityMap.containsKey(psDto.getParentTempId())) { |
| | | if (tempEntityMap.containsKey(parentTempId)) { |
| | | // 父节点是新节点 |
| | | realParentId = tempEntityMap.get(psDto.getParentTempId()).getId(); |
| | | realParentId = tempEntityMap.get(parentTempId).getId(); |
| | | } else { |
| | | // 父节点是老节点 |
| | | realParentId = Long.valueOf(psDto.getParentTempId()); |
| | | try { |
| | | realParentId = Long.valueOf(parentTempId); |
| | | } catch (NumberFormatException e) { |
| | | realParentId = 0L; |
| | | } |
| | | } |
| | | |
| | | child.setParentId(realParentId); |
| | | parentFixList.add(child); |
| | | } else if (psDto.getId() == null) { |
| | | // 如果 parentTempId 为空,则是顶级节点 |
| | | ProductStructure child = tempEntityMap.get(psDto.getTempId()); |
| | | child.setParentId(0L); |
| | | parentFixList.add(child); |
| | | } |
| | | } |
| | |
| | | if (!parentFixList.isEmpty()) { |
| | | this.updateBatchById(parentFixList); |
| | | } |
| | | |
| | | if (!updateList.isEmpty()) { |
| | | this.updateBatchById(updateList); |
| | | } |
| | |
| | | |
| | | |
| | | @Override |
| | | public List<ProductStructureDto> listBybomId(Integer bomId) { |
| | | List<ProductStructureDto> list = productStructureMapper.listBybomId(bomId); |
| | | public List<ProductStructureDto> listByBomId(Integer bomId) { |
| | | List<ProductStructureDto> list = productStructureMapper.listByBomId(bomId); |
| | | |
| | | Map<Long, ProductStructureDto> map = new HashMap<>(); |
| | | for (ProductStructureDto node : list) { |