创建二次码垛出库任务.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using ServiceCenter.Extensions;
  2. using ServiceCenter.Logs;
  3. using ServiceCenter.SqlSugars;
  4. using System.ComponentModel;
  5. using WCS.Core;
  6. using WCS.Entity;
  7. using WCS.Entity.Protocol.Station;
  8. using WCS.WorkEngineering.Extensions;
  9. using WCS.WorkEngineering.WebApi.Controllers;
  10. using WCS.WorkEngineering.Worlds;
  11. namespace WCS.WorkEngineering.Systems.桁架码垛
  12. {
  13. [BelongTo(typeof(NoInteractionWorld))]
  14. [Description("创建二次码垛出库任务")]
  15. public class TrussCreateTwoOut : DeviceSystem<Device<IStation520>>
  16. {
  17. protected override bool ParallelDo => true;
  18. public override void Do(Device<IStation520> obj)
  19. {
  20. SqlSugarHelper.Do(db =>
  21. {
  22. var palls = db.Queryable<WCS_Palletizing>().ReadPastUpdLock().Where(x => !x.Finish && x.isItHalf).ToList();
  23. foreach (var pall in palls)
  24. {
  25. var task = db.Queryable<WCS_TaskInfo>().NoLock().First(x => x.ID == pall.TaskId);
  26. if (task != null) continue;
  27. try
  28. {
  29. //没有对应的出库任务
  30. var res = WmsApi.GetTwoPallet(pall.WarehouseCode, pall.TaskId);
  31. pall.TaskId = res.ResData;
  32. db.UpdateableRowLock(pall).UpdateColumns(x => new { x.TaskId }).ExecuteCommand();
  33. }
  34. catch (Exception e)
  35. {
  36. World.Log(e.Message, LogLevelEnum.Mid);
  37. continue;
  38. }
  39. }
  40. });
  41. }
  42. public override bool Select(Device dev)
  43. {
  44. return dev.Code == nameof(TrussCreateTwoOut);
  45. }
  46. }
  47. }