补数据少一天问题处理
查看代码
接口是
@PostMapping(value = "/data/repair")
@ResponseStatus(HttpStatus.OK)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result repairData(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "projectCode") long projectCode,
@RequestParam String scheduleTime,
@RequestParam(value = "processDefinitionCode") long processDefinitionCode,
@RequestParam(value = "runMode") RunMode runMode){
return customizationCycleTaskDefService.repairData(loginUser, projectCode, processDefinitionCode, scheduleTime, runMode);
}
查询数据源
Page<DataSource> dataSourcePage = new Page<>(pageNo, pageSize);
dataSourceList = dataSourceMapper.selectPaging(dataSourcePage,
UserType.ADMIN_USER.equals(loginUser.getUserType()) ? 0 : loginUser.getId(),
searchVal,type);
直接加一个字段就好。
新建数据源
@ApiOperation(value = "createDataSource", notes = "CREATE_DATA_SOURCE_NOTES")
@PostMapping()
@ResponseStatus(HttpStatus.CREATED)
@ApiException(CREATE_DATASOURCE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result createDataSource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@ApiParam(name = "dataSourceParam", value = "DATA_SOURCE_PARAM", required = true) @RequestBody String jsonStr) {
BaseDataSourceParamDTO dataSourceParam = DataSourceUtils.buildDatasourceParam(jsonStr);
return dataSourceService.createDataSource(loginUser, dataSourceParam);
}
/**
* build connection url
*/
public static BaseDataSourceParamDTO buildDatasourceParam(String param) {
JsonNode jsonNodes = JSONUtils.parseObject(param);
return getDatasourceProcessor(DbType.ofName(jsonNodes.get("type").asText().toUpperCase()))
.castDatasourceParamDTO(param);
}
类 HiveDataSourceParamDTO 和抽象类 BaseHDFSDataSourceParamDTO
需要更新的jar
数据库操作工具类优化
在这个示例代码中,我们使用枚举类型DriverType来表示不同的数据库类型,使用getCode()方法获取code参数的枚举值,并使用getDriverClassName()方法获取对应的驱动程序。另外,在这个示例中,我们增加了一个方法fromCode(),用于根据code参数返回对应的枚举类型,这样我们就可以通过code参数来获取对应的驱动程序。
需要注意的是,如果code参数的值是未知的,则会抛出IllegalArgumentException异常。另外,建议使用try-with-resources语句来确保资源被正确关闭。
public Connection openConn(String url, String username, String password, int code) {
DriverType driverType = DriverType.fromCode(code);
String driverClassName = driverType.getDriverClassName();
Connection connection = null;
try {
Class.forName(driverClassName);
connection = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
logger.info("Failed to load driver class " + driverClassName, e.getCause());
} catch (SQLException e) {
logger.info("Failed to connect to database", e.getCause());
}
return connection;
}