Merge branch 'dev' into cbs

# Conflicts:
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/robot/RobotInformationServiceImpl.java
This commit is contained in:
cbs 2025-02-15 09:18:37 +08:00
commit 570852382f
27 changed files with 388 additions and 127 deletions

View File

@ -16,7 +16,8 @@ public enum NodeTypeEnum {
DEVICE(3, "设备点"),
PARKING(4, "停车点"),
CHANGE(5, "区域变更点"),
WAIT(6, "等待点");
WAIT(6, "等待点"),
TEXT(7, "文字点");
/**
* 类型

View File

@ -44,10 +44,10 @@ public abstract class AbstractWebSocketMessageSender implements WebSocketMessage
/**
* 发送消息
*
* @param sessionId Session 编号
* @param userType 用户类型
* @param userId 用户编号
* @param messageType 消息类型
* @param sessionId Session 编号
* @param userType 用户类型
* @param userId 用户编号
* @param messageType 消息类型
* @param messageContent 消息内容
*/
public void send(String sessionId, Integer userType, Long userId, String messageType, String messageContent) {
@ -57,6 +57,12 @@ public abstract class AbstractWebSocketMessageSender implements WebSocketMessage
WebSocketSession session = sessionManager.getSession(sessionId);
if (session != null) {
sessions = Collections.singletonList(session);
} else {
// -- 这里用于获取地图的webSocket
session = sessionManager.getMapSession(sessionId);
if (session != null){
sessions = Collections.singletonList(session);
}
}
} else if (userType != null && userId != null) {
sessions = (List<WebSocketSession>) sessionManager.getSessionList(userType, userId);
@ -74,8 +80,8 @@ public abstract class AbstractWebSocketMessageSender implements WebSocketMessage
/**
* 发送消息的具体实现
*
* @param sessions Session 列表
* @param messageType 消息类型
* @param sessions Session 列表
* @param messageType 消息类型
* @param messageContent 消息内容
*/
public void doSend(Collection<WebSocketSession> sessions, String messageType, String messageContent) {

View File

@ -33,6 +33,14 @@ public interface WebSocketSessionManager {
*/
WebSocketSession getSession(String id);
/**
* 根据 地图 +"_"+ 获取session
*
* @param key
* @return
*/
WebSocketSession getMapSession(String key);
/**
* 获得指定用户类型的 Session 列表
*
@ -45,9 +53,9 @@ public interface WebSocketSessionManager {
* 获得指定用户编号的 Session 列表
*
* @param userType 用户类型
* @param userId 用户编号
* @param userId 用户编号
* @return Session 列表
*/
Collection<WebSocketSession> getSessionList(Integer userType, Long userId);
}
}

View File

@ -1,15 +1,14 @@
package cn.iocoder.yudao.framework.websocket.core.session;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.http.HttpUtil;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.websocket.core.util.WebSocketFrameworkUtils;
import org.springframework.web.socket.WebSocketSession;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
@ -23,63 +22,87 @@ public class WebSocketSessionManagerImpl implements WebSocketSessionManager {
/**
* id WebSocketSession 映射
*
* <p>
* keySession 编号
*/
private final ConcurrentMap<String, WebSocketSession> idSessions = new ConcurrentHashMap<>();
/**
* user WebSocketSession 映射
*
* <p>
* key1用户类型
* key2用户编号
*/
private final ConcurrentMap<Integer, ConcurrentMap<Long, CopyOnWriteArrayList<WebSocketSession>>> userSessions
= new ConcurrentHashMap<>();
/**
* 地图 WebSocketSession 映射
* <p>
* key地图地址 +'_'+
*/
private final ConcurrentMap<String, WebSocketSession> mapSessions = new ConcurrentHashMap<>();
@Override
public void addSession(WebSocketSession session) {
// 添加到 idSessions
idSessions.put(session.getId(), session);
// 添加到 userSessions
LoginUser user = WebSocketFrameworkUtils.getLoginUser(session);
if (user == null) {
return;
}
ConcurrentMap<Long, CopyOnWriteArrayList<WebSocketSession>> userSessionsMap = userSessions.get(user.getUserType());
if (userSessionsMap == null) {
userSessionsMap = new ConcurrentHashMap<>();
if (userSessions.putIfAbsent(user.getUserType(), userSessionsMap) != null) {
userSessionsMap = userSessions.get(user.getUserType());
// 解析 session Url 中参数
Map<String, String> paramMap = HttpUtil.decodeParamMap(String.valueOf(session.getUri()), StandardCharsets.UTF_8);
String type = paramMap.get("type");
// -- 如果是地图里面过来的
if ("map".equals(type)) {
mapSessions.put(paramMap.get("floor") + "_" + paramMap.get("area"), session);
} else {
// 添加到 idSessions
idSessions.put(session.getId(), session);
// 添加到 userSessions
LoginUser user = WebSocketFrameworkUtils.getLoginUser(session);
if (user == null) {
return;
}
}
CopyOnWriteArrayList<WebSocketSession> sessions = userSessionsMap.get(user.getId());
if (sessions == null) {
sessions = new CopyOnWriteArrayList<>();
if (userSessionsMap.putIfAbsent(user.getId(), sessions) != null) {
sessions = userSessionsMap.get(user.getId());
ConcurrentMap<Long, CopyOnWriteArrayList<WebSocketSession>> userSessionsMap = userSessions.get(user.getUserType());
if (userSessionsMap == null) {
userSessionsMap = new ConcurrentHashMap<>();
if (userSessions.putIfAbsent(user.getUserType(), userSessionsMap) != null) {
userSessionsMap = userSessions.get(user.getUserType());
}
}
CopyOnWriteArrayList<WebSocketSession> sessions = userSessionsMap.get(user.getId());
if (sessions == null) {
sessions = new CopyOnWriteArrayList<>();
if (userSessionsMap.putIfAbsent(user.getId(), sessions) != null) {
sessions = userSessionsMap.get(user.getId());
}
}
sessions.add(session);
}
sessions.add(session);
}
@Override
public void removeSession(WebSocketSession session) {
// 移除从 idSessions
idSessions.remove(session.getId());
// 移除从 idSessions
LoginUser user = WebSocketFrameworkUtils.getLoginUser(session);
if (user == null) {
return;
}
ConcurrentMap<Long, CopyOnWriteArrayList<WebSocketSession>> userSessionsMap = userSessions.get(user.getUserType());
if (userSessionsMap == null) {
return;
}
CopyOnWriteArrayList<WebSocketSession> sessions = userSessionsMap.get(user.getId());
sessions.removeIf(session0 -> session0.getId().equals(session.getId()));
if (CollUtil.isEmpty(sessions)) {
userSessionsMap.remove(user.getId(), sessions);
// 解析 session Url 中参数
Map<String, String> paramMap = HttpUtil.decodeParamMap(String.valueOf(session.getUri()), StandardCharsets.UTF_8);
String type = paramMap.get("type");
// -- 如果是地图里面过来的
if ("map".equals(type)) {
mapSessions.remove(paramMap.get("floor") + "_" + paramMap.get("area"), session);
} else {
// 移除从 idSessions
idSessions.remove(session.getId());
// 移除从 idSessions
LoginUser user = WebSocketFrameworkUtils.getLoginUser(session);
if (user == null) {
return;
}
ConcurrentMap<Long, CopyOnWriteArrayList<WebSocketSession>> userSessionsMap = userSessions.get(user.getUserType());
if (userSessionsMap == null) {
return;
}
CopyOnWriteArrayList<WebSocketSession> sessions = userSessionsMap.get(user.getId());
sessions.removeIf(session0 -> session0.getId().equals(session.getId()));
if (CollUtil.isEmpty(sessions)) {
userSessionsMap.remove(user.getId(), sessions);
}
}
}
@ -88,6 +111,11 @@ public class WebSocketSessionManagerImpl implements WebSocketSessionManager {
return idSessions.get(id);
}
@Override
public WebSocketSession getMapSession(String key) {
return mapSessions.get(key);
}
@Override
public Collection<WebSocketSession> getSessionList(Integer userType) {
ConcurrentMap<Long, CopyOnWriteArrayList<WebSocketSession>> userSessionsMap = userSessions.get(userType);

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.system.api.robot.dto;
import lombok.Data;
/**
* 楼层区域
*/
@Data
public class FloorZoneDTO {
//地图所在楼
public String floor;
//地图所在区
public String area;
}

View File

@ -9,6 +9,11 @@ import java.util.List;
*/
@Data
public class RobotStatusDataDTO {
/**
* 楼层区域
*/
public FloorZoneDTO floor_zone;
/**
* 机器人位姿
*/

View File

@ -9,6 +9,7 @@ import lombok.Data;
public class RobotStatusDataPoseDTO {
public String y;
public String x;
//弧度
public String yaw;
//楼层
public String floor;

View File

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.system.api.robot;
import cn.hutool.core.map.MapUtil;
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Component
@Slf4j
public class RequestProcessor {
private final ConcurrentHashMap<String, ConcurrentHashMap<String, String>> cache = new ConcurrentHashMap<>();
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
@Resource
public WebSocketSenderApi webSocketSenderApi;
public RequestProcessor() {
// 每秒执行一次 - 处理并发送数据 - 避免数据丢失
scheduler.scheduleAtFixedRate(this::processAndSend, 1, 1, TimeUnit.SECONDS);
}
public void handleRequest(String map, String mac, String data) {
cache.computeIfAbsent(map, k -> new ConcurrentHashMap<>()).put(mac, data);
}
private void processAndSend() {
Map<String, ConcurrentHashMap<String, String>> snapshot = new ConcurrentHashMap<>(cache); // 创建快照
cache.clear(); // 先清理缓存
for (Map.Entry<String, ConcurrentHashMap<String, String>> entry : snapshot.entrySet()) {
if (!MapUtil.isEmpty(entry.getValue())) {
sendData(entry.getKey(), entry.getValue());
}
}
}
private void sendData(String map, Map<String, String> data) {
// -- 发送给对应的websocket
// System.out.println("key:" + map + "发送数据:" + data);
log.info("key:" + map + "发送数据:" + data);
webSocketSenderApi.sendObject(map, "map_push", data);
}
public void shutdown() {
scheduler.shutdown();
}
@PreDestroy
public void destroy() {
// 在Bean销毁前关闭去啊
shutdown();
}
}

View File

@ -54,8 +54,12 @@ public class RobotStatusApiImpl implements RobotStatusApi {
@Value("${zn.robot_error_level_time:30}")
private Long robotErrorLevelTime;
@Resource
private RequestProcessor processor;
/**
* 更新机器人点位/异常/能否做任务
*
* @param robotStatusDataDTO
* @return
*/
@ -68,26 +72,31 @@ public class RobotStatusApiImpl implements RobotStatusApi {
return;
}
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS +robotStatusDataDTO.getMac();
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED +robotStatusDataDTO.getMac();
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC +robotStatusDataDTO.getMac();
redisUtil.set(taskStatusKey, robotStatusDataDTO.getData().getTask_status(),robotPositionCacheTime);
redisUtil.set(cargoDetectedKey,robotStatusDataDTO.getData().getCargo_detected(),robotPositionCacheTime);
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS + robotStatusDataDTO.getMac();
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robotStatusDataDTO.getMac();
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robotStatusDataDTO.getMac();
redisUtil.set(taskStatusKey, robotStatusDataDTO.getData().getTask_status(), robotPositionCacheTime);
redisUtil.set(cargoDetectedKey, robotStatusDataDTO.getData().getCargo_detected(), robotPositionCacheTime);
Object object = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO= JSONUtil.toBean((String)object, RobotStatusDataPoseDTO.class);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
robotStatusDataPoseDTO.setX(robotStatusDataDTO.getData().getPose2d().getX());
robotStatusDataPoseDTO.setY(robotStatusDataDTO.getData().getPose2d().getY());
robotStatusDataPoseDTO.setYaw(robotStatusDataDTO.getData().getPose2d().getYaw());
robotStatusDataPoseDTO.setFloor(robotStatusDataDTO.getData().getPose2d().getFloor());
robotStatusDataPoseDTO.setArea(robotStatusDataDTO.getData().getPose2d().getArea());
redisUtil.set(pose2dKey,JSON.toJSONString(robotStatusDataPoseDTO),robotPositionCacheTime);
robotStatusDataPoseDTO.setFloor(robotStatusDataDTO.getData().getFloor_zone().getFloor());
robotStatusDataPoseDTO.setArea(robotStatusDataDTO.getData().getFloor_zone().getArea());
redisUtil.set(pose2dKey, JSON.toJSONString(robotStatusDataPoseDTO), robotPositionCacheTime);
// 合并请求 - 这里接受到的数据都丢给 RequestProcessor - 再整合数据通过WebSocket丢给前端
processor.handleRequest(robotStatusDataPoseDTO.getFloor() + "_" + robotStatusDataPoseDTO.getArea(),
robotStatusDataDTO.getMac(), JSONUtil.toJsonStr(robotStatusDataDTO.getData().getPose2d()));
if (ObjectUtil.isNotNull(robotStatusDataDTO.getData().getErr_code())) {
List<RobotStatusDataErrorDTO> errCode = robotStatusDataDTO.getData().getErr_code();
String robotNo = robotInformationService.getRobotNoByMac(robotStatusDataDTO.getMac());
if (ObjectUtil.isNull(robotNo)) {
log.info("查不到机器人编号 :{}",robotStatusDataDTO.getMac());
log.info("查不到机器人编号 :{}", robotStatusDataDTO.getMac());
return;
}
@ -95,7 +104,7 @@ public class RobotStatusApiImpl implements RobotStatusApi {
errCode.stream().map(RobotStatusDataErrorDTO::getError_code).collect(Collectors.toList());
List<RobotWarnCodeMappingDO> robotWarnCodeMappingDOS =
warnCodeMappingMapper.selectList(new LambdaQueryWrapper<RobotWarnCodeMappingDO>()
.in(RobotWarnCodeMappingDO::getWarnCode, warnCodes));
.in(RobotWarnCodeMappingDO::getWarnCode, warnCodes));
if (ObjectUtil.isEmpty(robotWarnCodeMappingDOS)) {
log.info("查不对应编号的告警信息 :{}", JSON.toJSONString(warnCodes));
return;
@ -107,7 +116,7 @@ public class RobotStatusApiImpl implements RobotStatusApi {
List<RobotWarnMsgDO> warnMsgDOS = new ArrayList<>();
//机器人异常等级
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL +robotStatusDataDTO.getMac();
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL + robotStatusDataDTO.getMac();
Object errorLevel = redisUtil.get(errorLevelKey);
Integer level = ObjectUtil.isEmpty(errorLevel) ? 0 : Integer.valueOf(errorLevel.toString());
@ -119,7 +128,7 @@ public class RobotStatusApiImpl implements RobotStatusApi {
List<RobotWarnCodeMappingDO> mappingDOS = warnCodeMapping.get(robotStatusData.getError_code());
if (ObjectUtil.isEmpty(mappingDOS)) {
log.info("当前告警类型查不到对应的告警信息 :{}",robotStatusData.getError_code());
log.info("当前告警类型查不到对应的告警信息 :{}", robotStatusData.getError_code());
continue;
}
RobotWarnMsgDO warnMsg = RobotWarnMsgDO.builder().warnLevel(Integer.valueOf(robotStatusData.getCode_level()))
@ -131,12 +140,11 @@ public class RobotStatusApiImpl implements RobotStatusApi {
.build();
warnMsgDOS.add(warnMsg);
}
redisUtil.set(errorLevelKey,level,robotErrorLevelTime);
redisUtil.set(errorLevelKey, level, robotErrorLevelTime);
warnMsgMapper.insertBatch(warnMsgDOS);
}
}
}

View File

@ -82,8 +82,8 @@ public class HouseAreaController {
@GetMapping("/getHouseAreaList")
@Operation(summary = "获得全部库区")
@PreAuthorize("@ss.hasPermission('ware:house-area:query')")
public CommonResult<List<HouseAreaRespVO>> getHouseAreaList() {
List<HouseAreaDO> list = houseAreaService.getHouseAreaList();
public CommonResult<List<HouseAreaRespVO>> getHouseAreaList(@RequestParam Long positionMapId) {
List<HouseAreaDO> list = houseAreaService.getHouseAreaList(positionMapId);
return success(BeanUtils.toBean(list, HouseAreaRespVO.class));
}

View File

@ -84,7 +84,7 @@ public class DeviceInformationController {
@PostMapping("/mapBindDeviceInfo")
@Operation(summary = "地图绑定设备")
public CommonResult<Boolean> mapBindDeviceInfo(@Valid MapBindDeviceInfoDTO dto) {
public CommonResult<Boolean> mapBindDeviceInfo(@Valid @RequestBody MapBindDeviceInfoDTO dto) {
informationService.mapBindDeviceInfo(dto);
return success(true);
}

View File

@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMa
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;
@ -43,6 +44,12 @@ 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 = "批量新增编辑删除节点")

View File

@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.controller.admin.positionmap;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapLineRespVO;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapLineSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapLineDO;

View File

@ -1,11 +1,12 @@
package cn.iocoder.yudao.module.system.controller.admin.positionmap.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.system.controller.admin.positionmap.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -27,6 +28,30 @@ public class PositionMapLinePageReqVO extends PageParam {
@Schema(description = "结束点id(点位子表id)", example = "15890")
private Long endPointId;
@Schema(description = "开始控制点x轴", example = "15890")
private String beginControlX;
@Schema(description = "开始控制点y轴", example = "15890")
private String beginControlY;
@Schema(description = "结束控制点x轴", example = "15890")
private String endControlX;
@Schema(description = "结束控制点y轴", example = "15890")
private String endControlY;
@Schema(description = "膨胀区域前", example = "15890")
private BigDecimal expansionZoneFront;
@Schema(description = "膨胀区域后", example = "15890")
private BigDecimal expansionZoneAfter;
@Schema(description = "膨胀区域左", example = "15890")
private BigDecimal expansionZoneLeft;
@Schema(description = "膨胀区域右", example = "15890")
private BigDecimal expansionZoneRight;
@Schema(description = "行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
private Integer method;

View File

@ -29,6 +29,38 @@ public class PositionMapLineRespVO {
@ExcelProperty("结束点id(点位子表id)")
private Long endPointId;
@Schema(description = "开始控制点x轴", example = "15890")
@ExcelProperty("开始控制点x轴")
private String beginControlX;
@Schema(description = "开始控制点y轴", example = "15890")
@ExcelProperty("开始控制点y轴")
private String beginControlY;
@Schema(description = "结束控制点x轴", example = "15890")
@ExcelProperty("结束控制点x轴")
private String endControlX;
@Schema(description = "结束控制点y轴", example = "15890")
@ExcelProperty("结束控制点y轴")
private String endControlY;
@Schema(description = "膨胀区域前", example = "15890")
@ExcelProperty("膨胀区域前")
private BigDecimal expansionZoneFront;
@Schema(description = "膨胀区域后", example = "15890")
@ExcelProperty("膨胀区域后")
private BigDecimal expansionZoneAfter;
@Schema(description = "膨胀区域左", example = "15890")
@ExcelProperty("膨胀区域左")
private BigDecimal expansionZoneLeft;
@Schema(description = "膨胀区域右", example = "15890")
@ExcelProperty("膨胀区域右")
private BigDecimal expansionZoneRight;
@Schema(description = "行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
@ExcelProperty("行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
private Integer method;

View File

@ -25,6 +25,30 @@ public class PositionMapLineSaveReqVO {
@Schema(description = "结束点id(点位子表id)", example = "15890")
private Long endPointId;
@Schema(description = "开始控制点x轴", example = "15890")
private String beginControlX;
@Schema(description = "开始控制点y轴", example = "15890")
private String beginControlY;
@Schema(description = "结束控制点x轴", example = "15890")
private String endControlX;
@Schema(description = "结束控制点y轴", example = "15890")
private String endControlY;
@Schema(description = "膨胀区域前", example = "15890")
private BigDecimal expansionZoneFront;
@Schema(description = "膨胀区域后", example = "15890")
private BigDecimal expansionZoneAfter;
@Schema(description = "膨胀区域左", example = "15890")
private BigDecimal expansionZoneLeft;
@Schema(description = "膨胀区域右", example = "15890")
private BigDecimal expansionZoneRight;
@Schema(description = "行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线")
private Integer method;

View File

@ -1,32 +1,30 @@
package cn.iocoder.yudao.module.system.controller.admin.robot;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
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.controller.admin.robot.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
import cn.iocoder.yudao.module.system.service.robot.RobotInformationService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 车辆信息")
@RestController
@ -83,12 +81,12 @@ public class RobotInformationController {
@PreAuthorize("@ss.hasPermission('robot:information:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportInformationExcel(@Valid RobotInformationPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<RobotInformationPageRespVO> list = informationService.getInformationPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "车辆信息.xls", "数据", RobotInformationPageRespVO.class,
BeanUtils.toBean(list, RobotInformationPageRespVO.class));
BeanUtils.toBean(list, RobotInformationPageRespVO.class));
}
@PostMapping("/statistics")
@ -122,4 +120,4 @@ public class RobotInformationController {
PageResult<RobotInformationPageRespVO> pageResult = informationService.getInformationPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, RobotInformationPageRespVO.class));
}
}
}

View File

@ -6,7 +6,10 @@ import cn.iocoder.yudao.module.system.framework.sms.core.enums.SmsChannelEnum;
import cn.iocoder.yudao.module.system.service.sms.SmsSendService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
@ -30,7 +33,6 @@ public class SmsCallbackController {
smsSendService.receiveSmsStatus(SmsChannelEnum.ALIYUN.getCode(), text);
return success(true);
}
@PostMapping("/tencent")
@PermitAll
@Operation(summary = "腾讯云短信的回调", description = "参见 https://cloud.tencent.com/document/product/382/52077 文档")
@ -57,4 +59,4 @@ public class SmsCallbackController {
return success(true);
}
}
}

View File

@ -42,6 +42,38 @@ public class PositionMapLineDO extends BaseDO {
* 结束点id(点位子表id)
*/
private Long endPointId;
/**
* 开始控制点x轴
*/
private String beginControlX;
/**
* 开始控制点y轴
*/
private String beginControlY;
/**
* 结束控制点x轴
*/
private String endControlX;
/**
* 结束控制点y轴
*/
private String endControlY;
/**
* 膨胀区域前
*/
private BigDecimal expansionZoneFront;
/**
* 膨胀区域后
*/
private BigDecimal expansionZoneAfter;
/**
* 膨胀区域左
*/
private BigDecimal expansionZoneLeft;
/**
* 膨胀区域右
*/
private BigDecimal expansionZoneRight;
/**
* 行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线
*/

View File

@ -50,6 +50,8 @@ public class NodeProcessingContext {
strategyMap.put(NodeTypeEnum.CHANGE.getType(), mapNodeStrategyImpl);
// 等待点
strategyMap.put(NodeTypeEnum.WAIT.getType(), mapNodeStrategyImpl);
// 文字点
strategyMap.put(NodeTypeEnum.TEXT.getType(), mapNodeStrategyImpl);
// todo 可以继续添加更多的策略 - 新增实现即可
}

View File

@ -64,5 +64,5 @@ public interface HouseAreaService {
* 获得全部库区
* @return
*/
List<HouseAreaDO> getHouseAreaList();
List<HouseAreaDO> getHouseAreaList(Long positionMapId);
}

View File

@ -14,7 +14,6 @@ import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.PositionM
import cn.iocoder.yudao.module.system.dal.dataobject.housearea.HouseAreaDO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotModelDO;
import cn.iocoder.yudao.module.system.dal.mysql.housearea.HouseAreaMapper;
import cn.iocoder.yudao.module.system.service.houselocation.HouseLocationService;
import cn.iocoder.yudao.module.system.service.positionmap.PositionMapItemService;
@ -157,10 +156,10 @@ public class HouseAreaServiceImpl implements HouseAreaService {
}
@Override
public List<HouseAreaDO> getHouseAreaList() {
List<HouseAreaDO> list = houseAreaMapper.selectList(new LambdaQueryWrapper<HouseAreaDO>()
public List<HouseAreaDO> getHouseAreaList(Long positionMapId) {
return houseAreaMapper.selectList(new LambdaQueryWrapper<HouseAreaDO>()
.eq(HouseAreaDO::getPositionMapId, positionMapId)
.orderByAsc(HouseAreaDO::getId));
return list;
}
}

View File

@ -72,9 +72,11 @@ public class PositionMapItemServiceImpl extends ServiceImpl<PositionMapItemMappe
public void batchSaveOrEditOrDel(Long positionMapId, List<List<PositionMapItemDO>> list) {
//批量添加修改删除
if (isNotEmpty(list.get(0))) {
list.get(0).forEach(a -> a.setPositionMapId(positionMapId));
positionMapItemMapper.insertBatch(list.get(0));
}
if (isNotEmpty(list.get(1))) {
list.get(1).forEach(a -> a.setPositionMapId(positionMapId));
positionMapItemMapper.updateBatch(list.get(1));
}
if (isNotEmpty(list.get(2))) {

View File

@ -1,12 +1,12 @@
package cn.iocoder.yudao.module.system.service.robot;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
import javax.validation.Valid;
import java.util.List;
/**
* 车辆信息 Service 接口
*
@ -54,27 +54,30 @@ public interface RobotInformationService {
/**
* 统计车辆待命/任务中/离线
*
* @return
*/
RobotInformationStatisticsVO statisticsInformation();
/**
* 查询能正常使用的车辆
*
* @return
*/
List<RobotInformationDO> getCanUseRobot();
/**
* 查询所有车辆
*
* @return
*/
List<RobotInformationDO> getAllRobot();
/**
* 查询机器人编号
*
* @param mac
* @return
*/
String getRobotNoByMac(String mac);
}
}

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.system.service.robot;
import cn.hutool.core.bean.BeanUtil;
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.module.system.api.robot.dto.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.*;
@ -19,13 +21,12 @@ import cn.iocoder.yudao.module.system.enums.robot.information.RobotStatisticsTyp
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
@ -106,7 +107,7 @@ public class RobotInformationServiceImpl implements RobotInformationService {
// 更新
RobotInformationDO updateObj = BeanUtils.toBean(updateReqVO, RobotInformationDO.class);
informationMapper.updateById(updateObj);
redisUtil.set(RobotTaskChcheConstant.ROBOT_GET_ROBOTNO_BY_MAC + updateObj.getMacAddress(),updateObj.getRobotNo());
redisUtil.set(RobotTaskChcheConstant.ROBOT_GET_ROBOTNO_BY_MAC + updateObj.getMacAddress(), updateObj.getRobotNo());
}
@Override
@ -156,7 +157,7 @@ public class RobotInformationServiceImpl implements RobotInformationService {
List<RobotInformationPageRespVO> resultList = new ArrayList<>();
for (RobotInformationPageRespVO v : targetList) {
if (RobotStatisticsTypeEnum.STANDBY.getType().equals(pageReqVO.getRobotStatisticsType())
&& v.getRobotTaskStatus().equals(0)) {
&& v.getRobotTaskStatus().equals(0)) {
resultList.add(v);
continue;
}
@ -191,7 +192,7 @@ public class RobotInformationServiceImpl implements RobotInformationService {
}
}
dataPage.setList(resultList);
}else {
} else {
dataPage.setList(targetList);
}
@ -200,14 +201,15 @@ public class RobotInformationServiceImpl implements RobotInformationService {
/**
* 设置状态和信息
*
* @param v
*/
private void setMsgAndRobotStatus(RobotInformationPageRespVO v) {
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);
RobotStatusDataPoseDTO robotStatusDataPoseDTO= JSONUtil.toBean((String)object, RobotStatusDataPoseDTO.class);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
String robotDoingActionKey = RobotTaskChcheConstant.ROBOT_QUERY_DOING_ACTION +v.getMacAddress();
String robotDoingActionKey = RobotTaskChcheConstant.ROBOT_QUERY_DOING_ACTION + v.getMacAddress();
Object action = redisUtil.get(robotDoingActionKey);
if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) {
@ -219,7 +221,7 @@ public class RobotInformationServiceImpl implements RobotInformationService {
v.setRobotEssenceStatus(v.getRobotTaskModel());
//设置异常
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) {
v.setRobotEssenceStatus(2);
@ -229,18 +231,18 @@ public class RobotInformationServiceImpl implements RobotInformationService {
//待命中
v.setRobotTaskStatus(0);
v.setMsg("车辆正在待命中");
}else if (RobotStatusEnum.CHARGE.getType().equals(v.getRobotStatus())) {
} else if (RobotStatusEnum.CHARGE.getType().equals(v.getRobotStatus())) {
//充电中
v.setRobotTaskStatus(2);
v.setMsg("车辆正在充电");
}else {
} else {
//任务中
v.setRobotTaskStatus(1);
if (RobotStatusEnum.DOING.getType().equals(v.getRobotStatus()) && ObjectUtil.isNotEmpty(action)) {
v.setRobotStatus(1);
CommandTypeEnum commandType = CommandTypeEnum.getCommandType(String.valueOf(action));
if (ObjectUtil.isNotEmpty(commandType)) {
v.setMsg("车辆正在"+commandType.getMsg());
v.setMsg("车辆正在" + commandType.getMsg());
}
}
}
@ -249,6 +251,7 @@ public class RobotInformationServiceImpl implements RobotInformationService {
/**
* 统计车辆待命/任务中/离线
*
* @return
*/
@Override
@ -310,7 +313,6 @@ public class RobotInformationServiceImpl implements RobotInformationService {
}
/**
*
* @return
*/
@Override
@ -328,6 +330,7 @@ public class RobotInformationServiceImpl implements RobotInformationService {
/**
* 根据mac查询机器人编号
*
* @param mac
* @return
*/
@ -346,10 +349,10 @@ public class RobotInformationServiceImpl implements RobotInformationService {
.eq(RobotInformationDO::getMacAddress, mac)
.last("limit 1"));
if (ObjectUtil.isNotEmpty(robotInformationDO)) {
redisUtil.set(RobotTaskChcheConstant.ROBOT_GET_ROBOTNO_BY_MAC + mac,robotInformationDO.getRobotNo());
redisUtil.set(RobotTaskChcheConstant.ROBOT_GET_ROBOTNO_BY_MAC + mac, robotInformationDO.getRobotNo());
return robotInformationDO.getRobotNo();
}
return "";
}
}
}

View File

@ -58,7 +58,7 @@ spring:
primary: master
datasource:
master:
url: jdbc:mysql://47.97.8.94:3306/zn_wcs?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
url: jdbc:mysql://47.97.8.94:3306/zn_wcs?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&allowMultiQueries=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
@ -72,7 +72,7 @@ spring:
# password: SYSDBA # DM 连接的示例
slave: # 模拟从库,可根据自己需要修改
lazy: true # 开启懒加载,保证启动速度
url: jdbc:mysql://47.97.8.94:3306/zn_wcs?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
url: jdbc:mysql://47.97.8.94:3306/zn_wcs?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&allowMultiQueries=true
username: root
password: yhtkj@2024!
@ -230,4 +230,4 @@ zn:
robot_position_cache_time: 10 #机器人上报点位存储时间(秒)
cycle_do_auto_move: true #存在循环的任务,是否开启自动移库. true:存在循环任务,开启自动移库; false有循环任务不自动移库
full_electricity: 100 #机器人充满电的电量
robot_error_level_time: 30 #机器人异常存储时间(秒)
robot_error_level_time: 30 #机器人异常存储时间(秒)