@ -8,6 +8,7 @@ using WMS_GIRAF_Interface.Entities;
using WMS_GIRAF_Interface.Models ;
using WMS_GIRAF_Interface.Models ;
using WMS_GIRAF_Interface.Repositories.Interface ;
using WMS_GIRAF_Interface.Repositories.Interface ;
using WMS_GIRAF_Interface.TaskServices ;
using WMS_GIRAF_Interface.TaskServices ;
using Newtonsoft.Json ;
namespace WMS_GIRAF_Interface.Controllers
namespace WMS_GIRAF_Interface.Controllers
{
{
@ -34,6 +35,8 @@ namespace WMS_GIRAF_Interface.Controllers
{
{
bool bResult = true ;
bool bResult = true ;
string sResult = string . Empty ;
string sResult = string . Empty ;
Log . Information ( $"{nameof(OutputRequestByProductIds)} Received new request:{JsonConvert.SerializeObject(outputRequest)}" ) ;
OutputRequestByProductIdsReturn returnJsonString = new OutputRequestByProductIdsReturn ( ) ;
OutputRequestByProductIdsReturn returnJsonString = new OutputRequestByProductIdsReturn ( ) ;
if ( outputRequest ! = null )
if ( outputRequest ! = null )
{
{
@ -171,11 +174,12 @@ namespace WMS_GIRAF_Interface.Controllers
{
{
bool bResult = true ;
bool bResult = true ;
string sResult = string . Empty ;
string sResult = string . Empty ;
Log . Information ( $"{nameof(OutputRequestBySku)} Received new request:{JsonConvert.SerializeObject(outputRequest)}" ) ;
OutputRequestBySkuReturn returnJsonString = new OutputRequestBySkuReturn ( ) ;
OutputRequestBySkuReturn returnJsonString = new OutputRequestBySkuReturn ( ) ;
if ( outputRequest ! = null )
if ( outputRequest ! = null )
{
{
//先判断当前sku是否有可用库存,然后筛选出库,如果没有的话就就启用备用sku的库存出库
//先判断当前sku是否有可用库存,然后筛选出库,如果没有的话就就启用备用sku的库存出库
if ( context . V_StorageList . FromSqlRaw ( $"SELECT TOP 1 STOCK_BARCODE FROM V_STORAGE_LIST WHERE requestNumber = '{outputRequest.outputRequestId}'" ) . ToList ( ) . Count > 0 )
if ( context . V_StorageList . FromSqlRaw ( $"SELECT TOP 1 * FROM V_STORAGE_LIST WHERE requestNumber = '{outputRequest.outputRequestId}'" ) . ToList ( ) . Count > 0 )
{
{
returnJsonString . status = "0" ;
returnJsonString . status = "0" ;
returnJsonString . evacuationPost = string . Empty ;
returnJsonString . evacuationPost = string . Empty ;
@ -200,7 +204,7 @@ namespace WMS_GIRAF_Interface.Controllers
//无需筛选巷道状态,直接选择可用轮胎,只需考虑availableEvacuationPosts即可,筛选lane_way
//无需筛选巷道状态,直接选择可用轮胎,只需考虑availableEvacuationPosts即可,筛选lane_way
#region outlevel 4/3/2/1/0
#region outlevel 4/3/2/1/0
var poolNumber = string . Empty ;
var poolNumber = string . Empty ;
string queryStringForLevel1234 = $ @ "SELECT TOP 1 STORAGE_ID,WAREHOUSE_CODE FROM V_STORAGE_LIST
string queryStringForLevel1234 = $ @ "SELECT TOP 1 * FROM V_STORAGE_LIST
WHERE RUN_STATUS = ' Enable '
WHERE RUN_STATUS = ' Enable '
AND ( requestNumber IS NULL OR requestNumber = ' ' )
AND ( requestNumber IS NULL OR requestNumber = ' ' )
AND IsBlocked = { ( outputRequest . productIsBlocked ? 1 : 0 ) }
AND IsBlocked = { ( outputRequest . productIsBlocked ? 1 : 0 ) }
@ -218,7 +222,7 @@ namespace WMS_GIRAF_Interface.Controllers
poolNumber = checkHighPriorityTire [ 0 ] . WAREHOUSE_CODE ;
poolNumber = checkHighPriorityTire [ 0 ] . WAREHOUSE_CODE ;
if ( storageId ! = 0 & & storageId ! = null )
if ( storageId ! = 0 & & storageId ! = null )
{
{
var getStorageMain = storageMainRepository . GetStorageMain ( "S torageId" , storageId . ToString ( ) ) ;
var getStorageMain = storageMainRepository . GetStorageMain ( "s torageId" , storageId . ToString ( ) ) ;
if ( getStorageMain ! = null )
if ( getStorageMain ! = null )
{
{
@ -255,7 +259,7 @@ namespace WMS_GIRAF_Interface.Controllers
{
{
//未找到当前库存信息
//未找到当前库存信息
//查看level为0的库存信息
//查看level为0的库存信息
var checkLowPriorityTire = $ @ "SELECT STORAGE_ID,WAREHOUSE_CODE FROM V_STORAGE_LIST
var checkLowPriorityTire = $ @ "SELECT * FROM V_STORAGE_LIST
WHERE RUN_STATUS = ' Enable '
WHERE RUN_STATUS = ' Enable '
AND OutLevel = 0
AND OutLevel = 0
AND IsBlocked = 0
AND IsBlocked = 0
@ -273,7 +277,7 @@ namespace WMS_GIRAF_Interface.Controllers
if ( storageId ! = 0 & & storageId ! = null )
if ( storageId ! = 0 & & storageId ! = null )
{
{
var storageMain = storageMainRepository . GetStorageMain ( "ID " , storageId . ToString ( ) ) ;
var storageMain = storageMainRepository . GetStorageMain ( "storageId " , storageId . ToString ( ) ) ;
if ( storageMain ! = null )
if ( storageMain ! = null )
{
{
storageMain . requestNumber = outputRequest . outputRequestId ;
storageMain . requestNumber = outputRequest . outputRequestId ;
@ -323,6 +327,13 @@ namespace WMS_GIRAF_Interface.Controllers
KeepRequestInMemoryEvenIfLackOfProductIssue = true
KeepRequestInMemoryEvenIfLackOfProductIssue = true
} ;
} ;
context . Manage_Detail . Add ( manageDetail ) ;
context . Manage_Detail . Add ( manageDetail ) ;
context . SaveChanges ( ) ;
bResult = true ;
returnJsonString . status = "1" ;
returnJsonString . evacuationPost = outputRequest . evacuationPost ;
returnJsonString . estimatedExitTime = DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) ;
returnJsonString . errorDetails = string . Empty ;
Log . Information ( $" Create manage_detail task completed! the detail list :{JsonConvert.SerializeObject(manageDetail)} " ) ;
}
}
@ -340,16 +351,96 @@ namespace WMS_GIRAF_Interface.Controllers
return returnJsonString ;
return returnJsonString ;
}
}
/// <summary>
/// 修改任务信息
/// </summary>
/// <param name="updateOutputRequest"></param>
[HttpPut]
[HttpPut]
public void UpdateOutputRequest ( UpdateOutputRequest . RootObjectForUpdateOutputRequest updateOutputRequest )
public UpdateOutputRequestReturn UpdateOutputRequest ( UpdateOutputRequest . RootObjectForUpdateOutputRequest ? updateOutputRequest )
{
{
Log . Information ( $"{nameof(UpdateOutputRequest)} Received new request:{JsonConvert.SerializeObject(updateOutputRequest)}" ) ;
if ( updateOutputRequest ! = null )
{
if ( ! string . IsNullOrEmpty ( updateOutputRequest . outputRequestId ) )
{
var checkTask =
manageMainRepository . GetManageMain ( "requestId" , updateOutputRequest . outputRequestId ) ;
if ( checkTask ! = null )
{
//更新信息
checkTask . TargetOutputDateInUtc = updateOutputRequest . expectedCompletionDate ;
manageMainRepository . UpdateManageMain ( checkTask ) ;
Log . Information ( $"update output request : TargetOutputDateInUtc new is {updateOutputRequest.expectedCompletionDate};" ) ;
return new UpdateOutputRequestReturn
{
status = "1" ,
errorDetails = null
} ;
}
else
{
//无任务情况下,
return new UpdateOutputRequestReturn
{
status = "5" ,
errorDetails = "OutputRequestAlreadyPerformed"
} ;
}
}
else
{
//任务ID为空
return new UpdateOutputRequestReturn ( )
{
status = "2" ,
errorDetails = "UnknownOutputRequestId"
} ;
}
}
else
{
//报错,入参为空
return new UpdateOutputRequestReturn ( )
{
status = "0" ,
errorDetails = "RefusedBecauseEmptyInputParameter"
} ;
}
}
}
/// <summary>
/// 取消任务
/// </summary>
/// <param name="cancelOutputRequest"></param>
[HttpPost("Cancel")]
[HttpPost("Cancel")]
public void CancelOutputRequest ( CancelOutputRequest . RootObjectForCancelOutputRequest cancelOutputRequest )
public CancelOutputRequestReturn CancelOutputRequest ( CancelOutputRequest . RootObjectForCancelOutputRequest ? cancelOutputRequest )
{
{
Log . Information ( $"{nameof(CancelOutputRequest)} Received new request:{JsonConvert.SerializeObject(cancelOutputRequest)}" ) ;
if ( cancelOutputRequest ! = null )
{
if ( ! string . IsNullOrEmpty ( cancelOutputRequest . ouputRequestId ) )
{
}
else
{
//requestID 为空
return new CancelOutputRequestReturn
{
status = "2" ,
errorDetails = "RefusedBecauseEmptyOutputRequestID"
} ;
}
}
else
{
return new CancelOutputRequestReturn
{
status = "0" ,
errorDetails = "RefusedBecauseEmptyInputParameter"
} ;
}
}
}
}
}
}
}