dengjunjie
昨天 441b6f8d257a01b2998253ef0515a201777d7e68
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_Tasks.ShuttleCarJob;
using WIDESEAWCS_Tasks.StackerCraneJob;
 
namespace WIDESEAWCS_Tasks
{
    public partial class CommonStackerCraneJob
    {
        /// <summary>
        /// 心跳
        /// </summary>
        /// <param name="commonStackerCrane"></param>
        public void Heartbeat(SpeStackerCrane commonStackerCrane)
        {
            var HeartBeat = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.HeartBeat);
            commonStackerCrane.SetValue(StackerCraneDBName.WCSHeartBeat, !HeartBeat);
        }
 
        /// <summary>
        /// 堆垛机与穿梭车信息交互
        /// </summary>
        /// <param name="commonStackerCrane"></param>
        public void ShuttleCarSignal(SpeStackerCrane commonStackerCrane)
        {
            var ASRSRqtGetAGV = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.ASRSRqtGetAGV);
            var ASRSRqtGetGoods = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.ASRSRqtGetGoods);
            var ASRSRqtPutGoods = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.ASRSRqtPutGoods);
            var ASRSRqtPutAGV = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.ASRSRqtPutAGV);
            var ASRSGetAGVDone = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.ASRSGetAGVDone);
            var ASRSGetGoodsDone = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.ASRSGetGoodsDone);
            var ASRSPutAGoodsDone = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.ASRSPutAGoodsDone);
            var ASRSPutAGVDone = commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.ASRSPutAGVDone);
            //任务查询目的地找到车
            if (ASRSRqtGetAGV || ASRSRqtGetGoods || ASRSRqtPutGoods || ASRSRqtPutAGV || ASRSGetAGVDone || ASRSGetGoodsDone || ASRSPutAGoodsDone || ASRSPutAGVDone)
            {
                Dt_Task? task = GetTaskInfo(commonStackerCrane);
                if (task != null)
                {
                    if ((_taskService.TaskInboundTypes.Contains(task.TaskType)
                        || task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt())
                       && task.TargetIsPickPlace && ASRSRqtPutGoods)//请求放货
                    {
                        commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPuttGoods, ASRSRqtPutGoods);
                        WriteDebug($"{commonStackerCrane.DeviceName}请求放货", $"WCS允许放货,任务号【{task.TaskNum}】");
                    }
                    else if ((_taskService.TaskOutboundTypes.Contains(task.TaskType)
                        || task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt())
                        && ASRSRqtGetGoods && task.SourceIsPickPlace)//请求取货
                    {
                        commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetGoods, ASRSRqtGetGoods);
                        WriteDebug($"{commonStackerCrane.DeviceName}请求取货", $"WCS允许取货,任务号【{task.TaskNum}】");
                    }
                    else
                    {
                        if (task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt())
                        {
                            var shuttleCar2 = _shuttleCarService.QueryNoCode(task.ShuttleCarCode);
                            ShuttleCar shuttleCarA = Storage.Devices.FirstOrDefault(x => x.DeviceCode == shuttleCar2.ShuttleCarCode) as ShuttleCar;
                            ShuttleCar shuttleCarB = Storage.Devices.FirstOrDefault(x => x.DeviceCode == task.ShuttleCarCode) as ShuttleCar;
 
                            #region 取货
                            if (ASRSRqtGetGoods)
                            {
                                shuttleCarA.SetValue(ShuttleCarDBName.ASRSRqtGetGoods, ASRSRqtGetGoods, shuttleCarA.DeviceCode);
 
                                var AGVAlwASRSGetGoods = shuttleCarA.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.AGVAlwASRSGetGoods, shuttleCarA.DeviceCode);//允许取货
                                if (AGVAlwASRSGetGoods)
                                    commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetGoods, AGVAlwASRSGetGoods);
 
                                WriteDebug($"{commonStackerCrane.DeviceName}请求取货", $"【{shuttleCarA.DeviceName}】{(AGVAlwASRSGetGoods ? "允许" : "不允许")}取货,任务号【{task.TaskNum}】");
                            }
                            #endregion
 
                            #region 取货完成
                            if (ASRSGetGoodsDone)
                            {
                                shuttleCarA.SetValue(ShuttleCarDBName.ASRSGetGoodsDone, ASRSGetGoodsDone, shuttleCarA.DeviceCode);
                                WriteDebug($"{commonStackerCrane.DeviceName}取货完成", $"【{shuttleCarA.DeviceName}】,任务号【{task.TaskNum}】");
                            }
                            #endregion
 
                            #region 放货
                            if (ASRSRqtPutGoods)
                            {
                                shuttleCarB.SetValue(ShuttleCarDBName.ASRSRqtPutGoods, ASRSRqtPutGoods, shuttleCarB.DeviceCode);
 
                                var AGVAlwASRSPuttGoods = shuttleCarB.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.AGVAlwASRSPuttGoods, shuttleCarB.DeviceCode);//允许放货
                                if (AGVAlwASRSPuttGoods)
                                    commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPuttGoods, AGVAlwASRSPuttGoods);
 
                                WriteDebug($"{commonStackerCrane.DeviceName}请求放货", $"【{shuttleCarB.DeviceName}】{(AGVAlwASRSPuttGoods ? "允许" : "不允许")}放货,任务号【{task.TaskNum}】");
                            }
                            #endregion
 
                            #region 放货完成
                            if (ASRSPutAGoodsDone)
                            {
                                shuttleCarB.SetValue(ShuttleCarDBName.ASRSPutAGoodsDone, ASRSPutAGoodsDone, shuttleCarB.DeviceCode);
                                WriteDebug($"{commonStackerCrane.DeviceName}放货完成", $"【{shuttleCarA.DeviceName}】,任务号【{task.TaskNum}】");
                            }
                            #endregion
 
                        }
                        else
                        {
                            ShuttleCar shuttleCar = Storage.Devices.FirstOrDefault(x => x.DeviceCode == task.ShuttleCarCode) as ShuttleCar;
                            if (shuttleCar != null)
                            {
                                shuttleCar.SetValue(ShuttleCarDBName.ASRSRqtGetAGV, ASRSRqtGetAGV, shuttleCar.DeviceCode);
 
                                shuttleCar.SetValue(ShuttleCarDBName.ASRSRqtGetGoods, ASRSRqtGetGoods, shuttleCar.DeviceCode);
 
                                shuttleCar.SetValue(ShuttleCarDBName.ASRSRqtPutGoods, ASRSRqtPutGoods, shuttleCar.DeviceCode);
 
                                var AGVAlwASRSGetAGV = shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.AGVAlwASRSGetAGV, shuttleCar.DeviceCode);//允许取车
                                commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetAGV, AGVAlwASRSGetAGV);
 
                                if (ASRSRqtGetAGV)
                                    WriteDebug($"{commonStackerCrane.DeviceName}请求取车", $"【{shuttleCar.DeviceName}】{(AGVAlwASRSGetAGV ? "允许" : "不允许")}取车,任务号【{task.TaskNum}】");
 
                                var AGVAlwASRSGetGoods = shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.AGVAlwASRSGetGoods, shuttleCar.DeviceCode);//允许取货
                                commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetGoods, AGVAlwASRSGetGoods);
 
                                if (ASRSRqtGetGoods)
                                    WriteDebug($"{commonStackerCrane.DeviceName}请求取货", $"【{shuttleCar.DeviceName}】{(AGVAlwASRSGetGoods ? "允许" : "不允许")}取货,任务号【{task.TaskNum}】");
 
                                var AGVAlwASRSPuttGoods = shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.AGVAlwASRSPuttGoods, shuttleCar.DeviceCode);//允许放货
                                commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPuttGoods, AGVAlwASRSPuttGoods);
 
                                if (ASRSRqtPutGoods)
                                    WriteDebug($"{commonStackerCrane.DeviceName}请求放货", $"【{shuttleCar.DeviceName}】{(AGVAlwASRSPuttGoods ? "允许" : "不允许")}放货,任务号【{task.TaskNum}】");
 
                                commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPutAGV, ASRSRqtPutAGV);
                                if (ASRSRqtPutAGV)
                                    WriteDebug($"{commonStackerCrane.DeviceName}请求放车", $"WCS允许放车,任务号【{task.TaskNum}】");
 
                                shuttleCar.SetValue(ShuttleCarDBName.ASRSGetAGVDone, ASRSGetAGVDone, shuttleCar.DeviceCode);
                                if (ASRSGetAGVDone)
                                    WriteDebug($"{commonStackerCrane.DeviceName}取车完成", $"【{shuttleCar.DeviceName}】,任务号【{task.TaskNum}】");
 
                                shuttleCar.SetValue(ShuttleCarDBName.ASRSGetGoodsDone, ASRSGetGoodsDone, shuttleCar.DeviceCode);
                                if (ASRSGetGoodsDone)
                                    WriteDebug($"{commonStackerCrane.DeviceName}取货完成", $"【{shuttleCar.DeviceName}】,任务号【{task.TaskNum}】");
 
                                shuttleCar.SetValue(ShuttleCarDBName.ASRSPutAGoodsDone, ASRSPutAGoodsDone, shuttleCar.DeviceCode);
                                if (ASRSPutAGoodsDone)
                                    WriteDebug($"{commonStackerCrane.DeviceName}放货完成", $"【{shuttleCar.DeviceName}】,任务号【{task.TaskNum}】");
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 获取任务信息
        /// </summary>
        /// <param name="commonStackerCrane"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public Dt_Task GetTaskInfo(SpeStackerCrane commonStackerCrane)
        {
            return _taskService.GetTaskInfo(commonStackerCrane.CurrentTaskNum);
        }
 
        /// <summary>
        /// 获取穿梭车信息
        /// </summary>
        /// <param name="Address"></param>
        /// <returns></returns>
        public Dt_ShuttleCar GetShuttleCarInfo(string Address)
        {
            return _shuttleCarService.QueryShuttleCar(Address);
        }
    }
}