| | |
| | | using Mapster; |
| | | using IStation.Calculation; |
| | | using IStation.Model; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | |
| | | namespace IStation.Application |
| | | { |
| | |
| | | public class MonitorVibrationRecord_Controller : IDynamicApiController |
| | | { |
| | | |
| | | #region 通过 MonitorPointID 获取某天的基础数据 |
| | | |
| | | /// <summary> |
| | | /// 通过 MonitorPointID 获取某天的基础数据 |
| | | /// 通过 MonitorPointID 获取某天的基础数据(已进行单位换算,使用的是信号显示单位) |
| | | /// </summary> |
| | | [Route("GetBasicByMonitorPointIDOfDay@V1.0")] |
| | | [HttpGet] |
| | | public List<MonitorVibrationBasicRecordDto> GetBasicByMonitorPointIDOfDay |
| | | public List<MonitorVibrationBasicRecordDto> GetBasicByMonitorPointIDOfDay_V1_0 |
| | | ( |
| | | [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")] |
| | | long CorpID, |
| | |
| | | DateTime Day |
| | | ) |
| | | { |
| | | var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID,MonitorPointID); |
| | | var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID); |
| | | if (monitor == null) |
| | | return default; |
| | | if (monitor.MonitorType != eMonitorType.Vibration) |
| | |
| | | (x.Flags.Contains(LogicFlags.配置) || x.Flags.Contains(LogicFlags.波形) || x.Flags.Contains(LogicFlags.FFT))); |
| | | if (signalList.Count < 1) |
| | | return default; |
| | | var recordList = new Service.MonitorRealRecord().GetBySignalIdsOfDay(CorpID,MonitorPointID,signalList.Select(x=>x.ID),Day); |
| | | var recordList = new Service.MonitorRealRecord().GetBySignalIdsOfDay(CorpID, MonitorPointID, signalList.Select(x => x.ID), Day); |
| | | if (recordList == null || recordList.Count < 1) |
| | | return default; |
| | | var groupList = recordList.GroupBy(x => x.DataTime).OrderBy(x=>x.Key).ToList(); |
| | | var groupList = recordList.GroupBy(x => x.DataTime).OrderBy(x => x.Key).ToList(); |
| | | var vmList = new List<MonitorVibrationBasicRecordDto>(); |
| | | foreach (var group in groupList) |
| | | { |
| | | var vm = new MonitorVibrationBasicRecordDto(); |
| | | vm.CorpID= CorpID; |
| | | vm.MonitorPointID= MonitorPointID; |
| | | vm.CorpID = CorpID; |
| | | vm.MonitorPointID = MonitorPointID; |
| | | vm.DataTime = group.Key; |
| | | vm.SignalRecordList = new List<MonitorVibrationBasicSignalRecordDto>(group.Count()); |
| | | foreach (var item in group) |
| | | { |
| | | var signal = signalList.Find(t=>t.ID==item.SignalID); |
| | | var vmItem=new MonitorVibrationBasicSignalRecordDto(signal,item); |
| | | var signal = signalList.Find(t => t.ID == item.SignalID); |
| | | var vmItem = new MonitorVibrationBasicSignalRecordDto(item,signal); |
| | | vm.SignalRecordList.Add(vmItem); |
| | | } |
| | | vmList.Add(vm); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 MonitorPointID 获取某个时刻的波形记录 |
| | | /// 通过 MonitorPointID 获取某天的基础数据(不需要验证Token)(已进行单位换算,使用的是信号显示单位) |
| | | /// </summary> |
| | | [AllowAnonymous] |
| | | [Route("GetBasicByMonitorPointIDOfDay@V1.1")] |
| | | [HttpGet] |
| | | public List<MonitorVibrationBasicRecordDto> GetBasicByMonitorPointIDOfDay_V1_1 |
| | | ( |
| | | [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")] |
| | | long CorpID, |
| | | [Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")] |
| | | long MonitorPointID, |
| | | [Required] |
| | | DateTime Day |
| | | ) |
| | | { |
| | | var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID); |
| | | if (monitor == null) |
| | | return default; |
| | | if (monitor.MonitorType != eMonitorType.Vibration) |
| | | return default; |
| | | var signalList = monitor.SignalList.ToList(); |
| | | signalList.RemoveAll(x => x.Flags != null && x.Flags.Count > 0 && |
| | | (x.Flags.Contains(LogicFlags.配置) || x.Flags.Contains(LogicFlags.波形) || x.Flags.Contains(LogicFlags.FFT))); |
| | | if (signalList.Count < 1) |
| | | return default; |
| | | var recordList = new Service.MonitorRealRecord().GetBySignalIdsOfDay(CorpID, MonitorPointID, signalList.Select(x => x.ID), Day); |
| | | if (recordList == null || recordList.Count < 1) |
| | | return default; |
| | | var groupList = recordList.GroupBy(x => x.DataTime).OrderBy(x => x.Key).ToList(); |
| | | var vmList = new List<MonitorVibrationBasicRecordDto>(); |
| | | foreach (var group in groupList) |
| | | { |
| | | var vm = new MonitorVibrationBasicRecordDto(); |
| | | vm.CorpID = CorpID; |
| | | vm.MonitorPointID = MonitorPointID; |
| | | vm.DataTime = group.Key; |
| | | vm.SignalRecordList = new List<MonitorVibrationBasicSignalRecordDto>(group.Count()); |
| | | foreach (var item in group) |
| | | { |
| | | var signal = signalList.Find(t => t.ID == item.SignalID); |
| | | var vmItem = new MonitorVibrationBasicSignalRecordDto(item, signal); |
| | | vm.SignalRecordList.Add(vmItem); |
| | | } |
| | | vmList.Add(vm); |
| | | } |
| | | return vmList; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 通过 MonitorPointID 获取某个时刻的波形记录 |
| | | |
| | | /// <summary> |
| | | /// 通过 MonitorPointID 获取某个时刻的波形记录(未进行单位转换,使用的是系统单位) |
| | | /// </summary> |
| | | [Route("GetWaveByMonitorPointIDOfDataTime@V1.0")] |
| | | [HttpGet] |
| | | public MonitorVibrationWaveRecordDto GetWaveByMonitorPointIDOfDataTime |
| | | public MonitorVibrationWaveRecordDto GetWaveByMonitorPointIDOfDataTime_V1_0 |
| | | ( |
| | | [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")] |
| | | long CorpID, |
| | |
| | | return default; |
| | | if (monitor.MonitorType != eMonitorType.Vibration) |
| | | return default; |
| | | var signal = monitor.SignalList.Find(t=>t.Flags!=null&&t.Flags.Contains(LogicFlags.波形)); |
| | | var signal = monitor.SignalList.Find(t => t.Flags != null && t.Flags.Contains(LogicFlags.波形)); |
| | | if (signal == null) |
| | | return default; |
| | | var record = new Service.MonitorRealRecord().GetBySignalIDOfDataTime(CorpID,MonitorPointID,signal.ID,DataTime); |
| | | var record = new Service.MonitorRealRecord().GetBySignalIDOfDataTime(CorpID, MonitorPointID, signal.ID, DataTime); |
| | | if (record == null) |
| | | return default; |
| | | var vm = new MonitorVibrationWaveRecordDto(record); |
| | | return vm; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 MonitorPointID 获取某个时刻的波形记录(不需要验证Token)(未进行单位转换,使用的是系统单位) |
| | | /// </summary> |
| | | [AllowAnonymous] |
| | | [Route("GetWaveByMonitorPointIDOfDataTime@V1.1")] |
| | | [HttpGet] |
| | | public MonitorVibrationWaveRecordDto GetWaveByMonitorPointIDOfDataTime_V1_1 |
| | | ( |
| | | [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")] |
| | | long CorpID, |
| | | [Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID 必须大于0")] |
| | | long MonitorPointID, |
| | | [Required] |
| | | DateTime DataTime |
| | | ) |
| | | { |
| | | var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(CorpID, MonitorPointID); |
| | | if (monitor == null) |
| | | return default; |
| | | if (monitor == null) |
| | | return default; |
| | | if (monitor.MonitorType != eMonitorType.Vibration) |
| | | return default; |
| | | var signal = monitor.SignalList.Find(t => t.Flags != null && t.Flags.Contains(LogicFlags.波形)); |
| | | if (signal == null) |
| | | return default; |
| | | var record = new Service.MonitorRealRecord().GetBySignalIDOfDataTime(CorpID, MonitorPointID, signal.ID, DataTime); |
| | | if (record == null) |
| | | return default; |
| | | var vm = new MonitorVibrationWaveRecordDto(record); |
| | | return vm; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | } |