Commit f2cbc8e78f72f1ee67ca04ce3bbaf6bcc115cefd
1 parent
b0ba5592
线路时刻分析
Showing
1 changed file
with
174 additions
and
209 deletions
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
| ... | ... | @@ -141,7 +141,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 141 | 141 | long dfsj = Long.valueOf(split0[0]) * 60 + Long.valueOf(split0[1]); |
| 142 | 142 | if(!schedule.getScheduleDateStr().equals(schedule.getRealExecDate())&&dfsj<23*60) |
| 143 | 143 | dfsj += 1440l; |
| 144 | - schedule.setDfsj(dfsj/60 + ":" + dfsj%60); | |
| 144 | + schedule.setDfsj((dfsj/60>9?"":"0")+dfsj/60+ ":" +(dfsj%60>9?"":"0")+dfsj%60); | |
| 145 | 145 | schedule.setDfsjT(dfsj); |
| 146 | 146 | } |
| 147 | 147 | if(schedule.getFcsjActual() != null){ |
| ... | ... | @@ -149,7 +149,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 149 | 149 | long fcsjA = Long.valueOf(split2[0]) * 60 + Long.valueOf(split2[1]); |
| 150 | 150 | if(!schedule.getScheduleDateStr().equals(schedule.getRealExecDate())&&fcsjA<23*60) |
| 151 | 151 | fcsjA += 1440l; |
| 152 | - schedule.setFcsjActual(fcsjA/60 + ":" + fcsjA%60); | |
| 152 | + schedule.setFcsjActual((fcsjA/60>9?"":"0")+fcsjA/60+ ":" +(fcsjA%60>9?"":"0")+fcsjA%60); | |
| 153 | 153 | schedule.setFcsjActualTime(fcsjA); |
| 154 | 154 | } |
| 155 | 155 | if(schedule.getZdsjActual() != null){ |
| ... | ... | @@ -159,11 +159,11 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 159 | 159 | zdsjA += 1440l; |
| 160 | 160 | if(schedule.getFcsjActualTime() != null && zdsjA < schedule.getFcsjActualTime()) |
| 161 | 161 | zdsjA += 1440l; |
| 162 | - schedule.setZdsjActual(zdsjA/60 + ":" + zdsjA%60); | |
| 162 | + schedule.setZdsjActual((zdsjA/60>9?"":"0")+zdsjA/60+ ":" +(zdsjA%60>9?"":"0")+zdsjA%60); | |
| 163 | 163 | schedule.setZdsjActualTime(zdsjA); |
| 164 | 164 | } |
| 165 | - schedule.setFcsj((fcsj/60<10?"0"+fcsj/60:fcsj/60) + ":" + (fcsj%60<10?"0"+fcsj%60:fcsj%60)); | |
| 166 | - schedule.setZdsj((zdsj/60<10?"0"+zdsj/60:zdsj/60) + ":" + (zdsj%60<10?"0"+zdsj%60:zdsj%60)); | |
| 165 | + schedule.setFcsj((fcsj/60<10?"0"+fcsj/60:fcsj/60)+ ":" +(fcsj%60<10?"0"+fcsj%60:fcsj%60)); | |
| 166 | + schedule.setZdsj((zdsj/60<10?"0"+zdsj/60:zdsj/60)+ ":" +(zdsj%60<10?"0"+zdsj%60:zdsj%60)); | |
| 167 | 167 | schedule.setFcsjT(fcsj); |
| 168 | 168 | schedule.setZdsjT(zdsj); |
| 169 | 169 | return schedule; |
| ... | ... | @@ -1379,249 +1379,214 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1379 | 1379 | times = "05:00-23:00"; |
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | - list = getSchedule(company, subCompany, line, startDate, endDate, model, times, true); | |
| 1382 | + list = getSchedule(company, subCompany, line, startDate, endDate, model, times, false); | |
| 1383 | 1383 | |
| 1384 | 1384 | String[] date1 = startDate.split("-"); |
| 1385 | 1385 | String[] date2 = endDate.split("-"); |
| 1386 | 1386 | startDate = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; |
| 1387 | 1387 | endDate = date2[0] + "年" + date2[1] + "月" + date2[2] + "日"; |
| 1388 | + String date = startDate + "-" + endDate; | |
| 1389 | + if(startDate.equals(endDate)){ | |
| 1390 | + date = startDate; | |
| 1391 | + } | |
| 1388 | 1392 | |
| 1389 | 1393 | String[] split = times.split("-"); |
| 1390 | 1394 | int startTime = Integer.valueOf(split[0].split(":")[0])*60 + Integer.valueOf(split[0].split(":")[1]); |
| 1391 | 1395 | int endTime = Integer.valueOf(split[1].split(":")[0])*60 + Integer.valueOf(split[1].split(":")[1]); |
| 1392 | 1396 | |
| 1393 | - for(ScheduleRealInfo schedule : list){ | |
| 1394 | - if(qdzName.length() != 0 && !qdzName.equals(schedule.getQdzName())){ | |
| 1395 | - continue; | |
| 1396 | - } | |
| 1397 | - Long fcsj = schedule.getFcsjT(); | |
| 1398 | - if(!(endTime!=0?fcsj>=startTime&&fcsj<endTime:fcsj>=startTime)){ | |
| 1399 | - continue; | |
| 1400 | - } | |
| 1401 | - String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName() + "/" + schedule.getFcsj() + "/" + schedule.getQdzName(); | |
| 1397 | + for(ScheduleRealInfo s : list){ | |
| 1398 | + String key = s.getScheduleDateStr() + "/" + s.getLpName(); | |
| 1402 | 1399 | if(!keyMap.containsKey(key)) |
| 1403 | 1400 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); |
| 1404 | - keyMap.get(key).add(schedule); | |
| 1401 | + keyMap.get(key).add(s); | |
| 1405 | 1402 | } |
| 1403 | + | |
| 1406 | 1404 | for(String key : keyMap.keySet()){ |
| 1407 | - Map<String, Object> tempMap = new HashMap<String, Object>(); | |
| 1408 | - int jhbc = 0, sjbc = 0, wdfz = 0; | |
| 1409 | - long jhdf = 0l, sjdf = 0l, wddf1 = 0l, wddf2 = 0l; | |
| 1410 | - long jhfc = 0l, sjfc = 0l, wdfc1 = 0l, wdfc2 = 0l; | |
| 1411 | - long jhys = 0l, sjys = 0l, yssjMax = 0l, yssjMin = 0l; | |
| 1412 | - long jhtz = 0l, sjtz = 0l, tzsjMax = 0l, tzsjMin = 0l; | |
| 1413 | - String companyName = "", subCompanyName = ""; | |
| 1414 | - for(ScheduleRealInfo schedule : keyMap.get(key)){ | |
| 1415 | - if(schedule.getGsName() != null && companyName.length() == 0) | |
| 1416 | - companyName = schedule.getGsName(); | |
| 1417 | - if(schedule.getFgsName() != null && subCompanyName.length() == 0) | |
| 1418 | - subCompanyName = schedule.getFgsName(); | |
| 1419 | - long tzsj = 0l; | |
| 1420 | - long yssj = 0l; | |
| 1421 | - jhbc++; | |
| 1422 | - if(schedule.getDfsj() != null){ | |
| 1423 | - jhtz += schedule.getFcsjT() - schedule.getDfsjT(); | |
| 1405 | + List<ScheduleRealInfo> list1 = keyMap.get(key); | |
| 1406 | + Map<String, List<ScheduleRealInfo>> keyMap_ = new HashMap<String, List<ScheduleRealInfo>>(); | |
| 1407 | + for(ScheduleRealInfo s : list1){ | |
| 1408 | + String dateStr = s.getScheduleDateStr(); | |
| 1409 | + if(!keyMap_.containsKey(dateStr)) | |
| 1410 | + keyMap_.put(dateStr, new ArrayList<ScheduleRealInfo>()); | |
| 1411 | + keyMap_.get(dateStr).add(s); | |
| 1412 | + } | |
| 1413 | + | |
| 1414 | + Set<String> keySet1 = keyMap_.keySet(); | |
| 1415 | + Map<Long, String> Map = new HashMap<Long, String>(); | |
| 1416 | + for(String key1 : keySet1){ | |
| 1417 | + Map.put(Long.valueOf(key1.replaceAll("-", "")), key1); | |
| 1418 | + } | |
| 1419 | + Set<Long> keySet2 = Map.keySet(); | |
| 1420 | + | |
| 1421 | + for(Long l : keySet2){ | |
| 1422 | + List<ScheduleRealInfo> list2 = keyMap_.get(Map.get(l)); | |
| 1423 | + List<ScheduleRealInfo> list3 = new ArrayList<ScheduleRealInfo>(); | |
| 1424 | + List<Long> fcsjs = new ArrayList<Long>(); | |
| 1425 | + List<Long> zdsjs = new ArrayList<Long>(); | |
| 1426 | + List<Long> fcsjAs = new ArrayList<Long>(); | |
| 1427 | + List<Long> zdsjAs = new ArrayList<Long>(); | |
| 1428 | + Map<Long, ScheduleRealInfo> fcsjMap = new HashMap<Long, ScheduleRealInfo>(); | |
| 1429 | + Map<Long, ScheduleRealInfo> zdsjMap = new HashMap<Long, ScheduleRealInfo>(); | |
| 1430 | + Map<Long, ScheduleRealInfo> fcsjAMap = new HashMap<Long, ScheduleRealInfo>(); | |
| 1431 | + Map<Long, ScheduleRealInfo> zdsjAMap = new HashMap<Long, ScheduleRealInfo>(); | |
| 1432 | + for(ScheduleRealInfo schedule : list2){ | |
| 1433 | + if(schedule.getStatus() != -1){ | |
| 1434 | + if(schedule.getFcsj()!=null&&schedule.getFcsjActual()!=null&& | |
| 1435 | + schedule.getZdsj()!=null&&schedule.getZdsjActual()!=null){ | |
| 1436 | + Long fcsj = schedule.getFcsjT(); | |
| 1437 | + Long zdsj = schedule.getZdsjT(); | |
| 1438 | + Long fcsjA = schedule.getFcsjActualTime(); | |
| 1439 | + Long zdsjA = schedule.getZdsjActualTime(); | |
| 1440 | + fcsjs.add(fcsj); | |
| 1441 | + zdsjs.add(zdsj); | |
| 1442 | + fcsjAs.add(fcsjA); | |
| 1443 | + zdsjAs.add(zdsjA); | |
| 1444 | + fcsjMap.put(fcsj, schedule); | |
| 1445 | + zdsjMap.put(zdsj, schedule); | |
| 1446 | + fcsjAMap.put(fcsjA, schedule); | |
| 1447 | + zdsjAMap.put(zdsjA, schedule); | |
| 1448 | + } | |
| 1449 | + } | |
| 1450 | + } | |
| 1451 | + Collections.sort(fcsjs); | |
| 1452 | + Collections.sort(zdsjs); | |
| 1453 | + Collections.sort(fcsjAs); | |
| 1454 | + Collections.sort(zdsjAs); | |
| 1455 | + for(int i = 0; i < fcsjs.size(); i++){ | |
| 1456 | + Long fcsj = fcsjs.get(i); | |
| 1457 | + Long zdsj = zdsjs.get(i); | |
| 1458 | + Long fcsjA = fcsjAs.get(i); | |
| 1459 | + Long zdsjA = zdsjAs.get(i); | |
| 1460 | + ScheduleRealInfo s = fcsjMap.get(fcsj); | |
| 1461 | + s.setFcsjActual(fcsjAMap.get(fcsjA).getFcsjActual()); | |
| 1462 | + s.setFcsjActualTime(fcsjAMap.get(fcsjA).getFcsjActualTime()); | |
| 1463 | + s.setZdsjActual(zdsjAMap.get(zdsjA).getZdsjActual()); | |
| 1464 | + s.setZdsjActualTime(zdsjAMap.get(zdsjA).getZdsjActualTime()); | |
| 1465 | + list3.add(s); | |
| 1424 | 1466 | } |
| 1425 | - jhys += schedule.getZdsjT() - schedule.getFcsjT(); | |
| 1426 | 1467 | |
| 1427 | - if(schedule.getFcsjActual() != null && schedule.getZdsjActual() != null){ | |
| 1428 | - sjbc++; | |
| 1429 | - sjfc += schedule.getFcsjActualTime(); | |
| 1430 | - yssj += schedule.getZdsjActualTime() - schedule.getFcsjActualTime(); | |
| 1431 | - if(schedule.getFcsjActualTime() - schedule.getFcsjT() < 0){ | |
| 1432 | - wdfc1 += schedule.getFcsjT() - schedule.getFcsjActualTime(); | |
| 1433 | -// kbc++; | |
| 1434 | - } else if(schedule.getFcsjActualTime() - schedule.getFcsjT() > 0){ | |
| 1435 | - wdfc2 += schedule.getFcsjActualTime() - schedule.getFcsjT(); | |
| 1436 | -// mbc++; | |
| 1437 | - } | |
| 1438 | - | |
| 1439 | - if(schedule.getDfsj() != null){ | |
| 1440 | - sjdf += schedule.getDfsjT(); | |
| 1441 | - tzsj += schedule.getFcsjActualTime() - schedule.getDfsjT(); | |
| 1442 | - if(schedule.getDfsjT() - schedule.getFcsjT() < 0) | |
| 1443 | - wddf1 += schedule.getFcsjT() - schedule.getDfsjT(); | |
| 1444 | - else | |
| 1445 | - wddf2 += schedule.getDfsjT() - schedule.getFcsjT(); | |
| 1446 | - } else { | |
| 1447 | - sjdf += schedule.getFcsjT(); | |
| 1448 | - tzsj += schedule.getFcsjActualTime() - schedule.getFcsjT(); | |
| 1468 | + for(int i = 0; i < list3.size(); i++){ | |
| 1469 | + ScheduleRealInfo s = list3.get(i); | |
| 1470 | + long fcwd = s.getFcsjActualTime() - s.getFcsjT(); | |
| 1471 | + long jhys = s.getBcsj(); | |
| 1472 | + long sjys = s.getZdsjActualTime() - s.getFcsjActualTime(); | |
| 1473 | + if(i > 0){ | |
| 1474 | + ScheduleRealInfo s1 = list3.get(i - 1); | |
| 1475 | + long ddwd = s1.getZdsjActualTime() - s1.getZdsjT(); | |
| 1476 | + long jhtz = s.getFcsjT() - s1.getZdsjT(); | |
| 1477 | + long sjtz = s.getFcsjActualTime() - s1.getZdsjActualTime(); | |
| 1478 | + | |
| 1479 | + if(s.getBcType().equals("normal")){ | |
| 1480 | + Map<String, Object> tempMap = new HashMap<String, Object>(); | |
| 1481 | + tempMap.put("dates", date); | |
| 1482 | + tempMap.put("line", s.getXlName()); | |
| 1483 | + tempMap.put("lp", s.getLpName()); | |
| 1484 | + tempMap.put("station", s.getQdzName()); | |
| 1485 | + tempMap.put("date", s.getScheduleDateStr()); | |
| 1486 | + tempMap.put("jhdd", s1.getZdsj()); | |
| 1487 | + tempMap.put("sjdd", s1.getZdsjActual()); | |
| 1488 | + tempMap.put("ddwd", ddwd); | |
| 1489 | + tempMap.put("jhfc", s.getFcsj()); | |
| 1490 | + tempMap.put("sjfc", s.getFcsjActual()); | |
| 1491 | + tempMap.put("fcwd", fcwd); | |
| 1492 | + tempMap.put("jhys", jhys); | |
| 1493 | + tempMap.put("sjys", sjys); | |
| 1494 | + tempMap.put("jhtz", jhtz); | |
| 1495 | + tempMap.put("sjtz", sjtz); | |
| 1496 | + | |
| 1497 | + String key0 = s.getLpName() + "/" + s.getQdzName(); | |
| 1498 | + if(!keyMap0.containsKey(key0)) | |
| 1499 | + keyMap0.put(key0, new ArrayList<Map<String, Object>>()); | |
| 1500 | + keyMap0.get(key0).add(tempMap); | |
| 1501 | + } | |
| 1449 | 1502 | } |
| 1450 | 1503 | } |
| 1451 | - | |
| 1452 | - sjys += yssj; | |
| 1453 | - if(yssj > yssjMax || yssjMax == 0l) | |
| 1454 | - yssjMax = yssj; | |
| 1455 | - if(yssj < yssjMin || yssjMin == 0l) | |
| 1456 | - yssjMin = yssj; | |
| 1457 | - | |
| 1458 | - sjtz += tzsj; | |
| 1459 | - if(tzsj > tzsjMax || tzsjMax == 0l) | |
| 1460 | - tzsjMax = tzsj; | |
| 1461 | - if(tzsj < tzsjMin || tzsjMin == 0l) | |
| 1462 | - tzsjMin = tzsj; | |
| 1463 | 1504 | } |
| 1464 | - String[] keys = key.split("/"); | |
| 1465 | - tempMap.put("date", keys[0]); | |
| 1466 | - tempMap.put("line", keys[1]); | |
| 1467 | - tempMap.put("lp", keys[2]); | |
| 1468 | - tempMap.put("jhdf", keys[3]); | |
| 1469 | - tempMap.put("jhfc", keys[3]); | |
| 1470 | - tempMap.put("station", keys[4]); | |
| 1471 | - tempMap.put("times", times); | |
| 1472 | - tempMap.put("company", companyName); | |
| 1473 | - tempMap.put("subCompany", subCompanyName); | |
| 1474 | - if(startDate.equals(endDate)) | |
| 1475 | - tempMap.put("dates", startDate); | |
| 1476 | - else | |
| 1477 | - tempMap.put("dates", startDate + "--" + endDate); | |
| 1478 | - tempMap.put("jhbc", jhbc); | |
| 1479 | - tempMap.put("sjbc", sjbc); | |
| 1480 | - if(sjbc != 0){ | |
| 1481 | - tempMap.put("sjdf", ((sjdf/sjbc)/60<10?"0"+(sjdf/sjbc)/60:(sjdf/sjbc)/60) + ":" + ((sjdf/sjbc)%60<10?"0"+(sjdf/sjbc)%60:(sjdf/sjbc)%60)); | |
| 1482 | - tempMap.put("wddf1", wddf1 / sjbc + "分"); | |
| 1483 | - tempMap.put("wddf2", wddf2 / sjbc + "分"); | |
| 1484 | - tempMap.put("sjfc", ((sjfc/sjbc)/60<10?"0"+(sjfc/sjbc)/60:(sjfc/sjbc)/60) + ":" + ((sjfc/sjbc)%60<10?"0"+(sjfc/sjbc)%60:(sjfc/sjbc)%60)); | |
| 1485 | - tempMap.put("wdfc1", wdfc1 / sjbc + "分"); | |
| 1486 | - tempMap.put("wdfc2", wdfc2 / sjbc + "分"); | |
| 1487 | -// tempMap.put("kbc", df.format((((double) kbc)/sjbc)*100)+"%"); | |
| 1488 | -// tempMap.put("mbc", df.format((((double) mbc)/sjbc)*100)+"%"); | |
| 1489 | - tempMap.put("pjys", sjys / sjbc + "分"); | |
| 1490 | - tempMap.put("pjtz", sjtz / sjbc + "分"); | |
| 1491 | - } else { | |
| 1492 | - tempMap.put("sjdf", "/"); | |
| 1493 | - tempMap.put("wddf1", "0分"); | |
| 1494 | - tempMap.put("wddf2", "0分"); | |
| 1495 | - tempMap.put("sjfc", "/"); | |
| 1496 | - tempMap.put("wdfc1", "0分"); | |
| 1497 | - tempMap.put("wdfc2", "0分"); | |
| 1498 | -// tempMap.put("kbc", "0%"); | |
| 1499 | -// tempMap.put("mbc", "0%"); | |
| 1500 | - tempMap.put("pjys", "0分"); | |
| 1501 | - tempMap.put("pjtz", "0分"); | |
| 1502 | - } | |
| 1503 | -// tempMap.put("kbc", kbc); | |
| 1504 | -// tempMap.put("mbc", mbc); | |
| 1505 | - if(!tempMap.get("jhfc").toString().equals("/") && !tempMap.get("sjfc").toString().equals("/")){ | |
| 1506 | - String[] temp1 = tempMap.get("jhfc").toString().split(":"); | |
| 1507 | - String[] temp2 = tempMap.get("sjfc").toString().split(":"); | |
| 1508 | - tempMap.put("wdfz", (Integer.valueOf(temp2[0])*60 + Integer.valueOf(temp2[1])) | |
| 1509 | - - (Integer.valueOf(temp1[0])*60 + Integer.valueOf(temp1[1]))); | |
| 1510 | - }else{ | |
| 1511 | - tempMap.put("wdfz", "/"); | |
| 1512 | - } | |
| 1513 | - tempMap.put("jhys", jhys); | |
| 1514 | - tempMap.put("sjys", sjys); | |
| 1515 | - tempMap.put("yssjMin", yssjMin); | |
| 1516 | - tempMap.put("yssjMax", yssjMax); | |
| 1517 | - tempMap.put("jhtz", jhtz); | |
| 1518 | - tempMap.put("sjtz", sjtz); | |
| 1519 | - tempMap.put("tzsjMax", tzsjMax); | |
| 1520 | - tempMap.put("tzsjMin", tzsjMin); | |
| 1521 | - list0.add(tempMap); | |
| 1522 | 1505 | } |
| 1523 | 1506 | |
| 1524 | - Collections.sort(list0, new Comparator<Map<String, Object>>() { | |
| 1525 | - | |
| 1526 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 1527 | - | |
| 1528 | - String[] split1 = o1.get("date").toString().split("-"); | |
| 1529 | - String[] split2 = o2.get("date").toString().split("-"); | |
| 1530 | - Long a = Long.valueOf(split1[0])*10000 + Long.valueOf(split1[1])*100 + Long.valueOf(split1[2]); | |
| 1531 | - Long b = Long.valueOf(split2[0])*10000 + Long.valueOf(split2[1])*100 + Long.valueOf(split2[2]); | |
| 1532 | - | |
| 1533 | - // 升序 | |
| 1534 | - return a.compareTo(b); | |
| 1535 | - } | |
| 1536 | - }); | |
| 1537 | 1507 | |
| 1538 | - for(Map<String, Object> m : list0){ | |
| 1539 | - String key = m.get("line").toString() + "/" + m.get("lp").toString() + "/" + m.get("station").toString(); | |
| 1540 | - if(!keyMap0.containsKey(key)) | |
| 1541 | - keyMap0.put(key, new ArrayList<Map<String, Object>>()); | |
| 1542 | - keyMap0.get(key).add(m); | |
| 1543 | - } | |
| 1544 | - for(String key : keyMap0.keySet()){ | |
| 1545 | - Map<String, Object> tempMap = new HashMap<String, Object>(); | |
| 1546 | - int jhbc = 0; | |
| 1547 | - int sjbc = 0; | |
| 1548 | - int wddf1 = 0; | |
| 1549 | - int wddf2 = 0; | |
| 1550 | - int wdfc1 = 0; | |
| 1551 | - int wdfc2 = 0; | |
| 1552 | - int ys = 0; | |
| 1553 | - int tz = 0; | |
| 1554 | - String companyName = "", subCompanyName = ""; | |
| 1555 | - for(Map<String, Object> m : keyMap0.get(key)){ | |
| 1556 | - if(m.containsKey("company") && companyName.length() == 0) | |
| 1557 | - companyName = m.get("company").toString(); | |
| 1558 | - if(m.containsKey("subCompany") && subCompanyName.length() == 0) | |
| 1559 | - subCompanyName = m.get("subCompany").toString(); | |
| 1560 | - jhbc += Integer.valueOf(m.get("jhbc").toString()); | |
| 1561 | - sjbc += Integer.valueOf(m.get("sjbc").toString()); | |
| 1562 | - wddf1 += Integer.valueOf(m.get("wddf1").toString().substring(0, m.get("wddf1").toString().length() - 1)); | |
| 1563 | - wddf2 += Integer.valueOf(m.get("wddf2").toString().substring(0, m.get("wddf2").toString().length() - 1)); | |
| 1564 | - wdfc1 += Integer.valueOf(m.get("wdfc1").toString().substring(0, m.get("wdfc1").toString().length() - 1)); | |
| 1565 | - wdfc2 += Integer.valueOf(m.get("wdfc2").toString().substring(0, m.get("wdfc2").toString().length() - 1)); | |
| 1566 | - ys += Integer.valueOf(m.get("pjys").toString().substring(0, m.get("pjys").toString().length() - 1)); | |
| 1567 | - tz += Integer.valueOf(m.get("pjtz").toString().substring(0, m.get("pjtz").toString().length() - 1)); | |
| 1568 | - } | |
| 1569 | - if(startDate.equals(endDate)) | |
| 1570 | - tempMap.put("dates", startDate); | |
| 1571 | - else | |
| 1572 | - tempMap.put("dates", startDate + "--" + endDate); | |
| 1573 | - tempMap.put("company", companyName); | |
| 1574 | - tempMap.put("subCompany", subCompanyName); | |
| 1575 | - String[] keys = key.split("/"); | |
| 1576 | - tempMap.put("line", keys[0]); | |
| 1577 | - tempMap.put("lp", keys[1]); | |
| 1578 | - tempMap.put("station", keys[2]); | |
| 1579 | - tempMap.put("times", times); | |
| 1580 | - tempMap.put("jhbc", jhbc); | |
| 1581 | - tempMap.put("sjbc", sjbc); | |
| 1582 | - tempMap.put("wddf1", wddf1/keyMap0.get(key).size()+"分"); | |
| 1583 | - tempMap.put("wddf2", wddf2/keyMap0.get(key).size()+"分"); | |
| 1584 | - tempMap.put("wdfc1", wdfc1/keyMap0.get(key).size()+"分"); | |
| 1585 | - tempMap.put("wdfc2", wdfc2/keyMap0.get(key).size()+"分"); | |
| 1586 | - tempMap.put("pjys", ys/keyMap0.get(key).size()+"分"); | |
| 1587 | - tempMap.put("pjtz", tz/keyMap0.get(key).size()+"分"); | |
| 1588 | - tempMap.put("workList", keyMap0.get(key)); | |
| 1589 | - | |
| 1590 | - String key1 = tempMap.get("line").toString(); | |
| 1591 | - if(!keyMap1.containsKey(key1)) | |
| 1592 | - keyMap1.put(key1, new ArrayList<Map<String, Object>>()); | |
| 1593 | - keyMap1.get(key1).add(tempMap); | |
| 1594 | - } | |
| 1595 | 1508 | |
| 1596 | - for(String key : keyMap1.keySet()){ | |
| 1597 | - Collections.sort(keyMap1.get(key), new Comparator<Map<String, Object>>() { | |
| 1509 | + if(keyMap0.keySet().size() > 0){ | |
| 1510 | + Set<String> keySet = keyMap0.keySet(); | |
| 1511 | + List<String> keyList = new ArrayList<String>(); | |
| 1512 | + keyList.addAll(keySet); | |
| 1513 | + Collections.sort(keyList, new Comparator<String>() { | |
| 1598 | 1514 | |
| 1599 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 1515 | + public int compare(String o1, String o2) { | |
| 1600 | 1516 | Long a; |
| 1601 | 1517 | Long b; |
| 1602 | - String lp1 = o1.get("lp").toString(); | |
| 1603 | - String lp2 = o2.get("lp").toString(); | |
| 1518 | + o1 = o1.split("/")[0]; | |
| 1519 | + o2 = o2.split("/")[0]; | |
| 1604 | 1520 | String str1 = ""; |
| 1605 | 1521 | String str2 = ""; |
| 1606 | - for(int i = 0; i < lp1.length(); i++){ | |
| 1607 | - str1 += (int)lp1.charAt(i); | |
| 1522 | + for(int i = 0; i < o1.length(); i++){ | |
| 1523 | + str1 += (int)o1.charAt(i); | |
| 1608 | 1524 | } |
| 1609 | - for(int i = 0; i < lp2.length(); i++){ | |
| 1610 | - str2 += (int)lp2.charAt(i); | |
| 1525 | + for(int i = 0; i < o2.length(); i++){ | |
| 1526 | + str2 += (int)o2.charAt(i); | |
| 1611 | 1527 | } |
| 1612 | 1528 | |
| 1613 | 1529 | a = Long.valueOf(str1); |
| 1614 | 1530 | b = Long.valueOf(str2); |
| 1615 | - | |
| 1531 | + | |
| 1616 | 1532 | // 升序 |
| 1617 | 1533 | return a.compareTo(b); |
| 1618 | 1534 | } |
| 1619 | 1535 | }); |
| 1620 | 1536 | |
| 1621 | - resList.addAll(keyMap1.get(key)); | |
| 1537 | + for(String key : keyList){ | |
| 1538 | + List<Map<String, Object>> mapList = keyMap0.get(key); | |
| 1539 | + Map<String, Object> tempMap = new HashMap<String, Object>(); | |
| 1540 | + int ddtq_ = 0, ddtqs = 0, ddyw_ = 0, ddyws = 0; | |
| 1541 | + int fctq_ = 0, fctqs = 0, fcyw_ = 0, fcyws = 0; | |
| 1542 | + int yssj_ = 0, yssjs = 0, tzsj_ = 0, tzsjs = 0; | |
| 1543 | + for(Map<String, Object> m : mapList){ | |
| 1544 | + int ddwd = Integer.valueOf(m.get("ddwd").toString()); | |
| 1545 | + if(ddwd < 0){ | |
| 1546 | + ddtq_ += 0 - ddwd; | |
| 1547 | + ++ddtqs; | |
| 1548 | + } else if(ddwd > 0){ | |
| 1549 | + ddyw_ += ddwd; | |
| 1550 | + ++ddyws; | |
| 1551 | + } | |
| 1552 | + int fcwd = Integer.valueOf(m.get("fcwd").toString()); | |
| 1553 | + if(fcwd < 0){ | |
| 1554 | + fctq_ += 0 - fcwd; | |
| 1555 | + ++fctqs; | |
| 1556 | + } else if(fcwd > 0){ | |
| 1557 | + fcyw_ += fcwd; | |
| 1558 | + ++fcyws; | |
| 1559 | + } | |
| 1560 | + int sjys = Integer.valueOf(m.get("sjys").toString()); | |
| 1561 | + yssj_ += sjys; | |
| 1562 | + ++yssjs; | |
| 1563 | + int sjtz = Integer.valueOf(m.get("sjtz").toString()); | |
| 1564 | + tzsj_ += sjtz; | |
| 1565 | + ++tzsjs; | |
| 1566 | + } | |
| 1567 | + tempMap.put("ddwd1", (ddtqs!=0?ddtq_/ddtqs:0) + "分"); | |
| 1568 | + tempMap.put("ddwd2", (ddyws!=0?ddyw_/ddyws:0) + "分"); | |
| 1569 | + tempMap.put("wdfc1", (fctqs!=0?fctq_/fctqs:0) + "分"); | |
| 1570 | + tempMap.put("wdfc2", (fcyws!=0?fcyw_/fcyws:0) + "分"); | |
| 1571 | + tempMap.put("pjys", (yssjs!=0?yssj_/yssjs:0) + "分"); | |
| 1572 | + tempMap.put("pjtz", (tzsjs!=0?tzsj_/tzsjs:0) + "分"); | |
| 1573 | + | |
| 1574 | + Map<String, Object> m = mapList.get(0); | |
| 1575 | + tempMap.put("dates", date); | |
| 1576 | + tempMap.put("times", times); | |
| 1577 | + tempMap.put("line", m.get("line")); | |
| 1578 | + tempMap.put("lp", m.get("lp")); | |
| 1579 | + tempMap.put("station", m.get("station")); | |
| 1580 | + tempMap.put("bcs", mapList.size()); | |
| 1581 | + tempMap.put("workList", mapList); | |
| 1582 | + if(qdzName != null && qdzName.trim().length() != 0){ | |
| 1583 | + if(!tempMap.get("station").equals(qdzName)){ | |
| 1584 | + continue; | |
| 1585 | + } | |
| 1586 | + } | |
| 1587 | + resList.add(tempMap); | |
| 1588 | + } | |
| 1622 | 1589 | } |
| 1623 | - | |
| 1624 | - | |
| 1625 | 1590 | return resList; |
| 1626 | 1591 | } |
| 1627 | 1592 | ... | ... |