|
|
@ -2,6 +2,7 @@ |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Microsoft.Identity.Client.Extensions.Msal; |
|
|
|
using System.Drawing; |
|
|
|
using Serilog; |
|
|
|
using WMS_GIRAF_Interface.Data; |
|
|
|
using WMS_GIRAF_Interface.Entities; |
|
|
|
using WMS_GIRAF_Interface.Models; |
|
|
@ -197,9 +198,9 @@ namespace WMS_GIRAF_Interface.Controllers |
|
|
|
{ |
|
|
|
//tlt:根据SKu来筛选物料信息
|
|
|
|
//无需筛选巷道状态,直接选择可用轮胎,只需考虑availableEvacuationPosts即可,筛选lane_way
|
|
|
|
#region outlevel 4/3/2/1
|
|
|
|
|
|
|
|
string temp = $@"SELECT TOP 1 STORAGE_ID FROM V_STORAGE_LIST
|
|
|
|
#region outlevel 4/3/2/1/0
|
|
|
|
var poolNumber = string.Empty; |
|
|
|
string queryStringForLevel1234 = $@"SELECT TOP 1 STORAGE_ID,WAREHOUSE_CODE FROM V_STORAGE_LIST
|
|
|
|
WHERE RUN_STATUS = 'Enable' |
|
|
|
AND (requestNumber IS NULL OR requestNumber = '') |
|
|
|
AND IsBlocked = {(outputRequest.productIsBlocked ? 1 : 0)} |
|
|
@ -208,39 +209,124 @@ namespace WMS_GIRAF_Interface.Controllers |
|
|
|
AND Lane_way IN ({string.Join(",", outputRequest.availableEvacuationPosts)}) |
|
|
|
ORDER BY OutLevel DESC , HdvDateTimeInUtc";
|
|
|
|
|
|
|
|
var checkHighPriorityTire = context.V_StorageList.FromSqlRaw( |
|
|
|
$@"SELECT TOP 1 STORAGE_ID FROM V_STORAGE_LIST
|
|
|
|
WHERE RUN_STATUS = 'Enable' |
|
|
|
AND (requestNumber IS NULL OR requestNumber = '') |
|
|
|
AND IsBlocked = {(outputRequest.productIsBlocked ? 1 : 0)} |
|
|
|
AND LOTNUMBER = '{outputRequest.sku}' |
|
|
|
AND PopulationNumber = '{outputRequest.productClass}' |
|
|
|
AND Lane_way IN ({string.Join(",",outputRequest.availableEvacuationPosts)}) |
|
|
|
ORDER BY OutLevel DESC , HdvDateTimeInUtc").ToList();
|
|
|
|
var checkHighPriorityTire = context.V_StorageList.FromSqlRaw(queryStringForLevel1234).ToList(); |
|
|
|
|
|
|
|
if (checkHighPriorityTire.Count > 0) |
|
|
|
{ |
|
|
|
//选择当前的可用的轮胎,更新需求号
|
|
|
|
var storageId = checkHighPriorityTire[0].STORAGE_ID; |
|
|
|
poolNumber = checkHighPriorityTire[0].WAREHOUSE_CODE; |
|
|
|
if (storageId != 0 && storageId !=null) |
|
|
|
{ |
|
|
|
var getStorageMain = storageMainRepository.GetStorageMain("StorageId", storageId.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
if (getStorageMain != null) |
|
|
|
{ |
|
|
|
getStorageMain.requestNumber = outputRequest.outputRequestId; |
|
|
|
storageMainRepository.UpdateStorageMain(getStorageMain); |
|
|
|
Log.Information($"Level1234 Update storage main info({getStorageMain.STOCK_BARCODE}) request number:{outputRequest.outputRequestId};"); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//未查询到当前的库存信息
|
|
|
|
bResult = false; |
|
|
|
returnJsonString.status = "0"; |
|
|
|
returnJsonString.evacuationPost = string.Empty; |
|
|
|
returnJsonString.estimatedExitTime = string.Empty; |
|
|
|
returnJsonString.errorDetails = "RefusedBecauseUnknownStorageInfo"; |
|
|
|
Log.Error($"Level1234 Update storage main failed: can not get storage main info; request number:{outputRequest.outputRequestId};"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//未获取storage
|
|
|
|
bResult = false; |
|
|
|
returnJsonString.status = "0"; |
|
|
|
returnJsonString.evacuationPost = string.Empty; |
|
|
|
returnJsonString.estimatedExitTime = string.Empty; |
|
|
|
returnJsonString.errorDetails = "Level1234 RefusedBecauseUnknownStorage ;storage info equal to 0 or null "; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
{ |
|
|
|
//未找到当前库存信息
|
|
|
|
//查看level为0的库存信息
|
|
|
|
var checkLowPriorityTire = $@"SELECT STORAGE_ID,WAREHOUSE_CODE FROM V_STORAGE_LIST
|
|
|
|
WHERE RUN_STATUS = 'Enable' |
|
|
|
AND OutLevel = 0 |
|
|
|
AND IsBlocked = 0 |
|
|
|
AND ( requestNumber IS NULL OR requestNumber = '' ) |
|
|
|
AND GETUTCDate() > DryDateTimeInUtc |
|
|
|
AND LOTNUMBER = '{outputRequest.sku}' |
|
|
|
AND populationNumber = '{outputRequest.productClass}' |
|
|
|
AND LANE_WAY IN({string.Join(",", outputRequest.availableEvacuationPosts)}) |
|
|
|
ORDER BY HdvDateTimeInUtc,PRIORITY,CELL_X,CELL_Y DESC";
|
|
|
|
var level0TireList = context.V_StorageList.FromSqlRaw(checkLowPriorityTire).ToList(); |
|
|
|
if (level0TireList is { Count: >0}) |
|
|
|
{ |
|
|
|
var storageId = level0TireList[0].STORAGE_ID; |
|
|
|
poolNumber = level0TireList[0].WAREHOUSE_CODE; |
|
|
|
if (storageId!=0 && storageId!=null) |
|
|
|
{ |
|
|
|
|
|
|
|
var storageMain = storageMainRepository.GetStorageMain("ID", storageId.ToString()); |
|
|
|
if (storageMain != null) |
|
|
|
{ |
|
|
|
storageMain.requestNumber = outputRequest.outputRequestId; |
|
|
|
storageMainRepository.UpdateStorageMain(storageMain); |
|
|
|
Log.Information($"Level0 Update storage main info({storageMain.STOCK_BARCODE}) request number:{outputRequest.outputRequestId};"); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//未查询到当前的库存信息
|
|
|
|
bResult = false; |
|
|
|
returnJsonString.status = "0"; |
|
|
|
returnJsonString.evacuationPost = string.Empty; |
|
|
|
returnJsonString.estimatedExitTime = string.Empty; |
|
|
|
returnJsonString.errorDetails = "RefusedBecauseUnknownStorageInfo"; |
|
|
|
Log.Error($"Level0 Update storage main failed: can not get storage main info; request number:{outputRequest.outputRequestId};"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//未获取storage
|
|
|
|
bResult = false; |
|
|
|
returnJsonString.status = "0"; |
|
|
|
returnJsonString.evacuationPost = string.Empty; |
|
|
|
returnJsonString.estimatedExitTime = string.Empty; |
|
|
|
returnJsonString.errorDetails = "RefusedBecauseUnknownStorage"; |
|
|
|
Log.Information($" Level0 RefusedBecauseUnknownStorage ;storage info equal to 0 or null "); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
if (bResult) |
|
|
|
{ |
|
|
|
//添加出库轮询信息到数据库中
|
|
|
|
MANAGE_DETAIL manageDetail = new MANAGE_DETAIL() |
|
|
|
{ |
|
|
|
requestNumber = outputRequest.outputRequestId, |
|
|
|
destinationId = outputRequest.evacuationPost, |
|
|
|
lotNumber = outputRequest.sku, |
|
|
|
populationNumber = outputRequest.productClass, |
|
|
|
poolNumber = poolNumber, |
|
|
|
targetOutputDateInUtc = Convert.ToDateTime(outputRequest.expectedCompletionDate), |
|
|
|
keepRequestInMemoryEvenIfMechanicalIssue = true, |
|
|
|
KeepRequestInMemoryEvenIfLackOfProductIssue = true |
|
|
|
}; |
|
|
|
context.Manage_Detail.Add(manageDetail); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|