From a0a0df2e824b6fe7e5a3c0afce78127fecf84fc9 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 03 十一月 2025 08:23:05 +0800
Subject: [PATCH] ERP接口代码更新,WCS代码优化,出入库分配优化
---
项目代码/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs | 540 ++++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 400 insertions(+), 140 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
index 57151fe..70ebbef 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
@@ -8,6 +8,7 @@
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core.LogHelper;
+using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.Agv;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
@@ -15,9 +16,13 @@
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.DTO;
+using WIDESEAWCS_QuartzJob.Models;
+using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_Tasks;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using WIDESEAWCS_Tasks.DBNames;
+using WIDESEAWCS_Tasks.StackPlateJob;
+using static Dm.net.buffer.ByteArrayBuffer;
namespace WIDESEAWCS_Server.Controllers
{
@@ -28,12 +33,14 @@
private readonly IStationMangerRepository _stationMangerRepository;
private readonly ITaskService _taskService;
private readonly ITaskRepository _taskRepository;
+ private readonly IRouterRepository _routerRepository;
- public AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository)
+ public AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository,IRouterRepository routerRepository)
{
_stationMangerRepository = stationMangerRepository;
_taskService = taskService;
_taskRepository = taskRepository;
+ _routerRepository = routerRepository;
}
@@ -44,42 +51,58 @@
/// <param name="secureApplyModel"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("AgvSecureApply"), AllowAnonymous]
- public AgvResponseContent AgvSecureApply([FromBody] AgvSecureApplyDTO secureApplyModel)
+ public AgvResponse AgvSecureApply([FromBody] AgvSecureApplyDTO secureApplyModel)
{
- AgvResponseContent agvResponseContent = new AgvResponseContent();
- agvResponseContent.ReqCode = secureApplyModel.ReqCode;
+ AgvResponse agvResponse = new AgvResponse();
try
{
- var task = _taskRepository.QueryFirst(x => secureApplyModel.TaskCode == x.AgvTaskNum);
+ var task = _taskRepository.QueryFirst(x => secureApplyModel.ReceiveTaskID.ObjToInt() == x.TaskNum);
if (task == null) throw new Exception("鏈壘鍒颁换鍔�");
- if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
+ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
{
- var content = TakeRequest(task.CurrentAddress);
- //if (!content.Status)
- //{
- // throw new Exception(content.Message);
- //}
+ if (task.TaskState==TaskStatusEnum.AGV_Executing.ObjToInt())//鍑哄簱鍙栬揣璇锋眰
+ {
+ var content = TakeRequest(secureApplyModel.WbCode);
+ if (!content.Status)
+ {
+ throw new Exception(content.Message);
+ }
+ }
+ else//鍑哄簱鏀捐揣璇锋眰
+ {
+ var content = PutRequest(task.NextAddress, task.PalletType);
+ if (!content.Status)
+ {
+ throw new Exception(content.Message);
+ }
+ }
}
else
{
- var content = PutRequest(task.NextAddress, task.PalletType);
- //if (!content.Status)
- //{
- // throw new Exception(content.Message);
- //}
+ if (task.TaskState == TaskStatusEnum.AGV_Executing.ObjToInt())//鍏ュ簱鍙栬揣璇锋眰
+ {
+ var content = TakeRequest(secureApplyModel.WbCode);
+ if (!content.Status)
+ {
+ throw new Exception(content.Message);
+ }
+ }
+ else//鍏ュ簱鏀捐揣璇锋眰
+ {
+ var content = PutRequest(task.NextAddress, task.TaskNum);
+ if (!content.Status)
+ {
+ throw new Exception(content.Message);
+ }
+ }
}
- task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
- var up = _taskRepository.UpdateData(task);
- agvResponseContent.Code = up ? "0" : "1";
- agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
+ agvResponse.OK("鎴愬姛","0");
}
catch (Exception ex)
{
- agvResponseContent.Code = "1";
- agvResponseContent.Message = ex.Message;
+ agvResponse.Error(ex.Message);
}
- return agvResponseContent;
- //return _taskService.AgvSecureApply(secureApplyModel);
+ return agvResponse;
}
/// <summary>
/// 鎻愬崌鏈虹敵璇� AGV-WCS
@@ -195,87 +218,91 @@
/// <param name="agvUpdateModel"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("AgvCallback"), AllowAnonymous]
- public AgvResponseContent AgvUpdateTask([FromBody] AgvUpdateDTO agvUpdateModel)
+ public AgvResponse AgvCallback([FromBody] AgvUpdateDTO agvUpdateModel)
{
- AgvResponseContent agvResponseContent = new AgvResponseContent();
+ AgvResponse agvResponse = new AgvResponse();
try
{
- if (agvUpdateModel == null) throw new Exception("鏈幏鍙栧埌璇锋眰鍙傛暟");
- agvResponseContent.ReqCode = agvUpdateModel.ReqCode;
- var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode == x.AgvTaskNum);
- if (task == null) throw new Exception($"鏈壘鍒颁换鍔�,浠诲姟鍙枫�恵agvUpdateModel.TaskCode}銆�");
- switch (agvUpdateModel.Method)
+ var task = _taskRepository.QueryFirst(x => agvUpdateModel.ReceiveTaskID == x.TaskNum.ToString());
+ if (task == null) throw new Exception($"鏈壘鍒颁换鍔�,浠诲姟鍙枫�恵agvUpdateModel.ReceiveTaskID}銆�");
+ switch (agvUpdateModel.GoodsState)
{
- case "start":
- break;
- case "outbin"://鍑哄簱鏍规嵁杩欎釜淇″彿鍒ゆ柇鍙栬揣瀹屾垚
- if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
+ case "1"://鍑哄簱鏍规嵁杩欎釜淇″彿鍒ゆ柇鍙栬揣瀹屾垚
+
+ //鏇存柊浠诲姟鐘舵��
+ _taskService.UpdateTask(task, TaskStatusEnum.AGV_TakeFinish);
+ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
{
var content = TakeFinish(task.CurrentAddress);
- if (!content.Status) throw new Exception(content.Message);
- task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
- var up = _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
- _taskService.TaskCompleted(task.TaskNum);
- agvResponseContent.Code = up ? "0" : "1";
- agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
- return agvResponseContent;
- }
- break;
- case "getSafetySignal"://瀹夊叏淇″彿鐢宠
- {
- if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
+ if (!content.Status)
{
- var content = TakeRequest(task.CurrentAddress);
- //if (!content.Status) throw new Exception(content.Message);
- }
- else
- {
- var content = PutRequest(task.NextAddress, task.PalletType);
- //if (!content.Status) throw new Exception(content.Message);
- }
- task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
- var up = _taskRepository.UpdateData(task);
- agvResponseContent.Code = up ? "0" : "1";
- agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
- return agvResponseContent;
+ throw new Exception(content.Message);
+ };
}
- case "end"://鍏ュ簱鏍规嵁杩欎釜淇″彿鍒ゆ柇鏀捐揣瀹屾垚
- if (task.TaskType != TaskTypeEnum.Outbound.ObjToInt())
+ else
{
- var content = PutFinish(task.NextAddress);
- if (!content.Status) throw new Exception(content.Message);
- Dt_StationManger dt_Station = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == task.NextAddress);
+ if (task.TaskType == TaskTypeEnum.PrintYLInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintYLBackInbound.ObjToInt())
+ {
+ var content = TakeFinish(task.CurrentAddress);
+ if (!content.Status)
+ {
+ throw new Exception(content.Message);
+ };
+ }
+ }
+ return agvResponse.OK("鎴愬姛", "0");
+ case "2"://鍏ュ簱鏍规嵁杩欎釜淇″彿鍒ゆ柇鏀捐揣瀹屾垚
+ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
+ {
+ Dt_StationManger dt_Station = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress);
if (dt_Station == null)
{
throw new Exception($"{task.NextAddress}AGV绔欏彴鏈畾涔�");
}
- task.CurrentAddress = dt_Station.StationCode;
- task.NextAddress = "";
- task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
- task.DeviceCode = "SC01_CSJ";
- var up = _taskRepository.UpdateData(task);
- agvResponseContent.Code = up ? "0" : "1";
- agvResponseContent.Message = up ? "鎴愬姛" : "澶辫触";
- return agvResponseContent;
+ if (task.TaskType == TaskTypeEnum.PrintYLInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintYLBackInbound.ObjToInt())
+ {
+ List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == task.TaskType && task.NextAddress == x.StartPosi);
+ Dt_Router router = routers.FirstOrDefault();
+ if (router == null)
+ {
+ throw new Exception($"浠诲姟鍙�:{task.TaskNum}鏈壘鍒拌矾鐢遍厤缃俊鎭�");
+ }
+ string oldAddress = task.NextAddress;
+ //鏇存柊浠诲姟鐘舵��
+ task.CurrentAddress = router.NextPosi;
+ task.NextAddress = "";
+ task.DeviceCode = router.ChildPosiDeviceCode;
+ _taskService.UpdateTask(task, TaskStatusEnum.AGV_Finish);
+ PutFinish(oldAddress, task.TaskNum);
+ }
+ else
+ {
+ task.CurrentAddress = dt_Station.StationCode;
+ task.NextAddress = "";
+ task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
+ task.DeviceCode = dt_Station.StationDeviceCode;
+ _taskRepository.UpdateData(task);
+ }
+ return agvResponse.OK("鎴愬姛","0");
}
- break;
- case "cancel":
- task.TaskState = TaskStatusEnum.Cancel.ObjToInt();
- _taskRepository.UpdateData(task);
- break;
+ else
+ {
+ _taskService.TaskCompleted(task.TaskNum);
+ if (task.TaskType==TaskTypeEnum.PrintYLOutbound.ObjToInt() || task.TaskType == TaskTypeEnum.OutCarton.ObjToInt())
+ {
+ PutFinish(task.NextAddress);
+ }
+ return agvResponse.OK("鎴愬姛", "0");
+ }
default:
- throw new Exception($"鏈畾涔夋柟娉曞悕銆恵agvUpdateModel.Method}銆�");
+ throw new Exception($"鏈畾涔夋柟娉曞悕銆恵agvUpdateModel.TaskState}銆�");
}
- agvResponseContent.Code = "0";
- agvResponseContent.Message = "鎴愬姛";
}
catch (Exception ex)
{
- agvResponseContent.Code = "1";
- agvResponseContent.Message = ex.Message;
+ agvResponse.Error(ex.Message);
}
- return agvResponseContent;
- //return _taskService.AgvUpdateTask(agvUpdateModel);
+ return agvResponse;
}
/// <summary>
@@ -285,47 +312,140 @@
/// <param name="palletType"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("PutRequest"), AllowAnonymous]
- public WebResponseContent PutRequest(string code, int palletType)
+ public WebResponseContent PutRequest(string code, int taskNum)
{
+ WebResponseContent content = new WebResponseContent();
try
{
- Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code);
+ Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == code);
if (stationManger == null)
{
- return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃�");
+ return content.Error($"鏈壘鍒扮珯鍙伴厤缃�");
}
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
- if (device == null)
+ #region todo:涓存椂閫昏緫
+ if (stationManger.StationDeviceCode=="MES")
{
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶�");
- }
-
- OtherDevice otherDevice = (OtherDevice)device;
-
- bool canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode);
- if (canPut)
- {
- otherDevice.SetValue(GroundStationDBName.W_PutRequest, true, stationManger.StationCode);
- return WebResponseContent.Instance.OK();
- }
- else
- {
- otherDevice.SetValue(GroundStationDBName.W_PutRequest, true, stationManger.StationCode);
- Thread.Sleep(1000);
- canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode);
- if (canPut)
+
+ RequestAGVArriveDTO requestAGVArriveDTO =new RequestAGVArriveDTO()
{
- return WebResponseContent.Instance.OK();
+ SD_WorkCentreAgvArriveNoticeInfo=new List<AgvArriveNotice> { new AgvArriveNotice()
+ {
+ DispatchPlanMaterialId=409,
+ WorkCentreCode="66",
+ LocationCode="3-ZD-ZJZZ",
+ CallId="4534c242-27a7-4fb6-86f5-460b09db303d"
+ } }
+ };
+ WebResponseContent webResponse= _taskService.MESAvgArriveNotice(requestAGVArriveDTO);
+ if (webResponse.Message.Contains("\"obj\": true"))
+ {
+ return content.Error($"鍏佽鍙栨枡");
}
else
{
- return WebResponseContent.Instance.Error($"鏀捐揣鐢宠涓�");
+ return content.Error($"绂佹鏀炬枡");
+ }
+
+ }
+ #endregion
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
+ if (device == null)
+ {
+ return content.Error($"鏈壘鍒板搴旇澶�");
+ }
+ if (device.DeviceCode.Contains("Plate"))
+ {
+ CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+ StackPlateTaskCommandCommand command = commonConveyorLine.ReadCustomer<StackPlateTaskCommandCommand>(device.DeviceCode);
+
+ if (command != null && command.State == 2 && command.InteractiveSignal == 1)
+ {
+ return content.OK("鍏佽鏀炬枡");
+ }
+ else
+ {
+ return content.Error("绂佹鏀炬枡");
}
}
+ else
+ {
+
+ OtherDevice otherDevice = (OtherDevice)device;
+
+ if (device.DeviceCode.Contains("CP"))//鎴愬搧杈撻�佺嚎
+ {
+ short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
+ if (Command == 3)
+ {
+ content.OK("鍏佽鏀炬枡");
+ }
+ else
+ {
+ return content.Error("绂佹鏀炬枡");
+ }
+ }
+ else if (device.DeviceCode.Contains("Coveryor"))//鎺ラ┏鍙�
+ {
+ bool RequestPut = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_RequestPut, stationManger.StationDeviceCode);
+ if (!RequestPut)
+ {
+ otherDevice.SetValue(CoveryorDB.C_InTaskNum, taskNum, stationManger.StationDeviceCode);
+ otherDevice.SetValue(CoveryorDB.C_RequestPut, true, stationManger.StationDeviceCode);
+ Thread.Sleep(1000);
+ }
+ bool AllowFinish = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_AllowFinish, stationManger.StationDeviceCode);
+ if (AllowFinish)
+ {
+ content.OK("鍏佽鏀炬枡");
+ }
+ else
+ {
+ return content.Error("绂佹鏀炬枡");
+ }
+ }
+ else if (device.DeviceCode.Contains("Retract"))//浼哥缉璐у弶
+ {
+ bool RequestPut = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_RequestPut, stationManger.StationDeviceCode);
+ if (!RequestPut)
+ {
+ otherDevice.SetValue(RetractDB.Ret_TargetAddress, Convert.ToInt16(stationManger.StationCode), stationManger.StationDeviceCode);
+ otherDevice.SetValue(RetractDB.Ret_RequestPut, true, stationManger.StationDeviceCode);
+ Thread.Sleep(1000);
+ }
+ bool AllowFinish = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_AllowFinish, stationManger.StationDeviceCode);
+ if (AllowFinish)
+ {
+ content.OK("鍏佽鏀炬枡");
+ }
+ else
+ {
+ return content.Error("绂佹鏀炬枡");
+ }
+ }
+ else if (device.DeviceCode.Contains("TrussCarton"))//妗佹灦
+ {
+ bool RequestPut = otherDevice.GetValue<W_TrussCartonDB, bool>(GetCartonRequest(stationManger.StackerCraneStationCode), stationManger.StationDeviceCode);
+ if (!RequestPut)
+ {
+ otherDevice.SetValue(GetCartonRequest(stationManger.StackerCraneStationCode), true, stationManger.StationDeviceCode);
+ Thread.Sleep(1000);
+ }
+ bool AllowFinish = otherDevice.GetValue<R_TrussCartonDB, bool>(GetCarton(stationManger.StackerCraneStationCode), stationManger.StationDeviceCode);
+ if (AllowFinish)
+ {
+ content.OK("鍏佽鏀炬枡");
+ }
+ else
+ {
+ return content.Error("绂佹鏀炬枡");
+ }
+ }
+ }
+ return content;
}
catch (Exception ex)
{
- return WebResponseContent.Instance.Error(ex.Message);
+ return content.Error(ex.Message);
}
}
@@ -336,11 +456,11 @@
/// <param name="code"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("PutFinish"), AllowAnonymous]
- public WebResponseContent PutFinish(string code)
+ public WebResponseContent PutFinish(string code,int taskNum=0)
{
try
{
- Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code);
+ Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == code);
if (stationManger == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃�");
@@ -350,14 +470,103 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶�");
}
-
- OtherDevice otherDevice = (OtherDevice)device;
- otherDevice.SetValue(GroundStationDBName.W_PutFinish, true, stationManger.StationCode);
+ if (device.DeviceCode.Contains("Plate"))
+ {
+ CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+ commonConveyorLine.SetValue(StackPlateDBName.WriteInteractiveSignal, Convert.ToInt16(1), device.DeviceCode);
+ return WebResponseContent.Instance.OK();
+ }
+ else
+ {
+ OtherDevice otherDevice = (OtherDevice)device;
+ if (device.DeviceCode.Contains("Coveryor"))//鎺ラ┏鍙�
+ {
+ otherDevice.SetValue(CoveryorDB.C_PutFinish, true, stationManger.StationDeviceCode);
+ }
+ else if (device.DeviceCode.Contains("Retract"))//浼哥缉璐у弶
+ {
+ otherDevice.SetValue(RetractDB.Ret_PutFinish, true, stationManger.StationDeviceCode);
+ }
+ else if (device.DeviceCode.Contains("TrussCarton"))//绾哥妗佹灦
+ {
+ otherDevice.SetValue(GetCartonPut(stationManger.StackerCraneStationCode), true, stationManger.StationDeviceCode);
+ }
+ }
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
{
return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+ /// <summary>
+ /// 鑾峰彇妗佹灦鏀炬枡淇″彿
+ /// </summary>
+ public W_TrussCartonDB GetCartonPut(string StationCode)
+ {
+ switch (StationCode)
+ {
+ case "1":
+ return W_TrussCartonDB.W_CartonPut1;
+ case "2":
+ return W_TrussCartonDB.W_CartonPut2;
+ case "3":
+ return W_TrussCartonDB.W_CartonPut3;
+ case "4":
+ return W_TrussCartonDB.W_CartonPut4;
+ case "5":
+ return W_TrussCartonDB.W_CartonPut5;
+ case "6":
+ return W_TrussCartonDB.W_CartonPut6;
+ default:
+ throw new Exception("鏈畾涔夊伐浣�");
+ }
+ }
+ /// <summary>
+ /// 鑾峰彇妗佹灦璇锋眰淇″彿
+ /// </summary>
+ public W_TrussCartonDB GetCartonRequest(string StationCode)
+ {
+ switch (StationCode)
+ {
+ case "1":
+ return W_TrussCartonDB.W_CartonRequest1;
+ case "2":
+ return W_TrussCartonDB.W_CartonRequest2;
+ case "3":
+ return W_TrussCartonDB.W_CartonRequest3;
+ case "4":
+ return W_TrussCartonDB.W_CartonRequest4;
+ case "5":
+ return W_TrussCartonDB.W_CartonRequest5;
+ case "6":
+ return W_TrussCartonDB.W_CartonRequest6;
+ default:
+ throw new Exception("鏈畾涔夊伐浣�");
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇妗佹灦杩涘叆淇″彿
+ /// </summary>
+ public R_TrussCartonDB GetCarton(string StationCode)
+ {
+ switch (StationCode)
+ {
+ case "1":
+ return R_TrussCartonDB.R_CartonAllow1;
+ case "2":
+ return R_TrussCartonDB.R_CartonAllow2;
+ case "3":
+ return R_TrussCartonDB.R_CartonAllow3;
+ case "4":
+ return R_TrussCartonDB.R_CartonAllow4;
+ case "5":
+ return R_TrussCartonDB.R_CartonAllow5;
+ case "6":
+ return R_TrussCartonDB.R_CartonAllow6;
+ default:
+ throw new Exception("鏈畾涔夊伐浣�");
}
}
@@ -370,49 +579,82 @@
[HttpPost, HttpGet, Route("TakeRequest"), AllowAnonymous]
public WebResponseContent TakeRequest(string code)
{
+ WebResponseContent content = new WebResponseContent();
try
{
Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code);
if (stationManger == null)
{
- return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃�");
+ return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃畕code}");
}
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
if (device == null)
{
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶�");
+ return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶噞stationManger.StationDeviceCode}");
}
-
- OtherDevice otherDevice = (OtherDevice)device;
-
- bool canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, stationManger.StationCode);
- if (canPut)
+ if (device.DeviceCode.Contains("Plate"))
{
- otherDevice.SetValue(GroundStationDBName.W_TakeRequest, true, stationManger.StationCode);
- return WebResponseContent.Instance.OK();
- }
- else
- {
- otherDevice.SetValue(GroundStationDBName.W_TakeRequest, true, stationManger.StationCode);
- Thread.Sleep(1000);
- canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, stationManger.StationCode);
- if (canPut)
+ CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+ StackPlateTaskCommandCommand command = commonConveyorLine.ReadCustomer<StackPlateTaskCommandCommand>(device.DeviceCode);
+
+ if (command != null&&command.State == 2 && command.InteractiveSignal == 2)
{
- return WebResponseContent.Instance.OK();
+ return content.OK("鍏佽鍙栨枡");
}
else
{
- return WebResponseContent.Instance.Error($"鍙栬揣鐢宠涓�");
+ return content.Error("绂佹鍙栨枡");
}
}
+ else
+ {
+ OtherDevice otherDevice = (OtherDevice)device;
+
+ if (otherDevice.DeviceCode.Contains("CP"))//鎴愬搧杈撻�佺嚎
+ {
+ short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
+ if (Command == 2)
+ {
+ content.OK("鍏佽鍙栨枡");
+ }
+ else
+ {
+ return content.Error("绂佹鍙栨枡");
+ }
+ }
+ else if (device.DeviceCode.Contains("Coveryor"))//鎺ラ┏鍙�
+ {
+ bool AllowTake = otherDevice.GetValue<CoveryorDB, bool>(CoveryorDB.C_AllowTake, stationManger.StationDeviceCode);
+ if (AllowTake)
+ {
+ content.OK("鍏佽鍙栨枡");
+ }
+ else
+ {
+ return content.Error("绂佹鍙栨枡");
+ }
+ }
+ else if (device.DeviceCode.Contains("Retract"))//浼哥缉璐у弶
+ {
+ bool AllowTake = otherDevice.GetValue<RetractDB, bool>(RetractDB.Ret_AllowTake, stationManger.StationDeviceCode);
+ if (AllowTake)
+ {
+ content.OK("鍏佽鍙栨枡");
+ }
+ else
+ {
+ return content.Error("绂佹鍙栨枡");
+ }
+ }
+ }
+ return content;
}
catch (Exception ex)
{
- return WebResponseContent.Instance.Error(ex.Message);
+ return content.Error(ex.Message);
}
}
- //[HttpPost, HttpGet, Route("TakeFinish"), AllowAnonymous]
/// <summary>
/// 鍙栬揣瀹屾垚
/// </summary>
@@ -423,7 +665,7 @@
{
try
{
- Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == code);
+ Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == code);
if (stationManger == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃�");
@@ -433,11 +675,29 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶�");
}
+ if (device.DeviceCode.Contains("Plate"))
+ {
+ CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+ commonConveyorLine.SetValue(StackPlateDBName.WriteInteractiveSignal, Convert.ToInt16(2), device.DeviceCode);
+ return WebResponseContent.Instance.OK();
+ }
+ else
+ {
+ OtherDevice otherDevice = (OtherDevice)device;
+ if (device.DeviceCode.Contains("CP"))
+ {
+ otherDevice.SetValue(W_ConveyorLineCPDB.W_Command, 2, stationManger.StationCode);
+ }
+ else if (device.DeviceCode.Contains("Coveryor"))
+ {
+ otherDevice.SetValue(CoveryorDB.C_TakeFinish, true, stationManger.StationDeviceCode);
+ }
+ else if (device.DeviceCode.Contains("Retract"))//浼哥缉璐у弶
+ {
+ otherDevice.SetValue(RetractDB.Ret_TakeFinish, true, stationManger.StationDeviceCode);
+ }
+ }
- OtherDevice otherDevice = (OtherDevice)device;
- otherDevice.SetValue(GroundStationDBName.W_TakeFinish, true, stationManger.StationCode);
- Thread.Sleep(1000);
- otherDevice.SetValue(GroundStationDBName.W_TakeFinish, false, stationManger.StationCode);
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
--
Gitblit v1.9.3