一楼扫码入库.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using ServiceCenter.Logs;
  2. using ServiceCenter.SqlSugars;
  3. using System.ComponentModel;
  4. using WCS.Core;
  5. using WCS.Entity;
  6. using WCS.WorkEngineering.Extensions;
  7. using WCS.WorkEngineering.Protocol.BCR;
  8. using WCS.WorkEngineering.Protocol.Station;
  9. using WCS.WorkEngineering.WebApi.Controllers;
  10. using WCS.WorkEngineering.WebApi.Models.WMS.Request;
  11. using WCS.WorkEngineering.Worlds;
  12. namespace WCS.WorkEngineering.Systems
  13. {
  14. /// <summary>
  15. /// 一楼入库工位处理系统
  16. /// </summary>
  17. [BelongTo(typeof(MainWorld))]
  18. [Description("一楼扫码入库")]
  19. public class 一楼扫码入库 : DeviceSystem<Device<IStation520, IStation521, IStation523, IStation91, IBCR81>>
  20. {
  21. protected override bool ParallelDo => true;
  22. protected override bool SaveLogsToFile => true;
  23. public 一楼扫码入库()
  24. {
  25. }
  26. public override void Do(Device<IStation520, IStation521, IStation523, IStation91, IBCR81> obj)
  27. {
  28. obj.入库站点是否被禁止();
  29. obj.入库站点是否满足执行条件();
  30. WCS_TaskInfo task = null;//处理完成的任务
  31. try
  32. {
  33. SqlSugarHelper.Do(_db =>
  34. {
  35. var db = _db.Default;
  36. //获取托盘条码
  37. var barcode = obj.Data5.GetBCRCode();
  38. //验证是否有对应的任务
  39. if (!db.Queryable<WCS_TaskInfo>().Any(v => v.BarCode == barcode))
  40. {
  41. WmsApi.OneFloorWorkerBuildEmptyPalletsStock(new OneFloorWorkerBuildEmptyPalletsStockRequest()
  42. {
  43. PalletCode = barcode,
  44. StartLoc = obj.Entity.Code,
  45. });
  46. }
  47. //找到对应的任务
  48. task = db.Queryable<WCS_TaskInfo>().First(v => v.BarCode == barcode);
  49. if (task.Status == Entity.TaskStatus.NewBuild)
  50. {
  51. //开始对任务进行处理
  52. task.Status = Entity.TaskStatus.ConveyorExecution;
  53. task.StartTime = DateTime.Now;
  54. task.SrmStation = task.AddrFrom;
  55. task.AddWCS_TASK_DTL(_db, obj.Entity.Code, "开始执行入库任务");
  56. db.Updateable(task).ExecuteCommand();
  57. task.updateRedisHash();
  58. }
  59. else return;
  60. });
  61. }
  62. catch (Exception ex)
  63. {
  64. throw new KnownException(ex.Message, LogLevelEnum.High);
  65. }
  66. obj.Data.TaskNumber = task.ID;
  67. obj.Data.VoucherNo++;
  68. }
  69. public override bool Select(Device dev)
  70. {
  71. return dev.HasFlag(Extensions.DeviceFlags.一楼扫码);
  72. }
  73. }
  74. }