From 4f3b0a6727ecfa555892ebea64bd76e5a07cd6fb Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期二, 17 三月 2026 10:01:38 +0800
Subject: [PATCH] feat: 新增WMS异常上报自动恢复异常按钮
---
项目代码/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs | 152 ++++++++++++++++++++++++++++++++++++++------------
1 files changed, 114 insertions(+), 38 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs"
index 470221f..f6bcbfc 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs"
@@ -2,7 +2,9 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
+using System.IO;
using System.Text;
+using WIDESEA_External.Model;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseController;
@@ -12,6 +14,7 @@
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_TaskInfoService;
using WIDESEAWCS_Tasks;
using WIDESEAWCS_Tasks.DBNames;
@@ -33,7 +36,7 @@
}
[HttpPost, Route("ReceiveTask"), AllowAnonymous]
- public WebResponseContent ReceiveWMSTask([FromBody] WMSTaskDTO taskDTO)
+ public WMSReceiveTaskContent ReceiveWMSTask([FromBody] WMSTaskDTO taskDTO)
{
return Service.ReceiveWMSTask(taskDTO);
}
@@ -56,6 +59,7 @@
{
return Service.RollbackTaskStatusToLast(taskNum);
}
+ private static object lock_containerFlow = new object();
/// <summary>
/// 瀹瑰櫒娴佸姩鎺ュ彛
/// </summary>
@@ -63,47 +67,90 @@
[HttpPost, HttpGet, Route("ContainerFlow"), AllowAnonymous]
public WebResponseContent ContainerFlow([FromBody] ContainerFlowDTO containerFlowDTO)
{
- WebResponseContent content = new WebResponseContent();
- try
+ lock (lock_containerFlow)
{
- Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x=>x.PickStationCode==containerFlowDTO.SlotCode) ?? throw new Exception($"{containerFlowDTO.SlotCode}鎷i�変綅缃笉瀛樺湪");
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
- if (device == null)
+ WebResponseContent content = new WebResponseContent();
+ try
{
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶噞stationManger.StationDeviceCode}");
- }
- if (stationManger.StationDeviceCode== "CL1" || stationManger.StationDeviceCode == "CL2")
- {
- OtherDevice commonConveyorLine = (OtherDevice)device;
- byte[] bytesPick = commonConveyorLine.Communicator.Read("2", 5);
- string PickBarCode = Encoding.UTF8.GetString(bytesPick).Replace("\0", "").Replace("\\0", "");
- if (containerFlowDTO.ContainerCode != PickBarCode) throw new Exception($"浼犲叆鏂欑鐮亄containerFlowDTO.ContainerCode}锛岃緭閫佹枡绠辩爜{PickBarCode}鏁版嵁閿欒");
- if (containerFlowDTO.Direction == "100")
+ Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.PickStationCode == containerFlowDTO.SlotCode) ?? throw new Exception($"{containerFlowDTO.SlotCode}鎷i�変綅缃笉瀛樺湪");
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
+ if (device == null)
{
- WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode);
- if (!responseContent.Status) throw new Exception(responseContent.Message);
+ return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇澶噞stationManger.StationDeviceCode}");
}
- commonConveyorLine.Communicator.Write("22", (short)(containerFlowDTO.Direction == "100" ? 256 : 512));
- }
- else
- {
- CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
- string PickBarCode = commonConveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.R_PickBarCode, stationManger.StationCode).Trim();
- if (containerFlowDTO.ContainerCode != PickBarCode) throw new Exception($"浼犲叆鏂欑鐮亄containerFlowDTO.ContainerCode}锛岃緭閫佹枡绠辩爜{PickBarCode}鏁版嵁閿欒");
- if (containerFlowDTO.Direction == "100")
+ if (stationManger.StationDeviceCode == "CL1" || stationManger.StationDeviceCode == "CL2")
{
- WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode);
- if (!responseContent.Status) throw new Exception(responseContent.Message);
+ OtherDevice commonConveyorLine = (OtherDevice)device;
+ byte[] bytesPick = commonConveyorLine.Communicator.Read("2", 5);
+ string PickBarCode = Encoding.UTF8.GetString(bytesPick).Replace("\0", "").Replace("\\0", "");
+ if (containerFlowDTO.ContainerCode != PickBarCode) throw new Exception($"浼犲叆鏂欑鐮亄containerFlowDTO.ContainerCode}锛岃緭閫佹枡绠辩爜{PickBarCode}鏁版嵁閿欒");
+ //if (containerFlowDTO.Direction == "100")
+ //{
+ // WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode, stationManger.PickStationCode);
+ // if (!responseContent.Status) throw new Exception(responseContent.Message);
+ //}
+ WriteLog.Write_Log("涓�鏈熷鍣ㄦ祦鍔ㄥ叆搴撴帴鍙�", "浠诲姟淇℃伅", $"杩斿洖杈撻�佺嚎{stationManger.PickStationCode}", $"杩斿洖缁欒緭閫佺嚎鐨勪换鍔′俊鎭細{containerFlowDTO.ToJson()}");
+ commonConveyorLine.Communicator.Write("22", (containerFlowDTO.Direction == "100" ? new byte[] { 1, 0 } : new byte[] { 2, 0 }));
}
- commonConveyorLine.SetValue(ConveyorLineDBName.W_PickToHode, (short)containerFlowDTO.Direction.ObjToInt(), stationManger.StationCode);
+ else
+ {
+
+ CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
+ string PickBarCode = commonConveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.R_PickBarCode, stationManger.StationCode).Trim();
+
+ if (containerFlowDTO.ContainerCode != PickBarCode) throw new Exception($"浼犲叆鏂欑鐮亄containerFlowDTO.ContainerCode}锛岃緭閫佹枡绠辩爜{PickBarCode}鏁版嵁閿欒");
+
+ if (containerFlowDTO.Direction == "100")
+ {
+ short W_PickToHode = commonConveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.W_PickToHode, stationManger.StationCode);
+ if (W_PickToHode == 300)
+ {
+ WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode, stationManger.PickStationCode);
+ if (!responseContent.Status) throw new Exception(responseContent.Message);
+ }
+ else
+ {
+ throw new Exception($"浼犲叆鏂欑鐮亄containerFlowDTO.ContainerCode}锛岃緭閫佹枡鐘舵�侊細{W_PickToHode}锛屼笉婊¤冻鍏ュ簱鏉′欢");
+ }
+ }
+ WriteLog.Write_Log("浜屾湡瀹瑰櫒娴佸姩鍏ュ簱鎺ュ彛", "浠诲姟淇℃伅", $"杩斿洖杈撻�佺嚎{stationManger.PickStationCode}", $"杩斿洖缁欒緭閫佺嚎鐨勪换鍔′俊鎭細{containerFlowDTO.ToJson()}");
+ commonConveyorLine.SetValue(ConveyorLineDBName.W_PickToHode, (short)containerFlowDTO.Direction.ObjToInt(), stationManger.StationCode);
+ }
+ content.OK();
}
- content.OK();
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
}
- catch (Exception ex)
- {
- content.Error(ex.Message);
- }
- return content;
+ }
+ /// <summary>
+ /// 鎾澧欏垵濮嬪寲
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost, HttpGet, Route("InitLight"), AllowAnonymous]
+ public WebResponseContent InitLight()
+ {
+ return Service.InitLight();
+ }
+ /// <summary>
+ /// 鎾澧欑粨鏉熶綔涓�
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost, HttpGet, Route("EndLight"), AllowAnonymous]
+ public WebResponseContent EndLight()
+ {
+ return Service.EndLight();
+ }
+ /// <summary>
+ /// 鎾澧欎寒鐏�
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost, HttpGet, Route("SendLight"), AllowAnonymous]
+ public WebResponseContent SendLight([FromBody] TaskSendLight taskSendLight)
+ {
+ return Service.SendLight(taskSendLight);
}
/// <summary>
/// 鐢宠鍏ュ簱
@@ -129,16 +176,45 @@
{
return Service.TaskCompleted(taskNum);
}
+ /// <summary>
+ /// 浜哄伐鎵嬪姩鍙栨秷鎸囧畾浠诲姟
+ /// </summary>
+ /// <param name="taskNum">浠诲姟缂栧彿</param>
+ /// <returns>鎿嶄綔缁撴灉</returns>
+ [HttpPost, HttpGet, Route("ManualTaskCancellation"), AllowAnonymous]
+ public WebResponseContent ManualTaskCancellation(int taskNum)
+ {
+ return Service.ManualTaskCancellation(taskNum);
+ }
+ /// WMS浠诲姟鍙栨秷鍚屾
+ /// </summary>
+ /// <param name="taskCancels"></param>
+ /// <returns></returns>
+ [HttpPost, HttpGet, Route("CancelTask"), AllowAnonymous]
+ public WebResponseContent CancelTask([FromBody] List<TaskCancel> taskCancels)
+ {
+ return Service.TaskCancel(taskCancels); ;
+ }
/// <summary>
- /// WMS浠诲姟鍙栨秷鍚屾
+ /// 鎶婁换鍔″紓甯�900淇敼涓篈GV鎵ц涓�300
/// </summary>
/// <param name="taskNum"></param>
/// <returns></returns>
- [HttpPost, HttpGet, Route("CancelTask"), AllowAnonymous]
- public WebResponseContent CancelTask(List<TaskCancel> taskCancels)
+ [HttpPost, HttpGet, Route("ResetAllExceptionTask"), AllowAnonymous]
+ public WebResponseContent ResetAllExceptionTask(int taskNum)
{
- return WebResponseContent.Instance.Error();
+ return Service.ResetAllExceptionTask(taskNum);
+ }
+
+ /// <summary>
+ /// WMS寮傚父鎭㈠
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost, HttpGet, Route("WmsRecovery"), AllowAnonymous]
+ public WebResponseContent WmsRecovery()
+ {
+ return Service.WmsRecovery();
}
}
}
--
Gitblit v1.9.3