一楼出库工位处理系统.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using ServiceCenter.Logs;
  2. using ServiceCenter.Redis;
  3. using ServiceCenter.SqlSugars;
  4. using System.ComponentModel;
  5. using WCS.Core;
  6. using WCS.Entity;
  7. using WCS.Service;
  8. using WCS.WorkEngineering.Extensions;
  9. using WCS.WorkEngineering.WebApi.Controllers;
  10. using WCS.WorkEngineering.Worlds;
  11. using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
  12. namespace WCS.WorkEngineering.Systems
  13. {
  14. /// <summary>
  15. /// 出库站台交互
  16. /// </summary>
  17. [BelongTo(typeof(MainWorld))]
  18. [Description("一楼出库工位处理系统")]
  19. public class 一楼出库工位处理系统 : DeviceSystem<Station>
  20. {
  21. protected override bool ParallelDo => true;
  22. protected override bool SaveLogsToFile => true;
  23. public override void Do(Station obj)
  24. {
  25. var key = $"WCS:Lock:{obj.Entity.Code}";
  26. try
  27. {
  28. if (RedisHub.Default.Get(key) != null)
  29. {
  30. throw new KnownException($"[{obj.Entity.Code}]--触发并发管控", LogLevelEnum.High);
  31. }
  32. RedisHub.Default.Set(key, obj.Entity.Code);
  33. if (!obj.Data3.Status.HasFlag(Entity.Protocol.Station.StatusEunm.PH_Status) && !obj.Data3.Status.HasFlag(Entity.Protocol.Station.StatusEunm.OT_Status))
  34. {
  35. var any = false;
  36. SqlSugarHelper.Do(db =>
  37. {
  38. any = db.Default.Queryable<WCS_TaskInfo>().Any(v => v.AddrTo == obj.Entity.Code && v.Status < Entity.TaskStatus.AGVExecution);
  39. });
  40. if (!any) WmsApi.ApplyStockOutTask(obj.Entity.Code);
  41. }
  42. }
  43. finally
  44. {
  45. RedisHub.Default.Del(key);
  46. }
  47. }
  48. public override bool Select(Device dev)
  49. {
  50. return dev.HasFlag(DeviceFlags.一楼出库口);
  51. }
  52. }
  53. }