1
huangxiaoqiang
2025-05-21 07b2fc307e6d7f8ddb4f652198f3d4856f884141
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs
@@ -73,7 +73,7 @@
                    var taskStation = BaseDal.QueryFirst(x => x.SourceAddress == item.stationName || x.TargetAddress == item.stationName);
                    outStationStatus.Add(new OutStationStatus()
                    {
                        StationName = item.stationName,
                        StationName = item.HostName,
                        StationEnable = station.StationEnable == "1" ? "0" : "1",
                        IsDistributionTask = taskStation == null ? "0" : "1",
                        Spare1 = "00"
@@ -161,12 +161,12 @@
                    switch (Status.AutoStatus)
                    {
                        case "MaintenanceMode":
                            //杩愯
                            //鎵嬪姩
                            _Socket.DeviceAutoStatusReport("1");
                            Thread.Sleep(500);
                            break;
                        case "ControlMode":
                            //鍏虫満
                            //鑷姩
                            _Socket.DeviceAutoStatusReport("0");
                            Thread.Sleep(500);
                            break;
@@ -319,8 +319,108 @@
                return content.Error(ex.Message);
            }
        }
        public WebResponseContent RequestOutTask(string PalletCode, string SourceAddress, string TargetAddress)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                //var tasks = BaseDal.QueryFirst(x => x.PalletCode == PalletCode);
                //if (tasks != null)
                //{
                //    return content.Error("璇ユ墭鐩樺凡瀛樺湪浠诲姟");
                //}
                Dt_Task newTask = new Dt_Task()
                {
                    TaskNum = BaseDal.GetTaskNo().Result,
                    SourceAddress = SourceAddress,
                    CurrentAddress = SourceAddress,
                    TargetAddress = TargetAddress,
                    NextAddress = TargetAddress,
                    Grade = 1,
                    PalletCode = PalletCode,
                    TaskType = (int)TaskOutboundTypeEnum.Outbound,
                    TaskState = (int)TaskOutStatusEnum.OutNew,
                    Dispatchertime = DateTime.Now,
                    SeqNo = Convert.ToInt32(1),
                    CommandID = Convert.ToInt32(101)
                };
                task_call task_Call = new task_call()
                {
                    d_task_type = newTask.TaskType == (int)TaskTypeEnum.Inbound ? 1 : 2,
                    d_floor = 1,
                    d_involed1 = newTask.SourceAddress,
                    d_involed2 = newTask.TargetAddress,
                    d_involed5 = newTask.TaskNum,
                };
                SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand();
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
        public WebResponseContent InTask(string PalletCode, string SourceAddress, string TargetAddress)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Task newTask = new Dt_Task()
                {
                    TaskNum = BaseDal.GetTaskNo().Result,
                    SourceAddress = SourceAddress,
                    TargetAddress = TargetAddress,
                    PalletCode = PalletCode,
                    TaskType = (int)TaskInboundTypeEnum.Inbound,
                    TaskState = (int)TaskInStatusEnum.InNew,
                    Dispatchertime = DateTime.Now,
                    SeqNo = Convert.ToInt32(1),
                    CommandID = Convert.ToInt32(101)
                };
                task_call task_Call = new task_call()
                {
                    d_task_type = newTask.TaskType == (int)TaskTypeEnum.Inbound ? 1 : 2,
                    d_floor = 1,
                    d_involed1 = newTask.SourceAddress,
                    d_involed2 = newTask.TargetAddress,
                    d_involed5 = newTask.TaskNum,
                };
                SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand();
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
        public WebResponseContent GetAGVStatus()
        {
            try
            {
                var x = _Socket.GetAGVStatus();
                return WebResponseContent.Instance.OK(data: x);
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        public WebResponseContent GetStationStatus(string StationName)
        {
            try
            {
                var x = _Socket.GetStationStatus(StationName);
                return WebResponseContent.Instance.OK(data: x);
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        #endregion 澶栭儴鎺ュ彛鏂规硶
    }
}