首页车辆列表、监听代码变动
This commit is contained in:
parent
93e9992041
commit
08d6256fd5
@ -39,24 +39,22 @@ public class SafeOrderExpirationListener {
|
||||
*/
|
||||
public void handleOrderExpiration(String expiredKey) {
|
||||
// 验证是否为工单键
|
||||
if (!expiredKey.startsWith(RedisUtil.BIKE_DISPATCH_ORDER_PREFIX)) {
|
||||
return;
|
||||
if (expiredKey.startsWith(RedisUtil.BIKE_DISPATCH_ORDER_PREFIX)) {
|
||||
// 提取订单ID
|
||||
String orderId = extractOrderIdFromKey(expiredKey);
|
||||
if (orderId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("实例 {} 接收到工单过期事件: orderId={}",
|
||||
instanceManager.getInstanceId(), orderId);
|
||||
|
||||
// 异步处理,避免阻塞监听线程
|
||||
CompletableFuture.runAsync(() -> processExpiredOrderSafely(orderId)).exceptionally(e -> {
|
||||
log.error("处理过期工单异常: orderId={}", orderId, e);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// 提取订单ID
|
||||
String orderId = extractOrderIdFromKey(expiredKey);
|
||||
if (orderId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("实例 {} 接收到工单过期事件: orderId={}",
|
||||
instanceManager.getInstanceId(), orderId);
|
||||
|
||||
// 异步处理,避免阻塞监听线程
|
||||
CompletableFuture.runAsync(() -> processExpiredOrderSafely(orderId)).exceptionally(e -> {
|
||||
log.error("处理过期工单异常: orderId={}", orderId, e);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -6,6 +6,7 @@ import com.cdzy.common.model.request.PageParam;
|
||||
import com.cdzy.common.model.response.JsonResult;
|
||||
import com.cdzy.operations.enums.BikeOrderHandleState;
|
||||
import com.cdzy.operations.model.dto.EbikeBikeOrderInfoDto;
|
||||
import com.cdzy.operations.model.dto.EbikeOrderBikeListDto;
|
||||
import com.cdzy.operations.model.dto.EbikeBikeOrderPageDto;
|
||||
import com.cdzy.operations.model.dto.EbikeOrderBikeInfoDto;
|
||||
import com.cdzy.operations.model.vo.EbikeBatteryChangeVo;
|
||||
@ -22,6 +23,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
||||
@ -209,6 +211,17 @@ public class EbikeBikeOrderController {
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆列表(工单用)
|
||||
*
|
||||
* @return 操作结果
|
||||
*/
|
||||
@GetMapping("bikeList")
|
||||
public JsonResult<List<EbikeOrderBikeListDto>> bikeList(@RequestParam("regionId") Long regionId) {
|
||||
List<EbikeOrderBikeListDto> list = ebikeBikeOrderService.bikeList(regionId);
|
||||
return JsonResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆详情(工单用)
|
||||
*
|
||||
|
||||
@ -0,0 +1,62 @@
|
||||
package com.cdzy.operations.model.dto;
|
||||
|
||||
import com.cdzy.operations.handler.PGpointDeserializer;
|
||||
import com.cdzy.operations.handler.PGpointSerializer;
|
||||
import com.cdzy.operations.handler.PGpointTypeHandler;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.postgresql.geometric.PGpoint;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 工单信息 实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-11-24
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EbikeOrderBikeListDto implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 车辆编号
|
||||
*/
|
||||
private String bikeCode;
|
||||
|
||||
/**
|
||||
* 中控编号
|
||||
*/
|
||||
private String ecuSn;
|
||||
|
||||
/**
|
||||
* 定位
|
||||
*/
|
||||
@Column(typeHandler = PGpointTypeHandler.class)
|
||||
@JsonSerialize(using = PGpointSerializer.class)
|
||||
@JsonDeserialize(using = PGpointDeserializer.class)
|
||||
private PGpoint location;
|
||||
|
||||
/**
|
||||
* 车辆使用状态
|
||||
*/
|
||||
private Integer usageStatus;
|
||||
|
||||
|
||||
/**
|
||||
* 外接电池电量(该值由控制器提供,若控制器不支持此值为0)
|
||||
*/
|
||||
private Integer soc;
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.cdzy.operations.service;
|
||||
|
||||
import com.cdzy.operations.model.dto.EbikeBikeOrderInfoDto;
|
||||
import com.cdzy.operations.model.dto.EbikeOrderBikeListDto;
|
||||
import com.cdzy.operations.model.dto.EbikeOrderBikeInfoDto;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeOrder;
|
||||
import com.cdzy.operations.model.vo.EbikeBatteryChangeVo;
|
||||
@ -10,6 +11,8 @@ import com.cdzy.operations.model.vo.InspectionSwapOrderVo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工单信息 服务层。
|
||||
*
|
||||
@ -94,4 +97,11 @@ public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
|
||||
* @return 详情
|
||||
*/
|
||||
EbikeOrderBikeInfoDto bikeInfo(String bikeCode);
|
||||
|
||||
/**
|
||||
* 获取车辆列表
|
||||
* @param regionId 运营区ID
|
||||
* @return 列表
|
||||
*/
|
||||
List<EbikeOrderBikeListDto> bikeList(Long regionId);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.cdzy.common.model.dto.ResGPSDto;
|
||||
import com.cdzy.operations.enums.*;
|
||||
import com.cdzy.operations.mapper.*;
|
||||
import com.cdzy.operations.model.dto.EbikeBikeOrderInfoDto;
|
||||
import com.cdzy.operations.model.dto.EbikeOrderBikeListDto;
|
||||
import com.cdzy.operations.model.dto.EbikeOrderBikeInfoDto;
|
||||
import com.cdzy.operations.model.entity.*;
|
||||
import com.cdzy.operations.model.vo.EbikeBatteryChangeVo;
|
||||
@ -29,10 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeBatteryInfoTableDef.EBIKE_BATTERY_INFO;
|
||||
import static com.cdzy.operations.model.entity.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
||||
@ -412,6 +410,25 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
return bikeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EbikeOrderBikeListDto> bikeList(Long regionId) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(EBIKE_BIKE_INFO.BIKE_CODE,EBIKE_BIKE_INFO.LOCATION,EBIKE_BIKE_INFO.USAGE_STATUS,EBIKE_ECU_INFO.ECU_SN)
|
||||
.where(EBIKE_BIKE_INFO.REGION_ID.eq(regionId))
|
||||
.where(EBIKE_BIKE_INFO.STATUS.eq(BikeStatus.LAUNCH))
|
||||
.leftJoin(EBIKE_ECU_INFO).on(EBIKE_ECU_INFO.ECU_ID.eq(EBIKE_BIKE_INFO.ECU_ID));
|
||||
List<EbikeOrderBikeListDto> list = bikeInfoMapper.selectListByQueryAs(queryWrapper, EbikeOrderBikeListDto.class);
|
||||
List<String> snList = list.stream().map(EbikeOrderBikeListDto::getEcuSn).toList();
|
||||
Map<String, Object> objectMap = redisUtil.batchGetEcuWithMap(snList);
|
||||
list.forEach(e->{
|
||||
ResGPSDto resGPSDto = (ResGPSDto)objectMap.get(e.getEcuSn());
|
||||
if (resGPSDto != null){
|
||||
e.setSoc(resGPSDto.getSoc());
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
EbikeBikeInfo checkBikeCode(String bikeCode) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user