运营区车辆
This commit is contained in:
parent
e41febdc35
commit
57f2a1804f
@ -99,4 +99,12 @@ public interface MaintenanceFeignClient {
|
||||
*/
|
||||
@GetMapping("ebikeBikeInfo/updateVehicleStatus")
|
||||
JsonResult<?> updateVehicleStatus(@RequestBody ReqVehicleStatusUpdateDto request);
|
||||
|
||||
/**
|
||||
* 根据运营区id获取所有车辆
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("ebikeBikeInfo/getVehicleDetailsByRegionId")
|
||||
JsonResult<List<RspBikeInfo>> getVehicleDetailsByRegionId(@RequestParam(name = "regionId") String regionId);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.cdzy.ebikeoperate.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cdzy.common.enums.Code;
|
||||
import com.cdzy.common.model.JsonResult;
|
||||
import com.cdzy.common.model.PageParam;
|
||||
import com.cdzy.common.model.ResGPSDto;
|
||||
@ -15,7 +15,10 @@ import com.cdzy.ebikeoperate.model.dto.request.ReqAuthorizeOperationDto;
|
||||
import com.cdzy.ebikeoperate.model.dto.request.ReqBatchRegionDto;
|
||||
import com.cdzy.ebikeoperate.model.dto.request.ReqEbikeOperationRegionDto;
|
||||
import com.cdzy.ebikeoperate.model.dto.request.ReqEbikePointDto;
|
||||
import com.cdzy.ebikeoperate.model.dto.response.*;
|
||||
import com.cdzy.ebikeoperate.model.dto.response.EbikeOperationRegionPageDto;
|
||||
import com.cdzy.ebikeoperate.model.dto.response.ResEbikeOperationRegionDto;
|
||||
import com.cdzy.ebikeoperate.model.dto.response.ResOperationRegionInfo;
|
||||
import com.cdzy.ebikeoperate.model.dto.response.ZoneDto;
|
||||
import com.cdzy.ebikeoperate.model.pojo.EbikeAdministrationZone;
|
||||
import com.cdzy.ebikeoperate.model.pojo.EbikeOperationRegion;
|
||||
import com.cdzy.ebikeoperate.model.pojo.EbikePoint;
|
||||
@ -24,7 +27,6 @@ import com.cdzy.ebikeoperate.service.EbikeOperationRegionService;
|
||||
import com.cdzy.ebikeoperate.utils.RedisUtil;
|
||||
import com.ebike.feign.clients.MaintenanceFeignClient;
|
||||
import com.ebike.feign.clients.StaffFeignClient;
|
||||
import com.ebike.feign.model.res.ReqEcuSnDto;
|
||||
import com.ebike.feign.model.rsp.RspBikeInfo;
|
||||
import com.ebike.feign.model.rsp.StaffFeign;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
@ -34,7 +36,6 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -95,7 +96,7 @@ public class EbikeOperationRegionServiceImpl extends ServiceImpl<EbikeOperationR
|
||||
@Override
|
||||
public Page<EbikeOperationRegionPageDto> pageOperationRegion(PageParam pageParam, String simpleName, String regionName, Integer inOperation) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(EBIKE_OPERATION_REGION.ALL_COLUMNS,EBIKE_ADMINISTRATION_ZONE.NAME.as(ResOperationRegionInfo::getZoneName),EBIKE_REGION_LEVEL.LEVEL_NAME)
|
||||
.select(EBIKE_OPERATION_REGION.ALL_COLUMNS, EBIKE_ADMINISTRATION_ZONE.NAME.as(ResOperationRegionInfo::getZoneName), EBIKE_REGION_LEVEL.LEVEL_NAME)
|
||||
.leftJoin(EBIKE_REGION_LEVEL).on(EBIKE_REGION_LEVEL.LEVEL_VALUE.eq(EBIKE_OPERATION_REGION.OPERATION_LEVEL))
|
||||
.leftJoin(EBIKE_ADMINISTRATION_ZONE).on(EBIKE_ADMINISTRATION_ZONE.ID.eq(EBIKE_OPERATION_REGION.ZONE_ID))
|
||||
.where(EBIKE_REGION_LEVEL.LEVEL_TYPE.eq(RegionLevelType.OPERATION))
|
||||
@ -108,7 +109,7 @@ public class EbikeOperationRegionServiceImpl extends ServiceImpl<EbikeOperationR
|
||||
@Override
|
||||
public ResOperationRegionInfo operationRegionInfo(Long regionId) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(EBIKE_OPERATION_REGION.ALL_COLUMNS,EBIKE_ADMINISTRATION_ZONE.NAME.as(ResOperationRegionInfo::getZoneName),EBIKE_REGION_LEVEL.LEVEL_NAME)
|
||||
.select(EBIKE_OPERATION_REGION.ALL_COLUMNS, EBIKE_ADMINISTRATION_ZONE.NAME.as(ResOperationRegionInfo::getZoneName), EBIKE_REGION_LEVEL.LEVEL_NAME)
|
||||
.leftJoin(EBIKE_ADMINISTRATION_ZONE).on(EBIKE_ADMINISTRATION_ZONE.ID.eq(EBIKE_OPERATION_REGION.ZONE_ID))
|
||||
.leftJoin(EBIKE_REGION_LEVEL).on(EBIKE_REGION_LEVEL.LEVEL_VALUE.eq(EBIKE_OPERATION_REGION.OPERATION_LEVEL))
|
||||
.where(EBIKE_OPERATION_REGION.OPERATION_REGION_ID.eq(regionId))
|
||||
@ -135,7 +136,7 @@ public class EbikeOperationRegionServiceImpl extends ServiceImpl<EbikeOperationR
|
||||
public void delOperation(ReqBatchRegionDto delRegionDto) {
|
||||
List<EbikeOperationRegion> ebikeOperationRegions = this.mapper.selectListByIds(delRegionDto.getIds());
|
||||
ebikeOperationRegions.forEach(region ->
|
||||
delPoints(region.getOrgId(), region.getOperationRegionId())
|
||||
delPoints(region.getOrgId(), region.getOperationRegionId())
|
||||
);
|
||||
this.mapper.deleteBatchByIds(delRegionDto.getIds());
|
||||
}
|
||||
@ -182,35 +183,23 @@ public class EbikeOperationRegionServiceImpl extends ServiceImpl<EbikeOperationR
|
||||
|
||||
@Override
|
||||
public List<RspBikeInfo> getOperationBike(String regionId) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_POINT.REGION_ID.eq(regionId));
|
||||
List<EbikePoint> ebikePoints = pointMapper.selectListByQuery(queryWrapper);
|
||||
List<Point> list = ebikePoints.stream().filter(Objects::nonNull).map(point -> new Point(point.getLongitude(), point.getLatitude())).toList();
|
||||
List<RedisPoint> redisPoints = redisUtil.searchBikeByPolygon(list);
|
||||
if (redisPoints == null || redisPoints.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
Map<String, RedisPoint> map = new HashMap<>();
|
||||
for (RedisPoint redisPoint : redisPoints) {
|
||||
map.put(redisPoint.getMember(), redisPoint);
|
||||
}
|
||||
List<String> strings = redisPoints.stream().map(RedisPoint::getMember).toList();
|
||||
ReqEcuSnDto ecuSnDto = new ReqEcuSnDto(strings);
|
||||
JsonResult<List<RspBikeInfo>> result = maintenanceFeignClient.getBikeByEcuSn(ecuSnDto);
|
||||
if (result.getCode() != 200) {
|
||||
JsonResult<List<RspBikeInfo>> bikeInfoJsonResult = maintenanceFeignClient.getVehicleDetailsByRegionId(regionId);
|
||||
if (bikeInfoJsonResult.getCode() != Code.SUCCESS) {
|
||||
throw new RuntimeException("获取车辆信息失败");
|
||||
}
|
||||
// List<String> ecuSns = new ArrayList<>();
|
||||
// List<Object> objects = redisUtil.multiGet(ecuSns);
|
||||
// List<ResGPSDto> resGPSDtos = objects.stream().map(object -> {
|
||||
// return (ResGPSDto) object;
|
||||
// }).toList();
|
||||
List<RspBikeInfo> bikeInfos = bikeInfoJsonResult.getData();
|
||||
List<String> ecuSns = new ArrayList<>();
|
||||
List<Object> objects = redisUtil.multiGet(ecuSns);
|
||||
Map<String, ResGPSDto> map = new HashMap<>();
|
||||
objects.forEach(object -> {
|
||||
ResGPSDto gpsDto = (ResGPSDto) object;
|
||||
map.put(gpsDto.getEcuSn(), gpsDto);
|
||||
});
|
||||
|
||||
List<RspBikeInfo> bikeInfos = result.getData();
|
||||
bikeInfos.forEach(rspBikeInfo -> {
|
||||
RedisPoint redisPoint = map.get(rspBikeInfo.getEcuSn());
|
||||
rspBikeInfo.setLongitude(redisPoint.getPoint().getX());
|
||||
rspBikeInfo.setLatitude(redisPoint.getPoint().getY());
|
||||
ResGPSDto gpsDto = map.get(rspBikeInfo.getEcuSn());
|
||||
rspBikeInfo.setLongitude(gpsDto.getLongitude());
|
||||
rspBikeInfo.setLatitude(gpsDto.getLatitude());
|
||||
});
|
||||
return bikeInfos;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user