1
huangxiaoqiang
2025-05-21 6c8b4c256053c61e848c3f9dd494feebf6ef0cea
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs
@@ -27,11 +27,11 @@
        private readonly ISys_ConfigService _configService;
        private readonly IDt_StationManagerRepository _stationManagerRepository;
        private readonly LogFactory LogFactory = new LogFactory();
        private readonly ISocketClientServices _Socket;
        public SocketClientService _Socket { get; set; }
        private readonly IMapper _mapper;
        private readonly IDt_DeviceInfoRepository _deviceInfoRepository;
        public AGVService(ILocationInfoRepository locationRepository,IDt_TaskRepository taskRepository,IStockInfoRepository stockInfoRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository,IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, ISocketClientServices socketClientServices)
        public AGVService(ILocationInfoRepository locationRepository, IDt_TaskRepository taskRepository, IStockInfoRepository stockInfoRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository, IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, SocketClientService socketClientService)
        {
            _locationRepository = locationRepository;
            BaseDal = taskRepository;
@@ -40,7 +40,7 @@
            _stationManagerRepository = stationManagerRepository;
            _deviceInfoRepository = deviceInfoRepository;
            _mapper = mapper;
            _Socket= socketClientServices;
            _Socket = socketClientService;
        }
        #region å¤–部接口方法
@@ -67,38 +67,39 @@
                    return content.Error("该托盘已存在任务");
                }
                List<OutStationStatus> outStationStatus = new List<OutStationStatus>();
                foreach (var item in Outstation)
                StationStatus stationOut = _Socket.GetStationStatus("B001");
                var taskOutStationO = BaseDal.QueryFirst(x => x.SourceAddress == "B001::1" || x.TargetAddress == "B001::1");
                var taskOutStationT = BaseDal.QueryFirst(x => x.SourceAddress == "B001::2" || x.TargetAddress == "B001::2");
                outStationStatus.Add(new OutStationStatus()
                {
                    StationStatus station = _Socket.GetStationStatus(item.stationName);
                    var taskStation = BaseDal.QueryFirst(x => x.SourceAddress == item.stationName || x.TargetAddress == item.stationName);
                    outStationStatus.Add(new OutStationStatus()
                    {
                        StationName = item.HostName,
                        StationEnable = station.StationEnable == "1" ? "0" : "1",
                        IsDistributionTask = taskStation == null ? "0" : "1",
                        Spare1 = "00"
                    });
                }
                    StationName = "04",
                    StationEnable = stationOut.WorkstationO == "1" ? "0" : "1",
                    IsDistributionTask = taskOutStationO == null ? "0" : "1",
                    Spare1 = "00"
                });
                outStationStatus.Add(new OutStationStatus()
                {
                    StationName = "03",
                    StationEnable = stationOut.WorkstationT == "1" ? "0" : "1",
                    IsDistributionTask = taskOutStationT == null ? "0" : "1",
                    Spare1 = "00"
                });
                AGVStatusRespone status = _Socket.GetAGVStatus();
                HOSTAGVStatus AgvStatus = new HOSTAGVStatus()
                {
                    RuntimeStatus = _Socket.CapitalizeFirstLetter(status.RuntimeStatus),
                    AutoStatus = status.AutoStatus== "MaintenanceMode"?"1":"0",
                    AutoStatus = status.AutoStatus == "MaintenanceMode" ? "1" : "0",
                    Ready = status.AutoStatus == "MaintenanceMode" ? "0" : "1",
                };
                InStationStatus inStationStatus = new InStationStatus()
                {
                    StationName = Instation.stationName,
                    StationName = Instation.HostName,
                    StationEnable = "0",
                    IsDistributionTask = "0",
                    PallteCode = task.PalletCode,
                    PallteCode = PalletCode,
                };
                _Socket.DeviceRequestInbound(AgvStatus, outStationStatus, inStationStatus);
                return content.OK("已下发入库任务");
            }
            catch (Autofac.Core.DependencyResolutionException ex)
            {
                return content.Error(ex.Message);
            }
            catch (Exception ex)
            {
@@ -161,12 +162,12 @@
                    switch (Status.AutoStatus)
                    {
                        case "MaintenanceMode":
                            //手动
                            //运行
                            _Socket.DeviceAutoStatusReport("1");
                            Thread.Sleep(500);
                            break;
                        case "ControlMode":
                            //自动
                            //关机
                            _Socket.DeviceAutoStatusReport("0");
                            Thread.Sleep(500);
                            break;
@@ -191,7 +192,7 @@
            }
        }
        public WebResponseContent AGVStartOrEndJob(string Status, int TaskNum)
        {
            WebResponseContent content = new WebResponseContent();
@@ -293,7 +294,7 @@
        }
        public WebResponseContent DeviceErrorResponse(string Message,int TaskNum)
        public WebResponseContent DeviceErrorResponse(string Message, int TaskNum)
        {
            WebResponseContent content = new WebResponseContent();
            try
@@ -301,7 +302,7 @@
                var task = BaseDal.QueryFirst(x => x.TaskNum == TaskNum);
                if (task != null)
                {
                    switch(Message)
                    switch (Message)
                    {
                        case "RepeatInbound":
@@ -309,7 +310,7 @@
                        case "EmptyOutbound":
                            break;
                        default:break;
                        default: break;
                    }
                }
                return content.OK();
@@ -319,6 +320,30 @@
                return content.Error(ex.Message);
            }
        }
        public WebResponseContent add()
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                task_call task_Call = new task_call()
                {
                    d_task_type = 2,
                    d_floor = 1,
                    d_involed1 = "000004",
                    d_involed2 = "450101",
                    d_involed5 = 11,
                };
                var x = SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand();
                return content.OK(data: x);
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
        public WebResponseContent RequestOutTask(string PalletCode, string SourceAddress, string TargetAddress)
        {
            WebResponseContent content = new WebResponseContent();
@@ -395,6 +420,7 @@
                return content.Error(ex.Message);
            }
        }
        public WebResponseContent GetAGVStatus()
        {
            try