1
zrg
2025-01-17 8f4af99e5ea3939e56148dc969158b35c0cb8470
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
 
namespace WebAPI.Controllers
{
    public class ReportPlatFormController : ApiController
    {
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
 
 
        #region 报工平台根据责任人筛选加载资源列表
        [Route("ReportPlatForm/SearchGetLineBindBillList")]
        [HttpGet]
        public object SearchGetLineBindBillList(string HUserName)
        {
            try
            {
                //根据选择资源ID获取当前生产工单、责任人
                ds = oCN.RunProcReturn("exec h_p_JIT_GetSourceInfoByUser " + HUserName + "", "h_p_JIT_GetSourceInfoByUser");
                if (ds.Tables[0].Rows.Count > 0)
                {
 
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取资源绑定数据成功!";
                    objJsonResult.data = ds;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "暂无资源绑定!";
                    objJsonResult.data = ds;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
 
            }
            return objJsonResult;
        }
        #endregion
 
        #region 报工平台资源保存
        /// <summary>
        /// 报工平台资源保存
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [Route("ReportPlatForm/SaveGetLineBindBillList")]
        [HttpGet]
        public object SaveGetLineBindBillList(string HUserName, string HSourceID, string HSourceName, string HManagerID, string HManagerName, string HGroupID, string HGroupName, string HCreateDate, string HRemark)
        {
 
            try
            {
 
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log_second("IpadIndex_Edit", 1, false, HUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "新增产线失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
 
                ds = oCN.RunProcReturn("select * from Gy_SourceRelationSet where HSourceID='" + HSourceID + "' and HUserName='" + HUserName + "'", "Gy_SourceRelationSet");
              
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "当前人员创建此生产资源,不允许重复创建!";
                    objJsonResult.data = null;
                    
                }
                else
                {
                    oCN.BeginTran();
                    //写入产线绑定
                    string sql = string.Format(@"insert into Gy_SourceRelationSet (HSourceID,HUserName,HGroupID,HManagerID,HRemark,HCreateDate,HCreator,HNowFlag,HCheckManID) 
                                           values('" + HSourceID + "','" + HUserName + "','" + HGroupID + "','" + HManagerID + "','" + HRemark + "','" + DateTime.Parse(HCreateDate).ToShortDateString() + "','" + HUserName + "','0','')");
                    oCN.RunProc(sql);
                    oCN.Commit();
 
 
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    objJsonResult.data = null;
                }
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = null;
 
            }
            return objJsonResult;
        }
        #endregion
 
        #region  报工平台根据选中的资源ID带出工单列表信息,当前状态信息
        [Route("ReportPlatForm/SearchGetWorkBillList")]
        [HttpGet]
        public object SearchGetWorkBillList(string HSourceID)
        {
            try
            {
                oCN.BeginTran();
                //更新切换状态值
                string sql = string.Format(@"update Gy_SourceRelationSet set HNowFlag='1' where HSourceID='" + HSourceID + "'");
                string sql1 = string.Format(@"update Gy_SourceRelationSet set HNowFlag='0' where HSourceID<>'" + HSourceID + "'");
                oCN.RunProc(sql);
                oCN.RunProc(sql1);
                oCN.Commit();
 
                //根据选择资源ID获取当前生产工单、责任人
                ds = oCN.RunProcReturn("exec h_p_JIT_GetWorkBillListInfoBySource " + HSourceID + "", "h_p_JIT_GetWorkBillListInfoBySource");
                if (ds.Tables.Count > 0)
                {
 
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
                    objJsonResult.data = ds;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "此资源暂无工单列表数据!";
                    objJsonResult.data = ds;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
 
            }
            return objJsonResult;
        }
        #endregion
 
        #region 报工平台删除资源列表
        [Route("ReportPlatForm/DeleteGetLineBindBillList")]
        [HttpGet]
        public object DeleteGetLineBindBillList(string HSourceID,string user)
        {
            try
            {
 
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log_second("IpadIndex_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除产线失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
 
                oCN.BeginTran();
                //更新切换状态值
                string sql = string.Format(@"delete Gy_SourceRelationSet  where HSourceID='" + HSourceID + "' and HUserName = '" + user + "'");
                oCN.RunProc(sql);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除资源成功!";
                objJsonResult.data = ds;
                return objJsonResult;
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
 
            }
            return objJsonResult;
        }
        #endregion
 
        #region  通过系统参数控制,判断生产订单是否做了首件检验单和工序检验单
        [Route("ReportPlatForm/IsCheck")]
        [HttpGet]
        public object IsCheck(Int64 HICMOInterID,Int64 HICMOEntryID,string HICMOBillNo)
        {
            try
            {
                //获取系统参数
                string sErrMsg = "";
                string HBackRemark = "";
                if (oSystemParameter.ShowBill(ref sErrMsg) == true)
                {
                    if (oSystemParameter.omodel.Sc_ICMOReportBill_FirstCheckOut == "Y") //系统参数  是否做了首件检验单  空白为通用
                    {
                        ds = oCN.RunProcReturn("exec h_p_JIT_IsFirstCheckOut " + HICMOInterID + "," + HICMOEntryID + ",'" + HICMOBillNo + "'", "h_p_Sc_IsFirstCheckOut");
 
                        if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                        {
                            HBackRemark += ds.Tables[0].Rows[0]["HBackRemark"] + "    ";
                        }
                    }
                    if(oSystemParameter.omodel.Sc_ICMOReportBill_ProcessCheckOut == "Y") //系统参数  是否做了过程检验单  空白为通用
                    {
                        ds = oCN.RunProcReturn("exec h_p_JIT_IsProcessCheckOut " + HICMOInterID + "," + HICMOEntryID + ",'" + HICMOBillNo + "'", "h_p_Sc_IsProcessCheckOut");
 
                        if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                        {
                            HBackRemark += ds.Tables[0].Rows[0]["HBackRemark"];
                        }
                    }                    
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "获取系统参数失败! " + sErrMsg;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
 
                if (HBackRemark == "")
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "当前生产订单已维护首件检验单和过程检验单";
                    objJsonResult.data = null;
                    return objJsonResult;                    
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = HBackRemark;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
 
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = ex.Message;
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
 
        #region 报工平台按钮查询
        [Route("ReportPlatForm/getButtonlist")]
        [HttpGet]
        public object getButtonlist(string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
 
                ds = oCN.RunProcReturn("select * from h_v_Gy_UserButton where 用户名称='" + user+ "' order by 按钮排序", "h_v_Gy_UserButton");
 
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;            
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
 
        #region 报工平台按钮添加
        [Route("ReportPlatForm/AddButtonlist")]
        [HttpGet]
        public object AddButtonlist(string HUserName,string HButtonID, string HButtonName, string HButtonSize, string HButtonOrder)
        {
            try
            {             
 
                ds = oCN.RunProcReturn("select * from Gy_UserButtons where HButtonID='" + HButtonID + "' and HUserName='" + HUserName + "'", "Gy_UserButtons");
 
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "当前人员已创建改按钮,不允许重复创建!";
                    objJsonResult.data = null;
 
                }
                else
                {
                    oCN.BeginTran();
                    //写入按钮绑定
                    oCN.RunProc("insert into Gy_UserButtons(HUserName,HButtonID,HButtonName,HButtonSize,HButtonOrder)values('" + HUserName+"','"+HButtonID+ "','" + HButtonName + "','" + HButtonSize + "','" + HButtonOrder + "')");
                    oCN.Commit();
 
 
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    objJsonResult.data = null;
                }
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
 
        #region 报工平台按钮删除
        [Route("ReportPlatForm/DeleteButtonlist")]
        [HttpGet]
        public object DeleteButtonlist(int HItemID)
        {
            try
            {           
                oCN.BeginTran();
                oCN.RunProc("delete from Gy_UserButtons where HItemID ='" + HItemID + "'");
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除按钮成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
 
            }
            return objJsonResult;
        }
        #endregion
 
        #region 报工平台按钮基础资料查询
        [Route("ReportPlatForm/GetGy_BGButtons")]
        [HttpGet]
        public object GetGy_BGButtons(string sWhere)
        {
            try
            {
                List<object> columnNameList = new List<object>();
 
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select HItemID 按钮id,HNumber 按钮代码,HName 按钮名称 from Gy_BGButtons", "Gy_BGButtons");
                }
                else
                {
                    string sql1 = "select HItemID 按钮id,HNumber 按钮代码,HName 按钮名称 from Gy_BGButtons where 1 = 1 ";
                    string sql = sql1 + sWhere;
                    ds = oCN.RunProcReturn(sql, "Gy_BGButtons");
                }
 
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}