| | |
| | | |
| | | @Override |
| | | public void importExcel(List<StructureData> list) { |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return; |
| | | } |
| | | List<String> uinck = new ArrayList<>(); |
| | | for (StructureData data : list) { |
| | | Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, data.getFatherPartNo()).eq(Part::getEngChgLevel, data.getFatherVersion())); |
| | | if (part == null) { |
| | | throw new RuntimeException("零件号:" + data.getFatherPartNo() + "不存在"); |
| | | } |
| | | Structure structure = baseMapper.selectOne(Wrappers.<Structure>lambdaQuery() |
| | | .eq(Structure::getPartId, part.getId()) |
| | | .eq(Structure::getBomTypeDb, data.getStructureType()) |
| | | .eq(Structure::getAlternativeNo, data.getAlternativeNo())); |
| | | if (structure == null) { |
| | | structure = new Structure(); |
| | | structure.setPartId(part.getId()); |
| | | structure.setVersion(data.getFatherVersion()); |
| | | structure.setAlternativeDesc(data.getAlternativeDesc()); |
| | | structure.setActive(true); |
| | | structure.setBomTypeDb(data.getStructureType()); |
| | | structure.setIfsSync(false); |
| | | structure.setAlternativeNo(data.getAlternativeNo()); |
| | | baseMapper.insert(structure); |
| | | } |
| | | if (uinck.contains(structure.getId() + "_" + data.getLineItemNo())) { |
| | | throw new RuntimeException("零件号:" + part.getPartNo() + "行项号重复"); |
| | | } |
| | | Part childPart = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, data.getChildPartNo()).eq(Part::getEngChgLevel, data.getChildVersion())); |
| | | if (childPart == null) { |
| | | throw new RuntimeException("零件号:" + data.getChildPartNo() + "不存在"); |
| | | } |
| | | StructureComponent component = new StructureComponent(); |
| | | component.setStructureId(structure.getId()); |
| | | component.setPartId(childPart.getId()); |
| | | component.setPlanningMethod(childPart.getPlanningMethod()); |
| | | component.setQpa(new BigDecimal(data.getQpa())); |
| | | component.setLineItemNo(Integer.valueOf(data.getLineItemNo())); |
| | | component.setDiscNum(StringUtils.isEmpty(data.getDiskNum()) ? null : new Long(data.getDiskNum())); |
| | | //查询工序 如果有多个获取第一个 |
| | | List<Operation> operationList = operationMapper.selectList(Wrappers.<Operation>lambdaQuery() |
| | | .eq(Operation::getName, data.getOperationName()) |
| | | .eq(Operation::getActive, true).orderByAsc(Operation::getId)); |
| | | if (CollectionUtil.isEmpty(operationList)) { |
| | | throw new RuntimeException("工序" + data.getOperationName() + "不存在"); |
| | | } |
| | | component.setOperationId(operationList.get(0).getId()); |
| | | structureComponentMapper.insert(component); |
| | | uinck.add(structure.getId() + "_" + data.getLineItemNo()); |
| | | } |
| | | list.forEach(System.out::println); |
| | | System.out.println("================================"); |
| | | return; |
| | | //if (CollectionUtil.isEmpty(list)) { |
| | | // return; |
| | | //} |
| | | //List<String> uinck = new ArrayList<>(); |
| | | //for (StructureData data : list) { |
| | | // Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, data.getFatherPartNo()).eq(Part::getEngChgLevel, data.getFatherVersion())); |
| | | // if (part == null) { |
| | | // throw new RuntimeException("零件号:" + data.getFatherPartNo() + "不存在"); |
| | | // } |
| | | // Structure structure = baseMapper.selectOne(Wrappers.<Structure>lambdaQuery() |
| | | // .eq(Structure::getPartId, part.getId()) |
| | | // .eq(Structure::getBomTypeDb, data.getStructureType()) |
| | | // .eq(Structure::getAlternativeNo, data.getAlternativeNo())); |
| | | // if (structure == null) { |
| | | // structure = new Structure(); |
| | | // structure.setPartId(part.getId()); |
| | | // structure.setVersion(data.getFatherVersion()); |
| | | // structure.setAlternativeDesc(data.getAlternativeDesc()); |
| | | // structure.setActive(true); |
| | | // structure.setBomTypeDb(data.getStructureType()); |
| | | // structure.setIfsSync(false); |
| | | // structure.setAlternativeNo(data.getAlternativeNo()); |
| | | // baseMapper.insert(structure); |
| | | // } |
| | | // if (uinck.contains(structure.getId() + "_" + data.getLineItemNo())) { |
| | | // throw new RuntimeException("零件号:" + part.getPartNo() + "行项号重复"); |
| | | // } |
| | | // Part childPart = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, data.getChildPartNo()).eq(Part::getEngChgLevel, data.getChildVersion())); |
| | | // if (childPart == null) { |
| | | // throw new RuntimeException("零件号:" + data.getChildPartNo() + "不存在"); |
| | | // } |
| | | // StructureComponent component = new StructureComponent(); |
| | | // component.setStructureId(structure.getId()); |
| | | // component.setPartId(childPart.getId()); |
| | | // component.setPlanningMethod(childPart.getPlanningMethod()); |
| | | // component.setQpa(new BigDecimal(data.getQpa())); |
| | | // component.setLineItemNo(Integer.valueOf(data.getLineItemNo())); |
| | | // component.setDiscNum(StringUtils.isEmpty(data.getDiskNum()) ? null : new Long(data.getDiskNum())); |
| | | // //查询工序 如果有多个获取第一个 |
| | | // List<Operation> operationList = operationMapper.selectList(Wrappers.<Operation>lambdaQuery() |
| | | // .eq(Operation::getName, data.getOperationName()) |
| | | // .eq(Operation::getActive, true).orderByAsc(Operation::getId)); |
| | | // if (CollectionUtil.isEmpty(operationList)) { |
| | | // throw new RuntimeException("工序" + data.getOperationName() + "不存在"); |
| | | // } |
| | | // component.setOperationId(operationList.get(0).getId()); |
| | | // structureComponentMapper.insert(component); |
| | | // uinck.add(structure.getId() + "_" + data.getLineItemNo()); |
| | | //} |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public R fullSave(StructureDTO structure) { |
| | | System.out.println(structure); |
| | | System.out.println("==============================="); |
| | | int noCount = baseMapper.selectCount(Wrappers.<Structure>lambdaQuery() |
| | | .eq(Structure::getAlternativeNo, structure.getAlternativeNo()) |
| | | .eq(Structure::getBomTypeDb, structure.getBomTypeDb()) |
| | |
| | | structure.setIfsSync(false); |
| | | resetMaster(structure); |
| | | baseMapper.updateById(structure); |
| | | // 对接ifs |
| | | List<StructureDTO> structureDTOS = structureMapper.getStructureDtoByIds(Arrays.asList(structure.getId())); |
| | | structureIfsSyncByDto(structureDTOS); |
| | | //// 对接ifs |
| | | //List<StructureDTO> structureDTOS = structureMapper.getStructureDtoByIds(Arrays.asList(structure.getId())); |
| | | //structureIfsSyncByDto(structureDTOS); |
| | | return R.ok(); |
| | | } |
| | | |