廖井涛
2025-09-03 82bd97c5a0e05c936f62acf28ac4969b351b6d59
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
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.erp.mapper.pp.ReportMapper">
    <resultMap id="flowCardMap" type="com.example.erp.entity.pp.FlowCard">
        <result column="order_id" property="orderId"/>
        <result column="process_Id" property="processId"/>
        <result column="quantity" property="quantity"/>
        <result column="founder" property="founder"/>
        <result column="create_time" property="createTime"/>
        <result column="layout_status" property="layoutStatus"/>
        <!--接收其他外键实体类数据-->
        <association property="order" javaType="com.example.erp.entity.sd.Order">
            <result column="project" property="project"/>
            <result column="order_id" property="orderId"/>
            <result column="customer_name" property="customerName"/>
            <result column="batch" property="batch"/>
            <result column="other_remarks" property="otherRemarks"/>
            <result column="icon" property="icon"/>
            <result column="order_type" property="orderType"/>
            <result column="salesman" property="salesman"/>
            <result column="processing_note" property="processingNote"/>
            <result column="delivery_address" property="deliveryAddress"/>
        </association>
        <association property="orderDetail" javaType="com.example.erp.entity.sd.OrderDetail">
            <result column="product_id" property="productId"/>
            <result column="product_name" property="productName"/>
            <result column="compute_gross_area" property="computeGrossArea"/>
            <result column="processing_note" property="processingNote"/>
            <result column="quantity" property="quantity"/>
            <result column="compute_gross_area" property="computeGrossArea"/>
            <result column="perimeter" property="perimeter"/>
            <result column="order_number" property="orderNumber"/>
            <result column="width" property="width"/>
            <result column="height" property="height"/>
            <result column="shape" property="shape"/>
            <result column="weight" property="weight"/>
        </association>
        <association property="orderGlassDetail" javaType="com.example.erp.entity.sd.OrderGlassDetail">
            <result column="production_id" property="productionId"/>
        </association>
        <association property="product" javaType="com.example.erp.entity.sd.Product">
            <result column="total_thickness" property="totalThickness"/>
            <result column="thickness" property="thickness"/>
        </association>
 
        <!--<result column="g_typeId" property="glassTypes.typeId"/>
        <result column="g_type" property="glassTypes.type"/>-->
 
    </resultMap>
 
    <resultMap id="damageDetailsTableMap" type="com.example.erp.dto.pp.CrossProcessBreakingDTO">
        <result column="responsible_process" property="responsibleProcess"/>
        <result column="responsible_team" property="responsibleTeam"/>
        <result column="breakage_type" property="breakageType"/>
        <result column="breakage_reason" property="breakageReason"/>
        <result column="breakage_quantity" property="breakageQuantity"/>
        <result column="area" property="area"/>
        <result column="reporting_work_time" property="reportingWorkTime"/>
        <result column="this_process" property="thisProcess"/>
        <result column="project" property="project"/>
        <result column="order_id" property="orderId"/>
        <result column="glass_child" property="glassChild"/>
        <result column="process_id" property="processId"/>
        <result column="code" property="code"/>
    </resultMap>
 
 
    <resultMap id="reportMap" type="com.example.erp.entity.pp.Report">
        <result column="process_id" property="processId"/>
        <result column="customer_name" property="customerName"/>
        <result column="project" property="project"/>
        <result column="order_id" property="orderId"/>
        <result column="batch" property="batch"/>
        <result column="shape" property="shape"/>
        <result column="order_number" property="orderNumber"/>
        <result column="technology_number" property="technologyNumber"/>
        <result column="process" property="technologyFlow"/>
        <result column="quantity" property="orderNum"/>
        <result column="child_width" property="childWidth"/>
        <result column="child_height" property="childHeight"/>
        <result column="stockNum" property="stockNum"/>
        <result column="stockArea" property="stockArea"/>
        <result column="product_name" property="productName"/>
        <result column="bend_radius" property="bendRadius"/>
    </resultMap>
 
    <resultMap id="damageReportMap" type="com.example.erp.dto.pp.DamageReportDTO">
        <result column="order_id" property="orderId"/>
        <result column="reporting_work_time" property="reportingWorkTime"/>
        <result column="area" property="area"/>
        <result column="breakage_quantity" property="breakageQuantity"/>
        <result column="project" property="project"/>
        <result column="batch" property="batch"/>
        <result column="process_id" property="processId"/>
        <result column="order_number" property="orderNumber"/>
        <result column="technology_number" property="technologyNumber"/>
        <result column="responsible_process" property="responsibleProcess"/>
        <result column="responsible_team" property="responsibleTeam"/>
        <result column="responsible_equipment" property="responsibleEquipment"/>
        <result column="breakage_type" property="breakageType"/>
        <result column="breakage_reason" property="breakageReason"/>
        <result column="personnel" property="personnel"/>
        <result column="glass_child" property="glassChild"/>
        <result column="glassNumber" property="glassNumber"/>
        <result column="child_width" property="childWidth"/>
        <result column="child_height" property="childHeight"/>
    </resultMap>
 
    <resultMap id="teamOutputMap" type="com.example.erp.dto.pp.TeamOutputDTO">
        <result column="reporting_work_time" property="reportingWorkTime"/>
        <result column="this_process" property="thisProcess"/>
        <result column="teams_groups_name" property="teamsGroupsName"/>
        <result column="project" property="project"/>
        <result column="process_id" property="processId"/>
        <result column="order_number" property="orderNumber"/>
        <result column="width" property="width"/>
        <result column="height" property="height"/>
        <result column="shape" property="shape"/>
        <result column="thickness" property="thickness"/>
        <result column="edging_type" property="edgingType"/>
        <result column="completed_quantity" property="completedQuantity"/>
        <result column="area" property="area"/>
        <result column="product_name" property="productName"/>
        <result column="code" property="code"/>
        <result column="reviewed" property="reviewed"/>
        <result column="examine_time" property="examineTime"/>
        <result column="workProcessName" property="workProcessName"/>
        <result column="device_name" property="deviceName"/>
        <result column="order_type" property="orderType"/>
    </resultMap>
 
    <resultMap id="scheduleProductionScheduleMap" type="com.example.erp.dto.pp.ScheduleProductionScheduleDTO">
        <result column="order_id" property="orderId"/>
        <result column="project" property="project"/>
        <result column="processes" property="processes"/>
        <result column="scheduling_quantity" property="schedulingQuantity"/>
        <result column="notes" property="notes"/>
        <result column="scheduled_start_time" property="scheduledStartTime"/>
        <result column="plan_end_time" property="planEndTime"/>
    </resultMap>
 
    <resultMap id="workInProgressMap" type="com.example.erp.dto.pp.WorkInProgressDTO">
        <result column="thisProcess" property="thisProcess"/>
        <result column="order_id" property="orderId"/>
        <result column="process_id" property="processId"/>
        <result column="customer_name" property="customerName"/>
        <result column="project" property="project"/>
        <result column="batch" property="batch"/>
        <result column="order_number" property="orderNumber"/>
        <result column="technology_number" property="technologyNumber"/>
        <result column="shape" property="shape"/>
        <result column="process" property="process"/>
        <result column="quantity" property="quantity"/>
        <result column="child_width" property="childWidth"/>
        <result column="child_height" property="childHeight"/>
        <result column="stockNum" property="stockNum"/>
        <result column="stockArea" property="stockArea"/>
        <result column="product_name" property="productName"/>
        <result column="bend_radius" property="bendRadius"/>
        <result column="glassNumber" property="glassNumber"/>
        <result column="teams_groups_name" property="teamsGroupsName"/>
    </resultMap>
 
    <!--    流程卡进度-->
    <select id="processCardProgressMp">
        select a.product_name,
               b.glass_child,
               d.order_type,
               concat(c.process_id, '/', c.technology_number) as process_id,
               c.process_id as 'processId',
               c.order_id,
               c.order_number,
               c.technology_number,
               b.child_width,
               b.child_height,
              if(c.technology_number=1,c.quantity-ifnull(c.termination_quantity,0),0) as quantity,
 
               c.quantity-ifnull(c.termination_quantity,0) as thisQuantity,/*用于判断是否改变颜色*/
               e.reportWorkQuantity,
               e.reportWorkQuantityShow,
               e.reportWorkQuantityCount,
               e.reportWorkTime,
               e.broken_num,
               c.quantity-ifnull(c.termination_quantity,0) as glassQuantity,
 
               c.quantity-ifnull(c.termination_quantity,0) as quantityShow,
               round( (c.quantity-ifnull(c.termination_quantity,0))*a.compute_area,2) as grossAreaShow,
               ifnull(c.received_quantity, 0) as StorageShow,
               ifnull(dd.quantity, 0) as shippedQuantityShow, -- 发货数量
               round(ifnull(dd.quantity, 0)*a.compute_area,2) as shippedAreaShow, -- 发货面积
               round((ifnull(c.received_quantity, 0))*a.compute_area,2)  as StorageAreaShow,-- 入库面积
 
               if(c.technology_number=1, round((c.quantity-ifnull(c.termination_quantity,0))*a.compute_area,2),0) as grossArea,
               if(c.technology_number=1,ifnull(c.received_quantity, 0) ,0)                        as Storage,
               if(c.technology_number=1,ifnull(dd.quantity, 0) ,0)                          as shippedQuantity,
               if(c.technology_number=1,round(ifnull(dd.quantity, 0)*a.compute_area,2),0)         as shippedArea,
               if(c.technology_number=1, round((ifnull(c.received_quantity, 0))*a.compute_area,2),0)  as StorageArea,
 
 
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(a.other_columns, '$.S01')),'') AS glassNumber,
               b.`group`
 
        from pp.flow_card as c
                 left join
             sd.order_detail as a
             on c.order_id = a.order_id
                 and c.order_number = a.order_number
                 left join sd.order_glass_detail as b
                           on c.order_id = b.order_id
                               and b.order_number = c.order_number
                               and c.technology_number = b.technology_number
                 left join sd.`order` as d
                           on c.order_id = d.order_id
#                  left join mm.finished_goods_inventory as f
#                            on c.order_id = f.order_id and f.order_number = c.order_number
                 left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
                 left join (SELECT process_id,
                                   order_number,
                                   technology_number,
                                   sum(a.broken_num) as broken_num,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", if(technology_number!=1 and (bd.nickname='stepD' || bd.nickname='stepB' ) ,0,reporting_work_num), "\"")),
                                          '}'
                                       )             as reportWorkQuantity,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num, "\"")),
                                          '}'
                                       )             as reportWorkQuantityShow,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num_count, "\"")),
                                          '}'
                                       )             as reportWorkQuantityCount,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", IFNULL(date(update_time),''), "\"")),
                                          '}'
                                       )             as reportWorkTime
                            FROM sd.order_process_detail as a
                            left join (SELECT DISTINCT basic_name,nickname from sd.basic_data as bd where  bd.basic_category = 'process') as bd
                            on a.process = bd.basic_name
                            where a.order_id = #{orderId}
                            GROUP BY process_id, a.order_number, a.technology_number
 
 
                            ) as e
                           on e.process_id = c.process_id
                               and e.technology_number = c.technology_number
                               and e.order_number = c.order_number
        where a.order_id = #{orderId} and d.create_order>0 and c.quantity-ifnull(c.termination_quantity,0)>0
        group by c.order_number,
                 c.technology_number,
                 c.process_id
        order by c.process_id, c.order_number, c.technology_number
    </select>
 
    <select id="getProcessBreaking" resultMap="damageDetailsTableMap">
        select rw.reporting_work_id,
               rw.reporting_work_time,
               dd.responsible_process,
               dd.responsible_team,
               dd.breakage_type,
               dd.breakage_reason,
               ROUND((dd.breakage_quantity))                                                   as breakage_quantity,
               round(ogd.child_width * ogd.child_height * (dd.breakage_quantity) / 1000000, 2) as area,
               rw.this_process,
               o.project,
               o.order_id,
               ogd.glass_child,
               rw.this_process,
               JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
               CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id
        from
            sd.`order` as o left join sd.order_detail as od on o.order_id=od.order_id
                             left join sd.order_glass_detail as ogd on ogd.order_id=od.order_id and ogd.order_number=od.order_number
                             left join reporting_work as rw on rw.order_id=o.order_id
                             left join damage_details as dd on dd.reporting_work_id=rw.reporting_work_id and dd.order_number=ogd.order_number
            and dd.technology_number=ogd.technology_number
        where date(rw.reporting_work_time) >= #{startDate}
          and date(rw.reporting_work_time) &lt;= #{endDate}
          and rw.this_worn_quantity > 0
          and dd.available = 0
          and reviewed_state != 2
          and rw.this_process != dd.responsible_process
        and o.create_order>0
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) regexp #{crossProcessBreakingDTO.code}
        </if>
        <if test="crossProcessBreakingDTO.processId != null and crossProcessBreakingDTO.processId != ''">
            and rw.process_id regexp #{crossProcessBreakingDTO.processId}
        </if>
        <if test="crossProcessBreakingDTO.thisProcess != null and crossProcessBreakingDTO.thisProcess != ''">
            and rw.this_process regexp #{crossProcessBreakingDTO.thisProcess}
        </if>
        <if test="crossProcessBreakingDTO.responsibleProcess != null and crossProcessBreakingDTO.responsibleProcess != ''">
            and dd.responsible_process regexp #{crossProcessBreakingDTO.responsibleProcess}
        </if>
        <if test="crossProcessBreakingDTO.responsibleTeam != null and crossProcessBreakingDTO.responsibleTeam != ''">
            and dd.responsible_team regexp #{crossProcessBreakingDTO.responsibleTeam}
        </if>
        <if test="crossProcessBreakingDTO.glassChild != null and crossProcessBreakingDTO.glassChild != ''">
            and ogd.glass_child regexp #{crossProcessBreakingDTO.glassChild}
        </if>
        <if test="crossProcessBreakingDTO.breakageType != null and crossProcessBreakingDTO.breakageType != ''">
            and dd.breakage_type regexp #{crossProcessBreakingDTO.breakageType}
        </if>
        <if test="crossProcessBreakingDTO.project != null and crossProcessBreakingDTO.project != ''">
            and o.project regexp #{crossProcessBreakingDTO.project}
        </if>
        <if test="crossProcessBreakingDTO.orderId != null and crossProcessBreakingDTO.orderId != ''">
            and o.order_id regexp #{crossProcessBreakingDTO.orderId}
        </if>
        GROUP BY dd.id
        order by dd.id desc
        limit #{offset},#{pageSize}
    </select>
 
    <select id="getProcessBreakingTotal">
        select CEILING(count(dd.id) / #{pageSize}) as 'pageTotal',
               count(distinct dd.id)               as 'total'
        from damage_details as dd
                 left join reporting_work as rw
                           on rw.reporting_work_id = dd.reporting_work_id
                 left join sd.order as o
                           on rw.order_id = o.order_id
                 left join sd.order_glass_detail as ogd
                           on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
                               and ogd.technology_number and dd.technology_number
        where date(rw.reporting_work_time) >= #{startDate}
          and date(rw.reporting_work_time) &lt;= #{endDate}
          and rw.this_worn_quantity > 0
          and dd.available = 0
          and reviewed_state != 2
          and rw.this_process != dd.responsible_process
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) regexp #{crossProcessBreakingDTO.code}
        </if>
        <if test="crossProcessBreakingDTO.processId != null and crossProcessBreakingDTO.processId != ''">
            and rw.process_id regexp #{crossProcessBreakingDTO.processId}
        </if>
        <if test="crossProcessBreakingDTO.thisProcess != null and crossProcessBreakingDTO.thisProcess != ''">
            and rw.this_process regexp #{crossProcessBreakingDTO.thisProcess}
        </if>
        <if test="crossProcessBreakingDTO.responsibleProcess != null and crossProcessBreakingDTO.responsibleProcess != ''">
            and dd.responsible_process regexp #{crossProcessBreakingDTO.responsibleProcess}
        </if>
        <if test="crossProcessBreakingDTO.responsibleTeam != null and crossProcessBreakingDTO.responsibleTeam != ''">
            and dd.responsible_team regexp #{crossProcessBreakingDTO.responsibleTeam}
        </if>
        <if test="crossProcessBreakingDTO.glassChild != null and crossProcessBreakingDTO.glassChild != ''">
            and ogd.glass_child regexp #{crossProcessBreakingDTO.glassChild}
        </if>
        <if test="crossProcessBreakingDTO.breakageType != null and crossProcessBreakingDTO.breakageType != ''">
            and dd.breakage_type regexp #{crossProcessBreakingDTO.breakageType}
        </if>
        <if test="crossProcessBreakingDTO.project != null and crossProcessBreakingDTO.project != ''">
            and o.project regexp #{crossProcessBreakingDTO.project}
        </if>
        <if test="crossProcessBreakingDTO.orderId != null and crossProcessBreakingDTO.orderId != ''">
            and o.order_id regexp #{crossProcessBreakingDTO.orderId}
        </if>
        order by dd.id desc
    </select>
 
    <select id="workInProgressMp" resultMap="workInProgressMap">
        select #{selectProcesses} as thisProcess,
        fc.process_id,
        o.customer_name,
        o.project,
        o.order_id,
        o.batch,
        if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
        if(od.shape=2,JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')),od.bend_radius) as bend_radius,
        ogd.order_number,
        ogd.technology_number,
        ogd.process,
        od.quantity,
        ogd.child_width,
        ogd.child_height,
        odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num as stockNum,
        ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2) as stockArea,
        od.product_name,
        od.bend_radius,
        ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber,
        rws.teams_groups_name
 
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
                        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        <if test="workInProgressDTO.orderNumber != null and workInProgressDTO.orderNumber != ''">
            and ogd.order_number regexp #{workInProgressDTO.orderNumber}
        </if>
        <if test="workInProgressDTO.technologyNumber != null and workInProgressDTO.technologyNumber != ''">
            and ogd.technology_number regexp #{workInProgressDTO.technologyNumber}
        </if>
        <if test="workInProgressDTO.glassNumber != null and workInProgressDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{workInProgressDTO.glassNumber}
        </if>
        group by fc.process_id, fc.order_number, fc.technology_number
        order by fc.process_id, fc.order_number, fc.technology_number
        limit #{offset},#{pageSize};
    </select>
 
    <select id="workInProgressTotal">
        select CEILING(count(fc.id)/#{pageSize}) as 'pageTotal',
        count(distinct fc.id) as 'total'
 
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        <if test="workInProgressDTO.orderNumber != null and workInProgressDTO.orderNumber != ''">
            and ogd.order_number regexp #{workInProgressDTO.orderNumber}
        </if>
        <if test="workInProgressDTO.technologyNumber != null and workInProgressDTO.technologyNumber != ''">
            and ogd.technology_number regexp #{workInProgressDTO.technologyNumber}
        </if>
        limit #{offset},#{pageSize};
    </select>
 
    <select id="processToBeCompletedMp">
        select DATE(o.create_time)                                                  as create_time,
               DATE(o.delivery_date)                                                as delivery_date,
               o.order_id,
               fc.process_id,
               o.customer_name,
               o.project,
               o.batch,
               od.order_number,
               ogd.technology_number,
               ogd.glass_child,
               ogd.child_width,
               ogd.child_height,
               fc.quantity - ifnull(fc.termination_quantity,0) as quantity,
               ROUND(ogd.child_width * ogd.child_height / 1000000, 2)               as childArea,
               ROUND(ogd.child_width * ogd.child_height * (fc.quantity- ifnull(fc.termination_quantity,0)) / 1000000, 2) as actualArea,
               odpd.reporting_work_num                                              as completeNum,
               ROUND(ogd.child_width * ogd.child_height * odpd.reporting_work_num / 1000000,
                     2)                                                             as completeArea,
               fc.quantity - odpd.reporting_work_num - ifnull(fc.termination_quantity,0)      as incompleteNum,
               ROUND(ogd.child_width * ogd.child_height * (fc.quantity - odpd.reporting_work_num- ifnull(fc.termination_quantity,0)) / 1000000,
                     2)                                                             as incompleteArea,
               od.product_name
 
        from sd.order_detail AS od
                 LEFT JOIN sd.order_glass_detail AS ogd
                           ON od.order_id = ogd.order_id
                               AND od.order_number = ogd.order_number
                 LEFT JOIN flow_card AS fc
                           ON fc.order_id = ogd.order_id
                               and fc.production_id = ogd.production_id
                               AND fc.order_number = ogd.order_number
                               AND fc.technology_number = ogd.technology_number
                 left join sd.order_process_detail as odpd
                           ON odpd.order_id = fc.order_id
                               AND odpd.order_number = fc.order_number
                               AND odpd.technology_number = fc.technology_number
                               and odpd.process_id = fc.process_id
                 left join sd.`order` as o
                           on o.order_id = od.order_id
        where  o.create_order>0
          and odpd.process = #{selectProcesses}
          and  o.create_time >= #{selectTime1}
          AND o.create_time &lt;  #{selectTime2}
          and position(#{orderId} in od.order_id)
          and position(#{inputProject} in o.project)
          and GREATEST(fc.quantity - odpd.reporting_work_num, 0)>0
          and fc.quantity-ifnull(fc.termination_quantity,0)>0
 
        group by fc.process_id, fc.order_number, fc.technology_number
        order by fc.process_id, fc.order_number, fc.technology_number
    </select>
 
    <select id="selectDamageReportMp" resultMap="damageReportMap">
        SELECT
        o.order_id,
        o.project,
        o.batch,
        rw.process_id,
        dd.order_number,
        dd.technology_number,
        rw.reporting_work_time as reporting_work_time,
        dd.responsible_process,
        dd.responsible_team,
        dd.responsible_equipment,
        dd.breakage_type,
        dd.breakage_reason,
        dd.breakage_quantity,
        round( ogd.child_width * ogd.child_height * dd.breakage_quantity / 1000000, 2 ) as area,
        IFNULL(dd.responsible_personnel,'') as personnel,
        ogd.glass_child,
        ogd.child_width,
        ogd.child_height,
        ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber
        FROM
        sd.ORDER AS o
        LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
        LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
        LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
        AND dd.order_number = ogd.order_number
        AND dd.technology_number = ogd.technology_number
        left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
        WHERE
        rw.reporting_work_time >= #{selectTime1}
        AND rw.reporting_work_time &lt;  #{selectTime2}
 
        AND dd.available = 0 and rw.reviewed_state>=0
        <if test="damageReportDTO.orderId != null and damageReportDTO.orderId != ''">
            and o.order_id regexp #{damageReportDTO.orderId}
        </if>
        <if test="damageReportDTO.project != null and damageReportDTO.project != ''">
            and o.project regexp #{damageReportDTO.project}
        </if>
        <if test="damageReportDTO.processId != null and damageReportDTO.processId != ''">
            and rw.process_id regexp #{damageReportDTO.processId}
        </if>
        <if test="damageReportDTO.orderNumber != null and damageReportDTO.orderNumber != ''">
            and dd.order_number regexp #{damageReportDTO.orderNumber}
        </if>
        <if test="damageReportDTO.technologyNumber != null and damageReportDTO.technologyNumber != ''">
            and dd.technology_number regexp #{damageReportDTO.technologyNumber}
        </if>
        <if test="damageReportDTO.responsibleProcess != null and damageReportDTO.responsibleProcess != ''">
            and dd.responsible_process regexp #{damageReportDTO.responsibleProcess}
        </if>
        <if test="damageReportDTO.responsibleTeam != null and damageReportDTO.responsibleTeam != ''">
            and dd.responsible_team regexp #{damageReportDTO.responsibleTeam}
        </if>
        <if test="damageReportDTO.responsibleEquipment != null and damageReportDTO.responsibleEquipment != ''">
            and dd.responsible_equipment regexp #{damageReportDTO.responsibleEquipment}
        </if>
        <if test="damageReportDTO.breakageType != null and damageReportDTO.breakageType != ''">
            and dd.breakage_type regexp #{damageReportDTO.breakageType}
        </if>
        <if test="damageReportDTO.breakageReason != null and damageReportDTO.breakageReason != ''">
            and dd.breakage_reason regexp #{damageReportDTO.breakageReason}
        </if>
        <if test="damageReportDTO.glassChild != null and damageReportDTO.glassChild != ''">
            and ogd.glass_child regexp #{damageReportDTO.glassChild}
        </if>
        <if test="damageReportDTO.glassNumber != null and damageReportDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{damageReportDTO.glassNumber}
        </if>
        GROUP BY
        dd.id
        limit #{offset},#{pageSize};
    </select>
 
    <select id="getDamageReportPageTotal">
        SELECT
        CEILING(count(dd.id)/#{pageSize}) as 'pageTotal',
        count(distinct dd.id) as 'total'
        FROM
        sd.ORDER AS o
        LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
        LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
        LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
        AND dd.order_number = ogd.order_number
        AND dd.technology_number = ogd.technology_number
        WHERE
        rw.reporting_work_time >= #{selectTime1}
        AND rw.reporting_work_time &lt;  #{selectTime2}
        AND dd.available = 0
        <if test="damageReportDTO.orderId != null and damageReportDTO.orderId != ''">
            and o.order_id regexp #{damageReportDTO.orderId}
        </if>
        <if test="damageReportDTO.project != null and damageReportDTO.project != ''">
            and o.project regexp #{damageReportDTO.project}
        </if>
        <if test="damageReportDTO.processId != null and damageReportDTO.processId != ''">
            and rw.process_id regexp #{damageReportDTO.processId}
        </if>
        <if test="damageReportDTO.orderNumber != null and damageReportDTO.orderNumber != ''">
            and dd.order_number regexp #{damageReportDTO.orderNumber}
        </if>
        <if test="damageReportDTO.technologyNumber != null and damageReportDTO.technologyNumber != ''">
            and dd.technology_number regexp #{damageReportDTO.technologyNumber}
        </if>
        <if test="damageReportDTO.responsibleProcess != null and damageReportDTO.responsibleProcess != ''">
            and dd.responsible_process regexp #{damageReportDTO.responsibleProcess}
        </if>
        <if test="damageReportDTO.responsibleTeam != null and damageReportDTO.responsibleTeam != ''">
            and dd.responsible_team regexp #{damageReportDTO.responsibleTeam}
        </if>
        <if test="damageReportDTO.responsibleEquipment != null and damageReportDTO.responsibleEquipment != ''">
            and dd.responsible_equipment regexp #{damageReportDTO.responsibleEquipment}
        </if>
        <if test="damageReportDTO.breakageType != null and damageReportDTO.breakageType != ''">
            and dd.breakage_type regexp #{damageReportDTO.breakageType}
        </if>
        <if test="damageReportDTO.breakageReason != null and damageReportDTO.breakageReason != ''">
            and dd.breakage_reason regexp #{damageReportDTO.breakageReason}
        </if>
        <if test="damageReportDTO.glassChild != null and damageReportDTO.glassChild != ''">
            and ogd.glass_child regexp #{damageReportDTO.glassChild}
        </if>
        limit #{offset},#{pageSize};
    </select>
 
    <select id="splittingDetailsOutsideMp">
        SELECT fc.process_id                                                           processId,
               fc.order_number                                                         orderNumber,
               fc.technology_number                                                 as technologyNumber,
               o.project,
               o.batch,
               ogd.child_width                                                      as childWidth,
               ogd.child_height                                                     as childHeight,
               fc.quantity,
               round(ogd.child_width * ogd.child_height * fc.quantity / 1000000, 2) as area,
               if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
               od.remarks,
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS S01,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S02')) AS S02,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S03')) AS S03,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')) AS S04,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S05')) AS S05
        FROM
            flow_card as fc left join sd.order_glass_detail as ogd on ogd.order_id=fc.order_id and ogd.order_number=ogd.order_number and ogd.technology_number=fc.technology_number
                            left join sd.order_detail as od on od.order_id=fc.order_id and od.order_number=fc.order_number
                            left join sd.`order` as o on o.order_id=fc.order_id
        WHERE fc.order_id = #{orderId}
        GROUP BY fc.id
        order by fc.order_number,fc.technology_number
    </select>
 
    <select id="qualityReportMp">
        SELECT o.order_id,
               o.customer_name,
               o.project,
               fc.order_number,
               fc.technology_number,
               od.product_name,
               od.quantity,
               ifnull(MAX(opd.reporting_work_num_count), 0)                                        as quantityMax,
               IFNULL(SUM(distinct dd.breakage_quantity), 0)                                       as breakage_quantity,
               IFNULL(sum(distinct pl.patch_num), 0)                                               as patch_num,
               ifnull(fc.received_quantity, 0)                                                     as received_quantity,
               CONCAT(ROUND(ROUND(od.quantity / MAX(opd.reporting_work_num_count), 2) * 100), '%') as finished
        FROM sd.`order` AS o
                 LEFT JOIN sd.order_detail AS od ON od.order_id = o.order_id
 
                 LEFT JOIN flow_card AS fc ON o.order_id = fc.order_id
            AND fc.order_number = od.order_number
 
                 LEFT JOIN damage_details AS dd ON dd.process_id = fc.process_id
            AND dd.order_number = fc.order_number
            AND dd.technology_number = fc.technology_number
            and dd.available != 1
 
                 LEFT JOIN patch_log AS pl ON pl.order_id = fc.order_id
            AND pl.process_id = fc.process_id
            AND pl.order_sort = fc.order_number
            AND pl.technology_number = fc.technology_number
 
                 LEFT JOIN sd.order_process_detail AS opd ON opd.order_id = fc.order_id
            AND opd.order_number = fc.order_number
            AND opd.technology_number = fc.technology_number
 
        WHERE  DATE_FORMAT((o.create_time), '%Y-%m-%d') BETWEEN #{selectTime1} and #{selectTime2}
          and o.create_order>0
        GROUP BY o.order_id,
                 fc.order_number,
                 fc.technology_number
        ORDER BY fc.order_number
    </select>
 
    <select id="yieldMp">
        SELECT
        t.reporting_work_time,
        t.this_process as process,
        t.process_id,
        t.project,
        t.batch,
        SUM(t.completed_quantity) as completedQuantity,
        SUM(t.area) as completedArea,
        SUM(t.breakageQuantity) as breakageQuantity,
        SUM(t.breakageArea) as breakageArea,
        t.responsibleTeam,
        CONCAT(ROUND(ROUND(SUM(t.area)/(SUM(t.area) + SUM(t.breakageArea)),2)*100), '%') as finished,
        t.product_name
        FROM
        (
        SELECT
        rw.reporting_work_time,
        rw.this_process,
        o.project,
        o.batch,
        rw.process_id,
        rwd.completed_quantity AS completed_quantity,
        ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * rwd.completed_quantity / 1000000, 2) AS area,
        IFNULL(dd.breakage_quantity,0) as breakageQuantity,
        IFNULL(ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * dd.breakage_quantity / 1000000, 2),0) AS breakageArea,
        IFNULL(dd.responsible_team,'') as responsibleTeam,
        od.product_name
 
        FROM
        reporting_work AS rw
        LEFT JOIN reporting_work_detail AS rwd
        ON rwd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN damage_details as dd on dd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN flow_card AS fc
        ON fc.order_id = rw.order_id
        AND fc.process_id = rw.process_id
        AND fc.order_number = rwd.order_number
        AND fc.technology_number = rwd.technology_number
        LEFT JOIN sd.order_glass_detail AS ogd
        ON ogd.order_id = fc.order_id
        AND ogd.order_number = fc.order_number
        AND ogd.technology_number = fc.technology_number
        LEFT JOIN sd.order_detail AS od
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN sd.`order` AS o
        ON o.order_id = od.order_id
        WHERE
        o.create_order > 0
        AND rw.reviewed_state >= 0
        AND rwd.completed_quantity + IFNULL(dd.breakage_quantity,0)> 0
        AND rw.reporting_work_time &gt;= #{selectTime1}
        AND rw.reporting_work_time &lt; #{selectTime2}
        AND rw.this_process = #{selectProcesses}
        GROUP BY
        rw.reporting_work_id,
        rw.process_id,
        rw.this_process,
        rw.teams_groups_name,
        rwd.order_number,
        rwd.technology_number
        ) t
        GROUP BY
        t.reporting_work_time,
        t.this_process,
        t.process_id,
        t.responsibleTeam
        ORDER BY
        t.this_process,
        t.process_id,
        t.reporting_work_time
    </select>
 
    <select id="productionScheduleMp">
        select a.order_number,
               if(a.shape='' || ISNULL(a.shape),'普形',if(a.shape = 1, '普形', if(a.shape = 2, '异形', ''))) as shape,
               a.product_name,
               b.child_width,
               b.child_height,
               c.quantity - ifnull(c.termination_quantity,0) as quantity,
               c.technology_number,
               b.glass_child,
               ifnull(e.reportWorkQuantity, 0)                      as reportWorkQuantity,
               ifnull(e.reportWorkQuantityCount, 0)                 as reportWorkQuantityCount,
               ifnull(f.inventory, 0)                               as inventoryNum,
               round(ifnull(f.inventory, 0) * a.area, 2)            as inventoryArea,
               ifnull(dd.quantity, 0)                               as shippedQuantity,
               ifnull(dd.area, 0)                                   as area,
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(a.other_columns, '$.S01')),'') AS glassNumber
 
        from flow_card as c
                 left join
             sd.order_detail as a
             on c.order_id = a.order_id
                 and c.order_number = a.order_number
                 left join sd.order_glass_detail as b
                           on c.order_id = b.order_id
                               and b.order_number = c.order_number
                               and c.technology_number = b.technology_number
                 left join sd.`order` as d
                           on c.order_id = d.order_id
                 left join mm.finished_goods_inventory as f
                           on c.order_id = f.order_id and f.order_number = c.order_number
                 left join (SELECT process_id,
                                   order_number,
                                   technology_number,
                                   sum(a.broken_num) as broken_num,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num, "\"")),
                                          '}'
                                       )             as reportWorkQuantity,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num_count, "\"")),
                                          '}'
                                       )             as reportWorkQuantityCount
                            FROM sd.order_process_detail as a
                            where a.order_id = #{orderId}
                            GROUP BY process_id, a.order_number,a.technology_number) as e
                           on e.process_id = c.process_id
                                and   e.order_number=c.order_number
                               and e.technology_number = c.technology_number
                 left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
        where a.order_id = #{orderId} and d.create_order>0 and c.quantity - ifnull(c.termination_quantity,0)>0
        group by c.order_number,c.technology_number
        ORDER BY a.order_number
    </select>
 
    <select id="taskCompletionStatusMp">
        select d.customer_name as customerName,
               d.project,
               d.batch,
               c.order_id      as orderId,
               d.quantity,
               d.area,
               dd.quantity     as shippedQuantity,
               dd.area         as shippedArea,
               e.reportWorkQuantity,
               e.reportWorkQuantityCount
 
        from sd.`order` as d
                 left join flow_card as c on c.order_id = d.order_id
                 left join
             sd.order_detail as a
             on c.order_id = a.order_id
                 and c.order_number = a.order_number
                 left join sd.order_glass_detail as b
                           on c.order_id = b.order_id
                               and b.order_number = c.order_number
                               and c.technology_number = b.technology_number
                 left join mm.finished_goods_inventory as f
                           on c.order_id = f.order_id and f.order_number = c.order_number
                 left join (SELECT process_id,
                                   technology_number,
                                   sum(a.broken_num) as broken_num,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num, 0), "\"")),
                                          '}'
                                       )             as reportWorkQuantity,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num, 0), "\"")),
                                          '}'
                                       )             as reportWorkQuantityCount
                            FROM sd.order_process_detail as a
                                     left join sd.`order` as o on o.order_id = a.order_id
                            where    o.create_time >= #{selectTime1}
                              AND o.create_time &lt;  #{selectTime2}
                              and position(#{orderId} in o.order_id)
                            GROUP BY process_id, a.technology_number) as e
                           on e.process_id = c.process_id
                               and e.technology_number = c.technology_number
                 left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
        where   d.create_time >= #{selectTime1}
          AND d.create_time &lt;  #{selectTime2}
          and position(#{orderId} in a.order_id)
          and d.create_order>0
          and reportWorkQuantity is not null
        GROUP BY a.order_id
        ORDER BY a.order_id
    </select>
 
    <select id="orderPlanDecompositionMp">
        SELECT o.order_id,
               o.customer_name,
               o.project,
               o.batch,
               o.quantity,
               o.area,
               date(fc.create_time)                                 as create_time,
               date(orw.startTime)                                  as startTime,
               ifnull(oopd.completionsNum, 0)                       as completionsNum,
               sum(DISTINCT fc.received_quantity)                   AS received_quantity,
               o.quantity - sum(DISTINCT fc.received_quantity)      AS receivedNo,
               IF(fc.quantity = fc.received_quantity, '已清单', '') as accomplish,
               DATEDIFF(
                       MAX(rw.reporting_work_time),
                       min(rw.reporting_work_time)) + 1             AS daysDifference
        FROM sd.`order` AS o
                 LEFT JOIN flow_card AS fc ON fc.order_id = o.order_id
                 LEFT JOIN (SELECT a.order_id,
                                   MIN(b.reporting_work_time) AS startTime
                            FROM sd.`order` AS a
                                     LEFT JOIN reporting_work AS b ON a.order_id = b.order_id
                            WHERE b.this_process = '切割'
            and  a.create_time >= #{selectTime1}
            AND a.create_time &lt;  #{selectTime2}
                            GROUP BY a.order_id) AS orw ON orw.order_id = o.order_id
                 LEFT JOIN (SELECT a.order_id,
                                   SUM(b.reporting_work_num) AS completionsNum
                            FROM sd.`order` AS a
                                     LEFT JOIN sd.order_process_detail AS b ON a.order_id = b.order_id
                            WHERE b.process = '包装'
            and  a.create_time >= #{selectTime1}
            AND a.create_time &lt;  #{selectTime2}
                            GROUP BY a.order_id) AS oopd ON oopd.order_id = o.order_id
                 LEFT JOIN reporting_work AS rw ON rw.order_id = fc.order_id
            AND rw.process_id = fc.process_id
        WHERE    o.create_time >= #{selectTime1}
          AND o.create_time &lt;  #{selectTime2}
          and o.create_order>0
          AND fc.create_time IS NOT NULL
        GROUP BY o.order_id
    </select>
 
    <select id="orderReportingWorks">
        SELECT *
        from sd.order_process_detail opd left join sd.`order` o on o.order_id=opd.order_id
        where    o.create_time >= #{selectTime1}
          and o.create_time &lt;  #{selectTime2}
        and opd.reporting_work_num_count>0
        group by opd.order_id
        order by opd.order_id
    </select>
 
    <select id="rawMaterialRequisitionMp">
        SELECT fc.project_no,
               modl.material_name,
               modl.producer,
               ou.width,
               ou.height,
               modl.date_of_manufacture,
               SUM(distinct modl.outbound_quantity)                                as quantity,
               ROUND(SUM(modl.outbound_quantity) * SUM(modl.single_piece_area), 2) as area,
               date(mo.material_requisition_date)                                  as date
        FROM mm.material_outbound_detail AS modl
                 left join mm.material_outbound as mo on mo.material_outbound_id = modl.material_outbound_id
                 LEFT JOIN optimize_use AS ou ON modl.use_id = ou.id and ou.raw_stock_code = modl.inventory_id
                 LEFT JOIN flow_card AS fc ON ou.project_no = fc.project_no
        where modl.use_id IS NOT NULL
          and  DATE_FORMAT((mo.material_requisition_date), '%Y-%m-%d') BETWEEN #{selectTime1} and #{selectTime2}
        GROUP BY ou.width, ou.height, material_code
    </select>
 
    <select id="exportCrossProcessBreakingMp">
        select rw.reporting_work_id,
               rw.reporting_work_time,
               dd.responsible_process,
               dd.responsible_team,
               dd.breakage_type,
               dd.breakage_reason,
               ROUND((dd.breakage_quantity))                                                   as breakage_quantity,
               round(ogd.child_width * ogd.child_height * (dd.breakage_quantity) / 1000000, 2) as area,
               rw.this_process,
               o.project,
               o.order_id,
               ogd.glass_child
        from damage_details as dd
                 left join reporting_work as rw
                           on rw.reporting_work_id = dd.reporting_work_id
                 left join sd.order as o
                           on rw.order_id = o.order_id
                 left join sd.order_glass_detail as ogd
                           on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
                               and ogd.technology_number and dd.technology_number
        where date(rw.reporting_work_time) >= #{dates[0]}
          and date(rw.reporting_work_time) &lt;= #{dates[1]}
          and rw.this_worn_quantity > 0
          and dd.available = 0
          and reviewed_state != 2
          and rw.this_process != dd.responsible_process
        GROUP BY dd.id
        order by dd.id desc
    </select>
 
    <select id="exportDamageReportMp">
        SELECT o.order_id,
               o.project,
               o.batch,
               rw.process_id,
               dd.order_number,
               dd.technology_number,
               date(rw.reporting_work_time)                                                  as reporting_work_time,
               dd.responsible_process,
               dd.responsible_team,
               dd.responsible_equipment,
               dd.breakage_type,
               dd.breakage_reason,
               dd.breakage_quantity,
               round(ogd.child_width * ogd.child_height * dd.breakage_quantity / 1000000, 2) as area,
               IFNULL(dd.responsible_personnel, '')                                          as personnel,
               ogd.glass_child,
               ogd.child_width,
               ogd.child_height
        FROM sd.ORDER AS o
                 LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
                 LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
                 LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
            AND dd.order_number = ogd.order_number
            AND dd.technology_number = ogd.technology_number
        WHERE rw.reporting_work_time >= #{dates[0]}
          and rw.reporting_work_time &lt;= #{dates[1]}
          AND dd.available = 0 and rw.reviewed_state>=0
        GROUP BY dd.id
    </select>
 
    <select id="exportOrderPlanDecompositionMp">
        SELECT o.order_id,
               o.customer_name,
               o.project,
               o.batch,
               o.quantity,
               o.area,
               date(fc.create_time)                                 as create_time,
               date(orw.startTime)                                  as startTime,
               oopd.completionsNum,
               sum(DISTINCT fc.received_quantity)                   AS received_quantity,
               sum(DISTINCT fc.quantity - fc.received_quantity)     AS receivedNo,
               IF(fc.quantity = fc.received_quantity, '已清单', '') as accomplish,
               DATEDIFF(
                       MAX(rw.reporting_work_time),
                       min(rw.reporting_work_time)) + 1             AS daysDifference
        FROM sd.`order` AS o
                 LEFT JOIN flow_card AS fc ON fc.order_id = o.order_id
                 LEFT JOIN (SELECT a.order_id,
                                   MIN(b.reporting_work_time) AS startTime
                            FROM sd.`order` AS a
                                     LEFT JOIN reporting_work AS b ON a.order_id = b.order_id
                            WHERE b.this_process = '切割'
                              AND date(a.create_time) >= #{dates[0]}
                              and date(a.create_time) &lt;= #{dates[1]}
 
                            GROUP BY a.order_id) AS orw ON orw.order_id = o.order_id
                 LEFT JOIN (SELECT a.order_id,
                                   SUM(b.reporting_work_num) AS completionsNum
                            FROM sd.`order` AS a
                                     LEFT JOIN sd.order_process_detail AS b ON a.order_id = b.order_id
                            WHERE b.process = '包装'
                              AND date(a.create_time) >= #{dates[0]}
                              and date(a.create_time) &lt;= #{dates[1]}
                            GROUP BY a.order_id) AS oopd ON oopd.order_id = o.order_id
                 LEFT JOIN reporting_work AS rw ON rw.order_id = fc.order_id
            AND rw.process_id = fc.process_id
        WHERE date(o.create_time) >= #{dates[0]}
          and date(o.create_time) &lt;= #{dates[1]}
          and o.create_order>0
          AND fc.create_time IS NOT NULL
        GROUP BY o.order_id
    </select>
 
    <select id="exportProcessToBeCompletedMp">
        select DATE(o.create_time)                                                  as create_time,
               DATE(o.delivery_date)                                                as delivery_date,
               o.order_id,
               fc.process_id,
               o.customer_name,
               o.project,
               o.batch,
               od.order_number,
               ogd.technology_number,
               ogd.glass_child,
               ogd.child_width,
               ogd.child_height,
               od.quantity,
               ROUND(ogd.child_width * ogd.child_height / 1000000, 2)               as childArea,
               ROUND(ogd.child_width * ogd.child_height * od.quantity / 1000000, 2) as actualArea,
               odpd.reporting_work_num                                              as completeNum,
               ROUND(ogd.child_width * ogd.child_height * odpd.reporting_work_num / 1000000,
                     2)                                                             as completeArea,
               od.quantity - odpd.reporting_work_num                                as incompleteNum,
               ROUND(ogd.child_width * ogd.child_height * (od.quantity - odpd.reporting_work_num) / 1000000,
                     2)                                                             as incompleteArea,
               od.product_name
 
        from sd.order_detail AS od
                 LEFT JOIN sd.order_glass_detail AS ogd
                           ON od.order_id = ogd.order_id
                               AND od.order_number = ogd.order_number
                 LEFT JOIN flow_card AS fc
                           ON fc.order_id = ogd.order_id
                               and fc.production_id = ogd.production_id
                               AND fc.order_number = ogd.order_number
                               AND fc.technology_number = ogd.technology_number
                 left join sd.order_process_detail as odpd
                           ON odpd.order_id = fc.order_id
                               AND odpd.order_number = fc.order_number
                               AND odpd.technology_number = fc.technology_number
                               and odpd.process_id = fc.process_id
                 left join sd.`order` as o
                           on o.order_id = od.order_id
        where  o.create_order>0
          and odpd.process = #{process}
          and date(o.create_time) >= #{date[0]}
          and date(o.create_time) &lt;= #{date[1]}
          and position(ifnull(#{inputVal}, '') in od.order_id)
          and position(ifnull(#{project}, '') in o.project)
          and od.quantity > odpd.reporting_work_num
 
        group by fc.process_id, fc.order_number, fc.technology_number
        order by fc.process_id, fc.order_number, fc.technology_number
    </select>
 
    <select id="exportWorkInProgressMp">
        select if(#{process}='',odpd.process,#{process}) as thisProcess,
               fc.process_id,
               o.customer_name,
               o.project,
               o.order_id,
               o.batch,
               if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
               ogd.order_number,
               ogd.technology_number,
               ogd.process,
               od.quantity,
               ogd.child_width,
               ogd.child_height,
               odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
               odpd.broken_num as stockNum,
               ROUND(ogd.child_width * ogd.child_height *
                     (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
                      odpd.broken_num) / 1000000, 2) as stockArea,
               od.product_name,
               od.bend_radius,
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber
 
        from sd.order_detail AS od
                 LEFT JOIN sd.order_glass_detail AS ogd
                           ON od.order_id = ogd.order_id
                               AND od.order_number = ogd.order_number
                 LEFT JOIN flow_card AS fc
                           ON fc.order_id = ogd.order_id
                               and fc.production_id = ogd.production_id
                               AND fc.order_number = ogd.order_number
                               AND fc.technology_number = ogd.technology_number
                 left join sd.order_process_detail as odpd
                           ON odpd.order_id = fc.order_id
                               AND odpd.order_number = fc.order_number
                               AND odpd.technology_number = fc.technology_number
                               and odpd.process_id = fc.process_id
                 left join sd.order_process_detail as odpds
                           ON odpds.id = odpd.id - 1
                 left join
             (SELECT sum(rw.rework_num) as 'patchNumSum',
                      rw.process_id,
                     rw.order_sort,
                     rw.technology_number,
                     rwk.this_process
              from rework as rw
                       LEFT JOIN
                   reporting_work as rwk
                   on rw.reporting_work_id = rwk.reporting_work_id
              where position(#{process} in rwk.this_process)
                and rw.review_status >= 0
              GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
             on c.process_id = fc.process_id
                 and c.order_sort = fc.order_number
                 and c.technology_number = fc.technology_number
                 left join sd.`order` as o
                           on o.order_id = od.order_id
        where  o.create_order>0
          and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
              odpd.broken_num != 0 and odpd.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
          and position(#{process} in odpd.process)
          and position(ifnull(#{inputVal}, '') in od.order_id)
          and position(ifnull(#{project}, '') in o.project)
 
        group by fc.process_id, fc.order_number, fc.technology_number,odpd.process
        order by fc.process_id, fc.order_number, fc.technology_number
    </select>
 
    <select id="exportTaskCompletionStatusMp">
        select d.customer_name as customerName,
               d.project,
               d.batch,
               c.order_id      as orderId,
               d.quantity,
               d.area,
               dd.quantity     as shippedQuantity,
               dd.area         as shippedArea,
               e.reportWorkQuantity,
               e.reportWorkQuantityCount
 
        from sd.`order` as d
                 left join flow_card as c on c.order_id = d.order_id
                 left join
             sd.order_detail as a
             on c.order_id = a.order_id
                 and c.order_number = a.order_number
                 left join sd.order_glass_detail as b
                           on c.order_id = b.order_id
                               and b.order_number = c.order_number
                               and c.technology_number = b.technology_number
                 left join mm.finished_goods_inventory as f
                           on c.order_id = f.order_id and f.order_number = c.order_number
                 left join (SELECT process_id,
                                   technology_number,
                                   sum(a.broken_num) as broken_num,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num, 0), "\"")),
                                          '}'
                                       )             as reportWorkQuantity,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num, 0), "\"")),
                                          '}'
                                       )             as reportWorkQuantityCount
                            FROM sd.order_process_detail as a
                                     left join sd.`order` as o on o.order_id = a.order_id
                            where date(o.create_time) >= #{date[0]}
                              and date(o.create_time) &lt;= #{date[1]}
                            GROUP BY process_id, a.technology_number) as e
                           on e.process_id = c.process_id
                               and e.technology_number = c.technology_number
                 left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
        where d.create_time
          and date(o.create_time) >= #{dates[0]}
          and date(o.create_time) &lt;= #{dates[1]}
          and d.create_order>0
          and reportWorkQuantity is not null
        GROUP BY a.order_id
        ORDER BY a.order_id
    </select>
 
    <select id="exportRawMaterialRequisitionMp">
        SELECT fc.project_no,
               modl.material_name,
               modl.producer,
               ou.width,
               ou.height,
               modl.date_of_manufacture,
               SUM(distinct modl.outbound_quantity)                                as quantity,
               ROUND(SUM(modl.outbound_quantity) * SUM(modl.single_piece_area), 2) as area,
               date(mo.material_requisition_date)                                  as date
        FROM mm.material_outbound_detail AS modl
                 left join mm.material_outbound as mo on mo.material_outbound_id = modl.material_outbound_id
                 LEFT JOIN optimize_use AS ou ON modl.use_id = ou.id and ou.raw_stock_code = modl.inventory_id
                 LEFT JOIN flow_card AS fc ON ou.project_no = fc.project_no
        where modl.use_id IS NOT NULL
          and date(mo.material_requisition_date) >= #{dates[0]}
          and date(mo.material_requisition_date) &lt;= #{dates[1]}
        GROUP BY ou.width, ou.height, material_code
    </select>
 
    <select id="exportQualityReportSv">
        SELECT o.order_id,
               o.customer_name,
               o.project,
               fc.order_number,
               fc.technology_number,
               od.product_name,
               od.quantity,
               MAX(opd.reporting_work_num_count)                                                   as quantityMax,
               IFNULL(SUM(distinct dd.breakage_quantity), 0)                                       as breakage_quantity,
               IFNULL(sum(distinct pl.patch_num), 0)                                               as patch_num,
               fc.received_quantity,
               CONCAT(ROUND(ROUND(od.quantity / MAX(opd.reporting_work_num_count), 2) * 100), '%') as finished
        FROM sd.`order` AS o
                 LEFT JOIN sd.order_detail AS od ON od.order_id = o.order_id
 
                 LEFT JOIN flow_card AS fc ON o.order_id = fc.order_id
            AND fc.order_number = od.order_number
 
                 LEFT JOIN damage_details AS dd ON dd.process_id = fc.process_id
            AND dd.order_number = fc.order_number
            AND dd.technology_number = fc.technology_number
            and dd.available != 1
 
                 LEFT JOIN patch_log AS pl ON pl.order_id = fc.order_id
            AND pl.process_id = fc.process_id
            AND pl.order_sort = fc.order_number
            AND pl.technology_number = fc.technology_number
 
                 LEFT JOIN sd.order_process_detail AS opd ON opd.order_id = fc.order_id
            AND opd.order_number = fc.order_number
            AND opd.technology_number = fc.technology_number
 
        WHERE date(o.create_time) >= #{dates[0]}
          and date(o.create_time) &lt;= #{dates[1]}
          and o.create_order>0
        GROUP BY o.order_id,
                 fc.order_number,
                 fc.technology_number
        ORDER BY fc.order_number
    </select>
 
    <select id="exportYieldMp">
        SELECT opd.process,
               o.order_id,
               o.customer_name,
               o.project,
               od.product_name,
               ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2)                               as finishedArea
                ,
               ROUND(SUM(distinct opd.broken_num) * od.area, 2)                                       as brokenArea,
               (ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2) +
                ROUND(SUM(distinct opd.broken_num) * od.area, 2))                                     as area,
               CONCAT(ROUND(ROUND(ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2) /
                                  (ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2) +
                                   ROUND(SUM(distinct opd.broken_num) * od.area, 2)), 2) * 100), '%') as finished
        FROM sd.`order` AS o
                 LEFT JOIN sd.order_detail AS od ON od.order_id = o.order_id
                 LEFT JOIN flow_card AS fc ON fc.order_id = od.order_id
            AND fc.order_number = fc.order_number
                 LEFT JOIN sd.order_process_detail AS opd ON opd.order_id = fc.order_id
            AND opd.process_id = fc.process_id
            AND opd.order_number = fc.order_number
            AND opd.technology_number = fc.technology_number
        WHERE opd.reporting_work_num > 0
          and date(o.create_time) >= #{date[0]}
          and date(o.create_time) &lt;= #{date[1]}
          and o.create_order>0
          AND position(#{process} IN opd.process)
        GROUP BY opd.process, o.order_id
    </select>
 
    <select id="teamOutputMp" resultMap="teamOutputMap">
        SELECT
        *
        FROM
        (
        SELECT
        rw.reporting_work_time,
        rw.this_process,
        rw.teams_groups_name,
        o.project,
        rw.process_id,
        fc.order_number,
        MAX(ogd.child_width)  AS width,
        MAX(ogd.child_height) AS height,
        od.edging_type,
        rwd.completed_quantity AS completed_quantity,
        ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * rwd.completed_quantity / 1000000, 2) AS area,
        od.product_name,
        JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS code,
        rw.reviewed,
        rw.examine_time,
        rw.device_name,
        o.order_type,
        CASE
        WHEN LOCATE('step', #{laminating}) > 0 THEN GROUP_CONCAT(ogd.glass_child SEPARATOR '+')
        ELSE MAX(ogd.glass_child)
        END AS workProcessName,
        o.batch
        FROM
        reporting_work AS rw
        LEFT JOIN reporting_work_detail AS rwd
        ON rwd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN flow_card AS fc
        ON fc.order_id = rw.order_id
        AND fc.process_id = rw.process_id
        AND fc.order_number = rwd.order_number
        AND fc.technology_number = rwd.technology_number
        LEFT JOIN sd.order_glass_detail AS ogd
        ON ogd.order_id = fc.order_id
        AND ogd.order_number = fc.order_number
        AND ogd.technology_number = fc.technology_number
        LEFT JOIN sd.order_detail AS od
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN sd.`order` AS o
        ON o.order_id = od.order_id
        WHERE
        o.create_order > 0
        AND rw.reviewed_state >= 0
        AND rwd.completed_quantity > 0
        AND rw.reporting_work_time &gt;= #{selectTime1}
        AND rw.reporting_work_time &lt;  #{selectTime2}
        <choose>
            <!-- 有传工序:精确匹配 -->
            <when test="selectProcesses != null and selectProcesses != ''">
                AND rw.this_process = #{selectProcesses}
            </when>
            <!-- 未传工序:不加限制,查所有) -->
            <otherwise>
            </otherwise>
        </choose>
        <if test="teamOutputDTO.thisProcess != null and teamOutputDTO.thisProcess != ''">
            AND rw.this_process REGEXP #{teamOutputDTO.thisProcess}
        </if>
        <if test="teamOutputDTO.teamsGroupsName != null and teamOutputDTO.teamsGroupsName != ''">
            AND rw.teams_groups_name REGEXP #{teamOutputDTO.teamsGroupsName}
        </if>
        <if test="teamOutputDTO.project != null and teamOutputDTO.project != ''">
            AND o.project REGEXP #{teamOutputDTO.project}
        </if>
        <if test="teamOutputDTO.processId != null and teamOutputDTO.processId != ''">
            AND rw.process_id REGEXP #{teamOutputDTO.processId}
        </if>
        <if test="teamOutputDTO.edgingType != null and teamOutputDTO.edgingType != ''">
            AND od.edging_type REGEXP #{teamOutputDTO.edgingType}
        </if>
        <if test="teamOutputDTO.deviceName != null and teamOutputDTO.deviceName != ''">
            AND rw.device_name REGEXP #{teamOutputDTO.deviceName}
        </if>
 
        <choose>
            <when test="laminating == ''">
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number,
                rwd.technology_number
            </when>
            <otherwise>
                GROUP BY
                <if test="laminating == 'stepA' || laminating == 'stepC'">
                    ogd.`group`,
                </if>
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number
            </otherwise>
        </choose>
        ) t
        WHERE 1 = 1
        <if test="teamOutputDTO.workProcessName != null and teamOutputDTO.workProcessName != ''">
            AND t.workProcessName REGEXP #{teamOutputDTO.workProcessName}
        </if>
        ORDER BY
        t.this_process,
        t.process_id,
        t.order_number,
        t.reporting_work_time,
        t.teams_groups_name
        LIMIT #{offset}, #{pageSize};
    </select>
 
    <select id="exportTeamOutputMp">
        SELECT
        rw.reporting_work_time,
        rw.this_process,
        rw.teams_groups_name,
        o.project,
        rw.process_id,
        fc.order_number,
        MAX( ogd.child_width ) as width,
        MAX( ogd.child_height ) as height,
        od.edging_type,
        rwd.completed_quantity as completed_quantity,
        ROUND(MAX( ogd.child_width )*MAX( ogd.child_height )*rwd.completed_quantity/1000000,2) as area,
        od.product_name,
        JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
        rw.reviewed,
        rw.examine_time,
        rw.device_name,
        o.order_type,
        --         GROUP_CONCAT(ogd.glass_child SEPARATOR '+') as workProcessName
        CASE
        WHEN LOCATE('step',#{laminating})>0 THEN GROUP_CONCAT(ogd.glass_child SEPARATOR '+')
        ELSE MAX( ogd.glass_child )
        END AS workProcessName,
        o.batch
        FROM
        reporting_work as rw left join reporting_work_detail as rwd on rwd.reporting_work_id=rw.reporting_work_id
        left join flow_card as fc on fc.order_id=rw.order_id and fc.process_id=rw.process_id  and fc.order_number=rwd.order_number and fc.technology_number=rwd.technology_number
        left join sd.order_glass_detail as ogd on ogd.order_id=fc.order_id and ogd.order_number=fc.order_number and ogd.technology_number=fc.technology_number
        left join sd.order_detail as od  on od.order_id=ogd.order_id and od.order_number=ogd.order_number
        left join sd.`order` as o on o.order_id=od.order_id
        where o.create_order>0 and rw.reviewed_state>=0 and rwd.completed_quantity>0 and
        rw.reporting_work_time >= #{date[0]}
        AND rw.reporting_work_time &lt;  #{date[1]}
        and position(#{process} in rw.this_process)
        <choose>
            <when test="laminating == ''">
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number,
                rwd.technology_number
            </when>
            <otherwise>
                GROUP BY
                <if test="laminating == 'stepA' || laminating == 'stepC'" >
                    ogd.`group`,
                </if>
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number
            </otherwise>
        </choose>
        ORDER BY
        rw.this_process,
        rw.process_id,
        rwd.order_number,
        rw.reporting_work_time,
        rw.teams_groups_name
    </select>
 
    <select id="teamOutputPageTotal">
        SELECT
        CEILING(count(*)/#{pageSize}) as 'pageTotal',
        count(*) as 'total'
        FROM
        (
        SELECT
        rw.reporting_work_time,
        rw.this_process,
        rw.teams_groups_name,
        o.project,
        rw.process_id,
        fc.order_number,
        MAX( ogd.child_width ) as width,
        MAX( ogd.child_height ) as height,
        od.edging_type,
        rwd.completed_quantity as completed_quantity,
        ROUND(MAX( ogd.child_width )*MAX( ogd.child_height )*rwd.completed_quantity/1000000,2) as area,
        od.product_name,
        JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code
        FROM
        reporting_work as rw left join reporting_work_detail as rwd on rwd.reporting_work_id=rw.reporting_work_id
        left join flow_card as fc on fc.order_id=rw.order_id and fc.process_id=rw.process_id  and fc.order_number=rwd.order_number and fc.technology_number=rwd.technology_number
        left join sd.order_glass_detail as ogd on ogd.order_id=fc.order_id and ogd.order_number=fc.order_number and ogd.technology_number=fc.technology_number
        left join sd.order_detail as od  on od.order_id=ogd.order_id and od.order_number=ogd.order_number
        left join sd.`order` as o on o.order_id=od.order_id
        where o.create_order>0 and rw.reviewed_state>=0 and rwd.completed_quantity>0 and
        rw.reporting_work_time >= #{selectTime1}
        AND rw.reporting_work_time &lt;  #{selectTime2}
        and position(#{selectProcesses} in rw.this_process)
        <if test="teamOutputDTO.thisProcess != null and teamOutputDTO.thisProcess != ''">
            and rw.this_process regexp #{teamOutputDTO.thisProcess}
        </if>
        <if test="teamOutputDTO.teamsGroupsName != null and teamOutputDTO.teamsGroupsName != ''">
            and rw.teams_groups_name regexp #{teamOutputDTO.teamsGroupsName}
        </if>
        <if test="teamOutputDTO.project != null and teamOutputDTO.project != ''">
            and o.project regexp #{teamOutputDTO.project}
        </if>
        <if test="teamOutputDTO.processId != null and teamOutputDTO.processId != ''">
            and rw.process_id regexp #{teamOutputDTO.processId}
        </if>
        <if test="teamOutputDTO.edgingType != null and teamOutputDTO.edgingType != ''">
            and od.edging_type regexp #{teamOutputDTO.edgingType}
        </if>
 
        <choose>
            <when test="laminating == ''">
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number,
                rwd.technology_number
            </when>
            <otherwise>
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number
            </otherwise>
        </choose>
        ORDER BY
        rw.this_process,
        rw.process_id,
        rwd.order_number,
        rw.reporting_work_time,
        rw.teams_groups_name
        ) as page_toal
        limit #{offset},#{pageSize}
    </select>
 
    <select id="workInProgressOrderMp" resultMap="workInProgressMap">
        select #{selectProcesses} as thisProcess,
        o.customer_name,
        o.project,
        o.order_id,
        o.batch,
        if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
        sum(od.quantity) as quantity,
        sum(odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) as stockNum,
        sum(ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2)) as stockArea,
        od.product_name,
        rws.teams_groups_name
 
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        group by o.order_id
        order by o.order_id
        limit #{offset},#{pageSize};
    </select>
 
    <select id="workInProgressOrderTotal">
        select CEILING(count(o.order_id)/#{pageSize}) as 'pageTotal',
        count(distinct o.order_id) as 'total'
 
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        limit #{offset},#{pageSize};
    </select>
 
    <select id="workInProgressProcessMp" resultMap="workInProgressMap">
        select #{selectProcesses} as thisProcess,
        o.customer_name,
        o.project,
        o.order_id,
        fc.process_id,
        o.batch,
        if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
        sum(od.quantity) as quantity,
        sum(odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) as stockNum,
        sum(ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2)) as stockArea,
        od.product_name,
        rws.teams_groups_name
 
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        group by o.order_id, fc.process_id
        order by o.order_id, fc.process_id
        limit #{offset},#{pageSize};
    </select>
 
    <select id="workInProgressProcessTotal">
        select CEILING(count(fc.process_id)/#{pageSize}) as 'pageTotal',
        count(distinct fc.process_id) as 'total'
 
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        limit #{offset},#{pageSize};
    </select>
 
    <select id="scheduleProductionScheduleMp" resultMap="scheduleProductionScheduleMap">
        select ps.order_id,
        o.project,
        ps.processes,
        sum(ps.scheduling_quantity) as scheduling_quantity,
        notes,
        date(ps.scheduled_start_time) as scheduled_start_time,
        date(ps.plan_end_time) as plan_end_time
        from (select order_id, order_number, processes, scheduling_quantity, scheduled_start_time, plan_end_time, notes
        from production_scheduling
        where processes = #{processes}
        GROUP BY order_id, order_number) as ps
        left join sd.`order` as o on o.order_id = ps.order_id
        where ps.processes = #{processes} and o.create_order>0
        and  DATE_FORMAT((ps.scheduled_start_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2}
        <if test="scheduleProductionScheduleDTO.orderId != null and scheduleProductionScheduleDTO.orderId != ''">
            and ps.order_id regexp #{scheduleProductionScheduleDTO.orderId}
        </if>
        <if test="scheduleProductionScheduleDTO.project != null and scheduleProductionScheduleDTO.project != ''">
            and o.project regexp #{scheduleProductionScheduleDTO.project}
        </if>
        <if test="scheduleProductionScheduleDTO.processes != null and scheduleProductionScheduleDTO.processes != ''">
            and ps.processes regexp #{scheduleProductionScheduleDTO.processes}
        </if>
        <if test="scheduleProductionScheduleDTO.notes != null and scheduleProductionScheduleDTO.notes != ''">
            and ps.notes regexp #{scheduleProductionScheduleDTO.notes}
        </if>
        GROUP BY ps.order_id, ps.processes
        limit #{offset},#{pageSize};
    </select>
 
    <select id="getScheduleProductionScheduleTotal">
        select CEILING(count(ps.order_id)/#{pageSize}) as 'pageTotal',
        count(distinct ps.order_id) as 'total'
        from (select order_id, order_number, processes, scheduling_quantity, scheduled_start_time, plan_end_time, notes
        from production_scheduling
        where processes = #{processes}
        GROUP BY order_id, order_number) as ps
        left join sd.`order` as o on o.order_id = ps.order_id
        where ps.processes = #{processes} and o.create_order>0
        and  DATE_FORMAT((ps.scheduled_start_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2}
        <if test="scheduleProductionScheduleDTO.orderId != null and scheduleProductionScheduleDTO.orderId != ''">
            and ps.order_id regexp #{scheduleProductionScheduleDTO.orderId}
        </if>
        <if test="scheduleProductionScheduleDTO.project != null and scheduleProductionScheduleDTO.project != ''">
            and o.project regexp #{scheduleProductionScheduleDTO.project}
        </if>
        <if test="scheduleProductionScheduleDTO.processes != null and scheduleProductionScheduleDTO.processes != ''">
            and ps.processes regexp #{scheduleProductionScheduleDTO.processes}
        </if>
        <if test="scheduleProductionScheduleDTO.notes != null and scheduleProductionScheduleDTO.notes != ''">
            and ps.notes regexp #{scheduleProductionScheduleDTO.notes}
        </if>
        limit #{offset},#{pageSize};
    </select>
 
    <select id="exportScheduleReportMp">
        select ps.order_id,
               o.project,
               ps.processes,
               sum(ps.scheduling_quantity)   as scheduling_quantity,
               notes,
               date(ps.scheduled_start_time) as scheduled_start_time,
               date(ps.plan_end_time)        as plan_end_time
        from (select order_id, order_number, processes, scheduling_quantity, scheduled_start_time, plan_end_time, notes
              from production_scheduling
              where processes = #{process}
              GROUP BY order_id, order_number) as ps
                 left join sd.`order` as o on o.order_id = ps.order_id
        where ps.processes = #{process} and o.create_order>0
          and date(scheduled_start_time) >= #{date[0]}
          and date(scheduled_start_time) &lt;= #{date[1]}
        GROUP BY ps.order_id, ps.processes
    </select>
 
    <select id="workInProgressOrderFootSum">
        SELECT SUM(aa.quantity) AS quantity,
        sum(aa.stockNum) AS stockNum,
        SUM(aa.stockArea) AS stockArea,
        count(* ) AS 'total',
        CEILING( count(* )/#{pageSize} ) AS 'pageTotal'
        from
        (
        SELECT (od.quantity) AS quantity,
        d.numCounts + d.patchNumSum - d.numCount -d.broken_num as stockNum,
        ROUND(ogd.child_width * ogd.child_height *
        (d.numCounts + d.patchNumSum - d.numCount -
        d.broken_num) / 1000000, 2) as stockArea
        FROM
        sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN pp.flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join (
        SELECT
        odpd.process,
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpds.reporting_work_num_count as numCounts,
        ifnull( c.patchNumSum, 0 ) as patchNumSum,
        odpd.reporting_work_num_count as numCount,
        odpd.broken_num
        FROM
        sd.order_process_detail AS odpd
        LEFT JOIN sd.order_process_detail AS odpds ON odpds.id = odpd.id - 1
        LEFT JOIN (
        SELECT
        sum( rw.rework_num ) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{selectProcesses} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS c ON c.process_id = odpd.process_id
        AND c.order_sort = odpd.order_number
        AND c.technology_number = odpd.technology_number
        WHERE
        position(#{selectProcesses} IN odpd.process )  and odpds.reporting_work_num_count is not null
        GROUP BY
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpd.process
 
        ) as d
        on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
        and position(#{selectProcesses} in d.process)
        left join sd.`order` as o on o.order_id=od.order_id
        where  o.create_order>0
        and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
        and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in d.process)
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        <if test="workInProgressDTO.orderNumber != null and workInProgressDTO.orderNumber != ''">
            and ogd.order_number regexp #{workInProgressDTO.orderNumber}
        </if>
        <if test="workInProgressDTO.technologyNumber != null and workInProgressDTO.technologyNumber != ''">
            and ogd.technology_number regexp #{workInProgressDTO.technologyNumber}
        </if>
        <if test="workInProgressDTO.glassNumber != null and workInProgressDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{workInProgressDTO.glassNumber}
        </if>
 
        group by fc.process_id, fc.order_number, fc.technology_number,d.process
        ) as aa
 
    </select>
 
    <select id="processToBeCompletedFootSum">
        SELECT
            SUM(fc.quantity) AS quantity,
            ROUND(SUM(ogd.child_width * ogd.child_height) / 1000000, 2) AS childArea,
            ROUND(SUM(ogd.child_width * ogd.child_height * fc.quantity) / 1000000, 2) AS actualArea,
            SUM(odpd.reporting_work_num) AS completeNum,
            ROUND(SUM(ogd.child_width * ogd.child_height * odpd.reporting_work_num) / 1000000, 2) AS completeArea,
            SUM(fc.quantity - odpd.reporting_work_num) AS incompleteNum,
            ROUND(SUM(ogd.child_width * ogd.child_height * (fc.quantity - odpd.reporting_work_num)) / 1000000, 2) AS incompleteArea
        FROM sd.order_detail AS od
                 LEFT JOIN sd.order_glass_detail AS ogd
                           ON od.order_id = ogd.order_id
                               AND od.order_number = ogd.order_number
                 LEFT JOIN flow_card AS fc
                           ON fc.order_id = ogd.order_id
                               AND fc.production_id = ogd.production_id
                               AND fc.order_number = ogd.order_number
                               AND fc.technology_number = ogd.technology_number
                 LEFT JOIN sd.order_process_detail AS odpd
                           ON odpd.order_id = fc.order_id
                               AND odpd.order_number = fc.order_number
                               AND odpd.technology_number = fc.technology_number
                               AND odpd.process_id = fc.process_id
                 LEFT JOIN sd.`order` AS o
                           ON o.order_id = od.order_id
        WHERE o.create_order > 0
          and odpd.process = #{selectProcesses}
          and  o.create_time >= #{selectTime1}
          AND o.create_time &lt;  #{selectTime2}
          and position(#{orderId} in od.order_id)
          and position(#{inputProject} in o.project)
          AND fc.quantity - odpd.reporting_work_num > 0;
 
    </select>
 
    <select id="damageReportFootSum">
        SELECT
            SUM(dd.breakage_quantity) AS breakageQuantity,
            ROUND(SUM(ogd.child_width * ogd.child_height * dd.breakage_quantity) / 1000000, 2) AS area
        FROM
            sd.ORDER AS o
                LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
                LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
                LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
                AND dd.order_number = ogd.order_number
                AND dd.technology_number = ogd.technology_number
                LEFT JOIN sd.order_detail AS od ON o.order_id = od.order_id
                AND od.order_number = ogd.order_number
        WHERE
            rw.reporting_work_time >= #{selectTime1}
          AND rw.reporting_work_time &lt;  #{selectTime2}
          AND dd.available = 0 and rw.reviewed_state>=0
        <if test="damageReportDTO.orderId != null and damageReportDTO.orderId != ''">
            and o.order_id regexp #{damageReportDTO.orderId}
        </if>
        <if test="damageReportDTO.project != null and damageReportDTO.project != ''">
            and o.project regexp #{damageReportDTO.project}
        </if>
        <if test="damageReportDTO.processId != null and damageReportDTO.processId != ''">
            and rw.process_id regexp #{damageReportDTO.processId}
        </if>
        <if test="damageReportDTO.orderNumber != null and damageReportDTO.orderNumber != ''">
            and dd.order_number regexp #{damageReportDTO.orderNumber}
        </if>
        <if test="damageReportDTO.technologyNumber != null and damageReportDTO.technologyNumber != ''">
            and dd.technology_number regexp #{damageReportDTO.technologyNumber}
        </if>
        <if test="damageReportDTO.responsibleProcess != null and damageReportDTO.responsibleProcess != ''">
            and dd.responsible_process regexp #{damageReportDTO.responsibleProcess}
        </if>
        <if test="damageReportDTO.responsibleTeam != null and damageReportDTO.responsibleTeam != ''">
            and dd.responsible_team regexp #{damageReportDTO.responsibleTeam}
        </if>
        <if test="damageReportDTO.responsibleEquipment != null and damageReportDTO.responsibleEquipment != ''">
            and dd.responsible_equipment regexp #{damageReportDTO.responsibleEquipment}
        </if>
        <if test="damageReportDTO.breakageType != null and damageReportDTO.breakageType != ''">
            and dd.breakage_type regexp #{damageReportDTO.breakageType}
        </if>
        <if test="damageReportDTO.breakageReason != null and damageReportDTO.breakageReason != ''">
            and dd.breakage_reason regexp #{damageReportDTO.breakageReason}
        </if>
        <if test="damageReportDTO.glassChild != null and damageReportDTO.glassChild != ''">
            and ogd.glass_child regexp #{damageReportDTO.glassChild}
        </if>
        <if test="damageReportDTO.glassNumber != null and damageReportDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{damageReportDTO.glassNumber}
        </if>
    </select>
 
    <select id="teamOutputFootSum">
        select SUM(completed_quantity) as completedQuantity,
        ifnull(SUM(ROUND(width * height * completed_quantity / 1000000, 2)),0) AS area
        from (
        SELECT
        rw.this_process,
        rw.teams_groups_name,
        o.project,
        rw.process_id,
        fc.order_number,
        MAX( ogd.child_width ) as width,
        MAX( ogd.child_height ) as height,
        rwd.completed_quantity as completed_quantity
        FROM
        reporting_work as rw left join reporting_work_detail as rwd on rwd.reporting_work_id=rw.reporting_work_id
        left join flow_card as fc on fc.order_id=rw.order_id and fc.process_id=rw.process_id  and fc.order_number=rwd.order_number and fc.technology_number=rwd.technology_number
        left join sd.order_glass_detail as ogd on ogd.order_id=fc.order_id and ogd.order_number=fc.order_number and ogd.technology_number=fc.technology_number
        left join sd.order_detail as od  on od.order_id=ogd.order_id and od.order_number=ogd.order_number
        left join sd.`order` as o on o.order_id=od.order_id
        where o.create_order>0 and rw.reviewed_state>=0 and rwd.completed_quantity>0
        AND rw.reporting_work_time >= #{selectTime1}
        AND rw.reporting_work_time &lt;  #{selectTime2}
        and position(#{selectProcesses} in rw.this_process)
        <if test="teamOutputDTO.thisProcess != null and teamOutputDTO.thisProcess != ''">
            and rw.this_process regexp #{teamOutputDTO.thisProcess}
        </if>
        <if test="teamOutputDTO.teamsGroupsName != null and teamOutputDTO.teamsGroupsName != ''">
            and rw.teams_groups_name regexp #{teamOutputDTO.teamsGroupsName}
        </if>
        <if test="teamOutputDTO.project != null and teamOutputDTO.project != ''">
            and o.project regexp #{teamOutputDTO.project}
        </if>
        <if test="teamOutputDTO.processId != null and teamOutputDTO.processId != ''">
            and rw.process_id regexp #{teamOutputDTO.processId}
        </if>
        <if test="teamOutputDTO.edgingType != null and teamOutputDTO.edgingType != ''">
            and od.edging_type regexp #{teamOutputDTO.edgingType}
        </if>
        <if test="teamOutputDTO.deviceName != null and teamOutputDTO.deviceName != ''">
            and rw.device_name regexp #{teamOutputDTO.deviceName}
        </if>
        <choose>
            <when test="laminating == ''">
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number,
                rwd.technology_number
            </when>
            <otherwise>
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number
            </otherwise>
        </choose>
        ORDER BY
        rw.this_process,
        rw.process_id,
        rwd.order_number,
        rw.reporting_work_time,
        rw.teams_groups_name
        ) as subquery
    </select>
 
    <select id="getLaminating">
        select IFNULL(nickname,'') from sd.basic_data where basic_category='process' and basic_name=#{selectProcesses}
    </select>
 
    <select id="workInProgressMpdataList1" resultMap="workInProgressMap">
        select d.process as thisProcess,
        fc.process_id,
        o.customer_name,
        o.project,
        o.order_id,
        o.batch,
        od.shape,
        if(od.shape=2,JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')),od.bend_radius) as bend_radius,
        ogd.order_number,
        ogd.technology_number,
        ogd.process,
        od.quantity,
        ogd.child_width,
        ogd.child_height,
        d.numCounts + d.patchNumSum - d.numCount -d.broken_num as stockNum,
        ROUND(ogd.child_width * ogd.child_height *
        (d.numCounts + d.patchNumSum - d.numCount -
        d.broken_num) / 1000000, 2) as stockArea,
        od.product_name,
        od.bend_radius,
        ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN pp.flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join (
        SELECT
        odpd.process,
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpds.reporting_work_num_count as numCounts,
        ifnull( c.patchNumSum, 0 ) as patchNumSum,
        odpd.reporting_work_num_count as numCount,
        odpd.broken_num
        FROM
        sd.order_process_detail AS odpd
        LEFT JOIN sd.order_process_detail AS odpds ON odpds.id = odpd.id - 1
        LEFT JOIN (
        SELECT
        sum( rw.rework_num ) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{selectProcesses} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS c ON c.process_id = odpd.process_id
        AND c.order_sort = odpd.order_number
        AND c.technology_number = odpd.technology_number
        WHERE
        position(#{selectProcesses} IN odpd.process )  and odpds.reporting_work_num_count is not null
        GROUP BY
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpd.process
 
        ) as d
        on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
        left join sd.`order` as o on o.order_id=od.order_id
        LEFT JOIN sd.basic_data AS bd ON bd.basic_name = d.process
        where  o.create_order>0
        and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
        and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.thisProcess != null and workInProgressDTO.thisProcess != ''">
            and d.process regexp #{workInProgressDTO.thisProcess}
        </if>
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        <if test="workInProgressDTO.orderNumber != null and workInProgressDTO.orderNumber != ''">
            and ogd.order_number regexp #{workInProgressDTO.orderNumber}
        </if>
        <if test="workInProgressDTO.technologyNumber != null and workInProgressDTO.technologyNumber != ''">
            and ogd.technology_number regexp #{workInProgressDTO.technologyNumber}
        </if>
        <if test="workInProgressDTO.quantity != null and workInProgressDTO.quantity != ''">
            and od.quantity regexp #{workInProgressDTO.quantity}
        </if>
        <if test="workInProgressDTO.childWidth != null and workInProgressDTO.childWidth != ''">
            and ogd.child_width regexp #{workInProgressDTO.childWidth}
        </if>
        <if test="workInProgressDTO.childHeight != null and workInProgressDTO.childHeight != ''">
            and ogd.child_height regexp #{workInProgressDTO.childHeight}
        </if>
        <if test="workInProgressDTO.stockNum != null and workInProgressDTO.stockNum != ''">
            and (d.numCounts + d.patchNumSum - d.numCount -d.broken_num) regexp #{workInProgressDTO.stockNum}
        </if>
        <if test="workInProgressDTO.stockArea != null and workInProgressDTO.stockArea != ''">
            and ROUND(ogd.child_width * ogd.child_height * (d.numCounts + d.patchNumSum - d.numCount -
            d.broken_num) / 1000000, 2) regexp #{workInProgressDTO.stockArea}
        </if>
        <if test="workInProgressDTO.glassNumber != null and workInProgressDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{workInProgressDTO.glassNumber}
        </if>
        <choose>
            <when test="laminating != null and laminating == 'stepC'">
                GROUP BY fc.process_id, fc.order_number, ogd.`group`, d.process
            </when>
            <when test="laminating != null and laminating == 'stepD'">
                GROUP BY fc.process_id, fc.order_number, d.process
            </when>
            <when test="laminating != null and laminating == 'stepB'">
                GROUP BY fc.process_id, fc.order_number, d.process
            </when>
            <otherwise>
                GROUP BY fc.process_id, fc.order_number, fc.technology_number, d.process
            </otherwise>
        </choose>
        order by d.process,fc.process_id, fc.order_number, fc.technology_number
        limit #{offset},#{pageSize};
    </select>
 
    <select id="workInProgressMpdataList2" resultMap="workInProgressMap">
        select
            a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from pp.reporting_work  as a
                 left join pp.reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        where position(#{selectProcesses} in a.next_process) and a.next_process!='切割'
        GROUP BY a.reporting_work_id
    </select>
 
    <select id="workInProgressOrderMpList1" resultMap="workInProgressMap">
        select if(#{selectProcesses}='',odpd.process,#{selectProcesses}) as thisProcess,
        o.customer_name,
        o.project,
        o.order_id,
        o.batch,
        od.shape,
        sum(od.quantity) as quantity,
        sum(odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) as stockNum,
        sum(ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2)) as stockArea,
        od.product_name
 
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where position(#{selectProcesses} in rwk.this_process)
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0 and odpd.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in odpd.process)
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        group by o.order_id
        order by o.order_id
        limit #{offset},#{pageSize};
    </select>
 
    <select id="workInProgressProcessMpList1" resultMap="workInProgressMap">
        select if(#{selectProcesses}='',odpd.process,#{selectProcesses}) as thisProcess,
        o.customer_name,
        o.project,
        o.order_id,
        fc.process_id,
        o.batch,
        od.shape,
        sum(od.quantity) as quantity,
        sum(odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) as stockNum,
        sum(ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2)) as stockArea,
        od.product_name
 
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where position(#{selectProcesses} in rwk.this_process)
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0 and odpd.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in odpd.process)
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        group by o.order_id, fc.process_id
        order by o.order_id, fc.process_id
        limit #{offset},#{pageSize};
    </select>
 
    <select id="exportWorkInProgressMpdataList2">
        select
            a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from pp.reporting_work  as a
                 left join pp.reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        where position(#{process} in a.next_process) and a.next_process!='切割'
        GROUP BY a.reporting_work_id
    </select>
 
    <select id="workInProgressCombinationMpdataList2">
        select
            a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from pp.reporting_work  as a
                 left join pp.reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        where position(#{selectProcesses} in a.next_process) and a.next_process!='切割'
        GROUP BY a.reporting_work_id
    </select>
 
    <select id="workInProgressCombinationMpdataList1">
        select if(#{selectProcesses}='',d.process,#{selectProcesses}) as thisProcess,
        o.project,
        SUM(d.numCounts + d.patchNumSum - d.numCount -d.broken_num) as stockNum,
        SUM(ROUND(ogd.child_width * ogd.child_height *
        (d.numCounts + d.patchNumSum - d.numCount -
        d.broken_num) / 1000000, 2)) as stockArea
        from sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN pp.flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join (
        SELECT
        odpd.process,
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpds.reporting_work_num_count as numCounts,
        ifnull( c.patchNumSum, 0 ) as patchNumSum,
        odpd.reporting_work_num_count as numCount,
        odpd.broken_num
        FROM
        sd.order_process_detail AS odpd
        LEFT JOIN sd.order_process_detail AS odpds ON odpds.id = odpd.id - 1
        LEFT JOIN (
        SELECT
        sum( rw.rework_num ) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{selectProcesses} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS c ON c.process_id = odpd.process_id
        AND c.order_sort = odpd.order_number
        AND c.technology_number = odpd.technology_number
        WHERE
        position(#{selectProcesses} IN odpd.process )  and odpds.reporting_work_num_count is not null
        GROUP BY
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpd.process
 
        ) as d
        on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
        and position(#{selectProcesses} in d.process)
        left join sd.`order` as o on o.order_id=od.order_id
        where  o.create_order>0
        and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
        and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in d.process)
 
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
 
        group by d.process
        order by d.process
        limit #{offset},#{pageSize};
    </select>
 
    <select id="workInProgressCombinationOrderFootSum">
        SELECT SUM(aa.quantity) AS quantity,
        sum(aa.stockNum) AS stockNum,
        SUM(aa.stockArea) AS stockArea,
        count(* ) AS 'total',
        CEILING( count(* )/#{pageSize} ) AS 'pageTotal'
        from
        (
        SELECT (od.quantity) AS quantity,
        d.numCounts + d.patchNumSum - d.numCount -d.broken_num as stockNum,
        ROUND(ogd.child_width * ogd.child_height *
        (d.numCounts + d.patchNumSum - d.numCount -
        d.broken_num) / 1000000, 2) as stockArea
        FROM
        sd.order_detail AS od
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN pp.flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join (
        SELECT
        odpd.process,
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpds.reporting_work_num_count as numCounts,
        ifnull( c.patchNumSum, 0 ) as patchNumSum,
        odpd.reporting_work_num_count as numCount,
        odpd.broken_num
        FROM
        sd.order_process_detail AS odpd
        LEFT JOIN sd.order_process_detail AS odpds ON odpds.id = odpd.id - 1
        LEFT JOIN (
        SELECT
        sum( rw.rework_num ) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{selectProcesses} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS c ON c.process_id = odpd.process_id
        AND c.order_sort = odpd.order_number
        AND c.technology_number = odpd.technology_number
        WHERE
        position(#{selectProcesses} IN odpd.process )  and odpds.reporting_work_num_count is not null
        GROUP BY
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpd.process
 
        ) as d
        on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
        and position(#{selectProcesses} in d.process)
        left join sd.`order` as o on o.order_id=od.order_id
        where  o.create_order>0
        and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
        and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in d.process)
 
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        group by d.process
        ) as aa
    </select>
 
    <select id="selectProcess">
        SELECT basic_name
        FROM sd.basic_data as bd
        where bd.basic_category = 'process'
          and bd.basic_type = 'product'
        and basic_name!='切割'
    </select>
 
    <select id="getWorkInProgressCombination">
        select
            #{process} as thisProcess,
            if(#{optionVal} = 1,'',h.project) as project,
            SUM(h.quantity) as stockNum,
            SUM(h.glassArea) as stockArea,
            if(#{optionVal} = 1,'',h.childName) as glassName
 
        from (
 
                 SELECT g.*
                      ,GROUP_CONCAT(g.glass_child SEPARATOR '+')  as childName
                 from( SELECT f.*,
        e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num as quantity,
        (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)*f.area as glassArea
                       from (SELECT a.order_id,
                                   if(a.batch!="",CONCAT(a.project,'(',a.batch,')'),a.project) as project,
                                    C.product_id,
                                    b.order_number,
                                    b.process_id,
                                    b.technology_number,
                                    b.reporting_work_num_count,
                                    d.`group` ,
                                    b.broken_num,
                                    b.id,
                                    c.area,
                                    d.glass_child,
                                    ifnull(cb.patchNumSum,0) as patchNumSum
 
                             FROM sd.`order` as a
                                      LEFT JOIN sd.order_process_detail as b
                                                on b.process = #{process} and a.order_id =b.order_id
                                      LEFT JOIN sd.order_detail as c
                                                on a.order_id = c.order_id and b.order_number =c.order_number
                                      left join sd.order_glass_detail as d
                                                on  d.order_id =a.order_id and d.order_number = b.order_number and d.technology_number = b.technology_number
                                      LEFT JOIN (
                                        SELECT
                                        IFNULL(sum( rw.rework_num ),0) AS 'patchNumSum',
                                        rw.process_id,
                                        rw.order_sort,
                                        rw.technology_number,
                                        rwk.this_process
                                        FROM
                                        pp.rework AS rw
                                        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
                                        WHERE
                                        position( #{process} IN rwk.this_process )
                                        AND rw.review_status >= 0
                                        GROUP BY
                                        rw.process_id,
                                        rw.order_sort,
                                        rw.technology_number
                                        ) AS cb ON cb.process_id = b.process_id
                                        AND cb.order_sort = b.order_number
                                        AND cb.technology_number = b.technology_number
                             where a.processing_card>0
                               and a.warehousing!=2
                                and (c.quantity-b.reporting_work_num)>0
                             GROUP BY  b.process_id, b.order_number,
                                 b.technology_number) as f
                                LEFT JOIN sd.order_process_detail as e
                                          on e.id=(f.id-1) and e.process_id = f.process_id and e.order_number = f.order_number and e.technology_number =f.technology_number
                       where
                           e.id is not null
                         and (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)>0 group by f.process_id, f.order_number,
        f.technology_number ORDER BY f.process_id, f.order_number,
        f.technology_number) as g
                            <choose>
                                <when test="laminating == 'stepC' and process == '预压'">
                                    GROUP BY g.process_id, g.order_number, g.technology_number
                                </when>
                                <when test="laminating == 'stepC'">
                                    GROUP BY g.process_id, g.order_number, g.`group`
                                </when>
                                <when test="laminating == 'stepD'">
                                    GROUP BY g.process_id, g.order_number
                                </when>
                                <otherwise>
                                    GROUP BY g.process_id, g.order_number, g.technology_number
                                </otherwise>
                            </choose>
 
 
             ) as h
        <choose>
            <when test="optionVal == 1">
                GROUP BY thisProcess
            </when>
            <otherwise>
                GROUP BY h.project,h.childName
            </otherwise>
        </choose>
 
    </select>
 
    <select id="getWorkInProgressCombinationFootSum">
        select
        SUM(h.quantity) as stockNum,
        SUM(h.glassArea) as stockArea
        from (
        SELECT g.*
        ,GROUP_CONCAT(g.glass_child SEPARATOR '+')  as childName
        from( SELECT f.*,
        e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num as quantity,
        (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)*f.area as glassArea
        from (SELECT a.order_id,
        a.project,
        C.product_id,
        b.order_number,
        b.process_id,
        b.technology_number,
        b.reporting_work_num_count,
        d.`group` ,
        b.broken_num,
        b.id,
        c.area,
        d.glass_child,
        ifnull(cb.patchNumSum,0) as patchNumSum
 
        FROM sd.`order` as a
        LEFT JOIN sd.order_process_detail as b
        on b.process = #{process} and a.order_id =b.order_id
        LEFT JOIN sd.order_detail as c
        on a.order_id = c.order_id and b.order_number =c.order_number
        left join sd.order_glass_detail as d
        on  d.order_id =a.order_id and d.order_number = b.order_number and d.technology_number = b.technology_number
        LEFT JOIN (
        SELECT
        IFNULL(sum( rw.rework_num ),0) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{process} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS cb ON cb.process_id = b.process_id
        AND cb.order_sort = b.order_number
        AND cb.technology_number = b.technology_number
        where a.processing_card>0
        and a.warehousing!=2
        and (c.quantity-b.reporting_work_num)>0
        GROUP BY  b.process_id, b.order_number,
        b.technology_number) as f
        LEFT JOIN sd.order_process_detail as e
        on e.id=(f.id-1) and e.process_id = f.process_id and e.order_number = f.order_number and e.technology_number =f.technology_number
        where
        e.id is not null
        and e.reporting_work_num_count-f.reporting_work_num_count>0 group by f.process_id, f.order_number,
        f.technology_number) as g
        <choose>
            <when test="laminating == 'stepC' and process == '预压'">
                GROUP BY g.process_id, g.order_number, g.technology_number
            </when>
            <when test="laminating == 'stepC'">
                GROUP BY g.process_id, g.order_number, g.`group`
            </when>
            <when test="laminating == 'stepD'">
                GROUP BY g.process_id, g.order_number
            </when>
            <otherwise>
                GROUP BY g.process_id, g.order_number, g.technology_number
            </otherwise>
        </choose>
 
 
        ) as h
 
    </select>
 
    <select id="exportWorkInProgressCombination">
        select
        #{process} as thisProcess,
        if(#{inputVal} = 1,'',h.project) as project,
        SUM(h.quantity) as stockNum,
        SUM(h.glassArea) as stockArea,
        if(#{inputVal} = 1,'',h.childName) as glassName
 
        from (
 
        SELECT g.*
        ,GROUP_CONCAT(g.glass_child SEPARATOR '+')  as childName
        from( SELECT f.*,
        e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num as quantity,
        (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)*f.area as glassArea
        from (SELECT a.order_id,
        a.project,
        C.product_id,
        b.order_number,
        b.process_id,
        b.technology_number,
        b.reporting_work_num_count,
        d.`group` ,
        b.broken_num,
        b.id,
        c.area,
        d.glass_child,
        ifnull(cb.patchNumSum,0) as patchNumSum
 
        FROM sd.`order` as a
        LEFT JOIN sd.order_process_detail as b
        on b.process = #{process} and a.order_id =b.order_id
        LEFT JOIN sd.order_detail as c
        on a.order_id = c.order_id and b.order_number =c.order_number
        left join sd.order_glass_detail as d
        on  d.order_id =a.order_id and d.order_number = b.order_number and d.technology_number = b.technology_number
        LEFT JOIN (
        SELECT
        IFNULL(sum( rw.rework_num ),0) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{process} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS cb ON cb.process_id = b.process_id
        AND cb.order_sort = b.order_number
        AND cb.technology_number = b.technology_number
        where a.processing_card>0
        and a.warehousing!=2
        and (c.quantity-b.reporting_work_num_count)>0
        GROUP BY  b.process_id, b.order_number,
        b.technology_number) as f
        LEFT JOIN sd.order_process_detail as e
        on e.id=(f.id-1) and e.process_id = f.process_id and e.order_number = f.order_number and e.technology_number =f.technology_number
        where
        e.id is not null
        and (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)>0 ) as g
        <choose>
            <when test="laminating == 'stepC' and process == '预压'">
                GROUP BY g.process_id, g.order_number, g.technology_number
            </when>
            <when test="laminating == 'stepC'">
                GROUP BY g.process_id, g.order_number, g.`group`
            </when>
            <when test="laminating == 'stepD'">
                GROUP BY g.process_id, g.order_number
            </when>
            <otherwise>
                GROUP BY g.process_id, g.order_number, g.technology_number
            </otherwise>
        </choose>
 
 
        ) as h
        <choose>
            <when test="inputVal == 1">
                GROUP BY thisProcess
            </when>
            <otherwise>
                GROUP BY h.project,h.childName
            </otherwise>
        </choose>
    </select>
    
    
    <select id="processCardProgressCollectMp">
       select * from (select
              a.order_id,
              a.order_number,
              c.glass_group as 'group',
              a.technology_number,
            b.product_name,
            c.detail as glass_child,
            d.order_type,
            concat(a.process_id,'/',a.technology_number)  as processID,
            a.process_id,
            if(a.technology_number=1,sum(a.quantity-ifnull(a.termination_quantity,0)),0) as quantity,
            sum(a.quantity)-ifnull(a.termination_quantity,0) as thisQuantity,/*用于判断是否改变颜色*/
            if(a.technology_number=1, round(sum((a.quantity-ifnull(a.termination_quantity,0)))*b.compute_area,2),0) as gross_area,
            if(a.technology_number=1, sum(a.received_quantity),0) as inventory,
            if(a.technology_number=1, round(sum(a.received_quantity*b.area),2),0) as inventoryArea,
 
            -- show
            sum(a.quantity-ifnull(a.termination_quantity,0)) as quantityShow ,
            round(sum((a.quantity-ifnull(a.termination_quantity,0)))*b.compute_area,2) as gross_areaShow,
            sum(a.received_quantity) as inventoryShow,
            round(sum(a.received_quantity*b.area),2) as inventoryAreaShow
 
 
 
 
            from pp.flow_card as a
            left join sd.order_detail as b
            on a.order_id = b.order_id and a.order_number = b.order_number
            left join sd.product_detail as c
            on c.prod_id = b.product_id and c.glass_sort = a.technology_number
            LEFT JOIN sd.`order` as d
            on a.order_id = d.order_id
            where a.order_id = #{orderId} group by processID
            ) as a
       left join (SELECT process_id,
                         technology_number,
                         sum(broken_num) as broken_num,
                         concat('{',GROUP_CONCAT(reporting_work_nums),'}') as reportWorkQuantity,
                         concat('{',GROUP_CONCAT(reporting_work_counts),'}') as reportWorkQuantityCount
                  from (select
                            opd.process_id,
                            opd.technology_number,
                            concat("\"", process, "\":\"", SUM(reporting_work_num), "\"") as  reporting_work_nums,
                            concat("\"", process, "\":\"", SUM(reporting_work_num_count), "\"") as  reporting_work_counts,
                            sum(broken_num) as broken_num
                        from sd.order_process_detail as opd
                        where opd.order_id = #{orderId}
                        group by opd.process_id,opd.technology_number,opd.process) as bb
                  GROUP BY bb.process_id,bb.technology_number) as b
       on a.process_id = b.process_id and a.technology_number = b.technology_number
       order by a.process_id
 
    </select>
 
    <select id="processCardProgressReportMp">
        select a.product_name,
               b.glass_child,
               d.order_type,
               concat(c.process_id, '/', c.technology_number) as process_id,
               c.process_id as 'processId',
                c.order_id,
               c.order_number,
               c.technology_number,
               b.child_width,
               b.child_height,
               c.quantity,
               c.quantity-ifnull(c.termination_quantity,0) as thisQuantity,/*用于判断是否改变颜色*/
               e.reportWorkQuantity,
               e.reportWorkQuantityShow,
               e.reportWorkQuantityCount,
               e.reportWorkTime,
               e.broken_num,
               c.quantity-ifnull(c.termination_quantity,0) as glassQuantity,
               c.quantity*a.area as gross_area,
               c.quantity-ifnull(c.termination_quantity,0) as quantityShow,
               (c.quantity-ifnull(c.termination_quantity,0))*a.compute_area as grossAreaShow,
               ifnull(f.inventory, 0) as inventoryShow,
               round(ifnull(f.inventory, 0) * a.compute_area, 2) as inventoryAreaShow, -- 库存面积
               ifnull(dd.quantity, 0) as shippedQuantityShow, -- 发货数量
               (ifnull(c.received_quantity, 0))*a.compute_area  as StorageAreaShow,-- 入库面积
 
               if(c.technology_number=1,(c.quantity-ifnull(c.termination_quantity,0))*a.compute_area,0) as grossArea,
               if(c.technology_number=1,ifnull(f.inventory, 0) ,0)                        as inventory,
               if(c.technology_number=1,round(ifnull(f.inventory, 0) * a.compute_area, 2),0)      as inventoryArea,
               if(c.technology_number=1,ifnull(dd.quantity, 0) ,0)                          as shippedQuantity,
               if(c.technology_number=1,(ifnull(c.received_quantity, 0))*a.compute_area,0)  as StorageArea,
 
 
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(a.other_columns, '$.S01')),'') AS glassNumber,
               b.`group`
 
        from pp.flow_card as c
                 left join
             sd.order_detail as a
             on c.order_id = a.order_id
                 and c.order_number = a.order_number
                 left join sd.order_glass_detail as b
                           on c.order_id = b.order_id
                               and b.order_number = c.order_number
                               and c.technology_number = b.technology_number
                 left join sd.`order` as d
                           on c.order_id = d.order_id
                 left join mm.finished_goods_inventory as f
                           on c.order_id = f.order_id and f.order_number = c.order_number
                 left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
                 left join (SELECT process_id,
                                   order_number,
                                   technology_number,
                                   sum(a.broken_num) as broken_num,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", if(technology_number!=1 and (bd.nickname='stepD' || bd.nickname='stepB' ) ,0,reporting_work_num), "\"")),
                                          '}'
                                       )             as reportWorkQuantity,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num, "\"")),
                                          '}'
                                       )             as reportWorkQuantityShow,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num_count, "\"")),
                                          '}'
                                       )             as reportWorkQuantityCount,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", IFNULL(date(update_time),''), "\"")),
                                          '}'
                                       )             as reportWorkTime
                            FROM sd.order_process_detail as a
                                     left join (SELECT DISTINCT basic_name,nickname from sd.basic_data as bd where  bd.basic_category = 'process') as bd
                                               on a.process = bd.basic_name
                            where a.order_id = #{orderId}
                            GROUP BY process_id, a.order_number, a.technology_number
 
 
        ) as e
                           on e.process_id = c.process_id
                               and e.technology_number = c.technology_number
                               and e.order_number = c.order_number
        where a.order_id = #{orderId} and d.create_order>0 and c.quantity-ifnull(c.termination_quantity,0)>0
        group by c.order_number,
                 c.technology_number,
                 c.process_id
        order by c.process_id, c.order_number, c.technology_number
    </select>
 
    <select id="yieldProcessMp">
        select
            rw.this_process as process,
            rw.completedQuantity,
            IFNULL(dd.breakageQuantity,0) as breakageQuantity,
            rw.completedArea,
            IFNULL(dd.breakageArea,0) as breakageArea,
            CONCAT(ROUND(TRUNCATE(rw.completedArea/(rw.completedArea + IFNULL(dd.breakageArea,0)),2)*100), '%') as finished
        from
            (
                select
                    tb.process as this_process,
                    SUM(tb.completedQuantity) as completedQuantity,
                    ROUND(SUM(completedArea),2) as completedArea
                from (
                         SELECT
                             rw.process_id,
                             rw.this_process                                   AS process,
                             rw.teams_groups_name                               AS teamsGroupsName,
                             rwd.order_number                                   AS orderNumber,
                             MAX(bd.nickname)                                   AS nickname,
                             /* 仅当 nickname 为空时才显示 technology_number,否则为 NULL */
                             MIN(CASE WHEN bd.nickname IS NULL THEN rwd.technology_number ELSE NULL END) AS technologyNumber,
                             COALESCE((rwd.completed_quantity), 0)           AS completedQuantity,
                             ROUND(COALESCE((rwd.child_width * rwd.child_height * rwd.completed_quantity),0)/1000000, 2)
                                 AS completedArea
                         FROM reporting_work rw
                                  LEFT JOIN reporting_work_detail rwd
                                            ON rwd.reporting_work_id = rw.reporting_work_id
                                  LEFT JOIN sd.basic_data bd
                                            ON bd.basic_name = rw.this_process
 
                         WHERE rw.reporting_work_time &gt;= #{selectTime1}
                           AND rw.reporting_work_time &lt; #{selectTime2}
                           AND rw.reviewed_state &gt;= 0
                         GROUP BY
                             rw.reporting_work_id,
                             rw.process_id,
                             rw.this_process,
                             rw.teams_groups_name,
                             rwd.order_number,
                             CASE WHEN bd.nickname IS NULL THEN rwd.technology_number ELSE NULL END
                         ORDER BY rw.process_id,
                                  rw.this_process, rw.teams_groups_name, rwd.order_number,
                                  CASE WHEN bd.nickname IS NULL THEN rwd.technology_number ELSE NULL END
                     ) as tb
                GROUP BY tb.process
            ) as rw
                left join
            (
                select dd.responsible_process,sum(dd.breakage_quantity) as breakageQuantity
                     ,ROUND(SUM((rwd.child_width) * (rwd.child_height) * dd.breakage_quantity / 1000000), 2) as breakageArea
                from reporting_work rw left join damage_details dd on dd.reporting_work_id = rw.reporting_work_id
                                       LEFT JOIN reporting_work_detail rwd on rwd.reporting_work_id = dd.reporting_work_id and rwd.order_number = dd.order_number and rwd.technology_number  = dd.technology_number
                where rw.reporting_work_time &gt;= #{selectTime1}
                  AND rw.reporting_work_time &lt; #{selectTime2}
                  AND rw.reviewed_state &gt;= 0 and dd.available =0
                GROUP BY dd.responsible_process
            ) as dd on  rw.this_process = dd.responsible_process
 
 
    </select>
</mapper>