huanghongfeng
2025-09-26 83f3c63f1cae6224320a8d19251e3bc0404da096
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -17,6 +17,7 @@
using Autofac.Core;
using AutoMapper;
using HslCommunication;
using Magicodes.ExporterAndImporter.Core;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
@@ -73,6 +74,7 @@
        private readonly ITask_HtyService _task_HtyService;
        private readonly IMapper _mapper;
        private readonly IEquipmentStatusService _equipmentStatus;
        private readonly IAgvStationService _gvStationService;
        private Dictionary<string, OrderByType> _taskOrderBy = new()
@@ -87,7 +89,7 @@
        public List<int> TaskOutboundTypes => typeof(TaskOutboundTypeEnum).GetEnumIndexList();
        public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService task_HtyService, IRouterRepository routerRepository, IEquipmentStatusService equipmentStatus) : base(BaseDal)
        public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService task_HtyService, IRouterRepository routerRepository, IEquipmentStatusService equipmentStatus, IAgvStationService agvStationService) : base(BaseDal)
        {
            _routerService = routerService;
            _taskExecuteDetailService = taskExecuteDetailService;
@@ -96,6 +98,7 @@
            _mapper = mapper;
            _routerRepository = routerRepository;
            _equipmentStatus = equipmentStatus;
            _gvStationService = agvStationService;
        }
        /// <summary>
@@ -162,26 +165,23 @@
                    else if (item.type == 2)    //出库
                    {
                        string roadway = "";
                        string CurrentAddress = "";
                        switch (item.startAddress)
                        {
                            case "1":
                                roadway = "RGV110";
                                CurrentAddress = "1101";
                                break;
                            case "2":
                                roadway = "RGV112";
                                CurrentAddress = "1121";
                                break;
                            case "3":
                                roadway = "RGV114";
                                CurrentAddress = "1141";
                                break;
                            case "4":
                                roadway = "RGV115";
                                CurrentAddress = "1151";
                                break;
                        }
                        AGVStation gVStation = _gvStationService.Corridorequipment(roadway);
                        Dt_Task dt_Task = new Dt_Task();
                        dt_Task.TaskNum = item.taskNo;
@@ -192,9 +192,9 @@
                        dt_Task.RGVCurrentexecution = "0";      //目前暂无
                        dt_Task.TaskState = (int)TaskOutStatusEnum.OutNew;      //目前暂无
                        dt_Task.SourceAddress = item.startAddress;
                        dt_Task.TargetAddress = "";
                        dt_Task.CurrentAddress = CurrentAddress;
                        dt_Task.NextAddress = "0";   //目前暂无
                        dt_Task.TargetAddress ="0";
                        dt_Task.CurrentAddress = gVStation.Motherinlaw.ToString();
                        dt_Task.NextAddress = gVStation.ZicheMotherinlaw.ToString();   //目前暂无
                        dt_Task.Grade = item.priority;
                        dt_Task.WMSId = 0;   //目前暂无
                        BaseDal.AddData(dt_Task);
@@ -230,6 +230,68 @@
            return BaseDal.QueryFirst(x => x.Roadway == DeviceCode, TaskOrderBy);
        }
        public Dt_Task ChildVehicleMission(AGVStation aGVStation)
        {
            Dt_Task dt_Tasks =BaseDal.QueryFirst(x => x.Roadway == aGVStation.ChildPosiDeviceCode && x.CurrentAddress== aGVStation.MotherCarDeviceCode.ToString() && x.RGVTaskType== (int)RGVTaskTypeEnum.PickingUp, TaskOrderBy);
            if(dt_Tasks !=null) return dt_Tasks;
            Dt_Task dt_Tasks2 = BaseDal.QueryFirst(x => x.Roadway == aGVStation.ChildPosiDeviceCode && x.CurrentAddress == aGVStation.MotherCardeputy.ToString() && x.RGVTaskType == (int)RGVTaskTypeEnum.PickingUp, TaskOrderBy);
            if (dt_Tasks2 != null) return dt_Tasks2;
            Dt_Task dt_Tasks3 = BaseDal.QueryFirst(x => x.Roadway == aGVStation.ChildPosiDeviceCode && x.CurrentAddress == aGVStation.HCJStorageaddress.ToString() && x.RGVTaskType == (int)RGVTaskTypeEnum.PickingUp, TaskOrderBy);
            if (dt_Tasks3 != null) return dt_Tasks3;
            return null;
        }
        public Dt_Task GetFinhuoTask(string DeviceCode)
        {
            return BaseDal.QueryFirst(x => x.Roadway == DeviceCode && x.TaskState == (int)TaskOutStatusEnum.RGV_OutZicheFinish && x.RGVTaskType == (int)RGVTaskTypeEnum.Placing, TaskOrderBy);
        }
        public Dt_Task GetOutkouFinhuoTask(string DeviceCode,string curraderr,int type)
        {
            if (type == 1)
            {
                return BaseDal.QueryFirst(x => x.Roadway == DeviceCode && x.TaskState == (int)TaskOutStatusEnum.RGV_OutZicheReleaseFinish && x.RGVTaskType == (int)RGVTaskTypeEnum.PickingUp && x.CurrentAddress == curraderr, TaskOrderBy);
            }
            else
            {
                return BaseDal.QueryFirst(x => x.Roadway == DeviceCode && x.TaskState == (int)TaskOutStatusEnum.RGV_OutPickupFinish && x.RGVTaskType == (int)RGVTaskTypeEnum.Placing && x.NextAddress !="", TaskOrderBy);
            }
        }
        public Dt_Task GetInkouFinhuoTask(string DeviceCode,int type)
        {
            if (type == 1)
            {
                return BaseDal.QueryFirst(x => x.Roadway == DeviceCode && x.TaskState == (int)TaskInStatusEnum.RGV_InNew && x.RGVTaskType == (int)RGVTaskTypeEnum.PickingUp, TaskOrderBy);
            }
            else
            {
                return BaseDal.QueryFirst(x => x.Roadway == DeviceCode && x.TaskState == (int)TaskInStatusEnum.RGV_InPickupFinish && x.RGVTaskType == (int)RGVTaskTypeEnum.Placing, TaskOrderBy);
            }
        }
        public Dt_Task GetInzicheTask(string DeviceCode, int type)
        {
            if (type == 1)
            {
                return BaseDal.QueryFirst(x => x.Roadway == DeviceCode && x.TaskState == (int)TaskInStatusEnum.RGV_InReleaseFinish && x.RGVTaskType == (int)RGVTaskTypeEnum.PickingUp, TaskOrderBy);
            }
            else
            {
                return BaseDal.QueryFirst(x => x.Roadway == DeviceCode && x.TaskState == (int)TaskInStatusEnum.RGV_InZicheFinish && x.RGVTaskType == (int)RGVTaskTypeEnum.Placing, TaskOrderBy);
            }
        }
        public Dt_Task GetInzicheTaskMobile(string DeviceCode, int type)
        {
            if (type == 1)  //1为子车移动任务    2为母车移动任务
            {
                return BaseDal.QueryFirst(x => x.Roadway == DeviceCode && x.TaskState == (int)TaskInStatusEnum.RGV_InZicheReleaseFinish && x.RGVTaskType == (int)RGVTaskTypeEnum.TravelingOnly, TaskOrderBy);
            }
            else
            {
                return BaseDal.QueryFirst(x => x.Roadway == DeviceCode && x.TaskState == (int)TaskInStatusEnum.RGV_InZichemoveFinish && x.RGVTaskType == (int)RGVTaskTypeEnum.TravelingOnly, TaskOrderBy);
            }
        }
        public WebResponseContent UpdateRGVTasktype(int taskNum, int RGVTasktype)
        {
            WebResponseContent content = new WebResponseContent();