From 7e2a3adf8599fd0a0c62af37eee7381303902f40 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Sat, 18 Jan 2025 18:22:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E7=BB=91=E5=AE=9A=EF=BC=88?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/DbModels/STZL/LocationInfo.cs | 18 + WCS.BLL/DbModels/STZL/MatDetailCurrentInfo.cs | 12 + .../IService/IBatchBindMatDetailService.cs | 34 ++ .../Service/BatchBindMatDetailService.cs | 188 ++++++++++ ...tDetailCurrentInfosByStationCodeRequest.cs | 14 + .../MatDetailCurrentInfo.cs | 9 + .../BatchBindMatDetailController.cs | 202 +---------- WCS.WebApi/Program.cs | 1 + .../ViewModels/BatchBindMatDetailViewModel.cs | 330 ++++++++++++++++++ .../Views/BatchBindMatDetailView.xaml | 47 ++- .../Views/BatchBindMatDetailView.xaml.cs | 5 +- 11 files changed, 645 insertions(+), 215 deletions(-) create mode 100644 WCS.BLL/Services/IService/IBatchBindMatDetailService.cs create mode 100644 WCS.BLL/Services/Service/BatchBindMatDetailService.cs create mode 100644 WCS.Model/ApiModel/BatchBindMatDetail/GetMatDetailCurrentInfosByStationCodeRequest.cs create mode 100644 货架标准上位机/ViewModels/BatchBindMatDetailViewModel.cs diff --git a/WCS.BLL/DbModels/STZL/LocationInfo.cs b/WCS.BLL/DbModels/STZL/LocationInfo.cs index 00596da..38dad89 100644 --- a/WCS.BLL/DbModels/STZL/LocationInfo.cs +++ b/WCS.BLL/DbModels/STZL/LocationInfo.cs @@ -58,6 +58,12 @@ namespace WCS.DAL.DbModels [SugarColumn(ColumnName = "modify_time", IsNullable = false, ColumnDescription = "更新时间")] public DateTime ModifyTime { get; set; } = DateTime.Now; + /// + /// 当前位置的状态 + /// + [SugarColumn(ColumnName = "location_status", IsNullable = false, DefaultValue = "0", ColumnDescription = "当前位置的状态")] + public LocationStatusEnum LocationStatus { get; set; } = LocationStatusEnum.空闲; + /// /// 是否启用 /// @@ -88,4 +94,16 @@ namespace WCS.DAL.DbModels [SugarColumn(IsIgnore = true)] public bool IsSelected { get; set; } } + + + /// + /// 货架运输状态 + /// + public enum LocationStatusEnum + { + 空闲 = 0,//位置上既没有货架 也没有送货架过来的任务 + 待占用 = 1,//位置上无货架 但是有送货架过来的任务 + 占用 = 2,//位置上有货架 + 待空闲 = 3,//位置上有货架 但是此货架已有送走的任务 + } } diff --git a/WCS.BLL/DbModels/STZL/MatDetailCurrentInfo.cs b/WCS.BLL/DbModels/STZL/MatDetailCurrentInfo.cs index bcff7d9..452ca3a 100644 --- a/WCS.BLL/DbModels/STZL/MatDetailCurrentInfo.cs +++ b/WCS.BLL/DbModels/STZL/MatDetailCurrentInfo.cs @@ -90,6 +90,18 @@ namespace WCS.BLL.DbModels #endregion #region 单据属性 + /// + /// 单据类型Id + /// + [SugarColumn(ColumnName = "order_type_id", IsNullable = true, ColumnDescription = "单据类型Id")] + public int OrderTypeId { get; set; } + + /// + /// 单据类型名称 + /// + [SugarColumn(ColumnName = "order_Type_name", Length = 64, IsNullable = true, ColumnDescription = "单据类型名称")] + public string OrderTypeName { get; set; } + /// /// 单据编号 /// diff --git a/WCS.BLL/Services/IService/IBatchBindMatDetailService.cs b/WCS.BLL/Services/IService/IBatchBindMatDetailService.cs new file mode 100644 index 0000000..9361f42 --- /dev/null +++ b/WCS.BLL/Services/IService/IBatchBindMatDetailService.cs @@ -0,0 +1,34 @@ +using WCS.Model; +using WCS.DAL.DbModels; +using WCS.Model.ApiModel.StoreInfo; +using WCS.BLL.DbModels; +using WCS.Model.ApiModel.MatBaseInfo; +using WCS.Model.ApiModel.MatDetailCurrentInfo; +using WCS.Model.ApiModel.BatchBindMatDetail; + +namespace WCS.BLL.Services.IService +{ + public interface IBatchBindMatDetailService + { + /// + /// 查询货架存量列表 + /// + /// + /// + public Task> GetMatDetailCurrentInfosByStationCode(GetMatDetailCurrentInfosByStationCodeRequest request); + + /// + /// 更新货架存量 + /// + /// + /// + public Task> updateMatDetailCurrentInfo(AddLocaionInfoRequest request); + + /// + /// 删除货架存量数据 + /// + /// + /// + public Task> deleteMatDetailCurrentInfo(DeleteInfosRequest request); + } +} diff --git a/WCS.BLL/Services/Service/BatchBindMatDetailService.cs b/WCS.BLL/Services/Service/BatchBindMatDetailService.cs new file mode 100644 index 0000000..943d0b9 --- /dev/null +++ b/WCS.BLL/Services/Service/BatchBindMatDetailService.cs @@ -0,0 +1,188 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using TouchSocket.Core; +using WCS.BLL.Config; +using WCS.BLL.DbModels; +using WCS.BLL.HardWare; +using WCS.BLL.Manager; +using WCS.BLL.Services.IService; +using WCS.DAL; +using WCS.DAL.Db; +using WCS.DAL.DbModels; +using WCS.Model; +using WCS.Model.ApiModel; +using WCS.Model.ApiModel.BatchBindMatDetail; +using WCS.Model.ApiModel.InOutRecord; +using WCS.Model.ApiModel.MatBaseInfo; +using WCS.Model.ApiModel.MatDetailCurrentInfo; +using WCS.Model.ApiModel.StoreInfo; +using WCS.Model.ApiModel.User; + +namespace WCS.BLL.Services.Service +{ + public class BatchBindMatDetailService : IBatchBindMatDetailService + { + + public async Task> GetMatDetailCurrentInfosByStationCode(GetMatDetailCurrentInfosByStationCodeRequest request) + { + try + { + var recordsQueryable = DbHelp.db.Queryable() + .LeftJoin((mci, si) => mci.ShlefId == si.Id) + .LeftJoin((mci, si, li) => (si.TransStatus == TransStatusEnum.静止 && si.CurrentLocationId == li.Id) + || (si.TransStatus == TransStatusEnum.运输中 && si.DestinationLocationId == li.Id)) + .WhereIF(request.OrderTypeId != null && request.OrderTypeId != 0, (mci, si, li) => mci.OrderTypeId == request.OrderTypeId) + .WhereIF(!string.IsNullOrEmpty(request.ShelfCode), (mci, si, li) => si.ShelfCode.Contains(request.ShelfCode)) + //.WhereIF(!string.IsNullOrEmpty(request.StationCode), (mci, si, li) => mci.StationCode.Contains(request.StationCode)) + .Select((mci, si, li) => new MatDetailCurrentInfoModel() + { + Id = mci.Id, + ShlefId = mci.ShlefId, + ShelfCode = mci.ShelfCode, + ShelfType = mci.ShelfType, + + LocationArea = li.LocationArea, + LocationCode = li.LocationCode, + + MatCode = mci.MatCode, + MatName = mci.MatName, + MatSpec = mci.MatSpec, + MatUnit = mci.MatUnit, + MatCustomer = mci.MatCustomer, + MatQty = mci.MatQty, + MatSupplier = mci.MatSupplier, + + OrderTypeId = mci.OrderTypeId, + OrderTypeName = mci.OrderTypeName, + OrderNumber = mci.OrderNumber, + + StationCode = mci.StationCode, + ModifyUser = mci.ModifyUser, + ModifyTime = mci.ModifyTime + }); + + //分页 + var totalCount = await recordsQueryable.CountAsync(); + var records = await recordsQueryable + .OrderByDescending(mci => mci.Id) + .Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize) + .ToListAsync(); + //生成序号 + for (int i = 0; i < records.Count; i++) + { + records[i].RowNumber = (request.PageNumber - 1) * request.PageSize + i + 1; + } + return new PageQueryResponse() + { + Code = 200, + Message = $"success", + Data = new PageQueryResponseData() + { + TotalCount = totalCount, + MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize), + Count = records.Count, + Lists = records.ToList() + } + }; + } + catch (Exception ex) + { + return new PageQueryResponse() + { + Code = 300, + Message = $"操作失败:{ex.Message}", + }; + } + } + + public async Task> updateMatDetailCurrentInfo(AddLocaionInfoRequest request) + { + try + { + var matDetailCurrentInfo = await DbHelp.db.Queryable() //.Where(t => t.MatDetailCurrentCode == request.MatDetailCurrentInfo.MatDetailCurrentCode) + .Where(t => t.Id == request.LocationInfo.Id) + .FirstAsync(); + if (matDetailCurrentInfo == null) + { + return new ResponseCommon + { + Code = 205, + Message = $"更新位置信息失败:此条数据不存在,请确认!", + Data = null + }; + } + + matDetailCurrentInfo.MatQty = request.LocationInfo.MatQty; + matDetailCurrentInfo.ModifyUser = request.UserName; + matDetailCurrentInfo.ModifyTime = DateTime.Now; + + var rowNum = await DbHelp.db.Updateable(matDetailCurrentInfo).ExecuteCommandAsync(); + if (rowNum == 0) + { + return new ResponseCommon + { + Code = 201, + Message = $"更新货架存量信息失败:请重试!", + Data = null + }; + } + else + { + return new ResponseCommon + { + Code = 200, + Message = $"更新货架存量信息成功!", + Data = null + }; + } + + + + } + catch (Exception ex) + { + var response = new ResponseCommon + { + Code = 300, + Message = $"操作失败:{ex.Message}", + Data = null + }; + return response; + } + } + + public async Task> deleteMatDetailCurrentInfo(DeleteInfosRequest request) + { + //先查询出具体的Id + var MatDetailCurrentInfos = await DbHelp.db.Queryable() + .Where(t => request.needDeleteIds.Contains(t.Id)) + .ToListAsync(); + //执行删除 + try + { + var deleteRows = await DbHelp.db.Deleteable(MatDetailCurrentInfos).ExecuteCommandAsync(); + return new ResponseCommon + { + Code = 200, + Message = $"已删除{deleteRows}条数据!", + Data = null + }; + } + catch (Exception ex) + { + var response = new ResponseCommon + { + Code = 300, + Message = $"操作失败:{ex.Message}", + Data = null + }; + return response; + } + } + } +} diff --git a/WCS.Model/ApiModel/BatchBindMatDetail/GetMatDetailCurrentInfosByStationCodeRequest.cs b/WCS.Model/ApiModel/BatchBindMatDetail/GetMatDetailCurrentInfosByStationCodeRequest.cs new file mode 100644 index 0000000..3f6df15 --- /dev/null +++ b/WCS.Model/ApiModel/BatchBindMatDetail/GetMatDetailCurrentInfosByStationCodeRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.BatchBindMatDetail +{ + public class GetMatDetailCurrentInfosByStationCodeRequest : PageQueryRequestBase + { + public int? OrderTypeId { get; set; } + public string OrderNumber { get; set; } + public string ShelfCode { get; set; } + public string StationCode { get; set; } + } +} diff --git a/WCS.Model/ApiModel/MatDetailCurrentInfo/MatDetailCurrentInfo.cs b/WCS.Model/ApiModel/MatDetailCurrentInfo/MatDetailCurrentInfo.cs index f804a4d..943f2ff 100644 --- a/WCS.Model/ApiModel/MatDetailCurrentInfo/MatDetailCurrentInfo.cs +++ b/WCS.Model/ApiModel/MatDetailCurrentInfo/MatDetailCurrentInfo.cs @@ -37,8 +37,17 @@ namespace WCS.Model.ApiModel.MatDetailCurrentInfo public int MatQty { get; set; } #endregion + #region 批量绑定相关 + //当前位置编码 public string? StationCode { get; set; } = string.Empty; + public int? OrderTypeId { get; set; } + + public string OrderTypeName { get; set; } = string.Empty; + + public string OrderNumber { get; set; } = string.Empty; + #endregion + public string? ModifyUser { get; set; } = string.Empty; public DateTime? ModifyTime { get; set; } = DateTime.Now; diff --git a/WCS.WebApi/Controllers/BatchBindMatDetailController.cs b/WCS.WebApi/Controllers/BatchBindMatDetailController.cs index a277b0a..1c67e97 100644 --- a/WCS.WebApi/Controllers/BatchBindMatDetailController.cs +++ b/WCS.WebApi/Controllers/BatchBindMatDetailController.cs @@ -5,6 +5,7 @@ using WCS.DAL.Db; using WCS.DAL.DbModels; using WCS.Model; using WCS.Model.ApiModel; +using WCS.Model.ApiModel.BatchBindMatDetail; using WCS.Model.ApiModel.Home; using WCS.Model.ApiModel.PDAMatBind; using WCS.Model.ApiModel.User; @@ -19,11 +20,11 @@ namespace WCS.WebApi.Controllers [Route("[controller]")] public class BatchBindMatDetailController : ControllerBase { - public IWarningService _warningService { get; set; } + public IBatchBindMatDetailService _batchBindMatDetailService { get; set; } - public BatchBindMatDetailController(IWarningService warningService) + public BatchBindMatDetailController(IBatchBindMatDetailService batchBindMatDetailService) { - _warningService = warningService; + _batchBindMatDetailService = batchBindMatDetailService; } [Route("getOrderTypes")] @@ -62,206 +63,37 @@ namespace WCS.WebApi.Controllers } - [Route("getShelfInfoByLocationCode1")] - [HttpPost(Name = "getShelfInfoByLocationCode1")] - public async Task getShelfInfoByLocationCode(GetShelfInfoByLocationCodeRequest request) + [Route("getMatDetailCurrentInfosByStationCode")] + [HttpPost(Name = "getMatDetailCurrentInfosByStationCode")] + public async Task GetMatDetailCurrentInfosByStationCode(GetMatDetailCurrentInfosByStationCodeRequest request) { //判断参数 - if (string.IsNullOrEmpty(request.LocationCode)) + if (string.IsNullOrEmpty(request.StationCode)) { return new ResponseCommon() { Code = 201, - Message = "工位编码为空!", + Message = "工位编码为空,请联系相关人员进行配置!", Data = null, }; } - - //获取是否存在当前工位 - var location = await DbHelp.db.Queryable() - .Where(t => t.LocationCode == request.LocationCode) - .Where(t => t.IsEnable == true) - .FirstAsync(); - if (location == null) + //判断工位是否存在 + var isExsistLocation = await DbHelp.db.Queryable() + .Where(t => t.LocationCode == request.StationCode) + .AnyAsync(); + //不存在工位 + if (!isExsistLocation) { return new ResponseCommon() { Code = 201, - Message = $"工位[{request.LocationCode}]不存在或已被禁用!\r\n请联系系统管理人员维护工位信息!", + Message = $"工位[{request.StationCode}]不存在,暂时无法使用此功能!", Data = null, }; } - //获取当前工位的货架 - var shelf = await DbHelp.db.Queryable() - .Where(t => t.CurrentLocationId == location.Id && t.TransStatus == TransStatusEnum.静止 - || t.DestinationLocationId == location.Id && t.TransStatus == TransStatusEnum.运输中)//解决产线人员 呼叫后货架未到的时候绑定的问题 - .Where(t => t.IsEnable) - .FirstAsync(); - - return new ResponseBase() - { - Code = 200, - Message = $"success", - Data = new GetShelfInfoByLocationReturnData() - { - LocationId = location.Id, - LocationCode = request.LocationCode, - ShelfId = shelf?.Id, - ShelfCode = shelf?.ShelfCode, - }, - }; - + return await _batchBindMatDetailService.GetMatDetailCurrentInfosByStationCode(request); } - //[Route("bindMatDetail")] - //[HttpPost(Name = "bindMatDetail")] - //public async Task bindMatDetail(BindMatDetailRequest request) - //{ - // try - // { - // #region 参数校验 - // //判断参数 - // if (request.LocationId == 0 || string.IsNullOrEmpty(request.LocationCode)) - // { - // return new ResponseCommon() - // { - // Code = 201, - // Message = "工位或工位编码为空!", - // Data = null, - // }; - // } - - // if (request.ShelfId == 0 || string.IsNullOrEmpty(request.ShelfCode)) - // { - - // return new ResponseCommon() - // { - // Code = 201, - // Message = "货架或货架编码为空!", - // Data = null, - // }; - // } - - // if (request.MatBaseInfoId == 0 || string.IsNullOrEmpty(request.MatCode)) - // { - // return new ResponseCommon() - // { - // Code = 201, - // Message = "未选择物料!", - // Data = null, - // }; - // } - - // if (request.Qty <= 0) - // { - // return new ResponseCommon() - // { - // Code = 201, - // Message = "数量应大于等于1!", - // Data = null, - // }; - // } - // #endregion - - // #region 数据校验 - // //判断参数 - // if (string.IsNullOrEmpty(request.LocationCode)) - // { - // return new ResponseCommon() - // { - // Code = 201, - // Message = "工位编码为空!", - // Data = null, - // }; - // } - - // //获取是否存在当前工位 - // var location = await DbHelp.db.Queryable() - // .Where(t => t.Id == request.LocationId) - // .Where(t => t.IsEnable == true) - // .FirstAsync(); - // if (location == null) - // { - // return new ResponseCommon() - // { - // Code = 201, - // Message = $"工位[{request.LocationCode}]不存在或已被禁用!\r\n请联系系统管理人员维护工位信息!", - // Data = null, - // }; - // } - - // //获取当前工位的货架 - // var shelf = await DbHelp.db.Queryable() - // .Where(t => t.Id == request.ShelfId) - // .Where(t => t.CurrentLocationId == location.Id && t.TransStatus == TransStatusEnum.静止 - // || t.DestinationLocationId == location.Id && t.TransStatus == TransStatusEnum.运输中)//解决产线人员 呼叫后货架未到的时候绑定的问题 - // .Where(t => t.IsEnable == true) - // .FirstAsync(); - // if (shelf == null) - // { - // return new ResponseCommon() - // { - // Code = 205, - // Message = $"货架[{request.ShelfCode}],已不在工位上!\r\n请进行【货架呼叫】!", - // Data = null, - // }; - // } - - // //获取物料基础信息 - // var matBaseInfo = await DbHelp.db.Queryable() - // .Where(t => t.Id == request.MatBaseInfoId) - // .Where(t => t.IsEnable == true) - // .FirstAsync(); - // if (matBaseInfo == null) - // { - // return new ResponseCommon() - // { - // Code = 201, - // Message = $"不存在物料[{request.MatCode}]或已被禁用!", - // Data = null, - // }; - // } - // #endregion - - // //校验合格 进行保存 - // var matDetailCurrentInfo = new MatDetailCurrentInfo() - // { - // ShlefId = shelf.Id, - // ShelfCode = shelf.ShelfCode, - // ShelfType = shelf.ShelfTypeName, - // //ShelfArea = shelf.ShelfArea, - - // MatCode = matBaseInfo.MatCode, - // MatName = matBaseInfo.MatName, - // MatSupplier = matBaseInfo.MatSupplier, - // MatCustomer = matBaseInfo.MatCustomer, - // MatSpec = matBaseInfo.MatSpec, - // MatUnit = matBaseInfo.MatUnit, - // MatQty = request.Qty, - - // ModifyUser = request.UserName, - // }; - // DbHelp.db.Insertable(matDetailCurrentInfo).ExecuteCommand(); - - // return new ResponseCommon() - // { - // Code = 200, - // Message = "success", - // Data = null, - // }; - // } - // catch (Exception ex) - // { - // return new ResponseCommon() - // { - // Code = 201, - // Message = ex.Message, - // Data = null, - // }; - // } - //} - - } } diff --git a/WCS.WebApi/Program.cs b/WCS.WebApi/Program.cs index c656354..479aef8 100644 --- a/WCS.WebApi/Program.cs +++ b/WCS.WebApi/Program.cs @@ -83,6 +83,7 @@ namespace WebApi builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); //롢ɵõģʽ builder.Services.AddSingleton(); diff --git a/货架标准上位机/ViewModels/BatchBindMatDetailViewModel.cs b/货架标准上位机/ViewModels/BatchBindMatDetailViewModel.cs new file mode 100644 index 0000000..fd8052a --- /dev/null +++ b/货架标准上位机/ViewModels/BatchBindMatDetailViewModel.cs @@ -0,0 +1,330 @@ +using HandyControl.Controls; +using MiniExcelLibs; +using Ping9719.WpfEx.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Input; +using 智慧物流软件系统.Views.Controls; +using 智慧物流软件系统.Api; +using WCS.Model; +using WCS.Model.ApiModel.Home; +using WCS.Model.ApiModel.StoreInfo; +using WCS.BLL.DbModels; +using WCS.Model.ApiModel.MatBaseInfo; +using WCS.Model.ApiModel.User; +using WCS.Model.ApiModel; +using Newtonsoft.Json.Bson; +using WCS.Model.ApiModel.LocationInfo; +using WCS.Model.ApiModel.MatDetailCurrentInfo; +using WCS.Model.ApiModel.BatchBindMatDetail; + +namespace 智慧物流软件系统.ViewModel +{ + public class BatchBindMatDetailViewModel : BindableBase + { + public BatchBindMatDetailViewModel() + { + + } + + #region Property + private List dataGridItemSource; + public List DataGridItemSource + { + get { return dataGridItemSource; } + set + { + SetProperty(ref dataGridItemSource, value); + } + } + + private MatDetailCurrentInfoModel selectedataGridItem; + public MatDetailCurrentInfoModel SelectedataGridItem + { + get { return selectedataGridItem; } + set + { + SetProperty(ref selectedataGridItem, value); + } + } + + /// + /// 单据编号 + /// + private string orderNumber; + public string OrderNumber + { + get { return orderNumber; } + set + { + SetProperty(ref orderNumber, value); + } + } + + #region 货架 + /// + /// 货架编号 + /// + private string shelfCode; + public string ShelfCode + { + get { return shelfCode; } + set + { + SetProperty(ref shelfCode, value); + } + } + + private List orderTypeItems; + public List OrderTypeItems + { + get { return orderTypeItems; } + set + { + SetProperty(ref orderTypeItems, value); + } + } + + private OrderTypeModel? selectedOrderTypeItem; + public OrderTypeModel? SelectedOrderTypeItem + { + get { return selectedOrderTypeItem; } + set + { + SetProperty(ref selectedOrderTypeItem, value); + } + } + public void InitOrderTypeItems() + { + //调用接口更新! + Task.Run(() => + { + OrderTypeItems = new List(); + OrderTypeItems.Add(new OrderTypeModel { Id = null, OrderTypeName = "全部" }); + + var body = new RequestBase() + { + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + }; + + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "batchBindMatDetail/getOrderTypes", body, "POST"); + if (Result != null && Result.Data != null && Result.Data.Lists.Count() > 0) + { + OrderTypeItems.AddRange(Result.Data.Lists); + } + + SelectedOrderTypeItem = OrderTypeItems.FirstOrDefault(); + }); + } + #endregion + + + + #endregion + + #region Command + public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); } + public void BtnReset() + { + if (OrderTypeItems != null) + { + SelectedOrderTypeItem = OrderTypeItems.FirstOrDefault(); + } + OrderNumber = string.Empty; + ShelfCode = string.Empty; + } + + public ICommand BtnSearchCommand { get => new DelegateCommand(BtnSearchReset); } + public void BtnSearchReset() + { + BtnSearch(true); + } + + public void BtnSearch(bool IsPageReset = true) + { + if (CurrentPage == 0 || IsPageReset) + { + CurrentPage = 1; + return; + } + #region 调用接口获取数据 + var dia = Dialog.Show(new TextDialog()); + try + { + var body = new GetMatDetailCurrentInfosByStationCodeRequest() + { + OrderTypeId = SelectedOrderTypeItem?.Id, + OrderNumber = OrderNumber, + ShelfCode = ShelfCode, + StationCode = LocalFile.Config.LocationCode, + + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + PageNumber = CurrentPage, + PageSize = PageSize, + }; + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "batchBindMatDetail/getMatDetailCurrentInfosByStationCode", body, "POST"); + if (Result != null && Result.Data != null && Result.Data.Lists != null) + { + DataGridItemSource = Result.Data.Lists; + MaxPage = Result.Data.MaxPage; + TotalCount = Result.Data.TotalCount; + } + else if(Result != null && !string.IsNullOrEmpty(Result.Message)) + { + Growl.Warning(Result.Message); + } + } + catch (Exception ex) + { + Growl.Error("加载数据失败:" + ex.Message); + } + finally + { + dia.Close(); + } + #endregion + } + + + public ICommand BtnEditCommand { get => new DelegateCommand(BtnEdit); } + public void BtnEdit() + { + //查询勾选的第一个数据 + var info = DataGridItemSource?.Where(t => t.IsSelected == true).FirstOrDefault(); + if (info == null) + { + Growl.Warning("请选择需要修改的数据!"); + } + else + { + var updateView = new MatDetailCurrentInfoUpdateView("修改货架存量", info); + updateView.ShowDialog(); + if (updateView.DialogResult == true) + { + CurrentPage = 1; + } + } + } + + public ICommand BtnDeleteCommand { get => new DelegateCommand(BtnDelete); } + public void BtnDelete() + { + Growl.Ask($"是否删除所有勾选的数据?", isConfirmed => + { + if (isConfirmed) + { + //查询勾选的第一个数据 + var needDeleteIds = DataGridItemSource?.Where(t => t.IsSelected == true) + .Select(t => t.Id) + .ToList(); + + if (needDeleteIds == null) + { + Growl.Warning("请选择需要修改的数据!"); + } + else + { + var body = new DeleteInfosRequest() + { + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + needDeleteIds = needDeleteIds, + }; + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "matDetailCurrenInfo/deleteMatDetailCurrentInfo", body, "POST"); + if (Result != null && Result.Code == 200) + { + BtnSearch(); + Growl.Success("删除成功!" + Result?.Message); + } + else + { + Growl.Error($"{Result?.Message?.ToString()}"); + } + } + } + return true; + }); + } + #endregion + + #region PageOperation 分页操作 + private int currentPage; + public int CurrentPage + { + get { return currentPage; } + set + { + SetProperty(ref currentPage, value); + BtnSearch(false); + } + } + + private int maxPage; + public int MaxPage + { + get { return maxPage; } + set { SetProperty(ref maxPage, value); } + } + + //总数量 + private int totalCount; + public int TotalCount + { + get { return totalCount; } + set { SetProperty(ref totalCount, value); } + } + + private int pageSize = 10; + public int PageSize + { + get => pageSize; + set + { + SetProperty(ref pageSize, value); + BtnSearch(true); + } + } + + + public ICommand BtnFirstPageCommand { get => new DelegateCommand(BtnFirstPage); } + public void BtnFirstPage() + { + CurrentPage = 1; + } + + public ICommand BtnPrePageCommand { get => new DelegateCommand(BtnPrePage); } + public void BtnPrePage() + { + if (CurrentPage > 1) + { + CurrentPage--; + } + } + + public ICommand BtnNextPageCommand { get => new DelegateCommand(BtnNextPage); } + public void BtnNextPage() + { + if (CurrentPage < MaxPage) + { + CurrentPage++; + } + } + + public ICommand BtnLastPageCommand { get => new DelegateCommand(BtnLastPage); } + public void BtnLastPage() + { + if (CurrentPage != MaxPage) + { + CurrentPage = MaxPage; + } + } + #endregion + } +} diff --git a/货架标准上位机/Views/BatchBindMatDetailView.xaml b/货架标准上位机/Views/BatchBindMatDetailView.xaml index 0ee3555..fd99201 100644 --- a/货架标准上位机/Views/BatchBindMatDetailView.xaml +++ b/货架标准上位机/Views/BatchBindMatDetailView.xaml @@ -39,9 +39,9 @@ FontSize="18"> @@ -51,32 +51,20 @@ Text="单据编号:" FontSize="18" > + FontSize="18" MinWidth="90" Text="{Binding OrderNumber}"> - - - + Text="{Binding ShelfCode}"> + +