|
@@ -1,6 +1,8 @@
|
|
|
-using PlcSiemens.Core.Extension;
|
|
|
+using Newtonsoft.Json;
|
|
|
+using PlcSiemens.Core.Extension;
|
|
|
using ServiceCenter.Extensions;
|
|
|
using ServiceCenter.Logs;
|
|
|
+using ServiceCenter.Redis;
|
|
|
using ServiceCenter.SqlSugars;
|
|
|
using SqlSugar;
|
|
|
using System.ComponentModel;
|
|
@@ -8,6 +10,7 @@ using WCS.Core;
|
|
|
using WCS.Entity;
|
|
|
using WCS.Entity.Protocol.Station;
|
|
|
using WCS.WorkEngineering.Extensions;
|
|
|
+using WCS.WorkEngineering.WebApi.Controllers;
|
|
|
using WCS.WorkEngineering.Worlds;
|
|
|
using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
|
|
|
using TaskStatus = WCS.Entity.TaskStatus;
|
|
@@ -33,25 +36,46 @@ namespace WCS.WorkEngineering.Systems
|
|
|
if (obj.Data2.Request != 1) throw new KnownException("无请求", LogLevelEnum.Mid);
|
|
|
|
|
|
//处理异常任务
|
|
|
- if (obj.Data2.TaskNumber == 1)
|
|
|
+ if (obj.Data2.TaskNumber == 1 && obj.Data4.Length.ToInt() == 9)
|
|
|
{
|
|
|
obj.Data.TaskNumber = 591;
|
|
|
obj.Data.GoodsStart = obj.Entity.Code.ToShort();
|
|
|
obj.Data.GoodsEnd = 591;
|
|
|
obj.Data.VoucherNo++;
|
|
|
- World.Log($"执行记录:任务号[{591}]-[{obj.Data.VoucherNo}]");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
var isPut = false;
|
|
|
short nextAdd = 0;
|
|
|
+ int taskId = 0;
|
|
|
SqlSugarHelper.Do(_db =>
|
|
|
{
|
|
|
var db = _db.Default;
|
|
|
- var taskInfo = db.Queryable<WCS_TaskInfo>().First(v => v.ID == obj.Data2.TaskNumber && v.Status == TaskStatus.WaitingToExecute) ?? throw new KnownException($"未找到对应的WCS任务{obj.Data2.TaskNumber}", LogLevelEnum.Mid);
|
|
|
+ var taskInfo = db.Queryable<WCS_TaskInfo>().First(v => v.ID == obj.Data2.TaskNumber && v.Status == TaskStatus.WaitingToExecute);
|
|
|
+ if (obj.Data2.TaskNumber == 1)
|
|
|
+ {
|
|
|
+ var type = obj.Data4.Length.ToInt().ToString();
|
|
|
+ var key = $"ErrorTasks:{obj.Entity.Code}:{type}";
|
|
|
+ //从redis获取最近的一条任务号
|
|
|
+ if (!RedisHub.WMS.Exists(key)) WmsApi.PalletizingCreateseErrorTasks(obj.Entity.Code, type);
|
|
|
+ var value = RedisHub.WMS.Get(key);
|
|
|
+ var task = JsonConvert.DeserializeObject<MainlineDiversion>(value);
|
|
|
+
|
|
|
+ //是异常任务,查询最近的一条异常任务
|
|
|
+ taskInfo = db.Queryable<WCS_TaskInfo>().First(x => x.ID == task.TaskId);
|
|
|
+ if (taskInfo.Status >= TaskStatus.FinishOfShunt && obj.Data2.TaskNumber != task.TaskId)
|
|
|
+ {
|
|
|
+ WmsApi.PalletizingCreateseErrorTasks(obj.Entity.Code, type);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (taskInfo == null) throw new KnownException($"未找到对应的WCS任务{obj.Data2.TaskNumber}", LogLevelEnum.Mid);
|
|
|
+
|
|
|
+ taskId = taskInfo.ID;
|
|
|
switch (obj.Data4.Length)
|
|
|
{
|
|
|
case 9:
|
|
|
- isPut = Allot09Or18(db, taskInfo, obj);
|
|
|
+ isPut = Allot09(db, taskInfo, obj);
|
|
|
nextAdd = 455;
|
|
|
break;
|
|
|
|
|
@@ -97,11 +121,11 @@ namespace WCS.WorkEngineering.Systems
|
|
|
}
|
|
|
});
|
|
|
if (!isPut) return;
|
|
|
- obj.Data.TaskNumber = obj.Data2.TaskNumber;
|
|
|
+ obj.Data.TaskNumber = taskId;
|
|
|
obj.Data.GoodsStart = obj.Entity.Code.ToShort();
|
|
|
obj.Data.GoodsEnd = nextAdd;
|
|
|
obj.Data.VoucherNo++;
|
|
|
- World.Log($"执行记录:任务号[{obj.Data2.TaskNumber}]-[{obj.Data.VoucherNo}]");
|
|
|
+ World.Log($"执行记录:任务号[{taskId}]-[{obj.Data.VoucherNo}]");
|
|
|
}
|
|
|
|
|
|
public override bool Select(Device dev)
|
|
@@ -110,25 +134,25 @@ namespace WCS.WorkEngineering.Systems
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 计算非零九或18的去向
|
|
|
+ /// 计算非零九的去向
|
|
|
/// </summary>
|
|
|
/// <param name="db"></param>
|
|
|
/// <param name="taskInfo"></param>
|
|
|
/// <param name="obj"></param>
|
|
|
/// <returns></returns>
|
|
|
- public bool AllotNot09Or18(SqlSugarScopeProvider db, WCS_TaskInfo taskInfo, Device<IStation520, IStation521, IStation523, IStation91> obj)
|
|
|
+ public bool AllotNot09(SqlSugarScopeProvider db, WCS_TaskInfo taskInfo, Device<IStation520, IStation521, IStation523, IStation91> obj)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 计算09/18去向
|
|
|
+ /// 计算09去向
|
|
|
/// </summary>
|
|
|
/// <param name="db"></param>
|
|
|
/// <param name="taskInfo"></param>
|
|
|
/// <param name="obj"></param>
|
|
|
/// <returns></returns>
|
|
|
- public bool Allot09Or18(SqlSugarScopeProvider db, WCS_TaskInfo taskInfo, Device<IStation520, IStation521, IStation523, IStation91> obj)
|
|
|
+ public bool Allot09(SqlSugarScopeProvider db, WCS_TaskInfo taskInfo, Device<IStation520, IStation521, IStation523, IStation91> obj)
|
|
|
{
|
|
|
//TODO:暂时不来考虑动态计算可前往的目标
|
|
|
var nextAdd = taskInfo.WarehouseCode switch
|