NouYouLocationMonitorApp.cs
11.5 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
using Infrastructure;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using WebRepository;
namespace WebApp
{
/// <summary>
/// 库位监控
/// </summary>
public partial class NouYouLocationMonitorApp
{
private IUnitWork _unitWork;
public NouYouLocationMonitorApp(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public TableData GetRoadwayApp(int roadway,int line)
{
TableData tab = new TableData();
try
{
if (roadway == 5)
{
var list = (from location in _unitWork.Find<Location>(n => n.Roadway == 5 && n.Line == line && (n.Code.Contains("EA") || n.Code.Contains("EB")))
join con in _unitWork.Find<Container>(null)
on location.ContainerCode equals con.Code into lc
from con in lc.DefaultIfEmpty()
select new { Code = location.Code, Row = location.Row, Layer = location.Layer, ContainerCode = location.ContainerCode, Status = location.Status, Type = con == null ? null:con.Type }).OrderByDescending(n => n.Layer).ToList();
tab.data = list;
}
else if (roadway == 6)
{
var list = (from location in _unitWork.Find<Location>(n => n.Roadway == 5 && n.Line == line && (n.Code.Contains("EC") || n.Code.Contains("ED")))
join con in _unitWork.Find<Container>(null)
on location.ContainerCode equals con.Code into lc
from con in lc.DefaultIfEmpty()
select new { Code = location.Code, Row = location.Row, Layer = location.Layer, ContainerCode = location.ContainerCode, Status = location.Status, Type = con == null ? null : con.Type }).OrderByDescending(n => n.Layer).ToList();
tab.data = list;
}
else
{
var list = (from location in _unitWork.Find<Location>( n => n.Roadway == roadway && n.Line == line)
join con in _unitWork.Find<Container>(null)
on location.ContainerCode equals con.Code into lc
from con in lc.DefaultIfEmpty()
select new { Code = location.Code, Row = location.Row, Layer = location.Layer, ContainerCode = location.ContainerCode, Status = location.Status, Type = con == null ? null : con.Type }).OrderByDescending(n => n.Layer).ToList();
tab.data = list;
}
tab.code = 200;
}
catch (Exception ex)
{
tab.code = 300;
tab.msg = ex.Message;
}
return tab;
}
public TableData GetLineApp(int roadway)
{
TableData tab = new TableData();
try
{
if (roadway == 5)
{
var list = (from location in _unitWork.Find<Location>(null)
where location.Roadway == roadway && (location.Code.Contains("EA") || location.Code.Contains("EB"))
group location by new {location.Line } into line
select new { line.Key }).OrderBy(n => n.Key.Line).ToList();
tab.data = list;
}
else if (roadway == 6)
{
var list = (from location in _unitWork.Find<Location>(null)
where location.Roadway == 5 && (location.Code.Contains("EC") || location.Code.Contains("ED"))
group location by new { location.Line } into line
select new { line.Key }).OrderBy(n => n.Key.Line).ToList();
tab.data = list;
}
else
{
var list = (from location in _unitWork.Find<Location>(null)
where location.Roadway == roadway
group location by new { location.Line } into line
select new { line.Key }).OrderBy(n => n.Key.Line).ToList();
tab.data = list;
}
tab.code = 200;
}
catch (Exception ex)
{
tab.code = 300;
tab.msg = ex.Message;
}
return tab;
}
public TableData GetInveApp(string code)
{
TableData tab = new TableData();
try
{
List<Inventory> inventories = _unitWork.Find<Inventory>(n => n.LocationCode == code).ToList();
if (inventories.Count == 0)
{
tab.data = null;
}
else
{
tab.data = inventories;
}
tab.code = 0;
}
catch (Exception ex)
{
tab.code = 300;
tab.msg = ex.Message;
}
return tab;
}
public TableData GetLocDataApp(int roadway,int line)
{
TableData tab = new TableData();
try
{
List<Location> list = new List<Location>();
if (roadway == 5)
{
list = _unitWork.Find<Location>(n => n.Roadway == 5 && n.Line == line && (n.Code.Contains("EA") || n.Code.Contains("EB"))).ToList();
}
else if (roadway == 6)
{
list = _unitWork.Find<Location>(n => n.Roadway == 5 && n.Line == line && (n.Code.Contains("EC") || n.Code.Contains("ED"))).ToList();
}
else
{
list = _unitWork.Find<Location>(n => n.Roadway == roadway && n.Line == line).ToList();
}
decimal sum;
//有托盘仓位
decimal consum;
//空仓位
decimal empty;
//有货仓位
decimal some;
//空栈板
decimal emptycontainer;
//利用率 包含空栈板
decimal consumsum;
//利用率
decimal somesum;
if (roadway == 5)
{
//库位总数
sum = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EA") || n.Code.Contains("EB")) && n.Line == line);
//有托盘仓位
consum = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EA") || n.Code.Contains("EB")) && n.Line == line && !string.IsNullOrEmpty(n.ContainerCode));
//空仓位
empty = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EA") || n.Code.Contains("EB")) && n.Line == line && n.Status == "empty");
//有货仓位
some = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EA") || n.Code.Contains("EB")) && n.Line == line && n.Status == "some");
//空栈板
emptycontainer = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EA") || n.Code.Contains("EB")) && n.Line == line && n.Status == "emptycontainer");
//利用率 包含空栈板
consumsum = (consum / sum) * 100;
//利用率
somesum = (some / sum) * 100;
}
else if (roadway == 6)
{
//库位总数
sum = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EC") || n.Code.Contains("ED")) && n.Line == line);
//有托盘仓位
consum = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EC") || n.Code.Contains("ED")) && n.Line == line && !string.IsNullOrEmpty(n.ContainerCode));
//空仓位
empty = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EC") || n.Code.Contains("ED")) && n.Line == line && n.Status == "empty");
//有货仓位
some = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EC") || n.Code.Contains("ED")) && n.Line == line && n.Status == "some");
//空栈板
emptycontainer = list.Count(n => n.IsStop == false && n.Roadway == 5 && n.Line == line && (n.Code.Contains("EC") || n.Code.Contains("ED")) && n.Line == line && n.Status == "emptycontainer");
//利用率 包含空栈板
consumsum = (consum / sum) * 100;
//利用率
somesum = (some / sum) * 100;
}
else
{
//库位总数
sum = list.Count(n => n.IsStop == false && n.Roadway == roadway && n.Line == line);
//有托盘仓位
consum = list.Count(n => n.IsStop == false && n.Roadway == roadway && n.Line == line && !string.IsNullOrEmpty(n.ContainerCode));
//空仓位
empty = list.Count(n => n.IsStop == false && n.Roadway == roadway && n.Line == line && n.Status == "empty");
//有货仓位
some = list.Count(n => n.IsStop == false && n.Roadway == roadway && n.Line == line && n.Status == "some");
//空栈板
emptycontainer = list.Count(n => n.IsStop == false && n.Roadway == roadway && n.Line == line && n.Status == "emptycontainer");
//利用率 包含空栈板
consumsum = (consum / sum) * 100;
//利用率
somesum = (some / sum) * 100;
}
dynamic temp = new ExpandoObject();
temp.sum = sum;
temp.consum = consum;
temp.empty = empty;
temp.some = some;
temp.emptycontainer = emptycontainer;
temp.consumsum = ((consum / sum) * 100).ToString("f0") + "%";
temp.somesum = ((some / sum) * 100).ToString("f0") + "%";
//string str = $"库位总数:{temp.sum} 有托盘仓位:{temp.consum} 空仓位:{temp.empty} 有货仓位:{temp.some} " +
// $"空栈板:{temp.emptycontainer} 利用率(含空栈板):{temp.consumsum} 利用率:{temp.somesum}";
string str = $"库位总数:{temp.sum} 空仓位:{temp.empty} 空栈板:{temp.emptycontainer} 利用率(空):{temp.consumsum} 利用率:{temp.somesum}";
tab.data = str;
tab.code = 0;
}
catch (Exception ex)
{
tab.code = 300;
tab.msg = ex.Message;
}
return tab;
}
}
}