change - 出入库逻辑测试

collectionStore
wenjy 1 year ago
parent e0ae21631b
commit f083b5d314

Binary file not shown.

@ -49,6 +49,8 @@ namespace Aucma.Scada.Business
/// 实时任务 /// 实时任务
/// </summary> /// </summary>
private IRealTaskInfoService _taskInfoService; private IRealTaskInfoService _taskInfoService;
private IBaseSpaceDetailService _baseSpaceDetailService;
#endregion #endregion
#region 委托事件 #region 委托事件
@ -81,15 +83,14 @@ namespace Aucma.Scada.Business
{ {
_spaceInfoService = registerServices.GetService<IBaseSpaceInfoService>(); _spaceInfoService = registerServices.GetService<IBaseSpaceInfoService>();
_taskInfoService = registerServices.GetService<IRealTaskInfoService>(); _taskInfoService = registerServices.GetService<IRealTaskInfoService>();
_baseSpaceDetailService = registerServices.GetService<IBaseSpaceDetailService>();
taskHandle.InStoreFinsihEvent += TaskFeedback; taskHandle.InStoreFinsihEvent += TaskFeedback;
grabImage.RefreshMaterialCodeStrEvent += InStore; grabImage.RefreshMaterialCodeStrEvent += InStore;
grabImage.RefreshLogMessageEvent += PrintLogInfoMessage; grabImage.RefreshLogMessageEvent += PrintLogInfoMessage;
StartPassDown(); StartPassDown();
}
private void HandleTimer() InStore(appConfig.shellStoreCode, "B236000007811019001");
{ InStore(appConfig.linerStoreCode, "L236000007881019001");
InStore("X-001", "SC232");
} }
/// <summary> /// <summary>
@ -108,7 +109,11 @@ namespace Aucma.Scada.Business
{ {
PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}"); PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}");
RefreshScanMateriaCodeEvent?.Invoke(materialCode, materialType, spaceInfo.spaceName, storeCode); //刷新界面扫码信息 RefreshScanMateriaCodeEvent?.Invoke(materialCode, materialType, spaceInfo.spaceName, storeCode); //刷新界面扫码信息
CreateInStoreTask(spaceInfo, materialCode); //创建入库任务 var result = CreateInStoreTask(spaceInfo, materialCode); //创建入库任务
if (result)
{
_spaceInfoService.UpdateSpaceInfo(spaceInfo);
}
} }
else else
{ {
@ -126,30 +131,37 @@ namespace Aucma.Scada.Business
/// 创建入库任务 /// 创建入库任务
/// </summary> /// </summary>
/// <param name="spaceInfo"></param> /// <param name="spaceInfo"></param>
private void CreateInStoreTask(BaseSpaceInfo spaceInfo, string materialCode) private bool CreateInStoreTask(BaseSpaceInfo spaceInfo, string materialCode)
{ {
//生成入库任务依次下发至PLC bool result = false;
#region 任务赋值
RealTaskInfo realTaskInfo = new RealTaskInfo(); RealTaskInfo realTaskInfo = new RealTaskInfo();
realTaskInfo.taskType = 1; realTaskInfo.taskType = 1;
realTaskInfo.taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 6); realTaskInfo.taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 6);
realTaskInfo.storeCode = spaceInfo.storeCode; realTaskInfo.storeCode = spaceInfo.storeCode;
realTaskInfo.spaceCode = spaceInfo.spaceCode; realTaskInfo.spaceCode = spaceInfo.spaceCode;
realTaskInfo.materialType = spaceInfo.materialType; realTaskInfo.materialType = spaceInfo.materialType;
realTaskInfo.materialCode = System.Guid.NewGuid().ToString("N").Substring(0, 6); ; realTaskInfo.materialCode = materialCode;
realTaskInfo.planAmount = 1; realTaskInfo.planAmount = 1;
realTaskInfo.taskStatus = 1; realTaskInfo.taskStatus = 1;
realTaskInfo.createTime = DateTime.Now; realTaskInfo.createTime = DateTime.Now;
bool result = _taskInfoService.AddTaskInfo(realTaskInfo); #endregion
result = _taskInfoService.AddTaskInfo(realTaskInfo);
if (result) if (result)
{ {
PrintLogInfoMessage("入库任务创建成功"); PrintLogInfoMessage("入库任务创建成功");
RefreshInStoreTaskEvent?.Invoke(realTaskInfo); RefreshInStoreTaskEvent?.Invoke(realTaskInfo);
result = true;
} }
else else
{ {
PrintLogInfoMessage("入库任务创建失败"); PrintLogInfoMessage("入库任务创建失败");
} }
return result;
} }
#region 轮询获取入库任务下发至PLC等待PLC执行反馈完成后再次下发 #region 轮询获取入库任务下发至PLC等待PLC执行反馈完成后再次下发
@ -240,7 +252,7 @@ namespace Aucma.Scada.Business
{ {
PrintLogInfoMessage($"下发内胆入库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}"); PrintLogInfoMessage($"下发内胆入库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}");
if (taskHandle.SendShellTask_InStore(taskInfo)) if (taskHandle.SendLinerTask_InStore(taskInfo))
{ {
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode}下发成功等待PLC执行反馈"); PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode}下发成功等待PLC执行反馈");
taskInfo.taskStatus = 2; taskInfo.taskStatus = 2;
@ -322,7 +334,7 @@ namespace Aucma.Scada.Business
PrintLogInfoMessage("箱壳执行完成,自动释放信号量"); PrintLogInfoMessage("箱壳执行完成,自动释放信号量");
InStoreFinish(appConfig.shellStoreCode, taskCode); InStoreFinish(taskCode, appConfig.shellStoreCode);
shellSemaphore.Release(); shellSemaphore.Release();
} }
@ -330,10 +342,10 @@ namespace Aucma.Scada.Business
/// <summary> /// <summary>
/// 内胆执行反馈 /// 内胆执行反馈
/// </summary> /// </summary>
private void LinerTaskFeedback(string LinerTaskFeedback) private void LinerTaskFeedback(string taskCode)
{ {
PrintLogInfoMessage("内胆执行完成,自动释放信号量"); PrintLogInfoMessage("内胆执行完成,自动释放信号量");
InStoreFinish(appConfig.linerStoreCode, LinerTaskFeedback); InStoreFinish(taskCode, appConfig.linerStoreCode);
linerSemaphore.Release(); linerSemaphore.Release();
} }
#endregion #endregion
@ -357,8 +369,19 @@ namespace Aucma.Scada.Business
{ {
//读取PLC获取货道信息存放数量、在途数量 //读取PLC获取货道信息存放数量、在途数量
spaceInfo.materialType = taskInfo.materialType; spaceInfo.materialType = taskInfo.materialType;
spaceInfo.spaceStock = spaceInfo.spaceStock + 1;
_spaceInfoService.UpdateSpaceInfo(spaceInfo); _spaceInfoService.UpdateSpaceInfo(spaceInfo);
#region 添加货道明细
BaseSpaceDetail spaceDetail = new BaseSpaceDetail();
spaceDetail.materialType = taskInfo.materialType;
spaceDetail.materialCode = taskInfo.materialCode;
spaceDetail.storeCode = spaceInfo.storeCode;
spaceDetail.spaceCode = spaceInfo.spaceCode;
spaceDetail.materialAmount = 1;
_baseSpaceDetailService.InsertSpaceDetail(spaceDetail);
#endregion
} }
//清除任务信息 //清除任务信息
_taskInfoService.DeleteTaskInfo(taskCode, storeCode); _taskInfoService.DeleteTaskInfo(taskCode, storeCode);

@ -291,10 +291,10 @@ namespace Aucma.Scada.Business
_plc.writeStringByAddress(plcConfig.in_liner_task, string.Empty); _plc.writeStringByAddress(plcConfig.in_liner_task, string.Empty);
isFlag = false; isFlag = false;
Thread.Sleep(5000);
ReadLinerFinish_InStore(taskCode); ReadLinerFinish_InStore(taskCode);
} }
Thread.Sleep(5000);
} while (isFlag); } while (isFlag);
} }
else else
@ -345,8 +345,9 @@ namespace Aucma.Scada.Business
isFlag = false; isFlag = false;
Thread.Sleep(5000);
} }
Thread.Sleep(5000);
} while (isFlag); } while (isFlag);
} }
else else

@ -113,14 +113,24 @@ namespace Aucma.Scada.Business
string taskCode = DateTime.Now.ToString("HH:mm:ss"); string taskCode = DateTime.Now.ToString("HH:mm:ss");
var shellBomInfo = _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.materialCode, appConfig.shellMaterialType); var shellBomInfo = _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.materialCode, appConfig.shellMaterialType);
var linerBomInfo = _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.materialCode, appConfig.linerMaterialType); var linerBomInfo = _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.materialCode, appConfig.linerMaterialType);
for (int i = 0; i < planInfo.planAmount - planInfo.completeAmount; i++)
{
OutStore(appConfig.shellStoreCode, shellBomInfo, planInfo.executePlanCode, taskCode);
Thread.Sleep(500);
OutStore(appConfig.linerStoreCode, linerBomInfo, planInfo.executePlanCode, taskCode);
Thread.Sleep(500);
if(shellBomInfo != null && linerBomInfo != null)
{
for (int i = 0; i < planInfo.planAmount - planInfo.completeAmount; i++)
{
OutStore(appConfig.shellStoreCode, shellBomInfo, planInfo.executePlanCode, taskCode);
Thread.Sleep(500);
OutStore(appConfig.linerStoreCode, linerBomInfo, planInfo.executePlanCode, taskCode);
Thread.Sleep(500);
}
}
else
{
PrintLogInfoMessage($"物料:{planInfo.materialCode}获取Bom信息为空");
} }
} }
}); });
} }
@ -484,6 +494,10 @@ namespace Aucma.Scada.Business
{ {
//读取PLC获取货道信息存放数量、在途数量 //读取PLC获取货道信息存放数量、在途数量
//spaceInfo.materialType = taskInfo.materialType; //spaceInfo.materialType = taskInfo.materialType;
if(spaceInfo.spaceStock == 0)
{
spaceInfo.materialType = string.Empty;
}
_spaceInfoService.UpdateSpaceInfo(spaceInfo); _spaceInfoService.UpdateSpaceInfo(spaceInfo);
//读取PLC获取物料类型进行绑定 //读取PLC获取物料类型进行绑定

@ -308,10 +308,10 @@ namespace Aucma.Scada.Business
_plc.writeStringByAddress(plcConfig.out_liner_task, string.Empty); _plc.writeStringByAddress(plcConfig.out_liner_task, string.Empty);
isFlag = false; isFlag = false;
Thread.Sleep(5000);
ReadLinerFinish_OutStore(taskCode); ReadLinerFinish_OutStore(taskCode);
} }
Thread.Sleep(5000);
} while (isFlag); } while (isFlag);
} }
else else
@ -362,8 +362,9 @@ namespace Aucma.Scada.Business
isFlag = false; isFlag = false;
Thread.Sleep(5000);
} }
Thread.Sleep(5000);
} while (isFlag); } while (isFlag);
} }
else else

@ -35,7 +35,7 @@ namespace HighWayIot.Repository.service.Impl
if (spaceInfos.Count == 0) //没有指定该类型物料的货道信息,需获取空白货道信息进行分配 if (spaceInfos.Count == 0) //没有指定该类型物料的货道信息,需获取空白货道信息进行分配
{ {
spaceInfos = GetEmptySpaceInfo(); spaceInfos = GetEmptySpaceInfo(store);
} }
logHelper.Info($"根据仓库{store};物料:{materialType};获取到的货道信息:{jsonChange.ModeToJson(spaceInfos)}"); logHelper.Info($"根据仓库{store};物料:{materialType};获取到的货道信息:{jsonChange.ModeToJson(spaceInfos)}");
spaceInfo = inStoreFilter(spaceInfos); spaceInfo = inStoreFilter(spaceInfos);
@ -81,13 +81,13 @@ namespace HighWayIot.Repository.service.Impl
/// 获取空货道:未分配物料型号的空白货道 /// 获取空货道:未分配物料型号的空白货道
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private List<BaseSpaceInfo> GetEmptySpaceInfo() private List<BaseSpaceInfo> GetEmptySpaceInfo(string store)
{ {
List<BaseSpaceInfo> spaceInfos = null; List<BaseSpaceInfo> spaceInfos = null;
try try
{ {
Expression<Func<BaseSpaceInfo, bool>> exp = s1 => true; Expression<Func<BaseSpaceInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.materialType == null && x.spaceCapacity != x.spaceStock); exp = exp.And(x => x.materialType == null && x.storeCode == store && x.spaceCapacity != x.spaceStock);
spaceInfos = _mesRepository.GetList(exp); spaceInfos = _mesRepository.GetList(exp);
} }
catch (Exception ex) catch (Exception ex)

Loading…
Cancel
Save