From 6d3ea08855337c0cfcc60df2903d3431611c7097 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期六, 13 十二月 2025 17:36:56 +0800
Subject: [PATCH] 优化程序,输送线入库按钮对接
---
项目代码/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs | 97 ++++++++++++++++++++++++++++++++----------------
1 files changed, 64 insertions(+), 33 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..f34f16d 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"
@@ -56,6 +56,7 @@
{
return Service.RollbackTaskStatusToLast(taskNum);
}
+ private static object lock_containerFlow = new object();
/// <summary>
/// 瀹瑰櫒娴佸姩鎺ュ彛
/// </summary>
@@ -63,47 +64,77 @@
[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);
+ }
+ 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")
+ {
+ WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode, stationManger.PickStationCode);
+ if (!responseContent.Status) throw new Exception(responseContent.Message);
+ }
+ 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>
/// 鐢宠鍏ュ簱
--
Gitblit v1.9.3