|
@@ -254,22 +254,41 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public CalculationFormula findByTypeAndProvince(String type, String formulaType, String province, String electricType) {
|
|
|
+ public CalculationFormula findByTypeAndProvince(String type, String formulaType, String province, String electricType,String stationCode) {
|
|
|
String sql = "";
|
|
|
electricType = "%" + electricType + "%";
|
|
|
+ if(stationCode!=null && !"".equals(stationCode)){
|
|
|
+ stationCode = "%" + stationCode + "%";
|
|
|
+ }
|
|
|
// 查询sql
|
|
|
if (CalculateResult.FORMULA.equals(type)) {
|
|
|
- sql = "SELECT * from t_calculation_formula where state = '1' and ELECTRIC_TYPE like ? and PROVINCE = ? and TYPE = ? limit 1 ";
|
|
|
+ sql = "SELECT * from t_calculation_formula where state = '1' and ELECTRIC_TYPE like ? and PROVINCE = ? and TYPE = ? and STATION_CODE like ? limit 1 ";
|
|
|
} else if (CalculateResult.RULES.equals(type)) {
|
|
|
- sql = "SELECT * from t_calculation_formula where state = '1' and TYPE = 'RULES' and ELECTRIC_TYPE like ? and PROVINCE = ? and RULE_FORMULA = ? limit 1";
|
|
|
+ sql = "SELECT * from t_calculation_formula where state = '1' and TYPE = 'RULES' and ELECTRIC_TYPE like ? and PROVINCE = ? and RULE_FORMULA = ? and STATION_CODE like ? limit 1";
|
|
|
+ }else{
|
|
|
+ log.error(CalculateResult.MSG_FORMULA_TYPE_ERROR);
|
|
|
}
|
|
|
+
|
|
|
+ CalculationFormula calculationFormula = new CalculationFormula();
|
|
|
// 根据类型和省调查询公式
|
|
|
try {
|
|
|
- CalculationFormula calculationFormula = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(CalculationFormula.class), electricType, province, formulaType);
|
|
|
-
|
|
|
+ calculationFormula = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(CalculationFormula.class), electricType, province, formulaType,stationCode);
|
|
|
return calculationFormula;
|
|
|
} catch (EmptyResultDataAccessException e) {
|
|
|
- return null;
|
|
|
+ // 如果根据场站编码没查到,则在根据省调和场站类型是All的查
|
|
|
+ if (CalculateResult.FORMULA.equals(type)) {
|
|
|
+ sql = "SELECT * from t_calculation_formula where state = '1' and ELECTRIC_TYPE like ? and PROVINCE = ? and TYPE = ? and STATION_CODE = 'ALL' limit 1";
|
|
|
+ } else if (CalculateResult.RULES.equals(type)) {
|
|
|
+ sql = "SELECT * from t_calculation_formula where state = '1' and TYPE = 'RULES' and ELECTRIC_TYPE like ? and PROVINCE = ? and RULE_FORMULA = ? and STATION_CODE = 'ALL' limit 1";
|
|
|
+ }
|
|
|
+ // 根据类型和省调查询公式
|
|
|
+ try {
|
|
|
+ calculationFormula = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(CalculationFormula.class), electricType, province, formulaType);
|
|
|
+ return calculationFormula;
|
|
|
+ } catch (EmptyResultDataAccessException ere) {
|
|
|
+ // 如果根据场站编码没查到,则在根据省调和场站类型是All的查
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -296,6 +315,9 @@ public class CalculationFormulaRepositoryImpl implements CalculationFormulaRepos
|
|
|
sql = "SELECT * from t_calculation_formula where state = '1' and ELECTRIC_TYPE like ? and PROVINCE = ? and TYPE = ? and STATION_CODE like ? limit 1";
|
|
|
} else if (CalculateResult.RULES.equals(type)) {
|
|
|
sql = "SELECT * from t_calculation_formula where state = '1' and TYPE = 'RULES' and ELECTRIC_TYPE like ? and PROVINCE = ? and RULE_FORMULA = ? and STATION_CODE like ? limit 1";
|
|
|
+ }else{
|
|
|
+ log.error(CalculateResult.MSG_FORMULA_TYPE_ERROR);
|
|
|
+ return null;
|
|
|
}
|
|
|
// 根据类型和省调查询公式
|
|
|
try {
|