二楼拆盘机自动补空托盘组.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using ServiceCenter.Extensions;
  2. using ServiceCenter.SqlSugars;
  3. using System.ComponentModel;
  4. using WCS.Core;
  5. using WCS.Entity;
  6. using WCS.Entity.Protocol.Station;
  7. using WCS.WorkEngineering.WebApi.Controllers;
  8. using WCS.WorkEngineering.WebApi.Models.WMS.Request;
  9. using WCS.WorkEngineering.Worlds;
  10. using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
  11. namespace WCS.WorkEngineering.Systems
  12. {
  13. /// <summary>
  14. /// 二楼拆盘机自动补空托盘组
  15. /// </summary>
  16. [BelongTo(typeof(MainWorld))]
  17. [Description("二楼拆盘机自动补空托盘组")]
  18. public class 二楼拆盘机自动补空托盘组 : DeviceSystem<Device<IStation520, IStation521, IStation523>>
  19. {
  20. protected override bool ParallelDo => true;
  21. protected override bool SaveLogsToFile => true;
  22. public override void Do(Device<IStation520, IStation521, IStation523> obj)
  23. {
  24. // 拆盘机没有光电
  25. if (obj.Data3.Status1.HasFlag(StationStatus1.RES14) || obj.Data3.Status.HasFlag(StationStatus.PH_Status)) return;
  26. var tunnel = obj.Entity.Sources.Where(x => x.HasFlag(DeviceFlags.输送机)) //堆垛机取货点设备
  27. .SelectMany(x => x.Sources)
  28. .FirstOrDefault(x => x.HasFlag(DeviceFlags.巷道));
  29. SqlSugarHelper.Do(_db =>
  30. {
  31. var db = _db.Default;
  32. //验证是否有对应的任务
  33. if (!db.Queryable<WCS_TaskInfo>().Any(v => v.AddrTo == obj.Entity.Code))
  34. {
  35. WmsApi.ApplyEmptyPalletGroupOutStorage(obj.Entity.Code, tunnel.Code.GetLastDigit(), obj.Entity.HasFlag(DeviceFlags.拆盘机09) ? PalletType.Pallet09 : PalletType.PalletNo09);
  36. }
  37. });
  38. }
  39. public override bool Select(Device dev)
  40. {
  41. return dev.HasFlag(DeviceFlags.拆盘机09) || dev.HasFlag(DeviceFlags.拆盘机非09);
  42. }
  43. }
  44. }