桌面端新增密炼计划获取

This commit is contained in:
2026-06-17 17:52:31 +08:00
parent 816af5df6e
commit 372dc10be2
23 changed files with 1335 additions and 92 deletions

View File

@@ -0,0 +1,11 @@
using Prism.Events;
namespace YY.Admin.Core.Events;
public class MixingProductionPlanChangedPayload
{
public string Action { get; set; } = string.Empty;
public string? MixingProductionPlanId { get; set; }
}
public class MixingProductionPlanChangedEvent : PubSubEvent<MixingProductionPlanChangedPayload> { }

View File

@@ -0,0 +1,28 @@
using YY.Admin.Core.Entity;
namespace YY.Admin.Core.Services;
/// <summary>密炼生产计划MES 只读同步)</summary>
public interface IMixingProductionPlanService
{
Task<MixingProductionPlanPageResult> PageAsync(
int pageNo, int pageSize,
DateTime? planDateFrom = null,
DateTime? planDateTo = null,
string? machineName = null,
int? shiftFlag = null,
string? planNo = null,
string? materialName = null,
CancellationToken ct = default);
Task<List<MesXslMixingProductionPlan>> GetAllCachedAsync(CancellationToken ct = default);
/// <returns>本地缓存是否有变更(有差异才写入)</returns>
Task<bool> SyncFromRemoteAsync(CancellationToken ct = default);
}
public record MixingProductionPlanPageResult(
List<MesXslMixingProductionPlan> Records,
long Total,
int PageNo,
int PageSize);

View File

@@ -14,7 +14,8 @@ public interface IRubberQuickTestStdService
Task<MesXslRubberQuickTestStd?> GetByIdAsync(string id, CancellationToken ct = default);
Task SyncFromRemoteAsync(CancellationToken ct = default);
/// <returns>本地缓存是否有变更(有差异才写入)</returns>
Task<bool> SyncFromRemoteAsync(CancellationToken ct = default);
}
public record RubberQuickTestStdPageResult(

View File

@@ -1,6 +1,6 @@
namespace YY.Admin.Core.Entity;
/// <summary>密炼生产计划维护(桌面端快检记录筛选用</summary>
/// <summary>密炼生产计划维护(MES 数据源,桌面端只读同步</summary>
public class MesXslMixingProductionPlan
{
public string? Id { get; set; }
@@ -8,21 +8,43 @@ public class MesXslMixingProductionPlan
public string? MachineId { get; set; }
public string? MachineName { get; set; }
public string? MorningPlanId { get; set; }
public string? MorningPlanType { get; set; }
public string? MorningOrderNo { get; set; }
public DateTime? MorningOrderDate { get; set; }
public string? MorningFormulaName { get; set; }
/// <summary>班次标识1早班 2中班 3晚班</summary>
public int? ShiftFlag { get; set; }
public string? NoonPlanId { get; set; }
public string? NoonPlanType { get; set; }
public string? NoonOrderNo { get; set; }
public DateTime? NoonOrderDate { get; set; }
public string? NoonFormulaName { get; set; }
/// <summary>计划日期(密炼日期)</summary>
public DateTime? PlanDate { get; set; }
public string? NightPlanId { get; set; }
public string? NightPlanType { get; set; }
public string? NightOrderNo { get; set; }
public DateTime? NightOrderDate { get; set; }
public string? NightFormulaName { get; set; }
public string? PlanNo { get; set; }
public string? PlanId { get; set; }
public string? PlanType { get; set; }
public string? SourceOrderId { get; set; }
public string? MaterialId { get; set; }
public string? MaterialName { get; set; }
public string? OrderNo { get; set; }
public DateTime? OrderDate { get; set; }
public string? FormulaName { get; set; }
public double? PlanWeight { get; set; }
public int? PlannedCarCount { get; set; }
public int? ScheduledCarCount { get; set; }
public int? FinishedCarCount { get; set; }
/// <summary>计划数量MES plan_count</summary>
public int? PlanCount { get; set; }
public string? Remark { get; set; }
public int? TenantId { get; set; }
public string? SysOrgCode { get; set; }
public string? CreateBy { get; set; }
public DateTime? CreateTime { get; set; }
public string? UpdateBy { get; set; }
public DateTime? UpdateTime { get; set; }
public int? DelFlag { get; set; }
public string ShiftFlagText => ShiftFlag switch
{
1 => "早班",
2 => "中班",
3 => "晚班",
_ => ShiftFlag?.ToString() ?? string.Empty
};
public string PlanDateText => PlanDate?.ToString("yyyy-MM-dd") ?? string.Empty;
}

View File

@@ -0,0 +1,66 @@
namespace YY.Admin.Core.Helper;
/// <summary>MES 只读数据:远端列表与本地缓存按 Id 对比合并</summary>
public static class MesReadOnlyCacheMergeHelper
{
public sealed record MergeResult(int Added, int Updated, int Removed)
{
public bool HasChanges => Added > 0 || Updated > 0 || Removed > 0;
}
/// <summary>
/// 对比远端与本地,返回合并后的列表及变更统计。
/// 内容相同则保留本地副本;<paramref name="mergeUpdated"/> 可定制变更行的合并策略(如保留本地子表)。
/// </summary>
public static (List<T> Merged, MergeResult Stats) Merge<T>(
IReadOnlyList<T> local,
IReadOnlyList<T> remote,
Func<T, string?> getId,
Func<T, T, bool> isContentEqual,
Func<T, T> clone,
Func<T, T, T>? mergeUpdated = null)
{
var localById = new Dictionary<string, T>(StringComparer.OrdinalIgnoreCase);
foreach (var item in local)
{
var id = getId(item);
if (!string.IsNullOrWhiteSpace(id))
localById[id] = item;
}
var remoteIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var merged = new List<T>(remote.Count);
int added = 0, updated = 0;
foreach (var remoteItem in remote)
{
var id = getId(remoteItem);
if (string.IsNullOrWhiteSpace(id))
{
merged.Add(clone(remoteItem));
added++;
continue;
}
remoteIds.Add(id);
if (!localById.TryGetValue(id, out var localItem))
{
merged.Add(clone(remoteItem));
added++;
}
else if (!isContentEqual(localItem, remoteItem))
{
merged.Add(mergeUpdated != null ? mergeUpdated(localItem, remoteItem) : clone(remoteItem));
updated++;
}
else
{
merged.Add(clone(localItem));
}
}
int removed = localById.Keys.Count(id => !remoteIds.Contains(id));
return (merged, new MergeResult(added, updated, removed));
}
}

View File

@@ -52,6 +52,8 @@ public class SysMenuSeedData : ISqlSugarEntitySeedData<SysMenu>
new SysMenu{ Id=1300150011201, Pid=1300150000101, Title="快检记录", Path="/xslmes/rubberQuickTestOperation", Name="rubberQuickTestOperation", Component="RubberQuickTestOperationView", Icon="&#xe7de;", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=111 },
// 胶料快检实验标准(桌面端只读)
new SysMenu{ Id=1300150011301, Pid=1300150000101, Title="胶料快检实验标准", Path="/xslmes/mesXslRubberQuickTestStd", Name="mesXslRubberQuickTestStd", Component="RubberQuickTestStdListView", Icon="&#xe7ce;", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=112 },
// 密炼计划
new SysMenu{ Id=1300150011401, Pid=1300150000101, Title="密炼计划", Path="/xslmes/mesXslMixingProductionPlan", Name="mesXslMixingProductionPlan", Component="MixingProductionPlanListView", Icon="&#xe7ce;", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=113 },
#endregion

View File

@@ -34,6 +34,7 @@ public class SysTenantMenuSeedData : ISqlSugarEntitySeedData<SysTenantMenu>
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011101},
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011201},
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011301},
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011401},
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012101},
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012111},
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012121},