change - 入库逻辑处理

collectionStore
wenjy 1 year ago
parent 783b04fe9f
commit e7d2c05665

@ -99,17 +99,17 @@ namespace Aucma.Scada.Business
grabImage.RefreshLogMessageEvent += PrintLogInfoMessage;
StartPassDown();
//Task.Run(() =>
//{
// Thread.Sleep(6000);
// for (int i = 1; i < 2; i++)
// {
// //InStore(appConfig.shellStoreCode, "B2360000078110300" + i.ToString().PadLeft(2, '0'));
// //Thread.Sleep(1000);
// //InStore(appConfig.linerStoreCode, "L2360000078810240" + i.ToString().PadLeft(2, '0'));
// //Thread.Sleep(1000);
// }
//});
Task.Run(() =>
{
Thread.Sleep(6000);
for (int i = 1; i < 12; i++)
{
//InStore(appConfig.shellStoreCode, "B2360000078110600" + i.ToString().PadLeft(2, '0'));
//Thread.Sleep(1000*60*1);
//InStore(appConfig.linerStoreCode, "L2360000078110600" + i.ToString().PadLeft(2, '0'));
//Thread.Sleep(1000 * 60 * 1);
}
});
}
@ -131,6 +131,7 @@ namespace Aucma.Scada.Business
if (spaceInfo != null)
{
PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}");
spaceInfo.materialType = materialType;
RefreshScanMateriaCodeEvent?.Invoke(materialCode, GetMaterialName(materialType), spaceInfo.spaceName, storeCode); //刷新界面扫码信息
var result = CreateInStoreTask(spaceInfo, materialCode); //创建入库任务
if (result)
@ -241,15 +242,7 @@ namespace Aucma.Scada.Business
RefreshInStoreTaskEvent?.Invoke(taskInfo);
//if (shellSemaphore.Wait(TimeSpan.FromSeconds(20)))
//{
// // 收到反馈
// PrintLogInfoMessage("收到反馈,继续执行");
//}
//else
//{
// PrintLogInfoMessage("超时未反馈");
//}
taskHandle.WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
shellSemaphore.Wait(); //一直堵塞直到信号量释放
@ -289,15 +282,7 @@ namespace Aucma.Scada.Business
RefreshInStoreTaskEvent?.Invoke(taskInfo);
//if (shellSemaphore.Wait(TimeSpan.FromSeconds(20)))
//{
// // 收到反馈
// PrintLogInfoMessage("收到反馈,继续执行");
//}
//else
//{
// PrintLogInfoMessage("超时未反馈");
//}
taskHandle.WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
linerSemaphore.Wait(); //一直堵塞直到信号量释放
@ -340,6 +325,11 @@ namespace Aucma.Scada.Business
return taskInfo;
}
/// <summary>
/// 任务反馈(入库完成)
/// </summary>
/// <param name="storeCode"></param>
/// <param name="taskCode"></param>
private void TaskFeedback(string storeCode,string taskCode)
{
if(storeCode == appConfig.shellStoreCode)
@ -397,9 +387,8 @@ namespace Aucma.Scada.Business
if (spaceInfo != null)
{
spaceInfo.materialType = taskInfo.materialType;
taskHandle.WritePlc(spaceInfo.storeCode, spaceInfo.spaceCode, true);
//spaceInfo.materialType = taskInfo.materialType;
spaceInfo.spaceStock = spaceInfo.spaceStock + 1;
spaceInfo.onRouteAmount -= 1;
@ -425,7 +414,7 @@ namespace Aucma.Scada.Business
_baseSpaceDetailService.InsertSpaceDetail(spaceDetail);
#endregion
#region 添加入库任务
#region 添加入库记录
RecordInstore recordInstore = new RecordInstore();
recordInstore.storeCode = taskInfo.storeCode;
recordInstore.spaceCode = taskInfo.spaceCode;
@ -536,15 +525,14 @@ namespace Aucma.Scada.Business
{
if (info.Count > 0)
{
foreach (BaseSpaceInfo item in info)
result = GetSpaceInfosByPlc(info);
if(result == null)
{
var spaceInfo = taskHandle.ReadSpaceInfoByPlc(item);
item.spaceStock = spaceInfo.spaceStock;
item.onRouteAmount = spaceInfo.onRouteAmount;
item.spaceStatus = spaceInfo.spaceStatus;
}
var list = _spaceInfoService.GetEmptySpaceInfo(storeCode);
result = info.Where(x=>x.spaceStatus == 1 && x.spaceStock > 0 ? x.spaceCapacity > (x.spaceStock + x.onRouteAmount) : 1 == 1).OrderByDescending(x => x.spaceStock).OrderBy(x=>x.spaceCode).First();
result = GetSpaceInfosByPlc(list);
}
}
}
@ -555,5 +543,40 @@ namespace Aucma.Scada.Business
return result;
}
/// <summary>
/// 读取PLC货道信息
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
private BaseSpaceInfo GetSpaceInfosByPlc(List<BaseSpaceInfo> info)
{
BaseSpaceInfo result = null;
if (info != null)
{
if (info.Count > 0)
{
foreach (BaseSpaceInfo item in info)
{
var spaceInfo = taskHandle.ReadSpaceInfoByPlc(item);
item.spaceStock = spaceInfo.spaceStock;
item.onRouteAmount = spaceInfo.onRouteAmount;
item.spaceStatus = spaceInfo.spaceStatus;
PrintLogInfoMessage($"通过PLC读取货道信息货道{spaceInfo.spaceName};在库数量:{item.spaceStock};在途数量:{item.onRouteAmount};货道状态:{item.spaceStatus}");
}
var list = info.Where(x => x.spaceStock > 0 ? x.spaceCapacity > (x.spaceStock + x.onRouteAmount) : 1 == 1 && x.spaceStatus == 1).ToList();
if(list.Count > 0)
{
result = list.OrderByDescending(x => x.spaceStock).OrderBy(x => x.spaceCode).First();
}
}
}
return result;
}
}
}

@ -226,7 +226,7 @@ namespace Aucma.Scada.Business
bool result = false;
try
{
IPlc _plc = _plcDictionary[taskInfo.storeCode];
IPlc _plc = _plcDictionary[appConfig.linerStoreCode];
if (_plc != null)
{
@ -269,7 +269,7 @@ namespace Aucma.Scada.Business
lock (string.Empty)
{
bool isFlag = true;
IPlc _plc = _plcDictionary[appConfig.shellStoreCode];
IPlc _plc = _plcDictionary[appConfig.linerStoreCode];
linerTaskCode = taskCode;
try
{
@ -393,5 +393,37 @@ namespace Aucma.Scada.Business
return spaceInfo;
}
/// <summary>
/// 测试方法,联调时不用
/// </summary>
/// <param name="storeCode"></param>
/// <param name="spaceCode"></param>
/// <param name="flag"></param>
public void WritePlc(string storeCode, string spaceCode, bool flag)
{
var spaceAddress = spaceConfig.GetSpaceAddress(storeCode, spaceCode);
IPlc _plc = _plcDictionary[storeCode];
if (_plc != null)
{
if (_plc.IsConnected)
{
var spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore);
var onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute);
if (flag)
{
_plc.writeInt32ByAddress(spaceAddress.onStore, spaceStock + 1);
_plc.writeInt32ByAddress(spaceAddress.onRoute, onRouteAmount - 1);
}
else
{
_plc.writeInt32ByAddress(spaceAddress.onRoute, onRouteAmount + 1);
}
}
}
}
}
}

@ -81,7 +81,7 @@ namespace Aucma.Scada.Business
bool result = false;
try
{
IPlc _plc = _plcDictionary[taskInfo.storeCode];
IPlc _plc = _plcDictionary[appConfig.shellStoreCode];
if (_plc != null)
{
@ -239,7 +239,7 @@ namespace Aucma.Scada.Business
bool result = false;
try
{
IPlc _plc = _plcDictionary[taskInfo.storeCode];
IPlc _plc = _plcDictionary[appConfig.linerStoreCode];
if (_plc != null)
{

@ -2,7 +2,7 @@
眊褲PLCIP=127.0.0.1
眊褲PLC傷諳=6000
囀筐PLCIP=127.0.0.1
トレオィPLCカヒソレ=6000
トレオィPLCカヒソレ=6001
#眊褲⻌踱華硊
[shell_inStore_address]

@ -300,19 +300,20 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo
MaterialNameList = new List<string>();
List<dynamic> info = inStoreBusiness.GetMaterialStock();
if (info != null)
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
Achievement.Clear();
foreach (var item in info)
if (info != null)
{
MaterialNameList.Add(item.parentMaterialName);
shellAchievement.Add(Convert.ToDouble(item.shellStock));
linerAchievement.Add(Convert.ToDouble(item.linerStock));
Achievement.Clear();
foreach (var item in info)
{
MaterialNameList.Add(item.parentMaterialName);
shellAchievement.Add(Convert.ToDouble(item.shellStock));
linerAchievement.Add(Convert.ToDouble(item.linerStock));
}
}
}
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
var shellColumn = new ColumnSeries();
shellColumn.DataLabels = true;
shellColumn.Title = "箱壳";

@ -62,5 +62,11 @@ namespace HighWayIot.Repository.service
/// <param name="linerStoreCode"></param>
/// <returns></returns>
List<dynamic> GetMaterialStock(string shellStoreCode,string linerStoreCode);
/// <summary>
/// 获取空货道:未分配物料型号的空白货道
/// </summary>
/// <returns></returns>
List<BaseSpaceInfo> GetEmptySpaceInfo(string store);
}
}

@ -84,7 +84,7 @@ namespace HighWayIot.Repository.service.Impl
/// 获取空货道:未分配物料型号的空白货道
/// </summary>
/// <returns></returns>
private List<BaseSpaceInfo> GetEmptySpaceInfo(string store)
public List<BaseSpaceInfo> GetEmptySpaceInfo(string store)
{
List<BaseSpaceInfo> spaceInfos = null;
try

Loading…
Cancel
Save