change - 上辅机校验逻辑完善

master
Wen JY 10 months ago
parent 15435b64d2
commit 060fec29c6

@ -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;
}
if (mcsInfo.MatCode.Contains(wmsInfo.MaterNo))
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))
{
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)

Loading…
Cancel
Save