From 6aa40d4e2c2375fba21d2bb3720a7933c56cf779 Mon Sep 17 00:00:00 2001 From: taoleite Date: Wed, 18 Jun 2025 16:57:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=85=A5=E5=BA=93=E4=B8=89?= =?UTF-8?q?=E4=B8=AA=E6=8E=A5=E5=8F=A3=E7=9A=84=E6=89=80=E6=9C=89=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/InputRequestController.cs | 160 +++++++++++++++++- Entities/MANAGE_MAIN.cs | 34 ++-- .../Implement/IoControlRouteRepository.cs | 7 + .../Implement/ManageMainRepository.cs | 6 +- .../Interface/IIoControlRouteRepository.cs | 8 +- 5 files changed, 187 insertions(+), 28 deletions(-) diff --git a/Controllers/InputRequestController.cs b/Controllers/InputRequestController.cs index 862ecb5..98386bd 100644 --- a/Controllers/InputRequestController.cs +++ b/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( /// /// 取消入库请求报文 [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; + } /// @@ -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; diff --git a/Entities/MANAGE_MAIN.cs b/Entities/MANAGE_MAIN.cs index 9d01a6f..2137d41 100644 --- a/Entities/MANAGE_MAIN.cs +++ b/Entities/MANAGE_MAIN.cs @@ -18,38 +18,38 @@ public class MANAGE_MAIN /// 终点 /// [Column("destinationId")] - public string DESTINATIONID { get; set; } + public string? DESTINATIONID { get; set; } /// /// 计划编号 /// [Column("PLAN_ID")] - public int PLAN_ID { get; set; } + public int? PLAN_ID { get; set; } /// /// 需求号 /// [Column("requestNumber")] - public string requestNumber { get; set; } + public string? requestNumber { get; set; } /// /// 任务类型编号 /// [Column("MANAGE_TYPE_CODE")] - public string MANAGE_TYPE_CODE { get; set; } + public string? MANAGE_TYPE_CODE { get; set; } /// /// 任务状态 /// [Column("MANAGE_STATUS")] - public string MANAGE_STATUS { get; set; } + public string? MANAGE_STATUS { get; set; } /// /// 托盘条码 /// [Column("STOCK_BARCODE")] - public string STOCK_BARCODE { get; set; } + public string? STOCK_BARCODE { get; set; } /// /// 物料尺寸 /// [Column("CELL_MODEL")] - public string CELL_MODEL { get; set; } + public string? CELL_MODEL { get; set; } /// /// 开始位置 /// @@ -64,37 +64,37 @@ public class MANAGE_MAIN /// 操作者 /// [Column("MANAGE_OPERATOR")] - public string MANAGE_OPERATOR { get; set; } + public string? MANAGE_OPERATOR { get; set; } /// /// 开始时间 /// [Column("MANAGE_BEGIN_TIME")] - public string MANAGE_BEGIN_TIME { get; set; } + public string? MANAGE_BEGIN_TIME { get; set; } /// /// 结束时间 /// [Column("MANAGE_END_TIME")] - public string MANAGE_END_TIME { get; set; } + public string? MANAGE_END_TIME { get; set; } /// /// 任务等级 /// [Column("MANAGE_LEVEL")] - public string MANAGE_LEVEL { get; set; } + public string? MANAGE_LEVEL { get; set; } /// /// 备注 /// [Column("MANAGE_REMARK")] - public string MANAGE_REMARK { get; set; } + public string? MANAGE_REMARK { get; set; } /// /// 机械有问题请求保持 /// [Column("keepRequestInMemoryEvenIfMechanicalIssue")] - public bool keepRequestInMemoryEvenIfMechanicalIssue { get; set; } + public bool? keepRequestInMemoryEvenIfMechanicalIssue { get; set; } /// /// 缺少产品持续叫料 /// [Column("keepRequestInMemoryEvenIfLackOfProductIssue")] - public bool keepRequestInMemoryEvenIfLackOfProductIssue { get; set; } + public bool? keepRequestInMemoryEvenIfLackOfProductIssue { get; set; } /// /// 目标出库时间 /// @@ -104,17 +104,17 @@ public class MANAGE_MAIN /// 批次号 /// [Column("LOTNUMBER")] - public string LOTNUMBER { get; set; } + public string? LOTNUMBER { get; set; } ///// /// 产品类型 /// [Column("POPULATIONNUMBER")] - public string POPULATIONNUMBER { get; set; } + public string? POPULATIONNUMBER { get; set; } /// /// 调用接口 /// [Column("INTERFACE")] - public string INTERFACE { get; set; } + public string? INTERFACE { get; set; } } \ No newline at end of file diff --git a/Repositories/Implement/IoControlRouteRepository.cs b/Repositories/Implement/IoControlRouteRepository.cs index 6181590..f1f4004 100644 --- a/Repositories/Implement/IoControlRouteRepository.cs +++ b/Repositories/Implement/IoControlRouteRepository.cs @@ -21,4 +21,11 @@ public class IoControlRouteRepository(MichelinDbContext context, ILogger GetEnableControlRoutes(string startDeviceCode, string endDeviceCode) + { + //查看起点终点之间是否有可用路径 + List getAvailableControlRoutes = context.IoControlRoute.Where(x => x.START_DEVICE == startDeviceCode && x.END_DEVICE == endDeviceCode && x.CONTROL_ROUTE_STATUS == 1).ToList()!; + return getAvailableControlRoutes; + } + } \ No newline at end of file diff --git a/Repositories/Implement/ManageMainRepository.cs b/Repositories/Implement/ManageMainRepository.cs index cbe6326..f6b1cad 100644 --- a/Repositories/Implement/ManageMainRepository.cs +++ b/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; } diff --git a/Repositories/Interface/IIoControlRouteRepository.cs b/Repositories/Interface/IIoControlRouteRepository.cs index a660e02..b81c85e 100644 --- a/Repositories/Interface/IIoControlRouteRepository.cs +++ b/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 GetEnableControlRoutes(string startDeviceCode, string endDeviceCode); } \ No newline at end of file