InstanceController.java 92.4 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 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577
package com.hotent.runtime.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.hotent.base.query.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
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.context.BaseContext;
import com.hotent.base.controller.BaseController;
import com.hotent.base.exception.BaseException;
import com.hotent.base.model.CommonResult;
import com.hotent.base.util.BeanUtils;
import com.hotent.base.util.SQLUtil;
import com.hotent.base.util.StringUtil;
import com.hotent.base.util.ThreadMsgUtil;
import com.hotent.bpm.api.constant.BpmConstants;
import com.hotent.bpm.api.model.form.FormType;
import com.hotent.bpm.api.model.process.def.BpmDefExtProperties;
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.inst.BpmInstanceTrack;
import com.hotent.bpm.api.model.process.inst.BpmProcessInstance;
import com.hotent.bpm.api.model.process.nodedef.BpmNodeDef;
import com.hotent.bpm.api.model.process.nodedef.BpmNodeForm;
import com.hotent.bpm.api.model.process.task.BpmTaskOpinion;
import com.hotent.bpm.api.service.BoDataService;
import com.hotent.bpm.api.service.BoSubDataHandlers;
import com.hotent.bpm.api.service.BpmDefinitionAccessor;
import com.hotent.bpm.api.service.BpmFormService;
import com.hotent.bpm.api.service.BpmIdentityService;
import com.hotent.bpm.api.service.BpmInstService;
import com.hotent.bpm.api.service.BpmOpinionService;
import com.hotent.bpm.engine.form.BpmFormFactory;
import com.hotent.bpm.engine.inst.DefaultProcessInstCmd;
import com.hotent.bpm.model.form.FormCategory;
import com.hotent.bpm.model.form.FormModel;
import com.hotent.bpm.params.PreviewProcessVo;
import com.hotent.bpm.persistence.manager.BpmBusLinkManager;
import com.hotent.bpm.persistence.manager.BpmCheckOpinionManager;
import com.hotent.bpm.persistence.manager.BpmCptoReceiverManager;
import com.hotent.bpm.persistence.manager.BpmDefinitionManager;
import com.hotent.bpm.persistence.manager.BpmExeStackManager;
import com.hotent.bpm.persistence.manager.BpmProcessInstanceManager;
import com.hotent.bpm.persistence.manager.BpmReadRecordManager;
import com.hotent.bpm.persistence.manager.BpmTaskManager;
import com.hotent.bpm.persistence.manager.BpmTaskTurnManager;
import com.hotent.bpm.persistence.manager.BpmTaskUrgentManager;
import com.hotent.bpm.persistence.manager.PreviewProcessService;
import com.hotent.bpm.persistence.model.BpmBusLink;
import com.hotent.bpm.persistence.model.BpmCptoReceiver;
import com.hotent.bpm.persistence.model.BpmIdentityResult;
import com.hotent.bpm.persistence.model.BpmInstDeleteLog;
import com.hotent.bpm.persistence.model.BpmReadRecord;
import com.hotent.bpm.persistence.model.BpmTaskUrgent;
import com.hotent.bpm.persistence.model.CopyTo;
import com.hotent.bpm.persistence.model.DefaultBpmCheckOpinion;
import com.hotent.bpm.persistence.model.DefaultBpmDefinition;
import com.hotent.bpm.persistence.model.DefaultBpmProcessInstance;
import com.hotent.bpm.persistence.model.DefaultBpmTask;
import com.hotent.bpm.persistence.model.ResultMessage;
import com.hotent.bpm.persistence.model.TaskTurnAssign;
import com.hotent.bpm.util.BoDataUtil;
import com.hotent.bpm.util.BpmUtil;
import com.hotent.runtime.annotation.PermissionCheck;
import com.hotent.runtime.manager.IFlowManager;
import com.hotent.runtime.manager.IProcessManager;
import com.hotent.runtime.manager.InstanceService;
import com.hotent.runtime.manager.PreviewProcessManager;
import com.hotent.runtime.model.RelatedInformation;
import com.hotent.runtime.params.BpmCheckOpinionVo;
import com.hotent.runtime.params.BpmImageParamObject;
import com.hotent.runtime.params.BpmNodeDefVo;
import com.hotent.runtime.params.CopyToParam;
import com.hotent.runtime.params.CustomSignRevokeParam;
import com.hotent.runtime.params.DataTemplateButtonPermissionVo;
import com.hotent.runtime.params.DoEndParamObject;
import com.hotent.runtime.params.DoNextParamObject;
import com.hotent.runtime.params.FlowImageMobileVo;
import com.hotent.runtime.params.FlowImageVo;
import com.hotent.runtime.params.FormAndBoVo;
import com.hotent.runtime.params.InfoboxVo;
import com.hotent.runtime.params.InstFormAndBoVo;
import com.hotent.runtime.params.NodeStatusVo;
import com.hotent.runtime.params.RevokeParamObject;
import com.hotent.runtime.params.RevokeSignLineParamObject;
import com.hotent.runtime.params.RevokeTransParamObject;
import com.hotent.runtime.params.SelectDestinationVo;
import com.hotent.runtime.params.StartCmdParam;
import com.hotent.runtime.params.StartFlowParamObject;
import com.hotent.runtime.params.StartResult;
import com.hotent.runtime.params.ToCopyToVo;
import com.hotent.runtime.service.RevokeHandler;
import com.hotent.runtime.vo.BpmInstDeleteVo;
import com.hotent.runtime.vo.FlowTypeVo;
import com.hotent.uc.api.impl.util.ContextUtil;
import com.hotent.uc.api.model.IUser;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 流程实例相关接口
 *
 * @company 广州宏天软件股份有限公司
 * @author zhangxianwen
 * @email zhangxw@jee-soft.cn
 * @date 2018年6月28日
 */

@RestController
@RequestMapping("/runtime/instance/v1/")
@Api(tags = "流程实例管理")
@ApiGroup(group= {ApiGroupConsts.GROUP_BPM})
public class InstanceController extends BaseController<BpmProcessInstanceManager,DefaultBpmProcessInstance> {

	@Resource
	IFlowManager iFlowService;
	@Resource
	IProcessManager iProcessService;
	@Resource
    BpmInstService processInstanceService;
	@Resource
    BpmDefinitionAccessor bpmDefinitionAccessor;
	@Resource
	BpmProcessInstanceManager bpmProcessInstanceManager;
	@Resource
    BpmOpinionService bpmOpinionService;
	@Resource
    BpmIdentityService bpmIdentityService;
	@Resource
	BpmTaskTurnManager bpmTaskTurnManager;
	@Resource
	BpmCptoReceiverManager bpmCptoReceiverManager;
	@Resource
	BpmDefinitionManager bpmDefinitionManager;
	@Resource
	BpmBusLinkManager bpmBusLinkManager;
	@Resource
	BoDataService boDataService;
	@Resource
	BpmCheckOpinionManager bpmCheckOpinionManager;
	@Resource
	BpmReadRecordManager bpmReadRecordManager;
	@Resource
	BpmTaskUrgentManager bpmTaskUrgentManager;
    @Resource
    BoSubDataHandlers boSubDataHandler;
    @Resource
    RevokeHandler revokeHandler;
    @Resource
    BaseContext baseContext;
	@Autowired
	InstanceService instanceService;
    @Resource
	BpmExeStackManager bpmExeStackManager;
	@Resource
	BpmTaskManager bpmTaskManager;
	@Resource
	PreviewProcessService previewProcessService;
    @Resource
    PreviewProcessManager previewProcessManager;


    @RequestMapping(value="getSubDataSqlByFk", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
    @ApiOperation(value = "根据外键获取子表数据sql", httpMethod = "POST", notes = "根据外键获取子表数据sql")
    public CommonResult<String> getSubDataSqlByFk(@ApiParam(name="boEnt",value="bo实体",required = true)@RequestBody ObjectNode boEnt,
                                                  @ApiParam(name="fkValue",value="外键值 ",required = true)@RequestParam Object fkValue,
                                                  @ApiParam(name="defId",value="定义id ",required = false)@RequestParam(required = false) Optional<String> defId,
                                                  @ApiParam(name="nodeId",value="节点id ",required = false)@RequestParam(required = false)  Optional<String> nodeId,
                                                  @ApiParam(name="parentDefKey",value="父流程key ",required = false)@RequestParam(required = false)  Optional<String> parentDefKey) throws Exception {
        return boSubDataHandler.getSubDataSqlByFk(boEnt,fkValue,defId.orElse(""),nodeId.orElse(""),parentDefKey.orElse(""));
    }

	@RequestMapping(value = "getDoneList", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取用户的已办事宜", httpMethod = "POST", notes = "获取用户的已办事宜,参数status表示流程状态,不填表示查询所有")
	public PageList<Map<String, Object>> getDoneList(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(name = "status", value = "流程状态", allowableValues = "running,end,manualend,cancel,back,revoke,revokeToStart", required = false) @RequestParam(required = false) String status,
			@ApiParam(name = "isCheckRevoke", value = "是否检测可撤回状态") @RequestParam Optional<Boolean> isCheckRevoke,@ApiParam(name = "ownerId",value = "指定用户") @RequestParam(required = false) String ownerId,
			HttpServletResponse response) throws Exception {
		PageList<Map<String, Object>> pageList = iFlowService.getDoneList(baseContext.getCurrentUserAccout(),ownerId, queryFilter, status);
		// 如果需要检测是否可以撤回
		if (isCheckRevoke.orElse(false)) {
			revokeHandler.checkRevoke(pageList);
		}
		return pageList;
	}

	@RequestMapping(value = "getDoneInstList", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取用户经办的流程实例", httpMethod = "POST", notes = "获取用户的已办事宜,参数status表示流程状态,不填表示查询所有")
	public PageList<Map<String, Object>> getDoneInstList(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(name = "status", value = "流程状态", allowableValues = "running,end,manualend,cancel,back,revoke,revokeToStart", required = false) @RequestParam(required = false) String status,
			HttpServletResponse response) throws Exception {
		return iFlowService.getDoneInstList(baseContext.getCurrentUserAccout(), queryFilter, status).get();
	}

	@PostMapping(value = "getDoneInstCount", produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取用户经办的流程实例数", httpMethod = "POST", notes = "获取用户的已办事宜,参数status表示流程状态,不填表示查询所有")
	public List<Map<String, Object>> getDoneInstCount(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(name = "status", value = "流程状态数", allowableValues = "running,end,manualend,cancel,back,revoke,revokeToStart", required = false) @RequestParam(required = false) String status,
			HttpServletResponse response) throws Exception {
		return iFlowService.getDoneInstCount(baseContext.getCurrentUserAccout(), queryFilter, status);
	}

	@RequestMapping(value = "completed", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "获取办结事宜", httpMethod = "POST", notes = "获取用户的办结事宜")
	public PageList<DefaultBpmProcessInstance> completed(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			HttpServletResponse response) throws Exception {
		return iFlowService.getCompletedList(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "myCompleted", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取用户办结事宜", httpMethod = "POST", notes = "获取用户的办结事宜")
	public PageList<DefaultBpmProcessInstance> myCompleted(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			HttpServletResponse response) throws Exception {
		return iFlowService.getMyCompletedList(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "getMyRequestList", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "我的请求", httpMethod = "POST", notes = "我的请求")
	public PageList<DefaultBpmProcessInstance> getMyRequestList(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			HttpServletResponse response) throws Exception {
		return iFlowService.getMyRequestList(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "getMyDraftList", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取我的草稿列表", httpMethod = "POST", notes = "获取我的草稿列表")
	public PageList<DefaultBpmProcessInstance> getMyDraftList(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			HttpServletResponse response) throws Exception {
		return iFlowService.getMyDraftList(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "getReceiverCopyTo", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取用户的抄送转发数据", httpMethod = "POST", notes = "获取用户的抄送转发数据")
	public PageList<CopyTo> getReceiverCopyTo(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(name = "type", value = "类型:copyto(抄送) trans(转发)", allowableValues = "copyto,trans", required = false) @RequestParam(required = false) String type,
			HttpServletResponse response) throws Exception {
		return iFlowService.getReceiverCopyTo(baseContext.getCurrentUserAccout(), queryFilter, type);
	}

	@RequestMapping(value = "getMobileReceiverCopyTo", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取手机用户的抄送转发数据", httpMethod = "POST", notes = "获取手机用户的抄送转发数据")
	public PageList<CopyTo> getMobileReceiverCopyTo(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(name = "type", value = "类型:copyto(抄送) trans(转发)", allowableValues = "copyto,trans", required = false) @RequestParam(required = false) String type,
			HttpServletResponse response) throws Exception {
		queryFilter.addFilter("support_mobile_", 1, QueryOP.EQUAL, FieldRelation.AND, "m");
		return iFlowService.getReceiverCopyTo(baseContext.getCurrentUserAccout(), queryFilter, type);
	}

	@RequestMapping(value = "myCopyTo", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "由我发出的抄送", httpMethod = "POST", notes = "获取用户的抄送转发数据")
	public PageList<CopyTo> myCopyTo(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
		return iFlowService.myCopyTo(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "revokeInstance", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据实例id撤回流程(撤销)", httpMethod = "POST", notes = "根据实例id撤回流程(撤销)")
	@AvoidRepeatableCommit
	public CommonResult<String> revokeInstance(
			@ApiParam(required = true, name = "revokeParamObject", value = "流程撤销对象") @RequestBody RevokeParamObject revokeParamObject)
			throws Exception {
		return iFlowService.revokeInstance(revokeParamObject);
	}

	@RequestMapping(value = "getProcessRunByTaskId", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据taskId获取对应的流程运行对象", notes = "根据taskId获取对应的流程运行对象", httpMethod = "GET")
	public BpmProcessInstance getProcessRunByTaskId(
			@ApiParam(name = "taskId", value = "任务id", required = true) @RequestParam String taskId) throws Exception {
		return iProcessService.getProcessRunByTaskId(taskId);
	}

	@RequestMapping(value = "getInstancetByBusinessKey", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "通过businessKey获取运行实例", notes = "通过businessKey获取运行实例", httpMethod = "GET")
	public BpmProcessInstance getInstancetByBusinessKey(
			@ApiParam(name = "businessKey", value = "业务主键", required = true) @RequestParam String businessKey)
			throws Exception {
		return iProcessService.getInstancetByBusinessKey(businessKey);
	}

	@RequestMapping(value = "getInstancetByBizKeySysCode", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "通过businessKey获取运行实例", notes = "通过businessKey获取运行实例", httpMethod = "GET")
	public BpmProcessInstance getInstancetByBizKeySysCode(
			@ApiParam(name = "businessKey", value = "业务主键", required = true) @RequestParam String businessKey,
			@ApiParam(name = "sysCode", value = "业务系统编码", required = true) @RequestParam String sysCode)
			throws Exception {
		return iProcessService.getInstancetByBizKeySysCode(businessKey, sysCode);
	}

	@RequestMapping(value = "getInstanceByInstId", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据实例id获取实例对象", notes = "根据实例id获取实例对象", httpMethod = "GET")
	public BpmProcessInstance getInstanceByInstId(
			@ApiParam(name = "instId", value = "实例id", required = true) @RequestParam String instId) throws Exception {
		return iProcessService.getInstanceByInstId(instId);
	}

	@RequestMapping(value = "getInstanceListByXml", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据xml获取实例列表", notes = "根据xml获取实例列表,xml的根元素包含属性account(用户帐号)、subject(标题)、<br/>status(流程状态,draft草稿,pending挂起,running运行中,manualend人工结束,revokeToStart撤销到发起人,back驳回,end结束)、<br/>"
			+ "pageSize(分页大小,不填默认20)、currentPage(当前页,不填默认第一页)", httpMethod = "GET")
	public PageList<DefaultBpmProcessInstance> getInstanceListByXml(
			@ApiParam(name = "xml", value = "xml", required = true) @RequestParam String xml) throws Exception {
		return iProcessService.getInstanceListByXml(xml);
	}

	@RequestMapping(value = "forbiddenInstance", method = RequestMethod.GET, produces = {
            "application/json; charset=utf-8" })
    @ApiOperation(value = "通过流程实例id挂起流程实例", notes = "通过流程实例id挂起流程实例", httpMethod = "GET")
    public CommonResult<String> forbiddenInstance(
            @ApiParam(name = "instId", value = "实例id", required = true) @RequestParam String instId,@ApiParam(name = "taskId", value = "任务id", required = false)@RequestParam(required = false) String taskId) throws Exception {
        if(StringUtil.isNotEmpty(taskId)){
            BpmUtil.checkDefForbidStatus(null,instId , taskId);
            DefaultBpmTask defaultBpmTask = bpmTaskManager.get(taskId);
            if (BeanUtils.isEmpty(defaultBpmTask) || BpmUtil.isCompletedByTaskStatus(defaultBpmTask.getStatus())) {
                throw new BaseException("任务不存在或已被处理!");
            }
        }
        return iProcessService.forbiddenInstance(instId);
    }

	@RequestMapping(value = "unForbiddenInstance", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "通过流程实例id取消挂起流程实例", notes = "通过流程实例id取消挂起流程实例", httpMethod = "GET")
	public CommonResult<String> unForbiddenInstance(
			@ApiParam(name = "instId", value = "实例id", required = true) @RequestParam String instId) throws Exception {
		return iProcessService.unForbiddenInstance(instId);
	}

	@RequestMapping(value = "getBpmProcessByParentIdAndSuperNodeId", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据父流程实例ID和节点定义ID查子流程实例", notes = "根据父流程实例ID和节点定义ID查子流程实例", httpMethod = "GET")
	public List<BpmProcessInstance> getBpmProcessByParentIdAndSuperNodeId(
			@ApiParam(name = "parentInstId", value = "父实例ID", required = true) @RequestParam String parentInstId,
			@ApiParam(name = "superNodeId", value = "节点ID", required = true) @RequestParam String superNodeId)
			throws Exception {
		return iProcessService.getBpmProcessByParentIdAndSuperNodeId(parentInstId, superNodeId);
	}

	@RequestMapping(value = "getInstancesByParentId", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "通过父流程实例ID和实例的状态获取实例列表", notes = "通过父流程实例ID和实例的状态获取实例列表", httpMethod = "GET")
	public List<DefaultBpmProcessInstance> getInstancesByParentId(
			@ApiParam(name = "parentInstId", value = "父实例ID", required = true) @RequestParam String parentInstId,
			@ApiParam(name = "status", value = "状态(draft:草稿,running:运行中,end:结束,manualend:人工结束,backToStart:驳回到发起人,back:驳回,revoke:撤销,revokeToStart:撤销到发起人)", required = true) @RequestParam String status)
			throws Exception {
		return iProcessService.getInstancesByParentId(parentInstId, status);
	}

	@RequestMapping(value = "getInstancesByDefId", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "通过流程定义id和实例的状态获取实例列表", notes = "通过流程定义id和实例的状态获取实例列表", httpMethod = "GET")
	public List<DefaultBpmProcessInstance> getInstancesByDefId(
			@ApiParam(name = "defId", value = "", required = true) @RequestParam String defId,
			@ApiParam(name = "status", value = "状态(draft:草稿,running:运行中,end:结束,manualend:人工结束,backToStart:驳回到发起人,back:驳回,revoke:撤销,revokeToStart:撤销到发起人)", required = true) @RequestParam String status)
			throws Exception {
		return iProcessService.getInstancesByDefId(defId, status);
	}

	@RequestMapping(value = "getTopBpmProcessInstance", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID查询顶级的流程实例(根据父实例向上查找,只到找到父实例为0的实例为止)", notes = "根据流程实例ID查询顶级的流程实例(根据父实例向上查找,只到找到父实例为0的实例为止)", httpMethod = "GET")
	public BpmProcessInstance getTopBpmProcessInstance(
			@ApiParam(name = "instId", value = "实例id", required = true) @RequestParam String instId) throws Exception {
		return iProcessService.getTopBpmProcessInstance(instId);
	}

	@RequestMapping(value = "getMyRequestListAll", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "我的请求(包括人工终止和结束状态的实例)", httpMethod = "POST", notes = "我的请求(包括人工终止和结束状态的实例)")
	public PageList<DefaultBpmProcessInstance> getMyRequestListAll(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			HttpServletResponse response) throws Exception {
		return iFlowService.getMyRequestListAll(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "getBpmImage", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程定义id或流程实例id或任务id或BPMN实例ID获取流程图。", notes = "根据流程定义id或流程实例id或任务id或BPMN实例ID获取流程图。", httpMethod = "POST")
	public String getBpmImage(
			@ApiParam(name = "BpmImageParamObject", value = "获取流程图(状态)参数", required = true) @RequestBody BpmImageParamObject bpmImageParamObject)
			throws Exception {
		return iProcessService.getBpmImage(bpmImageParamObject);
	}

	@RequestMapping(value = "getInstanceList", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "查询流程实例列表", httpMethod = "POST", notes = "查询流程实例列表")
	public PageList<DefaultBpmProcessInstance> getInstanceList(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(required = true, name = "defId", value = "查询参数对象") @RequestParam Optional<String> defId)
			throws Exception {
		if (StringUtil.isNotEmpty(defId.orElse("")))
			queryFilter.addFilter("proc_def_id_", defId.orElse(""), QueryOP.EQUAL);
		return iFlowService.getInstanceList(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "newProcess", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "新建流程", httpMethod = "POST", notes = "查询新建流程列表")
	public PageList<DefaultBpmDefinition> newProcess(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
		return iFlowService.newProcess(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "newProcessCard", method = RequestMethod.POST, produces = {"application/json; charset=utf-8"})
	@ApiOperation(value = "新建流程卡片,通过流程key分组,取前n个", httpMethod = "POST", notes = "新建流程卡片,通过流程key分组,取前n个")
	public CommonResult<Map<String, List<DefaultBpmDefinition>>> newProcessCard(@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
																  @ApiParam(required = true, name = "size", value = "每组个数") Integer size)throws Exception {
		Map<String, List<DefaultBpmDefinition>> map = iFlowService.newProcessCard(baseContext.getCurrentUserAccout(), queryFilter, size);
		return new CommonResult<>(true, "获取成功", map);
	}

	@PostMapping(value = "newProcessCount", produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "新建流程", httpMethod = "POST", notes = "查询新建流程列表")
	public List<Map<String,Object>> newProcessCount(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
		return iFlowService.newProcessCount(queryFilter);
	}

	@RequestMapping(value = "myRequest", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "我的请求", httpMethod = "POST", notes = "查询我的请求列表")
	public PageList<DefaultBpmProcessInstance> myRequest(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
		return iFlowService.myRequest(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@GetMapping(value = "myRequestCount", produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "我的请求", httpMethod = "POST", notes = "查询我的请求列表在个分类的数量")
	public List<Map<String,Object>> myRequestCount() throws Exception {
		return iFlowService.myRequestCount(baseContext.getCurrentUserAccout());
	}

	@RequestMapping(value = "myMobileRequest", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "手机端我的请求", httpMethod = "POST", notes = "查询手机端我的请求列表")
	public PageList<DefaultBpmProcessInstance> myMobileRequest(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
//		 queryFilter.addFilter("SUPPORT_MOBILE_", 1, QueryOP.EQUAL,FieldRelation.AND,"m");
		if (BeanUtils.isNotEmpty(queryFilter)){
			List<FieldSort> sorter = queryFilter.getSorter();
			List<FieldSort> fieldSortList = new ArrayList<>();
			//移动端,草稿案件始终排在我的申请列表最前面
			fieldSortList.add(new FieldSort("isDraft",Direction.DESC));
			if (BeanUtils.isNotEmpty(sorter)){
				fieldSortList.addAll(sorter);
			}
			queryFilter.setSorter(fieldSortList);
		}
		return iFlowService.myRequest(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "myMobileDraft", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取手机端我的草稿列表", httpMethod = "POST", notes = "获取手机端我的草稿列表")
	public PageList<DefaultBpmProcessInstance> myMobileDraft(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			HttpServletResponse response) throws Exception {
		queryFilter.addFilter("SUPPORT_MOBILE_", 1, QueryOP.EQUAL, FieldRelation.AND, "m");
		return iFlowService.getMyDraftList(baseContext.getCurrentUserAccout(), queryFilter);
	}

	@RequestMapping(value = "myMobileProcess", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "手机端新建流程", httpMethod = "POST", notes = "手机端查询新建流程列表")
	public PageList<DefaultBpmDefinition> myMobileProcess(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
//		queryFilter.addFilter("SUPPORT_MOBILE_", 1, QueryOP.EQUAL, FieldRelation.AND, "m");
		return iFlowService.newProcess(baseContext.getCurrentUserAccout(), queryFilter);
	}

    @RequestMapping(value = "myMobileProcessShowButton", method = RequestMethod.POST, produces = {
            "application/json; charset=utf-8" })
    @ApiOperation(value = "手机端查询新建流程列表时,该分类是否有未配置移动表单", httpMethod = "POST", notes = "手机端查询新建流程列表时,该分类是否有未配置移动表单")
    public CommonResult<Boolean> myMobileProcessShowButton(
            @ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
            throws Exception {
		queryFilter.addFilter("SUPPORT_MOBILE_", 0, QueryOP.EQUAL, FieldRelation.AND, "main");
        queryFilter.setPageBean(new PageBean(1,0));
        PageList<DefaultBpmDefinition> queryList = iFlowService.newProcess(baseContext.getCurrentUserAccout(), queryFilter);
        return CommonResult.success(Long.compare(queryList.getTotal(),Long.valueOf("0"))>0);
    }


    /**
	 * 根据任务id获取流程实例某个节点上的执行人员
	 *
	 * @param taskId
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "getNodeUsers", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据任务id获取流程实例某个节点上的执行人员", notes = "根据任务id获取流程实例某个节点上的执行人员", httpMethod = "GET")
	public List<BpmIdentityResult> getNodeUsers(
			@ApiParam(value = "任务id", name = "taskId", required = true) @RequestParam String taskId) throws Exception {
		return iProcessService.getNodeUsers(taskId);
	}

	@RequestMapping(value = "start", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "客户端启动流程", httpMethod = "POST", notes = "客户端启动流程")
	public StartResult start(
			@ApiParam(name = "startFlowParamObject", value = "流程启动参数", required = true) @RequestBody StartFlowParamObject startFlowParamObject)
			throws Exception {
		CompletableFuture<StartResult> start = iProcessService.start(startFlowParamObject);
		return start.get();
	}

	@RequestMapping(value = "syncStart", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "客户端同步启动流程", httpMethod = "POST", notes = "客户端启动流程-采用同步线程的方式")
	public StartResult syncStartWithRight(
			@ApiParam(name = "startFlowParamObject", value = "流程启动参数", required = true) @RequestBody StartFlowParamObject startFlowParamObject)
			throws Exception {
		return iProcessService.syncStartWithRight(startFlowParamObject);
	}

	@RequestMapping(value="assignBpmTask",method=RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "节点属性配置执行人为空时选择 assign:由审批人指定", httpMethod = "POST", notes = "节点属性配置执行人为空时选择 assign:由审批人指定")
	public CommonResult<String> assignBpmTask(@ApiParam(name="map",value="参数", required = true) @RequestBody Map<String,Object> map) throws Exception{
		return bpmTaskManager.assignBpmTask(map);
	}

	@RequestMapping(value = "saveDraft", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "保存草稿", httpMethod = "POST", notes = "保存草稿")
	public StartResult saveDraft(
			@ApiParam(name = "startFlowParamObject", value = "流程启动参数", required = true) @RequestBody StartFlowParamObject startFlowParamObject)
			throws Exception {
		startFlowParamObject.setAccount(baseContext.getCurrentUserAccout());
		return iProcessService.saveDraft(startFlowParamObject);
	}

	@RequestMapping(value = "doNext", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "客户端提交数据,执行流程往下跳转", httpMethod = "POST", notes = "客户端提交数据,执行流程往下跳转")
	public CommonResult<String> doNext(
			@ApiParam(name = "doNextParamObject", value = "流程向下执行对象", required = true) @RequestBody DoNextParamObject doNextParamObject)
			throws Exception {
		return iProcessService.doNext(doNextParamObject);
	}

	@RequestMapping(value = "doEndProcess", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "人工终止流程", httpMethod = "POST", notes = "人工终止流程")
	@AvoidRepeatableCommit
	public CommonResult<String> doEndProcess(
			@ApiParam(name = "doEndParamObject", value = "流程终止对象") @RequestBody DoEndParamObject doEndParamObject)
			throws Exception {
		return iProcessService.doEndProcess(doEndParamObject);
	}

	@RequestMapping(value = "renewProcess", method = RequestMethod.GET, produces = {
	"application/json; charset=utf-8" })
	@ApiOperation(value = "终止恢复", httpMethod = "GET", notes = "人工终止流程恢复")
	public CommonResult<String> renewProcess(@ApiParam(name = "id", required = true, value = "流程实例id") @RequestParam String id,
            @ApiParam(name = "reason", required = true, value = "终止原因") @RequestParam String reason)
		throws Exception {
	return iProcessService.renewProcess(id, reason);
	}

	@RequestMapping(value = "getHistoryOpinion", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "按流程实例ID或任务实例ID取得某个流程的审批历史", httpMethod = "GET", notes = "按流程实例ID或任务实例ID取得某个流程的审批历史")
	public List<BpmTaskOpinion> getHistoryOpinion(
			@ApiParam(name = "instanId", value = "流程实例id", required = false) @RequestParam(required = false) String instanId,
			@ApiParam(name = "taskId", value = "任务id", required = false) @RequestParam(required = false) String taskId)
			throws Exception {
		return iProcessService.getHistoryOpinion(instanId, taskId);
	}

	@RequestMapping(value = "getProcessOpinionByActInstId", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "按Activiti实例Id取得对应流程的审批历史", httpMethod = "GET", notes = "按Activiti实例Id取得对应流程的审批历史")
	public List<BpmCheckOpinionVo> getProcessOpinionByActInstId(
			@ApiParam(name = "actTaskId", value = "Activiti任务Id", required = true) @RequestParam String actTaskId)
			throws Exception {
		return iProcessService.getProcessOpinionByActInstId(actTaskId);
	}

	@RequestMapping(value = "getEnableRejectNode", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据任务ID获取可驳回的节点", httpMethod = "POST", notes = "根据任务ID获取可驳回的节点,rejectType驳回方式:direct直来直往,normal按照流程图执行")
	public List<BpmNodeDefVo> getEnableRejectNode(
			@ApiParam(name = "taskId", value = "任务id") @RequestParam String taskId,
			@ApiParam(name = "rejectType", allowableValues = "direct,normal", value = "返回方式") @RequestParam String rejectType)
			throws Exception {
		return iProcessService.getEnableRejectNode(taskId, rejectType);
	}

	@RequestMapping(value = "getBusinessKey", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据任务ID或流程实例ID获取BusinessKey(流程表单为URL表单的情况)", httpMethod = "GET", notes = "根据任务ID或流程实例ID获取BusinessKey(流程表单为URL表单的情况)")
	public CommonResult<String> getBusinessKey(
			@ApiParam(name = "instanId", value = "流程实例id", required = false) @RequestParam(required = false) String instanId,
			@ApiParam(name = "taskId", value = "任务id", required = false) @RequestParam(required = false) String taskId)
			throws NullPointerException {
		return iProcessService.getBusinessKey(instanId, taskId);
	}

	@RequestMapping(value = "getProcInstId", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据BussinessKey获取流程实例ID", httpMethod = "POST", notes = "根据BussinessKey获取流程实例ID")
	public CommonResult<String> getProcInstId(
			@ApiParam(name = "businessKey", value = "businessKey") @RequestParam String businessKey)
			throws NullPointerException {
		return iProcessService.getProcInstId(businessKey);
	}

	/**
	 * 根据任务id获取在线表单地址
	 *
	 * @param taskId
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "getDetailUrl", method = RequestMethod.GET, produces = { "application/json;charset=utf-8" })
	@ApiOperation(value = "根据任务id获取在线表单地址", notes = "根据任务id获取在线表单地址", httpMethod = "GET")
	public String getDetailUrl(@ApiParam(name = "taskId", value = "任务id") @RequestParam String taskId)
			throws Exception {
		return iProcessService.getDetailUrl(taskId);
	}

	@RequestMapping(value = "transToMore", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "抄送转发", httpMethod = "POST", notes = "抄送转发")
	public CommonResult<String> transToMore(
			@ApiParam(required = true, name = "copyToParam", value = "抄送转发参数对象") @RequestBody CopyToParam copyToParam)
			throws Exception {
		CommonResult<String> res=instanceService.transToMore(copyToParam);
		return res;
	}

	@RequestMapping(value = "getInstFormAndBO", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取流程实例的表单和数据", notes = "获取流程实例的表单和数据", httpMethod = "GET")
	@PermissionCheck(instanceId = "#proInstId",isDefAuthorize = "#isDefAuthorize")
	public CommonResult<InstFormAndBoVo> getInstFormAndBO(
			@ApiParam(name = "proInstId", value = "流程实例id") @RequestParam(required = false) String proInstId,
			@ApiParam(name = "nodeId", value = "任务节点id") @RequestParam Optional<String> nodeId,
			@ApiParam(name = "formId", value = "表单id") @RequestParam Optional<String> formId,
			@ApiParam(name = "getStartForm", value = "获取发起节点表单") @RequestParam Optional<Boolean> getStartForm,
			@ApiParam(name = "myApplication", value = "是否是我的申请") @RequestParam Optional<Boolean> myApplication,
			@ApiParam(name = "includData", value = "任务节点id") @RequestParam Optional<Boolean> includData,
			@ApiParam(name = "isDefAuthorize", value = "是否是分管授权获取的打开权限") @RequestParam(required = false) String isDefAuthorize
    )
			throws Exception {
		InstFormAndBoVo instFormAndBO = iFlowService.getInstFormAndBO(proInstId, nodeId.orElse(null),
				formId.orElse(null),
				FormType.PC,
				includData.orElse(true), getStartForm.orElse(false),myApplication.orElse(false));
		FormModel form = instFormAndBO.getForm();
		if((BeanUtils.isEmpty(instFormAndBO.getData()) || instFormAndBO.getData().isEmpty()) && form != null && FormCategory.INNER.value().equals(form.getFormType())){
			List<ObjectNode> boDatas = boDataService.getDataByDefId(instFormAndBO.getInstance().getProcDefId());
			ObjectNode jsondata = (ObjectNode) BoDataUtil.hanlerData(boDatas);
			instFormAndBO.setData(jsondata);
		}
		return CommonResult.<InstFormAndBoVo>ok().value(instFormAndBO);
	}

	@RequestMapping(value = "getMobileInstFormAndBO", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取手机流程实例的表单和数据", notes = "获取手机流程实例的表单和数据", httpMethod = "GET")
	public InstFormAndBoVo getMobileInstFormAndBO(
			@ApiParam(name = "proInstId", value = "流程实例id") @RequestParam Optional<String> proInstId,
			@ApiParam(name = "nodeId", value = "任务节点id") @RequestParam Optional<String> nodeId,@ApiParam(name = "myApplication", value = "我的申请") @RequestParam Optional<Boolean> myApplication) throws Exception {
		return iFlowService.getInstFormAndBO(proInstId.orElse(null), nodeId.orElse(null), null, FormType.MOBILE, true, false,myApplication.orElse(false));
	}

	@RequestMapping(value = "getFormAndBO", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "流程启动时获取bo和表单", notes = "流程启动时获取bo和表单", httpMethod = "POST")
	@PermissionCheck(instanceId = "#startCmdParam.proInstId")
	public FormAndBoVo getFormAndBO(
			@ApiParam(required = true, name = "startCmdParam", value = "参数对象") @RequestBody StartCmdParam startCmdParam)
			throws Exception {
		return iFlowService.getFormAndBO(startCmdParam, FormType.PC);
	}

	@RequestMapping(value = "getMobileFormAndBO", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "手机流程启动时获取bo和表单", notes = "手机流程启动时获取bo和表单", httpMethod = "POST")
	public FormAndBoVo getMobileFormAndBO(
			@ApiParam(required = true, name = "startCmdParam", value = "参数对象") @RequestBody StartCmdParam startCmdParam)
			throws Exception {
		return iFlowService.getFormAndBO(startCmdParam, FormType.MOBILE);
	}

	@RequestMapping(value = "getStartCmd", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取发起的cmd格式数据", httpMethod = "POST", notes = "获取发起的cmd格式数据")
	public DefaultProcessInstCmd getStartCmd(@RequestBody StartCmdParam startCmdParam) throws Exception {
		return iFlowService.getStartCmd(startCmdParam);
	}

	@RequestMapping(value = "startForm", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "业务数据模板中 启动流程实例", httpMethod = "POST", notes = "业务数据模板中 启动流程实例")
	public CommonResult<String> startForm(
			@ApiParam(required = true, name = "defKey", value = "流程定义defKey") @RequestParam String defKey,
			@ApiParam(required = true, name = "businessKey", value = "业务主键") @RequestParam String businessKey,
			@ApiParam(required = true, name = "boAlias", value = "bo定义alias") @RequestParam String boAlias)
			throws Exception {
		return instanceService.startForm(defKey,businessKey,boAlias);
	}

	@RequestMapping(value = "sendNodeUsers", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取可发送到节点指定人", httpMethod = "GET", notes = "获取可发送到节点指定人")
	public List<BpmNodeDef> nodeUsers(
			@ApiParam(required = true, name = "defId", value = "流程定义id") @RequestParam String defId,
			@ApiParam(name = "nodeId", value = "节点id") @RequestParam String nodeId) throws Exception {
		return instanceService.nodeUsers(defId,nodeId);
	}

	@RequestMapping(value = "selectDestination", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "选择路径", notes = "选择路径", httpMethod = "GET")
	public SelectDestinationVo selectDestination(
			@ApiParam(name = "defId", value = "流程定义id", required = true) @RequestParam String defId) throws Exception {
		return iFlowService.selectDestination(defId);
	}

	@RequestMapping(value = "instanceToStart", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "进入流程页面获取相关数据", notes = "进入流程页面获取相关数据", httpMethod = "GET")
	public BpmDefExtProperties instanceToStart(
			@ApiParam(name = "defId", value = "流程定义id", required = true) @RequestParam String defId) throws Exception {
		BpmProcessDef<BpmProcessDefExt> procDef = bpmDefinitionAccessor.getBpmProcessDef(defId);
		BpmDefExtProperties prop = procDef.getProcessDefExt().getExtProperties();
		return prop;
	}

	@RequestMapping(value = "instanceToCopyTo", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "进入流程转发页面", notes = "进入流程转发页面", httpMethod = "GET")
	public ToCopyToVo toCopyTo(
			@ApiParam(name = "proInstId", value = "流程实例id", required = true) @RequestParam String proInstId,
			@ApiParam(name = "taskId", value = "任务id", required = true) @RequestParam String taskId,
			@ApiParam(name = "copyToType", value = "类型:0 抄送  1转发", required = true) @RequestParam String copyToType)
			throws Exception {
		return instanceService.toCopyTo(proInstId,taskId,copyToType);

	}

	@RequestMapping(value = "get", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "获取流程实例明细", httpMethod = "GET", notes = "获取流程实例明细")
	public ObjectNode get(
			@ApiParam(name = "id", value = "流程实例id", required = true) @RequestParam String id) throws Exception {
		return bpmProcessInstanceManager.getInstDetail(id);
	}

	@RequestMapping(value = "realDetail", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "获取流程实例明细", httpMethod = "GET", notes = "获取流程实例明细")
	public DefaultBpmProcessInstance realDetail(
			@ApiParam(name = "cptoReceiverId", value = "抄送接收对象id", required = true) @RequestParam String cptoReceiverId,
			@ApiParam(name = "id", value = "流程实例id", required = true) @RequestParam String id) throws Exception {
		BpmCptoReceiver model = bpmCptoReceiverManager.get(cptoReceiverId);
		if (model != null && model.getIsRead() == 0) {
			model.setIsRead((short) 1);
			bpmCptoReceiverManager.update(model);
		}
		return bpmProcessInstanceManager.get(id);
	}

	@RequestMapping(value = "instanceFlowImage", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取流程实例明细", httpMethod = "GET", notes = "获取流程实例明细")
	public FlowImageVo flowImage(
			@ApiParam(name = "proInstId", value = "流程实例id", required = true) @RequestParam Optional<String> proInstId,
			@ApiParam(name = "type", value = "如果为子流程:subFlow") @RequestParam Optional<String> type,
			@ApiParam(name = "from", value = "") @RequestParam Optional<String> from,
			@ApiParam(name = "nodeId", value = "节点id") @RequestParam Optional<String> nodeId,
			@ApiParam(name = "defId", value = "流程定义id") @RequestParam Optional<String> defId,
			@ApiParam(name = "isScale", value = "缩放比例") @RequestParam Optional<Double> scalePrcent) throws Exception {
		ThreadMsgUtil.addMapMsg(BpmConstants.FLOW_CHART_SCALING, String.valueOf(scalePrcent.orElse((double) 1)));
		return iFlowService.flowImage(proInstId.orElse(null), type.orElse(null), from.orElse(null), nodeId.orElse(null),
				defId.orElse(null));
	}

	@RequestMapping(value = "instanceFlowImageMobile", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取移动端流程实例明细", httpMethod = "GET", notes = "获取流程实例明细")
	public FlowImageMobileVo flowImageFormMobile(
			@ApiParam(name = "proInstId", value = "流程实例id", required = true) @RequestParam Optional<String> proInstId,
			@ApiParam(name = "type", value = "如果为子流程:subFlow") @RequestParam Optional<String> type,
			@ApiParam(name = "from", value = "") @RequestParam Optional<String> from,
			@ApiParam(name = "nodeId", value = "节点id") @RequestParam Optional<String> nodeId,
			@ApiParam(name = "defId", value = "流程定义id") @RequestParam Optional<String> defId) throws Exception {
        FlowImageMobileVo flowImageVo = iFlowService.flowImageMobile(proInstId.orElse(null), type.orElse(null), from.orElse(null), nodeId.orElse(null),
                defId.orElse(null));
        return flowImageVo;
	}

	@RequestMapping(value = "getBpmImage", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "获取流程图", httpMethod = "GET", notes = "获取流程图")
	public String getBpmImage(@ApiParam(name = "defId", value = "流程定义id") @RequestParam Optional<String> defId,
			@ApiParam(name = "bpmnInstId", value = "bpmnInstId") @RequestParam Optional<String> bpmnInstId,
			@ApiParam(name = "taskId", value = "taskId") @RequestParam Optional<String> taskId,
			@ApiParam(name = "proInstId", value = "proInstId") @RequestParam Optional<String> proInstId,
	        @ApiParam(name = "isScale", value = "缩放比例") @RequestParam Optional<Double> scalePrcent) throws Exception {
		ThreadMsgUtil.addMapMsg(BpmConstants.FLOW_CHART_SCALING, String.valueOf(scalePrcent.orElse((double) 1)));
		BpmImageParamObject object = new BpmImageParamObject();
		object.setDefId(defId.orElse(null));
		object.setBpmnInstId(bpmnInstId.orElse(null));
		object.setTaskId(taskId.orElse(null));
		object.setProcInstId(proInstId.orElse(null));
		return iProcessService.getBpmImage(object);
	}

	@RequestMapping(value = "instanceNodeStatus", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取节点审批状态", httpMethod = "GET", notes = "获取节点审批状态")
	public NodeStatusVo getNodeStatus(
			@ApiParam(name = "instId", value = "流程实例id", required = true) @RequestParam String instId,
			@ApiParam(name = "nodeId", value = "节点id", required = true) @RequestParam String nodeId) throws Exception {
		List<IUser> userList = null;
		// 获取审批情况
		List<BpmTaskOpinion> bpmTaskOpinions = bpmOpinionService.getByInstNodeId(instId, nodeId);
		// 没有审批、则获取有审批权限的人...
		if (bpmTaskOpinions.size() < 1) {
			userList = bpmIdentityService.queryUsersByNode(instId, nodeId);
		}
		return new NodeStatusVo(userList, bpmTaskOpinions);
	}

	@RequestMapping(value = "instanceFlowOpinions", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "流程审批历史(页面数据)", httpMethod = "GET", notes = "流程审批历史")
	public List<ObjectNode> opinionHistory(
			@ApiParam(name = "instId", value = "流程实例id", required = true) @RequestParam Optional<String> instId,
			@ApiParam(name = "taskId", value = "任务id", required = false) @RequestParam Optional<String> taskId,
			@ApiParam(name = "isCommu", value = "是否包含沟通", required = false) @RequestParam Optional<Boolean> isCommu,
			@ApiParam(name = "isRelFlow", value = "是否相关流程", required = false) @RequestParam Optional<Boolean> isRelFlow,
			@ApiParam(name = "isRequest", value = "是否在我的请求处调用", required = false) @RequestParam Optional<Boolean> isRequest)
			throws Exception {
		List<ObjectNode> res=instanceService.opinionHistory(instId,taskId,isCommu,isRelFlow,isRequest);
		return res;
	}

	@RequestMapping(value = "remove", method = RequestMethod.DELETE, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "删除流程实例", httpMethod = "DELETE", notes = "删除流程实例")
	public Object remove(@ApiParam(name = "ids", value = "流程实例id,多个用“,”号隔开", required = true) @RequestParam String ids)
			throws Exception {
		Object res=instanceService.remove(ids);
		return res;
	}

	@RequestMapping(value = "instRemove", method = RequestMethod.DELETE, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "删除流程", httpMethod = "DELETE", notes = "删除流程")
	public Object instRemove(@ApiParam(name = "id", value = "流程实例id", required = true) @RequestParam String id)
			throws Exception {
		Object res=iFlowService.instRemove(id);
		return res;
	}

	@RequestMapping(value = "getInstDeleteLog", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "查询彻底删除的日志", httpMethod = "DELETE", notes = "查询彻底删除的日志")
	public PageList<BpmInstDeleteLog> getInstDeleteLog(@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter) throws Exception {
		return instanceService.getInstDeleteLog(queryFilter);
	}

	@RequestMapping(value = "completelyRemove", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "彻底删除流程实例", httpMethod = "DELETE", notes = "彻底删除流程实例")
	public Object completelyRemove(@ApiParam(name = "bpmInstDeleteVos", value = "流程实例删除对象list", required = true) @RequestBody List<BpmInstDeleteVo> bpmInstDeleteVos,
								   @ApiParam(name = "content", value = "删除事由", required = true) @RequestParam String content,
								   @ApiParam(name = "isRemoveBo" ,value = "是否删除表单数据",required = false)@RequestParam Boolean isRemoveBo)
			throws Exception {
		return instanceService.completelyRemove(bpmInstDeleteVos,content,isRemoveBo);
	}

	@RequestMapping(value = "restore", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID恢复实例数据", httpMethod = "GET", notes = "根据流程实例ID恢复实例数据")
	public Object restore(@ApiParam(name = "id", value = "流程实例id", required = true) @RequestParam String id)
			throws Exception {
		String[] idArr = null;
		if (StringUtil.isNotEmpty(id)) {
			idArr = id.split(",");
		}
		return iFlowService.doRestore(idArr);
	}

	@RequestMapping(value = "checkInvoke", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "判断根据流程实是否例撤销到发起人", httpMethod = "GET", notes = "判断根据流程实是否例撤销到发起人")
	public CommonResult<String> checkInvoke(
			@ApiParam(name = "invokeToStart", value = "", required = true) @RequestParam Integer invokeToStart,
			@ApiParam(name = "instanceId", value = "流程实例id", required = true) @RequestParam String instanceId)
			throws Exception {
		ResultMessage result = null;
		invokeToStart = BeanUtils.isEmpty(invokeToStart) ? 1 : invokeToStart;
		if (invokeToStart == 1) {
			result = bpmProcessInstanceManager.canRevokeToStart(instanceId);
			return new CommonResult<String>(true, result.getMessage(), null);
		}
		return new CommonResult<String>(false, "", null);
	}

	@RequestMapping(value = "getPathNodes", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "通过流程实例ID获取流程运行轨迹", httpMethod = "GET", notes = "通过流程实例ID获取流程运行轨迹")
	public List<BpmInstanceTrack> getPathNodes(
			@ApiParam(name = "instanceId", value = "流程实例id", required = true) @RequestParam String procInstId)
			throws Exception {
		return processInstanceService.getTracksByInstId(procInstId);
	}

	@RequestMapping(value = "getStatusByRunidNodeId", method = RequestMethod.GET, produces = {
			"application/json;charset=utf-8" })
	@ApiOperation(value = "根据实例id和节点id获取节点状态", notes = "根据实例id和节点id获取节点状态", httpMethod = "GET")
	public String getStatusByRunidNodeId(@ApiParam(name = "instId", value = "实例id") @RequestParam String instId,
			@ApiParam(name = "nodeId", value = "节点id") @RequestParam String nodeId) throws Exception {
		return iProcessService.getStatusByRunidNodeId(instId, nodeId);
	}

	@RequestMapping(value = "getDataByDefId", method = RequestMethod.GET, produces = {
			"application/json;charset=utf-8" })
	@ApiOperation(value = "根据流程定义id获取bo数据", notes = "根据流程定义id获取bo数据", httpMethod = "GET")
	public List<ObjectNode> getDataByDefId(@ApiParam(name = "defId", value = "流程定义id") @RequestParam String defId)
			throws Exception {
		return boDataService.getDataByDefId(defId);
	}

	@RequestMapping(value = "removeDraftById", method = RequestMethod.DELETE, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = " 删除草稿", httpMethod = "DELETE", notes = "删除草稿")
	public CommonResult<String> removeDraftById(
			@ApiParam(name = "ids", value = "流程实例id,多个用“,”号隔开", required = true) @RequestParam String ids)
			throws Exception {
		String[] aryIds = null;
		if (!StringUtil.isEmpty(ids)) {
			aryIds = ids.split(",");
		}
		for(String str : aryIds){
            bpmProcessInstanceManager.removeBpm(str);
        }
		return new CommonResult<String>(true, "删除草稿成功", "");
	}

	@RequestMapping(value = "taskTurnAssigns", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "通过Id获取转办人员", httpMethod = "GET", notes = "通过Id获取转办人员")
	public List<TaskTurnAssign> taskTurnAssigns(
			@ApiParam(name = "taskTurnId", value = "taskTurnId", required = true) @RequestParam String taskTurnId)
			throws Exception {
		return bpmTaskTurnManager.getTurnAssignByTaskTurnId(taskTurnId);
	}

	@RequestMapping(value = "getByBusinesKey", method = RequestMethod.GET, produces = {
			"application/json;charset=utf-8" })
	@ApiOperation(value = "获取流程实例与业务数据关系", notes = "获取流程实例与业务数据关系", httpMethod = "GET")
	public BpmBusLink getByBusinesKey(
			@ApiParam(name = "businessKey", value = "业务数据id", required = true) @RequestParam String businessKey,
			@ApiParam(name = "formIdentity", value = "表单标识") @RequestParam(required = false) String formIdentity,
			@ApiParam(name = "isNumber", value = "是否数字类型", required = true) @RequestParam Boolean isNumber)
			throws Exception {
		List<BpmBusLink> bpmBusLinkList = bpmBusLinkManager.getByBusinesKey(businessKey, formIdentity, isNumber);
		if(CollectionUtils.isEmpty(bpmBusLinkList)){
			return null;
		}
		return bpmBusLinkList.get(0);
	}

	@RequestMapping(value = "getDefaultInfobox", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "信息盒子", httpMethod = "GET", notes = "首页栏目信息盒子")
	public List<InfoboxVo> getDefaultInfobox() throws Exception {
		List<InfoboxVo> res=instanceService.getDefaultInfobox();
		return res;
	}

	@RequestMapping(value = "getDefaultInfoMap", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "信息盒子", httpMethod = "GET", notes = "首页栏目信息盒子")
	public Map<String, Object> getDefaultInfoMap() throws Exception {
		Map<String, Object> res=instanceService.getDefaultInfoMap();
		return res;
	}

	@RequestMapping(value = "getFlowsMap", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "首页栏目获取固化流程信息", httpMethod = "GET", notes = "首页栏目获取固化流程信息")
	public Map<String, DefaultBpmDefinition> getFlowsMap() throws Exception {
		return instanceService.getFlowsMap();
	}

	@RequestMapping(value = "getNewsAndBulletin", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取新闻公告", httpMethod = "POST", notes = "查询新建流程列表")
	public ArrayNode getNewsAndBulletin(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody Optional<QueryFilter> queryFilter)
			throws Exception {
		ArrayNode res=instanceService.getNewsAndBulletin(queryFilter);
		return res;
	}


	@RequestMapping(value = "publishMsgNews", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "通过Id获取转办人员", httpMethod = "POST", notes = "通过Id获取转办人员")
	public void publishMsgNews(@ApiParam(name = "params", required = true) @RequestBody String params)
			throws Exception {
		instanceService.publishMsgNews(params);
	}

	@RequestMapping(value = "getBusLink", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例获取关联数据", httpMethod = "POST", notes = "根据流程实例获取关联数据")
	public List<String> getBusLink(@ApiParam(name = "params", required = true) @RequestBody ObjectNode params) throws Exception {
		List<String> res=instanceService.getBusLink(params);
		return res;
	}

	/**
	 * 获取流程运行时的变量
	 */
	@RequestMapping(value = "getInstRunDataList", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取流程运行时的变量", httpMethod = "GET", notes = "获取流程运行时的变量")
	public List<ObjectNode> getInstRunDataList(
			@ApiParam(name = "instanceId", required = true) @RequestParam String instanceId) throws Exception {
		List<ObjectNode> res=instanceService.getInstRunDataList(instanceId);
		return res;
	}

	/**
	 * 移交流程列表
	 *
	 * @param userId
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "inst/listJson", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取移交流程列表(带分页信息,DefaultBpmProcessInstance对象)", httpMethod = "POST", notes = "获取移交流程列表(带分页信息,DefaultBpmProcessInstance对象)")
	public PageList<DefaultBpmProcessInstance> listJson(
			@ApiParam(name = "queryFilter", value = "通用查询对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(name = "userId", value = "移交人id", required = true) @RequestParam Optional<String> userId)
			throws Exception {
		queryFilter.addParams("userId", userId.orElse(ContextUtil.getCurrentUserId()));
		PageList<DefaultBpmProcessInstance> list = bpmProcessInstanceManager.queryByuserId(queryFilter);
		return list;
	}

	/**
	 * 流程实例列表
	 *
	 * @param queryFilter
	 * @param defId
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "getInstDetailList", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "查询流程实例列表", httpMethod = "POST", notes = "查询流程实例列表")
	public PageList<DefaultBpmProcessInstance> getInstDetailList(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestParam Optional<String> defId)
			throws Exception {
		PageList<DefaultBpmProcessInstance> res=instanceService.getInstDetailList(queryFilter,defId);
		return res;
	}

	@RequestMapping(value = "getByInstId", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID获取流程实例信息", httpMethod = "GET", notes = "根据流程实例ID获取流程实例信息")
	public DefaultBpmProcessInstance getByInstId(
			@ApiParam(name = "id", value = "是否相关流程", required = true) @RequestParam String id,
			@ApiParam(name = "isRelFlow", required = false) @RequestParam Optional<Boolean> isRelFlow)
			throws Exception {
		if (!isRelFlow.orElse(false)) {
			// 验证权限
			// checkInstAuth(id);
		}
		DefaultBpmProcessInstance instance = bpmProcessInstanceManager.get(id);
		// iFlowService.addReadRecord(instance);
		return instance;
	}

    @RequestMapping(value = "getSponsorRevokeByInstId", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
    @ApiOperation(value = "根据流程实例id判断是否允许发起人撤回", httpMethod = "GET", notes = "根据流程实例id判断是否允许发起人撤回")
    public CommonResult<Boolean> getSponsorRevokeByInstId(
            @ApiParam(name = "instId", value = "流程实例Id", required = true) @RequestParam String instId)throws Exception {
		CommonResult<Boolean> res=instanceService.getSponsorRevokeByInstId(instId);
	    return res;
    }

	@RequestMapping(value = "updateFlowOpinions", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "修改审批历史包含沟通", httpMethod = "POST", notes = "修改审批历史包含沟通")
	public CommonResult<String> updateFlowOpinions(
			@ApiParam(name = "opinions", value = "审批历史信息") @RequestBody ObjectNode opinions) throws Exception {
		return bpmCheckOpinionManager.updateFlowOpinions(opinions);
	}

	@RequestMapping(value = "delFlowOpinions", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "删除审批历史包含沟通", httpMethod = "POST", notes = "人工终止流程")
	public CommonResult<String> delFlowOpinions(@ApiParam(name = "id", value = "审批意见id") @RequestParam String id,
			@ApiParam(name = "opinion", value = "删除原因") @RequestBody String opinion) throws Exception {
		return bpmCheckOpinionManager.delFlowOpinions(id, opinion);
	}

	@RequestMapping(value = "saveFormData", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "保存表单数据", httpMethod = "POST", notes = "保存表单数据")
	public CommonResult<String> saveFormData(
			@ApiParam(name = "startFlowParamObject", value = "流程启动参数", required = true) @RequestBody StartFlowParamObject startFlowParamObject)
			throws Exception {
		CommonResult<String> res=instanceService.saveFormData(startFlowParamObject);
		return res;
	}

	@RequestMapping(value = "relatedProcess", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据申请人获取相关流程", httpMethod = "POST", notes = "根据申请人获取相关流程")
	public PageList<DefaultBpmProcessInstance> relatedProcess(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
		PageList<DefaultBpmProcessInstance> res=instanceService.relatedProcess(queryFilter);
		return res;
	}

	@RequestMapping(value = "getHasAuthFlowList", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取有权限的流程并将其按照分类名称进行分组", httpMethod = "POST", notes = "获取有权限的流程并将其按照分类名称进行分组")
	public List<ObjectNode> getHasAuthFlowList(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
		List<ObjectNode> res=instanceService.getHasAuthFlowList(queryFilter);
		return res;
	}

	@RequestMapping(value = "doNextcommu", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "沟通反馈", httpMethod = "POST", notes = "沟通反馈")
	public CommonResult<String> doNextcommu(
			@ApiParam(name = "doNextParamObject", value = "沟通反馈对象", required = true) @RequestBody DoNextParamObject doNextParamObject,
			HttpServletRequest request) throws Exception {
		return iProcessService.doNextcommu(doNextParamObject);
	}

	@RequestMapping(value = "getRelatedInformationById", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID获取相关信息", httpMethod = "GET", notes = "根据流程实例ID获取相关信息")
	public RelatedInformation getRelatedInformationById(@ApiParam(name = "id", required = true) @RequestParam String id)
			throws Exception {
		return instanceService.getRelatedInformationById(id);

	}

	@RequestMapping(value = "getByRecordInstId", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID获取阅读记录", httpMethod = "POST", notes = "根据流程实例ID获取阅读记录")
	public PageList<BpmReadRecord> getByRecordInstId(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter<BpmReadRecord> queryFilter)
			throws Exception {
		return instanceService.getByRecordInstId(queryFilter);
	}

	@RequestMapping(value = "isSynchronize", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID,任务节点,审批状态验证审批记录", httpMethod = "GET", notes = "根据流程实例ID,任务节点,审批状态验证审批记录")
	public Boolean isSynchronize(@ApiParam(name = "instId", required = false) @RequestParam String instId,
			@ApiParam(name = "nodeIds", required = false) @RequestParam String nodeIds,
			@ApiParam(name = "status", required = false) @RequestParam String status,
			@ApiParam(name = "lastStatus", required = false) @RequestParam String lastStatus,
			@ApiParam(name = "lastNodeIds", required = false) @RequestParam String lastNodeIds) throws Exception {
		Boolean flag = false;
		String dbType = SQLUtil.getDbType();
		String[] nodeId = nodeIds.split(",");
		for (String str : nodeId) {
			DefaultBpmCheckOpinion defaultBpmCheckOpinion = bpmCheckOpinionManager.getBpmOpinion(instId, str, dbType);
			if (status.equals(defaultBpmCheckOpinion.getStatus()) && !lastNodeIds.equals(str)) {
				flag = true;
			} else {
				if (lastNodeIds.equals(str) && lastStatus.equals(status)) {
					flag = true;
				} else {
					flag = false;
					break;
				}
			}
		}
		return flag;
	}

	@RequestMapping(value = "doEndProcessById", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID终止流程", httpMethod = "GET", notes = "根据流程实例ID终止流程")
	public CommonResult<String> doEndProcessById(@ApiParam(name = "id", required = true, value = "流程实例id") @RequestParam String id,
			                                     @ApiParam(name = "reason", required = false, value = "终止原因") @RequestParam Optional<String> reason)
			throws Exception {
		return instanceService.doEndProcessById(id,reason);
	}

	@RequestMapping(value = "getFlowFieldList", method = RequestMethod.POST, produces = {
			"application/json;charset=utf-8" })
	@ApiOperation(value = "获取流程字段信息", notes = "获取流程字段信息", httpMethod = "POST")
	public List<Map<String, Object>> getFlowFieldList(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
		return bpmProcessInstanceManager.getFlowFieldList(queryFilter);
	}

	@RequestMapping(value = "getUrgentStateConf", method = RequestMethod.POST, produces = {
			"application/json;charset=utf-8" })
	@ApiOperation(value = "获取流程紧急状态配置", notes = "获取流程字段信息", httpMethod = "POST")
	public Map<String, Object> getUrgentStateConf(
			@ApiParam(required = true, name = "conf", value = "参数对象") @RequestBody ObjectNode obj) throws Exception {
		return iProcessService.getUrgentStateConf(obj);
	}

	@RequestMapping(value = "getUrgrntById", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID、催办人ID获取催办记录", httpMethod = "POST", notes = "根据流程实例ID、催办人ID获取催办记录")
	public PageList<BpmTaskUrgent> getUrgrntById(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter)
			throws Exception {
		return bpmTaskUrgentManager.getUrgrntById(queryFilter);
	}

	@RequestMapping(value = "getExcutorNameByInstId", method = RequestMethod.GET, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID获取当前实例的所有节点和审批人", httpMethod = "GET", notes = "根据流程实例ID获取当前实例的所有节点和审批人")
	public Object getExcutorNameByInstId(@ApiParam(name = "instId", required = true) @RequestParam String instId)
			throws Exception {
		List<String> includeIdList = new ArrayList<String>();
		includeIdList.add(instId);
		return bpmProcessInstanceManager.getNodeApprovalUsers(includeIdList);
	}

    @RequestMapping(value = "sendUrgentByInstId", method = RequestMethod.POST, produces = {
            "application/json;charset=utf-8" })
    @ApiOperation(value = "发送人工催办", notes = "发送人工催办", httpMethod = "POST")
    public CommonResult<String> sendUrgentByInstId(
            @ApiParam(required = true, name = "bpmTaskUrgent", value = "参数对象") @RequestBody BpmTaskUrgent bpmTaskUrgent)
            throws Exception {
		CommonResult<String> res=instanceService.sendUrgentByInstId(bpmTaskUrgent);
        return res;
    }


    @RequestMapping(value = "sendBpmTaskUrgent", method = RequestMethod.POST, produces = {
			"application/json;charset=utf-8" })
	@ApiOperation(value = "发送人工催办", notes = "发送人工催办", httpMethod = "POST")
	public CommonResult<String> sendBpmTaskUrgent(
			@ApiParam(required = true, name = "bpmTaskUrgent", value = "参数对象") @RequestBody BpmTaskUrgent bpmTaskUrgent)
			throws Exception {
		CommonResult<String> res=instanceService.sendBpmTaskUrgent(bpmTaskUrgent);
		return res;
	}

	@RequestMapping(value = "doNextCopyto", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "传阅回复", httpMethod = "POST", notes = "传阅回复")
	public CommonResult<String> doNextCopyto(
			@ApiParam(name = "doNextParamObject", value = "传阅回复对象", required = true) @RequestBody DoNextParamObject doNextParamObject,
			HttpServletRequest request) throws Exception {
		return iProcessService.doNextCopyto(doNextParamObject);
	}

	/**
	 * 通用流程明细页面
	 *
	 * @param
	 * @return
	 * @throws Exception ModelAndView
	 */
	@GetMapping(value = "/getMyOftenFlow")
	@ApiOperation(value = "获取我的常用流程", httpMethod = "GET", notes = "获取我的常用流程")
	public PageList<DefaultBpmDefinition> getMyOftenFlow() throws Exception {
        QueryFilter<DefaultBpmDefinition> queryFilter = QueryFilter.<DefaultBpmDefinition>build();
        queryFilter.setPageBean(new PageBean(PageBean.NO_PAGE, PageBean.WITHOUT_PAGE));
        PageList<DefaultBpmDefinition> result = iFlowService.getMyOftenFlow(queryFilter);
        return result;
	}

    /**
     * 通用流程明细页面
     *
     * @param
     * @return
     * @throws Exception ModelAndView
     */
    @GetMapping(value = "/getMyMobileOftenFlow")
    @ApiOperation(value = "获取我的移动端常用流程", httpMethod = "GET", notes = "获取我的移动端常用流程")
    public PageList<DefaultBpmDefinition> getMyMobileOftenFlow(@ApiParam(name = "supportMobile", value = "是否支持手机表单", required = false) @RequestParam(required = false) Integer supportMobile) throws Exception {
        QueryFilter<DefaultBpmDefinition> queryFilter = QueryFilter.<DefaultBpmDefinition>build();
        queryFilter.setPageBean(new PageBean(PageBean.NO_PAGE, PageBean.WITHOUT_PAGE));
        if(supportMobile != null){
            queryFilter.addFilter("support_mobile_", supportMobile, QueryOP.EQUAL);
        }
        PageList<DefaultBpmDefinition> result = iFlowService.getMyOftenFlowKeyHasAuthority(queryFilter);
        return result;
    }

    @GetMapping(value = "getMyMobileOftenFlowShowButton")
    @ApiOperation(value = "获取我的移动端常用流程时,是否有未配置移动表单", httpMethod = "GET", notes = "获取我的移动端常用流程时,是否有未配置移动表单")
    public CommonResult<Boolean> getMyMobileOftenFlowShowButton()
            throws Exception {
        QueryFilter<DefaultBpmDefinition> queryFilter = QueryFilter.<DefaultBpmDefinition>build();
        queryFilter.addFilter("support_mobile_", 0, QueryOP.EQUAL);
        queryFilter.setPageBean(new PageBean(1,0));
        PageList<DefaultBpmDefinition> result = iFlowService.getMyOftenFlow(queryFilter);
        return CommonResult.success(Long.compare(result.getTotal(),Long.valueOf("0"))>0);
    }


    @RequestMapping(value = "revokeTrans", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "并行审批任务撤回", httpMethod = "POST", notes = "并行审批任务撤回")
	public CommonResult<String> revokeTrans(
			@ApiParam(required = true, name = "revokeParamObject", value = "流转任务撤销对象") @RequestBody RevokeTransParamObject revokeTransParamObject)
			throws Exception {
		return iFlowService.revokeTrans(revokeTransParamObject);
	}

	@RequestMapping(value = "revokeCustomSign", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "签署撤回", httpMethod = "POST", notes = "顺序签署撤回")
	public CommonResult<String> revokeSignSequence(
			@ApiParam(required = true, name = "revokeParamObject", value = "撤销对象") @RequestBody CustomSignRevokeParam customSignRevokeParam)
			throws Exception {
		revokeHandler.doRevoke(customSignRevokeParam);
		return new CommonResult<String>(true, "撤回成功", "");
	}

	@RequestMapping(value = "revokeSignLine", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "并行签署撤回", httpMethod = "POST", notes = "并行签署撤回")
	public CommonResult<String> revokeSignLine(
			@ApiParam(required = true, name = "revokeParamObject", value = "撤销对象") @RequestBody RevokeSignLineParamObject revokeParamObject)
			throws Exception {
		iFlowService.revokeSignLine(revokeParamObject);
		return new CommonResult<String>(true, "撤回成功", "");
	}

	@RequestMapping(value = "getDefStatus", method = RequestMethod.GET, produces = {
	"application/json; charset=utf-8"})
	@ApiOperation(value = "定义id或者实例id或者任务id获取流程状态", httpMethod = "GET", notes = "定义id或者实例id或者任务id获取流程状态")
	public String getDefStatus(
		@ApiParam(required = false, name = "instId", value = "实例id") @RequestParam Optional<String> instId,
		@ApiParam(required = false, name = "taskId", value = "任务id") @RequestParam Optional<String> taskId,
		@ApiParam(required = false, name = "defId", value = "定义id") @RequestParam Optional<String> defId)
		throws Exception {
		return bpmProcessInstanceManager.getDefForbidStatus(defId.orElse(""),instId.orElse(""),taskId.orElse(""));
	}

	//获取节点表单
	@RequestMapping(value="printBoAndFormKey",method=RequestMethod.GET, produces = {"application/json; charset=utf-8"})
	public ObjectNode printBoAndFormKey(@ApiParam(required = false, name = "defId", value = "流程定义Id") @RequestParam(required = false) String defId,
								 @ApiParam(required = false, name = "nodeId", value = "节点Id") @RequestParam(required = false) String nodeId,
								 @ApiParam(required = true, name = "procInstId", value = "流程实例Id") @RequestParam String procInstId) throws Exception {
		ObjectNode res=instanceService.printBoAndFormKey(defId,nodeId,procInstId);
		return res;
	}


	@RequestMapping(value = "getFlowKey", method = RequestMethod.GET, produces = {
	"application/json; charset=utf-8" })
	@ApiOperation(value = "获取流程key", httpMethod = "GET", notes = "根据定义id或流程实例ID或任务id获取流程key")
	public CommonResult<String> getFlowKey(@ApiParam(name = "defId", required = true, value = "流程定义id") @RequestParam Optional<String> defId,
			@ApiParam(name = "procInstId", required = true, value = "流程实例id") @RequestParam Optional<String> procInstId,
			@ApiParam(name = "taskId", required = true, value = "任务id") @RequestParam Optional<String> taskId)
		throws Exception {
		CommonResult<String> res=instanceService.getFlowKey(defId,procInstId,taskId);
		return res;
	}

	@RequestMapping(value = "testRestful", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "testRestful", httpMethod = "POST", notes = "testRestful")
	public CommonResult<String> testRestful(
			@ApiParam(required = true, name = "params", value = "params") @RequestBody String params) throws Exception {
		System.out.println("****************************************");
		System.out.println(params);
		System.out.println("****************************************");
		return new CommonResult<String>(true, "成功。");
	}

    @RequestMapping(value = "getDefaultInfoTodo", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
    @ApiOperation(value = "待办信息", httpMethod = "POST", notes = "待办信息")
    public Map<String, Object> getDefaultInfoTodo(@ApiParam(required = true, name = "map", value = "查询参数对象") @RequestBody Map<Object,String> map) throws Exception {
		Map<String, Object> res=instanceService.getDefaultInfoTodo(map);
		return res;
    }


    @RequestMapping(value = "getInstanceCountByDefKeys", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
    @ApiOperation(value = "根据流程key获取流程定义下的实例统计信息", httpMethod = "GET", notes = "根据流程key获取流程定义下的实例统计信息")
    public List<Map<String, Object>> getInstanceCountByDefKeys(@ApiParam(required = true, name = "defKeys", value = "流程key字符串,多个逗号分隔") @RequestParam String defKeys) throws Exception {
        if (StringUtil.isEmpty(defKeys)) {
			return new ArrayList<Map<String, Object>>();
		}
        return baseService.getInstanceCountByDefKeys(defKeys.split(","));
    }

    @RequestMapping(value = "getStartNodeTaskByInstId", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
    @ApiOperation(value = "根据流程流程实例id获取该流程在发起节点的任务", httpMethod = "GET", notes = "根据流程流程实例id获取该流程在发起节点的任务")
    public DefaultBpmTask getStartNodeTaskByInstId(@ApiParam(required = true, name = "instId", value = "实例id") @RequestParam String instId) throws Exception {
        if (StringUtil.isEmpty(instId)) {
			return null;
		}
        List<DefaultBpmTask> tasks = bpmTaskManager.getByInstId(instId);
        if (BeanUtils.isEmpty(tasks)) {
        	return null;
		}
        String StartNodeId = bpmDefinitionAccessor.getStartNodes(tasks.get(0).getProcDefId()).get(0).getNodeId();
        for (DefaultBpmTask task : tasks) {
			if (task.getNodeId().equals(StartNodeId) && task.getAssigneeId().equals(baseContext.getCurrentUserId())) {
				return task;
			}
		}
        return null;
    }

	@RequestMapping(value = "getFlowFilterBusinessKeys", method = RequestMethod.POST, produces = {"application/json; charset=utf-8"})
	@ApiOperation(value = "获取表单列表根据流程过滤的业务数据主键", httpMethod = "POST", notes = "获取表单列表根据流程过滤的业务数据主键")
	public Set<String> getFlowFilterBusinessKeys(@ApiParam(required = true, name = "filterTypes", value = "过滤类型") @RequestBody List<String> filterTypes,
												 @ApiParam(required = true, name = "entName", value = "实体名") @RequestParam("entName") String entName,
												 @ApiParam(required = true, name = "isNumberPk", value = "是否数字类型主键") @RequestParam("isNumberPk") boolean isNumberPk) {
		return bpmBusLinkManager.getFlowFilterBusinessKeys(filterTypes, entName, isNumberPk);
	}

	@PostMapping(value = "getInstanceByPks",produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "根据bo数据ID获取表单列表流程信息", httpMethod = "POST", notes = "根据bo数据ID获取表单列表流程信息")
	public CommonResult<Map<String, ObjectNode>> getInstanceByPks(@ApiParam(name = "boDefAlias") @RequestParam String boDefAlias,
                                                                  @ApiParam(name = "pks", value = "表单数据ID集合")@RequestBody List<String> pks,
                                                                  @ApiParam(name = "flowKey") @RequestParam(required = false) String flowKey)throws Exception{
		return new CommonResult<Map<String, ObjectNode>>(true, "", iFlowService.getInstanceByPks(pks, boDefAlias,flowKey));
	}

	@PostMapping(value = "getDataTemplateButtonPermission", produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程实例ID获取表单列表按钮权限", httpMethod = "POST", notes = "根据流程实例ID获取表单列表按钮权限")
	public CommonResult<List<DataTemplateButtonPermissionVo>> getDataTemplateButtonPermission(@ApiParam(name = "instIds", value = "流程实例ID集合") @RequestBody List<String> instIds,
																							  @ApiParam(name = "permissionTypes", value = "获取类型") @RequestParam String permissionTypes)throws Exception {
		return new CommonResult<>(true, "获取成功", iFlowService.getDataTemplateButtonPermission(instIds, permissionTypes));
	}

	@RequestMapping(value = "getDoneListByAccount", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取用户经办的流程实例", httpMethod = "POST", notes = "获取用户的已办事宜,参数status表示流程状态,不填表示查询所有")
	public PageList<Map<String, Object>> getDoneListByAccount(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(name="account",value="用户账号", required = true) @RequestParam String account,
			@ApiParam(name = "status", value = "流程状态", allowableValues = "running,end,manualend,cancel,back,revoke,revokeToStart", required = false) @RequestParam(required = false) String status,
			HttpServletResponse response) throws Exception {
		return iFlowService.getDoneInstList(account, queryFilter, status).get();
	}

	@RequestMapping(value="divertDoneTask",method=RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "转移已办给用户", httpMethod = "POST", notes = "转移任务给用户")
	public CommonResult<String> divertDoneTask(@ApiParam(name="map",value="参数", required = true) @RequestBody Map<String,Object> map) throws Exception{
		return iFlowService.divertDoneTask(map);
	}

	@PostMapping(value = "getDoneCountByAccount", produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "获取用户经办的流程实例数", httpMethod = "POST", notes = "获取用户的已办事宜,参数status表示流程状态,不填表示查询所有")
	public List<Map<String, Object>> getDoneCountByAccount(
			@ApiParam(required = true, name = "queryFilter", value = "查询参数对象") @RequestBody QueryFilter queryFilter,
			@ApiParam(name="account",value="用户账号", required = true) @RequestParam String account,
			@ApiParam(name = "status", value = "流程状态数", allowableValues = "running,end,manualend,cancel,back,revoke,revokeToStart", required = false) @RequestParam(required = false) String status,
			HttpServletResponse response) throws Exception {
		return iFlowService.getDoneInstCount(account, queryFilter, status);
	}

	@RequestMapping(value = "getStartFormKeyByFlowKey",produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "根据流程key获取主板本发起时的表单", httpMethod = "GET", notes = "根据流程key获取主板本发起时的表单")
	public CommonResult<String> getStartFormKeyByFlowKey(@ApiParam(required = true, name = "flowKey", value = "流程key") @RequestParam String flowKey)throws Exception{
    	DefaultBpmDefinition bpmDefinition = bpmDefinitionManager.getMainByDefKey(flowKey, false);
    	if(BeanUtils.isEmpty(bpmDefinition)) {
    		return new CommonResult<String>(false, "流程key:"+flowKey+" 不存在");
    	}
    	BpmFormService bpmFormService = BpmFormFactory.getFormService(FormType.PC);
		BpmNodeForm nodeForm = bpmFormService.getByDefId(bpmDefinition.getDefId());
		if(BeanUtils.isEmpty(nodeForm)) {
			return new CommonResult<String>(false, "流程还未设置表单");
		}
		return new CommonResult<String>(true, "获取成功!", nodeForm.getForm().getFormValue());
	}


	@RequestMapping(value = "meetingRoomApply", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "会议申请绑定流程发起", httpMethod = "POST", notes = "会议申请绑定流程发起")
	public CommonResult<String> meetingRoomApply(@ApiParam(name = "mappingObject", value = "会议申请信息字段映射", required = true) @RequestBody JsonNode mappingObject,
			@ApiParam(name="flowKey",value="流程key") @RequestParam(value="flowKey", required = true) String flowKey)
			throws Exception {
		return iProcessService.meetingRoomApply(mappingObject, flowKey);
	}

	@RequestMapping(value = "getMyDraftCount", method = RequestMethod.POST, produces = {"application/json; charset=utf-8"})
	@ApiOperation(value = "获取我的草稿分类数量", httpMethod = "POST", notes = "获取我的草稿分类数量")
	public List<Map<String, Object>> getMyDraftCount(@ApiParam(name = "queryFilter", value = "通用查询器") @RequestBody QueryFilter queryFilter) {
		return bpmProcessInstanceManager.getUserDraftCount(queryFilter, ContextUtil.getCurrentUserId());
	}

	/**
	 * 审批路径推演
	 * @param previewProcessVo
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "previewProcess", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "获取节点审批路径", httpMethod = "POST", notes = "获取节点审批路径")
	public Object previewProcess(@RequestBody @Valid PreviewProcessVo previewProcessVo) throws Exception {
        return previewProcessManager.previewProcess(previewProcessVo);
		//return previewProcessService.previewProcess(previewProcessVo);
	}

	@RequestMapping(value = "getSubInstanceList", method = RequestMethod.GET, produces = {"application/json; charset=utf-8" })
	@ApiOperation(value = "获取流程实例明细", httpMethod = "GET", notes = "获取流程实例明细")
	public List<BpmProcessInstance> getSubInstanceList(
			@ApiParam(name = "parentInstId", value = "流程实例id", required = true) @RequestParam String parentInstId,
			@ApiParam(name = "nodeId", value = "节点id") @RequestParam String nodeId) throws Exception {
		return iFlowService.getSubInstanceList(parentInstId, nodeId);
	}
	
	@RequestMapping(value = "getSubDefId", method = RequestMethod.GET, produces = {"application/json; charset=utf-8" })
	@ApiOperation(value = "获取流程实例明细", httpMethod = "GET", notes = "获取流程实例明细")
	public CommonResult<String> getSubDefId(
			@ApiParam(name = "parentDefId", value = "父流程定义id", required = true) @RequestParam Optional<String> parentDefId,
			@ApiParam(name = "parentInstId", value = "父流程实例id", required = true) @RequestParam Optional<String> parentInstId,
			@ApiParam(name = "nodeId", value = "节点id") @RequestParam String nodeId) throws Exception {
		return new CommonResult<>(true,"",iFlowService.getSubDefId(parentDefId.orElse(""),parentInstId.orElse(""), nodeId));
	}

    @RequestMapping(value = "getCurUserFlowType", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
    @ApiOperation(value = "获取当前用户有权限的流程分类信息", httpMethod = "GET", notes = "获取当前用户有权限的流程分类信息")
    public CommonResult<List<FlowTypeVo>> getCurUserFlowType() throws Exception {
        return CommonResult.success(iFlowService.getCurUserFlowType());
    }
}