Commit 55fc25d4 authored by yanzg's avatar yanzg

修复等待时间

parent c8030ef8
...@@ -40,7 +40,10 @@ public class YzgTimeout { ...@@ -40,7 +40,10 @@ public class YzgTimeout {
ex.printStackTrace(); ex.printStackTrace();
} }
}); });
runnable.run(); try {
isRun.value = true; runnable.run();
} finally {
isRun.value = true;
}
} }
} }
...@@ -5,7 +5,6 @@ import com.yanzuoguang.db.DbExecute; ...@@ -5,7 +5,6 @@ import com.yanzuoguang.db.DbExecute;
import com.yanzuoguang.util.helper.YzgTimeout; import com.yanzuoguang.util.helper.YzgTimeout;
import com.yanzuoguang.util.vo.MapRow; import com.yanzuoguang.util.vo.MapRow;
import com.yanzuoguang.util.vo.Ref; import com.yanzuoguang.util.vo.Ref;
import org.springframework.context.annotation.Lazy;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.support.rowset.SqlRowSet; import org.springframework.jdbc.support.rowset.SqlRowSet;
...@@ -52,7 +51,7 @@ public class DbExecuteImpl implements DbExecute { ...@@ -52,7 +51,7 @@ public class DbExecuteImpl implements DbExecute {
try { try {
sql = this.handleParas(sql, paras); sql = this.handleParas(sql, paras);
String finalSql = sql; String finalSql = sql;
YzgTimeout.timeOut(DbExecuteImpl.class, sqlName, () -> row.value = getJdbc().update(finalSql, paras)); YzgTimeout.timeOut(targetClass, sqlName, () -> row.value = getJdbc().update(finalSql, paras));
return row.value; return row.value;
} finally { } finally {
printSql.print(targetClass, sqlName, start, row.value, sql, paras); printSql.print(targetClass, sqlName, start, row.value, sql, paras);
...@@ -77,7 +76,7 @@ public class DbExecuteImpl implements DbExecute { ...@@ -77,7 +76,7 @@ public class DbExecuteImpl implements DbExecute {
try { try {
sql = this.handleParas(sql, paras); sql = this.handleParas(sql, paras);
String finalSql = sql; String finalSql = sql;
YzgTimeout.timeOut(DbExecuteImpl.class, sqlName, () -> { YzgTimeout.timeOut(targetClass, sqlName, () -> {
RowCallbackHandler rowCallbackHandler = rs -> { RowCallbackHandler rowCallbackHandler = rs -> {
AllBeanRowMapper<T> rowMap = AllBeanRowMapper.getInstance(cls, configDb); AllBeanRowMapper<T> rowMap = AllBeanRowMapper.getInstance(cls, configDb);
T data = rowMap.mapRow(rs, row.value); T data = rowMap.mapRow(rs, row.value);
...@@ -112,7 +111,7 @@ public class DbExecuteImpl implements DbExecute { ...@@ -112,7 +111,7 @@ public class DbExecuteImpl implements DbExecute {
Ref<List<T>> ret = new Ref<>(null); Ref<List<T>> ret = new Ref<>(null);
String finalSql = sql; String finalSql = sql;
YzgTimeout.timeOut(cls, sqlName, () -> { YzgTimeout.timeOut(targetClass, sqlName, () -> {
ret.value = this.getJdbc().query(finalSql, paras, AllBeanRowMapper.getInstance(cls, configDb)); ret.value = this.getJdbc().query(finalSql, paras, AllBeanRowMapper.getInstance(cls, configDb));
}); });
if (ret.value == null) { if (ret.value == null) {
...@@ -157,7 +156,7 @@ public class DbExecuteImpl implements DbExecute { ...@@ -157,7 +156,7 @@ public class DbExecuteImpl implements DbExecute {
Ref<Object> ret = new Ref<>(null); Ref<Object> ret = new Ref<>(null);
String finalSql = sql; String finalSql = sql;
YzgTimeout.timeOut(DbExecuteImpl.class, sqlName, () -> { YzgTimeout.timeOut(targetClass, sqlName, () -> {
SqlRowSet rowSet = this.getJdbc().queryForRowSet(finalSql, paras); SqlRowSet rowSet = this.getJdbc().queryForRowSet(finalSql, paras);
while (rowSet.next()) { while (rowSet.next()) {
row.value = 1; row.value = 1;
......
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