TaskBookBehavior_63030.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using DbCommon.BusinessCore.BaseCore;
  2. using DbCommon.Enties.DbModels;
  3. using Pms.DataLibrary.Order;
  4. using ProjectManagementSystem.Common.Core;
  5. using ProjectManagementSystem.Common.Extenions;
  6. using ProjectManagementSystem.Common.Logger;
  7. using ProjectManagementSystem.Common.Models;
  8. using ProjectManagementSystem.Common.Service;
  9. using ProjectManagementSystem.Common.WebApi;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. namespace ProjectManagementSystem.TaskBookEvent
  16. {
  17. public class TaskBookBehavior_63030 : BaseTaskBookBehaviorV2
  18. {
  19. LocationPropertyManager locationManager = new LocationPropertyManager();
  20. public TaskBookBehavior_63030() : base(63030, "等待按钮放行(成品发动机)")
  21. {
  22. }
  23. public override bool TaskBookOperator(TaskData taskDetailInfo, StepData stepInfo)
  24. {
  25. try
  26. {
  27. int[] marks = stepInfo.WareHouseID.GetLocationMember("放行叫料路线").ToValueArray<int>();
  28. if(marks == null || marks.Length == 0)
  29. {
  30. Log(taskDetailInfo, stepInfo, "未配置放行叫料路线");
  31. return false;
  32. }
  33. string nextWareHouse = null;
  34. var infoBoxDictionary = DeviceControl.Instance.Communication.InfoBoxDictionary;
  35. for (int i = 0; i < marks.Length; i++)
  36. {
  37. int mark = marks[i];
  38. var first = infoBoxDictionary.Values.FirstOrDefault(d => d.DataValid && d.Route == mark && d.BoxCalled);
  39. if(first != null)
  40. {
  41. nextWareHouse = stepInfo.WareHouseID.GetLocationMember("续接任务放货点").GetArrayValue<string>(i);
  42. if(!string.IsNullOrEmpty(nextWareHouse))
  43. {
  44. break;
  45. }
  46. }
  47. }
  48. if(string.IsNullOrEmpty(nextWareHouse))
  49. {
  50. Log(taskDetailInfo, stepInfo, "等待按钮放行(成品)");
  51. return false;
  52. }
  53. PmsTaskInfoDto data = new PmsTaskInfoDto();
  54. data.LocationCode = stepInfo.WareHouseID;
  55. data.TargetLocationCode = nextWareHouse;
  56. data.ParentTaskId = taskDetailInfo.TaskID;
  57. data.Carrier = taskDetailInfo.Carrier;
  58. var result = PmsTaskService.Instance.TaskAddNoCheck(data, new string[] { });
  59. if (result.code != 20000)
  60. {
  61. Log(taskDetailInfo, stepInfo, $"续接任务失败 {result.message}");
  62. return false;
  63. }
  64. //Log(taskDetailInfo, stepInfo, $"续接任务成功 {result.message}");
  65. //System.Threading.Thread.Sleep(500);
  66. for (int j = 0; j < 3; j++)
  67. {
  68. for (int i = 0; i < marks.Length; i++)
  69. {
  70. DeviceControl.Instance.CallBoxLightOff(marks[i]);
  71. System.Threading.Thread.Sleep(100);
  72. }
  73. }
  74. Log(taskDetailInfo, stepInfo, $"已放行,灭灯");
  75. return true;
  76. }
  77. catch (Exception ex)
  78. {
  79. LogException(ex);
  80. }
  81. return false;
  82. }
  83. }
  84. }