整车绑定(暂未做库存消减
This commit is contained in:
parent
bed9615b94
commit
98001c331a
@ -0,0 +1,17 @@
|
||||
package com.cdzy.operations.enums;
|
||||
|
||||
/**
|
||||
* @author attiya
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
public interface BikeStatus {
|
||||
/**
|
||||
* 未上架
|
||||
*/
|
||||
int UN_LAUNCH = 0;
|
||||
|
||||
/**
|
||||
* 已上架
|
||||
*/
|
||||
int LAUNCH = 1;
|
||||
}
|
||||
@ -70,16 +70,6 @@ public class EbikeBikeInfo implements Serializable {
|
||||
*/
|
||||
private PGpoint location;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private String longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private String latitude;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@ -33,16 +33,22 @@ public class EbikeBikeBindVo implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 电池ID
|
||||
* 车辆编号
|
||||
*/
|
||||
@NotNull(message = "电池编号不能为空")
|
||||
private Long batteryCode;
|
||||
@NotNull(message = "车辆编号不能为空")
|
||||
private String bikeCode;
|
||||
|
||||
/**
|
||||
* 中控ID
|
||||
* 电池编号
|
||||
*/
|
||||
@NotNull(message = "电池编号不能为空")
|
||||
private String batteryCode;
|
||||
|
||||
/**
|
||||
* 中控编号
|
||||
*/
|
||||
@NotNull(message = "中控编号不能为空")
|
||||
private Long ecuCode;
|
||||
private String ecuCode;
|
||||
|
||||
/**
|
||||
* 头盔ID
|
||||
|
||||
@ -1,23 +1,68 @@
|
||||
package com.cdzy.operations.service.impl;
|
||||
|
||||
import com.cdzy.operations.model.vo.EbikeBikeBindVo;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.operations.enums.BatteryStatus;
|
||||
import com.cdzy.operations.enums.BikeStatus;
|
||||
import com.cdzy.operations.mapper.EbikeBatteryInfoMapper;
|
||||
import com.cdzy.operations.mapper.EbikeBikeInfoMapper;
|
||||
import com.cdzy.operations.mapper.EbikeEcuInfoMapper;
|
||||
import com.cdzy.operations.model.entity.EbikeBatteryInfo;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
||||
import com.cdzy.operations.model.entity.EbikeEcuInfo;
|
||||
import com.cdzy.operations.model.vo.EbikeBikeBindVo;
|
||||
import com.cdzy.operations.service.EbikeBikeInfoService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeBatteryInfoTableDef.EBIKE_BATTERY_INFO;
|
||||
import static com.cdzy.operations.model.entity.table.EbikeEcuInfoTableDef.EBIKE_ECU_INFO;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-17
|
||||
*/
|
||||
@Service
|
||||
public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, EbikeBikeInfo> implements EbikeBikeInfoService{
|
||||
public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, EbikeBikeInfo> implements EbikeBikeInfoService {
|
||||
|
||||
@Resource
|
||||
EbikeBatteryInfoMapper batteryInfoMapper;
|
||||
|
||||
@Resource
|
||||
EbikeEcuInfoMapper ebikeEcuInfoMapper;
|
||||
|
||||
@Override
|
||||
public void bind(EbikeBikeBindVo bindVo) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_BATTERY_INFO.BATTERY_CODE.eq(bindVo.getBatteryCode()))
|
||||
.where(EBIKE_BATTERY_INFO.STATUS.eq(BatteryStatus.BIND));
|
||||
EbikeBatteryInfo batteryInfo = batteryInfoMapper.selectOneByQuery(queryWrapper);
|
||||
if (batteryInfo == null) {
|
||||
throw new EbikeException("该电池不存在或尚未绑定");
|
||||
}
|
||||
|
||||
queryWrapper.clear();
|
||||
queryWrapper.where(EBIKE_ECU_INFO.ECU_SN.eq(bindVo.getEcuCode()));
|
||||
EbikeEcuInfo ecuInfo = ebikeEcuInfoMapper.selectOneByQuery(queryWrapper);
|
||||
if (ecuInfo == null) {
|
||||
throw new EbikeException("该中控不存在");
|
||||
}
|
||||
|
||||
EbikeBikeInfo bikeInfo = EbikeBikeInfo.builder()
|
||||
.bikeCode(bindVo.getBikeCode())
|
||||
.batteryId(batteryInfo.getBatteryId())
|
||||
.ecuId(ecuInfo.getEcuId())
|
||||
.hasHelme(bindVo.getHasHelme())
|
||||
.status(BikeStatus.UN_LAUNCH)
|
||||
.createdBy(StpUtil.getLoginIdAsLong())
|
||||
.build();
|
||||
this.mapper.insert(bikeInfo);
|
||||
|
||||
//TODO: 消减库存
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,8 +19,6 @@ class EbikeOperationsApplicationTests {
|
||||
// 创建测试点:X经度、纬度
|
||||
PGpoint point =new PGpoint(116.3974, 39.9093);
|
||||
bikeInfo.setLocation(point);
|
||||
bikeInfo.setLongitude(String.valueOf(point.x));
|
||||
bikeInfo.setLatitude(String.valueOf(point.y));
|
||||
ebikeBikeInfoMapper.insert(bikeInfo);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user