diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateCreateInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateCreateInputVo.cs
new file mode 100644
index 0000000..69fc897
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateCreateInputVo.cs
@@ -0,0 +1,11 @@
+namespace FoodLabeling.Application.Contracts.Dtos.AlertTemplate;
+
+/// 告警模板新增/编辑入参
+public class AlertTemplateCreateInputVo
+{
+ public string TemplateName { get; set; } = string.Empty;
+
+ public string DateTimeFormat { get; set; } = string.Empty;
+
+ public bool State { get; set; } = true;
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateDto.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateDto.cs
new file mode 100644
index 0000000..c09253d
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateDto.cs
@@ -0,0 +1,17 @@
+namespace FoodLabeling.Application.Contracts.Dtos.AlertTemplate;
+
+/// 告警模板详情/列表项
+public class AlertTemplateDto
+{
+ public string Id { get; set; } = string.Empty;
+
+ public string TemplateName { get; set; } = string.Empty;
+
+ public string DateTimeFormat { get; set; } = string.Empty;
+
+ public bool State { get; set; }
+
+ public DateTime CreationTime { get; set; }
+
+ public DateTime? LastModificationTime { get; set; }
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateGetListInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateGetListInputVo.cs
new file mode 100644
index 0000000..4f89e5b
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateGetListInputVo.cs
@@ -0,0 +1,11 @@
+using Volo.Abp.Application.Dtos;
+
+namespace FoodLabeling.Application.Contracts.Dtos.AlertTemplate;
+
+/// 告警模板分页列表入参
+public class AlertTemplateGetListInputVo : PagedAndSortedResultRequestDto
+{
+ public string? Keyword { get; set; }
+
+ public bool? State { get; set; }
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateOptionDto.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateOptionDto.cs
new file mode 100644
index 0000000..80c27cc
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AlertTemplate/AlertTemplateOptionDto.cs
@@ -0,0 +1,11 @@
+namespace FoodLabeling.Application.Contracts.Dtos.AlertTemplate;
+
+/// 告警模板下拉项(仅启用)
+public class AlertTemplateOptionDto
+{
+ public string Id { get; set; } = string.Empty;
+
+ public string TemplateName { get; set; } = string.Empty;
+
+ public string DateTimeFormat { get; set; } = string.Empty;
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AppUpdate/AppUpdateDto.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AppUpdate/AppUpdateDto.cs
new file mode 100644
index 0000000..610f521
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AppUpdate/AppUpdateDto.cs
@@ -0,0 +1,29 @@
+namespace FoodLabeling.Application.Contracts.Dtos.AppUpdate;
+
+/// App 版本检查出参(对齐锁控面板 /api/app/update)。
+public class AppUpdateDto
+{
+ public string PackageName { get; set; } = string.Empty;
+
+ public int VersionCode { get; set; }
+
+ public string VersionName { get; set; } = string.Empty;
+
+ public bool ForceUpdate { get; set; }
+
+ public string Changelog { get; set; } = string.Empty;
+
+ /// 完整 APK 下载地址
+ public string ApkUrl { get; set; } = string.Empty;
+
+ public bool ApkReady { get; set; }
+
+ /// 服务端实际解析到的 APK 路径(排查 apkReady=false;前端可忽略)
+ public string? ApkResolvedPath { get; set; }
+
+ ///
+ /// 入参带了本地 versionCode 时:远程更大且 apkReady 则为 true;
+ /// 未传本地版本时为 null,由前端自行比较。
+ ///
+ public bool? HasUpdate { get; set; }
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelBatchCreateItemInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelBatchCreateItemInputVo.cs
index 6a91e82..91e1c7c 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelBatchCreateItemInputVo.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelBatchCreateItemInputVo.cs
@@ -32,6 +32,9 @@ public class LabelBatchCreateItemInputVo
public List ProductIds { get; set; } = new();
+ /// 绑定培训文件 Id(fl_training_file.Id);可空
+ public List? BoundTrainingFileIds { get; set; }
+
/// 标签级模板数据(落库 fl_label.LabelInfoJson);通常批量导入走模板 ProductDefaults
public object? LabelInfoJson { get; set; }
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelCreateInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelCreateInputVo.cs
index 69d0d12..c4385bf 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelCreateInputVo.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelCreateInputVo.cs
@@ -57,6 +57,9 @@ public class LabelCreateInputVo
public List ProductIds { get; set; } = new();
+ /// 绑定培训文件 Id(fl_training_file.Id);可空
+ public List? BoundTrainingFileIds { get; set; }
+
public object? LabelInfoJson { get; set; }
public bool State { get; set; } = true;
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelGetListOutputDto.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelGetListOutputDto.cs
index 4c8b4aa..5ea3624 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelGetListOutputDto.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelGetListOutputDto.cs
@@ -32,6 +32,12 @@ public class LabelGetListOutputDto
///
public string Products { get; set; } = string.Empty;
+ /// 绑定的培训文件 Id
+ public List BoundTrainingFileIds { get; set; } = new();
+
+ /// 绑定培训文件名称,逗号拼接
+ public string BoundTrainingFiles { get; set; } = string.Empty;
+
public string TemplateName { get; set; } = string.Empty;
///
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelGetOutputDto.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelGetOutputDto.cs
index 8b2d0f2..08c320e 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelGetOutputDto.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelGetOutputDto.cs
@@ -54,5 +54,11 @@ public class LabelGetOutputDto
public object? LabelInfoJson { get; set; }
public List ProductIds { get; set; } = new();
+
+ /// 绑定的培训文件 Id
+ public List BoundTrainingFileIds { get; set; } = new();
+
+ /// 绑定培训文件名称,逗号拼接
+ public string BoundTrainingFiles { get; set; } = string.Empty;
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelUpdateInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelUpdateInputVo.cs
index f5dab1a..a0055c8 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelUpdateInputVo.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Label/LabelUpdateInputVo.cs
@@ -42,6 +42,9 @@ public class LabelUpdateInputVo
public List ProductIds { get; set; } = new();
+ /// 绑定培训文件 Id;null 表示不改动,空数组表示清空
+ public List? BoundTrainingFileIds { get; set; }
+
public object? LabelInfoJson { get; set; }
public bool State { get; set; } = true;
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerCheckExpiredOutputDto.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerCheckExpiredOutputDto.cs
index 5fff58b..a95796d 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerCheckExpiredOutputDto.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerCheckExpiredOutputDto.cs
@@ -26,4 +26,11 @@ public class LabelAlertTimerCheckExpiredOutputDto
public string? TimerId { get; set; }
public string? BatchId { get; set; }
+
+ public string? LabelName { get; set; }
+
+ public string? FormattedExpiresAt { get; set; }
+
+ /// 固定文案:亲爱的{userName},您的{labelName}标签已过期,请及时处理
+ public string? ExpiredMessageTemplate { get; set; }
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerGetListInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerGetListInputVo.cs
index b216881..030b47b 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerGetListInputVo.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerGetListInputVo.cs
@@ -9,7 +9,8 @@ public class LabelAlertTimerGetListInputVo : PagedAndSortedResultRequestDto
{
///
/// 当前门店 Id(location.Id,Guid 字符串)。
- /// list 必填;app-list 可空(空则取已选门店缓存)。
+ /// list(平台)可空:空=权限范围内全部门店;有值则仅该门店。
+ /// app-list 必须落到一个门店(空则取已选门店缓存)。
///
public string? LocationId { get; set; }
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerListItemDto.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerListItemDto.cs
index f5a783a..97555c5 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerListItemDto.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/LabelAlertTimer/LabelAlertTimerListItemDto.cs
@@ -15,6 +15,8 @@ public class LabelAlertTimerListItemDto
public string? LabelCode { get; set; }
+ public string LabelName { get; set; } = string.Empty;
+
public string Title { get; set; } = string.Empty;
public string Subtitle { get; set; } = string.Empty;
@@ -30,9 +32,27 @@ public class LabelAlertTimerListItemDto
public DateTime ExpiresAt { get; set; }
+ /// 按告警模板 DateTimeFormat 格式化后的过期时刻
+ public string FormattedExpiresAt { get; set; } = string.Empty;
+
public DateTime PrintedAt { get; set; }
public string LocationId { get; set; } = string.Empty;
+ public string? LocationName { get; set; }
+
public string? ProductName { get; set; }
+
+ public string? AlertTemplateId { get; set; }
+
+ public string? AlertTemplateName { get; set; }
+
+ public string? DateTimeFormat { get; set; }
+
+ public string? PrintedByUserId { get; set; }
+
+ public string? PrintedByUserName { get; set; }
+
+ /// 固定文案:亲爱的{userName},您的{labelName}标签已过期,请及时处理
+ public string ExpiredMessageTemplate { get; set; } = string.Empty;
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingCategoryTreeInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingCategoryTreeInputVo.cs
index ca4aa55..d027380 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingCategoryTreeInputVo.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingCategoryTreeInputVo.cs
@@ -10,4 +10,7 @@ public class TrainingCategoryTreeInputVo
/// 是否包含文件列表,默认 true
public bool IncludeFiles { get; set; } = true;
+
+ /// 标签 Id 或 LabelCode;只返回绑定了该标签的培训文件
+ public string? LabelId { get; set; }
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileDto.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileDto.cs
index 1f0306c..b2624f0 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileDto.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileDto.cs
@@ -44,6 +44,12 @@ public class TrainingFileDto
public List LocationIds { get; set; } = new();
+ /// 绑定标签 Id(与标签列表 id 一致,为 LabelCode)
+ public List BoundLabelIds { get; set; } = new();
+
+ /// 绑定标签名称,逗号拼接
+ public string BoundLabels { get; set; } = string.Empty;
+
public DateTime CreationTime { get; set; }
public DateTime? LastModificationTime { get; set; }
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileUpdateInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileUpdateInputVo.cs
index 9cc01c7..c0c5f23 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileUpdateInputVo.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileUpdateInputVo.cs
@@ -34,4 +34,7 @@ public class TrainingFileUpdateInputVo : ITrainingFileScopeInput
/// 适用门店(location.Id);可含 ALL
public List? LocationIds { get; set; }
+
+ /// 绑定标签 Id(LabelCode 或内部 Id);null 不改动,空数组清空
+ public List? BoundLabelIds { get; set; }
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileUploadInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileUploadInputVo.cs
index f92b59a..180de6c 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileUploadInputVo.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/TrainingFileUploadInputVo.cs
@@ -50,4 +50,8 @@ public class TrainingFileUploadInputVo : ITrainingFileScopeInput
/// 适用门店(location.Id);可含 ALL
[FromForm(Name = "locationIds")]
public List? LocationIds { get; set; }
+
+ /// 绑定标签 Id(fl_label.LabelCode 或内部 Id)
+ [FromForm(Name = "boundLabelIds")]
+ public List? BoundLabelIds { get; set; }
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/UsAppTrainingTreeInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/UsAppTrainingTreeInputVo.cs
index 4d0fc19..bda8f30 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/UsAppTrainingTreeInputVo.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Training/UsAppTrainingTreeInputVo.cs
@@ -5,4 +5,7 @@ public class UsAppTrainingTreeInputVo
public string LocationId { get; set; } = string.Empty;
public string? Keyword { get; set; }
+
+ /// 标签 Id 或 LabelCode;只返回绑定了该标签的培训文件
+ public string? LabelId { get; set; }
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAlertTemplateAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAlertTemplateAppService.cs
new file mode 100644
index 0000000..c8b3b80
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAlertTemplateAppService.cs
@@ -0,0 +1,21 @@
+using FoodLabeling.Application.Contracts.Dtos.AlertTemplate;
+using FoodLabeling.Application.Contracts.Dtos.Common;
+using Volo.Abp.Application.Services;
+
+namespace FoodLabeling.Application.Contracts.IServices;
+
+/// 告警日期时间格式模板
+public interface IAlertTemplateAppService : IApplicationService
+{
+ Task> ListAsync(AlertTemplateGetListInputVo input);
+
+ Task GetAsync(string id);
+
+ Task CreateAsync(AlertTemplateCreateInputVo input);
+
+ Task UpdateAsync(string id, AlertTemplateCreateInputVo input);
+
+ Task DeleteAsync(string id);
+
+ Task> GetOptionsAsync();
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAppUpdateAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAppUpdateAppService.cs
new file mode 100644
index 0000000..dff6020
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAppUpdateAppService.cs
@@ -0,0 +1,13 @@
+using FoodLabeling.Application.Contracts.Dtos.AppUpdate;
+using Microsoft.AspNetCore.Mvc;
+using Volo.Abp.Application.Services;
+
+namespace FoodLabeling.Application.Contracts.IServices;
+
+/// App 版本检查与 APK 下载
+public interface IAppUpdateAppService : IApplicationService
+{
+ Task GetInfoAsync(int? versionCode);
+
+ IActionResult DownloadApk();
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILabelAlertTimerAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILabelAlertTimerAppService.cs
index 7503191..af43999 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILabelAlertTimerAppService.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILabelAlertTimerAppService.cs
@@ -5,7 +5,7 @@ using Volo.Abp.Application.Services;
namespace FoodLabeling.Application.Contracts.IServices;
///
-/// 标签告警计时器(App)
+/// 标签告警计时器(平台 list 可全店;App app-list 仅本店)
///
public interface ILabelAlertTimerAppService : IApplicationService
{
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILabelAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILabelAppService.cs
index 5abc6f2..e7ba956 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILabelAppService.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/ILabelAppService.cs
@@ -11,18 +11,19 @@ namespace FoodLabeling.Application.Contracts.IServices;
public interface ILabelAppService : IApplicationService
{
///
- /// 按产品分页列表(一个产品展示多个标签)。支持 GroupId / LocationId 筛选(命中 fl_label_region、fl_label_location 或 AppliedRegionType=ALL);labelTypeId 为可选筛选;出参含 locationIds、region、regionIds、appliedRegionType。
+ /// 按产品分页列表(一个产品展示多个标签)。支持 GroupId / LocationId 筛选(命中 fl_label_region、fl_label_location 或 AppliedRegionType=ALL);labelTypeId 为可选筛选;出参含 locationIds、region、regionIds、appliedRegionType、boundTrainingFileIds、boundTrainingFiles。
///
Task> GetListAsync(LabelGetListInputVo input);
///
- /// 标签详情(id=LabelCode)。出参含 locationIds、location、appliedRegionType、region、regionIds、groupIds;locationId 为 locationIds 首项兼容字段。
+ /// 标签详情(id=LabelCode)。出参含 locationIds、location、appliedRegionType、region、regionIds、groupIds、boundTrainingFileIds、boundTrainingFiles;locationId 为 locationIds 首项兼容字段。
///
Task GetAsync(string id);
///
/// 新增标签。Body 支持 appliedRegionType(ALL/SPECIFIED)、
- /// regionIds / groupIds / locationIds(可含哨兵 ALL,归档为 AppliedRegionType=ALL)。
+ /// regionIds / groupIds / locationIds(可含哨兵 ALL,归档为 AppliedRegionType=ALL),
+ /// 以及 boundTrainingFileIds(绑定培训文件 Id)。
///
Task CreateAsync(LabelCreateInputVo input);
@@ -33,6 +34,7 @@ public interface ILabelAppService : IApplicationService
///
/// 编辑标签(id=LabelCode)。范围传参与 一致,支持 Id 数组传 ALL。
+ /// boundTrainingFileIds 为 null 时不改绑定;空数组清空绑定。
///
Task UpdateAsync(string id, LabelUpdateInputVo input);
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabeling.Application.csproj b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabeling.Application.csproj
index 1a2747f..5560f89 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabeling.Application.csproj
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabeling.Application.csproj
@@ -36,6 +36,18 @@
FoodLabeling.TenantMigrations.fl_label_alert_timer.sql
+
+ FoodLabeling.TenantMigrations.fl_bound_label.sql
+
+
+ FoodLabeling.TenantMigrations.fl_alert_template.sql
+
+
+ FoodLabeling.TenantMigrations.fl_label_alert_timer_alert_template.sql
+
+
+ FoodLabeling.TenantMigrations.fl_menu_hide_platform_qr_codes.sql
+
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabelingApplicationModule.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabelingApplicationModule.cs
index 1ada7bf..679bc51 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabelingApplicationModule.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabelingApplicationModule.cs
@@ -23,6 +23,8 @@ public class FoodLabelingApplicationModule : AbpModule
{
Configure(
context.Services.GetConfiguration().GetSection(FoodLabelingBatchImportOptions.SectionName));
+ Configure(
+ context.Services.GetConfiguration().GetSection(FoodLabelingAppUpdateOptions.SectionName));
// 任意业务写接口成功后刷新系统编辑时间戳,供 my-menus.lastUpdated 使用
Configure(options =>
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdatePathHelper.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdatePathHelper.cs
new file mode 100644
index 0000000..b21f7ad
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdatePathHelper.cs
@@ -0,0 +1,82 @@
+using FoodLabeling.Application.Options;
+
+namespace FoodLabeling.Application.Helpers;
+
+/// 相对路径按进程工作目录解析;ApkPath 可为 APK 文件或目录。
+public static class AppUpdatePathHelper
+{
+ public const string DefaultDirectory = "/www/wwwroot/FoodLabelingManagementUs/wwwroot/app-update";
+
+ public const string DefaultFileName = "app-release.apk";
+
+ public static FileInfo? ResolveApk(FoodLabelingAppUpdateOptions cfg)
+ {
+ if (cfg is null || string.IsNullOrWhiteSpace(cfg.ApkPath))
+ {
+ return null;
+ }
+
+ var configured = cfg.ApkPath.Trim().TrimEnd('/', '\\');
+ var tried = new HashSet(StringComparer.OrdinalIgnoreCase);
+ var candidates = new List();
+
+ void AddFile(string path)
+ {
+ if (string.IsNullOrWhiteSpace(path) || !tried.Add(path))
+ {
+ return;
+ }
+
+ candidates.Add(new FileInfo(path));
+ }
+
+ void AddPath(string path)
+ {
+ if (string.IsNullOrWhiteSpace(path))
+ {
+ return;
+ }
+
+ if (Directory.Exists(path))
+ {
+ var preferred = Path.Combine(path, DefaultFileName);
+ AddFile(preferred);
+ foreach (var apk in Directory.EnumerateFiles(path, "*.apk")
+ .OrderByDescending(File.GetLastWriteTimeUtc))
+ {
+ AddFile(apk);
+ }
+
+ return;
+ }
+
+ AddFile(path);
+ if (!Path.HasExtension(path))
+ {
+ AddFile(Path.Combine(path, DefaultFileName));
+ }
+ }
+
+ AddPath(configured);
+ if (!Path.IsPathRooted(configured))
+ {
+ var stripped = configured.StartsWith("./", StringComparison.Ordinal)
+ ? configured[2..]
+ : configured;
+ AddPath(Path.Combine(Environment.CurrentDirectory, stripped));
+ }
+
+ AddPath(DefaultDirectory);
+ AddFile(Path.Combine(DefaultDirectory, DefaultFileName));
+
+ foreach (var file in candidates)
+ {
+ if (file.Exists && file.Length > 0)
+ {
+ return file;
+ }
+ }
+
+ return candidates.Count == 0 ? null : candidates[0];
+ }
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdateVersionResolver.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdateVersionResolver.cs
new file mode 100644
index 0000000..ee4719c
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdateVersionResolver.cs
@@ -0,0 +1,168 @@
+using System.Collections.Concurrent;
+using System.IO.Compression;
+using System.Text.Json;
+using FoodLabeling.Application.Options;
+
+namespace FoodLabeling.Application.Helpers;
+
+///
+/// 版本号以已上传 APK 为准:日常后端发版不改版本;只有目录里换了新包才变。
+/// 优先读 APK 内 UniApp manifest.json,其次同目录 version.json,最后才用 appsettings 兜底。
+///
+public static class AppUpdateVersionResolver
+{
+ private static readonly ConcurrentDictionary ApkCache =
+ new(StringComparer.OrdinalIgnoreCase);
+
+ public static (int VersionCode, string VersionName) Resolve(FileInfo? apk, FoodLabelingAppUpdateOptions options)
+ {
+ var fallbackCode = options.VersionCode;
+ var fallbackName = options.VersionName ?? string.Empty;
+
+ if (apk is not { Exists: true, Length: > 0 })
+ {
+ return (fallbackCode, fallbackName);
+ }
+
+ if (TryReadFromApk(apk, out var apkCode, out var apkName))
+ {
+ return (apkCode, string.IsNullOrWhiteSpace(apkName) ? fallbackName : apkName);
+ }
+
+ if (TryReadSidecar(apk.DirectoryName, out var fileCode, out var fileName))
+ {
+ return (fileCode, string.IsNullOrWhiteSpace(fileName) ? fallbackName : fileName);
+ }
+
+ return (fallbackCode, fallbackName);
+ }
+
+ private static bool TryReadFromApk(FileInfo apk, out int versionCode, out string versionName)
+ {
+ versionCode = 0;
+ versionName = string.Empty;
+ var cacheKey = apk.FullName;
+ var ticks = apk.LastWriteTimeUtc.Ticks;
+ if (ApkCache.TryGetValue(cacheKey, out var cached)
+ && cached.Length == apk.Length
+ && cached.Ticks == ticks)
+ {
+ versionCode = cached.Code;
+ versionName = cached.Name;
+ return versionCode > 0;
+ }
+
+ try
+ {
+ using var zip = ZipFile.OpenRead(apk.FullName);
+ foreach (var entry in zip.Entries)
+ {
+ if (!entry.FullName.EndsWith("manifest.json", StringComparison.OrdinalIgnoreCase))
+ {
+ continue;
+ }
+
+ var path = entry.FullName.Replace('\\', '/');
+ if (path.Contains("/node_modules/", StringComparison.OrdinalIgnoreCase)
+ || path.Contains("/unpackage/", StringComparison.OrdinalIgnoreCase))
+ {
+ continue;
+ }
+
+ using var stream = entry.Open();
+ using var doc = JsonDocument.Parse(stream);
+ if (!TryReadManifest(doc.RootElement, out versionCode, out versionName) || versionCode <= 0)
+ {
+ continue;
+ }
+
+ ApkCache[cacheKey] = (apk.Length, ticks, versionCode, versionName);
+ return true;
+ }
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ private static bool TryReadSidecar(string? directory, out int versionCode, out string versionName)
+ {
+ versionCode = 0;
+ versionName = string.Empty;
+ if (string.IsNullOrWhiteSpace(directory))
+ {
+ return false;
+ }
+
+ var sidecar = Path.Combine(directory, "version.json");
+ if (!File.Exists(sidecar))
+ {
+ return false;
+ }
+
+ try
+ {
+ using var doc = JsonDocument.Parse(File.ReadAllText(sidecar));
+ return TryReadManifest(doc.RootElement, out versionCode, out versionName) && versionCode > 0;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
+
+ private static bool TryReadManifest(JsonElement root, out int versionCode, out string versionName)
+ {
+ versionCode = 0;
+ versionName = string.Empty;
+ if (root.ValueKind != JsonValueKind.Object)
+ {
+ return false;
+ }
+
+ versionName = ReadString(root, "versionName") ?? string.Empty;
+ var codeEl = GetProperty(root, "versionCode");
+ if (codeEl.ValueKind == JsonValueKind.Number && codeEl.TryGetInt32(out var n))
+ {
+ versionCode = n;
+ return true;
+ }
+
+ if (codeEl.ValueKind == JsonValueKind.String
+ && int.TryParse(codeEl.GetString(), out var fromText)
+ && fromText > 0)
+ {
+ versionCode = fromText;
+ return true;
+ }
+
+ return false;
+ }
+
+ private static string? ReadString(JsonElement root, string name)
+ {
+ var el = GetProperty(root, name);
+ return el.ValueKind == JsonValueKind.String ? el.GetString() : null;
+ }
+
+ private static JsonElement GetProperty(JsonElement root, string name)
+ {
+ if (root.TryGetProperty(name, out var el))
+ {
+ return el;
+ }
+
+ foreach (var p in root.EnumerateObject())
+ {
+ if (string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase))
+ {
+ return p.Value;
+ }
+ }
+
+ return default;
+ }
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/BoundLabelBindingHelper.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/BoundLabelBindingHelper.cs
new file mode 100644
index 0000000..97de8ba
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/BoundLabelBindingHelper.cs
@@ -0,0 +1,435 @@
+using FoodLabeling.Application.Services.DbModels;
+using FoodLabeling.Domain.Shared;
+using FoodLabeling.Domain.Shared.Helpers;
+using SqlSugar;
+using Volo.Abp;
+
+namespace FoodLabeling.Application.Helpers;
+
+///
+/// 标签 ↔ 培训文件多对多(fl_training_file_label)。
+/// 标签侧绑定培训文件 Id;培训文件侧绑定标签 Id/LabelCode。
+///
+public static class BoundLabelBindingHelper
+{
+ public sealed class BoundLabelDisplay
+ {
+ public List BoundLabelIds { get; init; } = new();
+
+ public string BoundLabels { get; init; } = FoodLabelingDisplayConsts.NotAvailable;
+ }
+
+ public sealed class BoundTrainingFileDisplay
+ {
+ public List BoundTrainingFileIds { get; init; } = new();
+
+ public string BoundTrainingFiles { get; init; } = FoodLabelingDisplayConsts.NotAvailable;
+ }
+
+ public static BoundLabelDisplay EmptyDisplay { get; } = new();
+
+ public static BoundTrainingFileDisplay EmptyTrainingFileDisplay { get; } = new();
+
+ private static int _schemaReady;
+
+ private const string CreateTrainingFileLabelTableSql = """
+ CREATE TABLE IF NOT EXISTS `fl_training_file_label` (
+ `Id` varchar(36) NOT NULL,
+ `TrainingFileId` varchar(36) NOT NULL,
+ `LabelId` varchar(36) NOT NULL,
+ PRIMARY KEY (`Id`),
+ UNIQUE KEY `uk_fl_training_file_label` (`TrainingFileId`, `LabelId`),
+ KEY `idx_fl_tflabel_file` (`TrainingFileId`),
+ KEY `idx_fl_tflabel_label` (`LabelId`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
+ """;
+
+ private static async Task EnsureSchemaAsync(ISqlSugarClient db, bool throwIfMissing)
+ {
+ if (Volatile.Read(ref _schemaReady) == 1)
+ {
+ return;
+ }
+
+ if (await TablesExistAsync(db))
+ {
+ Volatile.Write(ref _schemaReady, 1);
+ return;
+ }
+
+ try
+ {
+ await db.Ado.ExecuteCommandAsync(CreateTrainingFileLabelTableSql);
+ }
+ catch (Exception ex) when (throwIfMissing)
+ {
+ throw new UserFriendlyException($"绑定标签表未初始化,请执行 fl_bound_label.sql:{ex.Message}");
+ }
+ catch
+ {
+ return;
+ }
+
+ if (await TablesExistAsync(db))
+ {
+ Volatile.Write(ref _schemaReady, 1);
+ return;
+ }
+
+ if (throwIfMissing)
+ {
+ throw new UserFriendlyException("绑定标签表未初始化,请执行 fl_bound_label.sql");
+ }
+ }
+
+ private static async Task TablesExistAsync(ISqlSugarClient db)
+ {
+ var count = await db.Ado.GetIntAsync(
+ """
+ SELECT COUNT(*)
+ FROM information_schema.TABLES
+ WHERE TABLE_SCHEMA = DATABASE()
+ AND TABLE_NAME = 'fl_training_file_label'
+ """);
+ return count >= 1;
+ }
+
+ ///
+ /// 保存标签绑定的培训文件。编辑时 为 null 表示不改动。
+ ///
+ public static async Task SaveForLabelAsync(
+ ISqlSugarClient db,
+ string labelId,
+ IEnumerable? inputIds,
+ bool replaceWhenNull)
+ {
+ if (inputIds is null && !replaceWhenNull)
+ {
+ return;
+ }
+
+ await EnsureSchemaAsync(db, throwIfMissing: true);
+ var fileIds = await ResolveTrainingFileIdsAsync(db, inputIds, throwIfMissing: true);
+
+ await db.Deleteable()
+ .Where(x => x.LabelId == labelId)
+ .ExecuteCommandAsync();
+
+ if (fileIds.Count == 0)
+ {
+ return;
+ }
+
+ var rows = fileIds.Select(id => new FlTrainingFileLabelDbEntity
+ {
+ Id = YitIdHelper.NextId().ToString(),
+ TrainingFileId = id,
+ LabelId = labelId
+ }).ToList();
+ await db.Insertable(rows).ExecuteCommandAsync();
+ }
+
+ ///
+ /// 保存培训文件绑定的标签。编辑时 为 null 表示不改动。
+ ///
+ public static async Task SaveForTrainingFileAsync(
+ ISqlSugarClient db,
+ string trainingFileId,
+ IEnumerable? inputIds,
+ bool replaceWhenNull)
+ {
+ if (inputIds is null && !replaceWhenNull)
+ {
+ return;
+ }
+
+ await EnsureSchemaAsync(db, throwIfMissing: true);
+ var boundIds = await ResolveInternalLabelIdsAsync(db, inputIds, throwIfMissing: true);
+
+ await db.Deleteable()
+ .Where(x => x.TrainingFileId == trainingFileId)
+ .ExecuteCommandAsync();
+
+ if (boundIds.Count == 0)
+ {
+ return;
+ }
+
+ var rows = boundIds.Select(id => new FlTrainingFileLabelDbEntity
+ {
+ Id = YitIdHelper.NextId().ToString(),
+ TrainingFileId = trainingFileId,
+ LabelId = id
+ }).ToList();
+ await db.Insertable(rows).ExecuteCommandAsync();
+ }
+
+ public static async Task DeleteForLabelAsync(ISqlSugarClient db, string labelId)
+ {
+ await EnsureSchemaAsync(db, throwIfMissing: false);
+ if (Volatile.Read(ref _schemaReady) != 1)
+ {
+ return;
+ }
+ await db.Deleteable()
+ .Where(x => x.LabelId == labelId)
+ .ExecuteCommandAsync();
+ }
+
+ public static async Task DeleteForTrainingFileAsync(ISqlSugarClient db, string trainingFileId)
+ {
+ await EnsureSchemaAsync(db, throwIfMissing: false);
+ if (Volatile.Read(ref _schemaReady) != 1)
+ {
+ return;
+ }
+ await db.Deleteable()
+ .Where(x => x.TrainingFileId == trainingFileId)
+ .ExecuteCommandAsync();
+ }
+
+ public static async Task> LoadForLabelsAsync(
+ ISqlSugarClient db,
+ IEnumerable labelIds)
+ {
+ var ids = labelIds.Where(x => !string.IsNullOrWhiteSpace(x)).Distinct(StringComparer.Ordinal).ToList();
+ if (ids.Count == 0)
+ {
+ return new Dictionary(StringComparer.Ordinal);
+ }
+
+ await EnsureSchemaAsync(db, throwIfMissing: false);
+ if (Volatile.Read(ref _schemaReady) != 1)
+ {
+ return new Dictionary(StringComparer.Ordinal);
+ }
+
+ var rows = await db.Queryable()
+ .InnerJoin((b, f) => b.TrainingFileId == f.Id)
+ .Where((b, f) => ids.Contains(b.LabelId) && !f.IsDeleted)
+ .Select((b, f) => new BoundFileRow
+ {
+ OwnerId = b.LabelId,
+ TrainingFileId = f.Id,
+ FileName = f.FileName
+ })
+ .ToListAsync();
+
+ return rows
+ .GroupBy(x => x.OwnerId, StringComparer.Ordinal)
+ .ToDictionary(
+ g => g.Key,
+ g =>
+ {
+ var fileIds = g.Select(x => x.TrainingFileId).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToList();
+ var names = g.Select(x => x.FileName?.Trim())
+ .Where(x => !string.IsNullOrWhiteSpace(x))
+ .Distinct()
+ .ToList();
+ return new BoundTrainingFileDisplay
+ {
+ BoundTrainingFileIds = fileIds,
+ BoundTrainingFiles = names.Count == 0
+ ? FoodLabelingDisplayConsts.NotAvailable
+ : string.Join(",", names)
+ };
+ },
+ StringComparer.Ordinal);
+ }
+
+ public static async Task> LoadForTrainingFilesAsync(
+ ISqlSugarClient db,
+ IEnumerable trainingFileIds)
+ {
+ var ids = trainingFileIds.Where(x => !string.IsNullOrWhiteSpace(x)).Distinct(StringComparer.Ordinal).ToList();
+ if (ids.Count == 0)
+ {
+ return new Dictionary(StringComparer.Ordinal);
+ }
+
+ await EnsureSchemaAsync(db, throwIfMissing: false);
+ if (Volatile.Read(ref _schemaReady) != 1)
+ {
+ return new Dictionary(StringComparer.Ordinal);
+ }
+ var rows = await db.Queryable()
+ .InnerJoin((b, l) => b.LabelId == l.Id)
+ .Where((b, l) => ids.Contains(b.TrainingFileId) && !l.IsDeleted)
+ .Select((b, l) => new BoundRow
+ {
+ OwnerId = b.TrainingFileId,
+ LabelCode = l.LabelCode,
+ LabelId = l.Id,
+ LabelName = l.LabelName
+ })
+ .ToListAsync();
+
+ return ToDisplayMap(rows);
+ }
+
+ public static async Task LoadForLabelAsync(ISqlSugarClient db, string labelId)
+ {
+ var map = await LoadForLabelsAsync(db, new[] { labelId });
+ return map.TryGetValue(labelId, out var display) ? display : EmptyTrainingFileDisplay;
+ }
+
+ /// 解析单个标签 Id 或 LabelCode;不存在返回 null,不抛异常。
+ public static async Task TryResolveInternalLabelIdAsync(ISqlSugarClient db, string? token)
+ {
+ if (string.IsNullOrWhiteSpace(token))
+ {
+ return null;
+ }
+
+ var ids = await ResolveInternalLabelIdsAsync(db, new[] { token.Trim() }, throwIfMissing: false);
+ return ids.Count > 0 ? ids[0] : null;
+ }
+
+ public static async Task TryEnsureSchemaAsync(ISqlSugarClient db)
+ {
+ await EnsureSchemaAsync(db, throwIfMissing: false);
+ return Volatile.Read(ref _schemaReady) == 1;
+ }
+
+ public static async Task LoadForTrainingFileAsync(ISqlSugarClient db, string trainingFileId)
+ {
+ var map = await LoadForTrainingFilesAsync(db, new[] { trainingFileId });
+ return map.TryGetValue(trainingFileId, out var display) ? display : EmptyDisplay;
+ }
+
+ private static async Task> ResolveInternalLabelIdsAsync(
+ ISqlSugarClient db,
+ IEnumerable? inputIds,
+ bool throwIfMissing)
+ {
+ var tokens = (inputIds ?? Enumerable.Empty())
+ .Where(x => !string.IsNullOrWhiteSpace(x))
+ .Select(x => x.Trim())
+ .Distinct(StringComparer.Ordinal)
+ .ToList();
+ if (tokens.Count == 0)
+ {
+ return new List();
+ }
+
+ var found = await db.Queryable()
+ .Where(x => !x.IsDeleted && (tokens.Contains(x.Id) || tokens.Contains(x.LabelCode)))
+ .Select(x => new { x.Id, x.LabelCode })
+ .ToListAsync();
+
+ var byId = found.ToDictionary(x => x.Id, x => x.Id, StringComparer.Ordinal);
+ var byCode = found
+ .Where(x => !string.IsNullOrWhiteSpace(x.LabelCode))
+ .GroupBy(x => x.LabelCode!, StringComparer.Ordinal)
+ .ToDictionary(g => g.Key, g => g.First().Id, StringComparer.Ordinal);
+
+ var resolved = new List();
+ var seen = new HashSet(StringComparer.Ordinal);
+ foreach (var token in tokens)
+ {
+ if (!byId.TryGetValue(token, out var internalId) && !byCode.TryGetValue(token, out internalId))
+ {
+ if (throwIfMissing)
+ {
+ throw new UserFriendlyException($"绑定标签不存在:{token}");
+ }
+
+ continue;
+ }
+
+ if (seen.Add(internalId))
+ {
+ resolved.Add(internalId);
+ }
+ }
+
+ return resolved;
+ }
+
+ private static async Task> ResolveTrainingFileIdsAsync(
+ ISqlSugarClient db,
+ IEnumerable? inputIds,
+ bool throwIfMissing)
+ {
+ var tokens = (inputIds ?? Enumerable.Empty())
+ .Where(x => !string.IsNullOrWhiteSpace(x))
+ .Select(x => x.Trim())
+ .Distinct(StringComparer.Ordinal)
+ .ToList();
+ if (tokens.Count == 0)
+ {
+ return new List();
+ }
+
+ var found = await db.Queryable()
+ .Where(x => !x.IsDeleted && tokens.Contains(x.Id))
+ .Select(x => x.Id)
+ .ToListAsync();
+ var foundSet = found.ToHashSet(StringComparer.Ordinal);
+
+ var resolved = new List();
+ foreach (var token in tokens)
+ {
+ if (!foundSet.Contains(token))
+ {
+ if (throwIfMissing)
+ {
+ throw new UserFriendlyException($"绑定培训文件不存在:{token}");
+ }
+
+ continue;
+ }
+
+ resolved.Add(token);
+ }
+
+ return resolved;
+ }
+
+ private static Dictionary ToDisplayMap(List rows)
+ {
+ return rows
+ .GroupBy(x => x.OwnerId, StringComparer.Ordinal)
+ .ToDictionary(
+ g => g.Key,
+ g =>
+ {
+ var ids = g.Select(ToApiId).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToList();
+ var names = g.Select(x => x.LabelName?.Trim())
+ .Where(x => !string.IsNullOrWhiteSpace(x))
+ .Distinct()
+ .ToList();
+ return new BoundLabelDisplay
+ {
+ BoundLabelIds = ids,
+ BoundLabels = names.Count == 0
+ ? FoodLabelingDisplayConsts.NotAvailable
+ : string.Join(",", names)
+ };
+ },
+ StringComparer.Ordinal);
+ }
+
+ private static string ToApiId(BoundRow row) =>
+ string.IsNullOrWhiteSpace(row.LabelCode) ? row.LabelId : row.LabelCode!;
+
+ private sealed class BoundRow
+ {
+ public string OwnerId { get; set; } = string.Empty;
+
+ public string? LabelCode { get; set; }
+
+ public string LabelId { get; set; } = string.Empty;
+
+ public string? LabelName { get; set; }
+ }
+
+ private sealed class BoundFileRow
+ {
+ public string OwnerId { get; set; } = string.Empty;
+
+ public string TrainingFileId { get; set; } = string.Empty;
+
+ public string? FileName { get; set; }
+ }
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelAlertTimerDisplayHelper.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelAlertTimerDisplayHelper.cs
new file mode 100644
index 0000000..29a5a4f
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelAlertTimerDisplayHelper.cs
@@ -0,0 +1,38 @@
+using System.Globalization;
+using FoodLabeling.Domain.Shared.Enums;
+
+namespace FoodLabeling.Application.Helpers;
+
+/// 告警计时器展示字段(格式化过期时刻、弹窗文案、状态)
+public static class LabelAlertTimerDisplayHelper
+{
+ public const string ExpiredMessageTemplate = "亲爱的{userName},您的{labelName}标签已过期,请及时处理";
+
+ public const string StatusRunning = "running";
+
+ public const string StatusExpired = "expired";
+
+ public static string ToStatusString(DateTime expiresAt, DateTime now) =>
+ expiresAt <= now ? StatusExpired : StatusRunning;
+
+ public static LabelAlertTimerStatus ToStatus(DateTime expiresAt, DateTime now) =>
+ expiresAt <= now ? LabelAlertTimerStatus.Expired : LabelAlertTimerStatus.Running;
+
+ public static string FormatExpiresAt(DateTime expiresAt, string? dateTimeFormat)
+ {
+ var format = dateTimeFormat?.Trim();
+ if (string.IsNullOrWhiteSpace(format))
+ {
+ return expiresAt.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
+ }
+
+ try
+ {
+ return expiresAt.ToString(format, CultureInfo.GetCultureInfo("en-US"));
+ }
+ catch (FormatException)
+ {
+ return expiresAt.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
+ }
+ }
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelAlertTimerWriteHelper.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelAlertTimerWriteHelper.cs
index 2c945b6..3178277 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelAlertTimerWriteHelper.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelAlertTimerWriteHelper.cs
@@ -1,22 +1,26 @@
using System.Globalization;
+using System.Text.Json;
using FoodLabeling.Application.Services.DbModels;
+using FoodLabeling.Domain.Entities;
using FoodLabeling.Domain.Shared.Helpers;
using SqlSugar;
+using Yi.Framework.Rbac.Domain.Entities;
namespace FoodLabeling.Application.Helpers;
///
-/// 打印成功后写入告警计时器(按 BatchId 幂等,一条批次一条计时器)。
+/// 打印成功后写入告警计时器(按 BatchId 幂等;须有到期提醒控件 + 启用模板 + 可解析过期时刻)。
///
public static class LabelAlertTimerWriteHelper
{
///
- /// 根据打印批次创建告警计时器;已存在未删除记录或无有效过期时刻时直接返回。
+ /// 根据打印批次创建告警计时器;条件不满足或已存在记录时直接返回。
///
public static async Task TryCreateFromPrintBatchAsync(
ISqlSugarClient db,
string batchId,
string? createdBy,
+ string? printedByUserName = null,
CancellationToken ct = default)
{
var bid = batchId?.Trim();
@@ -27,7 +31,6 @@ public static class LabelAlertTimerWriteHelper
ct.ThrowIfCancellationRequested();
- // BatchId 有唯一索引:含软删记录也不再插入,避免幂等补写撞唯一约束
var exists = await db.Queryable()
.AnyAsync(x => x.BatchId == bid);
if (exists)
@@ -46,6 +49,21 @@ public static class LabelAlertTimerWriteHelper
return;
}
+ if (!TryFindExpirationAlertTemplateId(task.RenderTemplateJson, out var alertTemplateId))
+ {
+ return;
+ }
+
+ var template = (await db.Queryable()
+ .Where(x => x.Id == alertTemplateId && !x.IsDeleted && x.State)
+ .Take(1)
+ .ToListAsync(ct))
+ .FirstOrDefault();
+ if (template is null)
+ {
+ return;
+ }
+
var printedAt = task.PrintedAt ?? task.BaseTime ?? task.CreationTime;
if (!ReportsPrintLogExpiryHelper.TryResolveExpiryDateTime(
task.PrintInputJson,
@@ -81,6 +99,14 @@ public static class LabelAlertTimerWriteHelper
.FirstOrDefault();
}
+ var locationId = task.LocationId?.Trim() ?? string.Empty;
+ var locationName = await ResolveLocationNameAsync(db, locationId, ct);
+ var printerName = printedByUserName?.Trim();
+ if (string.IsNullOrWhiteSpace(printerName))
+ {
+ printerName = await ResolveUserDisplayNameAsync(db, createdBy, ct);
+ }
+
var durationSeconds = Math.Max(0, (int)(expiresAt - printedAt).TotalSeconds);
var title = BuildTitle(labelName, durationSeconds);
var subtitle = BuildSubtitle(durationSeconds, expiresAt);
@@ -96,13 +122,19 @@ public static class LabelAlertTimerWriteHelper
LabelName = labelName,
ProductId = task.ProductId,
ProductName = string.IsNullOrWhiteSpace(productName) ? null : productName.Trim(),
- LocationId = task.LocationId?.Trim() ?? string.Empty,
+ LocationId = locationId,
+ LocationName = locationName,
PrintedAt = printedAt,
BaseTime = task.BaseTime,
ExpiresAt = expiresAt,
DurationSeconds = durationSeconds,
Title = title,
Subtitle = subtitle,
+ AlertTemplateId = template.Id,
+ AlertTemplateName = template.TemplateName,
+ DateTimeFormat = template.DateTimeFormat,
+ PrintedByUserId = createdBy,
+ PrintedByUserName = printerName,
IsDeleted = false,
DeletionTime = null,
CreatedBy = createdBy,
@@ -112,6 +144,124 @@ public static class LabelAlertTimerWriteHelper
await db.Insertable(entity).ExecuteCommandAsync();
}
+ internal static bool TryFindExpirationAlertTemplateId(string? renderTemplateJson, out string templateId)
+ {
+ templateId = string.Empty;
+ if (string.IsNullOrWhiteSpace(renderTemplateJson))
+ {
+ return false;
+ }
+
+ try
+ {
+ using var doc = JsonDocument.Parse(renderTemplateJson);
+ if (doc.RootElement.ValueKind != JsonValueKind.Object)
+ {
+ return false;
+ }
+
+ if (!TryGetProperty(doc.RootElement, "elements", out var elements) ||
+ elements.ValueKind != JsonValueKind.Array)
+ {
+ return false;
+ }
+
+ foreach (var el in elements.EnumerateArray())
+ {
+ if (el.ValueKind != JsonValueKind.Object || !IsExpirationAlertElement(el))
+ {
+ continue;
+ }
+
+ if (!TryGetProperty(el, "config", out var cfg) || cfg.ValueKind != JsonValueKind.Object)
+ {
+ continue;
+ }
+
+ var id = GetStringProperty(cfg, "alertTemplateId", "AlertTemplateId").Trim();
+ if (string.IsNullOrWhiteSpace(id))
+ {
+ continue;
+ }
+
+ templateId = id;
+ return true;
+ }
+ }
+ catch
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ private static bool IsExpirationAlertElement(JsonElement el)
+ {
+ var typeAdd = GetStringProperty(el, "typeAdd", "TypeAdd");
+ var elementName = GetStringProperty(el, "elementName", "ElementName");
+ var typeAddNorm = typeAdd.Trim().ToLowerInvariant().Replace(" ", "", StringComparison.Ordinal);
+ var nameLower = elementName.Trim().ToLowerInvariant();
+ if (typeAddNorm.Contains("expirationalert", StringComparison.Ordinal))
+ {
+ return true;
+ }
+
+ if (nameLower.Contains("expiration alert", StringComparison.Ordinal))
+ {
+ return true;
+ }
+
+ return elementName.Contains("到期提醒", StringComparison.Ordinal);
+ }
+
+ private static async Task ResolveLocationNameAsync(ISqlSugarClient db, string locationId, CancellationToken ct)
+ {
+ if (string.IsNullOrWhiteSpace(locationId) || !Guid.TryParse(locationId, out var locGuid))
+ {
+ return null;
+ }
+
+ var name = (await db.Queryable()
+ .Where(x => x.Id == locGuid)
+ .Select(x => x.LocationName)
+ .Take(1)
+ .ToListAsync(ct))
+ .FirstOrDefault();
+ return string.IsNullOrWhiteSpace(name) ? null : name.Trim();
+ }
+
+ private static async Task ResolveUserDisplayNameAsync(ISqlSugarClient db, string? userId, CancellationToken ct)
+ {
+ if (string.IsNullOrWhiteSpace(userId) || !Guid.TryParse(userId, out var uid))
+ {
+ return null;
+ }
+
+ var user = (await db.Queryable()
+ .Where(x => x.Id == uid)
+ .Select(x => new { x.Name, x.Nick, x.UserName })
+ .Take(1)
+ .ToListAsync(ct))
+ .FirstOrDefault();
+ if (user is null)
+ {
+ return null;
+ }
+
+ if (!string.IsNullOrWhiteSpace(user.Name))
+ {
+ return user.Name.Trim();
+ }
+
+ if (!string.IsNullOrWhiteSpace(user.Nick))
+ {
+ return user.Nick.Trim();
+ }
+
+ return string.IsNullOrWhiteSpace(user.UserName) ? null : user.UserName.Trim();
+ }
+
private static string BuildTitle(string labelName, int durationSeconds)
{
var hoursText = FormatDurationHoursLabel(durationSeconds);
@@ -145,4 +295,37 @@ public static class LabelAlertTimerWriteHelper
var minutes = Math.Max(1, (int)Math.Ceiling(durationSeconds / 60.0));
return minutes == 1 ? "1 minute" : $"{minutes} minutes";
}
+
+ private static bool TryGetProperty(JsonElement obj, string name, out JsonElement value)
+ {
+ if (obj.TryGetProperty(name, out value))
+ {
+ return true;
+ }
+
+ if (name.Length > 0)
+ {
+ var pascal = char.ToUpperInvariant(name[0]) + name[1..];
+ if (obj.TryGetProperty(pascal, out value))
+ {
+ return true;
+ }
+ }
+
+ value = default;
+ return false;
+ }
+
+ private static string GetStringProperty(JsonElement obj, params string[] names)
+ {
+ foreach (var name in names)
+ {
+ if (TryGetProperty(obj, name, out var v) && v.ValueKind == JsonValueKind.String)
+ {
+ return v.GetString() ?? string.Empty;
+ }
+ }
+
+ return string.Empty;
+ }
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PagedQueryConvention.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PagedQueryConvention.cs
index 165bcfa..3189077 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PagedQueryConvention.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PagedQueryConvention.cs
@@ -7,4 +7,19 @@ namespace FoodLabeling.Application.Helpers;
public static class PagedQueryConvention
{
public static int PageIndexFromSkipCount(int skipCount) => skipCount <= 0 ? 1 : skipCount;
+
+ ///
+ /// 将 ABP 风格 offset(SkipCount=(currentPage-1)*pageSize)转为 SqlSugar 页码(从 1 起)。
+ /// 例:skipCount=40, maxResultCount=10 → 第 5 页。
+ ///
+ public static int PageIndexFromOffset(int skipCount, int maxResultCount)
+ {
+ var pageSize = maxResultCount <= 0 ? 10 : maxResultCount;
+ if (skipCount <= 0)
+ {
+ return 1;
+ }
+
+ return skipCount / pageSize + 1;
+ }
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PlatformMenuHelper.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PlatformMenuHelper.cs
index 5b80325..a721af8 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PlatformMenuHelper.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PlatformMenuHelper.cs
@@ -17,6 +17,11 @@ public static class PlatformMenuHelper
return true;
}
+ if (IsQrCodeMenu(menu.Id, menu.PermissionCode, menu.Router))
+ {
+ return true;
+ }
+
var code = menu.PermissionCode?.Trim() ?? string.Empty;
if (code.StartsWith("menu.platform", StringComparison.OrdinalIgnoreCase))
{
@@ -27,6 +32,26 @@ public static class PlatformMenuHelper
return router.StartsWith("/platform", StringComparison.OrdinalIgnoreCase);
}
+ /// 二维码已改为仅平台;含历史 management 权限码 / 旧路由。
+ public static bool IsQrCodeMenu(string? menuId, string? permissionCode, string? router)
+ {
+ if (string.Equals(menuId?.Trim(), "f0010037-0001-4000-8000-000000000037", StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ var code = permissionCode?.Trim() ?? string.Empty;
+ if (code.Equals("menu.management.qr-codes", StringComparison.OrdinalIgnoreCase)
+ || code.Equals("menu.platform.qr-codes", StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ var path = router?.Trim() ?? string.Empty;
+ return path.Equals("/qr-codes", StringComparison.OrdinalIgnoreCase)
+ || path.Equals("/platform/qr-codes", StringComparison.OrdinalIgnoreCase);
+ }
+
///
/// 从全量菜单中保留平台菜单及其祖先节点,以便组装菜单树
///
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/MultiTenancy/FoodLabelingTenantMigrationScriptNames.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/MultiTenancy/FoodLabelingTenantMigrationScriptNames.cs
index 3ffd2b7..a062c76 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/MultiTenancy/FoodLabelingTenantMigrationScriptNames.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/MultiTenancy/FoodLabelingTenantMigrationScriptNames.cs
@@ -24,6 +24,16 @@ public static class FoodLabelingTenantMigrationScriptNames
public const string LabelAlertTimer = "FoodLabeling.TenantMigrations.fl_label_alert_timer.sql";
+ public const string BoundLabel = "FoodLabeling.TenantMigrations.fl_bound_label.sql";
+
+ public const string AlertTemplate = "FoodLabeling.TenantMigrations.fl_alert_template.sql";
+
+ public const string LabelAlertTimerAlertTemplate =
+ "FoodLabeling.TenantMigrations.fl_label_alert_timer_alert_template.sql";
+
+ public const string MenuHidePlatformQrCodes =
+ "FoodLabeling.TenantMigrations.fl_menu_hide_platform_qr_codes.sql";
+
/// CodeFirst 之后按序执行的脚本资源名。
public static readonly IReadOnlyList TenantInitializationOrder =
[
@@ -35,6 +45,10 @@ public static class FoodLabelingTenantMigrationScriptNames
TeamMemberScope,
TeamMemberRegion,
Training,
- LabelAlertTimer
+ LabelAlertTimer,
+ BoundLabel,
+ AlertTemplate,
+ LabelAlertTimerAlertTemplate,
+ MenuHidePlatformQrCodes
];
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Options/FoodLabelingAppUpdateOptions.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Options/FoodLabelingAppUpdateOptions.cs
new file mode 100644
index 0000000..c15d83f
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Options/FoodLabelingAppUpdateOptions.cs
@@ -0,0 +1,26 @@
+namespace FoodLabeling.Application.Options;
+
+///
+/// App 热更新(查版本 + 下载 APK)。发布时把新包放到 并提高 。
+///
+public class FoodLabelingAppUpdateOptions
+{
+ public const string SectionName = "FoodLabeling:AppUpdate";
+
+ public bool Enabled { get; set; } = true;
+
+ public string PackageName { get; set; } = "com.3flabeling.usapp";
+
+ /// 整型版本号,须大于 App 本地 versionCode 才会提示更新。
+ public int VersionCode { get; set; } = 106;
+
+ public string VersionName { get; set; } = "1.0.6";
+
+ public bool ForceUpdate { get; set; }
+
+ public string Changelog { get; set; } = string.Empty;
+
+ /// 服务器本地 APK 路径(建议绝对路径)。
+ public string ApkPath { get; set; } =
+ "/www/wwwroot/FoodLabelingManagementUs/wwwroot/app-update/app-release.apk";
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AlertTemplateAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AlertTemplateAppService.cs
new file mode 100644
index 0000000..693f2d9
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AlertTemplateAppService.cs
@@ -0,0 +1,266 @@
+using FoodLabeling.Application.Contracts.Dtos.AlertTemplate;
+using FoodLabeling.Application.Contracts.Dtos.Common;
+using FoodLabeling.Application.Contracts.IServices;
+using FoodLabeling.Application.Helpers;
+using FoodLabeling.Application.Services.DbModels;
+using FoodLabeling.Domain.Shared.Helpers;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using Volo.Abp;
+using Volo.Abp.Application.Services;
+using Yi.Framework.SqlSugarCore.Abstractions;
+
+namespace FoodLabeling.Application.Services;
+
+///
+/// 告警日期时间格式模板(平台告警页 / 标签模板到期提醒下拉)
+///
+[Authorize]
+public class AlertTemplateAppService : ApplicationService, IAlertTemplateAppService
+{
+ private readonly ISqlSugarDbContext _dbContext;
+
+ public AlertTemplateAppService(ISqlSugarDbContext dbContext)
+ {
+ _dbContext = dbContext;
+ }
+
+ ///
+ /// 分页查询告警模板
+ ///
+ ///
+ /// 查询当前租户 fl_alert_template 未删除记录。
+ ///
+ /// 示例请求:
+ /// ```json
+ /// {
+ /// "keyword": "冷藏",
+ /// "state": true,
+ /// "skipCount": 1,
+ /// "maxResultCount": 20
+ /// }
+ /// ```
+ ///
+ /// 参数说明:
+ /// - keyword: 模板名称模糊匹配
+ /// - state: 启用状态
+ /// - skipCount: 页码(从 1 开始)
+ /// - maxResultCount: 每页条数
+ ///
+ /// 分页与筛选
+ /// 分页模板列表
+ /// 成功
+ /// 参数无效
+ /// 服务器错误
+ [HttpPost]
+ [Route("/api/app/alert-template/list")]
+ public async Task> ListAsync(AlertTemplateGetListInputVo input)
+ {
+ input ??= new AlertTemplateGetListInputVo();
+ var keyword = input.Keyword?.Trim();
+ RefAsync total = 0;
+ var query = _dbContext.SqlSugarClient.Queryable()
+ .Where(x => !x.IsDeleted)
+ .WhereIF(!string.IsNullOrWhiteSpace(keyword), x => x.TemplateName.Contains(keyword!))
+ .WhereIF(input.State is not null, x => x.State == input.State);
+
+ var pageIndex = PagedQueryConvention.PageIndexFromSkipCount(input.SkipCount);
+ var pageSize = input.MaxResultCount <= 0 ? 10 : input.MaxResultCount;
+ var entities = await query
+ .OrderByDescending(x => x.LastModificationTime)
+ .OrderByDescending(x => x.CreationTime)
+ .ToPageListAsync(pageIndex, pageSize, total);
+
+ var items = entities.Select(MapDto).ToList();
+ var totalCount = (long)total;
+ var totalPages = pageSize <= 0 ? 0 : (int)Math.Ceiling(totalCount / (double)pageSize);
+ return new PagedResultWithPageDto
+ {
+ PageIndex = pageIndex,
+ PageSize = pageSize,
+ TotalCount = totalCount,
+ TotalPages = totalPages,
+ Items = items
+ };
+ }
+
+ ///
+ /// 告警模板详情
+ ///
+ /// 模板 Id
+ /// 模板
+ /// 成功
+ /// 不存在
+ /// 服务器错误
+ [HttpGet]
+ [Route("/api/app/alert-template/{id}")]
+ public async Task GetAsync(string id)
+ {
+ var entity = await FindActiveAsync(id);
+ return MapDto(entity);
+ }
+
+ ///
+ /// 新增告警模板
+ ///
+ ///
+ /// 示例请求:
+ /// ```json
+ /// {
+ /// "templateName": "US 过期展示",
+ /// "dateTimeFormat": "MM/dd/yyyy h:mm tt",
+ /// "state": true
+ /// }
+ /// ```
+ ///
+ /// 参数说明:
+ /// - templateName: 模板名称
+ /// - dateTimeFormat: 日期时间格式字符串(原样存储,用于 formattedExpiresAt)
+ /// - state: 是否启用
+ ///
+ /// 模板字段
+ /// 新建模板
+ /// 成功
+ /// 参数无效
+ /// 服务器错误
+ [HttpPost]
+ [Route("/api/app/alert-template")]
+ public async Task CreateAsync(AlertTemplateCreateInputVo input)
+ {
+ var (name, format) = ValidateInput(input);
+ var now = DateTime.Now;
+ var entity = new FlAlertTemplateDbEntity
+ {
+ Id = YitIdHelper.NextId().ToString(),
+ TemplateName = name,
+ DateTimeFormat = format,
+ State = input.State,
+ IsDeleted = false,
+ CreatedBy = CurrentUser?.Id?.ToString(),
+ CreationTime = now,
+ LastModificationTime = now
+ };
+ await _dbContext.SqlSugarClient.Insertable(entity).ExecuteCommandAsync();
+ return MapDto(entity);
+ }
+
+ ///
+ /// 编辑告警模板
+ ///
+ ///
+ /// 示例请求同新增。
+ ///
+ /// 模板 Id
+ /// 模板字段
+ /// 更新后的模板
+ /// 成功
+ /// 不存在或参数无效
+ /// 服务器错误
+ [HttpPut]
+ [Route("/api/app/alert-template/{id}")]
+ public async Task UpdateAsync(string id, AlertTemplateCreateInputVo input)
+ {
+ var entity = await FindActiveAsync(id);
+ var (name, format) = ValidateInput(input);
+ entity.TemplateName = name;
+ entity.DateTimeFormat = format;
+ entity.State = input.State;
+ entity.LastModificationTime = DateTime.Now;
+ await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync();
+ return MapDto(entity);
+ }
+
+ ///
+ /// 软删除告警模板
+ ///
+ /// 模板 Id
+ /// 成功
+ /// 不存在
+ /// 服务器错误
+ [HttpDelete]
+ [Route("/api/app/alert-template/{id}")]
+ public async Task DeleteAsync(string id)
+ {
+ var entity = await FindActiveAsync(id);
+ var now = DateTime.Now;
+ entity.IsDeleted = true;
+ entity.DeletionTime = now;
+ entity.LastModificationTime = now;
+ await _dbContext.SqlSugarClient.Updateable(entity).ExecuteCommandAsync();
+ }
+
+ ///
+ /// 启用中的告警模板下拉(标签模板编辑器到期提醒)
+ ///
+ /// id / templateName / dateTimeFormat
+ /// 成功
+ /// 服务器错误
+ [HttpGet]
+ [Route("/api/app/alert-template/options")]
+ public async Task> GetOptionsAsync()
+ {
+ var rows = await _dbContext.SqlSugarClient.Queryable()
+ .Where(x => !x.IsDeleted && x.State)
+ .OrderByDescending(x => x.LastModificationTime)
+ .OrderByDescending(x => x.CreationTime)
+ .ToListAsync();
+ return rows.Select(x => new AlertTemplateOptionDto
+ {
+ Id = x.Id,
+ TemplateName = x.TemplateName,
+ DateTimeFormat = x.DateTimeFormat
+ }).ToList();
+ }
+
+ private async Task FindActiveAsync(string id)
+ {
+ var tid = id?.Trim();
+ if (string.IsNullOrWhiteSpace(tid))
+ {
+ throw new UserFriendlyException("模板Id不能为空");
+ }
+
+ var entity = await _dbContext.SqlSugarClient.Queryable()
+ .FirstAsync(x => x.Id == tid && !x.IsDeleted);
+ if (entity is null)
+ {
+ throw new UserFriendlyException("告警模板不存在");
+ }
+
+ return entity;
+ }
+
+ private static (string Name, string Format) ValidateInput(AlertTemplateCreateInputVo? input)
+ {
+ if (input is null)
+ {
+ throw new UserFriendlyException("入参不能为空");
+ }
+
+ var name = input.TemplateName?.Trim();
+ if (string.IsNullOrWhiteSpace(name))
+ {
+ throw new UserFriendlyException("模板名称不能为空");
+ }
+
+ var format = input.DateTimeFormat?.Trim();
+ if (string.IsNullOrWhiteSpace(format))
+ {
+ throw new UserFriendlyException("日期时间格式不能为空");
+ }
+
+ return (name, format);
+ }
+
+ private static AlertTemplateDto MapDto(FlAlertTemplateDbEntity x) =>
+ new()
+ {
+ Id = x.Id,
+ TemplateName = x.TemplateName,
+ DateTimeFormat = x.DateTimeFormat,
+ State = x.State,
+ CreationTime = x.CreationTime,
+ LastModificationTime = x.LastModificationTime
+ };
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AppUpdateAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AppUpdateAppService.cs
new file mode 100644
index 0000000..1afffdd
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AppUpdateAppService.cs
@@ -0,0 +1,141 @@
+using FoodLabeling.Application.Contracts.Dtos.AppUpdate;
+using FoodLabeling.Application.Contracts.IServices;
+using FoodLabeling.Application.Helpers;
+using FoodLabeling.Application.Options;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Volo.Abp;
+using Volo.Abp.Application.Services;
+
+namespace FoodLabeling.Application.Services;
+
+///
+/// App 版本检查与 APK 下载(对齐锁控面板;供手动「检查更新」)。
+///
+[AllowAnonymous]
+public class AppUpdateAppService : ApplicationService, IAppUpdateAppService
+{
+ private readonly FoodLabelingAppUpdateOptions _options;
+ private readonly IHttpContextAccessor _httpContextAccessor;
+ private readonly ILogger _logger;
+
+ public AppUpdateAppService(
+ IOptions options,
+ IHttpContextAccessor httpContextAccessor,
+ ILogger logger)
+ {
+ _options = options.Value;
+ _httpContextAccessor = httpContextAccessor;
+ _logger = logger;
+ }
+
+ ///
+ /// 查询服务端最新 App 版本
+ ///
+ ///
+ /// 无需登录。前端用本地 versionCode 与返回的 versionCode 比较:
+ /// 远程更大且 apkReady=true 时再下载 apkUrl 并调起安装。
+ ///
+ /// 示例请求:
+ /// ```json
+ /// GET /api/app/update?versionCode=106
+ /// ```
+ ///
+ /// 参数说明:
+ /// - versionCode: 可选,当前 App 本地整型版本号;传入时出参带 hasUpdate
+ ///
+ /// 当前 App 本地 versionCode
+ /// 最新版本信息与 APK 地址
+ /// 成功
+ /// 更新未启用
+ /// 服务器错误
+ [HttpGet]
+ [Route("/api/app/update")]
+ public Task GetInfoAsync([FromQuery] int? versionCode)
+ {
+ EnsureEnabled();
+ var apk = AppUpdatePathHelper.ResolveApk(_options);
+ var ready = apk is { Exists: true, Length: > 0 };
+ if (!ready)
+ {
+ _logger.LogWarning(
+ "App 更新 APK 未就绪,配置路径={Configured},已解析={Resolved},user.dir={UserDir}",
+ _options.ApkPath,
+ apk?.FullName,
+ Environment.CurrentDirectory);
+ }
+
+ var (remoteCode, remoteName) = AppUpdateVersionResolver.Resolve(apk, _options);
+ bool? hasUpdate = null;
+ if (versionCode.HasValue)
+ {
+ hasUpdate = ready && remoteCode > versionCode.Value;
+ }
+
+ return Task.FromResult(new AppUpdateDto
+ {
+ PackageName = _options.PackageName ?? string.Empty,
+ VersionCode = remoteCode,
+ VersionName = remoteName,
+ ForceUpdate = _options.ForceUpdate,
+ Changelog = _options.Changelog ?? string.Empty,
+ ApkReady = ready,
+ ApkResolvedPath = apk?.FullName,
+ ApkUrl = BuildApkUrl(),
+ HasUpdate = hasUpdate
+ });
+ }
+
+ ///
+ /// 下载最新 APK(二进制,不走 JSON 包装)
+ ///
+ ///
+ /// 无需登录。Content-Type 为 application/vnd.android.package-archive。
+ ///
+ /// APK 文件流
+ /// 成功返回文件
+ /// 更新未启用或文件不存在
+ /// 服务器错误
+ [HttpGet]
+ [Route("/api/app/update/apk")]
+ public IActionResult DownloadApk()
+ {
+ EnsureEnabled();
+ var apk = AppUpdatePathHelper.ResolveApk(_options);
+ if (apk is not { Exists: true, Length: > 0 })
+ {
+ throw new UserFriendlyException(
+ "APK 文件不存在,请放到: " + _options.ApkPath
+ + "(当前工作目录=" + Environment.CurrentDirectory + ")");
+ }
+
+ var (_, remoteName) = AppUpdateVersionResolver.Resolve(apk, _options);
+ var downloadName = "food-labeling-" + (string.IsNullOrWhiteSpace(remoteName) ? "app" : remoteName) + ".apk";
+ return new PhysicalFileResult(apk.FullName, "application/vnd.android.package-archive")
+ {
+ FileDownloadName = downloadName
+ };
+ }
+
+ private void EnsureEnabled()
+ {
+ if (!_options.Enabled)
+ {
+ throw new UserFriendlyException("App 更新未启用");
+ }
+ }
+
+ private string BuildApkUrl()
+ {
+ var request = _httpContextAccessor.HttpContext?.Request;
+ if (request is null)
+ {
+ return "/api/app/update/apk";
+ }
+
+ return $"{request.Scheme}://{request.Host}{request.PathBase}/api/app/update/apk";
+ }
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlAlertTemplateDbEntity.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlAlertTemplateDbEntity.cs
new file mode 100644
index 0000000..9065ccc
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlAlertTemplateDbEntity.cs
@@ -0,0 +1,27 @@
+using SqlSugar;
+
+namespace FoodLabeling.Application.Services.DbModels;
+
+/// 告警日期时间格式模板(fl_alert_template)
+[SugarTable("fl_alert_template")]
+public class FlAlertTemplateDbEntity
+{
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; } = string.Empty;
+
+ public string TemplateName { get; set; } = string.Empty;
+
+ public string DateTimeFormat { get; set; } = string.Empty;
+
+ public bool State { get; set; } = true;
+
+ public bool IsDeleted { get; set; }
+
+ public DateTime? DeletionTime { get; set; }
+
+ public string? CreatedBy { get; set; }
+
+ public DateTime CreationTime { get; set; }
+
+ public DateTime? LastModificationTime { get; set; }
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelAlertTimerDbEntity.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelAlertTimerDbEntity.cs
index db8d7aa..a6f0f01 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelAlertTimerDbEntity.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelAlertTimerDbEntity.cs
@@ -27,6 +27,8 @@ public class FlLabelAlertTimerDbEntity
public string LocationId { get; set; } = string.Empty;
+ public string? LocationName { get; set; }
+
public DateTime PrintedAt { get; set; }
public DateTime? BaseTime { get; set; }
@@ -39,6 +41,16 @@ public class FlLabelAlertTimerDbEntity
public string Subtitle { get; set; } = string.Empty;
+ public string? AlertTemplateId { get; set; }
+
+ public string? AlertTemplateName { get; set; }
+
+ public string? DateTimeFormat { get; set; }
+
+ public string? PrintedByUserId { get; set; }
+
+ public string? PrintedByUserName { get; set; }
+
public bool IsDeleted { get; set; }
public DateTime? DeletionTime { get; set; }
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelBoundLabelDbEntity.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelBoundLabelDbEntity.cs
new file mode 100644
index 0000000..2264147
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlLabelBoundLabelDbEntity.cs
@@ -0,0 +1,15 @@
+using SqlSugar;
+
+namespace FoodLabeling.Application.Services.DbModels;
+
+/// 标签绑定其他标签(fl_label → fl_label)
+[SugarTable("fl_label_bound_label")]
+public class FlLabelBoundLabelDbEntity
+{
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; } = string.Empty;
+
+ public string LabelId { get; set; } = string.Empty;
+
+ public string BoundLabelId { get; set; } = string.Empty;
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlTrainingFileLabelDbEntity.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlTrainingFileLabelDbEntity.cs
new file mode 100644
index 0000000..3dcb8ca
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DbModels/FlTrainingFileLabelDbEntity.cs
@@ -0,0 +1,15 @@
+using SqlSugar;
+
+namespace FoodLabeling.Application.Services.DbModels;
+
+/// 培训文件绑定标签
+[SugarTable("fl_training_file_label")]
+public class FlTrainingFileLabelDbEntity
+{
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; } = string.Empty;
+
+ public string TrainingFileId { get; set; } = string.Empty;
+
+ public string LabelId { get; set; } = string.Empty;
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAlertTimerAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAlertTimerAppService.cs
index 52c9b89..ddf0faf 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAlertTimerAppService.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAlertTimerAppService.cs
@@ -18,9 +18,6 @@ namespace FoodLabeling.Application.Services;
///
public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerAppService
{
- private const string StatusRunning = "running";
- private const string StatusExpired = "expired";
-
private readonly ISqlSugarDbContext _dbContext;
private readonly IDistributedCache _distributedCache;
@@ -31,25 +28,24 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp
}
///
- /// 分页查询当前门店告警计时器列表(含倒计时)
+ /// 平台:分页查询告警计时器(locationId 可选,空=权限内全店)
///
///
/// 仅展示已打印标签的过期倒计时,不用于判断能否打印。
- /// 过期时刻与 Print Log「Expiration」列同源(ReportsPrintLogExpiryHelper)。
- /// 同一打印批次(BatchId)无论打印多少张标签,仅一条计时器(取 CopyIndex 最小任务)。
+ /// 过期时刻与 Print Log「Expiration」列同源。
///
/// 示例请求:
/// ```json
/// {
- /// "locationId": "11111111-1111-1111-1111-111111111111",
+ /// "locationId": "",
/// "skipCount": 1,
/// "maxResultCount": 20,
- /// "dateDay": "2026-08-07"
+ /// "dateDay": "2026-10-13"
/// }
/// ```
///
/// 参数说明:
- /// - locationId: 当前门店 Id(必填,须已绑定)
+ /// - locationId: 可选;空=当前用户权限范围内全部门店;有值则仅该门店(须可访问)
/// - skipCount: 页码(从 1 开始)
/// - maxResultCount: 每页条数
/// - dateDay: 可选,按 PrintedAt 自然日筛选(yyyy-MM-dd)
@@ -75,12 +71,21 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp
}
var locationId = input.LocationId?.Trim();
- if (string.IsNullOrWhiteSpace(locationId))
+ if (!string.IsNullOrWhiteSpace(locationId))
+ {
+ await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync(
+ CurrentUser, _dbContext.SqlSugarClient, locationId);
+ return await QueryListAsync(input, new List { locationId });
+ }
+
+ var scopeIds = await ReportsLocationScopeHelper.ResolveReportLocationIdsAsync(
+ CurrentUser, _dbContext.SqlSugarClient, null, null, null);
+ if (scopeIds is { Count: 0 })
{
- throw new UserFriendlyException("门店Id不能为空");
+ return EmptyPage(input);
}
- return await QueryListByLocationAsync(locationId, input);
+ return await QueryListAsync(input, scopeIds);
}
///
@@ -101,7 +106,7 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp
/// ```
///
/// 参数说明:
- /// - locationId: 当前门店 Id(可选;空则取已选门店缓存)
+ /// - locationId: 必须落到一个门店(可选;空则取已选门店缓存);禁止全店
/// - skipCount: 页码(从 1 开始)
/// - maxResultCount: 每页条数
/// - dateDay: 可选,按 PrintedAt 自然日筛选(yyyy-MM-dd)
@@ -146,7 +151,9 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp
throw new UserFriendlyException("请先选择门店或传入 locationId");
}
- return await QueryListByLocationAsync(locationId, input);
+ await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync(
+ CurrentUser, _dbContext.SqlSugarClient, locationId);
+ return await QueryListAsync(input, new List { locationId });
}
///
@@ -306,25 +313,26 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp
IsExpired = isExpired,
ExpiresAt = row.ExpiresAt,
RemainingSeconds = remaining,
- Status = isExpired ? StatusExpired : StatusRunning,
+ Status = LabelAlertTimerDisplayHelper.ToStatusString(row.ExpiresAt, now),
Title = row.Title,
Subtitle = row.Subtitle,
TimerId = row.Id,
- BatchId = row.BatchId
+ BatchId = row.BatchId,
+ LabelName = row.LabelName,
+ FormattedExpiresAt = LabelAlertTimerDisplayHelper.FormatExpiresAt(row.ExpiresAt, row.DateTimeFormat),
+ ExpiredMessageTemplate = LabelAlertTimerDisplayHelper.ExpiredMessageTemplate
};
}
- private async Task> QueryListByLocationAsync(
- string locationId,
- LabelAlertTimerGetListInputVo input)
+ private async Task> QueryListAsync(
+ LabelAlertTimerGetListInputVo input,
+ List? locationIds)
{
- await UsAppPrintLogScopeHelper.EnsureUserCanAccessLocationAsync(
- CurrentUser, _dbContext.SqlSugarClient, locationId);
-
var db = _dbContext.SqlSugarClient;
RefAsync total = 0;
var query = db.Queryable()
- .Where(x => !x.IsDeleted && x.LocationId == locationId);
+ .Where(x => !x.IsDeleted)
+ .WhereIF(locationIds is not null, x => locationIds!.Contains(x.LocationId));
var (dayStart, dayEndExcl) = ResolveDateDayFilter(input.DateDay);
if (dayStart.HasValue && dayEndExcl.HasValue)
@@ -360,7 +368,6 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp
private static LabelAlertTimerListItemDto MapListItem(FlLabelAlertTimerDbEntity row, DateTime now)
{
var remaining = Math.Max(0, (int)(row.ExpiresAt - now).TotalSeconds);
- var isExpired = row.ExpiresAt <= now;
return new LabelAlertTimerListItemDto
{
@@ -369,15 +376,38 @@ public class LabelAlertTimerAppService : ApplicationService, ILabelAlertTimerApp
PrintTaskId = row.PrintTaskId,
LabelId = row.LabelId,
LabelCode = row.LabelCode,
+ LabelName = row.LabelName,
Title = row.Title,
Subtitle = row.Subtitle,
TotalTime = row.DurationSeconds,
RemainingTime = remaining,
- Status = isExpired ? StatusExpired : StatusRunning,
+ Status = LabelAlertTimerDisplayHelper.ToStatusString(row.ExpiresAt, now),
ExpiresAt = row.ExpiresAt,
+ FormattedExpiresAt = LabelAlertTimerDisplayHelper.FormatExpiresAt(row.ExpiresAt, row.DateTimeFormat),
PrintedAt = row.PrintedAt,
LocationId = row.LocationId,
- ProductName = row.ProductName
+ LocationName = row.LocationName,
+ ProductName = row.ProductName,
+ AlertTemplateId = row.AlertTemplateId,
+ AlertTemplateName = row.AlertTemplateName,
+ DateTimeFormat = row.DateTimeFormat,
+ PrintedByUserId = row.PrintedByUserId,
+ PrintedByUserName = row.PrintedByUserName,
+ ExpiredMessageTemplate = LabelAlertTimerDisplayHelper.ExpiredMessageTemplate
+ };
+ }
+
+ private static PagedResultWithPageDto EmptyPage(LabelAlertTimerGetListInputVo input)
+ {
+ var pageSize = input.MaxResultCount <= 0 ? 10 : input.MaxResultCount;
+ var pageIndex = PagedQueryConvention.PageIndexFromSkipCount(input.SkipCount);
+ return new PagedResultWithPageDto
+ {
+ PageIndex = pageIndex,
+ PageSize = pageSize,
+ TotalCount = 0,
+ TotalPages = 0,
+ Items = new List()
};
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAppService.cs
index 6679748..d6c05f1 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAppService.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/LabelAppService.cs
@@ -252,6 +252,8 @@ public class LabelAppService : ApplicationService, ILabelAppService
ProductCategoryName = string.Join(",", g.Select(x => x.ProductCategoryName ?? string.Empty).Select(x => x.Trim()).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct())
});
+ var boundMap = await BoundLabelBindingHelper.LoadForLabelsAsync(db, pageLabelIds);
+
var items = orderedLabels.Select(x =>
{
var products = productsMap.TryGetValue(x.Id, out var prod) ? prod.Products : string.Empty;
@@ -260,6 +262,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
locationScopeMap.TryGetValue(x.Id, out var locationScope);
locationIdsMap.TryGetValue(x.Id, out var locIds);
appliedRegionTypeMap.TryGetValue(x.Id, out var appliedRegionType);
+ boundMap.TryGetValue(x.Id, out var bound);
return new LabelGetListOutputDto
{
Id = x.LabelCode ?? string.Empty,
@@ -275,6 +278,8 @@ public class LabelAppService : ApplicationService, ILabelAppService
LabelCategoryName = x.LabelCategoryName ?? string.Empty,
ProductCategoryName = string.IsNullOrWhiteSpace(productCategoryNameValue) ? FoodLabelingDisplayConsts.NotAvailable : productCategoryNameValue,
Products = products,
+ BoundTrainingFileIds = bound?.BoundTrainingFileIds ?? new List(),
+ BoundTrainingFiles = bound?.BoundTrainingFiles ?? FoodLabelingDisplayConsts.NotAvailable,
TemplateName = x.TemplateName ?? string.Empty,
TemplateCode = x.TemplateCode ?? string.Empty,
LabelTypeName = string.IsNullOrWhiteSpace(x.LabelTypeName) ? FoodLabelingDisplayConsts.NotAvailable : x.LabelTypeName,
@@ -404,6 +409,8 @@ public class LabelAppService : ApplicationService, ILabelAppService
? new List { partnerIds[0] }
: partnerIds.Where(x => !AllScopeBindingHelper.IsDeclaredAll(x)).ToList();
+ var bound = await BoundLabelBindingHelper.LoadForLabelAsync(db, label.Id);
+
return new LabelGetOutputDto
{
Id = label.LabelCode ?? string.Empty,
@@ -427,7 +434,9 @@ public class LabelAppService : ApplicationService, ILabelAppService
TemplateName = template?.TemplateName ?? string.Empty,
State = label.State,
LabelInfoJson = labelInfo,
- ProductIds = productIds
+ ProductIds = productIds,
+ BoundTrainingFileIds = bound.BoundTrainingFileIds,
+ BoundTrainingFiles = bound.BoundTrainingFiles
};
}
@@ -541,6 +550,8 @@ public class LabelAppService : ApplicationService, ILabelAppService
ProductId = pid
}).ToList();
await _dbContext.SqlSugarClient.Insertable(rows).ExecuteCommandAsync();
+ await BoundLabelBindingHelper.SaveForLabelAsync(
+ _dbContext.SqlSugarClient, labelId, input.BoundTrainingFileIds, replaceWhenNull: true);
await LabelCategoryAppService.TouchLabelCategoryLastEditedAsync(
_dbContext, labelEntity.LabelCategoryId, CurrentUser?.Id?.ToString());
@@ -739,6 +750,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
LabelCategoryId = item.LabelCategoryId,
LabelTypeId = item.LabelTypeId,
ProductIds = item.ProductIds ?? new List(),
+ BoundTrainingFileIds = item.BoundTrainingFileIds,
LabelInfoJson = item.LabelInfoJson,
State = item.State
};
@@ -841,6 +853,8 @@ public class LabelAppService : ApplicationService, ILabelAppService
ProductId = pid
}).ToList();
await _dbContext.SqlSugarClient.Insertable(rows).ExecuteCommandAsync();
+ await BoundLabelBindingHelper.SaveForLabelAsync(
+ _dbContext.SqlSugarClient, label.Id, input.BoundTrainingFileIds, replaceWhenNull: false);
var newCategoryId = label.LabelCategoryId;
await LabelCategoryAppService.TouchLabelCategoryLastEditedAsync(
@@ -895,6 +909,7 @@ public class LabelAppService : ApplicationService, ILabelAppService
await _dbContext.SqlSugarClient.Deleteable()
.Where(x => x.LabelId == label.Id)
.ExecuteCommandAsync();
+ await BoundLabelBindingHelper.DeleteForLabelAsync(_dbContext.SqlSugarClient, label.Id);
await LabelCategoryAppService.TouchLabelCategoryLastEditedAsync(
_dbContext, label.LabelCategoryId, CurrentUser?.Id?.ToString());
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/TrainingAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/TrainingAppService.cs
index c0b2ada..2b687ff 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/TrainingAppService.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/TrainingAppService.cs
@@ -73,7 +73,8 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
/// 参数说明:
/// - keyword: 匹配分类名或文件名
/// - locationId: 按门店权限过滤可见文件
- /// - includeFiles: 是否返回文件列表
+ /// - includeFiles: 是否返回文件列表;文件出参含 boundLabelIds / boundLabels
+ /// - labelId: 可选,按绑定标签(LabelCode 或 Id)过滤文件
///
/// 查询条件
/// 分类树
@@ -83,6 +84,18 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
public async Task> GetCategoryTreeAsync([FromQuery] TrainingCategoryTreeInputVo input)
{
var keyword = input.Keyword?.Trim();
+ var labelToken = input.LabelId?.Trim();
+ string? boundLabelInternalId = null;
+ if (!string.IsNullOrWhiteSpace(labelToken))
+ {
+ boundLabelInternalId = await BoundLabelBindingHelper.TryResolveInternalLabelIdAsync(
+ _dbContext.SqlSugarClient, labelToken);
+ if (boundLabelInternalId is null)
+ {
+ return new List();
+ }
+ }
+
TrainingFileScopeHelper.LocationScopeContext? scopeContext = null;
if (!string.IsNullOrWhiteSpace(input.LocationId))
{
@@ -115,6 +128,19 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
fileQuery = fileQuery.Where(x => x.FileName.Contains(keyword!));
}
+ if (!string.IsNullOrWhiteSpace(boundLabelInternalId)
+ && await BoundLabelBindingHelper.TryEnsureSchemaAsync(_dbContext.SqlSugarClient))
+ {
+ var labelKey = boundLabelInternalId;
+ fileQuery = fileQuery.Where(x => SqlFunc.Subqueryable()
+ .Where(b => b.TrainingFileId == x.Id && b.LabelId == labelKey)
+ .Any());
+ }
+ else if (!string.IsNullOrWhiteSpace(boundLabelInternalId))
+ {
+ fileQuery = fileQuery.Where(x => false);
+ }
+
var files = await fileQuery
.OrderByDescending(x => x.OrderNum)
.OrderByDescending(x => x.CreationTime)
@@ -130,6 +156,9 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
var scopeDisplayMap = await TrainingFileScopeHelper.BuildScopeDisplayMapAsync(
_dbContext.SqlSugarClient,
allFileEntities);
+ var boundMap = await BoundLabelBindingHelper.LoadForTrainingFilesAsync(
+ _dbContext.SqlSugarClient,
+ allFileEntities.Select(x => x.Id));
var level1 = categories.Where(x => string.IsNullOrWhiteSpace(x.ParentId)).ToList();
var level2Map = categories
@@ -163,7 +192,12 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
continue;
}
- childNodes.Add(MapCategoryNode(l2, fileRows, scopeDisplayMap));
+ if (!string.IsNullOrWhiteSpace(boundLabelInternalId) && fileRows.Count == 0)
+ {
+ continue;
+ }
+
+ childNodes.Add(MapCategoryNode(l2, fileRows, scopeDisplayMap, boundMap));
}
var l1NameMatch = string.IsNullOrWhiteSpace(keyword)
@@ -178,6 +212,11 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
continue;
}
+ if (!string.IsNullOrWhiteSpace(boundLabelInternalId) && childNodes.Count == 0)
+ {
+ continue;
+ }
+
result.Add(new TrainingCategoryTreeNodeDto
{
Id = l1.Id,
@@ -359,6 +398,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
/// - regionIds / groupIds: 可含 ALL
/// - availabilityType 或 appliedLocationType: ALL / SPECIFIED
/// - locationIds: 可含 ALL
+ /// - boundLabelIds: 绑定标签 LabelCode 或 Id,可重复传值
///
/// 上传表单
/// 文件信息
@@ -456,8 +496,12 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
now);
}
+ await BoundLabelBindingHelper.SaveForTrainingFileAsync(
+ _dbContext.SqlSugarClient, entity.Id, input.BoundLabelIds, replaceWhenNull: true);
+
var display = await TrainingFileScopeHelper.BuildScopeDisplayAsync(_dbContext.SqlSugarClient, entity);
- return MapFileDto(entity, display);
+ var bound = await BoundLabelBindingHelper.LoadForTrainingFileAsync(_dbContext.SqlSugarClient, entity.Id);
+ return MapFileDto(entity, display, bound);
}
///
@@ -473,7 +517,8 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
/// "partnerIds": ["p1"],
/// "appliedRegionType": "ALL",
/// "availabilityType": "SPECIFIED",
- /// "locationIds": ["loc1"]
+ /// "locationIds": ["loc1"],
+ /// "boundLabelIds": ["LB_1001"]
/// }
/// ```
///
@@ -482,6 +527,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
/// - appliedPartnerType / partnerIds / companyIds: Company 范围,Id 可含 ALL
/// - appliedRegionType / regionIds / groupIds: Region 范围,Id 可含 ALL
/// - availabilityType 或 appliedLocationType / locationIds: Location 范围,Id 可含 ALL
+ /// - boundLabelIds: 绑定标签;null 不改动,空数组清空
///
/// 文件Id
/// 文件元数据
@@ -510,8 +556,12 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
entity = await ApplyFileScopeAsync(entity, input);
}
+ await BoundLabelBindingHelper.SaveForTrainingFileAsync(
+ _dbContext.SqlSugarClient, entity.Id, input.BoundLabelIds, replaceWhenNull: false);
+
var display = await TrainingFileScopeHelper.BuildScopeDisplayAsync(_dbContext.SqlSugarClient, entity);
- return MapFileDto(entity, display);
+ var bound = await BoundLabelBindingHelper.LoadForTrainingFileAsync(_dbContext.SqlSugarClient, entity.Id);
+ return MapFileDto(entity, display, bound);
}
///
@@ -525,6 +575,7 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
{
var entity = await GetFileOrThrowAsync(id);
await TrainingFileScopeHelper.DeleteScopeRowsAsync(_dbContext.SqlSugarClient, entity.Id);
+ await BoundLabelBindingHelper.DeleteForTrainingFileAsync(_dbContext.SqlSugarClient, entity.Id);
entity.IsDeleted = true;
entity.LastModificationTime = DateTime.Now;
@@ -722,7 +773,8 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
private static TrainingCategoryTreeNodeDto MapCategoryNode(
FlTrainingCategoryDbEntity entity,
List files,
- IReadOnlyDictionary scopeDisplayMap) =>
+ IReadOnlyDictionary scopeDisplayMap,
+ IReadOnlyDictionary boundMap) =>
new()
{
Id = entity.Id,
@@ -733,13 +785,15 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
Files = files.Select(file =>
{
scopeDisplayMap.TryGetValue(file.Id, out var display);
- return MapFileDto(file, display);
+ boundMap.TryGetValue(file.Id, out var bound);
+ return MapFileDto(file, display, bound);
}).ToList()
};
private static TrainingFileDto MapFileDto(
FlTrainingFileDbEntity entity,
- TrainingFileScopeHelper.TrainingFileScopeDisplay? display = null) =>
+ TrainingFileScopeHelper.TrainingFileScopeDisplay? display = null,
+ BoundLabelBindingHelper.BoundLabelDisplay? bound = null) =>
new()
{
Id = entity.Id,
@@ -760,6 +814,8 @@ public class TrainingAppService : ApplicationService, ITrainingAppService
AvailabilityType = display?.AvailabilityType ?? entity.AvailabilityType,
Location = display?.Location ?? string.Empty,
LocationIds = display?.LocationIds ?? new List(),
+ BoundLabelIds = bound?.BoundLabelIds ?? new List(),
+ BoundLabels = bound?.BoundLabels ?? FoodLabelingDisplayConsts.NotAvailable,
CreationTime = entity.CreationTime,
LastModificationTime = entity.LastModificationTime
};
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 40b742b..98f8447 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
@@ -544,7 +544,8 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
await LabelAlertTimerWriteHelper.TryCreateFromPrintBatchAsync(
_dbContext.SqlSugarClient,
existedBatchId ?? string.Empty,
- CurrentUser?.Id?.ToString());
+ CurrentUser?.Id?.ToString(),
+ await ResolveCurrentUserDisplayNameAsync());
return new UsAppLabelPrintOutputDto
{
TaskId = existedTaskIds.FirstOrDefault() ?? string.Empty,
@@ -696,7 +697,8 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
await LabelAlertTimerWriteHelper.TryCreateFromPrintBatchAsync(
_dbContext.SqlSugarClient,
batchId,
- currentUserId);
+ currentUserId,
+ await ResolveCurrentUserDisplayNameAsync());
return new UsAppLabelPrintOutputDto
{
@@ -748,7 +750,8 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
await LabelAlertTimerWriteHelper.TryCreateFromPrintBatchAsync(
_dbContext.SqlSugarClient,
existedBatchId ?? string.Empty,
- CurrentUser?.Id?.ToString());
+ CurrentUser?.Id?.ToString(),
+ await ResolveCurrentUserDisplayNameAsync());
return new UsAppLabelPrintOutputDto
{
TaskId = existedTaskIds.FirstOrDefault() ?? string.Empty,
@@ -862,7 +865,8 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
await LabelAlertTimerWriteHelper.TryCreateFromPrintBatchAsync(
_dbContext.SqlSugarClient,
batchId,
- currentUserId);
+ currentUserId,
+ await ResolveCurrentUserDisplayNameAsync());
return new UsAppLabelPrintOutputDto
{
@@ -1649,6 +1653,32 @@ public class UsAppLabelingAppService : ApplicationService, IUsAppLabelingAppServ
: $"{ws}x{hs}{u}";
}
+ private async Task ResolveCurrentUserDisplayNameAsync()
+ {
+ if (!CurrentUser.Id.HasValue)
+ {
+ return CurrentUser.UserName;
+ }
+
+ var user = await _userRepository.GetFirstAsync(x => x.Id == CurrentUser.Id.Value);
+ if (user is null)
+ {
+ return CurrentUser.UserName;
+ }
+
+ if (!string.IsNullOrWhiteSpace(user.Name))
+ {
+ return user.Name.Trim();
+ }
+
+ if (!string.IsNullOrWhiteSpace(user.Nick))
+ {
+ return user.Nick.Trim();
+ }
+
+ return string.IsNullOrWhiteSpace(user.UserName) ? CurrentUser.UserName : user.UserName.Trim();
+ }
+
private static string? FormatLabelSizeWithUnit(decimal w, decimal h, string unit)
{
var u = (unit ?? "inch").Trim().ToLowerInvariant();
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppTrainingAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppTrainingAppService.cs
index 3859eb2..795a14b 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppTrainingAppService.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/UsAppTrainingAppService.cs
@@ -33,13 +33,15 @@ public class UsAppTrainingAppService : ApplicationService, IUsAppTrainingAppServ
/// ```json
/// {
/// "locationId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
- /// "keyword": "安全"
+ /// "keyword": "安全",
+ /// "labelId": "LB_1001"
/// }
/// ```
///
/// 参数说明:
/// - locationId: 当前门店 Id(必填)
/// - keyword: 可选,匹配分类名或文件名
+ /// - labelId: 可选,标签 LabelCode 或内部 Id,只返回绑定该标签的培训文件
///
/// 查询条件
/// 分类树(含可见文件)
@@ -64,6 +66,7 @@ public class UsAppTrainingAppService : ApplicationService, IUsAppTrainingAppServ
{
Keyword = input.Keyword,
LocationId = locationId,
+ LabelId = input.LabelId,
IncludeFiles = true
});
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Domain.Shared/Enums/LabelAlertTimerStatus.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Domain.Shared/Enums/LabelAlertTimerStatus.cs
new file mode 100644
index 0000000..6b295bd
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Domain.Shared/Enums/LabelAlertTimerStatus.cs
@@ -0,0 +1,13 @@
+namespace FoodLabeling.Domain.Shared.Enums;
+
+///
+/// 告警计时器展示状态(接口出参为小写字符串 running / expired)
+///
+public enum LabelAlertTimerStatus
+{
+ /// 进行中
+ Running = 0,
+
+ /// 已过期
+ Expired = 1
+}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/2026-10-12代码优化.md b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/2026-10-12代码优化.md
new file mode 100644
index 0000000..3b5d2b0
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/2026-10-12代码优化.md
@@ -0,0 +1,205 @@
+# 2026-10-12 代码优化接口文档
+
+鉴权:请求头 `Authorization` 填登录返回的 `data.token`(已含 `Bearer `)。
+统一包装:`{ "code": 200, "data": {}, "message": "" }`
+下文示例均为 `data` 内层,字段 camelCase。
+
+标签 ↔ 培训文件为多对多,租户库表 `fl_training_file_label`(`TrainingFileId` + `LabelId`)。
+
+---
+
+## 1. 标签 `/api/app/label`
+
+路径参数 `id` = **LabelCode**。
+`SkipCount` 为 **页码(从 1 起)**,不是 offset。
+
+本次:原「绑定标签」改为 **绑定培训文件 Id**(`boundTrainingFileIds`)。编辑不传该字段不改绑定,传 `[]` 清空。
+
+### 1.1 分页列表
+
+**GET** `/api/app/label?SkipCount=1&MaxResultCount=10`
+
+| Query | 类型 | 说明 |
+|---|---|---|
+| SkipCount | int | 页码,从 1 开始 |
+| MaxResultCount | int | 每页条数 |
+| Keyword / PartnerId / GroupId / LocationId / ProductId / LabelCategoryId / LabelTypeId / TemplateCode / State | | 筛选,均可选 |
+
+列表项相对原接口新增:
+
+| 字段 | 类型 | 说明 |
+|---|---|---|
+| boundTrainingFileIds | string[] | 绑定的培训文件 Id |
+| boundTrainingFiles | string | 文件名逗号拼接,无则为 `N/A` |
+
+```json
+{
+ "pageIndex": 1,
+ "pageSize": 10,
+ "totalCount": 100,
+ "totalPages": 10,
+ "items": [
+ {
+ "id": "LB_1001",
+ "labelName": "Chicken Salad",
+ "boundTrainingFileIds": ["file-id-1"],
+ "boundTrainingFiles": "手册.pdf",
+ "state": true
+ }
+ ]
+}
+```
+
+(其余列表字段:locationName、locationIds、region、regionIds、groupIds、appliedRegionType、labelCategoryName、productCategoryName、products、templateName、templateCode、labelTypeName、lastEdited、hasError 与原来一致。)
+
+### 1.2 详情
+
+**GET** `/api/app/label/{id}`
+
+出参在原有字段上增加 `boundTrainingFileIds`、`boundTrainingFiles`。
+
+### 1.3 新增
+
+**POST** `/api/app/label`
+
+| 字段 | 必填 | 说明 |
+|---|---|---|
+| labelName / templateCode / labelCategoryId | 是 | |
+| productIds | 是 | 至少 1 个 |
+| boundTrainingFileIds | 否 | 培训文件 Id 数组 |
+| 其余范围字段 | 否 | partnerId、appliedRegionType、regionIds、locationIds 等与原来一致 |
+
+```json
+{
+ "labelName": "Chicken Salad",
+ "templateCode": "TPL_NUTRITION_3X6",
+ "labelCategoryId": "cat-id",
+ "productIds": ["product-id"],
+ "boundTrainingFileIds": ["file-id-1", "file-id-2"],
+ "state": true
+}
+```
+
+成功返回详情。非法文件 Id:`绑定培训文件不存在:xxx`。
+
+### 1.4 编辑
+
+**PUT** `/api/app/label/{id}`
+
+Body 与新增类似(无 labelCode)。
+`boundTrainingFileIds`:省略不改;`[]` 清空;有值全量覆盖。
+
+---
+
+## 2. 培训 `/api/app/training`
+
+查询树:**GET** `/api/app/training/category-tree?includeFiles=true`
+新增/编辑绑定标签走 **文件** 上传与编辑(分类本身不绑标签)。
+
+本次:文件新增/编辑增加 **绑定标签 Id** `boundLabelIds`(LabelCode 或内部 Id)。查询树文件节点带回该字段。
+
+### 2.1 分类树(含文件)
+
+**GET** `/api/app/training/category-tree?includeFiles=true`
+
+| Query | 类型 | 必填 | 说明 |
+|---|---|---|---|
+| includeFiles | bool | 否 | 默认 true,是否带文件 |
+| keyword | string | 否 | 分类名或文件名 |
+| locationId | string | 否 | 按门店过滤可见文件 |
+| labelId | string | 否 | 只返回绑定了该标签的文件 |
+
+文件节点新增:
+
+| 字段 | 类型 | 说明 |
+|---|---|---|
+| boundLabelIds | string[] | 绑定标签 Id(LabelCode) |
+| boundLabels | string | 标签名称逗号拼接,无则为 `N/A` |
+
+```json
+[
+ {
+ "id": "cat-l1",
+ "categoryName": "Safety",
+ "parentId": null,
+ "orderNum": 100,
+ "children": [
+ {
+ "id": "cat-l2",
+ "categoryName": "Prep",
+ "parentId": "cat-l1",
+ "orderNum": 90,
+ "children": [],
+ "files": [
+ {
+ "id": "file-id-1",
+ "categoryId": "cat-l2",
+ "fileName": "手册.pdf",
+ "fileUrl": "/training/....pdf",
+ "fileType": "doc",
+ "fileSize": 1024,
+ "orderNum": 100,
+ "boundLabelIds": ["LB_1001"],
+ "boundLabels": "Chicken Salad"
+ }
+ ]
+ }
+ ],
+ "files": []
+ }
+]
+```
+
+### 2.2 上传文件(新增)
+
+**POST** `/api/app/training/file/upload`
+`multipart/form-data`
+
+| 字段 | 必填 | 说明 |
+|---|---|---|
+| file | 是 | 文件,最大 20MB |
+| categoryId | 是 | 二级分类 Id |
+| orderNum | 否 | 排序 |
+| boundLabelIds | 否 | 可重复,标签 LabelCode 或 Id |
+| 范围字段 | 否 | appliedPartnerType、partnerIds、appliedRegionType、regionIds、availabilityType、locationIds 等 |
+
+```bash
+curl -X POST "https://{host}/api/app/training/file/upload" \
+ -H "Authorization: {token}" \
+ -F "file=@手册.pdf" \
+ -F "categoryId=cat-l2" \
+ -F "boundLabelIds=LB_1001"
+```
+
+返回 `TrainingFileDto`(含 `boundLabelIds`)。
+
+### 2.3 编辑文件
+
+**PUT** `/api/app/training/{id}/file`
+
+```json
+{
+ "fileName": "操作手册.pdf",
+ "orderNum": 100,
+ "boundLabelIds": ["LB_1001", "LB_1002"]
+}
+```
+
+`boundLabelIds`:省略不改;`[]` 清空。非法标签:`绑定标签不存在:xxx`。
+
+---
+
+## 3. 系统菜单分页(同日修复)
+
+**GET** `/api/app/th-rbac-menu/list?maxResultCount=10&skipCount=40`
+
+`skipCount` 为 **offset**:`(currentPage-1)*maxResultCount`。上例为第 5 页。
+出参 `totalCount` + `items`(含 routeUrl、isShow 等)。
+
+---
+
+## 4. App 培训树(同日)
+
+**GET** `/api/app/us-app-training/tree?locationId={门店Id}&labelId={标签Id}`
+
+`locationId` 必填;`labelId` 可选,按绑定标签筛文件。
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/2026-10-15代码.md b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/2026-10-15代码.md
new file mode 100644
index 0000000..f9f26c0
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/2026-10-15代码.md
@@ -0,0 +1,112 @@
+# 2026-10-15 App 手动更新(前端对接)
+
+鉴权:本接口**无需登录**(可不带 `Authorization`)。
+统一包装:`GET /api/app/update` 返回 `{ "code": 200, "data": {}, "message": "" }`。
+`GET /api/app/update/apk` 为**二进制 APK**,不要当 JSON 解析。
+
+对齐锁控面板:查版本 → 弹窗确认 → 下载 APK → 调起系统安装页。
+后端只提供接口;前端(UniApp 打印端)在「Support / 关于」增加**手动检查更新**即可,不要改后端路由。
+
+---
+
+## 1. 查询最新版本
+
+**GET** `/api/app/update`
+
+| Query | 类型 | 必填 | 说明 |
+|---|---|---|---|
+| versionCode | int | 否 | 当前 App 本地整型版本(`manifest.versionCode` / `plus.runtime.versionCode`)。传入时 `data.hasUpdate` 有值 |
+
+### data 字段
+
+| 字段 | 类型 | 说明 |
+|---|---|---|
+| packageName | string | 包名,仅展示/校验,可不强制匹配 |
+| versionCode | int | 服务端最新整型版本 |
+| versionName | string | 展示用,如 `1.0.7` |
+| forceUpdate | bool | `true` 时弹窗不可取消,必须更新 |
+| changelog | string | 更新说明,可空 |
+| apkUrl | string | APK 完整下载地址(即 `/api/app/update/apk`) |
+| apkReady | bool | 服务端是否已放好 APK 文件 |
+| apkResolvedPath | string | 服务端本地路径,仅排查用,界面不要展示 |
+| hasUpdate | bool / null | 只有请求带了 `versionCode` 才有:远程更大且 `apkReady` 为 true |
+
+### 判断是否有更新(与锁控一致)
+
+```
+本地 versionCode < data.versionCode 且 data.apkReady === true 且 data.apkUrl 非空
+```
+
+也可直接用 `data.hasUpdate === true`(须在请求里带本地 `versionCode`)。
+
+`apkReady=false`:提示「服务器尚未上传安装包」,不要去下载。
+
+已是最新:Toast「已是最新版本 v{本地 versionName}」。
+
+---
+
+## 2. 下载 APK
+
+**GET** `/api/app/update/apk`
+
+- 响应:`application/vnd.android.package-archive`
+- 用 `uni.downloadFile({ url: data.apkUrl })`,成功后再 `plus.runtime.install(tempFilePath, { force: false })`
+- Android 需「允许安装未知应用」权限(API 26+:`REQUEST_INSTALL_PACKAGES`)
+
+---
+
+## 3. 建议交互(Support 页)
+
+当前 Support 已展示 App Version / Build Number,建议在版本卡片下加按钮 **Check for updates / 检查更新**:
+
+1. 取本地 `versionCode`(与 Build Number 同源)
+2. `GET /api/app/update?versionCode={本地}`
+3. 无更新 → Toast
+4. 有更新 → 弹窗标题「应用更新」,正文:`发现新版本 {versionName}\n{changelog}`
+ - `forceUpdate=false`:立即更新 / 稍后
+ - `forceUpdate=true`:仅「立即更新」,不可关闭
+5. 立即更新 → 下载进度 → 调起安装页,用户点一次「安装」
+
+不要做静默安装。不要在启动时强制自动弹窗(需求为**手动更新**);若以后要自动检查,仍调同一接口即可。
+
+---
+
+## 4. 请求示例
+
+```http
+GET /api/app/update?versionCode=106
+```
+
+`data` 示例:
+
+```json
+{
+ "packageName": "com.3flabeling.usapp",
+ "versionCode": 107,
+ "versionName": "1.0.7",
+ "forceUpdate": false,
+ "changelog": "修复打印连接",
+ "apkUrl": "https://flusapi-tetest.3flabeling.com/api/app/update/apk",
+ "apkReady": true,
+ "apkResolvedPath": "/www/wwwroot/FoodLabelingManagementUs/wwwroot/app-update/app-release.apk",
+ "hasUpdate": true
+}
+```
+
+---
+
+## 5. 发布约定(给联调)
+
+**接口里的 versionCode / versionName 跟 APK 走,不跟后端日常发版走。**
+
+- 只修后端 bug、重新部署 API:不换 APK → 检查更新仍是旧号,App 不会被提示更新。
+- 前端要发新包:把新 APK(`manifest.json` 里 versionCode 已 +1)放到
+ `/www/wwwroot/FoodLabelingManagementTeUsTest/wwwroot/app-update/app-release.apk`
+ 后端会从包内 `manifest.json` 读出版本。读不到时可在同目录放 `version.json`:
+ `{"versionCode":107,"versionName":"1.0.7"}`
+- `appsettings.json` 的 `FoodLabeling:AppUpdate.VersionCode` 只是**没有 APK 时的兜底**,日常修 bug 不用改。
+- `ForceUpdate` / `Changelog` 仍在
+ `美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json`
+ 的 `FoodLabeling.AppUpdate` 里手动改。
+
+无新数据库表,主库/租户库都不用改。
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_alert_template.sql b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_alert_template.sql
new file mode 100644
index 0000000..6ed8a8e
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_alert_template.sql
@@ -0,0 +1,19 @@
+-- 告警日期时间格式模板(租户业务库)
+-- 执行前请备份;可重复执行
+
+SET @db := DATABASE();
+
+CREATE TABLE IF NOT EXISTS `fl_alert_template` (
+ `Id` varchar(36) NOT NULL COMMENT '主键(YitId)',
+ `TemplateName` varchar(200) NOT NULL COMMENT '模板名称',
+ `DateTimeFormat` varchar(100) NOT NULL COMMENT '日期时间格式(如 MM/dd/yyyy h:mm tt)',
+ `State` tinyint(1) NOT NULL DEFAULT 1 COMMENT '启用状态',
+ `IsDeleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '软删',
+ `DeletionTime` datetime DEFAULT NULL,
+ `CreatedBy` varchar(36) DEFAULT NULL,
+ `CreationTime` datetime NOT NULL,
+ `LastModificationTime` datetime DEFAULT NULL,
+ PRIMARY KEY (`Id`),
+ KEY `idx_fl_alert_template_state` (`State`),
+ KEY `idx_fl_alert_template_name` (`TemplateName`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='告警日期时间格式模板';
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_bound_label.sql b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_bound_label.sql
new file mode 100644
index 0000000..c4b54d9
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_bound_label.sql
@@ -0,0 +1,24 @@
+-- 标签 / 培训文件「绑定标签」关联表
+-- 执行前请备份;可重复执行
+
+SET @db := DATABASE();
+
+CREATE TABLE IF NOT EXISTS `fl_label_bound_label` (
+ `Id` varchar(36) NOT NULL COMMENT '主键',
+ `LabelId` varchar(36) NOT NULL COMMENT '主标签 fl_label.Id',
+ `BoundLabelId` varchar(36) NOT NULL COMMENT '被绑定标签 fl_label.Id',
+ PRIMARY KEY (`Id`),
+ UNIQUE KEY `uk_fl_label_bound_label` (`LabelId`, `BoundLabelId`),
+ KEY `idx_fl_label_bound_owner` (`LabelId`),
+ KEY `idx_fl_label_bound_target` (`BoundLabelId`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='标签绑定其他标签';
+
+CREATE TABLE IF NOT EXISTS `fl_training_file_label` (
+ `Id` varchar(36) NOT NULL COMMENT '主键',
+ `TrainingFileId` varchar(36) NOT NULL COMMENT 'fl_training_file.Id',
+ `LabelId` varchar(36) NOT NULL COMMENT 'fl_label.Id',
+ PRIMARY KEY (`Id`),
+ UNIQUE KEY `uk_fl_training_file_label` (`TrainingFileId`, `LabelId`),
+ KEY `idx_fl_tflabel_file` (`TrainingFileId`),
+ KEY `idx_fl_tflabel_label` (`LabelId`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='培训文件绑定标签';
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_label_alert_timer.sql b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_label_alert_timer.sql
index 60dbfea..c00fa72 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_label_alert_timer.sql
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_label_alert_timer.sql
@@ -13,12 +13,18 @@ CREATE TABLE IF NOT EXISTS `fl_label_alert_timer` (
`ProductId` varchar(36) DEFAULT NULL COMMENT '产品Id',
`ProductName` varchar(500) DEFAULT NULL COMMENT '产品名称',
`LocationId` varchar(36) NOT NULL COMMENT '门店Id',
+ `LocationName` varchar(200) DEFAULT NULL COMMENT '门店名冗余',
`PrintedAt` datetime NOT NULL COMMENT '打印时刻(PrintedAt ?? BaseTime ?? CreationTime)',
`BaseTime` datetime DEFAULT NULL COMMENT '基准时间',
`ExpiresAt` datetime NOT NULL COMMENT '过期时刻',
`DurationSeconds` int NOT NULL DEFAULT 0 COMMENT '总时长(秒)',
`Title` varchar(500) NOT NULL COMMENT '标题',
`Subtitle` varchar(500) NOT NULL COMMENT '副标题',
+ `AlertTemplateId` varchar(36) DEFAULT NULL COMMENT '告警模板Id',
+ `AlertTemplateName` varchar(200) DEFAULT NULL COMMENT '告警模板名称',
+ `DateTimeFormat` varchar(100) DEFAULT NULL COMMENT '过期时刻展示格式',
+ `PrintedByUserId` varchar(36) DEFAULT NULL COMMENT '打印人Id',
+ `PrintedByUserName` varchar(200) DEFAULT NULL COMMENT '打印人姓名',
`IsDeleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '软删',
`DeletionTime` datetime DEFAULT NULL COMMENT '删除时间',
`CreatedBy` varchar(36) DEFAULT NULL COMMENT '创建者',
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_label_alert_timer_alert_template.sql b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_label_alert_timer_alert_template.sql
new file mode 100644
index 0000000..a01101a
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_label_alert_timer_alert_template.sql
@@ -0,0 +1,70 @@
+-- 告警计时器扩展:模板冗余、打印人、门店名(租户业务库)
+-- 执行前请备份;可重复执行
+
+SET @db := DATABASE();
+
+SET @c := (
+ SELECT COUNT(*) FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'AlertTemplateId'
+);
+SET @ddl := IF(
+ @c = 0,
+ 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `AlertTemplateId` varchar(36) NULL DEFAULT NULL COMMENT ''告警模板Id'' AFTER `Subtitle`',
+ 'SELECT 1'
+);
+PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s;
+
+SET @c := (
+ SELECT COUNT(*) FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'AlertTemplateName'
+);
+SET @ddl := IF(
+ @c = 0,
+ 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `AlertTemplateName` varchar(200) NULL DEFAULT NULL COMMENT ''告警模板名称'' AFTER `AlertTemplateId`',
+ 'SELECT 1'
+);
+PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s;
+
+SET @c := (
+ SELECT COUNT(*) FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'DateTimeFormat'
+);
+SET @ddl := IF(
+ @c = 0,
+ 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `DateTimeFormat` varchar(100) NULL DEFAULT NULL COMMENT ''过期时刻展示格式'' AFTER `AlertTemplateName`',
+ 'SELECT 1'
+);
+PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s;
+
+SET @c := (
+ SELECT COUNT(*) FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'PrintedByUserId'
+);
+SET @ddl := IF(
+ @c = 0,
+ 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `PrintedByUserId` varchar(36) NULL DEFAULT NULL COMMENT ''打印人Id'' AFTER `DateTimeFormat`',
+ 'SELECT 1'
+);
+PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s;
+
+SET @c := (
+ SELECT COUNT(*) FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'PrintedByUserName'
+);
+SET @ddl := IF(
+ @c = 0,
+ 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `PrintedByUserName` varchar(200) NULL DEFAULT NULL COMMENT ''打印人姓名'' AFTER `PrintedByUserId`',
+ 'SELECT 1'
+);
+PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s;
+
+SET @c := (
+ SELECT COUNT(*) FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'fl_label_alert_timer' AND COLUMN_NAME = 'LocationName'
+);
+SET @ddl := IF(
+ @c = 0,
+ 'ALTER TABLE `fl_label_alert_timer` ADD COLUMN `LocationName` varchar(200) NULL DEFAULT NULL COMMENT ''门店名冗余'' AFTER `LocationId`',
+ 'SELECT 1'
+);
+PREPARE s FROM @ddl; EXECUTE s; DEALLOCATE PREPARE s;
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_menu_hide_platform_qr_codes.sql b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_menu_hide_platform_qr_codes.sql
new file mode 100644
index 0000000..6244e5b
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/fl_menu_hide_platform_qr_codes.sql
@@ -0,0 +1,22 @@
+-- 企业端(租户业务库)去掉「二维码」菜单:软删 + 解除角色绑定
+-- 新租户初始化会自动执行;已有租户请手工执行
+-- 可重复执行。禁止在主库 Host 执行(主库二维码要保留在「平台管理」下)
+
+SET NAMES utf8mb4;
+
+UPDATE `menu`
+SET `IsDeleted` = 1,
+ `LastModificationTime` = NOW()
+WHERE (`IsDeleted` = 0 OR `IsDeleted` IS NULL)
+ AND (
+ `Id` = 'f0010037-0001-4000-8000-000000000037'
+ OR `Router` IN ('/qr-codes', '/platform/qr-codes')
+ OR `PermissionCode` IN ('menu.management.qr-codes', 'menu.platform.qr-codes')
+ );
+
+DELETE `rm`
+FROM `rolemenu` `rm`
+INNER JOIN `menu` `m` ON `m`.`Id` = `rm`.`MenuId`
+WHERE `m`.`Id` = 'f0010037-0001-4000-8000-000000000037'
+ OR `m`.`Router` IN ('/qr-codes', '/platform/qr-codes')
+ OR `m`.`PermissionCode` IN ('menu.management.qr-codes', 'menu.platform.qr-codes');
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/label-training-绑定标签接口文档.md b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/label-training-绑定标签接口文档.md
new file mode 100644
index 0000000..cef49bc
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/label-training-绑定标签接口文档.md
@@ -0,0 +1,314 @@
+# 泰鄂版 Label / Training 接口文档(绑定标签)
+
+适用范围:泰鄂版后端 `LabelAppService`、`TrainingAppService`。
+鉴权:请求头 `Authorization` 填登录返回的 `data.token`(已含 `Bearer ` 前缀)。
+租户:业务数据在**当前租户库**;`boundLabelIds` 落库 `fl_label_bound_label` / `fl_training_file_label`。
+
+统一响应(Yi 包装):
+
+```json
+{
+ "code": 200,
+ "data": {},
+ "message": ""
+}
+```
+
+下文示例均为 `data` 内层。JSON 字段均为 camelCase。
+
+---
+
+## 公共约定:绑定标签 `boundLabelIds`
+
+| 项 | 说明 |
+|---|---|
+| 入参 | `string[]`,元素为标签 **LabelCode** 或内部 `fl_label.Id` |
+| 出参 `boundLabelIds` | 统一为 **LabelCode**(与标签列表 `id` 相同) |
+| 出参 `boundLabels` | 绑定标签名称,逗号拼接;无绑定时为 `N/A` |
+| 新增未传 / 空数组 | 不绑定 |
+| **编辑未传(null)** | **不改动**已有绑定(兼容旧前端) |
+| 编辑传 `[]` | 清空绑定 |
+| 非法 Id | 400,提示 `绑定标签不存在:xxx` |
+| 标签绑自己 | 自动忽略 |
+
+---
+
+## 一、标签 `/api/app/label`
+
+路由前缀:`/api/app/label`。路径参数 `id` = **LabelCode**(不是内部主键)。
+
+### 1.1 分页列表
+
+- **GET** `/api/app/label`
+- Query(本项目分页:`SkipCount` 为页码,从 1 开始)
+
+| 参数 | 类型 | 必填 | 说明 |
+|---|---|---|---|
+| SkipCount | int | 否 | 页码,从 1 开始。例:`1` |
+| MaxResultCount | int | 否 | 每页条数。例:`10` |
+| Keyword | string | 否 | 关键字 |
+| PartnerId | string | 否 | Company Id |
+| GroupId | string | 否 | Region / `fl_group.Id` |
+| LocationId | string | 否 | 门店 Id |
+| ProductId | string | 否 | 按产品筛标签 |
+| LabelCategoryId | string | 否 | 标签分类 |
+| LabelTypeId | string | 否 | 标签类型 |
+| TemplateCode | string | 否 | 模板编码 |
+| State | bool | 否 | 启用状态 |
+
+示例:`GET /api/app/label?SkipCount=1&MaxResultCount=10`
+
+`data`:
+
+```json
+{
+ "pageIndex": 1,
+ "pageSize": 10,
+ "totalCount": 100,
+ "totalPages": 10,
+ "items": [
+ {
+ "id": "LB_1001",
+ "labelName": "Chicken Salad",
+ "locationName": "Store A",
+ "locationIds": ["loc-1"],
+ "region": "Group A",
+ "regionIds": ["g-1"],
+ "groupIds": ["g-1"],
+ "appliedRegionType": "SPECIFIED",
+ "labelCategoryName": "Prepared",
+ "productCategoryName": "Salad",
+ "products": "Chicken Salad",
+ "boundLabelIds": ["LB_2002"],
+ "boundLabels": "Allergen Warning",
+ "templateName": "Nutrition 3x6",
+ "templateCode": "TPL_NUTRITION_3X6",
+ "labelTypeName": "Prep",
+ "state": true,
+ "lastEdited": "2026-10-12T10:00:00",
+ "hasError": false
+ }
+ ]
+}
+```
+
+### 1.2 详情
+
+- **GET** `/api/app/label/{id}`
+- `id`:LabelCode
+
+`data` 主要字段:
+
+| 字段 | 类型 | 说明 |
+|---|---|---|
+| id | string | LabelCode |
+| labelName | string | 名称 |
+| locationId / locationIds / location / locationName | | 门店 |
+| partnerId / partnerIds / companyIds | | Company |
+| appliedRegionType | string | `ALL` / `SPECIFIED` |
+| region / regionIds / groupIds | | Region |
+| labelCategoryId / labelCategoryName | | 分类 |
+| labelTypeId / labelTypeName | | 类型 |
+| templateCode / templateName | | 模板 |
+| state | bool | 启用 |
+| labelInfoJson | object | 模板数据 |
+| productIds | string[] | 绑定产品 Id |
+| boundLabelIds | string[] | 绑定标签 LabelCode |
+| boundLabels | string | 绑定标签名称 |
+
+### 1.3 新增
+
+- **POST** `/api/app/label`
+- Header:`Content-Type: application/json`
+
+| 字段 | 类型 | 必填 | 说明 |
+|---|---|---|---|
+| labelName | string | 是 | 名称 |
+| templateCode | string | 是 | 模板编码 |
+| labelCategoryId | string | 是 | 分类 Id |
+| productIds | string[] | 是 | 至少 1 个产品 |
+| labelCode | string | 否 | 不传则后端生成 |
+| partnerId / partnerIds / companyIds | | 否 | Company,单选 |
+| appliedRegionType | string | 否 | `ALL` / `SPECIFIED` |
+| regionIds / groupIds | string[] | 否 | Region,可含 `"ALL"` |
+| locationIds / locationId | | 否 | 门店,可含 `"ALL"` |
+| labelTypeId | string | 否 | 类型 |
+| boundLabelIds | string[] | 否 | 绑定其他标签 |
+| labelInfoJson | object | 否 | 模板数据 |
+| state | bool | 否 | 默认 true |
+
+请求示例:
+
+```json
+{
+ "labelName": "Chicken Salad",
+ "templateCode": "TPL_NUTRITION_3X6",
+ "labelCategoryId": "cat-id",
+ "productIds": ["product-id"],
+ "appliedRegionType": "SPECIFIED",
+ "regionIds": ["group-id"],
+ "locationIds": ["location-id"],
+ "boundLabelIds": ["LB_2002"],
+ "state": true
+}
+```
+
+成功返回同 **1.2 详情**。
+
+### 1.4 编辑
+
+- **PUT** `/api/app/label/{id}`
+- `id`:LabelCode
+- Body 与新增基本相同(无 `labelCode`)
+- `boundLabelIds`:**省略则不改绑定**;`[]` 清空;有值则全量覆盖
+
+```json
+{
+ "labelName": "Chicken Salad",
+ "templateCode": "TPL_NUTRITION_3X6",
+ "labelCategoryId": "cat-id",
+ "productIds": ["product-id"],
+ "boundLabelIds": ["LB_2002", "LB_2003"],
+ "state": true
+}
+```
+
+成功返回同 **1.2 详情**。
+
+---
+
+## 二、培训 `/api/app/training`
+
+查询树:`GET /api/app/training/category-tree`(管理端实际调用此路径,不是裸 `/api/app/training`)。
+
+### 2.1 分类树(含文件)
+
+- **GET** `/api/app/training/category-tree`
+
+| 参数 | 类型 | 必填 | 说明 |
+|---|---|---|---|
+| keyword | string | 否 | 匹配分类名或文件名 |
+| locationId | string | 否 | 按门店过滤可见文件 |
+| includeFiles | bool | 否 | 是否带文件,默认 true |
+
+`data`:一级分类数组,`children` 为二级;文件只挂在二级 `files`。
+
+```json
+[
+ {
+ "id": "cat-l1",
+ "categoryName": "Safety",
+ "parentId": null,
+ "orderNum": 100,
+ "children": [
+ {
+ "id": "cat-l2",
+ "categoryName": "Prep",
+ "parentId": "cat-l1",
+ "orderNum": 90,
+ "children": [],
+ "files": [
+ {
+ "id": "file-id",
+ "categoryId": "cat-l2",
+ "fileName": "手册.pdf",
+ "fileUrl": "/training/....pdf",
+ "fileType": "doc",
+ "fileSize": 1024,
+ "orderNum": 100,
+ "appliedPartnerType": "ALL",
+ "company": "All Companies",
+ "partnerIds": [],
+ "companyIds": [],
+ "appliedRegionType": "ALL",
+ "region": "",
+ "regionIds": [],
+ "groupIds": [],
+ "availabilityType": "ALL",
+ "location": "",
+ "locationIds": [],
+ "boundLabelIds": ["LB_1001"],
+ "boundLabels": "Chicken Salad",
+ "creationTime": "2026-10-12T10:00:00",
+ "lastModificationTime": "2026-10-12T10:00:00"
+ }
+ ]
+ }
+ ],
+ "files": []
+ }
+]
+```
+
+### 2.2 上传文件(新增)
+
+- **POST** `/api/app/training/file/upload`
+- `multipart/form-data`,单文件最大 20MB
+
+| 字段 | 类型 | 必填 | 说明 |
+|---|---|---|---|
+| file | file | 是 | 文件 |
+| categoryId | string | 是 | **二级**分类 Id |
+| orderNum | int | 否 | 排序 |
+| appliedPartnerType | string | 否 | Company:`ALL` / `SPECIFIED` |
+| partnerIds / companyIds | string | 否 | 可重复;可含 `ALL` |
+| appliedRegionType | string | 否 | Region:`ALL` / `SPECIFIED` |
+| regionIds / groupIds | string | 否 | 可重复;可含 `ALL` |
+| availabilityType / appliedLocationType | string | 否 | Location:`ALL` / `SPECIFIED` |
+| locationIds | string | 否 | 可重复;可含 `ALL` |
+| boundLabelIds | string | 否 | 可重复,LabelCode 或 Id |
+
+curl 示例:
+
+```bash
+curl -X POST "https://{host}/api/app/training/file/upload" \
+ -H "Authorization: {token}" \
+ -F "file=@手册.pdf" \
+ -F "categoryId=cat-l2" \
+ -F "orderNum=100" \
+ -F "boundLabelIds=LB_1001" \
+ -F "boundLabelIds=LB_1002"
+```
+
+成功返回 `TrainingFileDto`(结构同树节点 `files[]`)。
+
+### 2.3 编辑文件
+
+- **PUT** `/api/app/training/{id}/file`
+- `id`:文件 Id
+- `Content-Type: application/json`
+
+| 字段 | 类型 | 必填 | 说明 |
+|---|---|---|---|
+| fileName | string | 是 | 展示文件名 |
+| orderNum | int | 否 | 排序 |
+| appliedPartnerType / partnerIds / companyIds | | 否 | 有传才改 Company 范围 |
+| appliedRegionType / regionIds / groupIds | | 否 | 有传才改 Region |
+| availabilityType / appliedLocationType / locationIds | | 否 | 有传才改 Location |
+| boundLabelIds | string[] | 否 | 省略不改;`[]` 清空 |
+
+```json
+{
+ "fileName": "操作手册.pdf",
+ "orderNum": 100,
+ "appliedPartnerType": "SPECIFIED",
+ "partnerIds": ["p1"],
+ "appliedRegionType": "ALL",
+ "availabilityType": "SPECIFIED",
+ "locationIds": ["loc1"],
+ "boundLabelIds": ["LB_1001"]
+}
+```
+
+成功返回 `TrainingFileDto`。
+
+---
+
+## 三、相关表(租户库)
+
+| 表 | 含义 |
+|---|---|
+| `fl_label_bound_label` | 标签绑定其他标签:`LabelId` → `BoundLabelId` |
+| `fl_training_file_label` | 培训文件绑定标签:`TrainingFileId` → `LabelId` |
+
+脚本:同目录 `fl_bound_label.sql`。
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/seed_host_platform_menus.sql b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/seed_host_platform_menus.sql
index 8645253..a7f9fab 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/seed_host_platform_menus.sql
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/scripts/seed_host_platform_menus.sql
@@ -1,6 +1,7 @@
-- 泰额版平台级菜单:清空 antis-foodlabeling-host.menu 后按前端路由表重录
-- 使用稳定 Id(f001*),保证 rolemenu 等引用不失效
-- MenuSource=0(Ruoyi),平台目录 MenuType=0,页面 MenuType=1
+-- 仅在【主库 Host】执行,禁止在租户业务库执行(会清空租户 menu)
SET NAMES utf8mb4;
START TRANSACTION;
@@ -24,6 +25,9 @@ INSERT INTO menu (
('f0010003-0001-4000-8000-000000000003', 0, NOW(), NULL, NULL, NULL,
6, 1, 'SAAS 公司', 'FoodLabelingPlatformTenants', 1, 'menu.platform.tenants', 'f0010002-0001-4000-8000-000000000002',
'lucide:building', '/platform/tenants', 0, 0, 1, NULL, '/food-labeling/platform/tenants/index', 0, NULL, ''),
+('f0010037-0001-4000-8000-000000000037', 0, NOW(), NULL, NULL, NULL,
+ 7, 1, '二维码', 'FoodLabelingQrCodes', 1, 'menu.platform.qr-codes', 'f0010002-0001-4000-8000-000000000002',
+ 'lucide:qr-code', '/platform/qr-codes', 0, 0, 1, NULL, '/food-labeling/modules/qr-codes/index', 0, NULL, ''),
-- 标签管理
('f0010010-0001-4000-8000-000000000010', 0, NOW(), NULL, NULL, NULL,
@@ -45,59 +49,53 @@ INSERT INTO menu (
15, 1, '多选选项集', 'FoodLabelingMultipleOptions', 1, 'menu.labeling.multiple-options', 'f0010010-0001-4000-8000-000000000010',
'lucide:list-checks', '/multiple-options', 0, 0, 1, NULL, '/food-labeling/labeling/multiple-options/index', 0, NULL, ''),
--- 业务模块
-('f0010020-0001-4000-8000-000000000020', 0, NOW(), NULL, NULL, NULL,
- 15, 1, '业务模块', 'FoodLabelingModules', 0, 'menu.modules', '0',
- 'lucide:boxes', '/modules', 0, 0, 1, NULL, NULL, 0, NULL, ''),
+-- 原「业务模块」子项:提升为一级菜单(ParentId=0),不再保留「业务模块」目录
('f0010021-0001-4000-8000-000000000021', 0, NOW(), NULL, NULL, NULL,
- 16, 1, '培训', 'FoodLabelingTraining', 1, 'menu.modules.training', 'f0010020-0001-4000-8000-000000000020',
+ 15, 1, '培训', 'FoodLabelingTraining', 1, 'menu.modules.training', '0',
'lucide:graduation-cap', '/training', 0, 0, 1, NULL, '/food-labeling/modules/training/index', 0, NULL, ''),
('f0010022-0001-4000-8000-000000000022', 0, NOW(), NULL, NULL, NULL,
- 17, 1, '告警', 'FoodLabelingAlerts', 1, 'menu.modules.alerts', 'f0010020-0001-4000-8000-000000000020',
+ 16, 1, '告警', 'FoodLabelingAlerts', 1, 'menu.modules.alerts', '0',
'lucide:bell', '/alerts', 0, 0, 1, NULL, '/food-labeling/modules/alerts/index', 0, NULL, ''),
('f0010023-0001-4000-8000-000000000023', 0, NOW(), NULL, NULL, NULL,
- 18, 1, '任务', 'FoodLabelingTasks', 1, 'menu.modules.tasks', 'f0010020-0001-4000-8000-000000000020',
+ 17, 1, '任务', 'FoodLabelingTasks', 1, 'menu.modules.tasks', '0',
'lucide:list-todo', '/tasks', 0, 0, 1, NULL, '/food-labeling/modules/tasks/index', 0, NULL, ''),
('f0010024-0001-4000-8000-000000000024', 0, NOW(), NULL, NULL, NULL,
- 19, 1, '传感器', 'FoodLabelingSensors', 1, 'menu.modules.sensors', 'f0010020-0001-4000-8000-000000000020',
+ 18, 1, '传感器', 'FoodLabelingSensors', 1, 'menu.modules.sensors', '0',
'lucide:activity', '/sensors', 0, 0, 1, NULL, '/food-labeling/modules/sensors/index', 0, NULL, ''),
('f0010025-0001-4000-8000-000000000025', 0, NOW(), NULL, NULL, NULL,
- 20, 1, '食物浪费', 'FoodLabelingFoodWaste', 1, 'menu.modules.food-waste', 'f0010020-0001-4000-8000-000000000020',
+ 19, 1, '食物浪费', 'FoodLabelingFoodWaste', 1, 'menu.modules.food-waste', '0',
'lucide:apple', '/food-waste', 0, 0, 1, NULL, '/food-labeling/modules/food-waste/index', 0, NULL, ''),
('f0010026-0001-4000-8000-000000000026', 0, NOW(), NULL, NULL, NULL,
- 21, 1, '电子标签', 'FoodLabelingELabelModule', 1, 'menu.modules.e-label', 'f0010020-0001-4000-8000-000000000020',
+ 20, 1, '电子标签', 'FoodLabelingELabelModule', 1, 'menu.modules.e-label', '0',
'lucide:file-digit', '/e-label-module', 0, 0, 1, NULL, '/food-labeling/modules/e-label/index', 0, NULL, ''),
-- 管理
('f0010030-0001-4000-8000-000000000030', 0, NOW(), NULL, NULL, NULL,
- 20, 1, '管理', 'FoodLabelingManagement', 0, 'menu.management', '0',
+ 30, 1, '管理', 'FoodLabelingManagement', 0, 'menu.management', '0',
'lucide:building-2', '/management', 0, 0, 1, NULL, NULL, 0, NULL, ''),
('f0010031-0001-4000-8000-000000000031', 0, NOW(), NULL, NULL, NULL,
- 21, 1, '账户管理', 'FoodLabelingAccountManagement', 1, 'menu.management.account', 'f0010030-0001-4000-8000-000000000030',
+ 31, 1, '账户管理', 'FoodLabelingAccountManagement', 1, 'menu.management.account', 'f0010030-0001-4000-8000-000000000030',
'lucide:users', '/account-management', 0, 0, 1, NULL, '/food-labeling/management/account-management/index', 0, NULL, ''),
('f0010032-0001-4000-8000-000000000032', 0, NOW(), NULL, NULL, NULL,
- 22, 1, '系统菜单', 'FoodLabelingSystemMenu', 1, 'menu.management.system-menu', 'f0010030-0001-4000-8000-000000000030',
+ 32, 1, '系统菜单', 'FoodLabelingSystemMenu', 1, 'menu.management.system-menu', 'f0010030-0001-4000-8000-000000000030',
'lucide:menu-square', '/system-menu', 0, 0, 1, NULL, '/food-labeling/management/system-menu/index', 0, NULL, ''),
('f0010033-0001-4000-8000-000000000033', 0, NOW(), NULL, NULL, NULL,
- 23, 1, '菜单管理', 'FoodLabelingMenuManagement', 1, 'menu.management.menu', 'f0010030-0001-4000-8000-000000000030',
+ 33, 1, '菜单管理', 'FoodLabelingMenuManagement', 1, 'menu.management.menu', 'f0010030-0001-4000-8000-000000000030',
'lucide:utensils', '/menu-management', 0, 0, 1, NULL, '/food-labeling/management/menu-management/index', 0, NULL, ''),
('f0010034-0001-4000-8000-000000000034', 0, NOW(), NULL, NULL, NULL,
- 24, 1, '设备', 'FoodLabelingDevices', 1, 'menu.management.devices', 'f0010030-0001-4000-8000-000000000030',
+ 34, 1, '设备', 'FoodLabelingDevices', 1, 'menu.management.devices', 'f0010030-0001-4000-8000-000000000030',
'lucide:smartphone', '/devices', 0, 0, 1, NULL, '/food-labeling/modules/devices/index', 0, NULL, ''),
('f0010035-0001-4000-8000-000000000035', 0, NOW(), NULL, NULL, NULL,
- 25, 1, '报表', 'FoodLabelingReports', 1, 'menu.management.reports', 'f0010030-0001-4000-8000-000000000030',
+ 35, 1, '报表', 'FoodLabelingReports', 1, 'menu.management.reports', 'f0010030-0001-4000-8000-000000000030',
'lucide:file-bar-chart', '/reports', 0, 0, 1, NULL, '/food-labeling/management/reports/index', 0, NULL, ''),
('f0010036-0001-4000-8000-000000000036', 0, NOW(), NULL, NULL, NULL,
- 26, 1, '发票', 'FoodLabelingInvoices', 1, 'menu.management.invoices', 'f0010030-0001-4000-8000-000000000030',
+ 36, 1, '发票', 'FoodLabelingInvoices', 1, 'menu.management.invoices', 'f0010030-0001-4000-8000-000000000030',
'lucide:receipt', '/invoices', 0, 0, 1, NULL, '/food-labeling/modules/invoices/index', 0, NULL, ''),
-('f0010037-0001-4000-8000-000000000037', 0, NOW(), NULL, NULL, NULL,
- 27, 1, '二维码', 'FoodLabelingQrCodes', 1, 'menu.management.qr-codes', 'f0010030-0001-4000-8000-000000000030',
- 'lucide:qr-code', '/qr-codes', 0, 0, 1, NULL, '/food-labeling/modules/qr-codes/index', 0, NULL, ''),
('f0010038-0001-4000-8000-000000000038', 0, NOW(), NULL, NULL, NULL,
- 28, 1, '支持', 'FoodLabelingSupport', 1, 'menu.management.support', 'f0010030-0001-4000-8000-000000000030',
+ 37, 1, '支持', 'FoodLabelingSupport', 1, 'menu.management.support', 'f0010030-0001-4000-8000-000000000030',
'lucide:life-buoy', '/support', 0, 0, 1, NULL, '/food-labeling/management/support/index', 0, NULL, ''),
('f0010039-0001-4000-8000-000000000039', 0, NOW(), NULL, NULL, NULL,
- 29, 1, 'API', 'FoodLabelingApi', 1, 'menu.management.api', 'f0010030-0001-4000-8000-000000000030',
+ 38, 1, 'API', 'FoodLabelingApi', 1, 'menu.management.api', 'f0010030-0001-4000-8000-000000000030',
'lucide:code-2', '/api-settings', 0, 0, 1, NULL, '/food-labeling/modules/api/index', 0, NULL, '');
COMMIT;
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/RbacMenu/ThRbacMenuGetListInputVo.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/RbacMenu/ThRbacMenuGetListInputVo.cs
index a454339..516b15a 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/RbacMenu/ThRbacMenuGetListInputVo.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/RbacMenu/ThRbacMenuGetListInputVo.cs
@@ -14,6 +14,11 @@ public class ThRbacMenuGetListInputVo : PagedAndSortedResultRequestDto
public string? MenuName { get; set; }
///
+ /// 关键字(与 相同,兼容前端 Keyword)
+ ///
+ public string? Keyword { get; set; }
+
+ ///
/// 启用状态
///
public bool? State { get; set; }
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/RbacMenu/ThRbacMenuGetListOutputDto.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/RbacMenu/ThRbacMenuGetListOutputDto.cs
index 931ed09..921f643 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/RbacMenu/ThRbacMenuGetListOutputDto.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application.Contracts/Dtos/RbacMenu/ThRbacMenuGetListOutputDto.cs
@@ -17,6 +17,25 @@ public class ThRbacMenuGetListOutputDto
public string? Router { get; set; }
+ /// 与 相同,兼容前端 routeUrl
+ public string? RouteUrl { get; set; }
+
+ public string? MenuIcon { get; set; }
+
+ public bool IsLink { get; set; }
+
+ public bool IsCache { get; set; }
+
+ public bool IsShow { get; set; }
+
+ public string? Remark { get; set; }
+
+ public string? Component { get; set; }
+
+ public string? Query { get; set; }
+
+ public string? ConcurrencyStamp { get; set; }
+
public string? PermissionCode { get; set; }
public MenuTypeEnum MenuType { get; set; }
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Filters/FoodLabelingBusinessTenantActionFilter.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Filters/FoodLabelingBusinessTenantActionFilter.cs
index 75887aa..9eff1a1 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Filters/FoodLabelingBusinessTenantActionFilter.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Filters/FoodLabelingBusinessTenantActionFilter.cs
@@ -105,6 +105,8 @@ public class FoodLabelingBusinessTenantActionFilter : IAsyncActionFilter, ITrans
"/authorization",
"/login",
"/logout",
+ // App 热更新:主库配置 + 服务器文件,不依赖租户库
+ "/api/app/update",
"/wwwroot",
"/hangfire",
"/demo",
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantCompanyMenuSyncService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantCompanyMenuSyncService.cs
index 7ba84bf..c1a6175 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantCompanyMenuSyncService.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/TenantCompanyMenuSyncService.cs
@@ -87,6 +87,7 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran
var hostMenus = await ThTenantHostDataAccessor.LoadHostMenusAsync(_dbConnOptions);
var menusToUpsert = CollectMenusWithAncestors(hostMenus, menuIds);
await UpsertTenantMenusAsync(tenantDb, menusToUpsert, cancellationToken);
+ await HidePlatformQrMenusAsync(tenantDb, cancellationToken);
await ReplaceAdminRoleMenusAsync(tenantDb, adminRole.Id, menusToUpsert.Select(m => m.Id).ToList(), cancellationToken);
_logger.LogInformation(
@@ -127,6 +128,11 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran
var currentId = menuId;
while (currentId != Guid.Empty && byId.TryGetValue(currentId, out var menu))
{
+ if (ThSaasMenuPermissionCatalog.IsPlatformOnlyMenu(menu))
+ {
+ break;
+ }
+
if (!collected.Add(currentId))
{
break;
@@ -161,6 +167,36 @@ public class TenantCompanyMenuSyncService : ITenantCompanyMenuSyncService, ITran
return adminRoles.FirstOrDefault();
}
+ private static async Task HidePlatformQrMenusAsync(
+ ISqlSugarClient tenantDb,
+ CancellationToken cancellationToken)
+ {
+ var qrMenuId = Guid.Parse("f0010037-0001-4000-8000-000000000037");
+ var qrIds = await tenantDb.Queryable()
+ .Where(m => !m.IsDeleted)
+ .Where(m => m.Id == qrMenuId
+ || m.Router == "/qr-codes"
+ || m.Router == "/platform/qr-codes"
+ || m.PermissionCode == "menu.management.qr-codes"
+ || m.PermissionCode == "menu.platform.qr-codes")
+ .Select(m => m.Id)
+ .ToListAsync(cancellationToken);
+ if (qrIds.Count == 0)
+ {
+ return;
+ }
+
+ await tenantDb.Updateable()
+ .SetColumns(m => m.IsDeleted == true)
+ .SetColumns(m => m.LastModificationTime == DateTime.Now)
+ .Where(m => qrIds.Contains(m.Id))
+ .ExecuteCommandAsync(cancellationToken);
+
+ await tenantDb.Deleteable()
+ .Where(x => qrIds.Contains(x.MenuId))
+ .ExecuteCommandAsync(cancellationToken);
+ }
+
private static async Task UpsertTenantMenusAsync(
ISqlSugarClient tenantDb,
IReadOnlyList hostMenus,
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/ThSaasMenuPermissionCatalog.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/ThSaasMenuPermissionCatalog.cs
index f37628a..e9ec55e 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/ThSaasMenuPermissionCatalog.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/MultiTenancy/ThSaasMenuPermissionCatalog.cs
@@ -37,6 +37,7 @@ public static class ThSaasMenuPermissionCatalog
["management:reports"] = "f0010035-0001-4000-8000-000000000035",
["management:invoices"] = "f0010036-0001-4000-8000-000000000036",
["management:qr-codes"] = "f0010037-0001-4000-8000-000000000037",
+ ["platform:qr-codes"] = "f0010037-0001-4000-8000-000000000037",
["management:support"] = "f0010038-0001-4000-8000-000000000038",
["management:api"] = "f0010039-0001-4000-8000-000000000039",
};
@@ -51,6 +52,11 @@ public static class ThSaasMenuPermissionCatalog
return true;
}
+ if (IsQrCodeMenu(menu.Id.ToString(), menu.PermissionCode, menu.Router))
+ {
+ return true;
+ }
+
var code = menu.PermissionCode?.Trim() ?? string.Empty;
if (code.StartsWith("menu.platform", StringComparison.OrdinalIgnoreCase))
{
@@ -61,6 +67,26 @@ public static class ThSaasMenuPermissionCatalog
return router.StartsWith("/platform", StringComparison.OrdinalIgnoreCase);
}
+ /// 二维码已改为仅平台;含历史 management 权限码 / 旧路由。
+ public static bool IsQrCodeMenu(string? menuId, string? permissionCode, string? router)
+ {
+ if (string.Equals(menuId?.Trim(), "f0010037-0001-4000-8000-000000000037", StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ var code = permissionCode?.Trim() ?? string.Empty;
+ if (code.Equals("menu.management.qr-codes", StringComparison.OrdinalIgnoreCase)
+ || code.Equals("menu.platform.qr-codes", StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ var path = router?.Trim() ?? string.Empty;
+ return path.Equals("/qr-codes", StringComparison.OrdinalIgnoreCase)
+ || path.Equals("/platform/qr-codes", StringComparison.OrdinalIgnoreCase);
+ }
+
///
/// 将历史 SaaS Key / PermissionCode / 菜单 Id 统一为菜单 Id 字符串
///
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Services/ThRbacMenuAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Services/ThRbacMenuAppService.cs
index c441a2e..a2e41ea 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Services/ThRbacMenuAppService.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Services/ThRbacMenuAppService.cs
@@ -55,9 +55,9 @@ public class ThRbacMenuAppService : ApplicationService, IThRbacMenuAppService
/// ```
///
/// 参数说明:
- /// - skipCount: 跳过条数
+ /// - skipCount: ABP offset,公式 (currentPage-1)*maxResultCount;第 5 页每页 10 条应传 40,不是页码 40
/// - maxResultCount: 每页条数
- /// - menuName: 菜单名称模糊匹配
+ /// - menuName / keyword: 菜单名称模糊匹配
/// - state: 启用状态
/// - menuSource: 菜单来源(MenuSourceEnum)
/// - menuType: 菜单类型(MenuTypeEnum)
@@ -71,10 +71,12 @@ public class ThRbacMenuAppService : ApplicationService, IThRbacMenuAppService
public virtual async Task> GetListAsync([FromQuery] ThRbacMenuGetListInputVo input)
{
RefAsync total = 0;
+ var pageSize = input.MaxResultCount <= 0 ? 10 : input.MaxResultCount;
+ var pageIndex = PagedQueryConvention.PageIndexFromOffset(input.SkipCount, pageSize);
var query = BuildFilteredQuery(input)
.OrderBy(x => x.OrderNum, OrderByType.Desc);
- var entities = await query.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
+ var entities = await query.ToPageListAsync(pageIndex, pageSize, total);
var items = entities.Select(MapToListDto).ToList();
return new PagedResultDto(total, items);
}
@@ -397,9 +399,10 @@ public class ThRbacMenuAppService : ApplicationService, IThRbacMenuAppService
private ISugarQueryable BuildFilteredQuery(ThRbacMenuGetListInputVo input)
{
+ var name = !string.IsNullOrWhiteSpace(input.MenuName) ? input.MenuName!.Trim() : input.Keyword?.Trim();
return _dbContext.SqlSugarClient.Queryable()
.Where(x => x.IsDeleted == false)
- .WhereIF(!string.IsNullOrWhiteSpace(input.MenuName), x => x.MenuName.Contains(input.MenuName!.Trim()))
+ .WhereIF(!string.IsNullOrWhiteSpace(name), x => x.MenuName.Contains(name!))
.WhereIF(input.State is not null, x => x.State == input.State)
.WhereIF(input.MenuSource is not null, x => x.MenuSource == (int)input.MenuSource!.Value)
.WhereIF(input.MenuType is not null, x => x.MenuType == (int)input.MenuType!.Value);
@@ -465,6 +468,15 @@ public class ThRbacMenuAppService : ApplicationService, IThRbacMenuAppService
MenuName = x.MenuName ?? string.Empty,
RouterName = x.RouterName,
Router = x.Router,
+ RouteUrl = x.Router,
+ MenuIcon = x.MenuIcon,
+ IsLink = x.IsLink,
+ IsCache = x.IsCache,
+ IsShow = x.IsShow,
+ Remark = x.Remark,
+ Component = x.Component,
+ Query = x.Query,
+ ConcurrencyStamp = x.ConcurrencyStamp,
PermissionCode = x.PermissionCode,
MenuType = (MenuTypeEnum)x.MenuType,
MenuSource = (MenuSourceEnum)x.MenuSource,
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
index bc00469..d1db9f3 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
@@ -20,7 +20,7 @@
},
//应用启动:SelfUrl 供 Program.cs UseUrls 绑定;用 0.0.0.0 避免写成固定局域网 IP 在本机无该网卡时启动失败(WinError 10049)
"App": {
- "SelfUrl": "http://192.168.31.87:19002",
+ "SelfUrl": "http://192.168.31.88:19002",
"CorsOrigins": "http://localhost:19002;http://localhost:18000;http://localhost:5666;http://localhost:5173;http://localhost:5174;http://localhost:3000;http://127.0.0.1:19002;http://flus-tetest.3flabeling.com;https://flus-tetest.3flabeling.com;http://flusapi-tetest.3flabeling.com;https://flusapi-tetest.3flabeling.com"
},
//配置
@@ -60,6 +60,15 @@
},
"TenantSelectCrypto": {
"SecretKey": "FoodLabelingThTenantSelect2026Key!"
+ },
+ "AppUpdate": {
+ "Enabled": true,
+ "PackageName": "com.3flabeling.usapp",
+ "VersionCode": 106,
+ "VersionName": "1.0.6",
+ "ForceUpdate": false,
+ "Changelog": "",
+ "ApkPath": "/www/wwwroot/FoodLabelingManagementUs/wwwroot/app-update/app-release.apk"
}
},
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/wwwroot/FoodLabelingManagementSAAS/training/20261012140249_23897803234742272.jpg b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/wwwroot/FoodLabelingManagementSAAS/training/20261012140249_23897803234742272.jpg
new file mode 100644
index 0000000..a166919
--- /dev/null
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/wwwroot/FoodLabelingManagementSAAS/training/20261012140249_23897803234742272.jpg
diff --git a/泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/api/request.ts b/泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/api/request.ts
index cc969e0..6de2c40 100644
--- a/泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/api/request.ts
+++ b/泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/api/request.ts
@@ -1,4 +1,4 @@
-/**
+/**
* 璇ユ枃浠跺彲鑷鏍规嵁涓氬姟閫昏緫杩涜璋冩暣
*/
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AppUpdate/AppUpdateDto.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AppUpdate/AppUpdateDto.cs
new file mode 100644
index 0000000..05eb09d
--- /dev/null
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/AppUpdate/AppUpdateDto.cs
@@ -0,0 +1,30 @@
+namespace FoodLabeling.Application.Contracts.Dtos.AppUpdate;
+
+/// App 版本检查出参(对齐锁控面板 /api/app/update)。
+public class AppUpdateDto
+{
+ public string PackageName { get; set; } = string.Empty;
+
+ /// 服务端当前可安装包的版本号(来自 APK / version.json,不是每次后端发版)
+ public int VersionCode { get; set; }
+
+ public string VersionName { get; set; } = string.Empty;
+
+ public bool ForceUpdate { get; set; }
+
+ public string Changelog { get; set; } = string.Empty;
+
+ /// 完整 APK 下载地址
+ public string ApkUrl { get; set; } = string.Empty;
+
+ public bool ApkReady { get; set; }
+
+ /// 服务端实际解析到的 APK 路径(排查 apkReady=false;前端可忽略)
+ public string? ApkResolvedPath { get; set; }
+
+ ///
+ /// 入参带了本地 versionCode 时:远程更大且 apkReady 则为 true;
+ /// 未传本地版本时为 null,由前端自行比较。
+ ///
+ public bool? HasUpdate { get; set; }
+}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAppUpdateAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAppUpdateAppService.cs
new file mode 100644
index 0000000..dff6020
--- /dev/null
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/IServices/IAppUpdateAppService.cs
@@ -0,0 +1,13 @@
+using FoodLabeling.Application.Contracts.Dtos.AppUpdate;
+using Microsoft.AspNetCore.Mvc;
+using Volo.Abp.Application.Services;
+
+namespace FoodLabeling.Application.Contracts.IServices;
+
+/// App 版本检查与 APK 下载
+public interface IAppUpdateAppService : IApplicationService
+{
+ Task GetInfoAsync(int? versionCode);
+
+ IActionResult DownloadApk();
+}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabelingApplicationModule.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabelingApplicationModule.cs
index 1ada7bf..679bc51 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabelingApplicationModule.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/FoodLabelingApplicationModule.cs
@@ -23,6 +23,8 @@ public class FoodLabelingApplicationModule : AbpModule
{
Configure(
context.Services.GetConfiguration().GetSection(FoodLabelingBatchImportOptions.SectionName));
+ Configure(
+ context.Services.GetConfiguration().GetSection(FoodLabelingAppUpdateOptions.SectionName));
// 任意业务写接口成功后刷新系统编辑时间戳,供 my-menus.lastUpdated 使用
Configure(options =>
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdatePathHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdatePathHelper.cs
new file mode 100644
index 0000000..58b13f6
--- /dev/null
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdatePathHelper.cs
@@ -0,0 +1,87 @@
+using FoodLabeling.Application.Options;
+
+namespace FoodLabeling.Application.Helpers;
+
+/// 相对路径按进程工作目录解析;ApkPath 可为 APK 文件或目录。
+public static class AppUpdatePathHelper
+{
+ public const string DefaultFileName = "app-release.apk";
+
+ private static readonly string[] FallbackDirectories =
+ [
+ "/www/wwwroot/FoodLabelingManagementTeUsTest/wwwroot/app-update",
+ "/www/wwwroot/FoodLabelingManagementUs/wwwroot/app-update"
+ ];
+
+ public static FileInfo? ResolveApk(FoodLabelingAppUpdateOptions cfg)
+ {
+ if (cfg is null || string.IsNullOrWhiteSpace(cfg.ApkPath))
+ {
+ return null;
+ }
+
+ var configured = cfg.ApkPath.Trim().TrimEnd('/', '\\');
+ var tried = new HashSet(StringComparer.OrdinalIgnoreCase);
+ var candidates = new List();
+
+ void AddFile(string path)
+ {
+ if (string.IsNullOrWhiteSpace(path) || !tried.Add(path))
+ {
+ return;
+ }
+
+ candidates.Add(new FileInfo(path));
+ }
+
+ void AddPath(string path)
+ {
+ if (string.IsNullOrWhiteSpace(path))
+ {
+ return;
+ }
+
+ if (Directory.Exists(path))
+ {
+ AddFile(Path.Combine(path, DefaultFileName));
+ foreach (var apk in Directory.EnumerateFiles(path, "*.apk")
+ .OrderByDescending(File.GetLastWriteTimeUtc))
+ {
+ AddFile(apk);
+ }
+
+ return;
+ }
+
+ AddFile(path);
+ if (!Path.HasExtension(path))
+ {
+ AddFile(Path.Combine(path, DefaultFileName));
+ }
+ }
+
+ AddPath(configured);
+ if (!Path.IsPathRooted(configured))
+ {
+ var stripped = configured.StartsWith("./", StringComparison.Ordinal)
+ ? configured[2..]
+ : configured;
+ AddPath(Path.Combine(Environment.CurrentDirectory, stripped));
+ }
+
+ foreach (var dir in FallbackDirectories)
+ {
+ AddPath(dir);
+ }
+
+ foreach (var file in candidates)
+ {
+ if (file.Exists && file.Length > 0)
+ {
+ return file;
+ }
+ }
+
+ return candidates.Count == 0 ? null : candidates[0];
+ }
+}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdateVersionResolver.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdateVersionResolver.cs
new file mode 100644
index 0000000..ee4719c
--- /dev/null
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AppUpdateVersionResolver.cs
@@ -0,0 +1,168 @@
+using System.Collections.Concurrent;
+using System.IO.Compression;
+using System.Text.Json;
+using FoodLabeling.Application.Options;
+
+namespace FoodLabeling.Application.Helpers;
+
+///
+/// 版本号以已上传 APK 为准:日常后端发版不改版本;只有目录里换了新包才变。
+/// 优先读 APK 内 UniApp manifest.json,其次同目录 version.json,最后才用 appsettings 兜底。
+///
+public static class AppUpdateVersionResolver
+{
+ private static readonly ConcurrentDictionary ApkCache =
+ new(StringComparer.OrdinalIgnoreCase);
+
+ public static (int VersionCode, string VersionName) Resolve(FileInfo? apk, FoodLabelingAppUpdateOptions options)
+ {
+ var fallbackCode = options.VersionCode;
+ var fallbackName = options.VersionName ?? string.Empty;
+
+ if (apk is not { Exists: true, Length: > 0 })
+ {
+ return (fallbackCode, fallbackName);
+ }
+
+ if (TryReadFromApk(apk, out var apkCode, out var apkName))
+ {
+ return (apkCode, string.IsNullOrWhiteSpace(apkName) ? fallbackName : apkName);
+ }
+
+ if (TryReadSidecar(apk.DirectoryName, out var fileCode, out var fileName))
+ {
+ return (fileCode, string.IsNullOrWhiteSpace(fileName) ? fallbackName : fileName);
+ }
+
+ return (fallbackCode, fallbackName);
+ }
+
+ private static bool TryReadFromApk(FileInfo apk, out int versionCode, out string versionName)
+ {
+ versionCode = 0;
+ versionName = string.Empty;
+ var cacheKey = apk.FullName;
+ var ticks = apk.LastWriteTimeUtc.Ticks;
+ if (ApkCache.TryGetValue(cacheKey, out var cached)
+ && cached.Length == apk.Length
+ && cached.Ticks == ticks)
+ {
+ versionCode = cached.Code;
+ versionName = cached.Name;
+ return versionCode > 0;
+ }
+
+ try
+ {
+ using var zip = ZipFile.OpenRead(apk.FullName);
+ foreach (var entry in zip.Entries)
+ {
+ if (!entry.FullName.EndsWith("manifest.json", StringComparison.OrdinalIgnoreCase))
+ {
+ continue;
+ }
+
+ var path = entry.FullName.Replace('\\', '/');
+ if (path.Contains("/node_modules/", StringComparison.OrdinalIgnoreCase)
+ || path.Contains("/unpackage/", StringComparison.OrdinalIgnoreCase))
+ {
+ continue;
+ }
+
+ using var stream = entry.Open();
+ using var doc = JsonDocument.Parse(stream);
+ if (!TryReadManifest(doc.RootElement, out versionCode, out versionName) || versionCode <= 0)
+ {
+ continue;
+ }
+
+ ApkCache[cacheKey] = (apk.Length, ticks, versionCode, versionName);
+ return true;
+ }
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ private static bool TryReadSidecar(string? directory, out int versionCode, out string versionName)
+ {
+ versionCode = 0;
+ versionName = string.Empty;
+ if (string.IsNullOrWhiteSpace(directory))
+ {
+ return false;
+ }
+
+ var sidecar = Path.Combine(directory, "version.json");
+ if (!File.Exists(sidecar))
+ {
+ return false;
+ }
+
+ try
+ {
+ using var doc = JsonDocument.Parse(File.ReadAllText(sidecar));
+ return TryReadManifest(doc.RootElement, out versionCode, out versionName) && versionCode > 0;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
+
+ private static bool TryReadManifest(JsonElement root, out int versionCode, out string versionName)
+ {
+ versionCode = 0;
+ versionName = string.Empty;
+ if (root.ValueKind != JsonValueKind.Object)
+ {
+ return false;
+ }
+
+ versionName = ReadString(root, "versionName") ?? string.Empty;
+ var codeEl = GetProperty(root, "versionCode");
+ if (codeEl.ValueKind == JsonValueKind.Number && codeEl.TryGetInt32(out var n))
+ {
+ versionCode = n;
+ return true;
+ }
+
+ if (codeEl.ValueKind == JsonValueKind.String
+ && int.TryParse(codeEl.GetString(), out var fromText)
+ && fromText > 0)
+ {
+ versionCode = fromText;
+ return true;
+ }
+
+ return false;
+ }
+
+ private static string? ReadString(JsonElement root, string name)
+ {
+ var el = GetProperty(root, name);
+ return el.ValueKind == JsonValueKind.String ? el.GetString() : null;
+ }
+
+ private static JsonElement GetProperty(JsonElement root, string name)
+ {
+ if (root.TryGetProperty(name, out var el))
+ {
+ return el;
+ }
+
+ foreach (var p in root.EnumerateObject())
+ {
+ if (string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase))
+ {
+ return p.Value;
+ }
+ }
+
+ return default;
+ }
+}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Options/FoodLabelingAppUpdateOptions.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Options/FoodLabelingAppUpdateOptions.cs
new file mode 100644
index 0000000..38b64c2
--- /dev/null
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Options/FoodLabelingAppUpdateOptions.cs
@@ -0,0 +1,26 @@
+namespace FoodLabeling.Application.Options;
+
+///
+/// App 热更新。接口展示的版本号优先来自已上传 APK;appsettings 仅作无包时的兜底。
+///
+public class FoodLabelingAppUpdateOptions
+{
+ public const string SectionName = "FoodLabeling:AppUpdate";
+
+ public bool Enabled { get; set; } = true;
+
+ public string PackageName { get; set; } = "com.3flabeling.usapp";
+
+ /// 整型版本号,须大于 App 本地 versionCode 才会提示更新。
+ public int VersionCode { get; set; } = 106;
+
+ public string VersionName { get; set; } = "1.0.6";
+
+ public bool ForceUpdate { get; set; }
+
+ public string Changelog { get; set; } = string.Empty;
+
+ /// APK 文件或目录。部署脚本会改成对应环境的 wwwroot/app-update 路径。
+ public string ApkPath { get; set; } =
+ "/www/wwwroot/FoodLabelingManagementTeUsTest/wwwroot/app-update/app-release.apk";
+}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AppUpdateAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AppUpdateAppService.cs
new file mode 100644
index 0000000..2e0c8fc
--- /dev/null
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/AppUpdateAppService.cs
@@ -0,0 +1,138 @@
+using FoodLabeling.Application.Contracts.Dtos.AppUpdate;
+using FoodLabeling.Application.Contracts.IServices;
+using FoodLabeling.Application.Helpers;
+using FoodLabeling.Application.Options;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using Volo.Abp;
+using Volo.Abp.Application.Services;
+
+namespace FoodLabeling.Application.Services;
+
+///
+/// App 版本检查与 APK 下载(对齐锁控面板;供手动「检查更新」)。
+///
+[AllowAnonymous]
+public class AppUpdateAppService : ApplicationService, IAppUpdateAppService
+{
+ private readonly FoodLabelingAppUpdateOptions _options;
+ private readonly IHttpContextAccessor _httpContextAccessor;
+ private readonly ILogger _logger;
+
+ public AppUpdateAppService(
+ IOptions options,
+ IHttpContextAccessor httpContextAccessor,
+ ILogger logger)
+ {
+ _options = options.Value;
+ _httpContextAccessor = httpContextAccessor;
+ _logger = logger;
+ }
+
+ ///
+ /// 查询服务端最新 App 版本
+ ///
+ ///
+ /// 无需登录。前端用本地 versionCode 与返回的 versionCode 比较。
+ ///
+ /// 示例请求:
+ /// ```json
+ /// GET /api/app/update?versionCode=106
+ /// ```
+ ///
+ /// 参数说明:
+ /// - versionCode: 可选,当前 App 本地整型版本号;传入时出参带 hasUpdate
+ ///
+ /// 当前 App 本地 versionCode
+ /// 最新版本信息与 APK 地址
+ /// 成功
+ /// 更新未启用
+ /// 服务器错误
+ [HttpGet]
+ [Route("/api/app/update")]
+ public Task GetInfoAsync([FromQuery] int? versionCode)
+ {
+ EnsureEnabled();
+ var apk = AppUpdatePathHelper.ResolveApk(_options);
+ var ready = apk is { Exists: true, Length: > 0 };
+ if (!ready)
+ {
+ _logger.LogWarning(
+ "App 更新 APK 未就绪,配置路径={Configured},已解析={Resolved},user.dir={UserDir}",
+ _options.ApkPath,
+ apk?.FullName,
+ Environment.CurrentDirectory);
+ }
+
+ var (remoteCode, remoteName) = AppUpdateVersionResolver.Resolve(apk, _options);
+ bool? hasUpdate = null;
+ if (versionCode.HasValue)
+ {
+ hasUpdate = ready && remoteCode > versionCode.Value;
+ }
+
+ return Task.FromResult(new AppUpdateDto
+ {
+ PackageName = _options.PackageName ?? string.Empty,
+ VersionCode = remoteCode,
+ VersionName = remoteName,
+ ForceUpdate = _options.ForceUpdate,
+ Changelog = _options.Changelog ?? string.Empty,
+ ApkReady = ready,
+ ApkResolvedPath = apk?.FullName,
+ ApkUrl = BuildApkUrl(),
+ HasUpdate = hasUpdate
+ });
+ }
+
+ ///
+ /// 下载最新 APK(二进制,不走 JSON 包装)
+ ///
+ /// 无需登录。Content-Type 为 application/vnd.android.package-archive。
+ /// APK 文件流
+ /// 成功返回文件
+ /// 更新未启用或文件不存在
+ /// 服务器错误
+ [HttpGet]
+ [Route("/api/app/update/apk")]
+ public IActionResult DownloadApk()
+ {
+ EnsureEnabled();
+ var apk = AppUpdatePathHelper.ResolveApk(_options);
+ if (apk is not { Exists: true, Length: > 0 })
+ {
+ throw new UserFriendlyException(
+ "APK 文件不存在,请放到: " + _options.ApkPath
+ + "(当前工作目录=" + Environment.CurrentDirectory + ")");
+ }
+
+ var (_, remoteName) = AppUpdateVersionResolver.Resolve(apk, _options);
+ var downloadName = "food-labeling-" + (string.IsNullOrWhiteSpace(remoteName) ? "app" : remoteName) + ".apk";
+ return new PhysicalFileResult(apk.FullName, "application/vnd.android.package-archive")
+ {
+ FileDownloadName = downloadName
+ };
+ }
+
+ private void EnsureEnabled()
+ {
+ if (!_options.Enabled)
+ {
+ throw new UserFriendlyException("App 更新未启用");
+ }
+ }
+
+ private string BuildApkUrl()
+ {
+ var request = _httpContextAccessor.HttpContext?.Request;
+ if (request is null)
+ {
+ return "/api/app/update/apk";
+ }
+
+ return $"{request.Scheme}://{request.Host}{request.PathBase}/api/app/update/apk";
+ }
+}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json b/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
index b316e9c..4a06755 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
@@ -128,6 +128,15 @@
},
"FoodLabeling": {
+ "AppUpdate": {
+ "Enabled": true,
+ "PackageName": "com.3flabeling.usapp",
+ "VersionCode": 108,
+ "VersionName": "1.0.8",
+ "ForceUpdate": false,
+ "Changelog": "",
+ "ApkPath": "/www/wwwroot/FoodLabelingManagementTeUsTest/wwwroot/app-update/app-release.apk"
+ },
"BatchImport": {
"TemplateDirectory": "/www/wwwroot/FoodLabelingManagementUs/batchImportOfFiles",
"LocationTemplateFileName": "Location-Manager-批量导入模板.xlsx",
diff --git a/美国版/scripts/泰鄂测试版部署.ps1 b/美国版/scripts/泰鄂测试版部署.ps1
index 9511a5f..dd38222 100644
--- a/美国版/scripts/泰鄂测试版部署.ps1
+++ b/美国版/scripts/泰鄂测试版部署.ps1
@@ -1,4 +1,4 @@
-#Requires -Version 5.1
+#Requires -Version 5.1
<#
.SYNOPSIS
食品标签泰鄂测试版 API 一键部署
diff --git a/美国版/scripts/泰鄂美国测试版部署.ps1 b/美国版/scripts/泰鄂美国测试版部署.ps1
index 6852799..48484f2 100644
--- a/美国版/scripts/泰鄂美国测试版部署.ps1
+++ b/美国版/scripts/泰鄂美国测试版部署.ps1
@@ -1,9 +1,14 @@
#Requires -Version 5.1
<#
.SYNOPSIS
- 泰鄂美国测试版 API 一键部署
+ Te US test API deploy
.DESCRIPTION
- 发布 Yi.Abp.Web,上传到 47.253.11.59,重启 Kestrel 19004,健康检查 https://flusapi-teustest.3flabeling.com
+ Publish Yi.Abp.Web to 47.253.11.59, restart Kestrel 19004.
+ https://flusapi-teustest.3flabeling.com
+ Script only rewrites ApkPath to wwwroot/app-update and keeps uploaded APK.
+ VersionCode is NOT auto-incremented. Edit manually:
+ 美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
+ FoodLabeling.AppUpdate.VersionCode / VersionName / Changelog / ForceUpdate
#>
param(
[switch]$SkipBuild
@@ -34,17 +39,17 @@ $PublishDir = Join-Path $RepoRoot "美国版\Food Labeling Management Code\Yi.Ab
Initialize-DeploySsh
$SshOpts = $global:SshOpts
-Write-Host "== 泰鄂美国测试版部署 ==" -ForegroundColor Cyan
-Write-Host "目标: $HostName $RemoteDir"
-Write-Host "域名: $HealthUrl"
-Write-Host "数据库: $TestDbName @ $DbHost"
+Write-Host "== Te US test deploy ==" -ForegroundColor Cyan
+Write-Host "target: $HostName $RemoteDir"
+Write-Host "url: $HealthUrl"
+Write-Host "db: $TestDbName @ $DbHost"
if (-not $SkipBuild) {
- if (-not (Test-Path $WebCsproj)) { throw "找不到工程: $WebCsproj" }
- Write-Host "== 发布 Yi.Abp.Web ==" -ForegroundColor Cyan
+ if (-not (Test-Path $WebCsproj)) { throw "csproj not found: $WebCsproj" }
+ Write-Host "== dotnet publish ==" -ForegroundColor Cyan
if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force }
& dotnet publish $WebCsproj -c Release -o $PublishDir --nologo
- if ($LASTEXITCODE -ne 0) { throw "dotnet publish 失败" }
+ if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed" }
$appsettings = Join-Path $PublishDir "appsettings.json"
if (Test-Path $appsettings) {
@@ -55,44 +60,53 @@ if (-not $SkipBuild) {
$json = [regex]::Replace($json, 'uid=[^;]+', "uid=$DbUser")
$json = [regex]::Replace($json, 'pwd=[^;]+', "pwd=$DbPassword")
$json = [regex]::Replace($json, 'database=antis-foodlabeling-[^;]+', "database=$TestDbName")
+ $apkPath = "$RemoteDir/wwwroot/app-update/app-release.apk"
+ if ($json -notmatch '"AppUpdate"') {
+ throw "appsettings.json missing FoodLabeling:AppUpdate"
+ }
+ $json = [regex]::Replace($json, '"ApkPath"\s*:\s*"[^"]*"', '"ApkPath": "' + $apkPath + '"')
+ Write-Host "AppUpdate.ApkPath => $apkPath (VersionCode unchanged)"
Set-Content -Path $appsettings -Value $json -Encoding UTF8
}
}
if (-not (Test-Path (Join-Path $PublishDir "Yi.Abp.Web.dll"))) {
- throw "发布目录缺少 Yi.Abp.Web.dll: $PublishDir"
+ throw "missing Yi.Abp.Web.dll: $PublishDir"
}
-Write-Host "== 停止远程进程 ==" -ForegroundColor Cyan
-Invoke-Remote @'
+Write-Host "== stop remote process ==" -ForegroundColor Cyan
+$stopRemote = @"
set -e
-if [ -f "/var/tmp/net_project/食品标签泰鄂美国测试版.pid" ]; then
- pid=$(cat "/var/tmp/net_project/食品标签泰鄂美国测试版.pid" || true)
- if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; fi
+PIDFILE=/var/tmp/net_project/食品标签泰鄂美国测试版.pid
+if test -f "`$PIDFILE"; then
+ pid=`$(cat "`$PIDFILE" || true)
+ if test -n "`$pid"; then kill `$pid 2>/dev/null || true; fi
fi
pkill -f "/www/wwwroot/FoodLabelingManagementTeUsTest/Yi.Abp.Web.dll" 2>/dev/null || true
sleep 1
echo stopped
-'@
+"@
+Invoke-Remote $stopRemote
-Write-Host "== 上传发布包 ==" -ForegroundColor Cyan
+Write-Host "== upload publish package ==" -ForegroundColor Cyan
$tar = Join-Path $env:TEMP "flus-teustest-publish.tgz"
if (Test-Path $tar) { Remove-Item $tar -Force }
Push-Location $PublishDir
try {
& tar -czf $tar --exclude=logs --exclude=startup.log *
- if ($LASTEXITCODE -ne 0) { throw "打包失败" }
+ if ($LASTEXITCODE -ne 0) { throw "tar failed" }
} finally {
Pop-Location
}
& scp @SshOpts $tar "${UserName}@${HostName}:/tmp/flus-teustest-publish.tgz"
-if ($LASTEXITCODE -ne 0) { throw "scp 失败" }
+if ($LASTEXITCODE -ne 0) { throw "scp failed" }
-Invoke-Remote @"
+$uploadRemote = @"
set -e
mkdir -p '$RemoteDir'
cd '$RemoteDir'
+test -d wwwroot/app-update && mv wwwroot/app-update /tmp/teustest-app-update-keep || true
for x in *; do
case "`$x" in
logs|*.log) ;;
@@ -101,23 +115,29 @@ for x in *; do
done
tar --overwrite -xzf /tmp/flus-teustest-publish.tgz -C '$RemoteDir'
rm -f /tmp/flus-teustest-publish.tgz
+mkdir -p '$RemoteDir/wwwroot/app-update'
+test -d /tmp/teustest-app-update-keep && cp -a /tmp/teustest-app-update-keep/. '$RemoteDir/wwwroot/app-update/' || true
+rm -rf /tmp/teustest-app-update-keep
chmod -R a+rX '$RemoteDir'
ls -l '$RemoteDir/Yi.Abp.Web.dll'
+ls -l '$RemoteDir/wwwroot/app-update' || true
echo uploaded_to=$RemoteDir
"@
+Invoke-Remote $uploadRemote
-Write-Host "== 登记宝塔 Net 项目 ==" -ForegroundColor Cyan
+Write-Host "== register BT net project ==" -ForegroundColor Cyan
$btPyLocal = Join-Path $ScriptDir "bt-register-net-project.py"
& scp @SshOpts $btPyLocal "${UserName}@${HostName}:/tmp/bt-register-net-project.py"
-if ($LASTEXITCODE -ne 0) { throw "上传宝塔登记脚本失败" }
-Invoke-Remote @"
+if ($LASTEXITCODE -ne 0) { throw "upload bt python failed" }
+$btRemote = @"
set -e
sed -i 's/\r`$//' /tmp/bt-register-net-project.py
python3 /tmp/bt-register-net-project.py name='$BtName' path='$RemoteDir' port='19004' ps='$BtName' domain='$BtDomain' cmd='$BtCmd' run_user='root' dotnet_version='8.0.100'
"@
+Invoke-Remote $btRemote
-Write-Host "== 启动 API ==" -ForegroundColor Cyan
-Invoke-Remote -AllowFail @"
+Write-Host "== start API ==" -ForegroundColor Cyan
+$startRemote = @"
mkdir -p /www/wwwlogs/net /var/tmp/net_project
cd '$RemoteDir'
nohup $Dotnet '$AppDll' --urls=$ListenUrl >> /www/wwwlogs/net/食品标签泰鄂美国测试版.log 2>&1 &
@@ -127,24 +147,47 @@ ss -lntp | grep 19004 || true
curl -s -o /dev/null -w 'local=%{http_code}\n' --max-time 15 http://127.0.0.1:19004/swagger/index.html || true
tail -n 20 /www/wwwlogs/net/食品标签泰鄂美国测试版.log || true
"@
+Invoke-Remote -AllowFail $startRemote
-Write-Host "== 健康检查 ==" -ForegroundColor Cyan
+Write-Host "== health check ==" -ForegroundColor Cyan
$ok = $false
for ($i = 1; $i -le 8; $i++) {
try {
$resp = Invoke-WebRequest -Uri $HealthUrl -UseBasicParsing -TimeoutSec 15
if ($resp.StatusCode -eq 200) {
- Write-Host "访问成功: $HealthUrl HTTP $($resp.StatusCode)" -ForegroundColor Green
+ Write-Host "OK: $HealthUrl HTTP $($resp.StatusCode)" -ForegroundColor Green
$ok = $true
break
}
} catch {
- Write-Host "等待服务就绪 ($i/8)..."
+ Write-Host "wait ($i/8)..."
Start-Sleep -Seconds 3
}
}
-if (-not $ok) { throw "部署后健康检查失败: $HealthUrl" }
-Write-Host "完成。API: https://flusapi-teustest.3flabeling.com" -ForegroundColor Green
+if (-not $ok) { throw "health check failed: $HealthUrl" }
+
+$updateUrl = "https://flusapi-teustest.3flabeling.com/api/app/update"
+Write-Host "== current App version ==" -ForegroundColor Cyan
+try {
+ $updateResp = Invoke-WebRequest -Uri $updateUrl -UseBasicParsing -TimeoutSec 20
+ $updateJson = $updateResp.Content | ConvertFrom-Json
+ $data = $updateJson.data
+ if (-not $data) { $data = $updateJson }
+ $code = $data.versionCode
+ $name = $data.versionName
+ $ready = $data.apkReady
+ Write-Host ("VERSION_CODE={0}" -f $code) -ForegroundColor Green
+ Write-Host ("VERSION_NAME={0}" -f $name) -ForegroundColor Green
+ Write-Host ("APK_READY={0}" -f $ready)
+ if ($data.apkResolvedPath) {
+ Write-Host ("APK_PATH={0}" -f $data.apkResolvedPath)
+ }
+ Write-Host "check: GET $updateUrl"
+} catch {
+ Write-Host "failed to read /api/app/update: $($_.Exception.Message)" -ForegroundColor Yellow
+}
+
+Write-Host "done. API: https://flusapi-teustest.3flabeling.com" -ForegroundColor Green
Write-Host "Swagger: $HealthUrl"
-Write-Host "登录: POST https://flusapi-teustest.3flabeling.com/api/app/account/login"
+Write-Host "login: POST https://flusapi-teustest.3flabeling.com/api/app/account/login"
diff --git a/项目相关文档/seed_host_platform_menus(1).sql b/项目相关文档/seed_host_platform_menus(1).sql
new file mode 100644
index 0000000..4c78a8e
--- /dev/null
+++ b/项目相关文档/seed_host_platform_menus(1).sql
@@ -0,0 +1,100 @@
+-- 泰额版平台级菜单:清空 antis-foodlabeling-host.menu 后按前端路由表重录
+-- 使用稳定 Id(f001*),保证 rolemenu 等引用不失效
+-- MenuSource=0(Ruoyi),平台目录 MenuType=0,页面 MenuType=1
+
+SET NAMES utf8mb4;
+START TRANSACTION;
+
+DELETE FROM menu;
+
+INSERT INTO menu (
+ Id, IsDeleted, CreationTime, CreatorId, LastModifierId, LastModificationTime,
+ OrderNum, State, MenuName, RouterName, MenuType, PermissionCode, ParentId,
+ MenuIcon, Router, IsLink, IsCache, IsShow, Remark, Component, MenuSource, Query, ConcurrencyStamp
+) VALUES
+-- 首页概览
+('f0010001-0001-4000-8000-000000000001', 0, NOW(), NULL, NULL, NULL,
+ -1, 1, '首页概览', 'FoodLabelingDashboard', 1, 'menu.dashboard.analytics', '0',
+ 'lucide:layout-dashboard', '/analytics', 0, 0, 1, NULL, '/food-labeling/dashboard/index', 0, NULL, ''),
+
+-- 平台管理
+('f0010002-0001-4000-8000-000000000002', 0, NOW(), NULL, NULL, NULL,
+ 5, 1, '平台管理', 'FoodLabelingPlatform', 0, 'menu.platform', '0',
+ 'lucide:cloud-cog', '/platform', 0, 0, 1, NULL, NULL, 0, NULL, ''),
+('f0010003-0001-4000-8000-000000000003', 0, NOW(), NULL, NULL, NULL,
+ 6, 1, 'SAAS 公司', 'FoodLabelingPlatformTenants', 1, 'menu.platform.tenants', 'f0010002-0001-4000-8000-000000000002',
+ 'lucide:building', '/platform/tenants', 0, 0, 1, NULL, '/food-labeling/platform/tenants/index', 0, NULL, ''),
+('f0010037-0001-4000-8000-000000000037', 0, NOW(), NULL, NULL, NULL,
+ 7, 1, '二维码', 'FoodLabelingQrCodes', 1, 'menu.platform.qr-codes', 'f0010002-0001-4000-8000-000000000002',
+ 'lucide:qr-code', '/platform/qr-codes', 0, 0, 1, NULL, '/food-labeling/modules/qr-codes/index', 0, NULL, ''),
+
+-- 标签管理
+('f0010010-0001-4000-8000-000000000010', 0, NOW(), NULL, NULL, NULL,
+ 10, 1, '标签管理', 'FoodLabelingLabeling', 0, 'menu.labeling', '0',
+ 'lucide:tags', '/labeling', 0, 0, 1, NULL, NULL, 0, NULL, ''),
+('f0010011-0001-4000-8000-000000000011', 0, NOW(), NULL, NULL, NULL,
+ 11, 1, '标签', 'FoodLabelingLabels', 1, 'menu.labeling.labels', 'f0010010-0001-4000-8000-000000000010',
+ 'lucide:tag', '/labels', 0, 0, 1, NULL, '/food-labeling/labeling/labels/index', 0, NULL, ''),
+('f0010012-0001-4000-8000-000000000012', 0, NOW(), NULL, NULL, NULL,
+ 12, 1, '标签分类', 'FoodLabelingLabelCategories', 1, 'menu.labeling.categories', 'f0010010-0001-4000-8000-000000000010',
+ 'lucide:folder-tree', '/label-categories', 0, 0, 1, NULL, '/food-labeling/labeling/label-categories/index', 0, NULL, ''),
+('f0010013-0001-4000-8000-000000000013', 0, NOW(), NULL, NULL, NULL,
+ 13, 1, '标签类型', 'FoodLabelingLabelTypes', 1, 'menu.labeling.types', 'f0010010-0001-4000-8000-000000000010',
+ 'lucide:layers', '/label-types', 0, 0, 1, NULL, '/food-labeling/labeling/label-types/index', 0, NULL, ''),
+('f0010014-0001-4000-8000-000000000014', 0, NOW(), NULL, NULL, NULL,
+ 14, 1, '标签模板', 'FoodLabelingLabelTemplates', 1, 'menu.labeling.templates', 'f0010010-0001-4000-8000-000000000010',
+ 'lucide:layout-template', '/label-templates', 0, 0, 1, NULL, '/food-labeling/labeling/label-templates/index', 0, NULL, ''),
+('f0010015-0001-4000-8000-000000000015', 0, NOW(), NULL, NULL, NULL,
+ 15, 1, '多选选项集', 'FoodLabelingMultipleOptions', 1, 'menu.labeling.multiple-options', 'f0010010-0001-4000-8000-000000000010',
+ 'lucide:list-checks', '/multiple-options', 0, 0, 1, NULL, '/food-labeling/labeling/multiple-options/index', 0, NULL, ''),
+
+-- 原「业务模块」子项:提升为一级菜单(ParentId=0),不再保留「业务模块」目录
+('f0010021-0001-4000-8000-000000000021', 0, NOW(), NULL, NULL, NULL,
+ 15, 1, '培训', 'FoodLabelingTraining', 1, 'menu.modules.training', '0',
+ 'lucide:graduation-cap', '/training', 0, 0, 1, NULL, '/food-labeling/modules/training/index', 0, NULL, ''),
+('f0010022-0001-4000-8000-000000000022', 0, NOW(), NULL, NULL, NULL,
+ 16, 1, '告警', 'FoodLabelingAlerts', 1, 'menu.modules.alerts', '0',
+ 'lucide:bell', '/alerts', 0, 0, 1, NULL, '/food-labeling/modules/alerts/index', 0, NULL, ''),
+('f0010023-0001-4000-8000-000000000023', 0, NOW(), NULL, NULL, NULL,
+ 17, 1, '任务', 'FoodLabelingTasks', 1, 'menu.modules.tasks', '0',
+ 'lucide:list-todo', '/tasks', 0, 0, 1, NULL, '/food-labeling/modules/tasks/index', 0, NULL, ''),
+('f0010024-0001-4000-8000-000000000024', 0, NOW(), NULL, NULL, NULL,
+ 18, 1, '传感器', 'FoodLabelingSensors', 1, 'menu.modules.sensors', '0',
+ 'lucide:activity', '/sensors', 0, 0, 1, NULL, '/food-labeling/modules/sensors/index', 0, NULL, ''),
+('f0010025-0001-4000-8000-000000000025', 0, NOW(), NULL, NULL, NULL,
+ 19, 1, '食物浪费', 'FoodLabelingFoodWaste', 1, 'menu.modules.food-waste', '0',
+ 'lucide:apple', '/food-waste', 0, 0, 1, NULL, '/food-labeling/modules/food-waste/index', 0, NULL, ''),
+('f0010026-0001-4000-8000-000000000026', 0, NOW(), NULL, NULL, NULL,
+ 20, 1, '电子标签', 'FoodLabelingELabelModule', 1, 'menu.modules.e-label', '0',
+ 'lucide:file-digit', '/e-label-module', 0, 0, 1, NULL, '/food-labeling/modules/e-label/index', 0, NULL, ''),
+
+-- 管理
+('f0010030-0001-4000-8000-000000000030', 0, NOW(), NULL, NULL, NULL,
+ 30, 1, '管理', 'FoodLabelingManagement', 0, 'menu.management', '0',
+ 'lucide:building-2', '/management', 0, 0, 1, NULL, NULL, 0, NULL, ''),
+('f0010031-0001-4000-8000-000000000031', 0, NOW(), NULL, NULL, NULL,
+ 31, 1, '账户管理', 'FoodLabelingAccountManagement', 1, 'menu.management.account', 'f0010030-0001-4000-8000-000000000030',
+ 'lucide:users', '/account-management', 0, 0, 1, NULL, '/food-labeling/management/account-management/index', 0, NULL, ''),
+('f0010032-0001-4000-8000-000000000032', 0, NOW(), NULL, NULL, NULL,
+ 32, 1, '系统菜单', 'FoodLabelingSystemMenu', 1, 'menu.management.system-menu', 'f0010030-0001-4000-8000-000000000030',
+ 'lucide:menu-square', '/system-menu', 0, 0, 1, NULL, '/food-labeling/management/system-menu/index', 0, NULL, ''),
+('f0010033-0001-4000-8000-000000000033', 0, NOW(), NULL, NULL, NULL,
+ 33, 1, '菜单管理', 'FoodLabelingMenuManagement', 1, 'menu.management.menu', 'f0010030-0001-4000-8000-000000000030',
+ 'lucide:utensils', '/menu-management', 0, 0, 1, NULL, '/food-labeling/management/menu-management/index', 0, NULL, ''),
+('f0010034-0001-4000-8000-000000000034', 0, NOW(), NULL, NULL, NULL,
+ 34, 1, '设备', 'FoodLabelingDevices', 1, 'menu.management.devices', 'f0010030-0001-4000-8000-000000000030',
+ 'lucide:smartphone', '/devices', 0, 0, 1, NULL, '/food-labeling/modules/devices/index', 0, NULL, ''),
+('f0010035-0001-4000-8000-000000000035', 0, NOW(), NULL, NULL, NULL,
+ 35, 1, '报表', 'FoodLabelingReports', 1, 'menu.management.reports', 'f0010030-0001-4000-8000-000000000030',
+ 'lucide:file-bar-chart', '/reports', 0, 0, 1, NULL, '/food-labeling/management/reports/index', 0, NULL, ''),
+('f0010036-0001-4000-8000-000000000036', 0, NOW(), NULL, NULL, NULL,
+ 36, 1, '发票', 'FoodLabelingInvoices', 1, 'menu.management.invoices', 'f0010030-0001-4000-8000-000000000030',
+ 'lucide:receipt', '/invoices', 0, 0, 1, NULL, '/food-labeling/modules/invoices/index', 0, NULL, ''),
+('f0010038-0001-4000-8000-000000000038', 0, NOW(), NULL, NULL, NULL,
+ 37, 1, '支持', 'FoodLabelingSupport', 1, 'menu.management.support', 'f0010030-0001-4000-8000-000000000030',
+ 'lucide:life-buoy', '/support', 0, 0, 1, NULL, '/food-labeling/management/support/index', 0, NULL, ''),
+('f0010039-0001-4000-8000-000000000039', 0, NOW(), NULL, NULL, NULL,
+ 38, 1, 'API', 'FoodLabelingApi', 1, 'menu.management.api', 'f0010030-0001-4000-8000-000000000030',
+ 'lucide:code-2', '/api-settings', 0, 0, 1, NULL, '/food-labeling/modules/api/index', 0, NULL, '');
+
+COMMIT;
diff --git a/项目相关文档/二维码菜单改为平台级-说明(1).md b/项目相关文档/二维码菜单改为平台级-说明(1).md
new file mode 100644
index 0000000..6c0b795
--- /dev/null
+++ b/项目相关文档/二维码菜单改为平台级-说明(1).md
@@ -0,0 +1,80 @@
+# 二维码菜单改为平台级
+
+> 日期:2026-10-13
+> 说明:前端路由已挪到「平台管理」;**已有环境的 host / 租户库菜单需执行下方 SQL**(不自动改后端代码逻辑)。
+
+## 目标
+
+- **平台端**(图:平台管理):「二维码」挂在「平台管理」下,与「SAAS 公司」同级。
+- **企业端**(租户):「管理」下**不再**出现「二维码」。
+- 权限码改为 `menu.platform.qr-codes`(`IsPlatformOnlyMenu` 会按 `menu.platform*` 判定为仅平台,不可分配给公司)。
+
+## 前端(已改)
+
+- `Yi.Vben5.Vue3/.../router/routes/local.ts`
+ - 路径:`/platform/qr-codes`
+ - 父级:`FoodLabelingPlatform`(平台管理)
+
+## 种子脚本(已改,供重建 host 菜单)
+
+- `Yi.Abp.Net8/.../scripts/seed_host_platform_menus.sql`
+ - 二维码 `ParentId` → 平台管理目录
+ - `PermissionCode` → `menu.platform.qr-codes`
+ - `Router` → `/platform/qr-codes`
+
+## 已有库补丁 SQL(需运维执行)
+
+### 1)Host 库(如 `antis-foodlabeling-host`)
+
+```sql
+-- 二维码挪到「平台管理」下
+UPDATE menu
+SET
+ ParentId = 'f0010002-0001-4000-8000-000000000002',
+ PermissionCode = 'menu.platform.qr-codes',
+ Router = '/platform/qr-codes',
+ Component = '/food-labeling/modules/qr-codes/index',
+ OrderNum = 7,
+ IsShow = 1,
+ IsDeleted = 0
+WHERE Id = 'f0010037-0001-4000-8000-000000000037';
+```
+
+### 2)各租户库(企业端去掉二维码)
+
+对每个公司库执行其一即可:
+
+```sql
+-- 推荐:软删,企业端菜单不再展示
+UPDATE menu
+SET IsDeleted = 1, DeletionTime = NOW()
+WHERE Id = 'f0010037-0001-4000-8000-000000000037'
+ OR Router IN ('/qr-codes', '/platform/qr-codes')
+ OR PermissionCode IN ('menu.management.qr-codes', 'menu.platform.qr-codes');
+```
+
+或仅隐藏:
+
+```sql
+UPDATE menu SET IsShow = 0
+WHERE Id = 'f0010037-0001-4000-8000-000000000037'
+ OR Router IN ('/qr-codes', '/platform/qr-codes');
+```
+
+### 3)可选:权限目录兼容(后端 C#,若要用新 SaaS Key)
+
+文件:`FoodLabeling.Th.Application/MultiTenancy/ThSaasMenuPermissionCatalog.cs`
+在 `LegacyKeyToMenuId` 增加:
+
+```csharp
+["platform:qr-codes"] = "f0010037-0001-4000-8000-000000000037",
+```
+
+保留 `["management:qr-codes"] = ...` 兼容历史数据。
+(`menu.platform.qr-codes` 本身已会被 `IsPlatformOnlyMenu` 识别,可不改代码也能达到「不可分配给公司」。)
+
+## 验证
+
+1. 平台管理员登录 → 「平台管理」下可见「二维码」,打开 `/platform/qr-codes`。
+2. 企业管理员登录 → 「管理」下无「二维码」。
+3. 开通公司时的菜单树中不应再勾选到可分配的「二维码」(平台 only)。
diff --git a/项目相关文档/告警计时器后端改造方案(1).md b/项目相关文档/告警计时器后端改造方案(1).md
new file mode 100644
index 0000000..8a958fc
--- /dev/null
+++ b/项目相关文档/告警计时器后端改造方案(1).md
@@ -0,0 +1,285 @@
+# 告警计时器后端改造方案
+
+> 文档日期:2026-10-13
+> 适用范围:泰额版 `Yi.Abp.Net8` / `food-labeling-us`
+> 说明:本文档为**后端改造规格**,供后端单独实现;前端(平台告警页、标签模板「到期提醒」)按本文约定对接。
+
+---
+
+## 1. 已确认业务规则
+
+| # | 规则 |
+|---|---|
+| 1 | **过期时刻 `ExpiresAt`**:从标签打印数据解析(与 Print Log Expiration 同源,`ReportsPrintLogExpiryHelper.TryResolveExpiryDateTime`)。**告警模板的 `DateTimeFormat` 仅用于展示**该过期时刻(出参 `formattedExpiresAt`)。 |
+| 2 | **无「到期提醒」控件的旧模板**:打印成功后**不写**计时器。 |
+| 3 | **到期弹窗文案**:`亲爱的{userName},您的{labelName}标签已过期,请及时处理`。`{userName}` 由 **App 当前登录人**替换;后端可返回带占位符的 `expiredMessageTemplate`。 |
+| 4 | **平台**可查权限范围内**所有门店**计时器;**App**仅查**当前门店**。 |
+
+---
+
+## 2. 现状 vs 目标
+
+| 项 | 现状 | 目标 |
+|---|---|---|
+| 告警模板 | 无 | 表 `fl_alert_template` + CRUD + options |
+| 到期提醒控件 | 前端可选模板;写库逻辑需后端识别 | 打印时检测 Expiration Alert + 有效 `alertTemplateId` 才写计时器 |
+| 写计时器 | 有过期时刻即可能写入 | 必须:有到期提醒控件 + 启用模板 + 能解析过期时刻 |
+| 平台 list | 强制 `locationId` | `locationId` 可选;空 = 权限内全店 |
+| App list | 本店 | 保持本店 |
+| 展示格式 | 无 | 按模板 `DateTimeFormat` 输出 `formattedExpiresAt` |
+| 弹窗文案 | 无标准字段 | 出参 `expiredMessageTemplate` |
+
+---
+
+## 3. 数据库
+
+### 3.1 新表 `fl_alert_template`
+
+```sql
+CREATE TABLE IF NOT EXISTS `fl_alert_template` (
+ `Id` varchar(36) NOT NULL COMMENT '主键(YitId)',
+ `TemplateName` varchar(200) NOT NULL COMMENT '模板名称',
+ `DateTimeFormat` varchar(100) NOT NULL COMMENT '日期时间格式(如 MM/dd/yyyy h:mm tt)',
+ `State` tinyint(1) NOT NULL DEFAULT 1 COMMENT '启用状态',
+ `IsDeleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '软删',
+ `DeletionTime` datetime DEFAULT NULL,
+ `CreatedBy` varchar(36) DEFAULT NULL,
+ `CreationTime` datetime NOT NULL,
+ `LastModificationTime` datetime DEFAULT NULL,
+ PRIMARY KEY (`Id`),
+ KEY `idx_fl_alert_template_state` (`State`),
+ KEY `idx_fl_alert_template_name` (`TemplateName`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='告警日期时间格式模板';
+```
+
+**DateTimeFormat 建议预设(前端下拉,后端原样存储字符串):**
+
+- `MM/dd/yyyy h:mm tt`
+- `yyyy-MM-dd HH:mm`
+- `dd/MM/yyyy HH:mm`
+
+### 3.2 扩展 `fl_label_alert_timer`
+
+在现有表上增加:
+
+| 列 | 类型 | 说明 |
+|---|---|---|
+| `AlertTemplateId` | varchar(36) NULL | 告警模板 Id |
+| `AlertTemplateName` | varchar(200) NULL | 名称冗余 |
+| `DateTimeFormat` | varchar(100) NULL | 格式冗余(列表展示不依赖再查模板) |
+| `PrintedByUserId` | varchar(36) NULL | 打印人 Id |
+| `PrintedByUserName` | varchar(200) NULL | 打印人姓名 |
+| `LocationName` | varchar(200) NULL | 门店名冗余 |
+
+> 保留:`BatchId` 唯一、软删、`ExpiresAt`、`DurationSeconds`、`Title`、`Subtitle` 等。
+
+租户迁移:新 SQL 挂到 `FoodLabelingTenantMigrationScriptNames`;已有租户执行一次扩展脚本。
+
+**ID 规范:** 所有新实体主键使用 `YitIdHelper.NextId().ToString()`,禁止 `Guid.NewGuid()`。
+
+---
+
+## 4. 接口设计
+
+统一包装:`{ "code": 200, "data": {}, "message": "" }`
+鉴权:`Authorization: Bearer …`
+分页约定(本模块):`skipCount` = **页码从 1 起**(与现有 label-alert-timer 一致)。
+
+### 4.1 告警模板 `/api/app/alert-template`
+
+| 方法 | 路径 | 说明 |
+|---|---|---|
+| POST | `/api/app/alert-template/list` | 分页列表 |
+| GET | `/api/app/alert-template/{id}` | 详情 |
+| POST | `/api/app/alert-template` | 新增 |
+| PUT | `/api/app/alert-template/{id}` | 编辑 |
+| DELETE | `/api/app/alert-template/{id}` | 软删 |
+| GET | `/api/app/alert-template/options` | 启用项下拉(标签模板编辑器用) |
+
+#### list 入参
+
+```json
+{
+ "keyword": "冷藏",
+ "state": true,
+ "skipCount": 1,
+ "maxResultCount": 20
+}
+```
+
+#### 新增/编辑 body
+
+```json
+{
+ "templateName": "US 过期展示",
+ "dateTimeFormat": "MM/dd/yyyy h:mm tt",
+ "state": true
+}
+```
+
+#### options 出参(data 数组元素)
+
+```json
+{
+ "id": "…",
+ "templateName": "US 过期展示",
+ "dateTimeFormat": "MM/dd/yyyy h:mm tt"
+}
+```
+
+仅返回 `State=true` 且未删除。
+
+---
+
+### 4.2 计时器 `/api/app/label-alert-timer`(改造现有)
+
+| 方法 | 路径 | 说明 |
+|---|---|---|
+| POST | `/api/app/label-alert-timer/list` | **平台**:`locationId` 可选 |
+| POST | `/api/app/label-alert-timer/app-list` | **App**:强制当前门店 |
+| POST | `/api/app/label-alert-timer/check-expired` | 状态查询;补弹窗字段 |
+| DELETE | `/api/app/label-alert-timer/{id}` | 软删(保持门店权限校验) |
+
+#### 平台 list
+
+```json
+{
+ "locationId": "",
+ "skipCount": 1,
+ "maxResultCount": 20,
+ "dateDay": "2026-10-13"
+}
+```
+
+- `locationId` **空或省略**:当前用户权限范围内全部门店(参考 `ReportsLocationScopeHelper` / Print Log 全店范围)。
+- `locationId` **有值**:仅该门店,并校验可访问。
+- `dateDay`:按 `PrintedAt` 自然日筛选(可选)。
+
+#### App app-list
+
+- 必须落到**一个**门店:入参 `locationId` 或已选门店缓存;否则友好错误。
+- **禁止**全店查询。
+
+#### 列表项建议出参(data.items[])
+
+| 字段 | 说明 |
+|---|---|
+| id / batchId / printTaskId / labelId / labelCode | 原有 |
+| labelName | 标签名称 |
+| title / subtitle | 原有展示标题 |
+| totalTime / remainingTime | 秒 |
+| status | `running` \| `expired` |
+| expiresAt | 过期时刻 |
+| **formattedExpiresAt** | 按 `DateTimeFormat` 格式化后的字符串 |
+| printedAt | 打印时刻 |
+| locationId / **locationName** | 门店 |
+| productName | 产品名 |
+| **alertTemplateId / alertTemplateName / dateTimeFormat** | 模板冗余 |
+| printedByUserId / printedByUserName | 打印人 |
+| **expiredMessageTemplate** | 固定:`亲爱的{userName},您的{labelName}标签已过期,请及时处理` |
+
+App 弹窗:用当前登录人姓名替换 `{userName}`,用该项 `labelName` 替换 `{labelName}`。
+
+#### check-expired
+
+入参至少提供 `timerId` / `batchId` / `printTaskId` 之一。
+出参增加:`labelName`、`formattedExpiresAt`、`expiredMessageTemplate`(及原有 isExpired、remainingSeconds 等)。
+**注意:** 本接口仅展示倒计时,**不得**用于拦截打印。
+
+---
+
+## 5. 打印写计时器逻辑
+
+入口:打印成功后(现有 `UsAppLabelingAppService` 等调用点)→ `LabelAlertTimerWriteHelper.TryCreateFromPrintBatchAsync`。
+
+### 5.1 写入条件(全部满足才插入)
+
+1. `BatchId` 有效;该 `BatchId` **尚无**计时器记录(含软删也不再插,避免唯一索引冲突)。
+2. 从打印任务 `RenderTemplateJson`(或等价快照)的 `elements` 中找到 **Expiration Alert / 到期提醒** 控件。
+ 识别建议(与前端一致):
+ - `typeAdd` 含 `expiration alert` / `expirationalert`,或
+ - `elementName` 含 `expiration alert` / `到期提醒`
+3. 该元素 `config.alertTemplateId` 非空,且对应 `fl_alert_template` 存在、`!IsDeleted`、`State=true`。
+4. `ReportsPrintLogExpiryHelper.TryResolveExpiryDateTime(printInputJson, renderTemplateJson, …)` 成功得到 `ExpiresAt`。
+
+任一不满足 → **直接 return,不写计时器**(含:旧模板无到期提醒控件)。
+
+### 5.2 写入字段
+
+- 原有:BatchId、PrintTaskId、Label*、Product*、LocationId、PrintedAt、BaseTime、ExpiresAt、DurationSeconds、Title、Subtitle…
+- 新增:AlertTemplateId/Name、DateTimeFormat(从模板拷贝)、PrintedByUserId/Name(打印成功时传入当前用户)、LocationName(可查门店表冗余)
+
+### 5.3 标签模板前端约定(供后端解析)
+
+到期提醒元素写入 JSON 示例:
+
+```json
+{
+ "type": "TEXT_STATIC",
+ "typeAdd": "label_Expiration Alert",
+ "elementName": "Expiration Alert",
+ "config": {
+ "alertTemplateId": "模板Id",
+ "alertTemplateName": "US 过期展示",
+ "dateTimeFormat": "MM/dd/yyyy h:mm tt",
+ "text": "…"
+ }
+}
+```
+
+---
+
+## 6. 平台 / App 权限差异
+
+| | 平台 `list` | App `app-list` |
+|---|---|---|
+| 门店范围 | 可选;空=权限内全店 | 仅当前门店 |
+| 用途 | 管理端告警页「计时器」Tab(时钟卡片) | App 告警页 + 到期弹窗 |
+| 删除 | 校验该计时器所属门店权限 | 同左 |
+
+---
+
+## 7. 前端已按本文对接的能力(供联调)
+
+> 以下为平台/编辑器侧约定;**不要求本文作者改后端代码**,仅便于联调对照。
+
+1. 告警页两个 Tab:告警模板 CRUD;计时器全店时钟卡片(`locationId` 可空)。
+2. 标签模板编辑器开放「到期提醒」,属性绑定 `alert-template/options`。
+3. 弹窗文案占位:`{userName}` / `{labelName}`。
+
+若后端尚未实现上述接口,前端会调不通,需按本文实现后再联调。
+
+---
+
+## 8. 实现检查清单(后端)
+
+- [ ] `fl_alert_template` 建表 + 租户迁移
+- [ ] `fl_label_alert_timer` 扩展列 + 迁移
+- [ ] AlertTemplate AppService:list / get / create / update / delete / options
+- [ ] LabelAlertTimerWriteHelper:按 §5 条件写入;旧模板不写
+- [ ] 平台 list:`locationId` 可选 + 全店范围
+- [ ] App list:强制本店
+- [ ] list / check-expired:`formattedExpiresAt`、`expiredMessageTemplate`、`labelName`、`locationName` 等
+- [ ] 打印入口传入打印人 Id/Name
+- [ ] XML 注释、枚举、WhereIF、YitId 规范
+- [ ] 接口自测 + 查库验证:有/无到期提醒控件各打一次,确认写库与否
+
+---
+
+## 9. 相关现有代码位置(实现时参考)
+
+| 说明 | 路径(泰额版 Yi.Abp.Net8) |
+|---|---|
+| 写计时器 Helper | `module/food-labeling-us/.../Helpers/LabelAlertTimerWriteHelper.cs` |
+| 计时器 Service | `.../Services/LabelAlertTimerAppService.cs` |
+| 过期时刻解析 | `.../Helpers/ReportsPrintLogExpiryHelper.cs` |
+| 计时器表脚本 | `.../scripts/fl_label_alert_timer.sql` |
+| 打印成功调用点 | `.../Services/UsAppLabelingAppService.cs` |
+
+---
+
+## 10. 修订记录
+
+| 日期 | 说明 |
+|---|---|
+| 2026-10-13 | 初版:按产品确认(格式展示、无控件不写、弹窗当前登录人、平台全店)整理后端规格 |