From 992a33ca68af405d08da512c46d7d59ec3ceaabc Mon Sep 17 00:00:00 2001
From: 肖洋 <cathay_xy@163.com>
Date: 星期二, 11 二月 2025 14:33:47 +0800
Subject: [PATCH] 添加 ProductionLine 属性并优化任务处理逻辑
---
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs | 138 ++++++++++++++++++++++++++++++++-------------
1 files changed, 98 insertions(+), 40 deletions(-)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
index 4962235..7e35a13 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -14,6 +14,7 @@
using WIDESEA_StorageTaskRepository;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob.Models;
namespace WIDESEA_StorageTaskServices;
@@ -39,18 +40,20 @@
//if (task.TaskState == (int)TaskInStatusEnum.InNew)
{
// 鍒涘缓WMS浠诲姟
- WMSTaskDTO taskDTO = new WMSTaskDTO()
- {
- TaskNum = task.TaskNum.Value,
- Grade = 1,
- PalletCode = task.PalletCode,
- RoadWay = task.Roadway,
- SourceAddress = task.SourceAddress,
- TargetAddress = task.TargetAddress,
- TaskState = task.TaskState.Value,
- Id = 0,
- TaskType = task.TaskType,
- };
+ //WMSTaskDTO taskDTO = new WMSTaskDTO()
+ //{
+ // TaskNum = task.TaskNum.Value,
+ // Grade = 1,
+ // PalletCode = task.PalletCode,
+ // RoadWay = task.Roadway,
+ // SourceAddress = task.SourceAddress,
+ // TargetAddress = task.TargetAddress,
+ // TaskState = task.TaskState.Value,
+ // Id = 0,
+ // TaskType = task.TaskType,
+ // ProductionLine = task.ProductionLine,
+ //};
+ WMSTaskDTO taskDTO = CreateTaskDTO(task);
return content.OK(data: taskDTO);
}
}
@@ -100,7 +103,7 @@
WMSTaskDTO taskDTO = new WMSTaskDTO()
{
TaskNum = task.TaskNum.Value,
- Grade = 1,
+ Grade = task.Grade.Value,
PalletCode = task.PalletCode,
RoadWay = task.Roadway,
SourceAddress = task.SourceAddress,
@@ -108,6 +111,7 @@
TaskState = task.TaskState.Value,
Id = 0,
TaskType = task.TaskType,
+ ProductionLine = task.ProductionLine
};
content.OK(data: taskDTO);
}
@@ -204,7 +208,8 @@
TaskState = (int)TaskInStatusEnum.Line_InFinish,
TaskType = (int)TaskOutboundTypeEnum.InToOut,
TaskNum = await BaseDal.GetTaskNo(),
- Creater = "Systeam"
+ Creater = "Systeam",
+ ProductionLine = result.ProductionLine
};
return taskNG;
}
@@ -261,7 +266,8 @@
TaskState = (int)TaskInStatusEnum.Line_InFinish,
TaskType = (int)TaskOutboundTypeEnum.InToOut,
TaskNum = await BaseDal.GetTaskNo(),
- Creater = "Systeam"
+ Creater = "Systeam",
+ ProductionLine = result.ProductionLine
};
return taskNG;
}
@@ -293,7 +299,8 @@
TaskState = (int)TaskInStatusEnum.Line_InFinish,
TaskType = (int)TaskOutboundTypeEnum.InToOut,
TaskNum = await BaseDal.GetTaskNo(),
- Creater = "Systeam"
+ Creater = "Systeam",
+ ProductionLine = result.ProductionLine
};
return task;
}
@@ -324,26 +331,33 @@
if (locationInfo == null) throw new Exception("搴撲綅宸叉弧");
+ // 鍒涘缓涓�涓猅rayCellsStatusDto瀵硅薄锛屽苟璧嬪��
+ TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
+ {
+ Software = "WMS",
+ TrayBarcode = input.PalletCode,
+ //EquipmentCode = "EQ_CWJZ01"
+ EquipmentCode = input.EquiCodeMOM
+ };
+
+ // 璋冪敤GetTrayCellStatusAsync鏂规硶锛岃幏鍙栨暣鐩樼數鑺�
+ WebResponseContent content = await GetTrayCellStatusAsync(trayCells);
+ // 濡傛灉鐘舵�佷负false锛屽垯杩斿洖content
+ if (!content.Status) throw new Exception(content.Message);
+
+ // 灏哻ontent.Data杞崲涓篟esultTrayCellsStatus瀵硅薄
+ var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
+
+ if (stationManager.stationType == 6 && result.ProductionLine.IsNullOrEmpty())
+ {
+ ConsoleHelper.WriteErrorLine($"褰撳墠鎵樼洏鏃犱骇绾�,鑱旂郴MOM娣诲姞浜х嚎");
+ throw new Exception("褰撳墠鎵樼洏鏃犱骇绾�,鑱旂郴MOM娣诲姞浜х嚎");
+ }
+
if (stationManager.stationType == 1)
{
#region
- // 鍒涘缓涓�涓猅rayCellsStatusDto瀵硅薄锛屽苟璧嬪��
- TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
- {
- Software = "WMS",
- TrayBarcode = input.PalletCode,
- //EquipmentCode = "EQ_CWJZ01"
- EquipmentCode = input.EquiCodeMOM
- };
- // 璋冪敤GetTrayCellStatusAsync鏂规硶锛岃幏鍙栨暣鐩樼數鑺�
- WebResponseContent content = await GetTrayCellStatusAsync(trayCells);
- // 濡傛灉鐘舵�佷负false锛屽垯杩斿洖content
- if (!content.Status) throw new Exception(content.Message);
-
- // 娣诲姞缁勭洏淇℃伅
- // 灏哻ontent.Data杞崲涓篟esultTrayCellsStatus瀵硅薄
- var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
if (result.SerialNos.Count <= 0)
{
ConsoleHelper.WriteErrorLine(result.MOMMessage);
@@ -362,7 +376,8 @@
TaskState = (int)TaskInStatusEnum.Line_InFinish,
TaskType = (int)TaskOutboundTypeEnum.InToOut,
TaskNum = await BaseDal.GetTaskNo(),
- Creater = "Systeam"
+ Creater = "Systeam",
+ ProductionLine = result.ProductionLine
};
return taskNG;
}
@@ -410,7 +425,8 @@
TaskState = (int)TaskInStatusEnum.Line_InFinish,
TaskType = stationManager.stationType == 1 ? (int)TaskInboundTypeEnum.Inbound : (int)TaskInboundTypeEnum.InTray,
TaskNum = await BaseDal.GetTaskNo(),
- Creater = "Systeam"
+ Creater = "Systeam",
+ ProductionLine = result.ProductionLine,
};
int lastStatus = locationInfo.LocationStatus;
ConsoleHelper.WriteSuccessLine($"淇敼鍓嶏細" + lastStatus.ToString());
@@ -532,7 +548,7 @@
var task = new Dt_Task
{
CurrentAddress = input.Position,
- Grade = 1,
+ Grade = 2,
Roadway = input.Roadways,
TargetAddress = stationManager.stationLocation,
Dispatchertime = DateTime.Now,
@@ -544,7 +560,8 @@
TaskState = (int)TaskOutStatusEnum.OutNew,
TaskType = (int)TaskOutboundTypeEnum.OutTray,
TaskNum = await BaseDal.GetTaskNo(),
- Creater = "Systeam"
+ Creater = "Systeam",
+ ProductionLine = stockinfo.ProductionLine,
};
return task;
@@ -635,7 +652,8 @@
TaskState = (int)TaskInStatusEnum.Line_InFinish,
TaskType = (int)TaskInboundTypeEnum.InTray,
TaskNum = await BaseDal.GetTaskNo(),
- Creater = "Systeam"
+ Creater = "Systeam",
+ ProductionLine = result.ProductionLine,
};
return Epmtytask;
}
@@ -695,7 +713,8 @@
TaskState = (int)TaskInStatusEnum.Line_InFinish,
TaskType = (int)TaskInboundTypeEnum.Inbound,
TaskNum = await BaseDal.GetTaskNo(),
- Creater = "Systeam"
+ Creater = "Systeam",
+ ProductionLine = result.ProductionLine,
};
var isBox = await _boxingInfoRepository.AddDataNavAsync(boxing);
@@ -859,7 +878,7 @@
var location = locations.OrderBy(x => x.Layer).ThenBy(x => x.Column).ThenBy(x => x.Row).FirstOrDefault();
- var stockInfo = await QueryStockInfoForEmptyTrayAsync("CWSC1");
+ var stockInfo = await QueryStockInfoForEmptyTrayFRAsync("CWSC1", "10086", taskDTO.ProductionLine);
if (stockInfo != null)
{
@@ -895,6 +914,43 @@
return content;
}
+ /// <summary>
+ /// 鏌ヨ绌虹洏搴撳瓨淇℃伅
+ /// </summary>
+ private async Task<DtStockInfo> QueryStockInfoForEmptyTrayFRAsync(string areaCode, string position, string productLine)
+ {
+ var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode);
+
+ ConsoleHelper.WriteColorLine(position + "..." + areaCode, ConsoleColor.Magenta);
+ var station = await _stationManagerRepository.QueryFirstAsync(x => x.stationChildCode == position && x.stationType == 17);
+
+ ConsoleHelper.WriteColorLine(station.Roadway, ConsoleColor.Magenta);
+ var stackers = station.Roadway.Split(',').ToList();
+
+
+ var devices = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>()
+ .Where(x => x.DeviceStatus == "1")
+ .Where(x => stackers.Contains(x.DeviceCode))
+ .ToList();
+
+ var deviceCode = devices.Select(x => x.DeviceCode).ToList();
+
+ var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>()
+ .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo
+ .Includes(x => x.StockInfoDetails) // 棰勫姞杞絊tockInfoDetails
+ .Where(x => x.ProductionLine == productLine)
+ .Where(x => x.AreaCode == areaCode && x.IsFull == false)
+ .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "绌烘墭鐩�"))
+ .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢
+ .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo))
+ .OrderBy(x => x.CreateDate) // 鎺掑簭
+ .FirstAsync(); // 杞崲涓哄垪琛�
+
+ //var firstOrDefault = result[0]; // 鏌ユ壘绗竴涓尮閰嶇殑鍏冪礌
+ //return firstOrDefault;
+ return result;
+ }
+
#endregion
public async Task<WebResponseContent> RequestOutTaskToBZAsync(RequestTaskDto json)
@@ -905,6 +961,7 @@
Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position && x.stationType == 12 && x.stationArea == "Call");
var stockInfo = _stockInfoRepository.Db.Queryable<DtStockInfo>()
+ .Where(x => x.ProductionLine == station.productLine)
.Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo
.Where(x => x.AreaCode == "CWSC3" && x.IsFull == true) // 杩囨护鏉′欢
.Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock) // 杩囨护鏉′欢
@@ -934,7 +991,8 @@
TaskState = (int)TaskOutStatusEnum.OutNew,
TaskType = (int)TaskOutboundTypeEnum.Outbound,
TaskNum = await BaseDal.GetTaskNo(),
- Creater = "Systeam"
+ Creater = "Systeam",
+ ProductionLine = stockInfo.ProductionLine,
};
WMSTaskDTO taskDTO = CreateTaskDTO(task);
--
Gitblit v1.9.3