heheng
2024-11-07 3ca43826a747fda1447b2501901f84fc1a9019dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
package com.gkhy.labRiskManage.application.riskReport.service.impl;
 
import com.gkhy.labRiskManage.api.controller.riskReport.dto.repDto.*;
import com.gkhy.labRiskManage.api.controller.riskReport.dto.respDto.RiskAssessPlanListRespDTO;
import com.gkhy.labRiskManage.api.controller.riskReport.dto.respDto.RiskUnitListQueryRespDTO;
import com.gkhy.labRiskManage.application.riskReport.dto.bo.*;
import com.gkhy.labRiskManage.application.riskReport.dto.dto.*;
import com.gkhy.labRiskManage.application.riskReport.service.RiskAccessAppService;
import com.gkhy.labRiskManage.commons.domain.SearchResult;
import com.gkhy.labRiskManage.commons.enums.ResultCode;
import com.gkhy.labRiskManage.commons.enums.StatusEnum;
import com.gkhy.labRiskManage.commons.enums.UserRoleEnum;
import com.gkhy.labRiskManage.commons.exception.BusinessException;
import com.gkhy.labRiskManage.commons.utils.BeanCopyUtils;
import com.gkhy.labRiskManage.domain.account.model.dto.SysUserRoleBindDomainDTO;
import com.gkhy.labRiskManage.domain.account.model.dto.UserInfoDomainDTO;
import com.gkhy.labRiskManage.domain.account.service.UserDomainService;
import com.gkhy.labRiskManage.domain.basic.model.dto.PersonQueryDTO;
import com.gkhy.labRiskManage.domain.basic.model.dto.RiskUnitBasicQueryDTO;
import com.gkhy.labRiskManage.domain.experiment.model.dto.ExperimentInfoDTO;
import com.gkhy.labRiskManage.domain.riskReport.entity.*;
import com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessLSInsertBO;
import com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessLecInsertBO;
import com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessMesInsertBO;
import com.gkhy.labRiskManage.domain.riskReport.model.bo.AssessRsInsertBO;
import com.gkhy.labRiskManage.domain.riskReport.model.dto.*;
import com.gkhy.labRiskManage.domain.basic.service.BasicExperimentPersonService;
import com.gkhy.labRiskManage.domain.basic.service.BasicRiskUnitService;
import com.gkhy.labRiskManage.domain.experiment.service.ExperimentInfoService;
import com.gkhy.labRiskManage.domain.riskReport.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
 
import java.math.BigDecimal;
import java.util.List;
 
@Service
public class RiskAccessAppServiceImpl implements RiskAccessAppService {
 
    @Autowired
    private RiskAssessPlanService assessPlanService;
    @Autowired
    private RiskUnitService riskUnitService;
    @Autowired
    private ExperimentInfoService experimentInfoService;
    @Autowired
    private BasicRiskUnitService basicRiskUnitService;
    @Autowired
    private BasicExperimentPersonService basicExperimentPersonService;
 
 
    @Autowired
    private RiskAssessPlanIdentificationAnalogyService analogyService;
    @Autowired
    private RiskAssessPlanIdentificationHazopService hazopService;
    @Autowired
    private RiskAssessPlanIdentificationJhaService jhaService;
    @Autowired
    private RiskAssessPlanIdentificationPhaService phaService;
    @Autowired
    private RiskAssessPlanIdentificationSclService sclService;
 
    @Autowired
    private RiskAssessPlanEvaluateLecService lecService;
    @Autowired
    private RiskAssessPlanEvaluateLsService lsService;
    @Autowired
    private RiskAssessPlanEvaluateMesService mesService;
    @Autowired
    private RiskAssessPlanEvaluateRsService rsService;
 
    @Autowired
    private UserDomainService userDomainService;
 
    /**
     * 风险评估计划 - 插入
     */
    @Override
    public int insertAssessPlan(Long currentUserId, RiskAssessPlanInsertReqBO assessPlanInsertReqDTO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
//        RiskUnitQueryDTO riskUnitById = riskUnitService.getRiskUnitById(assessPlanInsertReqDTO.getRiskUnitId());
//        UserInfoDomainDTO userInfoById = userDomainService.getUserInfoById(currentUserId);
//        if (!userInfoById.getId().equals(riskUnitById.getLiabilityUserId())){
//            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "只有实验负责人,才能修改实验风险单元");
//        }
 
        RiskAssessPlanAppInsertBO insertParam = BeanCopyUtils.copyBean(assessPlanInsertReqDTO, RiskAssessPlanAppInsertBO.class);
        PlanInsertDTO planInsertDTO = assessPlanService.insertAssessPlan(currentUserId, insertParam);
 
        if (ObjectUtils.isEmpty(planInsertDTO)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险评估计划 - 查询
     */
    @Override
    public SearchResult<RiskAssessPlanAppQueryDTO> selectAssessPlanPage(Long currentUserId, RiskAssessPlanQueryReqBO queryReqBO) {
 
 
        SearchResult searchResult = new SearchResult<>();
 
        RiskAssessPlanAppQueryBO queryParam = BeanCopyUtils.copyBean(queryReqBO, RiskAssessPlanAppQueryBO.class);
        SearchResult<AssessPlanQueryDTO> queryResult = assessPlanService.selectAssessPlanPage(currentUserId, queryParam);
 
        searchResult.setPageIndex(queryResult.getPageIndex());
        searchResult.setPageSize(queryResult.getPageSize());
        searchResult.setTotal(queryResult.getTotal());
        searchResult.setData(BeanCopyUtils.copyRiskAssessPlanAppQueryList(queryResult.getData(), RiskAssessPlanAppQueryDTO.class));
 
        return searchResult;
    }
 
    /**
     * 风险评估计划 - 修改
     */
    @Override
    public int updateAssessPlan(Long currentUserId, RiskAssessPlanUpdateReqBO updateReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        RiskAssessPlanUpdateReqBO updateParam = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanUpdateReqBO.class);
 
        AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.updateAssessPlan(currentUserId, updateParam);
 
        if (ObjectUtils.isEmpty(assessPlanUpdateDTO)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险评估计划 - 删除
     */
    @Override
    public int deleteAssessPlan(Long currentUserId, Long id) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        AssessPlanDeleteDTO deleteResult = assessPlanService.deleteAssessPlan(currentUserId, id);
 
        if (ObjectUtils.isEmpty(deleteResult)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险评估计划 - 派发任务
     */
    @Override
    public int sellAssessPlan(Long currentUserId, Long id) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        AssessPlanUpdateDTO sellResult = assessPlanService.sellAssessPlan(currentUserId, id);
 
        if (ObjectUtils.isEmpty(sellResult)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险评估计划 - 辨识
     */
    @Override
    @Transactional
    public FactorQueryDTO identification(Long currentUserId, RiskAssessPlanIdentificationInsertReqBO identificationReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        RiskAssessPlanAppIdentificationBO identificationParam = BeanCopyUtils.copyBean(identificationReqBO, RiskAssessPlanAppIdentificationBO.class);
        int tag = 1;
        FactorQueryDTO factorQueryDTO = new FactorQueryDTO();
        PhaInsertDTO phaInsertDTO = new PhaInsertDTO();
        JhaInsertDTO jhaInsertDTO = new JhaInsertDTO();
        SclInsertDTO sclInsertDTO = new SclInsertDTO();
        HazopInsertDTO hazopInsertDTO = new HazopInsertDTO();
        AnalogyInsertDTO analogyInsertDTO = new AnalogyInsertDTO();
        //分发参数到不同的服务进行处理
        //辨识方法 1-PHA;
        if (identificationParam.getIdentificationMethod() == 1){
            RiskAssessPlanIdentificationPha pha = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationPha.class);
            pha.setAssessPlanId(identificationParam.getId());
            phaInsertDTO = phaService.insertPha(currentUserId, pha);
            if (ObjectUtils.isEmpty(phaInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(phaInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setPhaId(phaInsertDTO.getId());
            //辨识方法 2-JHA;
        }else if (identificationParam.getIdentificationMethod() == 2){
            RiskAssessPlanIdentificationJha jha = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationJha.class);
            jha.setAssessPlanId(identificationParam.getId());
            jhaInsertDTO = jhaService.insertJha(currentUserId, jha);
            if (ObjectUtils.isEmpty(jhaInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(jhaInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setJhaId(jhaInsertDTO.getId());
        //辨识方法 3-SCL;
        }else if (identificationParam.getIdentificationMethod() == 3){
            RiskAssessPlanIdentificationScl scl = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationScl.class);
            scl.setAssessPlanId(identificationParam.getId());
            sclInsertDTO = sclService.insertScl(currentUserId, scl);
            if (ObjectUtils.isEmpty(sclInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(sclInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setSclId(sclInsertDTO.getId());
        //辨识方法 4-HAZOP;
        }else if (identificationParam.getIdentificationMethod() == 4){
            RiskAssessPlanIdentificationHazop hazop = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationHazop.class);
            hazop.setAssessPlanId(identificationParam.getId());
            hazopInsertDTO = hazopService.insertHazop(currentUserId, hazop);
            if (ObjectUtils.isEmpty(hazopInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(hazopInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setHazopId(hazopInsertDTO.getId());
        //5-类比法 nalogy;
        }else if (identificationParam.getIdentificationMethod() == 5){
            RiskAssessPlanIdentificationAnalogy analogy = BeanCopyUtils.copyBean(identificationParam, RiskAssessPlanIdentificationAnalogy.class);
            analogy.setAssessPlanId(identificationParam.getId());
            analogyInsertDTO = analogyService.insertAnalogy(currentUserId, analogy);
            if (ObjectUtils.isEmpty(analogyInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(analogyInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setAnalogyId(analogyInsertDTO.getId());
        }else {
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode(), "请选择正确的辨识方法");
        }
 
        //处理评估计划表
        AssessPlanIdentificationDTO identificationResult = assessPlanService.identification(currentUserId, identificationParam);
 
        if (ObjectUtils.isEmpty(identificationResult) && tag == 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "新增辨识失败");
        }
        return factorQueryDTO;
    }
 
    /**
     * 风险评估计划 - 辨识修改
     */
    @Transactional
    @Override
    public FactorQueryDTO updateIdentification(Long currentUserId, RiskAssessPlanIdentificationUpdateReqBO updateReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        RiskAssessPlanIdentificationAppUpdateBO updateParam = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanIdentificationAppUpdateBO.class);
        int tag = 1;
        FactorQueryDTO factorQueryDTO = new FactorQueryDTO();
        //分发参数到不同的服务进行处理
        //辨识方法 1-PHA;
        if (updateParam.getIdentificationMethod() == 1){
            RiskAssessPlanIdentificationPha pha = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationPha.class);
            pha.setAssessPlanId(updateParam.getId());
            pha.setId(updateParam.getPhaId());
            PhaInsertDTO phaInsertDTO = phaService.updatePha(currentUserId, pha);
            if (ObjectUtils.isEmpty(phaInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(phaInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setPhaId(phaInsertDTO.getId());
            //辨识方法 2-JHA;
        }else if (updateParam.getIdentificationMethod() == 2){
            RiskAssessPlanIdentificationJha jha = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationJha.class);
            jha.setAssessPlanId(updateParam.getId());
            jha.setId(updateParam.getJhaId());
            JhaInsertDTO jhaInsertDTO = jhaService.updateJha(currentUserId, jha);
            if (ObjectUtils.isEmpty(jhaInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(jhaInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setJhaId(jhaInsertDTO.getId());
            //辨识方法 3-SCL;
        }else if (updateParam.getIdentificationMethod() == 3){
            RiskAssessPlanIdentificationScl scl = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationScl.class);
            scl.setAssessPlanId(updateParam.getId());
            scl.setId(updateParam.getSclId());
            SclInsertDTO sclInsertDTO = sclService.updateScl(currentUserId, scl);
            if (ObjectUtils.isEmpty(sclInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(sclInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setSclId(sclInsertDTO.getId());
            //辨识方法 4-HAZOP;
        }else if (updateParam.getIdentificationMethod() == 4){
            RiskAssessPlanIdentificationHazop hazop = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationHazop.class);
            hazop.setAssessPlanId(updateParam.getId());
            hazop.setId(updateParam.getHazopId());
            HazopInsertDTO hazopInsertDTO = hazopService.updateHazop(currentUserId, hazop);
            if (ObjectUtils.isEmpty(hazopInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(hazopInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setHazopId(hazopInsertDTO.getId());
            //5-类比法 nalogy;
        }else if (updateParam.getIdentificationMethod() == 5){
            RiskAssessPlanIdentificationAnalogy analogy = BeanCopyUtils.copyBean(updateParam, RiskAssessPlanIdentificationAnalogy.class);
            analogy.setAssessPlanId(updateParam.getId());
            analogy.setId(updateParam.getAnalogyId());
            AnalogyInsertDTO analogyInsertDTO = analogyService.updateAnalogy(currentUserId, analogy);
            if (ObjectUtils.isEmpty(analogyInsertDTO)){
                tag = 0;
            }
            factorQueryDTO = BeanCopyUtils.copyBean(analogyInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setAnalogyId(analogyInsertDTO.getId());
        }else {
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode(), "请选择正确的辨识方法");
        }
 
        RiskAssessPlanAppIdentificationBO riskAssessPlanAppIdentificationBO = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanAppIdentificationBO.class);
        //处理评估计划表
        AssessPlanIdentificationDTO identificationResult = assessPlanService.identification(currentUserId, riskAssessPlanAppIdentificationBO);
 
        if (ObjectUtils.isEmpty(identificationResult) && tag == 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "修改辨识失败");
        }
        return factorQueryDTO;
    }
 
    /**
     * 风险评估计划 - 辨识删除
     */
    @Override
    public int deleteIdentification(Long currentUserId, RiskAssessPlanIdentificationDeleteReqBO deleteReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        AssessPlanUpdateDTO deleteResult = assessPlanService.deleteIdentification(currentUserId, deleteReqBO);
 
        if (ObjectUtils.isEmpty(deleteResult)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险评估计划 - 辨识结果提交
     */
    @Override
    public int identificationSubmit(Long currentUserId, Long id) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        AssessPlanUpdateDTO identificationSubmitResult= assessPlanService.identificationSubmit(currentUserId, id);
 
        if (ObjectUtils.isEmpty(identificationSubmitResult)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险评估计划 - 评价
     */
    @Transactional
    @Override
    public FactorQueryDTO evaluate(Long currentUserId, RiskAssessPlanEvaluateInsertReqBO evaluateReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        RiskAssessPlanAppEvaluateBO evaluateParam = BeanCopyUtils.copyBean(evaluateReqBO, RiskAssessPlanAppEvaluateBO.class);
        AssessPlanQueryDTO assessPlanById = assessPlanService.getAssessPlanById(evaluateParam.getId());
        int tag = 1;
        FactorQueryDTO factorQueryDTO = new FactorQueryDTO();
        //分发参数到不同的服务进行处理
        // todo ,1、将参数与结果值传入,2计算比对前端传来的结果值是否正确,3相同存入,不同抛异常
        //辨识方法1 - LEC
        if (assessPlanById.getEvaluateMethod() == 1){
            AssessLecInsertBO lecInsertBO = BeanCopyUtils.copyBean(evaluateReqBO, AssessLecInsertBO.class);
            lecInsertBO.setAssessPlanId(evaluateParam.getId());
            lecInsertBO.setIdentificationId(evaluateReqBO.getIdentificationId());
            lecInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod());
            LecInsertDTO lecInsertDTO = lecService.insertLec(currentUserId, lecInsertBO);
            if (ObjectUtils.isEmpty(lecInsertDTO)){
                throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败");
            }
            factorQueryDTO = BeanCopyUtils.copyBean(lecInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setLecId(lecInsertDTO.getId());
            factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod());
            //辨识方法2 - LS
        }else if (assessPlanById.getEvaluateMethod() == 2){
            AssessLSInsertBO lsInsertBO = BeanCopyUtils.copyBean(evaluateReqBO, AssessLSInsertBO.class);
            lsInsertBO.setAssessPlanId(evaluateParam.getId());
            lsInsertBO.setIdentificationId(evaluateReqBO.getIdentificationId());
            lsInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod());
            LsInsertDTO lsInsertDTO = lsService.insertLs(currentUserId, lsInsertBO);
            if (ObjectUtils.isEmpty(lsInsertDTO)){
                throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败");
            }
            factorQueryDTO = BeanCopyUtils.copyBean(lsInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setLsId(lsInsertDTO.getId());
            factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod());
            //辨识方法3 - MES
        }else if (assessPlanById.getEvaluateMethod() == 3){
            AssessMesInsertBO mesInsertBO = BeanCopyUtils.copyBean(evaluateReqBO, AssessMesInsertBO.class);
            mesInsertBO.setAssessPlanId(evaluateParam.getId());
            mesInsertBO.setIdentificationId(evaluateReqBO.getIdentificationId());
            mesInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod());
            MesInsertDTO mesInsertDTO = mesService.InsertMes(currentUserId, mesInsertBO);
            if (ObjectUtils.isEmpty(mesInsertDTO)){
                throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败");
            }
            factorQueryDTO = BeanCopyUtils.copyBean(mesInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setMesId(mesInsertDTO.getId());
            factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod());
            //辨识方法4 - RS
        }else if (assessPlanById.getEvaluateMethod() == 4){
            AssessRsInsertBO rsInsertBO = BeanCopyUtils.copyBean(evaluateReqBO, AssessRsInsertBO.class);
            rsInsertBO.setAssessPlanId(evaluateParam.getId());
            rsInsertBO.setIdentificationId(evaluateReqBO.getIdentificationId());
            rsInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod());
            RsInsertDTO rsInsertDTO = rsService.InsertRs(currentUserId, rsInsertBO);
            if (ObjectUtils.isEmpty(rsInsertDTO)){
                throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败");
            }
            factorQueryDTO = BeanCopyUtils.copyBean(rsInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setRsId(rsInsertDTO.getId());
            factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod());
        }else {
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode(), "请选择正确的评价方法");
        }
 
        //处理评估计划表
        AssessPlanEvaluateDTO evaluateResult = assessPlanService.evaluate(currentUserId, evaluateParam);
        if (ObjectUtils.isEmpty(evaluateResult)){
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR.getCode(), "写入失败");
        }
        return factorQueryDTO;
    }
 
    /**
     * 风险评估计划 - 评价修改
     */
    @Transactional
    @Override
    public FactorQueryDTO updateEvaluate(Long currentUserId, RiskAssessPlanEvaluateUpdateReqBO updateReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        RiskAssessPlanEvaluateUpdateReqBO updateParam = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanEvaluateUpdateReqBO.class);
        AssessPlanQueryDTO assessPlanById = assessPlanService.getAssessPlanById(updateReqBO.getId());
        int tag = 1;
        FactorQueryDTO factorQueryDTO = new FactorQueryDTO();
        //分发参数到不同的服务进行处理
        // 1、将参数与结果值传入,2计算比对前端传来的结果值是否正确,3相同存入,不同抛异常
        //辨识方法1 - LEC
        if (assessPlanById.getEvaluateMethod() == 1){
            AssessLecInsertBO lecInsertBO = BeanCopyUtils.copyBean(updateParam, AssessLecInsertBO.class);
            lecInsertBO.setAssessPlanId(updateParam.getId());
            lecInsertBO.setId(updateParam.getLecId());
            lecInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod());
            LecInsertDTO lecInsertDTO = lecService.updateLec(currentUserId, lecInsertBO);
            if (ObjectUtils.isEmpty(lecInsertDTO)){
                throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "修改评价结果失败");
            }
            factorQueryDTO = BeanCopyUtils.copyBean(lecInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setLecId(lecInsertDTO.getId());
            factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod());
            //辨识方法2 - LS
        }else if (assessPlanById.getEvaluateMethod() == 2){
            AssessLSInsertBO lsInsertBO = BeanCopyUtils.copyBean(updateParam, AssessLSInsertBO.class);
            lsInsertBO.setAssessPlanId(updateParam.getId());
            lsInsertBO.setId(updateParam.getLsId());
            lsInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod());
            LecInsertDTO lsInsertDTO = lsService.updateLs(currentUserId, lsInsertBO);
            if (ObjectUtils.isEmpty(lsInsertDTO)){
                throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "修改评价结果失败");
            }
            factorQueryDTO = BeanCopyUtils.copyBean(lsInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setLsId(lsInsertDTO.getId());
            factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod());
            //辨识方法3 - MES
        }else if (assessPlanById.getEvaluateMethod() == 3){
            AssessMesInsertBO mesInsertBO = BeanCopyUtils.copyBean(updateParam, AssessMesInsertBO.class);
            mesInsertBO.setAssessPlanId(updateParam.getId());
            mesInsertBO.setId(updateParam.getMesId());
            mesInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod());
            MesInsertDTO mesInsertDTO = mesService.updateMes(currentUserId, mesInsertBO);
            if (ObjectUtils.isEmpty(mesInsertDTO)){
                throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败");
            }
            factorQueryDTO = BeanCopyUtils.copyBean(mesInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setMesId(mesInsertDTO.getId());
            factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod());
            //辨识方法4 - RS
        }else if (assessPlanById.getEvaluateMethod() == 4){
            AssessRsInsertBO rsInsertBO = BeanCopyUtils.copyBean(updateParam, AssessRsInsertBO.class);
            rsInsertBO.setAssessPlanId(updateParam.getId());
            rsInsertBO.setId(updateParam.getRsId());
            rsInsertBO.setIdentificationMethod(assessPlanById.getIdentificationMethod());
            RsInsertDTO rsInsertDTO = rsService.updateRs(currentUserId, rsInsertBO);
            if (ObjectUtils.isEmpty(rsInsertDTO)){
                throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "写入评价结果失败");
            }
            factorQueryDTO = BeanCopyUtils.copyBean(rsInsertDTO, FactorQueryDTO.class);
            factorQueryDTO.setRsId(rsInsertDTO.getId());
            factorQueryDTO.setEvaluateMethod(assessPlanById.getEvaluateMethod());
        }
 
        RiskAssessPlanAppEvaluateBO evaluateParam = BeanCopyUtils.copyBean(updateReqBO, RiskAssessPlanAppEvaluateBO.class);
        //处理评估计划表
        AssessPlanEvaluateDTO evaluateResult = assessPlanService.evaluateUpdate(currentUserId, evaluateParam);
 
        return factorQueryDTO;
    }
 
    /**
     * 风险评估计划 - 评价删除
     */
    @Override
    public int deleteEvaluate(Long currentUserId, RiskAssessPlanEvaluateDeleteReqBO deleteReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        AssessPlanUpdateDTO deleteResult= assessPlanService.deleteEvaluate(currentUserId, deleteReqBO);
 
        if (ObjectUtils.isEmpty(deleteResult)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险评估计划 - 评价结果提交
     */
    @Transactional
    @Override
    public int evaluateSubmit(Long currentUserId, Long id) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        //提交评价结果
        AssessPlanUpdateDTO evaluateSubmitResult= assessPlanService.evaluateSubmit(currentUserId, id);
 
        if (ObjectUtils.isEmpty(evaluateSubmitResult)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险辨识与评价 - 查询
     */
    @Override
    public SearchResult selectAssessPage(Long currentUserId, RiskAssessQueryReqBO queryReqBO) {
 
        SearchResult searchResult = new SearchResult<>();
 
        RiskAssessAppQueryBO queryBO = BeanCopyUtils.copyBean(queryReqBO, RiskAssessAppQueryBO.class);
 
        SearchResult<RiskAssessAppQueryDTO> queryResult = assessPlanService.selectAssessPage(currentUserId, queryBO);
 
        searchResult.setPageIndex(queryResult.getPageIndex());
        searchResult.setPageSize(queryResult.getPageSize());
        searchResult.setCount(queryResult.getCount());
        searchResult.setTotal(queryResult.getTotal());
        searchResult.setData(queryResult.getData());
 
        return searchResult;
    }
 
    /**
     * 实验风险单元 - 插入
     */
    @Transactional
    @Override
    public int insertRiskUnit(Long currentUserId, RiskUnitInsertReqBO riskUnitInsertReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
        int roleTag = 0;
        UserInfoDomainDTO user = userDomainService.getUserById(currentUserId);
//        for (SysUserRoleBindDomainDTO role : user.getRoles()) {
//            if (role.getRoleId() == UserRoleEnum.USER_ROLE_4.getCode().byteValue()){
//                roleTag = 1;
//            }
//        }
        //20241107修改注释权限
//        if (roleTag != 1){
//            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户不是管理人员,无权限添加");
//        }
        if (ObjectUtils.isEmpty(riskUnitInsertReqBO.getExperimentId())){
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不能为空");
        }
        ExperimentInfoDTO experimentById = experimentInfoService.getExperimentById(riskUnitInsertReqBO.getExperimentId());
 
        if (ObjectUtils.isEmpty(experimentById)){
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不存在或实验已被删除");
        }
        if (ObjectUtils.isEmpty(riskUnitInsertReqBO.getLiabilityUserId())){
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "责任人不能为空");
        }
 
        PersonQueryDTO basicExperimentPersonById = basicExperimentPersonService.getBasicExperimentPersonById(riskUnitInsertReqBO.getLiabilityUserId());
 
        if (ObjectUtils.isEmpty(basicExperimentPersonById)){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "责任人不存在,或已被删除");
        }
        RiskUnitAppInsertBO insertParam = BeanCopyUtils.copyBean(riskUnitInsertReqBO, RiskUnitAppInsertBO.class);
 
        RiskUnitInsertDTO riskUnitInsertDTO = riskUnitService.insertRiskUnit(currentUserId, insertParam);
 
        if (ObjectUtils.isEmpty(riskUnitInsertDTO)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 固有风险单元 - 插入
     */
    @Override
    public int insertInherentRiskUnit(Long currentUserId, InherentRiskUnitInsertReqBO insertReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
        int roleTag = 0;
        UserInfoDomainDTO user = userDomainService.getUserById(currentUserId);
        for (SysUserRoleBindDomainDTO role : user.getRoles()) {
            if (role.getRoleId() == UserRoleEnum.USER_ROLE_4.getCode().byteValue()){
                roleTag = 1;
            }
        }
        if (roleTag != 1){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户不是管理人员,无权限添加");
        }
        if (ObjectUtils.isEmpty(insertReqBO.getExperimentId())){
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不能为空,或实验已被删除");
        }
        ExperimentInfoDTO experimentById = experimentInfoService.getExperimentById(insertReqBO.getExperimentId());
 
        if (ObjectUtils.isEmpty(experimentById)){
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不存在或实验已被删除");
        }
        RiskUnitBasicQueryDTO basicRiskUnitById = basicRiskUnitService.getBasicRiskUnitById(insertReqBO.getBasicRiskUnitId());
 
        //封装插入需要的数据
        InherentRiskUnitAppInsertBO insertParam = BeanCopyUtils.copyBean(basicRiskUnitById, InherentRiskUnitAppInsertBO.class);
        insertParam.setExperimentId(insertReqBO.getExperimentId());
        insertParam.setBasicRiskUnitId(basicRiskUnitById.getId());
 
        RiskUnitInsertDTO riskUnitInsertDTO = riskUnitService.insertInherentRiskUnit(currentUserId, insertParam);
 
        if (ObjectUtils.isEmpty(riskUnitInsertDTO)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险单元 - 分页查询
     */
    @Override
    public SearchResult<RiskUnitAppQueryDTO> selectRiskUnitPage(Long currentUserId, RiskUnitQueryReqBO queryReqBO) {
 
        SearchResult searchResult = new SearchResult<>();
 
        RiskUnitAppQueryBO queryParam = BeanCopyUtils.copyBean(queryReqBO, RiskUnitAppQueryBO.class);
 
        SearchResult<RiskUnitQueryDTO> queryResult = riskUnitService.selectRiskUnitPage(currentUserId, queryParam);
 
        searchResult.setPageIndex(queryResult.getPageIndex());
        searchResult.setPageSize(queryResult.getPageSize());
        searchResult.setTotal(queryResult.getTotal());
        searchResult.setData(BeanCopyUtils.copyExperimentRiskUnitAppQueryList(queryResult.getData(), RiskUnitBasicQueryDTO.class));
 
        return searchResult;
    }
 
    /**
     * 风险单元 - 修改
     */
    @Override
    public int updateRiskUnit(Long currentUserId, RiskUnitUpdateReqBO updateReqBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
        int roleTag = 0;
        UserInfoDomainDTO user = userDomainService.getUserById(currentUserId);
//        for (SysUserRoleBindDomainDTO role : user.getRoles()) {
//            if (role.getRoleId() == UserRoleEnum.USER_ROLE_4.getCode().byteValue()){
//                roleTag = 1;
//            }
//        }
        //20241107修改注释权限
//        if (roleTag != 1){
//            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户不是管理人员,无权限修改");
//        }
        if (ObjectUtils.isEmpty(updateReqBO.getExperimentId())){
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不能为空,或实验已被删除");
        }
        ExperimentInfoDTO experimentById = experimentInfoService.getExperimentById(updateReqBO.getExperimentId());
 
        if (ObjectUtils.isEmpty(experimentById)){
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "所选实验不存在或实验已被删除");
        }
        if (ObjectUtils.isEmpty(updateReqBO.getLiabilityUserId())){
            throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "责任人不能为空");
        }
 
        PersonQueryDTO basicExperimentPersonById = basicExperimentPersonService.getBasicExperimentPersonById(updateReqBO.getLiabilityUserId());
        if (ObjectUtils.isEmpty(basicExperimentPersonById)){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "责任人不存在,或已被删除");
        }
        RiskUnitAppUpdateBO updateParam = BeanCopyUtils.copyBean(updateReqBO, RiskUnitAppUpdateBO.class);
 
        RiskUnitInsertDTO riskUnitUpdateDTO = riskUnitService.updateRiskUnit(currentUserId, updateParam);
 
        if (ObjectUtils.isEmpty(riskUnitUpdateDTO)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 风险单元 - 删除
     */
    @Override
    public int deleteRiskUnit(Long currentUserId, Long id) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
        RiskUnitQueryDTO riskUnitById = riskUnitService.getRiskUnitById(id);
        if (ObjectUtils.isEmpty(riskUnitById)){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前要删除的实验不存在,或已被删除");
        }
        int roleTag = 0;
        UserInfoDomainDTO user = userDomainService.getUserById(currentUserId);
        //20241107注释
//        for (SysUserRoleBindDomainDTO role : user.getRoles()) {
//            if (role.getRoleId() == UserRoleEnum.USER_ROLE_4.getCode().byteValue()){
//                roleTag = 1;
//            }
//        }
//        if (roleTag != 1){
//            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户不是管理人员,无权限添加");
//        }
        RiskUnitDeleteDTO deleteResult = riskUnitService.deleteRiskUnit(currentUserId, id);
 
        if (ObjectUtils.isEmpty(deleteResult)){
            return StatusEnum.FAIL.getCode();
        }
        return StatusEnum.SUCCESS.getCode();
    }
 
    /**
     * 基础风险单元管理 - 列表查询
     */
    @Override
    public SearchResult<RiskUnitListQueryRespDTO> listRiskUnit(Long currentUserId) {
 
        SearchResult result = new SearchResult();
 
        List<RiskUnitListAppQueryDTO> riskUnitListAppQueryDTOS = riskUnitService.listRiskUnit(currentUserId);
 
        result.setData(BeanCopyUtils.copyBeanList(riskUnitListAppQueryDTOS, RiskUnitListQueryRespDTO.class));
        result.setCount(riskUnitListAppQueryDTOS.size());
 
        return result;
    }
 
    /**
     * 风险单元 - 列表查询
     */
    @Override
    public SearchResult<RiskUnitListQueryRespDTO> listRiskUnitByExperiment(Long currentUserId, RiskUnitListReqBO reqBO) {
 
        SearchResult result = new SearchResult();
 
        List<RiskUnitListAppQueryDTO> riskUnitListAppQueryDTOS = riskUnitService.listRiskUnitByExperiment(currentUserId, reqBO);
 
        result.setData(BeanCopyUtils.copyBeanList(riskUnitListAppQueryDTOS, RiskUnitListQueryRespDTO.class));
        result.setCount(riskUnitListAppQueryDTOS.size());
 
        return result;
    }
 
    /**
     * 评估计划 - 列表查询
     */
    @Override
    public SearchResult<RiskAssessPlanListRespDTO> listAssessPlan() {
        SearchResult result = new SearchResult();
        Byte status = StatusEnum.PLAN_SELL.getCode().byteValue();
        List<RiskAssessPlanListAppDTO> riskAssessPlanListAppDTO = assessPlanService.listAssessPlan(status);
 
        result.setData(BeanCopyUtils.copyBeanList(riskAssessPlanListAppDTO, RiskAssessPlanListRespDTO.class));
        result.setCount(riskAssessPlanListAppDTO.size());
 
        return result;
    }
 
    /**
     * 评估计划 - 风险值计算
     */
    @Override
    public BigDecimal riskValue(RiskValueReqBO valueReqBO) {
 
        if (valueReqBO.getValue3() == null){
            BigDecimal value = valueReqBO.getValue1().multiply(valueReqBO.getValue2());
            return value;
        }
 
        BigDecimal value = valueReqBO.getValue1().multiply(valueReqBO.getValue2()).multiply(valueReqBO.getValue3());
 
        return value;
    }
 
    /**
     * 风险评估计划 - 辨识专家拒绝
     */
    @Override
    public AssessPlanUpdateDTO identificationRefuse(Long currentUserId, Long id) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
        AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.identificationRefuse(currentUserId, id);
        return assessPlanUpdateDTO;
    }
 
    /**
     * 风险评估计划 - 评价专家拒绝
     */
    @Override
    public AssessPlanUpdateDTO evaluateRefuse(Long currentUserId, Long id) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.evaluateRefuse(currentUserId, id);
        return assessPlanUpdateDTO;
    }
 
    /**
     * 风险评估计划 - 修改辨识方法
     */
    @Override
    public AssessPlanUpdateDTO identificationUpdateMethod(Long currentUserId, MethodUpdateReqDTO updateReqDTO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.identificationUpdateMethod(currentUserId, updateReqDTO);
 
        return assessPlanUpdateDTO;
    }
 
    /**
     * 风险评估计划 - 评价方法修改
     */
    @Override
    public AssessPlanUpdateDTO evaluateUpdateMethod(Long currentUserId, MethodUpdateReqDTO updateReqDTO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.evaluateUpdateMethod(currentUserId, updateReqDTO);
 
        return assessPlanUpdateDTO;
    }
    /**
     * 风险评估计划 - 重新指定专家
     */
    @Override
    public AssessPlanUpdateDTO appoint(Long currentUserId, AppointUserReBO appointUserReBO) {
 
        if (currentUserId < 0){
            throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR_NOT_ALLOWED.getCode(), "当前用户无效,请重新登录");
        }
 
        AssessPlanUpdateDTO assessPlanUpdateDTO = assessPlanService.appoint(currentUserId, appointUserReBO);
        return assessPlanUpdateDTO;
    }
 
}