using BBWY.Client.APIServices; using BBWY.Client.Helpers; using BBWY.Client.Models; using BBWY.Client.Views.Order; using BBWY.Common.Models; using BBWY.Controls; using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Messaging; using Microsoft.Win32; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading; using System.Windows.Input; using System.Windows; using BBWY.Common.Extensions; using System.Threading.Tasks; using BBWY.Client.Views.PackTask; using HandyControl.Tools.Extension; using Newtonsoft.Json; using BBWY.Client.Models.APIModel.Response.PackTask; using BBWY.Client.Models.PackTask; using WebSocketSharp; using BBWY.Client.Models.APIModel; using BBWY.Client.Views.SealBox; using BBWY.Client.Models.SealBox; using BBWY.Client.ViewModels.SealBox; using BBWY.Client.Views.FallWare; using BBWY.Client.Models.FallWare; namespace BBWY.Client.ViewModels.PackTask { /// /// /// public partial class TaskListViewModel : BaseVM, IDenpendency//注入服务 { #region 属性绑定 private string sealBoxWaitConfigureCount; /// /// 封箱 待配置数 /// public string SealBoxWaitConfigureCount { get => sealBoxWaitConfigureCount; set { Set(ref sealBoxWaitConfigureCount, value); } } private string sealBoxConfiguredCount; /// ///封箱 已配置数 /// public string SealBoxConfiguredCount { get => sealBoxConfiguredCount; set { Set(ref sealBoxConfiguredCount, value); } } private SealBoxConfigureType sealBoxConfigureType; /// /// 封箱配置状态 /// public SealBoxConfigureType SealBoxConfigureType { get => sealBoxConfigureType; set { Set(ref sealBoxConfigureType, value); } } //private SealBoxConfigureType fallWareConfigureType; ///// ///// 落仓配置状态 ///// //public SealBoxConfigureType FallWareConfigureType { get => fallWareConfigureType; set { Set(ref fallWareConfigureType, value); } } private ObservableCollection sealBoxWaitConfigureList; /// /// 封箱待配置列表 /// public ObservableCollection SealBoxWaitConfigureList { get => sealBoxWaitConfigureList; set { Set(ref sealBoxWaitConfigureList, value); } } private ObservableCollection sealBoxConfiguredList; /// /// 封箱已配置列表 /// public ObservableCollection SealBoxConfiguredList { get => sealBoxConfiguredList; set { Set(ref sealBoxConfiguredList, value); } } private ObservableCollection fallWareWaitConfigureList; /// /// 落仓待配置列表 /// public ObservableCollection FallWareWaitConfigureList { get => fallWareWaitConfigureList; set { Set(ref fallWareWaitConfigureList, value); } } private ObservableCollection fallWareConfiguredList; /// /// 落仓已配置列表 /// public ObservableCollection FallWareConfiguredList { get => fallWareConfiguredList; set { Set(ref fallWareConfiguredList, value); } } ///// ///// 查询时间段 ///// //private DateTime startTime; //public DateTime StartTime { get => startTime; set { Set(ref startTime, value); } } //private DateTime endTime; //public DateTime EndTime { get => endTime; set { Set(ref endTime, value); } } /// /// 查询任务id /// private string searchTaskId; public string SearchTaskId { get => searchTaskId; set { Set(ref searchTaskId, value); } } /// /// 查询Sku /// private string searchSkuId; public string SearchSkuId { get => searchSkuId; set { Set(ref searchSkuId, value); } } private TaskState? taskState; /// /// 任务状态 /// public TaskState? TaskState { get => taskState; set { Set(ref taskState, value); } } private int pageIndex = 1; private int pageSize = 10; public int PageIndex { get => pageIndex; set { Set(ref pageIndex, value); } } public int PageSize { get => pageSize; set { Set(ref pageSize, value); } } private int orderCount;//总数量 public int OrderCount { get => orderCount; set { Set(ref orderCount, value); } } /// /// 未到货数量 /// public string NoArrivedCount { get => noArrivedCount; set { Set(ref noArrivedCount, value); } } private string noArrivedCount; private string someArrivedCount; /// /// 部分到货数量 /// public string SomeArrivedCount { get => someArrivedCount; set { Set(ref someArrivedCount, value); } } private string arrivedCount; /// /// 已到货数量 /// public string ArrivedCount { get => arrivedCount; set { Set(ref arrivedCount, value); } } private bool isLoading; public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } private string waitPackCount; /// /// 待打包任务数 /// public string WaitPackCount { get => waitPackCount; set { Set(ref waitPackCount, value); } } private string waitSealBoxCount; /// /// 带封箱任务数 /// 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 string waitCompleted; /// /// 待完成任务数 /// public string WaitCompleted { get => waitCompleted; set { Set(ref waitCompleted, value); } } private SealBoxService sealBoxService; private PackTaskService packTaskService; WorkProcessService workProcessService; public int? taskStatus { get; set; } private ObservableCollection packTaskList; /// /// 动态数据表 /// public ObservableCollection PackTaskList { get => packTaskList; set { Set(ref packTaskList, value); } } #endregion public TaskListViewModel(PackTaskService packTaskService, GlobalContext globalContext, ProductService productService, ConsumableService consumableService, WorkProcessService workProcessService, IncreateServiceService increateServiceService, SealBoxService sealBoxService) { this.globalContext = globalContext; this.productService = productService; this.consumableService = consumableService; this.workProcessService = workProcessService; this.increateServiceService = increateServiceService; this.packTaskService = packTaskService; PackTaskList = new ObservableCollection();//初始化数据 SetTaskStateCommand = new RelayCommand(SetTaskState); SetSealBoxConfigureTypeCommand = new RelayCommand(s => { PageIndex = 1; SealBoxConfigureType = s; Task.Factory.StartNew(() => SearchTaskList()); }); CreateTaskCommand = new RelayCommand(CreateTask); SearchTaskCommand = new RelayCommand(() => { PageIndex = 1; Task.Factory.StartNew(() => SearchTaskList()); //手动点击查询订单 }); TaskPageIndexChangedCommand = new RelayCommand(p => { LoadIndex(p.PageIndex); }); OpenSkuDetailCommand = new RelayCommand(OpenSkuDetail); DeletedTaskCommand = new RelayCommand(DeletedTask); ConfiguredSealBoxCommand = new RelayCommand(ConfiguredSealBox); UpdateSealBoxConfiguredCommand = new RelayCommand(UpdateSealBoxConfigured); //StartTime = DateTime.Now.Date; //EndTime = DateTime.Now.Date; IsLoading = false; //加载数据 SetTaskState(null); this.sealBoxService = sealBoxService; SealBoxConfigureType = SealBoxConfigureType.待配置; SetFallWareConfiguredCommand = new RelayCommand(SetFallWareConfigured); } private void SetFallWareConfigured(object obj) { var fallware = obj as FallWareConfiguredModel; JDWareBoxModel model = new JDWareBoxModel { ShopName = globalContext.User.Shop.ShopName, WareName = fallware.WareName, SealBoxId = fallware.SealBoxId, ProductCount = fallware.SealBoxTotalCount, BoxCount = fallware.BoxCount.Value, PrewOrder = fallware.PrewOrder, ProductTitle = fallware.ProductTitle, PurchaseOrder = fallware.PurchaseOrder, WaybillNo = fallware.WaybillNo }; //if (fallware.WareType== WareType.京仓) //{ //SetJDWareBoxWindow window = new SetJDWareBoxWindow(model,sealBoxService,fallware.WareType.Value,ReflashTask); //window.Show(); var w = new SetJDWareBoxWindow2(model, sealBoxService, fallware.WareType.Value, ReflashTask); w.ShowDialog(); //} //if (fallware.WareType == WareType.云仓) //{ // SetCloudWareBoxWindow window = new SetCloudWareBoxWindow(model, sealBoxService, fallware.WareType.Value, ReflashTask); // window.Show(); //} } private void UpdateSealBoxConfigured(SealBoxConfiguredModel model) { var sealBoxId = model.SealBoxId; var taskIds = model.SealBoxConfigureTasks.Select(s => s.TaskId).ToArray(); var updateSealBoxConfig = sealBoxService.GetUpdateSealBoxConfigured(sealBoxId, taskIds); if (updateSealBoxConfig == null) { MessageBox.Show("网络异常,获取不到带封箱数据"); return; } if (!updateSealBoxConfig.Success || updateSealBoxConfig.Data == null) { MessageBox.Show(updateSealBoxConfig.Msg); return; } SealBoxConfigureWindow sealBoxConfigureWindow = new SealBoxConfigureWindow(updateSealBoxConfig.Data.UpdateSealBoxConfiguredTaskDatas, ReflashTask, sealBoxId); sealBoxConfigureWindow.Show(); } private void ConfiguredSealBox() { var waitSealBoxRes = sealBoxService.GetSealBoxWaitConfigureList(null, null, null, null, null);//获取所有待封装列表 if (waitSealBoxRes == null) { MessageBox.Show("网络异常,获取不到带封箱数据"); return; } if (!waitSealBoxRes.Success || waitSealBoxRes.Data == null) { MessageBox.Show(waitSealBoxRes.Msg); return; } if (waitSealBoxRes.Data.TotalCount <= 0) { MessageBox.Show("已全部封箱!"); return; } var taskIds = waitSealBoxRes.Data.SealBoxWaitConfigureModels.Select(w => w.TaskId).ToArray(); var updateSealBoxConfig = sealBoxService.GetUpdateSealBoxConfigured(0, taskIds); if (updateSealBoxConfig == null) { MessageBox.Show("网络异常,获取不到带封箱数据"); return; } if (!updateSealBoxConfig.Success || updateSealBoxConfig.Data == null) { MessageBox.Show(updateSealBoxConfig.Msg); return; } SealBoxConfigureWindow sealBoxConfigureWindow = new SealBoxConfigureWindow(updateSealBoxConfig.Data.UpdateSealBoxConfiguredTaskDatas, ReflashTask, 0); sealBoxConfigureWindow.Show(); } private void DeletedTask(object obj) { var packTaskmodel = (PackTaskModel)obj; if (!packTaskmodel.OrderId.IsNullOrEmpty()) { System.Windows.MessageBox.Show($"暂不支持删除采购组的任务,如要删除,请到采购列表取消订单:{packTaskmodel.OrderId}"); return; } MessageBoxResult result = MessageBox.Show("确定取消任务?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result != MessageBoxResult.Yes) return; packTaskService.DeletedTask(packTaskmodel.TaskId); Task.Factory.StartNew(() => SearchTaskList()); } private void IsLoadCount() { var packTaskResult = packTaskService.GetTaskAllCount(globalContext.User.Shop.ShopId.ToString()); if (packTaskResult != null && packTaskResult.Success && packTaskResult.Data != null) { App.Current.Dispatcher.Invoke(new Action(() => { ArrivedCount = packTaskResult.Data.ArrivedCount.ToString(); NoArrivedCount = packTaskResult.Data.NoArrivedCount.ToString(); SomeArrivedCount = packTaskResult.Data.SomeArrivedCount.ToString(); //WorryCount = packTaskResult.Data.WorryCount.ToString(); WaitOutbound = packTaskResult.Data.WaitOutbound?.ToString(); WaitPackCount = packTaskResult.Data.WaitPackCount?.ToString(); WaitSealBoxCount = packTaskResult.Data.WaitSealBox?.ToString(); WaitFallWareCount = packTaskResult.Data.WaitFallWareCount?.ToString(); WaitCompleted = packTaskResult.Data.WaitCompleted?.ToString(); })); } } private void LoadIndex(int pageIndex) { PageIndex = pageIndex;// SearchTaskList(); } #region 事件绑定 /// /// 设置落仓配置信息(上传材料) /// public ICommand SetFallWareConfiguredCommand { get; set; } /// /// 修改封箱数据 /// public ICommand UpdateSealBoxConfiguredCommand { get; set; } /// /// 配置封箱策略 /// public ICommand ConfiguredSealBoxCommand { get; set; } /// /// 待配置 /已配置 /// public ICommand SetSealBoxConfigureTypeCommand { get; set; } /// /// 筛选数据 /// public ICommand SetTaskStateCommand { get; set; } /// /// 搜索数据 /// public ICommand SearchTaskCommand { get; set; } /// /// 创建任务 /// public ICommand CreateTaskCommand { get; set; } /// /// 页面改变事件 /// public ICommand TaskPageIndexChangedCommand { get; set; } /// /// 打开图片链接 /// public ICommand OpenSkuDetailCommand { get; set; } /// /// 删除任务 /// public ICommand DeletedTaskCommand { get; set; } public void SetTaskState(TaskState? taskState) { PageIndex = 1; TaskState = taskState; SearchTaskList(); } private ConsumableService consumableService; private IncreateServiceService increateServiceService; public void ReflashTask()//刷新界面 { SearchTaskList(); } private List waitSealBoxTaskStates = new List { Models.TaskState.待落仓, Models.TaskState.待封箱 };//配置封箱的任务状态范围 private bool IsStartThread = false; private Thread qualityOverTimeThread = null; private Thread packOverTimeThread = null; private Thread sealboxOverTimeThread = null; private Thread fallwareOverTimeThread = null; /// /// 搜索任务列表 /// public void SearchTaskList() { IsStartThread = false; long? taskId = null; try { if (SearchTaskId != null && !string.IsNullOrEmpty(SearchTaskId.Trim())) taskId= Convert.ToInt64(SearchTaskId); } catch { System.Windows.MessageBox.Show("任务id必须为数字"); return; } IsLoading = true; if (TaskState == null || !waitSealBoxTaskStates.Contains(TaskState.Value)) Task.Factory.StartNew(() => { try { PackTaskList = new ObservableCollection();//初始化数据 var datas = packTaskService.GetTaskList(SearchSkuId, SearchTaskId, this.TaskState, PageIndex, PageSize); if (datas != null && datas.Data != null && datas.Success) { var dataModel = datas.Data; OrderCount = dataModel.TotalCount; foreach (var item in dataModel.Items) { var data = new PackTaskModel() { Brand = item.Brand, SkuId = item.SkuId, AcceptName = item.UserName, Availability = (Availability)item.Availability, BasicPack = (BasicPack)item.BasicPack, DepartmentName = item.DepartmentName, CertificatePosition = (CertificatePosition)item.CertificatePosition, GoodsNumber = item.GoodsNumber, Increment1 = item.Increment1, ItemList = new List() { new SkuMessage { BrandName = item.BrandName, GoodsNo = item.ProductItemNum, Logo= item.Logo, ShopName = item.ShopName, SkuName = item.SkuName, SkuId = item.SkuId } }, MarkMessage = item.MarkMessage, PackType = (PackType)item.PackType, PositionType = item.PositionType, SkuCount = item.SkuCount, SkuTitle = item.SkuGoodsTitle, TaskId = item.TaskId, EndTime = item.CreateTime, BrandName = item.BrandName, OrderId = item.OrderId, TaskState = item.TaskState, QualityCompletionOverTime = item.QualityCompletionOverTime, PackCompletionOverTime = item.PackCompletionOverTime, ExpressOrderList = item.ExpressOrderList, // IsWorry = (Worry)item.IsWorry, }; if (item.BarCodeDTO != null && item.BarCodeDTO.Id > 0) { data.BarCodeModel = item.BarCodeDTO; } if (item.Cers != null) { data.CertificateModel = item.Cers; } if (item.FeesItemResponse != null) { data.FeesItemResponse = item.FeesItemResponse; data.FeesMoney = item.FeesItemResponse.SingleFees; data.IsShowFees = data.FeesMoney > 0 ? true : false; data.FeesItemResponse.DiscountSingleFees = item.FeesItemResponse.SingleFees * item.FeesItemResponse.disCount; data.FeesItemResponse.DiscountAllFees = item.FeesItemResponse.AllFees * item.FeesItemResponse.disCount; } else { data.IsShowFees = false; } if (item.PackUserName != null && item.PackUserName.Count() > 0) { data.PackUser = string.Join("\r\n", item.PackUserName); } data.ReflashTask = ReflashTask; App.Current.Dispatcher.BeginInvoke(new Action(() => { PackTaskList.Add(data); })); } Thread.Sleep(500); //任务状态为待验收 var packtasks = PackTaskList.Where(p => p.TaskState == Models.TaskState.待验收 && p.QualityCompletionOverTime != null).ToList(); if (packtasks.Count() > 0 && TaskState == Models.TaskState.待验收) { //if (qualityOverTimeThread!=null) //{ // qualityOverTimeThread.Abort(); //} qualityOverTimeThread = new Thread(() => { IsStartThread = true; while (IsStartThread) { App.Current.Dispatcher.BeginInvoke(new Action(() => { foreach (var item in packtasks) { var datetime = item.QualityCompletionOverTime.Value.Subtract(DateTime.Now); if (datetime.TotalMilliseconds > 0) { item.IsQualityOverTime = false; //item.QualityRemainTime = $"{datetime.Days}天{datetime.Hours}小时{datetime.Minutes}分{datetime.Seconds}秒"; item.QualityRemainTime = $"{datetime.Days}天{datetime.Hours}小时{datetime.Minutes}分"; } else { item.IsQualityOverTime = true; //item.QualityRemainTime = $"{-datetime.Days}天{-datetime.Hours}小时{-datetime.Minutes}分{-datetime.Seconds}秒"; item.QualityRemainTime = $"{-datetime.Days}天{-datetime.Hours}小时{-datetime.Minutes}分"; } } })); Thread.Sleep(1000); } }); //任务倒计时数据 qualityOverTimeThread.IsBackground = true; qualityOverTimeThread.Start(); } var packCompletedTasks = PackTaskList.Where(p => p.TaskState == Models.TaskState.待打包 && p.PackCompletionOverTime != null).ToList(); if (packCompletedTasks.Count() > 0 && TaskState == Models.TaskState.待打包) { //if (packOverTimeThread!=null) //{ // packOverTimeThread.Abort(); //} packOverTimeThread = new Thread(() => { IsStartThread = true; while (IsStartThread) { App.Current.Dispatcher.BeginInvoke(new Action(() => { foreach (var item in packCompletedTasks) { var datetime = item.PackCompletionOverTime.Value.Subtract(DateTime.Now); if (datetime.TotalMilliseconds > 0) { item.IsPackOverTime = false; item.PackRemainTime = $"{datetime.Days}天{datetime.Hours}小时{datetime.Minutes}分"; } else { item.IsPackOverTime = true; item.PackRemainTime = $"{-datetime.Days}天{-datetime.Hours}小时{-datetime.Minutes}分"; } } })); Thread.Sleep(1000); } }); //任务倒计时数据 packOverTimeThread.IsBackground = true; packOverTimeThread.Start(); } //任务状态为待打包 } else { if (datas != null) System.Windows.MessageBox.Show(datas.Msg); } IsLoadCount(); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } IsLoading = false; }); if (TaskState != null && waitSealBoxTaskStates.Contains(TaskState.Value))//封箱操作 { if (TaskState == Models.TaskState.待封箱) Task.Factory.StartNew(() => { try { if (SealBoxConfigureType == SealBoxConfigureType.待配置) { SealBoxWaitConfigureList = new ObservableCollection(); ApiResponse sealBoxWaitRes = sealBoxService.GetSealBoxWaitConfigureList(SearchSkuId, SearchTaskId, PageSize, PageIndex); if (sealBoxWaitRes == null) { System.Windows.MessageBox.Show("网络异常"); IsLoading = false; return; } if (!sealBoxWaitRes.Success || sealBoxWaitRes.Data == null) { System.Windows.MessageBox.Show(sealBoxWaitRes.Msg); IsLoading = false; return; } App.Current.Dispatcher.BeginInvoke(new Action(() => { OrderCount = sealBoxWaitRes.Data.TotalCount; })); foreach (var item in sealBoxWaitRes.Data.SealBoxWaitConfigureModels) { App.Current.Dispatcher.BeginInvoke(new Action(() => { SealBoxWaitConfigureList.Add(item); })); } } if (SealBoxConfigureType == SealBoxConfigureType.已配置) { SealBoxConfiguredList = new ObservableCollection(); var sealBoxRes = sealBoxService.GetSealBoxConfiguredList(PositionState.待封箱, SearchSkuId, SearchTaskId, globalContext.User.Shop.ShopId.ToString(), PageSize, PageIndex); if (sealBoxRes == null) { System.Windows.MessageBox.Show("网络异常"); IsLoading = false; return; } if (!sealBoxRes.Success || sealBoxRes.Data == null) { System.Windows.MessageBox.Show(sealBoxRes.Msg); IsLoading = false; return; } App.Current.Dispatcher.BeginInvoke(new Action(() => { OrderCount = sealBoxRes.Data.TotalCount; })); foreach (var item in sealBoxRes.Data.SealBoxConfiguredModels) { App.Current.Dispatcher.BeginInvoke(new Action(() => { SealBoxConfiguredList.Add(item); })); } Thread.Sleep(500); var sealboxTasks = SealBoxConfiguredList.Where(p => p.SealBoxPackOverTime != null).ToList(); if (sealboxTasks.Count() > 0 && TaskState == Models.TaskState.待封箱) { sealboxOverTimeThread = new Thread(() => { IsStartThread = true; while (IsStartThread) { App.Current.Dispatcher.BeginInvoke(new Action(() => { foreach (var item in sealboxTasks) { var datetime = item.SealBoxPackOverTime.Value.Subtract(DateTime.Now); if (datetime.TotalMilliseconds > 0) { item.IsSealBoxOverTime = false; item.SealBoxRemainTime = $"{datetime.Hours}小时{datetime.Minutes}分"; } else { item.IsSealBoxOverTime = true; item.SealBoxRemainTime = datetime.Days == 0 ? $"{-datetime.Hours}小时{-datetime.Minutes}分" : $"{-datetime.Days}天{-datetime.Hours}小时{-datetime.Minutes}分"; } } })); Thread.Sleep(1000); } }); //任务倒计时数据 sealboxOverTimeThread.IsBackground = true; sealboxOverTimeThread.Start(); } } IsLoadSealBoxCount(); IsLoadCount(); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } IsLoading = false; }); if (TaskState == Models.TaskState.待落仓) Task.Factory.StartNew(() => { try { if (SealBoxConfigureType == SealBoxConfigureType.待配置) { FallWareWaitConfigureList = new ObservableCollection(); var fallWareRes = sealBoxService.SearchFallWareConfiguredList(PositionState.待落仓, taskId, SearchSkuId, PageIndex, PageSize); if (fallWareRes == null) { System.Windows.MessageBox.Show("网络异常"); IsLoading = false; return; } if (!fallWareRes.Success || fallWareRes.Data == null) { System.Windows.MessageBox.Show(fallWareRes.Msg); IsLoading = false; return; } App.Current.Dispatcher.BeginInvoke(new Action(() => { OrderCount = fallWareRes.Data.TotalCount; })); foreach (var item in fallWareRes.Data.FallWareConfiguredModels) { App.Current.Dispatcher.BeginInvoke(new Action(() => { FallWareWaitConfigureList.Add(item); })); } Thread.Sleep(100); var fallWareTasks = FallWareWaitConfigureList.Where(p => p.SetPurchaseOrderOverTime != null).ToList(); if (fallWareTasks.Count() > 0 && TaskState == Models.TaskState.待落仓&& SealBoxConfigureType == SealBoxConfigureType.待配置) { //if (packOverTimeThread!=null) //{ // packOverTimeThread.Abort(); //} fallwareOverTimeThread = new Thread(() => { IsStartThread = true; while (IsStartThread) { App.Current.Dispatcher.BeginInvoke(new Action(() => { foreach (var item in fallWareTasks) { var datetime = item.SetPurchaseOrderOverTime.Value.Subtract(DateTime.Now); if (datetime.TotalMilliseconds > 0) { item.IsFallWareOverTime = false; item.FallWareRemainTime = $"{datetime.Hours}小时{datetime.Minutes}分"; } else { item.IsFallWareOverTime = true; item.FallWareRemainTime = datetime.Days == 0 ? $"{-datetime.Hours}小时{-datetime.Minutes}分" : $"{-datetime.Days}天{-datetime.Hours}小时{-datetime.Minutes}分"; } } })); Thread.Sleep(1000); } }); //任务倒计时数据 fallwareOverTimeThread.IsBackground = true; fallwareOverTimeThread.Start(); } } if (SealBoxConfigureType == SealBoxConfigureType.已配置) { FallWareConfiguredList = new ObservableCollection(); var fallWareRes = sealBoxService.SearchFallWareConfiguredList(PositionState.已配置待落仓, taskId, SearchSkuId, PageIndex, PageSize); if (fallWareRes == null) { System.Windows.MessageBox.Show("网络异常"); IsLoading = false; return; } if (!fallWareRes.Success || fallWareRes.Data == null) { System.Windows.MessageBox.Show(fallWareRes.Msg); IsLoading = false; return; } App.Current.Dispatcher.BeginInvoke(new Action(() => { OrderCount = fallWareRes.Data.TotalCount; })); foreach (var item in fallWareRes.Data.FallWareConfiguredModels) { App.Current.Dispatcher.BeginInvoke(new Action(() => { FallWareConfiguredList.Add(item); })); } } IsLoadFallWareCount(); IsLoadCount(); } catch (Exception ex) { MessageBox.Show(ex.Message); } IsLoading = false; }); } } GlobalContext globalContext; ProductService productService; private void IsLoadFallWareCount() { var res = sealBoxService.GetFallWareConfigureCounts(globalContext.User.Shop.ShopId.ToString()); if (res != null && res.Success && res.Data != null) { SealBoxWaitConfigureCount = res.Data.FallWareWaitConfigureCount.ToString(); SealBoxConfiguredCount = res.Data.FallWareConfiguredCount.ToString(); } } private void IsLoadSealBoxCount() { var res = sealBoxService.GetSealBoxPackStateCount(); if (res != null && res.Success && res.Data != null) { SealBoxWaitConfigureCount = res.Data.SealBoxWaitConfigureCount.ToString(); SealBoxConfiguredCount = res.Data.SealBoxConfiguredCount.ToString(); } } /// /// 展示发布任务页面 /// public void CreateTask() { PublishTaskWindow publish = new PublishTaskWindow(ReflashTask); publish.Show(); } /// /// 弹出条形码可视化界面 /// public void ShowBarCodeWindow() { } /// /// 弹出合格证 可视化页面 /// public void ShowCertificateWindow() { } /// /// 筛选任务状态数据(根据TaskList数据) /// public void SelectTaskStatus() { } #endregion private void OpenSkuDetail(object param) { var paramList = (object[])param; // var orderId = paramList[0].ToString(); var skuId = paramList.Last().ToString(); var url = $"https://item.jd.com/{skuId}.html"; try { System.Diagnostics.Process.Start("explorer.exe", url); } catch (Exception ex) { Clipboard.SetText(url); MessageBox.Show($"{ex.Message}\r\n调用浏览器失败,网页链接已复制到剪切板,请手动打开浏览器访问", "提示"); } } } }