Commit 9019eb31 authored by chenhao's avatar chenhao

修改逻辑执行方法

parent 87482ed6
......@@ -9,7 +9,7 @@ public interface IWorkflowExcuteService{
* @param key 流程定义的key
* @param condition 执行控制条件
*/
void startAndComplete(String key,String condition)throws Exception;
String startAndComplete(String key,String condition)throws Exception;
/**
* 检查当前登录人有没有流程操作权限
......
......@@ -24,10 +24,10 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
@Transactional
@Override
public void startAndComplete(String key, String condition) throws Exception {
public String startAndComplete(String key, String condition) throws Exception {
JSONObject body = new JSONObject();
String businessKey = buildOrderNo();
body.put("businessKey", businessKey);
String businessKey = buildOrderNo();
body.put("businessKey", businessKey);
body.put("processDefinitionKey", key);
JSONObject jsonObject = workflowFeignService.startByVariable(body);
if (jsonObject == null || jsonObject.getJSONObject("data") == null) {
......@@ -39,6 +39,7 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
throw new RuntimeException("初始执行任务失败");
}
}
return jsonObject.getJSONObject("data").getString("id");
}
@Override
......@@ -105,15 +106,20 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
@Override
public Object setTaskAssign(String processInstanceId, String userId) {
JSONObject teskObject = workflowFeignService.getTaskList(processInstanceId);
if (ObjectUtils.isNotEmpty(teskObject)) {
JSONArray taskDetailArray = teskObject.getJSONArray("data");
for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
try {
if (ObjectUtils.isEmpty(teskObject)) {
throw new RuntimeException("设置任务执行人失败, 任务不存在,请检查processInstanceId" + processInstanceId + "是否正确");
}
JSONArray taskDetailArray = teskObject.getJSONArray("data");
for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
JSONObject taskGroupNameObject = workflowFeignService.getTaskGroupName(detail.getString("id"));
try {
if (taskGroupNameObject.getJSONArray("data") == null
&& taskGroupNameObject.getJSONArray("data").size() < 1) {
workflowFeignService.setTaskUser(detail.getString("id"), userId);
} catch (Exception e) {
throw new RuntimeException("设置任务执行人失败");
}
} catch (Exception e) {
throw new RuntimeException("设置任务执行人失败");
}
}
return true;
......@@ -135,14 +141,15 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
}
return true;
}
public static String buildOrderNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
}
return newDate + result;
}
public static String buildOrderNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
}
return newDate + result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment