From 720f7277fda53c943f9c319e59b7d42b93cda24e Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Mon, 24 Feb 2025 19:39:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=AE=B0=E5=BD=95=20?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GetMatDetailHistoryInfosRequest.cs | 19 + .../MatDetailHistoryInfoController.cs | 121 +++++++ .../ViewModels/InOutRecordViewModel.cs | 2 +- .../ViewModels/MatDetailHistoryInfoViewModel.cs | 336 ++++++++++++++++++ .../ViewModels/MatDetailStocktakingInfoViewModel.cs | 2 - .../ViewModels/MatInventoryDetailViewModel.cs | 12 +- .../ViewModels/OutInventoryAddDucumentViewModel.cs | 6 +- .../Views/MainWindows/MainWindow1.xaml | 2 +- .../Views/MatDetailHistoryInfoView.xaml | 328 +++++++++++++++++ .../Views/MatDetailHistoryInfoView.xaml.cs | 77 ++++ 10 files changed, 892 insertions(+), 13 deletions(-) create mode 100644 WCS.Model/ApiModel/MatDetailHistoryInfo/GetMatDetailHistoryInfosRequest.cs create mode 100644 WCS.WebApi/Controllers/MatDetailHistoryInfoController.cs create mode 100644 货架标准上位机/ViewModels/MatDetailHistoryInfoViewModel.cs create mode 100644 货架标准上位机/Views/MatDetailHistoryInfoView.xaml create mode 100644 货架标准上位机/Views/MatDetailHistoryInfoView.xaml.cs diff --git a/WCS.Model/ApiModel/MatDetailHistoryInfo/GetMatDetailHistoryInfosRequest.cs b/WCS.Model/ApiModel/MatDetailHistoryInfo/GetMatDetailHistoryInfosRequest.cs new file mode 100644 index 0000000..8afa445 --- /dev/null +++ b/WCS.Model/ApiModel/MatDetailHistoryInfo/GetMatDetailHistoryInfosRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WCS.Model.ApiModel.MatDetailHistoryInfo +{ + public class GetMatDetailHistoryInfosRequest : PageQueryRequestBase + { + public RecordTypeEnum? RecordType { get; set; } = null; + + public FunctionTypeEnum? FunctionType { get; set; } = null; + + public string ShelfCode { get; set; } = string.Empty; + + public string MatCode { get; set; } = string.Empty ; + + public string MatName { get; set; } = string.Empty; + } +} diff --git a/WCS.WebApi/Controllers/MatDetailHistoryInfoController.cs b/WCS.WebApi/Controllers/MatDetailHistoryInfoController.cs new file mode 100644 index 0000000..9d51e9b --- /dev/null +++ b/WCS.WebApi/Controllers/MatDetailHistoryInfoController.cs @@ -0,0 +1,121 @@ +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using NPOI.SS.Formula.Functions; +using SqlSugar; +using WCS.BLL; +using WCS.BLL.DbModels; +using WCS.BLL.HardWare; +using WCS.BLL.Manager; +using WCS.BLL.Services.IService; +using WCS.BLL.Services.Service; +using WCS.DAL.Db; +using WCS.DAL.DbModels; +using WCS.Model; +using WCS.Model.ApiModel.AGV; +using WCS.Model.ApiModel.Home; +using WCS.Model.ApiModel.MatBaseInfo; +using WCS.Model.ApiModel.MatDetailHistoryInfo; +using WCS.Model.ApiModel.StoreInfo; +using Mode = WCS.BLL.HardWare.Mode; + +namespace WCS.WebApi.Controllers +{ + /// + /// 主页面的接口 + /// + [ApiController] + [Route("[controller]")] + public class MatDetailHistoryInfoController : ControllerBase + { + public MatDetailHistoryInfoController() + { + + } + + [Route("getMatDetailHistoryInfos")] + [HttpPost(Name = "getMatDetailHistoryInfos")] + public async Task> getMatDetailHistoryInfos(GetMatDetailHistoryInfosRequest request) + { + try + { + var recordsQueryable = DbHelp.db.Queryable() + .WhereIF(request.RecordType != null, t => t.RecordType == request.RecordType) + .WhereIF(request.FunctionType != null, t => t.FunctionType == request.FunctionType) + .WhereIF(!string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode)) + .WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode)) + .WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName)) + ; + + var totalCount = await recordsQueryable.CountAsync(); + var records = await recordsQueryable + .OrderByDescending(t => t.ModifyTime) + .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}", + }; + } + } + + /// + /// 删除-假删除 + /// + /// + /// + [Route("deleteMatDetailHistoryInfo")] + [HttpPost(Name = "deleteMatDetailHistoryInfo")] + public async Task deleteMatDetailHistoryInfo(DeleteInfosRequest request) + { + + try + { + //先查询出具体的Id + var matDetailHistoryInfos = await DbHelp.db.Queryable() + .Where(t => request.needDeleteIds.Contains(t.Id)) + .ToListAsync(); + //执行删除 + var deleteRows = await DbHelp.db.Deleteable(matDetailHistoryInfos).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/货架标准上位机/ViewModels/InOutRecordViewModel.cs b/货架标准上位机/ViewModels/InOutRecordViewModel.cs index 5d26510..8a4f9d4 100644 --- a/货架标准上位机/ViewModels/InOutRecordViewModel.cs +++ b/货架标准上位机/ViewModels/InOutRecordViewModel.cs @@ -281,7 +281,7 @@ namespace 智慧物流软件系统.ViewModel // StoreCode = StoreCode, // Direction = SelectedDirection, - // ShelfTypeId = SelectedLocationAreaItems == null ? 0 : SelectedLocationAreaItems.Id, + // ShelfTypeId = SelectedRecordTypeItem == null ? 0 : SelectedRecordTypeItem.Id, // UserName = LocalStatic.CurrentUser, // DeviceType = LocalFile.Config.DeviceType, diff --git a/货架标准上位机/ViewModels/MatDetailHistoryInfoViewModel.cs b/货架标准上位机/ViewModels/MatDetailHistoryInfoViewModel.cs new file mode 100644 index 0000000..54c8b2e --- /dev/null +++ b/货架标准上位机/ViewModels/MatDetailHistoryInfoViewModel.cs @@ -0,0 +1,336 @@ +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.Stocktaking; +using WCS.Model.ApiModel.MatDetailHistoryInfo; +using WCS.Model.ApiModel.AGV; + +namespace 智慧物流软件系统.ViewModel +{ + public class MatDetailHistoryInfoViewModel : BindableBase + { + public MatDetailHistoryInfoViewModel() + { + //初始化下拉列表框 + //记录类型 + RecordTypeItems = ["全部"]; + var recordTypes = Enum.GetValues(typeof(RecordTypeEnum)) + .Cast() + .ToList(); + foreach (var recordType in recordTypes) + { + RecordTypeItems.Add(recordType.ToString()); + } + //操作功能 + FunctionTypeItems = ["全部"]; + var functionTypes = Enum.GetValues(typeof(FunctionTypeEnum)) + .Cast() + .ToList(); + foreach (var functionType in functionTypes) + { + FunctionTypeItems.Add(functionType.ToString()); + } + + } + + #region Property + private List dataGridItemSource; + public List DataGridItemSource + { + get { return dataGridItemSource; } + set + { + SetProperty(ref dataGridItemSource, value); + } + } + + private MatDetailHistoryInfoModel selectedataGridItem; + public MatDetailHistoryInfoModel SelectedataGridItem + { + get { return selectedataGridItem; } + set + { + SetProperty(ref selectedataGridItem, value); + } + } + + + #region + private string shelfCode; + public string ShelfCode + { + get { return shelfCode; } + set + { + SetProperty(ref shelfCode, value); + } + } + + private List recordTypeItems; + public List RecordTypeItems + { + get { return recordTypeItems; } + set + { + SetProperty(ref recordTypeItems, value); + } + } + private string selectedRecordTypeItem; + public string SelectedRecordTypeItem + { + get { return selectedRecordTypeItem; } + set + { + SetProperty(ref selectedRecordTypeItem, value); + } + } + + private List functionTypeItems; + public List FunctionTypeItems + { + get { return functionTypeItems; } + set + { + SetProperty(ref functionTypeItems, value); + } + } + private string selectedFunctionTypeItem; + public string SelectedFunctionTypeItem + { + get { return selectedFunctionTypeItem; } + set + { + SetProperty(ref selectedFunctionTypeItem, value); + } + } + + /// + /// 物料编码 + /// + private string matCode; + public string MatCode + { + get { return matCode; } + set + { + SetProperty(ref matCode, value); + } + } + + /// + /// 物料名称 + /// + private string matName; + public string MatName + { + get { return matName; } + set + { + SetProperty(ref matName, value); + } + } + #endregion + + #endregion + + #region Command + public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); } + public void BtnReset() + { + SelectedRecordTypeItem = RecordTypeItems.First(); + SelectedFunctionTypeItem = FunctionTypeItems.First(); + + ShelfCode = string.Empty; + + MatCode = string.Empty; + MatName = 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 isSelectedRecordType = Enum.TryParse(SelectedRecordTypeItem, out RecordTypeEnum recordType); + var isSelectedFunctionType = Enum.TryParse(SelectedFunctionTypeItem, out FunctionTypeEnum functionType); + + var body = new GetMatDetailHistoryInfosRequest() + { + FunctionType = isSelectedFunctionType ? functionType : null, + RecordType = isSelectedRecordType ? recordType : null, + + ShelfCode = ShelfCode, + MatCode = MatCode, + MatName = MatName, + + UserName = LocalStatic.CurrentUser, + DeviceType = LocalFile.Config.DeviceType, + PageNumber = CurrentPage, + PageSize = PageSize, + }; + var Result = ApiHelp.GetDataFromHttp>(LocalFile.Config.ApiIpHost + "matDetailHistoryInfo/getMatDetailHistoryInfos", body, "POST"); + if (Result != null && Result.Data != null && Result.Data.Lists != null) + { + DataGridItemSource = Result.Data.Lists; + MaxPage = Result.Data.MaxPage; + TotalCount = Result.Data.TotalCount; + } + } + catch (Exception ex) + { + Growl.Error("加载数据失败:" + ex.Message); + } + finally + { + dia.Close(); + } + #endregion + } + + 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 + "matDetailHistoryInfo/deleteMatDetailHistoryInfo", 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/货架标准上位机/ViewModels/MatDetailStocktakingInfoViewModel.cs b/货架标准上位机/ViewModels/MatDetailStocktakingInfoViewModel.cs index 8ee958c..23346c0 100644 --- a/货架标准上位机/ViewModels/MatDetailStocktakingInfoViewModel.cs +++ b/货架标准上位机/ViewModels/MatDetailStocktakingInfoViewModel.cs @@ -29,8 +29,6 @@ namespace 智慧物流软件系统.ViewModel { StocktakingStatuses.Add(status.ToString()); } - - } #region Property diff --git a/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs b/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs index dbe56e0..31dd549 100644 --- a/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs +++ b/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs @@ -253,8 +253,8 @@ namespace 智慧物流软件系统.ViewModel // MatCode = MatCode, // StoreCode = StoreCode, - // ShelfTypeId = SelectedLocationAreaItems == null ? 0 : SelectedLocationAreaItems.Id, - // LocationCode = LocationCode, + // ShelfTypeId = SelectedRecordTypeItem == null ? 0 : SelectedRecordTypeItem.Id, + // ShelfCode = ShelfCode, // UserName = LocalStatic.CurrentUser, // DeviceType = LocalFile.Config.DeviceType, @@ -342,8 +342,8 @@ namespace 智慧物流软件系统.ViewModel // MatCode = MatCode, // StoreCode = StoreCode, - // ShelfTypeId = SelectedLocationAreaItems == null ? 0 : SelectedLocationAreaItems.Id, - // LocationCode = LocationCode, + // ShelfTypeId = SelectedRecordTypeItem == null ? 0 : SelectedRecordTypeItem.Id, + // ShelfCode = ShelfCode, // UserName = LocalStatic.CurrentUser, // DeviceType = LocalFile.Config.DeviceType, @@ -443,8 +443,8 @@ namespace 智慧物流软件系统.ViewModel // MatCode = MatCode, // StoreCode = StoreCode, - // ShelfTypeId = SelectedLocationAreaItems == null ? 0 : SelectedLocationAreaItems.Id, - // LocationCode = LocationCode, + // ShelfTypeId = SelectedRecordTypeItem == null ? 0 : SelectedRecordTypeItem.Id, + // ShelfCode = ShelfCode, // UserName = LocalStatic.CurrentUser, // DeviceType = LocalFile.Config.DeviceType, diff --git a/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs b/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs index dcf71cc..4ef1448 100644 --- a/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs +++ b/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs @@ -115,7 +115,7 @@ namespace 智慧物流软件系统.ViewModels { HandyControl.Controls.MessageBox.Show("请选择货架类型!"); } - //var window = new OutInventoryAddMatView(SelectedLocationAreaItems.Id); + //var window = new OutInventoryAddMatView(SelectedRecordTypeItem.Id); //window.Owner = Application.Current.MainWindow; //window.Topmost = true; @@ -192,8 +192,8 @@ namespace 智慧物流软件系统.ViewModels // { // OrderType = "出库", // OrderSource = "WCS前端", - // ShelfTypeId = SelectedLocationAreaItems.Id, - // ShelfTypeName = SelectedLocationAreaItems.ShelfTypeName, + // ShelfTypeId = SelectedRecordTypeItem.Id, + // ShelfTypeName = SelectedRecordTypeItem.ShelfTypeName, // ItemList = DataGridItemSource.Select(t => new MatCodeItemList() // { // MatCode = t.MatCode, diff --git a/货架标准上位机/Views/MainWindows/MainWindow1.xaml b/货架标准上位机/Views/MainWindows/MainWindow1.xaml index f201852..47ff8ed 100644 --- a/货架标准上位机/Views/MainWindows/MainWindow1.xaml +++ b/货架标准上位机/Views/MainWindows/MainWindow1.xaml @@ -226,7 +226,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10条/页 + 20条/页 + 50条/页 + 100条/页 + 500条/页 + + + + + + + + + + + + + + + + +