From f5505856eb4cb12e29879a8a41b7a3470f0f2c79 Mon Sep 17 00:00:00 2001 From: "506583276@qq.com" <506583276@qq.com> Date: Tue, 4 Jul 2023 20:28:27 +0800 Subject: [PATCH] 1 --- .../APIServices/QiKu/PackTaskService.cs | 5 +- .../APIServices/QiKu/SealBoxService.cs | 23 +- BBWY.Client/BBWY.Client.csproj | 12 + BBWY.Client/Helpers/MyPrintHelper.cs | 38 +- BBWY.Client/Models/Enums.cs | 11 + BBWY.Client/Models/FallWare/JDWareBoxModel.cs | 5 + .../PackTask/PackServiceViewModel.cs | 7 - .../ViewModels/PackTask/TaskListViewModel.cs | 2 +- .../PackTask/WareHouseListViewModel.cs | 79 ++- .../Views/FallWare/PrintBoxWindow.xaml | 62 ++ .../Views/FallWare/PrintBoxWindow.xaml.cs | 120 ++++ .../Views/FallWare/SetCloudWareBoxWindow.xaml | 54 +- .../FallWare/SetCloudWareBoxWindow.xaml.cs | 76 +- .../Views/FallWare/SetJDWareBoxWindow.xaml | 144 ++-- .../Views/FallWare/SetJDWareBoxWindow.xaml.cs | 92 ++- .../Views/FallWare/WaitFallWareControl.xaml | 3 +- .../FallWare/WareFallWareListControl.xaml | 84 ++- .../FallWare/WareFallWareListControl.xaml.cs | 105 ++- BBWY.Client/Views/PackTask/TaskList.xaml | 81 +-- .../Views/PackTask/TaskListControl.xaml | 5 - .../Views/PackTask/WaitCompletedControl.xaml | 376 +++++----- .../PackTask/WaitCompletedControl.xaml.cs | 101 ++- .../Views/PackTask/WaitPackageControl.xaml | 655 ++++++++++-------- .../Views/PackTask/WaitPackageControl.xaml.cs | 195 +++++- BBWY.Client/Views/PackTask/WareHouseList.xaml | 78 +-- .../Views/PackTask/WareHouseList.xaml.cs | 231 ------ .../Views/PackTask/WareHouseListControl.xaml | 604 ++++++++-------- .../PackTask/WareHouseListControl.xaml.cs | 193 +++++- .../Views/QualityTask/WaitQualityControl.xaml | 615 ++++++++-------- .../QualityTask/WaitQualityControl.xaml.cs | 195 +++++- .../TaskOverTime/WareTaskOverTimeControl.xaml | 39 +- 31 files changed, 2704 insertions(+), 1586 deletions(-) create mode 100644 BBWY.Client/Views/FallWare/PrintBoxWindow.xaml create mode 100644 BBWY.Client/Views/FallWare/PrintBoxWindow.xaml.cs diff --git a/BBWY.Client/APIServices/QiKu/PackTaskService.cs b/BBWY.Client/APIServices/QiKu/PackTaskService.cs index f6133700..4a4fedb1 100644 --- a/BBWY.Client/APIServices/QiKu/PackTaskService.cs +++ b/BBWY.Client/APIServices/QiKu/PackTaskService.cs @@ -293,7 +293,7 @@ namespace BBWY.Client.APIServices /// /// /// - public ApiResponse SearchOverTimeTaskList(string ShopId, DateTime? StartTime, DateTime? EndTime, OverTimeTaskType? OverTimeTaskType, int? PageIndex, int? PageSize=20) + public ApiResponse SearchOverTimeTaskList(string ShopId, DateTime? StartTime, DateTime? EndTime,OverTimeTaskState overTimeTaskState, OverTimeTaskType? OverTimeTaskType, int? PageIndex, int? PageSize=20) { return SendRequest(globalContext.QKApiHost, $"api/PackTask/SearchOverTimeTaskList", new { ShopId, @@ -301,7 +301,8 @@ namespace BBWY.Client.APIServices EndTime, OverTimeTaskType, PageIndex, - PageSize + PageSize, + overTimeTaskState }, null, HttpMethod.Post); } diff --git a/BBWY.Client/APIServices/QiKu/SealBoxService.cs b/BBWY.Client/APIServices/QiKu/SealBoxService.cs index 8febd8d2..c66b54c0 100644 --- a/BBWY.Client/APIServices/QiKu/SealBoxService.cs +++ b/BBWY.Client/APIServices/QiKu/SealBoxService.cs @@ -88,7 +88,7 @@ namespace BBWY.Client.APIServices , null, HttpMethod.Post); } - public ApiResponse GetWareSealBoxList(string ShopName, long? TaskId, string SkuId, int? PageIndex, int? PageSize) + public ApiResponse GetWareSealBoxList(string ShopName, long? TaskId, string SkuId,long? SealBoxId, int? PageIndex, int? PageSize) { return SendRequest(globalContext.QKApiHost, $"api/SealBox/GetWareSealBoxList", new @@ -97,7 +97,8 @@ namespace BBWY.Client.APIServices TaskId, SkuId, PageIndex, - PageSize + PageSize, + SealBoxId } , null, HttpMethod.Post); } @@ -124,7 +125,7 @@ namespace BBWY.Client.APIServices /// /// /// - public ApiResponse SearchWareFallWareConfigureList(PositionState positionState, string ShopName = null, long? TaskId = null, string SkuId = null, int PageIndex = 1 + public ApiResponse SearchWareFallWareConfigureList(PositionState positionState, string ShopName = null, long? TaskId = null, string SkuId = null,long?sealBoxId=null, int PageIndex = 1 , int PageSize = 10) { return SendRequest(globalContext.QKApiHost, $"api/SealBox/SearchWareFallWareConfigureList", @@ -135,7 +136,8 @@ namespace BBWY.Client.APIServices SkuId, PageIndex, PageSize, - positionState + positionState, + sealBoxId } , null, HttpMethod.Post); } @@ -169,7 +171,7 @@ namespace BBWY.Client.APIServices - public ApiResponse SetFallWareConfigure(long SealBoxId, string ProductTitle, string PurchaseOrder, string PrewOrder, string WaybillNo, string providerName = "", string wareName = "") + public ApiResponse SetFallWareConfigure(long SealBoxId, string ProductTitle, string PurchaseOrder, string PrewOrder, string WaybillNo, string providerName = "", string wareName = "",string WareCity="") { return SendRequest(globalContext.QKApiHost, $"api/SealBox/SetFallWareConfigure", new @@ -180,7 +182,8 @@ namespace BBWY.Client.APIServices PrewOrder, WaybillNo, providerName, - wareName + wareName, + WareCity } , null, HttpMethod.Post); } @@ -264,13 +267,17 @@ namespace BBWY.Client.APIServices null, null, HttpMethod.Post); } - public ApiResponse GetWareWaitCompletedList(string shopId, int? PageIndex, int? PageSize) + public ApiResponse GetWareWaitCompletedList(string shopId, string ShopName , long? TaskId , string SkuId , long? sealBoxId , int? PageIndex, int? PageSize) { return SendRequest(globalContext.QKApiHost, $"api/SealBox/GetWareWaitCompletedList", new { shopId, PageIndex, - PageSize + PageSize, + ShopName, + TaskId, + SkuId, + sealBoxId }, null, HttpMethod.Post); } diff --git a/BBWY.Client/BBWY.Client.csproj b/BBWY.Client/BBWY.Client.csproj index 2643c69f..36e0e5dc 100644 --- a/BBWY.Client/BBWY.Client.csproj +++ b/BBWY.Client/BBWY.Client.csproj @@ -84,6 +84,18 @@ + + + + + + + + + + + + diff --git a/BBWY.Client/Helpers/MyPrintHelper.cs b/BBWY.Client/Helpers/MyPrintHelper.cs index d9fbd559..bac14d65 100644 --- a/BBWY.Client/Helpers/MyPrintHelper.cs +++ b/BBWY.Client/Helpers/MyPrintHelper.cs @@ -52,10 +52,7 @@ namespace BBWY.Client.Helpers default: break; } - } - - private static void SetBar(BarCodeModel barCode, ref PrintPageEventArgs args, Font font, int heightSpace) { @@ -106,10 +103,6 @@ namespace BBWY.Client.Helpers topHeigth += (50 + 5); args.Graphics.DrawString(barcodeSku, font, System.Drawing.Brushes.Black, new PointF((236 - size.Width) / 2, topHeigth)); } - - - - /// /// 标准 /// @@ -159,7 +152,6 @@ namespace BBWY.Client.Helpers args.Graphics.DrawString(barcodeSku, font, System.Drawing.Brushes.Black, new PointF((236 - size.Width) / 2, 130)); args.Graphics.DrawImage(img, 1, 68, 234, 60); } - public static void PrintCertificate(ref PrintPageEventArgs args, CertificateModel certificate, Font font) { @@ -194,7 +186,6 @@ namespace BBWY.Client.Helpers } - private static void SetCerStander(ref PrintPageEventArgs args, CertificateModel certificate, Font font) { @@ -579,7 +570,6 @@ namespace BBWY.Client.Helpers } - public static void SaveImage(PrintPageEventArgs args) { args.Graphics.Save(); @@ -593,9 +583,13 @@ namespace BBWY.Client.Helpers } - - - + /// + /// 字符串生成条形码 图片 + /// + /// + /// + /// + /// public static BitmapImage GetBarcodeImage(string printStr, int width, int height) { Bitmap image = new Bitmap(width, height); @@ -606,6 +600,24 @@ namespace BBWY.Client.Helpers return bitmapToBitmapImage(image); } + /// + /// 字符串生成条形码 图片 + /// + /// + /// + /// + /// + public static BitmapImage GetBarcodeImageV2(string printStr, int width, int height) + { + Bitmap image = new Bitmap(width, height); + Graphics graphics2 = Graphics.FromImage(image); + Barcode barcode = new Barcode(); + System.Drawing.Image img = barcode.Encode(TYPE.CODE128, printStr, width, height); + graphics2.DrawImage(img, 0, 0, width, height); + return bitmapToBitmapImage(image); + } + + static BitmapImage bitmapToBitmapImage(Bitmap bitmap) { using (var stream = new MemoryStream()) diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs index 9f5f5dbc..f74b9bc1 100644 --- a/BBWY.Client/Models/Enums.cs +++ b/BBWY.Client/Models/Enums.cs @@ -538,6 +538,17 @@ 待落仓 = 8, 待转运 = 11, } + + /// + /// 超时任务状态 + /// + public enum OverTimeTaskState + { + 未完成 = 0, + 已完成 = 1, + 全部=2 + + } public enum TaskMessageType { 任务ID = 0, diff --git a/BBWY.Client/Models/FallWare/JDWareBoxModel.cs b/BBWY.Client/Models/FallWare/JDWareBoxModel.cs index c3483d75..2f51f68d 100644 --- a/BBWY.Client/Models/FallWare/JDWareBoxModel.cs +++ b/BBWY.Client/Models/FallWare/JDWareBoxModel.cs @@ -58,5 +58,10 @@ namespace BBWY.Client.Models.FallWare /// 供应商 /// public string ProviderName { get; set; } + + /// + /// 仓库城市 + /// + public string WareCity { get; set; } } } diff --git a/BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs b/BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs index bc724769..d8512662 100644 --- a/BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/PackServiceViewModel.cs @@ -60,13 +60,6 @@ namespace BBWY.Client.ViewModels.PackTask public int IncrementPartTaskCount { get => incrementPartTaskCount; set { Set(ref incrementPartTaskCount, value); } } - - //public ObservableCollection incrementPartCountList = new ObservableCollection() { - //"0","1","2","3","4件以上" - //}; - - //public ObservableCollection IncrementPartCountList { get => incrementPartCountList; set { Set(ref incrementPartCountList, value); } } - private int incrementPartCount; /// /// 配件数量 diff --git a/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs b/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs index 96b1d83c..ac7e5f88 100644 --- a/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/TaskListViewModel.cs @@ -942,7 +942,7 @@ namespace BBWY.Client.ViewModels.PackTask Task.Factory.StartNew(() => { WaitCompletedList = new ObservableCollection(); - var datas = sealBoxService.GetWareWaitCompletedList(globalContext.User.Shop.ShopId.ToString(), PageIndex, PageSize); + var datas = sealBoxService.GetWareWaitCompletedList(globalContext.User.Shop.ShopId.ToString(), null, taskId, SearchSkuId, null, PageIndex, PageSize); if (datas != null && datas.Data != null && datas.Success) { var dataModel = datas.Data; diff --git a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs index 6e657193..06b1adba 100644 --- a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs @@ -64,11 +64,27 @@ namespace BBWY.Client.ViewModels.PackTask /// public ObservableCollection OverTimeTaskTypeList { get => overTimeTaskTypeList; set { Set(ref overTimeTaskTypeList, value); } } - private OverTimeTaskType overTimeTaskState = OverTimeTaskType.全部; + private ObservableCollection overTimeTaskStateList = new ObservableCollection { + Models.OverTimeTaskState.未完成 , Models.OverTimeTaskState.已完成, OverTimeTaskState.全部 + }; + /// + ///超时任务类型 + /// + public ObservableCollection OverTimeTaskStateList { get => overTimeTaskStateList; set { Set(ref overTimeTaskStateList, value); } } + + + + private OverTimeTaskType overTimeTaskType = OverTimeTaskType.全部; /// /// 任务类型(超时) /// - public OverTimeTaskType OverTimeTaskState { get => overTimeTaskState; set { Set(ref overTimeTaskState, value); } } + public OverTimeTaskType OverTimeTaskType { get => overTimeTaskType; set { Set(ref overTimeTaskType, value); } } + + private OverTimeTaskState overTimeTaskState = OverTimeTaskState.全部; + /// + /// 任务类型(超时) + /// + public OverTimeTaskState OverTimeTaskState { get => overTimeTaskState; set { Set(ref overTimeTaskState, value); } } @@ -171,6 +187,18 @@ namespace BBWY.Client.ViewModels.PackTask } } + /// + /// 查询任务id + /// + private string searchSealBoxId; + public string SearchSealBoxId + { + get => searchSealBoxId; set + { + Set(ref searchSealBoxId, value); + } + } + /// /// 查询Sku /// @@ -496,16 +524,14 @@ namespace BBWY.Client.ViewModels.PackTask PrewOrder = fallware.BoxConfigureData.PrewOrder, ProductTitle = fallware.BoxConfigureData.ProductTitle, PurchaseOrder = fallware.BoxConfigureData.PurchaseOrder, - WaybillNo = fallware.BoxConfigureData.WaybillNo + WaybillNo = fallware.BoxConfigureData.WaybillNo, + ProviderName = fallware.BoxConfigureData.ProviderName }; - if (fallware.WareType == WareType.京仓) - { + + PrintBoxWindow printBox = new PrintBoxWindow(model, fallware.WareType); + printBox.ShowDialog(); //加载模板数据 - } - if (fallware.WareType == WareType.云仓) - { - - } + //打印 } @@ -527,14 +553,14 @@ namespace BBWY.Client.ViewModels.PackTask }; if (fallware.WareType == WareType.京仓) { - SetJDWareBoxWindow window = new SetJDWareBoxWindow(model, sealBoxService, fallware.WareType, ReflashTask, false); + SetJDWareBoxWindow window = new SetJDWareBoxWindow(model); window.Show(); //var w = new SetJDWareBoxWindow2(model, sealBoxService, fallware.WareType, ReflashTask, false); //w.ShowDialog(); } if (fallware.WareType == WareType.云仓 || fallware.WareType == WareType.聚水潭齐越仓) { - SetCloudWareBoxWindow window = new SetCloudWareBoxWindow(model, sealBoxService, fallware.WareType, ReflashTask, false); + SetCloudWareBoxWindow window = new SetCloudWareBoxWindow(model, fallware.WareType); window.Show(); } @@ -714,12 +740,26 @@ namespace BBWY.Client.ViewModels.PackTask case Models.TaskState.未到货: case Models.TaskState.部分到货: + + if (!model.OrderId.IsNullOrEmpty()) + { + if (model.ExpressOrderList==null||model.ExpressOrderList.Count<=0) + { + System.Windows.MessageBox.Show("该任务采购单未进行发货,请联系业务进行发货后在确认收货", "提示"); + return; + } + } if (System.Windows.MessageBox.Show("是否确认收货?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes) return; res = packTaskService.SetPackTaskState(taskId, Models.TaskState.待验收); + if (res != null && res.Success) + { + + //todo:手动发货上传B端数据 + } break; case Models.TaskState.待验收: break; @@ -782,10 +822,17 @@ namespace BBWY.Client.ViewModels.PackTask PageSize = 10; IsStartThread = false; long? taskId = null; + long? sealBoxId = null; try { if (SearchTaskId != null && !string.IsNullOrEmpty(SearchTaskId.Trim())) taskId = Convert.ToInt64(SearchTaskId); + + var istrue = long.TryParse(SearchSealBoxId, out long sealboxid); + if (istrue) + { + sealBoxId = sealboxid; + } } catch { @@ -800,7 +847,7 @@ namespace BBWY.Client.ViewModels.PackTask Task.Factory.StartNew(() => { WaitCompletedList = new ObservableCollection(); - var datas = sealBoxService.GetWareWaitCompletedList(null, PageIndex, PageSize); + var datas = sealBoxService.GetWareWaitCompletedList(null, SearchShopName, taskId, SearchSkuId, sealBoxId, PageIndex, PageSize); if (datas != null && datas.Data != null && datas.Success) { var dataModel = datas.Data; @@ -828,7 +875,7 @@ namespace BBWY.Client.ViewModels.PackTask Task.Factory.StartNew(() => { OverTimeTaskList = new ObservableCollection(); - var datas = packTaskService.SearchOverTimeTaskList(null, StartTime, EndTime, OverTimeTaskState, PageIndex, PageSize); + var datas = packTaskService.SearchOverTimeTaskList(null, StartTime, EndTime, OverTimeTaskState,OverTimeTaskType, PageIndex, PageSize); if (datas != null && datas.Data != null && datas.Success) { var dataModel = datas.Data; @@ -923,7 +970,7 @@ namespace BBWY.Client.ViewModels.PackTask WaitFallWareList = new ObservableCollection(); - var datas = sealBoxService.SearchWareFallWareConfigureList(PositionState, SearchShopName, taskId, SearchSkuId, PageIndex, PageSize); + var datas = sealBoxService.SearchWareFallWareConfigureList(PositionState, SearchShopName, taskId, SearchSkuId,sealBoxId, PageIndex, PageSize); if (datas != null && datas.Data != null && datas.Success) { var dataModel = datas.Data; @@ -1014,7 +1061,7 @@ namespace BBWY.Client.ViewModels.PackTask { WaitSealBoxModels = new ObservableCollection(); - var datas = sealBoxService.GetWareSealBoxList(SearchShopName, taskId, SearchSkuId, PageIndex, PageSize); + var datas = sealBoxService.GetWareSealBoxList(SearchShopName, taskId, SearchSkuId, sealBoxId, PageIndex, PageSize); if (datas != null && datas.Data != null && datas.Success) { var dataModel = datas.Data; diff --git a/BBWY.Client/Views/FallWare/PrintBoxWindow.xaml b/BBWY.Client/Views/FallWare/PrintBoxWindow.xaml new file mode 100644 index 00000000..0dbcf4ce --- /dev/null +++ b/BBWY.Client/Views/FallWare/PrintBoxWindow.xaml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/FallWare/PrintBoxWindow.xaml.cs b/BBWY.Client/Views/FallWare/PrintBoxWindow.xaml.cs new file mode 100644 index 00000000..9d55e9a1 --- /dev/null +++ b/BBWY.Client/Views/FallWare/PrintBoxWindow.xaml.cs @@ -0,0 +1,120 @@ +using BBWY.Client.APIServices; +using BBWY.Client.Models; +using BBWY.Client.Models.FallWare; +using BBWY.Controls; +using NPOI.Util; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing.Printing; +using System.IO; +using System.Reflection; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace BBWY.Client.Views.FallWare +{ + /// + /// PrintBoxWindow.xaml 的交互逻辑 + /// + public partial class PrintBoxWindow : BWindow + { + public PrintBoxWindow(JDWareBoxModel model, WareType WareType) + { + JDWareBoxModel =model ; this.WareType = WareType; + InitializeComponent(); + this.DataContext = this; + InitPrintList(); + } + public void InitPrintList() + { + //TaskImage = MyPrintHelper.GetBarcodeImage(TaskId.ToString(), 300, 60); + + //BarcodeImage = MyPrintHelper.GetBarcodeImage(SkuId, 300, 60); + + + PrintList = new ObservableCollection(); + var printingNames = PrinterSettings.InstalledPrinters;//获取本机的打印机数据 + int index = -1; + int selectIndex = 0; + foreach (string name in printingNames) + { + if (name == "Microsoft XPS Document Writer" || name == "Microsoft Print to PDF" || name == "Fax") + { + continue; + } + index++; + if (name.Contains("Deli")) + { + selectIndex = index; + } + PrintList.Add(name); + } + try + { + var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string printNames = System.IO.Path.Combine(applicationPath, "printName.init"); + if (File.Exists(printNames)) + { + PrintName = File.ReadAllText(printNames); + } + else + { + if (PrintList.Count > 0) + { + PrintName = PrintList[0].ToString(); + } + } + } + catch (Exception) + { + + + } + + } + + public string PrintName { get; set; } + public int PrintCount { get; set; } = 1; + + + + public JDWareBoxModel JDWareBoxModel { get; set; } + + /// + /// 箱唛类型 + /// + public WareType WareType { get; set; } + /// + /// 打印机列表 + /// + public ObservableCollection PrintList { get; set; } + + private void BButton_Click(object sender, RoutedEventArgs e) + { + if (WareType== WareType.京仓) + { + SetJDWareBoxWindow jdWindow = new SetJDWareBoxWindow(JDWareBoxModel); + jdWindow.Show(); + //jdWindow.WindowState = WindowState.Maximized; + jdWindow.PrintBox(PrintName); + } + + if (WareType== WareType.云仓|| WareType== WareType.聚水潭齐越仓) + { + SetCloudWareBoxWindow cloudWareWindow = new SetCloudWareBoxWindow(JDWareBoxModel, WareType); + cloudWareWindow.Visibility = Visibility.Hidden; + cloudWareWindow.Show(); + + cloudWareWindow.PrintBox(PrintName); + } + } + } +} diff --git a/BBWY.Client/Views/FallWare/SetCloudWareBoxWindow.xaml b/BBWY.Client/Views/FallWare/SetCloudWareBoxWindow.xaml index edd95a9e..f695c01b 100644 --- a/BBWY.Client/Views/FallWare/SetCloudWareBoxWindow.xaml +++ b/BBWY.Client/Views/FallWare/SetCloudWareBoxWindow.xaml @@ -16,7 +16,7 @@ CloseButtonColor="{StaticResource WindowButtonColor}" MinButtonVisibility="Collapsed" MaxButtonVisibility="Collapsed" - Width="450" Height="330" + Width="450" Height="380" RightButtonGroupMargin="0,5,5,0"> @@ -45,12 +45,12 @@ Background="{StaticResource Border.Background}"> - + - - - - + + + + @@ -59,37 +59,41 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + + + + - + + diff --git a/BBWY.Client/Views/FallWare/SetCloudWareBoxWindow.xaml.cs b/BBWY.Client/Views/FallWare/SetCloudWareBoxWindow.xaml.cs index cc441b07..a7488555 100644 --- a/BBWY.Client/Views/FallWare/SetCloudWareBoxWindow.xaml.cs +++ b/BBWY.Client/Views/FallWare/SetCloudWareBoxWindow.xaml.cs @@ -14,6 +14,10 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using WebSocketSharp; +using BBWY.Client.Helpers; +using System.Printing; +using System.Reflection; +using System.IO; namespace BBWY.Client.Views.FallWare { @@ -22,51 +26,71 @@ namespace BBWY.Client.Views.FallWare /// public partial class SetCloudWareBoxWindow : BWindow { - public SetCloudWareBoxWindow(JDWareBoxModel model, SealBoxService sealBoxService, WareType wareType, Action reflashWindow, bool isEnabled = true) + public SetCloudWareBoxWindow(JDWareBoxModel model, WareType wareType) { - if (SealBoxService == null) this.SealBoxService = sealBoxService; - WareType = wareType; - ReflashWindow = reflashWindow; + WareType = wareType; JDWareBoxModel = model; InitializeComponent(); - this.DataContext =this ; - if (!isEnabled) - { - //this.jd_box.IsEnabled = isEnabled; - //this.btn_save.Visibility = Visibility.Collapsed; - } + PurchaseOrderImage = MyPrintHelper.GetBarcodeImageV2(model.PurchaseOrder, 420, 50); + this.DataContext = this; + } public JDWareBoxModel JDWareBoxModel { get; set; } - - private SealBoxService SealBoxService { get; set; } - - private Action ReflashWindow { get; set; } - + /// + /// 采购单号条形码 + /// + public BitmapImage PurchaseOrderImage { get; set; } public WareType WareType { get; set; } - private void BButton_Click(object sender, RoutedEventArgs e) + public int PrintCount { get; set; } = 1; + + public void PrintBox(string printName) { - if (JDWareBoxModel.PurchaseOrder.IsNullOrEmpty()) + var localPrintServer = new LocalPrintServer(); + if (string.IsNullOrEmpty(printName)) { - MessageBox.Show("采购单号不能为空"); return; } - if (JDWareBoxModel.PrewOrder.IsNullOrEmpty() && WareType == WareType.京仓) + var printQueue = localPrintServer.GetPrintQueue(printName); + if (printQueue.IsInError) { - MessageBox.Show("预约单号不能为空"); + System.Windows.MessageBox.Show("打印机处于错误状态"); return; } - var res = SealBoxService.SetFallWareConfigure(JDWareBoxModel.SealBoxId, JDWareBoxModel.ProductTitle, JDWareBoxModel.PurchaseOrder, JDWareBoxModel.PrewOrder, JDWareBoxModel.WaybillNo); + MyPrintHelper.SetDefaultPrint(printName);//设置默认打印机 + PrintDialog printDialog = new PrintDialog(); - if (res != null && res.Success) + printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape;//设置为横向打印 PageOrientation.Landscape Portrait为纵向 + + for (int i = 1; i <= JDWareBoxModel.BoxCount; i++) { - if (ReflashWindow != null) ReflashWindow(); - this.Close(); + PrintCount = i; + //设置纸张大小 + var pageWidth = (int)Math.Ceiling(printDialog.PrintableAreaWidth); + var pageHeight = (int)Math.Ceiling(printDialog.PrintableAreaHeight); + printDialog.PrintTicket.PageMediaSize = new PageMediaSize(pageWidth, pageHeight); - return; + + this.Height = pageHeight + 39; + this.Width = pageWidth; + this.FontSize = 30; + this.jd_box.Arrange(new Rect(new Point(0, 0), new Size(pageWidth, pageHeight))); + //794 429 Width="478" Height="440" + //this.jd_box.Arrange(new Rect(new Point((pageWidth - jd_box.DesiredSize.Width) / 2, (pageHeight - jd_box.DesiredSize.Height) / 2), new Size(jd_box.DesiredSize.Width, jd_box.DesiredSize.Height))); + + printDialog.PrintVisual(this.jd_box, "打印任务"); + + + } + var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string printNames = System.IO.Path.Combine(applicationPath, "printName.init"); + if (File.Exists(printNames)) + { + File.Delete(printNames); } - if (res != null) MessageBox.Show(res.Msg); + System.IO.File.WriteAllText(printNames, printName); + this.Close(); } } } diff --git a/BBWY.Client/Views/FallWare/SetJDWareBoxWindow.xaml b/BBWY.Client/Views/FallWare/SetJDWareBoxWindow.xaml index eb41b156..acfb7497 100644 --- a/BBWY.Client/Views/FallWare/SetJDWareBoxWindow.xaml +++ b/BBWY.Client/Views/FallWare/SetJDWareBoxWindow.xaml @@ -10,13 +10,13 @@ xmlns:ctr="clr-namespace:BBWY.Client.Converters" xmlns:cmodel="clr-namespace:BBWY.Client.Models" xmlns:sys="clr-namespace:System;assembly=mscorlib" - + xmlns:hc="https://handyorg.github.io/handycontrol" WindowStartupLocation="CenterScreen" CloseButtonVisibility="Visible" CloseButtonColor="{StaticResource WindowButtonColor}" MinButtonVisibility="Collapsed" MaxButtonVisibility="Collapsed" - Width="450" Height="500" + Width="480" Height="480" RightButtonGroupMargin="0,5,5,0"> @@ -29,13 +29,13 @@ - + - - + + @@ -45,69 +45,77 @@ Background="{StaticResource Border.Background}"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + diff --git a/BBWY.Client/Views/FallWare/SetJDWareBoxWindow.xaml.cs b/BBWY.Client/Views/FallWare/SetJDWareBoxWindow.xaml.cs index 1102aee2..000f38a1 100644 --- a/BBWY.Client/Views/FallWare/SetJDWareBoxWindow.xaml.cs +++ b/BBWY.Client/Views/FallWare/SetJDWareBoxWindow.xaml.cs @@ -1,10 +1,18 @@ using BBWY.Client.APIServices; +using BBWY.Client.Helpers; using BBWY.Client.Models; using BBWY.Client.Models.FallWare; using BBWY.Controls; +using HandyControl.Controls; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing.Printing; +using System.IO; +using System.Printing; +using System.Reflection; using System.Text; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -22,54 +30,82 @@ namespace BBWY.Client.Views.FallWare /// public partial class SetJDWareBoxWindow : BWindow { - public SetJDWareBoxWindow(JDWareBoxModel model, SealBoxService sealBoxService,WareType wareType, Action reflashWindow,bool isEnabled = true) + public SetJDWareBoxWindow(JDWareBoxModel model) { - if (SealBoxService == null) this.SealBoxService = sealBoxService; - WareType = wareType; - ReflashWindow = reflashWindow; - JDWareBoxModel = model; InitializeComponent(); - this.DataContext = JDWareBoxModel; - if (!isEnabled) - { - //this.jd_box.IsEnabled = isEnabled; - //this.btn_save.Visibility = Visibility.Collapsed; - } - - - + PurchaseOrderImage= MyPrintHelper.GetBarcodeImageV2(model.PurchaseOrder, 420, 50); + PrewOrderImage = MyPrintHelper.GetBarcodeImageV2(model.PrewOrder, 350, 50); + this.DataContext =this; } public JDWareBoxModel JDWareBoxModel { get; set; } - private SealBoxService SealBoxService { get; set; } - private Action ReflashWindow { get; set; } + /// + /// 采购单号条形码 + /// + public BitmapImage PurchaseOrderImage { get; set; } + + + /// + /// 预约单号条形码 + /// + public BitmapImage PrewOrderImage { get; set; } + + + public int PrintCount { get; set; } = 1; + + + - private WareType WareType { get; set; } - private void BButton_Click(object sender, RoutedEventArgs e) + + public void PrintBox(string printName) { - if (JDWareBoxModel.PurchaseOrder.IsNullOrEmpty()) + var localPrintServer = new LocalPrintServer(); + if (string.IsNullOrEmpty(printName)) { - MessageBox.Show("采购单号不能为空"); return; } - if (JDWareBoxModel.PrewOrder.IsNullOrEmpty()&& WareType== WareType.京仓) + var printQueue = localPrintServer.GetPrintQueue(printName); + if (printQueue.IsInError) { - MessageBox.Show("预约单号不能为空"); + System.Windows.MessageBox.Show("打印机处于错误状态"); return; } - var res = SealBoxService.SetFallWareConfigure(JDWareBoxModel.SealBoxId, JDWareBoxModel.ProductTitle,JDWareBoxModel.PurchaseOrder,JDWareBoxModel.PrewOrder,JDWareBoxModel.WaybillNo); + MyPrintHelper.SetDefaultPrint(printName);//设置默认打印机 + PrintDialog printDialog = new PrintDialog(); + + printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape;//设置为横向打印 PageOrientation.Landscape Portrait为纵向 - if (res!=null&&res.Success) + for (int i = 1; i <= JDWareBoxModel.BoxCount; i++) { - if (ReflashWindow != null) ReflashWindow(); - this.Close(); + PrintCount = i; + //设置纸张大小 + var pageWidth = (int)Math.Ceiling(printDialog.PrintableAreaWidth); + var pageHeight = (int)Math.Ceiling(printDialog.PrintableAreaHeight); + printDialog.PrintTicket.PageMediaSize = new PageMediaSize(pageWidth, pageHeight); - return; + + this.Height = pageHeight + 39; + this.Width = pageWidth; + this.FontSize = 30; + this.jd_box.Arrange(new Rect(new Point(0, 0), new Size(pageWidth, pageHeight))); + //794 429 Width="478" Height="440" + //this.jd_box.Arrange(new Rect(new Point((pageWidth - jd_box.DesiredSize.Width) / 2, (pageHeight - jd_box.DesiredSize.Height) / 2), new Size(jd_box.DesiredSize.Width, jd_box.DesiredSize.Height))); + + printDialog.PrintVisual(this.jd_box, "打印任务"); + + + } + var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string printNames = System.IO.Path.Combine(applicationPath, "printName.init"); + if (File.Exists(printNames)) + { + File.Delete(printNames); } - if (res != null) MessageBox.Show(res.Msg); + System.IO.File.WriteAllText(printNames, printName); + this.Close(); } } } diff --git a/BBWY.Client/Views/FallWare/WaitFallWareControl.xaml b/BBWY.Client/Views/FallWare/WaitFallWareControl.xaml index bf3d47d6..fda3766c 100644 --- a/BBWY.Client/Views/FallWare/WaitFallWareControl.xaml +++ b/BBWY.Client/Views/FallWare/WaitFallWareControl.xaml @@ -255,10 +255,9 @@ Command="{Binding DataContext.LookBoxConfigureCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" CommandParameter="{Binding}" /> - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +