chenlu
2025-07-22 17a165040ee30e09bb5de343b2e5bf4d916b3883
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
 
package com.example.erp.service.pp;
 
import com.baomidou.dynamic.datasource.annotation.DS;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.erp.dto.pp.*;
import com.example.erp.entity.pp.Report;
import com.example.erp.entity.sd.BasicData;
import com.example.erp.entity.sd.OrderDetail;
import com.example.erp.entity.sd.OrderGlassDetail;
import com.example.erp.entity.sd.ProductDetail;
import com.example.erp.mapper.pp.FlowCardMapper;
import com.example.erp.mapper.pp.ProductionSchedulingMapper;
import com.example.erp.mapper.pp.ReportMapper;
import com.example.erp.mapper.pp.ReportingWorkMapper;
import com.example.erp.mapper.sd.*;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
 
import java.sql.Date;
import java.time.LocalDate;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
 
@Service
@DS("pp")
public class ReportService {
    private final ReportMapper reportMapper;
 
    private final OrderProcessDetailMapper orderProcessDetailMapper;
    private final ProductionSchedulingMapper productionSchedulingMapper;
 
    private final OrderGlassDetailMapper orderGlassDetailMapper;
    private final BasicDataMapper basicDataMapper;
    private final ProductDetailMapper productDetailMapper;
    private final OrderDetailMapper orderDetailMapper;
 
    FlowCardMapper flowCardMapper;
    private ReportingWorkMapper reportingWorkMapper;
 
 
    //上工序报工班组
    private void mergeTeamsGroupsName( List<WorkInProgressDTO> dataList1,List<WorkInProgressDTO> dataList2) {
 
        for (WorkInProgressDTO dto1 : dataList1) {
            //根据当前工序获取 是否为单片、夹胶、或者全部
          BasicData basicData =  basicDataMapper.
                  selectOne(new QueryWrapper<BasicData>()
                          .eq("basic_name", dto1.getThisProcess())
                          .last("limit 1")
                  );
 
          OrderDetail orderDetail = orderDetailMapper
                .selectOne(
                        new QueryWrapper<OrderDetail>()
                                .eq("order_id", dto1.getOrderId())
                                .eq("order_number", dto1.getOrderNumber())
                );
 
          //如果为单片,则根据产品名称和工艺编号获取玻璃名称
          if(basicData.getNickname()==null || basicData.getNickname().isEmpty()){
              ProductDetail productDetail = productDetailMapper.
                      selectOne(new QueryWrapper<ProductDetail>()
                              .eq("prod_id", orderDetail.getProductId())
                              .eq("glass_sort",dto1.getTechnologyNumber())
                      );
              dto1.setGlassName(productDetail.getDetail());
 
          }else if(basicData.getNickname().equals("stepC")){
              OrderGlassDetail orderGlassDetailGroup = orderGlassDetailMapper
                      .selectOne(new QueryWrapper<OrderGlassDetail>()
                              .eq("order_id", dto1.getOrderId())
                              .eq("order_number", dto1.getOrderNumber())
                              .eq("technology_number",dto1.getTechnologyNumber())
                      );
 
              String glassName = productDetailMapper.getGlassNameByGroup(
                      orderDetail.getProductId(),
                      orderGlassDetailMapper.getMinTechnologyNumberByGroup(dto1.getOrderId(),dto1.getOrderNumber(), String.valueOf(orderGlassDetailGroup.getGroup())),
                      orderGlassDetailMapper.getMaxTechnologyNumberByGroup(dto1.getOrderId(),dto1.getOrderNumber(), String.valueOf(orderGlassDetailGroup.getGroup()))
              );
              dto1.setGlassName(glassName);
 
          }else{
              dto1.setGlassName(dto1.getProductName());
          }
 
        }
 
        Function<WorkInProgressDTO, String> keyFn = dto ->
                dto.getProcessId() + "|" +
                        dto.getOrderNumber() + "|" +
                        dto.getTechnologyNumber();
 
        Map<String, WorkInProgressDTO> map2 = dataList2.stream()
                .collect(Collectors.toMap(
                        keyFn,
                        Function.identity(),
                        (existing, replacement) -> existing
                ));
 
        for (WorkInProgressDTO dto1 : dataList1) {
            WorkInProgressDTO dto2 = map2.get(keyFn.apply(dto1));
            if (dto2 != null) {
                String tgn = dto2.getTeamsGroupsName();
                if (StringUtils.hasText(tgn)) {
                    dto1.setTeamsGroupsName(tgn);
                }
            }
        }
    }
 
 
    public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper,
                         ProductionSchedulingMapper productionSchedulingMapper, FlowCardMapper flowCardMapper,
                         OrderGlassDetailMapper orderGlassDetailMapper, BasicDataMapper basicDataMapper,
                         ProductDetailMapper productDetailMapper, OrderDetailMapper orderDetailMapper,
                         ReportingWorkMapper reportingWorkMapper) {
        this.reportMapper = reportMapper;
        this.orderProcessDetailMapper = orderProcessDetailMapper;
        this.productionSchedulingMapper = productionSchedulingMapper;
        this.flowCardMapper = flowCardMapper;
        this.orderGlassDetailMapper = orderGlassDetailMapper;
        this.basicDataMapper = basicDataMapper;
        this.productDetailMapper = productDetailMapper;
        this.orderDetailMapper = orderDetailMapper;
        this.reportingWorkMapper = reportingWorkMapper;
    }
 
    //流程卡进度方法
    public Map<String, Object> processCardProgressSv(String orderId, List<Integer> columns) {
        Map<String, Object> map = new HashMap<>();
        //获取表格内容数据
        map.put("data", reportMapper.processCardProgressMp(orderId));
 
        //获取表头工序筛选数据
        List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcess(orderId);
        List<Map<String, String>> processList = processFilterList;
 
        List<String> filterList = new ArrayList<>();
        //循环遍历数组,判断此序号当前的工序
        for (int i = 1; i < processFilterList.size(); i++) {
            filterList.add(processFilterList.get(i).get("process"));
            List<Map<String, String>> lastProcessList =
                    orderProcessDetailMapper.filterLastProcess(
                            orderId,
                            String.valueOf(processFilterList.get(i).get("order_number")),
                            String.valueOf(processFilterList.get(i).get("technology_number")),
                            String.valueOf(processFilterList.get(i).get("id"))
                    );
            if (!lastProcessList.isEmpty()) {
                int finalI = i;
                lastProcessList.forEach(lastProcess -> {
                    if (filterList.contains(lastProcess.get("process"))) {
                        processList.add(lastProcess);
                    }
                });
            }
 
        }
        // 使用HashSet来记录已经遇到的value值
        Set<String> seenValues = new HashSet<>();
        // 创建一个新的List来存储结果
        List<Map<String, String>> uniqueList = new ArrayList<>();
 
        // 反向遍历原始List
        for (int i = processList.size() - 1; i >= 0; i--) {
            Map<String, String> maps = processList.get(i);
            String value = maps.values().iterator().next(); // 假设每个Map只有一个value
 
            // 如果value还没有被看到过,就添加到结果List和HashSet中
            if (!seenValues.contains(value)) {
                uniqueList.add(0, maps); // 添加到结果List的开头,以保持原顺序
                seenValues.add(value);
            }
        }
        map.put("title", uniqueList);
 
 
        List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId);
        List<Map<String, Integer>> rowCount = new ArrayList<>();
        columns.forEach(col -> {
            getRowCount.forEach(row -> {
                Map<String, Integer> getRow = new HashMap<>();
                // { row: 0, col: 1, rowspan: 3, colspan: 0},
                Object rowNumObj = row.get("RowNum");
                if (rowNumObj instanceof Double) {
                    getRow.put("row", ((Double) rowNumObj).intValue());
                } else if (rowNumObj instanceof Integer) {
                    getRow.put("row", (Integer) rowNumObj);
                }
                getRow.put("col", col);
                getRow.put("rowspan", row.get("rowCount"));
                getRow.put("colspan", 0);
                rowCount.add(getRow);
            });
        });
 
 
        map.put("mergeCells", rowCount);
 
        return map;
    }
 
    public Map<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize, List<String> selectDate, CrossProcessBreakingDTO crossProcessBreakingDTO) {
        Integer offset = (pageNum - 1) * pageSize;
        String endDate = LocalDate.now().toString();
        String startDate = LocalDate.now().minusDays(15).toString();
        if (selectDate != null && selectDate.size() == 2) {
            if (!selectDate.get(0).isEmpty()) {
                startDate = selectDate.get(0);
            }
            if (!selectDate.get(1).isEmpty()) {
                endDate = selectDate.get(1);
            }
        }
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.getProcessBreaking(offset, pageSize, startDate, endDate, crossProcessBreakingDTO));
        map.put("total", reportMapper.getProcessBreakingTotal(offset, pageSize, startDate, endDate, crossProcessBreakingDTO));
        List<String> list = new ArrayList<>();
        list.add(startDate);
        list.add(endDate);
        map.put("selectDate", list);
        return map;
    }
 
    public Map<String, Object> workInProgressSv(Integer pageNum, Integer pageSize, String orderId, String inputProject, String selectProcesses, String optionVal, WorkInProgressDTO workInProgressDTO) {
        Integer offset = (pageNum - 1) * pageSize;
        if ("null".equals(orderId)) {
            orderId = "";
        }
        if ("null".equals(inputProject)) {
            inputProject = "";
        }
        if ("null".equals(optionVal)) {
            optionVal = ("");
        }
        if (selectProcesses.equals("全部")){
            selectProcesses="";
        }
        Map<String, Object> map = new HashMap<>();
        List<WorkInProgressDTO> dataList2  =reportMapper.workInProgressMpdataList2(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO);
        if (optionVal.equals("1")){
            System.out.println(1);
            /* 根据销售单号汇总*/
            //map.put("data", reportMapper.workInProgressOrderMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            List<WorkInProgressDTO> dataList1  =reportMapper.workInProgressOrderMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO);
            mergeTeamsGroupsName(dataList1, dataList2);
            map.put("data",dataList1);
            // map.put("total", reportMapper.workInProgressOrderTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO));
        }else if(optionVal.equals("2")){
            System.out.println(2);
            /* 根据流程卡号汇总*/
            //map.put("data", reportMapper.workInProgressProcessMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            List<WorkInProgressDTO> dataList1  =reportMapper.workInProgressProcessMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO);
            mergeTeamsGroupsName(dataList1, dataList2);
            map.put("data",dataList1);
            // map.put("total", reportMapper.workInProgressProcessTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO));
 
        } else if (optionVal.equals("3")) {
 
        } else {
            //没有选择分组
            //map.put("data", reportMapper.workInProgressMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            List<WorkInProgressDTO> dataList1  =reportMapper.workInProgressMpdataList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO);
            mergeTeamsGroupsName(dataList1, dataList2);
            map.put("data",dataList1);
            //map.put("total", reportMapper.workInProgressTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO));
 
        }
        map.put("process", productionSchedulingMapper.selectProcess());
        return map;
    }
 
    public Map<String, Object> selectProcessToBeCompletedSv(Date selectTime1, Date selectTime2, String orderId, String inputProject, String selectProcesses, Report report) {
        if ("null".equals(orderId)) {
            orderId = "";
        }
        if ("null".equals(inputProject)) {
            inputProject = "";
        }
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.processToBeCompletedMp(selectTime1, selectTime2, orderId, inputProject, selectProcesses, report));
        map.put("process", productionSchedulingMapper.selectProcess());
        map.put("footSum" ,reportMapper.processToBeCompletedFootSum(selectTime1, selectTime2, orderId, inputProject, selectProcesses, report));
 
        return map;
    }
 
    public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize, String selectTime1, String selectTime2, DamageReportDTO damageReportDTO) {
        Integer offset = (pageNum - 1) * pageSize;
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.selectDamageReportMp(offset, pageSize, selectTime1, selectTime2, damageReportDTO));
        map.put("total", reportMapper.getDamageReportPageTotal(offset, pageSize, selectTime1, selectTime2, damageReportDTO));
        map.put("footSum" ,reportMapper.damageReportFootSum(selectTime1, selectTime2, damageReportDTO));
        return map;
    }
 
    public Map<String, Object> splittingDetailsOutsideSv(String orderId, Report report) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.splittingDetailsOutsideMp(orderId, report));
        map.put("orderOtherMoney", flowCardMapper.selectorderOtherMoney());
        return map;
    }
 
    public Map<String, Object> qualityReportSv(Date selectTime1, Date selectTime2, Report report) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.qualityReportMp(selectTime1, selectTime2, report));
        return map;
    }
 
    public Map<String, Object> yieldSv(Date selectTime1, Date selectTime2, String selectProcesses, Report report) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.yieldMp(selectTime1, selectTime2, selectProcesses, report));
        map.put("process", productionSchedulingMapper.selectProcess());
        return map;
    }
 
    public Map<String, Object> productionScheduleSv(String orderId, List<Integer> columns) {
        Map<String, Object> map = new HashMap<>();
        //获取表格内容数据
        map.put("data", reportMapper.productionScheduleMp(orderId));
 
        //获取表头工序筛选数据
        List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcess(orderId);
        List<Map<String, String>> processList = processFilterList;
 
        List<String> filterList = new ArrayList<>();
        //循环遍历数组,判断此序号当前的工序
        for (int i = 1; i < processFilterList.size(); i++) {
            filterList.add(processFilterList.get(i).get("process"));
            List<Map<String, String>> lastProcessList =
                    orderProcessDetailMapper.filterLastProcess(
                            orderId,
                            String.valueOf(processFilterList.get(i).get("order_number")),
                            String.valueOf(processFilterList.get(i).get("technology_number")),
                            String.valueOf(processFilterList.get(i).get("id"))
                    );
            if (!lastProcessList.isEmpty()) {
                int finalI = i;
                lastProcessList.forEach(lastProcess -> {
                    if (filterList.contains(lastProcess.get("process"))) {
                        processList.add(lastProcess);
                    }
                });
            }
 
        }
        // 使用HashSet来记录已经遇到的value值
        Set<String> seenValues = new HashSet<>();
        // 创建一个新的List来存储结果
        List<Map<String, String>> uniqueList = new ArrayList<>();
 
        // 反向遍历原始List
        for (int i = processList.size() - 1; i >= 0; i--) {
            Map<String, String> maps = processList.get(i);
            String value = maps.values().iterator().next(); // 假设每个Map只有一个value
 
            // 如果value还没有被看到过,就添加到结果List和HashSet中
            if (!seenValues.contains(value)) {
                uniqueList.add(0, maps); // 添加到结果List的开头,以保持原顺序
                seenValues.add(value);
            }
        }
        map.put("title", uniqueList);
 
 
        List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId);
        List<Map<String, Integer>> rowCount = new ArrayList<>();
        columns.forEach(col -> {
            getRowCount.forEach(row -> {
                Map<String, Integer> getRow = new HashMap<>();
                // { row: 0, col: 1, rowspan: 3, colspan: 0},
                getRow.put("row", row.get("RowNum"));
                getRow.put("col", col);
                getRow.put("rowspan", row.get("rowCount"));
                getRow.put("colspan", 0);
                rowCount.add(getRow);
            });
        });
 
 
        map.put("mergeCells", rowCount);
 
        return map;
    }
 
    public Map<String, Object> taskCompletionStatusSv(Date selectTime1, Date selectTime2, List<Integer> columns) {
        Map<String, Object> map = new HashMap<>();
        //获取表格内容数据
        map.put("data", reportMapper.taskCompletionStatusMp(selectTime1, selectTime2));
 
        //获取表头工序筛选数据
        List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcessCollect(selectTime1, selectTime2);
        List<Map<String, String>> processList = processFilterList;
 
        List<String> filterList = new ArrayList<>();
        //循环遍历数组,判断此序号当前的工序
        for (int i = 1; i < processFilterList.size(); i++) {
            filterList.add(processFilterList.get(i).get("process"));
            List<Map<String, String>> lastProcessList =
                    orderProcessDetailMapper.filterLastProcess(
                            String.valueOf(processFilterList.get(i).get("order_id")),
                            String.valueOf(processFilterList.get(i).get("order_number")),
                            String.valueOf(processFilterList.get(i).get("technology_number")),
                            String.valueOf(processFilterList.get(i).get("id"))
                    );
            if (!lastProcessList.isEmpty()) {
                int finalI = i;
                lastProcessList.forEach(lastProcess -> {
                    if (filterList.contains(lastProcess.get("process"))) {
                        processList.add(lastProcess);
                    }
                });
            }
 
        }
        // 使用HashSet来记录已经遇到的value值
        Set<String> seenValues = new HashSet<>();
        // 创建一个新的List来存储结果
        List<Map<String, String>> uniqueList = new ArrayList<>();
 
        // 反向遍历原始List
        for (int i = processList.size() - 1; i >= 0; i--) {
            Map<String, String> maps = processList.get(i);
            String value = maps.values().iterator().next(); // 假设每个Map只有一个value
 
            // 如果value还没有被看到过,就添加到结果List和HashSet中
            if (!seenValues.contains(value)) {
                uniqueList.add(0, maps); // 添加到结果List的开头,以保持原顺序
                seenValues.add(value);
            }
        }
        map.put("title", uniqueList);
 
 
        List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRowCollect(selectTime1, selectTime2);
        List<Map<String, Integer>> rowCount = new ArrayList<>();
        columns.forEach(col -> {
            getRowCount.forEach(row -> {
                Map<String, Integer> getRow = new HashMap<>();
                // { row: 0, col: 1, rowspan: 3, colspan: 0},
                getRow.put("row", row.get("RowNum"));
                getRow.put("col", col);
                getRow.put("rowspan", row.get("rowCount"));
                getRow.put("colspan", 0);
                rowCount.add(getRow);
            });
        });
 
 
        map.put("mergeCells", rowCount);
 
        return map;
    }
 
    public Map<String, Object> orderPlanDecompositionSv(Date selectTime1, Date selectTime2, Report report) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.orderPlanDecompositionMp(selectTime1, selectTime2, report));
        return map;
    }
 
    public Map<String, Object> orderReportingWorks(Date selectTime1, Date selectTime2, Report report) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.orderReportingWorks(selectTime1, selectTime2, report));
        return map;
    }
 
    public Map<String, Object> rawMaterialRequisitionSv(Date selectTime1, Date selectTime2, Report report) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.rawMaterialRequisitionMp(selectTime1, selectTime2, report));
        return map;
    }
 
    public List exportCrossProcessBreakingSv(List<LocalDate> dates) {
        return reportMapper.exportCrossProcessBreakingMp(dates);
    }
 
    public List exportDamageReportSv(List<LocalDate> dates) {
        if (dates != null && dates.size() > 1) {
            dates.set(1, dates.get(1).plusDays(1)); // 将第二个日期加一天
        }
        return reportMapper.exportDamageReportMp(dates);
    }
 
    public List exportOrderPlanDecompositionSv(List<LocalDate> dates) {
        return reportMapper.exportOrderPlanDecompositionMp(dates);
    }
 
    public List exportProcessToBeCompletedSv(Map<String, Object> dates) {
        List<LocalDate> date= (List<LocalDate>) dates.get("date");
        String process= (String) dates.get("processes");
        String inputVal= (String) dates.get("inputVal");
        String project= (String) dates.get("project");
        if ("null".equals(inputVal)) {
            inputVal = "";
        }
        if ("null".equals(project)) {
            project = "";
        }
        return reportMapper.exportProcessToBeCompletedMp(date,process,inputVal,project);
    }
 
    public List exportWorkInProgressSv(Map<String, Object> dates) {
        String process= (String) dates.get("processes");
        if (process.equals("全部")){
            process="";
        }
        String inputVal= (String) dates.get("inputVal");
        String project= (String) dates.get("project");
        if ("null".equals(inputVal)) {
            inputVal = "";
        }
        if ("null".equals(project)) {
            project = "";
        }
        List<WorkInProgressDTO> dataList1  =reportMapper.exportWorkInProgressMp(process,inputVal,project);
        List<WorkInProgressDTO> dataList2  =reportMapper.exportWorkInProgressMpdataList2(process);
 
        mergeTeamsGroupsName(dataList1, dataList2);
        return dataList1;
    }
 
    public List exportTaskCompletionStatusSv(Map<String, Object> dates) {
        return reportMapper.exportTaskCompletionStatusMp(dates);
    }
 
    public List exportRawMaterialRequisitionSv(List<LocalDate> dates) {
        return reportMapper.exportRawMaterialRequisitionMp(dates);
    }
 
    public List exportQualityReportSv(List<LocalDate> dates) {
        return reportMapper.exportQualityReportSv(dates);
    }
 
    public List exportYieldSv(Map<String, Object> dates) {
        List<LocalDate> date= (List<LocalDate>) dates.get("date");
        String process= (String) dates.get("processes");
        return reportMapper.exportYieldMp(date,process);
    }
 
    public Map<String, Object> teamOutputSv(Integer pageNum, Integer pageSize, String selectTime1, String selectTime2, String selectProcesses, TeamOutputDTO teamOutputDTO) {
        if (selectProcesses.equals("全部")){
            selectProcesses="";
        }
        Integer offset = (pageNum - 1) * pageSize;
        Map<String, Object> map = new HashMap<>();
        String laminating = reportMapper.getLaminating(selectProcesses);
        map.put("data", reportMapper.teamOutputMp(offset, pageSize, selectTime1, selectTime2,selectProcesses,laminating, teamOutputDTO));
        map.put("process", productionSchedulingMapper.selectProcess());
        map.put("total", reportMapper.teamOutputPageTotal(offset, pageSize, selectTime1, selectTime2,selectProcesses,laminating, teamOutputDTO));
        map.put("footSum" ,reportMapper.teamOutputFootSum(selectTime1, selectTime2,selectProcesses,laminating, teamOutputDTO));
        return map;
    }
 
    public Map<String, Object> scheduleProductionScheduleSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, String processes, ScheduleProductionScheduleDTO scheduleProductionScheduleDTO) {
        Integer offset = (pageNum - 1) * pageSize;
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.scheduleProductionScheduleMp(offset, pageSize, selectTime1, selectTime2,processes, scheduleProductionScheduleDTO));
        map.put("total", reportMapper.getScheduleProductionScheduleTotal(offset, pageSize, selectTime1, selectTime2,processes, scheduleProductionScheduleDTO));
        map.put("process", productionSchedulingMapper.selectProcess());
        return map;
    }
 
    public List exportScheduleReportSv(Map<String, Object> dates) {
        List<LocalDate> date= (List<LocalDate>) dates.get("date1");
        String process= (String) dates.get("processes");
        return reportMapper.exportScheduleReportMp(date,process);
    }
 
    public List exportTeamOutputSv(Map<String, Object> dates) {
        List<LocalDate> date= (List<LocalDate>) dates.get("date");
        String process= (String) dates.get("processes");
        if (process.equals("全部")){
            process="";
        }
        String laminating = reportMapper.getLaminating(process);
        return reportMapper.exportTeamOutputMp(date,process,laminating);
    }
 
    public Map<String, Object> workInProgressCombinationSv(Integer pageNum, Integer pageSize,String orderId, String inputProject, String selectProcesses, String optionVal, WorkInProgressDTO workInProgressDTO) {
        Integer offset = (pageNum - 1) * pageSize;
        if ("null".equals(orderId)) {
            orderId = "";
        }
        if ("null".equals(inputProject)) {
            inputProject = "";
        }
        if ("null".equals(optionVal)) {
            optionVal = ("");
        }
        if (selectProcesses.equals("全部")){
            selectProcesses="";
        }
        String laminating = "";
        Map<String, Object> map = new HashMap<>();
        // 获取所有工序
        List<String> processList  = reportMapper.selectProcess();
        // 遍历每个工序并调用新方法
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (selectProcesses!=""){
            laminating = reportingWorkMapper.getProcessLaminating(selectProcesses);
            List<Map<String, Object>> singleResult = reportMapper.getWorkInProgressCombination(selectProcesses,laminating,optionVal);
 
            resultList.addAll(singleResult);
        }else {
            for (String process : processList) {
                //获取报工工序是否为复合工程
                laminating = reportingWorkMapper.getProcessLaminating(process);
                List<Map<String, Object>> singleResult = reportMapper.getWorkInProgressCombination(process,laminating,optionVal);
 
                if (singleResult != null && !singleResult.isEmpty()) {
                    resultList.addAll(singleResult);
                }
            }
        }
 
        map.put("data",resultList);
        map.put("process", productionSchedulingMapper.selectProcess());
        return map;
    }
}