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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 db = _db.Default;
  23. var palls = db.Queryable<WCS_Palletizing>().ReadPastUpdLock().Where(x => !x.Finish && x.isItHalf).ToList();
  24. foreach (var pall in palls)
  25. {
  26. var task = db.Queryable<WCS_TaskInfo>().NoLock().First(x => x.ID == pall.TaskId);
  27. if (task != null) continue;
  28. try
  29. {
  30. //没有对应的出库任务
  31. var res = WmsApi.GetTwoPallet(pall.WarehouseCode, pall.TaskId);
  32. pall.TaskId = res.ResData;
  33. db.UpdateableRowLock(pall).UpdateColumns(x => new { x.TaskId }).ExecuteCommand();
  34. }
  35. catch (Exception e)
  36. {
  37. World.Log(e.Message, LogLevelEnum.Mid);
  38. continue;
  39. }
  40. }
  41. });
  42. }
  43. public override bool Select(Device dev)
  44. {
  45. return dev.Code == nameof(TrussCreateTwoOut);
  46. }
  47. }
  48. }