From 391e0e408d09e698850eb5daaef485d088612b4f Mon Sep 17 00:00:00 2001 From: ningshuxia <ningshuxia0927@outlook.com> Date: 星期四, 01 十二月 2022 13:41:12 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/IStation/Service.V4.1 --- Application/IStation.Application.Run/data_docking/DataDocking_StandardController.cs | 255 +++++++++++++++++--------------------------------- 1 files changed, 87 insertions(+), 168 deletions(-) diff --git a/Application/IStation.Application.Run/data_docking/DataDocking_StandardController.cs b/Application/IStation.Application.Run/data_docking/DataDocking_StandardController.cs index 0d94f68..e9a0a7c 100644 --- a/Application/IStation.Application.Run/data_docking/DataDocking_StandardController.cs +++ b/Application/IStation.Application.Run/data_docking/DataDocking_StandardController.cs @@ -13,6 +13,7 @@ using Furion.DataEncryption; using AutoMapper; using System.Text; +using IStation.Calculation; namespace IStation.Application { @@ -104,179 +105,97 @@ return false; } - ///// <summary> - ///// 琛ュ綍 - ///// </summary> - //[Route("Supplement@V1.0")] - //[HttpPost] - //public bool Supplement([Required] DataDockingStandardInput input) - //{ - // LogHelper.Info($"鏁版嵁鏍囧噯瀵规帴鎺ュ彛涓紝娉ㄥ唽鐮�:{input.RegisterCode},琛ュ綍鏁版嵁璁板綍鏁伴噺:{input.Records.Count}."); + /// <summary> + /// 琛ュ綍 + /// </summary> + [Route("Supplement@V1.0")] + [HttpPost] + public bool Supplement([Required] DataDockingStandardInput input) + { + LogHelper.Info($"鏁版嵁鏍囧噯瀵规帴鎺ュ彛涓紝娉ㄥ唽鐮�:{input.RegisterCode},琛ュ綍鏁版嵁璁板綍鏁伴噺:{input.Records.Count}."); - // var corpIds = DataDockingCorpHelper.GetCorpIds(); - // if (corpIds == null || corpIds.Count < 1) - // { - // throw new Exception("鏈绱㈠埌瀹㈡埛鏍囪瘑閰嶇疆淇℃伅锛�"); - // } - // if (_standardConfigureList == null) - // { - // var configureList = new Service.DataDockingConfigure().GetByCorpIds(corpIds); - // if (configureList == null || configureList.Count < 1) - // { - // throw new Exception("鏈绱㈠埌鏁版嵁瀵规帴閰嶇疆淇℃伅锛�"); - // } - // configureList = configureList.Where(x => x.DockingMode == Model.DataDockingConfigure.eDockingMode.Standard).ToList(); - // if (configureList == null || configureList.Count < 1) - // { - // throw new Exception("鏈绱㈠埌鏁版嵁瀵规帴鏍囧噯閰嶇疆淇℃伅锛�"); - // } - // _standardConfigureList = configureList.Select(x => new Model.DataDockingConfigureExStandard(x)).ToList(); - // } - // var standardConfigure = _standardConfigureList.Find(x => x.ConfigureParas != null && x.ConfigureParas.RegisterCode == input.RegisterCode); - // if (standardConfigure == null) - // { - // throw new Exception("鏈绱㈠埌鏁版嵁瀵规帴鏍囧噯閰嶇疆淇℃伅锛�"); - // } - // if (standardConfigure.Mappers == null || standardConfigure.Mappers.Count < 1) - // { - // throw new Exception("鏁版嵁瀵规帴鏍囧噯閰嶇疆淇℃伅涓紝鏈厤缃湁鏁堟槧灏勫叧绯伙紒"); - // } + var corpIds = DataDockingCorpHelper.GetCorpIds(); + if (corpIds == null || corpIds.Count < 1) + { + throw new Exception("鏈绱㈠埌瀹㈡埛鏍囪瘑閰嶇疆淇℃伅锛�"); + } + if (_standardConfigureList == null) + { + var configureList = new Service.DataDockingConfigure().GetByCorpIds(corpIds); + if (configureList == null || configureList.Count < 1) + { + throw new Exception("鏈绱㈠埌鏁版嵁瀵规帴閰嶇疆淇℃伅锛�"); + } + configureList = configureList.Where(x => x.DockingMode == Model.DataDockingConfigure.eDockingMode.Standard).ToList(); + if (configureList == null || configureList.Count < 1) + { + throw new Exception("鏈绱㈠埌鏁版嵁瀵规帴鏍囧噯閰嶇疆淇℃伅锛�"); + } + _standardConfigureList = configureList.Select(x => new Model.DataDockingConfigureExStandard(x)).ToList(); + } + var standardConfigure = _standardConfigureList.Find(x => x.ConfigureParas != null && x.ConfigureParas.RegisterCode == input.RegisterCode); + if (standardConfigure == null) + { + throw new Exception("鏈绱㈠埌鏁版嵁瀵规帴鏍囧噯閰嶇疆淇℃伅锛�"); + } + if (standardConfigure.Mappers == null || standardConfigure.Mappers.Count < 1) + { + throw new Exception("鏁版嵁瀵规帴鏍囧噯閰嶇疆淇℃伅涓紝鏈厤缃湁鏁堟槧灏勫叧绯伙紒"); + } - // //鐢熸垚璁板綍 - // var recordList = new List<Model.MonitorRealRecordPure>(); - // foreach (var mapper in standardConfigure.Mappers) - // { - // var inputRecordList = input.Records.Where(t => t.RecordId == mapper.SignId).ToList(); - // if (inputRecordList != null && inputRecordList.Count > 0) - // { - // var inputGroupList = inputRecordList.GroupBy(x => new { x.RecordId, x.RecordTime }).ToList(); - // foreach (var inputGroup in inputGroupList) - // { - // var inputFirstRecord = inputGroup.First(); - // var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(standardConfigure.CorpID, mapper.SysId); - // if (monitor == null) - // { - // continue; - // } - // if (monitor.CronType != Model.Monitor.eCronType.Real) - // { - // continue; - // } - // switch (inputFirstRecord.RecordType) - // { - // case Model.eMonitorType.General: - // { - // var record = new Model.MonitorRealRecordPure(); - // record.CorpID = standardConfigure.CorpID; - // record.MonitorPointID = monitor.ID; - // record.SignalID = monitor.SignalList.First().ID; - // record.RecordType = monitor.MonitorType; - // record.SrcTime = inputFirstRecord.RecordTime; - // record.SrcValue = inputFirstRecord.RecordValue; + //鐢熸垚璁板綍 + var recordList = new List<Model.MonitorBasicRecord>(); + foreach (var mapper in standardConfigure.Mappers) + { + var inputRecordList = input.Records.Where(t => t.RecordId == mapper.SignId).ToList(); + if (inputRecordList != null && inputRecordList.Count > 0) + { + var inputGroupList = inputRecordList.GroupBy(x => new { x.RecordId, x.RecordTime }).ToList(); + foreach (var inputGroup in inputGroupList) + { + var inputFirstRecord = inputGroup.First(); + var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(standardConfigure.CorpID, mapper.SysId); + if (monitor == null) + { + continue; + } + switch (inputFirstRecord.RecordType) + { + case Model.eMonitorType.General: + { + var receiveRecord = new Model.MonitorDataDockingReceiveRecord(); + receiveRecord.SysId = mapper.SysId; + receiveRecord.RecordType = inputFirstRecord.RecordType; + receiveRecord.SrcTime = inputFirstRecord.RecordTime; + receiveRecord.SrcValue = inputFirstRecord.RecordValue; + var record = MonitorHandleHelper.HandleHistory(monitor, monitor.SignalList.First(),receiveRecord,inputFirstRecord.RecordTime); + if (record != null) + { + recordList.Add(record); + } + } + break; + case Model.eMonitorType.Vibration: + { + } + break; + default: break; + } + } + } + } - // record.MonitorPointID = item.MonitorPointID; - // record.SignalID = signal.ID; - // record.RecordType = monitor.MonitorType; - // record.SrcTime = item.SrcTime; - // record.SrcValue = item.SrcValue; - // record.DataTime = item.DataTime; - // record.DataValue = data_value; - // record.DataStatus = data_status; - // recordList.Add(record); + if (recordList.Count < 1) + { + return false; + } + + //涓存椂 + var bol = new Service.MonitorRealRecord().InsertsSupplement(recordList.Select(x=>x as Model.MonitorRealRecordPure).ToList()); + return bol; - // } - // break; - // case Model.eMonitorType.Vibration: - // { - - // } - // break; - // default:break; - // } - - - // } - // } - // } - // foreach (var item in list) - // { - // var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(item.CorpID, item.MonitorPointID); - // if (monitor == null) - // { - // continue; - // } - // if (monitor.CronType != Model.Monitor.eCronType.Real) - // { - // continue; - // } - // switch (monitor.MonitorType) - // { - // case Model.eMonitorType.General: - // { - // var signal = monitor.SignalList?.FirstOrDefault(); - // if (signal != null) - // { - // var data_status = new List<string>(); - // var data_value = MonitorHandleHelper.Handle(monitor, signal, lastRecord: null, item.SrcTime, item.SrcValue, data_status); - // if (!string.IsNullOrEmpty(data_value)) - // { - // var record = new Model.MonitorRealRecordPure(); - // record.CorpID = item.CorpID; - // record.MonitorPointID = item.MonitorPointID; - // record.SignalID = signal.ID; - // record.RecordType = monitor.MonitorType; - // record.SrcTime = item.SrcTime; - // record.SrcValue = item.SrcValue; - // record.DataTime = item.DataTime; - // record.DataValue = data_value; - // record.DataStatus = data_status; - // recordList.Add(record); - // } - // } - // } - // break; - // case Model.eMonitorType.Vibration: - // { - // var sub_record_list = AddMonitorSubRecordInput.ToList(item.SrcValue); - // if (sub_record_list != null && sub_record_list.Count > 0) - // { - // foreach (var sub_record in sub_record_list) - // { - // var signal = monitor.SignalList?.FirstOrDefault(x => x.ID == sub_record.SignalID); - // if (signal == null) - // continue; - // var data_status = new List<string>(); - // var data_value = MonitorHandleHelper.Handle(monitor, signal, lastRecord: null, item.SrcTime, sub_record.SrcValue, data_status); - // if (string.IsNullOrEmpty(data_value)) - // continue; - // var record = new Model.MonitorRealRecordPure(); - // record.CorpID = item.CorpID; - // record.MonitorPointID = item.MonitorPointID; - // record.SignalID = signal.ID; - // record.RecordType = monitor.MonitorType; - // record.SrcTime = item.SrcTime; - // record.SrcValue = item.SrcValue; - // record.DataTime = item.DataTime; - // record.DataValue = data_value; - // record.DataStatus = data_status; - // recordList.Add(record); - // } - // } - // } - // break; - // default: break; - // } - // } - - // if (recordList.Count < 1) - // { - // return false; - // } - // var bol = _service.InsertsSupplement(recordList); - // return bol; - - //} + } -- Gitblit v1.9.3