| | |
| | | using Mapster; |
| | | using IStation.Calculation; |
| | | using IStation.Model; |
| | | using System.Threading; |
| | | using Furion.DataValidation; |
| | | |
| | | namespace IStation.Application |
| | | { |
| | |
| | | { |
| | | var corpId = input.CorpID; |
| | | var monitorPointIds = LongListHelper.ToList(input.MonitorPointIds); |
| | | var list = new Service.MonitorRecord().GetLastRecord(corpId, monitorPointIds); |
| | | if (list == null || list.Count < 1) |
| | | return default; |
| | | var monitorList = new Service.MonitorPoint().GetExSignalWithSignalTypeByIds(corpId, monitorPointIds); |
| | | var vm_list = list.Select(x => { |
| | | if (monitorList == null || monitorList.Count < 1) |
| | | return default; |
| | | |
| | | var list = new List<MonitorBasicRecordMobileDto>(); |
| | | |
| | | var virtualMonitorPoints = monitorList.Where(x => x.SourceType == Model.Monitor.eSourceType.Virtual); |
| | | if (virtualMonitorPoints != null && virtualMonitorPoints.Count() > 0) |
| | | { |
| | | foreach (var monitor in virtualMonitorPoints) |
| | | { |
| | | if (string.IsNullOrEmpty(monitor.SourceParas)) |
| | | continue; |
| | | var analyModel = Model.Monitor.AnalyseParameters.ToModel(monitor.SourceParas); |
| | | if (analyModel.FormulaType != Model.Monitor.FormulaType.Calculation_Const) |
| | | continue; |
| | | var formulaModel = Model.Monitor.ConstCalculationFormulaParas.ToModel(analyModel.FormulaParas); |
| | | if (formulaModel == null) |
| | | continue; |
| | | var record = new Model.MonitorBasicRecord(); |
| | | record.CorpID = monitor.CorpID; |
| | | record.DataTime = DateTime.Now; |
| | | record.DataValue = formulaModel.Value; |
| | | record.DataStatus = new List<string>(); |
| | | var signal = monitor.SignalList.First(); |
| | | var vm = new MonitorBasicRecordMobileDto(record, signal); |
| | | list.Add(vm); |
| | | } |
| | | } |
| | | |
| | | var lastRecords = new Service.MonitorRecord().GetLastRecord(corpId, monitorPointIds); |
| | | if (lastRecords == null || lastRecords.Count < 1) |
| | | return list; |
| | | var vm_list = lastRecords.Select(x => |
| | | { |
| | | var monitor = monitorList.Find(t => t.ID == x.MonitorPointID); |
| | | var signal = monitor.SignalList.Find(t => t.ID == x.SignalID); |
| | | var vm = new MonitorBasicRecordMobileDto(x, signal); |
| | | return vm; |
| | | }).ToList(); |
| | | |
| | | return vm_list; |
| | | list.AddRange(vm_list); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /// <summary> |