From 695571c6009ecbc12e7d4a4fb147df7967a1260e Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 07 七月 2025 20:21:19 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesProductService.cs | 245 ++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 224 insertions(+), 21 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 7bede87..8f54ef4 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"
@@ -15,6 +15,12 @@
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using WIDESEA_Common.APIEnum;
+using System.Reflection.Metadata;
+using Microsoft.Extensions.FileSystemGlobbing.Internal;
+using System.Text.RegularExpressions;
+using WIDESEA_Common.CommonEnum;
+using WIDESEA_Core.CodeConfigEnum;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
namespace WIDESEA_TaskInfoService
{
@@ -34,6 +40,12 @@
{
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)
@@ -54,6 +66,23 @@
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))
@@ -90,6 +119,7 @@
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(),
@@ -133,13 +163,28 @@
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)
};
_unitOfWorkManage.BeginTran();
int taskId = BaseDal.AddData(newTask);
newTask.TaskId = taskId;
- Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand();
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;
+ throw new Exception(responseContent.Message);
+ }
+ else
+ {
+ mesProInOrder.UpErpStatus = WhetherEnum.True.ObjToInt();
+ }
+ Db.InsertNav(mesProInOrder).Include(x => x.Details).ExecuteCommand();
_unitOfWorkManage.CommitTran();
//鎺ㄩ�佷换鍔�
PushTasksToWCS(new List<Dt_Task> { newTask });
@@ -151,6 +196,108 @@
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();
+ //涓婁紶ERP
+ WebResponseContent responseContent = _inboundOrderService.FeedbackProIn(mesProInOrder);
+ if (!responseContent.Status)
+ {
+ //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("鎺ユ敹鎴愬姛");
}
/// <summary>
/// 澶栧寘淇℃伅鎺ユ敹
@@ -188,6 +335,10 @@
{
return content.Error($"鍐呭寘{item.BagNo}璐х墿鐘舵�佸紓甯�");
}
+ if (proStockInfoDetail.OutboundQuantity<=0)
+ {
+ return content.Error($"鍐呭寘{item.BagNo}鍑哄簱鏁伴噺鏈垎閰�");
+ }
Dt_MesProInOrderDetail mesProInOrderDetail = new Dt_MesProInOrderDetail()
{
BagNo = item.BagNo,
@@ -218,24 +369,29 @@
x.ProOutDetailStatus = StockStatusEmun.骞冲簱鍏ュ簱瀹屾垚.ObjToInt();
});
- Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
- {
- PalletCode = boxInfoModel.BoxNo,
- PalletType = 0,
- LocationCode="鎴愬搧寰呭彂璐у尯",
- WarehouseId = warehouse.WarehouseId,
- ShipmentOrder = shipmentOrder,
- StockStatus = StockStatusEmun.骞冲簱鍏ュ簱瀹屾垚.ObjToInt(),
- proStockInfoDetails = proStockInfoDetails
- };
+
_unitOfWorkManage.BeginTran();
- //鏍规嵁澶栧寘淇℃伅瑙g粦鍐呭寘涓庤兌妗嗗簱瀛樺叧绯�
WebResponseContent UnBindContent = _stockService.ProStockInfoService.UnBindStock(proStockInfoDetails);
if (!UnBindContent.Status)
{
throw new Exception(UnBindContent.Message);
}
- Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
+ 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("澶栧寘鎺ユ敹鎴愬姛");
}
@@ -248,30 +404,40 @@
/// <summary>
/// MES鎴愬搧鍑哄簱鍗曞悓姝ユ暟鎹鐞�
/// </summary>
- public MesShipmentOrderSync MesOutSync(Dt_OutProStockInfo outProStockInfo, Dt_ProOutOrderDetail proOutOrderDetail)
+ 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.Customer);
-
+ 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,
+ DateCode = outProStockInfo.DateCode,
SaleOrder = proOutOrderDetail.SaleOrder,
Sequence = outProStockInfo.Id,
- WorkCenter = "SPCK_OUTER-001"
+ 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.Customer,
+ Customer = proOutOrderDetail.EndCustomer,
FactoryCode = proOutOrderDetail.FactoryCode,
ShipName = customerInfo.Name,
ShippingAddress = customerInfo.NickName,
@@ -317,7 +483,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>
--
Gitblit v1.9.3