From 38339731265cb8ffef7954fb90874036fd46f09d Mon Sep 17 00:00:00 2001
From: cdk <2441919651@qq.com>
Date: 星期一, 22 十二月 2025 09:46:11 +0800
Subject: [PATCH] 供应商分数获取调整
---
service/Warehouse/MesItemQtManager.cs | 426 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 264 insertions(+), 162 deletions(-)
diff --git a/service/Warehouse/MesItemQtManager.cs b/service/Warehouse/MesItemQtManager.cs
index 01ce4e1..a254c1e 100644
--- a/service/Warehouse/MesItemQtManager.cs
+++ b/service/Warehouse/MesItemQtManager.cs
@@ -1,8 +1,13 @@
-锘縰sing NewPdaSqlServer.DB;
+锘縰sing Masuit.Tools;
+using NewPdaSqlServer.DB;
using NewPdaSqlServer.Dto.service;
using NewPdaSqlServer.entity;
+using NewPdaSqlServer.entity.Base;
using NewPdaSqlServer.util;
using SqlSugar;
+using System.Data;
+using System.Data.SqlClient;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace NewPdaSqlServer.service.Warehouse;
@@ -13,79 +18,82 @@
/// 鑾峰彇鏈畬鎴愮殑閫�鏂欏崟鍙峰垪琛�
/// </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>
- /// 鑾峰彇寰呭鐞嗙殑閫�鏂欏崟鏄庣粏鍒楄〃
+ /// 鑾峰彇寰呭鐞嗙殑閫�鏂欏崟鏄庣粏鍒楄〃
/// </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)
+ 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
{
- 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
+ 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,
+ allList = blDetails,
+ };
+ }
+ 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)
@@ -97,10 +105,7 @@
var p_transaction_no = 202;
// 妫�鏌ュ崟鎹彿鏄惁涓虹┖
- if (string.IsNullOrEmpty(p_bill_no))
- {
- throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
- }
+ if (string.IsNullOrEmpty(p_bill_no)) throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
// 妫�鏌ユ槸鍚﹂噸澶嶆壂鎻�
var existingBarcode = Db.Queryable<MesInvItemOutCDetails>()
@@ -108,10 +113,7 @@
it.ItemBarcode == p_item_barcode && it.PbillNo == p_bill_no)
.Any();
- if (existingBarcode)
- {
- throw new Exception("姝ゆ潯鐮佸凡缁忔壂鐮佸嚭搴�,鍕块噸澶嶆壂鎻忥紒");
- }
+ if (existingBarcode) throw new Exception("姝ゆ潯鐮佸凡缁忔壂鐮佸嚭搴�,鍕块噸澶嶆壂鎻忥紒");
// 鑾峰彇鏉$爜淇℃伅
var barcode = Db.Queryable<MesInvItemBarcodes>()
@@ -119,9 +121,10 @@
.First();
if (barcode == null)
- {
throw new Exception($"mes涓笉瀛樺湪姝ゆ潯鐮�,璇锋牳瀵癸紒{p_item_barcode}");
- }
+
+
+
// 鑾峰彇搴撳瓨淇℃伅
var stock = Db.Queryable<MesInvItemStocks>()
@@ -129,20 +132,14 @@
.First();
if (stock == null)
- {
throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮侊紝璇锋鏌ユ潯鐮佹槸鍚︽湭鍏ュ簱鎴栧凡鍑哄簱锛亄p_item_barcode}");
- }
if (string.IsNullOrEmpty(stock.DepotsCode))
- {
throw new Exception($"璋冩嫧涓殑鏉$爜涓嶅彲鍙戞枡,璇峰厛瀹屾垚璋冩嫧鍗曟嵁{p_item_barcode}");
- }
if (stock.DepotsCode is "S006" or "S005")
- {
throw new Exception($"鏉$爜鍦ㄤ笉鑹搧浠撲笅 涓嶅彲鍙戞枡{p_item_barcode}");
- }
// 妫�鏌ユ槸鍚﹀湪瀵勫瓨浠撲綅
// var isDepotSection = Db.Queryable<MesJcDepot>()
@@ -156,20 +153,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 (mesItemQt.Qt011 != stock.DepotsCode)
- {
- throw new Exception(
- $"鎵爜鍑鸿揣浠撳簱{stock.DepotsCode}涓庡叾浠栧嚭搴撶敵璇蜂粨搴搟mesItemQt.Qt011}涓嶄竴鑷达紝璇锋牳瀵癸紒");
- }
// 鑾峰彇鍑哄簱鍗曟槑缁�
var qtDetail = Db.Queryable<MesItemQtDatall>()
@@ -178,17 +166,25 @@
it.ItemId == stock.ItemId.ToString())
.First();
- if (qtDetail == null)
- {
- throw new Exception("鎵爜鐗╂枡闈炴湰娆″嚭搴撶敵璇风墿鏂欙紝璇锋牳瀵癸紒");
- }
+ 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);
if (remainingQty <= 0)
- {
throw new Exception($"鐢宠鐗╂枡 {barcode.ItemNo} 宸插嚭搴撳畬鎴愶紒");
- }
// 妫�鏌ユ暟閲忔槸鍚﹁秴鍑�
if (stock.Quantity > remainingQty)
@@ -214,6 +210,8 @@
var message =
$"璇风‘璁ゅ彂鏂欐暟閲忥紒锛佸凡甯﹀嚭婊¤冻鍏朵粬鍑哄簱鍗曠殑鍙戞枡鏁伴噺 {remainingQty} 纭鍚庤鐐瑰嚮鏉$爜鎷嗗垎";
+ throw new Exception($"鏉$爜鏁伴噺瓒呭嚭鍙戞枡鏁伴噺锛岃鎷嗗垎鍚庡啀鎵弿锛�");
+
query.itemNo = stock.ItemNo;
query.Num = stock.Quantity;
query.Fum = remainingQty;
@@ -229,7 +227,7 @@
// 鏌ユ壘褰撳ぉ鏄惁宸插瓨鍦ㄥ嚭搴撳崟
var existingOut = Db.Queryable<MesInvItemOuts>()
- .Where(it => it.PbillNo == p_bill_no
+ .Where(it => it.TaskNo == p_bill_no
// && it.DepotCode == stock.DepotsCode
&& it.DepotId == stock.DepotId
&& it.OutDate.Value.Date.ToString("yyyy-MM-dd") ==
@@ -246,7 +244,7 @@
{
// 鍒涘缓鏂扮殑鍑哄簱鍗�
outId = Guid.NewGuid();
- outNo = BillNo.GetBillNo("INV_OUT_OTHER");
+ outNo = BillNo.GetBillNo("QTCK(鍏朵粬鍑哄簱)");
var mesItemQt = Db.Queryable<MesItemQt>()
.Where(it => it.Qtck == p_bill_no)
@@ -265,14 +263,14 @@
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,
- WorkNo = p_bill_no,
+ //WorkNo = p_bill_no,
OutType = "鍏朵粬鍑哄簱",
- PbillNo = p_bill_no,
+ //PbillNo = p_bill_no,
OutDate = DateTime.Now,
Nflag = 0,
Reason = mesItemQt.Qt010,
@@ -295,15 +293,12 @@
it.ItemId == stock.ItemId.ToString())
.First();
- if (qtDetail == null)
- {
- throw new Exception($"鏈壘鍒板搴旂殑閫�鏂欏崟鏄庣粏淇℃伅");
- }
+ if (qtDetail == null) throw new Exception("鏈壘鍒板搴旂殑閫�鏂欏崟鏄庣粏淇℃伅");
// 妫�鏌ユ槸鍚﹀凡瀛樺湪鍑哄簱鐗╂枡璁板綍
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)
@@ -314,7 +309,8 @@
Guid = Guid.NewGuid(),
ItemOutId = outId,
ItemNo = qtDetail.Qd002,
- Quantity = stock.Quantity,
+ Quantity = qtDetail.Qd007,
+ TlQty = stock.Quantity,
CreateBy = c_user,
CreateDate = DateTime.Now,
LastupdateBy = c_user,
@@ -330,6 +326,8 @@
? long.Parse(qtDetail.ItemId)
: null,
FType = 0,
+ AboutGuid = qtDetail.Guid,
+ ItemDabid = qtDetail.Guid
// Unit = qtDetail.Qd009
};
@@ -341,10 +339,8 @@
// 鏇存柊宸插瓨鍦ㄧ殑鍑哄簱鐗╂枡璁板綍鏁伴噺
commit += db.Updateable<MesInvItemOutItems>()
.SetColumns(it =>
- it.Quantity == (it.Quantity ?? 0) + stock.Quantity)
- .Where(it => it.ItemOutId == outId &&
- it.ItemId == barcode.ItemId &&
- it.QtOutId == qtDetail.Guid)
+ it.TlQty == (it.TlQty ?? 0) + stock.Quantity)
+ .Where(it => it.ItemOutId == outId && it.ItemId == barcode.ItemId && it.ItemDabid == qtDetail.Guid)
.ExecuteCommand();
}
@@ -362,8 +358,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,
@@ -429,12 +425,10 @@
// 妫�鏌ユ槑缁嗘槸鍚﹀畬鎴�,濡傛灉瀹屾垚鍒欐洿鏂扮姸鎬�
if ((qtDetail.Qd007 ?? 0) - (qtDetail.Qd008 ?? 0) == stock.Quantity)
- {
commit += db.Updateable<MesItemQtDatall>()
.SetColumns(it => it.Qd011 == 1)
.Where(it => it.Guid == qtDetail.Guid)
.ExecuteCommand();
- }
mesItemQtDatalls = Db
.Queryable<MesItemQt, MesItemQtDatall, MesItems>(
@@ -456,12 +450,10 @@
// 濡傛灉娌℃湁寰呭鐞嗘槑缁嗭紝鏇存柊閫�鏂欏崟鐘舵�佷负宸插畬鎴�
if (CollectionUtil.IsNullOrEmpty(mesItemQtDatalls))
- {
db.Updateable<MesItemQt>()
.SetColumns(it => it.Qt014 == true)
.Where(it => it.Qtck == p_bill_no)
.ExecuteCommand();
- }
// 鏋勫缓杩斿洖娑堟伅
mess = $"鎵爜鎴愬姛锛佹潯鐮� {p_item_barcode} 鏁伴噺 {stock.Quantity} 宸插嚭搴�";
@@ -471,10 +463,12 @@
query.Num = stock.Quantity;
query.Fum = null;
- if (commit < 5)
- {
- throw new Exception("鏇存柊澶辫触");
- }
+ // 鍒涘缓 鎻掑叆鏃ュ織
+ 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;
});
@@ -482,6 +476,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)
@@ -494,16 +494,10 @@
var p_transaction_no = 202;
// 妫�鏌ュ崟鎹彿鏄惁涓虹┖
- if (string.IsNullOrEmpty(p_bill_no))
- {
- throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
- }
+ if (string.IsNullOrEmpty(p_bill_no)) throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
// 妫�鏌ユ暟閲忔槸鍚︽湁鏁�
- if (p_qty <= 0)
- {
- throw new Exception("璇疯緭鍏ユ纭殑鍙戞枡鏁伴噺锛�");
- }
+ if (p_qty <= 0) throw new Exception("璇疯緭鍏ユ纭殑鍙戞枡鏁伴噺锛�");
// 鑾峰彇搴撳瓨鏉$爜淇℃伅
var stock = Db.Queryable<MesInvItemStocks>()
@@ -511,19 +505,13 @@
.First();
if (stock == null)
- {
throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮侊紝璇锋鏌ユ潯鐮佹槸鍚︽湭鍏ュ簱鎴栧凡鍑哄簱锛亄p_old_barcode}");
- }
if (string.IsNullOrEmpty(stock.DepotsCode))
- {
throw new Exception($"璋冩嫧涓殑鏉$爜涓嶅彲鍙戞枡,璇峰厛瀹屾垚璋冩嫧鍗曟嵁{p_old_barcode}");
- }
if (stock.DepotsCode is "S006" or "S005")
- {
throw new Exception($"鏉$爜鍦ㄤ笉鑹搧浠撲笅 涓嶅彲鍙戞枡{p_old_barcode}");
- }
// 鑾峰彇鏉$爜淇℃伅
var barcode = Db.Queryable<MesInvItemBarcodes>()
@@ -531,9 +519,7 @@
.First();
if (barcode == null)
- {
throw new Exception($"mes涓笉瀛樺湪姝ゆ潯鐮侊紝璇锋牳瀵癸紒{p_old_barcode}");
- }
// 鑾峰彇閫�鏂欏崟淇℃伅
var mesItemQt = Db.Queryable<MesItemQt>()
@@ -541,15 +527,11 @@
.First();
if (mesItemQt == null)
- {
throw new Exception($"鍏朵粬鍑哄簱鐢宠鍗� {p_bill_no} 涓嶅瓨鍦紝璇风‘璁わ紒");
- }
if (mesItemQt.Qt011 != stock.DepotsCode)
- {
throw new Exception(
$"鎵爜鍑鸿揣浠撳簱{stock.DepotsCode}涓庡叾浠栧嚭搴撶敵璇蜂粨搴搟mesItemQt.Qt011}涓嶄竴鑷达紝璇锋牳瀵癸紒");
- }
// 鑾峰彇閫�鏂欏崟鏄庣粏
var qtDetail = Db.Queryable<MesItemQtDatall>()
@@ -558,32 +540,23 @@
it.ItemId == stock.ItemId.ToString())
.First();
- if (qtDetail == null)
- {
- throw new Exception("鎵爜鐗╂枡闈炴湰娆″嚭搴撶敵璇风墿鏂欙紝璇锋牳瀵癸紒");
- }
+ if (qtDetail == null) throw new Exception("鎵爜鐗╂枡闈炴湰娆″嚭搴撶敵璇风墿鏂欙紝璇锋牳瀵癸紒");
var remainingQty = (qtDetail.Qd007 ?? 0) - (qtDetail.Qd008 ?? 0);
if (remainingQty <= 0)
- {
throw new Exception($"鐢宠鐗╂枡 {barcode.ItemNo} 宸插嚭搴撳畬鎴愶紒");
- }
if (p_qty > remainingQty)
- {
throw new Exception(
$"杈撳叆鐨勬媶鍒嗘暟閲� {p_qty} 涓嶅彲澶т簬鍓╀綑闇�鍙戞暟閲� {remainingQty} 璇蜂慨鏀�");
- }
var totalQty = Db.Queryable<MesInvItemStocks>()
.Where(it => it.ItemBarcode == p_old_barcode && it.Quantity > 0)
.Sum(it => it.Quantity);
if (totalQty < p_qty)
- {
throw new Exception($"杈撳叆鐨勫彂鏂欐暟閲� {p_qty} 涓嶅彲澶т簬鏉$爜鏁伴噺 {totalQty} 璇蜂慨鏀�");
- }
var message = string.Empty;
var mesItemQtDatalls = new List<MesItemQtDatall>();
@@ -633,7 +606,7 @@
ComeFlg = 5,
EbelnK3id = barcode.EbelnK3id,
LineK3id = barcode.LineK3id,
- ItemId = barcode.ItemId,
+ ItemId = barcode.ItemId
}).IgnoreColumns(true).ExecuteCommand();
// 鏇存柊鍘熸潯鐮佹暟閲�
@@ -667,7 +640,7 @@
BillNo = stock.BillNo,
EbelnK3id = stock.EbelnK3id,
LineK3id = stock.LineK3id,
- ItemId = stock.ItemId,
+ ItemId = stock.ItemId
}).IgnoreColumns(true).ExecuteCommand();
@@ -702,7 +675,7 @@
LineK3id = stock.LineK3id,
SuppId = stock.SuppId,
SuppNo = stock.SuppNo,
- ItemId = stock.ItemId,
+ ItemId = stock.ItemId
}).IgnoreColumns(true).ExecuteCommand();
}
else
@@ -733,7 +706,7 @@
commit += db.Insertable(new MesInvItemOuts
{
Guid = outId,
- ItemOutNo = $"OUT-{DateTime.Now:yyyyMMddHHmmss}",
+ ItemOutNo = outNo,
TaskNo = p_bill_no,
Status = 0,
CreateBy = c_user,
@@ -751,9 +724,8 @@
PbillNo = p_bill_no,
OutDate = DateTime.Now,
Nflag = 0,
- Reason = mesItemQt.Qt010,
+ Reason = mesItemQt.Qt010
}).ExecuteReturnIdentity();
- outNo = $"OUT-{DateTime.Now:yyyyMMddHHmmss}";
}
else
{
@@ -768,7 +740,6 @@
.First();
if (outItem == null)
- {
// 鎻掑叆鏂版槑缁�
db.Insertable(new MesInvItemOutItems
{
@@ -789,12 +760,10 @@
ItemId = !string.IsNullOrEmpty(qtDetail.ItemId)
? long.Parse(qtDetail.ItemId)
: null,
- FType = 0,
+ FType = 0
// Unit = qtDetail.Qd009
}).ExecuteCommand();
- }
else
- {
// 鏇存柊鏄庣粏鏁伴噺
db.Updateable<MesInvItemOutItems>()
.SetColumns(it =>
@@ -804,7 +773,6 @@
it.ItemId == stock.ItemId &&
it.QtOutId == qtDetail.Guid)
.ExecuteCommand();
- }
// 鎻掑叆鍑哄簱鏄庣粏
db.Insertable(new MesInvItemOutCDetails
@@ -887,12 +855,10 @@
// 濡傛灉鎵�鏈夋槑缁嗗畬鎴愶紝鏇存柊閫�鏂欏崟鐘舵��
if (!hasUnfinished)
- {
db.Updateable<MesItemQt>()
.SetColumns(it => it.Qt014 == true)
.Where(it => it.Qtck == p_bill_no)
.ExecuteCommand();
- }
// 鑾峰彇鍓╀綑寰呭鐞嗘槑缁�
mesItemQtDatalls = db
@@ -919,4 +885,140 @@
});
return (query, mesItemQtDatalls, message);
}
+
+
+ /// <summary>
+ /// 鍏朵粬鍑哄簱锛堟柊锛夊瓨鍌ㄨ繃绋�
+ /// </summary>
+ /// <param name="query"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
+ public ProductionPickDto ScanCode(WarehouseQuery query)
+ {
+ var _strMsg = "";
+ var _intSum = "";
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ {
+ if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖");
+ if (query.billNo.IsNullOrEmpty()) throw new Exception("鐢宠鍗曞彿涓嶅厑璁镐负绌�"); if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
+
+ using (var cmd = new SqlCommand("[prc_pda_QTCK]", conn))
+ {
+ try
+ {
+ conn.Open();
+ cmd.CommandType = CommandType.StoredProcedure;
+ SqlParameter[] parameters =
+ {
+ new("@outMsg", SqlDbType.NVarChar, 300),
+ new("@outSum", SqlDbType.NVarChar, 300),
+ new("@barcode_num", SqlDbType.NVarChar, 300),
+ new("@split_num", SqlDbType.NVarChar, 300),
+ new("@c_User", query.userName),
+ new("@p_biLL_no", query.billNo),
+ new("@p_item_barcode", query.barcode)
+ };
+ parameters[0].Direction = ParameterDirection.Output;
+ parameters[1].Direction = ParameterDirection.Output;
+ parameters[2].Direction = ParameterDirection.Output;
+ parameters[3].Direction = ParameterDirection.Output;
+ foreach (var parameter in parameters)
+ cmd.Parameters.Add(parameter);
+ cmd.ExecuteNonQuery();
+ _strMsg = parameters[0].Value.ToString();
+ _intSum = parameters[1].Value.ToString();
+
+ var barcodeNum = parameters[2].Value.ToString();
+ var splitNum = parameters[3].Value.ToString();
+
+ var result = Convert.ToInt32(_intSum);
+ if (result <= 0) throw new Exception(_strMsg);
+
+ var dto = new ProductionPickDto
+ {
+ daa001 = query.billNo,
+ barcodeNum = barcodeNum,
+ splitNum = splitNum,
+ barcode = query.barcode,
+ result = result.ToString()
+ };
+
+ return dto;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+ }
+ }
+
+
+ public ProductionPickDto ScanCodeCF(WarehouseQuery query)
+ {
+ if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖");
+ if (query.billNo.IsNullOrEmpty()) throw new Exception("鐢宠鍗曞彿涓嶅厑璁镐负绌�");
+ if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
+
+ if (query.Num is null or 0) throw new Exception("鏉$爜鎷嗗垎鏁颁笉鍏佽涓虹┖鎴栬�呬负0");
+
+ var _strMsg = "";
+ var _intSum = "";
+ var _cfBar = "";//鎷嗗垎鍚庢潯鐮�
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ {
+ using (var cmd = new SqlCommand("[prc_pda_QTCK_CF]", conn))
+ {
+ try
+ {
+ conn.Open();
+ cmd.CommandType = CommandType.StoredProcedure;
+ SqlParameter[] parameters =
+ {
+ new("@outMsg", SqlDbType.NVarChar, 2000),
+ new("@outSum", SqlDbType.NVarChar, 300),
+ new("@outCfBar", SqlDbType.NVarChar, 300),
+ new("@c_User", query.userName),
+ new("@p_biLL_no", query.billNo),
+ new("@p_item_barcode", query.barcode),
+ new("@num", query.Num)
+ };
+ parameters[0].Direction = ParameterDirection.Output;
+ parameters[1].Direction = ParameterDirection.Output;
+ parameters[2].Direction = ParameterDirection.Output;
+ foreach (var parameter in parameters)
+ cmd.Parameters.Add(parameter);
+ cmd.ExecuteNonQuery();
+ _strMsg = parameters[0].Value.ToString();
+ _intSum = parameters[1].Value.ToString();
+ _cfBar = parameters[2].Value.ToString();
+
+
+ var result = Convert.ToInt32(_intSum);
+ if (result <= 0) throw new Exception(_strMsg);
+
+ var dto = new ProductionPickDto
+ {
+ daa001 = query.billNo,
+ barcode = query.barcode,//鍘熸潯鐮�
+ cfBarcode = _cfBar//鎷嗗垎鍚庢潯鐮�
+ };
+
+ return dto;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3