From 135599eb59bccb5f8f8a567ad174cc2af4357887 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期五, 13 六月 2025 14:39:25 +0800
Subject: [PATCH] 1.采购退货单优化 2.采购退料单拆分 3.采购入库优化

---
 service/Warehouse/MesCgthSqManager.cs |   77 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/service/Warehouse/MesCgthSqManager.cs b/service/Warehouse/MesCgthSqManager.cs
index 45e7b9b..169d43d 100644
--- a/service/Warehouse/MesCgthSqManager.cs
+++ b/service/Warehouse/MesCgthSqManager.cs
@@ -23,8 +23,8 @@
     {
         if (string.IsNullOrEmpty(query.billNo)) throw new Exception("鐢宠鍗曞彿涓虹┖");
 
-        var mesInvItemOuts = base.GetSingle(it => it.BillNo == query.billNo);
-        if (mesInvItemOuts == null) throw new Exception("閲囪喘閫�璐х敵璇峰崟涓嶅瓨鍦�");
+        var mesInvItemOuts = base.GetSingle(it => it.BillNo == query.billNo && it.Status == true);
+        if (mesInvItemOuts == null) throw new Exception("閲囪喘閫�璐х敵璇峰崟涓嶅瓨鍦ㄦ垨鏈鏍�");
 
         var sql = string.Format(@"SELECT c.item_no ItemNo,c.item_name ItemName,c.item_model ItemModel,A.SQ_NUM FQty,A.YS_NUM SQty,A.SQ_NUM - A.YS_NUM DSQty,
        dbo.F_QX_GETRECODEPOTSE(A.ITEM_ID,'','','') as RecoKw
@@ -34,6 +34,11 @@
 WHERE B.BILL_NO = '{0}'", query.billNo);
 
         var womdabs = Db.Ado.SqlQuery<ItemDetailModel>(sql);
+
+        if(womdabs.Count < 1)
+        {
+            throw new Exception("璇ラ噰璐��璐х敵璇峰崟鏄庣粏涓嶅瓨鍦�");
+        }
 
 
         var DS_list = womdabs.Where(s => s.DSQty > 0).ToList();
@@ -138,7 +143,73 @@
                         daa001 = query.daa001,
                         barcodeNum = barcodeNum,
                         splitNum = splitNum,
-                        barcode = query.barcode
+                        barcode = query.barcode,
+                        result = result.ToString()
+                    };
+
+                    return dto;
+                }
+                catch (Exception ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+                finally
+                {
+                    conn.Close();
+                }
+            }
+        }
+    }
+
+
+    public ProductionPickDto ScanCodeCF(WarehouseQuery query)
+    {
+        if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖");
+        if (query.daa001.IsNullOrEmpty()) throw new Exception("棰嗘枡鍗曞彿涓嶅厑璁镐负绌�");
+        if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
+
+        if (query.Num is null or 0) throw new Exception("鏉$爜鎷嗗垎鏁颁笉鍏佽涓虹┖鎴栬�呬负0");
+
+        var _strMsg = "";
+        var _intSum = "";
+        var _cfBar = "";//鎷嗗垎鍚庢潯鐮�
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            using (var cmd = new SqlCommand("[prc_pda_CGTH_CF]", conn))
+            {
+                try
+                {
+                    conn.Open();
+                    cmd.CommandType = CommandType.StoredProcedure;
+                    SqlParameter[] parameters =
+                    {
+                        new("@outMsg", SqlDbType.NVarChar, 2000),
+                        new("@outSum", SqlDbType.NVarChar, 300),
+                        new("@outCfBar", SqlDbType.NVarChar, 300),
+                        new("@c_User", query.userName),
+                        new("@p_biLL_no", query.daa001),
+                        new("@p_item_barcode", query.barcode),
+                        new("@num", query.Num)
+                    };
+                    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
+                    {
+                        daa001 = query.daa001,
+                        barcode = query.barcode,//鍘熸潯鐮�
+                        cfBarcode = _cfBar//鎷嗗垎鍚庢潯鐮�
                     };
 
                     return dto;

--
Gitblit v1.9.3