From 0aa54059b26e6641196e9953490dd18616e916e3 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期三, 10 九月 2025 17:26:47 +0800 Subject: [PATCH] 精简修正代码 --- service/Warehouse/KwbgManager.cs | 117 ++++++++++++++++++++++++++++++---------------------------- 1 files changed, 61 insertions(+), 56 deletions(-) diff --git a/service/Warehouse/KwbgManager.cs b/service/Warehouse/KwbgManager.cs index 93f22ef..5e9dbb8 100644 --- a/service/Warehouse/KwbgManager.cs +++ b/service/Warehouse/KwbgManager.cs @@ -1,30 +1,27 @@ 锘縰sing System.Data; using System.Data.SqlClient; -using Masuit.Tools; -using Masuit.Tools.Hardware; using NewPdaSqlServer.DB; -using NewPdaSqlServer.Dto.service; using NewPdaSqlServer.entity; +using NewPdaSqlServer.util; using SqlSugar; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace NewPdaSqlServer.service.Warehouse; /// <summary> -/// 搴撲綅鍙樻洿绠$悊绫伙紝缁ф壙鑷�氱敤浠撳偍绫籖epository锛屾搷浣滈噰璐��璐х敵璇疯〃锛圡esCgthSq锛� +/// 搴撲綅鍙樻洿绠$悊绫伙紝缁ф壙鑷�氱敤浠撳偍绫籖epository锛屾搷浣滈噰璐��璐х敵璇疯〃锛圡esCgthSq锛� /// </summary> public class KwbgManager : Repository<MesCgthSq> { /// <summary> - /// 鏍规嵁浼犲叆鐨刉arehouseQuery瀵硅薄锛堝寘鍚潯鐮佷俊鎭級锛屾煡璇㈢墿鏂欏簱瀛樿〃MES_INV_ITEM_STOCKS锛岃幏鍙栧搴旂殑搴撳瓨淇℃伅 + /// 鏍规嵁浼犲叆鐨刉arehouseQuery瀵硅薄锛堝寘鍚潯鐮佷俊鎭級锛屾煡璇㈢墿鏂欏簱瀛樿〃MES_INV_ITEM_STOCKS锛岃幏鍙栧搴旂殑搴撳瓨淇℃伅 /// </summary> /// <param name="unity">WarehouseQuery瀵硅薄锛屽寘鍚潯鐮佺紪鍙风瓑鏌ヨ鏉′欢</param> /// <returns> - /// 杩斿洖MES_INV_ITEM_STOCKS琛ㄤ腑涓庢潯鐮佸尮閰嶇殑绗竴鏉″簱瀛樹俊鎭紙MesInvItemStocks绫诲瀷锛夈�� - /// 濡傛灉鏈壘鍒帮紝鍒欐姏鍑哄紓甯告彁绀衡�滆鏉$爜搴撳瓨涓嶅瓨鍦紒鈥� - /// resultInfos.tbBillList = m.GetBarInfo(unity); + /// 杩斿洖MES_INV_ITEM_STOCKS琛ㄤ腑涓庢潯鐮佸尮閰嶇殑绗竴鏉″簱瀛樹俊鎭紙MesInvItemStocks绫诲瀷锛夈�� + /// 濡傛灉鏈壘鍒帮紝鍒欐姏鍑哄紓甯告彁绀衡�滆鏉$爜搴撳瓨涓嶅瓨鍦紒鈥� + /// resultInfos.tbBillList = m.GetBarInfo(unity); /// </returns> - ///public MesInvItemStocks GetBarInfo(WarehouseQuery unity) + /// public MesInvItemStocks GetBarInfo(WarehouseQuery unity) public dynamic GetBarInfo(dynamic query) { if (query == null) @@ -34,18 +31,19 @@ throw new ArgumentException("鐗╂枡鏉$爜涓嶈兘涓虹┖", nameof(query.barcode)); var parameters = new[] - { - new SugarParameter("@pi_barcode", query.barcode), - new SugarParameter("@inP1", null), - new SugarParameter("@inP2", null), - new SugarParameter("@inP3", null), - new SugarParameter("@inP4", null) - }; + { + new SugarParameter("@pi_barcode", query.barcode), + new SugarParameter("@inP1", null), + new SugarParameter("@inP2", null), + new SugarParameter("@inP3", null), + new SugarParameter("@inP4", null) + }; try { - List<dynamic>? ZsBarInfo = Db.Ado.SqlQuery<dynamic>( - "EXEC prc_pda_kwbg_selKwInfoByBarcode @pi_barcode,@inP1,@inP2,@inP3,@inP4", parameters); + var ZsBarInfo = Db.Ado.SqlQuery<dynamic>( + "EXEC prc_pda_kwbg_selKwInfoByBarcode @pi_barcode,@inP1,@inP2,@inP3,@inP4", + parameters); return ZsBarInfo; } @@ -57,13 +55,13 @@ } /// <summary> - /// 鏍规嵁鐗╂枡ID鏌ヨ鐗╂枡琛∕ES_ITEMS锛岃幏鍙栫墿鏂欒缁嗕俊鎭� + /// 鏍规嵁鐗╂枡ID鏌ヨ鐗╂枡琛∕ES_ITEMS锛岃幏鍙栫墿鏂欒缁嗕俊鎭� /// </summary> /// <param name="strItemId">鐗╂枡ID锛坉ecimal绫诲瀷锛�</param> /// <returns> - /// 杩斿洖MES_ITEMS琛ㄤ腑涓嶪D鍖归厤涓旀湭绂佺敤锛團forbidstatus涓�"A"锛夌殑绗竴鏉$墿鏂欎俊鎭紙MesItems绫诲瀷锛夈�� - /// 濡傛灉鏈壘鍒帮紝鍒欐姏鍑哄紓甯告彁绀衡�滆鏉$爜瀵瑰簲鐗╂枡淇℃伅涓嶅瓨鍦ㄦ垨宸茬鐢紒鈥� - /// resultInfos.tbMesItems = m.GetItemNo(resultInfos.tbBillList.ItemId); + /// 杩斿洖MES_ITEMS琛ㄤ腑涓嶪D鍖归厤涓旀湭绂佺敤锛團forbidstatus涓�"A"锛夌殑绗竴鏉$墿鏂欎俊鎭紙MesItems绫诲瀷锛夈�� + /// 濡傛灉鏈壘鍒帮紝鍒欐姏鍑哄紓甯告彁绀衡�滆鏉$爜瀵瑰簲鐗╂枡淇℃伅涓嶅瓨鍦ㄦ垨宸茬鐢紒鈥� + /// resultInfos.tbMesItems = m.GetItemNo(resultInfos.tbBillList.ItemId); /// </returns> public MesItems GetItemNo(decimal strItemId) { @@ -79,14 +77,15 @@ // 杩斿洖鏌ヨ鍒扮殑鐗╂枡淇℃伅瀵硅薄 return itemInfo; } + /// <summary> - /// 浠撳簱淇℃伅琛� + /// 浠撳簱淇℃伅琛� /// </summary> /// <param name="depot_id"></param> /// <returns></returns> public MesDepots GetDepot(decimal depot_id) { - var depotInfo = Db.Queryable< MesDepots >() + var depotInfo = Db.Queryable<MesDepots>() .Where(s => s.DepotId == depot_id) .First(); // 鑾峰彇绗竴鏉″尮閰嶈褰� // 濡傛灉鏈煡璇㈠埌缁撴灉锛坕temInfo涓簄ull锛夛紝鍒欐姏鍑哄紓甯革紝鎻愮ず鐗╂枡淇℃伅涓嶅瓨鍦ㄦ垨宸茬鐢� @@ -95,9 +94,8 @@ } - /// <summary> - /// 鍙樻洿搴撲綅 + /// 鍙樻洿搴撲綅 /// </summary> /// <param name="unity"></param> /// <returns></returns> @@ -116,13 +114,15 @@ { //if (string.IsNullOrEmpty(query.barcode?.ToString())) //throw new ArgumentException("鐗╂枡鏉$爜涓嶈兘涓虹┖", nameof(query.barcode)); - + if (string.IsNullOrEmpty(unity.userName?.ToString())) throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(unity.userName)); if (string.IsNullOrEmpty(unity.OldDepotSectionCode?.ToString())) - throw new ArgumentException("鍘熷簱浣嶄笉鍏佽涓虹┖", nameof(unity.OldDepotSectionCode)); + throw new ArgumentException("鍘熷簱浣嶄笉鍏佽涓虹┖", + nameof(unity.OldDepotSectionCode)); if (string.IsNullOrEmpty(unity.NewDepotSectionCode?.ToString())) - throw new ArgumentException("鏂板簱浣嶄笉鍏佽涓虹┖", nameof(unity.NewDepotSectionCode)); + throw new ArgumentException("鏂板簱浣嶄笉鍏佽涓虹┖", + nameof(unity.NewDepotSectionCode)); if (string.IsNullOrEmpty(unity.barcode?.ToString())) throw new ArgumentException("鐗╂枡鏉$爜涓嶅厑璁镐负绌�", nameof(unity.barcode)); @@ -144,25 +144,31 @@ // 鏋勯�犲瓨鍌ㄨ繃绋嬪弬鏁版暟缁� SqlParameter[] parameters = { - // 杈撳嚭鍙傛暟锛氳繑鍥炰俊鎭� - new("@outMsg", SqlDbType.NVarChar, 2000), - // 杈撳嚭鍙傛暟锛氳繑鍥炴暟閲� - new("@outSum", SqlDbType.Int), - // 杈撳嚭鍙傛暟锛氳繑鍥炴柊搴撲綅浠g爜 - new("@new_depotSectionsCode", SqlDbType.NVarChar, 300), - // 杈撳叆鍙傛暟锛氭搷浣滅敤鎴� - new SqlParameter("@c_user", unity.userName?.ToString() ?? ""), - // 杈撳叆鍙傛暟锛氬師鏉$爜 - new SqlParameter("@p_barcode", unity.barcode?.ToString() ?? ""), - // 杈撳叆鍙傛暟锛氬師搴撲綅浠g爜 - new("@old_depotSectionsCode", unity.OldDepotSectionCode?.ToString() ??""), - // 杈撳叆鍙傛暟锛氭柊搴撲綅浠g爜 - new("@new_depotSectionsCode_input", unity.NewDepotSectionCode?.ToString() ??""), - // 杈撳叆鍙傛暟锛氫粨搴撲唬鐮� - new("@DepotCode", unity.DepotCode) { Value = unity.DepotCode ?? "" }, - // 杈撳叆鍙傛暟锛氫粨搴搃d - new SqlParameter("@DepotId", (int?)unity.DepotId ?? (object)DBNull.Value) - }; + // 杈撳嚭鍙傛暟锛氳繑鍥炰俊鎭� + new("@outMsg", SqlDbType.NVarChar, 2000), + // 杈撳嚭鍙傛暟锛氳繑鍥炴暟閲� + new("@outSum", SqlDbType.Int), + // 杈撳嚭鍙傛暟锛氳繑鍥炴柊搴撲綅浠g爜 + new("@new_depotSectionsCode", SqlDbType.NVarChar, 300), + // 杈撳叆鍙傛暟锛氭搷浣滅敤鎴� + new SqlParameter("@c_user", + unity.userName?.ToString() ?? ""), + // 杈撳叆鍙傛暟锛氬師鏉$爜 + new SqlParameter("@p_barcode", + unity.barcode?.ToString() ?? ""), + // 杈撳叆鍙傛暟锛氬師搴撲綅浠g爜 + new("@old_depotSectionsCode", + unity.OldDepotSectionCode?.ToString() ?? ""), + // 杈撳叆鍙傛暟锛氭柊搴撲綅浠g爜 + new("@new_depotSectionsCode_input", + unity.NewDepotSectionCode?.ToString() ?? ""), + // 杈撳叆鍙傛暟锛氫粨搴撲唬鐮� + new("@DepotCode", unity.DepotCode) + { Value = unity.DepotCode ?? "" }, + // 杈撳叆鍙傛暟锛氫粨搴搃d + new("@DepotId", + (int?)unity.DepotId ?? (object)DBNull.Value) + }; // 璁剧疆杈撳嚭鍙傛暟鏂瑰悜 parameters[0].Direction = ParameterDirection.Output; parameters[1].Direction = ParameterDirection.Output; @@ -176,9 +182,10 @@ cmd.ExecuteNonQuery(); // 鑾峰彇瀛樺偍杩囩▼杈撳嚭鍙傛暟鐨勫�� - _strMsg = parameters[0].Value.ToString(); // 杩斿洖淇℃伅 - _intSum = parameters[1].Value.ToString(); // 杩斿洖鏁伴噺 - _NewDepotSectionCode = parameters[2].Value.ToString(); // 鏂板簱浣嶄唬鐮� + _strMsg = parameters[0].Value.ToString(); // 杩斿洖淇℃伅 + _intSum = parameters[1].Value.ToString(); // 杩斿洖鏁伴噺 + _NewDepotSectionCode = + parameters[2].Value.ToString(); // 鏂板簱浣嶄唬鐮� // 鍒ゆ柇鍙樻洿缁撴灉锛屽鏋滄暟閲忓皬浜庣瓑浜�0锛屽垯琛ㄧず鍙樻洿澶辫触锛屾姏鍑哄紓甯稿苟杩斿洖閿欒淇℃伅 var result = Convert.ToInt32(_intSum); @@ -187,8 +194,8 @@ // 浣跨敤鍖垮悕瀵硅薄鑰屼笉鏄� dynamic? 鏇村悎閫� var dto = new { - barcode = unity.barcode, - OldDepotSectionCode = unity.OldDepotSectionCode, + unity.barcode, + unity.OldDepotSectionCode, NewDepotSectionCode = _NewDepotSectionCode }; @@ -214,6 +221,4 @@ ProductionPickDto鏈夎繃娣诲姞 public int? DepotId { get; set; } //浠撳簱id */ - - } \ No newline at end of file -- Gitblit v1.9.3