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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.Extensions;
  8. using WCS.WorkEngineering.WebApi.Controllers;
  9. using WCS.WorkEngineering.WebApi.Models.WMS.Request;
  10. using WCS.WorkEngineering.WebApi.Models.WMS.Response;
  11. using WCS.WorkEngineering.Worlds;
  12. using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
  13. namespace WCS.WorkEngineering.Systems
  14. {
  15. /// <summary>
  16. /// 二楼拆盘机自动补空托盘组
  17. /// </summary>
  18. [BelongTo(typeof(MainWorld))]
  19. [Description("二楼拆盘机自动补空托盘组")]
  20. public class 二楼拆盘机自动补空托盘组 : DeviceSystem<Device<IStation520, IStation521, IStation523>>
  21. {
  22. protected override bool ParallelDo => true;
  23. public override void Do(Device<IStation520, IStation521, IStation523> obj)
  24. {
  25. // 拆盘机没有光电
  26. if (obj.Data3.Status1.HasFlag(StationStatus1.RES14) || obj.Data3.Status.HasFlag(StationStatus.PH_Status)) return;
  27. var tunnel = obj.Entity.Sources.Where(x => x.HasFlag(DeviceFlags.输送机)) //堆垛机取货点设备
  28. .SelectMany(x => x.Sources)
  29. .FirstOrDefault(x => x.HasFlag(DeviceFlags.巷道));
  30. if (tunnel == null)
  31. {
  32. World.Log($"{obj.Entity.Code}找不到对应放货点");
  33. return;
  34. }
  35. SqlSugarHelper.Do(_db =>
  36. {
  37. var db = _db.Default;
  38. //验证是否有对应的任务
  39. if (db.Queryable<WCS_TaskInfo>().NoLock().Any(v => v.AddrTo == obj.Entity.Code && v.Status < Entity.TaskStatus.Finish)) return;
  40. var res = WmsApi.ApplyEmptyPalletGroupOutStorage(obj.Entity.Code, tunnel.Code.GetLastDigit(), obj.Entity.HasFlag(DeviceFlags.拆盘机) ? PalletType.Pallet09 : PalletType.PalletNo09);
  41. if (res.ResCode == ResponseStatusCodeEnum.Sucess) return;
  42. World.Log(res.ResMsg);
  43. });
  44. }
  45. public override bool Select(Device dev)
  46. {
  47. return dev.HasFlag(DeviceFlags.拆盘机);
  48. }
  49. }
  50. }