333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using wcftest.EnumDefine;
using wcftest.Model;
 
namespace wcftest.BussinessExtension
{
    public class ExtendHelper
    {
 
        /// <summary>
        /// 转换PLC任务号
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public static int ConvertPlcNO(int taskId)
        {
            if (taskId >= 65535)
            {
                taskId %= 65535;
            }
            taskId += 1;//自增加1
            if (taskId <= 0)// 增加验证 【Editby shaocx,2023-03-18】
            {
                throw new Exception("生成的任务号不能为0!");
            }
            if (taskId > 65535)// 增加验证 【Editby shaocx,2023-03-18】
            {
                throw new Exception("生成的任务号不能大于65535!");
            }
            return taskId;
        }
 
        /// <summary>
        /// 获取基础数据的叠盘机编号
        /// </summary>
        /// <param name="plateType"></param>
        /// <returns></returns>
        public static DiePanJiModel GetDeviceCodeForDiePanJi(int plateType)
        {
            DiePanJiModel model = null;
            //根据表Base_Equipment的配置得来
            Sys_containerType _Sys_containerType = (Sys_containerType)Enum.Parse(typeof(Sys_containerType), plateType.ToString());
            switch (_Sys_containerType)
            {
                case Sys_containerType.大托盘:
                    model = new DiePanJiModel()
                    {
                        DeviceCode = "D001",
                        DeviceName = "大叠盘机",
                        FullQuantity = 8
                    };
                    break;
                case Sys_containerType.小托盘:
                    model = new DiePanJiModel()
                    {
                        DeviceCode = "D002",
                        DeviceName = "小叠盘机",
                        FullQuantity = 10
                    };
                    break;
            }
 
            return model;
        }
 
        /// <summary>
        /// 获取要更新OnShelveStatus字段的失败字符串
        /// </summary>
        /// <param name="checkHeight"></param>
        /// <param name="height"></param>
        /// <param name="findEmptyReason"></param>
        /// <returns></returns>
        public static string GetOnShelveStatusFailMsg(int checkHeight, int height, string findEmptyReason)
        {
            return "找不到可用空库位-" + "光电检测高度:" + checkHeight + ",系统校验高度:" + height + "," + findEmptyReason;
        }
 
        //    /// <summary>
        //    /// 根据光电检测高度,得出库区1的高度
        //    /// </summary>
        //    /// <param name="checkHeight">光电检测高度</param>
        //    /// <returns></returns>
        //    public static int ConvertHeightForArea1(int checkHeight)
        //    {
        //        /*
        //         * 小堆垛机:
        //高度 1、2、3 ,去往 0-975
        //高度 4、5、6,去往 975-1850
        //         */
        //        return checkHeight > 3 ? 2 : 1;//因为库区1的高度只有两种,所以就转换成了1,2两种
        //    }
 
        //    /// <summary>
        //    /// 根据光电检测高度,得出库区2的高度
        //    /// </summary>
        //    /// <param name="checkHeight">光电检测高度</param>
        //    /// <returns></returns>
        //    public static int ConvertHeightForArea2(int checkHeight)
        //    {
        //        return checkHeight > 3 ? checkHeight - 1 : checkHeight;//因为库区2的高度只有四种,所以就转换成了1,2,3,4四种
        //    }
 
        /// <summary>
        /// 根据光电检测高度,得出库区的高度
        /// </summary>
        /// <param name="checkHeight">光电检测高度</param>
        /// <returns></returns>
        public static int ConvertHeightByArea(int areaCode, int checkHeight)
        {
            if (areaCode == 1)
            {//库区1
                /*
            * 小堆垛机:
   高度 1、2、3 ,去往 0-975
   高度 4、5、6,去往 975-1850
            */
                return checkHeight > 3 ? 2 : 1;//因为库区1的高度只有两种,所以就转换成了1,2两种
            }
            else if (areaCode == 2)
            {//库区2
                return checkHeight > 3 ? checkHeight - 1 : checkHeight;//因为库区2的高度只有四种,所以就转换成了1,2,3,4四种
            }
            else
            {
                throw new Exception("无效的库区" + areaCode);
            }
        }
    }
}