Commit 7a36acc0d9dce63b453ab5bf5abbeab08e323185
Merge branch 'minhang' of http://192.168.168.201:8888/panzhaov5/bsth_control.git into minhang
Showing
50 changed files
with
2323 additions
and
1422 deletions
Too many changes to show.
To preserve performance only 50 of 183 files are displayed.
README.md
| 1 | -公交调度系统BS版 0.1 | |
| 2 | -====== | |
| 3 | ----------- | |
| 4 | -## 目录 | |
| 5 | ---------- | |
| 6 | - * [字典表](#字典表) | |
| 7 | - * [动态jpa查询实现](#动态jpa查询实现) | |
| 8 | - * [车载 gps 相关数据](#gps) | |
| 9 | - * [实时gps数据接口 http](#实时gps接口) | |
| 10 | - * [进出站数据表结构](#进站数据) | |
| 11 | - * [异常警报表结构](#异常警报) | |
| 12 | - * [大间隔](#大间隔) | |
| 13 | - * [超速](#超速) | |
| 14 | - * [越界](#越界) | |
| 15 | - * [越站](#越站) | |
| 16 | - * [聚集](#聚集) | |
| 17 | - * [掉线](#掉线) | |
| 18 | - * [调度消息下发接口HTTP](#调度消息下发接口) | |
| 19 | - * [调度消息上传接口HTTP](#调度消息上传接口) | |
| 20 | - * [车辆历史GPS数据](#车辆历史GPS) | |
| 21 | - | |
| 22 | ----------- | |
| 23 | - | |
| 24 | -## 字典表 | |
| 25 | ----------- | |
| 26 | -字典操作全部由前端负责,主要有2种。 | |
| 27 | - | |
| 28 | -1、转换字典代码。 | |
| 29 | - 当pjax的`pjax:success`事件被触发(片段加载完成) | |
| 30 | - 扫描容器内所有有 `$(".nt-dictionary")` 元素进行字典转换 | |
| 31 | -``` html | |
| 32 | ---dom标签为span div p h1 h2 h3 h4 h5 h6 等等文本元素时,如下写法,text为要转换的代码 | |
| 33 | -<span class="nt-dictionary" data-group="ScheduleType">out</span> | |
| 34 | ---to | |
| 35 | -<span>出场</span> | |
| 36 | - | |
| 37 | -<!- dom标签为input时,如下 data-code为要转换的代码 --> | |
| 38 | -<input class="nt-dictionary" data-group="ScheduleType" data-code="out"> | |
| 39 | ---to | |
| 40 | -<input value="出场"> | |
| 41 | - | |
| 42 | -<!- dom标签为select时 如下 data-code为要选中的项 --> | |
| 43 | -<select class="nt-dictionary" data-group="ScheduleType" data-code="out"></select> | |
| 44 | ---to | |
| 45 | -<select> | |
| 46 | - <option value="normal">正常班次</option> | |
| 47 | - <option value="out" selected>出场</option> | |
| 48 | - <option value="in">进场</option> | |
| 49 | - <option value="oil">加油</option> | |
| 50 | - <option value="temp">临加</option> | |
| 51 | - <option value="region">区间</option> | |
| 52 | - <option value="venting">放空</option> | |
| 53 | - <option value="major">放大站</option> | |
| 54 | -</select> | |
| 55 | -``` | |
| 56 | -*原标签的class 除nt-dictionary 外,其余均会被保留* | |
| 57 | - | |
| 58 | -2、dictionary.js提供如下方法自行使用 | |
| 59 | -| 方法名 | 参数|返回| | |
| 60 | -| ---- | ---- | ---- | ---- | | |
| 61 | -| groups (获取所有字典组) | 无| | {LineTrend: 线路走向, ScheduleType: 班次类型} | | |
| 62 | -| getByGroup (获取字典组下的字典)| (group) |{0: 上行, 1: 下行}| | |
| 63 | -| transformCode (转换字典代码)| (group, code) | 上行 | | |
| 64 | - | |
| 65 | -## 动态jpa查询实现 | |
| 66 | ----------- | |
| 67 | -*参考调度系统枚举com.bsth.entity.search.SearchOperator* | |
| 68 | - | |
| 69 | - | |
| 70 | -## gps | |
| 71 | ----------- | |
| 72 | -### 实时gps接口 | |
| 73 | - | |
| 74 | -所有在线GPS: [http://192.168.168.192:8080/transport_server/rtgps](http://192.168.168.192:8080/transport_server/rtgps/) | |
| 75 | -根据设备号查询:[http://192.168.168.192:8080/transport_server/rtgps/05B01901](http://192.168.168.192:8080/transport_server/rtgps/05B01901) | |
| 76 | - | |
| 77 | -<span style="color: red">Response</span>: | |
| 78 | -```json | |
| 79 | -{ | |
| 80 | - "data":[ | |
| 81 | - { | |
| 82 | - "companyCode":5, | |
| 83 | - "lineId":10329, | |
| 84 | - "deviceId":"05B01901", | |
| 85 | - "carparkNo":"00000000", | |
| 86 | - "stopNo":"7C890002", | |
| 87 | - "lon":121.549866, | |
| 88 | - "lat":31.238798, | |
| 89 | - "timestamp":1397104499000, | |
| 90 | - "speed":42.0, | |
| 91 | - "direction":245.9, | |
| 92 | - "state":0, | |
| 93 | - "upDown":0 | |
| 94 | - }] | |
| 95 | -} | |
| 96 | -``` | |
| 97 | - | |
| 98 | -| -- | --|--| | |
| 99 | -| ---- | ---- | ---- | | |
| 100 | -| companyCode | int | 公司代码 | | |
| 101 | -| lineId | int | 线路编码 | | |
| 102 | -| deviceId | String | 设备编号 | | |
| 103 | -| carparkNo | String | 停车场编码 | | |
| 104 | -| stopNo | String | 站点编码 | | |
| 105 | -| lon | float | 经度 | | |
| 106 | -| lat | float | 纬度 | | |
| 107 | -| timestamp | long | 时间戳 | | |
| 108 | -| speed | float | 速度| | |
| 109 | -| direction | float | 方向(角度) | | |
| 110 | -| state | int | 营运状态( 0 营运 ,1 非营运, -1 无效) | | |
| 111 | -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效)| | |
| 112 | - | |
| 113 | - | |
| 114 | -### 进站数据 | |
| 115 | ----------- | |
| 116 | -表名: | |
| 117 | - | |
| 118 | -| .. | .. | .. | | |
| 119 | -| ---- | ---- | ---- | | |
| 120 | -| id | int | 主键 | | |
| 121 | -| deviceId | String | 设备号 | | |
| 122 | -| lineId | int | 线路编码 | | |
| 123 | -| stopNo | long | 站点编码 | | |
| 124 | -| timestamp | long | 时间戳 | | |
| 125 | -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 126 | -| createDate | Date | 创建时间 | | |
| 127 | - | |
| 128 | - | |
| 129 | -### 异常警报 | |
| 130 | ----------- | |
| 131 | - | |
| 132 | -### 大间隔 | |
| 133 | ----------- | |
| 134 | -表名: | |
| 135 | - | |
| 136 | -| .. | .. | .. | | |
| 137 | -| ---- | ---- | ---- | | |
| 138 | -| id | int | 主键 | | |
| 139 | -| line | int | 线路编码 | | |
| 140 | -| station | String | 站点编码 | | |
| 141 | -| cVehicle | String | 当前车辆编码 | | |
| 142 | -| lastVehicle | String | 上一个车辆编码 | | |
| 143 | -| interval | long | 间隔时间(秒) | | |
| 144 | -| timestamp | long | 时间戳 | | |
| 145 | -| createDate | Date | 创建时间 | | |
| 146 | - | |
| 147 | -### 超速 | |
| 148 | ----------- | |
| 149 | -表名: | |
| 150 | - | |
| 151 | -| .. | .. | .. | | |
| 152 | -| ---- | ---- | ---- | | |
| 153 | -| id | int | 主键 | | |
| 154 | -| vehicle | String | 车辆编码 | | |
| 155 | -| line | int | 线路编码 | | |
| 156 | -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 157 | -| lon | float | 经度 | | |
| 158 | -| lat | float | 纬度| | |
| 159 | -| speed | float | 速度 | | |
| 160 | -| timestamp | long | 时间戳 | | |
| 161 | -| createDate | Date | 时间 | | |
| 162 | - | |
| 163 | -### 越界 | |
| 164 | ----------- | |
| 165 | -表名: | |
| 166 | - | |
| 167 | -| .. | .. | .. | | |
| 168 | -| ---- | ---- | ---- | | |
| 169 | -| id | int | 主键 | | |
| 170 | -| vehicle | String | 车辆编码 | | |
| 171 | -| line | int | 线路编码 | | |
| 172 | -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 173 | -| lon | float | 经度 | | |
| 174 | -| lat | float | 纬度| | |
| 175 | -| location | String | 越界位置(由线调页面进行初始转换)意思是该字段默认为空,页面第一次查看时会写入值| | |
| 176 | -| timestamp | long | 时间戳 | | |
| 177 | -| createDate | Date | 时间 | | |
| 178 | - | |
| 179 | - | |
| 180 | -### 越站 | |
| 181 | ----------- | |
| 182 | -表名: | |
| 183 | - | |
| 184 | -| .. | .. | .. | | |
| 185 | -| ---- | ---- | ---- | | |
| 186 | -| id | int | 主键 | | |
| 187 | -| line | int | 线路编码 | | |
| 188 | -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 189 | -| station | String | 站点编码 | | |
| 190 | -| vehicle | String | 车辆编码 | | |
| 191 | -| inData | Date | 进站时间 | | |
| 192 | -| outDate | Date | 出站时间 | | |
| 193 | - | |
| 194 | - | |
| 195 | -### 聚集 | |
| 196 | ----------- | |
| 197 | -表名: | |
| 198 | - | |
| 199 | -| .. | .. | .. | | |
| 200 | -| ---- | ---- | ---- | | |
| 201 | -| id | int | 主键 | | |
| 202 | -| line | int | 线路编码 | | |
| 203 | -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 204 | -| stations | String | 站点(多个用 , 号分隔。应该是连续站点) | | |
| 205 | -| vehicles | String | 车辆编码(多个用 , 号分隔) | | |
| 206 | -| timestamp | long | 时间戳 | | |
| 207 | -| createDate | Date | 时间 | | |
| 208 | - | |
| 209 | - | |
| 210 | -### 掉线 | |
| 211 | ----------- | |
| 212 | -表名: | |
| 213 | - | |
| 214 | -| .. | .. | .. | | |
| 215 | -| ---- | ---- | ---- | | |
| 216 | -| id | int | 主键 | | |
| 217 | -| line | int | 线路编码 | | |
| 218 | -| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 219 | -| vehicle | String | 车辆编码 | | |
| 220 | -| lon | float | 经度 | | |
| 221 | -| lat | float | 纬度| | |
| 222 | -| timestamp | long | 时间戳 | | |
| 223 | -| createDate | Date | 时间 | | |
| 224 | - | |
| 225 | - | |
| 226 | -### 调度消息下发接口 | |
| 227 | ----------- | |
| 228 | -[http://192.168.168.192:8080/transport_server/message](http://192.168.168.192:8080/transport_server/message/) | |
| 229 | - | |
| 230 | -<span style="color: red">Request</span>: | |
| 231 | -```json | |
| 232 | -{ | |
| 233 | - "deviceId":12345, | |
| 234 | - "timestamp":44324, | |
| 235 | - "operCode":0x60, | |
| 236 | - "data":{ | |
| 237 | - "companyCode":22, | |
| 238 | - "deviceId":"029L2222", | |
| 239 | - "timestamp":134326, | |
| 240 | - "instructType":00, | |
| 241 | - "dispatchInstruct":0x00, | |
| 242 | - "msgId":12345, | |
| 243 | - "alarmTime":201606012000, | |
| 244 | - "serviceState":00000000, | |
| 245 | - "txtContent":"你好" | |
| 246 | - } | |
| 247 | -} | |
| 248 | -``` | |
| 249 | -| .. | .. | .. | | |
| 250 | -| ---- | ---- | ---- | | |
| 251 | -| deviceId | string | 设备编号 | | |
| 252 | -| timestamp | long | 时间戳(ms) | | |
| 253 | -| operCode | short | 一级协议 | | |
| 254 | -| data.companyCode | short | 公司代码 | | |
| 255 | -| data.deviceId | string | 设备编号 | | |
| 256 | -| data.timestamp | long | 时间戳 | | |
| 257 | -| data.instructType | short | 保留 默认0 | | |
| 258 | -| data.dispatchInstruct | short | 调度指令 调度指令。0X00表示信息短语,0X01表示取消上次指令+调度指令(闹钟有效),0x02表示为调度指令(闹钟有效); 0x03表示运营状态指令(闹钟无效);0x04表示其他指令。| | |
| 259 | -| data.msgId | long | 同上 | | |
| 260 | -| data.alarmTime | long | 闹钟 MMddhhmm| | |
| 261 | -| data.serviceState | long | 多状态字节 先由车载发起车辆故障、事故报告、扣证、纠纷、加油等审请,经调度确认后,下发调度指令与运营状态。当调度指令为0X00终端需要提示信息。当调度指令为0x01和0x02,终端需要收到后提示信息。并且必须在闹钟结束后进行终端相关状态更新。在闹钟时间前120秒开始提示。当调度指令为0x03,收到后进行终端相关状态更新,终端不需要提示信息。当调度指令为0x04,暂不需要提示信息。| | |
| 262 | -| data.txtContent | string | 下发的消息文本 | | |
| 263 | -```json | |
| 264 | -{ | |
| 265 | - "deviceId":12345, | |
| 266 | - "timestamp":44324, | |
| 267 | - "operCode":0x64, | |
| 268 | - "data":{ | |
| 269 | - "cityCode":22, | |
| 270 | - "deviceId":"029L2222", | |
| 271 | - "lineId":"134326" | |
| 272 | - } | |
| 273 | -} | |
| 274 | -``` | |
| 275 | -| .. | .. | .. | | |
| 276 | -| ---- | ---- | ---- | | |
| 277 | -| deviceId | string | 设备编号 | | |
| 278 | -| timestamp | long | 时间戳(ms) | | |
| 279 | -| operCode | short | 一级协议 | | |
| 280 | -| data.cityCode | short | 城市区号 | | |
| 281 | -| data.deviceId | string | 设备编号 | | |
| 282 | -| data.lineId | string | 线路编号 6位 不足6位前面补0 如编号890 用000890表示 | | |
| 283 | - | |
| 284 | -```json | |
| 285 | -{ | |
| 286 | - "deviceId":12345, | |
| 287 | - "timestamp":44324, | |
| 288 | - "operCode":0xC0, | |
| 289 | - "data":{ | |
| 290 | - "operCode":0x86, | |
| 291 | - "requestAck":0x06 | |
| 292 | - } | |
| 293 | -} | |
| 294 | -``` | |
| 295 | -| .. | .. | .. | | |
| 296 | -| ---- | ---- | ---- | | |
| 297 | -| deviceId | string | 设备编号 | | |
| 298 | -| timestamp | long | 时间戳(ms) | | |
| 299 | -| operCode | short | 一级协议 | | |
| 300 | -| data.operCode | short | 二级协议 | | |
| 301 | -| data.requestAck | short | 请求应答字 0x06同意 0x15不同意| | |
| 302 | - | |
| 303 | -```json | |
| 304 | -{ | |
| 305 | - "deviceId":12345, | |
| 306 | - "timestamp":44324, | |
| 307 | - "operCode":0xC0, | |
| 308 | - "data":{ | |
| 309 | - "operCode":0xa3, | |
| 310 | - "deviceId":12345, | |
| 311 | - "ipAddress":222.66.0.204, | |
| 312 | - "port":8899, | |
| 313 | - "reportMode":0, | |
| 314 | - "interval":0, | |
| 315 | - "distance":0, | |
| 316 | - "speedingThreshold":0, | |
| 317 | - "alarmThreshold":0, | |
| 318 | - "posIpAddress":0, | |
| 319 | - "posPort":0, | |
| 320 | - "delay":0, | |
| 321 | - "speedThreshold1":0, | |
| 322 | - "speedThreshold2":0, | |
| 323 | - "contrast":0, | |
| 324 | - "brightness":0, | |
| 325 | - "saturation":0 | |
| 326 | - } | |
| 327 | -} | |
| 328 | -``` | |
| 329 | -| .. | .. | .. | | |
| 330 | -| ---- | ---- | ---- | | |
| 331 | -| deviceId | string | 设备编号 | | |
| 332 | -| timestamp | long | 时间戳(ms) | | |
| 333 | -| operCode | short | 一级协议 | | |
| 334 | -| data.operCode | short | 二级协议 | | |
| 335 | -| data.deviceId | string | 设备编号| | |
| 336 | -| data.ipAddress | string | 网关IP地址| | |
| 337 | -| data.port | string | 网关端口| | |
| 338 | -| data.reportMode | short | 定时定距上报模式| | |
| 339 | -| data.interval | int | 定时上报时间间隔| | |
| 340 | -| data.distance | string | 定距上报距离间隔| | |
| 341 | -| data.speedingThreshold | short | 非线路状态超速阀门| | |
| 342 | -| data.alarmThreshold | short | 预警阀门| | |
| 343 | -| data.posIpAddress | string | pos机IP地址| | |
| 344 | -| data.posPort | string | pos机端口| | |
| 345 | -| data.delay | int | 延迟机关时间| | |
| 346 | -| data.deviceId | short | 中门视频切换到码表界面速度阀门 默认45| | |
| 347 | -| data.deviceId | short | 码表界面切换到中门视频速度阀门 默认35| | |
| 348 | -| data.deviceId | short | 对比度| | |
| 349 | -| data.deviceId | short | 亮度| | |
| 350 | -| data.deviceId | short | 饱和度| | |
| 351 | - | |
| 352 | -```json | |
| 353 | -{ | |
| 354 | - "deviceId":12345, | |
| 355 | - "timestamp":44324, | |
| 356 | - "operCode":0xC0, | |
| 357 | - "data":{ | |
| 358 | - "operCode":0xa4 | |
| 359 | - } | |
| 360 | -} | |
| 361 | -``` | |
| 362 | -| .. | .. | .. | | |
| 363 | -| ---- | ---- | ---- | | |
| 364 | -| deviceId | string | 设备编号 | | |
| 365 | -| timestamp | long | 时间戳(ms) | | |
| 366 | -| operCode | short | 一级协议 | | |
| 367 | -| data.operCode | short | 二级协议 | | |
| 368 | - | |
| 369 | -```json | |
| 370 | -{ | |
| 371 | - "deviceId":12345, | |
| 372 | - "timestamp":44324, | |
| 373 | - "operCode":0xC0, | |
| 374 | - "data":{ | |
| 375 | - "operCode":0xa5 | |
| 376 | - "programVersion":2 | |
| 377 | - } | |
| 378 | -} | |
| 379 | -``` | |
| 380 | -| .. | .. | .. | | |
| 381 | -| ---- | ---- | ---- | | |
| 382 | -| deviceId | string | 设备编号 | | |
| 383 | -| timestamp | long | 时间戳(ms) | | |
| 384 | -| operCode | short | 一级协议 | | |
| 385 | -| data.operCode | short | 二级协议 | | |
| 386 | -| data.programVersion | short | 程序版本 | | |
| 387 | - | |
| 388 | -<span style="color: red">Response</span>: | |
| 389 | -```json | |
| 390 | -{ | |
| 391 | - "errCode":0 | |
| 392 | -} | |
| 393 | -``` | |
| 394 | - | |
| 395 | -### 调度消息上传接口 | |
| 396 | ----------- | |
| 397 | -上行POST地址:[http://192.168.168.120:9088/control/upstream](http://192.168.168.120:9088/control/upstream) | |
| 398 | -<span style="color: red">Request</span>: | |
| 399 | -```json | |
| 400 | -{ | |
| 401 | - "deviceId":12345, | |
| 402 | - "timestamp":44324, | |
| 403 | - "status":0, | |
| 404 | - "operCode":0x80, | |
| 405 | - "data":{ | |
| 406 | - "operCode":0x26, | |
| 407 | - "requestCode":22 | |
| 408 | - } | |
| 409 | -} | |
| 410 | -``` | |
| 411 | -| .. | .. | .. | | |
| 412 | -| ---- | ---- | ---- | | |
| 413 | -| deviceId | string | 设备编号 | | |
| 414 | -| timestamp | long | 时间戳(ms) | | |
| 415 | -| status | int | 0x80时无数据 0表示失败 1表示成功或设备确认 2表示驾驶员阅读 | | |
| 416 | -| operCode | short | 一级协议 消息确认将无数据 | | |
| 417 | -| data.operCode | short | 二级协议 | | |
| 418 | -| data.requestCode | short | 请求代码0xa1 恢复运营 0xa2 申请调档 0xa3 出场请求 0xa5 进场请求 0xa7 加油请求 0x50 车辆故障 0x70 路阻报告 0x60 事故报告 0x11 扣证纠纷 0x12 报警 | | |
| 419 | -<span style="color: red">Response</span>: | |
| 420 | -```json | |
| 421 | -{ | |
| 422 | - "errCode":0 | |
| 423 | -} | |
| 424 | -``` | |
| 425 | - | |
| 426 | -### 车辆历史GPS | |
| 427 | ----------- | |
| 428 | -表名:BSTH_C_GPS_INFO | |
| 429 | - | |
| 430 | -| .. | .. | .. | | |
| 431 | -| ---- | ---- | ---- | | |
| 432 | -| cityCode | int | 城市代码 | | |
| 433 | -| industryCode | int | 行业代码 | | |
| 434 | -| companyCode | int | 企业代码 | | |
| 435 | -| lineId | int | 线路编号 | | |
| 436 | -| deviceId | string | 设备编号 | | |
| 437 | -| driverNo | int | 驾驶员工号 | | |
| 438 | -| carparkSerialNo | int | 停车场序列号 | | |
| 439 | -| carparkNo | string | 停车场编号 | | |
| 440 | -| stopSerialNo | int | 站点序列号 | | |
| 441 | -| stopNo | string | 停车场编号 | | |
| 442 | -| lon | float | 经度 | | |
| 443 | -| lat | float | 维度 | | |
| 444 | -| ts | long | 时间戳 | | |
| 445 | -| speedSensor | float | 发动机速度 | | |
| 446 | -| speedGps | float | gps速度 | | |
| 447 | -| direction | float | 角度0-359 | | |
| 448 | -| inTemp | int | 车内温度 | | |
| 449 | -| serviceState | long | 设备状态字 | | |
| 450 | -| daysYear | int | 对应年中的天数 为分区字段 查询一定要用此字段过滤 | | |
| 451 | - | |
| 1 | +公交调度系统BS版 0.1 | |
| 2 | +====== | |
| 3 | +---------- | |
| 4 | +## 目录 | |
| 5 | +--------- | |
| 6 | + * [字典表](#字典表) | |
| 7 | + * [动态jpa查询实现](#动态jpa查询实现) | |
| 8 | + * [车载 gps 相关数据](#gps) | |
| 9 | + * [实时gps数据接口 http](#实时gps接口) | |
| 10 | + * [进出站数据表结构](#进站数据) | |
| 11 | + * [异常警报表结构](#异常警报) | |
| 12 | + * [大间隔](#大间隔) | |
| 13 | + * [超速](#超速) | |
| 14 | + * [越界](#越界) | |
| 15 | + * [越站](#越站) | |
| 16 | + * [聚集](#聚集) | |
| 17 | + * [掉线](#掉线) | |
| 18 | + * [调度消息下发接口HTTP](#调度消息下发接口) | |
| 19 | + * [调度消息上传接口HTTP](#调度消息上传接口) | |
| 20 | + * [车辆历史GPS数据](#车辆历史GPS) | |
| 21 | + | |
| 22 | +---------- | |
| 23 | + | |
| 24 | +## 字典表 | |
| 25 | +---------- | |
| 26 | +字典操作全部由前端负责,主要有2种。 | |
| 27 | + | |
| 28 | +1、转换字典代码。 | |
| 29 | + 当pjax的`pjax:success`事件被触发(片段加载完成) | |
| 30 | + 扫描容器内所有有 `$(".nt-dictionary")` 元素进行字典转换 | |
| 31 | +``` html | |
| 32 | +--dom标签为span div p h1 h2 h3 h4 h5 h6 等等文本元素时,如下写法,text为要转换的代码 | |
| 33 | +<span class="nt-dictionary" data-group="ScheduleType">out</span> | |
| 34 | +--to | |
| 35 | +<span>出场</span> | |
| 36 | + | |
| 37 | +<!- dom标签为input时,如下 data-code为要转换的代码 --> | |
| 38 | +<input class="nt-dictionary" data-group="ScheduleType" data-code="out"> | |
| 39 | +--to | |
| 40 | +<input value="出场"> | |
| 41 | + | |
| 42 | +<!- dom标签为select时 如下 data-code为要选中的项 --> | |
| 43 | +<select class="nt-dictionary" data-group="ScheduleType" data-code="out"></select> | |
| 44 | +--to | |
| 45 | +<select> | |
| 46 | + <option value="normal">正常班次</option> | |
| 47 | + <option value="out" selected>出场</option> | |
| 48 | + <option value="in">进场</option> | |
| 49 | + <option value="oil">加油</option> | |
| 50 | + <option value="temp">临加</option> | |
| 51 | + <option value="region">区间</option> | |
| 52 | + <option value="venting">放空</option> | |
| 53 | + <option value="major">放大站</option> | |
| 54 | +</select> | |
| 55 | +``` | |
| 56 | +*原标签的class 除nt-dictionary 外,其余均会被保留* | |
| 57 | + | |
| 58 | +2、dictionary.js提供如下方法自行使用 | |
| 59 | +| 方法名 | 参数|返回| | |
| 60 | +| ---- | ---- | ---- | ---- | | |
| 61 | +| groups (获取所有字典组) | 无| | {LineTrend: 线路走向, ScheduleType: 班次类型} | | |
| 62 | +| getByGroup (获取字典组下的字典)| (group) |{0: 上行, 1: 下行}| | |
| 63 | +| transformCode (转换字典代码)| (group, code) | 上行 | | |
| 64 | + | |
| 65 | +## 动态jpa查询实现 | |
| 66 | +---------- | |
| 67 | +*参考调度系统枚举com.bsth.entity.search.SearchOperator* | |
| 68 | + | |
| 69 | + | |
| 70 | +## gps | |
| 71 | +---------- | |
| 72 | +### 实时gps接口 | |
| 73 | + | |
| 74 | +所有在线GPS: [http://192.168.168.192:8080/transport_server/rtgps](http://192.168.168.192:8080/transport_server/rtgps/) | |
| 75 | +根据设备号查询:[http://192.168.168.192:8080/transport_server/rtgps/05B01901](http://192.168.168.192:8080/transport_server/rtgps/05B01901) | |
| 76 | + | |
| 77 | +<span style="color: red">Response</span>: | |
| 78 | +```json | |
| 79 | +{ | |
| 80 | + "data":[ | |
| 81 | + { | |
| 82 | + "companyCode":5, | |
| 83 | + "lineId":10329, | |
| 84 | + "deviceId":"05B01901", | |
| 85 | + "carparkNo":"00000000", | |
| 86 | + "stopNo":"7C890002", | |
| 87 | + "lon":121.549866, | |
| 88 | + "lat":31.238798, | |
| 89 | + "timestamp":1397104499000, | |
| 90 | + "speed":42.0, | |
| 91 | + "direction":245.9, | |
| 92 | + "state":0, | |
| 93 | + "upDown":0 | |
| 94 | + }] | |
| 95 | +} | |
| 96 | +``` | |
| 97 | + | |
| 98 | +| -- | --|--| | |
| 99 | +| ---- | ---- | ---- | | |
| 100 | +| companyCode | int | 公司代码 | | |
| 101 | +| lineId | int | 线路编码 | | |
| 102 | +| deviceId | String | 设备编号 | | |
| 103 | +| carparkNo | String | 停车场编码 | | |
| 104 | +| stopNo | String | 站点编码 | | |
| 105 | +| lon | float | 经度 | | |
| 106 | +| lat | float | 纬度 | | |
| 107 | +| timestamp | long | 时间戳 | | |
| 108 | +| speed | float | 速度| | |
| 109 | +| direction | float | 方向(角度) | | |
| 110 | +| state | int | 营运状态( 0 营运 ,1 非营运, -1 无效) | | |
| 111 | +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效)| | |
| 112 | + | |
| 113 | + | |
| 114 | +### 进站数据 | |
| 115 | +---------- | |
| 116 | +表名: | |
| 117 | + | |
| 118 | +| .. | .. | .. | | |
| 119 | +| ---- | ---- | ---- | | |
| 120 | +| id | int | 主键 | | |
| 121 | +| deviceId | String | 设备号 | | |
| 122 | +| lineId | int | 线路编码 | | |
| 123 | +| stopNo | long | 站点编码 | | |
| 124 | +| timestamp | long | 时间戳 | | |
| 125 | +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 126 | +| createDate | Date | 创建时间 | | |
| 127 | + | |
| 128 | + | |
| 129 | +### 异常警报 | |
| 130 | +---------- | |
| 131 | + | |
| 132 | +### 大间隔 | |
| 133 | +---------- | |
| 134 | +表名: | |
| 135 | + | |
| 136 | +| .. | .. | .. | | |
| 137 | +| ---- | ---- | ---- | | |
| 138 | +| id | int | 主键 | | |
| 139 | +| line | int | 线路编码 | | |
| 140 | +| station | String | 站点编码 | | |
| 141 | +| cVehicle | String | 当前车辆编码 | | |
| 142 | +| lastVehicle | String | 上一个车辆编码 | | |
| 143 | +| interval | long | 间隔时间(秒) | | |
| 144 | +| timestamp | long | 时间戳 | | |
| 145 | +| createDate | Date | 创建时间 | | |
| 146 | + | |
| 147 | +### 超速 | |
| 148 | +---------- | |
| 149 | +表名: | |
| 150 | + | |
| 151 | +| .. | .. | .. | | |
| 152 | +| ---- | ---- | ---- | | |
| 153 | +| id | int | 主键 | | |
| 154 | +| vehicle | String | 车辆编码 | | |
| 155 | +| line | int | 线路编码 | | |
| 156 | +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 157 | +| lon | float | 经度 | | |
| 158 | +| lat | float | 纬度| | |
| 159 | +| speed | float | 速度 | | |
| 160 | +| timestamp | long | 时间戳 | | |
| 161 | +| createDate | Date | 时间 | | |
| 162 | + | |
| 163 | +### 越界 | |
| 164 | +---------- | |
| 165 | +表名: | |
| 166 | + | |
| 167 | +| .. | .. | .. | | |
| 168 | +| ---- | ---- | ---- | | |
| 169 | +| id | int | 主键 | | |
| 170 | +| vehicle | String | 车辆编码 | | |
| 171 | +| line | int | 线路编码 | | |
| 172 | +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 173 | +| lon | float | 经度 | | |
| 174 | +| lat | float | 纬度| | |
| 175 | +| location | String | 越界位置(由线调页面进行初始转换)意思是该字段默认为空,页面第一次查看时会写入值| | |
| 176 | +| timestamp | long | 时间戳 | | |
| 177 | +| createDate | Date | 时间 | | |
| 178 | + | |
| 179 | + | |
| 180 | +### 越站 | |
| 181 | +---------- | |
| 182 | +表名: | |
| 183 | + | |
| 184 | +| .. | .. | .. | | |
| 185 | +| ---- | ---- | ---- | | |
| 186 | +| id | int | 主键 | | |
| 187 | +| line | int | 线路编码 | | |
| 188 | +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 189 | +| station | String | 站点编码 | | |
| 190 | +| vehicle | String | 车辆编码 | | |
| 191 | +| inData | Date | 进站时间 | | |
| 192 | +| outDate | Date | 出站时间 | | |
| 193 | + | |
| 194 | + | |
| 195 | +### 聚集 | |
| 196 | +---------- | |
| 197 | +表名: | |
| 198 | + | |
| 199 | +| .. | .. | .. | | |
| 200 | +| ---- | ---- | ---- | | |
| 201 | +| id | int | 主键 | | |
| 202 | +| line | int | 线路编码 | | |
| 203 | +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 204 | +| stations | String | 站点(多个用 , 号分隔。应该是连续站点) | | |
| 205 | +| vehicles | String | 车辆编码(多个用 , 号分隔) | | |
| 206 | +| timestamp | long | 时间戳 | | |
| 207 | +| createDate | Date | 时间 | | |
| 208 | + | |
| 209 | + | |
| 210 | +### 掉线 | |
| 211 | +---------- | |
| 212 | +表名: | |
| 213 | + | |
| 214 | +| .. | .. | .. | | |
| 215 | +| ---- | ---- | ---- | | |
| 216 | +| id | int | 主键 | | |
| 217 | +| line | int | 线路编码 | | |
| 218 | +| upDown | int | 上下行(0 上行 , 1 下行 , -1 无效) | | |
| 219 | +| vehicle | String | 车辆编码 | | |
| 220 | +| lon | float | 经度 | | |
| 221 | +| lat | float | 纬度| | |
| 222 | +| timestamp | long | 时间戳 | | |
| 223 | +| createDate | Date | 时间 | | |
| 224 | + | |
| 225 | + | |
| 226 | +### 调度消息下发接口 | |
| 227 | +---------- | |
| 228 | +[http://192.168.168.192:8080/transport_server/message](http://192.168.168.192:8080/transport_server/message/) | |
| 229 | + | |
| 230 | +<span style="color: red">Request</span>: | |
| 231 | +```json | |
| 232 | +{ | |
| 233 | + "deviceId":12345, | |
| 234 | + "timestamp":44324, | |
| 235 | + "operCode":0x60, | |
| 236 | + "data":{ | |
| 237 | + "companyCode":22, | |
| 238 | + "deviceId":"029L2222", | |
| 239 | + "timestamp":134326, | |
| 240 | + "instructType":00, | |
| 241 | + "dispatchInstruct":0x00, | |
| 242 | + "msgId":12345, | |
| 243 | + "alarmTime":201606012000, | |
| 244 | + "serviceState":00000000, | |
| 245 | + "txtContent":"你好" | |
| 246 | + } | |
| 247 | +} | |
| 248 | +``` | |
| 249 | +| .. | .. | .. | | |
| 250 | +| ---- | ---- | ---- | | |
| 251 | +| deviceId | string | 设备编号 | | |
| 252 | +| timestamp | long | 时间戳(ms) | | |
| 253 | +| operCode | short | 一级协议 | | |
| 254 | +| data.companyCode | short | 公司代码 | | |
| 255 | +| data.deviceId | string | 设备编号 | | |
| 256 | +| data.timestamp | long | 时间戳 | | |
| 257 | +| data.instructType | short | 保留 默认0 | | |
| 258 | +| data.dispatchInstruct | short | 调度指令 调度指令。0X00表示信息短语,0X01表示取消上次指令+调度指令(闹钟有效),0x02表示为调度指令(闹钟有效); 0x03表示运营状态指令(闹钟无效);0x04表示其他指令。| | |
| 259 | +| data.msgId | long | 同上 | | |
| 260 | +| data.alarmTime | long | 闹钟 MMddhhmm| | |
| 261 | +| data.serviceState | long | 多状态字节 先由车载发起车辆故障、事故报告、扣证、纠纷、加油等审请,经调度确认后,下发调度指令与运营状态。当调度指令为0X00终端需要提示信息。当调度指令为0x01和0x02,终端需要收到后提示信息。并且必须在闹钟结束后进行终端相关状态更新。在闹钟时间前120秒开始提示。当调度指令为0x03,收到后进行终端相关状态更新,终端不需要提示信息。当调度指令为0x04,暂不需要提示信息。| | |
| 262 | +| data.txtContent | string | 下发的消息文本 | | |
| 263 | +```json | |
| 264 | +{ | |
| 265 | + "deviceId":12345, | |
| 266 | + "timestamp":44324, | |
| 267 | + "operCode":0x64, | |
| 268 | + "data":{ | |
| 269 | + "cityCode":22, | |
| 270 | + "deviceId":"029L2222", | |
| 271 | + "lineId":"134326" | |
| 272 | + } | |
| 273 | +} | |
| 274 | +``` | |
| 275 | +| .. | .. | .. | | |
| 276 | +| ---- | ---- | ---- | | |
| 277 | +| deviceId | string | 设备编号 | | |
| 278 | +| timestamp | long | 时间戳(ms) | | |
| 279 | +| operCode | short | 一级协议 | | |
| 280 | +| data.cityCode | short | 城市区号 | | |
| 281 | +| data.deviceId | string | 设备编号 | | |
| 282 | +| data.lineId | string | 线路编号 6位 不足6位前面补0 如编号890 用000890表示 | | |
| 283 | + | |
| 284 | +```json | |
| 285 | +{ | |
| 286 | + "deviceId":12345, | |
| 287 | + "timestamp":44324, | |
| 288 | + "operCode":0xC0, | |
| 289 | + "data":{ | |
| 290 | + "operCode":0x86, | |
| 291 | + "requestAck":0x06 | |
| 292 | + } | |
| 293 | +} | |
| 294 | +``` | |
| 295 | +| .. | .. | .. | | |
| 296 | +| ---- | ---- | ---- | | |
| 297 | +| deviceId | string | 设备编号 | | |
| 298 | +| timestamp | long | 时间戳(ms) | | |
| 299 | +| operCode | short | 一级协议 | | |
| 300 | +| data.operCode | short | 二级协议 | | |
| 301 | +| data.requestAck | short | 请求应答字 0x06同意 0x15不同意| | |
| 302 | + | |
| 303 | +```json | |
| 304 | +{ | |
| 305 | + "deviceId":12345, | |
| 306 | + "timestamp":44324, | |
| 307 | + "operCode":0xC0, | |
| 308 | + "data":{ | |
| 309 | + "operCode":0xa3, | |
| 310 | + "deviceId":12345, | |
| 311 | + "ipAddress":222.66.0.204, | |
| 312 | + "port":8899, | |
| 313 | + "reportMode":0, | |
| 314 | + "interval":0, | |
| 315 | + "distance":0, | |
| 316 | + "speedingThreshold":0, | |
| 317 | + "alarmThreshold":0, | |
| 318 | + "posIpAddress":0, | |
| 319 | + "posPort":0, | |
| 320 | + "delay":0, | |
| 321 | + "speedThreshold1":0, | |
| 322 | + "speedThreshold2":0, | |
| 323 | + "contrast":0, | |
| 324 | + "brightness":0, | |
| 325 | + "saturation":0 | |
| 326 | + } | |
| 327 | +} | |
| 328 | +``` | |
| 329 | +| .. | .. | .. | | |
| 330 | +| ---- | ---- | ---- | | |
| 331 | +| deviceId | string | 设备编号 | | |
| 332 | +| timestamp | long | 时间戳(ms) | | |
| 333 | +| operCode | short | 一级协议 | | |
| 334 | +| data.operCode | short | 二级协议 | | |
| 335 | +| data.deviceId | string | 设备编号| | |
| 336 | +| data.ipAddress | string | 网关IP地址| | |
| 337 | +| data.port | string | 网关端口| | |
| 338 | +| data.reportMode | short | 定时定距上报模式| | |
| 339 | +| data.interval | int | 定时上报时间间隔| | |
| 340 | +| data.distance | string | 定距上报距离间隔| | |
| 341 | +| data.speedingThreshold | short | 非线路状态超速阀门| | |
| 342 | +| data.alarmThreshold | short | 预警阀门| | |
| 343 | +| data.posIpAddress | string | pos机IP地址| | |
| 344 | +| data.posPort | string | pos机端口| | |
| 345 | +| data.delay | int | 延迟机关时间| | |
| 346 | +| data.deviceId | short | 中门视频切换到码表界面速度阀门 默认45| | |
| 347 | +| data.deviceId | short | 码表界面切换到中门视频速度阀门 默认35| | |
| 348 | +| data.deviceId | short | 对比度| | |
| 349 | +| data.deviceId | short | 亮度| | |
| 350 | +| data.deviceId | short | 饱和度| | |
| 351 | + | |
| 352 | +```json | |
| 353 | +{ | |
| 354 | + "deviceId":12345, | |
| 355 | + "timestamp":44324, | |
| 356 | + "operCode":0xC0, | |
| 357 | + "data":{ | |
| 358 | + "operCode":0xa4 | |
| 359 | + } | |
| 360 | +} | |
| 361 | +``` | |
| 362 | +| .. | .. | .. | | |
| 363 | +| ---- | ---- | ---- | | |
| 364 | +| deviceId | string | 设备编号 | | |
| 365 | +| timestamp | long | 时间戳(ms) | | |
| 366 | +| operCode | short | 一级协议 | | |
| 367 | +| data.operCode | short | 二级协议 | | |
| 368 | + | |
| 369 | +```json | |
| 370 | +{ | |
| 371 | + "deviceId":12345, | |
| 372 | + "timestamp":44324, | |
| 373 | + "operCode":0xC0, | |
| 374 | + "data":{ | |
| 375 | + "operCode":0xa5 | |
| 376 | + "programVersion":2 | |
| 377 | + } | |
| 378 | +} | |
| 379 | +``` | |
| 380 | +| .. | .. | .. | | |
| 381 | +| ---- | ---- | ---- | | |
| 382 | +| deviceId | string | 设备编号 | | |
| 383 | +| timestamp | long | 时间戳(ms) | | |
| 384 | +| operCode | short | 一级协议 | | |
| 385 | +| data.operCode | short | 二级协议 | | |
| 386 | +| data.programVersion | short | 程序版本 | | |
| 387 | + | |
| 388 | +<span style="color: red">Response</span>: | |
| 389 | +```json | |
| 390 | +{ | |
| 391 | + "errCode":0 | |
| 392 | +} | |
| 393 | +``` | |
| 394 | + | |
| 395 | +### 调度消息上传接口 | |
| 396 | +---------- | |
| 397 | +上行POST地址:[http://192.168.168.120:9088/control/upstream](http://192.168.168.120:9088/control/upstream) | |
| 398 | +<span style="color: red">Request</span>: | |
| 399 | +```json | |
| 400 | +{ | |
| 401 | + "deviceId":12345, | |
| 402 | + "timestamp":44324, | |
| 403 | + "status":0, | |
| 404 | + "operCode":0x80, | |
| 405 | + "data":{ | |
| 406 | + "operCode":0x26, | |
| 407 | + "requestCode":22 | |
| 408 | + } | |
| 409 | +} | |
| 410 | +``` | |
| 411 | +| .. | .. | .. | | |
| 412 | +| ---- | ---- | ---- | | |
| 413 | +| deviceId | string | 设备编号 | | |
| 414 | +| timestamp | long | 时间戳(ms) | | |
| 415 | +| status | int | 0x80时无数据 0表示失败 1表示成功或设备确认 2表示驾驶员阅读 | | |
| 416 | +| operCode | short | 一级协议 消息确认将无数据 | | |
| 417 | +| data.operCode | short | 二级协议 | | |
| 418 | +| data.requestCode | short | 请求代码0xa1 恢复运营 0xa2 申请调档 0xa3 出场请求 0xa5 进场请求 0xa7 加油请求 0x50 车辆故障 0x70 路阻报告 0x60 事故报告 0x11 扣证纠纷 0x12 报警 | | |
| 419 | +<span style="color: red">Response</span>: | |
| 420 | +```json | |
| 421 | +{ | |
| 422 | + "errCode":0 | |
| 423 | +} | |
| 424 | +``` | |
| 425 | + | |
| 426 | +### 车辆历史GPS | |
| 427 | +---------- | |
| 428 | +表名:BSTH_C_GPS_INFO | |
| 429 | + | |
| 430 | +| .. | .. | .. | | |
| 431 | +| ---- | ---- | ---- | | |
| 432 | +| cityCode | int | 城市代码 | | |
| 433 | +| industryCode | int | 行业代码 | | |
| 434 | +| companyCode | int | 企业代码 | | |
| 435 | +| lineId | int | 线路编号 | | |
| 436 | +| deviceId | string | 设备编号 | | |
| 437 | +| driverNo | int | 驾驶员工号 | | |
| 438 | +| carparkSerialNo | int | 停车场序列号 | | |
| 439 | +| carparkNo | string | 停车场编号 | | |
| 440 | +| stopSerialNo | int | 站点序列号 | | |
| 441 | +| stopNo | string | 停车场编号 | | |
| 442 | +| lon | float | 经度 | | |
| 443 | +| lat | float | 维度 | | |
| 444 | +| ts | long | 时间戳 | | |
| 445 | +| speedSensor | float | 发动机速度 | | |
| 446 | +| speedGps | float | gps速度 | | |
| 447 | +| direction | float | 角度0-359 | | |
| 448 | +| inTemp | int | 车内温度 | | |
| 449 | +| serviceState | long | 设备状态字 | | |
| 450 | +<<<<<<< HEAD | |
| 451 | +| daysYear | int | 对应年中的天数 为分区字段 查询一定要用此字段过滤 | | |
| 452 | +======= | |
| 453 | +| daysYear | int | 对应年中的天数 为分区字段 查询一定要用此字段过滤 | | |
| 454 | + | |
| 455 | +>>>>>>> af8ec3bedc8644f5813e9adab12a163e93cc7f50 | ... | ... |
pom.xml
| ... | ... | @@ -219,6 +219,12 @@ |
| 219 | 219 | <artifactId>jaxrpc-api</artifactId> |
| 220 | 220 | <version>1.1</version> |
| 221 | 221 | </dependency> |
| 222 | + | |
| 223 | + <dependency> | |
| 224 | + <groupId>org.springframework.boot</groupId> | |
| 225 | + <artifactId>spring-boot-devtools</artifactId> | |
| 226 | + <optional>true</optional> | |
| 227 | + </dependency> | |
| 222 | 228 | </dependencies> |
| 223 | 229 | |
| 224 | 230 | <dependencyManagement> |
| ... | ... | @@ -248,7 +254,6 @@ |
| 248 | 254 | <artifactId>maven-war-plugin</artifactId> |
| 249 | 255 | <version>2.2</version><!--$NO-MVN-MAN-VER$ --> |
| 250 | 256 | <configuration> |
| 251 | - <version>3.1</version> | |
| 252 | 257 | <failOnMissingWebXml>false</failOnMissingWebXml> |
| 253 | 258 | </configuration> |
| 254 | 259 | </plugin> |
| ... | ... | @@ -257,6 +262,12 @@ |
| 257 | 262 | <artifactId>spring-boot-maven-plugin</artifactId> |
| 258 | 263 | </plugin> |
| 259 | 264 | </plugins> |
| 265 | + <resources> | |
| 266 | + <resource> | |
| 267 | + <directory>src/main/resources</directory> | |
| 268 | + <filtering>false</filtering> | |
| 269 | + </resource> | |
| 270 | + </resources> | |
| 260 | 271 | </build> |
| 261 | 272 | <repositories> |
| 262 | 273 | <repository> | ... | ... |
src/main/java/com/bsth/ServiceStateTest.java
| ... | ... | @@ -3,8 +3,8 @@ package com.bsth; |
| 3 | 3 | public class ServiceStateTest { |
| 4 | 4 | |
| 5 | 5 | public static void main(String[] args) { |
| 6 | - System.out.println("运营状态:" + getService(268435456)); | |
| 7 | - System.out.println("上下行:" + getUpOrDown(268435456)); | |
| 6 | + System.out.println("运营状态:" + getService(603979776)); | |
| 7 | + System.out.println("上下行:" + getUpOrDown(603979776)); | |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | /** | ... | ... |
src/main/java/com/bsth/WebAppConfiguration.java
| ... | ... | @@ -25,8 +25,8 @@ import com.bsth.websocket.handler.RealControlSocketHandler; |
| 25 | 25 | @ComponentScan |
| 26 | 26 | public class WebAppConfiguration extends WebMvcConfigurerAdapter implements WebSocketConfigurer{ |
| 27 | 27 | |
| 28 | - @Autowired | |
| 29 | - HttpOpLogInterceptor httpOpLogInterceptor; | |
| 28 | +// @Autowired | |
| 29 | +// HttpOpLogInterceptor httpOpLogInterceptor; | |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * @Title: httpPutFormContentFilter |
| ... | ... | @@ -63,11 +63,11 @@ public class WebAppConfiguration extends WebMvcConfigurerAdapter implements WebS |
| 63 | 63 | * |
| 64 | 64 | * @Title: addInterceptors |
| 65 | 65 | * @Description: TODO(HTTP结构化访问日志记录 ) |
| 66 | - */ | |
| 66 | + | |
| 67 | 67 | @Override |
| 68 | 68 | public void addInterceptors(InterceptorRegistry registry) { |
| 69 | 69 | registry.addInterceptor(httpOpLogInterceptor); |
| 70 | - } | |
| 70 | + }*/ | |
| 71 | 71 | |
| 72 | 72 | @Override |
| 73 | 73 | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { | ... | ... |
src/main/java/com/bsth/controller/BaseController.java
| ... | ... | @@ -17,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile; |
| 17 | 17 | |
| 18 | 18 | import javax.servlet.http.HttpServletResponse; |
| 19 | 19 | import java.io.*; |
| 20 | +import java.util.ArrayList; | |
| 20 | 21 | import java.util.HashMap; |
| 21 | 22 | import java.util.List; |
| 22 | 23 | import java.util.Map; |
| ... | ... | @@ -54,18 +55,31 @@ public class BaseController<T, ID extends Serializable> { |
| 54 | 55 | @RequestParam(defaultValue = "id") String order, |
| 55 | 56 | @RequestParam(defaultValue = "DESC") String direction){ |
| 56 | 57 | |
| 57 | - Direction d; | |
| 58 | - | |
| 59 | - if(null != direction && direction.equals("ASC")) | |
| 60 | - d = Direction.ASC; | |
| 61 | - else | |
| 62 | - d = Direction.DESC; | |
| 63 | - | |
| 64 | 58 | // 允许多个字段排序,order可以写单个字段,也可以写多个字段 |
| 65 | 59 | // 多个字段格式:{col1},{col2},{col3},....,{coln} |
| 66 | - // 每个字段的排序方向都是一致,这个以后再看要不要改 | |
| 67 | - List<String> list = Splitter.on(",").trimResults().splitToList(order); | |
| 68 | - return baseService.list(map, new PageRequest(page, size, new Sort(d, list))); | |
| 60 | + List<String> order_columns = Splitter.on(",").trimResults().splitToList(order); | |
| 61 | + // 多字段排序:DESC,ASC... | |
| 62 | + List<String> order_dirs = Splitter.on(",").trimResults().splitToList(direction); | |
| 63 | + | |
| 64 | + if (order_dirs.size() == 1) { // 所有字段采用一种排序 | |
| 65 | + if (null != order_dirs.get(0) && order_dirs.get(0).equals("ASC")) { | |
| 66 | + return baseService.list(map, new PageRequest(page, size, new Sort(Direction.ASC, order_columns))); | |
| 67 | + } else { | |
| 68 | + return baseService.list(map, new PageRequest(page, size, new Sort(Direction.DESC, order_columns))); | |
| 69 | + } | |
| 70 | + } else if (order_columns.size() == order_dirs.size()) { | |
| 71 | + List<Sort.Order> orderList = new ArrayList<>(); | |
| 72 | + for (int i = 0; i < order_columns.size(); i++) { | |
| 73 | + if (null != order_dirs.get(i) && order_dirs.get(i).equals("ASC")) { | |
| 74 | + orderList.add(new Sort.Order(Direction.ASC, order_columns.get(i))); | |
| 75 | + } else { | |
| 76 | + orderList.add(new Sort.Order(Direction.DESC, order_columns.get(i))); | |
| 77 | + } | |
| 78 | + } | |
| 79 | + return baseService.list(map, new PageRequest(page, size, new Sort(orderList))); | |
| 80 | + } else { | |
| 81 | + throw new RuntimeException("多字段排序参数格式问题,排序顺序和字段数不一致"); | |
| 82 | + } | |
| 69 | 83 | } |
| 70 | 84 | |
| 71 | 85 | /** | ... | ... |
src/main/java/com/bsth/controller/CarDeviceController.java
| 1 | 1 | package com.bsth.controller; |
| 2 | 2 | |
| 3 | +import com.bsth.common.ResponseCode; | |
| 3 | 4 | import com.bsth.entity.CarDevice; |
| 5 | +import com.bsth.service.CarDeviceService; | |
| 6 | +import org.joda.time.DateTime; | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | 8 | import org.springframework.web.bind.annotation.RequestBody; |
| 5 | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
| 6 | 10 | import org.springframework.web.bind.annotation.RequestMethod; |
| 7 | 11 | import org.springframework.web.bind.annotation.RestController; |
| 8 | 12 | |
| 13 | +import java.util.HashMap; | |
| 14 | +import java.util.Iterator; | |
| 9 | 15 | import java.util.Map; |
| 10 | 16 | |
| 11 | 17 | /** |
| 12 | 18 | * Created by xu on 16/6/15. |
| 13 | 19 | */ |
| 14 | 20 | @RestController |
| 15 | -@RequestMapping("carDevice") | |
| 21 | +@RequestMapping("cde") | |
| 16 | 22 | public class CarDeviceController extends BaseController<CarDevice, Long> { |
| 17 | - | |
| 23 | + @Autowired | |
| 24 | + private CarDeviceService carDeviceService; | |
| 18 | 25 | /** |
| 19 | 26 | * 覆写方法,因为form提交的方式参数不全,改用 json形式提交 @RequestBody |
| 20 | 27 | * @Title: save |
| ... | ... | @@ -28,4 +35,22 @@ public class CarDeviceController extends BaseController<CarDevice, Long> { |
| 28 | 35 | public Map<String, Object> save(@RequestBody CarDevice t){ |
| 29 | 36 | return baseService.save(t); |
| 30 | 37 | } |
| 38 | + | |
| 39 | + @RequestMapping(value = "/validate/qyrq", method = RequestMethod.GET) | |
| 40 | + public Map<String, Object> validateQyrq(String qyrq, Integer xl, Integer cl) { | |
| 41 | + // 验证启用日期,必须是最大的日期,就是最晚的日期 | |
| 42 | + Map<String, Object> obj = new HashMap<>(); | |
| 43 | + obj.put("xl_eq", xl); | |
| 44 | + obj.put("cl_eq", cl); | |
| 45 | + obj.put("qyrq_ge", new DateTime(qyrq).toDate()); | |
| 46 | + Iterator<CarDevice> iterator = carDeviceService.list(obj).iterator(); | |
| 47 | + if (iterator.hasNext()) { | |
| 48 | + obj.clear(); | |
| 49 | + obj.put("status", ResponseCode.ERROR); | |
| 50 | + } else { | |
| 51 | + obj.clear(); | |
| 52 | + obj.put("status", ResponseCode.SUCCESS); | |
| 53 | + } | |
| 54 | + return obj; | |
| 55 | + } | |
| 31 | 56 | } | ... | ... |
src/main/java/com/bsth/controller/oil/YlbController.java
| ... | ... | @@ -2,7 +2,9 @@ package com.bsth.controller.oil; |
| 2 | 2 | |
| 3 | 3 | import java.text.ParseException; |
| 4 | 4 | import java.text.SimpleDateFormat; |
| 5 | +import java.util.ArrayList; | |
| 5 | 6 | import java.util.Date; |
| 7 | +import java.util.Iterator; | |
| 6 | 8 | import java.util.List; |
| 7 | 9 | import java.util.Map; |
| 8 | 10 | |
| ... | ... | @@ -44,14 +46,47 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 44 | 46 | * @return |
| 45 | 47 | */ |
| 46 | 48 | @RequestMapping(value = "/obtain",method = RequestMethod.GET) |
| 47 | - public List<Map<String, Object>> obtain(@RequestParam Map<String, Object> map){ | |
| 49 | + public Map<String, Object> obtain(@RequestParam Map<String, Object> map){ | |
| 48 | 50 | String rq=map.get("rq").toString(); |
| 49 | - List<Map<String, Object>> list=yblService.obtain(rq); | |
| 51 | + Map<String, Object> list=yblService.obtain(rq); | |
| 50 | 52 | System.out.println(); |
| 51 | 53 | return list; |
| 52 | 54 | } |
| 53 | 55 | |
| 54 | 56 | /** |
| 57 | + * 拆分油量 | |
| 58 | + * @param map | |
| 59 | + * @return | |
| 60 | + */ | |
| 61 | + @RequestMapping(value = "/sort",method = RequestMethod.GET) | |
| 62 | + public Map<String, Object> sort(@RequestParam Map<String, Object> map){ | |
| 63 | + Map<String, Object> list=yblService.sort(map); | |
| 64 | + return list; | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * 进场油量等于出场油量 | |
| 69 | + * @param map | |
| 70 | + * @return | |
| 71 | + */ | |
| 72 | + @RequestMapping(value = "/outAndIn",method = RequestMethod.GET) | |
| 73 | + public Map<String, Object> outAndIn(@RequestParam Map<String, Object> map){ | |
| 74 | + Map<String, Object> list=yblService.outAndIn(map); | |
| 75 | + return list; | |
| 76 | + } | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * 核对油量(有加油没里程) | |
| 80 | + * @param map | |
| 81 | + * @return | |
| 82 | + */ | |
| 83 | + @RequestMapping(value = "/checkYl",method = RequestMethod.GET) | |
| 84 | + public Map<String, Object> checkYl(@RequestParam Map<String, Object> map){ | |
| 85 | + Map<String, Object> list=yblService.checkYl(map); | |
| 86 | + return list; | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 55 | 90 | * |
| 56 | 91 | * @Title: list |
| 57 | 92 | * @Description: TODO(多条件分页查询) | ... | ... |
src/main/java/com/bsth/controller/oil/YlxxbController.java
| 1 | 1 | package com.bsth.controller.oil; |
| 2 | 2 | |
| 3 | +import java.util.Map; | |
| 4 | + | |
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 3 | 6 | import org.springframework.web.bind.annotation.RequestMapping; |
| 7 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 4 | 9 | import org.springframework.web.bind.annotation.RestController; |
| 5 | 10 | |
| 6 | 11 | import com.bsth.controller.BaseController; |
| 7 | 12 | import com.bsth.entity.oil.Ylxxb; |
| 13 | +import com.bsth.service.oil.YlxxbService; | |
| 14 | +import com.bsth.util.PageObject; | |
| 8 | 15 | |
| 9 | 16 | @RestController |
| 10 | 17 | @RequestMapping("ylxxb") |
| 11 | 18 | public class YlxxbController extends BaseController<Ylxxb, Integer>{ |
| 12 | - | |
| 19 | + @Autowired | |
| 20 | + private YlxxbService service; | |
| 21 | + @RequestMapping(value = "/pagequery",method = RequestMethod.GET) | |
| 22 | + public PageObject<Ylxxb> pagequery(@RequestParam Map<String, Object> map){ | |
| 23 | + PageObject<Ylxxb> pagequery=null; | |
| 24 | + map.put("curPage", map.get("page").toString()); | |
| 25 | + map.put("pageData","10"); | |
| 26 | + pagequery=service.Pagequery(map); | |
| 27 | + return pagequery; | |
| 28 | + } | |
| 29 | + | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 核对油量(有加油没里程) | |
| 33 | + * @param map | |
| 34 | + * @return | |
| 35 | + */ | |
| 36 | + @RequestMapping(value = "/check",method = RequestMethod.GET) | |
| 37 | + public Map<String, Object> check(@RequestParam Map<String, Object> map){ | |
| 38 | + Map<String, Object> list=service.checkJsy(map); | |
| 39 | + return list; | |
| 40 | + } | |
| 13 | 41 | } | ... | ... |
src/main/java/com/bsth/controller/realcontrol/BasicDataController.java
| ... | ... | @@ -21,6 +21,11 @@ public class BasicDataController { |
| 21 | 21 | return BasicData.deviceId2NbbmMap.values(); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | + @RequestMapping("/nbbm2deviceId") | |
| 25 | + public Map<String, String> nbbm2deviceId(Map<String, Object> map){ | |
| 26 | + return BasicData.deviceId2NbbmMap.inverse(); | |
| 27 | + } | |
| 28 | + | |
| 24 | 29 | @RequestMapping("/lineCode2Name") |
| 25 | 30 | public Map<String, String> findLineCodeMap(){ |
| 26 | 31 | return BasicData.lineCode2NameMap; |
| ... | ... | @@ -47,6 +52,15 @@ public class BasicDataController { |
| 47 | 52 | return rs; |
| 48 | 53 | } |
| 49 | 54 | |
| 55 | + @RequestMapping("/all_personnel") | |
| 56 | + public Map<String, String> all_personnel(){ | |
| 57 | + //Map<String, Object> rs = new HashMap<>(); | |
| 58 | + //PersonnelFieldFilter filter=new PersonnelFieldFilter(); | |
| 59 | + | |
| 60 | + //rs.put("list", JSON.parse(JSON.toJSONString(BasicData.jsyMap.values(), filter))); | |
| 61 | + return BasicData.allPerson; | |
| 62 | + } | |
| 63 | + | |
| 50 | 64 | |
| 51 | 65 | public class PersonnelFieldFilter implements PropertyFilter{ |
| 52 | 66 | ... | ... |
src/main/java/com/bsth/controller/schedule/GuideboardInfoController.java
| ... | ... | @@ -8,8 +8,12 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 8 | 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| 9 | 9 | import org.springframework.web.bind.annotation.PathVariable; |
| 10 | 10 | import org.springframework.web.bind.annotation.RequestMapping; |
| 11 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 11 | 12 | import org.springframework.web.bind.annotation.RestController; |
| 12 | 13 | |
| 14 | +import java.util.List; | |
| 15 | +import java.util.Map; | |
| 16 | + | |
| 13 | 17 | /** |
| 14 | 18 | * Created by xu on 16/5/11. |
| 15 | 19 | */ |
| ... | ... | @@ -31,4 +35,10 @@ public class GuideboardInfoController extends BaseController<GuideboardInfo, Lon |
| 31 | 35 | public GuideboardInfo findById(@PathVariable("id") Long aLong) { |
| 32 | 36 | return guideboardInfoRepository.findOneExtend(aLong); |
| 33 | 37 | } |
| 38 | + | |
| 39 | + | |
| 40 | + @RequestMapping(value = "/ttlpnames", method = RequestMethod.GET) | |
| 41 | + public List<Map<String, Object>> findLpName(Long ttid) { | |
| 42 | + return guideboardInfoRepository.findLpName(ttid); | |
| 43 | + } | |
| 34 | 44 | } | ... | ... |
src/main/java/com/bsth/controller/schedule/RerunController.java
0 → 100644
| 1 | +package com.bsth.controller.schedule; | |
| 2 | + | |
| 3 | +import com.bsth.controller.BaseController; | |
| 4 | +import com.bsth.entity.schedule.rule.RerunRule; | |
| 5 | +import com.bsth.repository.schedule.RerunRuleRepository; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.web.bind.annotation.*; | |
| 8 | + | |
| 9 | +import java.util.Map; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Created by xu on 16/10/20. | |
| 13 | + */ | |
| 14 | +@RestController | |
| 15 | +@RequestMapping("rms") | |
| 16 | +public class RerunController extends BaseController<RerunRule, Long> { | |
| 17 | + | |
| 18 | + @Autowired | |
| 19 | + private RerunRuleRepository rerunRuleRepository; | |
| 20 | + | |
| 21 | + @Override | |
| 22 | + public RerunRule findById(@PathVariable("id") Long aLong) { | |
| 23 | + return rerunRuleRepository.findOneExtend(aLong); | |
| 24 | + } | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 覆写方法,因为form提交的方式参数不全,改用 json形式提交 @RequestBody | |
| 28 | + * @Title: save | |
| 29 | + * @Description: TODO(持久化对象) | |
| 30 | + * @param @param t | |
| 31 | + * @param @return 设定文件 | |
| 32 | + * @return Map<String,Object> {status: 1(成功),-1(失败)} | |
| 33 | + * @throws | |
| 34 | + */ | |
| 35 | + @RequestMapping(method = RequestMethod.POST) | |
| 36 | + public Map<String, Object> save(@RequestBody RerunRule t){ | |
| 37 | + return baseService.save(t); | |
| 38 | + } | |
| 39 | + | |
| 40 | + | |
| 41 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/TTInfoDetailController.java
| ... | ... | @@ -16,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile; |
| 16 | 16 | |
| 17 | 17 | import java.util.HashMap; |
| 18 | 18 | import java.util.Iterator; |
| 19 | +import java.util.List; | |
| 19 | 20 | import java.util.Map; |
| 20 | 21 | |
| 21 | 22 | /** |
| ... | ... | @@ -111,4 +112,9 @@ public class TTInfoDetailController extends BaseController<TTInfoDetail, Long> { |
| 111 | 112 | public TTInfoDetail findById(@PathVariable("id") Long aLong) { |
| 112 | 113 | return ttInfoDetailRepository.findOneExtend(aLong); |
| 113 | 114 | } |
| 115 | + | |
| 116 | + @RequestMapping(value = "/bcdetail", method = RequestMethod.GET) | |
| 117 | + public List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId) { | |
| 118 | + return ttInfoDetailRepository.findBcdetails(xlId, ttinfoId, lpId); | |
| 119 | + } | |
| 114 | 120 | } | ... | ... |
src/main/java/com/bsth/data/BasicData.java
src/main/java/com/bsth/data/arrival/AnalyseData.java
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
| ... | ... | @@ -51,7 +51,7 @@ public class ArrivalData_GPS implements CommandLineRunner{ |
| 51 | 51 | @Override |
| 52 | 52 | public void run(String... arg0) throws Exception { |
| 53 | 53 | logger.info("ArrivalData_GPS,30,10"); |
| 54 | - Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 30, 10, TimeUnit.SECONDS); | |
| 54 | + //Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 40, 10, TimeUnit.SECONDS); | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | @Component |
| ... | ... | @@ -144,4 +144,4 @@ public class ArrivalData_GPS implements CommandLineRunner{ |
| 144 | 144 | carIndexMap.put(nbbm, size); |
| 145 | 145 | return rs; |
| 146 | 146 | } |
| 147 | -} | |
| 147 | +} | |
| 148 | 148 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/arrival/DataLoader.java
| ... | ... | @@ -58,7 +58,7 @@ public class DataLoader { |
| 58 | 58 | PreparedStatement ps = null; |
| 59 | 59 | ResultSet rs = null; |
| 60 | 60 | |
| 61 | - String sql = "select * from bsth_c_arrival_info where weeks_year=? AND create_timestamp > ? AND create_timestamp <=? AND ABS(create_timestamp - ts) < 3600000 order by ts"; | |
| 61 | + String sql = "select * from bsth_c_arrival_info where weeks_year=? AND create_timestamp > ? AND create_timestamp <=? AND ABS(create_timestamp - ts) < 3600000 order by create_date"; | |
| 62 | 62 | try{ |
| 63 | 63 | long t = System.currentTimeMillis(); |
| 64 | 64 | ... | ... |
src/main/java/com/bsth/data/directive/FirstScheduleCheckThread.java
| ... | ... | @@ -8,6 +8,8 @@ import org.slf4j.LoggerFactory; |
| 8 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | 9 | import org.springframework.stereotype.Component; |
| 10 | 10 | |
| 11 | +import com.bsth.data.match.Arrival2Schedule; | |
| 12 | +import com.bsth.data.match.ExpectArrivalEnd; | |
| 11 | 13 | import com.bsth.data.schedule.DayOfSchedule; |
| 12 | 14 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 13 | 15 | import com.bsth.service.directive.DirectiveService; |
| ... | ... | @@ -43,9 +45,7 @@ public class FirstScheduleCheckThread extends Thread{ |
| 43 | 45 | List<ScheduleRealInfo> schList; |
| 44 | 46 | ScheduleRealInfo first; |
| 45 | 47 | for(String car : cars){ |
| 46 | - if(car.equals("SXC-CD1004")){ | |
| 47 | - System.out.println("debugger..."); | |
| 48 | - } | |
| 48 | + | |
| 49 | 49 | schList = dayOfSchedule.findByNbbm(car); |
| 50 | 50 | |
| 51 | 51 | if(null == schList || schList.size() == 0) |
| ... | ... | @@ -65,6 +65,26 @@ public class FirstScheduleCheckThread extends Thread{ |
| 65 | 65 | && Math.abs(first.getDfsjT() - t) < THREE_MINUTES){ |
| 66 | 66 | |
| 67 | 67 | directiveService.send60Dispatch(first, dayOfSchedule.doneSum(first.getClZbh()), "定补@系统"); |
| 68 | + //期望完成出场班次时间 | |
| 69 | + long endTime; | |
| 70 | + | |
| 71 | + if(first.getZdsj() != null) | |
| 72 | + endTime=first.getZdsjT() - 60000; | |
| 73 | + else | |
| 74 | + endTime=schList.get(1).getDfsjT() - 60000; | |
| 75 | + | |
| 76 | + ExpectArrivalEnd ead = new ExpectArrivalEnd() | |
| 77 | + ,ead2 = new ExpectArrivalEnd(); | |
| 78 | + ead.setNbbm(car); | |
| 79 | + ead.setEndStation(first.getQdzCode()); | |
| 80 | + ead.setEndTime(endTime); | |
| 81 | + | |
| 82 | + ead2.setNbbm(car); | |
| 83 | + ead2.setEndStation(first.getZdzCode()); | |
| 84 | + ead2.setEndTime(endTime); | |
| 85 | + | |
| 86 | + Arrival2Schedule.addExpect(car, ead); | |
| 87 | + Arrival2Schedule.addExpect(car, ead2); | |
| 68 | 88 | } |
| 69 | 89 | } |
| 70 | 90 | } | ... | ... |
src/main/java/com/bsth/data/directive/GatewayHttpUtils.java
| ... | ... | @@ -52,7 +52,7 @@ public class GatewayHttpUtils { |
| 52 | 52 | post.setEntity(new StringEntity(jsonStr, "utf-8")); |
| 53 | 53 | |
| 54 | 54 | CloseableHttpResponse response = httpClient.execute(post); |
| 55 | - | |
| 55 | + | |
| 56 | 56 | JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity())); |
| 57 | 57 | if(null != json && json.getInteger("errCode") == 0) |
| 58 | 58 | code = 0; | ... | ... |
src/main/java/com/bsth/data/forecast/ForecastRealServer.java
| ... | ... | @@ -61,7 +61,7 @@ public class ForecastRealServer implements CommandLineRunner { |
| 61 | 61 | @Override |
| 62 | 62 | public void run(String... arg0) throws Exception { |
| 63 | 63 | //2小时更新一次站点间耗时数据 |
| 64 | - Application.mainServices.scheduleWithFixedDelay(dataLoader, 12, 120 * 60, TimeUnit.SECONDS); | |
| 64 | + //Application.mainServices.scheduleWithFixedDelay(dataLoader, 12, 120 * 60, TimeUnit.SECONDS); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** | ... | ... |
src/main/java/com/bsth/data/forecast/SampleTimeDataLoader.java
| 1 | 1 | package com.bsth.data.forecast; |
| 2 | 2 | |
| 3 | -import java.text.SimpleDateFormat; | |
| 4 | 3 | import java.util.ArrayList; |
| 5 | 4 | import java.util.Collections; |
| 6 | 5 | import java.util.Comparator; |
| ... | ... | @@ -9,6 +8,8 @@ import java.util.Iterator; |
| 9 | 8 | import java.util.List; |
| 10 | 9 | import java.util.Set; |
| 11 | 10 | |
| 11 | +import org.joda.time.format.DateTimeFormat; | |
| 12 | +import org.joda.time.format.DateTimeFormatter; | |
| 12 | 13 | import org.slf4j.Logger; |
| 13 | 14 | import org.slf4j.LoggerFactory; |
| 14 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -39,14 +40,14 @@ public class SampleTimeDataLoader extends Thread { |
| 39 | 40 | // 当天日期 |
| 40 | 41 | String rq; |
| 41 | 42 | |
| 42 | - SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 43 | + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm") | |
| 44 | + ,fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | |
| 43 | 45 | |
| 44 | 46 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 45 | 47 | |
| 46 | 48 | @Override |
| 47 | 49 | public void run() { |
| 48 | - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); | |
| 49 | - rq = sdfyyyyMMdd.format(new Date()); | |
| 50 | + rq = fmtyyyyMMdd.print(new Date().getTime()); | |
| 50 | 51 | |
| 51 | 52 | Iterator<Sample> iterator = sampleRepository.findAll().iterator(); |
| 52 | 53 | ArrayListMultimap<String, Sample> sampleMap = ArrayListMultimap.create(); |
| ... | ... | @@ -103,8 +104,9 @@ public class SampleTimeDataLoader extends Thread { |
| 103 | 104 | TimeRange tg; |
| 104 | 105 | for (Sample s : list) { |
| 105 | 106 | tg = new TimeRange(); |
| 106 | - tg.startTime = sdfyyyyMMddHHmm.parse(rq + s.getsDate()).getTime(); | |
| 107 | - tg.endTime = sdfyyyyMMddHHmm.parse(rq + s.geteDate()).getTime(); | |
| 107 | + | |
| 108 | + tg.startTime = fmtyyyyMMddHHmm.parseMillis(rq + s.getsDate()); | |
| 109 | + tg.endTime = fmtyyyyMMddHHmm.parseMillis(rq + s.geteDate()); | |
| 108 | 110 | tg.runTime = s.getRunTime(); |
| 109 | 111 | simple.ranges.add(tg); |
| 110 | 112 | } | ... | ... |
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
| ... | ... | @@ -34,7 +34,7 @@ import com.google.common.collect.TreeMultimap; |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * |
| 37 | - * @ClassName: GpsRealEntityBuffer | |
| 37 | + * @ClassName: GpsRealData | |
| 38 | 38 | * @Description: TODO(实时GPS数据集合) |
| 39 | 39 | * @author PanZhao |
| 40 | 40 | * @date 2016年8月12日 下午2:04:41 |
| ... | ... | @@ -72,7 +72,8 @@ public class GpsRealData implements CommandLineRunner{ |
| 72 | 72 | |
| 73 | 73 | @Override |
| 74 | 74 | public void run(String... arg0) throws Exception { |
| 75 | - Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 6, TimeUnit.SECONDS); | |
| 75 | + logger.info("gpsDataLoader,20,6"); | |
| 76 | + //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 6, TimeUnit.SECONDS); | |
| 76 | 77 | } |
| 77 | 78 | |
| 78 | 79 | public GpsEntity add(GpsEntity gps) { |
| ... | ... | @@ -188,6 +189,7 @@ public class GpsRealData implements CommandLineRunner{ |
| 188 | 189 | |
| 189 | 190 | String nbbm; |
| 190 | 191 | //附加车辆内部编码 |
| 192 | + Integer updown; | |
| 191 | 193 | for(GpsEntity gps : list){ |
| 192 | 194 | nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId()); |
| 193 | 195 | if(StringUtils.isBlank(nbbm)) |
| ... | ... | @@ -196,6 +198,12 @@ public class GpsRealData implements CommandLineRunner{ |
| 196 | 198 | gps.setNbbm(nbbm); |
| 197 | 199 | |
| 198 | 200 | gps.setStationName(BasicData.stationCode2NameMap.get(gps.getStopNo())); |
| 201 | + if(gps.getUpDown() == -1){ | |
| 202 | + //如果走向未知,尝试根据站点纠正走向 | |
| 203 | + updown=BasicData.lineStationUpDownMap.get(gps.getLineId()+"_"+gps.getStopNo()); | |
| 204 | + if(updown != null) | |
| 205 | + gps.setUpDown(updown); | |
| 206 | + } | |
| 199 | 207 | gpsRealData.add(gps); |
| 200 | 208 | } |
| 201 | 209 | } else | ... | ... |
src/main/java/com/bsth/data/match/Arrival2Schedule.java
| 1 | 1 | package com.bsth.data.match; |
| 2 | 2 | |
| 3 | -import java.text.SimpleDateFormat; | |
| 4 | 3 | import java.util.ArrayList; |
| 5 | 4 | import java.util.Collections; |
| 6 | 5 | import java.util.List; |
| 7 | 6 | import java.util.Set; |
| 8 | 7 | |
| 8 | +import org.joda.time.format.DateTimeFormat; | |
| 9 | +import org.joda.time.format.DateTimeFormatter; | |
| 9 | 10 | import org.slf4j.Logger; |
| 10 | 11 | import org.slf4j.LoggerFactory; |
| 11 | 12 | import org.springframework.beans.BeansException; |
| ... | ... | @@ -13,14 +14,17 @@ import org.springframework.context.ApplicationContext; |
| 13 | 14 | import org.springframework.context.ApplicationContextAware; |
| 14 | 15 | import org.springframework.stereotype.Component; |
| 15 | 16 | |
| 17 | +import com.bsth.data.LineConfigData; | |
| 16 | 18 | import com.bsth.data.arrival.ArrivalComparator; |
| 17 | 19 | import com.bsth.data.arrival.ArrivalData_GPS; |
| 18 | 20 | import com.bsth.data.arrival.ArrivalEntity; |
| 19 | 21 | import com.bsth.data.schedule.DayOfSchedule; |
| 20 | 22 | import com.bsth.data.schedule.ScheduleComparator; |
| 23 | +import com.bsth.entity.realcontrol.LineConfig; | |
| 21 | 24 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 22 | 25 | import com.bsth.service.directive.DirectiveService; |
| 23 | 26 | import com.bsth.websocket.handler.SendUtils; |
| 27 | +import com.google.common.collect.ArrayListMultimap; | |
| 24 | 28 | |
| 25 | 29 | /** |
| 26 | 30 | * |
| ... | ... | @@ -36,12 +40,15 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 36 | 40 | private static DayOfSchedule dayOfSchedule; |
| 37 | 41 | private static SendUtils sendUtils; |
| 38 | 42 | private static DirectiveService directiveService; |
| 43 | + private static LineConfigData lineConfigData; | |
| 39 | 44 | private final static int ONE_MINUTE = 1000 * 60; |
| 40 | 45 | //定一个4小时的范围,基本能对正常班次进行容错。主要防止早上停车场GPS飘导致完成晚上的进场班次 |
| 41 | 46 | private final static int FOUR_HOURS = 1000 * 60 * 60 * 4; |
| 42 | 47 | |
| 43 | 48 | private static Logger logger = LoggerFactory.getLogger(Arrival2Schedule.class); |
| 44 | 49 | |
| 50 | + private static ArrayListMultimap<String, ExpectArrivalEnd> expectMap = ArrayListMultimap.create(); | |
| 51 | + | |
| 45 | 52 | /** |
| 46 | 53 | * |
| 47 | 54 | * @Title: start |
| ... | ... | @@ -57,6 +64,8 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 57 | 64 | |
| 58 | 65 | public static class SchMatchThread extends Thread{ |
| 59 | 66 | String nbbm; |
| 67 | + LineConfig conf; | |
| 68 | + | |
| 60 | 69 | public SchMatchThread(String nbbm){ |
| 61 | 70 | this.nbbm = nbbm; |
| 62 | 71 | } |
| ... | ... | @@ -65,8 +74,9 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 65 | 74 | private ScheduleComparator.FCSJ schComparator = new ScheduleComparator.FCSJ(); |
| 66 | 75 | private ArrivalComparator arrComparator = new ArrivalComparator(); |
| 67 | 76 | private MatchResultComparator mrComparator = new MatchResultComparator(); |
| 68 | - private SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 69 | - | |
| 77 | + | |
| 78 | + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | |
| 79 | + | |
| 70 | 80 | @Override |
| 71 | 81 | public void run() { |
| 72 | 82 | //班次列表 |
| ... | ... | @@ -77,6 +87,7 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 77 | 87 | if(schList.size() == 0 || arrList.size() == 0) |
| 78 | 88 | return; |
| 79 | 89 | |
| 90 | + conf = lineConfigData.get(schList.get(0).getXlBm()); | |
| 80 | 91 | //排序 |
| 81 | 92 | Collections.sort(schList, schComparator); |
| 82 | 93 | Collections.sort(arrList, arrComparator); |
| ... | ... | @@ -108,8 +119,8 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 108 | 119 | if(sch.isDestroy()) |
| 109 | 120 | continue; |
| 110 | 121 | |
| 111 | - //没有里程的不匹配 | |
| 112 | - if(sch.getBcsj() == null && sch.getJhlc() == null) | |
| 122 | + //线路配置出站既出场,并且没有里程的不匹配 | |
| 123 | + if(conf.getOutConfig()==2 && sch.getBcsj() == null && sch.getJhlc() == null) | |
| 113 | 124 | continue; |
| 114 | 125 | |
| 115 | 126 | list.add(sch); |
| ... | ... | @@ -189,7 +200,15 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 189 | 200 | mr = new MatchResult(); |
| 190 | 201 | mr.sch = sch; |
| 191 | 202 | mr.ts = inArr.getTs(); |
| 192 | - mr.diff = inArr.getTs() - sch.getZdsjT(); | |
| 203 | + //班次没有里程和运送时间的 | |
| 204 | + if(sch.getZdsj() == null){ | |
| 205 | + if(i < schList.size()-1) | |
| 206 | + mr.diff = inArr.getTs() - schList.get(i + 1).getDfsjT(); | |
| 207 | + else | |
| 208 | + mr.diff = inArr.getTs() - sch.getDfsjT(); | |
| 209 | + } | |
| 210 | + else | |
| 211 | + mr.diff = inArr.getTs() - sch.getZdsjT(); | |
| 193 | 212 | mr.success = dayOfSchedule.validEndTime(sch, inArr.getTs()); |
| 194 | 213 | if(Math.abs(mr.diff) < FOUR_HOURS && mr.success) |
| 195 | 214 | mrs.add(mr); |
| ... | ... | @@ -209,14 +228,44 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 209 | 228 | * @Description: TODO(车辆发出) |
| 210 | 229 | */ |
| 211 | 230 | public void carOut(MatchResult mr){ |
| 231 | + ScheduleRealInfo sch = mr.sch; | |
| 232 | + | |
| 233 | + if(!isExpectOut(mr)) | |
| 234 | + return; | |
| 212 | 235 | //设置发车时间 |
| 213 | - mr.sch.setFcsjActualAll(mr.ts); | |
| 236 | + sch.setFcsjActualAll(mr.ts); | |
| 214 | 237 | //通知客户端 |
| 215 | - sendUtils.sendFcsj(mr.sch); | |
| 238 | + sendUtils.sendFcsj(sch); | |
| 216 | 239 | //持久化 |
| 217 | - dayOfSchedule.save(mr.sch); | |
| 240 | + dayOfSchedule.save(sch); | |
| 218 | 241 | //车辆当前执行班次 |
| 219 | - dayOfSchedule.addExecPlan(mr.sch); | |
| 242 | + dayOfSchedule.addExecPlan(sch); | |
| 243 | + | |
| 244 | + //期望车辆到达的终点 | |
| 245 | + if(sch.getZdsj() != null) | |
| 246 | + expectMap.put(nbbm, ExpectArrivalEnd.getEndInstance(sch, mr.ts)); | |
| 247 | + } | |
| 248 | + | |
| 249 | + /** | |
| 250 | + * | |
| 251 | + * @Title: isExpectOut | |
| 252 | + * @Description: TODO(是否是一个期望的出站匹配结果) | |
| 253 | + */ | |
| 254 | + private boolean isExpectOut(MatchResult mr){ | |
| 255 | + ScheduleRealInfo sch = mr.sch; | |
| 256 | + String nbbm = sch.getClZbh(); | |
| 257 | + if(expectMap.containsKey(nbbm)){ | |
| 258 | + List<ExpectArrivalEnd> eads = expectMap.get(nbbm); | |
| 259 | + for(ExpectArrivalEnd ead : eads){ | |
| 260 | + if(sch.getQdzCode().equals(ead.getEndStation()) | |
| 261 | + || mr.ts > ead.getEndTime()){ | |
| 262 | + expectMap.removeAll(nbbm); | |
| 263 | + return true; | |
| 264 | + } | |
| 265 | + } | |
| 266 | + return false; | |
| 267 | + } | |
| 268 | + return true; | |
| 220 | 269 | } |
| 221 | 270 | |
| 222 | 271 | /** |
| ... | ... | @@ -225,12 +274,23 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 225 | 274 | * @Description: TODO(车辆进入终点站) |
| 226 | 275 | */ |
| 227 | 276 | public void carInStop(MatchResult mr){ |
| 228 | - mr.sch.setZdsjActualAll(mr.ts); | |
| 277 | + ScheduleRealInfo sch = mr.sch; | |
| 278 | + String nbbm=sch.getClZbh(); | |
| 279 | + if(!isExpectIn(mr)) | |
| 280 | + return; | |
| 229 | 281 | |
| 230 | - int doneSum = dayOfSchedule.doneSum(mr.sch.getClZbh()); | |
| 231 | - ScheduleRealInfo next = dayOfSchedule.next(mr.sch); | |
| 282 | + //如果是进停车场,并且实达时间差值大于 30 分钟,并且之前还有未完成班次。 | |
| 283 | + if(sch.getBcType().equals("in") && Math.abs(mr.diff) > (1000 * 60 * 30)){ | |
| 284 | + int prve_nen = dayOfSchedule.prveNotExecNum(sch); | |
| 285 | + if(prve_nen > 0) | |
| 286 | + return; | |
| 287 | + } | |
| 288 | + | |
| 289 | + sch.setZdsjActualAll(mr.ts); | |
| 290 | + int doneSum = dayOfSchedule.doneSum(nbbm); | |
| 291 | + ScheduleRealInfo next = dayOfSchedule.next(sch); | |
| 232 | 292 | if(null != next){ |
| 233 | - next.setQdzArrDateSJ(mr.sch.getZdsjActual()); | |
| 293 | + next.setQdzArrDateSJ(sch.getZdsjActual()); | |
| 234 | 294 | //下发调度指令 |
| 235 | 295 | directiveService.send60Dispatch(next, doneSum, "到站@系统"); |
| 236 | 296 | |
| ... | ... | @@ -239,18 +299,40 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 239 | 299 | next.setFcsjActualAll(mr.ts); |
| 240 | 300 | |
| 241 | 301 | //套跑 -下发线路切换指令 |
| 242 | - if(!next.getXlBm().equals(mr.sch.getXlBm())) | |
| 243 | - directiveService.lineChange(next.getClZbh(), next.getXlBm(), "套跑@系统"); | |
| 302 | + if(!next.getXlBm().equals(sch.getXlBm())) | |
| 303 | + directiveService.lineChange(nbbm, next.getXlBm(), "套跑@系统"); | |
| 244 | 304 | } |
| 245 | 305 | else//下发文本指令(已结束运营) |
| 246 | - directiveService.send60Phrase(nbbm, "到达终点 " + mr.sch.getZdzName() + ",已完成当日所有排班。", "系统"); | |
| 306 | + directiveService.send60Phrase(nbbm, "到达终点 " + sch.getZdzName() + ",已完成当日所有排班。", "系统"); | |
| 247 | 307 | //通知客户端 |
| 248 | - sendUtils.sendZdsj(mr.sch, next, doneSum); | |
| 308 | + sendUtils.sendZdsj(sch, next, doneSum); | |
| 249 | 309 | //持久化 |
| 250 | - dayOfSchedule.save(mr.sch); | |
| 251 | - logger.info(mr.sch.getClZbh() + "移除正在执行班次," + mr.sch.getFcsj()); | |
| 310 | + dayOfSchedule.save(sch); | |
| 311 | + logger.info(sch.getClZbh() + "移除正在执行班次," + sch.getFcsj()); | |
| 252 | 312 | //移除车辆正在执行班次索引 |
| 253 | - dayOfSchedule.removeExecPlan(mr.sch.getClZbh()); | |
| 313 | + dayOfSchedule.removeExecPlan(nbbm); | |
| 314 | + } | |
| 315 | + | |
| 316 | + /** | |
| 317 | + * | |
| 318 | + * @Title: isExpectOut | |
| 319 | + * @Description: TODO(是否是一个期望的进站匹配结果) | |
| 320 | + */ | |
| 321 | + private boolean isExpectIn(MatchResult mr){ | |
| 322 | + ScheduleRealInfo sch = mr.sch; | |
| 323 | + String nbbm = sch.getClZbh(); | |
| 324 | + if(expectMap.containsKey(nbbm)){ | |
| 325 | + List<ExpectArrivalEnd> eads = expectMap.get(nbbm); | |
| 326 | + for(ExpectArrivalEnd ead : eads){ | |
| 327 | + if(sch.getZdzCode().equals(ead.getEndStation()) | |
| 328 | + || mr.ts > ead.getEndTime()){ | |
| 329 | + expectMap.removeAll(nbbm); | |
| 330 | + return true; | |
| 331 | + } | |
| 332 | + } | |
| 333 | + return false; | |
| 334 | + } | |
| 335 | + return true; | |
| 254 | 336 | } |
| 255 | 337 | |
| 256 | 338 | /** |
| ... | ... | @@ -308,8 +390,9 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 308 | 390 | //上行发车,和到达时间比较一下。起点一般不会立即发出 |
| 309 | 391 | if(mr.sch.getXlDir().equals("0") |
| 310 | 392 | && null != mr.sch.getQdzArrDateSJ()){ |
| 311 | - | |
| 312 | - long dt = sdfyyyyMMddHHmm.parse(mr.sch.getRealExecDate() + mr.sch.getQdzArrDateSJ()).getTime(); | |
| 393 | + | |
| 394 | + | |
| 395 | + long dt = fmtyyyyMMddHHmm.parseMillis(mr.sch.getRealExecDate() + mr.sch.getQdzArrDateSJ()); | |
| 313 | 396 | |
| 314 | 397 | //停站时间少于 计划的3分之1,标记为漂移信号 |
| 315 | 398 | if((mr.ts - dt < (mr.sch.getDfsjT() - dt) / 3)){ |
| ... | ... | @@ -333,5 +416,20 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 333 | 416 | sendUtils = arg0.getBean(SendUtils.class); |
| 334 | 417 | dayOfSchedule = arg0.getBean(DayOfSchedule.class); |
| 335 | 418 | directiveService = arg0.getBean(DirectiveService.class); |
| 419 | + lineConfigData = arg0.getBean(LineConfigData.class); | |
| 420 | + } | |
| 421 | + | |
| 422 | + /** | |
| 423 | + * | |
| 424 | + * @Title: removeExpect | |
| 425 | + * @Description: TODO(清除预期站点) | |
| 426 | + * @param @param nbbm | |
| 427 | + */ | |
| 428 | + public void removeExpect(String nbbm){ | |
| 429 | + expectMap.removeAll(nbbm); | |
| 430 | + } | |
| 431 | + | |
| 432 | + public static void addExpect(String nbbm, ExpectArrivalEnd eae){ | |
| 433 | + expectMap.put(nbbm, eae); | |
| 336 | 434 | } |
| 337 | 435 | } | ... | ... |
src/main/java/com/bsth/data/match/ExpectArrivalEnd.java
0 → 100644
| 1 | +package com.bsth.data.match; | |
| 2 | + | |
| 3 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * | |
| 7 | + * @ClassName: ExpectArrivalEnd | |
| 8 | + * @Description: TODO(期望车辆在某个时间段到达某个终点或 发出某个起点........) | |
| 9 | + * @author PanZhao | |
| 10 | + * @date 2016年11月2日 下午8:04:43 | |
| 11 | + * | |
| 12 | + */ | |
| 13 | +public class ExpectArrivalEnd { | |
| 14 | + | |
| 15 | + private String nbbm; | |
| 16 | + | |
| 17 | + private String endStation; | |
| 18 | + | |
| 19 | + private Long endTime; | |
| 20 | + | |
| 21 | + public static ExpectArrivalEnd getEndInstance(ScheduleRealInfo sch, long t){ | |
| 22 | + ExpectArrivalEnd ead = new ExpectArrivalEnd(); | |
| 23 | + ead.setNbbm(sch.getClZbh()); | |
| 24 | + ead.setEndStation(sch.getZdzCode()); | |
| 25 | + if(sch.getBcType().equals("out")) | |
| 26 | + ead.setEndTime(sch.getZdsjT()); | |
| 27 | + else{ | |
| 28 | + ead.setEndTime(sch.getZdsjT() - (sch.getDfsjT() - t)); | |
| 29 | + } | |
| 30 | + return ead; | |
| 31 | + } | |
| 32 | + | |
| 33 | + | |
| 34 | + public String getNbbm() { | |
| 35 | + return nbbm; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public void setNbbm(String nbbm) { | |
| 39 | + this.nbbm = nbbm; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public String getEndStation() { | |
| 43 | + return endStation; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public void setEndStation(String endStation) { | |
| 47 | + this.endStation = endStation; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public Long getEndTime() { | |
| 51 | + return endTime; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public void setEndTime(Long endTime) { | |
| 55 | + this.endTime = endTime; | |
| 56 | + } | |
| 57 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| 1 | -package com.bsth.data.schedule; | |
| 2 | - | |
| 3 | -import java.text.ParseException; | |
| 4 | -import java.text.SimpleDateFormat; | |
| 5 | -import java.util.ArrayList; | |
| 6 | -import java.util.Collection; | |
| 7 | -import java.util.Collections; | |
| 8 | -import java.util.Date; | |
| 9 | -import java.util.HashMap; | |
| 10 | -import java.util.HashSet; | |
| 11 | -import java.util.Iterator; | |
| 12 | -import java.util.LinkedList; | |
| 13 | -import java.util.List; | |
| 14 | -import java.util.Map; | |
| 15 | -import java.util.Set; | |
| 16 | -import java.util.concurrent.TimeUnit; | |
| 17 | - | |
| 18 | -import org.slf4j.Logger; | |
| 19 | -import org.slf4j.LoggerFactory; | |
| 20 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | -import org.springframework.boot.CommandLineRunner; | |
| 22 | -import org.springframework.stereotype.Component; | |
| 23 | - | |
| 24 | -import com.alibaba.fastjson.JSON; | |
| 25 | -import com.alibaba.fastjson.JSONArray; | |
| 26 | -import com.bsth.Application; | |
| 27 | -import com.bsth.data.LineConfigData; | |
| 28 | -import com.bsth.data.directive.FirstScheduleCheckThread; | |
| 29 | -import com.bsth.data.gpsdata.GpsRealData; | |
| 30 | -import com.bsth.data.schedule.thread.ScheduleLateThread; | |
| 31 | -import com.bsth.data.schedule.thread.SchedulePstThread; | |
| 32 | -import com.bsth.data.schedule.thread.ScheduleRefreshThread; | |
| 33 | -import com.bsth.entity.realcontrol.LineConfig; | |
| 34 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 35 | -import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 36 | -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 37 | -import com.bsth.service.schedule.SchedulePlanInfoService; | |
| 38 | -import com.bsth.util.BatchSaveUtils; | |
| 39 | -import com.bsth.util.DateUtils; | |
| 40 | -import com.bsth.websocket.handler.SendUtils; | |
| 41 | -import com.google.common.collect.ArrayListMultimap; | |
| 42 | -import com.google.common.collect.TreeMultimap; | |
| 43 | - | |
| 44 | -/** | |
| 45 | - * | |
| 46 | - * @ClassName: DayOfSchedule | |
| 47 | - * @Description: TODO(当日实际排班) | |
| 48 | - * @author PanZhao | |
| 49 | - * @date 2016年8月15日 上午10:16:12 | |
| 50 | - * | |
| 51 | - */ | |
| 52 | -@Component | |
| 53 | -public class DayOfSchedule implements CommandLineRunner { | |
| 54 | - | |
| 55 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 56 | - | |
| 57 | - // 按车辆分组的班次数据 | |
| 58 | - private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap; | |
| 59 | - | |
| 60 | - // 班次主键映射 | |
| 61 | - private static Map<Long, ScheduleRealInfo> id2SchedulMap; | |
| 62 | - | |
| 63 | - // 车辆和排班起终点站对照(包括进出的停车场,区间起终点) | |
| 64 | - private static TreeMultimap<String, String> nbbm2SEStationMap; | |
| 65 | - | |
| 66 | - //车辆 ——> 当前执行班次 | |
| 67 | - private static Map<String, ScheduleRealInfo> carExecutePlanMap; | |
| 68 | - | |
| 69 | - // 持久化缓冲区 | |
| 70 | - public static LinkedList<ScheduleRealInfo> pstBuffer; | |
| 71 | - | |
| 72 | - // 排序器 | |
| 73 | - private static ScheduleComparator.FCSJ schFCSJComparator; | |
| 74 | - | |
| 75 | - @Autowired | |
| 76 | - LineConfigData lineConfigData; | |
| 77 | - | |
| 78 | - @Autowired | |
| 79 | - ScheduleRealInfoRepository schRepository; | |
| 80 | - | |
| 81 | - @Autowired | |
| 82 | - SchedulePlanInfoService schPlanService; | |
| 83 | - | |
| 84 | - @Autowired | |
| 85 | - SchAttrCalculator schAttrCalculator; | |
| 86 | - | |
| 87 | - @Autowired | |
| 88 | - SendUtils sendUtils; | |
| 89 | - | |
| 90 | - @Autowired | |
| 91 | - GpsRealData gpsRealData; | |
| 92 | - | |
| 93 | - /** 线路当前使用的排班的日期 */ | |
| 94 | - public static Map<String, String> currSchDateMap; | |
| 95 | - | |
| 96 | - static { | |
| 97 | - nbbmScheduleMap = ArrayListMultimap.create(); | |
| 98 | - id2SchedulMap = new HashMap<>(); | |
| 99 | - pstBuffer = new LinkedList<>(); | |
| 100 | - schFCSJComparator = new ScheduleComparator.FCSJ(); | |
| 101 | - currSchDateMap = new HashMap<>(); | |
| 102 | - nbbm2SEStationMap = TreeMultimap.create(); | |
| 103 | - carExecutePlanMap = new HashMap<>(); | |
| 104 | - } | |
| 105 | - | |
| 106 | - @Autowired | |
| 107 | - ScheduleRefreshThread scheduleRefreshThread; | |
| 108 | - | |
| 109 | - @Autowired | |
| 110 | - SchedulePstThread schedulePstThread; | |
| 111 | - | |
| 112 | - @Autowired | |
| 113 | - FirstScheduleCheckThread firstScheduleCheckThread; | |
| 114 | - | |
| 115 | - @Autowired | |
| 116 | - ScheduleLateThread scheduleLateThread; | |
| 117 | - | |
| 118 | - @Override | |
| 119 | - public void run(String... arg0) throws Exception { | |
| 120 | - //翻班线程 | |
| 121 | - Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 20, 120, TimeUnit.SECONDS); | |
| 122 | - //入库 | |
| 123 | - Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS); | |
| 124 | - //首班出场指令补发器 | |
| 125 | - Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 10, 60, TimeUnit.SECONDS); | |
| 126 | - //班次误点扫描 | |
| 127 | - Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS); | |
| 128 | - } | |
| 129 | - | |
| 130 | - public Map<String, String> getCurrSchDate() { | |
| 131 | - return currSchDateMap; | |
| 132 | - } | |
| 133 | - | |
| 134 | - /** | |
| 135 | - * | |
| 136 | - * @Title: calcSchDateB | |
| 137 | - * @Description: TODO(计算线路当前应该使用的排班日期) | |
| 138 | - */ | |
| 139 | - public String calcSchDate(String lineCode) { | |
| 140 | - LineConfig conf = lineConfigData.get(lineCode); | |
| 141 | - long ct = System.currentTimeMillis(); | |
| 142 | - | |
| 143 | - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); | |
| 144 | - String schDate = sdfyyyyMMdd.format(new Date(ct)); | |
| 145 | - // 小于当天起始运营时间,则取前一天的排班 | |
| 146 | - if (ct < conf.getCurrStartTime()) | |
| 147 | - schDate = DateUtils.subtractDay(schDate, 1); | |
| 148 | - | |
| 149 | - return schDate; | |
| 150 | - } | |
| 151 | - | |
| 152 | - /** | |
| 153 | - * @Title: reloadSch | |
| 154 | - * @Title: reloadSch | |
| 155 | - * @Description: TODO(重新载入排班) | |
| 156 | - * @param @param | |
| 157 | - * lineCode 线路编码 | |
| 158 | - * @param @param | |
| 159 | - * schDate 班次日期 yyyy-MM-dd | |
| 160 | - * @param @param | |
| 161 | - * forcePlan 强制从计划调度重新抓取 | |
| 162 | - */ | |
| 163 | - public int reloadSch(String lineCode, String schDate, boolean forcePlan) { | |
| 164 | - try { | |
| 165 | - List<ScheduleRealInfo> list; | |
| 166 | - | |
| 167 | - if (forcePlan) | |
| 168 | - removeRealSch(lineCode, schDate); | |
| 169 | - else | |
| 170 | - clearRAMData(lineCode); | |
| 171 | - | |
| 172 | - if (existRealSch(lineCode, schDate)) | |
| 173 | - list = loadRealSch(lineCode, schDate);// 从实际排班表加载 | |
| 174 | - else { | |
| 175 | - list = loadPlanSch(lineCode, schDate);// 从计划排班表加载 | |
| 176 | - // 写入数据库 | |
| 177 | - batchSave(list); | |
| 178 | - } | |
| 179 | - | |
| 180 | - //更新线路和班次日期对照 | |
| 181 | - currSchDateMap.put(lineCode, schDate); | |
| 182 | - //添加到缓存 | |
| 183 | - putAll(list); | |
| 184 | - | |
| 185 | - Set<String> cars = searchAllCars(list); | |
| 186 | - //计算“起点站应到”时间 | |
| 187 | - for(String nbbm : cars) | |
| 188 | - schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm)); | |
| 189 | - | |
| 190 | - //是否是出站即出场 | |
| 191 | - LineConfig conf = lineConfigData.get(lineCode); | |
| 192 | - if(conf.getOutConfig() == 2){ | |
| 193 | - for(String nbbm : cars) | |
| 194 | - schAttrCalculator.connectOutSchedule(nbbmScheduleMap.get(nbbm)); | |
| 195 | - } | |
| 196 | - | |
| 197 | - // 页面 翻班通知 | |
| 198 | - sendUtils.shiftSchedule(lineCode); | |
| 199 | - } catch (Exception e) { | |
| 200 | - logger.error("", e); | |
| 201 | - return -1; | |
| 202 | - } | |
| 203 | - | |
| 204 | - return 0; | |
| 205 | - } | |
| 206 | - | |
| 207 | - /** | |
| 208 | - * | |
| 209 | - * @Title: searchAllCars | |
| 210 | - * @Description: TODO(搜索班次集合中的车辆) | |
| 211 | - */ | |
| 212 | - private Set<String> searchAllCars(List<ScheduleRealInfo> list) { | |
| 213 | - Set<String> cars = new HashSet<>(); | |
| 214 | - for(ScheduleRealInfo sch : list) | |
| 215 | - cars.add(sch.getClZbh()); | |
| 216 | - | |
| 217 | - return cars; | |
| 218 | - } | |
| 219 | - | |
| 220 | - private void putAll(List<ScheduleRealInfo> list) { | |
| 221 | - for (ScheduleRealInfo sch : list) | |
| 222 | - put(sch); | |
| 223 | - } | |
| 224 | - | |
| 225 | - /** | |
| 226 | - * @Title: removeRealSch | |
| 227 | - * @Description: TODO(清除实际排班,包括数据库和内存数据) | |
| 228 | - * @param @param | |
| 229 | - * lineCode 线路编码 | |
| 230 | - * @param @param | |
| 231 | - * schDate 班次日期 yyyy-MM-dd | |
| 232 | - */ | |
| 233 | - public void removeRealSch(String lineCode, String schDate) throws Exception { | |
| 234 | - try { | |
| 235 | - // 清理数据库数据 | |
| 236 | - schRepository.deleteByLineCodeAndDate(lineCode + "", schDate); | |
| 237 | - | |
| 238 | - // 清理内存数据 | |
| 239 | - clearRAMData(lineCode + ""); | |
| 240 | - } catch (Exception e) { | |
| 241 | - logger.error("removeRealSch error, " + lineCode + " -" + schDate, e); | |
| 242 | - throw e; | |
| 243 | - } | |
| 244 | - } | |
| 245 | - | |
| 246 | - /** | |
| 247 | - * | |
| 248 | - * @Title: clearRAMData | |
| 249 | - * @Description: TODO(清理内存数据) | |
| 250 | - */ | |
| 251 | - public void clearRAMData(String lineCode) { | |
| 252 | - int count = 0; | |
| 253 | - List<ScheduleRealInfo> remList = new ArrayList<>(); | |
| 254 | - Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 255 | - for (ScheduleRealInfo sch : schs) { | |
| 256 | - if (sch.getXlBm().equals(lineCode)) | |
| 257 | - remList.add(sch); | |
| 258 | - } | |
| 259 | - | |
| 260 | - for(ScheduleRealInfo sch : remList){ | |
| 261 | - if(null != sch){ | |
| 262 | - nbbmScheduleMap.remove(sch.getClZbh(), sch); | |
| 263 | - id2SchedulMap.remove(sch.getId()); | |
| 264 | - count ++; | |
| 265 | - } | |
| 266 | - } | |
| 267 | - | |
| 268 | - logger.info(lineCode + "排班清理 " + count); | |
| 269 | - } | |
| 270 | - | |
| 271 | - /** | |
| 272 | - * @Title: existRealSch | |
| 273 | - * @Description: TODO(实际排班是否已存在) | |
| 274 | - */ | |
| 275 | - public boolean existRealSch(String lineCode, String schDate) { | |
| 276 | - int count = schRepository.countByLineCodeAndDate(lineCode, schDate); | |
| 277 | - return count > 0; | |
| 278 | - } | |
| 279 | - | |
| 280 | - /** | |
| 281 | - * @Title: loadRealSch | |
| 282 | - * @Description: TODO(从实际排班表加载数据) | |
| 283 | - */ | |
| 284 | - public List<ScheduleRealInfo> loadRealSch(String lineCode, String schDate) { | |
| 285 | - return schRepository.findByLineCodeAndDate(lineCode, schDate); | |
| 286 | - } | |
| 287 | - | |
| 288 | - /** | |
| 289 | - * @Title: loadPlanSch | |
| 290 | - * @Description: TODO(从计划排班表加载数据) | |
| 291 | - */ | |
| 292 | - public List<ScheduleRealInfo> loadPlanSch(String lineCode, String schDate) { | |
| 293 | - logger.info("从计划排班表恢复排班,lineCode: " + lineCode + ", schDate: " + schDate); | |
| 294 | - List<ScheduleRealInfo> realList = new ArrayList<>(); | |
| 295 | - | |
| 296 | - try { | |
| 297 | - Map<String, Object> data = new HashMap<>(); | |
| 298 | - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd") | |
| 299 | - ,sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 300 | - | |
| 301 | - data.put("scheduleDate_eq", sdfyyyyMMdd.parse(schDate)); | |
| 302 | - data.put("xlBm_eq", lineCode); | |
| 303 | - | |
| 304 | - // 查询计划排班 | |
| 305 | - List<SchedulePlanInfo> planItr = cleanSchPlanItr(schPlanService.list(data).iterator()); | |
| 306 | - | |
| 307 | - // 转换为实际排班 | |
| 308 | - realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class); | |
| 309 | - | |
| 310 | - for (ScheduleRealInfo sch : realList) { | |
| 311 | - sch.setScheduleDateStr(sdfyyyyMMdd.format(sch.getScheduleDate())); | |
| 312 | - sch.setRealExecDate(sch.getScheduleDateStr()); | |
| 313 | - // 计划终点时间 | |
| 314 | - if (sch.getBcsj() != null) { | |
| 315 | - try{ | |
| 316 | - sch.setZdsjT(sdfHHmm.parse(sch.getFcsj()).getTime() + (sch.getBcsj() * 60 * 1000)); | |
| 317 | - sch.setZdsj(sdfHHmm.format(sch.getZdsjT())); | |
| 318 | - sch.setLate(false); | |
| 319 | - }catch(ParseException pe){ | |
| 320 | - logger.error("loadPlanSch... 计算终点时间失败..."); | |
| 321 | - } | |
| 322 | - } | |
| 323 | - //计划里程为0,直接清空 | |
| 324 | - if(sch.getJhlc() != null && sch.getJhlc() == 0) | |
| 325 | - sch.setJhlc(null); | |
| 326 | - } | |
| 327 | - } catch (Exception e) { | |
| 328 | - logger.error("", e); | |
| 329 | - } | |
| 330 | - return realList; | |
| 331 | - } | |
| 332 | - | |
| 333 | - /** | |
| 334 | - * @Title: batchSave | |
| 335 | - * @Description: TODO(批量入库) | |
| 336 | - */ | |
| 337 | - private void batchSave(List<ScheduleRealInfo> list) { | |
| 338 | - // 查询数据库最大ID | |
| 339 | - Long id = schRepository.getMaxId(); | |
| 340 | - if (null == id) | |
| 341 | - id = 0L; | |
| 342 | - id++; | |
| 343 | - | |
| 344 | - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); | |
| 345 | - for (ScheduleRealInfo item : list) { | |
| 346 | - item.setSpId(item.getId());// 保留原始的计划ID | |
| 347 | - item.setId(id++);// 设置ID | |
| 348 | - item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate())); | |
| 349 | - } | |
| 350 | - | |
| 351 | - // 入库 | |
| 352 | - new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class); | |
| 353 | - } | |
| 354 | - | |
| 355 | - private List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) { | |
| 356 | - List<SchedulePlanInfo> list = new ArrayList<>(); | |
| 357 | - | |
| 358 | - SchedulePlanInfo sp; | |
| 359 | - while (itrab.hasNext()) { | |
| 360 | - sp = itrab.next(); | |
| 361 | - sp.setSchedulePlan(null); | |
| 362 | - list.add(sp); | |
| 363 | - } | |
| 364 | - return list; | |
| 365 | - } | |
| 366 | - | |
| 367 | - /** | |
| 368 | - * | |
| 369 | - * @Title: findByLineCode | |
| 370 | - * @Description: TODO(lineCode 获取班次) | |
| 371 | - */ | |
| 372 | - public List<ScheduleRealInfo> findByLineCode(String lineCode) { | |
| 373 | - List<ScheduleRealInfo> rs = new ArrayList<>(); | |
| 374 | - | |
| 375 | - Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 376 | - for (ScheduleRealInfo sch : schs) { | |
| 377 | - if (sch.getXlBm().equals(lineCode)) | |
| 378 | - rs.add(sch); | |
| 379 | - } | |
| 380 | - return rs; | |
| 381 | - } | |
| 382 | - | |
| 383 | - /** | |
| 384 | - * | |
| 385 | - * @Title: findCarByLineCode | |
| 386 | - * @Description: TODO(线路下运营的车辆) | |
| 387 | - */ | |
| 388 | - public Set<String> findCarByLineCode(String lineCode){ | |
| 389 | - Set<String> rs = new HashSet<>(); | |
| 390 | - | |
| 391 | - Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 392 | - for (ScheduleRealInfo sch : schs) { | |
| 393 | - if (sch.getXlBm().equals(lineCode)) | |
| 394 | - rs.add(sch.getClZbh()); | |
| 395 | - } | |
| 396 | - | |
| 397 | - return rs; | |
| 398 | - } | |
| 399 | - | |
| 400 | - public List<ScheduleRealInfo> findByNbbm(String nbbm) { | |
| 401 | - return nbbmScheduleMap.get(nbbm); | |
| 402 | - } | |
| 403 | - | |
| 404 | - /** | |
| 405 | - * | |
| 406 | - * @Title: findByLineAndUpDown | |
| 407 | - * @Description: TODO(lineCode 和走向获取班次) | |
| 408 | - */ | |
| 409 | - public List<ScheduleRealInfo> findByLineAndUpDown(String lineCode, Integer upDown) { | |
| 410 | - List<ScheduleRealInfo> list = findByLineCode(lineCode), rs = new ArrayList<>(); | |
| 411 | - | |
| 412 | - for (ScheduleRealInfo sch : list) { | |
| 413 | - if (sch.getXlDir().equals(upDown + "")) | |
| 414 | - rs.add(sch); | |
| 415 | - } | |
| 416 | - return rs; | |
| 417 | - } | |
| 418 | - | |
| 419 | - public ScheduleRealInfo get(long id) { | |
| 420 | - return id2SchedulMap.get(id); | |
| 421 | - } | |
| 422 | - | |
| 423 | - public Set<String> getSEStationList(String nbbm) { | |
| 424 | - return nbbm2SEStationMap.get(nbbm); | |
| 425 | - } | |
| 426 | - | |
| 427 | - /** | |
| 428 | - * | |
| 429 | - * @Title: next | |
| 430 | - * @Description: TODO(下一个班次) | |
| 431 | - */ | |
| 432 | - public ScheduleRealInfo next(ScheduleRealInfo sch) { | |
| 433 | - | |
| 434 | - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | |
| 435 | - | |
| 436 | - boolean flag = false; | |
| 437 | - ScheduleRealInfo next = null; | |
| 438 | - for(ScheduleRealInfo temp : list){ | |
| 439 | - if(temp.getId() == sch.getId()){ | |
| 440 | - flag = true; | |
| 441 | - continue; | |
| 442 | - } | |
| 443 | - //忽略烂班 | |
| 444 | - if(temp.isDestroy()) | |
| 445 | - continue; | |
| 446 | - | |
| 447 | - if(flag){ | |
| 448 | - next = temp; | |
| 449 | - break; | |
| 450 | - } | |
| 451 | - } | |
| 452 | - return next; | |
| 453 | - } | |
| 454 | - | |
| 455 | - public void put(ScheduleRealInfo sch) { | |
| 456 | - schAttrCalculator | |
| 457 | - .calcRealDate(sch) | |
| 458 | - .calcAllTimeByFcsj(sch); | |
| 459 | - | |
| 460 | - String nbbm = sch.getClZbh(); | |
| 461 | - nbbmScheduleMap.put(nbbm, sch); | |
| 462 | - nbbm2SEStationMap.put(nbbm, sch.getQdzCode()); | |
| 463 | - nbbm2SEStationMap.put(nbbm, sch.getZdzCode()); | |
| 464 | - | |
| 465 | - //主键索引 | |
| 466 | - id2SchedulMap.put(sch.getId(), sch); | |
| 467 | - } | |
| 468 | - | |
| 469 | - public void delete(ScheduleRealInfo sch) { | |
| 470 | - //ScheduleRealInfo sch = id2SchedulMap.get(id); | |
| 471 | - if(!sch.isSflj()) | |
| 472 | - return; | |
| 473 | - | |
| 474 | - nbbmScheduleMap.remove(sch.getClZbh(), sch); | |
| 475 | - id2SchedulMap.remove(sch.getId()); | |
| 476 | - //return sch; | |
| 477 | - } | |
| 478 | - | |
| 479 | - public void calcQdzTimePlan(String nbbm){ | |
| 480 | - schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm)); | |
| 481 | - } | |
| 482 | - | |
| 483 | - public List<ScheduleRealInfo> updateQdzTimePlan(String nbbm){ | |
| 484 | - return schAttrCalculator.updateQdzTimePlan(nbbmScheduleMap.get(nbbm)); | |
| 485 | - } | |
| 486 | - | |
| 487 | - /** | |
| 488 | - * | |
| 489 | - * @Title: nextAll | |
| 490 | - * @Description: TODO(之后的所有班次) | |
| 491 | - */ | |
| 492 | - public List<ScheduleRealInfo> nextAll(ScheduleRealInfo sch) { | |
| 493 | - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | |
| 494 | - // 排序 | |
| 495 | - Collections.sort(list, schFCSJComparator); | |
| 496 | - | |
| 497 | - List<ScheduleRealInfo> rs = new ArrayList<>(); | |
| 498 | - ScheduleRealInfo temp; | |
| 499 | - for (int i = 0; i < list.size() - 1; i++) { | |
| 500 | - temp = list.get(i); | |
| 501 | - if(temp.getFcsjT() > sch.getFcsjT()) | |
| 502 | - rs.add(temp); | |
| 503 | - | |
| 504 | - } | |
| 505 | - return rs; | |
| 506 | - } | |
| 507 | - | |
| 508 | - /** | |
| 509 | - * | |
| 510 | - * @Title: doneSum | |
| 511 | - * @Description: TODO(已完成班次总数) | |
| 512 | - */ | |
| 513 | - public int doneSum(String clZbh) { | |
| 514 | - List<ScheduleRealInfo> list = nbbmScheduleMap.get(clZbh); | |
| 515 | - int rs = 0; | |
| 516 | - | |
| 517 | - for(ScheduleRealInfo sch : list){ | |
| 518 | - if(sch.getStatus() == 2 && !sch.isDestroy()) | |
| 519 | - rs ++; | |
| 520 | - } | |
| 521 | - return rs; | |
| 522 | - } | |
| 523 | - | |
| 524 | - /** | |
| 525 | - * | |
| 526 | - * @Title: validEndTime | |
| 527 | - * @Description: TODO(是否是有效的到达时间) | |
| 528 | - */ | |
| 529 | - public boolean validEndTime(ScheduleRealInfo sch, Long ts) { | |
| 530 | - if(sch.getFcsjActualTime() != null && sch.getFcsjActualTime() > ts) | |
| 531 | - return false; | |
| 532 | - | |
| 533 | - return validTime(sch, ts); | |
| 534 | - } | |
| 535 | - | |
| 536 | - /** | |
| 537 | - * | |
| 538 | - * @Title: validStartTime | |
| 539 | - * @Description: TODO(是否是合适的发车时间) | |
| 540 | - */ | |
| 541 | - public boolean validStartTime(ScheduleRealInfo sch, Long ts) { | |
| 542 | - if(sch.getZdsjActualTime() != null && sch.getZdsjActualTime() < ts) | |
| 543 | - return false; | |
| 544 | - | |
| 545 | - return validTime(sch, ts); | |
| 546 | - } | |
| 547 | - | |
| 548 | - public boolean validTime(ScheduleRealInfo sch, Long ts){ | |
| 549 | - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | |
| 550 | - int ci = list.indexOf(sch); | |
| 551 | - ScheduleRealInfo prve, next; | |
| 552 | - if(ci > 0){ | |
| 553 | - //之前班次实际时间不能大于该时间 | |
| 554 | - for(int i = ci - 1; i >= 0; i --){ | |
| 555 | - prve = list.get(i); | |
| 556 | - if(prve.getZdsjActualTime() != null && prve.getZdsjActualTime() > ts ) | |
| 557 | - return false; | |
| 558 | - | |
| 559 | - if(prve.getFcsjActualTime() != null && prve.getFcsjActualTime() > ts) | |
| 560 | - return false; | |
| 561 | - } | |
| 562 | - } | |
| 563 | - | |
| 564 | - if(ci < list.size() - 1){ | |
| 565 | - //之后班次实际时间不能小于该时间 | |
| 566 | - for(int i = ci + 1; i < list.size(); i ++){ | |
| 567 | - next = list.get(i); | |
| 568 | - if(next.getFcsjActualTime() != null && next.getFcsjActualTime() < ts) | |
| 569 | - return false; | |
| 570 | - | |
| 571 | - if(next.getZdsjActualTime() != null && next.getZdsjActualTime() < ts) | |
| 572 | - return false; | |
| 573 | - } | |
| 574 | - } | |
| 575 | - return true; | |
| 576 | - } | |
| 577 | - | |
| 578 | - public void save(ScheduleRealInfo sch){ | |
| 579 | - //schRepository.save(sch); | |
| 580 | - pstBuffer.add(sch); | |
| 581 | - } | |
| 582 | - | |
| 583 | - | |
| 584 | - /** | |
| 585 | - * | |
| 586 | - * @Title: nextByBcType | |
| 587 | - * @Description: TODO(获取下一个指定班次类型的班次) | |
| 588 | - */ | |
| 589 | - public ScheduleRealInfo nextByBcType(String nbbm, String bcType){ | |
| 590 | - List<ScheduleRealInfo> list = findByBcType(nbbm, bcType); | |
| 591 | - | |
| 592 | - Collections.sort(list, schFCSJComparator); | |
| 593 | - ScheduleRealInfo sch = null; | |
| 594 | - for(ScheduleRealInfo temp : list){ | |
| 595 | - if(temp.getFcsjActual() == null) | |
| 596 | - sch = temp; | |
| 597 | - } | |
| 598 | - | |
| 599 | - return sch; | |
| 600 | - } | |
| 601 | - | |
| 602 | - public List<ScheduleRealInfo> findByBcType(String nbbm, String bcType){ | |
| 603 | - List<ScheduleRealInfo> all = nbbmScheduleMap.get(nbbm) | |
| 604 | - ,outList = new ArrayList<>(); | |
| 605 | - | |
| 606 | - for(ScheduleRealInfo sch : all){ | |
| 607 | - if(sch.getBcType().equals(bcType)) | |
| 608 | - outList.add(sch); | |
| 609 | - } | |
| 610 | - return outList; | |
| 611 | - } | |
| 612 | - | |
| 613 | - public Set<String> allCar(){ | |
| 614 | - return nbbmScheduleMap.keySet(); | |
| 615 | - } | |
| 616 | - | |
| 617 | - public Collection<ScheduleRealInfo> findAll(){ | |
| 618 | - return nbbmScheduleMap.values(); | |
| 619 | - } | |
| 620 | - | |
| 621 | - public void addExecPlan(ScheduleRealInfo sch){ | |
| 622 | - carExecutePlanMap.put(sch.getClZbh(), sch); | |
| 623 | - } | |
| 624 | - | |
| 625 | - public void removeExecPlan(String clzbh){ | |
| 626 | - carExecutePlanMap.remove(clzbh); | |
| 627 | - } | |
| 628 | - | |
| 629 | - public Map<String, ScheduleRealInfo> execPlamMap(){ | |
| 630 | - return carExecutePlanMap; | |
| 631 | - } | |
| 632 | - | |
| 633 | - /** | |
| 634 | - * @Title: changeCar | |
| 635 | - * @Description: TODO(班次换车) 返回有更新的班次 | |
| 636 | - * @param @param sch | |
| 637 | - * @param @param newClZbh 新的车辆自编号 | |
| 638 | - */ | |
| 639 | - public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch , String newClZbh){ | |
| 640 | - List<ScheduleRealInfo> ups = new ArrayList<>(); | |
| 641 | - String oldClzbh = sch.getClZbh(); | |
| 642 | - if(oldClzbh.equals(newClZbh)) | |
| 643 | - return ups; | |
| 644 | - | |
| 645 | - | |
| 646 | - //变更相关映射信息 | |
| 647 | - nbbmScheduleMap.remove(sch.getClZbh(), sch); | |
| 648 | - | |
| 649 | - sch.setClZbh(newClZbh); | |
| 650 | - nbbmScheduleMap.put(newClZbh, sch); | |
| 651 | - nbbm2SEStationMap.put(newClZbh, sch.getQdzCode()); | |
| 652 | - nbbm2SEStationMap.put(newClZbh, sch.getZdzCode()); | |
| 653 | - | |
| 654 | - //重新计算班次应到时间 | |
| 655 | - ups.addAll(updateQdzTimePlan(oldClzbh)); | |
| 656 | - ups.addAll(updateQdzTimePlan(newClZbh)); | |
| 657 | - return ups; | |
| 658 | - } | |
| 659 | - | |
| 660 | - /** | |
| 661 | - * | |
| 662 | - * @Title: linkToSchPlan | |
| 663 | - * @Description: TODO(车辆关联到班次) | |
| 664 | - */ | |
| 665 | -/* public void linkToSchPlan(String nbbm) { | |
| 666 | - //当前GPS状态 | |
| 667 | - GpsEntity gps = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm)); | |
| 668 | - if(null == gps) | |
| 669 | - return; | |
| 670 | - | |
| 671 | - //班次集合 | |
| 672 | - List<ScheduleRealInfo> schArr = nbbmScheduleMap.get(nbbm); | |
| 673 | - | |
| 674 | - for(ScheduleRealInfo sch : schArr){ | |
| 675 | - if(sch.getStatus() == 2) | |
| 676 | - continue; | |
| 677 | - if(sch.isDestroy()) | |
| 678 | - continue; | |
| 679 | - if(!sch.getXlBm().equals(gps.getLineId()) | |
| 680 | - || Integer.parseInt(sch.getXlDir()) != gps.getUpDown().intValue()) | |
| 681 | - continue; | |
| 682 | - | |
| 683 | - addExecPlan(sch); | |
| 684 | - break; | |
| 685 | - } | |
| 686 | - }*/ | |
| 687 | -} | |
| 1 | +package com.bsth.data.schedule; | |
| 2 | + | |
| 3 | +import java.text.SimpleDateFormat; | |
| 4 | +import java.util.ArrayList; | |
| 5 | +import java.util.Collection; | |
| 6 | +import java.util.Collections; | |
| 7 | +import java.util.HashMap; | |
| 8 | +import java.util.HashSet; | |
| 9 | +import java.util.Iterator; | |
| 10 | +import java.util.LinkedList; | |
| 11 | +import java.util.List; | |
| 12 | +import java.util.Map; | |
| 13 | +import java.util.Set; | |
| 14 | +import java.util.concurrent.TimeUnit; | |
| 15 | + | |
| 16 | +import org.joda.time.format.DateTimeFormat; | |
| 17 | +import org.joda.time.format.DateTimeFormatter; | |
| 18 | +import org.slf4j.Logger; | |
| 19 | +import org.slf4j.LoggerFactory; | |
| 20 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | +import org.springframework.boot.CommandLineRunner; | |
| 22 | +import org.springframework.stereotype.Component; | |
| 23 | + | |
| 24 | +import com.alibaba.fastjson.JSON; | |
| 25 | +import com.alibaba.fastjson.JSONArray; | |
| 26 | +import com.bsth.Application; | |
| 27 | +import com.bsth.data.LineConfigData; | |
| 28 | +import com.bsth.data.directive.FirstScheduleCheckThread; | |
| 29 | +import com.bsth.data.gpsdata.GpsRealData; | |
| 30 | +import com.bsth.data.schedule.thread.ScheduleLateThread; | |
| 31 | +import com.bsth.data.schedule.thread.SchedulePstThread; | |
| 32 | +import com.bsth.data.schedule.thread.ScheduleRefreshThread; | |
| 33 | +import com.bsth.entity.realcontrol.LineConfig; | |
| 34 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 35 | +import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 36 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 37 | +import com.bsth.service.schedule.SchedulePlanInfoService; | |
| 38 | +import com.bsth.util.BatchSaveUtils; | |
| 39 | +import com.bsth.util.DateUtils; | |
| 40 | +import com.bsth.websocket.handler.SendUtils; | |
| 41 | +import com.google.common.collect.ArrayListMultimap; | |
| 42 | +import com.google.common.collect.TreeMultimap; | |
| 43 | + | |
| 44 | +/** | |
| 45 | + * | |
| 46 | + * @ClassName: DayOfSchedule | |
| 47 | + * @Description: TODO(当日实际排班) | |
| 48 | + * @author PanZhao | |
| 49 | + * @date 2016年8月15日 上午10:16:12 | |
| 50 | + * | |
| 51 | + */ | |
| 52 | +@Component | |
| 53 | +public class DayOfSchedule implements CommandLineRunner { | |
| 54 | + | |
| 55 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 56 | + | |
| 57 | + // 按车辆分组的班次数据 | |
| 58 | + private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap; | |
| 59 | + | |
| 60 | + // 班次主键映射 | |
| 61 | + private static Map<Long, ScheduleRealInfo> id2SchedulMap; | |
| 62 | + | |
| 63 | + // 车辆和排班起终点站对照(包括进出的停车场,区间起终点) | |
| 64 | + private static TreeMultimap<String, String> nbbm2SEStationMap; | |
| 65 | + | |
| 66 | + //车辆 ——> 当前执行班次 | |
| 67 | + private static Map<String, ScheduleRealInfo> carExecutePlanMap; | |
| 68 | + | |
| 69 | + // 持久化缓冲区 | |
| 70 | + public static LinkedList<ScheduleRealInfo> pstBuffer; | |
| 71 | + | |
| 72 | + // 排序器 | |
| 73 | + private static ScheduleComparator.FCSJ schFCSJComparator; | |
| 74 | + | |
| 75 | + @Autowired | |
| 76 | + LineConfigData lineConfigData; | |
| 77 | + | |
| 78 | + @Autowired | |
| 79 | + ScheduleRealInfoRepository schRepository; | |
| 80 | + | |
| 81 | + @Autowired | |
| 82 | + SchedulePlanInfoService schPlanService; | |
| 83 | + | |
| 84 | + @Autowired | |
| 85 | + SchAttrCalculator schAttrCalculator; | |
| 86 | + | |
| 87 | + @Autowired | |
| 88 | + SendUtils sendUtils; | |
| 89 | + | |
| 90 | + @Autowired | |
| 91 | + GpsRealData gpsRealData; | |
| 92 | + | |
| 93 | + /** 线路当前使用的排班的日期 */ | |
| 94 | + public static Map<String, String> currSchDateMap; | |
| 95 | + | |
| 96 | + static { | |
| 97 | + nbbmScheduleMap = ArrayListMultimap.create(); | |
| 98 | + id2SchedulMap = new HashMap<>(); | |
| 99 | + pstBuffer = new LinkedList<>(); | |
| 100 | + schFCSJComparator = new ScheduleComparator.FCSJ(); | |
| 101 | + currSchDateMap = new HashMap<>(); | |
| 102 | + nbbm2SEStationMap = TreeMultimap.create(); | |
| 103 | + carExecutePlanMap = new HashMap<>(); | |
| 104 | + } | |
| 105 | + | |
| 106 | + @Autowired | |
| 107 | + ScheduleRefreshThread scheduleRefreshThread; | |
| 108 | + | |
| 109 | + @Autowired | |
| 110 | + SchedulePstThread schedulePstThread; | |
| 111 | + | |
| 112 | + @Autowired | |
| 113 | + FirstScheduleCheckThread firstScheduleCheckThread; | |
| 114 | + | |
| 115 | + @Autowired | |
| 116 | + ScheduleLateThread scheduleLateThread; | |
| 117 | + | |
| 118 | + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd") | |
| 119 | + ,fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | |
| 120 | + | |
| 121 | + @Override | |
| 122 | + public void run(String... arg0) throws Exception { | |
| 123 | + //翻班线程 | |
| 124 | + Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); | |
| 125 | + //入库 | |
| 126 | + Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS); | |
| 127 | + //首班出场指令补发器 | |
| 128 | + Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS); | |
| 129 | + //班次误点扫描 | |
| 130 | + //Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS); | |
| 131 | + } | |
| 132 | + | |
| 133 | + public Map<String, String> getCurrSchDate() { | |
| 134 | + return currSchDateMap; | |
| 135 | + } | |
| 136 | + | |
| 137 | + /** | |
| 138 | + * | |
| 139 | + * @Title: calcSchDateB | |
| 140 | + * @Description: TODO(计算线路当前应该使用的排班日期) | |
| 141 | + */ | |
| 142 | + public String calcSchDate(String lineCode) { | |
| 143 | + LineConfig conf = lineConfigData.get(lineCode); | |
| 144 | + long ct = System.currentTimeMillis(); | |
| 145 | + | |
| 146 | + String schDate = fmtyyyyMMdd.print(ct); | |
| 147 | + // 小于当天起始运营时间,则取前一天的排班 | |
| 148 | + if (ct < conf.getCurrStartTime()) | |
| 149 | + schDate = DateUtils.subtractDay(schDate, 1); | |
| 150 | + | |
| 151 | + return schDate; | |
| 152 | + } | |
| 153 | + | |
| 154 | + /** | |
| 155 | + * @Title: reloadSch | |
| 156 | + * @Title: reloadSch | |
| 157 | + * @Description: TODO(重新载入排班) | |
| 158 | + * @param @param | |
| 159 | + * lineCode 线路编码 | |
| 160 | + * @param @param | |
| 161 | + * schDate 班次日期 yyyy-MM-dd | |
| 162 | + * @param @param | |
| 163 | + * forcePlan 强制从计划调度重新抓取 | |
| 164 | + */ | |
| 165 | + public int reloadSch(String lineCode, String schDate, boolean forcePlan) { | |
| 166 | + try { | |
| 167 | + List<ScheduleRealInfo> list; | |
| 168 | + | |
| 169 | + if (forcePlan) | |
| 170 | + removeRealSch(lineCode, schDate); | |
| 171 | + else | |
| 172 | + clearRAMData(lineCode); | |
| 173 | + | |
| 174 | + if (existRealSch(lineCode, schDate)) | |
| 175 | + list = loadRealSch(lineCode, schDate);// 从实际排班表加载 | |
| 176 | + else { | |
| 177 | + list = loadPlanSch(lineCode, schDate);// 从计划排班表加载 | |
| 178 | + // 写入数据库 | |
| 179 | + batchSave(list); | |
| 180 | + } | |
| 181 | + | |
| 182 | + //更新线路和班次日期对照 | |
| 183 | + currSchDateMap.put(lineCode, schDate); | |
| 184 | + //添加到缓存 | |
| 185 | + putAll(list); | |
| 186 | + | |
| 187 | + Set<String> cars = searchAllCars(list); | |
| 188 | + //计算“起点站应到”时间 | |
| 189 | + for(String nbbm : cars) | |
| 190 | + schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm)); | |
| 191 | + | |
| 192 | + //是否是出站即出场 | |
| 193 | + LineConfig conf = lineConfigData.get(lineCode); | |
| 194 | + if(conf.getOutConfig() == 2){ | |
| 195 | + for(String nbbm : cars) | |
| 196 | + schAttrCalculator.connectOutSchedule(nbbmScheduleMap.get(nbbm)); | |
| 197 | + } | |
| 198 | + | |
| 199 | + // 页面 翻班通知 | |
| 200 | + sendUtils.shiftSchedule(lineCode); | |
| 201 | + } catch (Exception e) { | |
| 202 | + logger.error("", e); | |
| 203 | + return -1; | |
| 204 | + } | |
| 205 | + | |
| 206 | + return 0; | |
| 207 | + } | |
| 208 | + | |
| 209 | + /** | |
| 210 | + * | |
| 211 | + * @Title: searchAllCars | |
| 212 | + * @Description: TODO(搜索班次集合中的车辆) | |
| 213 | + */ | |
| 214 | + private Set<String> searchAllCars(List<ScheduleRealInfo> list) { | |
| 215 | + Set<String> cars = new HashSet<>(); | |
| 216 | + for(ScheduleRealInfo sch : list) | |
| 217 | + cars.add(sch.getClZbh()); | |
| 218 | + | |
| 219 | + return cars; | |
| 220 | + } | |
| 221 | + | |
| 222 | + private void putAll(List<ScheduleRealInfo> list) { | |
| 223 | + for (ScheduleRealInfo sch : list) | |
| 224 | + put(sch); | |
| 225 | + } | |
| 226 | + | |
| 227 | + /** | |
| 228 | + * @Title: removeRealSch | |
| 229 | + * @Description: TODO(清除实际排班,包括数据库和内存数据) | |
| 230 | + * @param @param | |
| 231 | + * lineCode 线路编码 | |
| 232 | + * @param @param | |
| 233 | + * schDate 班次日期 yyyy-MM-dd | |
| 234 | + */ | |
| 235 | + public void removeRealSch(String lineCode, String schDate) throws Exception { | |
| 236 | + try { | |
| 237 | + // 清理数据库数据 | |
| 238 | + schRepository.deleteByLineCodeAndDate(lineCode + "", schDate); | |
| 239 | + | |
| 240 | + // 清理内存数据 | |
| 241 | + clearRAMData(lineCode + ""); | |
| 242 | + } catch (Exception e) { | |
| 243 | + logger.error("removeRealSch error, " + lineCode + " -" + schDate, e); | |
| 244 | + throw e; | |
| 245 | + } | |
| 246 | + } | |
| 247 | + | |
| 248 | + /** | |
| 249 | + * | |
| 250 | + * @Title: clearRAMData | |
| 251 | + * @Description: TODO(清理内存数据) | |
| 252 | + */ | |
| 253 | + public void clearRAMData(String lineCode) { | |
| 254 | + int count = 0; | |
| 255 | + List<ScheduleRealInfo> remList = new ArrayList<>(); | |
| 256 | + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 257 | + for (ScheduleRealInfo sch : schs) { | |
| 258 | + if (sch.getXlBm().equals(lineCode)) | |
| 259 | + remList.add(sch); | |
| 260 | + } | |
| 261 | + | |
| 262 | + for(ScheduleRealInfo sch : remList){ | |
| 263 | + if(null != sch){ | |
| 264 | + nbbmScheduleMap.remove(sch.getClZbh(), sch); | |
| 265 | + id2SchedulMap.remove(sch.getId()); | |
| 266 | + count ++; | |
| 267 | + } | |
| 268 | + } | |
| 269 | + | |
| 270 | + logger.info(lineCode + "排班清理 " + count); | |
| 271 | + } | |
| 272 | + | |
| 273 | + /** | |
| 274 | + * @Title: existRealSch | |
| 275 | + * @Description: TODO(实际排班是否已存在) | |
| 276 | + */ | |
| 277 | + public boolean existRealSch(String lineCode, String schDate) { | |
| 278 | + int count = schRepository.countByLineCodeAndDate(lineCode, schDate); | |
| 279 | + return count > 0; | |
| 280 | + } | |
| 281 | + | |
| 282 | + /** | |
| 283 | + * @Title: loadRealSch | |
| 284 | + * @Description: TODO(从实际排班表加载数据) | |
| 285 | + */ | |
| 286 | + public List<ScheduleRealInfo> loadRealSch(String lineCode, String schDate) { | |
| 287 | + return schRepository.findByLineCodeAndDate(lineCode, schDate); | |
| 288 | + } | |
| 289 | + | |
| 290 | + /** | |
| 291 | + * @Title: loadPlanSch | |
| 292 | + * @Description: TODO(从计划排班表加载数据) | |
| 293 | + */ | |
| 294 | + public List<ScheduleRealInfo> loadPlanSch(String lineCode, String schDate) { | |
| 295 | + logger.info("从计划排班表恢复排班,lineCode: " + lineCode + ", schDate: " + schDate); | |
| 296 | + List<ScheduleRealInfo> realList = new ArrayList<>(); | |
| 297 | + | |
| 298 | + try { | |
| 299 | + Map<String, Object> data = new HashMap<>(); | |
| 300 | + | |
| 301 | + data.put("scheduleDate_eq", fmtyyyyMMdd.parseDateTime(schDate).toDate()); | |
| 302 | + data.put("xlBm_eq", lineCode); | |
| 303 | + | |
| 304 | + // 查询计划排班 | |
| 305 | + List<SchedulePlanInfo> planItr = cleanSchPlanItr(schPlanService.list(data).iterator()); | |
| 306 | + | |
| 307 | + // 转换为实际排班 | |
| 308 | + realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class); | |
| 309 | + | |
| 310 | + for (ScheduleRealInfo sch : realList) { | |
| 311 | + sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime())); | |
| 312 | + sch.setRealExecDate(sch.getScheduleDateStr()); | |
| 313 | + // 计划终点时间 | |
| 314 | + if (sch.getBcsj() != null) { | |
| 315 | + sch.setZdsj(fmtHHmm.print(fmtHHmm.parseMillis(sch.getFcsj()) + (sch.getBcsj() * 60 * 1000))); | |
| 316 | + sch.setLate(false); | |
| 317 | + } | |
| 318 | + //计划里程为0,设置NULL | |
| 319 | + if(sch.getJhlc() != null && sch.getJhlc() == 0) | |
| 320 | + sch.setJhlc(null); | |
| 321 | + } | |
| 322 | + } catch (Exception e) { | |
| 323 | + logger.error("", e); | |
| 324 | + } | |
| 325 | + return realList; | |
| 326 | + } | |
| 327 | + | |
| 328 | + /** | |
| 329 | + * @Title: batchSave | |
| 330 | + * @Description: TODO(批量入库) | |
| 331 | + */ | |
| 332 | + private void batchSave(List<ScheduleRealInfo> list) { | |
| 333 | + // 查询数据库最大ID | |
| 334 | + Long id = schRepository.getMaxId(); | |
| 335 | + if (null == id) | |
| 336 | + id = 0L; | |
| 337 | + id++; | |
| 338 | + | |
| 339 | + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); | |
| 340 | + for (ScheduleRealInfo item : list) { | |
| 341 | + item.setSpId(item.getId());// 保留原始的计划ID | |
| 342 | + item.setId(id++);// 设置ID | |
| 343 | + item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate())); | |
| 344 | + } | |
| 345 | + | |
| 346 | + // 入库 | |
| 347 | + new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class); | |
| 348 | + } | |
| 349 | + | |
| 350 | + private List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) { | |
| 351 | + List<SchedulePlanInfo> list = new ArrayList<>(); | |
| 352 | + | |
| 353 | + SchedulePlanInfo sp; | |
| 354 | + while (itrab.hasNext()) { | |
| 355 | + sp = itrab.next(); | |
| 356 | + sp.setSchedulePlan(null); | |
| 357 | + list.add(sp); | |
| 358 | + } | |
| 359 | + return list; | |
| 360 | + } | |
| 361 | + | |
| 362 | + /** | |
| 363 | + * | |
| 364 | + * @Title: findByLineCode | |
| 365 | + * @Description: TODO(lineCode 获取班次) | |
| 366 | + */ | |
| 367 | + public List<ScheduleRealInfo> findByLineCode(String lineCode) { | |
| 368 | + List<ScheduleRealInfo> rs = new ArrayList<>(); | |
| 369 | + | |
| 370 | + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 371 | + for (ScheduleRealInfo sch : schs) { | |
| 372 | + if (sch.getXlBm().equals(lineCode)) | |
| 373 | + rs.add(sch); | |
| 374 | + } | |
| 375 | + return rs; | |
| 376 | + } | |
| 377 | + | |
| 378 | + /** | |
| 379 | + * | |
| 380 | + * @Title: findCarByLineCode | |
| 381 | + * @Description: TODO(线路下运营的车辆) | |
| 382 | + */ | |
| 383 | + public Set<String> findCarByLineCode(String lineCode){ | |
| 384 | + Set<String> rs = new HashSet<>(); | |
| 385 | + | |
| 386 | + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 387 | + for (ScheduleRealInfo sch : schs) { | |
| 388 | + if (sch.getXlBm().equals(lineCode)) | |
| 389 | + rs.add(sch.getClZbh()); | |
| 390 | + } | |
| 391 | + | |
| 392 | + return rs; | |
| 393 | + } | |
| 394 | + | |
| 395 | + public List<ScheduleRealInfo> findByNbbm(String nbbm) { | |
| 396 | + return nbbmScheduleMap.get(nbbm); | |
| 397 | + } | |
| 398 | + | |
| 399 | + /** | |
| 400 | + * | |
| 401 | + * @Title: findByLineAndUpDown | |
| 402 | + * @Description: TODO(lineCode 和走向获取班次) | |
| 403 | + */ | |
| 404 | + public List<ScheduleRealInfo> findByLineAndUpDown(String lineCode, Integer upDown) { | |
| 405 | + List<ScheduleRealInfo> list = findByLineCode(lineCode), rs = new ArrayList<>(); | |
| 406 | + | |
| 407 | + for (ScheduleRealInfo sch : list) { | |
| 408 | + if (sch.getXlDir().equals(upDown + "")) | |
| 409 | + rs.add(sch); | |
| 410 | + } | |
| 411 | + return rs; | |
| 412 | + } | |
| 413 | + | |
| 414 | + public ScheduleRealInfo get(long id) { | |
| 415 | + return id2SchedulMap.get(id); | |
| 416 | + } | |
| 417 | + | |
| 418 | + public Set<String> getSEStationList(String nbbm) { | |
| 419 | + return nbbm2SEStationMap.get(nbbm); | |
| 420 | + } | |
| 421 | + | |
| 422 | + /** | |
| 423 | + * | |
| 424 | + * @Title: next | |
| 425 | + * @Description: TODO(下一个班次) | |
| 426 | + */ | |
| 427 | + public ScheduleRealInfo next(ScheduleRealInfo sch) { | |
| 428 | + | |
| 429 | + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | |
| 430 | + | |
| 431 | + boolean flag = false; | |
| 432 | + ScheduleRealInfo next = null; | |
| 433 | + for(ScheduleRealInfo temp : list){ | |
| 434 | + if(temp.getId() == sch.getId()){ | |
| 435 | + flag = true; | |
| 436 | + continue; | |
| 437 | + } | |
| 438 | + //忽略烂班 | |
| 439 | + if(temp.isDestroy()) | |
| 440 | + continue; | |
| 441 | + | |
| 442 | + if(flag){ | |
| 443 | + next = temp; | |
| 444 | + break; | |
| 445 | + } | |
| 446 | + } | |
| 447 | + return next; | |
| 448 | + } | |
| 449 | + | |
| 450 | + public void put(ScheduleRealInfo sch) { | |
| 451 | + | |
| 452 | + schAttrCalculator | |
| 453 | + .calcRealDate(sch) | |
| 454 | + .calcAllTimeByFcsj(sch); | |
| 455 | + | |
| 456 | + String nbbm = sch.getClZbh(); | |
| 457 | + nbbmScheduleMap.put(nbbm, sch); | |
| 458 | + nbbm2SEStationMap.put(nbbm, sch.getQdzCode()); | |
| 459 | + nbbm2SEStationMap.put(nbbm, sch.getZdzCode()); | |
| 460 | + | |
| 461 | + //主键索引 | |
| 462 | + id2SchedulMap.put(sch.getId(), sch); | |
| 463 | + } | |
| 464 | + | |
| 465 | + public void delete(ScheduleRealInfo sch) { | |
| 466 | + //ScheduleRealInfo sch = id2SchedulMap.get(id); | |
| 467 | + if(!sch.isSflj()) | |
| 468 | + return; | |
| 469 | + | |
| 470 | + nbbmScheduleMap.remove(sch.getClZbh(), sch); | |
| 471 | + id2SchedulMap.remove(sch.getId()); | |
| 472 | + //return sch; | |
| 473 | + } | |
| 474 | + | |
| 475 | +// public void calcQdzTimePlan(String nbbm){ | |
| 476 | +// schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm)); | |
| 477 | +// } | |
| 478 | + | |
| 479 | + public List<ScheduleRealInfo> updateQdzTimePlan(String nbbm){ | |
| 480 | + return schAttrCalculator.updateQdzTimePlan(nbbmScheduleMap.get(nbbm)); | |
| 481 | + } | |
| 482 | + | |
| 483 | + /** | |
| 484 | + * | |
| 485 | + * @Title: nextAll | |
| 486 | + * @Description: TODO(之后的所有班次) | |
| 487 | + */ | |
| 488 | +/* public List<ScheduleRealInfo> nextAll(ScheduleRealInfo sch) { | |
| 489 | + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | |
| 490 | + // 排序 | |
| 491 | + Collections.sort(list, schFCSJComparator); | |
| 492 | + | |
| 493 | + List<ScheduleRealInfo> rs = new ArrayList<>(); | |
| 494 | + ScheduleRealInfo temp; | |
| 495 | + for (int i = 0; i < list.size() - 1; i++) { | |
| 496 | + temp = list.get(i); | |
| 497 | + if(temp.getFcsjT() > sch.getFcsjT()) | |
| 498 | + rs.add(temp); | |
| 499 | + | |
| 500 | + } | |
| 501 | + return rs; | |
| 502 | + }*/ | |
| 503 | + | |
| 504 | + /** | |
| 505 | + * | |
| 506 | + * @Title: doneSum | |
| 507 | + * @Description: TODO(已完成班次总数) | |
| 508 | + */ | |
| 509 | + public int doneSum(String clZbh) { | |
| 510 | + List<ScheduleRealInfo> list = nbbmScheduleMap.get(clZbh); | |
| 511 | + int rs = 0; | |
| 512 | + | |
| 513 | + for(ScheduleRealInfo sch : list){ | |
| 514 | + if(sch.getStatus() == 2 && !sch.isDestroy()) | |
| 515 | + rs ++; | |
| 516 | + } | |
| 517 | + return rs; | |
| 518 | + } | |
| 519 | + | |
| 520 | + /** | |
| 521 | + * | |
| 522 | + * @Title: prveNotExecNum | |
| 523 | + * @Description: TODO(班次之前未执行班次数量) | |
| 524 | + */ | |
| 525 | + public int prveNotExecNum(ScheduleRealInfo sch){ | |
| 526 | + int n = 0; | |
| 527 | + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | |
| 528 | + for(ScheduleRealInfo s : list){ | |
| 529 | + if(s.getFcsjActual() == null && !s.isDestroy()) | |
| 530 | + n ++; | |
| 531 | + | |
| 532 | + if(s.getId().equals(sch.getId())) | |
| 533 | + break; | |
| 534 | + } | |
| 535 | + return n; | |
| 536 | + } | |
| 537 | + | |
| 538 | + /** | |
| 539 | + * | |
| 540 | + * @Title: validEndTime | |
| 541 | + * @Description: TODO(是否是有效的到达时间) | |
| 542 | + */ | |
| 543 | + public boolean validEndTime(ScheduleRealInfo sch, Long ts) { | |
| 544 | + if(sch.getFcsjActualTime() != null && sch.getFcsjActualTime() > ts) | |
| 545 | + return false; | |
| 546 | + | |
| 547 | + return validTime(sch, ts); | |
| 548 | + } | |
| 549 | + | |
| 550 | + /** | |
| 551 | + * | |
| 552 | + * @Title: validStartTime | |
| 553 | + * @Description: TODO(是否是合适的发车时间) | |
| 554 | + */ | |
| 555 | + public boolean validStartTime(ScheduleRealInfo sch, Long ts) { | |
| 556 | + if(sch.getZdsjActualTime() != null && sch.getZdsjActualTime() < ts) | |
| 557 | + return false; | |
| 558 | + | |
| 559 | + return validTime(sch, ts); | |
| 560 | + } | |
| 561 | + | |
| 562 | + public boolean validTime(ScheduleRealInfo sch, Long ts){ | |
| 563 | + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | |
| 564 | + int ci = list.indexOf(sch); | |
| 565 | + ScheduleRealInfo prve, next; | |
| 566 | + if(ci > 0){ | |
| 567 | + //之前班次实际时间不能大于该时间 | |
| 568 | + for(int i = ci - 1; i >= 0; i --){ | |
| 569 | + prve = list.get(i); | |
| 570 | + if(prve.getZdsjActualTime() != null && prve.getZdsjActualTime() > ts ) | |
| 571 | + return false; | |
| 572 | + | |
| 573 | + if(prve.getFcsjActualTime() != null && prve.getFcsjActualTime() > ts) | |
| 574 | + return false; | |
| 575 | + } | |
| 576 | + } | |
| 577 | + | |
| 578 | + if(ci < list.size() - 1){ | |
| 579 | + //之后班次实际时间不能小于该时间 | |
| 580 | + for(int i = ci + 1; i < list.size(); i ++){ | |
| 581 | + next = list.get(i); | |
| 582 | + if(next.getFcsjActualTime() != null && next.getFcsjActualTime() < ts) | |
| 583 | + return false; | |
| 584 | + | |
| 585 | + if(next.getZdsjActualTime() != null && next.getZdsjActualTime() < ts) | |
| 586 | + return false; | |
| 587 | + } | |
| 588 | + } | |
| 589 | + return true; | |
| 590 | + } | |
| 591 | + | |
| 592 | + public void save(ScheduleRealInfo sch){ | |
| 593 | + //schRepository.save(sch); | |
| 594 | + pstBuffer.add(sch); | |
| 595 | + } | |
| 596 | + | |
| 597 | + | |
| 598 | + /** | |
| 599 | + * | |
| 600 | + * @Title: nextByBcType | |
| 601 | + * @Description: TODO(获取下一个指定班次类型的班次) | |
| 602 | + */ | |
| 603 | + public ScheduleRealInfo nextByBcType(String nbbm, String bcType){ | |
| 604 | + List<ScheduleRealInfo> list = findByBcType(nbbm, bcType); | |
| 605 | + | |
| 606 | + Collections.sort(list, schFCSJComparator); | |
| 607 | + ScheduleRealInfo sch = null; | |
| 608 | + for(ScheduleRealInfo temp : list){ | |
| 609 | + if(temp.getFcsjActual() == null) | |
| 610 | + sch = temp; | |
| 611 | + } | |
| 612 | + | |
| 613 | + return sch; | |
| 614 | + } | |
| 615 | + | |
| 616 | + public List<ScheduleRealInfo> findByBcType(String nbbm, String bcType){ | |
| 617 | + List<ScheduleRealInfo> all = nbbmScheduleMap.get(nbbm) | |
| 618 | + ,outList = new ArrayList<>(); | |
| 619 | + | |
| 620 | + for(ScheduleRealInfo sch : all){ | |
| 621 | + if(sch.getBcType().equals(bcType)) | |
| 622 | + outList.add(sch); | |
| 623 | + } | |
| 624 | + return outList; | |
| 625 | + } | |
| 626 | + | |
| 627 | + public Set<String> allCar(){ | |
| 628 | + return nbbmScheduleMap.keySet(); | |
| 629 | + } | |
| 630 | + | |
| 631 | + public Collection<ScheduleRealInfo> findAll(){ | |
| 632 | + return nbbmScheduleMap.values(); | |
| 633 | + } | |
| 634 | + | |
| 635 | + public void addExecPlan(ScheduleRealInfo sch){ | |
| 636 | + carExecutePlanMap.put(sch.getClZbh(), sch); | |
| 637 | + } | |
| 638 | + | |
| 639 | + public void removeExecPlan(String clzbh){ | |
| 640 | + carExecutePlanMap.remove(clzbh); | |
| 641 | + } | |
| 642 | + | |
| 643 | + public Map<String, ScheduleRealInfo> execPlamMap(){ | |
| 644 | + return carExecutePlanMap; | |
| 645 | + } | |
| 646 | + | |
| 647 | + /** | |
| 648 | + * @Title: changeCar | |
| 649 | + * @Description: TODO(班次换车) 返回有更新的班次 | |
| 650 | + * @param @param sch | |
| 651 | + * @param @param newClZbh 新的车辆自编号 | |
| 652 | + */ | |
| 653 | + public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch , String newClZbh){ | |
| 654 | + List<ScheduleRealInfo> ups = new ArrayList<>(); | |
| 655 | + String oldClzbh = sch.getClZbh(); | |
| 656 | + if(oldClzbh.equals(newClZbh)) | |
| 657 | + return ups; | |
| 658 | + | |
| 659 | + | |
| 660 | + //变更相关映射信息 | |
| 661 | + nbbmScheduleMap.remove(sch.getClZbh(), sch); | |
| 662 | + | |
| 663 | + sch.setClZbh(newClZbh); | |
| 664 | + nbbmScheduleMap.put(newClZbh, sch); | |
| 665 | + nbbm2SEStationMap.put(newClZbh, sch.getQdzCode()); | |
| 666 | + nbbm2SEStationMap.put(newClZbh, sch.getZdzCode()); | |
| 667 | + | |
| 668 | + //重新计算班次应到时间 | |
| 669 | + ups.addAll(updateQdzTimePlan(oldClzbh)); | |
| 670 | + ups.addAll(updateQdzTimePlan(newClZbh)); | |
| 671 | + return ups; | |
| 672 | + } | |
| 673 | + | |
| 674 | + /** | |
| 675 | + * | |
| 676 | + * @Title: linkToSchPlan | |
| 677 | + * @Description: TODO(车辆关联到班次) | |
| 678 | + */ | |
| 679 | +/* public void linkToSchPlan(String nbbm) { | |
| 680 | + //当前GPS状态 | |
| 681 | + GpsEntity gps = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm)); | |
| 682 | + if(null == gps) | |
| 683 | + return; | |
| 684 | + | |
| 685 | + //班次集合 | |
| 686 | + List<ScheduleRealInfo> schArr = nbbmScheduleMap.get(nbbm); | |
| 687 | + | |
| 688 | + for(ScheduleRealInfo sch : schArr){ | |
| 689 | + if(sch.getStatus() == 2) | |
| 690 | + continue; | |
| 691 | + if(sch.isDestroy()) | |
| 692 | + continue; | |
| 693 | + if(!sch.getXlBm().equals(gps.getLineId()) | |
| 694 | + || Integer.parseInt(sch.getXlDir()) != gps.getUpDown().intValue()) | |
| 695 | + continue; | |
| 696 | + | |
| 697 | + addExecPlan(sch); | |
| 698 | + break; | |
| 699 | + } | |
| 700 | + }*/ | |
| 701 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
| 1 | 1 | package com.bsth.data.schedule; |
| 2 | 2 | |
| 3 | 3 | import java.text.ParseException; |
| 4 | -import java.text.SimpleDateFormat; | |
| 5 | 4 | import java.util.ArrayList; |
| 6 | 5 | import java.util.Collections; |
| 7 | -import java.util.Date; | |
| 8 | 6 | import java.util.List; |
| 9 | 7 | |
| 8 | +import org.joda.time.format.DateTimeFormat; | |
| 9 | +import org.joda.time.format.DateTimeFormatter; | |
| 10 | 10 | import org.slf4j.Logger; |
| 11 | 11 | import org.slf4j.LoggerFactory; |
| 12 | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -34,6 +34,10 @@ public class SchAttrCalculator { |
| 34 | 34 | |
| 35 | 35 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 36 | 36 | |
| 37 | + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd") | |
| 38 | + ,fmtHHmm = DateTimeFormat.forPattern("HH:mm") | |
| 39 | + ,fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | |
| 40 | + | |
| 37 | 41 | /** |
| 38 | 42 | * @Title: calcRealDate |
| 39 | 43 | * @Description: TODO(计算班次的真实执行日期) |
| ... | ... | @@ -45,22 +49,12 @@ public class SchAttrCalculator { |
| 45 | 49 | if (null == sch.getFcsjT()) |
| 46 | 50 | calcFcsjTime(sch); |
| 47 | 51 | |
| 48 | - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); | |
| 49 | - /* | |
| 50 | - * 早于线路开始运营时间的,加一天 | |
| 51 | - * 如该线路 2点开始运营,2016-08-23的班次,则 2016-08-23 0:25 的班次应该调整成 2016-08-24 0:25 | |
| 52 | - | |
| 53 | - | |
| 54 | - ,sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); | |
| 55 | - long st = sdfyyyyMMddHHmm.parse(sch.getScheduleDateStr() + conf.getStartOpt()).getTime(); | |
| 56 | - if (st > sch.getFcsjT()) | |
| 57 | - sch.setFcsjAll(sch.getFcsjT() + DAY_TIME);*/ | |
| 58 | 52 | |
| 59 | 53 | if(sch.getFcsj().compareTo(conf.getStartOpt()) < 0){ |
| 60 | 54 | sch.setFcsjAll(sch.getFcsjT() + DAY_TIME); |
| 61 | 55 | } |
| 62 | 56 | |
| 63 | - sch.setRealExecDate(sdfyyyyMMdd.format(new Date(sch.getFcsjT()))); | |
| 57 | + sch.setRealExecDate(fmtyyyyMMdd.print(sch.getFcsjT())); | |
| 64 | 58 | } catch (Exception e) { |
| 65 | 59 | logger.error("", e); |
| 66 | 60 | } |
| ... | ... | @@ -77,12 +71,10 @@ public class SchAttrCalculator { |
| 77 | 71 | // 生成时间戳 |
| 78 | 72 | calcTimestamp(sch); |
| 79 | 73 | |
| 80 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 81 | 74 | // 计划终点时间 |
| 82 | 75 | if (sch.getBcsj() != null) { |
| 83 | - Date zdDate = new Date(sch.getDfsjT() + (sch.getBcsj() * 60 * 1000)); | |
| 84 | - sch.setZdsjT(zdDate.getTime()); | |
| 85 | - sch.setZdsj(sdfHHmm.format(zdDate)); | |
| 76 | + sch.setZdsjT(sch.getDfsjT() + (sch.getBcsj() * 60 * 1000)); | |
| 77 | + sch.setZdsj(fmtHHmm.print(sch.getZdsjT())); | |
| 86 | 78 | } |
| 87 | 79 | } catch (ParseException e) { |
| 88 | 80 | logger.error("", e); |
| ... | ... | @@ -178,8 +170,7 @@ public class SchAttrCalculator { |
| 178 | 170 | } |
| 179 | 171 | |
| 180 | 172 | public SchAttrCalculator calcFcsjTime(ScheduleRealInfo sch) throws ParseException { |
| 181 | - SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 182 | - sch.setFcsjT(sdfyyyyMMddHHmm.parse(sch.getRealExecDate() + sch.getFcsj()).getTime()); | |
| 173 | + sch.setFcsjT(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getFcsj())); | |
| 183 | 174 | return this; |
| 184 | 175 | } |
| 185 | 176 | ... | ... |
src/main/java/com/bsth/data/schedule/thread/ScheduleRefreshThread.java
| ... | ... | @@ -18,7 +18,7 @@ import com.bsth.entity.realcontrol.LineConfig; |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * |
| 21 | - * @ClassName: refreshScheduleThread | |
| 21 | + * @ClassName: ScheduleRefreshThread | |
| 22 | 22 | * @Description: TODO(班次刷新线程,用于在营运开始时间切换到当日排班) |
| 23 | 23 | * @author PanZhao |
| 24 | 24 | * @date 2016年8月17日 下午1:23:34 |
| ... | ... | @@ -72,6 +72,7 @@ public class ScheduleRefreshThread extends Thread{ |
| 72 | 72 | logger.info(lineCode + "翻班完成, " + currSchDate + " -班次数量:" + dayOfSchedule.findByLineCode(lineCode).size()); |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | + | |
| 75 | 76 | } catch (Exception e) { |
| 76 | 77 | logger.error("", e); |
| 77 | 78 | } | ... | ... |
src/main/java/com/bsth/entity/CarDevice.java
| 1 | 1 | package com.bsth.entity; |
| 2 | 2 | |
| 3 | +import com.bsth.entity.sys.SysUser; | |
| 4 | + | |
| 3 | 5 | import javax.persistence.*; |
| 4 | 6 | import java.util.Date; |
| 5 | 7 | |
| ... | ... | @@ -15,17 +17,32 @@ public class CarDevice { |
| 15 | 17 | @GeneratedValue |
| 16 | 18 | private Long id; |
| 17 | 19 | |
| 18 | - /** 公司名称 */ | |
| 19 | - @Column(nullable = false) | |
| 20 | + /** 公司名称(留着,暂时不用) */ | |
| 21 | + @Column | |
| 20 | 22 | private String gsName; |
| 23 | + | |
| 24 | + /** 车辆id,关联bsth_c_cars */ | |
| 25 | + @Column(nullable = false) | |
| 26 | + private Integer cl; | |
| 21 | 27 | /** 内部编号(自编号) */ |
| 28 | + @Column(nullable = false) | |
| 22 | 29 | private String clZbh; |
| 30 | + | |
| 31 | + /** 关联 bsth_c_line 主键,不做mapping */ | |
| 32 | + @Column(nullable = false) | |
| 33 | + private Integer xl; | |
| 23 | 34 | /** 线路名称 */ |
| 35 | + @Column(nullable = false) | |
| 24 | 36 | private String xlName; |
| 37 | + /** 线路编码 */ | |
| 38 | + @Column(nullable = false) | |
| 39 | + private String xlBm; | |
| 25 | 40 | |
| 26 | 41 | /** 旧终端号 */ |
| 42 | + @Column(nullable = false) | |
| 27 | 43 | private String oldDeviceNo; |
| 28 | 44 | /** 新终端号 */ |
| 45 | + @Column(nullable = false) | |
| 29 | 46 | private String newDeviceNo; |
| 30 | 47 | /** 旧SIM卡号 */ |
| 31 | 48 | private String oldSimNo; |
| ... | ... | @@ -37,11 +54,24 @@ public class CarDevice { |
| 37 | 54 | /** 保修描述 */ |
| 38 | 55 | private String guaranteeDesc; |
| 39 | 56 | |
| 40 | - // 创建日期 | |
| 57 | + /** 启用日期 */ | |
| 58 | + @Column(nullable = false) | |
| 59 | + private Date qyrq; | |
| 60 | + | |
| 61 | + /** 是否删除(标记) */ | |
| 62 | + @Column(nullable = false) | |
| 63 | + private Boolean isCancel = false; | |
| 64 | + | |
| 65 | + /** 创建人 */ | |
| 66 | + @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | |
| 67 | + private SysUser createBy; | |
| 68 | + /** 修改人 */ | |
| 69 | + @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | |
| 70 | + private SysUser updateBy; | |
| 71 | + /** 创建日期 */ | |
| 41 | 72 | @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") |
| 42 | 73 | private Date createDate; |
| 43 | - | |
| 44 | - // 修改日期 | |
| 74 | + /** 修改日期 */ | |
| 45 | 75 | @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") |
| 46 | 76 | private Date updateDate; |
| 47 | 77 | |
| ... | ... | @@ -61,6 +91,14 @@ public class CarDevice { |
| 61 | 91 | this.gsName = gsName; |
| 62 | 92 | } |
| 63 | 93 | |
| 94 | + public Integer getCl() { | |
| 95 | + return cl; | |
| 96 | + } | |
| 97 | + | |
| 98 | + public void setCl(Integer cl) { | |
| 99 | + this.cl = cl; | |
| 100 | + } | |
| 101 | + | |
| 64 | 102 | public String getClZbh() { |
| 65 | 103 | return clZbh; |
| 66 | 104 | } |
| ... | ... | @@ -69,6 +107,14 @@ public class CarDevice { |
| 69 | 107 | this.clZbh = clZbh; |
| 70 | 108 | } |
| 71 | 109 | |
| 110 | + public Integer getXl() { | |
| 111 | + return xl; | |
| 112 | + } | |
| 113 | + | |
| 114 | + public void setXl(Integer xl) { | |
| 115 | + this.xl = xl; | |
| 116 | + } | |
| 117 | + | |
| 72 | 118 | public String getXlName() { |
| 73 | 119 | return xlName; |
| 74 | 120 | } |
| ... | ... | @@ -77,6 +123,14 @@ public class CarDevice { |
| 77 | 123 | this.xlName = xlName; |
| 78 | 124 | } |
| 79 | 125 | |
| 126 | + public String getXlBm() { | |
| 127 | + return xlBm; | |
| 128 | + } | |
| 129 | + | |
| 130 | + public void setXlBm(String xlBm) { | |
| 131 | + this.xlBm = xlBm; | |
| 132 | + } | |
| 133 | + | |
| 80 | 134 | public String getOldDeviceNo() { |
| 81 | 135 | return oldDeviceNo; |
| 82 | 136 | } |
| ... | ... | @@ -125,6 +179,22 @@ public class CarDevice { |
| 125 | 179 | this.guaranteeDesc = guaranteeDesc; |
| 126 | 180 | } |
| 127 | 181 | |
| 182 | + public SysUser getCreateBy() { | |
| 183 | + return createBy; | |
| 184 | + } | |
| 185 | + | |
| 186 | + public void setCreateBy(SysUser createBy) { | |
| 187 | + this.createBy = createBy; | |
| 188 | + } | |
| 189 | + | |
| 190 | + public SysUser getUpdateBy() { | |
| 191 | + return updateBy; | |
| 192 | + } | |
| 193 | + | |
| 194 | + public void setUpdateBy(SysUser updateBy) { | |
| 195 | + this.updateBy = updateBy; | |
| 196 | + } | |
| 197 | + | |
| 128 | 198 | public Date getCreateDate() { |
| 129 | 199 | return createDate; |
| 130 | 200 | } |
| ... | ... | @@ -140,4 +210,20 @@ public class CarDevice { |
| 140 | 210 | public void setUpdateDate(Date updateDate) { |
| 141 | 211 | this.updateDate = updateDate; |
| 142 | 212 | } |
| 213 | + | |
| 214 | + public Date getQyrq() { | |
| 215 | + return qyrq; | |
| 216 | + } | |
| 217 | + | |
| 218 | + public void setQyrq(Date qyrq) { | |
| 219 | + this.qyrq = qyrq; | |
| 220 | + } | |
| 221 | + | |
| 222 | + public Boolean getIsCancel() { | |
| 223 | + return isCancel; | |
| 224 | + } | |
| 225 | + | |
| 226 | + public void setIsCancel(Boolean isCancel) { | |
| 227 | + this.isCancel = isCancel; | |
| 228 | + } | |
| 143 | 229 | } | ... | ... |
src/main/java/com/bsth/entity/directive/DC0_A3.java
| 1 | 1 | package com.bsth.entity.directive; |
| 2 | 2 | |
| 3 | -import javax.persistence.Embeddable; | |
| 4 | -import javax.persistence.Entity; | |
| 5 | -import javax.persistence.GeneratedValue; | |
| 6 | -import javax.persistence.Id; | |
| 7 | -import javax.persistence.Table; | |
| 8 | -import javax.persistence.Transient; | |
| 3 | +import javax.persistence.*; | |
| 9 | 4 | |
| 10 | 5 | /** |
| 11 | 6 | * |
| ... | ... | @@ -41,6 +36,7 @@ public class DC0_A3 extends Directive{ |
| 41 | 36 | /** 定时定距上报模式 */ |
| 42 | 37 | private short reportMode; |
| 43 | 38 | /** 定时上报时间间隔 */ |
| 39 | + @Column(name = "_interval") | |
| 44 | 40 | private int interval; |
| 45 | 41 | /** 定距上报距离间隔 */ |
| 46 | 42 | private String distance; | ... | ... |
src/main/java/com/bsth/entity/directive/DC0_A4.java
| 1 | 1 | package com.bsth.entity.directive; |
| 2 | 2 | |
| 3 | -import javax.persistence.Embeddable; | |
| 4 | -import javax.persistence.Entity; | |
| 5 | -import javax.persistence.GeneratedValue; | |
| 6 | -import javax.persistence.Id; | |
| 7 | -import javax.persistence.Table; | |
| 8 | -import javax.persistence.Transient; | |
| 3 | +import javax.persistence.*; | |
| 9 | 4 | |
| 10 | 5 | /** |
| 11 | 6 | * |
| ... | ... | @@ -41,6 +36,7 @@ public class DC0_A4 extends Directive{ |
| 41 | 36 | /** 定时定距上报模式 */ |
| 42 | 37 | private short reportMode; |
| 43 | 38 | /** 定时上报时间间隔 */ |
| 39 | + @Column(name = "_interval") | |
| 44 | 40 | private int interval; |
| 45 | 41 | /** 定距上报距离间隔 */ |
| 46 | 42 | private String distance; | ... | ... |
src/main/java/com/bsth/entity/oil/Ylb.java
| 1 | 1 | package com.bsth.entity.oil; |
| 2 | 2 | |
| 3 | +import java.text.DecimalFormat; | |
| 3 | 4 | import java.util.Date; |
| 4 | 5 | |
| 5 | 6 | import javax.persistence.Entity; |
| 6 | 7 | import javax.persistence.GeneratedValue; |
| 7 | 8 | import javax.persistence.Id; |
| 8 | 9 | import javax.persistence.Table; |
| 10 | +import javax.persistence.Transient; | |
| 9 | 11 | |
| 10 | 12 | import org.springframework.format.annotation.DateTimeFormat; |
| 11 | 13 | |
| 14 | +import com.bsth.data.BasicData; | |
| 15 | + | |
| 12 | 16 | @Entity |
| 13 | 17 | @Table(name = "bsth_c_ylb") |
| 14 | 18 | public class Ylb { |
| ... | ... | @@ -22,23 +26,23 @@ public class Ylb { |
| 22 | 26 | private String fgsdm; |
| 23 | 27 | private String nbbm; |
| 24 | 28 | private String jsy; |
| 25 | - private Double czlc; | |
| 26 | - private Double jzlc; | |
| 27 | - private Double czyl; | |
| 28 | - private Double jzyl; | |
| 29 | + private Double czlc=0.0; | |
| 30 | + private Double jzlc=0.0; | |
| 31 | + private Double czyl=0.0; | |
| 32 | + private Double jzyl=0.0; | |
| 29 | 33 | private Double jzl; |
| 30 | 34 | private int sfkt; |
| 31 | 35 | private String jhsj; |
| 32 | - private Double yh; | |
| 33 | - private Double sh; | |
| 36 | + private Double yh=0.0; | |
| 37 | + private Double sh=0.0; | |
| 34 | 38 | private String shyy; |
| 35 | - private Double zlc; | |
| 39 | + private Double zlc=0.0; | |
| 36 | 40 | private int yhlx; |
| 37 | 41 | private String rylx; |
| 38 | - private Double ns; | |
| 39 | - private Double fyylc; | |
| 40 | - private Double jhzlc; | |
| 41 | - private Double jhfyylc; | |
| 42 | + private Double ns=0.0; | |
| 43 | + private Double fyylc=0.0; | |
| 44 | + private Double jhzlc=0.0; | |
| 45 | + private Double jhfyylc=0.0; | |
| 42 | 46 | private int jhzbc; |
| 43 | 47 | private int jhbc; |
| 44 | 48 | private int sjzbc; |
| ... | ... | @@ -49,6 +53,16 @@ public class Ylb { |
| 49 | 53 | private int nylx; |
| 50 | 54 | //进场顺序(根据最先出场和最后进场来关联车辆的存油量) |
| 51 | 55 | private int jcsx; |
| 56 | + | |
| 57 | + @Transient | |
| 58 | + private String bglyh; | |
| 59 | + | |
| 60 | + @Transient | |
| 61 | + private String xlname; | |
| 62 | + | |
| 63 | + @Transient | |
| 64 | + private String gsname; | |
| 65 | + | |
| 52 | 66 | |
| 53 | 67 | public Integer getId() { |
| 54 | 68 | return id; |
| ... | ... | @@ -254,5 +268,38 @@ public class Ylb { |
| 254 | 268 | public void setJcsx(int jcsx){ |
| 255 | 269 | this.jcsx=jcsx; |
| 256 | 270 | } |
| 271 | + | |
| 272 | + public String getBglyh() { | |
| 273 | + if(this.getZlc()==0){ | |
| 274 | + return "0.00"; | |
| 275 | + }else{ | |
| 276 | + DecimalFormat df = new DecimalFormat("0.00"); | |
| 277 | + return df.format(this.getYh()/this.getZlc()*100); | |
| 278 | + } | |
| 279 | + } | |
| 280 | + | |
| 281 | + public void setBglyh(String bglyh) { | |
| 282 | + this.bglyh = bglyh; | |
| 283 | + } | |
| 284 | + | |
| 285 | + public String getXlname() { | |
| 286 | + return BasicData.lineCode2NameMap.get(this.xlbm); | |
| 287 | + } | |
| 288 | + | |
| 289 | + public void setXlname(String xlname) { | |
| 290 | + this.xlname = xlname; | |
| 291 | + } | |
| 292 | + | |
| 293 | + public String getGsname() { | |
| 294 | + return BasicData.nbbm2CompanyCodeMap.get(this.nbbm); | |
| 295 | + } | |
| 296 | + | |
| 297 | + public void setGsname(String gsname) { | |
| 298 | + this.gsname = gsname; | |
| 299 | + } | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 257 | 304 | |
| 258 | 305 | } | ... | ... |
src/main/java/com/bsth/entity/oil/Ylxxb.java
| ... | ... | @@ -6,6 +6,9 @@ import javax.persistence.Entity; |
| 6 | 6 | import javax.persistence.GeneratedValue; |
| 7 | 7 | import javax.persistence.Id; |
| 8 | 8 | import javax.persistence.Table; |
| 9 | +import javax.persistence.Transient; | |
| 10 | + | |
| 11 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | 12 | |
| 10 | 13 | @Entity |
| 11 | 14 | @Table(name = "bsth_c_ylxxb") |
| ... | ... | @@ -13,6 +16,7 @@ public class Ylxxb { |
| 13 | 16 | @Id |
| 14 | 17 | @GeneratedValue |
| 15 | 18 | private Integer id; |
| 19 | + @DateTimeFormat(pattern="yyyy-MM-dd") | |
| 16 | 20 | private Date yyrq; |
| 17 | 21 | private Date jlrq; |
| 18 | 22 | private String nbbm; |
| ... | ... | @@ -29,6 +33,12 @@ public class Ylxxb { |
| 29 | 33 | private String xgr; |
| 30 | 34 | private String fromgsdm; |
| 31 | 35 | private int nylx; |
| 36 | + @Transient | |
| 37 | + private String ldgh; | |
| 38 | + //0为接口数据,1为手工输入 | |
| 39 | + private int jylx=0; | |
| 40 | + | |
| 41 | + | |
| 32 | 42 | public Integer getId() { |
| 33 | 43 | return id; |
| 34 | 44 | } |
| ... | ... | @@ -131,6 +141,18 @@ public class Ylxxb { |
| 131 | 141 | public void setNylx(int nylx) { |
| 132 | 142 | this.nylx = nylx; |
| 133 | 143 | } |
| 144 | + public String getLdgh() { | |
| 145 | + return ldgh; | |
| 146 | + } | |
| 147 | + public void setLdgh(String ldgh) { | |
| 148 | + this.ldgh = ldgh; | |
| 149 | + } | |
| 150 | + public int getJylx() { | |
| 151 | + return jylx; | |
| 152 | + } | |
| 153 | + public void setJylx(int jylx) { | |
| 154 | + this.jylx = jylx; | |
| 155 | + } | |
| 134 | 156 | |
| 135 | 157 | |
| 136 | 158 | ... | ... |
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
| ... | ... | @@ -6,9 +6,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore; |
| 6 | 6 | import javax.persistence.*; |
| 7 | 7 | |
| 8 | 8 | import org.apache.commons.lang3.StringUtils; |
| 9 | +import org.joda.time.format.DateTimeFormat; | |
| 10 | +import org.joda.time.format.DateTimeFormatter; | |
| 9 | 11 | |
| 10 | -import java.text.ParseException; | |
| 11 | -import java.text.SimpleDateFormat; | |
| 12 | 12 | import java.util.Date; |
| 13 | 13 | import java.util.HashSet; |
| 14 | 14 | import java.util.Set; |
| ... | ... | @@ -507,31 +507,28 @@ public class ScheduleRealInfo { |
| 507 | 507 | public void setDfsjT(Long dfsjT) { |
| 508 | 508 | this.dfsjT = dfsjT; |
| 509 | 509 | } |
| 510 | - | |
| 510 | + | |
| 511 | + | |
| 512 | + @Transient | |
| 513 | + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | |
| 514 | + @Transient | |
| 515 | + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | |
| 516 | + | |
| 511 | 517 | public void setDfsjAll(Long dfsjT) { |
| 512 | 518 | this.dfsjT = dfsjT; |
| 513 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 514 | - this.dfsj = sdfHHmm.format(new Date(this.dfsjT)); | |
| 519 | + this.dfsj = fmtHHmm.print(this.dfsjT); | |
| 515 | 520 | } |
| 516 | 521 | |
| 517 | 522 | public void setDfsjAll(String dfsj) { |
| 518 | - | |
| 519 | - try { | |
| 520 | - SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 521 | - this.dfsjT = sdfyyyyMMddHHmm.parse(this.realExecDate + dfsj).getTime(); | |
| 522 | - this.dfsj = dfsj; | |
| 523 | - } catch (ParseException e) { | |
| 524 | - e.printStackTrace(); | |
| 525 | - } | |
| 523 | + this.dfsjT = fmtyyyyMMddHHmm.parseMillis(this.realExecDate + dfsj); | |
| 524 | + this.dfsj = dfsj; | |
| 526 | 525 | } |
| 527 | 526 | |
| 528 | 527 | public void calcEndTime(){ |
| 529 | 528 | //计划终点时间 |
| 530 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 531 | 529 | if(this.getBcsj() != null){ |
| 532 | - Date zdDate = new Date(this.getDfsjT() + (this.getBcsj() * 60 * 1000)); | |
| 533 | - this.setZdsjT(zdDate.getTime()); | |
| 534 | - this.setZdsj(sdfHHmm.format(zdDate)); | |
| 530 | + this.setZdsjT(this.getDfsjT() + (this.getBcsj() * 60 * 1000)); | |
| 531 | + this.setZdsj(fmtHHmm.print(this.zdsjT)); | |
| 535 | 532 | } |
| 536 | 533 | } |
| 537 | 534 | |
| ... | ... | @@ -583,13 +580,8 @@ public class ScheduleRealInfo { |
| 583 | 580 | * @throws |
| 584 | 581 | */ |
| 585 | 582 | public void setFcsjAll(String fcsj){ |
| 586 | - try { | |
| 587 | - SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 588 | - this.fcsjT = sdfyyyyMMddHHmm.parse(this.realExecDate + fcsj).getTime(); | |
| 589 | - this.fcsj = fcsj; | |
| 590 | - } catch (ParseException e) { | |
| 591 | - e.printStackTrace(); | |
| 592 | - } | |
| 583 | + this.fcsjT = fmtyyyyMMddHHmm.parseMillis(this.realExecDate + fcsj); | |
| 584 | + this.fcsj = fcsj; | |
| 593 | 585 | } |
| 594 | 586 | |
| 595 | 587 | /** |
| ... | ... | @@ -600,8 +592,7 @@ public class ScheduleRealInfo { |
| 600 | 592 | */ |
| 601 | 593 | public void setFcsjAll(Long fcsjT){ |
| 602 | 594 | this.fcsjT = fcsjT; |
| 603 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 604 | - this.fcsj = sdfHHmm.format(new Date(fcsjT)); | |
| 595 | + this.fcsj = fmtHHmm.print(fcsjT); | |
| 605 | 596 | } |
| 606 | 597 | |
| 607 | 598 | /** |
| ... | ... | @@ -611,15 +602,9 @@ public class ScheduleRealInfo { |
| 611 | 602 | * @throws |
| 612 | 603 | */ |
| 613 | 604 | public void setFcsjActualAll(String fcsjActual){ |
| 614 | - try { | |
| 615 | - SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 616 | - this.fcsjActualTime = sdfyyyyMMddHHmm.parse(this.realExecDate + fcsjActual).getTime(); | |
| 617 | - this.fcsjActual = fcsjActual; | |
| 618 | - | |
| 619 | - calcStatus(); | |
| 620 | - } catch (ParseException e) { | |
| 621 | - e.printStackTrace(); | |
| 622 | - } | |
| 605 | + this.fcsjActualTime = fmtyyyyMMddHHmm.parseMillis(this.realExecDate + fcsjActual); | |
| 606 | + this.fcsjActual = fcsjActual; | |
| 607 | + calcStatus(); | |
| 623 | 608 | } |
| 624 | 609 | |
| 625 | 610 | /** |
| ... | ... | @@ -630,9 +615,8 @@ public class ScheduleRealInfo { |
| 630 | 615 | */ |
| 631 | 616 | public void setFcsjActualAll(Long t){ |
| 632 | 617 | this.fcsjActualTime = t; |
| 633 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 634 | - this.fcsjActual = sdfHHmm.format(new Date(t)); | |
| 635 | - | |
| 618 | + this.fcsjActual = fmtHHmm.print(t); | |
| 619 | + | |
| 636 | 620 | //更新班次状态 |
| 637 | 621 | calcStatus(); |
| 638 | 622 | } |
| ... | ... | @@ -645,12 +629,10 @@ public class ScheduleRealInfo { |
| 645 | 629 | */ |
| 646 | 630 | public void setZdsjActualAll(Long t){ |
| 647 | 631 | this.zdsjActualTime = t; |
| 648 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 649 | - this.zdsjActual = sdfHHmm.format(new Date(t)); | |
| 632 | + this.zdsjActual = fmtHHmm.print(t); | |
| 650 | 633 | |
| 651 | 634 | //更新班次状态 |
| 652 | 635 | calcStatus(); |
| 653 | - //this.synchroZdsj(); | |
| 654 | 636 | } |
| 655 | 637 | |
| 656 | 638 | /** |
| ... | ... | @@ -660,15 +642,10 @@ public class ScheduleRealInfo { |
| 660 | 642 | * @throws |
| 661 | 643 | */ |
| 662 | 644 | public void setZdsjActualAll(String zdsjActual){ |
| 663 | - try { | |
| 664 | - SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 665 | - this.zdsjActualTime = sdfyyyyMMddHHmm.parse(this.realExecDate + zdsjActual).getTime(); | |
| 666 | - this.zdsjActual = zdsjActual; | |
| 667 | - | |
| 668 | - calcStatus(); | |
| 669 | - } catch (ParseException e) { | |
| 670 | - e.printStackTrace(); | |
| 671 | - } | |
| 645 | + this.zdsjActualTime = fmtyyyyMMddHHmm.parseMillis(this.realExecDate + zdsjActual); | |
| 646 | + this.zdsjActual = zdsjActual; | |
| 647 | + | |
| 648 | + calcStatus(); | |
| 672 | 649 | } |
| 673 | 650 | |
| 674 | 651 | public Long getSpId() { |
| ... | ... | @@ -713,17 +690,17 @@ public class ScheduleRealInfo { |
| 713 | 690 | return this.status == -1; |
| 714 | 691 | } |
| 715 | 692 | |
| 716 | - public boolean isNotDestroy(){ | |
| 693 | +/* public boolean isNotDestroy(){ | |
| 717 | 694 | return this.status != -1; |
| 718 | - } | |
| 695 | + }*/ | |
| 719 | 696 | |
| 720 | 697 | public Set<ChildTaskPlan> getcTasks() { |
| 721 | 698 | return cTasks; |
| 722 | 699 | } |
| 723 | 700 | |
| 724 | - public void setcTasks(Set<ChildTaskPlan> cTasks) { | |
| 701 | +/* public void setcTasks(Set<ChildTaskPlan> cTasks) { | |
| 725 | 702 | this.cTasks = cTasks; |
| 726 | - } | |
| 703 | + }*/ | |
| 727 | 704 | |
| 728 | 705 | public String getScheduleDateStr() { |
| 729 | 706 | return scheduleDateStr; | ... | ... |
src/main/java/com/bsth/entity/schedule/rule/RerunRule.java
0 → 100644
| 1 | +package com.bsth.entity.schedule.rule; | |
| 2 | + | |
| 3 | +import com.bsth.entity.Line; | |
| 4 | +import com.bsth.entity.schedule.CarConfigInfo; | |
| 5 | +import com.bsth.entity.schedule.EmployeeConfigInfo; | |
| 6 | +import com.bsth.entity.schedule.GuideboardInfo; | |
| 7 | +import com.bsth.entity.schedule.TTInfo; | |
| 8 | +import com.bsth.entity.sys.SysUser; | |
| 9 | + | |
| 10 | +import javax.persistence.*; | |
| 11 | +import java.util.Date; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 套跑规则。 | |
| 15 | + */ | |
| 16 | +@Entity | |
| 17 | +@Table(name = "bsth_c_s_rerun_rule") | |
| 18 | +@NamedEntityGraphs({ | |
| 19 | + @NamedEntityGraph(name = "dylp", attributeNodes = { | |
| 20 | + @NamedAttributeNode("rerunXl"), | |
| 21 | + @NamedAttributeNode("rerunTtinfo"), | |
| 22 | + @NamedAttributeNode("rerunLp"), | |
| 23 | + @NamedAttributeNode("useXl"), | |
| 24 | + @NamedAttributeNode("useLp"), | |
| 25 | + @NamedAttributeNode("useCarConfig"), | |
| 26 | + @NamedAttributeNode("useEmployeeConfig") | |
| 27 | + | |
| 28 | + // TODO:subgraph貌似没有用,再议 | |
| 29 | +// subgraphs = { | |
| 30 | +// @NamedSubgraph(name = "useCarConfig", attributeNodes = { | |
| 31 | +// @NamedAttributeNode("xl"), | |
| 32 | +// @NamedAttributeNode("cl") | |
| 33 | +// }), | |
| 34 | +// @NamedSubgraph(name = "useEmployeeConfig", attributeNodes = { | |
| 35 | +// @NamedAttributeNode("jsy"), | |
| 36 | +// @NamedAttributeNode("spy"), | |
| 37 | +// @NamedAttributeNode("xl") | |
| 38 | +// }) | |
| 39 | +// } | |
| 40 | + }) | |
| 41 | +}) | |
| 42 | + | |
| 43 | + | |
| 44 | +public class RerunRule { | |
| 45 | + /** 主键Id */ | |
| 46 | + @Id | |
| 47 | + @GeneratedValue | |
| 48 | + private Long id; | |
| 49 | + | |
| 50 | + /** 套跑线路 */ | |
| 51 | + @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 52 | + private Line rerunXl; | |
| 53 | + /** 套跑时刻表 */ | |
| 54 | + @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 55 | + private TTInfo rerunTtinfo; | |
| 56 | + /** 套跑路牌 */ | |
| 57 | + @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 58 | + private GuideboardInfo rerunLp; | |
| 59 | + /** 套跑班次(时刻表明细ids,使用逗号连接) */ | |
| 60 | + private String rerunTtinfodetailIds; | |
| 61 | + | |
| 62 | + | |
| 63 | + /** 套跑类型(dylp;对应路牌,dybc:对应班车) */ | |
| 64 | + @Column(nullable = false) | |
| 65 | + private String rerunType; | |
| 66 | + | |
| 67 | + //--------- 对应路牌 ----------/ | |
| 68 | + /** 使用线路 */ | |
| 69 | + @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 70 | + private Line useXl; | |
| 71 | + /** 使用路牌 */ | |
| 72 | + @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 73 | + private GuideboardInfo useLp; | |
| 74 | + | |
| 75 | + //--------- 对应班车 ----------/ | |
| 76 | + /** 车辆配置 */ | |
| 77 | + @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 78 | + private CarConfigInfo useCarConfig; | |
| 79 | + /** 人员配置 */ | |
| 80 | + @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 81 | + private EmployeeConfigInfo useEmployeeConfig; | |
| 82 | + | |
| 83 | + /** 是否删除(标记) */ | |
| 84 | + @Column(nullable = false) | |
| 85 | + private Boolean isCancel = false; | |
| 86 | + | |
| 87 | + /** 创建人 */ | |
| 88 | + @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | |
| 89 | + private SysUser createBy; | |
| 90 | + /** 修改人 */ | |
| 91 | + @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | |
| 92 | + private SysUser updateBy; | |
| 93 | + /** 创建日期 */ | |
| 94 | + @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | |
| 95 | + private Date createDate; | |
| 96 | + /** 修改日期 */ | |
| 97 | + @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") | |
| 98 | + private Date updateDate; | |
| 99 | + | |
| 100 | + public Long getId() { | |
| 101 | + return id; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public void setId(Long id) { | |
| 105 | + this.id = id; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public Line getRerunXl() { | |
| 109 | + return rerunXl; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public void setRerunXl(Line rerunXl) { | |
| 113 | + this.rerunXl = rerunXl; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public TTInfo getRerunTtinfo() { | |
| 117 | + return rerunTtinfo; | |
| 118 | + } | |
| 119 | + | |
| 120 | + public void setRerunTtinfo(TTInfo rerunTtinfo) { | |
| 121 | + this.rerunTtinfo = rerunTtinfo; | |
| 122 | + } | |
| 123 | + | |
| 124 | + public GuideboardInfo getRerunLp() { | |
| 125 | + return rerunLp; | |
| 126 | + } | |
| 127 | + | |
| 128 | + public void setRerunLp(GuideboardInfo rerunLp) { | |
| 129 | + this.rerunLp = rerunLp; | |
| 130 | + } | |
| 131 | + | |
| 132 | + public String getRerunTtinfodetailIds() { | |
| 133 | + return rerunTtinfodetailIds; | |
| 134 | + } | |
| 135 | + | |
| 136 | + public void setRerunTtinfodetailIds(String rerunTtinfodetailIds) { | |
| 137 | + this.rerunTtinfodetailIds = rerunTtinfodetailIds; | |
| 138 | + } | |
| 139 | + | |
| 140 | + public String getRerunType() { | |
| 141 | + return rerunType; | |
| 142 | + } | |
| 143 | + | |
| 144 | + public void setRerunType(String rerunType) { | |
| 145 | + this.rerunType = rerunType; | |
| 146 | + } | |
| 147 | + | |
| 148 | + public Line getUseXl() { | |
| 149 | + return useXl; | |
| 150 | + } | |
| 151 | + | |
| 152 | + public void setUseXl(Line useXl) { | |
| 153 | + this.useXl = useXl; | |
| 154 | + } | |
| 155 | + | |
| 156 | + public GuideboardInfo getUseLp() { | |
| 157 | + return useLp; | |
| 158 | + } | |
| 159 | + | |
| 160 | + public void setUseLp(GuideboardInfo useLp) { | |
| 161 | + this.useLp = useLp; | |
| 162 | + } | |
| 163 | + | |
| 164 | + public CarConfigInfo getUseCarConfig() { | |
| 165 | + return useCarConfig; | |
| 166 | + } | |
| 167 | + | |
| 168 | + public void setUseCarConfig(CarConfigInfo useCarConfig) { | |
| 169 | + this.useCarConfig = useCarConfig; | |
| 170 | + } | |
| 171 | + | |
| 172 | + public EmployeeConfigInfo getUseEmployeeConfig() { | |
| 173 | + return useEmployeeConfig; | |
| 174 | + } | |
| 175 | + | |
| 176 | + public void setUseEmployeeConfig(EmployeeConfigInfo useEmployeeConfig) { | |
| 177 | + this.useEmployeeConfig = useEmployeeConfig; | |
| 178 | + } | |
| 179 | + | |
| 180 | + public SysUser getCreateBy() { | |
| 181 | + return createBy; | |
| 182 | + } | |
| 183 | + | |
| 184 | + public void setCreateBy(SysUser createBy) { | |
| 185 | + this.createBy = createBy; | |
| 186 | + } | |
| 187 | + | |
| 188 | + public SysUser getUpdateBy() { | |
| 189 | + return updateBy; | |
| 190 | + } | |
| 191 | + | |
| 192 | + public void setUpdateBy(SysUser updateBy) { | |
| 193 | + this.updateBy = updateBy; | |
| 194 | + } | |
| 195 | + | |
| 196 | + public Date getCreateDate() { | |
| 197 | + return createDate; | |
| 198 | + } | |
| 199 | + | |
| 200 | + public void setCreateDate(Date createDate) { | |
| 201 | + this.createDate = createDate; | |
| 202 | + } | |
| 203 | + | |
| 204 | + public Date getUpdateDate() { | |
| 205 | + return updateDate; | |
| 206 | + } | |
| 207 | + | |
| 208 | + public Boolean getIsCancel() { | |
| 209 | + return isCancel; | |
| 210 | + } | |
| 211 | + | |
| 212 | + public void setIsCancel(Boolean isCancel) { | |
| 213 | + this.isCancel = isCancel; | |
| 214 | + } | |
| 215 | + | |
| 216 | + public void setUpdateDate(Date updateDate) { | |
| 217 | + this.updateDate = updateDate; | |
| 218 | + } | |
| 219 | +} | ... | ... |
src/main/java/com/bsth/entity/search/PredicatesBuilder.java
| 1 | 1 | package com.bsth.entity.search; |
| 2 | 2 | |
| 3 | +import javax.persistence.criteria.CriteriaBuilder; | |
| 4 | +import javax.persistence.criteria.Path; | |
| 5 | +import javax.persistence.criteria.Predicate; | |
| 3 | 6 | import java.text.NumberFormat; |
| 4 | 7 | import java.text.ParseException; |
| 5 | 8 | import java.text.SimpleDateFormat; |
| 6 | 9 | import java.util.Date; |
| 7 | 10 | |
| 8 | -import javax.persistence.criteria.CriteriaBuilder; | |
| 9 | -import javax.persistence.criteria.Path; | |
| 10 | -import javax.persistence.criteria.Predicate; | |
| 11 | - | |
| 12 | 11 | /** |
| 13 | 12 | * |
| 14 | 13 | * @ClassName: PredicatesBuilder |
| ... | ... | @@ -44,13 +43,22 @@ public class PredicatesBuilder { |
| 44 | 43 | } |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | - public static Predicate ge(CriteriaBuilder cb,Path<Number> expression, Object object){ | |
| 48 | - try { | |
| 49 | - return cb.ge(expression, nf.parse(object.toString())); | |
| 50 | - } catch (ParseException e) { | |
| 51 | - e.printStackTrace(); | |
| 52 | - return null; | |
| 53 | - } | |
| 46 | + public static Predicate ge(CriteriaBuilder cb,Path<?> expression, Object object){ | |
| 47 | + Class<?> leftType = expression.getJavaType(); | |
| 48 | + Class<?> rightType = object.getClass(); | |
| 49 | + | |
| 50 | + if (leftType.isAssignableFrom(Number.class) && | |
| 51 | + rightType.isAssignableFrom(Number.class)) { // 判定是否是Number类型的子类 | |
| 52 | + return cb.ge((Path<Number>) expression, (Number) object); | |
| 53 | + } else if (leftType.isAssignableFrom(String.class) && | |
| 54 | + rightType.isAssignableFrom(String.class)) { // 判定是否是String类型的子类 | |
| 55 | + return cb.greaterThanOrEqualTo((Path<String>) expression, (String) object); | |
| 56 | + } else if (leftType.isAssignableFrom(Date.class) && | |
| 57 | + rightType.isAssignableFrom(Date.class)) { // 判定是否是Date类型的子类 | |
| 58 | + return cb.greaterThanOrEqualTo((Path<Date>) expression, (Date) object); | |
| 59 | + } else { | |
| 60 | + throw new RuntimeException("ge 不支持类型组合:" + expression.getJavaType() + ">=" + object.getClass()); | |
| 61 | + } | |
| 54 | 62 | } |
| 55 | 63 | |
| 56 | 64 | public static Predicate lt(CriteriaBuilder cb,Path<Number> expression, Object object){ |
| ... | ... | @@ -62,13 +70,22 @@ public class PredicatesBuilder { |
| 62 | 70 | } |
| 63 | 71 | } |
| 64 | 72 | |
| 65 | - public static Predicate le(CriteriaBuilder cb,Path<Number> expression, Object object){ | |
| 66 | - try { | |
| 67 | - return cb.le(expression, nf.parse(object.toString())); | |
| 68 | - } catch (ParseException e) { | |
| 69 | - e.printStackTrace(); | |
| 70 | - return null; | |
| 71 | - } | |
| 73 | + public static Predicate le(CriteriaBuilder cb,Path<?> expression, Object object){ | |
| 74 | + Class<?> leftType = expression.getJavaType(); | |
| 75 | + Class<?> rightType = object.getClass(); | |
| 76 | + | |
| 77 | + if (leftType.isAssignableFrom(Number.class) && | |
| 78 | + rightType.isAssignableFrom(Number.class)) { // 判定是否是Number类型的子类 | |
| 79 | + return cb.le((Path<Number>) expression, (Number) object); | |
| 80 | + } else if (leftType.isAssignableFrom(String.class) && | |
| 81 | + rightType.isAssignableFrom(String.class)) { // 判定是否是String类型的子类 | |
| 82 | + return cb.lessThanOrEqualTo((Path<String>) expression, (String) object); | |
| 83 | + } else if (leftType.isAssignableFrom(Date.class) && | |
| 84 | + rightType.isAssignableFrom(Date.class)) { // 判定是否是Date类型的子类 | |
| 85 | + return cb.lessThanOrEqualTo((Path<Date>) expression, (Date) object); | |
| 86 | + } else { | |
| 87 | + throw new RuntimeException("ge 不支持类型组合:" + expression.getJavaType() + ">=" + object.getClass()); | |
| 88 | + } | |
| 72 | 89 | } |
| 73 | 90 | |
| 74 | 91 | public static Predicate prefixLike(CriteriaBuilder cb,Path<String> expression, Object object){ | ... | ... |
src/main/java/com/bsth/filter/ResourceFilter.java
| 1 | -package com.bsth.filter; | |
| 2 | - | |
| 3 | -import java.io.File; | |
| 4 | -import java.io.IOException; | |
| 5 | - | |
| 6 | -import javax.servlet.FilterChain; | |
| 7 | -import javax.servlet.ServletException; | |
| 8 | -import javax.servlet.http.HttpServletRequest; | |
| 9 | -import javax.servlet.http.HttpServletResponse; | |
| 10 | - | |
| 11 | -import org.apache.commons.lang3.StringUtils; | |
| 12 | - | |
| 13 | -import com.bsth.util.RequestUtils; | |
| 14 | - | |
| 15 | -/** | |
| 16 | - * | |
| 17 | - * @ClassName: ResourceFilter | |
| 18 | - * @Description: TODO(HTML片段过滤器) | |
| 19 | - * @author PanZhao | |
| 20 | - * @date 2016年3月19日 下午10:10:11 | |
| 21 | - * | |
| 22 | - */ | |
| 23 | -public class ResourceFilter extends BaseFilter { | |
| 24 | - | |
| 25 | - String[] params = new String[]{"no"}; | |
| 26 | - | |
| 27 | - @Override | |
| 28 | - public void doFilter(HttpServletRequest request, | |
| 29 | - HttpServletResponse response, FilterChain chain) | |
| 30 | - throws IOException, ServletException { | |
| 31 | - | |
| 32 | - String uri = request.getRequestURI(); | |
| 33 | - int len = uri.length(); | |
| 34 | - if (RequestUtils.isAjaxRequest(request) || | |
| 35 | - !uri.substring(len - 5, len).equals(".html")) { | |
| 36 | - super.doFilter(request, response, chain); | |
| 37 | - } else { | |
| 38 | - | |
| 39 | - String fPath = this.getClass().getResource("/").getPath() | |
| 40 | - + "static/" + uri; | |
| 41 | - | |
| 42 | - File f = new File(fPath); | |
| 43 | - | |
| 44 | - | |
| 45 | - if (f.exists() && f.isFile() ){ | |
| 46 | - request.getRequestDispatcher("/?initFragment=" + joinParam(request)).forward(request, response);; | |
| 47 | - }else | |
| 48 | - response.sendRedirect("/"); | |
| 49 | - } | |
| 50 | - } | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * 拼接参数 | |
| 54 | - * @param request | |
| 55 | - * @return | |
| 56 | - */ | |
| 57 | - public String joinParam(HttpServletRequest request){ | |
| 58 | - | |
| 59 | - StringBuilder sb = new StringBuilder(); | |
| 60 | - | |
| 61 | - String v | |
| 62 | - ,url = request.getRequestURI(); | |
| 63 | - for(String p : params){ | |
| 64 | - v = request.getParameter(p); | |
| 65 | - if(!StringUtils.isEmpty(v)) | |
| 66 | - sb.append("&" + p + "=" + v); | |
| 67 | - } | |
| 68 | - | |
| 69 | - if(sb.length() > 0) | |
| 70 | - url += "?" + sb.substring(1, sb.length()); | |
| 71 | - return url; | |
| 72 | - } | |
| 73 | -} | |
| 1 | +package com.bsth.filter; | |
| 2 | + | |
| 3 | +import java.io.File; | |
| 4 | +import java.io.IOException; | |
| 5 | + | |
| 6 | +import javax.servlet.FilterChain; | |
| 7 | +import javax.servlet.ServletException; | |
| 8 | +import javax.servlet.http.HttpServletRequest; | |
| 9 | +import javax.servlet.http.HttpServletResponse; | |
| 10 | + | |
| 11 | +import org.apache.commons.lang3.StringUtils; | |
| 12 | + | |
| 13 | +import com.bsth.util.RequestUtils; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * | |
| 17 | + * @ClassName: ResourceFilter | |
| 18 | + * @Description: TODO(HTML片段过滤器) | |
| 19 | + * @author PanZhao | |
| 20 | + * @date 2016年3月19日 下午10:10:11 | |
| 21 | + * | |
| 22 | + */ | |
| 23 | +public class ResourceFilter extends BaseFilter { | |
| 24 | + | |
| 25 | + String[] params = new String[]{"no"}; | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public void doFilter(HttpServletRequest request, | |
| 29 | + HttpServletResponse response, FilterChain chain) | |
| 30 | + throws IOException, ServletException { | |
| 31 | + | |
| 32 | + String uri = request.getRequestURI(); | |
| 33 | + int len = uri.length(); | |
| 34 | + if (RequestUtils.isAjaxRequest(request) || | |
| 35 | + !uri.substring(len - 5, len).equals(".html")) { | |
| 36 | + super.doFilter(request, response, chain); | |
| 37 | + } else { | |
| 38 | + | |
| 39 | + String fPath = this.getClass().getResource("/").getPath() | |
| 40 | + + "static/" + uri; | |
| 41 | + | |
| 42 | + File f = new File(fPath); | |
| 43 | + | |
| 44 | + | |
| 45 | + if (f.exists() && f.isFile() ){ | |
| 46 | + request.getRequestDispatcher("/?initFragment=" + joinParam(request)).forward(request, response);; | |
| 47 | + }else | |
| 48 | + response.sendRedirect("/"); | |
| 49 | + } | |
| 50 | + } | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * 拼接参数 | |
| 54 | + * @param request | |
| 55 | + * @return | |
| 56 | + */ | |
| 57 | + public String joinParam(HttpServletRequest request){ | |
| 58 | + | |
| 59 | + StringBuilder sb = new StringBuilder(); | |
| 60 | + | |
| 61 | + String v | |
| 62 | + ,url = request.getRequestURI(); | |
| 63 | + for(String p : params){ | |
| 64 | + v = request.getParameter(p); | |
| 65 | + if(!StringUtils.isEmpty(v)) | |
| 66 | + sb.append("&" + p + "=" + v); | |
| 67 | + } | |
| 68 | + | |
| 69 | + if(sb.length() > 0) | |
| 70 | + url += "?" + sb.substring(1, sb.length()); | |
| 71 | + return url; | |
| 72 | + } | |
| 73 | +} | ... | ... |
src/main/java/com/bsth/oplog/http/HttpOpLogInterceptor.java
| ... | ... | @@ -19,7 +19,7 @@ import org.springframework.web.servlet.ModelAndView; |
| 19 | 19 | * @date 2016年10月20日 上午12:03:11 |
| 20 | 20 | * |
| 21 | 21 | */ |
| 22 | -@Component | |
| 22 | +//@Component | |
| 23 | 23 | public class HttpOpLogInterceptor implements HandlerInterceptor { |
| 24 | 24 | |
| 25 | 25 | private final PathMatcher pathMatcher = new AntPathMatcher(); | ... | ... |
src/main/java/com/bsth/repository/SectionRepository.java
| ... | ... | @@ -58,7 +58,7 @@ public interface SectionRepository extends BaseRepository<Section, Integer> { |
| 58 | 58 | |
| 59 | 59 | "VALUES (?1 , ?2 , ?3 , ?4 , ?5 , "+ |
| 60 | 60 | |
| 61 | - "?6 , GEOMFROMTEXT(?7) , GEOMFROMTEXT(?8) , ?9 , ?10 ,"+ | |
| 61 | + "?6 , ST_GeomFromText(?7) , ST_GeomFromText(?8) , ?9 , ?10 ,"+ | |
| 62 | 62 | |
| 63 | 63 | "?11 , ?12 , ?13 , ?14 , ?15 ,"+ |
| 64 | 64 | |
| ... | ... | @@ -83,8 +83,8 @@ public interface SectionRepository extends BaseRepository<Section, Integer> { |
| 83 | 83 | @Transactional |
| 84 | 84 | @Modifying |
| 85 | 85 | @Query(value="UPDATE bsth_c_section SET " + |
| 86 | - "gsection_vector = GEOMFROMTEXT(?2) , " + | |
| 87 | - "bsection_vector = GEOMFROMTEXT(?3)," + | |
| 86 | + "gsection_vector = ST_GeomFromText(?2) , " + | |
| 87 | + "bsection_vector = ST_GeomFromText(?3)," + | |
| 88 | 88 | "section_code = ?4," + |
| 89 | 89 | "section_name = ?5," + |
| 90 | 90 | "croses_road = ?6," + | ... | ... |
src/main/java/com/bsth/repository/StationRepository.java
| ... | ... | @@ -61,7 +61,7 @@ public interface StationRepository extends BaseRepository<Station, Integer> { |
| 61 | 61 | "create_by,update_by,id) " + |
| 62 | 62 | " VALUES(" + |
| 63 | 63 | "?1 , ?2 , ?3 , ?4 , ?5," + |
| 64 | - "?6 , ?7 , ?8 , ?9 , GeomFromText(?10),GeomFromText(?11)," + | |
| 64 | + "?6 , ?7 , ?8 , ?9 , ST_GeomFromText(?10),ST_GeomFromText(?11)," + | |
| 65 | 65 | "?12 ,?13, ?14, ?15, ?16," + |
| 66 | 66 | "?17,?18,?19)", nativeQuery=true) |
| 67 | 67 | public void stationSave(String stationCode,String stationName,String roadCoding,String dbType,String bJwpoints, |
| ... | ... | @@ -93,8 +93,8 @@ public interface StationRepository extends BaseRepository<Station, Integer> { |
| 93 | 93 | "g_laty = ?7 , " + |
| 94 | 94 | "x = ?8 , " + |
| 95 | 95 | "y = ?9 , " + |
| 96 | - "b_polygon_grid = GeomFromText(?10) , " + | |
| 97 | - "g_polygon_grid = GeomFromText(?11) , " + | |
| 96 | + "b_polygon_grid = ST_GeomFromText(?10) , " + | |
| 97 | + "g_polygon_grid = ST_GeomFromText(?11) , " + | |
| 98 | 98 | "destroy = ?12 , " + |
| 99 | 99 | "radius = ?13 , " + |
| 100 | 100 | "shapes_type = ?14 , " + | ... | ... |
src/main/java/com/bsth/repository/oil/YlbRepository.java
| 1 | 1 | package com.bsth.repository.oil; |
| 2 | 2 | |
| 3 | +import java.util.Date; | |
| 3 | 4 | import java.util.List; |
| 5 | +import java.util.Map; | |
| 4 | 6 | |
| 5 | 7 | import org.springframework.data.jpa.repository.Modifying; |
| 6 | 8 | import org.springframework.data.jpa.repository.Query; |
| ... | ... | @@ -19,7 +21,9 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 19 | 21 | */ |
| 20 | 22 | @Transactional |
| 21 | 23 | @Modifying |
| 22 | - @Query(value="SELECT * FROM bsth_c_ylb where to_days(?)-to_days(rq)=1",nativeQuery=true) | |
| 24 | + @Query(value="SELECT a.* FROM bsth_c_ylb a where to_days(?1)-to_days(a.rq)=1" | |
| 25 | + + " and jcsx=(select max(b.jcsx) from bsth_c_ylb b where a.nbbm=b.nbbm and " | |
| 26 | + + " to_days(?1)-to_days(b.rq)=1 ) group by nbbm",nativeQuery=true) | |
| 23 | 27 | List<Ylb> obtainYlbefore(String rq); |
| 24 | 28 | |
| 25 | 29 | /** |
| ... | ... | @@ -31,4 +35,15 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 31 | 35 | @Modifying |
| 32 | 36 | @Query(value="SELECT * FROM bsth_c_ylb where to_days(?)=to_days(rq)",nativeQuery=true) |
| 33 | 37 | List<Ylb> obtainYl(String rq); |
| 38 | + | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 查询当天总的加注量和总里程 | |
| 42 | + * @param rq | |
| 43 | + * @return | |
| 44 | + */ | |
| 45 | + @Transactional | |
| 46 | + @Modifying | |
| 47 | + @Query(value="select sum(jzl) as jzl,sum(zlc) as zlc from bsth_c_ylb where nbbm=?1 and rq=?2",nativeQuery=true) | |
| 48 | + List<Object[]> sumLcYl(String nbbm,Date rq); | |
| 34 | 49 | } | ... | ... |
src/main/java/com/bsth/repository/oil/YlxxbRepository.java
| ... | ... | @@ -21,4 +21,10 @@ public interface YlxxbRepository extends BaseRepository<Ylxxb, Integer>{ |
| 21 | 21 | @Modifying |
| 22 | 22 | @Query(value="SELECT * FROM bsth_c_ylxxb where to_days(?)=to_days(yyrq)",nativeQuery=true) |
| 23 | 23 | List<Ylxxb> obtainYlxx(String rq); |
| 24 | + | |
| 25 | + @Transactional | |
| 26 | + @Modifying | |
| 27 | + @Query(value="SELECT * FROM bsth_c_ylxxb where to_days(?1)=to_days(yyrq) and nbbm =?2 and jylx=1",nativeQuery=true) | |
| 28 | + List<Ylxxb> obtainYlxx2(String rq,String nbbm); | |
| 29 | + | |
| 24 | 30 | } | ... | ... |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| ... | ... | @@ -20,9 +20,12 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 20 | 20 | List<ScheduleRealInfo> findByLines(List<String> lines); |
| 21 | 21 | |
| 22 | 22 | |
| 23 | - @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.jGh,s.clZbh,s.lpName order by (lpName+1)") | |
| 23 | + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.id,s.jGh,s.clZbh,s.lpName order by (lpName+1)") | |
| 24 | 24 | List<ScheduleRealInfo> queryUserInfo(String line,String date); |
| 25 | 25 | |
| 26 | + @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,s.jName from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.jGh,s.clZbh,s.lpName ,s.jName order by (lpName+1)") | |
| 27 | + List<ScheduleRealInfo> queryUserInfo2(String line,String date); | |
| 28 | + | |
| 26 | 29 | @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by bcs") |
| 27 | 30 | List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName); |
| 28 | 31 | |
| ... | ... | @@ -57,6 +60,9 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 57 | 60 | @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') order by bcs") |
| 58 | 61 | List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date); |
| 59 | 62 | |
| 63 | + @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and bcType='normal' order by bcs") | |
| 64 | + List<ScheduleRealInfo> queryListWaybill2(String jName,String clZbh,String lpName,String date); | |
| 65 | + | |
| 60 | 66 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2") |
| 61 | 67 | List<ScheduleRealInfo> scheduleDaily(String line,String date); |
| 62 | 68 | |
| ... | ... | @@ -72,7 +78,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 72 | 78 | @Query(value = "delete ScheduleRealInfo s where s.xlBm=?1 and s.scheduleDateStr=?2") |
| 73 | 79 | void deleteByLineCodeAndDate(String xlBm, String schDate); |
| 74 | 80 | |
| 75 | - @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2") | |
| 81 | + @Query(value="select s from ScheduleRealInfo s where (s.xlBm = ?1 or s.xlBm is not null) and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2") | |
| 76 | 82 | List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date); |
| 77 | 83 | |
| 78 | 84 | @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh) from ScheduleRealInfo s where (s.xlBm = ?1 or s.xlBm is not null) and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY xlBm,clZbh,jGh ORDER BY xlBm,clZbh,realExecDate,fcsjActual") | ... | ... |
src/main/java/com/bsth/repository/schedule/GuideboardInfoRepository.java
| 1 | 1 | package com.bsth.repository.schedule; |
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | +import java.util.Map; | |
| 4 | 5 | |
| 5 | 6 | import com.bsth.entity.schedule.EmployeeConfigInfo; |
| 6 | 7 | import com.bsth.entity.schedule.GuideboardInfo; |
| ... | ... | @@ -29,4 +30,11 @@ public interface GuideboardInfoRepository extends BaseRepository<GuideboardInfo, |
| 29 | 30 | |
| 30 | 31 | @Query(value = " SELECT g FROM GuideboardInfo g where g.lpName like ?1") |
| 31 | 32 | List<GuideboardInfo> findLpName(String lpName); |
| 33 | + | |
| 34 | + @Query(value = "" + | |
| 35 | + "select new map(td.lp.id as lpId, td.lp.lpName as lpName) " + | |
| 36 | + "from TTInfoDetail td " + | |
| 37 | + "where td.ttinfo.id=?1 " + | |
| 38 | + "group by td.ttinfo.id, td.lp.id, td.lp.lpName") | |
| 39 | + List<Map<String, Object>> findLpName(Long ttid); | |
| 32 | 40 | } | ... | ... |
src/main/java/com/bsth/repository/schedule/RerunRuleRepository.java
0 → 100644
| 1 | +package com.bsth.repository.schedule; | |
| 2 | + | |
| 3 | +import com.bsth.entity.schedule.rule.RerunRule; | |
| 4 | +import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | |
| 5 | +import com.bsth.repository.BaseRepository; | |
| 6 | +import org.springframework.data.domain.Page; | |
| 7 | +import org.springframework.data.domain.Pageable; | |
| 8 | +import org.springframework.data.jpa.domain.Specification; | |
| 9 | +import org.springframework.data.jpa.repository.EntityGraph; | |
| 10 | +import org.springframework.data.jpa.repository.Query; | |
| 11 | +import org.springframework.stereotype.Repository; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * Created by xu on 16/10/18. | |
| 15 | + */ | |
| 16 | +@Repository | |
| 17 | +public interface RerunRuleRepository extends BaseRepository<RerunRule, Long> { | |
| 18 | + @EntityGraph(value = "dylp", type = EntityGraph.EntityGraphType.FETCH) | |
| 19 | + @Override | |
| 20 | + Page<RerunRule> findAll(Specification<RerunRule> spec, Pageable pageable); | |
| 21 | + | |
| 22 | + @EntityGraph(value = "dylp", type = EntityGraph.EntityGraphType.FETCH) | |
| 23 | + @Query("select cc from RerunRule cc where cc.id=?1") | |
| 24 | + RerunRule findOneExtend(Long aLong); | |
| 25 | +} | ... | ... |
src/main/java/com/bsth/repository/schedule/TTInfoDetailRepository.java
| ... | ... | @@ -35,4 +35,7 @@ public interface TTInfoDetailRepository extends BaseRepository<TTInfoDetail, Lon |
| 35 | 35 | @Query(value = "select max(tt.fcno) as mx from bsth_c_s_ttinfo_detail tt where tt.xl =?1 and tt.ttinfo =?2", nativeQuery = true) |
| 36 | 36 | Long findMaxFcno(Integer xlid, Long ttinfoid); |
| 37 | 37 | |
| 38 | + @Query(value = "select tt from TTInfoDetail tt where tt.xl.id = ?1 and tt.ttinfo.id = ?2 and tt.lp.id = ?3 order by tt.fcno asc") | |
| 39 | + List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId); | |
| 40 | + | |
| 38 | 41 | } | ... | ... |
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
| 1 | 1 | package com.bsth.service.directive; |
| 2 | 2 | |
| 3 | -import java.text.SimpleDateFormat; | |
| 4 | 3 | import java.util.ArrayList; |
| 5 | 4 | import java.util.Collection; |
| 6 | 5 | import java.util.Collections; |
| ... | ... | @@ -11,6 +10,8 @@ import java.util.List; |
| 11 | 10 | import java.util.Map; |
| 12 | 11 | |
| 13 | 12 | import org.apache.commons.lang3.StringUtils; |
| 13 | +import org.joda.time.format.DateTimeFormat; | |
| 14 | +import org.joda.time.format.DateTimeFormatter; | |
| 14 | 15 | import org.slf4j.Logger; |
| 15 | 16 | import org.slf4j.LoggerFactory; |
| 16 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -73,7 +74,10 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 73 | 74 | @Autowired |
| 74 | 75 | DayOfSchedule dayOfSchedule; |
| 75 | 76 | |
| 76 | - static Long schDiff = 1000 * 60 * 60L; | |
| 77 | + //static Long schDiff = 1000 * 60 * 60L; | |
| 78 | + | |
| 79 | + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm") | |
| 80 | + ,fmtHHmm_CN = DateTimeFormat.forPattern("HH点mm分"); | |
| 77 | 81 | |
| 78 | 82 | @Override |
| 79 | 83 | public int send60Phrase(String nbbm, String text, String sender) { |
| ... | ... | @@ -111,10 +115,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 111 | 115 | logger.warn("烂班不允许发送调度指令...."); |
| 112 | 116 | return -1; |
| 113 | 117 | } |
| 114 | - //多线程下发指令时,SimpleDateFormat必须方法内初始化 | |
| 115 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH点mm分"); | |
| 116 | - | |
| 117 | - String text = "已完成" + finish + "个班次,下一发车时间" + sdfHHmm.format(new Date(sch.getDfsjT())) + ",由" | |
| 118 | + String text = "已完成" + finish + "个班次,下一发车时间" + fmtHHmm_CN.print(sch.getDfsjT()) + ",由" | |
| 118 | 119 | + sch.getQdzName() + "发往" + sch.getZdzName(); |
| 119 | 120 | |
| 120 | 121 | //下发0x02指令 调度指令(闹钟有效) |
| ... | ... | @@ -168,7 +169,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 168 | 169 | @Override |
| 169 | 170 | public void sendD60ToPage(ScheduleRealInfo sch) { |
| 170 | 171 | Map<String, Object> map = new HashMap<>(); |
| 171 | - map.put("fn", sch); | |
| 172 | + map.put("fn", "directive"); | |
| 172 | 173 | map.put("t", sch); |
| 173 | 174 | |
| 174 | 175 | ObjectMapper mapper = new ObjectMapper(); |
| ... | ... | @@ -274,8 +275,10 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 274 | 275 | return null; |
| 275 | 276 | } |
| 276 | 277 | } |
| 277 | - upDown = gpsData.getUpDown(); | |
| 278 | - state = gpsData.getState(); | |
| 278 | + else{ | |
| 279 | + upDown = gpsData.getUpDown(); | |
| 280 | + state = gpsData.getState(); | |
| 281 | + } | |
| 279 | 282 | } else { |
| 280 | 283 | upDown = Integer.parseInt(sch.getXlDir()); |
| 281 | 284 | state = 0; |
| ... | ... | @@ -400,11 +403,10 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 400 | 403 | |
| 401 | 404 | List<Directive> rs = list.subList(s, e); |
| 402 | 405 | |
| 403 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 404 | 406 | // 时间格式化,车辆自编号转换 |
| 405 | 407 | for (Directive d : rs) { |
| 406 | 408 | if (d.getTimeHHmm() == null) |
| 407 | - d.setTimeHHmm(sdfHHmm.format(new Date(d.getTimestamp()))); | |
| 409 | + d.setTimeHHmm(fmtHHmm.print(d.getTimestamp())); | |
| 408 | 410 | if (d.getNbbm() == null) |
| 409 | 411 | d.setNbbm(BasicData.deviceId2NbbmMap.get(d.getDeviceId())); |
| 410 | 412 | } |
| ... | ... | @@ -453,10 +455,10 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 453 | 455 | if (e > count) |
| 454 | 456 | e = count; |
| 455 | 457 | |
| 456 | - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 458 | + //SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 457 | 459 | List<D80> rs = d80s.subList(s, e); |
| 458 | 460 | for(D80 d80 : rs){ |
| 459 | - d80.setTimeStr(sdfHHmm.format(new Date(d80.getTimestamp()))); | |
| 461 | + d80.setTimeStr(fmtHHmm.print(d80.getTimestamp())); | |
| 460 | 462 | } |
| 461 | 463 | |
| 462 | 464 | Map<String, Object> rsMap = new HashMap<>(); | ... | ... |
src/main/java/com/bsth/service/impl/CarDeviceServiceImpl.java
| 1 | 1 | package com.bsth.service.impl; |
| 2 | 2 | |
| 3 | +import com.bsth.common.ResponseCode; | |
| 3 | 4 | import com.bsth.entity.CarDevice; |
| 5 | +import com.bsth.entity.Cars; | |
| 6 | +import com.bsth.entity.schedule.rule.RerunRule; | |
| 7 | +import com.bsth.repository.CarDeviceRepository; | |
| 8 | +import com.bsth.repository.CarsRepository; | |
| 4 | 9 | import com.bsth.service.CarDeviceService; |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 5 | 11 | import org.springframework.stereotype.Service; |
| 6 | 12 | |
| 13 | +import javax.transaction.Transactional; | |
| 14 | +import java.util.HashMap; | |
| 15 | +import java.util.Map; | |
| 16 | + | |
| 7 | 17 | /** |
| 8 | 18 | * Created by xu on 16/6/15. |
| 9 | 19 | */ |
| 10 | 20 | @Service |
| 11 | 21 | public class CarDeviceServiceImpl extends BaseServiceImpl<CarDevice, Long> implements CarDeviceService { |
| 22 | + @Autowired | |
| 23 | + private CarDeviceRepository carDeviceRepository; | |
| 24 | + @Autowired | |
| 25 | + private CarsRepository carsRepository; | |
| 26 | + | |
| 27 | + @Transactional | |
| 28 | + @Override | |
| 29 | + public Map<String, Object> save(CarDevice carDevice) { | |
| 30 | + Map<String, Object> map = new HashMap<>(); | |
| 31 | + | |
| 32 | + try { | |
| 33 | + // 查找对应的车辆基础信息,更新设备编号数据 | |
| 34 | + Cars cars = carsRepository.findOne(carDevice.getCl()); | |
| 35 | + cars.setEquipmentCode(carDevice.getNewDeviceNo()); | |
| 36 | + // 保存车辆设备信息 | |
| 37 | + carDeviceRepository.save(carDevice); | |
| 38 | + map.put("status", ResponseCode.SUCCESS); | |
| 39 | + map.put("t", carDevice); | |
| 40 | + } catch(Exception e) { | |
| 41 | + map.put("status", ResponseCode.ERROR); | |
| 42 | + logger.error("save erro.", e); | |
| 43 | + } | |
| 44 | + | |
| 45 | + return map; | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Transactional | |
| 49 | + @Override | |
| 50 | + public Map<String, Object> delete(Long aLong) { | |
| 51 | + // 获取作废数据 | |
| 52 | + CarDevice carDevice = carDeviceRepository.findOne(aLong); | |
| 53 | + | |
| 54 | + toogleIsCancel(carDevice); | |
| 55 | + | |
| 56 | + Map<String, Object> map = new HashMap<>(); | |
| 57 | + map.put("status", ResponseCode.SUCCESS); | |
| 58 | + | |
| 59 | + return map; | |
| 60 | + } | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 撤销/作废切换。 | |
| 64 | + * @param rerunRule | |
| 65 | + */ | |
| 66 | + private void toogleIsCancel(CarDevice carDevice) { | |
| 67 | + boolean isCancel = carDevice.getIsCancel(); | |
| 68 | + if (isCancel) { | |
| 69 | + carDevice.setIsCancel(false); | |
| 70 | + } else { | |
| 71 | + carDevice.setIsCancel(true); | |
| 72 | + } | |
| 73 | + } | |
| 12 | 74 | } | ... | ... |
src/main/java/com/bsth/service/impl/SectionServiceImpl.java
| ... | ... | @@ -181,10 +181,14 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem |
| 181 | 181 | Integer version = map.get("versions").equals("") ? null : Integer.valueOf(map.get("versions").toString()); |
| 182 | 182 | |
| 183 | 183 | // WGS坐标点集合 |
| 184 | - String gsectionVector = "LINESTRING(" + sectionsWJPpoints +")"; | |
| 184 | + String gsectionVector = null; | |
| 185 | + if(!sectionsWJPpoints.equals("")) | |
| 186 | + gsectionVector = "LINESTRING(" + sectionsWJPpoints +")"; | |
| 185 | 187 | |
| 186 | 188 | // 原坐标点集合 |
| 187 | - String bsectionVectorS = "LINESTRING(" + sectionsBpoints + ")"; | |
| 189 | + String bsectionVectorS = null; | |
| 190 | + if(!sectionsBpoints.equals("")) | |
| 191 | + bsectionVectorS = "LINESTRING(" + sectionsBpoints + ")"; | |
| 188 | 192 | |
| 189 | 193 | Integer createBy = map.get("createBy").equals("") ? null : Integer.valueOf(map.get("createBy").toString()); |
| 190 | 194 | ... | ... |
src/main/java/com/bsth/service/impl/StationServiceImpl.java
| ... | ... | @@ -1029,6 +1029,16 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 1029 | 1029 | |
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | + if(bPloygonGrid.equals("")) | |
| 1033 | + bPloygonGrid = null; | |
| 1034 | + else | |
| 1035 | + bPloygonGrid = "POLYGON((" + bPloygonGrid +"))"; | |
| 1036 | + | |
| 1037 | + if(gPloygonGrid.equals("")) | |
| 1038 | + gPloygonGrid = null; | |
| 1039 | + else | |
| 1040 | + gPloygonGrid = "POLYGON((" + gPloygonGrid +"))"; | |
| 1041 | + | |
| 1032 | 1042 | // 保存站点 |
| 1033 | 1043 | repository.stationSave(stationCod, stationName, roadCoding, dbType, bJwpoints, |
| 1034 | 1044 | |
| ... | ... | @@ -1219,9 +1229,16 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 1219 | 1229 | |
| 1220 | 1230 | } |
| 1221 | 1231 | |
| 1222 | - bPloygonGrid = "POLYGON((" + bPloygonGrid +"))"; | |
| 1232 | + if(bPloygonGrid.equals("")) | |
| 1233 | + bPloygonGrid = null; | |
| 1234 | + else | |
| 1235 | + bPloygonGrid = "POLYGON((" + bPloygonGrid +"))"; | |
| 1236 | + | |
| 1237 | + if(gPloygonGrid.equals("")) | |
| 1238 | + gPloygonGrid = null; | |
| 1239 | + else | |
| 1240 | + gPloygonGrid = "POLYGON((" + gPloygonGrid +"))"; | |
| 1223 | 1241 | |
| 1224 | - gPloygonGrid = "POLYGON((" + gPloygonGrid +"))"; | |
| 1225 | 1242 | |
| 1226 | 1243 | // 是否撤销 |
| 1227 | 1244 | Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); | ... | ... |
src/main/java/com/bsth/service/oil/YlbService.java
| 1 | 1 | package com.bsth.service.oil; |
| 2 | 2 | |
| 3 | -import java.util.List; | |
| 4 | 3 | import java.util.Map; |
| 5 | 4 | |
| 6 | 5 | import com.bsth.entity.oil.Ylb; |
| 7 | 6 | import com.bsth.service.BaseService; |
| 8 | 7 | |
| 9 | 8 | public interface YlbService extends BaseService<Ylb, Integer>{ |
| 10 | - List<Map<String, Object>> obtain(String rq); | |
| 9 | + Map<String, Object> obtain(String rq); | |
| 10 | + | |
| 11 | + Map<String, Object> sort(Map<String, Object> map); | |
| 12 | + | |
| 13 | + Map<String, Object> outAndIn(Map<String, Object> map); | |
| 14 | + | |
| 15 | + Map<String, Object> checkYl(Map<String, Object> map); | |
| 11 | 16 | } | ... | ... |
src/main/java/com/bsth/service/oil/YlxxbService.java
| 1 | 1 | package com.bsth.service.oil; |
| 2 | 2 | |
| 3 | +import java.util.Map; | |
| 4 | + | |
| 3 | 5 | import com.bsth.entity.oil.Ylxxb; |
| 4 | 6 | import com.bsth.service.BaseService; |
| 7 | +import com.bsth.util.PageObject; | |
| 5 | 8 | |
| 6 | 9 | public interface YlxxbService extends BaseService<Ylxxb, Integer>{ |
| 10 | + PageObject<Ylxxb> Pagequery(Map<String, Object> map) ; | |
| 11 | + | |
| 12 | + Map<String, Object> checkJsy(Map<String, Object> map); | |
| 7 | 13 | |
| 8 | 14 | } | ... | ... |