From 72390e0230b64cd43fedf0ba8e17aba097568a4a Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 26 六月 2025 16:36:13 +0800
Subject: [PATCH] 1
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs | 93 +++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 86 insertions(+), 7 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs"
index 4cd9c3e..d6d8d99 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs"
@@ -36,6 +36,81 @@
return BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).First(x => x.OrderNo == inboundOrderNo); ;
}
+ public WebResponseContent MaterielGroup(SaveModel saveModel)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var palletCode = saveModel.MainData["palletCode"].ToString();
+ if (string.IsNullOrEmpty(palletCode)) throw new Exception("鎵樼洏鍙蜂笉鍙负绌�");
+ var orderNo = saveModel.MainData["orderNo"].ToString();
+ if (string.IsNullOrEmpty(orderNo)) throw new Exception("鍗曞彿涓嶅彲涓虹┖");
+ var batchNo = saveModel.MainData["batchNo"].ToString();
+ if (string.IsNullOrEmpty(batchNo)) throw new Exception("鎵瑰彿涓嶅彲涓虹┖");
+ //var StationCode = saveModel.MainData["address"].ToString();
+ //if (string.IsNullOrEmpty(StationCode)) throw new Exception("鍦板潃涓嶅彲涓虹┖");
+
+ //Dt_RoadwayInfo roadwayInfo = _basicService.RoadwayInfoService.Repository.QueryFirst(x => x.InStationCode == StationCode) ?? throw new Exception("鏈壘鍒拌鍏ュ簱绔欏彴锛岃妫�鏌ュ熀纭�閰嶇疆淇℃伅!");
+ Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode);
+ if (stockInfo != null) throw new Exception($"鎵樼洏銆恵palletCode}銆戝凡瀛樺湪搴撳瓨淇℃伅");
+ stockInfo = new Dt_StockInfo();
+ stockInfo.Details = new List<Dt_StockInfoDetail>();
+ Dt_InboundOrder? inboundOrder = GetInboundOrder(orderNo);
+ if (inboundOrder == null) throw new Exception($"鏈壘鍒板崟鍙蜂负銆恵orderNo}銆戠殑鍏ュ簱鍗�");
+ Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.Where(x => x.BatchNo == batchNo).FirstOrDefault();
+ if (inboundOrderDetail == null) throw new Exception($"鍗曞彿銆恵orderNo}銆戠殑鍏ュ簱鍗曟湭鎵惧埌鎵瑰彿銆恵batchNo}銆�");
+ if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) throw new Exception($"鍗曞彿銆恵orderNo}銆戠殑鎵瑰彿銆恵batchNo}銆戝彲缁勭洏鏁伴噺涓嶈冻");
+
+ #region 澶勭悊鍏ュ簱鍗�
+ inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱涓�.ObjToInt();
+ inboundOrderDetail.ReceiptQuantity++;
+ inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
+ #endregion
+
+ #region 娣诲姞搴撳瓨
+ if (stockInfo.Id == 0)
+ {
+ stockInfo.PalletCode = palletCode;
+ stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
+ stockInfo.Creater = "System";
+ stockInfo.Remark = "浜哄伐缁勭洏鍏ュ簱";
+ }
+ Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
+ {
+ Status = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+ OrderNo = inboundOrder.OrderNo,
+ StockId = stockInfo.Id != 0 ? stockInfo.Id : 0,
+ MaterielName = inboundOrderDetail.MaterielName,
+ MaterielCode = inboundOrderDetail.MaterielCode,
+ BatchNo = inboundOrderDetail.BatchNo,
+ StockQuantity = 1,
+ SerialNumber = "",
+ Creater = "System"
+ };
+ stockInfo.Details.Add(stockInfoDetail);
+ #endregion
+ Db.Ado.BeginTran();
+ BaseDal.UpdateData(inboundOrder);
+ _inboundOrderDetailService.UpdateData(inboundOrderDetail);
+ _stockService.StockInfoService.AddMaterielGroup(stockInfo);
+ Db.Ado.CommitTran();
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ Db.Ado.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ public WebResponseContent QueryOrderDetailInfo(int pageNo, string orderNo)
+ {
+ WebResponseContent content = new WebResponseContent();
+ Dt_InboundOrder inboundOrder = GetInboundOrder(orderNo);
+ List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details;
+ content.OK(data: inboundOrderDetails);
+ return content;
+ }
/// <summary>
/// 缁勭洏
/// </summary>
@@ -58,6 +133,7 @@
Dt_StockInfo? stockInfo = _stockService.StockInfoService.GetStockByPalletCode(materielGroupDTO.PalletCode);
+ //if (stockInfo != null) throw new Exception($"鎵樼洏鍙枫�恵materielGroupDTO.PalletCode}銆戝凡瀛樺湪");
(bool, string, object?) result = CheckMaterielGroupParam(materielGroupDTO, matSerialNumberDTOs, materielInfos, materielCodes, inboundOrder, stockInfo);
if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
@@ -71,7 +147,8 @@
List<Dt_StockInfoDetail> stockInfoDetails = _mapper.Map<List<Dt_StockInfoDetail>>(matSerialNumberDTOs);
stockInfoDetails.ForEach(x =>
{
- x.Status = 0;
+ //x.Status = 0;
+ x.Status = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
x.OrderNo = inboundOrder.OrderNo;
x.MaterielName = materielInfos.FirstOrDefault(v => v.MaterielCode == x.MaterielCode)?.MaterielName ?? "";
x.StockId = stockInfo.Id != 0 ? stockInfo.Id : 0;
@@ -87,7 +164,13 @@
for (int i = 0; i < materielCodes.Count; i++)
{
decimal stockQuantity = stockInfoDetails.Where(x => x.MaterielCode == materielCodes[i]).Sum(x => x.StockQuantity);
- inboundOrderDetails.AddRange(_inboundOrderDetailService.UpdateReceiptQuantity(inboundOrder.Details.Where(x => x.MaterielCode == materielCodes[i]).ToList(), stockQuantity));
+ List<Dt_InboundOrderDetail> orderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCodes[i]).ToList();
+ if (orderDetails.Count > 0)
+ {
+ var OrderQuantity = orderDetails.Sum(x => x.OrderQuantity);
+ if (OrderQuantity < stockQuantity) throw new Exception("缁勭洏鏁伴噺瓒呭嚭鍗曟嵁鏁伴噺");
+ inboundOrderDetails.AddRange(_inboundOrderDetailService.UpdateReceiptQuantity(orderDetails, stockQuantity));
+ }
}
List<int> updateDetailIds = inboundOrderDetails.Select(x => x.Id).ToList();
if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null && inboundOrder.Details.FirstOrDefault(x => !updateDetailIds.Contains(x.Id) && x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null)
@@ -102,17 +185,13 @@
else if (inboundOrder.OrderStatus == InboundStatusEnum.鏈紑濮�.ObjToInt())
{
inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱涓�.ObjToInt();
- for (int i = 0; i < inboundOrderDetails.Count; i++)
- {
- _inboundOrderDetailService.Repository.DeleteAndMoveIntoHty(inboundOrderDetails[i], App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
- }
}
content = MaterielGroupUpdateData(inboundOrder, inboundOrderDetails, stockInfo);
}
catch (Exception ex)
{
- content = WebResponseContent.Instance.Error(ex.Message);
+ content.Error(ex.Message);
}
finally
{
--
Gitblit v1.9.3