From d8d129a2e41f7099968cb4f4dc1b028ab985135f Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期四, 16 十一月 2023 20:20:47 +0800
Subject: [PATCH] Changes14

---
 mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java |   93 +++++++++++++++++++---------------------------
 1 files changed, 39 insertions(+), 54 deletions(-)

diff --git a/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java b/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java
index 4fda2b9..348755a 100644
--- a/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java
+++ b/mes-plan/src/main/java/com/chinaztt/mes/plan/service/impl/CustomerOrderServiceImpl.java
@@ -5,7 +5,6 @@
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.IoUtil;
 import cn.hutool.core.util.BooleanUtil;
-import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpRequest;
 import com.alibaba.excel.EasyExcel;
@@ -37,7 +36,6 @@
 import com.chinaztt.mes.common.oa.OAResult;
 import com.chinaztt.mes.common.util.StateResult;
 import com.chinaztt.mes.common.util.WechatMsgTips;
-import com.chinaztt.mes.common.util.easyexcel.EasyExcelUtils;
 import com.chinaztt.mes.common.wechat.WechatProperty;
 import com.chinaztt.mes.plan.dto.*;
 import com.chinaztt.mes.plan.entity.*;
@@ -95,10 +93,10 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
-import org.springframework.util.Assert;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -196,7 +194,7 @@
 
 	private final static String AFFILIATED_CONTRACT = "涓ぉ娉ㄥ鍘�";
 
-
+	//private FileSaveUtil fileSaveUtil;
 
 	@Override
 	public void otcDownload(Long id, HttpServletResponse response) {
@@ -288,42 +286,17 @@
 
 
 	@Override
-	public R fullUpdate(CustomerOrderDTO customerOrderDTO) {
-		List<String> unitWhitMapList = customerOrderUnitWhiteListConfig.getUnitWhitListMap();
-		String unitConcat = customerOrderDTO.getOtcUnit() + "_" + customerOrderDTO.getIfsSalesUnit();
-		if (!customerOrderDTO.getOtcUnit().equals(customerOrderDTO.getIfsSalesUnit()) && !unitWhitMapList.contains(unitConcat)) {
-			//濡傛灉閿�鍞崟浣嶅拰ifs涓攢鍞崟浣嶄笉涓�鏍峰垯涓嶇粰淇濆瓨A
-			return R.failed("璁㈠崟琛岄攢鍞崟浣嶅拰閿�鍞欢閿�鍞閲忓崟浣嶄笉涓�鑷村苟涓旂櫧鍚嶅崟涓笉瀛樺湪瀵瑰簲鍏崇郴");
-		} else {
-			if (StringUtils.isNotBlank(customerOrderDTO.getPartNo())) {
-				Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, customerOrderDTO.getPartNo()));
-				if (null == part) {
-					throw new RuntimeException("鏍规嵁闆朵欢缂栧彿 = 銆�" + customerOrderDTO.getPartNo() + "銆慚ES鏈湴鏌ユ棤鍖归厤闆朵欢瀵硅薄");
-				}
-			}
-			if (StringUtils.isNotBlank(customerOrderDTO.getSalesPartNo())) {
-				Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, customerOrderDTO.getSalesPartNo()));
-				if (null == part) {
-					throw new RuntimeException("鏍规嵁閿�鍞欢缂栧彿 = 銆�" + customerOrderDTO.getSalesPartNo() + "銆慚ES鏈湴鏌ユ棤鍖归厤闆朵欢瀵硅薄");
-				}
-			}
-			// 濡傛灉閿�鍞浂浠跺彿鏈慨鏀癸紝otc鍚屾鐘舵�佷笉闇�瑕佹洿鏂�
-			CustomerOrder oriCustomerOrder = customerOrderMapper.selectById(customerOrderDTO.getId());
-			if (!org.apache.commons.lang3.StringUtils.equals(oriCustomerOrder.getSalesPartNo(),
-					customerOrderDTO.getSalesPartNo())) {
-				customerOrderDTO.setOtcPartSync(false);
-			}
-			//mes鏁伴噺 = 璁㈠崟鏁伴噺 * 鍥犲瓙
-			Assert.notNull(customerOrderDTO.getIfsConvFactor(), "璇烽�夋嫨閿�鍞浂浠跺彿");
-			customerOrderDTO.setBuyQtyDue(customerOrderDTO.getIfsConvFactor().multiply(customerOrderDTO.getOtcQuantity()));
-			if (BooleanUtil.isTrue(customerOrderDTO.getIsDocument())) {
-				customerOrderDTO.setCoState(CustomerOrderStateStringValues.PLAN);
-			} else {
-				customerOrderDTO.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
-			}
-			updateById(customerOrderDTO);
-			return R.ok();
-		}
+	public R fullUpdate(CustomerOrderVO1 customerOrderVO1) {
+		CustomerOrder customerOrder = new CustomerOrder();
+		BeanUtils.copyProperties(customerOrderVO1,customerOrder);
+		customerOrder.setId(customerOrderVO1.getId());
+		customerOrderMapper.updateById(customerOrder);
+
+		Customer customer = new Customer();
+		BeanUtils.copyProperties(customerOrderVO1,customer);
+		customer.setId(customerOrderMapper.selectById(customerOrderVO1.getId()).getCustomerId());
+		customerMapper.updateById(customer);
+		return R.ok("淇敼鎴愬姛!");
 	}
 
 	@Override
@@ -398,18 +371,28 @@
 			// }
 			//淇濆瓨涓荤敓浜ц鍒�
 			MasterProductionSchedule masterProductionSchedule = new MasterProductionSchedule();
+			//涓荤敓浜ц鍒掑彿
 			masterProductionSchedule.setMpsNo(scheduleNumberGenerator.generateNumberWithPrefix(MasterProductionSchedule.DIGIT, MasterProductionSchedule.PREFIX, MasterProductionSchedule::getMpsNo));
-			masterProductionSchedule.setPartId(customerOrderDTO.getPartId());
+			Part part = partMapper.selectOne(Wrappers.<Part>lambdaQuery().eq(Part::getPartNo, customerOrderDTO.getPartNo()));
+			//闆朵欢id
+			masterProductionSchedule.setPartId(part.getId());
 			//灏嗗鏍哥姸鎬佸拰宸ヨ壓鏂囦欢鐨刬d鍚屾缁欑敓浜ц鍒�
 			masterProductionSchedule.setIsAudit(customerOrderDTO.getIsAudit());
 			masterProductionSchedule.setTechnologyDocumentId(customerOrderDTO.getTechnologyDocumentId());
 			masterProductionSchedule.setManufactureAttr(customerOrderDTO.getManufactureAttr());
 			masterProductionSchedule.setDocNumber(customerOrderDTO.getDocNumber());
+			//闇�姹傛暟閲�
+			masterProductionSchedule.setQtyRequired(qta);
+			//闇�姹傛棩鏈�
+			masterProductionSchedule.setRequiredDate(customerOrderDTO.getDeliveryDate());
+			//澶囨敞
+			masterProductionSchedule.setRemark(customerOrderDTO.getRemark());
 			masterProductionSchedule.setQtyRequired(qta);
 			masterProductionSchedule.setRequiredDate(customerOrderDTO.getWantedDeliveryDate());
 			masterProductionSchedule.setRemark(customerOrderDTO.getRemark());
 			masterProductionSchedule.setSource("閿�鍞鍗�");
 			masterProductionScheduleMapper.insert(masterProductionSchedule);
+			customerOrderDTO.setRequireNumber(customerOrderDTO.getQtyPlaned());
 
 			// if (CollectionUtil.isNotEmpty(operationTaskProduceList)) {
 			// 	for (OperationTaskProduce operationTaskProduce : operationTaskProduceList) {
@@ -436,6 +419,7 @@
 		return true;
 	}
 
+	//澶氫釜閿�鍞鍗曞垱寤轰竴涓富鐢熶骇璁″垝
 	@Override
 	public MasterProductionSchedule createOneMasterProductionScheduleByCustomerOrders(List<CustomerOrderDTO> customerOrders) {
 		List<Long> ids = customerOrders.stream().map(CustomerOrderDTO::getId).collect(Collectors.toList());
@@ -597,17 +581,20 @@
 			return R.failed("宸ヨ壓鏂囦欢缂哄け");
 		}
 		List<CustomerOrder> customerOrderList = baseMapper.selectBatchIds(ids);
+		customerOrderList.forEach(l->{
+			log.info("鍏宠仈鏁版嵁==============================>"+l);
+		});
 		String msg = "";
 		for (CustomerOrder customerOrder : customerOrderList) {
 			if (BooleanUtil.isTrue(customerOrder.getIsDocument())) {
 				msg += customerOrder.getCustomerOrderNo() + "宸插叧鑱斿伐鑹烘枃浠讹紒";
 			}
-			if (StringUtils.isBlank(customerOrder.getSalesPartNo())) {
+			if (StringUtils.isBlank(customerOrder.getPartNo())) {
 				msg += customerOrder.getCustomerOrderNo() + "鏈�夋嫨閿�鍞欢锛�";
 			}
-			if (StringUtils.isBlank(customerOrder.getPartNo())) {
-				customerOrder.setPartNo(document.getPartNo());
-			}
+			//if (StringUtils.isBlank(customerOrder.getPartNo())) {
+			//	customerOrder.setPartNo(document.getPartNo());
+			//}
 			customerOrder.setIsDocument(true);
 			customerOrder.setCoState(CustomerOrderStateStringValues.PLAN);
 			customerOrder.setTechnologyDocumentId(docId);
@@ -697,9 +684,6 @@
 					.contentType("application/json")
 					.header("Authorization", "Bearer " + token).form(map).execute().body();
 			JSONObject result = JSONObject.parseObject(str);
-			//JSONArray jsonArray = result.getJSONArray("data");
-			//jsonArray.forEach();
-			//return null;
 			//涓昏〃鍙傛暟琛�
 			List<OrderParam> orderParams = orderParamService.list();
 			if (result.getInteger("code") == 0) {
@@ -824,7 +808,7 @@
 						customerOrder = new CustomerOrder();
 					}
 					//濡傛灉杩欎釜鍗曞瓙鍦∣TC涓彇娑堢姸鎬� 閭e氨鍒犻櫎
-					if (otcOrderStatus.equals("宸插彇娑�")) {
+					if (otcOrderStatus.equals(OTC_MAIN_STATUS_CANCEL)) {
 						if (customerOrder.getId() != null) {
 							baseMapper.deleteById(customerOrder.getId());
 						}
@@ -912,7 +896,7 @@
 						} else {
 							customerOrder.setCoState(CustomerOrderStateStringValues.PARTUNCHECKED);
 						}
-						if (org.apache.commons.lang3.StringUtils.equals("宸蹭笅杈�", otcMainStatus)) {
+						if (org.apache.commons.lang3.StringUtils.equals(OTC_MAIN_STATUS_TRANSMIT, otcMainStatus)) {
 							customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
 							customerOrder.setOtcPartSync(Boolean.TRUE);
 						}
@@ -921,8 +905,8 @@
 							customerOrder.setCoState(CustomerOrderStateStringValues.TECHNOLOGYUNCHECK);
 							customerOrder.setOtcPartSync(Boolean.TRUE);
 						}
-						//瀹℃牳鐘舵�佷负 01draft 鑽夌
-						customerOrder.setIsAudit(AuditStateStringValues.DRAFT);
+						//瀹℃牳鐘舵�佷负 03accepted 閫氳繃
+						customerOrder.setIsAudit(AuditStateStringValues.ACCEPTED);
 						baseMapper.insert(customerOrder);
 					}
 					addCustomerPara(customerJSONObject, customerOrderJSONObject, customerOrder, orderParamList);
@@ -1913,7 +1897,6 @@
 		try {
 			String path = FileSaveUtil.FILE_PATH + bucket;
 			InputStream inputStream = new FileInputStream(path);
-//			EasyExcel.write(path).sheet().doWrite(null);
 			response.setContentType("application/octet-stream; charset=UTF-8");
 			IoUtil.copy(inputStream, response.getOutputStream());
 		} catch (Exception e) {
@@ -1925,7 +1908,9 @@
 	public R deleteProcessConfigFile(Long id) {
 		try {
 			OrderProcessConfigFile configFile = orderProcessConfigFileMapper.selectById(id);
-			minioTemplate.removeObject(configFile.getBucketName(), configFile.getFileName());
+			String filePath=FileSaveUtil.FILE_PATH+"//"+configFile.getBucketName();
+			boolean del = FileUtil.del(new File(filePath));
+			//minioTemplate.removeObject(configFile.getBucketName(), configFile.getFileName());
 			orderProcessConfigFileMapper.deleteById(id);
 			processConfigFileOrderMappingMapper.delete(Wrappers.<ProcessConfigFileOrderMapping>lambdaQuery().eq(ProcessConfigFileOrderMapping::getConfigFileId, id));
 			return R.ok();

--
Gitblit v1.9.3