Compare commits
2 Commits
5c9ef72ba0
...
a743e1aff7
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a743e1aff7 | ||
![]() |
28d30da941 |
@ -0,0 +1,24 @@
|
|||||||
|
package cn.iocoder.yudao.module.mqtt.api.path.task;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送任务给PP
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TaskToPathPlanningDTO {
|
||||||
|
|
||||||
|
@Schema(description = "robot_task_detail 的 id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "能执行此任务的机器人编号")
|
||||||
|
private List<String> robotNoList;
|
||||||
|
|
||||||
|
//线库: LINE + 线库号
|
||||||
|
//普通库位: POINT + 点位号
|
||||||
|
@Schema(description = "取的编号: 线库id+点位id")
|
||||||
|
private String takeId;
|
||||||
|
}
|
@ -7,43 +7,43 @@ public class PathPlanningTopicConstant {
|
|||||||
/**
|
/**
|
||||||
* 同步全部地图点位 ware_position_map_line数据
|
* 同步全部地图点位 ware_position_map_line数据
|
||||||
*/
|
*/
|
||||||
public static String SYNCHRONOUS_ALL_MAP_POINT = "SYNCHRONOUS_MAP_POINT";
|
public static String SYNCHRONOUS_ALL_MAP_LINE = "SYNCHRONOUS_ALL_MAP_LINE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步 ware_position_map_item数据
|
* 同步 ware_position_map_item数据
|
||||||
*/
|
*/
|
||||||
public static String SYNCHRONOUS_ALL_ITEM = "SYNCHRONOUS_ALL_ITEM";
|
public static String SYNCHRONOUS_ALL_MAP_NODE = "SYNCHRONOUS_ALL_MAP_NODE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加ware_position_map_line地图点位给PP
|
* 添加ware_position_map_line地图点位给PP
|
||||||
*/
|
*/
|
||||||
public static String ADD_MAP_POINT = "ADD_MAP_POINT";
|
public static String ADD_MAP_LINE = "ADD_MAP_LINE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除ware_position_map_line地图点位给PP
|
* 删除ware_position_map_line地图点位给PP
|
||||||
*/
|
*/
|
||||||
public static String DELETE_MAP_POINT = "DELETE_MAP_POINT";
|
public static String DELETE_MAP_LINE = "DELETE_MAP_LINE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新ware_position_map_line地图点位给PP
|
* 更新ware_position_map_line地图点位给PP
|
||||||
*/
|
*/
|
||||||
public static String UPDATE_MAP_POINT = "UPDATE_MAP_POINT";
|
public static String UPDATE_MAP_LINE = "UPDATE_MAP_LINE";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加ware_position_map_item地图点位给PP
|
* 添加ware_position_map_item地图点位给PP
|
||||||
*/
|
*/
|
||||||
public static String ADD_MAP_ITEM = "ADD_MAP_ITEM";
|
public static String ADD_MAP_NODE = "ADD_MAP_NODE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除ware_position_map_item地图点位给PP
|
* 删除ware_position_map_item地图点位给PP
|
||||||
*/
|
*/
|
||||||
public static String DELETE_MAP_ITEM = "DELETE_MAP_ITEM";
|
public static String DELETE_MAP_NODE = "DELETE_MAP_NODE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新ware_position_map_item地图点位给PP
|
* 更新ware_position_map_item地图点位给PP
|
||||||
*/
|
*/
|
||||||
public static String UPDATE_MAP_ITEM = "UPDATE_MAP_ITEM";
|
public static String UPDATE_MAP_NODE = "UPDATE_MAP_NODE";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,13 +12,16 @@ import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
@ -45,11 +48,11 @@ public class CommonConfigServiceImpl implements CommonConfigService {
|
|||||||
CommonConfigDO config = BeanUtils.toBean(createReqVO, CommonConfigDO.class);
|
CommonConfigDO config = BeanUtils.toBean(createReqVO, CommonConfigDO.class);
|
||||||
|
|
||||||
if (ZeroOneEnum.ONE.getType().equals(config.getConfigType())) {
|
if (ZeroOneEnum.ONE.getType().equals(config.getConfigType())) {
|
||||||
CommonConfigVO chargeConfig= JSONUtil.toBean(config.getConfigStr(),CommonConfigVO.class);
|
CommonConfigVO chargeConfig = JSONUtil.toBean(config.getConfigStr(), CommonConfigVO.class);
|
||||||
//一次
|
//一次
|
||||||
if (ZeroOneEnum.ZERO.getType().equals(chargeConfig.getEveryDay())
|
if (ZeroOneEnum.ZERO.getType().equals(chargeConfig.getEveryDay())
|
||||||
&& ObjectUtil.isNotEmpty(chargeConfig.getScheduleChargeStartTime())) {
|
&& ObjectUtil.isNotEmpty(chargeConfig.getScheduleChargeStartTime())) {
|
||||||
setOnceStartTimeConfig(config,chargeConfig);
|
setOnceStartTimeConfig(config, chargeConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +63,7 @@ public class CommonConfigServiceImpl implements CommonConfigService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置一次的开始时间和结束时间
|
* 设置一次的开始时间和结束时间
|
||||||
|
*
|
||||||
* @param config
|
* @param config
|
||||||
* @param chargeConfig
|
* @param chargeConfig
|
||||||
*/
|
*/
|
||||||
@ -69,8 +73,8 @@ public class CommonConfigServiceImpl implements CommonConfigService {
|
|||||||
LocalDateTime nowEnd = LocalDateTime.now();
|
LocalDateTime nowEnd = LocalDateTime.now();
|
||||||
|
|
||||||
if (now.isAfter(chargeConfig.getScheduleChargeEndTime())) {
|
if (now.isAfter(chargeConfig.getScheduleChargeEndTime())) {
|
||||||
now.plusDays(1);
|
now = now.plusDays(1);
|
||||||
nowEnd.plusDays(1);
|
nowEnd = nowEnd.plusDays(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDateTime s = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(),
|
LocalDateTime s = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(),
|
||||||
@ -103,12 +107,12 @@ public class CommonConfigServiceImpl implements CommonConfigService {
|
|||||||
CommonConfigDO updateObj = BeanUtils.toBean(updateReqVO, CommonConfigDO.class);
|
CommonConfigDO updateObj = BeanUtils.toBean(updateReqVO, CommonConfigDO.class);
|
||||||
|
|
||||||
if (ZeroOneEnum.ONE.getType().equals(updateReqVO.getConfigType())) {
|
if (ZeroOneEnum.ONE.getType().equals(updateReqVO.getConfigType())) {
|
||||||
CommonConfigVO chargeConfig= JSONUtil.toBean(updateReqVO.getConfigStr(),CommonConfigVO.class);
|
CommonConfigVO chargeConfig = JSONUtil.toBean(updateReqVO.getConfigStr(), CommonConfigVO.class);
|
||||||
//一次
|
//一次
|
||||||
if (ZeroOneEnum.ZERO.getType().equals(chargeConfig.getEveryDay())
|
if (ZeroOneEnum.ZERO.getType().equals(chargeConfig.getEveryDay())
|
||||||
&& ObjectUtil.isNotEmpty(chargeConfig.getScheduleChargeStartTime())) {
|
&& ObjectUtil.isNotEmpty(chargeConfig.getScheduleChargeStartTime())) {
|
||||||
setOnceStartTimeConfig(updateObj,chargeConfig);
|
setOnceStartTimeConfig(updateObj, chargeConfig);
|
||||||
}else if(ZeroOneEnum.ONE.getType().equals(chargeConfig.getEveryDay()) ) {
|
} else if (ZeroOneEnum.ONE.getType().equals(chargeConfig.getEveryDay())) {
|
||||||
JSONObject jsonObject = new JSONObject(updateObj.getConfigStr());
|
JSONObject jsonObject = new JSONObject(updateObj.getConfigStr());
|
||||||
jsonObject.put("onceStartTime", "");
|
jsonObject.put("onceStartTime", "");
|
||||||
jsonObject.put("onceEndTime", "");
|
jsonObject.put("onceEndTime", "");
|
||||||
|
@ -121,7 +121,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
|
|||||||
relatedPathNode.setType(PathTypeEnum.INIT.getType());
|
relatedPathNode.setType(PathTypeEnum.INIT.getType());
|
||||||
relatedPathNode.setControl_nodes(positionMapItemSynDTOS);
|
relatedPathNode.setControl_nodes(positionMapItemSynDTOS);
|
||||||
|
|
||||||
pathPlanningApi.synchronousLineObject(relatedPathNode, PathPlanningTopicConstant.SYNCHRONOUS_ALL_ITEM);
|
pathPlanningApi.synchronousLineObject(relatedPathNode, PathPlanningTopicConstant.SYNCHRONOUS_ALL_MAP_NODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
|
|||||||
relatedPathNode.setArea(positionMapDO.getArea());
|
relatedPathNode.setArea(positionMapDO.getArea());
|
||||||
relatedPathNode.setControl_nodes(list);
|
relatedPathNode.setControl_nodes(list);
|
||||||
|
|
||||||
pathPlanningApi.synchronousLineObject(relatedPathNode, PathPlanningTopicConstant.ADD_MAP_POINT);
|
pathPlanningApi.synchronousLineObject(relatedPathNode, PathPlanningTopicConstant.ADD_MAP_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,7 +195,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
|
|||||||
ids.add(data.getId());
|
ids.add(data.getId());
|
||||||
relatedPathNode.setIds(ids);
|
relatedPathNode.setIds(ids);
|
||||||
|
|
||||||
pathPlanningApi.synchronousLineObject(relatedPathNode, PathPlanningTopicConstant.DELETE_MAP_POINT);
|
pathPlanningApi.synchronousLineObject(relatedPathNode, PathPlanningTopicConstant.DELETE_MAP_LINE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
|
|||||||
relatedPathNode.setType(PathTypeEnum.UPDATE.getType());
|
relatedPathNode.setType(PathTypeEnum.UPDATE.getType());
|
||||||
relatedPathNode.setControl_nodes(list);
|
relatedPathNode.setControl_nodes(list);
|
||||||
|
|
||||||
pathPlanningApi.synchronousLineObject(relatedPathNode, PathPlanningTopicConstant.UPDATE_MAP_POINT);
|
pathPlanningApi.synchronousLineObject(relatedPathNode, PathPlanningTopicConstant.UPDATE_MAP_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -279,7 +279,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
|
|||||||
PositionMapItemPathDTO.setType(PathTypeEnum.ADD.getType());
|
PositionMapItemPathDTO.setType(PathTypeEnum.ADD.getType());
|
||||||
PositionMapItemPathDTO.setControl_nodes(Arrays.asList(build));
|
PositionMapItemPathDTO.setControl_nodes(Arrays.asList(build));
|
||||||
|
|
||||||
pathPlanningApi.synchronousLineObject(PositionMapItemPathDTO, PathPlanningTopicConstant.ADD_MAP_ITEM);
|
pathPlanningApi.synchronousLineObject(PositionMapItemPathDTO, PathPlanningTopicConstant.ADD_MAP_NODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -312,7 +312,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
|
|||||||
PositionMapItemPathDTO.setType(PathTypeEnum.DELETE.getType());
|
PositionMapItemPathDTO.setType(PathTypeEnum.DELETE.getType());
|
||||||
PositionMapItemPathDTO.setIds(Arrays.asList(data.getId()));
|
PositionMapItemPathDTO.setIds(Arrays.asList(data.getId()));
|
||||||
|
|
||||||
pathPlanningApi.synchronousLineObject(PositionMapItemPathDTO, PathPlanningTopicConstant.DELETE_MAP_ITEM);
|
pathPlanningApi.synchronousLineObject(PositionMapItemPathDTO, PathPlanningTopicConstant.DELETE_MAP_NODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -347,7 +347,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
|
|||||||
PositionMapItemPathDTO.setType(PathTypeEnum.UPDATE.getType());
|
PositionMapItemPathDTO.setType(PathTypeEnum.UPDATE.getType());
|
||||||
PositionMapItemPathDTO.setControl_nodes(Arrays.asList(build));
|
PositionMapItemPathDTO.setControl_nodes(Arrays.asList(build));
|
||||||
|
|
||||||
pathPlanningApi.synchronousLineObject(PositionMapItemPathDTO, PathPlanningTopicConstant.UPDATE_MAP_ITEM);
|
pathPlanningApi.synchronousLineObject(PositionMapItemPathDTO, PathPlanningTopicConstant.UPDATE_MAP_NODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PositionMapLineDTO setPositionMapLineDTOData(PositionMapLineDTO positionMapLineDO) {
|
public PositionMapLineDTO setPositionMapLineDTOData(PositionMapLineDTO positionMapLineDO) {
|
||||||
@ -391,7 +391,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
|
|||||||
|
|
||||||
relatedPathNode.setControl_nodes(list);
|
relatedPathNode.setControl_nodes(list);
|
||||||
|
|
||||||
pathPlanningApi.synchronousPointToPP(relatedPathNode, PathPlanningTopicConstant.SYNCHRONOUS_ALL_MAP_POINT);
|
pathPlanningApi.synchronousPointToPP(relatedPathNode, PathPlanningTopicConstant.SYNCHRONOUS_ALL_MAP_LINE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapItemMappe
|
|||||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskMapper;
|
||||||
|
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.config.CommandConfigTypeEnum;
|
||||||
import cn.iocoder.yudao.module.system.enums.robot.*;
|
import cn.iocoder.yudao.module.system.enums.robot.*;
|
||||||
import cn.iocoder.yudao.module.system.enums.robot.charge.ChargeModelEnum;
|
import cn.iocoder.yudao.module.system.enums.robot.charge.ChargeModelEnum;
|
||||||
@ -34,6 +35,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
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.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -116,7 +118,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
// List<RobotTaskDetailDO> cycleTaskDetails = robotTaskMapper.getCycleTaskDetails();
|
// List<RobotTaskDetailDO> cycleTaskDetails = robotTaskMapper.getCycleTaskDetails();
|
||||||
//任务下发给机器人
|
//任务下发给机器人
|
||||||
distributeTasks(robots,taskDetailDOS);
|
distributeTasks(robots, taskDetailDOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,24 +127,21 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Pair<List<RobotInformationDO>, List<RobotTaskDetailDO>> getRobotAndTaskDetails() {
|
public Pair<List<RobotInformationDO>, List<RobotTaskDetailDO>> getRobotAndTaskDetails() {
|
||||||
|
TenantContextHolder.setTenantId(1L);
|
||||||
Pair<List<RobotInformationDO>, List<RobotTaskDetailDO>> pair = Pair.of(new ArrayList<>(), new ArrayList<>());
|
Pair<List<RobotInformationDO>, List<RobotTaskDetailDO>> pair = Pair.of(new ArrayList<>(), new ArrayList<>());
|
||||||
|
|
||||||
CommonConfigDO commonConfigDO = configMapper.selectOne(new LambdaQueryWrapper<CommonConfigDO>()
|
CommonConfigDO commonConfigDO = configMapper.selectOne(new LambdaQueryWrapper<CommonConfigDO>()
|
||||||
.eq(CommonConfigDO::getConfigType, CommandConfigTypeEnum.CHARG_CONFIG.getType()));
|
.eq(CommonConfigDO::getConfigType, CommandConfigTypeEnum.CHARG_CONFIG.getType()));
|
||||||
CommonConfigVO chargeConfig= JSONUtil.toBean(commonConfigDO.getConfigStr(),CommonConfigVO.class);
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
Boolean needDoCharge = needDoCharge(commonConfigDO);
|
||||||
if ((ObjectUtil.isNotEmpty(chargeConfig.getScheduleChargeEndTime()) &&
|
if (needDoCharge) {
|
||||||
(ObjectUtil.isNotEmpty(chargeConfig.getScheduleChargeStartTime())))
|
log.info("所有机器人都需要去执行充电任务");
|
||||||
&& (now.isBefore(chargeConfig.getScheduleChargeEndTime()) && now.isAfter(chargeConfig.getScheduleChargeStartTime()))) {
|
|
||||||
log.info("充电时间,不派发任务");
|
|
||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
TenantContextHolder.setTenantId(1L);
|
|
||||||
List<RobotInformationDO> robots = robotInformationMapper.selectList(new LambdaQueryWrapperX<RobotInformationDO>()
|
List<RobotInformationDO> robots = robotInformationMapper.selectList(new LambdaQueryWrapperX<RobotInformationDO>()
|
||||||
.in(RobotInformationDO::getRobotStatus, RobotStatusEnum.STAND_BY.getType(),RobotStatusEnum.CHARGE.getType())
|
.in(RobotInformationDO::getRobotStatus, RobotStatusEnum.STAND_BY.getType(), RobotStatusEnum.CHARGE.getType())
|
||||||
.eq(RobotInformationDO::getRobotTaskModel, RobotTaskModelEnum.NORMAL.getType())
|
.eq(RobotInformationDO::getRobotTaskModel, RobotTaskModelEnum.NORMAL.getType()));
|
||||||
.orderByDesc(RobotInformationDO::getUpdateTime));
|
|
||||||
|
|
||||||
if (robots.isEmpty()) {
|
if (robots.isEmpty()) {
|
||||||
log.info("暂无空闲的机器人");
|
log.info("暂无空闲的机器人");
|
||||||
@ -150,8 +149,8 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (RobotInformationDO robot : robots) {
|
for (RobotInformationDO robot : robots) {
|
||||||
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS +robot.getMacAddress();
|
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS + robot.getMacAddress();
|
||||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED +robot.getMacAddress();
|
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robot.getMacAddress();
|
||||||
Object taskStatus = redisUtil.get(taskStatusKey);
|
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(taskStatus.toString())) {
|
||||||
robot.setRobotStatus(RobotStatusEnum.DOING.getType());
|
robot.setRobotStatus(RobotStatusEnum.DOING.getType());
|
||||||
@ -164,9 +163,10 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//手动充电的机器人状态是待命
|
//手动充电的机器人状态是待命
|
||||||
|
//自动充电的车子,电量到达设定的阀值,也能执行充电任务
|
||||||
if (ChargeTypeEnum.AUTOMATIC.getType().equals(robot.getChargeType())
|
if (ChargeTypeEnum.AUTOMATIC.getType().equals(robot.getChargeType())
|
||||||
&& RobotStatusEnum.CHARGE.getType().equals(robot.getRobotStatus())) {
|
&& RobotStatusEnum.CHARGE.getType().equals(robot.getRobotStatus())) {
|
||||||
setRobotStatus(commonConfigDO,robot);
|
setRobotStatus(commonConfigDO, robot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,23 +175,37 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (robots.isEmpty()) {
|
if (robots.isEmpty()) {
|
||||||
log.info("暂无可用的机器人");
|
log.info("暂无可用的机器人,可能正在充电,可能机器人有任务");
|
||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//拼接任务id
|
//拼接任务id
|
||||||
List<Long> detailDongIds = robotTaskDetailMapper.getDoingTaskIds();
|
/*List<Long> detailDongIds = robotTaskDetailMapper.getDoingTaskIds();
|
||||||
List<Long> montageTaskIds = robotTaskMapper.getUnDoAndDoingTaskIds(MontageTaskEnum.YES.getType(),detailDongIds);
|
List<Long> montageTaskIds = robotTaskMapper.getUnDoAndDoingTaskIds(MontageTaskEnum.YES.getType(), detailDongIds);
|
||||||
//不拼接的任务id
|
//不拼接的任务id
|
||||||
List<Long> singleTaskIds = robotTaskMapper.getUnDoAndDoingTaskIds(MontageTaskEnum.NO.getType(),new ArrayList<>());
|
List<Long> singleTaskIds = robotTaskMapper.getUnDoAndDoingTaskIds(MontageTaskEnum.NO.getType(), new ArrayList<>());*/
|
||||||
|
|
||||||
|
List<RobotTaskDO> taskDOList = robotTaskMapper.selectList(new LambdaQueryWrapper<RobotTaskDO>()
|
||||||
|
.in(RobotTaskDO::getTaskStatus, RobotTaskStatusEnum.DOING.getType(), RobotTaskStatusEnum.NEW.getType()));
|
||||||
|
|
||||||
|
//拼接
|
||||||
|
List<Long> montageTaskIds =taskDOList.stream()
|
||||||
|
.filter(v -> MontageTaskEnum.YES.getType().equals(v.getMontageTask()))
|
||||||
|
.map(RobotTaskDO::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
//不拼接
|
||||||
|
List<Long> singleTaskIds =taskDOList.stream()
|
||||||
|
.filter(v -> MontageTaskEnum.YES.getType().equals(v.getMontageTask()))
|
||||||
|
.map(RobotTaskDO::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(montageTaskIds) && ObjectUtil.isEmpty(singleTaskIds)) {
|
if (ObjectUtil.isEmpty(montageTaskIds) && ObjectUtil.isEmpty(singleTaskIds)) {
|
||||||
log.info("暂无需要处理的主任务");
|
log.info("暂无需要处理的主任务");
|
||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<RobotTaskDetailDO> taskDetailDOS = getTaskDetail(montageTaskIds,singleTaskIds);
|
List<RobotTaskDetailDO> taskDetailDOS = getTaskDetail(montageTaskIds, singleTaskIds);
|
||||||
|
|
||||||
if (taskDetailDOS.isEmpty()) {
|
if (taskDetailDOS.isEmpty()) {
|
||||||
log.info("暂无需要处理的明细任务");
|
log.info("暂无需要处理的明细任务");
|
||||||
@ -200,24 +214,51 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
return ImmutablePair.of(robots, taskDetailDOS);
|
return ImmutablePair.of(robots, taskDetailDOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* true 需要去充电
|
||||||
|
*
|
||||||
|
* @param commonConfigDO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Boolean needDoCharge(CommonConfigDO commonConfigDO) {
|
||||||
|
if (ObjectUtil.isEmpty(commonConfigDO) || ObjectUtil.isEmpty(commonConfigDO.getConfigStr())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommonConfigVO chargeConfig = JSONUtil.toBean(commonConfigDO.getConfigStr(), CommonConfigVO.class);
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
if (ZeroOneEnum.ZERO.getType().equals(chargeConfig.getEveryDay())
|
||||||
|
&& now.isAfter(chargeConfig.getOnceStartTime()) && now.isBefore(chargeConfig.getOnceEndTime())) {
|
||||||
|
return true;
|
||||||
|
} else if (ZeroOneEnum.ONE.getType().equals(chargeConfig.getEveryDay())
|
||||||
|
&& now.isBefore(chargeConfig.getScheduleChargeEndTime())
|
||||||
|
&& now.isAfter(chargeConfig.getScheduleChargeStartTime())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置机器人的状态
|
* 设置机器人的状态
|
||||||
|
*
|
||||||
* @param commonConfigDO
|
* @param commonConfigDO
|
||||||
* @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_SOC + 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.getBat_soc())) {
|
if (ObjectUtil.isEmpty(commonConfigDO) || ObjectUtil.isEmpty(poseCache) || ObjectUtil.isEmpty(dataPoseDTO.getBat_soc())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonConfigVO chargeConfig=JSONUtil.toBean(commonConfigDO.getConfigStr(),CommonConfigVO.class);
|
CommonConfigVO chargeConfig = JSONUtil.toBean(commonConfigDO.getConfigStr(), CommonConfigVO.class);
|
||||||
|
|
||||||
//车子剩余电量
|
//车子剩余电量
|
||||||
BigDecimal robotRemainingElectricity = new BigDecimal(dataPoseDTO.getBat_soc());
|
BigDecimal robotRemainingElectricity = new BigDecimal(dataPoseDTO.getBat_soc());
|
||||||
@ -242,14 +283,15 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取明细
|
* 获取明细
|
||||||
* @param montageTaskIds
|
*
|
||||||
* @param singleTaskIds
|
* @param montageTaskIds 拼接
|
||||||
|
* @param singleTaskIds 不拼接
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<RobotTaskDetailDO> getTaskDetail(List<Long> montageTaskIds, List<Long> singleTaskIds) {
|
private List<RobotTaskDetailDO> getTaskDetail(List<Long> montageTaskIds, List<Long> singleTaskIds) {
|
||||||
if (ObjectUtil.isNotEmpty(montageTaskIds) && ObjectUtil.isEmpty(singleTaskIds)) {
|
if (ObjectUtil.isNotEmpty(montageTaskIds) && ObjectUtil.isEmpty(singleTaskIds)) {
|
||||||
return robotTaskDetailMapper.getMontageUnDoTask(montageTaskIds);
|
return robotTaskDetailMapper.getMontageUnDoTask(montageTaskIds);
|
||||||
} else if (ObjectUtil.isEmpty(montageTaskIds) && ObjectUtil.isNotEmpty(singleTaskIds) ) {
|
} else if (ObjectUtil.isEmpty(montageTaskIds) && ObjectUtil.isNotEmpty(singleTaskIds)) {
|
||||||
return robotTaskDetailMapper.getSingleUnDoTask(singleTaskIds);
|
return robotTaskDetailMapper.getSingleUnDoTask(singleTaskIds);
|
||||||
}
|
}
|
||||||
return robotTaskDetailMapper.getUnDoTaskDetail(montageTaskIds, singleTaskIds);
|
return robotTaskDetailMapper.getUnDoTaskDetail(montageTaskIds, singleTaskIds);
|
||||||
@ -257,6 +299,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 下发任务给机器人
|
* 下发任务给机器人
|
||||||
|
*
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param taskDetailDOS
|
* @param taskDetailDOS
|
||||||
*/
|
*/
|
||||||
@ -279,7 +322,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
RobotTaskTypeEnum robotTaskType = RobotTaskTypeEnum.getRobotTaskType(taskDetailDO.getTaskType());
|
RobotTaskTypeEnum robotTaskType = RobotTaskTypeEnum.getRobotTaskType(taskDetailDO.getTaskType());
|
||||||
switch (robotTaskType) {
|
switch (robotTaskType) {
|
||||||
case TAKE_RELEASE:
|
case TAKE_RELEASE:
|
||||||
doTakeReleaseDistribute(taskDetailDO, robots,robotTaskDOS,taskIds,updateTaskDetails,robotNos,doingLocationIds);
|
doTakeReleaseDistribute(taskDetailDO, robots, robotTaskDOS, taskIds, updateTaskDetails, robotNos, doingLocationIds);
|
||||||
break;
|
break;
|
||||||
/*case PARK:
|
/*case PARK:
|
||||||
doParkDistribute(taskDetailDO, robots,robotTaskDOS);
|
doParkDistribute(taskDetailDO, robots,robotTaskDOS);
|
||||||
@ -326,12 +369,13 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
robotTaskDetailMapper.updateBatch(updateTaskDetails);
|
robotTaskDetailMapper.updateBatch(updateTaskDetails);
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotEmpty(robotNos)) {
|
if (ObjectUtil.isNotEmpty(robotNos)) {
|
||||||
robotInformationMapper.updateRobotListStatus(robotNos,RobotStatusEnum.DOING.getType());
|
robotInformationMapper.updateRobotListStatus(robotNos, RobotStatusEnum.DOING.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测托盘类型
|
* 检测托盘类型
|
||||||
|
*
|
||||||
* @param taskDetailDO
|
* @param taskDetailDO
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param robotTaskDOS
|
* @param robotTaskDOS
|
||||||
@ -344,6 +388,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫描码
|
* 扫描码
|
||||||
|
*
|
||||||
* @param taskDetailDO
|
* @param taskDetailDO
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param robotTaskDOS
|
* @param robotTaskDOS
|
||||||
@ -356,6 +401,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅放货
|
* 仅放货
|
||||||
|
*
|
||||||
* @param taskDetailDO
|
* @param taskDetailDO
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param robotTaskDOS
|
* @param robotTaskDOS
|
||||||
@ -368,6 +414,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 取放货
|
* 取放货
|
||||||
|
*
|
||||||
* @param taskDetailDO
|
* @param taskDetailDO
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param robotTaskDOS
|
* @param robotTaskDOS
|
||||||
@ -380,6 +427,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 移动
|
* 移动
|
||||||
|
*
|
||||||
* @param taskDetailDO
|
* @param taskDetailDO
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param robotTaskDOS
|
* @param robotTaskDOS
|
||||||
@ -395,7 +443,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
.map(RobotInformationDO::getMacAddress)
|
.map(RobotInformationDO::getMacAddress)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse("");
|
.orElse("");
|
||||||
if (ObjectUtil.isEmpty(macAddress) ) {
|
if (ObjectUtil.isEmpty(macAddress)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -406,7 +454,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
RobotAcceptTaskDTO robotTaskDO = new RobotAcceptTaskDTO();
|
RobotAcceptTaskDTO robotTaskDO = new RobotAcceptTaskDTO();
|
||||||
robotTaskDO.setOrder_id(taskDetailDO.getId().toString());
|
robotTaskDO.setOrder_id(taskDetailDO.getId().toString());
|
||||||
robotTaskDO.setOrder_type("出库");//未定
|
robotTaskDO.setOrder_type("出库");//未定
|
||||||
robotTaskDO.setTopic(RobotTopicConstant.ROBOT_TASK_TOPIC+macAddress);
|
robotTaskDO.setTopic(RobotTopicConstant.ROBOT_TASK_TOPIC + macAddress);
|
||||||
|
|
||||||
//1
|
//1
|
||||||
RobotAcceptTaskData taskOne = new RobotAcceptTaskData();
|
RobotAcceptTaskData taskOne = new RobotAcceptTaskData();
|
||||||
@ -434,11 +482,12 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
robotTaskDO.setData(data);
|
robotTaskDO.setData(data);
|
||||||
robotTaskDOS.add(robotTaskDO);
|
robotTaskDOS.add(robotTaskDO);
|
||||||
|
|
||||||
updateTaskStatus(robotNo,taskDetailDO);
|
updateTaskStatus(robotNo, taskDetailDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电
|
* 充电
|
||||||
|
*
|
||||||
* @param taskDetailDO
|
* @param taskDetailDO
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param robotTaskDOS
|
* @param robotTaskDOS
|
||||||
@ -451,6 +500,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 停车
|
* 停车
|
||||||
|
*
|
||||||
* @param taskDetailDO
|
* @param taskDetailDO
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param robotTaskDOS
|
* @param robotTaskDOS
|
||||||
@ -466,7 +516,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
.map(RobotInformationDO::getMacAddress)
|
.map(RobotInformationDO::getMacAddress)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse("");
|
.orElse("");
|
||||||
if (ObjectUtil.isEmpty(macAddress) ) {
|
if (ObjectUtil.isEmpty(macAddress)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -474,7 +524,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
RobotAcceptTaskDTO robotTaskDO = new RobotAcceptTaskDTO();
|
RobotAcceptTaskDTO robotTaskDO = new RobotAcceptTaskDTO();
|
||||||
robotTaskDO.setOrder_id(taskDetailDO.getId().toString());
|
robotTaskDO.setOrder_id(taskDetailDO.getId().toString());
|
||||||
robotTaskDO.setOrder_type("出库");//未定
|
robotTaskDO.setOrder_type("出库");//未定
|
||||||
robotTaskDO.setTopic(RobotTopicConstant.ROBOT_TASK_TOPIC+macAddress);
|
robotTaskDO.setTopic(RobotTopicConstant.ROBOT_TASK_TOPIC + macAddress);
|
||||||
|
|
||||||
RobotAcceptTaskData taskOne = new RobotAcceptTaskData();
|
RobotAcceptTaskData taskOne = new RobotAcceptTaskData();
|
||||||
taskOne.setSerial("1");
|
taskOne.setSerial("1");
|
||||||
@ -490,28 +540,29 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
final String mac = macAddress;
|
final String mac = macAddress;
|
||||||
robots.removeIf(v -> v.getMacAddress().equals(mac));
|
robots.removeIf(v -> v.getMacAddress().equals(mac));
|
||||||
|
|
||||||
updateTaskStatus(robotNo,taskDetailDO);
|
updateTaskStatus(robotNo, taskDetailDO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取放货
|
* 取放货
|
||||||
|
*
|
||||||
* @param taskDetailDO
|
* @param taskDetailDO
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param robotTaskDOS
|
* @param robotTaskDOS
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void doTakeReleaseDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
|
public void doTakeReleaseDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
|
||||||
List<RobotAcceptTaskDTO> robotTaskDOS,Set<Long> taskIdSet,
|
List<RobotAcceptTaskDTO> robotTaskDOS, Set<Long> taskIdSet,
|
||||||
List<RobotTaskDetailDO> updateTaskDetail, Set<String> robotNos
|
List<RobotTaskDetailDO> updateTaskDetail, Set<String> robotNos
|
||||||
,Set<Long> doingLocationIds) {
|
, Set<Long> doingLocationIds) {
|
||||||
WareHouseLocationDO query = WareHouseLocationDO.builder().id(taskDetailDO.getFromLocationId()).build();
|
WareHouseLocationDO query = WareHouseLocationDO.builder().id(taskDetailDO.getFromLocationId()).build();
|
||||||
WareHouseLocationDO fromLocation = locationMapper.queryAllByLimit(query);
|
WareHouseLocationDO fromLocation = locationMapper.queryAllByLimit(query);
|
||||||
|
|
||||||
WareHouseLocationDO toQuery = WareHouseLocationDO.builder().id(taskDetailDO.getToLocationId()).build();
|
WareHouseLocationDO toQuery = WareHouseLocationDO.builder().id(taskDetailDO.getToLocationId()).build();
|
||||||
WareHouseLocationDO toLocation = locationMapper.queryAllByLimit(toQuery);
|
WareHouseLocationDO toLocation = locationMapper.queryAllByLimit(toQuery);
|
||||||
|
|
||||||
Pair<String,String> pair = getMadAddressRobotNo(taskDetailDO,robots,fromLocation,toLocation);
|
Pair<String, String> pair = getMadAddressRobotNo(taskDetailDO, robots, fromLocation, toLocation);
|
||||||
String macAddress = pair.getLeft();
|
String macAddress = pair.getLeft();
|
||||||
String robotNo = pair.getRight();
|
String robotNo = pair.getRight();
|
||||||
|
|
||||||
@ -521,11 +572,11 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 取货/放货 校验有没有其他库位挡住
|
// 取货/放货 校验有没有其他库位挡住
|
||||||
Boolean fromCanMove = checkCanMove(fromLocation,doingLocationIds);
|
Boolean fromCanMove = checkCanMove(fromLocation, doingLocationIds);
|
||||||
if (!fromCanMove) {
|
if (!fromCanMove) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Boolean toCanMove = checkCanMove(toLocation,doingLocationIds);
|
Boolean toCanMove = checkCanMove(toLocation, doingLocationIds);
|
||||||
if (!toCanMove) {
|
if (!toCanMove) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -533,7 +584,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
RobotAcceptTaskDTO robotTaskDO = new RobotAcceptTaskDTO();
|
RobotAcceptTaskDTO robotTaskDO = new RobotAcceptTaskDTO();
|
||||||
robotTaskDO.setOrder_id(taskDetailDO.getId().toString());
|
robotTaskDO.setOrder_id(taskDetailDO.getId().toString());
|
||||||
robotTaskDO.setOrder_type("出库");//未定
|
robotTaskDO.setOrder_type("出库");//未定
|
||||||
robotTaskDO.setTopic(RobotTopicConstant.ROBOT_TASK_TOPIC+macAddress);
|
robotTaskDO.setTopic(RobotTopicConstant.ROBOT_TASK_TOPIC + macAddress);
|
||||||
|
|
||||||
//1
|
//1
|
||||||
RobotAcceptTaskData taskOne = new RobotAcceptTaskData();
|
RobotAcceptTaskData taskOne = new RobotAcceptTaskData();
|
||||||
@ -590,7 +641,6 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
taskSeven.setCommand_type(CommandTypeEnum.MOVE_TO_PALLET_POSE.getType());
|
taskSeven.setCommand_type(CommandTypeEnum.MOVE_TO_PALLET_POSE.getType());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//8
|
//8
|
||||||
RobotAcceptTaskData taskEigth = new RobotAcceptTaskData();
|
RobotAcceptTaskData taskEigth = new RobotAcceptTaskData();
|
||||||
taskEigth.setSerial("7");
|
taskEigth.setSerial("7");
|
||||||
@ -620,7 +670,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
.laneId(-2l)
|
.laneId(-2l)
|
||||||
.build();
|
.build();
|
||||||
List<WareHouseLocationDO> releaseStockList =
|
List<WareHouseLocationDO> releaseStockList =
|
||||||
locationMapper.selectLocations(ware,new ArrayList<>(),new HashSet<>());
|
locationMapper.selectLocations(ware, new ArrayList<>(), new HashSet<>());
|
||||||
for (WareHouseLocationDO wareHouseLocationDO : releaseStockList) {
|
for (WareHouseLocationDO wareHouseLocationDO : releaseStockList) {
|
||||||
Pose2ds pose = positionMapItemMapper.selectByLocationId(wareHouseLocationDO.getId());
|
Pose2ds pose = positionMapItemMapper.selectByLocationId(wareHouseLocationDO.getId());
|
||||||
pose2dsNight.add(pose);
|
pose2dsNight.add(pose);
|
||||||
@ -720,6 +770,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验当前库位能否取放
|
* 校验当前库位能否取放
|
||||||
|
*
|
||||||
* @param fromLocation
|
* @param fromLocation
|
||||||
* @return false : 有货,不能移动 ; true: 没货, 能移动
|
* @return false : 有货,不能移动 ; true: 没货, 能移动
|
||||||
*/
|
*/
|
||||||
@ -734,7 +785,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (ObjectUtil.isNotEmpty(locationDOS)) {
|
if (ObjectUtil.isNotEmpty(locationDOS)) {
|
||||||
// todo 后续记录到异常表
|
// todo 后续记录到异常表
|
||||||
log.info("普通库位--库位上有其他货物, 库位号:{} ,无法进行移动 :{}",fromLocation.getLocationNo() ,locationDOS);
|
log.info("普通库位--库位上有其他货物, 库位号:{} ,无法进行移动 :{}", fromLocation.getLocationNo(), locationDOS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -750,7 +801,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (ObjectUtil.isNotEmpty(wareHouseLocationDOS)) {
|
if (ObjectUtil.isNotEmpty(wareHouseLocationDOS)) {
|
||||||
// todo 后续记录到异常表
|
// todo 后续记录到异常表
|
||||||
log.info("线库-当前库位上有其他货物, 库位号:{},无法进行移动 :{}",fromLocation.getLocationNo() ,wareHouseLocationDOS);
|
log.info("线库-当前库位上有其他货物, 库位号:{},无法进行移动 :{}", fromLocation.getLocationNo(), wareHouseLocationDOS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -780,7 +831,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
macAddress = robotInformationDO.getMacAddress();
|
macAddress = robotInformationDO.getMacAddress();
|
||||||
robotNo = robotInformationDO.getRobotNo();
|
robotNo = robotInformationDO.getRobotNo();
|
||||||
}
|
}
|
||||||
Pair<String,String> pair = new ImmutablePair<>(macAddress,robotNo);
|
Pair<String, String> pair = new ImmutablePair<>(macAddress, robotNo);
|
||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.robot.pathplanning;
|
package cn.iocoder.yudao.module.system.service.robot.pathplanning;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
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.RobotTaskApi;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
|
||||||
|
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.config.CommonConfigMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.houselocation.WareHouseLocationMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.houselocation.WareHouseLocationMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapItemMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapItemMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskMapper;
|
||||||
|
import cn.iocoder.yudao.module.system.service.robot.job.DistributeTasksService;
|
||||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
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.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -16,9 +22,11 @@ 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.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
|
@Slf4j
|
||||||
public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RobotInformationMapper robotInformationMapper;
|
private RobotInformationMapper robotInformationMapper;
|
||||||
@ -63,6 +71,9 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
|||||||
@Resource
|
@Resource
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DistributeTasksService distributeTasksService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下发任务给PP
|
* 下发任务给PP
|
||||||
*/
|
*/
|
||||||
@ -70,6 +81,20 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void sendTaskToPP() {
|
public void sendTaskToPP() {
|
||||||
TenantContextHolder.setTenantId(1L);
|
TenantContextHolder.setTenantId(1L);
|
||||||
|
Pair<List<RobotInformationDO>, List<RobotTaskDetailDO>> robotAndTaskDetails =
|
||||||
|
distributeTasksService.getRobotAndTaskDetails();
|
||||||
|
|
||||||
|
List<RobotInformationDO> robots = robotAndTaskDetails.getLeft();
|
||||||
|
if (ObjectUtil.isEmpty(robots)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<RobotTaskDetailDO> taskDetailDOS = robotAndTaskDetails.getRight();
|
||||||
|
if (ObjectUtil.isEmpty(taskDetailDOS)) {
|
||||||
|
log.info("--不存在需要执行的任务--");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user