Commit 2beb31d3 by 余根龙

增加fast

parent 10f8b792
......@@ -31,12 +31,12 @@ public class GreenRadioSink extends RichSinkFunction<Cycle> {
//String path = ".\\realtime\\hologram-streaming\\src\\main\\resources\\mysql.properties";
connection = MySQLUtils.getConnection();
String cycleSql="insert into app_cycle_green_ratio" +
"(id,cross_code,signal_code,begin_time,end_time,duration,cycle_order,green_ratio,loss_time,update_time) " +
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
"(id,cross_id,signal_code,begin_time,end_time,duration,cycle_order,green_ratio,loss_time,statistic_time,record_date,p_month) " +
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
insertCyclePstmt = connection.prepareStatement(cycleSql);
String phaseSql="insert into app_phase_green_ratio(cycle_order,cross_code,phase_value,begin_time,end_time,duration,phase_order,green_ratio,valid_green,loss_time,update_time) values (?,?,?,?,?,?,?,?,?,?,?)";
insertPhasePstmt = connection.prepareStatement(phaseSql);
//String phaseSql="insert into app_phase_green_ratio(cycle_order,cross_code,phase_value,begin_time,end_time,duration,phase_order,green_ratio,valid_green,loss_time,update_time) values (?,?,?,?,?,?,?,?,?,?,?)";
//insertPhasePstmt = connection.prepareStatement(phaseSql);
}
@Override
public void close() throws Exception {
......@@ -57,24 +57,27 @@ public class GreenRadioSink extends RichSinkFunction<Cycle> {
insertCyclePstmt.setDouble(8, cycle.getGreenRatio());
insertCyclePstmt.setInt(9, cycle.getLossTime());
insertCyclePstmt.setString(10, DateUtils.getTodayTime());
insertCyclePstmt.setString(11, DateUtils.getTodayDate());
insertCyclePstmt.setString(12, DateUtils.getCurrentMonth());
insertCyclePstmt.execute();
List<Stage> stageList = cycle.getStageList();
for(int i=0;i<stageList.size();i++){
Stage phase = stageList.get(i);
insertPhasePstmt.setLong(1,cycle.getCycleOrder());
insertPhasePstmt.setString(2,cycle.getCrossCode());
insertPhasePstmt.setString(3,phase.getPhaseValue());
insertPhasePstmt.setString(4, cycle.getBeginDateTime());
insertPhasePstmt.setString(5, cycle.getEndDateTime());
insertPhasePstmt.setInt(6,cycle.getDuration());
insertPhasePstmt.setInt(7,phase.getPhaseOrder());
insertPhasePstmt.setDouble(8,phase.getGreenRatio());
insertPhasePstmt.setInt(9,phase.getValidGreen());
insertPhasePstmt.setInt(10,phase.getLossTime());
insertPhasePstmt.setString(11, DateUtils.getTodayTime());
insertPhasePstmt.addBatch();
}
insertPhasePstmt.executeBatch();
insertPhasePstmt.clearBatch();
//List<Stage> stageList = cycle.getStageList();
//for(int i=0;i<stageList.size();i++){
// Stage phase = stageList.get(i);
// insertPhasePstmt.setLong(1,cycle.getCycleOrder());
// insertPhasePstmt.setString(2,cycle.getCrossCode());
// insertPhasePstmt.setString(3,phase.getPhaseValue());
// insertPhasePstmt.setString(4, cycle.getBeginDateTime());
// insertPhasePstmt.setString(5, cycle.getEndDateTime());
// insertPhasePstmt.setInt(6,cycle.getDuration());
// insertPhasePstmt.setInt(7,phase.getPhaseOrder());
// insertPhasePstmt.setDouble(8,phase.getGreenRatio());
// insertPhasePstmt.setInt(9,phase.getValidGreen());
// insertPhasePstmt.setInt(10,phase.getLossTime());
// insertPhasePstmt.setString(11, DateUtils.getTodayTime());
// insertPhasePstmt.addBatch();
//}
//insertPhasePstmt.executeBatch();
//insertPhasePstmt.clearBatch();
}
}
......@@ -1058,7 +1058,7 @@ public class DateUtils {
* 例如 202211
* @return
*/
public static String getCurrentMonthPartition() {
public static String getCurrentMonth() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMM");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
return simpleDateFormat.format(new Date());
......
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