105 lines
3.7 KiB
C#
105 lines
3.7 KiB
C#
using LiveChartsCore;
|
|
using LiveChartsCore.Defaults;
|
|
using LiveChartsCore.SkiaSharpView;
|
|
using Prism.Mvvm;
|
|
using System.Collections.ObjectModel;
|
|
using YY.Admin.Core.Entity;
|
|
|
|
namespace YY.Admin.ViewModels.RubberQuickTest;
|
|
|
|
public class RubberQuickTestRecordDetailDialogViewModel : BindableBase
|
|
{
|
|
private MesXslRubberQuickTestRecord? _record;
|
|
public MesXslRubberQuickTestRecord? Record
|
|
{
|
|
get => _record;
|
|
private set => SetProperty(ref _record, value);
|
|
}
|
|
|
|
private string? _inspectResultDisplay;
|
|
public string? InspectResultDisplay
|
|
{
|
|
get => _inspectResultDisplay;
|
|
private set => SetProperty(ref _inspectResultDisplay, value);
|
|
}
|
|
|
|
public ObservableCollection<MesXslRubberQuickTestRecordStdLine> StdLines { get; } = new();
|
|
public ObservableCollection<MesXslRubberQuickTestRecordRawLine> RawLines { get; } = new();
|
|
|
|
public ObservableCollection<ISeries> TemperatureSeries { get; }
|
|
public ObservableCollection<ISeries> TorqueSeries { get; }
|
|
public ObservableCollection<ObservablePoint> UpperTempValues { get; } = new();
|
|
public ObservableCollection<ObservablePoint> LowerTempValues { get; } = new();
|
|
public ObservableCollection<ObservablePoint> TorqueValues { get; } = new();
|
|
|
|
public Axis[] TemperatureXAxes { get; } = BuildTimeAxis();
|
|
public Axis[] TemperatureYAxes { get; } = BuildTempYAxis();
|
|
public Axis[] TorqueXAxes { get; } = BuildTimeAxis();
|
|
public Axis[] TorqueYAxes { get; } = BuildTorqueYAxis();
|
|
|
|
public RubberQuickTestRecordDetailDialogViewModel()
|
|
{
|
|
TemperatureSeries = new ObservableCollection<ISeries>
|
|
{
|
|
new LineSeries<ObservablePoint> { Name = "上模温度", Values = UpperTempValues, GeometrySize = 4, LineSmoothness = 0.3 },
|
|
new LineSeries<ObservablePoint> { Name = "下模温度", Values = LowerTempValues, GeometrySize = 4, LineSmoothness = 0.3 }
|
|
};
|
|
TorqueSeries = new ObservableCollection<ISeries>
|
|
{
|
|
new LineSeries<ObservablePoint> { Name = "S'(dNm)", Values = TorqueValues, GeometrySize = 4, LineSmoothness = 0.3 }
|
|
};
|
|
}
|
|
|
|
public void Initialize(MesXslRubberQuickTestRecord record)
|
|
{
|
|
Record = record;
|
|
InspectResultDisplay = record.InspectResult switch
|
|
{
|
|
"1" => "合格",
|
|
"0" => "不合格",
|
|
_ => record.InspectResultText ?? record.InspectResult ?? ""
|
|
};
|
|
StdLines.Clear();
|
|
foreach (var line in record.StdLineList ?? [])
|
|
StdLines.Add(line);
|
|
|
|
RawLines.Clear();
|
|
foreach (var line in record.RawLineList ?? [])
|
|
RawLines.Add(line);
|
|
|
|
UpperTempValues.Clear();
|
|
LowerTempValues.Clear();
|
|
TorqueValues.Clear();
|
|
foreach (var p in (record.ChartPointList ?? []).OrderBy(x => x.SortNo ?? 0))
|
|
{
|
|
var time = (double)(p.TimeMin ?? 0);
|
|
UpperTempValues.Add(new ObservablePoint(time, (double)(p.UpperTemp ?? 0)));
|
|
LowerTempValues.Add(new ObservablePoint(time, (double)(p.LowerTemp ?? 0)));
|
|
TorqueValues.Add(new ObservablePoint(time, (double)(p.TorqueS ?? 0)));
|
|
}
|
|
}
|
|
|
|
private static Axis[] BuildTimeAxis() => new[]
|
|
{
|
|
new Axis { Name = "时间(min)", MinLimit = 0, MaxLimit = 2, Labeler = v => v.ToString("0.0#") }
|
|
};
|
|
|
|
private static Axis[] BuildTempYAxis() => new[]
|
|
{
|
|
new Axis { Name = "温度(℃)", MinLimit = 189, MaxLimit = 201 }
|
|
};
|
|
|
|
private static readonly double[] TorqueYTicks = { 0.0, 3.0, 5.9, 8.9, 11.8, 14.8 };
|
|
|
|
private static Axis[] BuildTorqueYAxis() => new[]
|
|
{
|
|
new Axis
|
|
{
|
|
Name = "S'(dNm)",
|
|
MinLimit = 0,
|
|
MaxLimit = 14.8,
|
|
CustomSeparators = TorqueYTicks
|
|
}
|
|
};
|
|
}
|