From c378358dc38972fe6643cb0c2e3a68ce49b9f002 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期六, 11 一月 2025 14:01:37 +0800
Subject: [PATCH] 11
---
service/Warehouse/TransferOutManager.cs | 91 +++++++++++++++++----------------------------
1 files changed, 34 insertions(+), 57 deletions(-)
diff --git a/service/Warehouse/TransferOutManager.cs b/service/Warehouse/TransferOutManager.cs
index 2788646..0524c81 100644
--- a/service/Warehouse/TransferOutManager.cs
+++ b/service/Warehouse/TransferOutManager.cs
@@ -7,13 +7,13 @@
namespace NewPdaSqlServer.service.Warehouse;
/// <summary>
-/// 璋冩嫧鍑哄簱绠$悊绫�
-/// 璐熻矗澶勭悊璋冩嫧鍑哄簱鐩稿叧鐨勪笟鍔¢�昏緫
+/// 璋冩嫧鍑哄簱绠$悊绫�
+/// 璐熻矗澶勭悊璋冩嫧鍑哄簱鐩稿叧鐨勪笟鍔¢�昏緫
/// </summary>
public class TransferOutManager : Repository<TransferOut>
{
/// <summary>
- /// 鑾峰彇鏈畬鎴愮殑璋冩嫧鍑哄簱鍗曞彿鍒楄〃
+ /// 鑾峰彇鏈畬鎴愮殑璋冩嫧鍑哄簱鍗曞彿鍒楄〃
/// </summary>
/// <returns>鏈畬鎴愮殑璋冩嫧鍑哄簱鍗曞彿鍒楄〃</returns>
public List<string> GetTransferOutNoList()
@@ -28,8 +28,8 @@
.Select(g => new
{
pid = g.Key,
- sq = g.Sum(x => x.ShNum), // 鐢宠鏁伴噺鍚堣
- ys = g.Sum(x => x.YsNum) // 宸叉壂鏁伴噺鍚堣
+ sq = g.Sum(x => x.ShNum), // 鐢宠鏁伴噺鍚堣
+ ys = g.Sum(x => x.YsNum) // 宸叉壂鏁伴噺鍚堣
})
.Where(x => (x.sq ?? 0) != (x.ys ?? 0))
.Select(x => x.pid)
@@ -45,7 +45,7 @@
}
/// <summary>
- /// 鏍规嵁鍗曟嵁鍙疯幏鍙栧緟澶勭悊鐨勮皟鎷ㄥ嚭搴撴槑缁嗗垪琛�
+ /// 鏍规嵁鍗曟嵁鍙疯幏鍙栧緟澶勭悊鐨勮皟鎷ㄥ嚭搴撴槑缁嗗垪琛�
/// </summary>
/// <param name="query">鏌ヨ鍙傛暟,鍖呭惈鍗曟嵁鍙�</param>
/// <returns>寰呭鐞嗙殑璋冩嫧鍑哄簱鏄庣粏鍒楄〃</returns>
@@ -62,16 +62,16 @@
JoinType.Left, b.Pid == a.Guid,
JoinType.Left, b.ItemId == s.Id))
.Where((b, a, s) =>
- (b.ShNum ?? 0) - (b.YsNum ?? 0) > 0 // 鏈畬鎴愭暟閲忓ぇ浜�0
- && a.BillNo == p_bill_no // 鍖归厤鍗曟嵁鍙�
- && a.Status == 1) // 鍗曟嵁宸插鏍�
+ (b.ShNum ?? 0) - (b.YsNum ?? 0) > 0 // 鏈畬鎴愭暟閲忓ぇ浜�0
+ && a.BillNo == p_bill_no // 鍖归厤鍗曟嵁鍙�
+ && a.Status == 1) // 鍗曟嵁宸插鏍�
.OrderBy((b, a, s) => s.ItemNo)
.Select((b, a, s) => new TransferOutDetail
{
ItemNo = s.ItemNo,
ItemModel = s.ItemModel,
- ShNum = b.ShNum, // 鐢宠鏁伴噺
- YsNum = b.YsNum, // 宸叉壂鏁伴噺
+ ShNum = b.ShNum, // 鐢宠鏁伴噺
+ YsNum = b.YsNum, // 宸叉壂鏁伴噺
// 淇濈暀鍏朵粬蹇呰瀛楁...
Pid = b.Pid,
ItemId = b.ItemId,
@@ -83,7 +83,7 @@
}
/// <summary>
- /// 鎵弿鏉$爜杩涜璋冩嫧鍑哄簱澶勭悊
+ /// 鎵弿鏉$爜杩涜璋冩嫧鍑哄簱澶勭悊
/// </summary>
/// <param name="query">鍖呭惈鍗曟嵁鍙枫�佺敤鎴峰悕鍜屾潯鐮佷俊鎭殑鏌ヨ鍙傛暟</param>
/// <returns>澶勭悊鍚庣殑琛ㄥ崟鍜屽緟澶勭悊鏄庣粏鍒楄〃</returns>
@@ -94,23 +94,17 @@
var c_user = query.userName;
var p_item_barcode = query.barcode;
- var p_bill_type_id = 300; // 鍗曟嵁绫诲瀷ID
- var p_transaction_no = 301; // 浜ゆ槗缂栧彿
+ var p_bill_type_id = 300; // 鍗曟嵁绫诲瀷ID
+ var p_transaction_no = 301; // 浜ゆ槗缂栧彿
// 楠岃瘉鍗曟嵁鍙�
- if (string.IsNullOrEmpty(p_bill_no))
- {
- throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
- }
+ if (string.IsNullOrEmpty(p_bill_no)) throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
// 鏌ヨ鍑哄簱鍗曞苟楠岃瘉鐘舵��
var transferOut = Db.Queryable<TransferOut>()
.Where(x => x.BillNo == p_bill_no && x.Status == 1)
.First();
- if (transferOut == null)
- {
- throw new Exception("鏈壘鍒拌皟鎷ㄧ敵璇峰崟鎴栬�呰皟鎷ㄧ敵璇峰崟娌″鏍�");
- }
+ if (transferOut == null) throw new Exception("鏈壘鍒拌皟鎷ㄧ敵璇峰崟鎴栬�呰皟鎷ㄧ敵璇峰崟娌″鏍�");
// 鏌ヨ鏉$爜搴撳瓨淇℃伅骞堕獙璇�
var stock = Db.Queryable<MesInvItemStocks>()
@@ -118,42 +112,29 @@
&& x.Quantity > 0
&& !string.IsNullOrEmpty(x.DepotsCode))
.First();
- if (stock == null)
- {
- throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮侊紝璇锋牳瀵癸紒{p_item_barcode}");
- }
+ if (stock == null) throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮侊紝璇锋牳瀵癸紒{p_item_barcode}");
// 楠岃瘉浠撳簱涓�鑷存��
if (stock.DepotsCode != transferOut.InvCode)
- {
throw new Exception(
$"鏉$爜搴撳瓨浠撳簱{stock.DepotsCode}鍜岀敵璇蜂粨搴撲笉涓�鑷磠transferOut.InvCode}");
- }
// 鏌ヨ鐗╂枡淇℃伅
var item = Db.Queryable<MesItems>()
.Where(x => x.Id == stock.ItemId)
.First();
- if (item == null)
- {
- throw new Exception("鏈壘鍒扮墿鏂�");
- }
+ if (item == null) throw new Exception("鏈壘鍒扮墿鏂�");
// 鏌ヨ璋冩嫧鏄庣粏骞堕獙璇�
var detail = Db.Queryable<TransferOutDetail>()
.Where(x => x.ItemId == stock.ItemId && x.Pid == transferOut.Guid)
.First();
- if (detail == null)
- {
- throw new Exception("鏈壘鍒版潯鐮佺墿鏂欑浉搴旂殑璋冩嫧鐢宠");
- }
+ if (detail == null) throw new Exception("鏈壘鍒版潯鐮佺墿鏂欑浉搴旂殑璋冩嫧鐢宠");
// 楠岃瘉鏁伴噺鏄惁瓒呭嚭鏈壂鏁伴噺
if ((detail.ShNum ?? 0) - (detail.YsNum ?? 0) < stock.Quantity)
- {
throw new Exception("鏉$爜鏁伴噺澶т簬鐢宠鏈壂鏁伴噺锛岃鎷嗗垎浜嗗啀鎵爜");
- }
-
+
// 浣跨敤浜嬪姟澶勭悊鏁版嵁鏇存柊
UseTransaction(db =>
{
@@ -164,7 +145,7 @@
&& (x.Status ?? 0) == 0)
.First();
- var commit = 0; // 璁板綍鏇存柊鎿嶄綔娆℃暟
+ var commit = 0; // 璁板綍鏇存柊鎿嶄綔娆℃暟
var c_id = Guid.Empty;
// 澶勭悊绉诲簱涓昏〃璁板綍
@@ -241,7 +222,7 @@
SuppNo = stock.SuppNo,
ItemId = stock.ItemId,
EbelnK3id = stock.EbelnK3id,
- LineK3id = stock.LineK3id,
+ LineK3id = stock.LineK3id
// RkDepot = transferOut.RkDepot,
// CkDepot = transferOut.CkDepot
};
@@ -284,7 +265,7 @@
SuppNo = stock.SuppNo,
ItemId = (int)stock.ItemId,
EbelnK3id = stock.EbelnK3id,
- LineK3id = stock.LineK3id,
+ LineK3id = stock.LineK3id
// RkDepot = transferOut.RkDepot,
// CkDepot = transferOut.CkDepot
};
@@ -321,7 +302,7 @@
WorkLine = stock.WorkLine,
EbelnK3id = (int)stock.EbelnK3id,
LineK3id = (int)stock.LineK3id,
- Quantity = stock.Quantity,
+ Quantity = stock.Quantity
// Unit = stock.ItemUnit
};
@@ -342,35 +323,31 @@
.Where(x => x.Guid == detail.Guid)
.ExecuteCommand();
}
-
+
// 妫�鏌ユ槸鍚︽墍鏈夋槑缁嗛兘宸插畬鎴�
- var totals = db.Queryable<TransferOutDetail, TransferOut>((b, a) =>
- new JoinQueryInfos(JoinType.Left, b.Pid == a.Guid))
+ var totals = db.Queryable<TransferOutDetail, TransferOut>((b, a) =>
+ new JoinQueryInfos(JoinType.Left, b.Pid == a.Guid))
.Where((b, a) => a.BillNo == p_bill_no)
- .Select((b, a) => new {
- ShNum = SqlFunc.AggregateSum(b.ShNum), // 鐢宠鎬绘暟閲�
- YsNum = SqlFunc.AggregateSum(b.YsNum) // 宸叉壂鎬绘暟閲�
+ .Select((b, a) => new
+ {
+ ShNum = SqlFunc.AggregateSum(b.ShNum), // 鐢宠鎬绘暟閲�
+ YsNum = SqlFunc.AggregateSum(b.YsNum) // 宸叉壂鎬绘暟閲�
})
.First();
// 濡傛灉鐢宠鏁伴噺绛変簬宸叉壂鏁伴噺锛屾洿鏂板崟鎹畬鎴愮姸鎬�
if (totals.ShNum == totals.YsNum)
- {
commit += db.Updateable<TransferOut>()
.SetColumns(x => x.IsWc == 1)
.Where(x => x.BillNo == p_bill_no)
.ExecuteCommand();
- }
-
+
// 鏇存柊杩斿洖鍙傛暟
query.itemNo = item.ItemNo;
query.Num = stock.Quantity;
-
+
// 楠岃瘉鏇存柊鎿嶄綔鏄惁鍏ㄩ儴鎴愬姛
- if (commit < 4)
- {
- throw new Exception("鏇存柊澶辫触");
- }
+ if (commit < 4) throw new Exception("鏇存柊澶辫触");
return commit;
});
--
Gitblit v1.9.3