1
huangxiaoqiang
2025-05-21 c570f80289bd9b04f02b861f2a91d47b3e1aec72
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs
@@ -319,28 +319,106 @@
                return content.Error(ex.Message);
            }
        }
        //public WebResponseContent Add()
        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)
        //{
        //    try
        //    {
        //        var x = BaseDal.GetTaskNo().Result;
                //    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();
        //        task_call task_Call = new task_call()
        //        {
        //            d_task_type = 1,
        //            d_floor = 1,
        //            d_involed1 = "480101",
        //            d_involed2 = "B001::1",
        //            d_involed5 = x,
        //        };
        //        var y=SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand();
        //        return WebResponseContent.Instance.OK(data: y);
        //    }
        //    catch (Exception ex)
        //    {
        //        return WebResponseContent.Instance.Error(ex.Message);
        //    }
        //}
            }
            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 澶栭儴鎺ュ彛鏂规硶