zhanghonglin
7 小时以前 b51cfdec1dde066a1afbec0fa816347031ca6d25
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ZXJ/ZXJJob.cs
@@ -20,6 +20,7 @@
using WIDESEAWCS_ISystemServices;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_Model.Models.System;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.DeviceBase;
using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
@@ -31,19 +32,25 @@
    public class ZXJJob : JobBase, IJob
    {
        public static bool W_ZXJ_Heat = true;
        public static bool W_TC_Heat = true;
        public static bool W_GZJ_Heat = true;
        private readonly ITaskService _taskService;
        private readonly Idt_ThicknessHtyService _IThicknessHtyService;
        private readonly Idt_WeightHtyService _IWeightHtyService;
        WebSocketServer _webSocketServer;
        private readonly Idt_ErrormsginfoService _ErrormsginfoService;
        public ZXJJob(ITaskService taskService, WebSocketServer webSocketServer,Idt_ErrormsginfoService errormsginfoService)
        public ZXJJob(ITaskService taskService, WebSocketServer webSocketServer,Idt_ErrormsginfoService errormsginfoService, Idt_ThicknessHtyService ThicknessHtyService, Idt_WeightHtyService WeightHtyService)
        {
            _taskService = taskService;//注入
            _webSocketServer = webSocketServer;
            _ErrormsginfoService = errormsginfoService;
            _IThicknessHtyService = ThicknessHtyService;
            _IWeightHtyService = WeightHtyService;
        }
        public Task Execute(IJobExecutionContext context)
        {
            //return Task.CompletedTask;
            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
            if (flag && value != null)
            {
@@ -68,6 +75,16 @@
                        OHTJob.oHTReadData.R_Loaded_2 = TCevice.GetValue<DeviceDBName, short>(DeviceDBName.R_Loaded_2);
                        OHTJob.oHTReadData.weight = TCevice.GetValue<DeviceDBName, float>(DeviceDBName.weight);
                        #endregion
                        if (W_TC_Heat)
                        {
                            W_TC_Heat = false;
                            TCevice.SetValue(DeviceDBName.W_HeartBeat, W_TC_Heat);
                        }
                        else
                        {
                            W_TC_Heat = true;
                            TCevice.SetValue(DeviceDBName.W_HeartBeat, W_TC_Heat);
                        }
                    }
                    else
                    {
@@ -88,7 +105,156 @@
                        OHTJob.oHTReadData.R_HC_isReady = device.GetValue<ZXJDBName, bool>(ZXJDBName.R_HC_isReady);
                        OHTJob.oHTReadData.R_HC_isReadyWork = device.GetValue<ZXJDBName, bool>(ZXJDBName.R_HC_isReadyWork);
                        OHTJob.oHTReadData.R_issafe = device.GetValue<ZXJDBName, bool>(ZXJDBName.R_issafe);
                        //总数
                        OHTJob.oHTReadData.R_CommonRecorder = device.GetValue<ZXJDBName, Int16>(ZXJDBName.R_CommonRecorder);
                        OHTJob.oHTReadData.R_SpecialRecorder = device.GetValue<ZXJDBName, Int16>(ZXJDBName.R_SpecialRecorder);
                        OHTJob.oHTReadData.R_TotalWeight = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TotalWeight);
                        //重量厚度上、下限值
                        //厚度
                        float tza1 = OHTJob.oHTReadData.R_TopLeftUp = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TopLeftUp);
                        float tza2 = OHTJob.oHTReadData.R_TopLeftBelow = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TopLeftBelow);
                        float tzb1 = OHTJob.oHTReadData.R_TopMiddleUp = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TopMiddleUp);
                        float tzb2 = OHTJob.oHTReadData.R_TopMiddleBelow = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TopMiddleBelow);
                        float tzc1 = OHTJob.oHTReadData.R_TopRightUp = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TopRightUp);
                        float tzc2 = OHTJob.oHTReadData.R_TopRightBelow = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TopRightBelow);
                        float tzd1 = OHTJob.oHTReadData.R_CentreLeftUp = device.GetValue<ZXJDBName, float>(ZXJDBName.R_CentreLeftUp);
                        float tzd2 = OHTJob.oHTReadData.R_CentreLeftBelow = device.GetValue<ZXJDBName, float>(ZXJDBName.R_CentreLeftBelow);
                        float tze1 = OHTJob.oHTReadData.R_CentreMiddleUp = device.GetValue<ZXJDBName, float>(ZXJDBName.R_CentreMiddleUp);
                        float tze2 = OHTJob.oHTReadData.R_CentreMiddleBelow = device.GetValue<ZXJDBName, float>(ZXJDBName.R_CentreMiddleBelow);
                        float tzf1 = OHTJob.oHTReadData.R_CentreRightUp = device.GetValue<ZXJDBName, float>(ZXJDBName.R_CentreRightUp);
                        float tzf2 = OHTJob.oHTReadData.R_CentreRightBelow = device.GetValue<ZXJDBName, float>(ZXJDBName.R_CentreRightBelow);
                        float tzg1 = OHTJob.oHTReadData.R_BottomLeftUp = device.GetValue<ZXJDBName, float>(ZXJDBName.R_BottomLeftUp);
                        float tzg2 = OHTJob.oHTReadData.R_BottomLeftBelow = device.GetValue<ZXJDBName, float>(ZXJDBName.R_BottomLeftBelow);
                        float tzh1 = OHTJob.oHTReadData.R_BottomRightUp = device.GetValue<ZXJDBName, float>(ZXJDBName.R_BottomRightUp);
                        float tzh2 = OHTJob.oHTReadData.R_BottomRightBelow = device.GetValue<ZXJDBName, float>(ZXJDBName.R_BottomRightBelow);
                        //重量
                        float ws1 = OHTJob.oHTReadData.R_WeightUp = device.GetValue<ZXJDBName, float>(ZXJDBName.R_WeightUp);
                        float ws2 = OHTJob.oHTReadData.R_WeightBelow = device.GetValue<ZXJDBName, float>(ZXJDBName.R_WeightBelow);
                        //重量厚度值
                        //厚度
                        float tz1 = OHTJob.oHTReadData.R_TopLeft = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TopLeft);
                        float tz2 = OHTJob.oHTReadData.R_TopMiddle = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TopMiddle);
                        float tz3 = OHTJob.oHTReadData.R_TopRight = device.GetValue<ZXJDBName, float>(ZXJDBName.R_TopRight);
                        float tz4 = OHTJob.oHTReadData.R_CentreLeft = device.GetValue<ZXJDBName, float>(ZXJDBName.R_CentreLeft);
                        float tz5 = OHTJob.oHTReadData.R_CentreMiddle = device.GetValue<ZXJDBName, float>(ZXJDBName.R_CentreMiddle);
                        float tz6 = OHTJob.oHTReadData.R_CentreRight = device.GetValue<ZXJDBName, float>(ZXJDBName.R_CentreRight);
                        float tz7 = OHTJob.oHTReadData.R_BottomLeft = device.GetValue<ZXJDBName, float>(ZXJDBName.R_BottomLeft);
                        float tz8 = OHTJob.oHTReadData.R_BottomRight = device.GetValue<ZXJDBName, float>(ZXJDBName.R_BottomRight);
                        //重量
                        float w = OHTJob.oHTReadData.R_Weight = device.GetValue<ZXJDBName, float>(ZXJDBName.R_Weight);
                        //记录重量厚度
                        bool thickness = OHTJob.oHTReadData.R_ThicknessRecorder = device.GetValue<ZXJDBName, bool>(ZXJDBName.R_ThicknessRecorder);
                        bool weight = OHTJob.oHTReadData.R_WeightRecorder = device.GetValue<ZXJDBName, bool>(ZXJDBName.R_WeightRecorder);
                        #endregion
                        //记录重量与厚度
                        //厚度
                        if (thickness)
                        {
                            dt_Thickness_hty dt_thickness = new dt_Thickness_hty();
                            dt_thickness.topleft = tz1;
                            dt_thickness.topmiddle = tz2;
                            dt_thickness.topright = tz3;
                            dt_thickness.centreleft = tz4;
                            dt_thickness.centremiddle = tz5;
                            dt_thickness.centreright = tz6;
                            dt_thickness.bottomleft = tz7;
                            dt_thickness.bottomright = tz8;
                            int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0;
                            //判断合格
                            if (tz1 < tza2 && tz1 > tza1)
                            {
                                a = 1;
                            }
                            if (tz2 < tzb2 && tz2 > tzb1)
                            {
                                b = 1;
                            }
                            if (tz3 < tzc2 && tz3 > tzc1)
                            {
                                c = 1;
                            }
                            if (tz4 < tzd2 && tz4 > tzd1)
                            {
                                d = 1;
                            }
                            if (tz5 < tze2 && tz5 > tze1)
                            {
                                e = 1;
                            }
                            if (tz6 < tzf2 && tz6 > tzf1)
                            {
                                f = 1;
                            }
                            if (tz7 < tzg2 && tz7 > tzg1)
                            {
                                g = 1;
                            }
                            if (tz8 < tzh2 && tz8 > tzh1)
                            {
                                h = 1;
                            }
                            if (a == 1 && b == 1 && c == 1 && d == 1 && e == 1 && f == 1 && g == 1 && h == 1)
                            {
                                dt_thickness.qualified = 1;
                            }
                            else
                            {
                                dt_thickness.qualified = 0;
                            }
                            //区间值
                            dt_thickness.interval = tza1 + "-" + tza2+","+ tzb1 + "-" + tzb2 + "," + tzc1 + "-" + tzc2 + "," + tzd1 + "-" + tzd2 + "," + tze1 + "-" + tze2 + "," + tzf1 + "-" + tzf2 + "," + tzg1 + "-" + tzg2 + "," + tzh1 + "-" + tzh2;
                            if(tz1 != 0 && tz2 != 0 && tz3 != 0 && tz4 != 0 && tz5 != 0 && tz6 != 0 && tz7 != 0 && tz8 != 0)
                            {
                                _IThicknessHtyService.AddData(dt_thickness);
                            }
                            device.SetValue(DeviceDBName.R_ThicknessSuccess, true);
                            //防止整形机没收到信号延时
                            Thread.Sleep(400);
                            device.SetValue(DeviceDBName.R_ThicknessSuccess, false);
                            //防止整形机不能即使更改信号导致重复生成记录,延时
                            Thread.Sleep(400);
                        }
                        //重量
                        if (weight)
                        {
                            dt_Weight_hty dt_weight = new dt_Weight_hty();
                            dt_weight.weight = w;
                            //判断合格
                            if (w>ws1&&w<ws2)
                            {
                                dt_weight.qualified = 1;
                            }
                            else
                            {
                                dt_weight.qualified = 0;
                            }
                            //区间值
                            dt_weight.interval = ws1+"-"+ws2;
                            //不得小于150大于350
                            if (w > 150 && w < 350 && w!=0)
                            {
                                _IWeightHtyService.AddData(dt_weight);
                            }
                            device.SetValue(DeviceDBName.R_WeightSuccess, true);
                            bool c = device.GetValue<DeviceDBName, bool>(DeviceDBName.R_WeightSuccess);
                            //防止整形机没收到信号延时
                            Thread.Sleep(400);
                            device.SetValue(DeviceDBName.R_WeightSuccess, false);
                            //防止整形机不能即使更改信号导致重复生成记录,延时
                            Thread.Sleep(400);
                        }
                        if (W_ZXJ_Heat)
                        {
                            W_ZXJ_Heat = false;
@@ -118,6 +284,16 @@
                        OHTJob.oHTReadData.R_XK_isready = GZJevice.GetValue<GZJDBName, bool>(GZJDBName.R_XK_isready);
                        OHTJob.oHTReadData.R_TC_isready = GZJevice.GetValue<GZJDBName, bool>(GZJDBName.R_TC_isready);
                        #endregion
                        if (W_GZJ_Heat)
                        {
                            W_GZJ_Heat = false;
                            GZJevice.SetValue(GZJDBName.W_GZJ_HeartBeat, W_GZJ_Heat);
                        }
                        else
                        {
                            W_GZJ_Heat = true;
                            GZJevice.SetValue(GZJDBName.W_GZJ_HeartBeat, W_GZJ_Heat);
                        }
                    }
                    else
                    {