gps定位
This commit is contained in:
parent
e5f6e16d8c
commit
38aa18053e
@ -9,6 +9,7 @@ import com.cdzy.operations.model.vo.EbikeEcuInfoVo;
|
||||
import com.cdzy.operations.service.EbikeEcuInfoService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -132,7 +133,7 @@ public class EbikeEcuInfoController {
|
||||
* @return 执行结构
|
||||
*/
|
||||
@GetMapping("checkSnOrBikeCode")
|
||||
public JsonResult<?> checkSnOrBikeCode(String ecuSn,String bikeCode) throws IOException {
|
||||
public JsonResult<?> checkSnOrBikeCode(String ecuSn,String bikeCode) {
|
||||
boolean result = ebikeEcuInfoService.checkSnOrBikeCode(ecuSn,bikeCode);
|
||||
return JsonResult.success(result);
|
||||
}
|
||||
@ -151,13 +152,13 @@ public class EbikeEcuInfoController {
|
||||
|
||||
|
||||
/**
|
||||
* 寻车铃
|
||||
* 执行命令
|
||||
*
|
||||
* @return 执行结构
|
||||
*/
|
||||
@GetMapping("findBike")
|
||||
public JsonResult<?> findBike(String ecuSn,String bikeCode) {
|
||||
boolean findBike = ebikeEcuInfoService.findBike(ecuSn,bikeCode);
|
||||
@GetMapping("executeCommand")
|
||||
public JsonResult<?> executeCommand(String ecuSn,String bikeCode,@NotNull(message = "命令编码不能为空") String commandCode) {
|
||||
boolean findBike = ebikeEcuInfoService.executeCommand(ecuSn,bikeCode,commandCode);
|
||||
return JsonResult.success(findBike);
|
||||
}
|
||||
|
||||
|
||||
@ -5,5 +5,14 @@ package com.cdzy.operations.enums;
|
||||
* @since 2025-10-30
|
||||
*/
|
||||
public interface CommandType {
|
||||
|
||||
/**
|
||||
* 寻车铃
|
||||
*/
|
||||
String FIND_BIKE = "FIND_BIKE";
|
||||
|
||||
/**
|
||||
* GPS
|
||||
*/
|
||||
String GPS = "GPS";
|
||||
}
|
||||
|
||||
@ -17,6 +17,13 @@ public interface CommandService{
|
||||
*/
|
||||
boolean findBike(EbikeEcuInfo ebikeEcuInfo);
|
||||
|
||||
/**
|
||||
* GPS定位上报
|
||||
* @param ebikeEcuInfo 中控信息
|
||||
* @return 执行结果
|
||||
*/
|
||||
boolean gps(EbikeEcuInfo ebikeEcuInfo);
|
||||
|
||||
/**
|
||||
* 回调事件
|
||||
* @param taskId 任务ID
|
||||
|
||||
@ -45,11 +45,17 @@ public interface EbikeEcuInfoService extends IService<EbikeEcuInfo> {
|
||||
|
||||
/**
|
||||
* 寻车铃命令
|
||||
* @param ecuSn 中控SN码
|
||||
* @param bikeCode 车辆编号
|
||||
* @param ebikeEcuInfo 中控信息
|
||||
* @return 结果
|
||||
*/
|
||||
boolean findBike(String ecuSn, String bikeCode);
|
||||
boolean findBike(EbikeEcuInfo ebikeEcuInfo);
|
||||
|
||||
/**
|
||||
* GPS命令
|
||||
* @param ebikeEcuInfo 中控信息
|
||||
* @return 结果
|
||||
*/
|
||||
boolean gps(EbikeEcuInfo ebikeEcuInfo);
|
||||
|
||||
/**
|
||||
* 校验参数
|
||||
@ -58,4 +64,13 @@ public interface EbikeEcuInfoService extends IService<EbikeEcuInfo> {
|
||||
* @return 结果
|
||||
*/
|
||||
boolean checkSnOrBikeCode(String ecuSn, String bikeCode);
|
||||
|
||||
/**
|
||||
* 执行命令
|
||||
* @param ecuSn 中控SN码
|
||||
* @param bikeCode 车辆编号
|
||||
* @param commandCode 命令编码
|
||||
* @return 执行结果
|
||||
*/
|
||||
boolean executeCommand(String ecuSn, String bikeCode, String commandCode);
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@ public class CommandServiceImpl implements CommandService {
|
||||
|
||||
@Override
|
||||
public boolean findBike(EbikeEcuInfo ebikeEcuInfo) {
|
||||
boolean result = false;
|
||||
String taskId = createTaskId();
|
||||
switch (ebikeEcuInfo.getEcuBrand()){
|
||||
case EcuBrand.GUANG_HE_TONG:
|
||||
@ -46,12 +45,27 @@ public class CommandServiceImpl implements CommandService {
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
result = submitTaskAndWait(topic, taskId,command);
|
||||
break;
|
||||
return submitTaskAndWait(topic, taskId,command);
|
||||
default :
|
||||
throw new EbikeException("该品牌中控暂未接入");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean gps(EbikeEcuInfo ebikeEcuInfo) {
|
||||
String taskId = createTaskId();
|
||||
switch (ebikeEcuInfo.getEcuBrand()){
|
||||
case EcuBrand.GUANG_HE_TONG:
|
||||
String command = null;
|
||||
try {
|
||||
command = CommandUtil.guang_he_tong(ebikeEcuInfo.getEcuSn(),taskId, CommandType.GPS);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return submitTaskAndWait(topic, taskId,command);
|
||||
default :
|
||||
throw new EbikeException("该品牌中控暂未接入");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,9 +104,7 @@ public class CommandServiceImpl implements CommandService {
|
||||
*/
|
||||
private void sendMessageToQueue(String topic, String taskData) {
|
||||
|
||||
executor.submit(() -> {
|
||||
kafkaProducer.send(topic, taskData);
|
||||
});
|
||||
executor.submit(() -> kafkaProducer.send(topic, taskData));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,6 +2,7 @@ package com.cdzy.operations.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.operations.enums.CommandType;
|
||||
import com.cdzy.operations.mapper.EbikeBikeInfoMapper;
|
||||
import com.cdzy.operations.model.dto.EbikeEcuInOverview;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
||||
@ -121,15 +122,13 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean findBike(String ecuSn, String bikeCode) {
|
||||
check(ecuSn, bikeCode);
|
||||
if (StringUtil.hasText(ecuSn)) {
|
||||
EbikeEcuInfo ebikeEcuInfo = checkEcuSn(ecuSn);
|
||||
public boolean findBike(EbikeEcuInfo ebikeEcuInfo) {
|
||||
return commandService.findBike(ebikeEcuInfo);
|
||||
} else {
|
||||
EbikeEcuInfo ebikeEcuInfo = getEcu(bikeCode);
|
||||
return commandService.findBike(ebikeEcuInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean gps(EbikeEcuInfo ebikeEcuInfo) {
|
||||
return commandService.gps(ebikeEcuInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,16 +137,31 @@ public class EbikeEcuInfoServiceImpl extends ServiceImpl<EbikeEcuInfoMapper, Ebi
|
||||
check(ecuSn, bikeCode);
|
||||
if (StringUtil.hasText(ecuSn)) {
|
||||
checkEcuSn(ecuSn);
|
||||
return true;
|
||||
} else {
|
||||
getEcu(bikeCode);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeCommand(String ecuSn, String bikeCode, String commandCode) {
|
||||
check(ecuSn, bikeCode);
|
||||
EbikeEcuInfo ebikeEcuInfo = null;
|
||||
if (StringUtil.hasText(ecuSn)) {
|
||||
ebikeEcuInfo = checkEcuSn(ecuSn);
|
||||
} else {
|
||||
ebikeEcuInfo = getEcu(bikeCode);
|
||||
}
|
||||
return switch (commandCode) {
|
||||
case CommandType.FIND_BIKE -> findBike(ebikeEcuInfo);
|
||||
case CommandType.GPS -> gps(ebikeEcuInfo);
|
||||
default -> throw new EbikeException("该命令不存在/未接入");
|
||||
};
|
||||
}
|
||||
|
||||
private EbikeEcuInfo checkEcuSn(String ecuSn) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_ECU_INFO.ECU_SN.eq(ecuSn));
|
||||
|
||||
@ -23,10 +23,14 @@ public class CommandUtil {
|
||||
|
||||
switch (code) {
|
||||
case CommandType.FIND_BIKE:
|
||||
String json = "{\"c\":14,\"tid\":\""+ taskId+"\",\"param\":{\"volume\":50,\"idx\":5}}";
|
||||
ObjectNode objectNode = mapper.readValue(json,ObjectNode.class);
|
||||
objectNode.put("tid",taskId);
|
||||
jsonNode.put("command",objectNode.toString());
|
||||
String command_14 = "{\"c\":14,\"tid\":\""+ taskId+"\",\"param\":{\"volume\":50,\"idx\":5}}";
|
||||
ObjectNode objectNode_14 = mapper.readValue(command_14,ObjectNode.class);
|
||||
jsonNode.put("command",objectNode_14.toString());
|
||||
break;
|
||||
case CommandType.GPS:
|
||||
String command_34 = "{\"c\":34,\"tid\":\""+ taskId+"\"}";
|
||||
ObjectNode objectNode_34 = mapper.readValue(command_34,ObjectNode.class);
|
||||
jsonNode.put("command",objectNode_34.toString());
|
||||
break;
|
||||
default :
|
||||
throw new EbikeException("该命令暂未接入");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user