diff --git a/src/main/java/com/cm/inspection/controller/apis/activiti/ActivitiController.java b/src/main/java/com/cm/inspection/controller/apis/activiti/ActivitiController.java index 0e23c52..438e32a 100644 --- a/src/main/java/com/cm/inspection/controller/apis/activiti/ActivitiController.java +++ b/src/main/java/com/cm/inspection/controller/apis/activiti/ActivitiController.java @@ -44,7 +44,10 @@ public class ActivitiController extends AbstractController { @PostMapping("create") @CheckRequestBodyAnnotation public SuccessResultData create(@RequestBody ActivitiVO activitiVO) throws UnsupportedEncodingException { - if(!RegexUtil.isChinese(activitiVO.getModelKey())) { + if (RegexUtil.isChinese(activitiVO.getModelName())) { + throw new ParamsException("模型名称不能有中文"); + } + if (RegexUtil.isChinese(activitiVO.getModelKey())) { throw new ParamsException("模型Key不能有中文"); } return new SuccessResultData<>(activitiService.create(activitiVO)); diff --git a/src/main/java/com/cm/inspection/controller/apis/activiti/ActivitiModelController.java b/src/main/java/com/cm/inspection/controller/apis/activiti/ActivitiModelController.java index c98699c..c0f093d 100644 --- a/src/main/java/com/cm/inspection/controller/apis/activiti/ActivitiModelController.java +++ b/src/main/java/com/cm/inspection/controller/apis/activiti/ActivitiModelController.java @@ -3,24 +3,17 @@ package com.cm.inspection.controller.apis.activiti; import com.alibaba.fastjson.JSONObject; import com.cm.common.base.AbstractController; import com.cm.common.constants.ISystemConstant; +import com.cm.common.exception.ParamsException; import com.cm.common.result.SuccessResult; +import com.cm.common.utils.RegexUtil; import com.cm.inspection.service.activiti.IActivitiModelService; -import com.cm.inspection.service.activiti.IActivitiService; -import com.fasterxml.jackson.databind.node.ObjectNode; import io.swagger.annotations.Api; -import org.activiti.engine.ActivitiException; -import org.activiti.engine.repository.Model; -import org.apache.batik.transcoder.TranscoderException; -import org.apache.batik.transcoder.TranscoderInput; -import org.apache.batik.transcoder.TranscoderOutput; -import org.apache.batik.transcoder.image.PNGTranscoder; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; -import java.io.*; +import java.io.IOException; +import java.io.UnsupportedEncodingException; /** * When you feel like quitting. Think about why you started @@ -42,6 +35,13 @@ public class ActivitiModelController extends AbstractController { @PutMapping("save/{modelId}") public SuccessResult saveModel(@PathVariable String modelId, String name, String description, String json_xml, String svg_xml) throws Exception { + name = name.trim().replace("\\s", ""); + if (StringUtils.isBlank(name)) { + throw new ParamsException("名称不能为空"); + } + if (RegexUtil.isChinese(name)) { + throw new ParamsException("名称不能有中文"); + } activitiModelService.saveModel(modelId, name, description, json_xml, svg_xml); return new SuccessResult(); } diff --git a/src/main/java/com/cm/inspection/pojo/vos/activiti/ActivitiVO.java b/src/main/java/com/cm/inspection/pojo/vos/activiti/ActivitiVO.java index cfa4fae..34ab70b 100644 --- a/src/main/java/com/cm/inspection/pojo/vos/activiti/ActivitiVO.java +++ b/src/main/java/com/cm/inspection/pojo/vos/activiti/ActivitiVO.java @@ -31,7 +31,7 @@ public class ActivitiVO { private Integer modelVersion; public String getModelName() { - return modelName == null ? "" : modelName.trim(); + return modelName == null ? "" : modelName.trim().replaceAll("\\s", ""); } public void setModelName(String modelName) { diff --git a/src/main/java/com/cm/inspection/service/check/impl/Check2ServiceImpl.java b/src/main/java/com/cm/inspection/service/check/impl/Check2ServiceImpl.java index 7825a6e..52005cd 100644 --- a/src/main/java/com/cm/inspection/service/check/impl/Check2ServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/check/impl/Check2ServiceImpl.java @@ -177,7 +177,7 @@ public class Check2ServiceImpl extends BaseService implements ICheck2Service { Map params = getHashMap(16); LOG.debug("开启流程v2"); params.put(GridPersonnelTypeEnum.GRID.getValue(), grid); - processService.startProcess(IProcessService.BT_CHECK_REPORT_V2, businessKey, params); + processService.startProcessByName(IProcessService.BT_CHECK_REPORT_V2, businessKey, params); // 得到当前任务 Task task = processService.getTaskByAssigneeAndBusinessKey(grid, businessKey); LOG.debug("检查结果是否全部通过"); diff --git a/src/main/java/com/cm/inspection/service/check/impl/CheckServiceImpl.java b/src/main/java/com/cm/inspection/service/check/impl/CheckServiceImpl.java index 1eec4fe..f67bd49 100644 --- a/src/main/java/com/cm/inspection/service/check/impl/CheckServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/check/impl/CheckServiceImpl.java @@ -167,7 +167,7 @@ public class CheckServiceImpl extends BaseService implements ICheckService { String userId = params.get("creator").toString(); String businessKey = String.format("check:%s", checkId); params.put("reporter", userId); - processService.startProcess(IProcessService.CHECK_SELF_PROCESS, businessKey, params); + processService.startProcessByName(IProcessService.CHECK_SELF_PROCESS, businessKey, params); Task task = processService.getTaskByAssigneeAndBusinessKey(userId, businessKey); completeCheck(token, checkVO, checkId, null, userId, task, isCoordination); // 更新任务处理状态 diff --git a/src/main/java/com/cm/inspection/service/process/IProcessService.java b/src/main/java/com/cm/inspection/service/process/IProcessService.java index 35e99ae..2e74ce9 100644 --- a/src/main/java/com/cm/inspection/service/process/IProcessService.java +++ b/src/main/java/com/cm/inspection/service/process/IProcessService.java @@ -40,7 +40,17 @@ public interface IProcessService { * @param params 参数 * @return 流程主键 */ - String startProcess(String processName, String businessKey, Map params); + String startProcessByName(String processName, String businessKey, Map params); + + /** + * 启动流程 + * + * @param deploymentId 部署ID + * @param businessKey 业务主键 + * @param params 参数 + * @return 流程主键 + */ + String startProcessByDeploymentId(String deploymentId, String businessKey, Map params); /** * 任务列表(通过执行人) diff --git a/src/main/java/com/cm/inspection/service/process/impl/ProcessServiceImpl.java b/src/main/java/com/cm/inspection/service/process/impl/ProcessServiceImpl.java index 917f487..c0fe284 100644 --- a/src/main/java/com/cm/inspection/service/process/impl/ProcessServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/process/impl/ProcessServiceImpl.java @@ -1,9 +1,11 @@ package com.cm.inspection.service.process.impl; +import com.cm.common.exception.base.SystemException; import com.cm.inspection.service.process.IProcessService; import org.activiti.engine.*; import org.activiti.engine.history.HistoricProcessInstance; import org.activiti.engine.history.HistoricTaskInstance; +import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.task.Task; import org.activiti.engine.task.TaskQuery; @@ -46,11 +48,24 @@ public class ProcessServiceImpl implements IProcessService { } @Override - public String startProcess(String processName, String businessKey, Map params) { + public String startProcessByName(String processName, String businessKey, Map params) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processName, businessKey, params); return processInstance.getId(); } + @Override + public String startProcessByDeploymentId(String deploymentId, String businessKey, Map params) { + ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult(); + if(processDefinition == null) { + throw new SystemException("流程不存在"); + } + if(!processDefinition.isSuspended()) { + throw new SystemException("流程未发布"); + } + ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId(), businessKey, params); + return processInstance.getId(); + } + @Override public List listTaskByAssignee(String assignee) { TaskQuery taskQuery = taskService.createTaskQuery(); diff --git a/src/main/resources/static/editor-app/configuration/toolbar-default-actions.js b/src/main/resources/static/editor-app/configuration/toolbar-default-actions.js index 28c86bf..22afe33 100644 --- a/src/main/resources/static/editor-app/configuration/toolbar-default-actions.js +++ b/src/main/resources/static/editor-app/configuration/toolbar-default-actions.js @@ -422,9 +422,11 @@ var SaveModelCtrl = [ '$rootScope', '$scope', '$http', '$route', '$location', }) .error(function (data, status, headers, config) { - $scope.error = {}; - console.log('Something went wrong when updating the process model:' + JSON.stringify(data)); $scope.status.loading = false; + top.dialog.msg(data.msg); + // $scope.error = {}; + // console.log('Something went wrong when updating the process model:' + JSON.stringify(data)); + // $scope.status.loading = false; }); }; diff --git a/src/main/resources/static/editor-app/popups/save-model.html b/src/main/resources/static/editor-app/popups/save-model.html index b031f1c..fe6a4d3 100644 --- a/src/main/resources/static/editor-app/popups/save-model.html +++ b/src/main/resources/static/editor-app/popups/save-model.html @@ -6,7 +6,7 @@

{{'MODEL.SAVE.TITLE' | translate}}

\ No newline at end of file