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 +++++++++++++++++++++++++++++++++++++-
 Controllers/Warehouse/MesCgthSqController.cs     |   34 +++++++++++++++++
 service/Warehouse/MesInvItemInCDetailsManager.cs |    3 +
 3 files changed, 110 insertions(+), 4 deletions(-)

diff --git a/Controllers/Warehouse/MesCgthSqController.cs b/Controllers/Warehouse/MesCgthSqController.cs
index 5f38f1d..f8f491d 100644
--- a/Controllers/Warehouse/MesCgthSqController.cs
+++ b/Controllers/Warehouse/MesCgthSqController.cs
@@ -2,6 +2,7 @@
 using Microsoft.AspNetCore.Mvc;
 using NewPdaSqlServer.Dto.service;
 using NewPdaSqlServer.entity;
+using NewPdaSqlServer.service.@base;
 using NewPdaSqlServer.service.Warehouse;
 using NewPdaSqlServer.util;
 
@@ -12,6 +13,7 @@
 public class MesCgthSqController : ControllerBase
 {
     private readonly MesCgthSqManager m = new();
+    private readonly MesPrintMangeer _mCf = new();
 
 
     /// <summary>
@@ -74,6 +76,38 @@
         {
             dynamic resultInfos = new ExpandoObject();
             resultInfos.tbBillList = m.ScanCode(query);
+            if (resultInfos.tbBillList.result == "2")
+            {
+                return new ResponseResult
+                {
+                    status = Convert.ToInt32(resultInfos.tbBillList.result),
+                    message = resultInfos.tbBillList.strMsg,
+                    data = resultInfos
+                };
+            }
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    [HttpPost("ScanCodeCF")]
+    public ResponseResult ScanCodeCF(WarehouseQuery query)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = new ExpandoObject();
+            resultInfos.tbBillList.printInfo = _mCf.getPrintInfo(query);
+            var scanResult = m.ScanCodeCF(query);
+            resultInfos.tbBillList.cfBarInfo = _mCf.getCfInfo(scanResult);
             return new ResponseResult
             {
                 status = 0,
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;
diff --git a/service/Warehouse/MesInvItemInCDetailsManager.cs b/service/Warehouse/MesInvItemInCDetailsManager.cs
index 198f4e4..9c0a051 100644
--- a/service/Warehouse/MesInvItemInCDetailsManager.cs
+++ b/service/Warehouse/MesInvItemInCDetailsManager.cs
@@ -789,7 +789,8 @@
                         FQty = a.Quantity, // 鐢宠鏁伴噺
                         FMaterialId = b.ItemId,
                         Id = a.Guid.ToString(),
-                        kw = a.DepotSectionCode
+                        kw = a.DepotSectionCode,
+                        barcode = a.ItemBarcode
                     })
                     .ToList();
 

--
Gitblit v1.9.3