装箱区子母托盘输送.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using ServiceCenter.Extensions;
  2. using ServiceCenter.Logs;
  3. using ServiceCenter.SqlSugars;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using WCS.Core;
  12. using WCS.Entity;
  13. using WCS.WorkEngineering.Extensions;
  14. using WCS.WorkEngineering.Protocol.BCR;
  15. using WCS.WorkEngineering.Protocol.SRM;
  16. using WCS.WorkEngineering.Protocol.Station;
  17. using WCS.WorkEngineering.WebApi.Controllers;
  18. using WCS.WorkEngineering.Worlds;
  19. using static System.Runtime.InteropServices.JavaScript.JSType;
  20. using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
  21. namespace WCS.WorkEngineering.Systems
  22. {
  23. /// <summary>
  24. /// 装箱区子母托盘输送
  25. /// </summary>
  26. [BelongTo(typeof(MainWorld))]
  27. [Description("装箱区子母托盘输送")]
  28. public class 装箱区子母托盘输送 : DeviceSystem<Device<IStation520, IStation521, IStation523>>
  29. {
  30. protected override bool ParallelDo => true;
  31. protected override bool SaveLogsToFile => true;
  32. private List<Station> devs = new List<Station>();
  33. private List<SRM> srms = new List<SRM>();
  34. public override void Do(Device<IStation520, IStation521, IStation523> obj)
  35. {
  36. obj.入库站点是否被禁止();
  37. obj.入库站点是否满足执行条件();
  38. WCS_TaskInfo task = null;
  39. SqlSugarHelper.Do(_db =>
  40. {
  41. var db = _db.Default;
  42. //找到对应任务
  43. var taskInfo = db.Queryable<WCS_TaskInfo>().First(v=>v.AddrFrom== obj.Entity.Code && v.Status == Entity.TaskStatus.WaitingToExecute);
  44. //未找到对应任务
  45. if (taskInfo == null)
  46. {
  47. return;
  48. }
  49. taskInfo.Status = Entity.TaskStatus.ConveyorExecution;
  50. taskInfo.EditWho = "WCS";
  51. taskInfo.EditTime = DateTime.Now;
  52. taskInfo.AddrNext = "8058";
  53. db.Updateable(taskInfo).ExecuteCommand();
  54. taskInfo.AddWCS_TASK_DTL(_db, obj.Entity.Code, taskInfo.AddrNext, $"子托盘开始输送,目标地址:{taskInfo.AddrTo}");
  55. //taskInfo.updateRedisHash();
  56. task = taskInfo;
  57. });
  58. if (task == null) return;
  59. obj.Data.TaskNumber = task.ID;
  60. obj.Data.GoodsStart = obj.Entity.Code.ToShort();
  61. obj.Data.GoodsEnd = task.AddrNext.ToShort();
  62. obj.Data.VoucherNo++;
  63. }
  64. public override bool Select(Device dev)
  65. {
  66. return dev.Code == "8003" || dev.Code == "8011"|| dev.Code == "8019";
  67. }
  68. }
  69. }