From 546c4baeda5102c9c767831e1b74058d3383c53d Mon Sep 17 00:00:00 2001
From: cnf <3200815559@qq.com>
Date: 星期三, 06 八月 2025 14:15:13 +0800
Subject: [PATCH] 退补料修改完成
---
service/Warehouse/MesItemBlManager.cs | 1661 +++++++++++++++++++-----------------
service/Warehouse/MesItemTblManager.cs | 984 +++++++++++----------
2 files changed, 1,407 insertions(+), 1,238 deletions(-)
diff --git a/service/Warehouse/MesItemBlManager.cs b/service/Warehouse/MesItemBlManager.cs
index 0f0b52d..bf74ff4 100644
--- a/service/Warehouse/MesItemBlManager.cs
+++ b/service/Warehouse/MesItemBlManager.cs
@@ -5,6 +5,8 @@
using NewPdaSqlServer.entity.Base;
using NewPdaSqlServer.util;
using SqlSugar;
+using System.Data;
+using System.Data.SqlClient;
namespace NewPdaSqlServer.service.Warehouse;
@@ -111,8 +113,6 @@
ScblScanBarcode(
WarehouseQuery query)
{
- //if (string.IsNullOrEmpty(query.billNo))
- // throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
if (string.IsNullOrEmpty(query.barcode))
throw new Exception("璇锋壂鎻忔潯鐮侊紒");
@@ -123,355 +123,462 @@
if (string.IsNullOrEmpty(query.blNo))
throw new Exception("鐢宠鍗曞彿涓嶈兘涓虹┖锛�");
+ // 鍑嗗璋冪敤瀛樺偍杩囩▼鐨勫弬鏁�
+ string outMsg = "";
+ int outSum = -1;
+ decimal barcodeNum = 0;
+ decimal splitNum = 0;
- // 妫�楠屾槸鍚﹂噸澶嶆壂鎻�
- var exists = Db.Queryable<MesInvItemOutCDetails>()
- .Where(b => b.ItemBarcode == query.barcode)
- .Any();
-
- if (exists)
- throw new Exception("姝ゆ潯鐮佸凡鎵弿,鍕块噸澶嶆壂鐮侊紒");
-
- // 鏌ヨ鏉$爜搴撳瓨淇℃伅
- var stockBarcode = Db.Queryable<MesInvItemStocks>()
- .Where(t => t.ItemBarcode == query.barcode && t.Quantity > 0)
- .First();
-
- if (stockBarcode == null)
- throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮�,璇锋牳瀵癸紒{query.barcode}");
-
- var depots = Db.Queryable<MesDepots>()
- .Where(t => t.DepotId == stockBarcode.DepotId)
- .First();
-
- // 妫�鏌ヨˉ鏂欏崟鐘舵��
- var mesItemBl = Db.Queryable<MesItemBl>()
- .Where(a => a.BlNo == query.blNo)
- .First();
-
- if (mesItemBl == null)
- throw new Exception($"鐢宠鍗� {query.blNo} 宸叉挙鍥烇紒");
-
- if (mesItemBl.Bl018 != true)
- throw new Exception($"鐢宠鍗� {query.blNo} 鏈鏍革紒");
-
- if (mesItemBl.Bl019 == true)
- throw new Exception($"鐢宠鍗� {query.blNo} 宸插畬缁擄紒");
-
- // 鑾峰彇琛ユ枡鍗曟槑缁嗗苟鏍¢獙
- var blDetail = Db.Queryable<MesItemBlDetail>()
- .Where(b =>
- b.Mid == mesItemBl.Id && b.Bld012 == stockBarcode.ItemId)
- .First();
-
- if (blDetail == null)
- throw new Exception($"鐢宠鍗曚笉瀛樺湪姝ょ墿鏂� {stockBarcode.ItemNo} 璇风‘璁わ紒");
-
- // 妫�鏌ュ緟琛ユ暟閲�
- var quantity = (blDetail.Bld007 ?? 0) - (blDetail.Bld008 ?? 0);
- if (quantity == 0)
- throw new Exception("鐗╂枡宸叉壂鐮佸畬鎴愶紝璇锋牳瀵癸紒");
-
-
- if(stockBarcode.Quantity > quantity)
+ try
{
- query.status = 2;
- query.message = "鏉$爜搴撳瓨澶т簬闇�棰嗭紝璇锋媶鍒嗭紒";
- query.CfNum = quantity;
- query.Num = stockBarcode.Quantity;
- return (query, []);
- }
+ // 璋冪敤瀛樺偍杩囩▼
+ var parameters = new List<SqlParameter>
+ {
+ new SqlParameter("@c_user", query.userName),
+ new SqlParameter("@p_bill_no", query.billNo ?? string.Empty),
+ new SqlParameter("@p_item_barcode", query.barcode),
+ new SqlParameter("@p_bl_no", query.blNo),
+ new SqlParameter("@p_type", query.Type),
+ new SqlParameter("@outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output },
+ new SqlParameter("@outSum", SqlDbType.Int) { Direction = ParameterDirection.Output },
+ new SqlParameter("@barcode_num", SqlDbType.Decimal) { Direction = ParameterDirection.Output },
+ new SqlParameter("@split_num", SqlDbType.Decimal) { Direction = ParameterDirection.Output }
+ };
- // 妫�鏌ュ伐鍗曚俊鎭�
- var womdaa = Db.Queryable<Womdaa>()
- .Where(a => a.Daa001 == query.billNo)
- .First();
+ // 鎵ц瀛樺偍杩囩▼
+ Db.Ado.ExecuteCommand(
+ "EXEC PRC_PDA_SCBLCL @c_user, @p_bill_no, @p_item_barcode, @p_bl_no, @p_type, @outMsg OUTPUT, @outSum OUTPUT, @barcode_num OUTPUT, @split_num OUTPUT",
+ parameters.ToArray());
- if (womdaa == null)
- throw new Exception($"宸ュ崟 {query.billNo} 涓嶅瓨鍦紝璇风‘璁わ紒");
+ // 鑾峰彇杈撳嚭鍙傛暟
+ outMsg = parameters[5].Value?.ToString() ?? "";
+ outSum = Convert.ToInt32(parameters[6].Value);
+ barcodeNum = Convert.ToDecimal(parameters[7].Value);
+ splitNum = Convert.ToDecimal(parameters[8].Value);
- // 妫�鏌ュ鏂欐槑缁�
- var womdab = Db.Queryable<Womdab>()
- .Where(b => b.Dab001 == query.billNo && b.Erpid == blDetail.Bld014)
- .First();
-
- if (womdab == null)
- throw new Exception($"澶囨枡鏄庣粏涓嶅瓨鍦ㄦ鐗╂枡 {stockBarcode.ItemNo} 璇风‘璁わ紒");
-
- if (stockBarcode.Quantity > quantity)
- {
- // 鑾峰彇寰呭彂鏂欐槑缁嗗垪琛�
- var pendingList = Db.Queryable<MesItemBl, MesItemBlDetail>((a, b) =>
- new JoinQueryInfos(JoinType.Left, a.Id == b.Mid))
- .Where((a, b) => a.BlNo == query.blNo
- && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0)
- .Select((a, b) => new MesItemBlDetail
- {
- Bld012 = b.Bld012,
- Bld002 = b.Bld002,
- Bld003 = b.Bld003,
- Bld004 = b.Bld004,
- Bld007 = b.Bld007,
- Bld008 = b.Bld008
- })
- .ToList();
-
-
- query.Num = stockBarcode.Quantity;
- query.Fum = quantity;
-
- return (query, pendingList);
- }
-
- // 寮�鍚簨鍔″鐞�
- var success = UseTransaction(db =>
- {
- var outNoType = "";
- if(query.Type == "鐢熶骇琛ユ枡")
+ // 澶勭悊瀛樺偍杩囩▼杩斿洖鐨勭粨鏋�
+ if (outSum == 2) // 闇�瑕佹媶鍒�
{
- outNoType = "SCBL(鐢熶骇琛ユ枡)";
- }else
- {
- outNoType = "SCCL(鐢熶骇瓒呴)";
- }
- // 鑾峰彇鎴栧垱寤哄嚭搴撳崟
- var outId = Guid.NewGuid();
- var outNo = BillNo.GetBillNo(outNoType);
+ query.status = 2;
+ query.message = outMsg;
+ query.CfNum = splitNum;
+ query.Num = barcodeNum;
- var existingOut = db.Queryable<MesInvItemOuts>()
- .Where(a => a.TaskNo == query.blNo
- && a.DepotId == stockBarcode.DepotId
- && a.OutDate.Value.Date.ToString("yyyy-MM-dd") ==
- DateTime.Now.Date.ToString("yyyy-MM-dd")
- && a.BillTypeId == 200
- && a.TransactionNo == 209
- && a.Status == 0)
- .First();
-
- if (existingOut != null)
- {
- outId = existingOut.Guid;
- outNo = existingOut.ItemOutNo;
- }
- else
- {
- // 鎻掑叆鍑哄簱鍗曚富琛�
- db.Insertable(new MesInvItemOuts
- {
- Guid = outId,
- ItemOutNo = outNo,
- TaskNo = query.blNo,
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- BillTypeId = 200,
- TransactionNo = 209,
- Remark = mesItemBl.Bl007,
- DepotCode = depots.DepotCode,
- OutPart = womdaa.Daa013,
- OutType = query.Type,
- FType = 0,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- WorkNo = womdaa.Daa021,
- BoardItem = womdaa.Daa002,
- PbillNo = womdaa.Daa001,
- OutDate = DateTime.Now,
- Status = 0,
- DepotId = stockBarcode.DepotId,
- THORGID = stockBarcode.StockOrgId,
- //BbillNo = query.billNo
- }).IgnoreColumns(true).ExecuteCommand();
- }
-
- // 妫�鏌ュ苟鏇存柊鍑哄簱鍗曠墿鏂欐槑缁�
- var itemCount = db.Queryable<MesInvItemOutItems>()
- .Where(i =>
- i.ItemOutId == outId && i.ItemId == stockBarcode.ItemId && i.ItemOutId == outId && i.DepotId == stockBarcode.DepotsId.ToString())
- .Count();
-
- if (itemCount > 0)
- // 鏇存柊宸插瓨鍦ㄧ殑鐗╂枡鏄庣粏鏁伴噺
- db.Updateable<MesInvItemOutItems>()
- .SetColumns(i =>
- i.TlQty == i.TlQty + stockBarcode.Quantity)
- .Where(i =>
- i.ItemOutId == outId && i.ItemId == stockBarcode.ItemId && i.ItemOutId == outId && i.DepotId == stockBarcode.DepotsId.ToString())
- .ExecuteCommand();
- else
- // 鎻掑叆鏂扮殑鐗╂枡鏄庣粏璁板綍
- db.Insertable(new MesInvItemOutItems
- {
- Guid = Guid.NewGuid(),
- ItemOutId = outId,
- ItemNo = blDetail.Bld002,
- Quantity = stockBarcode.Quantity,
- TlQty = stockBarcode.Quantity,
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- DepotCode = depots.DepotCode,
- TaskNo = query.blNo,
- WorkNo = womdaa.Daa021,
- WorkLine = blDetail.Bld013,
- ErpItemNo = womdab.Dab003,
- ErpId = womdab.Eid,
- ErpAutoid = womdab.Erpid,
- PbillNo = query.billNo,
- ItemId = blDetail.Bld012,
- DepotId = stockBarcode.DepotId.ToString(),
- ItemDabid = blDetail.Id,
- // Unit = blDetail.Bld009,
- // DepotId = (int)stockBarcode.DepotsId
- }).IgnoreColumns(true).ExecuteCommand();
-
- // 鎻掑叆鍑哄簱鍗曟潯鐮佹槑缁�
- db.Insertable(new MesInvItemOutCDetails
- {
- Guid = Guid.NewGuid(),
- ItemOutId = outId,
- ItemBarcode = stockBarcode.ItemBarcode,
- ItemNo = stockBarcode.ItemNo,
- LotNo = stockBarcode.LotNo,
- Quantity = stockBarcode.Quantity,
- ForceOutFlag = 0,
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- DepotCode = depots.DepotCode,
- DepotSectionCode = stockBarcode.DepotSectionsCode,
- Remark = blDetail.Bld010,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- TaskNoy = mesItemBl.Bl013,
- BoardStyle = mesItemBl.Bl002,
- TaskNo = query.blNo,
- WorkNo = blDetail.Bld001,
- WorkLine = blDetail.Bld013,
- SuppNo = stockBarcode.SuppNo,
- PbillNo = query.billNo,
- ItemId = blDetail.Bld012,
- Unit = blDetail.Bld009,
- DepotId = (int)stockBarcode.DepotId,
- EbelnK3id = womdab.Eid,
- LineK3id = womdab.Erpid
- }).IgnoreColumns(true).ExecuteCommand();
-
- // 鎻掑叆涓氬姟浜ゆ槗璁板綍
- db.Insertable(new MesInvBusiness2
- {
- Guid = Guid.NewGuid(),
- Status = 1,
- BillTypeId = 200, // p_bill_type_id
- TransactionCode = "209", // p_transaction_no
- BusinessType = -1,
- ItemBarcode = stockBarcode.ItemBarcode,
- ItemNo = stockBarcode.ItemNo,
- LotNo = stockBarcode.LotNo,
- EpFlag = true,
- Quantity = stockBarcode.Quantity,
- FromInvDepotsCode = stockBarcode.DepotsCode,
- FromInvDepotSectionsCode = stockBarcode.DepotSectionsCode,
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- TaskNo = mesItemBl.Bl012, // Matches C_QTCK.Bl012
- BillNo = query.blNo,
- WorkNo = blDetail.Bld001, // Matches C_QTCK_D.Bld001
- WorkLine = blDetail.Bld013, // Matches C_QTCK_D.Bld013
- SuppNo = stockBarcode.SuppNo,
- ItemId = stockBarcode.ItemId
- // CkDepot = stockBarcode.DepotsId
- }).IgnoreColumns(true).ExecuteCommand();
-
-
- // 鏇存柊宸ュ崟琛ㄦ暟閲�
- db.Updateable<Womdab>()
- .SetColumns(it => new Womdab
- {
- Dab007 = (it.Dab007 ?? 0) + stockBarcode.Quantity,
- Dab020 = (it.Dab020 ?? 0) + stockBarcode.Quantity,
- Dab021 = (it.Dab021 ?? 0) + stockBarcode.Quantity
- })
- .Where(it => it.Guid == womdab.DaaGuid && it.Dab003 == womdab.Dab003)
- .ExecuteCommand();
-
- // 鏇存柊琛ユ枡鍗曟槑缁嗗凡琛ユ暟閲�
- db.Updateable<MesItemBlDetail>()
- .SetColumns(it => new MesItemBlDetail
- {
- Bld008 = (it.Bld008 ?? 0) + (int)stockBarcode.Quantity
- })
- .Where(it => it.Id == blDetail.Id)
- .ExecuteCommand();
-
- // 妫�鏌ヨˉ鏂欏崟鏄庣粏鏄惁瀹屾垚
- var blDetail1 = db.Queryable<MesItemBlDetail>()
- .Where(it => it.Id == blDetail.Id)
- .First();
-
- if ((blDetail1.Bld007 ?? 0) <= (blDetail1.Bld008 ?? 0))
- // 鏇存柊鏄庣粏瀹屾垚鐘舵��
- db.Updateable<MesItemBlDetail>()
- .SetColumns(it => it.Bld011 == 1)
- .Where(it => it.Id == blDetail1.Id)
- .ExecuteCommand();
-
- // 鏇存柊搴撳瓨鏁伴噺涓�0
- db.Updateable<MesInvItemStocks>()
- .SetColumns(it => it.Quantity == 0)
- .Where(it => it.Guid == stockBarcode.Guid)
- .ExecuteCommand();
-
-
- // 妫�鏌ユ槸鍚︽墍鏈夋槑缁嗛兘宸插畬鎴�
- var unfinishedDetail = db.Queryable<MesItemBlDetail>()
- .LeftJoin<MesItemBl>((b, a) => a.Id == b.Mid)
- .Where((b, a) => a.BlNo == query.blNo && (b.Bld011 ?? 0) == 0)
- .Select((b, a) => b)
- .First();
-
- if (unfinishedDetail == null)
- // 濡傛灉娌℃湁鏈畬鎴愮殑鏄庣粏锛屾洿鏂拌ˉ鏂欏崟鐘舵�佷负宸插畬鎴�
- db.Updateable<MesItemBl>()
- .SetColumns(it => new MesItemBl
+ // 鑾峰彇寰呭彂鏂欐槑缁嗗垪琛�
+ var pendingList = Db.Queryable<MesItemBl, MesItemBlDetail>((a, b) =>
+ new JoinQueryInfos(JoinType.Left, a.Id == b.Mid))
+ .Where((a, b) => a.BlNo == query.blNo
+ && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0)
+ .Select((a, b) => new MesItemBlDetail
{
- Bl019 = true,
- WcUser = query.userName,
- WcTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ Bld012 = b.Bld012,
+ Bld002 = b.Bld002,
+ Bld003 = b.Bld003,
+ Bld004 = b.Bld004,
+ Bld007 = b.Bld007,
+ Bld008 = b.Bld008
})
- .Where(it => it.Id == mesItemBl.Id)
- .ExecuteCommand();
+ .ToList();
- return 1;
- });
-
- // 鑾峰彇鏈�缁堢殑寰呭彂鏂欐槑缁嗗垪琛�
- var finalPendingList = Db.Queryable<MesItemBl, MesItemBlDetail>(
- (a, b) =>
- new JoinQueryInfos(JoinType.Left, a.Id == b.Mid))
- .Where((a, b) => a.BlNo == query.blNo
- && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0)
- .Select((a, b) => new MesItemBlDetail
+ return (query, pendingList);
+ }
+ else if (outSum == -1) // 澶勭悊澶辫触
{
- Bld012 = b.Bld012,
- Bld002 = b.Bld002,
- Bld003 = b.Bld003,
- Bld004 = b.Bld004,
- Bld007 = b.Bld007,
- Bld008 = b.Bld008
- })
- .ToList();
+ throw new Exception(outMsg);
+ }
+ else if (outSum == 1) // 澶勭悊鎴愬姛
+ {
+ // 鑾峰彇鏈�缁堢殑寰呭彂鏂欐槑缁嗗垪琛�
+ var finalPendingList = Db.Queryable<MesItemBl, MesItemBlDetail>(
+ (a, b) => new JoinQueryInfos(JoinType.Left, a.Id == b.Mid))
+ .Where((a, b) => a.BlNo == query.blNo
+ && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0)
+ .Select((a, b) => new MesItemBlDetail
+ {
+ Bld012 = b.Bld012,
+ Bld002 = b.Bld002,
+ Bld003 = b.Bld003,
+ Bld004 = b.Bld004,
+ Bld007 = b.Bld007,
+ Bld008 = b.Bld008
+ })
+ .ToList();
- return (query, finalPendingList);
+ query.status = 1;
+ query.message = outMsg;
+ return (query, finalPendingList);
+ }
+ else
+ {
+ throw new Exception("鏈煡鐨勫鐞嗙粨鏋滅姸鎬�");
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"璋冪敤瀛樺偍杩囩▼PRC_PDA_SCBLCL澶辫触: {ex.Message}");
+ }
+
+ //if (string.IsNullOrEmpty(query.billNo))
+ // throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
+
+ //if (string.IsNullOrEmpty(query.barcode))
+ // throw new Exception("璇锋壂鎻忔潯鐮侊紒");
+
+ //if (string.IsNullOrEmpty(query.userName))
+ // throw new Exception("鐢ㄦ埛鍚嶄笉鑳戒负绌猴紒");
+
+ //if (string.IsNullOrEmpty(query.blNo))
+ // throw new Exception("鐢宠鍗曞彿涓嶈兘涓虹┖锛�");
+
+
+ //// 妫�楠屾槸鍚﹂噸澶嶆壂鎻�
+ //var exists = Db.Queryable<MesInvItemOutCDetails>()
+ // .Where(b => b.ItemBarcode == query.barcode)
+ // .Any();
+
+ //if (exists)
+ // throw new Exception("姝ゆ潯鐮佸凡鎵弿,鍕块噸澶嶆壂鐮侊紒");
+
+ //// 鏌ヨ鏉$爜搴撳瓨淇℃伅
+ //var stockBarcode = Db.Queryable<MesInvItemStocks>()
+ // .Where(t => t.ItemBarcode == query.barcode && t.Quantity > 0)
+ // .First();
+
+ //if (stockBarcode == null)
+ // throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮�,璇锋牳瀵癸紒{query.barcode}");
+
+ //var depots = Db.Queryable<MesDepots>()
+ // .Where(t => t.DepotId == stockBarcode.DepotId)
+ // .First();
+
+ //// 妫�鏌ヨˉ鏂欏崟鐘舵��
+ //var mesItemBl = Db.Queryable<MesItemBl>()
+ // .Where(a => a.BlNo == query.blNo)
+ // .First();
+
+ //if (mesItemBl == null)
+ // throw new Exception($"鐢宠鍗� {query.blNo} 宸叉挙鍥烇紒");
+
+ //if (mesItemBl.Bl018 != true)
+ // throw new Exception($"鐢宠鍗� {query.blNo} 鏈鏍革紒");
+
+ //if (mesItemBl.Bl019 == true)
+ // throw new Exception($"鐢宠鍗� {query.blNo} 宸插畬缁擄紒");
+
+ //// 鑾峰彇琛ユ枡鍗曟槑缁嗗苟鏍¢獙
+ //var blDetail = Db.Queryable<MesItemBlDetail>()
+ // .Where(b =>
+ // b.Mid == mesItemBl.Id && b.Bld012 == stockBarcode.ItemId)
+ // .First();
+
+ //if (blDetail == null)
+ // throw new Exception($"鐢宠鍗曚笉瀛樺湪姝ょ墿鏂� {stockBarcode.ItemNo} 璇风‘璁わ紒");
+
+ //// 妫�鏌ュ緟琛ユ暟閲�
+ //var quantity = (blDetail.Bld007 ?? 0) - (blDetail.Bld008 ?? 0);
+ //if (quantity == 0)
+ // throw new Exception("鐗╂枡宸叉壂鐮佸畬鎴愶紝璇锋牳瀵癸紒");
+
+
+ //if(stockBarcode.Quantity > quantity)
+ //{
+ // query.status = 2;
+ // query.message = "鏉$爜搴撳瓨澶т簬闇�棰嗭紝璇锋媶鍒嗭紒";
+ // query.CfNum = quantity;
+ // query.Num = stockBarcode.Quantity;
+ // return (query, []);
+ //}
+
+ //// 妫�鏌ュ伐鍗曚俊鎭�
+ //var womdaa = Db.Queryable<Womdaa>()
+ // .Where(a => a.Daa001 == query.billNo)
+ // .First();
+
+ //if (womdaa == null)
+ // throw new Exception($"宸ュ崟 {query.billNo} 涓嶅瓨鍦紝璇风‘璁わ紒");
+
+ //// 妫�鏌ュ鏂欐槑缁�
+ //var womdab = Db.Queryable<Womdab>()
+ // .Where(b => b.Dab001 == query.billNo && b.Erpid == blDetail.Bld014)
+ // .First();
+
+ //if (womdab == null)
+ // throw new Exception($"澶囨枡鏄庣粏涓嶅瓨鍦ㄦ鐗╂枡 {stockBarcode.ItemNo} 璇风‘璁わ紒");
+
+ //if (stockBarcode.Quantity > quantity)
+ //{
+ // // 鑾峰彇寰呭彂鏂欐槑缁嗗垪琛�
+ // var pendingList = Db.Queryable<MesItemBl, MesItemBlDetail>((a, b) =>
+ // new JoinQueryInfos(JoinType.Left, a.Id == b.Mid))
+ // .Where((a, b) => a.BlNo == query.blNo
+ // && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0)
+ // .Select((a, b) => new MesItemBlDetail
+ // {
+ // Bld012 = b.Bld012,
+ // Bld002 = b.Bld002,
+ // Bld003 = b.Bld003,
+ // Bld004 = b.Bld004,
+ // Bld007 = b.Bld007,
+ // Bld008 = b.Bld008
+ // })
+ // .ToList();
+
+
+ // query.Num = stockBarcode.Quantity;
+ // query.Fum = quantity;
+
+ // return (query, pendingList);
+ //}
+
+ //// 寮�鍚簨鍔″鐞�
+ //var success = UseTransaction(db =>
+ //{
+ // var outNoType = "";
+ // if(query.Type == "鐢熶骇琛ユ枡")
+ // {
+ // outNoType = "SCBL(鐢熶骇琛ユ枡)";
+ // }else
+ // {
+ // outNoType = "SCCL(鐢熶骇瓒呴)";
+ // }
+ // // 鑾峰彇鎴栧垱寤哄嚭搴撳崟
+ // var outId = Guid.NewGuid();
+ // var outNo = BillNo.GetBillNo(outNoType);
+
+ // var existingOut = db.Queryable<MesInvItemOuts>()
+ // .Where(a => a.TaskNo == query.blNo
+ // && a.DepotId == stockBarcode.DepotId
+ // && a.OutDate.Value.Date.ToString("yyyy-MM-dd") ==
+ // DateTime.Now.Date.ToString("yyyy-MM-dd")
+ // && a.BillTypeId == 200
+ // && a.TransactionNo == 209
+ // && a.Status == 0)
+ // .First();
+
+ // if (existingOut != null)
+ // {
+ // outId = existingOut.Guid;
+ // outNo = existingOut.ItemOutNo;
+ // }
+ // else
+ // {
+ // // 鎻掑叆鍑哄簱鍗曚富琛�
+ // db.Insertable(new MesInvItemOuts
+ // {
+ // Guid = outId,
+ // ItemOutNo = outNo,
+ // TaskNo = query.blNo,
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // BillTypeId = 200,
+ // TransactionNo = 209,
+ // Remark = mesItemBl.Bl007,
+ // DepotCode = depots.DepotCode,
+ // OutPart = womdaa.Daa013,
+ // OutType = query.Type,
+ // FType = 0,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // WorkNo = womdaa.Daa021,
+ // BoardItem = womdaa.Daa002,
+ // PbillNo = womdaa.Daa001,
+ // OutDate = DateTime.Now,
+ // Status = 0,
+ // DepotId = stockBarcode.DepotId,
+ // THORGID = stockBarcode.StockOrgId,
+ // //BbillNo = query.billNo
+ // }).IgnoreColumns(true).ExecuteCommand();
+ // }
+
+ // // 妫�鏌ュ苟鏇存柊鍑哄簱鍗曠墿鏂欐槑缁�
+ // var itemCount = db.Queryable<MesInvItemOutItems>()
+ // .Where(i =>
+ // i.ItemOutId == outId && i.ItemId == stockBarcode.ItemId && i.ItemOutId == outId && i.DepotId == stockBarcode.DepotsId.ToString())
+ // .Count();
+
+ // if (itemCount > 0)
+ // // 鏇存柊宸插瓨鍦ㄧ殑鐗╂枡鏄庣粏鏁伴噺
+ // db.Updateable<MesInvItemOutItems>()
+ // .SetColumns(i =>
+ // i.TlQty == i.TlQty + stockBarcode.Quantity)
+ // .Where(i =>
+ // i.ItemOutId == outId && i.ItemId == stockBarcode.ItemId && i.ItemOutId == outId && i.DepotId == stockBarcode.DepotsId.ToString())
+ // .ExecuteCommand();
+ // else
+ // // 鎻掑叆鏂扮殑鐗╂枡鏄庣粏璁板綍
+ // db.Insertable(new MesInvItemOutItems
+ // {
+ // Guid = Guid.NewGuid(),
+ // ItemOutId = outId,
+ // ItemNo = blDetail.Bld002,
+ // Quantity = stockBarcode.Quantity,
+ // TlQty = stockBarcode.Quantity,
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // DepotCode = depots.DepotCode,
+ // TaskNo = query.blNo,
+ // WorkNo = womdaa.Daa021,
+ // WorkLine = blDetail.Bld013,
+ // ErpItemNo = womdab.Dab003,
+ // ErpId = womdab.Eid,
+ // ErpAutoid = womdab.Erpid,
+ // PbillNo = query.billNo,
+ // ItemId = blDetail.Bld012,
+ // DepotId = stockBarcode.DepotId.ToString(),
+ // ItemDabid = blDetail.Id,
+ // // Unit = blDetail.Bld009,
+ // // DepotId = (int)stockBarcode.DepotsId
+ // }).IgnoreColumns(true).ExecuteCommand();
+
+ // // 鎻掑叆鍑哄簱鍗曟潯鐮佹槑缁�
+ // db.Insertable(new MesInvItemOutCDetails
+ // {
+ // Guid = Guid.NewGuid(),
+ // ItemOutId = outId,
+ // ItemBarcode = stockBarcode.ItemBarcode,
+ // ItemNo = stockBarcode.ItemNo,
+ // LotNo = stockBarcode.LotNo,
+ // Quantity = stockBarcode.Quantity,
+ // ForceOutFlag = 0,
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // DepotCode = depots.DepotCode,
+ // DepotSectionCode = stockBarcode.DepotSectionsCode,
+ // Remark = blDetail.Bld010,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // TaskNoy = mesItemBl.Bl013,
+ // BoardStyle = mesItemBl.Bl002,
+ // TaskNo = query.blNo,
+ // WorkNo = blDetail.Bld001,
+ // WorkLine = blDetail.Bld013,
+ // SuppNo = stockBarcode.SuppNo,
+ // PbillNo = query.billNo,
+ // ItemId = blDetail.Bld012,
+ // Unit = blDetail.Bld009,
+ // DepotId = (int)stockBarcode.DepotId,
+ // EbelnK3id = womdab.Eid,
+ // LineK3id = womdab.Erpid
+ // }).IgnoreColumns(true).ExecuteCommand();
+
+ // // 鎻掑叆涓氬姟浜ゆ槗璁板綍
+ // db.Insertable(new MesInvBusiness2
+ // {
+ // Guid = Guid.NewGuid(),
+ // Status = 1,
+ // BillTypeId = 200, // p_bill_type_id
+ // TransactionCode = "209", // p_transaction_no
+ // BusinessType = -1,
+ // ItemBarcode = stockBarcode.ItemBarcode,
+ // ItemNo = stockBarcode.ItemNo,
+ // LotNo = stockBarcode.LotNo,
+ // EpFlag = true,
+ // Quantity = stockBarcode.Quantity,
+ // FromInvDepotsCode = stockBarcode.DepotsCode,
+ // FromInvDepotSectionsCode = stockBarcode.DepotSectionsCode,
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // TaskNo = mesItemBl.Bl012, // Matches C_QTCK.Bl012
+ // BillNo = query.blNo,
+ // WorkNo = blDetail.Bld001, // Matches C_QTCK_D.Bld001
+ // WorkLine = blDetail.Bld013, // Matches C_QTCK_D.Bld013
+ // SuppNo = stockBarcode.SuppNo,
+ // ItemId = stockBarcode.ItemId
+ // // CkDepot = stockBarcode.DepotsId
+ // }).IgnoreColumns(true).ExecuteCommand();
+
+
+ // // 鏇存柊宸ュ崟琛ㄦ暟閲�
+ // db.Updateable<Womdab>()
+ // .SetColumns(it => new Womdab
+ // {
+ // Dab007 = (it.Dab007 ?? 0) + stockBarcode.Quantity,
+ // Dab020 = (it.Dab020 ?? 0) + stockBarcode.Quantity,
+ // Dab021 = (it.Dab021 ?? 0) + stockBarcode.Quantity
+ // })
+ // .Where(it => it.Guid == womdab.DaaGuid && it.Dab003 == womdab.Dab003)
+ // .ExecuteCommand();
+
+ // // 鏇存柊琛ユ枡鍗曟槑缁嗗凡琛ユ暟閲�
+ // db.Updateable<MesItemBlDetail>()
+ // .SetColumns(it => new MesItemBlDetail
+ // {
+ // Bld008 = (it.Bld008 ?? 0) + (int)stockBarcode.Quantity
+ // })
+ // .Where(it => it.Id == blDetail.Id)
+ // .ExecuteCommand();
+
+ // // 妫�鏌ヨˉ鏂欏崟鏄庣粏鏄惁瀹屾垚
+ // var blDetail1 = db.Queryable<MesItemBlDetail>()
+ // .Where(it => it.Id == blDetail.Id)
+ // .First();
+
+ // if ((blDetail1.Bld007 ?? 0) <= (blDetail1.Bld008 ?? 0))
+ // // 鏇存柊鏄庣粏瀹屾垚鐘舵��
+ // db.Updateable<MesItemBlDetail>()
+ // .SetColumns(it => it.Bld011 == 1)
+ // .Where(it => it.Id == blDetail1.Id)
+ // .ExecuteCommand();
+
+ // // 鏇存柊搴撳瓨鏁伴噺涓�0
+ // db.Updateable<MesInvItemStocks>()
+ // .SetColumns(it => it.Quantity == 0)
+ // .Where(it => it.Guid == stockBarcode.Guid)
+ // .ExecuteCommand();
+
+
+ // // 妫�鏌ユ槸鍚︽墍鏈夋槑缁嗛兘宸插畬鎴�
+ // var unfinishedDetail = db.Queryable<MesItemBlDetail>()
+ // .LeftJoin<MesItemBl>((b, a) => a.Id == b.Mid)
+ // .Where((b, a) => a.BlNo == query.blNo && (b.Bld011 ?? 0) == 0)
+ // .Select((b, a) => b)
+ // .First();
+
+ // if (unfinishedDetail == null)
+ // // 濡傛灉娌℃湁鏈畬鎴愮殑鏄庣粏锛屾洿鏂拌ˉ鏂欏崟鐘舵�佷负宸插畬鎴�
+ // db.Updateable<MesItemBl>()
+ // .SetColumns(it => new MesItemBl
+ // {
+ // Bl019 = true,
+ // WcUser = query.userName,
+ // WcTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ // })
+ // .Where(it => it.Id == mesItemBl.Id)
+ // .ExecuteCommand();
+
+ // return 1;
+ //});
+
+ //// 鑾峰彇鏈�缁堢殑寰呭彂鏂欐槑缁嗗垪琛�
+ //var finalPendingList = Db.Queryable<MesItemBl, MesItemBlDetail>(
+ // (a, b) =>
+ // new JoinQueryInfos(JoinType.Left, a.Id == b.Mid))
+ // .Where((a, b) => a.BlNo == query.blNo
+ // && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0)
+ // .Select((a, b) => new MesItemBlDetail
+ // {
+ // Bld012 = b.Bld012,
+ // Bld002 = b.Bld002,
+ // Bld003 = b.Bld003,
+ // Bld004 = b.Bld004,
+ // Bld007 = b.Bld007,
+ // Bld008 = b.Bld008
+ // })
+ // .ToList();
+
+ //return (query, finalPendingList);
}
/// <summary>
@@ -490,501 +597,501 @@
public (bool success, List<MesItemBlDetail> pendingList) SplitBarcode(
WarehouseQuery query)
{
- if (string.IsNullOrEmpty(query.userName))
- throw new Exception("鐢ㄦ埛鍚嶄笉鑳戒负绌猴紒");
+ //if (string.IsNullOrEmpty(query.userName))
+ // throw new Exception("鐢ㄦ埛鍚嶄笉鑳戒负绌猴紒");
- if (string.IsNullOrEmpty(query.billNo))
- throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
+ //if (string.IsNullOrEmpty(query.billNo))
+ // throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
- if (string.IsNullOrEmpty(query.barcode))
- throw new Exception("璇锋壂鎻忔潯鐮侊紒");
+ //if (string.IsNullOrEmpty(query.barcode))
+ // throw new Exception("璇锋壂鎻忔潯鐮侊紒");
- if ((query.Num ?? 0) <= 0)
- throw new Exception("璇疯緭鍏ユ纭殑鍙戞枡鏁伴噺锛�");
+ //if ((query.Num ?? 0) <= 0)
+ // throw new Exception("璇疯緭鍏ユ纭殑鍙戞枡鏁伴噺锛�");
- if (string.IsNullOrEmpty(query.blNo))
- throw new Exception("琛ユ枡鍗曞彿涓嶈兘涓虹┖锛�");
+ //if (string.IsNullOrEmpty(query.blNo))
+ // throw new Exception("琛ユ枡鍗曞彿涓嶈兘涓虹┖锛�");
- // 妫�楠屾槸鍚﹂噸澶嶆壂鎻�
- var exists = Db.Queryable<MesInvItemOutCDetails>()
- .Where(b => b.ItemBarcode == query.barcode)
- .Any();
+ //// 妫�楠屾槸鍚﹂噸澶嶆壂鎻�
+ //var exists = Db.Queryable<MesInvItemOutCDetails>()
+ // .Where(b => b.ItemBarcode == query.barcode)
+ // .Any();
- if (exists)
- throw new Exception("姝ゆ潯鐮佸凡鎵弿,鍕块噸澶嶆壂鐮侊紒");
+ //if (exists)
+ // throw new Exception("姝ゆ潯鐮佸凡鎵弿,鍕块噸澶嶆壂鐮侊紒");
- // 鏌ヨ鏉$爜搴撳瓨淇℃伅
- var stockBarcode = Db.Queryable<MesInvItemStocks>()
- .Where(t => t.ItemBarcode == query.barcode && t.Quantity > 0)
- .First();
+ //// 鏌ヨ鏉$爜搴撳瓨淇℃伅
+ //var stockBarcode = Db.Queryable<MesInvItemStocks>()
+ // .Where(t => t.ItemBarcode == query.barcode && t.Quantity > 0)
+ // .First();
- if (stockBarcode == null)
- throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮�,璇锋牳瀵癸紒{query.barcode}");
+ //if (stockBarcode == null)
+ // throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮�,璇锋牳瀵癸紒{query.barcode}");
- var totalQty = stockBarcode.Quantity;
- string newBarcode = null;
+ //var totalQty = stockBarcode.Quantity;
+ //string newBarcode = null;
- var outNoType = "";
- if (query.Type == "鐢熶骇琛ユ枡")
- {
- outNoType = "SCBL(鐢熶骇琛ユ枡)";
- }
- else
- {
- outNoType = "SCCL(鐢熶骇瓒呴)";
- }
+ //var outNoType = "";
+ //if (query.Type == "鐢熶骇琛ユ枡")
+ //{
+ // outNoType = "SCBL(鐢熶骇琛ユ枡)";
+ //}
+ //else
+ //{
+ // outNoType = "SCCL(鐢熶骇瓒呴)";
+ //}
- // 寮�鍚簨鍔″鐞�
- var success = UseTransaction(db =>
- {
- var executeCommand = 0;
+ //// 寮�鍚簨鍔″鐞�
+ //var success = UseTransaction(db =>
+ //{
+ // var executeCommand = 0;
- // 鎷嗗垎鏉$爜
- if (totalQty > query.Num)
- {
- var mesItems = db.Queryable<MesItems>()
- .Where(s => s.Id == stockBarcode.ItemId).First();
+ // // 鎷嗗垎鏉$爜
+ // if (totalQty > query.Num)
+ // {
+ // var mesItems = db.Queryable<MesItems>()
+ // .Where(s => s.Id == stockBarcode.ItemId).First();
- // 鐢熸垚鏂版潯鐮佸彿
- newBarcode = BillNo.GetBillNo("TM(鏉$爜)", mesItems.ItemNo);
+ // // 鐢熸垚鏂版潯鐮佸彿
+ // newBarcode = BillNo.GetBillNo("TM(鏉$爜)", mesItems.ItemNo);
- // 鍐欏叆鏂版潯鐮�
- executeCommand += db.Insertable(new MesInvItemBarcodes
- {
- Guid = Guid.NewGuid(),
- ItemBarcode = newBarcode,
- CustNo = stockBarcode.CustomerNo,
- // ProductCode = stockBarcode.ProductCode,
- // ItemBarcode2 = stockBarcode.ItemBarcode2,
- // ItemCode = stockBarcode.ItemCode,
- ItemNo = stockBarcode.ItemNo,
- LotNo = stockBarcode.LotNo,
- Quantity = query.Num,
- EpFlag = true,
- TaskNo = stockBarcode.TaskNo,
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- OldItemBarcode = query.barcode,
- // Mblnr = stockBarcode.Mblnr,
- // Zeile = stockBarcode.Zeile,
- // RohInId = stockBarcode.RohInId,
- Barcodestatus = false,
- Oldqty = query.Num as long?,
- // Unit = stockBarcode.Unit,
- // WeightUnit = stockBarcode.WeightUnit,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- BillNo = stockBarcode.BillNo,
- BoardStyle = stockBarcode.BoardStyle,
- // ColorName = stockBarcode.ColorName,
- WorkNo = stockBarcode.WorkNo,
- WorkLine = stockBarcode.WorkLine,
- // MemoBad = stockBarcode.MemoBad,
- ComeFlg = 5,
- // Memo = stockBarcode.Memo,
- SuppId = stockBarcode.SuppId,
- SuppNo = stockBarcode.SuppNo,
- InsDate = stockBarcode.IndepDate, // Added InsDate
- ItemId = stockBarcode.ItemId
- // ItemUnit = stockBarcode.ItemUnit // Added ItemUnit
- }).IgnoreColumns(true).ExecuteCommand();
+ // // 鍐欏叆鏂版潯鐮�
+ // executeCommand += db.Insertable(new MesInvItemBarcodes
+ // {
+ // Guid = Guid.NewGuid(),
+ // ItemBarcode = newBarcode,
+ // CustNo = stockBarcode.CustomerNo,
+ // // ProductCode = stockBarcode.ProductCode,
+ // // ItemBarcode2 = stockBarcode.ItemBarcode2,
+ // // ItemCode = stockBarcode.ItemCode,
+ // ItemNo = stockBarcode.ItemNo,
+ // LotNo = stockBarcode.LotNo,
+ // Quantity = query.Num,
+ // EpFlag = true,
+ // TaskNo = stockBarcode.TaskNo,
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // OldItemBarcode = query.barcode,
+ // // Mblnr = stockBarcode.Mblnr,
+ // // Zeile = stockBarcode.Zeile,
+ // // RohInId = stockBarcode.RohInId,
+ // Barcodestatus = false,
+ // Oldqty = query.Num as long?,
+ // // Unit = stockBarcode.Unit,
+ // // WeightUnit = stockBarcode.WeightUnit,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // BillNo = stockBarcode.BillNo,
+ // BoardStyle = stockBarcode.BoardStyle,
+ // // ColorName = stockBarcode.ColorName,
+ // WorkNo = stockBarcode.WorkNo,
+ // WorkLine = stockBarcode.WorkLine,
+ // // MemoBad = stockBarcode.MemoBad,
+ // ComeFlg = 5,
+ // // Memo = stockBarcode.Memo,
+ // SuppId = stockBarcode.SuppId,
+ // SuppNo = stockBarcode.SuppNo,
+ // InsDate = stockBarcode.IndepDate, // Added InsDate
+ // ItemId = stockBarcode.ItemId
+ // // ItemUnit = stockBarcode.ItemUnit // Added ItemUnit
+ // }).IgnoreColumns(true).ExecuteCommand();
- // 鏇存柊鍘熸潯鐮佹暟閲�
- executeCommand += db.Updateable<MesInvItemBarcodes>()
- .SetColumns(it => it.Quantity == it.Quantity - query.Num)
- .Where(it => it.ItemBarcode == query.barcode)
- .ExecuteCommand();
+ // // 鏇存柊鍘熸潯鐮佹暟閲�
+ // executeCommand += db.Updateable<MesInvItemBarcodes>()
+ // .SetColumns(it => it.Quantity == it.Quantity - query.Num)
+ // .Where(it => it.ItemBarcode == query.barcode)
+ // .ExecuteCommand();
- // 鏇存柊鍘熸潯鐮佹暟閲�
- executeCommand += db.Updateable<MesInvItemStocks>()
- .SetColumns(it => it.Quantity == it.Quantity - query.Num)
- .Where(it => it.ItemBarcode == query.barcode)
- .ExecuteCommand();
+ // // 鏇存柊鍘熸潯鐮佹暟閲�
+ // executeCommand += db.Updateable<MesInvItemStocks>()
+ // .SetColumns(it => it.Quantity == it.Quantity - query.Num)
+ // .Where(it => it.ItemBarcode == query.barcode)
+ // .ExecuteCommand();
- //// 鍒犻櫎鍘熸潯鐮佸簱瀛樿褰�
- //executeCommand += db.Deleteable<MesInvItemStocks>()
- // .Where(it => it.ItemBarcode == query.barcode)
- // .ExecuteCommand();
+ // //// 鍒犻櫎鍘熸潯鐮佸簱瀛樿褰�
+ // //executeCommand += db.Deleteable<MesInvItemStocks>()
+ // // .Where(it => it.ItemBarcode == query.barcode)
+ // // .ExecuteCommand();
- // 鎻掑叆鍓╀綑鏉$爜鏁伴噺鐨勬柊搴撳瓨璁板綍
- executeCommand += db.Insertable(new MesInvItemStocks
- {
- Guid = Guid.NewGuid(),
- TaskNo = stockBarcode.TaskNo,
- ItemBarcode = newBarcode,
- ItemNo = stockBarcode.ItemNo,
- LotNo = stockBarcode.LotNo,
- Quantity = query.Num,
- EpFlag = stockBarcode.EpFlag,
- CustomerNo = stockBarcode.CustomerNo,
- ItemWt = stockBarcode.ItemWt,
- DepotsCode = stockBarcode.DepotsCode,
- DepotsId = stockBarcode.DepotsId,
- DepotSectionsCode = stockBarcode.DepotSectionsCode,
- CheckDate = stockBarcode.CheckDate,
- ItemType = stockBarcode.ItemType,
- IndepDate = stockBarcode.IndepDate,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- IqcStatus = stockBarcode.IqcStatus,
- BoardStyle = stockBarcode.BoardStyle,
- WorkNo = stockBarcode.WorkNo,
- WorkLine = stockBarcode.WorkLine,
- SuppNo = stockBarcode.SuppNo,
- ItemId = stockBarcode.ItemId
- // UnitId = stockBarcode.ItemUnit
- }).IgnoreColumns(true).ExecuteCommand();
+ // // 鎻掑叆鍓╀綑鏉$爜鏁伴噺鐨勬柊搴撳瓨璁板綍
+ // executeCommand += db.Insertable(new MesInvItemStocks
+ // {
+ // Guid = Guid.NewGuid(),
+ // TaskNo = stockBarcode.TaskNo,
+ // ItemBarcode = newBarcode,
+ // ItemNo = stockBarcode.ItemNo,
+ // LotNo = stockBarcode.LotNo,
+ // Quantity = query.Num,
+ // EpFlag = stockBarcode.EpFlag,
+ // CustomerNo = stockBarcode.CustomerNo,
+ // ItemWt = stockBarcode.ItemWt,
+ // DepotsCode = stockBarcode.DepotsCode,
+ // DepotsId = stockBarcode.DepotsId,
+ // DepotSectionsCode = stockBarcode.DepotSectionsCode,
+ // CheckDate = stockBarcode.CheckDate,
+ // ItemType = stockBarcode.ItemType,
+ // IndepDate = stockBarcode.IndepDate,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // IqcStatus = stockBarcode.IqcStatus,
+ // BoardStyle = stockBarcode.BoardStyle,
+ // WorkNo = stockBarcode.WorkNo,
+ // WorkLine = stockBarcode.WorkLine,
+ // SuppNo = stockBarcode.SuppNo,
+ // ItemId = stockBarcode.ItemId
+ // // UnitId = stockBarcode.ItemUnit
+ // }).IgnoreColumns(true).ExecuteCommand();
- // 鍐欏叆鏂版潯鐮佺殑浜ゆ槗璁板綍
- executeCommand += db.Insertable(new MesInvBusiness2
- {
- Guid = Guid.NewGuid(),
- Status = 1,
- BillTypeId = 200, // p_bill_type_id
- TransactionCode = "209", // p_transaction_no
- BusinessType = 0,
- ItemBarcode = newBarcode,
- ItemNo = stockBarcode.ItemNo,
- LotNo = stockBarcode.LotNo,
- EpFlag = true,
- Quantity = query.Num,
- FromInvDepotsCode = null,
- FromInvDepotSectionsCode = null,
- ToInvDepotsCode = stockBarcode.DepotsCode,
- ToInvDepotSectionsCode = stockBarcode.DepotSectionsCode,
- Description = query.Type + "鎷嗗垎鐢熸垚",
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- TaskNo = stockBarcode.TaskNo,
- BillNo = stockBarcode.BillNo,
- WorkNo = stockBarcode.WorkNo,
- WorkLine = stockBarcode.WorkLine,
- SuppNo = stockBarcode.SuppNo,
- SuppId = stockBarcode.SuppId,
- ItemId = stockBarcode.ItemId
- // CkDepot = stockBarcode.DepotsId
- }).IgnoreColumns(true).ExecuteCommand();
- }
- else if (totalQty < query.Num)
- {
- throw new Exception("鍙戞枡鏁伴噺澶т簬鏉$爜鏁�,璇锋牳瀵癸紒");
- }
+ // // 鍐欏叆鏂版潯鐮佺殑浜ゆ槗璁板綍
+ // executeCommand += db.Insertable(new MesInvBusiness2
+ // {
+ // Guid = Guid.NewGuid(),
+ // Status = 1,
+ // BillTypeId = 200, // p_bill_type_id
+ // TransactionCode = "209", // p_transaction_no
+ // BusinessType = 0,
+ // ItemBarcode = newBarcode,
+ // ItemNo = stockBarcode.ItemNo,
+ // LotNo = stockBarcode.LotNo,
+ // EpFlag = true,
+ // Quantity = query.Num,
+ // FromInvDepotsCode = null,
+ // FromInvDepotSectionsCode = null,
+ // ToInvDepotsCode = stockBarcode.DepotsCode,
+ // ToInvDepotSectionsCode = stockBarcode.DepotSectionsCode,
+ // Description = query.Type + "鎷嗗垎鐢熸垚",
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // TaskNo = stockBarcode.TaskNo,
+ // BillNo = stockBarcode.BillNo,
+ // WorkNo = stockBarcode.WorkNo,
+ // WorkLine = stockBarcode.WorkLine,
+ // SuppNo = stockBarcode.SuppNo,
+ // SuppId = stockBarcode.SuppId,
+ // ItemId = stockBarcode.ItemId
+ // // CkDepot = stockBarcode.DepotsId
+ // }).IgnoreColumns(true).ExecuteCommand();
+ // }
+ // else if (totalQty < query.Num)
+ // {
+ // throw new Exception("鍙戞枡鏁伴噺澶т簬鏉$爜鏁�,璇锋牳瀵癸紒");
+ // }
- //if (string.IsNullOrEmpty(newBarcode)) newBarcode = query.barcode;
+ // //if (string.IsNullOrEmpty(newBarcode)) newBarcode = query.barcode;
- // 妫�鏌ヨˉ鏂欏崟鐘舵��
- var mesItemBl = Db.Queryable<MesItemBl>()
- .Where(a => a.BlNo == query.blNo && (a.Bl018 ?? false) == true)
- .First();
+ // // 妫�鏌ヨˉ鏂欏崟鐘舵��
+ // var mesItemBl = Db.Queryable<MesItemBl>()
+ // .Where(a => a.BlNo == query.blNo && (a.Bl018 ?? false) == true)
+ // .First();
- if (mesItemBl == null)
- throw new Exception($"鐢宠鍗� {query.blNo} 宸叉挙鍥烇紒");
+ // if (mesItemBl == null)
+ // throw new Exception($"鐢宠鍗� {query.blNo} 宸叉挙鍥烇紒");
- if (mesItemBl.Bl018 != true)
- throw new Exception($"鐢宠鍗� {query.blNo} 鏈鏍革紒");
+ // if (mesItemBl.Bl018 != true)
+ // throw new Exception($"鐢宠鍗� {query.blNo} 鏈鏍革紒");
- if (mesItemBl.Bl019 == true)
- throw new Exception($"鐢宠鍗� {query.blNo} 宸插畬缁擄紒");
+ // if (mesItemBl.Bl019 == true)
+ // throw new Exception($"鐢宠鍗� {query.blNo} 宸插畬缁擄紒");
- // 鑾峰彇琛ユ枡鍗曟槑缁嗗苟鏍¢獙
- var blDetail = Db.Queryable<MesItemBlDetail>()
- .Where(b =>
- b.Mid == mesItemBl.Id && b.Bld012 == stockBarcode.ItemId)
- .First();
+ // // 鑾峰彇琛ユ枡鍗曟槑缁嗗苟鏍¢獙
+ // var blDetail = Db.Queryable<MesItemBlDetail>()
+ // .Where(b =>
+ // b.Mid == mesItemBl.Id && b.Bld012 == stockBarcode.ItemId)
+ // .First();
- if (blDetail == null)
- throw new Exception($"鐢宠鍗曚笉瀛樺湪姝ょ墿鏂� {stockBarcode.ItemNo} 璇风‘璁わ紒");
+ // if (blDetail == null)
+ // throw new Exception($"鐢宠鍗曚笉瀛樺湪姝ょ墿鏂� {stockBarcode.ItemNo} 璇风‘璁わ紒");
- var remainingQty = (blDetail.Bld007 ?? 0) - (blDetail.Bld008 ?? 0);
- if (remainingQty == 0)
- throw new Exception("鐗╂枡宸叉壂鐮佸畬鎴愶紝璇锋牳瀵癸紒");
+ // var remainingQty = (blDetail.Bld007 ?? 0) - (blDetail.Bld008 ?? 0);
+ // if (remainingQty == 0)
+ // throw new Exception("鐗╂枡宸叉壂鐮佸畬鎴愶紝璇锋牳瀵癸紒");
- if (query.Num > remainingQty)
- throw new Exception(
- $"鎷嗗垎鏁伴噺锛歿query.Num} 澶т簬寰呭彂鏂欐暟閲忥細{remainingQty}锛岃鏍稿锛�");
+ // if (query.Num > remainingQty)
+ // throw new Exception(
+ // $"鎷嗗垎鏁伴噺锛歿query.Num} 澶т簬寰呭彂鏂欐暟閲忥細{remainingQty}锛岃鏍稿锛�");
- // 妫�鏌ュ伐鍗曚俊鎭�
- var womdaa = Db.Queryable<Womdaa>()
- .Where(a => a.Daa001 == query.billNo)
- .First();
+ // // 妫�鏌ュ伐鍗曚俊鎭�
+ // var womdaa = Db.Queryable<Womdaa>()
+ // .Where(a => a.Daa001 == query.billNo)
+ // .First();
- if (womdaa == null)
- throw new Exception($"宸ュ崟 {query.billNo} 涓嶅瓨鍦紝璇风‘璁わ紒");
+ // if (womdaa == null)
+ // throw new Exception($"宸ュ崟 {query.billNo} 涓嶅瓨鍦紝璇风‘璁わ紒");
- var womdab = Db.Queryable<Womdab>()
- .Where(b =>
- b.Dab001 == query.billNo && b.Erpid == blDetail.Bld014)
- .First();
+ // var womdab = Db.Queryable<Womdab>()
+ // .Where(b =>
+ // b.Dab001 == query.billNo && b.Erpid == blDetail.Bld014)
+ // .First();
- if (womdab == null)
- throw new Exception($"澶囨枡鏄庣粏涓嶅瓨鍦ㄦ鐗╂枡 {stockBarcode.ItemNo} 璇风‘璁わ紒");
+ // if (womdab == null)
+ // throw new Exception($"澶囨枡鏄庣粏涓嶅瓨鍦ㄦ鐗╂枡 {stockBarcode.ItemNo} 璇风‘璁わ紒");
- // 妫�鏌ュ凡鍙戞枡鏁伴噺鏄惁瓒呰繃寰呭彂鏂欐暟閲�
- var sumQty = db.Queryable<MesInvItemOutCDetails>()
- .Where(it =>
- it.TaskNo == query.blNo && it.ItemId == stockBarcode.ItemId)
- .Sum(it => it.Quantity);
+ // // 妫�鏌ュ凡鍙戞枡鏁伴噺鏄惁瓒呰繃寰呭彂鏂欐暟閲�
+ // var sumQty = db.Queryable<MesInvItemOutCDetails>()
+ // .Where(it =>
+ // it.TaskNo == query.blNo && it.ItemId == stockBarcode.ItemId)
+ // .Sum(it => it.Quantity);
- //if (sumQty > remainingQty)
- // throw new Exception(
- // $"鎷嗗垎鏁伴噺锛歿sumQty} 澶т簬寰呭彂鏂欐暟閲忥細{remainingQty}锛岃鏍稿锛�");
+ // //if (sumQty > remainingQty)
+ // // throw new Exception(
+ // // $"鎷嗗垎鏁伴噺锛歿sumQty} 澶т簬寰呭彂鏂欐暟閲忥細{remainingQty}锛岃鏍稿锛�");
- var depots = Db.Queryable<MesDepots>()
- .Where(t => t.DepotId == stockBarcode.DepotId)
- .First();
+ // var depots = Db.Queryable<MesDepots>()
+ // .Where(t => t.DepotId == stockBarcode.DepotId)
+ // .First();
- // 鑾峰彇鎴栧垱寤哄嚭搴撳崟
- var itemOut = db.Queryable<MesInvItemOuts>()
- .Where(a => a.TaskNo == query.blNo
- && a.DepotId == stockBarcode.DepotId
- && a.OutDate.Value.Date.ToString("yyyy-MM-dd") ==
- DateTime.Now.Date.ToString("yyyy-MM-dd")
- && a.BillTypeId == 200
- && a.TransactionNo == 209
- && a.Status == 0)
- .First();
+ // // 鑾峰彇鎴栧垱寤哄嚭搴撳崟
+ // var itemOut = db.Queryable<MesInvItemOuts>()
+ // .Where(a => a.TaskNo == query.blNo
+ // && a.DepotId == stockBarcode.DepotId
+ // && a.OutDate.Value.Date.ToString("yyyy-MM-dd") ==
+ // DateTime.Now.Date.ToString("yyyy-MM-dd")
+ // && a.BillTypeId == 200
+ // && a.TransactionNo == 209
+ // && a.Status == 0)
+ // .First();
- var outId = new Guid();
- var outNo = "";
- if (itemOut == null)
- {
- // 鍒涘缓鏂扮殑鍑哄簱鍗�
- outId = Guid.NewGuid();
- outNo = BillNo.GetBillNo(outNoType);
+ // var outId = new Guid();
+ // var outNo = "";
+ // if (itemOut == null)
+ // {
+ // // 鍒涘缓鏂扮殑鍑哄簱鍗�
+ // outId = Guid.NewGuid();
+ // outNo = BillNo.GetBillNo(outNoType);
- // 鎻掑叆鍑哄簱鍗曚富琛�
- executeCommand += db.Insertable(new MesInvItemOuts
- {
- Guid = outId,
- ItemOutNo = outNo,
- TaskNo = query.blNo,
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- BillTypeId = 200,
- TransactionNo = 209,
- Remark = mesItemBl.Bl007,
- DepotCode = depots.DepotCode,
- OutPart = womdaa.Daa013,
- FType = 0,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- WorkNo = womdaa.Daa021,
- BoardItem = womdaa.Daa002,
- PbillNo = womdaa.Daa001,
- OutDate = DateTime.Now,
- Status = 0,
- DepotId = stockBarcode.DepotId,
- THORGID = stockBarcode.StockOrgId,
- OutType = query.Type,
- //BbillNo = query.blNo
- }).IgnoreColumns(true).ExecuteCommand();
- }
- else
- {
- outId = itemOut.Guid;
- outNo = itemOut.ItemOutNo;
- }
+ // // 鎻掑叆鍑哄簱鍗曚富琛�
+ // executeCommand += db.Insertable(new MesInvItemOuts
+ // {
+ // Guid = outId,
+ // ItemOutNo = outNo,
+ // TaskNo = query.blNo,
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // BillTypeId = 200,
+ // TransactionNo = 209,
+ // Remark = mesItemBl.Bl007,
+ // DepotCode = depots.DepotCode,
+ // OutPart = womdaa.Daa013,
+ // FType = 0,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // WorkNo = womdaa.Daa021,
+ // BoardItem = womdaa.Daa002,
+ // PbillNo = womdaa.Daa001,
+ // OutDate = DateTime.Now,
+ // Status = 0,
+ // DepotId = stockBarcode.DepotId,
+ // THORGID = stockBarcode.StockOrgId,
+ // OutType = query.Type,
+ // //BbillNo = query.blNo
+ // }).IgnoreColumns(true).ExecuteCommand();
+ // }
+ // else
+ // {
+ // outId = itemOut.Guid;
+ // outNo = itemOut.ItemOutNo;
+ // }
- // 妫�鏌ユ槸鍚﹀凡瀛樺湪鍑哄簱鍗曟槑缁�
- var itemOutItemCount = db.Queryable<MesInvItemOutItems>()
- .Where(it =>
- it.ItemOutId == outId &&
- it.ItemId == stockBarcode.ItemId &&
- it.DepotId == stockBarcode.DepotId.ToString())
- .Count();
+ // // 妫�鏌ユ槸鍚﹀凡瀛樺湪鍑哄簱鍗曟槑缁�
+ // var itemOutItemCount = db.Queryable<MesInvItemOutItems>()
+ // .Where(it =>
+ // it.ItemOutId == outId &&
+ // it.ItemId == stockBarcode.ItemId &&
+ // it.DepotId == stockBarcode.DepotId.ToString())
+ // .Count();
- if (itemOutItemCount == 0)
- // 鎻掑叆鏂扮殑鍑哄簱鍗曟槑缁�
- executeCommand += db.Insertable(new MesInvItemOutItems
- {
- Guid = Guid.NewGuid(),
- ItemOutId = outId,
- ItemNo = blDetail.Bld002,
- Quantity = query.Num,
- TlQty = query.Num,
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- DepotCode = depots.DepotCode,
- TaskNo = query.blNo,
- WorkNo = womdaa.Daa021,
- WorkLine = blDetail.Bld013,
- ErpItemNo = womdab.Dab003,
- ErpId = womdab.Eid,
- ErpAutoid = womdab.Erpid,
- PbillNo = query.billNo,
- ItemId = blDetail.Bld012,
- DepotId = stockBarcode.DepotId.ToString(),
- ItemDabid = blDetail.Id,
- // Unit = blDetail.Bld009,
- // DepotId = (int)stockBarcode.DepotsId
- }).IgnoreColumns(true).ExecuteCommand();
- else
- // 鏇存柊宸叉湁鍑哄簱鍗曟槑缁嗘暟閲�
- executeCommand += db.Updateable<MesInvItemOutItems>()
- .SetColumns(it => it.TlQty == (it.TlQty ?? 0) + query.Num)
- .Where(it =>
- it.ItemOutId == outId &&
- it.ItemId == stockBarcode.ItemId &&
- it.DepotId == stockBarcode.DepotId.ToString())
- .ExecuteCommand();
+ // if (itemOutItemCount == 0)
+ // // 鎻掑叆鏂扮殑鍑哄簱鍗曟槑缁�
+ // executeCommand += db.Insertable(new MesInvItemOutItems
+ // {
+ // Guid = Guid.NewGuid(),
+ // ItemOutId = outId,
+ // ItemNo = blDetail.Bld002,
+ // Quantity = query.Num,
+ // TlQty = query.Num,
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // DepotCode = depots.DepotCode,
+ // TaskNo = query.blNo,
+ // WorkNo = womdaa.Daa021,
+ // WorkLine = blDetail.Bld013,
+ // ErpItemNo = womdab.Dab003,
+ // ErpId = womdab.Eid,
+ // ErpAutoid = womdab.Erpid,
+ // PbillNo = query.billNo,
+ // ItemId = blDetail.Bld012,
+ // DepotId = stockBarcode.DepotId.ToString(),
+ // ItemDabid = blDetail.Id,
+ // // Unit = blDetail.Bld009,
+ // // DepotId = (int)stockBarcode.DepotsId
+ // }).IgnoreColumns(true).ExecuteCommand();
+ // else
+ // // 鏇存柊宸叉湁鍑哄簱鍗曟槑缁嗘暟閲�
+ // executeCommand += db.Updateable<MesInvItemOutItems>()
+ // .SetColumns(it => it.TlQty == (it.TlQty ?? 0) + query.Num)
+ // .Where(it =>
+ // it.ItemOutId == outId &&
+ // it.ItemId == stockBarcode.ItemId &&
+ // it.DepotId == stockBarcode.DepotId.ToString())
+ // .ExecuteCommand();
- // 鎻掑叆鍑哄簱鏉$爜鏄庣粏
- executeCommand += db.Insertable(new MesInvItemOutCDetails
- {
- Guid = Guid.NewGuid(),
- ItemOutId = outId,
- ItemBarcode = newBarcode ?? query.barcode,
- ItemNo = stockBarcode.ItemNo,
- LotNo = stockBarcode.LotNo,
- Quantity = query.Num,
- ForceOutFlag = 0,
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- DepotCode = depots.DepotCode,
- DepotSectionCode = stockBarcode.DepotSectionsCode,
- Remark = blDetail.Bld010,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- TaskNoy = mesItemBl.Bl013,
- BoardStyle = mesItemBl.Bl002,
- TaskNo = query.blNo,
- WorkNo = blDetail.Bld001,
- WorkLine = blDetail.Bld013,
- SuppNo = stockBarcode.SuppNo,
- PbillNo = query.billNo,
- ItemId = blDetail.Bld012,
- Unit = blDetail.Bld009,
- DepotId = (int)stockBarcode.DepotId,
- Dabid = womdab.Guid,
- }).IgnoreColumns(true).ExecuteCommand();
+ // // 鎻掑叆鍑哄簱鏉$爜鏄庣粏
+ // executeCommand += db.Insertable(new MesInvItemOutCDetails
+ // {
+ // Guid = Guid.NewGuid(),
+ // ItemOutId = outId,
+ // ItemBarcode = newBarcode ?? query.barcode,
+ // ItemNo = stockBarcode.ItemNo,
+ // LotNo = stockBarcode.LotNo,
+ // Quantity = query.Num,
+ // ForceOutFlag = 0,
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // DepotCode = depots.DepotCode,
+ // DepotSectionCode = stockBarcode.DepotSectionsCode,
+ // Remark = blDetail.Bld010,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // TaskNoy = mesItemBl.Bl013,
+ // BoardStyle = mesItemBl.Bl002,
+ // TaskNo = query.blNo,
+ // WorkNo = blDetail.Bld001,
+ // WorkLine = blDetail.Bld013,
+ // SuppNo = stockBarcode.SuppNo,
+ // PbillNo = query.billNo,
+ // ItemId = blDetail.Bld012,
+ // Unit = blDetail.Bld009,
+ // DepotId = (int)stockBarcode.DepotId,
+ // Dabid = womdab.Guid,
+ // }).IgnoreColumns(true).ExecuteCommand();
- // 鎻掑叆涓氬姟娴佹按
- executeCommand += db.Insertable(new MesInvBusiness2
- {
- Guid = Guid.NewGuid(),
- Status = 1,
- BillTypeId = 200, // p_bill_type_id
- TransactionCode = "209", // p_transaction_no
- BusinessType = 1,
- ItemBarcode = newBarcode ?? query.barcode,
- ItemNo = stockBarcode.ItemNo,
- LotNo = stockBarcode.LotNo,
- EpFlag = true,
- Quantity = query.Num,
- FromInvDepotsCode = stockBarcode.DepotsCode,
- FromInvDepotSectionsCode = stockBarcode.DepotSectionsCode,
- Description = query.Type,
- CreateBy = query.userName,
- CreateDate = DateTime.Now,
- LastupdateBy = query.userName,
- LastupdateDate = DateTime.Now,
- Factory = stockBarcode.Factory,
- Company = stockBarcode.Company,
- TaskNo = mesItemBl.Bl012,
- BillNo = query.blNo,
- WorkNo = blDetail.Bld001,
- WorkLine = blDetail.Bld013,
- SuppNo = stockBarcode.SuppNo,
- ItemId = stockBarcode.ItemId
- // CkDepot = stockBarcode.DepotsId
- }).IgnoreColumns(true).ExecuteCommand();
+ // // 鎻掑叆涓氬姟娴佹按
+ // executeCommand += db.Insertable(new MesInvBusiness2
+ // {
+ // Guid = Guid.NewGuid(),
+ // Status = 1,
+ // BillTypeId = 200, // p_bill_type_id
+ // TransactionCode = "209", // p_transaction_no
+ // BusinessType = 1,
+ // ItemBarcode = newBarcode ?? query.barcode,
+ // ItemNo = stockBarcode.ItemNo,
+ // LotNo = stockBarcode.LotNo,
+ // EpFlag = true,
+ // Quantity = query.Num,
+ // FromInvDepotsCode = stockBarcode.DepotsCode,
+ // FromInvDepotSectionsCode = stockBarcode.DepotSectionsCode,
+ // Description = query.Type,
+ // CreateBy = query.userName,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = query.userName,
+ // LastupdateDate = DateTime.Now,
+ // Factory = stockBarcode.Factory,
+ // Company = stockBarcode.Company,
+ // TaskNo = mesItemBl.Bl012,
+ // BillNo = query.blNo,
+ // WorkNo = blDetail.Bld001,
+ // WorkLine = blDetail.Bld013,
+ // SuppNo = stockBarcode.SuppNo,
+ // ItemId = stockBarcode.ItemId
+ // // CkDepot = stockBarcode.DepotsId
+ // }).IgnoreColumns(true).ExecuteCommand();
- // 鏇存柊宸ュ崟琛ㄦ暟閲�
- executeCommand += db.Updateable<Womdab>()
- .SetColumns(it => new Womdab
- {
- Dab007 = (it.Dab007 ?? 0) + query.Num, // 宸ュ崟鏁伴噺
- Dab020 = (it.Dab020 ?? 0) + query.Num, // 宸插彂鏂欐暟閲�
- Dab021 = (it.Dab021 ?? 0) + query.Num // 宸插彂鏂欐暟閲�
- })
- .Where(it => it.Guid == womdab.DaaGuid && it.Dab003 == womdab.Dab003)
- .ExecuteCommand();
+ // // 鏇存柊宸ュ崟琛ㄦ暟閲�
+ // executeCommand += db.Updateable<Womdab>()
+ // .SetColumns(it => new Womdab
+ // {
+ // Dab007 = (it.Dab007 ?? 0) + query.Num, // 宸ュ崟鏁伴噺
+ // Dab020 = (it.Dab020 ?? 0) + query.Num, // 宸插彂鏂欐暟閲�
+ // Dab021 = (it.Dab021 ?? 0) + query.Num // 宸插彂鏂欐暟閲�
+ // })
+ // .Where(it => it.Guid == womdab.DaaGuid && it.Dab003 == womdab.Dab003)
+ // .ExecuteCommand();
- // 鏇存柊琛ユ枡鍗曟槑缁嗗凡琛ユ暟閲�
- executeCommand += db.Updateable<MesItemBlDetail>()
- .SetColumns(it => new MesItemBlDetail
- {
- Bld008 = (it.Bld008 ?? 0) + (int)query.Num
- })
- .Where(it => it.Id == blDetail.Id)
- .ExecuteCommand();
+ // // 鏇存柊琛ユ枡鍗曟槑缁嗗凡琛ユ暟閲�
+ // executeCommand += db.Updateable<MesItemBlDetail>()
+ // .SetColumns(it => new MesItemBlDetail
+ // {
+ // Bld008 = (it.Bld008 ?? 0) + (int)query.Num
+ // })
+ // .Where(it => it.Id == blDetail.Id)
+ // .ExecuteCommand();
- // 鑾峰彇鏇存柊鍚庣殑琛ユ枡鍗曟槑缁嗘暟閲�
- var updatedDetail = db.Queryable<MesItemBlDetail>()
- .Where(it => it.Id == blDetail.Id)
- .Select(it => new { it.Bld007, it.Bld008 })
- .First();
+ // // 鑾峰彇鏇存柊鍚庣殑琛ユ枡鍗曟槑缁嗘暟閲�
+ // var updatedDetail = db.Queryable<MesItemBlDetail>()
+ // .Where(it => it.Id == blDetail.Id)
+ // .Select(it => new { it.Bld007, it.Bld008 })
+ // .First();
- if ((updatedDetail.Bld007 ?? 0) <= (updatedDetail.Bld008 ?? 0))
- // 鏇存柊鏄庣粏瀹屾垚鐘舵��
- executeCommand += db.Updateable<MesItemBlDetail>()
- .SetColumns(it => new MesItemBlDetail { Bld011 = 1 })
- .Where(it => it.Id == blDetail.Id)
- .ExecuteCommand();
+ // if ((updatedDetail.Bld007 ?? 0) <= (updatedDetail.Bld008 ?? 0))
+ // // 鏇存柊鏄庣粏瀹屾垚鐘舵��
+ // executeCommand += db.Updateable<MesItemBlDetail>()
+ // .SetColumns(it => new MesItemBlDetail { Bld011 = 1 })
+ // .Where(it => it.Id == blDetail.Id)
+ // .ExecuteCommand();
- // 妫�鏌ユ槸鍚﹁繕鏈夋湭瀹屾垚鐨勬槑缁�
+ // // 妫�鏌ユ槸鍚﹁繕鏈夋湭瀹屾垚鐨勬槑缁�
- var unfinishedDetail = db.Queryable<MesItemBlDetail>()
- .Where(it => it.Mid == mesItemBl.Id && (it.Bld011 ?? 0) == 0)
- .First();
+ // var unfinishedDetail = db.Queryable<MesItemBlDetail>()
+ // .Where(it => it.Mid == mesItemBl.Id && (it.Bld011 ?? 0) == 0)
+ // .First();
- if (unfinishedDetail == null)
- // 濡傛灉娌℃湁鎵惧埌鏈畬鎴愭槑缁嗭紝鍒欐洿鏂拌ˉ鏂欏崟鐘舵�佷负宸插畬鎴�
- executeCommand += db.Updateable<MesItemBl>()
- .SetColumns(it => new MesItemBl
- {
- Bl019 = true,
- WcUser = query.userName,
- WcTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .Where(it => it.Id == mesItemBl.Id)
- .ExecuteCommand();
+ // if (unfinishedDetail == null)
+ // // 濡傛灉娌℃湁鎵惧埌鏈畬鎴愭槑缁嗭紝鍒欐洿鏂拌ˉ鏂欏崟鐘舵�佷负宸插畬鎴�
+ // executeCommand += db.Updateable<MesItemBl>()
+ // .SetColumns(it => new MesItemBl
+ // {
+ // Bl019 = true,
+ // WcUser = query.userName,
+ // WcTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ // })
+ // .Where(it => it.Id == mesItemBl.Id)
+ // .ExecuteCommand();
- if (executeCommand <= 1) throw new Exception("鏇存柊澶辫触");
+ // if (executeCommand <= 1) throw new Exception("鏇存柊澶辫触");
- // 鍒涘缓 鎻掑叆鏃ュ織
- var logService = new LogService();
- var LogMsg = "[PDA]" + query.Type + "銆傛潯鐮併��" + query.barcode + "銆� 鍑哄簱鍗曞彿銆�" + outNo + "銆�";
- logService.CreateLog(db, query.userName, womdaa.Guid.ToString(), "WOMDAA", LogMsg, womdaa.Daa001);
+ // // 鍒涘缓 鎻掑叆鏃ュ織
+ // var logService = new LogService();
+ // var LogMsg = "[PDA]" + query.Type + "銆傛潯鐮併��" + query.barcode + "銆� 鍑哄簱鍗曞彿銆�" + outNo + "銆�";
+ // logService.CreateLog(db, query.userName, womdaa.Guid.ToString(), "WOMDAA", LogMsg, womdaa.Daa001);
- return executeCommand;
- }) > 0;
+ // return executeCommand;
+ //}) > 0;
- // 鑾峰彇鏈�缁堢殑寰呭彂鏂欐槑缁嗗垪琛�
- var pendingList = Db.Queryable<MesItemBl, MesItemBlDetail>((a, b) =>
- new JoinQueryInfos(JoinType.Left, a.Id == b.Mid))
- .Where((a, b) => a.BlNo == query.blNo
- && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0)
- .Select((a, b) => new MesItemBlDetail
- {
- Bld012 = b.Bld012,
- Bld002 = b.Bld002,
- Bld003 = b.Bld003,
- Bld004 = b.Bld004,
- Bld007 = b.Bld007,
- Bld008 = b.Bld008
- })
- .ToList();
+ //// 鑾峰彇鏈�缁堢殑寰呭彂鏂欐槑缁嗗垪琛�
+ //var pendingList = Db.Queryable<MesItemBl, MesItemBlDetail>((a, b) =>
+ // new JoinQueryInfos(JoinType.Left, a.Id == b.Mid))
+ // .Where((a, b) => a.BlNo == query.blNo
+ // && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0)
+ // .Select((a, b) => new MesItemBlDetail
+ // {
+ // Bld012 = b.Bld012,
+ // Bld002 = b.Bld002,
+ // Bld003 = b.Bld003,
+ // Bld004 = b.Bld004,
+ // Bld007 = b.Bld007,
+ // Bld008 = b.Bld008
+ // })
+ // .ToList();
- return (success, pendingList);
+ //return (success, pendingList);
}
#endregion
@@ -1861,7 +1968,7 @@
fROM MES_ITEM_BL_DETAIL A
LEFT JOIN MES_ITEM_BL B ON A.MID = B.ID
LEFT JOIN MES_ITEMS C ON A.bld012 = CAST(C.item_id AS VARCHAR(50))
- LEFT JOIN WW_GD D ON B.about_guid = D.ID
+ LEFT JOIN WOMDAA D ON B.about_guid = D.guid
WHERE B.bl_no = '{0}'", query.billNo);
var womdabs = Db.Ado.SqlQuery<ItemDetailModel>(sql);
diff --git a/service/Warehouse/MesItemTblManager.cs b/service/Warehouse/MesItemTblManager.cs
index 8464f91..b31d262 100644
--- a/service/Warehouse/MesItemTblManager.cs
+++ b/service/Warehouse/MesItemTblManager.cs
@@ -5,6 +5,8 @@
using NewPdaSqlServer.entity.Base;
using NewPdaSqlServer.util;
using SqlSugar;
+using System.Data;
+using System.Data.SqlClient;
using System.Security.Cryptography;
namespace NewPdaSqlServer.service.Warehouse;
@@ -109,477 +111,537 @@
/// <returns>澶勭悊缁撴灉</returns>
public WarehouseQuery SctlScanBarcode(WarehouseQuery query)
{
- var p_item_barcode = query.barcode; // 鐗╂枡鏉$爜
- var p_bill_no = query.billNo; // 鍗曟嵁鍙�
- var p_section_code = query.DepotCode; // 搴撲綅缂栫爜
- var c_user = query.userName; // 鐢ㄦ埛鍚�
- var p_bill_type_id = 100; // 鍗曟嵁绫诲瀷ID
- var p_transction_no = 104; // 浜ゆ槗缂栧彿
-
- // 楠岃瘉搴撲綅鏉$爜
- if (p_section_code.IsNullOrEmpty()) throw new Exception("璇锋壂搴撲綅鏉$爜锛�");
-
- // 鑾峰彇搴撲綅淇℃伅
- var c_depot_code = Db.Queryable<MesDepotSections, MesDepots>((a, b) =>
- new JoinQueryInfos(JoinType.Inner, a.DepotGuid == b.Guid))
- .Where((a, b) => a.DepotSectionCode == p_section_code)
- .Select((a, b) => b.DepotId).First();
-
- if (!c_depot_code.HasValue)
- throw new Exception("搴撲綅缂栫爜" + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
-
- // 鑾峰彇搴撲綅鍒嗗尯淇℃伅
- var mesDepotSections = Db.Queryable<MesDepotSections>()
- .Where(a => a.DepotSectionCode == p_section_code).First();
-
- if (mesDepotSections == null)
- throw new Exception("搴撲綅缂栫爜" + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
-
- // 鑾峰彇搴撲綅鍩虹淇℃伅
- var c_mes_depots = Db.Queryable<MesDepots>()
- .Where(b => b.Guid == mesDepotSections.DepotGuid).First();
-
- if (c_mes_depots == null)
- throw new Exception("搴撲綅缂栫爜" + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
-
- // 妫�鏌ユ潯鐮佹槸鍚﹀凡鍏ュ簱
- var c_num = Db.Queryable<MesInvItemIns, MesInvItemInCDetails>((a, b) =>
- new JoinQueryInfos(JoinType.Inner, a.Guid == b.ItemInId))
- .Where((a, b) => b.ItemBarcode == p_item_barcode
- && a.BillTypeId == p_bill_type_id &&
- a.TransctionNo == p_transction_no.ToString())
- .Count();
-
- if (c_num > 0) throw new Exception("姝ゆ潯鐮佸凡鎵叆搴擄紝鍕块噸澶嶆壂鎻忥紒");
-
- c_num = Db.Queryable<MesInvItemStocks>()
- .Where(t => t.ItemBarcode == p_item_barcode).Count();
-
- if (c_num > 0) throw new Exception("姝ゆ潯鐮佸凡鎵叆搴擄紝鍕块噸澶嶆壂鎻忥紒");
-
- // 鑾峰彇鏉$爜淇℃伅
- var c_mes_inv_item_barcodes = Db.Queryable<MesInvItemBarcodes>()
- .Where(t => t.ItemBarcode == p_item_barcode).First();
-
- if (c_mes_inv_item_barcodes == null)
- throw new Exception("姝ゆ潯鐮佷笉灞炰簬璇ラ��鏂欏崟锛岃鏍稿锛�");
-
- if (c_mes_inv_item_barcodes.Memo != "鐢熶骇閫�鏂�")
- throw new Exception("姝ゆ潯鐮佷笉鏄敓浜ч��鏂欐潯鐮侊紝涓嶅彲浣跨敤鐢熶骇閫�鏂欐ā鍧楋紒");
-
- // 浣跨敤 String.Equals 鏂规硶杩涜瀛楃涓叉瘮杈冿紝鎸囧畾姣旇緝瑙勫垯涓哄拷鐣ュぇ灏忓啓锛屾彁楂樻瘮杈冪殑鐏垫椿鎬�
- if (!string.Equals(c_mes_inv_item_barcodes.BillNo, p_bill_no, StringComparison.OrdinalIgnoreCase))
- throw new Exception($"璇ユ潯鐮佸搴旂殑鐢宠鍙枫�恵c_mes_inv_item_barcodes.BillNo}銆戜笌 褰撳墠鐢宠鍗曞彿銆恵p_bill_no}銆戜笉涓�鑷达紝璇锋牳瀵癸紒");
- // 鑾峰彇閫�鏂欏崟淇℃伅
- var C_MES_ITEM_TBL = Db.Queryable<MesItemTbl>()
- .Where(a => a.BillNo == p_bill_no
- && (a.Tbl013 ?? 0) == 1).First();
-
-
-
- // 鑾峰彇閫�鏂欏崟淇℃伅
- var tbWOMDAA = Db.Queryable<Womdaa>()
- .Where(a => a.Guid.ToString() == C_MES_ITEM_TBL.Tbl002).First();
-
-
-
- if (C_MES_ITEM_TBL == null) throw new Exception("鐢宠鍗曞凡鎾ゅ洖,鏃犳硶鎵爜!");
-
- if (C_MES_ITEM_TBL.Tbl020 == 1) throw new Exception("鎵爜瀹屾垚,鐢宠鍗曞凡瀹岀粨!");
-
- // 鑾峰彇閫�鏂欏崟鏄庣粏
- var C_MES_ITEM_TBL_DETAIL = Db.Queryable<MesItemTblDetail>()
- .Where(a => a.Tlid == c_mes_inv_item_barcodes.AboutGuid)
+ // 2. 楠岃瘉鏉$爜淇℃伅
+ var barcode = Db.Queryable<MesInvItemBarcodes>()
+ .Where(x => x.ItemBarcode == query.barcode)
.First();
+ if (barcode == null)
+ throw new Exception($"鏃犳鏉$爜锛岃鏍稿锛亄query.barcode}");
- if (C_MES_ITEM_TBL_DETAIL == null)
- throw new Exception("鏉$爜涓嶅睘浜庤鐢宠鍗曟槑缁�,鏃犳硶鎵爜!");
+ // 3. 楠岃瘉鐗╂枡淇℃伅
+ var item = Db.Queryable<MesItems>()
+ .Where(x => x.Id == barcode.ItemId)
+ .First();
+ if (item == null)
+ throw new Exception($"鏃犳鐗╂枡锛岃鏍稿锛亄query.barcode}");
- var CABerpid = Db.Queryable<Womdab>().Where(womdab => womdab.Guid.ToString() == C_MES_ITEM_TBL_DETAIL.Tld013).Select(womdab => womdab.Erpid).First();
+ // 4. 楠岃瘉閫�鏂欏崟淇℃伅
+ var returnOrder = Db.Queryable<MesItemTbl>()
+ .Where(x => x.BillNo == query.billNo && (x.Tbl013 ?? 0) == 1)
+ .First();
+ if (returnOrder == null)
+ throw new Exception("鐢宠鍗曞凡鎾ゅ洖,鏃犳硶鎵爜!");
- var ownerId = Db.Queryable<Womcab>().Where(womcab => womcab.Erpid == CABerpid.Value).Select(womcab => womcab.OwnerId).First();
+ if (returnOrder.Tbl020 == 1)
+ throw new Exception("鎵爜瀹屾垚,鐢宠鍗曞凡瀹岀粨!");
- if (ownerId == null) throw new Exception("鐢ㄦ枡娓呭崟璐т富淇℃伅涓嶅瓨鍦�,鏃犳硶鎵爜锛岃鑱旂郴绠$悊鍛�!");
-
- var owner_type = "";
- if (Db.Queryable<SysOrganization>().Any(x => x.Fid == ownerId))
+ // 5. 浣跨敤瀛樺偍杩囩▼澶勭悊鐢熶骇閫�鏂�
+ var parameters = new SqlParameter[]
{
- owner_type = "BD_OwnerOrg";
- }
- else
+ new SqlParameter("@pi_user", query.userName),
+ new SqlParameter("@pi_barcode", query.barcode),
+ new SqlParameter("@pi_bill_no", query.billNo),
+ new SqlParameter("@pi_section_code", query.DepotCode),
+ new SqlParameter("@PI_INP1", DBNull.Value), // 澶囩敤鍙傛暟1
+ new SqlParameter("@PI_INP2", DBNull.Value), // 澶囩敤鍙傛暟2
+ new SqlParameter("@PO_OUT_MSG", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output },
+ new SqlParameter("@PO_OUT_SUM", SqlDbType.Int) { Direction = ParameterDirection.Output },
+ new SqlParameter("@PO_ITEM_NO", SqlDbType.NVarChar, 100) { Direction = ParameterDirection.Output },
+ new SqlParameter("@PO_QUANTITY", SqlDbType.Decimal) { Direction = ParameterDirection.Output }
+ };
+
+ string procedureName = "PRC_PDA_SCTL";
+ int res = DbHelperSQL.RunProcedure_NonQuery(procedureName, parameters);
+
+ // 鑾峰彇杈撳嚭鍙傛暟
+ var outMsg = parameters[6].Value?.ToString() ?? string.Empty;
+ var outSum = parameters[7].Value != DBNull.Value ? Convert.ToInt32(parameters[7].Value) : -1;
+ var itemNo = parameters[8].Value?.ToString() ?? string.Empty;
+ var quantity = parameters[9].Value != DBNull.Value ? Convert.ToDecimal(parameters[9].Value) : 0m;
+
+ // 妫�鏌ュ瓨鍌ㄨ繃绋嬫墽琛岀粨鏋�
+ if (outSum == -1)
{
- // 绗簩灞傚垽鏂細妫�鏌� MES_CUSTOMER
- if (Db.Queryable<MesCustomer>().Any(x => x.Id == Convert.ToInt32(ownerId)))
- {
- owner_type = "BD_Customer";
- }
- else
- {
- // 绗笁灞傚垽鏂細妫�鏌� MES_SUPPLIER
- if (Db.Queryable<MesSupplier>().Any(x => x.Id == Convert.ToInt32(ownerId)))
- {
- owner_type = "BD_Supplier";
- }
- else
- {
- throw new Exception("鍏ュ簱澶辫触,鐢ㄦ枡娓呭崟璐т富淇℃伅瀛樺湪闂锛岃鑱旂郴绠$悊鍛樿В鍐筹紒");
- }
- }
+ throw new Exception(outMsg);
}
-
- var c_quantity = c_mes_inv_item_barcodes.Quantity;
-
- var c_bill_no = "";
- var c_id = Guid.Empty;
-
- // 浣跨敤浜嬪姟澶勭悊鏁版嵁鏇存柊
- UseTransaction(db =>
- {
- // 鏌ヨ鍏ュ簱鍗�
- var mesInvItemIns = db.Queryable<MesInvItemIns>()
- .Where(d =>
- d.Status == 0 && d.TransctionNo ==
- p_transction_no.ToString()
- && d.TaskNo == c_mes_inv_item_barcodes.BillNo
- && d.DepotsId == c_depot_code
- && d.InsDate.Value.ToString("yyyyMMdd") ==
- DateTime.Now.ToString("yyyyMMdd")).First();
-
- var totalResult = 0;
-
- // 濡傛灉鍏ュ簱鍗曚笉瀛樺湪鍒欏垱寤烘柊鐨勫叆搴撳崟
- if (mesInvItemIns == null)
- {
- c_bill_no = BillNo.GetBillNo("SCTL(鐢熶骇閫�鏂�)");
-
- c_id = Guid.NewGuid();
-
- totalResult += db.Insertable(new MesInvItemIns
- {
- Guid = c_id,
- BillNo = c_bill_no,
- BillTypeId = p_bill_type_id,
- InsDate = DateTime.Now,
- DepotsId = c_depot_code,
- UserNoBack = c_user,
- Reason = C_MES_ITEM_TBL.Tbl005,
- Remark = C_MES_ITEM_TBL.Tbl006,
- //InsDate = DateTime.Now,
- DepotsCode = c_mes_depots.DepotCode,
- TaskNo = c_mes_inv_item_barcodes.BillNo,
- //DepotsId = c_depot_code,
- TransctionNo = p_transction_no.ToString(),
- CreateBy = c_user,
- CreateDate = DateTime.Now,
- LastupdateBy = c_user,
- LastupdateDate = DateTime.Now,
- CbillNo = tbWOMDAA.Daa001,
- InType = "鐢熶骇閫�鏂�",
- ReceiveOrgId = c_mes_depots.FSubsidiary,
- Fstatus = 0,
- Status = 0,
- WorkNo = tbWOMDAA.Daa021
- }).IgnoreColumns(true).ExecuteCommand();
- }
- else
- {
- c_id = mesInvItemIns.Guid;
- c_bill_no = mesInvItemIns.BillNo;
- }
-
- // 妫�鏌ユ槸鍚︿负鍚堝苟鎵撳嵃鏉$爜
- var hbdy = c_mes_inv_item_barcodes.Hbdy ?? 0;
- if (hbdy == 1) throw new Exception("涓嶆敮鎸佸悎骞舵墦鍗扮殑鏉$爜:" + p_item_barcode);
-
-
- // 妫�鏌ユ槸鍚﹀瓨鍦ㄤ簬 MES_INV_ITEM_IN_C_ITEMS 琛�
- var existingCount = db.Queryable<MesInvItemInCItems>()
- .Where(it =>
- it.ItemInId == c_id &&
- it.ItemId == C_MES_ITEM_TBL_DETAIL.Tld009 &&
- it.DepotId == c_depot_code.ToString())
- .Count();
-
- if (existingCount == 0)
- // 涓嶅瓨鍦ㄦ椂鎻掑叆鏂拌褰�
- db.Insertable(new MesInvItemInCItems
- {
- ItemInId = c_id,
- Quantity = c_mes_inv_item_barcodes.Quantity,
- CreateBy = c_user,
- CreateDate = DateTime.Now,
- ItemNo = c_mes_inv_item_barcodes.ItemNo,
- //DepotCode = mesDepost.DepotCode,
- ItemSname = c_mes_inv_item_barcodes.ItemSname,
- Unit = c_mes_inv_item_barcodes.Unit,
- Ebeln = c_mes_inv_item_barcodes.WorkNo,
- BillNo = c_bill_no,
- WorkNo = c_mes_inv_item_barcodes.WorkNo,
- EbelnLineNo = c_mes_inv_item_barcodes.WorkLine,
- CbillNo = c_mes_inv_item_barcodes.BillNo,
- WorkLine = c_mes_inv_item_barcodes.WorkLine,
- SuppId = c_mes_inv_item_barcodes.SuppId,
- SuppNo = c_mes_inv_item_barcodes.SuppNo,
- Remark = c_mes_inv_item_barcodes.Memo,
- EbelnK3id = c_mes_inv_item_barcodes.EbelnK3id,
- LineK3id = c_mes_inv_item_barcodes.LineK3id,
- ItemId = c_mes_inv_item_barcodes.ItemId,
- DepotCode = c_mes_depots.DepotCode,
- DepotId = c_depot_code.ToString(),
- itemDabid = C_MES_ITEM_TBL_DETAIL.Tlid.ToString()
- }).IgnoreColumns(true).ExecuteCommand();
- else
- // 瀛樺湪鏃舵洿鏂版暟閲�
- db.Updateable<MesInvItemInCItems>()
- .SetColumns(it => new MesInvItemInCItems
- {
- Quantity = SqlFunc.IsNull(it.Quantity, 0) + c_mes_inv_item_barcodes.Quantity // 纭繚 Quantity 涓嶄负 null
- })
- .Where(it =>
- it.ItemInId == c_id &&
- it.ItemId == C_MES_ITEM_TBL_DETAIL.Tld009 &&
- it.DepotId == c_depot_code.ToString())
- //.IgnoreColumns(true) // 淇濈暀 IgnoreColumns
- .ExecuteCommand();
-
-
- // 鎻掑叆 mes_inv_item_in_c_details 琛�
- totalResult += db.Insertable(new MesInvItemInCDetails
- {
- ItemInId = c_id,
- BillNo = c_bill_no,
- ItemBarcode = p_item_barcode,
- Quantity = c_mes_inv_item_barcodes.Quantity,
- BarcodeFlag = true,
- EpFlag = true,
- WorkType = 1,
- ItemNo = c_mes_inv_item_barcodes.ItemNo,
- //LotNo = cgddDetails.BatchNumber,--鎵瑰彿锛岄��鏂欎笉璁剧疆鎵瑰彿
- SuppId = c_mes_inv_item_barcodes.SuppId,
- SuppNo = c_mes_inv_item_barcodes.SuppNo,
- //DepotCode = mesDepost.DepotCode,
- DepotSectionCode = p_section_code,
- ItemSname = c_mes_inv_item_barcodes.ItemSname,
- Unit = c_mes_inv_item_barcodes.Unit,
- CreateBy = c_user,
- CreateDate = DateTime.Now,
- LastupdateBy = c_user,
- LastupdateDate = DateTime.Now,
- Remark = c_mes_inv_item_barcodes.Memo,
- Ebeln = c_mes_inv_item_barcodes.Mblnr,
- EbelnLineNo = c_mes_inv_item_barcodes.Zeile,
- WorkNo = c_mes_inv_item_barcodes.WorkNo,
- WorkLine = c_mes_inv_item_barcodes.WorkLine,
- CbillNo = c_mes_inv_item_barcodes.BillNo,
- UrgentFlag = c_mes_inv_item_barcodes.UrgentFlag,
- BoardStyle = c_mes_inv_item_barcodes.BoardStyle,
- TaskNo = c_mes_inv_item_barcodes.TaskNo,
- EbelnK3id = c_mes_inv_item_barcodes.EbelnK3id,
- LineK3id = c_mes_inv_item_barcodes.LineK3id,
- ItemId = c_mes_inv_item_barcodes.ItemId,
- Ischeck = true,
- //CheckDate = C_MES_ITEM_TBL_DETAIL.CheckDate,
- //CheckRes = C_MES_ITEM_TBL_DETAIL.CheckRes,
- //CheckStates = C_MES_ITEM_TBL_DETAIL.CheckStates,--妫�楠屼俊鎭�
- ReceiveOrgId = c_mes_depots.FSubsidiary,
- DepotCode = c_mes_depots.DepotCode,
- DepotId = Convert.ToInt64(c_depot_code)
- }).IgnoreColumns(true).ExecuteCommand();
-
- // 鎻掑叆涓氬姟璁板綍
- totalResult += db.Insertable(new MesInvBusiness2
- {
- Guid = Guid.NewGuid(),
- Status = 1,
- BillTypeId = p_bill_type_id,
- TransactionCode = p_transction_no.ToString(),
- BusinessType = 1,
- ItemBarcode = p_item_barcode,
- ItemNo = c_mes_inv_item_barcodes.ItemNo,
- LotNo = c_mes_inv_item_barcodes.LotNo,
- EpFlag = true,
- Quantity = c_mes_inv_item_barcodes.Quantity,
- ToInvDepotsCode = c_mes_depots.DepotCode,
- InvDepotId = c_depot_code,
- ToInvDepotSectionsCode = p_section_code,
- Description = "鐢熶骇閫�鏂�",
- CreateBy = c_user,
- CreateDate = DateTime.Now,
- LastupdateBy = c_user,
- LastupdateDate = DateTime.Now,
- TaskNo = c_mes_inv_item_barcodes.TaskNo,
- BillNo = c_bill_no,
- WorkNo = c_mes_inv_item_barcodes.WorkNo,
- WorkLine = c_mes_inv_item_barcodes.WorkLine,
- SuppId = c_mes_inv_item_barcodes.SuppId,
- SuppNo = c_mes_inv_item_barcodes.SuppNo,
- ItemId = c_mes_inv_item_barcodes.ItemId
- }).IgnoreColumns(true).ExecuteCommand();
-
- // 鎻掑叆搴撳瓨璁板綍
- totalResult += db.Insertable(new MesInvItemStocks
- {
- Guid = Guid.NewGuid(),
- TaskNo = c_mes_inv_item_barcodes.TaskNo,
- ItemBarcode = p_item_barcode,
- ItemNo = c_mes_inv_item_barcodes.ItemNo,
- LotNo = c_mes_inv_item_barcodes.LotNo,
- Quantity = c_mes_inv_item_barcodes.Quantity,
- //EpFlag = c_mes_inv_item_barcodes.EpFlag.Value
- // ? (byte)1
- // : (byte)0,
- DepotId = c_mes_depots.DepotId,
- DepotsCode = c_mes_depots.DepotCode,
- DepotSectionsCode = p_section_code,
- CheckDate = c_mes_inv_item_barcodes.CreateDate,
- IndepDate = DateTime.Now,
- BoardStyle = c_mes_inv_item_barcodes.BoardStyle,
- WorkNo = c_mes_inv_item_barcodes.WorkNo,
- WorkLine = c_mes_inv_item_barcodes.WorkLine,
- SuppNo = c_mes_inv_item_barcodes.SuppNo,
- ItemId = c_mes_inv_item_barcodes.ItemId,
- BillNo = c_mes_inv_item_barcodes.BillNo,
- //DepotId = Convert.ToInt32(c_depot_code),
- OwnerId = ownerId,
- OwnerType = owner_type,
- StockOrgId = c_mes_depots.FSubsidiary,
- IndepUserCode = c_user
- }).IgnoreColumns(true).ExecuteCommand();
-
- // 鏍规嵁閫�鏂欑被鍨�(鑹搧閫�鏂欍�佹潵鏂欎笉鑹��鏂欍�佷綔涓氫笉鑹��鏂�)鏇存柊鐩稿叧鏁版嵁
- if (C_MES_ITEM_TBL.Tbl005 is "鑹搧閫�鏂�" or "鏉ユ枡涓嶈壇閫�鏂�")
- {
- // 鑹搧閫�鏂� - 鏇存柊宸ュ崟琛�(WOMDAB)鐩稿叧鏁伴噺
- if (C_MES_ITEM_TBL.Tbl005 == "鑹搧閫�鏂�")
- totalResult += Db.Updateable<Womdab>()
- .SetColumns(it => new Womdab
- {
- Dab007 = it.Dab007 -
- c_mes_inv_item_barcodes.Quantity, // 鍑忓皯宸ュ崟鏁伴噺
- Dab022 = (it.Dab022 ?? 0) +
- c_mes_inv_item_barcodes.Quantity, // 澧炲姞閫�鏂欐暟閲�
- LpTl = (it.LpTl ?? 0) +
- (int)c_mes_inv_item_barcodes
- .Quantity, // 澧炲姞鑹搧閫�鏂欐暟閲�
- Dab020 = (it.Dab020 ?? 0) -
- c_mes_inv_item_barcodes.Quantity // 鍑忓皯宸插彂鏂欐暟閲�
- })
- .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo
- && it.Dab002 == c_mes_inv_item_barcodes
- .WorkLine
- && it.Dab003 == c_mes_inv_item_barcodes
- .ItemId.ToString())
- .ExecuteCommand();
- // 鏉ユ枡涓嶈壇閫�鏂� - 鏇存柊宸ュ崟琛�(WOMDAB)鐩稿叧鏁伴噺
- else if (C_MES_ITEM_TBL.Tbl005 == "鏉ユ枡涓嶈壇閫�鏂�")
- totalResult += Db.Updateable<Womdab>()
- .SetColumns(it => new Womdab
- {
- Dab007 = it.Dab007 -
- c_mes_inv_item_barcodes.Quantity, // 鍑忓皯宸ュ崟鏁伴噺
- Dab022 = (it.Dab022 ?? 0) +
- c_mes_inv_item_barcodes.Quantity, // 澧炲姞閫�鏂欐暟閲�
- LlBl = (it.LlBl ?? 0) +
- (int)c_mes_inv_item_barcodes
- .Quantity, // 澧炲姞鏉ユ枡涓嶈壇鏁伴噺
- Dab020 = (it.Dab020 ?? 0) -
- c_mes_inv_item_barcodes.Quantity // 鍑忓皯宸插彂鏂欐暟閲�
- })
- .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo
- && it.Dab002 == c_mes_inv_item_barcodes
- .WorkLine
- && it.Dab003 == c_mes_inv_item_barcodes
- .ItemId.ToString())
- .ExecuteCommand();
-
- // 鏇存柊閫�鏂欏崟鏄庣粏琛ㄥ凡閫�鏁伴噺
- totalResult += Db.Updateable<MesItemTblDetail>()
- .SetColumns(it => new MesItemTblDetail
- {
- Tld006 = (it.Tld006 ?? 0) +
- (int)c_mes_inv_item_barcodes.Quantity // 澧炲姞宸查��鏁伴噺
- })
- .Where(it => it.Tlmid == C_MES_ITEM_TBL.Id &&
- it.Tlid == c_mes_inv_item_barcodes.AboutGuid)
- .ExecuteCommand();
- }
- // 浣滀笟涓嶈壇閫�鏂� - 鏇存柊宸ュ崟琛ㄥ拰閫�鏂欏崟鏄庣粏琛�
- else if (C_MES_ITEM_TBL.Tbl005 == "浣滀笟涓嶈壇閫�鏂�")
- {
- totalResult += Db.Updateable<Womdab>()
- .SetColumns(it => new Womdab
- {
- Dab022 = (it.Dab022 ?? 0) +
- c_mes_inv_item_barcodes.Quantity, // 澧炲姞閫�鏂欐暟閲�
- ZyBl = (it.ZyBl ?? 0) +
- (int)c_mes_inv_item_barcodes
- .Quantity, // 澧炲姞浣滀笟涓嶈壇鏁伴噺
- Dab020 = (it.Dab020 ?? 0) -
- c_mes_inv_item_barcodes.Quantity // 鍑忓皯宸插彂鏂欐暟閲�
- })
- .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo
- && it.Dab002 ==
- c_mes_inv_item_barcodes.WorkLine
- && it.Dab003 == c_mes_inv_item_barcodes.ItemId
- .ToString())
- .ExecuteCommand();
-
- // 鏇存柊閫�鏂欏崟鏄庣粏琛ㄥ凡閫�鏁伴噺
- totalResult += Db.Updateable<MesItemTblDetail>()
- .SetColumns(it => new MesItemTblDetail
- {
- Tld006 = (it.Tld006 ?? 0) +
- (int)c_mes_inv_item_barcodes.Quantity // 澧炲姞宸查��鏁伴噺
- })
- .Where(it => it.Tlmid == C_MES_ITEM_TBL.Id &&
- it.Tlid == c_mes_inv_item_barcodes.AboutGuid)
- .ExecuteCommand();
- }
-
- // 濡傛灉寰呴��鏁伴噺绛変簬鏈閫�鏂欐暟閲忥紝鍒欐洿鏂版槑缁嗗畬鎴愮姸鎬�
- if ((C_MES_ITEM_TBL_DETAIL.Tld005 ?? 0) -
- (C_MES_ITEM_TBL_DETAIL.Tld006 ?? 0) ==
- c_mes_inv_item_barcodes.Quantity)
- totalResult += Db.Updateable<MesItemTblDetail>()
- .SetColumns(it => new MesItemTblDetail
- { Tld008 = 1 }) // 璁剧疆瀹屾垚鏍囧織
- .Where(it => it.Tlid == C_MES_ITEM_TBL_DETAIL.Tlid)
- .ExecuteCommand();
-
- // 妫�鏌ラ��鏂欏崟鏄惁鎵�鏈夋槑缁嗛兘宸插畬鎴�
- var remainingCount = Db.Queryable<MesItemTbl, MesItemTblDetail>(
- (a, b) =>
- new JoinQueryInfos(JoinType.Left, a.Id == b.Tlmid))
- .Where((a, b) =>
- a.BillNo == p_bill_no &&
- (b.Tld005 ?? 0) - (b.Tld006 ?? 0) > 0)
- .Count();
-
- // 濡傛灉鎵�鏈夋槑缁嗛兘宸插畬鎴愶紝鍒欐洿鏂伴��鏂欏崟鐘舵�佷负宸插畬鎴�
- if (remainingCount < 1)
- totalResult += Db.Updateable<MesItemTbl>()
- .SetColumns(it => it.Tbl020 == 1) // 璁剧疆瀹屾垚鏍囧織
- .Where(it => it.BillNo == p_bill_no)
- .ExecuteCommand();
-
- // 妫�鏌ュ繀瑕佺殑鎻掑叆鎿嶄綔鏄惁閮芥垚鍔熸墽琛�
- var minimumExpectedOperations = 3; // 鑷冲皯闇�瑕佹墽琛岀殑鎻掑叆鎿嶄綔鏁�
- if (totalResult < minimumExpectedOperations)
- throw new Exception(
- $"鍏抽敭鏁版嵁鎻掑叆澶辫触锛岄鏈熻嚦灏憑minimumExpectedOperations}涓搷浣滐紝瀹為檯鎵ц{totalResult}涓搷浣�");
-
- // 鍒涘缓 鎻掑叆鏃ュ織
- var logService = new LogService();
- var LogMsg = "[PDA]鐢熶骇閫�鏂欍�傛潯鐮併��" + query.barcode + "銆� 閫�鏂欏崟鍙枫��" + c_bill_no + "銆�";
- logService.CreateLog(db, query.userName, tbWOMDAA.Guid.ToString(), "WOMDAA", LogMsg, tbWOMDAA.Daa001);
-
- return totalResult;
- });
-
- query.itemNo = c_mes_inv_item_barcodes.ItemNo;
- query.Num = c_quantity.Value;
+ query.itemNo = itemNo;
+ query.Num = quantity;
return query;
+
+
+ //var p_item_barcode = query.barcode; // 鐗╂枡鏉$爜
+ //var p_bill_no = query.billNo; // 鍗曟嵁鍙�
+ //var p_section_code = query.DepotCode; // 搴撲綅缂栫爜
+ //var c_user = query.userName; // 鐢ㄦ埛鍚�
+
+ //var p_bill_type_id = 100; // 鍗曟嵁绫诲瀷ID
+ //var p_transction_no = 104; // 浜ゆ槗缂栧彿
+
+ //// 楠岃瘉搴撲綅鏉$爜
+ //if (p_section_code.IsNullOrEmpty()) throw new Exception("璇锋壂搴撲綅鏉$爜锛�");
+
+ //// 鑾峰彇搴撲綅淇℃伅
+ //var c_depot_code = Db.Queryable<MesDepotSections, MesDepots>((a, b) =>
+ // new JoinQueryInfos(JoinType.Inner, a.DepotGuid == b.Guid))
+ // .Where((a, b) => a.DepotSectionCode == p_section_code)
+ // .Select((a, b) => b.DepotId).First();
+
+ //if (!c_depot_code.HasValue)
+ // throw new Exception("搴撲綅缂栫爜" + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
+
+ //// 鑾峰彇搴撲綅鍒嗗尯淇℃伅
+ //var mesDepotSections = Db.Queryable<MesDepotSections>()
+ // .Where(a => a.DepotSectionCode == p_section_code).First();
+
+ //if (mesDepotSections == null)
+ // throw new Exception("搴撲綅缂栫爜" + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
+
+ //// 鑾峰彇搴撲綅鍩虹淇℃伅
+ //var c_mes_depots = Db.Queryable<MesDepots>()
+ // .Where(b => b.Guid == mesDepotSections.DepotGuid).First();
+
+ //if (c_mes_depots == null)
+ // throw new Exception("搴撲綅缂栫爜" + p_section_code + " 涓嶅瓨鍦紝璇风‘璁わ紒");
+
+ //// 妫�鏌ユ潯鐮佹槸鍚﹀凡鍏ュ簱
+ //var c_num = Db.Queryable<MesInvItemIns, MesInvItemInCDetails>((a, b) =>
+ // new JoinQueryInfos(JoinType.Inner, a.Guid == b.ItemInId))
+ // .Where((a, b) => b.ItemBarcode == p_item_barcode
+ // && a.BillTypeId == p_bill_type_id &&
+ // a.TransctionNo == p_transction_no.ToString())
+ // .Count();
+
+ //if (c_num > 0) throw new Exception("姝ゆ潯鐮佸凡鎵叆搴擄紝鍕块噸澶嶆壂鎻忥紒");
+
+ //c_num = Db.Queryable<MesInvItemStocks>()
+ // .Where(t => t.ItemBarcode == p_item_barcode).Count();
+
+ //if (c_num > 0) throw new Exception("姝ゆ潯鐮佸凡鎵叆搴擄紝鍕块噸澶嶆壂鎻忥紒");
+
+ //// 鑾峰彇鏉$爜淇℃伅
+ //var c_mes_inv_item_barcodes = Db.Queryable<MesInvItemBarcodes>()
+ // .Where(t => t.ItemBarcode == p_item_barcode).First();
+
+ //if (c_mes_inv_item_barcodes == null)
+ // throw new Exception("姝ゆ潯鐮佷笉灞炰簬璇ラ��鏂欏崟锛岃鏍稿锛�");
+
+ //if (c_mes_inv_item_barcodes.Memo != "鐢熶骇閫�鏂�")
+ // throw new Exception("姝ゆ潯鐮佷笉鏄敓浜ч��鏂欐潯鐮侊紝涓嶅彲浣跨敤鐢熶骇閫�鏂欐ā鍧楋紒");
+
+ //// 浣跨敤 String.Equals 鏂规硶杩涜瀛楃涓叉瘮杈冿紝鎸囧畾姣旇緝瑙勫垯涓哄拷鐣ュぇ灏忓啓锛屾彁楂樻瘮杈冪殑鐏垫椿鎬�
+ //if (!string.Equals(c_mes_inv_item_barcodes.BillNo, p_bill_no, StringComparison.OrdinalIgnoreCase))
+ // throw new Exception($"璇ユ潯鐮佸搴旂殑鐢宠鍙枫�恵c_mes_inv_item_barcodes.BillNo}銆戜笌 褰撳墠鐢宠鍗曞彿銆恵p_bill_no}銆戜笉涓�鑷达紝璇锋牳瀵癸紒");
+ //// 鑾峰彇閫�鏂欏崟淇℃伅
+ //var C_MES_ITEM_TBL = Db.Queryable<MesItemTbl>()
+ // .Where(a => a.BillNo == p_bill_no
+ // && (a.Tbl013 ?? 0) == 1).First();
+
+
+
+ //// 鑾峰彇閫�鏂欏崟淇℃伅
+ //var tbWOMDAA = Db.Queryable<Womdaa>()
+ // .Where(a => a.Guid.ToString() == C_MES_ITEM_TBL.Tbl002).First();
+
+
+
+ //if (C_MES_ITEM_TBL == null) throw new Exception("鐢宠鍗曞凡鎾ゅ洖,鏃犳硶鎵爜!");
+
+ //if (C_MES_ITEM_TBL.Tbl020 == 1) throw new Exception("鎵爜瀹屾垚,鐢宠鍗曞凡瀹岀粨!");
+
+ //// 鑾峰彇閫�鏂欏崟鏄庣粏
+ //var C_MES_ITEM_TBL_DETAIL = Db.Queryable<MesItemTblDetail>()
+ // .Where(a => a.Tlid == c_mes_inv_item_barcodes.AboutGuid)
+ // .First();
+
+ //if (C_MES_ITEM_TBL_DETAIL == null)
+ // throw new Exception("鏉$爜涓嶅睘浜庤鐢宠鍗曟槑缁�,鏃犳硶鎵爜!");
+
+ //var CABerpid = Db.Queryable<Womdab>().Where(womdab => womdab.Guid.ToString() == C_MES_ITEM_TBL_DETAIL.Tld013).Select(womdab => womdab.Erpid).First();
+
+ //var ownerId = Db.Queryable<Womcab>().Where(womcab => womcab.Erpid == CABerpid.Value).Select(womcab => womcab.OwnerId).First();
+
+ //if (ownerId == null) throw new Exception("鐢ㄦ枡娓呭崟璐т富淇℃伅涓嶅瓨鍦�,鏃犳硶鎵爜锛岃鑱旂郴绠$悊鍛�!");
+
+ //var owner_type = "";
+ //if (Db.Queryable<SysOrganization>().Any(x => x.Fid == ownerId))
+ //{
+ // owner_type = "BD_OwnerOrg";
+ //}
+ //else
+ //{
+ // // 绗簩灞傚垽鏂細妫�鏌� MES_CUSTOMER
+ // if (Db.Queryable<MesCustomer>().Any(x => x.Id == Convert.ToInt32(ownerId)))
+ // {
+ // owner_type = "BD_Customer";
+ // }
+ // else
+ // {
+ // // 绗笁灞傚垽鏂細妫�鏌� MES_SUPPLIER
+ // if (Db.Queryable<MesSupplier>().Any(x => x.Id == Convert.ToInt32(ownerId)))
+ // {
+ // owner_type = "BD_Supplier";
+ // }
+ // else
+ // {
+ // throw new Exception("鍏ュ簱澶辫触,鐢ㄦ枡娓呭崟璐т富淇℃伅瀛樺湪闂锛岃鑱旂郴绠$悊鍛樿В鍐筹紒");
+ // }
+ // }
+ //}
+
+
+ //var c_quantity = c_mes_inv_item_barcodes.Quantity;
+
+ //var c_bill_no = "";
+ //var c_id = Guid.Empty;
+
+ //// 浣跨敤浜嬪姟澶勭悊鏁版嵁鏇存柊
+ //UseTransaction(db =>
+ //{
+ // // 鏌ヨ鍏ュ簱鍗�
+ // var mesInvItemIns = db.Queryable<MesInvItemIns>()
+ // .Where(d =>
+ // d.Status == 0 && d.TransctionNo ==
+ // p_transction_no.ToString()
+ // && d.TaskNo == c_mes_inv_item_barcodes.BillNo
+ // && d.DepotsId == c_depot_code
+ // && d.InsDate.Value.ToString("yyyyMMdd") ==
+ // DateTime.Now.ToString("yyyyMMdd")).First();
+
+ // var totalResult = 0;
+
+ // // 濡傛灉鍏ュ簱鍗曚笉瀛樺湪鍒欏垱寤烘柊鐨勫叆搴撳崟
+ // if (mesInvItemIns == null)
+ // {
+ // c_bill_no = BillNo.GetBillNo("SCTL(鐢熶骇閫�鏂�)");
+
+ // c_id = Guid.NewGuid();
+
+ // totalResult += db.Insertable(new MesInvItemIns
+ // {
+ // Guid = c_id,
+ // BillNo = c_bill_no,
+ // BillTypeId = p_bill_type_id,
+ // InsDate = DateTime.Now,
+ // DepotsId = c_depot_code,
+ // UserNoBack = c_user,
+ // Reason = C_MES_ITEM_TBL.Tbl005,
+ // Remark = C_MES_ITEM_TBL.Tbl006,
+ // //InsDate = DateTime.Now,
+ // DepotsCode = c_mes_depots.DepotCode,
+ // TaskNo = c_mes_inv_item_barcodes.BillNo,
+ // //DepotsId = c_depot_code,
+ // TransctionNo = p_transction_no.ToString(),
+ // CreateBy = c_user,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = c_user,
+ // LastupdateDate = DateTime.Now,
+ // CbillNo = tbWOMDAA.Daa001,
+ // InType = "鐢熶骇閫�鏂�",
+ // ReceiveOrgId = c_mes_depots.FSubsidiary,
+ // Fstatus = 0,
+ // Status = 0,
+ // WorkNo = tbWOMDAA.Daa021
+ // }).IgnoreColumns(true).ExecuteCommand();
+ // }
+ // else
+ // {
+ // c_id = mesInvItemIns.Guid;
+ // c_bill_no = mesInvItemIns.BillNo;
+ // }
+
+ // // 妫�鏌ユ槸鍚︿负鍚堝苟鎵撳嵃鏉$爜
+ // var hbdy = c_mes_inv_item_barcodes.Hbdy ?? 0;
+ // if (hbdy == 1) throw new Exception("涓嶆敮鎸佸悎骞舵墦鍗扮殑鏉$爜:" + p_item_barcode);
+
+
+ // // 妫�鏌ユ槸鍚﹀瓨鍦ㄤ簬 MES_INV_ITEM_IN_C_ITEMS 琛�
+ // var existingCount = db.Queryable<MesInvItemInCItems>()
+ // .Where(it =>
+ // it.ItemInId == c_id &&
+ // it.ItemId == C_MES_ITEM_TBL_DETAIL.Tld009 &&
+ // it.DepotId == c_depot_code.ToString())
+ // .Count();
+
+ // if (existingCount == 0)
+ // // 涓嶅瓨鍦ㄦ椂鎻掑叆鏂拌褰�
+ // db.Insertable(new MesInvItemInCItems
+ // {
+ // ItemInId = c_id,
+ // Quantity = c_mes_inv_item_barcodes.Quantity,
+ // CreateBy = c_user,
+ // CreateDate = DateTime.Now,
+ // ItemNo = c_mes_inv_item_barcodes.ItemNo,
+ // //DepotCode = mesDepost.DepotCode,
+ // ItemSname = c_mes_inv_item_barcodes.ItemSname,
+ // Unit = c_mes_inv_item_barcodes.Unit,
+ // Ebeln = c_mes_inv_item_barcodes.WorkNo,
+ // BillNo = c_bill_no,
+ // WorkNo = c_mes_inv_item_barcodes.WorkNo,
+ // EbelnLineNo = c_mes_inv_item_barcodes.WorkLine,
+ // CbillNo = c_mes_inv_item_barcodes.BillNo,
+ // WorkLine = c_mes_inv_item_barcodes.WorkLine,
+ // SuppId = c_mes_inv_item_barcodes.SuppId,
+ // SuppNo = c_mes_inv_item_barcodes.SuppNo,
+ // Remark = c_mes_inv_item_barcodes.Memo,
+ // EbelnK3id = c_mes_inv_item_barcodes.EbelnK3id,
+ // LineK3id = c_mes_inv_item_barcodes.LineK3id,
+ // ItemId = c_mes_inv_item_barcodes.ItemId,
+ // DepotCode = c_mes_depots.DepotCode,
+ // DepotId = c_depot_code.ToString(),
+ // itemDabid = C_MES_ITEM_TBL_DETAIL.Tlid.ToString()
+ // }).IgnoreColumns(true).ExecuteCommand();
+ // else
+ // // 瀛樺湪鏃舵洿鏂版暟閲�
+ // db.Updateable<MesInvItemInCItems>()
+ // .SetColumns(it => new MesInvItemInCItems
+ // {
+ // Quantity = SqlFunc.IsNull(it.Quantity, 0) + c_mes_inv_item_barcodes.Quantity // 纭繚 Quantity 涓嶄负 null
+ // })
+ // .Where(it =>
+ // it.ItemInId == c_id &&
+ // it.ItemId == C_MES_ITEM_TBL_DETAIL.Tld009 &&
+ // it.DepotId == c_depot_code.ToString())
+ // //.IgnoreColumns(true) // 淇濈暀 IgnoreColumns
+ // .ExecuteCommand();
+
+
+ // // 鎻掑叆 mes_inv_item_in_c_details 琛�
+ // totalResult += db.Insertable(new MesInvItemInCDetails
+ // {
+ // ItemInId = c_id,
+ // BillNo = c_bill_no,
+ // ItemBarcode = p_item_barcode,
+ // Quantity = c_mes_inv_item_barcodes.Quantity,
+ // BarcodeFlag = true,
+ // EpFlag = true,
+ // WorkType = 1,
+ // ItemNo = c_mes_inv_item_barcodes.ItemNo,
+ // //LotNo = cgddDetails.BatchNumber,--鎵瑰彿锛岄��鏂欎笉璁剧疆鎵瑰彿
+ // SuppId = c_mes_inv_item_barcodes.SuppId,
+ // SuppNo = c_mes_inv_item_barcodes.SuppNo,
+ // //DepotCode = mesDepost.DepotCode,
+ // DepotSectionCode = p_section_code,
+ // ItemSname = c_mes_inv_item_barcodes.ItemSname,
+ // Unit = c_mes_inv_item_barcodes.Unit,
+ // CreateBy = c_user,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = c_user,
+ // LastupdateDate = DateTime.Now,
+ // Remark = c_mes_inv_item_barcodes.Memo,
+ // Ebeln = c_mes_inv_item_barcodes.Mblnr,
+ // EbelnLineNo = c_mes_inv_item_barcodes.Zeile,
+ // WorkNo = c_mes_inv_item_barcodes.WorkNo,
+ // WorkLine = c_mes_inv_item_barcodes.WorkLine,
+ // CbillNo = c_mes_inv_item_barcodes.BillNo,
+ // UrgentFlag = c_mes_inv_item_barcodes.UrgentFlag,
+ // BoardStyle = c_mes_inv_item_barcodes.BoardStyle,
+ // TaskNo = c_mes_inv_item_barcodes.TaskNo,
+ // EbelnK3id = c_mes_inv_item_barcodes.EbelnK3id,
+ // LineK3id = c_mes_inv_item_barcodes.LineK3id,
+ // ItemId = c_mes_inv_item_barcodes.ItemId,
+ // Ischeck = true,
+ // //CheckDate = C_MES_ITEM_TBL_DETAIL.CheckDate,
+ // //CheckRes = C_MES_ITEM_TBL_DETAIL.CheckRes,
+ // //CheckStates = C_MES_ITEM_TBL_DETAIL.CheckStates,--妫�楠屼俊鎭�
+ // ReceiveOrgId = c_mes_depots.FSubsidiary,
+ // DepotCode = c_mes_depots.DepotCode,
+ // DepotId = Convert.ToInt64(c_depot_code)
+ // }).IgnoreColumns(true).ExecuteCommand();
+
+ // // 鎻掑叆涓氬姟璁板綍
+ // totalResult += db.Insertable(new MesInvBusiness2
+ // {
+ // Guid = Guid.NewGuid(),
+ // Status = 1,
+ // BillTypeId = p_bill_type_id,
+ // TransactionCode = p_transction_no.ToString(),
+ // BusinessType = 1,
+ // ItemBarcode = p_item_barcode,
+ // ItemNo = c_mes_inv_item_barcodes.ItemNo,
+ // LotNo = c_mes_inv_item_barcodes.LotNo,
+ // EpFlag = true,
+ // Quantity = c_mes_inv_item_barcodes.Quantity,
+ // ToInvDepotsCode = c_mes_depots.DepotCode,
+ // InvDepotId = c_depot_code,
+ // ToInvDepotSectionsCode = p_section_code,
+ // Description = "鐢熶骇閫�鏂�",
+ // CreateBy = c_user,
+ // CreateDate = DateTime.Now,
+ // LastupdateBy = c_user,
+ // LastupdateDate = DateTime.Now,
+ // TaskNo = c_mes_inv_item_barcodes.TaskNo,
+ // BillNo = c_bill_no,
+ // WorkNo = c_mes_inv_item_barcodes.WorkNo,
+ // WorkLine = c_mes_inv_item_barcodes.WorkLine,
+ // SuppId = c_mes_inv_item_barcodes.SuppId,
+ // SuppNo = c_mes_inv_item_barcodes.SuppNo,
+ // ItemId = c_mes_inv_item_barcodes.ItemId
+ // }).IgnoreColumns(true).ExecuteCommand();
+
+ // // 鎻掑叆搴撳瓨璁板綍
+ // totalResult += db.Insertable(new MesInvItemStocks
+ // {
+ // Guid = Guid.NewGuid(),
+ // TaskNo = c_mes_inv_item_barcodes.TaskNo,
+ // ItemBarcode = p_item_barcode,
+ // ItemNo = c_mes_inv_item_barcodes.ItemNo,
+ // LotNo = c_mes_inv_item_barcodes.LotNo,
+ // Quantity = c_mes_inv_item_barcodes.Quantity,
+ // //EpFlag = c_mes_inv_item_barcodes.EpFlag.Value
+ // // ? (byte)1
+ // // : (byte)0,
+ // DepotId = c_mes_depots.DepotId,
+ // DepotsCode = c_mes_depots.DepotCode,
+ // DepotSectionsCode = p_section_code,
+ // CheckDate = c_mes_inv_item_barcodes.CreateDate,
+ // IndepDate = DateTime.Now,
+ // BoardStyle = c_mes_inv_item_barcodes.BoardStyle,
+ // WorkNo = c_mes_inv_item_barcodes.WorkNo,
+ // WorkLine = c_mes_inv_item_barcodes.WorkLine,
+ // SuppNo = c_mes_inv_item_barcodes.SuppNo,
+ // ItemId = c_mes_inv_item_barcodes.ItemId,
+ // BillNo = c_mes_inv_item_barcodes.BillNo,
+ // //DepotId = Convert.ToInt32(c_depot_code),
+ // OwnerId = ownerId,
+ // OwnerType = owner_type,
+ // StockOrgId = c_mes_depots.FSubsidiary,
+ // IndepUserCode = c_user
+ // }).IgnoreColumns(true).ExecuteCommand();
+
+ // // 鏍规嵁閫�鏂欑被鍨�(鑹搧閫�鏂欍�佹潵鏂欎笉鑹��鏂欍�佷綔涓氫笉鑹��鏂�)鏇存柊鐩稿叧鏁版嵁
+ // if (C_MES_ITEM_TBL.Tbl005 is "鑹搧閫�鏂�" or "鏉ユ枡涓嶈壇閫�鏂�")
+ // {
+ // // 鑹搧閫�鏂� - 鏇存柊宸ュ崟琛�(WOMDAB)鐩稿叧鏁伴噺
+ // if (C_MES_ITEM_TBL.Tbl005 == "鑹搧閫�鏂�")
+ // totalResult += Db.Updateable<Womdab>()
+ // .SetColumns(it => new Womdab
+ // {
+ // Dab007 = it.Dab007 -
+ // c_mes_inv_item_barcodes.Quantity, // 鍑忓皯宸ュ崟鏁伴噺
+ // Dab022 = (it.Dab022 ?? 0) +
+ // c_mes_inv_item_barcodes.Quantity, // 澧炲姞閫�鏂欐暟閲�
+ // LpTl = (it.LpTl ?? 0) +
+ // (int)c_mes_inv_item_barcodes
+ // .Quantity, // 澧炲姞鑹搧閫�鏂欐暟閲�
+ // Dab020 = (it.Dab020 ?? 0) -
+ // c_mes_inv_item_barcodes.Quantity // 鍑忓皯宸插彂鏂欐暟閲�
+ // })
+ // .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo
+ // && it.Dab002 == c_mes_inv_item_barcodes
+ // .WorkLine
+ // && it.Dab003 == c_mes_inv_item_barcodes
+ // .ItemId.ToString())
+ // .ExecuteCommand();
+ // // 鏉ユ枡涓嶈壇閫�鏂� - 鏇存柊宸ュ崟琛�(WOMDAB)鐩稿叧鏁伴噺
+ // else if (C_MES_ITEM_TBL.Tbl005 == "鏉ユ枡涓嶈壇閫�鏂�")
+ // totalResult += Db.Updateable<Womdab>()
+ // .SetColumns(it => new Womdab
+ // {
+ // Dab007 = it.Dab007 -
+ // c_mes_inv_item_barcodes.Quantity, // 鍑忓皯宸ュ崟鏁伴噺
+ // Dab022 = (it.Dab022 ?? 0) +
+ // c_mes_inv_item_barcodes.Quantity, // 澧炲姞閫�鏂欐暟閲�
+ // LlBl = (it.LlBl ?? 0) +
+ // (int)c_mes_inv_item_barcodes
+ // .Quantity, // 澧炲姞鏉ユ枡涓嶈壇鏁伴噺
+ // Dab020 = (it.Dab020 ?? 0) -
+ // c_mes_inv_item_barcodes.Quantity // 鍑忓皯宸插彂鏂欐暟閲�
+ // })
+ // .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo
+ // && it.Dab002 == c_mes_inv_item_barcodes
+ // .WorkLine
+ // && it.Dab003 == c_mes_inv_item_barcodes
+ // .ItemId.ToString())
+ // .ExecuteCommand();
+
+ // // 鏇存柊閫�鏂欏崟鏄庣粏琛ㄥ凡閫�鏁伴噺
+ // totalResult += Db.Updateable<MesItemTblDetail>()
+ // .SetColumns(it => new MesItemTblDetail
+ // {
+ // Tld006 = (it.Tld006 ?? 0) +
+ // (int)c_mes_inv_item_barcodes.Quantity // 澧炲姞宸查��鏁伴噺
+ // })
+ // .Where(it => it.Tlmid == C_MES_ITEM_TBL.Id &&
+ // it.Tlid == c_mes_inv_item_barcodes.AboutGuid)
+ // .ExecuteCommand();
+ // }
+ // // 浣滀笟涓嶈壇閫�鏂� - 鏇存柊宸ュ崟琛ㄥ拰閫�鏂欏崟鏄庣粏琛�
+ // else if (C_MES_ITEM_TBL.Tbl005 == "浣滀笟涓嶈壇閫�鏂�")
+ // {
+ // totalResult += Db.Updateable<Womdab>()
+ // .SetColumns(it => new Womdab
+ // {
+ // Dab022 = (it.Dab022 ?? 0) +
+ // c_mes_inv_item_barcodes.Quantity, // 澧炲姞閫�鏂欐暟閲�
+ // ZyBl = (it.ZyBl ?? 0) +
+ // (int)c_mes_inv_item_barcodes
+ // .Quantity, // 澧炲姞浣滀笟涓嶈壇鏁伴噺
+ // Dab020 = (it.Dab020 ?? 0) -
+ // c_mes_inv_item_barcodes.Quantity // 鍑忓皯宸插彂鏂欐暟閲�
+ // })
+ // .Where(it => it.Dab001 == c_mes_inv_item_barcodes.WorkNo
+ // && it.Dab002 ==
+ // c_mes_inv_item_barcodes.WorkLine
+ // && it.Dab003 == c_mes_inv_item_barcodes.ItemId
+ // .ToString())
+ // .ExecuteCommand();
+
+ // // 鏇存柊閫�鏂欏崟鏄庣粏琛ㄥ凡閫�鏁伴噺
+ // totalResult += Db.Updateable<MesItemTblDetail>()
+ // .SetColumns(it => new MesItemTblDetail
+ // {
+ // Tld006 = (it.Tld006 ?? 0) +
+ // (int)c_mes_inv_item_barcodes.Quantity // 澧炲姞宸查��鏁伴噺
+ // })
+ // .Where(it => it.Tlmid == C_MES_ITEM_TBL.Id &&
+ // it.Tlid == c_mes_inv_item_barcodes.AboutGuid)
+ // .ExecuteCommand();
+ // }
+
+ // // 濡傛灉寰呴��鏁伴噺绛変簬鏈閫�鏂欐暟閲忥紝鍒欐洿鏂版槑缁嗗畬鎴愮姸鎬�
+ // if ((C_MES_ITEM_TBL_DETAIL.Tld005 ?? 0) -
+ // (C_MES_ITEM_TBL_DETAIL.Tld006 ?? 0) ==
+ // c_mes_inv_item_barcodes.Quantity)
+ // totalResult += Db.Updateable<MesItemTblDetail>()
+ // .SetColumns(it => new MesItemTblDetail
+ // { Tld008 = 1 }) // 璁剧疆瀹屾垚鏍囧織
+ // .Where(it => it.Tlid == C_MES_ITEM_TBL_DETAIL.Tlid)
+ // .ExecuteCommand();
+
+ // // 妫�鏌ラ��鏂欏崟鏄惁鎵�鏈夋槑缁嗛兘宸插畬鎴�
+ // var remainingCount = Db.Queryable<MesItemTbl, MesItemTblDetail>(
+ // (a, b) =>
+ // new JoinQueryInfos(JoinType.Left, a.Id == b.Tlmid))
+ // .Where((a, b) =>
+ // a.BillNo == p_bill_no &&
+ // (b.Tld005 ?? 0) - (b.Tld006 ?? 0) > 0)
+ // .Count();
+
+ // // 濡傛灉鎵�鏈夋槑缁嗛兘宸插畬鎴愶紝鍒欐洿鏂伴��鏂欏崟鐘舵�佷负宸插畬鎴�
+ // if (remainingCount < 1)
+ // totalResult += Db.Updateable<MesItemTbl>()
+ // .SetColumns(it => it.Tbl020 == 1) // 璁剧疆瀹屾垚鏍囧織
+ // .Where(it => it.BillNo == p_bill_no)
+ // .ExecuteCommand();
+
+ // // 妫�鏌ュ繀瑕佺殑鎻掑叆鎿嶄綔鏄惁閮芥垚鍔熸墽琛�
+ // var minimumExpectedOperations = 3; // 鑷冲皯闇�瑕佹墽琛岀殑鎻掑叆鎿嶄綔鏁�
+ // if (totalResult < minimumExpectedOperations)
+ // throw new Exception(
+ // $"鍏抽敭鏁版嵁鎻掑叆澶辫触锛岄鏈熻嚦灏憑minimumExpectedOperations}涓搷浣滐紝瀹為檯鎵ц{totalResult}涓搷浣�");
+
+ // // 鍒涘缓 鎻掑叆鏃ュ織
+ // var logService = new LogService();
+ // var LogMsg = "[PDA]鐢熶骇閫�鏂欍�傛潯鐮併��" + query.barcode + "銆� 閫�鏂欏崟鍙枫��" + c_bill_no + "銆�";
+ // logService.CreateLog(db, query.userName, tbWOMDAA.Guid.ToString(), "WOMDAA", LogMsg, tbWOMDAA.Daa001);
+
+ // return totalResult;
+ //});
+
+ //query.itemNo = itemNo;
+ //query.Num = quantity;
+ //return query;
}
}
\ No newline at end of file
--
Gitblit v1.9.3