From 63b8880e08f489986edc9e24b09462ac916d7f72 Mon Sep 17 00:00:00 2001 From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU> Date: 星期四, 18 九月 2025 09:22:12 +0800 Subject: [PATCH] 受托退料:前端界面规范,列表与明细转为存储过程,添加组织隔离、拆分、库位列表、已扫待扫、完结功能 --- Controllers/Warehouse/MesSttlController.cs | 74 +++++++++++++- service/Warehouse/MesSttlManager.cs | 185 ++++++++++++++++++++++++++++++------ 2 files changed, 223 insertions(+), 36 deletions(-) diff --git a/Controllers/Warehouse/MesSttlController.cs b/Controllers/Warehouse/MesSttlController.cs index 2496b66..73cc308 100644 --- a/Controllers/Warehouse/MesSttlController.cs +++ b/Controllers/Warehouse/MesSttlController.cs @@ -1,9 +1,10 @@ -锘縰sing System.Dynamic; -using Microsoft.AspNetCore.Mvc; +锘縰sing Microsoft.AspNetCore.Mvc; using NewPdaSqlServer.Dto.service; using NewPdaSqlServer.entity; +using NewPdaSqlServer.service.@base; using NewPdaSqlServer.service.Warehouse; using NewPdaSqlServer.util; +using System.Dynamic; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace NewPdaSqlServer.Controllers.Warehouse; @@ -13,9 +14,11 @@ /// </summary> [Route("api/[controller]")] [ApiController] -public class MesSttlController : ControllerBase +public class MesSttlController : BaseController { private readonly MesSttlManager _manager = new(); + + private readonly MesPrintMangeer _mCf = new(); #region 鍩虹 /***杩涘叆妯$増绠$悊鍙互淇敼妯$増***/ @@ -178,7 +181,7 @@ try { dynamic resultInfos = new ExpandoObject(); - resultInfos.tbBillList = _manager.GetSttlBillNo(query); + resultInfos.tbBillList = _manager.GetSttlBillNo(query,RequestInfo); return new ResponseResult { status = 0, @@ -204,7 +207,7 @@ try { dynamic resultInfos = new ExpandoObject(); - resultInfos.tbBillList = _manager.GetMesItemDetailByBillNo(query); + resultInfos.tbBillList = _manager.GetMesItemDetailByBillNo(query, RequestInfo); if (resultInfos.tbBillList.Count < 1) { @@ -262,5 +265,66 @@ } } + /// <summary> + /// 鍙楁墭閫�鏂欐潯鐮佹媶鍒� + /// </summary> + /// <param name="query">鏌ヨ鍙傛暟</param> + /// <returns>鎷嗗垎缁撴灉鍜屽緟澶勭悊鍒楄〃</returns> + /// <remarks> + /// 璇锋眰绀轰緥: + /// POST /api/MesItemBl/SplitBarcode + /// { + /// "billNo": "WO202401010001", // 宸ュ崟鍙�(蹇呭~) + /// "barcode": "BC001", // 鏉$爜鍙�(蹇呭~) + /// "userName": "admin", // 鐢ㄦ埛鍚�(蹇呭~) + /// "blNo": "BL202401010001", // 琛ユ枡鍗曞彿(蹇呭~) + /// "Num": 10 // 鎷嗗垎鏁伴噺(蹇呭~,蹇呴』澶т簬0) + /// } + /// 涓氬姟澶勭悊锛� + /// - 楠岃瘉琛ユ枡鍗曠姸鎬� + /// - 楠岃瘉鏉$爜搴撳瓨淇℃伅 + /// - 楠岃瘉鎷嗗垎鏁伴噺鏄惁鍚堢悊 + /// - 鎵ц鏉$爜鎷嗗垎浜嬪姟澶勭悊 + /// - 鏇存柊宸ュ崟鍜岃ˉ鏂欏崟鐩稿叧鏁伴噺 + /// 杩斿洖鏁版嵁鍖呭惈锛� + /// - success: 鎷嗗垎鏄惁鎴愬姛 + /// - pendingList: 寰呭鐞嗘槑缁嗗垪琛紝鍖呭惈锛� + /// * Bld012: 鐗╂枡ID + /// * Bld002: 鐗╂枡缂栧彿 + /// * Bld003: 鐗╂枡鍚嶇О + /// * Bld004: 鐗╂枡瑙勬牸 + /// * Bld007: 璁″垝鏁伴噺 + /// * Bld008: 宸茶ˉ鏁伴噺 + /// </remarks> + /// <response code="200">鎷嗗垎鎴愬姛</response> + /// <response code="400">鎷嗗垎澶辫触锛岃繑鍥炲叿浣撻敊璇俊鎭�</response> + [HttpPost("SplitBarcode")] + public ResponseResult SplitBarcode(WarehouseQuery query) + { + try + { + dynamic resultInfos = new ExpandoObject(); + resultInfos.tbBillList = new ExpandoObject(); + resultInfos.tbBillList.printInfo = _mCf.getPrintInfo(query); + var scanResult = _manager.SplitBarcode(query); + resultInfos.tbBillList.cfBarInfo = _mCf.getCfInfo(scanResult); + + //dynamic resultInfos = new ExpandoObject(); + //var (success, pendingList) = _manager.SplitBarcode(query); + //resultInfos.success = success; + //resultInfos.pendingList = pendingList; + + return new ResponseResult + { + status = 0, + message = "OK", + data = resultInfos + }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } } \ No newline at end of file diff --git a/service/Warehouse/MesSttlManager.cs b/service/Warehouse/MesSttlManager.cs index 74f90d1..f19a1b9 100644 --- a/service/Warehouse/MesSttlManager.cs +++ b/service/Warehouse/MesSttlManager.cs @@ -8,6 +8,7 @@ using OracleInternal.Sharding; using SqlSugar; using SqlSugar.Extensions; +using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; @@ -20,13 +21,33 @@ /// 鑾峰彇鍙楁墭閫�鏂欑敵璇峰垪琛� /// </summary> /// <returns>鍙楁墭閫�鏂欑敵璇峰垪琛�</returns> - public List<string> GetSttlBillNo(WarehouseQuery query) + public List<string> GetSttlBillNo(WarehouseQuery query, dynamic RequestInfo) { - var list = Db.Queryable<MesShouTui>() - .Where(s => s.IsCheck == true && s.IsFinish == false) - .Select(s => s.BillNo).ToList(); + var orgId = RequestInfo.OrgId; - return list; + if (orgId == null) + throw new Exception("缁勭粐涓嶅瓨鍦紒"); + + // 鑾峰彇鏈畬鎴愮殑閫�鏂欏崟鍙峰垪琛� + var parameters = new[] + { + new SugarParameter("@pi_orgId", orgId), + new SugarParameter("@inP1", null), + new SugarParameter("@inP2", null), + new SugarParameter("@inP3", null), + new SugarParameter("@inP4", null) + }; + try + { + // 杩斿洖鍗曞彿瀛楃涓插垪琛℅et_Qt_ck_List + var list = Db.Ado.SqlQuery<string>( + "EXEC prc_pda_sttl_list @pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters); + return list; + } + catch (Exception ex) + { + throw new Exception($"{ex.Message}"); + } } /// <summary> @@ -34,39 +55,65 @@ /// </summary> /// <param name="query">浠撳簱鏌ヨ鍙傛暟</param> /// <returns>鐗╂枡鏄庣粏鍒楄〃</returns> - public List<ItemDetailModel> GetMesItemDetailByBillNo( - WarehouseQuery query) + public dynamic GetMesItemDetailByBillNo(WarehouseQuery query, dynamic RequestInfo) { - // 鍏宠仈鏌ヨ鐗╂枡琛ㄣ�佺墿鏂欐槑缁嗚〃鍜岀墿鏂欏熀纭�淇℃伅琛� - var mesItemTblDetails = Db - .Queryable<MesShouTui, MesShouTuiDetail, MesItems>( - (a, b, c) => new JoinQueryInfos( - JoinType.Left, - a.Guid == b.PGuid, - JoinType.Left, - b.FMaterialId == c.Id.ToString()) - ).Where((a, b, c) => a.BillNo == query.billNo && a.IsCheck == true) - .Select<ItemDetailModel>((a, b, c) => new ItemDetailModel + if (string.IsNullOrEmpty(query.billNo)) + throw new Exception("璇烽�夊崟鎹彿锛�"); + + if (query == null) + throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓簄ull"); + + if (string.IsNullOrEmpty(query.billNo?.ToString())) + throw new ArgumentException("鍗曟嵁鍙蜂笉鑳戒负绌�", nameof(query.billNo)); + + var orgId = RequestInfo.OrgId; + + if (orgId == null) + throw new Exception("缁勭粐涓嶅瓨鍦紒"); + + // 鑾峰彇鏈畬鎴愮殑鍙戣揣閫氱煡鍗曟槑缁� + var parameters = new[] +{ + new SugarParameter("@billNo", query.billNo), + new SugarParameter("@pi_orgId",orgId), + new SugarParameter("@inP1", null), + new SugarParameter("@inP2", null), + new SugarParameter("@inP3", null), + new SugarParameter("@inP4", null) + }; + try + { + List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>( + "EXEC prc_pda_sttl_detailList @billNo,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters); + var items = blDetails.Where(x => x.DSQty > 0).ToList(); // 寰呮壂鐗╂枡 + var ysitems = blDetails.Where(x => x.SQty > 0).ToList(); // 宸叉壂鐗╂枡 + + // 杩欓噷杩斿洖鎵�鏈夋槑缁嗗垪琛� + var result = blDetails.Select(b => new ItemDetailModel { - ItemNo = c.ItemNo, - ItemName = c.ItemName, - ItemModel = c.ItemModel, - FQty = b.FQty, // 鐢宠鏁伴噺 - SQty = b.SQty, // 宸叉壂鏁伴噺 - Pid = b.PGuid.ToString(), + ItemNo = b.ItemNo, + ItemName = b.ItemName, + ItemModel = b.ItemModel, + FQty = b.FQty, + SQty = b.SQty, + DSQty = b.DSQty, + Pid = b.Pid, FMaterialId = b.FMaterialId, - Id = b.Guid.ToString() + Id = b.Id, + RecoKw=b.RecoKw, + ItemId = b.FMaterialId }).ToList(); - - // 绛涢�夊嚭寰呴��鏁伴噺澶т簬宸查��鏁伴噺鐨勮褰� - //var itemTblDetails = mesItemTblDetails - // .Where(s => (s.Tld005 ?? 0) - (s.Tld006 ?? 0) > 0).ToList(); - - return mesItemTblDetails; + return result; + } + catch (Exception ex) + { + // 淇濈暀鍘熸湁寮傚父澶勭悊閫昏緫 + throw new Exception($"{ex.Message}"); + } } /// <summary> - /// 鍙楁墭閫�鏂欏叆搴� + /// 鍙楁墭閫�鏂� /// </summary> /// <param name="query"></param> /// <returns></returns> @@ -136,4 +183,80 @@ } } } + /// <summary> + /// 鍙楁墭閫�鏂欐潯鐮佹媶鍒� prc_rf_pda_prnt_zout_barcode2 + /// </summary> + /// <param name="query">鏌ヨ鍙傛暟</param> + /// <returns>(鎴愬姛鏍囧織, 寰呭鐞嗗垪琛�)</returns> + /// <remarks> + /// 鍓嶅彴闇�瑕佷紶鍏ョ殑鍙傛暟: + /// - userName: 鐢ㄦ埛鍚�(蹇呭~) + /// - billNo: 宸ュ崟鍙�(蹇呭~) + /// - barcode: 鐗╂枡鏉$爜(蹇呭~) + /// - Num: 鍙戞枡鏁伴噺(蹇呭~,蹇呴』澶т簬0) + /// - blNo: 鍙戣揣閫氱煡鍗曞彿(蹇呭~) + /// </remarks> + public ProductionPickDto SplitBarcode(WarehouseQuery query) + { + if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖"); + if (query.billNo.IsNullOrEmpty()) throw new Exception("鐢宠鍗曞彿涓嶅厑璁镐负绌�"); + if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�"); + + if (query.Num is null or 0) throw new Exception("鏉$爜鎷嗗垎鏁颁笉鍏佽涓虹┖鎴栬�呬负0"); + + var _strMsg = ""; + var _intSum = ""; + var _cfBar = "";//鎷嗗垎鍚庢潯鐮� + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + { + using (var cmd = new SqlCommand("[prc_pda_STTL_CF]", conn)) + { + try + { + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; + SqlParameter[] parameters = + { + new("@outMsg", SqlDbType.NVarChar, 2000), + new("@outSum", SqlDbType.NVarChar, 300), + new("@outCfBar", SqlDbType.NVarChar, 300), + new("@c_user", query.userName), + new("@p_biLL_no", query.billNo), + new("@p_item_barcode", query.barcode), + new("@NUM", query.Num) + }; + parameters[0].Direction = ParameterDirection.Output; + parameters[1].Direction = ParameterDirection.Output; + parameters[2].Direction = ParameterDirection.Output; + foreach (var parameter in parameters) + cmd.Parameters.Add(parameter); + cmd.ExecuteNonQuery(); + _strMsg = parameters[0].Value.ToString(); + _intSum = parameters[1].Value.ToString(); + _cfBar = parameters[2].Value.ToString(); + + + var result = Convert.ToInt32(_intSum); + if (result <= 0) throw new Exception(_strMsg); + + var dto = new ProductionPickDto + { + daa001 = query.billNo, + barcode = query.barcode,//鍘熸潯鐮� + cfBarcode = _cfBar//鎷嗗垎鍚庢潯鐮� + }; + + return dto; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + finally + { + conn.Close(); + } + } + } + } } \ No newline at end of file -- Gitblit v1.9.3