change - 入库逻辑处理

collectionStore
wenjy 1 year ago
parent 783b04fe9f
commit e7d2c05665

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

@ -226,7 +226,7 @@ namespace Aucma.Scada.Business
bool result = false; bool result = false;
try try
{ {
IPlc _plc = _plcDictionary[taskInfo.storeCode]; IPlc _plc = _plcDictionary[appConfig.linerStoreCode];
if (_plc != null) if (_plc != null)
{ {
@ -269,7 +269,7 @@ namespace Aucma.Scada.Business
lock (string.Empty) lock (string.Empty)
{ {
bool isFlag = true; bool isFlag = true;
IPlc _plc = _plcDictionary[appConfig.shellStoreCode]; IPlc _plc = _plcDictionary[appConfig.linerStoreCode];
linerTaskCode = taskCode; linerTaskCode = taskCode;
try try
{ {
@ -393,5 +393,37 @@ namespace Aucma.Scada.Business
return spaceInfo; 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; bool result = false;
try try
{ {
IPlc _plc = _plcDictionary[taskInfo.storeCode]; IPlc _plc = _plcDictionary[appConfig.shellStoreCode];
if (_plc != null) if (_plc != null)
{ {
@ -239,7 +239,7 @@ namespace Aucma.Scada.Business
bool result = false; bool result = false;
try try
{ {
IPlc _plc = _plcDictionary[taskInfo.storeCode]; IPlc _plc = _plcDictionary[appConfig.linerStoreCode];
if (_plc != null) if (_plc != null)
{ {

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

@ -300,6 +300,9 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo
MaterialNameList = new List<string>(); MaterialNameList = new List<string>();
List<dynamic> info = inStoreBusiness.GetMaterialStock(); List<dynamic> info = inStoreBusiness.GetMaterialStock();
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
if (info != null) if (info != null)
{ {
Achievement.Clear(); Achievement.Clear();
@ -311,8 +314,6 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo
} }
} }
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
var shellColumn = new ColumnSeries(); var shellColumn = new ColumnSeries();
shellColumn.DataLabels = true; shellColumn.DataLabels = true;
shellColumn.Title = "箱壳"; shellColumn.Title = "箱壳";

@ -62,5 +62,11 @@ namespace HighWayIot.Repository.service
/// <param name="linerStoreCode"></param> /// <param name="linerStoreCode"></param>
/// <returns></returns> /// <returns></returns>
List<dynamic> GetMaterialStock(string shellStoreCode,string linerStoreCode); 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> /// </summary>
/// <returns></returns> /// <returns></returns>
private List<BaseSpaceInfo> GetEmptySpaceInfo(string store) public List<BaseSpaceInfo> GetEmptySpaceInfo(string store)
{ {
List<BaseSpaceInfo> spaceInfos = null; List<BaseSpaceInfo> spaceInfos = null;
try try

Loading…
Cancel
Save