using BBWY.Client.APIServices; using BBWY.Client.APIServices.QiKu; using BBWY.Client.Models.APIModel; using BBWY.Client.Models.APIModel.Response.PackTask; using BBWY.Client.ViewModels; using BBWY.Client.ViewModels.PackTask; using BBWY.Client.Views.PackTask; using BBWY.Client.Views.QualityTask; using BBWY.Client.Views.QualityTipWindows; using BBWY.Client.Views.SplitTask; using BBWY.Client.Views.StorePickSelf; using GalaSoft.MvvmLight.Command; using Microsoft.Extensions.DependencyInjection; using NPOI.Util; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using WebSocketSharp; namespace BBWY.Client.Models { /// /// 打包任务 数据绑定 /// public class PackTaskModel : BaseVM { private string taskIdRemark; /// ///任务备注(原任务:10000 子任务:10000-1) /// public string TaskIdRemark { get => taskIdRemark; set { Set(ref taskIdRemark, value); } } private bool showSendMsg = false; /// /// 展示留言信息 /// public bool ShowSendMsg { get => showSendMsg; set { Set(ref showSendMsg, value); } } private string taskMarkMsg; /// /// 展示留言信息 /// public string TaskMarkMsg { get => taskMarkMsg; set { Set(ref taskMarkMsg, value); } } private bool showMoreMsg = true; /// /// 展示留言信息 /// public bool ShowMoreMsg { get => showMoreMsg; set { Set(ref showMoreMsg, value); } } private bool isShowFees; public bool IsShowFees { get => isShowFees; set { Set(ref isShowFees, value); } } private long id; public long Id { get => id; set { Set(ref id, value); } } public ICommand PrintBarcodeCommand { get; set; } public ICommand PrintCerCommand { get; set; } public ICommand LookCerCommand { get; set; } public ICommand LookBarCommand { get; set; } public ICommand SetServiceCommand { get; set; } /// /// 修改任务 /// public ICommand UpdateTaskCommand { get; set; } /// /// 任务拆分 /// public ICommand TaskSplitCommand { get; set; } /// /// 挂起 /// public ICommand PackagingTaskExceptionCommand { get; set; } /// /// 商家自取 /// public ICommand StoreGetBySelfCommand { get; set; } /// /// 包装任务释放挂起 /// public ICommand DisposeTaskCommand { get; set; } /// /// 删除任务 /// public ICommand DeletedTaskCommand { get; set; } public Action ReflashTask { get; set; } private void UpdateTask() { try { if (!this.SkuPurchaseSchemeId.IsNullOrEmpty())//B端有采购方案 { UpdatePurchaseTaskWindow updatePurchaseWindow = new UpdatePurchaseTaskWindow(this, ReflashTask); if (!updatePurchaseWindow.IsClosed) updatePurchaseWindow.ShowDialog(); return; } if (!OrderId.IsNullOrEmpty() && SkuPurchaseSchemeId.IsNullOrEmpty())//B端无采购方案 ,手动添加合格证 { PublishTaskWindow publishB = new PublishTaskWindow(ReflashTask, this, SaveType.B端); publishB.ShowDialog(); return; } PublishTaskWindow publish = new PublishTaskWindow(ReflashTask, this, SaveType.C端); publish.ShowDialog(); } catch (Exception) { } } private IServiceProvider sp; public PackTaskModel() { sp = (App.Current as App).ServiceProvider; using (var ss = sp.CreateScope()) { packTaskService = ss.ServiceProvider.GetRequiredService(); packTaskAbortService = ss.ServiceProvider.GetRequiredService(); } PrintBarcodeCommand = new RelayCommand(PrintBarcode); PrintCerCommand = new RelayCommand(PrintCer); LookBarCommand = new RelayCommand(LookBar); LookCerCommand = new RelayCommand(LookCer); SetServiceCommand = new RelayCommand(SetService); UpdateTaskCommand = new RelayCommand(UpdateTask); DeletedTaskCommand = new RelayCommand(DeletedTask); DisposeTaskCommand = new RelayCommand(DisposeTask); StoreGetBySelfCommand = new RelayCommand(StoreGetBySelf); PackagingTaskExceptionCommand = new RelayCommand(PackagingTaskException); TaskSplitCommand = new RelayCommand(TaskSplit); } PackTaskService packTaskService; PackTaskAbortService packTaskAbortService; private void PackagingTaskException(long taskId) { var wareVm = (App.Current as App).ServiceProvider.GetRequiredService(); AddExceptionWindow addExceptionWindow = new AddExceptionWindow(packTaskAbortService, taskId, Models.TaskState.待包装, ReflashTask, wareVm.IsCanPackModelList, wareVm.ShelvesNumberList, wareVm.FloorNumberList); addExceptionWindow.ShowDialog(); } private void TaskSplit(PackTaskModel model) { SplitTaskWindow addExceptionWindow = new SplitTaskWindow(packTaskService, model.TaskId, model.TaskState, ReflashTask); addExceptionWindow.ShowDialog(); } public void StoreGetBySelf(long taskId) { //MessageBoxResult result = System.Windows.MessageBox.Show($"确定商家自取,任务id:{taskId}?", "提示", // MessageBoxButton.YesNo, // MessageBoxImage.Warning); //if (result != MessageBoxResult.Yes) return; var data = packTaskService.GetStoreGetSelfData(taskId); if (!data.Success) { MessageBox.Show(data?.Msg); return; } StorePickProductWindow sorePickProductWindow = new StorePickProductWindow(data.Data, (count, UserName) => { var res = packTaskService.StoreGetBySelfV3(taskId, count, UserName); if (res == null) { return false; } if (!res.Success) { System.Windows.MessageBox.Show(res.Msg, "错误信息"); return false; } Task.Factory.StartNew(() => ReflashTask?.Invoke()); return true; }, false); sorePickProductWindow.ShowDialog(); } /// /// 手动释放挂起 /// /// private void DisposeTask(long taskId) { if (System.Windows.MessageBox.Show("是否释放挂起?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes) return; var res = packTaskAbortService.DisposedPackTask(taskId); if (res == null || !res.Success) { System.Windows.MessageBox.Show(res?.Msg); return; } ReflashTask?.Invoke(); } private void DeletedTask(object obj) { var packTaskmodel = (PackTaskModel)obj; MessageBoxResult result = System.Windows.MessageBox.Show($"确定取消任务{packTaskmodel.TaskIdRemark}?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result != MessageBoxResult.Yes) return; packTaskService.DeletedTask(packTaskmodel.TaskId); Task.Factory.StartNew(() => ReflashTask?.Invoke()); } private void SetService() { if (this.PackProcessType == null && this.FeesMoney > 0) { ServiceWindow window = new ServiceWindow(this, ReflashTask); window.ShowDialog(); return;//旧版本 } PackDetailWindow service = new PackDetailWindow(this, ReflashTask); service.ShowDialog(); } /// /// 查看合格证 /// private void LookCer() { if (CertificateModel == null) { new TipsWindow("该任务无设置合格证信息,无法查看!").ShowDialog(); return; } LookCerWindow lookCerWindow = new LookCerWindow(CertificateModel); lookCerWindow.ShowDialog(); } /// /// 查看条形码 /// private void LookBar() { if (BarCodeModel == null) { new TipsWindow("该任务无设置条形码信息,无法查看!").ShowDialog(); return; } LookBarCodeWindow look = new LookBarCodeWindow(); look.SetData(BarCodeModel.Copy()); look.Show(); } private void PrintCer() { if (CertificateModel == null) { new TipsWindow("该任务无设置合格证信息,无法打印!").Show(); return; } PrintWindow printWindow = new PrintWindow(); printWindow.CertificateModel = certificateModel; printWindow.LoadData(); //printWindow.Datas = LoadCerLabelModels(); printWindow.ShowDialog(); } /// /// 打印条形码 /// private void PrintBarcode() { if (BarCodeModel == null) { new TipsWindow("该任务无设置条形码信息,无法打印!").Show(); return; } PrintWindow printWindow = new PrintWindow(); printWindow.BarCodeModel = new BarCodeModel { Brand = BarCodeModel.Brand, BrandName = BarCodeModel.BrandName, LabelModel = BarCodeModel.LabelModel, ProductNo = BarCodeModel.ProductNo, SkuId = BarCodeModel.SkuId, SkuName = BarCodeModel.SkuName, ShopName = BarCodeModel.ShopName }; printWindow.LoadData(); //printWindow.Datas = LoadBarLabelModels(); printWindow.ShowDialog(); } private DateTime endTime; /// /// 提交时间 /// public DateTime EndTime { get => endTime; set { Set(ref endTime, value); } } private long taskId; /// /// 任务id /// public long TaskId { get => taskId; set { Set(ref taskId, value); } } private string departmentName; /// /// 部门名称 /// public string DepartmentName { get => departmentName; set { Set(ref departmentName, value); } } private string acceptName; /// /// 对接人 /// public string AcceptName { get => acceptName; set { Set(ref acceptName, value); } } private int skuCount; /// /// sku数量 /// public int SkuCount { get => skuCount; set { Set(ref skuCount, value); } } private TaskState taskState; /// /// 打包仓库任务状态 /// public TaskState TaskState { get => taskState; set { Set(ref taskState, value); } } private PackType packType; /// /// 打包类型(单件=0,多件=1) /// public PackType PackType { get => packType; set { Set(ref packType, value); } } private int goodsNumber; /// /// 配件数 /// public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } } private string skuTitle; /// /// sku配件商品名称 /// public string SkuTitle { get => skuTitle; set { Set(ref skuTitle, value); } } private BasicPack basicPack; /// /// 基础包装(快递袋=0,纸箱=1,麻袋=2) /// public BasicPack BasicPack { get => basicPack; set { Set(ref basicPack, value); } } private string increment1; /// /// 增量1() /// public string Increment1 { get => increment1; set { Set(ref increment1, value); } } private string positionType; /// /// 落仓(商家仓=0,云仓=1,京仓=2,聚水潭=3) /// public string PositionType { get => positionType; set { Set(ref positionType, value); } } #region 条形码数据 /// /// 条形码id /// public long BarCodeId { get; set; } /// /// 标签模板 /// public BarcodeLabelModel LabelModel { get; set; } private string brand; /// /// 品牌 /// public string Brand { get => brand; set { Set(ref brand, value); } } private string brandName; /// /// 品名 /// public string BrandName { get => brandName; set { Set(ref brandName, value); } } private string producNo; /// /// 货号 /// public string ProductNo { get => producNo; set { Set(ref producNo, value); } } private string skuName; /// /// sku名称 /// public string SkuName { get => skuName; set { Set(ref skuName, value); } } private string skuId; /// /// skuId(条形码号=POP+SkuId) /// public string SkuId { get => skuId; set { Set(ref skuId, value); } } //private string modelNo; ///// ///// 型号 ///// //public string ModelNo { get => modelNo; set { Set(ref modelNo, value); } } #endregion private BarCodeModel barCodeModel; /// /// 合格证 /// public BarCodeModel BarCodeModel { get => barCodeModel; set { Set(ref barCodeModel, value); } } private CertificateModel[] certificateModel; /// /// 合格证 /// public CertificateModel[] CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } } /// /// 合格证位置(外部包装=0,产品包装=1) /// private CertificatePosition certificatePosition; /// /// 合格证位置(外部包装=0,产品包装=1) /// public CertificatePosition CertificatePosition { get => certificatePosition; set { Set(ref certificatePosition, value); } } /// /// 服务收费 (单个任务id 消耗的总费用) /// private decimal feesMoney; /// /// 服务收费 (单个任务id 消耗的总费用) /// public decimal FeesMoney { get => feesMoney; set { Set(ref feesMoney, value); } } /// /// 打包员 /// private string packUser; /// /// 打包员 /// public string PackUser { get => packUser; set { Set(ref packUser, value); } } private FeesItemResponse feesItemResponse; public FeesItemResponse FeesItemResponse { get => feesItemResponse; set { Set(ref feesItemResponse, value); } } private QualityTaskExceptionState? qualityTaskExceptionState; public QualityTaskExceptionState? QualityTaskExceptionState { get => qualityTaskExceptionState; set { Set(ref qualityTaskExceptionState, value); } } private PackagingTaskExceptionState packagingTaskExceptionState; /// /// 包装任务状态 /// public Models.PackagingTaskExceptionState PackagingTaskExceptionState { get => packagingTaskExceptionState; set { Set(ref packagingTaskExceptionState, value); } } /// /// 包装人收益(默认0.85折) /// public decimal PackagerFees { get; set; } /// /// 包装费用(包装原价) /// public decimal PackageFees { get; set; } /// /// 耗材费用 /// public decimal ConsumableFees { get; set; } private decimal packTotalFees; /// /// 总计 /// public decimal PackTotalFees { get => packTotalFees; set { Set(ref packTotalFees, value); } } public IList ItemList { get; set; } public string OrderId { get; set; } private int? floorDragNumber; public int? FloorDragNumber { get => floorDragNumber; set { Set(ref floorDragNumber, value); } } private string qualityRemainTime; /// /// 质检剩余时间 /// public string QualityRemainTime { get => qualityRemainTime; set { Set(ref qualityRemainTime, value); } } private bool isQualityOverTime; public bool IsQualityOverTime { get => isQualityOverTime; set { Set(ref isQualityOverTime, value); } } /// /// 质检超时时间 /// public DateTime? QualityCompletionOverTime { get; set; } /// /// 任务挂起时间 /// public DateTime? TaskAbortTime { get; set; } private string packRemainTime; /// /// 打包剩余时间 /// public string PackRemainTime { get => packRemainTime; set { Set(ref packRemainTime, value); } } private decimal actualIncome; /// /// 预估收益 /// public decimal ActualIncome { get => actualIncome; set { Set(ref actualIncome, value); } } private string compensationFee; /// /// 赔付金额 /// public string CompensationFee { get => compensationFee; set { Set(ref compensationFee, value); } } /// /// 打包完成时间(超时时间) /// public DateTime? PackCompletionOverTime { get; set; } private bool isPackOverTime; public bool IsPackOverTime { get => isPackOverTime; set { Set(ref isPackOverTime, value); } } private bool isScheduleOverTime; public bool IsScheduleOverTime { get => isScheduleOverTime; set { Set(ref isScheduleOverTime, value); } } private string scheduleRemainTime; /// /// 打包剩余时间 /// public string ScheduleRemainTime { get => scheduleRemainTime; set { Set(ref scheduleRemainTime, value); } } /// /// 排单超时备注信息 /// public string ScheduleOverTimeMarkMsg { get; set; } /// /// 物流信息 /// private List expressOrderList; /// /// 物流信息 /// public List ExpressOrderList { get => expressOrderList; set { Set(ref expressOrderList, value); } } /// /// 需求方店铺id /// private string shopName; /// /// 需求方店铺id /// public string ShopName { get => shopName; set { Set(ref shopName, value); } } private string qualityOverTimeMarkMsg; /// /// 质检超时备注信息 /// public string QualityOverTimeMarkMsg { get => qualityOverTimeMarkMsg; set { Set(ref qualityOverTimeMarkMsg, value); } } private string packOverTimeMarkMsg; /// /// 打包超时备注信息 /// public string PackOverTimeMarkMsg { get => packOverTimeMarkMsg; set { Set(ref packOverTimeMarkMsg, value); } } /// /// 消息列表 /// public List MarkMessageModelList { get; set; } /// /// 采购方案 /// public string SkuPurchaseSchemeId { get; set; } /// /// 排单超时时间 /// public DateTime? ScheduleOverTime { get; set; } private PackProcessType? packProcessType; /// /// 打包工序类型(0=推荐工序,1=自定义工序) NULL 金额不为0则为旧版本结算 /// public PackProcessType? PackProcessType { get => packProcessType; set { Set(ref packProcessType, value); } } public string ShopId { get; set; } /// /// 发送信息不全时间 /// public DateTime? SendToSetSkuConfigureTime { get; set; } /// /// 异常类型 /// public string TaskExceptionType { get; set; } /// /// 货架编号 /// public string ShelvesNumber { get; set; } /// /// 货架层数 /// public int? FloorNumber { get; set; } /// /// 挂起异常备注 /// public string AbortRemark { get; set; } } public class SkuMessage : NotifyObject { private string skuId; public string SkuId { get => skuId; set { Set(ref skuId, value); } } /// /// 店铺Sku图链接 /// private string logo; /// /// 店铺Sku图链接 /// public string Logo { get => logo; set { Set(ref logo, value); } } /// /// 采购Sku名称 /// private string skuName; /// /// 采购Sku名称 /// public string SkuName { get => skuName; set { Set(ref skuName, value); } } /// /// 货号品名(手写上传) /// private string brandName; /// /// 货号品名(手写上传) /// public string BrandName { get => brandName; set { Set(ref brandName, value); } } /// /// 货号 /// private string goodsNo; /// /// 货号 /// public string GoodsNo { get => goodsNo; set { Set(ref goodsNo, value); } } } }