桌面端新增密炼计划获取

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

@@ -162,6 +162,11 @@ namespace YY.Admin.ViewModels.Control
["/xslmes/mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
["mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
// 已实现页面:密炼计划(只读)
["MixingProductionPlanListView"] = "MixingProductionPlanListView",
["/xslmes/mesXslMixingProductionPlan"] = "MixingProductionPlanListView",
["mesXslMixingProductionPlan"] = "MixingProductionPlanListView",
// 已实现页面:打印设置
["PrintSettingsView"] = "PrintSettingsView",
["/system/printSettings"] = "PrintSettingsView",

View File

@@ -0,0 +1,139 @@
using HandyControl.Controls;
using Prism.Events;
using System.Collections.ObjectModel;
using System.Diagnostics;
using YY.Admin.Core;
using YY.Admin.Core.Entity;
using YY.Admin.Core.Events;
using YY.Admin.Core.Helper;
using YY.Admin.Core.Services;
using YY.Admin.Services.Service;
namespace YY.Admin.ViewModels.MixingProductionPlan;
public class MixingProductionPlanListViewModel : BaseViewModel
{
private readonly IMixingProductionPlanService _planService;
private SubscriptionToken? _changedToken;
private ObservableCollection<MesXslMixingProductionPlan> _items = new();
public ObservableCollection<MesXslMixingProductionPlan> Items
{
get => _items;
set => SetProperty(ref _items, value);
}
private long _total;
public long Total { get => _total; set => SetProperty(ref _total, value); }
private int _pageNo = 1;
public int PageNo { get => _pageNo; set => SetProperty(ref _pageNo, value); }
private int _pageSize = 20;
public int PageSize { get => _pageSize; set => SetProperty(ref _pageSize, value); }
private DateTime? _filterPlanDateFrom;
public DateTime? FilterPlanDateFrom { get => _filterPlanDateFrom; set => SetProperty(ref _filterPlanDateFrom, value); }
private DateTime? _filterPlanDateTo;
public DateTime? FilterPlanDateTo { get => _filterPlanDateTo; set => SetProperty(ref _filterPlanDateTo, value); }
private string? _filterMachineName;
public string? FilterMachineName { get => _filterMachineName; set => SetProperty(ref _filterMachineName, value); }
private int? _filterShiftFlag;
public int? FilterShiftFlag { get => _filterShiftFlag; set => SetProperty(ref _filterShiftFlag, value); }
private string? _filterPlanNo;
public string? FilterPlanNo { get => _filterPlanNo; set => SetProperty(ref _filterPlanNo, value); }
private string? _filterMaterialName;
public string? FilterMaterialName { get => _filterMaterialName; set => SetProperty(ref _filterMaterialName, value); }
public ObservableCollection<KeyValuePair<string, int?>> ShiftOptions { get; } = new()
{
new KeyValuePair<string, int?>("全部", null),
new KeyValuePair<string, int?>("早班", 1),
new KeyValuePair<string, int?>("中班", 2),
new KeyValuePair<string, int?>("晚班", 3)
};
public DelegateCommand SearchCommand { get; }
public DelegateCommand ResetCommand { get; }
public DelegateCommand PrevPageCommand { get; }
public DelegateCommand NextPageCommand { get; }
public MixingProductionPlanListViewModel(
IMixingProductionPlanService planService,
IContainerExtension container,
IRegionManager regionManager) : base(container, regionManager)
{
_planService = planService;
SearchCommand = new DelegateCommand(async () => { PageNo = 1; await LoadAsync(); });
ResetCommand = new DelegateCommand(async () =>
{
FilterPlanDateFrom = null;
FilterPlanDateTo = null;
FilterMachineName = null;
FilterShiftFlag = null;
FilterPlanNo = null;
FilterMaterialName = null;
PageNo = 1;
await LoadAsync();
});
PrevPageCommand = new DelegateCommand(async () => { if (PageNo > 1) { PageNo--; await LoadAsync(); } });
NextPageCommand = new DelegateCommand(async () => { if ((long)PageNo * PageSize < Total) { PageNo++; await LoadAsync(); } });
_changedToken = _eventAggregator.GetEvent<MixingProductionPlanChangedEvent>()
.Subscribe(async _ => await LoadAsync(), ThreadOption.UIThread);
_ = InitializeAsync();
}
private async Task InitializeAsync()
{
try
{
await UIHelper.WaitForRenderAsync();
await LoadAsync();
}
catch (Exception ex)
{
Debug.WriteLine($"密炼计划列表初始化失败: {ex.Message}");
}
}
public async Task LoadAsync()
{
try
{
IsLoading = true;
var result = await _planService.PageAsync(
PageNo, PageSize,
FilterPlanDateFrom, FilterPlanDateTo,
FilterMachineName, FilterShiftFlag,
FilterPlanNo, FilterMaterialName);
Items = new ObservableCollection<MesXslMixingProductionPlan>(result.Records);
Total = result.Total;
}
catch (Exception ex)
{
Growl.Error($"加载密炼计划失败:{ex.Message}");
}
finally
{
IsLoading = false;
}
}
protected override void CleanUp()
{
base.CleanUp();
if (_changedToken != null)
{
_eventAggregator.GetEvent<MixingProductionPlanChangedEvent>().Unsubscribe(_changedToken);
_changedToken = null;
}
}
}

View File

@@ -25,9 +25,10 @@ public class MixingPlanShiftOption
public string? PlanId { get; set; }
public string? OrderNo { get; set; }
public string? FormulaName { get; set; }
public string? MaterialName { get; set; }
public string DisplayText => string.IsNullOrWhiteSpace(OrderNo)
? FormulaName ?? string.Empty
: $"{OrderNo} | {FormulaName}";
? MaterialName ?? FormulaName ?? string.Empty
: $"{OrderNo} | {MaterialName ?? FormulaName}";
}
public class QuickTestInspectCellViewModel : BindableBase
@@ -217,7 +218,7 @@ public class RubberQuickTestOperationViewModel : BaseViewModel
public string? ProductionOrderNo => _selectedPlan?.OrderNo;
public string? MachineName => _selectedPlan?.MachineName ?? SelectedMachine;
public string? WorkShiftDisplay => SelectedShift?.Name ?? string.Empty;
public string? RubberMaterialName => _selectedPlan?.FormulaName;
public string? RubberMaterialName => _selectedPlan?.MaterialName ?? _selectedPlan?.FormulaName;
private string? _trainNo;
public string? TrainNo
@@ -286,32 +287,25 @@ public class RubberQuickTestOperationViewModel : BaseViewModel
_allShiftOptions.Clear();
foreach (var row in _allPlans)
{
AddShiftOption(row, "morning", "1", "早班", row.MorningPlanId, row.MorningOrderDate, row.MorningOrderNo, row.MorningFormulaName);
AddShiftOption(row, "noon", "2", "中班", row.NoonPlanId, row.NoonOrderDate, row.NoonOrderNo, row.NoonFormulaName);
AddShiftOption(row, "night", "3", "晚班", row.NightPlanId, row.NightOrderDate, row.NightOrderNo, row.NightFormulaName);
if (string.IsNullOrWhiteSpace(row.PlanId)) continue;
var shiftCode = row.ShiftFlag?.ToString() ?? string.Empty;
_allShiftOptions.Add(new MixingPlanShiftOption
{
PlanRowId = row.Id ?? string.Empty,
MachineId = row.MachineId,
MachineName = row.MachineName,
ShiftKey = shiftCode,
ShiftCode = shiftCode,
ShiftName = row.ShiftFlagText,
OrderDate = row.PlanDate,
PlanId = row.PlanId,
OrderNo = row.OrderNo,
FormulaName = row.FormulaName,
MaterialName = row.MaterialName
});
}
}
private void AddShiftOption(
MesXslMixingProductionPlan row, string shiftKey, string shiftCode, string shiftName,
string? planId, DateTime? orderDate, string? orderNo, string? formulaName)
{
if (string.IsNullOrWhiteSpace(planId) || string.IsNullOrWhiteSpace(orderNo)) return;
_allShiftOptions.Add(new MixingPlanShiftOption
{
PlanRowId = row.Id ?? string.Empty,
MachineId = row.MachineId,
MachineName = row.MachineName,
ShiftKey = shiftKey,
ShiftCode = shiftCode,
ShiftName = shiftName,
OrderDate = orderDate,
PlanId = planId,
OrderNo = orderNo,
FormulaName = formulaName
});
}
private IEnumerable<MixingPlanShiftOption> FilteredByDate =>
_allShiftOptions.Where(o => o.OrderDate?.Date == MixingDate.Date);