dengjunjie
2025-06-06 7e7f17c08a0f18d83eb379ddff1689597fecefde
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_QuartzJob;
 
namespace WIDESEAWCS_Tasks
{
    public partial class AGVsignal
    {
        /// <summary>
        /// 申请进出交管区
        /// </summary>
        /// <param name="areaModel"></param>
        /// <returns></returns>
        public static object applyTrafficCtlArea(applyTrafficCtlAreaModel areaModel)
        {
            try
            {
                if (areaModel == null) throw new Exception("请求数据为空或传参格式有误");
                if (string.IsNullOrEmpty(areaModel.areaName)) throw new Exception("交管区编号为空");
                switch (areaModel.type)
                {
                    case 1:
                        AGVApplyIn(areaModel);
                        break;
                    case 2:
                        AGVApplyOut(areaModel);
                        break;
                    default:
                        throw new Exception($"未定义申请类型[type:{areaModel.type}]");
                }
            }
            catch (Exception ex)
            {
                return new { code = 400, message = ex.Message };
            }
            return new { code = 200, message = "success" };
        }
 
        public static void AGVApplyIn(applyTrafficCtlAreaModel areaModel)
        {
            try
            {
                CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceName == areaModel.areaName) as CommonConveyorLine;
                if (conveyorLine == null) throw new Exception("未找到输送线设备信息");
                if (!conveyorLine.IsConnected) throw new Exception($"输送线设备通讯异常");
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 
        public static void AGVApplyOut(applyTrafficCtlAreaModel areaModel)
        {
            try
            {
                CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceName == "输送线") as CommonConveyorLine;
                if (conveyorLine == null) throw new Exception("未找到输送线设备信息");
                if (!conveyorLine.IsConnected) throw new Exception($"输送线设备通讯异常");
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}