From 885bd60ed54a0642c48c57a3d685cba24e4c763b Mon Sep 17 00:00:00 2001 From: huanghongfeng <huanghongfeng@hnkhzn.com> Date: 星期日, 08 十二月 2024 11:33:07 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs" index cb9a605..ce649d1 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Task_HtyService.cs" @@ -1,4 +1,6 @@ 锘縰sing AutoMapper; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; using MailKit.Search; using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; using SqlSugar; @@ -30,6 +32,7 @@ using WIDESEA_ITaskInfoService; using WIDESEA_Model.Models; using WIDESEA_TaskInfoRepository; +using OrderByType = SqlSugar.OrderByType; namespace WIDESEA_TaskInfoService; @@ -71,9 +74,60 @@ CreateDate = task.CreateDate, ModifyDate = DateTime.Now, Modifier = task.Modifier, - Remark = task.Remark + Remark = task.Remark, + PLCTo=task.PLCTo, + PalletCodequantity=task.PalletCodequantity, + MaterialType = task.MaterialType }; BaseDal.AddData(task_Hty); return content; } + + //瀵煎嚭 + public override WebResponseContent Export(PageDataOptions options) + { + WebResponseContent content = new WebResponseContent(); + try + { + string savePath = AppDomain.CurrentDomain.BaseDirectory + $"ExcelExport"; + IExporter exporter = new ExcelExporter(); + //娣诲姞鏉′欢 + string wheres = options.ValidatePageOptions(TProperties); + //鑾峰彇鎺掑簭瀛楁 + Dictionary<string, OrderByType> orderbyDic = options.GetPageDataSort(TProperties); + List<Dt_Task_Hty> entities = BaseDal.QueryData(wheres, orderbyDic); + var stockdct = entities + .GroupBy(x => new { x.TaskType,x.MaterialType }) + .Select(g => new Dt_Task_Htyt + { + MaterialType = g.Key.MaterialType.ToString() == "0" ? "鍘熸潗鏂�" : "鎴愬搧", // 杩欓噷璧嬪�肩粰 MaterielCode + TaskType= g.Key.TaskType.ToString() == "100" ? "鍑哄簱" : "鍏ュ簱", + PalletCodequantity = g.Count(), + }) + .ToList(); + + byte[] data = exporter.ExportAsByteArray(stockdct).Result; + + string fileName = "1.xlsx"; + + FileHelper.WriteFile(savePath, fileName, data); + + content = WebResponseContent.Instance.OK(data: savePath + "\\" + fileName); + } + catch (Exception ex) + { + content = WebResponseContent.Instance.Error(ex.Message); + } + return content; + } + + public class Dt_Task_Htyt + { + [ExporterHeader(DisplayName = "鐗╂枡绫诲瀷")] + public string MaterialType { get; set;} + [ExporterHeader(DisplayName = "浠诲姟绫诲瀷")] + public string TaskType { get; set; } + [ExporterHeader(DisplayName = "鏁伴噺")] + public int PalletCodequantity { get; set; } + } } \ No newline at end of file -- Gitblit v1.9.3