Commit 90dc7e2f0d419d40a823cd26b01e352d0be4ffee

Authored by 李曜臣
1 parent 7af95447

重新打印优化

美国版/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 @@ -32,13 +32,8 @@ public class PrintLogItemDto
32 /// <summary>模板尺寸(来自 fl_label_template.Width/Height/Unit)</summary> 32 /// <summary>模板尺寸(来自 fl_label_template.Width/Height/Unit)</summary>
33 public string? LabelSizeText { get; set; } 33 public string? LabelSizeText { get; set; }
34 34
35 - /// <summary>本次任务落库的渲染模板 JSON(fl_label_print_task.RenderTemplateJson)</summary>  
36 - public string? RenderTemplateJson { get; set; }  
37 -  
38 - /// <summary>  
39 - /// 本次打印的内容快照(来自 fl_label_print_data,按 PrintTaskId 关联)  
40 - /// </summary>  
41 - public List<PrintLogDataItemDto> PrintDataList { get; set; } = new(); 35 + /// <summary>打印入参 JSON(直接来自 fl_label_print_task.PrintInputJson 列)</summary>
  36 + public string? PrintInputJson { get; set; }
42 37
43 /// <summary>打印时间(PrintedAt ?? CreationTime)</summary> 38 /// <summary>打印时间(PrintedAt ?? CreationTime)</summary>
44 public DateTime PrintedAt { get; set; } 39 public DateTime PrintedAt { get; set; }
@@ -49,16 +44,3 @@ public class PrintLogItemDto @@ -49,16 +44,3 @@ public class PrintLogItemDto
49 /// <summary>门店名称</summary> 44 /// <summary>门店名称</summary>
50 public string LocationName { get; set; } = "无"; 45 public string LocationName { get; set; } = "无";
51 } 46 }
52 -  
53 -/// <summary>  
54 -/// 打印内容快照项(fl_label_print_data)  
55 -/// </summary>  
56 -public class PrintLogDataItemDto  
57 -{  
58 - public string ElementId { get; set; } = string.Empty;  
59 -  
60 - public string? RenderValue { get; set; }  
61 -  
62 - public object? RenderConfigJson { get; set; }  
63 -}  
64 -  
美国版/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 @@ -775,48 +775,13 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
775 TemplateWidth = tpl.Width, 775 TemplateWidth = tpl.Width,
776 TemplateHeight = tpl.Height, 776 TemplateHeight = tpl.Height,
777 TemplateUnit = tpl.Unit, 777 TemplateUnit = tpl.Unit,
778 - t.RenderTemplateJson, 778 + t.PrintInputJson,
779 t.PrintedAt, 779 t.PrintedAt,
780 t.CreationTime 780 t.CreationTime
781 }); 781 });
782 782
783 var pageRows = await query.ToPageListAsync(input.SkipCount, input.MaxResultCount, total); 783 var pageRows = await query.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
784 784
785 - var taskIds = pageRows.Select(x => x.Id).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToList();  
786 -  
787 - var dataRows = taskIds.Count == 0  
788 - ? new List<FlLabelPrintDataDbEntity>()  
789 - : await _dbContext.SqlSugarClient.Queryable<FlLabelPrintDataDbEntity>()  
790 - .Where(x => taskIds.Contains(x.PrintTaskId))  
791 - .ToListAsync();  
792 -  
793 - var dataMap = dataRows  
794 - .GroupBy(x => x.PrintTaskId)  
795 - .ToDictionary(  
796 - g => g.Key,  
797 - g => g.Select(d =>  
798 - {  
799 - object? cfg = null;  
800 - if (!string.IsNullOrWhiteSpace(d.RenderConfigJson))  
801 - {  
802 - try  
803 - {  
804 - cfg = JsonSerializer.Deserialize<object>(d.RenderConfigJson);  
805 - }  
806 - catch  
807 - {  
808 - cfg = null;  
809 - }  
810 - }  
811 -  
812 - return new PrintLogDataItemDto  
813 - {  
814 - ElementId = d.ElementId,  
815 - RenderValue = d.RenderValue,  
816 - RenderConfigJson = cfg  
817 - };  
818 - }).ToList());  
819 -  
820 var items = pageRows.Select(x => new PrintLogItemDto 785 var items = pageRows.Select(x => new PrintLogItemDto
821 { 786 {
822 TaskId = x.Id, 787 TaskId = x.Id,
@@ -828,8 +793,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ @@ -828,8 +793,7 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
828 ProductName = string.IsNullOrWhiteSpace(x.ProductName) ? "无" : x.ProductName.Trim(), 793 ProductName = string.IsNullOrWhiteSpace(x.ProductName) ? "无" : x.ProductName.Trim(),
829 TypeName = x.TypeName ?? string.Empty, 794 TypeName = x.TypeName ?? string.Empty,
830 LabelSizeText = FormatLabelSizeWithUnit(x.TemplateWidth, x.TemplateHeight, x.TemplateUnit), 795 LabelSizeText = FormatLabelSizeWithUnit(x.TemplateWidth, x.TemplateHeight, x.TemplateUnit),
831 - RenderTemplateJson = x.RenderTemplateJson,  
832 - PrintDataList = dataMap.TryGetValue(x.Id, out var list) ? list : new List<PrintLogDataItemDto>(), 796 + PrintInputJson = x.PrintInputJson,
833 PrintedAt = x.PrintedAt ?? x.CreationTime, 797 PrintedAt = x.PrintedAt ?? x.CreationTime,
834 OperatorName = operatorName, 798 OperatorName = operatorName,
835 LocationName = locationName 799 LocationName = locationName
项目相关文档/标签模块接口对接说明.md
@@ -1021,19 +1021,12 @@ curl -X POST &quot;http://localhost:19001/api/app/us-app-labeling/print&quot; \ @@ -1021,19 +1021,12 @@ curl -X POST &quot;http://localhost:19001/api/app/us-app-labeling/print&quot; \
1021 | `productName` | string | 产品名(来自 fl_product.ProductName;无则 “无”) | 1021 | `productName` | string | 产品名(来自 fl_product.ProductName;无则 “无”) |
1022 | `typeName` | string | 标签类型名称(来自 fl_label_type.TypeName) | 1022 | `typeName` | string | 标签类型名称(来自 fl_label_type.TypeName) |
1023 | `labelSizeText` | string | 模板尺寸(宽高+单位,如 `2.00x2.00inch` / `6.00x4.00cm`) | 1023 | `labelSizeText` | string | 模板尺寸(宽高+单位,如 `2.00x2.00inch` / `6.00x4.00cm`) |
1024 -| `renderTemplateJson` | string | 本次任务落库的渲染模板 JSON(`fl_label_print_task.RenderTemplateJson`) |  
1025 -| `printDataList` | PrintLogDataItemDto[] | 本次打印内容快照(来自 fl_label_print_data,按 taskId 关联) | 1024 +| `printInputJson` | string | **直接**来自表 `fl_label_print_task.PrintInputJson`(前端打印时传入的打印输入 JSON 字符串;无则为 null) |
1026 | `printedAt` | string | 打印时间(PrintedAt ?? CreationTime) | 1025 | `printedAt` | string | 打印时间(PrintedAt ?? CreationTime) |
1027 | `operatorName` | string | 操作人姓名(当前登录账号 Name) | 1026 | `operatorName` | string | 操作人姓名(当前登录账号 Name) |
1028 | `locationName` | string | 门店名称 | 1027 | `locationName` | string | 门店名称 |
1029 1028
1030 -`PrintLogDataItemDto`:  
1031 -  
1032 -| 字段 | 类型 | 说明 |  
1033 -|---|---|---|  
1034 -| `elementId` | string | 模板组件Id(fl_label_print_data.ElementId) |  
1035 -| `renderValue` | string | 最终渲染值(fl_label_print_data.RenderValue) |  
1036 -| `renderConfigJson` | object | 最终渲染配置(fl_label_print_data.RenderConfigJson 反序列化) | 1029 +> 本接口**不**返回 `printDataList`;逐元素快照仍在表 `fl_label_print_data` 中,可按 `PrintTaskId` 自行查询。
1037 1030
1038 #### curl 1031 #### curl
1039 1032