From 2b5708d9da762cc01d6dc7cca79b3bce86db7355 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期三, 04 三月 2026 16:56:18 +0800
Subject: [PATCH] 编写四向车job
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 216 insertions(+), 3 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
index 8a5ba62..b5f2ecc 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
@@ -1,15 +1,28 @@
-锘縰sing System;
+锘縰sing Magicodes.IE.Core;
+using NetTaste;
+using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection.Metadata;
using System.Text;
+using System.Text.Json;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
+using WIDESEAWCS_Common.LocationEnum;
+using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO;
+using WIDESEAWCS_DTO.WMS;
+using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_TaskInfoService
{
public partial class TaskService
{
+
+ #region 鏇存柊浠诲姟鐘舵��
/// <summary>
/// 鏇存柊浠诲姟鐘舵��
/// </summary>
@@ -19,17 +32,216 @@
/// <exception cref="NotImplementedException"></exception>
public WebResponseContent UpdateTaskStatus(object TaskDTO, DeviceTypeEnum deviceTypeEnum)
{
+
+ WebResponseContent content = new WebResponseContent();
+ GALAXISUpdateTaskStatus gALAXIS = new();
try
{
if (deviceTypeEnum == DeviceTypeEnum.GALAXIS)
{
-
+ gALAXIS = TaskDTO.Serialize().DeserializeObject<GALAXISUpdateTaskStatus>();
+ if (gALAXIS == null) throw new Exception("鍙傛暟杞崲澶辫触锛�");
+ var task = BaseDal.QueryFirst(x => x.WMSTaskNum == gALAXIS.taskId);
+ if (task == null) throw new Exception($"鏈壘鍒颁换鍔�,浠诲姟缂栧彿銆恵gALAXIS.taskId}銆�");
+ switch (gALAXIS.taskStatus)
+ {
+ case 0:
+ TaskCompleted(task, deviceTypeEnum);
+ break;
+ case 4:
+ TaskFromCompleted(task, deviceTypeEnum);
+ break;
+ default:
+ task.TaskState = ReturnTaskStatus(gALAXIS.taskStatus, deviceTypeEnum);
+ BaseDal.UpdateData(task);
+ break;
+ }
}
else if (deviceTypeEnum == DeviceTypeEnum.HIKROBOT)
{
}
+ else //鍥涘悜杞�
+ {
+
+ }
+ //return WebResponseContent.Instance.OK();
+ return content.OK();
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+ finally
+ {
+ _trackloginfoService.AddTrackLog(gALAXIS, content, "涓嬪彂鍑箰澹獳GV浠诲姟", "", "");
+ }
+ }
+ #endregion
+
+ #region 浠诲姟鐘舵�佽浆鎹�
+ public int ReturnTaskStatus(object status, DeviceTypeEnum deviceTypeEnum)
+ {
+ try
+ {
+ if (deviceTypeEnum == DeviceTypeEnum.GALAXIS)
+ {
+ TaskStatusEnum taskStatus = status switch
+ {
+ 1 => TaskStatusEnum.FromOutOfStock,
+ 2 => TaskStatusEnum.ToaddInStock,
+ 3 => TaskStatusEnum.TaskNumRepetition,
+ 5 => TaskStatusEnum.RCSDataError,
+ 6 => TaskStatusEnum.TaskTypeError,
+ 7 => TaskStatusEnum.ParameterError,
+ 8 => TaskStatusEnum.RCSError,
+ 10 => TaskStatusEnum.Takeing,
+ 13 => TaskStatusEnum.Cancel,
+ _ => throw new ArgumentOutOfRangeException(
+ nameof(status),
+ status,
+ $"鏈煡鐨勪换鍔$姸鎬佺爜: {status}"
+ )
+ };
+ return (int)taskStatus;
+ }
+ else if (deviceTypeEnum == DeviceTypeEnum.HIKROBOT)
+ {
+ return 0;
+ }
else
+ {
+ return 0;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+ #endregion
+
+ #region 浠诲姟璧风偣瀹屾垚
+ /// <summary>
+ /// 浠诲姟璧风偣瀹屾垚
+ /// </summary>
+ /// <param name="dt_Task"></param>
+ /// <param name="deviceTypeEnum"></param>
+ /// <returns></returns>
+ public WebResponseContent TaskFromCompleted(Dt_Task dt_Task, DeviceTypeEnum deviceTypeEnum)
+ {
+ try
+ {
+ dt_Task.TaskState = TaskStatusEnum.TakeFinish.ObjToInt();
+ Db.Ado.BeginTran();
+ UpdateLocationStatus(dt_Task.SourceAddress, deviceTypeEnum, LocationStatusEnum.Free);
+ BaseDal.UpdateData(dt_Task);
+ Db.Ado.CommitTran();
+ return WebResponseContent.Instance.OK();
+ }
+ catch (Exception ex)
+ {
+ Db.Ado.RollbackTran();
+ throw new Exception(ex.Message);
+ }
+ }
+ #endregion
+
+ #region 浠诲姟瀹屾垚
+ /// <summary>
+ /// 浠诲姟瀹屾垚
+ /// </summary>
+ /// <param name=""></param>
+ /// <param name="deviceTypeEnum"></param>
+ /// <returns></returns>
+ public WebResponseContent TaskCompleted(Dt_Task dt_Task, DeviceTypeEnum deviceTypeEnum)
+ {
+ try
+ {
+ WMSInOutBoundCompleteFeedback boundCompleteFeedback = new WMSInOutBoundCompleteFeedback();
+ WMSReturn agvContent = null;
+ dt_Task.TaskState = TaskStatusEnum.Finish.ObjToInt();
+
+ Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(WMSInOutBoundCompleteFeedback));
+ if (apiInfo == null) dt_Task.ExceptionMessage = "鏈壘鍒板嚭鍏ュ簱瀹屾垚鍙嶉WMS鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�";
+ else
+ {
+ boundCompleteFeedback.taskCode = dt_Task.WMSTaskNum;
+ boundCompleteFeedback.containerCode = dt_Task.PalletCode;
+ boundCompleteFeedback.fromStationCode = dt_Task.SourceAddress;
+ boundCompleteFeedback.toLocationCode = dt_Task.TargetAddress;
+ switch (deviceTypeEnum)
+ {
+ case DeviceTypeEnum.GALAXIS:
+ boundCompleteFeedback.businessType = 1;
+ break;
+ case DeviceTypeEnum.YuanLiJuHe:
+ boundCompleteFeedback.businessType = 2;
+ break;
+ }
+
+ boundCompleteFeedback.completeType = 1;
+ string response = HttpHelper.Post(apiInfo.ApiAddress, boundCompleteFeedback.Serialize());
+ agvContent = response.DeserializeObject<WMSReturn>();
+ if (agvContent.code != 0) dt_Task.ExceptionMessage = agvContent.msg;
+ }
+ Db.Ado.BeginTran();
+ UpdateLocationStatus(dt_Task.TargetAddress, deviceTypeEnum, LocationStatusEnum.InStock);
+ if (agvContent != null && agvContent.code == 0)
+ BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.鑷姩瀹屾垚);
+ else
+ BaseDal.UpdateData(dt_Task);
+ Db.Ado.CommitTran();
+ return WebResponseContent.Instance.OK();
+ }
+ catch (Exception ex)
+ {
+ Db.Ado.RollbackTran();
+ throw new Exception(ex.Message);
+ }
+ }
+ #endregion
+
+ #region 鏇存柊璐т綅鐘舵��
+ /// <summary>
+ /// 鏇存柊璐т綅鐘舵��
+ /// </summary>
+ /// <param name="LocationCode"></param>
+ /// <param name="deviceTypeEnum"></param>
+ /// <param name="locationStatusEnum"></param>
+ /// <returns></returns>
+ public WebResponseContent UpdateLocationStatus(string LocationCode, DeviceTypeEnum deviceTypeEnum, LocationStatusEnum locationStatusEnum)
+ {
+ try
+ {
+ if (deviceTypeEnum == DeviceTypeEnum.GALAXIS)
+ {
+ Dt_KLSLocationInfo? dt_KLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode);
+ if (dt_KLSLocationInfo != null)
+ {
+ dt_KLSLocationInfo.LocationStatus = locationStatusEnum.ObjToInt();
+ _kLSLocationInfoService.Repository.UpdateData(dt_KLSLocationInfo);
+ }
+ }
+ else if (deviceTypeEnum == DeviceTypeEnum.HIKROBOT)
+ {
+ Dt_HKLocationInfo? dt_HKLocationInfo = _hKLocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode);
+ if (dt_HKLocationInfo != null)
+ {
+ dt_HKLocationInfo.LocationStatus = locationStatusEnum.ObjToInt();
+ _hKLocationInfoService.Repository.UpdateData(dt_HKLocationInfo);
+ }
+ }
+ else if (deviceTypeEnum == DeviceTypeEnum.YuanLiJuHe)
+ {
+ Dt_RGVLocationInfo dt_RGVLocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode);
+ if (dt_RGVLocationInfo != null)
+ {
+ dt_RGVLocationInfo.LocationStatus = locationStatusEnum.ObjToInt();
+ _rGVLocationInfoService.Repository.UpdateData(dt_RGVLocationInfo);
+ }
+ }
+ else//搴撳绔欏彴
{
}
@@ -37,8 +249,9 @@
}
catch (Exception ex)
{
- return WebResponseContent.Instance.Error(ex.Message);
+ throw new Exception(ex.Message);
}
}
+ #endregion
}
}
--
Gitblit v1.9.3