用户开锁
This commit is contained in:
parent
fb118431ac
commit
4764f9aaa0
@ -99,4 +99,15 @@ public class EbikeBikeInfoController {
|
|||||||
List<EbikeDto> list = ebikeBikeInfoService.userRadiusList(radiusVo);
|
List<EbikeDto> list = ebikeBikeInfoService.userRadiusList(radiusVo);
|
||||||
return JsonResult.success(list);
|
return JsonResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户开锁
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/api/openLock")
|
||||||
|
public JsonResult<?> openLock(@RequestParam("bikeCode") String bikeCode) {
|
||||||
|
ebikeBikeInfoService.openLock(bikeCode);
|
||||||
|
return JsonResult.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,4 +11,10 @@ import com.cdzy.operations.model.entity.EbikeRegion;
|
|||||||
*/
|
*/
|
||||||
public interface EbikeRegionMapper extends BaseMapper<EbikeRegion> {
|
public interface EbikeRegionMapper extends BaseMapper<EbikeRegion> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查车辆是否在运营区内
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
boolean checkBikeInRegion(String bikeCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,4 +67,10 @@ public interface EbikeBikeInfoService extends IService<EbikeBikeInfo> {
|
|||||||
* @return 车辆列表
|
* @return 车辆列表
|
||||||
*/
|
*/
|
||||||
List<EbikeDto> userRadiusList(EbikeBikeRadiusVo radiusVo);
|
List<EbikeDto> userRadiusList(EbikeBikeRadiusVo radiusVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户开锁
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
*/
|
||||||
|
void openLock(String bikeCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,4 +116,12 @@ public interface EbikeEcuInfoService extends IService<EbikeEcuInfo> {
|
|||||||
* @return 执行结果
|
* @return 执行结果
|
||||||
*/
|
*/
|
||||||
boolean executeCommand(String ecuSn, String bikeCode, String commandCode);
|
boolean executeCommand(String ecuSn, String bikeCode, String commandCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据车辆编号获取中控信息
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
* @return 中控信息
|
||||||
|
*/
|
||||||
|
EbikeEcuInfo getEcu(String bikeCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -197,7 +197,7 @@ public class CommandServiceImpl implements CommandService {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
pendingRequests.remove(taskId);
|
pendingRequests.remove(taskId);
|
||||||
log.info("任务提交失败: {}", e.getMessage());
|
log.info("任务提交失败: {}", e.getMessage());
|
||||||
return false;
|
throw new EbikeException("超时未响应");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.cdzy.operations.model.dto.EbikeDto;
|
|||||||
import com.cdzy.operations.model.entity.*;
|
import com.cdzy.operations.model.entity.*;
|
||||||
import com.cdzy.operations.model.vo.*;
|
import com.cdzy.operations.model.vo.*;
|
||||||
import com.cdzy.operations.service.EbikeBikeInfoService;
|
import com.cdzy.operations.service.EbikeBikeInfoService;
|
||||||
|
import com.cdzy.operations.service.EbikeEcuInfoService;
|
||||||
import com.cdzy.operations.service.EbikeInventoryRecordService;
|
import com.cdzy.operations.service.EbikeInventoryRecordService;
|
||||||
import com.cdzy.operations.service.EbikeInventoryService;
|
import com.cdzy.operations.service.EbikeInventoryService;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
@ -59,6 +60,9 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
|||||||
@Resource
|
@Resource
|
||||||
EbikeInventoryRecordService recordService;
|
EbikeInventoryRecordService recordService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EbikeEcuInfoService ebikeEcuInfoService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void bind(EbikeBikeBindVo bindVo) {
|
public void bind(EbikeBikeBindVo bindVo) {
|
||||||
@ -246,4 +250,38 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
|||||||
return this.mapper.selectRadiusGeometryWithOrder(radiusVo.getPoint(), radiusVo.getRadius() * 1000);
|
return this.mapper.selectRadiusGeometryWithOrder(radiusVo.getPoint(), radiusVo.getRadius() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openLock(String bikeCode) {
|
||||||
|
QueryWrapper query = QueryWrapper.create()
|
||||||
|
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode));
|
||||||
|
EbikeBikeInfo info = this.mapper.selectOneByQuery(query);
|
||||||
|
|
||||||
|
//车辆状态检查
|
||||||
|
if (info.getStatus() != BikeStatus.LAUNCH) {
|
||||||
|
throw new RuntimeException("车辆未上架,不可骑行");
|
||||||
|
}
|
||||||
|
if (info.getUsageStatus() != BikeUsageStatus.WAIT) {
|
||||||
|
throw new RuntimeException("车辆已被占用或故障");
|
||||||
|
}
|
||||||
|
|
||||||
|
query.clear();
|
||||||
|
query.where(EBIKE_REGION.REGION_ID.eq(info.getRegionId()));
|
||||||
|
EbikeRegion region = regionMapper.selectOneByQuery(query);
|
||||||
|
|
||||||
|
//运营区是否运营中
|
||||||
|
if (region == null || region.getStatus() != RegionStatus.OPERATION) {
|
||||||
|
throw new RuntimeException("该区暂停运营中");
|
||||||
|
}
|
||||||
|
|
||||||
|
//车辆是否在运营区内
|
||||||
|
boolean result = regionMapper.checkBikeInRegion(bikeCode);
|
||||||
|
if (!result) {
|
||||||
|
throw new RuntimeException("该车辆在运营区外,暂不能骑行");
|
||||||
|
}
|
||||||
|
EbikeEcuInfo ebikeEcuInfo = ebikeEcuInfoService.getEcu(bikeCode);
|
||||||
|
|
||||||
|
ebikeEcuInfoService.unLock(ebikeEcuInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,6 +106,7 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
|||||||
EBIKE_ECU_INFO.OPERATOR_ID,
|
EBIKE_ECU_INFO.OPERATOR_ID,
|
||||||
QueryMethods.count().as(EbikeEcuInOverview::getCount)
|
QueryMethods.count().as(EbikeEcuInOverview::getCount)
|
||||||
)
|
)
|
||||||
|
.where(EBIKE_ECU_INFO.IS_CLAIM.eq(Boolean.FALSE))
|
||||||
.from(EBIKE_ECU_INFO)
|
.from(EBIKE_ECU_INFO)
|
||||||
.groupBy(EBIKE_ECU_INFO.OPERATOR_ID);
|
.groupBy(EBIKE_ECU_INFO.OPERATOR_ID);
|
||||||
return ebikeEcuInfoMapper.selectListByQueryAs(queryWrapper, EbikeEcuInOverview.class);
|
return ebikeEcuInfoMapper.selectListByQueryAs(queryWrapper, EbikeEcuInOverview.class);
|
||||||
@ -216,7 +217,8 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private EbikeEcuInfo getEcu(String bikeCode) {
|
@Override
|
||||||
|
public EbikeEcuInfo getEcu(String bikeCode) {
|
||||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode));
|
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode));
|
||||||
EbikeBikeInfo ebikeBikeInfo = bikeInfoMapper.selectOneByQuery(queryWrapper);
|
EbikeBikeInfo ebikeBikeInfo = bikeInfoMapper.selectOneByQuery(queryWrapper);
|
||||||
|
|||||||
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cdzy.operations.mapper.EbikeRegionMapper">
|
||||||
|
|
||||||
|
<!-- 查询车辆是否在指定运营区内 -->
|
||||||
|
<select id="checkBikeInRegion" resultType="boolean">
|
||||||
|
SELECT
|
||||||
|
ST_Contains(
|
||||||
|
r.region_polygon::geometry,
|
||||||
|
ST_MakePoint((b.location[0])::float, (b.location[1])::float)::geometry
|
||||||
|
) as in_region
|
||||||
|
FROM
|
||||||
|
ebike_bike_info b
|
||||||
|
INNER JOIN
|
||||||
|
ebike_region r ON b.region_id = r.region_id
|
||||||
|
WHERE
|
||||||
|
b.bike_code = #{bikeCode}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user