bklLiudl
2024-07-23 277bbae216debe7e6c04e8cc6ee6e1ba9763e14b
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
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common;
using Model;
using Model.WcsModel;
 
namespace BLL.DAL
{
    public class DAL_Alarm
    {
        public IList<WCSAlarmInfo> GetList(AjaxAlarmInfoList Json, ref PageInfo pageInfo)
        {
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("Select * from WCSAlarmInfo where Status=1 ");
 
                if (!string.IsNullOrWhiteSpace(Json.AlarmCode))
                {
                    strSql.Append(" and AlarmCode like '%" + Json.AlarmCode + "%'  ");
                }
                if (!string.IsNullOrWhiteSpace(Json.AlarmName))
                {
                    strSql.Append(" and AlarmName like '%" + Json.AlarmName + "%'  ");
                }
                DataTable dt = DataFactory.SqlDataBase().GetPageList(strSql.ToString(), null, "CreateTime", "Desc", ref pageInfo);
                return ModelConvertHelper<WCSAlarmInfo>.DataTableToModel(dt);
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
 
        //获取排序好的储位俯视图列表
        public IList<WCSStorageLocat> GetLocatList()
        {
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select WareHouseNo,RoadwayNo,Row,Depth,MAX([Column]) from WCSStorageLocat where IsDel = '0' and WareHouseNo = 'W01' group by WareHouseNo,RoadwayNo,Row,Depth " +
                    "ORDER BY " +
                    " RoadwayNo,Row,CASE " +
                    "   WHEN Row % 2 = 1 and Depth = '02' THEN '00' " +
                    "   WHEN Row % 2 = 1 and Depth = '01' THEN '01' " +
                    "   WHEN Row % 2 = 0 and Depth = '02' THEN '02' " +
                    "   WHEN Row % 2 = 0 and Depth = '01' THEN '01' " +
                    "END; ");
                DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(strSql);
                List<WCSStorageLocat> list = (List<WCSStorageLocat>)ModelConvertHelper<WCSStorageLocat>.DataTableToModel(dt);
                #region 注释无用代码
                //获取对应垛机起始目标位置
                //for (int i = 0; i < list.Count; i++)
                //{
                //    //临时位置(实际位置到现成与plc沟通
                //    if (i == 0)
                //    {
                //        list[i].Column2 = list[i].Column1 + 1;
                //        list[i].Column3 = 0;
                //    }
                //    else
                //    {
                //        if (list[i - 1].RoadwayNo == list[i].RoadwayNo)
                //        {
                //            list[i].Column2 = list[i - 1].Column2;
                //            list[i].Column3 = list[i - 1].Column3;
                //        }
                //        else if (i == 4)
                //        {
                //            list[i].Column2 = 24;
                //            list[i].Column3 = 11;
                //        }
                //        else if (i == 8)
                //        {
                //            list[i].Column2 = i + 30;
                //            list[i].Column3 = list[i].Column1 + 1;
                //        }
                //        else if (i == 12)
                //        {
                //            list[i].Column2 = 3;
                //            list[i].Column3 = 42;
                //        }
                //        else if (i == 16)
                //        {
                //            list[i].Column2 = 9;
                //            list[i].Column3 = 33;
                //        }
                //        else if (i == 20)
                //        {
                //            list[i].Column2 = 30;
                //            list[i].Column3 = 50;
                //        }
                //        else if (i == 24)
                //        {
                //            list[i].Column2 = list[i].Column1 + 1;
                //            list[i].Column3 = list[i].Column1;
                //        }
                //    }
                //}
                #endregion
                return list;
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
 
        public bool AlarmDelete(string[] ID)
        {
            bool result = false;
            try
            {
                int dt = DataFactory.SqlDataBase().IsExist("Alarm", "ID", ID);
                if (dt >= ID.Length)
                {
                    int i = 0;
                    while (i < ID.Length)
                    {
                        StringBuilder sql = new StringBuilder();
                        sql.Append("update Alarm set IsDel=1 where Id='" + ID[i] + "'");
                        int _ret = DataFactory.SqlDataBase().ExecuteBySql(sql);
                        if (_ret >= ID.Length) result = true;
                        i++;
                    }
 
                }
                return result;
 
            }
            catch
            {
                return result;
            }
        }
 
        public bool AlarmDispose(string[] ID, string loginUser)
        {
            bool result = false;
            try
            {
                int dt = DataFactory.SqlDataBase().IsExist("Alarm", "ID", ID);
                if (dt >= ID.Length)
                {
                    int i = 0;
                    while (i < ID.Length)
                    {
                        StringBuilder sql = new StringBuilder();
                        sql.Append("update Alarm set State = 1,UpdateUser = '" + loginUser + "',UpdateTime = getdate() where Id='" + ID[i] + "'");
                        int _ret = DataFactory.SqlDataBase().ExecuteBySql(sql);
                        if (_ret >= ID.Length) result = true;
                        i++;
                    }
 
                }
                return result;
 
            }
            catch
            {
                return result;
            }
        }
    }
}