From f319fd5d5e5e0332c4c7e209df64c351dfbe6887 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期六, 25 四月 2026 22:13:19 +0800
Subject: [PATCH] fix: 修复PLC通信及任务处理中的多个问题
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs | 65 ++++++++++++++++++--------------
1 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
index b5af9c9..1a240f1 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
@@ -4,6 +4,7 @@
using SqlSugar;
using System.DirectoryServices.Protocols;
using System.Text.Json;
+using WIDESEA_Common.Constants;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
@@ -48,12 +49,19 @@
if (stockInfo == null)
{
var location = await _locationInfoService.GetLocationInfoAsync(input.LocationCode);
- locationStatus = location?.LocationStatus ?? 0;
+ locationStatus = location?.LocationStatus == (int)LocationStatusEnum.InStock ? 10 : 0;
}
else
{
- locationStatus = stockInfo.LocationDetails?.LocationStatus ?? 0;
+ locationStatus = MapLocationStatus(stockInfo.StockStatus);
}
+
+ int MapLocationStatus(int stockStatus) => stockStatus switch
+ {
+ (int)StockStatusEmun.鍏ュ簱瀹屾垚 => 10,
+ (int)StockStatusEmun.绌烘墭鐩樺簱瀛� => 11,
+ _ => 0
+ };
OutputDto outPutDto = new OutputDto()
{
@@ -90,8 +98,8 @@
var result = await _locationInfoService.Db.Updateable<Dt_LocationInfo>()
.SetColumns(s => new Dt_LocationInfo
{
- LocationStatus = input.LocationStatus
- }).Where(s => s.LocationCode == input.LocationCode).ExecuteCommandAsync() > 0;
+ EnableStatus = input.LocationStatus == 1 ? 0 : 3,
+ }).Where(s => s.LocationCode == input.LocationCode && s.RoadwayNo == TaskAddressConstants.GRADING_RoadWayNo).ExecuteCommandAsync() > 0;
if (result)
{
@@ -126,40 +134,41 @@
var stock = await _stockInfoService.GetStockInfoAsync(input.PalletCode, input.LocationCode);
if (stock == null)
{
- content.Error("鏈壘鍒板搴旂殑鎵樼洏");
+ return content.Error("鏈壘鍒板搴旂殑鎵樼洏");
}
- else
- {
- var taskList = new Dt_Task
- {
- WarehouseId = stock.WarehouseId,
- PalletCode = stock.PalletCode,
- PalletType = stock.PalletType,
- SourceAddress = stock.LocationCode,
- CurrentAddress = stock.LocationCode,
- NextAddress = "10080",
- TargetAddress = "10081",
- Roadway = stock.LocationDetails.RoadwayNo,
- TaskType = TaskTypeEnum.Outbound.GetHashCode(),
- TaskStatus = TaskStatusEnum.New.GetHashCode(),
- Grade = 1,
- TaskNum = await BaseDal.GetTaskNo(),
- Creater = "system",
- };
+ var taskList = new Dt_Task
+ {
+ WarehouseId = stock.WarehouseId,
+ PalletCode = stock.PalletCode,
+ PalletType = stock.PalletType,
+ SourceAddress = stock.LocationCode,
+ CurrentAddress = stock.LocationCode,
+ NextAddress = TaskAddressConstants.GRADING_OUTBOUND_ADDRESS,
+ TargetAddress = TaskAddressConstants.GRADING_OUTBOUND_ADDRESS,
+ Roadway = stock.LocationDetails.RoadwayNo,
+ TaskType = TaskOutboundTypeEnum.Outbound.GetHashCode(),
+ TaskStatus = TaskOutStatusEnum.OutNew.GetHashCode(),
+ Grade = 1,
+ TaskNum = await BaseDal.GetTaskNo(),
+ Creater = "system",
+ };
+
+ return await _unitOfWorkManage.BeginTranAsync(async () =>
+ {
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)
{
- content.OK("鍑哄簱璇锋眰鎴愬姛");
+ return content.OK("鍑哄簱璇锋眰鎴愬姛");
}
else
{
- content.Error("鍑哄簱璇锋眰澶辫触");
+ return content.Error("鍑哄簱璇锋眰澶辫触");
}
- }
+ });
}
catch (Exception ex)
{
--
Gitblit v1.9.3