Commit 9fb0bfe0 authored by 赵建伟's avatar 赵建伟

update codes

parent 921af55b
......@@ -72,54 +72,56 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
private void insertAndDel(DeviceCurrentEstimatePfrTmp deviceCurrentEstimatePfrTmp) {
Statement statement = null;
Date date = new Date();
try{
statement = connection.createStatement();
statement.executeUpdate(
String.format(
"insert into device_recently_estimate_view_pfr("+
"device_id," +
"statistics_type," +
"statistics_type_id," +
"project_pfr," +
"first_demands_pfr," +
"first_positions_pfr," +
"first_solutions_pfr," +
"second_demands_pfr," +
"second_positions_pfr," +
"second_solutions_pfr," +
"partition_date," +
"last_update_time"
+ ") values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
deviceCurrentEstimatePfrTmp.getDeviceId(),
deviceCurrentEstimatePfrTmp.getStatisticsType(),
deviceCurrentEstimatePfrTmp.getStatisticsTypeId(),
deviceCurrentEstimatePfrTmp.getProjectPfr(),
deviceCurrentEstimatePfrTmp.getFirstDemandsPfr(),
deviceCurrentEstimatePfrTmp.getFirstPositionsPfr(),
deviceCurrentEstimatePfrTmp.getFirstSolutionsPfr(),
deviceCurrentEstimatePfrTmp.getSecondDemandsPfr(),
deviceCurrentEstimatePfrTmp.getSecondPositionsPfr(),
deviceCurrentEstimatePfrTmp.getSecondSolutionsPfr(),
DateUtils.getDateStr(date),
DateUtils.getTimeStr(date)
)
);
statement.executeUpdate(
String.format(
"delete from device_recently_estimate_view_pfr where " +
"device_id = '%s' and " +
"statistics_type = '%s' and " +
"statistics_type_id = '%s' and " +
"last_update_time <= '%s'",
deviceCurrentEstimatePfrTmp.getDeviceId(),
deviceCurrentEstimatePfrTmp.getStatisticsType(),
deviceCurrentEstimatePfrTmp.getStatisticsTypeId(),
DateUtils.getSevenDaysAgoTimeStr(date)
)
);
JDBCUtils.close(null,statement,null);
}catch (Exception e){
e.printStackTrace();
if(null != deviceCurrentEstimatePfrTmp){
try{
statement = connection.createStatement();
statement.executeUpdate(
String.format(
"insert into device_recently_estimate_view_pfr("+
"device_id," +
"statistics_type," +
"statistics_type_id," +
"project_pfr," +
"first_demands_pfr," +
"first_positions_pfr," +
"first_solutions_pfr," +
"second_demands_pfr," +
"second_positions_pfr," +
"second_solutions_pfr," +
"partition_date," +
"last_update_time"
+ ") values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
deviceCurrentEstimatePfrTmp.getDeviceId(),
deviceCurrentEstimatePfrTmp.getStatisticsType(),
deviceCurrentEstimatePfrTmp.getStatisticsTypeId(),
deviceCurrentEstimatePfrTmp.getProjectPfr(),
deviceCurrentEstimatePfrTmp.getFirstDemandsPfr(),
deviceCurrentEstimatePfrTmp.getFirstPositionsPfr(),
deviceCurrentEstimatePfrTmp.getFirstSolutionsPfr(),
deviceCurrentEstimatePfrTmp.getSecondDemandsPfr(),
deviceCurrentEstimatePfrTmp.getSecondPositionsPfr(),
deviceCurrentEstimatePfrTmp.getSecondSolutionsPfr(),
DateUtils.getDateStr(date),
DateUtils.getTimeStr(date)
)
);
statement.executeUpdate(
String.format(
"delete from device_recently_estimate_view_pfr where " +
"device_id = '%s' and " +
"statistics_type = '%s' and " +
"statistics_type_id = '%s' and " +
"last_update_time <= '%s'",
deviceCurrentEstimatePfrTmp.getDeviceId(),
deviceCurrentEstimatePfrTmp.getStatisticsType(),
deviceCurrentEstimatePfrTmp.getStatisticsTypeId(),
DateUtils.getSevenDaysAgoTimeStr(date)
)
);
JDBCUtils.close(null,statement,null);
}catch (Exception e){
e.printStackTrace();
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment