机器人响应式状态上报
This commit is contained in:
parent
df8c8b28c6
commit
9296aabd48
@ -55,4 +55,25 @@ public class TaskToPathPlanningDTO {
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "取货高度")
|
||||
private Double takeHeight;
|
||||
|
||||
@Schema(description = "放货高度")
|
||||
private Double releaseHeight;
|
||||
|
||||
@Schema(description = "等待点")
|
||||
private List<String> waitIds;
|
||||
|
||||
@Schema(description = "取的层数")
|
||||
private Integer takeLevel;
|
||||
|
||||
@Schema(description = "放的层数")
|
||||
private Integer releaseLevel;
|
||||
|
||||
@Schema(description = "取货-叉起货需要在原来高度基础上偏移的高度")
|
||||
private Double takeOffsetHeight;
|
||||
|
||||
@Schema(description = "取货-叉起货需要在原来高度基础上偏移的高度")
|
||||
private Double releaseOffsetHeight;
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public enum DefineSubTopicEnum {
|
||||
//qos 0-至多1次、1-至少1次、2-正好一次
|
||||
ROBOT_STATUS("ROBOT_STATUS", 0,"点位"),
|
||||
ROBOT_TASK_STATUS("ROBOT_TASK_STATUS", 0,"机器人任务完成上报"),
|
||||
ROBOT_REACTIVE_STATUS("ROBOT_REACTIVE_STATUS", 0,"机器人响应式状态上报"),
|
||||
ROBOT_GENERICS_STATUS("ROBOT_GENERICS_STATUS", 0,"机器人异常"),
|
||||
SYNCHRONOUS_ALL_MAP_REQUEST("SYNCHRONOUS_ALL_MAP_REQUEST", 0,"路径规划需要初始数据上报"),
|
||||
TASK_ASSIGNMENT_FEEDBACK("TASK_ASSIGNMENT_FEEDBACK", 0,"路径规划任务分配上报"),
|
||||
|
@ -1,12 +1,13 @@
|
||||
package cn.iododer.yudao.module.mqtt.framework.system;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.robot.RobotGenericsStatusApi;
|
||||
import cn.iocoder.yudao.module.system.api.robot.RobotReactiveStatusApi;
|
||||
import cn.iocoder.yudao.module.system.api.robot.RobotStatusApi;
|
||||
import cn.iocoder.yudao.module.system.api.robot.RobotTaskStatusApi;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {RobotGenericsStatusApi.class, RobotTaskStatusApi.class, RobotStatusApi.class})
|
||||
@EnableFeignClients(clients = {RobotGenericsStatusApi.class, RobotTaskStatusApi.class, RobotStatusApi.class, RobotReactiveStatusApi.class})
|
||||
public class SystemConfiguration {
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package cn.iododer.yudao.module.mqtt.service;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.robot.RobotReactiveStatusApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RobotReactiveStatusServiceImpl implements MqttService{
|
||||
|
||||
@Autowired
|
||||
private RobotReactiveStatusApi robotReactiveStatusApi;
|
||||
|
||||
@Override
|
||||
public void analysisMessage(String message) {
|
||||
log.info("机器人状态上报 :{}", message);
|
||||
robotReactiveStatusApi.robotReactiveStatus(message);
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cn.iododer.yudao.module.mqtt.service;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.robot.RobotStatusApi;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotPoseStatusDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDTO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -22,7 +23,7 @@ public class RobotStatusServiceImpl implements MqttService {
|
||||
@Override
|
||||
public void analysisMessage(String message) {
|
||||
log.info("处理RobotStatusServiceImpl的消息 :{}", message);
|
||||
RobotStatusDTO robotStatusData = JSON.parseObject(message, RobotStatusDTO.class);
|
||||
RobotPoseStatusDTO robotStatusData = JSON.parseObject(message, RobotPoseStatusDTO.class);
|
||||
robotStatusApi.robotStatusUpdate(robotStatusData);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.system.api.robot;
|
||||
|
||||
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "响应式状态上报")
|
||||
public interface RobotReactiveStatusApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/task";
|
||||
|
||||
@PostMapping(PREFIX + "/robotReactiveStatus")
|
||||
@Operation(summary = "机器人响应式状态上报")
|
||||
void robotReactiveStatus(@RequestParam("message") String message);
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.api.robot;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotPoseStatusDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDTO;
|
||||
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -15,5 +16,5 @@ public interface RobotStatusApi {
|
||||
|
||||
@PostMapping(PREFIX + "/robotStatusUpdate")
|
||||
@Operation(summary = "机器人点位状态/异常/是否能做任务上报")
|
||||
void robotStatusUpdate(@RequestBody RobotStatusDTO robotStatusDataDTO);
|
||||
void robotStatusUpdate(@RequestBody RobotPoseStatusDTO robotStatusDataDTO);
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.system.api.robot.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RobotPoseStatusDTO {
|
||||
/**
|
||||
* mac地址
|
||||
*/
|
||||
public String mac;
|
||||
|
||||
/**
|
||||
* 货物到位传感器触发状态:被按下则 true,否则 false
|
||||
*/
|
||||
public Boolean cargoDetected;
|
||||
/**
|
||||
* true表示可以做任务,如果是到达了充电点正在充电中应该返回true
|
||||
*/
|
||||
public Boolean taskStatus;
|
||||
|
||||
/**
|
||||
* 机器人位姿
|
||||
*/
|
||||
public RobotStatusDataPoseDTO pose2d;
|
||||
|
||||
}
|
@ -10,9 +10,9 @@ public class RobotStatusDataErrorDTO {
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
public String error_code;
|
||||
public String errorCode;
|
||||
/**
|
||||
* 错误等级
|
||||
*/
|
||||
public String code_level;
|
||||
public String codeLevel;
|
||||
}
|
||||
|
@ -17,5 +17,5 @@ public class RobotStatusDataPoseDTO {
|
||||
//区域
|
||||
public String area;
|
||||
//电池剩余容量
|
||||
public String bat_soc;
|
||||
public String batSoc;
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ public class RobotStatusDataSpeedDTO {
|
||||
/**
|
||||
* 线速度 float 单位m/s
|
||||
*/
|
||||
public String linear_speed;
|
||||
public String linearSpeed;
|
||||
/**
|
||||
* 角速度 float rad/s
|
||||
*/
|
||||
public String angle_speed;
|
||||
public String angleSpeed;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class RobotGenericsStatusApiImpl implements RobotGenericsStatusApi {
|
||||
BigDecimal a = new BigDecimal(batSoc);
|
||||
BigDecimal b = new BigDecimal("100");
|
||||
BigDecimal multiply = a.multiply(b);
|
||||
robotStatusDataPoseDTO.setBat_soc(multiply.toString());
|
||||
robotStatusDataPoseDTO.setBatSoc(multiply.toString());
|
||||
}
|
||||
|
||||
redisUtil.set(pose2dKey,JSON.toJSONString(robotStatusDataPoseDTO),robotPositionCacheTime);
|
||||
|
@ -0,0 +1,147 @@
|
||||
package cn.iocoder.yudao.module.system.api.robot;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
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.RobotReactiveStatusDTO;
|
||||
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;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnCodeMappingMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnMsgMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.RobotWarnType;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotInformationService;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotWarnMsgService;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class RobotReactiveStatusApiImpl implements RobotReactiveStatusApi {
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Value("${zn.robot_position_cache_time:600}")
|
||||
private Long robotPositionCacheTime;
|
||||
|
||||
@Value("${zn.robot_error_level_time:30}")
|
||||
private Long robotErrorLevelTime;
|
||||
|
||||
@Resource
|
||||
private RobotWarnMsgService warnMsgService;
|
||||
|
||||
@Resource
|
||||
private RobotWarnMsgMapper warnMsgMapper;
|
||||
|
||||
@Resource
|
||||
private RobotWarnCodeMappingMapper warnCodeMappingMapper;
|
||||
|
||||
@Autowired
|
||||
private RobotInformationService robotInformationService;
|
||||
|
||||
@Override
|
||||
public void robotReactiveStatus(String message) {
|
||||
TenantContextHolder.setTenantId(1L);
|
||||
RobotReactiveStatusDTO data = JSON.parseObject(message, RobotReactiveStatusDTO.class);
|
||||
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + data.getMac();
|
||||
Object object = redisUtil.get(pose2dKey);
|
||||
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(data.getFloorZone())) {
|
||||
robotStatusDataPoseDTO.setFloor(data.getFloorZone().getFloor());
|
||||
robotStatusDataPoseDTO.setArea(data.getFloorZone().getArea());
|
||||
}
|
||||
redisUtil.set(pose2dKey, JSON.toJSONString(robotStatusDataPoseDTO), robotPositionCacheTime);
|
||||
|
||||
//机器人异常等级
|
||||
if (ObjectUtil.isEmpty(data.getErrCode())) {
|
||||
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL + data.getMac();
|
||||
String errorMsgKey = RobotTaskChcheConstant.ROBOT_ERROR_MSG + data.getMac();
|
||||
redisUtil.del(errorLevelKey);
|
||||
redisUtil.del(errorMsgKey);
|
||||
}else {
|
||||
addRobotErrorMsg(data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加异常
|
||||
* @param data
|
||||
*/
|
||||
private void addRobotErrorMsg(RobotReactiveStatusDTO data) {
|
||||
String robotNo = robotInformationService.getRobotNoByMac(data.getMac());
|
||||
List<RobotStatusDataErrorDTO> errCode = data.getErrCode();
|
||||
List<String> warnCodes =
|
||||
errCode.stream().map(RobotStatusDataErrorDTO::getErrorCode).collect(Collectors.toList());
|
||||
List<RobotWarnCodeMappingDO> robotWarnCodeMappingDOS =
|
||||
warnCodeMappingMapper.selectList(new LambdaQueryWrapper<RobotWarnCodeMappingDO>()
|
||||
.in(RobotWarnCodeMappingDO::getWarnCode, warnCodes));
|
||||
if (ObjectUtil.isEmpty(robotWarnCodeMappingDOS)) {
|
||||
log.info("查不对应编号的告警信息 :{}", JSON.toJSONString(warnCodes));
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, List<RobotWarnCodeMappingDO>> warnCodeMapping =
|
||||
robotWarnCodeMappingDOS.stream().collect(Collectors.groupingBy(RobotWarnCodeMappingDO::getWarnCode));
|
||||
|
||||
List<RobotWarnMsgDO> warnMsgDOS = new ArrayList<>();
|
||||
|
||||
//机器人异常等级
|
||||
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL + data.getMac();
|
||||
Object errorLevel = redisUtil.get(errorLevelKey);
|
||||
|
||||
String errorMsgKey = RobotTaskChcheConstant.ROBOT_ERROR_MSG + data.getMac();
|
||||
Object errorMsg = redisUtil.get(errorMsgKey);
|
||||
|
||||
Integer level = ObjectUtil.isEmpty(errorLevel) ? 0 : Integer.valueOf(errorLevel.toString());
|
||||
|
||||
String msg = "";
|
||||
int i = 0;
|
||||
for (RobotStatusDataErrorDTO robotStatusData : errCode) {
|
||||
List<RobotWarnCodeMappingDO> mappingDOS = warnCodeMapping.get(robotStatusData.getErrorCode());
|
||||
if (ObjectUtil.isEmpty(mappingDOS)) {
|
||||
log.info("当前告警类型查不到对应的告警信息 :{}", robotStatusData.getErrorCode());
|
||||
continue;
|
||||
}
|
||||
RobotWarnMsgDO warnMsg = RobotWarnMsgDO.builder().warnLevel(Integer.valueOf(robotStatusData.getCodeLevel()))
|
||||
.warnCode(robotStatusData.getErrorCode())
|
||||
.robotNo(robotNo)
|
||||
.warnType(RobotWarnType.ROBOT_WARN.getType())
|
||||
.warnMsg(robotNo+"_"+mappingDOS.get(0).getWarnMsg())
|
||||
.warnSolve(mappingDOS.get(0).getWarnSolve())
|
||||
.build();
|
||||
warnMsgDOS.add(warnMsg);
|
||||
|
||||
if (level.intValue() < Integer.valueOf(robotStatusData.getCodeLevel()).intValue()) {
|
||||
level = Integer.valueOf(robotStatusData.getCodeLevel());
|
||||
errorMsg = warnMsg.getWarnMsg();
|
||||
}
|
||||
if (i< Integer.valueOf(robotStatusData.getCodeLevel()).intValue()) {
|
||||
i = Integer.valueOf(robotStatusData.getCodeLevel());
|
||||
msg = warnMsg.getWarnMsg();
|
||||
}
|
||||
}
|
||||
redisUtil.set(errorLevelKey, level, robotErrorLevelTime);
|
||||
redisUtil.set(errorMsgKey, errorMsg, robotErrorLevelTime);
|
||||
|
||||
warnMsgService.sendWarnMsgToWebsocket(msg);
|
||||
|
||||
warnMsgMapper.insertBatch(warnMsgDOS);
|
||||
}
|
||||
}
|
@ -3,15 +3,14 @@ package cn.iocoder.yudao.module.system.api.robot;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
|
||||
import cn.iocoder.yudao.module.mqtt.api.path.PathPlanningApi;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotPoseStatusDTO;
|
||||
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.path.PathPlanningTopicConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.webSocket.WebSocketConstant;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnMsgDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnCodeMappingMapper;
|
||||
@ -79,49 +78,6 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
}
|
||||
|
||||
String robotNo = robotInformationService.getRobotNoByMac(robotStatusDataDTO.getMac());
|
||||
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();
|
||||
// todo 后续需要改为从车机上报
|
||||
|
||||
redisUtil.set(taskStatusKey, robotStatusDataDTO.getData().getTask_status(), robotPositionCacheTime);
|
||||
redisUtil.set(cargoDetectedKey, robotStatusDataDTO.getData().getCargo_detected(), robotPositionCacheTime);
|
||||
/*redisUtil.set(taskStatusKey, "IDLE", robotPositionCacheTime);
|
||||
redisUtil.set(cargoDetectedKey, false, robotPositionCacheTime);*/
|
||||
|
||||
Object object = redisUtil.get(pose2dKey);
|
||||
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(robotStatusDataDTO.getData())
|
||||
&& ObjectUtil.isNotEmpty(robotStatusDataDTO.getData().getPose2d())) {
|
||||
robotStatusDataPoseDTO.setX(robotStatusDataDTO.getData().getPose2d().getX());
|
||||
robotStatusDataPoseDTO.setY(robotStatusDataDTO.getData().getPose2d().getY());
|
||||
robotStatusDataPoseDTO.setYaw(robotStatusDataDTO.getData().getPose2d().getYaw());
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(robotStatusDataDTO.getData())
|
||||
&& ObjectUtil.isNotEmpty(robotStatusDataDTO.getData().getFloor_zone())) {
|
||||
robotStatusDataPoseDTO.setFloor(robotStatusDataDTO.getData().getFloor_zone().getFloor());
|
||||
robotStatusDataPoseDTO.setArea(robotStatusDataDTO.getData().getFloor_zone().getArea());
|
||||
}
|
||||
|
||||
/*robotStatusDataPoseDTO.setFloor("1");
|
||||
robotStatusDataPoseDTO.setArea("C区");*/
|
||||
|
||||
robotStatusDataPoseDTO.setRobotNo(robotNo);
|
||||
redisUtil.set(pose2dKey, JSON.toJSONString(robotStatusDataPoseDTO), robotPositionCacheTime);
|
||||
pathPlanningApi.synchronousLineObject(robotStatusDataPoseDTO, PathPlanningTopicConstant.AGV_POSE);
|
||||
// -- 通过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(robotInformationVO));
|
||||
|
||||
|
||||
if (ObjectUtil.isNotNull(robotStatusDataDTO.getData().getErr_code())) {
|
||||
List<RobotStatusDataErrorDTO> errCode = robotStatusDataDTO.getData().getErr_code();
|
||||
@ -132,7 +88,7 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
}
|
||||
|
||||
List<String> warnCodes =
|
||||
errCode.stream().map(RobotStatusDataErrorDTO::getError_code).collect(Collectors.toList());
|
||||
errCode.stream().map(RobotStatusDataErrorDTO::getErrorCode).collect(Collectors.toList());
|
||||
List<RobotWarnCodeMappingDO> robotWarnCodeMappingDOS =
|
||||
warnCodeMappingMapper.selectList(new LambdaQueryWrapper<RobotWarnCodeMappingDO>()
|
||||
.in(RobotWarnCodeMappingDO::getWarnCode, warnCodes));
|
||||
@ -156,13 +112,13 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
Integer level = ObjectUtil.isEmpty(errorLevel) ? 0 : Integer.valueOf(errorLevel.toString());
|
||||
|
||||
for (RobotStatusDataErrorDTO robotStatusData : errCode) {
|
||||
List<RobotWarnCodeMappingDO> mappingDOS = warnCodeMapping.get(robotStatusData.getError_code());
|
||||
List<RobotWarnCodeMappingDO> mappingDOS = warnCodeMapping.get(robotStatusData.getErrorCode());
|
||||
if (ObjectUtil.isEmpty(mappingDOS)) {
|
||||
log.info("当前告警类型查不到对应的告警信息 :{}", robotStatusData.getError_code());
|
||||
log.info("当前告警类型查不到对应的告警信息 :{}", robotStatusData.getErrorCode());
|
||||
continue;
|
||||
}
|
||||
RobotWarnMsgDO warnMsg = RobotWarnMsgDO.builder().warnLevel(Integer.valueOf(robotStatusData.getCode_level()))
|
||||
.warnCode(robotStatusData.getError_code())
|
||||
RobotWarnMsgDO warnMsg = RobotWarnMsgDO.builder().warnLevel(Integer.valueOf(robotStatusData.getCodeLevel()))
|
||||
.warnCode(robotStatusData.getErrorCode())
|
||||
.robotNo(robotNo)
|
||||
.warnType(RobotWarnType.ROBOT_WARN.getType())
|
||||
.warnMsg(robotNo+"_"+mappingDOS.get(0).getWarnMsg())
|
||||
@ -170,8 +126,8 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
.build();
|
||||
warnMsgDOS.add(warnMsg);
|
||||
|
||||
if (level.intValue() < Integer.valueOf(robotStatusData.getCode_level()).intValue()) {
|
||||
level = Integer.valueOf(robotStatusData.getCode_level());
|
||||
if (level.intValue() < Integer.valueOf(robotStatusData.getCodeLevel()).intValue()) {
|
||||
level = Integer.valueOf(robotStatusData.getCodeLevel());
|
||||
errorMsg = warnMsg.getWarnMsg();
|
||||
}
|
||||
}
|
||||
@ -191,11 +147,51 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void robotStatusUpdate(RobotStatusDTO robotStatusDataDTO) {
|
||||
public void robotStatusUpdate(RobotPoseStatusDTO robotStatusDataDTO) {
|
||||
taskExecutor.execute(()->{
|
||||
doRobotStatusUpdate(robotStatusDataDTO);
|
||||
updateRobotPosed(robotStatusDataDTO);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新点位信息
|
||||
* @param robotStatusDataDTO
|
||||
*/
|
||||
private void updateRobotPosed(RobotPoseStatusDTO robotStatusDataDTO) {
|
||||
TenantContextHolder.setTenantId(1L);
|
||||
if (ObjectUtil.isEmpty(robotStatusDataDTO) || ObjectUtil.isEmpty(robotStatusDataDTO.getMac())) {
|
||||
log.info("机器人上报的信息不全 :{}", JSON.toJSONString(robotStatusDataDTO));
|
||||
return;
|
||||
}
|
||||
String robotNo = robotInformationService.getRobotNoByMac(robotStatusDataDTO.getMac());
|
||||
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robotStatusDataDTO.getMac();
|
||||
Object object = redisUtil.get(pose2dKey);
|
||||
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(robotStatusDataDTO.getPose2d())) {
|
||||
robotStatusDataPoseDTO.setX(robotStatusDataDTO.getPose2d().getX());
|
||||
robotStatusDataPoseDTO.setY(robotStatusDataDTO.getPose2d().getY());
|
||||
robotStatusDataPoseDTO.setYaw(robotStatusDataDTO.getPose2d().getYaw());
|
||||
}
|
||||
robotStatusDataPoseDTO.setRobotNo(robotNo);
|
||||
redisUtil.set(pose2dKey, JSON.toJSONString(robotStatusDataPoseDTO), robotPositionCacheTime);
|
||||
pathPlanningApi.synchronousLineObject(robotStatusDataPoseDTO, PathPlanningTopicConstant.AGV_POSE);
|
||||
|
||||
//机器人身上是否有货
|
||||
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS + robotStatusDataDTO.getMac();
|
||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robotStatusDataDTO.getMac();
|
||||
redisUtil.set(taskStatusKey, robotStatusDataDTO.getTaskStatus(), robotPositionCacheTime);
|
||||
redisUtil.set(cargoDetectedKey, robotStatusDataDTO.getCargoDetected(), robotPositionCacheTime);
|
||||
|
||||
// -- 通过mac 地址获取车辆信息 - (并且加入到缓存中)
|
||||
Map<String, RobotInformationVO> robotInformationVOS = robotInformationService.getAllRobotByRedis();
|
||||
RobotInformationVO robotInformationVO = robotInformationVOS.get(robotStatusDataDTO.getMac());
|
||||
if (robotInformationVO == null) {
|
||||
robotInformationVO = robotInformationService.getRobotByRedis(robotStatusDataDTO.getMac());
|
||||
}
|
||||
robotInformationVO.setPose2d(robotStatusDataPoseDTO);
|
||||
// 合并请求 - 这里接受到的数据都丢给 RequestProcessor - 再整合数据通过WebSocket丢给前端
|
||||
processor.handleRequest(robotStatusDataPoseDTO.getFloor() + "_" + robotStatusDataPoseDTO.getArea(),
|
||||
robotStatusDataDTO.getMac(), JSONUtil.toJsonStr(robotInformationVO));
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,18 @@
|
||||
package cn.iocoder.yudao.module.system.api.robot;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
|
||||
import cn.iocoder.yudao.module.mqtt.api.common.CommonApi;
|
||||
import cn.iocoder.yudao.module.mqtt.api.task.dto.RobotAcceptTaskDTO;
|
||||
import cn.iocoder.yudao.module.mqtt.enums.task.ExecutionTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.api.path.vo.RobotClosePathPlantingDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotCommandStateDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotCompleteTaskDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
|
||||
import cn.iocoder.yudao.module.system.constant.path.PathPlanningTopicConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotExecutionStateConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTopicConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.webSocket.WebSocketConstant;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.actionlog.RobotTaskDetailActionLogDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.config.CommonConfigDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.*;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.actionlog.RobotTaskDetailActionLogMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.cycle.TaskCycleMapper;
|
||||
@ -29,7 +20,6 @@ import cn.iocoder.yudao.module.system.dal.mysql.houselocation.WareHouseLocationM
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.information.DeviceInformationMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.*;
|
||||
import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.device.DeviceUseStatusEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.path.PathIsReachEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.path.PathTaskType;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.*;
|
||||
@ -44,7 +34,6 @@ import cn.iocoder.yudao.module.system.service.robot.RobotWarnMsgService;
|
||||
import cn.iocoder.yudao.module.system.service.wait.MoveToWaitService;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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;
|
||||
@ -55,8 +44,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId;
|
||||
@ -141,7 +128,6 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
|
||||
|| RobotExecutionStateConstant.STOP.equals(robotCompleteTaskDTO.getExecutionState())
|
||||
|| RobotExecutionStateConstant.CLOSE.equals(robotCompleteTaskDTO.getExecutionState())) {
|
||||
log.info("任务未开始/暂停/取消 :{}", robotCompleteTaskDTO.getOrderId());
|
||||
return;
|
||||
} else if (RobotExecutionStateConstant.DONE.equals(robotCompleteTaskDTO.getExecutionState())) {
|
||||
robotTaskDone(robotCompleteTaskDTO);
|
||||
redisUtil.del(robotDoingActionKey);
|
||||
@ -164,7 +150,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
|
||||
logOne.setTaskDetailId(robotCompleteTaskDTO.getOrderId());
|
||||
taskDetailActionLogMapper.insert(logOne);
|
||||
redisUtil.set(robotDoingActionKey, logOne.getActionMsg(), doingActionCacheTime);
|
||||
moveToWaitService.setMoveToWaitDoing(robotCompleteTaskDTO.getOrderId(), WaitStatusEnum.GO_TO_WAIT.getType());
|
||||
moveToWaitService.updateWaitStatus(robotCompleteTaskDTO.getOrderId(), WaitStatusEnum.GO_TO_WAIT.getType());
|
||||
} else {
|
||||
taskDoing(robotCompleteTaskDTO, robotDoingActionKey);
|
||||
}
|
||||
@ -199,6 +185,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
|
||||
if (PathTaskType.MOVE.getType().equals(robotCompleteTaskDTO.getOrderType())
|
||||
|| PathTaskType.MOVE_TO_WAIT_STOP.getType().equals(robotCompleteTaskDTO.getOrderType())
|
||||
|| PathTaskType.TAKE.getType().equals(robotCompleteTaskDTO.getOrderType())
|
||||
|| PathTaskType.CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())
|
||||
|| PathTaskType.RELEASE.getType().equals(robotCompleteTaskDTO.getOrderType())) {
|
||||
taskDone(robotCompleteTaskDTO);
|
||||
|
||||
@ -210,6 +197,15 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
|
||||
} else if (RobotTaskStageEnum.RELEASEING.getType().equals(robotTaskDetailDO.getTaskStage())) {
|
||||
taskDone(robotCompleteTaskDTO);
|
||||
}
|
||||
} else if (PathTaskType.MOVE_TO_WAIT.getType().equals(robotCompleteTaskDTO.getOrderType())) {
|
||||
moveToWaitService.updateWaitStatus(robotCompleteTaskDTO.getOrderId(), WaitStatusEnum.REACH_WAIT.getType());
|
||||
} else if (PathTaskType.AUTO_CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())) {
|
||||
RobotChargeLogDO build = RobotChargeLogDO
|
||||
.builder()
|
||||
.id(robotCompleteTaskDTO.getOrderId())
|
||||
.taskStatus(ChargeTaskStatusEnum.CHARGEING.getType())
|
||||
.build();
|
||||
chargeLogMapper.updateById(build);
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,7 +233,9 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void closeTask(RobotCompleteTaskDTO robotCompleteTaskDTO) {
|
||||
PPCloseOrder(robotCompleteTaskDTO);
|
||||
String robotNo = robotInformationService.getRobotNoByMac(robotCompleteTaskDTO.getMac());
|
||||
|
||||
//先不释放库位状态
|
||||
/*if (RobotTaksOrderTypeEnum.TASK.getType().equals(robotCompleteTaskDTO.getOrderType())) {
|
||||
RobotTaskDetailDO robotTaskDetailDO = closeTaskDetail(robotCompleteTaskDTO.getOrderId());
|
||||
List<Long> locationIds = new ArrayList<>();
|
||||
@ -266,7 +264,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
|
||||
DeviceUseStatusEnum.IDLE.getType(), ZeroOneEnum.ZERO.getType());
|
||||
}*/
|
||||
|
||||
/* RobotWarnMsgDO warnMsg = RobotWarnMsgDO.builder().warnLevel(4)
|
||||
RobotWarnMsgDO warnMsg = RobotWarnMsgDO.builder().warnLevel(4)
|
||||
.warnCode(robotCompleteTaskDTO.getStatusCode())
|
||||
.robotNo(robotNo)
|
||||
.warnType(RobotWarnType.ROBOT_WARN.getType())
|
||||
@ -275,7 +273,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
|
||||
.build();
|
||||
warnMsgMapper.insert(warnMsg);
|
||||
|
||||
warnMsgService.sendWarnMsgToWebsocket(warnMsg.getWarnMsg());*/
|
||||
warnMsgService.sendWarnMsgToWebsocket(warnMsg.getWarnMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -312,9 +310,11 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
|
||||
private void chargeDoing(RobotCompleteTaskDTO robotCompleteTaskDTO, String robotDoingActionKey) {
|
||||
RobotTaskDetailActionLogDO logOne = new RobotTaskDetailActionLogDO();
|
||||
RobotCommandStateDTO commandStatus = robotCompleteTaskDTO.getCommandStatus();
|
||||
Integer taskStatus = ChargeTaskStatusEnum.CHARGEING.getType();
|
||||
if (ObjectUtil.isNotEmpty(commandStatus) && CommandTypeEnum.MOVE_POSES.getType().equals(commandStatus.getCommandType())) {
|
||||
RobotChargeLogDO robotChargeLogDO = chargeLogMapper.selectById(robotCompleteTaskDTO.getOrderId());
|
||||
logOne.setActionMsg("车辆正在前往充电点" + robotChargeLogDO.getDeviceNo());
|
||||
taskStatus = ChargeTaskStatusEnum.DOING.getType();
|
||||
} else if (ObjectUtil.isNotEmpty(commandStatus)) {
|
||||
logOne.setActionMsg("车辆正在充电");
|
||||
}
|
||||
@ -324,6 +324,12 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
|
||||
logOne.setTaskDetailId(robotCompleteTaskDTO.getOrderId());
|
||||
taskDetailActionLogMapper.insert(logOne);
|
||||
redisUtil.set(robotDoingActionKey, logOne.getActionMsg(), doingActionCacheTime);
|
||||
RobotChargeLogDO build = RobotChargeLogDO
|
||||
.builder()
|
||||
.id(robotCompleteTaskDTO.getOrderId())
|
||||
.taskStatus(taskStatus)
|
||||
.build();
|
||||
chargeLogMapper.updateById(build);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.system.api.robot.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.FloorZoneDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataErrorDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataSpeedDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RobotReactiveStatusDTO {
|
||||
|
||||
/**
|
||||
* 楼层区域
|
||||
*/
|
||||
public FloorZoneDTO floorZone;
|
||||
//货叉高度 float
|
||||
public Double forkHeight;
|
||||
/**
|
||||
* 车辆运行速度
|
||||
*/
|
||||
public RobotStatusDataSpeedDTO agvSpeed;
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
public List<RobotStatusDataErrorDTO> errCode;
|
||||
/**
|
||||
* mac地址
|
||||
*/
|
||||
public String mac;
|
||||
////手动充电 0或者1,1表示电源线连接着机器人充电口或者是准备连接机器人充电口(待定,充电会关机)
|
||||
public String manualChargeStatus;
|
||||
|
||||
}
|
@ -10,8 +10,8 @@ public class RobotStatusCodeConstant {
|
||||
public static final String OK = "1000";
|
||||
|
||||
//货物到位传感器触发状态:被按下则 true,否则 false
|
||||
public static Boolean CARGO_DETECTED_TRUE = true;
|
||||
public static Boolean CARGO_DETECTED = true;
|
||||
|
||||
//IDLE 和 RUNNING
|
||||
public static String TASK_STATUS_RUNNING = "RUNNING";
|
||||
//true表示可以做任务,如果是到达了充电点正在充电中应该返回true
|
||||
public static Boolean TASK_STATUS_RUNNING = true;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class WareHouseLocationPageReqVO extends PageParam {
|
||||
@Schema(description = "机车上报的高度/总高(如果两个箱子叠加,就是叠加后的总高度)--备用")
|
||||
private BigDecimal locationTotalHeight;
|
||||
|
||||
@Schema(description = "机车上报的托盘高度--备用")
|
||||
@Schema(description = "机车上报的托盘高度--机车上报的下一层箱子高度")
|
||||
private BigDecimal locationTrayHeight;
|
||||
|
||||
@Schema(description = "库位方向(1:单向、2:双向、3:三向、4:四向)")
|
||||
|
@ -101,8 +101,8 @@ public class WareHouseLocationRespVO {
|
||||
@ExcelProperty("机车上报的高度/总高(如果两个箱子叠加,就是叠加后的总高度)")
|
||||
private BigDecimal locationTotalHeight;
|
||||
|
||||
@Schema(description = "机车上报的托盘高度--备用")
|
||||
@ExcelProperty("机车上报的托盘高度")
|
||||
@Schema(description = "机车上报的托盘高度--机车上报的下一层箱子高度")
|
||||
@ExcelProperty("机车上报的托盘高度--机车上报的下一层箱子高度")
|
||||
private BigDecimal locationTrayHeight;
|
||||
|
||||
@Schema(description = "库位方向(1:单向、2:双向、3:三向、4:四向)")
|
||||
|
@ -86,7 +86,7 @@ public class WareHouseLocationSaveReqVO {
|
||||
@Schema(description = "机车上报的高度/总高(如果两个箱子叠加,就是叠加后的总高度)--备用")
|
||||
private BigDecimal locationTotalHeight;
|
||||
|
||||
@Schema(description = "机车上报的托盘高度--备用")
|
||||
@Schema(description = "机车上报的托盘高度--机车上报的下一层箱子高度")
|
||||
private BigDecimal locationTrayHeight;
|
||||
|
||||
@Schema(description = "层数")
|
||||
|
@ -38,7 +38,7 @@ public class RobotChargeLogPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "任务状态(0:未开始、1:执行中、2:已完成、3:已取消、4:异常)")
|
||||
@Schema(description = "任务状态(0:未开始、1:前往充电途中、2:已完成、3:已取消、4:异常、5:充电中)")
|
||||
private Integer taskStatus;
|
||||
|
||||
@Schema(description = "robot_task_detail的id")
|
||||
|
@ -44,8 +44,8 @@ public class RobotChargeLogRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "任务状态(0:未开始、1:执行中、2:已完成、3:已取消、4:异常)")
|
||||
@ExcelProperty("任务状态(0:未开始、1:执行中、2:已完成、3:已取消、4:异常)")
|
||||
@Schema(description = "任务状态(0:未开始、1:前往充电途中、2:已完成、3:已取消、4:异常、5:充电中)")
|
||||
@ExcelProperty("任务状态(0:未开始、1:前往充电途中、2:已完成、3:已取消、4:异常、5:充电中)")
|
||||
private Integer taskStatus;
|
||||
|
||||
@Schema(description = "robot_task_detail的id")
|
||||
|
@ -33,7 +33,7 @@ public class RobotChargeLogSaveReqVO {
|
||||
@Schema(description = "device_information表的设备编号")
|
||||
private String deviceNo;
|
||||
|
||||
@Schema(description = "任务状态(0:未开始、1:执行中、2:已完成、3:已取消、4:异常)")
|
||||
@Schema(description = "任务状态(0:未开始、1:前往充电途中、2:已完成、3:已取消、4:异常、5:充电中)")
|
||||
private Integer taskStatus;
|
||||
|
||||
@Schema(description = "robot_task_detail的id")
|
||||
|
@ -135,7 +135,7 @@ public class WareHouseLocationDO extends BaseDO {
|
||||
*/
|
||||
private BigDecimal locationTotalHeight;
|
||||
/**
|
||||
* 机车上报的托盘高度--备用
|
||||
* 机车上报的下一层箱子高度
|
||||
*/
|
||||
private BigDecimal locationTrayHeight;
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ public class RobotChargeLogDO extends BaseDO {
|
||||
*/
|
||||
private Integer chargeModel;
|
||||
/**
|
||||
* 任务状态(0:未开始、1:执行中、2:已完成、3:已取消、4:异常)
|
||||
* 任务状态(0:未开始、1:前往充电途中、2:已完成、3:已取消、4:异常、5:充电中)
|
||||
*/
|
||||
private Integer taskStatus;
|
||||
/**
|
||||
|
@ -10,10 +10,11 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
public enum ChargeTaskStatusEnum {
|
||||
NEW(0),//未开始
|
||||
DOING(1),//执行中
|
||||
DOING(1),//前往充电涂中
|
||||
DONE(2),//已完成
|
||||
CLOSE(3), //已取消
|
||||
ABNORMAL(4); //异常
|
||||
ABNORMAL(4),//异常
|
||||
CHARGEING(5); //充电中
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
|
@ -122,7 +122,7 @@ public class BulletinBoardServiceImpl implements BulletinBoardService {
|
||||
BeanUtil.copyProperties(item, robotElectricityLevelVO);
|
||||
}
|
||||
robotElectricityLevelVO.setRobotNo(robotInformationDO.getRobotNo());
|
||||
robotElectricityLevelVO.setBatSoc(robotStatusDataPoseDTO.getBat_soc());
|
||||
robotElectricityLevelVO.setBatSoc(robotStatusDataPoseDTO.getBatSoc());
|
||||
robotElectricityLevelVOS.add(robotElectricityLevelVO);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotModelDO;
|
||||
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.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;
|
||||
@ -170,7 +169,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
|
||||
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) {
|
||||
bean.setElectricity(robotStatusDataPoseDTO.getBat_soc());
|
||||
bean.setElectricity(robotStatusDataPoseDTO.getBatSoc());
|
||||
bean.setFloor(robotStatusDataPoseDTO.getFloor());
|
||||
bean.setArea(robotStatusDataPoseDTO.getArea());
|
||||
}
|
||||
@ -259,7 +258,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
|
||||
Object action = redisUtil.get(robotDoingActionKey);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) {
|
||||
v.setElectricity(robotStatusDataPoseDTO.getBat_soc());
|
||||
v.setElectricity(robotStatusDataPoseDTO.getBatSoc());
|
||||
v.setFloor(robotStatusDataPoseDTO.getFloor());
|
||||
v.setArea(robotStatusDataPoseDTO.getArea());
|
||||
v.setOnlineStatus(1);
|
||||
@ -469,7 +468,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
|
||||
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());
|
||||
robotStatusDataPoseDTO.setBatSoc(robotStatusDataDTO.getData().getPose2d().getBatSoc());
|
||||
|
||||
robotInformationVO.setPose2d(robotStatusDataPoseDTO);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.service.robot;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -21,14 +20,12 @@ import cn.iocoder.yudao.module.system.constant.robot.RobotTopicConstant;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.detail.RobotTaskDetailLogResoVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.detail.RobotTaskDetailLogVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.task.TaskAssignDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.task.TaskPPDistribution;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.cycle.TaskCycleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.housearea.HouseAreaDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.houselane.WareHouseLaneDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotChargeLogDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
|
||||
@ -50,16 +47,15 @@ import cn.iocoder.yudao.module.system.enums.robot.*;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.charge.ChargeTaskStatusEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.task.RobotCommandTypeEnum;
|
||||
//import cn.iocoder.yudao.module.system.service.robot.job.RobotCommonTaskService;
|
||||
import cn.iocoder.yudao.module.system.enums.wait.WaitStatusEnum;
|
||||
import cn.iocoder.yudao.module.system.service.wait.MoveToWaitService;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedissonUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RLock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -72,9 +68,7 @@ import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
@ -149,6 +143,9 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
|
||||
@Resource
|
||||
private DeviceInformationMapper deviceInformationMapper;
|
||||
|
||||
@Resource
|
||||
private MoveToWaitService moveToWaitService;
|
||||
|
||||
@Resource
|
||||
private CommonApi commonApi;
|
||||
|
||||
@ -425,11 +422,13 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
|
||||
}
|
||||
|
||||
for (RobotInformationDO robotInformationDO : robotInformationDOS) {
|
||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robotInformationDO.getMacAddress();
|
||||
/*String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robotInformationDO.getMacAddress();
|
||||
Object cargoDetected = redisUtil.get(cargoDetectedKey);
|
||||
if (ObjectUtil.isEmpty(cargoDetected) || RobotStatusCodeConstant.CARGO_DETECTED_TRUE.equals(cargoDetected)) {
|
||||
if (ObjectUtil.isEmpty(cargoDetected) || RobotStatusCodeConstant.CARGO_DETECTED.equals(cargoDetected)) {
|
||||
robotInformationDO.setRobotTaskModel(RobotTaskModelEnum.REJECTION.getType());
|
||||
}
|
||||
}*/
|
||||
//因为机器人如果正在抬叉取货,这时把任务取消,如果货叉刚好伸到托盘底下,还是需要人为控制
|
||||
robotInformationDO.setRobotTaskModel(RobotTaskModelEnum.REJECTION.getType());
|
||||
robotInformationDO.setRobotStatus(RobotStatusEnum.STAND_BY.getType());
|
||||
}
|
||||
|
||||
@ -456,32 +455,38 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
|
||||
Map<Long, String> deviceNoMap = new HashMap<>();
|
||||
RobotChargeLogDO robotChargeLogs = null;
|
||||
|
||||
/**
|
||||
* 充电
|
||||
*/
|
||||
Integer robotStatus = RobotStatusEnum.DOING.getType();
|
||||
|
||||
if (PathTaskType.AUTO_CHARGE.getType().equals(taskAssignDTO.getType())) {
|
||||
robotChargeLogs = chargeLogMapper.selectById(taskAssignDTO.getId());
|
||||
|
||||
robotChargeLogs.setTaskStatus(ChargeTaskStatusEnum.DOING.getType());
|
||||
chargeLogMapper.updateBatch(robotChargeLogs);
|
||||
|
||||
robotInformationMapper.updateRobotListStatus(taskAssignDTO.getRobotNo(), RobotStatusEnum.CHARGE.getType(), taskAssignDTO.getId());
|
||||
robotStatus = RobotStatusEnum.CHARGE.getType();
|
||||
if (ObjectUtil.isNotEmpty(robotChargeLogs.getTaskDetailId())) {
|
||||
deviceNoMap.put(robotChargeLogs.getTaskDetailId(), robotChargeLogs.getDeviceNo());
|
||||
detailId = robotChargeLogs.getTaskDetailId();
|
||||
}
|
||||
|
||||
} else if (PathTaskType.MOVE_TO_WAIT.getType().equals(taskAssignDTO.getType())) {
|
||||
chargeDone(taskAssignDTO.getRobotNo());
|
||||
moveToWaitService.updateWaitStatus(taskAssignDTO.getId(), WaitStatusEnum.GO_TO_WAIT.getType());
|
||||
} else if (PathTaskType.CHARGE.getType().equals(taskAssignDTO.getType())) {
|
||||
robotStatus = RobotStatusEnum.CHARGE.getType();
|
||||
detailId = taskAssignDTO.getId();
|
||||
} else {
|
||||
chargeDone(taskAssignDTO.getRobotNo());
|
||||
robotInformationMapper.updateRobotListStatus(taskAssignDTO.getRobotNo(), RobotStatusEnum.DOING.getType(), taskAssignDTO.getId());
|
||||
detailId = taskAssignDTO.getId();
|
||||
}
|
||||
|
||||
RobotTaskDetailDO robotTaskDetailDO = null;
|
||||
robotInformationMapper.updateRobotListStatus(taskAssignDTO.getRobotNo(), robotStatus, taskAssignDTO.getId());
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailId)) {
|
||||
robotTaskDetailDO = setTaskDoing(detailId, taskAssignDTO.getRobotNo(), deviceNoMap);
|
||||
setTaskDoing(detailId, taskAssignDTO.getRobotNo(), deviceNoMap);
|
||||
}
|
||||
|
||||
sendTaskToRobot(robotTaskDetailDO, taskAssignDTO);
|
||||
// sendTaskToRobot(robotTaskDetailDO, taskAssignDTO);
|
||||
|
||||
}
|
||||
|
||||
@ -1238,7 +1243,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
|
||||
.eq(RobotChargeLogDO::getRobotNo, robotNo)
|
||||
.orderByDesc(RobotChargeLogDO::getCreateTime)
|
||||
.last("limit 1"));
|
||||
if (ObjectUtil.isEmpty(robotChargeLogDO)) {
|
||||
if (ObjectUtil.isEmpty(robotChargeLogDO) || !ChargeTaskStatusEnum.CHARGEING.getType().equals(robotChargeLogDO.getTaskStatus())) {
|
||||
return;
|
||||
}
|
||||
log.info("开始结束充电,并接任务 :{}", robotNo);
|
||||
@ -1249,11 +1254,17 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
|
||||
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) {
|
||||
robotChargeLogDO.setEndElectricity(Integer.valueOf(robotStatusDataPoseDTO.getBat_soc()));
|
||||
robotChargeLogDO.setEndElectricity(Integer.valueOf(robotStatusDataPoseDTO.getBatSoc()));
|
||||
}
|
||||
robotChargeLogDO.setTaskStatus(ChargeTaskStatusEnum.DONE.getType());
|
||||
chargeLogMapper.updateBatch(robotChargeLogDO);
|
||||
|
||||
DeviceInformationDO deviceInformationDO = deviceInformationMapper.selectOne(new LambdaQueryWrapperX<DeviceInformationDO>()
|
||||
.eq(DeviceInformationDO::getDeviceNo, robotChargeLogDO.getDeviceNo()));
|
||||
deviceInformationDO.setDeviceUseStatus(DeviceUseStatusEnum.IDLE.getType());
|
||||
deviceInformationMapper.updateBatch(deviceInformationDO);
|
||||
log.info("充电桩设置为空闲 :{}", deviceInformationDO.getDeviceNo());
|
||||
|
||||
if (ObjectUtil.isEmpty(robotChargeLogDO.getTaskDetailId())) {
|
||||
return;
|
||||
}
|
||||
@ -1263,11 +1274,6 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
|
||||
RobotTaskDO robotTask = taskMapper.selectById(taskDetail.getRobotTaskId());
|
||||
robotTask.setTaskStatus(RobotTaskStatusEnum.DONE.getType());
|
||||
taskMapper.updateBatch(robotTask);
|
||||
DeviceInformationDO deviceInformationDO = deviceInformationMapper.selectOne(new LambdaQueryWrapperX<DeviceInformationDO>()
|
||||
.eq(DeviceInformationDO::getDeviceNo, robotChargeLogDO.getDeviceNo()));
|
||||
deviceInformationDO.setDeviceUseStatus(DeviceUseStatusEnum.IDLE.getType());
|
||||
deviceInformationMapper.updateBatch(deviceInformationDO);
|
||||
log.info("充电桩设置为空闲 :{}", deviceInformationDO.getDeviceNo());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.service.robot.job;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
|
||||
@ -12,7 +11,6 @@ import cn.iocoder.yudao.module.system.dal.dataobject.config.CommonConfigDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotChargeLogDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.config.CommonConfigMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.information.DeviceInformationMapper;
|
||||
@ -24,7 +22,6 @@ import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.config.CommandConfigTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.device.DeviceTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.device.DeviceUseStatusEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.redis.RobotCacheLockEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.*;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.charge.ChargeModelEnum;
|
||||
import cn.iocoder.yudao.module.system.service.robot.pathplanning.RobotPathPlanningService;
|
||||
@ -40,14 +37,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.PATH_PLANNING_DOING_DISTRIBUTE;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.TASK_CHECK_UPDATE_STATUS;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@ -170,7 +163,7 @@ public class AutoChargeServiceImpl implements AutoChargeService {
|
||||
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC +robot.getMacAddress();
|
||||
Object poseCache = redisUtil.get(pose2dKey);
|
||||
RobotStatusDataPoseDTO dataPoseDTO= JSON.parseObject((String)poseCache, RobotStatusDataPoseDTO.class);
|
||||
if (ObjectUtil.isEmpty(dataPoseDTO) || ObjectUtil.isEmpty(dataPoseDTO.getBat_soc())) {
|
||||
if (ObjectUtil.isEmpty(dataPoseDTO) || ObjectUtil.isEmpty(dataPoseDTO.getBatSoc())) {
|
||||
log.info("当前机器人查不到电量信息,所以不执行充电 :{}",robot.getRobotNo());
|
||||
continue;
|
||||
}
|
||||
@ -194,7 +187,7 @@ public class AutoChargeServiceImpl implements AutoChargeService {
|
||||
logDo.setRobotNo(robot.getRobotNo());
|
||||
logDo.setDeviceNo(deviceInformationDO.getDeviceNo());
|
||||
logDo.setPositionMapItemId(deviceInformationDO.getPositionMapItemId());
|
||||
String[] split = dataPoseDTO.getBat_soc().split("\\.");
|
||||
String[] split = dataPoseDTO.getBatSoc().split("\\.");
|
||||
logDo.setStartElectricity(Integer.valueOf(split[0]));
|
||||
//配置的充满电电量
|
||||
BigDecimal robotFullElectricity = new BigDecimal(fullElectricity);
|
||||
|
@ -5,16 +5,11 @@ import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.mqtt.api.task.RobotTaskApi;
|
||||
import cn.iocoder.yudao.module.mqtt.api.task.dto.Pose2ds;
|
||||
import cn.iocoder.yudao.module.mqtt.api.task.dto.RobotAcceptTaskDTO;
|
||||
import cn.iocoder.yudao.module.mqtt.api.task.dto.RobotAcceptTaskData;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotStatusCodeConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTopicConstant;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.config.vo.CommonConfigVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.config.CommonConfigDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO;
|
||||
@ -35,7 +30,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.bouncycastle.pqc.crypto.util.PQCOtherInfoGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -45,9 +39,7 @@ import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -129,14 +121,14 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
||||
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS + robot.getMacAddress();
|
||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robot.getMacAddress();
|
||||
Object taskStatus = redisUtil.get(taskStatusKey);
|
||||
if (ObjectUtil.isEmpty(taskStatus) || RobotStatusCodeConstant.TASK_STATUS_RUNNING.equals(taskStatus.toString())) {
|
||||
if (ObjectUtil.isEmpty(taskStatus) || RobotStatusCodeConstant.TASK_STATUS_RUNNING.equals(Boolean.parseBoolean(String.valueOf(taskStatus)))) {
|
||||
robot.setRobotStatus(RobotStatusEnum.DOING.getType());
|
||||
continue;
|
||||
}
|
||||
|
||||
Object cargoDetected = redisUtil.get(cargoDetectedKey);
|
||||
// todo 后续需要判断(新建个任务明细表),如果上一条任务是仅取货,且正常完成, 则能进行仅放货的任务
|
||||
if (ObjectUtil.isEmpty(cargoDetected) || RobotStatusCodeConstant.CARGO_DETECTED_TRUE.equals(cargoDetected)) {
|
||||
if (ObjectUtil.isEmpty(cargoDetected) || RobotStatusCodeConstant.CARGO_DETECTED.equals(Boolean.parseBoolean(String.valueOf(cargoDetected)))) {
|
||||
robot.setRobotStatus(RobotStatusEnum.DOING.getType());
|
||||
continue;
|
||||
}
|
||||
@ -229,14 +221,14 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
||||
RobotStatusDataPoseDTO dataPoseDTO = JSON.parseObject((String) poseCache, RobotStatusDataPoseDTO.class);
|
||||
log.info("充电机器人编号:{} ,信息: {}", robot.getRobotNo(), JSON.toJSONString(dataPoseDTO));
|
||||
|
||||
if (ObjectUtil.isEmpty(commonConfigDO) || ObjectUtil.isEmpty(poseCache) || ObjectUtil.isEmpty(dataPoseDTO.getBat_soc())) {
|
||||
if (ObjectUtil.isEmpty(commonConfigDO) || ObjectUtil.isEmpty(poseCache) || ObjectUtil.isEmpty(dataPoseDTO.getBatSoc())) {
|
||||
return;
|
||||
}
|
||||
|
||||
CommonConfigVO chargeConfig = JSONUtil.toBean(commonConfigDO.getConfigStr(), CommonConfigVO.class);
|
||||
|
||||
//车子剩余电量
|
||||
BigDecimal robotRemainingElectricity = new BigDecimal(dataPoseDTO.getBat_soc());
|
||||
BigDecimal robotRemainingElectricity = new BigDecimal(dataPoseDTO.getBatSoc());
|
||||
//设置离开的电量
|
||||
BigDecimal robotEndElectricity = null;
|
||||
|
||||
|
@ -108,6 +108,9 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
@Value("${zn.robot_chearg.priority_config:50}")
|
||||
private Long priorityConfig;
|
||||
|
||||
@Value("${zn.robot_config.offset_height}")
|
||||
private Double offsetHeight;
|
||||
|
||||
/**
|
||||
* 下发任务给PP
|
||||
*/
|
||||
@ -239,20 +242,28 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
}
|
||||
pathPlanning.setRobotNoLimitationAreaDTOS(robotNoLimitions);
|
||||
|
||||
WareHouseLocationDO fromLocation = locationDOMap.get(taskDetailDO.getFromLocationId());
|
||||
WareHouseLocationDO toLocation = locationDOMap.get(taskDetailDO.getToLocationId());
|
||||
//取是线库
|
||||
if (ObjectUtil.isNotEmpty(taskDetailDO.getFromLocationId())
|
||||
&& ObjectUtil.isNotEmpty(taskDetailDO.getFromLaneId())) {
|
||||
|
||||
pathPlanning.setTakeGroupId("LINE_" + taskDetailDO.getFromLaneId());
|
||||
pathPlanning.setTakeLocationNumber(Math.abs(locationNumberReduce - taskDetailDO.getFromLocationNumber()));
|
||||
pathPlanning.setTakePointId(locationDOMap.get(taskDetailDO.getFromLocationId()).getMapItemId());
|
||||
pathPlanning.setTakePointId(fromLocation.getMapItemId());
|
||||
pathPlanning.setTakeHeight(Double.valueOf(fromLocation.getLocationTrayHeight()+""));
|
||||
pathPlanning.setTakeLevel(fromLocation.getLocationStorey());
|
||||
pathPlanning.setTakeOffsetHeight(offsetHeight);
|
||||
|
||||
} else if (ObjectUtil.isNotEmpty(taskDetailDO.getFromLocationId())
|
||||
&& ObjectUtil.isEmpty(taskDetailDO.getFromLaneId())) {
|
||||
//取的是普通点位
|
||||
pathPlanning.setTakeGroupId("POINT_" + taskDetailDO.getFromMapItemId());
|
||||
pathPlanning.setTakeLocationNumber(Math.abs(locationNumberReduce - taskDetailDO.getFromLocationNumber()));
|
||||
pathPlanning.setTakePointId(locationDOMap.get(taskDetailDO.getFromLocationId()).getMapItemId());
|
||||
pathPlanning.setTakePointId(fromLocation.getMapItemId());
|
||||
pathPlanning.setTakeHeight(Double.valueOf(fromLocation.getLocationTrayHeight()+""));
|
||||
pathPlanning.setTakeLevel(fromLocation.getLocationStorey());
|
||||
pathPlanning.setTakeOffsetHeight(offsetHeight);
|
||||
}
|
||||
|
||||
//放是线库
|
||||
@ -261,14 +272,21 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
|
||||
pathPlanning.setReleaseGroupId("LINE_" + taskDetailDO.getToLaneId());
|
||||
pathPlanning.setReleaseLocationNumber(taskDetailDO.getToLocationNumber());
|
||||
pathPlanning.setReleasePointId(locationDOMap.get(taskDetailDO.getToLocationId()).getMapItemId());
|
||||
pathPlanning.setReleasePointId(toLocation.getMapItemId());
|
||||
pathPlanning.setReleaseHeight(Double.valueOf(toLocation.getLocationTrayHeight()+""));
|
||||
pathPlanning.setReleaseLevel(toLocation.getLocationStorey());
|
||||
pathPlanning.setReleaseOffsetHeight(offsetHeight);
|
||||
|
||||
} else if (ObjectUtil.isNotEmpty(taskDetailDO.getToLocationId())
|
||||
&& ObjectUtil.isEmpty(taskDetailDO.getToLaneId())) {
|
||||
//放的是普通点位
|
||||
pathPlanning.setReleaseGroupId("POINT_" + taskDetailDO.getToMapItemId());
|
||||
pathPlanning.setReleaseLocationNumber(taskDetailDO.getToLocationNumber());
|
||||
pathPlanning.setReleasePointId(locationDOMap.get(taskDetailDO.getToLocationId()).getMapItemId());
|
||||
pathPlanning.setReleasePointId(toLocation.getMapItemId());
|
||||
pathPlanning.setReleaseHeight(Double.valueOf(toLocation.getLocationTrayHeight()+""));
|
||||
pathPlanning.setReleaseLevel(toLocation.getLocationStorey());
|
||||
pathPlanning.setReleaseOffsetHeight(offsetHeight);
|
||||
|
||||
}
|
||||
|
||||
pathPlanningList.add(pathPlanning);
|
||||
|
@ -1,9 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.service.wait;
|
||||
|
||||
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.wait.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.wait.MoveToWaitDO;
|
||||
|
||||
@ -52,5 +50,5 @@ public interface MoveToWaitService {
|
||||
*/
|
||||
PageResult<MoveToWaitDO> getMoveToWaitPage(MoveToWaitPageReqVO pageReqVO);
|
||||
|
||||
void setMoveToWaitDoing(Long orderId,Integer status);
|
||||
void updateWaitStatus(Long orderId, Integer status);
|
||||
}
|
@ -72,7 +72,7 @@ public class MoveToWaitServiceImpl implements MoveToWaitService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoveToWaitDoing(Long orderId,Integer status) {
|
||||
public void updateWaitStatus(Long orderId, Integer status) {
|
||||
MoveToWaitDO updateObj = new MoveToWaitDO();
|
||||
updateObj.setId(orderId);
|
||||
updateObj.setWaitStatus(status);
|
||||
|
Loading…
Reference in New Issue
Block a user