From dfcc9f5693c44fcc52a9b0b261ae4dce69bbdb8c Mon Sep 17 00:00:00 2001
From: 6c <420680616@qq.com>
Date: 星期五, 19 九月 2025 10:50:12 +0800
Subject: [PATCH] 请求历史特殊处理-若是多次维修导致报表库数据重复,那么按照主键取最新数据
---
product-server-datasource/src/main/java/com/product/datasource/dao/impl/OracleDaoImpl.java | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/product-server-datasource/src/main/java/com/product/datasource/dao/impl/OracleDaoImpl.java b/product-server-datasource/src/main/java/com/product/datasource/dao/impl/OracleDaoImpl.java
index 56db4d0..3ecf140 100644
--- a/product-server-datasource/src/main/java/com/product/datasource/dao/impl/OracleDaoImpl.java
+++ b/product-server-datasource/src/main/java/com/product/datasource/dao/impl/OracleDaoImpl.java
@@ -7,7 +7,6 @@
import com.product.core.config.Global;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
-import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.datasource.config.DataBaseType;
import com.product.datasource.config.ErrorCode;
@@ -19,8 +18,6 @@
import com.product.datasource.utils.BatchUtil;
import org.apache.commons.lang3.StringUtils;
-import java.lang.ref.PhantomReference;
-import java.lang.ref.WeakReference;
import java.sql.*;
import java.util.List;
@@ -65,7 +62,7 @@
}
private void info(String message) {
- if (this.outLog) {
+ if (this.outLog || "true".equals(Global.getSystemConfig("log.sql.print", "false")) ) {
SpringMVCContextHolder.getSystemLogger().info(message);
}
}
@@ -89,7 +86,7 @@
}
return this.connection;
} catch (Exception e) {
- e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
throw new BaseException(ErrorCode.GET_CONNECTION_FAIL, e);
}
}
@@ -138,6 +135,7 @@
ResultSet resultSet = pst.executeQuery();
return loaddingDataList(resultSet);
} catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
SpringMVCContextHolder.getSystemLogger().error("EXECUTE_ERROR_SQL:\n" + sql);
throw new BaseException(ErrorCode.GET_LIST_FAIL, e);
}
@@ -427,6 +425,7 @@
pst.execute();
} catch (Exception e) {
e.printStackTrace();
+ SpringMVCContextHolder.getSystemLogger().error(e);
throw new BaseException(ErrorCode.ADD_RECORD_FAIL, e);
}
}
@@ -486,6 +485,7 @@
info("鎵ц鎵归噺鎻愪氦鏁版嵁瀹屾垚锛屽叡鎻愪氦 " + data.getRows() + " 鏉�,鑰楁椂锛�" + timer.intervalSecond() + " 绉� 锛�");
pst.clearBatch();
} catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
throw e;
} finally {
connection.setAutoCommit(true);
@@ -532,11 +532,13 @@
}
return pst.executeUpdate();
} catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
throw e;
} finally {
// this.closeConnection();
}
} catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
throw new BaseException(ErrorCode.UPDATE_BATCH_ERROR, e);
}
}
@@ -597,7 +599,7 @@
int[] ints = pst.executeBatch();
info("鎵ц鎵归噺鎻愪氦鏁版嵁瀹屾垚锛屽叡鎻愪氦 " + data.getRows() + " 鏉�,鑰楁椂锛�" + timer.intervalSecond() + " 绉� 锛�");
pst.clearBatch();
- if (isCommit) {
+ if (isCommit && !connection.getAutoCommit()) {
connection.commit();
}
int successCount = 0;
@@ -610,14 +612,16 @@
batchResultEntity.setConnection(connection);
return batchResultEntity;
} catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
throw e;
} finally {
- if (isCommit) {
+ if (isCommit && !connection.isClosed() && !connection.getAutoCommit()) {
connection.setAutoCommit(true);
}
-// this.closeConnection();
+// this.closeConnection();
}
} catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
throw new BaseException(ErrorCode.UPDATE_BATCH_ERROR, e);
}
}
@@ -688,6 +692,7 @@
}
return pst.executeUpdate();
} catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(e);
throw new OracleDaoImpl.BaseException(ErrorCode.EXECUTE_SQL_FAIL, e);
}
}
--
Gitblit v1.9.2