Commit 9019eb31 authored by chenhao's avatar chenhao

修改逻辑执行方法

parent 87482ed6
...@@ -9,7 +9,7 @@ public interface IWorkflowExcuteService{ ...@@ -9,7 +9,7 @@ public interface IWorkflowExcuteService{
* @param key 流程定义的key * @param key 流程定义的key
* @param condition 执行控制条件 * @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 { ...@@ -24,10 +24,10 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
@Transactional @Transactional
@Override @Override
public void startAndComplete(String key, String condition) throws Exception { public String startAndComplete(String key, String condition) throws Exception {
JSONObject body = new JSONObject(); JSONObject body = new JSONObject();
String businessKey = buildOrderNo(); String businessKey = buildOrderNo();
body.put("businessKey", businessKey); body.put("businessKey", businessKey);
body.put("processDefinitionKey", key); body.put("processDefinitionKey", key);
JSONObject jsonObject = workflowFeignService.startByVariable(body); JSONObject jsonObject = workflowFeignService.startByVariable(body);
if (jsonObject == null || jsonObject.getJSONObject("data") == null) { if (jsonObject == null || jsonObject.getJSONObject("data") == null) {
...@@ -39,6 +39,7 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService { ...@@ -39,6 +39,7 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
throw new RuntimeException("初始执行任务失败"); throw new RuntimeException("初始执行任务失败");
} }
} }
return jsonObject.getJSONObject("data").getString("id");
} }
@Override @Override
...@@ -105,15 +106,20 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService { ...@@ -105,15 +106,20 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
@Override @Override
public Object setTaskAssign(String processInstanceId, String userId) { public Object setTaskAssign(String processInstanceId, String userId) {
JSONObject teskObject = workflowFeignService.getTaskList(processInstanceId); JSONObject teskObject = workflowFeignService.getTaskList(processInstanceId);
if (ObjectUtils.isNotEmpty(teskObject)) { if (ObjectUtils.isEmpty(teskObject)) {
JSONArray taskDetailArray = teskObject.getJSONArray("data"); throw new RuntimeException("设置任务执行人失败, 任务不存在,请检查processInstanceId" + processInstanceId + "是否正确");
for (Object obj : taskDetailArray) { }
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj)); JSONArray taskDetailArray = teskObject.getJSONArray("data");
try { 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); workflowFeignService.setTaskUser(detail.getString("id"), userId);
} catch (Exception e) {
throw new RuntimeException("设置任务执行人失败");
} }
} catch (Exception e) {
throw new RuntimeException("设置任务执行人失败");
} }
} }
return true; return true;
...@@ -135,14 +141,15 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService { ...@@ -135,14 +141,15 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
} }
return true; return true;
} }
public static String buildOrderNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static String buildOrderNo() {
String newDate = sdf.format(new Date()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String result = ""; String newDate = sdf.format(new Date());
Random random = new Random(); String result = "";
for (int i = 0; i < 3; i++) { Random random = new Random();
result += random.nextInt(10); for (int i = 0; i < 3; i++) {
} result += random.nextInt(10);
return newDate + result; }
} 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