From 2950220f98f891a64cc452478e2a2ae61b82a8cd Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期日, 13 四月 2025 16:21:52 +0800
Subject: [PATCH] 优化代码、添加大屏

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/PalletCodeInfoService.cs |   76 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 74 insertions(+), 2 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/PalletCodeInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/PalletCodeInfoService.cs"
index 5b38556..9f98f67 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/PalletCodeInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/PalletCodeInfoService.cs"
@@ -1,10 +1,14 @@
 锘縰sing BarcodeStandard;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
 using SkiaSharp;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Drawing.Imaging;
+using System.Drawing.Printing;
 using System.Linq;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEA_Core;
@@ -42,6 +46,8 @@
                     Width = Width,
                     Height = Height,
                     Size = Size,
+                    Qty = 1,
+                    PrintFrequency = 2,
                 };
                 BaseDal.AddData(palletCodeInfo);
                 return WebResponseContent.Instance.OK();
@@ -51,7 +57,73 @@
                 return WebResponseContent.Instance.Error(ex.Message);
             }
         }
+        /// <summary>
+        /// 鎵撳嵃鏉$爜
+        /// </summary>
+        /// <param name="keys"></param>
+        /// <returns></returns>
+        public WebResponseContent PrintBarcodeLib(List<int> keys)
+        {
+            try
+            {
+                Dt_PalletCodeInfo palletCodeInfo = BaseDal.QueryFirst(x => keys.Contains(x.Id));
+                if (palletCodeInfo == null) throw new Exception("淇℃伅鏈夎");
+                #region 鐢熸垚鏉$爜
+                Barcode barcode = new Barcode();//鍒涘缓鏉″舰鐮佸璞�
+                barcode.IncludeLabel = true;//纭繚鍖呮嫭鏍囩
+                barcode.Alignment = AlignmentPositions.Center;//鏉″舰鐮佸榻愭柟寮�
+                barcode.LabelFont = new SKFont
+                {
+                    Typeface = SKTypeface.FromFamilyName("Arial", SKFontStyle.Normal),//瀛椾綋鏍峰紡
+                    Size = palletCodeInfo.Size,// 鏍囩瀛椾綋
+                };
+                barcode.EncodedType = BarcodeStandard.Type.Code128;
+                barcode.Width = palletCodeInfo.Width;
+                barcode.Height = palletCodeInfo.Height;
+                #endregion
+                for (int i = 1; i <= palletCodeInfo.Qty; i++)
+                {
+                    #region 鐢熸垚鏉″舰鐮佸浘鍍�
+                    var n = DateTime.Now.ToString("yy");
+                    var Barcode = n + palletCodeInfo.Code.ToString("000000");
+                    //var Barcode = palletCodeInfo.PalletCode + palletCodeInfo.Code.ToString("00000000");
+                    palletCodeInfo.Code++;
+                    SKImage bitmap = barcode.Encode(Barcode);
+                    #endregion
+                    for (int j = 1; j <= palletCodeInfo.PrintFrequency; j++)
+                    {
 
+                    }
+                }
+                return WebResponseContent.Instance.OK("鎵撳嵃鎴愬姛");
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+        public string newBarcodeLib(int key)
+        {
+            Dt_PalletCodeInfo palletCodeInfo = BaseDal.QueryFirst(x => key == x.Id);
+            Barcode barcode = new Barcode();//鍒涘缓鏉″舰鐮佸璞�
+            barcode.IncludeLabel = true;//纭繚鍖呮嫭鏍囩
+            barcode.Alignment = AlignmentPositions.Center;//鏉″舰鐮佸榻愭柟寮�
+            barcode.LabelFont = new SKFont
+            {
+                Typeface = SKTypeface.FromFamilyName("Arial", SKFontStyle.Bold),//瀛椾綋鏍峰紡
+                Size = palletCodeInfo.Size,// 鏍囩瀛椾綋
+            };
+            barcode.EncodedType = BarcodeStandard.Type.Code128;
+            barcode.Width = palletCodeInfo.Width;
+            barcode.Height = palletCodeInfo.Height;
+            var Barcode = DateTime.Now.ToString("yy") + palletCodeInfo.Code.ToString("000000");
+            palletCodeInfo.Code++;
+            BaseDal.UpdateData(palletCodeInfo);
+            SKImage bitmap = barcode.Encode(Barcode);
+            var a = barcode.EncodedImageBytes;
+
+            return Convert.ToBase64String(a, 0, (int)a.Length);
+        }
         public string newBarcodeLib(palletCodeInfoDTO palletCodeInfo)
         {
             #region 鐢熸垚鏉″舰鐮�
@@ -75,9 +147,9 @@
             //璁剧疆鏉″舰鐮佸昂瀵�
             barcode.Width = palletCodeInfo.Width;
             barcode.Height = palletCodeInfo.Height;
-
+            var Barcode = DateTime.Now.ToString("yy") + palletCodeInfo.Code.ToString("000000");
             //鐢熸垚鏉″舰鐮佸浘鍍�
-            SKImage bitmap = barcode.Encode(palletCodeInfo.PalletCode);
+            SKImage bitmap = barcode.Encode(Barcode);
             var a = barcode.EncodedImageBytes;
             var b = Convert.ToBase64String(a, 0, (int)a.Length);
             //淇濆瓨鏉″舰鐮佸浘鍍忓埌鏂囦欢锛堝彲閫夛級

--
Gitblit v1.9.3