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
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
using BLL.DAL;
using Commom.Utility;
using Common;
using Json;
using Lib;
using Model;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web.Mvc;
using System.Web.Script.Serialization;
 
namespace wms.Areas.Business.Controllers
{
    public class CheckTaskController : MasterPage
    {
        // GET: Business/CheckTask
        [LoginFilter]
        public ActionResult Index()
        {
            ViewBag.Title = "盘点任务";
            ViewBag.StatuList = LocalHelper.GetDictionaryHtml("CDStatu");
            return View();
        }
 
        [LoginFilter]
        public ActionResult Edit()
        {
            Session["Items"] = null;
            ViewBag.Title = "编辑库存";
            string Guid = Request.QueryString.Get("Guid");
            DALCheckTask provider = new DALCheckTask();
            DataTable dt = provider.GetCheckTask(Guid);
            Session["Items"] = dt;
            return View();
        }
    }
 
    public class CheckTaskAjaxController : AjaxPage
    {
        public ActionResult GetList()
        {
            try
            {
                var dd = Request["aaa"];
                var modelItems = new JavaScriptSerializer().Deserialize<CheckTask>(dd);
                if (modelItems != null)
                {
                    // 实例化分页信息
                    PageInfo pageInfo = new PageInfo()
                    {
                        PageIndex = modelItems.PageIndex,
                        PageSize = modelItems.PageSize
                    };
                    modelItems.DepartGuid = this.LoginDepartNum;
                    // 数据库交互,获取库区集合and分页信息。
                    DALCheckTask provider = new DALCheckTask();
                    List<CheckTask> entity = provider.GetList(modelItems, ref pageInfo).ToList();
 
                    // Data =》json
                    string json = JsonHelper.IListToJson<CheckTask>(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 (System.Exception)
            {
                return Content(null);
            }
        }
 
        public ActionResult GetItems()
        {
            try
            {
                var dd = Request["bbb"];
                var modelItems = new JavaScriptSerializer().Deserialize<CheckMat>(dd);
                if (modelItems != null)
                {
                    // 数据库交互,获取库区集合and分页信息。
                    DataTable dt = (DataTable)Session["Items"];
                    string strWhere = "1=1 ";
                    if (!string.IsNullOrEmpty(modelItems.MatNo))
                    {
                        strWhere += "and MatNo like '%" + modelItems.MatNo + "%'";
                    }
                    if (!string.IsNullOrEmpty(modelItems.MatName))
                    {
                        strWhere += "and MatName like '%" + modelItems.MatName + "%'";
                    }
                    if (!string.IsNullOrEmpty(modelItems.Palno))
                    {
                        strWhere += "and Palno like '%" + modelItems.Palno + "%'";
                    }
                    if (!string.IsNullOrEmpty(modelItems.LingNo))
                    {
                        strWhere += "and LingNo like '%" + modelItems.LingNo + "%'";
                    }
 
                    DataRow[] rows = dt.Select(strWhere);
                    IList<CheckMat> entity = ModelConvertHelper<CheckMat>.DataRowToModel(rows);
                    // Data =》json
                    string json = JsonHelper.IListToJson<CheckMat>(entity, "List");
 
                    // controller => view
                    ReturnJson.AddProperty("Result", new JsonObject(json));
                    ReturnJson.AddProperty("Code", 1);
                    ReturnJson.AddProperty("Message", "加载托盘物料明细成功!");
 
                    return Content(this.ReturnJson.ToString());
                }
 
                return Content(null);
            }
            catch (System.Exception)
            {
                return Content(null);
            }
        }
 
        public ActionResult SetItems()
        {
            var dd = Request["bbb"];
            var models = new JavaScriptSerializer().Deserialize<CheckMat>(dd);
 
            if (models != null)
            {
                DALCheckTask provider = new DALCheckTask();
                if (provider.SetItems(this.LoginUserCode, models))
                {
                    // 刷新页面信息
                    DataTable dt = (DataTable)Session["Items"];
                    DataRow[] dr = dt.Select("Guid = " + models.Guid.AddQuotes());
                    if (dr != null)
                    {
                        dr[0].SetField("AQuant", models.AQuant);
                    }
 
                    ReturnJson.AddProperty("Code", 1);
                    ReturnJson.AddProperty("Message", "保存成功");
                }
                else
                {
                    ReturnJson.AddProperty("Code", -1);
                    ReturnJson.AddProperty("Message", "保存失败");
                }
 
                return Content(this.ReturnJson.ToString());
            }
 
            return Content(null);
        }
 
        public ActionResult CreateOrder()
        {
            var Guid = Request["aaa"];
            try
            {
                if (!string.IsNullOrEmpty(Guid))
                {
                    DALCheckTask provider = new DALCheckTask();
                    if (provider.CreateOrder(Guid, this.LoginUserCode))
                    {
                        ReturnJson.AddProperty("Code", 1);
                        ReturnJson.AddProperty("Message", "盘点出库指令已下发");
                    }
                    else
                    {
                        ReturnJson.AddProperty("Code", -1);
                        ReturnJson.AddProperty("Message", "盘点出库指令下发失败");
                    }
                }
            }
            catch
            {
                return Content(null);
            }
 
            return Content(this.ReturnJson.ToString());
        }
 
        /// <summary>
        /// 盘点任务自动出库
        /// </summary>
        /// <returns></returns>
        public ActionResult AutoOrders()
        {
            //var Guid = Request["aaa"];
            try
            {
                //if (!string.IsNullOrEmpty(Guid))
                //{
                DALCheckTask provider = new DALCheckTask();
                if (provider.AutoOrders(this.LoginUserCode))
                {
                    ReturnJson.AddProperty("Code", 1);
                    ReturnJson.AddProperty("Message", "盘点出库指令已下发!");
                }
                else
                {
                    ReturnJson.AddProperty("Code", -1);
                    ReturnJson.AddProperty("Message", "等待上条指令完成!");
                }
                //}
            }
            catch (System.Exception)
            {
                return Content(null);
            }
 
            return Content(this.ReturnJson.ToString());
        }
    }
}