dengjunjie
2025-04-19 9e579eda4601ed7b492b9d19a24e8146f6ebdf8d
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
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);
                    }
                    else if ((_taskService.TaskOutboundTypes.Contains(task.TaskType)
                        || task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt())
                        && ASRSRqtGetGoods && task.SourceIsPickPlace)//请求取货
                    {
                        commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetGoods, ASRSRqtGetGoods);
                    }
                    else if (_taskService.TaskOutboundTypes.Contains(task.TaskType) && ASRSPutAGoodsDone)
                    {
 
                    }
                    else
                    {
                        Dt_ShuttleCar? shuttleCar1 = _shuttleCarService.QueryCode(task.ShuttleCarCode);
                        if (shuttleCar1 != null)
                        {
                            ShuttleCar shuttleCar = Storage.Devices.FirstOrDefault(x => x.DeviceName == shuttleCar1.ShuttleCarName) 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);
                                var AGVAlwASRSGetGoods = shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.AGVAlwASRSGetGoods, shuttleCar.DeviceCode);//允许取货
                                commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSGetGoods, AGVAlwASRSGetGoods);
                                var AGVAlwASRSPuttGoods = shuttleCar.GetValue<ShuttleCarDBName, bool>(ShuttleCarDBName.AGVAlwASRSPuttGoods, shuttleCar.DeviceCode);//允许放货
                                commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPuttGoods, AGVAlwASRSPuttGoods);
                                commonStackerCrane.SetValue(StackerCraneDBName.AGVAlwASRSPutAGV, ASRSRqtPutAGV);
 
                                shuttleCar.SetValue(ShuttleCarDBName.ASRSGetAGVDone, ASRSGetAGVDone, shuttleCar.DeviceCode);
                                shuttleCar.SetValue(ShuttleCarDBName.ASRSGetGoodsDone, ASRSGetGoodsDone, shuttleCar.DeviceCode);
                                shuttleCar.SetValue(ShuttleCarDBName.ASRSPutAGoodsDone, ASRSPutAGoodsDone, shuttleCar.DeviceCode);
                                //shuttleCar.SetValue(ShuttleCarDBName.ASRSPutAGVDone, ASRSPutAGVDone, shuttleCar.DeviceCode);
                            }
                        }
                    }
                }
            }
        }
        /// <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);
        }
    }
}