ProcessCallboxTask.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using DbCommon.BusinessCore.BaseCore;
  2. using DbCommon.Enties.DbModels;
  3. using Pms.DataLibrary.Order;
  4. using ProjectManagementSystem.Common.Config;
  5. using ProjectManagementSystem.Common.Core;
  6. using ProjectManagementSystem.Common.Extenions;
  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.TaskEvent
  16. {
  17. public class ProcessCallboxTask : ICustomProcess
  18. {
  19. private string location1;
  20. private string location2;
  21. private List<RouteConfig> routeConfigs = ExcelConfig.Instance.RouteConfigList
  22. .Where(d =>
  23. {
  24. var location1 = d.LocationCode.GetLocationMember("续接任务取货点");
  25. if (string.IsNullOrWhiteSpace(location1)) return false;
  26. var location2 = d.LocationCode.GetLocationMember("续接任务放货点");
  27. if (string.IsNullOrWhiteSpace(location2)) return false;
  28. var routes = d.LocationCode.GetLocationMember("放行叫料路线").ToValueArray<int>();
  29. if (routes.Length != 1) return false;
  30. return routes[0] > 0;
  31. })
  32. .ToList();
  33. private LocationPropertyManager locationManager = new LocationPropertyManager();
  34. public void CustomProcess(List<TaskData> taskDataList)
  35. {
  36. location1 = null;
  37. location2 = null;
  38. var infoBoxDict = DeviceControl.Instance.Communication.InfoBoxDictionary;
  39. for (int i = 0; i < routeConfigs.Count; i++)
  40. {
  41. var config = routeConfigs[i];
  42. int route = config.LocationCode.GetLocationMember("放行叫料路线").ToValue<int>();
  43. if (!infoBoxDict.ContainsKey(route))
  44. {
  45. continue;
  46. }
  47. var infoBox = infoBoxDict[route];
  48. if (!infoBox.DataValid
  49. || !infoBox.BoxCalled)
  50. {
  51. continue;
  52. }
  53. string pos = config.LocationCode.GetLocationMember("续接任务取货点");
  54. if (PmsTaskService.Instance.LocationHasTask(pos))
  55. {
  56. //该点已有任务,不能产生任务
  57. continue;
  58. }
  59. location1 = config.LocationCode.GetLocationMember("续接任务取货点");
  60. location2 = config.LocationCode.GetLocationMember("续接任务放货点");
  61. break;
  62. }
  63. if (!string.IsNullOrEmpty(location1)
  64. && !string.IsNullOrEmpty(location2))
  65. {
  66. locationManager.UpdateStatusNotLocked(location2, LocationStatus.Empty);
  67. PmsTaskInfoDto data = new PmsTaskInfoDto();
  68. data.LocationCode = location1;
  69. data.TargetLocationCode = location2;
  70. var result = PmsTaskService.Instance.TaskAdd(data);
  71. }
  72. }
  73. }
  74. }