|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using HighWayIot.Config;
|
|
|
|
|
using HighWayIot.Log4net;
|
|
|
|
|
using HighWayIot.Plc;
|
|
|
|
|
using HighWayIot.Repository.service;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
@ -56,8 +57,8 @@ namespace Aucma.Scada.Business
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 已下传的任务信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<RealTaskInfo> shellTaskInfos = new List<RealTaskInfo>();
|
|
|
|
|
private List<RealTaskInfo> linerTaskInfos = new List<RealTaskInfo>();
|
|
|
|
|
// private List<RealTaskInfo> shellTaskInfos = new List<RealTaskInfo>();
|
|
|
|
|
// private List<RealTaskInfo> linerTaskInfos = new List<RealTaskInfo>();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 委托事件
|
|
|
|
@ -78,17 +79,112 @@ namespace Aucma.Scada.Business
|
|
|
|
|
public event InStoreAnswer InStoreAnswerEvent;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 实时任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IRealTaskInfoService _taskInfoService;
|
|
|
|
|
private RegisterServices registerServices = RegisterServices.Instance;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private InStoreTaskHandle()
|
|
|
|
|
{
|
|
|
|
|
_taskInfoService = registerServices.GetService<IRealTaskInfoService>();
|
|
|
|
|
_plcDictionary = _pool.GetAll();
|
|
|
|
|
RealReadFinish();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 判断箱壳,内胆入库是否完成
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 实时读取箱壳,内胆入库完成信号
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void RealReadFinish()
|
|
|
|
|
{
|
|
|
|
|
// 箱壳线程
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
if (_plcDictionary.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
IPlc _plc = _plcDictionary[appConfig.shellStoreCode];
|
|
|
|
|
if (_plc != null && _plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
List<RealTaskInfo> taskList = _taskInfoService.GetTaskInfosForInstore(appConfig.shellStoreCode, appConfig.instoreTaskType, 2);
|
|
|
|
|
if (taskList != null && taskList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (RealTaskInfo taskInfo in taskList)
|
|
|
|
|
{
|
|
|
|
|
SpaceAddress spaceAddress = spaceConfig.GetSpaceAddress(appConfig.shellStoreCode, taskInfo.spaceCode);
|
|
|
|
|
JudgeIsFinish(taskInfo, _plc, spaceAddress, appConfig.shellStoreCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
logHelper.Info($"PLC信息为空或连接失败,通过{appConfig.shellStoreCode}未获取到该仓库对应的PLC信息");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
//内胆线程
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
if (_plcDictionary.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
IPlc _plc = _plcDictionary[appConfig.linerStoreCode];
|
|
|
|
|
if (_plc != null && _plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
// 修改这个方法
|
|
|
|
|
List<RealTaskInfo> taskList = _taskInfoService.GetTaskInfosForInstore(appConfig.linerStoreCode, appConfig.instoreTaskType, 2);
|
|
|
|
|
if (taskList != null && taskList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (RealTaskInfo taskInfo in taskList)
|
|
|
|
|
{
|
|
|
|
|
SpaceAddress spaceAddress = spaceConfig.GetSpaceAddress(appConfig.linerStoreCode, taskInfo.spaceCode);
|
|
|
|
|
JudgeIsFinish(taskInfo, _plc, spaceAddress, appConfig.linerStoreCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
logHelper.Info($"PLC信息为空或连接失败,通过{appConfig.linerStoreCode}未获取到该仓库对应的PLC信息");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RealReadPlcSpace();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 判断该任务对应的货道是否有完成信号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public void JudgeIsFinish(RealTaskInfo taskInfo, IPlc _plc, SpaceAddress spaceAddress,string storeCode)
|
|
|
|
|
{
|
|
|
|
|
//读取入库完成反馈信号
|
|
|
|
|
if (_plc.readInt32ByAddress(spaceAddress.inStoreFinish) == 1)
|
|
|
|
|
{
|
|
|
|
|
_plc.writeInt32ByAddress(spaceAddress.inStoreFinish, 0);
|
|
|
|
|
InStoreFinsihEvent?.Invoke(storeCode, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 箱壳入库任务下发处理
|
|
|
|
|
public bool SendShellTask_InStore(RealTaskInfo taskInfo)
|
|
|
|
|
public int SendShellTask_InStore(RealTaskInfo taskInfo)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
int result = 0;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IPlc _plc = _plcDictionary[taskInfo.storeCode];
|
|
|
|
@ -97,17 +193,24 @@ namespace Aucma.Scada.Business
|
|
|
|
|
{
|
|
|
|
|
if (_plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
//写入货道号
|
|
|
|
|
_plc.writeStringByAddress(plcConfig.in_shell_spaceCode, taskInfo.spaceCode);
|
|
|
|
|
//写入应答字
|
|
|
|
|
_plc.writeInt32ByAddress(plcConfig.in_shell_answer, 1);
|
|
|
|
|
//写入任务号
|
|
|
|
|
_plc.writeStringByAddress(plcConfig.in_shell_task, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
//写入完成后读取应答字进行复位
|
|
|
|
|
ReadShellAnswer_InStore(taskInfo);
|
|
|
|
|
|
|
|
|
|
result = true;
|
|
|
|
|
if (_plc.readInt32ByAddress(plcConfig.in_shell_answer) == 1)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Info("箱壳入库应答字为1,货道号:" + plcConfig.in_shell_spaceCode + ";写" + short.Parse(taskInfo.spaceCode.Substring(5, 1)));
|
|
|
|
|
//写入货道号
|
|
|
|
|
_plc.writeInt32ByAddress(plcConfig.in_shell_spaceCode, short.Parse(taskInfo.spaceCode.Substring(5, 1)));
|
|
|
|
|
//写入完成后读取应答字进行复位
|
|
|
|
|
ReadShellAnswer_InStore(taskInfo);
|
|
|
|
|
//写入应答字
|
|
|
|
|
// _plc.writeInt32ByAddress(plcConfig.in_shell_answer, 1);
|
|
|
|
|
//写入任务号
|
|
|
|
|
// _plc.writeStringByAddress(plcConfig.in_shell_task, taskInfo.taskCode);
|
|
|
|
|
result = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = 2;
|
|
|
|
|
logHelper.PlcLog("应答字为2,下发新任务plc未就绪");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -149,22 +252,18 @@ namespace Aucma.Scada.Business
|
|
|
|
|
//读取PLC应答字为2时,上位机清空写入的入库内容
|
|
|
|
|
if (_plc.readInt32ByAddress(plcConfig.in_shell_answer) == 2)
|
|
|
|
|
{
|
|
|
|
|
logHelper.PlcLog("内胆入库应答字为2,货道号:" + plcConfig.in_shell_spaceCode + ";复位写0");
|
|
|
|
|
//写入货道号
|
|
|
|
|
_plc.writeStringByAddress(plcConfig.in_shell_spaceCode, string.Empty);
|
|
|
|
|
_plc.writeInt32ByAddress(plcConfig.in_shell_spaceCode, 0);
|
|
|
|
|
//写入应答字
|
|
|
|
|
_plc.writeInt32ByAddress(plcConfig.in_shell_answer, 0);
|
|
|
|
|
//写入任务号
|
|
|
|
|
_plc.writeStringByAddress(plcConfig.in_shell_task, string.Empty);
|
|
|
|
|
// _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 0);
|
|
|
|
|
|
|
|
|
|
isFlag = false;
|
|
|
|
|
WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
|
|
|
|
|
|
|
|
|
|
//ReadShellFinish_InStore(taskCode);
|
|
|
|
|
InStoreAnswerEvent?.Invoke(appConfig.shellStoreCode, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
shellTaskInfos.Add(taskInfo);
|
|
|
|
|
// shellTaskInfos.Add(taskInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
} while (isFlag);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -191,9 +290,9 @@ namespace Aucma.Scada.Business
|
|
|
|
|
/// 内胆入库任务下发
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskInfo"></param>
|
|
|
|
|
public bool SendLinerTask_InStore(RealTaskInfo taskInfo)
|
|
|
|
|
public int SendLinerTask_InStore(RealTaskInfo taskInfo)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
int result = 0;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IPlc _plc = _plcDictionary[appConfig.linerStoreCode];
|
|
|
|
@ -202,17 +301,27 @@ namespace Aucma.Scada.Business
|
|
|
|
|
{
|
|
|
|
|
if (_plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
//写入货道号
|
|
|
|
|
_plc.writeStringByAddress(plcConfig.in_liner_spaceCode, taskInfo.spaceCode);
|
|
|
|
|
//写入应答字
|
|
|
|
|
_plc.writeInt32ByAddress(plcConfig.in_liner_answer, 1);
|
|
|
|
|
//写入任务号
|
|
|
|
|
_plc.writeStringByAddress(plcConfig.in_liner_task, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
//写入完成后读取应答字进行复位
|
|
|
|
|
ReadLinerAnswer_InStore(taskInfo);
|
|
|
|
|
|
|
|
|
|
result = true;
|
|
|
|
|
if (_plc.readInt32ByAddress(plcConfig.in_liner_answer) == 1)
|
|
|
|
|
{
|
|
|
|
|
logHelper.PlcLog("内胆入库应答字为1,货道号:" + plcConfig.in_liner_spaceCode + ";写" + short.Parse(taskInfo.spaceCode.Substring(5, 1)));
|
|
|
|
|
//写入货道号
|
|
|
|
|
_plc.writeInt32ByAddress(plcConfig.in_liner_spaceCode, short.Parse(taskInfo.spaceCode.Substring(5, 1)));
|
|
|
|
|
//写入应答字
|
|
|
|
|
// _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 1);
|
|
|
|
|
//写入任务号
|
|
|
|
|
// _plc.writeStringByAddress(plcConfig.in_foam_task, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
//写入完成后读取应答字进行复位
|
|
|
|
|
ReadLinerAnswer_InStore(taskInfo);
|
|
|
|
|
|
|
|
|
|
result = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = 2;
|
|
|
|
|
logHelper.PlcLog("内胆应答字为2,下发新任务plc未就绪");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -254,20 +363,21 @@ namespace Aucma.Scada.Business
|
|
|
|
|
//读取PLC应答字为2时,上位机清空写入的入库内容
|
|
|
|
|
if (_plc.readInt32ByAddress(plcConfig.in_liner_answer) == 2)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
logHelper.PlcLog("内胆入库应答字为2,货道号:" + plcConfig.in_liner_spaceCode + ";复位写0");
|
|
|
|
|
//写入货道号
|
|
|
|
|
_plc.writeStringByAddress(plcConfig.in_liner_spaceCode, string.Empty);
|
|
|
|
|
_plc.writeInt32ByAddress(plcConfig.in_liner_spaceCode, 0);
|
|
|
|
|
//写入应答字
|
|
|
|
|
_plc.writeInt32ByAddress(plcConfig.in_liner_answer, 0);
|
|
|
|
|
//写入任务号
|
|
|
|
|
_plc.writeStringByAddress(plcConfig.in_liner_task, string.Empty);
|
|
|
|
|
isFlag = false;
|
|
|
|
|
// _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 0);
|
|
|
|
|
|
|
|
|
|
isFlag = false;
|
|
|
|
|
InStoreAnswerEvent?.Invoke(appConfig.linerStoreCode, taskInfo.taskCode);
|
|
|
|
|
//ReadLinerFinish_InStore(taskCode);
|
|
|
|
|
// WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
|
|
|
|
|
|
|
|
|
|
InStoreAnswerEvent?.Invoke(appConfig.linerStoreCode, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
linerTaskInfos.Add(taskInfo);
|
|
|
|
|
// linerTaskInfos.Add(taskInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
@ -292,7 +402,7 @@ namespace Aucma.Scada.Business
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 读取PLC入库完成 Delete By Wenjy 2023-11-08 15:05:00,经讨论入库完成改为监测在途数量变化
|
|
|
|
|
#region 读取PLC入库完成 Delete By Wenjy 2023-11-08 15:05:00,经讨论入库完成改为监测在途数量变化
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取箱壳入库完成
|
|
|
|
|
/// </summary>
|
|
|
|
@ -398,139 +508,142 @@ namespace Aucma.Scada.Business
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 监测PLC在途数量变化,完成入库任务
|
|
|
|
|
|
|
|
|
|
private void RealReadPlcSpace()
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
RealReadShellPlcSpace();
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
RealReadLinerPlcSpace();
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取箱壳已下发任务的货道信息,读取后将货道编号及在途数量写入Dictionary进行比较,在途数减少则入库完成
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void RealReadShellPlcSpace()
|
|
|
|
|
{
|
|
|
|
|
if (shellTaskInfos != null)
|
|
|
|
|
{
|
|
|
|
|
List<string> spaceCodes = shellTaskInfos.Select(x => x.spaceCode).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < spaceCodes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string spaceCode = spaceCodes[i];
|
|
|
|
|
|
|
|
|
|
BaseSpaceInfo spaceInfo = new BaseSpaceInfo() { storeCode = appConfig.shellStoreCode, spaceCode = spaceCode };
|
|
|
|
|
|
|
|
|
|
spaceInfo = ReadSpaceInfoByPlc(spaceInfo);
|
|
|
|
|
|
|
|
|
|
if (shellKeyValuePairs.ContainsKey(spaceInfo.spaceCode))
|
|
|
|
|
{
|
|
|
|
|
shellKeyValuePairs.TryGetValue(spaceInfo.spaceCode, out int value);
|
|
|
|
|
//判断前次读取的数据和当前数据,如果前次数据大于当前数据则代表入库完成,然后筛选任务中对应货道的首个任务进行完成
|
|
|
|
|
//如果前次数据不大于当前数据则更新字典中存放的数据
|
|
|
|
|
if (value > spaceInfo.onRouteAmount)
|
|
|
|
|
{
|
|
|
|
|
//筛选任务
|
|
|
|
|
var list = shellTaskInfos.Where(x => x.spaceCode == spaceInfo.spaceCode).ToList();
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo taskInfo = list.OrderBy(x => x.createTime).First();
|
|
|
|
|
|
|
|
|
|
InStoreFinsihEvent?.Invoke(taskInfo.storeCode, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
shellTaskInfos.Remove(taskInfo);
|
|
|
|
|
}
|
|
|
|
|
shellKeyValuePairs.Remove(spaceInfo.spaceCode);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
shellKeyValuePairs[spaceInfo.spaceCode] = spaceInfo.onRouteAmount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
shellKeyValuePairs.Add(spaceInfo.spaceCode, spaceInfo.onRouteAmount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取内胆已下发任务的货道信息,读取后将货道编号及在途数量写入Dictionary进行比较,在途数减少则入库完成
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void RealReadLinerPlcSpace()
|
|
|
|
|
{
|
|
|
|
|
if (linerTaskInfos != null)
|
|
|
|
|
{
|
|
|
|
|
List<string> spaceCodes = linerTaskInfos.Select(x => x.spaceCode).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < spaceCodes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string spaceCode = spaceCodes[i];
|
|
|
|
|
|
|
|
|
|
BaseSpaceInfo spaceInfo = new BaseSpaceInfo() { storeCode = appConfig.linerStoreCode, spaceCode = spaceCode };
|
|
|
|
|
|
|
|
|
|
spaceInfo = ReadSpaceInfoByPlc(spaceInfo);
|
|
|
|
|
|
|
|
|
|
if (linerKeyValuePairs.ContainsKey(spaceInfo.spaceCode))
|
|
|
|
|
{
|
|
|
|
|
linerKeyValuePairs.TryGetValue(spaceInfo.spaceCode, out int value);
|
|
|
|
|
//判断前次读取的数据和当前数据,如果前次数据大于当前数据则代表入库完成,然后筛选任务中对应货道的首个任务进行完成
|
|
|
|
|
//如果前次数据不大于当前数据则更新字典中存放的数据
|
|
|
|
|
if (value > spaceInfo.onRouteAmount)
|
|
|
|
|
{
|
|
|
|
|
//筛选任务
|
|
|
|
|
var list = linerTaskInfos.Where(x => x.spaceCode == spaceInfo.spaceCode).ToList();
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo taskInfo = list.OrderBy(x => x.createTime).First();
|
|
|
|
|
|
|
|
|
|
InStoreFinsihEvent?.Invoke(taskInfo.storeCode, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
linerTaskInfos.Remove(taskInfo);
|
|
|
|
|
}
|
|
|
|
|
linerKeyValuePairs.Remove(spaceInfo.spaceCode);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
linerKeyValuePairs[spaceInfo.spaceCode] = spaceInfo.onRouteAmount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
linerKeyValuePairs.Add(spaceInfo.spaceCode, spaceInfo.onRouteAmount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region 监测PLC在途数量变化,完成入库任务 delete by liuwf 2024-01-06,入库完成改成根据每个货道完成信号完成任务
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private void RealReadPlcSpace()
|
|
|
|
|
//{
|
|
|
|
|
// Thread.Sleep(1000);
|
|
|
|
|
// Task.Run(() =>
|
|
|
|
|
// {
|
|
|
|
|
// while (true)
|
|
|
|
|
// {
|
|
|
|
|
// RealReadShellPlcSpace();
|
|
|
|
|
|
|
|
|
|
// Thread.Sleep(500);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// Task.Run(() =>
|
|
|
|
|
// {
|
|
|
|
|
// while (true)
|
|
|
|
|
// {
|
|
|
|
|
// RealReadLinerPlcSpace();
|
|
|
|
|
|
|
|
|
|
// Thread.Sleep(500);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 读取箱壳已下发任务的货道信息,读取后将货道编号及在途数量写入Dictionary进行比较,在途数减少则入库完成
|
|
|
|
|
///// </summary>
|
|
|
|
|
//private void RealReadShellPlcSpace()
|
|
|
|
|
//{
|
|
|
|
|
// if (shellTaskInfos != null)
|
|
|
|
|
// {
|
|
|
|
|
// List<string> spaceCodes = shellTaskInfos.Select(x => x.spaceCode).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
// for (int i = 0; i < spaceCodes.Count; i++)
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// string spaceCode = spaceCodes[i];
|
|
|
|
|
|
|
|
|
|
// BaseSpaceInfo spaceInfo = new BaseSpaceInfo() { storeCode = appConfig.shellStoreCode, spaceCode = spaceCode };
|
|
|
|
|
|
|
|
|
|
// spaceInfo = ReadSpaceInfoByPlc(spaceInfo);
|
|
|
|
|
|
|
|
|
|
// if (shellKeyValuePairs.ContainsKey(spaceInfo.spaceCode))
|
|
|
|
|
// {
|
|
|
|
|
// shellKeyValuePairs.TryGetValue(spaceInfo.spaceCode, out int value);
|
|
|
|
|
// //判断前次读取的数据和当前数据,如果前次数据大于当前数据则代表入库完成,然后筛选任务中对应货道的首个任务进行完成
|
|
|
|
|
// //如果前次数据不大于当前数据则更新字典中存放的数据
|
|
|
|
|
// if (value > spaceInfo.onRouteAmount)
|
|
|
|
|
// {
|
|
|
|
|
// //筛选任务
|
|
|
|
|
// var list = shellTaskInfos.Where(x => x.spaceCode == spaceInfo.spaceCode).ToList();
|
|
|
|
|
// if (list.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// RealTaskInfo taskInfo = list.OrderBy(x => x.createTime).First();
|
|
|
|
|
|
|
|
|
|
// InStoreFinsihEvent?.Invoke(taskInfo.storeCode, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
// shellTaskInfos.Remove(taskInfo);
|
|
|
|
|
// }
|
|
|
|
|
// shellKeyValuePairs.Remove(spaceInfo.spaceCode);
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// shellKeyValuePairs[spaceInfo.spaceCode] = spaceInfo.onRouteAmount;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// shellKeyValuePairs.Add(spaceInfo.spaceCode, spaceInfo.onRouteAmount);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 读取内胆已下发任务的货道信息,读取后将货道编号及在途数量写入Dictionary进行比较,在途数减少则入库完成
|
|
|
|
|
///// </summary>
|
|
|
|
|
//private void RealReadLinerPlcSpace()
|
|
|
|
|
//{
|
|
|
|
|
// if (linerTaskInfos != null)
|
|
|
|
|
// {
|
|
|
|
|
// List<string> spaceCodes = linerTaskInfos.Select(x => x.spaceCode).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
// for (int i = 0; i < spaceCodes.Count; i++)
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// string spaceCode = spaceCodes[i];
|
|
|
|
|
|
|
|
|
|
// BaseSpaceInfo spaceInfo = new BaseSpaceInfo() { storeCode = appConfig.linerStoreCode, spaceCode = spaceCode };
|
|
|
|
|
|
|
|
|
|
// spaceInfo = ReadSpaceInfoByPlc(spaceInfo);
|
|
|
|
|
|
|
|
|
|
// if (linerKeyValuePairs.ContainsKey(spaceInfo.spaceCode))
|
|
|
|
|
// {
|
|
|
|
|
// linerKeyValuePairs.TryGetValue(spaceInfo.spaceCode, out int value);
|
|
|
|
|
// //判断前次读取的数据和当前数据,如果前次数据大于当前数据则代表入库完成,然后筛选任务中对应货道的首个任务进行完成
|
|
|
|
|
// //如果前次数据不大于当前数据则更新字典中存放的数据
|
|
|
|
|
// if (value > spaceInfo.onRouteAmount)
|
|
|
|
|
// {
|
|
|
|
|
// //筛选任务
|
|
|
|
|
// var list = linerTaskInfos.Where(x => x.spaceCode == spaceInfo.spaceCode).ToList();
|
|
|
|
|
// if (list.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// RealTaskInfo taskInfo = list.OrderBy(x => x.createTime).First();
|
|
|
|
|
|
|
|
|
|
// InStoreFinsihEvent?.Invoke(taskInfo.storeCode, taskInfo.taskCode);
|
|
|
|
|
|
|
|
|
|
// linerTaskInfos.Remove(taskInfo);
|
|
|
|
|
// }
|
|
|
|
|
// linerKeyValuePairs.Remove(spaceInfo.spaceCode);
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// linerKeyValuePairs[spaceInfo.spaceCode] = spaceInfo.onRouteAmount;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// linerKeyValuePairs.Add(spaceInfo.spaceCode, spaceInfo.onRouteAmount);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC获取货道信息
|
|
|
|
|
/// </summary>
|
|
|
|
@ -547,7 +660,7 @@ namespace Aucma.Scada.Business
|
|
|
|
|
{
|
|
|
|
|
spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore);
|
|
|
|
|
spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute);
|
|
|
|
|
spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus);
|
|
|
|
|
// spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|