完善流程发布业务

This commit is contained in:
wanggeng888 2021-07-13 17:15:14 +08:00
parent 3a9b060914
commit 932e11ed59
9 changed files with 56 additions and 25 deletions

View File

@ -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));

View File

@ -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();
}

View File

@ -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) {

View File

@ -177,7 +177,7 @@ public class Check2ServiceImpl extends BaseService implements ICheck2Service {
Map<String, Object> 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("检查结果是否全部通过");

View File

@ -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);
// 更新任务处理状态

View File

@ -40,7 +40,17 @@ public interface IProcessService {
* @param params 参数
* @return 流程主键
*/
String startProcess(String processName, String businessKey, Map<String, Object> params);
String startProcessByName(String processName, String businessKey, Map<String, Object> params);
/**
* 启动流程
*
* @param deploymentId 部署ID
* @param businessKey 业务主键
* @param params 参数
* @return 流程主键
*/
String startProcessByDeploymentId(String deploymentId, String businessKey, Map<String, Object> params);
/**
* 任务列表通过执行人

View File

@ -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<String, Object> params) {
public String startProcessByName(String processName, String businessKey, Map<String, Object> params) {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processName, businessKey, params);
return processInstance.getId();
}
@Override
public String startProcessByDeploymentId(String deploymentId, String businessKey, Map<String, Object> 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<Task> listTaskByAssignee(String assignee) {
TaskQuery taskQuery = taskService.createTaskQuery();

View File

@ -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;
});
};

View File

@ -6,7 +6,7 @@
<h2>{{'MODEL.SAVE.TITLE' | translate}}</h2>
</div>
<div class="modal-body">
<div class="form-group">
<label for="nameField">{{'MODEL.NAME' | translate}}</label>
<input type="text"
@ -15,7 +15,8 @@
class="form-control"
ng-model="saveDialog.name"
ui-keypress="{13:'save()'}"
auto-focus />
auto-focus
/>
</div>
<div class="form-group">
<label for="docTextArea">{{'MODEL.DESCRIPTION' | translate}}</label>
@ -23,19 +24,19 @@
</div>
</div>
<div class="modal-footer">
<div class="pull-right">
<button type="button" class="btn" ng-click="close()" ng-disabled="status.loading" translate>ACTION.CANCEL</button>
<button class="btn btn-primary" ng-click="saveAndClose()" ng-disabled="status.loading" ng-show="!error" translate>ACTION.SAVE-AND-CLOSE</button>
<button class="btn btn-primary" ng-click="save()" ng-disabled="status.loading" ng-show="!error" translate>ACTION.SAVE</button>
</div>
<div class="pull-right popup-error" ng-if="error && !error.isConflict">
<span>{{'MODEL.SAVE.ERROR' | translate}}</span>
</div>
<loading></loading>
</div>
</div>
</div>