Commit 8f96f973c675e9c5383ee5cd61f24919f240044f
Merge branch 'pudong_jdk8' of http://101.95.0.106:8888/panzhaov5/bsth_control into pudong_jdk8
Showing
40 changed files
with
3354 additions
and
2903 deletions
pom.xml
| ... | ... | @@ -34,8 +34,6 @@ |
| 34 | 34 | <groupId>org.springframework.boot</groupId> |
| 35 | 35 | <artifactId>spring-boot-starter-security</artifactId> |
| 36 | 36 | </dependency> |
| 37 | - <!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> | |
| 38 | - </dependency> --> | |
| 39 | 37 | <dependency> |
| 40 | 38 | <groupId>org.springframework.boot</groupId> |
| 41 | 39 | <artifactId>spring-boot-starter-data-jpa</artifactId> |
| ... | ... | @@ -59,6 +57,10 @@ |
| 59 | 57 | <optional>true</optional> |
| 60 | 58 | </dependency> |
| 61 | 59 | <dependency> |
| 60 | + <groupId>org.springframework.kafka</groupId> | |
| 61 | + <artifactId>spring-kafka</artifactId> | |
| 62 | + </dependency> | |
| 63 | + <dependency> | |
| 62 | 64 | <groupId>mysql</groupId> |
| 63 | 65 | <artifactId>mysql-connector-java</artifactId> |
| 64 | 66 | <version>5.1.38</version> | ... | ... |
src/main/java/com/bsth/controller/sys/UserController.java
| ... | ... | @@ -94,6 +94,7 @@ public class UserController extends BaseController<SysUser, Integer> { |
| 94 | 94 | StringBuilder sb = HttpClientUtils.post(ssoConfig.getSsoAuthUrl(), mapper.writeValueAsString(param)); |
| 95 | 95 | |
| 96 | 96 | Assert.notNull(sb, "统一登录平台验证数据不为空"); |
| 97 | + logger.info(String.format("统一登录平台:%s", sb.toString())); | |
| 97 | 98 | param = mapper.readValue(mapper.writeValueAsString(mapper.readValue(sb.toString(), Map.class).get("data")), Map.class); |
| 98 | 99 | String jobCode = (String) param.get("account"), realName = (String) param.get("userName"); |
| 99 | 100 | if (!account.equals(jobCode)) { | ... | ... |
src/main/java/com/bsth/data/LineVersionsData.java
| 1 | -package com.bsth.data; | |
| 2 | - | |
| 3 | -import com.bsth.entity.LineVersions; | |
| 4 | -import com.bsth.service.LineVersionsService; | |
| 5 | -import com.bsth.service.StationRouteService; | |
| 6 | -import org.slf4j.Logger; | |
| 7 | -import org.slf4j.LoggerFactory; | |
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | -import org.springframework.core.annotation.Order; | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | - | |
| 12 | -import java.util.HashMap; | |
| 13 | -import java.util.List; | |
| 14 | -import java.util.Map; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * @ClassName: LineVersionsData | |
| 18 | - * @Description: TODO(线路版本数据管理) | |
| 19 | - */ | |
| 20 | -@Component | |
| 21 | -@Order(20) | |
| 22 | -public class LineVersionsData extends Thread { | |
| 23 | - | |
| 24 | - static Logger logger = LoggerFactory.getLogger(LineVersionsData.class); | |
| 25 | - | |
| 26 | - @Autowired | |
| 27 | - LineVersionsService lineVersionsService; | |
| 28 | - | |
| 29 | - @Autowired | |
| 30 | - StationRouteService stationRouteService; | |
| 31 | - | |
| 32 | - @Override | |
| 33 | - public void run() { | |
| 34 | - try { | |
| 35 | - List<LineVersions> list = lineVersionsService.lineUpdate(); | |
| 36 | - if(list.size() == 0){ | |
| 37 | - logger.info("没有需要更新的线路!"); | |
| 38 | - return; | |
| 39 | - } | |
| 40 | - for (LineVersions lineVersions : list) { | |
| 41 | - Integer lineId = lineVersions.getLine().getId(); | |
| 42 | - // 更新线路文件 | |
| 43 | - Map<String, Object> map = new HashMap<>(); | |
| 44 | - map.put("lineId", lineId); | |
| 45 | - stationRouteService.usingSingle(map); | |
| 46 | - logger.info("线路版本更新成功!"); | |
| 47 | - } | |
| 48 | - } catch (Exception e) { | |
| 49 | - e.printStackTrace(); | |
| 50 | - logger.error("线路版本更新出现异常!", e); | |
| 51 | - } | |
| 52 | - } | |
| 53 | -} | |
| 1 | +package com.bsth.data; | |
| 2 | + | |
| 3 | +import com.bsth.entity.LineVersions; | |
| 4 | +import com.bsth.service.LineVersionsService; | |
| 5 | +import com.bsth.service.StationRouteService; | |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.core.annotation.Order; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +import java.util.HashMap; | |
| 13 | +import java.util.List; | |
| 14 | +import java.util.Map; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * @ClassName: LineVersionsData | |
| 18 | + * @Description: TODO(线路版本数据管理) | |
| 19 | + */ | |
| 20 | +@Component | |
| 21 | +@Order(20) | |
| 22 | +public class LineVersionsData extends Thread { | |
| 23 | + | |
| 24 | + static Logger logger = LoggerFactory.getLogger(LineVersionsData.class); | |
| 25 | + | |
| 26 | + @Autowired | |
| 27 | + LineVersionsService lineVersionsService; | |
| 28 | + | |
| 29 | + @Autowired | |
| 30 | + StationRouteService stationRouteService; | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public void run() { | |
| 34 | + logger.warn("线路版本更新开始"); | |
| 35 | + try { | |
| 36 | + List<LineVersions> list = lineVersionsService.lineUpdate(); | |
| 37 | + if(list.size() == 0){ | |
| 38 | + logger.info("没有需要更新的线路!"); | |
| 39 | + return; | |
| 40 | + } | |
| 41 | + for (LineVersions lineVersions : list) { | |
| 42 | + Integer lineId = lineVersions.getLine().getId(); | |
| 43 | + // 更新线路文件 | |
| 44 | + Map<String, Object> map = new HashMap<>(); | |
| 45 | + map.put("lineId", lineId); | |
| 46 | + stationRouteService.usingSingle(map); | |
| 47 | + logger.info("线路版本更新成功!"); | |
| 48 | + } | |
| 49 | + } catch (Exception e) { | |
| 50 | + e.printStackTrace(); | |
| 51 | + logger.error("线路版本更新出现异常!", e); | |
| 52 | + } | |
| 53 | + logger.warn("线路版本更新结束"); | |
| 54 | + } | |
| 55 | +} | ... | ... |
src/main/java/com/bsth/data/car_out_info/CarOutInfoHandler.java
| ... | ... | @@ -15,12 +15,8 @@ import org.slf4j.LoggerFactory; |
| 15 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 16 | 16 | import org.springframework.jdbc.core.BatchPreparedStatementSetter; |
| 17 | 17 | import org.springframework.jdbc.core.JdbcTemplate; |
| 18 | -import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 19 | 18 | import org.springframework.stereotype.Component; |
| 20 | -import org.springframework.transaction.TransactionDefinition; | |
| 21 | 19 | import org.springframework.transaction.TransactionStatus; |
| 22 | -import org.springframework.transaction.support.DefaultTransactionDefinition; | |
| 23 | -import org.springframework.transaction.support.TransactionCallback; | |
| 24 | 20 | import org.springframework.transaction.support.TransactionCallbackWithoutResult; |
| 25 | 21 | import org.springframework.transaction.support.TransactionTemplate; |
| 26 | 22 | |
| ... | ... | @@ -70,6 +66,7 @@ public class CarOutInfoHandler { |
| 70 | 66 | * 全量更新发车信息表 |
| 71 | 67 | */ |
| 72 | 68 | public void updateAll() { |
| 69 | + logger.warn("发车信息更新开始"); | |
| 73 | 70 | try{ |
| 74 | 71 | //将班次按线路分组 |
| 75 | 72 | List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()); |
| ... | ... | @@ -88,6 +85,7 @@ public class CarOutInfoHandler { |
| 88 | 85 | }catch (Exception e){ |
| 89 | 86 | logger.error("", e); |
| 90 | 87 | } |
| 88 | + logger.warn("发车信息更新结束"); | |
| 91 | 89 | } |
| 92 | 90 | |
| 93 | 91 | public List<ScheduleRealInfo> update(List<ScheduleRealInfo> list) { | ... | ... |
src/main/java/com/bsth/data/directive/DirectivesPstThread.java
| ... | ... | @@ -14,11 +14,10 @@ import org.slf4j.LoggerFactory; |
| 14 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 15 | import org.springframework.jdbc.core.BatchPreparedStatementSetter; |
| 16 | 16 | import org.springframework.jdbc.core.JdbcTemplate; |
| 17 | -import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 18 | 17 | import org.springframework.stereotype.Component; |
| 19 | -import org.springframework.transaction.TransactionDefinition; | |
| 20 | 18 | import org.springframework.transaction.TransactionStatus; |
| 21 | -import org.springframework.transaction.support.DefaultTransactionDefinition; | |
| 19 | +import org.springframework.transaction.support.TransactionCallbackWithoutResult; | |
| 20 | +import org.springframework.transaction.support.TransactionTemplate; | |
| 22 | 21 | |
| 23 | 22 | import java.sql.PreparedStatement; |
| 24 | 23 | import java.sql.SQLException; |
| ... | ... | @@ -48,10 +47,14 @@ public class DirectivesPstThread extends Thread { |
| 48 | 47 | @Autowired |
| 49 | 48 | JdbcTemplate jdbcTemplate; |
| 50 | 49 | |
| 50 | + @Autowired | |
| 51 | + private TransactionTemplate transactionTemplate; | |
| 52 | + | |
| 51 | 53 | private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); |
| 52 | 54 | |
| 53 | 55 | @Override |
| 54 | 56 | public void run() { |
| 57 | + logger.warn("指令持久化开始"); | |
| 55 | 58 | try{ |
| 56 | 59 | ConcurrentLinkedQueue<Directive> list = DayOfDirectives.pstDirectives; |
| 57 | 60 | |
| ... | ... | @@ -99,176 +102,172 @@ public class DirectivesPstThread extends Thread { |
| 99 | 102 | }catch (Exception e){ |
| 100 | 103 | logger.error("指令入库出现异常", e); |
| 101 | 104 | } |
| 105 | + logger.warn("指令持久化结束"); | |
| 102 | 106 | } |
| 103 | 107 | |
| 104 | 108 | private void save64(final List<D64> d64s) { |
| 105 | 109 | if(null == d64s || d64s.size() == 0) |
| 106 | 110 | return; |
| 107 | 111 | |
| 112 | + logger.warn("64指令保存开始"); | |
| 113 | + | |
| 108 | 114 | String sql = "insert into bsth_v_directive_64(device_id,error_text,http_code,oper_code,rq,sender,timestamp,city_code,line_id,txt_content,resp_ack) " + |
| 109 | 115 | " values(?,?,?,?,?,?,?,?,?,?,?)"; |
| 110 | 116 | |
| 111 | - //编程式事务 | |
| 112 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 113 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 114 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 115 | - TransactionStatus status = tran.getTransaction(def); | |
| 116 | - | |
| 117 | - try{ | |
| 118 | - jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { | |
| 119 | - @Override | |
| 120 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 121 | - D64 d64 = d64s.get(i); | |
| 122 | - ps.setString(1 , d64.getDeviceId()); | |
| 123 | - ps.setString(2, isNvl(d64.getErrorText())); | |
| 124 | - ps.setInt(3, d64.getHttpCode()); | |
| 125 | - ps.setShort(4, isNvl(d64.getOperCode())); | |
| 126 | - ps.setString(5, d64.getRq()); | |
| 127 | - | |
| 128 | - ps.setString(6, isNvl(d64.getSender())); | |
| 129 | - ps.setLong(7, d64.getTimestamp()); | |
| 130 | - | |
| 131 | - ps.setShort(8, isNvl(d64.getData().getCityCode())); | |
| 132 | - ps.setString(9, isNvl(d64.getData().getLineId())); | |
| 133 | - ps.setString(10, isNvl(d64.getData().getTxtContent())); | |
| 134 | - ps.setShort(11, isNvl(d64.getRespAck())); | |
| 135 | - } | |
| 136 | - | |
| 137 | - @Override | |
| 138 | - public int getBatchSize() { | |
| 139 | - return d64s.size(); | |
| 117 | + transactionTemplate.execute(new TransactionCallbackWithoutResult() { | |
| 118 | + | |
| 119 | + @Override | |
| 120 | + protected void doInTransactionWithoutResult(TransactionStatus status) { | |
| 121 | + try { | |
| 122 | + jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { | |
| 123 | + @Override | |
| 124 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 125 | + D64 d64 = d64s.get(i); | |
| 126 | + ps.setString(1 , d64.getDeviceId()); | |
| 127 | + ps.setString(2, isNvl(d64.getErrorText())); | |
| 128 | + ps.setInt(3, d64.getHttpCode()); | |
| 129 | + ps.setShort(4, isNvl(d64.getOperCode())); | |
| 130 | + ps.setString(5, d64.getRq()); | |
| 131 | + | |
| 132 | + ps.setString(6, isNvl(d64.getSender())); | |
| 133 | + ps.setLong(7, d64.getTimestamp()); | |
| 134 | + | |
| 135 | + ps.setShort(8, isNvl(d64.getData().getCityCode())); | |
| 136 | + ps.setString(9, isNvl(d64.getData().getLineId())); | |
| 137 | + ps.setString(10, isNvl(d64.getData().getTxtContent())); | |
| 138 | + ps.setShort(11, isNvl(d64.getRespAck())); | |
| 139 | + } | |
| 140 | + | |
| 141 | + @Override | |
| 142 | + public int getBatchSize() { | |
| 143 | + return d64s.size(); | |
| 144 | + } | |
| 145 | + }); | |
| 146 | + } catch (Exception e) { | |
| 147 | + logger.error(String.format("错误数据:%s", JSON.toJSONString(d64s)), e); | |
| 148 | + status.setRollbackOnly(); | |
| 140 | 149 | } |
| 141 | - }); | |
| 142 | - | |
| 143 | - tran.commit(status); | |
| 144 | - | |
| 145 | - logger.info("64 入库成功: " + d64s.size()); | |
| 146 | - }catch (Exception e){ | |
| 147 | - logger.error(String.format("错误数据:%s", JSON.toJSONString(d64s)), e); | |
| 148 | - tran.rollback(status); | |
| 149 | - } | |
| 150 | + } | |
| 151 | + }); | |
| 152 | + logger.warn("64指令保存结束"); | |
| 150 | 153 | } |
| 151 | 154 | |
| 152 | 155 | private void update60(final List<D60> d60s) { |
| 153 | 156 | if(null == d60s || d60s.size() == 0) |
| 154 | 157 | return; |
| 155 | 158 | |
| 159 | + logger.warn("60指令更新开始"); | |
| 156 | 160 | String sql = "update bsth_v_directive_60 set reply46=?,reply46time=?,reply47=?,reply47time=? where device_id=? and timestamp=? and msg_id=?"; |
| 157 | 161 | |
| 158 | - //编程式事务 | |
| 159 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 160 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 161 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 162 | - TransactionStatus status = tran.getTransaction(def); | |
| 163 | - | |
| 164 | - try{ | |
| 165 | - jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { | |
| 166 | - @Override | |
| 167 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 168 | - D60 d60 = d60s.get(i); | |
| 169 | - ps.setShort(1, isNvl(d60.getReply46())); | |
| 170 | - if(null == d60.getReply46Time()) | |
| 171 | - ps.setNull(2, Types.BIGINT); | |
| 172 | - else | |
| 173 | - ps.setLong(2, d60.getReply46Time()); | |
| 174 | - | |
| 175 | - ps.setShort(3, isNvl(d60.getReply47())); | |
| 176 | - | |
| 177 | - if(null == d60.getReply47Time()) | |
| 178 | - ps.setNull(4, Types.BIGINT); | |
| 179 | - else | |
| 180 | - ps.setLong(4, d60.getReply47Time()); | |
| 181 | - ps.setString(5, d60.getDeviceId()); | |
| 182 | - ps.setLong(6, d60.getTimestamp()); | |
| 183 | - ps.setInt(7, d60.getMsgId()); | |
| 184 | - } | |
| 185 | - | |
| 186 | - @Override | |
| 187 | - public int getBatchSize() { | |
| 188 | - return d60s.size(); | |
| 162 | + transactionTemplate.execute(new TransactionCallbackWithoutResult() { | |
| 163 | + | |
| 164 | + @Override | |
| 165 | + protected void doInTransactionWithoutResult(TransactionStatus status) { | |
| 166 | + try{ | |
| 167 | + jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { | |
| 168 | + @Override | |
| 169 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 170 | + D60 d60 = d60s.get(i); | |
| 171 | + ps.setShort(1, isNvl(d60.getReply46())); | |
| 172 | + if(null == d60.getReply46Time()) | |
| 173 | + ps.setNull(2, Types.BIGINT); | |
| 174 | + else | |
| 175 | + ps.setLong(2, d60.getReply46Time()); | |
| 176 | + | |
| 177 | + ps.setShort(3, isNvl(d60.getReply47())); | |
| 178 | + | |
| 179 | + if(null == d60.getReply47Time()) | |
| 180 | + ps.setNull(4, Types.BIGINT); | |
| 181 | + else | |
| 182 | + ps.setLong(4, d60.getReply47Time()); | |
| 183 | + ps.setString(5, d60.getDeviceId()); | |
| 184 | + ps.setLong(6, d60.getTimestamp()); | |
| 185 | + ps.setInt(7, d60.getMsgId()); | |
| 186 | + } | |
| 187 | + | |
| 188 | + @Override | |
| 189 | + public int getBatchSize() { | |
| 190 | + return d60s.size(); | |
| 191 | + } | |
| 192 | + }); | |
| 193 | + }catch (Exception e){ | |
| 194 | + logger.error(String.format("错误数据:%s", JSON.toJSONString(d60s)), e); | |
| 195 | + status.setRollbackOnly(); | |
| 189 | 196 | } |
| 190 | - }); | |
| 191 | - | |
| 192 | - tran.commit(status); | |
| 193 | - | |
| 194 | - logger.info("60 更新成功: " + d60s.size()); | |
| 195 | - }catch (Exception e){ | |
| 196 | - logger.error(String.format("错误数据:%s", JSON.toJSONString(d60s)), e); | |
| 197 | - tran.rollback(status); | |
| 198 | - } | |
| 197 | + } | |
| 198 | + }); | |
| 199 | + logger.warn("60指令更新结束"); | |
| 199 | 200 | } |
| 200 | 201 | |
| 201 | 202 | private void save60(final List<D60> d60s) { |
| 202 | 203 | if(null == d60s || d60s.size() == 0) |
| 203 | 204 | return; |
| 204 | 205 | |
| 206 | + logger.warn("60指令保存开始"); | |
| 205 | 207 | String sql = "insert into bsth_v_directive_60(device_id,error_text,http_code,oper_code,rq,sender,timestamp" + |
| 206 | 208 | ",alarm_time,company_code,dispatch_instruct,instruct_type,msg_id,service_state,txt_content,is_dispatch" + |
| 207 | 209 | ",line_code,reply46,reply46time,reply47,reply47time,sch) " + |
| 208 | 210 | " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
| 209 | 211 | |
| 210 | - //编程式事务 | |
| 211 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 212 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 213 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 214 | - TransactionStatus status = tran.getTransaction(def); | |
| 215 | - | |
| 216 | - try{ | |
| 217 | - jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { | |
| 218 | - @Override | |
| 219 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 220 | - D60 d60 = d60s.get(i); | |
| 221 | - ps.setString(1, d60.getDeviceId()); | |
| 222 | - ps.setString(2, isNvl(d60.getErrorText())); | |
| 223 | - ps.setInt(3, d60.getHttpCode()); | |
| 224 | - ps.setShort(4, d60.getOperCode()); | |
| 225 | - ps.setString(5, d60.getRq()); | |
| 226 | - ps.setString(6, d60.getSender()); | |
| 227 | - ps.setLong(7, d60.getTimestamp()); | |
| 228 | - | |
| 229 | - ps.setLong(8, isNvl(d60.getData().getAlarmTime())); | |
| 230 | - ps.setShort(9, isNvl(d60.getData().getCompanyCode())); | |
| 231 | - ps.setShort(10, isNvl(d60.getData().getDispatchInstruct())); | |
| 232 | - ps.setInt(11, d60.getData().getInstructType()); | |
| 233 | - ps.setInt(12, d60.getData().getMsgId()); | |
| 234 | - ps.setLong(13, d60.getData().getServiceState()); | |
| 235 | - ps.setString(14, d60.getData().getTxtContent()); | |
| 236 | - ps.setBoolean(15, d60.isDispatch()); | |
| 237 | - | |
| 238 | - ps.setString(16, isNvl(d60.getLineCode())); | |
| 239 | - ps.setShort(17, isNvl(d60.getReply46())); | |
| 240 | - | |
| 241 | - if(null == d60.getReply46Time()) | |
| 242 | - ps.setNull(18, Types.BIGINT); | |
| 243 | - else | |
| 244 | - ps.setLong(18, d60.getReply46Time()); | |
| 245 | - | |
| 246 | - ps.setShort(19, isNvl(d60.getReply47())); | |
| 247 | - | |
| 248 | - if(null == d60.getReply47Time()) | |
| 249 | - ps.setNull(20, Types.BIGINT); | |
| 250 | - else | |
| 251 | - ps.setLong(20, d60.getReply47Time()); | |
| 252 | - | |
| 253 | - if(d60.getSch()==null) | |
| 254 | - ps.setNull(21, Types.BIGINT); | |
| 255 | - else | |
| 256 | - ps.setLong(21, d60.getSch().getId()); | |
| 212 | + transactionTemplate.execute(new TransactionCallbackWithoutResult() { | |
| 213 | + | |
| 214 | + @Override | |
| 215 | + protected void doInTransactionWithoutResult(TransactionStatus status) { | |
| 216 | + try{ | |
| 217 | + jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { | |
| 218 | + @Override | |
| 219 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 220 | + D60 d60 = d60s.get(i); | |
| 221 | + ps.setString(1, d60.getDeviceId()); | |
| 222 | + ps.setString(2, isNvl(d60.getErrorText())); | |
| 223 | + ps.setInt(3, d60.getHttpCode()); | |
| 224 | + ps.setShort(4, d60.getOperCode()); | |
| 225 | + ps.setString(5, d60.getRq()); | |
| 226 | + ps.setString(6, d60.getSender()); | |
| 227 | + ps.setLong(7, d60.getTimestamp()); | |
| 228 | + | |
| 229 | + ps.setLong(8, isNvl(d60.getData().getAlarmTime())); | |
| 230 | + ps.setShort(9, isNvl(d60.getData().getCompanyCode())); | |
| 231 | + ps.setShort(10, isNvl(d60.getData().getDispatchInstruct())); | |
| 232 | + ps.setInt(11, d60.getData().getInstructType()); | |
| 233 | + ps.setInt(12, d60.getData().getMsgId()); | |
| 234 | + ps.setLong(13, d60.getData().getServiceState()); | |
| 235 | + ps.setString(14, d60.getData().getTxtContent()); | |
| 236 | + ps.setBoolean(15, d60.isDispatch()); | |
| 237 | + | |
| 238 | + ps.setString(16, isNvl(d60.getLineCode())); | |
| 239 | + ps.setShort(17, isNvl(d60.getReply46())); | |
| 240 | + | |
| 241 | + if(null == d60.getReply46Time()) | |
| 242 | + ps.setNull(18, Types.BIGINT); | |
| 243 | + else | |
| 244 | + ps.setLong(18, d60.getReply46Time()); | |
| 245 | + | |
| 246 | + ps.setShort(19, isNvl(d60.getReply47())); | |
| 247 | + | |
| 248 | + if(null == d60.getReply47Time()) | |
| 249 | + ps.setNull(20, Types.BIGINT); | |
| 250 | + else | |
| 251 | + ps.setLong(20, d60.getReply47Time()); | |
| 252 | + | |
| 253 | + if(d60.getSch()==null) | |
| 254 | + ps.setNull(21, Types.BIGINT); | |
| 255 | + else | |
| 256 | + ps.setLong(21, d60.getSch().getId()); | |
| 257 | + } | |
| 258 | + | |
| 259 | + @Override | |
| 260 | + public int getBatchSize() { | |
| 261 | + return d60s.size(); | |
| 262 | + } | |
| 263 | + }); | |
| 264 | + }catch (Exception e){ | |
| 265 | + logger.error(String.format("错误数据:%s", JSON.toJSONString(d60s)), e); | |
| 266 | + status.setRollbackOnly(); | |
| 257 | 267 | } |
| 258 | - | |
| 259 | - @Override | |
| 260 | - public int getBatchSize() { | |
| 261 | - return d60s.size(); | |
| 262 | - } | |
| 263 | - }); | |
| 264 | - | |
| 265 | - tran.commit(status); | |
| 266 | - | |
| 267 | - logger.info("60 入库成功: " + d60s.size()); | |
| 268 | - }catch (Exception e){ | |
| 269 | - logger.error(String.format("错误数据:%s", JSON.toJSONString(d60s)), e); | |
| 270 | - tran.rollback(status); | |
| 271 | - } | |
| 268 | + } | |
| 269 | + }); | |
| 270 | + logger.warn("60指令保存结束"); | |
| 272 | 271 | } |
| 273 | 272 | |
| 274 | 273 | private String isNvl(String v) { | ... | ... |
src/main/java/com/bsth/data/forecast/SampleTimeDataLoader.java
| 1 | -package com.bsth.data.forecast; | |
| 2 | - | |
| 3 | -import java.util.ArrayList; | |
| 4 | -import java.util.Collections; | |
| 5 | -import java.util.Comparator; | |
| 6 | -import java.util.Date; | |
| 7 | -import java.util.Iterator; | |
| 8 | -import java.util.List; | |
| 9 | -import java.util.Set; | |
| 10 | - | |
| 11 | -import org.joda.time.format.DateTimeFormat; | |
| 12 | -import org.joda.time.format.DateTimeFormatter; | |
| 13 | -import org.slf4j.Logger; | |
| 14 | -import org.slf4j.LoggerFactory; | |
| 15 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | -import org.springframework.stereotype.Component; | |
| 17 | - | |
| 18 | -import com.bsth.data.forecast.entity.SimpleRoute; | |
| 19 | -import com.bsth.data.forecast.entity.SimpleRoute.TimeRange; | |
| 20 | -import com.bsth.entity.StationRoute; | |
| 21 | -import com.bsth.entity.forecast.Sample; | |
| 22 | -import com.bsth.repository.StationRouteRepository; | |
| 23 | -import com.bsth.repository.forecast.SampleRepository; | |
| 24 | -import com.google.common.collect.ArrayListMultimap; | |
| 25 | - | |
| 26 | -/** | |
| 27 | - * | |
| 28 | - * @Title: loadData | |
| 29 | - * @Description: TODO(从数据库加载数据) | |
| 30 | - */ | |
| 31 | -@Component | |
| 32 | -public class SampleTimeDataLoader extends Thread { | |
| 33 | - | |
| 34 | - @Autowired | |
| 35 | - SampleRepository sampleRepository; | |
| 36 | - | |
| 37 | - @Autowired | |
| 38 | - StationRouteRepository stationRouteRepository; | |
| 39 | - | |
| 40 | - // 当天日期 | |
| 41 | - String rq; | |
| 42 | - | |
| 43 | - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm") | |
| 44 | - ,fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | |
| 45 | - | |
| 46 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 47 | - | |
| 48 | - @Override | |
| 49 | - public void run() { | |
| 50 | - rq = fmtyyyyMMdd.print(new Date().getTime()); | |
| 51 | - | |
| 52 | - Iterator<Sample> iterator = sampleRepository.findAll().iterator(); | |
| 53 | - ArrayListMultimap<String, Sample> sampleMap = ArrayListMultimap.create(); | |
| 54 | - | |
| 55 | - Sample sample; | |
| 56 | - String key; | |
| 57 | - while (iterator.hasNext()) { | |
| 58 | - sample = iterator.next(); | |
| 59 | - key = sample.getLineCode() + "_" + sample.getUpdown() + "_" + sample.getsStation() + "_" | |
| 60 | - + sample.geteStation(); | |
| 61 | - sampleMap.put(key, sample); | |
| 62 | - } | |
| 63 | - | |
| 64 | - // 加载全部路由信息 | |
| 65 | - List<StationRoute> allRoutes = stationRouteRepository.findAllEffective(); | |
| 66 | - // 线路和走向分组 | |
| 67 | - ArrayListMultimap<String, StationRoute> groupMap = ArrayListMultimap.create(); | |
| 68 | - for (StationRoute sr : allRoutes) | |
| 69 | - groupMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr); | |
| 70 | - | |
| 71 | - ArrayListMultimap<String, SimpleRoute> lineSampleMapCopy = ArrayListMultimap.create(); | |
| 72 | - // 排序路由链并附加各个时区耗时信息 | |
| 73 | - StationRouteComp comp = new StationRouteComp(); | |
| 74 | - Set<String> kys = groupMap.keySet(); | |
| 75 | - List<StationRoute> routeList; | |
| 76 | - StationRoute sRoute; | |
| 77 | - | |
| 78 | - List<Sample> sapList; | |
| 79 | - for (String k : kys) { | |
| 80 | - routeList = groupMap.get(k); | |
| 81 | - // 排序 | |
| 82 | - Collections.sort(routeList, comp); | |
| 83 | - | |
| 84 | - for (int i = 1; i < routeList.size(); i++) { | |
| 85 | - sRoute = routeList.get(i); | |
| 86 | - | |
| 87 | - sapList = sampleMap.get(k + "_" +routeList.get(i - 1).getStationCode() + "_" + sRoute.getStationCode()); | |
| 88 | - | |
| 89 | - lineSampleMapCopy.put(k, createSimpleRoute(sRoute, sapList)); | |
| 90 | - } | |
| 91 | - } | |
| 92 | - | |
| 93 | - ForecastRealServer.lineSampleMap = lineSampleMapCopy; | |
| 94 | - logger.info("SampleTimeDataLoader.... over..."); | |
| 95 | - } | |
| 96 | - | |
| 97 | - private SimpleRoute createSimpleRoute(StationRoute sRoute, List<Sample> list) { | |
| 98 | - SimpleRoute simple = new SimpleRoute(); | |
| 99 | - | |
| 100 | - simple.stationCode = sRoute.getStationCode(); | |
| 101 | - simple.ranges = new ArrayList<>(); | |
| 102 | - | |
| 103 | - try{ | |
| 104 | - TimeRange tg; | |
| 105 | - for (Sample s : list) { | |
| 106 | - tg = new TimeRange(); | |
| 107 | - | |
| 108 | - tg.startTime = fmtyyyyMMddHHmm.parseMillis(rq + s.getsDate()); | |
| 109 | - tg.endTime = fmtyyyyMMddHHmm.parseMillis(rq + s.geteDate()); | |
| 110 | - tg.runTime = s.getRunTime(); | |
| 111 | - simple.ranges.add(tg); | |
| 112 | - } | |
| 113 | - | |
| 114 | - //排序 | |
| 115 | - Collections.sort(simple.ranges); | |
| 116 | - }catch(Exception e){ | |
| 117 | - logger.error("", e); | |
| 118 | - } | |
| 119 | - return simple; | |
| 120 | - } | |
| 121 | - | |
| 122 | - public static class StationRouteComp implements Comparator<StationRoute> { | |
| 123 | - | |
| 124 | - @Override | |
| 125 | - public int compare(StationRoute o1, StationRoute o2) { | |
| 126 | - return o1.getStationRouteCode() - o2.getStationRouteCode(); | |
| 127 | - } | |
| 128 | - } | |
| 129 | -} | |
| 1 | +package com.bsth.data.forecast; | |
| 2 | + | |
| 3 | +import java.util.ArrayList; | |
| 4 | +import java.util.Collections; | |
| 5 | +import java.util.Comparator; | |
| 6 | +import java.util.Date; | |
| 7 | +import java.util.Iterator; | |
| 8 | +import java.util.List; | |
| 9 | +import java.util.Set; | |
| 10 | + | |
| 11 | +import org.joda.time.format.DateTimeFormat; | |
| 12 | +import org.joda.time.format.DateTimeFormatter; | |
| 13 | +import org.slf4j.Logger; | |
| 14 | +import org.slf4j.LoggerFactory; | |
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | +import org.springframework.stereotype.Component; | |
| 17 | + | |
| 18 | +import com.bsth.data.forecast.entity.SimpleRoute; | |
| 19 | +import com.bsth.data.forecast.entity.SimpleRoute.TimeRange; | |
| 20 | +import com.bsth.entity.StationRoute; | |
| 21 | +import com.bsth.entity.forecast.Sample; | |
| 22 | +import com.bsth.repository.StationRouteRepository; | |
| 23 | +import com.bsth.repository.forecast.SampleRepository; | |
| 24 | +import com.google.common.collect.ArrayListMultimap; | |
| 25 | + | |
| 26 | +/** | |
| 27 | + * | |
| 28 | + * @Title: loadData | |
| 29 | + * @Description: TODO(从数据库加载数据) | |
| 30 | + */ | |
| 31 | +@Component | |
| 32 | +public class SampleTimeDataLoader extends Thread { | |
| 33 | + | |
| 34 | + @Autowired | |
| 35 | + SampleRepository sampleRepository; | |
| 36 | + | |
| 37 | + @Autowired | |
| 38 | + StationRouteRepository stationRouteRepository; | |
| 39 | + | |
| 40 | + // 当天日期 | |
| 41 | + String rq; | |
| 42 | + | |
| 43 | + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm") | |
| 44 | + ,fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | |
| 45 | + | |
| 46 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public void run() { | |
| 50 | + logger.warn("到离站预测样本加载开始"); | |
| 51 | + rq = fmtyyyyMMdd.print(System.currentTimeMillis()); | |
| 52 | + | |
| 53 | + Iterator<Sample> iterator = sampleRepository.findAll().iterator(); | |
| 54 | + ArrayListMultimap<String, Sample> sampleMap = ArrayListMultimap.create(); | |
| 55 | + | |
| 56 | + Sample sample; | |
| 57 | + String key; | |
| 58 | + while (iterator.hasNext()) { | |
| 59 | + sample = iterator.next(); | |
| 60 | + key = sample.getLineCode() + "_" + sample.getUpdown() + "_" + sample.getsStation() + "_" | |
| 61 | + + sample.geteStation(); | |
| 62 | + sampleMap.put(key, sample); | |
| 63 | + } | |
| 64 | + | |
| 65 | + // 加载全部路由信息 | |
| 66 | + List<StationRoute> allRoutes = stationRouteRepository.findAllEffective(); | |
| 67 | + // 线路和走向分组 | |
| 68 | + ArrayListMultimap<String, StationRoute> groupMap = ArrayListMultimap.create(); | |
| 69 | + for (StationRoute sr : allRoutes) | |
| 70 | + groupMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr); | |
| 71 | + | |
| 72 | + ArrayListMultimap<String, SimpleRoute> lineSampleMapCopy = ArrayListMultimap.create(); | |
| 73 | + // 排序路由链并附加各个时区耗时信息 | |
| 74 | + StationRouteComp comp = new StationRouteComp(); | |
| 75 | + Set<String> kys = groupMap.keySet(); | |
| 76 | + List<StationRoute> routeList; | |
| 77 | + StationRoute sRoute; | |
| 78 | + | |
| 79 | + List<Sample> sapList; | |
| 80 | + for (String k : kys) { | |
| 81 | + routeList = groupMap.get(k); | |
| 82 | + // 排序 | |
| 83 | + Collections.sort(routeList, comp); | |
| 84 | + | |
| 85 | + for (int i = 1; i < routeList.size(); i++) { | |
| 86 | + sRoute = routeList.get(i); | |
| 87 | + | |
| 88 | + sapList = sampleMap.get(k + "_" +routeList.get(i - 1).getStationCode() + "_" + sRoute.getStationCode()); | |
| 89 | + | |
| 90 | + lineSampleMapCopy.put(k, createSimpleRoute(sRoute, sapList)); | |
| 91 | + } | |
| 92 | + } | |
| 93 | + | |
| 94 | + ForecastRealServer.lineSampleMap = lineSampleMapCopy; | |
| 95 | + logger.warn("到离站预测样本加载结束"); | |
| 96 | + } | |
| 97 | + | |
| 98 | + private SimpleRoute createSimpleRoute(StationRoute sRoute, List<Sample> list) { | |
| 99 | + SimpleRoute simple = new SimpleRoute(); | |
| 100 | + | |
| 101 | + simple.stationCode = sRoute.getStationCode(); | |
| 102 | + simple.ranges = new ArrayList<>(); | |
| 103 | + | |
| 104 | + try{ | |
| 105 | + TimeRange tg; | |
| 106 | + for (Sample s : list) { | |
| 107 | + tg = new TimeRange(); | |
| 108 | + | |
| 109 | + tg.startTime = fmtyyyyMMddHHmm.parseMillis(rq + s.getsDate()); | |
| 110 | + tg.endTime = fmtyyyyMMddHHmm.parseMillis(rq + s.geteDate()); | |
| 111 | + tg.runTime = s.getRunTime(); | |
| 112 | + simple.ranges.add(tg); | |
| 113 | + } | |
| 114 | + | |
| 115 | + //排序 | |
| 116 | + Collections.sort(simple.ranges); | |
| 117 | + }catch(Exception e){ | |
| 118 | + logger.error("", e); | |
| 119 | + } | |
| 120 | + return simple; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public static class StationRouteComp implements Comparator<StationRoute> { | |
| 124 | + | |
| 125 | + @Override | |
| 126 | + public int compare(StationRoute o1, StationRoute o2) { | |
| 127 | + return o1.getStationRouteCode() - o2.getStationRouteCode(); | |
| 128 | + } | |
| 129 | + } | |
| 130 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/GpsRealData.java
| 1 | -package com.bsth.data.gpsdata_v2; | |
| 2 | - | |
| 3 | -import com.bsth.data.BasicData; | |
| 4 | -import com.bsth.data.forecast.ForecastRealServer; | |
| 5 | -import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 6 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 7 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | -import com.bsth.service.realcontrol.impl.ScheduleRealInfoServiceImpl; | |
| 9 | -import com.google.common.collect.TreeMultimap; | |
| 10 | -import org.apache.commons.lang3.StringUtils; | |
| 11 | -import org.slf4j.Logger; | |
| 12 | -import org.slf4j.LoggerFactory; | |
| 13 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | -import org.springframework.stereotype.Component; | |
| 15 | - | |
| 16 | -import java.util.*; | |
| 17 | -import java.util.concurrent.ConcurrentHashMap; | |
| 18 | -import java.util.concurrent.ConcurrentMap; | |
| 19 | - | |
| 20 | -/** | |
| 21 | - * @author PanZhao | |
| 22 | - * @ClassName: GpsRealData | |
| 23 | - * @Description: TODO(实时GPS数据集合) | |
| 24 | - * @date 2016年8月12日 下午2:04:41 | |
| 25 | - */ | |
| 26 | -@Component | |
| 27 | -public class GpsRealData { | |
| 28 | - | |
| 29 | - static Logger logger = LoggerFactory.getLogger(GpsRealData.class); | |
| 30 | - | |
| 31 | - private static ConcurrentMap<String, GpsEntity> gpsMap; | |
| 32 | - | |
| 33 | - //按线路分组设备号 | |
| 34 | - private static TreeMultimap<String, String> lineCode2Devices; | |
| 35 | - | |
| 36 | - @Autowired | |
| 37 | - DayOfSchedule dayOfSchedule; | |
| 38 | - | |
| 39 | - @Autowired | |
| 40 | - ForecastRealServer forecastRealServer; | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * 构造函数 | |
| 44 | - */ | |
| 45 | - public GpsRealData() { | |
| 46 | - gpsMap = new ConcurrentHashMap<>(); | |
| 47 | - lineCode2Devices = TreeMultimap.create(); | |
| 48 | - } | |
| 49 | - | |
| 50 | - | |
| 51 | - public void put(GpsEntity gps) { | |
| 52 | - String device = gps.getDeviceId(); | |
| 53 | - GpsEntity old = gpsMap.get(device); | |
| 54 | - | |
| 55 | - try { | |
| 56 | - if (!StringUtils.isEmpty(gps.getStopNo())) { | |
| 57 | - //站点编码改变 | |
| 58 | - if (null == old || !gps.getStopNo().equals(old.getStopNo())) { | |
| 59 | - gps.setArrTime(gps.getTimestamp()); | |
| 60 | - //预测到达终点时间 | |
| 61 | - forecastRealServer.forecast(gps.getNbbm(), gps); | |
| 62 | - } else { | |
| 63 | - gps.setArrTime(old.getArrTime()); | |
| 64 | - //不预测, 重新计算终点时间 | |
| 65 | - gps.setExpectStopTime(forecastRealServer.expectStopTime(gps.getNbbm())); | |
| 66 | - } | |
| 67 | - } | |
| 68 | - | |
| 69 | - //刷新对照 | |
| 70 | - gpsMap.put(device, gps); | |
| 71 | - if (StringUtils.isNotBlank(gps.getLineId())) { | |
| 72 | - //站点名称 | |
| 73 | - gps.setStationName(getStationName(gps)); | |
| 74 | - lineCode2Devices.put(gps.getLineId(), device); | |
| 75 | - | |
| 76 | - if(old != null && !gps.getLineId().equals(old.getLineId())) | |
| 77 | - lineCode2Devices.remove(old.getLineId(), device); | |
| 78 | - } | |
| 79 | - | |
| 80 | - //车辆换设备了 | |
| 81 | - String nbbm = gps.getNbbm(); | |
| 82 | - if(old != null && StringUtils.isNotEmpty(nbbm) && !nbbm.equals(old.getNbbm())){ | |
| 83 | - List<GpsEntity> list = findByNbbm(nbbm); | |
| 84 | - for(GpsEntity g : list){ | |
| 85 | - if(!g.getDeviceId().equals(device)) | |
| 86 | - gpsMap.remove(g.getDeviceId()); | |
| 87 | - } | |
| 88 | - } | |
| 89 | - } catch (Exception e) { | |
| 90 | - logger.error("", e); | |
| 91 | - } | |
| 92 | - } | |
| 93 | - | |
| 94 | - public String getStationName(GpsEntity gps) { | |
| 95 | - return BasicData.getStationNameByCode(gps.getStopNo(), gps.getLineId() + "_" + gps.getUpDown() + "_"); | |
| 96 | - } | |
| 97 | - | |
| 98 | - /** | |
| 99 | - * @Title: get @Description: TODO(设备号获取GPS) | |
| 100 | - */ | |
| 101 | - public static GpsEntity get(String deviceId) { | |
| 102 | - return gpsMap.get(deviceId); | |
| 103 | - } | |
| 104 | - | |
| 105 | - public List<GpsEntity> findByNbbm(String nbbm){ | |
| 106 | - Collection<GpsEntity> arr = gpsMap.values(); | |
| 107 | - List<GpsEntity> rs = new ArrayList<>(); | |
| 108 | - for(GpsEntity g : arr){ | |
| 109 | - if(nbbm.equals(g.getNbbm())) | |
| 110 | - rs.add(g); | |
| 111 | - } | |
| 112 | - return rs; | |
| 113 | - } | |
| 114 | - | |
| 115 | - public GpsEntity getByNbbm(String nbbm){ | |
| 116 | - String device = BasicData.deviceId2NbbmMap.inverse().get(nbbm); | |
| 117 | - if(StringUtils.isNotBlank(device)) | |
| 118 | - return get(device); | |
| 119 | - else | |
| 120 | - return null; | |
| 121 | - } | |
| 122 | - | |
| 123 | - /** | |
| 124 | - * @Title: get @Description: TODO(线路编码获取GPS集合) @throws | |
| 125 | - */ | |
| 126 | - public List<GpsEntity> getByLine(String lineCode) { | |
| 127 | - NavigableSet<String> set = lineCode2Devices.get(lineCode);//实际车载 | |
| 128 | - if(null == set) | |
| 129 | - set = new TreeSet(); | |
| 130 | - Set<String> nbbmSet = dayOfSchedule.findCarByLineCode(lineCode);//计划用车 | |
| 131 | - | |
| 132 | - Map<String, String> nbbm2deviceMap = BasicData.deviceId2NbbmMap.inverse(); | |
| 133 | - String deviceId; | |
| 134 | - for(String nbbm : nbbmSet){ | |
| 135 | - deviceId = nbbm2deviceMap.get(nbbm); | |
| 136 | - if(StringUtils.isNotEmpty(deviceId)) | |
| 137 | - set.add(deviceId); | |
| 138 | - } | |
| 139 | - | |
| 140 | - List<GpsEntity> rs = new ArrayList<>(); | |
| 141 | - GpsEntity gps; | |
| 142 | - ScheduleRealInfo sch; | |
| 143 | - for (String device : set) { | |
| 144 | - gps = gpsMap.get(device); | |
| 145 | - //过滤异常GPS数据 | |
| 146 | - if (gps == null || StringUtils.isBlank(gps.getNbbm())) | |
| 147 | - continue; | |
| 148 | - | |
| 149 | - sch = dayOfSchedule.execPlanMap().get(gps.getNbbm()); | |
| 150 | - if (null != sch){ | |
| 151 | - gps.setSchId(sch.getId()); | |
| 152 | - if(!sch.getXlBm().equals(lineCode)){ | |
| 153 | - //车辆在其他线路营运 | |
| 154 | - gps.setRemark("执行 " + sch.getXlName() + " " + sch.getDfsj() + " 班次"); | |
| 155 | - gps.setPlanCode(sch.getXlBm()); | |
| 156 | - } | |
| 157 | - }else | |
| 158 | - gps.setRemark(null); | |
| 159 | - | |
| 160 | - gps.setDvrcode(ScheduleRealInfoServiceImpl.DIRMAP.get(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())));; | |
| 161 | - rs.add(gps); | |
| 162 | - } | |
| 163 | - | |
| 164 | - return rs; | |
| 165 | - } | |
| 166 | - | |
| 167 | - public static Set<String> findDevices(String lineCode){ | |
| 168 | - return lineCode2Devices.get(lineCode); | |
| 169 | - } | |
| 170 | - | |
| 171 | - public List<GpsEntity> get(List<String> pArray) { | |
| 172 | - List<GpsEntity> list = new ArrayList<>(); | |
| 173 | - | |
| 174 | - for (String code : pArray) | |
| 175 | - list.addAll(getByLine(code)); | |
| 176 | - return list; | |
| 177 | - } | |
| 178 | - | |
| 179 | - public Set<String> allDevices() { | |
| 180 | - return gpsMap.keySet(); | |
| 181 | - } | |
| 182 | - | |
| 183 | - public Collection<GpsEntity> all() { | |
| 184 | - return gpsMap.values(); | |
| 185 | - } | |
| 186 | - | |
| 187 | - public void remove(String device) { | |
| 188 | - gpsMap.remove(device); | |
| 189 | - } | |
| 1 | +package com.bsth.data.gpsdata_v2; | |
| 2 | + | |
| 3 | +import com.bsth.data.BasicData; | |
| 4 | +import com.bsth.data.forecast.ForecastRealServer; | |
| 5 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 6 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 7 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | +import com.bsth.message.buffer.CarEnergyBuffer; | |
| 9 | +import com.bsth.service.realcontrol.impl.ScheduleRealInfoServiceImpl; | |
| 10 | +import com.google.common.collect.TreeMultimap; | |
| 11 | +import org.apache.commons.lang3.StringUtils; | |
| 12 | +import org.slf4j.Logger; | |
| 13 | +import org.slf4j.LoggerFactory; | |
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | +import org.springframework.stereotype.Component; | |
| 16 | + | |
| 17 | +import java.util.*; | |
| 18 | +import java.util.concurrent.ConcurrentHashMap; | |
| 19 | +import java.util.concurrent.ConcurrentMap; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * @author PanZhao | |
| 23 | + * @ClassName: GpsRealData | |
| 24 | + * @Description: TODO(实时GPS数据集合) | |
| 25 | + * @date 2016年8月12日 下午2:04:41 | |
| 26 | + */ | |
| 27 | +@Component | |
| 28 | +public class GpsRealData { | |
| 29 | + | |
| 30 | + static Logger logger = LoggerFactory.getLogger(GpsRealData.class); | |
| 31 | + | |
| 32 | + private static ConcurrentMap<String, GpsEntity> gpsMap; | |
| 33 | + | |
| 34 | + //按线路分组设备号 | |
| 35 | + private static TreeMultimap<String, String> lineCode2Devices; | |
| 36 | + | |
| 37 | + @Autowired | |
| 38 | + DayOfSchedule dayOfSchedule; | |
| 39 | + | |
| 40 | + @Autowired | |
| 41 | + ForecastRealServer forecastRealServer; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 构造函数 | |
| 45 | + */ | |
| 46 | + public GpsRealData() { | |
| 47 | + gpsMap = new ConcurrentHashMap<>(); | |
| 48 | + lineCode2Devices = TreeMultimap.create(); | |
| 49 | + } | |
| 50 | + | |
| 51 | + | |
| 52 | + public void put(GpsEntity gps) { | |
| 53 | + String device = gps.getDeviceId(); | |
| 54 | + GpsEntity old = gpsMap.get(device); | |
| 55 | + | |
| 56 | + try { | |
| 57 | + if (!StringUtils.isEmpty(gps.getStopNo())) { | |
| 58 | + //站点编码改变 | |
| 59 | + if (null == old || !gps.getStopNo().equals(old.getStopNo())) { | |
| 60 | + gps.setArrTime(gps.getTimestamp()); | |
| 61 | + //预测到达终点时间 | |
| 62 | + forecastRealServer.forecast(gps.getNbbm(), gps); | |
| 63 | + } else { | |
| 64 | + gps.setArrTime(old.getArrTime()); | |
| 65 | + //不预测, 重新计算终点时间 | |
| 66 | + gps.setExpectStopTime(forecastRealServer.expectStopTime(gps.getNbbm())); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + | |
| 70 | + //刷新对照 | |
| 71 | + gpsMap.put(device, gps); | |
| 72 | + if (StringUtils.isNotBlank(gps.getLineId())) { | |
| 73 | + //站点名称 | |
| 74 | + gps.setStationName(getStationName(gps)); | |
| 75 | + lineCode2Devices.put(gps.getLineId(), device); | |
| 76 | + | |
| 77 | + if(old != null && !gps.getLineId().equals(old.getLineId())) | |
| 78 | + lineCode2Devices.remove(old.getLineId(), device); | |
| 79 | + } | |
| 80 | + | |
| 81 | + //车辆换设备了 | |
| 82 | + String nbbm = gps.getNbbm(); | |
| 83 | + if(old != null && StringUtils.isNotEmpty(nbbm) && !nbbm.equals(old.getNbbm())){ | |
| 84 | + List<GpsEntity> list = findByNbbm(nbbm); | |
| 85 | + for(GpsEntity g : list){ | |
| 86 | + if(!g.getDeviceId().equals(device)) | |
| 87 | + gpsMap.remove(g.getDeviceId()); | |
| 88 | + } | |
| 89 | + } | |
| 90 | + | |
| 91 | + // 设置车辆的电量 | |
| 92 | + gps.setEnergy(CarEnergyBuffer.getCarEnergy(gps.getNbbm())); | |
| 93 | + } catch (Exception e) { | |
| 94 | + logger.error("", e); | |
| 95 | + } | |
| 96 | + } | |
| 97 | + | |
| 98 | + public String getStationName(GpsEntity gps) { | |
| 99 | + return BasicData.getStationNameByCode(gps.getStopNo(), gps.getLineId() + "_" + gps.getUpDown() + "_"); | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * @Title: get @Description: TODO(设备号获取GPS) | |
| 104 | + */ | |
| 105 | + public static GpsEntity get(String deviceId) { | |
| 106 | + return gpsMap.get(deviceId); | |
| 107 | + } | |
| 108 | + | |
| 109 | + public List<GpsEntity> findByNbbm(String nbbm){ | |
| 110 | + Collection<GpsEntity> arr = gpsMap.values(); | |
| 111 | + List<GpsEntity> rs = new ArrayList<>(); | |
| 112 | + for(GpsEntity g : arr){ | |
| 113 | + if(nbbm.equals(g.getNbbm())) | |
| 114 | + rs.add(g); | |
| 115 | + } | |
| 116 | + return rs; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public GpsEntity getByNbbm(String nbbm){ | |
| 120 | + String device = BasicData.deviceId2NbbmMap.inverse().get(nbbm); | |
| 121 | + if(StringUtils.isNotBlank(device)) | |
| 122 | + return get(device); | |
| 123 | + else | |
| 124 | + return null; | |
| 125 | + } | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * @Title: get @Description: TODO(线路编码获取GPS集合) @throws | |
| 129 | + */ | |
| 130 | + public List<GpsEntity> getByLine(String lineCode) { | |
| 131 | + NavigableSet<String> set = lineCode2Devices.get(lineCode);//实际车载 | |
| 132 | + if(null == set) | |
| 133 | + set = new TreeSet(); | |
| 134 | + Set<String> nbbmSet = dayOfSchedule.findCarByLineCode(lineCode);//计划用车 | |
| 135 | + | |
| 136 | + Map<String, String> nbbm2deviceMap = BasicData.deviceId2NbbmMap.inverse(); | |
| 137 | + String deviceId; | |
| 138 | + for(String nbbm : nbbmSet){ | |
| 139 | + deviceId = nbbm2deviceMap.get(nbbm); | |
| 140 | + if(StringUtils.isNotEmpty(deviceId)) | |
| 141 | + set.add(deviceId); | |
| 142 | + } | |
| 143 | + | |
| 144 | + List<GpsEntity> rs = new ArrayList<>(); | |
| 145 | + GpsEntity gps; | |
| 146 | + ScheduleRealInfo sch; | |
| 147 | + for (String device : set) { | |
| 148 | + gps = gpsMap.get(device); | |
| 149 | + //过滤异常GPS数据 | |
| 150 | + if (gps == null || StringUtils.isBlank(gps.getNbbm())) | |
| 151 | + continue; | |
| 152 | + | |
| 153 | + sch = dayOfSchedule.execPlanMap().get(gps.getNbbm()); | |
| 154 | + if (null != sch){ | |
| 155 | + gps.setSchId(sch.getId()); | |
| 156 | + if(!sch.getXlBm().equals(lineCode)){ | |
| 157 | + //车辆在其他线路营运 | |
| 158 | + gps.setRemark("执行 " + sch.getXlName() + " " + sch.getDfsj() + " 班次"); | |
| 159 | + gps.setPlanCode(sch.getXlBm()); | |
| 160 | + } | |
| 161 | + }else | |
| 162 | + gps.setRemark(null); | |
| 163 | + | |
| 164 | + gps.setDvrcode(ScheduleRealInfoServiceImpl.DIRMAP.get(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())));; | |
| 165 | + rs.add(gps); | |
| 166 | + } | |
| 167 | + | |
| 168 | + return rs; | |
| 169 | + } | |
| 170 | + | |
| 171 | + public static Set<String> findDevices(String lineCode){ | |
| 172 | + return lineCode2Devices.get(lineCode); | |
| 173 | + } | |
| 174 | + | |
| 175 | + public List<GpsEntity> get(List<String> pArray) { | |
| 176 | + List<GpsEntity> list = new ArrayList<>(); | |
| 177 | + | |
| 178 | + for (String code : pArray) | |
| 179 | + list.addAll(getByLine(code)); | |
| 180 | + return list; | |
| 181 | + } | |
| 182 | + | |
| 183 | + public Set<String> allDevices() { | |
| 184 | + return gpsMap.keySet(); | |
| 185 | + } | |
| 186 | + | |
| 187 | + public Collection<GpsEntity> all() { | |
| 188 | + return gpsMap.values(); | |
| 189 | + } | |
| 190 | + | |
| 191 | + public void remove(String device) { | |
| 192 | + gpsMap.remove(device); | |
| 193 | + } | |
| 190 | 194 | } |
| 191 | 195 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/entity/GpsEntity.java
| 1 | -package com.bsth.data.gpsdata_v2.entity; | |
| 2 | - | |
| 3 | -import com.fasterxml.jackson.annotation.JsonIgnore; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * | |
| 7 | - * @ClassName: GpsRealData | |
| 8 | - * @Description: TODO(HTTP接口的实时GPS数据) | |
| 9 | - * @author PanZhao | |
| 10 | - * @date 2016年5月11日 下午4:32:07 | |
| 11 | - * | |
| 12 | - */ | |
| 13 | -public class GpsEntity implements Cloneable{ | |
| 14 | - | |
| 15 | - /** 公司代码 */ | |
| 16 | - @JsonIgnore | |
| 17 | - private Short companyCode; | |
| 18 | - | |
| 19 | - /** 线路编码 */ | |
| 20 | - private String lineId; | |
| 21 | - | |
| 22 | - /** 设备编码 */ | |
| 23 | - private String deviceId; | |
| 24 | - | |
| 25 | - /** 停车场编码 */ | |
| 26 | - private String carparkNo; | |
| 27 | - | |
| 28 | - /** 站点编码 */ | |
| 29 | - private String stopNo; | |
| 30 | - | |
| 31 | - /** 站点名称 */ | |
| 32 | - private String stationName; | |
| 33 | - | |
| 34 | - /** 到站时间 */ | |
| 35 | - @JsonIgnore | |
| 36 | - private long arrTime; | |
| 37 | - | |
| 38 | - /** 经度 */ | |
| 39 | - private Float lon; | |
| 40 | - | |
| 41 | - /** 纬度 */ | |
| 42 | - private Float lat; | |
| 43 | - | |
| 44 | - /** GPS发送时间戳 */ | |
| 45 | - private Long timestamp; | |
| 46 | - | |
| 47 | - /** 网关收到时间 */ | |
| 48 | - private Long serverTimestamp; | |
| 49 | - | |
| 50 | - /** 速度 */ | |
| 51 | - private Float speed; | |
| 52 | - | |
| 53 | - /** 方向(角度) */ | |
| 54 | - private float direction; | |
| 55 | - | |
| 56 | - /** 营运状态( 0 营运 ,1 非营运, -1 无效) */ | |
| 57 | - private Integer state; | |
| 58 | - | |
| 59 | - /** 上下行(0 上行 , 1 下行 , -1 无效) */ | |
| 60 | - private Byte upDown; | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * 设备原始走向_营运状态 | |
| 64 | - * 当设备状态和系统不一致时,该字段有值 | |
| 65 | - */ | |
| 66 | - private String origStateStr; | |
| 67 | - | |
| 68 | - /** 车辆内部编码 */ | |
| 69 | - private String nbbm; | |
| 70 | - | |
| 71 | - /** 预计到达终点时间 */ | |
| 72 | - private Float expectStopTime; | |
| 73 | - | |
| 74 | - /** 当前执行班次ID */ | |
| 75 | - private Long schId; | |
| 76 | - | |
| 77 | - private int version; | |
| 78 | - | |
| 79 | - /** 0: 站外 1:站内 2:场内 */ | |
| 80 | - private int instation; | |
| 81 | - | |
| 82 | - /** 站点信息,站内时有值 */ | |
| 83 | - @JsonIgnore | |
| 84 | - private StationRoute station; | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * 前置约束 -站点编码 | |
| 88 | - */ | |
| 89 | - @JsonIgnore | |
| 90 | - private String premiseCode; | |
| 91 | - | |
| 92 | - /** 状态 */ | |
| 93 | - private String signalState = "normal"; | |
| 94 | - | |
| 95 | - /** 异常状态 */ | |
| 96 | - private String abnormalStatus; | |
| 97 | - | |
| 98 | - /** 越界距离 */ | |
| 99 | - private double outOfBoundDistance; | |
| 100 | - | |
| 101 | - /** gps是否有效 设备端发送的状态 */ | |
| 102 | - private int valid; | |
| 103 | - | |
| 104 | - /** | |
| 105 | - * 数据来源 | |
| 106 | - * 1:网关 | |
| 107 | - * 0:转发 | |
| 108 | - */ | |
| 109 | - private int source = -1; | |
| 110 | - | |
| 111 | - private String remark; | |
| 112 | - private String planCode; | |
| 113 | - | |
| 114 | - private String dvrcode; | |
| 115 | - | |
| 116 | - public Object clone() { | |
| 117 | - try { | |
| 118 | - return super.clone(); | |
| 119 | - } catch (CloneNotSupportedException e) { | |
| 120 | - return null; | |
| 121 | - } | |
| 122 | - } | |
| 123 | - | |
| 124 | - public String getDvrcode() { | |
| 125 | - return dvrcode; | |
| 126 | - } | |
| 127 | - | |
| 128 | - public void setDvrcode(String dvrcode) { | |
| 129 | - this.dvrcode = dvrcode; | |
| 130 | - } | |
| 131 | - | |
| 132 | - public String getDeviceId() { | |
| 133 | - return deviceId; | |
| 134 | - } | |
| 135 | - | |
| 136 | - public void setDeviceId(String deviceId) { | |
| 137 | - this.deviceId = deviceId; | |
| 138 | - } | |
| 139 | - | |
| 140 | - public String getCarparkNo() { | |
| 141 | - return carparkNo; | |
| 142 | - } | |
| 143 | - | |
| 144 | - public void setCarparkNo(String carparkNo) { | |
| 145 | - this.carparkNo = carparkNo; | |
| 146 | - } | |
| 147 | - | |
| 148 | - public String getStopNo() { | |
| 149 | - return stopNo; | |
| 150 | - } | |
| 151 | - | |
| 152 | - public void setStopNo(String stopNo) { | |
| 153 | - this.stopNo = stopNo; | |
| 154 | - } | |
| 155 | - | |
| 156 | - public Float getLon() { | |
| 157 | - return lon; | |
| 158 | - } | |
| 159 | - | |
| 160 | - public void setLon(Float lon) { | |
| 161 | - this.lon = lon; | |
| 162 | - } | |
| 163 | - | |
| 164 | - public Float getLat() { | |
| 165 | - return lat; | |
| 166 | - } | |
| 167 | - | |
| 168 | - public void setLat(Float lat) { | |
| 169 | - this.lat = lat; | |
| 170 | - } | |
| 171 | - | |
| 172 | - public Long getTimestamp() { | |
| 173 | - return timestamp; | |
| 174 | - } | |
| 175 | - | |
| 176 | - public void setTimestamp(Long timestamp) { | |
| 177 | - this.timestamp = timestamp; | |
| 178 | - } | |
| 179 | - | |
| 180 | - | |
| 181 | - public Integer getState() { | |
| 182 | - return state; | |
| 183 | - } | |
| 184 | - | |
| 185 | - public void setState(Integer state) { | |
| 186 | - this.state = state; | |
| 187 | - } | |
| 188 | - | |
| 189 | - public String getNbbm() { | |
| 190 | - return nbbm; | |
| 191 | - } | |
| 192 | - | |
| 193 | - public void setNbbm(String nbbm) { | |
| 194 | - this.nbbm = nbbm; | |
| 195 | - } | |
| 196 | - | |
| 197 | - public String getStationName() { | |
| 198 | - return stationName; | |
| 199 | - } | |
| 200 | - | |
| 201 | - public void setStationName(String stationName) { | |
| 202 | - this.stationName = stationName; | |
| 203 | - } | |
| 204 | - | |
| 205 | - public long getArrTime() { | |
| 206 | - return arrTime; | |
| 207 | - } | |
| 208 | - | |
| 209 | - public void setArrTime(long arrTime) { | |
| 210 | - this.arrTime = arrTime; | |
| 211 | - } | |
| 212 | - | |
| 213 | - public Float getExpectStopTime() { | |
| 214 | - return expectStopTime; | |
| 215 | - } | |
| 216 | - | |
| 217 | - public void setExpectStopTime(Float expectStopTime) { | |
| 218 | - this.expectStopTime = expectStopTime; | |
| 219 | - } | |
| 220 | - | |
| 221 | - public String getLineId() { | |
| 222 | - return lineId; | |
| 223 | - } | |
| 224 | - | |
| 225 | - public void setLineId(String lineId) { | |
| 226 | - this.lineId = lineId; | |
| 227 | - } | |
| 228 | - | |
| 229 | - public Long getSchId() { | |
| 230 | - return schId; | |
| 231 | - } | |
| 232 | - | |
| 233 | - public void setSchId(Long schId) { | |
| 234 | - this.schId = schId; | |
| 235 | - } | |
| 236 | - | |
| 237 | - | |
| 238 | - public int getVersion() { | |
| 239 | - return version; | |
| 240 | - } | |
| 241 | - | |
| 242 | - public void setVersion(int version) { | |
| 243 | - this.version = version; | |
| 244 | - } | |
| 245 | - | |
| 246 | - public StationRoute getStation() { | |
| 247 | - return station; | |
| 248 | - } | |
| 249 | - | |
| 250 | - public void setStation(StationRoute station) { | |
| 251 | - this.station = station; | |
| 252 | - } | |
| 253 | - | |
| 254 | - public String getSignalState() { | |
| 255 | - return signalState; | |
| 256 | - } | |
| 257 | - | |
| 258 | - public void setSignalState(String signalState) { | |
| 259 | - this.signalState = signalState; | |
| 260 | - } | |
| 261 | - | |
| 262 | - public int getInstation() { | |
| 263 | - return instation; | |
| 264 | - } | |
| 265 | - | |
| 266 | - public void setInstation(int instation) { | |
| 267 | - this.instation = instation; | |
| 268 | - } | |
| 269 | - | |
| 270 | - public String getAbnormalStatus() { | |
| 271 | - return abnormalStatus; | |
| 272 | - } | |
| 273 | - | |
| 274 | - public void setAbnormalStatus(String abnormalStatus) { | |
| 275 | - this.abnormalStatus = abnormalStatus; | |
| 276 | - } | |
| 277 | - | |
| 278 | - public double getOutOfBoundDistance() { | |
| 279 | - return outOfBoundDistance; | |
| 280 | - } | |
| 281 | - | |
| 282 | - public void setOutOfBoundDistance(double outOfBoundDistance) { | |
| 283 | - this.outOfBoundDistance = outOfBoundDistance; | |
| 284 | - } | |
| 285 | - | |
| 286 | - public int getValid() { | |
| 287 | - return valid; | |
| 288 | - } | |
| 289 | - | |
| 290 | - public void setValid(int valid) { | |
| 291 | - this.valid = valid; | |
| 292 | - } | |
| 293 | - | |
| 294 | - | |
| 295 | - | |
| 296 | - public short getCompanyCode() { | |
| 297 | - return companyCode; | |
| 298 | - } | |
| 299 | - | |
| 300 | - public void setCompanyCode(short companyCode) { | |
| 301 | - this.companyCode = companyCode; | |
| 302 | - } | |
| 303 | - | |
| 304 | - public Byte getUpDown() { | |
| 305 | - return upDown; | |
| 306 | - } | |
| 307 | - | |
| 308 | - public void setUpDown(Byte upDown) { | |
| 309 | - this.upDown = upDown; | |
| 310 | - } | |
| 311 | - | |
| 312 | - | |
| 313 | - public float getDirection() { | |
| 314 | - return direction; | |
| 315 | - } | |
| 316 | - | |
| 317 | - public void setDirection(float direction) { | |
| 318 | - this.direction = direction; | |
| 319 | - } | |
| 320 | - | |
| 321 | - public Float getSpeed() { | |
| 322 | - return speed; | |
| 323 | - } | |
| 324 | - | |
| 325 | - public void setSpeed(Float speed) { | |
| 326 | - this.speed = speed; | |
| 327 | - } | |
| 328 | - | |
| 329 | - public int getSource() { | |
| 330 | - return source; | |
| 331 | - } | |
| 332 | - | |
| 333 | - public void setSource(int source) { | |
| 334 | - this.source = source; | |
| 335 | - } | |
| 336 | - | |
| 337 | - public void offline(){ | |
| 338 | - this.setAbnormalStatus("offline"); | |
| 339 | - } | |
| 340 | - | |
| 341 | -/* public boolean isOnline(){ | |
| 342 | - if(isOffline()) | |
| 343 | - return false; | |
| 344 | - | |
| 345 | - long t = System.currentTimeMillis(); | |
| 346 | - | |
| 347 | - if((t - this.getServerTimestamp()) > 1000 * 60 * 2){ | |
| 348 | - return false; | |
| 349 | - } | |
| 350 | - | |
| 351 | - if((this.getServerTimestamp() - t) > 1000 * 60 * 3){ | |
| 352 | - return false; | |
| 353 | - } | |
| 354 | - return true; | |
| 355 | - }*/ | |
| 356 | - | |
| 357 | - /** | |
| 358 | - * 是否营运 | |
| 359 | - * @return | |
| 360 | - */ | |
| 361 | - public boolean isService(){ | |
| 362 | - return state!=null && state==0; | |
| 363 | - } | |
| 364 | - | |
| 365 | - public boolean isOffline(){ | |
| 366 | - return this.getAbnormalStatus() != null && this.getAbnormalStatus().equals("offline"); | |
| 367 | - } | |
| 368 | - | |
| 369 | - public Long getServerTimestamp() { | |
| 370 | - return serverTimestamp; | |
| 371 | - } | |
| 372 | - | |
| 373 | - public void setServerTimestamp(Long serverTimestamp) { | |
| 374 | - this.serverTimestamp = serverTimestamp; | |
| 375 | - } | |
| 376 | - | |
| 377 | - public String getPremiseCode() { | |
| 378 | - return premiseCode; | |
| 379 | - } | |
| 380 | - | |
| 381 | - public void setPremiseCode(String premiseCode) { | |
| 382 | - this.premiseCode = premiseCode; | |
| 383 | - } | |
| 384 | - | |
| 385 | - public String getRemark() { | |
| 386 | - return remark; | |
| 387 | - } | |
| 388 | - | |
| 389 | - public void setRemark(String remark) { | |
| 390 | - this.remark = remark; | |
| 391 | - } | |
| 392 | - | |
| 393 | - public String getPlanCode() { | |
| 394 | - return planCode; | |
| 395 | - } | |
| 396 | - | |
| 397 | - public void setPlanCode(String planCode) { | |
| 398 | - this.planCode = planCode; | |
| 399 | - } | |
| 400 | - | |
| 401 | - public String getOrigStateStr() { | |
| 402 | - return origStateStr; | |
| 403 | - } | |
| 404 | - | |
| 405 | - public void setOrigStateStr(String origStateStr) { | |
| 406 | - this.origStateStr = origStateStr; | |
| 407 | - } | |
| 408 | -} | |
| 1 | +package com.bsth.data.gpsdata_v2.entity; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * | |
| 7 | + * @ClassName: GpsRealData | |
| 8 | + * @Description: TODO(HTTP接口的实时GPS数据) | |
| 9 | + * @author PanZhao | |
| 10 | + * @date 2016年5月11日 下午4:32:07 | |
| 11 | + * | |
| 12 | + */ | |
| 13 | +public class GpsEntity implements Cloneable{ | |
| 14 | + | |
| 15 | + /** 公司代码 */ | |
| 16 | + @JsonIgnore | |
| 17 | + private Short companyCode; | |
| 18 | + | |
| 19 | + /** 线路编码 */ | |
| 20 | + private String lineId; | |
| 21 | + | |
| 22 | + /** 设备编码 */ | |
| 23 | + private String deviceId; | |
| 24 | + | |
| 25 | + /** 停车场编码 */ | |
| 26 | + private String carparkNo; | |
| 27 | + | |
| 28 | + /** 站点编码 */ | |
| 29 | + private String stopNo; | |
| 30 | + | |
| 31 | + /** 站点名称 */ | |
| 32 | + private String stationName; | |
| 33 | + | |
| 34 | + /** 到站时间 */ | |
| 35 | + @JsonIgnore | |
| 36 | + private long arrTime; | |
| 37 | + | |
| 38 | + /** 经度 */ | |
| 39 | + private Float lon; | |
| 40 | + | |
| 41 | + /** 纬度 */ | |
| 42 | + private Float lat; | |
| 43 | + | |
| 44 | + /** GPS发送时间戳 */ | |
| 45 | + private Long timestamp; | |
| 46 | + | |
| 47 | + /** 网关收到时间 */ | |
| 48 | + private Long serverTimestamp; | |
| 49 | + | |
| 50 | + /** 速度 */ | |
| 51 | + private Float speed; | |
| 52 | + | |
| 53 | + /** 方向(角度) */ | |
| 54 | + private float direction; | |
| 55 | + | |
| 56 | + /** 营运状态( 0 营运 ,1 非营运, -1 无效) */ | |
| 57 | + private Integer state; | |
| 58 | + | |
| 59 | + /** 上下行(0 上行 , 1 下行 , -1 无效) */ | |
| 60 | + private Byte upDown; | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 设备原始走向_营运状态 | |
| 64 | + * 当设备状态和系统不一致时,该字段有值 | |
| 65 | + */ | |
| 66 | + private String origStateStr; | |
| 67 | + | |
| 68 | + /** 车辆内部编码 */ | |
| 69 | + private String nbbm; | |
| 70 | + | |
| 71 | + /** 预计到达终点时间 */ | |
| 72 | + private Float expectStopTime; | |
| 73 | + | |
| 74 | + /** 当前执行班次ID */ | |
| 75 | + private Long schId; | |
| 76 | + | |
| 77 | + private int version; | |
| 78 | + | |
| 79 | + /** 0: 站外 1:站内 2:场内 */ | |
| 80 | + private int instation; | |
| 81 | + | |
| 82 | + /** 站点信息,站内时有值 */ | |
| 83 | + @JsonIgnore | |
| 84 | + private StationRoute station; | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * 前置约束 -站点编码 | |
| 88 | + */ | |
| 89 | + @JsonIgnore | |
| 90 | + private String premiseCode; | |
| 91 | + | |
| 92 | + /** 状态 */ | |
| 93 | + private String signalState = "normal"; | |
| 94 | + | |
| 95 | + /** 异常状态 */ | |
| 96 | + private String abnormalStatus; | |
| 97 | + | |
| 98 | + /** 越界距离 */ | |
| 99 | + private double outOfBoundDistance; | |
| 100 | + | |
| 101 | + /** gps是否有效 设备端发送的状态 */ | |
| 102 | + private int valid; | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * 数据来源 | |
| 106 | + * 1:网关 | |
| 107 | + * 0:转发 | |
| 108 | + */ | |
| 109 | + private int source = -1; | |
| 110 | + | |
| 111 | + private String remark; | |
| 112 | + private String planCode; | |
| 113 | + | |
| 114 | + private String dvrcode; | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * 电量 单位:% | |
| 118 | + */ | |
| 119 | + private int energy = -1; | |
| 120 | + | |
| 121 | + public Object clone() { | |
| 122 | + try { | |
| 123 | + return super.clone(); | |
| 124 | + } catch (CloneNotSupportedException e) { | |
| 125 | + return null; | |
| 126 | + } | |
| 127 | + } | |
| 128 | + | |
| 129 | + public String getDvrcode() { | |
| 130 | + return dvrcode; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public void setDvrcode(String dvrcode) { | |
| 134 | + this.dvrcode = dvrcode; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public String getDeviceId() { | |
| 138 | + return deviceId; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public void setDeviceId(String deviceId) { | |
| 142 | + this.deviceId = deviceId; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public String getCarparkNo() { | |
| 146 | + return carparkNo; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void setCarparkNo(String carparkNo) { | |
| 150 | + this.carparkNo = carparkNo; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public String getStopNo() { | |
| 154 | + return stopNo; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public void setStopNo(String stopNo) { | |
| 158 | + this.stopNo = stopNo; | |
| 159 | + } | |
| 160 | + | |
| 161 | + public Float getLon() { | |
| 162 | + return lon; | |
| 163 | + } | |
| 164 | + | |
| 165 | + public void setLon(Float lon) { | |
| 166 | + this.lon = lon; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public Float getLat() { | |
| 170 | + return lat; | |
| 171 | + } | |
| 172 | + | |
| 173 | + public void setLat(Float lat) { | |
| 174 | + this.lat = lat; | |
| 175 | + } | |
| 176 | + | |
| 177 | + public Long getTimestamp() { | |
| 178 | + return timestamp; | |
| 179 | + } | |
| 180 | + | |
| 181 | + public void setTimestamp(Long timestamp) { | |
| 182 | + this.timestamp = timestamp; | |
| 183 | + } | |
| 184 | + | |
| 185 | + | |
| 186 | + public Integer getState() { | |
| 187 | + return state; | |
| 188 | + } | |
| 189 | + | |
| 190 | + public void setState(Integer state) { | |
| 191 | + this.state = state; | |
| 192 | + } | |
| 193 | + | |
| 194 | + public String getNbbm() { | |
| 195 | + return nbbm; | |
| 196 | + } | |
| 197 | + | |
| 198 | + public void setNbbm(String nbbm) { | |
| 199 | + this.nbbm = nbbm; | |
| 200 | + } | |
| 201 | + | |
| 202 | + public String getStationName() { | |
| 203 | + return stationName; | |
| 204 | + } | |
| 205 | + | |
| 206 | + public void setStationName(String stationName) { | |
| 207 | + this.stationName = stationName; | |
| 208 | + } | |
| 209 | + | |
| 210 | + public long getArrTime() { | |
| 211 | + return arrTime; | |
| 212 | + } | |
| 213 | + | |
| 214 | + public void setArrTime(long arrTime) { | |
| 215 | + this.arrTime = arrTime; | |
| 216 | + } | |
| 217 | + | |
| 218 | + public Float getExpectStopTime() { | |
| 219 | + return expectStopTime; | |
| 220 | + } | |
| 221 | + | |
| 222 | + public void setExpectStopTime(Float expectStopTime) { | |
| 223 | + this.expectStopTime = expectStopTime; | |
| 224 | + } | |
| 225 | + | |
| 226 | + public String getLineId() { | |
| 227 | + return lineId; | |
| 228 | + } | |
| 229 | + | |
| 230 | + public void setLineId(String lineId) { | |
| 231 | + this.lineId = lineId; | |
| 232 | + } | |
| 233 | + | |
| 234 | + public Long getSchId() { | |
| 235 | + return schId; | |
| 236 | + } | |
| 237 | + | |
| 238 | + public void setSchId(Long schId) { | |
| 239 | + this.schId = schId; | |
| 240 | + } | |
| 241 | + | |
| 242 | + | |
| 243 | + public int getVersion() { | |
| 244 | + return version; | |
| 245 | + } | |
| 246 | + | |
| 247 | + public void setVersion(int version) { | |
| 248 | + this.version = version; | |
| 249 | + } | |
| 250 | + | |
| 251 | + public StationRoute getStation() { | |
| 252 | + return station; | |
| 253 | + } | |
| 254 | + | |
| 255 | + public void setStation(StationRoute station) { | |
| 256 | + this.station = station; | |
| 257 | + } | |
| 258 | + | |
| 259 | + public String getSignalState() { | |
| 260 | + return signalState; | |
| 261 | + } | |
| 262 | + | |
| 263 | + public void setSignalState(String signalState) { | |
| 264 | + this.signalState = signalState; | |
| 265 | + } | |
| 266 | + | |
| 267 | + public int getInstation() { | |
| 268 | + return instation; | |
| 269 | + } | |
| 270 | + | |
| 271 | + public void setInstation(int instation) { | |
| 272 | + this.instation = instation; | |
| 273 | + } | |
| 274 | + | |
| 275 | + public String getAbnormalStatus() { | |
| 276 | + return abnormalStatus; | |
| 277 | + } | |
| 278 | + | |
| 279 | + public void setAbnormalStatus(String abnormalStatus) { | |
| 280 | + this.abnormalStatus = abnormalStatus; | |
| 281 | + } | |
| 282 | + | |
| 283 | + public double getOutOfBoundDistance() { | |
| 284 | + return outOfBoundDistance; | |
| 285 | + } | |
| 286 | + | |
| 287 | + public void setOutOfBoundDistance(double outOfBoundDistance) { | |
| 288 | + this.outOfBoundDistance = outOfBoundDistance; | |
| 289 | + } | |
| 290 | + | |
| 291 | + public int getValid() { | |
| 292 | + return valid; | |
| 293 | + } | |
| 294 | + | |
| 295 | + public void setValid(int valid) { | |
| 296 | + this.valid = valid; | |
| 297 | + } | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + public short getCompanyCode() { | |
| 302 | + return companyCode; | |
| 303 | + } | |
| 304 | + | |
| 305 | + public void setCompanyCode(short companyCode) { | |
| 306 | + this.companyCode = companyCode; | |
| 307 | + } | |
| 308 | + | |
| 309 | + public Byte getUpDown() { | |
| 310 | + return upDown; | |
| 311 | + } | |
| 312 | + | |
| 313 | + public void setUpDown(Byte upDown) { | |
| 314 | + this.upDown = upDown; | |
| 315 | + } | |
| 316 | + | |
| 317 | + | |
| 318 | + public float getDirection() { | |
| 319 | + return direction; | |
| 320 | + } | |
| 321 | + | |
| 322 | + public void setDirection(float direction) { | |
| 323 | + this.direction = direction; | |
| 324 | + } | |
| 325 | + | |
| 326 | + public Float getSpeed() { | |
| 327 | + return speed; | |
| 328 | + } | |
| 329 | + | |
| 330 | + public void setSpeed(Float speed) { | |
| 331 | + this.speed = speed; | |
| 332 | + } | |
| 333 | + | |
| 334 | + public int getSource() { | |
| 335 | + return source; | |
| 336 | + } | |
| 337 | + | |
| 338 | + public void setSource(int source) { | |
| 339 | + this.source = source; | |
| 340 | + } | |
| 341 | + | |
| 342 | + public void offline(){ | |
| 343 | + this.setAbnormalStatus("offline"); | |
| 344 | + } | |
| 345 | + | |
| 346 | +/* public boolean isOnline(){ | |
| 347 | + if(isOffline()) | |
| 348 | + return false; | |
| 349 | + | |
| 350 | + long t = System.currentTimeMillis(); | |
| 351 | + | |
| 352 | + if((t - this.getServerTimestamp()) > 1000 * 60 * 2){ | |
| 353 | + return false; | |
| 354 | + } | |
| 355 | + | |
| 356 | + if((this.getServerTimestamp() - t) > 1000 * 60 * 3){ | |
| 357 | + return false; | |
| 358 | + } | |
| 359 | + return true; | |
| 360 | + }*/ | |
| 361 | + | |
| 362 | + /** | |
| 363 | + * 是否营运 | |
| 364 | + * @return | |
| 365 | + */ | |
| 366 | + public boolean isService(){ | |
| 367 | + return state!=null && state==0; | |
| 368 | + } | |
| 369 | + | |
| 370 | + public boolean isOffline(){ | |
| 371 | + return this.getAbnormalStatus() != null && this.getAbnormalStatus().equals("offline"); | |
| 372 | + } | |
| 373 | + | |
| 374 | + public Long getServerTimestamp() { | |
| 375 | + return serverTimestamp; | |
| 376 | + } | |
| 377 | + | |
| 378 | + public void setServerTimestamp(Long serverTimestamp) { | |
| 379 | + this.serverTimestamp = serverTimestamp; | |
| 380 | + } | |
| 381 | + | |
| 382 | + public String getPremiseCode() { | |
| 383 | + return premiseCode; | |
| 384 | + } | |
| 385 | + | |
| 386 | + public void setPremiseCode(String premiseCode) { | |
| 387 | + this.premiseCode = premiseCode; | |
| 388 | + } | |
| 389 | + | |
| 390 | + public String getRemark() { | |
| 391 | + return remark; | |
| 392 | + } | |
| 393 | + | |
| 394 | + public void setRemark(String remark) { | |
| 395 | + this.remark = remark; | |
| 396 | + } | |
| 397 | + | |
| 398 | + public String getPlanCode() { | |
| 399 | + return planCode; | |
| 400 | + } | |
| 401 | + | |
| 402 | + public void setPlanCode(String planCode) { | |
| 403 | + this.planCode = planCode; | |
| 404 | + } | |
| 405 | + | |
| 406 | + public String getOrigStateStr() { | |
| 407 | + return origStateStr; | |
| 408 | + } | |
| 409 | + | |
| 410 | + public void setOrigStateStr(String origStateStr) { | |
| 411 | + this.origStateStr = origStateStr; | |
| 412 | + } | |
| 413 | + | |
| 414 | + public int getEnergy() { | |
| 415 | + return energy; | |
| 416 | + } | |
| 417 | + | |
| 418 | + public void setEnergy(int energy) { | |
| 419 | + this.energy = energy; | |
| 420 | + } | |
| 421 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/thread/GpsDataLoaderThread.java
| 1 | -package com.bsth.data.gpsdata_v2.thread; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata_v2.DataHandleProcess; | |
| 4 | -import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 5 | -import com.bsth.data.gpsdata_v2.load.GatewayHttpLoader; | |
| 6 | -import com.bsth.data.gpsdata_v2.load.SocketClientLoader; | |
| 7 | -import org.slf4j.Logger; | |
| 8 | -import org.slf4j.LoggerFactory; | |
| 9 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | - | |
| 12 | -import java.util.List; | |
| 13 | - | |
| 14 | -/** | |
| 15 | - * Created by panzhao on 2017/1/11. | |
| 16 | - */ | |
| 17 | -@Component | |
| 18 | -public class GpsDataLoaderThread extends Thread { | |
| 19 | - | |
| 20 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 21 | - | |
| 22 | - //0:从GPS客户端内存获取 -1:从网关获取 | |
| 23 | - private static int flag = 0; | |
| 24 | - | |
| 25 | - public static void setFlag(int v) { | |
| 26 | - flag = v; | |
| 27 | - } | |
| 28 | - | |
| 29 | - @Autowired | |
| 30 | - DataHandleProcess handleProcess; | |
| 31 | - | |
| 32 | - @Override | |
| 33 | - public void run() { | |
| 34 | - try { | |
| 35 | - List<GpsEntity> list; | |
| 36 | - if (flag == 0) | |
| 37 | - list = SocketClientLoader.load(); | |
| 38 | - else | |
| 39 | - list = GatewayHttpLoader.load(); | |
| 40 | - | |
| 41 | - if(null != list && list.size() > 0) | |
| 42 | - handleProcess.handle(list); | |
| 43 | - } catch (Exception e) { | |
| 44 | - logger.error("", e); | |
| 45 | - } | |
| 46 | - } | |
| 1 | +package com.bsth.data.gpsdata_v2.thread; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata_v2.DataHandleProcess; | |
| 4 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 5 | +import com.bsth.data.gpsdata_v2.load.GatewayHttpLoader; | |
| 6 | +import com.bsth.data.gpsdata_v2.load.SocketClientLoader; | |
| 7 | +import org.slf4j.Logger; | |
| 8 | +import org.slf4j.LoggerFactory; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * Created by panzhao on 2017/1/11. | |
| 16 | + */ | |
| 17 | +@Component | |
| 18 | +public class GpsDataLoaderThread extends Thread { | |
| 19 | + | |
| 20 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 21 | + | |
| 22 | + //0:从GPS客户端内存获取 -1:从网关获取 | |
| 23 | + private static int flag = 0; | |
| 24 | + | |
| 25 | + public static void setFlag(int v) { | |
| 26 | + flag = v; | |
| 27 | + } | |
| 28 | + | |
| 29 | + @Autowired | |
| 30 | + DataHandleProcess handleProcess; | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public void run() { | |
| 34 | + logger.warn("GPS获取数据开始"); | |
| 35 | + try { | |
| 36 | + List<GpsEntity> list; | |
| 37 | + if (flag == 0) | |
| 38 | + list = SocketClientLoader.load(); | |
| 39 | + else | |
| 40 | + list = GatewayHttpLoader.load(); | |
| 41 | + | |
| 42 | + if(null != list && list.size() > 0) | |
| 43 | + handleProcess.handle(list); | |
| 44 | + } catch (Exception e) { | |
| 45 | + logger.error("", e); | |
| 46 | + } | |
| 47 | + logger.warn("GPS获取数据结束"); | |
| 48 | + } | |
| 47 | 49 | } |
| 48 | 50 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/thread/OfflineMonitorThread.java
| 1 | -package com.bsth.data.gpsdata_v2.thread; | |
| 2 | - | |
| 3 | -import com.bsth.data.gpsdata_v2.GpsRealData; | |
| 4 | -import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 5 | -import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | |
| 6 | -import com.bsth.websocket.handler.SendUtils; | |
| 7 | -import org.slf4j.Logger; | |
| 8 | -import org.slf4j.LoggerFactory; | |
| 9 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | - | |
| 12 | -import java.util.Collection; | |
| 13 | - | |
| 14 | -/** | |
| 15 | - * GPS掉离线监控 | |
| 16 | - * Created by panzhao on 2017/1/11. | |
| 17 | - */ | |
| 18 | -@Component | |
| 19 | -public class OfflineMonitorThread extends Thread{ | |
| 20 | - | |
| 21 | - @Autowired | |
| 22 | - GpsRealData gpsRealData; | |
| 23 | - | |
| 24 | - //掉线阈值 | |
| 25 | - private final static int LOSE_TIME = 1000 * 60 * 10; | |
| 26 | - | |
| 27 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 28 | - | |
| 29 | - @Autowired | |
| 30 | - SendUtils sendUtils; | |
| 31 | - | |
| 32 | - @Autowired | |
| 33 | - OverspeedProcess overspeedProcess; | |
| 34 | - | |
| 35 | - //无任务时 离线阈值 | |
| 36 | - //private final static int OFFLINE_TIME = 1000 * 60 * 10; | |
| 37 | - | |
| 38 | - @Override | |
| 39 | - public void run() { | |
| 40 | - try{ | |
| 41 | - long t = System.currentTimeMillis(); | |
| 42 | - Collection<GpsEntity> list = gpsRealData.all(); | |
| 43 | - | |
| 44 | - String state; | |
| 45 | - for(GpsEntity gps : list){ | |
| 46 | - state = gps.getAbnormalStatus(); | |
| 47 | - | |
| 48 | - if(state != null && state.equals("offline")) | |
| 49 | - continue; | |
| 50 | - | |
| 51 | - if (t - gps.getTimestamp() > LOSE_TIME){ | |
| 52 | - gps.offline(); | |
| 53 | - | |
| 54 | - //结束超速 | |
| 55 | - overspeedProcess.offline(gps.getDeviceId()); | |
| 56 | - //通知页面有设备掉线 | |
| 57 | - sendUtils.deviceOffline(gps); | |
| 58 | - } | |
| 59 | - } | |
| 60 | - }catch (Exception e){ | |
| 61 | - logger.error("", e); | |
| 62 | - } | |
| 63 | - } | |
| 64 | -} | |
| 1 | +package com.bsth.data.gpsdata_v2.thread; | |
| 2 | + | |
| 3 | +import com.bsth.data.gpsdata_v2.GpsRealData; | |
| 4 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 5 | +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | |
| 6 | +import com.bsth.websocket.handler.SendUtils; | |
| 7 | +import org.slf4j.Logger; | |
| 8 | +import org.slf4j.LoggerFactory; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +import java.util.Collection; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * GPS掉离线监控 | |
| 16 | + * Created by panzhao on 2017/1/11. | |
| 17 | + */ | |
| 18 | +@Component | |
| 19 | +public class OfflineMonitorThread extends Thread{ | |
| 20 | + | |
| 21 | + @Autowired | |
| 22 | + GpsRealData gpsRealData; | |
| 23 | + | |
| 24 | + //掉线阈值 | |
| 25 | + private final static int LOSE_TIME = 1000 * 60 * 10; | |
| 26 | + | |
| 27 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 28 | + | |
| 29 | + @Autowired | |
| 30 | + SendUtils sendUtils; | |
| 31 | + | |
| 32 | + @Autowired | |
| 33 | + OverspeedProcess overspeedProcess; | |
| 34 | + | |
| 35 | + //无任务时 离线阈值 | |
| 36 | + //private final static int OFFLINE_TIME = 1000 * 60 * 10; | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public void run() { | |
| 40 | + logger.warn("GPS离线检查开始"); | |
| 41 | + try{ | |
| 42 | + long t = System.currentTimeMillis(); | |
| 43 | + Collection<GpsEntity> list = gpsRealData.all(); | |
| 44 | + | |
| 45 | + String state; | |
| 46 | + for(GpsEntity gps : list){ | |
| 47 | + state = gps.getAbnormalStatus(); | |
| 48 | + | |
| 49 | + if(state != null && state.equals("offline")) | |
| 50 | + continue; | |
| 51 | + | |
| 52 | + if (t - gps.getTimestamp() > LOSE_TIME){ | |
| 53 | + gps.offline(); | |
| 54 | + | |
| 55 | + //结束超速 | |
| 56 | + overspeedProcess.offline(gps.getDeviceId()); | |
| 57 | + //通知页面有设备掉线 | |
| 58 | + sendUtils.deviceOffline(gps); | |
| 59 | + } | |
| 60 | + } | |
| 61 | + }catch (Exception e){ | |
| 62 | + logger.error("", e); | |
| 63 | + } | |
| 64 | + logger.warn("GPS离线检查结束"); | |
| 65 | + } | |
| 66 | +} | ... | ... |
src/main/java/com/bsth/data/maintenance_plan/MtPlanDataLoadThread.java
| 1 | 1 | package com.bsth.data.maintenance_plan; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 5 | 4 | import org.apache.http.HttpEntity; |
| 6 | 5 | import org.apache.http.client.config.RequestConfig; |
| ... | ... | @@ -27,6 +26,7 @@ import java.util.Map; |
| 27 | 26 | |
| 28 | 27 | /** |
| 29 | 28 | * 维修保养计划 |
| 29 | + * @author Hill | |
| 30 | 30 | */ |
| 31 | 31 | @Component |
| 32 | 32 | public class MtPlanDataLoadThread extends Thread implements InitializingBean { |
| ... | ... | @@ -57,6 +57,7 @@ public class MtPlanDataLoadThread extends Thread implements InitializingBean { |
| 57 | 57 | |
| 58 | 58 | @Override |
| 59 | 59 | public void run() { |
| 60 | + logger.warn("维修保养计划获取数据开始"); | |
| 60 | 61 | List<MaintenancePlan> list; |
| 61 | 62 | StringBuilder sb = new StringBuilder(url); |
| 62 | 63 | try { |
| ... | ... | @@ -92,6 +93,7 @@ public class MtPlanDataLoadThread extends Thread implements InitializingBean { |
| 92 | 93 | } catch (Exception e) { |
| 93 | 94 | logger.error("维修保养计划接口报错了", e); |
| 94 | 95 | } |
| 96 | + logger.warn("维修保养计划获取数据结束"); | |
| 95 | 97 | } |
| 96 | 98 | |
| 97 | 99 | @Override | ... | ... |
src/main/java/com/bsth/data/safe_driv/SafeDrivDataLoadThread.java
| 1 | -package com.bsth.data.safe_driv; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import org.apache.http.HttpEntity; | |
| 5 | -import org.apache.http.client.config.RequestConfig; | |
| 6 | -import org.apache.http.client.methods.CloseableHttpResponse; | |
| 7 | -import org.apache.http.client.methods.HttpGet; | |
| 8 | -import org.apache.http.impl.client.CloseableHttpClient; | |
| 9 | -import org.apache.http.impl.client.HttpClients; | |
| 10 | -import org.slf4j.Logger; | |
| 11 | -import org.slf4j.LoggerFactory; | |
| 12 | -import org.springframework.stereotype.Component; | |
| 13 | - | |
| 14 | -import java.io.BufferedReader; | |
| 15 | -import java.io.InputStreamReader; | |
| 16 | -import java.util.List; | |
| 17 | - | |
| 18 | -/** | |
| 19 | - * 安全驾驶数据加载线程 | |
| 20 | - * Created by panzhao on 2017/4/6. | |
| 21 | - */ | |
| 22 | -@Component | |
| 23 | -public class SafeDrivDataLoadThread extends Thread { | |
| 24 | - | |
| 25 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 26 | - | |
| 27 | - static String url; | |
| 28 | - static CloseableHttpClient httpClient; | |
| 29 | - static HttpGet get; | |
| 30 | - static RequestConfig requestConfig; | |
| 31 | - static CloseableHttpResponse response; | |
| 32 | - static HttpEntity entity; | |
| 33 | - static BufferedReader br; | |
| 34 | - | |
| 35 | - static { | |
| 36 | - url = "http://211.95.61.66:9008/safedriving/realtimeInterface"; | |
| 37 | - httpClient = HttpClients.createDefault(); | |
| 38 | - get = new HttpGet(url); | |
| 39 | - requestConfig = RequestConfig.custom() | |
| 40 | - .setConnectTimeout(5500).setConnectionRequestTimeout(5000) | |
| 41 | - .setSocketTimeout(5500).build(); | |
| 42 | - get.setConfig(requestConfig); | |
| 43 | - } | |
| 44 | - | |
| 45 | - @Override | |
| 46 | - public void run() { | |
| 47 | - List<SafeDriv> list; | |
| 48 | - try { | |
| 49 | - | |
| 50 | - response = httpClient.execute(get); | |
| 51 | - | |
| 52 | - int statusCode = response.getStatusLine().getStatusCode(); | |
| 53 | - if(statusCode != 200){ | |
| 54 | - logger.error("http client status code: " + statusCode); | |
| 55 | - } | |
| 56 | - | |
| 57 | - entity = response.getEntity(); | |
| 58 | - if (null != entity) { | |
| 59 | - br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
| 60 | - StringBuffer stringBuffer = new StringBuffer(); | |
| 61 | - String str = ""; | |
| 62 | - while ((str = br.readLine()) != null) | |
| 63 | - stringBuffer.append(str); | |
| 64 | - | |
| 65 | - | |
| 66 | - list = JSON.parseArray(stringBuffer.toString(), SafeDriv.class); | |
| 67 | - | |
| 68 | - for (SafeDriv sd : list) { | |
| 69 | - SafeDrivCenter.put(sd); | |
| 70 | - } | |
| 71 | - } | |
| 72 | - | |
| 73 | - if (null != response) | |
| 74 | - response.close(); | |
| 75 | - } catch (Exception e) { | |
| 76 | - logger.error("安全驾驶接口报错了", e); | |
| 77 | - } | |
| 78 | - } | |
| 79 | -} | |
| 1 | +package com.bsth.data.safe_driv; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import org.apache.http.HttpEntity; | |
| 5 | +import org.apache.http.client.config.RequestConfig; | |
| 6 | +import org.apache.http.client.methods.CloseableHttpResponse; | |
| 7 | +import org.apache.http.client.methods.HttpGet; | |
| 8 | +import org.apache.http.impl.client.CloseableHttpClient; | |
| 9 | +import org.apache.http.impl.client.HttpClients; | |
| 10 | +import org.slf4j.Logger; | |
| 11 | +import org.slf4j.LoggerFactory; | |
| 12 | +import org.springframework.stereotype.Component; | |
| 13 | + | |
| 14 | +import java.io.BufferedReader; | |
| 15 | +import java.io.InputStreamReader; | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 安全驾驶数据加载线程 | |
| 20 | + * Created by panzhao on 2017/4/6. | |
| 21 | + */ | |
| 22 | +@Component | |
| 23 | +public class SafeDrivDataLoadThread extends Thread { | |
| 24 | + | |
| 25 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 26 | + | |
| 27 | + static String url; | |
| 28 | + static CloseableHttpClient httpClient; | |
| 29 | + static HttpGet get; | |
| 30 | + static RequestConfig requestConfig; | |
| 31 | + static CloseableHttpResponse response; | |
| 32 | + static HttpEntity entity; | |
| 33 | + static BufferedReader br; | |
| 34 | + | |
| 35 | + static { | |
| 36 | + url = "http://211.95.61.66:9008/safedriving/realtimeInterface"; | |
| 37 | + httpClient = HttpClients.createDefault(); | |
| 38 | + get = new HttpGet(url); | |
| 39 | + requestConfig = RequestConfig.custom() | |
| 40 | + .setConnectTimeout(5500).setConnectionRequestTimeout(5000) | |
| 41 | + .setSocketTimeout(5500).build(); | |
| 42 | + get.setConfig(requestConfig); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public void run() { | |
| 47 | + logger.warn("安全驾驶获取数据开始"); | |
| 48 | + List<SafeDriv> list; | |
| 49 | + try { | |
| 50 | + | |
| 51 | + response = httpClient.execute(get); | |
| 52 | + | |
| 53 | + int statusCode = response.getStatusLine().getStatusCode(); | |
| 54 | + if(statusCode != 200){ | |
| 55 | + logger.error("http client status code: " + statusCode); | |
| 56 | + } | |
| 57 | + | |
| 58 | + entity = response.getEntity(); | |
| 59 | + if (null != entity) { | |
| 60 | + br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
| 61 | + StringBuffer stringBuffer = new StringBuffer(); | |
| 62 | + String str = ""; | |
| 63 | + while ((str = br.readLine()) != null) | |
| 64 | + stringBuffer.append(str); | |
| 65 | + | |
| 66 | + | |
| 67 | + list = JSON.parseArray(stringBuffer.toString(), SafeDriv.class); | |
| 68 | + | |
| 69 | + for (SafeDriv sd : list) { | |
| 70 | + SafeDrivCenter.put(sd); | |
| 71 | + } | |
| 72 | + } | |
| 73 | + | |
| 74 | + if (null != response) | |
| 75 | + response.close(); | |
| 76 | + } catch (Exception e) { | |
| 77 | + logger.error("安全驾驶接口报错了", e); | |
| 78 | + } | |
| 79 | + logger.warn("安全驾驶获取数据结束"); | |
| 80 | + } | |
| 81 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| ... | ... | @@ -15,6 +15,8 @@ import com.bsth.entity.schedule.SchedulePlanInfo; |
| 15 | 15 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 16 | 16 | import com.bsth.service.schedule.SchedulePlanInfoService; |
| 17 | 17 | import com.bsth.websocket.handler.SendUtils; |
| 18 | +import com.fasterxml.jackson.core.JsonProcessingException; | |
| 19 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
| 18 | 20 | import com.google.common.collect.ArrayListMultimap; |
| 19 | 21 | import com.google.common.collect.HashMultimap; |
| 20 | 22 | import com.google.common.collect.ListMultimap; |
| ... | ... | @@ -29,11 +31,10 @@ import org.springframework.beans.factory.annotation.Value; |
| 29 | 31 | import org.springframework.dao.DataIntegrityViolationException; |
| 30 | 32 | import org.springframework.jdbc.core.BatchPreparedStatementSetter; |
| 31 | 33 | import org.springframework.jdbc.core.JdbcTemplate; |
| 32 | -import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 33 | 34 | import org.springframework.stereotype.Component; |
| 34 | -import org.springframework.transaction.TransactionDefinition; | |
| 35 | 35 | import org.springframework.transaction.TransactionStatus; |
| 36 | -import org.springframework.transaction.support.DefaultTransactionDefinition; | |
| 36 | +import org.springframework.transaction.support.TransactionCallbackWithoutResult; | |
| 37 | +import org.springframework.transaction.support.TransactionTemplate; | |
| 37 | 38 | |
| 38 | 39 | import java.sql.PreparedStatement; |
| 39 | 40 | import java.sql.SQLException; |
| ... | ... | @@ -440,85 +441,84 @@ public class DayOfSchedule { |
| 440 | 441 | item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate())); |
| 441 | 442 | } |
| 442 | 443 | |
| 443 | - //编程式事务 | |
| 444 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 445 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 446 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 447 | - TransactionStatus status = tran.getTransaction(def); | |
| 448 | - | |
| 449 | - try{ | |
| 450 | - final List<ScheduleRealInfo> pstList = list; | |
| 451 | - //写入 | |
| 452 | - jdbcTemplate.batchUpdate("insert into bsth_c_s_sp_info_real(id,bc_type,bcs,bcsj,cl_zbh,create_date,dfsj,directive_state,fcno,fcsj,fcsj_actual,j_gh,j_name,jhlc,lp_name,qdz_code,qdz_name,real_exec_date,remarks,s_gh,s_name,schedule_date,schedule_date_str,sflj,sp_id,status,update_date,xl_bm,xl_dir,xl_name,zdsj,zdsj_actual,zdz_code,zdz_name,ccno,df_auto,fgs_bm,fgs_name,gs_bm,gs_name,online,adjust_exps,reissue,jhlc_orig,sigin_compate,drift_status,cc_service,major_station_name,rfid_state,first_rfid_state)" + | |
| 453 | - " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 454 | - @Override | |
| 455 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 456 | - ScheduleRealInfo sch = pstList.get(i); | |
| 457 | - ps.setLong(1, sch.getId()); | |
| 458 | - ps.setString(2, sch.getBcType()); | |
| 459 | - ps.setInt(3, sch.getBcs()==null?0:sch.getBcs()); | |
| 460 | - ps.setInt(4, sch.getBcsj()==null?0:sch.getBcsj()); | |
| 461 | - ps.setString(5, sch.getClZbh()); | |
| 462 | - ps.setTimestamp(6, new java.sql.Timestamp(sch.getCreateDate().getTime())); | |
| 463 | - ps.setString(7, sch.getDfsj()); | |
| 464 | - ps.setInt(8, sch.getDirectiveState()); | |
| 465 | - ps.setInt(9, sch.getFcno()==null?0:sch.getFcno()); | |
| 466 | - ps.setString(10, sch.getFcsj()); | |
| 467 | - ps.setString(11, sch.getFcsjActual()); | |
| 468 | - ps.setString(12, sch.getjGh()); | |
| 469 | - ps.setString(13, sch.getjName()); | |
| 470 | - ps.setDouble(14, sch.getJhlc()); | |
| 471 | - ps.setString(15, sch.getLpName()); | |
| 472 | - ps.setString(16, sch.getQdzCode()); | |
| 473 | - ps.setString(17, sch.getQdzName()); | |
| 474 | - ps.setString(18, sch.getRealExecDate()); | |
| 475 | - ps.setString(19, sch.getRemarks()); | |
| 476 | - ps.setString(20, sch.getsGh()); | |
| 477 | - ps.setString(21, sch.getsName()); | |
| 478 | - ps.setTimestamp(22, new java.sql.Timestamp(sch.getScheduleDate().getTime())); | |
| 479 | - ps.setString(23, sch.getScheduleDateStr()); | |
| 480 | - ps.setBoolean(24, sch.isSflj()); | |
| 481 | - ps.setLong(25, sch.getSpId()); | |
| 482 | - ps.setInt(26, sch.getStatus()); | |
| 483 | - ps.setTimestamp(27, new java.sql.Timestamp(sch.getUpdateDate().getTime())); | |
| 484 | - ps.setString(28, sch.getXlBm()); | |
| 485 | - ps.setString(29, sch.getXlDir()); | |
| 486 | - ps.setString(30, sch.getXlName()); | |
| 487 | - ps.setString(31, sch.getZdsj()); | |
| 488 | - ps.setString(32, sch.getZdsjActual()); | |
| 489 | - ps.setString(33, sch.getZdzCode()); | |
| 490 | - ps.setString(34, sch.getZdzName()); | |
| 491 | - ps.setInt(35, sch.getCcno()==null?0:sch.getCcno()); | |
| 492 | - ps.setBoolean(36, sch.isDfAuto()); | |
| 493 | - ps.setString(37, sch.getFgsBm()); | |
| 494 | - ps.setString(38, sch.getFgsName()); | |
| 495 | - ps.setString(39, sch.getGsBm()); | |
| 496 | - ps.setString(40, sch.getGsName()); | |
| 497 | - ps.setBoolean(41, sch.isOnline()); | |
| 498 | - ps.setString(42, sch.getAdjustExps()); | |
| 499 | - ps.setBoolean(43, sch.isReissue()); | |
| 500 | - ps.setDouble(44, sch.getJhlcOrig()); | |
| 501 | - ps.setInt(45, sch.getSiginCompate()); | |
| 502 | - ps.setInt(46, sch.getDriftStatus()); | |
| 503 | - ps.setBoolean(47, sch.isCcService()); | |
| 504 | - ps.setString(48, sch.getMajorStationName()); | |
| 505 | - ps.setInt(49, sch.getRfidState()); | |
| 506 | - ps.setInt(50, sch.getFirstRfidState()); | |
| 507 | - } | |
| 508 | - | |
| 509 | - @Override | |
| 510 | - public int getBatchSize() { | |
| 511 | - return pstList.size(); | |
| 444 | + transactionTemplate.execute(new TransactionCallbackWithoutResult() { | |
| 445 | + @Override | |
| 446 | + protected void doInTransactionWithoutResult(TransactionStatus status) { | |
| 447 | + try{ | |
| 448 | + final List<ScheduleRealInfo> pstList = list; | |
| 449 | + //写入 | |
| 450 | + jdbcTemplate.batchUpdate("insert into bsth_c_s_sp_info_real(id,bc_type,bcs,bcsj,cl_zbh,create_date,dfsj,directive_state,fcno,fcsj,fcsj_actual,j_gh,j_name,jhlc,lp_name,qdz_code,qdz_name,real_exec_date,remarks,s_gh,s_name,schedule_date,schedule_date_str,sflj,sp_id,status,update_date,xl_bm,xl_dir,xl_name,zdsj,zdsj_actual,zdz_code,zdz_name,ccno,df_auto,fgs_bm,fgs_name,gs_bm,gs_name,online,adjust_exps,reissue,jhlc_orig,sigin_compate,drift_status,cc_service,major_station_name,rfid_state,first_rfid_state)" + | |
| 451 | + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 452 | + @Override | |
| 453 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 454 | + ScheduleRealInfo sch = pstList.get(i); | |
| 455 | + ps.setLong(1, sch.getId()); | |
| 456 | + ps.setString(2, sch.getBcType()); | |
| 457 | + ps.setInt(3, sch.getBcs()==null?0:sch.getBcs()); | |
| 458 | + ps.setInt(4, sch.getBcsj()==null?0:sch.getBcsj()); | |
| 459 | + ps.setString(5, sch.getClZbh()); | |
| 460 | + ps.setTimestamp(6, new java.sql.Timestamp(sch.getCreateDate().getTime())); | |
| 461 | + ps.setString(7, sch.getDfsj()); | |
| 462 | + ps.setInt(8, sch.getDirectiveState()); | |
| 463 | + ps.setInt(9, sch.getFcno()==null?0:sch.getFcno()); | |
| 464 | + ps.setString(10, sch.getFcsj()); | |
| 465 | + ps.setString(11, sch.getFcsjActual()); | |
| 466 | + ps.setString(12, sch.getjGh()); | |
| 467 | + ps.setString(13, sch.getjName()); | |
| 468 | + ps.setDouble(14, sch.getJhlc()); | |
| 469 | + ps.setString(15, sch.getLpName()); | |
| 470 | + ps.setString(16, sch.getQdzCode()); | |
| 471 | + ps.setString(17, sch.getQdzName()); | |
| 472 | + ps.setString(18, sch.getRealExecDate()); | |
| 473 | + ps.setString(19, sch.getRemarks()); | |
| 474 | + ps.setString(20, sch.getsGh()); | |
| 475 | + ps.setString(21, sch.getsName()); | |
| 476 | + ps.setTimestamp(22, new java.sql.Timestamp(sch.getScheduleDate().getTime())); | |
| 477 | + ps.setString(23, sch.getScheduleDateStr()); | |
| 478 | + ps.setBoolean(24, sch.isSflj()); | |
| 479 | + ps.setLong(25, sch.getSpId()); | |
| 480 | + ps.setInt(26, sch.getStatus()); | |
| 481 | + ps.setTimestamp(27, new java.sql.Timestamp(sch.getUpdateDate().getTime())); | |
| 482 | + ps.setString(28, sch.getXlBm()); | |
| 483 | + ps.setString(29, sch.getXlDir()); | |
| 484 | + ps.setString(30, sch.getXlName()); | |
| 485 | + ps.setString(31, sch.getZdsj()); | |
| 486 | + ps.setString(32, sch.getZdsjActual()); | |
| 487 | + ps.setString(33, sch.getZdzCode()); | |
| 488 | + ps.setString(34, sch.getZdzName()); | |
| 489 | + ps.setInt(35, sch.getCcno()==null?0:sch.getCcno()); | |
| 490 | + ps.setBoolean(36, sch.isDfAuto()); | |
| 491 | + ps.setString(37, sch.getFgsBm()); | |
| 492 | + ps.setString(38, sch.getFgsName()); | |
| 493 | + ps.setString(39, sch.getGsBm()); | |
| 494 | + ps.setString(40, sch.getGsName()); | |
| 495 | + ps.setBoolean(41, sch.isOnline()); | |
| 496 | + ps.setString(42, sch.getAdjustExps()); | |
| 497 | + ps.setBoolean(43, sch.isReissue()); | |
| 498 | + ps.setDouble(44, sch.getJhlcOrig()); | |
| 499 | + ps.setInt(45, sch.getSiginCompate()); | |
| 500 | + ps.setInt(46, sch.getDriftStatus()); | |
| 501 | + ps.setBoolean(47, sch.isCcService()); | |
| 502 | + ps.setString(48, sch.getMajorStationName()); | |
| 503 | + ps.setInt(49, sch.getRfidState()); | |
| 504 | + ps.setInt(50, sch.getFirstRfidState()); | |
| 505 | + } | |
| 506 | + | |
| 507 | + @Override | |
| 508 | + public int getBatchSize() { | |
| 509 | + return pstList.size(); | |
| 510 | + } | |
| 511 | + }); | |
| 512 | + }catch (Exception e){ | |
| 513 | + status.setRollbackOnly(); | |
| 514 | + try { | |
| 515 | + logger.error(String.format("翻班实际排班数据批量保存异常: %s", mapper.writeValueAsString(list)), e); | |
| 516 | + } catch (JsonProcessingException jsonProcessingException) { | |
| 517 | + jsonProcessingException.printStackTrace(); | |
| 518 | + } | |
| 512 | 519 | } |
| 513 | - }); | |
| 514 | - | |
| 515 | - tran.commit(status); | |
| 516 | - }catch (Exception e){ | |
| 517 | - tran.rollback(status); | |
| 518 | - logger.error("real schedule batchSave error...", e); | |
| 519 | - } | |
| 520 | - // 入库 | |
| 521 | - //new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class); | |
| 520 | + } | |
| 521 | + }); | |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | public List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) { |
| ... | ... | @@ -993,6 +993,12 @@ public class DayOfSchedule { |
| 993 | 993 | @Autowired |
| 994 | 994 | JdbcTemplate jdbcTemplate; |
| 995 | 995 | |
| 996 | + @Autowired | |
| 997 | + private TransactionTemplate transactionTemplate; | |
| 998 | + | |
| 999 | + @Autowired | |
| 1000 | + private ObjectMapper mapper; | |
| 1001 | + | |
| 996 | 1002 | /** |
| 997 | 1003 | * 删除实际排班 |
| 998 | 1004 | * | ... | ... |
src/main/java/com/bsth/data/schedule/auto_exec/AutoExecScanThread.java
| 1 | -package com.bsth.data.schedule.auto_exec; | |
| 2 | - | |
| 3 | -import com.bsth.data.LineConfigData; | |
| 4 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 5 | -import com.bsth.entity.realcontrol.LineConfig; | |
| 6 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 7 | -import org.slf4j.Logger; | |
| 8 | -import org.slf4j.LoggerFactory; | |
| 9 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | - | |
| 12 | -import java.util.ArrayList; | |
| 13 | -import java.util.Collection; | |
| 14 | -import java.util.List; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * 班次自动执行扫描线程 | |
| 18 | - * Created by panzhao on 2017/10/31. | |
| 19 | - */ | |
| 20 | -@Component | |
| 21 | -public class AutoExecScanThread extends Thread{ | |
| 22 | - | |
| 23 | - | |
| 24 | - @Autowired | |
| 25 | - LineConfigData lineConfigData; | |
| 26 | - | |
| 27 | - @Autowired | |
| 28 | - DayOfSchedule dayOfSchedule; | |
| 29 | - | |
| 30 | - @Autowired | |
| 31 | - RealScheduleAutoExecHandler realScheduleAutoExecHandler; | |
| 32 | - | |
| 33 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public void run() { | |
| 37 | - try{ | |
| 38 | - //要自动执行的线路 | |
| 39 | - List<String> autos = new ArrayList<>(); | |
| 40 | - Collection<LineConfig> lcs = lineConfigData.getAll(); | |
| 41 | - | |
| 42 | - for(LineConfig config : lcs){ | |
| 43 | - if(config.isAutoExec()){ | |
| 44 | - autos.add(config.getLine().getLineCode()); | |
| 45 | - } | |
| 46 | - } | |
| 47 | - | |
| 48 | - if(autos.size()==0) | |
| 49 | - return; | |
| 50 | - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()); | |
| 51 | - for(ScheduleRealInfo sch : all){ | |
| 52 | - if(autos.contains(sch.getXlBm())){ | |
| 53 | - realScheduleAutoExecHandler.exec(sch); | |
| 54 | - } | |
| 55 | - } | |
| 56 | - }catch (Exception e){ | |
| 57 | - logger.error("", e); | |
| 58 | - } | |
| 59 | - } | |
| 60 | -} | |
| 1 | +package com.bsth.data.schedule.auto_exec; | |
| 2 | + | |
| 3 | +import com.bsth.data.LineConfigData; | |
| 4 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 5 | +import com.bsth.entity.realcontrol.LineConfig; | |
| 6 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 7 | +import org.slf4j.Logger; | |
| 8 | +import org.slf4j.LoggerFactory; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +import java.util.ArrayList; | |
| 13 | +import java.util.Collection; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * 班次自动执行扫描线程 | |
| 18 | + * Created by panzhao on 2017/10/31. | |
| 19 | + */ | |
| 20 | +@Component | |
| 21 | +public class AutoExecScanThread extends Thread{ | |
| 22 | + | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + LineConfigData lineConfigData; | |
| 26 | + | |
| 27 | + @Autowired | |
| 28 | + DayOfSchedule dayOfSchedule; | |
| 29 | + | |
| 30 | + @Autowired | |
| 31 | + RealScheduleAutoExecHandler realScheduleAutoExecHandler; | |
| 32 | + | |
| 33 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public void run() { | |
| 37 | + logger.warn("班次自动执行扫描开始"); | |
| 38 | + try{ | |
| 39 | + //要自动执行的线路 | |
| 40 | + List<String> autos = new ArrayList<>(); | |
| 41 | + Collection<LineConfig> lcs = lineConfigData.getAll(); | |
| 42 | + | |
| 43 | + for(LineConfig config : lcs){ | |
| 44 | + if(config.isAutoExec()){ | |
| 45 | + autos.add(config.getLine().getLineCode()); | |
| 46 | + } | |
| 47 | + } | |
| 48 | + | |
| 49 | + if(autos.size()==0) | |
| 50 | + return; | |
| 51 | + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()); | |
| 52 | + for(ScheduleRealInfo sch : all){ | |
| 53 | + if(autos.contains(sch.getXlBm())){ | |
| 54 | + realScheduleAutoExecHandler.exec(sch); | |
| 55 | + } | |
| 56 | + } | |
| 57 | + }catch (Exception e){ | |
| 58 | + logger.error("", e); | |
| 59 | + } | |
| 60 | + logger.warn("班次自动执行扫描结束"); | |
| 61 | + } | |
| 62 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/e_state_check/thread/FixedCheckStationCodeThread.java
| 1 | -package com.bsth.data.schedule.e_state_check.thread; | |
| 2 | - | |
| 3 | -import com.bsth.data.schedule.e_state_check.ScheduleStationCodeChecker; | |
| 4 | -import org.slf4j.Logger; | |
| 5 | -import org.slf4j.LoggerFactory; | |
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | -import org.springframework.stereotype.Component; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 定时检查班次站点编码线程 | |
| 11 | - * Created by panzhao on 2018/4/2. | |
| 12 | - */ | |
| 13 | -@Component | |
| 14 | -public class FixedCheckStationCodeThread extends Thread { | |
| 15 | - | |
| 16 | - @Autowired | |
| 17 | - ScheduleStationCodeChecker scheduleStationCodeChecker; | |
| 18 | - | |
| 19 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 20 | - | |
| 21 | - @Override | |
| 22 | - public void run() { | |
| 23 | - try { | |
| 24 | - scheduleStationCodeChecker.checkAll(); | |
| 25 | - } catch (Exception e) { | |
| 26 | - logger.error("", e); | |
| 27 | - } | |
| 28 | - } | |
| 29 | -} | |
| 1 | +package com.bsth.data.schedule.e_state_check.thread; | |
| 2 | + | |
| 3 | +import com.bsth.data.schedule.e_state_check.ScheduleStationCodeChecker; | |
| 4 | +import org.slf4j.Logger; | |
| 5 | +import org.slf4j.LoggerFactory; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 定时检查班次站点编码线程 | |
| 11 | + * Created by panzhao on 2018/4/2. | |
| 12 | + */ | |
| 13 | +@Component | |
| 14 | +public class FixedCheckStationCodeThread extends Thread { | |
| 15 | + | |
| 16 | + @Autowired | |
| 17 | + ScheduleStationCodeChecker scheduleStationCodeChecker; | |
| 18 | + | |
| 19 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 20 | + | |
| 21 | + @Override | |
| 22 | + public void run() { | |
| 23 | + logger.warn("班次站点编码检查开始"); | |
| 24 | + try { | |
| 25 | + scheduleStationCodeChecker.checkAll(); | |
| 26 | + } catch (Exception e) { | |
| 27 | + logger.error("", e); | |
| 28 | + } | |
| 29 | + logger.warn("班次站点编码检查结束"); | |
| 30 | + } | |
| 31 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/edit_logs/SeiPstThread.java
| ... | ... | @@ -28,6 +28,7 @@ public class SeiPstThread extends Thread{ |
| 28 | 28 | |
| 29 | 29 | @Override |
| 30 | 30 | public void run() { |
| 31 | + log.warn("班次修正日志保存开始"); | |
| 31 | 32 | try{ |
| 32 | 33 | List<SchEditInfo> pstList = new ArrayList<>(); |
| 33 | 34 | LinkedList<SchEditInfo> list = ScheduleModifyLogger.list; |
| ... | ... | @@ -48,5 +49,6 @@ public class SeiPstThread extends Thread{ |
| 48 | 49 | }catch (Exception e){ |
| 49 | 50 | log.error("", e); |
| 50 | 51 | } |
| 52 | + log.warn("班次修正日志保存结束"); | |
| 51 | 53 | } |
| 52 | 54 | } |
| 53 | 55 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
| 1 | - | |
| 2 | -package com.bsth.data.schedule.late_adjust; | |
| 3 | - | |
| 4 | -import com.bsth.data.LineConfigData; | |
| 5 | -import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 6 | -import com.bsth.entity.realcontrol.LineConfig; | |
| 7 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | -import com.bsth.util.Arith; | |
| 9 | -import com.bsth.websocket.handler.SendUtils; | |
| 10 | -import org.slf4j.Logger; | |
| 11 | -import org.slf4j.LoggerFactory; | |
| 12 | -import org.springframework.beans.BeansException; | |
| 13 | -import org.springframework.context.ApplicationContext; | |
| 14 | -import org.springframework.context.ApplicationContextAware; | |
| 15 | -import org.springframework.stereotype.Component; | |
| 16 | - | |
| 17 | -import java.util.Collection; | |
| 18 | -import java.util.concurrent.ConcurrentHashMap; | |
| 19 | -import java.util.concurrent.ConcurrentMap; | |
| 20 | - | |
| 21 | -/** | |
| 22 | - * 误点自动调整待发 处理程序 | |
| 23 | - * <p> | |
| 24 | - * 注意 :这里的误点是指应发未到 | |
| 25 | - * Created by panzhao on 2017/4/16. | |
| 26 | - */ | |
| 27 | -@Component | |
| 28 | -public class LateAdjustHandle implements ApplicationContextAware { | |
| 29 | - | |
| 30 | - static LineConfigData lineConfigData; | |
| 31 | - static SendUtils sendUtils; | |
| 32 | - | |
| 33 | - static Logger logger = LoggerFactory.getLogger(LateAdjustHandle.class); | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * 应发未到的班次 key : id | |
| 37 | - */ | |
| 38 | - private static ConcurrentMap<Long, ScheduleRealInfo> lateSchMap = new ConcurrentHashMap<>(); | |
| 39 | - | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * 新增一个误点班次 | |
| 43 | - * | |
| 44 | - * @param sch | |
| 45 | - */ | |
| 46 | - public static void putLate(ScheduleRealInfo sch) { | |
| 47 | - try { | |
| 48 | - //线路配置 | |
| 49 | - LineConfig config = lineConfigData.get(sch.getXlBm()); | |
| 50 | - if (sch.getLateMinute() == 0) { | |
| 51 | - if (!config.isEnableYjtk()) | |
| 52 | - return; | |
| 53 | - | |
| 54 | - sch.setLateMinute(sch.getXlDir().equals("0") ? config.getUpStopMinute() : config.getDownStopMinute()); | |
| 55 | - } | |
| 56 | - | |
| 57 | - if (sch.getDfsj().compareTo(config.getYjtkStart()) > 0 | |
| 58 | - && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0) { | |
| 59 | - | |
| 60 | - //班次压入 | |
| 61 | - if (!lateSchMap.containsKey(sch.getId())) { | |
| 62 | - logger.info("29【应发未到 班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); | |
| 63 | - | |
| 64 | - sch.setLate2(true); | |
| 65 | - lateSchMap.put(sch.getId(), sch); | |
| 66 | - //通知客户端 | |
| 67 | - sendUtils.sendAutoWdtz(sch, null); | |
| 68 | - } | |
| 69 | - } | |
| 70 | - | |
| 71 | - } catch (Exception e) { | |
| 72 | - logger.error("", e); | |
| 73 | - } | |
| 74 | - } | |
| 75 | - | |
| 76 | - | |
| 77 | - /** | |
| 78 | - * 获取所有应发未到的班次 | |
| 79 | - * | |
| 80 | - * @return | |
| 81 | - */ | |
| 82 | - public static Collection<ScheduleRealInfo> allLateSch() { | |
| 83 | - return lateSchMap.values(); | |
| 84 | - } | |
| 85 | - | |
| 86 | - public static void remove(ScheduleRealInfo sch) { | |
| 87 | - try { | |
| 88 | - if (lateSchMap.containsKey(sch.getId())) { | |
| 89 | - lateSchMap.remove(sch.getId()); | |
| 90 | - | |
| 91 | - sch.setLate2(false); | |
| 92 | - sch.setLateMinute(0); | |
| 93 | - sch.setDfAuto(false); | |
| 94 | - | |
| 95 | - logger.info("移除误点调整 -" + sch.getClZbh() + " -time: " + sch.getDfsj() + " -id: " + sch.getId()); | |
| 96 | - } | |
| 97 | - } catch (Exception e) { | |
| 98 | - logger.error("", e); | |
| 99 | - } | |
| 100 | - } | |
| 101 | - | |
| 102 | - /** | |
| 103 | - * 车辆到站 进站 进 的哪个班次,就调该车辆的下一个班次 | |
| 104 | - * | |
| 105 | - * @param gps | |
| 106 | - */ | |
| 107 | - public static void carArrive(GpsEntity gps, ScheduleRealInfo sch) { | |
| 108 | - try { | |
| 109 | - if (gps.getInstation() <= 0 || null == sch) | |
| 110 | - return; | |
| 111 | - | |
| 112 | - if (!lateSchMap.containsKey(sch.getId())) { | |
| 113 | - //班次是否误点(可能处于误点线程扫描的空隙,所以再判定一次) | |
| 114 | - if (sch.getDfsjT() <= gps.getTimestamp()) { | |
| 115 | - putLate(sch); | |
| 116 | - | |
| 117 | - if (!lateSchMap.containsKey(sch.getId())) | |
| 118 | - return; | |
| 119 | - | |
| 120 | - logger.info("线程空隙漏掉的误点,id: " + sch.getId()); | |
| 121 | - } else | |
| 122 | - return; | |
| 123 | - } | |
| 124 | - | |
| 125 | - | |
| 126 | - //可能是延迟信号,gps时间没有误点 | |
| 127 | - if (gps.getTimestamp() <= sch.getDfsjT()) { | |
| 128 | - sch.setLate2(false); | |
| 129 | - lateSchMap.remove(sch.getId()); | |
| 130 | - return; | |
| 131 | - } | |
| 132 | - | |
| 133 | - | |
| 134 | - //自动调整待发 到达时间 + 停靠时间 | |
| 135 | - long dt = Arith.addLong(gps.getTimestamp(), (sch.getLateMinute() * 60 * 1000)); | |
| 136 | - | |
| 137 | - sch.setDfsjAll(dt); | |
| 138 | - sch.setDfAuto(true); | |
| 139 | - //取消应发未到标记 | |
| 140 | - sch.setLate2(false); | |
| 141 | - | |
| 142 | - lateSchMap.remove(sch.getId()); | |
| 143 | - logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt + " -id:" + sch.getId()); | |
| 144 | - } catch (Exception e) { | |
| 145 | - e.printStackTrace(); | |
| 146 | - logger.error("late2 car arrive", e); | |
| 147 | - } | |
| 148 | - } | |
| 149 | - | |
| 150 | - | |
| 151 | - @Override | |
| 152 | - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
| 153 | - lineConfigData = applicationContext.getBean(LineConfigData.class); | |
| 154 | - sendUtils = applicationContext.getBean(SendUtils.class); | |
| 155 | - } | |
| 1 | + | |
| 2 | +package com.bsth.data.schedule.late_adjust; | |
| 3 | + | |
| 4 | +import com.bsth.data.LineConfigData; | |
| 5 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 6 | +import com.bsth.entity.realcontrol.LineConfig; | |
| 7 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | +import com.bsth.util.Arith; | |
| 9 | +import com.bsth.websocket.handler.SendUtils; | |
| 10 | +import org.slf4j.Logger; | |
| 11 | +import org.slf4j.LoggerFactory; | |
| 12 | +import org.springframework.beans.BeansException; | |
| 13 | +import org.springframework.context.ApplicationContext; | |
| 14 | +import org.springframework.context.ApplicationContextAware; | |
| 15 | +import org.springframework.stereotype.Component; | |
| 16 | + | |
| 17 | +import java.util.Collection; | |
| 18 | +import java.util.concurrent.ConcurrentHashMap; | |
| 19 | +import java.util.concurrent.ConcurrentMap; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * 误点自动调整待发 处理程序 | |
| 23 | + * <p> | |
| 24 | + * 注意 :这里的误点是指应发未到 | |
| 25 | + * Created by panzhao on 2017/4/16. | |
| 26 | + */ | |
| 27 | +@Component | |
| 28 | +public class LateAdjustHandle implements ApplicationContextAware { | |
| 29 | + | |
| 30 | + static LineConfigData lineConfigData; | |
| 31 | + static SendUtils sendUtils; | |
| 32 | + | |
| 33 | + static Logger logger = LoggerFactory.getLogger(LateAdjustHandle.class); | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 应发未到的班次 key : id | |
| 37 | + */ | |
| 38 | + private static ConcurrentMap<Long, ScheduleRealInfo> lateSchMap = new ConcurrentHashMap<>(); | |
| 39 | + | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 新增一个误点班次 | |
| 43 | + * | |
| 44 | + * @param sch | |
| 45 | + */ | |
| 46 | + public static void putLate(ScheduleRealInfo sch) { | |
| 47 | + try { | |
| 48 | + //线路配置 | |
| 49 | + LineConfig config = lineConfigData.get(sch.getXlBm()); | |
| 50 | + if (sch.getLateMinute() == 0) { | |
| 51 | + if (!config.isEnableYjtk()) | |
| 52 | + return; | |
| 53 | + | |
| 54 | + sch.setLateMinute(sch.getXlDir().equals("0") ? config.getUpStopMinute() : config.getDownStopMinute()); | |
| 55 | + } | |
| 56 | + | |
| 57 | + if (sch.getDfsj().compareTo(config.getYjtkStart()) > 0 | |
| 58 | + && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0) { | |
| 59 | + | |
| 60 | + //班次压入 | |
| 61 | + if (!lateSchMap.containsKey(sch.getId())) { | |
| 62 | + logger.info("【应发未到】 班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); | |
| 63 | + | |
| 64 | + sch.setLate2(true); | |
| 65 | + lateSchMap.put(sch.getId(), sch); | |
| 66 | + //通知客户端 | |
| 67 | + sendUtils.sendAutoWdtz(sch, null); | |
| 68 | + } | |
| 69 | + } | |
| 70 | + | |
| 71 | + } catch (Exception e) { | |
| 72 | + logger.error("", e); | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * 获取所有应发未到的班次 | |
| 79 | + * | |
| 80 | + * @return | |
| 81 | + */ | |
| 82 | + public static Collection<ScheduleRealInfo> allLateSch() { | |
| 83 | + return lateSchMap.values(); | |
| 84 | + } | |
| 85 | + | |
| 86 | + public static void remove(ScheduleRealInfo sch) { | |
| 87 | + try { | |
| 88 | + if (lateSchMap.containsKey(sch.getId())) { | |
| 89 | + lateSchMap.remove(sch.getId()); | |
| 90 | + | |
| 91 | + sch.setLate2(false); | |
| 92 | + sch.setLateMinute(0); | |
| 93 | + sch.setDfAuto(false); | |
| 94 | + | |
| 95 | + logger.info("移除误点调整 -" + sch.getClZbh() + " -time: " + sch.getDfsj() + " -id: " + sch.getId()); | |
| 96 | + } | |
| 97 | + } catch (Exception e) { | |
| 98 | + logger.error("", e); | |
| 99 | + } | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * 车辆到站 进站 进 的哪个班次,就调该车辆的下一个班次 | |
| 104 | + * | |
| 105 | + * @param gps | |
| 106 | + */ | |
| 107 | + public static void carArrive(GpsEntity gps, ScheduleRealInfo sch) { | |
| 108 | + try { | |
| 109 | + if (gps.getInstation() <= 0 || null == sch) | |
| 110 | + return; | |
| 111 | + | |
| 112 | + if (!lateSchMap.containsKey(sch.getId())) { | |
| 113 | + //班次是否误点(可能处于误点线程扫描的空隙,所以再判定一次) | |
| 114 | + if (sch.getDfsjT() <= gps.getTimestamp()) { | |
| 115 | + putLate(sch); | |
| 116 | + | |
| 117 | + if (!lateSchMap.containsKey(sch.getId())) | |
| 118 | + return; | |
| 119 | + | |
| 120 | + logger.info("线程空隙漏掉的误点,id: " + sch.getId()); | |
| 121 | + } else | |
| 122 | + return; | |
| 123 | + } | |
| 124 | + | |
| 125 | + | |
| 126 | + //可能是延迟信号,gps时间没有误点 | |
| 127 | + if (gps.getTimestamp() <= sch.getDfsjT()) { | |
| 128 | + sch.setLate2(false); | |
| 129 | + lateSchMap.remove(sch.getId()); | |
| 130 | + return; | |
| 131 | + } | |
| 132 | + | |
| 133 | + | |
| 134 | + //自动调整待发 到达时间 + 停靠时间 | |
| 135 | + long dt = Arith.addLong(gps.getTimestamp(), (sch.getLateMinute() * 60 * 1000)); | |
| 136 | + | |
| 137 | + sch.setDfsjAll(dt); | |
| 138 | + sch.setDfAuto(true); | |
| 139 | + //取消应发未到标记 | |
| 140 | + sch.setLate2(false); | |
| 141 | + | |
| 142 | + lateSchMap.remove(sch.getId()); | |
| 143 | + logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt + " -id:" + sch.getId()); | |
| 144 | + } catch (Exception e) { | |
| 145 | + e.printStackTrace(); | |
| 146 | + logger.error("late2 car arrive", e); | |
| 147 | + } | |
| 148 | + } | |
| 149 | + | |
| 150 | + | |
| 151 | + @Override | |
| 152 | + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
| 153 | + lineConfigData = applicationContext.getBean(LineConfigData.class); | |
| 154 | + sendUtils = applicationContext.getBean(SendUtils.class); | |
| 155 | + } | |
| 156 | 156 | } |
| 157 | 157 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/schedule/late_adjust/ScheduleLateThread.java
| 1 | -package com.bsth.data.schedule.late_adjust; | |
| 2 | - | |
| 3 | - | |
| 4 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 5 | -import com.bsth.data.schedule.ScheduleComparator; | |
| 6 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 7 | -import com.bsth.websocket.handler.SendUtils; | |
| 8 | -import org.apache.commons.lang3.StringUtils; | |
| 9 | -import org.slf4j.Logger; | |
| 10 | -import org.slf4j.LoggerFactory; | |
| 11 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | -import org.springframework.stereotype.Component; | |
| 13 | - | |
| 14 | -import java.util.ArrayList; | |
| 15 | -import java.util.Collections; | |
| 16 | -import java.util.Comparator; | |
| 17 | -import java.util.List; | |
| 18 | - | |
| 19 | -/** | |
| 20 | - * | |
| 21 | - * @ClassName: ScheduleLateThread | |
| 22 | - * @Description: TODO(班次误点扫描线程) | |
| 23 | - * @author PanZhao | |
| 24 | - * @date 2016年8月31日 下午3:09:02 | |
| 25 | - * | |
| 26 | - */ | |
| 27 | -@Component | |
| 28 | -public class ScheduleLateThread extends Thread{ | |
| 29 | - | |
| 30 | - @Autowired | |
| 31 | - DayOfSchedule dayOfSchedule; | |
| 32 | - | |
| 33 | - @Autowired | |
| 34 | - SendUtils sendUtils; | |
| 35 | - | |
| 36 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 37 | - | |
| 38 | - private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.DFSJ2(); | |
| 39 | - | |
| 40 | - @Override | |
| 41 | - public void run() { | |
| 42 | - try{ | |
| 43 | - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()); | |
| 44 | - Collections.sort(all, cpm); | |
| 45 | - | |
| 46 | - long t = System.currentTimeMillis(); | |
| 47 | - int size = all.size(); | |
| 48 | - | |
| 49 | - ScheduleRealInfo sch; | |
| 50 | - for(int i = 0; i < size; i ++){ | |
| 51 | - sch = all.get(i); | |
| 52 | - if(sch.getDfsjT() > t) | |
| 53 | - break; | |
| 54 | - | |
| 55 | - if(sch.isLate()) | |
| 56 | - continue; | |
| 57 | - | |
| 58 | - if(sch.getStatus() == 0 | |
| 59 | - && StringUtils.isEmpty(sch.getFcsjActual())){ | |
| 60 | - | |
| 61 | - //检查应发未到 当前班次无起点到达时间 | |
| 62 | - if(StringUtils.isEmpty(sch.getQdzArrDatesj())){ | |
| 63 | - ScheduleRealInfo prev = dayOfSchedule.prev(sch); | |
| 64 | - //上一个班次也没有实际终点到达时间 | |
| 65 | - if(prev != null && StringUtils.isEmpty(prev.getZdsjActual())){ | |
| 66 | - //进入误点调整程序 | |
| 67 | - LateAdjustHandle.putLate(sch); | |
| 68 | - } | |
| 69 | - } | |
| 70 | - | |
| 71 | - //应发未发 | |
| 72 | - sch.setLate(true); | |
| 73 | - //通知客户端 | |
| 74 | - sendUtils.refreshSch(sch); | |
| 75 | - } | |
| 76 | - } | |
| 77 | - }catch (Exception e){ | |
| 78 | - logger.error("", e); | |
| 79 | - } | |
| 80 | - } | |
| 1 | +package com.bsth.data.schedule.late_adjust; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 5 | +import com.bsth.data.schedule.ScheduleComparator; | |
| 6 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 7 | +import com.bsth.websocket.handler.SendUtils; | |
| 8 | +import org.apache.commons.lang3.StringUtils; | |
| 9 | +import org.slf4j.Logger; | |
| 10 | +import org.slf4j.LoggerFactory; | |
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | +import org.springframework.stereotype.Component; | |
| 13 | + | |
| 14 | +import java.util.ArrayList; | |
| 15 | +import java.util.Collections; | |
| 16 | +import java.util.Comparator; | |
| 17 | +import java.util.List; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * | |
| 21 | + * @ClassName: ScheduleLateThread | |
| 22 | + * @Description: TODO(班次误点扫描线程) | |
| 23 | + * @author PanZhao | |
| 24 | + * @date 2016年8月31日 下午3:09:02 | |
| 25 | + * | |
| 26 | + */ | |
| 27 | +@Component | |
| 28 | +public class ScheduleLateThread extends Thread{ | |
| 29 | + | |
| 30 | + @Autowired | |
| 31 | + DayOfSchedule dayOfSchedule; | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + SendUtils sendUtils; | |
| 35 | + | |
| 36 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 37 | + | |
| 38 | + private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.DFSJ2(); | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public void run() { | |
| 42 | + logger.warn("班次误点扫描开始"); | |
| 43 | + try{ | |
| 44 | + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()); | |
| 45 | + Collections.sort(all, cpm); | |
| 46 | + | |
| 47 | + long t = System.currentTimeMillis(); | |
| 48 | + int size = all.size(); | |
| 49 | + | |
| 50 | + ScheduleRealInfo sch; | |
| 51 | + for(int i = 0; i < size; i ++){ | |
| 52 | + sch = all.get(i); | |
| 53 | + if(sch.getDfsjT() > t) | |
| 54 | + break; | |
| 55 | + | |
| 56 | + if(sch.isLate()) | |
| 57 | + continue; | |
| 58 | + | |
| 59 | + if(sch.getStatus() == 0 | |
| 60 | + && StringUtils.isEmpty(sch.getFcsjActual())){ | |
| 61 | + | |
| 62 | + //检查应发未到 当前班次无起点到达时间 | |
| 63 | + if(StringUtils.isEmpty(sch.getQdzArrDatesj())){ | |
| 64 | + ScheduleRealInfo prev = dayOfSchedule.prev(sch); | |
| 65 | + //上一个班次也没有实际终点到达时间 | |
| 66 | + if(prev != null && StringUtils.isEmpty(prev.getZdsjActual())){ | |
| 67 | + //进入误点调整程序 | |
| 68 | + LateAdjustHandle.putLate(sch); | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + //应发未发 | |
| 73 | + sch.setLate(true); | |
| 74 | + //通知客户端 | |
| 75 | + sendUtils.refreshSch(sch); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + }catch (Exception e){ | |
| 79 | + logger.error("", e); | |
| 80 | + } | |
| 81 | + logger.warn("班次误点扫描结束"); | |
| 82 | + } | |
| 81 | 83 | } |
| 82 | 84 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
| ... | ... | @@ -54,7 +54,7 @@ public class SchedulePstThread extends Thread { |
| 54 | 54 | |
| 55 | 55 | @Override |
| 56 | 56 | public void run() { |
| 57 | - | |
| 57 | + logger.warn("班次批量保存开始"); | |
| 58 | 58 | try{ |
| 59 | 59 | ScheduleRealInfo schedule; |
| 60 | 60 | for (int i = 0; i < 500; i++) { |
| ... | ... | @@ -75,6 +75,7 @@ public class SchedulePstThread extends Thread { |
| 75 | 75 | }catch (Exception e){ |
| 76 | 76 | logger.error("", e); |
| 77 | 77 | } |
| 78 | + logger.warn("班次批量保存结束"); | |
| 78 | 79 | } |
| 79 | 80 | |
| 80 | 81 | private void save(){ | ... | ... |
src/main/java/com/bsth/data/schedule/thread/ScheduleRefreshThread.java
| 1 | -package com.bsth.data.schedule.thread; | |
| 2 | - | |
| 3 | -import com.bsth.data.LineConfigData; | |
| 4 | -import com.bsth.data.directive.DayOfDirectives; | |
| 5 | -import com.bsth.data.gpsdata_v2.cache.GpsCacheData; | |
| 6 | -import com.bsth.data.pilot80.PilotReport; | |
| 7 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 8 | -import com.bsth.data.schedule.f_a_l.FirstAndLastHandler; | |
| 9 | -import com.bsth.entity.realcontrol.LineConfig; | |
| 10 | -import org.slf4j.Logger; | |
| 11 | -import org.slf4j.LoggerFactory; | |
| 12 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | -import org.springframework.stereotype.Component; | |
| 14 | - | |
| 15 | -import java.util.Collection; | |
| 16 | -import java.util.Set; | |
| 17 | - | |
| 18 | -/** | |
| 19 | - * | |
| 20 | - * @ClassName: ScheduleRefreshThread | |
| 21 | - * @Description: TODO(班次刷新线程,用于在营运开始时间切换到当日排班) | |
| 22 | - * @author PanZhao | |
| 23 | - * @date 2016年8月17日 下午1:23:34 | |
| 24 | - * | |
| 25 | - */ | |
| 26 | -@Component | |
| 27 | -public class ScheduleRefreshThread extends Thread{ | |
| 28 | - | |
| 29 | - @Autowired | |
| 30 | - DayOfSchedule dayOfSchedule; | |
| 31 | - | |
| 32 | - @Autowired | |
| 33 | - LineConfigData lineConfs; | |
| 34 | - | |
| 35 | - @Autowired | |
| 36 | - DayOfDirectives dayOfDirectives; | |
| 37 | - | |
| 38 | - @Autowired | |
| 39 | - PilotReport pilotReport; | |
| 40 | - | |
| 41 | - Logger logger = LoggerFactory.getLogger(ScheduleRefreshThread.class); | |
| 42 | - | |
| 43 | - @Override | |
| 44 | - public void run() { | |
| 45 | - try { | |
| 46 | - Collection<LineConfig> confs = lineConfs.getAll(); | |
| 47 | - | |
| 48 | - String currSchDate, oldSchDate; | |
| 49 | - String lineCode = null; | |
| 50 | - for(LineConfig conf : confs){ | |
| 51 | - try{ | |
| 52 | - lineCode = conf.getLine().getLineCode(); | |
| 53 | - oldSchDate = dayOfSchedule.getCurrSchDate().get(lineCode); | |
| 54 | - currSchDate = dayOfSchedule.calcSchDate(lineCode); | |
| 55 | - | |
| 56 | - if(oldSchDate == null || !oldSchDate.equals(currSchDate)){ | |
| 57 | - | |
| 58 | - try{ | |
| 59 | - Set<String> cars = dayOfSchedule.findCarByLineCode(lineCode); | |
| 60 | - for(String car : cars){ | |
| 61 | - GpsCacheData.remove(car); | |
| 62 | - dayOfSchedule.resetRepairReport(car); | |
| 63 | - } | |
| 64 | - //清除驾驶员上报数据 | |
| 65 | - pilotReport.clear(lineCode); | |
| 66 | - //清除指令数据 指令数据,直接定时全部清空 | |
| 67 | - //dayOfDirectives.clear(lineCode); | |
| 68 | - }catch (Exception e){ | |
| 69 | - logger.error("清理 60 和 80出现问题", e); | |
| 70 | - } | |
| 71 | - | |
| 72 | - //重载排班数据 | |
| 73 | - dayOfSchedule.reloadSch(lineCode, currSchDate, false); | |
| 74 | - logger.info(lineCode + "翻班完成, " + currSchDate + " -班次数量:" + dayOfSchedule.findByLineCode(lineCode).size()); | |
| 75 | - } | |
| 76 | - }catch (Exception e){ | |
| 77 | - logger.error("班次更新失败!! -" + lineCode, e); | |
| 78 | - } | |
| 79 | - } | |
| 80 | - | |
| 81 | - //按公司编码索引数据 | |
| 82 | - dayOfSchedule.groupByGsbm(); | |
| 83 | - | |
| 84 | - //首末班入库(给网关用的数据) | |
| 85 | - FirstAndLastHandler.saveAll(); | |
| 86 | - } catch (Exception e) { | |
| 87 | - logger.error("", e); | |
| 88 | - } | |
| 89 | - } | |
| 90 | -} | |
| 1 | +package com.bsth.data.schedule.thread; | |
| 2 | + | |
| 3 | +import com.bsth.data.LineConfigData; | |
| 4 | +import com.bsth.data.directive.DayOfDirectives; | |
| 5 | +import com.bsth.data.gpsdata_v2.cache.GpsCacheData; | |
| 6 | +import com.bsth.data.pilot80.PilotReport; | |
| 7 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 8 | +import com.bsth.data.schedule.f_a_l.FirstAndLastHandler; | |
| 9 | +import com.bsth.entity.realcontrol.LineConfig; | |
| 10 | +import org.slf4j.Logger; | |
| 11 | +import org.slf4j.LoggerFactory; | |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | +import org.springframework.stereotype.Component; | |
| 14 | + | |
| 15 | +import java.util.Collection; | |
| 16 | +import java.util.Set; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * | |
| 20 | + * @ClassName: ScheduleRefreshThread | |
| 21 | + * @Description: TODO(班次刷新线程,用于在营运开始时间切换到当日排班) | |
| 22 | + * @author PanZhao | |
| 23 | + * @date 2016年8月17日 下午1:23:34 | |
| 24 | + * | |
| 25 | + */ | |
| 26 | +@Component | |
| 27 | +public class ScheduleRefreshThread extends Thread{ | |
| 28 | + | |
| 29 | + @Autowired | |
| 30 | + DayOfSchedule dayOfSchedule; | |
| 31 | + | |
| 32 | + @Autowired | |
| 33 | + LineConfigData lineConfs; | |
| 34 | + | |
| 35 | + @Autowired | |
| 36 | + DayOfDirectives dayOfDirectives; | |
| 37 | + | |
| 38 | + @Autowired | |
| 39 | + PilotReport pilotReport; | |
| 40 | + | |
| 41 | + Logger logger = LoggerFactory.getLogger(ScheduleRefreshThread.class); | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void run() { | |
| 45 | + logger.warn("班次刷新开始"); | |
| 46 | + try { | |
| 47 | + Collection<LineConfig> confs = lineConfs.getAll(); | |
| 48 | + | |
| 49 | + String currSchDate, oldSchDate; | |
| 50 | + String lineCode = null; | |
| 51 | + for(LineConfig conf : confs){ | |
| 52 | + try{ | |
| 53 | + lineCode = conf.getLine().getLineCode(); | |
| 54 | + oldSchDate = dayOfSchedule.getCurrSchDate().get(lineCode); | |
| 55 | + currSchDate = dayOfSchedule.calcSchDate(lineCode); | |
| 56 | + | |
| 57 | + if(oldSchDate == null || !oldSchDate.equals(currSchDate)){ | |
| 58 | + | |
| 59 | + try{ | |
| 60 | + Set<String> cars = dayOfSchedule.findCarByLineCode(lineCode); | |
| 61 | + for(String car : cars){ | |
| 62 | + GpsCacheData.remove(car); | |
| 63 | + dayOfSchedule.resetRepairReport(car); | |
| 64 | + } | |
| 65 | + //清除驾驶员上报数据 | |
| 66 | + pilotReport.clear(lineCode); | |
| 67 | + //清除指令数据 指令数据,直接定时全部清空 | |
| 68 | + //dayOfDirectives.clear(lineCode); | |
| 69 | + }catch (Exception e){ | |
| 70 | + logger.error("清理 60 和 80出现问题", e); | |
| 71 | + } | |
| 72 | + | |
| 73 | + //重载排班数据 | |
| 74 | + dayOfSchedule.reloadSch(lineCode, currSchDate, false); | |
| 75 | + logger.info(lineCode + "翻班完成, " + currSchDate + " -班次数量:" + dayOfSchedule.findByLineCode(lineCode).size()); | |
| 76 | + } | |
| 77 | + }catch (Exception e){ | |
| 78 | + logger.error("班次更新失败!! -" + lineCode, e); | |
| 79 | + } | |
| 80 | + } | |
| 81 | + | |
| 82 | + //按公司编码索引数据 | |
| 83 | + dayOfSchedule.groupByGsbm(); | |
| 84 | + | |
| 85 | + //首末班入库(给网关用的数据) | |
| 86 | + FirstAndLastHandler.saveAll(); | |
| 87 | + } catch (Exception e) { | |
| 88 | + logger.error("", e); | |
| 89 | + } | |
| 90 | + logger.warn("班次刷新结束"); | |
| 91 | + } | |
| 92 | +} | ... | ... |
src/main/java/com/bsth/message/buffer/CarEnergyBuffer.java
0 → 100644
| 1 | +package com.bsth.message.buffer; | |
| 2 | + | |
| 3 | +import com.bsth.message.entity.CarEnergy; | |
| 4 | + | |
| 5 | +import java.util.Map; | |
| 6 | +import java.util.concurrent.ConcurrentHashMap; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * @author Hill | |
| 10 | + */ | |
| 11 | +public class CarEnergyBuffer { | |
| 12 | + | |
| 13 | + private static Map<String, CarEnergy> code2energy = new ConcurrentHashMap<>(); | |
| 14 | + | |
| 15 | + public static void put(CarEnergy carEnergy) { | |
| 16 | + code2energy.put(carEnergy.getNbbm(), carEnergy); | |
| 17 | + } | |
| 18 | + | |
| 19 | + public static int getCarEnergy(String carCode) { | |
| 20 | + CarEnergy carEnergy = code2energy.get(carCode); | |
| 21 | + | |
| 22 | + return carEnergy == null ? -1 : (int) (carEnergy.getEnergy() * 100); | |
| 23 | + } | |
| 24 | +} | ... | ... |
src/main/java/com/bsth/message/entity/CarEnergy.java
0 → 100644
| 1 | +package com.bsth.message.entity; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
| 4 | +import com.fasterxml.jackson.annotation.JsonProperty; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * @author Hill | |
| 8 | + */ | |
| 9 | +@JsonIgnoreProperties(ignoreUnknown = true) | |
| 10 | +public class CarEnergy { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * 车辆内部编码 | |
| 14 | + */ | |
| 15 | + @JsonProperty("carCode") | |
| 16 | + private String nbbm; | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 剩余电量 | |
| 20 | + */ | |
| 21 | + private double energy; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 最后更新时间戳 | |
| 25 | + */ | |
| 26 | + private long updateTimestamp; | |
| 27 | + | |
| 28 | + public String getNbbm() { | |
| 29 | + return nbbm; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public void setNbbm(String nbbm) { | |
| 33 | + this.nbbm = nbbm; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public double getEnergy() { | |
| 37 | + return energy; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void setEnergy(double energy) { | |
| 41 | + this.energy = energy; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public long getUpdateTimestamp() { | |
| 45 | + return updateTimestamp; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public void setUpdateTimestamp(long updateTimestamp) { | |
| 49 | + this.updateTimestamp = updateTimestamp; | |
| 50 | + } | |
| 51 | +} | ... | ... |
src/main/java/com/bsth/message/entity/CarErrorStop.java
0 → 100644
| 1 | +package com.bsth.message.entity; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 企业信息化运行监控中心 | |
| 7 | + * 车辆异常停车(理论上超过5分钟) | |
| 8 | + * @author Hill | |
| 9 | + */ | |
| 10 | +@JsonIgnoreProperties(ignoreUnknown = true) | |
| 11 | +public class CarErrorStop { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * ID | |
| 15 | + */ | |
| 16 | + private int id; | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 日期 | |
| 20 | + */ | |
| 21 | + private String rq; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 公司编码 | |
| 25 | + */ | |
| 26 | + private String company; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 分公司名称 | |
| 30 | + */ | |
| 31 | + private String branchCompany; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 线路名称 | |
| 35 | + */ | |
| 36 | + private String line; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 线路代码 | |
| 40 | + */ | |
| 41 | + private String lineId; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 车辆内部编码 | |
| 45 | + */ | |
| 46 | + private String nbbm; | |
| 47 | + | |
| 48 | + private String carCode; | |
| 49 | + | |
| 50 | + private String driver; | |
| 51 | + | |
| 52 | + private double lat; | |
| 53 | + | |
| 54 | + private double lon; | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 发生地址 | |
| 58 | + */ | |
| 59 | + private String address; | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * 异常停车起始时间 | |
| 63 | + */ | |
| 64 | + private String startTime; | |
| 65 | + | |
| 66 | + private long startTimestamp; | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * 异常停车结束时间 | |
| 70 | + */ | |
| 71 | + private String endTime; | |
| 72 | + | |
| 73 | + private long endTimestamp; | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * 上下行 | |
| 77 | + */ | |
| 78 | + private int upDown; | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * 备注 | |
| 82 | + */ | |
| 83 | + private String remark; | |
| 84 | + | |
| 85 | + public int getId() { | |
| 86 | + return id; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void setId(int id) { | |
| 90 | + this.id = id; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public String getRq() { | |
| 94 | + return rq; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setRq(String rq) { | |
| 98 | + this.rq = rq; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public String getCompany() { | |
| 102 | + return company; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setCompany(String company) { | |
| 106 | + this.company = company; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public String getBranchCompany() { | |
| 110 | + return branchCompany; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setBranchCompany(String branchCompany) { | |
| 114 | + this.branchCompany = branchCompany; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public String getLine() { | |
| 118 | + return line; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public void setLine(String line) { | |
| 122 | + this.line = line; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public String getLineId() { | |
| 126 | + return lineId; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public void setLineId(String lineId) { | |
| 130 | + this.lineId = lineId; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public String getNbbm() { | |
| 134 | + return nbbm; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public void setNbbm(String nbbm) { | |
| 138 | + this.nbbm = nbbm; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public String getCarCode() { | |
| 142 | + return carCode; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public void setCarCode(String carCode) { | |
| 146 | + this.carCode = carCode; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public String getDriver() { | |
| 150 | + return driver; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public void setDriver(String driver) { | |
| 154 | + this.driver = driver; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public double getLat() { | |
| 158 | + return lat; | |
| 159 | + } | |
| 160 | + | |
| 161 | + public void setLat(double lat) { | |
| 162 | + this.lat = lat; | |
| 163 | + } | |
| 164 | + | |
| 165 | + public double getLon() { | |
| 166 | + return lon; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public void setLon(double lon) { | |
| 170 | + this.lon = lon; | |
| 171 | + } | |
| 172 | + | |
| 173 | + public String getAddress() { | |
| 174 | + return address; | |
| 175 | + } | |
| 176 | + | |
| 177 | + public void setAddress(String address) { | |
| 178 | + this.address = address; | |
| 179 | + } | |
| 180 | + | |
| 181 | + public String getStartTime() { | |
| 182 | + return startTime; | |
| 183 | + } | |
| 184 | + | |
| 185 | + public void setStartTime(String startTime) { | |
| 186 | + this.startTime = startTime; | |
| 187 | + } | |
| 188 | + | |
| 189 | + public long getStartTimestamp() { | |
| 190 | + return startTimestamp; | |
| 191 | + } | |
| 192 | + | |
| 193 | + public void setStartTimestamp(long startTimestamp) { | |
| 194 | + this.startTimestamp = startTimestamp; | |
| 195 | + } | |
| 196 | + | |
| 197 | + public String getEndTime() { | |
| 198 | + return endTime; | |
| 199 | + } | |
| 200 | + | |
| 201 | + public void setEndTime(String endTime) { | |
| 202 | + this.endTime = endTime; | |
| 203 | + } | |
| 204 | + | |
| 205 | + public long getEndTimestamp() { | |
| 206 | + return endTimestamp; | |
| 207 | + } | |
| 208 | + | |
| 209 | + public void setEndTimestamp(long endTimestamp) { | |
| 210 | + this.endTimestamp = endTimestamp; | |
| 211 | + } | |
| 212 | + | |
| 213 | + public int getUpDown() { | |
| 214 | + return upDown; | |
| 215 | + } | |
| 216 | + | |
| 217 | + public void setUpDown(int upDown) { | |
| 218 | + this.upDown = upDown; | |
| 219 | + } | |
| 220 | + | |
| 221 | + public String getRemark() { | |
| 222 | + return remark; | |
| 223 | + } | |
| 224 | + | |
| 225 | + public void setRemark(String remark) { | |
| 226 | + this.remark = remark; | |
| 227 | + } | |
| 228 | + | |
| 229 | + @Override | |
| 230 | + public boolean equals(Object o) { | |
| 231 | + return this.id == ((CarErrorStop) o).id; | |
| 232 | + } | |
| 233 | + | |
| 234 | + @Override | |
| 235 | + public int hashCode() { | |
| 236 | + return this.id; | |
| 237 | + } | |
| 238 | +} | ... | ... |
src/main/java/com/bsth/message/handler/MessageHandler.java
0 → 100644
| 1 | +package com.bsth.message.handler; | |
| 2 | + | |
| 3 | +import com.bsth.message.buffer.CarEnergyBuffer; | |
| 4 | +import com.bsth.message.entity.CarEnergy; | |
| 5 | +import com.bsth.message.entity.CarErrorStop; | |
| 6 | +import com.bsth.websocket.handler.SendUtils; | |
| 7 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |
| 10 | +import org.springframework.kafka.annotation.KafkaListener; | |
| 11 | +import org.springframework.messaging.Message; | |
| 12 | +import org.springframework.stereotype.Component; | |
| 13 | + | |
| 14 | +import java.io.IOException; | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * @author Hill | |
| 19 | + */ | |
| 20 | +@Component | |
| 21 | +@ConditionalOnProperty("kafka.use") | |
| 22 | +public class MessageHandler { | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + private SendUtils sendUtils; | |
| 26 | + | |
| 27 | + @Autowired | |
| 28 | + private ObjectMapper mapper; | |
| 29 | + | |
| 30 | + @KafkaListener(topics="schedule-mainsys-carerrorstop") | |
| 31 | + public void receivedCarErrorStop(Message<String> message) { | |
| 32 | + try { | |
| 33 | + List<CarErrorStop> carErrorStopList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, CarErrorStop.class)); | |
| 34 | + for (CarErrorStop carErrorStop : carErrorStopList) { | |
| 35 | + sendUtils.sendCarErrorStop(carErrorStop); | |
| 36 | + } | |
| 37 | + } catch (IOException e) { | |
| 38 | + e.printStackTrace(); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + | |
| 42 | + @KafkaListener(topics="schedule-mainsys-carenergy") | |
| 43 | + public void receivedCarEnergy(Message<String> message) { | |
| 44 | + try { | |
| 45 | + List<CarEnergy> carEnergyList = mapper.readValue(message.getPayload(), mapper.getTypeFactory().constructParametricType(List.class, CarEnergy.class)); | |
| 46 | + for (CarEnergy carEnergy : carEnergyList) { | |
| 47 | + CarEnergyBuffer.put(carEnergy); | |
| 48 | + } | |
| 49 | + } catch (IOException e) { | |
| 50 | + e.printStackTrace(); | |
| 51 | + } | |
| 52 | + } | |
| 53 | +} | ... | ... |
src/main/java/com/bsth/service/geo_data/impl/GeoDataServiceImpl.java
| ... | ... | @@ -12,8 +12,8 @@ import com.bsth.service.geo_data.impl.dto.CascadeSaveRoad; |
| 12 | 12 | import com.bsth.service.geo_data.impl.dto.CascadeSaveStation; |
| 13 | 13 | import com.bsth.service.geo_data.impl.dto.SaveRoadRouteDTO; |
| 14 | 14 | import com.bsth.service.geo_data.impl.dto.SaveStationRouteDTO; |
| 15 | -import com.bsth.util.GetUIDAndCode; | |
| 16 | 15 | import com.bsth.util.TransGPS; |
| 16 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
| 17 | 17 | import com.google.common.base.Splitter; |
| 18 | 18 | import org.slf4j.Logger; |
| 19 | 19 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -21,11 +21,10 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 21 | 21 | import org.springframework.jdbc.core.BatchPreparedStatementSetter; |
| 22 | 22 | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
| 23 | 23 | import org.springframework.jdbc.core.JdbcTemplate; |
| 24 | -import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 25 | 24 | import org.springframework.stereotype.Service; |
| 26 | -import org.springframework.transaction.TransactionDefinition; | |
| 27 | 25 | import org.springframework.transaction.TransactionStatus; |
| 28 | -import org.springframework.transaction.support.DefaultTransactionDefinition; | |
| 26 | +import org.springframework.transaction.support.TransactionCallback; | |
| 27 | +import org.springframework.transaction.support.TransactionTemplate; | |
| 29 | 28 | |
| 30 | 29 | import java.sql.PreparedStatement; |
| 31 | 30 | import java.sql.SQLException; |
| ... | ... | @@ -47,6 +46,12 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 47 | 46 | @Autowired |
| 48 | 47 | StationRepository stationRepository; |
| 49 | 48 | |
| 49 | + @Autowired | |
| 50 | + private TransactionTemplate transactionTemplate; | |
| 51 | + | |
| 52 | + @Autowired | |
| 53 | + private ObjectMapper mapper; | |
| 54 | + | |
| 50 | 55 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 51 | 56 | |
| 52 | 57 | @Override |
| ... | ... | @@ -172,141 +177,138 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 172 | 177 | public Map<String, Object> updateStationName(Map<String, Object> map) { |
| 173 | 178 | Map<String, Object> rs = new HashMap<>(); |
| 174 | 179 | |
| 175 | - //编程式事务 | |
| 176 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 177 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 178 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 179 | - TransactionStatus status = tran.getTransaction(def); | |
| 180 | - try { | |
| 181 | - | |
| 182 | - int id = Integer.parseInt(map.get("id").toString()); | |
| 183 | - String name = map.get("stationName").toString(); | |
| 184 | - String code = map.get("stationCode").toString(); | |
| 185 | - String lineCode = map.get("lineCode").toString(); | |
| 186 | - String versions = map.get("versions").toString(); | |
| 187 | - | |
| 188 | - //更新历史站点路由 | |
| 189 | - jdbcTemplate.update("update bsth_c_ls_stationroute set station_name=? where id=?", name, id); | |
| 190 | - //更新站点 | |
| 191 | - jdbcTemplate.update("update bsth_c_station set station_name=? where station_cod=?", name, code); | |
| 192 | - | |
| 193 | - //写一条走向变更记录 | |
| 194 | - jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions); | |
| 195 | - | |
| 196 | - tran.commit(status); | |
| 197 | - | |
| 198 | - rs.put("station", findOne(id)); | |
| 199 | - rs.put("status", ResponseCode.SUCCESS); | |
| 200 | - } catch (Exception e) { | |
| 201 | - tran.rollback(status); | |
| 202 | - logger.error("", e); | |
| 203 | - rs.put("status", ResponseCode.ERROR); | |
| 204 | - rs.put("msg", "服务器出现异常"); | |
| 205 | - } | |
| 206 | - return rs; | |
| 180 | + return transactionTemplate.execute(new TransactionCallback<Map<String, Object>>() { | |
| 181 | + @Override | |
| 182 | + public Map<String, Object> doInTransaction(TransactionStatus status) { | |
| 183 | + try { | |
| 184 | + | |
| 185 | + int id = Integer.parseInt(map.get("id").toString()); | |
| 186 | + String name = map.get("stationName").toString(); | |
| 187 | + String code = map.get("stationCode").toString(); | |
| 188 | + String lineCode = map.get("lineCode").toString(); | |
| 189 | + String versions = map.get("versions").toString(); | |
| 190 | + | |
| 191 | + //更新历史站点路由 | |
| 192 | + jdbcTemplate.update("update bsth_c_ls_stationroute set station_name=? where id=?", name, id); | |
| 193 | + //更新站点 | |
| 194 | + jdbcTemplate.update("update bsth_c_station set station_name=? where station_cod=?", name, code); | |
| 195 | + | |
| 196 | + //写一条走向变更记录 | |
| 197 | + jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions); | |
| 198 | + | |
| 199 | + rs.put("station", findOne(id)); | |
| 200 | + rs.put("status", ResponseCode.SUCCESS); | |
| 201 | + } catch (Exception e) { | |
| 202 | + status.setRollbackOnly(); | |
| 203 | + logger.error("", e); | |
| 204 | + rs.put("status", ResponseCode.ERROR); | |
| 205 | + rs.put("msg", "服务器出现异常"); | |
| 206 | + } | |
| 207 | + return rs; | |
| 208 | + } | |
| 209 | + }); | |
| 207 | 210 | } |
| 208 | 211 | |
| 209 | 212 | @Override |
| 210 | 213 | public Map<String, Object> addNewRoadRoute(String lineCode, int upDown, int versions, String sectionName, String crosesRoad, String coords, int prevRouteId) { |
| 211 | 214 | Map<String, Object> rs = new HashMap<>(); |
| 212 | 215 | |
| 213 | - //编程式事务 | |
| 214 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 215 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 216 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 217 | - TransactionStatus status = tran.getTransaction(def); | |
| 218 | - try { | |
| 219 | - //根据线路编码,查询线路ID | |
| 220 | - int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class); | |
| 221 | - | |
| 222 | - String sql = "select * from bsth_c_ls_sectionroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions; | |
| 223 | - List<SaveRoadRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveRoadRouteDTO.class)); | |
| 224 | - | |
| 225 | - Collections.sort(routes, new RoadRouteComp()); | |
| 226 | - | |
| 227 | - long sCode = sectionRepository.sectionMaxId() + 1; | |
| 228 | - //转wgs | |
| 229 | - String wgsCoord = "LINESTRING(" + bdPolygon2Wgs(coords) + ")"; | |
| 230 | - String bdCooed = "LINESTRING(" + coords + ")"; | |
| 231 | - //insert 路段 | |
| 232 | - sql = "insert into bsth_c_section(id, section_code, section_name, croses_road, bsection_vector, gsection_vector, create_date, update_date, versions) " + | |
| 233 | - " values(?,?,?,?,ST_GeomFromText('" + bdCooed + "'),ST_GeomFromText('" + wgsCoord + "'),sysdate(),sysdate(),?)"; | |
| 234 | - | |
| 235 | - jdbcTemplate.update(sql, sCode, sCode, sectionName, crosesRoad, 1); | |
| 236 | - | |
| 216 | + return transactionTemplate.execute(new TransactionCallback<Map<String, Object>>() { | |
| 237 | 217 | |
| 238 | - SaveRoadRouteDTO srr; | |
| 239 | - int currentNo = -1, | |
| 240 | - no = 100, step = 100; | |
| 241 | - | |
| 242 | - if (prevRouteId == -1) { | |
| 243 | - //起点站 | |
| 244 | - currentNo = no; | |
| 245 | - no += step; | |
| 246 | - } | |
| 247 | - //重新排序路由 | |
| 248 | - for (int i = 0, size = routes.size(); i < size; i++) { | |
| 249 | - srr = routes.get(i); | |
| 250 | - srr.setSectionrouteCode(no += step); | |
| 251 | - if (srr.getId().intValue() == prevRouteId) { | |
| 252 | - no += step; | |
| 253 | - currentNo = no; | |
| 218 | + @Override | |
| 219 | + public Map<String, Object> doInTransaction(TransactionStatus status) { | |
| 220 | + try { | |
| 221 | + //根据线路编码,查询线路ID | |
| 222 | + int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class); | |
| 223 | + | |
| 224 | + String sql = "select * from bsth_c_ls_sectionroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions; | |
| 225 | + List<SaveRoadRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveRoadRouteDTO.class)); | |
| 226 | + | |
| 227 | + Collections.sort(routes, new RoadRouteComp()); | |
| 228 | + | |
| 229 | + long sCode = sectionRepository.sectionMaxId() + 1; | |
| 230 | + //转wgs | |
| 231 | + String wgsCoord = "LINESTRING(" + bdPolygon2Wgs(coords) + ")"; | |
| 232 | + String bdCooed = "LINESTRING(" + coords + ")"; | |
| 233 | + //insert 路段 | |
| 234 | + sql = "insert into bsth_c_section(id, section_code, section_name, croses_road, bsection_vector, gsection_vector, create_date, update_date, versions) " + | |
| 235 | + " values(?,?,?,?,ST_GeomFromText('" + bdCooed + "'),ST_GeomFromText('" + wgsCoord + "'),sysdate(),sysdate(),?)"; | |
| 236 | + | |
| 237 | + jdbcTemplate.update(sql, sCode, sCode, sectionName, crosesRoad, 1); | |
| 238 | + | |
| 239 | + | |
| 240 | + SaveRoadRouteDTO srr; | |
| 241 | + int currentNo = -1, | |
| 242 | + no = 100, step = 100; | |
| 243 | + | |
| 244 | + if (prevRouteId == -1) { | |
| 245 | + //起点站 | |
| 246 | + currentNo = no; | |
| 247 | + no += step; | |
| 248 | + } | |
| 249 | + //重新排序路由 | |
| 250 | + for (int i = 0, size = routes.size(); i < size; i++) { | |
| 251 | + srr = routes.get(i); | |
| 252 | + srr.setSectionrouteCode(no += step); | |
| 253 | + if (srr.getId().intValue() == prevRouteId) { | |
| 254 | + no += step; | |
| 255 | + currentNo = no; | |
| 256 | + } | |
| 257 | + } | |
| 258 | + | |
| 259 | + srr = new SaveRoadRouteDTO(); | |
| 260 | + srr.setLine(lineId); | |
| 261 | + srr.setLineCode(lineCode); | |
| 262 | + srr.setDirections(upDown); | |
| 263 | + srr.setVersions(versions); | |
| 264 | + | |
| 265 | + srr.setSectionrouteCode(currentNo); | |
| 266 | + srr.setSection(sCode); | |
| 267 | + srr.setSectionCode(sCode + ""); | |
| 268 | + srr.setIsRoadeSpeed(0); | |
| 269 | + srr.setDestroy(0); | |
| 270 | + Date d = new Date(); | |
| 271 | + srr.setCreateDate(d); | |
| 272 | + srr.setUpdateDate(d); | |
| 273 | + | |
| 274 | + final List<SaveRoadRouteDTO> saveList = routes; | |
| 275 | + //insert 新路由 (ID自增) | |
| 276 | + jdbcTemplate.update("insert into bsth_c_ls_sectionroute(line_code, section_code, sectionroute_code, directions, line, section, create_date,update_date,versions,destroy,is_roade_speed)" + | |
| 277 | + " values(?,?,?,?,?,?,?,?,?,?,?)", srr.getLineCode(), srr.getSectionCode(), srr.getSectionrouteCode(), srr.getDirections(), srr.getLine(), srr.getSection(), srr.getCreateDate(), srr.getUpdateDate(), versions, srr.getDestroy(), srr.getIsRoadeSpeed()); | |
| 278 | + | |
| 279 | + // update 原路由 | |
| 280 | + jdbcTemplate.batchUpdate("update bsth_c_ls_sectionroute set sectionroute_code=? where id=?" | |
| 281 | + , new BatchPreparedStatementSetter() { | |
| 282 | + @Override | |
| 283 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 284 | + SaveRoadRouteDTO srr = saveList.get(i); | |
| 285 | + ps.setInt(1, srr.getSectionrouteCode()); | |
| 286 | + ps.setInt(2, srr.getId()); | |
| 287 | + } | |
| 288 | + | |
| 289 | + @Override | |
| 290 | + public int getBatchSize() { | |
| 291 | + return saveList.size(); | |
| 292 | + } | |
| 293 | + }); | |
| 294 | + | |
| 295 | + | |
| 296 | + //写一条走向变更记录 | |
| 297 | + jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions); | |
| 298 | + | |
| 299 | + //返回更新之后的数据 | |
| 300 | + List<GeoRoad> list = findRoadByUpdown(lineCode, upDown, versions); | |
| 301 | + rs.put("list", list); | |
| 302 | + rs.put("status", ResponseCode.SUCCESS); | |
| 303 | + } catch (Exception e) { | |
| 304 | + status.setRollbackOnly(); | |
| 305 | + logger.error("", e); | |
| 306 | + rs.put("status", ResponseCode.ERROR); | |
| 307 | + rs.put("msg", "服务器出现异常"); | |
| 254 | 308 | } |
| 309 | + return rs; | |
| 255 | 310 | } |
| 256 | - | |
| 257 | - srr = new SaveRoadRouteDTO(); | |
| 258 | - srr.setLine(lineId); | |
| 259 | - srr.setLineCode(lineCode); | |
| 260 | - srr.setDirections(upDown); | |
| 261 | - srr.setVersions(versions); | |
| 262 | - | |
| 263 | - srr.setSectionrouteCode(currentNo); | |
| 264 | - srr.setSection(sCode); | |
| 265 | - srr.setSectionCode(sCode + ""); | |
| 266 | - srr.setIsRoadeSpeed(0); | |
| 267 | - srr.setDestroy(0); | |
| 268 | - Date d = new Date(); | |
| 269 | - srr.setCreateDate(d); | |
| 270 | - srr.setUpdateDate(d); | |
| 271 | - | |
| 272 | - final List<SaveRoadRouteDTO> saveList = routes; | |
| 273 | - //insert 新路由 (ID自增) | |
| 274 | - jdbcTemplate.update("insert into bsth_c_ls_sectionroute(line_code, section_code, sectionroute_code, directions, line, section, create_date,update_date,versions,destroy,is_roade_speed)" + | |
| 275 | - " values(?,?,?,?,?,?,?,?,?,?,?)", srr.getLineCode(), srr.getSectionCode(), srr.getSectionrouteCode(), srr.getDirections(), srr.getLine(), srr.getSection(), srr.getCreateDate(), srr.getUpdateDate(), versions, srr.getDestroy(), srr.getIsRoadeSpeed()); | |
| 276 | - | |
| 277 | - // update 原路由 | |
| 278 | - jdbcTemplate.batchUpdate("update bsth_c_ls_sectionroute set sectionroute_code=? where id=?" | |
| 279 | - , new BatchPreparedStatementSetter() { | |
| 280 | - @Override | |
| 281 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 282 | - SaveRoadRouteDTO srr = saveList.get(i); | |
| 283 | - ps.setInt(1, srr.getSectionrouteCode()); | |
| 284 | - ps.setInt(2, srr.getId()); | |
| 285 | - } | |
| 286 | - | |
| 287 | - @Override | |
| 288 | - public int getBatchSize() { | |
| 289 | - return saveList.size(); | |
| 290 | - } | |
| 291 | - }); | |
| 292 | - | |
| 293 | - | |
| 294 | - //写一条走向变更记录 | |
| 295 | - jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions); | |
| 296 | - | |
| 297 | - tran.commit(status); | |
| 298 | - | |
| 299 | - //返回更新之后的数据 | |
| 300 | - List<GeoRoad> list = findRoadByUpdown(lineCode, upDown, versions); | |
| 301 | - rs.put("list", list); | |
| 302 | - rs.put("status", ResponseCode.SUCCESS); | |
| 303 | - } catch (Exception e) { | |
| 304 | - tran.rollback(status); | |
| 305 | - logger.error("", e); | |
| 306 | - rs.put("status", ResponseCode.ERROR); | |
| 307 | - rs.put("msg", "服务器出现异常"); | |
| 308 | - } | |
| 309 | - return rs; | |
| 311 | + }); | |
| 310 | 312 | } |
| 311 | 313 | |
| 312 | 314 | /** |
| ... | ... | @@ -339,99 +341,100 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 339 | 341 | public Map<String, Object> addNewLineVersion(Map<String, Object> map) { |
| 340 | 342 | Map<String, Object> rs = new HashMap<>(); |
| 341 | 343 | |
| 342 | - //编程式事务 | |
| 343 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 344 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 345 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 346 | - TransactionStatus status = tran.getTransaction(def); | |
| 347 | - try { | |
| 348 | - | |
| 349 | - String lineCode = map.get("lineCode").toString(); | |
| 350 | - String remark = map.get("remark").toString(); | |
| 351 | - String name = map.get("name").toString(); | |
| 352 | - Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(map.get("startDate").toString()); | |
| 353 | - int extendsVersion = Integer.parseInt(map.get("extendsVersion").toString()); | |
| 344 | + return transactionTemplate.execute(new TransactionCallback<Map<String, Object>>() { | |
| 354 | 345 | |
| 355 | - if(startDate.getTime() - System.currentTimeMillis() < 1000 * 60 * 3){ | |
| 356 | - rs.put("status", ResponseCode.ERROR); | |
| 357 | - rs.put("msg", "启用时间最少需要晚于当前服务器时间3分钟!"); | |
| 358 | - return rs; | |
| 359 | - } | |
| 360 | - | |
| 361 | - int nameCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code=" + lineCode + " and name='"+name+"'", Integer.class); | |
| 362 | - if(nameCount > 0){ | |
| 363 | - rs.put("status", ResponseCode.ERROR); | |
| 364 | - rs.put("msg", "你不能使用一个已经存在的版本名称!!"); | |
| 365 | - return rs; | |
| 366 | - } | |
| 367 | - | |
| 368 | - //当前最大的版本号 | |
| 369 | - int maxVersion = jdbcTemplate.queryForObject("select max(versions) as versions from bsth_c_line_versions where line_code=" + lineCode, Integer.class); | |
| 370 | - Date d = new Date(); | |
| 371 | - | |
| 372 | - //根据线路编码,查询线路ID | |
| 373 | - int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class); | |
| 374 | - | |
| 375 | - maxVersion += 1; | |
| 376 | - LineVersions lVersion = new LineVersions(); | |
| 377 | - lVersion.setName(name); | |
| 378 | - lVersion.setVersions(maxVersion); | |
| 379 | - lVersion.setRemark(remark); | |
| 380 | - lVersion.setStartDate(startDate); | |
| 381 | - lVersion.setStatus(2); | |
| 382 | - lVersion.setCreateDate(d); | |
| 383 | - lVersion.setUpdateDate(d); | |
| 384 | - lVersion.setLineCode(lineCode); | |
| 385 | - | |
| 386 | - //如果有待启用的版本,设置为历史版本 | |
| 387 | - jdbcTemplate.update("update bsth_c_line_versions set `status`=2, start_date=null,end_date=null where line_code='"+lineCode+"' and `status`=0"); | |
| 388 | - | |
| 389 | - //入库线路版本 | |
| 390 | - jdbcTemplate.update("insert into bsth_c_line_versions(name, line, line_code, versions, start_date, create_date, update_date, remark,status, isupdate) " + | |
| 391 | - " values(?,?,?,?,?,?,?,?,?,?)", lVersion.getName(), lineId, lVersion.getLineCode() | |
| 392 | - , lVersion.getVersions(), lVersion.getStartDate(), lVersion.getCreateDate(), lVersion.getUpdateDate(), lVersion.getRemark(), lVersion.getStatus(), lVersion.getIsupdate()); | |
| 393 | - | |
| 394 | - if (extendsVersion != -1) { | |
| 395 | - //复制站点信息 | |
| 396 | - String sql = "SELECT t1.id AS route_id,t1.line,t1.directions,t1.station,t1.station_name,t1.station_route_code,t1.line_code,t1.station_code,t1.station_mark,t1.distances,t1.to_time,t2.id AS station_id,t2.db_type,t2.b_jwpoints,t2.g_lonx,t2.g_laty,t2.radius,ST_AsText(t2.g_polygon_grid) as g_polygon_grid,t2.shapes_type FROM bsth_c_ls_stationroute t1 LEFT JOIN bsth_c_station t2 ON t1.station_code = t2.station_cod where t1.destroy=0 and t1.line_code='" + lineCode + "' and t1.versions="+extendsVersion+" order by t1.directions, t1.station_route_code"; | |
| 397 | - List<CascadeSaveStation> cssList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(CascadeSaveStation.class)); | |
| 398 | - | |
| 399 | - //新的站点编码 | |
| 400 | - long sCode; | |
| 401 | - for (CascadeSaveStation ss : cssList) { | |
| 402 | - sCode = stationRepository.stationMaxId() + 1; | |
| 403 | - ss.setRouteId(null); | |
| 404 | - ss.setStationCode(sCode + ""); | |
| 405 | - ss.setStation((int) sCode); | |
| 406 | - } | |
| 407 | - //入库新版本的站点 和 路由 | |
| 408 | - batchInsertStation(cssList, maxVersion); | |
| 409 | - | |
| 410 | - //复制路段信息 | |
| 411 | - sql = "SELECT t1.id AS route_id,t1.line,t1.line_code,t1.directions,t1.section,t1.section_code,t1.sectionroute_code,t1.versions,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector,t2.db_type,t2.speed_limit FROM bsth_c_ls_sectionroute t1 LEFT JOIN bsth_c_section t2 ON t1.section_code = t2.section_code WHERE t1.destroy = 0 AND t1.line_code = '"+lineCode+"' and t1.versions="+ extendsVersion +" ORDER BY t1.directions,t1.sectionroute_code"; | |
| 412 | - List<CascadeSaveRoad> csrList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(CascadeSaveRoad.class)); | |
| 413 | - //新的路段编码 | |
| 414 | - long cCode; | |
| 415 | - for(CascadeSaveRoad csr : csrList){ | |
| 416 | - cCode = sectionRepository.sectionMaxId() + 1; | |
| 417 | - csr.setRouteId(null); | |
| 418 | - csr.setSection((int) cCode); | |
| 419 | - csr.setSectionCode(cCode + ""); | |
| 346 | + @Override | |
| 347 | + public Map<String, Object> doInTransaction(TransactionStatus status) { | |
| 348 | + try { | |
| 349 | + | |
| 350 | + String lineCode = map.get("lineCode").toString(); | |
| 351 | + String remark = map.get("remark").toString(); | |
| 352 | + String name = map.get("name").toString(); | |
| 353 | + Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(map.get("startDate").toString()); | |
| 354 | + int extendsVersion = Integer.parseInt(map.get("extendsVersion").toString()); | |
| 355 | + | |
| 356 | + if(startDate.getTime() - System.currentTimeMillis() < 1000 * 60 * 3){ | |
| 357 | + rs.put("status", ResponseCode.ERROR); | |
| 358 | + rs.put("msg", "启用时间最少需要晚于当前服务器时间3分钟!"); | |
| 359 | + return rs; | |
| 360 | + } | |
| 361 | + | |
| 362 | + int nameCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code=" + lineCode + " and name='"+name+"'", Integer.class); | |
| 363 | + if(nameCount > 0){ | |
| 364 | + rs.put("status", ResponseCode.ERROR); | |
| 365 | + rs.put("msg", "你不能使用一个已经存在的版本名称!!"); | |
| 366 | + return rs; | |
| 367 | + } | |
| 368 | + | |
| 369 | + //当前最大的版本号 | |
| 370 | + int maxVersion = jdbcTemplate.queryForObject("select max(versions) as versions from bsth_c_line_versions where line_code=" + lineCode, Integer.class); | |
| 371 | + Date d = new Date(); | |
| 372 | + | |
| 373 | + //根据线路编码,查询线路ID | |
| 374 | + int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class); | |
| 375 | + | |
| 376 | + maxVersion += 1; | |
| 377 | + LineVersions lVersion = new LineVersions(); | |
| 378 | + lVersion.setName(name); | |
| 379 | + lVersion.setVersions(maxVersion); | |
| 380 | + lVersion.setRemark(remark); | |
| 381 | + lVersion.setStartDate(startDate); | |
| 382 | + lVersion.setStatus(2); | |
| 383 | + lVersion.setCreateDate(d); | |
| 384 | + lVersion.setUpdateDate(d); | |
| 385 | + lVersion.setLineCode(lineCode); | |
| 386 | + | |
| 387 | + //如果有待启用的版本,设置为历史版本 | |
| 388 | + jdbcTemplate.update("update bsth_c_line_versions set `status`=2, start_date=null,end_date=null where line_code='"+lineCode+"' and `status`=0"); | |
| 389 | + | |
| 390 | + //入库线路版本 | |
| 391 | + jdbcTemplate.update("insert into bsth_c_line_versions(name, line, line_code, versions, start_date, create_date, update_date, remark,status, isupdate) " + | |
| 392 | + " values(?,?,?,?,?,?,?,?,?,?)", lVersion.getName(), lineId, lVersion.getLineCode() | |
| 393 | + , lVersion.getVersions(), lVersion.getStartDate(), lVersion.getCreateDate(), lVersion.getUpdateDate(), lVersion.getRemark(), lVersion.getStatus(), lVersion.getIsupdate()); | |
| 394 | + | |
| 395 | + if (extendsVersion != -1) { | |
| 396 | + //复制站点信息 | |
| 397 | + String sql = "SELECT t1.id AS route_id,t1.line,t1.directions,t1.station,t1.station_name,t1.station_route_code,t1.line_code,t1.station_code,t1.station_mark,t1.distances,t1.to_time,t2.id AS station_id,t2.db_type,t2.b_jwpoints,t2.g_lonx,t2.g_laty,t2.radius,ST_AsText(t2.g_polygon_grid) as g_polygon_grid,t2.shapes_type FROM bsth_c_ls_stationroute t1 LEFT JOIN bsth_c_station t2 ON t1.station_code = t2.station_cod where t1.destroy=0 and t1.line_code='" + lineCode + "' and t1.versions="+extendsVersion+" order by t1.directions, t1.station_route_code"; | |
| 398 | + List<CascadeSaveStation> cssList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(CascadeSaveStation.class)); | |
| 399 | + | |
| 400 | + //新的站点编码 | |
| 401 | + long sCode; | |
| 402 | + for (CascadeSaveStation ss : cssList) { | |
| 403 | + sCode = stationRepository.stationMaxId() + 1; | |
| 404 | + ss.setRouteId(null); | |
| 405 | + ss.setStationCode(sCode + ""); | |
| 406 | + ss.setStation((int) sCode); | |
| 407 | + } | |
| 408 | + //入库新版本的站点 和 路由 | |
| 409 | + batchInsertStation(cssList, maxVersion); | |
| 410 | + | |
| 411 | + //复制路段信息 | |
| 412 | + sql = "SELECT t1.id AS route_id,t1.line,t1.line_code,t1.directions,t1.section,t1.section_code,t1.sectionroute_code,t1.versions,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector,t2.db_type,t2.speed_limit FROM bsth_c_ls_sectionroute t1 LEFT JOIN bsth_c_section t2 ON t1.section_code = t2.section_code WHERE t1.destroy = 0 AND t1.line_code = '"+lineCode+"' and t1.versions="+ extendsVersion +" ORDER BY t1.directions,t1.sectionroute_code"; | |
| 413 | + List<CascadeSaveRoad> csrList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(CascadeSaveRoad.class)); | |
| 414 | + //新的路段编码 | |
| 415 | + long cCode; | |
| 416 | + for(CascadeSaveRoad csr : csrList){ | |
| 417 | + cCode = sectionRepository.sectionMaxId() + 1; | |
| 418 | + csr.setRouteId(null); | |
| 419 | + csr.setSection((int) cCode); | |
| 420 | + csr.setSectionCode(cCode + ""); | |
| 421 | + } | |
| 422 | + //入库新版本的路段 和 路段路由 | |
| 423 | + batchInsertRoad(csrList, maxVersion); | |
| 424 | + } | |
| 425 | + | |
| 426 | + rs.put("newVersion", maxVersion); | |
| 427 | + rs.put("status", ResponseCode.SUCCESS); | |
| 428 | + } catch (Exception e) { | |
| 429 | + status.setRollbackOnly(); | |
| 430 | + logger.error("", e); | |
| 431 | + rs.put("status", ResponseCode.ERROR); | |
| 432 | + rs.put("msg", "服务器出现异常"); | |
| 420 | 433 | } |
| 421 | - //入库新版本的路段 和 路段路由 | |
| 422 | - batchInsertRoad(csrList, maxVersion); | |
| 434 | + return rs; | |
| 423 | 435 | } |
| 436 | + }); | |
| 424 | 437 | |
| 425 | - tran.commit(status); | |
| 426 | - rs.put("newVersion", maxVersion); | |
| 427 | - rs.put("status", ResponseCode.SUCCESS); | |
| 428 | - } catch (Exception e) { | |
| 429 | - tran.rollback(status); | |
| 430 | - logger.error("", e); | |
| 431 | - rs.put("status", ResponseCode.ERROR); | |
| 432 | - rs.put("msg", "服务器出现异常"); | |
| 433 | - } | |
| 434 | - return rs; | |
| 435 | 438 | } |
| 436 | 439 | |
| 437 | 440 | /** |
| ... | ... | @@ -444,19 +447,17 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 444 | 447 | public Map<String, Object> deleteLineVersion(String lineCode, int version) { |
| 445 | 448 | Map<String, Object> rs = new HashMap<>(); |
| 446 | 449 | |
| 447 | - //编程式事务 | |
| 448 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 449 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 450 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 451 | - TransactionStatus status = tran.getTransaction(def); | |
| 452 | - try{ | |
| 453 | - int enableVersion = jdbcTemplate.queryForObject("select versions from bsth_c_line_versions where line_code='"+lineCode+"' and `status`=1", Integer.class); | |
| 454 | - | |
| 455 | - if(enableVersion==version){ | |
| 456 | - rs.put("status", ResponseCode.ERROR); | |
| 457 | - rs.put("msg", "你不能删除当前正在启用的走向版本!"); | |
| 458 | - return rs; | |
| 459 | - } | |
| 450 | + return transactionTemplate.execute(new TransactionCallback<Map<String, Object>>() { | |
| 451 | + @Override | |
| 452 | + public Map<String, Object> doInTransaction(TransactionStatus status) { | |
| 453 | + try{ | |
| 454 | + int enableVersion = jdbcTemplate.queryForObject("select versions from bsth_c_line_versions where line_code='"+lineCode+"' and `status`=1", Integer.class); | |
| 455 | + | |
| 456 | + if(enableVersion==version){ | |
| 457 | + rs.put("status", ResponseCode.ERROR); | |
| 458 | + rs.put("msg", "你不能删除当前正在启用的走向版本!"); | |
| 459 | + return rs; | |
| 460 | + } | |
| 460 | 461 | /*int versionCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code='"+lineCode+"'", Integer.class); |
| 461 | 462 | if(versionCount == 1){ |
| 462 | 463 | rs.put("status", ResponseCode.ERROR); |
| ... | ... | @@ -472,27 +473,29 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 472 | 473 | |
| 473 | 474 | List<Integer> stationRemoves = jdbcTemplate.queryForList(sql, Integer.class);*/ |
| 474 | 475 | |
| 475 | - //删除站点路由 | |
| 476 | - String sql = "delete from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions=" + version; | |
| 477 | - jdbcTemplate.update(sql); | |
| 476 | + //删除站点路由 | |
| 477 | + String sql = "delete from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions=" + version; | |
| 478 | + jdbcTemplate.update(sql); | |
| 478 | 479 | |
| 479 | - //删除路段路由 | |
| 480 | - sql = "delete from bsth_c_ls_sectionroute where line_code='"+lineCode+"' and versions=" + version; | |
| 481 | - jdbcTemplate.update(sql); | |
| 480 | + //删除路段路由 | |
| 481 | + sql = "delete from bsth_c_ls_sectionroute where line_code='"+lineCode+"' and versions=" + version; | |
| 482 | + jdbcTemplate.update(sql); | |
| 482 | 483 | |
| 483 | - //删除版本信息 | |
| 484 | - sql = "delete from bsth_c_line_versions where line_code='"+lineCode+"' and versions=" + version; | |
| 485 | - jdbcTemplate.update(sql); | |
| 484 | + //删除版本信息 | |
| 485 | + sql = "delete from bsth_c_line_versions where line_code='"+lineCode+"' and versions=" + version; | |
| 486 | + jdbcTemplate.update(sql); | |
| 487 | + | |
| 488 | + rs.put("status", ResponseCode.SUCCESS); | |
| 489 | + }catch (Exception e){ | |
| 490 | + status.setRollbackOnly(); | |
| 491 | + logger.error("", e); | |
| 492 | + rs.put("status", ResponseCode.ERROR); | |
| 493 | + rs.put("msg", "服务器出现异常"); | |
| 494 | + } | |
| 495 | + return rs; | |
| 496 | + } | |
| 497 | + }); | |
| 486 | 498 | |
| 487 | - tran.commit(status); | |
| 488 | - rs.put("status", ResponseCode.SUCCESS); | |
| 489 | - }catch (Exception e){ | |
| 490 | - tran.rollback(status); | |
| 491 | - logger.error("", e); | |
| 492 | - rs.put("status", ResponseCode.ERROR); | |
| 493 | - rs.put("msg", "服务器出现异常"); | |
| 494 | - } | |
| 495 | - return rs; | |
| 496 | 499 | } |
| 497 | 500 | |
| 498 | 501 | /** |
| ... | ... | @@ -541,7 +544,7 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 541 | 544 | |
| 542 | 545 | /** |
| 543 | 546 | * 批量入库路段 |
| 544 | - * @param cssList | |
| 547 | + * @param csrList | |
| 545 | 548 | * @param version |
| 546 | 549 | */ |
| 547 | 550 | private void batchInsertRoad(final List<CascadeSaveRoad> csrList, final int version){ |
| ... | ... | @@ -659,145 +662,144 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 659 | 662 | public Map<String, Object> addNewStationRoute(String lineCode, int upDown, int versions, String stationName, Float lat, Float lng, int prevRouteId) { |
| 660 | 663 | Map<String, Object> rs = new HashMap<>(); |
| 661 | 664 | |
| 662 | - //编程式事务 | |
| 663 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 664 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 665 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 666 | - TransactionStatus status = tran.getTransaction(def); | |
| 667 | - try { | |
| 668 | - //根据线路编码,查询线路ID | |
| 669 | - int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class); | |
| 665 | + return transactionTemplate.execute(new TransactionCallback<Map<String, Object>>() { | |
| 666 | + @Override | |
| 667 | + public Map<String, Object> doInTransaction(TransactionStatus status) { | |
| 668 | + try { | |
| 669 | + //根据线路编码,查询线路ID | |
| 670 | + int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class); | |
| 670 | 671 | |
| 671 | - String sql = "select * from bsth_c_ls_stationroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions; | |
| 672 | - List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class)); | |
| 672 | + String sql = "select * from bsth_c_ls_stationroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions; | |
| 673 | + List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class)); | |
| 673 | 674 | |
| 674 | - for (SaveStationRouteDTO s : routes) { | |
| 675 | - if (s.getStationName().equals(stationName)) { | |
| 675 | + for (SaveStationRouteDTO s : routes) { | |
| 676 | + if (s.getStationName().equals(stationName)) { | |
| 676 | 677 | |
| 678 | + rs.put("status", ResponseCode.ERROR); | |
| 679 | + rs.put("msg", "重复的站点路由名称!"); | |
| 680 | + return rs; | |
| 681 | + } | |
| 682 | + } | |
| 683 | + //按路由顺序排列 | |
| 684 | + Collections.sort(routes, new StationRouteComp()); | |
| 685 | + | |
| 686 | + //转WGS | |
| 687 | + TransGPS.Location wgsLoc = TransGPS.transformFromGCJToWGS(TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(String.valueOf(lng)), Double.parseDouble(String.valueOf(lat))))); | |
| 688 | + | |
| 689 | + //insert 站点 | |
| 690 | + long sCode = stationRepository.stationMaxId() + 1; | |
| 691 | + jdbcTemplate.update("insert into bsth_c_station(id, station_cod, station_name, db_type, b_jwpoints, g_lonx, g_laty, destroy, radius, shapes_type, versions) " + | |
| 692 | + " values(?,?,?,?,?,?,?,?,?,?,?)", sCode, sCode, stationName, "b", lng + " " + lat, wgsLoc.getLng(), wgsLoc.getLat(), 0, 88, "r", 1); | |
| 693 | + | |
| 694 | + | |
| 695 | + SaveStationRouteDTO sr; | |
| 696 | + int currentNo = -1, | |
| 697 | + no = 100, step = 100; | |
| 698 | + | |
| 699 | + if (prevRouteId == -1) { | |
| 700 | + //起点站 | |
| 701 | + currentNo = no; | |
| 702 | + no += step; | |
| 703 | + } | |
| 704 | + //重新排序路由 | |
| 705 | + for (int i = 0, size = routes.size(); i < size; i++) { | |
| 706 | + sr = routes.get(i); | |
| 707 | + sr.setStationRouteCode(no); | |
| 708 | + no += step; | |
| 709 | + if (sr.getId().intValue() == prevRouteId) { | |
| 710 | + currentNo = no; | |
| 711 | + no += step; | |
| 712 | + } | |
| 713 | + } | |
| 714 | + | |
| 715 | + SaveStationRouteDTO nsr = new SaveStationRouteDTO(); | |
| 716 | + nsr.setLine(lineId); | |
| 717 | + nsr.setLineCode(lineCode); | |
| 718 | + nsr.setDirections(upDown); | |
| 719 | + nsr.setVersions(versions); | |
| 720 | + nsr.setStationRouteCode(currentNo); | |
| 721 | + nsr.setStation(sCode); | |
| 722 | + nsr.setStationCode(sCode + ""); | |
| 723 | + nsr.setStationName(stationName); | |
| 724 | + nsr.setDistances(0d); | |
| 725 | + nsr.setToTime(0d); | |
| 726 | + Date d = new Date(); | |
| 727 | + nsr.setCreateDate(d); | |
| 728 | + nsr.setUpdateDate(d); | |
| 729 | + nsr.setDestroy(0); | |
| 730 | + if (prevRouteId == -1) | |
| 731 | + nsr.setStationMark("B"); | |
| 732 | + else if(routes.size()==1) | |
| 733 | + nsr.setStationMark("E"); | |
| 734 | + | |
| 735 | + //routes.add(sr); | |
| 736 | + | |
| 737 | + //重新标记mark | |
| 738 | + Collections.sort(routes, new StationRouteComp()); | |
| 739 | + for (int i = 0, size = routes.size(); i < size; i++) { | |
| 740 | + routes.get(i).setStationMark("Z"); | |
| 741 | + } | |
| 742 | + if(routes.size() > 0 && prevRouteId!=-1) | |
| 743 | + routes.get(0).setStationMark("B"); | |
| 744 | + if(routes.size() > 1) | |
| 745 | + routes.get(routes.size() - 1).setStationMark("E"); | |
| 746 | + | |
| 747 | + final List<SaveStationRouteDTO> saveList = routes; | |
| 748 | + //insert 新路由 (ID自增) | |
| 749 | + jdbcTemplate.update("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)" | |
| 750 | + , nsr.getLine(), nsr.getStation(), nsr.getStationName(), nsr.getStationRouteCode(), nsr.getLineCode(), nsr.getStationCode(), nsr.getStationMark() | |
| 751 | + , nsr.getDistances(), nsr.getToTime(), nsr.getDestroy(), nsr.getVersions(), nsr.getCreateDate(), nsr.getUpdateDate(), nsr.getDirections()); | |
| 752 | + | |
| 753 | + // update 原路由 | |
| 754 | + jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," + | |
| 755 | + "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" + | |
| 756 | + " where id=?" | |
| 757 | + , new BatchPreparedStatementSetter() { | |
| 758 | + @Override | |
| 759 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 760 | + SaveStationRouteDTO sr = saveList.get(i); | |
| 761 | + ps.setInt(1, sr.getLine()); | |
| 762 | + ps.setLong(2, sr.getStation()); | |
| 763 | + ps.setString(3, sr.getStationName()); | |
| 764 | + ps.setInt(4, sr.getStationRouteCode()); | |
| 765 | + ps.setString(5, sr.getLineCode()); | |
| 766 | + ps.setString(6, sr.getStationCode()); | |
| 767 | + ps.setString(7, sr.getStationMark()); | |
| 768 | + ps.setDouble(8, sr.getDistances()); | |
| 769 | + ps.setDouble(9, sr.getToTime()); | |
| 770 | + ps.setInt(10, sr.getDestroy()); | |
| 771 | + ps.setInt(11, sr.getVersions()); | |
| 772 | + ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime())); | |
| 773 | + ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime())); | |
| 774 | + ps.setInt(14, sr.getDirections()); | |
| 775 | + ps.setInt(15, sr.getId()); | |
| 776 | + } | |
| 777 | + | |
| 778 | + @Override | |
| 779 | + public int getBatchSize() { | |
| 780 | + return saveList.size(); | |
| 781 | + } | |
| 782 | + }); | |
| 783 | + | |
| 784 | + //写一条走向变更记录 | |
| 785 | + jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions); | |
| 786 | + | |
| 787 | + //返回更新之后的数据 | |
| 788 | + List<GeoStation> list = findByUpdown(lineCode, upDown, versions); | |
| 789 | + | |
| 790 | + rs.put("list", list); | |
| 791 | + rs.put("newStationRouteCode", currentNo); | |
| 792 | + rs.put("status", ResponseCode.SUCCESS); | |
| 793 | + } catch (Exception e) { | |
| 794 | + status.setRollbackOnly(); | |
| 795 | + logger.error("", e); | |
| 677 | 796 | rs.put("status", ResponseCode.ERROR); |
| 678 | - rs.put("msg", "重复的站点路由名称!"); | |
| 679 | - return rs; | |
| 797 | + rs.put("msg", "服务器出现异常"); | |
| 680 | 798 | } |
| 799 | + return rs; | |
| 681 | 800 | } |
| 682 | - //按路由顺序排列 | |
| 683 | - Collections.sort(routes, new StationRouteComp()); | |
| 684 | - | |
| 685 | - //转WGS | |
| 686 | - TransGPS.Location wgsLoc = TransGPS.transformFromGCJToWGS(TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(String.valueOf(lng)), Double.parseDouble(String.valueOf(lat))))); | |
| 687 | - | |
| 688 | - //insert 站点 | |
| 689 | - long sCode = stationRepository.stationMaxId() + 1; | |
| 690 | - jdbcTemplate.update("insert into bsth_c_station(id, station_cod, station_name, db_type, b_jwpoints, g_lonx, g_laty, destroy, radius, shapes_type, versions) " + | |
| 691 | - " values(?,?,?,?,?,?,?,?,?,?,?)", sCode, sCode, stationName, "b", lng + " " + lat, wgsLoc.getLng(), wgsLoc.getLat(), 0, 88, "r", 1); | |
| 692 | - | |
| 693 | - | |
| 694 | - SaveStationRouteDTO sr; | |
| 695 | - int currentNo = -1, | |
| 696 | - no = 100, step = 100; | |
| 697 | - | |
| 698 | - if (prevRouteId == -1) { | |
| 699 | - //起点站 | |
| 700 | - currentNo = no; | |
| 701 | - no += step; | |
| 702 | - } | |
| 703 | - //重新排序路由 | |
| 704 | - for (int i = 0, size = routes.size(); i < size; i++) { | |
| 705 | - sr = routes.get(i); | |
| 706 | - sr.setStationRouteCode(no); | |
| 707 | - no += step; | |
| 708 | - if (sr.getId().intValue() == prevRouteId) { | |
| 709 | - currentNo = no; | |
| 710 | - no += step; | |
| 711 | - } | |
| 712 | - } | |
| 713 | - | |
| 714 | - SaveStationRouteDTO nsr = new SaveStationRouteDTO(); | |
| 715 | - nsr.setLine(lineId); | |
| 716 | - nsr.setLineCode(lineCode); | |
| 717 | - nsr.setDirections(upDown); | |
| 718 | - nsr.setVersions(versions); | |
| 719 | - nsr.setStationRouteCode(currentNo); | |
| 720 | - nsr.setStation(sCode); | |
| 721 | - nsr.setStationCode(sCode + ""); | |
| 722 | - nsr.setStationName(stationName); | |
| 723 | - nsr.setDistances(0d); | |
| 724 | - nsr.setToTime(0d); | |
| 725 | - Date d = new Date(); | |
| 726 | - nsr.setCreateDate(d); | |
| 727 | - nsr.setUpdateDate(d); | |
| 728 | - nsr.setDestroy(0); | |
| 729 | - if (prevRouteId == -1) | |
| 730 | - nsr.setStationMark("B"); | |
| 731 | - else if(routes.size()==1) | |
| 732 | - nsr.setStationMark("E"); | |
| 733 | - | |
| 734 | - //routes.add(sr); | |
| 735 | - | |
| 736 | - //重新标记mark | |
| 737 | - Collections.sort(routes, new StationRouteComp()); | |
| 738 | - for (int i = 0, size = routes.size(); i < size; i++) { | |
| 739 | - routes.get(i).setStationMark("Z"); | |
| 740 | - } | |
| 741 | - if(routes.size() > 0 && prevRouteId!=-1) | |
| 742 | - routes.get(0).setStationMark("B"); | |
| 743 | - if(routes.size() > 1) | |
| 744 | - routes.get(routes.size() - 1).setStationMark("E"); | |
| 745 | - | |
| 746 | - final List<SaveStationRouteDTO> saveList = routes; | |
| 747 | - //insert 新路由 (ID自增) | |
| 748 | - jdbcTemplate.update("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)" | |
| 749 | - , nsr.getLine(), nsr.getStation(), nsr.getStationName(), nsr.getStationRouteCode(), nsr.getLineCode(), nsr.getStationCode(), nsr.getStationMark() | |
| 750 | - , nsr.getDistances(), nsr.getToTime(), nsr.getDestroy(), nsr.getVersions(), nsr.getCreateDate(), nsr.getUpdateDate(), nsr.getDirections()); | |
| 751 | - | |
| 752 | - // update 原路由 | |
| 753 | - jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," + | |
| 754 | - "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" + | |
| 755 | - " where id=?" | |
| 756 | - , new BatchPreparedStatementSetter() { | |
| 757 | - @Override | |
| 758 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 759 | - SaveStationRouteDTO sr = saveList.get(i); | |
| 760 | - ps.setInt(1, sr.getLine()); | |
| 761 | - ps.setLong(2, sr.getStation()); | |
| 762 | - ps.setString(3, sr.getStationName()); | |
| 763 | - ps.setInt(4, sr.getStationRouteCode()); | |
| 764 | - ps.setString(5, sr.getLineCode()); | |
| 765 | - ps.setString(6, sr.getStationCode()); | |
| 766 | - ps.setString(7, sr.getStationMark()); | |
| 767 | - ps.setDouble(8, sr.getDistances()); | |
| 768 | - ps.setDouble(9, sr.getToTime()); | |
| 769 | - ps.setInt(10, sr.getDestroy()); | |
| 770 | - ps.setInt(11, sr.getVersions()); | |
| 771 | - ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime())); | |
| 772 | - ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime())); | |
| 773 | - ps.setInt(14, sr.getDirections()); | |
| 774 | - ps.setInt(15, sr.getId()); | |
| 775 | - } | |
| 776 | - | |
| 777 | - @Override | |
| 778 | - public int getBatchSize() { | |
| 779 | - return saveList.size(); | |
| 780 | - } | |
| 781 | - }); | |
| 782 | - | |
| 783 | - //写一条走向变更记录 | |
| 784 | - jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), lineCode, versions); | |
| 785 | - | |
| 786 | - tran.commit(status); | |
| 787 | - | |
| 788 | - //返回更新之后的数据 | |
| 789 | - List<GeoStation> list = findByUpdown(lineCode, upDown, versions); | |
| 801 | + }); | |
| 790 | 802 | |
| 791 | - rs.put("list", list); | |
| 792 | - rs.put("newStationRouteCode", currentNo); | |
| 793 | - rs.put("status", ResponseCode.SUCCESS); | |
| 794 | - } catch (Exception e) { | |
| 795 | - tran.rollback(status); | |
| 796 | - logger.error("", e); | |
| 797 | - rs.put("status", ResponseCode.ERROR); | |
| 798 | - rs.put("msg", "服务器出现异常"); | |
| 799 | - } | |
| 800 | - return rs; | |
| 801 | 803 | } |
| 802 | 804 | |
| 803 | 805 | private List<GeoStation> findByUpdown(String lineCode, int upDown, int versions) { |
| ... | ... | @@ -827,87 +829,86 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 827 | 829 | public Map<String, Object> destroyStation(GeoStation station) { |
| 828 | 830 | Map<String, Object> rs = new HashMap<>(); |
| 829 | 831 | |
| 830 | - //编程式事务 | |
| 831 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 832 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 833 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 834 | - TransactionStatus status = tran.getTransaction(def); | |
| 835 | - try { | |
| 836 | - String sql = "update bsth_c_ls_stationroute set destroy=1 where id=?"; | |
| 837 | - jdbcTemplate.update(sql, station.getId()); | |
| 838 | - | |
| 839 | - /** | |
| 840 | - * ########## 重新排序路由,标记mark ######### | |
| 841 | - */ | |
| 842 | - sql = "select * from bsth_c_ls_stationroute where line_code='" + station.getLineCode() + "' and directions=" + station.getDirections() + " and destroy=0 and versions=" + station.getVersions(); | |
| 843 | - List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class)); | |
| 844 | - Collections.sort(routes, new StationRouteComp()); | |
| 845 | - | |
| 846 | - int no = 0, | |
| 847 | - step = 100; | |
| 848 | - SaveStationRouteDTO sr; | |
| 849 | - //重新排序路由 | |
| 850 | - for (int i = 0, size = routes.size(); i < size; i++) { | |
| 851 | - sr = routes.get(i); | |
| 852 | - sr.setStationRouteCode(no += step); | |
| 853 | - } | |
| 854 | - | |
| 855 | - for (int i = 0, size = routes.size(); i < size; i++) { | |
| 856 | - routes.get(i).setStationMark("Z"); | |
| 832 | + return transactionTemplate.execute(new TransactionCallback<Map<String, Object>>() { | |
| 833 | + @Override | |
| 834 | + public Map<String, Object> doInTransaction(TransactionStatus status) { | |
| 835 | + try { | |
| 836 | + String sql = "update bsth_c_ls_stationroute set destroy=1 where id=?"; | |
| 837 | + jdbcTemplate.update(sql, station.getId()); | |
| 838 | + | |
| 839 | + /** | |
| 840 | + * ########## 重新排序路由,标记mark ######### | |
| 841 | + */ | |
| 842 | + sql = "select * from bsth_c_ls_stationroute where line_code='" + station.getLineCode() + "' and directions=" + station.getDirections() + " and destroy=0 and versions=" + station.getVersions(); | |
| 843 | + List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class)); | |
| 844 | + Collections.sort(routes, new StationRouteComp()); | |
| 845 | + | |
| 846 | + int no = 0, | |
| 847 | + step = 100; | |
| 848 | + SaveStationRouteDTO sr; | |
| 849 | + //重新排序路由 | |
| 850 | + for (int i = 0, size = routes.size(); i < size; i++) { | |
| 851 | + sr = routes.get(i); | |
| 852 | + sr.setStationRouteCode(no += step); | |
| 853 | + } | |
| 854 | + | |
| 855 | + for (int i = 0, size = routes.size(); i < size; i++) { | |
| 856 | + routes.get(i).setStationMark("Z"); | |
| 857 | + } | |
| 858 | + if(routes.size() > 0) | |
| 859 | + routes.get(0).setStationMark("B"); | |
| 860 | + if(routes.size() > 1) | |
| 861 | + routes.get(routes.size() - 1).setStationMark("E"); | |
| 862 | + | |
| 863 | + final List<SaveStationRouteDTO> saveList = routes; | |
| 864 | + // update 原路由 | |
| 865 | + jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," + | |
| 866 | + "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" + | |
| 867 | + " where id=?" | |
| 868 | + , new BatchPreparedStatementSetter() { | |
| 869 | + @Override | |
| 870 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 871 | + SaveStationRouteDTO sr = saveList.get(i); | |
| 872 | + ps.setInt(1, sr.getLine()); | |
| 873 | + ps.setLong(2, sr.getStation()); | |
| 874 | + ps.setString(3, sr.getStationName()); | |
| 875 | + ps.setInt(4, sr.getStationRouteCode()); | |
| 876 | + ps.setString(5, sr.getLineCode()); | |
| 877 | + ps.setString(6, sr.getStationCode()); | |
| 878 | + ps.setString(7, sr.getStationMark()); | |
| 879 | + ps.setDouble(8, sr.getDistances()); | |
| 880 | + ps.setDouble(9, sr.getToTime()); | |
| 881 | + ps.setInt(10, sr.getDestroy()); | |
| 882 | + ps.setInt(11, sr.getVersions()); | |
| 883 | + ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime())); | |
| 884 | + ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime())); | |
| 885 | + ps.setInt(14, sr.getDirections()); | |
| 886 | + ps.setInt(15, sr.getId()); | |
| 887 | + } | |
| 888 | + | |
| 889 | + @Override | |
| 890 | + public int getBatchSize() { | |
| 891 | + return saveList.size(); | |
| 892 | + } | |
| 893 | + }); | |
| 894 | + | |
| 895 | + //写一条走向变更记录 | |
| 896 | + jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), station.getLineCode(), station.getVersions()); | |
| 897 | + | |
| 898 | + //返回更新之后的数据 | |
| 899 | + List<GeoStation> list = findByUpdown(station.getLineCode(), station.getDirections(), station.getVersions()); | |
| 900 | + rs.put("list", list); | |
| 901 | + rs.put("status", ResponseCode.SUCCESS); | |
| 902 | + } catch (Exception e) { | |
| 903 | + status.setRollbackOnly(); | |
| 904 | + logger.error("", e); | |
| 905 | + rs.put("status", ResponseCode.ERROR); | |
| 906 | + rs.put("msg", "服务器出现异常"); | |
| 907 | + } | |
| 908 | + return rs; | |
| 857 | 909 | } |
| 858 | - if(routes.size() > 0) | |
| 859 | - routes.get(0).setStationMark("B"); | |
| 860 | - if(routes.size() > 1) | |
| 861 | - routes.get(routes.size() - 1).setStationMark("E"); | |
| 862 | - | |
| 863 | - final List<SaveStationRouteDTO> saveList = routes; | |
| 864 | - // update 原路由 | |
| 865 | - jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," + | |
| 866 | - "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" + | |
| 867 | - " where id=?" | |
| 868 | - , new BatchPreparedStatementSetter() { | |
| 869 | - @Override | |
| 870 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 871 | - SaveStationRouteDTO sr = saveList.get(i); | |
| 872 | - ps.setInt(1, sr.getLine()); | |
| 873 | - ps.setLong(2, sr.getStation()); | |
| 874 | - ps.setString(3, sr.getStationName()); | |
| 875 | - ps.setInt(4, sr.getStationRouteCode()); | |
| 876 | - ps.setString(5, sr.getLineCode()); | |
| 877 | - ps.setString(6, sr.getStationCode()); | |
| 878 | - ps.setString(7, sr.getStationMark()); | |
| 879 | - ps.setDouble(8, sr.getDistances()); | |
| 880 | - ps.setDouble(9, sr.getToTime()); | |
| 881 | - ps.setInt(10, sr.getDestroy()); | |
| 882 | - ps.setInt(11, sr.getVersions()); | |
| 883 | - ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime())); | |
| 884 | - ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime())); | |
| 885 | - ps.setInt(14, sr.getDirections()); | |
| 886 | - ps.setInt(15, sr.getId()); | |
| 887 | - } | |
| 888 | - | |
| 889 | - @Override | |
| 890 | - public int getBatchSize() { | |
| 891 | - return saveList.size(); | |
| 892 | - } | |
| 893 | - }); | |
| 894 | - | |
| 895 | - //写一条走向变更记录 | |
| 896 | - jdbcTemplate.update("insert into logger_route_synchro(t, line_code, version) values(?, ?, ?)", System.currentTimeMillis(), station.getLineCode(), station.getVersions()); | |
| 897 | - | |
| 898 | - tran.commit(status); | |
| 910 | + }); | |
| 899 | 911 | |
| 900 | - //返回更新之后的数据 | |
| 901 | - List<GeoStation> list = findByUpdown(station.getLineCode(), station.getDirections(), station.getVersions()); | |
| 902 | - rs.put("list", list); | |
| 903 | - rs.put("status", ResponseCode.SUCCESS); | |
| 904 | - } catch (Exception e) { | |
| 905 | - tran.rollback(status); | |
| 906 | - logger.error("", e); | |
| 907 | - rs.put("status", ResponseCode.ERROR); | |
| 908 | - rs.put("msg", "服务器出现异常"); | |
| 909 | - } | |
| 910 | - return rs; | |
| 911 | 912 | } |
| 912 | 913 | |
| 913 | 914 | @Override | ... | ... |
src/main/java/com/bsth/websocket/handler/SendUtils.java
| ... | ... | @@ -8,6 +8,7 @@ import com.bsth.data.maintenance_plan.MaintenancePlan; |
| 8 | 8 | import com.bsth.data.safe_driv.SafeDriv; |
| 9 | 9 | import com.bsth.entity.directive.D80; |
| 10 | 10 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 11 | +import com.bsth.message.entity.CarErrorStop; | |
| 11 | 12 | import com.bsth.websocket.dto.WsScheduleRealInfo; |
| 12 | 13 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 13 | 14 | import com.fasterxml.jackson.databind.ObjectMapper; |
| ... | ... | @@ -268,4 +269,22 @@ public class SendUtils{ |
| 268 | 269 | logger.error("sendMaintenancePlan", e); |
| 269 | 270 | } |
| 270 | 271 | } |
| 272 | + | |
| 273 | + /** | |
| 274 | + * 将车辆异常停车发送至线调页面 | |
| 275 | + */ | |
| 276 | + public void sendCarErrorStop(CarErrorStop carErrorStop) { | |
| 277 | + Map<String, Object> map = new HashMap<>(); | |
| 278 | + map.put("fn", "carErrorStop"); | |
| 279 | + map.put("data", carErrorStop); | |
| 280 | + ObjectMapper mapper = new ObjectMapper(); | |
| 281 | + | |
| 282 | + try { | |
| 283 | + if (carErrorStop.getLineId() != null) { | |
| 284 | + socketHandler.sendMessageToLine(carErrorStop.getLineId(), mapper.writeValueAsString(map)); | |
| 285 | + } | |
| 286 | + } catch (JsonProcessingException e) { | |
| 287 | + logger.error("sendCarErrorStop", e); | |
| 288 | + } | |
| 289 | + } | |
| 271 | 290 | } | ... | ... |
src/main/resources/application-cloud.properties
| ... | ... | @@ -30,6 +30,13 @@ spring.datasource.hikari.connection-test-query= SELECT 1 |
| 30 | 30 | spring.datasource.hikari.validation-timeout= 3000 |
| 31 | 31 | spring.datasource.hikari.register-mbeans=true |
| 32 | 32 | |
| 33 | +kafka.use= true | |
| 34 | +spring.kafka.consumer.bootstrap-servers= 192.170.100.114:9092,192.170.100.114:9093,192.170.100.114:9094 | |
| 35 | +spring.kafka.consumer.group-id= schedule-system | |
| 36 | +spring.kafka.consumer.auto-offset-reset= latest | |
| 37 | +spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer | |
| 38 | +spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer | |
| 39 | + | |
| 33 | 40 | ## gps client data |
| 34 | 41 | http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all |
| 35 | 42 | ## gateway real data |
| ... | ... | @@ -57,8 +64,8 @@ admin.mail= 3090342880@qq.com |
| 57 | 64 | ## enabled |
| 58 | 65 | enabled.whiteip= true |
| 59 | 66 | |
| 60 | -sso.enabled= false | |
| 61 | -sso.systemcode = SYS0019 | |
| 62 | -sso.http.url.login= http://180.169.154.251:28090/portal/index.html#/login | |
| 63 | -sso.http.url.logout= http://180.169.154.251:18080/information/api/v1/logout | |
| 64 | -sso.http.url.auth= http://180.169.154.251:18080/information/authenticate/authorityAuthentication | |
| 65 | 67 | \ No newline at end of file |
| 68 | +sso.enabled= true | |
| 69 | +sso.systemcode = SYS0023 | |
| 70 | +sso.http.url.login= https://112.64.45.51/portal/index.html#/login | |
| 71 | +sso.http.url.logout= https://112.64.45.51/information/api/v1/logout | |
| 72 | +sso.http.url.auth= https://112.64.45.51/information/authenticate/authorityAuthentication | |
| 66 | 73 | \ No newline at end of file | ... | ... |
src/main/resources/application-dev.properties
| ... | ... | @@ -37,6 +37,13 @@ spring.datasource.hikari.connection-test-query= SELECT 1 |
| 37 | 37 | spring.datasource.hikari.validation-timeout= 3000 |
| 38 | 38 | spring.datasource.hikari.register-mbeans=true |
| 39 | 39 | |
| 40 | +kafka.use= false | |
| 41 | +spring.kafka.consumer.bootstrap-servers= localhost:9092 | |
| 42 | +spring.kafka.consumer.group-id= schedule-system | |
| 43 | +spring.kafka.consumer.auto-offset-reset= latest | |
| 44 | +spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer | |
| 45 | +spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer | |
| 46 | + | |
| 40 | 47 | ## gps client data |
| 41 | 48 | http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all |
| 42 | 49 | ## gateway real data |
| ... | ... | @@ -57,4 +64,10 @@ cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confi |
| 57 | 64 | ## admin mail |
| 58 | 65 | admin.mail= 3090342880@qq.com |
| 59 | 66 | ## enabled |
| 60 | -enabled.whiteip= true | |
| 61 | 67 | \ No newline at end of file |
| 68 | +enabled.whiteip= true | |
| 69 | + | |
| 70 | +sso.enabled= false | |
| 71 | +sso.systemcode = SYS0019 | |
| 72 | +sso.http.url.login= http://180.169.154.251:28090/portal/index.html#/login | |
| 73 | +sso.http.url.logout= http://180.169.154.251:18080/information/api/v1/logout | |
| 74 | +sso.http.url.auth= http://180.169.154.251:18080/information/authenticate/authorityAuthentication | |
| 62 | 75 | \ No newline at end of file | ... | ... |
src/main/resources/application-prod.properties deleted
100644 → 0
| 1 | -server.port=9088 | |
| 2 | - | |
| 3 | -# dubbo����ʹ�ÿ���flag | |
| 4 | -dubbo.use=false | |
| 5 | - | |
| 6 | -#JPA | |
| 7 | -spring.jpa.hibernate.ddl-auto= none | |
| 8 | -spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl | |
| 9 | -spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy | |
| 10 | -spring.jpa.database= MYSQL | |
| 11 | -spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true | |
| 12 | -spring.jpa.show-sql= false | |
| 13 | - | |
| 14 | -#DATABASE | |
| 15 | -spring.datasource.driver-class-name= com.mysql.jdbc.Driver | |
| 16 | -spring.datasource.url= jdbc:mysql://10.10.200.121:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai | |
| 17 | -spring.datasource.username= root | |
| 18 | -spring.datasource.password= root2jsp | |
| 19 | -spring.datasource.type= com.zaxxer.hikari.HikariDataSource | |
| 20 | - | |
| 21 | -#DATASOURCE SETTING | |
| 22 | -spring.datasource.hikari.minimum-idle= 8 | |
| 23 | -spring.datasource.hikari.maximum-pool-size= 100 | |
| 24 | -#spring.datasource.hikari.auto-commit= true | |
| 25 | -spring.datasource.hikari.idle-timeout= 60000 | |
| 26 | -#spring.datasource.hikari.pool-name= HikariPool | |
| 27 | -spring.datasource.hikari.max-lifetime= 1800000 | |
| 28 | -spring.datasource.hikari.connection-timeout= 3000 | |
| 29 | -spring.datasource.hikari.connection-test-query= SELECT 1 | |
| 30 | -spring.datasource.hikari.validation-timeout= 3000 | |
| 31 | -spring.datasource.hikari.register-mbeans=true | |
| 32 | - | |
| 33 | -## gps client data | |
| 34 | -http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all | |
| 35 | -## gateway real data | |
| 36 | -http.gps.real.url= http://10.10.200.79:8080/transport_server/rtgps/ | |
| 37 | -## gateway send directive | |
| 38 | -http.send.directive= http://10.10.200.79:8080/transport_server/message/ | |
| 39 | -## rfid data | |
| 40 | -http.rfid.url= http://10.10.200.82:9000/rfid | |
| 41 | -## wxsb | |
| 42 | -#http.report.url.05= http://192.168.168.154:8088/ygjwsystem_j2ee/clbx/clbx_dd.do | |
| 43 | -#http.report.url.22= http://192.168.168.154:8088/jgjwsystem_j2ee/clbx/clbx_dd.do | |
| 44 | -#http.report.url.26= http://192.168.168.154:8088/nhjwsystem_j2ee/clbx/clbx_dd.do | |
| 45 | -#http.report.url.55= http://192.168.168.154:8088/snjwsystem_j2ee/clbx/clbx_dd.do | |
| 46 | -http.report.url.05= http://116.228.197.222:8081/ygjwsystem_j2ee/clbx/clbx_dd.do | |
| 47 | -http.report.url.22= http://116.247.73.122:9098/jgjwsystem_j2ee/clbx/clbx_dd.do | |
| 48 | -http.report.url.26= http://116.236.141.34:8088/nhjwsystem_j2ee/clbx/clbx_dd.do | |
| 49 | -http.report.url.55= http://180.168.216.248:8088/snjwsystem_j2ee/clbx/clbx_dd.do | |
| 50 | -## http ticketing interface | |
| 51 | -http.ticketing.interface= http://112.64.187.3:1080/gjService/request | |
| 52 | -http.mtplan.interface= https://112.64.45.51/wxk-prod-api/service-api/pdgj/schedule/byinfo | |
| 53 | -## first last generate | |
| 54 | -ms.fl.generate=true | |
| 55 | -## dsm ack interface | |
| 56 | -dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? | |
| 57 | -## cp ack interface | |
| 58 | -cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | |
| 59 | -## admin mail | |
| 60 | -admin.mail= 3090342880@qq.com | |
| 61 | -## enabled | |
| 62 | -enabled.whiteip= true | |
| 63 | 0 | \ No newline at end of file |
src/main/resources/application-test.properties
| ... | ... | @@ -30,6 +30,13 @@ spring.datasource.hikari.connection-test-query= SELECT 1 |
| 30 | 30 | spring.datasource.hikari.validation-timeout= 3000 |
| 31 | 31 | spring.datasource.hikari.register-mbeans=true |
| 32 | 32 | |
| 33 | +kafka.use= true | |
| 34 | +spring.kafka.consumer.bootstrap-servers= 192.170.100.114:9092,192.170.100.114:9093,192.170.100.114:9094 | |
| 35 | +spring.kafka.consumer.group-id= schedule-system | |
| 36 | +spring.kafka.consumer.auto-offset-reset= latest | |
| 37 | +spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer | |
| 38 | +spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer | |
| 39 | + | |
| 33 | 40 | ## gps client data |
| 34 | 41 | http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all |
| 35 | 42 | ## gateway real data |
| ... | ... | @@ -55,4 +62,10 @@ cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confi |
| 55 | 62 | ## admin mail |
| 56 | 63 | admin.mail= 3090342880@qq.com |
| 57 | 64 | ## enabled |
| 58 | -enabled.whiteip= false | |
| 59 | 65 | \ No newline at end of file |
| 66 | +enabled.whiteip= false | |
| 67 | + | |
| 68 | +sso.enabled= true | |
| 69 | +sso.systemcode = SYS0023 | |
| 70 | +sso.http.url.login= https://112.64.45.51/portal/index.html#/login | |
| 71 | +sso.http.url.logout= https://112.64.45.51/information/api/v1/logout | |
| 72 | +sso.http.url.auth= https://112.64.45.51/information/authenticate/authorityAuthentication | |
| 60 | 73 | \ No newline at end of file | ... | ... |
src/main/resources/logback.xml
| ... | ... | @@ -9,8 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 11 | 11 | <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> |
| 12 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level-%msg%n | |
| 13 | - </pattern> | |
| 12 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 14 | 13 | </layout> |
| 15 | 14 | </appender> |
| 16 | 15 | |
| ... | ... | @@ -31,8 +30,7 @@ |
| 31 | 30 | |
| 32 | 31 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 33 | 32 | <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> |
| 34 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level-%msg%n | |
| 35 | - </pattern> | |
| 33 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 36 | 34 | </layout> |
| 37 | 35 | </appender> |
| 38 | 36 | |
| ... | ... | @@ -50,8 +48,7 @@ |
| 50 | 48 | |
| 51 | 49 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 52 | 50 | <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> |
| 53 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level -%msg%n | |
| 54 | - </pattern> | |
| 51 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 55 | 52 | </layout> |
| 56 | 53 | </appender> |
| 57 | 54 | <logger name="com.bsth.filter.AccessLogFilter" level="INFO" |
| ... | ... | @@ -72,8 +69,7 @@ |
| 72 | 69 | </rollingPolicy> |
| 73 | 70 | |
| 74 | 71 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 75 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n | |
| 76 | - </pattern> | |
| 72 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 77 | 73 | </layout> |
| 78 | 74 | </appender> |
| 79 | 75 | <logger name="com.bsth.service.directive.DirectiveServiceImpl" |
| ... | ... | @@ -102,8 +98,7 @@ |
| 102 | 98 | </rollingPolicy> |
| 103 | 99 | |
| 104 | 100 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 105 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n | |
| 106 | - </pattern> | |
| 101 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 107 | 102 | </layout> |
| 108 | 103 | </appender> |
| 109 | 104 | <logger name="com.bsth.service.impl.TrafficManageServiceImpl" |
| ... | ... | @@ -124,8 +119,7 @@ |
| 124 | 119 | </rollingPolicy> |
| 125 | 120 | |
| 126 | 121 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 127 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n | |
| 128 | - </pattern> | |
| 122 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 129 | 123 | </layout> |
| 130 | 124 | </appender> |
| 131 | 125 | <!-- schedule 时刻表操作日志 --> |
| ... | ... | @@ -141,8 +135,7 @@ |
| 141 | 135 | </rollingPolicy> |
| 142 | 136 | |
| 143 | 137 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 144 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n | |
| 145 | - </pattern> | |
| 138 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 146 | 139 | </layout> |
| 147 | 140 | </appender> |
| 148 | 141 | <logger name="com.bsth.service.schedule.impl.TTInfoServiceImpl" |
| ... | ... | @@ -171,7 +164,7 @@ |
| 171 | 164 | <file>${LOG_BASE}/datasync/vehicle/vehicle-data-sync.${taskLogKey}.log</file> |
| 172 | 165 | <append>true</append> |
| 173 | 166 | <encoder charset="UTF-8"> |
| 174 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level-%msg%n</pattern> | |
| 167 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 175 | 168 | </encoder> |
| 176 | 169 | </appender> |
| 177 | 170 | </sift> |
| ... | ... | @@ -234,8 +227,7 @@ |
| 234 | 227 | </rollingPolicy> |
| 235 | 228 | |
| 236 | 229 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 237 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n | |
| 238 | - </pattern> | |
| 230 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 239 | 231 | </layout> |
| 240 | 232 | </appender> |
| 241 | 233 | <logger name="com.bsth.data.gpsdata_v2" |
| ... | ... | @@ -256,8 +248,7 @@ |
| 256 | 248 | </rollingPolicy> |
| 257 | 249 | |
| 258 | 250 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 259 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n | |
| 260 | - </pattern> | |
| 251 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 261 | 252 | </layout> |
| 262 | 253 | </appender> |
| 263 | 254 | <logger name="com.bsth.data.gpsdata.status_manager" |
| ... | ... | @@ -278,8 +269,7 @@ |
| 278 | 269 | </rollingPolicy> |
| 279 | 270 | |
| 280 | 271 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 281 | - <pattern>%d{MM-dd HH:mm:ss.SSS} %-5level -%msg%n | |
| 282 | - </pattern> | |
| 272 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 283 | 273 | </layout> |
| 284 | 274 | </appender> |
| 285 | 275 | <logger name="com.bsth.data.msg_queue.WebSocketPushQueue" |
| ... | ... | @@ -298,8 +288,7 @@ |
| 298 | 288 | </rollingPolicy> |
| 299 | 289 | |
| 300 | 290 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 301 | - <pattern>%d{MM-dd HH:mm:ss.SSS} %-5level -%msg%n | |
| 302 | - </pattern> | |
| 291 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 303 | 292 | </layout> |
| 304 | 293 | </appender> |
| 305 | 294 | <logger name="com.bsth.data.msg_queue.DirectivePushQueue" |
| ... | ... | @@ -325,8 +314,7 @@ |
| 325 | 314 | </rollingPolicy> |
| 326 | 315 | |
| 327 | 316 | <layout class="ch.qos.logback.classic.PatternLayout"> |
| 328 | - <pattern>%d{MM-dd HH:mm:ss.SSS} %-5level -%msg%n | |
| 329 | - </pattern> | |
| 317 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level -%msg%n</pattern> | |
| 330 | 318 | </layout> |
| 331 | 319 | </appender> |
| 332 | 320 | <logger name="com.bsth.data.schedule.thread.SchedulePstThread" | ... | ... |
src/main/resources/static/pages/home.html
| ... | ... | @@ -59,18 +59,14 @@ |
| 59 | 59 | } |
| 60 | 60 | </style> |
| 61 | 61 | <div class="system_change_log"> |
| 62 | - <h2 style="text-indent: 35px;margin: 10px 0 5px;">2023-05-25 更新说明 Changelog</h2> | |
| 62 | + <h2 style="text-indent: 35px;margin: 10px 0 5px;">2023-08-06 更新说明 Changelog</h2> | |
| 63 | 63 | <br><br> |
| 64 | 64 | <ul> |
| 65 | 65 | <li class="sub_title"><h6>线调</h6></li> |
| 66 | - <li><span class="label s_c_change">修改</span>1.保养计划推送异常修复</li> | |
| 67 | - <li><span class="label s_c_change">修改</span>2.临加班次偶尔路牌信息缺失问题修正</li> | |
| 68 | - <li><span class="label s_c_change">修改</span>3.轨迹回放中撤销线路无法回放问题修正</li> | |
| 69 | - <li class="sub_title"><h6>报表</h6></li> | |
| 70 | - <li><span class="label s_c_change">修改</span>1.统计日报导出模板修正</li> | |
| 71 | - <li><span class="label s_c_change">修改</span>2.报表中撤销线路无法查询问题修正</li> | |
| 72 | - <li class="sub_title"><h6>基础信息</h6></li> | |
| 73 | - <li><span class="label s_c_change">修改</span>1.保留特定账户新增人员的功能,并可选择此人信息是否与人事库同步</li> | |
| 66 | + <li><span class="label s_c_change">新增</span>1.线调增加企业信息化运行监控中心推送的异常停车信息</li> | |
| 67 | + <li><span class="label s_c_change">新增</span>2.线调模拟图、地图增加车辆的实时电量信息显示</li> | |
| 68 | + <li class="sub_title"><h6>系统安全</h6></li> | |
| 69 | + <li><span class="label s_c_change">新增</span>1.启用统一门户集群调度的单点登录功能,原登录页面暂时沿用</li> | |
| 74 | 70 | </ul> |
| 75 | 71 | |
| 76 | 72 | </div> | ... | ... |
src/main/resources/static/real_control_v2/fragments/home/tooltip.html
| 1 | -<div> | |
| 2 | - <script id="tooltip_gps_temp" type="text/html"> | |
| 3 | - <div class="tooltip" data-id="{{deviceId}}"> | |
| 4 | - <div class="tooltip-container"> | |
| 5 | - | |
| 6 | - <div class="cont-text-panel home_svg_tips"> | |
| 7 | - <div class="title"> | |
| 8 | - <a href="javascript:;" data-for="station" class="tip_modal"> | |
| 9 | - {{nbbm}} | |
| 10 | - {{if abnormalStatus == 'outBounds'}} | |
| 11 | - <span class="abnormal-text">越界</span> | |
| 12 | - {{else if abnormalStatus == 'overspeed'}} | |
| 13 | - <span class="abnormal-text">超速</span> | |
| 14 | - {{else if abnormalStatus == 'gps-offline'}} | |
| 15 | - <span class="abnormal-text">GPS掉线</span> | |
| 16 | - {{else if abnormalStatus == 'offline'}} | |
| 17 | - <span class="abnormal-text">已离线</span> | |
| 18 | - {{/if}} | |
| 19 | - </a> | |
| 20 | - </div> | |
| 21 | - <div> | |
| 22 | - <span class="field">车牌号:</span>{{plateNo}} | |
| 23 | - </div> | |
| 24 | - <div title="{{stationName}}"> | |
| 25 | - <span class="field">站点:</span>{{stationName}} | |
| 26 | - </div> | |
| 27 | - <!-- <div> | |
| 28 | - {{lineName}} -{{if upDown==0}}上行{{else}}下行{{/if}} | |
| 29 | - </div> --> | |
| 30 | - <div> | |
| 31 | - <span class="field">设备:</span>{{deviceId}} | |
| 32 | - </div> | |
| 33 | - <!--<div> | |
| 34 | - <span class="field">坐标:</span>{{lon}} {{lat}} | |
| 35 | - </div>--> | |
| 36 | - {{if sch!=null}} | |
| 37 | - <div> | |
| 38 | - <span class="field">驾驶员:</span>{{sch.jGh}}/{{sch.jName}} | |
| 39 | - </div> | |
| 40 | - {{if sch.sGh!=null && sch.sGh!=""}} | |
| 41 | - <div> | |
| 42 | - <span class="field">售票员:</span>{{sch.sGh}}/{{sch.sName}} | |
| 43 | - </div> | |
| 44 | - {{/if}} | |
| 45 | - {{/if}} | |
| 46 | - <div> | |
| 47 | - <span class="field">速度:</span>{{speed>99?'..':speed}}</div> | |
| 48 | - <div> | |
| 49 | - <span class="field">时间:</span>{{dateStr}}</div> | |
| 50 | - {{if expectStopTime!=null}} | |
| 51 | - <div> | |
| 52 | - 预计 {{expectStopTime}} 分钟到达终点</div> | |
| 53 | - {{/if}} | |
| 54 | - </div> | |
| 55 | - | |
| 56 | - <div class="tip_map_wrap"></div> | |
| 57 | - </div> | |
| 58 | - </div> | |
| 59 | - </script> | |
| 60 | - | |
| 61 | - <script id="tooltip_multi_gps_temp" type="text/html"> | |
| 62 | - <div class="multi-tooltip-wrap"> | |
| 63 | - {{each list as gps i}} | |
| 64 | - <div class="tooltip multi-tooltip" > | |
| 65 | - <div class="tooltip-container"> | |
| 66 | - <div class="title"> | |
| 67 | - <a href="javascript:;" data-for="station" class="tip_modal"> | |
| 68 | - {{gps.nbbm}} | |
| 69 | - </a> | |
| 70 | - </div> | |
| 71 | - <div> | |
| 72 | - <span class="field">车牌号:</span>{{gps.plateNo}} | |
| 73 | - </div> | |
| 74 | - <div> | |
| 75 | - <span class="field">站点:</span>{{gps.stationName}} | |
| 76 | - </div> | |
| 77 | - <div> | |
| 78 | - <span class="field">设备:</span>{{gps.deviceId}} | |
| 79 | - </div> | |
| 80 | - <div style="color: #747272;"> | |
| 81 | - {{gps.dateStr}} | |
| 82 | - </div> | |
| 83 | - </div> | |
| 84 | - </div> | |
| 85 | - {{/each}} | |
| 86 | - </div> | |
| 87 | - <div class="tip_map_wrap multi"></div> | |
| 88 | - </script> | |
| 89 | - | |
| 90 | - | |
| 91 | - <script id="tooltip_multi_gps_cont_temp" type="text/html"> | |
| 92 | - <div class="tooltip-container"> | |
| 93 | - <div class="title"> | |
| 94 | - <a href="javascript:;" data-for="station" class="tip_modal"> | |
| 95 | - {{nbbm}} | |
| 96 | - </a> | |
| 97 | - </div> | |
| 98 | - <div> | |
| 99 | - <span class="field">站点:</span>{{stationName}} | |
| 100 | - </div> | |
| 101 | - <div> | |
| 102 | - <span class="field">设备:</span>{{deviceId}} | |
| 103 | - </div> | |
| 104 | - <div style="color: #747272;"> | |
| 105 | - {{gps.dateStr}} | |
| 106 | - </div> | |
| 107 | - </div> | |
| 108 | - </script> | |
| 109 | -</div> | |
| 1 | +<div> | |
| 2 | + <script id="tooltip_gps_temp" type="text/html"> | |
| 3 | + <div class="tooltip" data-id="{{deviceId}}"> | |
| 4 | + <div class="tooltip-container"> | |
| 5 | + | |
| 6 | + <div class="cont-text-panel home_svg_tips"> | |
| 7 | + <div class="title"> | |
| 8 | + <a href="javascript:;" data-for="station" class="tip_modal"> | |
| 9 | + {{nbbm}} | |
| 10 | + {{if abnormalStatus == 'outBounds'}} | |
| 11 | + <span class="abnormal-text">越界</span> | |
| 12 | + {{else if abnormalStatus == 'overspeed'}} | |
| 13 | + <span class="abnormal-text">超速</span> | |
| 14 | + {{else if abnormalStatus == 'gps-offline'}} | |
| 15 | + <span class="abnormal-text">GPS掉线</span> | |
| 16 | + {{else if abnormalStatus == 'offline'}} | |
| 17 | + <span class="abnormal-text">已离线</span> | |
| 18 | + {{/if}} | |
| 19 | + </a> | |
| 20 | + </div> | |
| 21 | + <div> | |
| 22 | + <span class="field">车牌号:</span>{{plateNo}} | |
| 23 | + </div> | |
| 24 | + <div title="{{stationName}}"> | |
| 25 | + <span class="field">站点:</span>{{stationName}} | |
| 26 | + </div> | |
| 27 | + <!-- <div> | |
| 28 | + {{lineName}} -{{if upDown==0}}上行{{else}}下行{{/if}} | |
| 29 | + </div> --> | |
| 30 | + <div> | |
| 31 | + <span class="field">设备:</span>{{deviceId}} | |
| 32 | + </div> | |
| 33 | + <!--<div> | |
| 34 | + <span class="field">坐标:</span>{{lon}} {{lat}} | |
| 35 | + </div>--> | |
| 36 | + {{if sch!=null}} | |
| 37 | + <div> | |
| 38 | + <span class="field">驾驶员:</span>{{sch.jGh}}/{{sch.jName}} | |
| 39 | + </div> | |
| 40 | + {{if sch.sGh!=null && sch.sGh!=""}} | |
| 41 | + <div> | |
| 42 | + <span class="field">售票员:</span>{{sch.sGh}}/{{sch.sName}} | |
| 43 | + </div> | |
| 44 | + {{/if}} | |
| 45 | + {{/if}} | |
| 46 | + <div> | |
| 47 | + <span class="field">速度:</span>{{speed>99?'..':speed}}</div> | |
| 48 | + {{if energy == 0}} | |
| 49 | + <div><span class="field">电量:</span><span style="color: red;">{{energy}}% (异常)</span></div> | |
| 50 | + {{/if}} | |
| 51 | + {{if energy > 0}} | |
| 52 | + <div><span class="field">电量:</span>{{energy}}%</div> | |
| 53 | + {{/if}} | |
| 54 | + <div> | |
| 55 | + <span class="field">时间:</span>{{dateStr}}</div> | |
| 56 | + {{if expectStopTime!=null}} | |
| 57 | + <div> | |
| 58 | + 预计 {{expectStopTime}} 分钟到达终点</div> | |
| 59 | + {{/if}} | |
| 60 | + </div> | |
| 61 | + | |
| 62 | + <div class="tip_map_wrap"></div> | |
| 63 | + </div> | |
| 64 | + </div> | |
| 65 | + </script> | |
| 66 | + | |
| 67 | + <script id="tooltip_multi_gps_temp" type="text/html"> | |
| 68 | + <div class="multi-tooltip-wrap"> | |
| 69 | + {{each list as gps i}} | |
| 70 | + <div class="tooltip multi-tooltip" > | |
| 71 | + <div class="tooltip-container"> | |
| 72 | + <div class="title"> | |
| 73 | + <a href="javascript:;" data-for="station" class="tip_modal"> | |
| 74 | + {{gps.nbbm}} | |
| 75 | + </a> | |
| 76 | + </div> | |
| 77 | + <div> | |
| 78 | + <span class="field">车牌号:</span>{{gps.plateNo}} | |
| 79 | + </div> | |
| 80 | + <div> | |
| 81 | + <span class="field">站点:</span>{{gps.stationName}} | |
| 82 | + </div> | |
| 83 | + <div> | |
| 84 | + <span class="field">设备:</span>{{gps.deviceId}} | |
| 85 | + </div> | |
| 86 | + <div style="color: #747272;"> | |
| 87 | + {{gps.dateStr}} | |
| 88 | + </div> | |
| 89 | + </div> | |
| 90 | + </div> | |
| 91 | + {{/each}} | |
| 92 | + </div> | |
| 93 | + <div class="tip_map_wrap multi"></div> | |
| 94 | + </script> | |
| 95 | + | |
| 96 | + | |
| 97 | + <script id="tooltip_multi_gps_cont_temp" type="text/html"> | |
| 98 | + <div class="tooltip-container"> | |
| 99 | + <div class="title"> | |
| 100 | + <a href="javascript:;" data-for="station" class="tip_modal"> | |
| 101 | + {{nbbm}} | |
| 102 | + </a> | |
| 103 | + </div> | |
| 104 | + <div> | |
| 105 | + <span class="field">站点:</span>{{stationName}} | |
| 106 | + </div> | |
| 107 | + <div> | |
| 108 | + <span class="field">设备:</span>{{deviceId}} | |
| 109 | + </div> | |
| 110 | + <div style="color: #747272;"> | |
| 111 | + {{gps.dateStr}} | |
| 112 | + </div> | |
| 113 | + </div> | |
| 114 | + </script> | |
| 115 | +</div> | ... | ... |
src/main/resources/static/real_control_v2/js/platform/carErrorStop.js
0 → 100644
| 1 | +/** | |
| 2 | + * 车辆异常停车相关 | |
| 3 | + */ | |
| 4 | +var gb_carerrorstop = (function () { | |
| 5 | + var $wrap = $('.multi_plat_msg_pop_wrap'); | |
| 6 | + var max = 5; | |
| 7 | + | |
| 8 | + var pop = function (data) { | |
| 9 | + //时间格式化 | |
| 10 | + var stm = moment(data.bysj); | |
| 11 | + data.timeStr = stm.format('HH时mm分'); | |
| 12 | + data.dateTimeStr = stm.format('YYYY-MM-DD HH:mm') | |
| 13 | + data.type = 'ces'; | |
| 14 | + | |
| 15 | + var htmlStr = template('ces_plat_msg_template', data); | |
| 16 | + var items = $wrap.find('.multi_plat_msg_pop'), len = items.length; | |
| 17 | + if (len >= max) | |
| 18 | + $wrap.find('.multi_plat_msg_pop:lt(' + (len - max) + ')').remove(); | |
| 19 | + | |
| 20 | + $wrap.append(htmlStr); | |
| 21 | + }; | |
| 22 | + | |
| 23 | + return { | |
| 24 | + pop: pop | |
| 25 | + } | |
| 26 | +})(); | |
| 0 | 27 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/js/safe_driv/safeDriv.js
| ... | ... | @@ -90,6 +90,16 @@ var gb_safe_driv = (function () { |
| 90 | 90 | window.localStorage.setItem('mtPlanModal', JSON.stringify(data)); |
| 91 | 91 | open_modal('/real_control_v2/fragments/multi_plat_msg/mt_plan_modal.html', {}, {center: false, bgclose: false}); |
| 92 | 92 | break; |
| 93 | + // 企业信息化运行监控中心 | |
| 94 | + case 'ces': | |
| 95 | + var data = { nbbm: $(this).data('zbh'), clZbh: $(this).data('zbh'), start: $(this).data('start'), fcsjActualTime: $(this).data('start'), end: $(this).data('end'), zdsjActualTime: $(this).data('end'),}; | |
| 96 | + $(this).remove(); | |
| 97 | + if(!$('.layui-layer.play_back-layer').is(':visible')){ | |
| 98 | + gb_map_play_back.initParams(data); | |
| 99 | + } else { | |
| 100 | + gb_map_play_back.setParam(data); | |
| 101 | + } | |
| 102 | + break; | |
| 93 | 103 | default: |
| 94 | 104 | break; |
| 95 | 105 | } | ... | ... |
src/main/resources/static/real_control_v2/js/websocket/sch_websocket.js
| ... | ... | @@ -200,6 +200,10 @@ var gb_sch_websocket = (function () { |
| 200 | 200 | gb_mt_plan.pop(msg.data); |
| 201 | 201 | }; |
| 202 | 202 | |
| 203 | + var carErrorStop = function (msg){ | |
| 204 | + gb_carerrorstop.pop(msg.data); | |
| 205 | + }; | |
| 206 | + | |
| 203 | 207 | var msgHandle = { |
| 204 | 208 | report80: report80, |
| 205 | 209 | faChe: faChe, |
| ... | ... | @@ -213,7 +217,8 @@ var gb_sch_websocket = (function () { |
| 213 | 217 | auto_wdtz: autoWdtz, |
| 214 | 218 | rfid: refreshRfid, |
| 215 | 219 | contingencyPlan: contingencyPlan, |
| 216 | - maintenancePlan: maintenancePlan | |
| 220 | + maintenancePlan: maintenancePlan, | |
| 221 | + carErrorStop: carErrorStop | |
| 217 | 222 | }; |
| 218 | 223 | |
| 219 | 224 | function currentSecond() { | ... | ... |
src/main/resources/static/real_control_v2/main.html
| ... | ... | @@ -230,6 +230,7 @@ |
| 230 | 230 | <div class="multi_plat_msg_pop uk-animation-slide-bottom" data-type="{{type}}" data-nbbm="{{clzbh}}" data-type="{{yczltype}}" data-title="{{clzbh}} {{timeStr}} {{ycztText}}" data-url="{{url}}" data-ts="{{ts}}"> |
| 231 | 231 | <div> |
| 232 | 232 | <span class="title">异常 {{clzbh}}</span> |
| 233 | + <br/> | |
| 233 | 234 | <span class="text"> {{timeStr}} 出现违规驾驶({{ycztText}})</span> |
| 234 | 235 | <span class="desc">--安全驾驶监管平台</span> |
| 235 | 236 | </div> |
| ... | ... | @@ -239,6 +240,7 @@ |
| 239 | 240 | <div class="multi_plat_msg_pop uk-animation-slide-bottom" data-type="{{type}}" data-id="{{id}}" data-title="{{responseState}}" data-ts="{{ts}}"> |
| 240 | 241 | <div> |
| 241 | 242 | <span class="title">应急预案</span> |
| 243 | + <br/> | |
| 242 | 244 | <span class="text"> {{instructionsContent}}</span> |
| 243 | 245 | <span class="desc">--应急预案平台</span> |
| 244 | 246 | </div> |
| ... | ... | @@ -248,15 +250,27 @@ |
| 248 | 250 | <div class="multi_plat_msg_pop uk-animation-slide-bottom" style="background-color: #0aae0a;" data-type="{{type}}" data-confirm="维修保养计划" data-line="{{line}}" data-zbh="{{zbh}}" data-bydj="{{bydj}}" data-bysj="{{dateTimeStr}}" data-bydd="{{bydd}}"> |
| 249 | 251 | <div> |
| 250 | 252 | <span class="title">维修保养计划</span> |
| 253 | + <br/> | |
| 251 | 254 | <span class="text"> {{zbh}} {{timeStr}} 进场保养</span> |
| 252 | 255 | <span class="desc">--浦东公交维修库</span> |
| 253 | 256 | </div> |
| 254 | 257 | </div> |
| 255 | 258 | </script> |
| 259 | +<script id="ces_plat_msg_template" type="text/html"> | |
| 260 | + <div class="multi_plat_msg_pop uk-animation-slide-bottom" style="background-color: #00ccff;" data-type="{{type}}" data-zbh="{{nbbm}}" data-start="{{startTimestamp}}" data-end="{{endTimestamp}}"> | |
| 261 | + <div> | |
| 262 | + <span class="title">车辆异常停车</span> | |
| 263 | + <br/> | |
| 264 | + <span class="text"> {{line}} {{nbbm}} 在 {{address}} 异常停车</span> | |
| 265 | + <span class="desc">--企业信息化运行监控中心</span> | |
| 266 | + </div> | |
| 267 | + </div> | |
| 268 | +</script> | |
| 256 | 269 | |
| 257 | 270 | <script src="/real_control_v2/js/safe_driv/safeDriv.js" merge="custom_js"></script> |
| 258 | 271 | <script src="/real_control_v2/js/con_plan/conPlan.js" merge="custom_js"></script> |
| 259 | 272 | <script src="/real_control_v2/js/mt_plan/mtPlan.js" merge="custom_js"></script> |
| 273 | +<script src="/real_control_v2/js/platform/carErrorStop.js" merge="custom_js"></script> | |
| 260 | 274 | <!-- #### 安全驾驶 end ### --> |
| 261 | 275 | |
| 262 | 276 | <!-- 打电话 --> | ... | ... |
src/main/resources/static/real_control_v2/mapmonitor/fragments/map_infowindow.html
| ... | ... | @@ -32,7 +32,12 @@ |
| 32 | 32 | <p>角度:{{direction}}</p> |
| 33 | 33 | <p>经度:{{lon}}</p> |
| 34 | 34 | <p>纬度:{{lat}}</p> |
| 35 | - | |
| 35 | + {{if energy == 0}} | |
| 36 | + <div><span class="field">电量:</span><span style="color: red;">{{energy}}% (异常)</span></div> | |
| 37 | + {{/if}} | |
| 38 | + {{if energy > 0}} | |
| 39 | + <p>电量:{{energy}}%</p> | |
| 40 | + {{/if}} | |
| 36 | 41 | <p class="date-str">{{dateStr}}</p> |
| 37 | 42 | <hr> |
| 38 | 43 | {{if expectStopTime!=null}} |
| ... | ... | @@ -40,7 +45,7 @@ |
| 40 | 45 | {{/if}} |
| 41 | 46 | <a href="javascript:;" style="float: left;" onclick="javascript:window.open('http://211.95.61.66:9020/transport_server/dvr_monitor2.html?userid=4&zbh={{nbbm}}');">DVR</a> |
| 42 | 47 | {{if dvrcode != null}}<a href="W9:1@139.196.29.203@?method=call&1111:{{dvrcode}}" style="margin-left: 50px;" >拨打电话</a>{{/if}} |
| 43 | - <a href="javascript:;" style="float: right;" onclick="javascript:gb_map_play_back.initParams('{{deviceId}}', '{{nbbm}}');">轨迹回放</a> | |
| 48 | + <a href="javascript:;" style="float: right;" onclick="javascript:gb_map_play_back.initParams({deviceId: '{{deviceId}}', nbbm: '{{nbbm}}'});">轨迹回放</a> | |
| 44 | 49 | </div> |
| 45 | 50 | </script> |
| 46 | 51 | ... | ... |
src/main/resources/static/real_control_v2/mapmonitor/fragments/playback_v3/left.html
| 1 | -<div class="play-back-form bg-grey"> | |
| 2 | - <form class="uk-form uk-form-horizontal"> | |
| 3 | - <div class="uk-form-row"> | |
| 4 | - <label class="uk-form-label">车辆编码</label> | |
| 5 | - <div class="uk-form-controls"> | |
| 6 | - <div class="uk-autocomplete uk-form autocomplete-nbbm" style="width: calc(100% - 60px)"> | |
| 7 | - <div class="uk-autocomplete uk-form autocomplete-nbbm"> | |
| 8 | - <input name="nbbm" required/> | |
| 9 | - </div> | |
| 10 | - </div> | |
| 11 | - <a style="color: #009688;margin-left: 5px;" data-uk-offcanvas="{target:'#carSelectOffcanvas'}">选择</a> | |
| 12 | - </div> | |
| 13 | - </div> | |
| 14 | - | |
| 15 | - <div class="uk-form-row"> | |
| 16 | - <label class="uk-form-label">开始时间</label> | |
| 17 | - <div class="uk-form-controls"> | |
| 18 | - <input class="flatpickr_input" name="startTime" required/> | |
| 19 | - </div> | |
| 20 | - </div> | |
| 21 | - | |
| 22 | - <div class="uk-form-row"> | |
| 23 | - <label class="uk-form-label">结束时间</label> | |
| 24 | - <div class="uk-form-controls"> | |
| 25 | - <input class="flatpickr_input" name="endTime" required/> | |
| 26 | - </div> | |
| 27 | - </div> | |
| 28 | - <div style="text-align: center;margin-top: 20px;"> | |
| 29 | - <button class="uk-button uk-button-large uk-button-link p_back_form_submit" type="submit"><i | |
| 30 | - class="uk-icon-search"> </i> 搜索轨迹 | |
| 31 | - </button> | |
| 32 | - </div> | |
| 33 | - </form> | |
| 34 | - <div class="form-error-text"> | |
| 35 | - <a href="" class="uk-close uk-close-alt"></a><span></span> | |
| 36 | - </div> | |
| 37 | -</div> | |
| 38 | - | |
| 39 | -<!-- 异常table --> | |
| 40 | -<div class="play-back-abnormal_table_wrap bg-grey"> | |
| 41 | - <div class="pback_abnormal_table_panel" | |
| 42 | - style="height: 100%;overflow: auto;"> | |
| 43 | - <div class="ct_table abnormal_table" style="height: calc(100% - 30px);width: 500px;background: #e6e6e6;"> | |
| 44 | - <div class="ct_table_head" style="background: #e6e6e6;"> | |
| 45 | - <dl> | |
| 46 | - <dt>异常信息</dt> | |
| 47 | - <dt>开始时间</dt> | |
| 48 | - <dt>结束时间</dt> | |
| 49 | - <dt>所在路段</dt> | |
| 50 | - </dl> | |
| 51 | - </div> | |
| 52 | - <div class="ct_table_body"> | |
| 53 | - </div> | |
| 54 | - </div> | |
| 55 | - </div> | |
| 56 | -</div> | |
| 57 | - | |
| 58 | -<!-- 行车轨迹和到离站 --> | |
| 59 | -<div class="play-back-trail-info-wrap bg-grey"> | |
| 60 | - <div class="uk-width-medium-1-1"> | |
| 61 | - | |
| 62 | - <ul class="uk-subnav uk-subnav-pill" data-uk-switcher="{connect:'#playBackV3TrailCont', swiping: false}" style="padding-left: 12px;"> | |
| 63 | - <li class="uk-active"><a>行车轨迹</a></li> | |
| 64 | - <li><a>到离站信息</a></li> | |
| 65 | - </ul> | |
| 66 | - <span class="sum_mileage_span"></span> | |
| 67 | - | |
| 68 | - <ul class="uk-switcher uk-margin real_gps_info_tab_content" id="playBackV3TrailCont"> | |
| 69 | - <li class="uk-active" style="height: 100%;"> | |
| 70 | - <div class="trail-info-wrap" > | |
| 71 | - <div class="ct_table trail-info-table" style="height: calc(100% - 30px);"> | |
| 72 | - <div class="ct_table_head" style="background: #e6e6e6;"> | |
| 73 | - <dl> | |
| 74 | - <dt>时间</dt> | |
| 75 | - <dt>速度</dt> | |
| 76 | - <dt>上下行</dt> | |
| 77 | - <dt>所在路段</dt> | |
| 78 | - <dt>车载线路</dt> | |
| 79 | - </dl> | |
| 80 | - </div> | |
| 81 | - <div class="ct_table_body"></div> | |
| 82 | - </div> | |
| 83 | - </div> | |
| 84 | - </li> | |
| 85 | - <!-- 到离站数据 --> | |
| 86 | - <li style="height: 100%;"> | |
| 87 | - <div class="inout_table_wrap" style="height: 100%;overflow: auto;"> | |
| 88 | - <div class="ct_table" style="height: calc(100% - 30px);"> | |
| 89 | - <div class="ct_table_head" style="background: #e6e6e6;"> | |
| 90 | - <dl> | |
| 91 | - <dt>站点</dt> | |
| 92 | - <dt>进站时间</dt> | |
| 93 | - <dt>离站时间</dt> | |
| 94 | - <dt>上客</dt> | |
| 95 | - <dt>下客</dt> | |
| 96 | - </dl> | |
| 97 | - </div> | |
| 98 | - <div class="ct_table_body"> | |
| 99 | - </div> | |
| 100 | - </div> | |
| 101 | - </div> | |
| 102 | - </li> | |
| 103 | - </ul> | |
| 104 | - </div> | |
| 105 | -</div> | |
| 106 | - | |
| 107 | -<!-- 车辆选择抽屉 --> | |
| 108 | -<div id="carSelectOffcanvas" class="uk-offcanvas"> | |
| 109 | - <div class="uk-offcanvas-bar"> | |
| 110 | - <div class="uk-panel offcanvas-cont"> | |
| 111 | - <div class="spinner"> | |
| 112 | - <div class="rect1"></div> | |
| 113 | - <div class="rect2"></div> | |
| 114 | - <div class="rect3"></div> | |
| 115 | - <div class="rect4"></div> | |
| 116 | - <div class="rect5"></div> | |
| 117 | - </div> | |
| 118 | - </div> | |
| 119 | - </div> | |
| 120 | -</div> | |
| 121 | - | |
| 122 | -<script> | |
| 123 | - var gb_playback_v3_leftpanel = (function () { | |
| 124 | - | |
| 125 | - var leftWrap = '.gps-play-back-panel-v3>div.left-panel'; | |
| 126 | - var f = $('.play-back-form form', leftWrap); | |
| 127 | - var params; | |
| 128 | - | |
| 129 | - $(leftWrap).one('init-left-dom', function (e, data) { | |
| 130 | - e.stopPropagation(); | |
| 131 | - params = data; | |
| 132 | - | |
| 133 | - //初始化表单 | |
| 134 | - initForm(); | |
| 135 | - | |
| 136 | - //固定表头 | |
| 137 | - gb_ct_table.fixedHead($('.trail-info-wrap', leftWrap)); | |
| 138 | - gb_ct_table.fixedHead($('.pback_abnormal_table_panel', leftWrap)); | |
| 139 | - gb_ct_table.fixedHead($('.inout_table_wrap', leftWrap)); | |
| 140 | - //滚动条 | |
| 141 | - createScrollbar(); | |
| 142 | - | |
| 143 | - //show title | |
| 144 | - /*UIkit.notify("设备端自身标识为无效的GPS点位,将不会再进入回放通路", { | |
| 145 | - status: 'info' | |
| 146 | - });*/ | |
| 147 | - }); | |
| 148 | - | |
| 149 | - /** | |
| 150 | - * 初始化表单 | |
| 151 | - */ | |
| 152 | - var initForm = function () { | |
| 153 | - if (params.nbbm) | |
| 154 | - $('[name=nbbm]', f).val(params.nbbm); | |
| 155 | - var st = moment().subtract(2, 'hour'); | |
| 156 | - if (params.st) | |
| 157 | - st = moment(data.st, 'YYYY-MM-DD HH:mm'); | |
| 158 | - $('[name=startTime]', f).val(st.format('YYYY-MM-DD HH:mm')); | |
| 159 | - var et = moment(); | |
| 160 | - if (params.et) | |
| 161 | - et = moment(data.et, 'YYYY-MM-DD HH:mm'); | |
| 162 | - $('[name=endTime]', f).val(et.format('YYYY-MM-DD HH:mm')); | |
| 163 | - | |
| 164 | - //初始化 flatpickr | |
| 165 | - var sConf = $.extend(gb_common.flatpickrDateTimeConfig, { | |
| 166 | - defaultHour: st.format('HH'), | |
| 167 | - defaultMinute: st.format('mm') | |
| 168 | - }); | |
| 169 | - var eConf = $.extend(gb_common.flatpickrDateTimeConfig, { | |
| 170 | - defaultHour: et.format('HH'), | |
| 171 | - defaultMinute: et.format('mm') | |
| 172 | - }); | |
| 173 | - flatpickr(leftWrap + ' .flatpickr_input[name=startTime]', sConf); | |
| 174 | - flatpickr(leftWrap + ' .flatpickr_input[name=endTime]', eConf); | |
| 175 | - }; | |
| 176 | - | |
| 177 | - //搜索轨迹 | |
| 178 | - var ONE_DAY = 60 * 60 * 24; | |
| 179 | - var MIN_SPACE = 60; | |
| 180 | - $('button[type=submit]', f).on('click', function (e) { | |
| 181 | - e.stopPropagation(); | |
| 182 | - try { | |
| 183 | - var data = f.serializeJSON(); | |
| 184 | - | |
| 185 | - //校验时间间隔 | |
| 186 | - var fs = 'YYYY-MM-DD HH:mm'; | |
| 187 | - var st = parseInt(moment(data.startTime, fs).format('X')); | |
| 188 | - var et = parseInt(moment(data.endTime, fs).format('X')); | |
| 189 | - data.st = st; | |
| 190 | - data.et = et; | |
| 191 | - | |
| 192 | - if (!data.nbbm || !data.nbbm.trim()) | |
| 193 | - notify_err('你必须输入车辆编码'); | |
| 194 | - else if (!data.startTime || !data.startTime.trim()) | |
| 195 | - notify_err('你必须输入开始时间'); | |
| 196 | - else if (!data.endTime || !data.endTime.trim()) | |
| 197 | - notify_err('你必须输入结束时间'); | |
| 198 | - else if (et < st) | |
| 199 | - notify_err('结束时间不能小于开始时间!'); | |
| 200 | - else if ((et - st) > ONE_DAY) | |
| 201 | - notify_err('查询范围不能超过24小时!'); | |
| 202 | - else if ((et - st) < MIN_SPACE) | |
| 203 | - notify_err('最小间隔1分钟!'); | |
| 204 | - else { | |
| 205 | - show_load_btn(this); | |
| 206 | - //查询数据 | |
| 207 | - get_server_trail_data(data, function (rs) { | |
| 208 | - //线路名称 | |
| 209 | - var code2Name = gb_data_basic.lineCode2NameAll(); | |
| 210 | - $.each(rs.list, function () { | |
| 211 | - this.lineName = code2Name[this.lineId]; | |
| 212 | - this.nbbm = data.nbbm; | |
| 213 | - }); | |
| 214 | - //排序 | |
| 215 | - rs.list.sort(function (a, b) { | |
| 216 | - return parseInt((a.ts - b.ts) + '' + (a.stop_no - b.stop_no)); | |
| 217 | - }); | |
| 218 | - fillTrailTable(rs.list);//填充行车轨迹表格 | |
| 219 | - fillArivalStationTable(rs.list);//填充到离站表格 | |
| 220 | - $('.sum_mileage_span', leftWrap).text('共约 ' + rs.sumMileage + ' 公里'); | |
| 221 | - fillAbnormalTable(rs['outboundList'], rs['speedList'],rs['gpsInvalid'],rs['gpslineSwitch'],rs['lineVerson'],rs['gpslonlatex']);//填充异常信息表格 | |
| 222 | - //准备播放 | |
| 223 | - rs.arrivalData = arrivalData; | |
| 224 | - $('.gps-play-back-panel-v3>div.right-panel .play-back-tools-wrap').trigger('ready-to-play', rs); | |
| 225 | - | |
| 226 | - //更新滚动条 | |
| 227 | - resetScrollbar(); | |
| 228 | - | |
| 229 | - /** | |
| 230 | - * 显示设备更换信息 | |
| 231 | - */ | |
| 232 | - var deviceStr='', fs='YYYY-MM-DD HH:mm'; | |
| 233 | - for(var i=0,dc;dc=rs.dcs[i++];){ | |
| 234 | - deviceStr+=dc.device + ','; | |
| 235 | - dc.stStr = dc.st>0?moment(dc.st).format(fs):''; | |
| 236 | - dc.etStr = dc.et>0?moment(dc.et).format(fs):''; | |
| 237 | - } | |
| 238 | - deviceStr=deviceStr.substr(0, deviceStr.length-1); | |
| 239 | - | |
| 240 | - $('.play-back-form>.dynamic_devices', leftWrap).remove(); | |
| 241 | - $('.play-back-form>.dynamic_devices_dropdown', leftWrap).remove(); | |
| 242 | - var htmlStr = template('pbv3_park_form_devices-temp', {deviceStr:deviceStr}), | |
| 243 | - htmlStr2 = template('pbv3_park_devices_dropdown-temp', {dcs:rs.dcs}); | |
| 244 | - $('.play-back-form', leftWrap).append(htmlStr).append(htmlStr2); | |
| 245 | - }); | |
| 246 | - } | |
| 247 | - } catch (e) { | |
| 248 | - console.log(e); | |
| 249 | - } | |
| 250 | - return false; | |
| 251 | - }); | |
| 252 | - | |
| 253 | - function resetScrollbar() { | |
| 254 | - $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0); | |
| 255 | - $('.trail-info-wrap', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0); | |
| 256 | - $('.inout_table_wrap', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0); | |
| 257 | - } | |
| 258 | - | |
| 259 | - function destoryScrollbar() { | |
| 260 | - $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar('destroy'); | |
| 261 | - $('.trail-info-wrap', leftWrap).perfectScrollbar('destroy'); | |
| 262 | - $('.inout_table_wrap', leftWrap).perfectScrollbar('destroy'); | |
| 263 | - } | |
| 264 | - | |
| 265 | - function createScrollbar() { | |
| 266 | - $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar(); | |
| 267 | - $('.trail-info-wrap', leftWrap).perfectScrollbar(); | |
| 268 | - $('.inout_table_wrap', leftWrap).perfectScrollbar(); | |
| 269 | - } | |
| 270 | - | |
| 271 | - $('.form-error-text .uk-close', leftWrap).on('click', function (e) { | |
| 272 | - e.stopPropagation(); | |
| 273 | - $('.form-error-text').removeClass('show').find('span').text(''); | |
| 274 | - return false; | |
| 275 | - }); | |
| 276 | - | |
| 277 | - function notify_err(t) { | |
| 278 | - $('.form-error-text', leftWrap).addClass('show').find('span').text(t); | |
| 279 | - } | |
| 280 | - | |
| 281 | - function show_load_btn(btn) { | |
| 282 | - $(btn).attr('disabled', 'disabled').html('<i class="uk-icon-spinner uk-icon-spin"> </i> '); | |
| 283 | - } | |
| 284 | - | |
| 285 | - function hide_load_btn() { | |
| 286 | - $('button[type=submit]', f).removeAttr('disabled').html('<i class="uk-icon-search"> </i> 搜索轨迹'); | |
| 287 | - } | |
| 288 | - | |
| 289 | - //车辆 autocomplete | |
| 290 | - gb_common.carAutocomplete($('.autocomplete-nbbm', leftWrap), gb_data_basic.carsArray()); | |
| 291 | - $('.autocomplete-nbbm', leftWrap).on('input', function () { | |
| 292 | - $('.play-back-form>.dynamic_devices', leftWrap).remove(); | |
| 293 | - }); | |
| 294 | - | |
| 295 | - /** | |
| 296 | - * 车辆选择抽屉显示 | |
| 297 | - */ | |
| 298 | - var fw = '#carSelectOffcanvas .search-form-wrap'; | |
| 299 | - $('#carSelectOffcanvas').on('show.uk.offcanvas', function () { | |
| 300 | - var that = this; | |
| 301 | - $.get('/basic/ccInfo/lineArray', {idx: gb_data_basic.line_idx}, function (rs) { | |
| 302 | - if (!rs || rs.length == 0) | |
| 303 | - return; | |
| 304 | - | |
| 305 | - rs.sort(function (a, b) { | |
| 306 | - if (a.lineName == b.lineName) | |
| 307 | - return a.nbbm.localeCompare(b.nbbm); | |
| 308 | - return a.lineName.localeCompare(b.lineName); | |
| 309 | - }); | |
| 310 | - | |
| 311 | - var lineNames = {}; | |
| 312 | - $.each(rs, function () { | |
| 313 | - lineNames[this.lineName] = 1; | |
| 314 | - }); | |
| 315 | - | |
| 316 | - var bodyStr = template('pbv3_park_list_dropdown-temp', { | |
| 317 | - list: rs, | |
| 318 | - lineNameArray: gb_common.get_keys(lineNames) | |
| 319 | - }); | |
| 320 | - $('.offcanvas-cont', that).html(bodyStr); | |
| 321 | - | |
| 322 | - $('select[name=lineName]', fw).on('change', offcanvasTableFilter); | |
| 323 | - $('input[name=deviceId]', fw).on('input', offcanvasTableFilter); | |
| 324 | - $('.offcanvas-cont .uk-table tr').dblclick(function () { | |
| 325 | - var nbbm = $('td:eq(0)', this).text(); | |
| 326 | - $('[name=nbbm]', f).val(nbbm); | |
| 327 | - $.UIkit.offcanvas.hide([force = false]); | |
| 328 | - }); | |
| 329 | - }); | |
| 330 | - }); | |
| 331 | - var carTab = '.offcanvas-cont .uk-table'; | |
| 332 | - var offcanvasTableFilter = function () { | |
| 333 | - var lineName = $('select[name=lineName]', fw).val(); | |
| 334 | - var deviceId = $('input[name=deviceId]', fw).val(); | |
| 335 | - $('tr', carTab).show().each(function () { | |
| 336 | - if (lineName && $('td:eq(2)', this).text() != lineName) | |
| 337 | - $(this).hide(); | |
| 338 | - | |
| 339 | - if (deviceId && $('td:eq(1)', this).text().indexOf(deviceId) == -1) | |
| 340 | - $(this).hide(); | |
| 341 | - }); | |
| 342 | - }; | |
| 343 | - | |
| 344 | - | |
| 345 | - /** | |
| 346 | - * 从服务器获取轨迹数据 | |
| 347 | - * @param data | |
| 348 | - */ | |
| 349 | - function get_server_trail_data(data, cb) { | |
| 350 | - $.ajax({ | |
| 351 | - url: '/gps/history_v3/' + data.nbbm, | |
| 352 | - data: {st: data.st, et: data.et}, | |
| 353 | - success: function (rs) { | |
| 354 | - $('.bg-grey', leftWrap).removeClass('bg-grey'); | |
| 355 | - hide_load_btn(); | |
| 356 | - if(rs.status=='ERROR'){ | |
| 357 | - notify_err('异常:' + rs.msg); | |
| 358 | - } | |
| 359 | - else if(rs.status=='SUCCESS'){ | |
| 360 | - if(!rs.list || rs.list.length==0){ | |
| 361 | - notify_err('没有查询到历史轨迹信息'); | |
| 362 | - } | |
| 363 | - cb && cb(rs); | |
| 364 | - } | |
| 365 | - }, | |
| 366 | - error: function () { | |
| 367 | - hide_load_btn(); | |
| 368 | - notify_err('服务器出现异常,请联系管理员!'); | |
| 369 | - } | |
| 370 | - }); | |
| 371 | - } | |
| 372 | - | |
| 373 | - /** | |
| 374 | - * 填充行车轨迹表格 | |
| 375 | - */ | |
| 376 | - function fillTrailTable(list){ | |
| 377 | - var array = []; | |
| 378 | - for (var i = 0, gps; gps = list[i++];) { | |
| 379 | - //格式化时间 | |
| 380 | - gps.timeStr = moment(gps.timestamp).format('HH:mm.ss'); | |
| 381 | - try { | |
| 382 | - if (i > 0 && array[array.length - 1]['section_code'] == gps['section_code']) | |
| 383 | - array.pop(); | |
| 384 | - } | |
| 385 | - catch (e) { | |
| 386 | - } | |
| 387 | - | |
| 388 | - if (gps['section_code']) | |
| 389 | - array.push(gps); | |
| 390 | - } | |
| 391 | - var htmlStr = template('pbv3_trail_tbody-temp', {array: array}); | |
| 392 | - $('.trail-info-table .ct_table_body', leftWrap).html(htmlStr); | |
| 393 | - } | |
| 394 | - | |
| 395 | - /** | |
| 396 | - * 填充到离站数据表格 | |
| 397 | - * @param list | |
| 398 | - */ | |
| 399 | - var arrivalData; | |
| 400 | - function fillArivalStationTable(list){ | |
| 401 | - var data, f, prev; | |
| 402 | - var $wrap = $('.inout_table_wrap', leftWrap); | |
| 403 | - var $tbody = $('.ct_table_body', $wrap); | |
| 404 | - | |
| 405 | - data = []; | |
| 406 | - $.each(list, function (i, gps) { | |
| 407 | - prev = data[data.length - 1]; | |
| 408 | - if (gps['inout_stop'] == -1) | |
| 409 | - return true; | |
| 410 | - if (gps['inout_stop'] == 0 && gps['inout_stop_info']) { | |
| 411 | - //连续进站信号,取第一个 | |
| 412 | - if(prev && prev['out_ts'] == null | |
| 413 | - && prev['stopName'] == gps['inout_stop_info'].stopName){ | |
| 414 | - return true; | |
| 415 | - } | |
| 416 | - data.push(createIn(gps)); | |
| 417 | - } | |
| 418 | - else if (gps['inout_stop'] == 1) { | |
| 419 | - f = matchOut(prev, gps); | |
| 420 | - if(f) | |
| 421 | - data.push(f); | |
| 422 | - } | |
| 423 | - }); | |
| 424 | - //格式化时间 | |
| 425 | - $.each(data, function (i) { | |
| 426 | - if (this.in_ts) | |
| 427 | - this.in_time_str = moment(this.in_ts).format('HH:mm.ss'); | |
| 428 | - if (this.out_ts) | |
| 429 | - this.out_time_str = moment(this.out_ts).format('HH:mm.ss'); | |
| 430 | - //id | |
| 431 | - this.id = 'in_out_' + i; | |
| 432 | - }); | |
| 433 | - | |
| 434 | - var htmlStr = template('pbv3_inout_station_tbody-temp', {list: data}); | |
| 435 | - $tbody.html(htmlStr); | |
| 436 | - arrivalData = data; | |
| 437 | - } | |
| 438 | - | |
| 439 | - var createIn = function (gps) { | |
| 440 | - var info = gps['inout_stop_info']; | |
| 441 | - return {in_ts: info.ts, stopNo: info.stopNo, stopName: info.stopName} | |
| 442 | - }; | |
| 443 | - var matchOut = function (prevInfo, gps) { | |
| 444 | - var oi = gps['inout_stop_info']; | |
| 445 | - if(!oi) | |
| 446 | - return; | |
| 447 | - if(prevInfo && prevInfo.stopName == oi.stopName){ | |
| 448 | - prevInfo['out_ts'] = oi.ts; | |
| 449 | - return null; | |
| 450 | - } | |
| 451 | - else { | |
| 452 | - return {out_ts: oi.ts,stopNo: oi.stopNo,stopName: oi.stopName} | |
| 453 | - } | |
| 454 | - }; | |
| 455 | - | |
| 456 | - /** | |
| 457 | - * 填充异常信息表格 | |
| 458 | - */ | |
| 459 | - function fillAbnormalTable(){ | |
| 460 | - var array = []; | |
| 461 | - for(var i = 0; i < arguments.length; i ++){ | |
| 462 | - if(arguments[i]!=null) | |
| 463 | - array = array.concat(arguments[i]); | |
| 464 | - } | |
| 465 | - var i=null; | |
| 466 | - //格式化时间 | |
| 467 | - $.each(array, function () { | |
| 468 | - if(!this.abnormalType&&this.version){ | |
| 469 | - i=array.indexOf(this); | |
| 470 | - } | |
| 471 | - if(this.st) | |
| 472 | - this.st_str = moment(this.st).format('HH:mm.ss'); | |
| 473 | - if(this.et) | |
| 474 | - this.et_str = moment(this.et).format('HH:mm.ss'); | |
| 475 | - }); | |
| 476 | - | |
| 477 | - if(i){ | |
| 478 | - array.splice(i,1); | |
| 479 | - } | |
| 480 | - //排序 | |
| 481 | - array.sort(function (a, b) { | |
| 482 | - return a.st - b.st; | |
| 483 | - }); | |
| 484 | - var htmlStr = template('pbv3_abnormal_table_temp', {array: array}); | |
| 485 | - $('.abnormal_table .ct_table_body', leftWrap).html(htmlStr); | |
| 486 | - } | |
| 487 | - | |
| 488 | - $(leftWrap).on('mouseover', '.dynamic_devices', function () { | |
| 489 | - $('.dynamic_devices_dropdown', leftWrap).show(); | |
| 490 | - }).on('mouseout', function () { | |
| 491 | - $('.dynamic_devices_dropdown', leftWrap).hide(); | |
| 492 | - }); | |
| 493 | - | |
| 494 | - return { | |
| 495 | - fillTrailTable: fillTrailTable, | |
| 496 | - fillArivalStationTable: fillArivalStationTable, | |
| 497 | - destoryScrollbar: destoryScrollbar, | |
| 498 | - createScrollbar: createScrollbar | |
| 499 | - } | |
| 500 | - })(); | |
| 1 | +<div class="play-back-form bg-grey"> | |
| 2 | + <form class="uk-form uk-form-horizontal"> | |
| 3 | + <div class="uk-form-row"> | |
| 4 | + <label class="uk-form-label">车辆编码</label> | |
| 5 | + <div class="uk-form-controls"> | |
| 6 | + <div class="uk-autocomplete uk-form autocomplete-nbbm" style="width: calc(100% - 60px)"> | |
| 7 | + <div class="uk-autocomplete uk-form autocomplete-nbbm"> | |
| 8 | + <input name="nbbm" required/> | |
| 9 | + </div> | |
| 10 | + </div> | |
| 11 | + <a style="color: #009688;margin-left: 5px;" data-uk-offcanvas="{target:'#carSelectOffcanvas'}">选择</a> | |
| 12 | + </div> | |
| 13 | + </div> | |
| 14 | + | |
| 15 | + <div class="uk-form-row"> | |
| 16 | + <label class="uk-form-label">开始时间</label> | |
| 17 | + <div class="uk-form-controls"> | |
| 18 | + <input class="flatpickr_input" name="startTime" required/> | |
| 19 | + </div> | |
| 20 | + </div> | |
| 21 | + | |
| 22 | + <div class="uk-form-row"> | |
| 23 | + <label class="uk-form-label">结束时间</label> | |
| 24 | + <div class="uk-form-controls"> | |
| 25 | + <input class="flatpickr_input" name="endTime" required/> | |
| 26 | + </div> | |
| 27 | + </div> | |
| 28 | + <div style="text-align: center;margin-top: 20px;"> | |
| 29 | + <button class="uk-button uk-button-large uk-button-link p_back_form_submit" type="submit"><i | |
| 30 | + class="uk-icon-search"> </i> 搜索轨迹 | |
| 31 | + </button> | |
| 32 | + </div> | |
| 33 | + </form> | |
| 34 | + <div class="form-error-text"> | |
| 35 | + <a href="" class="uk-close uk-close-alt"></a><span></span> | |
| 36 | + </div> | |
| 37 | +</div> | |
| 38 | + | |
| 39 | +<!-- 异常table --> | |
| 40 | +<div class="play-back-abnormal_table_wrap bg-grey"> | |
| 41 | + <div class="pback_abnormal_table_panel" | |
| 42 | + style="height: 100%;overflow: auto;"> | |
| 43 | + <div class="ct_table abnormal_table" style="height: calc(100% - 30px);width: 500px;background: #e6e6e6;"> | |
| 44 | + <div class="ct_table_head" style="background: #e6e6e6;"> | |
| 45 | + <dl> | |
| 46 | + <dt>异常信息</dt> | |
| 47 | + <dt>开始时间</dt> | |
| 48 | + <dt>结束时间</dt> | |
| 49 | + <dt>所在路段</dt> | |
| 50 | + </dl> | |
| 51 | + </div> | |
| 52 | + <div class="ct_table_body"> | |
| 53 | + </div> | |
| 54 | + </div> | |
| 55 | + </div> | |
| 56 | +</div> | |
| 57 | + | |
| 58 | +<!-- 行车轨迹和到离站 --> | |
| 59 | +<div class="play-back-trail-info-wrap bg-grey"> | |
| 60 | + <div class="uk-width-medium-1-1"> | |
| 61 | + | |
| 62 | + <ul class="uk-subnav uk-subnav-pill" data-uk-switcher="{connect:'#playBackV3TrailCont', swiping: false}" style="padding-left: 12px;"> | |
| 63 | + <li class="uk-active"><a>行车轨迹</a></li> | |
| 64 | + <li><a>到离站信息</a></li> | |
| 65 | + </ul> | |
| 66 | + <span class="sum_mileage_span"></span> | |
| 67 | + | |
| 68 | + <ul class="uk-switcher uk-margin real_gps_info_tab_content" id="playBackV3TrailCont"> | |
| 69 | + <li class="uk-active" style="height: 100%;"> | |
| 70 | + <div class="trail-info-wrap" > | |
| 71 | + <div class="ct_table trail-info-table" style="height: calc(100% - 30px);"> | |
| 72 | + <div class="ct_table_head" style="background: #e6e6e6;"> | |
| 73 | + <dl> | |
| 74 | + <dt>时间</dt> | |
| 75 | + <dt>速度</dt> | |
| 76 | + <dt>上下行</dt> | |
| 77 | + <dt>所在路段</dt> | |
| 78 | + <dt>车载线路</dt> | |
| 79 | + </dl> | |
| 80 | + </div> | |
| 81 | + <div class="ct_table_body"></div> | |
| 82 | + </div> | |
| 83 | + </div> | |
| 84 | + </li> | |
| 85 | + <!-- 到离站数据 --> | |
| 86 | + <li style="height: 100%;"> | |
| 87 | + <div class="inout_table_wrap" style="height: 100%;overflow: auto;"> | |
| 88 | + <div class="ct_table" style="height: calc(100% - 30px);"> | |
| 89 | + <div class="ct_table_head" style="background: #e6e6e6;"> | |
| 90 | + <dl> | |
| 91 | + <dt>站点</dt> | |
| 92 | + <dt>进站时间</dt> | |
| 93 | + <dt>离站时间</dt> | |
| 94 | + <dt>上客</dt> | |
| 95 | + <dt>下客</dt> | |
| 96 | + </dl> | |
| 97 | + </div> | |
| 98 | + <div class="ct_table_body"> | |
| 99 | + </div> | |
| 100 | + </div> | |
| 101 | + </div> | |
| 102 | + </li> | |
| 103 | + </ul> | |
| 104 | + </div> | |
| 105 | +</div> | |
| 106 | + | |
| 107 | +<!-- 车辆选择抽屉 --> | |
| 108 | +<div id="carSelectOffcanvas" class="uk-offcanvas"> | |
| 109 | + <div class="uk-offcanvas-bar"> | |
| 110 | + <div class="uk-panel offcanvas-cont"> | |
| 111 | + <div class="spinner"> | |
| 112 | + <div class="rect1"></div> | |
| 113 | + <div class="rect2"></div> | |
| 114 | + <div class="rect3"></div> | |
| 115 | + <div class="rect4"></div> | |
| 116 | + <div class="rect5"></div> | |
| 117 | + </div> | |
| 118 | + </div> | |
| 119 | + </div> | |
| 120 | +</div> | |
| 121 | + | |
| 122 | +<script> | |
| 123 | + var gb_playback_v3_leftpanel = (function () { | |
| 124 | + | |
| 125 | + var leftWrap = '.gps-play-back-panel-v3>div.left-panel'; | |
| 126 | + var f = $('.play-back-form form', leftWrap); | |
| 127 | + var params; | |
| 128 | + | |
| 129 | + $(leftWrap).one('init-left-dom', function (e, data) { | |
| 130 | + e.stopPropagation(); | |
| 131 | + params = data; | |
| 132 | + | |
| 133 | + //初始化表单 | |
| 134 | + initForm(); | |
| 135 | + | |
| 136 | + //固定表头 | |
| 137 | + gb_ct_table.fixedHead($('.trail-info-wrap', leftWrap)); | |
| 138 | + gb_ct_table.fixedHead($('.pback_abnormal_table_panel', leftWrap)); | |
| 139 | + gb_ct_table.fixedHead($('.inout_table_wrap', leftWrap)); | |
| 140 | + //滚动条 | |
| 141 | + createScrollbar(); | |
| 142 | + | |
| 143 | + //show title | |
| 144 | + /*UIkit.notify("设备端自身标识为无效的GPS点位,将不会再进入回放通路", { | |
| 145 | + status: 'info' | |
| 146 | + });*/ | |
| 147 | + }); | |
| 148 | + | |
| 149 | + /** | |
| 150 | + * 初始化表单 | |
| 151 | + */ | |
| 152 | + var initForm = function () { | |
| 153 | + if (params.nbbm) | |
| 154 | + $('[name=nbbm]', f).val(params.nbbm); | |
| 155 | + var st = moment().subtract(2, 'hour'), et = moment(); | |
| 156 | + if (params.start) | |
| 157 | + st = moment(params.start - 300000); | |
| 158 | + $('[name=startTime]', f).val(st.format('YYYY-MM-DD HH:mm')); | |
| 159 | + if (params.end) | |
| 160 | + et = moment(params.end + 300000); | |
| 161 | + $('[name=endTime]', f).val(et.format('YYYY-MM-DD HH:mm')); | |
| 162 | + | |
| 163 | + //初始化 flatpickr | |
| 164 | + var sConf = $.extend(gb_common.flatpickrDateTimeConfig, { | |
| 165 | + defaultHour: st.format('HH'), | |
| 166 | + defaultMinute: st.format('mm') | |
| 167 | + }); | |
| 168 | + var eConf = $.extend(gb_common.flatpickrDateTimeConfig, { | |
| 169 | + defaultHour: et.format('HH'), | |
| 170 | + defaultMinute: et.format('mm') | |
| 171 | + }); | |
| 172 | + flatpickr(leftWrap + ' .flatpickr_input[name=startTime]', sConf); | |
| 173 | + flatpickr(leftWrap + ' .flatpickr_input[name=endTime]', eConf); | |
| 174 | + }; | |
| 175 | + | |
| 176 | + //搜索轨迹 | |
| 177 | + var ONE_DAY = 60 * 60 * 24; | |
| 178 | + var MIN_SPACE = 60; | |
| 179 | + $('button[type=submit]', f).on('click', function (e) { | |
| 180 | + e.stopPropagation(); | |
| 181 | + try { | |
| 182 | + var data = f.serializeJSON(); | |
| 183 | + | |
| 184 | + //校验时间间隔 | |
| 185 | + var fs = 'YYYY-MM-DD HH:mm'; | |
| 186 | + var st = parseInt(moment(data.startTime, fs).format('X')); | |
| 187 | + var et = parseInt(moment(data.endTime, fs).format('X')); | |
| 188 | + data.st = st; | |
| 189 | + data.et = et; | |
| 190 | + | |
| 191 | + if (!data.nbbm || !data.nbbm.trim()) | |
| 192 | + notify_err('你必须输入车辆编码'); | |
| 193 | + else if (!data.startTime || !data.startTime.trim()) | |
| 194 | + notify_err('你必须输入开始时间'); | |
| 195 | + else if (!data.endTime || !data.endTime.trim()) | |
| 196 | + notify_err('你必须输入结束时间'); | |
| 197 | + else if (et < st) | |
| 198 | + notify_err('结束时间不能小于开始时间!'); | |
| 199 | + else if ((et - st) > ONE_DAY) | |
| 200 | + notify_err('查询范围不能超过24小时!'); | |
| 201 | + else if ((et - st) < MIN_SPACE) | |
| 202 | + notify_err('最小间隔1分钟!'); | |
| 203 | + else { | |
| 204 | + show_load_btn(this); | |
| 205 | + //查询数据 | |
| 206 | + get_server_trail_data(data, function (rs) { | |
| 207 | + //线路名称 | |
| 208 | + var code2Name = gb_data_basic.lineCode2NameAll(); | |
| 209 | + $.each(rs.list, function () { | |
| 210 | + this.lineName = code2Name[this.lineId]; | |
| 211 | + this.nbbm = data.nbbm; | |
| 212 | + }); | |
| 213 | + //排序 | |
| 214 | + rs.list.sort(function (a, b) { | |
| 215 | + return parseInt((a.ts - b.ts) + '' + (a.stop_no - b.stop_no)); | |
| 216 | + }); | |
| 217 | + fillTrailTable(rs.list);//填充行车轨迹表格 | |
| 218 | + fillArivalStationTable(rs.list);//填充到离站表格 | |
| 219 | + $('.sum_mileage_span', leftWrap).text('共约 ' + rs.sumMileage + ' 公里'); | |
| 220 | + fillAbnormalTable(rs['outboundList'], rs['speedList'],rs['gpsInvalid'],rs['gpslineSwitch'],rs['lineVerson'],rs['gpslonlatex']);//填充异常信息表格 | |
| 221 | + //准备播放 | |
| 222 | + rs.arrivalData = arrivalData; | |
| 223 | + $('.gps-play-back-panel-v3>div.right-panel .play-back-tools-wrap').trigger('ready-to-play', rs); | |
| 224 | + | |
| 225 | + //更新滚动条 | |
| 226 | + resetScrollbar(); | |
| 227 | + | |
| 228 | + /** | |
| 229 | + * 显示设备更换信息 | |
| 230 | + */ | |
| 231 | + var deviceStr='', fs='YYYY-MM-DD HH:mm'; | |
| 232 | + for(var i=0,dc;dc=rs.dcs[i++];){ | |
| 233 | + deviceStr+=dc.device + ','; | |
| 234 | + dc.stStr = dc.st>0?moment(dc.st).format(fs):''; | |
| 235 | + dc.etStr = dc.et>0?moment(dc.et).format(fs):''; | |
| 236 | + } | |
| 237 | + deviceStr=deviceStr.substr(0, deviceStr.length-1); | |
| 238 | + | |
| 239 | + $('.play-back-form>.dynamic_devices', leftWrap).remove(); | |
| 240 | + $('.play-back-form>.dynamic_devices_dropdown', leftWrap).remove(); | |
| 241 | + var htmlStr = template('pbv3_park_form_devices-temp', {deviceStr:deviceStr}), | |
| 242 | + htmlStr2 = template('pbv3_park_devices_dropdown-temp', {dcs:rs.dcs}); | |
| 243 | + $('.play-back-form', leftWrap).append(htmlStr).append(htmlStr2); | |
| 244 | + }); | |
| 245 | + } | |
| 246 | + } catch (e) { | |
| 247 | + console.log(e); | |
| 248 | + } | |
| 249 | + return false; | |
| 250 | + }); | |
| 251 | + | |
| 252 | + function resetScrollbar() { | |
| 253 | + $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0); | |
| 254 | + $('.trail-info-wrap', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0); | |
| 255 | + $('.inout_table_wrap', leftWrap).perfectScrollbar('destroy').perfectScrollbar().scrollTop(0); | |
| 256 | + } | |
| 257 | + | |
| 258 | + function destoryScrollbar() { | |
| 259 | + $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar('destroy'); | |
| 260 | + $('.trail-info-wrap', leftWrap).perfectScrollbar('destroy'); | |
| 261 | + $('.inout_table_wrap', leftWrap).perfectScrollbar('destroy'); | |
| 262 | + } | |
| 263 | + | |
| 264 | + function createScrollbar() { | |
| 265 | + $('.pback_abnormal_table_panel', leftWrap).perfectScrollbar(); | |
| 266 | + $('.trail-info-wrap', leftWrap).perfectScrollbar(); | |
| 267 | + $('.inout_table_wrap', leftWrap).perfectScrollbar(); | |
| 268 | + } | |
| 269 | + | |
| 270 | + $('.form-error-text .uk-close', leftWrap).on('click', function (e) { | |
| 271 | + e.stopPropagation(); | |
| 272 | + $('.form-error-text').removeClass('show').find('span').text(''); | |
| 273 | + return false; | |
| 274 | + }); | |
| 275 | + | |
| 276 | + function notify_err(t) { | |
| 277 | + $('.form-error-text', leftWrap).addClass('show').find('span').text(t); | |
| 278 | + } | |
| 279 | + | |
| 280 | + function show_load_btn(btn) { | |
| 281 | + $(btn).attr('disabled', 'disabled').html('<i class="uk-icon-spinner uk-icon-spin"> </i> '); | |
| 282 | + } | |
| 283 | + | |
| 284 | + function hide_load_btn() { | |
| 285 | + $('button[type=submit]', f).removeAttr('disabled').html('<i class="uk-icon-search"> </i> 搜索轨迹'); | |
| 286 | + } | |
| 287 | + | |
| 288 | + //车辆 autocomplete | |
| 289 | + gb_common.carAutocomplete($('.autocomplete-nbbm', leftWrap), gb_data_basic.carsArray()); | |
| 290 | + $('.autocomplete-nbbm', leftWrap).on('input', function () { | |
| 291 | + $('.play-back-form>.dynamic_devices', leftWrap).remove(); | |
| 292 | + }); | |
| 293 | + | |
| 294 | + /** | |
| 295 | + * 车辆选择抽屉显示 | |
| 296 | + */ | |
| 297 | + var fw = '#carSelectOffcanvas .search-form-wrap'; | |
| 298 | + $('#carSelectOffcanvas').on('show.uk.offcanvas', function () { | |
| 299 | + var that = this; | |
| 300 | + $.get('/basic/ccInfo/lineArray', {idx: gb_data_basic.line_idx}, function (rs) { | |
| 301 | + if (!rs || rs.length == 0) | |
| 302 | + return; | |
| 303 | + | |
| 304 | + rs.sort(function (a, b) { | |
| 305 | + if (a.lineName == b.lineName) | |
| 306 | + return a.nbbm.localeCompare(b.nbbm); | |
| 307 | + return a.lineName.localeCompare(b.lineName); | |
| 308 | + }); | |
| 309 | + | |
| 310 | + var lineNames = {}; | |
| 311 | + $.each(rs, function () { | |
| 312 | + lineNames[this.lineName] = 1; | |
| 313 | + }); | |
| 314 | + | |
| 315 | + var bodyStr = template('pbv3_park_list_dropdown-temp', { | |
| 316 | + list: rs, | |
| 317 | + lineNameArray: gb_common.get_keys(lineNames) | |
| 318 | + }); | |
| 319 | + $('.offcanvas-cont', that).html(bodyStr); | |
| 320 | + | |
| 321 | + $('select[name=lineName]', fw).on('change', offcanvasTableFilter); | |
| 322 | + $('input[name=deviceId]', fw).on('input', offcanvasTableFilter); | |
| 323 | + $('.offcanvas-cont .uk-table tr').dblclick(function () { | |
| 324 | + var nbbm = $('td:eq(0)', this).text(); | |
| 325 | + $('[name=nbbm]', f).val(nbbm); | |
| 326 | + $.UIkit.offcanvas.hide([force = false]); | |
| 327 | + }); | |
| 328 | + }); | |
| 329 | + }); | |
| 330 | + var carTab = '.offcanvas-cont .uk-table'; | |
| 331 | + var offcanvasTableFilter = function () { | |
| 332 | + var lineName = $('select[name=lineName]', fw).val(); | |
| 333 | + var deviceId = $('input[name=deviceId]', fw).val(); | |
| 334 | + $('tr', carTab).show().each(function () { | |
| 335 | + if (lineName && $('td:eq(2)', this).text() != lineName) | |
| 336 | + $(this).hide(); | |
| 337 | + | |
| 338 | + if (deviceId && $('td:eq(1)', this).text().indexOf(deviceId) == -1) | |
| 339 | + $(this).hide(); | |
| 340 | + }); | |
| 341 | + }; | |
| 342 | + | |
| 343 | + | |
| 344 | + /** | |
| 345 | + * 从服务器获取轨迹数据 | |
| 346 | + * @param data | |
| 347 | + */ | |
| 348 | + function get_server_trail_data(data, cb) { | |
| 349 | + $.ajax({ | |
| 350 | + url: '/gps/history_v3/' + data.nbbm, | |
| 351 | + data: {st: data.st, et: data.et}, | |
| 352 | + success: function (rs) { | |
| 353 | + $('.bg-grey', leftWrap).removeClass('bg-grey'); | |
| 354 | + hide_load_btn(); | |
| 355 | + if(rs.status=='ERROR'){ | |
| 356 | + notify_err('异常:' + rs.msg); | |
| 357 | + } | |
| 358 | + else if(rs.status=='SUCCESS'){ | |
| 359 | + if(!rs.list || rs.list.length==0){ | |
| 360 | + notify_err('没有查询到历史轨迹信息'); | |
| 361 | + } | |
| 362 | + cb && cb(rs); | |
| 363 | + } | |
| 364 | + }, | |
| 365 | + error: function () { | |
| 366 | + hide_load_btn(); | |
| 367 | + notify_err('服务器出现异常,请联系管理员!'); | |
| 368 | + } | |
| 369 | + }); | |
| 370 | + } | |
| 371 | + | |
| 372 | + /** | |
| 373 | + * 填充行车轨迹表格 | |
| 374 | + */ | |
| 375 | + function fillTrailTable(list){ | |
| 376 | + var array = []; | |
| 377 | + for (var i = 0, gps; gps = list[i++];) { | |
| 378 | + //格式化时间 | |
| 379 | + gps.timeStr = moment(gps.timestamp).format('HH:mm.ss'); | |
| 380 | + try { | |
| 381 | + if (i > 0 && array[array.length - 1]['section_code'] == gps['section_code']) | |
| 382 | + array.pop(); | |
| 383 | + } | |
| 384 | + catch (e) { | |
| 385 | + } | |
| 386 | + | |
| 387 | + if (gps['section_code']) | |
| 388 | + array.push(gps); | |
| 389 | + } | |
| 390 | + var htmlStr = template('pbv3_trail_tbody-temp', {array: array}); | |
| 391 | + $('.trail-info-table .ct_table_body', leftWrap).html(htmlStr); | |
| 392 | + } | |
| 393 | + | |
| 394 | + /** | |
| 395 | + * 填充到离站数据表格 | |
| 396 | + * @param list | |
| 397 | + */ | |
| 398 | + var arrivalData; | |
| 399 | + function fillArivalStationTable(list){ | |
| 400 | + var data, f, prev; | |
| 401 | + var $wrap = $('.inout_table_wrap', leftWrap); | |
| 402 | + var $tbody = $('.ct_table_body', $wrap); | |
| 403 | + | |
| 404 | + data = []; | |
| 405 | + $.each(list, function (i, gps) { | |
| 406 | + prev = data[data.length - 1]; | |
| 407 | + if (gps['inout_stop'] == -1) | |
| 408 | + return true; | |
| 409 | + if (gps['inout_stop'] == 0 && gps['inout_stop_info']) { | |
| 410 | + //连续进站信号,取第一个 | |
| 411 | + if(prev && prev['out_ts'] == null | |
| 412 | + && prev['stopName'] == gps['inout_stop_info'].stopName){ | |
| 413 | + return true; | |
| 414 | + } | |
| 415 | + data.push(createIn(gps)); | |
| 416 | + } | |
| 417 | + else if (gps['inout_stop'] == 1) { | |
| 418 | + f = matchOut(prev, gps); | |
| 419 | + if(f) | |
| 420 | + data.push(f); | |
| 421 | + } | |
| 422 | + }); | |
| 423 | + //格式化时间 | |
| 424 | + $.each(data, function (i) { | |
| 425 | + if (this.in_ts) | |
| 426 | + this.in_time_str = moment(this.in_ts).format('HH:mm.ss'); | |
| 427 | + if (this.out_ts) | |
| 428 | + this.out_time_str = moment(this.out_ts).format('HH:mm.ss'); | |
| 429 | + //id | |
| 430 | + this.id = 'in_out_' + i; | |
| 431 | + }); | |
| 432 | + | |
| 433 | + var htmlStr = template('pbv3_inout_station_tbody-temp', {list: data}); | |
| 434 | + $tbody.html(htmlStr); | |
| 435 | + arrivalData = data; | |
| 436 | + } | |
| 437 | + | |
| 438 | + var createIn = function (gps) { | |
| 439 | + var info = gps['inout_stop_info']; | |
| 440 | + return {in_ts: info.ts, stopNo: info.stopNo, stopName: info.stopName} | |
| 441 | + }; | |
| 442 | + var matchOut = function (prevInfo, gps) { | |
| 443 | + var oi = gps['inout_stop_info']; | |
| 444 | + if(!oi) | |
| 445 | + return; | |
| 446 | + if(prevInfo && prevInfo.stopName == oi.stopName){ | |
| 447 | + prevInfo['out_ts'] = oi.ts; | |
| 448 | + return null; | |
| 449 | + } | |
| 450 | + else { | |
| 451 | + return {out_ts: oi.ts,stopNo: oi.stopNo,stopName: oi.stopName} | |
| 452 | + } | |
| 453 | + }; | |
| 454 | + | |
| 455 | + /** | |
| 456 | + * 填充异常信息表格 | |
| 457 | + */ | |
| 458 | + function fillAbnormalTable(){ | |
| 459 | + var array = []; | |
| 460 | + for(var i = 0; i < arguments.length; i ++){ | |
| 461 | + if(arguments[i]!=null) | |
| 462 | + array = array.concat(arguments[i]); | |
| 463 | + } | |
| 464 | + var i=null; | |
| 465 | + //格式化时间 | |
| 466 | + $.each(array, function () { | |
| 467 | + if(!this.abnormalType&&this.version){ | |
| 468 | + i=array.indexOf(this); | |
| 469 | + } | |
| 470 | + if(this.st) | |
| 471 | + this.st_str = moment(this.st).format('HH:mm.ss'); | |
| 472 | + if(this.et) | |
| 473 | + this.et_str = moment(this.et).format('HH:mm.ss'); | |
| 474 | + }); | |
| 475 | + | |
| 476 | + if(i){ | |
| 477 | + array.splice(i,1); | |
| 478 | + } | |
| 479 | + //排序 | |
| 480 | + array.sort(function (a, b) { | |
| 481 | + return a.st - b.st; | |
| 482 | + }); | |
| 483 | + var htmlStr = template('pbv3_abnormal_table_temp', {array: array}); | |
| 484 | + $('.abnormal_table .ct_table_body', leftWrap).html(htmlStr); | |
| 485 | + } | |
| 486 | + | |
| 487 | + $(leftWrap).on('mouseover', '.dynamic_devices', function () { | |
| 488 | + $('.dynamic_devices_dropdown', leftWrap).show(); | |
| 489 | + }).on('mouseout', function () { | |
| 490 | + $('.dynamic_devices_dropdown', leftWrap).hide(); | |
| 491 | + }); | |
| 492 | + | |
| 493 | + return { | |
| 494 | + fillTrailTable: fillTrailTable, | |
| 495 | + fillArivalStationTable: fillArivalStationTable, | |
| 496 | + destoryScrollbar: destoryScrollbar, | |
| 497 | + createScrollbar: createScrollbar | |
| 498 | + } | |
| 499 | + })(); | |
| 501 | 500 | </script> |
| 502 | 501 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/mapmonitor/js/playback.js
| 1 | -/* 地图模块 轨迹回放 */ | |
| 2 | - | |
| 3 | -var gb_map_play_back = (function () { | |
| 4 | - | |
| 5 | - var dom; | |
| 6 | -/* $.get('/real_control_v2/mapmonitor/fragments/playback_v2/main.html', function (rs) { | |
| 7 | - dom = rs; | |
| 8 | - });*/ | |
| 9 | - $.get('/real_control_v2/mapmonitor/fragments/playback_v3/layout.html', function (rs) { | |
| 10 | - dom = rs; | |
| 11 | - }); | |
| 12 | - | |
| 13 | - var setParam = function (sch) { | |
| 14 | - console.log('sch', sch); | |
| 15 | - var f = $('.play-back-form form'), | |
| 16 | - st = (sch['fcsjActualTime']?sch['fcsjActualTime']:sch['dfsjT']) - 1000 * 60 * 5, | |
| 17 | - et = (sch['zdsjActualTime']?sch['zdsjActualTime']:sch['zdsjT']) + 1000 * 60 * 5, | |
| 18 | - fs = 'YYYY-MM-DD HH:mm'; | |
| 19 | - | |
| 20 | - $('[name=nbbm]', f).val(sch.clZbh); | |
| 21 | - $('[name=startTime]', f).val(moment(st).format(fs)); | |
| 22 | - $('[name=endTime]', f).val(moment(et).format(fs)); | |
| 23 | - }; | |
| 24 | - | |
| 25 | - var initParams = function (deviceId, nbbm) { | |
| 26 | - //关闭infowindow | |
| 27 | - if (deviceId) | |
| 28 | - gb_map_imap.call('closeWin', deviceId); | |
| 29 | - | |
| 30 | - //show modal | |
| 31 | - //open_modal_dom(dom, {deviceId: deviceId, nbbm: nbbm}); | |
| 32 | - | |
| 33 | - var pbv3MapWrap = '.gps-play-back-panel-v3>div.right-panel .play-back-map-wrap'; | |
| 34 | - var resizeFlag; | |
| 35 | - var index = layer.open({ | |
| 36 | - id: 'play_back_v3_modal', | |
| 37 | - type: 1, | |
| 38 | - title: '<i class="uk-icon-play-circle"></i> 轨迹回放', | |
| 39 | - shadeClose: true, | |
| 40 | - shade: false, | |
| 41 | - moveOut: true, | |
| 42 | - maxmin: true, //开启最大化最小化按钮 | |
| 43 | - area: ['1299px', '754px'], | |
| 44 | - //moveOut: true, | |
| 45 | - skin:'layui-layer-molv play_back-layer', | |
| 46 | - content: dom, | |
| 47 | - zIndex: layer.zIndex, | |
| 48 | - success: function(layero){ | |
| 49 | - layer.setTop(layero); | |
| 50 | - $('.gps-play-back-panel-v3').trigger('init', {deviceId: deviceId, nbbm: nbbm}); | |
| 51 | - }, | |
| 52 | - end: function () { | |
| 53 | - | |
| 54 | - }, | |
| 55 | - resizing: function () { | |
| 56 | - if(resizeFlag) | |
| 57 | - return; | |
| 58 | - resizeFlag = true; | |
| 59 | - setTimeout(function () { | |
| 60 | - $(pbv3MapWrap).trigger('reset-map'); | |
| 61 | - resizeFlag = false; | |
| 62 | - }, 1200); | |
| 63 | - }, | |
| 64 | - full: function () { | |
| 65 | - $(pbv3MapWrap).trigger('reset-map'); | |
| 66 | - }, | |
| 67 | - min: function () { | |
| 68 | - $(pbv3MapWrap).trigger('reset-map'); | |
| 69 | - }, | |
| 70 | - restore: function () { | |
| 71 | - $(pbv3MapWrap).trigger('reset-map'); | |
| 72 | - }, | |
| 73 | - cancel: function () { | |
| 74 | - $(pbv3MapWrap).trigger('close'); | |
| 75 | - //删除所有的flatpickr元素,避免元素堆积 | |
| 76 | - $('.flatpickr-calendar.showTimeInput').remove(); | |
| 77 | - } | |
| 78 | - }); | |
| 79 | - layer.full(index); | |
| 80 | - }; | |
| 81 | - | |
| 82 | - //导出excel | |
| 83 | - var listToExcel = function (list) { | |
| 84 | - var temp = '<html>' + | |
| 85 | - ' <head> '+ | |
| 86 | - ' </head>' + | |
| 87 | - ' <body>' + | |
| 88 | - ' <table border="1">' + | |
| 89 | - ' <tr><th>序号</th><th>车辆</th><th>所在道路</th><th>经度</th><th>纬度</th><th>时间</th><th>速度</th></tr>' + | |
| 90 | - ' {{each list as gps i}}' + | |
| 91 | - ' <tr><td>{{i+1}}</td><td>{{gps.nbbm}}</td><td>{{gps.section_name}}</td><td>{{gps.lon}}</td><td>{{gps.lat}}</td><td>{{gps.timeStr}}</td><td>{{gps.speed}}</td></tr>' + | |
| 92 | - ' {{/each}}' + | |
| 93 | - ' </table>' + | |
| 94 | - ' </body>' + | |
| 95 | - ' </html>'; | |
| 96 | - | |
| 97 | - var rs = template.compile(temp)({list: list}); | |
| 98 | - | |
| 99 | - var uri = 'data:application/vnd.ms-excel;base64,'; | |
| 100 | - return uri + base64(rs); | |
| 101 | - //location.href = uri + base64(rs); | |
| 102 | - }; | |
| 103 | - | |
| 104 | - | |
| 105 | - function base64(string) { | |
| 106 | - return window.btoa(unescape(encodeURIComponent(string))); | |
| 107 | - } | |
| 108 | - | |
| 109 | - return { | |
| 110 | - initParams: initParams, | |
| 111 | - listToExcel: listToExcel, | |
| 112 | - setParam: setParam | |
| 113 | - } | |
| 1 | +/* 地图模块 轨迹回放 */ | |
| 2 | + | |
| 3 | +var gb_map_play_back = (function () { | |
| 4 | + | |
| 5 | + var dom; | |
| 6 | +/* $.get('/real_control_v2/mapmonitor/fragments/playback_v2/main.html', function (rs) { | |
| 7 | + dom = rs; | |
| 8 | + });*/ | |
| 9 | + $.get('/real_control_v2/mapmonitor/fragments/playback_v3/layout.html', function (rs) { | |
| 10 | + dom = rs; | |
| 11 | + }); | |
| 12 | + | |
| 13 | + var setParam = function (sch) { | |
| 14 | + console.log('sch', sch); | |
| 15 | + var f = $('.play-back-form form'), | |
| 16 | + st = (sch['fcsjActualTime']?sch['fcsjActualTime']:sch['dfsjT']) - 1000 * 60 * 5, | |
| 17 | + et = (sch['zdsjActualTime']?sch['zdsjActualTime']:sch['zdsjT']) + 1000 * 60 * 5, | |
| 18 | + fs = 'YYYY-MM-DD HH:mm'; | |
| 19 | + | |
| 20 | + $('[name=nbbm]', f).val(sch.clZbh); | |
| 21 | + $('[name=startTime]', f).val(moment(st).format(fs)); | |
| 22 | + $('[name=endTime]', f).val(moment(et).format(fs)); | |
| 23 | + }; | |
| 24 | + | |
| 25 | + var initParams = function (params) { | |
| 26 | + //关闭infowindow | |
| 27 | + if (params && params.deviceId) | |
| 28 | + gb_map_imap.call('closeWin', params.deviceId); | |
| 29 | + | |
| 30 | + //show modal | |
| 31 | + //open_modal_dom(dom, {deviceId: deviceId, nbbm: nbbm}); | |
| 32 | + | |
| 33 | + var pbv3MapWrap = '.gps-play-back-panel-v3>div.right-panel .play-back-map-wrap'; | |
| 34 | + var resizeFlag; | |
| 35 | + var index = layer.open({ | |
| 36 | + id: 'play_back_v3_modal', | |
| 37 | + type: 1, | |
| 38 | + title: '<i class="uk-icon-play-circle"></i> 轨迹回放', | |
| 39 | + shadeClose: true, | |
| 40 | + shade: false, | |
| 41 | + moveOut: true, | |
| 42 | + maxmin: true, //开启最大化最小化按钮 | |
| 43 | + area: ['1299px', '754px'], | |
| 44 | + //moveOut: true, | |
| 45 | + skin:'layui-layer-molv play_back-layer', | |
| 46 | + content: dom, | |
| 47 | + zIndex: layer.zIndex, | |
| 48 | + success: function(layero){ | |
| 49 | + layer.setTop(layero); | |
| 50 | + $('.gps-play-back-panel-v3').trigger('init', params); | |
| 51 | + }, | |
| 52 | + end: function () { | |
| 53 | + | |
| 54 | + }, | |
| 55 | + resizing: function () { | |
| 56 | + if(resizeFlag) | |
| 57 | + return; | |
| 58 | + resizeFlag = true; | |
| 59 | + setTimeout(function () { | |
| 60 | + $(pbv3MapWrap).trigger('reset-map'); | |
| 61 | + resizeFlag = false; | |
| 62 | + }, 1200); | |
| 63 | + }, | |
| 64 | + full: function () { | |
| 65 | + $(pbv3MapWrap).trigger('reset-map'); | |
| 66 | + }, | |
| 67 | + min: function () { | |
| 68 | + $(pbv3MapWrap).trigger('reset-map'); | |
| 69 | + }, | |
| 70 | + restore: function () { | |
| 71 | + $(pbv3MapWrap).trigger('reset-map'); | |
| 72 | + }, | |
| 73 | + cancel: function () { | |
| 74 | + $(pbv3MapWrap).trigger('close'); | |
| 75 | + //删除所有的flatpickr元素,避免元素堆积 | |
| 76 | + $('.flatpickr-calendar.showTimeInput').remove(); | |
| 77 | + } | |
| 78 | + }); | |
| 79 | + layer.full(index); | |
| 80 | + }; | |
| 81 | + | |
| 82 | + //导出excel | |
| 83 | + var listToExcel = function (list) { | |
| 84 | + var temp = '<html>' + | |
| 85 | + ' <head> '+ | |
| 86 | + ' </head>' + | |
| 87 | + ' <body>' + | |
| 88 | + ' <table border="1">' + | |
| 89 | + ' <tr><th>序号</th><th>车辆</th><th>所在道路</th><th>经度</th><th>纬度</th><th>时间</th><th>速度</th></tr>' + | |
| 90 | + ' {{each list as gps i}}' + | |
| 91 | + ' <tr><td>{{i+1}}</td><td>{{gps.nbbm}}</td><td>{{gps.section_name}}</td><td>{{gps.lon}}</td><td>{{gps.lat}}</td><td>{{gps.timeStr}}</td><td>{{gps.speed}}</td></tr>' + | |
| 92 | + ' {{/each}}' + | |
| 93 | + ' </table>' + | |
| 94 | + ' </body>' + | |
| 95 | + ' </html>'; | |
| 96 | + | |
| 97 | + var rs = template.compile(temp)({list: list}); | |
| 98 | + | |
| 99 | + var uri = 'data:application/vnd.ms-excel;base64,'; | |
| 100 | + return uri + base64(rs); | |
| 101 | + //location.href = uri + base64(rs); | |
| 102 | + }; | |
| 103 | + | |
| 104 | + | |
| 105 | + function base64(string) { | |
| 106 | + return window.btoa(unescape(encodeURIComponent(string))); | |
| 107 | + } | |
| 108 | + | |
| 109 | + return { | |
| 110 | + initParams: initParams, | |
| 111 | + listToExcel: listToExcel, | |
| 112 | + setParam: setParam | |
| 113 | + } | |
| 114 | 114 | })(); |
| 115 | 115 | \ No newline at end of file | ... | ... |