From 3504aefa0e2995774b87f88c57df75197909b8cb Mon Sep 17 00:00:00 2001
From: "kang.luo" <986033787@qq.com>
Date: Wed, 10 Jan 2024 13:40:40 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BD=BD=E5=85=B7=E6=9D=A1=E7=A0=81=E6=89=93?=
=?UTF-8?q?=E5=8D=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Tnb.WarehouseMgr/BaseWareHouseService.cs | 134 +++++++++++++++++-
.../Tnb.WarehouseMgr/WmsCarryLedgerService.cs | 15 ++
2 files changed, 148 insertions(+), 1 deletion(-)
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs
index 71aef205..f2a989d5 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs
@@ -346,6 +346,138 @@ namespace Tnb.WarehouseMgr
}
+ ///
+ /// 载具条码打印
+ ///
+ /// 条码
+ /// 打印份数
+ ///
+ [NonAction]
+ protected void CarryPrint(List barCodes, int copies, string ip)
+ {
+ TaskCompletionSource tcs = new();
+ // open port.
+ try
+ {
+ int nLen, ret, sw;
+ byte[] pbuf = new byte[128];
+ string strmsg;
+
+ IntPtr ver;
+ System.Text.Encoding encAscII = System.Text.Encoding.ASCII;
+ System.Text.Encoding encUnicode = System.Text.Encoding.Unicode;
+
+ // dll version.
+ ver = PPLBUtility.B_Get_DLL_Version(0);
+ // search port.
+ nLen = PPLBUtility.B_GetUSBBufferLen() + 1;
+ strmsg = "DLL ";
+ strmsg += Marshal.PtrToStringAnsi(ver);
+ strmsg += "\r\n";
+ if (nLen > 1)
+ {
+ byte[] buf1, buf2;
+ int len1 = 128, len2 = 128;
+ buf1 = new byte[len1];
+ buf2 = new byte[len2];
+ _ = PPLBUtility.B_EnumUSB(pbuf);
+ _ = PPLBUtility.B_GetUSBDeviceInfo(1, buf1, out len1, buf2, out len2);
+ sw = 1;
+ if (1 == sw)
+ {
+ ret = PPLBUtility.B_CreatePrn(12, encAscII.GetString(buf2, 0, len2));// open usb.
+ }
+ else
+ {
+ ret = PPLBUtility.B_CreateUSBPort(1);// must call B_GetUSBBufferLen() function fisrt.
+ }
+ if (0 != ret)
+ {
+ strmsg += "Open USB fail!";
+ }
+ else
+ {
+ strmsg += "Open USB:\r\nDevice name: ";
+ strmsg += encAscII.GetString(buf1, 0, len1);
+ strmsg += "\r\nDevice path: ";
+ strmsg += encAscII.GetString(buf2, 0, len2);
+ //sw = 2;
+ if (2 == sw)
+ {
+ //Immediate Error Report.
+ _ = PPLBUtility.B_WriteData(1, encAscII.GetBytes("^ee\r\n"), 5);//^ee
+ ret = PPLBUtility.B_ReadData(pbuf, 4, 1000);
+ }
+ }
+ }
+ else
+ {
+ ret = PPLBUtility.B_CreatePrn(13, ip);
+ }
+ /* else
+ {
+
+ _ = System.IO.Directory.CreateDirectory(PPLBUtility.szSavePath);
+ ret = PPLBUtility.B_CreatePrn(0, PPLBUtility.szSaveFile);// open file.
+ strmsg += "Open ";
+ strmsg += PPLBUtility.szSaveFile;
+ if (0 != ret)
+ {
+ strmsg += " file fail!";
+ }
+ else
+ {
+ strmsg += " file succeed!";
+ }
+ }*/
+ if (0 != ret)
+ {
+ return;
+ }
+ // sample setting.
+ _ = PPLBUtility.B_Set_Originpoint(0, 0);
+ _ = PPLBUtility.B_Select_Option(2);
+ _ = PPLBUtility.B_Set_Darkness(8);
+ _ = PPLBUtility.B_Del_Pcx("*");// delete all picture.
+ //PPLBUtility.B_Set_LabelForSmartPrint(254 * 3, 30);//label information: length= 3 * 25.4 mm, gap= 3 mm. 254 * 3, 30
+ _ = PPLBUtility.B_Set_Labwidth(80 * 8);
+ //var labelWidth = 640; //254 * 3; // 标签宽度
+ //var barcodeWidth = 320; // 条码宽度
+ //var barcodeX = (labelWidth - barcodeWidth) / 2;
+ //B_Prn_Barcode(barcodeX, 100, 0, "QRcode", 1, 0, 2, 2, "YourBarcodeData"); 8
+
+
+
+ foreach (string code in barCodes)
+ {
+ for (int i = 0; i < copies; i++)
+ {
+ // _ = PPLBUtility.B_Prn_Text(50, 90, 0, 2, 2, 2, 'N', code);
+ // _ = PPLBUtility.B_Prn_Barcode(50, 270, 0, "1", 3, 5, 70, 'N', code);
+ //_ = PPLBUtility.B_Prn_Text(50, 100, 0, 2, 2, 2, 'N', code);
+ //_ = PPLBUtility.B_Prn_Barcode(50, 150, 0, "1", 3, 5, 100, 'N', code);
+ _ = PPLBUtility.B_Prn_Text(50, 100, 0, 2, 2, 2, 'N', code);
+ _ = PPLBUtility.B_Prn_Barcode(50, 150, 0, "1", 3, 5, 90, 'N', code);
+ //_ = PPLBUtility.B_Prn_Text(50, 305, 0, 2, 2, 2, 'N', code);
+
+ _ = PPLBUtility.B_Print_Out(1);
+
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ tcs.SetException(ex);
+ throw ex;
+ Logger.Error("条码打印时出现错误", ex);
+ }
+ finally
+ {
+ // close port.
+ PPLBUtility.B_ClosePrn();
+ }
+ }
+
#region 斑马打印
///
/// 打印
@@ -393,7 +525,7 @@ namespace Tnb.WarehouseMgr
// tcs.SetResult(printerList);
// return tcs.Task;
//}
- #endregion
+ #endregion
///
/// Api响应结果
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs
index b15eee4f..e8afb39c 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs
@@ -5,9 +5,11 @@ using JNPF.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDev;
using JNPF.VisualDev.Interfaces;
using Mapster;
+using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
@@ -111,6 +113,19 @@ namespace Tnb.WarehouseMgr
}
return row > 0;
}
+
+ ///
+ /// 载具条码打印
+ ///
+ ///
+ ///
+ [HttpPost]
+ public void CarryBarCodePrint(CarryBarCodeInput input)
+ {
+ if (input == null || input.barCodes.Count < 1) throw new ArgumentNullException(nameof(input));
+ var ip = _db.Queryable().Where(p => p.key == "carrybarcodeprinterip").FirstAsync().Result.value;
+ base.CarryPrint(input.barCodes, input.copies, ip);
+ }
}
}