From fd5a43c2e677740482b8d25195120ffa75c5ac77 Mon Sep 17 00:00:00 2001
From: yangpeixing <yangpeixing@hnkhzn.com>
Date: 星期一, 19 一月 2026 15:47:29 +0800
Subject: [PATCH] 1
---
WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs | 300 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 281 insertions(+), 19 deletions(-)
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs
index 153eb42..92a3b43 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs
@@ -37,6 +37,8 @@
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Inbound;
using static WIDESEA_Common.HouseInventoryIn;
+using static WIDESEA_Common.HouseSyncretism;
+using static WIDESEA_Common.InventoryAllocate;
using Parameter = WIDESEA_Common.Parameter;
namespace WIDESEA_InboundService
@@ -211,6 +213,7 @@
Wlstatus = (int)InventoryMaterialStatus.鍚堟牸,
Mgeneratetime = DateTime.Now,
WarehouseId = warehouse.WarehouseId,
+ System = inboundOrder.System,
Details = new List<Dt_StockInfoDetail>()
};
}
@@ -330,6 +333,205 @@
_stockRepository.StockInfoRepository.Db.UpdateNav(stockInfo).Include(x => x.Details, new UpdateNavOptions() { OneToManyInsertOrUpdate = true }).ExecuteCommand();
}
_inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetails);
+ _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+ _unitOfWorkManage.CommitTran();
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content = WebResponseContent.Instance.Error(ex.Message);
+ }
+ finally
+ {
+
+ }
+ return content;
+ }
+
+ //鑽按锛屼綆娓╀粨缁勭洏
+ public WebResponseContent NewMaterielGroup(SaveModel saveModel)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+
+ var orderNo = saveModel.MainData["orderNo"].ToString();
+ var palletCode = saveModel.MainData["palletCode"].ToString();
+ var warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
+ var Initiallife = saveModel.MainData["initiallife"].ObjToInt();
+ List<string> serialNumbers = new List<string>();
+ List<decimal> quantitys = new List<decimal>();
+ foreach (var item in saveModel.DelKeys)
+ {
+ string json = JsonConvert.SerializeObject(item);
+ Dictionary<string, object> delKeyDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
+
+
+ if (delKeyDict.TryGetValue("serialNumber", out object serialNumberObj))
+ {
+ string serialNumber = serialNumberObj?.ToString();
+ if (!string.IsNullOrEmpty(serialNumber))
+ {
+ serialNumbers.Add(serialNumber);
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error("serialNumber鐨勫�间负绌�");
+ }
+ }
+ if (delKeyDict.TryGetValue("quantity", out object quantityObj))
+ {
+ if (quantityObj == null)
+ {
+ return WebResponseContent.Instance.Error("鐗╂枡鏁伴噺鐨勫�间负绌�");
+ }
+ decimal quantity;
+ try
+ {
+ quantity = Convert.ToDecimal(quantityObj);
+ }
+ catch
+ {
+ return WebResponseContent.Instance.Error($"鐗╂枡鏁伴噺{quantityObj}鏃犳硶杞崲涓烘暟瀛�");
+ }
+ if (quantity <= 0)
+ {
+ return WebResponseContent.Instance.Error("鐗╂枡鏁伴噺蹇呴』澶т簬0");
+ }
+
+ quantitys.Add(quantity);
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error("缂哄皯鐗╂枡鏁伴噺瀛楁");
+ }
+ }
+ Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == warehouseId);
+ if (warehouse == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌浠撳簱淇℃伅");
+ }
+
+ Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderNo == orderNo && x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).First();
+ if (inboundOrder == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒板叆搴撳崟淇℃伅");
+ }
+ if (inboundOrder.Details == null || inboundOrder.Details.Count <= 0)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒板叆搴撳崟鏄庣粏淇℃伅");
+ }
+ List<MatSerNumAnalysisModel> models = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, serialNumbers);
+ //楠岃瘉鍒ゆ柇鏃堕棿鏍煎紡
+ WebResponseContent IsValidContent = IsValidMCDates(models);
+ if (!IsValidContent.Status)
+ {
+ return content.Error(IsValidContent.Message);
+ }
+
+ string materielCode = models.FirstOrDefault()?.MaterielCode ?? "";
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode);
+ if (materielInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌鐗╂枡鐨勪俊鎭�");
+ }
+
+ decimal beforeQuantity = 0;
+
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
+ if (stockInfo == null)
+ {
+ stockInfo = new Dt_StockInfo()
+ {
+ BatchNo ="",
+ PalletCode = palletCode,
+ PalletType = GetPalletType(warehouse, palletCode),//GetPalletType(warehouse, palletCode)
+ IsFull = true,
+ StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨,
+ Creater = "WMS",
+ CreateDate = DateTime.Now,
+ MaterialType = (int)InventoryMaterialType.鍘熸潗鏂�,
+ Materialweight = 0,
+ Wlstatus = (int)InventoryMaterialStatus.鍚堟牸,
+ Mgeneratetime = DateTime.Now,
+ WarehouseId = warehouse.WarehouseId,
+ System = inboundOrder.System,
+ Details = new List<Dt_StockInfoDetail>()
+ };
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error($"鎵樼洏鍙烽噸澶�,璇ユ墭鐩樺凡缁勮繃鐗╂枡");
+ }
+ List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>();
+ foreach (var model in models)
+ {
+
+ Dt_InboundOrderDetail notGroupDetail = new Dt_InboundOrderDetail();
+
+ notGroupDetail = inboundOrder.Details.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.BatchNo == model.LotNo).FirstOrDefault();
+
+ if (notGroupDetail == null)
+ {
+ return WebResponseContent.Instance.Error($"璇ョ墿鏂欏湪璇ュ叆搴撳崟涓凡鍏ㄩ儴缁勭洏瀹屾垚");
+ }
+ Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
+ {
+ MaterielCode = notGroupDetail.MaterielCode,
+ MaterielName = notGroupDetail.MaterielName,
+ OrderNo = inboundOrder.OrderNo,
+ BatchNo = notGroupDetail.BatchNo,
+ LinId = notGroupDetail.LinId,
+ StockQuantity = model.Quantity,
+ Status = (int)StockStatusEmun.缁勭洏鏆傚瓨,
+ Creater = "WMS",
+ CreateDate = DateTime.Now,
+ Id = notGroupDetail.LinId.ObjToInt(),
+ DeliveryNote = model.DeliveryNote,
+ SupplierBatch = notGroupDetail.SupplierBatch,
+ MaterieSpec = notGroupDetail.MaterieSpec,
+ OrinalLocation = notGroupDetail.OrinalLocation
+ };
+
+ if (stockInfo.Id > 0)
+ {
+ stockInfoDetail.StockId = stockInfo.Id;
+ }
+ stockInfo.Details.Add(stockInfoDetail);
+
+ stockInfoDetails.Add(stockInfoDetail);
+
+ decimal decimalReceiptQuantity = Convert.ToDecimal(notGroupDetail.ReceiptQuantity);
+ decimal decimalModelQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity);
+ decimal decimalOrderQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity);
+ decimalReceiptQuantity += model.Quantity;
+ // 妫�鏌ユ槸鍚﹁秴鍑鸿鍗曟暟閲�
+ if (decimalReceiptQuantity > decimalOrderQuantity)
+ {
+ return WebResponseContent.Instance.Error($"缁勭洏鏁伴噺婧㈠嚭{decimalReceiptQuantity - decimalOrderQuantity}");
+ }
+ // 杞洖float绫诲瀷瀛樺偍锛屼絾姣旇緝鍜岃绠楅兘浣跨敤decimal瀹屾垚
+ notGroupDetail.ReceiptQuantity = Convert.ToDecimal(decimalReceiptQuantity);
+ if (notGroupDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
+ {
+ notGroupDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
+ }
+ }
+
+ decimal totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity);
+
+ inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+
+ _unitOfWorkManage.BeginTran();
+ if (stockInfo.Id == 0)
+ {
+ _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand();
+ }
+ else
+ {
+ _stockRepository.StockInfoRepository.Db.UpdateNav(stockInfo).Include(x => x.Details, new UpdateNavOptions() { OneToManyInsertOrUpdate = true }).ExecuteCommand();
+ }
+ _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrder.Details);
_inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
_unitOfWorkManage.CommitTran();
content.OK();
@@ -522,6 +724,7 @@
Wlstatus = (int)InventoryMaterialStatus.鍚堟牸,
Mgeneratetime = DateTime.Now,
WarehouseId = warehouse.WarehouseId,
+ System = inboundOrder.System,
Details = new List<Dt_StockInfoDetail>()
};
}
@@ -663,32 +866,85 @@
var targetAddress = saveModel.MainData["targetAddress"];
Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == soussAddress).First();
- Dt_StockInfo stockInfo1 = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == targetAddress).First();
- Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == stockInfo1.WarehouseId);
- if (stockInfo == null || stockInfo1 == null)
+ Dt_StockInfo targetstockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == targetAddress).First();
+ Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == targetstockInfo.WarehouseId);
+ if (stockInfo == null || targetstockInfo == null)
{
throw new Exception("搴撳瓨鏈壘鍒版墭鐩樺彿");
}
+
+ var sameItems = from sourceItem in stockInfo.Details
+ join targetItem in targetstockInfo.Details
+ on new
+ {
+ sourceItem.BatchNo,
+ sourceItem.MaterielName,
+ sourceItem.MaterielCode
+ }
+ equals new
+ {
+ targetItem.BatchNo,
+ targetItem.MaterielName,
+ targetItem.MaterielCode
+ }
+ select new
+ {
+ SourceItem = sourceItem,
+ TargetItem = targetItem,
+ BatchNo = sourceItem.BatchNo,
+ MaterialCode = sourceItem.MaterielCode,
+ MaterialType = sourceItem.MaterielName
+ };
+
+ var matchedSourceItemIds = sameItems.Select(x => x.SourceItem.Id).ToList();
+
foreach (var item in stockInfo.Details)
{
- item.StockId = stockInfo1.Id;
+ if (!matchedSourceItemIds.Contains(item.Id))
+ {
+ item.StockId = targetstockInfo.Id;
+ }
+ }
+ var differentItems = stockInfo.Details
+ .Where(x => !matchedSourceItemIds.Contains(x.Id))
+ .ToList();
+ targetstockInfo.Details = targetstockInfo.Details
+ .Where(x => !matchedSourceItemIds.Contains(x.Id))
+ .Concat(differentItems)
+ .ToList();
+ if (warehouse.WarehouseCode == "SC02_CP")
+ {
+ warehouse.WarehouseCode = "SC01_CP";
+ }
+ if (warehouse.WarehouseCode == "SC02_BC")
+ {
+ warehouse.WarehouseCode = "SC01_BC";
}
var houseSyncretism = new HouseSyncretism
{
- ApiType = "AsnController",
- Method = "AsrsGroudingAsn",
- Parameters = new List<HouseSyncretism.data>
- {
- new HouseSyncretism.data
- {
- Lpn=stockInfo.PalletCode,
- MoveType=0,
- WareHouseCode=warehouse.WarehouseCode,
+ ApiType = "InventoryMoveController",
+ Method = "AsrsSubmitMoveDatas",
- }
+ Parameters = new List<HouseSyncretism.Parame>
+ {
+ new HouseSyncretism.Parame {
+ Value = stockInfo.Details.Select(g => new Parame.Syncretism
+ {
+ Lpn = stockInfo.PalletCode,
+ MoveType = 0,
+ WareHouseCode = warehouse.WarehouseCode,
+ ItemCode = g.MaterielCode,
+ MoveNumber = g.StockQuantity,
+ LotNo = g.BatchNo,
+ WipBatch = g.BatchNo,
+ LocationName = stockInfo.LocationCode,
+ TargetLocName = targetstockInfo.LocationCode,
+ TargetLpn = targetstockInfo.PalletCode,
+
+ }).ToList()
+ }
}
};
-
var authResult = AuthenticateWithWMS();
if (authResult.IsSuccess)
{
@@ -708,10 +964,15 @@
}
_unitOfWorkManage.BeginTran();
- stockInfo1.Details.AddRange(stockInfo.Details);
- _stockRepository.StockInfoRepository.UpdateData(stockInfo1);
- stockInfo.Details.Clear();
- _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ foreach (var sameItem in sameItems)
+ {
+ sameItem.TargetItem.StockQuantity += sameItem.SourceItem.StockQuantity;
+ _stockRepository.StockInfoDetailRepository.UpdateData(sameItem.TargetItem);
+ _stockRepository.StockInfoDetailRepository.DeleteData(sameItem.SourceItem);
+ }
+ _stockRepository.StockInfoRepository.UpdateData(targetstockInfo);
+ _stockRepository.StockInfoRepository.DeleteData(stockInfo);
+
_unitOfWorkManage.CommitTran();
webResponseContent = WebResponseContent.Instance.OK("鍚堟墭鎴愬姛");
}
@@ -1015,6 +1276,7 @@
if (inboundOrderDetailOld != null)
{
inboundOrderDetailOld.OrderQuantity += item.OrderQuantity;
+ inboundOrderDetailOld.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt();
_inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetailOld);
}
else
--
Gitblit v1.9.3