From 9ae0890dd74771ba9edd44d4830e0de37f8d9938 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 26 九月 2025 16:55:03 +0800
Subject: [PATCH] MES接口优化,老厂排程优化等
---
项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/MesProductService.cs | 584 ----------------------------------------------------------
1 files changed, 1 insertions(+), 583 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/MesProductService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/MesProductService.cs"
index d6adcc8..2189143 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/MesProductService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/MesProductService.cs"
@@ -7,7 +7,6 @@
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
-using WIDESEA_DTO.MES;
using WIDESEA_DTO;
using WIDESEA_Model.Models;
using WIDESEA_Core.Helper;
@@ -26,587 +25,6 @@
{
public partial class TaskService
{
- /// <summary>
- /// MES鎴愬搧鍏ュ簱鍗曟帴鏀�
- /// </summary>
- /// <returns></returns>
- public MesResponseContent BagInfoSync(MesBagInfoModel bagInfoModel)
- {
- MesResponseContent content = new MesResponseContent();
- try
- {
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == bagInfoModel.WarehouseCode);
- if (warehouse == null)
- {
- return content.Error("鏈壘鍒颁粨搴撲俊鎭�");
- }
- ////闄愬埗浠诲姟
- //Dt_Task task = BaseDal.QueryFirst(x => x.SourceAddress == bagInfoModel.WorkCenter && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Execute.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt()));
- //if (task!=null)
- //{
- // return content.Error($"绾夸綋瀛樺湪浠诲姟鎴栨墽琛屼腑,鑳舵鍙穥task.PalletCode}");
- //}
- Dt_Warehouse warehouseLocation = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA71.ToString());
- Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == warehouseLocation.WarehouseId);
- if (locationInfo == null)
- {
- return content.Error($"鏈壘鍒皗warehouse.WarehouseCode}璐т綅淇℃伅");
- }
- Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x=>x.PalletCode==bagInfoModel.BatchNo);
- if (proStockInfoOld != null)
- {
- return content.Error($"鑳舵{bagInfoModel.BatchNo}搴撳瓨淇℃伅宸插瓨鍦�");
- }
- //鍒ゆ柇璇ヨ兌妗嗗彿鐨勫唴鍖呬俊鎭槸鍚﹀瓨鍦�
- Dt_MesProInOrder mesProInOrderOld = BaseDal.Db.Queryable<Dt_MesProInOrder>().Where(x => x.BatchNo == bagInfoModel.BatchNo && x.MesProStatus == InOrderStatusEnum.鍏ュ簱涓�.ObjToInt()).Includes(x => x.Details).First();
- if (mesProInOrderOld!=null)
- {
- return content.Error($"鑳舵{bagInfoModel.BatchNo}鍐呭寘淇℃伅鏈畬鎴�");
- }
- List<string> proDetailsExists = _stockRepository.ProStockInfoDetailRepository.QueryData().Select(x=>x.BagNo).ToList();
- //鍐呭寘淇℃伅缁勭洏
- List<Dt_MesProInOrderDetail> mesProInOrderDetails = new List<Dt_MesProInOrderDetail>();
- string palletCode = @"^C\d{5}$"; // 姝e垯琛ㄨ揪寮�
- bool isValid = Regex.IsMatch(bagInfoModel.BatchNo, palletCode);
- if (!isValid && bagInfoModel.BatchNo.Substring(0,3).ToUpper()!= "CPK")
- {
- return content.Error($"妗嗙爜鏍煎紡閿欒{bagInfoModel.BatchNo}");
- }
- if (bagInfoModel.BatchNo.Substring(0, 3).ToUpper() == "CPK")
- {
- WebResponseContent inProRespone = InPKProStock(bagInfoModel, proDetailsExists, warehouse);
- if (!inProRespone.Status)
- {
- return content.Error(inProRespone.Message);
- }
- _proInStatisticsService.SaveStatic(bagInfoModel);
- return content.OK(inProRespone.Message);
- }
-
- foreach (var item in bagInfoModel.BagDetails)
- {
- if (proDetailsExists.Contains(item.BagNo))
- {
- return content.Error($"鍐呭寘{item.BagNo}宸插瓨鍦�");
- }
- foreach (var child in item.BagItems)
- {
- Dt_MesProInOrderDetail mesProInOrderDetail = new Dt_MesProInOrderDetail()
- {
- BagNo = item.BagNo,
- ProductCode = item.ProductCode,
- ProductVersion = item.ProductVersion,
- SETQty = child.SETQty,
- OKPCSQTY = child.OKPCSQTY,
- DateCode = item.DateCode,
- XQty = child.XQty,
- XSite = child.XSite,
- Weight = item.Weight,
- PackingDate = item.PackingDate,
- LotNumber = child.LotNumber,
- ERPOrder = child.ERPOrder,
- SaleOrder = child.SaleOrder,
- MoNumber = child.MoNumber,
- };
- mesProInOrderDetails.Add(mesProInOrderDetail);
- }
- }
- List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
- foreach (var item in mesProInOrderDetails)
- {
- proStockInfoDetails.Add(_mapper.Map<Dt_ProStockInfoDetail>(item));
- }
- Dt_MesProInOrder mesProInOrder = new Dt_MesProInOrder()
- {
- WarehouseId = warehouse.WarehouseId,
- ProInOrderNo = _outboundService.OutboundOrderService.CreateCodeByRule(nameof(RuleCodeEnum.ProInCodeRule)),
- BatchNo = bagInfoModel.BatchNo,
- WorkCenter = bagInfoModel.WorkCenter,
- MesProStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt(),
- UnPackStock = bagInfoModel.UnPackStock,
- CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(),
- Details = mesProInOrderDetails
- };
- ProStockAttributeEnum attributeEnum = new ProStockAttributeEnum();
- switch (warehouse.WarehouseCode)
- {
- case "HA71":
- attributeEnum = ProStockAttributeEnum.鎴愬搧;
- break;
- case "HA72":
- attributeEnum = ProStockAttributeEnum.灏炬暟;
- break;
- case "HA73":
- attributeEnum = ProStockAttributeEnum.鐮斿彂;
- break;
- default:
- throw new Exception("鏈壘鍒拌搴撳瓨灞炴��");
- }
- Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
- {
- PalletCode = bagInfoModel.BatchNo,
- PalletType = 1,
- ProStockAttribute= attributeEnum.ObjToInt(),
- WarehouseId = warehouse.WarehouseId,
- StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
- proStockInfoDetails = proStockInfoDetails
- };
- Dt_Task newTask = new Dt_Task()
- {
- CurrentAddress = bagInfoModel.WorkCenter,
- Grade = 0,
- NextAddress = "",
- PalletCode = proStockInfo.PalletCode,
- Roadway = locationInfo.RoadwayNo,
- SourceAddress = bagInfoModel.WorkCenter,
- TargetAddress = "",
- TaskType = TaskTypeEnum.InProduct.ObjToInt(),
- TaskStatus = TaskStatusEnum.New.ObjToInt(),
- WarehouseId = warehouse.WarehouseId,
- PalletType = proStockInfo.PalletType,
- MaterielCode = proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.ProductCode,
- Quantity = (float)proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty)
- };
- _unitOfWorkManage.BeginTran();
- int taskId = BaseDal.AddData(newTask);
- newTask.TaskId = taskId;
- Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
- //涓婁紶ERP
- WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder);
- _proInStatisticsService.SaveStatic(bagInfoModel);
- if (!responseContent.Status)
- {
- mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt();
- mesProInOrder.Remark = responseContent.Message;
- }
- else
- {
- mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt();
- }
- Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand();
- _unitOfWorkManage.CommitTran();
- //鎺ㄩ�佷换鍔�
- PushTasksToWCS(new List<Dt_Task> { newTask });
- content.OK("鎺ユ敹鎴愬姛");
- }
- catch (Exception ex)
- {
- _unitOfWorkManage.RollbackTran();
- content.Error(ex.Message);
- }
- return content;
- }
- public WebResponseContent InPKProStock(MesBagInfoModel bagInfoModel, List<string> proDetailsExists,Dt_Warehouse wareSource)
- {
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseCode==WarehouseEnum.HA101.ToString());
- if (warehouse==null)
- {
- return WebResponseContent.Instance.Error("鏈壘鍒板钩搴撲粨搴撲俊鎭�");
- }
- //鍐呭寘淇℃伅缁勭洏
- List<Dt_MesProInOrderDetail> mesProInOrderDetails = new List<Dt_MesProInOrderDetail>();
- foreach (var item in bagInfoModel.BagDetails)
- {
- if (proDetailsExists.Contains(item.BagNo))
- {
- return WebResponseContent.Instance.Error($"鍐呭寘{item.BagNo}宸插瓨鍦�");
- }
- foreach (var child in item.BagItems)
- {
- Dt_MesProInOrderDetail mesProInOrderDetail = new Dt_MesProInOrderDetail()
- {
- BagNo = item.BagNo,
- ProductCode = item.ProductCode,
- ProductVersion = item.ProductVersion,
- SETQty = child.SETQty,
- OKPCSQTY = child.OKPCSQTY,
- DateCode = item.DateCode,
- XQty = child.XQty,
- XSite = child.XSite,
- Weight = item.Weight,
- PackingDate = item.PackingDate,
- LotNumber = child.LotNumber,
- ERPOrder = child.ERPOrder,
- SaleOrder = child.SaleOrder,
- MoNumber = child.MoNumber,
- OverInQuantity= child.OKPCSQTY
- };
- mesProInOrderDetails.Add(mesProInOrderDetail);
- }
- }
- List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
- foreach (var item in mesProInOrderDetails)
- {
- proStockInfoDetails.Add(_mapper.Map<Dt_ProStockInfoDetail>(item));
- }
- Dt_MesProInOrder mesProInOrder = new Dt_MesProInOrder()
- {
- WarehouseId = warehouse.WarehouseId,
- ProInOrderNo = _outboundService.OutboundOrderService.CreateCodeByRule(nameof(RuleCodeEnum.ProInCodeRule)),
- BatchNo = bagInfoModel.BatchNo,
- WorkCenter = bagInfoModel.WorkCenter,
- MesProStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt(),
- UnPackStock = bagInfoModel.UnPackStock,
- CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(),
- Details = mesProInOrderDetails
- };
- ProStockAttributeEnum attributeEnum = new ProStockAttributeEnum();
- switch (wareSource.WarehouseCode)
- {
- case "HA71":
- attributeEnum = ProStockAttributeEnum.鎴愬搧;
- break;
- case "HA72":
- attributeEnum = ProStockAttributeEnum.灏炬暟;
- break;
- case "HA73":
- attributeEnum = ProStockAttributeEnum.鐮斿彂;
- break;
- default:
- throw new Exception("鏈壘鍒拌搴撳瓨灞炴��");
- }
- proStockInfoDetails.ForEach(x =>
- {
- x.ProOutDetailStatus = StockStatusEmun.骞冲簱鍏ュ簱瀹屾垚.ObjToInt();
- });
- Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
- {
- PalletCode = bagInfoModel.BatchNo,
- PalletType = 1,
- LocationCode= "鎴愬搧寰呭彂璐у尯",
- ProStockAttribute = attributeEnum.ObjToInt(),
- WarehouseId = warehouse.WarehouseId,
- StockStatus = StockStatusEmun.骞冲簱鍏ュ簱瀹屾垚.ObjToInt(),
- proStockInfoDetails = proStockInfoDetails
- };
-
- _unitOfWorkManage.BeginTran();
- Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
- //涓婁紶ERP
- WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder);
- if (!responseContent.Status)
- {
- mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt();
- mesProInOrder.Remark = responseContent.Message;
- }
- else
- {
- mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt();
- }
- Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand();
- _unitOfWorkManage.CommitTran();
- return WebResponseContent.Instance.OK("鎺ユ敹鎴愬姛");
- }
- /// <summary>
- /// 澶栧寘淇℃伅鎺ユ敹
- /// </summary>
- public MesResponseContent BoxStockin(MesBoxInfoModel boxInfoModel)
- {
- MesResponseContent content = new MesResponseContent();
- try
- {
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString());
- //鎴彇鍑哄簱鍗曞彿
- string shipmentOrder = boxInfoModel.ShipmentOrder.Substring(0, boxInfoModel.ShipmentOrder.IndexOf("-"));
- //鍒ゆ柇MES浼犲叆鐨勫嚭搴撳崟鍙锋槸鍚﹀瓨鍦�
- Dt_ProOutOrder proOutOrder = _outboundRepository.ProOutOrderRepository.Db.Queryable<Dt_ProOutOrder>().Where(x => x.ProOutOrderNo == shipmentOrder).Includes(x => x.Details).First();
- if (proOutOrder == null)
- {
- return content.Error($"鍗曞彿{shipmentOrder}涓嶅瓨鍦�");
- }
- //鍒ゆ柇澶栫鍙锋槸鍚﹀凡瀛樺湪
- Dt_ProStockInfo ProStockOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == boxInfoModel.BoxNo);
- if (ProStockOld!=null)
- {
- return content.Error($"澶栫鍙穥ProStockOld.PalletCode}瀛樺簱淇℃伅宸插瓨鍦�");
- }
- //鑾峰彇鎵�鏈夋垚鍝佸嚭搴撳唴鍖呬俊鎭�
- List<Dt_ProStockInfoDetail> dt_ProStockInfos = _stockRepository.ProStockInfoDetailRepository.QueryData(x => x.ProOutDetailStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt());
- //鑾峰彇MES鍐呭寘淇℃伅
- List<Dt_MesProInOrderDetail> mesProInOrderDetails = new List<Dt_MesProInOrderDetail>();
- foreach (var item in boxInfoModel.Bags)
- {
- foreach (var child in item.BagItems)
- {
- Dt_ProStockInfoDetail? proStockInfoDetail = dt_ProStockInfos.Where(x => x.BagNo == item.BagNo)?.FirstOrDefault();
- if (proStockInfoDetail == null)
- {
- return content.Error($"鍐呭寘{item.BagNo}璐х墿鐘舵�佸紓甯�");
- }
- if (proStockInfoDetail.OutboundQuantity<=0)
- {
- return content.Error($"鍐呭寘{item.BagNo}鍑哄簱鏁伴噺鏈垎閰�");
- }
- Dt_MesProInOrderDetail mesProInOrderDetail = new Dt_MesProInOrderDetail()
- {
- BagNo = item.BagNo,
- ProductCode = item.ProductCode,
- ProductVersion = item.ProductVersion,
- SETQty = child.SETQty,
- OKPCSQTY = child.OKPCSQTY,
- DateCode = item.DateCode,
- XQty = child.XQty,
- XSite = child.XSite,
- Weight = item.Weight,
- PackingDate = item.PackingDate,
- LotNumber = child.LotNumber,
- ERPOrder = child.ERPOrder,
- SaleOrder = child.SaleOrder,
- MoNumber = child.MoNumber,
- };
- mesProInOrderDetails.Add(mesProInOrderDetail);
- }
- }
- List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
- foreach (var item in mesProInOrderDetails)
- {
- proStockInfoDetails.Add(_mapper.Map<Dt_ProStockInfoDetail>(item));
- }
- proStockInfoDetails.ForEach(x =>
- {
- x.ProOutDetailStatus = StockStatusEmun.骞冲簱鍏ュ簱瀹屾垚.ObjToInt();
- });
-
-
- _unitOfWorkManage.BeginTran();
- WebResponseContent UnBindContent = _stockService.ProStockInfoService.UnBindStock(proStockInfoDetails);
- if (!UnBindContent.Status)
- {
- throw new Exception(UnBindContent.Message);
- }
- if (UnBindContent.Data!=null)
- {
- Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
- {
- PalletCode = boxInfoModel.BoxNo,
- PalletType = 0,
- LocationCode = "鎴愬搧寰呭彂璐у尯",
- WarehouseId = warehouse.WarehouseId,
- ShipmentOrder = shipmentOrder,
- StockStatus = StockStatusEmun.骞冲簱鍏ュ簱瀹屾垚.ObjToInt(),
- proStockInfoDetails = UnBindContent.Data as List<Dt_ProStockInfoDetail>,
- ProStockAttribute = ProStockAttributeEnum.鎴愬搧.ObjToInt()
- };
- //鏍规嵁澶栧寘淇℃伅瑙g粦鍐呭寘涓庤兌妗嗗簱瀛樺叧绯�
- Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
- }
- _unitOfWorkManage.CommitTran();
- return content.OK("澶栧寘鎺ユ敹鎴愬姛");
- }
- catch (Exception ex)
- {
- content.Error(ex.Message);
- }
- return content;
- }
- /// <summary>
- /// MES鎴愬搧鍑哄簱鍗曞悓姝ユ暟鎹鐞�
- /// </summary>
- public MesShipmentOrderSync MesOutSync(Dt_OutProStockInfo outProStockInfo, Dt_ProOutOrderDetail proOutOrderDetail,List<Dt_ProStockInfoDetail> proStockInfoDetails)
- {
- List<MesShipOrderDetail> mesShipOrderDetails = new List<MesShipOrderDetail>();
- //鑾峰彇鍑哄簱鍗�
- Dt_ProOutOrder proOutOrder = _outboundService.ProOutOrderService.Repository.QueryFirst(x => x.Id == proOutOrderDetail.ProOrderId);
- //鑾峰彇瀹㈡埛
- Dt_CustomerInfo customerInfo = _basicRepository.CustomerInfoRepository.QueryFirst(x => x.Code == proOutOrderDetail.EndCustomer);
- List<string> outBags = proStockInfoDetails.Where(x => x.OutboundQuantity > 0).Select(x => x.BagNo).ToList();
- outBags.ForEach(x =>
- {
- x = string.Format($"{0},{1},{2},0,{3}",x,outProStockInfo.PCode,outProStockInfo.DateCode,outProStockInfo.AssignQuantity.ObjToInt());
- });
- MesShipOrderDetail orderDetail = new MesShipOrderDetail()
- {
- ProductCode = proOutOrderDetail.PCode,
- ProductVersion = proOutOrderDetail.PVer,
- Qty = outProStockInfo.AssignQuantity,
- DateCode = outProStockInfo.DateCode,
- SaleOrder = proOutOrderDetail.SaleOrder,
- Sequence = outProStockInfo.Id,
- WorkCenter = "SPCK_OUTER-001",
- PlasticBox = new List<PlasticBox> { new PlasticBox()
- {
- PlasticBoxNumber= outProStockInfo.PalletCode,
- Insourcings = outBags
- }
- }
- };
- mesShipOrderDetails.Add(orderDetail);
- MesShipmentOrderSync shipmentOrderSync = new MesShipmentOrderSync()
- {
- ShipmentOrder = proOutOrder.ProOutOrderNo+"-"+ outProStockInfo.TaskNum,
- PlantShipDate = proOutOrder.PlantShipDate.ToString("yyyy-MM-dd HH:mm:ss"),
- Customer = proOutOrderDetail.EndCustomer,
- FactoryCode = proOutOrderDetail.FactoryCode,
- ShipName = customerInfo.Name,
- ShippingAddress = customerInfo.NickName,
- OrderDetails = mesShipOrderDetails
- };
- return shipmentOrderSync;
- }
- /// <summary>
- /// WMS鍚屾鎴愬搧鍑哄簱鑷矼ES
- /// </summary>
- public WebResponseContent ShipmentOrderSync(MesShipmentOrderSync model)
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMS_MES_ShipmentOrderSync.ToString());
- MESRoot<MesShipmentOrderSync> root = new MESRoot<MesShipmentOrderSync>()
- {
- From = "WMS",
- DateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- Content = model
- };
- JsonSerializerSettings settings = new JsonSerializerSettings
- {
- ContractResolver = new CamelCasePropertyNamesContractResolver()
- };
- string request = JsonConvert.SerializeObject(root, settings);
- string response = HttpMesHelper.Post(apiInfo.ApiAddress, request);
- MesResponseContent mesResponseContent = response.DeserializeObject<MesResponseContent>();
- //璋冪敤鎺ュ彛
- if (mesResponseContent.BSucc == true)
- {
- content.OK(mesResponseContent.StrMsg);
- }
- else
- {
- content.Error(mesResponseContent.StrMsg);
- }
- }
- catch (Exception ex)
- {
- content.Error(ex.Message);
- }
- return content;
- }
-
- /// <summary>
- /// MES鎴愬搧杩斿伐鎻愬簱
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- public MesResponseContent RworkTask(RworkTaskModel model)
- {
- MesResponseContent content = new MesResponseContent();
- try
- {
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString());
- if (warehouse == null)
- {
- return content.Error($"灏炬暟浠撲俊鎭湭閰嶇疆");
- }
- Dt_MesRworkOutboundOrder rworkOutboundOrderOld = _outboundRepository.RworkOutboundOrderRepository.QueryFirst(x => x.TaskNo == model.TaskNo);
- if (rworkOutboundOrderOld != null)
- {
- return content.Error($"鎻愬簱浠诲姟鍗晎model.TaskNo}宸插瓨鍦�");
- }
- Dt_MesRworkOutboundOrder mesRworkOutboundOrder = new Dt_MesRworkOutboundOrder()
- {
- WarehouseId = warehouse.WarehouseId,
- TaskNo = model.TaskNo,
- OrderStatus = OutOrderStatusEnum.鏈紑濮�.ObjToInt(),
- CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(),
- ProductCode = model.ProductCode,
- ProductName = model.ProductName,
- ProductVersion = model.ProductVersion,
- DateCode = model.DateCode,
- RequiredQuantity = model.RequiredQuantity,
- FactoryCode = model.FactoryCode,
- SaleOrder = model.SaleOrder,
- OrderType = model.InventoryType
- };
- List<Dt_Task> tasks = new List<Dt_Task>();
- List<Dt_ProStockInfo>? proStockInfos = null;
- List<Dt_OutProStockInfo>? outProStockInfos = null;
- List<Dt_LocationInfo>? locationInfos = null;
- //鍒嗛厤搴撳瓨鐢熸垚鎻愬簱浠诲姟
- (List<Dt_ProStockInfo>?, Dt_MesRworkOutboundOrder?, List<Dt_OutProStockInfo>?, List<Dt_LocationInfo>) result = _outboundService.RworkOutboundOrderService.AssignMesStocks(mesRworkOutboundOrder);
- if (result.Item1 != null && result.Item1.Count > 0)
- {
- tasks = GetTasks(result.Item1, TaskTypeEnum.OutMesRworkProduct);
- result.Item2.OrderStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
- result.Item3.ForEach(x =>
- {
- x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
- });
-
- proStockInfos = result.Item1;
- mesRworkOutboundOrder = result.Item2;
- outProStockInfos = result.Item3;
- locationInfos = result.Item4;
- }
- else
- {
- throw new Exception("鏃犲簱瀛樺垎閰�");
- }
- tasks.ForEach(x =>
- {
- x.TargetAddress = "5236";
- x.OrderNo = mesRworkOutboundOrder.TaskNo;
- });
- _unitOfWorkManage.BeginTran();
-
- int id = BaseDal.AddData(tasks);
- outProStockInfos.ForEach(x =>
- {
- x.OrderNo = mesRworkOutboundOrder.TaskNo;
- x.OrderDetailId = id;
- });
- if (proStockInfos != null && proStockInfos.Count > 0 && outProStockInfos != null && outProStockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0)
- {
- WebResponseContent updateContent = _outboundService.RworkOutboundOrderService.LockOutboundStockDataUpdate(proStockInfos, outProStockInfos, locationInfos, tasks: tasks);
-
- if (!updateContent.Status)
- {
- _unitOfWorkManage.RollbackTran();
- return content.Error(updateContent.Message);
- }
- }
- _outboundService.RworkOutboundOrderService.Repository.AddData(mesRworkOutboundOrder);
- _unitOfWorkManage.CommitTran();
- return content.OK("鎻愪緵杩斿簱鍗曟帴鏀舵垚鍔�");
- }
- catch (Exception ex)
- {
- _unitOfWorkManage.RollbackTran();
- content.Error(ex.Message);
- }
- return content;
- }
- #region 寮冪敤
- /// <summary>
- /// 搴撳瓨鏉挎暟鎹浆鎹�
- /// </summary>
- /// <returns></returns>
- //public MesProductOutBound MesProOutBound(Dt_MesRworkOutboundOrder mesRworkOutboundOrder,List<Dt_ProStockInfoDetail> proStockInfoDetails)
- //{
- // //鑾峰彇浠撳簱淇℃伅
- // Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == mesRworkOutboundOrder.WarehouseId);
- // List<MesInventoryInfo> inventoryInfos = new List<MesInventoryInfo>();
- // foreach (var item in proStockInfoDetails)
- // {
- // MesInventoryInfo mesInventoryInfo = new MesInventoryInfo()
- // {
- // Warhouseno = warehouse.WarehouseCode,
- // InternalPackageNumber = item.BagNo,
- // SetCount = (int)item.SETQty,
- // EligiblePcsCount = (int)item.StockPcsQty
- // };
- // inventoryInfos.Add(mesInventoryInfo);
- // }
- // MesProductOutBound mesProductOutBound = new MesProductOutBound()
- // {
- // TaskNo = mesRworkOutboundOrder.TaskNo,
- // ProductCode = mesRworkOutboundOrder.ProductCode,
- // ProductVersion = mesRworkOutboundOrder.ProductVersion,
- // DateCode = mesRworkOutboundOrder.DateCode,
- // SaleOrder = mesRworkOutboundOrder.SaleOrder,
- // InventoryInfo = inventoryInfos
- // };
- // return mesProductOutBound;
- //}
- #endregion
+
}
}
--
Gitblit v1.9.3