refactor(robot): 重构机器人信息获取逻辑
- 新增 RobotInformationVO 类用于封装机器人信息 - 实现机器人信息缓存机制,优化信息获取效率 - 修改测试接口,使用 RobotStatusDTO 作为参数 - 更新机器人状态处理逻辑,支持错误级别判断 -优化数据库查询,减少冗余操作
This commit is contained in:
parent
5c9ef72ba0
commit
86f0385836
@ -3,6 +3,10 @@ package cn.iocoder.yudao.framework.common.enums;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 通用状态枚举
|
||||
*
|
||||
@ -28,4 +32,8 @@ public enum NodeTypeEnum {
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
public static List<Integer> getAllTypes() {
|
||||
return Arrays.stream(NodeTypeEnum.values()).map(NodeTypeEnum::getType).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class PositionMapLineDTO {
|
||||
@Schema(description = "结束点id(点位子表id)", example = "15890")
|
||||
private Long endPointId;
|
||||
|
||||
@Schema(description = "行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
|
||||
@Schema(description = "行走方法 0.直线 1.曲线")
|
||||
private Integer method;
|
||||
|
||||
@Schema(description = "方向 1.单向 2.双向", example = "15890")
|
||||
@ -48,7 +48,38 @@ public class PositionMapLineDTO {
|
||||
|
||||
@Schema(description = "结束控制点y轴")
|
||||
private String endControlY;
|
||||
|
||||
/**
|
||||
* 开始点位x轴
|
||||
*/
|
||||
private String actualStartPointX;
|
||||
/**
|
||||
* 开始点位y轴
|
||||
*/
|
||||
private String actualStartPointY;
|
||||
/**
|
||||
* 结束点位x轴
|
||||
*/
|
||||
private String actualEndPointX;
|
||||
/**
|
||||
* 结束点位y轴
|
||||
*/
|
||||
private String actualEndPointY;
|
||||
/**
|
||||
* 开始控制点x轴
|
||||
*/
|
||||
private String actualBeginControlX;
|
||||
/**
|
||||
* 开始控制点y轴
|
||||
*/
|
||||
private String actualBeginControlY;
|
||||
/**
|
||||
* 结束控制点x轴
|
||||
*/
|
||||
private String actualEndControlX;
|
||||
/**
|
||||
* 结束控制点y轴
|
||||
*/
|
||||
private String actualEndControlY;
|
||||
@Schema(description = "膨胀区域前")
|
||||
private BigDecimal expansionZoneFront;
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.system.api.robot.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 车机响应信息
|
||||
*/
|
||||
@Data
|
||||
public class RobotInformationVO {
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* mac地址
|
||||
*/
|
||||
private String macAddress;
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private String robotModelNumber;
|
||||
/**
|
||||
* 点位信息
|
||||
*/
|
||||
public RobotStatusDataPoseDTO pose2d;
|
||||
}
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataErrorDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnMsgDO;
|
||||
@ -19,7 +20,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -29,8 +29,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.module.system.config.SystemJobConfiguration.NOTIFY_THREAD_POOL_TASK_EXECUTOR;
|
||||
|
||||
@Slf4j
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
@ -85,10 +83,16 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
robotStatusDataPoseDTO.setFloor(robotStatusDataDTO.getData().getFloor_zone().getFloor());
|
||||
robotStatusDataPoseDTO.setArea(robotStatusDataDTO.getData().getFloor_zone().getArea());
|
||||
redisUtil.set(pose2dKey, JSON.toJSONString(robotStatusDataPoseDTO), robotPositionCacheTime);
|
||||
|
||||
// -- 通过mac 地址获取车辆信息 - (并且加入到缓存中)
|
||||
Map<String, RobotInformationVO> robotInformationVOS = robotInformationService.getAllRobotByRedis();
|
||||
RobotInformationVO robotInformationVO = robotInformationVOS.get(robotStatusDataDTO.getMac());
|
||||
if (robotInformationVO == null) {
|
||||
robotInformationVO = robotInformationService.getRobotByRedis(robotStatusDataDTO.getMac());
|
||||
}
|
||||
robotInformationVO.setPose2d(robotStatusDataDTO.getData().getPose2d());
|
||||
// 合并请求 - 这里接受到的数据都丢给 RequestProcessor - 再整合数据通过WebSocket丢给前端
|
||||
processor.handleRequest(robotStatusDataPoseDTO.getFloor() + "_" + robotStatusDataPoseDTO.getArea(),
|
||||
robotStatusDataDTO.getMac(), JSONUtil.toJsonStr(robotStatusDataDTO.getData().getPose2d()));
|
||||
robotStatusDataDTO.getMac(), JSONUtil.toJsonStr(robotInformationVO));
|
||||
|
||||
|
||||
if (ObjectUtil.isNotNull(robotStatusDataDTO.getData().getErr_code())) {
|
||||
|
@ -28,4 +28,7 @@ public class RobotTaskChcheConstant {
|
||||
|
||||
//机器人异常信息(拼接的是mac地址)
|
||||
public static String ROBOT_ERROR_MSG = "robot:information:error:msg";
|
||||
|
||||
//机器人mac地址和机器人id以及机器人类型映射(通过mac地址。获取机器人基本信息)
|
||||
public static String ROBOT_GET_ROBOT_INFO = "robot:information:getRobotInfo";
|
||||
}
|
||||
|
@ -1,19 +1,15 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.positionmap;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.enums.NodeTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapItemPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapItemRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO;
|
||||
import cn.iocoder.yudao.module.system.handler.mapnode.NodeProcessingContext;
|
||||
import cn.iocoder.yudao.module.system.service.positionmap.PositionMapItemService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -22,15 +18,12 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 仓库点位地图子表")
|
||||
@ -44,12 +37,6 @@ public class PositionMapItemController {
|
||||
@Resource
|
||||
private NodeProcessingContext nodeProcessingContext;
|
||||
|
||||
@GetMapping("/getMapItemId")
|
||||
@Operation(summary = "获取节点id")
|
||||
public CommonResult<String> getMapItemId() {
|
||||
return success(String.valueOf(IdWorker.getId()));
|
||||
}
|
||||
|
||||
// -- 前端给所有的节点信息 -
|
||||
@PostMapping("/batchSaveOrEditOrDel")
|
||||
@Operation(summary = "批量新增编辑删除节点")
|
||||
@ -59,10 +46,10 @@ public class PositionMapItemController {
|
||||
// -- 获取到对应地图的所有点位
|
||||
List<PositionMapItemDO> oldList = positionMapItemService.getByMapId(positionMapId);
|
||||
Map<Integer, List<PositionMapItemDO>> oldMap = oldList.stream().collect(Collectors.groupingBy(PositionMapItemDO::getType));
|
||||
for (Map.Entry<Integer, List<NodeBaseDTO>> entry : map.entrySet()) {
|
||||
int key = entry.getKey();
|
||||
for (Integer key : NodeTypeEnum.getAllTypes()) {
|
||||
List<NodeBaseDTO> nodeBaseDTOList = CollectionUtil.isEmpty(map.get(key)) ? Collections.emptyList() : map.get(key);
|
||||
List<PositionMapItemDO> oldItemList = CollectionUtil.isEmpty(oldMap.get(key)) ? Collections.emptyList() : oldMap.get(key);
|
||||
nodeProcessingContext.processNodesByStrategy(positionMapId, oldItemList, key, entry.getValue());
|
||||
nodeProcessingContext.processNodesByStrategy(positionMapId, oldItemList, key, nodeBaseDTOList);
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
@ -88,18 +75,4 @@ public class PositionMapItemController {
|
||||
.eqIfPresent(PositionMapItemDO::getLaneId, laneId));
|
||||
return success(BeanUtils.toBean(list, PositionMapItemRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出仓库点位地图子表 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('system:position-map-item:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportPositionMapItemExcel(@Valid PositionMapItemPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<PositionMapItemDO> list = positionMapItemService.getPositionMapItemPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "仓库点位地图子表.xls", "数据", PositionMapItemRespVO.class,
|
||||
BeanUtils.toBean(list, PositionMapItemRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class PositionMapLineDTO {
|
||||
@Schema(description = "结束点id(点位子表id)", example = "15890")
|
||||
private Long endPointId;
|
||||
|
||||
@Schema(description = "行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
|
||||
@Schema(description = "行走方法 0.直线 1.曲线")
|
||||
private Integer method;
|
||||
|
||||
@Schema(description = "方向 1.单向 2.双向", example = "15890")
|
||||
@ -46,7 +46,38 @@ public class PositionMapLineDTO {
|
||||
|
||||
@Schema(description = "结束控制点y轴")
|
||||
private String endControlY;
|
||||
|
||||
/**
|
||||
* 开始点位x轴
|
||||
*/
|
||||
private String actualStartPointX;
|
||||
/**
|
||||
* 开始点位y轴
|
||||
*/
|
||||
private String actualStartPointY;
|
||||
/**
|
||||
* 结束点位x轴
|
||||
*/
|
||||
private String actualEndPointX;
|
||||
/**
|
||||
* 结束点位y轴
|
||||
*/
|
||||
private String actualEndPointY;
|
||||
/**
|
||||
* 开始控制点x轴
|
||||
*/
|
||||
private String actualBeginControlX;
|
||||
/**
|
||||
* 开始控制点y轴
|
||||
*/
|
||||
private String actualBeginControlY;
|
||||
/**
|
||||
* 结束控制点x轴
|
||||
*/
|
||||
private String actualEndControlX;
|
||||
/**
|
||||
* 结束控制点y轴
|
||||
*/
|
||||
private String actualEndControlY;
|
||||
@Schema(description = "膨胀区域前")
|
||||
private BigDecimal expansionZoneFront;
|
||||
|
||||
|
@ -42,6 +42,12 @@ public class PositionMapItemRespVO {
|
||||
@ExcelProperty("坐标y轴")
|
||||
private String locationY;
|
||||
|
||||
@Schema(description = "实际坐标x轴")
|
||||
private String actualLocationX;
|
||||
|
||||
@Schema(description = "实际坐标y轴")
|
||||
private String actualLocationY;
|
||||
|
||||
@Schema(description = "类型 1.路径点位 2.库位点 3.充电桩 4.停车点 5.区域变更点 6.等待点 --- 后续补充", example = "1")
|
||||
@ExcelProperty("类型 1.路径点位 2.库位点 3.充电桩 4.停车点 5.区域变更点 6.等待点 --- 后续补充")
|
||||
private Integer type;
|
||||
|
@ -49,6 +49,30 @@ public class PositionMapLinePageReqVO extends PageParam {
|
||||
@Schema(description = "结束控制点y轴", example = "15890")
|
||||
private String endControlY;
|
||||
|
||||
@Schema(description = "实际开始点位x轴", example = "15890")
|
||||
private String actualStartPointX;
|
||||
|
||||
@Schema(description = "实际开始点位y轴", example = "15890")
|
||||
private String actualStartPointY;
|
||||
|
||||
@Schema(description = "实际结束点位x轴", example = "15890")
|
||||
private String actualEndPointX;
|
||||
|
||||
@Schema(description = "实际结束点位y轴", example = "15890")
|
||||
private String actualEndPointY;
|
||||
|
||||
@Schema(description = "实际开始控制点x轴", example = "15890")
|
||||
private String actualBeginControlX;
|
||||
|
||||
@Schema(description = "实际开始控制点y轴", example = "15890")
|
||||
private String actualBeginControlY;
|
||||
|
||||
@Schema(description = "实际结束控制点x轴", example = "15890")
|
||||
private String actualEndControlX;
|
||||
|
||||
@Schema(description = "实际结束控制点y轴", example = "15890")
|
||||
private String actualEndControlY;
|
||||
|
||||
@Schema(description = "膨胀区域前", example = "15890")
|
||||
private BigDecimal expansionZoneFront;
|
||||
|
||||
@ -61,7 +85,7 @@ public class PositionMapLinePageReqVO extends PageParam {
|
||||
@Schema(description = "膨胀区域右", example = "15890")
|
||||
private BigDecimal expansionZoneRight;
|
||||
|
||||
@Schema(description = "行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
|
||||
@Schema(description = "行走方法 0.直线 1.曲线")
|
||||
private Integer method;
|
||||
|
||||
@Schema(description = "方向 1.单向 2.双向", example = "15890")
|
||||
|
@ -54,6 +54,30 @@ public class PositionMapLineRespVO {
|
||||
@ExcelProperty("结束控制点y轴")
|
||||
private String endControlY;
|
||||
|
||||
@Schema(description = "实际开始点位x轴", example = "15890")
|
||||
private String actualStartPointX;
|
||||
|
||||
@Schema(description = "实际开始点位y轴", example = "15890")
|
||||
private String actualStartPointY;
|
||||
|
||||
@Schema(description = "实际结束点位x轴", example = "15890")
|
||||
private String actualEndPointX;
|
||||
|
||||
@Schema(description = "实际结束点位y轴", example = "15890")
|
||||
private String actualEndPointY;
|
||||
|
||||
@Schema(description = "实际开始控制点x轴", example = "15890")
|
||||
private String actualBeginControlX;
|
||||
|
||||
@Schema(description = "实际开始控制点y轴", example = "15890")
|
||||
private String actualBeginControlY;
|
||||
|
||||
@Schema(description = "实际结束控制点x轴", example = "15890")
|
||||
private String actualEndControlX;
|
||||
|
||||
@Schema(description = "实际结束控制点y轴", example = "15890")
|
||||
private String actualEndControlY;
|
||||
|
||||
@Schema(description = "膨胀区域前", example = "15890")
|
||||
@ExcelProperty("膨胀区域前")
|
||||
private BigDecimal expansionZoneFront;
|
||||
@ -70,8 +94,8 @@ public class PositionMapLineRespVO {
|
||||
@ExcelProperty("膨胀区域右")
|
||||
private BigDecimal expansionZoneRight;
|
||||
|
||||
@Schema(description = "行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
|
||||
@ExcelProperty("行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
|
||||
@Schema(description = "行走方法 0.直线 1.曲线")
|
||||
@ExcelProperty("行走方法 0.直线 1.曲线")
|
||||
private Integer method;
|
||||
|
||||
@Schema(description = "方向 1.单向 2.双向", example = "15890")
|
||||
|
@ -46,6 +46,30 @@ public class PositionMapLineSaveReqVO {
|
||||
@Schema(description = "结束控制点y轴", example = "15890")
|
||||
private String endControlY;
|
||||
|
||||
@Schema(description = "实际开始点位x轴", example = "15890")
|
||||
private String actualStartPointX;
|
||||
|
||||
@Schema(description = "实际开始点位y轴", example = "15890")
|
||||
private String actualStartPointY;
|
||||
|
||||
@Schema(description = "实际结束点位x轴", example = "15890")
|
||||
private String actualEndPointX;
|
||||
|
||||
@Schema(description = "实际结束点位y轴", example = "15890")
|
||||
private String actualEndPointY;
|
||||
|
||||
@Schema(description = "实际开始控制点x轴", example = "15890")
|
||||
private String actualBeginControlX;
|
||||
|
||||
@Schema(description = "实际开始控制点y轴", example = "15890")
|
||||
private String actualBeginControlY;
|
||||
|
||||
@Schema(description = "实际结束控制点x轴", example = "15890")
|
||||
private String actualEndControlX;
|
||||
|
||||
@Schema(description = "实际结束控制点y轴", example = "15890")
|
||||
private String actualEndControlY;
|
||||
|
||||
@Schema(description = "膨胀区域前", example = "15890")
|
||||
private BigDecimal expansionZoneFront;
|
||||
|
||||
@ -58,7 +82,7 @@ public class PositionMapLineSaveReqVO {
|
||||
@Schema(description = "膨胀区域右", example = "15890")
|
||||
private BigDecimal expansionZoneRight;
|
||||
|
||||
@Schema(description = "行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
|
||||
@Schema(description = "行走方法 0.直线 1.曲线")
|
||||
private Integer method;
|
||||
|
||||
@Schema(description = "方向 1.单向 2.双向", example = "15890")
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotInformationService;
|
||||
@ -17,6 +18,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
@ -120,4 +122,12 @@ public class RobotInformationController {
|
||||
PageResult<RobotInformationPageRespVO> pageResult = informationService.getInformationPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, RobotInformationPageRespVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/test")
|
||||
@Operation(summary = "测试")
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> test(@RequestBody RobotStatusDTO dto) {
|
||||
informationService.test(dto);
|
||||
return success(true);
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,38 @@ public class PositionMapLineDO extends BaseDO {
|
||||
* 结束控制点y轴
|
||||
*/
|
||||
private String endControlY;
|
||||
/**
|
||||
* 实际开始点位x轴
|
||||
*/
|
||||
private String actualStartPointX;
|
||||
/**
|
||||
* 实际开始点位y轴
|
||||
*/
|
||||
private String actualStartPointY;
|
||||
/**
|
||||
* 实际结束点位x轴
|
||||
*/
|
||||
private String actualEndPointX;
|
||||
/**
|
||||
* 实际结束点位y轴
|
||||
*/
|
||||
private String actualEndPointY;
|
||||
/**
|
||||
* 实际开始控制点x轴
|
||||
*/
|
||||
private String actualBeginControlX;
|
||||
/**
|
||||
* 实际开始控制点y轴
|
||||
*/
|
||||
private String actualBeginControlY;
|
||||
/**
|
||||
* 实际结束控制点x轴
|
||||
*/
|
||||
private String actualEndControlX;
|
||||
/**
|
||||
* 实际结束控制点y轴
|
||||
*/
|
||||
private String actualEndControlY;
|
||||
/**
|
||||
* 膨胀区域前
|
||||
*/
|
||||
@ -91,7 +123,7 @@ public class PositionMapLineDO extends BaseDO {
|
||||
*/
|
||||
private BigDecimal expansionZoneRight;
|
||||
/**
|
||||
* 行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线
|
||||
* 行走方法 0.直线 1.曲线
|
||||
*/
|
||||
private Integer method;
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ public class DeviceStrategyImpl implements NodeProcessingStrategy {
|
||||
});
|
||||
|
||||
List<DeviceInformationDO> oldList = deviceInformationService.getByMapId(positionMapId);
|
||||
List<List<DeviceInformationDO>> list = CollectionUtils.diffList(oldList, newList,
|
||||
List<List<DeviceInformationDO>> list = CollectionUtils.compareLists(oldList, newList,
|
||||
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId()));
|
||||
deviceInformationService.batchSaveOrEditOrDel(positionMapId, list);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class HouseLocationStrategyImpl implements NodeProcessingStrategy {
|
||||
});
|
||||
|
||||
List<WareHouseLocationDO> oldList = houseLocationService.getByMapId(positionMapId);
|
||||
List<List<WareHouseLocationDO>> list = CollectionUtils.diffList(oldList, newList,
|
||||
List<List<WareHouseLocationDO>> list = CollectionUtils.compareLists(oldList, newList,
|
||||
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId()));
|
||||
houseLocationService.batchSaveOrEditOrDel(positionMapId, list);
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ public class ParkingSpotStrategyImpl implements NodeProcessingStrategy {
|
||||
parkingSpotDO.setPositionMapItemId(item.getId());
|
||||
newList.add(parkingSpotDO);
|
||||
item.setDataJson(JSONUtil.toJsonStr(parkingSpotDO));
|
||||
});
|
||||
});
|
||||
|
||||
List<ParkingSpotDO> oldList = parkingSpotService.getByMapId(positionMapId);
|
||||
List<List<ParkingSpotDO>> list = CollectionUtils.diffList(oldList, newList,
|
||||
List<List<ParkingSpotDO>> list = CollectionUtils.compareLists(oldList, newList,
|
||||
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId()));
|
||||
parkingSpotService.batchSaveOrEditOrDel(positionMapId, list);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class HouseAreaServiceImpl implements HouseAreaService {
|
||||
}
|
||||
|
||||
// -- 这里去判断更新点位的线库信息
|
||||
List<List<PositionMapItemDO>> allList = CollectionUtils.diffList(oldList, list,
|
||||
List<List<PositionMapItemDO>> allList = CollectionUtils.compareLists(oldList, list,
|
||||
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getAreaId(), newVal.getAreaId()));
|
||||
List<PositionMapItemDO> editList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(allList.get(0))) {
|
||||
|
@ -100,7 +100,7 @@ public class WareHouseLaneServiceImpl extends ServiceImpl<WareHouseLaneMapper, W
|
||||
}
|
||||
|
||||
// -- 这里去判断更新点位的线库信息
|
||||
List<List<PositionMapItemDO>> allList = CollectionUtils.diffList(oldList, list,
|
||||
List<List<PositionMapItemDO>> allList = CollectionUtils.compareLists(oldList, list,
|
||||
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getLaneId(), newVal.getLaneId()));
|
||||
List<PositionMapItemDO> editList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(allList.get(0))) {
|
||||
|
@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapLinePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapLineSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapLineDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapLineMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -51,8 +50,10 @@ public class PositionMapLineServiceImpl extends ServiceImpl<PositionMapLineMappe
|
||||
@Override
|
||||
public void createOrEditPositionMapLine(Long positionMapId, List<PositionMapLineSaveReqVO> createReqVO) {
|
||||
List<PositionMapLineDO> newList = BeanUtils.toBean(createReqVO, PositionMapLineDO.class);
|
||||
newList.forEach(a -> a.setPositionMapId(positionMapId));
|
||||
// todo 判断是否有重复数据
|
||||
List<PositionMapLineDO> oldList = this.getByMapId(positionMapId);
|
||||
List<List<PositionMapLineDO>> list = CollectionUtils.diffList(oldList, newList,
|
||||
List<List<PositionMapLineDO>> list = CollectionUtils.compareLists(oldList, newList,
|
||||
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId()));
|
||||
this.batchSaveOrEditOrDel(list);
|
||||
}
|
||||
|
@ -1,18 +1,22 @@
|
||||
package cn.iocoder.yudao.module.system.service.robot;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 车辆信息 Service 接口
|
||||
*
|
||||
* @author 陈宾顺
|
||||
*/
|
||||
public interface RobotInformationService {
|
||||
public interface RobotInformationService extends IService<RobotInformationDO> {
|
||||
|
||||
/**
|
||||
* 创建车辆信息
|
||||
@ -80,4 +84,24 @@ public interface RobotInformationService {
|
||||
* @return
|
||||
*/
|
||||
String getRobotNoByMac(String mac);
|
||||
|
||||
/**
|
||||
* @param dto
|
||||
*/
|
||||
void test(@Valid RobotStatusDTO dto);
|
||||
|
||||
/**
|
||||
* 获取所有的车辆信息 (缓存中获取)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, RobotInformationVO> getAllRobotByRedis();
|
||||
|
||||
/**
|
||||
* 通过macAddress 获取设备基础信息 - 然后存入到redis中
|
||||
*
|
||||
* @param macAddress
|
||||
* @return
|
||||
*/
|
||||
RobotInformationVO getRobotByRedis(String macAddress);
|
||||
}
|
||||
|
@ -5,28 +5,37 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.system.api.robot.RequestProcessor;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotModelDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotModelMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.*;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.CommandTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.RobotStatusEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.RobotTaskModelEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.information.RobotStatisticsTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
@ -38,7 +47,7 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class RobotInformationServiceImpl implements RobotInformationService {
|
||||
public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMapper, RobotInformationDO> implements RobotInformationService {
|
||||
|
||||
@Resource
|
||||
private RobotInformationMapper informationMapper;
|
||||
@ -54,6 +63,10 @@ public class RobotInformationServiceImpl implements RobotInformationService {
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private RequestProcessor processor;
|
||||
// -- 获取所有的设备信息key
|
||||
public static final String key = RobotTaskChcheConstant.ROBOT_GET_ROBOT_INFO;
|
||||
|
||||
@Override
|
||||
public Long createInformation(RobotInformationSaveReqVO createReqVO) {
|
||||
@ -281,7 +294,7 @@ public class RobotInformationServiceImpl implements RobotInformationService {
|
||||
Integer fault = 0;
|
||||
//0:待命、1:任务中、2:锁定、3:离线、4:充电中、5:故障
|
||||
for (RobotInformationDO v : existRobot) {
|
||||
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC +v.getMacAddress();
|
||||
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + v.getMacAddress();
|
||||
Object object = redisUtil.get(pose2dKey);
|
||||
|
||||
if (ObjectUtil.isEmpty(object)) {
|
||||
@ -294,7 +307,7 @@ public class RobotInformationServiceImpl implements RobotInformationService {
|
||||
doLock++;
|
||||
}
|
||||
//设置异常
|
||||
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL +v.getMacAddress();
|
||||
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL + v.getMacAddress();
|
||||
Object errorLevel = redisUtil.get(errorLevelKey);
|
||||
if (ObjectUtil.isNotEmpty(errorLevel) && Integer.valueOf(errorLevel.toString()).intValue() >= 3) {
|
||||
fault++;
|
||||
@ -303,10 +316,10 @@ public class RobotInformationServiceImpl implements RobotInformationService {
|
||||
if (RobotStatusEnum.STAND_BY.getType().equals(v.getRobotStatus())) {
|
||||
//待命中
|
||||
standby++;
|
||||
}else if (RobotStatusEnum.CHARGE.getType().equals(v.getRobotStatus())) {
|
||||
} else if (RobotStatusEnum.CHARGE.getType().equals(v.getRobotStatus())) {
|
||||
//充电中
|
||||
charge++;
|
||||
}else {
|
||||
} else {
|
||||
//任务中
|
||||
inTask++;
|
||||
}
|
||||
@ -365,4 +378,66 @@ public class RobotInformationServiceImpl implements RobotInformationService {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(RobotStatusDTO robotStatusDataDTO) {
|
||||
TenantContextHolder.setTenantId(1L);
|
||||
if (ObjectUtil.isEmpty(robotStatusDataDTO) || ObjectUtil.isEmpty(robotStatusDataDTO.getMac())) {
|
||||
return;
|
||||
}
|
||||
// -- 通过mac 地址获取车辆信息 - (并且加入到缓存中)
|
||||
Map<String, RobotInformationVO> robotInformationVOS = this.getAllRobotByRedis();
|
||||
RobotInformationVO robotInformationVO = robotInformationVOS.get(robotStatusDataDTO.getMac());
|
||||
if (robotInformationVO == null) {
|
||||
robotInformationVO = this.getRobotByRedis(robotStatusDataDTO.getMac());
|
||||
}
|
||||
|
||||
RobotStatusDataPoseDTO robotStatusDataPoseDTO = new RobotStatusDataPoseDTO();
|
||||
robotStatusDataPoseDTO.setX(robotStatusDataDTO.getData().getPose2d().getX());
|
||||
robotStatusDataPoseDTO.setY(robotStatusDataDTO.getData().getPose2d().getY());
|
||||
robotStatusDataPoseDTO.setYaw(robotStatusDataDTO.getData().getPose2d().getYaw());
|
||||
robotStatusDataPoseDTO.setFloor(robotStatusDataDTO.getData().getFloor_zone().getFloor());
|
||||
robotStatusDataPoseDTO.setArea(robotStatusDataDTO.getData().getFloor_zone().getArea());
|
||||
robotStatusDataPoseDTO.setBat_soc(robotStatusDataDTO.getData().getPose2d().getBat_soc());
|
||||
|
||||
robotInformationVO.setPose2d(robotStatusDataPoseDTO);
|
||||
|
||||
// 模拟请求
|
||||
processor.handleRequest(robotStatusDataDTO.getData().getFloor_zone().getFloor() + "_" + robotStatusDataDTO.getData().getFloor_zone().getArea(),
|
||||
robotStatusDataDTO.getMac(), JSONUtil.toJsonStr(robotInformationVO));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, RobotInformationVO> getAllRobotByRedis() {
|
||||
Object o = redisUtil.get(key);
|
||||
if (ObjectUtil.isNotEmpty(o)) {
|
||||
// 化作列表
|
||||
List<RobotInformationVO> list = JSONUtil.toList(o.toString(), RobotInformationVO.class);
|
||||
return list.stream().collect(Collectors.toMap(RobotInformationVO::getMacAddress, Function.identity()));
|
||||
} else {
|
||||
List<RobotInformationDO> allRobotInfoList = this.list();
|
||||
List<RobotInformationVO> list = BeanUtil.copyToList(allRobotInfoList, RobotInformationVO.class);
|
||||
redisUtil.set(key, JSONUtil.toJsonStr(list));
|
||||
return list.stream().collect(Collectors.toMap(RobotInformationVO::getMacAddress, Function.identity()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RobotInformationVO getRobotByRedis(String macAddress) {
|
||||
// todo -- 如果说有一个设备的mac 一直都不在库里 会出现缓存穿透的问题 - 后续如果出现这种情况的话 - 考虑将null值也存入到缓存中
|
||||
RobotInformationDO item = this.getOne(new LambdaQueryWrapper<RobotInformationDO>().eq(RobotInformationDO::getMacAddress, macAddress));
|
||||
// -- 将获取到的存入到redis中
|
||||
if (ObjectUtil.isNotEmpty(item)) {
|
||||
RobotInformationVO vo = BeanUtil.toBean(item, RobotInformationVO.class);
|
||||
List<RobotInformationVO> list = new ArrayList<>();
|
||||
Object o = redisUtil.get(key);
|
||||
if (ObjectUtil.isNotEmpty(o)) {
|
||||
list = JSONUtil.toList(o.toString(), RobotInformationVO.class);
|
||||
}
|
||||
list.add(vo);
|
||||
redisUtil.set(key, JSONUtil.toJsonStr(list));
|
||||
return vo;
|
||||
}
|
||||
return new RobotInformationVO();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user