|
@@ -14,6 +14,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.ResultSetExtractor;
|
|
import org.springframework.jdbc.core.ResultSetExtractor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.ClassUtils;
|
|
import org.springframework.util.ClassUtils;
|
|
|
|
+
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
@@ -58,13 +59,13 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
// 从表中获取旧版本
|
|
// 从表中获取旧版本
|
|
String oldVersion = getVersion();
|
|
String oldVersion = getVersion();
|
|
// 如果版本没变化,不进行初始化表操作
|
|
// 如果版本没变化,不进行初始化表操作
|
|
- if(oldVersion.equals(version) || oldVersion.equals("null")){
|
|
|
|
|
|
+ if (oldVersion.equals(version) || oldVersion.equals("null")) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
// 如果版本不同,则初始化表
|
|
// 如果版本不同,则初始化表
|
|
this.createTable();
|
|
this.createTable();
|
|
- // 如果表不存在,初始化表
|
|
|
|
- }else{
|
|
|
|
|
|
+ // 如果表不存在,初始化表
|
|
|
|
+ } else {
|
|
this.createTable();
|
|
this.createTable();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -155,20 +156,20 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
* 查询公式数据
|
|
* 查询公式数据
|
|
*
|
|
*
|
|
* @param type 类型
|
|
* @param type 类型
|
|
- * @param province 省调
|
|
|
|
|
|
+ * @param province 省调
|
|
* @param formulaType 公式类型
|
|
* @param formulaType 公式类型
|
|
* @param electricType 场站类型
|
|
* @param electricType 场站类型
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public CalculationFormula findByTypeAndProvince(String type, String formulaType, String province, String electricType) {
|
|
public CalculationFormula findByTypeAndProvince(String type, String formulaType, String province, String electricType) {
|
|
-
|
|
|
|
String sql = "";
|
|
String sql = "";
|
|
|
|
+ electricType = "%" + electricType + "%";
|
|
// 查询sql
|
|
// 查询sql
|
|
if (CalculateResult.FORMULA.equals(type)) {
|
|
if (CalculateResult.FORMULA.equals(type)) {
|
|
- sql = "SELECT * from t_calculation_formula where ELECTRIC_TYPE = ? and PROVINCE = ? and TYPE = ? limit 1 ";
|
|
|
|
|
|
+ sql = "SELECT * from t_calculation_formula where ELECTRIC_TYPE like ? and PROVINCE = ? and TYPE = ? limit 1 ";
|
|
} else if (CalculateResult.RULES.equals(type)) {
|
|
} else if (CalculateResult.RULES.equals(type)) {
|
|
- sql = "SELECT * from t_calculation_formula where TYPE = 'RULES' and ELECTRIC_TYPE = ? and PROVINCE = ? and RULE_FORMULA = ? limit 1";
|
|
|
|
|
|
+ sql = "SELECT * from t_calculation_formula where TYPE = 'RULES' and ELECTRIC_TYPE like ? and PROVINCE = ? and RULE_FORMULA = ? limit 1";
|
|
}
|
|
}
|
|
// 根据类型和省调查询公式
|
|
// 根据类型和省调查询公式
|
|
try {
|
|
try {
|
|
@@ -182,7 +183,7 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
/**
|
|
/**
|
|
* 创建表
|
|
* 创建表
|
|
*/
|
|
*/
|
|
- private void createTable(){
|
|
|
|
|
|
+ private void createTable() {
|
|
try {
|
|
try {
|
|
// 获取初始化公式表sql
|
|
// 获取初始化公式表sql
|
|
String path = "sql/t_calculation_formula.sql";
|
|
String path = "sql/t_calculation_formula.sql";
|
|
@@ -214,7 +215,7 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
/**
|
|
/**
|
|
* 获取版本
|
|
* 获取版本
|
|
*/
|
|
*/
|
|
- private String getVersion(){
|
|
|
|
|
|
+ private String getVersion() {
|
|
String version = "";
|
|
String version = "";
|
|
String sql = " SELECT * FROM t_calculation_formula where type = 'VERSION' ";
|
|
String sql = " SELECT * FROM t_calculation_formula where type = 'VERSION' ";
|
|
try {
|
|
try {
|
|
@@ -229,9 +230,9 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
/**
|
|
/**
|
|
* 更新版本
|
|
* 更新版本
|
|
*/
|
|
*/
|
|
- private void updateVersion(){
|
|
|
|
|
|
+ private void updateVersion() {
|
|
String version = properties.getVersion();
|
|
String version = properties.getVersion();
|
|
- String sql = " UPDATE t_calculation_formula set FORMULA = '" + version +"' where type = 'VERSION' ";
|
|
|
|
|
|
+ String sql = " UPDATE t_calculation_formula set FORMULA = '" + version + "' where type = 'VERSION' ";
|
|
try {
|
|
try {
|
|
jdbcTemplate.update(sql);
|
|
jdbcTemplate.update(sql);
|
|
} catch (DataAccessException e) {
|
|
} catch (DataAccessException e) {
|