zss
2025-03-11 eeb8d7faa8d25b3ca9fe75ef28f035c49af5b06d
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
package com.ruoyi.requier.service.impl;
 
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.vo.StandardProductVO;
import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.exception.ErrorException;
import com.ruoyi.inspect.mapper.*;
import com.ruoyi.inspect.pojo.*;
import com.ruoyi.inspect.vo.ProductVo;
import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper;
import com.ruoyi.performance.mapper.PerformanceShiftMapper;
import com.ruoyi.performance.mapper.ShiftTimeMapper;
import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours;
import com.ruoyi.performance.pojo.PerformanceShift;
import com.ruoyi.performance.pojo.ShiftTime;
import com.ruoyi.requier.mapper.PkMasterMapper;
import com.ruoyi.requier.mapper.PkSlaveMapper;
import com.ruoyi.requier.pojo.PkMaster;
import com.ruoyi.requier.pojo.PkSlave;
import com.ruoyi.requier.service.InsOrderPlanService;
import com.ruoyi.requier.service.PkMasterService;
import com.ruoyi.system.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 江苏鵷雏网络科技有限公司
 * @since 2024-07-29 01:16:26
 */
@Service
@Slf4j
public class PkMasterServiceImpl extends ServiceImpl<PkMasterMapper, PkMaster> implements PkMasterService {
 
    @Resource
    private PkMasterMapper pkMasterMapper;
 
    @Resource
    private PkSlaveMapper pkSlaveMapper;
 
    @Resource
    private InsOrderMapper insOrderMapper;
 
    @Resource
    private InsSampleMapper insSampleMapper;
 
    @Resource
    private InsProductMapper insProductMapper;
 
    @Resource
    private InsProductResultMapper insProductResultMapper;
 
    @Resource
    private InsProductUserMapper insProductUserMapper;
 
    @Resource
    private UserMapper userMapper;
 
    @Resource
    private InsOrderPlanService insOrderPlanService;
 
    @Resource
    private InsOrderPlanServiceImpl insOrderPlanServiceImpl;
 
    @Resource
    private ShiftTimeMapper shiftTimeMapper;
    @Resource
    private PerformanceShiftMapper performanceShiftMapper;
 
    @Resource
    private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper;
 
    //温度循环数采
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int temDataAcquisition(PkMaster pkMaster) {
        Integer userId = SecurityUtils.getUserId().intValue();
        //查询数采关联的子表信息
        PkMaster master = new PkMaster();
        List<PkMaster> pkMasters = pkMasterMapper.selectList(Wrappers.<PkMaster>lambdaQuery()
                .eq(PkMaster::getEntrustCode, pkMaster.getEntrustCode())
                .eq(PkMaster::getSampleCode, pkMaster.getSampleCode())
                .eq(PkMaster::getModel, pkMaster.getModel())
                .eq(PkMaster::getCycles, pkMaster.getCycles())
                .eq(PkMaster::getTemperature, pkMaster.getTemperature()).orderByDesc(PkMaster::getId));
        if(!pkMasters.isEmpty()){
            master = pkMasters.get(0);
        }
        //查询对应的检验单表
        InsOrder insOrder = insOrderMapper.selectOne(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).eq(InsOrder::getEntrustCode, pkMaster.getEntrustCode()));
        if (ObjectUtils.isEmpty(insOrder)) {
            throw new ErrorException("没有找到对应委托单" + pkMaster.getEntrustCode());
        }
        //查询对应检验样品id
        InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery()
                .eq(InsSample::getInsOrderId, insOrder.getId())
                .eq(InsSample::getSampleCode, pkMaster.getSampleCode())
                .eq(InsSample::getModel, pkMaster.getModel()));
        if (ObjectUtils.isEmpty(insSample)) {
            throw new ErrorException("没有找到对应委托单下的该样品" + pkMaster.getSampleCode());
        }        if (ObjectUtils.isNotEmpty(master)) {
            //throw new ErrorException("没有找到对应委托单" + pkMaster.getEntrustCode() + "的数采数据");
            List<PkSlave> pkSlaves = pkSlaveMapper.selectList1(master.getIsid());
            if (CollectionUtils.isEmpty(pkSlaves)) {
                throw new ErrorException("没有找到对应委托单" + pkMaster.getEntrustCode() + "的数采子数据");
            }
 
            //查询对应检验项目
            Map<String, Object> map = insOrderPlanService.temCycle(insSample.getId(), pkMaster.getCycles(), pkMaster.getTemperature());
            List<ProductVo> productVos = (List<ProductVo>) map.get("productVos");
            if (CollectionUtils.isNotEmpty(productVos)) {
                //todo 如果温度循环的项目nm有改动这里需要改动 @zss
                for (PkSlave pkSlave : pkSlaves) {
                    for (ProductVo productVo : productVos) {
                        if (pkSlave.getInsBushingId().equals(productVo.getBushColor()) &&
                                pkSlave.getInsFibersId().equals(productVo.getCode()) &&
                                pkSlave.getInsFiberId().equals(productVo.getColor())) {
                            //找到对应的数据(对应套管光纤的数据)
                            List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, productVo.getInsProduct().getId()));
                            InsProductResult result;
                            if (CollectionUtils.isEmpty(results)) {
                                result = new InsProductResult();
                            } else {
                                result = results.get(0);
                            }
                            result.setInsProductId(productVo.getInsProduct().getId());//检验项目id
                            List<Map<String, Object>> iv = new ArrayList<>();
                            List<Map<String, Object>> cv = new ArrayList<>();
                            if (productVo.getInsProduct().getInspectionItemClass().equals("1310nm")) {
                                //1310nm外端
                                Map<String, Object> map1 = new HashMap<>();
                                map1.put("u", userId + "");
                                map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1310A()) ? pkSlave.getWeaken1310A().toString() : null);
                                iv.add(map1);
                                //1310nm内端
                                Map<String, Object> map2 = new HashMap<>();
                                map2.put("u", userId + "");
                                map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1310B()) ? pkSlave.getWeaken1310B().toString() : null);
                                iv.add(map2);
                                //1310nm衰减系数
                                Map<String, Object> map3 = new HashMap<>();
                                double v = 0.0;
                                if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1310A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1310B())) {
                                    v = (pkSlave.getWeaken1310A() + pkSlave.getWeaken1310B()) / 2;
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1310A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1310B())) {
                                    v = pkSlave.getWeaken1310A();
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1310B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1310A())) {
                                    v = pkSlave.getWeaken1310B();
                                } else {
                                    log.info("数采id:{}", pkSlave.getId());
                                    throw new ErrorException("1310的两端都没有数据!!!");
                                }
                                BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP);
                                map3.put("v", String.valueOf(decimal));
                                cv.add(map3);
                            } else if (productVo.getInsProduct().getInspectionItemClass().equals("1550nm")) {
                                //1550nm外端
                                Map<String, Object> map1 = new HashMap<>();
                                map1.put("u", userId + "");
                                map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1550A()) ? pkSlave.getWeaken1550A().toString() : null);
                                iv.add(map1);
                                //1550nm内端
                                Map<String, Object> map2 = new HashMap<>();
                                map2.put("u", userId + "");
                                map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1550B()) ? pkSlave.getWeaken1550B().toString() : null);
                                iv.add(map2);
                                //1550nm衰减系数
                                Map<String, Object> map3 = new HashMap<>();
                                double v = 0.0;
                                if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1550A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1550B())) {
                                    v = (pkSlave.getWeaken1550A() + pkSlave.getWeaken1550B()) / 2;
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1550A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1550B())) {
                                    v = pkSlave.getWeaken1550A();
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1550B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1550A())) {
                                    v = pkSlave.getWeaken1550B();
                                } else {
                                    throw new ErrorException("1550的两端都没有数据!!!");
                                }
                                BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP);
                                map3.put("v", String.valueOf(decimal));
                                cv.add(map3);
                            } else if (productVo.getInsProduct().getInspectionItemClass().equals("1625nm")) {
                                //1625nm外端
                                Map<String, Object> map1 = new HashMap<>();
                                map1.put("u", userId + "");
                                map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1625A()) ? pkSlave.getWeaken1625A().toString() : null);
                                iv.add(map1);
                                //1625nm内端
                                Map<String, Object> map2 = new HashMap<>();
                                map2.put("u", userId + "");
                                map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1625B()) ? pkSlave.getWeaken1625B().toString() : null);
                                iv.add(map2);
                                //1625nm衰减系数
                                Map<String, Object> map3 = new HashMap<>();
                                double v = 0.0;
                                if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1625A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1625B())) {
                                    v = (pkSlave.getWeaken1625A() + pkSlave.getWeaken1625B()) / 2;
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1625A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1625B())) {
                                    v = pkSlave.getWeaken1625A();
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1625B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1625A())) {
                                    v = pkSlave.getWeaken1625B();
                                } else {
                                    throw new ErrorException("1625的两端都没有数据!!!");
                                }
                                BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP);
                                map3.put("v", String.valueOf(decimal));
                                cv.add(map3);
                            } else if (productVo.getInsProduct().getInspectionItemClass().equals("1383nm")) {
                                //1383nm外端
                                Map<String, Object> map1 = new HashMap<>();
                                map1.put("u", userId + "");
                                map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1383A()) ? pkSlave.getWeaken1383A().toString() : null);
                                iv.add(map1);
                                //1383nm内端
                                Map<String, Object> map2 = new HashMap<>();
                                map2.put("u", userId + "");
                                map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1383B()) ? pkSlave.getWeaken1383B().toString() : null);
                                iv.add(map2);
                                //1383nm衰减系数
                                Map<String, Object> map3 = new HashMap<>();
                                double v = 0.0;
                                if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1383A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1383B())) {
                                    v = (pkSlave.getWeaken1383A() + pkSlave.getWeaken1310B()) / 2;
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1383A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1383B())) {
                                    v = pkSlave.getWeaken1383A();
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1383B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1383A())) {
                                    v = pkSlave.getWeaken1383B();
                                } else {
                                    throw new ErrorException("1383的两端都没有数据!!!");
                                }
                                BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP);
                                map3.put("v", String.valueOf(decimal));
                                cv.add(map3);
                            } else if (productVo.getInsProduct().getInspectionItemClass().equals("1490nm")) {
                                //1490nm外端
                                Map<String, Object> map1 = new HashMap<>();
                                map1.put("u", userId + "");
                                map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1490A()) ? pkSlave.getWeaken1490A().toString() : null);
                                iv.add(map1);
                                //1490nm内端
                                Map<String, Object> map2 = new HashMap<>();
                                map2.put("u", userId + "");
                                map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1490B()) ? pkSlave.getWeaken1490B().toString() : null);
                                iv.add(map2);
                                //1490nm衰减系数
                                Map<String, Object> map3 = new HashMap<>();
                                double v = 0.0;
                                if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1490A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1490B())) {
                                    v = (pkSlave.getWeaken1490A() + pkSlave.getWeaken1310B()) / 2;
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1490A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1490B())) {
                                    v = pkSlave.getWeaken1490A();
                                } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1490B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1490A())) {
                                    v = pkSlave.getWeaken1490B();
                                } else {
                                    throw new ErrorException("1490的两端都没有数据!!!");
                                }
                                BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP);
                                map3.put("v", String.valueOf(decimal));
                                cv.add(map3);
                            } else {
                                throw new ErrorException("没有找到该温度的检验项目" + productVo.getInsProduct().getInspectionItemClass());
                            }
                            result.setInsValue(JSON.toJSONString(iv));//检验值
                            result.setComValue(JSON.toJSONString(cv));//计算值
                            if (BeanUtil.isEmpty(result.getId())) {
                                result.setCreateUser(userId);
                                result.setUpdateUser(userId);
                                insProductResultMapper.insert(result);
                            } else {
                                result.setUpdateUser(userId);
                                result.setUpdateTime(LocalDateTime.now());
                                insProductResultMapper.updateById(result);
                            }
 
                            InsProduct insProduct = productVo.getInsProduct();
                            InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId()));
                            String[] comValue = insProductResult.getComValue().split(":");
                            String comple = comValue[comValue.length-1].split("\"")[1];
                            //首先查看温度是否是20度常温
                            if (!pkMaster.getTemperature().equals("20℃(常温)")) {
                                //如果不是先查询是否有值
                                int a = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                                        .eq(InsProduct::getInsSampleId, insSample.getId())
                                        .eq(InsProduct::getInspectionItem, "1")
                                        .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")).stream().map(InsProduct::getInsResult).anyMatch(ObjectUtils::isEmpty) ? 1 : 0;
                                if (a == 1) {
                                    throw new ErrorException("先获取20℃(常温)的检验值,再获取其他温度" + pkMaster.getSampleCode());
                                } else {
                                    //计算衰减差
                                    InsProduct insPro = null;
                                    switch (insProduct.getInspectionItemClass()) {
                                        case "1310nm":
                                            //查询20℃(常温)1310nm的衰减系数
                                            try {
                                                insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                                                        .eq(InsProduct::getInsSampleId, insSample.getId())
                                                        .eq(InsProduct::getInspectionItem, "1")
                                                        .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")
                                                        .eq(InsProduct::getInspectionItemClass, "1310nm")
                                                        .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId()));
                                            } catch (Exception e) {
                                                throw new ErrorException("没有查到20℃(常温),1310nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目");
                                            }
                                            break;
                                        case "1550nm":
                                            //查询20℃(常温)1550nm的衰减系数
                                            try {
                                                insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                                                        .eq(InsProduct::getInsSampleId, insSample.getId())
                                                        .eq(InsProduct::getInspectionItem, "1")
                                                        .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")
                                                        .eq(InsProduct::getInspectionItemClass, "1550nm")
                                                        .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId()));
                                            } catch (Exception e) {
                                                throw new ErrorException("没有查到20℃(常温),1625nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目");
                                            }
                                            break;
                                        case "1625nm":
                                            //查询20℃(常温)1625nm的衰减系数
                                            try {
                                                insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                                                        .eq(InsProduct::getInsSampleId, insSample.getId())
                                                        .eq(InsProduct::getInspectionItem, "1")
                                                        .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")
                                                        .eq(InsProduct::getInspectionItemClass, "1625nm")
                                                        .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId()));
                                            } catch (Exception e) {
                                                throw new ErrorException("没有查到20℃(常温),1625nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目");
                                            }
                                            break;
                                        case "1383nm":
                                            //查询20℃(常温)1383nm的衰减系数
                                            try {
                                                insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                                                        .eq(InsProduct::getInsSampleId, insSample.getId())
                                                        .eq(InsProduct::getInspectionItem, "1")
                                                        .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")
                                                        .eq(InsProduct::getInspectionItemClass, "1383nm")
                                                        .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId()));
                                            } catch (Exception e) {
                                                throw new ErrorException("没有查到20℃(常温),1383nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目");
                                            }
                                            break;
                                        case "1490nm":
                                            //查询20℃(常温)1490nm的衰减系数
                                            try {
                                                insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                                                        .eq(InsProduct::getInsSampleId, insSample.getId())
                                                        .eq(InsProduct::getInspectionItem, "1")
                                                        .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")
                                                        .eq(InsProduct::getInspectionItemClass, "1490nm")
                                                        .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId()));
                                            } catch (Exception e) {
                                                throw new ErrorException("没有查到20℃(常温),1490nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目");
                                            }
                                            break;
                                    }
                                    InsProductResult insProductRes = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insPro.getId()));
                                    String[] split = insProductRes.getComValue().split(":");
                                    double abs = Math.abs(Double.parseDouble(split[split.length-1].split("\"")[1]) - Double.parseDouble(comple));
                                    BigDecimal scale = BigDecimal.valueOf(abs).setScale(3, RoundingMode.HALF_UP);
                                    insProduct.setLastValue(String.valueOf(scale));
                                    String ask = insProduct.getAsk();
                                    int insResult = 1;
                                    switch (ask.charAt(0)) {
                                        case '<':
                                            insResult = Double.parseDouble(insProduct.getLastValue()) < Double.parseDouble(ask.substring(1)) ? 1 : 0;
                                            break;
                                        case '>':
                                            insResult = Double.parseDouble(insProduct.getLastValue()) > Double.parseDouble(ask.substring(1)) ? 1 : 0;
                                            break;
                                        case '=':
                                            insResult = Double.parseDouble(insProduct.getLastValue()) == Double.parseDouble(ask.substring(1)) ? 1 : 0;
                                            break;
                                        case '≤':
                                            insResult = Double.parseDouble(insProduct.getLastValue()) <= Double.parseDouble(ask.substring(1)) ? 1 : 0;
                                            break;
                                        case '≥':
                                            insResult = Double.parseDouble(insProduct.getLastValue()) >= Double.parseDouble(ask.substring(1)) ? 1 : 0;
                                            break;
                                    }
                                    insProduct.setInsResult(insResult);
                                }
                            } else {
                                //如果是20度常温,需要给出合格的结论
                                insProduct.setInsResult(1);//20度常温的检验项默认为合格
                            }
                            insProduct.setUpdateUser(userId);
                            insProductMapper.updateById(insProduct);
                            User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getAccount, master.getDetectionPeople()));
                            if (ObjectUtils.isEmpty(user)) {
                                throw new ErrorException("lims系统没有找到该用户" + master.getDetectionPeople());
                            }
                            insProductUserMapper.insert(new InsProductUser(null, user.getId(), master.getDetectionDate(), insProduct.getId()));
                        }
                    }
                }
            }
            //给温度循环的检验项目绑定设备
            InsProduct product = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                    .eq(InsProduct::getState, 1)
                    .eq(InsProduct::getInsSampleId, insSample.getId())
                    .eq(InsProduct::getInspectionItem, "温度循环"));
            if (ObjectUtils.isEmpty(product)) {
                throw new ErrorException("没有找到对应委托单下该样品的相关温度循环检验项目");
            }
            InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, product.getId()));
            if (ObjectUtils.isEmpty(insProductResult)) {
                insProductResult = new InsProductResult();
                insProductResult.setInsProductId(product.getId());
            }
            if (ObjectUtils.isEmpty(insProductResult.getEquipValue())) {
                List<Map<String, Object>> dv = new ArrayList<>();
                Map<String, Object> map4 = new HashMap<>();
                map4.put("v", "JCZX-TX-TT02006");
                dv.add(map4);
                Map<String, Object> map5 = new HashMap<>();
                map5.put("v", "JCZX-TX-TT02001");
                dv.add(map5);
                insProductResult.setEquipValue(JSON.toJSONString(dv));
                List<Map<String, Object>> dn = new ArrayList<>();
                Map<String, Object> map6 = new HashMap<>();
                map6.put("v", "步入式高低温湿热试验箱");
                dn.add(map6);
                Map<String, Object> map7 = new HashMap<>();
                map7.put("v", "步入式高低温试验箱");
                dn.add(map7);
                insProductResult.setEquipName(JSON.toJSONString(dn));
                if (BeanUtil.isEmpty(insProductResult.getId())) {
                    insProductResult.setCreateUser(userId);
                    insProductResult.setUpdateUser(userId);
                    insProductResultMapper.insert(insProductResult);
                } else {
                    insProductResult.setUpdateUser(userId);
                    insProductResult.setUpdateTime(LocalDateTime.now());
                    insProductResultMapper.updateById(insProductResult);
                }
            }
        }
        //查找样品下该次数的温度的项目
        List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getInsSampleId, insSample.getId())
                .eq(InsProduct::getState, 1)
                .isNotNull(InsProduct::getSpecialItemParentId)
                .isNotNull(InsProduct::getInspectionItemClass));
        // 过滤出当前循环次数 和 温度的检验项目
        List<InsProduct> productList = insProducts.stream()
                .filter(item -> item.getInspectionItem().equals(pkMaster.getCycles()) &&
                        item.getInspectionItemSubclass().equals(pkMaster.getTemperature()))
                .collect(Collectors.toList());
        // 工时添加
        int count = 0;
        for(InsProduct insProduct1 : productList) {
            // 查询insProductResult拿到insValue的有值的个数
            InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>()
                    .eq(InsProductResult::getInsProductId, insProduct1.getId()));
            if(!Objects.isNull(insProductResult)) {
                // insProductResult不为空,获取有值的个数
                insProductResult.getInsValue();
                List<Map> maps = JSONArray.parseArray(insProductResult.getInsValue(), Map.class);
                for (Map map : maps) {
                    if (Strings.isNotEmpty(map.get("v").toString())) {
                        count++;
                        break;
                    }
                }
            }
        }
        // 该单子下除了当前次数以及温度有值的记录
        List<InsProduct> productList1 = insProducts.stream()
                .filter(item -> !(item.getInspectionItem().equals(pkMaster.getCycles()) && item.getInspectionItemSubclass().equals(pkMaster.getTemperature())))
                .collect(Collectors.toList());
        int allValue = 0;
        for(InsProduct insProduct1 : productList1) {
            // 查询insProductResult拿到insValue的有值的个数
            InsProductResult insProductResult = insProductResultMapper.selectOne(new LambdaQueryWrapper<InsProductResult>()
                    .eq(InsProductResult::getInsProductId, insProduct1.getId()));
            if(!Objects.isNull(insProductResult)) {
                // insProductResult不为空,获取有值的个数
                insProductResult.getInsValue();
                List<Map> maps = JSONArray.parseArray(insProductResult.getInsValue(), Map.class);
                for (Map map : maps) {
                    if (Strings.isNotEmpty(map.get("v").toString())) {
                        allValue++;
                        break;
                    }
                }
            }
        }
        Map<String, Boolean> map = isOvertimeAndCrossDay(userId);
        Boolean isWithinRange = map.get("isWithinRange"); // 是否正常上班
        Boolean isCross = map.get("isCross"); // 是否跨天
        BigDecimal manHour = BigDecimal.ZERO; // 工时
        InsProduct insProduct = insProductMapper.selectOne(new LambdaQueryWrapper<InsProduct>().eq(InsProduct::getInsSampleId, insSample.getId())
                .eq(InsProduct::getInspectionItem, "温度循环"));
        StandardProductVO workHourMap = insOrderPlanServiceImpl.getInspectWorkHourAndGroup(insProduct);
        if(ObjectUtil.isNotNull(workHourMap)){
            manHour = new BigDecimal(workHourMap.getManHour());
        }
        DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        DateTime parse = DateUtil.parse(LocalDateTime.now().format(formatter));
        AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
        auxiliaryOutputWorkingHours.setInspectionItem("温度循环"); // 检验项目
        auxiliaryOutputWorkingHours.setInspectionItemSubclass(""); // 检验项目子类
        if(isWithinRange) {
            // 正常上班
            auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode()); // 非加班委托单号
            auxiliaryOutputWorkingHours.setWorkTime(new BigDecimal(accuracy(manHour,count))); // 工时
            auxiliaryOutputWorkingHours.setAmount(count); // 非加班数量
        }else{
            // 加班
            auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode()); // 非加班委托单号
            auxiliaryOutputWorkingHours.setOvertimeWorkTime(new BigDecimal(accuracy(manHour,count))); // 工时
            auxiliaryOutputWorkingHours.setOvertimeAmount(count); // 非加班数量
        }
        if(isCross) {
            String date = LocalDateTime.now().minusDays(1).toLocalDate().atStartOfDay().format(formatters);// 前一天
            auxiliaryOutputWorkingHours.setDateTime(date); // 日期
        }else {
            String date = LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters);// 当天
            auxiliaryOutputWorkingHours.setDateTime(date); // 日期
        }
        auxiliaryOutputWorkingHours.setOutputWorkTime(new BigDecimal(accuracy(manHour,count))); // 产出工时
        auxiliaryOutputWorkingHours.setWeekDay(insOrderPlanServiceImpl.getWeek(LocalDateTime.now().format(formatters)));//星期
        auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//周次
        auxiliaryOutputWorkingHours.setCheck(userId);//检测人
        auxiliaryOutputWorkingHours.setSample(insSample.getSampleCode());//样品编号
        auxiliaryOutputWorkingHours.setManHourGroup(workHourMap.getManHourGroup());//工时分组
        // 查询需要操作的日期是否有记录
        List<AuxiliaryOutputWorkingHours> oldRecords = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                .eq(AuxiliaryOutputWorkingHours::getCheck,userId)
                .eq(AuxiliaryOutputWorkingHours::getInspectionItem, "温度循环")
                .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, "")
                .eq(AuxiliaryOutputWorkingHours::getSample, insSample.getSampleCode())
                .and(i->i.eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode())
                        .or()
                        .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode()))
                .eq(AuxiliaryOutputWorkingHours::getDateTime, auxiliaryOutputWorkingHours.getDateTime())
        );
        // 所有的记录(其他天 + 当前天)
        List<AuxiliaryOutputWorkingHours> addOldRecords = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                .eq(AuxiliaryOutputWorkingHours::getCheck,userId)
                .eq(AuxiliaryOutputWorkingHours::getInspectionItem, "温度循环")
                .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, "")
                .eq(AuxiliaryOutputWorkingHours::getSample, insSample.getSampleCode())
                .and(i->i.eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode())
                        .or()
                        .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode()))
        );
        if(CollectionUtils.isEmpty(oldRecords)){
            // 新增也要查看是否有所有的记录
            if(Objects.isNull(addOldRecords)) {
                // 其他天也没有记录
                auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
            }else{
                // 所有的记录
                int otherDayAmount = 0; // 所有的数量
                for(AuxiliaryOutputWorkingHours a : addOldRecords) {
                    otherDayAmount += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount());
                }
                if(isWithinRange) {
                    // 正常上班
 
                    auxiliaryOutputWorkingHours.setWorkTime(new BigDecimal(accuracy(manHour,(count - otherDayAmount + allValue)))); // 工时
                    auxiliaryOutputWorkingHours.setAmount((count - otherDayAmount + allValue)); // 非加班数量
                }else {
                    // 加班
                    auxiliaryOutputWorkingHours.setOvertimeWorkTime(new BigDecimal(accuracy(manHour,(count - otherDayAmount + allValue)))); // 工时
                    auxiliaryOutputWorkingHours.setOvertimeAmount((count - otherDayAmount + allValue)); // 非加班数量
                }
                auxiliaryOutputWorkingHours.setOutputWorkTime(new BigDecimal(accuracy(manHour,(count - otherDayAmount + allValue)))); // 产出工时
                auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
            }
        }else {
            // 不为空
            Integer oldAmount = 0; // 工时添加的个数
            for(AuxiliaryOutputWorkingHours a : addOldRecords) {
                oldAmount += (Objects.isNull(a.getAmount()) ? 0 : a.getAmount()) + (Objects.isNull(a.getOvertimeAmount()) ? 0 : a.getOvertimeAmount());
            }
            if(count > (oldAmount - allValue)){
                // 查找出日期为得到日期的记录
                List<AuxiliaryOutputWorkingHours> collect = oldRecords.stream().filter(item -> item.getDateTime().equals(auxiliaryOutputWorkingHours.getDateTime())).collect(Collectors.toList());
                if(CollectionUtils.isNotEmpty(collect)){
                    // 有的话就是更新操作
                    AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours1 = collect.get(0);
                    if(isWithinRange) {
                        // 正常上班
                        // 拿到原本的数量 与 新的数量相加
                        int num =  Objects.isNull(auxiliaryOutputWorkingHours1.getAmount()) ? 0 :auxiliaryOutputWorkingHours1.getAmount(); // 原本的数量
                        auxiliaryOutputWorkingHours1.setAmount(count - oldAmount + num + allValue); // 非加班数量
                        auxiliaryOutputWorkingHours1.setOrderNo(insOrder.getEntrustCode()); // 非加班委托单号
                        auxiliaryOutputWorkingHours1.setWorkTime(new BigDecimal(accuracy(manHour,(count - oldAmount + num + allValue)))); // 工时
                        BigDecimal outputWorkTime = new BigDecimal(accuracy(manHour, auxiliaryOutputWorkingHours1.getAmount())).add((Objects.isNull(auxiliaryOutputWorkingHours1.getOvertimeWorkTime()) ? new BigDecimal(0) : auxiliaryOutputWorkingHours1.getOvertimeWorkTime()));
                        auxiliaryOutputWorkingHours1.setOutputWorkTime(outputWorkTime);// 产出工时 采集肯定是会采集完
                    }else{
                        // 加班
                        // 拿到原本的数量 与 新的数量相加
                        int num =  Objects.isNull(auxiliaryOutputWorkingHours1.getOvertimeAmount()) ? 0 :auxiliaryOutputWorkingHours1.getOvertimeAmount(); // 原本的数量
                        auxiliaryOutputWorkingHours1.setOvertimeAmount(count - oldAmount + num + allValue);// 加班数量
                        auxiliaryOutputWorkingHours1.setOvertimeOrderNo(insOrder.getEntrustCode()); // 加班委托单号
                        auxiliaryOutputWorkingHours1.setOvertimeWorkTime(new BigDecimal(accuracy(manHour,(count - oldAmount + num + allValue)))); // 工时
                        BigDecimal outputWorkTime = new BigDecimal(accuracy(manHour, auxiliaryOutputWorkingHours1.getOvertimeAmount())).add(
                                (Objects.isNull(auxiliaryOutputWorkingHours1.getWorkTime()) ? new BigDecimal(0) : auxiliaryOutputWorkingHours1.getWorkTime()));
                        auxiliaryOutputWorkingHours1.setOutputWorkTime(outputWorkTime); // 产出工时 采集肯定是会采集完
                    }
                    auxiliaryOutputWorkingHoursMapper.updateById(auxiliaryOutputWorkingHours1);
                }
            }
        }
 
 
 
        return 0;
    }
 
    //温度循环数采总体
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int temDataAcquisition2(PkMaster pkMaster) {
        //查询出所有循环次数和温度,然后循环调用temDataAcquisition接口
        //查询对应的检验单表
        InsOrder insOrder = insOrderMapper.selectOne(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).eq(InsOrder::getEntrustCode, pkMaster.getEntrustCode()));
        if (ObjectUtils.isEmpty(insOrder)) {
            throw new ErrorException("没有找到对应委托单" + pkMaster.getEntrustCode());
        }
        //查询对应检验样品id
        InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery()
                .eq(InsSample::getInsOrderId, insOrder.getId())
                .eq(InsSample::getSampleCode, pkMaster.getSampleCode())
                .eq(InsSample::getModel, pkMaster.getModel()));
        if (ObjectUtils.isEmpty(insSample)) {
            throw new ErrorException("没有找到对应委托单下的该样品" + pkMaster.getSampleCode());
        }
        //查找样品下所有温度循环的项目
        List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getInsSampleId, insSample.getId())
                .eq(InsProduct::getState, 1)
                .isNotNull(InsProduct::getSpecialItemParentId)
                .isNotNull(InsProduct::getInspectionItemClass));
        //过滤出所有循环次数和温度
        List<String> collect1 = insProducts.stream().map(InsProduct::getInspectionItem).distinct().collect(Collectors.toList());
        List<String> collect2 = insProducts.stream().map(InsProduct::getInspectionItemSubclass).distinct().collect(Collectors.toList());
        for (String s : collect1) {
            for (String s1 : collect2) {
                PkMaster master = new PkMaster();
                master.setEntrustCode(pkMaster.getEntrustCode());
                master.setSampleCode(pkMaster.getSampleCode());
                master.setModel(pkMaster.getModel());
                master.setCycles(s);
                master.setTemperature(s1);
                temDataAcquisition(master);
            }
        }
        return 0;
    }
 
    /**
     * 是否加班、跨天
     */
    public Map<String,Boolean> isOvertimeAndCrossDay(Integer userId){
        Map<String, Boolean> map = new HashMap<>();
        Boolean isWithinRange = true;
        Boolean isCross = false; // 是否将当前检验单子的工时计算到班次开始天
        LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT);
        PerformanceShift performanceShift = performanceShiftMapper.selectOne(Wrappers.<PerformanceShift>lambdaQuery()
                .eq(PerformanceShift::getUserId, userId)
                .eq(PerformanceShift::getWorkTime, today));
        if (ObjectUtils.isNotEmpty(performanceShift)) {
            ShiftTime shiftTime = shiftTimeMapper.selectOne(Wrappers.<ShiftTime>lambdaQuery().eq(ShiftTime::getShift, performanceShift.getShift()));
            if (ObjectUtils.isNotEmpty(shiftTime)) {
                DateTimeFormatter forma = DateTimeFormatter.ofPattern("HH:mm");
                LocalTime now = LocalTime.now();
                LocalTime startTime = LocalTime.parse(shiftTime.getStartTime(), forma);
                LocalTime endTime = LocalTime.parse(shiftTime.getEndTime(), forma);
                // 检查当前时间是否在范围内(包括边界)
 
                // 如果当前时间不在今天的班次内  17:00~5.00  15.00 首先判断是否跨天了
                // 跨天的情况
                if (startTime.isAfter(endTime)) {
                    // 查看当前时间是否在班次时间内
                    if (now.isAfter(startTime)) {
                        // 如果是在结束时间之后那么就是正常上班
                        isWithinRange = true;
                        isCross = false;
                    } else {
                        // 当前时间不在班次内,查看昨天的班次
                        LocalDateTime yesterday = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MIDNIGHT);
                        PerformanceShift yesterdayShift = performanceShiftMapper.selectOne(Wrappers.<PerformanceShift>lambdaQuery()
                                .eq(PerformanceShift::getUserId, userId)
                                .eq(PerformanceShift::getWorkTime, yesterday));
                        ShiftTime yesterdayShiftTime = shiftTimeMapper.selectOne(Wrappers.<ShiftTime>lambdaQuery().eq(ShiftTime::getShift, yesterdayShift.getShift()));
                        // 如果昨天的班次不为空,那么就要看昨天的班次时间
                        if (!Objects.isNull(yesterdayShiftTime)) {
                            LocalTime yesterdayStartTime = LocalTime.parse(yesterdayShiftTime.getStartTime(), forma);
                            LocalTime yesterdayEndTime = LocalTime.parse(yesterdayShiftTime.getEndTime(), forma);
                            // 昨天的班次是否跨天
                            if (yesterdayStartTime.isAfter(yesterdayEndTime)) {
                                // 如果昨天的班次跨天了,那么就要看今天是否在昨天的班次内,并且只能是在结束时间之前,已经实现了跨天
                                if (now.isBefore(yesterdayEndTime)) {
                                    // 在昨天班次时间内正常上班,工时计算到昨天
                                    isWithinRange = true;
                                    isCross = true;
                                } else {
                                    // 不在昨天班次时间内就是加班,工时计算到昨天
                                    isWithinRange = false;
                                    isCross = true;
                                }
                            } else {
                                // 昨天的班次没有跨天 如果当前时间在今天班次开始时间之前就是昨天的加班,否则就是今天的加班
                                if (now.isBefore(startTime)) {
                                    isWithinRange = false;
                                    isCross = true;
                                } else {
                                    isWithinRange = false;
                                    isCross = false;
                                }
                            }
                        } else {
                            isWithinRange = false;
                            // 如果是在开始时间之前那么就要算到昨天
                            if (now.isBefore(startTime)) {
                                isCross = true;
                            } else {
                                isCross = false;
                            }
                        }
                    }
                } else {
                    // 当前班次不跨天的情况下
                    // 如果当前时间在开始时间之前,查昨天的班次看当前时间是否在昨天的班次内
                    if (now.isBefore(startTime)) {
                        // 查看昨天是否跨天
                        LocalDateTime yesterday = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MIDNIGHT);
                        PerformanceShift yesterdayShift = performanceShiftMapper.selectOne(Wrappers.<PerformanceShift>lambdaQuery()
                                .eq(PerformanceShift::getUserId, userId)
                                .eq(PerformanceShift::getWorkTime, yesterday));
                        ShiftTime yesterdayShiftTime = shiftTimeMapper.selectOne(Wrappers.<ShiftTime>lambdaQuery().eq(ShiftTime::getShift, yesterdayShift.getShift()));
                        LocalTime yesterdayStartTime = LocalTime.parse(yesterdayShiftTime.getStartTime(), forma);
                        LocalTime yesterdayEndTime = LocalTime.parse(yesterdayShiftTime.getEndTime(), forma);
                        if (yesterdayStartTime.isAfter(yesterdayEndTime)) {
                            // 如果昨天跨天
                            if (now.isBefore(yesterdayEndTime)) {
                                // 在昨天的班次时间内正常上班,工时计算到昨天
                                isWithinRange = true;
                                isCross = true;
                            } else {
                                // 不在昨天班次时间内就是加班,工时计算到昨天
                                isWithinRange = false;
                                isCross = true;
                            }
                        } else {
                            // 昨天不跨天
                            isWithinRange = false;
                            isCross = true;
                        }
                    } else if (now.isAfter(endTime)) {
                        // 如果当前时间在结束时间之后,那么就是今天的加班
                        isWithinRange = false;
                        isCross = false;
                    } else {
                        // 正常上班
                        isWithinRange = true;
                        isCross = false;
                    }
                }
            }
        }
        map.put("isWithinRange",isWithinRange);
        map.put("isCross",isCross);
        return map;
    }
 
    /**
     * 精度问题
     */
    public double accuracy(BigDecimal manHour, int count){
        return  manHour.multiply(BigDecimal.valueOf(count)).setScale(4, RoundingMode.HALF_UP).doubleValue();
    }
 
}