From aefdecd0aa3226b7d00d1dc764241b82658b3be8 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 06 三月 2026 10:41:02 +0800
Subject: [PATCH] 添加机器人客户端;更新 WCS 缓存及任务
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 91 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 79 insertions(+), 12 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index 2a799c9..5606824 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -1,5 +1,4 @@
锘縰sing AutoMapper;
-using Microsoft.AspNetCore.Components.Forms;
using SqlSugar;
using System.Text.Json;
using WIDESEA_Common.LocationEnum;
@@ -8,7 +7,6 @@
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
-using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_DTO.Task;
using WIDESEA_IBasicService;
@@ -49,6 +47,8 @@
_httpClientHelper = httpClientHelper;
}
+ #region WCS閫昏緫澶勭悊
+
/// <summary>
/// 鍒涘缓浠诲姟锛堢粍鐩樺叆搴撲换鍔°�佺┖鎵樼洏鍥炲簱浠诲姟锛�
/// </summary>
@@ -56,9 +56,13 @@
{
try
{
+ WebResponseContent content = await GetTasksByPalletCodeAsync(taskDto.PalletCode);
+ if (content.Status)
+ {
+ return content;
+ }
+
if (string.IsNullOrWhiteSpace(taskDto.PalletCode) ||
- string.IsNullOrWhiteSpace(taskDto.SourceAddress) ||
- string.IsNullOrWhiteSpace(taskDto.TargetAddress) ||
string.IsNullOrWhiteSpace(taskDto.Roadway))
{
return WebResponseContent.Instance.Error("鏃犳晥鐨勪换鍔¤鎯�");
@@ -69,14 +73,22 @@
return WebResponseContent.Instance.Error("鏃犳晥鐨勪换鍔¤鎯�");
}
+ // 浣跨敤 switch 琛ㄨ揪寮忔槧灏勪换鍔$被鍨�
+ int taskInboundType = taskDto.TaskType switch
+ {
+ TaskTypeEnum.Inbound => TaskInboundTypeEnum.Inbound.GetHashCode(),
+ TaskTypeEnum.InEmpty => TaskInboundTypeEnum.InEmpty.GetHashCode(),
+ _ => 0 // 鐞嗚涓婁笉浼氳蛋鍒拌繖閲岋紝鍥犱负宸茬粡楠岃瘉杩囦簡
+ };
+
var task = new Dt_Task
{
- TaskNum = 0,
+ TaskNum = await BaseDal.GetTaskNo(),
PalletCode = taskDto.PalletCode,
PalletType = taskDto.PalletType,
Roadway = taskDto.Roadway,
- TaskType = taskDto.TaskType.GetHashCode(),
- TaskStatus = TaskStatusEnum.New.GetHashCode(),
+ TaskType = taskInboundType,
+ TaskStatus = TaskInStatusEnum.InNew.GetHashCode(),
SourceAddress = taskDto.SourceAddress,
TargetAddress = taskDto.TargetAddress,
CurrentAddress = taskDto.SourceAddress,
@@ -259,6 +271,12 @@
{
try
{
+ WebResponseContent content = await GetTasksByPalletCodeAsync(taskDto.PalletCode);
+ if (content.Status)
+ {
+ return content;
+ }
+
//var tasks = await BaseDal.QueryAsync(s => s.PalletCode == palletCode);
//if (tasks == null || !tasks.Any())
// return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟");
@@ -280,8 +298,9 @@
{
try
{
+
var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => x.LocationDetails.WarehouseId == taskDto.WarehouseId && x.LocationDetails.LocationStatus == LocationStatusEnum.InStock.GetHashCode() && x.StockStatus == StockStatusEmun.绌烘墭鐩樺簱瀛�.GetHashCode());
- if(stockInfo == null)
+ if (stockInfo == null)
return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑搴撳瓨淇℃伅");
var task = new Dt_Task()
@@ -300,7 +319,7 @@
TaskNum = await BaseDal.GetTaskNo(),
Creater = "system",
};
- var taskDtos = _mapper.Map<List<WMSTaskDTO>>(task);
+ var taskDtos = _mapper.Map<List<WMSTaskDTO>>(task);
return WebResponseContent.Instance.OK("鏌ヨ鎴愬姛", taskDtos);
}
catch (Exception ex)
@@ -308,6 +327,55 @@
return WebResponseContent.Instance.Error($"鏌ヨ浠诲姟澶辫触: {ex.Message}");
}
}
+
+ /// <summary>
+ /// 淇敼浠诲姟鐘舵�侊紙鏍规嵁浠诲姟ID淇敼涓烘寚瀹氱姸鎬侊級
+ /// </summary>
+ /// <param name="taskId"></param>
+ /// <param name="newStatus"></param>
+ /// <returns></returns>
+ public async Task<WebResponseContent> UpdateTaskByStatusAsync(int taskId, int newStatus)
+ {
+ try
+ {
+ var tasks = await BaseDal.QueryFirstAsync(s => s.TaskId == taskId);
+ if (tasks == null)
+ return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟");
+
+ tasks.TaskStatus = newStatus;
+ await BaseDal.UpdateDataAsync(tasks);
+
+ return WebResponseContent.Instance.OK("淇敼鎴愬姛", tasks);
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"淇敼澶辫触: {ex.Message}");
+ }
+ }
+
+
+ /// <summary>
+ /// 鏌ユ壘鎵樼洏鏄惁鏈変换鍔�
+ /// </summary>
+ /// <param name="palletCode"></param>
+ /// <returns></returns>
+ private async Task<WebResponseContent> GetTasksByPalletCodeAsync(string palletCode)
+ {
+ try
+ {
+ var tasks = await BaseDal.QueryFirstAsync(s => s.PalletCode == palletCode);
+ if (tasks == null)
+ return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟");
+ var taskDtos = _mapper.Map<List<WMSTaskDTO>>(tasks);
+ return WebResponseContent.Instance.OK("鏌ヨ鎴愬姛", taskDtos);
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"鏌ヨ浠诲姟澶辫触: {ex.Message}");
+ }
+ }
+
+ #endregion WCS閫昏緫澶勭悊
#region 鍒嗗鏌滄帴鍙�
@@ -436,7 +504,6 @@
var result = await BaseDal.AddDataAsync(taskList) > 0;
var wmstaskDto = result ? _mapper.Map<WMSTaskDTO>(taskList) : null;
-
var httpResponse = _httpClientHelper.Post<WebResponseContent>("http://logistics-service/api/logistics/notifyoutbound", JsonSerializer.Serialize(wmstaskDto)).Data;
if (result && httpResponse != null)
{
@@ -491,6 +558,6 @@
}
}
- #endregion
+ #endregion 鍒嗗鏌滄帴鍙�
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3