运营区车辆列表(仓库外
This commit is contained in:
parent
7a4fe2272b
commit
60c5a12a4b
@ -2,6 +2,7 @@ package com.cdzy.ebikemaintenance.controller;
|
||||
|
||||
import com.cdzy.common.model.JsonResult;
|
||||
import com.cdzy.common.model.PageParam;
|
||||
import com.cdzy.ebikemaintenance.model.dto.response.ResEbikeInfoRegionDto;
|
||||
import com.cdzy.ebikemaintenance.model.pojo.EbikeBikeInfo;
|
||||
import com.cdzy.ebikemaintenance.service.EbikeBikeInfoService;
|
||||
import com.cdzy.ebikemaintenance.service.EbikeSystemInfoService;
|
||||
@ -11,8 +12,11 @@ import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
||||
/**
|
||||
* 运营车辆控制层
|
||||
@ -50,5 +54,14 @@ public class EbikeOperationController {
|
||||
return JsonResult.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运营区id获取运营车辆状态及其位置信息列表
|
||||
* @return 运营车辆列表
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public JsonResult<?> list(@RequestParam("operationRegionId")Long operationRegionId) {
|
||||
List<ResEbikeInfoRegionDto> list = bikeInfoService.getOperationalBikeListWithGpsByRegionId(operationRegionId);
|
||||
return JsonResult.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
package com.cdzy.ebikemaintenance.model.dto.response;
|
||||
|
||||
import com.cdzy.common.model.ResGPSDto;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ResEbikeInfoRegionDto {
|
||||
|
||||
/**
|
||||
* 电动车ID
|
||||
*/
|
||||
private String bikeId;
|
||||
|
||||
/**
|
||||
* 区域ID
|
||||
*/
|
||||
private String reginId;
|
||||
|
||||
/**
|
||||
* ECU(电控单元)ID
|
||||
*/
|
||||
private String ecuId;
|
||||
/**
|
||||
* ECUSN
|
||||
*/
|
||||
private String ecuSn;
|
||||
|
||||
/**
|
||||
* 电池ID
|
||||
*/
|
||||
private String batteryId;
|
||||
|
||||
/**
|
||||
* 头盔ID
|
||||
*/
|
||||
private String helmetId;
|
||||
|
||||
/**
|
||||
* 电动车状态
|
||||
*/
|
||||
private Character state;
|
||||
|
||||
/**
|
||||
* 电动车编码
|
||||
*/
|
||||
private String bikeCode;
|
||||
|
||||
/**
|
||||
* 电动车使用状态
|
||||
*/
|
||||
private Integer usageStatus;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
/**
|
||||
* 是否已删除(逻辑删除标志)
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
private LocalDateTime deletedAt;
|
||||
|
||||
/**
|
||||
* 电动车型号
|
||||
*/
|
||||
private String bikeModel;
|
||||
|
||||
/**
|
||||
* 电动车编号
|
||||
*/
|
||||
private String bikeNumber;
|
||||
|
||||
/**
|
||||
* 是否是新车
|
||||
*/
|
||||
private String isNew;
|
||||
|
||||
/**
|
||||
* 是否在仓库中
|
||||
*/
|
||||
private String isInWarehouse;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double latitude;
|
||||
|
||||
/**
|
||||
* 外接电池电量(该值由控制器提供,若控制器不支持此值为0)
|
||||
*/
|
||||
private Integer soc;
|
||||
|
||||
/**
|
||||
* 是否在运营区(记录最后一次用户停车
|
||||
*/
|
||||
private Boolean inOperation;
|
||||
|
||||
/**
|
||||
* 是否在停车区(记录最后一次用户停车
|
||||
*/
|
||||
private Boolean inParking;
|
||||
|
||||
/**
|
||||
* 最后一次还车时间
|
||||
*/
|
||||
private String latestTimestamp;
|
||||
|
||||
}
|
||||
@ -312,4 +312,11 @@ public interface EbikeBikeInfoService extends IService<EbikeBikeInfo> {
|
||||
* @return 列表
|
||||
*/
|
||||
List<String> checkEcuSn(EcuSnDto ecuSnDto);
|
||||
|
||||
/**
|
||||
* 根据运营区id获取运营车辆状态及其位置信息列表
|
||||
* @param operationRegionId 运营区id
|
||||
* @return 列表
|
||||
*/
|
||||
List<ResEbikeInfoRegionDto> getOperationalBikeListWithGpsByRegionId(Long operationRegionId);
|
||||
}
|
||||
|
||||
@ -47,6 +47,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBatteryInfoTableDef.EBIKE_BATTERY_INFO;
|
||||
@ -1536,6 +1537,38 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
return ebikeBikeInfoMapper.selectListByQueryAs(query, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResEbikeInfoRegionDto> getOperationalBikeListWithGpsByRegionId(Long operationRegionId) {
|
||||
QueryWrapper query = QueryWrapper.create()
|
||||
.select(EBIKE_BIKE_INFO.ALL_COLUMNS,EBIKE_ECU_INFO.ECU_SN)
|
||||
.leftJoin(EBIKE_ECU_INFO).on(EBIKE_BIKE_INFO.ECU_ID.eq(EBIKE_ECU_INFO.ECU_ID))
|
||||
.where(EBIKE_BIKE_INFO.STATE.in(new String[]{"2", "3", "4"}))
|
||||
.where(EBIKE_BIKE_INFO.IS_IN_WAREHOUSE.eq("0"))
|
||||
.where(EBIKE_BIKE_INFO.REGIN_ID.eq(String.valueOf(operationRegionId)));
|
||||
List<ResEbikeInfoRegionDto> list = ebikeBikeInfoMapper.selectListByQueryAs(query, ResEbikeInfoRegionDto.class);
|
||||
if (list == null || list.isEmpty()) {
|
||||
return list;
|
||||
}
|
||||
Map<String, ResEbikeInfoRegionDto> map = list.stream().filter(entity -> entity.getEcuSn() != null).collect(Collectors.toMap(
|
||||
ResEbikeInfoRegionDto::getEcuSn,
|
||||
Function.identity(),
|
||||
(oldVal, newVal) -> newVal // 重复键时覆盖旧值
|
||||
));
|
||||
List<String> strings = map.keySet().stream().toList();
|
||||
List<Object> all = redisUtil.getAll(strings);
|
||||
all.forEach(obj->{
|
||||
ResGPSDto resGPSDto = JSON.toJavaObject(obj, ResGPSDto.class);
|
||||
ResEbikeInfoRegionDto resEbikeInfoRegionDto = map.get(resGPSDto.getEcuSn());
|
||||
resEbikeInfoRegionDto.setLatitude(resGPSDto.getLatitude());
|
||||
resEbikeInfoRegionDto.setLongitude(resGPSDto.getLongitude());
|
||||
resEbikeInfoRegionDto.setSoc(resGPSDto.getSoc());
|
||||
resEbikeInfoRegionDto.setLatestTimestamp(String.valueOf(resGPSDto.getLatestTimestamp()));
|
||||
resEbikeInfoRegionDto.setInOperation(resGPSDto.getInOperation());
|
||||
resEbikeInfoRegionDto.setInParking(resGPSDto.getInParking());
|
||||
});
|
||||
return map.values().stream().toList();
|
||||
}
|
||||
|
||||
private void modifyMaintenanceStatus(String bikeCode) {
|
||||
//是否存在维修中的订单数据
|
||||
int i = ebikeBikeInfoMapper.selectOrderCount(bikeCode);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cdzy.ebikemaintenance.utils;
|
||||
|
||||
import com.cdzy.common.model.ResGPSDto;
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.locationtech.jts.geom.GeometryFactory;
|
||||
import org.locationtech.jts.geom.Polygon;
|
||||
@ -214,6 +215,15 @@ public class RedisUtil {
|
||||
return redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量获取值
|
||||
* @param key 键列表
|
||||
*/
|
||||
public List<Object> getAll(List<String> key) {
|
||||
return redisTemplate.opsForValue().multiGet(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自增操作(增量=1)
|
||||
* @param key 键
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user