bug修复:剩余里程

This commit is contained in:
attiya 2025-07-31 16:59:28 +08:00
parent b7e9f57ce1
commit e1eeae9ddf
2 changed files with 7 additions and 2 deletions

View File

@ -20,11 +20,12 @@ public class RspBikeDto {
private Float mileage;
private String bikeCode;
public RspBikeDto(String ecuSn, Integer soc, Double longitude, Double latitude, String bikeCode) {
public RspBikeDto(String ecuSn, Integer soc, Double longitude, Double latitude, String bikeCode,Float mileage) {
this.ecuSn = ecuSn;
this.soc = soc;
this.longitude = longitude;
this.latitude = latitude;
this.bikeCode = bikeCode;
this.mileage = mileage;
}
}

View File

@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
@ -256,7 +257,10 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, EbikeUs
return objects.stream().map(object -> {
String jsonString = JSONObject.toJSONString(object);
ResGPSDto resGpsDto = JSONObject.parseObject(jsonString, ResGPSDto.class);
return new RspBikeDto(resGpsDto.getEcuSn(), resGpsDto.getSoc(), resGpsDto.getLongitude(), resGpsDto.getLatitude(),map.get(resGpsDto.getEcuSn()).getBikeCode());
BigDecimal number = new BigDecimal(resGpsDto.getSoc());
BigDecimal hundred = new BigDecimal("100");
BigDecimal result = number.divide(hundred, 2, RoundingMode.HALF_UP);
return new RspBikeDto(resGpsDto.getEcuSn(), resGpsDto.getSoc(), resGpsDto.getLongitude(), resGpsDto.getLatitude(),map.get(resGpsDto.getEcuSn()).getBikeCode(),result.floatValue());
}).toList();
}