|
|
|
@ -17,6 +17,9 @@ public class IngCheckController
|
|
|
|
|
private ILogger<IngCheckController> _logger;
|
|
|
|
|
private AppConfig _appConfig;
|
|
|
|
|
private IMcsBinToMaterService _mcsBinToMaterService;
|
|
|
|
|
private IWmsTaskOutService _wmsTaskOutService;
|
|
|
|
|
|
|
|
|
|
private PlcPool _plcPool;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
@ -24,15 +27,19 @@ public class IngCheckController
|
|
|
|
|
/// <param name="logger"></param>
|
|
|
|
|
public IngCheckController(ILogger<IngCheckController> logger,
|
|
|
|
|
IMcsBinToMaterService mcsBinToMaterService,
|
|
|
|
|
AppConfig appConfig)
|
|
|
|
|
AppConfig appConfig,
|
|
|
|
|
IWmsTaskOutService wmsTaskOutService,
|
|
|
|
|
PlcPool plcPool)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_mcsBinToMaterService = mcsBinToMaterService;
|
|
|
|
|
_appConfig = appConfig;
|
|
|
|
|
_wmsTaskOutService = wmsTaskOutService;
|
|
|
|
|
_plcPool = plcPool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 大料投料校验
|
|
|
|
|
/// 上辅机投料校验
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ingredientInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
@ -44,36 +51,52 @@ public class IngCheckController
|
|
|
|
|
{
|
|
|
|
|
if (ingredientInfo != null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"大料验证参数:{JsonSerializer.Serialize(ingredientInfo)}");
|
|
|
|
|
var info = _mcsBinToMaterService.GetMcsBinToMaterByBinNo(ingredientInfo.EquipId, ingredientInfo.CanNumber);
|
|
|
|
|
if (info != null)
|
|
|
|
|
_logger.LogInformation($"上辅机验证参数:{JsonSerializer.Serialize(ingredientInfo)}");
|
|
|
|
|
var mcsInfo = _mcsBinToMaterService.GetMcsBinToMaterByBinNo(1, ingredientInfo.CanNumber);
|
|
|
|
|
if (mcsInfo != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (info.MatCode == ingredientInfo.MaterialBarcode)
|
|
|
|
|
var wmsInfo = _wmsTaskOutService.GetWmsTaskOutBySerialNum(ingredientInfo.MaterialBarcode);
|
|
|
|
|
|
|
|
|
|
if (mcsInfo.MatCode.Contains(wmsInfo.MaterNo))
|
|
|
|
|
{
|
|
|
|
|
result.SetSuccess($"大料校验成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
|
|
|
|
|
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("上辅机开仓指令下发失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//保存数据
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.SetFailure($"大料校验失败,物料不匹配,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
|
|
|
|
|
result.SetFailure($"上辅机校验失败,物料不匹配,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.SetFailure($"大料校验失败,根据料罐获取对应信息为空,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
|
|
|
|
|
result.SetFailure($"上辅机校验失败,根据料罐获取对应信息为空,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.SetSuccess($"大料校验失败,缺少必要参数,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
|
|
|
|
|
result.SetSuccess($"上辅机校验失败,缺少必要参数,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
result.SetException(e,"大料投料校验异常");
|
|
|
|
|
_logger.LogError($"大料投料校验异常:{e.Message}");
|
|
|
|
|
result.SetException(e,"上辅机投料校验异常");
|
|
|
|
|
_logger.LogError($"上辅机投料校验异常:{e.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
@ -111,4 +134,26 @@ public class IngCheckController
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下发开仓指令
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address"></param>
|
|
|
|
|
/// <param name="canNumber"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool SendOpenInstructions(string plcType, string address, int canNumber)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = _plcPool.GetPlcByKey(plcType).writeInt32ByAddress(address,canNumber);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"开仓指令下发异常:{e.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|