From 64e2f748cd194ec9e6e8f6e6ce1ca27374c3f686 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期四, 08 五月 2025 08:30:57 +0800
Subject: [PATCH] 1.PDA拆分领料打印条码

---
 service/base/MesPrintMangeer.cs        |   80 ++++++++++++++++++++++++++
 Controllers/Wom/WomdaaController.cs    |    7 ++
 Controllers/base/MesPrintController.cs |   72 ++++++++++++++++++++++++
 3 files changed, 158 insertions(+), 1 deletions(-)

diff --git a/Controllers/Wom/WomdaaController.cs b/Controllers/Wom/WomdaaController.cs
index fa38828..133ab40 100644
--- a/Controllers/Wom/WomdaaController.cs
+++ b/Controllers/Wom/WomdaaController.cs
@@ -2,6 +2,7 @@
 using Microsoft.AspNetCore.Mvc;
 using NewPdaSqlServer.Dto.service;
 using NewPdaSqlServer.entity;
+using NewPdaSqlServer.service.@base;
 using NewPdaSqlServer.service.Wom;
 using NewPdaSqlServer.util;
 
@@ -12,6 +13,7 @@
 public class WomdaaController : ControllerBase
 {
     private readonly WomdaaManager m = new();
+    private readonly MesPrintMangeer _mCf = new();
 
     #region 鐢熶骇棰嗘枡
 
@@ -102,7 +104,10 @@
         try
         {
             dynamic resultInfos = new ExpandoObject();
-            resultInfos.tbBillList = m.ScanCodeCF(query);
+            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/Controllers/base/MesPrintController.cs b/Controllers/base/MesPrintController.cs
new file mode 100644
index 0000000..224e620
--- /dev/null
+++ b/Controllers/base/MesPrintController.cs
@@ -0,0 +1,72 @@
+锘縰sing System.Dynamic;
+using Microsoft.AspNetCore.Mvc;
+using NewPdaSqlServer.Dto.service;
+using NewPdaSqlServer.entity;
+using NewPdaSqlServer.service.@base;
+using NewPdaSqlServer.service.Wom;
+using NewPdaSqlServer.util;
+
+namespace NewPdaSqlServer.Controllers.@base;
+
+/// <summary>
+///     鐢熶骇鎶ュ伐鐩稿叧鎺ュ彛
+/// </summary>
+[Route("api/[controller]")]
+[ApiController]
+public class MesPrintController : ControllerBase
+{
+    private readonly MesPrintMangeer _manager = new();
+
+    /// <summary>
+    ///     鎵弿娉ㄥ鐮侊紝鑾峰彇宸ュ崟鍜屾潯鐮佷俊鎭�
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("getPrintInfo")]
+    public ResponseResult getPrintInfo([FromBody] dynamic query)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            // 鍏堝垵濮嬪寲tbBillList灞炴��
+            resultInfos.tbBillList = new ExpandoObject();
+            resultInfos.tbBillList = _manager.getPrintInfo(query);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    ///     鎵弿娉ㄥ鐮侊紝鑾峰彇宸ュ崟鍜屾潯鐮佷俊鎭�
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("getCfInfo")]
+    public ResponseResult getCfInfo([FromBody] dynamic query)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            // 鍏堝垵濮嬪寲tbBillList灞炴��
+            resultInfos.tbBillList = new ExpandoObject();
+            resultInfos.tbBillList = _manager.getCfInfo(query);
+            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/service/base/MesPrintMangeer.cs b/service/base/MesPrintMangeer.cs
new file mode 100644
index 0000000..dc68505
--- /dev/null
+++ b/service/base/MesPrintMangeer.cs
@@ -0,0 +1,80 @@
+锘縩amespace NewPdaSqlServer.service.@base
+{
+    using NewPdaSqlServer.Dto.service;
+    using NewPdaSqlServer.entity;
+    using SqlSugar;
+    using System;
+    using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
+    using System.Data;
+    using NewPdaSqlServer.DB;
+    using System.Data;
+    using System.Data.SqlClient;
+    using Microsoft.EntityFrameworkCore.Metadata.Internal;
+
+
+    public class MesPrintMangeer : Repository<dynamic>
+    {
+        public dynamic getPrintInfo(dynamic query)
+        {
+
+            // 浣跨敤鍙傛暟鍖栨煡璇㈤槻姝QL娉ㄥ叆
+            var sqlParams = new List<SugarParameter> { new("@userAccount", query.userName) };
+
+            var sql1 = @"SELECT TOP 1 ip,port fROM print_info A
+         left join SYS_USER_BIND B on A.guid = B.aboutGuid
+         left join SYS_USER C ON C.GUID = B.userGuid
+WHERE C.ACCOUNT = @userAccount AND B.fType = '鎵撳嵃鏈�'";
+
+            var printInfo = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams);
+
+            if (printInfo.Count < 1 ) throw new Exception("褰撳墠鐢ㄦ埛鏈粦瀹氭墦鍗版満锛岃缁存姢鍚庝娇鐢ㄦ媶鍒嗗姛鑳斤紒");
+
+            return printInfo;
+        }
+
+
+        public dynamic getCfInfo(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,A.ITEM_BARCODE,GETDATE() as print_date
+            FROM MES_INV_ITEM_STOCKS A
+            LEFT JOIN MES_INV_ITEM_BARCODES B ON A.ITEM_BARCODE = B.ITEM_BARCODE
+            LEFT JOIN MES_ITEMS C ON C.item_id = B.ITEM_ID
+            WHERE A.ITEM_BARCODE = @cfBar
+            
+            UNION ALL
+            
+            SELECT TOP 1 C.ITEM_NO,C.item_name,C.item_model,A.QUANTITY as QUANTITY,B.CREATE_DATE, '鍘熷鏉$爜' AS BarType,A.ITEM_BARCODE,GETDATE() as print_date
+            FROM MES_INV_ITEM_STOCKS A
+            LEFT JOIN MES_INV_ITEM_BARCODES B ON A.ITEM_BARCODE = B.ITEM_BARCODE
+            LEFT JOIN MES_ITEMS C ON C.item_id = B.ITEM_ID
+            WHERE A.ITEM_BARCODE = @oldBar";
+
+            var mergedData = Db.Ado.SqlQuery<dynamic>(sql, sqlParams);
+
+            if (mergedData.Count < 2) throw new Exception("鏉$爜淇℃伅瀛樺湪寮傚父锛岃鑱旂郴绠$悊鍛橈紒");
+
+            return mergedData;
+        }
+
+        // // 鐜板満鏀舵枡灞曠ず鍒楄〃
+        // public class PrintBarInfo
+        // {
+        //     public List<dynamic> cfBarInfo { get; set; }
+        //     public List<dynamic> oldBarInfo { get; set; }
+        // }
+
+
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3