jinlin
2024-01-15 1a7af6fff5185bb257c16b0445140c93263a3331
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
/**
 * 版权所有,侵权必究!
 */
 
package com.zt.modules.workflow.service;
 
import cn.hutool.core.convert.Convert;
import com.zt.common.entity.BaseEntity;
import com.zt.common.entity.BusiEntity;
import com.zt.common.entity.FlowInfo;
import com.zt.common.service.BaseService;
import com.zt.common.utils.UUIDUtil;
import com.zt.core.context.UserContext;
import com.zt.core.sys.model.SysUser;
import com.zt.modules.workflow.dao.WfRunTaskDao;
import com.zt.modules.workflow.dto.BizInfoDto;
import com.zt.modules.workflow.dto.QueryWfInfoDto;
import com.zt.modules.workflow.dto.TaskParamDto;
import com.zt.modules.workflow.model.WfRunInstance;
import com.zt.modules.workflow.model.WfRunTask;
import com.zt.modules.workflowconfig.dao.WfDefDao;
import com.zt.modules.workflowconfig.dao.WfDefStepDao;
import com.zt.modules.workflowconfig.model.WfDef;
import com.zt.modules.workflowconfig.model.WfDefStep;
import com.zt.modules.workflowconfig.service.WorkflowConfigService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 工作流服务
 *
 * @author 朱曙光
 * @since 1.0.0
 */
@Service
public class WorkflowService extends BaseService<WfRunTaskDao, WfRunTask> {
    @Autowired
    private WfDefStepDao wfDefStepDao;
 
    @Autowired
    private WfDefDao wfDefDao;
 
    @Autowired
    private WorkflowConfigService workflowConfigService;
 
    @Autowired
    private WfRunInstanceService wfRunInstanceService;
 
    @Value("${zt.oss.local-server}")
    private String localServer;
 
    public QueryWfInfoDto queryWfStepInfo(String wfCode, String wfStepId) {
        QueryWfInfoDto dto = new QueryWfInfoDto();
 
        dto.setIsMyStep(0);
        dto.setIsFirstStep(0);
        dto.setIsFinallyStep(0);
 
        WfDefStep firstStep = this.queryWfDefFirstStep(wfCode);
        WfDefStep finallyStep = this.queryWfDefFinallyStep(wfCode);
        WfDefStep currentStep;
        if (wfStepId == null) {
            currentStep = firstStep;
        } else {
            currentStep = wfDefStepDao.selectById(Convert.toLong(wfStepId));
        }
        if (currentStep == null)
            currentStep = firstStep;
 
        dto.setWfStepId(currentStep.getId());
        dto.setIsCounterSign(currentStep.getIsCounterSign());
        dto.setCanRefuse(currentStep.getCanRefuse());
        dto.setStepName(currentStep.getName());
        dto.setApproverIds(currentStep.getApproverIds());
 
        if (firstStep.getId() == currentStep.getId()) {
            dto.setIsFirstStep(1);
        }
        if (finallyStep.getId() == currentStep.getId()) {
            dto.setIsFinallyStep(1);
        }
        if (("," + currentStep.getApproverIds() + ",").contains("," + UserContext.getUserId().toString() + ",")) {
            dto.setIsMyStep(1);
        }
        return dto;
    }
 
    public WfDefStep queryWfDefStep(String wfIdCode, String stepIdMarker) {
        List<WfDefStep> list = wfDefStepDao.queryWfDefStep(wfIdCode, stepIdMarker);
        if (list.isEmpty()) {
            return null;
        } else {
            WfDefStep step = list.get(0);
            // step.setCurrentUserId(UserContext.getUserId().toString());
            return step;
        }
    }
 
    public WfDefStep queryWfDefFirstStep(String wfIdCode) {
        List<WfDefStep> list = wfDefStepDao.queryWfDefFirstStep(wfIdCode);
        if (list.isEmpty()) {
            return null;
        } else {
            WfDefStep step = list.get(0);
            // step.setCurrentUserId(UserContext.getUserId().toString());
            return step;
        }
    }
 
    public WfDefStep queryWfDefFinallyStep(String wfIdCode) {
        List<WfDefStep> list = wfDefStepDao.queryWfDefFinallyStep(wfIdCode);
        if (list.isEmpty()) {
            return null;
        } else {
            WfDefStep step = list.get(0);
            // step.setCurrentUserId(UserContext.getUserId().toString());
            return step;
        }
    }
 
    public WfDefStep queryWfDefNextStep(WfDefStep currentStep) {
        if (currentStep == null) {
            throw new RuntimeException("Null WfDefStep object.");
        }
 
        List<WfDefStep> list = wfDefStepDao.queryWfDefNextStep(currentStep);
        if (list.isEmpty()) {
        } else {
            return list.get(0);
        }
        return null;
    }
 
    public WfDefStep queryWfDefPreStep(WfDefStep currentStep) {
        if (currentStep == null) {
            throw new RuntimeException("Null WfDefStep object.");
        }
        List<WfDefStep> list = wfDefStepDao.queryWfDefPreStep(currentStep);
        if (list.isEmpty()) {
        } else {
            return list.get(0);
        }
        return null;
    }
 
    public WfDefStep queryCurrentTaskStep(String wfIdCode, Long bizId) {
        List<WfDefStep> list = baseDao.queryCurrentTaskStep(wfIdCode, bizId);
        if (list.size() > 0)
            return list.get(0);
        else
            return null;
    }
 
    public WfDefStep queryCurrentTaskStep100(String wfIdCode, Long bizId) {
        List<WfDefStep> list = baseDao.queryCurrentTaskStep100(wfIdCode, bizId);
        if (list.size() > 0)
            return list.get(0);
        else
            return null;
    }
 
    public Boolean isFlowFinish(String wfIdCode, Long bizId) {
        Boolean result = true;
        String[] wfIdCodeArr = wfIdCode.split(",");
        for (String code : wfIdCodeArr) {
            List<WfRunTask> list = baseDao.getFlowFinish(wfIdCode, bizId);
            if (list.size() == 0) {
                result = false;
                break;
            }
        }
        return result;
    }
 
    // 按task分組設置上一步狀體,並獲取設置狀態后縂的步驟狀態
    public Boolean setMyStepStatus(Long prevStepId, Long currentStepId, Integer status, Long bizId, Integer option) {
        Boolean result = false;
        WfDefStep prevStep = workflowConfigService.get(prevStepId);
        if (prevStep != null) {
            String taskGroup = prevStep.getTaskGroup();
            status = status == 0 ? 20 : 10; // (0:20 pass, 1:10 refuse)
 
            // 设置状态 本人status 别人status+1 taskGroup
            baseDao.setTaskStatus(bizId, prevStepId, status, UserContext.getUserId(),
                    UserContext.getUser().getRealName(), taskGroup, option);
            if (prevStep.getStepType() != 0 && currentStepId == 0L)
                return false;
 
            if (option == 1) {
                // 1 refuse 2 pass 已办任务不显示 施工清单已办
                // 设置状态 是否是驳回的(撤回?)
                // 如果是駁回的,則後面的步驟都設置 status2 =1, 查詢狀態或待辦任務的時候要剔出
                baseDao.setTaskRefuse(bizId, currentStepId, 1);
            }
 
            if (status == 10) {
                // 驳回肯定执行(如果是按专业、部门分组的话,都驳回)
                result = true;
            } else {
                // 前进的话检查,是否所有的都完成了(taskGroup)
                result = this.getFlowStepFinish(prevStep.getWfDefId().toString(), bizId, prevStep.getStepMarker());
            }
        }
        return result;
    }
 
    public void setTaskPartFinish(Long bizId, Long currentStepId, Integer status) {
        baseDao.setTaskPartFinish(bizId, currentStepId, status);
    }
 
    public void setTaskPartFinish2(Long bizId, Long receiveId, Integer status) {
        baseDao.setTaskPartFinish2(bizId, receiveId, status);
    }
 
    public void setTaskPartFinish3(Long bizId, Long receiveDeptId, Integer status) {
        baseDao.setTaskPartFinish3(bizId, receiveDeptId, status);
    }
 
    public void setFlowTask(Long prevStepId, Long currentStepId, Integer status, Long bizId, String deptIds,
            Integer direct) {
        Boolean result = true;
        if (prevStepId > 0) {
            // 设置上一步骤的分組状态,並獲取上一步骤縂的狀態
            result = setMyStepStatus(prevStepId, currentStepId, status, bizId, direct);
        }
        if (result) {
            /*
             * int num = baseDao.isExistsStep(null, currentStepId, bizId); if (num == 0) {
             * setNextFlowTask(prevStepId, currentStepId, status, bizId, deptIds); }
             */
            setNextFlowTask(prevStepId, currentStepId, status, bizId, deptIds);
        }
    }
 
    public int isExistsStep(String currentStepMarker, Long currentStepId, Long bizId) {
        int num = baseDao.isExistsStep(currentStepMarker, currentStepId, bizId);
        System.out.println("num:" + num);
        return num;
    }
 
    public void setNextFlowTask(Long prevStepId, Long currentStepId, Integer status, Long bizId, String deptIds) {
        int num = baseDao.isExistsRunningStep(null, currentStepId, bizId);
        if (num > 0) {
            // 已經存在該步驟了,不用繼續
            return;
        }
        WfDefStep currentStep = workflowConfigService.get(currentStepId);
        WfDefStep finallyStep = this.queryWfDefFinallyStep(currentStep.getWfDefId().toString());
 
        WfDef wfDef = wfDefDao.queryWfDef(currentStep.getWfDefId(), null).get(0);
 
        Long instanceId = UUIDUtil.generateId();
        WfRunInstance wfRunInstanceOld = wfRunInstanceService.getFlowInstance(wfDef.getCode(), bizId);
        Boolean isNewInstance = true;
        if (wfRunInstanceOld != null) {
            isNewInstance = false;
            instanceId = wfRunInstanceOld.getId();
        }
 
        String sqlStr = wfDef.getBizSql();
        sqlStr = sqlStr.replace("${bizId}", bizId.toString());
        List<BizInfoDto> bizInfoList = baseDao.getSqlResult(sqlStr);
        BizInfoDto bizInfoDto = bizInfoList.size() > 0 ? bizInfoList.get(0) : null;
 
        Long preTaskId = 0L;
        WfRunTask task = getFlowStepStatus(wfDef.getCode(), bizId, currentStep.getStepMarker());
        if (task != null)
            preTaskId = task.getId();
 
        // sqlStr = "update project set subject='aaa' where id=${bizId}";
        // sqlStr = sqlStr.replace("${bizId}",bizId.toString());
        // baseDao.exeSql(sqlStr);
 
        Map<Long, String> existsUsers = new HashMap<Long, String>();
 
        TaskParamDto taskParamDto = new TaskParamDto();
        taskParamDto.setInstanceId(instanceId);
        taskParamDto.setPreTaskId(preTaskId);
        taskParamDto.setPrevStepId(prevStepId);
        taskParamDto.setBizId(bizId);
        taskParamDto.setStatus(status);
        taskParamDto.setStatus2(0);
        taskParamDto.setGroupId(UUIDUtil.generateId());
        taskParamDto.setGroupId2(null);
        taskParamDto.setEventDate(new Date());
        taskParamDto.setWfDef(wfDef);
        taskParamDto.setCurrentStep(currentStep);
        taskParamDto.setBizInfoDto(bizInfoDto);
 
        if (finallyStep.getStepNo() > currentStep.getStepNo()) {
 
            Integer isSelfDept = currentStep.getIsSelfDept();
            if (isSelfDept > 0 && bizInfoDto!=null) {
                deptIds = bizInfoDto.getDeptIds();
            }
            if (isSelfDept == 0)
                deptIds = null;
 
            String bizGroupId = bizInfoList.get(0).getBizId();
            if ("br".equals(currentStep.getTaskGroup())) {
                List<SysUser> listUser = baseDao.getAssignUser(wfDef.getCode(), currentStep.getStepMarker(), bizId);
                for (SysUser user : listUser) {
                    if (existsUsers.containsKey(user.getId())) {
                        continue;
                    }
                    existsUsers.put(user.getId(), "");
                    taskParamDto.setUser(user);
                    taskParamDto.setGroupId2(user.getId());
                    insertFlowTaskData(taskParamDto);
                }
            }
            else if (currentStep.getTaskGroup() !=null && "pall,zrr,csr,shr,pzr".contains(currentStep.getTaskGroup())) {
                String userList = null;
                if ("zrr".equals(currentStep.getTaskGroup())) {
                    userList = bizInfoDto.getZrr();
                }
                if ("csr".equals(currentStep.getTaskGroup())) {
                    userList = bizInfoDto.getCsr();
                }
                if ("shr".equals(currentStep.getTaskGroup())) {
                    userList = bizInfoDto.getShr();
                }
                if ("pzr".equals(currentStep.getTaskGroup())) {
                    userList = bizInfoDto.getPzr();
                }
                if ("pall".equals(currentStep.getTaskGroup())) {
                    userList = bizInfoDto.getPall();
                }
                if (userList != null) {
                    String[] userArr = userList.split(",");
                    Long groupId2 = UUIDUtil.generateId();
                    for (String userStr : userArr) {
                        Long userId = Convert.toLong(userStr);
                        SysUser user = baseDao.getUserById(userId);
                        existsUsers.put(userId, "");
                        taskParamDto.setUser(user);
                        taskParamDto.setGroupId2(groupId2);
                        insertFlowTaskData(taskParamDto);
                    }
                }
            } else if ("sqr".equals(currentStep.getTaskGroup())) {
                SysUser user = baseDao.getUserById(bizInfoList.get(0).getApplyUserId());
                existsUsers.put(user.getId(), "");
                taskParamDto.setUser(user);
                taskParamDto.setGroupId2(user.getId());
                insertFlowTaskData(taskParamDto);
            } else {
                String roleIds = currentStep.getApproverRoleIds();
                if (StringUtils.isBlank(roleIds)) {
                    throw new RuntimeException("没有设置下一步流程角色!");
                }
                String[] roleIdArr = roleIds.split(",");
                for (String roleId : roleIdArr) {
                    if (StringUtils.isBlank(roleId))
                        continue;
                    List<SysUser> listUser = baseDao.getTaskUser(roleId, deptIds);
                    for (SysUser user : listUser) {
                        if (existsUsers.containsKey(user.getId())) {
                            continue;
                        }
                        existsUsers.put(user.getId(), "");
                        taskParamDto.setUser(user);
                        taskParamDto.setGroupId2(Convert.toLong(roleId));
                        insertFlowTaskData(taskParamDto);
                    }
                }
            }
            if (existsUsers.size() == 0) {
                throw new RuntimeException("没有符合(" + wfDef.getName() + ")流程的下一步(" + currentStep.getName() + ")执行人!");
            }
 
            WfDefStep prevStep = workflowConfigService.get(prevStepId);
            if (prevStep!=null) {
                String updateSql = prevStep.getUpdateSql();
                if (org.apache.commons.lang3.StringUtils.isNotBlank(updateSql)) {
                    updateSql = updateSql.replace("${bizId}", bizId.toString());
                    updateSql = updateSql.replace("${bizId}", bizId.toString());
                    updateSql = updateSql.replace("${nickName}", UserContext.getUser().getRealName());
                    updateSql = updateSql.replace("${userId}", UserContext.getUser().getId().toString());
                    baseDao.exeSql(updateSql);
                }
            }
        } else {
            taskParamDto.setUser(null);
            taskParamDto.setGroupId2(null);
            status = 100;
            taskParamDto.setFinishTime(new Date());
            taskParamDto.setStatus(status);
            insertFlowTaskData(taskParamDto);
 
            String updateSql = currentStep.getUpdateSql();
            if (org.apache.commons.lang3.StringUtils.isNotBlank(updateSql)) {
                updateSql = updateSql.replace("${bizId}", bizId.toString());
                updateSql = updateSql.replace("${bizId}", bizId.toString());
                updateSql = updateSql.replace("${nickName}", UserContext.getUser().getRealName());
                updateSql = updateSql.replace("${userId}", UserContext.getUser().getId().toString());
                baseDao.exeSql(updateSql);
            }
 
            WfDefStep prevStep = workflowConfigService.get(prevStepId);
            if (prevStep!=null) {
                updateSql = prevStep.getUpdateSql();
                if (org.apache.commons.lang3.StringUtils.isNotBlank(updateSql)) {
                    updateSql = updateSql.replace("${bizId}", bizId.toString());
                    updateSql = updateSql.replace("${bizId}", bizId.toString());
                    updateSql = updateSql.replace("${nickName}", UserContext.getUser().getRealName());
                    updateSql = updateSql.replace("${userId}", UserContext.getUser().getId().toString());
                    baseDao.exeSql(updateSql);
                }
            }
 
            if (!StringUtils.isBlank(currentStep.getNextFlows())) {
                boolean canNext = true;
                if (!StringUtils.isBlank(currentStep.getPreFlows())) {
                    if (!this.isFlowFinish(currentStep.getPreFlows(), bizId)) {
                        canNext = false;
                    }
                }
                if (canNext) {
                    String[] nextFlowArr = currentStep.getNextFlows().split(",");
                    for (String nextFlowCode : nextFlowArr) {
                        this.startFlow(nextFlowCode, bizId);
                    }
                }
            }
        }
        if (currentStep.getStepType() == 0) {
            WfRunInstance wfRunInstance = new WfRunInstance();
 
            wfRunInstance.setFlowId(wfDef.getId());
            wfRunInstance.setFlowCode(wfDef.getCode());
 
            wfRunInstance.setBizId(bizId);
            wfRunInstance.setRunStatus(1);
 
            wfRunInstance.setHasOut(0);
            wfRunInstance.setStepSite(currentStep.getStepSite());
            wfRunInstance.setStepId(currentStep.getStepId());
            wfRunInstance.setStepMarker(currentStep.getStepMarker());
            wfRunInstance.setStepName(currentStep.getName());
            wfRunInstance.setStatus(status);
            wfRunInstance.setPrevId(preTaskId);
            wfRunInstance.setPrevStepId(prevStepId);
 
            wfRunInstance.setSenderId(UserContext.getUser().getId());
            wfRunInstance.setSenderName(UserContext.getUser().getRealName());
            wfRunInstance.setSenderTime(taskParamDto.getEventDate());
 
            String param = bizInfoDto == null ? "" : bizInfoDto.getParam();
            param = "".equals(param) ? "" : " (" + param + ")";
            wfRunInstance.setRemark(wfDef.getRemark() + param);
 
            wfRunInstance.setTitle(wfDef.getName());
            if (bizInfoList.size() > 0) {
                wfRunInstance.setBizGroupId(taskParamDto.getBizInfoDto().getBizGroupId());
                wfRunInstance.setApplyUserId(taskParamDto.getBizInfoDto().getApplyUserId());
                wfRunInstance.setApplyUser(taskParamDto.getBizInfoDto().getApplyUser());
                wfRunInstance.setApplyTime(taskParamDto.getBizInfoDto().getApplyTime());
                wfRunInstance.setTopic(taskParamDto.getBizInfoDto().getTopic());
            }
 
            if (isNewInstance) {
                // wfRunInstance = new WfRunInstance();
                wfRunInstance.setId(instanceId);
                wfRunInstanceService.insert(wfRunInstance);
            } else {
                wfRunInstance.setId(wfRunInstanceOld.getId());
                wfRunInstanceService.update(wfRunInstance);
            }
        }
 
        WfDefStep prevStep = workflowConfigService.get(prevStepId);
        if (prevStep != null && currentStep.getStepType() == 0) {
            if (prevStep.getCopyTo() != null) {
                String[] copyStepArr = prevStep.getCopyTo().split(",");
                for (String stepMarker : copyStepArr) {
                    WfDefStep wfDefStep = this.queryWfDefStep(null, stepMarker);
                    if (wfDefStep != null)
                        setNextFlowTask(prevStep.getId(), wfDefStep.getId(), 0, bizId, null);
                }
            }
        }
    }
 
    public void insertFlowTaskData(TaskParamDto taskParamDto) {
        WfRunTask wfRunTask = new WfRunTask();
        wfRunTask.setInstanceId(taskParamDto.getInstanceId());
        wfRunTask.setPrevId(taskParamDto.getPreTaskId());
        wfRunTask.setPrevStepId(taskParamDto.getPrevStepId());
        wfRunTask.setFlowCode(taskParamDto.getWfDef().getCode());
        wfRunTask.setFlowId(taskParamDto.getCurrentStep().getWfDefId());
        wfRunTask.setStepId(taskParamDto.getCurrentStep().getId());
        wfRunTask.setStepName(taskParamDto.getCurrentStep().getName());
        wfRunTask.setStepMarker(taskParamDto.getCurrentStep().getStepMarker());
 
        wfRunTask.setHasOut(0);
        wfRunTask.setStepSite(taskParamDto.getCurrentStep().getStepSite());
 
        wfRunTask.setBizId(taskParamDto.getBizId());
        wfRunTask.setGroupId(taskParamDto.getGroupId());
        wfRunTask.setGroupId2(taskParamDto.getGroupId2());
 
        wfRunTask.setSenderId(UserContext.getUser().getId());
        wfRunTask.setSenderName(UserContext.getUser().getRealName());
        wfRunTask.setSenderTime(taskParamDto.getEventDate());
 
        if (taskParamDto.getUser() != null) {
            wfRunTask.setReceiveId(taskParamDto.getUser().getId());
            wfRunTask.setReceiveName(taskParamDto.getUser().getRealName());
        }
 
        wfRunTask.setReceiveTime(taskParamDto.getEventDate());
        wfRunTask.setOpenTime(null);
        wfRunTask.setFinishTime(null);
        wfRunTask.setFinishTime2(null);
 
        wfRunTask.setStatus(taskParamDto.getStatus());
        String param = "";
        if (taskParamDto.getBizInfoDto() != null) {
            param = taskParamDto.getBizInfoDto().getParam();
            wfRunTask.setBizGroupId(taskParamDto.getBizInfoDto().getBizGroupId());
            wfRunTask.setApplyUserId(taskParamDto.getBizInfoDto().getApplyUserId());
            wfRunTask.setApplyUser(taskParamDto.getBizInfoDto().getApplyUser());
            wfRunTask.setApplyTime(taskParamDto.getBizInfoDto().getApplyTime());
            wfRunTask.setTopic(taskParamDto.getBizInfoDto().getTopic());
        }
        if (StringUtils.isBlank(taskParamDto.getCurrentStep().getStepTitle())) {
            wfRunTask.setTitle(taskParamDto.getWfDef().getName());
        } else {
            wfRunTask.setTitle(taskParamDto.getCurrentStep().getStepTitle());
        }
        param = "".equals(param) ? "" : " (" + param + ")";
        wfRunTask.setRemark(taskParamDto.getWfDef().getRemark() + param);
 
        baseDao.insert(wfRunTask);
    }
 
    @Transactional(rollbackFor = Exception.class)
    public Boolean writeFlowTask(WfRunTask wfRunTask) {
        Date eventDate = new Date();
        Long groupId = UUIDUtil.generateId();
        // wfRunTask.setPrevId(0L);
        /// wfRunTask.setPrevStepId(0L);
        // wfRunTask.setFlowId(currentStep.getWfDefId());
        // wfRunTask.setFlowCode(wfDef.get(0).getCode());
        // wfRunTask.setStepId(currentStep.getId());
        // wfRunTask.setStepName(currentStep.getName());
        // wfRunTask.setStepMarker(currentStep.getStepMarker());
        // wfRunTask.setBizId(bizId);
        // wfRunTask.setTitle(currentStep.getStepTitle());
        wfRunTask.setSenderId(UserContext.getUser().getId());
        wfRunTask.setSenderName(UserContext.getUser().getRealName());
        wfRunTask.setSenderTime(eventDate);
 
        wfRunTask.setGroupId(groupId);
        wfRunTask.setGroupId2(groupId);
        // wfRunTask.setReceiveId(UserContext.getUser().getId());
        // wfRunTask.setReceiveName(UserContext.getUser().getRealName());
        wfRunTask.setReceiveTime(eventDate);
        wfRunTask.setOpenTime(null);
        wfRunTask.setFinishTime(null);
        wfRunTask.setFinishTime2(null);
 
        // wfRunTask.setStatus(100);
        wfRunTask.setApplyUserId(UserContext.getUser().getId());
        wfRunTask.setApplyUser(UserContext.getUser().getRealName());
        wfRunTask.setApplyTime(eventDate);
 
        baseDao.insert(wfRunTask);
        return true;
    }
 
    @Transactional(rollbackFor = Exception.class)
    public Boolean startFlow(String wfCode, Long bizId) {
        if (hasExistFlow(wfCode, bizId)) {
            return false;
        }
        WfDefStep firstStep = this.queryWfDefFirstStep(wfCode);
        if (firstStep == null) {
            throw new RuntimeException("没有定义流程" + wfCode);
        }
 
        // this.createFlowInstance(wfCode,bizId);
        this.setFlowTask(0L, firstStep.getId(), 0, bizId, null, 0);
        return true;
    }
 
    public void createFlowInstance(String wfCode, Long bizId) {
        WfDef wfDef = wfDefDao.queryWfDef(null, wfCode).get(0);
        WfRunInstance wfRunInstance = new WfRunInstance();
        wfRunInstance.setFlowId(wfDef.getId());
        wfRunInstance.setFlowCode(wfDef.getCode());
        wfRunInstance.setBizId(bizId);
        wfRunInstanceService.insert(wfRunInstance);
    }
 
    public void deleteFlowTask(String wfIdCodes, Long bizId) {
        baseDao.deleteFlowTask(wfIdCodes, bizId);
    }
 
    @Transactional(rollbackFor = Exception.class)
    public void approvePass(String wfIdCode, Long bizId, String stepIdMark) {
        WfDefStep taskDbStep = this.queryCurrentTaskStep(wfIdCode, bizId);
        if (taskDbStep == null) {
            throw new RuntimeException("没有当前任务");
        }
        WfDefStep currentStep = this.queryWfDefStep(wfIdCode, stepIdMark);
        if (currentStep == null) {
            throw new RuntimeException("该流程没有该步骤");
        }
 
        WfDefStep endStep = this.queryWfDefFinallyStep(wfIdCode);
        if (currentStep.getStepNo() == endStep.getStepNo()) {
            throw new RuntimeException("已经完成了,不能继续提交");
        }
 
        if (taskDbStep.getStepNo() != currentStep.getStepNo()) {
            throw new RuntimeException("其他用户已经提交");
        } else {
            Long nextStepId = 0L;
            if (currentStep.getStepType() == 0) {
                WfDefStep nextStep = this.queryWfDefNextStep(currentStep);
                nextStepId = nextStep.getId();
            }
            this.setFlowTask(currentStep.getId(), nextStepId, 0, bizId, null, 2);
        }
    }
 
    @Transactional(rollbackFor = Exception.class)
    public void approvePass2(String wfIdCode, Long bizId, String stepIdMark, String nextStepIdMark) {
        WfDefStep currentStep = this.queryWfDefStep(wfIdCode, stepIdMark);
        if (currentStep == null) {
            throw new RuntimeException("该流程没有该当前步骤");
        }
 
        Long nextStepId = 0L;
        if (currentStep.getStepType() == 0) {
            WfDefStep nextStep = this.queryWfDefStep(wfIdCode, nextStepIdMark);
            nextStepId = nextStep.getId();
            if (currentStep == null) {
                throw new RuntimeException("该流程没有指定下一步步骤");
            }
        }
 
        WfDefStep endStep = this.queryWfDefFinallyStep(wfIdCode);
        if (currentStep.getStepNo() == endStep.getStepNo()) {
            throw new RuntimeException("已经完成了,不能继续提交");
        }
        this.setFlowTask(currentStep.getId(), nextStepId, 0, bizId, null, 2);
    }
 
    @Transactional(rollbackFor = Exception.class)
    public void approveDirectPass(String wfIdCode, Long bizId, String stepIdMark, String nextStepIdMark) {
        WfDefStep currentStep = this.queryWfDefStep(wfIdCode, stepIdMark);
        if (currentStep == null) {
            throw new RuntimeException("该流程没有该当前步骤");
        }
 
        Long nextStepId = 0L;
        if (currentStep.getStepType() == 0) {
            WfDefStep nextStep = this.queryWfDefStep(wfIdCode, nextStepIdMark);
            nextStepId = nextStep.getId();
            if (currentStep == null) {
                throw new RuntimeException("该流程没有指定下一步步骤");
            }
        }
 
        WfDefStep endStep = this.queryWfDefFinallyStep(wfIdCode);
        if (currentStep.getStepNo() == endStep.getStepNo()) {
            throw new RuntimeException("已经完成了,不能继续提交");
        }
        this.setNextFlowTask(currentStep.getId(), nextStepId, 0, bizId, null);
    }
 
    @Transactional(rollbackFor = Exception.class)
    // 驳回到上一步
    public void approveRefuse(String wfIdCode, Long bizId, String stepIdMark) {
        WfDefStep taskDbStep = this.queryCurrentTaskStep(wfIdCode, bizId);
        if (taskDbStep == null) {
            throw new RuntimeException("没有当前任务");
        }
 
        WfDefStep currentStep = this.queryWfDefStep(wfIdCode, stepIdMark);
        if (currentStep == null) {
            throw new RuntimeException("该流程没有该步骤");
        }
 
        WfDefStep firstStep = this.queryWfDefFirstStep(wfIdCode);
        if (currentStep.getStepNo() == firstStep.getStepNo()) {
            throw new RuntimeException("已经第一步了,不能驳回");
        }
 
        if (taskDbStep.getStepNo() != currentStep.getStepNo()) {
            throw new RuntimeException("其他用户已经提交");
        } else {
            WfDefStep preStep = this.queryWfDefPreStep(currentStep);
            this.setFlowTask(currentStep.getId(), preStep.getId(), 1, bizId, null, 1);
        }
    }
 
    @Transactional(rollbackFor = Exception.class)
    // 驳回到指定步骤
    public void approveRefuse2(String wfIdCode, Long bizId, String stepIdMark, String prevStepIdMark) {
        WfDefStep taskDbStep = this.queryCurrentTaskStep100(wfIdCode, bizId);
        if (taskDbStep == null) {
            throw new RuntimeException("没有当前任务");
        }
 
        WfDefStep currentStep = this.queryWfDefStep(wfIdCode, stepIdMark);
        if (currentStep == null) {
            throw new RuntimeException("该流程没有该当前步骤");
        }
 
        WfDefStep firstStep = this.queryWfDefFirstStep(wfIdCode);
        if (currentStep.getStepNo() == firstStep.getStepNo()) {
            throw new RuntimeException("已经第一步了,不能驳回");
        }
 
        WfDefStep preStep = this.queryWfDefStep(wfIdCode, prevStepIdMark);
        if (preStep == null) {
            throw new RuntimeException("该流程没有指定前一步步骤");
        }
        this.setFlowTask(currentStep.getId(), preStep.getId(), 1, bizId, null, 1);
    }
 
    @Transactional(rollbackFor = Exception.class)
    // 重新从某一步开始
    public void reStartFlow(String wfIdCode, Long bizId, String stepIdMark, String prevStepIdMark) {
        WfDefStep taskDbStep = this.queryCurrentTaskStep100(wfIdCode, bizId);
        if (taskDbStep == null) {
            throw new RuntimeException("没有当前任务");
        }
 
        WfDefStep currentStep = this.queryWfDefStep(wfIdCode, stepIdMark);
        if (currentStep == null) {
            throw new RuntimeException("该流程没有该当前步骤");
        }
 
        WfDefStep firstStep = this.queryWfDefFirstStep(wfIdCode);
        if (currentStep.getStepNo() == firstStep.getStepNo()) {
            throw new RuntimeException("已经第一步了,不能驳回");
        }
 
        WfDefStep preStep = this.queryWfDefStep(wfIdCode, prevStepIdMark);
        if (preStep == null) {
            throw new RuntimeException("该流程没有指定前一步步骤");
        }
        baseDao.setReStartStatus(wfIdCode, bizId);
        this.setFlowTask(currentStep.getId(), preStep.getId(), 0, bizId, null, 1);
    }
 
    public Map<String, WfRunTask> getSingleFlowStatus(String wfIdCodes, Long bizId) {
        int lastStepStatus = 100;
        Map<String, WfRunTask> result = new HashMap<>();
        if ("yearPlanFlow".equals(wfIdCodes)) {
            WfRunTask item_zl = new WfRunTask();
            WfRunTask item_cz = new WfRunTask();
            int count = baseDao.getRoleCount(UserContext.getUser().getId(), "zlbm");
            if (count > 1) {
                item_zl.setStatus(1);
                item_cz.setStatus(0);
            } else {
                item_zl.setStatus(20);
                item_cz.setStatus(1);
            }
            result.put("yearPlanFlow_zl", item_zl);
            result.put("yearPlanFlow_cz", item_cz);
        } else if ("yearPlanFlow2".equals(wfIdCodes)) {
            WfRunTask item_zl = new WfRunTask();
            WfRunTask item_cz = new WfRunTask();
            int status = baseDao.getPlanStatus(bizId);
            if (status == 10) {
                item_zl.setStatus(20);
                item_cz.setStatus(20);
            } else if (status == 5) {
                item_zl.setStatus(20);
                item_cz.setStatus(1);
            } else {
                item_zl.setStatus(1);
                item_cz.setStatus(0);
            }
 
            result.put("yearPlanFlow_zl", item_zl);
            result.put("yearPlanFlow_cz", item_cz);
        } else {
            List<WfRunTask> list = baseDao.getSingleFlowStatus(wfIdCodes, bizId);
            for (WfRunTask item : list) {
                lastStepStatus = checkStaus(lastStepStatus, item.getStatus(), item);
                item.setStatus(lastStepStatus);
                result.put(item.getStepMarker(), item);
            }
        }
        return result;
    }
 
    public int checkStaus(int lastStepStatus, int currentStepStatus, WfRunTask item) {
        if (currentStepStatus > lastStepStatus && !"jzjys_sc".equals(item.getStepMarker())) {
            return 0;
        } else {
            return currentStepStatus;
        }
    }
 
    public Map<String, WfRunTask> getFlowStatus(String wfIdCodes, Long bizId) {
        int lastStepStatus = 0;
        String lastflowCode = "";
        Map<String, WfRunTask> result = new HashMap<>();
        List<WfRunTask> list = baseDao.getFlowStatus(wfIdCodes, bizId);
        for (WfRunTask item : list) {
            if (!lastflowCode.equals(item.getFlowCode())) {
                lastflowCode = item.getFlowCode();
                lastStepStatus = item.getStatus();
                result.put(item.getStepMarker(), item);
            } else {
                lastStepStatus = checkStaus(lastStepStatus, item.getStatus(), item);
                item.setStatus(lastStepStatus);
                result.put(item.getStepMarker(), item);
            }
        }
 
        List<WfRunTask> list2 = baseDao.getFlowStatus2(wfIdCodes, bizId);
        for (WfRunTask item : list2) {
            if (!lastflowCode.equals(item.getFlowCode())) {
                lastflowCode = item.getFlowCode();
                lastStepStatus = item.getStatus();
                result.put(item.getStepMarker(), item);
            } else {
                lastStepStatus = checkStaus(lastStepStatus, item.getStatus(), item);
                item.setStatus(lastStepStatus);
                result.put(item.getStepMarker(), item);
            }
        }
        return result;
    }
 
    public Map<String, WfRunTask> getFlowStatus2(String wfIdCodes, Long bizId) {
        Map<String, WfRunTask> result = new HashMap<>();
        List<WfRunTask> list = baseDao.getFlowStatus3(wfIdCodes, bizId);
        for (WfRunTask item : list) {
            result.put(item.getFlowCode(), item);
        }
        return result;
    }
 
    // 弃用
    public Map<String, Integer> getPlanFlowStatus(Long bizId) {
        Map<String, Integer> result = new HashMap<>();
        /*
         * List<WfRunTask> list = baseDao.getPLanFlowStatus(bizId); for (WfRunTask item
         * : list) { result.put(item.getFlowCode(), item.getStatus()); }
         */
        return result;
    }
 
    // 准备弃用
    public Map<String, WfRunTask> getPlanFlowStatus2(Long bizId) {
        Map<String, WfRunTask> result = new HashMap<>();
        /*
         * List<WfRunTask> list = baseDao.getPLanFlowStatus(bizId); for (WfRunTask item
         * : list) { if ("planFlow".equals(item.getFlowCode()))
         * result.put("gcjd_plan_tybx", item); else if
         * ("sgmxFlow".equals(item.getFlowCode())) result.put("gcjd_sgmx_bb", item);
         * else if ("sgqdFlow".equals(item.getFlowCode())) result.put("gcjd_sgqd_cz",
         * item); else if ("gckyFlow".equals(item.getFlowCode()))
         * result.put("gcjd_gcky_bb", item); else if
         * ("gywjFlow".equals(item.getFlowCode())) result.put("gcjd_gywj_sc", item);
         * else if ("jzjFlow".equals(item.getFlowCode())) result.put("gcjd_jzj_bb",
         * item); else if ("wltFlow".equals(item.getFlowCode()))
         * result.put("gcjd_wlt_pz", item); else if
         * ("wxsbFlow".equals(item.getFlowCode())) result.put("gcjd_wxsb_wxsb", item);
         * else if ("jsfaFlow".equals(item.getFlowCode())) result.put("gcjd_jsfa_sc",
         * item); else if ("yxscFlow".equals(item.getFlowCode()))
         * result.put("gcjd_yxsc_bb", item); }
         */
        return result;
    }
 
    public Map<String, WfRunTask> getPhaseFlowStatus(String wfIdCode, Long bizId) {
        Map<String, WfRunTask> result = new HashMap<>();
        List<WfRunTask> list = baseDao.getPhaseFlowStatus(wfIdCode, bizId);
        for (WfRunTask item : list) {
            result.put(item.getFlowCode(), item);
        }
        return result;
    }
 
    public Boolean getFlowStepFinish(String wfIdCode, Long bizId, String stepIdMark) {
        Integer finishNum = baseDao.getFlowStepFinish(wfIdCode, bizId, stepIdMark);
        if (finishNum > 0)
            return false;
        else
            return true;
    }
 
    public Boolean getFlowStepFinish2(String wfIdCode, Long bizId, String stepIdMark) {
        Integer finishNum = baseDao.getFlowStepFinish2(wfIdCode, bizId, stepIdMark);
        if (finishNum > 0)
            return true;
        else
            return false;
    }
 
    public Boolean isMyStepFinish(String wfIdCode, Long bizId, String stepIdMark) {
        Integer finishNum = baseDao.isMyStepFinish(wfIdCode, bizId, stepIdMark, UserContext.getUser().getId());
        if (finishNum > 0) {
            // 我的完成了
            return true;
        } else {
            // 我的未完成了
            return false;
        }
    }
 
    /*
     * myStatus 0: 不是我的步骤 1: 是我的步骤,当前正需要我执行 2:其他情况 5:步骤执行过了
     */
    public WfRunTask getFlowStepStatus(String wfIdCode, Long bizId, String stepIdMark) {
        WfRunTask result = null;
        WfDefStep requestStep = this.queryWfDefStep(wfIdCode, stepIdMark);
        if (requestStep != null) {
            List<WfRunTask> list = baseDao.getFlowStepStatus(wfIdCode, bizId);
            if (list.size() > 0) {
                result = list.get(0);
                result.setMyStatus(0);
                WfDefStep currentStep = this.queryWfDefStep(wfIdCode, list.get(0).getStepMarker());
                Integer myStep = baseDao.isMyStep(wfIdCode, bizId, requestStep.getStepMarker(),
                        UserContext.getUser().getId());
                if (myStep > 0)
                    result.setMyStatus(1);
                else if (currentStep.getStepNo() > requestStep.getStepNo()) {
                    result.setMyStatus(5); // 执行过了
                } else if (currentStep.getStepNo() == requestStep.getStepNo()) {
                    result.setMyStatus(2);
                }
            }
        }
        return result;
    }
 
    public WfRunTask getFlowStepStatus2(String wfIdCode, Long bizId, String stepIdMark) {
        List<WfRunTask> list = baseDao.getFlowStepStatus(wfIdCode, bizId);
        WfRunTask result = null;
        if (list.size() > 0) {
            result = list.get(0);
            result.setMyStatus(0);
            if (result.getStatus() == 0 || result.getStatus() == 1) {
                Integer myStep = baseDao.isMyStep(wfIdCode, bizId, result.getStepMarker(),
                        UserContext.getUser().getId());
                if (myStep > 0)
                    result.setMyStatus(1);
                else
                    result.setMyStatus(2);
            }
        }
        return result;
    }
 
    public List<Map<String, Object>> getStepCount(String wfIdCode, Long bizId) {
        List<WfRunTask> list = baseDao.getStepCount(wfIdCode, bizId);
        List<Map<String, Object>> result = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("name", "数量");
        for (WfRunTask item : list) {
            map.put(item.getStepMarker(), item.getStatus());
        }
        result.add(map);
        return result;
    }
 
    public Boolean hasExistFlow(String wfIdCode, Long bizId) {
        Integer num = baseDao.getBizTaskCount(wfIdCode, bizId);
        return num > 0 ? true : false;
    }
 
    public String recallFlow(String wfIdCode, Long bizId, String stepMarker, Long taskId, Long taskPrevId) {
        WfRunTask task = getFlowStepStatus(wfIdCode, bizId, stepMarker);
        if (task != null) {
            if (task.getStatus() == 0 || task.getStatus() == 1) {
                if (localServer.equals(task.getStepSite()) || localServer.equals("yjs") || task.getHasOut() == 0) {
                    baseDao.setTaskRecall(taskId, wfIdCode);
                    WfRunTask task2 = baseDao.selectById(taskId);
                    if (task2 != null) {
                        Long stepId = task2.getStepId();
                        WfDefStep wfDefStep = workflowConfigService.get(stepId);
                        this.refuseExecSql(wfDefStep, bizId);
                    }
                    return "OK";
                } else {
                    return "已经导出到其他服务器执行,不能撤回了";
                }
            }
        }
        return "任务已经执行完毕,不能撤回了";
    }
 
    public void refuseExecSql(WfDefStep wfDefStep, Long bizId) {
        if (wfDefStep != null) {
            String sqlStr = wfDefStep.getRecallSql();
            if (StringUtils.isNotEmpty(sqlStr)) {
                sqlStr = sqlStr.replace("${bizId}", bizId.toString());
                baseDao.exeSql(sqlStr);
            }
        }
    }
 
    public Map<String, Map<String, String>> getAllSteps() {
        Map<String, String> bean = new HashMap<>();
        bean.put("status", "");
        bean.put("receiveName", "");
        Map<String, Map<String, String>> result = new HashMap<>();
        List<String> list = wfDefStepDao.getAllSteps();
        for (String item : list) {
            result.put(item, bean);
        }
        return result;
    }
 
    public List<WfRunTask> getConnectInformation(String oldShipTeam) {
        return baseDao.getConnectInformation(oldShipTeam);
    }
 
    public void updateConnect(String oldShipTeam) {
        baseDao.updateConnect(oldShipTeam);
    }
 
    public List<WfRunTask> getFlowTrack(String flowCode, Long bizId) {
        List<WfRunTask> flowTrack = baseDao.getFlowTrack(flowCode, bizId);
        return flowTrack;
    }
 
    public String getFlowStepName(String wfIdCodes, Long bizId) {
        return baseDao.getFlowStepName(wfIdCodes, bizId);
    }
 
    public void deleteFlowStep(String wfIdCode, String stepIdMark, Long bizId){
        baseDao.deleteFlowStep(wfIdCode,stepIdMark,bizId);
    }
 
    public void getRunFlow(List<? extends BusiEntity> dataList, String flowCode) {
        List<Long> ids = dataList.stream().map(f -> f.getId()).collect(Collectors.toList());
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("bizIds", ids);
        params.put("flowCode", flowCode);
        List<FlowInfo> list = baseDao.getRunFlow(params);
        for (BaseEntity item : dataList) {
            List<FlowInfo> list2 = list.stream().filter(item2->item2.getBizId().equals(item.getId())).collect(Collectors.toList());
            if (list2.size()>0) {
                item.setFlowInfo(list2.get(0));
            }else{
                item.setFlowInfo(new FlowInfo());
            }
        }
    }
}