1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ProductionLineMonitor.Web.Services.LineService
- {
- public class LineDayFaultRecord
- {
- /// <summary>
- /// 设备类型
- /// </summary>
- public string MechineName { get; set; }
- /// <summary>
- /// 开始时间
- /// </summary>
- public DateTime StartTime { get; set; }
- /// <summary>
- /// 结束时间
- /// </summary>
- public DateTime? EndTime { get; set; }
- /// <summary>
- /// 故障码
- /// </summary>
- public string FaultCode { get; set; }
- /// <summary>
- /// 故障详情
- /// </summary>
- public string FaultInfo { get; set; }
- /// <summary>
- /// 持续时间
- /// </summary>
- public double Duration { get; set; }
- /// <summary>
- /// 数据源 0: 系统自动抓取 1:人工录入
- /// </summary>
- public int DataSource { get; set; }
- }
- public class ProductionLineFaultViewModel : ProductionLineViewModel
- {
- public ProductionLineFaultViewModel(int floor, int line, string date, string[] topics)
- {
- Floor = floor;
- Line = line;
- Date = date;
- KeyInInfos = MesApiService.GetKeyInInfos(floor, line, date);
- foreach (var key in KeyInInfos)
- {
- if (key.KeyInType == 2 || key.KeyInType == 3 || key.KeyInType == 4 ||
- key.KeyInType == 6 || key.KeyInType == 7 || key.KeyInType == 9 ||
- key.KeyInType == 0)
- LineDayFaultRecords.Add(new LineDayFaultRecord
- {
- FaultCode = key.KeyInType.ToString(),
- FaultInfo = key.Description,
- EndTime = key.EndTime,
- MechineName = "Line",
- StartTime = key.StartTime.Value,
- Duration = key.AffectTime
- });
- }
- // string[] topics = Global.App.ProductionLines.Find(x => x.Floor == floor && x.Line == line)?.Topics;
- foreach (var topic in topics)
- {
- MachineFaultViewModel model = new MachineFaultViewModel(topic, date);
- var faults = model.FaultRecords.Where(x => x.Duration >= 3 && !x.FaultInfo.Contains("安全门")).ToList();
- foreach (var fault in faults)
- {
- LineDayFaultRecords.Add(new LineDayFaultRecord
- {
- FaultCode = fault.FaultCode,
- FaultInfo = fault.FaultInfo,
- EndTime = fault.EndTime,
- MechineName = model.Type,
- StartTime = fault.StartTime,
- Duration = fault.Duration
- });
- }
- }
- LineDayFaultRecords = LineDayFaultRecords.OrderBy(x => x.StartTime).ToList();
- }
- public List<LineDayFaultRecord> LineDayFaultRecords { get; set; }
- = new List<LineDayFaultRecord>();
- }
- }
|