From 37d02df69d8e9d7c4f30e069a8f6caa3e47a5de7 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期四, 26 六月 2025 10:52:59 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs | 520 +++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 395 insertions(+), 125 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs"
index f533dc7..5e18cd1 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs"
@@ -1,6 +1,7 @@
锘縰sing LogLibrary.Log;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -10,12 +11,14 @@
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
{
@@ -23,24 +26,26 @@
{
private readonly ILocationInfoRepository _locationRepository;
private readonly IDt_TaskRepository BaseDal;
- private readonly IStockInfoRepository _stockInfoRepository;
- private readonly ISys_ConfigService _configService;
+ private readonly IDt_TaskService _taskService;
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;
+ private readonly IDt_HandAutomaticRepository _handAutomaticRepository;
+ private readonly IDt_ErrorDescriptionRepository _descriptionRepository;
- 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, IDt_StationManagerRepository stationManagerRepository, IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, SocketClientService socketClientService, IDt_TaskService taskService, IDt_HandAutomaticRepository handAutomaticRepository, IDt_ErrorDescriptionRepository descriptionRepository)
{
_locationRepository = locationRepository;
BaseDal = taskRepository;
- _stockInfoRepository = stockInfoRepository;
- _configService = configService;
_stationManagerRepository = stationManagerRepository;
_deviceInfoRepository = deviceInfoRepository;
_mapper = mapper;
- _Socket= socketClientServices;
+ _Socket = socketClientService;
+ _taskService = taskService;
+ _handAutomaticRepository = handAutomaticRepository;
+ _descriptionRepository = descriptionRepository;
}
#region 澶栭儴鎺ュ彛鏂规硶
@@ -50,55 +55,67 @@
/// <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 location = _locationRepository.QueryData(x => x.LocationStatus==(int)LocationEnum.Free).ToList();
+ if (location.Count == 0)
+ {
+ 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>();
- foreach (var item in Outstation)
+ //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()
{
- 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.stationName,
- StationEnable = station.StationEnable == "1" ? "0" : "1",
- IsDistributionTask = taskStation == null ? "0" : "1",
- Spare1 = "00"
- });
- }
+ StationName = "04",
+ StationEnable = aGVDTO.WorkstationO == "1" ? "0" : "1",
+ IsDistributionTask = taskOutStationO == null ? "0" : "1",
+ Spare1 = "00"
+ });
+ outStationStatus.Add(new OutStationStatus()
+ {
+ StationName = "03",
+ StationEnable = aGVDTO.WorkstationT == "1" ? "0" : "1",
+ IsDistributionTask = taskOutStationT == null ? "0" : "1",
+ Spare1 = "00",
+
+ });
+ #endregion
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 = aGVDTO.PalletCode,
};
_Socket.DeviceRequestInbound(AgvStatus, outStationStatus, inStationStatus);
+
+ LogFactory.GetLog("鍏ュ簱璇锋眰").InfoFormat(true, $"璇锋眰鍙傛暟锛歿JsonConvert.SerializeObject(aGVDTO)}", "");
return content.OK("宸蹭笅鍙戝叆搴撲换鍔�");
- }
- catch (Autofac.Core.DependencyResolutionException ex)
- {
- return content.Error(ex.Message);
}
catch (Exception ex)
{
@@ -113,64 +130,85 @@
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
@@ -183,6 +221,8 @@
};
_deviceInfoRepository.AddData(deviceInfo);
}
+
+ LogFactory.GetLog("AGV鐘舵�佸彉鏇�").InfoFormat(true, $"璇锋眰鍙傛暟锛歿JsonConvert.SerializeObject(Status)}", "");
return content.OK();
}
catch (Exception ex)
@@ -191,94 +231,250 @@
}
}
-
- 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 == Convert.ToInt32(aGVDTO.TaskNum));
if (task != null)
{
switch (task.TaskType)
{
case (int)TaskInboundTypeEnum.Inbound:
//鍏ュ簱
- if (Status == "Start")
+ var station = _stationManagerRepository.QueryFirst(x => x.stationName == task.SourceAddress);
+ if (aGVDTO.Status == "Start")
{
- _Socket.JobStartOrEnd(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "I", task.PalletCode);
- task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting;
+ if (task.Roadway == "PDA")
+ {
+ _taskService.TaskStatus(task);
+ return content.OK();
+ }
+ else
+ {
+ _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), "0000" + station.HostName, task.TargetAddress, "I", task.PalletCode);
+ task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting;
+ }
+
}
- else if (Status == "Loadel")
+ else if (aGVDTO.Status == "Loadel")
{
- _Socket.PalletActionReport(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "I", task.PalletCode);
+ _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + station.HostName, 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);
+ if (task.Roadway == "PDA")
+ {
+ _Socket.PalletActionReportPDA("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:
//鍑哄簱
- if (Status == "Start")
+ var stationOut = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress);
+ if (aGVDTO.Status == "Start")
{
- _Socket.JobStartOrEnd(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "O", task.PalletCode);
- task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting;
+ if (task.Roadway == "PDA")
+ {
+ _taskService.TaskStatus(task);
+ return content.OK();
+ }
+ else
+ {
+ _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode);
+ task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting;
+ }
}
- else if (Status == "Loadel")
+ else if (aGVDTO.Status == "Loadel")
{
- _Socket.PalletActionReport(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "O", task.PalletCode);
+ _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationOut.HostName, "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);
+ if (task.Roadway == "PDA")
+ {
+ _Socket.PalletActionReportPDA(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 (Status == "Start")
+ if (aGVDTO.Status == "Start")
{
- _Socket.JobStartOrEnd(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode);
- task.TaskState = (int)TaskRelocationStatusEnum.AGV_RelocationExecuting;
+ if (task.Roadway == "PDA")
+ {
+ _taskService.TaskStatus(task);
+ return content.OK();
+ }
+ else
+ {
+ _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode);
+ task.TaskState = (int)TaskRelocationStatusEnum.AGV_RelocationExecuting;
+ }
}
- else if (Status == "Loadel")
+ else if (aGVDTO.Status == "Loadel")
{
- _Socket.PalletActionReport(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode);
+ _Socket.PalletActionReport(aGVDTO.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);
+ if (task.Roadway == "PDA")
+ {
+ _Socket.PalletActionReportPDA(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:
- if (Status == "Start")
+ var stationIn = _stationManagerRepository.QueryFirst(x => x.stationName == task.SourceAddress);
+ var stationout = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress);
+ if (aGVDTO.Status == "Start")
{
- _Socket.JobStartOrEnd(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "S", task.PalletCode);
- task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting;
+ if (task.Roadway == "PDA")
+ {
+ _taskService.TaskStatus(task);
+ return content.OK();
+ }
+ else
+ {
+ _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), "0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode);
+ task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting;
+ }
}
- else if (Status == "Loadel")
+ else if (aGVDTO.Status == "Loadel")
{
- _Socket.PalletActionReport(Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "S", task.PalletCode);
+ _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + stationIn.HostName, "0000" + stationout.HostName, "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);
+ if (task.Roadway == "PDA")
+ {
+ _Socket.PalletActionReportPDA("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;
+ case (int)TaskFireAlarmTypeEnum.FireAlarmOut:
+ if (aGVDTO.Status == "Start")
+ {
+ _taskService.AddStcokHty(task.PalletCode, task.SourceAddress);
+ task.TaskState = (int)TaskFireAlarmStatusEnum.AGV_FireAlarmExecuting;
+ BaseDal.Update(task);
+ }
+ else if (aGVDTO.Status == "Loadel")
+ {
+
+ }
+ else
+ {
+
+ var stationFireAlarm = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress);
+ if (task.Roadway == "PDA")
+ {
+ _Socket.PalletActionReportFrie(task.SourceAddress, "0000" + stationFireAlarm.HostName, "F", task.PalletCode); ;
+ }
+ task.TaskState = (int)TaskFireAlarmStatusEnum.AGV_FireAlarmFinish;
+ _taskService.TaskMoveHty(task);
+ }
+ break;
+ case (int)TaskOutboundTypeEnum.OutQuality:
+ //鎶芥
+ var stationC = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress);
+ if (aGVDTO.Status == "Start")
+ {
+ if (task.Roadway == "PDA")
+ {
+ _taskService.TaskStatus(task);
+ return content.OK();
+ }
+ else
+ {
+ _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationC.HostName, "C", task.PalletCode);
+ task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting;
+ }
+ }
+ else if (aGVDTO.Status == "Loadel")
+ {
+ if (task.Roadway == "PDA")
+ {
+ return content.OK();
+ }
+ _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationC.HostName, "C", task.PalletCode);
+ }
+ else
+ {
+ if (task.Roadway == "PDA")
+ {
+ _taskService.TaskComplete(task.TaskNum);
+ _Socket.PalletActionReportPDA(task.SourceAddress, "0000" + stationC.HostName, "O", task.PalletCode);
+ }
+ else
+ {
+ _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationC.HostName, "C", task.PalletCode);
+ Thread.Sleep(2000);
+ _Socket.PalletActionReport(task.SourceAddress, "0000" + stationC.HostName, "C", task.PalletCode);
+ task.TaskState = (int)TaskOutStatusEnum.AGV_OutFinish;
+ _taskService.CompleteOutboundTask(task);
+ }
+ }
+ break;
+ case (int)TaskInboundTypeEnum.InQuality:
+ //鎶芥
+ if (aGVDTO.Status == "Start")
+ {
+ if (task.Roadway == "PDA")
+ {
+ _taskService.TaskStatus(task);
+ return content.OK();
+ }
+ }
+ else if (aGVDTO.Status == "Loadel")
+ {
+ return content.OK();
+ }
+ else
+ {
+ if (task.Roadway == "PDA")
+ {
+ _taskService.TaskComplete(task.TaskNum);
+ }
}
break;
default: break;
}
BaseDal.Update(task);
+ LogFactory.GetLog("AGV鍔ㄤ綔鐘舵�佸彉鏇�").InfoFormat(true, $"璇锋眰鍙傛暟锛歿JsonConvert.SerializeObject(aGVDTO)}", "");
return content.OK();
}
else
@@ -293,34 +489,108 @@
}
- 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);
+ LogFactory.GetLog("AGV寮傚父淇℃伅").InfoFormat(true, $"璇锋眰鍙傛暟锛歿JsonConvert.SerializeObject(aGVDTO)}", "");
+ var task = BaseDal.QueryFirst(x => x.TaskNum ==Convert.ToInt32( aGVDTO.TaskNum));
if (task != null)
{
- switch(Message)
+
+ string HostType = string.Empty;
+ if (task.TaskType == (int)TaskInboundTypeEnum.Inbound)
{
- case "RepeatInbound":
-
+ HostType = "I";
+ }
+ else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+ {
+ HostType = "O";
+ }
+ else if (task.TaskType == (int)TaskOutboundTypeEnum.OutQuality)
+ {
+ HostType = "C";
+ }
+ else if (task.TaskType == (int)TaskRelocationTypeEnum.Relocation)
+ {
+ HostType = "R";
+ }
+ else if (task.TaskType == (int)TaskStationTypeEnum.StationToStation)
+ {
+ HostType = "S";
+ }
+ switch (aGVDTO.Message)
+ {
+ //绌哄嚭搴�
+ case "0000400":
+ _Socket.EmptyOutBound(task.SourceAddress, "0000" + StationParse(task.TargetAddress), task.PalletCode);
+ _taskService.AddStcokHty(task.PalletCode, task.SourceAddress);
+ _taskService.TaskMoveHty(task);
+ _Socket.AddErrorMessage("2101", "AGV", "");
break;
- case "EmptyOutbound":
-
+ //閲嶅叆搴�
+ case "0000200":
+ _Socket.RecreateGetLocation("0000" + StationParse(task.SourceAddress), task.TargetAddress, HostType, task.PalletCode);
+ _Socket.AddErrorMessage("2100", "AGV", "");
break;
- default:break;
+ default: break;
}
}
return content.OK();
}
catch (Exception ex)
{
+ LogFactory.GetLog("AGV寮傚父淇℃伅").InfoFormat(true, $"璇锋眰鍙傛暟锛歿JsonConvert.SerializeObject(ex.Message)}", "");
return content.Error(ex.Message);
}
}
- #endregion 澶栭儴鎺ュ彛鏂规硶
-
+ public string StationParse(string station)
+ {
+ var Station = SqlSugarHelper.DbWMS.Queryable<Dt_StationManager>().Where(x => x.stationName == station).First();
+ if (Station != null)
+ {
+ return Station.HostName;
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public WebResponseContent DeviceWarning(AGVDTO DTO)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ LogFactory.GetLog("AG涓婁紶鎶ヨ淇℃伅").InfoFormat(true, $"璇锋眰鍙傛暟锛歿JsonConvert.SerializeObject(DTO)}", "");
+ if (DTO.Message!= null)
+ {
+ Dt_ErrorDescription description=_descriptionRepository.QueryFirst(x => x.Type == DTO.Message);
+ if(description != null)
+ {
+ _Socket.ErrorReport(description.ErrorCode, "A", "00");
+ _Socket.AddErrorMessage(description.ErrorCode, "AGV", "");
+ return content.OK();
+ }
+ else
+ {
+ return content.Error("鏈瘑鍒姤璀︽簮");
+ }
+ }
+ else
+ {
+ return content.Error("鏈帴鏀跺埌寮傚父淇℃伅");
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFactory.GetLog("AG涓婁紶鎶ヨ淇℃伅").InfoFormat(true, $"璇锋眰鍙傛暟锛歿JsonConvert.SerializeObject(ex.Message)}", "");
+ return content.Error(ex.Message);
+ }
+
+ }
+ #endregion 澶栭儴鎺ュ彛鏂规硶
}
}
--
Gitblit v1.9.3