|
|
@ -1,4 +1,4 @@
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using SlnMesnac.Business.@base;
|
|
|
|
using SlnMesnac.Business.@base;
|
|
|
|
using SlnMesnac.Common;
|
|
|
|
using SlnMesnac.Common;
|
|
|
@ -21,32 +21,32 @@ using System.Threading.Tasks;
|
|
|
|
using TouchSocket.Core;
|
|
|
|
using TouchSocket.Core;
|
|
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
|
|
|
|
|
|
|
|
#region << 版 本 注 释 >>
|
|
|
|
#region << 版 本 注 释 >>
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
* 版权所有 (c) 2024 WenJY 保留所有权利。
|
|
|
|
* 版权所有 (c) 2024 WenJY 保留所有权利。
|
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
|
* 机器名称:LAPTOP-E0N2L34V
|
|
|
|
* 机器名称:LAPTOP-E0N2L34V
|
|
|
|
* 命名空间:SlnMesnac.Business
|
|
|
|
* 命名空间:SlnMesnac.Business
|
|
|
|
* 唯一标识:f79d6d97-d9b0-4b0b-a442-e6bb1c1c79e6
|
|
|
|
* 唯一标识:f79d6d97-d9b0-4b0b-a442-e6bb1c1c79e6
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 创建者:WenJY
|
|
|
|
* 创建者:WenJY
|
|
|
|
* 电子邮箱:wenjy@mesnac.com
|
|
|
|
* 电子邮箱:wenjy@mesnac.com
|
|
|
|
* 创建时间:2024-04-10 16:36:01
|
|
|
|
* 创建时间:2024-04-10 16:36:01
|
|
|
|
* 版本:V1.0.0
|
|
|
|
* 版本:V1.0.0
|
|
|
|
* 描述:
|
|
|
|
* 描述:
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*--------------------------------------------------------------------
|
|
|
|
*--------------------------------------------------------------------
|
|
|
|
* 修改人:
|
|
|
|
* 修改人:
|
|
|
|
* 时间:
|
|
|
|
* 时间:
|
|
|
|
* 修改说明:
|
|
|
|
* 修改说明:
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 版本:V1.0.0
|
|
|
|
* 版本:V1.0.0
|
|
|
|
*--------------------------------------------------------------------*/
|
|
|
|
*--------------------------------------------------------------------*/
|
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
|
namespace SlnMesnac.Business
|
|
|
|
namespace SlnMesnac.Business
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 设备产出业务逻辑
|
|
|
|
/// 设备产出业务逻辑
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class ProdCompletionBusiness : BaseBusiness
|
|
|
|
public class ProdCompletionBusiness : BaseBusiness
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -61,7 +61,7 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
|
|
private ISqlSugarClient sqlSugarClient;
|
|
|
|
private ISqlSugarClient sqlSugarClient;
|
|
|
|
|
|
|
|
|
|
|
|
public ProdCompletionBusiness(ISqlSugarClient _sqlSugarClient,ILogger<BaseBusiness> logger, AppConfig appConfig, List<PlcAbsractFactory> plcFactories, List<RfidAbsractFactory> rfidFactories, IMesProductPlanService mesProductPlanService, IMesPrdBarCodeService barCodeTaskService, IServiceProvider serviceProvider) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider)
|
|
|
|
public ProdCompletionBusiness(ISqlSugarClient _sqlSugarClient, ILogger<BaseBusiness> logger, AppConfig appConfig, List<PlcAbsractFactory> plcFactories, List<RfidAbsractFactory> rfidFactories, IMesProductPlanService mesProductPlanService, IMesPrdBarCodeService barCodeTaskService, IServiceProvider serviceProvider) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sqlSugarClient = _sqlSugarClient;
|
|
|
|
sqlSugarClient = _sqlSugarClient;
|
|
|
|
_mesProductPlanService = mesProductPlanService;
|
|
|
|
_mesProductPlanService = mesProductPlanService;
|
|
|
@ -72,10 +72,10 @@ namespace SlnMesnac.Business
|
|
|
|
_mesProductOrderService = serviceProvider.GetRequiredService<IMesProductOrderService>();
|
|
|
|
_mesProductOrderService = serviceProvider.GetRequiredService<IMesProductOrderService>();
|
|
|
|
_baseMaterialInfoService = serviceProvider.GetRequiredService<IBaseMaterialInfoService>();
|
|
|
|
_baseMaterialInfoService = serviceProvider.GetRequiredService<IBaseMaterialInfoService>();
|
|
|
|
Init();
|
|
|
|
Init();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void test()
|
|
|
|
private void test()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
string epc = "A123456";
|
|
|
|
string epc = "A123456";
|
|
|
@ -85,28 +85,31 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static bool isEmptyPalletHandleRunning = false;
|
|
|
|
public void Init()
|
|
|
|
public void Init()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
Task.Run(async () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
EmptyPalletHandle();
|
|
|
|
await EmptyPalletHandle();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
Task.Run(() =>
|
|
|
|
Task.Run(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DeviceOutPutHandle();
|
|
|
|
DeviceOutPutHandle();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 设备产出逻辑处理
|
|
|
|
/// 设备产出逻辑处理
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private async void DeviceOutPutHandle()
|
|
|
|
private async void DeviceOutPutHandle()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 读取RFID失败重试次数,超过5次推送报警
|
|
|
|
// 读取RFID失败重试次数,超过5次推送报警
|
|
|
|
int readRfidAmount = 0;
|
|
|
|
int readRfidAmount = 0;
|
|
|
|
while(true)
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -114,24 +117,32 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
|
|
if (plc == null)
|
|
|
|
if (plc == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation("读取小包出口信号,PLC连接信息为空......");
|
|
|
|
_logger.LogInformation("读取小包出口信号,PLC连接信息为空......");
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (plc.readByteByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号"))!=1)
|
|
|
|
if (plc.readByteByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号")) != 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation("等待小包出口信号触发......");
|
|
|
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
string rfid = plc.readStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"),12).Replace("\0","");
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(rfid))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation("等待小包出口信号触发......");
|
|
|
|
_logger.LogInformation("小包出口已经有RFID了,无需再读");
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorOut");
|
|
|
|
string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorOut");
|
|
|
|
if (string.IsNullOrEmpty(epcStr))
|
|
|
|
if (string.IsNullOrEmpty(epcStr))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogError("小包出口到位信号触发,读取RFID失败......");
|
|
|
|
_logger.LogError("小包出口到位信号触发,读取RFID失败......");
|
|
|
|
//判断前一位置是否有托盘缓存
|
|
|
|
//判断前一位置是否有托盘缓存
|
|
|
|
RealPalletTask realPalletTask = _realPalletTaskService.Query().FirstOrDefault();
|
|
|
|
RealPalletTask realPalletTask = _realPalletTaskService.Query().FirstOrDefault();
|
|
|
|
if (realPalletTask != null)
|
|
|
|
if (realPalletTask != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
epcStr = realPalletTask.PalletCode;
|
|
|
|
epcStr = realPalletTask.PalletCode;
|
|
|
@ -139,15 +150,15 @@ namespace SlnMesnac.Business
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
readRfidAmount++;
|
|
|
|
readRfidAmount++;
|
|
|
|
if(readRfidAmount == 5)
|
|
|
|
if (readRfidAmount == 5)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
string virtualEpc = NoReadRFIDAlarm();
|
|
|
|
string virtualEpc = NoReadRFIDAlarm();
|
|
|
|
_logger.LogError("小包出口到位信号触发,读取RFID失败超过5次......");
|
|
|
|
_logger.LogError("小包出口到位信号触发,读取RFID失败超过5次......");
|
|
|
|
if (!string.IsNullOrEmpty(virtualEpc))
|
|
|
|
if (!string.IsNullOrEmpty(virtualEpc))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
epcStr = virtualEpc;
|
|
|
|
epcStr = virtualEpc;
|
|
|
|
_logger.LogError("小包出口到位信号触发,读取RFID失败超过5次,生成虚拟托盘号:"+virtualEpc);
|
|
|
|
_logger.LogError("小包出口到位信号触发,读取RFID失败超过5次,生成虚拟托盘号:" + virtualEpc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -155,52 +166,52 @@ namespace SlnMesnac.Business
|
|
|
|
Thread.Sleep(1000 * 5);
|
|
|
|
Thread.Sleep(1000 * 5);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RefreshMessage($"小包出口读取到RFID条码{epcStr},开始绑定流程:");
|
|
|
|
RefreshMessage($"小包出口读取到RFID条码{epcStr},开始绑定流程:");
|
|
|
|
|
|
|
|
|
|
|
|
_mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
|
|
|
|
_mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
|
|
|
|
if (productPlanDto == null)
|
|
|
|
if (productPlanDto == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//TODO:没有计划的话,处理方式待定
|
|
|
|
//TODO:没有计划的话,处理方式待定
|
|
|
|
throw new ArgumentException($"未获取到正在执行的生产计划");
|
|
|
|
throw new ArgumentException($"未获取到正在执行的生产计划");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#region 开启事务
|
|
|
|
#region 开启事务
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
//1.生成大条码插入mes_barcode_info;
|
|
|
|
//1.生成大条码插入mes_barcode_info;
|
|
|
|
string bigCode =GenerateBigBarcode(productPlanDto, epcStr);
|
|
|
|
string bigCode = GenerateBigBarcode(productPlanDto, epcStr);
|
|
|
|
//2.40个小条码及大条码绑定托盘号,小条码绑定大条码
|
|
|
|
//2.40个小条码及大条码绑定托盘号,小条码绑定大条码
|
|
|
|
BindingBarCode(bigCode,epcStr);
|
|
|
|
BindingBarCode(bigCode, epcStr);
|
|
|
|
//3.更新mes_product_plan及mes_product_order表,更新已生产数量
|
|
|
|
//3.更新mes_product_plan及mes_product_order表,更新已生产数量
|
|
|
|
UpdatePlanInfoAndOrder(productPlanDto);
|
|
|
|
UpdatePlanInfoAndOrder(productPlanDto);
|
|
|
|
|
|
|
|
|
|
|
|
// 删除正在使用的数据库托盘号
|
|
|
|
// 删除正在使用的数据库托盘号
|
|
|
|
RealPalletTask realPallet = _realPalletTaskService.Query(x => x.PalletCode == epcStr).FirstOrDefault();
|
|
|
|
RealPalletTask realPallet = _realPalletTaskService.Query(x => x.PalletCode == epcStr).FirstOrDefault();
|
|
|
|
if (realPallet != null)
|
|
|
|
if (realPallet != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Deleteable(realPallet).ExecuteCommand();
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Deleteable(realPallet).ExecuteCommand();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 写入PLC RFID号供调度使用
|
|
|
|
// 写入PLC RFID号供调度使用
|
|
|
|
plc.writeStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"), epcStr);
|
|
|
|
plc.writeStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"), epcStr);
|
|
|
|
plc.writeByteByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号"),2);
|
|
|
|
// plc.writeByteByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号"), 2);
|
|
|
|
readRfidAmount = 0;
|
|
|
|
readRfidAmount = 0;
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogError($"DeviceOutPutHandle异常:{ex.Message}");
|
|
|
|
_logger.LogError($"DeviceOutPutHandle异常:{ex.Message}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(1000 * 5);
|
|
|
|
Thread.Sleep(1000 * 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 推送报警,并生成虚拟托盘号暂时使用,虚拟托盘号储存到报警信息,人工处理可以将虚拟托盘号替换为正常托盘号
|
|
|
|
/// 推送报警,并生成虚拟托盘号暂时使用,虚拟托盘号储存到报警信息,人工处理可以将虚拟托盘号替换为正常托盘号
|
|
|
|
/// <return> 返回生产的虚拟托盘号
|
|
|
|
/// <return> 返回生产的虚拟托盘号
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private string NoReadRFIDAlarm()
|
|
|
|
private string NoReadRFIDAlarm()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -210,13 +221,13 @@ namespace SlnMesnac.Business
|
|
|
|
epcStr = "TEMP" + DateTime.Now.ToString("MMddHHmm");
|
|
|
|
epcStr = "TEMP" + DateTime.Now.ToString("MMddHHmm");
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
|
|
|
|
|
|
|
|
// 有报警,找出该设备的报警记录,如果没有报警记录或者报警记录已结束,则新增报警记录
|
|
|
|
// 有报警,找出该设备的报警记录,如果没有报警记录或者报警记录已结束,则新增报警记录
|
|
|
|
int warnRuleId = int.Parse(WarnStatusEnum.小包出口读取RFID失败5次.GetDescription());
|
|
|
|
int warnRuleId = int.Parse(WarnStatusEnum.小包出口读取RFID失败5次.GetDescription());
|
|
|
|
DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmTime>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmTime>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
if (dmsRecordAlarmTime == null)
|
|
|
|
if (dmsRecordAlarmTime == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DmsBaseAlarmRule dmsBaseAlarmRule = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsBaseAlarmRule>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
DmsBaseAlarmRule dmsBaseAlarmRule = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsBaseAlarmRule>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
|
|
|
|
|
|
|
|
dmsRecordAlarmTime = new DmsRecordAlarmTime();
|
|
|
|
dmsRecordAlarmTime = new DmsRecordAlarmTime();
|
|
|
|
dmsRecordAlarmTime.DeviceId = dmsBaseAlarmRule.DeviceId;
|
|
|
|
dmsRecordAlarmTime.DeviceId = dmsBaseAlarmRule.DeviceId;
|
|
|
|
dmsRecordAlarmTime.AlarmRuleId = warnRuleId;
|
|
|
|
dmsRecordAlarmTime.AlarmRuleId = warnRuleId;
|
|
|
@ -224,8 +235,8 @@ namespace SlnMesnac.Business
|
|
|
|
dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmTime.AlarmData = WarnStatusEnum.小包出口读取RFID失败5次.ToString();
|
|
|
|
dmsRecordAlarmTime.AlarmData = WarnStatusEnum.小包出口读取RFID失败5次.ToString();
|
|
|
|
dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest+";;虚拟托盘号为:"+epcStr;
|
|
|
|
dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest + ";;虚拟托盘号为:" + epcStr;
|
|
|
|
dmsRecordAlarmTime.CreateBy = "SlnMesnac";
|
|
|
|
dmsRecordAlarmTime.CreateBy = "SlnMesnac";
|
|
|
|
dmsRecordAlarmTime.CreateTime = DateTime.Now;
|
|
|
|
dmsRecordAlarmTime.CreateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
@ -238,20 +249,20 @@ namespace SlnMesnac.Business
|
|
|
|
dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.小包出口读取RFID失败5次.ToString();
|
|
|
|
dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.小包出口读取RFID失败5次.ToString();
|
|
|
|
dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest + ";;虚拟托盘号为:" + epcStr;
|
|
|
|
dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest + ";;虚拟托盘号为:" + epcStr;
|
|
|
|
dmsRecordAlarmInfo.CreateBy = "SlnMesnac";
|
|
|
|
dmsRecordAlarmInfo.CreateBy = "SlnMesnac";
|
|
|
|
dmsRecordAlarmInfo.CreateTime = DateTime.Now;
|
|
|
|
dmsRecordAlarmInfo.CreateTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmTime).ExecuteCommand();
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmTime).ExecuteCommand();
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmInfo).ExecuteCommand();
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmInfo).ExecuteCommand();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
dmsRecordAlarmTime.UpdateTime = DateTime.Now;
|
|
|
|
dmsRecordAlarmTime.UpdateTime = DateTime.Now;
|
|
|
|
dmsRecordAlarmTime.UpdateBy = "SlnMesnac";
|
|
|
|
dmsRecordAlarmTime.UpdateBy = "SlnMesnac";
|
|
|
|
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x=>x.AlarmRuleId==warnRuleId);
|
|
|
|
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
if (dmsRecordAlarmInfo != null)
|
|
|
|
if (dmsRecordAlarmInfo != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dmsRecordAlarmInfo.UpdateTime = DateTime.Now;
|
|
|
|
dmsRecordAlarmInfo.UpdateTime = DateTime.Now;
|
|
|
@ -259,15 +270,16 @@ namespace SlnMesnac.Business
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand();
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand();
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand();
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
return epcStr;
|
|
|
|
return epcStr;
|
|
|
|
}catch(Exception ex)
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
_logger.LogError($"NoReadRFIDAlarm异常:{ex.Message}");
|
|
|
|
_logger.LogError($"NoReadRFIDAlarm异常:{ex.Message}");
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -275,15 +287,15 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 生成大条码插入mes_barcode_info;
|
|
|
|
/// 生成大条码插入mes_barcode_info;
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="productPlanDto"></param>
|
|
|
|
/// <param name="productPlanDto"></param>
|
|
|
|
/// <param name="epcStr"></param>
|
|
|
|
/// <param name="epcStr"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
private string GenerateBigBarcode(MesProductPlanDto productPlanDto,string epcStr)
|
|
|
|
private string GenerateBigBarcode(MesProductPlanDto productPlanDto, string epcStr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
string bigBarcode = productPlanDto.PlanCode+DateTime.Now.ToString("_MMddHHmmss");
|
|
|
|
string bigBarcode = productPlanDto.PlanCode + DateTime.Now.ToString("_MMddHHmmss");
|
|
|
|
MesBaseBarcodeInfo mesBaseBarcodeInfo = new MesBaseBarcodeInfo();
|
|
|
|
MesBaseBarcodeInfo mesBaseBarcodeInfo = new MesBaseBarcodeInfo();
|
|
|
|
mesBaseBarcodeInfo.printTime = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.printTime = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.printPerson = "SlnMesnac";
|
|
|
|
mesBaseBarcodeInfo.printPerson = "SlnMesnac";
|
|
|
@ -299,40 +311,40 @@ namespace SlnMesnac.Business
|
|
|
|
mesBaseBarcodeInfo.productionDate = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.productionDate = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.acceptedDate = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.acceptedDate = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.planCode = productPlanDto.PlanCode;
|
|
|
|
mesBaseBarcodeInfo.planCode = productPlanDto.PlanCode;
|
|
|
|
mesBaseBarcodeInfo.safeFlag = productPlanDto.SaleOrderId ==0 ?"1" : "0";
|
|
|
|
mesBaseBarcodeInfo.safeFlag = productPlanDto.SaleOrderId == 0 ? "1" : "0";
|
|
|
|
mesBaseBarcodeInfo.saleOrderId = productPlanDto.SaleOrderId;
|
|
|
|
mesBaseBarcodeInfo.saleOrderId = productPlanDto.SaleOrderId;
|
|
|
|
mesBaseBarcodeInfo.saleorderCode = productPlanDto.SaleorderCode;
|
|
|
|
mesBaseBarcodeInfo.saleorderCode = productPlanDto.SaleorderCode;
|
|
|
|
mesBaseBarcodeInfo.bindStatus = "1";
|
|
|
|
mesBaseBarcodeInfo.bindStatus = "1";
|
|
|
|
mesBaseBarcodeInfo.bindTime = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.bindTime = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.updateBy = "SlnMesnac";
|
|
|
|
mesBaseBarcodeInfo.updateBy = "SlnMesnac";
|
|
|
|
mesBaseBarcodeInfo.updateTime = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.updateTime = DateTime.Now;
|
|
|
|
mesBaseBarcodeInfo.completeFlag = "1";
|
|
|
|
mesBaseBarcodeInfo.completeFlag = "1";
|
|
|
|
mesBaseBarcodeInfo.singleFlag = "0";
|
|
|
|
mesBaseBarcodeInfo.singleFlag = "0";
|
|
|
|
var materialInfo = _baseMaterialInfoService.Query(x => x.MaterialId == productPlanDto.MaterialId).FirstOrDefault();
|
|
|
|
var materialInfo = _baseMaterialInfoService.Query(x => x.MaterialId == productPlanDto.MaterialId).FirstOrDefault();
|
|
|
|
if(materialInfo != null)
|
|
|
|
if (materialInfo != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mesBaseBarcodeInfo.barcodeSpec = materialInfo.MaterialSpec;
|
|
|
|
mesBaseBarcodeInfo.barcodeSpec = materialInfo.MaterialSpec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(mesBaseBarcodeInfo).ExecuteCommand();
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(mesBaseBarcodeInfo).ExecuteCommand();
|
|
|
|
return bigBarcode;
|
|
|
|
return bigBarcode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 40个小条码及大条码绑定托盘号,小条码绑定大条码
|
|
|
|
/// 40个小条码及大条码绑定托盘号,小条码绑定大条码
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="bigBarcode"></param>
|
|
|
|
/// <param name="bigBarcode"></param>
|
|
|
|
/// <param name="epcStr"></param>
|
|
|
|
/// <param name="epcStr"></param>
|
|
|
|
private void BindingBarCode(string bigBarcode,string epcStr)
|
|
|
|
private void BindingBarCode(string bigBarcode, string epcStr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<MesPrdBarcodeInfo> list = _mesPrdBarCodeService.GetUseBarCodeList();
|
|
|
|
List<MesPrdBarcodeInfo> list = _mesPrdBarCodeService.GetUseBarCodeList();
|
|
|
|
if(list==null || list.Count == 0)
|
|
|
|
if (list == null || list.Count == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("托盘未找到可以绑定的小条码");
|
|
|
|
throw new InvalidOperationException("托盘未找到可以绑定的小条码");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (list.Where(x => x.PrintFlag == "1").ToList().Count < 40)
|
|
|
|
if (list.Where(x => x.PrintFlag == "1").ToList().Count < 40)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO推送低级别报警
|
|
|
|
// TODO推送低级别报警
|
|
|
|
PrintLessThan40Alarm();
|
|
|
|
PrintLessThan40Alarm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach (var item in list)
|
|
|
|
foreach (var item in list)
|
|
|
@ -347,44 +359,44 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
|
|
private void UpdatePlanInfoAndOrder(MesProductPlanDto productPlanDto)
|
|
|
|
private void UpdatePlanInfoAndOrder(MesProductPlanDto productPlanDto)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MesProductPlan productPlan = _mesProductPlanService.Query(x => x.PlanCode == productPlanDto.PlanCode).FirstOrDefault();
|
|
|
|
MesProductPlan productPlan = _mesProductPlanService.Query(x => x.PlanCode == productPlanDto.PlanCode).FirstOrDefault();
|
|
|
|
if(productPlan == null)
|
|
|
|
if (productPlan == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("未找到该生产计划!");
|
|
|
|
throw new InvalidOperationException("未找到该生产计划!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MesProductOrder productOrder = _mesProductOrderService.Query(x => x.ProductOrderId == productPlan.ProductOrderId).FirstOrDefault();
|
|
|
|
MesProductOrder productOrder = _mesProductOrderService.Query(x => x.ProductOrderId == productPlan.ProductOrderId).FirstOrDefault();
|
|
|
|
if (productPlan == null)
|
|
|
|
if (productPlan == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("未找到该生产计划对应的生产工单!");
|
|
|
|
throw new InvalidOperationException("未找到该生产计划对应的生产工单!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#region 更新生产计划
|
|
|
|
#region 更新生产计划
|
|
|
|
if (productPlan.CompleteAmount == 0)
|
|
|
|
if (productPlan.CompleteAmount == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
productPlan.RealBeginTime = DateTime.Now;
|
|
|
|
productPlan.RealBeginTime = DateTime.Now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
productPlan.CompleteAmount++;
|
|
|
|
productPlan.CompleteAmount++;
|
|
|
|
if(productPlan.CompleteAmount == productPlan.PlanAmount)
|
|
|
|
if (productPlan.CompleteAmount == productPlan.PlanAmount)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
productPlan.RealEndTime = DateTime.Now;
|
|
|
|
productPlan.RealEndTime = DateTime.Now;
|
|
|
|
productPlan.PlanStatus = Model.enums.PlanStatusEnum.已完成;
|
|
|
|
productPlan.PlanStatus = Model.enums.PlanStatusEnum.已完成;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
productPlan.UpdateTime = DateTime.Now;
|
|
|
|
productPlan.UpdateTime = DateTime.Now;
|
|
|
|
productPlan.UpdateBy = "SlnMesnac";
|
|
|
|
productPlan.UpdateBy = "SlnMesnac";
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(productPlan).ExecuteCommand();
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Updateable(productPlan).ExecuteCommand();
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 更新生产工单
|
|
|
|
#region 更新生产工单
|
|
|
|
|
|
|
|
|
|
|
|
if (productOrder.CompleteAmount == 0)
|
|
|
|
if (productOrder.CompleteAmount == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
productOrder.RealBeginTime = DateTime.Now;
|
|
|
|
productOrder.RealBeginTime = DateTime.Now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
productOrder.CompleteAmount++;
|
|
|
|
productOrder.CompleteAmount++;
|
|
|
|
if(productOrder.CompleteAmount== productOrder.PlanAmount)
|
|
|
|
if (productOrder.CompleteAmount == productOrder.PlanAmount)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
productOrder.RealEndTime = DateTime.Now;
|
|
|
|
productOrder.RealEndTime = DateTime.Now;
|
|
|
|
productOrder.OrderStatus = "2";
|
|
|
|
productOrder.OrderStatus = "2";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -396,8 +408,8 @@ namespace SlnMesnac.Business
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 小包产出绑定托盘,小包喷码数量小于40低级别报警
|
|
|
|
/// 小包产出绑定托盘,小包喷码数量小于40低级别报警
|
|
|
|
/// <return> 返回生产的虚拟托盘号
|
|
|
|
/// <return> 返回生产的虚拟托盘号
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private void PrintLessThan40Alarm()
|
|
|
|
private void PrintLessThan40Alarm()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -405,8 +417,8 @@ namespace SlnMesnac.Business
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
|
|
|
|
|
|
|
|
// 有报警,找出该设备的报警记录,如果没有报警记录或者报警记录已结束,则新增报警记录
|
|
|
|
// 有报警,找出该设备的报警记录,如果没有报警记录或者报警记录已结束,则新增报警记录
|
|
|
|
int warnRuleId = int.Parse(WarnStatusEnum.托盘绑定时已喷码数不足40.GetDescription());
|
|
|
|
int warnRuleId = int.Parse(WarnStatusEnum.托盘绑定时已喷码数不足40.GetDescription());
|
|
|
|
DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmTime>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
DmsRecordAlarmTime? dmsRecordAlarmTime = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmTime>().First(x => x.AlarmRuleId == warnRuleId);
|
|
|
|
if (dmsRecordAlarmTime == null)
|
|
|
|
if (dmsRecordAlarmTime == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -419,7 +431,7 @@ namespace SlnMesnac.Business
|
|
|
|
dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
dmsRecordAlarmTime.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmTime.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmTime.AlarmData = WarnStatusEnum.托盘绑定时已喷码数不足40.ToString();
|
|
|
|
dmsRecordAlarmTime.AlarmData = WarnStatusEnum.托盘绑定时已喷码数不足40.ToString();
|
|
|
|
dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest;
|
|
|
|
dmsRecordAlarmTime.HandleSuggest = dmsBaseAlarmRule.HandleSuggest;
|
|
|
|
dmsRecordAlarmTime.CreateBy = "SlnMesnac";
|
|
|
|
dmsRecordAlarmTime.CreateBy = "SlnMesnac";
|
|
|
|
dmsRecordAlarmTime.CreateTime = DateTime.Now;
|
|
|
|
dmsRecordAlarmTime.CreateTime = DateTime.Now;
|
|
|
@ -433,7 +445,7 @@ namespace SlnMesnac.Business
|
|
|
|
dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
dmsRecordAlarmInfo.ContinueTime = dmsBaseAlarmRule.ContinueTime;
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmInfo.AlarmReason = dmsBaseAlarmRule.AlarmReason;
|
|
|
|
dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.托盘绑定时已喷码数不足40.ToString();
|
|
|
|
dmsRecordAlarmInfo.AlarmData = WarnStatusEnum.托盘绑定时已喷码数不足40.ToString();
|
|
|
|
dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest;
|
|
|
|
dmsRecordAlarmInfo.HandleSuggest = dmsBaseAlarmRule.HandleSuggest;
|
|
|
|
dmsRecordAlarmInfo.CreateBy = "SlnMesnac";
|
|
|
|
dmsRecordAlarmInfo.CreateBy = "SlnMesnac";
|
|
|
|
dmsRecordAlarmInfo.CreateTime = DateTime.Now;
|
|
|
|
dmsRecordAlarmInfo.CreateTime = DateTime.Now;
|
|
|
@ -458,23 +470,23 @@ namespace SlnMesnac.Business
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
_logger.LogError($"PrintLessThan40Alarm异常:{ex.Message}");
|
|
|
|
_logger.LogError($"PrintLessThan40Alarm异常:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 空托盘进入码垛位,读取RFID备用
|
|
|
|
/// 空托盘进入码垛位,读取RFID备用
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private async void EmptyPalletHandle()
|
|
|
|
private async Task EmptyPalletHandle()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//读取PLC空托盘流转信号
|
|
|
|
//读取PLC空托盘流转信号
|
|
|
|
while (true)
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -482,71 +494,75 @@ namespace SlnMesnac.Business
|
|
|
|
var plc = base.GetPlcByKey("plc");
|
|
|
|
var plc = base.GetPlcByKey("plc");
|
|
|
|
if (plc == null)
|
|
|
|
if (plc == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation("读取PLC空托盘码垛到位信号,PLC连接信息为空......");
|
|
|
|
_logger.LogInformation("读取PLC空托盘码垛到位信号,PLC连接信息为空......");
|
|
|
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2楼码垛到位信号")))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation("等待空托盘到位信号触发......");
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2楼码垛到位信号")))
|
|
|
|
|
|
|
|
|
|
|
|
RealPalletTask realPalletTask = _realPalletTaskService.Query().FirstOrDefault();
|
|
|
|
|
|
|
|
if (realPalletTask != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation("等待空托盘到位信号触发......");
|
|
|
|
_logger.LogInformation("空托盘到位信号触发,已经有读取托盘,不再读取......");
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//读取RFID、获取当前正在执行的计划、将当前计划、工单等信息与托盘绑定
|
|
|
|
//读取RFID、获取当前正在执行的计划、将当前计划、工单等信息与托盘绑定
|
|
|
|
RefreshMessage("空托盘到位信号触发成功,读取托盘RFID信息");
|
|
|
|
RefreshMessage("空托盘到位信号触发成功,读取托盘RFID信息");
|
|
|
|
|
|
|
|
|
|
|
|
string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorPallet");
|
|
|
|
string epcStr = await ReadEpcStrByRfidKeyAsync("secondFloorPallet");
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(epcStr))
|
|
|
|
if (string.IsNullOrEmpty(epcStr))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogError("空托盘到位信号触发,读取RFID失败......");
|
|
|
|
_logger.LogError("空托盘到位信号触发,读取RFID失败......");
|
|
|
|
Thread.Sleep(1000*10);
|
|
|
|
Thread.Sleep(1000 * 10);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RefreshMessage($"空托盘RFID信息读取成功,标签信息:{epcStr}");
|
|
|
|
RefreshMessage($"空托盘RFID信息读取成功,标签信息:{epcStr}");
|
|
|
|
|
|
|
|
|
|
|
|
// 插入一条托盘记录
|
|
|
|
// 插入一条托盘记录
|
|
|
|
RealPalletTask realPalletTask = new RealPalletTask()
|
|
|
|
realPalletTask = new RealPalletTask()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PalletCode = epcStr,
|
|
|
|
PalletCode = epcStr,
|
|
|
|
RecordTime = DateTime.Now,
|
|
|
|
RecordTime = DateTime.Now,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
bool result = _realPalletTaskService.Insert(realPalletTask);
|
|
|
|
_realPalletTaskService.Insert(realPalletTask);
|
|
|
|
if (result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
plc.writeBoolByAddress(GetPlcAddressByConfigKey("2楼码垛到位信号"), false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RefreshMessage($"空托盘进入码垛位处理异常:{e.Message}");
|
|
|
|
RefreshMessage($"空托盘进入码垛位处理异常:{e.Message}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Thread.Sleep(1000*5);
|
|
|
|
Thread.Sleep(1000 * 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 根据条码提取序列
|
|
|
|
/// 根据条码提取序列
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="barCode"></param>
|
|
|
|
/// <param name="barCode"></param>
|
|
|
|
/// <param name="result"></param>
|
|
|
|
/// <param name="result"></param>
|
|
|
|
/// <exception cref="InvalidOperationException"></exception>
|
|
|
|
/// <exception cref="InvalidOperationException"></exception>
|
|
|
|
private void ExtractNumber(string barCode,out int result)
|
|
|
|
private void ExtractNumber(string barCode, out int result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string pattern = @"\b0*(\d{1,6})\b$";
|
|
|
|
string pattern = @"\b0*(\d{1,6})\b$";
|
|
|
|
|
|
|
|
|
|
|
|
Match match = Regex.Match(barCode, pattern);
|
|
|
|
Match match = Regex.Match(barCode, pattern);
|
|
|
|
if (match.Success)
|
|
|
|
if (match.Success)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = Convert.ToInt32(match.Groups[1].Value)+1;
|
|
|
|
result = Convert.ToInt32(match.Groups[1].Value) + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException($"通过条码:{barCode}提取当前序列异常:未找到匹配的数字");
|
|
|
|
throw new InvalidOperationException($"通过条码:{barCode}提取当前序列异常:未找到匹配的数字");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|