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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using ServiceCenter.Extensions;
  2. using ServiceCenter.SqlSugars;
  3. using System.ComponentModel;
  4. using WCS.Core;
  5. using WCS.Entity;
  6. using WCS.WorkEngineering.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)) return;
  26. var tunnel = obj.Entity.Sources.Where(x => x.HasFlag(DeviceFlags.输送机))
  27. .SelectMany(x => x.Sources) //堆垛机取货点设备
  28. .Where(x => x.HasFlag(DeviceFlags.巷道))
  29. .FirstOrDefault();
  30. SqlSugarHelper.Do(_db =>
  31. {
  32. var db = _db.Default;
  33. //验证是否有对应的任务
  34. if (!db.Queryable<WCS_TaskInfo>().Any(v => v.AddrTo == obj.Entity.Code))
  35. {
  36. var res = WmsApi.ApplyEmptyPalletGroupOutStorage(obj.Entity.Code, tunnel.Code.GetLastDigit(), obj.Entity.HasFlag(DeviceFlags.拆盘机09) ? PalletType.Pallet09 : PalletType.PalletNo09);
  37. if (res.ResCode == WebApi.Models.WMS.Response.ResponseStatusCodeEnum.Sucess) return;
  38. }
  39. else return;
  40. });
  41. }
  42. public override bool Select(Device dev)
  43. {
  44. //return dev.Code == "1602";
  45. return dev.HasFlag(DeviceFlags.拆盘机09) || dev.HasFlag(DeviceFlags.拆盘机非09);
  46. }
  47. }
  48. }