添加项目文件。
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
using JinYuan.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public static class MockDataGenerator
|
||||
{
|
||||
public static readonly Random _random = new Random();
|
||||
|
||||
// 修改为与实际数据结构匹配的类
|
||||
public class ProdData
|
||||
{
|
||||
public string DisplayTime { get; set; }
|
||||
public int ProdIn { get; set; }
|
||||
public int ProdOut { get; set; }
|
||||
public double OKRatio { get; set; }
|
||||
}
|
||||
|
||||
public class AlarmData
|
||||
{
|
||||
public string DataType { get; set; }
|
||||
public int DataCount { get; set; }
|
||||
}
|
||||
|
||||
public class NGData
|
||||
{
|
||||
public string DataType { get; set; }
|
||||
public int DataCount { get; set; }
|
||||
}
|
||||
|
||||
public static List<Chart12HourData> Generate12HourData()
|
||||
{
|
||||
var result = new List<Chart12HourData>();
|
||||
var random = new Random();
|
||||
|
||||
// 方法1:使用数组预定义顺序
|
||||
var timeSlots = new[]
|
||||
{
|
||||
"08:30", "09:30", "10:30", "11:30", "12:30", "13:30", "14:30", "15:30", "16:30", "17:30",
|
||||
"18:30", "19:30", "20:30", "21:30", "22:30", "23:30", "00:30", "01:30", "02:30", "03:30",
|
||||
"04:30", "05:30", "06:30", "07:30"
|
||||
};
|
||||
|
||||
foreach (var timeSlot in timeSlots)
|
||||
{
|
||||
var prodIn = random.Next(800, 2000);
|
||||
var prodOut = random.Next(700, prodIn);
|
||||
var okRatio = Math.Round((double)prodOut / prodIn * 100, 2);
|
||||
|
||||
result.Add(new Chart12HourData
|
||||
{
|
||||
DisplayTime = timeSlot,
|
||||
ProdIn = prodIn,
|
||||
ProdOut = prodOut,
|
||||
OKRatio = okRatio.ToString("F2") + "%"
|
||||
});
|
||||
}
|
||||
|
||||
return result; // 不需要额外排序,因为已经按照需要的顺序生成
|
||||
}
|
||||
|
||||
public static List<ChartDataType> GenerateAlarmTop10Data()
|
||||
{
|
||||
var alarmTypes = new[]
|
||||
{
|
||||
"设备故障", "原料异常", "温度超限", "压力异常",
|
||||
"速度偏差", "位置错误", "通信中断", "电源故障",
|
||||
"气压不足", "传感器异常"
|
||||
};
|
||||
|
||||
return alarmTypes
|
||||
.Select(type => new ChartDataType
|
||||
{
|
||||
DataType = type,
|
||||
DataCount = _random.Next(5, 50)
|
||||
})
|
||||
.OrderByDescending(x => x.DataCount)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static List<ChartDataType> GenerateNGData()
|
||||
{
|
||||
var ngTypes = new[]
|
||||
{
|
||||
"尺寸超差", "表面划伤", "变形", "异物",
|
||||
"色差", "气泡", "裂纹", "焊接不良"
|
||||
};
|
||||
|
||||
return ngTypes
|
||||
.Select(type => new ChartDataType
|
||||
{
|
||||
DataType = type,
|
||||
DataCount = _random.Next(10, 100)
|
||||
})
|
||||
.OrderByDescending(x => x.DataCount)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user