TaskBookBehavior_63008.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using DbCommon.BusinessCore.BaseCore;
  2. using DbCommon.Enties.DbModels;
  3. using ProjectManagementSystem.Common.Config;
  4. using ProjectManagementSystem.Common.Extenions;
  5. using ProjectManagementSystem.Common.Logger;
  6. using ProjectManagementSystem.Common.Models;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using ProjectManagementSystem.Common.Core;
  13. using ProjectManagementSystem.Common.Service;
  14. using ProjectManagementSystem.Common.Models.Crms;
  15. namespace ProjectManagementSystem.Common.TaskBookEvent
  16. {
  17. public class TaskBookBehavior_63008 : BaseTaskBookBehaviorV2
  18. {
  19. //LocationPropertyManager locationManager = new LocationPropertyManager();
  20. public TaskBookBehavior_63008() : base(63008, "续接任务")
  21. {
  22. }
  23. public override bool TaskBookOperator(TaskData taskDetailInfo, StepData stepInfo)
  24. {
  25. try
  26. {
  27. var nextLocation = stepInfo.WareHouseID.GetLocationMember("续接取货位置");
  28. if (string.IsNullOrEmpty(nextLocation))
  29. {
  30. Log(taskDetailInfo, stepInfo, $"未配置续接取货位置");
  31. return false;
  32. }
  33. if (stepInfo.WareHouseID == "上料人工")
  34. {
  35. if (PackControl.Instance.StationDictionary.TryGetValue(stepInfo.WareHouseID, out var packStation)
  36. && packStation != null
  37. && packStation.PackPlcToAgv != null)
  38. {
  39. var ret = packStation.PackPlcToAgv.ReleaseAgv(packStation.routeConfig, out string msg);
  40. if (ret != 20000)
  41. {
  42. Log(taskDetailInfo, stepInfo, $"等待放行 {msg}");
  43. return false;
  44. }
  45. }
  46. }
  47. PmsTaskInfoDto data = new PmsTaskInfoDto();
  48. data.LocationCode = nextLocation;
  49. data.TargetLocationCode = "模组A";
  50. data.ParentTaskId = taskDetailInfo.TaskID;
  51. data.Carrier = taskDetailInfo.Carrier;
  52. var result = Crms.PmsTaskService.TaskAddNoCheck(data, new string[] { });
  53. return result.code == 20000;
  54. }
  55. catch (Exception ex)
  56. {
  57. LogException(ex);
  58. }
  59. return false;
  60. }
  61. //public override bool TaskBookOperator(TaskData taskDetailInfo, StepData stepInfo)
  62. //{
  63. // try
  64. // {
  65. // var startWarehouse = stepInfo.WareHouseID.GetLocationMember("续接取货仓库");
  66. // var startLocation = stepInfo.WareHouseID.GetLocationMember("续接取货仓位");
  67. // var startMaterial = stepInfo.WareHouseID.GetLocationMember("续接取货物料");
  68. // var endWarehouse = stepInfo.WareHouseID.GetLocationMember("续接放货仓库");
  69. // var endLocation = stepInfo.WareHouseID.GetLocationMember("续接放货仓位");
  70. // if (string.IsNullOrWhiteSpace(startWarehouse) && string.IsNullOrWhiteSpace(startLocation))
  71. // {
  72. // Log(taskDetailInfo, stepInfo, $"续接取货仓库和续接取货仓位都为空,不需要续接");
  73. // return true;
  74. // }
  75. // if (string.IsNullOrWhiteSpace(endWarehouse) && string.IsNullOrWhiteSpace(endLocation))
  76. // {
  77. // Log(taskDetailInfo, stepInfo, $"续接放货仓库和续接放货仓位都为空,不需要续接");
  78. // return true;
  79. // }
  80. // if (!string.IsNullOrWhiteSpace(startLocation) && !string.IsNullOrWhiteSpace(startMaterial))
  81. // {
  82. // //起点物料修改
  83. // var locationStock = Crms.SWmsApi.GetLocationStockByLocationId(startLocation);
  84. // if (locationStock == null)
  85. // {
  86. // Log(taskDetailInfo, stepInfo, $"获取起点库位信息失败 {startLocation}");
  87. // return false;
  88. // }
  89. // if (locationStock.Stock?.goodsCode != startMaterial)
  90. // {
  91. // var res2 = Crms.PmsTaskService.UpdateLocationProperty(new LocationPropertyUpdateDto()
  92. // {
  93. // LocationCode = startLocation,
  94. // Status = LocationStatus.Filled,
  95. // MaterialId = startMaterial
  96. // });
  97. // if (res2.code != 20000)
  98. // {
  99. // Log(taskDetailInfo, stepInfo, $"设置起点库位物料失败 {startLocation} {startMaterial}");
  100. // return false;
  101. // }
  102. // }
  103. // }
  104. // PmsTaskInfoDto data = new PmsTaskInfoDto();
  105. // data.WareHouseCode = startWarehouse;
  106. // data.LocationCode = startLocation;
  107. // data.MaterialId = startMaterial;
  108. // data.TargetWareHouseCode = endWarehouse;
  109. // data.TargetLocationCode = endLocation;
  110. // data.ParentTaskId = taskDetailInfo.TaskID;
  111. // data.Carrier = taskDetailInfo.Carrier;
  112. // var res = Crms.PmsTaskService.TaskAdd(data);
  113. // var result = res.code == 20000;
  114. // Log(taskDetailInfo, stepInfo, $"续接任务{result.ToChineseString()} {res.message}");
  115. // return result;
  116. // }
  117. // catch (Exception ex)
  118. // {
  119. // LogException(ex);
  120. // }
  121. // return false;
  122. //}
  123. }
  124. }