中控上报信息存储优化
This commit is contained in:
parent
a907d7891b
commit
cef25e8180
@ -321,7 +321,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
|||||||
}
|
}
|
||||||
EbikeEcuInfo ebikeEcuInfo = ebikeEcuInfoService.getEcu(bikeCode);
|
EbikeEcuInfo ebikeEcuInfo = ebikeEcuInfoService.getEcu(bikeCode);
|
||||||
|
|
||||||
ResGPSDto resGPSDto = (ResGPSDto)redisUtil.get(RedisUtil.Database.DB2, ebikeEcuInfo.getEcuSn());
|
ResGPSDto resGPSDto = (ResGPSDto)redisUtil.getEcu(ebikeEcuInfo.getEcuSn());
|
||||||
|
|
||||||
if (resGPSDto.getSoc() < 20){
|
if (resGPSDto.getSoc() < 20){
|
||||||
throw new EbikeException("该车辆电量低,暂不能骑行");
|
throw new EbikeException("该车辆电量低,暂不能骑行");
|
||||||
@ -382,7 +382,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
|||||||
EbikeEcuInfo ecuInfo = ebikeEcuInfoService.getOne(query);
|
EbikeEcuInfo ecuInfo = ebikeEcuInfoService.getOne(query);
|
||||||
int soc = 0;
|
int soc = 0;
|
||||||
if (ecuInfo != null) {
|
if (ecuInfo != null) {
|
||||||
ResGPSDto resGPSDto = (ResGPSDto) redisUtil.get(RedisUtil.Database.DB2,ecuInfo.getEcuSn());
|
ResGPSDto resGPSDto = (ResGPSDto) redisUtil.getEcu(ecuInfo.getEcuSn());
|
||||||
soc = resGPSDto.getSoc();
|
soc = resGPSDto.getSoc();
|
||||||
}
|
}
|
||||||
if (specialBillingConfiguration == null || specialBillingConfiguration.getType() == SpecialBillingConfigurationType.CLOSED) {
|
if (specialBillingConfiguration == null || specialBillingConfiguration.getType() == SpecialBillingConfigurationType.CLOSED) {
|
||||||
|
|||||||
@ -185,7 +185,7 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
.leftJoin(EBIKE_BIKE_INFO).on(EBIKE_BIKE_INFO.BIKE_CODE.eq(EBIKE_BIKE_ORDER.BIKE_CODE))
|
.leftJoin(EBIKE_BIKE_INFO).on(EBIKE_BIKE_INFO.BIKE_CODE.eq(EBIKE_BIKE_ORDER.BIKE_CODE))
|
||||||
.leftJoin(EBIKE_ECU_INFO).on(EBIKE_ECU_INFO.ECU_ID.eq(EBIKE_BIKE_INFO.ECU_ID));
|
.leftJoin(EBIKE_ECU_INFO).on(EBIKE_ECU_INFO.ECU_ID.eq(EBIKE_BIKE_INFO.ECU_ID));
|
||||||
EbikeBikeOrderInfoDto infoDto = this.mapper.selectOneWithRelationsByQueryAs(queryWrapper, EbikeBikeOrderInfoDto.class);
|
EbikeBikeOrderInfoDto infoDto = this.mapper.selectOneWithRelationsByQueryAs(queryWrapper, EbikeBikeOrderInfoDto.class);
|
||||||
ResGPSDto resGPSDto = (ResGPSDto) redisUtil.get(RedisUtil.Database.DB2, infoDto.getEcuSn());
|
ResGPSDto resGPSDto = (ResGPSDto) redisUtil.getEcu(infoDto.getEcuSn());
|
||||||
if (Objects.nonNull(resGPSDto)) {
|
if (Objects.nonNull(resGPSDto)) {
|
||||||
infoDto.setSoc(resGPSDto.getSoc());
|
infoDto.setSoc(resGPSDto.getSoc());
|
||||||
}
|
}
|
||||||
@ -315,6 +315,13 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
@Override
|
@Override
|
||||||
public void batteryChange(EbikeBatteryChangeVo changeVo) {
|
public void batteryChange(EbikeBatteryChangeVo changeVo) {
|
||||||
String bikeCode = changeVo.getBikeCode();
|
String bikeCode = changeVo.getBikeCode();
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode));
|
||||||
|
EbikeBikeInfo bikeInfo = bikeInfoMapper.selectOneByQuery(queryWrapper);
|
||||||
|
if (bikeInfo == null) {
|
||||||
|
throw new EbikeException("车辆编号错误");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EbikeBikeInfo checkBikeCode(String bikeCode) {
|
EbikeBikeInfo checkBikeCode(String bikeCode) {
|
||||||
|
|||||||
@ -39,6 +39,9 @@ public class RedisUtil {
|
|||||||
// 调度工单相关
|
// 调度工单相关
|
||||||
public static final String BIKE_DISPATCH_ORDER_PREFIX = "bike:dispatch:order:";
|
public static final String BIKE_DISPATCH_ORDER_PREFIX = "bike:dispatch:order:";
|
||||||
|
|
||||||
|
// 车辆信息相关
|
||||||
|
public static final String BIKE_ECU_PREFIX = "bike:ecu:";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误消息常量
|
* 错误消息常量
|
||||||
@ -473,4 +476,18 @@ public class RedisUtil {
|
|||||||
public Boolean releaseDispatchLock(String lockKey) {
|
public Boolean releaseDispatchLock(String lockKey) {
|
||||||
return delete(Database.DB2, lockKey);
|
return delete(Database.DB2, lockKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库2专用:存储中控信息
|
||||||
|
*/
|
||||||
|
public void saveEcu(String ecuSn, Object ecuData) {
|
||||||
|
set(Database.DB2, BIKE_ECU_PREFIX + ecuSn, ecuData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库2专用:获取中控信息
|
||||||
|
*/
|
||||||
|
public Object getEcu(String ecuSn) {
|
||||||
|
return get(Database.DB2, BIKE_ECU_PREFIX + ecuSn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ public class ReoprtHandler {
|
|||||||
resGpsDto.setIsHelmetLocked(isHelmetLocked);
|
resGpsDto.setIsHelmetLocked(isHelmetLocked);
|
||||||
resGpsDto.setIsWheelSpin(isWheelSpin);
|
resGpsDto.setIsWheelSpin(isWheelSpin);
|
||||||
resGpsDto.setIsMoving(isMoving);
|
resGpsDto.setIsMoving(isMoving);
|
||||||
redisUtil.set(deviceId, resGpsDto);
|
redisUtil.saveEcu(deviceId, resGpsDto);
|
||||||
double[] doubles = CoordinateUtil.WGS84ToGCJ02(resGpsDto.getLongitude(), resGpsDto.getLatitude());
|
double[] doubles = CoordinateUtil.WGS84ToGCJ02(resGpsDto.getLongitude(), resGpsDto.getLatitude());
|
||||||
boolean outOfChina = CoordinateUtil.outOfChina(doubles[0], doubles[1]);
|
boolean outOfChina = CoordinateUtil.outOfChina(doubles[0], doubles[1]);
|
||||||
if (!outOfChina) {
|
if (!outOfChina) {
|
||||||
@ -90,12 +90,11 @@ public class ReoprtHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void bmsMsgHandler(JsonNode param, String deviceId) {
|
public void bmsMsgHandler(JsonNode param, String deviceId) {
|
||||||
ResGPSDto resGpsDto = (ResGPSDto) redisUtil.get(deviceId);
|
ResGPSDto resGpsDto = (ResGPSDto) redisUtil.getEcu(deviceId);
|
||||||
if (resGpsDto != null) {
|
if (resGpsDto != null) {
|
||||||
Integer mosState = param.get("MOSState").asInt();
|
Integer mosState = param.get("MOSState").asInt();
|
||||||
resGpsDto.setMosState(mosState);
|
resGpsDto.setMosState(mosState);
|
||||||
redisUtil.delete(deviceId);
|
redisUtil.saveEcu(deviceId, resGpsDto);
|
||||||
redisUtil.set(deviceId, resGpsDto);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,9 @@ public class RedisUtil {
|
|||||||
|
|
||||||
private final RedisTemplate<String, Object> redisTemplate;
|
private final RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
|
// 车辆信息相关
|
||||||
|
public static final String BIKE_ECU_PREFIX = "bike:ecu:";
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public RedisUtil(RedisTemplate<String, Object> redisTemplate) {
|
public RedisUtil(RedisTemplate<String, Object> redisTemplate) {
|
||||||
@ -252,4 +255,18 @@ public class RedisUtil {
|
|||||||
public Boolean releaseLock(String key) {
|
public Boolean releaseLock(String key) {
|
||||||
return redisTemplate.delete(key);
|
return redisTemplate.delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库2专用:存储中控信息
|
||||||
|
*/
|
||||||
|
public void saveEcu(String ecuSn, Object ecuData) {
|
||||||
|
set( BIKE_ECU_PREFIX + ecuSn, ecuData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库2专用:获取中控信息
|
||||||
|
*/
|
||||||
|
public Object getEcu(String ecuSn) {
|
||||||
|
return get( BIKE_ECU_PREFIX + ecuSn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user