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 | 366 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 266 insertions(+), 100 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 bd06e10..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;
@@ -20,6 +21,7 @@
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
@@ -68,7 +70,7 @@
}
else//鍑哄簱鏀捐揣璇锋眰
{
- var content = PutRequest(secureApplyModel.WbCode, task.PalletType);
+ var content = PutRequest(task.NextAddress, task.PalletType);
if (!content.Status)
{
throw new Exception(content.Message);
@@ -87,7 +89,7 @@
}
else//鍏ュ簱鏀捐揣璇锋眰
{
- var content = PutRequest(secureApplyModel.WbCode, task.TaskNum);
+ var content = PutRequest(task.NextAddress, task.TaskNum);
if (!content.Status)
{
throw new Exception(content.Message);
@@ -239,7 +241,7 @@
}
else
{
- if (task.TaskType == TaskTypeEnum.PrintInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintBackInbound.ObjToInt())
+ if (task.TaskType == TaskTypeEnum.PrintYLInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintYLBackInbound.ObjToInt())
{
var content = TakeFinish(task.CurrentAddress);
if (!content.Status)
@@ -257,7 +259,7 @@
{
throw new Exception($"{task.NextAddress}AGV绔欏彴鏈畾涔�");
}
- if (task.TaskType == TaskTypeEnum.PrintInbound.ObjToInt() || task.TaskType == TaskTypeEnum.PrintBackInbound.ObjToInt())
+ 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();
@@ -286,7 +288,7 @@
else
{
_taskService.TaskCompleted(task.TaskNum);
- if (task.TaskType==TaskTypeEnum.PrintOutbound.ObjToInt())
+ if (task.TaskType==TaskTypeEnum.PrintYLOutbound.ObjToInt() || task.TaskType == TaskTypeEnum.OutCarton.ObjToInt())
{
PutFinish(task.NextAddress);
}
@@ -315,70 +317,130 @@
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 content.Error($"鏈壘鍒扮珯鍙伴厤缃�");
}
+ #region todo:涓存椂閫昏緫
+ if (stationManger.StationDeviceCode=="MES")
+ {
+
+ RequestAGVArriveDTO requestAGVArriveDTO =new RequestAGVArriveDTO()
+ {
+ 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 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);
- OtherDevice otherDevice = (OtherDevice)device;
+ if (command != null && command.State == 2 && command.InteractiveSignal == 1)
+ {
+ return content.OK("鍏佽鏀炬枡");
+ }
+ else
+ {
+ return content.Error("绂佹鏀炬枡");
+ }
+ }
+ else
+ {
- if (device.DeviceCode.Contains("CP"))//鎴愬搧杈撻�佺嚎
- {
- short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
- if (Command == 3)
+ OtherDevice otherDevice = (OtherDevice)device;
+
+ if (device.DeviceCode.Contains("CP"))//鎴愬搧杈撻�佺嚎
{
- content.OK("鍏佽鏀炬枡");
+ short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
+ if (Command == 3)
+ {
+ content.OK("鍏佽鏀炬枡");
+ }
+ else
+ {
+ return content.Error("绂佹鏀炬枡");
+ }
}
- else
+ else if (device.DeviceCode.Contains("Coveryor"))//鎺ラ┏鍙�
{
- return content.Error("绂佹鏀炬枡");
+ 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("绂佹鏀炬枡");
+ }
}
}
- 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("绂佹鏀炬枡");
- }
- }
-
return content;
}
catch (Exception ex)
@@ -408,21 +470,103 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶�");
}
-
- OtherDevice otherDevice = (OtherDevice)device;
- if (device.DeviceCode.Contains("Coveryor"))//鎺ラ┏鍙�
+ if (device.DeviceCode.Contains("Plate"))
{
- otherDevice.SetValue(CoveryorDB.C_PutFinish, true, stationManger.StationDeviceCode);
+ CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+ commonConveyorLine.SetValue(StackPlateDBName.WriteInteractiveSignal, Convert.ToInt16(1), device.DeviceCode);
+ return WebResponseContent.Instance.OK();
}
- else if (device.DeviceCode.Contains("Retract"))//浼哥缉璐у弶
+ else
{
- otherDevice.SetValue(RetractDB.Ret_PutFinish, true, stationManger.StationDeviceCode);
+ 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("鏈畾涔夊伐浣�");
}
}
@@ -448,46 +592,61 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶噞stationManger.StationDeviceCode}");
}
-
- OtherDevice otherDevice = (OtherDevice)device;
-
- if (otherDevice.DeviceCode.Contains("CP"))//鎴愬搧杈撻�佺嚎
+ if (device.DeviceCode.Contains("Plate"))
{
- short Command = otherDevice.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
- if (Command == 2)
+ CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+ StackPlateTaskCommandCommand command = commonConveyorLine.ReadCustomer<StackPlateTaskCommandCommand>(device.DeviceCode);
+
+ if (command != null&&command.State == 2 && command.InteractiveSignal == 2)
{
- content.OK("鍏佽鍙栨枡");
+ return content.OK("鍏佽鍙栨枡");
}
else
{
return content.Error("绂佹鍙栨枡");
}
}
- else if (device.DeviceCode.Contains("Coveryor"))//鎺ラ┏鍙�
+ else
{
- 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("绂佹鍙栨枡");
- }
- }
+ 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)
@@ -496,7 +655,6 @@
}
}
- //[HttpPost, HttpGet, Route("TakeFinish"), AllowAnonymous]
/// <summary>
/// 鍙栬揣瀹屾垚
/// </summary>
@@ -517,19 +675,27 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶�");
}
-
- OtherDevice otherDevice = (OtherDevice)device;
- if (device.DeviceCode.Contains("CP"))
+ if (device.DeviceCode.Contains("Plate"))
{
- otherDevice.SetValue(W_ConveyorLineCPDB.W_Command, 2, stationManger.StationCode);
+ CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+ commonConveyorLine.SetValue(StackPlateDBName.WriteInteractiveSignal, Convert.ToInt16(2), device.DeviceCode);
+ return WebResponseContent.Instance.OK();
}
- else if (device.DeviceCode.Contains("Coveryor"))
+ else
{
- 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;
+ 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);
+ }
}
return WebResponseContent.Instance.OK();
--
Gitblit v1.9.3