|
@@ -2,6 +2,7 @@ package com.syjy.calculate.repository.repositoryImpl;
|
|
|
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.db.sql.SqlUtil;
|
|
|
import cn.hutool.poi.excel.ExcelReader;
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
@@ -482,7 +483,11 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
|
case CalculateResult.DB_POSTGRES:
|
|
|
case CalculateResult.DB_HIGHGO:
|
|
|
case CalculateResult.DB_XUGU:
|
|
|
- jdbcTemplate.execute(SqlUtil.formatSql(IoUtil.read(sqlInputStream, StandardCharsets.UTF_8)));
|
|
|
+ String initSQL = SqlUtil.formatSql(IoUtil.read(sqlInputStream, StandardCharsets.UTF_8));
|
|
|
+ List<String> ddls = StrUtil.splitTrim(initSQL, ";");
|
|
|
+ for (String ddl : ddls) {
|
|
|
+ jdbcTemplate.execute(ddl);
|
|
|
+ }
|
|
|
jdbcTemplate.batchUpdate("INSERT INTO T_CALCULATION_FORMULA VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", pss);
|
|
|
break;
|
|
|
case CalculateResult.DB_MYSQL:
|
|
@@ -513,7 +518,18 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
|
*/
|
|
|
private String getVersion() {
|
|
|
String version = "";
|
|
|
+ String dbType = properties.getDbType();
|
|
|
String sql = " SELECT * FROM t_calculation_formula where type = 'VERSION' ";
|
|
|
+ switch (dbType) {
|
|
|
+ case CalculateResult.DB_KINGBASE:
|
|
|
+ case CalculateResult.DB_POSTGRES:
|
|
|
+ case CalculateResult.DB_HIGHGO:
|
|
|
+ case CalculateResult.DB_XUGU:
|
|
|
+ sql = " SELECT * FROM t_calculation_formula where \"TYPE\" = 'VERSION' ";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ sql = " SELECT * FROM t_calculation_formula where type = 'VERSION' ";
|
|
|
+ }
|
|
|
try {
|
|
|
CalculationFormula calculationFormula = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(CalculationFormula.class));
|
|
|
version = calculationFormula.getFormula();
|
|
@@ -528,7 +544,18 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
|
*/
|
|
|
@Override
|
|
|
public List<CalculationFormula> getUser() {
|
|
|
+ String dbType = properties.getDbType();
|
|
|
String sql = " SELECT * FROM t_calculation_formula where type = 'USER' ";
|
|
|
+ switch (dbType) {
|
|
|
+ case CalculateResult.DB_KINGBASE:
|
|
|
+ case CalculateResult.DB_POSTGRES:
|
|
|
+ case CalculateResult.DB_HIGHGO:
|
|
|
+ case CalculateResult.DB_XUGU:
|
|
|
+ sql = " SELECT * FROM t_calculation_formula where \"TYPE\" = 'USER' ";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ sql = " SELECT * FROM t_calculation_formula where type = 'USER' ";
|
|
|
+ }
|
|
|
List<CalculationFormula> list = new ArrayList<>();
|
|
|
try {
|
|
|
list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(CalculationFormula.class));
|
|
@@ -543,7 +570,18 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
|
*/
|
|
|
private void updateVersion() {
|
|
|
String version = properties.getVersion();
|
|
|
+ String dbType = properties.getDbType();
|
|
|
String sql = " UPDATE t_calculation_formula set FORMULA = '" + version + "' where type = 'VERSION' ";
|
|
|
+ switch (dbType) {
|
|
|
+ case CalculateResult.DB_KINGBASE:
|
|
|
+ case CalculateResult.DB_POSTGRES:
|
|
|
+ case CalculateResult.DB_HIGHGO:
|
|
|
+ case CalculateResult.DB_XUGU:
|
|
|
+ sql = " UPDATE t_calculation_formula SET \"FORMULA\"='" + version + "' WHERE \"TYPE\"='VERSION' ";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ sql = " UPDATE t_calculation_formula set FORMULA = '" + version + "' where type = 'VERSION' ";
|
|
|
+ }
|
|
|
try {
|
|
|
jdbcTemplate.update(sql);
|
|
|
} catch (DataAccessException e) {
|