代码检查
This commit is contained in:
parent
77489ee59d
commit
074b3bd8a3
@ -22,6 +22,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeCmdTableDef.EBIKE_CMD;
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeCmdTableDef.EBIKE_CMD;
|
||||||
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeEcuInfoTableDef.EBIKE_ECU_INFO;
|
||||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeParamTableDef.EBIKE_PARAM;
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeParamTableDef.EBIKE_PARAM;
|
||||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeParamValueTableDef.EBIKE_PARAM_VALUE;
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeParamValueTableDef.EBIKE_PARAM_VALUE;
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ public class EbikeCoreHandler {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下发命令
|
* 根据ecuId下发命令
|
||||||
*
|
*
|
||||||
* @param ecuID 中控ID
|
* @param ecuID 中控ID
|
||||||
* @return 一致性返回
|
* @return 一致性返回
|
||||||
@ -87,6 +88,45 @@ public class EbikeCoreHandler {
|
|||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据eucSn下发命令
|
||||||
|
*
|
||||||
|
* @param ecuSn 中控编号
|
||||||
|
* @return 一致性返回
|
||||||
|
*/
|
||||||
|
public CompletableFuture<String> executeCommand(String ecuSn, String cmdCode) {
|
||||||
|
CompletableFuture<String> future = new CompletableFuture<>();
|
||||||
|
EbikeEcuInfoService ebikeEcuInfoService = SpringContextHolder.getBean(EbikeEcuInfoService.class);
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.where(EBIKE_ECU_INFO.ECU_SN.eq(ecuSn));
|
||||||
|
EbikeEcuInfo ebikeEcuInfo = ebikeEcuInfoService.getOne(queryWrapper);
|
||||||
|
if (ebikeEcuInfo == null) {
|
||||||
|
throw new RuntimeException("中控编号错误");
|
||||||
|
}
|
||||||
|
CMDMsg cmdMsg = new CMDMsg();
|
||||||
|
cmdMsg.setDeviceId(ecuSn);
|
||||||
|
cmdMsg.setGroup(ebikeEcuInfo.getOperatorCode());
|
||||||
|
|
||||||
|
String tid = UUID.randomUUID().toString().replace("-", "");
|
||||||
|
|
||||||
|
String command = getCommand(cmdCode, tid);
|
||||||
|
cmdMsg.setCommand(command);
|
||||||
|
// 注册响应监听
|
||||||
|
pendingRequests.put(tid, future);
|
||||||
|
String string = JSONObject.toJSONString(cmdMsg);
|
||||||
|
producer.send("command", string);
|
||||||
|
|
||||||
|
|
||||||
|
// 设置超时任务(30秒未响应则超时)
|
||||||
|
timeoutScheduler.schedule(() -> {
|
||||||
|
CompletableFuture<String> timedOutFuture = pendingRequests.remove(tid);
|
||||||
|
if (timedOutFuture != null) {
|
||||||
|
timedOutFuture.completeExceptionally(new TimeoutException("超时未响应"));
|
||||||
|
}
|
||||||
|
}, 5, TimeUnit.SECONDS);
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka信息统一处理
|
* kafka信息统一处理
|
||||||
*
|
*
|
||||||
|
|||||||
@ -5,11 +5,11 @@ import com.alibaba.fastjson2.JSONObject;
|
|||||||
import com.cdzy.common.enums.Code;
|
import com.cdzy.common.enums.Code;
|
||||||
import com.cdzy.common.model.CoreResult;
|
import com.cdzy.common.model.CoreResult;
|
||||||
import com.cdzy.common.model.JsonResult;
|
import com.cdzy.common.model.JsonResult;
|
||||||
|
import com.cdzy.common.model.ResGPSDto;
|
||||||
import com.cdzy.ebikemaintenance.component.EbikeCoreHandler;
|
import com.cdzy.ebikemaintenance.component.EbikeCoreHandler;
|
||||||
import com.cdzy.ebikemaintenance.enums.CmdCode;
|
import com.cdzy.ebikemaintenance.enums.CmdCode;
|
||||||
import com.cdzy.ebikemaintenance.mapper.EbikeErrorMsgMapper;
|
import com.cdzy.ebikemaintenance.mapper.EbikeErrorMsgMapper;
|
||||||
import com.cdzy.ebikemaintenance.model.dto.request.ReqEbikeBikeComDto;
|
import com.cdzy.ebikemaintenance.model.dto.request.ReqEbikeBikeComDto;
|
||||||
import com.cdzy.common.model.ResGPSDto;
|
|
||||||
import com.cdzy.ebikemaintenance.model.pojo.EbikeEcuInfo;
|
import com.cdzy.ebikemaintenance.model.pojo.EbikeEcuInfo;
|
||||||
import com.cdzy.ebikemaintenance.model.pojo.EbikeErrorMsg;
|
import com.cdzy.ebikemaintenance.model.pojo.EbikeErrorMsg;
|
||||||
import com.cdzy.ebikemaintenance.service.EbikeBikeComService;
|
import com.cdzy.ebikemaintenance.service.EbikeBikeComService;
|
||||||
@ -33,7 +33,7 @@ import java.io.IOException;
|
|||||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeErrorMsgTableDef.EBIKE_ERROR_MSG;
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeErrorMsgTableDef.EBIKE_ERROR_MSG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试中控控制层
|
* 车俩详情测试中控控制层
|
||||||
*
|
*
|
||||||
* @author attiya
|
* @author attiya
|
||||||
* @since 2025-03-18
|
* @since 2025-03-18
|
||||||
@ -41,7 +41,7 @@ import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeErrorMsgTableDef.E
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/core")
|
@RequestMapping("/core")
|
||||||
@Validated
|
@Validated
|
||||||
public class EbikeCoreController {
|
public class EbikeInfoCoreController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EbikeCoreHandler ebikeCoreService;
|
private EbikeCoreHandler ebikeCoreService;
|
||||||
@ -0,0 +1,423 @@
|
|||||||
|
package com.cdzy.ebikemaintenance.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.cdzy.common.enums.Code;
|
||||||
|
import com.cdzy.common.model.CoreResult;
|
||||||
|
import com.cdzy.common.model.JsonResult;
|
||||||
|
import com.cdzy.common.model.ResGPSDto;
|
||||||
|
import com.cdzy.ebikemaintenance.component.EbikeCoreHandler;
|
||||||
|
import com.cdzy.ebikemaintenance.enums.CmdCode;
|
||||||
|
import com.cdzy.ebikemaintenance.mapper.EbikeErrorMsgMapper;
|
||||||
|
import com.cdzy.ebikemaintenance.model.pojo.EbikeErrorMsg;
|
||||||
|
import com.cdzy.ebikemaintenance.utils.EmqxApiClient;
|
||||||
|
import com.cdzy.ebikemaintenance.utils.RedisUtil;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeErrorMsgTableDef.EBIKE_ERROR_MSG;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试中控控制层
|
||||||
|
*
|
||||||
|
* @author attiya
|
||||||
|
* @since 2025-03-18
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/testCore")
|
||||||
|
@Validated
|
||||||
|
public class EbikeTestCoreController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EbikeCoreHandler ebikeCoreService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EbikeErrorMsgMapper errorMsgMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备是否在线
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("online")
|
||||||
|
public JsonResult<?> online(@RequestParam("ecuSn") String ecuSn) throws IOException {
|
||||||
|
boolean online = EmqxApiClient.isClientOnline(ecuSn);
|
||||||
|
CoreResult result = online ? CoreResult.online() : CoreResult.offline();
|
||||||
|
return JsonResult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 寻车铃
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("findEbike")
|
||||||
|
public DeferredResult<JsonResult<?>> findEbike(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.VIDEO_5).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPS定位
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("gps")
|
||||||
|
public DeferredResult<JsonResult<?>> gps(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.GPS).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取GPS定位信息
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("gpsMsg")
|
||||||
|
public JsonResult<?> gpsMsg(@NotNull(message = "中控SN码不能为空") @RequestParam("ecuSn") String ecuSn) {
|
||||||
|
String jsonString = JSONObject.toJSONString(redisUtil.get(ecuSn));
|
||||||
|
ResGPSDto resGpsDto = JSONObject.parseObject(jsonString, ResGPSDto.class);
|
||||||
|
return JsonResult.success(resGpsDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开电池仓
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("openBatteryLock")
|
||||||
|
public DeferredResult<JsonResult<?>> openBatteryLock(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.OPEN_BATTERY_LOCK).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == Code.COMMAND_SUCCESS) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭电池仓
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("closeBatteryLock")
|
||||||
|
public DeferredResult<JsonResult<?>> closeBatteryLock(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.CLOSE_BATTERY_LOCK).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == Code.COMMAND_SUCCESS) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关锁
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("lock")
|
||||||
|
public DeferredResult<JsonResult<?>> lock(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.LOCK).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开锁
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("unlock")
|
||||||
|
public DeferredResult<JsonResult<?>> unlock(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.UNLOCK).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开头盔
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("openHelmet")
|
||||||
|
public DeferredResult<JsonResult<?>> openHelmet(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.OPEN_HEMET).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 摄像头还车
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("cameraReturn")
|
||||||
|
public DeferredResult<JsonResult<?>> cameraReturn(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.CAMERA_RETURN).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消设防
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("cancelAntiTheft")
|
||||||
|
public DeferredResult<JsonResult<?>> cancelAntiTheft(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.CANCEL_ANTI_THEFT).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭电源
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("powerOff")
|
||||||
|
public DeferredResult<JsonResult<?>> powerOff(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.GPS).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 远程重启
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("restart")
|
||||||
|
public DeferredResult<JsonResult<?>> restart(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.RESTART).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时锁车
|
||||||
|
*
|
||||||
|
* @return 执行结构
|
||||||
|
*/
|
||||||
|
@GetMapping("tempLock")
|
||||||
|
public DeferredResult<JsonResult<?>> tempLock(@RequestParam("ecuSn") String ecuSn) {
|
||||||
|
DeferredResult<JsonResult<?>> deferredResult = new DeferredResult<>(5000L); // 5秒超时
|
||||||
|
ebikeCoreService.executeCommand(ecuSn, CmdCode.TEMP_LOCK).whenComplete((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
CoreResult result = CoreResult.failed(ex.getMessage());
|
||||||
|
deferredResult.setResult(JsonResult.success(result));
|
||||||
|
} else {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code == 0) {
|
||||||
|
CoreResult success = CoreResult.success();
|
||||||
|
deferredResult.setResult(JsonResult.success(success));
|
||||||
|
} else {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_ERROR_MSG.CODE.eq(code));
|
||||||
|
EbikeErrorMsg ebikeErrorMsg = errorMsgMapper.selectOneByQuery(queryWrapper);
|
||||||
|
CoreResult failed = CoreResult.failed(code, ebikeErrorMsg.getMsg());
|
||||||
|
deferredResult.setResult(JsonResult.success(failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,7 +10,7 @@ import com.cdzy.common.model.JsonResult;
|
|||||||
import com.cdzy.common.model.PageParam;
|
import com.cdzy.common.model.PageParam;
|
||||||
import com.cdzy.common.model.ResGPSDto;
|
import com.cdzy.common.model.ResGPSDto;
|
||||||
import com.cdzy.common.utils.CoordinateUtil;
|
import com.cdzy.common.utils.CoordinateUtil;
|
||||||
import com.cdzy.ebikemaintenance.controller.EbikeCoreController;
|
import com.cdzy.ebikemaintenance.controller.EbikeInfoCoreController;
|
||||||
import com.cdzy.ebikemaintenance.mapper.*;
|
import com.cdzy.ebikemaintenance.mapper.*;
|
||||||
import com.cdzy.ebikemaintenance.model.dto.request.*;
|
import com.cdzy.ebikemaintenance.model.dto.request.*;
|
||||||
import com.cdzy.ebikemaintenance.model.dto.response.*;
|
import com.cdzy.ebikemaintenance.model.dto.response.*;
|
||||||
@ -35,7 +35,6 @@ import jakarta.annotation.Resource;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.kafka.common.errors.ResourceNotFoundException;
|
import org.apache.kafka.common.errors.ResourceNotFoundException;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@ -61,7 +60,8 @@ import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBikeOrderTableDef.
|
|||||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeCarStatusInfoTableDef.EBIKE_CAR_STATUS_INFO;
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeCarStatusInfoTableDef.EBIKE_CAR_STATUS_INFO;
|
||||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeDispatchRecordsTableDef.EBIKE_DISPATCH_RECORDS;
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeDispatchRecordsTableDef.EBIKE_DISPATCH_RECORDS;
|
||||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeEcuInfoTableDef.EBIKE_ECU_INFO;
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeEcuInfoTableDef.EBIKE_ECU_INFO;
|
||||||
import static com.mybatisflex.core.query.QueryMethods.*;
|
import static com.mybatisflex.core.query.QueryMethods.max;
|
||||||
|
import static com.mybatisflex.core.query.QueryMethods.select;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆基本信息 服务层实现。
|
* 车辆基本信息 服务层实现。
|
||||||
@ -112,7 +112,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
|||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EbikeCoreController ebikeCoreController;
|
private EbikeInfoCoreController ebikeCoreController;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MinioUtil minioUtil;
|
private MinioUtil minioUtil;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user