|
@@ -1,15 +1,18 @@
|
|
|
using RestSharp;
|
|
|
using ServiceCenter.Redis;
|
|
|
using ServiceCenter.SqlSugars;
|
|
|
+using ServiceCenter.WebApi;
|
|
|
using SqlSugar;
|
|
|
using System.ComponentModel;
|
|
|
using System.Diagnostics;
|
|
|
-using System.Reflection;
|
|
|
using System.Text;
|
|
|
using WCS.Core;
|
|
|
+using WCS.Entity.Protocol.BCR;
|
|
|
using WCS.Entity.Protocol.DataStructure;
|
|
|
+using WCS.Entity.Protocol.RGV;
|
|
|
using WCS.Entity.Protocol.Robot;
|
|
|
using WCS.Entity.Protocol.SRM;
|
|
|
+using WCS.Entity.Protocol.Station;
|
|
|
using WCS.Entity.Protocol.Truss;
|
|
|
using WCS.WorkEngineering.Extensions;
|
|
|
using WCS.WorkEngineering.Worlds;
|
|
@@ -27,16 +30,330 @@ namespace WCS.WorkEngineering.Systems
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- var sw = Stopwatch.StartNew();
|
|
|
- var number = new List<int> { 1, 2, 3, 4, 5 };
|
|
|
- var db = new SqlSugarHelper().PLC; // 提前创建数据库连接
|
|
|
- var pack = RedisHub.Monitor.LPop<DeviceDataPack>("DataCollectionpacks");
|
|
|
+ var sw = new Stopwatch();
|
|
|
+ sw.Start();
|
|
|
|
|
|
- if (pack == null) return;
|
|
|
+ var number = new List<int>();
|
|
|
+ number.AddRange(new[] { 1, 2, 3, 4, 5 });
|
|
|
|
|
|
- Parallel.ForEach(number, n =>
|
|
|
+ var sql1 = "";
|
|
|
+
|
|
|
+ Parallel.ForEach(number, i =>
|
|
|
{
|
|
|
- ProcessPack(db, pack); // 将处理逻辑提取到单独的方法中
|
|
|
+ var db = new SqlSugarHelper().PLC;
|
|
|
+ var pack = RedisHub.Monitor.LPop<DeviceDataPack>("DataCollectionpacks");
|
|
|
+ ;
|
|
|
+ if (pack == null) return;
|
|
|
+
|
|
|
+ Parallel.ForEach(pack.GetType().GetProperties().OrderBy(x => x.Name), ps =>
|
|
|
+ {
|
|
|
+ var sw10 = new Stopwatch();
|
|
|
+ sw10.Start();
|
|
|
+ var typeName = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (ps.PropertyType == typeof(ProtocolData<WCS_BCR80>[]))
|
|
|
+ {
|
|
|
+ if (pack.BCR80.Any())
|
|
|
+ {
|
|
|
+ var value = pack.BCR80.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_BCR80).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_BCR81>[]))
|
|
|
+ {
|
|
|
+ if (pack.BCR81.Any())
|
|
|
+ {
|
|
|
+ var value = pack.BCR81.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_BCR81).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //else if (ps.PropertyType == typeof(ProtocolData<WCS_BCR83>[]))
|
|
|
+ //{
|
|
|
+ // if (pack.BCR83.Any())
|
|
|
+ // {
|
|
|
+ // var value = pack.BCR83.Select(x => x.Data).ToList();
|
|
|
+ // var sql = db.Insertable(value).ToSqlString();
|
|
|
+ // db.Ado.ExecuteCommand(sql);
|
|
|
+ // typeName = typeof(WCS_BCR83).Name;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_RGV520>[]))
|
|
|
+ {
|
|
|
+ if (pack.RGV520.Any())
|
|
|
+ {
|
|
|
+ var value = pack.RGV520.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_RGV520).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_RGV521>[]))
|
|
|
+ {
|
|
|
+ if (pack.RGV521.Any())
|
|
|
+ {
|
|
|
+ var value = pack.RGV521.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_RGV521).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_RGV523>[]))
|
|
|
+ {
|
|
|
+ if (pack.RGV523.Any())
|
|
|
+ {
|
|
|
+ var value = pack.RGV523.Select(x => new QuestDb_RGV523()
|
|
|
+ {
|
|
|
+ Alarm = Convert.ToString(x.Data.Alarm),
|
|
|
+ Code = x.Data.Code,
|
|
|
+ Frame = x.Data.Frame.ToLocalTime()
|
|
|
+ }).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(GetString(sql));
|
|
|
+ typeName = typeof(WCS_RGV523).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot520>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot520.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Robot520.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Robot520).Name.Length.ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot521>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot521.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Robot521.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Robot521).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station5>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station5.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Station5.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Station5).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot522>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot522.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Robot522.Select(x => new QuestDb_Robot522()
|
|
|
+ {
|
|
|
+ Alarm = Convert.ToString(x.Data.Alarm),
|
|
|
+ Code = x.Data.Code,
|
|
|
+ Frame = x.Data.Frame.ToLocalTime()
|
|
|
+ }).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Robot522).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot530>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot530.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Robot530.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Robot530).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot531>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot531.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Robot531.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Robot531).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_SRM520>[]))
|
|
|
+ {
|
|
|
+ if (pack.SRM520.Any())
|
|
|
+ {
|
|
|
+ var value = pack.SRM520.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_SRM520).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_SRM521>[]))
|
|
|
+ {
|
|
|
+ if (pack.SRM521.Any())
|
|
|
+ {
|
|
|
+ var value = pack.SRM521.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_SRM521).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_SRM523>[]))
|
|
|
+ {
|
|
|
+ if (pack.SRM523.Any())
|
|
|
+ {
|
|
|
+ var value = pack.SRM523.Select(x => new QuestDb_SRM523()
|
|
|
+ {
|
|
|
+ Alarm = $"{Convert.ToString(x.Data.Alarm1)},{Convert.ToString(x.Data.Alarm1)}",
|
|
|
+ Code = x.Data.Code,
|
|
|
+ Frame = x.Data.Frame.ToLocalTime()
|
|
|
+ }).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(GetString(sql));
|
|
|
+ typeName = typeof(WCS_SRM523).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station520>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station520.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Station520.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Station520).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station521>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station521.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Station521.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Station521).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station523>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station523.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Station523.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Station523).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station524>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station524.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Station524.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Station524).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station525>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station525.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Station525.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Station525).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station90>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station90.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Station90.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Station90).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station91>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station91.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Station91.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Station91).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss520>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss520.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Truss520.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Truss520).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss521>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss521.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Truss521.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Truss521).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss523>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss523.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Truss523.Select(x => new QuestDb_Truss523()
|
|
|
+ {
|
|
|
+ Alarm = Convert.ToString(x.Data.Alarm),
|
|
|
+ Code = x.Data.Code,
|
|
|
+ Frame = x.Data.Frame.ToLocalTime()
|
|
|
+ }).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Truss523).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss530>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss530.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Truss530.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Truss530).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss531>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss531.Any())
|
|
|
+ {
|
|
|
+ var value = pack.Truss531.Select(x => x.Data).ToList();
|
|
|
+ var sql = db.Insertable(value).ToSqlString();
|
|
|
+ db.Ado.ExecuteCommand(sql);
|
|
|
+ typeName = typeof(WCS_Truss531).Name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ World.Log($"错误内容:{e.Message}");
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ sw10.Stop();
|
|
|
+ World.Log($"执行耗时:{typeName}:{sw10.ElapsedMilliseconds}");
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
sw.Stop();
|
|
@@ -48,429 +365,6 @@ namespace WCS.WorkEngineering.Systems
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 提取逻辑到单独的方法中
|
|
|
- private void ProcessPack(SqlSugarScopeProvider db, DeviceDataPack pack)
|
|
|
- {
|
|
|
- var properties = pack.GetType().GetProperties().OrderBy(x => x.Name);
|
|
|
- foreach (var ps in properties)
|
|
|
- {
|
|
|
- var sw10 = Stopwatch.StartNew();
|
|
|
- var typeName = "";
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- var typeHandled = HandleDataType(db, pack, ps, ref typeName);
|
|
|
- if (!typeHandled) continue; // 如果没有匹配的类型,则跳过
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- World.Log($"错误内容:{e.Message}");
|
|
|
- }
|
|
|
- finally
|
|
|
- {
|
|
|
- sw10.Stop();
|
|
|
- World.Log($"执行耗时:{typeName}:{sw10.ElapsedMilliseconds}");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 根据类型处理数据,返回是否成功处理该类型
|
|
|
- private bool HandleDataType(SqlSugarScopeProvider db, DeviceDataPack pack, PropertyInfo ps, ref string typeName)
|
|
|
- {
|
|
|
- if (ps.PropertyType == typeof(ProtocolData<WCS_Robot520>[]))
|
|
|
- {
|
|
|
- return ProcessSpecificType(db, pack.Robot520, ref typeName);
|
|
|
- }
|
|
|
- if (ps.PropertyType == typeof(ProtocolData<WCS_Robot521>[]))
|
|
|
- {
|
|
|
- return ProcessSpecificType(db, pack.Robot521, ref typeName);
|
|
|
- }
|
|
|
- if (ps.PropertyType == typeof(ProtocolData<WCS_SRM520>[]))
|
|
|
- {
|
|
|
- return ProcessSpecificType(db, pack.SRM520, ref typeName);
|
|
|
- }
|
|
|
- if (ps.PropertyType == typeof(ProtocolData<WCS_SRM521>[]))
|
|
|
- {
|
|
|
- return ProcessSpecificType(db, pack.SRM521, ref typeName);
|
|
|
- }
|
|
|
- if (ps.PropertyType == typeof(ProtocolData<WCS_Truss520>[]))
|
|
|
- {
|
|
|
- return ProcessSpecificType(db, pack.Truss520, ref typeName);
|
|
|
- }
|
|
|
- if (ps.PropertyType == typeof(ProtocolData<WCS_Truss521>[]))
|
|
|
- {
|
|
|
- return ProcessSpecificType(db, pack.Truss521, ref typeName);
|
|
|
- }
|
|
|
- //if (ps.PropertyType == typeof(ProtocolData<WCS_Station222>[]))
|
|
|
- //{
|
|
|
- // return ProcessSpecificType(db, pack.Station222, ref typeName);
|
|
|
- //}
|
|
|
- //if (ps.PropertyType == typeof(ProtocolData<WCS_Station5>[]))
|
|
|
- //{
|
|
|
- // return ProcessSpecificType(db, pack.Station5, ref typeName);
|
|
|
- //}
|
|
|
- // 添加更多类型处理...
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 处理具体类型的数据,并执行数据库操作
|
|
|
- private bool ProcessSpecificType<T>(SqlSugarScopeProvider db, ProtocolData<T>[] data, ref string typeName) where T : class
|
|
|
- {
|
|
|
- if (data == null || data.Length == 0) return false;
|
|
|
-
|
|
|
- var value = data.ToList().Select(x => x.Data).ToList();
|
|
|
- var sql = db.Insertable(value).ToSqlString();
|
|
|
- var res = QuestDbInsert(sql);
|
|
|
- typeName = typeof(T).Name;
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- //private bool ProcessSpecificTypeAlarm<T>(SqlSugarScopeProvider db, ProtocolData<T>[] data, ref string typeName) where T : class
|
|
|
- //{
|
|
|
- // if (data == null || data.Length == 0) return false;
|
|
|
-
|
|
|
- // typeName = typeof(T).Name;
|
|
|
- // var value = pack.RGV523.Select(x => new QuestDb_RGV523()
|
|
|
- // {
|
|
|
- // Alarm = Convert.ToString(x.Data.Alarm),
|
|
|
- // Code = x.Data.Code,
|
|
|
- // Frame = x.Data.Frame.ToLocalTime()
|
|
|
- // }).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(GetString(sql));
|
|
|
- // typeName = typeof(WCS_RGV523).Name;
|
|
|
- // return true;
|
|
|
- //}
|
|
|
-
|
|
|
- //public override void Update(List<WorkTimes> list)
|
|
|
- //{
|
|
|
- // try
|
|
|
- // {
|
|
|
- // var sw = new Stopwatch();
|
|
|
- // sw.Start();
|
|
|
-
|
|
|
- // var number = new List<int>();
|
|
|
- // number.AddRange(new[] { 1, 2, 3, 4, 5 });
|
|
|
-
|
|
|
- // var sql1 = "";
|
|
|
-
|
|
|
- // foreach (var n in number)
|
|
|
- // {
|
|
|
- // var db = new SqlSugarHelper().PLC;
|
|
|
- // var pack = RedisHub.Monitor.LPop<DeviceDataPack>("DataCollectionpacks"); ;
|
|
|
- // if (pack == null) return;
|
|
|
-
|
|
|
- // Parallel.ForEach(pack.GetType().GetProperties().OrderBy(x => x.Name), ps =>
|
|
|
- // {
|
|
|
- // var sw10 = new Stopwatch();
|
|
|
- // sw10.Start();
|
|
|
- // var typeName = "";
|
|
|
- // try
|
|
|
- // {
|
|
|
- // //if (ps.PropertyType == typeof(ProtocolData<WCS_BCR80>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.BCR80.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.BCR80.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_BCR80).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_BCR81>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.BCR81.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.BCR81.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_BCR81).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_BCR83>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.BCR83.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.BCR83.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_BCR83).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // if (ps.PropertyType == typeof(ProtocolData<WCS_RGV520>[]))
|
|
|
- // {
|
|
|
- // if (pack.RGV520.Any())
|
|
|
- // {
|
|
|
- // var value = pack.RGV520.Select(x => x.Data).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_RGV520).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_RGV521>[]))
|
|
|
- // {
|
|
|
- // if (pack.RGV521.Any())
|
|
|
- // {
|
|
|
- // var value = pack.RGV521.Select(x => x.Data).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_RGV521).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_RGV523>[]))
|
|
|
- // {
|
|
|
- // if (pack.RGV523.Any())
|
|
|
- // {
|
|
|
- // var value = pack.RGV523.Select(x => new QuestDb_RGV523()
|
|
|
- // {
|
|
|
- // Alarm = Convert.ToString(x.Data.Alarm),
|
|
|
- // Code = x.Data.Code,
|
|
|
- // Frame = x.Data.Frame.ToLocalTime()
|
|
|
- // }).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(GetString(sql));
|
|
|
- // typeName = typeof(WCS_RGV523).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot520>[]))
|
|
|
- // {
|
|
|
- // if (pack.Robot520.Any())
|
|
|
- // {
|
|
|
- // var value = pack.Robot520.Select(x => x.Data).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_Robot520).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot521>[]))
|
|
|
- // {
|
|
|
- // if (pack.Robot521.Any())
|
|
|
- // {
|
|
|
- // var value = pack.Robot521.Select(x => x.Data).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_Robot521).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot522>[]))
|
|
|
- // {
|
|
|
- // if (pack.Robot522.Any())
|
|
|
- // {
|
|
|
- // var value = pack.Robot522.Select(x => new QuestDb_Robot522()
|
|
|
- // {
|
|
|
- // Alarm = Convert.ToString(x.Data.Alarm),
|
|
|
- // Code = x.Data.Code,
|
|
|
- // Frame = x.Data.Frame.ToLocalTime()
|
|
|
- // }).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_Robot522).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot530>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Robot530.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Robot530.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Robot530).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot531>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Robot531.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Robot531.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Robot531).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_SRM520>[]))
|
|
|
- // {
|
|
|
- // if (pack.SRM520.Any())
|
|
|
- // {
|
|
|
- // var value = pack.SRM520.Select(x => x.Data).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_SRM520).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_SRM521>[]))
|
|
|
- // {
|
|
|
- // if (pack.SRM521.Any())
|
|
|
- // {
|
|
|
- // var value = pack.SRM521.Select(x => x.Data).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_SRM521).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_SRM523>[]))
|
|
|
- // {
|
|
|
- // if (pack.SRM523.Any())
|
|
|
- // {
|
|
|
- // var value = pack.SRM523.Select(x => new QuestDb_SRM523()
|
|
|
- // {
|
|
|
- // Alarm = $"{Convert.ToString(x.Data.Alarm1)},{Convert.ToString(x.Data.Alarm1)}",
|
|
|
- // Code = x.Data.Code,
|
|
|
- // Frame = x.Data.Frame.ToLocalTime()
|
|
|
- // }).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(GetString(sql));
|
|
|
- // typeName = typeof(WCS_SRM523).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Station520>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Station520.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Station520.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Station520).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Station521>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Station521.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Station521.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Station521).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Station523>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Station523.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Station523.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Station523).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Station524>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Station524.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Station524.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
-
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Station524).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Station525>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Station525.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Station525.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Station525).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Station90>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Station90.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Station90.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Station90).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_Station91>[]))
|
|
|
- // {
|
|
|
- // if (pack.Station91.Any())
|
|
|
- // {
|
|
|
- // var value = pack.Station91.Select(x => x.Data).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_Station91).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss520>[]))
|
|
|
- // {
|
|
|
- // if (pack.Truss520.Any())
|
|
|
- // {
|
|
|
- // var value = pack.Truss520.Select(x => x.Data).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_Truss520).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss521>[]))
|
|
|
- // {
|
|
|
- // if (pack.Truss521.Any())
|
|
|
- // {
|
|
|
- // var value = pack.Truss521.Select(x => x.Data).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_Truss521).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss523>[]))
|
|
|
- // {
|
|
|
- // if (pack.Truss523.Any())
|
|
|
- // {
|
|
|
- // var value = pack.Truss523.Select(x => new QuestDb_Truss523()
|
|
|
- // {
|
|
|
- // Alarm = Convert.ToString(x.Data.Alarm),
|
|
|
- // Code = x.Data.Code,
|
|
|
- // Frame = x.Data.Frame.ToLocalTime()
|
|
|
- // }).ToList();
|
|
|
- // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // var res = QuestDbInsert(sql);
|
|
|
- // typeName = typeof(WCS_Truss523).Name;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss530>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Truss530.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Truss530.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Truss530).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss531>[]))
|
|
|
- // //{
|
|
|
- // // if (pack.Truss531.Any())
|
|
|
- // // {
|
|
|
- // // var value = pack.Truss531.Select(x => x.Data).ToList();
|
|
|
- // // var sql = db.Insertable(value).ToSqlString();
|
|
|
- // // db.Ado.ExecuteCommand(sql);
|
|
|
- // // typeName = typeof(WCS_Truss531).Name;
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // }
|
|
|
- // catch (Exception e)
|
|
|
- // {
|
|
|
- // World.Log($"错误内容:{e.Message}");
|
|
|
- // }
|
|
|
- // finally
|
|
|
- // {
|
|
|
- // sw10.Stop();
|
|
|
- // World.Log($"执行耗时:{typeName}:{sw10.ElapsedMilliseconds}");
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
-
|
|
|
- // sw.Stop();
|
|
|
- // World.Log($"数据处理耗时:{sw.ElapsedMilliseconds}");
|
|
|
- // }
|
|
|
- // catch (Exception e)
|
|
|
- // {
|
|
|
- // World.Log($"错误内容:{e.Message}");
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
private Type GetProtocolType(Type source)
|
|
|
{
|
|
|
var t = source.GetInterfaces().FirstOrDefault(v => v.GetInterfaces().Any(d => d.Name == "IProtocol"));
|
|
@@ -511,8 +405,8 @@ namespace WCS.WorkEngineering.Systems
|
|
|
.AddParameter("query", query)
|
|
|
.AddParameter("timings", "true");
|
|
|
var response = client.Get<QuestDbResponse>(request);
|
|
|
- //Console.WriteLine(response.ddl);
|
|
|
- //var res = APICaller.CallApi1<QuestDbResponse>("http://10.30.37.2:9000" + "/exec", $"?limit=0,1000&explain=true&count=true&src=con&query={query}&timings=true", "GET");
|
|
|
+ Console.WriteLine(response.ddl);
|
|
|
+ var res = APICaller.CallApi1<QuestDbResponse>("http://10.30.37.2:9000" + "/exec", $"?limit=0,1000&explain=true&count=true&src=con&query={query}&timings=true", "GET");
|
|
|
return true;
|
|
|
}
|
|
|
}
|