wangxinhui
2025-04-08 dcecb039035f4b2e82e31c39b74db9402444c536
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/³ÉÆ·²Ö/ConveyorLineJob_CP.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using Quartz;
using SqlSugar.Extensions;
using System;
@@ -150,6 +151,48 @@
                        
                    }
                }
                Dt_StationManger? dt_StationManger = stationMangers.FirstOrDefault(x => x.StationType == StationTypeEnum.StationType_ProductBackTake.ObjToInt());
                if (dt_StationManger != null)
                {
                    DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == dt_StationManger.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    List<Dt_StationManger> ProductBackStations = stationMangers.Where(x => x.StationType == StationTypeEnum.StationType_ProductBack.ObjToInt()).ToList();
                    for (int i = 0; i < ProductBackStations.Count(); i++)
                    {
                        short isCanTake = device.GetValue<GroundStationDBName, short>(GroundStationDBName.R_IsCanTake, dt_StationManger.StationCode);
                        Dt_StationManger stationManger = ProductBackStations[i];
                        string startDb = "DB29.";
                        short stationCurrentStatus = device.Communicator.Read<short>(startDb + stationManger.Remark.ToString());
                        short stationEndStatus = device.Communicator.Read<short>(startDb + (stationManger.Remark.ObjToInt() + 2).ToString());
                        bool endStatus = true;
                        if ((i != 2 && i != 5 && i != 8))
                        {
                            endStatus = (stationEndStatus == 1);
                        }
                        //读取线体段状态
                        if (isCanTake == 1 && stationCurrentStatus == 1 && stationManger.IsOccupied==0 && endStatus)
                        {
                            device.SetValue(W_ConveyorLineCPDB.StartPos, dt_StationManger.StationCode, dt_StationManger.StationCode);
                            device.SetValue(W_ConveyorLineCPDB.EndPos, stationManger.AGVStationCode, dt_StationManger.StationCode);
                            device.SetValue(W_ConveyorLineCPDB.Barcode, "C00001", dt_StationManger.StationCode);
                            device.SetValue(W_ConveyorLineCPDB.TaskNum, DateTime.Now.ToString("yyMMddHHmmss"), dt_StationManger.StationCode);
                            device.SetValue(W_ConveyorLineCPDB.WorkType, 1, dt_StationManger.StationCode);
                            device.SetValue(W_ConveyorLineCPDB.WorkMode, 1, dt_StationManger.StationCode);
                            device.SetValue(W_ConveyorLineCPDB.CheckPos, 1, dt_StationManger.StationCode);
                            //启动指令
                            device.SetValue(W_ConveyorLineCPDB.ConveyArrival, 1, dt_StationManger.StationCode);
                            stationManger.IsOccupied = 1;
                            _stationMangerRepository.UpdateData(stationManger);
                            Thread.Sleep(2000);
                            return Task.CompletedTask;
                        }
                        else if(stationManger.IsOccupied == 1 && (stationCurrentStatus == 3))
                        {
                            stationManger.IsOccupied = 0;
                            _stationMangerRepository.UpdateData(stationManger);
                        }
                    }
                }
            }
            return Task.CompletedTask;
        }