From 940f06f6d8e5508f39bd7f8ce7791d60bfc0686c Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期二, 07 十一月 2023 14:11:21 +0800
Subject: [PATCH] Changes

---
 mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/BomServiceImpl.java |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 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 f5a24cb..cacfed0 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();
@@ -221,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());
@@ -263,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();
@@ -288,7 +296,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());
@@ -352,13 +362,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);
@@ -557,6 +570,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;
@@ -565,6 +579,7 @@
 		}
 		//鏍规嵁闆朵欢鎵惧埌缁撴瀯涓昏〃
 		List<Structure> structures = getRootNodes(partId, version, alternativeNo, bomType);
+		log.info("寰楀埌缁撴瀯=========銆�"+structures);
 		if (CollectionUtil.isNotEmpty(structures)) {
 			for (Structure structure : structures) {
 
@@ -598,6 +613,7 @@
 					}
 					// 濉厖child鑺傜偣鏁版嵁
 					StructureTree child = fillChildNode(parent, component, structure, part);
+					log.info("鑺傜偣鏁版嵁====================銆�"+child);
 					if (bomLayers == 999) {
 						getStructureByPartId(child, component.getPartId(), cache, "ALL", "ALL", bomType, bomLayers);
 						// 鍒ゆ柇鍒扮鍑犲眰浜嗭紝鍒堕�犵被鍨嬩负1-宸插埗閫狅紝璁″垝鏂规硶涓篜-铏氭嫙浠�

--
Gitblit v1.9.3