Commit e1a37a682da9febea382b56a8c6df09bd7158dab
1 parent
3eda500c
到离站设备号关联车辆自编号错误问题修复
Showing
3 changed files
with
109 additions
and
12 deletions
src/main/java/com/bsth/repository/CarDeviceRepository.java
| @@ -35,7 +35,7 @@ public interface CarDeviceRepository extends BaseRepository<CarDevice, Long> { | @@ -35,7 +35,7 @@ public interface CarDeviceRepository extends BaseRepository<CarDevice, Long> { | ||
| 35 | +"select * from(select c.inside_code, c.car_plate, d.old_device_no device_no, d.qyrq, 'off' state " | 35 | +"select * from(select c.inside_code, c.car_plate, d.old_device_no device_no, d.qyrq, 'off' state " |
| 36 | +"from bsth_c_cars c left join bsth_c_car_device d on c.inside_code = d.cl_zbh " | 36 | +"from bsth_c_cars c left join bsth_c_car_device d on c.inside_code = d.cl_zbh " |
| 37 | +"where qyrq is not null)b " | 37 | +"where qyrq is not null)b " |
| 38 | - +")c order by device_no, qyrq, state ",nativeQuery=true) | 38 | + +")c order by device_no, qyrq, state desc ",nativeQuery=true) |
| 39 | List<Object[]> selectCarHistoryDeviceNo(); | 39 | List<Object[]> selectCarHistoryDeviceNo(); |
| 40 | 40 | ||
| 41 | } | 41 | } |
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| @@ -225,17 +225,21 @@ public class ReportServiceImpl implements ReportService{ | @@ -225,17 +225,21 @@ public class ReportServiceImpl implements ReportService{ | ||
| 225 | String ts = rs.getString("ts"); | 225 | String ts = rs.getString("ts"); |
| 226 | Date gpsDate = new Date(Long.valueOf(ts).longValue()); | 226 | Date gpsDate = new Date(Long.valueOf(ts).longValue()); |
| 227 | if(deviceNoMap.containsKey(deviceNo)){ | 227 | if(deviceNoMap.containsKey(deviceNo)){ |
| 228 | - for(Map<String, Object> m : deviceNoMap.get(deviceNo)){ | 228 | + List<Map<String, Object>> deviceNoList = deviceNoMap.get(deviceNo); |
| 229 | + for(int i = 0; i < deviceNoList.size(); i++){ | ||
| 230 | + Map<String, Object> m = deviceNoList.get(i); | ||
| 229 | Date qyrq = (Date)m.get("qyrq"); | 231 | Date qyrq = (Date)m.get("qyrq"); |
| 230 | String state = m.get("state").toString(); | 232 | String state = m.get("state").toString(); |
| 231 | - if("off".equals(state) && qyrq.getTime() > gpsDate.getTime()){ // 启用时间前的旧设备号,旧设备号里符合时间的最后一个 | 233 | + if("on".equals(state) && qyrq.getTime() <= gpsDate.getTime()){ // 大于启用时间 |
| 234 | + arr.setNbbm(m.get("nbbm").toString()); | ||
| 235 | + arr.setPzh(m.get("pzh").toString()); | ||
| 236 | + } | ||
| 237 | + if("off".equals(state) && qyrq.getTime() <= gpsDate.getTime()){ // 大于等于停用时间 | ||
| 238 | + arr.setNbbm(null); | ||
| 239 | + arr.setPzh(null); | ||
| 240 | + } else if(i == 0 && "off".equals(state) && qyrq.getTime() > gpsDate.getTime()){ // 小于停用时间(仅限第一条,说明第一次被替换) | ||
| 232 | arr.setNbbm(m.get("nbbm").toString()); | 241 | arr.setNbbm(m.get("nbbm").toString()); |
| 233 | arr.setPzh(m.get("pzh").toString()); | 242 | arr.setPzh(m.get("pzh").toString()); |
| 234 | - } else if("on".equals(state) && qyrq.getTime() <= gpsDate.getTime()){ // 启用时间后的新设备号,新设备号符合时间的第一个 | ||
| 235 | - if(StringUtils.isEmpty(arr.getNbbm())){ | ||
| 236 | - arr.setNbbm(m.get("nbbm").toString()); | ||
| 237 | - arr.setPzh(m.get("pzh").toString()); | ||
| 238 | - } | ||
| 239 | } | 243 | } |
| 240 | } | 244 | } |
| 241 | } | 245 | } |
| @@ -4571,18 +4575,17 @@ public class ReportServiceImpl implements ReportService{ | @@ -4571,18 +4575,17 @@ public class ReportServiceImpl implements ReportService{ | ||
| 4571 | 4575 | ||
| 4572 | public Map<String,Object> calcDetailMonthlyE(Map<String, Object> map){ | 4576 | public Map<String,Object> calcDetailMonthlyE(Map<String, Object> map){ |
| 4573 | 4577 | ||
| 4574 | -// List<List<String>> list = calcWaybillService.calcDetailMonthly(map); | ||
| 4575 | - List<List<String>> list = calcWaybillService.calcDetailMonthlyNew(map); | ||
| 4576 | - | ||
| 4577 | Map<String, Object> resultMap = new HashMap<String, Object>(); | 4578 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 4578 | try { | 4579 | try { |
| 4580 | + List<List<String>> list = calcWaybillService.calcDetailMonthlyNew(map); | ||
| 4581 | + | ||
| 4579 | String name = map.get("name").toString(); | 4582 | String name = map.get("name").toString(); |
| 4580 | String type = map.get("statisticalObj").toString(); | 4583 | String type = map.get("statisticalObj").toString(); |
| 4581 | if(list.size()>0){ | 4584 | if(list.size()>0){ |
| 4582 | ReportUtils ee = new ReportUtils(); | 4585 | ReportUtils ee = new ReportUtils(); |
| 4583 | ee.createFlie(list,name,type); | 4586 | ee.createFlie(list,name,type); |
| 4584 | } | 4587 | } |
| 4585 | - | 4588 | + |
| 4586 | resultMap.put("status", ResponseCode.SUCCESS); | 4589 | resultMap.put("status", ResponseCode.SUCCESS); |
| 4587 | } catch (Exception e) { | 4590 | } catch (Exception e) { |
| 4588 | resultMap.put("status", ResponseCode.ERROR); | 4591 | resultMap.put("status", ResponseCode.ERROR); |
src/main/resources/static/pages/report/inoutstation.html
| @@ -416,6 +416,7 @@ | @@ -416,6 +416,7 @@ | ||
| 416 | $("#dlzmx").html("到离站详细 "+xlmc+" "+clmc+" "+rqmc+" "+bcmc); | 416 | $("#dlzmx").html("到离站详细 "+xlmc+" "+clmc+" "+rqmc+" "+bcmc); |
| 417 | $("#fcsj_xx").val(fcsj); | 417 | $("#fcsj_xx").val(fcsj); |
| 418 | $("#ddsj_xx").val(ddsj); | 418 | $("#ddsj_xx").val(ddsj); |
| 419 | + updateNbbmByDeviceId(result); | ||
| 419 | var ludan_ll_1 = template('ludan_ll_1',{list:result}); | 420 | var ludan_ll_1 = template('ludan_ll_1',{list:result}); |
| 420 | // 把渲染好的模版html文本追加到表格中 | 421 | // 把渲染好的模版html文本追加到表格中 |
| 421 | $('#forms1 .ludan_ll_1').html(ludan_ll_1); | 422 | $('#forms1 .ludan_ll_1').html(ludan_ll_1); |
| @@ -451,6 +452,7 @@ | @@ -451,6 +452,7 @@ | ||
| 451 | } | 452 | } |
| 452 | $("#dlzmx").html("到离站详细 "+xlmc+" "+rqmc+" "+sxmc+" "+zdmc); | 453 | $("#dlzmx").html("到离站详细 "+xlmc+" "+rqmc+" "+sxmc+" "+zdmc); |
| 453 | $get('/report/queryListClzd',{zd:zd,zdlx:zdlx,line:line,fcsj:date1,ddsj:date2},function(result){ | 454 | $get('/report/queryListClzd',{zd:zd,zdlx:zdlx,line:line,fcsj:date1,ddsj:date2},function(result){ |
| 455 | + updateNbbmByDeviceId(result); | ||
| 454 | var ludan_ll_1 = template('ludan_ll_1',{list:result}); | 456 | var ludan_ll_1 = template('ludan_ll_1',{list:result}); |
| 455 | // 把渲染好的模版html文本追加到表格中 | 457 | // 把渲染好的模版html文本追加到表格中 |
| 456 | $('#forms1 .ludan_ll_1').html(ludan_ll_1); | 458 | $('#forms1 .ludan_ll_1').html(ludan_ll_1); |
| @@ -458,6 +460,98 @@ | @@ -458,6 +460,98 @@ | ||
| 458 | } | 460 | } |
| 459 | }) | 461 | }) |
| 460 | 462 | ||
| 463 | + var carsMap = new Map(); | ||
| 464 | + var carsMapDeriveId = new Map(); | ||
| 465 | + $get('/cars/all',{},function(result){ | ||
| 466 | + if(result){ | ||
| 467 | + $.each(result, function(i, obj) { | ||
| 468 | + var nbbm = obj.insideCode; | ||
| 469 | + var deviceId = obj.equipmentCode; | ||
| 470 | + deviceId = deviceId.replace(/BF-/g, ""); | ||
| 471 | + var p = new Array(); | ||
| 472 | + p["deviceId"] = deviceId; | ||
| 473 | + p["nbbm"] = obj.insideCode; | ||
| 474 | + p["pzh"] = obj.carPlate; | ||
| 475 | + carsMap.set(nbbm, p); | ||
| 476 | + carsMapDeriveId.set(deviceId, p); | ||
| 477 | + }); | ||
| 478 | + } | ||
| 479 | + }); | ||
| 480 | + | ||
| 481 | + var cdMap = new Map(); | ||
| 482 | + $get('/cde_sc/all',{},function(result){ | ||
| 483 | + if(result.data){ | ||
| 484 | + $.each(result.data, function(i, obj) { | ||
| 485 | + var data = []; | ||
| 486 | + if(obj.newDeviceNo || obj.oldDeviceNo){ | ||
| 487 | + var newDeviceNo = obj.newDeviceNo; | ||
| 488 | + var oldDeviceNo = obj.oldDeviceNo; | ||
| 489 | + newDeviceNo = newDeviceNo.replace(/BF-/g, ""); | ||
| 490 | + oldDeviceNo = oldDeviceNo.replace(/BF-/g, ""); | ||
| 491 | + var p = new Array(); | ||
| 492 | + p["newDeviceNo"] = newDeviceNo; | ||
| 493 | + p["oldDeviceNo"] = oldDeviceNo; | ||
| 494 | + p["qyrq"] = obj.qyrq; | ||
| 495 | + p["nbbm"] = obj.clZbh; | ||
| 496 | + if(!(cdMap.has(newDeviceNo))){ | ||
| 497 | + cdMap.set(newDeviceNo, []); | ||
| 498 | + } | ||
| 499 | + if(!(cdMap.has(oldDeviceNo))){ | ||
| 500 | + cdMap.set(oldDeviceNo, []); | ||
| 501 | + } | ||
| 502 | + if(newDeviceNo == oldDeviceNo){ | ||
| 503 | + cdMap.get(newDeviceNo).push(p); | ||
| 504 | + } else { | ||
| 505 | + cdMap.get(newDeviceNo).push(p); | ||
| 506 | + cdMap.get(oldDeviceNo).push(p); | ||
| 507 | + } | ||
| 508 | + } | ||
| 509 | + }); | ||
| 510 | + } | ||
| 511 | + console.log("cdMap", cdMap); | ||
| 512 | + }); | ||
| 513 | + | ||
| 514 | + function updateNbbmByDeviceId(list){ | ||
| 515 | + $.each(list, function(i, obj) { | ||
| 516 | + var nbbm = ""; | ||
| 517 | + if(obj.deviceId && obj.ts){ | ||
| 518 | + var ts = obj.ts; | ||
| 519 | + var deviceId = obj.deviceId; | ||
| 520 | + deviceId = deviceId.replace(/BF-/g, ""); | ||
| 521 | + if(cdMap.has(deviceId)){ | ||
| 522 | + $.each(cdMap.get(deviceId), function(j, cd) { | ||
| 523 | + if(cd.newDeviceNo && cd.qyrq && cd.nbbm){ | ||
| 524 | + if(deviceId == cd.newDeviceNo){ | ||
| 525 | + if(ts >= cd.qyrq){ | ||
| 526 | + nbbm = cd.nbbm; | ||
| 527 | + } | ||
| 528 | + } | ||
| 529 | + if(deviceId == cd.oldDeviceNo){ | ||
| 530 | + if(ts >= cd.qyrq){ | ||
| 531 | + nbbm = ""; | ||
| 532 | + } else if(j == 0){ // 历史替换记录里第一条可能只有被替换的记录 | ||
| 533 | + nbbm = cd.nbbm; | ||
| 534 | + } | ||
| 535 | + } | ||
| 536 | + } | ||
| 537 | + }); | ||
| 538 | + } | ||
| 539 | + } | ||
| 540 | + if(nbbm != ""){ | ||
| 541 | + obj.nbbm = nbbm; | ||
| 542 | + if(carsMap.has(nbbm)){ | ||
| 543 | + obj.pzh = carsMap.get(nbbm).pzh; | ||
| 544 | + } | ||
| 545 | + } else { | ||
| 546 | + if(carsMapDeriveId.has(obj.deviceId)){ | ||
| 547 | + var m = carsMapDeriveId.get(obj.deviceId); | ||
| 548 | + obj.nbbm = m.nbbm; | ||
| 549 | + obj.pzh = m.pzh; | ||
| 550 | + } | ||
| 551 | + } | ||
| 552 | + }); | ||
| 553 | + } | ||
| 554 | + | ||
| 461 | $(".sreach-zd").on("change",initZd); | 555 | $(".sreach-zd").on("change",initZd); |
| 462 | $("#date1,#date2").on("blur",initZd); | 556 | $("#date1,#date2").on("blur",initZd); |
| 463 | var status=false; | 557 | var status=false; |