From 4476740c214edb7ab667c48fcab00488fbdd9879 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期六, 15 十一月 2025 09:03:54 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs | 114 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 91 insertions(+), 23 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs"
index ddc6e54..33f0cd7 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs"
@@ -1,4 +1,5 @@
-锘縰sing System;
+锘縰sing Microsoft.AspNetCore.Http;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -34,40 +35,31 @@
/// <summary>
/// 鎷嗗寘鎷嗙鎿嶄綔
/// </summary>
- public async Task<WebResponseContent> SplitPackage(SplitPackageRequest request)
+ public async Task<WebResponseContent> SplitPackage(SplitPackageDto request)
{
try
{
_unitOfWorkManage.BeginTran();
// 1. 楠岃瘉鍑哄簱閿佸畾淇℃伅
- var lockInfo = await Db.Queryable<Dt_OutStockLockInfo>()
- .Where(x => x.Id == request.OutStockLockInfoId &&
- x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓�)
+ var lockInfo = await _stockInfoDetailService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderNo == request.OrderNo &&
+ x.PalletCode == request.PalletCode &&
+ x.CurrentBarcode == request.OriginalBarcode &&
+ x.Status == 0)
.FirstAsync();
if (lockInfo == null)
return WebResponseContent.Instance.Error("鏈壘鍒版湁鏁堢殑鍑哄簱閿佸畾淇℃伅");
-
- //// 2. 楠岃瘉褰撳墠鏉$爜鐨勫彲鐢ㄦ暟閲�
- //var currentStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
- // .Where(x => x.Barcode == lockInfo.CurrentBarcode &&
- // x.MaterielCode == request.MaterielCode &&
- // x.StockId == lockInfo.StockId)
- // .FirstAsync();
-
- //if (currentStockDetail == null)
- // return WebResponseContent.Instance.Error("褰撳墠鏉$爜鍦ㄥ簱瀛樹腑涓嶅瓨鍦�");
-
- //// 3. 妫�鏌ュ彲鐢ㄦ暟閲�
- //decimal availableQuantity = currentStockDetail.StockQuantity - currentStockDetail.OutboundQuantity;
- //if (request.SplitQuantity > availableQuantity)
- // return WebResponseContent.Instance.Error($"鎷嗗寘鏁伴噺涓嶈兘澶т簬鍙敤鏁伴噺锛屽彲鐢ㄦ暟閲忥細{availableQuantity}");
-
+
// 2. 妫�鏌ュ墿浣欓攣瀹氭暟閲�
decimal remainingLockQuantity = lockInfo.AssignQuantity - lockInfo.PickedQty;
if (request.SplitQuantity > remainingLockQuantity)
return WebResponseContent.Instance.Error($"鎷嗗寘鏁伴噺涓嶈兘澶т簬鍓╀綑閿佸畾鏁伴噺锛屽墿浣欙細{remainingLockQuantity}");
+
+ var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .Where(x => x.Barcode == request.OriginalBarcode)
+ .FirstAsync();
// 3. 鐢熸垚鏂版潯鐮�
string newBarcode = "";
@@ -109,9 +101,11 @@
OriginalBarcode = lockInfo.CurrentBarcode,
NewBarcode = newBarcode,
SplitQty = request.SplitQuantity,
- MaterielCode = request.MaterielCode,
+ RemainQuantity = lockInfo.RemainQuantity - request.SplitQuantity,
+ MaterielCode = lockInfo.MaterielCode,
SplitTime = DateTime.Now,
- Operator = request.Operator,
+ OrderNo = request.OrderNo,
+ PalletCode = request.PalletCode,
Status = (int)SplitPackageStatusEnum.宸叉媶鍖�
};
await Db.Insertable(splitHistory).ExecuteCommandAsync();
@@ -134,6 +128,80 @@
}
}
+ // 鎾ら攢鎷嗗寘
+ public async Task<WebResponseContent> RevertSplitPackage(string originalBarcode)
+ {
+ try
+ {
+ _unitOfWorkManage.BeginTran();
+ // 鏌ユ壘鏈�杩戠殑鏈挙閿�鎷嗗寘璁板綍
+ var splitPackage = await Db.Queryable<Dt_SplitPackageRecord>()
+ .Where(x => x.OriginalBarcode == originalBarcode && !x.IsReverted)
+ .OrderByDescending(x => x.CreateDate)
+ .FirstAsync();
+
+ if (splitPackage == null)
+ return WebResponseContent.Instance.Error("鏈壘鍒版媶鍖呰褰�");
+
+ // 妫�鏌ユ柊鏉$爜鏄惁宸叉嫞閫�
+ var newOutStockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.CurrentBarcode == splitPackage.NewBarcode)
+ .FirstAsync();
+
+ if (newOutStockInfo.Status == 1)
+ return WebResponseContent.Instance.Error("鏂版潯鐮佸凡鎷i�夛紝鏃犳硶鎾ら攢鎷嗗寘");
+
+ // 杩樺師鍘熷嚭搴撹鎯呮暟閲�
+ var originalOutStockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.CurrentBarcode == originalBarcode)
+ .FirstAsync();
+
+ originalOutStockInfo.AssignQuantity += splitPackage.SplitQty;
+ await _outStockLockInfoService.Db.Updateable(originalOutStockInfo).ExecuteCommandAsync();
+
+ // 鍒犻櫎鏂板嚭搴撹鎯呰褰�
+ await _outStockLockInfoService.Db.Deleteable<Dt_OutStockLockInfo>()
+ .Where(x => x.CurrentBarcode == splitPackage.NewBarcode)
+ .ExecuteCommandAsync();
+
+ // 鏍囪鎷嗗寘璁板綍涓哄凡鎾ら攢
+ splitPackage.IsReverted = true;
+ await Db.Updateable(splitPackage).ExecuteCommandAsync();
+
+ _unitOfWorkManage.CommitTran();
+ return WebResponseContent.Instance.OK("鎾ら攢鎷嗗寘鎴愬姛");
+
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"鎾ら攢鎷嗗寘澶辫触锛歿ex.Message}");
+ }
+ }
+
+ // 鑾峰彇鎷嗗寘淇℃伅
+ public async Task< WebResponseContent > GetSplitPackageInfo(string orderNo, string palletCode, string barcode)
+ {
+ var outStockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderNo == orderNo &&
+ x.PalletCode == palletCode &&
+ x.CurrentBarcode == barcode &&
+ x.Status == 0)
+ .FirstAsync();
+
+ if (outStockInfo == null)
+ return WebResponseContent.Instance .Error("鏈壘鍒板搴旂殑鍑哄簱淇℃伅");
+
+ var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .Where(x => x.Barcode == barcode)
+ .FirstAsync();
+
+ return WebResponseContent.Instance .OK("",new
+ {
+ MaterielCode = outStockInfo.MaterielCode,
+ RemainQuantity = outStockInfo.RemainQuantity,
+ Unit = "涓�" // 鏍规嵁瀹為檯鎯呭喌鑾峰彇鍗曚綅
+ });
+ }
/// <summary>
/// 鑾峰彇鍙媶鍖呯殑鍑哄簱閿佸畾淇℃伅
/// </summary>
--
Gitblit v1.9.3