From 0010dd10c41c5c990bf6cc1b40ad857a6c956cbe Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期四, 05 六月 2025 09:45:43 +0800 Subject: [PATCH] 1.其他入库优化 2.推荐库位函数优化 --- service/Warehouse/MesItemQtrkManager.cs | 122 +++++++++++++++++++++++++--------------- 1 files changed, 75 insertions(+), 47 deletions(-) diff --git a/service/Warehouse/MesItemQtrkManager.cs b/service/Warehouse/MesItemQtrkManager.cs index 8c75e6d..81eceda 100644 --- a/service/Warehouse/MesItemQtrkManager.cs +++ b/service/Warehouse/MesItemQtrkManager.cs @@ -1,8 +1,10 @@ 锘縰sing NewPdaSqlServer.DB; using NewPdaSqlServer.Dto.service; using NewPdaSqlServer.entity; +using NewPdaSqlServer.entity.Base; using NewPdaSqlServer.util; using SqlSugar; +using System.Text.RegularExpressions; namespace NewPdaSqlServer.service.Warehouse; @@ -16,74 +18,68 @@ .ToList(); } - public List<MesItemQtrrDetail> GetQtckDetailList(WarehouseQuery query) + public ProductionPickDto GetQtckDetailList(WarehouseQuery query) { - // 1. 楠岃瘉鐢宠鍗曟槸鍚﹀瓨鍦� - var qtrk = Db.Queryable<MesItemQtrk>() - .Where(x => x.Qtck == query.billNo) - .First(); - if (qtrk == null) - throw new Exception($"鏈煡璇㈠埌姝ゅ叾浠栧叆搴撶敵璇峰崟 {query.billNo}"); + // 鍏宠仈鏌ヨ鐗╂枡琛ㄣ�佺墿鏂欐槑缁嗚〃鍜岀墿鏂欏熀纭�淇℃伅琛� + if (string.IsNullOrEmpty(query.billNo)) throw new Exception("鐢宠鍗曞彿涓虹┖"); - // 2. 楠岃瘉鐢宠鍗曠姸鎬� - if (qtrk.Qt015 != 1) - throw new Exception($"鍏朵粬鍏ュ簱鐢宠鍗� {query.billNo} 鏈鏍革紝璇风‘璁わ紒"); + var mesInvItemOuts = base.GetSingle(it => it.Qtck == query.billNo); + if (mesInvItemOuts == null) throw new Exception("鍏朵粬鍏ュ簱鐢宠鍗曚笉瀛樺湪"); - if (qtrk.Qt014 == 1) - throw new Exception($"鍏朵粬鍏ュ簱鐢宠鍗� {query.billNo} 宸插畬缁擄紝璇风‘璁わ紒"); + var sql = string.Format(@"SELECT c.item_no ItemNo,c.item_name ItemName,c.item_model ItemModel,A.qd007 FQty,A.qd008 SQty,A.qd007 - A.qd008 DSQty +fROM MES_ITEM_QTRR_DETAIL A + LEFT JOIN MES_ITEM_QTRK B ON A.qtrkGuid = B.guid + LEFT JOIN MES_ITEMS C ON A.itemId = C.item_id +WHERE B.qtck = '{0}'", query.billNo); - // 3. 鏌ヨ鐢宠鍗曟槑缁� - var details = Db.Queryable<MesItemQtrk, MesItemQtrrDetail, MesItems>( - (a, b, c) => new JoinQueryInfos( - JoinType.Left, a.Guid == b.QtrkGuid, - JoinType.Left, c.Id.ToString() == b.ItemId)) - .Where((a, b, c) => - a.Qtck == query.billNo && - (b.Qd007 ?? 0) - (b.Qd008 ?? 0) > 0) - .OrderBy((a, b, c) => b.Qd002) - .Select((a, b, c) => new MesItemQtrrDetail - { - Qtck = a.Qtck, - ItemNo = c.ItemNo, - ItemName = c.ItemName, - Qd007 = b.Qd007 ?? 0, - Qd008 = b.Qd008 ?? 0 - }) - .ToList(); + var womdabs = Db.Ado.SqlQuery<ItemDetailModel>(sql); - return details; + + var DS_list = womdabs.Where(s => s.DSQty > 0).ToList(); + + var YS_list = womdabs.Where(s => s.SQty > 0).ToList(); + + var dto = new ProductionPickDto + { + //daa001 = womdaa.Daa001, + //PlanNo = womcaa.Caa020, + items = DS_list, + Ysitems = YS_list + }; + + return dto; } public string ScanInDepotsQT(WarehouseQuery query) { - var sectionCode = query.sectionCode; + var sectionCode = query.sectionCode; var billNo = query.billNo; // 1. 楠岃瘉搴撲綅鏉$爜鏄惁涓虹┖ if (string.IsNullOrEmpty(sectionCode)) throw new Exception("璇锋壂搴撲綅鏉$爜锛�"); // 2. 鏌ヨ搴撲綅瀵瑰簲鐨勪粨搴撶紪鐮� - var depotCode = Db.Queryable<MesDepotSections, MesDepots>( + var depotId = Db.Queryable<MesDepotSections, MesDepots>( (a, b) => new JoinQueryInfos( JoinType.Inner, a.DepotGuid == b.Guid)) .Where((a, b) => a.DepotSectionCode == sectionCode) - .Select((a, b) => b.DepotCode) + .Select((a, b) => b.DepotId) .First(); - if (depotCode == null) + if (depotId == null) throw new Exception($"搴撲綅缂栫爜 {sectionCode} 涓嶅瓨鍦紝璇风‘璁わ紒"); // 3. 鏌ヨ鐢宠鍗曞搴旂殑浠撳簱 var qtrk = Db.Queryable<MesItemQtrk>() .Where(x => x.Qtck == billNo) - .Select(x => x.Qt011) + .Select(x => x.Qt008) .First(); if (qtrk == null) throw new Exception($"搴撲綅缂栫爜 {sectionCode} 涓嶅瓨鍦紝璇风‘璁わ紒"); // 4. 楠岃瘉搴撲綅鏄惁灞炰簬鐢宠浠撳簱 - if (depotCode != qtrk) - throw new Exception($"鎵爜搴撲綅 {sectionCode} 涓嶅睘浜庣敵璇锋浠撳簱!"); + if (depotId != Convert.ToInt32(qtrk)) + throw new Exception($"鎵爜搴撲綅 {sectionCode} 涓嶅睘浜庣敵璇蜂粨搴�!"); // 5. 杩斿洖鎴愬姛淇℃伅 return $"浠撳簱锛歿qtrk} 搴撲綅锛歿sectionCode}"; @@ -118,6 +114,13 @@ var c_depot_code = depotInfo.DepotCode; var c_depot_id = depotInfo.DepotId; + var mesDepost = Db.Queryable<MesDepots>() + .Where(s => s.DepotId == c_depot_id).First(); + + + + + // 3. 楠岃瘉鏉$爜鏄惁宸插叆搴� var existsInStock = Db.Queryable<MesInvItemInCDetails>() .Any(x => x.ItemBarcode == p_item_barcode); @@ -147,6 +150,10 @@ if (qtrk == null) throw new Exception("鍏朵粬鍏ュ簱鐢宠鍗曚笉瀛樺湪锛�"); + // 楠岃瘉搴撲綅鏄惁灞炰簬鐢宠浠撳簱 + if (c_depot_id != Convert.ToInt32(qtrk.Qt008)) + throw new Exception($"鎵爜搴撲綅 {p_section_code} 涓嶅睘浜庣敵璇蜂粨搴�!"); + // 6. 鏌ヨ鐢宠鍗曟槑缁� var detail = Db.Queryable<MesItemQtrrDetail>() .Where(x => @@ -163,7 +170,23 @@ var details = new List<MesItemQtrrDetail>(); - // 8. 鎵ц鍏ュ簱浜嬪姟 + string pattern = @"\(([^)]+)\)"; + Match match = Regex.Match(qtrk.Qt023, pattern); + var owner_type = ""; + + // 8.鑾峰彇璐т富绫诲瀷 + if (match.Success) + { + owner_type = match.Groups[1].Value; + } + else + { + throw new Exception("鍏朵粬鍏ュ簱鐢宠鍗曡揣涓荤被鍨嬫湁璇�,璇锋牳瀵癸紒"); + } + + + + // 10. 鎵ц鍏ュ簱浜嬪姟 UseTransaction(db => { var res = 0; @@ -186,7 +209,7 @@ if (existingInv == null) { newId = Guid.NewGuid(); - billNo = BillNo.GetBillNo("QTRK(鍏朵粬鍏ュ簱鍗�)"); + billNo = BillNo.GetBillNo("QTRK(鍏朵粬鍏ュ簱)"); barcode.UrgentFlag ??= false; @@ -204,13 +227,14 @@ LastupdateBy = c_user, LastupdateDate = DateTime.Now, UrgentFlag = barcode.UrgentFlag.Value ? "1" : "0", - CbillNo = p_bill_no, + //CbillNo = p_bill_no, Fstatus = 0, Status = 0, Reason = qtrk.Qt010, TaskNo = p_bill_no, DepotsId = Convert.ToInt64(c_depot_id) , - InType = "鍏朵粬鍏ュ簱" + InType = "鍏朵粬鍏ュ簱", + ReceiveOrgId = qtrk.Qt022 }).IgnoreColumns(true).ExecuteCommand(); } @@ -255,7 +279,8 @@ EbelnK3id = barcode.EbelnK3id, LineK3id = barcode.LineK3id, ItemId = barcode.ItemId, - DepotId = c_depot_id.ToString() + DepotId = c_depot_id.ToString(), + itemDabid = barcode.AboutGuid.ToString(), }).IgnoreColumns(true).ExecuteCommand(); else // 瀛樺湪鍒欐洿鏂版暟閲� @@ -263,9 +288,8 @@ .SetColumns( x => x.Quantity == x.Quantity + barcode.Quantity) .Where(x => x.ItemInId == newId - && x.ItemId == barcode.ItemId - && x.WorkNo == barcode.WorkNo - && x.WorkLine == barcode.WorkLine) + && x.ItemId == barcode.ItemId + && x.DepotId == c_depot_id.ToString()) .ExecuteCommand(); @@ -370,7 +394,11 @@ EbelnK3id = barcode.EbelnK3id, LineK3id = barcode.LineK3id, ItemId = barcode.ItemId, - BillNo = barcode.BillNo + BillNo = barcode.BillNo, + OwnerId = qtrk.Qt024, + OwnerType = owner_type, + StockOrgId = qtrk.Qt022, + IndepUserCode = c_user // SalesOrder = barcode.SalesOrder, // IsZy = barcode.IsZy, // Visable = 0, -- Gitblit v1.9.3