From 797b531dda2a48d3011657db03b9af205c615a27 Mon Sep 17 00:00:00 2001 From: 况洋洋 <3283105747@qq.com> Date: 星期四, 10 七月 2025 11:30:20 +0800 Subject: [PATCH] 入库前拆分 --- appsettings.json | 2 Startup.cs | 2 service/Warehouse/MesCprkManager.cs | 2 service/base/MesPrintMangeer.cs | 36 +++++++ service/Warehouse/MesBarCFManager.cs | 92 ++++++++++++++++++ Dto/service/WarehouseQuery.cs | 2 service/Warehouse/MesInvItemInCDetailsManager.cs | 65 +++++++++++- Controllers/Warehouse/MesBarCFController.cs | 55 ++++++++++ 8 files changed, 246 insertions(+), 10 deletions(-) diff --git a/Controllers/Warehouse/MesBarCFController.cs b/Controllers/Warehouse/MesBarCFController.cs index 33abddd..9c2938b 100644 --- a/Controllers/Warehouse/MesBarCFController.cs +++ b/Controllers/Warehouse/MesBarCFController.cs @@ -54,7 +54,7 @@ { dynamic resultInfos = new ExpandoObject(); resultInfos.tbBillList = new ExpandoObject(); - resultInfos.tbBillList.printInfo = _mCf.getPrintInfo(unity); + //resultInfos.tbBillList.printInfo = _mCf.getPrintInfo(unity); var scanResult = m.BarCF(unity); resultInfos.tbBillList.cfBarInfo = _mCf.getCfInfo(scanResult); return new ResponseResult @@ -69,4 +69,57 @@ return ResponseResult.ResponseError(ex); } } + + /// <summary> + /// 鑾峰彇鏉$爜淇℃伅鍜岀墿鏂欎俊鎭紙鍏ュ簱鍓嶆媶鍒嗭級 + /// </summary> + /// <returns></returns> + [HttpPost("GetBarInfoBefore")] + public ResponseResult GetBarInfoBefore(WarehouseQuery unity) + { + try + { + dynamic resultInfos = new ExpandoObject(); + resultInfos.tbBillList = m.GetBarInfoBefore(unity); + resultInfos.tbMesItems = m.GetItemNo(resultInfos.tbBillList.ITEM_ID); + return new ResponseResult + { + status = 0, + message = "OK", + data = resultInfos + }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } + + /// <summary> + /// 鑾峰彇鏉$爜淇℃伅鍜岀墿鏂欎俊鎭� 锛堝叆搴撳墠鎷嗗垎锛� + /// </summary> + /// <returns></returns> + [HttpPost("BarCfBefore")] + public ResponseResult BarCfBefore(WarehouseQuery unity) + { + try + { + dynamic resultInfos = new ExpandoObject(); + resultInfos.tbBillList = new ExpandoObject(); + resultInfos.tbBillList.printInfo = _mCf.getPrintInfo(unity); + var scanResult = m.BarCfBefore(unity); + resultInfos.tbBillList.cfBarInfo = _mCf.getCfBeforeInfo(scanResult); + 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/Dto/service/WarehouseQuery.cs b/Dto/service/WarehouseQuery.cs index ac13440..340aa6b 100644 --- a/Dto/service/WarehouseQuery.cs +++ b/Dto/service/WarehouseQuery.cs @@ -35,4 +35,6 @@ public string? itemNo { get; set; } public string? message { get; set; } + public string? cgrkType { get; set; } + } \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index 7ab10eb..caf1a01 100644 --- a/Startup.cs +++ b/Startup.cs @@ -38,7 +38,7 @@ var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); - c.IncludeXmlComments(xmlPath, true); + //c.IncludeXmlComments(xmlPath, true); }); //閰嶇疆JSON.NET diff --git a/appsettings.json b/appsettings.json index 11434a6..732f4a4 100644 --- a/appsettings.json +++ b/appsettings.json @@ -10,6 +10,6 @@ "TestErpUrl": "http://192.168.1.149:8066/WebService1.asmx/MesToErpinfoTest", "ProductionErpUrl": "http://192.168.1.149:8066/WebService1.asmx/MesToErpinfoTest", //"DataBaseConn": "Data Source=192.168.1.146;Initial Catalog=TEST_MES;User ID=sa;Password =qixi123;Encrypt=True;TrustServerCertificate=True;" - "DataBaseConn": "Data Source=192.168.1.146;Initial Catalog=GS_MES;User ID=mesUser;Password =qixi1qaz@WSXmes;Encrypt=True;TrustServerCertificate=True;" + "DataBaseConn": "Data Source=192.168.1.187;Initial Catalog=TEST_MES;User ID=sa;Password =LongWei@2025;Encrypt=True;TrustServerCertificate=True;" } } diff --git a/service/Warehouse/MesBarCFManager.cs b/service/Warehouse/MesBarCFManager.cs index b7e431b..2efe965 100644 --- a/service/Warehouse/MesBarCFManager.cs +++ b/service/Warehouse/MesBarCFManager.cs @@ -100,4 +100,96 @@ } } } + + //鍏ュ簱鍓嶆媶鍒� + public dynamic GetBarInfoBefore(WarehouseQuery unity) + { + + // 浣跨敤鍙傛暟鍖栨煡璇㈤槻姝QL娉ㄥ叆 + var sqlParams = new List<SugarParameter> { new("@barcode", unity.barcode) }; + + var sql1 = @"SELECT 1 FROM MES_INV_ITEM_STOCKS WHERE ITEM_BARCODE =@barcode "; + + var KcInfo = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams); + + if (KcInfo.Count > 0) throw new Exception("璇ユ潯鐮佸凡鍏ュ簱涓嶈兘杩涜鍏ュ簱鍓嶆媶鍒嗭紒"); + + var sql2 = @"SELECT ITEM_ID,QUANTITY FROM MES_INV_ITEM_BARCODES WHERE ITEM_BARCODE =@barcode "; + + var barInfo = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams).FirstOrDefault(); + + if (barInfo is null) throw new Exception("璇ユ潯鐮佷俊鎭笉瀛樺湪锛�"); + + return barInfo; + } + //鍏ュ簱鍓嶆媶鍒� + public ProductionPickDto BarCfBefore(WarehouseQuery unity) + { + var _strMsg = ""; + var _intSum = ""; + var _cfBar = "";//鎷嗗垎鍚庢潯鐮� + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + { + if (unity.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖"); + if (unity.CfNum <= 0) throw new Exception("鎷嗗垎鏁伴噺闇�澶т簬绛変簬0"); + if (unity.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�"); + + using (var cmd = new SqlCommand("[prc_pda_bar_cf_before]", conn)) + { + try + { + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; + SqlParameter[] parameters = + { + new("@outMsg", SqlDbType.NVarChar, 300), + new("@outSum", SqlDbType.NVarChar, 300), + new("@barcode_new", SqlDbType.NVarChar, 300), + new("@c_user", unity.userName), + new("@p_old_barcode", unity.barcode), + new("@p_qty", unity.CfNum), + + }; + 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 + { + barcode = unity.barcode,//鍘熸潯鐮� + cfBarcode = _cfBar//鎷嗗垎鍚庢潯鐮� + }; + return dto; + + //var result = Convert.ToInt32(_intSum); + //if (result <= 0) throw new Exception(_strMsg); + + //return _strMsg; + + //return 0; + + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + finally + { + conn.Close(); + } + } + } + } + } \ No newline at end of file diff --git a/service/Warehouse/MesCprkManager.cs b/service/Warehouse/MesCprkManager.cs index f6b7b34..1288be0 100644 --- a/service/Warehouse/MesCprkManager.cs +++ b/service/Warehouse/MesCprkManager.cs @@ -80,4 +80,6 @@ } } } + + } \ No newline at end of file diff --git a/service/Warehouse/MesInvItemInCDetailsManager.cs b/service/Warehouse/MesInvItemInCDetailsManager.cs index 648e17b..8749729 100644 --- a/service/Warehouse/MesInvItemInCDetailsManager.cs +++ b/service/Warehouse/MesInvItemInCDetailsManager.cs @@ -1,4 +1,5 @@ -锘縰sing Masuit.Tools.Models; +锘縰sing Masuit.Tools; +using Masuit.Tools.Models; using NewPdaSqlServer.DB; using NewPdaSqlServer.Dto.service; using NewPdaSqlServer.entity; @@ -7,6 +8,8 @@ using NewPdaSqlServer.util; using Newtonsoft.Json; using SqlSugar; +using System.Data; +using System.Data.SqlClient; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace NewPdaSqlServer.service.Warehouse; @@ -14,6 +17,56 @@ public class MesInvItemInCDetailsManager : Repository<MesInvItemInCDetails> { //褰撳墠绫诲凡缁忕户鎵夸簡 Repository 澧炪�佸垹銆佹煡銆佹敼鐨勬柟娉� + + + // public ItemInBaseModel SaveBarCodes(WarehouseQuery entity) + // { + // var _strMsg = ""; + // var _intSum = ""; + // using (var conn = new SqlConnection(DbHelperSQL.strConn)) + // { + // if (entity.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖"); + // if (entity.sectionCode.IsNullOrEmpty()) throw new Exception("搴撲綅缂栧彿涓嶅厑璁镐负绌�"); + // if (entity.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�"); + // if (entity.cgrkType.IsNullOrEmpty()) throw new Exception("閲囪喘鍏ュ簱绫诲瀷涓嶅厑璁镐负绌�"); + + // using (var cmd = new SqlCommand("[prc_pda_inv_cgrk]", conn)) + // { + // try + // { + // conn.Open(); + // cmd.CommandType = CommandType.StoredProcedure; + // SqlParameter[] parameters = + // { + // new("@pi_user", SqlDbType.NVarChar, 100) { Value = entity.userName }, + // new("@pi_barcode", SqlDbType.NVarChar, 100) { Value = entity.barcode }, + // new("@pi_cgrkType", SqlDbType.NVarChar, 30) { Value = entity.cgrkType }, + // new("@po_outMsg", SqlDbType.NVarChar, 300), + // new("@po_outSum", SqlDbType.NVarChar, 300) + //}; + + // foreach (var parameter in parameters) + // cmd.Parameters.Add(parameter); + // cmd.ExecuteNonQuery(); + // _strMsg = parameters[4].Value.ToString(); + // _intSum = parameters[5].Value.ToString(); + + // var result = Convert.ToInt32(_intSum); + // if (result <= 0) throw new Exception(_strMsg); + + // return _strMsg; + // } + // catch (Exception ex) + // { + // throw new Exception(ex.Message); + // } + // finally + // { + // conn.Close(); + // } + // } + // } + // } public ItemInBaseModel SaveBarCodes(WarehouseQuery entity) { @@ -40,7 +93,7 @@ throw new Exception("姝ゆ潯鐮佷笉灞炰簬鍒拌揣鏉$爜锛屾棤娉曠敤閲囪喘鍏ュ簱锛�"); var inventory = Db.Queryable<MesInvItemArn>() - .Where(it => it.BillNo == itemBarcodeDetails.BillNo && it.Fstatus == true ) + .Where(it => it.BillNo == itemBarcodeDetails.BillNo && it.Fstatus == true) .First(); if (inventory == null) @@ -69,7 +122,7 @@ var sql1 = @"SELECT *FROM v_dhmx WHERE dhmxGuid = @dhmxGuid "; var dhjymx = Db.Ado.SqlQuery<vDhmx>(sql1, sqlParams).First(); //鍒ゅ畾妫�楠岃兘鍚﹀叆搴� - if (dhjymx.CanStore!= 1) + if (dhjymx.CanStore != 1) { throw new Exception($"璇ユ潯鐮佸搴旂殑鏀舵枡鍗曟楠岀粨鏋�:銆恵dhjymx.InspectionResult}銆�,鍒ゅ畾缁撴灉锛氥�恵dhjymx.JudgmentResult}銆戯紝澶勭悊鎰忚锛氥�恵dhjymx.HandlingSuggestion}銆�,鏃犳硶鍏ュ簱"); } @@ -758,13 +811,13 @@ result.itemDetail = mesItems; - result.ItemInDetails = db.Queryable<MesInvItemInCItems,MesItems>( + result.ItemInDetails = db.Queryable<MesInvItemInCItems, MesItems>( (a, b) => new JoinQueryInfos( JoinType.Left, a.ItemId == b.ItemId) ) .Where(a => a.ItemInId == cId && a.ItemId == itemBarcodeDetails.ItemId) - .Select<dynamic>((a, b) => new + .Select<dynamic>((a, b) => new { ItemNo = b.ItemNo, ItemName = b.ItemName, @@ -871,7 +924,7 @@ var purchaseInventory = getPurchaseInventory(entity); - + //result.ItemInDetails = purchaseInventory.ItemInDetails; //result.InvItemInCDetails = purchaseInventory.InvItemInCDetails; diff --git a/service/base/MesPrintMangeer.cs b/service/base/MesPrintMangeer.cs index dc68505..dd0a641 100644 --- a/service/base/MesPrintMangeer.cs +++ b/service/base/MesPrintMangeer.cs @@ -75,6 +75,40 @@ // public List<dynamic> oldBarInfo { get; set; } // } + public dynamic getCfBeforeInfo(dynamic query) // 浣跨敤鍏蜂綋绫诲瀷鏇夸唬dynamic + { + // 鍙傛暟鏍¢獙 + if (string.IsNullOrEmpty(query?.cfBarcode)) + throw new ArgumentException("鎷嗗垎鏉$爜涓嶈兘涓虹┖"); + if (string.IsNullOrEmpty(query?.barcode)) + throw new ArgumentException("鍘熷鏉$爜涓嶈兘涓虹┖"); - } + // 浣跨敤寮虹被鍨嬪弬鏁� + var sqlParams = new List<SugarParameter> { + new("@cfBar", query.cfBarcode.Trim()), + new("@oldBar", query.barcode.Trim()) + }; + + var sql = @"SELECT TOP 1 C.ITEM_NO,C.item_name,C.item_model,B.OLDQTY as QUANTITY,B.CREATE_DATE, '鎷嗗垎鏉$爜' AS BarType,B.ITEM_BARCODE,GETDATE() as print_date + FROM MES_INV_ITEM_BARCODES B + LEFT JOIN MES_ITEMS C ON C.item_id = B.ITEM_ID + WHERE B.ITEM_BARCODE = @cfBar + + UNION ALL + + SELECT TOP 1 C.ITEM_NO,C.item_name,C.item_model,B.QUANTITY as QUANTITY,B.CREATE_DATE, '鍘熷鏉$爜' AS BarType,B.ITEM_BARCODE,GETDATE() as print_date + FROM MES_INV_ITEM_BARCODES B + LEFT JOIN MES_ITEMS C ON C.item_id = B.ITEM_ID + WHERE B.ITEM_BARCODE = @oldBar"; + + var mergedData = Db.Ado.SqlQuery<dynamic>(sql, sqlParams); + + if (mergedData.Count < 2) throw new Exception("鏉$爜淇℃伅瀛樺湪寮傚父锛岃鑱旂郴绠$悊鍛橈紒"); + + return mergedData; + } + + + +} } \ No newline at end of file -- Gitblit v1.9.3