骑行状态

This commit is contained in:
attiya 2025-06-04 09:50:19 +08:00
parent e09711e844
commit 7a4fe2272b
3 changed files with 56 additions and 9 deletions

View File

@ -135,4 +135,20 @@ public interface MaintenanceFeignClient {
*/ */
@PostMapping("ebikeBikeInfo/checkEcuSn") @PostMapping("ebikeBikeInfo/checkEcuSn")
JsonResult<List<String>> checkEcuSnWithBikeInOperate(@RequestBody EcuSnDto ecuSnDto); JsonResult<List<String>> checkEcuSnWithBikeInOperate(@RequestBody EcuSnDto ecuSnDto);
/**
* 根据车辆id将其设置为骑行中状态
* @param bikeId 车辆id
* @return 结果
*/
@GetMapping("ebikeBikeInfo/riding")
JsonResult<?> riding(String bikeId);
/**
* 根据车辆id将车辆设置为待使用状态
* @param bikeId 车辆id
* @return 结果
*/
@GetMapping("ebikeBikeInfo/used")
JsonResult<?> used(String bikeId);
} }

View File

@ -16,6 +16,7 @@ import com.ebike.feign.model.rsp.EbikeBikeBaseInfo;
import com.ebike.feign.model.rsp.RspBikeInfo; import com.ebike.feign.model.rsp.RspBikeInfo;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -879,4 +880,32 @@ public class EbikeBikeInfoController {
List<String> list = ebikeBikeInfoService.checkEcuSn(ecuSnDto); List<String> list = ebikeBikeInfoService.checkEcuSn(ecuSnDto);
return JsonResult.success(list); return JsonResult.success(list);
}; };
/**
* 根据车辆id将车辆设置为骑行中状态
* @param bikeId 车辆id
* @return 结果
*/
@GetMapping("riding")
JsonResult<?> riding(@RequestParam("bikeId")String bikeId){
UpdateChain.of(EbikeBikeInfo.class)
.set(EbikeBikeInfo::getState, "3")
.where(EbikeBikeInfo::getBikeId).eq(bikeId)
.update();
return JsonResult.success();
};
/**
* 根据车辆id将车辆设置为待使用状态
* @param bikeId 车辆id
* @return 结果
*/
@GetMapping("used")
JsonResult<?> used(@RequestParam("bikeId")String bikeId){
UpdateChain.of(EbikeBikeInfo.class)
.set(EbikeBikeInfo::getState, "2")
.where(EbikeBikeInfo::getBikeId).eq(bikeId)
.update();
return JsonResult.success();
};
} }

View File

@ -94,13 +94,13 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, EbikeUs
throw new RuntimeException("获取车辆信息失败"); throw new RuntimeException("获取车辆信息失败");
} }
FeignEbikeBikeInfoDto bikeInfoDto = jsonResult.getData(); FeignEbikeBikeInfoDto bikeInfoDto = jsonResult.getData();
// TODO:判断车辆状态 // 判断车辆状态
// if (bikeInfoDto.getUsageStatus() == 1) { if ("3".equals(bikeInfoDto.getState())) {
// throw new RuntimeException("车辆使用中"); throw new RuntimeException("车辆使用中");
// } }
// if (bikeInfoDto.getUsageStatus() == 1) { if ("4".equals(bikeInfoDto.getState())) {
// throw new RuntimeException("车辆故障,暂不可用"); throw new RuntimeException("车辆故障,暂不可用");
// } }
FeignEbikeEcuInfo ecuInfo = bikeInfoDto.getEbikeEcuInfo(); FeignEbikeEcuInfo ecuInfo = bikeInfoDto.getEbikeEcuInfo();
JsonResult<FeignEbikeRegionDto> operationResult = operateFeignClient.getOperationById(bikeInfoDto.getReginId()); JsonResult<FeignEbikeRegionDto> operationResult = operateFeignClient.getOperationById(bikeInfoDto.getReginId());
if (operationResult.getCode() != Code.SUCCESS) { if (operationResult.getCode() != Code.SUCCESS) {
@ -127,7 +127,8 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, EbikeUs
//添加借车单量 //添加借车单量
Long siteRegionId = redisUtil.isPointInSiteWithSiteRegionId(resGpsDto.getLongitude(), resGpsDto.getLatitude(), regionDto.getOperationRegionId()); Long siteRegionId = redisUtil.isPointInSiteWithSiteRegionId(resGpsDto.getLongitude(), resGpsDto.getLatitude(), regionDto.getOperationRegionId());
operateFeignClient.addBorrowing(siteRegionId); operateFeignClient.addBorrowing(siteRegionId);
//TODO:改变骑行状态-骑行中 //改变骑行状态-骑行中
maintenanceFeignClient.riding(bikeInfoDto.getBikeId());
userOrders.setBikeId(bikeInfoDto.getBikeId()); userOrders.setBikeId(bikeInfoDto.getBikeId());
String stringBuilder = resGpsDto.getLongitude() + "," + resGpsDto.getLatitude(); String stringBuilder = resGpsDto.getLongitude() + "," + resGpsDto.getLatitude();
userOrders.setRidePoint(stringBuilder); userOrders.setRidePoint(stringBuilder);
@ -183,7 +184,8 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, EbikeUs
//添加还车单量 //添加还车单量
Long siteRegionId = redisUtil.isPointInSiteWithSiteRegionId(resGpsDto.getLongitude(), resGpsDto.getLatitude(), regionDto.getOperationRegionId()); Long siteRegionId = redisUtil.isPointInSiteWithSiteRegionId(resGpsDto.getLongitude(), resGpsDto.getLatitude(), regionDto.getOperationRegionId());
operateFeignClient.addReturn(siteRegionId); operateFeignClient.addReturn(siteRegionId);
//TODO:改变骑行状态-待使用 //改变骑行状态-待使用
maintenanceFeignClient.used(bikeInfoDto.getBikeId());
return userOrders.getOrderId(); return userOrders.getOrderId();
} }