代码优化

This commit is contained in:
cbs 2025-06-20 09:35:17 +08:00
parent 235f751e13
commit a2841e9276
6 changed files with 20 additions and 9 deletions

View File

@ -18,6 +18,7 @@ public class RobotPoseStatusDTO {
* true表示可以做任务如果是到达了充电点正在充电中应该返回true
*/
public Boolean taskStatus;
public String timestamp;
/**
* 机器人位姿

View File

@ -20,4 +20,6 @@ public class RobotStatusDataPoseDTO {
public Double forkHeight;
//电池剩余容量 废弃 从ROBOT_INFORMATION_SOC 获取电量
// public String batSoc;
public String timestamp;
}

View File

@ -111,6 +111,7 @@ public class RobotStatusApiImpl implements RobotStatusApi {
redisUtil.set(pose2dKey, JSON.toJSONString(robotStatusDataPoseDTO), znConfigConstant.getRobotPositionCacheTime());
executorService.execute(() ->{
robotStatusDataPoseDTO.setTimestamp(robotStatusDataDTO.getTimestamp());
sendToPP(robotStatusDataPoseDTO);
});

View File

@ -414,7 +414,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
robotTaskDetailDO.setTaskStage(RobotTaskStageEnum.UN_START.getType());
if (!znConfigConstant.getIsSimulation()) {
robotTaskDetailDO.setRobotNo("");
// robotTaskDetailDO.setRobotNo("");
}
robotTaskDetailDO.setOccurError(ZeroOneEnum.ZERO.getType());
robotTaskDetailMapper.updateById(robotTaskDetailDO);

View File

@ -42,7 +42,7 @@ public class ThreeDimensionalScheduled {
private static final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(3);
// 这个方法将每200毫秒执行一次
@Scheduled(fixedDelay = 300, timeUnit = TimeUnit.MILLISECONDS)
// @Scheduled(fixedDelay = 300, timeUnit = TimeUnit.MILLISECONDS)
public void executeTask() {
fixedThreadPool.execute(new Runnable() {
@Override

View File

@ -1425,12 +1425,19 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
throw exception(ROBOT_NOT_FOUND_FREE_CHARGING_STATION);
}
DeviceInformationDO deviceInformationDO = deviceInformations.stream()
.filter(v -> v.getDeviceAttribute().equals(robot.getChargeType())
&& robot.getFloorAreaJson().contains(v.getPositionMapId()))
.findFirst()
.orElse(new DeviceInformationDO());
if (ObjectUtil.isEmpty(deviceInformationDO.getDeviceNo())) {
DeviceInformationDO deviceInformationDO = null;
for (DeviceInformationDO v : deviceInformations) {
if (ObjectUtil.isNotEmpty(v.getLastUser()) && v.getLastUser().equals(robot.getRobotNo())) {
deviceInformationDO = v;
break;
}
if (v.getDeviceAttribute().equals(robot.getChargeType())
&& robot.getFloorAreaJson().contains(v.getPositionMapId()) && DeviceUseStatusEnum.IDLE.getType().equals(v.getDeviceUseStatus())) {
deviceInformationDO = v;
}
}
if (ObjectUtil.isEmpty(deviceInformationDO)) {
log.info("当前机器人查不到对应的充电桩类型、或者机器人不能在此区域充电 :{}", robot.getRobotNo());
throw exception(ROBOT_NOT_FOUND_FREE_CHARGING_STATION);
}
@ -1477,7 +1484,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
|| RobotTaskStageEnum.GO_TAKE.getType().equals(robotTaskDetail.getTaskStage())) {
log.info("清除交管--任务阶段是前往取货/待执行/前往放货 :{}", robotTaskDetail.getRobotNo());
robotTaskDetail.setTaskStatus(RobotTaskDetailStatusEnum.NEW.getType());
robotTaskDetail.setRobotNo(null);
// robotTaskDetail.setRobotNo(null);
taskDetailMapper.updateById(robotTaskDetail);
}
}