From a9cb1154be286af34862015c57918038c85c3749 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <1247017146@qq.com>
Date: 星期一, 26 五月 2025 15:26:42 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs | 202 ++++++++++++++++++++++++++++++++++++++------------
1 files changed, 153 insertions(+), 49 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 ed96e28..0a6e45e 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"
@@ -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,30 +320,133 @@
return content.Error(ex.Message);
}
}
- //public WebResponseContent Add()
- //{
- // try
- // {
- // var x = BaseDal.GetTaskNo().Result;
- // 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);
- // }
- //}
+ 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 澶栭儴鎺ュ彛鏂规硶
-
+
}
}
--
Gitblit v1.9.3