From ad6f399066a747aeaba987360bce9ee40227302c Mon Sep 17 00:00:00 2001
From: 肖洋 <cathay_xy@163.com>
Date: 星期一, 09 十二月 2024 18:23:00 +0800
Subject: [PATCH] SignalR+事件总线推送前端
---
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 140 +++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 129 insertions(+), 11 deletions(-)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index 3caf61c..19379e7 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,12 +1,16 @@
锘�
using AngleSharp.Io;
+using log4net.Core;
using Mapster;
using Masuit.Tools;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
+using SixLabors.Fonts.Tables.AdvancedTypographic;
using WIDESEA_Core.Const;
using WIDESEA_DTO.MOM;
using WIDESEA_DTO.WMS;
using WIDESEA_IServices;
using WIDESEA_IStoragIntegrationServices;
+using WIDESEA_Model.Models;
using WIDESEA_Services;
using WIDESEA_StorageBasicRepository;
using WIDESEAWCS_BasicInfoRepository;
@@ -102,9 +106,12 @@
// 浜嬪姟澶勭悊
await _unitOfWorkManage.UseTranAsync(async () =>
{
+ if (task.TaskType != (int)TaskOutboundTypeEnum.OutQuality)
+ {
+ await DeleteStockInfoAsync(stock.Id);
+ await DeleteStockInfoDetailsAsync(stock.StockInfoDetails);
+ }
await UpdateLocationAsync(loc);
- await DeleteStockInfoAsync(stock.Id);
- await DeleteStockInfoDetailsAsync(stock.StockInfoDetails);
//if (task.Roadway.Contains("FR") || task.Roadway.Contains("GW") || task.TaskType == (int)TaskOutboundTypeEnum.OutTray) //濡傛灉鏄垎瀹规垨楂樻俯鍑哄簱 灏嗕换鍔″垹闄�
await DeleteTaskAsync(task.TaskId);
});
@@ -165,7 +172,8 @@
TargetValue = parameterInfo.TargetValue,
LowerLomit = parameterInfo.LowerSpecificationsLimit,
UpperLimit = parameterInfo.UpperSpecificationsLimit,
- DefectCode = defectCode
+ DefectCode = defectCode,
+ UOMCode = parameterInfo.UOMCode,
}
}
}).ToList()
@@ -762,11 +770,32 @@
var stock = await QueryStockInfo(input.PalletCode);
if (stock != null)
{
+ Dt_Task taskNew = new Dt_Task
+ {
+ Grade = 1,
+ Roadway = stock.LocationInfo.RoadwayNo,
+ TargetAddress = stock.LocationInfo.RoadwayNo,
+ Dispatchertime = DateTime.Now,
+ MaterialNo = "",
+ NextAddress = stock.LocationInfo.RoadwayNo,
+ OrderNo = null,
+ PalletCode = stock.PalletCode,
+ SourceAddress = input.Position,
+ CurrentAddress = input.Position,
+ TaskState = (int)TaskInStatusEnum.InNew,
+ TaskType = (int)TaskInboundTypeEnum.InQuality,
+ TaskNum = BaseDal.GetTaskNo().Result,
+ Creater = "System", // 淇鎷煎啓閿欒
+ CreateDate = DateTime.Now,
+ TaskId = 0,
+ };
+
+ var taskDTO = CreateTaskDTO(task);
// TODO璐ㄦ鍥炲簱
}
// 鏍规嵁浣嶇疆鏌ヨ鍖哄煙淇℃伅
- var area = await QueryAreaInfoByPosition(input.Position);
+ var area = await QueryAreaInfoByPosition(input.Position.Replace("-1", ""));
if (area == null)
{
return content.Error("璇ョ偣浣嶄笉鍦ㄥ尯鍩熷垪琛ㄤ腑瀛樺湪");
@@ -780,7 +809,13 @@
var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
if (!result.Success)
{
- return content.Error(result.MOMMessage);
+ if (result.SerialNos.Count <= 0)
+ {
+ // 绌烘墭鐩樺叆搴撻�昏緫
+ return await RequestTrayInTaskAsync(input);
+ }
+ else
+ return content.Error(result.MOMMessage);
}
// 澶勭悊寮傚父鐢佃姱鎯呭喌
@@ -790,11 +825,6 @@
return await HandleErrorCells(input, area, serialNosError);
}
- if (result.SerialNos.Count <= 0)
- {
- // 绌烘墭鐩樺叆搴撻�昏緫
- return await RequestTrayInTaskAsync(input);
- }
var boxing = CreateBoxingInfo(result, input.PalletCode);
if (boxing == null) return content.Error("缁勭洏澶辫触");
@@ -1049,7 +1079,7 @@
SourceAddress = stockInfo.LocationCode,
CurrentAddress = stockInfo.LocationCode,
TaskState = (int)TaskOutStatusEnum.OutNew,
- TaskType = tag == (int)TaskOutboundTypeEnum.Outbound ? (int)TaskOutboundTypeEnum.Outbound : (int)TaskOutboundTypeEnum.OutTray,
+ TaskType = tag,
TaskNum = BaseDal.GetTaskNo().Result,
Creater = "System", // 淇鎷煎啓閿欒
CreateDate = DateTime.Now,
@@ -1151,6 +1181,84 @@
content.Error(ex.Message);
}
return content;
+ }
+
+ #endregion
+
+ #region 鎸囧畾浠诲姟鍑哄簱
+
+ public async Task<WebResponseContent> CreateAndSendOutboundTask(string locationCode, string palletCode)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ // 鏌ヨ搴撳瓨淇℃伅
+ var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.LocationCode == locationCode && x.PalletCode == palletCode);
+ if (stockInfo == null)
+ {
+ return content.Error("鏈煡璇㈠埌瀵瑰簲鐨勫簱瀛樹俊鎭�");
+ }
+
+ var task = await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode);
+ if (task != null)
+ {
+ return content.Error($"銆恵palletCode}銆戝凡瀛樺湪浠诲姟");
+ }
+
+ int taskType = 0;
+ if (stockInfo.IsFull)
+ taskType = (int)TaskOutboundTypeEnum.OutQuality;
+ else
+ taskType = (int)TaskOutboundTypeEnum.OutTray;
+ // 鍒涘缓骞舵坊鍔犱换鍔″埌鏁版嵁搴�
+ task = CreateTask(stockInfo, "1020-1", taskType);
+ //var taskId = await BaseDal.AddDataAsync(task);
+ //if (taskId <= 0)
+ //{
+ // return content.Error("浠诲姟鍒涘缓澶辫触");
+ //}
+
+ // 鍒涘缓浠诲姟浼犺緭鐢ㄧ殑DTO瀵硅薄
+ var taskDTO = CreateTaskDTO(task);
+
+ // 鑾峰彇WMS IP鍦板潃鐢ㄤ簬鍙戦�佷换鍔¤姹�
+ var wmsIpAddress = GetWCSIpReceiveTask();
+ if (wmsIpAddress == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+
+ var tasks = new List<WMSTaskDTO>() { taskDTO };
+ // 鍙戦�佷换鍔¤姹傚埌WMS
+ var result = await HttpHelper.PostAsync(wmsIpAddress, tasks.ToJsonString());
+ content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+ if (content.Status)
+ {
+ // 娣诲姞浠诲姟鍒版暟鎹簱
+ await BaseDal.AddDataAsync(task);
+ // 鏇存柊搴撳瓨浣嶇疆鐘舵�佷负涓嶅彲鐢�
+ stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
+ await _locationRepository.UpdateDataAsync(stockInfo.LocationInfo);
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鍙戠敓寮傚父: {ex.Message}");
+ content.Error(ex.Message);
+ }
+
+ return content;
+ }
+ private string GetWCSIpReceiveTask()
+ {
+ var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue;
+ var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ReceiveTask)?.ConfigValue;
+ if (wmsBase == null || ipAddress == null)
+ {
+ return null;
+ }
+ return wmsBase + ipAddress;
}
#endregion
@@ -1448,6 +1556,16 @@
bool isResult = await BaseDal.UpdateDataAsync(task);
return content.OK(data: task);
}
+ else if (task.TaskType == (int)TaskInboundTypeEnum.InQuality)
+ {
+ var stockInfo = _stockInfoRepository.QueryFirst(x => x.PalletCode == input.PalletCode);
+ task.CurrentAddress = input.Position;
+ task.TargetAddress = stockInfo.LocationInfo.LocationCode;
+ task.NextAddress = stockInfo.LocationInfo.LocationCode;
+ task.TaskState = (int)TaskInStatusEnum.Line_InFinish;
+ bool isResult = await BaseDal.UpdateDataAsync(task);
+ return content.OK(data: task);
+ }
else
{
var location = await GetLocationDistributeAsync(task.Roadway);
--
Gitblit v1.9.3