zhao
2021-06-24 02ca96debc6056275d58e55d97f7885a195542d0
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
using HH.WMS.BLL;
using HH.WMS.BLL.Algorithm;
using HH.WMS.BLL.Basic;
using HH.WMS.Common.Algorithm;
using HH.WMS.Entitys;
using HH.WMS.Entitys.Algorithm;
using HH.WMS.Entitys.Basic;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
 
namespace HH.WMS.WebApi.Areas.Common.Controllers
{
    public class LocationController : BaseController
    {
 
        #region 获取仓库下的所有巷道
        /// <summary>
        /// 获取仓库下的所有巷道
        /// </summary>
        /// <param name="tokenId"></param>
        /// <param name="stockCode">仓库号</param>
        /// <param name="areaCode">库区号</param>
        /// <returns></returns>
        /// <History>[Hanhe(DBS)] created 2018/12/04</History>
        [HttpGet]
        public OperateResult GetTunnels(string stockCode, string areaCode)
        {
            try
            {
                return ValidateToken(y =>
              {
                  List<AutoBomStockStructreEntity> structreList = BLLCreator.Create<TN_WMS_STOCKBLL>().GetStructList(stockCode, areaCode);
                  List<string> roadWay = structreList.GroupBy(x => x.CN_S_ROADWAY).OrderBy(x => x.Key).Select(o => o.Key).ToList();
                  return OperateResult.Succeed("", roadWay);
              });
            }
            catch (Exception ex)
            {
                return OperateResult.Error("查询异常!" + ex.ToString());
            }
        }
        #endregion
 
        #region 获取巷道下面的所有排信息
        /// <summary>
        /// 获取巷道下面的所有排信息
        /// </summary>
        /// <param name="tokenId"></param>
        /// <param name="stockCode">仓库号</param>
        /// <param name="areaCode">库区号</param>
        /// <param name="roadway">巷道</param>
        /// <returns></returns>
        /// <History>[Hanhe(DBS)] created 2018/12/04</History>
        [HttpGet]
        public OperateResult GetStructList(string stockCode, string areaCode, string roadway)
        {
            return ValidateToken(y =>
            {
                List<AutoBomStockStructreEntity> structreList = BLLCreator.Create<TN_WMS_STOCKBLL>().GetStructList(stockCode, areaCode);
                if (!string.IsNullOrEmpty(roadway))
                {
                    structreList = structreList.FindAll(x => x.CN_S_ROADWAY.Equals(roadway)).ToList();
                }
                structreList = structreList.OrderBy(e => e.CN_S_ROW).ToList();
                return OperateResult.Succeed("", structreList);
            });
        }
        #endregion
 
        #region 获取巷道下的货位信息
        /// <summary>
        /// 获取巷 道下的货位信息
        /// </summary>
        /// <param name="tokenId"></param>
        /// <param name="stockCode">仓库号</param>
        /// <param name="areaCode">库区号</param>
        /// <param name="roadway">巷道号</param>
        /// <returns></returns>
        /// <History>[Hanhe(DBS)] created 2018/12/04</History>
        [HttpGet]
        public string GetTunnelLocations(string stockCode, string areaCode, string roadway)
        {
            try
            {
                return ValidateToken(x =>
                {
                    DataTable dt = BLLCreator.Create<TN_WM_LOCATION_EXTBLL>().ViewState(stockCode, areaCode, roadway);
                    return JsonConvert.SerializeObject(OperateResult.Succeed("", dt));
                });
            }
            catch (Exception ex)
            {
                return JsonConvert.SerializeObject(OperateResult.Error("查询异常!" + ex.ToString()));
            }
        }
        #endregion
 
        #region PDA接口-获取建议货位
        /// <summary>
        /// 整托获取建议货位-空货位
        /// </summary>
        /// <param name="areaCode">库区</param>
        /// <param name="trayCode">托盘编码</param>
        /// <param name="itemCode">物料编码</param>
        /// <param name="locationQty">获取货位的数量</param>
        /// <param name="tokenId">tokenId</param>
        /// <returns></returns>
        [HttpGet]
        public OperateResult GetZtEmptyCommandLocation(string areaCode, string trayCode, string itemCode, int locationQty)
        {
            return ValidateToken(x =>
          {
              //调用入库算法,获取空货位
              InAlgorEnitty iAe = new InAlgorEnitty()
              {
                  stockAreaCode = areaCode,
                  logicCode = "",
                  locationQty = locationQty,
                  trayCode = trayCode,
                  itemCode = itemCode,
                  lockLocation = false//是否需要锁定货位
              };
              iAe.lstDevice = null;
 
              var paramString = JsonConvert.SerializeObject(iAe);
              InResultEntity irEresult = BLLCreator.Create<In_AlgorBLL>().In(iAe);
              if (!irEresult.Success)
              {
                  return OperateResult.Error(irEresult.Msg);//货位获取失败!
              }
 
              return OperateResult.Succeed("", irEresult.lstLocation);
          });
        }
 
        /// <summary>
        /// 物料上架获取建议货位-空货位
        /// </summary>
        /// <param name="areaCode"></param>
        /// <param name="itemCode"></param>
        /// <returns></returns>
        [HttpGet]
        public OperateResult GetEmptyCommandLocation(string areaCode, string itemCode)
        {
            return ValidateToken(x =>
            {
                //调用补料算法,获取空货位
                FeedAlgorEntity fAe = new FeedAlgorEntity()
                {
                    stockAreaCode = areaCode,
                    itemCode = itemCode,
                    lockLocation = false//是否需要锁定货位
                };
 
                var paramString = JsonConvert.SerializeObject(fAe);
                FeedResultEntity feedResult = BLLCreator.Create<Feed_AlgorBLL>().FeedEmptyLocation(fAe);
                if (!feedResult.Success)
                {
                    return OperateResult.Error(feedResult.Msg);//货位获取失败!
                }
 
                return OperateResult.Succeed("", feedResult.lstLocation);
            });
        }
        #endregion
 
        [HttpGet]
        public OperateResult GetStateQty(string stockCode)
        {
            return ValidateToken(x =>
            {
                DataTable dt = BLLCreator.Create<TN_WM_LOCATION_EXTBLL>().GetStateQty(stockCode);
                return OperateResult.Succeed("", dt);
            });
        }
 
        #region 获取摆放位置
        /// <summary>
        /// 获取摆放位置
        /// </summary>
        /// <param name="areaClass">区域类型</param>
        /// <returns></returns>
        [HttpGet]
        public OperateResult GetSHLocation(string areaClass)
        {
            return ValidateToken(x =>
            {
                List<AutoBomStockAreaEntity> list = new List<AutoBomStockAreaEntity>();
                List<AutoBomLocationEntity> listlocation = new List<AutoBomLocationEntity>();
                list = BLLCreator.Create<TN_WMS_STOCKBLL>().GetSHLocationArea(areaClass);
                if (list.Count > 0)
                {
                    List<string> arrAreaCode = new List<string>();
                    foreach (var item in list)
                    {
                        arrAreaCode.Add(item.CN_S_AREA_CODE);
                    }
                    listlocation = BLLCreator.Create<TN_WMS_STOCKBLL>().GetSHLocation(arrAreaCode);
                }
                return OperateResult.Succeed("", listlocation);
            });
        }
 
        #endregion
 
    }
}