|
|
|
|
@ -152,6 +152,7 @@ public class CommonApiController extends BladeController { |
|
|
|
|
if (BusinessConstant.CAR_STAT_IN.toString().equals(info.getNowstate())) { |
|
|
|
|
nextSiteIdx -= 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 下一站
|
|
|
|
|
List<Map<String, String>> snameList = new ArrayList<>(); |
|
|
|
|
SiteInfoVO nextSite = nextSiteIdx < siteList.size() ? siteList.get(nextSiteIdx) : null; |
|
|
|
|
@ -315,13 +316,13 @@ public class CommonApiController extends BladeController { |
|
|
|
|
public R getCurrentCarInfo(@RequestParam String carNo) { |
|
|
|
|
CarInfoVO carInfo = carInfoService.getCarInfo(carNo); |
|
|
|
|
//获取当前站点
|
|
|
|
|
StationHintVo currentStation = getCurrentStation(carInfo.getLinename(),carInfo.getUpordown(), carInfo.getInorder()); |
|
|
|
|
SiteInfoVO currentStation = getCurrentStation(carInfo.getLinename(),carInfo.getUpordown(), carInfo.getInorder()); |
|
|
|
|
//当前站点
|
|
|
|
|
String currentSnameKey = currentStation.getName(); |
|
|
|
|
String currentSnameKey = currentStation.getSname(); |
|
|
|
|
//获取上一站
|
|
|
|
|
StationHintVo upStation = getUpStation(carInfo.getLinename(), carInfo.getUpordown(), currentSnameKey); |
|
|
|
|
SiteInfoVO upStation = getUpStation(carInfo.getLinename(), carInfo.getUpordown(), currentSnameKey); |
|
|
|
|
//获取下一站
|
|
|
|
|
StationHintVo downStation = getDownStation(carInfo.getLinename(), carInfo.getUpordown(), currentSnameKey); |
|
|
|
|
SiteInfoVO downStation = getDownStation(carInfo.getLinename(), carInfo.getUpordown(), currentSnameKey); |
|
|
|
|
//计算当前车辆距离上一站点百分比
|
|
|
|
|
double pass = 0; |
|
|
|
|
if (Func.isNotEmpty(upStation)) { |
|
|
|
|
@ -340,8 +341,8 @@ public class CommonApiController extends BladeController { |
|
|
|
|
currentCarInfoVo.setLinename(carInfo.getLinename()); |
|
|
|
|
currentCarInfoVo.setSpeed(carInfo.getSpeed()); |
|
|
|
|
currentCarInfoVo.setCurrentStation(currentSnameKey); |
|
|
|
|
currentCarInfoVo.setUpStation(upStation.getName()); |
|
|
|
|
currentCarInfoVo.setDownStation(downStation.getName()); |
|
|
|
|
currentCarInfoVo.setUpStation(upStation.getSname()); |
|
|
|
|
currentCarInfoVo.setDownStation(downStation.getSname()); |
|
|
|
|
currentCarInfoVo.setPercentage(runPercent); |
|
|
|
|
//定时任务缓存
|
|
|
|
|
carInfoTask.setCarInfo(currentCarInfoVo); |
|
|
|
|
@ -356,9 +357,9 @@ public class CommonApiController extends BladeController { |
|
|
|
|
* @param inOrder 已经经过了第几个站点 |
|
|
|
|
* @return 当前站点 |
|
|
|
|
*/ |
|
|
|
|
private StationHintVo getCurrentStation(String linename, String upOrDown, String inOrder) { |
|
|
|
|
private SiteInfoVO getCurrentStation(String linename, String upOrDown, String inOrder) { |
|
|
|
|
// 根据上下行获取对应的站点集合
|
|
|
|
|
List<StationHintVo> stationList = getStationListByUpOrDown(linename,upOrDown); |
|
|
|
|
List<SiteInfoVO> stationList = getStationListByUpOrDown(linename,upOrDown); |
|
|
|
|
// 计算当前站点
|
|
|
|
|
int currentStationIndex = Integer.parseInt(inOrder) - 1; |
|
|
|
|
if (currentStationIndex < 0) { |
|
|
|
|
@ -377,10 +378,10 @@ public class CommonApiController extends BladeController { |
|
|
|
|
* @param currentSnameKey |
|
|
|
|
* @return |
|
|
|
|
**/ |
|
|
|
|
private StationHintVo getUpStation(String linename, String upordown, String currentSnameKey) { |
|
|
|
|
List<StationHintVo> busLineVoList = getStationListByUpOrDown(linename, upordown); |
|
|
|
|
private SiteInfoVO getUpStation(String linename, String upordown, String currentSnameKey) { |
|
|
|
|
List<SiteInfoVO> busLineVoList = getStationListByUpOrDown(linename, upordown); |
|
|
|
|
for (int i = 0; i < busLineVoList.size(); i++) { |
|
|
|
|
if (busLineVoList.get(i).getName().equals(currentSnameKey)) { |
|
|
|
|
if (busLineVoList.get(i).getSname().equals(currentSnameKey)) { |
|
|
|
|
if (i == 0) { |
|
|
|
|
return null; |
|
|
|
|
} else { |
|
|
|
|
@ -399,10 +400,10 @@ public class CommonApiController extends BladeController { |
|
|
|
|
* @param currentSnameKey |
|
|
|
|
* @return |
|
|
|
|
**/ |
|
|
|
|
private StationHintVo getDownStation(String linename, String upordown, String currentSnameKey) { |
|
|
|
|
List<StationHintVo> busLineVoList = getStationListByUpOrDown(linename, upordown); |
|
|
|
|
private SiteInfoVO getDownStation(String linename, String upordown, String currentSnameKey) { |
|
|
|
|
List<SiteInfoVO> busLineVoList = getStationListByUpOrDown(linename, upordown); |
|
|
|
|
for (int i = 0; i < busLineVoList.size(); i++) { |
|
|
|
|
if (busLineVoList.get(i).getName().equals(currentSnameKey)) { |
|
|
|
|
if (busLineVoList.get(i).getSname().equals(currentSnameKey)) { |
|
|
|
|
if (i == busLineVoList.size() - 1) { |
|
|
|
|
return null; |
|
|
|
|
} else { |
|
|
|
|
@ -420,11 +421,10 @@ public class CommonApiController extends BladeController { |
|
|
|
|
* @param upOrDown 上下行 |
|
|
|
|
* @return 站点集合 |
|
|
|
|
*/ |
|
|
|
|
private List<StationHintVo> getStationListByUpOrDown(String linename,String upOrDown) { |
|
|
|
|
private List<SiteInfoVO> getStationListByUpOrDown(String linename,String upOrDown) { |
|
|
|
|
//根据在那条线路,上下行获取对应的站点集合
|
|
|
|
|
R queryStationHint = stationHintService.QueryBusLineMessage(linename, upOrDown); |
|
|
|
|
List<StationHintVo> busLineVoList = (List<StationHintVo>) queryStationHint.getData(); |
|
|
|
|
return busLineVoList; |
|
|
|
|
List<SiteInfoVO> siteList = SiteListCache.getSiteList(linename,upOrDown); |
|
|
|
|
return siteList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|