Compare commits
2 Commits
738cb26e99
...
a97e3b166a
| Author | SHA256 | Date | |
|---|---|---|---|
| a97e3b166a | |||
| 29affcc380 |
@ -5,6 +5,7 @@ import com.ebike.feign.component.FeignTokenInterceptor;
|
||||
import com.ebike.feign.config.ExampleFeignConfiguration;
|
||||
import com.ebike.feign.model.dto.FeignEbikeDto;
|
||||
import com.ebike.feign.model.dto.FeignEbikeUserBikeInfo;
|
||||
import com.ebike.feign.model.dto.FeignEbikeUserLockDto;
|
||||
import com.ebike.feign.model.vo.FeignEbikeBikeRadiusVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -44,7 +45,7 @@ public interface OperationsFeignClient {
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("/ebikeBikeInfo/api/lock")
|
||||
JsonResult<?> lock(@RequestParam("bikeCode")String bikeCode);
|
||||
JsonResult<FeignEbikeUserLockDto> lock(@RequestParam("bikeCode")String bikeCode);
|
||||
|
||||
/**
|
||||
* 用户获取车辆详情及其计费规则
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package com.ebike.feign.model.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-21
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FeignEbikeUserLockDto implements Serializable {
|
||||
|
||||
/**
|
||||
* 是否在运营区内
|
||||
*/
|
||||
Boolean bikeInRegion;
|
||||
|
||||
/**
|
||||
* 是否在停车区内
|
||||
*/
|
||||
Boolean bikeInParking;
|
||||
|
||||
/**
|
||||
* 是否在禁停区内
|
||||
*/
|
||||
Boolean bikeInNoParking;
|
||||
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.cdzy.operations.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.cdzy.operations.model.entity.EbikeSite;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
@ -11,4 +12,7 @@ import com.cdzy.operations.model.entity.EbikeSite;
|
||||
*/
|
||||
public interface EbikeSiteMapper extends BaseMapper<EbikeSite> {
|
||||
|
||||
boolean checkBikeInParking(@RequestParam("bikeCode") String bikeCode);
|
||||
|
||||
boolean checkBikeInNoParking(@RequestParam("bikeCode") String bikeCode);
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package com.cdzy.operations.model.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-21
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EbikeUserLockDto implements Serializable {
|
||||
|
||||
/**
|
||||
* 是否在运营区内
|
||||
*/
|
||||
Boolean bikeInRegion;
|
||||
|
||||
/**
|
||||
* 是否在停车区内
|
||||
*/
|
||||
Boolean bikeInParking;
|
||||
|
||||
/**
|
||||
* 是否在禁停区内
|
||||
*/
|
||||
Boolean bikeInNoParking;
|
||||
|
||||
}
|
||||
@ -4,6 +4,7 @@ import com.cdzy.common.model.request.PageParam;
|
||||
import com.cdzy.operations.model.dto.EbikeBikeInfoDto;
|
||||
import com.cdzy.operations.model.dto.EbikeDto;
|
||||
import com.cdzy.operations.model.dto.EbikeUserBikeInfo;
|
||||
import com.cdzy.operations.model.dto.EbikeUserLockDto;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
||||
import com.cdzy.operations.model.vo.EbikeBatchLaunchVo;
|
||||
import com.cdzy.operations.model.vo.EbikeBatchUnLaunchVo;
|
||||
@ -86,5 +87,5 @@ public interface EbikeBikeInfoService extends IService<EbikeBikeInfo> {
|
||||
* 用户关锁
|
||||
* @param bikeCode 车辆编号
|
||||
*/
|
||||
void lock(String bikeCode);
|
||||
EbikeUserLockDto lock(String bikeCode);
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import com.cdzy.operations.mapper.*;
|
||||
import com.cdzy.operations.model.dto.EbikeBikeInfoDto;
|
||||
import com.cdzy.operations.model.dto.EbikeDto;
|
||||
import com.cdzy.operations.model.dto.EbikeUserBikeInfo;
|
||||
import com.cdzy.operations.model.dto.EbikeUserLockDto;
|
||||
import com.cdzy.operations.model.entity.*;
|
||||
import com.cdzy.operations.model.vo.*;
|
||||
import com.cdzy.operations.service.EbikeBikeInfoService;
|
||||
@ -20,6 +21,7 @@ import com.mybatisflex.core.update.UpdateChain;
|
||||
import com.mybatisflex.core.util.StringUtil;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.postgresql.geometric.PGpolygon;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -47,6 +49,7 @@ import static com.cdzy.operations.model.entity.table.EbikeSpecialTimeTableDef.EB
|
||||
* @author attiya
|
||||
* @since 2025-10-17
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, EbikeBikeInfo> implements EbikeBikeInfoService {
|
||||
|
||||
@ -59,6 +62,9 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
@Resource
|
||||
EbikeRegionMapper regionMapper;
|
||||
|
||||
@Resource
|
||||
EbikeSiteMapper siteMapper;
|
||||
|
||||
@Resource
|
||||
EbikeEcuInfoMapper ebikeEcuInfoMapper;
|
||||
|
||||
@ -385,8 +391,31 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lock(String bikeCode) {
|
||||
public EbikeUserLockDto lock(String bikeCode) {
|
||||
QueryWrapper query = QueryWrapper.create()
|
||||
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode));
|
||||
EbikeBikeInfo info = this.mapper.selectOneByQuery(query);
|
||||
|
||||
|
||||
EbikeEcuInfo ebikeEcuInfo = ebikeEcuInfoService.getEcu(bikeCode);
|
||||
|
||||
info.setUsageStatus(BikeUsageStatus.WAIT);
|
||||
|
||||
boolean bikeInRegion = regionMapper.checkBikeInRegion(bikeCode);
|
||||
|
||||
boolean bikeInParking = siteMapper.checkBikeInParking(bikeCode);
|
||||
|
||||
boolean bikeInNoParking = siteMapper.checkBikeInNoParking(bikeCode);
|
||||
|
||||
ebikeEcuInfoService.lock(ebikeEcuInfo);
|
||||
|
||||
this.mapper.update(info);
|
||||
|
||||
return EbikeUserLockDto.builder()
|
||||
.bikeInRegion(bikeInRegion)
|
||||
.bikeInParking(bikeInParking)
|
||||
.bikeInNoParking(bikeInNoParking)
|
||||
.build();
|
||||
}
|
||||
|
||||
static EbikeSpecialDay getEbikeSpecialDay(List<EbikeSpecialDay> ebikeSpecialDays) {
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
<?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.EbikeSiteMapper">
|
||||
|
||||
<!--检查车辆是否在停车区内-->
|
||||
<select id="checkBikeInParking" resultType="java.lang.Boolean">
|
||||
SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM ebike_bike_info b
|
||||
INNER JOIN ebike_site s ON b.region_id = s.region_id
|
||||
WHERE b.bike_code = #{bikeCode}
|
||||
AND b.is_deleted = false
|
||||
AND s.is_deleted = false
|
||||
AND s.site_type = 1
|
||||
AND ST_Contains(
|
||||
s.site_polygon::geometry,
|
||||
ST_MakePoint((b.location[0])::float, (b.location[1])::float)::geometry
|
||||
)
|
||||
) as in_parking_area;
|
||||
</select>
|
||||
|
||||
<!--检查车辆是否在禁止停区内-->
|
||||
<select id="checkBikeInNoParking" resultType="java.lang.Boolean">
|
||||
-- 查询车辆是否在禁停区内 (site_type = 2)
|
||||
SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM ebike_bike_info b
|
||||
INNER JOIN ebike_site s ON b.region_id = s.region_id
|
||||
WHERE b.bike_code = #{bikeCode}
|
||||
AND b.is_deleted = false
|
||||
AND s.is_deleted = false
|
||||
AND s.site_type = 2
|
||||
AND ST_Contains(
|
||||
s.site_polygon::geometry,
|
||||
ST_MakePoint((b.location[0])::float, (b.location[1])::float)::geometry
|
||||
)
|
||||
) as in_no_parking_area;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user