|
|
@ -2,6 +2,7 @@ package irbs.reports.service.impl; |
|
|
|
|
|
|
|
import dm.jdbc.util.StringUtil; |
|
|
|
import io.sc.platform.core.util.DateUtil; |
|
|
|
import io.sc.platform.jdbc.DatabaseType; |
|
|
|
import irbs.reports.jpa.entity.ReportSqlConfig; |
|
|
|
import irbs.reports.jpa.repository.ReportSqlConfigRepository; |
|
|
|
import irbs.reports.jpa.support.RptModelMonitorStableVo; |
|
|
@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.sql.DataSource; |
|
|
|
import java.sql.DatabaseMetaData; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.util.Date; |
|
|
@ -30,8 +32,11 @@ public class RptModelMonitorStableServiceImpl implements RptModelMonitorStableSe |
|
|
|
private JdbcTemplate jdbcTemplate; |
|
|
|
@Autowired |
|
|
|
private ReportSqlConfigRepository reportSqlConfigRepository; |
|
|
|
@Autowired |
|
|
|
private DataSource dataSource; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<RptModelMonitorStableVo> query(QueryParams queryParams) throws SQLException { |
|
|
|
public List<RptModelMonitorStableVo> query(QueryParams queryParams) throws Exception { |
|
|
|
//设置默认查询条件,默认查询当前所在月份的数据
|
|
|
|
if(StringUtil.isEmpty(queryParams.getRatingMonth())){ |
|
|
|
queryParams.setRatingMonth("2023-07-01"); |
|
|
@ -40,9 +45,10 @@ public class RptModelMonitorStableServiceImpl implements RptModelMonitorStableSe |
|
|
|
if(StringUtil.isEmpty(queryParams.getModelCode())){ |
|
|
|
queryParams.setModelCode("WHM18"); |
|
|
|
} |
|
|
|
DatabaseMetaData md = jdbcTemplate.getDataSource().getConnection().getMetaData(); |
|
|
|
String dataBaseType = md.getDatabaseProductName(); |
|
|
|
ReportSqlConfig reportSqlConfig = reportSqlConfigRepository.findByReportIdAndDataBaseType("rptModelMonitorStable", dataBaseType); |
|
|
|
// DatabaseMetaData md = jdbcTemplate.getDataSource().getConnection().getMetaData();
|
|
|
|
// String dataBaseType = md.getDatabaseProductName();
|
|
|
|
DatabaseType type = DatabaseType.fromMetaData(dataSource); |
|
|
|
ReportSqlConfig reportSqlConfig = reportSqlConfigRepository.findByReportIdAndDataBaseType("rptModelMonitorStable", type.getProductName()); |
|
|
|
if(reportSqlConfig != null){ |
|
|
|
String sql = reportSqlConfig.getSqlText(); |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|