设备上线状态获取
This commit is contained in:
parent
49259960d9
commit
7aa6e4b03b
@ -18,7 +18,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -285,10 +284,9 @@ public class EbikeBikeOrderController {
|
||||
* @param acceptOrder 是否自己接单
|
||||
* @param orderType 工单类型
|
||||
* @return 操作结果
|
||||
* @throws IOException 异常
|
||||
*/
|
||||
@GetMapping("bikeList")
|
||||
public JsonResult<List<EbikeOrderBikeListDto>> bikeList(@RequestParam("regionId") Long regionId,String bikeCode,Integer bikeStatus,Boolean acceptOrder,Integer orderType) throws IOException {
|
||||
public JsonResult<List<EbikeOrderBikeListDto>> bikeList(@RequestParam("regionId") Long regionId,String bikeCode,Integer bikeStatus,Boolean acceptOrder,Integer orderType) {
|
||||
List<EbikeOrderBikeListDto> list = ebikeBikeOrderService.bikeList(regionId,bikeCode,bikeStatus,acceptOrder,orderType);
|
||||
return JsonResult.success(list);
|
||||
}
|
||||
@ -299,7 +297,7 @@ public class EbikeBikeOrderController {
|
||||
* @return 操作结果
|
||||
*/
|
||||
@GetMapping("bikeInfo")
|
||||
public JsonResult<EbikeOrderBikeInfoDto> bikeInfo(@RequestParam("bikeCode") String bikeCode,Integer orderType) throws IOException {
|
||||
public JsonResult<EbikeOrderBikeInfoDto> bikeInfo(@RequestParam("bikeCode") String bikeCode,Integer orderType){
|
||||
EbikeOrderBikeInfoDto info = ebikeBikeOrderService.bikeInfo(bikeCode,orderType);
|
||||
return JsonResult.success(info);
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ import com.mybatisflex.core.service.IService;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -95,14 +94,14 @@ public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
|
||||
* @param bikeCode 车辆编号
|
||||
* @return 详情
|
||||
*/
|
||||
EbikeOrderBikeInfoDto bikeInfo(String bikeCode,Integer orderType) throws IOException;
|
||||
EbikeOrderBikeInfoDto bikeInfo(String bikeCode,Integer orderType) ;
|
||||
|
||||
/**
|
||||
* 获取车辆列表
|
||||
* @param regionId 运营区ID
|
||||
* @return 列表
|
||||
*/
|
||||
List<EbikeOrderBikeListDto> bikeList(Long regionId,String bikeCode,Integer bikeStatus,Boolean acceptOrder,Integer orderType) throws IOException;
|
||||
List<EbikeOrderBikeListDto> bikeList(Long regionId,String bikeCode,Integer bikeStatus,Boolean acceptOrder,Integer orderType);
|
||||
|
||||
/**
|
||||
* 完成调度
|
||||
|
||||
@ -12,12 +12,9 @@ import com.cdzy.operations.model.dto.*;
|
||||
import com.cdzy.operations.model.entity.*;
|
||||
import com.cdzy.operations.model.vo.*;
|
||||
import com.cdzy.operations.service.EbikeBikeOrderService;
|
||||
import com.cdzy.operations.utils.EmqxApiClient;
|
||||
import com.cdzy.operations.utils.GeoCodingUtil;
|
||||
import com.cdzy.operations.utils.MinioUtil;
|
||||
import com.cdzy.operations.utils.RedisUtil;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator;
|
||||
import com.mybatisflex.core.query.QueryMethods;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@ -31,7 +28,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
@ -485,9 +481,17 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public EbikeOrderBikeInfoDto bikeInfo(String bikeCode, Integer orderType) throws IOException {
|
||||
public EbikeOrderBikeInfoDto bikeInfo(String bikeCode, Integer orderType){
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(EBIKE_BIKE_INFO.BIKE_INFO_ID, EBIKE_BIKE_INFO.BATTERY_ID, EBIKE_BIKE_INFO.LOCATION, EBIKE_BIKE_INFO.USAGE_STATUS, EBIKE_BIKE_INFO.LATEST_CYCLING_TIME, EBIKE_ECU_INFO.ECU_SN)
|
||||
.select(
|
||||
EBIKE_BIKE_INFO.BIKE_INFO_ID,
|
||||
EBIKE_BIKE_INFO.BATTERY_ID,
|
||||
EBIKE_BIKE_INFO.LOCATION,
|
||||
EBIKE_BIKE_INFO.USAGE_STATUS,
|
||||
EBIKE_BIKE_INFO.LATEST_CYCLING_TIME,
|
||||
EBIKE_ECU_INFO.ECU_SN,
|
||||
EBIKE_ECU_INFO.IS_ONLINE.as(EbikeOrderBikeInfoDto::getOnline)
|
||||
)
|
||||
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode))
|
||||
.leftJoin(EBIKE_ECU_INFO).on(EBIKE_ECU_INFO.ECU_ID.eq(EBIKE_BIKE_INFO.ECU_ID));
|
||||
if (orderType != null) {
|
||||
@ -535,14 +539,12 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
bikeInfo.setSpeed(resGPSDto.getSpeed());
|
||||
bikeInfo.setLatestTime(resGPSDto.getLatestTime());
|
||||
String locationToAddress = geoCodingUtil.getLocationToAddress(resGPSDto.getLongitude(), resGPSDto.getLatitude());
|
||||
boolean online = EmqxApiClient.isClientOnline(bikeInfo.getEcuSn());
|
||||
bikeInfo.setOnline(online);
|
||||
bikeInfo.setChineseLocation(locationToAddress);
|
||||
return bikeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EbikeOrderBikeListDto> bikeList(Long regionId, String bikeCode, Integer bikeStatus, Boolean acceptOrder, Integer orderType) throws IOException {
|
||||
public List<EbikeOrderBikeListDto> bikeList(Long regionId, String bikeCode, Integer bikeStatus, Boolean acceptOrder, Integer orderType) {
|
||||
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(
|
||||
@ -550,6 +552,7 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
EBIKE_BIKE_INFO.LOCATION,
|
||||
EBIKE_BIKE_INFO.USAGE_STATUS,
|
||||
EBIKE_ECU_INFO.ECU_SN,
|
||||
EBIKE_ECU_INFO.IS_ONLINE.as(EbikeOrderBikeListDto::getOnline),
|
||||
// 判断是否有巡检工单
|
||||
QueryMethods.case_()
|
||||
.when(QueryMethods.exists(
|
||||
@ -657,18 +660,12 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
List<EbikeOrderBikeListDto> list = bikeInfoMapper.selectListByQueryAs(queryWrapper, EbikeOrderBikeListDto.class);
|
||||
List<String> snList = list.stream().map(EbikeOrderBikeListDto::getEcuSn).toList();
|
||||
Map<String, Object> objectMap = redisUtil.batchGetEcuWithMap(snList);
|
||||
ObjectNode clientsOnline = EmqxApiClient.isClientsOnline(snList);
|
||||
//TODO:优化电量的批量获取
|
||||
list.forEach(e -> {
|
||||
ResGPSDto resGPSDto = (ResGPSDto) objectMap.get(e.getEcuSn());
|
||||
if (resGPSDto != null) {
|
||||
e.setSoc(resGPSDto.getSoc());
|
||||
}
|
||||
JsonNode jsonNode = clientsOnline.get(e.getEcuSn());
|
||||
if (jsonNode != null) {
|
||||
e.setOnline(Boolean.TRUE);
|
||||
} else {
|
||||
e.setOnline(Boolean.FALSE);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user