From b690250002ee04f4309e6a90fd16fbfd9bd959e2 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 01 五月 2026 23:11:23 +0800
Subject: [PATCH] feat(router): 添加托盘操作页面路由
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs | 120 +++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 74 insertions(+), 46 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
index 23d3d27..d71074d 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
@@ -1,33 +1,26 @@
-using Mapster;
-using MapsterMapper;
-using Microsoft.Extensions.Configuration;
-using SqlSugar;
-using System.DirectoryServices.Protocols;
+using Serilog;
using System.Text.Json;
+using System.Text.Encodings.Web;
+using System.Text.Unicode;
using WIDESEA_Common.Constants;
-using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
-using WIDESEA_Common.WareHouseEnum;
using WIDESEA_Core;
-using WIDESEA_Core.BaseRepository;
-using WIDESEA_Core.BaseServices;
-using WIDESEA_Core.Core;
-using WIDESEA_Core.Enums;
-using WIDESEA_Core.Helper;
using WIDESEA_DTO.GradingMachine;
-using WIDESEA_DTO.MES;
-using WIDESEA_DTO.Stock;
using WIDESEA_DTO.Task;
-using WIDESEA_IBasicService;
-using WIDESEA_IStockService;
-using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
namespace WIDESEA_TaskInfoService
{
public partial class TaskService
{
+ /// <summary>
+ /// JSON搴忓垪鍖栭�夐」锛堜腑鏂囦笉杞箟锛�
+ /// </summary>
+ private static readonly JsonSerializerOptions _jsonOptions = new()
+ {
+ Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
+ };
#region 鍒嗗鏌滄帴鍙�
/// <summary>
@@ -35,26 +28,28 @@
/// </summary>
public async Task<WebResponseContent> InOrOutCompletedAsync(GradingMachineInputDto input)
{
+ var log = Log.ForContext("SourceContext", "鍒嗗鏌滃畬鎴愪俊鍙�");
+ log.Information("[InOrOutCompleted] 璇锋眰鍙傛暟: {Request}", JsonSerializer.Serialize(input, _jsonOptions));
WebResponseContent content = new WebResponseContent();
- if (string.IsNullOrWhiteSpace(input.PalletCode) || string.IsNullOrWhiteSpace(input.LocationCode))
+ if (string.IsNullOrWhiteSpace(input.LocationCode))
{
- return content.Error($"鎵樼洏鍙锋垨鑰呰揣浣嶇紪鍙蜂笉鑳戒负绌�");
+ var errResult = content.Error($"璐т綅缂栧彿涓嶈兘涓虹┖");
+ log.Warning("[InOrOutCompleted] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+ return errResult;
}
try
{
- var stockInfo = await _stockInfoService.GetStockInfoAsync(input.PalletCode, input.LocationCode);
+ var stockInfo = await _stockInfoService.GetStockInfoAsync(3, input.LocationCode);
int locationStatus;
if (stockInfo == null)
{
- var location = await _locationInfoService.GetLocationInfoAsync(input.LocationCode);
- locationStatus = location?.LocationStatus == (int)LocationStatusEnum.InStock ? 10 : 0;
+ var errResult = content.Error("WMS鏈壘鍒板簱瀛樹俊鎭�");
+ log.Warning("[InOrOutCompleted] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+ return errResult;
}
- else
- {
- locationStatus = MapLocationStatus(stockInfo.StockStatus);
- }
+ locationStatus = MapLocationStatus(stockInfo.StockStatus);
int MapLocationStatus(int stockStatus) => stockStatus switch
{
@@ -66,15 +61,18 @@
OutputDto outPutDto = new OutputDto()
{
LocationCode = input.LocationCode,
- PalletCode = input.PalletCode,
+ PalletCode = stockInfo.PalletCode,
IsNormalProcedure = 1,
LocationStatus = locationStatus
};
- return content.OK(data: outPutDto);
+ var result = content.OK(data: outPutDto);
+ log.Information("[InOrOutCompleted] 鍝嶅簲: {Response}", JsonSerializer.Serialize(result, _jsonOptions));
+ return result;
}
catch (Exception ex)
{
content.Error(ex.Message);
+ log.Error(ex, "[InOrOutCompleted] 寮傚父");
}
return content;
@@ -87,10 +85,14 @@
/// <returns></returns>
public async Task<WebResponseContent> SendLocationStatusAsync(GradingMachineInputDto input)
{
+ var log = Log.ForContext("SourceContext", "鍒嗗鏌滅姸鎬佹洿鏂�");
+ log.Information("[SendLocationStatus] 璇锋眰鍙傛暟: {Request}", JsonSerializer.Serialize(input, _jsonOptions));
WebResponseContent content = new WebResponseContent();
if (string.IsNullOrWhiteSpace(input.LocationCode))
{
- return content.Error($"璐т綅缂栧彿涓嶈兘涓虹┖");
+ var errResult = content.Error($"璐т綅缂栧彿涓嶈兘涓虹┖");
+ log.Warning("[SendLocationStatus] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+ return errResult;
}
try
@@ -109,10 +111,12 @@
{
content.Error("鏇存柊澶辫触");
}
+ log.Information("[SendLocationStatus] 鍝嶅簲: {Response}", JsonSerializer.Serialize(content, _jsonOptions));
}
catch (Exception ex)
{
content.Error(ex.Message);
+ log.Error(ex, "[SendLocationStatus] 寮傚父");
}
return content;
}
@@ -124,17 +128,23 @@
/// <returns></returns>
public async Task<WebResponseContent> RequestOutboundAsync(GradingMachineInputDto input)
{
+ var log = Log.ForContext("SourceContext", "鍒嗗鏌滃嚭搴撹姹�");
+ log.Information("[RequestOutbound] 璇锋眰鍙傛暟: {Request}", JsonSerializer.Serialize(input, _jsonOptions));
WebResponseContent content = new WebResponseContent();
if (string.IsNullOrWhiteSpace(input.LocationCode) || string.IsNullOrWhiteSpace(input.PalletCode))
{
- return content.Error($"鎵樼洏鍙锋垨鑰呰揣浣嶇紪鍙蜂笉鑳戒负绌�");
+ var errResult = content.Error($"鎵樼洏鍙锋垨鑰呰揣浣嶇紪鍙蜂笉鑳戒负绌�");
+ log.Warning("[RequestOutbound] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+ return errResult;
}
try
{
var stock = await _stockInfoService.GetStockInfoAsync(input.PalletCode, input.LocationCode);
if (stock == null)
{
- return content.Error("鏈壘鍒板搴旂殑鎵樼洏");
+ var errResult = content.Error("鏈壘鍒板搴旂殑鎵樼洏");
+ log.Warning("[RequestOutbound] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+ return errResult;
}
var taskList = new Dt_Task
@@ -144,7 +154,7 @@
PalletType = stock.PalletType,
SourceAddress = stock.LocationCode,
CurrentAddress = stock.LocationCode,
- NextAddress = TaskAddressConstants.DEFAULT_ADDRESS,
+ NextAddress = TaskAddressConstants.GRADING_OUTBOUND_ADDRESS,
TargetAddress = TaskAddressConstants.GRADING_OUTBOUND_ADDRESS,
Roadway = stock.LocationDetails.RoadwayNo,
TaskType = TaskOutboundTypeEnum.Outbound.GetHashCode(),
@@ -158,21 +168,26 @@
{
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;
+ var wmsTaskDtos = new List<WMSTaskDTO> { wmstaskDto };
+ var httpResponse = _httpClientHelper.Post<WebResponseContent>("http://localhost:9292/api/Task/ReceiveTask", JsonSerializer.Serialize(wmsTaskDtos)).Data;
if (result && httpResponse != null)
{
- return content.OK("鍑哄簱璇锋眰鎴愬姛");
+ var okResult = content.OK("鍑哄簱璇锋眰鎴愬姛");
+ log.Information("[RequestOutbound] 鍝嶅簲: {Response}", JsonSerializer.Serialize(okResult, _jsonOptions));
+ return okResult;
}
else
{
- return content.Error("鍑哄簱璇锋眰澶辫触");
+ var errResult = content.Error("鍑哄簱璇锋眰澶辫触");
+ log.Warning("[RequestOutbound] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+ return errResult;
}
});
}
catch (Exception ex)
{
content.Error(ex.Message);
+ log.Error(ex, "[RequestOutbound] 寮傚父");
}
return content;
}
@@ -184,31 +199,44 @@
/// <returns></returns>
public async Task<WebResponseContent> GetPalletCodeCellAsync(GradingMachineInputDto input)
{
+ var log = Log.ForContext("SourceContext", "鍒嗗鏌滅數鑺煡璇�");
+ log.Information("[GetPalletCodeCell] 璇锋眰鍙傛暟: {Request}", JsonSerializer.Serialize(input, _jsonOptions));
WebResponseContent content = new WebResponseContent();
if (string.IsNullOrWhiteSpace(input.PalletCode) || string.IsNullOrWhiteSpace(input.LocationCode))
{
- return content.Error($"鎵樼洏鍙锋垨鑰呰揣浣嶇紪鍙蜂笉鑳戒负绌�");
+ var errResult = content.Error($"鎵樼洏鍙锋垨鑰呰揣浣嶇紪鍙蜂笉鑳戒负绌�");
+ log.Warning("[GetPalletCodeCell] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+ return errResult;
}
try
{
var stockInfo = await _stockInfoService.GetStockInfoAsync(input.PalletCode, input.LocationCode);
if (stockInfo == null)
{
- return content.Error("鏈壘鍒板搴旂殑鎵樼洏");
+ var errResult = content.Error("鏈壘鍒板搴旂殑鎵樼洏");
+ log.Warning("[GetPalletCodeCell] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+ return errResult;
}
- var outPutDtos = stockInfo.Details.Select(x => new OutputDto()
+
+ var outPutDtos = new
{
- LocationCode = input.LocationCode,
- PalletCode = input.PalletCode,
+ input.LocationCode,
+ input.PalletCode,
IsNormalProcedure = 1,
- LocationStatus = stockInfo.LocationDetails.LocationStatus,
- CellCode = x.SerialNumber,
- Channel = x.InboundOrderRowNo.ToString()
- }).ToList();
- return content.OK(data: outPutDtos);
+ stockInfo.LocationDetails.LocationStatus,
+ Data = stockInfo.Details.Select(x => new CellCodeData
+ {
+ CellCode = x.SerialNumber,
+ Channel = x.InboundOrderRowNo.ToString()
+ }).ToList()
+ };
+ var result = content.OK(data: outPutDtos);
+ log.Information("[GetPalletCodeCell] 鍝嶅簲: {Response}", JsonSerializer.Serialize(result, _jsonOptions));
+ return result;
}
catch (Exception ex)
{
+ log.Error(ex, "[GetPalletCodeCell] 寮傚父");
return content.Error(ex.Message);
}
}
--
Gitblit v1.9.3