分支自 SuZhouGuanHong/TaiYuanTaiZhong

huanghongfeng
2024-07-08 32678f5c24c7681a198b517fa72db1de2e98646d
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
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml.Drawing.Chart;
using System;
using System.Collections.Generic;
using System.Linq;
using WIDESEA_Comm;
using WIDESEA_Comm.PLCDBItem;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.Extensions;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
using WIDESEA_WCS.IRepositories;
using WIDESEA_WCS.Repositories;
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
 
namespace WIDESEA_WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ReadplcController : Controller
    {
        #region PCS平面图
        public class SectionData    //静态参数
        {
            public int r_direction { get; set; }
            public bool r_machine_nr { get; set; }
            public int r_part_process { get; set; }
            public int r_part_status { get; set; }
            public string r_wheel_SN { get; set; }
            public int r_wheel_type { get; set; }
            public string stackerNo { get; set; }
            public string Name { get; set; }
            public int vk_state { get; set; }
        }
 
        #region 辊道1
        [HttpPost("One_unit_plc")]
        public IActionResult One_unit_plc()
        {
            var DBIems = WheelDBItem.VK4WheelDBItem; //获取辊道,输送线信息
            var DBIems2 = VKDBItem.VK4DBItem;       //VK4状态信息对象集合
 
            var DBIems3 = Oiling_machine.Oiling_machineDBItem;
 
            if (DBIems.Count == 0)
            {
                List<SectionData> DBIemss = new List<SectionData>();
                for (int i = 0; i < 32; i++)
                {
                    var seDataList = new SectionData
                    {
                        r_direction = 0,
                        r_machine_nr = false,
                        r_part_process = 1,
                        r_part_status = 0,
                        r_wheel_SN = "",
                        r_wheel_type = 3,
                        stackerNo = "4." + i.ToString(),
                    };
                    switch (i)
                    {
                        case 27:
                            seDataList.stackerNo = "机械手1";
                            break;
                        case 28:
                            seDataList.stackerNo = "10.11";
                            break;
                        case 29:
                            seDataList.stackerNo = "10.12";
                            break;
                        case 30:
                            seDataList.stackerNo = "10.5";
                            break;
                        case 31:
                            seDataList.stackerNo = "10.6";
                            break;
                        default:
                            break;
                    }
                    DBIemss.Add(seDataList);
                }
 
 
 
                List<WheelDBItem> convertedList = DBIemss.Select(sd => new WheelDBItem
                {
                    StackerNo = sd.stackerNo,
                }).ToList();
 
                DBIems = convertedList;
            }
 
 
            var Section_one = DBIems.Where(x => IsInRange(x.StackerNo, 4, 13, 4, 24)).ToList();
            var Section_two = DBIems.Where(x => IsInRange(x.StackerNo, 4, 11, 4, 12)).ToList();
            var Section_three = DBIems.Where(x => IsInRange(x.StackerNo, 4, 9, 4, 10)).OrderByDescending(x=>x.StackerNo).ToList();
            var Section_four = DBIems.Where(x => IsInRange(x.StackerNo, 4, 1, 4, 8)).ToList();
            var Section_six = DBIems.Where(x => IsInRange(x.StackerNo, 10, 1, 10, 2)).ToList();   //10.1-10.2
            var Section_seven = DBIems.Where(x => IsInRange(x.StackerNo, 10, 3, 10, 4)).ToList(); //10.3-10.4
            var Section_eight = DBIems.Where(x => IsInRange(x.StackerNo, 10, 7, 10, 8)).ToList();     //10.7-10.8
            var Section_nine = DBIems.Where(x => IsInRange(x.StackerNo, 10, 9, 10, 10)).OrderByDescending(x => x.StackerNo).ToList();      //10.9-10.10
 
 
 
 
            #region
            var Section_five = DBIems
                .Where(x => IsInRange(x.StackerNo, 10, 5, 10, 6) || IsInRange(x.StackerNo, 10, 11, 10, 12))
                .Select(x => CreateSectionFiveItem(x))
                .ToList();
            #endregion
 
            //老机械手
            var Section_ten = DBIems.Where(x => x.StackerNo == "机械手1")
                .Select(x => CreateSectionFiveItem4(x, 1))
                .ToList();
 
 
 
            //新机械手(下料口位)
            var Section_twelve = DBIems.Where(x => x.StackerNo == "机械手1")
                .Select(x => new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                })
                .ToList();
 
 
            List<SectionData> sectDataList7 = new List<SectionData>();
            var seDataList7 = new SectionData
            {
                r_direction = 0,
                r_machine_nr = false,
                r_part_process = 1,         //读取车轮零件工艺
                r_part_status = 0,          //读取车轮零件状态
                r_wheel_SN = "2222",
                r_wheel_type = 3,       //读取车轮类型
                stackerNo = "10.12",
 
            };
            sectDataList7.Add(seDataList7);
 
            var Section_eleven = sectDataList7.ToList();
 
            var Section_thirteen = DBIems.Where(x => x.StackerNo == "4.11").ToList();   //视觉检测台
            var Section_fourteen = DBIems.Where(x => x.StackerNo == "4.12").ToList();   //视觉检测台
 
 
            var Section_fifteen = DBIems2.ToList();
            if (DBIems2.Count == 0)
            {
                List<SectionData> sectDataList1 = new List<SectionData>();
                var seDataList1 = new SectionData
                {
                    Name = "VK4",
                    vk_state = 0,
 
                };
                sectDataList1.Add(seDataList1);
                List<VKDBItem> convertedList = sectDataList1.Select(sd => new VKDBItem
                {
                    Name = sd.Name,
                }).ToList();
                Section_fifteen = convertedList;
            }
 
            var data = new
            {
                Section_one,
                Section_two,
                Section_three,
                Section_four,
                Section_five,
                Section_six,
                Section_seven,
                Section_eight,
                Section_nine,
                Section_ten,   //老机械手
                Section_eleven,   //涂油机
                Section_twelve,     //新机械手
                Section_thirteen,  //最左边
                Section_fourteen,  //第二个靠涂油机
                Section_fifteen     //VK4信息
 
            };
 
            return Ok(data);
        }
 
        private object CreateSectionFiveItem(WheelDBItem x)   //车床数据
        {
            var stackerToMachineMap = new Dictionary<string, string>
        {
            { "10.5", "Machine1" },
            { "10.6", "Machine2" },
            { "10.11", "Machine3" },
            { "10.12", "Machine4" }
        };
            var machineDataLookup = MachineDBItem.VK4MachineDBItem.Where(x => x.Name == "Machine1" || x.Name == "Machine2" || x.Name == "Machine3" || x.Name == "Machine4").ToDictionary(x => x.Name, x => x);       //VK4机床对象集合
            if (stackerToMachineMap.TryGetValue(x.StackerNo, out var machineName) && machineDataLookup.TryGetValue(machineName, out var machineData))
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    c_machine_state = machineData.machine_state,
 
                };
            }
            else
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    c_machine_state = 0,
                };
            }
        }
 
 
 
        [HttpGet("Four_unit_plc")]
        public IActionResult Four_unit_plc(string staname)
        {
            var data = MachineDBItem.VK4MachineDBItem.Where(x => x.Name == staname).ToList();
 
            return Ok(data);
        }
        #endregion
 
        #region 共用方法(辊道1-2)
        private object CreateSectionFiveItem4(WheelDBItem x, int k) //机械手数据
        {
            var DBIems3 = GantryDBItem.VK4GantryDBItem.Where(x => x.Name == "Gantry1").FirstOrDefault();
            if (k == 2)
            {
                DBIems3 = GantryDBItem.VK4GantryDBItem.Where(x => x.Name == "Gantry2").FirstOrDefault();
            }
            if (DBIems3 == null)
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    g_name = false,
                    g_communication_IO = false,
                    g_drive_fault = false,
                    g_emergency_stop_portal = false,
                    g_gantry_state = false,
                    g_portal_fault = false,
                    g_power_on = false,
                    g_programm_running = false,
                    g_ready_for_auto_start = false,
                    g_ready_for_operate = false,
                    g_state_AUTO = false,
                    g_state_JOG = false,
                    g_state_MDA = false,
 
                };
            }
            else
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    g_name = DBIems3.Name,
                    g_communication_IO = DBIems3.communication_IO,
                    g_drive_fault = DBIems3.drive_fault,
                    g_emergency_stop_portal = DBIems3.emergency_stop_portal,
                    g_gantry_state = DBIems3.gantry_state,
                    g_portal_fault = DBIems3.portal_fault,
                    g_power_on = DBIems3.power_on,
                    g_programm_running = DBIems3.programm_running,
                    g_ready_for_auto_start = DBIems3.ready_for_auto_start,
                    g_ready_for_operate = DBIems3.ready_for_operate,
                    g_state_AUTO = DBIems3.state_AUTO,
                    g_state_JOG = DBIems3.state_JOG,
                    g_state_MDA = DBIems3.state_MDA,
 
                };
            }
        }
        #endregion
 
 
        #region 辊道2
        [HttpPost("Two_unit_plc")]
        public IActionResult Two_unit_plc()
        {
            var DBIems = WheelDBItem.VK4WheelDBItem;
            var DBIems3 = GantryDBItem.VK4GantryDBItem.Where(x => x.Name == "Gantry2").FirstOrDefault();
            if (DBIems.Count == 0)
            {
                List<SectionData> DBIemss = new List<SectionData>();
                for (int i = 0; i < 32; i++)
                {
                    var seDataList = new SectionData
                    {
                        r_direction = 0,
                        r_machine_nr = false,
                        r_part_process = 1,
                        r_part_status = 0,
                        r_wheel_SN = "",
                        r_wheel_type = 3,
                        stackerNo = "5." + i.ToString(),
                    };
                    switch (i)
                    {
                        case 27:
                            seDataList.stackerNo = "机械手2";
                            break;
                        case 28:
                            seDataList.stackerNo = "20.11";
                            break;
                        case 29:
                            seDataList.stackerNo = "20.12";
                            break;
                        case 30:
                            seDataList.stackerNo = "20.5";
                            break;
                        case 31:
                            seDataList.stackerNo = "20.6";
                            break;
                        default:
                            break;
                    }
                    DBIemss.Add(seDataList);
                }
 
 
 
                List<WheelDBItem> convertedList = DBIemss.Select(sd => new WheelDBItem
                {
                    StackerNo = sd.stackerNo,
                }).ToList();
 
                DBIems = convertedList;
            }
 
 
            List<SectionData> DataList2 = new List<SectionData>();
            var Section_one = DBIems.Where(x => IsInRange(x.StackerNo, 5, 13, 5, 24)).ToList();
            var Section_two = DBIems.Where(x => IsInRange(x.StackerNo, 5, 11, 5, 12)).ToList();
            var Section_three = DBIems.Where(x => IsInRange(x.StackerNo, 5, 9, 5, 10)).OrderByDescending(x => x.StackerNo).ToList();
            var Section_four = DBIems.Where(x => IsInRange(x.StackerNo, 5, 1, 5, 8)).ToList();
 
 
            #region
 
            //var Section_five = DBIems.Where(x => IsInRange(x.StackerNo, 20, 5, 20, 6) || IsInRange(x.StackerNo, 20, 11, 20, 12)).ToList();       //车间
 
            var Section_five = DBIems
                .Where(x => IsInRange(x.StackerNo, 20, 5, 20, 6) || IsInRange(x.StackerNo, 20, 11, 20, 12))
                .Select(x => CreateSectionFiveItem2(x))
                .ToList();
            #endregion
 
 
            var Section_six = DBIems.Where(x => IsInRange(x.StackerNo, 20, 1, 20, 2)).ToList();   //10.1-10.2
            var Section_seven = DBIems.Where(x => IsInRange(x.StackerNo, 20, 3, 20, 4)).ToList(); //10.3-10.4
            var Section_eight = DBIems.Where(x => IsInRange(x.StackerNo, 20, 7, 20, 8)).ToList();     //10.7-10.8
            var Section_nine = DBIems.Where(x => IsInRange(x.StackerNo, 20, 9, 20, 10)).OrderByDescending(x => x.StackerNo).ToList();      //10.9-10.10
 
            //老机械手(机床位)
            var Section_ten = DBIems.Where(x => x.StackerNo == "机械手2")
               .Select(x => CreateSectionFiveItem4(x, 2))
                .ToList();
 
 
            var Section_twelve = DBIems.Where(x => x.StackerNo == "机械手2").ToList();      //新机械手(下料口位)
 
 
            List<SectionData> sectDataList7 = new List<SectionData>();
            var seDataList7 = new SectionData
            {
                r_direction = 0,
                r_machine_nr = false,
                r_part_process = 1,         //读取车轮零件工艺
                r_part_status = 0,          //读取车轮零件状态
                r_wheel_SN = "2222",
                r_wheel_type = 3,       //读取车轮类型
                stackerNo = "20.12",
 
            };
            sectDataList7.Add(seDataList7);
 
            var Section_eleven = sectDataList7.ToList();        //涂油机
 
            var Section_thirteen = DBIems.Where(x => x.StackerNo == "5.11").ToList();   //视觉检测台
            var Section_fourteen = DBIems.Where(x => x.StackerNo == "5.12").ToList();   //视觉检测台
 
            var data = new
            {
                Section_one,
                Section_two,
                Section_three,
                Section_four,
                Section_five,
                Section_six,
                Section_seven,
                Section_eight,
                Section_nine,
                Section_ten,
                Section_eleven,
                Section_twelve,
                Section_thirteen,
                Section_fourteen
 
            };
 
            return Ok(data);
        }
 
        private object CreateSectionFiveItem2(WheelDBItem x)
        {
            var stackerToMachineMap = new Dictionary<string, string>
        {
            { "20.5", "Machine5" },
            { "20.6", "Machine6" },
            { "20.11", "Machine7" },
            { "20.12", "Machine8" }
        };
            var machineDataLookup = MachineDBItem.VK4MachineDBItem.Where(x => x.Name == "Machine5" || x.Name == "Machine6" || x.Name == "Machine7" || x.Name == "Machine8").ToDictionary(x => x.Name, x => x);       //VK4机床对象集合
            if (stackerToMachineMap.TryGetValue(x.StackerNo, out var machineName) && machineDataLookup.TryGetValue(machineName, out var machineData))
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    c_machine_state = machineData.machine_state,
 
                };
            }
            else
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    c_machine_state = 0,
 
                };
            }
        }
 
        [HttpGet("Four_unit_plc2")]
        public IActionResult Four_unit_plc2(string staname)
        {
            var data = MachineDBItem.VK4MachineDBItem.Where(x => x.Name == staname).ToList();
 
            return Ok(data);
        }
        #endregion
 
 
 
        #region 辊道3
        [HttpPost("Three_unit_plc")]
        public IActionResult Three_unit_plc()
        {
 
            var DBIems = WheelDBItem.VK5WheelDBItem;
            var DBIems2 = VKDBItem.VK5DBItem;       //VK4状态信息对象集合
 
 
            if (DBIems.Count == 0)
            {
                List<SectionData> DBIemss = new List<SectionData>();
                for (int i = 0; i < 36; i++)
                {
                    var seDataList = new SectionData
                    {
                        r_direction = 0,
                        r_machine_nr = false,
                        r_part_process = 0,
                        r_part_status = 0,
                        r_wheel_SN = "",
                        r_wheel_type = 0,
                        stackerNo = "6." + i.ToString(),
                    };
                    switch (i)
                    {
                        case 25:
                            seDataList.stackerNo = "7.21";
                            break;
                        case 26:
                            seDataList.stackerNo = "30.9";
                            break;
                        case 27:
                            seDataList.stackerNo = "30.10";
                            break;
                        case 28:
                            seDataList.stackerNo = "30.4";
                            break;
                        case 29:
                            seDataList.stackerNo = "30.5";
                            break;
                        case 30:
                            seDataList.stackerNo = "机械手3";
                            break;
                        case 31:
                            seDataList.stackerNo = "7.26";
                            break;
                        case 32:
                            seDataList.stackerNo = "7.27";
                            break;
                        case 33:
                            seDataList.stackerNo = "7.28";
                            break;
                        case 34:
                            seDataList.stackerNo = "7.29";
                            break;
                        case 35:
                            seDataList.stackerNo = "7.30";
                            break;
                        default:
                            break;
                    }
                    DBIemss.Add(seDataList);
                }
 
 
 
                List<WheelDBItem> convertedList = DBIemss.Select(sd => new WheelDBItem
                {
                    StackerNo = sd.stackerNo,
                }).ToList();
 
                DBIems = convertedList;
            }
 
            var Section_one = DBIems.Where(x => IsInRange(x.StackerNo, 6, 13, 6, 20) || x.StackerNo == "6.24" || x.StackerNo == "7.21").ToList();
 
            var Section_fourteen= DBIems.Where(x => IsInRange(x.StackerNo, 7, 26, 7, 27)).ToList(); //上料口
            var Section_sixteen = DBIems.Where(x => IsInRange(x.StackerNo, 7, 28, 7, 30)).ToList(); //上料口
 
            var Section_two = DBIems.Where(x => IsInRange(x.StackerNo, 6, 11, 6, 12)).ToList();
            var Section_three = DBIems.Where(x => IsInRange(x.StackerNo, 6, 9, 6, 10)).OrderByDescending(x => x.StackerNo).ToList();
            var Section_four = DBIems.Where(x => IsInRange(x.StackerNo, 6, 1, 6, 8)).ToList();
            var Section_thirteen = DBIems.Where(x => IsInRange(x.StackerNo, 6, 21, 6, 23)).ToList();
 
            //车间
            #region
 
            //var Section_five = DBIems.Where(x => IsInRange(x.StackerNo, 30, 4, 30, 5) || IsInRange(x.StackerNo, 30, 9, 30, 10)).ToList();       //车间
 
            var Section_five = DBIems
                .Where(x => IsInRange(x.StackerNo, 30, 4, 30, 5) || IsInRange(x.StackerNo, 30, 9, 30, 10))
                .Select(x => CreateSectionFiveItem3(x))
                .ToList();
            #endregion
 
 
            var Section_six = DBIems.Where(x => x.StackerNo == "30.1").ToList();   //30.7
            var Section_seven = DBIems.Where(x => IsInRange(x.StackerNo, 30, 2, 30, 3)).ToList(); //30.2-30.3
            var Section_eight = DBIems.Where(x => x.StackerNo == "30.6").ToList();     //30.6
            var Section_nine = DBIems.Where(x => IsInRange(x.StackerNo, 30, 7, 30, 8)).ToList();      //30.7-30.8
 
            //老机械手(机床位)
            var Section_ten = DBIems.Where(x => x.StackerNo == "机械手3")
               .Select(x => CreateSectionFiveItem4(x))
                .ToList();
            var Section_twelve = DBIems.Where(x => x.StackerNo == "机械手3").ToList();      //新机械手(下料口位)
 
 
            List<SectionData> sectDataList7 = new List<SectionData>();
            var seDataList7 = new SectionData
            {
                r_direction = 0,
                r_machine_nr = false,
                r_part_process = 1,         //读取车轮零件工艺
                r_part_status = 0,          //读取车轮零件状态
                r_wheel_SN = "",
                r_wheel_type = 3,       //读取车轮类型
                stackerNo = "30.12",
 
            };
            sectDataList7.Add(seDataList7);
 
            var Section_eleven = sectDataList7.ToList();  //涂油机
 
            var Section_fifteen = DBIems2.ToList();
            if (DBIems2.Count == 0)
            {
                List<SectionData> sectDataList1 = new List<SectionData>();
                var seDataList1 = new SectionData
                {
                    Name = "VK5",
                    vk_state = 0,
 
                };
                sectDataList1.Add(seDataList1);
                List<VKDBItem> convertedList = sectDataList1.Select(sd => new VKDBItem
                {
                    Name = sd.Name,
                }).ToList();
                Section_fifteen = convertedList;
            }
 
            var data = new
            {
                Section_one,
                Section_two,
                Section_three,
                Section_four,
                Section_five,
                Section_six,
                Section_seven,
                Section_eight,
                Section_nine,
                Section_ten,
                Section_eleven,
                Section_twelve,
                Section_thirteen,
                Section_fifteen,
                Section_fourteen,
                Section_sixteen
            };
 
            return Ok(data);
        }
 
        private object CreateSectionFiveItem3(WheelDBItem x)
        {
            var stackerToMachineMap = new Dictionary<string, string>
        {
            { "30.4", "Machine9" },
            { "30.5", "Machine10" },
            { "30.9", "Machine11" },
            { "30.10", "Machine12" }
        };
            var machineDataLookup = MachineDBItem.VK5MachineDBItem.Where(x => x.Name == "Machine9" || x.Name == "Machine10" || x.Name == "Machine11" || x.Name == "Machine12").ToDictionary(x => x.Name, x => x);       //VK4机床对象集合
            if (stackerToMachineMap.TryGetValue(x.StackerNo, out var machineName) && machineDataLookup.TryGetValue(machineName, out var machineData))
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    c_machine_state = machineData.machine_state,
 
                };
            }
            else
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    c_machine_state = 0
 
                };
            }
        }
        private object CreateSectionFiveItem4(WheelDBItem x) //机械手数据
        {
            var DBIems3 = GantryDBItem.VK5GantryDBItem.Where(x => x.Name == "Gantry3").FirstOrDefault();
            if (DBIems3 == null)
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    g_name = false,
                    g_communication_IO = false,
                    g_drive_fault = false,
                    g_emergency_stop_portal = false,
                    g_gantry_state = false,
                    g_portal_fault = false,
                    g_power_on = false,
                    g_programm_running = false,
                    g_ready_for_auto_start = false,
                    g_ready_for_operate = false,
                    g_state_AUTO = false,
                    g_state_JOG = false,
                    g_state_MDA = false,
 
                };
            }
            else
            {
                return new
                {
                    stackerNo = x.StackerNo,
                    r_wheel_SN = x.R_wheel_SN,
                    r_wheel_type = x.R_wheel_type,
                    r_part_status = x.R_part_status,
                    r_part_process = x.R_part_process,
                    g_name = DBIems3.Name,
                    g_communication_IO = DBIems3.communication_IO,
                    g_drive_fault = DBIems3.drive_fault,
                    g_emergency_stop_portal = DBIems3.emergency_stop_portal,
                    g_gantry_state = DBIems3.gantry_state,
                    g_portal_fault = DBIems3.portal_fault,
                    g_power_on = DBIems3.power_on,
                    g_programm_running = DBIems3.programm_running,
                    g_ready_for_auto_start = DBIems3.ready_for_auto_start,
                    g_ready_for_operate = DBIems3.ready_for_operate,
                    g_state_AUTO = DBIems3.state_AUTO,
                    g_state_JOG = DBIems3.state_JOG,
                    g_state_MDA = DBIems3.state_MDA,
 
                };
            }
        }
 
 
        [HttpGet("Four_unit_plc3")]
        public IActionResult Four_unit_plc3(string staname)
        {
            var data = MachineDBItem.VK5MachineDBItem.Where(x => x.Name == staname).ToList();
 
            return Ok(data);
        }
 
 
 
        #endregion
 
 
 
        // 辅助方法:检查给定的 stackerNo 是否在指定的范围内
        private bool IsInRange(string stackerNo, int startRow, int startColumn, int endRow, int endColumn)
        {
            string[] parts = stackerNo.Split('.');
            if (parts.Length != 2)
                return false;
 
            if (!int.TryParse(parts[0], out int row) || !int.TryParse(parts[1], out int column))
                return false;
 
            return row == startRow && column >= startColumn && row == endRow && column <= endColumn;
        }
        #endregion
 
 
        #region  第五板块(新增内容)
        /// <summary>
        /// 工单信息VV_Workinfo
        /// </summary>
        /// <returns></returns>
        [HttpPost("Workinfo_information")]
        public object Workinfo_information()
        {
            VOLContext volContext = new VOLContext();
            Idt_mes_headRepository db = new dt_mes_headRepository(volContext);
            Idt_mes_detailRepository dbs = new dt_mes_detailRepository(volContext);
            var data = db.Find(_ => true).Where(x => x.processCode == "28").OrderByDescending(x => x.CreateTime).Take(10).ToList();
            var dataList = data.Select(x => new
            {
                jobID = x.jobID,
                drawingNo = x.drawingNo,
                quantity = x.quantity,
                heatID = string.Join(", ", dbs.Find(d => d.jobID == x.jobID).Select(d => d.heatID).Distinct())
            }).ToList();
            return Ok(dataList);
        }
        #endregion
 
        #region pcs平面图库位信息
        [HttpPost("dt_stationinfolist")]
        public IActionResult dt_stationinfolist()
        {
            VOLContext volContext = new VOLContext();
            Idt_stationinfoRepository dsta = new dt_stationinfoRepository(volContext);
            string[] stationCodes = { "W", "A", "B", "C", "D01" };
            List<Tuple<List<dt_stationinfo>, int>> responseData = new List<Tuple<List<dt_stationinfo>, int>>();
            foreach (string code in stationCodes)
            {
                var data = dsta.Find(_ => true).Where(a => a.stationCode.Contains(code)).OrderBy(a => a.stationCode).ToList();
                int inst = dsta.Find(_ => true).Where(a => a.stationCode.Contains(code)).GroupBy(a => a.line).Count();
                responseData.Add(Tuple.Create(data, inst));
            }
            return Ok(responseData);
        }
        [HttpPost("pcs_dt_stationinfolist")]
        public IActionResult pcs_dt_stationinfolist()
        {
            VOLContext volContext = new VOLContext();
            Idt_stationinfoRepository dsta = new dt_stationinfoRepository(volContext);
            string[] stationCodes = { "X01", "X02", "X03", "S", "DD001" };
            List<Tuple<List<dt_stationinfo>>> responseData = new List<Tuple<List<dt_stationinfo>>>();
            foreach (string code in stationCodes)
            {
                var data = dsta.Find(_ => true).Where(a => a.stationCode.Contains(code)).OrderBy(a => a.stationCode).ToList();
                responseData.Add(Tuple.Create(data));
            }
            return Ok(responseData);
        }
        #endregion
 
 
       
    }
}