33import java .io .IOException ;
44import java .time .LocalDate ;
55import java .time .format .DateTimeFormatter ;
6+ import java .util .ArrayList ;
7+ import java .util .Collections ;
68import java .util .HashMap ;
79import java .util .List ;
810import java .util .Map ;
@@ -81,11 +83,7 @@ public MonitoringAPController(Class<T> clazz) {
8183
8284 // Add comoboBox click listner
8385 this .aliasComboBox .getSelectionModel ().selectedItemProperty ().addListener ((options , oldVlaue , newValue ) -> {
84- // monitoringResultTV.getItems().clear();
85- // if (tableDataMap != null && tableDataMap.get(newValue) != null) {
86- System .out .println ("changed: " + oldVlaue + "->" + newValue );
87- syncTableData (newValue );
88- // }
86+ syncTableData (newValue , 0 );
8987 });
9088
9189 // Setting inquiry datepicker initial value
@@ -99,8 +97,12 @@ public MonitoringAPController(Class<T> clazz) {
9997 int defaultRoundingDigits = propertyRepo .getIntegerCommonResource ("unit.rounding" );
10098 this .roundComboBox .getSelectionModel ().select (Integer .valueOf (defaultRoundingDigits ));
10199
102- // Set pagination count
103- this .pagination .setPageCount (1 );
100+ // Set pagination property
101+ this .pagination .currentPageIndexProperty ().addListener ((observable , oldValue , newValue ) -> {
102+ String selected = aliasComboBox .getSelectionModel ().getSelectedItem ();
103+ syncTableData (selected , newValue .intValue ());
104+ });
105+
104106 } catch (IOException e ) {
105107 }
106108 }
@@ -154,7 +156,7 @@ public void addTableDataSet(String id, Map<String, List<T>> dataList) {
154156 *
155157 * @param id
156158 */
157- public void syncTableData (String id ) {
159+ public void syncTableData (String id , int index ) {
158160 // Set Alias comboBox
159161 aliasComboBox .getSelectionModel ().select (id );
160162
@@ -171,9 +173,11 @@ public void syncTableData(String id) {
171173
172174 // Add tableView items
173175 Map <String , List <T >> data = tableDataMap .get (id );
174- monitoringResultTV .setItems (FXCollections .observableList (data .values ().stream ().findFirst ().get ()));
176+ List <String > times = new ArrayList <>(data .keySet ());
177+ Collections .sort (times );
178+ monitoringResultTV .setItems (FXCollections .observableList (data .get (times .get (index ))));
175179 }
176-
180+
177181 /**
178182 * tableData에 세팅된 데이터의 Row수를 반환한다.
179183 *
@@ -247,7 +251,23 @@ public void setAnchor(double left, double top, double right, double bottom) {
247251 * @param e
248252 */
249253 public void run (ActionEvent e ) {
254+ String selected = aliasComboBox .getSelectionModel ().getSelectedItem ();
255+
256+ // Clear data
257+ clearTableData (selected );
258+
259+ Map <String , List <T >> allDataList = inquiryMonitoringHistory ();
260+ if (allDataList == null || allDataList .size () == 0 ) {
261+ AlertUtils .showAlert (AlertType .INFORMATION , "조회결과 없음" , "해당일자의 모니터링 기록이 없습니다." );
262+ return ;
263+ }
264+
265+ // Add and Sync data
266+ addTableDataSet (selected , allDataList );
267+ syncTableData (selected , 0 );
268+ }
250269
270+ private Map <String , List <T >> inquiryMonitoringHistory () {
251271 // Get selected inquiry condition
252272 String inquiryDate = this .inquiryDatePicker .getValue ().format (DateTimeFormatter .ofPattern ("yyyyMMdd" ));
253273 String selected = aliasComboBox .getSelectionModel ().getSelectedItem ();
@@ -256,20 +276,9 @@ public void run(ActionEvent e) {
256276
257277 // TODO Show Progress UI
258278
259- // Clear data
260- clearTableData (selected );
261-
262279 // Acquire data on inquiry date
263- Map <String , List <T >> allDataList = reportUsecase .getMonitoringReportDataByTime (this .clazz , selected ,
264- selectedUnit , selectedRoundUnit , inquiryDate );
265- if (allDataList == null || allDataList .size () == 0 ) {
266- AlertUtils .showAlert (AlertType .INFORMATION , "조회결과 없음" , "해당일자의 모니터링 기록이 없습니다." );
267- return ;
268- }
269-
270- // Add and Sync data
271- addTableDataSet (selected , allDataList );
272- syncTableData (selected );
280+ return reportUsecase .getMonitoringReportDataByTime (this .clazz , selected , selectedUnit , selectedRoundUnit ,
281+ inquiryDate );
273282 }
274283
275284 /**
0 commit comments