| | |
| | | using LogLibrary.Log; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | |
| | | using WIDESEA_IStorageBasicRepository; |
| | | using WIDESEA_IStorageSocketServices; |
| | | using WIDESEA_IStorageTaskRepository; |
| | | using WIDESEA_IStorageTaskServices; |
| | | using WIDESEA_IStoragIntegrationServices; |
| | | using WIDESEA_Model.Models.AGV; |
| | | using WIDESEA_Repository; |
| | | using WIDESEA_StorageSocketServices; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Model.Models; |
| | | using static WIDESEAWCS_BasicInfoService.Dt_StationManagerService; |
| | | |
| | | namespace WIDESEA_StoragIntegrationServices |
| | | { |
| | |
| | | { |
| | | private readonly ILocationInfoRepository _locationRepository; |
| | | private readonly IDt_TaskRepository BaseDal; |
| | | private readonly IDt_TaskService _taskService; |
| | | private readonly IStockInfoRepository _stockInfoRepository; |
| | | private readonly ISys_ConfigService _configService; |
| | | private readonly IDt_StationManagerRepository _stationManagerRepository; |
| | |
| | | public SocketClientService _Socket { get; set; } |
| | | private readonly IMapper _mapper; |
| | | private readonly IDt_DeviceInfoRepository _deviceInfoRepository; |
| | | private readonly IDt_HandAutomaticRepository _handAutomaticRepository; |
| | | |
| | | public AGVService(ILocationInfoRepository locationRepository, IDt_TaskRepository taskRepository, IStockInfoRepository stockInfoRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository, IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, SocketClientService socketClientService) |
| | | public AGVService(ILocationInfoRepository locationRepository, IDt_TaskRepository taskRepository, IStockInfoRepository stockInfoRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository, IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, SocketClientService socketClientService, IDt_TaskService taskService, IDt_HandAutomaticRepository handAutomaticRepository) |
| | | { |
| | | _locationRepository = locationRepository; |
| | | BaseDal = taskRepository; |
| | |
| | | _deviceInfoRepository = deviceInfoRepository; |
| | | _mapper = mapper; |
| | | _Socket = socketClientService; |
| | | _taskService = taskService; |
| | | _handAutomaticRepository = handAutomaticRepository; |
| | | } |
| | | #region å¤é¨æ¥å£æ¹æ³ |
| | | |
| | |
| | | /// <param name="PallteCode"></param> |
| | | /// <param name="SourceAddress"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RequestInTask(string PalletCode, string SourceAddress) |
| | | public WebResponseContent RequestInTask(AGVDTO aGVDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_StationManager Instation = _stationManagerRepository.QueryFirst(x => x.stationName == SourceAddress && x.stationType == 1); |
| | | var HandAutomatic = _handAutomaticRepository.QueryFirst(x => true && x.HandAutomatic == "Automatic"); |
| | | if (HandAutomatic == null) |
| | | { |
| | | return content.Error("å½å䏿¯èªå¨æ¨¡å¼ä¸å¯ä¸åä»»å¡"); |
| | | } |
| | | Dt_StationManager Instation = _stationManagerRepository.QueryFirst(x => x.stationName == aGVDTO.SourceAddress && x.stationType == 1); |
| | | List<Dt_StationManager> Outstation = _stationManagerRepository.QueryData(x => x.stationType == 2).ToList(); |
| | | if (Instation == null) |
| | | { |
| | | return content.Error("æªæ¾å°å
¥åºç«å°ä¿¡æ¯"); |
| | | } |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == PalletCode); |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == aGVDTO.PalletCode); |
| | | if (task != null) |
| | | { |
| | | return content.Error("该æçå·²åå¨ä»»å¡"); |
| | | } |
| | | //StationStatus stationOut = _Socket.GetStationStatus("B001"); |
| | | List<OutStationStatus> outStationStatus = new List<OutStationStatus>(); |
| | | StationStatus stationOut = _Socket.GetStationStatus("B001"); |
| | | //List<OutStationStatus> outStationStatus = _Socket.GetOutStationStatus(stationOut); |
| | | #region |
| | | 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() |
| | | { |
| | | StationName = "04", |
| | | StationEnable = stationOut.WorkstationO == "1" ? "0" : "1", |
| | | StationEnable = aGVDTO.WorkstationO == "1" ? "0" : "1", |
| | | IsDistributionTask = taskOutStationO == null ? "0" : "1", |
| | | Spare1 = "00" |
| | | }); |
| | | outStationStatus.Add(new OutStationStatus() |
| | | { |
| | | StationName = "03", |
| | | StationEnable = stationOut.WorkstationT == "1" ? "0" : "1", |
| | | StationEnable = aGVDTO.WorkstationT == "1" ? "0" : "1", |
| | | IsDistributionTask = taskOutStationT == null ? "0" : "1", |
| | | Spare1 = "00" |
| | | Spare1 = "00", |
| | | |
| | | }); |
| | | #endregion |
| | | AGVStatusRespone status = _Socket.GetAGVStatus(); |
| | | HOSTAGVStatus AgvStatus = new HOSTAGVStatus() |
| | | { |
| | |
| | | StationName = Instation.HostName, |
| | | StationEnable = "0", |
| | | IsDistributionTask = "0", |
| | | PallteCode = PalletCode, |
| | | PallteCode = aGVDTO.PalletCode, |
| | | }; |
| | | _Socket.DeviceRequestInbound(AgvStatus, outStationStatus, inStationStatus); |
| | | |
| | | LogFactory.GetLog("å
¥åºè¯·æ±").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(aGVDTO)}", ""); |
| | | return content.OK("å·²ä¸åå
¥åºä»»å¡"); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var HandAutomatic = _handAutomaticRepository.QueryFirst(x => true && x.HandAutomatic == "Automatic"); |
| | | if (HandAutomatic == null) |
| | | { |
| | | _Socket.DeviceAutoStatusReport("1"); |
| | | return content.OK(); |
| | | } |
| | | Dt_DeviceInfo device = _deviceInfoRepository.QueryFirst(x => x.DeviceName == Status.AGVName); |
| | | if (device != null) |
| | | { |
| | | device.RuntimeStatus = Status.RuntimeStatus; |
| | | device.AutoStatus = Status.AutoStatus; |
| | | _deviceInfoRepository.UpdateData(device); |
| | | switch (Status.RuntimeStatus) |
| | | if (device.RuntimeStatus != Status.RuntimeStatus) |
| | | { |
| | | case "Run": |
| | | //è¿è¡ |
| | | _Socket.DeviceStateReport("R"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | case "Idle": |
| | | //å
³æº |
| | | _Socket.DeviceStateReport("I"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | case "Trouble": |
| | | //æ
é |
| | | _Socket.DeviceStateReport("T"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | case "Pause": |
| | | //æå |
| | | _Socket.DeviceStateReport("S"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | case "Charge": |
| | | //å
çµ |
| | | _Socket.DeviceStateReport("C"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | case "PowerOn": |
| | | //弿º |
| | | _Socket.DeviceStateReport("P"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | case "PowerOFF": |
| | | //å
³æº |
| | | _Socket.DeviceStateReport("O"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | default: break; |
| | | device.RuntimeStatus = Status.RuntimeStatus; |
| | | device.AutoStatus = Status.AutoStatus; |
| | | _deviceInfoRepository.UpdateData(device); |
| | | switch (Status.RuntimeStatus) |
| | | { |
| | | case "Run": |
| | | //è¿è¡ |
| | | _Socket.DeviceStateReport("R"); |
| | | Thread.Sleep(1000); |
| | | _Socket.JobReady("0"); |
| | | break; |
| | | case "Idle": |
| | | //ç©ºé² |
| | | _Socket.DeviceStateReport("I"); |
| | | _Socket.JobReady("1"); |
| | | break; |
| | | case "Trouble": |
| | | //æ
é |
| | | _Socket.DeviceStateReport("T"); |
| | | Thread.Sleep(1000); |
| | | _Socket.JobReady("0"); |
| | | break; |
| | | case "Pause": |
| | | //æå |
| | | _Socket.DeviceStateReport("S"); |
| | | Thread.Sleep(1000); |
| | | _Socket.JobReady("0"); |
| | | break; |
| | | case "Charge": |
| | | //å
çµ |
| | | _Socket.DeviceStateReport("C"); |
| | | Thread.Sleep(1000); |
| | | _Socket.JobReady("0"); |
| | | break; |
| | | case "PowerOn": |
| | | //弿º |
| | | _Socket.DeviceStateReport("P"); |
| | | Thread.Sleep(1000); |
| | | _Socket.JobReady("0"); |
| | | break; |
| | | case "PowerOFF": |
| | | //å
³æº |
| | | _Socket.DeviceStateReport("O"); |
| | | Thread.Sleep(1000); |
| | | _Socket.JobReady("0"); |
| | | break; |
| | | default: break; |
| | | } |
| | | } |
| | | switch (Status.AutoStatus) |
| | | if (device.AutoStatus != Status.AutoStatus) |
| | | { |
| | | case "MaintenanceMode": |
| | | //è¿è¡ |
| | | _Socket.DeviceAutoStatusReport("1"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | case "ControlMode": |
| | | //å
³æº |
| | | _Socket.DeviceAutoStatusReport("0"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | default: break; |
| | | device.RuntimeStatus = Status.RuntimeStatus; |
| | | device.AutoStatus = Status.AutoStatus; |
| | | _deviceInfoRepository.UpdateData(device); |
| | | switch (Status.AutoStatus) |
| | | { |
| | | case "MaintenanceMode": |
| | | //æå¨ |
| | | _Socket.DeviceAutoStatusReport("1"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | case "ControlMode": |
| | | //èªå¨ |
| | | _Socket.DeviceAutoStatusReport("0"); |
| | | Thread.Sleep(500); |
| | | break; |
| | | default: break; |
| | | } |
| | | } |
| | | } |
| | | else |
| | |
| | | }; |
| | | _deviceInfoRepository.AddData(deviceInfo); |
| | | } |
| | | |
| | | LogFactory.GetLog("AGVç¶æåæ´").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(Status)}", ""); |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | |
| | | |
| | | public WebResponseContent AGVStartOrEndJob(string Status, int TaskNum) |
| | | public WebResponseContent AGVStartOrEndJob(AGVDTO aGVDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == TaskNum); |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == aGVDTO.TaskNum); |
| | | if (task != null) |
| | | { |
| | | switch (task.TaskType) |
| | | if (task.Roadway == "PDA") |
| | | { |
| | | case (int)TaskInboundTypeEnum.Inbound: |
| | | //å
¥åº |
| | | if (Status == "Start") |
| | | { |
| | | _Socket.JobStartOrEnd(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "I", task.PalletCode); |
| | | task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting; |
| | | } |
| | | else if (Status == "Loadel") |
| | | { |
| | | _Socket.PalletActionReport(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "I", task.PalletCode); |
| | | } |
| | | else |
| | | { |
| | | _Socket.PalletActionReport(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "I", task.PalletCode); |
| | | Thread.Sleep(2000); |
| | | _Socket.PalletActionReport(task.SourceAddress, task.TargetAddress, "I", task.PalletCode); |
| | | task.TaskState = (int)TaskInStatusEnum.AGV_InFinish; |
| | | } |
| | | break; |
| | | case (int)TaskOutboundTypeEnum.Outbound: |
| | | //åºåº |
| | | if (Status == "Start") |
| | | { |
| | | _Socket.JobStartOrEnd(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "O", task.PalletCode); |
| | | task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting; |
| | | } |
| | | else if (Status == "Loadel") |
| | | { |
| | | _Socket.PalletActionReport(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "O", task.PalletCode); |
| | | } |
| | | else |
| | | { |
| | | _Socket.PalletActionReport(Status, task.SourceAddress, task.TargetAddress, "O", task.PalletCode); |
| | | Thread.Sleep(2000); |
| | | _Socket.PalletActionReport(task.SourceAddress, task.TargetAddress, "O", task.PalletCode); |
| | | task.TaskState = (int)TaskOutStatusEnum.AGV_OutFinish; |
| | | } |
| | | break; |
| | | case (int)TaskRelocationTypeEnum.Relocation: |
| | | if (Status == "Start") |
| | | { |
| | | _Socket.JobStartOrEnd(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode); |
| | | task.TaskState = (int)TaskRelocationStatusEnum.AGV_RelocationExecuting; |
| | | } |
| | | else if (Status == "Loadel") |
| | | { |
| | | _Socket.PalletActionReport(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode); |
| | | } |
| | | else |
| | | { |
| | | _Socket.PalletActionReport(Status, task.SourceAddress, task.TargetAddress, "R", task.PalletCode); |
| | | Thread.Sleep(2000); |
| | | _Socket.PalletActionReport(task.SourceAddress, task.TargetAddress, "R", task.PalletCode); |
| | | task.TaskState = (int)TaskRelocationStatusEnum.AGV_RelocationFinish; |
| | | } |
| | | break; |
| | | case (int)TaskStationTypeEnum.StationToStation: |
| | | if (Status == "Start") |
| | | { |
| | | _Socket.JobStartOrEnd(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "S", task.PalletCode); |
| | | task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting; |
| | | } |
| | | else if (Status == "Loadel") |
| | | { |
| | | _Socket.PalletActionReport(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "S", task.PalletCode); |
| | | } |
| | | else |
| | | { |
| | | _Socket.PalletActionReport(Status, task.SourceAddress, task.TargetAddress, "S", task.PalletCode); |
| | | Thread.Sleep(2000); |
| | | _Socket.PalletActionReport(task.SourceAddress, task.TargetAddress, "S", task.PalletCode); |
| | | task.TaskState = (int)TaskOutStatusEnum.AGV_OutFinish; |
| | | } |
| | | break; |
| | | default: break; |
| | | LogFactory.GetLog("AGVå¨ä½ç¶æåæ´PDAä»»å¡").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(aGVDTO)}", ""); |
| | | if (aGVDTO.Status == "Start") |
| | | { |
| | | _taskService.TaskStatus(task); |
| | | return content.OK(); |
| | | } |
| | | else if (aGVDTO.Status == "Unload") |
| | | { |
| | | return _taskService.TaskComplete(task.TaskNum); |
| | | } |
| | | else |
| | | { |
| | | return content.OK(); |
| | | } |
| | | } |
| | | BaseDal.Update(task); |
| | | return content.OK(); |
| | | else |
| | | { |
| | | switch (task.TaskType) |
| | | { |
| | | case (int)TaskInboundTypeEnum.Inbound: |
| | | //å
¥åº |
| | | var station = _stationManagerRepository.QueryFirst(x => x.stationName == task.SourceAddress); |
| | | if (aGVDTO.Status == "Start") |
| | | { |
| | | _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), "0000" + station.HostName, task.TargetAddress, "I", task.PalletCode); |
| | | task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting; |
| | | } |
| | | else if (aGVDTO.Status == "Loadel") |
| | | { |
| | | _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + station.HostName, task.TargetAddress, "I", task.PalletCode); |
| | | } |
| | | else |
| | | { |
| | | _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + station.HostName, task.TargetAddress, "I", task.PalletCode); |
| | | Thread.Sleep(2000); |
| | | _Socket.PalletActionReport("0000" + station.HostName, task.TargetAddress, "I", task.PalletCode); |
| | | task.TaskState = (int)TaskInStatusEnum.AGV_InFinish; |
| | | _taskService.CompleteInboundTask(task); |
| | | } |
| | | break; |
| | | case (int)TaskOutboundTypeEnum.Outbound: |
| | | //åºåº |
| | | var stationOut = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress); |
| | | if (aGVDTO.Status == "Start") |
| | | { |
| | | _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode); |
| | | task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting; |
| | | } |
| | | else if (aGVDTO.Status == "Loadel") |
| | | { |
| | | _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode); |
| | | } |
| | | else |
| | | { |
| | | _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode); |
| | | Thread.Sleep(2000); |
| | | _Socket.PalletActionReport(task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode); |
| | | task.TaskState = (int)TaskOutStatusEnum.AGV_OutFinish; |
| | | _taskService.CompleteOutboundTask(task); |
| | | } |
| | | break; |
| | | case (int)TaskRelocationTypeEnum.Relocation: |
| | | if (aGVDTO.Status == "Start") |
| | | { |
| | | _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode); |
| | | task.TaskState = (int)TaskRelocationStatusEnum.AGV_RelocationExecuting; |
| | | } |
| | | else if (aGVDTO.Status == "Loadel") |
| | | { |
| | | _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode); |
| | | } |
| | | else |
| | | { |
| | | _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode); |
| | | Thread.Sleep(2000); |
| | | _Socket.PalletActionReport(task.SourceAddress, task.TargetAddress, "R", task.PalletCode); |
| | | task.TaskState = (int)TaskRelocationStatusEnum.AGV_RelocationFinish; |
| | | _taskService.CompleteRelocationboundTask(task); |
| | | } |
| | | break; |
| | | case (int)TaskStationTypeEnum.StationToStation: |
| | | var stationIn = _stationManagerRepository.QueryFirst(x => x.stationName == task.SourceAddress); |
| | | var stationout = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress); |
| | | if (aGVDTO.Status == "Start") |
| | | { |
| | | _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), "0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode); |
| | | task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting; |
| | | } |
| | | else if (aGVDTO.Status == "Loadel") |
| | | { |
| | | _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode); |
| | | } |
| | | else |
| | | { |
| | | _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode); |
| | | Thread.Sleep(2000); |
| | | _Socket.PalletActionReport("0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode); |
| | | task.TaskState = (int)TaskOutStatusEnum.AGV_OutFinish; |
| | | _taskService.TaskMoveHty(task); |
| | | } |
| | | break; |
| | | default: break; |
| | | } |
| | | BaseDal.Update(task); |
| | | LogFactory.GetLog("AGVå¨ä½ç¶æåæ´").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(aGVDTO)}", ""); |
| | | return content.OK(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | public WebResponseContent DeviceErrorResponse(string Message, int TaskNum) |
| | | public WebResponseContent DeviceErrorResponse(AGVDTO aGVDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var task = BaseDal.QueryFirst(x => x.TaskNum == TaskNum); |
| | | var task = BaseDal.QueryFirst(x => x.TaskNum == aGVDTO.TaskNum); |
| | | if (task != null) |
| | | { |
| | | switch (Message) |
| | | switch (aGVDTO.Message) |
| | | { |
| | | case "RepeatInbound": |
| | | |
| | |
| | | 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(); |
| | | 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 å¤é¨æ¥å£æ¹æ³ |
| | | |
| | | |
| | | } |
| | | } |