From 1d976f52878c9f776146502037377310921e5a21 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期四, 04 九月 2025 08:23:13 +0800
Subject: [PATCH] 1.携客云获取送货单优化
---
service/Warehouse/MesItemQtManager.cs | 171 ++++++++++++++++++++++++++++++++++----------------------
1 files changed, 103 insertions(+), 68 deletions(-)
diff --git a/service/Warehouse/MesItemQtManager.cs b/service/Warehouse/MesItemQtManager.cs
index fbac799..6fb9b43 100644
--- a/service/Warehouse/MesItemQtManager.cs
+++ b/service/Warehouse/MesItemQtManager.cs
@@ -1,8 +1,10 @@
锘縰sing NewPdaSqlServer.DB;
using NewPdaSqlServer.Dto.service;
using NewPdaSqlServer.entity;
+using NewPdaSqlServer.entity.Base;
using NewPdaSqlServer.util;
using SqlSugar;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace NewPdaSqlServer.service.Warehouse;
@@ -13,14 +15,33 @@
/// 鑾峰彇鏈畬鎴愮殑閫�鏂欏崟鍙峰垪琛�
/// </summary>
/// <returns>閫�鏂欏崟鍙峰垪琛�</returns>
- public List<string> GetPendingQtList()
- {
- return Db.Queryable<MesItemQt>()
- .Where(it =>
- (it.Qt015 ?? false) == true && (it.Qt014 ?? false) == false)
- .OrderByDescending(it => it.Qtck)
- .Select(it => it.Qtck)
- .ToList();
+ public dynamic GetPendingQtList(dynamic RequestInfo)
+ {
+ var orgId = RequestInfo.OrgId;
+
+ if (orgId == null)
+ throw new Exception("缁勭粐涓嶅瓨鍦紒");
+
+ // 鑾峰彇鏈畬鎴愮殑閫�鏂欏崟鍙峰垪琛�
+ var parameters = new[]
+ {
+ new SugarParameter("@pi_orgId", orgId),
+ new SugarParameter("@inP1", null),
+ new SugarParameter("@inP2", null),
+ new SugarParameter("@inP3", null),
+ new SugarParameter("@inP4", null)
+ };
+ try
+ {
+ // 杩斿洖鍗曞彿瀛楃涓插垪琛�
+ var blDetails = Db.Ado.SqlQuery<string>(
+ "EXEC prc_pda_qtck_list @pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters);
+ return blDetails;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"{ex.Message}");
+ }
}
/// <summary>
@@ -28,57 +49,47 @@
/// </summary>
/// <param name="query">浠撳簱鏌ヨ鍙傛暟锛屽寘鍚敤鎴峰悕鍜屽崟鎹彿</param>
/// <returns>寰呭鐞嗙殑閫�鏂欏崟鏄庣粏鍒楄〃</returns>
- public List<MesItemQtDatall> GetPendingQtList(WarehouseQuery query)
+ public dynamic GetPendingQtDetailList(dynamic query, dynamic RequestInfo)
{
- // 浠庢煡璇㈠弬鏁颁腑鑾峰彇鐢ㄦ埛鍚嶅拰鍗曟嵁鍙�
- var c_User = query.userName;
- var p_bill_no = query.billNo;
+ var orgId = RequestInfo.OrgId;
- // 鏍规嵁鍗曟嵁鍙锋煡璇㈤��鏂欏崟涓昏〃淇℃伅
- var mesItemQt = Db.Queryable<MesItemQt>()
- .Where(it => it.Qtck == p_bill_no)
- .First();
+ if (orgId == null)
+ throw new Exception("缁勭粐涓嶅瓨鍦紒");
- // 濡傛灉鏈壘鍒伴��鏂欏崟锛屾姏鍑哄紓甯�
- if (mesItemQt == null) throw new Exception($"鏈煡璇㈠埌姝ゅ叾浠栧叆搴撶敵璇峰崟 {p_bill_no}");
-
- // 妫�鏌ラ��鏂欏崟鐨勫鏍哥姸鎬�(Qt015)锛屾湭瀹℃牳鍒欐姏鍑哄紓甯�
- if (mesItemQt.Qt015 == false)
- throw new Exception($"鍏朵粬鍑哄簱鐢宠鍗� {p_bill_no} 鏈鏍革紝璇风‘璁わ紒");
-
- // 妫�鏌ラ��鏂欏崟鐨勫畬缁撶姸鎬�(Qt014)锛屽凡瀹岀粨鍒欐姏鍑哄紓甯�
- if (mesItemQt.Qt014 == true)
- throw new Exception($"鍏朵粬鍑哄簱鐢宠鍗� {p_bill_no} 宸插畬缁擄紝璇风‘璁わ紒");
-
- // 鑱旇〃鏌ヨ鑾峰彇鏈畬鎴愮殑鏄庣粏鍒楄〃
- // 鍏宠仈琛細
- // - MesItemQt: 閫�鏂欏崟涓昏〃(a)
- // - MesItemQtDatall: 閫�鏂欏崟鏄庣粏琛�(b)
- // - MesItems: 鐗╂枡鍩虹淇℃伅琛�(c)
- var pendingList = Db.Queryable<MesItemQt, MesItemQtDatall, MesItems>(
- (a, b, c) =>
- new JoinQueryInfos(
- JoinType.Left, a.Guid == b.QtGuid, // 涓昏〃鍜屾槑缁嗚〃閫氳繃Guid鍏宠仈
- JoinType.Left,
- b.ItemId == c.Id.ToString())) // 鏄庣粏琛ㄥ拰鐗╂枡琛ㄩ�氳繃ItemId鍏宠仈
- .Where((a, b, c) =>
- a.Qtck == p_bill_no && // 鍖归厤鍗曟嵁鍙�
- (b.Qd007 ?? 0) - (b.Qd008 ?? 0) >
- 0) // 璁″垝鏁伴噺鍑忓幓宸插畬鎴愭暟閲忓ぇ浜�0鐨勮褰�(鍗虫湭瀹屾垚鐨勮褰�)
- .OrderBy((a, b, c) => c.ItemNo) // 鎸夌墿鏂欑紪鍙锋帓搴�
- .Select((a, b, c) => new MesItemQtDatall
+ var parameters = new[]
+{
+ new SugarParameter("@billNo",query.billNo),
+ new SugarParameter("@pi_orgId", orgId),
+ new SugarParameter("@inP1", null),
+ new SugarParameter("@inP2", null),
+ new SugarParameter("@inP3", null),
+ new SugarParameter("@inP4", null)
+ };
+ try
+ {
+ List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>(
+ "EXEC prc_pda_qtck_detailList @billNo,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters);
+ var items = blDetails.Where(x => x.DSQty > 0).ToList(); // 寰呮壂鐗╂枡
+ var ysitems = blDetails.Where(x => x.SQty > 0).ToList(); // 宸叉壂鐗╂枡
+ return new
{
- Qd002 = b.Qd002, // 鏄庣粏琛屽彿
- Qt011 = a.Qt011, // 閫�鏂欏師鍥�
- ItemNo = c.ItemNo, // 鐗╂枡缂栧彿
- Qd007 = b.Qd007 ?? 0, // 璁″垝鏁伴噺
- Qd008 = b.Qd008 ?? 0 // 宸插畬鎴愭暟閲�
- })
- .ToList();
-
- return pendingList;
+ items = items,
+ ysitems = ysitems
+ };
+ }
+ catch (Exception ex)
+ {
+ // 淇濈暀鍘熸湁寮傚父澶勭悊閫昏緫
+ throw new Exception($"{ex.Message}");
+ }
}
+ /// <summary>
+ /// 鎵爜鍑哄簱
+ /// </summary>
+ /// <param name="query"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
public (WarehouseQuery form, List<MesItemQtDatall> item, string message)
OutScanBarcode(
WarehouseQuery query)
@@ -108,6 +119,9 @@
if (barcode == null)
throw new Exception($"mes涓笉瀛樺湪姝ゆ潯鐮�,璇锋牳瀵癸紒{p_item_barcode}");
+
+
+
// 鑾峰彇搴撳瓨淇℃伅
var stock = Db.Queryable<MesInvItemStocks>()
.Where(it => it.ItemBarcode == p_item_barcode && it.Quantity > 0)
@@ -135,16 +149,11 @@
// 鑾峰彇鍏朵粬鍑哄簱鍗曚俊鎭�
var mesItemQt = Db.Queryable<MesItemQt>()
- .Where(it => it.Qtck == p_bill_no)
+ .Where(it => it.Qtck == p_bill_no && it.Qt015 == true && it.Qt026 == true && it.Qt029 == true && it.Qt032 == true)
.First();
if (mesItemQt == null)
throw new Exception($"鍏朵粬鍑哄簱鐢宠鍗� {p_bill_no} 涓嶅瓨鍦紝璇风‘璁わ紒");
-
- // 妫�鏌ヤ粨搴撴槸鍚︿竴鑷�
- if (Convert.ToInt32(mesItemQt.Qt008) != stock.DepotId)
- throw new Exception(
- $"鎵爜鍑鸿揣浠撳簱id{mesItemQt.Qt008}涓庡叾浠栧嚭搴撶敵璇蜂粨搴搟stock.DepotId}涓嶄竴鑷达紝璇锋牳瀵癸紒");
// 鑾峰彇鍑哄簱鍗曟槑缁�
var qtDetail = Db.Queryable<MesItemQtDatall>()
@@ -154,6 +163,19 @@
.First();
if (qtDetail == null) throw new Exception("鎵爜鐗╂枡闈炴湰娆″嚭搴撶敵璇风墿鏂欙紝璇锋牳瀵癸紒");
+
+
+ if (mesItemQt.Qt014 == true)
+ throw new Exception($"鍏朵粬鍑哄簱鐢宠鍗� {p_bill_no} 宸插畬缁擄紝璇风‘璁わ紒");
+
+ // 妫�鏌ヤ粨搴撴槸鍚︿竴鑷�
+ if (qtDetail.DepotId != stock.DepotId)
+ throw new Exception(
+ $"鎵爜鍑鸿揣浠撳簱id{qtDetail.DepotId}涓庡叾浠栧嚭搴撶敵璇蜂粨搴搟stock.DepotId}涓嶄竴鑷达紝璇锋牳瀵癸紒");
+
+
+
+
// 妫�鏌ュ墿浣欐暟閲�
var remainingQty = (qtDetail.Qd007 ?? 0) - (qtDetail.Qd008 ?? 0);
@@ -183,6 +205,8 @@
var message =
$"璇风‘璁ゅ彂鏂欐暟閲忥紒锛佸凡甯﹀嚭婊¤冻鍏朵粬鍑哄簱鍗曠殑鍙戞枡鏁伴噺 {remainingQty} 纭鍚庤鐐瑰嚮鏉$爜鎷嗗垎";
+
+ throw new Exception($"鏉$爜鏁伴噺瓒呭嚭鍙戞枡鏁伴噺锛岃鎷嗗垎鍚庡啀鎵弿锛�");
query.itemNo = stock.ItemNo;
query.Num = stock.Quantity;
@@ -235,8 +259,8 @@
BillTypeId = p_bill_type_id,
TransactionNo = p_transaction_no,
DepotCode = stock.DepotsCode,
- DepotId = stock.DepotsId.HasValue
- ? (int)stock.DepotsId
+ DepotId = stock.DepotId.HasValue
+ ? (int)stock.DepotId
: null,
OutPart = mesItemQt.Qt012,
FType = 0,
@@ -270,7 +294,7 @@
// 妫�鏌ユ槸鍚﹀凡瀛樺湪鍑哄簱鐗╂枡璁板綍
var existingOutItem = Db.Queryable<MesInvItemOutItems>()
.Where(it =>
- it.ItemOutId == outId && it.ItemId == barcode.ItemId)
+ it.ItemOutId == outId && it.ItemId == barcode.ItemId && it.ItemDabid == qtDetail.Guid)
.First();
if (existingOutItem == null)
@@ -297,7 +321,9 @@
ItemId = !string.IsNullOrEmpty(qtDetail.ItemId)
? long.Parse(qtDetail.ItemId)
: null,
- FType = 0
+ FType = 0,
+ AboutGuid = qtDetail.Guid,
+ ItemDabid = qtDetail.Guid
// Unit = qtDetail.Qd009
};
@@ -310,9 +336,7 @@
commit += db.Updateable<MesInvItemOutItems>()
.SetColumns(it =>
it.TlQty == (it.TlQty ?? 0) + stock.Quantity)
- .Where(it => it.ItemOutId == outId &&
- it.ItemId == barcode.ItemId &&
- it.QtOutId == qtDetail.Guid)
+ .Where(it => it.ItemOutId == outId && it.ItemId == barcode.ItemId && it.ItemDabid == qtDetail.Guid)
.ExecuteCommand();
}
@@ -330,8 +354,8 @@
LastupdateBy = c_user,
LastupdateDate = DateTime.Now,
DepotCode = stock.DepotsCode,
- DepotId = stock.DepotsId.HasValue
- ? (int)stock.DepotsId
+ DepotId = stock.DepotId.HasValue
+ ? (int)stock.DepotId
: null,
// DepotsCode = stock.DepotsCode,
// DepotSectionsCode = stock.DepotSectionsCode,
@@ -435,6 +459,11 @@
query.Num = stock.Quantity;
query.Fum = null;
+ // 鍒涘缓 鎻掑叆鏃ュ織
+ var logService = new LogService();
+ var LogMsg = "銆怭DA銆戝叾浠栧嚭搴撱�傛潯鐮併��" + query.barcode + "銆戞暟閲忋��"+ stock.Quantity.ToString() + "銆� 鍑哄簱鍗曞彿銆�" + outNo + "銆�";
+ logService.CreateLog(db, query.userName, mesItemQt.Guid.ToString(), "MES_ITEM_QT", LogMsg, mesItemQt.Qtck);
+
if (commit < 5) throw new Exception("鏇存柊澶辫触");
return commit;
@@ -443,6 +472,12 @@
return (query, mesItemQtDatalls, mess);
}
+ /// <summary>
+ /// 鎷嗗垎鏉$爜骞跺嚭搴�
+ /// </summary>
+ /// <param name="query"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
public (WarehouseQuery form, List<MesItemQtDatall> item, string message)
PrintQtckBarcode(
WarehouseQuery query)
--
Gitblit v1.9.3