From 2fb28b36f15de26249ae34160e1accf118c011c7 Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期五, 17 十一月 2023 16:47:17 +0800
Subject: [PATCH] Changes16

---
 mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/MasterProductionScheduleServiceImpl.java |   44 +++++++++++++++++++++++++++++++++++++-------
 1 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/MasterProductionScheduleServiceImpl.java b/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/MasterProductionScheduleServiceImpl.java
index 510d7b7..9ce7fc6 100644
--- a/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/MasterProductionScheduleServiceImpl.java
+++ b/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/MasterProductionScheduleServiceImpl.java
@@ -3,6 +3,7 @@
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.http.HttpRequest;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -28,12 +29,14 @@
 import com.chinaztt.mes.plan.state.masterproductionschedule.MasterProductionScheduleStateMachineConfig;
 import com.chinaztt.mes.plan.state.masterproductionschedule.constant.MasterProductionScheduleEvents;
 import com.chinaztt.mes.plan.state.masterproductionschedule.constant.MasterProductionScheduleStates;
+import com.chinaztt.mes.technology.dto.BomDTO;
+import com.chinaztt.mes.technology.dto.StructureTree;
 import com.chinaztt.mes.technology.entity.Document;
+import com.chinaztt.mes.technology.entity.JoinDocumentBomRouting;
 import com.chinaztt.mes.technology.entity.Routing;
 import com.chinaztt.mes.technology.entity.Structure;
-import com.chinaztt.mes.technology.mapper.DocumentMapper;
-import com.chinaztt.mes.technology.mapper.RoutingMapper;
-import com.chinaztt.mes.technology.mapper.StructureMapper;
+import com.chinaztt.mes.technology.mapper.*;
+import com.chinaztt.mes.technology.service.BomService;
 import com.chinaztt.mes.technology.service.DocumentService;
 import com.chinaztt.mes.technology.state.document.constant.DocumentStates;
 import com.chinaztt.ztt.admin.api.vo.TreeUtil;
@@ -88,6 +91,12 @@
 	private StateMachineFactory<MasterProductionScheduleStates, MasterProductionScheduleEvents> masterproductionscheduleStateMachineFactory;
 	private StateMachinePersister<MasterProductionScheduleStates, MasterProductionScheduleEvents, MasterProductionSchedule> persister;
 	private MoStructureComponentMapper moStructureComponentMapper;
+	private JoinDocumentBomRoutingMapper joinDocumentBomRoutingMapper;
+	private BomComponentMapper bomComponentMapper;
+	private BomService bomService;
+	private ProcurementPlanMapper procurementPlanMapper;
+	private RawMaterialMapper rawMaterialMapper;
+
 
 	@Override
 	public IPage<List<MasterProductionScheduleDTO>> getMasterProductionSchedulePage(Page page, QueryWrapper<MasterProductionScheduleDTO> masterProductionScheduleDTO) {
@@ -468,16 +477,19 @@
 	@Override
 	public boolean addPlanPurchasing(List<MasterProductionSchedule>masterProductionSchedules) {
 		masterProductionSchedules.forEach(p->{
+			System.out.println("----------------->"+p);
 			Long technologyDocumentId = p.getTechnologyDocumentId();
 			Document document = documentMapper.selectById(technologyDocumentId);
 			Long firstPart = document.getPartId();
+			JoinDocumentBomRouting joinDocumentBomRouting = joinDocumentBomRoutingMapper.selectOne(new QueryWrapper<JoinDocumentBomRouting>().lambda()
+					.eq(JoinDocumentBomRouting::getDocumentId, document.getId()).eq(JoinDocumentBomRouting::getPartId, firstPart));
+			BomDTO bomDtoById = bomService.getBomDtoById(joinDocumentBomRouting.getBomId());
+			StructureTree tree = bomDtoById.getTree();
+			BigDecimal total=p.getQtyRequired().multiply(tree.getOriginalQpa());
 			List<MoStructureComponent> moStructureComponents = moStructureComponentMapper.selectList(new QueryWrapper<MoStructureComponent>().lambda().eq(MoStructureComponent::getPlanManufacturingOrderId, p.getId()));
 			moStructureComponents.forEach(m->{
 				Part part = partMapper.selectById(m.getPartId());
-				String url="http://192.168.20.47:8008/PurchService.ashx?contract=ZTKJ&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_INVENTORY_INFO_STD&userId=7632&inAttr={\"LOCATION_NO\": \"1019\",\"PART_NO\":"+part.getPartNo()+"}";
-				String body = HttpRequest.get(url).execute().body();
-				JSONObject partInfo = JSONObject.parseObject(body);
-				log.info("搴撳瓨闆朵欢==================================>"+partInfo);
+
 			});
 		});
 		return false;
@@ -485,6 +497,24 @@
 
 
 
+	public void getPlanPurchase(List<StructureTree> children,List<ProcurementPlan> planList,BigDecimal originalQpa,long planId){
+		children.forEach(l->{
+			String url="http://192.168.20.47:8008/PurchService.ashx?contract=ZTKJ&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_INVENTORY_INFO_STD&userId=7632&inAttr={\"LOCATION_NO\": \"1019\",\"PART_NO\":"+l.getPartNo()+"}";
+			String body = HttpRequest.get(url).execute().body();
+			JSONObject result = JSONObject.parseObject(body);
+			log.info("搴撳瓨闆朵欢==================================>"+result);
+			JSONArray listInfo = result.getJSONArray("LIST_INFO");
+			listInfo.forEach(i->{
+				JSONObject data = JSONObject.parseObject(i.toString());
+				//Ifs褰撳墠闆朵欢搴撳瓨鏁伴噺
+				BigDecimal qtyOnhand = data.getBigDecimal("QTY_ONHAND");
+				//闇�瑕佺敓浜у灏戞暟閲�
+				BigDecimal multiply = l.getOriginalQpa().multiply(originalQpa);
+				BigDecimal subtract = qtyOnhand.subtract(multiply);
+				
+			});
 
+		});
+	}
 
 }

--
Gitblit v1.9.3