From 3c34085a21511610477f555cebf3f6fa42272402 Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期二, 07 十一月 2023 18:32:53 +0800 Subject: [PATCH] 产品结构导入数据 --- mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java | 45 +++++++++++++++++---------------------------- 1 files changed, 17 insertions(+), 28 deletions(-) diff --git a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java index 9acf37a..a6243fe 100644 --- a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java +++ b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java @@ -48,6 +48,7 @@ import com.chinaztt.ztt.common.core.util.R; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; @@ -260,51 +261,37 @@ 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())); + List<Part> parts = partMapper.selectList(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, data.getPartNo())); + Part part = parts.get(0); if (part == null) { - throw new RuntimeException("闆朵欢鍙�:" + data.getFatherPartNo() + "涓嶅瓨鍦�"); + throw new RuntimeException("闆朵欢鍙�:" + data.getPartNo() + "涓嶅瓨鍦�"); } - Structure structure = baseMapper.selectOne(Wrappers.<Structure>lambdaQuery() - .eq(Structure::getPartId, part.getId()) - .eq(Structure::getBomTypeDb, data.getStructureType()) - .eq(Structure::getAlternativeNo, data.getAlternativeNo())); + Structure structure = baseMapper.selectOne(Wrappers.<Structure>lambdaQuery().eq(Structure::getPartId, part.getId())); if (structure == null) { structure = new Structure(); + BeanUtils.copyProperties(data, structure); structure.setPartId(part.getId()); - structure.setVersion(data.getFatherVersion()); - structure.setAlternativeDesc(data.getAlternativeDesc()); structure.setActive(true); - structure.setBomTypeDb(data.getStructureType()); + structure.setBomTypeDb("M"); structure.setIfsSync(false); - structure.setAlternativeNo(data.getAlternativeNo()); + structure.setAlternativeNo("*"); 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())); + List<Part> childParts = partMapper.selectList(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, data.getSonPartNo())); + Part childPart = childParts.get(0); if (childPart == null) { - throw new RuntimeException("闆朵欢鍙�:" + data.getChildPartNo() + "涓嶅瓨鍦�"); + throw new RuntimeException("闆朵欢鍙�:" + data.getSonPartNo() + "涓嶅瓨鍦�"); } + List<Operation> operations = operationMapper.selectList(Wrappers.<Operation>lambdaQuery().eq(Operation::getName, data.getOperationName())); + Operation operation = operations.get(0); 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()); + component.setQpa(new BigDecimal(1));// todo: 浜у搧缁撴瀯瀵煎叆鏁伴噺,杩樼己涓�涓鍙� + component.setOperationId(operation.getId()); structureComponentMapper.insert(component); - uinck.add(structure.getId() + "_" + data.getLineItemNo()); } } @@ -353,6 +340,8 @@ @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()) -- Gitblit v1.9.3