|
@@ -27,86 +27,92 @@ namespace WCS.WorkEngineering.Systems
|
|
|
|
|
|
public override void Do(Device<IStation523, IBCR83, IStation525> obj)
|
|
|
{
|
|
|
- var devCode = obj.Entity.Code switch
|
|
|
+ try
|
|
|
{
|
|
|
- "18" => "22",
|
|
|
- "38" => "41",
|
|
|
- "58" => "61",
|
|
|
- "118" => "122",
|
|
|
- "138" => "141",
|
|
|
- "158" => "161",
|
|
|
- _ => throw new ArgumentOutOfRangeException()
|
|
|
- };
|
|
|
- var dev = new Device<IStation520>(Device.All.First(x => x.Code == devCode), World);
|
|
|
- dev.Data.Mode = StationMode.Automatic;
|
|
|
- //从DB83中获取待处理条码组
|
|
|
- var pendingBcrList = obj.Data2.GetBcrCodeList().Where(x => !x.IsNullOrEmpty());
|
|
|
- //从DB525获取已处理条码组
|
|
|
- var cacheBcrList = obj.Data3.GetBcrCodeList();
|
|
|
- //筛选出未处理条码组
|
|
|
- var codes = pendingBcrList.Where(x => !cacheBcrList.Contains(x));
|
|
|
- World.Log($"扫码器:{JsonConvert.SerializeObject(pendingBcrList)}");
|
|
|
- World.Log($"缓存信息:{JsonConvert.SerializeObject(cacheBcrList)}");
|
|
|
- //循环处理所有缓存条码组中没有的条码
|
|
|
- foreach (var bcrCode in codes)
|
|
|
- {
|
|
|
- ////取出预分配地址,并计算相关信息
|
|
|
- //var key = $"AllocationWarehouseSort:{bcrCode}";
|
|
|
- //var value = RedisHub.WMS.Get(key);
|
|
|
- //if (value == null)
|
|
|
- //{
|
|
|
- // World.Log($"{bcrCode}:找不到分库记录", LogLevelEnum.High);
|
|
|
- // continue;
|
|
|
- //}
|
|
|
- //var mainlineDiversion = JsonConvert.DeserializeObject<MainlineDiversion>(value);
|
|
|
-
|
|
|
- WCS_TaskInfo taskInfo = null;
|
|
|
-
|
|
|
- try
|
|
|
+ var devCode = obj.Entity.Code switch
|
|
|
{
|
|
|
- SqlSugarHelper.Do(_db =>
|
|
|
+ "18" => "22",
|
|
|
+ "38" => "41",
|
|
|
+ "58" => "61",
|
|
|
+ "118" => "122",
|
|
|
+ "138" => "141",
|
|
|
+ "158" => "161",
|
|
|
+ _ => throw new ArgumentOutOfRangeException()
|
|
|
+ };
|
|
|
+ var dev = new Device<IStation520>(Device.All.First(x => x.Code == devCode), World);
|
|
|
+ dev.Data.Mode = StationMode.Automatic;
|
|
|
+ //从DB83中获取待处理条码组
|
|
|
+ var pendingBcrList = obj.Data2.GetBcrCodeList().Where(x => !x.IsNullOrEmpty());
|
|
|
+ //从DB525获取已处理条码组
|
|
|
+ var cacheBcrList = obj.Data3.GetBcrCodeList();
|
|
|
+ //筛选出未处理条码组
|
|
|
+ var codes = pendingBcrList.Where(x => !cacheBcrList.Contains(x));
|
|
|
+ World.Log($"扫码器:{JsonConvert.SerializeObject(pendingBcrList)}");
|
|
|
+ World.Log($"缓存信息:{JsonConvert.SerializeObject(cacheBcrList)}");
|
|
|
+ //循环处理所有缓存条码组中没有的条码
|
|
|
+ foreach (var bcrCode in codes)
|
|
|
+ {
|
|
|
+ WCS_TaskInfo taskInfo = null;
|
|
|
+
|
|
|
+ try
|
|
|
{
|
|
|
- var db = _db.Default;
|
|
|
- var task = db.Queryable<WCS_TaskInfo>().NoLock().Single(x => x.BarCode == bcrCode && x.Status == TaskStatus.NewBuild);
|
|
|
- if (task == null)
|
|
|
+ SqlSugarHelper.Do(_db =>
|
|
|
{
|
|
|
- World.Log($"{bcrCode}:找不到匹配的新建任务", LogLevelEnum.High);
|
|
|
- return;
|
|
|
- }
|
|
|
- taskInfo = task;
|
|
|
- });
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- World.Log($"{bcrCode}:----{e.Message}", LogLevelEnum.High);
|
|
|
- continue;
|
|
|
- }
|
|
|
- var srmCode = taskInfo.WarehouseCode.WarehouseToSrm();
|
|
|
- var path = DevicePath.GetPath(obj.Entity.Code, srmCode);
|
|
|
- if (path == null || path is { Points.Count: < 2 })
|
|
|
- {
|
|
|
- World.Log($"{bcrCode}:路径错误,当前位置{obj.Entity.Code},目标位置:{srmCode}", LogLevelEnum.High);
|
|
|
- continue;
|
|
|
- }
|
|
|
- var next = path.Points[1].Code;
|
|
|
- if (taskInfo == null) continue;
|
|
|
- //开始赋值
|
|
|
- obj.Data3.GetType().GetProperty($"BcrCode{obj.Data3.NextIndex}").SetValue(obj.Data3, bcrCode);
|
|
|
- obj.Data3.GetType().GetProperty($"BcrCode{obj.Data3.NextIndex}").SetValue(obj.Data3, bcrCode);
|
|
|
- obj.Data3.GetType().GetProperty($"TaskNumber{obj.Data3.NextIndex}").SetValue(obj.Data3, taskInfo.ID);
|
|
|
- obj.Data3.GetType().GetProperty($"TaskNumber{obj.Data3.NextIndex}").SetValue(obj.Data3, taskInfo.ID);
|
|
|
- obj.Data3.GetType().GetProperty($"GoodsEnd{obj.Data3.NextIndex}").SetValue(obj.Data3, next.ToShort());
|
|
|
- obj.Data3.GetType().GetProperty($"GoodsEnd{obj.Data3.NextIndex}").SetValue(obj.Data3, next.ToShort());
|
|
|
- if (obj.Data3.NextIndex >= 49)
|
|
|
- {
|
|
|
- obj.Data3.NextIndex = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- obj.Data3.NextIndex++;
|
|
|
+ var db = _db.Default;
|
|
|
+ var task = db.Queryable<WCS_TaskInfo>().NoLock().First(x => x.BarCode == bcrCode && x.Status == TaskStatus.NewBuild);
|
|
|
+ if (task == null)
|
|
|
+ {
|
|
|
+ World.Log($"{bcrCode}:找不到匹配的任务", LogLevelEnum.High);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ taskInfo = task;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ World.Log($"{bcrCode}:----{e.Message}", LogLevelEnum.High);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ var srmCode = taskInfo.WarehouseCode.WarehouseToSrm();
|
|
|
+ var path = DevicePath.GetPath(obj.Entity.Code, srmCode);
|
|
|
+ if (path == null || path is { Points.Count: < 2 })
|
|
|
+ {
|
|
|
+ World.Log($"{bcrCode}:路径错误,当前位置{obj.Entity.Code},目标位置:{srmCode}", LogLevelEnum.High);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ var next = path.Points[1].Code;
|
|
|
+ if (taskInfo == null) continue;
|
|
|
+ //开始赋值
|
|
|
+ obj.Data3.GetType().GetProperty($"BcrCode{obj.Data3.NextIndex}").SetValue(obj.Data3, bcrCode);
|
|
|
+ obj.Data3.GetType().GetProperty($"BcrCode{obj.Data3.NextIndex}").SetValue(obj.Data3, bcrCode);
|
|
|
+ obj.Data3.GetType().GetProperty($"TaskNumber{obj.Data3.NextIndex}")
|
|
|
+ .SetValue(obj.Data3, taskInfo.ID);
|
|
|
+ obj.Data3.GetType().GetProperty($"TaskNumber{obj.Data3.NextIndex}")
|
|
|
+ .SetValue(obj.Data3, taskInfo.ID);
|
|
|
+ obj.Data3.GetType().GetProperty($"GoodsEnd{obj.Data3.NextIndex}")
|
|
|
+ .SetValue(obj.Data3, next.ToShort());
|
|
|
+ obj.Data3.GetType().GetProperty($"GoodsEnd{obj.Data3.NextIndex}")
|
|
|
+ .SetValue(obj.Data3, next.ToShort());
|
|
|
+ if (obj.Data3.NextIndex >= 49)
|
|
|
+ {
|
|
|
+ obj.Data3.NextIndex = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ obj.Data3.NextIndex++;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ dev.Data.Mode = StationMode.Automatic;
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ World.Log($"{e.Message}:---{e.StackTrace}", LogLevelEnum.High);
|
|
|
+ throw;
|
|
|
}
|
|
|
- dev.Data.Mode = StationMode.Automatic;
|
|
|
}
|
|
|
|
|
|
public override bool Select(Device dev)
|