DefController.java
51.9 KB
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
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
package com.hotent.bpmModel.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.hotent.base.annotation.ApiGroup;
import com.hotent.base.annotation.AvoidRepeatableCommit;
import com.hotent.base.constants.ApiGroupConsts;
import com.hotent.base.constants.SQLConst;
import com.hotent.base.controller.BaseController;
import com.hotent.base.exception.BaseException;
import com.hotent.base.feign.FormFeignService;
import com.hotent.base.model.CommonResult;
import com.hotent.base.model.ImportCheckResult;
import com.hotent.base.query.FieldRelation;
import com.hotent.base.query.PageList;
import com.hotent.base.query.QueryFilter;
import com.hotent.base.query.QueryOP;
import com.hotent.base.util.*;
import com.hotent.base.util.time.DateFormatUtil;
import com.hotent.bpm.api.constant.NodeType;
import com.hotent.bpm.api.constant.ScriptType;
import com.hotent.bpm.api.model.process.def.BpmDefExtProperties;
import com.hotent.bpm.api.model.process.def.BpmDefinition;
import com.hotent.bpm.api.model.process.def.BpmProcessDef;
import com.hotent.bpm.api.model.process.def.BpmProcessDefExt;
import com.hotent.bpm.api.model.process.nodedef.BpmNodeDef;
import com.hotent.bpm.api.model.process.nodedef.BpmNodeDefComparator;
import com.hotent.bpm.api.model.process.nodedef.ext.UserTaskNodeDef;
import com.hotent.bpm.api.model.process.nodedef.ext.extmodel.Button;
import com.hotent.bpm.api.plugin.core.context.PluginParse;
import com.hotent.bpm.api.service.BpmDefinitionAccessor;
import com.hotent.bpm.api.service.BpmDefinitionService;
import com.hotent.bpm.engine.def.impl.handler.ButtonsBpmDefXmlHandler;
import com.hotent.bpm.model.def.BpmDefXmlList;
import com.hotent.bpm.params.SearchDefNodeVO;
import com.hotent.bpm.persistence.manager.BpmDefAuthorizeManager;
import com.hotent.bpm.persistence.manager.BpmDefinitionManager;
import com.hotent.bpm.persistence.model.BpmDefAuthorizeType;
import com.hotent.bpm.persistence.model.DefaultBpmDefinition;
import com.hotent.bpm.plugin.task.userassign.context.UserAssignPluginContext;
import com.hotent.bpmModel.manager.BpmDefService;
import com.hotent.bpmModel.manager.BpmDefTransform;
import com.hotent.bpmModel.manager.BpmOftenFlowManager;
import com.hotent.bpmModel.params.*;
import com.hotent.uc.api.impl.util.ContextUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.http.client.ClientProtocolException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* 描述:流程定义管理
* @company 广州宏天软件有限公司
* @author wanghb
* @email wanghb@jee-soft.cn
* @date 2018年6月26日
*/
@RestController
@RequestMapping("/flow/def/v1/")
@Api(tags="流程定义")
@ApiGroup(group= {ApiGroupConsts.GROUP_BPM})
public class DefController extends BaseController<BpmDefinitionManager, DefaultBpmDefinition> {
@Resource
BpmDefinitionManager bpmDefinitionManager;
@Resource
BpmDefinitionService bpmDefinitionService;
@Resource
BpmDefinitionAccessor bpmDefinitionAccessor;
@Resource
BpmDefAuthorizeManager bpmDefAuthorizeManager;
@Resource
BpmDefTransform bpmDefTransform;
@Resource
ButtonsBpmDefXmlHandler buttonsBpmDefXmlHandler;
@Autowired
private BpmOftenFlowManager bpmOftenFlowManager;
@Autowired
private BpmDefService bpmDefService;
@SuppressWarnings("unused")
private final static String ROOT_PATH = "attachFiles" + File.separator + "tempZip"; // 导入和导出的文件操作根目录
/**
* 返回流程设计生成的BPMNxml
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value="bpmnXml",method=RequestMethod.GET, produces={"application/xml; charset=UTF-8"})
@ApiOperation(value = "返回流程设计生成的BPMNxml", httpMethod = "GET", notes = "返回流程设计生成的BPMNxml")
public Object bpmnXml(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception {
if (StringUtils.isEmpty(defId)) {
return "no def input";
}
DefaultBpmDefinition po = bpmDefinitionManager.getById(defId);
String bpmnXml = po.getBpmnXml();
return bpmnXml;
}
/**
* 返回流程设计的xml
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value="designXml",method=RequestMethod.GET, produces={"application/xml; charset=UTF-8"})
@ApiOperation(value = "返回流程设计的xml", httpMethod = "GET", notes = "返回流程设计的xml")
public Object designXml(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception {
if (StringUtils.isEmpty(defId)) {
return "no def input";
}
DefaultBpmDefinition po = bpmDefinitionManager.getById(defId);
String bpmnXml = po.getDefXml();
return bpmnXml;
}
@RequestMapping(value="getJson",method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "根据流程定义Key获取流程定义对象", httpMethod = "GET", notes = "根据流程定义Key获取流程定义对象")
public DefaultBpmDefinition getJson(@ApiParam(name="defKey",value="流程定义Key", required = true) @RequestParam String defKey){
DefaultBpmDefinition po = bpmDefinitionManager.getMainByDefKey(defKey);
if (po != null) {
po.setBpmnXml("");
}
return po;
}
/**
* 通过h5来设计一个流程
* @param request
* @param response
* @throws IOException
* @throws ClientProtocolException
*/
@RequestMapping(value="webDefDesign",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "返回流程设计的xml", httpMethod = "GET", notes = "返回流程设计的xml")
public Object webDefDesign(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception {
Map<String,Object> map=bpmDefinitionManager.webDefDesign(defId);
return map;
}
/**
* web流程设计器保存
* @param request
* @param response
* @throws Exception
*/
@RequestMapping(value="webDefSave",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "web流程设计器保存", httpMethod = "POST", notes = "web流程设计器保存")
public CommonResult<String> webDefSave(
@ApiParam(name="bpmDefinitionVo",value="保存流程对象", required = true) @RequestBody DefaultBpmDefinitionVo bpmDefinitionVo) throws Exception{
//Ocacle数据库的一个汉字为3个字节,字段大小是64,也就是不能超过21.
String dbType = SQLUtil.getDbType();
if (dbType.equals(SQLConst.DB_ORACLE) && StringUtils.isNotEmpty(bpmDefinitionVo.getDefaultBpmDefinition().getName())){
int length = bpmDefinitionVo.getDefaultBpmDefinition().getName().length();
if(length > 21) return new CommonResult<String>(false,"流程名称长度不能超过21!","");
}
CommonResult<String> res=bpmOftenFlowManager.webDefSave(bpmDefinitionVo);
return res;
}
/**
* flex,保存发布流程信息。
*
* @param
* @param
* @return ModelAndView
* @throws Exception
*/
@RequestMapping(value="flexDefSave",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "flex流程设计器保存", httpMethod = "POST", notes = "flex流程设计器保存")
public CommonResult<String> flexDefSave(
@ApiParam(name="bpmDefinitionVo",value="保存流程对象", required = true) @RequestBody DefaultBpmDefinitionVo bpmDefinitionVo) throws Exception {
CommonResult<String> res=bpmDefService.flexDefSave(bpmDefinitionVo);
return res;
}
/**
* 流程定义列表(分页条件查询)数据
*
* @param request
* @param reponse
* @return
* @throws Exception
* PageJson
*/
@RequestMapping(value="listJson", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "流程定义列表(分页条件查询)数据", httpMethod = "POST", notes = "流程定义列表(分页条件查询)数据")
public PageList<DefaultBpmDefinition> listJson(@ApiParam(name="queryFilter",value="通用查询对象")@RequestBody QueryFilter<DefaultBpmDefinition> queryFilter) throws Exception {
// 查询列表
PageList<DefaultBpmDefinition> bpmDefinitionList = bpmDefinitionManager.queryList(queryFilter);
return bpmDefinitionList;
}
/**
* 绑定指定表单的流程定义列表(分页条件查询)数据
*
* @param request
* @param reponse
* @return
* @throws Exception
* PageJson
*/
@RequestMapping(value="formDeflist", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "绑定指定表单的流程定义列表(分页条件查询)数据", httpMethod = "POST", notes = "流程定义列表(分页条件查询)数据")
public PageList<DefaultBpmDefinition> formDeflist(@ApiParam(name="boCode",value="boCode",required=true)@RequestParam String boCode,
@ApiParam(name="formKey",value="formKey",required=true)@RequestParam String formKey,
@ApiParam(name="queryFilter",value="通用查询对象") @RequestBody QueryFilter<DefaultBpmDefinition> queryFilter) throws Exception {
PageList<DefaultBpmDefinition> pageList=bpmDefService.formDeflist(boCode,formKey,queryFilter);
return pageList;
}
/**
* 流程定义分类id查询数据
*
* @param request
* @param reponse
* @return
* @throws Exception
* PageJson
*/
@RequestMapping(value="getByTypeId", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "流程定义分类id查询数据", httpMethod = "GET", notes = "流程定义分类id查询数据")
public PageList<DefaultBpmDefinition> getByTypeId(@ApiParam(name="typeId",value="分类id")@RequestParam String typeId) throws Exception {
QueryFilter<DefaultBpmDefinition> queryFilter =QueryFilter.build();
queryFilter.addFilter("is_main_", "Y", QueryOP.EQUAL);
queryFilter.addFilter("type_id_", typeId, QueryOP.EQUAL);
return bpmDefinitionManager.queryList(queryFilter);
}
/**
* 根据流程定义id获取流程信息
*
* @param request
* @param response
* @return
* @throws Exception
* ModelAndView
*/
@RequestMapping(value="defGet",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "根据流程定义id获取流程信息", httpMethod = "GET", notes = "根据流程定义id获取流程信息")
public DefaultBpmDefinition defGet(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception {
DefaultBpmDefinition bpmDefinition = null;
if (StringUtil.isNotEmpty(defId)) {
bpmDefinition = bpmDefinitionManager.getById(defId);
}
return bpmDefinition;
}
@RequestMapping(value = "getDefDesignByDefId",method = RequestMethod.GET,produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "根据流程定义id获取流程的最基本信息,返回的内容不含xml", httpMethod = "GET", notes = "根据流程定义id获取流程信息")
public CommonResult getDefDesignByDefId(@RequestParam(value = "defId")String defId){
DefaultBpmDefinition definition = bpmDefService.getDefDesignByDefId(defId);
if (definition!=null){
return CommonResult.ok().value(definition);
}
return CommonResult.error().message("该流程不存在");
}
/**
* 流程图
*
* @param request
* @param response
* @throws Exception
*/
@RequestMapping(value="image",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "获取流程图", httpMethod = "GET", notes = "获取流程图")
public void image(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId,
@ApiParam(name="bpmnInstId",value="bpmn实例id", required = false) @RequestParam String bpmnInstId,
@ApiParam(name="taskId",value="任务idid", required = false) @RequestParam String taskId,
HttpServletResponse response) throws Exception {
bpmDefinitionManager.image(defId,bpmnInstId,taskId,response);
}
/**
* 保存流程定义。
*
* @param bpmVo
* @throws Exception
* void
*/
@RequestMapping(value="save",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "保存流程定义。", httpMethod = "POST", notes = "保存流程定义。")
public Object save(
@ApiParam(name="bpmVo",value="流程保存对象", required = true) @RequestParam DefaultBpmDefinitionVo bpmVo) throws Exception {
Object res=bpmDefService.save(bpmVo);
return res;
}
/**
* 批量删除流程定义
* <pre>
* 这个方法是通过流程定义ID删除
* </pre>
* @param request
* @param response
* @throws Exception
* void
*/
@RequestMapping(value="removeByDefIds",method=RequestMethod.DELETE, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "批量删除流程定义", httpMethod = "DELETE", notes = "批量删除流程定义")
public CommonResult<String> removeByDefIds(
@ApiParam(name="ids",value="流程定义id字符串", required = true) @RequestParam String ids,
@ApiParam(name="cascade",value="是否级联删除该流程所有版本", required = true) @RequestParam Optional<Boolean> cascade,
@ApiParam(name="isVersion",value="是否是从版本管理删除", required = true) @RequestParam Optional<Boolean> isVersion) throws Exception {
try{
String[] aryIds = ids.split(",");
bpmDefinitionManager.removeDefIds(cascade.orElse(false), isVersion.orElse(false),aryIds);
return new CommonResult<String>(true,"删除流程定义成功!","");
} catch (Exception e) {
String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e);
return new CommonResult<String>(false,"删除流程定义失败:" + rootCauseMessage,"");
}
}
@RequestMapping(value="physicsRemoveAllVersionByIds",method=RequestMethod.DELETE, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "根据流程定义id,物理删除所有版本的流程相关数据", httpMethod = "DELETE", notes = "根据流程定义id,物理删除所有版本的流程相关数据")
public CommonResult<String> physicsRemoveAllVersionByIds(
@ApiParam(name="ids",value="流程定义id字符串", required = true) @RequestParam String ids) throws Exception {
try{
bpmDefinitionManager.physicsRemoveAllVersionByIds(ids);
return new CommonResult<String>(true,"删除流程定义成功!","");
} catch (Exception e) {
String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e);
return new CommonResult<String>(false,"删除流程定义失败:" + rootCauseMessage,"");
}
}
/**
* 保存流程设置的BO设置
*
* <pre>
* 1.保存BO设定。
* 2.保存表单初始化数据。
*
* {
* "formInitItems": [
* {
* "nodeId": "userTask1",
* "parentDefKey": "qingjia",
* "saveFieldsSetting": [
* {
* "boDefCode": "code1",
* "fieldDesc": "描述",
* "setting": "return \"1\";"
* }
* ],
* "showFieldsSetting": [
* {
* "boDefCode": "code1",
* "fieldDesc": "描述",
* "setting": "return \"1\";"
* }
* ]
* },
* {
* "nodeId": "userTask1",
* "parentDefKey": "local",
* "saveFieldsSetting": [
* {
* "boDefCode": "code1",
* "fieldDesc": "描述",
* "setting": "return \"1\";"
* }
* ],
* "showFieldsSetting": [
* {
* "boDefCode": "code1",
* "fieldDesc": "描述",
* "setting": "return \"1\";"
* }
* ]
* }
* ],
* bodef:{"boSaveMode":"db","boDefs":[{"required":false,"key":"bbb","name":"a"}]}
* }
*
* </pre>
*
* @param request
* @param reponse
* @return
* @throws Exception
* ResultMessage
*/
@RequestMapping(value="saveSetBos",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "保存流程设置的BO设置", httpMethod = "POST", notes = "保存流程设置的BO设置")
public CommonResult<String> saveSetBos(
@ApiParam(name="defBoSetVo",value="流程bo设置对象", required = true) @RequestBody DefBoSetVo defBoSetVo) throws Exception {
CommonResult<String> res=bpmDefService.saveSetBos(defBoSetVo);
return res;
}
/**
* 在流程在线设计中获取分类的所有流程列表。
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value="getFlowListByTypeId",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "保存代理信息", httpMethod = "GET", notes = "保存代理信息")
public void getFlowListByTypeId(
@ApiParam(name="typeId",value="分类id", required = true) @RequestParam String typeId,
@ApiParam(name="word",value="查询关键字", required = true) @RequestParam String word,
HttpServletResponse response) throws Exception {
bpmDefService.getFlowListByTypeId(typeId,word,response);
}
/**
* 流程在线设计,根据defId获取流程对应的详细信息
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value="flexGet",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "流程在线设计,根据defId获取流程对应的详细信息", httpMethod = "GET", notes = "流程在线设计,根据defId获取流程对应的详细信息")
public void flexGet(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId, HttpServletResponse response) throws Exception {
bpmDefService.flexGet(defId,response);
}
/**
* 获取流程其他属性的参数。
*
* @param request
* @param response
* @return
* @throws Exception
* BpmDefExtProperties
*/
@RequestMapping(value="getOtherParam",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "获取流程其他属性的参数", httpMethod = "GET", notes = "获取流程其他属性的参数")
public Map<String, Object> getOtherParam(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception {
Map<String, Object> map =bpmDefService.getOtherParam(defId);
return map;
}
/**
* 保存流程的其他属性。 注意:这里有几个操作没有使用事务。
*
* @param request
* @param response
* @throws Exception
* void
*/
@RequestMapping(value="saveProp",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "获取流程其他属性的参数", httpMethod = "POST", notes = "获取流程其他属性的参数")
public CommonResult<String> saveProp(
@ApiParam(name="defPropVo",value="流程其他参数保存对象", required = true) @RequestBody DefPropSaveVo defPropVo) throws Exception {
CommonResult<String> res=bpmDefService.saveProp(defPropVo);
return res;
}
@RequestMapping(value="nodeBos",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "展示流程节点BO设置", httpMethod = "GET", notes = "获取流程其他属性的参数")
public Object nodeBos(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId,
@ApiParam(name="topDefKey",value="流程定义key", required = true) @RequestParam String topDefKey) throws Exception {
Object res=bpmDefService.nodeBos(defId,topDefKey);
return res;
}
@RequestMapping(value="exportXml" ,method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "导出流程定义xml", httpMethod = "GET", notes = "导出流程定义xml")
public void exportXml( HttpServletRequest request, HttpServletResponse response,
@ApiParam(name="bpmDefId",value="流程定义id", required = true) @RequestParam String bpmDefId) throws Exception {
response.setContentType("APPLICATION/OCTET-STREAM");
if (BeanUtils.isNotEmpty(bpmDefId)) {
String[] bpmDefIds = bpmDefId.split(",");
List<String> defList = bpmDefinitionService.getExternalSubprocess(Arrays.asList(bpmDefIds));
String zipName = "";
String fullname = ContextUtil.getCurrentUser().getFullname();
if(defList.size() == 1){
DefaultBpmDefinition bpmDefinition = baseService.get(defList.get(0));
zipName = String.format("流程导出_%s(%s)_%s%s",bpmDefinition.getName(),bpmDefinition.getDefKey(),fullname,DateFormatUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss"));
//防止文件名过长问题
if(zipName.length()>123){
zipName = zipName.substring(0,120)+"...";
}
}else {
zipName = String.format("批量流程导出文件_%s%s",fullname,DateFormatUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss"));
}
// 写XML
Map<String, String> strXml = bpmDefTransform.exportDef(defList);
HttpUtil.downLoadFile(request, response, strXml,zipName);
}
}
@RequestMapping(value="exportData" ,method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "导出流程定义xml", httpMethod = "GET", notes = "导出流程定义xml")
public Map<String, String> exportData(@ApiParam(name="bpmDefId",value="流程定义id", required = true) @RequestParam String ...ids) throws Exception {
List<String> defList = bpmDefinitionService.getExternalSubprocess(Arrays.asList(ids));
return bpmDefTransform.exportDef(defList);
}
@RequestMapping(value="importData" ,method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "导出流程定义xml", httpMethod = "POST", notes = "导出流程定义xml")
public CommonResult<Map<String, String>> importData(@RequestBody Map<String, Object> param,
@RequestParam(value = "typeId", required = false) Optional<String> typeId) throws JAXBException, UnsupportedEncodingException {
String bpmdefsXml = param.getOrDefault("bpmdefs.flow.xml", "").toString();
String formXmlStr = param.getOrDefault("form.xml", "").toString();
String boXmlStr = param.getOrDefault("bo.xml", "").toString();
String formRightsXml = param.getOrDefault("formrights.xml", "").toString();
ObjectNode obj = JsonUtil.getMapper().createObjectNode();
obj.put("bpmdefsXml", bpmdefsXml);
obj.put("formXmlStr", formXmlStr);
obj.put("boXmlStr", boXmlStr);
obj.put("formRightsXml", formRightsXml);
ThreadMsgUtil.addMapMsg("notNeedTransaction", "true");
CommonResult<String> result = bpmDefTransform.importDef(obj, typeId.orElse("6"), true);
if (!result.getState()) {
return new CommonResult<>(false, result.getMessage());
}
Map<String, String> map = new HashMap<>();
BpmDefXmlList defList = (BpmDefXmlList) JAXBUtil.unmarshall(bpmdefsXml, BpmDefXmlList.class);
if (BeanUtils.isNotEmpty(defList.getBpmList())) {
List<String> alias = defList.getBpmList().stream().map(item -> item.getBpmDefinition().getDefKey()).collect(Collectors.toList());
map = bpmDefinitionManager.list(Wrappers.<DefaultBpmDefinition>lambdaQuery().in(DefaultBpmDefinition::getDefKey, alias))
.stream()
.collect(Collectors.toMap(DefaultBpmDefinition::getDefKey, DefaultBpmDefinition::getId, (k1, k2) -> k1));
}
return new CommonResult<>(true, "导入成功", map);
}
@RequestMapping(value = "importCheck1", method = RequestMethod.POST)
List<ImportCheckResult> importFlowCheck(@RequestBody Map<String, Object> param) throws Exception {
return bpmDefService.importFlowCheck(param);
}
@RequestMapping(value="importSave", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "流程导入,根据传入的文件id从缓存中取出xml文件导入,并清除缓存", httpMethod = "POST", notes = "附件上传操作")
public Object importSave(@ApiParam(name="confirmImport",value="确认导入",required=false) @RequestParam Optional<Boolean> confirmImport,
@ApiParam(name="typeId",value="表单标识",required=false) @RequestParam Optional<String> typeId,
@ApiParam(name="cacheFileId",value="缓存的流程文件id",required=false) @RequestParam Optional<String> cacheFileId) throws Exception {
CommonResult<String> message = null;
try {
if (confirmImport.orElse(false)) {
String byKey = baseService.getImportFileFromCache(cacheFileId.get());
if(StringUtil.isEmpty(byKey)) {
return new CommonResult<String>(false, "导入失败:上传的文件已从缓存中清除,请重新导入。");
}
ObjectNode objectNode = (ObjectNode) JsonUtil.toJsonNode(byKey);
message = bpmDefTransform.importDef(objectNode,typeId.orElse(""));
}
baseService.delImportFileFromCache(cacheFileId.orElse(""));
} catch (Exception e) {
message = new CommonResult<String>(false, "导入失败:" + ExceptionUtils.getRootCauseMessage(e));
}
return message;
}
@RequestMapping(value="importCheck", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "流程导入前校验,通过校验则直接导入,如有重复流程,则返回流程xml的缓存key,待用户确认覆盖后再次导入", httpMethod = "POST", notes = "流程导入前校验")
public Object importCheck(MultipartHttpServletRequest request, HttpServletResponse response,
@ApiParam(name="typeId",value="表单标识",required=false) @RequestParam Optional<String> typeId) throws Exception {
Object res=bpmDefService.importCheck(request,response,typeId);
return res;
}
/**
* 流程定义历史版本
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value="versions", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "流程定义历史版本", httpMethod = "POST", notes = "流程定义历史版本")
public PageList<DefaultBpmDefinition> versions(
@ApiParam(name="defId",value="流程定义id")@RequestParam String defId,
@ApiParam(name="defKey",value="流程定义key")@RequestParam String defKey,
@ApiParam(name="queryFilter",value="通用查询对象")@RequestBody QueryFilter<DefaultBpmDefinition> queryFilter) throws Exception {
PageList<DefaultBpmDefinition> res=bpmDefinitionManager.versions(defId,defKey,queryFilter);
return res;
}
/**
* 当前版本是否是流程定义最新版本
* @return
*/
@RequestMapping(value = "isLatestVersion", method = RequestMethod.GET, produces = {"application/json; charset=utf-8"})
@ApiOperation(value = "流程定义历史版本", httpMethod = "GET", notes = "流程定义历史版本")
public CommonResult<String> isLatestVersion(
@ApiParam(name = "defId", value = "流程定义id") @RequestParam() String defId) {
return bpmDefinitionManager.isLatestVersion(defId);
}
/**
* 设置历史版本的流程定义为主版本
*
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("switchMainVersion")
@ApiOperation(value = "设置历史版本的流程定义为主版本", httpMethod = "GET", notes = "设置历史版本的流程定义为主版本")
public CommonResult<String> switchMainVersion(@ApiParam(name="defId",value="流程定义id")@RequestParam String defId) throws Exception {
try {
bpmDefinitionService.switchMainVersion(defId);
return new CommonResult<String>(true,"设置成功","");
} catch (Exception e) {
return new CommonResult<String>(false,"设置失败:"+e.getMessage(),"");
}
}
/**
* 设置外部子流程
* **/
@RequestMapping(value="subFlowDetail", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "设置外部子流程", httpMethod = "GET", notes = "设置外部子流程")
public Map<String,Object> subFlowDetail(
@ApiParam(name="defId",value="流程定义id")@RequestParam String defId,
@ApiParam(name="nodeId",value="节点id")@RequestParam String nodeId )throws Exception {
Map<String,Object> res=bpmDefinitionManager.subFlowDetail(defId,nodeId);
return res;
}
/**
* 得到全部节点自定义按钮
*
* @param request
* @param response
* @return
* @throws Exception
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value="getNodeBtns", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "流程代理设置列表(分页条件查询)数据", httpMethod = "POST", notes = "流程代理设置列表(分页条件查询)数据")
public PageList<BpmNodeDef> getNodeBtns(@ApiParam(name="defId",value="流程定义id")@RequestBody String defId) throws Exception {
PageList<BpmNodeDef> res=bpmDefinitionManager.getNodeBtns(defId);
return res;
}
/**
* 得到某个节点自定义按钮
*
* action : 0:获取默认初始化的按钮,1:获取配置的按钮,2:获取默认不初始化的按钮
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value="getNodeSet", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "得到某个节点自定义按钮", httpMethod = "POST", notes = "得到某个节点自定义按钮")
public List<Button> getNodeSet(
@ApiParam(name="defId",value="流程定义id")@RequestParam String defId,
@ApiParam(name="nodeId",value="节点id")@RequestParam String nodeId,
@ApiParam(name="action",value="0:获取默认初始化的按钮,1:获取配置的按钮,2:获取默认不初始化的按钮")@RequestParam int action) throws Exception {
List<Button> res=bpmDefService.getNodeSet(defId,nodeId,action);
return res;
}
/**
* 保存节点的按钮
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value="saveNodeBtns", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "保存节点的按钮", httpMethod = "POST", notes = "保存节点的按钮")
public CommonResult<List<Button>> saveNodeBtns(
@ApiParam(name="btnsVo",value="流程节点按钮对象")@RequestBody DefBtnsSaveVo btnsVo) throws Exception {
try {
String defId = btnsVo.getDefId();
String nodeId =btnsVo.getNodeId();
List<Button> btns =btnsVo.getBtns();
buttonsBpmDefXmlHandler.saveNodeXml(defId, nodeId, btns);
return new CommonResult<List<Button>>(true,"按钮设置成功",btns);
} catch (Exception e) {
return new CommonResult<List<Button>>(false,"按钮设置失败",null);
}
}
/**
* 清除测试状态流程的测试数据
* @throws Exception
*/
@RequestMapping(value="cleanData", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "清除测试状态流程的测试数据", httpMethod = "POST", notes = "清除测试状态流程的测试数据")
public CommonResult<String> cleanData(
@ApiParam(name="defId",value="流程定义id")@RequestParam String defId) throws Exception {
try {
bpmDefinitionService.cleanData(defId);
return new CommonResult<String>(true,"清除数据成功","");
} catch (Exception e) {
e.printStackTrace();
return new CommonResult<String>(false,"清除数据失败:"+e.getMessage(),"");
}
}
/**
* 发布
*
*/
@RequestMapping(value="deploy", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "发布流程定义", httpMethod = "POST", notes = "发布流程定义")
public CommonResult<String> deploy(
@ApiParam(name="defId",value="流程定义id")@RequestParam String defId) throws Exception {
try {
BpmDefinition def = (BpmDefinition) bpmDefinitionService.getBpmDefinitionByDefId(defId);
bpmDefinitionService.deploy(def);
return new CommonResult<String>(true,"发布流程定义成功!","");
} catch (Exception e) {
e.printStackTrace();
return new CommonResult<String>(false,"发布流程定义失败:"+e.getMessage(),"");
}
}
@RequestMapping(value="goRunOrTest", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "批量上线或者测试", httpMethod = "GET", notes = "批量上线或者测试")
public CommonResult<String> goLive(@ApiParam(name="defIds",value="流程定义ids(多个使用,隔开)")@RequestParam String defIds,
@ApiParam(name = "isRun",value = "是否上线,true是上线,false是测试")@RequestParam Boolean isRun) throws Exception {
return bpmDefinitionService.goRunOrTest(defIds,isRun);
}
@RequestMapping(value="getBindRelation", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "获取表单绑定关系。", httpMethod = "GET", notes = "根据组件别名获取所有子实体。")
public Map<String,Object> getBindRelation(@ApiParam(name="defId",value="表单defId")@RequestParam String defId) throws Exception {
return bpmDefinitionManager.getBindRelation(defId);
}
/**
* 节点概要
*
* @param request
* @param response
* @return
* @throws Exception
*/
/*@RequestMapping("nodeSummary")mark
public ModelAndView nodeSummary(HttpServletRequest request, HttpServletResponse response) throws Exception {
String defId = RequestUtil.getString(request, "defId");
// String parentActDefId = RequestUtil.getString(request,
// "parentActDefId", "");
BpmProcessDef<BpmProcessDefExt> bpmProcessDefExt = bpmDefinitionAccessor.getBpmProcessDef(defId);
List<BpmNodeDef> nodeDefList = bpmProcessDefExt.getBpmnNodeDefs();
Map<String, Boolean> startScriptMap = new HashMap<String, Boolean>();
Map<String, Boolean> endScriptMap = new HashMap<String, Boolean>();
Map<String, Boolean> preScriptMap = new HashMap<String, Boolean>();
Map<String, Boolean> afterScriptMap = new HashMap<String, Boolean>();
Map<String, Boolean> assignScriptMap = new HashMap<String, Boolean>();
Map<String, Boolean> nodeRulesMap = new HashMap<String, Boolean>();
Map<String, Boolean> nodeButtonMap = new HashMap<String, Boolean>();
Map<String, Boolean> taskReminderMap = new HashMap<String, Boolean>();
Map<String, Boolean> nodeFormMap = new HashMap<String, Boolean>();
boolean globalFormFlag = false;
DefaultBpmProcessDefExt defExt = (DefaultBpmProcessDefExt) bpmProcessDefExt.getProcessDefExt();
Form globalForm = defExt.getGlobalForm();
if (globalForm != null)
globalFormFlag = true;
Map<String, Boolean> nodeUserMap = new HashMap<String, Boolean>();
for (BpmNodeDef bpmNodeDef : nodeDefList) {
String nodeId = bpmNodeDef.getNodeId();
// 用户设置
this.getNodeUserMap(bpmNodeDef, nodeId, nodeUserMap);
// 流程事件(脚本)
this.getNodeScriptMap(bpmNodeDef, nodeId, startScriptMap, endScriptMap, preScriptMap, afterScriptMap, assignScriptMap);
// 流程节点规则
this.getNodeRulesMap(bpmNodeDef, nodeId, nodeRulesMap);
// 操作按钮
this.getNodeButtonMap(bpmNodeDef, nodeId, nodeButtonMap);
// 催办信息
// this.getTaskReminderMap(bpmNodeDef, nodeId, defId, taskReminderMap);
}
this.orderNodeDefList(nodeDefList);
return this.getAutoView().addObject("bpmDefinition", bpmProcessDefExt).addObject("defId", defId).addObject("nodeDefList", nodeDefList).addObject("startScriptMap", startScriptMap).addObject("endScriptMap", endScriptMap).addObject("preScriptMap", preScriptMap).addObject("afterScriptMap", afterScriptMap).addObject("assignScriptMap", assignScriptMap).addObject("nodeRulesMap", nodeRulesMap).addObject("nodeUserMap", nodeUserMap).addObject("nodeFormMap", nodeFormMap).addObject("nodeButtonMap", nodeButtonMap).addObject("taskReminderMap", taskReminderMap).addObject("globalFormFlag", globalFormFlag);
}*/
/**
* 操作按钮
*
* @param bpmNodeDef
* @param nodeId
* @param nodeButtonMap
*/
@SuppressWarnings("unused")
private void getNodeButtonMap(BpmNodeDef bpmNodeDef, String nodeId, Map<String, Boolean> nodeButtonMap) {
if (BeanUtils.isNotEmpty(bpmNodeDef.getButtons()))
nodeButtonMap.put(nodeId, true);
else
nodeButtonMap.put(nodeId, false);
}
/**
* 流程节点规则
*
* @param bpmNodeDef
* @param nodeId
* @param nodeRulesMap
*/
@SuppressWarnings("unused")
private void getNodeRulesMap(BpmNodeDef bpmNodeDef, String nodeId, Map<String, Boolean> nodeRulesMap) {
if (! (bpmNodeDef instanceof UserTaskNodeDef) ) return ;
UserTaskNodeDef userTaskNodeDef = (UserTaskNodeDef) bpmNodeDef;
if (BeanUtils.isNotEmpty(userTaskNodeDef.getJumpRuleList()))
nodeRulesMap.put(nodeId, true);
else
nodeRulesMap.put(nodeId, false);
}
/**
* 流程事件(脚本)
*
* @param bpmNodeDef
* @param nodeId
* @param startScriptMap
* @param endScriptMap
* @param preScriptMap
* @param afterScriptMap
* @param assignScriptMap
*/
@SuppressWarnings("unused")
private void getNodeScriptMap(BpmNodeDef bpmNodeDef, String nodeId, Map<String, Boolean> startScriptMap, Map<String, Boolean> endScriptMap, Map<String, Boolean> preScriptMap, Map<String, Boolean> afterScriptMap, Map<String, Boolean> assignScriptMap) {
Map<ScriptType, String> scriptMap = bpmNodeDef.getScripts();
for (Map.Entry<ScriptType, String> entry : scriptMap.entrySet()) {
if (StringUtil.isEmpty(entry.getValue())) continue;
switch (entry.getKey()) {
case START:
startScriptMap.put(nodeId, true);
break;
case END:
endScriptMap.put(nodeId, true);
break;
case CREATE:
preScriptMap.put(nodeId, true);
break;
case COMPLETE:
afterScriptMap.put(nodeId, true);
break;
default:
break;
}
}
}
/**
* 节点排序
*
* @param nodeDefList
*/
@SuppressWarnings("unused")
private void orderNodeDefList(List<BpmNodeDef> nodeDefList) {
for (BpmNodeDef bpmNodeDef : nodeDefList) {
if (bpmNodeDef.getType() == NodeType.START)
bpmNodeDef.setOrder(bpmNodeDef.getOrder());
else if (bpmNodeDef.getType() == NodeType.END)
bpmNodeDef.setOrder(bpmNodeDef.getOrder() + 100);
else
bpmNodeDef.setOrder(bpmNodeDef.getOrder() + 1000);
}
// 节点排序
Collections.sort(nodeDefList, new BpmNodeDefComparator());
}
/**
* 设置节点人员
*
* @param bpmNodeDef
* @param nodeId
* @param nodeUserMap
* @throws Exception
* @throws IOException
*/
@SuppressWarnings("unused")
private void getNodeUserMap(BpmNodeDef bpmNodeDef, String nodeId, Map<String, Boolean> nodeUserMap) throws Exception {
// 节点类型是用户节点和会签才有人员设置
if (bpmNodeDef.getType() == NodeType.USERTASK || bpmNodeDef.getType() == NodeType.SIGNTASK) {
PluginParse userPluginContext = (PluginParse) bpmNodeDef.getPluginContext(UserAssignPluginContext.class);
if (userPluginContext != null && userPluginContext.getJson() != null) {
nodeUserMap.put(nodeId, true);
}
}
}
/**
* 初始化所有按钮
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value="initNodeBtn",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "初始化所有按钮", httpMethod = "GET", notes = "初始化所有按钮")
public CommonResult<String> initNodeBtn(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId,
@ApiParam(name="nodeId",value="节点id", required = true) @RequestParam String nodeId) throws Exception {
CommonResult<String> res=bpmDefService.initNodeBtn(defId,nodeId);
return res;
}
@Deprecated
@RequestMapping(value="copyDef",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "复制流程", httpMethod = "GET", notes = "复制流程")
public CommonResult<String> copyDef(
@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId,
@ApiParam(name="name",value="流程名称", required = true) @RequestParam String name,
@ApiParam(name="defKey",value="流程定义key", required = true) @RequestParam String defKey) throws IOException{
BpmDefinition bpmDefinition = (BpmDefinition) bpmDefinitionManager.getMainByDefKey(defKey, false);
if(bpmDefinition!=null){
return new CommonResult<String>(false,"流程key已经存在","");
}
try{
bpmDefinitionManager.copyDef(defId,name,defKey,null, null);
}catch(Exception ex){
return new CommonResult<String>(false,ex.getMessage(),"");
}
return new CommonResult<String>(true,"复制成功","");
}
@PostMapping(value="copy",produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "复制流程", httpMethod = "POST", notes = "复制流程")
@AvoidRepeatableCommit
public CommonResult<String> copyDef(@ApiParam(name="flowInfo",value="流程信息", required = true) @RequestBody CopyFlow flow) throws IOException{
BpmDefinition bpmDefinition = (BpmDefinition) bpmDefinitionManager.getMainByDefKey(flow.getDefKey(), false);
if(bpmDefinition!=null){
return new CommonResult<String>(false,"流程key已经存在","");
}
try{
bpmDefinitionManager.copyDef(flow.getDefId(),flow.getName(),flow.getDefKey(),flow.getTypeId(), flow.getTypeName());
}catch(Exception ex){
return new CommonResult<String>(false,ex.getMessage(),"");
}
return new CommonResult<String>(true,"复制成功","");
}
/**
*根据流程key获取最新的流程定义id
*
* @param request
* @param reponse
* @return
* @throws Exception
*/
@RequestMapping(value="getBpmDefId",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "根据流程key获取最新的流程定义id", httpMethod = "GET", notes = "根据流程key获取最新的流程定义id")
public String getBpmDefId(@ApiParam(name="defKey",value="流程定义key", required = true) @RequestParam String defKey) throws Exception {
List<DefaultBpmDefinition> defs = bpmDefinitionManager.queryByDefKey(defKey);
String defId = "";
if(defs.size()>0 && BeanUtils.isNotEmpty(defs.get(defs.size()-1))) defId= defs.get(defs.size()-1).getDefId();
return defId;
}
/**
*根据流程key获取最新的流程定义id
*
* @param request
* @param reponse
* @return
* @throws Exception
*/
@RequestMapping(value="isBoBindFlowCheck",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "检测bo是否已绑定流程", httpMethod = "GET", notes = "检测bo是否已绑定流程")
public CommonResult<Boolean> isBoBindFlowCheck(@ApiParam(name="boCode",value="bo定义别名", required = true) @RequestParam String boCode,@ApiParam(name="formKey",value="表单key", required = true) @RequestParam String formKey) throws Exception {
CommonResult<Boolean> res=bpmDefService.isBoBindFlowCheck(boCode,formKey);
return res;
}
/**
*根据流程key获取最新的流程定义id
* x
* @param request
* @param reponse
* @return
* @throws Exception
*/
@RequestMapping(value="getBpmdefByDefId",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "根据流程定义id获取流程定义", httpMethod = "GET", notes = "根据流程定义id获取流程定义")
public DefaultBpmDefinition getBpmdefByDefId(@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception {
return bpmDefinitionManager.getById(defId);
}
/**
*根据流程key获取最新的流程定义id
* x
* @param request
* @param reponse
* @return
* @throws Exception
*/
@RequestMapping(value="defSetCategory",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "设置流程分类", httpMethod = "POST", notes = "设置流程分类")
public CommonResult<String> defSetCategory(@ApiParam(name="jNode",value="设置分类参数对象", required = true) @RequestBody ObjectNode jNode) throws Exception {
List<String> defIds = Arrays.asList(jNode.get("defIds").asText().split(","));
String typeName = jNode.get("typeName").asText();
String typeId = jNode.get("typeId").asText();
return bpmDefinitionManager.setDefType(typeName,typeId,defIds);
}
@RequestMapping(value = "bpmDefinitionData",method = RequestMethod.GET)
@ApiOperation(value = "获取流程",httpMethod = "GET",notes = "获取流程")
public List<Map<String, Object>> bpmDefinitionData(String alias){
return bpmDefinitionManager.bpmDefinitionData(alias);
}
/**
* 判断用户是否有启动流程权限
* @return
* @throws IOException
*/
@RequestMapping(value="flowHasStartRights",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "判断用户是否有启动流程权限", httpMethod = "GET", notes = "判断用户是否有启动流程权限")
public CommonResult<Boolean> flowHasStartRights(@ApiParam(required = false, name = "defKey", value = "defKey") @RequestParam String defKey) throws IOException{
ObjectNode reslt = bpmDefAuthorizeManager.getRight(defKey, BpmDefAuthorizeType.BPMDEFAUTHORIZE_RIGHT_TYPE.START);
return new CommonResult<>(true, "",BeanUtils.isNotEmpty(reslt));
}
/**
* 获取流程其他属性的参数。
*
* @param request
* @param response
* @return
* @throws Exception
* BpmDefExtProperties
*/
@RequestMapping(value="getAllowSignet",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "根据流程定义获取是否允许套打印章", httpMethod = "GET", notes = "根据流程定义获取是否允许套打印章")
public CommonResult<Boolean> getAllowSignet(@ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception {
BpmProcessDef<BpmProcessDefExt> procDef = bpmDefinitionAccessor.getBpmProcessDef(defId);
BpmDefExtProperties prop = procDef.getProcessDefExt().getExtProperties();
return new CommonResult<Boolean>(true, "获取成功。", "true".equals(prop.getAllowSignet())?true:false);
}
@PostMapping(value = "getDefNodeUserByTeam", produces = { "application/json; charset=utf-8" })
@ApiOperation("根据任务节点key,(用户账号/名称,组织、角色、岗位编码/名称)获取流转配置任务节点、审批人信息")
public CommonResult<ObjectNode> getDefNodeUserByTeam(
@ApiParam(name = "map", value = "查询条件") @RequestBody SearchDefNodeVO searchDefNodeVO)throws Exception {
return baseService.getAllDefNodeUserByTeam(searchDefNodeVO);
}
@PostMapping(value = "operatingDefSetting", produces = { "application/json; charset=utf-8" })
@ApiOperation("转移、复制流程节点审批配置信息给(用户、组织、角色、岗位)")
public CommonResult<String> operatingDefSetting(
@ApiParam(name = "map", value = "查询条件") @RequestBody Map<String, Object> map)throws Exception {
return baseService.operatingDefSetting(map);
}
@PostMapping(value = "saveDefTags", produces = { "application/json; charset=utf-8" })
@ApiOperation("保存流程定义标签")
public CommonResult<String> saveDefTags(@RequestBody ObjectNode params)throws Exception {
baseService.saveDefTags(params);
return new CommonResult<>(true, "保存成功");
}
@RequestMapping(value = "getMainByDefIdOrKey", method = RequestMethod.GET, produces = {"application/json; charset=utf-8" })
@ApiOperation(value = "根据流程定义Key或者流程定义id获取流程主版本对象", httpMethod = "GET", notes = "根据流程定义Key或者流程定义id获取流程主版本对象")
public DefaultBpmDefinition getMainByDefIdOrKey(
@ApiParam(name = "defId", value = "流程定义id", required = true) @RequestParam Optional<String> defId,
@ApiParam(name = "defKey", value = "流程定义key", required = true) @RequestParam Optional<String> defKey) {
String definitionKey = defKey.orElse("");
if (StringUtil.isEmpty(definitionKey)) {
if (StringUtil.isNotEmpty(defId.orElse(""))) {
DefaultBpmDefinition defaultBpmDefinition = bpmDefinitionManager.get(defId.get());
if (BeanUtils.isEmpty(defaultBpmDefinition)) {
throw new BaseException(String.format("根据流程定义id[%s]未找到流程定义", defId));
}
definitionKey = defaultBpmDefinition.getDefKey();
} else {
throw new BaseException(String.format("根据流程定义key和流程定义id不能都为空", defId));
}
}
DefaultBpmDefinition po = bpmDefinitionManager.getMainByDefKey(definitionKey);
if (BeanUtils.isEmpty(po)) {
throw new BaseException(String.format("根据流程定义key[%s]未找到流程定义", definitionKey));
}
if (po != null) {
po.setBpmnXml("");
}
return po;
}
@RequestMapping(value = "getFlowKeyByDefId", method = RequestMethod.GET, produces = {
"application/json; charset=utf-8" })
@ApiOperation(value = "根据流程defId获取流程flowKey", httpMethod = "GET", notes = "根据流程defId获取流程flowKey")
public CommonResult<String> getFlowKeyByDefId(@RequestParam(value = "defId") String defId) {
DefaultBpmDefinition definition = bpmDefService.getDefDesignByDefId(defId);
if (definition != null) {
return CommonResult.<String>ok().value(definition.getDefKey());
}
return CommonResult.<String>error().message("该流程不存在");
}
@RequestMapping(value = "batchDeleteNode", method = RequestMethod.GET, produces = {
"application/json; charset=utf-8" })
@ApiOperation(value = "删除指定流程的某一个节点", httpMethod = "GET", notes = "删除指定流程的某一个节点")
public HashMap<String, Object> batchDeleteNode(@RequestParam(value = "nodeName") String nodeName,
@RequestParam(value = "defIds") String defIds) throws Exception {
return baseService.batchDeleteNode(nodeName,defIds);
}
@RequestMapping(value = "batchAddNode", method = RequestMethod.POST, produces = {
"application/json; charset=utf-8" })
@ApiOperation(value = "批量添加节点", httpMethod = "POST", notes = "批量添加节点")
public HashMap<String, Object> batchAddNode(@RequestBody HashMap<String, Object> parmter) throws Exception {
return baseService.batchAddNode(parmter);
}
@RequestMapping(value="webDefDesignByDefKey",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "根据defkey返回流程设计的xml", httpMethod = "GET", notes = "根据defkey返回流程设计的xml")
public Object webDefDesignByDefKey(
@ApiParam(name="defKey",value="流程定义key", required = true) @RequestParam String defKey) throws ClientProtocolException, IOException{
Map<String,Object> map=bpmDefinitionManager.webDefDesignByDefKey(defKey);
return map;
}
@RequestMapping(value="physicsRemoveAllVersionByKey",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "根据流程定义key,物理删除所有版本的流程相关数据", httpMethod = "POST", notes = "根据流程定义key,物理删除所有版本的流程相关数据")
public CommonResult<String> physicsRemoveAllVersionByKey(
@RequestBody List<String> keys) throws Exception {
try{
bpmDefinitionManager.physicsRemoveAllVersionByKey(keys);
return new CommonResult<String>(true,"删除流程定义成功!","");
} catch (Exception e) {
String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e);
return new CommonResult<String>(false,"删除流程定义失败:" + rootCauseMessage,"");
}
}
@RequestMapping(value="checkDefKey",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "校验流程定义是否存在", httpMethod = "GET", notes = "校验流程定义是否存在")
public CommonResult<Boolean> checkDefKey(@ApiParam(name="defKey",value="流程定义key", required = true)@RequestParam String defKey) throws Exception {
List<DefaultBpmDefinition> definitions = bpmDefinitionManager.queryByDefKey(defKey);
return CommonResult.success(BeanUtils.isNotEmpty(definitions));
}
}