bklLiudl
2024-07-23 675b8bcc4a3630d95e3d0b97d933e63442075ecb
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
using BLL.DAL;
using Common;
using Json;
using Lib;
using Model;
using Model.WcsModel;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using System;
using System.Collections;
 
namespace wms.Areas.BaseInfo.Controllers
{
    public class PlcPosController : MasterPage
    {
        // GET: BaseInfo/PlcPos
        [LoginFilter]
        public ActionResult Index()
        {
            ViewBag.Title = "工位维护";
            return View();
        }
 
        /// <summary>
        /// 新增编辑工位对应的流程字
        /// </summary>
        /// <returns></returns>
        [LoginFilter]
        public ActionResult AddEditPlcPos() 
        {
            try
            {
                string id = Request.QueryString.Get("Id");
                DAL_PlcPos provider = new DAL_PlcPos();
 
                if (id != null)
                {
                    var model = provider.GetPlcPos(id);
                    ViewBag.StationNum = model.StationNum;
                    ViewBag.Name = model.Name;
                    ViewBag.PlcPos = model.PlcPos;
                    ViewBag.PosType = model.PosType;
                    ViewBag.LedIP = model.LedIP;
 
                    ViewBag.Type = provider.GetPlcPosHtml(model.PlcInfoId.ToString());
                }
                else
                {
                    ViewBag.Type = provider.GetPlcPosHtml();
                }
 
                return View();
            }
            catch (System.Exception)
            {
                return View();
            }
        }
    }
 
    public class PlcPosAjaxController : AjaxPage 
    {
        /// <summary>
        /// 获取工位对应的流程字表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetPlcPosList()
        {
            var dd = Request["ajaxdata"];
 
            var models = new JavaScriptSerializer().Deserialize<AjaxPlcPosList>(dd);
 
            if (models != null)
            {
                PageInfo pageInfo = new PageInfo() { PageIndex = models.pageIndex, PageSize = models.pageSize };
 
                DAL_PlcPos provider = new DAL_PlcPos();
                var entity = provider.GetPlcPosList(models, ref pageInfo);
 
                string json = JsonHelper.IListToJson<WCSPlcPos>(entity, "List");
                string pjson = ConvertJson.Serializer(pageInfo);
 
                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);
        }
 
        /// <summary>
        /// 新增编辑工位流程字
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult AddPlcPos() 
        {
            var dd = Request["ajaxdata"];
            var models = new JavaScriptSerializer().Deserialize<AjaxPlcPos>(dd);
            string Operation = models.Operation;
 
            if (models != null)
            {
 
                DAL_PlcPos provider = new DAL_PlcPos();
                if (Operation == "Add")
                {
                    models.CreateUser = this.LoginUser.ID;
                    string sqlWhere = " (PlcPos = '" + models.PlcPos + "') and isdel = '0' ";
                    if (provider.IsExist(sqlWhere))
                    {
                        bool value = provider.AddPlcPos(models);
 
                        if (value)
                        {
                            ReturnJson.AddProperty("Code", 1);
                            ReturnJson.AddProperty("Message", "新增工位流程字成功!");
                        }
                        else
                        {
                            ReturnJson.AddProperty("Code", -1);
                            ReturnJson.AddProperty("Message", "新增工位流程字失败!");
                        }
                    }
                    else
                    {
                        ReturnJson.AddProperty("Code", -1);
                        ReturnJson.AddProperty("Message", "该偏移量已存在!");
                    }
                }
                else if (Operation == "Edit")
                {
                    bool value = provider.AddPlcPos(models);
 
                    if (value)
                    {
                        ReturnJson.AddProperty("Code", 1);
                        ReturnJson.AddProperty("Message", "编辑工位流程字成功!");
                    }
                    else
                    {
                        ReturnJson.AddProperty("Code", -1);
                        ReturnJson.AddProperty("Message", "编辑工位流程字失败!");
                    }
                }
 
            }
            else
            {
                ReturnJson.AddProperty("Code", -1);
                ReturnJson.AddProperty("Message", "工位流程字信息有误!!!");
            }
            return Content(this.ReturnJson.ToString());
        }
 
        /// <summary>
        /// 删除工位流程字
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult DeletePlcPos()
        {
            string dd = Request["list"];
            ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd);
            string[] list = (string[])models.ToArray(typeof(string));
            if (models != null)
            {
                DAL_PlcPos provider = new DAL_PlcPos();
                bool value = provider.DeletePlcPos(list);
 
                if (value)
                {
                    ReturnJson.AddProperty("Code", 1);
                    ReturnJson.AddProperty("Message", "删除工位流程字成功");
                }
                else
                {
                    ReturnJson.AddProperty("Code", -1);
                    ReturnJson.AddProperty("Message", "删除工位流程字失败");
                }
 
                return Content(this.ReturnJson.ToString());
            }
            return Content(null);
        }
    }
}