From 4910c0fa81d93635e19a57c073c3a62c76053320 Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期五, 25 七月 2025 13:24:18 +0800 Subject: [PATCH] 1.巡检扫描工位 --- service/Warehouse/MesCgthSqManager.cs | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 166 insertions(+), 6 deletions(-) diff --git a/service/Warehouse/MesCgthSqManager.cs b/service/Warehouse/MesCgthSqManager.cs index 9c23a05..4c92478 100644 --- a/service/Warehouse/MesCgthSqManager.cs +++ b/service/Warehouse/MesCgthSqManager.cs @@ -6,6 +6,7 @@ using NewPdaSqlServer.entity; using NewPdaSqlServer.entity.Base; using SqlSugar; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace NewPdaSqlServer.service.Warehouse; @@ -103,8 +104,7 @@ using (var conn = new SqlConnection(DbHelperSQL.strConn)) { if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖"); - if (query.billNo.IsNullOrEmpty()) throw new Exception("棰嗘枡鍗曞彿涓嶅厑璁镐负绌�"); - if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�"); + if (query.billNo.IsNullOrEmpty()) throw new Exception("鐢宠鍗曞彿涓嶅厑璁镐负绌�"); if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�"); using (var cmd = new SqlCommand("[prc_pda_CGTH]", conn)) { @@ -140,7 +140,7 @@ var dto = new ProductionPickDto { - daa001 = query.daa001, + daa001 = query.billNo, barcodeNum = barcodeNum, splitNum = splitNum, barcode = query.barcode, @@ -165,7 +165,7 @@ public ProductionPickDto ScanCodeCF(WarehouseQuery query) { if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖"); - if (query.daa001.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"); @@ -187,7 +187,7 @@ new("@outSum", SqlDbType.NVarChar, 300), new("@outCfBar", SqlDbType.NVarChar, 300), new("@c_User", query.userName), - new("@p_biLL_no", query.daa001), + new("@p_biLL_no", query.billNo), new("@p_item_barcode", query.barcode), new("@num", query.Num) }; @@ -207,7 +207,7 @@ var dto = new ProductionPickDto { - daa001 = query.daa001, + daa001 = query.billNo, barcode = query.barcode,//鍘熸潯鐮� cfBarcode = _cfBar//鎷嗗垎鍚庢潯鐮� }; @@ -225,4 +225,164 @@ } } } + + + /// <summary> + /// 閲囪喘鎵爜楠岄�� + /// </summary> + /// <param name="query"></param> + /// <returns></returns> + /// <exception cref="ArgumentNullException"></exception> + /// <exception cref="ArgumentException"></exception> + /// <exception cref="Exception"></exception> + public dynamic ScanCgyt(dynamic query) + { + if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null"); + + // 2. 浣跨敤 string.IsNullOrEmpty 鐩存帴鍒ゆ柇瀛楃涓插睘鎬э紙閬垮厤 NullReferenceException锛� + if (string.IsNullOrEmpty(query.userName?.ToString())) + throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userName)); + + if (string.IsNullOrEmpty(query.barcode?.ToString())) + throw new ArgumentException("閲囪喘鐗╂枡鏉$爜涓嶅厑璁镐负绌�", nameof(query.barcode)); + + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + { + using (var cmd = new SqlCommand("prc_pda_scan_CGYT", conn)) + { + cmd.CommandType = CommandType.StoredProcedure; + var parameters = new SqlParameter[] + { + new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName }, + new("@pi_barcode", SqlDbType.NVarChar, 100) { Value = query.barcode }, + new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output }, + new("@po_outSum", SqlDbType.Int) { Direction = ParameterDirection.Output }, + new("@po_ygdh", SqlDbType.NVarChar, 200) { Direction = ParameterDirection.Output } + }; + + cmd.Parameters.AddRange(parameters); + conn.Open(); + cmd.ExecuteNonQuery(); + + var result = new + { + result = parameters[3].Value.ToString(), + barcode = query.barcode, + ytdh = parameters[4].Value.ToString(), + msg = parameters[2].Value.ToString() + }; + + if (result.result == "-1") + throw new Exception(parameters[2].Value.ToString()); + + return result; + } + } + } + + /// <summary> + /// 鍒犻櫎楠岄��鍗� + /// </summary> + /// <param name="query"></param> + /// <returns></returns> + /// <exception cref="ArgumentNullException"></exception> + /// <exception cref="ArgumentException"></exception> + /// <exception cref="Exception"></exception> + public dynamic deleteCgyt(dynamic query) + { + if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null"); + + // 2. 浣跨敤 string.IsNullOrEmpty 鐩存帴鍒ゆ柇瀛楃涓插睘鎬э紙閬垮厤 NullReferenceException锛� + if (string.IsNullOrEmpty(query.userName?.ToString())) + throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userName)); + + if (string.IsNullOrEmpty(query.ytdh?.ToString())) + throw new ArgumentException("杩芥函鐮佷笉鍏佽涓虹┖", nameof(query.ytdh)); + + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + { + using (var cmd = new SqlCommand("prc_pda_delete_CGYT", conn)) + { + cmd.CommandType = CommandType.StoredProcedure; + var parameters = new SqlParameter[] + { + new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName }, + new("@pi_ytdh", SqlDbType.NVarChar, 100) { Value = query.ytdh }, + new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output }, + new("@po_outSum", SqlDbType.Int) { Direction = ParameterDirection.Output } + }; + + cmd.Parameters.AddRange(parameters); + conn.Open(); + cmd.ExecuteNonQuery(); + + var result = new + { + result = parameters[3].Value.ToString(), + msg = parameters[2].Value.ToString(), + }; + + if (result.result == "-1") + throw new Exception(parameters[2].Value.ToString()); + + return result; + } + } + } + + /// <summary> + /// 鑾峰彇楠岄��鍗曞凡鎵墿鏂欎俊鎭� + /// </summary> + /// <param name="query"></param> + /// <returns></returns> + public dynamic getYtItem(string ytdh) + { + if (string.IsNullOrEmpty(ytdh?.ToString())) + throw new ArgumentException("楠岄��鍗曞彿涓嶅厑璁镐负绌�", nameof(ytdh)); + + var sqlParams = new List<SugarParameter> { new("@ytdh", ytdh) }; + + var sql1 = @"SELECT C.item_id,C.item_no,C.item_name,C.item_model,A.quantity +FROM MES_INV_ITEM_CGYT_ITEMS A + LEFT JOIN MES_INV_ITEM_CGYT B ON A.item_cgyt_id = B.GUID + LEFT JOIN MES_ITEMS C ON A.item_id = C.item_id +WHERE B.item_cgyt_no = @ytdh"; + + var YtItem = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams); + + //if (YtItem.Count < 1) + //{ + // throw new Exception($"璇ラ獙閫�鍗曞彿{ytdh}鐗╂枡鏄庣粏涓嶅瓨鍦紒"); + //} + + return YtItem; + } + + /// <summary> + /// 鑾峰彇楠岄��鍗曞凡鎵潯鐮佷俊鎭� + /// </summary> + /// <param name="query"></param> + /// <returns></returns> + public dynamic getYtBarInfo(string ytdh) + { + if (string.IsNullOrEmpty(ytdh?.ToString())) + throw new ArgumentException("楠岄��鍗曞彿涓嶅厑璁镐负绌�", nameof(ytdh)); + + var sqlParams = new List<SugarParameter> { new("@ytdh", ytdh) }; + + var sql1 = @"SELECT C.item_id,C.item_no,C.item_name,C.item_model,A.quantity,A.ITEM_BARCODE +FROM MES_INV_ITEM_CGYT_C_DETAILS A + LEFT JOIN MES_INV_ITEM_CGYT B ON A.item_cgyt_id = B.GUID + LEFT JOIN MES_ITEMS C ON A.item_id = C.item_id +WHERE B.item_cgyt_no = @ytdh"; + + var YtBarInfo = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams); + + //if (YtBarInfo.Count < 1) + //{ + // throw new Exception($"璇ラ獙閫�鍗曞彿{ytdh}浠栦滑涓嶅瓨鍦紒"); + //} + + return YtBarInfo; + } } \ No newline at end of file -- Gitblit v1.9.3