|
|
|
@ -83,11 +83,6 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 入库出库完成信号定时器
|
|
|
|
|
/// </summary>
|
|
|
|
|
System.Timers.Timer timer = new System.Timers.Timer(1000);
|
|
|
|
|
|
|
|
|
|
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(InStoreBusiness));
|
|
|
|
|
private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
|
|
|
|
|
private readonly IRealTaskInfoServices? _realTaskInfoService = App.ServiceProvider.GetService<IRealTaskInfoServices>();
|
|
|
|
@ -116,37 +111,17 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
{
|
|
|
|
|
spaceAddresses.Add(spaceConfig.GetSpaceAddress(storeCode, space.SpaceCode));
|
|
|
|
|
}
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
|
|
// test();
|
|
|
|
|
// 获取任务下发plc
|
|
|
|
|
// StartPassDown();
|
|
|
|
|
// InStore("B23600083025024860011");
|
|
|
|
|
});
|
|
|
|
|
// startTimer();
|
|
|
|
|
}
|
|
|
|
|
//实时监测入库任务下发和入库任务完成
|
|
|
|
|
StartPassDownAndRealInstoreFinish();
|
|
|
|
|
|
|
|
|
|
public async void test()
|
|
|
|
|
{
|
|
|
|
|
// InStoreFinish("PB01_001");
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 入库出库完成信号定时器
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void startTimer()
|
|
|
|
|
{
|
|
|
|
|
timer.Elapsed += new System.Timers.ElapsedEventHandler(RealInstoreFinish); //到达时间的时候执行事件;
|
|
|
|
|
timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
|
|
|
|
|
timer.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
|
|
|
|
|
timer.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 定时器实时监测入库出库完成信号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public void RealInstoreFinish(object? sender, ElapsedEventArgs e)
|
|
|
|
|
public void RealInstoreFinish()
|
|
|
|
|
{
|
|
|
|
|
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc"));
|
|
|
|
|
if (obj != null && obj.plc.IsConnected)
|
|
|
|
@ -163,21 +138,33 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
if (obj.plc.ReadInt16(spaceAddress.outStoreFinish) == 1)
|
|
|
|
|
{
|
|
|
|
|
obj.plc.WriteInt16(spaceAddress.outStoreFinish, "0");
|
|
|
|
|
// 减货道明细
|
|
|
|
|
// 系统不控制出库,暂时未使用出库完成信号
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async void StartPassDown()
|
|
|
|
|
/// <summary>
|
|
|
|
|
///实时监测入库任务下发和入库任务完成
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async void StartPassDownAndRealInstoreFinish()
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
PassDown();
|
|
|
|
|
Thread.Sleep(200000);
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
RealInstoreFinish();
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -523,103 +510,6 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#region 监测PLC在途数量变化,完成入库任务
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 读取箱壳已下发任务的货道信息,读取后将货道编号及在途数量写入Dictionary进行比较,在途数减少则入库完成
|
|
|
|
|
///// </summary>
|
|
|
|
|
//private void RealReadPlcSpace()
|
|
|
|
|
//{
|
|
|
|
|
// if (TaskInfos != null)
|
|
|
|
|
// {
|
|
|
|
|
// List<string> spaceCodes = TaskInfos.Select(x => x.SpaceCode).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
// for (int i = 0; i < spaceCodes.Count; i++)
|
|
|
|
|
// {
|
|
|
|
|
// string spaceCode = spaceCodes[i];
|
|
|
|
|
|
|
|
|
|
// BaseSpaceInfo spaceInfo = new BaseSpaceInfo() { StoreCode = storeCode, SpaceCode = spaceCode };
|
|
|
|
|
|
|
|
|
|
// spaceInfo = ReadSpaceInfoByPlc(spaceInfo);
|
|
|
|
|
|
|
|
|
|
// if (KeyValuePairs.ContainsKey(spaceInfo.SpaceCode))
|
|
|
|
|
// {
|
|
|
|
|
// KeyValuePairs.TryGetValue(spaceInfo.SpaceCode, out int value);
|
|
|
|
|
// //判断前次读取的数据和当前数据,如果前次数据大于当前数据则代表入库完成,然后筛选任务中对应货道的首个任务进行完成
|
|
|
|
|
// //如果前次数据不大于当前数据则更新字典中存放的数据
|
|
|
|
|
// if (value > spaceInfo.OnRouteAmount)
|
|
|
|
|
// {
|
|
|
|
|
// //筛选任务
|
|
|
|
|
// var list = TaskInfos.Where(x => x.SpaceCode == spaceInfo.SpaceCode).ToList();
|
|
|
|
|
// if (list.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// RealTaskInfo taskInfo = list.OrderBy(x => x.CreateTime).First();
|
|
|
|
|
// InStoreFinish(taskInfo.TaskCode);
|
|
|
|
|
|
|
|
|
|
// TaskInfos.Remove(taskInfo);
|
|
|
|
|
// }
|
|
|
|
|
// KeyValuePairs.Remove(spaceInfo.SpaceCode);
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// KeyValuePairs[spaceInfo.SpaceCode] = spaceInfo.OnRouteAmount;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// KeyValuePairs.Add(spaceInfo.SpaceCode, spaceInfo.OnRouteAmount);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取泡后入库完成
|
|
|
|
|
/// </summary>
|
|
|
|
|
//private void ReadShellFinish_InStore(string taskCode)
|
|
|
|
|
//{
|
|
|
|
|
// lock (string.Empty)
|
|
|
|
|
// {
|
|
|
|
|
// bool isFlag = true;
|
|
|
|
|
// var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc"));
|
|
|
|
|
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// Task.Run(() =>
|
|
|
|
|
// {
|
|
|
|
|
// if (obj != null && obj.plc.IsConnected)
|
|
|
|
|
// {
|
|
|
|
|
// do
|
|
|
|
|
// {
|
|
|
|
|
// //读取PLC入库任务完成
|
|
|
|
|
// if (obj.plc.ReadInt16("D220") == 1)
|
|
|
|
|
// {
|
|
|
|
|
// obj.plc.WriteInt16("D220", "0");
|
|
|
|
|
// FoamTaskFeedback(taskCode);
|
|
|
|
|
// isFlag = false;
|
|
|
|
|
// }
|
|
|
|
|
// Thread.Sleep(1000);
|
|
|
|
|
// } while (isFlag);
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// logHelper.Info("PLC未连接");
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// logHelper.Error("读取泡后入库完成异常", ex);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 泡前库执行反馈
|
|
|
|
@ -664,7 +554,7 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
|
|
|
|
|
await _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo);
|
|
|
|
|
|
|
|
|
|
#region 添加货道明细
|
|
|
|
|
#region 添加货道明细 不控制出库,暂时未添加明细
|
|
|
|
|
BaseSpaceDetail spaceDetail = new BaseSpaceDetail();
|
|
|
|
|
spaceDetail.MaterialType = taskInfo.MaterialType;
|
|
|
|
|
spaceDetail.MaterialCode = taskInfo.MaterialCode;
|
|
|
|
|