diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml index 751d7ed6..da0e9700 100644 --- a/Admin.Core.Api/Admin.Core.Model.xml +++ b/Admin.Core.Api/Admin.Core.Model.xml @@ -461,61 +461,6 @@ 接收从条码系统获取的校验字符串 - - - 箱体发泡数据 - - - - - 主键标识 - - - - - 夹具类型 - - - - - 夹具状态;1正常生产、0暂停生产 - - - - - 夹具产量 - - - - - 侧板温度 - - - - - 内模温度 - - - - - 节拍 - - - - - 发泡量 - - - - - 创建时间 - - - - - 创建时间 - - 物料完成记录 @@ -1121,6 +1066,286 @@ 所属工厂 + + + 设备 + + + + + 主键 + + + + + 产品线 1、2 + + + + + 设备编码 + + + + + 排序 + + + + + 每班发泡信息 + + + + + 主键 + + + + + 设备表主键 + + + + + SAP订单 + + + + + 产品线 1、2 + + + + + 夹具箱型 + + + + + 夹具状态:0:停止;1生产 + + + + + 产量 + + + + + 固化时间设定值 + + + + + 固化时间实际值 + + + + + 1小时 + + + + + 2小时 + + + + + 3小时 + + + + + 4小时 + + + + + 5小时 + + + + + 6小时 + + + + + 7小时 + + + + + 8小时 + + + + + 9小时 + + + + + 10小时 + + + + + 11小时 + + + + + 12小时 + + + + + 侧板温度 + + + + + 内模温度 + + + + + 节拍 + + + + + 更新时间 + + + + + 每日发泡信息数据记录表 + + + + + 主键 + + + + + 产线 1、2 + + + + + 订单编码 + + + + + 夹具箱型 + + + + + 夹具状态:0:停止;1生产 + + + + + 产量 + + + + + 固化时间设定值 + + + + + 固化时间实际值 + + + + + 1小时 + + + + + 2小时 + + + + + 3小时 + + + + + 4小时 + + + + + 5小时 + + + + + 6小时 + + + + + 7小时 + + + + + 8小时 + + + + + 9小时 + + + + + 10小时 + + + + + 11小时 + + + + + 12小时 + + + + + 侧板温度 + + + + + 内模温度 + + + + + 节拍 + + + + + 更新时间 + + 发泡计划 @@ -1131,11 +1356,6 @@ 主键标识 - - - BOM编号 - - 物料编号 @@ -1351,6 +1571,31 @@ plc放行标志,2为放行通过,1为pda提示需要放行记录 + + + 存储当班班组 + + + + + 主键 + + + + + 班组名称 + + + + + 开始时间 + + + + + 结束时间 + + 电检数据明细 @@ -1561,51 +1806,6 @@ 所属产线 - - - 拆分的SAP BOM 信息 - - - - - 主键 - - - - - 夹具箱型 - - - - - 夹具状态 - - - - - 产量 - - - - - 固化时间设定值 - - - - - 固化时间实际值 - - - - - 创建时间 - - - - - 更新时间 - - 灌注告警 @@ -3801,6 +4001,36 @@ 数量 + + + 获取每日班组时间 + + + + + 开始时间 + + + + + 开始时间 + + + + + 结束时间 + + + + + 小时 + + + + + 班组 + + 泡前库入库相信展示 diff --git a/Admin.Core.Common/Helper/UnicodeHelper.cs b/Admin.Core.Common/Helper/UnicodeHelper.cs index 8007037d..032e2e6d 100644 --- a/Admin.Core.Common/Helper/UnicodeHelper.cs +++ b/Admin.Core.Common/Helper/UnicodeHelper.cs @@ -43,5 +43,24 @@ namespace Admin.Core.Common //} //return resultStr; } + /// + /// Bytes转16进制字符 + /// + /// + /// + /// + public static string BytesToHexStr(byte[] bytes, int iLen)//e.g. { 0x01, 0x01} ---> " 01 01" + { + string returnStr = ""; + if (bytes != null) + { + for (int i = 0; i < iLen; i++) + { + returnStr += bytes[i].ToString("X2"); + } + } + return returnStr; + } + } } diff --git a/Admin.Core.IRepository/IRepository_New/IBoxDeviceInfoRepository.cs b/Admin.Core.IRepository/IRepository_New/IBoxDeviceInfoRepository.cs new file mode 100644 index 00000000..edc3043d --- /dev/null +++ b/Admin.Core.IRepository/IRepository_New/IBoxDeviceInfoRepository.cs @@ -0,0 +1,14 @@ +using Admin.Core.Model; +using Admin.Core.Model.Model_New; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Admin.Core.IRepository +{ + /// + /// IBoxDeviceInfoRepository + /// + public interface IBoxDeviceInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/Admin.Core.IRepository/IRepository_New/IBoxFoamDataRecordRepository.cs b/Admin.Core.IRepository/IRepository_New/IBoxFoamDataRecordRepository.cs new file mode 100644 index 00000000..0381b66f --- /dev/null +++ b/Admin.Core.IRepository/IRepository_New/IBoxFoamDataRecordRepository.cs @@ -0,0 +1,15 @@ +using Admin.Core.Model; +using Admin.Core.Model.Model_New; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Admin.Core.IRepository +{ + /// + /// IBoxFoamDataRecordRepository + /// + public interface IBoxFoamDataRecordRepository : IBaseRepository + { + + } +} \ No newline at end of file diff --git a/Admin.Core.IRepository/IRepository_New/ICurrentTeamTimeRepository.cs b/Admin.Core.IRepository/IRepository_New/ICurrentTeamTimeRepository.cs new file mode 100644 index 00000000..900ed1bb --- /dev/null +++ b/Admin.Core.IRepository/IRepository_New/ICurrentTeamTimeRepository.cs @@ -0,0 +1,20 @@ +using Admin.Core.Model; +using Admin.Core.Model.Model_New; +using Admin.Core.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Admin.Core.IRepository +{ + /// + /// ICurrentTeamTimeRepository + /// + public interface ICurrentTeamTimeRepository : IBaseRepository + { + /// + /// 获取班组数据 + /// + /// + // Task> GetTeamData(); + } +} \ No newline at end of file diff --git a/Admin.Core.IRepository/IRepository_New/IOldBoxFoamDataRepository.cs b/Admin.Core.IRepository/IRepository_New/IOldBoxFoamDataRepository.cs deleted file mode 100644 index 3a2bd104..00000000 --- a/Admin.Core.IRepository/IRepository_New/IOldBoxFoamDataRepository.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Admin.Core.Model; -using Admin.Core.Model.Model_New; - -namespace Admin.Core.IRepository -{ - /// - /// IOldBoxFoamDataRepository - /// - public interface IOldBoxFoamDataRepository : IBaseRepository - { - } -} \ No newline at end of file diff --git a/Admin.Core.IRepository/IRepository_New/ISysUserInfoRepository.cs b/Admin.Core.IRepository/IRepository_New/ISysUserInfoRepository.cs index 04a53990..b760f99b 100644 --- a/Admin.Core.IRepository/IRepository_New/ISysUserInfoRepository.cs +++ b/Admin.Core.IRepository/IRepository_New/ISysUserInfoRepository.cs @@ -1,5 +1,8 @@ using Admin.Core.Model; using Admin.Core.Model.Model_New; +using Admin.Core.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; namespace Admin.Core.IRepository { @@ -8,6 +11,10 @@ namespace Admin.Core.IRepository /// public interface ISysUserInfoRepository : IBaseRepository { - + /// + /// 获取班组数据 + /// + /// + Task> GetTeamData(); } } \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/IOldBoxFoamDataServices.cs b/Admin.Core.IService/IService_New/BoxDeviceInfoServices.cs similarity index 68% rename from Admin.Core.IService/IService_New/IOldBoxFoamDataServices.cs rename to Admin.Core.IService/IService_New/BoxDeviceInfoServices.cs index ffa10771..c69ac49f 100644 --- a/Admin.Core.IService/IService_New/IOldBoxFoamDataServices.cs +++ b/Admin.Core.IService/IService_New/BoxDeviceInfoServices.cs @@ -7,9 +7,9 @@ using System.Threading.Tasks; namespace Admin.Core.IService { /// - /// IOldBoxFoamDataServices + /// IBoxDeviceInfoServices /// - public interface IOldBoxFoamDataServices : IBaseServices + public interface IBoxDeviceInfoServices : IBaseServices { } diff --git a/Admin.Core.IService/IService_New/IBoxFoamDataRecordServices.cs b/Admin.Core.IService/IService_New/IBoxFoamDataRecordServices.cs new file mode 100644 index 00000000..a6397bd9 --- /dev/null +++ b/Admin.Core.IService/IService_New/IBoxFoamDataRecordServices.cs @@ -0,0 +1,16 @@ +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Admin.Core.IService +{ + /// + /// IBoxFoamDataRecordServices + /// + public interface IBoxFoamDataRecordServices : IBaseServices + { + + } +} \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/ICurrentTeamTimeServices.cs b/Admin.Core.IService/IService_New/ICurrentTeamTimeServices.cs new file mode 100644 index 00000000..94b38665 --- /dev/null +++ b/Admin.Core.IService/IService_New/ICurrentTeamTimeServices.cs @@ -0,0 +1,17 @@ +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Model.ViewModels; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Admin.Core.IService +{ + /// + /// ISysUserInfoServices + /// + public interface ICurrentTeamTimeServices : IBaseServices + { + + } +} \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/ISysUserInfoServices.cs b/Admin.Core.IService/IService_New/ISysUserInfoServices.cs index 96178765..7c1bbb29 100644 --- a/Admin.Core.IService/IService_New/ISysUserInfoServices.cs +++ b/Admin.Core.IService/IService_New/ISysUserInfoServices.cs @@ -1,5 +1,7 @@ using Admin.Core.IService; using Admin.Core.Model; +using Admin.Core.Model.ViewModels; +using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -10,5 +12,11 @@ namespace Admin.Core.IService /// public interface ISysUserInfoServices : IBaseServices { + /// + /// 获取当前班组 + /// + /// + /// + Task GetTeamData(DateTime nowDate); } } \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/BoxDeviceInfo.cs b/Admin.Core.Model/Model_New/BoxDeviceInfo.cs new file mode 100644 index 00000000..010db70c --- /dev/null +++ b/Admin.Core.Model/Model_New/BoxDeviceInfo.cs @@ -0,0 +1,38 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model +{ + /// + /// 设备 + /// + [SugarTable("BOX_DEVICEINFO", "AUCMA_SCADA")] + public class BoxDeviceInfo + { + /// + /// 主键 + /// + [SugarColumn(ColumnName = "OBJ_ID", IsIdentity = true, IsPrimaryKey = true)] + public int ObjId { get; set; } + + /// + /// 产品线 1、2 + /// + [SugarColumn(ColumnName = "PRODUCT_LINE_CODE")] + public string ProductLineCode { get; set; } + /// + /// 设备编码 + /// + [SugarColumn(ColumnName = "EQUIPMENT_CODE")] + public string EquipmentCode { get; set; } + /// + /// 排序 + /// + [SugarColumn(ColumnName = "SORT")] + public int Sort { get; set; } + } +} diff --git a/Admin.Core.Model/Model_New/BoxFoamData.cs b/Admin.Core.Model/Model_New/BoxFoamData.cs index b994bcf6..2b0cc2bb 100644 --- a/Admin.Core.Model/Model_New/BoxFoamData.cs +++ b/Admin.Core.Model/Model_New/BoxFoamData.cs @@ -1,41 +1,122 @@ using SqlSugar; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Admin.Core.Model.Model_New +namespace Admin.Core.Model { /// - /// 箱体发泡数据 + /// 每班发泡信息 /// [SugarTable("BOX_FOAMDATA", "AUCMA_SCADA")] public class BoxFoamData { /// - /// 主键标识 - /// - [SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true)] + /// 主键 + /// + [SugarColumn(ColumnName = "OBJ_ID", IsIdentity = true, IsPrimaryKey = true)] public int ObjId { get; set; } - /// - /// 夹具类型 + /// 设备表主键 + /// + [SugarColumn(ColumnName = "MAINID")] + public int MainId { get; set; } + /// + /// SAP订单 + /// + [SugarColumn(ColumnName = "ORDER_CODE")] + public string OrderCode { get; set; } + + /// + /// 产品线 1、2 /// - [SugarColumn(ColumnName = "BOX_FIXTURETYPE")] - public string BoxFixturetype { get; set; } + [SugarColumn(ColumnName = "PRODUCT_LINE_CODE")] + public string ProductLineCode { get; set; } + /// + /// 夹具箱型 + /// + [SugarColumn(ColumnName = "FIXTUREBOXTYPE")] + public string Fixtureboxtype { get; set; } /// - /// 夹具状态;1正常生产、0暂停生产 + /// 夹具状态:0:停止;1生产 /// - [SugarColumn(ColumnName = "BOX_FIXTURESTATUS")] - public int BoxFixturestatus { get; set; } + [SugarColumn(ColumnName = "FIXTURESTATUS")] + public int Fixturestatus { get; set; } + /// + /// 产量 + /// + [SugarColumn(ColumnName = "PRODUCTION")] + public int Production { get; set; } + /// + /// 固化时间设定值 + /// + [SugarColumn(ColumnName = "CURINGTIMESETTINGVALUE")] + public string CuringTimeSettingValue { get; set; } + /// + /// 固化时间实际值 + /// + [SugarColumn(ColumnName = "ACTUALVALUE")] + public string ActualValue { get; set; } /// - /// 夹具产量 + /// 1小时 + /// + [SugarColumn(ColumnName = "ANHOUR")] + public int AnHour { get; set; } + /// + /// 2小时 /// - [SugarColumn(ColumnName = "BOX_FIXTUREPRODUCTION")] - public int BoxFixtureproduction { get; set; } + [SugarColumn(ColumnName = "TWOHOUR")] + public int TwoHour { get; set; } + /// + /// 3小时 + /// + [SugarColumn(ColumnName = "THREEHOUR")] + public int ThreeHour { get; set; } + /// + /// 4小时 + /// + [SugarColumn(ColumnName = "FOURHOUR")] + public int FourHour { get; set; } + /// + /// 5小时 + /// + [SugarColumn(ColumnName = "FIVEHOUR")] + public int FiveHour { get; set; } + /// + /// 6小时 + /// + [SugarColumn(ColumnName = "SIXHOUR")] + public int SixHour { get; set; } + /// + /// 7小时 + /// + [SugarColumn(ColumnName = "SEVENHOUR")] + public int SevenHour { get; set; } + /// + /// 8小时 + /// + [SugarColumn(ColumnName = "EIGHTHOUR")] + public int EightHour { get; set; } + /// + /// 9小时 + /// + [SugarColumn(ColumnName = "NINEHOUR")] + public int NineHour { get; set; } + /// + /// 10小时 + /// + [SugarColumn(ColumnName = "TENHOUR")] + public int TenHour { get; set; } + /// + /// 11小时 + /// + [SugarColumn(ColumnName = "ELEVENHOUR")] + public int ElevenHour { get; set; } + /// + /// 12小时 + /// + [SugarColumn(ColumnName = "TWELVEHOUR")] + public int TwelveHour { get; set; } /// /// 侧板温度 @@ -55,19 +136,9 @@ namespace Admin.Core.Model.Model_New [SugarColumn(ColumnName = "BOX_BEAT")] public int BoxBeat { get; set; } /// - ///发泡量 - /// - [SugarColumn(ColumnName = "BOX_BEAT")] - public int FoamVolume { get; set; } - /// - /// 创建时间 - /// - [SugarColumn(ColumnName = "CREATETIME")] - public DateTime Createtime { get; set; } - /// - /// 创建时间 + /// 更新时间 /// - [SugarColumn(ColumnName = "CREATETIME")] - public DateTime UpdateTime { get; set; } + [SugarColumn(ColumnName = "UPDATETIME")] + public DateTime UpdatedTime { get; set; } } } diff --git a/Admin.Core.Model/Model_New/BoxFoamDataRecord.cs b/Admin.Core.Model/Model_New/BoxFoamDataRecord.cs new file mode 100644 index 00000000..fb63bbe7 --- /dev/null +++ b/Admin.Core.Model/Model_New/BoxFoamDataRecord.cs @@ -0,0 +1,142 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model +{ + /// + /// 每日发泡信息数据记录表 + /// + [SugarTable("BOX_FOAMDATARECORD", "AUCMA_SCADA")] + public class BoxFoamDataRecord + { + /// + /// 主键 + /// + [SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, IsIdentity = true)] + public int Obj_Id { get; set; } + /// + /// 产线 1、2 + /// + [SugarColumn(ColumnName = "PRODUCT_LINE_CODE")] + public string ProductLineCode { get; set; } + /// + /// 订单编码 + /// + [SugarColumn(ColumnName = "ORDER_CODE")] + public string OrderCode { get; set; } + /// + /// 夹具箱型 + /// + [SugarColumn(ColumnName = "FIXTUREBOXTYPE")] + public string Fixtureboxtype { get; set; } + + /// + /// 夹具状态:0:停止;1生产 + /// + [SugarColumn(ColumnName = "FIXTURESTATUS")] + public int Fixturestatus { get; set; } + /// + /// 产量 + /// + [SugarColumn(ColumnName = "PRODUCTION")] + public int Production { get; set; } + /// + /// 固化时间设定值 + /// + [SugarColumn(ColumnName = "CURINGTIMESETTINGVALUE")] + public string CuringTimeSettingValue { get; set; } + /// + /// 固化时间实际值 + /// + [SugarColumn(ColumnName = "ACTUALVALUE")] + public string ActualValue { get; set; } + + /// + /// 1小时 + /// + [SugarColumn(ColumnName = "ANHOUR")] + public int AnHour { get; set; } + /// + /// 2小时 + /// + [SugarColumn(ColumnName = "TWOHOUR")] + public int TwoHour { get; set; } + /// + /// 3小时 + /// + [SugarColumn(ColumnName = "THREEHOUR")] + public int ThreeHour { get; set; } + /// + /// 4小时 + /// + [SugarColumn(ColumnName = "FOURHOUR")] + public int FourHour { get; set; } + /// + /// 5小时 + /// + [SugarColumn(ColumnName = "FIVEHOUR")] + public int FiveHour { get; set; } + /// + /// 6小时 + /// + [SugarColumn(ColumnName = "SIXHOUR")] + public int SixHour { get; set; } + /// + /// 7小时 + /// + [SugarColumn(ColumnName = "SEVENHOUR")] + public int SevenHour { get; set; } + /// + /// 8小时 + /// + [SugarColumn(ColumnName = "EIGHTHOUR")] + public int EightHour { get; set; } + /// + /// 9小时 + /// + [SugarColumn(ColumnName = "NINEHOUR")] + public int NineHour { get; set; } + /// + /// 10小时 + /// + [SugarColumn(ColumnName = "TENHOUR")] + public int TenHour { get; set; } + /// + /// 11小时 + /// + [SugarColumn(ColumnName = "ELEVENHOUR")] + public int ElevenHour { get; set; } + /// + /// 12小时 + /// + [SugarColumn(ColumnName = "TWELVEHOUR")] + public int TwelveHour { get; set; } + + /// + /// 侧板温度 + /// + [SugarColumn(ColumnName = "BOX_FIXTURESIDEPLATE")] + public string BoxFixturesideplate { get; set; } + + /// + /// 内模温度 + /// + [SugarColumn(ColumnName = "BOX_CLOSEBETATEMPERATURE")] + public string BoxClosebetatemperature { get; set; } + + /// + /// 节拍 + /// + [SugarColumn(ColumnName = "BOX_BEAT")] + public int BoxBeat { get; set; } + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "CREATETIME")] + public DateTime CreateTime { get; set; } + } +} diff --git a/Admin.Core.Model/Model_New/BoxFoamplan.cs b/Admin.Core.Model/Model_New/BoxFoamplan.cs index a503ecd7..f10495a3 100644 --- a/Admin.Core.Model/Model_New/BoxFoamplan.cs +++ b/Admin.Core.Model/Model_New/BoxFoamplan.cs @@ -14,13 +14,6 @@ namespace Admin.Core.Model /// [SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, IsIdentity = true)] public int ObjId { get; set; } - - /// - /// BOM编号 - /// - [SugarColumn(ColumnName = "BOX_PLANID")] - public string BoxPlanId { get; set; } - /// /// 物料编号 /// diff --git a/Admin.Core.Model/Model_New/CurrentTeamTime.cs b/Admin.Core.Model/Model_New/CurrentTeamTime.cs new file mode 100644 index 00000000..639fca2d --- /dev/null +++ b/Admin.Core.Model/Model_New/CurrentTeamTime.cs @@ -0,0 +1,33 @@ +using SqlSugar; +using System; + +namespace Admin.Core.Model +{ + /// + /// 存储当班班组 + /// + [SugarTable("CURRENTTEAMTIME", "AUCMA_SCADA")] + public class CurrentTeamTime + { + /// + /// 主键 + /// + [SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, IsIdentity = true)] + public int Obj_Id { get; set; } + /// + /// 班组名称 + /// + [SugarColumn(ColumnName = "TEAMNAME")] + public string TeamName { get; set; } + /// + /// 开始时间 + /// + [SugarColumn(ColumnName = "STARTTIME")] + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + [SugarColumn(ColumnName = "ENDTIME")] + public DateTime EndTime { get; set; } + } +} diff --git a/Admin.Core.Model/Model_New/OldBoxFoamData.cs b/Admin.Core.Model/Model_New/OldBoxFoamData.cs deleted file mode 100644 index 3b61e059..00000000 --- a/Admin.Core.Model/Model_New/OldBoxFoamData.cs +++ /dev/null @@ -1,59 +0,0 @@ -using SqlSugar; -using System; - -namespace Admin.Core.Model -{ - /// - /// 拆分的SAP BOM 信息 - /// - [SugarTable("OLDBOX_FOAMDATA", "AUCMA_SCADA")] - public class OldBoxFoamData - { - /// - /// 主键 - /// - [SugarColumn(ColumnName = "OBJ_ID", IsIdentity = true, IsPrimaryKey = true)] - public int ObjId { get; set; } - - /// - /// 夹具箱型 - /// - [SugarColumn(ColumnName = "FIXTUREBOXTYPE")] - public string Fixtureboxtype { get; set; } - - /// - /// 夹具状态 - /// - [SugarColumn(ColumnName = "FIXTURESTATUS")] - public string Fixturestatus { get; set; } - - /// - /// 产量 - /// - [SugarColumn(ColumnName = "PRODUCTION")] - public float Production { get; set; } - - /// - /// 固化时间设定值 - /// - [SugarColumn(ColumnName = "CURINGTIMESETTINGVALUE")] - public string CuringTimeSettingValue { get; set; } - /// - /// 固化时间实际值 - /// - [SugarColumn(ColumnName = "ACTUALVALUE")] - public string ActualValue { get; set; } - - /// - /// 创建时间 - /// - [SugarColumn(ColumnName = "CREATED_TIME")] - public DateTime CreatedTime { get; set; } - - /// - /// 更新时间 - /// - [SugarColumn(ColumnName = "UPDATED_TIME")] - public DateTime UpdatedTime { get; set; } - } -} diff --git a/Admin.Core.Model/ViewModels/CurrentTeamTimeView.cs b/Admin.Core.Model/ViewModels/CurrentTeamTimeView.cs new file mode 100644 index 00000000..93780ccd --- /dev/null +++ b/Admin.Core.Model/ViewModels/CurrentTeamTimeView.cs @@ -0,0 +1,41 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model.ViewModels +{ + /// + /// 获取每日班组时间 + /// + public class CurrentTeamTimeView + { + /// + /// 开始时间 + /// + [SugarColumn(ColumnName = "SEQ")] + public int Seq { get; set; } + /// + /// 开始时间 + /// + [SugarColumn(ColumnName = "START_TIME")] + public DateTime StartTime { get; set; } + /// + /// 结束时间 + /// + [SugarColumn(ColumnName = "END_TIME")] + public DateTime EndTime { get; set; } + /// + /// 小时 + /// + [SugarColumn(ColumnName = "HOUR_TIME")] + public string HourTime { get; set; } + /// + /// 班组 + /// + [SugarColumn(ColumnName = "TEAM_NAME")] + public string TeamName { get; set; } + } +} diff --git a/Admin.Core.Repository/Repository_New/BoxDeviceInfoRepository.cs b/Admin.Core.Repository/Repository_New/BoxDeviceInfoRepository.cs new file mode 100644 index 00000000..ca15f249 --- /dev/null +++ b/Admin.Core.Repository/Repository_New/BoxDeviceInfoRepository.cs @@ -0,0 +1,19 @@ +using Admin.Core.IRepository; +using Admin.Core.Model; +using Admin.Core.Model.Model_New; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Admin.Core.Repository +{ + /// + /// BoxDeviceInfoRepository + /// + public class BoxDeviceInfoRepository : BaseRepository, IBoxDeviceInfoRepository + { + public BoxDeviceInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + + } +} \ No newline at end of file diff --git a/Admin.Core.Repository/Repository_New/BoxFoamDataRecordRepository.cs b/Admin.Core.Repository/Repository_New/BoxFoamDataRecordRepository.cs new file mode 100644 index 00000000..d8b0c7e1 --- /dev/null +++ b/Admin.Core.Repository/Repository_New/BoxFoamDataRecordRepository.cs @@ -0,0 +1,16 @@ +using Admin.Core.IRepository; +using Admin.Core.Model; + +namespace Admin.Core.Repository +{ + /// + /// BoxFoamDataRecordRepository + /// + public class BoxFoamDataRecordRepository : BaseRepository, IBoxFoamDataRecordRepository + { + public BoxFoamDataRecordRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + + } +} \ No newline at end of file diff --git a/Admin.Core.Repository/Repository_New/CurrentTeamTimeRepository.cs b/Admin.Core.Repository/Repository_New/CurrentTeamTimeRepository.cs new file mode 100644 index 00000000..ea9ddae8 --- /dev/null +++ b/Admin.Core.Repository/Repository_New/CurrentTeamTimeRepository.cs @@ -0,0 +1,23 @@ +using Admin.Core.Model; +using Admin.Core.IRepository; +using System.Threading.Tasks; +using Admin.Core.Model.ViewModels; +using Admin.Core.Model.Model_New; +using System.Collections.Generic; +using System; + +namespace Admin.Core.Repository +{ + /// + /// CurrentTeamTimeRepository + /// + public class CurrentTeamTimeRepository : BaseRepository, ICurrentTeamTimeRepository + { + public CurrentTeamTimeRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + + } + + + } +} \ No newline at end of file diff --git a/Admin.Core.Repository/Repository_New/OldBoxFoamDataRepository.cs b/Admin.Core.Repository/Repository_New/OldBoxFoamDataRepository.cs deleted file mode 100644 index 9f013c2a..00000000 --- a/Admin.Core.Repository/Repository_New/OldBoxFoamDataRepository.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Admin.Core.IRepository; -using Admin.Core.Model; - -namespace Admin.Core.Repository -{ - /// - /// OldBoxFoamDataRepository - /// - public class OldBoxFoamDataRepository : BaseRepository, IOldBoxFoamDataRepository - { - public OldBoxFoamDataRepository(IUnitOfWork unitOfWork) : base(unitOfWork) - { - } - } -} \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/OldBoxFoamDataServices.cs b/Admin.Core.Service/Service_New/BoxDeviceInfoServices.cs similarity index 54% rename from Admin.Core.Service/Service_New/OldBoxFoamDataServices.cs rename to Admin.Core.Service/Service_New/BoxDeviceInfoServices.cs index 64ad81b0..c5d1f0ab 100644 --- a/Admin.Core.Service/Service_New/OldBoxFoamDataServices.cs +++ b/Admin.Core.Service/Service_New/BoxDeviceInfoServices.cs @@ -14,14 +14,17 @@ using System.Threading.Tasks; namespace Admin.Core.Service { - public class OldBoxFoamDataServices : BaseServices, IOldBoxFoamDataServices + public class BoxDeviceInfoServices : BaseServices, IBoxDeviceInfoServices { - private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(OldBoxFoamDataServices)); - private readonly IBaseRepository _dal; - public OldBoxFoamDataServices(IBaseRepository dal) + private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BoxDeviceInfoServices)); + private readonly IBaseRepository _dal; + private readonly IBoxDeviceInfoRepository _boxDeviceInfoRepository; + + public BoxDeviceInfoServices(IBaseRepository dal, IBoxDeviceInfoRepository boxDeviceInfoRepository) { this._dal = dal; base.BaseDal = dal; + _boxDeviceInfoRepository = boxDeviceInfoRepository; } } diff --git a/Admin.Core.Service/Service_New/BoxFoamDataRecordServices.cs b/Admin.Core.Service/Service_New/BoxFoamDataRecordServices.cs new file mode 100644 index 00000000..2be4cc55 --- /dev/null +++ b/Admin.Core.Service/Service_New/BoxFoamDataRecordServices.cs @@ -0,0 +1,31 @@ +using Admin.Core.IRepository; +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Model.Model_New; +using Admin.Core.Model.ViewModels; +using log4net; +using Microsoft.AspNetCore.Razor.TagHelpers; +using Microsoft.IdentityModel.Logging; +using NPOI.XSSF.UserModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Admin.Core.Service +{ + public class BoxFoamDataRecordServices : BaseServices, IBoxFoamDataRecordServices + { + private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BoxFoamDataRecordServices)); + private readonly IBaseRepository _dal; + private readonly IBoxFoamDataRecordRepository _boxFoamDataRecordRepository; + + public BoxFoamDataRecordServices(IBaseRepository dal, IBoxFoamDataRecordRepository boxFoamDataRecordRepository) + { + this._dal = dal; + base.BaseDal = dal; + _boxFoamDataRecordRepository = boxFoamDataRecordRepository; + } + + } +} \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/BoxFoamDataServices.cs b/Admin.Core.Service/Service_New/BoxFoamDataServices.cs index 716ed288..81264024 100644 --- a/Admin.Core.Service/Service_New/BoxFoamDataServices.cs +++ b/Admin.Core.Service/Service_New/BoxFoamDataServices.cs @@ -1,5 +1,6 @@ using Admin.Core.IRepository; using Admin.Core.IService; +using Admin.Core.Model; using Admin.Core.Model.Model_New; using log4net; namespace Admin.Core.Service diff --git a/Admin.Core.Service/Service_New/BoxFoamPlanServices.cs b/Admin.Core.Service/Service_New/BoxFoamPlanServices.cs index 70c35401..5b2d9981 100644 --- a/Admin.Core.Service/Service_New/BoxFoamPlanServices.cs +++ b/Admin.Core.Service/Service_New/BoxFoamPlanServices.cs @@ -7,7 +7,6 @@ namespace Admin.Core.Service { public class BoxFoamPlanServices : BaseServices, IBoxFoamPlanServices { - private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BoxFoamPlanServices)); private readonly IBaseRepository _dal; public BoxFoamPlanServices(IBaseRepository dal) { diff --git a/Admin.Core.Service/Service_New/CurrentTeamTimeServices.cs b/Admin.Core.Service/Service_New/CurrentTeamTimeServices.cs new file mode 100644 index 00000000..19cffb36 --- /dev/null +++ b/Admin.Core.Service/Service_New/CurrentTeamTimeServices.cs @@ -0,0 +1,27 @@ +using Admin.Core.IRepository; +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Model.ViewModels; +using Admin.Core.Service; +using log4net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Admin.Core.IService +{ + /// + /// SysUserInfoServices + /// + public class CurrentTeamTimeServices : BaseServices, ICurrentTeamTimeServices + { + private readonly IBaseRepository _dal; + public CurrentTeamTimeServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + } +} \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/SysUserInfoServices.cs b/Admin.Core.Service/Service_New/SysUserInfoServices.cs index 3d7fd26e..fcff1d0b 100644 --- a/Admin.Core.Service/Service_New/SysUserInfoServices.cs +++ b/Admin.Core.Service/Service_New/SysUserInfoServices.cs @@ -1,9 +1,12 @@ using Admin.Core.IRepository; using Admin.Core.IService; using Admin.Core.Model; +using Admin.Core.Model.ViewModels; using Admin.Core.Service; using log4net; +using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; namespace Admin.Core.IService @@ -14,10 +17,24 @@ namespace Admin.Core.IService public class SysUserInfoServices : BaseServices, ISysUserInfoServices { private readonly IBaseRepository _dal; - public SysUserInfoServices(IBaseRepository dal) + private readonly ISysUserInfoRepository _sysUserInfoRepository; + public SysUserInfoServices(IBaseRepository dal, ISysUserInfoRepository sysUserInfoRepository) { this._dal = dal; base.BaseDal = dal; + _sysUserInfoRepository = sysUserInfoRepository; + } + + public async Task GetTeamData(DateTime nowDate) + { + var list= await _sysUserInfoRepository.GetTeamData(); + if (list.Count() == 0) return null; + + CurrentTeamTimeView view = list.SingleOrDefault(d=>d.StartTime<= nowDate && nowDate <= d.EndTime); + if (view != null) + return view; + else + return null; } } } \ No newline at end of file diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs index 3784cacd..1d57f624 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs @@ -21,10 +21,10 @@ namespace Admin.Core.Tasks private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(Job_BoxFoamData_Quartz)); private readonly IBoxFoamDataServices _boxFoamDataServices; - private readonly IOldBoxFoamDataServices _oldBoxFoamDataServices; + private readonly IBoxFoamDataServices _oldBoxFoamDataServices; public Job_BoxFoamData_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService, - IBoxFoamDataServices boxFoamDataServices, IOldBoxFoamDataServices oldBoxFoamDataServices) + IBoxFoamDataServices boxFoamDataServices, IBoxFoamDataServices oldBoxFoamDataServices) { _SysTasksQzService = SysTasksQzService; _boxFoamDataServices = boxFoamDataServices; @@ -80,149 +80,149 @@ namespace Admin.Core.Tasks try { - #region 更新PLC数据 - if (item.ObjId == 1) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW122.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW122.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD146"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD294"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD310"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD578"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 2) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX12.0"); - if (obj.plc.ReadInt16("DB8.DBW124.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW124.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD150"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD318"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD334"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD582"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 3) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW126.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW126.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD154"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD342"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD358"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD586"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 4) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW128.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW128.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD158"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD366"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD382"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD590"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 5) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW130.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW130.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD162"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD390"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD406"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD594"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 6) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW122.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW122.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD166"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD414"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD430"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD598"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 7) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW134.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW134.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD170"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD438"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD454"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD602"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 8) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW136.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW136.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD174"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD462"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD478"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD606"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 9) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW138.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW138.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD178"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD486"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD502"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD610"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 10) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW140.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW140.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD182"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD510"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD526"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD614"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 11) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DDB8.DBW142.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW142.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD186"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD534"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD550"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD622"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 12) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW144.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW144.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD190"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD558"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD574"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD626"); - item.UpdateTime = DateTime.Now; - } - #endregion - bool result = await _boxFoamDataServices.UpdateAsync(item); - if (result) - { - RefreshBoxFoamDataDelegateEvent?.Invoke(); - } - else - { - // LogDelegateEvent?.Invoke($"物料[{planInfo.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!"); - } + //#region 更新PLC数据 + //if (item.ObjId == 1) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW122.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW122.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD146"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD294"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD310"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD578"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 2) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX12.0"); + // if (obj.plc.ReadInt16("DB8.DBW124.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW124.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD150"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD318"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD334"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD582"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 3) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW126.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW126.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD154"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD342"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD358"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD586"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 4) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW128.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW128.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD158"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD366"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD382"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD590"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 5) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW130.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW130.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD162"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD390"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD406"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD594"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 6) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW122.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW122.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD166"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD414"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD430"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD598"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 7) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW134.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW134.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD170"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD438"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD454"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD602"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 8) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW136.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW136.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD174"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD462"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD478"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD606"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 9) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW138.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW138.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD178"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD486"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD502"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD610"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 10) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW140.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW140.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD182"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD510"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD526"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD614"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 11) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DDB8.DBW142.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW142.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD186"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD534"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD550"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD622"); + // item.UpdateTime = DateTime.Now; + //} + //if (item.ObjId == 12) + //{ + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW144.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW144.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD190"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD558"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD574"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD626"); + // item.UpdateTime = DateTime.Now; + //} + //#endregion + //bool result = await _boxFoamDataServices.UpdateAsync(item); + //if (result) + //{ + // RefreshBoxFoamDataDelegateEvent?.Invoke(); + //} + //else + //{ + // // LogDelegateEvent?.Invoke($"物料[{planInfo.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!"); + //} } catch (Exception ex) { @@ -260,7 +260,7 @@ namespace Admin.Core.Tasks } } - private async Task UpdateRealBoxFoamData(PlcModel obj, OldBoxFoamData item) + private async Task UpdateRealBoxFoamData(PlcModel obj, BoxFoamData item) { try { @@ -268,18 +268,18 @@ namespace Admin.Core.Tasks if (item.ObjId == 1) { item.Fixtureboxtype = obj.plc.ReadString("D3140")+ obj.plc.ReadString("D3141"); - if (obj.plc.ReadInt16("Y0F0") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y0F1") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y110") == 1) - { - item.Fixturestatus = "停止"; - } + //if (obj.plc.ReadInt16("Y0F0") == 1) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadInt16("Y0F1") == 1) + //{ + // item.Fixturestatus = "自动"; + //} + //if (obj.plc.ReadInt16("Y110") == 1) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D182"); item.CuringTimeSettingValue = obj.plc.ReadString("D911"); @@ -289,18 +289,18 @@ namespace Admin.Core.Tasks if (item.ObjId == 2) { item.Fixtureboxtype = obj.plc.ReadString("D3142") + obj.plc.ReadString("D3143"); - if (obj.plc.ReadInt16("Y0F5") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y0F6") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y111") == 1) - { - item.Fixturestatus = "停止"; - } + //if (obj.plc.ReadInt16("Y0F5") == 1) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadInt16("Y0F6") == 1) + //{ + // item.Fixturestatus = "自动"; + //} + //if (obj.plc.ReadInt16("Y111") == 1) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D183"); item.CuringTimeSettingValue = obj.plc.ReadString("D911"); @@ -310,18 +310,18 @@ namespace Admin.Core.Tasks if (item.ObjId == 3) { item.Fixtureboxtype = obj.plc.ReadString("D3144") + obj.plc.ReadString("D3145"); - if (obj.plc.ReadInt16("Y0FA") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y0FB") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y112") == 1) - { - item.Fixturestatus = "停止"; - } + //if (obj.plc.ReadInt16("Y0FA") == 1) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadInt16("Y0FB") == 1) + //{ + // item.Fixturestatus = "自动"; + //} + //if (obj.plc.ReadInt16("Y112") == 1) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D183"); item.CuringTimeSettingValue = obj.plc.ReadString("D912"); @@ -331,18 +331,18 @@ namespace Admin.Core.Tasks if (item.ObjId == 4) { item.Fixtureboxtype = obj.plc.ReadString("D3148") + obj.plc.ReadString("D3149"); - if (obj.plc.ReadInt16("Y100 ") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y101") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y113") == 1) - { - item.Fixturestatus = "停止"; - } + //if (obj.plc.ReadInt16("Y100 ") == 1) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadInt16("Y101") == 1) + //{ + // item.Fixturestatus = "自动"; + //} + //if (obj.plc.ReadInt16("Y113") == 1) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D184"); item.CuringTimeSettingValue = obj.plc.ReadString("D913"); @@ -352,18 +352,18 @@ namespace Admin.Core.Tasks if (item.ObjId == 5) { item.Fixtureboxtype = obj.plc.ReadString("D3150") + obj.plc.ReadString("D3151"); - if (obj.plc.ReadInt16("Y105") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y106") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y114") == 1) - { - item.Fixturestatus = "停止"; - } + //if (obj.plc.ReadInt16("Y105") == 1) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadInt16("Y106") == 1) + //{ + // item.Fixturestatus = "自动"; + //} + //if (obj.plc.ReadInt16("Y114") == 1) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D185"); item.CuringTimeSettingValue = obj.plc.ReadString("D914"); @@ -373,18 +373,18 @@ namespace Admin.Core.Tasks if (item.ObjId == 6) { item.Fixtureboxtype = obj.plc.ReadString("D3152") + obj.plc.ReadString("D3143"); - if (obj.plc.ReadInt16("Y10A") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y10B") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y115") == 1) - { - item.Fixturestatus = "停止"; - } + //if (obj.plc.ReadInt16("Y10A") == 1) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadInt16("Y10B") == 1) + //{ + // item.Fixturestatus = "自动"; + //} + //if (obj.plc.ReadInt16("Y115") == 1) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D186"); item.CuringTimeSettingValue = obj.plc.ReadString("D915"); diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs index f339d20b..c01d6468 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs @@ -20,10 +20,10 @@ namespace Admin.Core.Tasks public static event RefreshBoxFoamDataDelegate RefreshBoxFoamDataDelegateEvent; private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(Job_BoxFoamData_Quartz)); private readonly IBoxFoamDataServices _boxFoamDataServices; - private readonly IOldBoxFoamDataServices _oldBoxFoamDataServices; + private readonly IBoxFoamDataServices _oldBoxFoamDataServices; public Job_BoxFoamLastData_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService, - IBoxFoamDataServices boxFoamDataServices, IOldBoxFoamDataServices oldBoxFoamDataServices) + IBoxFoamDataServices boxFoamDataServices, IBoxFoamDataServices oldBoxFoamDataServices) { _SysTasksQzService = SysTasksQzService; _boxFoamDataServices = boxFoamDataServices; @@ -33,7 +33,6 @@ namespace Admin.Core.Tasks public async Task Execute(IJobExecutionContext context) { await ExecuteJob(context, async () => await Run(context)); - await ExecuteJob(context, async () => await BoxFoamDataRun(context)); } public async Task Run(IJobExecutionContext context) @@ -41,10 +40,6 @@ namespace Admin.Core.Tasks await SaveData(); } - public async Task BoxFoamDataRun(IJobExecutionContext context) - { - await SaveOldBoxFoamData(); - } #region PLC 任务处理表 /// @@ -77,338 +72,160 @@ namespace Admin.Core.Tasks private async Task UpdateRealData(PlcModel obj, BoxFoamData item) { - try - { - #region 更新PLC数据 - if (item.ObjId == 1) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW122.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW122.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD146"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD294"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD310"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD578"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 2) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX12.0"); - if (obj.plc.ReadInt16("DB8.DBW124.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW124.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD150"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD318"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD334"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD582"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 3) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW126.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW126.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD154"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD342"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD358"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD586"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 4) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW128.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW128.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD158"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD366"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD382"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD590"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 5) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW130.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW130.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD162"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD390"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD406"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD594"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 6) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW122.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW122.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD166"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD414"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD430"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD598"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 7) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW134.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW134.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD170"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD438"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD454"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD602"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 8) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW136.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW136.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD174"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD462"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD478"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD606"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 9) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW138.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW138.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD178"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD486"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD502"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD610"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 10) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW140.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW140.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD182"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD510"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD526"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD614"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 11) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DDB8.DBW142.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW142.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD186"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD534"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD550"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD622"); - item.UpdateTime = DateTime.Now; - } - if (item.ObjId == 12) - { - item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); - if (obj.plc.ReadInt16("DB8.DBW144.0") == 1) item.BoxFixturestatus = 1; - if (obj.plc.ReadInt16("DB8.DBW144.1") == 1) item.BoxFixturestatus = 0; - item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD190"); - item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD558"); - item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD574"); - item.BoxBeat = obj.plc.ReadInt16("DB8.DBD626"); - item.UpdateTime = DateTime.Now; - } - #endregion - bool result = await _boxFoamDataServices.UpdateAsync(item); - if (result) - { - RefreshBoxFoamDataDelegateEvent?.Invoke(); - } - else - { - // LogDelegateEvent?.Invoke($"物料[{planInfo.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!"); - } - } - catch (Exception ex) - { - logHelper.Error($"更新箱体发泡数据失败"); - } + //try + //{ + // #region 更新PLC数据 + // if (item.ObjId == 1) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW122.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW122.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD146"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD294"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD310"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD578"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 2) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX12.0"); + // if (obj.plc.ReadInt16("DB8.DBW124.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW124.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD150"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD318"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD334"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD582"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 3) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW126.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW126.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD154"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD342"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD358"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD586"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 4) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW128.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW128.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD158"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD366"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD382"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD590"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 5) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW130.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW130.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD162"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD390"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD406"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD594"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 6) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW122.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW122.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD166"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD414"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD430"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD598"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 7) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW134.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW134.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD170"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD438"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD454"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD602"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 8) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW136.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW136.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD174"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD462"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD478"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD606"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 9) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW138.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW138.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD178"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD486"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD502"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD610"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 10) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW140.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW140.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD182"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD510"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD526"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD614"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 11) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DDB8.DBW142.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW142.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD186"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD534"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD550"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD622"); + // item.UpdateTime = DateTime.Now; + // } + // if (item.ObjId == 12) + // { + // item.BoxFixturetype = obj.plc.ReadString("DB8.DBX2.0"); + // if (obj.plc.ReadInt16("DB8.DBW144.0") == 1) item.BoxFixturestatus = 1; + // if (obj.plc.ReadInt16("DB8.DBW144.1") == 1) item.BoxFixturestatus = 0; + // item.BoxFixtureproduction = obj.plc.ReadInt16("DB8.DBD190"); + // item.BoxFixturesideplate = obj.plc.ReadString("DB8.DBD558"); + // item.BoxClosebetatemperature = obj.plc.ReadString("DB8.DBD574"); + // item.BoxBeat = obj.plc.ReadInt16("DB8.DBD626"); + // item.UpdateTime = DateTime.Now; + // } + // #endregion + // bool result = await _boxFoamDataServices.UpdateAsync(item); + // if (result) + // { + // RefreshBoxFoamDataDelegateEvent?.Invoke(); + // } + // else + // { + // // LogDelegateEvent?.Invoke($"物料[{planInfo.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!"); + // } + //} + //catch (Exception ex) + //{ + // logHelper.Error($"更新箱体发泡数据失败"); + //} return await Task.FromResult(item); } #endregion - #region PLC 任务处理表 - /// - /// PLC 任务处理表 - /// - /// 仓库编码 - /// 物料编码 - /// - public async Task SaveOldBoxFoamData() - { - try - { - var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("发泡Plc")); - if (obj.plc.IsConnected) - { - var taskList = await _oldBoxFoamDataServices.QueryAsync(); - foreach (var item in taskList) - { - await UpdateRealBoxFoamData(obj, item); - } - } - } - catch (Exception ex) - { - logHelper.Error($"入库数据处理异常:{ex.Message}"); - } - } - - private async Task UpdateRealBoxFoamData(PlcModel obj, OldBoxFoamData item) - { - try - { - #region 更新PLC数据 - if (item.ObjId == 1) - { - item.Fixtureboxtype = obj.plc.ReadString("D3140")+ obj.plc.ReadString("D3141"); - if (obj.plc.ReadInt16("Y0F0") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y0F1") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y110") == 1) - { - item.Fixturestatus = "停止"; - } - - item.Production = obj.plc.ReadInt16("D182"); - item.CuringTimeSettingValue = obj.plc.ReadString("D911"); - item.ActualValue = obj.plc.ReadString("T3"); - item.UpdatedTime = DateTime.Now; - } - if (item.ObjId == 2) - { - item.Fixtureboxtype = obj.plc.ReadString("D3142") + obj.plc.ReadString("D3143"); - if (obj.plc.ReadInt16("Y0F5") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y0F6") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y111") == 1) - { - item.Fixturestatus = "停止"; - } - - item.Production = obj.plc.ReadInt16("D183"); - item.CuringTimeSettingValue = obj.plc.ReadString("D911"); - item.ActualValue = obj.plc.ReadString("T13"); - item.UpdatedTime = DateTime.Now; - } - if (item.ObjId == 3) - { - item.Fixtureboxtype = obj.plc.ReadString("D3144") + obj.plc.ReadString("D3145"); - if (obj.plc.ReadInt16("Y0FA") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y0FB") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y112") == 1) - { - item.Fixturestatus = "停止"; - } - - item.Production = obj.plc.ReadInt16("D183"); - item.CuringTimeSettingValue = obj.plc.ReadString("D912"); - item.ActualValue = obj.plc.ReadString("T23"); - item.UpdatedTime = DateTime.Now; - } - if (item.ObjId == 4) - { - item.Fixtureboxtype = obj.plc.ReadString("D3148") + obj.plc.ReadString("D3149"); - if (obj.plc.ReadInt16("Y100 ") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y101") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y113") == 1) - { - item.Fixturestatus = "停止"; - } - - item.Production = obj.plc.ReadInt16("D184"); - item.CuringTimeSettingValue = obj.plc.ReadString("D913"); - item.ActualValue = obj.plc.ReadString("T33"); - item.UpdatedTime = DateTime.Now; - } - if (item.ObjId == 5) - { - item.Fixtureboxtype = obj.plc.ReadString("D3150") + obj.plc.ReadString("D3151"); - if (obj.plc.ReadInt16("Y105") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y106") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y114") == 1) - { - item.Fixturestatus = "停止"; - } - - item.Production = obj.plc.ReadInt16("D185"); - item.CuringTimeSettingValue = obj.plc.ReadString("D914"); - item.ActualValue = obj.plc.ReadString("T43"); - item.UpdatedTime = DateTime.Now; - } - if (item.ObjId == 6) - { - item.Fixtureboxtype = obj.plc.ReadString("D3152") + obj.plc.ReadString("D3143"); - if (obj.plc.ReadInt16("Y10A") == 1) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadInt16("Y10B") == 1) - { - item.Fixturestatus = "自动"; - } - if (obj.plc.ReadInt16("Y115") == 1) - { - item.Fixturestatus = "停止"; - } - - item.Production = obj.plc.ReadInt16("D186"); - item.CuringTimeSettingValue = obj.plc.ReadString("D915"); - item.ActualValue = obj.plc.ReadString("T53"); - item.UpdatedTime = DateTime.Now; - } - - #endregion - bool result = await _oldBoxFoamDataServices.UpdateAsync(item); - if (result) - { - //RefreshBoxFoamDataDelegateEvent?.Invoke(); - } - else - { - // LogDelegateEvent?.Invoke($"物料[{planInfo.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!"); - } - } - catch (Exception ex) - { - logHelper.Error($"更新老箱体发泡数据失败"); - } - - return await Task.FromResult(item); - } - #endregion } } diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoamStore_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoamStore_Quartz.cs index 128748b5..325f6029 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoamStore_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoamStore_Quartz.cs @@ -29,7 +29,7 @@ namespace Admin.Core.Tasks /// 老发泡线更新事件 /// /// - public delegate Task RefreshOldBoxFoamDataDelegate(List list); + public delegate Task RefreshOldBoxFoamDataDelegate(List list); public static event RefreshOldBoxFoamDataDelegate RefreshOldBoxFoamDataDelegateEvent; /// /// 老泡前库更新事件 @@ -43,10 +43,10 @@ namespace Admin.Core.Tasks private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(Job_BoxFoamData_Quartz)); private readonly IOldBoxFoamTypeServices _oldBoxFoamTypeServices; - private readonly IOldBoxFoamDataServices _oldBoxFoamDataServices; + private readonly IBoxFoamDataServices _oldBoxFoamDataServices; public Job_OldBoxFoamStore_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService, - IOldBoxFoamTypeServices oldBoxFoamTypeServices, IOldBoxFoamDataServices oldBoxFoamDataServices) + IOldBoxFoamTypeServices oldBoxFoamTypeServices, IBoxFoamDataServices oldBoxFoamDataServices) { _SysTasksQzService = SysTasksQzService; _oldBoxFoamTypeServices = oldBoxFoamTypeServices; @@ -388,13 +388,13 @@ namespace Admin.Core.Tasks i--; if (i == 0) { - List old = await _oldBoxFoamDataServices.QueryAsync(); + List old = await _oldBoxFoamDataServices.QueryAsync(); RefreshOldBoxFoamDataDelegateEvent?.Invoke(old); } } } - private async void UpdateRealOldBoxFoamData(OldBoxFoamData item) + private async void UpdateRealOldBoxFoamData(BoxFoamData item) { if (item.ObjId == 1) { @@ -414,18 +414,18 @@ namespace Admin.Core.Tasks //} //string type = $"{obj.plc.ReadInt16("D3140")}{obj.plc.ReadInt16("D3141")}"; //item.Fixtureboxtype = type; - if (obj.plc.ReadBool("Y0F0")) - { - item.Fixturestatus = "手动"; - } - else if (obj.plc.ReadBool("Y0F1")) - { - item.Fixturestatus = "手动"; - } - else if (obj.plc.ReadBool("Y110")) - { - item.Fixturestatus = "停止"; - } + //if (obj.plc.ReadBool("Y0F0")) + //{ + // item.Fixturestatus = "手动"; + //} + //else if (obj.plc.ReadBool("Y0F1")) + //{ + // item.Fixturestatus = "手动"; + //} + //else if (obj.plc.ReadBool("Y110")) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D182"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D910").ToString(); item.ActualValue = obj.plc.ReadInt16("T3").ToString(); @@ -447,18 +447,18 @@ namespace Admin.Core.Tasks item.Fixtureboxtype = type1; } - if (obj.plc.ReadBool("Y0F5")) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadBool("Y0F6")) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadBool("Y111")) - { - item.Fixturestatus = "停止"; - } + //if (obj.plc.ReadBool("Y0F5")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadBool("Y0F6")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadBool("Y111")) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D183"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D912").ToString(); item.ActualValue = obj.plc.ReadInt16("T13").ToString(); @@ -474,22 +474,22 @@ namespace Admin.Core.Tasks //string type = $"{obj.plc.ReadInt16("D3142")}{obj.plc.ReadInt16("D3143")}"; //item.Fixtureboxtype = type; var type1 = $"{obj.plc.ReadInt32("D3144")}"; - if (type1.ToString() != "0") - { - item.Fixtureboxtype = type1; - } - if (obj.plc.ReadBool("Y0FA")) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadBool("Y0FB")) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadBool("Y112")) - { - item.Fixturestatus = "停止"; - } + //if (type1.ToString() != "0") + //{ + // item.Fixtureboxtype = type1; + //} + //if (obj.plc.ReadBool("Y0FA")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadBool("Y0FB")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadBool("Y112")) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D184"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D912").ToString(); item.ActualValue = obj.plc.ReadInt16("T23").ToString(); @@ -515,18 +515,18 @@ namespace Admin.Core.Tasks } var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); if (objStatus != null) { - if (objStatus.plc.ReadBool("Y100")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y101")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y113")) - { - item.Fixturestatus = "停止"; - } + //if (objStatus.plc.ReadBool("Y100")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y101")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y113")) + //{ + // item.Fixturestatus = "停止"; + //} } } @@ -552,18 +552,18 @@ namespace Admin.Core.Tasks var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); if (objStatus != null&& objStatus.plc.IsConnected) { - if (objStatus.plc.ReadBool("Y105")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y106")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y114")) - { - item.Fixturestatus = "停止"; - } + //if (objStatus.plc.ReadBool("Y105")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y106")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y114")) + //{ + // item.Fixturestatus = "停止"; + //} } } @@ -591,18 +591,18 @@ namespace Admin.Core.Tasks var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); if (objStatus != null) { - if (objStatus.plc.ReadBool("Y10A")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y10B")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y115")) - { - item.Fixturestatus = "停止"; - } + //if (objStatus.plc.ReadBool("Y10A")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y10B")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y115")) + //{ + // item.Fixturestatus = "停止"; + //} item.ActualValue = objStatus.plc.ReadInt16("T53").ToString(); } diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoam_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoam_Quartz.cs index 07001cf8..3a067a90 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoam_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_OldBoxFoam_Quartz.cs @@ -10,6 +10,13 @@ using Admin.Core.Model.Model_New; using Aucma.Core.HwPLc; using System.Collections.Generic; using Admin.Core.Model; +using Elasticsearch.Net; +using NPOI.POIFS.Crypt.Dsig; +using NetTaste; +using Consul; +using Admin.Core.Model.ViewModels; +using Admin.Core.Service; +using System.Collections; /// /// 老发泡数据采集 @@ -29,7 +36,7 @@ namespace Admin.Core.Tasks /// 老发泡线更新事件 /// /// - public delegate Task RefreshOldBoxFoamDataDelegate(List list); + public delegate Task RefreshOldBoxFoamDataDelegate(List list); public static event RefreshOldBoxFoamDataDelegate RefreshOldBoxFoamDataDelegateEvent; /// /// 老泡前库更新事件 @@ -43,367 +50,112 @@ namespace Admin.Core.Tasks private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(Job_BoxFoamData_Quartz)); private readonly IOldBoxFoamTypeServices _oldBoxFoamTypeServices; - private readonly IOldBoxFoamDataServices _oldBoxFoamDataServices; + private readonly IBoxFoamDataServices _oldBoxFoamDataServices; + private readonly ISysUserInfoServices _sysUserInfoServices; + private readonly ICurrentTeamTimeServices _currentTeamTimeServices; + private readonly IBoxFoamDataRecordServices _boxFoamDataRecordServices; + private readonly IBoxFoamPlanServices _boxFoamPlanServices; + private readonly IBoxDeviceInfoServices _boxDeviceInfoServices; public Job_OldBoxFoam_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService, - IOldBoxFoamTypeServices oldBoxFoamTypeServices, IOldBoxFoamDataServices oldBoxFoamDataServices) + IOldBoxFoamTypeServices oldBoxFoamTypeServices, IBoxFoamDataServices oldBoxFoamDataServices, + ISysUserInfoServices sysUserInfoServices, ICurrentTeamTimeServices currentTeamTimeServices, + IBoxFoamDataRecordServices boxFoamDataRecordServices, IBoxDeviceInfoServices boxDeviceInfoServices) { _SysTasksQzService = SysTasksQzService; _oldBoxFoamTypeServices = oldBoxFoamTypeServices; _oldBoxFoamDataServices = oldBoxFoamDataServices; + _sysUserInfoServices = sysUserInfoServices; + _currentTeamTimeServices = currentTeamTimeServices; + _boxFoamDataRecordServices = boxFoamDataRecordServices; + _boxDeviceInfoServices= boxDeviceInfoServices; } public async Task Execute(IJobExecutionContext context) { - var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); - if (obj == null) { return; } - if (obj.plc.IsConnected) - { - ushort len =Convert.ToUInt16("48"); - byte[] bt = obj.plc.ReadBytes("D2010", len); - readbyte.Content.Skip(2).Take(4).ToArray() - (int)byteTransform.TransSingle(readbyte.Content.Skip(2).Take(4).ToArray(), 0); - var t= bt; - } - //await ExecuteJob(context, async () => await OldBoxFoamDataRun(context));//发泡线 - //await ExecuteJob(context, async () => await OldBoxFoamStoreDataRun(context)); + await ExecuteJob(context, async () => await OldBoxFoamDataRun(context));//发泡线 } + /// /// 发泡线 /// /// /// public async Task OldBoxFoamDataRun(IJobExecutionContext context) - { - await OldBoxFoamData(); - } - - public async Task OldBoxFoamStoreDataRun(IJobExecutionContext context) - { - await OldBoxFoamStoreData(); - } - - #region PLC 老泡前库任务处理表 - /// - /// PLC 任务处理表 - /// - /// 仓库编码 - /// 物料编码 - /// - public async Task OldBoxFoamStoreData() { try { - var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); - if (obj == null) { return; } - if (obj.plc.IsConnected) + //判断是否切换了班组,切换班组,数据清空,同时保存数据到历史记录表中 + DateTime now = DateTime.Now; + CurrentTeamTime time = await _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now); + if (time != null) { - var taskList = await _oldBoxFoamTypeServices.QueryAsync(); - int i = taskList.Count(); - foreach (var item in taskList) - { - await UpdateRealOldBoxFoamTypeData(obj, item); - i--; - if (i==0) - { - var list = await _oldBoxFoamTypeServices.QueryAsync(); - RefreshOldBoxFoamTypeDataDelegateEvent?.Invoke(list); - } - - } - } - } - catch (Exception ex) - { - logHelper.Error($"入库数据处理异常:{ex.Message}"); - } - } - - /// - /// 泡前库更新 - /// - /// - /// - /// - private async Task UpdateRealOldBoxFoamTypeData(PlcModel obj, OldBoxFoamType item) - { - try - { - #region 更新PLC数据 - if (item.ObjId == 1) - { - int amount = 0; - - var str = $"{obj.plc.ReadInt16("L101")}{obj.plc.ReadInt16("L102")}{obj.plc.ReadInt16("L103")}"; - if (str.IsNotEmptyOrNull()) - { - int r=Convert.ToInt32(str); - switch (r) - { - case 0: - amount = 0; - break; - case 1: - amount=1; - break; - case 11: - amount = 2; - break; - case 111: - amount = 3; - break; - default: - break; - } - item.Boxtype = obj.plc.ReadString("D2010"); - item.Storeamount = amount; - item.UpdatedTime = DateTime.Now; - } - } - if (item.ObjId == 2) - { - int amount = 0; - var str = obj.plc.ReadInt16("L201").ToString() + obj.plc.ReadInt16("L202").ToString() + obj.plc.ReadInt16("L303").ToString(); - if (str.IsNotEmptyOrNull()) - { - int r = Convert.ToInt32(str); - switch (r) - { - case 0: - amount = 0; - break; - case 1: - amount = 1; - break; - case 11: - amount = 2; - break; - case 111: - amount = 3; - break; - default: - amount = r; - break; - } - item.Boxtype = obj.plc.ReadString("D2020"); - item.Storeamount = amount; - item.UpdatedTime = DateTime.Now; - } - } - if (item.ObjId == 3) - { - int amount = 0; - var str = obj.plc.ReadInt16("L301").ToString() + obj.plc.ReadInt16("L302").ToString() + obj.plc.ReadInt16("L303").ToString(); - if (str.IsNotEmptyOrNull()) - { - int r = Convert.ToInt32(str); - switch (r) - { - case 0: - amount = 0; - break; - case 1: - amount = 1; - break; - case 11: - amount = 2; - break; - case 111: - amount = 3; - break; - default: - break; - } - item.Boxtype = obj.plc.ReadString("D2030"); - item.Storeamount = amount; - item.UpdatedTime = DateTime.Now; - } - } - if (item.ObjId == 4) - { - int amount = 0; - var str = obj.plc.ReadInt16("L401").ToString() + obj.plc.ReadInt16("L402").ToString() + obj.plc.ReadInt16("L403").ToString(); - if (str.IsNotEmptyOrNull()) - { - int r = Convert.ToInt32(str); - switch (r) - { - case 0: - amount = 0; - break; - case 1: - amount = 1; - break; - case 11: - amount = 2; - break; - case 111: - amount = 3; - break; - default: - break; - } - item.Boxtype = obj.plc.ReadString("D2040"); - item.Storeamount = amount; - item.UpdatedTime = DateTime.Now; - } - } - if (item.ObjId == 5) - { - int amount = 0; - var str = obj.plc.ReadInt16("L501").ToString() + obj.plc.ReadInt16("L502").ToString() + obj.plc.ReadInt16("L503").ToString(); - if (str.IsNotEmptyOrNull()) - { - int r = Convert.ToInt32(str); - switch (r) - { - case 0: - amount = 0; - break; - case 1: - amount = 1; - break; - case 11: - amount = 2; - break; - case 111: - amount = 3; - break; - default: - break; - } - item.Boxtype = obj.plc.ReadString("D2010"); - item.Storeamount = amount; - item.UpdatedTime = DateTime.Now; - } - } - if (item.ObjId == 6) - { - int amount = 0; - var str = obj.plc.ReadInt16("L601").ToString() + obj.plc.ReadInt16("L602").ToString() + obj.plc.ReadInt16("L603").ToString(); - if (str.IsNotEmptyOrNull()) - { - int r = Convert.ToInt32(str); - switch (r) - { - case 0: - amount = 0; - break; - case 1: - amount = 1; - break; - case 11: - amount = 2; - break; - case 111: - amount = 3; - break; - default: - break; - } - item.Boxtype = obj.plc.ReadString("D2020"); - item.Storeamount = amount; - item.UpdatedTime = DateTime.Now; - } - } - if (item.ObjId == 7) - { - int amount = 0; - var str = obj.plc.ReadInt16("L701").ToString() + obj.plc.ReadInt16("L702").ToString() + obj.plc.ReadInt16("L703").ToString(); - if (str.IsNotEmptyOrNull()) - { - int r = Convert.ToInt32(str); - switch (r) - { - case 0: - amount = 0; - break; - case 1: - amount = 1; - break; - case 11: - amount = 2; - break; - case 111: - amount = 3; - break; - default: - break; - } - item.Boxtype = obj.plc.ReadString("D2030"); - item.Storeamount = amount; - item.UpdatedTime = DateTime.Now; - } - } - if (item.ObjId == 8) - { - int amount = 0; - var str = obj.plc.ReadInt16("L801").ToString() + obj.plc.ReadInt16("L802").ToString() + obj.plc.ReadInt16("L803").ToString(); - if (str.IsNotEmptyOrNull()) - { - int r = Convert.ToInt32(str); - switch (r) - { - case 0: - amount = 0; - break; - case 1: - amount = 1; - break; - case 11: - amount = 2; - break; - case 111: - amount = 3; - break; - default: - break; - } - item.Boxtype = obj.plc.ReadString("D2040"); - item.Storeamount = amount; - item.UpdatedTime = DateTime.Now; - } - } - #endregion - bool result = await _oldBoxFoamTypeServices.UpdateAsync(item); - if (result) - { - //var list = await _oldBoxFoamTypeServices.QueryAsync(); - //RefreshOldBoxFoamTypeDataDelegateEvent?.Invoke(list); + //记录数据 + await OldBoxFoamData(); } else { - // LogDelegateEvent?.Invoke($"物料[{planInfo.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!"); + string productLineCode = Appsettings.app("StationInfo", "ProductLineCode"); + //把数据保存到记录表中,同时删除实时数据,重新更新数据 + List list = await _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode); + List recordList = new List(); + list.ForEach(d => + { + BoxFoamDataRecord record = new BoxFoamDataRecord(); + record.OrderCode = d.OrderCode; + record.ProductLineCode = d.ProductLineCode; + record.Fixturestatus = d.Production; + record.CuringTimeSettingValue = d.CuringTimeSettingValue; + record.ActualValue = d.ActualValue; + record.AnHour = d.AnHour; + record.TwoHour = d.TwoHour; + record.ThreeHour = d.ThreeHour; + record.FourHour = d.FourHour; + record.FiveHour = d.FiveHour; + record.SixHour = d.SixHour; + record.SevenHour = d.SevenHour; + record.EightHour = d.EightHour; + record.NineHour = d.NineHour; + record.TenHour = d.TenHour; + record.ElevenHour = d.ElevenHour; + record.TwelveHour = d.TwelveHour; + record.BoxFixturesideplate = d.BoxFixturesideplate; + record.BoxClosebetatemperature = d.BoxClosebetatemperature; + record.BoxBeat = d.BoxBeat; + record.CreateTime = DateTime.Now; + + recordList.Add(record); + }); + int result = await _boxFoamDataRecordServices.AddAsync(recordList); + if (result > 0) + { + var lbfdsList = await _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == "1"); + await _oldBoxFoamDataServices.DeletesAsync(lbfdsList); + + var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + if (obj2 == null) { return; } + obj2.plc.WriteInt16("M216", "1");//换班 数据清空 + + } } } catch (Exception ex) { - logHelper.Error($"更新老箱体发泡数据失败"); - } - return await Task.FromResult(item); + throw; + } } - #endregion - #region 老泡线体夹具任务处理表 public async Task OldBoxFoamData() { - var list = await _oldBoxFoamDataServices.QueryAsync(); - int i = list.Count(); - foreach (var item in list) - { - UpdateRealOldBoxFoamData(item); - i--; - if (i == 0) - { - List old = await _oldBoxFoamDataServices.QueryAsync(); - RefreshOldBoxFoamDataDelegateEvent?.Invoke(old); - } - } + await GetData(); + await GetData2(); + List old = await _oldBoxFoamDataServices.QueryAsync(); + RefreshOldBoxFoamDataDelegateEvent?.Invoke(old); } - private async void UpdateRealOldBoxFoamData(OldBoxFoamData item) + private async void UpdateRealOldBoxFoamData(BoxFoamData item) { if (item.ObjId == 1) { @@ -411,30 +163,24 @@ namespace Admin.Core.Tasks if (obj == null) { return; } if (obj.plc.IsConnected) { + // int temp1 = short.Parse(UnicodeHelper.BytesToHexStr(bt.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); var type1 = $"{obj.plc.ReadInt32("D3140")}"; if (type1.ToString()!="0") { item.Fixtureboxtype = type1; } - //var type2 = $"{obj.plc.ReadInt16("D3141")}"; - //if (type1.ToString() != "0") + //if (obj.plc.ReadBool("Y0F0")) //{ - // item.Fixtureboxtype = item.Fixtureboxtype+type2; + // item.Fixturestatus = "手动"; + //} + //else if (obj.plc.ReadBool("Y0F1")) + //{ + // item.Fixturestatus = "手动"; + //} + //else if (obj.plc.ReadBool("Y110")) + //{ + // item.Fixturestatus = "停止"; //} - //string type = $"{obj.plc.ReadInt16("D3140")}{obj.plc.ReadInt16("D3141")}"; - //item.Fixtureboxtype = type; - if (obj.plc.ReadBool("Y0F0")) - { - item.Fixturestatus = "手动"; - } - else if (obj.plc.ReadBool("Y0F1")) - { - item.Fixturestatus = "手动"; - } - else if (obj.plc.ReadBool("Y110")) - { - item.Fixturestatus = "停止"; - } item.Production = obj.plc.ReadInt16("D182"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D910").ToString(); item.ActualValue = obj.plc.ReadInt16("T3").ToString(); @@ -456,18 +202,7 @@ namespace Admin.Core.Tasks item.Fixtureboxtype = type1; } - if (obj.plc.ReadBool("Y0F5")) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadBool("Y0F6")) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadBool("Y111")) - { - item.Fixturestatus = "停止"; - } + item.Production = obj.plc.ReadInt16("D183"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D912").ToString(); item.ActualValue = obj.plc.ReadInt16("T13").ToString(); @@ -487,18 +222,18 @@ namespace Admin.Core.Tasks { item.Fixtureboxtype = type1; } - if (obj.plc.ReadBool("Y0FA")) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadBool("Y0FB")) - { - item.Fixturestatus = "手动"; - } - if (obj.plc.ReadBool("Y112")) - { - item.Fixturestatus = "停止"; - } + //if (obj.plc.ReadBool("Y0FA")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadBool("Y0FB")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (obj.plc.ReadBool("Y112")) + //{ + // item.Fixturestatus = "停止"; + //} item.Production = obj.plc.ReadInt16("D184"); item.CuringTimeSettingValue = obj.plc.ReadInt16("D912").ToString(); item.ActualValue = obj.plc.ReadInt16("T23").ToString(); @@ -524,18 +259,18 @@ namespace Admin.Core.Tasks } var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); if (objStatus != null) { - if (objStatus.plc.ReadBool("Y100")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y101")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y113")) - { - item.Fixturestatus = "停止"; - } + //if (objStatus.plc.ReadBool("Y100")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y101")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y113")) + //{ + // item.Fixturestatus = "停止"; + //} } } @@ -561,18 +296,18 @@ namespace Admin.Core.Tasks var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); if (objStatus != null&& objStatus.plc.IsConnected) { - if (objStatus.plc.ReadBool("Y105")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y106")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y114")) - { - item.Fixturestatus = "停止"; - } + //if (objStatus.plc.ReadBool("Y105")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y106")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y114")) + //{ + // item.Fixturestatus = "停止"; + //} } } @@ -600,19 +335,19 @@ namespace Admin.Core.Tasks var objStatus = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); if (objStatus != null) { - if (objStatus.plc.ReadBool("Y10A")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y10B")) - { - item.Fixturestatus = "手动"; - } - if (objStatus.plc.ReadBool("Y115")) - { - item.Fixturestatus = "停止"; - } - item.ActualValue = objStatus.plc.ReadInt16("T53").ToString(); + //if (objStatus.plc.ReadBool("Y10A")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y10B")) + //{ + // item.Fixturestatus = "手动"; + //} + //if (objStatus.plc.ReadBool("Y115")) + //{ + // item.Fixturestatus = "停止"; + //} + //item.ActualValue = objStatus.plc.ReadInt16("T53").ToString(); } } @@ -627,7 +362,1978 @@ namespace Admin.Core.Tasks { // RefreshOldBoxFoamDataDelegateEvent?.Invoke($"物料[{planInfo.MaterialName}], 入库[{baseSpace.SpaceName}]失败,任务回滚!"); } - } + } #endregion + + public byte[] ArrReverse(byte[] bt) + { + for (int i = 0; i < bt.Length; i += 2) + { + byte temp = bt[i]; + bt[i] = bt[i + 1]; + bt[i + 1] = temp; + } + + return bt; + } + + public async Task GetData() + { + try + { + var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); + if (obj2 == null) { return; } + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + if (obj == null) { return; } + string productLineCode = Appsettings.app("StationInfo", "ProductLineCode"); + List fdList = await _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode); + + byte[] bt = obj.plc.Read("D3140", (ushort)48); + if (bt == null) return; + var arr1 = ArrReverse(bt); + + byte[] bt3 = obj.plc.Read("D182", (ushort)24); + if (bt3 == null) return; + var arr3 = ArrReverse(bt3); + byte[] bt4 = obj.plc.Read("D910", (ushort)24); + if (bt4 == null) return; + var arr4 = ArrReverse(bt4); + byte[] bt5 = obj.plc.Read("T3", (ushort)24); + if (bt5 == null) return; + var arr5 = ArrReverse(bt5); + + var fixtureboxtype1 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList1 = fdList.SingleOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 1); + if (oldList1 != null) + { + //只更新小时数量 + oldList1.Fixtureboxtype = fixtureboxtype1; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0F0", 1); + byte[] result2 = obj.plc.Read("Y0F1", 1); + byte[] result3 = obj.plc.Read("Y110", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList1.Fixturestatus = 1; + } + else + { + oldList1.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList1.AnHour = num - oldList1.AnHour; + break; + case 2: + oldList1.TwoHour = num - oldList1.TwoHour; + break; + case 3: + oldList1.ThreeHour = num - oldList1.ThreeHour; + break; + case 4: + oldList1.FourHour = num - oldList1.FourHour; + break; + case 5: + oldList1.FiveHour = num - oldList1.FiveHour; + break; + case 6: + oldList1.SixHour = num - oldList1.SixHour; + break; + case 7: + oldList1.SevenHour = num - oldList1.SevenHour; + break; + case 8: + oldList1.EightHour = num - oldList1.EightHour; ; + break; + case 9: + oldList1.NineHour = num - oldList1.NineHour; + break; + case 10: + oldList1.TenHour = num - oldList1.TenHour; + break; + case 11: + oldList1.ElevenHour = num - oldList1.ElevenHour; + break; + case 12: + oldList1.TwelveHour = num - oldList1.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList1.Production = short.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(),2), System.Globalization.NumberStyles.HexNumber); + oldList1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList1.UpdatedTime = DateTime.Now; + oldList1.ProductLineCode = "CX_01"; + oldList1.MainId = 1; + await _oldBoxFoamDataServices.UpdateAsync(oldList1); + } + else + { + BoxFoamData boxfoam1 = new BoxFoamData(); + //新增 + boxfoam1.Fixtureboxtype = fixtureboxtype1; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0F0", 1); + byte[] result2 = obj.plc.Read("Y0F1", 1); + byte[] result3 = obj.plc.Read("Y110", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam1.Fixturestatus = 1; + } + else + { + boxfoam1.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam1.AnHour = num; + break; + case 2: + boxfoam1.TwoHour = num; + break; + case 3: + boxfoam1.ThreeHour = num; + break; + case 4: + boxfoam1.FourHour = num; + break; + case 5: + boxfoam1.FiveHour = num; + break; + case 6: + boxfoam1.SixHour = num; + break; + case 7: + boxfoam1.SevenHour = num; + break; + case 8: + boxfoam1.EightHour = num; + break; + case 9: + boxfoam1.NineHour = num; + break; + case 10: + boxfoam1.TenHour = num; + break; + case 11: + boxfoam1.ElevenHour = num; + break; + case 12: + boxfoam1.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam1.ProductLineCode = "CX_01"; + boxfoam1.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + boxfoam1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam1.UpdatedTime = DateTime.Now; + boxfoam1.ProductLineCode = "CX_01"; + boxfoam1.MainId = 1; + await _oldBoxFoamDataServices.AddAsync(boxfoam1); + } + + var fixtureboxtype2 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(4).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList2 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 2); + if (oldList2 != null) + { + oldList2.Fixtureboxtype = fixtureboxtype2; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0F5", 1); + byte[] result2 = obj.plc.Read("Y0F6", 1); + byte[] result3 = obj.plc.Read("Y111", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList2.Fixturestatus = 1; + } + else + { + oldList2.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList2.AnHour = num - oldList2.AnHour; + break; + case 2: + oldList2.TwoHour = num - oldList2.TwoHour; + break; + case 3: + oldList2.ThreeHour = num - oldList2.ThreeHour; + break; + case 4: + oldList2.FourHour = num - oldList2.FourHour; + break; + case 5: + oldList2.FiveHour = num - oldList2.FiveHour; + break; + case 6: + oldList2.SixHour = num - oldList2.SixHour; + break; + case 7: + oldList2.SevenHour = num - oldList2.SevenHour; + break; + case 8: + oldList2.EightHour = num - oldList2.EightHour; ; + break; + case 9: + oldList2.NineHour = num - oldList2.NineHour; + break; + case 10: + oldList2.TenHour = num - oldList2.TenHour; + break; + case 11: + oldList2.ElevenHour = num - oldList2.ElevenHour; + break; + case 12: + oldList2.TwelveHour = num - oldList2.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList2.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber); + oldList2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList2.UpdatedTime = DateTime.Now; + oldList2.ProductLineCode = "CX_01"; + oldList2.MainId = 2; + await _oldBoxFoamDataServices.UpdateAsync(oldList2); + } + else + { + BoxFoamData boxfoam2 = new BoxFoamData(); + boxfoam2.Fixtureboxtype = fixtureboxtype2; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0F5", 1); + byte[] result2 = obj.plc.Read("Y0F6", 1); + byte[] result3 = obj.plc.Read("Y111", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam2.Fixturestatus = 1; + } + else + { + boxfoam2.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam2.AnHour = num; + break; + case 2: + boxfoam2.TwoHour = num; + break; + case 3: + boxfoam2.ThreeHour = num; + break; + case 4: + boxfoam2.FourHour = num; + break; + case 5: + boxfoam2.FiveHour = num; + break; + case 6: + boxfoam2.SixHour = num; + break; + case 7: + boxfoam2.SevenHour = num; + break; + case 8: + boxfoam2.EightHour = num; + break; + case 9: + boxfoam2.NineHour = num; + break; + case 10: + boxfoam2.TenHour = num; + break; + case 11: + boxfoam2.ElevenHour = num; + break; + case 12: + boxfoam2.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam2.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber); + boxfoam2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam2.UpdatedTime = DateTime.Now; + boxfoam2.MainId = 2; + boxfoam2.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam2); + } + + var fixtureboxtype3 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(8).Take(9).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList3 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype3 && d.MainId == 3); + if (oldList3 != null) + { + oldList3.Fixtureboxtype = fixtureboxtype3; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0FA", 1); + byte[] result2 = obj.plc.Read("Y0FB", 1); + byte[] result3 = obj.plc.Read("Y112", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList2.Fixturestatus = 1; + } + else + { + oldList2.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList3.AnHour = num - oldList3.AnHour; + break; + case 2: + oldList3.TwoHour = num - oldList3.TwoHour; + break; + case 3: + oldList3.ThreeHour = num - oldList3.ThreeHour; + break; + case 4: + oldList3.FourHour = num - oldList3.FourHour; + break; + case 5: + oldList3.FiveHour = num - oldList3.FiveHour; + break; + case 6: + oldList3.SixHour = num - oldList3.SixHour; + break; + case 7: + oldList3.SevenHour = num - oldList3.SevenHour; + break; + case 8: + oldList3.EightHour = num - oldList3.EightHour; ; + break; + case 9: + oldList3.NineHour = num - oldList3.NineHour; + break; + case 10: + oldList3.TenHour = num - oldList3.TenHour; + break; + case 11: + oldList3.ElevenHour = num - oldList3.ElevenHour; + break; + case 12: + oldList3.TwelveHour = num - oldList3.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList3.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + oldList3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 1), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList3.UpdatedTime = DateTime.Now; + oldList3.MainId = 3; + oldList3.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.UpdateAsync(oldList3); + } + else + { + BoxFoamData boxfoam3 = new BoxFoamData(); + boxfoam3.Fixtureboxtype = fixtureboxtype3; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0FA", 1); + byte[] result2 = obj.plc.Read("Y0FB", 1); + byte[] result3 = obj.plc.Read("Y112", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam3.Fixturestatus = 1; + } + else + { + boxfoam3.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(),1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam3.AnHour = num; + break; + case 2: + boxfoam3.TwoHour = num; + break; + case 3: + boxfoam3.ThreeHour = num; + break; + case 4: + boxfoam3.FourHour = num; + break; + case 5: + boxfoam3.FiveHour = num; + break; + case 6: + boxfoam3.SixHour = num; + break; + case 7: + boxfoam3.SevenHour = num; + break; + case 8: + boxfoam3.EightHour = num; + break; + case 9: + boxfoam3.NineHour = num; + break; + case 10: + boxfoam3.TenHour = num; + break; + case 11: + boxfoam3.ElevenHour = num; + break; + case 12: + boxfoam3.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam3.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + boxfoam3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam3.UpdatedTime = DateTime.Now; + boxfoam3.MainId = 3; + boxfoam3.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam3); + } + + + var fixtureboxtype4 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(12).Take(13).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList4 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype4 && d.MainId == 4); + if (oldList4 != null) + { + oldList4.Fixtureboxtype = fixtureboxtype4; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y100", 1); + byte[] result2 = obj2.plc.Read("Y101", 1); + byte[] result3 = obj2.plc.Read("Y113", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList4.Fixturestatus = 1; + } + else + { + oldList4.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList4.AnHour = num - oldList4.AnHour; + break; + case 2: + oldList4.TwoHour = num - oldList4.TwoHour; + break; + case 3: + oldList4.ThreeHour = num - oldList4.ThreeHour; + break; + case 4: + oldList4.FourHour = num - oldList4.FourHour; + break; + case 5: + oldList4.FiveHour = num - oldList4.FiveHour; + break; + case 6: + oldList4.SixHour = num - oldList4.SixHour; + break; + case 7: + oldList4.SevenHour = num - oldList4.SevenHour; + break; + case 8: + oldList4.EightHour = num - oldList4.EightHour; ; + break; + case 9: + oldList4.NineHour = num - oldList4.NineHour; + break; + case 10: + oldList4.TenHour = num - oldList4.TenHour; + break; + case 11: + oldList4.ElevenHour = num - oldList4.ElevenHour; + break; + case 12: + oldList4.TwelveHour = num - oldList4.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList4.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(),1), System.Globalization.NumberStyles.HexNumber); + oldList4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(12).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList4.UpdatedTime = DateTime.Now; + oldList4.MainId = 4; + oldList4.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.UpdateAsync(oldList4); + } + else + { + BoxFoamData boxfoam4 = new BoxFoamData(); + boxfoam4.Fixtureboxtype = fixtureboxtype4; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y100", 1); + byte[] result2 = obj2.plc.Read("Y101", 1); + byte[] result3 = obj2.plc.Read("Y113", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam4.Fixturestatus = 1; + } + else + { + boxfoam4.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam4.AnHour = num; + break; + case 2: + boxfoam4.TwoHour = num; + break; + case 3: + boxfoam4.ThreeHour = num; + break; + case 4: + boxfoam4.FourHour = num; + break; + case 5: + boxfoam4.FiveHour = num; + break; + case 6: + boxfoam4.SixHour = num; + break; + case 7: + boxfoam4.SevenHour = num; + break; + case 8: + boxfoam4.EightHour = num; + break; + case 9: + boxfoam4.NineHour = num; + break; + case 10: + boxfoam4.TenHour = num; + break; + case 11: + boxfoam4.ElevenHour = num; + break; + case 12: + boxfoam4.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam4.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + boxfoam4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam4.UpdatedTime = DateTime.Now; + boxfoam4.MainId = 4; + boxfoam4.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam4); + } + + var fixtureboxtype5 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(16).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList5 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype5 && d.MainId == 5); + if (oldList5 != null) + { + oldList5.Fixtureboxtype = fixtureboxtype5; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y105", 1); + byte[] result2 = obj2.plc.Read("Y106", 1); + byte[] result3 = obj2.plc.Read("Y114", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList5.Fixturestatus = 1; + } + else + { + oldList5.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(),1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList5.AnHour = num - oldList5.AnHour; + break; + case 2: + oldList5.TwoHour = num - oldList5.TwoHour; + break; + case 3: + oldList5.ThreeHour = num - oldList5.ThreeHour; + break; + case 4: + oldList5.FourHour = num - oldList5.FourHour; + break; + case 5: + oldList5.FiveHour = num - oldList5.FiveHour; + break; + case 6: + oldList5.SixHour = num - oldList5.SixHour; + break; + case 7: + oldList5.SevenHour = num - oldList5.SevenHour; + break; + case 8: + oldList5.EightHour = num - oldList5.EightHour; ; + break; + case 9: + oldList5.NineHour = num - oldList5.NineHour; + break; + case 10: + oldList5.TenHour = num - oldList5.TenHour; + break; + case 11: + oldList5.ElevenHour = num - oldList5.ElevenHour; + break; + case 12: + oldList5.TwelveHour = num - oldList5.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList5.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + oldList5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList5.UpdatedTime = DateTime.Now; + oldList5.MainId = 5; + oldList5.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.UpdateAsync(oldList5); + } + else + { + BoxFoamData boxfoam5 = new BoxFoamData(); + boxfoam5.Fixtureboxtype = fixtureboxtype5; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y105", 1); + byte[] result2 = obj2.plc.Read("Y106", 1); + byte[] result3 = obj2.plc.Read("Y114", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam5.Fixturestatus = 1; + } + else + { + boxfoam5.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam5.AnHour = num; + break; + case 2: + boxfoam5.TwoHour = num; + break; + case 3: + boxfoam5.ThreeHour = num; + break; + case 4: + boxfoam5.FourHour = num; + break; + case 5: + boxfoam5.FiveHour = num; + break; + case 6: + boxfoam5.SixHour = num; + break; + case 7: + boxfoam5.SevenHour = num; + break; + case 8: + boxfoam5.EightHour = num; + break; + case 9: + boxfoam5.NineHour = num; + break; + case 10: + boxfoam5.TenHour = num; + break; + case 11: + boxfoam5.ElevenHour = num; + break; + case 12: + boxfoam5.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam5.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + boxfoam5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam5.UpdatedTime = DateTime.Now; + boxfoam5.MainId = 5; + boxfoam5.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam5); + } + var fixtureboxtype6 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(20).Take(21).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList6 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype6 && d.MainId == 6); + if (oldList6 != null) + { + oldList6.Fixtureboxtype = fixtureboxtype6; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y10A", 1); + byte[] result2 = obj2.plc.Read("Y10B", 1); + byte[] result3 = obj2.plc.Read("Y115", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList6.Fixturestatus = 1; + } + else + { + oldList6.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(),2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList6.AnHour = num - oldList6.AnHour; + break; + case 2: + oldList6.TwoHour = num - oldList6.TwoHour; + break; + case 3: + oldList6.ThreeHour = num - oldList6.ThreeHour; + break; + case 4: + oldList6.FourHour = num - oldList6.FourHour; + break; + case 5: + oldList6.FiveHour = num - oldList6.FiveHour; + break; + case 6: + oldList6.SixHour = num - oldList6.SixHour; + break; + case 7: + oldList6.SevenHour = num - oldList6.SevenHour; + break; + case 8: + oldList6.EightHour = num - oldList6.EightHour; ; + break; + case 9: + oldList6.NineHour = num - oldList6.NineHour; + break; + case 10: + oldList6.TenHour = num - oldList6.TenHour; + break; + case 11: + oldList6.ElevenHour = num - oldList6.ElevenHour; + break; + case 12: + oldList6.TwelveHour = num - oldList6.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList6.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + oldList6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList6.UpdatedTime = DateTime.Now; + oldList6.MainId = 6; + oldList6.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.UpdateAsync(oldList6); + } + else + { + BoxFoamData boxfoam6 = new BoxFoamData(); + boxfoam6.Fixtureboxtype = fixtureboxtype6; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y10A", 1); + byte[] result2 = obj2.plc.Read("Y10B", 1); + byte[] result3 = obj2.plc.Read("Y115", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam6.Fixturestatus = 1; + } + else + { + boxfoam6.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam6.AnHour = num; + break; + case 2: + boxfoam6.TwoHour = num; + break; + case 3: + boxfoam6.ThreeHour = num; + break; + case 4: + boxfoam6.FourHour = num; + break; + case 5: + boxfoam6.FiveHour = num; + break; + case 6: + boxfoam6.SixHour = num; + break; + case 7: + boxfoam6.SevenHour = num; + break; + case 8: + boxfoam6.EightHour = num; + break; + case 9: + boxfoam6.NineHour = num; + break; + case 10: + boxfoam6.TenHour = num; + break; + case 11: + boxfoam6.ElevenHour = num; + break; + case 12: + boxfoam6.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam6.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + boxfoam6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam6.UpdatedTime = DateTime.Now; + boxfoam6.MainId = 6; + boxfoam6.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam6); + } + } + catch (Exception ex) + { + + throw; + } + } + + public async Task GetData2() + { + try + { + var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc4")); + if (obj2 == null) { return; } + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc3")); + if (obj == null) { return; } + string productLineCode = Appsettings.app("StationInfo", "ProductLineCode"); + List fdList = await _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode); + + byte[] bt = obj.plc.Read("D3140", (ushort)48); + if (bt == null) return; + var arr1 = ArrReverse(bt); + + byte[] bt3 = obj.plc.Read("D182", (ushort)24); + if (bt3 == null) return; + var arr3 = ArrReverse(bt3); + byte[] bt4 = obj.plc.Read("D910", (ushort)24); + if (bt4 == null) return; + var arr4 = ArrReverse(bt4); + byte[] bt5 = obj.plc.Read("T3", (ushort)24); + if (bt5 == null) return; + var arr5 = ArrReverse(bt5); + + var fixtureboxtype1 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList1 = fdList.SingleOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 1); + if (oldList1 != null) + { + //只更新小时数量 + oldList1.Fixtureboxtype = fixtureboxtype1; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0F0", 1); + byte[] result2 = obj.plc.Read("Y0F1", 1); + byte[] result3 = obj.plc.Read("Y110", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList1.Fixturestatus = 1; + } + else + { + oldList1.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList1.AnHour = num - oldList1.AnHour; + break; + case 2: + oldList1.TwoHour = num - oldList1.TwoHour; + break; + case 3: + oldList1.ThreeHour = num - oldList1.ThreeHour; + break; + case 4: + oldList1.FourHour = num - oldList1.FourHour; + break; + case 5: + oldList1.FiveHour = num - oldList1.FiveHour; + break; + case 6: + oldList1.SixHour = num - oldList1.SixHour; + break; + case 7: + oldList1.SevenHour = num - oldList1.SevenHour; + break; + case 8: + oldList1.EightHour = num - oldList1.EightHour; ; + break; + case 9: + oldList1.NineHour = num - oldList1.NineHour; + break; + case 10: + oldList1.TenHour = num - oldList1.TenHour; + break; + case 11: + oldList1.ElevenHour = num - oldList1.ElevenHour; + break; + case 12: + oldList1.TwelveHour = num - oldList1.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList1.Production = short.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + oldList1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList1.UpdatedTime = DateTime.Now; + oldList1.ProductLineCode = "CX_01"; + oldList1.MainId = 7; + await _oldBoxFoamDataServices.UpdateAsync(oldList1); + } + else + { + BoxFoamData boxfoam1 = new BoxFoamData(); + //新增 + boxfoam1.Fixtureboxtype = fixtureboxtype1; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0F0", 1); + byte[] result2 = obj.plc.Read("Y0F1", 1); + byte[] result3 = obj.plc.Read("Y110", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam1.Fixturestatus = 1; + } + else + { + boxfoam1.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam1.AnHour = num; + break; + case 2: + boxfoam1.TwoHour = num; + break; + case 3: + boxfoam1.ThreeHour = num; + break; + case 4: + boxfoam1.FourHour = num; + break; + case 5: + boxfoam1.FiveHour = num; + break; + case 6: + boxfoam1.SixHour = num; + break; + case 7: + boxfoam1.SevenHour = num; + break; + case 8: + boxfoam1.EightHour = num; + break; + case 9: + boxfoam1.NineHour = num; + break; + case 10: + boxfoam1.TenHour = num; + break; + case 11: + boxfoam1.ElevenHour = num; + break; + case 12: + boxfoam1.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam1.ProductLineCode = "CX_01"; + boxfoam1.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + boxfoam1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam1.UpdatedTime = DateTime.Now; + boxfoam1.ProductLineCode = "CX_01"; + boxfoam1.MainId = 7; + await _oldBoxFoamDataServices.AddAsync(boxfoam1); + } + + var fixtureboxtype2 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(4).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList2 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 2); + if (oldList2 != null) + { + oldList2.Fixtureboxtype = fixtureboxtype2; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0F5", 1); + byte[] result2 = obj.plc.Read("Y0F6", 1); + byte[] result3 = obj.plc.Read("Y111", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList2.Fixturestatus = 1; + } + else + { + oldList2.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList2.AnHour = num - oldList2.AnHour; + break; + case 2: + oldList2.TwoHour = num - oldList2.TwoHour; + break; + case 3: + oldList2.ThreeHour = num - oldList2.ThreeHour; + break; + case 4: + oldList2.FourHour = num - oldList2.FourHour; + break; + case 5: + oldList2.FiveHour = num - oldList2.FiveHour; + break; + case 6: + oldList2.SixHour = num - oldList2.SixHour; + break; + case 7: + oldList2.SevenHour = num - oldList2.SevenHour; + break; + case 8: + oldList2.EightHour = num - oldList2.EightHour; ; + break; + case 9: + oldList2.NineHour = num - oldList2.NineHour; + break; + case 10: + oldList2.TenHour = num - oldList2.TenHour; + break; + case 11: + oldList2.ElevenHour = num - oldList2.ElevenHour; + break; + case 12: + oldList2.TwelveHour = num - oldList2.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList2.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + oldList2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList2.UpdatedTime = DateTime.Now; + oldList2.ProductLineCode = "CX_01"; + oldList2.MainId = 8; + await _oldBoxFoamDataServices.UpdateAsync(oldList2); + } + else + { + BoxFoamData boxfoam2 = new BoxFoamData(); + boxfoam2.Fixtureboxtype = fixtureboxtype2; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0F5", 1); + byte[] result2 = obj.plc.Read("Y0F6", 1); + byte[] result3 = obj.plc.Read("Y111", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam2.Fixturestatus = 1; + } + else + { + boxfoam2.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam2.AnHour = num; + break; + case 2: + boxfoam2.TwoHour = num; + break; + case 3: + boxfoam2.ThreeHour = num; + break; + case 4: + boxfoam2.FourHour = num; + break; + case 5: + boxfoam2.FiveHour = num; + break; + case 6: + boxfoam2.SixHour = num; + break; + case 7: + boxfoam2.SevenHour = num; + break; + case 8: + boxfoam2.EightHour = num; + break; + case 9: + boxfoam2.NineHour = num; + break; + case 10: + boxfoam2.TenHour = num; + break; + case 11: + boxfoam2.ElevenHour = num; + break; + case 12: + boxfoam2.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam2.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + boxfoam2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam2.UpdatedTime = DateTime.Now; + boxfoam2.MainId = 8; + boxfoam2.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam2); + } + + var fixtureboxtype3 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(8).Take(9).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList3 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype3 && d.MainId == 3); + if (oldList3 != null) + { + oldList3.Fixtureboxtype = fixtureboxtype3; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0FA", 1); + byte[] result2 = obj.plc.Read("Y0FB", 1); + byte[] result3 = obj.plc.Read("Y112", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList2.Fixturestatus = 1; + } + else + { + oldList2.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList3.AnHour = num - oldList3.AnHour; + break; + case 2: + oldList3.TwoHour = num - oldList3.TwoHour; + break; + case 3: + oldList3.ThreeHour = num - oldList3.ThreeHour; + break; + case 4: + oldList3.FourHour = num - oldList3.FourHour; + break; + case 5: + oldList3.FiveHour = num - oldList3.FiveHour; + break; + case 6: + oldList3.SixHour = num - oldList3.SixHour; + break; + case 7: + oldList3.SevenHour = num - oldList3.SevenHour; + break; + case 8: + oldList3.EightHour = num - oldList3.EightHour; ; + break; + case 9: + oldList3.NineHour = num - oldList3.NineHour; + break; + case 10: + oldList3.TenHour = num - oldList3.TenHour; + break; + case 11: + oldList3.ElevenHour = num - oldList3.ElevenHour; + break; + case 12: + oldList3.TwelveHour = num - oldList3.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList3.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + oldList3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 1), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList3.UpdatedTime = DateTime.Now; + oldList3.MainId = 9; + oldList3.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.UpdateAsync(oldList3); + } + else + { + BoxFoamData boxfoam3 = new BoxFoamData(); + boxfoam3.Fixtureboxtype = fixtureboxtype3; + + #region 状态 + byte[] result1 = obj.plc.Read("Y0FA", 1); + byte[] result2 = obj.plc.Read("Y0FB", 1); + byte[] result3 = obj.plc.Read("Y112", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam3.Fixturestatus = 1; + } + else + { + boxfoam3.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam3.AnHour = num; + break; + case 2: + boxfoam3.TwoHour = num; + break; + case 3: + boxfoam3.ThreeHour = num; + break; + case 4: + boxfoam3.FourHour = num; + break; + case 5: + boxfoam3.FiveHour = num; + break; + case 6: + boxfoam3.SixHour = num; + break; + case 7: + boxfoam3.SevenHour = num; + break; + case 8: + boxfoam3.EightHour = num; + break; + case 9: + boxfoam3.NineHour = num; + break; + case 10: + boxfoam3.TenHour = num; + break; + case 11: + boxfoam3.ElevenHour = num; + break; + case 12: + boxfoam3.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam3.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + boxfoam3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam3.UpdatedTime = DateTime.Now; + boxfoam3.MainId = 9; + boxfoam3.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam3); + } + + + var fixtureboxtype4 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(12).Take(13).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList4 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype4 && d.MainId == 4); + if (oldList4 != null) + { + oldList4.Fixtureboxtype = fixtureboxtype4; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y100", 1); + byte[] result2 = obj2.plc.Read("Y101", 1); + byte[] result3 = obj2.plc.Read("Y113", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList4.Fixturestatus = 1; + } + else + { + oldList4.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList4.AnHour = num - oldList4.AnHour; + break; + case 2: + oldList4.TwoHour = num - oldList4.TwoHour; + break; + case 3: + oldList4.ThreeHour = num - oldList4.ThreeHour; + break; + case 4: + oldList4.FourHour = num - oldList4.FourHour; + break; + case 5: + oldList4.FiveHour = num - oldList4.FiveHour; + break; + case 6: + oldList4.SixHour = num - oldList4.SixHour; + break; + case 7: + oldList4.SevenHour = num - oldList4.SevenHour; + break; + case 8: + oldList4.EightHour = num - oldList4.EightHour; ; + break; + case 9: + oldList4.NineHour = num - oldList4.NineHour; + break; + case 10: + oldList4.TenHour = num - oldList4.TenHour; + break; + case 11: + oldList4.ElevenHour = num - oldList4.ElevenHour; + break; + case 12: + oldList4.TwelveHour = num - oldList4.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList4.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + oldList4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(12).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList4.UpdatedTime = DateTime.Now; + oldList4.MainId = 10; + oldList4.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.UpdateAsync(oldList4); + } + else + { + BoxFoamData boxfoam4 = new BoxFoamData(); + boxfoam4.Fixtureboxtype = fixtureboxtype4; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y100", 1); + byte[] result2 = obj2.plc.Read("Y101", 1); + byte[] result3 = obj2.plc.Read("Y113", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam4.Fixturestatus = 1; + } + else + { + boxfoam4.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam4.AnHour = num; + break; + case 2: + boxfoam4.TwoHour = num; + break; + case 3: + boxfoam4.ThreeHour = num; + break; + case 4: + boxfoam4.FourHour = num; + break; + case 5: + boxfoam4.FiveHour = num; + break; + case 6: + boxfoam4.SixHour = num; + break; + case 7: + boxfoam4.SevenHour = num; + break; + case 8: + boxfoam4.EightHour = num; + break; + case 9: + boxfoam4.NineHour = num; + break; + case 10: + boxfoam4.TenHour = num; + break; + case 11: + boxfoam4.ElevenHour = num; + break; + case 12: + boxfoam4.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam4.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + boxfoam4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam4.UpdatedTime = DateTime.Now; + boxfoam4.MainId = 10; + boxfoam4.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam4); + } + + var fixtureboxtype5 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(16).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList5 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype5 && d.MainId == 5); + if (oldList5 != null) + { + oldList5.Fixtureboxtype = fixtureboxtype5; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y105", 1); + byte[] result2 = obj2.plc.Read("Y106", 1); + byte[] result3 = obj2.plc.Read("Y114", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList5.Fixturestatus = 1; + } + else + { + oldList5.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList5.AnHour = num - oldList5.AnHour; + break; + case 2: + oldList5.TwoHour = num - oldList5.TwoHour; + break; + case 3: + oldList5.ThreeHour = num - oldList5.ThreeHour; + break; + case 4: + oldList5.FourHour = num - oldList5.FourHour; + break; + case 5: + oldList5.FiveHour = num - oldList5.FiveHour; + break; + case 6: + oldList5.SixHour = num - oldList5.SixHour; + break; + case 7: + oldList5.SevenHour = num - oldList5.SevenHour; + break; + case 8: + oldList5.EightHour = num - oldList5.EightHour; ; + break; + case 9: + oldList5.NineHour = num - oldList5.NineHour; + break; + case 10: + oldList5.TenHour = num - oldList5.TenHour; + break; + case 11: + oldList5.ElevenHour = num - oldList5.ElevenHour; + break; + case 12: + oldList5.TwelveHour = num - oldList5.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList5.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(), 1), System.Globalization.NumberStyles.HexNumber); + oldList5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList5.UpdatedTime = DateTime.Now; + oldList5.MainId = 11; + oldList5.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.UpdateAsync(oldList5); + } + else + { + BoxFoamData boxfoam5 = new BoxFoamData(); + boxfoam5.Fixtureboxtype = fixtureboxtype5; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y105", 1); + byte[] result2 = obj2.plc.Read("Y106", 1); + byte[] result3 = obj2.plc.Read("Y114", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam5.Fixturestatus = 1; + } + else + { + boxfoam5.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam5.AnHour = num; + break; + case 2: + boxfoam5.TwoHour = num; + break; + case 3: + boxfoam5.ThreeHour = num; + break; + case 4: + boxfoam5.FourHour = num; + break; + case 5: + boxfoam5.FiveHour = num; + break; + case 6: + boxfoam5.SixHour = num; + break; + case 7: + boxfoam5.SevenHour = num; + break; + case 8: + boxfoam5.EightHour = num; + break; + case 9: + boxfoam5.NineHour = num; + break; + case 10: + boxfoam5.TenHour = num; + break; + case 11: + boxfoam5.ElevenHour = num; + break; + case 12: + boxfoam5.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam5.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + boxfoam5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam5.UpdatedTime = DateTime.Now; + boxfoam5.MainId = 11; + boxfoam5.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam5); + } + var fixtureboxtype6 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(20).Take(21).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + var oldList6 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype6 && d.MainId == 6); + if (oldList6 != null) + { + oldList6.Fixtureboxtype = fixtureboxtype6; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y10A", 1); + byte[] result2 = obj2.plc.Read("Y10B", 1); + byte[] result3 = obj2.plc.Read("Y115", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + oldList6.Fixturestatus = 1; + } + else + { + oldList6.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + oldList6.AnHour = num - oldList6.AnHour; + break; + case 2: + oldList6.TwoHour = num - oldList6.TwoHour; + break; + case 3: + oldList6.ThreeHour = num - oldList6.ThreeHour; + break; + case 4: + oldList6.FourHour = num - oldList6.FourHour; + break; + case 5: + oldList6.FiveHour = num - oldList6.FiveHour; + break; + case 6: + oldList6.SixHour = num - oldList6.SixHour; + break; + case 7: + oldList6.SevenHour = num - oldList6.SevenHour; + break; + case 8: + oldList6.EightHour = num - oldList6.EightHour; ; + break; + case 9: + oldList6.NineHour = num - oldList6.NineHour; + break; + case 10: + oldList6.TenHour = num - oldList6.TenHour; + break; + case 11: + oldList6.ElevenHour = num - oldList6.ElevenHour; + break; + case 12: + oldList6.TwelveHour = num - oldList6.TwelveHour; + break; + default: + break; + } + + #endregion + + oldList6.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + oldList6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString(); + oldList6.UpdatedTime = DateTime.Now; + oldList6.MainId = 12; + oldList6.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.UpdateAsync(oldList6); + } + else + { + BoxFoamData boxfoam6 = new BoxFoamData(); + boxfoam6.Fixtureboxtype = fixtureboxtype6; + + #region 状态 + byte[] result1 = obj2.plc.Read("Y10A", 1); + byte[] result2 = obj2.plc.Read("Y10B", 1); + byte[] result3 = obj2.plc.Read("Y115", 1); + int status1 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result1), result1.Length), System.Globalization.NumberStyles.HexNumber); + int status2 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result2), result2.Length), System.Globalization.NumberStyles.HexNumber); + int status3 = int.Parse(UnicodeHelper.BytesToHexStr(ArrReverse(result3), result3.Length), System.Globalization.NumberStyles.HexNumber); + + if (status2 == 1) + { + boxfoam6.Fixturestatus = 1; + } + else + { + boxfoam6.Fixturestatus = 0; + } + #endregion + + #region 计算每小时产量 + int num = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + switch (GetTeamHour()) + { + case 1: + boxfoam6.AnHour = num; + break; + case 2: + boxfoam6.TwoHour = num; + break; + case 3: + boxfoam6.ThreeHour = num; + break; + case 4: + boxfoam6.FourHour = num; + break; + case 5: + boxfoam6.FiveHour = num; + break; + case 6: + boxfoam6.SixHour = num; + break; + case 7: + boxfoam6.SevenHour = num; + break; + case 8: + boxfoam6.EightHour = num; + break; + case 9: + boxfoam6.NineHour = num; + break; + case 10: + boxfoam6.TenHour = num; + break; + case 11: + boxfoam6.ElevenHour = num; + break; + case 12: + boxfoam6.TwelveHour = num; + break; + default: + break; + } + + #endregion + + boxfoam6.Production = int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber); + boxfoam6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString(); + boxfoam6.UpdatedTime = DateTime.Now; + boxfoam6.MainId = 12; + boxfoam6.ProductLineCode = "CX_01"; + await _oldBoxFoamDataServices.AddAsync(boxfoam6); + } + } + catch (Exception ex) + { + + throw; + } + } + public int GetTeamHour() + { + DateTime now= DateTime.Now; + var obj = _sysUserInfoServices.GetTeamData(now).Result; + return obj.Seq; + } + } } diff --git a/Aucma.Core.BoxFoam/Models/OldBoxFoamDataModel.cs b/Aucma.Core.BoxFoam/Models/OldBoxFoamDataModel.cs index 8b6f19c0..df344945 100644 --- a/Aucma.Core.BoxFoam/Models/OldBoxFoamDataModel.cs +++ b/Aucma.Core.BoxFoam/Models/OldBoxFoamDataModel.cs @@ -17,7 +17,7 @@ namespace Aucma.Core.BoxFoam.Models /// /// 夹具状态 /// - public string Fixturestatus { get; set; } + public int Fixturestatus { get; set; } /// /// 产量 diff --git a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs index f2472ad6..4f17b97c 100644 --- a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs +++ b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs @@ -70,7 +70,7 @@ namespace Aucma.Core.BoxFoam.ViewModels { string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code - var baseSpaceInfolist = _baseSpaceInfoServices.QueryAsync(d => d.StoreCode.Equals(storeCode)).Result;//仓库 + var baseSpaceInfolist = _baseSpaceInfoServices.QueryAsync(d => d.StoreCode==storeCode).Result;//仓库 if (baseSpaceInfolist == null) return; Shapes.Clear(); diff --git a/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs index 0cef152f..81b9bb85 100644 --- a/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs @@ -263,18 +263,18 @@ namespace Aucma.Core.BoxFoam.ViewModels if (list == null) return; foreach (var item in list) { - if (item.BoxFixturestatus == 1) StatusColor.Add("Green"); - if (item.BoxFixturestatus == 0) StatusColor.Add("Red"); + if (item.Fixturestatus == 1) StatusColor.Add("Green"); + if (item.Fixturestatus == 0) StatusColor.Add("Red"); - FixtureName.Add(item.BoxFixturetype); - Production.Add(item.BoxFixtureproduction.ToString()); - FoamVolume.Add(item.FoamVolume); - InternalTemperature.Add(item.BoxClosebetatemperature.ToString()); - OutsideTemperature.Add(item.BoxFixturesideplate.ToString()); + FixtureName.Add(item.Fixtureboxtype); + Production.Add(item.Production.ToString()); + //FoamVolume.Add(item.v); + //InternalTemperature.Add(item.BoxClosebetatemperature.ToString()); + //OutsideTemperature.Add(item.BoxFixturesideplate.ToString()); Beat.Add(item.BoxBeat); - total += item.BoxFixtureproduction; + total += item.Production; } Totle = total; } diff --git a/Aucma.Core.BoxFoam/ViewModels/OldBoxFoamPageViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/OldBoxFoamPageViewModel.cs index 4294244d..d5cbc52c 100644 --- a/Aucma.Core.BoxFoam/ViewModels/OldBoxFoamPageViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/OldBoxFoamPageViewModel.cs @@ -19,10 +19,10 @@ namespace Aucma.Core.BoxFoam.ViewModels { public partial class OldBoxFoamPageViewModel : ObservableObject { - IOldBoxFoamDataServices? _oldBoxFoamDataServices; + IBoxFoamDataServices? _oldBoxFoamDataServices; IOldBoxFoamTypeServices _oldBoxFoamTypeServices; public OldBoxFoamPageViewModel() { - _oldBoxFoamDataServices = App.ServiceProvider.GetService(); + _oldBoxFoamDataServices = App.ServiceProvider.GetService(); _oldBoxFoamTypeServices = App.ServiceProvider.GetService(); //Job_OldBoxFoam_Quartz.RefreshOldBoxFoamTypeDataDelegateEvent += OldBoxFoamTypeOnLoad; @@ -35,7 +35,7 @@ namespace Aucma.Core.BoxFoam.ViewModels public async Task OldBoxFoamOnLoad() { - List list = await _oldBoxFoamDataServices.QueryAsync(); + List list = await _oldBoxFoamDataServices.QueryAsync(); if (list == null) return; foreach (var item in list) { diff --git a/Aucma.Core.HwPLc/Impl/MelsecPlc.cs b/Aucma.Core.HwPLc/Impl/MelsecPlc.cs index 6e1f962d..6aa32fe0 100644 --- a/Aucma.Core.HwPLc/Impl/MelsecPlc.cs +++ b/Aucma.Core.HwPLc/Impl/MelsecPlc.cs @@ -1,7 +1,10 @@ using HwCommunication; +using HwCommunication.Core; using HwCommunication.Profinet.Melsec; using log4net; using System; +using System.Collections.Generic; +using System.Linq; using System.Text; using System.Threading.Tasks; @@ -34,7 +37,7 @@ namespace Aucma.Core.HwPLc // //log.Info("HslCommunication激活失败"); // return; //} - Console.WriteLine("HwCommunication激活成功!"); + //Console.WriteLine("HwCommunication激活成功!"); melsecMcNet = new MelsecMcNet(); melsecMcNet.ConnectTimeOut = 2000; IsConnected = Connect(iP, port);//建立连接 @@ -518,6 +521,7 @@ namespace Aucma.Core.HwPLc if (readbyte.IsSuccess) { IsConnected = true; + return readbyte.Content; } else @@ -526,5 +530,6 @@ namespace Aucma.Core.HwPLc return null; } } + } } diff --git a/Aucma.Core.OldBoxFoam/Models/OldBoxFoamDataModel.cs b/Aucma.Core.OldBoxFoam/Models/OldBoxFoamDataModel.cs index 1b0ee42d..33ab29dc 100644 --- a/Aucma.Core.OldBoxFoam/Models/OldBoxFoamDataModel.cs +++ b/Aucma.Core.OldBoxFoam/Models/OldBoxFoamDataModel.cs @@ -17,7 +17,7 @@ namespace Aucma.Core.OldBoxFoam.Models /// /// 夹具状态 /// - public string Fixturestatus { get; set; } + public int Fixturestatus { get; set; } /// /// 产量 diff --git a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs index a61e688a..e81bfe8f 100644 --- a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs +++ b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs @@ -20,10 +20,11 @@ namespace Aucma.Core.OldBoxFoam.ViewModels { public partial class OldBoxFoamPageViewModel : ObservableObject { - IOldBoxFoamDataServices? _oldBoxFoamDataServices; + IBoxFoamDataServices? _oldBoxFoamDataServices; IOldBoxFoamTypeServices _oldBoxFoamTypeServices; + public OldBoxFoamPageViewModel() { - _oldBoxFoamDataServices = App.ServiceProvider.GetService(); + _oldBoxFoamDataServices = App.ServiceProvider.GetService(); _oldBoxFoamTypeServices = App.ServiceProvider.GetService(); Job_OldBoxFoam_Quartz.RefreshOldBoxFoamTypeDataDelegateEvent += OldBoxFoamTypeOnLoad3; @@ -36,8 +37,9 @@ namespace Aucma.Core.OldBoxFoam.ViewModels public async Task OldBoxFoamOnLoad() { - List list = await _oldBoxFoamDataServices.QueryAsync(); + List list = await _oldBoxFoamDataServices.QueryAsync(); if (list == null) return; + int i = 0; foreach (var item in list) { OldBoxFoamDataModel model = new OldBoxFoamDataModel(); @@ -46,18 +48,29 @@ namespace Aucma.Core.OldBoxFoam.ViewModels model.Fixturestatus = item.Fixturestatus; model.Production = item.Production; model.CuringTimeSettingValue = item.CuringTimeSettingValue; - model.ActualValue = item.ActualValue; - - _oldBoxFoamDataGrid.Add(model); + if (item.Fixturestatus == 1)//停止 + { + _statusColor.Add("green"); + + } + else + { + _statusColor.Add("red"); + } + _fixtureName.Add(item.Fixtureboxtype); + _production.Add(item.Production); + _beat.Add(item.BoxBeat); + i =+ item.Production; } + _totle = list.Sum(d=>d.Production); } - public Task OldBoxFoamOnLoad3(List list) + public Task OldBoxFoamOnLoad3(List list) { if (list == null) return Task.CompletedTask; System.Windows.Application.Current.Dispatcher.Invoke((Action)( () => { OldBoxFoamDataGrid.Clear(); - + int i = 0; foreach (var item in list) { OldBoxFoamDataModel model = new OldBoxFoamDataModel(); @@ -66,9 +79,19 @@ namespace Aucma.Core.OldBoxFoam.ViewModels model.Fixturestatus = item.Fixturestatus; model.Production = item.Production; model.CuringTimeSettingValue = item.CuringTimeSettingValue; - model.ActualValue = item.ActualValue; + if (item.Fixturestatus == 1)//停止 + { + _statusColor.Add("green"); - OldBoxFoamDataGrid.Add(model); + } + else + { + _statusColor.Add("red"); + } + _fixtureName.Add(item.Fixtureboxtype); + _production.Add(item.Production); + _beat.Add(item.BoxBeat); + i = +item.Production; } })); @@ -126,5 +149,56 @@ namespace Aucma.Core.OldBoxFoam.ViewModels set => SetProperty(ref _oldBoxFoamTypeDataGrid, value); } #endregion + + #region 夹具状态 + private ObservableCollection _statusColor = new ObservableCollection(); + public ObservableCollection StatusColor + { + get => _statusColor; + set => SetProperty(ref _statusColor, value); + } + #endregion + + #region 夹具名称 + private ObservableCollection _fixtureName = new ObservableCollection(); + public ObservableCollection FixtureName + { + get => _fixtureName; + set => SetProperty(ref _fixtureName, value); + } + #endregion + + #region 夹具产量 + /// + ///夹具产量 + /// + private ObservableCollection _production = new ObservableCollection(); + public ObservableCollection Production + { + get => _production; + set => SetProperty(ref _production, value); + } + #endregion + + #region 节拍 + /// + ///夹具产量 + /// + private ObservableCollection _beat = new ObservableCollection(); + public ObservableCollection Beat + { + get => _beat; + set => SetProperty(ref _beat, value); + } + #endregion + + #region 总计 + private int _totle = 0; + public int Totle + { + get => _totle; + set => SetProperty(ref _totle, value); + } + #endregion } } diff --git a/Aucma.Core.OldBoxFoam/ViewModels/SplitPlanViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/SplitPlanViewModel.cs index 79fee37d..110c856d 100644 --- a/Aucma.Core.OldBoxFoam/ViewModels/SplitPlanViewModel.cs +++ b/Aucma.Core.OldBoxFoam/ViewModels/SplitPlanViewModel.cs @@ -256,13 +256,11 @@ namespace Aucma.Core.OldBoxFoam.ViewModels /// 重置 /// [RelayCommand] - public void Reset() + public async void Reset() { - LoadData(); - Search = string.Empty; MaterialTypeCombox = string.Empty; - this.LoadData(); + await this.LoadData(); } #endregion diff --git a/Aucma.Core.OldBoxFoam/Views/OldBoxFoamPageView.xaml b/Aucma.Core.OldBoxFoam/Views/OldBoxFoamPageView.xaml index 76ff571f..b02b6346 100644 --- a/Aucma.Core.OldBoxFoam/Views/OldBoxFoamPageView.xaml +++ b/Aucma.Core.OldBoxFoam/Views/OldBoxFoamPageView.xaml @@ -71,37 +71,218 @@ - + - + + + + + - - + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/Aucma.Core.OldBoxFoam/appsettings.json b/Aucma.Core.OldBoxFoam/appsettings.json index 4e10b638..ee789b85 100644 --- a/Aucma.Core.OldBoxFoam/appsettings.json +++ b/Aucma.Core.OldBoxFoam/appsettings.json @@ -98,7 +98,7 @@ "ID": 1, "Name": "OldBoxFoam", "JobGroup": "DEFAULT", - "Cron": "*/1 * * * * ?", + "Cron": "*/5 * * * * ?", "AssemblyName": "Admin.Core.Tasks", "ClassName": "Job_OldBoxFoam_Quartz", "Remark": "执行老发泡线任务调度系统", @@ -167,6 +167,9 @@ "Enabled": true } }, + "StationInfo": { + "ProductLineCode": "CX_01" + }, "PLCServer": [ { "Id": 1, diff --git a/Aucma.Core.Tasks/AucamTaskService.cs b/Aucma.Core.Tasks/AucamTaskService.cs index 62433103..30769d92 100644 --- a/Aucma.Core.Tasks/AucamTaskService.cs +++ b/Aucma.Core.Tasks/AucamTaskService.cs @@ -32,7 +32,7 @@ namespace Aucma.Core.Tasks private readonly ISMProductionCompletionRecordServices _smProductionCompletionRecordServices; public AucamTaskService(ISmTaskExecutionServices smTaskExecutionServices, ISMProductionCompletionRecordServices smProductionCompletionRecordServices, - IOldBoxFoamDataServices oldBoxFoamDataServices) + IBoxFoamDataServices oldBoxFoamDataServices) { _smTaskExecutionServices= smTaskExecutionServices; _smProductionCompletionRecordServices = smProductionCompletionRecordServices;