From 52d1e37bb116c995b601728bfe81e3816c3944c9 Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期五, 27 六月 2025 08:22:33 +0800 Subject: [PATCH] 1.携客云到货单主表新增单据类型字段 2.条码入库前拆分 --- service/base/MesPrintMangeer.cs | 33 ++++++++ entity/DeliveryNotice.cs | 6 + service/Warehouse/MesBarCFManager.cs | 90 ++++++++++++++++++++++ Controllers/Warehouse/MesBarCFController.cs | 53 +++++++++++++ 4 files changed, 182 insertions(+), 0 deletions(-) diff --git a/Controllers/Warehouse/MesBarCFController.cs b/Controllers/Warehouse/MesBarCFController.cs index 33abddd..3199bfb 100644 --- a/Controllers/Warehouse/MesBarCFController.cs +++ b/Controllers/Warehouse/MesBarCFController.cs @@ -47,6 +47,31 @@ /// 鑾峰彇鏉$爜淇℃伅鍜岀墿鏂欎俊鎭� /// </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("BarCF")] public ResponseResult BarCF(WarehouseQuery unity) { @@ -69,4 +94,32 @@ 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/entity/DeliveryNotice.cs b/entity/DeliveryNotice.cs index 8fc7a8d..78a9e4e 100644 --- a/entity/DeliveryNotice.cs +++ b/entity/DeliveryNotice.cs @@ -34,6 +34,12 @@ public string InnerVendorName { get; set; } /// <summary> + /// 閲囪喘绫诲瀷锛�1锛氫竴鑸噰璐紱2锛氬澶栭噰璐紱3锛氬瑙掗噰璐紱4锛氳垂鐢ㄩ噰璐紱5锛氬浐璧勯噰璐紱6锛氬澶栫洿閫侊紱7锛氬澶栭噰璐紱8锛氬钩鍙伴噰璐紱9锛歏MI閲囪喘锛�10锛氭牱鍝侀噰璐紱11锛氭姌璁╄鍗曪紱12:閫�璐ц鍗曪紱13:浠i�佽鍗� + /// </summary> + [SugarColumn(ColumnName = "purchase_type")] + public string PurchaseType { get; set; } + + /// <summary> /// 閫佽揣绫诲瀷锛�1-鏅�� 2-琛ヨ揣 3-澶囧搧 4-鏍峰搧 5-VMI /// </summary> [SugarColumn(ColumnName = "delivery_type")] diff --git a/service/Warehouse/MesBarCFManager.cs b/service/Warehouse/MesBarCFManager.cs index b7e431b..4ef9d12 100644 --- a/service/Warehouse/MesBarCFManager.cs +++ b/service/Warehouse/MesBarCFManager.cs @@ -22,6 +22,27 @@ return barInfo; // 杩斿洖绗竴琛屾暟鎹紝濡傛灉娌℃湁鍒欒繑鍥� null } + 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).First(); + + if (barInfo is null) throw new Exception("璇ユ潯鐮佷俊鎭笉瀛樺湪锛�"); + + return barInfo; + } + public MesItems GetItemNo(decimal strItemId) { var itemInfo = Db.Queryable<MesItems>() @@ -100,4 +121,73 @@ } } } + + 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/base/MesPrintMangeer.cs b/service/base/MesPrintMangeer.cs index dc68505..264514d 100644 --- a/service/base/MesPrintMangeer.cs +++ b/service/base/MesPrintMangeer.cs @@ -75,6 +75,39 @@ // 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