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 |   70 ++++++++++++++++++++++++++++++++--
 1 files changed, 65 insertions(+), 5 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 8f1353b..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
@@ -1,7 +1,9 @@
 package com.chinaztt.mes.plan.service.impl;
 
 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;
@@ -27,19 +29,21 @@
 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.Operation;
+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;
 import com.chinaztt.ztt.common.core.util.R;
 import com.chinaztt.ztt.common.security.util.SecurityUtils;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.messaging.Message;
 import org.springframework.messaging.support.MessageBuilder;
@@ -50,7 +54,6 @@
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
-import java.time.format.DateTimeFormatter;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
@@ -63,6 +66,7 @@
  * @author cxf
  * @date 2020-09-21 14:42:39
  */
+@Slf4j
 @Service
 @AllArgsConstructor
 @Transactional(rollbackFor = Exception.class)
@@ -86,6 +90,13 @@
 	private StructureMapper structureMapper;
 	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) {
@@ -457,4 +468,53 @@
 		masterProductionScheduleDTO.setOutPutBatchList(operationTaskProduceList);
 		return masterProductionScheduleDTO;
 	}
+
+	/**
+	 * 娣诲姞閲囪喘璁″垝
+	 * @param masterProductionSchedules
+	 * @return
+	 */
+	@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());
+
+			});
+		});
+		return false;
+	}
+
+
+
+	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