From 90a273f924e78dac0387694fae9898579dc790f4 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Tue, 18 Mar 2025 10:39:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8F=91=E9=80=81=E4=BB=BB=E5=8A=A1=E6=97=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B4=A7=E6=9E=B6=E7=BC=96=E7=A0=81=E8=AF=86?= =?UTF-8?q?=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2.客户端功能优化:任务管理无法通过货架编码等进行模糊搜索 3.数据记录功能增加导出功能 --- WCS.BLL/Manager/AGVManager.cs | 1 + WCS.WebApi/Controllers/AgvTaskController.cs | 8 +-- .../MatDetailHistoryInfoController.cs | 52 +++++++++++++++++++ .../ViewModels/MatDetailHistoryInfoViewModel.cs | 48 +++++++++++++++++ 4 files changed, 105 insertions(+), 4 deletions(-) diff --git a/WCS.BLL/Manager/AGVManager.cs b/WCS.BLL/Manager/AGVManager.cs index bca4d35..62198ec 100644 --- a/WCS.BLL/Manager/AGVManager.cs +++ b/WCS.BLL/Manager/AGVManager.cs @@ -285,6 +285,7 @@ namespace WCS.BLL.Manager var body = new GenAgvSchedulingTaskRequest() { positionCodePath = positionCodePathItems, + podCode = shelfCode,//发送任务时添加货架编码 }; var response = ApiHelp.GetDataFromHttp(url, body, "POST", true); if (response.code == "0" && response.message == "成功") diff --git a/WCS.WebApi/Controllers/AgvTaskController.cs b/WCS.WebApi/Controllers/AgvTaskController.cs index fb92130..2aa5863 100644 --- a/WCS.WebApi/Controllers/AgvTaskController.cs +++ b/WCS.WebApi/Controllers/AgvTaskController.cs @@ -83,10 +83,10 @@ namespace WCS.WebApi.Controllers } var recordsQueryable = DbHelp.db.Queryable() - .WhereIF(string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode)) - .WhereIF(string.IsNullOrEmpty(request.CreateUser), t => t.CreateUser.Contains(request.CreateUser)) - .WhereIF(string.IsNullOrEmpty(request.StartLocationCode), t => t.StartLocationCode.Contains(request.StartLocationCode)) - .WhereIF(string.IsNullOrEmpty(request.EndLocationCode), t => t.StartLocationCode.Contains(request.EndLocationCode)) + .WhereIF(!string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode)) + .WhereIF(!string.IsNullOrEmpty(request.CreateUser), t => t.CreateUser.Contains(request.CreateUser)) + .WhereIF(!string.IsNullOrEmpty(request.StartLocationCode), t => t.StartLocationCode.Contains(request.StartLocationCode)) + .WhereIF(!string.IsNullOrEmpty(request.EndLocationCode), t => t.StartLocationCode.Contains(request.EndLocationCode)) .WhereIF(request.TaskStatus != null, t => t.TaskStatus == request.TaskStatus); var totalCount = await recordsQueryable.CountAsync(); diff --git a/WCS.WebApi/Controllers/MatDetailHistoryInfoController.cs b/WCS.WebApi/Controllers/MatDetailHistoryInfoController.cs index 9d51e9b..90bd6a3 100644 --- a/WCS.WebApi/Controllers/MatDetailHistoryInfoController.cs +++ b/WCS.WebApi/Controllers/MatDetailHistoryInfoController.cs @@ -14,8 +14,10 @@ using WCS.Model; using WCS.Model.ApiModel.AGV; using WCS.Model.ApiModel.Home; using WCS.Model.ApiModel.MatBaseInfo; +using WCS.Model.ApiModel.MatDetailCurrentInfo; using WCS.Model.ApiModel.MatDetailHistoryInfo; using WCS.Model.ApiModel.StoreInfo; +using WCS.WebApi.Helper; using Mode = WCS.BLL.HardWare.Mode; namespace WCS.WebApi.Controllers @@ -117,5 +119,55 @@ namespace WCS.WebApi.Controllers } + [Route("exportMatDetailHistoryInfo")] + [HttpPost(Name = "exportMatDetailHistoryInfo")] + public async Task exportMatDetailHistoryInfo(GetMatDetailHistoryInfosRequest request) + { + 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 result = await recordsQueryable + .OrderByDescending(t => t.ModifyTime) + //.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize) + .ToListAsync(); + //生成序号 + for (int i = 0; i < result.Count; i++) + { + result[i].RowNumber = (request.PageNumber - 1) * request.PageSize + i + 1; + } + var columns = new[] + { + new ExportableColumn("序号","RowNumber"), + + new ExportableColumn("货架编码","ShelfCode"), + new ExportableColumn("记录类型","RecordType"), + new ExportableColumn("操作功能","FunctionType"), + + new ExportableColumn("货架编码","MatCode"), + new ExportableColumn("物料名称","MatName"), + new ExportableColumn("物料批次","MatBatch"), + new ExportableColumn("物料规格","MatSpec"), + + new ExportableColumn("更新前数量", "BeforeQty"), + new ExportableColumn("更新后数量", "AfterQty"), + + + new ExportableColumn("更新人", "ModifyUser"), + new ExportableColumn("更新时间", "ModifyTime"), + }; + if (result == null) + { + return NotFound(); + } + else + return ExportExcelHelper.Export("导出数据", columns, result); + } + } } diff --git a/货架标准上位机/ViewModels/MatDetailHistoryInfoViewModel.cs b/货架标准上位机/ViewModels/MatDetailHistoryInfoViewModel.cs index 54c8b2e..8ac964d 100644 --- a/货架标准上位机/ViewModels/MatDetailHistoryInfoViewModel.cs +++ b/货架标准上位机/ViewModels/MatDetailHistoryInfoViewModel.cs @@ -24,6 +24,7 @@ using WCS.Model.ApiModel.MatDetailCurrentInfo; using WCS.Model.ApiModel.Stocktaking; using WCS.Model.ApiModel.MatDetailHistoryInfo; using WCS.Model.ApiModel.AGV; +using System.Data.SQLite; namespace 智慧物流软件系统.ViewModel { @@ -258,6 +259,53 @@ namespace 智慧物流软件系统.ViewModel return true; }); } + + + /// + /// 导出数据为Excel文件 + /// + public ICommand BtnExportCommand { get => new DelegateCommand(BtnExport); } + public async void BtnExport() + { + try + { + #region 选择文件保存路径 + Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog(); + sfd.Title = "选择文件保存路径"; + sfd.Filter = ".xlsx文件(*.xlsx)|*.xlsx"; + sfd.FileName = "数据记录" + DateTime.Now.ToString("yyyyMMddhhmmss"); + sfd.OverwritePrompt = true; + if (sfd.ShowDialog() != true) + { + return; + } + string path = sfd.FileName; + #endregion + + 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, + }; + await ApiHelp.PostDownloadFileAsync(path, System.Net.Http.HttpMethod.Post, LocalFile.Config.ApiIpHost + "matDetailHistoryInfo/exportMatDetailHistoryInfo", body); + Growl.Success("导出成功!"); + } + catch (Exception ex) + { + Growl.Error("导出失败:" + ex.Message); + } + } #endregion #region PageOperation 分页操作