Browse Source

完成入库三个接口的所有测试工作

master
taoleite 1 day ago
parent
commit
6aa40d4e2c
  1. 160
      Controllers/InputRequestController.cs
  2. 34
      Entities/MANAGE_MAIN.cs
  3. 7
      Repositories/Implement/IoControlRouteRepository.cs
  4. 6
      Repositories/Implement/ManageMainRepository.cs
  5. 8
      Repositories/Interface/IIoControlRouteRepository.cs

160
Controllers/InputRequestController.cs

@ -22,6 +22,7 @@ public class InputRequestController(
IWhCellRepository whCellRepository,
IProductInformationRepository productInformationRepository,
IIoControlRepository ioControlRepository,
IIoControlRouteRepository ioControlRouteRepository,
CellLogicService cellLogicService)
: ControllerBase
{
@ -310,11 +311,158 @@ public class InputRequestController(
/// </summary>
/// <param name="itemDropped">取消入库请求报文</param>
[HttpPost("ItemDropped")]
public void GetItemDroppedFromGiraf(ItemDropped.RootObjectForItemDropped itemDropped)
public ItemDroppedReturn.RootObjectForItemDroppedReturn GetItemDroppedFromGiraf(ItemDropped.RootObjectForItemDropped? itemDropped)
{
//TODO:获取轮胎post信息,并进行更新
//TODO:获取轮胎新的introduction post信息,并进行更新
var itemDroppedReturn = new ItemDroppedReturn.RootObjectForItemDroppedReturn();
if (itemDropped!=null)
{
if (!string.IsNullOrEmpty(itemDropped.inputRequestId))
{
if (!string.IsNullOrEmpty(itemDropped.introductionPost))
{
//判断当前request ID是否有任务存在
var checkManageMain = manageMainRepository.GetManageMain("requestNumber", itemDropped.inputRequestId);
if (checkManageMain is { MANAGE_STATUS: "WaitingSend", MANAGE_TYPE_CODE: "ManageLineMove" })
{
//判断当前的任务起点是否为报文给出位置
if (checkManageMain.START_CELL_ID!=0)
{
var startCell = whCellRepository.GetCell(checkManageMain.START_CELL_ID);
if (startCell!=null)
{
if (startCell.CELL_CODE!=itemDropped.introductionPost)
{
//获取新的post的信息,然后更新任务信息
var newCell = whCellRepository.GetCell(itemDropped.introductionPost);
if (newCell!=null)
{
var endCell = whCellRepository.GetCell(checkManageMain.END_CELL_ID);
if (endCell != null)
{
//检查新的post与终点巷道是否有路径可用;
var getRoutes =
ioControlRouteRepository.GetEnableControlRoutes(newCell.CELL_CODE,
endCell.CELL_CODE);
if (getRoutes is{ Count:>0 })
{
//有课+-\
checkManageMain.START_CELL_ID = newCell.CELL_ID;
checkManageMain.MANAGE_BEGIN_TIME =
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
manageMainRepository.UpdateManageMain(checkManageMain);
itemDroppedReturn.status = "1";
itemDroppedReturn.errorDetails = null;
Log.Information($"{checkManageMain.STOCK_BARCODE} Item Dropped at {newCell.CELL_CODE},end lane way :{endCell.CELL_CODE} ");
}
else
{
//当前新起点无法到达指定终点巷道
itemDroppedReturn.status = "0";
itemDroppedReturn.errorDetails = $"the introduction post{newCell.CELL_CODE} can not reach the line{endCell.CELL_CODE}";
Log.Error($"requestId :{itemDropped.inputRequestId}; Error details:+ the introduction post{newCell.CELL_CODE} can not reach the line{endCell.CELL_CODE}");
}
}
else
{
//出库站台信息为空
itemDroppedReturn.status = "0";
itemDroppedReturn.errorDetails = $"Error details: the task have errors, the end line ID ({checkManageMain.END_CELL_ID}) can not get info from WMS ";
Log.Error(itemDroppedReturn.errorDetails);
}
}
else
{
//报错:未查到新post信息
itemDroppedReturn.status = "2";
itemDroppedReturn.errorDetails = $"Error details: the task have errors, the new Post ID ({itemDropped.introductionPost}) can not get info from WMS";
Log.Error(itemDroppedReturn.errorDetails);
}
}
else
{
//如果相等不做任何更改
itemDroppedReturn.status = "4";
itemDroppedReturn.errorDetails = null;
Log.Information($"{checkManageMain.STOCK_BARCODE} Item Dropped already done");
}
}
else
{
//起始站台信息不为空
itemDroppedReturn.status = "0";
itemDroppedReturn.errorDetails = $"Error details: the task have errors, the start post ID ({checkManageMain.START_CELL_ID}) can not get info from WMS ";
Log.Error(itemDroppedReturn.errorDetails);
}
}
else
{
//起始站台id不为空
itemDroppedReturn.status = "0";
itemDroppedReturn.errorDetails = $"Error details: the task have errors, the start post ID ({checkManageMain.START_CELL_ID}) is null";
Log.Error(itemDroppedReturn.errorDetails);
}
}
else
{
//无任务或者任务已经执行
if (checkManageMain==null)
{
itemDroppedReturn.status = "3";
itemDroppedReturn.errorDetails = $"Error details: the task didn't find, the request ID ({itemDropped.inputRequestId}) can not find corresponding task";
Log.Error(itemDroppedReturn.errorDetails);
}
else if(checkManageMain.MANAGE_STATUS!="WaitingSend")
{
itemDroppedReturn.status = "0";
itemDroppedReturn.errorDetails = $"Error details: the task ({itemDropped.inputRequestId}) is already running. ";
Log.Error(itemDroppedReturn.errorDetails);
}
else if(checkManageMain.MANAGE_TYPE_CODE!="ManageLineMove")
{
itemDroppedReturn.status = "0";
itemDroppedReturn.errorDetails = $"Error details: the task ({itemDropped.inputRequestId}) type code is not right. the task type code is {checkManageMain.MANAGE_TYPE_CODE} ";
Log.Error(itemDroppedReturn.errorDetails);
}
}
}
else
{
//introduction post为空
itemDroppedReturn.status = "2";
itemDroppedReturn.errorDetails = $"Error details: the task have errors, the new Post ID ({itemDropped.introductionPost}) is null";
Log.Error(itemDroppedReturn.errorDetails);
}
}
else
{
//requestId为空
itemDroppedReturn.status = "0";
itemDroppedReturn.errorDetails = $"Error details: the task have errors, the request ID ({itemDropped.inputRequestId}) is null";
Log.Error(itemDroppedReturn.errorDetails);
}
}
else
{
//报文为空
itemDroppedReturn.status = "0";
itemDroppedReturn.errorDetails = $"Error details: the task have errors, the request ID ({itemDropped.inputRequestId}) is null";
Log.Error(itemDroppedReturn.errorDetails);
}
//返回信息
return itemDroppedReturn;
}
/// <summary>
@ -328,7 +476,7 @@ public class InputRequestController(
//TODO:取消入库请求,如果已经到入库口,无法进行取消
//根据requestNumber获取入库信息
CancelInputRequestReturn returnJson = new CancelInputRequestReturn();
if (inputRequest!=null && string.IsNullOrEmpty(inputRequest.inputRequestId) )
if (inputRequest!=null && !string.IsNullOrEmpty(inputRequest.inputRequestId) )
{
var inputTaskInfo = manageMainRepository.GetManageMain("requestNumber", inputRequest.inputRequestId);
if (inputTaskInfo != null)
@ -337,7 +485,7 @@ public class InputRequestController(
var checkIoControlTask = ioControlRepository.GetIoControlTaskByManageId(inputTaskInfo.MANAGE_ID);
if (checkIoControlTask != null)
{
//不可以删除当前任务
//不可以删除当前任务;或者通过调度来删除任务
returnJson.status = "3";
returnJson.errorDetails = "this task has been already in progress,it cannot be deleted ";
Log.Error($"cannot delete input task [{inputTaskInfo.STOCK_BARCODE}] already have task {inputTaskInfo.STOCK_BARCODE};");
@ -363,8 +511,8 @@ public class InputRequestController(
{
//传入数据位null
returnJson.status = "2";
returnJson.errorDetails = "CancelInputRequest:WMS can not get the json string ";
Log.Error(returnJson.errorDetails);
returnJson.errorDetails = "The input json string is null ";
Log.Error( returnJson.errorDetails);
}
return returnJson;

34
Entities/MANAGE_MAIN.cs

@ -18,38 +18,38 @@ public class MANAGE_MAIN
/// 终点
///</sumary>
[Column("destinationId")]
public string DESTINATIONID { get; set; }
public string? DESTINATIONID { get; set; }
///<sumary>
/// 计划编号
///</sumary>
[Column("PLAN_ID")]
public int PLAN_ID { get; set; }
public int? PLAN_ID { get; set; }
///<sumary>
/// 需求号
///</sumary>
[Column("requestNumber")]
public string requestNumber { get; set; }
public string? requestNumber { get; set; }
///<sumary>
/// 任务类型编号
///</sumary>
[Column("MANAGE_TYPE_CODE")]
public string MANAGE_TYPE_CODE { get; set; }
public string? MANAGE_TYPE_CODE { get; set; }
///<sumary>
/// 任务状态
///</sumary>
[Column("MANAGE_STATUS")]
public string MANAGE_STATUS { get; set; }
public string? MANAGE_STATUS { get; set; }
///<sumary>
/// 托盘条码
///</sumary>
[Column("STOCK_BARCODE")]
public string STOCK_BARCODE { get; set; }
public string? STOCK_BARCODE { get; set; }
///<sumary>
/// 物料尺寸
///</sumary>
[Column("CELL_MODEL")]
public string CELL_MODEL { get; set; }
public string? CELL_MODEL { get; set; }
///<sumary>
/// 开始位置
///</sumary>
@ -64,37 +64,37 @@ public class MANAGE_MAIN
/// 操作者
///</sumary>
[Column("MANAGE_OPERATOR")]
public string MANAGE_OPERATOR { get; set; }
public string? MANAGE_OPERATOR { get; set; }
///<sumary>
/// 开始时间
///</sumary>
[Column("MANAGE_BEGIN_TIME")]
public string MANAGE_BEGIN_TIME { get; set; }
public string? MANAGE_BEGIN_TIME { get; set; }
///<sumary>
/// 结束时间
///</sumary>
[Column("MANAGE_END_TIME")]
public string MANAGE_END_TIME { get; set; }
public string? MANAGE_END_TIME { get; set; }
///<sumary>
/// 任务等级
///</sumary>
[Column("MANAGE_LEVEL")]
public string MANAGE_LEVEL { get; set; }
public string? MANAGE_LEVEL { get; set; }
///<sumary>
/// 备注
///</sumary>
[Column("MANAGE_REMARK")]
public string MANAGE_REMARK { get; set; }
public string? MANAGE_REMARK { get; set; }
///<sumary>
/// 机械有问题请求保持
///</sumary>
[Column("keepRequestInMemoryEvenIfMechanicalIssue")]
public bool keepRequestInMemoryEvenIfMechanicalIssue { get; set; }
public bool? keepRequestInMemoryEvenIfMechanicalIssue { get; set; }
///<sumary>
/// 缺少产品持续叫料
///</sumary>
[Column("keepRequestInMemoryEvenIfLackOfProductIssue")]
public bool keepRequestInMemoryEvenIfLackOfProductIssue { get; set; }
public bool? keepRequestInMemoryEvenIfLackOfProductIssue { get; set; }
/// <summary>
/// 目标出库时间
/// </summary>
@ -104,17 +104,17 @@ public class MANAGE_MAIN
/// 批次号
/// </summary>
[Column("LOTNUMBER")]
public string LOTNUMBER { get; set; }
public string? LOTNUMBER { get; set; }
///// <summary>
/// 产品类型
/// </summary>
[Column("POPULATIONNUMBER")]
public string POPULATIONNUMBER { get; set; }
public string? POPULATIONNUMBER { get; set; }
///<sumary>
/// 调用接口
///</sumary>
[Column("INTERFACE")]
public string INTERFACE { get; set; }
public string? INTERFACE { get; set; }
}

7
Repositories/Implement/IoControlRouteRepository.cs

@ -21,4 +21,11 @@ public class IoControlRouteRepository(MichelinDbContext context, ILogger<ManageM
}
}
public List<IO_CONTROL_ROUTE?> GetEnableControlRoutes(string startDeviceCode, string endDeviceCode)
{
//查看起点终点之间是否有可用路径
List<IO_CONTROL_ROUTE?> getAvailableControlRoutes = context.IoControlRoute.Where(x => x.START_DEVICE == startDeviceCode && x.END_DEVICE == endDeviceCode && x.CONTROL_ROUTE_STATUS == 1).ToList()!;
return getAvailableControlRoutes;
}
}

6
Repositories/Implement/ManageMainRepository.cs

@ -56,10 +56,10 @@ public class ManageMainRepository: IManageMainRepository
_context.Manage_Main.Add(manageMain);
_context.SaveChanges();
_logger.LogInformation($"Catch Manage main info({manageMain.STOCK_BARCODE});");
var managemain = _context.Manage_Main.Where(x => x.STOCK_BARCODE == manageMain.STOCK_BARCODE).AsNoTracking().FirstOrDefault();
if (managemain != null)
MANAGE_MAIN? checkManageMain = _context.Manage_Main.FirstOrDefault(x => x.STOCK_BARCODE == manageMain.STOCK_BARCODE);
if (checkManageMain != null)
{
manageId = managemain.MANAGE_ID;
manageId = checkManageMain.MANAGE_ID;
}
return true;
}

8
Repositories/Interface/IIoControlRouteRepository.cs

@ -1,6 +1,10 @@
namespace WMS_GIRAF_Interface.Repositories.Interface;
using WMS_GIRAF_Interface.Entities;
namespace WMS_GIRAF_Interface.Repositories.Interface;
public interface IIoControlRouteRepository
{
public IO_CONTROL_ROUTE? GetIoControlRoute(int? lineNumber);
public List<IO_CONTROL_ROUTE?> GetEnableControlRoutes(string startDeviceCode, string endDeviceCode);
}
Loading…
Cancel
Save