TemplateController.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. package jnpf.flowable.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import cn.hutool.core.util.ObjectUtil;
  4. import com.google.common.collect.ImmutableList;
  5. import io.swagger.v3.oas.annotations.Operation;
  6. import io.swagger.v3.oas.annotations.Parameter;
  7. import io.swagger.v3.oas.annotations.Parameters;
  8. import io.swagger.v3.oas.annotations.tags.Tag;
  9. import jakarta.validation.Valid;
  10. import jnpf.base.ActionResult;
  11. import jnpf.base.controller.SuperController;
  12. import jnpf.base.entity.DictionaryDataEntity;
  13. import jnpf.base.entity.VisualdevEntity;
  14. import jnpf.base.vo.DownloadVO;
  15. import jnpf.base.vo.ListVO;
  16. import jnpf.base.vo.PageListVO;
  17. import jnpf.base.vo.PaginationVO;
  18. import jnpf.constant.MsgCode;
  19. import jnpf.emnus.ModuleTypeEnum;
  20. import jnpf.exception.WorkFlowException;
  21. import jnpf.flowable.entity.TemplateEntity;
  22. import jnpf.flowable.entity.TemplateJsonEntity;
  23. import jnpf.flowable.enums.TemplateStatueEnum;
  24. import jnpf.flowable.model.candidates.CandidateUserVo;
  25. import jnpf.flowable.model.template.*;
  26. import jnpf.flowable.model.templatejson.FlowListModel;
  27. import jnpf.flowable.model.templatejson.TemplateJsonInfoVO;
  28. import jnpf.flowable.model.templatejson.TemplateJsonSelectVO;
  29. import jnpf.flowable.model.templatenode.TemplateNodeCrFrom;
  30. import jnpf.flowable.model.templatenode.TemplateNodeUpFrom;
  31. import jnpf.flowable.model.util.FlowNature;
  32. import jnpf.flowable.service.*;
  33. import jnpf.flowable.util.ServiceUtil;
  34. import jnpf.flowable.util.TaskUtil;
  35. import jnpf.model.FlowWorkListVO;
  36. import jnpf.permission.entity.UserEntity;
  37. import jnpf.permission.model.authorize.AuthorizeVO;
  38. import jnpf.permission.model.user.WorkHandoverModel;
  39. import jnpf.util.*;
  40. import jnpf.util.context.RequestContext;
  41. import jnpf.workflow.service.TemplateApi;
  42. import lombok.extern.slf4j.Slf4j;
  43. import org.springframework.beans.factory.annotation.Autowired;
  44. import org.springframework.http.MediaType;
  45. import org.springframework.web.bind.annotation.*;
  46. import org.springframework.web.multipart.MultipartFile;
  47. import java.util.*;
  48. import java.util.stream.Collectors;
  49. @Slf4j
  50. @Tag(name = "流程模板", description = "flowTemplate")
  51. @RestController
  52. @RequestMapping("/api/workflow/template")
  53. public class TemplateController extends SuperController<TemplateService, TemplateEntity> implements TemplateApi {
  54. @Autowired
  55. private TemplateService templateService;
  56. @Autowired
  57. private TemplateJsonService templateJsonService;
  58. @Autowired
  59. private ServiceUtil serviceUtil;
  60. @Autowired
  61. private TaskUtil taskUtil;
  62. @Autowired
  63. private CommonService commonService;
  64. @Autowired
  65. private OperatorService operatorService;
  66. @Autowired
  67. private TemplateUseNumService templateUseNumService;
  68. /**
  69. * 流程列表
  70. *
  71. * @param pagination 分页模型
  72. * @return
  73. */
  74. @Operation(summary = "流程列表")
  75. @GetMapping
  76. public ActionResult<PageListVO<TemplatePageLisVO>> list(TemplatePagination pagination) {
  77. pagination.setSystemId(serviceUtil.getSystemCodeById(RequestContext.getAppCode()));
  78. List<TemplateEntity> list = templateService.getList(pagination);
  79. List<DictionaryDataEntity> dictionList = serviceUtil.getDictionName(list.stream().map(TemplateEntity::getCategory).collect(Collectors.toList()));
  80. List<UserEntity> userList = serviceUtil.getUserName(list.stream().map(TemplateEntity::getCreatorUserId).collect(Collectors.toList()));
  81. List<TemplatePageLisVO> listVO = new ArrayList<>();
  82. for (TemplateEntity entity : list) {
  83. TemplatePageLisVO vo = JsonUtil.getJsonToBean(entity, TemplatePageLisVO.class);
  84. DictionaryDataEntity dataEntity = dictionList.stream().filter(t -> t.getId().equals(entity.getCategory())).findFirst().orElse(null);
  85. vo.setCategory(dataEntity != null ? dataEntity.getFullName() : "");
  86. UserEntity userEntity = userList.stream().filter(t -> t.getId().equals(entity.getCreatorUserId())).findFirst().orElse(null);
  87. vo.setCreatorUser(userEntity != null ? userEntity.getRealName() + "/" + userEntity.getAccount() : "");
  88. listVO.add(vo);
  89. }
  90. PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
  91. return ActionResult.page(listVO, paginationVO);
  92. }
  93. /**
  94. * 流程列表
  95. *
  96. * @param pagination 分页模型
  97. * @return
  98. */
  99. @Operation(summary = "流程列表")
  100. @GetMapping("/Selector")
  101. public ActionResult<PageListVO<TemplatePageVo>> selector(TemplatePagination pagination) {
  102. List<TemplatePageVo> list = templateService.getSelector(pagination);
  103. PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
  104. return ActionResult.page(list, paginationVO);
  105. }
  106. @Operation(summary = "常用流程前六")
  107. @GetMapping("/useNumSelect")
  108. public ActionResult<List<TemplateUseNumVo>> useNumSelector() {
  109. AuthorizeVO authorize = serviceUtil.getAuthorizeByUser();
  110. List<TemplateUseNumVo> menuUseNum = templateUseNumService.getMenuUseNum(0, authorize.getFlowIdList());
  111. return ActionResult.success(menuUseNum);
  112. }
  113. @Operation(summary = "用户访问流程次数记录")
  114. @PostMapping("/useTemplateNum/{templateId}")
  115. public ActionResult useTemplateNum(@PathVariable String templateId) {
  116. templateUseNumService.insertOrUpdateUseNum(templateId);
  117. return ActionResult.success();
  118. }
  119. @Operation(summary = "用户访问流程次数清空")
  120. @DeleteMapping("/useTemplateNum/{templateId}")
  121. public ActionResult deleteUseTemplateNum(@PathVariable String templateId) {
  122. String userId = UserProvider.getUser().getUserId();
  123. templateUseNumService.deleteUseNum(templateId, userId);
  124. return ActionResult.success();
  125. }
  126. /**
  127. * 常用流程树
  128. */
  129. @Operation(summary = "常用流程树")
  130. @GetMapping("/CommonFlowTree")
  131. public ActionResult getTreeCommon() {
  132. ListVO<TemplateTreeListVo> vo = new ListVO<>();
  133. vo.setList(templateService.getTreeCommon());
  134. return ActionResult.success(vo);
  135. }
  136. /**
  137. * 树形列表
  138. */
  139. @Operation(summary = "树形列表")
  140. @GetMapping("/TreeList")
  141. public ActionResult<ListVO<TemplateTreeListVo>> treeList(@RequestParam(value = "formType", required = false) Integer formType) {
  142. ListVO<TemplateTreeListVo> vo = new ListVO<>();
  143. vo.setList(templateService.treeList(formType));
  144. return ActionResult.success(vo);
  145. }
  146. /**
  147. * 流程基础信息
  148. *
  149. * @param id 主键
  150. * @return
  151. */
  152. @Operation(summary = "流程基础信息")
  153. @GetMapping("/{id}")
  154. @Parameters({
  155. @Parameter(name = "id", description = "主键", required = true),
  156. })
  157. public ActionResult<TemplateInfoVO> info(@PathVariable("id") String id) throws WorkFlowException {
  158. TemplateEntity entity = templateService.getInfo(id);
  159. TemplateInfoVO vo = JsonUtil.getJsonToBean(entity, TemplateInfoVO.class);
  160. return ActionResult.success(vo);
  161. }
  162. /**
  163. * 流程版本列表
  164. *
  165. * @param id 主键
  166. * @return
  167. */
  168. @Operation(summary = "流程版本列表")
  169. @GetMapping("/Version/{id}")
  170. @Parameters({
  171. @Parameter(name = "id", description = "主键", required = true),
  172. })
  173. public ActionResult<List<TemplateJsonSelectVO>> version(@PathVariable("id") String id) throws WorkFlowException {
  174. List<TemplateJsonEntity> list = templateJsonService.getList(id);
  175. List<TemplateJsonSelectVO> listVO = new ArrayList<>();
  176. for (TemplateJsonEntity jsonEntity : list) {
  177. TemplateJsonSelectVO vo = JsonUtil.getJsonToBean(jsonEntity, TemplateJsonSelectVO.class);
  178. vo.setFlowVersion(jsonEntity.getVersion());
  179. vo.setFullName("流程版本V" + jsonEntity.getVersion());
  180. listVO.add(vo);
  181. }
  182. return ActionResult.success(listVO);
  183. }
  184. /**
  185. * 流程模板信息
  186. *
  187. * @param id 主键
  188. * @return
  189. */
  190. @Operation(summary = "流程模板信息")
  191. @GetMapping("/Info/{id}")
  192. @Parameters({
  193. @Parameter(name = "id", description = "主键", required = true),
  194. })
  195. public ActionResult<TemplateJsonInfoVO> templateJsonInfo(@PathVariable("id") String id) throws WorkFlowException {
  196. return ActionResult.success(templateJsonService.getInfoVo(id));
  197. }
  198. /**
  199. * 新建流程
  200. *
  201. * @param form 流程模型
  202. * @return
  203. */
  204. @Operation(summary = "新建流程")
  205. @PostMapping
  206. @Parameters({
  207. @Parameter(name = "form", description = "流程模型", required = true),
  208. })
  209. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  210. public ActionResult create(@RequestBody @Valid TemplateNodeCrFrom form) throws WorkFlowException {
  211. TemplateEntity entity = JsonUtil.getJsonToBean(form, TemplateEntity.class);
  212. String flowConfig = form.getFlowConfig();
  213. FlowConfigModel config = JsonUtil.getJsonToBean(flowConfig, FlowConfigModel.class);
  214. config = config == null ? new FlowConfigModel() : config;
  215. entity.setVisibleType(config.getVisibleType());
  216. templateService.create(entity, form.getFlowXml(), form.getFlowNodes());
  217. return ActionResult.success(MsgCode.SU001.get(), entity.getId());
  218. }
  219. /**
  220. * 更新流程
  221. *
  222. * @param id 主键
  223. * @param form 流程模型
  224. * @return
  225. */
  226. @Operation(summary = "更新流程")
  227. @PutMapping("/{id}")
  228. @Parameters({
  229. @Parameter(name = "id", description = "主键", required = true),
  230. @Parameter(name = "form", description = "流程模型", required = true),
  231. })
  232. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  233. public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid TemplateNodeUpFrom form) throws WorkFlowException {
  234. TemplateEntity entity = JsonUtil.getJsonToBean(form, TemplateEntity.class);
  235. String flowConfig = form.getFlowConfig();
  236. FlowConfigModel config = JsonUtil.getJsonToBean(flowConfig, FlowConfigModel.class);
  237. config = config == null ? new FlowConfigModel() : config;
  238. entity.setVisibleType(config.getVisibleType());
  239. TemplateEntity info = templateService.getInfo(id);
  240. entity.setSystemId(info.getSystemId());
  241. templateService.update(id, entity);
  242. return ActionResult.success(MsgCode.SU004.get());
  243. }
  244. /**
  245. * 更新流程类型
  246. *
  247. * @param id 主键
  248. */
  249. @Operation(summary = "更新流程类型")
  250. @PutMapping("/{id}/UpdateType")
  251. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  252. public ActionResult updateType(@PathVariable("id") String id) throws WorkFlowException {
  253. TemplateEntity entity = templateService.getInfo(id);
  254. entity.setType(FlowNature.Standard);
  255. templateService.updateById(entity);
  256. return ActionResult.success(MsgCode.SU004.get());
  257. }
  258. /**
  259. * 删除流程引擎
  260. *
  261. * @param id 主键
  262. * @return
  263. */
  264. @Operation(summary = "删除流程引擎")
  265. @DeleteMapping("/{id}")
  266. @Parameters({
  267. @Parameter(name = "id", description = "主键", required = true),
  268. })
  269. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  270. public ActionResult delete(@PathVariable("id") String id) throws WorkFlowException {
  271. TemplateEntity entity = templateService.getInfo(id);
  272. templateService.delete(entity);
  273. return ActionResult.success(MsgCode.SU003.get());
  274. }
  275. /**
  276. * 删除流程版本
  277. *
  278. * @param id 主键
  279. * @return
  280. */
  281. @Operation(summary = "删除流程版本")
  282. @DeleteMapping("/Info/{id}")
  283. @Parameters({
  284. @Parameter(name = "id", description = "主键", required = true),
  285. })
  286. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  287. public ActionResult deleteInfo(@PathVariable("id") String id) throws WorkFlowException {
  288. TemplateJsonEntity entity = templateJsonService.getInfo(id);
  289. List<TemplateJsonEntity> list = templateJsonService.getList(entity.getTemplateId());
  290. if (list.size() == 1) {
  291. return ActionResult.fail(MsgCode.WF071.get());
  292. }
  293. if (Objects.equals(entity.getState(), 1)) {
  294. return ActionResult.fail(MsgCode.WF072.get());
  295. }
  296. if (Objects.equals(entity.getState(), 2)) {
  297. return ActionResult.fail(MsgCode.WF073.get());
  298. }
  299. templateJsonService.delete(ImmutableList.of(id));
  300. return ActionResult.success(MsgCode.SU003.get());
  301. }
  302. /**
  303. * 上架下架
  304. *
  305. * @param id 主键
  306. * @param fo 参数
  307. */
  308. @Operation(summary = "上架下架")
  309. @PutMapping("/{id}/UpDownShelf")
  310. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  311. public ActionResult updateStatus(@PathVariable("id") String id, @RequestBody UpDownModel fo) throws WorkFlowException {
  312. TemplateEntity entity = templateService.getInfo(id);
  313. if (ObjectUtil.equals(fo.getIsUp(), 0)) {
  314. entity.setStatus(TemplateStatueEnum.up.getCode());
  315. } else {
  316. entity.setStatus(ObjectUtil.equals(fo.getIsHidden(), 0) ? TemplateStatueEnum.downContinue.getCode() : TemplateStatueEnum.downHidden.getCode());
  317. }
  318. templateService.updateById(entity);
  319. return ActionResult.success(MsgCode.SU005.get());
  320. }
  321. /**
  322. * 复制流程引擎
  323. *
  324. * @param id 主键
  325. * @return
  326. */
  327. @Operation(summary = "复制流程引擎")
  328. @PostMapping("/{id}/Actions/Copy")
  329. @Parameters({
  330. @Parameter(name = "id", description = "主键", required = true),
  331. })
  332. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  333. public ActionResult copy(@PathVariable("id") String id) throws WorkFlowException {
  334. TemplateEntity entity = templateService.getInfo(id);
  335. templateService.copy(entity);
  336. return ActionResult.success(MsgCode.SU007.get());
  337. }
  338. /**
  339. * 复制流程版本
  340. *
  341. * @param id 主键
  342. * @return
  343. */
  344. @Operation(summary = "复制流程版本")
  345. @PostMapping("/Info/{id}")
  346. @Parameters({
  347. @Parameter(name = "id", description = "主键", required = true),
  348. })
  349. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  350. public ActionResult copyVersion(@PathVariable("id") String id) throws WorkFlowException {
  351. String templateJsonId = RandomUtil.uuId();
  352. TemplateJsonEntity entity = templateJsonService.getInfo(id);
  353. templateJsonService.copy(entity, templateJsonId);
  354. return ActionResult.success(MsgCode.SU007.get(), templateJsonId);
  355. }
  356. /**
  357. * 流程保存或发布
  358. *
  359. * @return
  360. */
  361. @Operation(summary = "流程保存或发布")
  362. @PostMapping("/Save")
  363. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  364. public ActionResult save(@RequestBody @Valid TemplateNodeUpFrom form) throws WorkFlowException {
  365. templateJsonService.save(form);
  366. return ActionResult.success(MsgCode.SU004.get());
  367. }
  368. /**
  369. * 导出
  370. *
  371. * @param id 主键
  372. */
  373. @Operation(summary = "导出")
  374. @GetMapping("/{id}/Actions/Export")
  375. @Parameters({
  376. @Parameter(name = "id", description = "主键", required = true),
  377. })
  378. public ActionResult<DownloadVO> export(@PathVariable("id") String id) throws WorkFlowException {
  379. TemplateExportModel model = templateService.export(id);
  380. DownloadVO downloadVO = serviceUtil.exportData(model);
  381. return ActionResult.success(downloadVO);
  382. }
  383. /**
  384. * 导入
  385. *
  386. * @param file 文件
  387. * @param type 类型
  388. */
  389. @Operation(summary = "导入")
  390. @PostMapping(value = "/Actions/Import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
  391. @SaCheckPermission(value = {"onlineDev.flowEngine"})
  392. public ActionResult<String> importData(@RequestPart("file") MultipartFile file, @RequestParam("type") String type) throws WorkFlowException {
  393. //判断是否为.json结尾
  394. if (FileUtil.existsSuffix(file, ModuleTypeEnum.FLOW_FLOWENGINE.getTableName())) {
  395. return ActionResult.fail(MsgCode.IMP002.get());
  396. }
  397. //获取文件内容
  398. String fileContent = FileUtil.getFileContent(file);
  399. TemplateExportModel model = JsonUtil.getJsonToBean(fileContent, TemplateExportModel.class);
  400. if (ObjectUtil.isEmpty(model.getTemplate())) {
  401. return ActionResult.fail(MsgCode.IMP004.get());
  402. }
  403. templateService.importData(model, type);
  404. return ActionResult.success(MsgCode.IMP001.get());
  405. }
  406. /**
  407. * 委托流程选择展示
  408. *
  409. * @param ids 版本主键集合
  410. */
  411. @Operation(summary = "委托流程选择展示")
  412. @PostMapping("/GetFlowList")
  413. public ActionResult getFlowList(@RequestBody List<String> ids) {
  414. List<TemplateEntity> list = templateService.getList(ids);
  415. List<FlowListModel> voList = new ArrayList<>();
  416. for (TemplateEntity templateEntity : list) {
  417. FlowListModel model = new FlowListModel();
  418. model.setId(templateEntity.getId());
  419. model.setFullName(templateEntity.getFullName());
  420. model.setEnCode(templateEntity.getEnCode());
  421. voList.add(model);
  422. }
  423. return ActionResult.success(voList);
  424. }
  425. /**
  426. * 子流程表单信息
  427. *
  428. * @param id 版本主键
  429. */
  430. @Operation(summary = "子流程表单信息")
  431. @GetMapping("/{id}/FormInfo")
  432. public ActionResult formInfo(@PathVariable("id") String id) throws WorkFlowException {
  433. VisualdevEntity formInfo = templateJsonService.getFormInfo(id);
  434. return ActionResult.success(formInfo);
  435. }
  436. /**
  437. * 根据表单主键获取流程
  438. *
  439. * @param formId 表单主键
  440. */
  441. @Operation(summary = "根据表单主键获取流程")
  442. @GetMapping("/{formId}/FlowList")
  443. public ActionResult getByFormId(@PathVariable("formId") String formId, Boolean start) {
  444. FlowByFormModel model = templateService.getFlowByFormId(formId, start);
  445. return ActionResult.success(model);
  446. }
  447. /**
  448. * 子流程可发起人员
  449. *
  450. * @param id 版本主键
  451. * @param pagination 分页参数
  452. */
  453. @Operation(summary = "子流程可发起人员")
  454. @GetMapping("/{id}/SubFlowUserList")
  455. public ActionResult getSubFlowUserList(@PathVariable("id") String id, TemplatePagination pagination) throws WorkFlowException {
  456. List<UserEntity> list = templateService.getSubFlowUserList(id, pagination);
  457. List<String> userIdList = list.stream().map(UserEntity::getId).collect(Collectors.toList());
  458. List<CandidateUserVo> voList = taskUtil.getUserModel(userIdList, pagination);
  459. PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
  460. return ActionResult.page(voList, paginationVO);
  461. }
  462. /**
  463. * 常用流程
  464. *
  465. * @param id 版本主键
  466. */
  467. @Operation(summary = "常用流程")
  468. @PostMapping("/SetCommonFlow/{id}")
  469. public ActionResult SetCommonFlow(@PathVariable("id") String id) {
  470. int flag = commonService.setCommonFLow(id);
  471. if (flag == 2) {
  472. return ActionResult.success(MsgCode.SU021.get());
  473. }
  474. return ActionResult.success(MsgCode.SU016.get());
  475. }
  476. /**
  477. * 常用流程列表
  478. *
  479. */
  480. @Operation(summary = "常用流程")
  481. @GetMapping("/getCommonFlowList")
  482. public ActionResult getCommonFlowList(TemplatePagination pagination) {
  483. pagination.setSystemId(serviceUtil.getSystemCodeById(RequestContext.getAppCode()));
  484. List<TemplatePageVo> commonList = templateService.getCommonList(pagination);
  485. return ActionResult.success(new ListVO<>(commonList));
  486. }
  487. /**
  488. * 根据模板主键获取表单
  489. *
  490. * @param templateId 流程模板主键
  491. */
  492. @Operation(summary = "根据模板主键获取表单")
  493. @GetMapping("/StartForm/{templateId}")
  494. public ActionResult getFormByTemplateId(@PathVariable("templateId") String templateId) throws WorkFlowException {
  495. return ActionResult.success(templateService.getFormByTemplateId(templateId));
  496. }
  497. /**
  498. * 根据模板主键获取表单主键和流程版本主键
  499. *
  500. * @param templateId 流程模板主键
  501. */
  502. @Operation(summary = "根据模板主键获取表单主键和流程版本主键")
  503. @GetMapping("/StartFormId/{templateId}")
  504. public ActionResult getFormIdAndFlowIdByTemplateId(@PathVariable("templateId") String templateId) throws WorkFlowException {
  505. return ActionResult.success(templateService.getFormIdAndFlowId(templateId));
  506. }
  507. @Override
  508. public FlowByFormModel getFlowByFormId(String formId, Boolean start) {
  509. return templateService.getFlowByFormId(formId, start);
  510. }
  511. @Override
  512. public String getFormByFlowId(String templateId) {
  513. String formId = "";
  514. try {
  515. VisualdevEntity entity = templateService.getFormByTemplateId(templateId);
  516. if (null == entity) {
  517. throw new WorkFlowException(MsgCode.VS412.get());
  518. }
  519. formId = entity.getId();
  520. } catch (Exception e) {
  521. log.error("流程获取表单失败: {}", e.getMessage());
  522. }
  523. return formId;
  524. }
  525. @Override
  526. public List<String> getFlowIdsByTemplateId(String templateId) {
  527. List<TemplateJsonEntity> list = templateJsonService.getList(templateId);
  528. return list.stream().map(TemplateJsonEntity::getId).distinct().collect(Collectors.toList());
  529. }
  530. @Override
  531. public List<TemplateJsonEntity> getFlowIdsByTemplate(String templateId) {
  532. return templateJsonService.getList(templateId);
  533. }
  534. @Override
  535. public List<TemplateEntity> getListByFlowIds(List<String> flowId) {
  536. return templateService.getList(flowId);
  537. }
  538. @Override
  539. public List<TemplateTreeListVo> treeListWithPower() {
  540. return templateService.treeListWithPower();
  541. }
  542. @Override
  543. public FlowWorkListVO flowWork(String fromId) {
  544. return operatorService.flowWork(fromId);
  545. }
  546. @Override
  547. public boolean flowWork(WorkHandoverModel workHandoverModel) {
  548. return operatorService.flowWork(workHandoverModel);
  549. }
  550. @Override
  551. public List<String> getFormList() {
  552. return templateService.getFormList();
  553. }
  554. @Override
  555. public String getTemplateByVersionId(String flowId) {
  556. String templateId = "";
  557. TemplateJsonEntity byId = templateJsonService.getById(flowId);
  558. if (byId != null) {
  559. templateId = byId.getTemplateId();
  560. }
  561. return templateId;
  562. }
  563. @Override
  564. public Map<String, String> getFlowFormMap() {
  565. return templateService.getFlowFormMap();
  566. }
  567. @Override
  568. public List<TemplatePageVo> getCommonList(TemplatePagination pagination) {
  569. return templateService.getCommonList(pagination);
  570. }
  571. @Override
  572. public List<TemplateUseNumVo> getMenuUseNum(int i, List<String> authFlowList) {
  573. return templateUseNumService.getMenuUseNum(i, authFlowList);
  574. }
  575. @Override
  576. public List<TemplateEntity> getListByCreUser(String creUser) {
  577. return templateService.getListByCreUser(creUser);
  578. }
  579. }