1
HuBingJie
8 天以前 5da3a276b7847187a7c155ee069d3cd4c9e58074
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/SpeStackerCraneJob/SpeStackerCraneJob.cs
@@ -20,6 +20,7 @@
using WIDESEA_Common.Log;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_DTO.Enum;
using WIDESEAWCS_ISystemServices;
@@ -48,15 +49,19 @@
        private readonly ITaskRepository _taskRepository;
        private readonly IRouterService _routerService;
        private readonly IAgvStationService _agvStationService;
        IRepository<AbnormalTask> _abnormalTask;
        IRgvoperainformService _rgvoperainformService;
        public SpeStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IAgvStationService agvStationService)
        public SpeStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IAgvStationService agvStationService, IRepository<AbnormalTask> abnormalTask, IRgvoperainformService rgvoperainformService)
        {
            _taskService = taskService;
            _taskExecuteDetailService = taskExecuteDetailService;
            _taskRepository = taskRepository;
            _routerService = routerService;
            _agvStationService = agvStationService;
            _abnormalTask = abnormalTask;
            _rgvoperainformService = rgvoperainformService;
        }
@@ -64,10 +69,15 @@
        {
            try
            {
                //WriteLog.Write_Log("23");
                SpeStackerCrane speStackerCrane = (SpeStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
                if (speStackerCrane != null)
                {
                    GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
                    _rgvoperainformService.LogAlarmToDatabase(speStackerCrane.DeviceCode);
                    if (getStackerObject.RGVInitializationValue == RGVInitialize.Initialized)
                    {
@@ -76,6 +86,25 @@
                        {
                            CommonStackerCrane_AGVTaskCompletedEventHandler(getStackerObject, speStackerCrane);
                        }
                        //判断当前设备是入库还是出库
                        if (GetDeviceAddress.OutbounMotherChildCartbool(speStackerCrane.DeviceCode))
                        {
                            //判断当前安全门是否为绿色灯
                            if (GetDeviceAddress.ReadAqmDecicStice(1))
                            {
                                return null;
                            }
                        }
                        else
                        {
                            //判断入库端安全门是否正常
                            if (GetDeviceAddress.ReadAqmDecicStice(2))
                            {
                                return null;
                           }
                        }
                        if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
                        getStackerObject.StaclerkJobJobStatusValue == RGV_Rgvtaskstutas.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
@@ -139,8 +168,25 @@
            }
            else if (getStackerObject.StaclerkJobJobStatusValue == RGV_Rgvtaskstutas.AbnormalCompletion && getStackerObject.CurrentRgvtaskid != 0 && getStackerObject.CurrentRgvtaskid != 30001)
            {
                string ErrorContent = RgvOperationService.AQMReadAlarminform();
                if (ErrorContent != null && ErrorContent != "")
                {
                    _abnormalTask.AddData(new AbnormalTask
                    {
                        TaskNum = getStackerObject.CurrentRgvtaskid,
                        ErrorContent = ErrorContent,
                        CreateDate = DateTime.Now,
                        Creater = "system",
                    });
                }
                //修改任务状态为异常完成
                _taskService.HandleInAbnormal(getStackerObject.CurrentRgvtaskid);
                //写入异常完成报警信息
                speStackerCrane.Communicator.Write<short>("DB101.36", 1);
                //speStackerCrane.Communicator.Write<short>("DB101.36", 1);   //写入报警
                speStackerCrane.SetValue(RGV_taskcoDBName.RGV_taskcomplete, 1);
                speStackerCrane.SetValue(RGV_taskcoDBName.RGV_taskcomplete, 0);
            }
        }
        #endregion
@@ -179,7 +225,7 @@
                    => GoodsPlacedCorridor(RGVTaskdevice),    //子车放货任务(已完成)
                ((int)RGVEquipment.Mothertrailer, RgvEquipmentStatus.HasCargo)
                    => MotherVehicleMovement(RGVTaskdevice),        //(已完成)
                    => MotherVehicleMovement(RGVTaskdevice),        //母车移动(已完成)
                _ => null
            };
@@ -190,23 +236,32 @@
        public Dt_Task? ForkliftUnloading(AGVStation RGVTaskdevice)
        {
            Dt_Task dt_Task = _taskService.GetInkouFinhuoTask(RGVTaskdevice.ChildPosiDeviceCode);
            if (dt_Task == null) return null;
            //判断HCJ是否有货
            if (GetDeviceAddress.HCJIsstock(dt_Task.NextAddress))
            {
                //判断子车是否在接驳台下
                var zichestation = _agvStationService.OutGetZicheDeepHCJ(1061);
                int ziche = GetDeviceAddress.GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
                if ((ziche == zichestation.WaitmomentOne || ziche == zichestation.WaitmomentTwo || ziche == zichestation.MotherCarDeviceCode || ziche == zichestation.MotherCardeputy || ziche == zichestation.HCJStorageaddress) && ziche != 1021)
                if ((ziche == zichestation.WaitmomentOne || ziche == zichestation.WaitmomentTwo || ziche == zichestation.MotherCarDeviceCode || ziche == zichestation.MotherCardeputy || ziche == zichestation.HCJStorageaddress) && ziche != 1021 && ziche !=0)
                {
                    //获取这个接驳台是否有取货任务
                    Dt_Task zitask = _taskService.ViceChariotPickupTask2(RGVTaskdevice.ChildPosiDeviceCode);
                    if (zitask == null)
                    {
                        return dt_Task;
                    }
                }
                else
                {
                    //如果没货,则下发移动任务
                    RGVMovetask(RGVTaskdevice.HCJStorageaddress, RGVTaskdevice.ChildPosiDeviceCode);
                }
            }
            else
            {
                //如果没货,则下发移动任务
                RGVMovetask(RGVTaskdevice.HCJStorageaddress, RGVTaskdevice.ChildPosiDeviceCode);
            }
            return null;
        }
@@ -218,6 +273,10 @@
            //获取子车取货任务
            Dt_Task dt_Task = _taskService.ViceChariotPickupTask(RGVTaskdevice.ChildPosiDeviceCode);
            if (dt_Task == null) return null;
            //判断HCJ站台是否有货
            if (GetDeviceAddress.HCJIsstock(dt_Task.CurrentAddress)) return null;
            if (RGVTaskdevice.Station_Area == 6)    //外侧进取货,则需要判断子车当前位置
            {
                if (getStackerObject.RGVCurrentlocation == RGVTaskdevice.WaitmomentOne)
@@ -244,27 +303,24 @@
                                }
                                else if (mu2 == InMotherVehicle.Motherinlaw)
                                {
                                    RGVMovetask(InMotherVehicle.ZicheMotherinlaw, InMotherVehicle.ChildPosiDeviceCode);
                                    //判断母车是否有任务
                                    Dt_Task muche1task = _taskService.MothermachinemovementTask2(InMotherVehicle.ChildPosiDeviceCode);
                                    if (muche1task == null)
                                    {
                                        RGVMovetask(InMotherVehicle.ZicheMotherinlaw, InMotherVehicle.ChildPosiDeviceCode);
                                    }
                                }
                            }
                        }
                        //=============================新增当去取货时进行判断巷道,看能不能提前拉出母车
                        return dt_Task;
                    }
                    //去掉原因:在该出子车去取货,可直接穿过无货母车,拖车
                    /*else
                    {
                        Dt_Task task = _taskService.MothermachinemovementTask2(RGVTaskdevice.ChildPosiDeviceCode);
                        if (task == null)
                        {
                            RGVMovetask(mu1rgv.Motherinlaw, mu1rgv.ChildPosiDeviceCode);
                        }
                    }*/
                }
                else if (getStackerObject.RGVCurrentlocation == RGVTaskdevice.WaitmomentTwo)    //则需要判断两个母车的位子
                {
                    //判断两个子车是否在堆垛机取货口
                    //判断两个母车是否在堆垛机取货口
                    //母车1
                    var mu1rgv = _agvStationService.GetMothervehicle(RGVTaskdevice.MotherCarDeviceCode);
@@ -324,6 +380,29 @@
                    {
                        return dt_Task;
                    }
                    //判断内侧是否有货,是否有任务
                    if (int.Parse(dt_Task.TargetAddress) == (int)StorageAisleEnum.LaneThree || int.Parse(dt_Task.TargetAddress) == (int)StorageAisleEnum.LaneFour)
                    {
                        int taraddress = int.Parse(dt_Task.TargetAddress);
                        var InMotherVehicle = _agvStationService.ObtainCcordingTunnel(taraddress);    //获取到需要入库的母车(2巷道)
                        int mu2 = GetDeviceAddress.GetEquipmentlocation(InMotherVehicle.ChildPosiDeviceCode); //此时的RGV应该无货
                        if (GetDeviceAddress.Mucheywhaddres(InMotherVehicle.ChildPosiDeviceCode))   //判断无货
                        {
                            if (mu2 == InMotherVehicle.Motherinlaw)
                            {
                                //判断母车是否有任务
                                Dt_Task muche1task = _taskService.MothermachinemovementTask2(InMotherVehicle.ChildPosiDeviceCode);
                                if (muche1task == null)
                                {
                                    RGVMovetask(InMotherVehicle.ZicheMotherinlaw, InMotherVehicle.ChildPosiDeviceCode);
                                }
                            }
                        }
                    }
                }
                else if (getStackerObject.RGVCurrentlocation == RGVTaskdevice.WaitmomentTwo)    //需要判断3巷道母车是否在取货站台
@@ -434,7 +513,13 @@
                    }
                    else
                    {
                        RGVMovetask(Muche.ZicheMotherinlaw, Muche.ChildPosiDeviceCode);  //如果没有任务,则可以进行移动出来
                        //判断母车是否有任务
                        Dt_Task _Task1 = _taskService.MothermacTask(Muche.ChildPosiDeviceCode);
                        if (_Task1 == null)
                        {
                            RGVMovetask(Muche.ZicheMotherinlaw, Muche.ChildPosiDeviceCode);  //如果没有任务,则可以进行移动出来
                        }
                    }
                }
            }
@@ -480,7 +565,12 @@
                Dt_Task task = _taskService.MothermachinemovementTask2(Muche2.ChildPosiDeviceCode);   //获取到母车移动任务
                if (task == null)
                {
                    RGVMovetask(Muche2.ZicheMotherinlaw, Muche2.ChildPosiDeviceCode);  //如果没有任务,则可以进行移动出来
                    Dt_Task _Task1 = _taskService.MothermacTask(Muche2.ChildPosiDeviceCode);
                    if (_Task1 == null)
                    {
                        RGVMovetask(Muche2.ZicheMotherinlaw, Muche2.ChildPosiDeviceCode);  //如果没有任务,则可以进行移动出来
                    }
                }
            }
            return null;
@@ -511,7 +601,7 @@
                AGVStation Muche2 = _agvStationService.GetMothervehicle(aGVStation.MotherCardeputy);    //内侧母车
                int mucheaddre2 = GetDeviceAddress.GetEquipmentlocation(Muche2.ChildPosiDeviceCode);
                if ((neizichecurraddres == neiziche.WaitmomentOne || neizichecurraddres == neiziche.WaitmomentTwo) && task == null && mucheaddre1 == Muche.Motherinlaw && mucheaddre2 == Muche2.Motherinlaw)
                if ((neizichecurraddres == neiziche.WaitmomentOne || neizichecurraddres == neiziche.WaitmomentTwo) && task == null && neizichecurraddres != neiziche.HCJStorageaddress && mucheaddre1 == Muche.Motherinlaw && mucheaddre2 == Muche2.Motherinlaw)
                {
                    return _Task;
                }
@@ -570,7 +660,7 @@
                    => Findshippingtask(RGVTaskdevice, getStackerObject.RGVCurrentlocation),    //子车取货后,进行放货(已完成)
                ((int)RGVEquipment.OutRGVForklift, RgvEquipmentStatus.NoCargo)
                    => OutboundGateVehicle(RGVTaskdevice),              //出库口RGV取货(已完成)
                    => OutboundGateVehicle(RGVTaskdevice),          //出库口RGV取货(已完成)
                ((int)RGVEquipment.OutRGVForklift, RgvEquipmentStatus.HasCargo)
                    => _taskService.GetOutkouFinhuoTask(RGVTaskdevice.ChildPosiDeviceCode,
@@ -624,8 +714,14 @@
            Dt_Task Muche2Task = _taskService.ObtainMuChetask(ZicheinnerSide.MotherCardeputy.ToString());
            if (Muche2Task == null) return null;
            //获取子车是否有任务
            Dt_Task zicheTASK = _taskService.GetChariotTaskBool(ZicheinnerSide.ChildPosiDeviceCode);
            if (zicheTASK != null) return null;
            //获取2巷道子车是否有任务
            var muche1 = _agvStationService.GetMothervehicle(ZicheinnerSide.MotherCarDeviceCode);
            Dt_Task Muche1 = _taskService.GetChariotTaskBool(muche1.ChildPosiDeviceCode.ToString());
            if(Muche1!=null) return null;
            return Muche2Task;
        }
@@ -635,15 +731,11 @@
            Dt_Task Muche3Task = _taskService.ObtainMuChetask(ZicheinnerSide.MotherCarDeviceCode.ToString());
            if (Muche3Task == null) return null;
            //判断子车是否有有需要取货的任务
            Dt_Task zicheTASK = _taskService.GetChariotTaskBool(ZicheinnerSide.ChildPosiDeviceCode);
            //判断子车是否有要取HCJ任务
            Dt_Task zicheTASK = _taskService.GetHCJTaskBool(ZicheinnerSide.ChildPosiDeviceCode, ZicheinnerSide.HCJStorageaddress);
            if (zicheTASK != null) return null;
            if (curraddZiChe == ZicheinnerSide.WaitmomentTwo || curraddZiChe == ZicheinnerSide.WaitmomentOne)
            {
                return Muche3Task;
            }
            return null;
            return Muche3Task;
        }
        public Dt_Task? OutboundSideAisle4(int curraddZiChe, AGVStation ZicheinnerSide)
        {
@@ -651,25 +743,16 @@
            Dt_Task Muche4Task = _taskService.ObtainMuChetask(ZicheinnerSide.MotherCardeputy.ToString());
            if (Muche4Task == null) return null;
            //判断是否有需要取HCJ的任务
            Dt_Task zicheTASK = _taskService.GetChariotTaskBool(ZicheinnerSide.ChildPosiDeviceCode);
            if (zicheTASK != null) return null;
            if (curraddZiChe == ZicheinnerSide.WaitmomentOne)
            {
            //判断3巷道是否有出库的任务
            var muche3 = _agvStationService.GetMothervehicle(ZicheinnerSide.MotherCarDeviceCode);
            Dt_Task muchetask = _taskService.OutMothermaTask(muche3.ChildPosiDeviceCode);
            if (muchetask != null) return null;
            }
            if ( || curraddZiChe == ZicheinnerSide.WaitmomentTwo)
            {
                return Muche4Task;
            }
            return null;
            return Muche4Task;
        }
        #endregion
@@ -700,6 +783,16 @@
                            if (muche2addres == muchestation.Motherinlaw)
                            {
                                return dtTasks;
                            }
                            else
                            {
                                //如果母车无货,则下到里面去
                                bool NoCargobool = GetDeviceAddress.Mucheywhaddres(muchestation.ChildPosiDeviceCode);
                                if (NoCargobool)
                                {
                                    //下发母车移动任务
                                    RGVMovetask(muchestation.Motherinlaw, muchestation.ChildPosiDeviceCode);
                                }
                            }
                        }
                    }
@@ -737,6 +830,16 @@
                            {
                                return dtTasks;
                            }
                            else
                            {
                                //如果母车无货,则下到里面去
                                bool NoCargobool = GetDeviceAddress.Mucheywhaddres(muchestation.ChildPosiDeviceCode);
                                if (NoCargobool)
                                {
                                    //下发母车移动任务
                                    RGVMovetask(muchestation.Motherinlaw, muchestation.ChildPosiDeviceCode);
                                }
                            }
                        }
                    }
@@ -754,6 +857,25 @@
                                var mu2rgv = _agvStationService.GetMothervehicle(GdZiche.MotherCardeputy);
                                int mu2 = GetDeviceAddress.GetEquipmentlocation(mu2rgv.ChildPosiDeviceCode);
                                //需要判断母车是否有货,无货则下方至移动任务
                                bool NoCargobool = GetDeviceAddress.Mucheywhaddres(mu1rgv.ChildPosiDeviceCode);
                                if (NoCargobool)
                                {
                                    //下发母车移动任务
                                    RGVMovetask(mu1rgv.Motherinlaw, mu1rgv.ChildPosiDeviceCode);
                                }
                                bool NoCargobool2 = GetDeviceAddress.Mucheywhaddres(mu2rgv.ChildPosiDeviceCode);
                                if (NoCargobool2)
                                {
                                    //下发母车移动任务
                                    RGVMovetask(mu2rgv.Motherinlaw, mu2rgv.ChildPosiDeviceCode);
                                }
                                if (mu1 == mu1rgv.Motherinlaw && mu2 == mu2rgv.Motherinlaw)
                                {
@@ -819,7 +941,12 @@
                            int mucboject4 = GetDeviceAddress.GetEquipmentlocation(muchestation2.ChildPosiDeviceCode);
                            if (mucboject4 == muchestation2.Motherinlaw)
                            {
                                return task;
                                //判断叉车是否有取货任务
                                Dt_Task chachetask = _taskService.ChacheGetFinhuoTask("RGV118");
                                if(chachetask == null)
                                {
                                    return task;
                                }
                            }
                        }
@@ -876,7 +1003,7 @@
                GetStackerObject getStackerObject = GetDeviceAddress.GetChildDeviceCode(zichestation.ChildPosiDeviceCode);
                if (getStackerObject.StaclerkJobJobStatusValue != RGV_Rgvtaskstutas.Executing && getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic
                     && (getStackerObject.RGVCurrentlocation == zichestation.WaitmomentOne || getStackerObject.RGVCurrentlocation == zichestation.WaitmomentTwo) && getStackerObject.RGVCurrentlocation != zichestation.ZicheMotherinlaw)
                     && (getStackerObject.RGVCurrentlocation == zichestation.WaitmomentOne || getStackerObject.RGVCurrentlocation == zichestation.WaitmomentTwo || getStackerObject.RGVCurrentlocation==1171) && getStackerObject.RGVCurrentlocation != zichestation.ZicheMotherinlaw)
                {
                    RGVMovetask(GdZiche.Motherinlaw, GdZiche.ChildPosiDeviceCode);
                }
@@ -901,7 +1028,7 @@
                    {
                        RGVMovetask(GdZiche.WaitmomentOne, GdZiche.ChildPosiDeviceCode);
                    }
                    else if (GdZiche.MotherCardeputy == RGVCurrentlocation && RGVCurrentlocation == 1171)
                    else if (GdZiche.MotherCardeputy == RGVCurrentlocation || RGVCurrentlocation == 1171)
                    {
                        RGVMovetask(GdZiche.WaitmomentTwo, GdZiche.ChildPosiDeviceCode);
                    }
@@ -918,14 +1045,19 @@
            {
                if (GdZiche.Station_Area == 5)
                {
                    if (GdZiche.MotherCarDeviceCode == RGVCurrentlocation || GdZiche.HCJStorageaddress == RGVCurrentlocation)
                    Dt_Task task = _taskService.GetChariotTaskBool(GdZiche.ChildPosiDeviceCode);
                    if (task == null && RgvCraneStatusValue == (int)RgvEquipmentStatus.NoCargo)
                    {
                        RGVMovetask(GdZiche.WaitmomentOne, GdZiche.ChildPosiDeviceCode);
                        if (GdZiche.MotherCarDeviceCode == RGVCurrentlocation || GdZiche.HCJStorageaddress == RGVCurrentlocation)
                        {
                            RGVMovetask(GdZiche.WaitmomentOne, GdZiche.ChildPosiDeviceCode);
                        }
                        else if (GdZiche.MotherCardeputy == RGVCurrentlocation)
                        {
                            RGVMovetask(GdZiche.WaitmomentTwo, GdZiche.ChildPosiDeviceCode);
                        }
                    }
                    else if (GdZiche.MotherCardeputy == RGVCurrentlocation)
                    {
                        RGVMovetask(GdZiche.WaitmomentTwo, GdZiche.ChildPosiDeviceCode);
                    }
                }
                else
                {
@@ -952,6 +1084,13 @@
                            }
                        }
                    }else if(task != null && RgvCraneStatusValue == (int)RgvEquipmentStatus.NoCargo)
                    {
                        if (GdZiche.HCJStorageaddress == RGVCurrentlocation)
                        {
                            //如果在2巷道的母车,则可以放子车来1号等待点,如果在HCJ则可以让子车去2号
                            RGVMovetask(GdZiche.WaitmomentTwo, GdZiche.ChildPosiDeviceCode);
                        }
                    }
                }
            }