From cb23d88faf0bd112db57816c5cc02e47eb685324 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期一, 13 一月 2025 10:56:10 +0800
Subject: [PATCH] 11
---
service/Warehouse/TransferOutManager.cs | 139 ++++++++++++++++++++++++++++++++++
Controllers/Warehouse/TransferOutController.cs | 95 +++++++++++++++++++++++
2 files changed, 234 insertions(+), 0 deletions(-)
diff --git a/Controllers/Warehouse/TransferOutController.cs b/Controllers/Warehouse/TransferOutController.cs
index d37e531..314ce0f 100644
--- a/Controllers/Warehouse/TransferOutController.cs
+++ b/Controllers/Warehouse/TransferOutController.cs
@@ -43,6 +43,57 @@
#endregion
+ #region 璋冩嫧鍏ュ簱涓氬姟
+
+ /// <summary>
+ /// 鎵弿鏉$爜杩涜璋冩嫧鍏ュ簱澶勭悊
+ /// </summary>
+ /// <param name="query">鏌ヨ鍙傛暟</param>
+ /// <returns>澶勭悊缁撴灉鍜屽緟澶勭悊鏄庣粏</returns>
+ /// <remarks>
+ /// 璇锋眰绀轰緥:
+ /// POST /api/TransferOut/ScanReceiveBarcode
+ /// {
+ /// "billNo": "DB202401010001", // 璋冩嫧鍗曞彿(蹇呭~)
+ /// "userName": "admin", // 鐢ㄦ埛鍚�(蹇呭~)
+ /// "barcode": "BC001" // 鏉$爜鍙�(蹇呭~)
+ /// }
+ /// 涓氬姟澶勭悊锛�
+ /// - 楠岃瘉璋冩嫧鍗曠姸鎬�
+ /// - 楠岃瘉鏉$爜搴撳瓨淇℃伅
+ /// - 楠岃瘉浠撳簱涓�鑷存��
+ /// - 楠岃瘉鏁伴噺鏄惁瓒呭嚭鏈壂鏁伴噺
+ /// - 鎵ц璋冩嫧鍏ュ簱浜嬪姟澶勭悊
+ /// 杩斿洖鏁版嵁鍖呭惈锛�
+ /// - form: 澶勭悊缁撴灉琛ㄥ崟
+ /// - items: 寰呭鐞嗘槑缁嗗垪琛�
+ /// </remarks>
+ /// <response code="200">鎵弿鎴愬姛</response>
+ /// <response code="400">鎵弿澶辫触锛岃繑鍥炲叿浣撻敊璇俊鎭�</response>
+ [HttpPost("ScanReceiveBarcode")]
+ public ResponseResult ScanReceiveBarcode([FromBody] WarehouseQuery query)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ var (form, items) = _manager.ScanReceiveBarcode(query);
+ resultInfos.form = form;
+ resultInfos.items = items;
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ #endregion
+
#region 璋冩嫧鍑哄簱涓氬姟
/// <summary>
@@ -162,5 +213,49 @@
}
}
+ /// <summary>
+ /// 鍒嗗壊鏉$爜杩涜璋冩嫧鍑哄簱澶勭悊
+ /// </summary>
+ /// <param name="query">鏌ヨ鍙傛暟</param>
+ /// <returns>澶勭悊缁撴灉鍜屽緟澶勭悊鏄庣粏</returns>
+ /// <remarks>
+ /// 璇锋眰绀轰緥:
+ /// POST /api/TransferOut/SplitBarcode
+ /// {
+ /// "billNo": "DB202401010001", // 璋冩嫧鍗曞彿(蹇呭~)
+ /// "userName": "admin", // 鐢ㄦ埛鍚�(蹇呭~)
+ /// "barcode": "BC001" // 鏉$爜鍙�(蹇呭~)
+ /// "fum": "1" // 鎷嗗垎鏁�(蹇呭~)
+ /// }
+ /// 涓氬姟澶勭悊锛�
+ /// - 楠岃瘉璋冩嫧鍗曠姸鎬�
+ /// - 楠岃瘉鏉$爜搴撳瓨淇℃伅
+ /// - 楠岃瘉浠撳簱涓�鑷存��
+ /// - 楠岃瘉鏁伴噺鏄惁瓒呭嚭鏈壂鏁伴噺
+ /// - 鎵ц鍒嗗壊鏉$爜鐨勮皟鎷ㄥ嚭搴撲簨鍔″鐞�
+ /// </remarks>
+ /// <response code="200">鍒嗗壊鎴愬姛</response>
+ /// <response code="400">鍒嗗壊澶辫触锛岃繑鍥炲叿浣撻敊璇俊鎭�</response>
+ [HttpPost("SplitBarcode")]
+ public ResponseResult SplitBarcode([FromBody] WarehouseQuery query)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ var message = _manager.SplitBarcode(query);
+ resultInfos.tbBillList = message;
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
#endregion
}
\ No newline at end of file
diff --git a/service/Warehouse/TransferOutManager.cs b/service/Warehouse/TransferOutManager.cs
index 1314b8c..55ff835 100644
--- a/service/Warehouse/TransferOutManager.cs
+++ b/service/Warehouse/TransferOutManager.cs
@@ -171,4 +171,143 @@
}
}
}
+
+ /// <summary>
+ /// 鎵弿鏉$爜杩涜璋冩嫧鍏ュ簱澶勭悊
+ /// </summary>
+ /// <param name="query">鍖呭惈鍗曟嵁鍙枫�佺敤鎴峰悕鍜屾潯鐮佷俊鎭殑鏌ヨ鍙傛暟</param>
+ /// <returns>澶勭悊鍚庣殑琛ㄥ崟鍜屽緟澶勭悊鏄庣粏鍒楄〃</returns>
+ public (WarehouseQuery form, List<TransferOutDetail> items)
+ ScanReceiveBarcode(WarehouseQuery query)
+ {
+ var p_bill_no = query.billNo;
+ var p_item_barcode = query.barcode;
+
+ // 楠岃瘉鍗曟嵁鍙�
+ if (string.IsNullOrEmpty(p_bill_no)) throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
+
+ // 鏌ヨ鍑哄簱鍗曞苟楠岃瘉鐘舵��
+ var transferOut = Db.Queryable<TransferOut>()
+ .Where(x => x.BillNo == p_bill_no && x.Status == 1)
+ .First();
+ if (transferOut == null) throw new Exception("鏈壘鍒拌皟鎷ㄧ敵璇峰崟鎴栬�呰皟鎷ㄧ敵璇峰崟娌″鏍�");
+
+ // 鏌ヨ鏉$爜搴撳瓨淇℃伅骞堕獙璇�
+ var stock = Db.Queryable<MesInvItemStocks>()
+ .Where(x => x.ItemBarcode == p_item_barcode
+ && x.Quantity > 0
+ && !string.IsNullOrEmpty(x.DepotsCode))
+ .First();
+ if (stock == null) throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮侊紝璇锋牳瀵癸紒{p_item_barcode}");
+
+ // 鏌ヨ鐗╂枡淇℃伅
+ var item = Db.Queryable<MesItems>()
+ .Where(x => x.Id == stock.ItemId)
+ .First();
+ if (item == null) throw new Exception("鏈壘鍒扮墿鏂�");
+
+ var _strMsg = "";
+ var _intSum = "";
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ {
+ using (var cmd = new SqlCommand("[prc_pda_DBRK]", conn))
+ {
+ try
+ {
+ conn.Open();
+ cmd.CommandType = CommandType.StoredProcedure;
+ SqlParameter[] parameters =
+ {
+ new("@outMsg", SqlDbType.NVarChar, 300),
+ new("@outSum", SqlDbType.NVarChar, 300),
+ new("@barcode_num", SqlDbType.NVarChar, 300),
+ new("@split_num", SqlDbType.NVarChar, 300),
+ new("@c_user", query.userName),
+ new("@p_bill_no", p_bill_no),
+ new("@p_item_barcode", p_item_barcode),
+ new("@p_depot_section_code", query.sectionCode),
+ };
+ parameters[0].Direction = ParameterDirection.Output;
+ parameters[1].Direction = ParameterDirection.Output;
+ parameters[2].Direction = ParameterDirection.Output;
+ parameters[3].Direction = ParameterDirection.Output;
+ foreach (var parameter in parameters)
+ cmd.Parameters.Add(parameter);
+ cmd.ExecuteNonQuery();
+ _strMsg = parameters[0].Value.ToString();
+ _intSum = parameters[1].Value.ToString();
+
+ var barcodeNum = parameters[2].Value.ToString();
+ var splitNum = parameters[3].Value.ToString();
+
+ var result = Convert.ToInt32(_intSum);
+ if (result <= 0) throw new Exception(_strMsg);
+
+ query.itemNo = item.ItemNo;
+ query.Num = Convert.ToDecimal(barcodeNum);
+ query.Fum = Convert.ToDecimal(splitNum);
+
+ // 杩斿洖鏇存柊鍚庣殑琛ㄥ崟鍜屽緟澶勭悊鏄庣粏
+ return (query, GetTransferOutDetailListByBillNo(query));
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+ }
+ }
+
+ //璋冩嫧鍑哄簱鎷嗗垎 prc_pda_DBCK_CF
+ public string SplitBarcode(WarehouseQuery query)
+ {
+ var _strMsg = "";
+ var _intSum = "";
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ {
+ using (var cmd = new SqlCommand("[prc_pda_DBRK]", conn))
+ {
+ try
+ {
+ conn.Open();
+ cmd.CommandType = CommandType.StoredProcedure;
+ SqlParameter[] parameters =
+ {
+ new("@outMsg", SqlDbType.NVarChar, 300),
+ new("@outSum", SqlDbType.NVarChar, 300),
+ new("@c_user", query.userName),
+ new("@p_bill_no", query.billNo),
+ new("@p_item_barcode", query.barcode),
+ new("@NUM", query.Fum),
+ };
+
+ parameters[0].Direction = ParameterDirection.Output;
+ parameters[1].Direction = ParameterDirection.Output;
+
+ foreach (var parameter in parameters)
+ cmd.Parameters.Add(parameter);
+ cmd.ExecuteNonQuery();
+ _strMsg = parameters[0].Value.ToString();
+ _intSum = parameters[1].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();
+ }
+ }
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3