|
|
|
@ -60,6 +60,8 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
public readonly IBasePalletInfoService _basePalletInfoService;
|
|
|
|
|
|
|
|
|
|
public readonly IMesPrdBarCodeService _mesPrdBarCodeService;
|
|
|
|
|
|
|
|
|
|
public readonly IBaseRealTaskService _baseRealTaskService;
|
|
|
|
|
|
|
|
|
|
public readonly IWmsOutStockService _wmsOutStockService;
|
|
|
|
@ -67,11 +69,11 @@ namespace SlnMesnac.Business
|
|
|
|
|
private readonly ConfigInfoBusiness _configInfoBusiness;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<RealPalletTask> _palletTasks;
|
|
|
|
|
|
|
|
|
|
private ISqlSugarClient sqlSugarClient;
|
|
|
|
|
private DebugConfig debugConfig = DebugConfig.Instance;
|
|
|
|
|
|
|
|
|
|
public ProdMgmtBusiness(ISqlSugarClient _sqlSugarClient, IWmsOutStockService wmsOutStockService, ILogger<ProdMgmtBusiness> logger, AppConfig appConfig, List<PlcAbsractFactory> plcFactories, List<RfidAbsractFactory> rfidFactories, IMesProductPlanService mesProductPlanService, IBasePalletInfoService basePalletInfoService, IBaseRealTaskService baseRealTaskService, List<RealPalletTask> palletTasks, IServiceProvider serviceProvider, ConfigInfoBusiness configInfoBusiness) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider)
|
|
|
|
|
public ProdMgmtBusiness(ISqlSugarClient _sqlSugarClient, IWmsOutStockService wmsOutStockService, ILogger<ProdMgmtBusiness> logger, AppConfig appConfig, List<PlcAbsractFactory> plcFactories, List<RfidAbsractFactory> rfidFactories, IMesProductPlanService mesProductPlanService, IBasePalletInfoService basePalletInfoService, IBaseRealTaskService baseRealTaskService, IServiceProvider serviceProvider, ConfigInfoBusiness configInfoBusiness) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
sqlSugarClient = _sqlSugarClient;
|
|
|
|
@ -79,14 +81,35 @@ namespace SlnMesnac.Business
|
|
|
|
|
_mesProductPlanService = mesProductPlanService;
|
|
|
|
|
_basePalletInfoService = basePalletInfoService;
|
|
|
|
|
_baseRealTaskService = baseRealTaskService;
|
|
|
|
|
_palletTasks = palletTasks;
|
|
|
|
|
_configInfoBusiness =configInfoBusiness;
|
|
|
|
|
// testTran();
|
|
|
|
|
_mesPrdBarCodeService = serviceProvider.GetRequiredService<IMesPrdBarCodeService>();
|
|
|
|
|
|
|
|
|
|
_configInfoBusiness = configInfoBusiness;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async void testTran()
|
|
|
|
|
public void TestTran()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
|
BaseRealTask localPlan = _baseRealTaskService.GetExeTask();
|
|
|
|
|
localPlan.Status = 2;
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("local").Updateable(localPlan).ExecuteCommand();
|
|
|
|
|
GenerateBarcode(10);
|
|
|
|
|
// throw new Exception("事务测试");
|
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
|
Console.WriteLine("提交事务");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void testRFID()
|
|
|
|
|
{
|
|
|
|
|
//TcpClient tcpClient = new TcpClient();
|
|
|
|
|
|
|
|
|
|
//var waitClient = tcpClient.CreateWaitingClient(new WaitingOptions()
|
|
|
|
@ -350,15 +373,6 @@ namespace SlnMesnac.Business
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"投料校验异常:{e.Message}");
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
continue;
|
|
|
|
|
// TODO修改成传入本地计划查询出的mes计划
|
|
|
|
|
// result = MatPutInValidTriggerEvent(2, prodPlan, string.Empty, $"投料校验异常:{e.Message},是否继续投料");
|
|
|
|
|
}
|
|
|
|
|
if (prodPlan != null)
|
|
|
|
|
{
|
|
|
|
|
// 下发翻转信号
|
|
|
|
@ -366,22 +380,33 @@ namespace SlnMesnac.Business
|
|
|
|
|
Thread.Sleep(300);
|
|
|
|
|
plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"), false);
|
|
|
|
|
|
|
|
|
|
#region 清空投料系统运行时间
|
|
|
|
|
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "拆包机系统运行时长").FirstOrDefault();
|
|
|
|
|
configInfo.ConfigValue = "0";
|
|
|
|
|
_configInfoBusiness.UpdateConfigInfo(configInfo);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//在小包2楼绑定托盘时完成计划
|
|
|
|
|
// PutInResutlHandle(prodPlan, result);
|
|
|
|
|
|
|
|
|
|
// 完成本地计划
|
|
|
|
|
sqlSugarClient.AsTenant().BeginTran();
|
|
|
|
|
//1.完成本地计划
|
|
|
|
|
if (localPlan != null)
|
|
|
|
|
{
|
|
|
|
|
localPlan.Status = 2;
|
|
|
|
|
localPlan.UpdateTime = DateTime.Now;
|
|
|
|
|
_baseRealTaskService.Update(localPlan);
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("local").Updateable(localPlan).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
//2.生成小包条码
|
|
|
|
|
GenerateBarcode(40);
|
|
|
|
|
//3.清空投料系统运行时间
|
|
|
|
|
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "拆包机系统运行时长").FirstOrDefault();
|
|
|
|
|
configInfo.ConfigValue = "0";
|
|
|
|
|
_configInfoBusiness.UpdateConfigInfo(configInfo);
|
|
|
|
|
|
|
|
|
|
sqlSugarClient.AsTenant().CommitTran();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient.AsTenant().RollbackTran();
|
|
|
|
|
_logger.LogInformation($"投料流程异常:{e.Message}");
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
@ -474,6 +499,28 @@ namespace SlnMesnac.Business
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 投料后产生小包条码存储到数据库等待绑定
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void GenerateBarcode(int amount)
|
|
|
|
|
{
|
|
|
|
|
List<MesPrdBarcodeInfo> list = new List<MesPrdBarcodeInfo>();
|
|
|
|
|
string baseDate = DateTime.Now.ToString("yyyyMMddHHmm"); // 当前日期和时间到分钟
|
|
|
|
|
for (int i = 1; i <= amount; i++)
|
|
|
|
|
{
|
|
|
|
|
MesPrdBarcodeInfo record = new MesPrdBarcodeInfo();
|
|
|
|
|
record = new MesPrdBarcodeInfo();
|
|
|
|
|
record.PrdBarcodeInfo = baseDate + i.ToString("D3"); // 将序号格式化为三位数
|
|
|
|
|
record.PrintFlag = "0";
|
|
|
|
|
record.CreatTime = DateTime.Now;
|
|
|
|
|
list.Add(record);
|
|
|
|
|
}
|
|
|
|
|
sqlSugarClient.AsTenant().GetConnection("mes").Insertable(list).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新生产计划
|
|
|
|
|
/// </summary>
|
|
|
|
|