|
|
@@ -310,80 +310,81 @@ public class PositionMonitorManage { |
|
|
|
} |
|
|
|
|
|
|
|
public List<ResRealTimeMonitorVehicleGisListVO> realTimeMonitorVehicleGisList(ReqRealTimeMonitorPO po) { |
|
|
|
if (CollUtil.isEmpty(po.getCompanyIdList())) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
// 按照登录用户,如果是运营商账号登录,删选出该运营商关联的车辆信息 |
|
|
|
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); |
|
|
|
Long roleId = userDetail.getRoleId(); |
|
|
|
List<VehicleCompanyPO> carPlates = Lists.newArrayList(); |
|
|
|
// 如果登录用户是运营商,只过滤出运营商下的车辆 |
|
|
|
if (UserRoleTypeEnum.OPERATOR_ROLE_ID.getId().equals(roleId)) { |
|
|
|
carPlates = vehicleBaseInfoService.getCarPlatesByCompanyIds(po.getCompanyIdList()); |
|
|
|
String companyName = userDetail.getCompanyName(); |
|
|
|
// 暂时控制运营商名称和运营商所在企业名称相同 |
|
|
|
OperatorQueryDTO operatorQueryDTO = operatorsCacheHelper.getByName(companyName); |
|
|
|
// 获取运营商id |
|
|
|
Long operatorId = operatorQueryDTO.getId(); |
|
|
|
carPlates = carPlates.stream() |
|
|
|
.filter(v -> operatorId.equals(v.getOperatorId())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
// 如果登录用户是企业信息员,过滤出使用企业和所属企业为该企业的车辆 |
|
|
|
else if (UserRoleTypeEnum.COMPANY_INFO_OFFICER_ROLE_ID.getId().equals(roleId)) { |
|
|
|
Long companyId = userDetail.getCompanyId(); |
|
|
|
carPlates = vehicleBaseInfoService.getCarPlatesByUseCompanyId(companyId); |
|
|
|
}else{ |
|
|
|
carPlates = vehicleBaseInfoService.getCarPlatesByCompanyIds(po.getCompanyIdList()); |
|
|
|
} |
|
|
|
log.info("request real carPlates 【{}】:", JSON.toJSONString(carPlates)); |
|
|
|
if (CollUtil.isEmpty(carPlates)) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
Map<String, Object> map = Maps.newConcurrentMap(); |
|
|
|
map.put(PositionContant.FIELD_CAR_PLATE, carPlates.stream().map(VehicleCompanyPO::getCarPlate).collect(Collectors.joining(","))); |
|
|
|
map.put(PositionContant.HOST_FEILD, HOST); |
|
|
|
JSONObject response = restTemplate.getForObject(PositionContant.REAL_GPS_URL, JSONObject.class, map); |
|
|
|
log.info("request real gps 【{}】:", JSON.toJSONString(response)); |
|
|
|
if (Objects.isNull(response)) { |
|
|
|
throw new BizException(ExceptionCode.BAD_REQUEST.getCode(), "实时数据请求失败 网络异常"); |
|
|
|
} |
|
|
|
Integer statusCode = response.getInteger("status_code"); |
|
|
|
if (0 != statusCode) { |
|
|
|
throw new BizException(ExceptionCode.BAD_REQUEST.getCode(), response.getString("message")); |
|
|
|
} |
|
|
|
JSONArray resultJsonArray = response.getJSONArray("result"); |
|
|
|
if (Objects.isNull(resultJsonArray) || resultJsonArray.size() == 0) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, VehicleCompanyPO> carMap = carPlates.stream() |
|
|
|
.filter(w -> Objects.nonNull(w) && Objects.nonNull(w.getCarPlate())) |
|
|
|
.filter(CodeUtil.distinctByKey(VehicleCompanyPO::getCarPlate)).collect(Collectors.toMap(VehicleCompanyPO::getCarPlate, v -> v)); |
|
|
|
List<ResRealTimeMonitorVehicleGisListVO> res = resultJsonArray.stream().map(o -> { |
|
|
|
JSONObject j = JSON.parseObject(JSON.toJSONString(o)); |
|
|
|
String carPlate = j.getString(PositionContant.FIELD_CAR_PLATE); |
|
|
|
VehicleCompanyPO vehicleCompany = carMap.get(carPlate); |
|
|
|
ResRealTimeMonitorVehicleGisListVO vo = new ResRealTimeMonitorVehicleGisListVO(); |
|
|
|
vo.setCarLongitude(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.LONGITUDE,BigDecimal.valueOf(0L))))); |
|
|
|
vo.setCarLatitude(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.LATITUDE,BigDecimal.valueOf(0L))))); |
|
|
|
vo.setCarAltitude(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.ALTITUDE,BigDecimal.valueOf(0L))))); |
|
|
|
vo.setCarDirection(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.DIRECTION,BigDecimal.valueOf(0L))))); |
|
|
|
vo.setCarPlate(carPlate); |
|
|
|
vo.setPlateColor(j.getString(PositionContant.PLATE_COLOR)); |
|
|
|
vo.setCompanyId(vehicleCompany.getCompanyId()); |
|
|
|
vo.setCompanyName(vehicleCompany.getCompanyName()); |
|
|
|
vo.setCarVelocity(BigDecimal.valueOf(Double.valueOf(String.valueOf(j.getOrDefault(PositionContant.CAR_VELOCITY,BigDecimal.valueOf(0L)))))); |
|
|
|
vo.setUpdateTime((j.getString(PositionContant.UPDATE_TIME))); |
|
|
|
vo.setSelfNo(vehicleCompany.getSelfNo()); |
|
|
|
vo.setStatus(j.getInteger(PositionContant.ONLINE_STATUS)); |
|
|
|
vo.setMoving(vehicleCompany.getMoving()); |
|
|
|
vo.setVehicleType(vehicleCompany.getVehicleType()); |
|
|
|
vo.setVehicleTypeName(vehicleCompany.getVechileTypeName()); |
|
|
|
vo.setLimitSpeed(VehicleLimitSpeedEnum.getLimitSpeedByCode(vehicleCompany.getVehicleType())); |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return res; |
|
|
|
return Collections.emptyList(); |
|
|
|
// if (CollUtil.isEmpty(po.getCompanyIdList())) { |
|
|
|
// return Collections.emptyList(); |
|
|
|
// } |
|
|
|
// // 按照登录用户,如果是运营商账号登录,删选出该运营商关联的车辆信息 |
|
|
|
// UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); |
|
|
|
// Long roleId = userDetail.getRoleId(); |
|
|
|
// List<VehicleCompanyPO> carPlates = Lists.newArrayList(); |
|
|
|
// // 如果登录用户是运营商,只过滤出运营商下的车辆 |
|
|
|
// if (UserRoleTypeEnum.OPERATOR_ROLE_ID.getId().equals(roleId)) { |
|
|
|
// carPlates = vehicleBaseInfoService.getCarPlatesByCompanyIds(po.getCompanyIdList()); |
|
|
|
// String companyName = userDetail.getCompanyName(); |
|
|
|
// // 暂时控制运营商名称和运营商所在企业名称相同 |
|
|
|
// OperatorQueryDTO operatorQueryDTO = operatorsCacheHelper.getByName(companyName); |
|
|
|
// // 获取运营商id |
|
|
|
// Long operatorId = operatorQueryDTO.getId(); |
|
|
|
// carPlates = carPlates.stream() |
|
|
|
// .filter(v -> operatorId.equals(v.getOperatorId())) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// } |
|
|
|
// // 如果登录用户是企业信息员,过滤出使用企业和所属企业为该企业的车辆 |
|
|
|
// else if (UserRoleTypeEnum.COMPANY_INFO_OFFICER_ROLE_ID.getId().equals(roleId)) { |
|
|
|
// Long companyId = userDetail.getCompanyId(); |
|
|
|
// carPlates = vehicleBaseInfoService.getCarPlatesByUseCompanyId(companyId); |
|
|
|
// }else{ |
|
|
|
// carPlates = vehicleBaseInfoService.getCarPlatesByCompanyIds(po.getCompanyIdList()); |
|
|
|
// } |
|
|
|
// log.info("request real carPlates 【{}】:", JSON.toJSONString(carPlates)); |
|
|
|
// if (CollUtil.isEmpty(carPlates)) { |
|
|
|
// return Collections.emptyList(); |
|
|
|
// } |
|
|
|
// Map<String, Object> map = Maps.newConcurrentMap(); |
|
|
|
// map.put(PositionContant.FIELD_CAR_PLATE, carPlates.stream().map(VehicleCompanyPO::getCarPlate).collect(Collectors.joining(","))); |
|
|
|
// map.put(PositionContant.HOST_FEILD, HOST); |
|
|
|
// JSONObject response = restTemplate.getForObject(PositionContant.REAL_GPS_URL, JSONObject.class, map); |
|
|
|
// log.info("request real gps 【{}】:", JSON.toJSONString(response)); |
|
|
|
// if (Objects.isNull(response)) { |
|
|
|
// throw new BizException(ExceptionCode.BAD_REQUEST.getCode(), "实时数据请求失败 网络异常"); |
|
|
|
// } |
|
|
|
// Integer statusCode = response.getInteger("status_code"); |
|
|
|
// if (0 != statusCode) { |
|
|
|
// throw new BizException(ExceptionCode.BAD_REQUEST.getCode(), response.getString("message")); |
|
|
|
// } |
|
|
|
// JSONArray resultJsonArray = response.getJSONArray("result"); |
|
|
|
// if (Objects.isNull(resultJsonArray) || resultJsonArray.size() == 0) { |
|
|
|
// return Collections.emptyList(); |
|
|
|
// } |
|
|
|
// |
|
|
|
// Map<String, VehicleCompanyPO> carMap = carPlates.stream() |
|
|
|
// .filter(w -> Objects.nonNull(w) && Objects.nonNull(w.getCarPlate())) |
|
|
|
// .filter(CodeUtil.distinctByKey(VehicleCompanyPO::getCarPlate)).collect(Collectors.toMap(VehicleCompanyPO::getCarPlate, v -> v)); |
|
|
|
// List<ResRealTimeMonitorVehicleGisListVO> res = resultJsonArray.stream().map(o -> { |
|
|
|
// JSONObject j = JSON.parseObject(JSON.toJSONString(o)); |
|
|
|
// String carPlate = j.getString(PositionContant.FIELD_CAR_PLATE); |
|
|
|
// VehicleCompanyPO vehicleCompany = carMap.get(carPlate); |
|
|
|
// ResRealTimeMonitorVehicleGisListVO vo = new ResRealTimeMonitorVehicleGisListVO(); |
|
|
|
// vo.setCarLongitude(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.LONGITUDE,BigDecimal.valueOf(0L))))); |
|
|
|
// vo.setCarLatitude(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.LATITUDE,BigDecimal.valueOf(0L))))); |
|
|
|
// vo.setCarAltitude(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.ALTITUDE,BigDecimal.valueOf(0L))))); |
|
|
|
// vo.setCarDirection(new BigDecimal(String.valueOf(j.getOrDefault(PositionContant.DIRECTION,BigDecimal.valueOf(0L))))); |
|
|
|
// vo.setCarPlate(carPlate); |
|
|
|
// vo.setPlateColor(j.getString(PositionContant.PLATE_COLOR)); |
|
|
|
// vo.setCompanyId(vehicleCompany.getCompanyId()); |
|
|
|
// vo.setCompanyName(vehicleCompany.getCompanyName()); |
|
|
|
// vo.setCarVelocity(BigDecimal.valueOf(Double.valueOf(String.valueOf(j.getOrDefault(PositionContant.CAR_VELOCITY,BigDecimal.valueOf(0L)))))); |
|
|
|
// vo.setUpdateTime((j.getString(PositionContant.UPDATE_TIME))); |
|
|
|
// vo.setSelfNo(vehicleCompany.getSelfNo()); |
|
|
|
// vo.setStatus(j.getInteger(PositionContant.ONLINE_STATUS)); |
|
|
|
// vo.setMoving(vehicleCompany.getMoving()); |
|
|
|
// vo.setVehicleType(vehicleCompany.getVehicleType()); |
|
|
|
// vo.setVehicleTypeName(vehicleCompany.getVechileTypeName()); |
|
|
|
// vo.setLimitSpeed(VehicleLimitSpeedEnum.getLimitSpeedByCode(vehicleCompany.getVehicleType())); |
|
|
|
// return vo; |
|
|
|
// }).collect(Collectors.toList()); |
|
|
|
// return res; |
|
|
|
} |
|
|
|
|
|
|
|
public List<ResRealTimeMonitorVehicleGisListVO> realTimeMonitorVehicleGisList(DataScreenParam param) { |
|
|
|