2
schangxiang@126.com
2024-08-16 b47c50a2a514def7374b32d7194b2c599cba5625
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using iWareCc.Cache.Entity;
using iWareCc.DecomposeTask.Entity;
using iWareCc.Properties;
using iWareCommon.Common.Entity;
using iWareCommon.Common.EnumType;
using iWareCommon.Utils;
using iWareDataCore.DEV.EnumType;
using iWareDataCore.TASK.Entity;
using iWareDataCore.TASK.EnumType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace iWareCc.DecomposeTask.Strategy.出库任务.Chain
{
   public class 生成堆垛机任务 : IHandler
    {
       private MainTaskContainer LogisticalTaskContainer;
       private PartTaskContainer DecompositionTaskContainer;
        private PlaceContainer PlaceContainer;
        private ResultContainer ResultContainer;
 
        /// <summary>
        /// 该节点的下一个节点
        /// </summary>
        private IHandler nextHandler = null;
        public IHandler NextHandler
        {
            set { nextHandler = value; }
        }
 
        public 生成堆垛机任务(ResultContainer resultContainer, MainTaskContainer logisticalTaskContainer, PartTaskContainer decompositionTaskContainer, PlaceContainer placeContainer)
        {
            this.ResultContainer = resultContainer;
            this.LogisticalTaskContainer = logisticalTaskContainer;
            this.DecompositionTaskContainer = decompositionTaskContainer;
            this.PlaceContainer = placeContainer;
        }
 
        public void Handle()
        {
 
            try
            {
                if (LogisticalTaskContainer.MainTask == null)
                {
                    ResultContainer.Msg = "未找到待分解任务";
                    LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "生成堆垛机任务:{0}", "未找到待分解任务");
                    return;
                }
 
                if (PlaceContainer.Place == null)
                {
                    ResultContainer.Msg = "未找到起始位置";
                    LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "生成堆垛机任务:{0}", "未找到起始位置");
                    return;
                }
                string stackerName = Enum.GetName(typeof(EEquipmentCnName), EEquipmentCnName.stacker1);
                var stacker = CacheEntity.Equipments.FirstOrDefault(x => x.EquipName == stackerName);
                var toPlace = CacheEntity.Places.FirstOrDefault(x => x.PlaceTypeName== "gate21");
 
                DecompositionTaskContainer.PartTask = new  PartTaskEntity
                {
                    Type = (int)EPartTaskType.堆垛机任务,
                    MainTaskId = LogisticalTaskContainer.MainTask.Id,
                    MainTaskType = LogisticalTaskContainer.MainTask.TaskType,
                    TaskNo = LogisticalTaskContainer.MainTask.TaskNo,
                    SysCode = LogisticalTaskContainer.MainTask.SysCode,
                    ExecutionSequence = 1,
                    SourcePlace = PlaceContainer.Place.Code,
                    SourcePlaceId = PlaceContainer.Place.Id,
                    SourcePosx = (int)PlaceContainer.Place.Row,
                    SourcePosy = (int)PlaceContainer.Place.Layer,
                    SourcePosz = (int)PlaceContainer.Place.Col,
                    ToPlace = toPlace.Code,
                    ToPlaceId = toPlace.Id,
                    ToPosx = (int)toPlace.Row,
                    ToPosy = (int)toPlace.Layer,
                    ToPosz = (int)toPlace.Col,
                    Status = (int)EPartTaskStatus.未开始,
                    CreateTime = DateTime.Now,
                    UpdateTime = DateTime.Now,
                    EquipId = stacker.Id,
                    EquipName = stacker.EquipName,
                    TaskProcessStatus = (int)ESrmState.未知,
                    VoidLabel = (int)EYesOrNo.否,
                    Priority = 100,
                    IsMoveTask = (int)EYesOrNo.否,
                    ProcessCardNumber = LogisticalTaskContainer.MainTask.ProcessCardNumber,
                    PackageNo = LogisticalTaskContainer.MainTask.PackageNo,
                    MaterialCode = LogisticalTaskContainer.MainTask.MaterialCode,
                    Quantity = LogisticalTaskContainer.MainTask.Quantity,
                    TargetPlaceId=416
                };
 
                LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "生成堆垛机任务:{0}", DecompositionTaskContainer.PartTask.TaskNo);
 
 
                if (nextHandler != null)
                {
                    nextHandler.Handle();
                }
            }
            catch (Exception ex)
            {
                ResultContainer.Msg = ex.Message;
                LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "生成堆垛机任务:{0}", ex.Message);
                LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "Handle", ex.Message);
            }
 
        }
    }
}