From 9a886d711d8b21adc335fdf8c39350584c7ba6fd Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 14 十月 2025 02:12:14 +0800
Subject: [PATCH] 更新代码,取消MES出库单号同步标识,平库转立库功能,寄售周期判断取消,精品标识等
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs | 165 +++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 137 insertions(+), 28 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs"
index a2e1a4c..7b1f8e9 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs"
@@ -20,6 +20,7 @@
using System.Text.RegularExpressions;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Core.CodeConfigEnum;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
namespace WIDESEA_TaskInfoService
{
@@ -29,7 +30,7 @@
/// MES鎴愬搧鍏ュ簱鍗曟帴鏀�
/// </summary>
/// <returns></returns>
- public MesResponseContent BagInfoSync(MesBagInfoModel bagInfoModel)
+ public MesResponseContent BagInfoSync(MesBagInfoModel bagInfoModel, string formSign = "")
{
MesResponseContent content = new MesResponseContent();
try
@@ -73,17 +74,19 @@
}
if (bagInfoModel.BatchNo.Substring(0, 3).ToUpper() == "CPK")
{
+ if (warehouse.WarehouseCode==WarehouseEnum.HA73.ToString())
+ {
+ return content.Error($"鐮斿彂浠撳睘鎬т笉鑳藉叆骞冲簱");
+ }
WebResponseContent inProRespone = InPKProStock(bagInfoModel, proDetailsExists, warehouse);
if (!inProRespone.Status)
{
return content.Error(inProRespone.Message);
}
+ _proInStatisticsService.SaveStatic(bagInfoModel);
return content.OK(inProRespone.Message);
}
- else if (isValid)
- {
-
- }
+
foreach (var item in bagInfoModel.BagDetails)
{
if (proDetailsExists.Contains(item.BagNo))
@@ -108,6 +111,7 @@
ERPOrder = child.ERPOrder,
SaleOrder = child.SaleOrder,
MoNumber = child.MoNumber,
+ IsFineWorks=item.IsFineWorks,
};
mesProInOrderDetails.Add(mesProInOrderDetail);
}
@@ -164,24 +168,31 @@
TaskType = TaskTypeEnum.InProduct.ObjToInt(),
TaskStatus = TaskStatusEnum.New.ObjToInt(),
WarehouseId = warehouse.WarehouseId,
- PalletType = proStockInfo.PalletType
+ 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),
+ BatchNo = proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.LotNumber,
};
_unitOfWorkManage.BeginTran();
int taskId = BaseDal.AddData(newTask);
newTask.TaskId = taskId;
Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
-
//涓婁紶ERP
- WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder);
- if (!responseContent.Status)
+ if (string.IsNullOrEmpty(formSign))
{
- mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt();
- mesProInOrder.Remark = responseContent.Message;
+ WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder);
+ if (!responseContent.Status)
+ {
+ //mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt();
+ //mesProInOrder.Remark = responseContent.Message;
+ throw new Exception(responseContent.Message);
+ }
+ else
+ {
+ mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt();
+ }
}
- else
- {
- mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt();
- }
+ _proInStatisticsService.SaveStatic(bagInfoModel);
Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand();
_unitOfWorkManage.CommitTran();
//鎺ㄩ�佷换鍔�
@@ -280,18 +291,19 @@
};
_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;
+ //mesProInOrder.UpErpStatus = WhetherEnum.False.ObjToInt();
+ //mesProInOrder.Remark = responseContent.Message;
+ return WebResponseContent.Instance.Error($"{responseContent.Message}");
}
else
{
mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt();
}
+ Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand();
_unitOfWorkManage.CommitTran();
return WebResponseContent.Instance.OK("鎺ユ敹鎴愬姛");
@@ -432,7 +444,7 @@
mesShipOrderDetails.Add(orderDetail);
MesShipmentOrderSync shipmentOrderSync = new MesShipmentOrderSync()
{
- ShipmentOrder = proOutOrder.ProOutOrderNo+"-"+ outProStockInfo.TaskNum,
+ ShipmentOrder = proOutOrder.ProOutOrderNo,
PlantShipDate = proOutOrder.PlantShipDate.ToString("yyyy-MM-dd HH:mm:ss"),
Customer = proOutOrderDetail.EndCustomer,
FactoryCode = proOutOrderDetail.FactoryCode,
@@ -480,7 +492,44 @@
}
return content;
}
-
+ /// <summary>
+ /// WMS鍚屾鎴愬搧鍑哄簱鑷矼ES澶栧寘瑁呮満
+ /// </summary>
+ public WebResponseContent ShipmentOrderMESSync(MesShipmentOrderSync model)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.AnhuaitcShipmentOrderSync.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>
@@ -491,7 +540,7 @@
MesResponseContent content = new MesResponseContent();
try
{
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA72.ToString());
+ Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == model.WarehouseCode);
if (warehouse == null)
{
return content.Error($"灏炬暟浠撲俊鎭湭閰嶇疆");
@@ -501,25 +550,68 @@
{
return content.Error($"鎻愬簱浠诲姟鍗晎model.TaskNo}宸插瓨鍦�");
}
+ //鐢熸垚鎻愬簱鍗�
Dt_MesRworkOutboundOrder mesRworkOutboundOrder = new Dt_MesRworkOutboundOrder()
{
WarehouseId = warehouse.WarehouseId,
TaskNo = model.TaskNo,
- OrderStatus = OutOrderStatusEnum.鏈紑濮�.ObjToInt(),
+ OrderStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt(),
CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(),
ProductCode = model.ProductCode,
- ProductName = model.ProductName,
+ ProductName = model.ProductCode,
ProductVersion = model.ProductVersion,
DateCode = model.DateCode,
RequiredQuantity = model.RequiredQuantity,
+ RequiredSetCount=model.RequiredSetCount,
FactoryCode = model.FactoryCode,
- SaleOrder = model.SaleOrder,
+ SaleOrder = model.SaleOrder ?? "",
OrderType = model.InventoryType
};
+ if (model.DateCode.IndexOf("骞冲簱")>0 || warehouse.WarehouseCode==WarehouseEnum.HA101.ToString())
+ {
+ Dt_Warehouse warehousePing = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString());
+ mesRworkOutboundOrder.WarehouseId = warehousePing.WarehouseId;
+ mesRworkOutboundOrder.OrderStatus = OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ _outboundService.RworkOutboundOrderService.Repository.AddData(mesRworkOutboundOrder);
+ MesInventoryInfo mesInventoryInfo = new MesInventoryInfo()
+ {
+ Warhouseno = warehousePing.WarehouseCode,
+ InternalPackageNumber = model.ProductCode,
+ SetCount = (int)model.RequiredSetCount,
+ EligiblePcsCount = (int)model.RequiredQuantity
+ };
+
+ MesProductOutBound mesProductOutBound = new MesProductOutBound()
+ {
+ TaskNo = mesRworkOutboundOrder.TaskNo,
+ ProductCode = mesRworkOutboundOrder.ProductCode,
+ ProductVersion = mesRworkOutboundOrder.ProductVersion,
+ DateCode = mesRworkOutboundOrder.DateCode,
+ SaleOrder = mesRworkOutboundOrder.SaleOrder,
+ InventoryInfo = new List<MesInventoryInfo> { mesInventoryInfo }
+ };
+ if (model.ReceiveDown==EnableEnum.Enable.ObjToInt())
+ {
+ _unitOfWorkManage.RollbackTran();
+ }
+ else
+ {
+ //MES鎴愬搧搴撳瓨鏉垮嚭搴撳悓姝�
+ WebResponseContent responseContentPing = _outboundService.RworkOutboundOrderService.ProductOutBoundSync(mesProductOutBound);
+ if (!responseContentPing.Status)
+ {
+ throw new Exception("鍚屾MES搴撳瓨鏉垮嚭搴撳け璐�,閿欒:" + responseContentPing.Message);
+ }
+ _unitOfWorkManage.CommitTran();
+ }
+ return content.OK($"鎻愪緵杩斿簱鍗曟帴鏀舵垚鍔�,ReceiveDown:{model.ReceiveDown}");
+ }
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_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
//鍒嗛厤搴撳瓨鐢熸垚鎻愬簱浠诲姟
(List<Dt_ProStockInfo>?, Dt_MesRworkOutboundOrder?, List<Dt_OutProStockInfo>?, List<Dt_LocationInfo>) result = _outboundService.RworkOutboundOrderService.AssignMesStocks(mesRworkOutboundOrder);
if (result.Item1 != null && result.Item1.Count > 0)
@@ -545,6 +637,10 @@
x.TargetAddress = "5236";
x.OrderNo = mesRworkOutboundOrder.TaskNo;
});
+ proStockInfos.ForEach(x =>
+ {
+ proStockInfoDetails.AddRange(x.proStockInfoDetails);
+ });
_unitOfWorkManage.BeginTran();
int id = BaseDal.AddData(tasks);
@@ -559,13 +655,26 @@
if (!updateContent.Status)
{
- _unitOfWorkManage.RollbackTran();
- return content.Error(updateContent.Message);
+ throw new Exception(updateContent.Message);
}
}
_outboundService.RworkOutboundOrderService.Repository.AddData(mesRworkOutboundOrder);
- _unitOfWorkManage.CommitTran();
- return content.OK("鎻愪緵杩斿簱鍗曟帴鏀舵垚鍔�");
+ if (model.ReceiveDown == EnableEnum.Enable.ObjToInt())
+ {
+ _unitOfWorkManage.RollbackTran();
+ }
+ else
+ {
+ //MES鎴愬搧搴撳瓨鏉垮嚭搴撳悓姝�
+ WebResponseContent responseContent = _outboundService.RworkOutboundOrderService.ProductOutBoundSync(_outboundService.RworkOutboundOrderService.MesProOutBound(mesRworkOutboundOrder, proStockInfoDetails));
+ if (!responseContent.Status)
+ {
+ throw new Exception("鍚屾MES搴撳瓨鏉垮嚭搴撳け璐�,閿欒:" + responseContent.Message);
+ }
+ _unitOfWorkManage.CommitTran();
+ PushTasksToWCS(tasks);
+ }
+ return content.OK($"鎻愪緵杩斿簱鍗曟帴鏀舵垚鍔�,ReceiveDown:{model.ReceiveDown}");
}
catch (Exception ex)
{
--
Gitblit v1.9.3