This commit is contained in:
cbs 2025-05-14 17:32:01 +08:00
parent 6966fe9b4c
commit 26c26007d0
14 changed files with 104 additions and 74 deletions

View File

@ -145,7 +145,7 @@ public class RemoteControllerProcessor {
cache.remove(remoteControllerIp); cache.remove(remoteControllerIp);
Socket socket = remoteControllerSocketDTO.getSocket(); Socket socket = remoteControllerSocketDTO.getSocket();
if (socket == null ||socket.isClosed()) { if (socket == null || socket.isClosed()) {
try { try {
socket = new Socket(); socket = new Socket();
socket.connect(new InetSocketAddress(remoteControllerIp, remoteControllerPort), 1000); socket.connect(new InetSocketAddress(remoteControllerIp, remoteControllerPort), 1000);
@ -186,7 +186,7 @@ public class RemoteControllerProcessor {
if (ObjectUtil.isEmpty(cache)) { if (ObjectUtil.isEmpty(cache)) {
return; return;
} }
log.info("socket发送数据开始"); // log.info("socket发送数据开始");
for (Map.Entry<String, RemoteControllerSocketDTO> v : cache.entrySet()) { for (Map.Entry<String, RemoteControllerSocketDTO> v : cache.entrySet()) {
RemoteControllerSocketDTO remoteControllerSocketDTO = v.getValue(); RemoteControllerSocketDTO remoteControllerSocketDTO = v.getValue();
if (ObjectUtil.isEmpty(remoteControllerSocketDTO)) { if (ObjectUtil.isEmpty(remoteControllerSocketDTO)) {
@ -218,8 +218,8 @@ public class RemoteControllerProcessor {
try { try {
os = socket.getOutputStream(); os = socket.getOutputStream();
String str = remoteControllerSocketDTO.getMsg(); String str = remoteControllerSocketDTO.getMsg();
log.info("socket推送的数据 :{}", str);
os.write(remoteControllerSocketDTO.getMsg().getBytes()); os.write(remoteControllerSocketDTO.getMsg().getBytes());
log.info("socket推送的数据 :{}", str);
} catch (IOException e) { } catch (IOException e) {
log.error("socket发送异常 :{}", e); log.error("socket发送异常 :{}", e);
} finally { } finally {
@ -230,7 +230,6 @@ public class RemoteControllerProcessor {
} }
} }
} }
log.info("socket发送数据成功");
} }
} }

View File

@ -16,6 +16,6 @@ public class RobotStatusDataPoseDTO {
public String floor; public String floor;
//区域 //区域
public String area; public String area;
//电池剩余容量 //电池剩余容量 废弃 从ROBOT_INFORMATION_SOC 获取电量
public String batSoc; // public String batSoc;
} }

View File

@ -3,15 +3,11 @@ package cn.iocoder.yudao.module.system.api.robot;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotGenericsDataDTO; import cn.iocoder.yudao.module.system.api.robot.dto.RobotGenericsDataDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.config.ratelimiter.SystemRateLimiter; import cn.iocoder.yudao.module.system.config.ratelimiter.SystemRateLimiter;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant; import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil; import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -26,8 +22,6 @@ public class RobotGenericsStatusApiImpl implements RobotGenericsStatusApi {
@Resource @Resource
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Resource@Value("${zn.robot_position_cache_time:10}")
private Long robotPositionCacheTime;
@Override @Override
@SystemRateLimiter(time = 1, count = 20, keyArg = "updateRobotCommonStatus",message = "机器人上报车辆其他信息") @SystemRateLimiter(time = 1, count = 20, keyArg = "updateRobotCommonStatus",message = "机器人上报车辆其他信息")
@ -43,17 +37,13 @@ public class RobotGenericsStatusApiImpl implements RobotGenericsStatusApi {
} }
String mac = robotStatusData.getMac(); String mac = robotStatusData.getMac();
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC +mac; String socKey = RobotTaskChcheConstant.ROBOT_INFORMATION_SOC +mac;
Object object = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO= JSONUtil.toBean((String)object, RobotStatusDataPoseDTO.class);
String batSoc = robotStatusData.getHwStates().getBatSoc(); String batSoc = robotStatusData.getHwStates().getBatSoc();
if (ObjectUtil.isNotEmpty(batSoc)) { if (ObjectUtil.isNotEmpty(batSoc)) {
String[] split = batSoc.split("\\."); String[] split = batSoc.split("\\.");
batSoc = split[1].substring(0,2); batSoc = split[1].substring(0,2);
robotStatusDataPoseDTO.setBatSoc(batSoc); redisUtil.set(socKey,batSoc);
} }
redisUtil.set(pose2dKey,JSON.toJSONString(robotStatusDataPoseDTO),robotPositionCacheTime);
} }
} }

View File

@ -9,29 +9,18 @@ import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
import cn.iocoder.yudao.module.system.config.ratelimiter.SystemRateLimiter; import cn.iocoder.yudao.module.system.config.ratelimiter.SystemRateLimiter;
import cn.iocoder.yudao.module.system.constant.path.PathPlanningTopicConstant; 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.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.RobotInformationService;
import cn.iocoder.yudao.module.system.service.robot.RobotWarnMsgService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil; import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@RestController // 提供 RESTful API 接口 Feign 调用 @RestController // 提供 RESTful API 接口 Feign 调用
@ -82,7 +71,7 @@ public class RobotStatusApiImpl implements RobotStatusApi {
Object floorAreaObject = redisUtil.get(floorAreaKey); Object floorAreaObject = redisUtil.get(floorAreaKey);
FloorZoneDTO floorZoneDTO = JSONUtil.toBean((String) floorAreaObject, FloorZoneDTO.class); FloorZoneDTO floorZoneDTO = JSONUtil.toBean((String) floorAreaObject, FloorZoneDTO.class);
String robotNo = robotInformationService.getRobotNoByMac(robotStatusDataDTO.getMac()); String robotNo = robotInformationService.getRobotNoByMac(robotStatusDataDTO.getMac());
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robotStatusDataDTO.getMac(); String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + robotStatusDataDTO.getMac();
Object object = redisUtil.get(pose2dKey); Object object = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class); RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);

View File

@ -9,7 +9,10 @@ public class RobotTaskChcheConstant {
public static String ROBOT_CARGO_DETECTED = "robot:information:cargo:detected"; public static String ROBOT_CARGO_DETECTED = "robot:information:cargo:detected";
//机器人点位和电量 (拼接的是mac地址) //机器人点位和电量 (拼接的是mac地址)
public static String ROBOT_INFORMATION_POSE_BAT_SOC = "robot:information:pose:bat:soc"; public static String ROBOT_INFORMATION_POSE_BAT = "robot:information:pose:bat";
//机器人电量
public static String ROBOT_INFORMATION_SOC = "robot:information:soc";
//机器人楼层和区域 (拼接的是mac地址) //机器人楼层和区域 (拼接的是mac地址)
public static String ROBOT_FLOOR_AREA = "robot:floor:area"; public static String ROBOT_FLOOR_AREA = "robot:floor:area";

View File

@ -121,4 +121,13 @@ public class RobotTaskController {
return success(pageResult); return success(pageResult);
} }
@PostMapping("/checkHaveTask")
@Operation(summary = "判断是否存在任务")
@PreAuthorize("@ss.hasPermission('robot:task:checkHaveTask')")
public CommonResult<Boolean> checkHaveTask() {
//校验是否存在未完成的任务
taskService.checkHaveDoingTask();
return success(true);
}
} }

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO; import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
@ -19,6 +20,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformati
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO; 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.RobotTaskDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnMsgDO; import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnMsgDO;
import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum;
import cn.iocoder.yudao.module.system.enums.robot.RobotTaskDetailStatusEnum; import cn.iocoder.yudao.module.system.enums.robot.RobotTaskDetailStatusEnum;
import cn.iocoder.yudao.module.system.service.dict.DictDataService; import cn.iocoder.yudao.module.system.service.dict.DictDataService;
import cn.iocoder.yudao.module.system.service.information.DeviceInformationService; import cn.iocoder.yudao.module.system.service.information.DeviceInformationService;
@ -116,7 +118,7 @@ public class BulletinBoardServiceImpl implements BulletinBoardService {
map = agvListStatusInfo.stream().collect(Collectors.toMap(RobotInfoStatusVO::getMacAddress, Function.identity())); map = agvListStatusInfo.stream().collect(Collectors.toMap(RobotInfoStatusVO::getMacAddress, Function.identity()));
} }
for (RobotInformationDO robotInformationDO : allRobot) { for (RobotInformationDO robotInformationDO : allRobot) {
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robotInformationDO.getMacAddress(); String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + robotInformationDO.getMacAddress();
Object object = redisUtil.get(pose2dKey); Object object = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class); RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
if (robotStatusDataPoseDTO != null) { if (robotStatusDataPoseDTO != null) {
@ -127,7 +129,10 @@ public class BulletinBoardServiceImpl implements BulletinBoardService {
BeanUtil.copyProperties(item, robotElectricityLevelVO); BeanUtil.copyProperties(item, robotElectricityLevelVO);
} }
robotElectricityLevelVO.setRobotNo(robotInformationDO.getRobotNo()); robotElectricityLevelVO.setRobotNo(robotInformationDO.getRobotNo());
robotElectricityLevelVO.setBatSoc(robotStatusDataPoseDTO.getBatSoc()); String socByMac = robotInformationService.getSocByMac(robotInformationDO.getMacAddress(), ZeroOneEnum.ONE.getType());
if (ObjectUtil.isNotEmpty(socByMac)) {
robotElectricityLevelVO.setBatSoc(socByMac);
}
robotElectricityLevelVOS.add(robotElectricityLevelVO); robotElectricityLevelVOS.add(robotElectricityLevelVO);
} }
} }

View File

@ -23,7 +23,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.List; import java.util.List;
import static cn.hutool.core.collection.CollUtil.isNotEmpty; import static cn.hutool.core.collection.CollUtil.isNotEmpty;
@ -128,7 +127,7 @@ public class PositionMapItemServiceImpl extends ServiceImpl<PositionMapItemMappe
@Override @Override
public Object getAGVPointInformation(String macAddress) { public Object getAGVPointInformation(String macAddress) {
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + macAddress; String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + macAddress;
try { try {
// 睡眠 0.5s 以确保获取到是最新的数据 // 睡眠 0.5s 以确保获取到是最新的数据
Thread.sleep(500); Thread.sleep(500);

View File

@ -67,6 +67,14 @@ public interface RobotInformationService extends IService<RobotInformationDO> {
*/ */
RobotInformationStatisticsVO statisticsInformation(); RobotInformationStatisticsVO statisticsInformation();
/**
* 车机mac地址获取电量
* @param str
* type 1:是mac 0 :是车辆编号
* @return
*/
String getSocByMac(String str, Integer type);
/** /**
* 获取所有AGV状态 * 获取所有AGV状态
* @return * @return

View File

@ -484,7 +484,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
RobotInformationDO robotInformationDO = informationMapper.selectById(id); RobotInformationDO robotInformationDO = informationMapper.selectById(id);
RobotInformationRespVO bean = BeanUtils.toBean(robotInformationDO, RobotInformationRespVO.class); RobotInformationRespVO bean = BeanUtils.toBean(robotInformationDO, RobotInformationRespVO.class);
setPositionMapList(bean); setPositionMapList(bean);
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + bean.getMacAddress(); String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + bean.getMacAddress();
Object object = redisUtil.get(pose2dKey); Object object = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class); RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
@ -492,7 +492,10 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
Object floorAreaObject = redisUtil.get(floorAreaKey); Object floorAreaObject = redisUtil.get(floorAreaKey);
FloorZoneDTO floorZoneDTO = JSONUtil.toBean((String) floorAreaObject, FloorZoneDTO.class); FloorZoneDTO floorZoneDTO = JSONUtil.toBean((String) floorAreaObject, FloorZoneDTO.class);
if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) { if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) {
bean.setElectricity(robotStatusDataPoseDTO.getBatSoc()); String soc = getSocByMac(robotInformationDO.getMacAddress(), ZeroOneEnum.ONE.getType());
if (ObjectUtil.isNotEmpty(soc)) {
bean.setElectricity(soc);
}
bean.setFloor(floorZoneDTO.getFloor()); bean.setFloor(floorZoneDTO.getFloor());
bean.setArea(floorZoneDTO.getArea()); bean.setArea(floorZoneDTO.getArea());
} }
@ -576,7 +579,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
* @param v * @param v
*/ */
private void setMsgAndRobotStatus(RobotInformationPageRespVO v, String robotStatisticsType) { private void setMsgAndRobotStatus(RobotInformationPageRespVO v, String robotStatisticsType) {
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + v.getMacAddress(); String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + v.getMacAddress();
Object object = redisUtil.get(pose2dKey); Object object = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class); RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
@ -588,7 +591,10 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
FloorZoneDTO floorZoneDTO = JSONUtil.toBean((String) floorAreaObject, FloorZoneDTO.class); FloorZoneDTO floorZoneDTO = JSONUtil.toBean((String) floorAreaObject, FloorZoneDTO.class);
if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) { if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) {
v.setElectricity(robotStatusDataPoseDTO.getBatSoc()); String soc = getSocByMac(v.getMacAddress(), ZeroOneEnum.ONE.getType());
if (ObjectUtil.isNotEmpty(soc)) {
v.setElectricity(soc);
}
v.setFloor(floorZoneDTO.getFloor()); v.setFloor(floorZoneDTO.getFloor());
v.setArea(floorZoneDTO.getArea()); v.setArea(floorZoneDTO.getArea());
v.setOnlineStatus(1); v.setOnlineStatus(1);
@ -653,7 +659,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
Integer fault = 0; Integer fault = 0;
//0待命1任务中2锁定3离线4:充电中5:故障 //0待命1任务中2锁定3离线4:充电中5:故障
for (RobotInformationDO v : existRobot) { for (RobotInformationDO v : existRobot) {
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + v.getMacAddress(); String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + v.getMacAddress();
Object object = redisUtil.get(pose2dKey); Object object = redisUtil.get(pose2dKey);
if (ObjectUtil.isEmpty(object)) { if (ObjectUtil.isEmpty(object)) {
@ -694,6 +700,26 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
return info; return info;
} }
/**
*
* @param str
* type 1:是mac 0 :是车辆编号
* @param type
* @return
*/
@Override
public String getSocByMac(String str, Integer type) {
if (ZeroOneEnum.ZERO.getType().equals(type)) {
str = getMacByRobotNo(str);
}
String socKey = RobotTaskChcheConstant.ROBOT_INFORMATION_SOC +str;
Object o = redisUtil.get(socKey);
if (ObjectUtil.isEmpty(o)){
return null;
}
return o.toString();
}
@Override @Override
public List<RobotInfoStatusVO> getAGVListStatusInfo() { public List<RobotInfoStatusVO> getAGVListStatusInfo() {
List<RobotInfoStatusVO> list = new ArrayList<>(); List<RobotInfoStatusVO> list = new ArrayList<>();
@ -706,7 +732,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
RobotInfoStatusVO vo = new RobotInfoStatusVO(); RobotInfoStatusVO vo = new RobotInfoStatusVO();
vo.setMacAddress(informationDO.getMacAddress()); vo.setMacAddress(informationDO.getMacAddress());
//0待命1任务中2锁定3离线4:充电中5:故障 //0待命1任务中2锁定3离线4:充电中5:故障
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + informationDO.getMacAddress(); String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + informationDO.getMacAddress();
Object object = redisUtil.get(pose2dKey); Object object = redisUtil.get(pose2dKey);
if (ObjectUtil.isEmpty(object)) { if (ObjectUtil.isEmpty(object)) {
//离线 //离线
@ -799,7 +825,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
robotStatusDataPoseDTO.setYaw(robotStatusDataDTO.getData().getPose2d().getYaw()); robotStatusDataPoseDTO.setYaw(robotStatusDataDTO.getData().getPose2d().getYaw());
robotStatusDataPoseDTO.setFloor(robotStatusDataDTO.getData().getFloor_zone().getFloor()); robotStatusDataPoseDTO.setFloor(robotStatusDataDTO.getData().getFloor_zone().getFloor());
robotStatusDataPoseDTO.setArea(robotStatusDataDTO.getData().getFloor_zone().getArea()); robotStatusDataPoseDTO.setArea(robotStatusDataDTO.getData().getFloor_zone().getArea());
robotStatusDataPoseDTO.setBatSoc(robotStatusDataDTO.getData().getPose2d().getBatSoc()); // robotStatusDataPoseDTO.setBatSoc(robotStatusDataDTO.getData().getPose2d().getBatSoc());
robotInformationVO.setPose2d(robotStatusDataPoseDTO); robotInformationVO.setPose2d(robotStatusDataPoseDTO);
@ -1369,20 +1395,14 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
CommonConfigVO chargeConfig = JSONUtil.toBean(commonConfig.getConfigStr(), CommonConfigVO.class); CommonConfigVO chargeConfig = JSONUtil.toBean(commonConfig.getConfigStr(), CommonConfigVO.class);
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robotInformation.getMacAddress(); String soc = getSocByMac(robotInformation.getMacAddress(), ZeroOneEnum.ONE.getType());
Object poseCache = redisUtil.get(pose2dKey); if (ObjectUtil.isEmpty(soc)) {
if (ObjectUtil.isEmpty(poseCache)) {
log.info("车机没有电量信息 :{}", robotInformation.getRobotNo());
return false;
}
RobotStatusDataPoseDTO dataPoseDTO = JSON.parseObject((String) poseCache, RobotStatusDataPoseDTO.class);
if (ObjectUtil.isEmpty(dataPoseDTO.getBatSoc())) {
log.info("车机没有电量信息 :{}", robotInformation.getRobotNo()); log.info("车机没有电量信息 :{}", robotInformation.getRobotNo());
return false; return false;
} }
if (ObjectUtil.isNotEmpty(chargeConfig) && ObjectUtil.isNotEmpty(chargeConfig.getStartAutoCharge())) { if (ObjectUtil.isNotEmpty(chargeConfig) && ObjectUtil.isNotEmpty(chargeConfig.getStartAutoCharge())) {
BigDecimal robotRemainingElectricity = new BigDecimal(dataPoseDTO.getBatSoc()); BigDecimal robotRemainingElectricity = new BigDecimal(soc);
BigDecimal robotEndElectricity = new BigDecimal(chargeConfig.getStartAutoCharge() + ""); BigDecimal robotEndElectricity = new BigDecimal(chargeConfig.getStartAutoCharge() + "");
if (robotRemainingElectricity.compareTo(robotEndElectricity) < 0) { if (robotRemainingElectricity.compareTo(robotEndElectricity) < 0) {
log.info("机器人的电量少于自动充电电量,不能接任务 :{}", robotInformation.getRobotNo()); log.info("机器人的电量少于自动充电电量,不能接任务 :{}", robotInformation.getRobotNo());
@ -1390,7 +1410,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
} }
} }
return checkElectricity(chargeConfig, robotInformation, dataPoseDTO); return checkElectricity(chargeConfig, robotInformation,soc);
} }
@Override @Override
@ -1490,13 +1510,13 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
informationMapper.updateById(robotInformationDO); informationMapper.updateById(robotInformationDO);
} }
private Boolean checkElectricity(CommonConfigVO chargeConfig, RobotInformationDO robot, RobotStatusDataPoseDTO dataPoseDTO) { private Boolean checkElectricity(CommonConfigVO chargeConfig, RobotInformationDO robot, String soc) {
String chargeModelKey = RobotTaskChcheConstant.ROBOT_CHARGE_MODEL + robot.getRobotNo(); String chargeModelKey = RobotTaskChcheConstant.ROBOT_CHARGE_MODEL + robot.getRobotNo();
Object chargeModelCache = redisUtil.get(chargeModelKey); Object chargeModelCache = redisUtil.get(chargeModelKey);
log.info("充电机器人编号:{} ,信息: {}", robot.getRobotNo(), JSON.toJSONString(dataPoseDTO)); log.info("充电机器人编号:{} ,信息: {}", robot.getRobotNo());
//车子剩余电量 //车子剩余电量
BigDecimal robotRemainingElectricity = new BigDecimal(dataPoseDTO.getBatSoc()); BigDecimal robotRemainingElectricity = new BigDecimal(soc);
//设置离开的电量 //设置离开的电量
BigDecimal robotEndElectricity = new BigDecimal("10"); BigDecimal robotEndElectricity = new BigDecimal("10");

View File

@ -991,8 +991,8 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
* @param robotTaskVo * @param robotTaskVo
*/ */
private void doMoveToPoint(RobotTaskDetailAddVO robotTaskVo) { private void doMoveToPoint(RobotTaskDetailAddVO robotTaskVo) {
PositionMapItemDO positionMapItem = positionMapItemService.getPositionMapItem(robotTaskVo.getReleaseId());
robotTaskVo.setToLocationNo(String.valueOf(positionMapItem.getSortNum()));
} }
/** /**
@ -1474,12 +1474,11 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
robotChargeLogDO.setEndTime(LocalDateTime.now()); robotChargeLogDO.setEndTime(LocalDateTime.now());
deviceInformationService.chargeDeviceShrink(robotChargeLogDO.getDeviceNo()); deviceInformationService.chargeDeviceShrink(robotChargeLogDO.getDeviceNo());
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robotInformationDO.getMacAddress(); String socKey = RobotTaskChcheConstant.ROBOT_INFORMATION_SOC +robotInformationDO.getMacAddress();
Object object = redisUtil.get(pose2dKey); Object socObject = redisUtil.get(socKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) { if (ObjectUtil.isNotEmpty(socObject)) {
robotChargeLogDO.setEndElectricity(Integer.valueOf(robotStatusDataPoseDTO.getBatSoc())); robotChargeLogDO.setEndElectricity(Integer.valueOf(socObject.toString()));
} }
robotChargeLogDO.setTaskStatus(ChargeTaskStatusEnum.DONE.getType()); robotChargeLogDO.setTaskStatus(ChargeTaskStatusEnum.DONE.getType());
chargeLogMapper.updateById(robotChargeLogDO); chargeLogMapper.updateById(robotChargeLogDO);

View File

@ -160,10 +160,14 @@ public class AutoChargeServiceImpl implements AutoChargeService {
List<RobotChargeLogDO> logs, Map<String, List<RobotTaskDetailDO>> detailMap) { List<RobotChargeLogDO> logs, Map<String, List<RobotTaskDetailDO>> detailMap) {
//判断机器人身上的电量少于设定的电量 //判断机器人身上的电量少于设定的电量
for (RobotInformationDO robot : robots) { for (RobotInformationDO robot : robots) {
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC +robot.getMacAddress(); String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT +robot.getMacAddress();
Object poseCache = redisUtil.get(pose2dKey); Object poseCache = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO dataPoseDTO= JSON.parseObject((String)poseCache, RobotStatusDataPoseDTO.class); RobotStatusDataPoseDTO dataPoseDTO= JSON.parseObject((String)poseCache, RobotStatusDataPoseDTO.class);
if (ObjectUtil.isEmpty(dataPoseDTO) || ObjectUtil.isEmpty(dataPoseDTO.getBatSoc())) {
String socKey = RobotTaskChcheConstant.ROBOT_INFORMATION_SOC +robot.getMacAddress();
Object socObject = redisUtil.get(socKey);
if (ObjectUtil.isEmpty(dataPoseDTO) || ObjectUtil.isEmpty(socObject)) {
log.info("当前机器人查不到电量信息,所以不执行充电 :{}",robot.getRobotNo()); log.info("当前机器人查不到电量信息,所以不执行充电 :{}",robot.getRobotNo());
continue; continue;
} }
@ -187,7 +191,8 @@ public class AutoChargeServiceImpl implements AutoChargeService {
logDo.setRobotNo(robot.getRobotNo()); logDo.setRobotNo(robot.getRobotNo());
logDo.setDeviceNo(deviceInformationDO.getDeviceNo()); logDo.setDeviceNo(deviceInformationDO.getDeviceNo());
logDo.setPositionMapItemId(deviceInformationDO.getPositionMapItemId()); logDo.setPositionMapItemId(deviceInformationDO.getPositionMapItemId());
String[] split = dataPoseDTO.getBatSoc().split("\\.");
String[] split = socObject.toString().split("\\.");
logDo.setStartElectricity(Integer.valueOf(split[0])); logDo.setStartElectricity(Integer.valueOf(split[0]));
//配置的充满电电量 //配置的充满电电量
BigDecimal robotFullElectricity = new BigDecimal(fullElectricity); BigDecimal robotFullElectricity = new BigDecimal(fullElectricity);

View File

@ -129,15 +129,15 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
} }
if (ObjectUtil.isNotEmpty(chargeConfig) && ObjectUtil.isNotEmpty(chargeConfig.getStartAutoCharge())) { if (ObjectUtil.isNotEmpty(chargeConfig) && ObjectUtil.isNotEmpty(chargeConfig.getStartAutoCharge())) {
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robot.getMacAddress(); String socKey = RobotTaskChcheConstant.ROBOT_INFORMATION_SOC +robot.getMacAddress();
Object poseCache = redisUtil.get(pose2dKey); Object socObject = redisUtil.get(socKey);
RobotStatusDataPoseDTO dataPoseDTO = JSON.parseObject((String) poseCache, RobotStatusDataPoseDTO.class);
if (ObjectUtil.isEmpty(dataPoseDTO.getBatSoc())) { if (ObjectUtil.isEmpty(socObject)) {
robot.setRobotStatus(RobotStatusEnum.DOING.getType()); robot.setRobotStatus(RobotStatusEnum.DOING.getType());
log.info("车机没有电量信息 :{}",robot.getRobotNo()); log.info("车机没有电量信息 :{}",robot.getRobotNo());
continue; continue;
} }
BigDecimal robotRemainingElectricity = new BigDecimal(dataPoseDTO.getBatSoc()); BigDecimal robotRemainingElectricity = new BigDecimal(socObject.toString());
BigDecimal robotEndElectricity = new BigDecimal(chargeConfig.getStartAutoCharge()+""); BigDecimal robotEndElectricity = new BigDecimal(chargeConfig.getStartAutoCharge()+"");
if (robotRemainingElectricity.compareTo(robotEndElectricity) < 0) { if (robotRemainingElectricity.compareTo(robotEndElectricity) < 0) {
robot.setRobotStatus(RobotStatusEnum.DOING.getType()); robot.setRobotStatus(RobotStatusEnum.DOING.getType());
@ -235,21 +235,25 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
* @param robot * @param robot
*/ */
private void setRobotStatus(CommonConfigDO commonConfigDO, RobotInformationDO robot) { private void setRobotStatus(CommonConfigDO commonConfigDO, RobotInformationDO robot) {
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robot.getMacAddress(); String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + robot.getMacAddress();
String chargeModelKey = RobotTaskChcheConstant.ROBOT_CHARGE_MODEL + robot.getRobotNo(); String chargeModelKey = RobotTaskChcheConstant.ROBOT_CHARGE_MODEL + robot.getRobotNo();
Object chargeModelCache = redisUtil.get(chargeModelKey); Object chargeModelCache = redisUtil.get(chargeModelKey);
Object poseCache = redisUtil.get(pose2dKey); Object poseCache = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO dataPoseDTO = JSON.parseObject((String) poseCache, RobotStatusDataPoseDTO.class); RobotStatusDataPoseDTO dataPoseDTO = JSON.parseObject((String) poseCache, RobotStatusDataPoseDTO.class);
log.info("充电机器人编号:{} ,信息: {}", robot.getRobotNo(), JSON.toJSONString(dataPoseDTO)); log.info("充电机器人编号:{} ,信息: {}", robot.getRobotNo(), JSON.toJSONString(dataPoseDTO));
if (ObjectUtil.isEmpty(commonConfigDO) || ObjectUtil.isEmpty(poseCache) || ObjectUtil.isEmpty(dataPoseDTO.getBatSoc())) { String socKey = RobotTaskChcheConstant.ROBOT_INFORMATION_SOC +robot.getMacAddress();
Object o = redisUtil.get(socKey);
String soc = ObjectUtil.isEmpty(o) ? "0": o.toString();
if (ObjectUtil.isEmpty(commonConfigDO) || ObjectUtil.isEmpty(poseCache) || ObjectUtil.isEmpty(o)) {
return; return;
} }
CommonConfigVO chargeConfig = JSONUtil.toBean(commonConfigDO.getConfigStr(), CommonConfigVO.class); CommonConfigVO chargeConfig = JSONUtil.toBean(commonConfigDO.getConfigStr(), CommonConfigVO.class);
//车子剩余电量 //车子剩余电量
BigDecimal robotRemainingElectricity = new BigDecimal(dataPoseDTO.getBatSoc()); BigDecimal robotRemainingElectricity = new BigDecimal(soc);
//设置离开的电量 //设置离开的电量
BigDecimal robotEndElectricity = new BigDecimal("10"); BigDecimal robotEndElectricity = new BigDecimal("10");

View File

@ -196,7 +196,7 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
List<RobotPositionMapDTO> list = new ArrayList<>(); List<RobotPositionMapDTO> list = new ArrayList<>();
for (RobotInformationDO robot : robots) { for (RobotInformationDO robot : robots) {
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robot.getMacAddress(); String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + robot.getMacAddress();
Object object = redisUtil.get(pose2dKey); Object object = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class); RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
if (ObjectUtil.isEmpty(object) || ObjectUtil.isEmpty(robotStatusDataPoseDTO)) { if (ObjectUtil.isEmpty(object) || ObjectUtil.isEmpty(robotStatusDataPoseDTO)) {