diff --git a/BBWY.Client/GlobalContext.cs b/BBWY.Client/GlobalContext.cs index 7cc3b287..8d013252 100644 --- a/BBWY.Client/GlobalContext.cs +++ b/BBWY.Client/GlobalContext.cs @@ -9,7 +9,7 @@ namespace BBWY.Client { ShopServiceGroupList = new List(); ShopServiceGroupLowerList = new List(); - ClientVersion = "10122"; + ClientVersion = "10125"; } private User user; diff --git a/BBWY.Client/Helpers/MyPrintHelper.cs b/BBWY.Client/Helpers/MyPrintHelper.cs index 12515e17..6296a880 100644 --- a/BBWY.Client/Helpers/MyPrintHelper.cs +++ b/BBWY.Client/Helpers/MyPrintHelper.cs @@ -9,6 +9,7 @@ using System.Drawing.Printing; using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.InteropServices; using System.Text; using System.Windows.Media.Imaging; using WebSocketSharp; @@ -618,5 +619,19 @@ namespace BBWY.Client.Helpers } } + + public static void SetDefaultPrint(string printName) + { + SetDefaultPrinter(printName); + } + + /// + /// 调用win api将指定名称的打印机设置为默认打印机 + /// + /// + /// + [DllImport("winspool.drv")] + public static extern bool SetDefaultPrinter(string Name); + } } diff --git a/BBWY.Client/Models/APIModel/Request/CerRequest.cs b/BBWY.Client/Models/APIModel/Request/CerRequest.cs index 194e8bee..cc221097 100644 --- a/BBWY.Client/Models/APIModel/Request/CerRequest.cs +++ b/BBWY.Client/Models/APIModel/Request/CerRequest.cs @@ -68,11 +68,14 @@ namespace BBWY.Client.Models.APIModel.Request /// public string ApplyAge { get; set; } - public int GoodsNumber { get; set; } + public long GoodsNumber { get; set; } public string ProduceDate { get; set; } public string PurchaseSkuId { get; set; } + + public SaveType? SaveType { get; set; } + } } diff --git a/BBWY.Client/Models/APIModel/Response/PackPurchaseTask/QualityTaskResponse.cs b/BBWY.Client/Models/APIModel/Response/PackPurchaseTask/QualityTaskResponse.cs index f8f767c6..1a7c7571 100644 --- a/BBWY.Client/Models/APIModel/Response/PackPurchaseTask/QualityTaskResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/PackPurchaseTask/QualityTaskResponse.cs @@ -93,6 +93,12 @@ namespace BBWY.Client.Models.APIModel.Response.PackPurchaseTask /// 配件列表 /// public PurchaseSku[] PurchaseSkus { get; set; } + + + /// + /// + /// + public SaveType? SaveType { get; set; } } public class WareHourseDTO { diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs index b0da91f3..c79f546c 100644 --- a/BBWY.Client/Models/Enums.cs +++ b/BBWY.Client/Models/Enums.cs @@ -452,4 +452,19 @@ { 增值服务工序 = 0, 基础包装工序 = 1/*,其他=2//基础包装 增量配件*/ } + + /// + /// 打包配置存放区分 + /// + public enum SaveType + { + /// + /// c端 + /// + C端 = 0, + /// + /// B端 + /// + B端 = 1 + } } diff --git a/BBWY.Client/Models/PackTask/CertificateModel.cs b/BBWY.Client/Models/PackTask/CertificateModel.cs index 437d9a1a..91c03978 100644 --- a/BBWY.Client/Models/PackTask/CertificateModel.cs +++ b/BBWY.Client/Models/PackTask/CertificateModel.cs @@ -12,9 +12,6 @@ namespace BBWY.Client.Models /// 合格证id /// public long Id { get; set; } - - - /// /// skuid /// @@ -142,11 +139,20 @@ namespace BBWY.Client.Models - private int goodsNumber = 1; + private long goodsNumber = 1; + /// + /// 配件序号 + /// + public long GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } } + + + + private int goodsNumberIndex = 1; /// /// 配件序号 /// - public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } } + public int GoodsNumberIndex { get => goodsNumberIndex; set { Set(ref goodsNumberIndex, value); } } + private string produceDate; /// diff --git a/BBWY.Client/Models/PackTask/PackTaskModel.cs b/BBWY.Client/Models/PackTask/PackTaskModel.cs index ce5db38a..252775e4 100644 --- a/BBWY.Client/Models/PackTask/PackTaskModel.cs +++ b/BBWY.Client/Models/PackTask/PackTaskModel.cs @@ -103,7 +103,16 @@ namespace BBWY.Client.Models // qualityViewModel.TaskId = TaskId; qualityViewModel.OrderId = OrderId; qualityViewModel.SkuId = SkuId; - qualityViewModel.SearchSku(this); + try + { + qualityViewModel.SearchSku(this); + } + catch (Exception ex) + { + System.Windows.MessageBox.Show(ex.Message); + + } + //qualityViewModel.LoadPackDatas(); //qualityViewModel.SetAllFees = new Action>((feesItem, packUsers) => //{ diff --git a/BBWY.Client/ViewModels/QualityTask/QualityViewModel.cs b/BBWY.Client/ViewModels/QualityTask/QualityViewModel.cs index d10dab7a..aa95f675 100644 --- a/BBWY.Client/ViewModels/QualityTask/QualityViewModel.cs +++ b/BBWY.Client/ViewModels/QualityTask/QualityViewModel.cs @@ -20,6 +20,7 @@ using Org.BouncyCastle.Asn1.Crmf; using System.Runtime.InteropServices.WindowsRuntime; using NPOI.Util; using BBWY.Controls; +using WebSocketSharp; namespace BBWY.Client.ViewModels { @@ -445,20 +446,20 @@ namespace BBWY.Client.ViewModels }; if (IsNeedBarCode == Need.需要) { - if (BarCodeModel==null|| BarCodeModel.Id <= 0) + if (BarCodeModel == null || BarCodeModel.Id <= 0) { MessageBox.Show("条形码不能为空"); return; } request.BarcodeId = BarCodeModel.Id; } - if (IsNeedCertificateModel == Need.需要) + if(PurchaseSkuList != null && PurchaseSkuList.Count > 0&&purchaseSkuList.Any(p=> p.IsNeedCer)) //(IsNeedCertificateModel == Need.需要) { - if (PurchaseSkuList == null && PurchaseSkuList.Count <= 0) - { - MessageBox.Show("无可用的合格证打印!"); - return; - } + //if () + //{ + // MessageBox.Show("无可用的合格证打印!"); + // return; + //} if (PurchaseSkuList.Where(p => p.IsSetCertificate).Count() > 0) { MessageBox.Show("存在未确认的合格证,请先完成确认!"); @@ -506,7 +507,7 @@ namespace BBWY.Client.ViewModels - if (competeTime now.AddDays(1).Date.AddHours(12)) + if (competeTime > now.AddDays(1).Date.AddHours(12)) { MessageBox.Show($"预计完成时间不能超过明天12点,请重新选择预计完成时间"); return; @@ -552,28 +553,40 @@ namespace BBWY.Client.ViewModels request.PreCompeteTime = competeTime; - var competeRes = packPurchaseTaskService.CompeteQualityTask(request); - if (competeRes == null) - { - MessageBox.Show("网络异常"); - return; - } - if (!competeRes.Success) + try { - MessageBox.Show(competeRes.Msg); - return; - } - BatchPrintWindow batchPrint = new BatchPrintWindow(); + var competeRes = packPurchaseTaskService.CompeteQualityTask(request); + if (competeRes == null) + { + MessageBox.Show("网络异常"); + return; + } + if (!competeRes.Success) + { + MessageBox.Show(competeRes.Msg); + return; + } + BatchPrintWindow batchPrint = new BatchPrintWindow(); - batchPrint.SetData(GoodProductQuantity, - PurchaseSkuList.Where(p => p.IsNeedCer && p.CerDTO.Id > 0).Select(p => p.CerDTO).ToArray() - , BarCodeModel); - batchPrint.ShowDialog(); + batchPrint.SetData(GoodProductQuantity, + PurchaseSkuList.Where(p => p.IsNeedCer && p.CerDTO.Id > 0).Select(p => p.CerDTO).ToArray() + , BarCodeModel); + batchPrint.ShowDialog(); - if (ReflashWindow != null) ReflashWindow(); - var window = obj as BWindow; + if (ReflashWindow != null) ReflashWindow(); + var window = obj as BWindow; + App.Current.Dispatcher.Invoke(new Action(() => + { + + window.Close(); + })); + + } + catch (Exception ex) + { - window.Close(); + System.Windows.MessageBox.Show(ex.Message); + } } @@ -638,7 +651,7 @@ namespace BBWY.Client.ViewModels model.CerDTO.BrandName = BrandName; QualitySetCerWindow setCerWindow = new QualitySetCerWindow(); - setCerWindow.LoadData(model.IsNeedCer, model.CerDTO, packPurchaseTaskService, spuCertificateModel, IsSetSpuCertificate); + setCerWindow.LoadData(model.IsNeedCer, model.CerDTO, packPurchaseTaskService, spuCertificateModel, IsSetSpuCertificate, saveType); setCerWindow.SaveResult = (s, PackCerState) => { if (string.IsNullOrEmpty(s.PurchaseSkuId)) @@ -679,6 +692,9 @@ namespace BBWY.Client.ViewModels look.Show(); } + + + SaveType? saveType; /// /// 搜索 skuId(todo:) /// @@ -702,6 +718,7 @@ namespace BBWY.Client.ViewModels BasicPack = model.BasicPack; CertificatePosition = model.CertificatePosition; + ArrivalQuantity = 0; GoodProductQuantity = 0; @@ -728,10 +745,30 @@ namespace BBWY.Client.ViewModels var packTaskRes = packPurchaseTaskService.GetQualityTask(model.TaskId); + + if (packTaskRes==null) + { + MessageBox.Show("网络异常!"); + return; + } + if (!packTaskRes.Success || packTaskRes.Data==null) + { + MessageBox.Show(packTaskRes.Msg); + return; + } + + + + SkuPurchaseSchemeId = packTaskRes.Data.SkuPurchaseSchemeId; + saveType = packTaskRes.Data.SaveType; + if (saveType == null) + { + saveType = OrderId.IsNullOrEmpty() ? SaveType.C端 : SaveType.B端; + } if (packTaskRes == null || !packTaskRes.Success) return; BarCodeModel = packTaskRes.Data.BarCodeDTO; IsNeedBarCode = packTaskRes.Data.IsNeedBar ? Need.需要 : Need.不需要; - IsSetBarCode = packTaskRes.Data.IsNeedBar ? false : true; + IsSetBarCode = packTaskRes.Data.BarCodeDTO == null ? true : false; IsNeedCertificateModel = packTaskRes.Data.IsNeedCer ? Need.需要 : Need.不需要; if (packTaskRes.Data.WareHourses != null) packTaskRes.Data.WareHourses.ToList().ForEach(w => @@ -742,9 +779,11 @@ namespace BBWY.Client.ViewModels if (packTaskRes.Data.PurchaseSkus != null) { - + int goodsIndex = 0; foreach (var item in packTaskRes.Data.PurchaseSkus) { + goodsIndex++; + if (item.CerDTO != null) item.CerDTO.GoodsNumberIndex = goodsIndex; item.IsSetCertificate = true; if (string.IsNullOrEmpty(item.PurchaseProductId)) { @@ -756,14 +795,16 @@ namespace BBWY.Client.ViewModels { PurchaseSkuList.Add(item); continue; } + PurchaseSkuItemBasicInfoResponse skuItem = null; + if (list.Data != null) skuItem = list.Data.ItemList.FirstOrDefault(f => f.PurchaseSkuId == item.PurchaseSkuId); + - var skuItem = list.Data.ItemList.FirstOrDefault(f => f.PurchaseSkuId == item.PurchaseSkuId); App.Current.Dispatcher.Invoke(new Action(() => { PurchaseSkuList.Add(new PurchaseSku { - Logo = skuItem.Logo, - Title = skuItem.Title, + Logo = skuItem?.Logo, + Title = skuItem?.Title, IsNeedCer = item.IsNeedCer, PurchaseSkuId = item.PurchaseSkuId, CerDTO = item.CerDTO, @@ -806,7 +847,7 @@ namespace BBWY.Client.ViewModels - if (hour<12) + if (hour < 12) { PreCompeteTimeDayList.Add("今天"); PreCompeteTimeDayList.Add("明天"); @@ -815,7 +856,7 @@ namespace BBWY.Client.ViewModels PreCompeteTimeHour = "12点前"; } - else if (hour<18) + else if (hour < 18) { PreCompeteTimeDayList.Add("今天"); PreCompeteTimeDayList.Add("明天"); diff --git a/BBWY.Client/Views/PackTask/LookCerWindow.xaml b/BBWY.Client/Views/PackTask/LookCerWindow.xaml index d7893ee0..d6d90724 100644 --- a/BBWY.Client/Views/PackTask/LookCerWindow.xaml +++ b/BBWY.Client/Views/PackTask/LookCerWindow.xaml @@ -44,7 +44,7 @@ - + diff --git a/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs b/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs index f5ff0e73..4ff41ffe 100644 --- a/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs +++ b/BBWY.Client/Views/PackTask/LookCerWindow.xaml.cs @@ -29,11 +29,23 @@ namespace BBWY.Client.Views.PackTask InitializeComponent(); GoodsNumberCerList = new ObservableCollection(); + int goodsNumberIndex = 0; foreach (CertificateModel certificateModel in certificate) + { + if (certificateModel==null) + { + continue; + } + goodsNumberIndex++; + certificateModel.GoodsNumberIndex = goodsNumberIndex; GoodsNumberCerList.Add(new GoodsNumberCer { CertificateModel = certificateModel.Copy(), + + }); + } + this.DataContext = this; } diff --git a/BBWY.Client/Views/PackTask/ServiceWindow.xaml.cs b/BBWY.Client/Views/PackTask/ServiceWindow.xaml.cs index cd1668ac..f51f2957 100644 --- a/BBWY.Client/Views/PackTask/ServiceWindow.xaml.cs +++ b/BBWY.Client/Views/PackTask/ServiceWindow.xaml.cs @@ -1,5 +1,6 @@ using BarcodeLib; using BBWY.Client.APIServices; +using BBWY.Client.Helpers; using BBWY.Client.ViewModels; using BBWY.Client.ViewModels.PackTask; using BBWY.Controls; @@ -50,9 +51,8 @@ namespace BBWY.Client.Views.PackTask MessageBox.Show("打印机处于错误状态"); return; } - //Print(this.printArea, cbPrintName.Text, "打印任务",1); - - + + MyPrintHelper.SetDefaultPrint(printName);//设置默认打印机 this.printArea.Arrange(new Rect(new Point(0, 0), new Size(printArea.ActualWidth, printArea.ActualHeight))); PrintDialog printDialog = new PrintDialog(); @@ -76,99 +76,7 @@ namespace BBWY.Client.Views.PackTask - /// - /// 打印 - /// - /// 流文档 - /// 打印机名称 - /// 打印描述 - /// 打印个数 - public static void Print(Visual document, string printer, string description, int copyCount) - { - var localPrintServer = new LocalPrintServer(); - var printQueue = localPrintServer.GetPrintQueue(printer); - if (printQueue.IsInError) - { - throw new Exception("打印机处于错误状态"); - } - - var printDialog = new PrintDialog - { - PrintQueue = printQueue, //打印队列 - PrintTicket = { CopyCount = copyCount } //打印个数 - }; - - //设置纸张大小 - var pageWidth = (int)Math.Ceiling(printDialog.PrintableAreaWidth); //小标签:114 - var pageHeight = (int)Math.Ceiling(printDialog.PrintableAreaHeight); //小标签:227 - printDialog.PrintTicket.PageMediaSize = new PageMediaSize(pageWidth, pageHeight); - - //设置纸张边距 - var paperSize = GetPaperSize(printer); //小标签:118*246 - //var offsetX = (int)Math.Ceiling((paperSize.Width - pageWidth) / 2f); - //var offsetY = (int)Math.Ceiling((paperSize.Height - pageHeight) / 2f); - //document.PagePadding = new Thickness(offsetX, offsetY, offsetX, offsetY); - - //打印 - var paginator = ((IDocumentPaginatorSource)document).DocumentPaginator; - printDialog.PrintDocument(paginator, description); - - var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - string printNames = System.IO.Path.Combine(applicationPath, "printName.init"); - File.WriteAllText(printNames, printer); - - } - - private static object GetPaperSize(string printer) - { - return null; - } - - public interface IDocumentRenderer - { - void Render(FlowDocument doc, object data); - } - - public class CommonDocumentRenderer : IDocumentRenderer - { - public void Render(FlowDocument doc, object data) - { - var model = data as PrintModel; - if (model == null) - { - throw new ArgumentException("data is not PrintModel"); - } - - var type = typeof(PrintModel); - var properties = type.GetProperties(); - foreach (var property in properties) - { - //文本赋值 - if (doc.FindName(property.Name) is TextBlock textBlock) - { - textBlock.Text = property.GetValue(model)?.ToString(); - } - } - } - } - - public class PrintModel - { - /// - /// 批号 - /// - public string BatchNumber { get; set; } - - /// - /// 订单号 - /// - public string OrderNumber { get; set; } - - /// - /// 物料代码 - /// - public string MaterialNumber { get; set; } - } + } } diff --git a/BBWY.Client/Views/PackTask/SetCerWindow.xaml.cs b/BBWY.Client/Views/PackTask/SetCerWindow.xaml.cs index 55073097..fb46342b 100644 --- a/BBWY.Client/Views/PackTask/SetCerWindow.xaml.cs +++ b/BBWY.Client/Views/PackTask/SetCerWindow.xaml.cs @@ -139,7 +139,7 @@ namespace BBWY.Client.Views.PackTask setSpuCerWindow.Show(); } - int selectCer = -1;//tabcontrol 选中事件 + long selectCer = -1;//tabcontrol 选中事件 private void InseartCer_Click(object sender, RoutedEventArgs e) { if (IsSetSpuCertificate) diff --git a/BBWY.Client/Views/QualityTask/QualitySetCerWindow.xaml.cs b/BBWY.Client/Views/QualityTask/QualitySetCerWindow.xaml.cs index 477e0dbd..9ce656c1 100644 --- a/BBWY.Client/Views/QualityTask/QualitySetCerWindow.xaml.cs +++ b/BBWY.Client/Views/QualityTask/QualitySetCerWindow.xaml.cs @@ -35,14 +35,16 @@ namespace BBWY.Client.Views.QualityTask PackCerState = obj; } - public void LoadData(bool isNeedCer, CertificateModel CertificateModel, PackPurchaseTaskService packTaskService, CertificateModel SpuCertificateModel, bool IsSetSpuCertificate) + public void LoadData(bool isNeedCer, CertificateModel CertificateModel, PackPurchaseTaskService packTaskService, CertificateModel SpuCertificateModel, bool IsSetSpuCertificate,SaveType? saveType) { this.CertificateModel = CertificateModel.Copy(); this.packTaskService = packTaskService; PackCerState = isNeedCer ? PackCerState.合格证信息 : PackCerState.无需合格证; + SaveType = saveType; this.DataContext = this; } + public SaveType? SaveType { get; set; } public ICommand SetPackCerStateCommand { get; set; } @@ -123,6 +125,7 @@ namespace BBWY.Client.Views.QualityTask GoodsNumber = CertificateModel.GoodsNumber, ProduceDate = CertificateModel.ProduceDate, PurchaseSkuId = CertificateModel.PurchaseSkuId, + SaveType = SaveType }); if (resData == null || !resData.Success) { diff --git a/BBWY.Client/Views/QualityTask/QualityWindow.xaml b/BBWY.Client/Views/QualityTask/QualityWindow.xaml index a307c095..98e8d707 100644 --- a/BBWY.Client/Views/QualityTask/QualityWindow.xaml +++ b/BBWY.Client/Views/QualityTask/QualityWindow.xaml @@ -212,7 +212,7 @@ ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" ItemsSource="{Binding PurchaseSkuList,Mode=TwoWay}" BorderBrush="{StaticResource Border.Brush}" - BorderThickness="0" Visibility="{Binding OrderId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Collapsed:Visible}" + BorderThickness="0" Visibility="{Binding SkuPurchaseSchemeId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Collapsed:Visible}" Foreground="{StaticResource Text.Color}"> @@ -316,7 +316,7 @@ ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" ItemsSource="{Binding PurchaseSkuList,Mode=TwoWay}" BorderBrush="{StaticResource Border.Brush}" - BorderThickness="0" Visibility="{Binding OrderId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Visible:Collapsed}" + BorderThickness="0" Visibility="{Binding SkuPurchaseSchemeId,Mode=TwoWay,Converter={StaticResource objConverter},ConverterParameter=#null:Visible:Collapsed}" Foreground="{StaticResource Text.Color}"> @@ -331,7 +331,7 @@ - + @@ -395,7 +395,7 @@ - +