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

update codes

parent 921af55b
...@@ -72,54 +72,56 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim ...@@ -72,54 +72,56 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
private void insertAndDel(DeviceCurrentEstimatePfrTmp deviceCurrentEstimatePfrTmp) { private void insertAndDel(DeviceCurrentEstimatePfrTmp deviceCurrentEstimatePfrTmp) {
Statement statement = null; Statement statement = null;
Date date = new Date(); Date date = new Date();
try{ if(null != deviceCurrentEstimatePfrTmp){
statement = connection.createStatement(); try{
statement.executeUpdate( statement = connection.createStatement();
String.format( statement.executeUpdate(
"insert into device_recently_estimate_view_pfr("+ String.format(
"device_id," + "insert into device_recently_estimate_view_pfr("+
"statistics_type," + "device_id," +
"statistics_type_id," + "statistics_type," +
"project_pfr," + "statistics_type_id," +
"first_demands_pfr," + "project_pfr," +
"first_positions_pfr," + "first_demands_pfr," +
"first_solutions_pfr," + "first_positions_pfr," +
"second_demands_pfr," + "first_solutions_pfr," +
"second_positions_pfr," + "second_demands_pfr," +
"second_solutions_pfr," + "second_positions_pfr," +
"partition_date," + "second_solutions_pfr," +
"last_update_time" "partition_date," +
+ ") values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", "last_update_time"
deviceCurrentEstimatePfrTmp.getDeviceId(), + ") values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
deviceCurrentEstimatePfrTmp.getStatisticsType(), deviceCurrentEstimatePfrTmp.getDeviceId(),
deviceCurrentEstimatePfrTmp.getStatisticsTypeId(), deviceCurrentEstimatePfrTmp.getStatisticsType(),
deviceCurrentEstimatePfrTmp.getProjectPfr(), deviceCurrentEstimatePfrTmp.getStatisticsTypeId(),
deviceCurrentEstimatePfrTmp.getFirstDemandsPfr(), deviceCurrentEstimatePfrTmp.getProjectPfr(),
deviceCurrentEstimatePfrTmp.getFirstPositionsPfr(), deviceCurrentEstimatePfrTmp.getFirstDemandsPfr(),
deviceCurrentEstimatePfrTmp.getFirstSolutionsPfr(), deviceCurrentEstimatePfrTmp.getFirstPositionsPfr(),
deviceCurrentEstimatePfrTmp.getSecondDemandsPfr(), deviceCurrentEstimatePfrTmp.getFirstSolutionsPfr(),
deviceCurrentEstimatePfrTmp.getSecondPositionsPfr(), deviceCurrentEstimatePfrTmp.getSecondDemandsPfr(),
deviceCurrentEstimatePfrTmp.getSecondSolutionsPfr(), deviceCurrentEstimatePfrTmp.getSecondPositionsPfr(),
DateUtils.getDateStr(date), deviceCurrentEstimatePfrTmp.getSecondSolutionsPfr(),
DateUtils.getTimeStr(date) DateUtils.getDateStr(date),
) DateUtils.getTimeStr(date)
); )
statement.executeUpdate( );
String.format( statement.executeUpdate(
"delete from device_recently_estimate_view_pfr where " + String.format(
"device_id = '%s' and " + "delete from device_recently_estimate_view_pfr where " +
"statistics_type = '%s' and " + "device_id = '%s' and " +
"statistics_type_id = '%s' and " + "statistics_type = '%s' and " +
"last_update_time <= '%s'", "statistics_type_id = '%s' and " +
deviceCurrentEstimatePfrTmp.getDeviceId(), "last_update_time <= '%s'",
deviceCurrentEstimatePfrTmp.getStatisticsType(), deviceCurrentEstimatePfrTmp.getDeviceId(),
deviceCurrentEstimatePfrTmp.getStatisticsTypeId(), deviceCurrentEstimatePfrTmp.getStatisticsType(),
DateUtils.getSevenDaysAgoTimeStr(date) deviceCurrentEstimatePfrTmp.getStatisticsTypeId(),
) DateUtils.getSevenDaysAgoTimeStr(date)
); )
JDBCUtils.close(null,statement,null); );
}catch (Exception e){ JDBCUtils.close(null,statement,null);
e.printStackTrace(); }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