Admin
2025-12-02 9e42f0dafa019f5ecf6b0ff425ecb966b002171e
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WIDESEA.Common;
using WIDESEA.Core.Utilities;
using WIDESEA.Entity.DomainModels;
using WIDESEA.Services.Repositories;
 
namespace WIDESEA.Services.Services
{
    public partial class CommonFunction
    {
 
        public static WebResponseContent SelectContainerList(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                //string line = saveModel.MainData["layer"].ToString();
                Console.Out.WriteLine("开始时间:" + DateTime.Now);
                List<List<object>> lists = new List<List<object>>();
                List<Dt_locationinfo> allLocation = Dt_locationinfoRepository.Instance.Find(x => true);
                List<VV_ContainerInfo> allContainer = VV_ContainerInfoRepository.Instance.Find(x => true);
                List<VV_ContainerInfo_EmptyPallet> allEmptyContainer = VV_ContainerInfo_EmptyPalletRepository.Instance.Find(x => true);
                int count = 1;
                for (int i = 1; i <= 2; i++)
                {
                    List<object> list = new List<object>();
                    List<Dt_locationinfo> currentLineLocations = allLocation.FindAll(r => r.location_line == i);
                    foreach (var item in currentLineLocations.GroupBy(r => r.location_layer).OrderBy(r => r.Key))
                    {
                        List<object> layerlist = new List<object>();
                        List<Dt_locationinfo> layerLocation = item.OrderBy(r => r.location_column).ToList();
                        foreach (var temp in layerLocation)
                        {
                            VV_ContainerInfo containerInfo = allContainer.Find(x => x.location_id == temp.location_id);
                            VV_ContainerInfo_EmptyPallet emptyPalletContainer = allEmptyContainer.Find(x => x.location_id == temp.location_id);
                            if (containerInfo != null)
                                containerInfo.location_state = locationstate(temp, containerInfo, true);
                            else if (emptyPalletContainer != null)
                                emptyPalletContainer.location_state = locationstate(temp, containerInfo, true);
                            else
                                temp.location_state = locationstate(temp, containerInfo, false);
 
                            if (containerInfo != null)
                            {
                                layerlist.Add(new
                                {
                                    color = "success",
                                    id = temp.location_id,
                                    src = LocationStausImage(containerInfo.location_state),
                                    form = containerInfo,
                                    form2 = temp
                                });
                            }
                            else if (emptyPalletContainer != null)
                            {
                                layerlist.Add(new
                                {
                                    color = "success",
                                    id = temp.location_id,
                                    src = LocationStausImage(emptyPalletContainer.location_state),
                                    form = emptyPalletContainer,
                                    form2 = temp
                                });
                            }
                            else
                            {
                                layerlist.Add(new
                                {
                                    color = "success",
                                    id = temp.location_id,
                                    src = LocationStausImage(temp.location_state),
                                    form = containerInfo,
                                    form2 = temp
                                }); ;
                            }
                            Console.Out.WriteLine($"第{count}次时间:" + DateTime.Now);
                            count++;
                        }
                        list.Add(layerlist);
 
                    }
                    lists.Add(list);
                }
 
                content.OK("成功", lists);
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            Console.Out.WriteLine("结束时间:" + DateTime.Now);
            return content;
        }
        public static string LocationStausImage(string locationState)
        {
            string img = "";
            switch (locationState)
            {
                case "有货被锁定":
                    img = "CountLocked";
                    break;
                case "空货位被锁定":
                    img = "NewLock";
                    break;
                case "空货位":
                    img = "NewEmpty";
                    break;
                case "入库中":
                    img = "NewInbound";
                    break;
                case "出库中":
                    img = "NewOutbound";
                    break;
                case "测量中":
                    img = "Measureing";
                    break;
                case "空托盘":
                    img = "EmptyPallet";
                    break;
                case "已测量":
                    img = "HadMeasure";
                    break;
                case "等待测量":
                    img = "WaitMeasure";
                    break;
                default:
                    img = "NoNormal";
                    break;
            }
            return img + ".png";
        }
        public static string locationstate(Dt_locationinfo locationinfo, VV_ContainerInfo containerInfo, bool flag)
        {
            string state = "";
            if (locationinfo.location_islocked)
            {
                if (flag)
                    return "有货被锁定";
                else
                    return "空货位被锁定";
            }
            if (locationinfo.location_state == LocationState.LocationState_Empty.ToString())
                return "空货位";
            else if (locationinfo.location_state.Contains("In"))
            {
                state = "入库中";
            }
            else if (locationinfo.location_state.Contains("Out"))
            {
                state = "出库中";
            }
            else if (locationinfo.location_state == LocationState.LocationState_Measureing.ToString())
            {
                state = "测量中";
            }
            else if (locationinfo.location_state == LocationState.LocationState_Stored.ToString())
            {
                if (null != containerInfo && flag)
                {
                    if (string.IsNullOrEmpty(containerInfo.csize_in_result))
                        state = "等待测量";
                    else
                        state = "已测量";
                }
                else
                    return "空托盘";
            }
            else
                state = "异常货位";
            return state;
        }
 
 
    }
}