|
|
|
@ -54,7 +54,7 @@ namespace SlnMesnac.Business
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备生产管理业务类 -3F
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ProdMgmtBusiness: BaseBusiness
|
|
|
|
|
public class ProdMgmtBusiness : BaseBusiness
|
|
|
|
|
{
|
|
|
|
|
public readonly IMesProductPlanService _mesProductPlanService;
|
|
|
|
|
|
|
|
|
@ -64,19 +64,24 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
public readonly IWmsOutStockService _wmsOutStockService;
|
|
|
|
|
|
|
|
|
|
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) : 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, List<RealPalletTask> palletTasks, IServiceProvider serviceProvider, ConfigInfoBusiness configInfoBusiness) : base(logger, appConfig, plcFactories, rfidFactories, serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
sqlSugarClient = _sqlSugarClient;
|
|
|
|
|
_wmsOutStockService = wmsOutStockService;
|
|
|
|
|
|
|
|
|
|
sqlSugarClient = _sqlSugarClient;
|
|
|
|
|
_wmsOutStockService = wmsOutStockService;
|
|
|
|
|
_mesProductPlanService = mesProductPlanService;
|
|
|
|
|
_basePalletInfoService = basePalletInfoService;
|
|
|
|
|
_baseRealTaskService = baseRealTaskService;
|
|
|
|
|
_palletTasks = palletTasks;
|
|
|
|
|
// testTran();
|
|
|
|
|
_configInfoBusiness =configInfoBusiness;
|
|
|
|
|
// testTran();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async void testTran()
|
|
|
|
@ -94,10 +99,10 @@ namespace SlnMesnac.Business
|
|
|
|
|
//tcpClient.Setup(new TouchSocketConfig().SetRemoteIPHost($"192.168.2.51:3000"));
|
|
|
|
|
//tcpClient.Connect();
|
|
|
|
|
// byte[] reciveBuffer = await waitClient.SendThenReturnAsync(pMessagePack.m_pData, timeout);
|
|
|
|
|
string aaa =await ReadEpcStrByRfidKeyAsync("test");
|
|
|
|
|
// ReadEpcStrByRfidKey("test", out string epcStr);
|
|
|
|
|
Console.WriteLine(aaa);
|
|
|
|
|
//RefreshMessage($"投料校验RFID标签读取成功,标签信息:{epcStr}");
|
|
|
|
|
string aaa = await ReadEpcStrByRfidKeyAsync("test");
|
|
|
|
|
// ReadEpcStrByRfidKey("test", out string epcStr);
|
|
|
|
|
Console.WriteLine(aaa);
|
|
|
|
|
//RefreshMessage($"投料校验RFID标签读取成功,标签信息:{epcStr}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -140,7 +145,7 @@ namespace SlnMesnac.Business
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// var aaa = _mesProductPlanService.GetMesProductPlans();
|
|
|
|
|
// var aaa = _mesProductPlanService.GetMesProductPlans();
|
|
|
|
|
var info = _mesProductPlanService.GetPlanDtos();
|
|
|
|
|
RefreshProdPlanListEvent?.Invoke(info);
|
|
|
|
|
}
|
|
|
|
@ -194,19 +199,19 @@ namespace SlnMesnac.Business
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RefreshMessage("设备要料信号触发成功");
|
|
|
|
|
|
|
|
|
|
RefreshProdPlanExecEvent?.Invoke(prodPlan);
|
|
|
|
|
|
|
|
|
|
// string palletCode = GetPalletInfoByTask();
|
|
|
|
|
// string palletCode = GetPalletInfoByTask();
|
|
|
|
|
|
|
|
|
|
RefreshMessage($"执行计划:{prodPlan.PlanCode};计划数量:{Math.Round(prodPlan.PlanAmount,2)};完成数量:{Math.Round(prodPlan.CompleteAmount,2)};发起叫料申请");
|
|
|
|
|
RefreshMessage($"执行计划:{prodPlan.PlanCode};计划数量:{Math.Round(prodPlan.PlanAmount, 2)};完成数量:{Math.Round(prodPlan.CompleteAmount, 2)};发起叫料申请");
|
|
|
|
|
|
|
|
|
|
//查询下发agv的主键
|
|
|
|
|
WmsRawOutstock wmsRaw = _wmsOutStockService.GetProdPlanByPlanCode(prodPlan.PlanCode);
|
|
|
|
|
WmsRawOutstock wmsRaw = _wmsOutStockService.GetProdPlanByPlanCode(prodPlan.PlanCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//进行叫料
|
|
|
|
@ -261,7 +266,7 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
localPlan = _baseRealTaskService.GetExeTask();
|
|
|
|
|
|
|
|
|
|
if (localPlan== null)
|
|
|
|
|
if (localPlan == null)
|
|
|
|
|
{
|
|
|
|
|
RefreshMessage("本地未获取到叫料任务......");
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
@ -283,14 +288,14 @@ namespace SlnMesnac.Business
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO 时间校验,修改为计算设备运行20分钟
|
|
|
|
|
// TODO 投料时间校验
|
|
|
|
|
bool timeCheck = JudgeProductTime();
|
|
|
|
|
if (!timeCheck)
|
|
|
|
|
{
|
|
|
|
|
RefreshMessage($"收到物料到位信号,但是距离上次投料不满20min,禁止投料");
|
|
|
|
|
Thread.Sleep(1000 * 15);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
RefreshMessage($"投料时间校验通过");
|
|
|
|
|
|
|
|
|
|
// 调用调度接口,判断AGV小车是否已经离开到位,否则不允许投料
|
|
|
|
|
bool positionCheck = JudgeAgvPosition();
|
|
|
|
@ -345,8 +350,6 @@ namespace SlnMesnac.Business
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
@ -359,16 +362,21 @@ namespace SlnMesnac.Business
|
|
|
|
|
if (prodPlan != null)
|
|
|
|
|
{
|
|
|
|
|
// 下发翻转信号
|
|
|
|
|
plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"),true);
|
|
|
|
|
plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"), true);
|
|
|
|
|
Thread.Sleep(300);
|
|
|
|
|
plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"), false);
|
|
|
|
|
|
|
|
|
|
debugConfig.LastTime = DateTime.Now.ToString();
|
|
|
|
|
#region 清空投料系统运行时间
|
|
|
|
|
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "拆包机系统运行时长").FirstOrDefault();
|
|
|
|
|
configInfo.ConfigValue = "0";
|
|
|
|
|
_configInfoBusiness.UpdateConfigInfo(configInfo);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//在小包2楼绑定托盘时完成计划
|
|
|
|
|
// PutInResutlHandle(prodPlan, result);
|
|
|
|
|
// PutInResutlHandle(prodPlan, result);
|
|
|
|
|
|
|
|
|
|
// 完成本地计划
|
|
|
|
|
if(localPlan!= null)
|
|
|
|
|
if (localPlan != null)
|
|
|
|
|
{
|
|
|
|
|
localPlan.Status = 2;
|
|
|
|
|
localPlan.UpdateTime = DateTime.Now;
|
|
|
|
@ -385,7 +393,7 @@ namespace SlnMesnac.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="prodPlan"></param>
|
|
|
|
|
/// <param name="isRes"></param>
|
|
|
|
|
private void PutInResutlHandle(MesProductPlan prodPlan,bool isRes)
|
|
|
|
|
private void PutInResutlHandle(MesProductPlan prodPlan, bool isRes)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -406,7 +414,8 @@ namespace SlnMesnac.Business
|
|
|
|
|
{
|
|
|
|
|
RefreshMessage("投料校验失败,人工确认不许投料");
|
|
|
|
|
}
|
|
|
|
|
}catch(Exception e)
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"投料结果处理异常:{e.Message}");
|
|
|
|
|
}
|
|
|
|
@ -438,10 +447,10 @@ namespace SlnMesnac.Business
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var content = new
|
|
|
|
|
{
|
|
|
|
|
rawOutstockId = taskId,
|
|
|
|
|
};
|
|
|
|
|
var content = new
|
|
|
|
|
{
|
|
|
|
|
rawOutstockId = taskId,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string message = JsonConvert.SerializeObject(content);
|
|
|
|
|
//询问小车是否离开接口 0已经离开
|
|
|
|
@ -480,7 +489,7 @@ namespace SlnMesnac.Business
|
|
|
|
|
|
|
|
|
|
var info = _mesProductPlanService.GetProdPlanByPlanCode(planInfo.PlanCode);
|
|
|
|
|
|
|
|
|
|
if(info == null)
|
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("更新生产计划异常:根据计划编号获取计划信息为空");
|
|
|
|
|
}
|
|
|
|
@ -510,33 +519,22 @@ namespace SlnMesnac.Business
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int IntervalMin = int.Parse(GetPlcAddressByConfigKey("投料时间间隔")); // 单位分钟
|
|
|
|
|
if (debugConfig.LastTime != "")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DateTime lastTime = DateTime.Parse(debugConfig.LastTime);
|
|
|
|
|
|
|
|
|
|
TimeSpan timeDifference = DateTime.Now - lastTime;
|
|
|
|
|
|
|
|
|
|
if (timeDifference.TotalMinutes > IntervalMin)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
int systemRunTime = int.Parse(GetPlcAddressByConfigKey("拆包机系统运行时长")); // 单位分钟
|
|
|
|
|
|
|
|
|
|
if (systemRunTime > IntervalMin)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
RefreshMessage($"收到物料到位请求投料信号,但是距离上次投料不满20min,禁止投料");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"距离上次投料时间合格判断异常JudgeProductTime:{ex.Message}");
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|