Commit c4d00ef13aff42e217e1c3e1ec303ad26aa67029
Merge branch 'minhang' of http://222.66.0.204:8090//panzhaov5/bsth_control into minhang
Showing
3 changed files
with
102 additions
and
7 deletions
src/main/java/com/bsth/entity/excep/Offline.java
| @@ -72,6 +72,40 @@ public class Offline { | @@ -72,6 +72,40 @@ public class Offline { | ||
| 72 | private String jsy; | 72 | private String jsy; |
| 73 | @Transient | 73 | @Transient |
| 74 | private String lpname; | 74 | private String lpname; |
| 75 | + @Transient | ||
| 76 | + private Long ts; | ||
| 77 | + | ||
| 78 | + @Transient | ||
| 79 | + private String tsdate; | ||
| 80 | + @Transient | ||
| 81 | + private String deviceid; | ||
| 82 | + | ||
| 83 | + public String getDeviceid() { | ||
| 84 | + return deviceid; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public void setDeviceid(String deviceid) { | ||
| 88 | + this.deviceid = deviceid; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + public String getTsdate() { | ||
| 94 | + return tsdate; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public void setTsdate(String tsdate) { | ||
| 98 | + this.tsdate = tsdate; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public Long getTs() { | ||
| 102 | + return ts; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void setTs(Long ts) { | ||
| 106 | + this.ts = ts; | ||
| 107 | + } | ||
| 108 | + | ||
| 75 | public Integer getId() { | 109 | public Integer getId() { |
| 76 | return id; | 110 | return id; |
| 77 | } | 111 | } |
src/main/java/com/bsth/service/excep/impl/OfflineServiceImpl.java
| @@ -4,6 +4,7 @@ import java.sql.Connection; | @@ -4,6 +4,7 @@ import java.sql.Connection; | ||
| 4 | import java.sql.PreparedStatement; | 4 | import java.sql.PreparedStatement; |
| 5 | import java.sql.ResultSet; | 5 | import java.sql.ResultSet; |
| 6 | import java.sql.SQLException; | 6 | import java.sql.SQLException; |
| 7 | +import java.text.DateFormat; | ||
| 7 | import java.text.ParseException; | 8 | import java.text.ParseException; |
| 8 | import java.text.SimpleDateFormat; | 9 | import java.text.SimpleDateFormat; |
| 9 | import java.util.ArrayList; | 10 | import java.util.ArrayList; |
| @@ -34,6 +35,35 @@ public class OfflineServiceImpl implements OfflineService { | @@ -34,6 +35,35 @@ public class OfflineServiceImpl implements OfflineService { | ||
| 34 | 35 | ||
| 35 | @Autowired | 36 | @Autowired |
| 36 | JdbcTemplate jdbcTemplate; | 37 | JdbcTemplate jdbcTemplate; |
| 38 | + public List<Offline> findGPS(Map<String, Object> map) { | ||
| 39 | + Connection conn = null; | ||
| 40 | + PreparedStatement ps = null; | ||
| 41 | + ResultSet rs = null; | ||
| 42 | + List<Offline> list=new ArrayList<Offline>(); | ||
| 43 | + String days_year=map.get("days_year").toString(); | ||
| 44 | + String line_id=map.get("line_id").toString(); | ||
| 45 | + String device_id=map.get("device_id").toString(); | ||
| 46 | + String sql="SELECT t.line_id,t.device_id,MIN(ts) as ts,days_year FROM bsth_c_gps_info t " | ||
| 47 | + + " WHERE t.line_id='"+line_id+"' and t.device_id='"+device_id+"' and t.days_year='"+days_year+"' " | ||
| 48 | + + " GROUP BY t.device_id,t.line_id "; | ||
| 49 | + sql +=" order by ts limit ?,?"; | ||
| 50 | + try { | ||
| 51 | + conn = DBUtils_MS.getConnection(); | ||
| 52 | + ps = conn.prepareStatement(sql); | ||
| 53 | + ps.setInt(1,0*10); // O-最大条数 -- M-起始条数 | ||
| 54 | + ps.setInt(2, 100000000); // O-最小条数 -- M-显示条数 | ||
| 55 | + rs = ps.executeQuery(); | ||
| 56 | + list = resultSet(rs); | ||
| 57 | + } catch (SQLException e) { | ||
| 58 | + // TODO Auto-generated catch block | ||
| 59 | + e.printStackTrace(); | ||
| 60 | + }finally { | ||
| 61 | + DBUtils_MS.close(rs, ps, conn); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + return list; | ||
| 65 | + } | ||
| 66 | + | ||
| 37 | // @Override | 67 | // @Override |
| 38 | static List<Offline> findAll(Map<String, Object> map) { | 68 | static List<Offline> findAll(Map<String, Object> map) { |
| 39 | // TODO Auto-generated method stub | 69 | // TODO Auto-generated method stub |
| @@ -100,7 +130,18 @@ public class OfflineServiceImpl implements OfflineService { | @@ -100,7 +130,18 @@ public class OfflineServiceImpl implements OfflineService { | ||
| 100 | 130 | ||
| 101 | return list; | 131 | return list; |
| 102 | } | 132 | } |
| 103 | - | 133 | + public List<Offline> resultSet(ResultSet rs) throws SQLException{ |
| 134 | + // TODO Auto-generated method stub | ||
| 135 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); | ||
| 136 | + List<Offline> list=new ArrayList<Offline>(); | ||
| 137 | + Offline offline; | ||
| 138 | + while(rs.next()){ | ||
| 139 | + offline=new Offline(); | ||
| 140 | + offline.setTs(Long.parseLong(rs.getObject("ts").toString())); | ||
| 141 | + list.add(offline); | ||
| 142 | + } | ||
| 143 | + return list; | ||
| 144 | + } | ||
| 104 | /** | 145 | /** |
| 105 | * 数据转换 | 146 | * 数据转换 |
| 106 | */ | 147 | */ |
| @@ -122,6 +163,7 @@ public class OfflineServiceImpl implements OfflineService { | @@ -122,6 +163,7 @@ public class OfflineServiceImpl implements OfflineService { | ||
| 122 | offline.setTimestampDate(sdf.format(new Date(offline.getTimestamp()))); | 163 | offline.setTimestampDate(sdf.format(new Date(offline.getTimestamp()))); |
| 123 | offline.setUpDown(Integer.valueOf(rs.getObject("up_down").toString())); | 164 | offline.setUpDown(Integer.valueOf(rs.getObject("up_down").toString())); |
| 124 | offline.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("vehicle").toString())); | 165 | offline.setVehicle(BasicData.deviceId2NbbmMap.get(rs.getObject("vehicle").toString())); |
| 166 | + offline.setDeviceid(rs.getObject("vehicle").toString()); | ||
| 125 | list.add(offline); | 167 | list.add(offline); |
| 126 | } | 168 | } |
| 127 | return list; | 169 | return list; |
| @@ -190,7 +232,9 @@ public class OfflineServiceImpl implements OfflineService { | @@ -190,7 +232,9 @@ public class OfflineServiceImpl implements OfflineService { | ||
| 190 | // List<T> list = this.baseDao.queryByObject(pageHelper.getMap()); | 232 | // List<T> list = this.baseDao.queryByObject(pageHelper.getMap()); |
| 191 | List<Offline> list=findAll(pageHelper.getMap()); | 233 | List<Offline> list=findAll(pageHelper.getMap()); |
| 192 | for (int i = 0; i < list.size(); i++) { | 234 | for (int i = 0; i < list.size(); i++) { |
| 193 | - String nbbm2=list.get(i).getVehicle() ; | 235 | + int lineid= list.get(i).getLine(); |
| 236 | + String nbbm2=list.get(i).getVehicle(); | ||
| 237 | + String deviceid=list.get(i).getDeviceid(); | ||
| 194 | Long d1=list.get(i).getTimestamp(); | 238 | Long d1=list.get(i).getTimestamp(); |
| 195 | Date datess = new Date(d1); | 239 | Date datess = new Date(d1); |
| 196 | String dates=new SimpleDateFormat("yyyy-MM-dd").format(datess); | 240 | String dates=new SimpleDateFormat("yyyy-MM-dd").format(datess); |
| @@ -209,10 +253,22 @@ public class OfflineServiceImpl implements OfflineService { | @@ -209,10 +253,22 @@ public class OfflineServiceImpl implements OfflineService { | ||
| 209 | return s; | 253 | return s; |
| 210 | } | 254 | } |
| 211 | }); | 255 | }); |
| 256 | + Map<String, Object> gpsmap=new HashMap<>(); | ||
| 257 | + String str = String.format("%tj",datess); | ||
| 258 | + gpsmap.put("device_id",deviceid ); | ||
| 259 | + gpsmap.put("line_id", lineid); | ||
| 260 | + gpsmap.put("days_year", str); | ||
| 261 | + List<Offline> gps=findGPS(gpsmap); | ||
| 262 | + if(gps.size()>0){ | ||
| 263 | + Long ts= gps.get(0).getTs(); | ||
| 264 | + String ts1 =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(ts)); | ||
| 265 | + list.get(0).setTsdate(ts1); | ||
| 266 | + } | ||
| 212 | if(pbb.size()>0){ | 267 | if(pbb.size()>0){ |
| 213 | list.get(i).setJsy(pbb.get(0).getjGh()+"/"+pbb.get(0).getjName()); | 268 | list.get(i).setJsy(pbb.get(0).getjGh()+"/"+pbb.get(0).getjName()); |
| 214 | list.get(i).setLpname(pbb.get(0).getLpName()); | 269 | list.get(i).setLpname(pbb.get(0).getLpName()); |
| 215 | } | 270 | } |
| 271 | + | ||
| 216 | } | 272 | } |
| 217 | 273 | ||
| 218 | PageObject<Offline> pageObject = pageHelper.getPageObject(); | 274 | PageObject<Offline> pageObject = pageHelper.getPageObject(); |
src/main/resources/static/pages/excep/offlineList.html
| @@ -56,11 +56,12 @@ | @@ -56,11 +56,12 @@ | ||
| 56 | <th width="3%">#</th> | 56 | <th width="3%">#</th> |
| 57 | <th width="15%">线路</th> | 57 | <th width="15%">线路</th> |
| 58 | <th width="13%">车辆自编号</th> | 58 | <th width="13%">车辆自编号</th> |
| 59 | - <th width="100">工号/名字</th> | 59 | + <th width="10%">工号/名字</th> |
| 60 | <th width="11%">路牌名</th> | 60 | <th width="11%">路牌名</th> |
| 61 | <th width="10%">上下行</th> | 61 | <th width="10%">上下行</th> |
| 62 | - <th width="18%">时间</th> | ||
| 63 | - <th width="18%">操作</th> | 62 | + <th width="18%">掉线时间</th> |
| 63 | + <th width="18%">恢复时间</th> | ||
| 64 | + <th width="20%">操作</th> | ||
| 64 | </tr> | 65 | </tr> |
| 65 | <tr role="row" class="filter"> | 66 | <tr role="row" class="filter"> |
| 66 | <td></td> | 67 | <td></td> |
| @@ -87,11 +88,12 @@ | @@ -87,11 +88,12 @@ | ||
| 87 | <td> | 88 | <td> |
| 88 | <input class="form-control" type="date" name="date" /> | 89 | <input class="form-control" type="date" name="date" /> |
| 89 | </td> | 90 | </td> |
| 91 | + <td></td> | ||
| 90 | <td> | 92 | <td> |
| 91 | <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > | 93 | <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > |
| 92 | <i class="fa fa-search"></i> 搜索</button> | 94 | <i class="fa fa-search"></i> 搜索</button> |
| 93 | - | ||
| 94 | - <button class="btn btn-sm red btn-outline filter-cancel"> | 95 | + <br> |
| 96 | + <button class="btn btn-sm red btn-outline filter-cancel "> | ||
| 95 | <i class="fa fa-times"></i> 重置</button> | 97 | <i class="fa fa-times"></i> 重置</button> |
| 96 | </td> | 98 | </td> |
| 97 | </tr> | 99 | </tr> |
| @@ -139,6 +141,9 @@ | @@ -139,6 +141,9 @@ | ||
| 139 | {{obj.timestampDate}} | 141 | {{obj.timestampDate}} |
| 140 | </td> | 142 | </td> |
| 141 | <td> | 143 | <td> |
| 144 | + {{obj.tsdate}} | ||
| 145 | + </td> | ||
| 146 | + <td> | ||
| 142 | 147 | ||
| 143 | </td> | 148 | </td> |
| 144 | </tr> | 149 | </tr> |