zss
2024-12-30 97bb7a8832281eafe0ef947ea095258d355e52f5
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
package com.yuanchu.mom.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.common.GetLook;
import com.yuanchu.mom.dto.CostStatisticsDto;
import com.yuanchu.mom.dto.InsOrderUserDto;
import com.yuanchu.mom.mapper.*;
import com.yuanchu.mom.pojo.*;
import com.yuanchu.mom.service.ReportService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
 
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
 
@Service
@AllArgsConstructor
public class ReportServiceImpl implements ReportService {
 
    private InsOrderMapper insOrderMapper;
    private InsSampleMapper insSampleMapper;
    private InsProductUserMapper insProductUserMapper;
    private InsProductMapper insProductMapper;
    private GetLook getLook;
    private ScheduleMapper scheduleMapper;
    private UserMapper userMapper;
    private RoleMapper roleMapper;
    private InsSampleUserMapper insSampleUserMapper;
    private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper;
    private InsOrderStateMapper insOrderStateMapper;
    private InsOrderUserMapper insOrderUserMapper;
 
    //每日业务统计
    @Override
    public Map<String, Object> businessStatisticsByDay(String startTime, String endTime, String type) {
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay();
        LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59);
        LocalDateTime oldStart = start;
        LocalDateTime oldEnd = end;
        switch (type) {
            case "周":
                oldStart = start.minusDays(7);
                oldEnd = end.minusDays(7);
                break;
            case "月":
                oldStart = start.minusMonths(1);
                oldEnd = end.minusMonths(1);
                break;
            case "年":
                oldStart = start.minusYears(1);
                oldEnd = end.minusYears(1);
                break;
        }
        Map<String, Object> map = new HashMap<>();
        /*任务接收*/
        //今日任务接收
        Long receive = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
                .eq(InsOrder::getState, 1)
                .between(InsOrder::getCreateTime, start, end));
        map.put("RECEIVE", receive);
        //昨日任务接收
        Long received = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
                .eq(InsOrder::getState, 1)
                .between(InsOrder::getCreateTime, oldStart, oldEnd));
        //比例=(今天-昨天)/昨天
        BigDecimal ratio = new BigDecimal(receive - received).divide(new BigDecimal(received == 0 ? 1 : received), 2, BigDecimal.ROUND_HALF_UP);
        map.put("RECEIVE_RATIO", ratio);
 
        /*任务已完成*/
        //今日任务完成
        Long finishe = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
                .eq(InsOrder::getState, 4)
                .between(InsOrder::getCreateTime, start, end));
        map.put("FINISHE", finishe);
        //昨日任务完成
        Long finished = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
                .eq(InsOrder::getState, 4)
                .between(InsOrder::getCreateTime, oldStart, oldEnd));
        //任务完成比例=(今天-昨天)/昨天
        BigDecimal finishedRatio = new BigDecimal(finishe - finished).divide(new BigDecimal(finished == 0 ? 1 : finished), 2, BigDecimal.ROUND_HALF_UP);
        map.put("FINISHE_RATIO", finishedRatio);
 
        /*任务剩余*/
        //今日任务剩余
        long surplus = receive - finishe;
        map.put("SURPLUS", surplus);
        //昨日任务剩余
        long surplused = received - finished;
        //剩余比例=(今天-昨天)/昨天
        BigDecimal surplusRatio = new BigDecimal(surplus - surplused).divide(new BigDecimal(surplused == 0 ? 1 : surplused), 2, BigDecimal.ROUND_HALF_UP);
        map.put("SURPLUS_RATIO", surplusRatio);
 
        /*检测费用*/
        //今日检测费用
        QueryWrapper<CostStatisticsDto> costStatisticsDtoQueryWrappers = new QueryWrapper<>();
        costStatisticsDtoQueryWrappers.between("create_time", start, end);
        IPage<CostStatisticsDto> page = new Page<>();
        page.setSize(-1);
        page.setCurrent(-1);
        IPage<CostStatisticsDto> iPage = insOrderMapper.selectCostStatistics(page, costStatisticsDtoQueryWrappers);
        BigDecimal price = BigDecimal.ZERO;
        for (CostStatisticsDto record : iPage.getRecords()) {
            price = price.add(ObjectUtils.isNotEmpty(record.getPrice()) ? record.getPrice() : BigDecimal.ZERO);
        }
        map.put("PRICE", price);
        //昨日检测费用
        QueryWrapper<CostStatisticsDto> costWrappers = new QueryWrapper<>();
        costWrappers.between("create_time", oldStart, oldEnd);
        IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, costWrappers);
        BigDecimal priced = BigDecimal.ZERO;
        for (CostStatisticsDto record : dtoIPage.getRecords()) {
            priced = priced.add(ObjectUtils.isNotEmpty(record.getPrice()) ? record.getPrice() : BigDecimal.ZERO);
        }
        //比例=(今日-昨日)/昨日
        BigDecimal priceRatio = (price.subtract(priced)).divide(priced.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ONE : priced, 2, BigDecimal.ROUND_HALF_UP);
        map.put("PRICE_RATIO", priceRatio);
 
        /*检测工时*/
        //今日检测工时
        Double cost = 0.0;
        for (CostStatisticsDto record : iPage.getRecords()) {
            cost += ObjectUtils.isNotEmpty(record.getCost()) ? record.getCost() : 0.0;
        }
        map.put("COST", cost);
        //昨日检测工时
        Double costed = 0.0;
        for (CostStatisticsDto record : dtoIPage.getRecords()) {
            costed += ObjectUtils.isNotEmpty(record.getCost()) ? record.getCost() : 0.0;
        }
        //比例=(今日-昨日)/昨日
        BigDecimal costRatio = new BigDecimal(cost - costed).divide(new BigDecimal(costed == 0 ? 1 : costed), 2, BigDecimal.ROUND_HALF_UP);
        map.put("COST_RATIO", costRatio);
 
 
        /*检测人员*/
        //今日检测人员
        List<InsProductUser> insProductUsers = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery()
                .between(InsProductUser::getCreateTime, start, end));
        long person = insProductUsers.stream().map(InsProductUser::getCreateUser).distinct().count();
        map.put("PERSON", person);
        //昨日检测人员
        List<InsProductUser> insProductUserss = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery()
                .between(InsProductUser::getCreateTime, oldStart, oldEnd));
        long persons = insProductUserss.stream().map(InsProductUser::getCreateUser).distinct().count();
        //比例=(今天-昨天)/昨天
        BigDecimal personRatio = new BigDecimal(person - persons).divide(new BigDecimal(persons == 0 ? 1 : persons), 2, BigDecimal.ROUND_HALF_UP);
        map.put("PERSON_RATIO", personRatio);
 
        /*近十日任务接收量与完成量*/
        //获取近十日的横坐标
        LocalDate startDate = LocalDate.parse(startTime, format);
        LocalDate endDate = LocalDate.parse(endTime, format);
        List<String> lastTenDays = new ArrayList<>();
        List<Long> receTenDays = new ArrayList<>();
        List<Long> finTenDays = new ArrayList<>();
        while (!startDate.isAfter(endDate)) {
            if (type.equals("年")) {
                lastTenDays.add(startDate.format(format).substring(0, 7));
            } else {
                lastTenDays.add(startDate.format(format));
            }
            receTenDays.add(insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
                    .eq(InsOrder::getState, 1)
                    .between(InsOrder::getCreateTime, startDate.atStartOfDay(), startDate.plusMonths(1).minusDays(1).atTime(23, 59, 59))));
            finTenDays.add(insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
                    .eq(InsOrder::getState, 4)
                    .between(InsOrder::getCreateTime, startDate.atStartOfDay(), startDate.plusMonths(1).minusDays(1).atTime(23, 59, 59))));
            if (type.equals("年")) {
                startDate = startDate.plusMonths(1);
            } else {
                startDate = startDate.plusDays(1);
            }
        }
        map.put("DAYS", lastTenDays);
        map.put("RECETENDAYS", receTenDays);
        map.put("FINISHTENDAYS", finTenDays);
        return map;
    }
 
    //检测项目统计
    @Override
    public Map<String, Object> testProductByDay(String startTime, String endTime, String type) {
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay();
        LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59);
        LocalDateTime oldStart = start;
        LocalDateTime oldEnd = end;
        Map<String, Object> map = new HashMap<>();
        switch (type) {
            case "周":
                oldStart = start.minusDays(7);
                oldEnd = end.minusDays(7);
                break;
            case "月":
                oldStart = start.minusMonths(1);
                oldEnd = end.minusMonths(1);
                break;
            case "年":
                oldStart = start.minusYears(1);
                oldEnd = end.minusYears(1);
                break;
        }
        /*项目接收*/
        //今日项目接收量
        Long receive = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getState, 1)
                .between(InsProduct::getCreateTime, start, end));
        map.put("RECEVICE", receive);
        //昨日项目接收量
        Long received = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getState, 1)
                .between(InsProduct::getCreateTime, oldStart, oldEnd));
        //比例=(今天-昨天)/昨天
        BigDecimal ratio = new BigDecimal(receive - received).divide(new BigDecimal(received == 0 ? 1 : received), 2, BigDecimal.ROUND_HALF_UP);
        map.put("RECEIVE_RATIO", ratio);
 
        /*项目完成*/
        //今日项目完成量
        Long finishe = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getState, 1)
                .isNotNull(InsProduct::getInsResult)
                .between(InsProduct::getCreateTime, start, end));
        map.put("FINISHE", finishe);
        //昨日项目完成量
        Long finished = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getState, 1)
                .isNotNull(InsProduct::getInsResult)
                .between(InsProduct::getCreateTime, oldStart, oldEnd));
        //任务完成比例=(今天-昨天)/昨天
        BigDecimal finishedRatio = new BigDecimal(finishe - finished).divide(new BigDecimal(finished == 0 ? 1 : finished), 2, BigDecimal.ROUND_HALF_UP);
        map.put("FINISHE_RATIO", finishedRatio);
 
        /*项目剩余*/
        //今日项目剩余量
        long surplus = receive - finishe;
        map.put("SURPLUS", surplus);
        //昨日项目剩余
        long surplused = received - finished;
        //剩余比例=(今天-昨天)/昨天
        BigDecimal surplusRatio = new BigDecimal(surplus - surplused).divide(new BigDecimal(surplused == 0 ? 1 : surplused), 2, BigDecimal.ROUND_HALF_UP);
        map.put("SURPLUS_RATIO", surplusRatio);
 
        /*今日项目合格率*/
        //今日完成量中的合格量/今日完成量
        Long accept = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getState, 1)
                .isNotNull(InsProduct::getInsResult)
                .ne(InsProduct::getInsResult, 0)
                .between(InsProduct::getCreateTime, start, end));
        map.put("ACCEPT", accept);
        BigDecimal acceptRate = new BigDecimal(accept).divide(new BigDecimal(finishe == 0 ? 1 : finishe), 2, BigDecimal.ROUND_HALF_UP);
        map.put("ACCEPT_RATE_TODAY", acceptRate);
 
        /*今日项目完成率*/
        //今日完成量/今日接收量
        BigDecimal finishRate = new BigDecimal(finishe).divide(new BigDecimal(receive == 0 ? 1 : receive), 2, BigDecimal.ROUND_HALF_UP);
        map.put("FINISH_RATE_TODAY", finishRate);
 
        /*今日项目延期率*/
        //今日项目剩余/今日项目接收量
        BigDecimal delayRate = new BigDecimal(surplus).divide(new BigDecimal(received == 0 ? 1 : received), 2, BigDecimal.ROUND_HALF_UP);
        map.put("DELAY_RATE_TODAY", delayRate);
 
        /*近十日的项目接收量与完成量*/
        //获取近十日的横坐标
        LocalDate startDate = LocalDate.parse(startTime, format);
        LocalDate endDate = LocalDate.parse(endTime, format);
        List<String> lastTenDays = new ArrayList<>();
        List<Long> receTenDays = new ArrayList<>();
        List<Long> finTenDays = new ArrayList<>();
        while (!startDate.isAfter(endDate)) {
            if (type.equals("年")) {
                lastTenDays.add(startDate.format(format).substring(0, 7));
            } else {
                lastTenDays.add(startDate.format(format));
            }
            receTenDays.add(insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                    .eq(InsProduct::getState, 1)
                    .between(InsProduct::getCreateTime, startDate.atStartOfDay(), startDate.plusMonths(1).minusDays(1).atTime(23, 59, 59))));
            finTenDays.add(insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                    .eq(InsProduct::getState, 1)
                    .isNotNull(InsProduct::getInsResult)
                    .between(InsProduct::getCreateTime, startDate.atStartOfDay(), startDate.plusMonths(1).minusDays(1).atTime(23, 59, 59))));
            if (type.equals("年")) {
                startDate = startDate.plusMonths(1);
            } else {
                startDate = startDate.plusDays(1);
            }
        }
        map.put("DAYS", lastTenDays);
        map.put("RECETENDAYS", receTenDays);
        map.put("FINISHTENDAYS", finTenDays);
 
        return map;
    }
 
    //首页-->日历任务图
    @Override
    public Map<String, Object> calendarWorkByWeek() {
        Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
        String name = roleMapper.selectById(userMapper.selectById(userId).getRoleId()).getName();
        Map<String, Object> map = new HashMap<>();
        List<Integer> insState = new ArrayList<>();
        insState.add(0);
        insState.add(1);
        /*获取后一周日期*/
        LocalDate currentDate = LocalDate.now();
        List<LocalDate> weekDays = new ArrayList<>();
        for (int i = 6, j = 0; i >= 0; i--, j++) {
            weekDays.add(currentDate.minusDays(i));
            //查询当天需要检测的委托订单
            List<InsOrder> insOrders = insOrderMapper.selectList(Wrappers.<InsOrder>lambdaQuery()
                    .eq(InsOrder::getState, 1)
                    .in(InsOrder::getInsState, insState)
                    .apply("DATE(create_time) = CURDATE() - INTERVAL " + j + " DAY"));
            //如果当前登录人是测试工程师或者是检测组长,需要过滤出检验人是他们的订单或者是还没检验的订单
            if (name.equals("测试工程师") || name.equals("检测组长")) {
                insOrders = insOrders.stream().filter(insOrder -> {
                    List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insOrder.getId()));
                    List<Integer> sampleId = insSamples.stream().map(InsSample::getId).collect(Collectors.toList());
                    List<InsSampleUser> insSampleUsers = insSampleUserMapper.selectList(Wrappers.<InsSampleUser>lambdaQuery()
                            .in(InsSampleUser::getInsSampleId, sampleId)
                            .eq(InsSampleUser::getState, 0)  //检验人
                    );
                    return insSampleUsers.size() == 0 || insSampleUsers.stream().map(InsSampleUser::getUserId).collect(Collectors.toList()).contains(userId);
                }).collect(Collectors.toList());
            }
            //如果当前登录人是送样员,需过滤出单子的送样员是当前人的订单
            else if (name.equals("送样员")) {
                insOrders = insOrders.stream().filter(insOrder ->
                        ObjectUtils.isNotEmpty(insOrder.getIssueUser()) && insOrder.getIssueUser().equals(userId)
                ).collect(Collectors.toList());
            }
            List<Map<String, Object>> works = insOrders.stream().map(insOrder -> {
                List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insOrder.getId()));
                HashMap<String, Object> hashMap = new HashMap<>();
                hashMap.put("text", insOrder.getEntrustCode());
                hashMap.put("sample", insSamples.stream().map(InsSample::getSample).collect(Collectors.joining(",")));
                hashMap.put("type", insOrder.getType());
                hashMap.put("state", insOrder.getState());
                User user = userMapper.selectById(insOrder.getCreateUser());
                hashMap.put("name", user.getName());
                return hashMap;
            }).collect(Collectors.toList());
            map.put("work" + i, works);
        }
        map.put("weekDays", weekDays);
        return map;
    }
 
    //首页-->添加日程
    @Override
    public int addSchedule(String time, String text) {
        //获取当前用户id
        Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
        Schedule schedule = new Schedule();
        schedule.setUserId(userId);
        schedule.setScheduleTime(LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        schedule.setText(text);
        return scheduleMapper.insert(schedule);
    }
 
    //首页-->我的日程
    @Override
    public List<Schedule> ScheduleByMe(String date) {
        //获取当前用户id
        Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
        LocalDate localDate = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        LocalDateTime startTime = localDate.atStartOfDay();
        LocalDateTime endTime = localDate.plusDays(1).atStartOfDay().minusSeconds(1);
        return scheduleMapper.selectList(Wrappers.<Schedule>lambdaQuery().eq(Schedule::getUserId, userId).between(Schedule::getScheduleTime, startTime, endTime));
    }
 
    //首页-->各站点的工时
    @Override
    public String manHourByStation(String startTime, String endTime, String sonLaboratory) {
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay();
        LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59);
        //查询这个时间内所有的工时
        List<AuxiliaryOutputWorkingHours> auxiliaryOutputWorkingHours = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                .between(AuxiliaryOutputWorkingHours::getCreateTime, start, end));
        double sum = auxiliaryOutputWorkingHours.stream()
                .filter(auxiliaryOutputWorkingHours1 ->
                        insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId()).getSonLaboratory().equals(sonLaboratory)
                ).mapToDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime).sum();
        String num = String.format("%.2f", sum);
        return num;
    }
 
    //首页-->各站点工时每个人所占百分比
    @Override
    public Map<Object, Double> manHourByPerson(String startTime, String endTime, String sonLaboratory) {
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay();
        LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59);
        //查询这个时间内所有的工时
        List<AuxiliaryOutputWorkingHours> auxiliaryOutputWorkingHours = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                .between(AuxiliaryOutputWorkingHours::getCreateTime, start, end));
        //根据检验项查出来的站点进行分类
        List<AuxiliaryOutputWorkingHours> outputWorkingHours = auxiliaryOutputWorkingHours.stream()
                .filter(auxiliaryOutputWorkingHours1 ->
                        insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId()).getSonLaboratory().equals(sonLaboratory)
                ).collect(Collectors.toList());
        Map<Object, Double> mapMap = outputWorkingHours.stream()
                .collect(Collectors.groupingBy(
                        t -> userMapper.selectById(t.getCheck()).getName(),
                        Collectors.summingDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime)));
        return mapMap;
    }
 
    @Override
    public Map<String, IPage<InsOrderUserDto>> timeByStation(String startTime, String endTime, Page page, String sonLaboratory) {
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay();
        LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59);
        Map<String, IPage<InsOrderUserDto>> map = new HashMap<>();
        //查询这个时间内所有检验任务
        if (ObjectUtils.isNotEmpty(sonLaboratory)) {
            IPage<InsOrderUserDto> insOrderUserDtoIPage = insOrderUserMapper.selectInsOrderUserDto(start, end, sonLaboratory, page);
            map.put(sonLaboratory, insOrderUserDtoIPage);
        }else {
            List<InsOrderState> insOrderStates = insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery()
                    .between(InsOrderState::getCreateTime, start, end));
            Map<String, List<InsOrderState>> listMap = insOrderStates.stream().collect(Collectors.groupingBy(InsOrderState::getLaboratory));
            for (Map.Entry<String, List<InsOrderState>> entry : listMap.entrySet()) {
                List<Integer> ids = entry.getValue().stream().map(InsOrderState::getId).collect(Collectors.toList());
                IPage<InsOrderUserDto> insOrderUserDtoIPage = insOrderUserMapper.selectInsOrderUserDto2(ids, new Page(1,9));
                map.put(entry.getKey(), insOrderUserDtoIPage);
            }
        }
        return map;
    }
}