chengsc
2024-07-23 f575652587d4160ab42e75acb2bc26b4f60fb7c3
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
using Lib;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using Model;
using BLL.DAL;
using System.Linq;
using System.Collections.Generic;
using Common;
using Json;
using System.Collections;
using System;
 
namespace wms.Areas.BasicInfo.Controllers
{
    public class DepotsLocationController : MasterPage
    {
        // GET: BasicInfo/DepotsLocation
        [LoginFilter]
        public ActionResult Index()
        {
            ViewBag.Title = "库位管理";
            ViewBag.DepotsArea = LocalHelper.GetDepotsAreaHtml();
            ViewBag.DepotsRow = LocalHelper.GetDepotsNumHtml("DepotsRow");
            ViewBag.DepotsColumn = LocalHelper.GetDepotsNumHtml("DepotsColumn");
            ViewBag.DepotsLayer = LocalHelper.GetDepotsNumHtml("DepotsLayer");
 
            ViewBag.Property = LocalHelper.GetDictionaryCodeHtml("Property");
            ViewBag.TurnoverDemand = LocalHelper.GetDictionaryCodeHtml("TurnoveDemand","-03");
            ViewBag.Type = LocalHelper.GetDictionaryCodeHtml("Type");
 
            return View();
        }
 
        [LoginFilter]
        public ActionResult AddEdit() 
        {
            try
            {
                string Guid = Request.QueryString.Get("Guid");
                DALDepotsLocation depotsLocation = new DALDepotsLocation();
 
                if (Guid != null && Guid != "")
                {
                    DepotsLocation dLocation  = depotsLocation.GetDepotsLocationItems(Guid)[0];
 
                    ViewBag.LocationCode = dLocation.LocationCode;
                    ViewBag.DepotsArea = LocalHelper.GetDepotsAreaHtml(dLocation.DepotsAreaID);
                    ViewBag.LRow = LocalHelper.GetDepotsNumHtml("DepotsRow", dLocation.DepotsAreaID, dLocation.LRow);
                    ViewBag.LColumn = LocalHelper.GetDepotsNumHtml("DepotsColumn", dLocation.DepotsAreaID, dLocation.LColumn);
                    ViewBag.LLayer = LocalHelper.GetDepotsNumHtml("DepotsLayer", dLocation.DepotsAreaID, dLocation.LLayer);
                    ViewBag.Type = LocalHelper.GetDictionaryCodeHtml("Type", dLocation.TypeID);
                    ViewBag.Property = LocalHelper.GetDictionaryCodeHtml("Property", dLocation.PropertyID);
                    ViewBag.TurnoverDemand = LocalHelper.GetDictionaryCodeHtml("TurnoveDemand", dLocation.TurnoverDemandID);
                    ViewBag.Weight = dLocation.Weight;
                    ViewBag.Volume = dLocation.Volume;
                    ViewBag.Long = dLocation.Long;
                    ViewBag.Width = dLocation.Width;
                    ViewBag.Height = dLocation.Height;
                    ViewBag.NumPlies = dLocation.NumPlies;
                    ViewBag.IsBatch = "name='IsBatch'";
                    if (dLocation.IsBatch == 0)
                    {
                        ViewBag.IsBatch = "name='IsBatch' checked='checked'";
                    }
                    ViewBag.IsProduct = "name='IsProduct'";
                    if (dLocation.IsProduct == 0)
                    {
                        ViewBag.IsProduct = "name='IsProduct' checked='checked'";
                    }
                   
                    ViewBag.Demo = dLocation.Demo;
                }
                else
                {
                    ViewBag.LocationCode = "";
                    ViewBag.DepotsArea = LocalHelper.GetDepotsAreaHtml();
                    ViewBag.LRow = LocalHelper.GetDepotsNumHtml("DepotsRow");
                    ViewBag.LColumn = LocalHelper.GetDepotsNumHtml("DepotsColumn");
                    ViewBag.LLayer = LocalHelper.GetDepotsNumHtml("DepotsLayer");
                    ViewBag.Type = LocalHelper.GetDictionaryCodeHtml("Type");
                    ViewBag.Property = LocalHelper.GetDictionaryCodeHtml("Property");
                    ViewBag.TurnoverDemand = LocalHelper.GetDictionaryCodeHtml("TurnoveDemand");
                    ViewBag.IsBatch = "name='IsBatch'";
                    ViewBag.IsProduct = "name='IsProduct'";
                }
 
                return View();
            }
            catch (System.Exception)
            {
                return View();
            }
        }
    }
 
 
    public class DLocationAjaxController : AjaxPage
    {
        /// <summary>
        /// 下拉框联动
        /// </summary>
        /// <returns></returns>
        public ActionResult BindOption()
        {
            try
            {
                string Guid = Request["ajaxdata"];
                string OperType = Request["opertype"];
 
                if (OperType == "Region")
                {
                    ReturnJson.AddProperty("DepotsArea", LocalHelper.GetDepotsAreaHtml(Guid));
                }
                else 
                {
                    ReturnJson.AddProperty("DepotsRow", LocalHelper.GetDepotsNumHtml("DepotsRow", Guid));
                    ReturnJson.AddProperty("DepotsColumn", LocalHelper.GetDepotsNumHtml("DepotsColumn", Guid));
                    ReturnJson.AddProperty("DepotsLayer", LocalHelper.GetDepotsNumHtml("DepotsLayer", Guid));
                }
 
                return Content(this.ReturnJson.ToString());
            }
            catch (System.Exception ex)
            {
                WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod());
                return Content(null);
            }
        }
 
        /// <summary>
        /// 获取库位信息集合
        /// </summary>
        /// <returns></returns>
        public ActionResult GetDLocationItems() 
        {
            try
            {
                var dd = Request["ajaxdata"];
                var modelItems = new JavaScriptSerializer().Deserialize<QueryDLocation>(dd);
                if (modelItems != null)
                {
                    // 实例化分页信息
                    PageInfo pageInfo = new PageInfo()
                    {
                        PageIndex = modelItems.PageIndex,
                        PageSize = modelItems.PageSize
                    };
 
                    // 数据库交互,获取库区集合and分页信息。
                    DALDepotsLocation provider = new DALDepotsLocation();
                    List<DepotsLocation> entity = provider.GetDepotsLocationItems(modelItems, ref pageInfo).ToList();
 
                    // Data =》json
                    string json = JsonHelper.IListToJson<DepotsLocation>(entity, "List");
                    string pjson = ConvertJson.Serializer(pageInfo);
 
                    // controller => view
                    ReturnJson.AddProperty("Result", new JsonObject(json));
                    ReturnJson.AddProperty("PageInfo", new JsonObject(pjson));
                    ReturnJson.AddProperty("Code", 1);
                    ReturnJson.AddProperty("Message", "加载库位集合成功!");
 
                    return Content(this.ReturnJson.ToString());
                }
 
                return Content(null);
            }
            catch (Exception ex) 
            {
                WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod());
                return Content(null);
            }
        }
 
        /// <summary>
        /// 编辑库位信息
        /// </summary>
        /// <returns></returns>
        public ActionResult SetDLocations() 
        {
            try
            {
                var dd = Request["ajaxdata"];
                var Items = new JavaScriptSerializer().Deserialize<DepotsLocation>(dd);
                if (Items != null)
                {
                    // 数据库交互
                    DALDepotsLocation provider = new DALDepotsLocation();
                    if (provider.SetDLocations(Items, this.LoginUserCode))
                    {
                        // 批量更新库位信息
                        if (Session["Locations"] != null)
                        {
                            ArrayList list = (ArrayList)Session["Locations"];
                            foreach (string guid in list) 
                            {
                                Items.Guid = guid;
                                provider.SetDLocations(Items, this.LoginUserCode);
                            }
                        }
 
                        Session["Locations"] = null;
                        ReturnJson.AddProperty("Code", 1);
                        ReturnJson.AddProperty("Message", "保存成功!");
                    }
                    else
                    {
                        ReturnJson.AddProperty("Code", 1);
                        ReturnJson.AddProperty("Message", "保存失败!");
                    }
                }
 
                return Content(this.ReturnJson.ToString());
            }
            catch (System.Exception ex)
            {
                WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod());
                return Content(null);
            }
        }
 
        /// <summary>
        /// 将选择的库位暂存在缓存内
        /// </summary>
        /// <returns></returns>
        public ActionResult SetLocationsSeession() 
        {
            Session["Locations"] = null;
            var dd = Request["list"];
            Session["Locations"] = new JavaScriptSerializer().Deserialize<ArrayList>(dd);
 
            ReturnJson.AddProperty("Code", 1);
            return Content(this.ReturnJson.ToString());
        }
 
        public ActionResult DelLocations()
        {
            try
            {
                string dd = Request["list"];
                ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd);
                string[] list = (string[])models.ToArray(typeof(string));
 
                if (models != null)
                {
                    // 数据库交互
                    DALDepotsLocation provider = new DALDepotsLocation();
                    if (provider.DelLocations(list, this.LoginUserCode))
                    {
                        ReturnJson.AddProperty("Code", 1);
                        ReturnJson.AddProperty("Message", "删除成功!");
                    }
                    else
                    {
                        ReturnJson.AddProperty("Code", 1);
                        ReturnJson.AddProperty("Message", "删除失败!");
                    }
                }
 
                return Content(this.ReturnJson.ToString());
            }
            catch (System.Exception ex)
            {
                WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod());
                return Content(null);
            }
        }
 
        /// <summary>
        /// 验证库位是否操作员所属部门占用         
        /// </summary>
        /// <returns></returns>
        public ActionResult CheckDepartment() 
        {
            try
            {
                string dd = Request["ajaxdata"];
                if (dd != "")
                {
                    // 数据库交互
                    DALDepotsLocation provider = new DALDepotsLocation();
                    if (!provider.CheckDepartment(dd, this.LoginDepartNum))
                    {
                        ReturnJson.AddProperty("Code", 1);
                        ReturnJson.AddProperty("Message", "其他部门占用的库位,不允许修改!");
                    }
                    else 
                    {
                        ReturnJson.AddProperty("Code", 0);
                        ReturnJson.AddProperty("Message", "允许修改!");
                    }
                }
 
                return Content(this.ReturnJson.ToString());
            }
            catch (System.Exception ex)
            {
                WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod());
                return Content(null);
            }
        }
 
    }
}