From 3059430a0db3f75426e435c06090358646fc3792 Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期四, 09 十一月 2023 09:11:17 +0800
Subject: [PATCH] Changes11

---
 mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/BomServiceImpl.java |   69 ++++++++++++++++++++++++++++++----
 1 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/BomServiceImpl.java b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/BomServiceImpl.java
index 8ed9c14..bb92df5 100644
--- a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/BomServiceImpl.java
+++ b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/BomServiceImpl.java
@@ -40,6 +40,7 @@
 import com.chinaztt.mes.technology.state.bom.constant.BomStates;
 import com.chinaztt.ztt.common.core.util.R;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.messaging.Message;
 import org.springframework.messaging.support.MessageBuilder;
@@ -66,6 +67,7 @@
 @Service
 @AllArgsConstructor
 @Transactional(rollbackFor = Exception.class)
+@Slf4j
 public class BomServiceImpl extends ServiceImpl<BomMapper, Bom> implements BomService {
 
 	private NumberGenerator<Bom> numberGenerator;
@@ -162,10 +164,13 @@
 			bom.setVersion(structure.getVersion());
 			bom.setAlternativeNo(structure.getAlternativeNo());
 			bom.setAlternativeDesc(structure.getAlternativeDesc());
-			StructureTree tree = getAllBomExt(bom, 998);
+			//log.info("绗竴灞�========================銆�"+bom);
+			StructureTree tree = getAllBomExt(bom, 999);
 			BomDTO bomDTO = new BomDTO();
 			BeanUtils.copyProperties(bom, bomDTO);
 			bomDTO.setTree(tree);
+			//BomDTO bomDTO = getBomDtoById(structure.getPartId());
+			log.info("bomDto============>"+bomDTO);
 			saveBom(bomDTO);
 		});
 		return R.ok();
@@ -184,6 +189,18 @@
 		bomComp.setPlanningMethod(structureTree.getPlanningMethod());
 		bomComp.setColor(structureTree.getColor());
 		bomComp.setOperationId(structureTree.getOperationId());
+
+		bomComp.setSharpenerNo(structureTree.getSharpenerNo());
+		bomComp.setCaveNum(structureTree.getCaveNum());
+		bomComp.setGramWeight(structureTree.getGramWeight());
+		bomComp.setGateGramWeight(structureTree.getGateGramWeight());
+		bomComp.setMoldingCycle(structureTree.getMoldingCycle());
+		bomComp.setMachine(structureTree.getMachine());
+		bomComp.setScale(structureTree.getScale());
+		bomComp.setDryingTime(structureTree.getDryingTime());
+		bomComp.setDryingTemperature(structureTree.getDryingTemperature());
+		bomComp.setPackingInfo(structureTree.getPackingInfo());
+
 		bomComponentMapper.insert(bomComp);
 		saveChildren(structureTree.getChildren(), bomComp.getId(), bom, structureTree.getPartId());
 	}
@@ -209,12 +226,14 @@
 			return;
 		}
 		Part parentPart = partMapper.selectById(parentPartId);
-		//"P" 铏氭嫙浠剁殑鎰忔�� 鍦ㄤ竴涓狟OM涓紝闄ゆ牴鑺傜偣澶栵紝鍏朵綑鑺傜偣鑻ヤ笉鏄櫄鎷熶欢锛堥浂浠躲�愯鍒掓柟娉曘�戜笉涓篜 鍜� K锛夛紝鍒欑姝负鍏跺鍔犲瓙浠躲��
-		if (!bom.getPartId().equals(parentPartId)) {
-			if (!"P".equals(parentPart.getPlanningMethod()) && !"K".equals(parentPart.getPlanningMethod())) {
-				throw new RuntimeException(parentPart.getPartNo() + parentPart.getPartName() + "涓洪潪铏氭嫙浠讹紝涓嶅彲娣诲姞瀛愪欢");
-			}
-		}
+		log.error("parentId=======>"+parentPartId);
+		log.error("bomParentId====>"+bom);
+		////"P" 铏氭嫙浠剁殑鎰忔�� 鍦ㄤ竴涓狟OM涓紝闄ゆ牴鑺傜偣澶栵紝鍏朵綑鑺傜偣鑻ヤ笉鏄櫄鎷熶欢锛堥浂浠躲�愯鍒掓柟娉曘�戜笉涓篜 鍜� K锛夛紝鍒欑姝负鍏跺鍔犲瓙浠躲��
+		//if (!bom.getPartId().equals(parentPartId)) {
+		//	if (!"P".equals(parentPart.getPlanningMethod()) && !"K".equals(parentPart.getPlanningMethod())) {
+		//		throw new RuntimeException(parentPart.getPartNo() + parentPart.getPartName() + "涓洪潪铏氭嫙浠讹紝涓嶅彲娣诲姞瀛愪欢");
+		//	}
+		//}
 		for (StructureTree child : children) {
 			BomComponent bomComp = new BomComponent();
 			bomComp.setQpa(child.getQpa());
@@ -227,6 +246,18 @@
 			bomComp.setOperationId(child.getOperationId());
 			bomComp.setPlanningMethod(child.getPlanningMethod());
 			bomComp.setDiscNum(child.getDiscNum());
+
+			bomComp.setSharpenerNo(child.getSharpenerNo());
+			bomComp.setCaveNum(child.getCaveNum());
+			bomComp.setGramWeight(child.getGramWeight());
+			bomComp.setGateGramWeight(child.getGateGramWeight());
+			bomComp.setMoldingCycle(child.getMoldingCycle());
+			bomComp.setMachine(child.getMachine());
+			bomComp.setScale(child.getScale());
+			bomComp.setDryingTime(child.getDryingTime());
+			bomComp.setDryingTemperature(child.getDryingTemperature());
+			bomComp.setPackingInfo(child.getPackingInfo());
+
 			bomComponentMapper.insert(bomComp);
 			saveChildren(child.getChildren(), bomComp.getId(), bom, child.getPartId());
 		}
@@ -239,6 +270,7 @@
 	 */
 	@Override
 	public StructureTree getAllBomExt(Bom bom, int bomLayers) {
+		log.info("鐢熸垚鏍�=======銆�");
 		Long partId = bom.getPartId();
 		String version = bom.getVersion();
 		String alternativeNo = bom.getAlternativeNo();
@@ -254,6 +286,7 @@
 		StructureTree root = getRootNode(partId);
 		//閫氳繃浜у搧缁撴瀯鏌ュ伐搴�
 		Map<Long, Integer> cache = new HashMap<>(80);
+
 		getStructureByPartId(root, partId, cache, version, alternativeNo, bomType, bomLayers);
 		return root;
 	}
@@ -264,7 +297,9 @@
 	 * @Date: 2022-06-01
 	 */
 	private StructureTree getRootNode(Long partId) {
+		log.info("鑾峰彇bom鏍硅妭鐐�====銆�"+partId);
 		Part part = partMapper.selectById(partId);
+		log.info("鐖剁骇闆朵欢====銆�"+part);
 		StructureTree root = new StructureTree();
 		root.setPartName(part.getPartName());
 		root.setPlanningMethod(part.getPlanningMethod());
@@ -328,13 +363,16 @@
 	@Override
 	public BomDTO getBomDtoById(Long id) {
 		Bom bom = baseMapper.selectById(id);
+		log.info("getBomDtoById=>>>"+bom);
 		//濡傛灉瀛樺湪鏈粦瀹氬伐搴忕殑 宸ヨ壓璺嚎 鍒欎細涓虹┖
 		List<StructureTree> nodes = baseMapper.getBomComponents4Tree(id);
 		if (CollectionUtil.isEmpty(nodes)) {
 			return null;
 		}
 		StructureTree root = nodes.stream().filter(e -> e.getParentId() == null || e.getParentId() == 0).findFirst().get();
+		log.info("root=======>"+root);
 		setChildren(root, nodes);
+		log.info("setChildren鍚�========銆�"+root);
 		Part part = partMapper.selectById(bom.getPartId());
 		BomDTO bomDto = new BomDTO();
 		BeanUtils.copyProperties(bom, bomDto);
@@ -533,6 +571,7 @@
 	 */
 	private void getStructureByPartId(StructureTree parent, Long partId, Map<Long, Integer> cache, String version,
 									  String alternativeNo, String bomType, int bomLayers) {
+		log.info("姣忓眰鏍�===================銆�"+parent);
 		Integer cycleCount = cache.get(partId) == null ? 0 : cache.get(partId);
 		if (cycleCount >= CYCLE_DEEP) {
 			return;
@@ -541,8 +580,21 @@
 		}
 		//鏍规嵁闆朵欢鎵惧埌缁撴瀯涓昏〃
 		List<Structure> structures = getRootNodes(partId, version, alternativeNo, bomType);
+		log.info("寰楀埌缁撴瀯=========銆�"+structures);
 		if (CollectionUtil.isNotEmpty(structures)) {
 			for (Structure structure : structures) {
+
+				parent.setSharpenerNo(structure.getSharpenerNo());
+				parent.setCaveNum(structure.getCaveNum());
+				parent.setGramWeight(structure.getGramWeight());
+				parent.setGateGramWeight(structure.getGateGramWeight());
+				parent.setMoldingCycle(structure.getMoldingCycle());
+				parent.setMachine(structure.getMachine());
+				parent.setScale(structure.getScale());
+				parent.setDryingTime(structure.getDryingTime());
+				parent.setDryingTemperature(structure.getDryingTemperature());
+				parent.setPackingInfo(structure.getPackingInfo());
+
 				// 鏌ヨBOM瀛愯妭鐐�
 				List<StructureComponent> components = structureComponentMapper.selectList(Wrappers.<StructureComponent>lambdaQuery().
 						eq(StructureComponent::getStructureId, structure.getId())
@@ -562,10 +614,11 @@
 					}
 					// 濉厖child鑺傜偣鏁版嵁
 					StructureTree child = fillChildNode(parent, component, structure, part);
+					log.info("鑺傜偣鏁版嵁====================銆�"+child);
 					if (bomLayers == 999) {
 						getStructureByPartId(child, component.getPartId(), cache, "ALL", "ALL", bomType, bomLayers);
 						// 鍒ゆ柇鍒扮鍑犲眰浜嗭紝鍒堕�犵被鍨嬩负1-宸插埗閫狅紝璁″垝鏂规硶涓篜-铏氭嫙浠�
-					} else if (bomLayers > 0 && (part.getMaterialType().equals("1") && !part.getPlanningMethod().equals(
+					} else if (bomLayers > 0 && (part.getMaterialType().equals("1") && part.getPlanningMethod().equals(
 							"A"))) {
 						getStructureByPartId(child, component.getPartId(), cache, "ALL", "ALL", bomType, bomLayers);
 					}

--
Gitblit v1.9.3