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
using iWareCc.Cache.Entity;
using iWareCc.DecomposeTask.Entity;
using iWareCcTest.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 ResultContainer ResultContainer;
        private MainTaskContainer LogisticalTaskContainer;
        private PartTaskContainer DecompositionTaskContainer;
        private PlaceContainer PlaceContainer;
 
        /// <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;
                }
 
                var sourcePlace = CacheEntity.Places.FirstOrDefault(x => x.PlaceTypeName == "gate11");//"输送机始端库口"
                var toPlace = CacheEntity.Places.FirstOrDefault(x => x.PlaceTypeName == "gate12");//"输送机末端库口"
                var equipment = CacheEntity.Equipments.FirstOrDefault(x => x.EquipName == "conveyor1");//入库输送机
 
                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 = sourcePlace.Code,
                    SourcePlaceId = sourcePlace.Id,
                    ToPlace = toPlace.Code,
                    ToPlaceId = toPlace.Id,
                    Status = (int)EPartTaskStatus.未开始,
                    CreateTime = DateTime.Now,
                    UpdateTime = DateTime.Now,
                    EquipId = equipment.Id,
                    EquipName = equipment.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 = PlaceContainer.Place.Id,
                    NextNode=(int)EInstorgNextNode.gate13,
                    IsLots = LogisticalTaskContainer.MainTask.IsLots
                };
 
                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);
            }
        }
    }
}