From 1e12c140c041c0cb52306a0db9ff0ba18354d0d8 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 03 四月 2025 18:01:52 +0800
Subject: [PATCH] 优化WMS前端首页,货位查询column数据库关键字处理
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs | 264 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 264 insertions(+), 0 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs"
index b0b79d7..bdba05a 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs"
@@ -10,11 +10,269 @@
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_Core;
+using Newtonsoft.Json;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO.WMSInfo;
+using WIDESEAWCS_Tasks.ShuttleCarJob;
namespace WIDESEAWCS_Tasks
{
partial class CommonShuttleCarJob
{
+ private object _CarTaskObject = new object();
+ #region 鍫嗗灈鏈虹Щ杞﹀畬鎴�
+ /// <summary>
+ /// 鑾峰彇鍫嗗灈鏈虹Щ杞�/绉诲簱瀹屾垚浠诲姟
+ /// </summary>
+ public void GetSC_CarFinish()
+ {
+ Dt_Task dt_Task = GetTask(TaskCarStatusEnum.SC_CarFinish.ObjToInt(), TaskOtherTypeEnum.RelocationCar.ObjToInt());//绉昏溅浠诲姟
+ if (dt_Task != null)
+ {
+ UpdateShuttleCar(dt_Task.ShuttleCarCode, dt_Task.CurrentAddress);
+ _taskService.AddTask_Hty(dt_Task, TaskOperateTypeEnum.AutoComplete);
+ }
+ dt_Task = GetTask(CarChargingTaskEnum.SC_CarFinish.ObjToInt(), TaskOtherTypeEnum.RelocationCarCharging.ObjToInt());//绉昏溅鍏呯數浠诲姟
+ if (dt_Task != null)
+ {
+ UpdateShuttleCar(dt_Task.ShuttleCarCode, dt_Task.CurrentAddress);
+ SendTask(dt_Task);//涓嬪彂鍏呯數浠诲姟
+ }
+ dt_Task = GetTask(TaskRelocationStatusEnum.SC_RelocationFinish.ObjToInt(), TaskRelocationTypeEnum.Relocation.ObjToInt());//绉诲簱浠诲姟
+ if (dt_Task != null)
+ SendTask(dt_Task);
+ }
+ #endregion
+ /// <summary>
+ /// 淇敼绌挎杞︿綅缃俊鍙�
+ /// </summary>
+ /// <param name="ShuttleCarCode">绌挎杞﹀彿</param>
+ /// <param name="Address">浣嶇疆</param>
+ public void UpdateShuttleCar(string ShuttleCarCode, string Address)
+ {
+ var ShuttleCar = QueryCode(ShuttleCarCode);
+ string[] targetCodes = Address.Split("-");
+ var Row = Convert.ToInt16(targetCodes[0]);
+ if (Row == 3)
+ {
+ ShuttleCar.ShuttleCarPosition = Address;
+ ShuttleCar.ShuttleCarPosition1 = Address;
+ }
+ else
+ {
+ var a = Row == 1 ? 2.ToString("000") : 1.ToString("000");
+ ShuttleCar.ShuttleCarPosition = Address;
+ ShuttleCar.ShuttleCarPosition1 = a + "-" + targetCodes[1] + "-" + targetCodes[2];
+ }
+ _shuttleCarService.UpdateData(ShuttleCar);
+ }
+ #region 鑾峰彇绉昏溅浠诲姟
+ /// <summary>
+ /// 鑾峰彇绉昏溅浠诲姟/鍑哄叆搴撲换鍔�
+ /// </summary>
+ public void Get_CarTask(ShuttleCar shuttleCar, ShuttleCarTaskCommandR command)
+ {
+ lock (_CarTaskObject)
+ {
+ #region 鑾峰彇鏂板缓绉昏溅浠诲姟
+ Dt_Task dt_Task = GetTask((int)TaskCarStatusEnum.CarNew, (int)TaskOtherTypeEnum.RelocationCar);
+ if (dt_Task != null)
+ {
+ if (string.IsNullOrEmpty(dt_Task.SourceAddress))
+ {
+ (bool, Dt_ShuttleCar) result = GetSourceTask(shuttleCar, command);
+ if (result.Item1)
+ UpdateSource(ref dt_Task, result.Item2);
+ else
+ GetShuttleCar(ref dt_Task, shuttleCar);//鑾峰彇鍙﹀涓�涓┛姊溅淇℃伅
+ }
+ else if (string.IsNullOrEmpty(dt_Task.TargetAddress))
+ {
+ #region 鍚慦MS鐢宠
+ WebResponseContent content = new WebResponseContent();
+ var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.GetPosition + $"?position={dt_Task.SourceAddress}", "", headers: new Dictionary<string, string>());
+ if (ResultData.Result != null)
+ {
+ content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result);
+ if (content != null && content.Status)
+ {
+ dt_Task.TargetAddress = content.Message;
+ dt_Task.NextAddress = dt_Task.TargetAddress;
+ _taskService.UpdateData(dt_Task);
+ _taskExecuteDetailService.AddTaskExecuteDetail(dt_Task.TaskNum, "鏇存柊绉昏溅浠诲姟鐩爣鍦板潃");
+ }
+ }
+ #endregion
+ }
+ //绌挎杞︾Щ杞︿换鍔′笅鍙�
+ if (!string.IsNullOrEmpty(dt_Task.SourceAddress) && !string.IsNullOrEmpty(dt_Task.TargetAddress) && !string.IsNullOrEmpty(dt_Task.ShuttleCarCode))
+ {
+ SendTask(dt_Task);
+ }
+ }
+ #endregion
+
+ #region 绌挎杞︿换鍔�
+ else
+ {
+ var task = _taskService.ShuttleCarRelocationTask(shuttleCar.DeviceCode);//鑾峰彇绌挎杞︾Щ搴撲换鍔�
+ if (task != null)
+ {
+ if (!task.SourceIsPickPlace)
+ SendTask(task);
+ }
+ else
+ {
+ task = _taskService.QueryShuttleCarTask(shuttleCar.DeviceCode);
+ if (task != null)
+ {
+ if (_taskService.TaskOutboundTypes.Contains(task.TaskType) && !task.SourceIsPickPlace)
+ {
+ var ShuttleCar = _shuttleCarService.QueryShuttleCar(task.SourceAddress);//鍑哄簱浠诲姟鍒ゆ柇璧风偣鏄惁鏈夌┛姊溅
+ if (ShuttleCar == null) _taskService.AddRelocationCarTask("", task.SourceAddress);
+ else
+ {
+ task.ShuttleCarCode = ShuttleCar.ShuttleCarCode;
+ SendTask(task);
+ }
+ }
+ else
+ SendTask(task);
+ }
+ }
+ }
+ #endregion
+ }
+ }
+ #endregion
+
+ #region 鏇存柊绉昏溅浠诲姟璧峰鍦板潃
+ /// <summary>
+ /// 鏇存柊绉昏溅浠诲姟璧峰鍦板潃
+ /// </summary>
+ /// <param name="dt_Task"></param>
+ /// <param name="shuttleCar"></param>
+ /// <param name="command"></param>
+ public void UpdateSource(ref Dt_Task dt_Task, Dt_ShuttleCar _ShuttleCar)
+ {
+ dt_Task.SourceAddress = _ShuttleCar.ShuttleCarPosition;
+ dt_Task.CurrentAddress = dt_Task.SourceAddress;
+ dt_Task.ShuttleCarCode = _ShuttleCar.ShuttleCarCode;
+ _taskService.UpdateData(dt_Task);
+ _taskExecuteDetailService.AddTaskExecuteDetail(dt_Task.TaskNum, "鏇存柊绉昏溅浠诲姟璧峰鍦板潃");
+ }
+ #endregion
+ /// <summary>
+ /// 鍒ゆ柇褰撳墠绌挎杞︽槸鍚﹀彲浠ユ墽琛岀Щ搴�
+ /// </summary>
+ /// <param name="shuttleCar"></param>
+ /// <param name="command"></param>
+ /// <returns></returns>
+ public (bool, Dt_ShuttleCar) GetSourceTask(ShuttleCar shuttleCar, ShuttleCarTaskCommandR command)
+ {
+ Dt_ShuttleCar _ShuttleCar = QueryCode(shuttleCar.DeviceCode);
+ bool ok = false;
+ if (command.Status == (short)ShuttleCarStatus.Standby && command.TaskTypeComplete == (short)ShuttleCarTaskComplete.Standby && command.Err_Status == (short)ShuttleCarErr.Normal)
+ {
+ #region 鍒ゆ柇褰撳墠绌挎杞︽槸鍚﹀瓨鍦ㄤ换鍔�
+ Dt_Task? _Task = _taskRepository.QueryFirst(x =>
+ x.SourceAddress == _ShuttleCar.ShuttleCarPosition ||
+ x.TargetAddress == _ShuttleCar.ShuttleCarPosition ||
+ x.SourceAddress == _ShuttleCar.ShuttleCarPosition1 ||
+ x.TargetAddress == _ShuttleCar.ShuttleCarPosition1);
+ #endregion
+ ok = _Task == null;
+ }
+ if (!ok)
+ {
+ if (command.Status == (short)ShuttleCarStatus.Charging && command.ElectricQuantity >= 50)//閫�鍑哄厖鐢�
+ {
+ ok = shuttleCar.SetValue(ShuttleCarDBName.TaskType, (short)ShuttleCarStatus.QuitCharging);
+ }
+ }
+ return (ok, _ShuttleCar);
+ }
+
+ /// <summary>
+ /// 鑾峰彇鍙﹀涓�涓┛姊溅淇℃伅
+ /// </summary>
+ public void GetShuttleCar(ref Dt_Task dt_Task, ShuttleCar shuttleCar)
+ {
+ Dt_ShuttleCar _ShuttleCar = _shuttleCarService.QueryNoCode(shuttleCar.DeviceCode);
+ ShuttleCar shuttleCar1 = Storage.Devices.Where(x => x.DeviceCode.Equals(_ShuttleCar.ShuttleCarCode)).FirstOrDefault() as ShuttleCar;
+ ShuttleCarTaskCommandR command = ReadCustomer<ShuttleCarTaskCommandR>(shuttleCar1, shuttleCar1.DeviceCode);//璇诲彇绌挎杞︿俊鎭�
+ (bool, Dt_ShuttleCar) result = GetSourceTask(shuttleCar1, command);
+ if (result.Item1) UpdateSource(ref dt_Task, result.Item2);
+ }
+
+ #region 涓嬪彂绌挎杞︿换鍔�
+ /// <summary>
+ /// 涓嬪彂绌挎杞︿换鍔�
+ /// </summary>
+ /// <param name="task"></param>
+ private void SendTask(Dt_Task task)
+ {
+ ShuttleCar shuttleCar = Storage.Devices.FirstOrDefault(x => x.DeviceCode == task.ShuttleCarCode) as ShuttleCar;
+ if (shuttleCar != null)
+ {
+ ShuttleCarTaskCommandR command = ReadCustomer<ShuttleCarTaskCommandR>(shuttleCar, shuttleCar.DeviceCode);//璇诲彇绌挎杞︿俊鎭�
+ if (command != null && command.Status == (short)ShuttleCarStatus.Standby && command.TaskTypeComplete == (short)ShuttleCarTaskComplete.Standby && command.Err_Status == (short)ShuttleCarErr.Normal)
+ {
+ #region 鍒ゆ柇灏忚溅浣嶇疆鏃燗B闈笉涓嬪彂浠诲姟
+ short Position = 0;
+ if (shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.DirectionA)) Position = 1;
+ if (shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.DirectionB)) Position = 2;
+ if (Position != 1 && Position != 2)
+ {
+ var Message = $"{shuttleCar.DeviceName}鏃燗B闈�";
+ if (task.ExceptionMessage != Message)
+ _taskService.UpdateData(task);
+ return;
+ }
+ #endregion
+ //浠诲姟杞崲
+ shuttleCar.SetValue(ShuttleCarDBName.Direction, Position);//鍐欏叆杞︿綋鏂瑰悜
+ ShuttleCarTaskCommandW shuttleCarTaskCommand = new ShuttleCarTaskCommandW();
+ shuttleCarTaskCommand.Direction = Position;
+ shuttleCarTaskCommand.TaskNum = task.TaskNum;
+ if (task.TaskType == (int)TaskOtherTypeEnum.RelocationCar)//绉昏溅
+ {
+ if (task.TaskState == (int)TaskCarStatusEnum.CarNew)
+ {
+ //if (task.Remark == ShuttleCarTaskType.ExitCharge.ToString()) shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.Remark);
+ //else
+ shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction);
+ }
+ else if (task.TaskState == (int)TaskCarStatusEnum.SC_CarFinish)
+ {
+ if (task.Remark == ShuttleCarTaskType.Charging.ToString()) shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.Remark);
+ //else
+ // shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction);
+ }
+ }
+ else if (task.TaskType == (int)TaskOtherTypeEnum.RelocationCarCharging)
+ {
+ shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(ShuttleCarTaskType.Charging.ToString());
+ }
+ else
+ shuttleCarTaskCommand.TaskType = (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction);
+ //shuttleCarTaskCommand.TaskType = string.IsNullOrEmpty(task.Remark) ? (short)GetCarTaskType(task.TaskType, shuttleCarTaskCommand.Direction) : (short)GetCarTaskType(task.Remark);
+ //浠诲姟涓嬪彂
+ if (shuttleCarTaskCommand.TaskType != null)//0
+ {
+ if (shuttleCar.SendCommand(shuttleCarTaskCommand, shuttleCar.DeviceCode))
+ {
+ if (!string.IsNullOrEmpty(task.Remark)) task.Remark = task.Remark + "宸蹭笅鍙�";
+ task.TaskState = GetTaskState(task.TaskType);
+ _taskService.UpdateData(task);
+ }
+ }
+ }
+ }
+ }
+ #endregion
+
+
/// <summary>
/// 鏍规嵁浠诲姟鐘舵�併�佺被鍨嬭幏鍙栦换鍔�
/// </summary>
@@ -53,6 +311,7 @@
taskType = ShuttleCarTaskType.Out;
break;
case (int)TaskOtherTypeEnum.RelocationCar:
+ case (int)TaskOtherTypeEnum.RelocationCarCharging:
taskType = Direction == 1 ? ShuttleCarTaskType.ZeroA : ShuttleCarTaskType.ZeroB;
break;
default:
@@ -71,14 +330,19 @@
switch (TaskType)
{
case (int)TaskInboundTypeEnum.Inbound:
+ case (int)TaskInboundTypeEnum.PalletInbound:
state = (int)TaskInStatusEnum.Car_InExecuting;
break;
case (int)TaskOutboundTypeEnum.Outbound:
+ case (int)TaskOutboundTypeEnum.PalletOutbound:
state = (int)TaskOutStatusEnum.Car_OutExecuting;
break;
case (int)TaskOtherTypeEnum.RelocationCar:
state = (int)TaskCarStatusEnum.ShuttleCar_Executing;
break;
+ case (int)TaskOtherTypeEnum.RelocationCarCharging:
+ state = (int)CarChargingTaskEnum.ShuttleCar_Charging;
+ break;
default:
break;
}
--
Gitblit v1.9.3