From 41a5531dc31a642623f0a7a766fbe9c256ba9247 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 11 二月 2025 13:53:29 +0800
Subject: [PATCH] 优化WMS前端
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarExtend/PartialTaskService.cs | 198 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 198 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..1c0a236 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,209 @@
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((int)TaskCarStatusEnum.SC_CarFinish, (int)TaskOtherTypeEnum.RelocationCar);
+ if (dt_Task != null)
+ {
+ var ShuttleCar = QueryCode(dt_Task.ShuttleCarCode);
+ ShuttleCar.ShuttleCarPosition = dt_Task.TargetAddress;
+ _shuttleCarService.UpdateData(ShuttleCar);
+ if (string.IsNullOrEmpty(dt_Task.Remark))//瀹屾垚绉诲簱浠诲姟
+ _taskService.AddTask_Hty(dt_Task, TaskOperateTypeEnum.AutoComplete);
+ else//涓嬪彂鍏呯數浠诲姟
+ SendTask(dt_Task);
+ }
+ }
+ #endregion
+
+ #region 鑾峰彇绉昏溅浠诲姟
+ /// <summary>
+ /// 鑾峰彇绉昏溅浠诲姟/鍑哄叆搴撲换鍔�
+ /// </summary>
+ public void Get_CarTask(ShuttleCar shuttleCar, ShuttleCarTaskCommandR command)
+ {
+ lock (_CarTaskObject)
+ {
+ Dt_Task dt_Task = GetTask((int)TaskCarStatusEnum.CarNew, (int)TaskOtherTypeEnum.RelocationCar);//鑾峰彇鏂板缓绉昏溅浠诲姟
+ if (dt_Task != null)
+ {
+ if (string.IsNullOrEmpty(dt_Task.SourceAddress))
+ {
+ if (command.Status == (short)ShuttleCarStatus.Standby && command.TaskTypeComplete == (short)ShuttleCarTaskComplete.Standby && command.Err_Status == (short)ShuttleCarErr.Normal)
+ {
+ UpdateSource(ref dt_Task, shuttleCar);
+ }
+ else
+ {
+ #region 鍒ゆ柇鏄惁瀛樺湪绌洪棽绌挎杞�,濡傞兘鍦ㄥ厖鐢�(閫夋嫨鐢甸噺楂樼殑骞惰秴杩�50%鐢甸噺鐨勭┛姊溅閫�鍑哄厖鐢�)
+ QuitCharging(dt_Task, shuttleCar, command);
+ #endregion
+ }
+ }
+ 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);
+ }
+ }
+ #region 绌挎杞﹀嚭鍏ュ簱浠诲姟
+ else
+ {
+ var task = _taskService.QueryShuttleCarTask(shuttleCar.DeviceCode);
+ if (task != null)
+ {
+ if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && !task.IsPickPlace)
+ {
+ var ShuttleCar = _shuttleCarService.QueryShuttleCar(task.SourceAddress);//鍑哄簱浠诲姟鍒ゆ柇鏄惁瀛樺湪绌挎杞�
+ if (ShuttleCar != null) SendTask(task);
+ else _taskService.AddRelocationCarTask("", task.SourceAddress);
+ }
+ }
+ }
+ #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, ShuttleCar shuttleCar)
+ {
+ dt_Task.SourceAddress = QueryCode(shuttleCar._deviceCode).ShuttleCarPosition;
+ dt_Task.CurrentAddress = dt_Task.SourceAddress;
+ dt_Task.ShuttleCarCode = shuttleCar._deviceCode;
+ _taskService.UpdateData(dt_Task);
+ _taskExecuteDetailService.AddTaskExecuteDetail(dt_Task.TaskNum, "鏇存柊绉昏溅浠诲姟璧峰鍦板潃");
+ }
+ #endregion
+
+ #region 閫�鍑哄厖鐢典换鍔�
+ public void QuitCharging(Dt_Task dt_Task, ShuttleCar shuttleCar, ShuttleCarTaskCommandR command)
+ {
+ List<string> shuttleCarCodes = new List<string>() { "RGV01", "RGV02" };
+ string CarCode = shuttleCarCodes.Where(x => !x.Contains(shuttleCar.DeviceCode)).First();
+ ShuttleCar shuttleCar1 = Storage.Devices.Where(x => x.DeviceCode.Equals(CarCode)).FirstOrDefault() as ShuttleCar;
+ if (shuttleCar1 != null)
+ {
+ var command1 = ReadCustomer<ShuttleCarTaskCommandR>(shuttleCar1, shuttleCar1.DeviceCode);//璇诲彇绌挎杞︿俊鎭�
+ if (command1.Status == (short)ShuttleCarStatus.Standby && command1.TaskTypeComplete == (short)ShuttleCarTaskComplete.Standby && command1.Err_Status == (short)ShuttleCarErr.Normal)
+ {
+ UpdateSource(ref dt_Task, shuttleCar1);
+ }
+ else
+ {
+ //閫夋嫨鐢甸噺楂樼殑骞惰秴杩�50%鐢甸噺鐨勭┛姊溅閫�鍑哄厖鐢�
+ command = command.ElectricQuantity > command1.ElectricQuantity ? command : command1;
+ shuttleCar = command.ElectricQuantity > command1.ElectricQuantity ? shuttleCar : shuttleCar1;
+ }
+ }
+ if (string.IsNullOrEmpty(dt_Task.SourceAddress))
+ {
+ if (command.ElectricQuantity > 50)
+ {
+ ShuttleCarTaskCommandW shuttleCarTaskCommand = new ShuttleCarTaskCommandW();
+ shuttleCarTaskCommand.Direction = command.Position;
+ shuttleCarTaskCommand.TaskNum = dt_Task.TaskNum;
+ shuttleCarTaskCommand.TaskType = (short)ShuttleCarTaskType.ExitCharge;
+ if (shuttleCar.SendCommand(shuttleCarTaskCommand, shuttleCar.DeviceCode))
+ {
+ dt_Task.Remark = "閫�鍑哄厖鐢靛凡涓嬪彂";
+ UpdateSource(ref dt_Task, shuttleCar);
+ }
+ }
+ }
+ }
+ #endregion
+
+ #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)
+ {
+ //浠诲姟杞崲
+ ShuttleCarTaskCommandW shuttleCarTaskCommand = new ShuttleCarTaskCommandW();
+ shuttleCarTaskCommand.Direction = command.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
+ 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>
--
Gitblit v1.9.3