change - 完善上辅机投料校验

master
Wen JY 1 year ago
parent 0a8bff449d
commit 15435b64d2

@ -14,6 +14,16 @@ namespace SlnMesnac.Config
/// </summary>
public string logPath { get; set; }
/// <summary>
/// MCS 开仓地址
/// </summary>
public string mcsOpenAddr { get; set; }
/// <summary>
/// CWSS 开仓地址
/// </summary>
public string cwssOpenAddr { get; set; }
/// <summary>
/// Sql连接配置
/// </summary>

@ -7,6 +7,7 @@ namespace SlnMesnac.Model.domain
/// WMS 出库记录反馈
/// </summary>
[SugarTable("I_TASKOUT_FEEDBACK_TO_MES"), TenantAttribute("wms")]
[DataContract(Name = "WmsTaskOut WMS 出库记录反馈")]
public class WmsTaskOut
{
[SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, IsIdentity = true)]

@ -117,7 +117,14 @@ namespace SlnMesnac.Plc
/// <returns></returns>
public IPlc GetPlcByKey(string key)
{
return keyValuePairs[key];
try
{
return keyValuePairs[key];
}
catch (Exception e)
{
throw new ArgumentException($"根据PLC Key获取连接信息异常:{e.Message}");;
}
}
/// <summary>

@ -43,7 +43,7 @@ namespace SlnMesnac.Repository.service.Impl
{
try
{
return _rep.GetFirst(x=>x.EquipId == EquipId && x.BinNo == BinNo);;
return _rep.GetFirst(x=>x.ScaleNum == 101 && x.EquipId == EquipId && x.BinNo == BinNo);;
}
catch (Exception e)
{

@ -7,6 +7,11 @@ namespace SlnMesnac.Repository.service.Impl
public class WmsTaskOutServiceImpl:IWmsTaskOutService
{
private readonly Repository<WmsTaskOut> _rep;
public WmsTaskOutServiceImpl(Repository<WmsTaskOut> rep)
{
_rep = rep;
}
/// <summary>
/// 获取WMS出库记录
@ -21,7 +26,7 @@ namespace SlnMesnac.Repository.service.Impl
}
catch (Exception e)
{
throw new ArgumentException($"获取料仓物料对应信息异常:{e.Message}");
throw new ArgumentException($"获取WMS出库记录异常:{e.Message}");
}
}
@ -39,7 +44,7 @@ namespace SlnMesnac.Repository.service.Impl
}
catch (Exception e)
{
throw new ArgumentException($"获取料仓物料对应信息异常:{e.Message}");
throw new ArgumentException($"通过标签唯一编码获取出库记录异常:{e.Message}");
}
}
}

@ -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;
}
}

@ -9,6 +9,8 @@
"AllowedHosts": "*",
"AppConfig": {
"logPath": "/Users/wenxiansheng/Desktop/日常代码/杜肯新材料程序设计/Durk.SlnMesnac/SlnMesnac/bin/Debug/net6.0",
"mcsOpenAddr": "D75367",
"cwssOpenAddr": "DB122",
"SqlConfig": [
{
"configId": "mcs",
@ -30,7 +32,7 @@
{
"configId": 1,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcIp": "127.0.0.1", //192.168.1.71
"plcPort": 102,
"plcKey": "mcs"
},

Loading…
Cancel
Save