Commit 276177a5 by huangfusuper

死锁BUG

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