廖井涛
2025-06-18 581995c70efe4f8f386b1878a656b32c7f35d539
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
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
ÿþUSE [WinccSQL]
GO
/****** Object:  User [SIMATIC HMI User]    Script Date: 2023/12/11 8:44:59 ******/
CREATE USER [SIMATIC HMI User] FOR LOGIN [DESKTOP-OAB5EAB\SIMATIC HMI]
GO
/****** Object:  User [SIMATIC HMI VIEWER User]    Script Date: 2023/12/11 8:44:59 ******/
CREATE USER [SIMATIC HMI VIEWER User] FOR LOGIN [DESKTOP-OAB5EAB\SIMATIC HMI VIEWER]
GO
/****** Object:  DatabaseRole [SIMATIC HMI role]    Script Date: 2023/12/11 8:44:59 ******/
CREATE ROLE [SIMATIC HMI role]
GO
/****** Object:  DatabaseRole [SIMATIC HMI VIEWER role]    Script Date: 2023/12/11 8:44:59 ******/
CREATE ROLE [SIMATIC HMI VIEWER role]
GO
ALTER ROLE [SIMATIC HMI role] ADD MEMBER [SIMATIC HMI User]
GO
ALTER ROLE [db_ddladmin] ADD MEMBER [SIMATIC HMI User]
GO
ALTER ROLE [db_datareader] ADD MEMBER [SIMATIC HMI User]
GO
ALTER ROLE [db_datawriter] ADD MEMBER [SIMATIC HMI User]
GO
ALTER ROLE [SIMATIC HMI VIEWER role] ADD MEMBER [SIMATIC HMI VIEWER User]
GO
ALTER ROLE [db_datareader] ADD MEMBER [SIMATIC HMI VIEWER User]
GO
ALTER ROLE [db_ddladmin] ADD MEMBER [SIMATIC HMI role]
GO
ALTER ROLE [db_datareader] ADD MEMBER [SIMATIC HMI role]
GO
ALTER ROLE [db_datawriter] ADD MEMBER [SIMATIC HMI role]
GO
ALTER ROLE [db_datareader] ADD MEMBER [SIMATIC HMI VIEWER role]
GO
/****** Object:  Table [dbo].[GlassIDTemp]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GlassIDTemp](
    [GlassIDTemp] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[glassIn]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[glassIn](
    [¢[7bãN÷S] [nvarchar](max) NULL,
    [¤N'åeg] [datetime] NULL,
    [¢‹US÷S] [nvarchar](max) NULL,
    [ň±{÷Sÿ¶g÷S    ÿ] [nvarchar](max) NULL,
    [±{…Q»sƒt;`pe] [float] NULL,
    [WY÷S] [nvarchar](max) NULL,
    [WY…Q»sƒt;`pe] [float] NULL,
    [»sƒtID] [nvarchar](max) NULL,
    [»sƒt•¦^ÿmm    ÿ] [float] NULL,
    [»sƒt½[¦^ÿmm    ÿ] [float] NULL,
    [»sƒtšS¦^ÿmm    ÿ] [float] NULL,
    [WY…Q»sƒt^÷S] [float] NULL,
    [±{…Q»sƒt^÷S] [float] NULL,
    [¢‹US»sƒt;`pe] [float] NULL,
    [item_quantity] [int] NULL,
    [RackTypeID] [nvarchar](max) NULL,
    [P[±{÷S] [nvarchar](max) NULL,
    [RackID] [float] NULL,
    [±{pe] [int] NULL,
    [»sƒt/UNID] [nvarchar](max) NULL,
    [ŸSň±{÷S] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[glassOut]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[glassOut](
    [^÷S] [float] NULL,
    [¢[7bãN÷S] [nvarchar](max) NULL,
    [¤N'åeg] [datetime] NULL,
    [¢‹US÷S] [nvarchar](max) NULL,
    [ň±{÷Sÿ¶g÷S    ÿ] [nvarchar](max) NULL,
    [±{…Q»sƒt;`pe] [float] NULL,
    [WY÷S] [nvarchar](max) NULL,
    [WY…Q»sƒt;`pe] [float] NULL,
    [»sƒtID] [nvarchar](max) NULL,
    [»sƒt•¦^ÿmm    ÿ] [float] NULL,
    [»sƒt½[¦^ÿmm    ÿ] [float] NULL,
    [»sƒtšS¦^ÿmm    ÿ] [float] NULL,
    [RackTypeID] [float] NULL,
    [rackID] [float] NULL,
    [™e¶g
N„všS¦^] [int] NULL,
    [™e¶g
N„v^÷S] [int] NULL,
    [±{…Q»sƒt^÷S] [int] NULL,
    [ö€«WšS¦^] [float] NULL,
    [P[±{÷S] [nvarchar](max) NULL,
    [±{pe] [int] NULL,
    [»sƒt/UNID] [nvarchar](max) NULL,
    [ŸSň±{÷S] [nvarchar](max) NULL,
    [ŸS±{…Q^÷S] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[glassOut2]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[glassOut2](
    [^÷S] [float] NULL,
    [¢[7bãN÷S] [nvarchar](max) NULL,
    [¤N'åeg] [datetime] NULL,
    [¢‹US÷S] [nvarchar](max) NULL,
    [ň±{÷Sÿ¶g÷S    ÿ] [nvarchar](max) NULL,
    [±{…Q»sƒt;`pe] [float] NULL,
    [WY÷S] [nvarchar](max) NULL,
    [WY…Q»sƒt;`pe] [float] NULL,
    [»sƒtID] [nvarchar](max) NULL,
    [»sƒt•¦^ÿmm    ÿ] [float] NULL,
    [»sƒt½[¦^ÿmm    ÿ] [float] NULL,
    [»sƒtšS¦^ÿmm    ÿ] [float] NULL,
    [RackTypeID] [float] NULL,
    [rackID] [float] NULL,
    [™e¶g
N„všS¦^] [int] NULL,
    [™e¶g
N„v^÷S] [int] NULL,
    [±{…Q»sƒt^÷S] [int] NULL,
    [ö€«WšS¦^] [float] NULL,
    [P[±{÷S] [nvarchar](max) NULL,
    [±{pe] [int] NULL,
    [»sƒt/UNID] [nvarchar](max) NULL,
    [ŸSň±{÷S] [nvarchar](max) NULL,
    [ŸS±{…Q^÷S] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[glassOut3]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[glassOut3](
    [^÷S] [float] NULL,
    [¢[7bãN÷S] [nvarchar](max) NULL,
    [¤N'åeg] [datetime] NULL,
    [¢‹US÷S] [nvarchar](max) NULL,
    [ň±{÷Sÿ¶g÷S    ÿ] [nvarchar](max) NULL,
    [±{…Q»sƒt;`pe] [float] NULL,
    [WY÷S] [nvarchar](max) NULL,
    [WY…Q»sƒt;`pe] [float] NULL,
    [»sƒtID] [nvarchar](max) NULL,
    [»sƒt•¦^ÿmm    ÿ] [float] NULL,
    [»sƒt½[¦^ÿmm    ÿ] [float] NULL,
    [»sƒtšS¦^ÿmm    ÿ] [float] NULL,
    [RackTypeID] [float] NULL,
    [rackID] [float] NULL,
    [™e¶g
N„všS¦^] [int] NULL,
    [™e¶g
N„v^÷S] [int] NULL,
    [±{…Q»sƒt^÷S] [int] NULL,
    [ö€«WšS¦^] [float] NULL,
    [P[±{÷S] [nvarchar](max) NULL,
    [±{pe] [int] NULL,
    [»sƒt/UNID] [nvarchar](max) NULL,
    [ŸSň±{÷S] [nvarchar](max) NULL,
    [ŸS±{…Q^÷S] [int] NULL,
    [úQGröeô•] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[modeSwitch]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[modeSwitch](
    [mode] [bit] NULL
) ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[newtesttable]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[newtesttable](
    [¢[7bãN÷S] [nvarchar](max) NULL,
    [¤N'åeg] [datetime] NULL,
    [¢‹US÷S] [nvarchar](max) NULL,
    [ň±{÷Sÿ¶g÷S    ÿ] [nvarchar](max) NULL,
    [±{…Q»sƒt;`pe] [float] NULL,
    [WY÷S] [nvarchar](max) NULL,
    [WY…Q»sƒt;`pe] [float] NULL,
    [»sƒtID] [nvarchar](max) NULL,
    [»sƒt•¦^ÿmm    ÿ] [float] NULL,
    [»sƒt½[¦^ÿmm    ÿ] [float] NULL,
    [»sƒtšS¦^ÿmm    ÿ] [float] NULL,
    [WY…Q»sƒt^÷S] [float] NULL,
    [±{…Q»sƒt^÷S] [float] NULL,
    [item_quantity] [int] NULL,
    [RackTypeID] [float] NULL,
    [RackID] [float] NULL,
    [ۏGrz˜^] [float] NULL,
    [ۏGr] [float] NULL,
    [úQGr] [float] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[Order$]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Order$](
    [¢[7bãN÷S] [nvarchar](max) NULL,
    [¤N'åeg] [datetime] NULL,
    [¢‹US÷S] [nvarchar](max) NULL,
    [ň±{÷Sÿ¶g÷S    ÿ] [nvarchar](max) NULL,
    [±{…Q»sƒt;`pe] [float] NULL,
    [WY÷S] [nvarchar](max) NULL,
    [WY…Q»sƒt;`pe] [float] NULL,
    [»sƒtID] [nvarchar](max) NULL,
    [»sƒt•¦^ÿmm    ÿ] [float] NULL,
    [»sƒt½[¦^ÿmm    ÿ] [float] NULL,
    [»sƒtšS¦^ÿmm    ÿ] [float] NULL,
    [WY…Q»sƒt^÷S] [float] NULL,
    [±{…Q»sƒt^÷S] [float] NULL,
    [¢‹US»sƒt;`pe] [float] NULL,
    [item_quantity] [int] NULL,
    [RackTypeID] [nvarchar](max) NULL,
    [P[±{÷S] [nvarchar](max) NULL,
    [RackID] [float] NULL,
    [±{pe] [int] NULL,
    [»sƒt/UNID] [nvarchar](max) NULL,
    [ŸSň±{÷S] [nvarchar](max) NULL,
    [last_update_time] [datetime] NULL,
    [number] [int] NULL,
    [úQP[±{÷S] [nvarchar](max) NULL,
    [ŸS±{…Q^÷S] [float] NULL,
    [¢‹US÷S÷S] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[QuestionsTB]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[QuestionsTB](
    [customer_order_number] [nvarchar](max) NULL,
    [last_update_date] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[Rack]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Rack](
    [^÷S] [int] IDENTITY(1,1) NOT NULL,
    [RACK] [float] NULL,
    [½[¦^] [float] NULL,
    [ň±{÷S] [nvarchar](max) NULL,
    [»sƒt;`šS¦^] [float] NULL,
    [{|‹W] [nvarchar](max) NULL,
    [¢‹US÷S] [nvarchar](max) NULL,
    [WY÷S] [nvarchar](max) NULL,
    [¢[7bãN÷S] [nvarchar](max) NULL,
 CONSTRAINT [PK_Rack] PRIMARY KEY CLUSTERED 
(
    [^÷S] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[Report]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Report](
    [ID] [bigint] IDENTITY(1,1) NOT NULL,
    [markDate] [date] NULL,
    [GlassID] [nvarchar](max) NULL,
    [TheOnlyGlassID] [nvarchar](max) NULL,
    [OrderNum] [nvarchar](max) NULL,
    [CustomNum] [nvarchar](max) NULL,
 CONSTRAINT [PK_Report] PRIMARY KEY CLUSTERED 
(
    [ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[storage]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[storage](
    [^÷S] [bigint] IDENTITY(1,1) NOT NULL,
    [¢[7bãN÷S] [nvarchar](max) NULL,
    [¤N'åeg] [datetime] NULL,
    [¢‹US÷S] [nvarchar](max) NULL,
    [ň±{÷Sÿ¶g÷S    ÿ] [nvarchar](max) NULL,
    [±{…Q»sƒt;`pe] [float] NULL,
    [WY÷S] [nvarchar](max) NULL,
    [WY…Q»sƒt;`pe] [float] NULL,
    [»sƒtID] [nvarchar](max) NULL,
    [»sƒt•¦^ÿmm    ÿ] [float] NULL,
    [»sƒt½[¦^ÿmm    ÿ] [float] NULL,
    [»sƒtšS¦^ÿmm    ÿ] [float] NULL,
    [RackTypeID] [float] NULL,
    [rackID] [float] NULL,
    [™e¶g
N„všS¦^] [int] NULL,
    [™e¶g
N„v^÷S] [int] NULL,
    [±{…Q»sƒt^÷S] [int] NULL,
    [ö€«WšS¦^] [float] NULL,
    [item_quantity] [int] NULL,
    [P[±{÷S] [nvarchar](max) NULL,
    [±{pe] [int] NULL,
    [»sƒt/UNID] [nvarchar](max) NULL,
    [ŸSň±{÷S] [nvarchar](max) NULL,
    [úQP[±{÷S] [nvarchar](max) NULL,
    [ŸS±{…Q^÷S] [float] NULL,
 CONSTRAINT [PK_storage] PRIMARY KEY CLUSTERED 
(
    [^÷S] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[t_report_processing_order]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[t_report_processing_order](
    [id] [nvarchar](255) NULL,
    [customer_number] [nvarchar](255) NULL,
    [shipping_date] [datetime] NULL,
    [customer_order_number] [nvarchar](255) NULL,
    [customer_order_number_number] [nvarchar](255) NULL,
    [item_memo_one] [nvarchar](255) NULL,
    [processing_order_number] [nvarchar](255) NULL,
    [processing_order_item_number] [nvarchar](255) NULL,
    [item_height] [nvarchar](255) NULL,
    [item_width] [nvarchar](255) NULL,
    [thickness] [nvarchar](255) NULL,
    [item_memo_one_last_no] [nvarchar](255) NULL,
    [last_update_time] [datetime] NULL,
    [used] [nvarchar](255) NULL,
    [used_time] [nvarchar](255) NULL,
    [remark] [nvarchar](255) NULL,
    [customer_product_desc] [nvarchar](255) NULL,
    [serial_number] [nvarchar](255) NULL,
    [item_quantity] [nvarchar](255) NULL,
    [total_quantity] [nvarchar](255) NULL,
    [customer_product_desc_number] [nvarchar](255) NULL,
    [serial_number_number] [nvarchar](255) NULL,
    [work_shop] [nvarchar](255) NULL
) ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[Temp]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Temp](
    [¢[7bãN÷S] [nvarchar](255) NULL,
    [¤N'åeg] [datetime] NULL,
    [¢‹US÷S] [nvarchar](255) NULL,
    [ň±{÷S_¶g÷S] [nvarchar](255) NULL,
    [±{…Q»sƒt;`pe] [float] NULL,
    [WY÷S] [nvarchar](255) NULL,
    [WY…Q»sƒt;`pe] [float] NULL,
    [»sƒtID] [nvarchar](255) NULL,
    [»sƒt•¦^_mm] [float] NULL,
    [»sƒt½[¦^_mm] [float] NULL,
    [»sƒtšS¦^_mm] [float] NULL,
    [WY…Q»sƒt^÷S] [float] NULL,
    [±{…Q»sƒt^÷S] [float] NULL,
    [¢‹US»sƒt;`pe] [float] NULL,
    [item_quantity] [float] NULL,
    [RackTypeID] [nvarchar](255) NULL,
    [P[±{÷S] [nvarchar](255) NULL,
    [RackID] [float] NULL,
    [±{pe] [int] NULL,
    [»sƒt/UNID] [nvarchar](255) NULL,
    [ŸSň±{÷S] [nvarchar](255) NULL,
    [last_update_time] [datetime] NULL,
    [number] [int] NULL,
    [úQP[±{÷S] [nvarchar](max) NULL,
    [ŸS±{…Q^÷S] [float] NULL,
    [¢‹US÷S÷S] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
/****** Object:  Table [dbo].[weiyiID]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[weiyiID](
    [»sƒt/UNID] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 
GO
ALTER TABLE [dbo].[Temp] ADD  CONSTRAINT [DF_Temp_number]  DEFAULT ((0)) FOR [number]
GO
/****** Object:  StoredProcedure [dbo].[insert_chai]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--4Nöehˆ  ÒceQpenc
CREATE proc [dbo].[insert_chai]
@days int
as    
begin 
    declare @¢[7bãN÷S nvarchar(50)
    declare @¤N'åeg nvarchar(50)
    declare @¢‹US÷S nvarchar(50)
    declare @ň±{÷S_¶g÷S nvarchar(50)
    --declare @ŸSň±{÷S nvarchar(50)
    declare @»sƒtID nvarchar(50)
    declare @»sƒt•¦^_mm nvarchar(50)
    declare @»sƒt½[¦^_mm nvarchar(50)
    declare @»sƒtšS¦^_mm nvarchar(50)
    declare @±{…Q»sƒt^÷S nvarchar(50)
    declare @¢‹US»sƒt;`pe nvarchar(50)
    declare @item_quantity nvarchar(50)
    declare @ûm Råeg nvarchar(50)
    declare cursor1 cursor for
    select customer_number,shipping_date,customer_order_number,customer_product_desc_number,processing_order_number,item_height,item_width,thickness,serial_number_number,total_quantity,item_quantity,last_update_time from [192.168.3.16].shebei.dbo.t_report_processing_order
    where work_shop=2000 and last_update_time>getdate()-@days --and processing_order_number not in(select »sƒtID from Order$ group by »sƒtID)     --ÿb0R@b    g¡l    gûm R„v»sƒtID
    open cursor1
    fetch next from cursor1 into @¢[7bãN÷S,@¤N'åeg,@¢‹US÷S,@ň±{÷S_¶g÷S,@»sƒtID,@»sƒt•¦^_mm,@»sƒt½[¦^_mm,@»sƒtšS¦^_mm,@±{…Q»sƒt^÷S,@¢‹US»sƒt;`pe,@item_quantity,@ûm Råeg
    while @@fetch_status=0
        begin 
            declare @prices int
            declare @ò]0Rpe int
            set @ò]0Rpe=0
            set @prices=@item_quantity-@ò]0Rpe  --;`pe-ò]Ï~ûm R„vpeϑ
            while @prices>0
                begin
                    declare @»sƒt/UNID nvarchar(50)
                    set @ò]0Rpe=@ò]0Rpe+1
                    set @»sƒt/UNID=@»sƒtID+'-'+CONVERT(nvarchar,@ò]0Rpe)
                    --set @ŸSň±{÷S=@ň±{÷S_¶g÷S
                    insert into Temp(¢[7bãN÷S,¤N'åeg,¢‹US÷S,ň±{÷S_¶g÷S,»sƒtID,»sƒt•¦^_mm,»sƒt½[¦^_mm,»sƒtšS¦^_mm,±{…Q»sƒt^÷S,¢‹US»sƒt;`pe,item_quantity,±{pe,»sƒt/UNID,ŸSň±{÷S,last_update_time,ŸS±{…Q^÷S,¢‹US÷S÷S)    --ûm RW[µk  ±{pe Øž¤‹<P:N1
                    select @¢[7bãN÷S,@¤N'åeg,@¢‹US÷S,@ň±{÷S_¶g÷S,@»sƒtID,@»sƒt•¦^_mm,@»sƒt½[¦^_mm,@»sƒtšS¦^_mm,@±{…Q»sƒt^÷S,@¢‹US»sƒt;`pe,@item_quantity,0,@»sƒt/UNID,@ň±{÷S_¶g÷S,@ûm Råeg,@±{…Q»sƒt^÷S,LEFT(@»sƒtID,13)
                    set @prices=@prices-1
                end
            fetch next from cursor1 into @¢[7bãN÷S,@¤N'åeg,@¢‹US÷S,@ň±{÷S_¶g÷S,@»sƒtID,@»sƒt•¦^_mm,@»sƒt½[¦^_mm,@»sƒtšS¦^_mm,@±{…Q»sƒt^÷S,@¢‹US»sƒt;`pe,@item_quantity,@ûm Råeg
        end
    close cursor1                   --sQí•8nh
    deallocate cursor1
end
GO
/****** Object:  StoredProcedure [dbo].[Pro_ChildBox]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[Pro_ChildBox]
@ň±{÷S_¶g÷S nvarchar(100)
as
begin
    if (select MAX(CONVERT(int,ŸS±{…Q^÷S)) from Temp where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S)>0  --    g^÷S„v   
        begin
            exec Pro_ChildBox_Rule1 @ň±{÷S_¶g÷S
        end
    else 
        begin
            if((select top(1)mode from modeSwitch)='false')  or (select PATINDEX('%JYC-%',@ň±{÷S_¶g÷S))>0   --!j_1  b€/fÖNìN„vň±{÷S
                begin
                    update Temp set P[±{÷S=@ň±{÷S_¶g÷S where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S                    
                end
            else
                begin
                    exec Pro_ChildBox_Rule2 @ň±{÷S_¶g÷S
                end
        end
end
 
GO
/****** Object:  StoredProcedure [dbo].[Pro_ChildBox_Rule1]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--P[±{ĉR1   50N¶g
CREATE proc [dbo].[Pro_ChildBox_Rule1]
@ň±{÷S_¶g÷S nvarchar(100)
as 
begin
    declare @Box_childID nvarchar(50)          --°eP[±{÷S    
    declare @Count int                           --hˆ:y,{àQ*N±{
    set @Count=1
    while(select count(*) from Temp where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and P[±{÷S is null)>0
        begin
            set @Box_childID=@ň±{÷S_¶g÷S+'-'+CONVERT(nvarchar,@Count)
            update Temp set P[±{÷S=@Box_childID where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and »sƒt/UNID in (select top(50)»sƒt/UNID from Temp where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and P[±{÷S is null order by ±{…Q»sƒt^÷S,»sƒt½[¦^_mm desc,»sƒtID) 
            set @Count=@Count+1
        end
end
GO
/****** Object:  StoredProcedure [dbo].[Pro_ChildBox_Rule2]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[Pro_ChildBox_Rule2]
@ň±{÷S_¶g÷S nvarchar(100)
as 
begin
    declare @Box_childID nvarchar(50)          --°eP[±{÷S    
    declare @Count int                           --hˆ:y,{àQ*N±{
    declare @g'Y±{…Qpeϑ int                  --g'Y±{…Qpeϑ
    declare @±{…Qg'YšS¦^ int                  --±{…Qg'YšS¦^
    set @±{…Qg'YšS¦^=(select MAX(CONVERT(int,»sƒtšS¦^_mm)) from Temp where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S)
    if(@±{…Qg'YšS¦^=10)
        begin
            set @g'Y±{…Qpeϑ=45
        end
    else if(@±{…Qg'YšS¦^=6)
        begin
            set @g'Y±{…Qpeϑ=60
        end
    else if(@±{…Qg'YšS¦^=5)
        begin
            set @g'Y±{…Qpeϑ=70
        end
    else
        begin
            set @g'Y±{…Qpeϑ=50
        end
    set @Count=1
    if(@g'Y±{…Qpeϑ<=50)
        begin
            while(select count(*) from Temp where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and P[±{÷S is null)>0
                begin
                    set @Box_childID=@ň±{÷S_¶g÷S+'-'+CONVERT(nvarchar,@Count)
                    update Temp set P[±{÷S=@Box_childID,úQP[±{÷S=@Box_childID where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and »sƒt/UNID in (select top(@g'Y±{…Qpeϑ)»sƒt/UNID from Temp where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and P[±{÷S is null order by ±{…Q»sƒt^÷S,»sƒt½[¦^_mm desc,»sƒtID) 
                    set @Count=@Count+1
                end
        end
    else
        begin
            while(select count(*) from Temp where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and P[±{÷S is null)>0
                begin
                    set @Box_childID=@ň±{÷S_¶g÷S+'-'+CONVERT(nvarchar,@Count)
                    insert into weiyiID(»sƒt/UNID)    --ûm RW[µk  ±{pe Øž¤‹<P:N1
                    select top(@g'Y±{…Qpeϑ)»sƒt/UNID from Temp where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and P[±{÷S is null order by ±{…Q»sƒt^÷S,»sƒt½[¦^_mm desc,»sƒtID
                    update Temp set úQP[±{÷S=@Box_childID where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and »sƒt/UNID in (select »sƒt/UNID from weiyiID)
                    update Temp set P[±{÷S=@Box_childID where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and »sƒt/UNID in (select top(50)»sƒt/UNID from weiyiID)
                    delete top(50) weiyiID
                    set @Count=@Count+1
                    set @Box_childID=@ň±{÷S_¶g÷S+'-'+CONVERT(nvarchar,@Count)
                    update Temp set P[±{÷S=@Box_childID where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and »sƒt/UNID in (select »sƒt/UNID from weiyiID)
                    delete weiyiID
                    set @Count=@Count+1
                end
        end
    
end
GO
/****** Object:  StoredProcedure [dbo].[Pro_Copys]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[Pro_Copys]
@day int
as
begin
    begin tran
        begin try
            exec Pro_Delete
            declare @X[(W int
            set @X[(W=(select count(*) from [192.168.3.16].shebei.dbo.t_report_processing_order where work_shop=2000 and last_update_time>getdate()-@day)
            if (@X[(W>0)
                begin
                    --print 1
                    exec insert_chai @day
                    declare @counnt int
                    declare @Dateing datetime
                    --ågâ‹g'Y„vnumber
                    set @counnt=(select max(number) from Order$)
                    if(@counnt is null)
                        begin
                            set @counnt=0
                        end
                    set    @counnt=@counnt+1
                    --¡‹—{ÿň±{÷S:N  NG+peW[   x<h_   RúQP[±{÷S
                    exec Pro_Update_BoxID @counnt
                    --¡‹—{ÿ±{…Q»sƒt;`pe
                    exec Pro_Sum
                    --¡‹—{™e¶g{|‹W
                    exec Pro_Type
                    --ŠbYtŒ[„v4Nöehˆpenc ReQ0ROrdershˆ-N                
                    set @Dateing=GETDATE()
                    --úQǏ„v
                    insert into QuestionsTB(customer_order_number,last_update_date) 
                    select ¢‹US÷S,@Dateing from Order$ where 
                    ¢‹US÷S in(select ¢‹US÷S from Order$ where »sƒtID in(select »sƒtID from Temp group by »sƒtID) group by ¢[7bãN÷S,¢‹US÷S) and
                    ¢‹US÷S not in(select customer_order_number from QuestionsTB group by customer_order_number)                    
                    group by ¢[7bãN÷S,¢‹US÷S having max(±{pe)!=0
                    --(W“^…Q„v
                    insert into QuestionsTB(customer_order_number,last_update_date) 
                    select ¢‹US÷S,@Dateing from Order$ where 
                    ¢‹US÷S in(select ¢‹US÷S from Order$ where »sƒtID in(select »sƒtID from Temp group by »sƒtID) group by ¢[7bãN÷S,¢‹US÷S) and
                    ¢‹US÷S not in(select customer_order_number from QuestionsTB group by customer_order_number) and
                    ¢‹US÷S in(select ¢‹US÷S from storage group by ¢[7bãN÷S,¢‹US÷S)                     
                    group by ¢[7bãN÷S,¢‹US÷S
 
                    delete Order$  where 
                    ¢‹US÷S in( 
                    select ¢‹US÷S from Order$ where 
                    ¢‹US÷S in(select ¢‹US÷S from Order$ where »sƒtID in(select »sƒtID from Temp group by »sƒtID) group by ¢[7bãN÷S,¢‹US÷S) and
                    ¢‹US÷S not in(select ¢‹US÷S from storage group by ¢[7bãN÷S,¢‹US÷S) 
                    group by ¢[7bãN÷S,¢‹US÷S having max(±{pe)=0)
                     
                    insert into Order$ select * from Temp where »sƒtID not in(select »sƒtID from Order$ group by »sƒtID)     --ÿb0R@b    g¡l    gûm R„v»sƒtID
                    -- Rd–Temphˆ
                    delete Temp
                end
        end try  
        begin catch
            select Error_number() as ErrorNumber,  --•ï‹ãNx
            Error_severity() as ErrorSeverity,     --•ï‹%N͑§~+R ÿ§~+R\ŽN10 try catch Uc·ƒ N0R
            Error_state() as ErrorState ,          --•ï‹¶r`x
            Error_Procedure() as ErrorProcedure ,  --úQ°s•ï‹„vX[¨PǏ zbæ‰ÑShV„v Tðy0
            Error_line() as ErrorLine,             --ÑSu•ï‹„vLˆ÷S
            Error_message() as ErrorMessage        --•ï‹„vwQSOáOo`
            rollback tran                          ---1uŽNúQ• ÿُ̑ÞVÚn0R_ËY ÿ,{Nagí‹åS_N¡l    gÒceQbŸR0
        end catch
    if(@@trancount>0)
    commit tran
end
GO
/****** Object:  StoredProcedure [dbo].[Pro_Delete]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Rd–orders$hˆ  15)YKNMR„v
CREATE proc [dbo].[Pro_Delete]
as
begin
    delete Order$ where last_update_time<getdate()-40
    delete QuestionsTB where last_update_date<getdate()-20
end
 
GO
/****** Object:  StoredProcedure [dbo].[Pro_InsertXuhao]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[Pro_InsertXuhao]
@ň±{÷S_¶g÷S nvarchar(100)
as
begin
    declare @»sƒt/UNID nvarchar(255)           --hˆ:y»sƒt/UNID
    declare @±{…Q»sƒt^÷S int                   --hˆ:y±{…Q»sƒt^÷S
    set @±{…Q»sƒt^÷S=1
    declare cursor_Xuhao cursor for
    select »sƒt/UNID from Temp where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S order by ŸS±{…Q^÷S asc,CONVERT(int,»sƒt½[¦^_mm) desc,»sƒtID
    open cursor_Xuhao
    fetch next from cursor_Xuhao into @»sƒt/UNID
    while @@fetch_status=0
        begin
            update Temp set ±{…Q»sƒt^÷S=@±{…Q»sƒt^÷S where Åˆ±{÷S_¶g÷S=@ň±{÷S_¶g÷S and »sƒt/UNID=@»sƒt/UNID
            set @±{…Q»sƒt^÷S=@±{…Q»sƒt^÷S+1
            fetch next from cursor_Xuhao into @»sƒt/UNID
        end
    close cursor_Xuhao                  
    deallocate cursor_Xuhao
end
 
GO
/****** Object:  StoredProcedure [dbo].[Pro_Sum]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--¡‹—{P[±{…Q;`pe
create proc [dbo].[Pro_Sum]
as
begin
    --declare @ň±{÷S_¶g÷S nvarchar(100)
    declare @P[±{÷S nvarchar(100)
    declare cursor1 cursor for 
    --select distinct P[±{÷S from ##Temp 
    select distinct P[±{÷S from Temp 
    open cursor1
    fetch next from cursor1 into @P[±{÷S
    while @@fetch_status=0
        begin
        --select sum(item_quantity) from Table_Name1 where Åˆ±{÷S_¶g÷S='' 
        update Temp set ±{…Q»sƒt;`pe=(select COUNT(*) from Temp where P[±{÷S=@P[±{÷S) where P[±{÷S=@P[±{÷S    
        fetch next from cursor1 into @P[±{÷S  
        end
close cursor1                  
deallocate cursor1
end
 
 
GO
/****** Object:  StoredProcedure [dbo].[Pro_SumOut]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[Pro_SumOut]
as
begin
    declare @P[±{÷S nvarchar(100)
    declare cursor6 cursor for 
    select distinct P[±{÷S from glassOut2 
    open cursor6
    fetch next from cursor6 into @P[±{÷S
    while @@fetch_status=0
        begin
            if (select MAX(CONVERT(int,ŸS±{…Q^÷S)) from glassOut2 where P[±{÷S=@P[±{÷S)>0  --    g^÷S„v
                begin                                        
                    if(select top(1) count(*) from glassOut2 where P[±{÷S=@P[±{÷S group by ŸS±{…Q^÷S having count(*)>1 order by count(*) desc)>0
                        begin
                            --RWY
                            update glassOut2 set ±{…Q»sƒt^÷S=0 where P[±{÷S=@P[±{÷S                            
                            exec proc_Xuhao @P[±{÷S
                        end
                end
            else  --àe^÷S„v
                begin
                    exec proc_Xuhao @P[±{÷S
                end
            update glassOut2 set ±{…Q»sƒt;`pe=(select COUNT(*) from glassOut2 where P[±{÷S=@P[±{÷S) where P[±{÷S=@P[±{÷S        
            --select sum(item_quantity) from Table_Name1 where Åˆ±{÷S_¶g÷S='' 
            --update glassOut set ±{…Q»sƒt;`pe=(select COUNT(*) from glassOut where P[±{÷S=@P[±{÷S) where P[±{÷S=@P[±{÷S    
            fetch next from cursor6 into @P[±{÷S  
        end
    close cursor6                  
    deallocate cursor6
    --YtŒ[b  ûm RۏúQGrhˆ
    insert into glassOut(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S) 
    select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S from glassOut2 
    
    insert into glassOut3(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S,úQGröeô•) 
    select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S,getdate() from glassOut2 
    delete glassOut2
end
 
 
GO
/****** Object:  StoredProcedure [dbo].[Pro_Type]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--¡‹—{™e¶g{|‹W
CREATE proc [dbo].[Pro_Type]
as
begin
--select * from ##Temp where item_width>@Str_width
--    c½[¦^š[INÏköN»sƒt„v{|‹W\ŽN400:N1,400-600:N2,600-800:N3,800åN
N:N5
    update Temp set RackTypeID=1 where »sƒt½[¦^_mm<400.00 
    update Temp set RackTypeID=2 where »sƒt½[¦^_mm between 400 and 651
    update Temp set RackTypeID=3 where »sƒt½[¦^_mm between 652 and 850
    update Temp set RackTypeID=5 where »sƒt½[¦^_mm>850
end
 
GO
/****** Object:  StoredProcedure [dbo].[Pro_Update_BoxID]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--¡‹—{ň±{÷S   x<h_ JYC-
CREATE proc [dbo].[Pro_Update_BoxID]
@BoxNum int   -- OÂSpe Åˆ±{÷S;`pe
as
begin
--@OrdersID @b    g¢‹US÷S  @BoxID@b    g„vň±{÷S
    declare @OrdersID nvarchar(100)
    declare @BoxID nvarchar(100)
    declare @BoxBOXX nvarchar(100)
    declare cursor1 cursor for 
    select ¢‹US÷S,ň±{÷S_¶g÷S from Temp group by Åˆ±{÷S_¶g÷S,¢‹US÷S
    open cursor1
    fetch next from cursor1 into @OrdersID,@BoxID;
    --set @BoxNum=1;
    while @@fetch_status=0
        begin 
            --‚Yœgň±{÷Sò]Ï~ 0R¾ 999999R͑°e1_ËY
            if(@BoxNum>9999999 or @BoxNum=0)
                begin
                    set @BoxNum=1
                end
            if ((@BoxID is not null) and (@BoxID!='') and (@BoxID!=0))
                begin
                    set @BoxBOXX='JYC-'+CONVERT(nvarchar,@BoxNum)
                end
            else
                begin
                    set @BoxBOXX='JYC\'+CONVERT(nvarchar,@BoxNum)
                end
            --îO9e4Nöehˆ-N TN¢‹US  TNň±{÷S   Šbň±{÷S  9e:NNG+@BoxNum
            update Temp set Åˆ±{÷S_¶g÷S=@BoxBOXX,number=@BoxNum where ¢‹US÷S=@OrdersID and Åˆ±{÷S_¶g÷S=@BoxID
            --exec Pro_InsertXuhao @BoxBOXX   --R^÷S
            exec Pro_ChildBox @BoxBOXX        --RP[±{÷S
            set @BoxNum=@BoxNum+1;
            fetch next from cursor1 into @OrdersID,@BoxID
        end
    close cursor1                
    deallocate cursor1
end
 
 
GO
/****** Object:  StoredProcedure [dbo].[proc_aa]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create proc [dbo].[proc_aa]
as
begin
    declare @g'Y±{…Qpeϑ int
    declare @ň±{÷S nvarchar(50)
    declare @P[±{÷S nvarchar(50)
    
    declare @ò]0RGrpe int
    declare @±{…Q»sƒt;`pe int
    select [ň±{÷Sÿ¶g÷S    ÿ],P[±{÷S,count(*),±{…Q»sƒt;`pe,[»sƒtšS¦^ÿmm    ÿ] from storage group by P[±{÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,[»sƒtšS¦^ÿmm    ÿ]
    open cursor2
    fetch next from cursor2 into @ň±{÷S,@P[±{÷S,@ò]0RGrpe,@±{…Q»sƒt;`pe
    while @@fetch_status=0
        begin
            --print(@šS¦^)        
            fetch next from cursor2 into @ň±{÷S,@P[±{÷S,@ò]0RGrpe,@±{…Q»sƒt;`pe
        end
        close cursor2                   --sQí•8nh
        deallocate cursor2
end
GO
/****** Object:  StoredProcedure [dbo].[proc_ChuPian]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[proc_ChuPian]
@P[±{÷SúQ nvarchar(100)
as
begin
    ------_ËYM†SP[±{ hQèSbS
    declare @»sƒt/UNID nvarchar(255)            --hˆ:y»sƒt/UNID
    declare @Number int                            --hˆ:y,{àQGr
    declare @Count int                            --hˆ:y,{àQ*N±{
    declare @Box_childID nvarchar(50)           --°eP[±{÷S
    set @Number=1
    set @Count=(select MAX(±{pe) from Order$ where P[±{÷S=@P[±{÷SúQ)+1
    declare cursor_TaGlassId cursor for
    select »sƒt/UNID from storage where P[±{÷S=@P[±{÷SúQ order by CONVERT(int,rackID) desc,™e¶g
N„v^÷S desc
    open cursor_TaGlassId
    fetch next from cursor_TaGlassId into @»sƒt/UNID
        while @@fetch_status=0
            begin
                if(@Number<=50)
                        begin
                            set @Box_childID=@P[±{÷SúQ+'-'+CONVERT(nvarchar,@Count)
                            set @Number=@Number+1
                            insert into glassOut2(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S) 
                            select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S from storage 
                            where P[±{÷S=@P[±{÷SúQ and »sƒt/UNID=@»sƒt/UNID
                            update Order$ set ±{pe=@Count where P[±{÷S=@P[±{÷SúQ and »sƒt/UNID=@»sƒt/UNID
                            update glassOut2 set P[±{÷S=@Box_childID where P[±{÷S=@P[±{÷SúQ and »sƒt/UNID=@»sƒt/UNID
                        end
                    else 
                        begin
                            set @Count=@Count+1
                            set @Number=2
                            set @Box_childID=@P[±{÷SúQ+'-'+CONVERT(nvarchar,@Count)
                            insert into glassOut2(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S) 
                            select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S from storage 
                            where P[±{÷S=@P[±{÷SúQ and »sƒt/UNID=@»sƒt/UNID
                            update Order$ set ±{pe=@Count where P[±{÷S=@P[±{÷SúQ and »sƒt/UNID=@»sƒt/UNID
                            update glassOut2 set P[±{÷S=@Box_childID where P[±{÷S=@P[±{÷SúQ and »sƒt/UNID=@»sƒt/UNID    
                        end
                fetch next from cursor_TaGlassId into @»sƒt/UNID
            end
        close cursor_TaGlassId                   --sQí•8nhcursor_TaGlassId
        deallocate cursor_TaGlassId
end
GO
/****** Object:  StoredProcedure [dbo].[proc_ChupianType1]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[proc_ChupianType1]
@ň±{÷S nvarchar(50)
as
begin
    declare @P[±{÷S nvarchar(50)
    declare @±{…Q»sƒt;`pe int
    declare @P[±{…Qg'YšS¦^ nvarchar(50)
    declare @ò]0RGrpe int
    declare @g'Y±{…Qpeϑ int
    declare cursor_MyBox cursor for
    select P[±{÷S,±{…Q»sƒt;`pe,MAX([»sƒtšS¦^ÿmm    ÿ]),count(*) from storage where [ň±{÷Sÿ¶g÷S    ÿ]=@ň±{÷S group by P[±{÷S,±{…Q»sƒt;`pe
    open cursor_MyBox
    fetch next from cursor_MyBox into @P[±{÷S,@±{…Q»sƒt;`pe,@P[±{…Qg'YšS¦^,@ò]0RGrpe
    --M†SP[±{÷S Yt
    while @@fetch_status=0
        begin
            declare @»sƒt/UNID2 nvarchar(255)            --hˆ:y»sƒt/UNID
            declare @Grpe int    --hˆ:y,{àQGr
            declare @±{pe int    --hˆ:y,{àQ*N±{
            declare @°eP[±{÷S nvarchar(50)              --°eP[±{÷S
            if(@P[±{…Qg'YšS¦^='10')
                begin
                    set @g'Y±{…Qpeϑ=45
                end
            else if(@P[±{…Qg'YšS¦^='6')
                begin
                    set @g'Y±{…Qpeϑ=60
                end
            else if(@P[±{…Qg'YšS¦^='5')
                begin
                    set @g'Y±{…Qpeϑ=70
                end
            else
                begin
                    set @g'Y±{…Qpeϑ=50
                end
            --án³N±{agöN
            if(@ò]0RGrpe>=@g'Y±{…Qpeϑ)
                begin
                    set @Grpe=0
                    set @±{pe=(select MAX(±{pe) from Order$ where P[±{÷S=@P[±{÷S)+1
                    declare cursor_MyGlass_id cursor for
                    select »sƒt/UNID from storage 
                    where P[±{÷S=@P[±{÷S and »sƒt/UNID not in (select »sƒt/UNID from glassOut2 group by »sƒt/UNID) order by CONVERT(int,rackID) desc,™e¶g
N„v^÷S desc
                    open cursor_MyGlass_id
                    fetch next from cursor_MyGlass_id into @»sƒt/UNID2
                    while @@fetch_status=0
                        begin
                            if(@Grpe=@g'Y±{…Qpeϑ)
                                begin
                                    break
                                end
                            else if(@Grpe<50)
                                begin
                                    set @°eP[±{÷S=@P[±{÷S+'-'+CONVERT(nvarchar,@±{pe)
                                    set @Grpe=@Grpe+1
                                    insert into glassOut2(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S) 
                                    select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S from storage 
                                    where P[±{÷S=@P[±{÷S and »sƒt/UNID=@»sƒt/UNID2
                                    update glassOut2 set P[±{÷S=@°eP[±{÷S where »sƒt/UNID=@»sƒt/UNID2
                                    update Order$ set ±{pe=@±{pe where P[±{÷S=@P[±{÷S and »sƒt/UNID=@»sƒt/UNID2
                                end
                            else
                                begin
                                    if (@Grpe=50)
                                        begin
                                            set @±{pe=@±{pe+1
                                        end        
                                    set @°eP[±{÷S=@P[±{÷S+'-'+CONVERT(nvarchar,@±{pe)
                                    set @Grpe=@Grpe+1
                                    insert into glassOut2(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S) 
                                    select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S from storage 
                                    where P[±{÷S=@P[±{÷S and »sƒt/UNID=@»sƒt/UNID2
                                    update glassOut2 set P[±{÷S=@°eP[±{÷S where »sƒt/UNID=@»sƒt/UNID2
                                    update Order$ set ±{pe=@±{pe where P[±{÷S=@P[±{÷S and »sƒt/UNID=@»sƒt/UNID2
                                end
                            fetch next from cursor_MyGlass_id into @»sƒt/UNID2
                        end
                    close cursor_MyGlass_id                   --sQí•8nhcursor_MyGlass_id
                    deallocate cursor_MyGlass_id
                    break
                end
            else if((@±{…Q»sƒt;`pe-(select count(*) from Order$ where P[±{÷S=@P[±{÷S and ±{pe>0))=@ò]0RGrpe) --àe±{÷S ÿ±{…Q;`pe\ŽN50 Töeò]Ï~0R¾„v
                begin
                    if(@ò]0RGrpe<=50)          --àe±{÷S    g^÷S ÿ„˜YtŒ[b„vÿpeϑ<50    ÿ  gTNyb„vöeP
                        begin
                        set @±{pe=(select MAX(±{pe) from Order$ where P[±{÷S=@P[±{÷S)+1
                        set @°eP[±{÷S=@P[±{÷S+'-'+CONVERT(nvarchar,@±{pe)
                        insert into glassOut2(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S) 
                        select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S from storage 
                        where P[±{÷S=@P[±{÷S
                        update glassOut2 set P[±{÷S=@°eP[±{÷S where P[±{÷S=@P[±{÷S
                        --update Order$ set ±{pe=@±{pe where P[±{÷S=@P[±{÷S
                        end
                    else
                        begin
                            set @Grpe=0
                            set @±{pe=(select MAX(±{pe) from Order$ where P[±{÷S=@P[±{÷S)+1
                            declare cursor_MyGlass_id2 cursor for
                            select »sƒt/UNID from storage 
                            where P[±{÷S=@P[±{÷S and »sƒt/UNID not in (select »sƒt/UNID from glassOut2 group by »sƒt/UNID) order by CONVERT(int,rackID) desc,™e¶g
N„v^÷S desc
                            open cursor_MyGlass_id2
                            fetch next from cursor_MyGlass_id2 into @»sƒt/UNID2
                            while @@fetch_status=0
                                begin
                                    if(@Grpe<50)
                                        begin
                                            set @°eP[±{÷S=@P[±{÷S+'-'+CONVERT(nvarchar,@±{pe)
                                            set @Grpe=@Grpe+1
                                            insert into glassOut2(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S) 
                                            select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S from storage 
                                            where P[±{÷S=@P[±{÷S and »sƒt/UNID=@»sƒt/UNID2
                                            update glassOut2 set P[±{÷S=@°eP[±{÷S where »sƒt/UNID=@»sƒt/UNID2
                                            update Order$ set ±{pe=@±{pe where P[±{÷S=@P[±{÷S and »sƒt/UNID=@»sƒt/UNID2
                                        end
                                    else
                                        begin
                                            set @±{pe=@±{pe+1
                                            set @°eP[±{÷S=@P[±{÷S+'-'+CONVERT(nvarchar,@±{pe)
                                            set @Grpe=@Grpe+1
                                            insert into glassOut2(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S) 
                                            select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S from storage 
                                            where P[±{÷S=@P[±{÷S and »sƒt/UNID=@»sƒt/UNID2
                                            update glassOut2 set P[±{÷S=@°eP[±{÷S where »sƒt/UNID=@»sƒt/UNID2
                                            update Order$ set ±{pe=@±{pe where P[±{÷S=@P[±{÷S and »sƒt/UNID=@»sƒt/UNID2
                                        end
                                fetch next from cursor_MyGlass_id2 into @»sƒt/UNID2
                                end
                            close cursor_MyGlass_id2                   --sQí•8nhcursor_MyGlass_id2
                            deallocate cursor_MyGlass_id2
                        end    
                    break
                end
            fetch next from cursor_MyBox into @P[±{÷S,@±{…Q»sƒt;`pe,@P[±{…Qg'YšS¦^,@ò]0RGrpe
        end
    close cursor_MyBox                   
    deallocate cursor_MyBox           --sQí•8nhcursor_MyBox
end
 
GO
/****** Object:  StoredProcedure [dbo].[proc_ChupianType2]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[proc_ChupianType2]
@ň±{÷S nvarchar(100)
as
begin
    declare @úQP[±{÷S nvarchar(50)
    declare @ò]0RGrpe2 int
    declare cursor_TaBox2 cursor for
    select úQP[±{÷S,count(*) from storage where [ň±{÷Sÿ¶g÷S    ÿ]=@ň±{÷S group by úQP[±{÷S
    open cursor_TaBox2
    fetch next from cursor_TaBox2 into @úQP[±{÷S,@ò]0RGrpe2
    while @@fetch_status=0
        begin
            --ò]0Rpeϑ==±{…Q»sƒt;`pe
            if((select count(*) from Order$ where úQP[±{÷S=@úQP[±{÷S)=@ò]0RGrpe2)
                begin
                    insert into glassOut2(^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S) 
                    select ^÷S,¢[7bãN÷S,¤N'åeg,¢‹US÷S,[ň±{÷Sÿ¶g÷S    ÿ],±{…Q»sƒt;`pe,WY÷S,WY…Q»sƒt;`pe,»sƒtID,[»sƒt•¦^ÿmm    ÿ],[»sƒt½[¦^ÿmm    ÿ],[»sƒtšS¦^ÿmm    ÿ],RackTypeID,rackID,™e¶g
N„všS¦^,™e¶g
N„v^÷S,±{…Q»sƒt^÷S,ö€«WšS¦^,P[±{÷S,»sƒt/UNID,ŸSň±{÷S,ŸS±{…Q^÷S from storage 
                    where úQP[±{÷S=@úQP[±{÷S
                end
            ------hQèSbSŒ[b
            fetch next from cursor_TaBox2 into @úQP[±{÷S,@ò]0RGrpe2
        end
    close cursor_TaBox2                   
    deallocate cursor_TaBox2           --sQí•8nhcursor_TaBox2
end
GO
/****** Object:  StoredProcedure [dbo].[proc_Xuhao]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[proc_Xuhao]
@P[±{÷S nvarchar(100)
as
begin
    --ûm R^÷S
    declare @»sƒt/UNID nvarchar(100)
    declare @^÷S nvarchar(100)
    set @^÷S=1
    declare cursor_GlassOutXu cursor for
    select »sƒt/UNID from glassOut2 where P[±{÷S=@P[±{÷S order by ŸS±{…Q^÷S asc,[»sƒt½[¦^ÿmm    ÿ] desc,»sƒtID 
    open cursor_GlassOutXu
    fetch next from cursor_GlassOutXu into @»sƒt/UNID
    while @@fetch_status=0
        begin                        
            update glassOut2 set ±{…Q»sƒt^÷S=@^÷S where P[±{÷S=@P[±{÷S and »sƒt/UNID=@»sƒt/UNID
            set @^÷S=@^÷S+1
            fetch next from cursor_GlassOutXu into @»sƒt/UNID  
        end
    close cursor_GlassOutXu                  
    deallocate cursor_GlassOutXu
end
GO
/****** Object:  StoredProcedure [dbo].[proc_Zong]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[proc_Zong]
as 
begin
    if ((select count(*) from glassOut)=0)--åg wúQGrhˆ/f&Tò]    gpenc
        begin
            declare @ň±{÷S nvarchar(50)
            declare cursor_All cursor for
            select [ň±{÷Sÿ¶g÷S    ÿ] from storage group by [ň±{÷Sÿ¶g÷S    ÿ]
            open cursor_All
            fetch next from cursor_All into @ň±{÷S
            --_ËYM†S@b    g„vň±{÷S
            while @@fetch_status=0             
                begin
                    --ÖNìN„vň±{÷S án†NúQ
                    if((select PATINDEX('%JYC-%',@ň±{÷S))>0 and (select count(*) from Order$ where [ň±{÷Sÿ¶g÷S    ÿ]=@ň±{÷S)=(select count(*) from storage where [ň±{÷Sÿ¶g÷S    ÿ]=@ň±{÷S))
                        begin
                            declare @P[±{÷S nvarchar(50)
                            declare @±{…Q»sƒt;`pe int
                            declare @ò]0RGrpe int
                            declare cursor_TaBox cursor for
                            select P[±{÷S,±{…Q»sƒt;`pe,count(*) from storage where [ň±{÷Sÿ¶g÷S    ÿ]=@ň±{÷S group by P[±{÷S,±{…Q»sƒt;`pe
                            open cursor_TaBox
                            fetch next from cursor_TaBox into @P[±{÷S,@±{…Q»sƒt;`pe,@ò]0RGrpe
                            while @@fetch_status=0
                                begin
                                    exec proc_ChuPian @P[±{÷S
                                    ------hQèSbSŒ[b
                                    fetch next from cursor_TaBox into @P[±{÷S,@±{…Q»sƒt;`pe,@ò]0RGrpe
                                end
                            close cursor_TaBox                   
                            deallocate cursor_TaBox           --sQí•8nhcursor_MyBox
                            break   --úQGr
                        end
                    --bìN„vň±{÷S
                    else if((select PATINDEX('%JYC\%',@ň±{÷S))>0)
                        begin                        
                            if (select count(*) from Order$ where [ň±{÷Sÿ¶g÷S    ÿ]=@ň±{÷S and úQP[±{÷S is not null)>0
                                begin
                                    exec proc_ChupianType2 @ň±{÷S          --!j_2
                                end
                            else   
                                begin                                
                                    exec proc_ChupianType1 @ň±{÷S            --!j_1                     
                                end
                        end    
                    if ((select count(*) from glassOut2)!=0)--åg wúQGrhˆ/f&Tò]    gpenc
                        begin
                            break
                        end
                    fetch next from cursor_All into @ň±{÷S
                end
                close cursor_All                   
            deallocate cursor_All     --sQí•8nhcursor_All
            
            exec Pro_SumOut           --¡‹—{úQGrhˆP[±{…Q;`pe  v^ûm RۏúQGrhˆ                        
        end
end
GO
/****** Object:  DdlTrigger [OnTriggerDboSchema]    Script Date: 2023/12/11 8:45:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE trigger [OnTriggerDboSchema] ON database FOR create_table, create_view AS BEGIN   DECLARE @xmlEventData xml   SELECT    @xmlEventData = eventdata()   DECLARE @schemaName nvarchar(max)   DECLARE @objectName nvarchar(max)   DECLARE @DynSql nvarchar(max)      SET @schemaName    = convert(nvarchar(max), @xmlEventData.query('/EVENT_INSTANCE/SchemaName/text()'))   SET @objectName    = convert(nvarchar(max), @xmlEventData.query('/EVENT_INSTANCE/ObjectName/text()'))   IF(@schemaName='')   BEGIN     SET @DynSql = N'alter schema [dbo] transfer [' + @schemaName + N'].[' + @objectName + N']'     EXEC sp_executesql @statement=@DynSql   END END SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON 
GO
ENABLE TRIGGER [OnTriggerDboSchema] ON DATABASE
GO