| | |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | import javax.swing.plaf.synth.SynthScrollPaneUI; |
| | |
| | | List row=new ArrayList(); |
| | | row.add(ActionUtil.chageDateToString(rs.getTimestamp("record_time"), ActionUtil.time_yyyyMMddHHmmss).trim()); |
| | | for (int i = 0; i < state.length; i++) { |
| | | row.add(rs.getFloat(state[i])); |
| | | String stateString=state[i]; |
| | | if(stateString.contains("switching_value")) { |
| | | if(stateString.equals("switching_value_one")) { |
| | | int switching_value_one=rs.getInt("switching_value_one"); |
| | | for (int j= 0; j < 32; j++) { |
| | | int a=getBinaryByInt(j, switching_value_one); |
| | | row.add(a); |
| | | } |
| | | } |
| | | if(stateString.equals("switching_value_two")) { |
| | | int switching_value_two=rs.getInt("switching_value_two"); |
| | | for (int j= 0; j < 24; j++) { |
| | | row.add(getBinaryByInt(j, switching_value_two)); |
| | | } |
| | | } |
| | | if(stateString.equals("switching_value_three")) { |
| | | int switching_value_three=rs.getInt("switching_value_three"); |
| | | for (int j= 0; j < 20; j++) { |
| | | row.add(getBinaryByInt(j, switching_value_three)); |
| | | } |
| | | } |
| | | if(stateString.equals("switching_value_four")) { |
| | | int switching_value_four=rs.getInt("switching_value_four"); |
| | | for (int j= 0; j < 15; j++) { |
| | | row.add(getBinaryByInt(j, switching_value_four)); |
| | | } |
| | | } |
| | | |
| | | }else{ |
| | | row.add(rs.getFloat(state[i])); |
| | | } |
| | | } |
| | | list.add(row); |
| | | } |
| | |
| | | //System.out.println(dateString); |
| | | return dateString; |
| | | } |
| | | //整数转换为2进制后取每一位上面的值 |
| | | private static int getBinaryByInt(int position,int number){ |
| | | int Binary=number>>position&1; |
| | | return Binary; |
| | | } |
| | | public static void main(String[] args) { |
| | | Partin_elemonitorImpl pimpl=new Partin_elemonitorImpl(); |
| | | /*List<Partin_elemonitor> list=pimpl.searchAll(); |
| | |
| | | for (Partin_elemonitor p : list) { |
| | | System.out.println(p); |
| | | }*/ |
| | | changeDateFrom("tb_partin_elemonitor_2021_05_20"); |
| | | //changeDateFrom("tb_partin_elemonitor_2021_05_20"); |
| | | System.out.println(getBinaryByInt(8,256)); |
| | | } |
| | | |
| | | } |