From 90dc7e2f0d419d40a823cd26b01e352d0be4ffee Mon Sep 17 00:00:00 2001 From: 李曜臣 Date: Thu, 2 Apr 2026 16:31:17 +0800 Subject: [PATCH] 重新打印优化 --- 美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/PrintLogItemDto.cs | 22 ++-------------------- 美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs | 40 ++-------------------------------------- 项目相关文档/标签模块接口对接说明.md | 11 ++--------- 3 files changed, 6 insertions(+), 67 deletions(-) diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/PrintLogItemDto.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/PrintLogItemDto.cs index 85a1cf3..f006a1f 100644 --- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/PrintLogItemDto.cs +++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/UsAppLabeling/PrintLogItemDto.cs @@ -32,13 +32,8 @@ public class PrintLogItemDto /// 模板尺寸(来自 fl_label_template.Width/Height/Unit) public string? LabelSizeText { get; set; } - /// 本次任务落库的渲染模板 JSON(fl_label_print_task.RenderTemplateJson) - public string? RenderTemplateJson { get; set; } - - /// - /// 本次打印的内容快照(来自 fl_label_print_data,按 PrintTaskId 关联) - /// - public List PrintDataList { get; set; } = new(); + /// 打印入参 JSON(直接来自 fl_label_print_task.PrintInputJson 列) + public string? PrintInputJson { get; set; } /// 打印时间(PrintedAt ?? CreationTime) public DateTime PrintedAt { get; set; } @@ -49,16 +44,3 @@ public class PrintLogItemDto /// 门店名称 public string LocationName { get; set; } = "无"; } - -/// -/// 打印内容快照项(fl_label_print_data) -/// -public class PrintLogDataItemDto -{ - public string ElementId { get; set; } = string.Empty; - - public string? RenderValue { get; set; } - - public object? RenderConfigJson { get; set; } -} - diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs index bfbadbd..1a89a0d 100644 --- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs +++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppLabelingAppService.cs @@ -775,48 +775,13 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ TemplateWidth = tpl.Width, TemplateHeight = tpl.Height, TemplateUnit = tpl.Unit, - t.RenderTemplateJson, + t.PrintInputJson, t.PrintedAt, t.CreationTime }); var pageRows = await query.ToPageListAsync(input.SkipCount, input.MaxResultCount, total); - var taskIds = pageRows.Select(x => x.Id).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToList(); - - var dataRows = taskIds.Count == 0 - ? new List() - : await _dbContext.SqlSugarClient.Queryable() - .Where(x => taskIds.Contains(x.PrintTaskId)) - .ToListAsync(); - - var dataMap = dataRows - .GroupBy(x => x.PrintTaskId) - .ToDictionary( - g => g.Key, - g => g.Select(d => - { - object? cfg = null; - if (!string.IsNullOrWhiteSpace(d.RenderConfigJson)) - { - try - { - cfg = JsonSerializer.Deserialize(d.RenderConfigJson); - } - catch - { - cfg = null; - } - } - - return new PrintLogDataItemDto - { - ElementId = d.ElementId, - RenderValue = d.RenderValue, - RenderConfigJson = cfg - }; - }).ToList()); - var items = pageRows.Select(x => new PrintLogItemDto { TaskId = x.Id, @@ -828,8 +793,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ ProductName = string.IsNullOrWhiteSpace(x.ProductName) ? "无" : x.ProductName.Trim(), TypeName = x.TypeName ?? string.Empty, LabelSizeText = FormatLabelSizeWithUnit(x.TemplateWidth, x.TemplateHeight, x.TemplateUnit), - RenderTemplateJson = x.RenderTemplateJson, - PrintDataList = dataMap.TryGetValue(x.Id, out var list) ? list : new List(), + PrintInputJson = x.PrintInputJson, PrintedAt = x.PrintedAt ?? x.CreationTime, OperatorName = operatorName, LocationName = locationName diff --git a/项目相关文档/标签模块接口对接说明.md b/项目相关文档/标签模块接口对接说明.md index cc13fe6..d21d1dc 100644 --- a/项目相关文档/标签模块接口对接说明.md +++ b/项目相关文档/标签模块接口对接说明.md @@ -1021,19 +1021,12 @@ curl -X POST "http://localhost:19001/api/app/us-app-labeling/print" \ | `productName` | string | 产品名(来自 fl_product.ProductName;无则 “无”) | | `typeName` | string | 标签类型名称(来自 fl_label_type.TypeName) | | `labelSizeText` | string | 模板尺寸(宽高+单位,如 `2.00x2.00inch` / `6.00x4.00cm`) | -| `renderTemplateJson` | string | 本次任务落库的渲染模板 JSON(`fl_label_print_task.RenderTemplateJson`) | -| `printDataList` | PrintLogDataItemDto[] | 本次打印内容快照(来自 fl_label_print_data,按 taskId 关联) | +| `printInputJson` | string | **直接**来自表 `fl_label_print_task.PrintInputJson`(前端打印时传入的打印输入 JSON 字符串;无则为 null) | | `printedAt` | string | 打印时间(PrintedAt ?? CreationTime) | | `operatorName` | string | 操作人姓名(当前登录账号 Name) | | `locationName` | string | 门店名称 | -`PrintLogDataItemDto`: - -| 字段 | 类型 | 说明 | -|---|---|---| -| `elementId` | string | 模板组件Id(fl_label_print_data.ElementId) | -| `renderValue` | string | 最终渲染值(fl_label_print_data.RenderValue) | -| `renderConfigJson` | object | 最终渲染配置(fl_label_print_data.RenderConfigJson 反序列化) | +> 本接口**不**返回 `printDataList`;逐元素快照仍在表 `fl_label_print_data` 中,可按 `PrintTaskId` 自行查询。 #### curl -- libgit2 0.21.4