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;
|
||||||
@ -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(),
|
||||||
|
@ -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;
|
||||||
@ -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("暂无空闲的机器人");
|
||||||
@ -164,6 +163,7 @@ 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,16 +175,30 @@ 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("暂无需要处理的主任务");
|
||||||
@ -200,8 +214,35 @@ 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
|
||||||
*/
|
*/
|
||||||
@ -242,8 +283,9 @@ 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) {
|
||||||
@ -257,6 +299,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 下发任务给机器人
|
* 下发任务给机器人
|
||||||
|
*
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param taskDetailDOS
|
* @param taskDetailDOS
|
||||||
*/
|
*/
|
||||||
@ -332,6 +375,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测托盘类型
|
* 检测托盘类型
|
||||||
|
*
|
||||||
* @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
|
||||||
@ -439,6 +487,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电
|
* 充电
|
||||||
|
*
|
||||||
* @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
|
||||||
@ -496,6 +546,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 取放货
|
* 取放货
|
||||||
|
*
|
||||||
* @param taskDetailDO
|
* @param taskDetailDO
|
||||||
* @param robots
|
* @param robots
|
||||||
* @param robotTaskDOS
|
* @param robotTaskDOS
|
||||||
@ -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");
|
||||||
@ -720,6 +770,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验当前库位能否取放
|
* 校验当前库位能否取放
|
||||||
|
*
|
||||||
* @param fromLocation
|
* @param fromLocation
|
||||||
* @return false : 有货,不能移动 ; true: 没货, 能移动
|
* @return false : 有货,不能移动 ; true: 没货, 能移动
|
||||||
*/
|
*/
|
||||||
|
@ -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