From 472862a978b6cd45abeb4f442044ce04063c5129 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Tue, 21 May 2024 18:46:51 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=BA=93=E4=BD=8D=E7=A6=81=E7=94=A8=E5=92=8C?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E3=80=81=E6=A8=A1=E7=BB=84=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E5=90=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2.退出出库先解锁 后发指令 --- .../Services/IService/IStoreInfoService.cs | 18 ++- WCS.BLL/Services/Service/OutstoreService.cs | 13 +- WCS.BLL/Services/Service/StoreInfoService.cs | 132 ++++++++++++++++++ .../OutStore/GetOutOrderListRequest.cs | 2 + .../StoreInfo/DisableOrEnableModuleRequest.cs | 15 ++ .../StoreInfo/DisableOrEnableStoreRequest.cs | 22 +++ .../Controllers/FileDownLoadController.cs | 2 +- WCS.WebApi/Controllers/StoreInfoController.cs | 14 ++ WCS.WebApi/Files/APP.app | 0 .../ViewModels/ModuleInfoViewModel.cs | 94 ++++++++++++- .../ViewModels/StoreInfoViewModel.cs | 90 ++++++++++++ .../Views/Controls/UserView.xaml.cs | 14 -- .../Views/MainWindows/MainWindow1.xaml | 10 +- 货架标准上位机/Views/ModuleInfoView.xaml | 13 +- 货架标准上位机/Views/StoreInfoView.xaml | 12 +- 货架标准上位机/data/jsconfig.json | 2 +- 16 files changed, 417 insertions(+), 36 deletions(-) create mode 100644 WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs create mode 100644 WCS.Model/ApiModel/StoreInfo/DisableOrEnableStoreRequest.cs delete mode 100644 WCS.WebApi/Files/APP.app diff --git a/WCS.BLL/Services/IService/IStoreInfoService.cs b/WCS.BLL/Services/IService/IStoreInfoService.cs index 49bff75..e4ac645 100644 --- a/WCS.BLL/Services/IService/IStoreInfoService.cs +++ b/WCS.BLL/Services/IService/IStoreInfoService.cs @@ -32,19 +32,33 @@ namespace WCS.BLL.Services.IService /// - /// 查询货架列表 + /// 查询模组列表 /// /// /// public Task> GetModules(GetModulesRequest request); + /// + /// 禁用或启用模组 + /// + /// + /// + public Task disableOrEnableModule(DisableOrEnableModuleRequest request); + /// - /// 查询货架列表 + /// 查询库位列表 /// /// /// public Task> GetStores(GetStoresRequest request); + /// + /// 禁用或启用库位 + /// + /// + /// + public Task disableOrEnableStore(DisableOrEnableStoreRequest request); + } } diff --git a/WCS.BLL/Services/Service/OutstoreService.cs b/WCS.BLL/Services/Service/OutstoreService.cs index fba3311..14cbeb6 100644 --- a/WCS.BLL/Services/Service/OutstoreService.cs +++ b/WCS.BLL/Services/Service/OutstoreService.cs @@ -261,7 +261,8 @@ namespace WCS.BLL.Services.Service var recordsQueryable = DbHelp.db.Queryable() .WhereIF(!string.IsNullOrEmpty(request.OrderNumber), t => t.OrderNumber.Contains(request.OrderNumber)) .WhereIF(!string.IsNullOrEmpty(request.OrderSource), t => t.OrderSource.Contains(request.OrderSource)) - .WhereIF(!string.IsNullOrEmpty(request.OrderType), t => t.OrderType.Contains(request.OrderType)); + .WhereIF(!string.IsNullOrEmpty(request.OrderType), t => t.OrderType.Contains(request.OrderType)) + .WhereIF(request.ShelfTypeId != 0, t => t.ShelfTypeId == request.ShelfTypeId); var totalCount = await recordsQueryable.CountAsync(); var records = await recordsQueryable @@ -859,6 +860,10 @@ namespace WCS.BLL.Services.Service DbHelp.db.Updateable(order).ExecuteCommand(); } + //解锁物料 删除物料明细 + if (order.SyncType == SyncTypeEnum.ByMatCode) + CancelOutOrderMatDetails(order); + //找到正在出对应出库单的货架 var shelves = ShelfManager.Shelves.Where(t => t.OrderNumber == request.OrderNumber) .Where(t => t.CurrentMode == HardWare.Mode.出库模式) @@ -874,15 +879,15 @@ namespace WCS.BLL.Services.Service }; } + + //退出出库模式 shelves.ForEach(t => { t.GoOutOutstore(); }); - //解锁物料 删除物料明细 - if (order.SyncType == SyncTypeEnum.ByMatCode) - CancelOutOrderMatDetails(order); + return new ResponseCommon() { diff --git a/WCS.BLL/Services/Service/StoreInfoService.cs b/WCS.BLL/Services/Service/StoreInfoService.cs index 9056619..aef3f20 100644 --- a/WCS.BLL/Services/Service/StoreInfoService.cs +++ b/WCS.BLL/Services/Service/StoreInfoService.cs @@ -12,6 +12,7 @@ using WCS.DAL.Db; using WCS.DAL.DbModels; using WCS.Model; using WCS.Model.ApiModel; +using WCS.Model.ApiModel.InOutRecord; using WCS.Model.ApiModel.StoreInfo; using WCS.Model.ApiModel.User; @@ -308,6 +309,58 @@ namespace WCS.BLL.Services.Service }; } } + + /// + /// 禁用或启用模组 + /// + /// + /// + public async Task disableOrEnableModule(DisableOrEnableModuleRequest request) + { + //找到库位 + var moduleInfo = await DbHelp.db.Queryable() + .Where(t => t.Id == request.ModuleId) + .FirstAsync(); + //库位不存在 + if (moduleInfo == null) + { + return new ResponseCommon() + { + Code = 201, + Message = $"操作失败:模组{request.ModuleCode}不存在!" + }; + } + try + { + DbHelp.db.BeginTran(); + //禁用需要删除当前库存数据 + if (request.DisableOrEnable == DisableOrEnableEnum.Disable) + { + moduleInfo.IsEnable = false; + + } + else + { + moduleInfo.IsEnable = true; + } + DbHelp.db.Updateable(moduleInfo).ExecuteCommand(); + DbHelp.db.CommitTran(); + return new ResponseCommon() + { + Code = 200, + Message = $"Success" + }; + } + catch (Exception ex) + { + DbHelp.db.RollbackTran(); + return new ResponseCommon() + { + Code = 300, + Message = $"操作失败:异常{ex.Message}!" + }; + } + } #endregion #region 库位管理 @@ -352,6 +405,85 @@ namespace WCS.BLL.Services.Service }; } } + + public async Task disableOrEnableStore(DisableOrEnableStoreRequest request) + { + //找到库位 + var storeInfo = await DbHelp.db.Queryable() + .Where(t => t.Id == request.StoreId) + .FirstAsync(); + //库位不存在 + if (storeInfo == null) + { + return new ResponseCommon() + { + Code = 201, + Message = $"操作失败:库位{request.SroreCode}不存在!" + }; + } + try + { + DbHelp.db.BeginTran(); + //禁用需要删除当前库存数据 + if (request.DisableOrEnable == DisableOrEnableEnum.Disable) + { + //库位 + storeInfo.CurrentMatSn = "禁用"; + //库存数据处理 + var inventorys = DbHelp.db.Queryable() + .Where(t => t.StoreId == storeInfo.Id) + .ToList(); + if (inventorys != null && inventorys.Count > 0) + { + //删除并进行出入库记录 + foreach (var inventory in inventorys) + { + var inOutRecord = new InOutRecord() + { + StoreCode = storeInfo.StoreCode, + StoreId = storeInfo.Id, + StoreInfo = storeInfo, + + MatSN = inventory.MatSN, + MatCode = inventory.MatCode, + MatName = inventory.MatName, + MatSpec = inventory.MatSpec, + MatBatch = inventory.MatBatch, + MatQty = inventory.MatQty, + MatCustomer = inventory.MatCustomer, + MatSupplier = inventory.MatSupplier, + + OperateUser = request.UserName + "(禁用库位)", + Direction = DirectionEnum.丢失, + }; + DbHelp.db.Insertable(inOutRecord).ExecuteCommand(); + DbHelp.db.Deleteable(inventory).ExecuteCommand(); + } + } + } + else + { + storeInfo.CurrentMatSn = string.Empty; + } + DbHelp.db.Updateable(storeInfo).ExecuteCommand(); + DbHelp.db.CommitTran(); + return new ResponseCommon() + { + Code = 200, + Message = $"Success" + }; + } + catch (Exception ex) + { + DbHelp.db.RollbackTran(); + return new ResponseCommon() + { + Code = 300, + Message = $"操作失败:异常{ex.Message}!" + }; + } + } + #endregion } } diff --git a/WCS.Model/ApiModel/OutStore/GetOutOrderListRequest.cs b/WCS.Model/ApiModel/OutStore/GetOutOrderListRequest.cs index a9b18a0..76c0989 100644 --- a/WCS.Model/ApiModel/OutStore/GetOutOrderListRequest.cs +++ b/WCS.Model/ApiModel/OutStore/GetOutOrderListRequest.cs @@ -13,5 +13,7 @@ namespace WCS.Model public string OrderSource { get; set; } public string OrderType { get; set; } + + public int ShelfTypeId { get; set; } = 0; } } diff --git a/WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs b/WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs new file mode 100644 index 0000000..60b978d --- /dev/null +++ b/WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.StoreInfo +{ + public class DisableOrEnableModuleRequest : RequestBase + { + public int ModuleId { get; set; } + + public string ModuleCode { get; set; } + + public DisableOrEnableEnum DisableOrEnable { get; set; } + } +} diff --git a/WCS.Model/ApiModel/StoreInfo/DisableOrEnableStoreRequest.cs b/WCS.Model/ApiModel/StoreInfo/DisableOrEnableStoreRequest.cs new file mode 100644 index 0000000..1b36ec7 --- /dev/null +++ b/WCS.Model/ApiModel/StoreInfo/DisableOrEnableStoreRequest.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.StoreInfo +{ + public class DisableOrEnableStoreRequest : RequestBase + { + public int StoreId { get; set; } + + public string SroreCode { get; set; } + + public DisableOrEnableEnum DisableOrEnable { get; set; } + } + + public enum DisableOrEnableEnum + { + Disable = 0, + Enable = 1 + } + +} diff --git a/WCS.WebApi/Controllers/FileDownLoadController.cs b/WCS.WebApi/Controllers/FileDownLoadController.cs index e36f103..028b6be 100644 --- a/WCS.WebApi/Controllers/FileDownLoadController.cs +++ b/WCS.WebApi/Controllers/FileDownLoadController.cs @@ -47,7 +47,7 @@ namespace WCS.WebApi.Controllers string directoryPath = Path.Combine(Directory.GetCurrentDirectory(), $"Files"); // 获取目录下的所有文件信息 - FileInfo[] files = Directory.GetFiles(directoryPath, "*.app") + FileInfo[] files = Directory.GetFiles(directoryPath, "*.APK") .Select(file => new FileInfo(file)) .ToArray(); diff --git a/WCS.WebApi/Controllers/StoreInfoController.cs b/WCS.WebApi/Controllers/StoreInfoController.cs index 1532fb3..d0ac534 100644 --- a/WCS.WebApi/Controllers/StoreInfoController.cs +++ b/WCS.WebApi/Controllers/StoreInfoController.cs @@ -52,6 +52,13 @@ namespace WCS.WebApi.Controllers { return await _storeInfoService.GetModules(request); } + + [Route("disableOrEnableModule")] + [HttpPost(Name = "disableOrEnableModule")] + public async Task disableOrEnableModule(DisableOrEnableModuleRequest request) + { + return await _storeInfoService.disableOrEnableModule(request); + } #endregion #region 库位管理 @@ -61,6 +68,13 @@ namespace WCS.WebApi.Controllers { return await _storeInfoService.GetStores(request); } + + [Route("disableOrEnableStore")] + [HttpPost(Name = "disableOrEnableStore")] + public async Task disableOrEnableStore(DisableOrEnableStoreRequest request) + { + return await _storeInfoService.disableOrEnableStore(request); + } #endregion } } diff --git a/WCS.WebApi/Files/APP.app b/WCS.WebApi/Files/APP.app deleted file mode 100644 index e69de29..0000000 diff --git a/货架标准上位机/ViewModels/ModuleInfoViewModel.cs b/货架标准上位机/ViewModels/ModuleInfoViewModel.cs index 6476799..fa64745 100644 --- a/货架标准上位机/ViewModels/ModuleInfoViewModel.cs +++ b/货架标准上位机/ViewModels/ModuleInfoViewModel.cs @@ -19,6 +19,7 @@ using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.User; using WCS.Model.ApiModel; using Newtonsoft.Json.Bson; +using System.Windows; namespace 货架标准上位机.ViewModel { @@ -75,7 +76,7 @@ namespace 货架标准上位机.ViewModel public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); } public void BtnReset() { - ModuleCode = string.Empty; + ModuleCode = string.Empty; ShelfCode = string.Empty; } @@ -153,6 +154,97 @@ namespace 货架标准上位机.ViewModel } } } + + public ICommand DisableCommand { get => new DelegateCommand(Disable); } + public void Disable(ModuleInfoModel module) + { + if (module.IsEnable != true) + { + Growl.Warning("库位未被启用!"); + return; + } + var result = HandyControl.Controls.MessageBox.Show("模组禁用会影响正常流程,请确认是否屏蔽?" + , "提示", MessageBoxButton.YesNo); + if (result == MessageBoxResult.Yes) + { + #region 调用接口 禁用 + try + { + var body = new DisableOrEnableModuleRequest() + { + ModuleId = module.Id, + ModuleCode = module.ModuleCode, + DisableOrEnable = DisableOrEnableEnum.Disable, + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + }; + var Result = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "storeInfo/disableOrEnableModule", body, "POST"); + if (Result != null && Result.Code == 200) + { + Growl.Success("禁用成功"); + BtnSearch(); + } + else if (Result != null) + { + Growl.Warning(Result.Message); + } + else + { + Growl.Warning("操作失败:请重试!"); + } + } + catch (Exception ex) + { + Growl.Error("操作失败:" + ex.Message); + } + #endregion + } + else + { + return; + } + } + + public ICommand EnableCommand { get => new DelegateCommand(Enable); } + public void Enable(ModuleInfoModel module) + { + if (module.IsEnable == true) + { + Growl.Warning("库位未被禁用!"); + return; + } + #region 调用接口 临时禁用库位 删除库存数据 + try + { + var body = new DisableOrEnableModuleRequest() + { + ModuleId = module.Id, + ModuleCode = module.ModuleCode, + DisableOrEnable = DisableOrEnableEnum.Enable, + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + }; + var Result = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "storeInfo/disableOrEnableModule", body, "POST"); + if (Result != null && Result.Code == 200) + { + Growl.Success("操作成功!"); + BtnSearch(); + } + else if (Result != null) + { + Growl.Warning(Result.Message); + } + else + { + Growl.Warning("操作失败:请重试!"); + } + } + catch (Exception ex) + { + Growl.Error("操作失败:" + ex.Message); + } + #endregion + } #endregion #region PageOperation 分页操作 diff --git a/货架标准上位机/ViewModels/StoreInfoViewModel.cs b/货架标准上位机/ViewModels/StoreInfoViewModel.cs index c91026c..fc5302a 100644 --- a/货架标准上位机/ViewModels/StoreInfoViewModel.cs +++ b/货架标准上位机/ViewModels/StoreInfoViewModel.cs @@ -19,6 +19,8 @@ using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.User; using WCS.Model.ApiModel; using Newtonsoft.Json.Bson; +using System.Windows; +using System.Security.Cryptography; namespace 货架标准上位机.ViewModel { @@ -140,6 +142,94 @@ namespace 货架标准上位机.ViewModel } #endregion } + + public ICommand DisableCommand { get => new DelegateCommand(Disable); } + public void Disable(StoreInfoModel store) + { + var result = HandyControl.Controls.MessageBox.Show("库位屏蔽仅用于临时屏蔽硬件损坏识别的未扫描上架!\r\n" + + "操作时会删除对应库位的数据,需要保证对应库位物料已取出。\r\n" + + "请确认是否进行操作?" + , "提示", MessageBoxButton.YesNo); + if (result == MessageBoxResult.Yes) + { + #region 调用接口 临时禁用库位 删除库存数据 + try + { + var body = new DisableOrEnableStoreRequest() + { + StoreId = store.Id, + SroreCode = store.StoreCode, + DisableOrEnable = DisableOrEnableEnum.Disable, + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + }; + var Result = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "storeInfo/disableOrEnableStore", body, "POST"); + if (Result != null && Result.Code == 200) + { + Growl.Success("禁用成功"); + BtnSearch(); + } + else if (Result != null) + { + Growl.Warning(Result.Message); + } + else + { + Growl.Warning("操作失败:请重试!"); + } + } + catch (Exception ex) + { + Growl.Error("操作失败:" + ex.Message); + } + #endregion + } + else + { + return; + } + } + + public ICommand EnableCommand { get => new DelegateCommand(Enable); } + public void Enable(StoreInfoModel store) + { + if (store.CurrentMatSn != "禁用") + { + Growl.Warning("库位未被禁用!"); + return; + } + #region 调用接口 临时禁用库位 删除库存数据 + try + { + var body = new DisableOrEnableStoreRequest() + { + StoreId = store.Id, + SroreCode = store.StoreCode, + DisableOrEnable = DisableOrEnableEnum.Enable, + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + }; + var Result = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "storeInfo/disableOrEnableStore", body, "POST"); + if (Result != null && Result.Code == 200) + { + Growl.Success("操作成功!"); + BtnSearch(); + } + else if (Result != null) + { + Growl.Warning(Result.Message); + } + else + { + Growl.Warning("操作失败:请重试!"); + } + } + catch (Exception ex) + { + Growl.Error("操作失败:" + ex.Message); + } + #endregion + } #endregion #region PageOperation 分页操作 diff --git a/货架标准上位机/Views/Controls/UserView.xaml.cs b/货架标准上位机/Views/Controls/UserView.xaml.cs index 0424a80..f9f989e 100644 --- a/货架标准上位机/Views/Controls/UserView.xaml.cs +++ b/货架标准上位机/Views/Controls/UserView.xaml.cs @@ -1,20 +1,6 @@ using 货架标准上位机.ViewModel; using Ping9719.WpfEx; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -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 货架标准上位机 { diff --git a/货架标准上位机/Views/MainWindows/MainWindow1.xaml b/货架标准上位机/Views/MainWindows/MainWindow1.xaml index ae08325..8157270 100644 --- a/货架标准上位机/Views/MainWindows/MainWindow1.xaml +++ b/货架标准上位机/Views/MainWindows/MainWindow1.xaml @@ -241,16 +241,16 @@ - - - - - + + + + + diff --git a/货架标准上位机/Views/ModuleInfoView.xaml b/货架标准上位机/Views/ModuleInfoView.xaml index 19b669e..bceec7c 100644 --- a/货架标准上位机/Views/ModuleInfoView.xaml +++ b/货架标准上位机/Views/ModuleInfoView.xaml @@ -84,14 +84,23 @@ - - + + + + + + - @@ -102,8 +102,8 @@ -