1
czw
2025-06-23 466b3b2579cb33cb12219f949952de5bfd6f65f2
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
using HH.WCS.QingXigongchang.wms;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace HH.WCS.QingXigongchang.util
{
    public class Settings
    {
        public static Dictionary<string, WorkOrder> OrderCaches = new Dictionary<string, WorkOrder>();
 
        static object lockTPnum = new object();
        /// <summary>
        /// 记录 翻斗机名称, 和 筐的起点 area
        /// </summary>
        public static Dictionary<string, List<string>> _Dic_str_int = new Dictionary<string, List<string>>();
 
        public static string GetTimeStamp(DateTime? time = null)
        {
            TimeSpan ts = DateTime.UtcNow - (time ?? new DateTime(1970, 1, 1, 0, 0, 0, 0));
            return Convert.ToInt64(ts.TotalMilliseconds).ToString();
        }
 
        #region _securityKey
        private static string _securityKey = "";
        public static string securityKey
        {
            get
            {
                if (_securityKey == "")
                {
                    _securityKey = XmlHelper.GetElementValue("securityKey");
                }
                return _securityKey;
            }
        }
        #endregion
        #region _tokenfrom
        private static string _tokenfrom = "";
        public static string tokenfrom
        {
            get
            {
                if (_tokenfrom == "")
                {
                    _tokenfrom = XmlHelper.GetElementValue("tokenfrom");
                }
                return _tokenfrom;
            }
        }
        #endregion
        #region _repoNo
        private static string _repoNo = "";
        public static string repoNo
        {
            get
            {
                if (_repoNo == "")
                {
                    _repoNo = XmlHelper.GetElementValue("repoNo");
                }
                return _repoNo;
            }
        }
        #endregion
        #region _FuleServerUrl
        private static string _FuleServerUrl = "";
        public static string FuleServerUrl
        {
            get
            {
                if (_FuleServerUrl == "")
                {
                    _FuleServerUrl = XmlHelper.GetElementValue("FuleServerUrl");
                }
                return _FuleServerUrl;
            }
        }
        #endregion
        #region _factoryCode
        private static string _factoryCode = "";
        public static string factoryCode
        {
            get
            {
                if (_factoryCode == "")
                {
                    _factoryCode = XmlHelper.GetElementValue("factoryCode");
                }
                return _factoryCode;
            }
        }
        #endregion
 
        #region _MesServerUrl
        private static string _MesServerUrl = "";
        public static string MesServerUrl
        {
            get
            {
                if (_MesServerUrl == "")
                {
                    _MesServerUrl = XmlHelper.GetElementValue("MesServerUrl");
                }
                return _MesServerUrl;
            }
        }
        #endregion
        public static string _TPcc
        {
            get
            {
                return DateTime.Now.ToString("yyMMdd");
            }
        }
        public static int _TPnum = 0;
        public static string TPnum()
        {
            lock (lockTPnum)
            {
                var ti = (++_TPnum) + "";
                return "TP" + _TPcc + (ti.PadLeft(5, '0'));
            }
        }
 
        public static string areaSuffix(string size)
        {
            switch (size)
            {
                case "大板":
                    size = "_D";
                    break;
                case "小板":
                    size = "_X";
                    break;
                case "集化板":
                    size = "_J";
                    break;
                default:
                    size = "";
                    break;
            }
            return size;
        }
        public static string areaSuffixR(string a)
        {
            if (a.Contains("_D"))
                a = "大板";
            else if (a.Contains("_X"))
                a = "小板";
            else if (a.Contains("_J"))
                a = "集化板";
            else a = "";
            return a;
        }
 
 
        #region _任务上报地址。
        private static string _TaskReportUrl = "";
        public static string TaskReportUrl
        {
            get
            {
                if (_TaskReportUrl == "")
                {
                    _TaskReportUrl = XmlHelper.GetElementValue("TaskReportUrl");
                }
                return _TaskReportUrl;
            }
        }
        #endregion
        #region OneSign
        private static string _OneSign = "";
        public static string OneSign
        {
            get
            {
                if (_OneSign == "")
                {
                    _OneSign = XmlHelper.GetElementValue("OneSign");
                }
                return _OneSign;
            }
        }
        #endregion
        #region FactoryCode
        private static string _FactoryCode = "";
        public static string FactoryCode
        {
            get
            {
                if (_FactoryCode == "")
                {
                    _FactoryCode = XmlHelper.GetElementValue("FactoryCode");
                }
                return _FactoryCode;
            }
        }
        #endregion
        #region TaskReportKey
        private static string _TaskReportKey = "";
        public static string TaskReportKey
        {
            get
            {
                if (_TaskReportKey == "")
                {
                    _TaskReportKey = XmlHelper.GetElementValue("TaskReportKey");
                }
                return _TaskReportKey;
            }
        }
        #endregion
        #region FactoryName
        private static string _FactoryName = "";
        public static string FactoryName
        {
            get
            {
                if (_FactoryName == "")
                {
                    _FactoryName = XmlHelper.GetElementValue("FactoryName");
                }
                return _FactoryName;
            }
        }
        #endregion
 
        #region _HostToAgvServerUrl
        private static string _hostToAgvServerUrl = "";
        public static string HostToAgvServerUrl
        {
            get
            {
                if (_hostToAgvServerUrl == "")
                {
                    _hostToAgvServerUrl = XmlHelper.GetElementValue("HostToAgvServerUrl");
                }
                return _hostToAgvServerUrl;
            }
        }
        #endregion
 
        #region _OITcpServerUrl
        private static string _OITcpServerUrl = "";
        public static string OITcpSeverUrl
        {
            get
            {
                if (_OITcpServerUrl == "")
                {
                    _OITcpServerUrl = XmlHelper.GetElementValue("OITcpServerUrl");
                }
                return _OITcpServerUrl;
            }
        }
        #endregion
 
        #region _elevatorIP
        private static string _elevatorIP = "";
        public static string ElevatorIP
        {
            get
            {
                if (_elevatorIP == "")
                {
                    _elevatorIP = XmlHelper.GetElementValue("elevatorIP");
                }
                return _elevatorIP;
            }
        }
        #endregion
 
        #region _elevatorWaitMinute
        private static int _elevatorWaitMinute = 0;
        public static int ElevatorWaitMinute
        {
            get
            {
                if (_elevatorWaitMinute == 0)
                {
                    _elevatorWaitMinute = int.Parse(XmlHelper.GetElementValue("elevatorWaitMinute"));
                }
                return _elevatorWaitMinute;
            }
        }
        #endregion
 
        #region _SqlServer
        private static string _SqlServer = "";
        public static string SqlServer
        {
            get
            {
                if (_SqlServer == "")
                {
                    _SqlServer = XmlHelper.GetElementValue("SqlServer");
                }
                return _SqlServer;
            }
        }
        private static string _AgvSqlServer = "";
        public static string AgvSqlServer
        {
            get
            {
                if (_AgvSqlServer == "")
                {
                    _AgvSqlServer = XmlHelper.GetElementValue("AgvSqlServer");
                }
                return _AgvSqlServer;
            }
        }
        #endregion
 
        #region deviceInfo
        private static string _deviceInfo = "";
        private static string deviceInfoList
        {
            get
            {
                if (_deviceInfo == "")
                {
                    _deviceInfo = XmlHelper.GetElementValue("deviceInfo");
                }
                return _deviceInfo;
            }
        }
 
        private static List<deviceInfo> deviceInfos = new List<deviceInfo>();
        public static List<deviceInfo> GetDeviceInfoList()
        {
            if (deviceInfos.Count == 0 && deviceInfoList != "")
            {
                Console.WriteLine(deviceInfoList);
                deviceInfos = Newtonsoft.Json.JsonConvert.DeserializeObject<List<deviceInfo>>(deviceInfoList);
            }
            return deviceInfos;
        }
 
        public class deviceInfo
        {
            public string address { get; set; }
            public string deviceName { get; set; }
            public string FuLeLineNo { get; set; }
            public string[] deviceNo { get; set; }
 
            /// <summary>
            /// 优先级
            /// </summary>
            public string[] areaPriy { get; set; }
 
            public string[] location { get; set; }
            /// <summary>
            ///  1 门(独立门)
            ///  2 无菌盖
            ///  3 水盖
            ///  4 水盖翻斗机
            ///  5 瓶坯翻斗机
            ///  6 无菌翻斗机
            ///  8 瓶坯
            ///  9 550水线  1满2空
            ///  10  水线翻斗机。
            ///  11电梯,提升机。吊机。 管他啥,从一楼搬二楼。
            /// </summary>
            public int deviceType { get; set; }
            public int enable { get; set; }
 
            /// <summary>
            /// 任务权重。 
            /// </summary>
            public int taskPri { get; set; } = 60;
 
            /// <summary>
            /// 分钟数 =- 切筐时的等待。
            /// </summary>
            public int EmptyWait { get; set; } = 1;
 
        }
        #endregion
 
        #region inStockCacheBit
        private static string _inStockCacheBit = "";
        private static string inStockCacheBitList
        {
            get
            {
                if (_inStockCacheBit == "")
                {
                    _inStockCacheBit = XmlHelper.GetElementValue("inStockCacheBit");
                }
                return _inStockCacheBit;
            }
        }
 
        private static List<inStockCacheBit> inStockCacheBits = new List<inStockCacheBit>();
        public static List<inStockCacheBit> GetInStockCacheList()
        {
            if (inStockCacheBits.Count == 0 && inStockCacheBitList != "")
            {
                inStockCacheBits = Newtonsoft.Json.JsonConvert.DeserializeObject<List<inStockCacheBit>>(inStockCacheBitList);
            }
            return inStockCacheBits;
        }
 
        public class inStockCacheBit
        {
            public string deviceName { get; set; }
            public string location { get; set; }
            public int locationType { get; set; }
 
        }
        #endregion
 
        #region elevatorCacheBit
        private static string _elevatorCacheBit = "";
        private static string elevatorCacheList
        {
            get
            {
                if (_elevatorCacheBit == "")
                {
                    _elevatorCacheBit = XmlHelper.GetElementValue("elevatorCacheBit");
                }
                return _elevatorCacheBit;
            }
        }
 
        private static List<elevatorCacheBit> elevatorCacheBits = new List<elevatorCacheBit>();
        public static List<elevatorCacheBit> GetElevatorCacheBits()
        {
            Console.WriteLine("elevatorCacheList  =" + elevatorCacheList);
            if (elevatorCacheBits.Count == 0 && elevatorCacheList != "")
            {
                elevatorCacheBits = Newtonsoft.Json.JsonConvert.DeserializeObject<List<elevatorCacheBit>>(elevatorCacheList);
            }
            return elevatorCacheBits;
        }
        /// <summary>
        ///  {"location":"内部货位","order":0,"agvBits":[100,101]},
        /// </summary>
        public class elevatorCacheBit
        {
 
            public string location { get; set; }
 
            public int order { get; set; }
            public int[] agvBits { get; set; }
 
        }
        #endregion
 
        #region elevatorDoor
        private static string _elevatorDoor = "";
        public static string elevatorDoorList
        {
            get
            {
                if (_elevatorDoor == "")
                {
                    _elevatorDoor = XmlHelper.GetElementValue("elevatorDoor");
                }
                return _elevatorDoor;
            }
        }
 
        private static List<elevatorDoor> elevatorDoors = new List<elevatorDoor>();
        public static List<elevatorDoor> GetelEvatorDoorList()
        {
            if (elevatorDoors.Count == 0 && elevatorDoorList != "")
            {
                elevatorDoors = Newtonsoft.Json.JsonConvert.DeserializeObject<List<elevatorDoor>>(elevatorDoorList);
            }
            return elevatorDoors;
        }
 
        public class elevatorDoor
        {
            public string door { get; set; }
            public int floor { get; set; }
            public int addr { get; set; }
 
 
        }
        #endregion
 
        #region tipperCacheBit
        private static string _tipperCacheBit = "";
        private static string tipperCacheBitList
        {
            get
            {
                if (_tipperCacheBit == "")
                {
                    _tipperCacheBit = XmlHelper.GetElementValue("tipperCacheBit");
                }
                return _tipperCacheBit;
            }
        }
 
        private static List<TipperCacheBit> tipperCacheBits = new List<TipperCacheBit>();
        public static List<TipperCacheBit> GetTipperCacheList()
        {
            if (tipperCacheBits.Count == 0 && tipperCacheBitList != "")
            {
                tipperCacheBits = Newtonsoft.Json.JsonConvert.DeserializeObject<List<TipperCacheBit>>(tipperCacheBitList);
            }
            return tipperCacheBits;
        }
 
        public class TipperCacheBit
        {
            public string deviceName { get; set; }
            public string[] location { get; set; }
            /// <summary>
            ///locationType=11 满托位       locationType=12 空铁框       locationType=13 空塑料框     
            /// </summary>
            public int locationType { get; set; }
 
        }
        #endregion
 
        #region outStockCacheBit
        private static string _outStockCacheBit = "";
        private static string outStockCacheBitList
        {
            get
            {
                if (_outStockCacheBit == "")
                {
                    _outStockCacheBit = XmlHelper.GetElementValue("outStockCacheBit");
                }
                return _outStockCacheBit;
            }
        }
 
        private static List<outStockCacheBit> outStockCacheBits = new List<outStockCacheBit>();
        public static List<outStockCacheBit> GetOutStockCacheList()
        {
            if (outStockCacheBits.Count == 0 && outStockCacheBitList != "")
            {
                outStockCacheBits = Newtonsoft.Json.JsonConvert.DeserializeObject<List<outStockCacheBit>>(outStockCacheBitList);
            }
            return outStockCacheBits;
        }
 
        public class outStockCacheBit
        {
            public string areaName { get; set; }
            public string[] location { get; set; }
            /// <summary>
            ///locationType=1 无菌盖满(row=0专门给V6)  locationType=2 水盖满 
            ///locationType=3 铁空2层 loationType = 4 塑料空2层
            ///locationType = 4 v8满 locationType = 5 v8铁空 locationType = 6 v8塑料空
            /// </summary>
            public int locationType { get; set; }
            public int row { get; set; }
 
        }
        #endregion
 
        #region rawMaterialCacheBit
        private static string _rawMaterialCacheBit = "";
        private static string rawMaterialCacheBitList
        {
            get
            {
                if (_rawMaterialCacheBit == "")
                {
                    _rawMaterialCacheBit = XmlHelper.GetElementValue("rawMaterialCacheBit");
                }
                return _rawMaterialCacheBit;
            }
        }
 
        private static List<RawMaterialCacheBit> rawMaterialCacheBits = new List<RawMaterialCacheBit>();
        public static List<RawMaterialCacheBit> GetRawMaterialCacheList()
        {
            if (rawMaterialCacheBits.Count == 0 && rawMaterialCacheBitList != "")
            {
                rawMaterialCacheBits = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RawMaterialCacheBit>>(rawMaterialCacheBitList);
            }
            return rawMaterialCacheBits;
        }
 
        public class RawMaterialCacheBit
        {
            public string[] location { get; set; }
            public int locationType { get; set; }
            public int row { get; set; }
 
        }
        #endregion
 
        #region outStockCacheBit
        private static string _outgoCacheBit = "";
        private static string outgoCacheBitList
        {
            get
            {
                if (_outgoCacheBit == "")
                {
                    _outgoCacheBit = XmlHelper.GetElementValue("outgoCacheBit");
                }
                return _outgoCacheBit;
            }
        }
 
        private static List<OutgoCacheBit> outgoCacheBits = new List<OutgoCacheBit>();
        public static List<OutgoCacheBit> GetOutgoCacheList()
        {
            if (outgoCacheBits.Count == 0 && outgoCacheBitList != "")
            {
                outgoCacheBits = Newtonsoft.Json.JsonConvert.DeserializeObject<List<OutgoCacheBit>>(outgoCacheBitList);
            }
            return outgoCacheBits;
        }
 
        public class OutgoCacheBit
        {
            public string[] location { get; set; }
            public int locationType { get; set; }
            public int row { get; set; }
 
        }
        #endregion
 
        #region MoreSites
        private static string _MoreBit = "";
        private static string moreBit
        {
            get
            {
                if (_MoreBit == "")
                {
                    _MoreBit = XmlHelper.GetElementValue("MoreSites");
                }
                return _MoreBit;
            }
        }
 
        private static List<MoreSites> MoreBits = new List<MoreSites>();
        public static List<MoreSites> GetMoreBits()
        {
            if (MoreBits.Count == 0 && moreBit != "")
            {
                MoreBits = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MoreSites>>(moreBit);
            }
            return MoreBits;
        }
 
        public class MoreSites
        {
            public string Location { get; set; }
            public int StartBit { get; set; }
            public int EndBit { get; set; }
 
        }
        #endregion
 
        #region 
 
        private static string BolAreaList
        {
            get
            {
                return XmlHelper.GetElementValue("BOLArea") ?? "";
            }
        }
 
        public static List<BolArea> GetBolAreaList()
        {
            return Newtonsoft.Json.JsonConvert.DeserializeObject<List<BolArea>>(BolAreaList); ;
        }
        public class BolArea
        {
            /// <summary>
            /// 设备名称。
            /// </summary>
            public string DeviceName { get; set; }
            /// <summary>
            /// F即产线边位
            /// </summary>
            public string NotUsingBolArea { get; set; }
            /// <summary>
            /// 即产线边位
            /// </summary>
            public string UsingBolArea { get; set; }
            /// <summary>
            /// F即产线边 kong 位
            /// </summary>
            public string NotUsingEmpty { get; set; }
            /// <summary>
            /// 即产线边 kong 位
            /// </summary>
            public string UsingEmpty { get; set; }
            /// <summary>
            /// 设备类型和  deviceiNFO 一样  2水3无菌 盖,  4水5坯 6无菌 10水线(水盖) 斗
            /// </summary>
            public int deviceType { get; set; }
        }
        #endregion
 
 
 
        #region DoorOneToMany
 
        private static string _dm = "";
        private static string dnl
        {
            get
            {
                if (_dm == "")
                {
                    _dm = XmlHelper.GetElementValue("DoorOneToMany");
                }
                return _dm;
            }
        }
 
        private static List<DoorOneToMany> DoorOneToManys = new List<DoorOneToMany>();
        
 
        public static List<DoorOneToMany> GetDoorOneToMany()
        {
            if (DoorOneToManys.Count == 0 && dnl != "")
            {
                Console.WriteLine(dnl);
                DoorOneToManys = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DoorOneToMany>>(dnl);
            }
            return DoorOneToManys;
        }
 
        //{"DoorNo":"10","deviceNo":["184","185"]},
        public class DoorOneToMany
        {
            /// <summary>
            /// 上报的门号。 
            /// </summary>
            public string DoorNo { get; set; }
            /// <summary>
            ///  这里是设备的IP 对应的门号, 当然,如果现场给的多个门号10 ,那么就自定义ip 的门号
            /// </summary>
            public string[] deviceNo { get; set; }
            /// <summary>
            /// s数量和 deviceNo 对应, 打开的信号。 
            /// </summary>
            public string[] SignOpen { get; set; }
            /// <summary>
            /// s数量和 deviceNo 对应, 关闭的信号。 
            /// </summary>
            public string[] SignClose { get; set; }
        }
 
        #endregion
 
 
 
        #region _fromSystem
        private static string _fromSystem = "";
        public static string fromSystem
        {
            get
            {
                if (_fromSystem == "")
                {
                    _fromSystem = XmlHelper.GetElementValue("fromSystem");
                }
                return _fromSystem;
            }
        }
        #endregion
        #region _asnType
        private static string _asnType = "";
        public static string asnType
        {
            get
            {
                if (_asnType == "")
                {
                    _asnType = XmlHelper.GetElementValue("asnType");
                }
                return _asnType;
            }
        }
        #endregion
 
        #region _customerId
        private static string _customerId = "";
        public static string customerId
        {
            get
            {
                if (_customerId == "")
                {
                    _customerId = XmlHelper.GetElementValue("customerId");
                }
                return _customerId;
            }
        }
        #endregion
        #region _warehouseId
        private static string _warehouseId = "";
        public static string warehouseId
        {
            get
            {
                if (_warehouseId == "")
                {
                    _warehouseId = XmlHelper.GetElementValue("warehouseId");
                }
                return _warehouseId;
            }
        }
        #endregion
 
    }
}