From 80676027e82138b09aa2bc287fbf4b32af2699fe Mon Sep 17 00:00:00 2001 From: "506583276@qq.com" <506583276@qq.com> Date: Mon, 5 Jun 2023 11:33:50 +0800 Subject: [PATCH 01/10] 1 --- BBWY.Client/APIServices/PackTaskService.cs | 7 ++- .../PackTask/WareHouseListViewModel.cs | 43 ++++++++++----- BBWY.Client/Views/PackTask/TipsWindow.xaml | 2 +- BBWY.Client/Views/PackTask/TipsWindow.xaml.cs | 28 ++++++++-- .../Views/PackTask/WaitSealBoxControl.xaml | 35 ++++++++++--- .../Views/PackTask/WareHouseList.xaml.cs | 2 +- .../Views/SealBox/SetSealBoxWindow.xaml | 52 +++++++++++++++++++ .../Views/SealBox/SetSealBoxWindow.xaml.cs | 49 +++++++++++++++++ 8 files changed, 193 insertions(+), 25 deletions(-) create mode 100644 BBWY.Client/Views/SealBox/SetSealBoxWindow.xaml create mode 100644 BBWY.Client/Views/SealBox/SetSealBoxWindow.xaml.cs diff --git a/BBWY.Client/APIServices/PackTaskService.cs b/BBWY.Client/APIServices/PackTaskService.cs index 468975aa..ff12be0f 100644 --- a/BBWY.Client/APIServices/PackTaskService.cs +++ b/BBWY.Client/APIServices/PackTaskService.cs @@ -329,7 +329,7 @@ namespace BBWY.Client.APIServices /// /// /// - public ApiResponse CompeteSealBox( List CompeteSealBoxs) + public ApiResponse CompeteSealBox( CompeteSealBox CompeteSealBoxs) { return SendRequest(globalContext.QKApiHost, "api/PackTask/CompeteSealBox", new { @@ -346,11 +346,14 @@ namespace BBWY.Client.APIServices /// /// 任务Id /// - public long TaskId { get; set; } + public long[] TaskId { get; set; } /// /// 仓库Id /// public string WareId { get; set; } + + public int BoxCount { get; set; } + } diff --git a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs index 14cc413c..4f5df699 100644 --- a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs @@ -21,6 +21,7 @@ using NPOI.SS.Formula.Functions; using GalaSoft.MvvmLight.Messaging; using BBWY.Client.Models.APIModel; using BBWY.Client.Models.PackTask; +using BBWY.Client.Views.SealBox; namespace BBWY.Client.ViewModels.PackTask { @@ -261,6 +262,17 @@ namespace BBWY.Client.ViewModels.PackTask UpdateTaskStateCommand = new RelayCommand(UpdateTaskState); CompeteSealBoxCommand = new RelayCommand(CompeteSealBox); + + SetSealBoxCommand = new RelayCommand(SetSealBox); + } + + private void SetSealBox(object obj) + { + SetSealBoxWindow setSealBoxWindow = new SetSealBoxWindow(); + setSealBoxWindow.SendBoxCount= boxCount => { + BoxCount = boxCount; + }; + setSealBoxWindow.ShowDialog(); } @@ -302,27 +314,34 @@ namespace BBWY.Client.ViewModels.PackTask /// public ICommand TaskPageIndexChangedCommand { get; set; } + /// + /// 设置分箱数量 + /// + public ICommand SetSealBoxCommand { get; set; } + BatchPurchaseService batchPurchaseService; + + public int BoxCount { get; set; } + private void CompeteSealBox(object obj) { - var objList = obj as SealBoxModel; - List CompeteSealBoxs = new List(); - string wareId = objList.WareId; - foreach (var item in objList.SealBoxSkus) - { - CompeteSealBoxs.Add(new APIServices.CompeteSealBox - { - WareId = wareId, - TaskId = item.TaskId, + if (BoxCount<=0) + { + System.Windows.MessageBox.Show("请先设置封箱数量"); + return; + } - }); + var objList = obj as SealBoxModel; - } - var res = packTaskService.CompeteSealBox(CompeteSealBoxs); + CompeteSealBox competeSealBox = new CompeteSealBox(); + competeSealBox.WareId = objList.WareId; + competeSealBox.BoxCount = BoxCount; + competeSealBox.TaskId = objList.SealBoxSkus.Select(s => s.TaskId).ToArray(); + var res = packTaskService.CompeteSealBox(competeSealBox); if (res != null && res.Success) { SearchTaskList(); diff --git a/BBWY.Client/Views/PackTask/TipsWindow.xaml b/BBWY.Client/Views/PackTask/TipsWindow.xaml index 09662e26..ca4a72bf 100644 --- a/BBWY.Client/Views/PackTask/TipsWindow.xaml +++ b/BBWY.Client/Views/PackTask/TipsWindow.xaml @@ -30,7 +30,7 @@ + Text="请设置合格证内容" BorderBrush="White" VerticalAlignment="Center" HorizontalAlignment="Center"/> diff --git a/BBWY.Client/Views/PackTask/TipsWindow.xaml.cs b/BBWY.Client/Views/PackTask/TipsWindow.xaml.cs index 9ccf50a9..3b5a4dc2 100644 --- a/BBWY.Client/Views/PackTask/TipsWindow.xaml.cs +++ b/BBWY.Client/Views/PackTask/TipsWindow.xaml.cs @@ -20,7 +20,7 @@ namespace BBWY.Client.Views.PackTask public partial class TipsWindow : BWindow { private DispatcherTimer timer; - public TipsWindow(string Content,int waitTime=2) + public TipsWindow(string Content, int waitTime =3) { InitializeComponent(); tbContent.Text = Content; @@ -31,16 +31,38 @@ namespace BBWY.Client.Views.PackTask timer.Tick += OnTimerTick; timer.Start(); + this.Closed += TipsWindow_Closed; } + private void TipsWindow_Closed(object sender, EventArgs e) + { + IsClosed = true; + } + + private bool IsClosed; private void OnTimerTick(object sender, EventArgs e) { timer.Stop(); - Close(); + + CloseWindow(); } + + object closeWindow = new object(); + private void CloseWindow() + { + if (IsClosed) + return; + lock (closeWindow) + { + if (!IsClosed) + Close(); + } + + } + private void BButton_Click(object sender, RoutedEventArgs e) { - this.Close(); + CloseWindow(); } } } diff --git a/BBWY.Client/Views/PackTask/WaitSealBoxControl.xaml b/BBWY.Client/Views/PackTask/WaitSealBoxControl.xaml index 3fe553c7..e9d6efa6 100644 --- a/BBWY.Client/Views/PackTask/WaitSealBoxControl.xaml +++ b/BBWY.Client/Views/PackTask/WaitSealBoxControl.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:BBWY.Client.Views.PackTask" - mc:Ignorable="d" + mc:Ignorable="d" Background="white" xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls" xmlns:ctr="clr-namespace:BBWY.Client.Converters" xmlns:sys="clr-namespace:System;assembly=mscorlib" @@ -33,19 +33,22 @@ + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/SealBox/SetSealBoxWindow.xaml.cs b/BBWY.Client/Views/SealBox/SetSealBoxWindow.xaml.cs new file mode 100644 index 00000000..704c5da2 --- /dev/null +++ b/BBWY.Client/Views/SealBox/SetSealBoxWindow.xaml.cs @@ -0,0 +1,49 @@ +using BBWY.Controls; +using System; +using System.Collections.Generic; +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.SealBox +{ + /// + /// SetSealBoxWindow.xaml 的交互逻辑 + /// + public partial class SetSealBoxWindow : BWindow + { + public SetSealBoxWindow() + { + InitializeComponent(); + } + + + public Action SendBoxCount { get; set; } + private void BButton_Click(object sender, RoutedEventArgs e) + { + int boxCount = 0; + try + { + boxCount = Convert.ToInt32(tbSealBoxCount.Text); + } + catch (Exception) + { + MessageBox.Show("请输入数字!"); + return; + } + + + + //todo: 打印单子 + if (SendBoxCount != null) SendBoxCount(boxCount); + + + } + } +} From a2e35c65b0462f110c0d0e7f833cc73840a15806 Mon Sep 17 00:00:00 2001 From: "506583276@qq.com" <506583276@qq.com> Date: Thu, 8 Jun 2023 15:48:45 +0800 Subject: [PATCH 02/10] 1 --- BBWY.Client/APIServices/DictionaryService.cs | 27 ++ BBWY.Client/APIServices/PackTaskService.cs | 22 +- BBWY.Client/BBWYAppSettings.json | 4 +- .../Dictionary/GetDictionaryByKeyResponse.cs | 34 ++ .../PackTask/ProductSkuCountsResponse.cs | 5 + .../PackTask/SearchWaitFallWareResponse.cs | 111 +++++++ .../PackTask/SearchWaitSealBoxResponse.cs | 1 + BBWY.Client/Models/Enums.cs | 3 +- BBWY.Client/Models/PackTask/SealBoxModel.cs | 6 + .../PackTask/PublishTaskViewModel.cs | 1 - .../PackTask/WareHouseListViewModel.cs | 142 ++++++--- .../Views/PackTask/WaitFallWareControl.xaml | 296 ++++++++++++++++++ .../PackTask/WaitFallWareControl.xaml.cs | 26 ++ BBWY.Client/Views/PackTask/WareHouseList.xaml | 8 +- .../Views/SealBox/SetSealBoxWindow.xaml.cs | 143 ++++++++- .../WaitSealBoxControl.xaml | 69 ++-- .../WaitSealBoxControl.xaml.cs | 0 17 files changed, 812 insertions(+), 86 deletions(-) create mode 100644 BBWY.Client/APIServices/DictionaryService.cs create mode 100644 BBWY.Client/Models/APIModel/Response/Dictionary/GetDictionaryByKeyResponse.cs create mode 100644 BBWY.Client/Models/APIModel/Response/PackTask/SearchWaitFallWareResponse.cs create mode 100644 BBWY.Client/Views/PackTask/WaitFallWareControl.xaml create mode 100644 BBWY.Client/Views/PackTask/WaitFallWareControl.xaml.cs rename BBWY.Client/Views/{PackTask => SealBox}/WaitSealBoxControl.xaml (86%) rename BBWY.Client/Views/{PackTask => SealBox}/WaitSealBoxControl.xaml.cs (100%) diff --git a/BBWY.Client/APIServices/DictionaryService.cs b/BBWY.Client/APIServices/DictionaryService.cs new file mode 100644 index 00000000..b3deba82 --- /dev/null +++ b/BBWY.Client/APIServices/DictionaryService.cs @@ -0,0 +1,27 @@ +using BBWY.Client.Models.APIModel; +using BBWY.Client.Models.APIModel.Request; +using BBWY.Common.Http; +using BBWY.Common.Models; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; + +namespace BBWY.Client.APIServices +{ + public class DictionaryService : BaseApiService, IDenpendency + { + public DictionaryService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext) + { + } + + + + public ApiResponse GetDictionaryByKey(string key) + { + return SendRequest(globalContext.QKApiHost, $"api/Dictionary/GetDictionaryByKey?key={key}", + null + , null, HttpMethod.Get); + } + } +} diff --git a/BBWY.Client/APIServices/PackTaskService.cs b/BBWY.Client/APIServices/PackTaskService.cs index ff12be0f..7159590b 100644 --- a/BBWY.Client/APIServices/PackTaskService.cs +++ b/BBWY.Client/APIServices/PackTaskService.cs @@ -331,14 +331,30 @@ namespace BBWY.Client.APIServices /// public ApiResponse CompeteSealBox( CompeteSealBox CompeteSealBoxs) { - return SendRequest(globalContext.QKApiHost, "api/PackTask/CompeteSealBox", new + return SendRequest(globalContext.QKApiHost, "api/PackTask/CompeteSealBox", CompeteSealBoxs, null, HttpMethod.Post); + } + + + + /// + /// 获取待落仓列表 + /// + /// + /// + public ApiResponse SearchWaitFallWareList(string ShopName = null, long? TaskId = null, string SkuId = null, int PageIndex = 1 + , int PageSize = 10) + { + return SendRequest(globalContext.QKApiHost, "api/PackTask/SearchWaitFallWareList", new { - CompeteSealBoxs + ShopName, + TaskId, + SkuId, + PageIndex, + PageSize }, null, HttpMethod.Post); } - } public class CompeteSealBox diff --git a/BBWY.Client/BBWYAppSettings.json b/BBWY.Client/BBWYAppSettings.json index 34888905..9622efaf 100644 --- a/BBWY.Client/BBWYAppSettings.json +++ b/BBWY.Client/BBWYAppSettings.json @@ -4,6 +4,6 @@ "MDSApiHost": "http://mdsapi.qiyue666.com", "JOSApiHost": "", "1688ApiHost": "", - "QKApiHost": "http://localhost:8080" - // "QKApiHost": "http://qiku.qiyue666.com" + //"QKApiHost": "http://localhost:8080" + "QKApiHost": "http://qiku.qiyue666.com" } \ No newline at end of file diff --git a/BBWY.Client/Models/APIModel/Response/Dictionary/GetDictionaryByKeyResponse.cs b/BBWY.Client/Models/APIModel/Response/Dictionary/GetDictionaryByKeyResponse.cs new file mode 100644 index 00000000..491c9a46 --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/Dictionary/GetDictionaryByKeyResponse.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Client.Models.APIModel +{ + public class GetDictionaryByKeyResponse + { + /// + /// 字典类型 + /// + public string Key { get; set; } + /// + /// 字典类型名称 + /// + public string KeyName { get; set; } + /// + /// 字典值列表 + /// + public IList DicValueList { get; set; } + } + + public class DicValue + { + /// + /// 字典值 + /// + public string Value { get; set; } + /// + /// 字典值标签 + /// + public string ValueName { get; set; } + } +} diff --git a/BBWY.Client/Models/APIModel/Response/PackTask/ProductSkuCountsResponse.cs b/BBWY.Client/Models/APIModel/Response/PackTask/ProductSkuCountsResponse.cs index e6dd9cd9..51a9a651 100644 --- a/BBWY.Client/Models/APIModel/Response/PackTask/ProductSkuCountsResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/PackTask/ProductSkuCountsResponse.cs @@ -36,5 +36,10 @@ namespace BBWY.Client.Models.APIModel.Response.PackTask /// 待出库数 /// public int? WaitOutbound { get; set; } + + /// + /// 待落仓 + /// + public int? WaitFallWareCount { get; set; } } } diff --git a/BBWY.Client/Models/APIModel/Response/PackTask/SearchWaitFallWareResponse.cs b/BBWY.Client/Models/APIModel/Response/PackTask/SearchWaitFallWareResponse.cs new file mode 100644 index 00000000..c52aec33 --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/PackTask/SearchWaitFallWareResponse.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Client.Models.APIModel +{ + public class SearchWaitFallWareResponse + { + /// + /// 数量 + /// + public int TotalCount { get; set; } + + + public IList WaitFallWareList { get; set; } + } + + + + + + + public class WaitFallWareModelResponse + { + /// + /// 店铺Id + /// + public string ShopId { get; set; } + /// + /// 仓库Id(同一个店铺 唯一) + /// + public string WareId { get; set; } + /// + /// 店铺名称 + /// + public string ShopName { get; set; } + /// + /// 仓库名 + /// + public string WareName { get; set; } + + /// + /// 团队名称 + /// + public string DepartmentName { get; set; } + + /// + /// 对接人(同团队下) + /// + public List AcceptUserNames { get; set; } + + /// + /// 封箱sku列表 + /// + public List SealBoxSkus { get; set; } + + /// + /// 封箱的箱子数量 + /// + public int SealBoxCount { get; set; } + /// + /// 封箱id + /// + public long SealBoxId { get; set; } + } + + public class WaitFallWareModel + { + /// + /// 店铺Id + /// + public string ShopId { get; set; } + /// + /// 仓库Id(同一个店铺 唯一) + /// + public string WareId { get; set; } + /// + /// 店铺名称 + /// + public string ShopName { get; set; } + /// + /// 仓库名 + /// + public string WareName { get; set; } + + /// + /// 团队名称 + /// + public string DepartmentName { get; set; } + + /// + /// 对接人(同团队下) + /// + public string AcceptUserNames { get; set; } + + /// + /// 封箱sku列表 + /// + public List SealBoxSkus { get; set; } + + /// + /// 封箱的箱子数量 + /// + public int SealBoxCount { get; set; } + /// + /// 封箱id + /// + public long SealBoxId { get; set; } + } + +} diff --git a/BBWY.Client/Models/APIModel/Response/PackTask/SearchWaitSealBoxResponse.cs b/BBWY.Client/Models/APIModel/Response/PackTask/SearchWaitSealBoxResponse.cs index 97988b82..bcedf94a 100644 --- a/BBWY.Client/Models/APIModel/Response/PackTask/SearchWaitSealBoxResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/PackTask/SearchWaitSealBoxResponse.cs @@ -96,5 +96,6 @@ namespace BBWY.Client.Models.APIModel /// 打包sku产品数量 /// public int SkuCount { get; set; } + } } diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs index b0da91f3..5cc2ec9c 100644 --- a/BBWY.Client/Models/Enums.cs +++ b/BBWY.Client/Models/Enums.cs @@ -233,7 +233,8 @@ 待封箱 = 4, 待出库 = 5, 已完成 = 6, - 已取消 = 7 + 已取消 = 7, + 待落仓 = 8 } diff --git a/BBWY.Client/Models/PackTask/SealBoxModel.cs b/BBWY.Client/Models/PackTask/SealBoxModel.cs index 7611a399..248d85e5 100644 --- a/BBWY.Client/Models/PackTask/SealBoxModel.cs +++ b/BBWY.Client/Models/PackTask/SealBoxModel.cs @@ -39,5 +39,11 @@ namespace BBWY.Client.Models.PackTask /// 封箱sku列表 /// public List SealBoxSkus { get; set; } + + + /// + /// 封箱数 + /// + public int? SealBoxCount{ get; set; } } } diff --git a/BBWY.Client/ViewModels/PackTask/PublishTaskViewModel.cs b/BBWY.Client/ViewModels/PackTask/PublishTaskViewModel.cs index 6174e294..7f90713c 100644 --- a/BBWY.Client/ViewModels/PackTask/PublishTaskViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/PublishTaskViewModel.cs @@ -322,7 +322,6 @@ namespace BBWY.Client.ViewModels.PackTask public ICommand OpenSkuDetailCommand { get; set; } public ICommand CreateTaskCommand { get; set; } - public ICommand SearchSkuCommand { get; set; } private void SetBarCode() diff --git a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs index 4f5df699..66377368 100644 --- a/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs +++ b/BBWY.Client/ViewModels/PackTask/WareHouseListViewModel.cs @@ -49,13 +49,28 @@ namespace BBWY.Client.ViewModels.PackTask } + + + private ObservableCollection waitFallWareList; + /// + /// 待落仓列表 + /// + public ObservableCollection WaitFallWareList { get => waitFallWareList; set { Set(ref waitFallWareList, value); } } + + + + private ObservableCollection waitSealBoxModels; /// /// 分箱列表 /// public ObservableCollection WaitSealBoxModels { get => waitSealBoxModels; set { Set(ref waitSealBoxModels, value); } } - + private ObservableCollection packTaskList; + /// + /// 打包任务列表 + /// + public ObservableCollection PackTaskList { get => packTaskList; set { Set(ref packTaskList, value); } } /// /// 查询时间段 @@ -143,27 +158,30 @@ namespace BBWY.Client.ViewModels.PackTask private string waitPackCount; /// - /// 待打包数 + /// 待打包任务数 /// public string WaitPackCount { get => waitPackCount; set { Set(ref waitPackCount, value); } } - private string waitSealBox; + private string waitSealBoxCount; /// - /// 带封箱数 + /// 带封箱任务数 /// - public string WaitSealBox { get => waitSealBox; set { Set(ref waitSealBox, value); } } + public string WaitSealBoxCount { get => waitSealBoxCount; set { Set(ref waitSealBoxCount, value); } } + + + + private string waitFallWareCount; + /// + /// 待落仓任务数 + /// + public string WaitFallWareCount { get => waitFallWareCount; set { Set(ref waitFallWareCount, value); } } + private string waitOutbound; /// - /// 待出库数 + /// 待出库任务数 /// public string WaitOutbound { get => waitOutbound; set { Set(ref waitOutbound, value); } } - //private int totalCount; - ///// - ///// 全部数量 - ///// - //public int TotalCount { get => totalCount; set { Set(ref totalCount, value); } } - public int PageIndex { get => pageIndex; set { Set(ref pageIndex, value); } } @@ -177,17 +195,6 @@ namespace BBWY.Client.ViewModels.PackTask private int? IsWorry { get; set; } public int? taskStatus { get; set; } - private ObservableCollection packTaskList; - /// - /// 动态数据表 - /// - public ObservableCollection PackTaskList { get => packTaskList; set { Set(ref packTaskList, value); } } - - //private ObservableCollection feesItems; - ///// - ///// 动态数据表 - ///// - //public ObservableCollection FeesItems { get => feesItems; set { Set(ref feesItems, value); } } public string searchDepartment; @@ -264,13 +271,27 @@ namespace BBWY.Client.ViewModels.PackTask CompeteSealBoxCommand = new RelayCommand(CompeteSealBox); SetSealBoxCommand = new RelayCommand(SetSealBox); + CompeteFallWareCommand = new RelayCommand(CompeteFallWare); + } + + /// + /// 完成落仓(todo:) + /// + /// + private void CompeteFallWare(object obj) + { + //throw new NotImplementedException(); } private void SetSealBox(object obj) { - SetSealBoxWindow setSealBoxWindow = new SetSealBoxWindow(); - setSealBoxWindow.SendBoxCount= boxCount => { - BoxCount = boxCount; + + var model = (SealBoxModel)obj; + + SetSealBoxWindow setSealBoxWindow = new SetSealBoxWindow(model); + setSealBoxWindow.SendBoxCount = boxCount => + { + model.SealBoxCount = boxCount; }; setSealBoxWindow.ShowDialog(); } @@ -278,6 +299,7 @@ namespace BBWY.Client.ViewModels.PackTask #region 事件绑定 + public ICommand CompeteFallWareCommand { get; set; } public ICommand CompeteSealBoxCommand { get; set; } public ICommand SetTaskStatusCommand { get; set; } @@ -323,13 +345,12 @@ namespace BBWY.Client.ViewModels.PackTask BatchPurchaseService batchPurchaseService; - public int BoxCount { get; set; } private void CompeteSealBox(object obj) { + var model = (SealBoxModel)obj; - - if (BoxCount<=0) + if (model.SealBoxCount == null || model.SealBoxCount.Value <= 0) { System.Windows.MessageBox.Show("请先设置封箱数量"); return; @@ -339,7 +360,7 @@ namespace BBWY.Client.ViewModels.PackTask CompeteSealBox competeSealBox = new CompeteSealBox(); competeSealBox.WareId = objList.WareId; - competeSealBox.BoxCount = BoxCount; + competeSealBox.BoxCount = model.SealBoxCount.Value; competeSealBox.TaskId = objList.SealBoxSkus.Select(s => s.TaskId).ToArray(); var res = packTaskService.CompeteSealBox(competeSealBox); if (res != null && res.Success) @@ -362,7 +383,7 @@ namespace BBWY.Client.ViewModels.PackTask case PackTaskState.未到货: case PackTaskState.部分到货: - if (System.Windows.MessageBox.Show("是否确认收货?","提示", + if (System.Windows.MessageBox.Show("是否确认收货?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes) return; @@ -476,7 +497,50 @@ namespace BBWY.Client.ViewModels.PackTask IsLoading = true; - if (TaskState == PackTaskState.待封箱) + if (TaskState == PackTaskState.待落仓) + Task.Factory.StartNew(() => + { + + + WaitFallWareList = new ObservableCollection(); + var datas = packTaskService.SearchWaitFallWareList(SearchShopName, taskId, SearchSkuId, PageIndex, PageSize); + if (datas != null && datas.Data != null && datas.Success) + { + var dataModel = datas.Data; + OrderCount = dataModel.TotalCount; + foreach (var item in dataModel.WaitFallWareList) + { + App.Current.Dispatcher.Invoke(new Action(() => + { + WaitFallWareList.Add(new WaitFallWareModel + { + AcceptUserNames = string.Join("|", item.AcceptUserNames), + DepartmentName = item.DepartmentName, + SealBoxSkus = item.SealBoxSkus, + ShopId = item.ShopId, + ShopName = item.ShopName, + WareId = item.WareId, + WareName = item.WareName, + SealBoxCount = item.SealBoxCount, + SealBoxId = item.SealBoxId, + + }); + })); + + } + } + else + { + //App.Current.Dispatcher.BeginInvoke(new Action(() => + //{ + // new TipsWindow("查不到数据").Show(); + //})); + } + IsLoadCount(); + IsLoading = false; + + }); + else if (TaskState == PackTaskState.待封箱) Task.Factory.StartNew(() => { @@ -518,7 +582,6 @@ namespace BBWY.Client.ViewModels.PackTask }); else - Task.Factory.StartNew(() => { PackTaskList = new ObservableCollection();//初始化数据 @@ -604,10 +667,6 @@ namespace BBWY.Client.ViewModels.PackTask } else { - //App.Current.Dispatcher.BeginInvoke(new Action(() => - //{ - // new TipsWindow("查不到数据").Show(); - //})); } IsLoadCount(); IsLoading = false; @@ -622,9 +681,9 @@ namespace BBWY.Client.ViewModels.PackTask private void IsLoadCount() { var packTaskResult = packTaskService.GetWareAllCount(); - if (packTaskResult != null && packTaskResult.Success) + if (packTaskResult != null && packTaskResult.Success && packTaskResult.Data != null) { - App.Current.Dispatcher.Invoke(() => + App.Current.Dispatcher.Invoke(new Action(() => { ArrivedCount = packTaskResult.Data.ArrivedCount.ToString(); NoArrivedCount = packTaskResult.Data.NoArrivedCount.ToString(); @@ -632,8 +691,9 @@ namespace BBWY.Client.ViewModels.PackTask WorryCount = packTaskResult.Data.WorryCount.ToString(); WaitOutbound = packTaskResult.Data.WaitOutbound?.ToString(); WaitPackCount = packTaskResult.Data.WaitPackCount?.ToString(); - WaitSealBox = packTaskResult.Data.WaitSealBox?.ToString(); - }); + WaitSealBoxCount = packTaskResult.Data.WaitSealBox?.ToString(); + WaitFallWareCount= packTaskResult.Data.WaitFallWareCount?.ToString(); + })); } } private void LoadIndex(int pageIndex) diff --git a/BBWY.Client/Views/PackTask/WaitFallWareControl.xaml b/BBWY.Client/Views/PackTask/WaitFallWareControl.xaml new file mode 100644 index 00000000..f78b1f81 --- /dev/null +++ b/BBWY.Client/Views/PackTask/WaitFallWareControl.xaml @@ -0,0 +1,296 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/PackTask/WaitFallWareControl.xaml.cs b/BBWY.Client/Views/PackTask/WaitFallWareControl.xaml.cs new file mode 100644 index 00000000..ff4a7f1f --- /dev/null +++ b/BBWY.Client/Views/PackTask/WaitFallWareControl.xaml.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +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.Navigation; +using System.Windows.Shapes; + +namespace BBWY.Client.Views.PackTask +{ + /// + /// WaitFallWareControl.xaml 的交互逻辑 + /// + public partial class WaitFallWareControl : UserControl + { + public WaitFallWareControl() + { + InitializeComponent(); + } + } +} diff --git a/BBWY.Client/Views/PackTask/WareHouseList.xaml b/BBWY.Client/Views/PackTask/WareHouseList.xaml index d28b50bc..a97aceb7 100644 --- a/BBWY.Client/Views/PackTask/WareHouseList.xaml +++ b/BBWY.Client/Views/PackTask/WareHouseList.xaml @@ -153,7 +153,9 @@ - + + + @@ -169,8 +171,10 @@ - + + + diff --git a/BBWY.Client/Views/SealBox/SetSealBoxWindow.xaml.cs b/BBWY.Client/Views/SealBox/SetSealBoxWindow.xaml.cs index 704c5da2..c84d2c4b 100644 --- a/BBWY.Client/Views/SealBox/SetSealBoxWindow.xaml.cs +++ b/BBWY.Client/Views/SealBox/SetSealBoxWindow.xaml.cs @@ -1,6 +1,15 @@ -using BBWY.Controls; +using BBWY.Client.Extensions; +using BBWY.Client.Models.PackTask; +using BBWY.Controls; +using NPOI.HSSF.UserModel; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing.Printing; +using System.IO; +using System.Reflection; using System.Text; using System.Windows; using System.Windows.Controls; @@ -9,7 +18,6 @@ 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.SealBox { @@ -18,15 +26,51 @@ namespace BBWY.Client.Views.SealBox /// public partial class SetSealBoxWindow : BWindow { - public SetSealBoxWindow() + public SetSealBoxWindow(SealBoxModel sealBoxModel) { + SealBoxModel = sealBoxModel; InitializeComponent(); + LoadPrints(); + } + + + SealBoxModel SealBoxModel { get; set; } + /// + /// 获取打印机名称 + /// + private void LoadPrints() + { + 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; + } + cbPrint.Items.Add(name); + } + if (cbPrint.Items.Count > selectIndex) + { + cbPrint.SelectedIndex = selectIndex; + } } public Action SendBoxCount { get; set; } private void BButton_Click(object sender, RoutedEventArgs e) { + + + + + int boxCount = 0; try { @@ -38,12 +82,103 @@ namespace BBWY.Client.Views.SealBox return; } - + PrintSealboxModel(cbPrint.Text, boxCount); //todo: 打印单子 if (SendBoxCount != null) SendBoxCount(boxCount); + this.Close(); + } + + private void PrintSealboxModel(string printName, int boxCount) + { + var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + var excel = $"{applicationPath}/Resources/ExccelModel/sealbox.xlsx"; + + var newExccel = $"{applicationPath}/Resources/ExccelModel/newsealbox.xlsx"; + if (File.Exists(newExccel)) + { + File.Delete(newExccel); + } + FileStream fs = new FileStream(excel, FileMode.Open, FileAccess.Read); + XSSFWorkbook wb = new XSSFWorkbook(fs); + var sheet = wb.GetSheetAt(0); // 得到第一个sheet + + var nameCell = sheet.GetRow(0).GetCell(0); // name列,第2行 + var ageCell = sheet.GetRow(3).GetCell(0); // age列,第2行 + + + XSSFWorkbook wb2 = new XSSFWorkbook(); + //wb2.CreateSheet("Sheet1"); + sheet.CopyTo(wb2, "Sheet1", true, false); + var sheet2 = wb2.GetSheet("Sheet1"); + + + var nameCell2 = sheet2.GetRow(0).GetCell(1); + nameCell2.SetCellValue(SealBoxModel.ShopName); + + sheet2.GetRow(3).GetCell(1).SetCellValue(SealBoxModel.WareName); + + StringBuilder sb = new StringBuilder(); + int totalCount = 0; + for (int i = 0; i < SealBoxModel.SealBoxSkus.Count; i++) + { + var title = SealBoxModel.SealBoxSkus[i].SkuTitle; + //if (title.Length>5) + //{ + // title = title.Substring(0,5); + //} + totalCount += SealBoxModel.SealBoxSkus[i].SkuCount; + sheet2.GetRow(i + 6).GetCell(1).SetCellValue($"名称:{title}"); + sheet2.GetRow(i + 6).GetCell(2).SetCellValue($"SKU:{SealBoxModel.SealBoxSkus[i].SkuId}"); + sheet2.GetRow(i + 6).GetCell(3).SetCellValue($"数量:{SealBoxModel.SealBoxSkus[i].SkuCount}"); + + } + sheet2.GetRow(25).GetCell(1).SetCellValue(totalCount); + sheet2.GetRow(28).GetCell(1).SetCellValue(boxCount); + FileStream fs1 = new FileStream(newExccel, FileMode.OpenOrCreate, FileAccess.ReadWrite); + wb2.Write(fs1); + fs1.Close(); + fs1.Dispose(); + } + + } + + public class PrintDocumentAdapter : PrintDocument + { + FileStream fs; + public PrintDocumentAdapter(FileStream fs) + { + this.fs = fs; + } + + protected override void OnPrintPage(PrintPageEventArgs e) + { + if (fs == null) return; + + IWorkbook workbook = null; + if (fs.Name.EndsWith(".xls")) // XLS文件 + { + workbook = new HSSFWorkbook(fs); + } + else if (fs.Name.EndsWith(".xlsx")) // XLSX文件 + { + workbook = new XSSFWorkbook(fs); + } + + if (workbook != null) + { + ISheet sheet = workbook.GetSheetAt(0); // 第一个sheet + + // 使用NPOI的ExcelPrinting类打印sheet + ExcelPrinting printer = new ExcelPrinting(sheet); + printer.PrintArea(e.Graphics, e.MarginBounds, sheet.SheetName); + + fs.Close(); + } + base.OnPrintPage(e); } } } diff --git a/BBWY.Client/Views/PackTask/WaitSealBoxControl.xaml b/BBWY.Client/Views/SealBox/WaitSealBoxControl.xaml similarity index 86% rename from BBWY.Client/Views/PackTask/WaitSealBoxControl.xaml rename to BBWY.Client/Views/SealBox/WaitSealBoxControl.xaml index e9d6efa6..08d8d329 100644 --- a/BBWY.Client/Views/PackTask/WaitSealBoxControl.xaml +++ b/BBWY.Client/Views/SealBox/WaitSealBoxControl.xaml @@ -29,36 +29,42 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - + + + + -