package com.hotent.bpmModel.controller; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.fasterxml.jackson.databind.node.ObjectNode; import com.hotent.base.annotation.ApiGroup; import com.hotent.base.annotation.AvoidRepeatableCommit; import com.hotent.base.constants.ApiGroupConsts; import com.hotent.base.constants.SQLConst; import com.hotent.base.controller.BaseController; import com.hotent.base.exception.BaseException; import com.hotent.base.feign.FormFeignService; import com.hotent.base.model.CommonResult; import com.hotent.base.model.ImportCheckResult; import com.hotent.base.query.FieldRelation; import com.hotent.base.query.PageList; import com.hotent.base.query.QueryFilter; import com.hotent.base.query.QueryOP; import com.hotent.base.util.*; import com.hotent.base.util.time.DateFormatUtil; import com.hotent.bpm.api.constant.NodeType; import com.hotent.bpm.api.constant.ScriptType; import com.hotent.bpm.api.model.process.def.BpmDefExtProperties; import com.hotent.bpm.api.model.process.def.BpmDefinition; import com.hotent.bpm.api.model.process.def.BpmProcessDef; import com.hotent.bpm.api.model.process.def.BpmProcessDefExt; import com.hotent.bpm.api.model.process.nodedef.BpmNodeDef; import com.hotent.bpm.api.model.process.nodedef.BpmNodeDefComparator; import com.hotent.bpm.api.model.process.nodedef.ext.UserTaskNodeDef; import com.hotent.bpm.api.model.process.nodedef.ext.extmodel.Button; import com.hotent.bpm.api.plugin.core.context.PluginParse; import com.hotent.bpm.api.service.BpmDefinitionAccessor; import com.hotent.bpm.api.service.BpmDefinitionService; import com.hotent.bpm.engine.def.impl.handler.ButtonsBpmDefXmlHandler; import com.hotent.bpm.model.def.BpmDefXmlList; import com.hotent.bpm.params.SearchDefNodeVO; import com.hotent.bpm.persistence.manager.BpmDefAuthorizeManager; import com.hotent.bpm.persistence.manager.BpmDefinitionManager; import com.hotent.bpm.persistence.model.BpmDefAuthorizeType; import com.hotent.bpm.persistence.model.DefaultBpmDefinition; import com.hotent.bpm.plugin.task.userassign.context.UserAssignPluginContext; import com.hotent.bpmModel.manager.BpmDefService; import com.hotent.bpmModel.manager.BpmDefTransform; import com.hotent.bpmModel.manager.BpmOftenFlowManager; import com.hotent.bpmModel.params.*; import com.hotent.uc.api.impl.util.ContextUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.http.client.ClientProtocolException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartHttpServletRequest; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.bind.JAXBException; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; /** * 描述:流程定义管理 * @company 广州宏天软件有限公司 * @author wanghb * @email wanghb@jee-soft.cn * @date 2018年6月26日 */ @RestController @RequestMapping("/flow/def/v1/") @Api(tags="流程定义") @ApiGroup(group= {ApiGroupConsts.GROUP_BPM}) public class DefController extends BaseController { @Resource BpmDefinitionManager bpmDefinitionManager; @Resource BpmDefinitionService bpmDefinitionService; @Resource BpmDefinitionAccessor bpmDefinitionAccessor; @Resource BpmDefAuthorizeManager bpmDefAuthorizeManager; @Resource BpmDefTransform bpmDefTransform; @Resource ButtonsBpmDefXmlHandler buttonsBpmDefXmlHandler; @Autowired private BpmOftenFlowManager bpmOftenFlowManager; @Autowired private BpmDefService bpmDefService; @SuppressWarnings("unused") private final static String ROOT_PATH = "attachFiles" + File.separator + "tempZip"; // 导入和导出的文件操作根目录 /** * 返回流程设计生成的BPMNxml * * @param request * @param response * @return * @throws Exception */ @RequestMapping(value="bpmnXml",method=RequestMethod.GET, produces={"application/xml; charset=UTF-8"}) @ApiOperation(value = "返回流程设计生成的BPMNxml", httpMethod = "GET", notes = "返回流程设计生成的BPMNxml") public Object bpmnXml( @ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception { if (StringUtils.isEmpty(defId)) { return "no def input"; } DefaultBpmDefinition po = bpmDefinitionManager.getById(defId); String bpmnXml = po.getBpmnXml(); return bpmnXml; } /** * 返回流程设计的xml * * @param request * @param response * @return * @throws Exception */ @RequestMapping(value="designXml",method=RequestMethod.GET, produces={"application/xml; charset=UTF-8"}) @ApiOperation(value = "返回流程设计的xml", httpMethod = "GET", notes = "返回流程设计的xml") public Object designXml( @ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception { if (StringUtils.isEmpty(defId)) { return "no def input"; } DefaultBpmDefinition po = bpmDefinitionManager.getById(defId); String bpmnXml = po.getDefXml(); return bpmnXml; } @RequestMapping(value="getJson",method=RequestMethod.GET, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "根据流程定义Key获取流程定义对象", httpMethod = "GET", notes = "根据流程定义Key获取流程定义对象") public DefaultBpmDefinition getJson(@ApiParam(name="defKey",value="流程定义Key", required = true) @RequestParam String defKey){ DefaultBpmDefinition po = bpmDefinitionManager.getMainByDefKey(defKey); if (po != null) { po.setBpmnXml(""); } return po; } /** * 通过h5来设计一个流程 * @param request * @param response * @throws IOException * @throws ClientProtocolException */ @RequestMapping(value="webDefDesign",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "返回流程设计的xml", httpMethod = "GET", notes = "返回流程设计的xml") public Object webDefDesign( @ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception { Map map=bpmDefinitionManager.webDefDesign(defId); return map; } /** * web流程设计器保存 * @param request * @param response * @throws Exception */ @RequestMapping(value="webDefSave",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "web流程设计器保存", httpMethod = "POST", notes = "web流程设计器保存") public CommonResult webDefSave( @ApiParam(name="bpmDefinitionVo",value="保存流程对象", required = true) @RequestBody DefaultBpmDefinitionVo bpmDefinitionVo) throws Exception{ //Ocacle数据库的一个汉字为3个字节,字段大小是64,也就是不能超过21. String dbType = SQLUtil.getDbType(); if (dbType.equals(SQLConst.DB_ORACLE) && StringUtils.isNotEmpty(bpmDefinitionVo.getDefaultBpmDefinition().getName())){ int length = bpmDefinitionVo.getDefaultBpmDefinition().getName().length(); if(length > 21) return new CommonResult(false,"流程名称长度不能超过21!",""); } CommonResult res=bpmOftenFlowManager.webDefSave(bpmDefinitionVo); return res; } /** * flex,保存发布流程信息。 * * @param * @param * @return ModelAndView * @throws Exception */ @RequestMapping(value="flexDefSave",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "flex流程设计器保存", httpMethod = "POST", notes = "flex流程设计器保存") public CommonResult flexDefSave( @ApiParam(name="bpmDefinitionVo",value="保存流程对象", required = true) @RequestBody DefaultBpmDefinitionVo bpmDefinitionVo) throws Exception { CommonResult res=bpmDefService.flexDefSave(bpmDefinitionVo); return res; } /** * 流程定义列表(分页条件查询)数据 * * @param request * @param reponse * @return * @throws Exception * PageJson */ @RequestMapping(value="listJson", method=RequestMethod.POST, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "流程定义列表(分页条件查询)数据", httpMethod = "POST", notes = "流程定义列表(分页条件查询)数据") public PageList listJson(@ApiParam(name="queryFilter",value="通用查询对象")@RequestBody QueryFilter queryFilter) throws Exception { // 查询列表 PageList bpmDefinitionList = bpmDefinitionManager.queryList(queryFilter); return bpmDefinitionList; } /** * 绑定指定表单的流程定义列表(分页条件查询)数据 * * @param request * @param reponse * @return * @throws Exception * PageJson */ @RequestMapping(value="formDeflist", method=RequestMethod.POST, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "绑定指定表单的流程定义列表(分页条件查询)数据", httpMethod = "POST", notes = "流程定义列表(分页条件查询)数据") public PageList formDeflist(@ApiParam(name="boCode",value="boCode",required=true)@RequestParam String boCode, @ApiParam(name="formKey",value="formKey",required=true)@RequestParam String formKey, @ApiParam(name="queryFilter",value="通用查询对象") @RequestBody QueryFilter queryFilter) throws Exception { PageList pageList=bpmDefService.formDeflist(boCode,formKey,queryFilter); return pageList; } /** * 流程定义分类id查询数据 * * @param request * @param reponse * @return * @throws Exception * PageJson */ @RequestMapping(value="getByTypeId", method=RequestMethod.GET, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "流程定义分类id查询数据", httpMethod = "GET", notes = "流程定义分类id查询数据") public PageList getByTypeId(@ApiParam(name="typeId",value="分类id")@RequestParam String typeId) throws Exception { QueryFilter queryFilter =QueryFilter.build(); queryFilter.addFilter("is_main_", "Y", QueryOP.EQUAL); queryFilter.addFilter("type_id_", typeId, QueryOP.EQUAL); return bpmDefinitionManager.queryList(queryFilter); } /** * 根据流程定义id获取流程信息 * * @param request * @param response * @return * @throws Exception * ModelAndView */ @RequestMapping(value="defGet",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "根据流程定义id获取流程信息", httpMethod = "GET", notes = "根据流程定义id获取流程信息") public DefaultBpmDefinition defGet( @ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception { DefaultBpmDefinition bpmDefinition = null; if (StringUtil.isNotEmpty(defId)) { bpmDefinition = bpmDefinitionManager.getById(defId); } return bpmDefinition; } @RequestMapping(value = "getDefDesignByDefId",method = RequestMethod.GET,produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "根据流程定义id获取流程的最基本信息,返回的内容不含xml", httpMethod = "GET", notes = "根据流程定义id获取流程信息") public CommonResult getDefDesignByDefId(@RequestParam(value = "defId")String defId){ DefaultBpmDefinition definition = bpmDefService.getDefDesignByDefId(defId); if (definition!=null){ return CommonResult.ok().value(definition); } return CommonResult.error().message("该流程不存在"); } /** * 流程图 * * @param request * @param response * @throws Exception */ @RequestMapping(value="image",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "获取流程图", httpMethod = "GET", notes = "获取流程图") public void image( @ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId, @ApiParam(name="bpmnInstId",value="bpmn实例id", required = false) @RequestParam String bpmnInstId, @ApiParam(name="taskId",value="任务idid", required = false) @RequestParam String taskId, HttpServletResponse response) throws Exception { bpmDefinitionManager.image(defId,bpmnInstId,taskId,response); } /** * 保存流程定义。 * * @param bpmVo * @throws Exception * void */ @RequestMapping(value="save",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "保存流程定义。", httpMethod = "POST", notes = "保存流程定义。") public Object save( @ApiParam(name="bpmVo",value="流程保存对象", required = true) @RequestParam DefaultBpmDefinitionVo bpmVo) throws Exception { Object res=bpmDefService.save(bpmVo); return res; } /** * 批量删除流程定义 *
	 * 这个方法是通过流程定义ID删除
	 * 
* @param request * @param response * @throws Exception * void */ @RequestMapping(value="removeByDefIds",method=RequestMethod.DELETE, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "批量删除流程定义", httpMethod = "DELETE", notes = "批量删除流程定义") public CommonResult removeByDefIds( @ApiParam(name="ids",value="流程定义id字符串", required = true) @RequestParam String ids, @ApiParam(name="cascade",value="是否级联删除该流程所有版本", required = true) @RequestParam Optional cascade, @ApiParam(name="isVersion",value="是否是从版本管理删除", required = true) @RequestParam Optional isVersion) throws Exception { try{ String[] aryIds = ids.split(","); bpmDefinitionManager.removeDefIds(cascade.orElse(false), isVersion.orElse(false),aryIds); return new CommonResult(true,"删除流程定义成功!",""); } catch (Exception e) { String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e); return new CommonResult(false,"删除流程定义失败:" + rootCauseMessage,""); } } @RequestMapping(value="physicsRemoveAllVersionByIds",method=RequestMethod.DELETE, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "根据流程定义id,物理删除所有版本的流程相关数据", httpMethod = "DELETE", notes = "根据流程定义id,物理删除所有版本的流程相关数据") public CommonResult physicsRemoveAllVersionByIds( @ApiParam(name="ids",value="流程定义id字符串", required = true) @RequestParam String ids) throws Exception { try{ bpmDefinitionManager.physicsRemoveAllVersionByIds(ids); return new CommonResult(true,"删除流程定义成功!",""); } catch (Exception e) { String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e); return new CommonResult(false,"删除流程定义失败:" + rootCauseMessage,""); } } /** * 保存流程设置的BO设置 * *
	 * 1.保存BO设定。
	 * 2.保存表单初始化数据。
	 *
	 * {
	 * 	    "formInitItems": [
	 * 	        {
	 * 	            "nodeId": "userTask1",
	 * 	            "parentDefKey": "qingjia",
	 * 	            "saveFieldsSetting": [
	 * 	                {
	 * 	                    "boDefCode": "code1",
	 * 	                    "fieldDesc": "描述",
	 * 	                    "setting": "return \"1\";"
	 * 	                }
	 * 	            ],
	 * 	            "showFieldsSetting": [
	 * 	                {
	 * 	                    "boDefCode": "code1",
	 * 	                    "fieldDesc": "描述",
	 * 	                    "setting": "return \"1\";"
	 * 	                }
	 * 	            ]
	 * 	        },
	 * 	        {
	 * 	            "nodeId": "userTask1",
	 * 	            "parentDefKey": "local",
	 * 	            "saveFieldsSetting": [
	 * 	                {
	 * 	                    "boDefCode": "code1",
	 * 	                    "fieldDesc": "描述",
	 * 	                    "setting": "return \"1\";"
	 * 	                }
	 * 	            ],
	 * 	            "showFieldsSetting": [
	 * 	                {
	 * 	                    "boDefCode": "code1",
	 * 	                    "fieldDesc": "描述",
	 * 	                    "setting": "return \"1\";"
	 * 	                }
	 * 	            ]
	 * 	        }
	 * 	    ],
	 * 	    bodef:{"boSaveMode":"db","boDefs":[{"required":false,"key":"bbb","name":"a"}]}
	 * 	}
	 *
	 * 
* * @param request * @param reponse * @return * @throws Exception * ResultMessage */ @RequestMapping(value="saveSetBos",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "保存流程设置的BO设置", httpMethod = "POST", notes = "保存流程设置的BO设置") public CommonResult saveSetBos( @ApiParam(name="defBoSetVo",value="流程bo设置对象", required = true) @RequestBody DefBoSetVo defBoSetVo) throws Exception { CommonResult res=bpmDefService.saveSetBos(defBoSetVo); return res; } /** * 在流程在线设计中获取分类的所有流程列表。 * * @param request * @param response * @return * @throws Exception */ @RequestMapping(value="getFlowListByTypeId",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "保存代理信息", httpMethod = "GET", notes = "保存代理信息") public void getFlowListByTypeId( @ApiParam(name="typeId",value="分类id", required = true) @RequestParam String typeId, @ApiParam(name="word",value="查询关键字", required = true) @RequestParam String word, HttpServletResponse response) throws Exception { bpmDefService.getFlowListByTypeId(typeId,word,response); } /** * 流程在线设计,根据defId获取流程对应的详细信息 * * @param request * @param response * @return * @throws Exception */ @RequestMapping(value="flexGet",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "流程在线设计,根据defId获取流程对应的详细信息", httpMethod = "GET", notes = "流程在线设计,根据defId获取流程对应的详细信息") public void flexGet( @ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId, HttpServletResponse response) throws Exception { bpmDefService.flexGet(defId,response); } /** * 获取流程其他属性的参数。 * * @param request * @param response * @return * @throws Exception * BpmDefExtProperties */ @RequestMapping(value="getOtherParam",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "获取流程其他属性的参数", httpMethod = "GET", notes = "获取流程其他属性的参数") public Map getOtherParam( @ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId) throws Exception { Map map =bpmDefService.getOtherParam(defId); return map; } /** * 保存流程的其他属性。 注意:这里有几个操作没有使用事务。 * * @param request * @param response * @throws Exception * void */ @RequestMapping(value="saveProp",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "获取流程其他属性的参数", httpMethod = "POST", notes = "获取流程其他属性的参数") public CommonResult saveProp( @ApiParam(name="defPropVo",value="流程其他参数保存对象", required = true) @RequestBody DefPropSaveVo defPropVo) throws Exception { CommonResult res=bpmDefService.saveProp(defPropVo); return res; } @RequestMapping(value="nodeBos",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "展示流程节点BO设置", httpMethod = "GET", notes = "获取流程其他属性的参数") public Object nodeBos( @ApiParam(name="defId",value="流程定义id", required = true) @RequestParam String defId, @ApiParam(name="topDefKey",value="流程定义key", required = true) @RequestParam String topDefKey) throws Exception { Object res=bpmDefService.nodeBos(defId,topDefKey); return res; } @RequestMapping(value="exportXml" ,method=RequestMethod.GET, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "导出流程定义xml", httpMethod = "GET", notes = "导出流程定义xml") public void exportXml( HttpServletRequest request, HttpServletResponse response, @ApiParam(name="bpmDefId",value="流程定义id", required = true) @RequestParam String bpmDefId) throws Exception { response.setContentType("APPLICATION/OCTET-STREAM"); if (BeanUtils.isNotEmpty(bpmDefId)) { String[] bpmDefIds = bpmDefId.split(","); List defList = bpmDefinitionService.getExternalSubprocess(Arrays.asList(bpmDefIds)); String zipName = ""; String fullname = ContextUtil.getCurrentUser().getFullname(); if(defList.size() == 1){ DefaultBpmDefinition bpmDefinition = baseService.get(defList.get(0)); zipName = String.format("流程导出_%s(%s)_%s%s",bpmDefinition.getName(),bpmDefinition.getDefKey(),fullname,DateFormatUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss")); //防止文件名过长问题 if(zipName.length()>123){ zipName = zipName.substring(0,120)+"..."; } }else { zipName = String.format("批量流程导出文件_%s%s",fullname,DateFormatUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss")); } // 写XML Map strXml = bpmDefTransform.exportDef(defList); HttpUtil.downLoadFile(request, response, strXml,zipName); } } @RequestMapping(value="exportData" ,method=RequestMethod.GET, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "导出流程定义xml", httpMethod = "GET", notes = "导出流程定义xml") public Map exportData(@ApiParam(name="bpmDefId",value="流程定义id", required = true) @RequestParam String ...ids) throws Exception { List defList = bpmDefinitionService.getExternalSubprocess(Arrays.asList(ids)); return bpmDefTransform.exportDef(defList); } @RequestMapping(value="importData" ,method=RequestMethod.POST, produces = { "application/json; charset=utf-8" }) @ApiOperation(value = "导出流程定义xml", httpMethod = "POST", notes = "导出流程定义xml") public CommonResult> importData(@RequestBody Map param, @RequestParam(value = "typeId", required = false) Optional typeId) throws JAXBException, UnsupportedEncodingException { String bpmdefsXml = param.getOrDefault("bpmdefs.flow.xml", "").toString(); String formXmlStr = param.getOrDefault("form.xml", "").toString(); String boXmlStr = param.getOrDefault("bo.xml", "").toString(); String formRightsXml = param.getOrDefault("formrights.xml", "").toString(); ObjectNode obj = JsonUtil.getMapper().createObjectNode(); obj.put("bpmdefsXml", bpmdefsXml); obj.put("formXmlStr", formXmlStr); obj.put("boXmlStr", boXmlStr); obj.put("formRightsXml", formRightsXml); ThreadMsgUtil.addMapMsg("notNeedTransaction", "true"); CommonResult result = bpmDefTransform.importDef(obj, typeId.orElse("6"), true); if (!result.getState()) { return new CommonResult<>(false, result.getMessage()); } Map map = new HashMap<>(); BpmDefXmlList defList = (BpmDefXmlList) JAXBUtil.unmarshall(bpmdefsXml, BpmDefXmlList.class); if (BeanUtils.isNotEmpty(defList.getBpmList())) { List alias = defList.getBpmList().stream().map(item -> item.getBpmDefinition().getDefKey()).collect(Collectors.toList()); map = bpmDefinitionManager.list(Wrappers.lambdaQuery().in(DefaultBpmDefinition::getDefKey, alias)) .stream() .collect(Collectors.toMap(DefaultBpmDefinition::getDefKey, DefaultBpmDefinition::getId, (k1, k2) -> k1)); } return new CommonResult<>(true, "导入成功", map); } @RequestMapping(value = "importCheck1", method = RequestMethod.POST) List importFlowCheck(@RequestBody Map param) throws Exception { return bpmDefService.importFlowCheck(param); } @RequestMapping(value="importSave", method=RequestMethod.POST, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "流程导入,根据传入的文件id从缓存中取出xml文件导入,并清除缓存", httpMethod = "POST", notes = "附件上传操作") public Object importSave(@ApiParam(name="confirmImport",value="确认导入",required=false) @RequestParam Optional confirmImport, @ApiParam(name="typeId",value="表单标识",required=false) @RequestParam Optional typeId, @ApiParam(name="cacheFileId",value="缓存的流程文件id",required=false) @RequestParam Optional cacheFileId) throws Exception { CommonResult message = null; try { if (confirmImport.orElse(false)) { String byKey = baseService.getImportFileFromCache(cacheFileId.get()); if(StringUtil.isEmpty(byKey)) { return new CommonResult(false, "导入失败:上传的文件已从缓存中清除,请重新导入。"); } ObjectNode objectNode = (ObjectNode) JsonUtil.toJsonNode(byKey); message = bpmDefTransform.importDef(objectNode,typeId.orElse("")); } baseService.delImportFileFromCache(cacheFileId.orElse("")); } catch (Exception e) { message = new CommonResult(false, "导入失败:" + ExceptionUtils.getRootCauseMessage(e)); } return message; } @RequestMapping(value="importCheck", method=RequestMethod.POST, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "流程导入前校验,通过校验则直接导入,如有重复流程,则返回流程xml的缓存key,待用户确认覆盖后再次导入", httpMethod = "POST", notes = "流程导入前校验") public Object importCheck(MultipartHttpServletRequest request, HttpServletResponse response, @ApiParam(name="typeId",value="表单标识",required=false) @RequestParam Optional typeId) throws Exception { Object res=bpmDefService.importCheck(request,response,typeId); return res; } /** * 流程定义历史版本 * * @param request * @param response * @return * @throws Exception */ @RequestMapping(value="versions", method=RequestMethod.POST, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "流程定义历史版本", httpMethod = "POST", notes = "流程定义历史版本") public PageList versions( @ApiParam(name="defId",value="流程定义id")@RequestParam String defId, @ApiParam(name="defKey",value="流程定义key")@RequestParam String defKey, @ApiParam(name="queryFilter",value="通用查询对象")@RequestBody QueryFilter queryFilter) throws Exception { PageList res=bpmDefinitionManager.versions(defId,defKey,queryFilter); return res; } /** * 当前版本是否是流程定义最新版本 * @return */ @RequestMapping(value = "isLatestVersion", method = RequestMethod.GET, produces = {"application/json; charset=utf-8"}) @ApiOperation(value = "流程定义历史版本", httpMethod = "GET", notes = "流程定义历史版本") public CommonResult isLatestVersion( @ApiParam(name = "defId", value = "流程定义id") @RequestParam() String defId) { return bpmDefinitionManager.isLatestVersion(defId); } /** * 设置历史版本的流程定义为主版本 * * @param request * @param response * @throws Exception */ @RequestMapping("switchMainVersion") @ApiOperation(value = "设置历史版本的流程定义为主版本", httpMethod = "GET", notes = "设置历史版本的流程定义为主版本") public CommonResult switchMainVersion(@ApiParam(name="defId",value="流程定义id")@RequestParam String defId) throws Exception { try { bpmDefinitionService.switchMainVersion(defId); return new CommonResult(true,"设置成功",""); } catch (Exception e) { return new CommonResult(false,"设置失败:"+e.getMessage(),""); } } /** * 设置外部子流程 * **/ @RequestMapping(value="subFlowDetail", method=RequestMethod.GET, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "设置外部子流程", httpMethod = "GET", notes = "设置外部子流程") public Map subFlowDetail( @ApiParam(name="defId",value="流程定义id")@RequestParam String defId, @ApiParam(name="nodeId",value="节点id")@RequestParam String nodeId )throws Exception { Map res=bpmDefinitionManager.subFlowDetail(defId,nodeId); return res; } /** * 得到全部节点自定义按钮 * * @param request * @param response * @return * @throws Exception */ @SuppressWarnings({ "rawtypes", "unchecked" }) @RequestMapping(value="getNodeBtns", method=RequestMethod.POST, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "流程代理设置列表(分页条件查询)数据", httpMethod = "POST", notes = "流程代理设置列表(分页条件查询)数据") public PageList getNodeBtns(@ApiParam(name="defId",value="流程定义id")@RequestBody String defId) throws Exception { PageList res=bpmDefinitionManager.getNodeBtns(defId); return res; } /** * 得到某个节点自定义按钮 * * action : 0:获取默认初始化的按钮,1:获取配置的按钮,2:获取默认不初始化的按钮 * @param request * @param response * @return * @throws Exception */ @RequestMapping(value="getNodeSet", method=RequestMethod.POST, produces={"application/json; charset=utf-8" }) @ApiOperation(value = "得到某个节点自定义按钮", httpMethod = "POST", notes = "得到某个节点自定义按钮") public List