yl
2022-10-18 bc91272547462e667f12efb62fe1f058da227c61
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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
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;
using System.Web.Http;
using System.Web.Script.Serialization;
using VueWebApi.DLL.BLL;
using VueWebApi.Models;
using VueWebApi.Tools;
 
namespace VueWebApi.Controllers
{
 
    [RoutePrefix(prefix: "api/ProductModel")]
    [ControllerGroup("制造模型", "在线接口")]
    //[ChannelActionFilter]
    public class ProductModelController : ApiController
    {
        //定义全局信息返回变量
        ToMessage mes = new ToMessage();
        RedisHelper redis = new RedisHelper();
 
        #region[存货类型接口]
        /// <summary>
        /// 存货类型接口
        /// </summary>
        /// <returns></returns>
        [Route(template: "StockTypeSelect")]
        [HttpGet]
        public HttpResponseMessage StockTypeSelect()
        {
            try
            {
                mes = ProductModelBLL.StockTypeSelect();
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.Message = e.Message;
            }
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[物料类型查询]
        /// <summary>
        /// 物料类型查询
        /// </summary>
        /// <param name="materialtypecode">物料类型编码</param>
        /// <param name="materialtypename">物料类型名称</param>
        /// <param name="stocktypecode">存货类型编码</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "MaterialTypeSearch")]
        [HttpGet]
        public HttpResponseMessage MaterialTypeSearch(string materialtypecode = null, string materialtypename = null, string stocktypecode = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.MaterialTypeSearch(materialtypecode, materialtypename, stocktypecode, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[物料类型新增编辑]
        /// <summary>
        /// 物料类型新增编辑
        /// </summary>
        /// <param name="obj">提交数据对象</param>
        /// <returns></returns>
        [Route(template: "AddUpdateMaterialType")]
        [HttpPost]
        public HttpResponseMessage AddUpdateMaterialType([FromBody] JObject obj)
        {
            string materialtypeid = obj["id"].ToString();    //物料类型id(主键)
            string materialtypecode = obj["materialtypecode"].ToString(); //物料类型编码
            string materialtypename = obj["materialtypename"].ToString(); //物料类型名称
            string stocktypecode = obj["stocktypecode"].ToString(); //存货类型编码
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            string OperType = obj["OperType"].ToString();  //操作类型
            mes = ProductModelBLL.AddUpdateMaterialType(materialtypeid, materialtypecode, materialtypename, stocktypecode, username, OperType);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[物料类型删除]
        /// <summary>
        /// 物料类型删除
        /// </summary>
        /// <param name="materialtypecode">物料类型编码</param>
        /// <returns></returns>
        [Route(template: "DeleteMaterialType")]
        [HttpPost]
        public HttpResponseMessage DeleteMaterialType(string materialtypecode)
        {
            mes = ProductModelBLL.DeleteMaterialType(materialtypecode);
            return TJson.toJson(mes);
        }
        #endregion
 
 
 
 
 
        #region[单位列表查询]
        /// <summary>
        /// 单位列表查询
        /// </summary>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "UomSearch")]
        [HttpGet]
        public HttpResponseMessage UomSearch(int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.UomSearch(startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[单位新增]
        /// <summary>
        /// 单位新增
        /// </summary>
        /// <param name="json">单位提交数据</param>
        /// <returns></returns>
        [Route(template: "UomAdd")]
        [HttpPost]
        public HttpResponseMessage UomAdd(List<Uom> json)
        {
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            mes = ProductModelBLL.UomAdd(username, json);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[单位删除]
        /// <summary>
        /// 单位删除
        /// </summary>
        /// <param name="uomcode">单位编码</param>
        /// <returns></returns>
        [Route(template: "UomDelete")]
        [HttpPost]
        public HttpResponseMessage UomDelete(string uomcode)
        {
            mes = ProductModelBLL.UomDelete(uomcode);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[存货类型查找物料类型]
        /// <summary>
        /// 存货类型查找物料类型
        /// </summary>
        /// <param name="stocktypecode">存货类型编码</param>
        /// <returns></returns>
        [Route(template: "StockTypeSelectMaterialType")]
        [HttpGet]
        public HttpResponseMessage StockTypeSelectMaterialType(string stocktypecode)
        {
            try
            {
                mes = ProductModelBLL.StockTypeSelectMaterialType(stocktypecode);
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.Message = e.Message;
            }
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[单位下拉列表查询]
        /// <summary>
        /// 单位下拉列表查询
        /// </summary>
        /// <returns></returns>
        [Route(template: "UomSelect")]
        [HttpGet]
        public HttpResponseMessage UomSelect()
        {
            mes = ProductModelBLL.UomSelect();
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[存货档案查询]
        /// <summary>
        /// 存货档案查询
        /// </summary>
        /// <param name="partcode">物料编码</param>
        /// <param name="partname">物料名称</param>
        /// <param name="partspec">物料规格</param>
        /// <param name="stocktypecode">存货类型编码</param>
        /// <param name="materialtypecode">物料类型编码</param>
        /// <param name="storehousecode">所属仓库编码</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "InventoryFileSelect")]
        [HttpGet]
        public HttpResponseMessage InventoryFileSelect(string partcode = null, string partname = null, string partspec = null, string stocktypecode = null, string materialtypecode = null, string storehousecode = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.InventoryFileSelect(partcode, partname, partspec, stocktypecode, materialtypecode, storehousecode, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[存货档案新增编辑]
        /// <summary>
        /// 存货档案新增编辑
        /// </summary>
        /// <param name="obj">提交数据对象</param>
        /// <returns></returns>
        [Route(template: "AddUpdateInventoryFile")]
        [HttpPost]
        public HttpResponseMessage AddUpdateInventoryFile([FromBody] JObject obj)
        {
            string materialid = obj["id"].ToString();    //物料id(主键)
            string materialcode = obj["materialcode"].ToString(); //物料编码
            string materialname = obj["materialname"].ToString(); //物料名称
            string materialspec = obj["materialspec"].ToString(); //物料规格
            string uomcode = obj["uomcode"].ToString();           //单位编码
            string warehousecode = obj["warehousecode"].ToString(); //所属仓库编码
            string stocktypecode = obj["stocktypecode"].ToString(); //存货类型编码
            string materialtypecode = obj["materialtypecode"].ToString(); //物料类型编码
            string minstockqty = obj["minstockqty"].ToString(); //最小库存
            string maxstockqty = obj["maxstockqty"].ToString(); //最大库存
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            string OperType = obj["OperType"].ToString();  //操作类型
            mes = ProductModelBLL.AddUpdateInventoryFile(materialid, materialcode, materialname, materialspec, uomcode, warehousecode, stocktypecode, materialtypecode, minstockqty, maxstockqty, username, OperType);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[存货档案删除]
        /// <summary>
        /// 存货档案删除
        /// </summary>
        /// <param name="materialcode">物料编码</param>
        /// <returns></returns>
        [Route(template: "DeleteInventoryFile")]
        [HttpPost]
        public HttpResponseMessage DeleteInventoryFile(string materialcode)
        {
            mes = ProductModelBLL.DeleteInventoryFile(materialcode);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[存货档案关联工艺路线查询]
        /// <summary>
        /// 存货档案关联工艺路线查询
        /// </summary>
        /// <param name="partcode">物料编码</param>
        /// <returns></returns>
        [Route(template: "InventoryFileAssociationRoute")]
        [HttpGet]
        public HttpResponseMessage InventoryFileAssociationRoute(string partcode)
        {
            mes = ProductModelBLL.InventoryFileAssociationRoute(partcode);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[存货档案关联工艺路线提交]
        /// <summary>
        /// 存货档案关联工艺路线提交
        /// </summary>
        /// <param name="partcode">物料编码</param>
        /// <param name="defaultroute_code">默认工艺路线编码</param>
        /// <param name="json">提交数据对象</param>
        /// <returns></returns>
        [Route(template: "SaveInventoryFile")]
        [HttpPost]
        public HttpResponseMessage SaveInventoryFile(string partcode, List<ObjectData> json, string defaultroute_code = null)
        {
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            mes = ProductModelBLL.SaveInventoryFile(partcode, defaultroute_code, username, json);
            return TJson.toJson(mes);
        }
        #endregion
 
 
 
        #region[物料清单主列表查询]
        /// <summary>
        /// 物料清单主列表查询
        /// </summary>
        /// <param name="parentpartcode">母件编码</param>
        /// <param name="parentpartname">母件名称</param>
        /// <param name="parentpartspec">母件规格</param>
        /// <param name="status">启用状态</param>
        /// <param name="version">版本号</param>
        /// <param name="createusername">创建人员</param>
        /// <param name="createdate">创建日期</param>
        /// <param name="page">页码</param>
        /// <param name="rows">分页条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规格</param>
        /// <returns></returns>
        [Route(template: "BoIventorySelect")]
        [HttpGet]
        public HttpResponseMessage BoIventorySelect(string parentpartcode = null, string parentpartname = null,string parentpartspec=null,string parttype=null, string status = null, string version = null, string createusername = null, string createdate = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            string createopendate = "";  //开始时间
            string createclosedate = "";    //结束时间
            if (createdate != "" && createdate != null)
            {
                createopendate = createdate.Split('~')[0].ToString();
                createclosedate = createdate.Split('~')[1].ToString();
            }
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.BoIventorySelect(parentpartcode, parentpartname, parentpartspec, parttype, status, version, createusername, createopendate, createclosedate, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[物料清单编辑显示及预览]
        /// <summary>
        /// 物料清单编辑显示及预览
        /// </summary>
        /// <param name="bomid">Bom主表id</param>
        /// <returns></returns>
        [Route(template: "BoIventorySelectView")]
        [HttpGet]
        public HttpResponseMessage BoIventorySelectView(string bomid)
        {
            mes = ProductModelBLL.BoIventorySelectView(bomid);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[物料清单新增时获取最大版本号]
        /// <summary>
        /// 物料清单新增时获取最大版本号
        /// </summary>
        /// <param name="parentpartcode">母件编码</param>
        /// <returns></returns>
        [Route(template: "MaterielDetailedVsion")]
        [HttpGet]
        public HttpResponseMessage MaterielDetailedVsion(string parentpartcode)
        {
            mes = ProductModelBLL.MaterielDetailedVsion(parentpartcode);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[物料清单新增/编辑提交]
        /// <summary>
        /// 物料清单新增/编辑提交
        /// </summary>
        /// <param name="obj">提交数据</param>
        /// <returns></returns>
        [Route(template: "AddUpdateBoIventory")]
        [HttpPost]
        public HttpResponseMessage AddUpdateBoIventory([FromBody] JObject obj)
        {
            string bomid = obj["bomid"].ToString(); //母件id
            string parentpartcode = obj["parentpartcode"].ToString(); //母件编码
            string parentpartname = obj["parentpartname"].ToString(); //母件名称
            string parentpartspec = obj["parentpartspec"].ToString(); //母件规格
            string status = obj["status"].ToString();//启用状态
            string uomcode = obj["uomcode"].ToString(); //计量单位编码
            string quantity = obj["quantity"].ToString(); //基础数量
            string startdate = obj["startdate"].ToString(); //启用日期
            string version = obj["version"].ToString(); //版本号
            string worklist = obj["worklist"].ToString(); //提交数据
            string opertype = obj["opertype"].ToString(); //提交类型
            string username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            List<BomSub> objs = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BomSub>>(worklist);
            mes = ProductModelBLL.AddUpdateBoIventory(bomid,parentpartcode, parentpartname, parentpartspec, status, uomcode, quantity, startdate, version, username, opertype, objs);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[物料清单删除]
        /// <summary>
        /// 物料清单删除
        /// </summary>
        /// <param name="bomid">Bom主表id</param>
        /// <returns></returns>
        [Route(template: "DeleteBoIventory")]
        [HttpPost]
        public HttpResponseMessage DeleteBoIventory(string bomid)
        {
            mes = ProductModelBLL.DeleteBoIventory(bomid);
            return TJson.toJson(mes);
        }
        #endregion
 
 
 
 
        #region[工序下拉查询接口]
        /// <summary>
        /// 工序下拉查询接口
        /// </summary>
        /// <returns></returns>
        [Route(template: "StepSelect")]
        [HttpGet]
        public HttpResponseMessage StepSelect()
        {
            mes = ProductModelBLL.StepSelect();
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[工艺路线查询]
        /// <summary>
        /// 工艺路线查询
        /// </summary>
        /// <param name="routecode">工艺路线编码</param>
        /// <param name="routename">工艺路线名称</param>
        /// <param name="description">工艺路线描述</param>
        /// <param name="createuser">创建人员</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "RouteSearch")]
        [HttpGet]
        public HttpResponseMessage RouteSearch(string routecode = null, string routename = null, string description = null, string createuser = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.RouteSearch(routecode, routename, description, createuser, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[工艺路线预览]
        /// <summary>
        /// 工艺路线预览
        /// </summary>
        /// <param name="routecode">工艺路线编码</param>
        /// <returns></returns>
        [Route(template: "ViewRoute")]
        [HttpGet]
        public HttpResponseMessage ViewRoute(string routecode)
        {
            mes = ProductModelBLL.ViewRoute(routecode);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[工艺路线新增]
        /// <summary>
        /// 工艺路线新增
        /// </summary>
        /// <param name="id">工艺路线id</param>
        /// <param name="opertype">操作类型(新增)</param>
        /// <param name="json">提交数据</param>
        /// <returns></returns>
        [Route(template: "AddUpdateRoute")]
        [HttpPost]
        public HttpResponseMessage AddUpdateRoute(string opertype, RoutEdit json,string id=null)
        {
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            mes = ProductModelBLL.AddUpdateRoute(id, opertype, username, json);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[工艺路线删除]
        /// <summary>
        /// 工艺路线删除
        /// </summary>
        /// <param name="routecode">工艺路线编码</param>
        /// <returns></returns>
        [Route(template: "DeleteRoute")]
        [HttpPost]
        public HttpResponseMessage DeleteRoute(string routecode)
        {
            mes = ProductModelBLL.DeleteRoute(routecode);
            return TJson.toJson(mes);
        }
        #endregion
 
 
 
        #region[工序查询]
        /// <summary>
        /// 工序查询
        /// </summary>
        /// <param name="stepcode">工序编码</param>
        /// <param name="stepname">工序名称</param>
        /// <param name="enable">启用状态</param>
        /// <param name="steptypecode">工序类型编码</param>
        /// <param name="createuser">创建人员</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "StepSearch")]
        [HttpGet]
        public HttpResponseMessage StepSearch(string stepcode = null, string stepname = null, string enable = null, string steptypecode = null, string createuser = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.StepSearch(stepcode, stepname, enable, steptypecode, createuser, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[工序新增编辑]
        /// <summary>
        /// 工序新增编辑
        /// </summary>
        /// <param name="obj">提交数据对象</param>
        /// <returns></returns>
        [Route(template: "AddUpdateStep")]
        [HttpPost]
        public HttpResponseMessage AddUpdateStep([FromBody] JObject obj)
        {
            string stepid = obj["id"].ToString();    //工序id(主键)
            string stepcode = obj["stepcode"].ToString(); //工序编码
            string stepname = obj["stepname"].ToString(); //工序名称
            string steptypecode = obj["steptypecode"].ToString(); //工序类型编码
            string enable = obj["enable"].ToString();           //启用状态
            string description = obj["description"].ToString(); //工序描述
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            string OperType = obj["OperType"].ToString();  //操作类型
            mes = ProductModelBLL.AddUpdateStep(stepid, stepcode, stepname, steptypecode, enable, description, username, OperType);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[工序删除]
        /// <summary>
        /// 工序删除
        /// </summary>
        /// <param name="stepcode">工序编码</param>
        /// <returns></returns>
        [Route(template: "DeleteStep")]
        [HttpPost]
        public HttpResponseMessage DeleteStep(string stepcode)
        {
            mes = ProductModelBLL.DeleteStep(stepcode);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[工序定义关联工作站查询]
        /// <summary>
        /// 工序定义关联工作站查询
        /// </summary>
        /// <param name="stepcode">工序编码</param>
        /// <returns></returns>
        [Route(template: "StepAssociationEqp")]
        [HttpGet]
        public HttpResponseMessage StepAssociationEqp(string stepcode)
        {
            mes = ProductModelBLL.StepAssociationEqp(stepcode);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region [工序定义关联工作站提交]
        /// <summary>
        /// 工序定义关联工作站提交
        /// </summary>
        /// <param name="stepcode">工序编码</param>
        /// <param name="json">提交数据</param>
        /// <returns></returns>
        [Route(template: "SaveStepAssociationEqp")]
        [HttpPost]
        public HttpResponseMessage SaveStepAssociationEqp(string stepcode, List<ObjectData> json)
        {
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            mes = ProductModelBLL.SaveStepAssociationEqp(stepcode, username, json);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[工序关联缺陷查询]
        /// <summary>
        /// 工序关联缺陷查询
        /// </summary>
        /// <param name="stepcode">工序编码</param>
        /// <returns></returns>
        [Route(template: "StepAssociationDefect")]
        [HttpGet]
        public HttpResponseMessage StepAssociationDefect(string stepcode)
        {
            mes = ProductModelBLL.StepAssociationDefect(stepcode);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[工序关联缺陷提交]
        /// <summary>
        /// 工序关联缺陷提交
        /// </summary>
        /// <param name="stepcode">工序编码</param>
        /// <param name="json">提交数据</param>
        /// <returns></returns>
        [Route(template: "SaveStepAssociationDefect")]
        [HttpPost]
        public HttpResponseMessage SaveStepAssociationDefect(string stepcode, List<ObjectData> json)
        {
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            mes = ProductModelBLL.SaveStepAssociationDefect(stepcode, username, json);
            return TJson.toJson(mes);
        }
        #endregion
 
 
 
        #region[产品信息下拉框查询]
        /// <summary>
        /// 产品信息下拉框查询
        /// </summary>
        /// <returns></returns>
        [Route(template: "PartSelect")]
        [HttpGet]
        public HttpResponseMessage PartSelect()
        {
            try
            {
                mes = ProductModelBLL.PartSelect();
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.Message = e.Message;
            }
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[产品编码查找工艺路线下拉框]
        /// <summary>
        /// 产品编码查找工艺路线下拉框
        /// </summary>
        /// <param name="partcode">产品编码</param>
        /// <returns></returns>
        [Route(template: "PartSelectRpute")]
        [HttpGet]
        public HttpResponseMessage PartSelectRpute(string partcode)
        {
            try
            {
                mes = ProductModelBLL.PartSelectRpute(partcode);
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.Message = e.Message;
            }
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[根据工艺路线编码查找关联工序集合]
        /// <summary>
        /// 根据工艺路线编码查找关联工序集合
        /// </summary>
        /// <param name="routecode">工艺路线编码</param>
        /// <returns></returns>
        [Route(template: "RouteSelectStep")]
        [HttpGet]
        public HttpResponseMessage RouteSelectStep(string routecode)
        {
            try
            {
                mes = ProductModelBLL.RouteSelectStep(routecode);
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.Message = e.Message;
            }
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[根据工序线编码查找关联设备下拉框集合]
        /// <summary>
        /// 根据工序线编码查找关联设备下拉框集合
        /// </summary>
        /// <param name="stepcode">工序编码</param>
        /// <returns></returns>
        [Route(template: "StepSelectEqp")]
        [HttpGet]
        public HttpResponseMessage StepSelectEqp(string stepcode)
        {
            mes = ProductModelBLL.StepSelectEqp(stepcode);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[根据工序线编码查找关联设备列表集合]
        /// <summary>
        /// 根据工序线编码查找关联设备列表集合
        /// </summary>
        /// <param name="partcode">产品编码</param>
        ///  <param name="routecode">工艺路线编码</param>
        /// <param name="stepcode">工序编码</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "StepSelectEqpList")]
        [HttpGet]
        public HttpResponseMessage StepSelectEqpList(string partcode, string routecode, string stepcode, int page = 0, int rows = 0, string prop = null, string order = null)
        {
 
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.StepSelectEqpList(partcode, routecode, stepcode, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[节拍工价查询]
        /// <summary>
        /// 节拍工价查询
        /// </summary>
        /// <param name="partcode">产品编码</param>
        /// <param name="routecode">工艺路线编码</param>
        /// <param name="stepcode">工序编码</param>
        /// <param name="eqpcode">设备编码</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "BeatRateSearch")]
        [HttpGet]
        public HttpResponseMessage BeatRateSearch(string partcode = null, string routecode = null, string stepcode = null, string eqpcode = null,int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = ProductModelBLL.BeatRateSearch(partcode,routecode, stepcode, eqpcode, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[节拍工价提交]
        /// <summary>
        /// 节拍工价提交
        /// </summary>
        /// <param name="obj">提交数据</param>
        /// <returns></returns>
        [Route(template: "SaveBeatRate")]
        [HttpPost]
        public HttpResponseMessage SaveBeatRate([FromBody] JObject obj)
        {
            string partcode = obj["partcode"].ToString(); //产品编码
            string routecode = obj["routecode"].ToString(); //工艺路线编码
            string stepcode = obj["stepcode"].ToString(); //工序编码
            string eqpcode = obj["eqpcode"].ToString(); //设备编码
            string wkshopcode = obj["wkshopcode"].ToString(); //生产车间编码
            string eqp_value = obj["eqp_value"].ToString(); //设备节拍
            string stand_value = obj["stand_value"].ToString(); //生产节拍
            string cavity_qty = obj["cavity_qty"].ToString(); //型腔数
            string unprice = obj["unprice"].ToString(); //计件单价
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            mes = ProductModelBLL.SaveBeatRate(partcode, routecode, stepcode, eqpcode, wkshopcode, eqp_value, stand_value, cavity_qty, unprice, username);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[节拍工价删除]
        /// <summary>
        /// 节拍工价删除
        /// </summary>
        /// <param name="partcode">产品编码</param>
        /// <param name="routecode">工艺路线编码</param>
        /// <param name="stepcode">工序编码</param>
        /// <param name="eqpcode">设备编码</param>
        /// <returns></returns>
        [Route(template: "DeleteBeatRate")]
        [HttpPost]
        public HttpResponseMessage DeleteBeatRate(string partcode,string routecode,string stepcode,string eqpcode)
        {
            mes = ProductModelBLL.DeleteBeatRate(partcode, routecode, stepcode, eqpcode);
            return TJson.toJson(mes);
        }
        #endregion
 
    }
}