Commit 276177a5 by huangfusuper

死锁BUG

parent 22a70438
......@@ -972,7 +972,6 @@ public class ApiFlowServiceImpl implements ApiFlowService {
@Override
public void repairFlow(String param) {
ValidationUtil.dataNotBank(param, "请求参数不允许为空!");
JSONObject jsonObject = JSON.parseObject(param);
//获取工作空间名称
......@@ -998,51 +997,54 @@ public class ApiFlowServiceImpl implements ApiFlowService {
ValidationUtil.dataNotNull(flow, flowName + "工作流不存在");
List<Node> nodeList = nodeMapper.findByFlowIdAndName(flow.getFlowId(), nodeNameList);
RedissLockUtil.lock(flow.getFlowId().toString(), 60);
//设置触发时间
Long triggerTime = System.currentTimeMillis();
try{
RedissLockUtil.lock(flow.getFlowId().toString(), 60);
//设置触发时间
Long triggerTime = System.currentTimeMillis();
Map<String, List<WaitingTask>> waitTaskMap = buildTask(nodeList, nodeNameList, repairTimeList, triggerTime, flowName);
//将时间排序
Collections.sort(repairTimeList);
//查看当前排队的工作流最大排队序号
Integer order = waitingRecordMapper.findOrderByFlowId(flow.getFlowId());
if (order == null){
order = 0;
}
String userName = currentUserUtils.account();
for (String repairTime : repairTimeList){
WaitingRecord waitingRecord = new WaitingRecord();
RunRecording runRecording = new RunRecording();
String runId = UUID.randomUUID().toString().replace("-","");
//设置排期
BeanUtils.copyProperties(flow, waitingRecord);
waitingRecord.setFlowVersionName(flow.getVersionName());
waitingRecord.setRunId(runId);
waitingRecord.setFlowNodeCount(nodeList.size());
waitingRecord.setOperator(userName);
waitingRecord.setScheduleType(ScheduleTypeEnum.REPAIR.getCode());
waitingRecord.setWaitOrder(++order);
//需要按着时间先后来设置时间
waitingRecord.setTriggerTime(System.currentTimeMillis());
//设置实例
BeanUtils.copyProperties(waitingRecord, runRecording);
runRecording.setFlowStatus("1");
runRecording.setTriggerTime(System.currentTimeMillis());
Integer waitId = waitingRecordMapper.insertSelective(waitingRecord);
runRecordingMapper.saveRunRecording(runRecording);
List<WaitingTask> repairTaskList = waitTaskMap.get(repairTime);
repairTaskList.forEach(waitingTask -> {
waitingTask.setWaitId(waitingRecord.getWaitId());
waitingTaskMapper.insertSelective(waitingTask);
});
Map<String, List<WaitingTask>> waitTaskMap = buildTask(nodeList, nodeNameList, repairTimeList, triggerTime, flowName);
//将时间排序
Collections.sort(repairTimeList);
//查看当前排队的工作流最大排队序号
Integer order = waitingRecordMapper.findOrderByFlowId(flow.getFlowId());
if (order == null){
order = 0;
}
String userName = currentUserUtils.account();
for (String repairTime : repairTimeList){
WaitingRecord waitingRecord = new WaitingRecord();
RunRecording runRecording = new RunRecording();
String runId = UUID.randomUUID().toString().replace("-","");
//设置排期
BeanUtils.copyProperties(flow, waitingRecord);
waitingRecord.setFlowVersionName(flow.getVersionName());
waitingRecord.setRunId(runId);
waitingRecord.setFlowNodeCount(nodeList.size());
waitingRecord.setOperator(userName);
waitingRecord.setScheduleType(ScheduleTypeEnum.REPAIR.getCode());
waitingRecord.setWaitOrder(++order);
//需要按着时间先后来设置时间
waitingRecord.setTriggerTime(System.currentTimeMillis());
//设置实例
BeanUtils.copyProperties(waitingRecord, runRecording);
runRecording.setFlowStatus("1");
runRecording.setTriggerTime(System.currentTimeMillis());
Integer waitId = waitingRecordMapper.insertSelective(waitingRecord);
runRecordingMapper.saveRunRecording(runRecording);
List<WaitingTask> repairTaskList = waitTaskMap.get(repairTime);
repairTaskList.forEach(waitingTask -> {
waitingTask.setWaitId(waitingRecord.getWaitId());
waitingTaskMapper.insertSelective(waitingTask);
});
}
}catch (Exception e) {
e.printStackTrace();
}finally {
RedissLockUtil.unlock(flow.getFlowId().toString());
}
RedissLockUtil.unlock(flow.getFlowId().toString());
}
......
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