|
|
@@ -9,8 +9,13 @@ using System.ComponentModel;
|
|
|
using System.Diagnostics;
|
|
|
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;
|
|
|
|
|
|
@@ -65,11 +70,11 @@ namespace WCS.WorkEngineering.Systems
|
|
|
var sw = new Stopwatch();
|
|
|
sw.Start();
|
|
|
var pack = new DeviceDataPack();
|
|
|
+ var frame = DateTime.Now;
|
|
|
pack.Frame = World.Frame;
|
|
|
sql.Append("INSERT INTO ");
|
|
|
var ps = pack.GetType().GetProperties().OrderBy(x => x.Name);
|
|
|
var db = new SqlSugarHelper().PLC;
|
|
|
- var frame = DateTime.Now;
|
|
|
Parallel.ForEach(ps, p =>
|
|
|
{
|
|
|
if (!p.PropertyType.IsArray) return;
|
|
|
@@ -99,7 +104,7 @@ namespace WCS.WorkEngineering.Systems
|
|
|
|
|
|
var obj = Activator.CreateInstance(t);
|
|
|
t.GetProperty("Code").SetValue(obj, x.Code);
|
|
|
- var value = WCS.Core.Extentions.Copy(protObj, entType, protObj.Frame);
|
|
|
+ var value = WCS.Core.Extentions.Copy(protObj, entType, frame);
|
|
|
t.GetProperty("Data").SetValue(obj, value);
|
|
|
t.GetProperty("Frame").SetValue(obj, protObj.Frame);
|
|
|
entType.GetProperty("Code").SetValue(value, x.Code);
|
|
|
@@ -221,31 +226,110 @@ namespace WCS.WorkEngineering.Systems
|
|
|
var sw4 = new Stopwatch();
|
|
|
sw4.Start();
|
|
|
|
|
|
- if (pack.BCR80.Any()) db.Insertable(pack.BCR80.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.BCR81.Any()) db.Insertable(pack.BCR81.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.BCR83.Any()) db.Insertable(pack.BCR83.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.RGV520.Any()) db.Insertable(pack.RGV520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.RGV521.Any()) db.Insertable(pack.RGV521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Robot520.Any()) db.Insertable(pack.Robot520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Robot521.Any()) db.Insertable(pack.Robot521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Robot522.Any()) db.Insertable(pack.Robot522.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Robot530.Any()) db.Insertable(pack.Robot530.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Robot531.Any()) db.Insertable(pack.Robot531.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.SRM520.Any()) db.Insertable(pack.SRM520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.SRM521.Any()) db.Insertable(pack.SRM521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.SRM537.Any()) db.Insertable(pack.SRM537.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Station520.Any()) db.Insertable(pack.Station520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Station521.Any()) db.Insertable(pack.Station521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Station523.Any()) db.Insertable(pack.Station523.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Station524.Any()) db.Insertable(pack.Station524.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Station525.Any()) db.Insertable(pack.Station525.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Station90.Any()) db.Insertable(pack.Station90.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Station91.Any()) db.Insertable(pack.Station91.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Truss520.Any()) db.Insertable(pack.Truss520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Truss521.Any()) db.Insertable(pack.Truss521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Truss523.Any()) db.Insertable(pack.Truss523.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Truss530.Any()) db.Insertable(pack.Truss530.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
- if (pack.Truss531.Any()) db.Insertable(pack.Truss531.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ Parallel.ForEach(pack.GetType().GetProperties().OrderBy(x => x.Name), ps =>
|
|
|
+ {
|
|
|
+ if (ps.PropertyType == typeof(ProtocolData<WCS_BCR80>[]))
|
|
|
+ {
|
|
|
+ if (pack.BCR80.Any()) db.Insertable(pack.BCR80.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_BCR81>[]))
|
|
|
+ {
|
|
|
+ if (pack.BCR81.Any()) db.Insertable(pack.BCR81.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_BCR83>[]))
|
|
|
+ {
|
|
|
+ if (pack.BCR83.Any()) db.Insertable(pack.BCR83.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_RGV520>[]))
|
|
|
+ {
|
|
|
+ if (pack.RGV520.Any()) db.Insertable(pack.RGV520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_RGV521>[]))
|
|
|
+ {
|
|
|
+ if (pack.RGV521.Any()) db.Insertable(pack.RGV521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot520>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot520.Any()) db.Insertable(pack.Robot520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot521>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot521.Any()) db.Insertable(pack.Robot521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot522>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot522.Any()) db.Insertable(pack.Robot522.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot530>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot530.Any()) db.Insertable(pack.Robot530.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Robot531>[]))
|
|
|
+ {
|
|
|
+ if (pack.Robot531.Any()) db.Insertable(pack.Robot531.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_SRM520>[]))
|
|
|
+ {
|
|
|
+ if (pack.SRM520.Any()) db.Insertable(pack.SRM520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_SRM521>[]))
|
|
|
+ {
|
|
|
+ if (pack.SRM521.Any()) db.Insertable(pack.SRM521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_SRM537>[]))
|
|
|
+ {
|
|
|
+ if (pack.SRM537.Any()) db.Insertable(pack.SRM537.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station520>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station520.Any()) db.Insertable(pack.Station520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station521>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station521.Any()) db.Insertable(pack.Station521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station523>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station523.Any()) db.Insertable(pack.Station523.Select(x => x.Data).ToList()).UseParameter().ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station524>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station524.Any()) db.Insertable(pack.Station524.Select(x => x.Data).ToList()).UseParameter().ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station525>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station525.Any()) db.Insertable(pack.Station525.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station90>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station90.Any()) db.Insertable(pack.Station90.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Station91>[]))
|
|
|
+ {
|
|
|
+ if (pack.Station91.Any()) db.Insertable(pack.Station91.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss520>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss520.Any()) db.Insertable(pack.Truss520.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss521>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss521.Any()) db.Insertable(pack.Truss521.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss523>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss523.Any()) db.Insertable(pack.Truss523.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss530>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss530.Any()) db.Insertable(pack.Truss530.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ else if (ps.PropertyType == typeof(ProtocolData<WCS_Truss531>[]))
|
|
|
+ {
|
|
|
+ if (pack.Truss531.Any()) db.Insertable(pack.Truss531.Select(x => x.Data).ToList()).ExecuteCommand();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
sw4.Stop();
|
|
|
World.Log($"执行SQL耗时:{sw4.ElapsedMilliseconds}");
|
|
|
|