201 lines
6.1 KiB
Java
Raw Normal View History

package com.cdzy.operations.controller;
2025-12-10 16:54:23 +08:00
import com.cdzy.common.model.dto.ResGPSDto;
2025-11-05 15:14:40 +08:00
import com.cdzy.common.model.request.PageParam;
2025-10-21 09:36:31 +08:00
import com.cdzy.common.model.response.JsonResult;
2025-11-05 16:34:54 +08:00
import com.cdzy.operations.model.dto.EbikeBikeInfoDto;
2025-11-07 17:04:22 +08:00
import com.cdzy.operations.model.dto.EbikeDto;
2025-11-10 16:51:47 +08:00
import com.cdzy.operations.model.dto.EbikeUserBikeInfo;
2025-11-11 17:31:14 +08:00
import com.cdzy.operations.model.dto.EbikeUserLockDto;
2025-12-18 15:50:14 +08:00
import com.cdzy.operations.model.entity.EbikeBikeInfo;
import com.cdzy.operations.model.vo.EbikeBatchLaunchVo;
import com.cdzy.operations.model.vo.EbikeBatchUnLaunchVo;
import com.cdzy.operations.model.vo.EbikeBikeBindVo;
import com.cdzy.operations.model.vo.EbikeBikeRadiusVo;
2025-10-21 09:36:31 +08:00
import com.cdzy.operations.service.EbikeBikeInfoService;
2025-12-18 15:38:40 +08:00
import com.ebike.feign.model.vo.EbikeLockVo;
2025-11-05 15:14:40 +08:00
import com.mybatisflex.core.paginate.Page;
2025-12-18 15:50:14 +08:00
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
2025-10-21 09:36:31 +08:00
import jakarta.annotation.Resource;
2025-12-18 15:50:14 +08:00
import lombok.extern.slf4j.Slf4j;
import org.postgresql.geometric.PGpoint;
2025-10-21 09:36:31 +08:00
import org.springframework.validation.annotation.Validated;
2025-11-05 15:14:40 +08:00
import org.springframework.web.bind.annotation.*;
2025-11-07 17:04:22 +08:00
import java.util.List;
2025-12-18 15:50:14 +08:00
import static com.cdzy.operations.model.entity.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
import static com.cdzy.operations.model.entity.table.EbikeEcuInfoTableDef.EBIKE_ECU_INFO;
/**
2025-10-21 09:36:31 +08:00
* 车辆基本信息 控制层
*
* @author attiya
* @since 2025-10-17
*/
2025-12-18 15:50:14 +08:00
@Slf4j
2025-10-21 09:36:31 +08:00
@Validated
@RestController
@RequestMapping("/ebikeBikeInfo")
public class EbikeBikeInfoController {
2025-10-21 09:36:31 +08:00
@Resource
private EbikeBikeInfoService ebikeBikeInfoService;
2025-10-21 09:51:51 +08:00
/**
* 整车绑定
2025-11-05 15:14:40 +08:00
*
2025-10-21 09:51:51 +08:00
* @param bindVo 绑定信息
* @return 绑定结果
*/
2025-10-21 09:36:31 +08:00
@PostMapping("bind")
2025-10-21 09:51:07 +08:00
public JsonResult<?> bind(@Validated @RequestBody EbikeBikeBindVo bindVo) {
ebikeBikeInfoService.bind(bindVo);
2025-10-21 09:36:31 +08:00
return JsonResult.success();
}
2025-11-05 15:14:40 +08:00
/**
* 未上架车辆分页查询
*
* @param pageParam 分页参数
* @return 结果
*/
@GetMapping("unLaunchPage")
public JsonResult<?> unLaunchPage(PageParam pageParam) {
2025-11-05 16:34:54 +08:00
Page<EbikeBikeInfoDto> page = ebikeBikeInfoService.unLaunchPage(pageParam);
2025-11-05 15:14:40 +08:00
return JsonResult.success(page);
}
/**
* 上架车辆分页查询
*
* @param pageParam 分页参数
* @return 结果
*/
@GetMapping("launchPage")
public JsonResult<?> launchPage(PageParam pageParam) {
2025-11-05 16:34:54 +08:00
Page<EbikeBikeInfoDto> page = ebikeBikeInfoService.launchPage(pageParam);
2025-11-05 15:14:40 +08:00
return JsonResult.success(page);
}
/**
* 批量上架
*
* @return 结果
*/
@PostMapping("batchLaunch")
public JsonResult<?> batchLaunch(@Validated @RequestBody EbikeBatchLaunchVo launchVo) {
ebikeBikeInfoService.batchLaunch(launchVo);
return JsonResult.success();
}
/**
* 批量下架
*
* @return 结果
*/
@PostMapping("batchUnLaunch")
public JsonResult<?> batchUnLaunch(@Validated @RequestBody EbikeBatchUnLaunchVo launchVo) {
ebikeBikeInfoService.batchUnLaunch(launchVo);
return JsonResult.success();
}
2025-11-07 17:04:22 +08:00
/**
* 用户半径范围内车辆
*
* @return 结果
*/
@PostMapping("/api/userRadiusList")
public JsonResult<?> userRadiusList(@Validated @RequestBody EbikeBikeRadiusVo radiusVo) {
List<EbikeDto> list = ebikeBikeInfoService.userRadiusList(radiusVo);
return JsonResult.success(list);
}
2025-11-10 16:25:04 +08:00
/**
* 用户开锁
*
* @return 结果
*/
@GetMapping("/api/openLock")
public JsonResult<?> openLock(@RequestParam("bikeCode") String bikeCode) {
ebikeBikeInfoService.openLock(bikeCode);
return JsonResult.success();
}
2025-11-10 16:51:47 +08:00
2025-11-11 15:30:58 +08:00
/**
* 用户关锁
*
* @return 结果
*/
2025-12-18 15:38:40 +08:00
@PostMapping("/api/lock")
public JsonResult<?> lock(@RequestBody @Validated EbikeLockVo lockVo) {
EbikeUserLockDto result = ebikeBikeInfoService.lock(lockVo);
2025-11-11 17:31:14 +08:00
return JsonResult.success(result);
2025-11-11 15:30:58 +08:00
}
2025-11-10 16:51:47 +08:00
/**
* 用户获取车辆详情
*
* @return 结果
*/
@GetMapping("/api/bikeInfo")
public JsonResult<?> bikeInfo(@RequestParam("bikeCode") String bikeCode) {
EbikeUserBikeInfo info = ebikeBikeInfoService.bikeInfo(bikeCode);
return JsonResult.success(info);
}
2025-12-10 10:24:59 +08:00
/**
* 中控换绑
*
* @param bikeCode 车辆编号
* @param ecuSn 中控编号
* @return 结果
*/
@GetMapping("/changeEcu")
public JsonResult<?> changeEcu(@RequestParam("bikeCode") String bikeCode, @RequestParam("ecuSn") String ecuSn) {
ebikeBikeInfoService.changeEcu(bikeCode, ecuSn);
return JsonResult.success();
}
2025-12-10 16:54:23 +08:00
/**
* 根据中控编号获取设备信息
*
2025-12-18 15:50:14 +08:00
* @param ecuSn 中控编号
2025-12-10 16:54:23 +08:00
* @return 结果
*/
@GetMapping("/getEcuMsg")
public JsonResult<ResGPSDto> getEcuMsg(@RequestParam("ecuSn") String ecuSn) {
ResGPSDto ecuMsg = ebikeBikeInfoService.getEcuMsg(ecuSn);
return JsonResult.success(ecuMsg);
}
2025-12-18 15:50:14 +08:00
/**
* 保存车辆最新位置
*
* @param ecuSn 中控编号
* @return 结果
*/
@GetMapping("/changeLocation")
public JsonResult<?> changeLocation(@RequestParam("ecuSn") String ecuSn, @RequestParam("longitude") Double longitude,@RequestParam("latitude") Double latitude) {
QueryWrapper queryWrapper = QueryWrapper.create()
.leftJoin(EBIKE_ECU_INFO).on(EBIKE_ECU_INFO.ECU_ID.eq(EBIKE_BIKE_INFO.ECU_ID))
.where(EBIKE_ECU_INFO.ECU_SN.eq(ecuSn));
EbikeBikeInfo bikeInfo = ebikeBikeInfoService.getOne(queryWrapper);
if (bikeInfo == null) {
log.warn("中控未绑定车辆或不存在,SN={}", ecuSn);
return JsonResult.failed();
}else {
UpdateChain.of(EbikeBikeInfo.class)
.set(EBIKE_BIKE_INFO.LOCATION,new PGpoint(longitude,latitude))
.where(EBIKE_BIKE_INFO.BIKE_INFO_ID.eq(bikeInfo.getBikeInfoId()))
.update();
log.info("更新车辆位置成功,SN={}", ecuSn);
2025-12-18 15:50:14 +08:00
}
return JsonResult.success();
}
}