From 060fec29c6beddaa8fa0d9e66b66da9fe33a79d0 Mon Sep 17 00:00:00 2001 From: Wen JY Date: Thu, 25 Jan 2024 17:56:48 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=B8=8A=E8=BE=85=E6=9C=BA?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac/Controllers/IngCheckController.cs | 75 ++++++++++++--------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/SlnMesnac/Controllers/IngCheckController.cs b/SlnMesnac/Controllers/IngCheckController.cs index 1d9ef93..4505914 100644 --- a/SlnMesnac/Controllers/IngCheckController.cs +++ b/SlnMesnac/Controllers/IngCheckController.cs @@ -1,6 +1,7 @@ using System.Text.Json; using Microsoft.AspNetCore.Mvc; using SlnMesnac.Config; +using SlnMesnac.Model.domain; using SlnMesnac.Model.dto; using SlnMesnac.Plc; using SlnMesnac.Repository.service; @@ -49,48 +50,58 @@ public class IngCheckController var result = new ApiResponse(); try { - if (ingredientInfo != null) + do { + if (ingredientInfo == null) + { + result.SetSuccess($"上辅机校验失败,缺少必要参数,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + break; + } + _logger.LogInformation($"上辅机验证参数:{JsonSerializer.Serialize(ingredientInfo)}"); - var mcsInfo = _mcsBinToMaterService.GetMcsBinToMaterByBinNo(1, ingredientInfo.CanNumber); - if (mcsInfo != null) + + McsBinToMater mcsInfo = _mcsBinToMaterService.GetMcsBinToMaterByBinNo(1, ingredientInfo.CanNumber); + if (mcsInfo == null) { - var wmsInfo = _wmsTaskOutService.GetWmsTaskOutBySerialNum(ingredientInfo.MaterialBarcode); + result.SetFailure($"上辅机校验失败,根据料罐获取对应信息为空,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + break; + } + + WmsTaskOut wmsInfo = _wmsTaskOutService.GetWmsTaskOutBySerialNum(ingredientInfo.MaterialBarcode); + if (wmsInfo == null) + { + result.SetFailure($"上辅机校验失败,根据物料条码获取物料信息为空,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + break; + } - if (mcsInfo.MatCode.Contains(wmsInfo.MaterNo)) + if (mcsInfo.MatCode.Contains(wmsInfo.MaterNo)) + { + result.SetSuccess($"上辅机校验成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + } + else + { + result.SetFailure($"上辅机校验失败,物料不匹配,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + break; + } + + if (ingredientInfo.IsOpen == 1) + { + var openFlag = _plcPool.GetPlcByKey("mcs").writeInt32ByAddress(_appConfig.mcsOpenAddr,ingredientInfo.CanNumber); + if (openFlag) { - result.SetSuccess($"上辅机校验成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); - - if (ingredientInfo.IsOpen == 1) - { - var openFlag = _plcPool.GetPlcByKey("mcs").writeInt32ByAddress(_appConfig.mcsOpenAddr,ingredientInfo.CanNumber); - if (openFlag) - { - _logger.LogInformation($"上辅机开仓指令下发成功!"); - } - else - { - _logger.LogError("上辅机开仓指令下发失败"); - } - } - - //保存数据 + _logger.LogInformation($"上辅机开仓指令下发成功!"); + result.SetSuccess($"上辅机校验成功,开仓指令下发成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); } else { - result.SetFailure($"上辅机校验失败,物料不匹配,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + _logger.LogError("上辅机开仓指令下发失败"); + result.SetSuccess($"上辅机校验成功,开仓指令下发失败,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + break; } } - else - { - result.SetFailure($"上辅机校验失败,根据料罐获取对应信息为空,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); - } - - } - else - { - result.SetSuccess($"上辅机校验失败,缺少必要参数,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); - } + + //保存数据 + } while (false); } catch (Exception e)