任务查询/更新、校验机器人区域

This commit is contained in:
cbs 2025-01-18 17:11:46 +08:00
parent ee6f39faa0
commit 4c62f8b205
20 changed files with 654 additions and 89 deletions

View File

@ -31,7 +31,8 @@ management:
# MQTT
mqtt:
host: tcp://192.168.0.116:1883
# host: tcp://192.168.0.54:1883
host: tcp://127.0.0.1:1883
username: adminuser
password: adminuser
qos: 1

View File

@ -194,6 +194,7 @@ public interface ErrorCodeConstants {
ErrorCode TASK_CHECK_ID_EXCEPTION = new ErrorCode(1-002-035-006, "请输入ID");
ErrorCode TASK_CHECK_TASK_PRIORITY = new ErrorCode(1-002-035-007, "非新单据不能修改优先级");
ErrorCode TASK_CHECK_TASK_STATUS = new ErrorCode(1-002-035-100, "订单已完成");
ErrorCode TASK_CHECK_UPDATE_STATUS = new ErrorCode(1-002-035-101, "订单更新失败");
// ========== 机器人任务明细 1-002-036-000 ==========
ErrorCode TASK_DETAIL_NOT_EXISTS = new ErrorCode(1-002-036-001, "机器人任务明细不存在");

View File

@ -82,10 +82,10 @@ public class RobotTaskController {
return success(taskService.getTaskNo());
}
@GetMapping("/page")
@PostMapping("/page")
@Operation(summary = "获得机器人任务主表分页")
@PreAuthorize("@ss.hasPermission('robot:task:query')")
public CommonResult<PageResult<RobotTaskRespVO>> getTaskPage(@Valid RobotTaskPageReqVO pageReqVO) {
public CommonResult<PageResult<RobotTaskRespVO>> getTaskPage(@Valid @RequestBody RobotTaskPageReqVO pageReqVO) {
PageResult<RobotTaskRespVO> pageResult = taskService.getTaskPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, RobotTaskRespVO.class));
}

View File

@ -51,6 +51,9 @@ public class RobotTaskPageReqVO extends PageParam {
@Schema(description = "任务号")
private String taskNo;
@Schema(description = "机器人编号")
private String robotNo;
@Schema(description = "任务状态(0:未开始、1执行中、2已完成、3已取消)", example = "2")
private Integer taskStatus;

View File

@ -146,4 +146,8 @@ public class WareHouseLocationDO extends BaseDO {
* ware_position_map的id
*/
private Long mapId;
/**
* ware_position_map_item的id
*/
private Long mapItemId;
}

View File

@ -47,6 +47,10 @@ public class PositionMapItemDO extends BaseDO {
* 坐标y轴
*/
private String locationY;
/**
* 对应各个类型的独有属性Json格式 例如{库位长度:1,库位宽度:2,库位方向:单向
*/
private String dataJson;
/**
* 类型 1.行走点位 2.库位 3.充电桩 --- 后续补充
*/

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.dal.mysql.positionmap;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mqtt.api.task.dto.Pose2ds;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapItemPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO;
import org.apache.ibatis.annotations.Mapper;
@ -26,4 +27,10 @@ public interface PositionMapItemMapper extends BaseMapperX<PositionMapItemDO> {
.orderByDesc(PositionMapItemDO::getId));
}
/**
* 根据库位id查询
* @param locationId
* @return
*/
Pose2ds selectByLocationId(Long locationId);
}

View File

@ -86,4 +86,10 @@ public interface RobotTaskDetailMapper extends BaseMapperX<RobotTaskDetailDO> {
void updateRobotDetailById(RobotTaskDetailDO detailDO);
/**
* 查询正在处理中的任务主表id
* @return
*/
List<Long> getDoingTaskIds();
}

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotTaskPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -50,6 +51,15 @@ public interface RobotTaskMapper extends BaseMapperX<RobotTaskDO> {
* 获取未完成的订单id
* @return
*/
List<Long> getUnDoAndDoingTaskIds(@Param("montageTask") Integer montageTask);
List<Long> getUnDoAndDoingTaskIds(@Param("montageTask") Integer montageTask,
@Param("ids") List<Long> ids );
/**
* 分页查询
* @param mpPage
* @param pageReqVO
* @return
*/
IPage<RobotTaskDO> selectPageList(@Param("mpPage") IPage mpPage,
@Param("pageReqVO") RobotTaskPageReqVO pageReqVO);
}

View File

@ -16,6 +16,8 @@ public enum CommandTypeEnum {
STOP("STOP"),//停止
START("START"),//启动
WAIT("WAIT"),//等待
GET_PALLET_TOPIC("GET_PALLET_TOPIC"),//获取托盘位置
MOVE_TO_PALLET_POSE("MOVE_TO_PALLET_POSE"),//让车机移动到取货终点
FORK("FORK"); //控制货叉上下移动
/**
* 类型

View File

@ -9,7 +9,8 @@ public enum RobotTaskStatusEnum {
NEW(0),//未开始
DOING(1),//执行中
DONE(2),//已完成
CLOSE(3); //已取消
CLOSE(3), //已取消
Exc(4); //异常
/**
* 类型
*/

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.robot;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.system.enums.redis.RobotCacheLockEnum;
import cn.iocoder.yudao.module.system.enums.robot.*;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import cn.iocoder.yudao.module.system.util.redis.RedissonUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
@ -364,7 +366,8 @@ public class RobotTaskServiceImpl implements RobotTaskService {
*/
@Transactional(rollbackFor = Exception.class)
public void doDetectingTrays(RobotTaskDetailAddVO robotTaskVo) {
setToLocation(robotTaskVo,getMapIdsByRobotNo(robotTaskVo.getRobotNo()),new ArrayList<>());
locationMapper.updateLocationLockStatus(robotTaskVo.getToLocationId(),0,robotTaskVo.getRobotTaskId());
}
/**
@ -373,7 +376,8 @@ public class RobotTaskServiceImpl implements RobotTaskService {
*/
@Transactional(rollbackFor = Exception.class)
public void doScan(RobotTaskDetailAddVO robotTaskVo) {
setToLocation(robotTaskVo,getMapIdsByRobotNo(robotTaskVo.getRobotNo()),new ArrayList<>());
locationMapper.updateLocationLockStatus(robotTaskVo.getToLocationId(),0,robotTaskVo.getRobotTaskId());
}
/**
@ -445,7 +449,7 @@ public class RobotTaskServiceImpl implements RobotTaskService {
}
/**
* 设置停车/目标库位
* 设置停车/目标库位/扫描库位
*/
@Transactional(rollbackFor = Exception.class)
public void setToLocation(RobotTaskDetailAddVO robotTaskVo, Set<Long> mapIds, List<Long> locationIds){
@ -530,7 +534,7 @@ public class RobotTaskServiceImpl implements RobotTaskService {
List<RobotTaskDetailDO> doingTasks = taskDetailMapper.queryDoingTaskByIds(set);
if (ObjectUtil.isNotEmpty(doingTasks)) {
log.error("取货库位,存在未完成的任务 :{}", robotTaskVo.getTakeId());
throw new RuntimeException("取货库位,存在未完成的任务");
throw new RuntimeException("取货库位,存在未完成的任务 ");
}
//设置为锁定
@ -542,6 +546,7 @@ public class RobotTaskServiceImpl implements RobotTaskService {
@Transactional(rollbackFor = Exception.class)
public void updateTask(RobotTaskSaveReqVO updateReqVO) {
RLock lock = redissonUtils.getLock(RobotCacheLockEnum.ROBOT_TASK_DISTRIBUTE_LOCK.getKey());
String msg = "";
if (lock.tryLock()){
try {
// 校验存在
@ -550,33 +555,53 @@ public class RobotTaskServiceImpl implements RobotTaskService {
throw exception(TASK_CHECK_ID_EXCEPTION);
}
// 更新
//修改优先级需要订单状态为未开始
//修改优先级需要订单状态为未开始/处理中
RobotTaskDO robotTaskDO = taskMapper.selectById(updateReqVO.getId());
if (ObjectUtil.isNotEmpty(updateReqVO.getPriority())) {
if (!RobotTaskStatusEnum.NEW.getType().equals(robotTaskDO.getTaskStatus())) {
List<RobotTaskDetailDO> taskDetailDOS = taskDetailMapper.queryByTaskId(updateReqVO.getId());
if (ObjectUtil.isNotEmpty(updateReqVO.getPriority())
&& !updateReqVO.getPriority().equals(robotTaskDO.getPriority())) {
if (!RobotTaskStatusEnum.NEW.getType().equals(robotTaskDO.getTaskStatus())
&& !RobotTaskStatusEnum.DOING.getType().equals(robotTaskDO.getTaskStatus())) {
throw exception(TASK_CHECK_TASK_PRIORITY);
}
List<RobotTaskDetailDO> taskDetailDOS = taskDetailMapper.queryByTaskId(updateReqVO.getId());
for (RobotTaskDetailDO taskDetailDO : taskDetailDOS) {
taskDetailDO.setPriority(updateReqVO.getPriority());
taskDetailMapper.updateRobotDetailById(taskDetailDO);
}
}
//修改订单状态
if (ObjectUtil.isNotEmpty(updateReqVO.getTaskStatus()) &&
RobotTaskStatusEnum.DONE.getType().equals(robotTaskDO.getTaskStatus())) {
if (ObjectUtil.isNotEmpty(updateReqVO.getTaskStatus())
&& RobotTaskStatusEnum.DONE.getType().equals(robotTaskDO.getTaskStatus())
&& !robotTaskDO.getTaskStatus().equals(updateReqVO.getTaskStatus())) {
throw exception(TASK_CHECK_TASK_STATUS);
}
if (ObjectUtil.isNotEmpty(updateReqVO.getTaskStatus())
&& !robotTaskDO.getTaskStatus().equals(updateReqVO.getTaskStatus())) {
for (RobotTaskDetailDO taskDetailDO : taskDetailDOS) {
if (RobotTaskDetailStatusEnum.DONE.getType().equals(taskDetailDO.getTaskStatus())) {
continue;
}
//后期需做状态映射
taskDetailDO.setTaskStatus(updateReqVO.getTaskStatus());
}
}
RobotTaskDO updateObj = BeanUtils.toBean(updateReqVO, RobotTaskDO.class);
taskMapper.updateById(updateObj);
taskDetailMapper.updateBatch(taskDetailDOS);
} catch (Exception e) {
log.error("下发任务给车机出现异常 :{}",e.getMessage());
log.error("更新任务失败 :{}",e.getMessage());
msg = e.getMessage();
} finally {
lock.unlock();
}
} else {
throw exception(REDISSON_NOT_OBTAIN_LOCK);
}
if (ObjectUtil.isNotEmpty(msg)) {
throw exception0(TASK_CHECK_UPDATE_STATUS.getCode(), msg);
}
}
@Override
@ -600,10 +625,21 @@ public class RobotTaskServiceImpl implements RobotTaskService {
@Override
public PageResult<RobotTaskRespVO> getTaskPage(RobotTaskPageReqVO pageReqVO) {
PageResult<RobotTaskDO> pageResult = taskMapper.selectPage(pageReqVO);
PageResult<RobotTaskDO> pageResult = null;
PageResult<RobotTaskRespVO> dataPage = new PageResult<>();
dataPage.setTotal(pageResult.getTotal());
List<RobotTaskDO> list = pageResult.getList();
List<RobotTaskDO> list = new ArrayList<>();
if (ObjectUtil.isEmpty(pageReqVO.getRobotNo())) {
pageResult = taskMapper.selectPage(pageReqVO);
dataPage.setTotal(pageResult.getTotal());
list = pageResult.getList();
}else {
IPage mpPage = MyBatisUtils.buildPage(pageReqVO);
IPage<RobotTaskDO> page = taskMapper.selectPageList(mpPage, pageReqVO);
dataPage.setTotal(page.getTotal());
list = page.getRecords();
}
List<RobotTaskRespVO> targetList = BeanUtil.copyToList(list, RobotTaskRespVO.class);
for (RobotTaskRespVO robotTaskRespVO : targetList) {
robotTaskRespVO.setDetails(taskDetailMapper.queryByTaskId(robotTaskRespVO.getId()));

View File

@ -6,25 +6,29 @@ import cn.iocoder.yudao.module.mqtt.api.task.RobotTaskApi;
import cn.iocoder.yudao.module.mqtt.api.task.dto.Pose2ds;
import cn.iocoder.yudao.module.mqtt.api.task.dto.RobotAcceptTaskDTO;
import cn.iocoder.yudao.module.mqtt.api.task.dto.RobotAcceptTaskData;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO;
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.robot.RobotInformationMapper;
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.enums.robot.*;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.*;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@Service
@Slf4j
@ -42,6 +46,28 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
@Resource
private RobotTaskApi robotTaskApi;
@Resource
private PositionMapItemMapper positionMapItemMapper;
@Value("${zn.init_height:0.0}")
private double initHeight;
@Value("${zn.scan_height:0.4}")
private double scanHeight;
@Value("${zn.parm:5000}")
private Integer parm;
@Value("${zn.lift_height:0.1}")
private double liftHeight;
@Value("${zn.move_height:0.1}")
private double moveHeight;
@Resource
private WareHouseLocationMapper locationMapper;
/**
* 下发搬运任务
*/
@ -56,9 +82,10 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
}
//拼接任务id
List<Long> montageTaskIds = robotTaskMapper.getUnDoAndDoingTaskIds(MontageTaskEnum.YES.getType());
List<Long> detailDongIds = robotTaskDetailMapper.getDoingTaskIds();
List<Long> montageTaskIds = robotTaskMapper.getUnDoAndDoingTaskIds(MontageTaskEnum.YES.getType(),detailDongIds);
//不拼接的任务id
List<Long> singleTaskIds = robotTaskMapper.getUnDoAndDoingTaskIds(MontageTaskEnum.NO.getType());
List<Long> singleTaskIds = robotTaskMapper.getUnDoAndDoingTaskIds(MontageTaskEnum.NO.getType(),new ArrayList<>());
if (ObjectUtil.isEmpty(montageTaskIds) && ObjectUtil.isEmpty(singleTaskIds)) {
log.info("暂无需要处理的主任务");
@ -111,7 +138,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
case TAKE_RELEASE:
doTakeReleaseDistribute(taskDetailDO, robots,robotTaskDOS);
break;
case PARK:
/*case PARK:
doParkDistribute(taskDetailDO, robots,robotTaskDOS);
break;
case CHARGE:
@ -131,13 +158,14 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
break;
case DETECTING_TRAYS:
doDetectingTraysDistribute(taskDetailDO,robots,robotTaskDOS);
break;
break;*/
default:
log.error("下发任务的类型不存在");
}
}
if (ObjectUtil.isNotEmpty(robotTaskDOS)) {
log.info("任务下发给车机 :{}", JSON.toJSONString(robotTaskDOS));
robotTaskApi.sendTaskToRobot(robotTaskDOS);
}
}
@ -148,7 +176,8 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
* @param robots
* @param robotTaskDOS
*/
private void doDetectingTraysDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
@Transactional(rollbackFor = Exception.class)
public void doDetectingTraysDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
List<RobotAcceptTaskDTO> robotTaskDOS) {
}
@ -159,7 +188,8 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
* @param robots
* @param robotTaskDOS
*/
private void doScanDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
@Transactional(rollbackFor = Exception.class)
public void doScanDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
List<RobotAcceptTaskDTO> robotTaskDOS) {
}
@ -170,7 +200,8 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
* @param robots
* @param robotTaskDOS
*/
private void doReleaseDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
@Transactional(rollbackFor = Exception.class)
public void doReleaseDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
List<RobotAcceptTaskDTO> robotTaskDOS) {
}
@ -181,7 +212,8 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
* @param robots
* @param robotTaskDOS
*/
private void doTakeDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
@Transactional(rollbackFor = Exception.class)
public void doTakeDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
List<RobotAcceptTaskDTO> robotTaskDOS) {
}
@ -192,7 +224,8 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
* @param robots
* @param robotTaskDOS
*/
private void doMoveDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
@Transactional(rollbackFor = Exception.class)
public void doMoveDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
List<RobotAcceptTaskDTO> robotTaskDOS) {
String macAddress = "";
String robotNo = taskDetailDO.getRobotNo();
@ -250,7 +283,8 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
* @param robots
* @param robotTaskDOS
*/
private void doChargeDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
@Transactional(rollbackFor = Exception.class)
public void doChargeDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
List<RobotAcceptTaskDTO> robotTaskDOS) {
}
@ -261,7 +295,8 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
* @param robots
* @param robotTaskDOS
*/
private void doParkDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
@Transactional(rollbackFor = Exception.class)
public void doParkDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
List<RobotAcceptTaskDTO> robotTaskDOS) {
String macAddress = "";
String robotNo = taskDetailDO.getRobotNo();
@ -308,21 +343,19 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
@Transactional(rollbackFor = Exception.class)
public void doTakeReleaseDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
List<RobotAcceptTaskDTO> robotTaskDOS) {
WareHouseLocationDO query = WareHouseLocationDO.builder().id(taskDetailDO.getFromLocationId()).build();
WareHouseLocationDO fromLocation = locationMapper.queryAllByLimit(query);
String macAddress = "";
String robotNo = taskDetailDO.getRobotNo();
if (ObjectUtil.isNotEmpty(taskDetailDO.getRobotNo())) {
macAddress = robots.stream()
.filter(v -> v.getRobotNo().equals(taskDetailDO.getRobotNo()))
.map(RobotInformationDO::getMacAddress)
.findFirst()
.orElse("");
if (ObjectUtil.isEmpty(macAddress) ) {
return;
}
} else {
macAddress = robots.get(0).getMacAddress();
robotNo = robots.get(0).getRobotNo();
WareHouseLocationDO toQuery = WareHouseLocationDO.builder().id(taskDetailDO.getToLocationId()).build();
WareHouseLocationDO toLocation = locationMapper.queryAllByLimit(toQuery);
Pair<String,String> pair = getMadAddressRobotNo(taskDetailDO,robots,fromLocation,toLocation);
String macAddress = pair.getLeft();
String robotNo = pair.getRight();
if (ObjectUtil.isEmpty(macAddress) || ObjectUtil.isEmpty(robotNo)) {
log.info("mac地址为空 :{}, 机器人编号 {}", macAddress, robotNo);
return;
}
RobotAcceptTaskDTO robotTaskDO = new RobotAcceptTaskDTO();
@ -337,17 +370,8 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
taskOne.setCommand_type(CommandTypeEnum.MOVE_POSES.getType());
List<Pose2ds> pose2ds = new ArrayList<>();
Pose2ds pose2d1 = new Pose2ds();
pose2d1.setX(-1.305);
pose2d1.setY(-0.553);
pose2d1.setYaw(0.091);
Pose2ds pose2d2 = new Pose2ds();
pose2d2.setX(-0.407);
pose2d2.setY(-0.566);
pose2d2.setYaw(0.117);
pose2ds.add(pose2d1);
pose2ds.add(pose2d2);
Pose2ds pose2 = positionMapItemMapper.selectByLocationId(taskDetailDO.getFromLocationId());
pose2ds.add(pose2);
taskOne.setPose2ds(pose2ds);
//2
@ -355,57 +379,157 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
taskTwo.setSerial("1");
taskTwo.setCommand_id(taskDetailDO.getId().toString());
taskTwo.setCommand_type(CommandTypeEnum.FORK.getType());
taskTwo.setTarget_height(0.0d);
taskTwo.setTarget_height(initHeight);
//3
RobotAcceptTaskData taskThree = new RobotAcceptTaskData();
taskThree.setSerial("2");
taskThree.setCommand_id(taskDetailDO.getId().toString());
taskThree.setCommand_type(CommandTypeEnum.WAIT.getType());
taskThree.setParm(2000);
taskThree.setCommand_type(CommandTypeEnum.FORK.getType());
taskThree.setTarget_height(scanHeight);
//4
RobotAcceptTaskData taskFour = new RobotAcceptTaskData();
taskFour.setSerial("3");
taskFour.setCommand_id(taskDetailDO.getId().toString());
taskFour.setCommand_type(CommandTypeEnum.FORK.getType());
taskFour.setTarget_height(0.5);
taskFour.setCommand_type(CommandTypeEnum.WAIT.getType());
taskFour.setParm(parm);
//5
RobotAcceptTaskData taskFive = new RobotAcceptTaskData();
taskFive.setSerial("4");
taskFive.setCommand_id(taskDetailDO.getId().toString());
taskFive.setCommand_type(CommandTypeEnum.MOVE_POSE.getType());
Pose2ds pose2d = new Pose2ds();
pose2d.setX(0.183);
pose2d.setY(-0.572);
pose2d.setYaw(-0.088);
taskFive.setPose2d(pose2d);
taskFive.setCommand_type(CommandTypeEnum.GET_PALLET_TOPIC.getType());
//6
RobotAcceptTaskData taskSix = new RobotAcceptTaskData();
taskSix.setSerial("5");
taskSix.setCommand_id(taskDetailDO.getId().toString());
taskSix.setCommand_type(CommandTypeEnum.FORK.getType());
taskSix.setTarget_height(0.05);
double fromLocationTotalHeight = fromLocation.getLocationTotalHeight().doubleValue();
taskSix.setTarget_height(fromLocationTotalHeight);
//7
RobotAcceptTaskData taskSeven = new RobotAcceptTaskData();
taskSeven.setSerial("6");
taskSeven.setCommand_id(taskDetailDO.getId().toString());
taskSeven.setCommand_type(CommandTypeEnum.MOVE_POSE.getType());
Pose2ds pose2d7 = new Pose2ds();
pose2d7.setX(-0.407);
pose2d7.setY(-0.566);
pose2d7.setYaw(0.117);
taskSeven.setPose2d(pose2d7);
taskSeven.setCommand_type(CommandTypeEnum.MOVE_TO_PALLET_POSE.getType());
//8
RobotAcceptTaskData taskEight = new RobotAcceptTaskData();
taskEight.setSerial("7");
taskEight.setCommand_id(taskDetailDO.getId().toString());
taskEight.setCommand_type(CommandTypeEnum.FORK.getType());
taskEight.setTarget_height(0.05);
RobotAcceptTaskData taskEigth = new RobotAcceptTaskData();
taskEigth.setSerial("7");
taskEigth.setCommand_id(taskDetailDO.getId().toString());
taskEigth.setCommand_type(CommandTypeEnum.FORK.getType());
BigDecimal b1 = new BigDecimal(Double.toString(fromLocationTotalHeight));
BigDecimal b2 = new BigDecimal(Double.toString(liftHeight));
taskEigth.setTarget_height(b1.add(b2).doubleValue());
//8-2
RobotAcceptTaskData taskEigth2 = new RobotAcceptTaskData();
taskEigth2.setSerial("8");
taskEigth2.setCommand_id(taskDetailDO.getId().toString());
taskEigth2.setCommand_type(CommandTypeEnum.MOVE_POSE.getType());
Pose2ds poseWait1 = positionMapItemMapper.selectByLocationId(100l);
taskEigth2.setPose2d(poseWait1);
//9
RobotAcceptTaskData taskNigth = new RobotAcceptTaskData();
taskNigth.setSerial("9");
taskNigth.setCommand_id(taskDetailDO.getId().toString());
taskNigth.setCommand_type(CommandTypeEnum.MOVE_POSES.getType());
List<Pose2ds> pose2dsNight = new ArrayList<>();
WareHouseLocationDO ware = WareHouseLocationDO.builder()
.laneId(-2l)
.build();
List<WareHouseLocationDO> releaseStockList =
locationMapper.selectLocations(ware,new ArrayList<>(),new HashSet<>());
for (WareHouseLocationDO wareHouseLocationDO : releaseStockList) {
Pose2ds pose = positionMapItemMapper.selectByLocationId(wareHouseLocationDO.getId());
pose2dsNight.add(pose);
}
/*Pose2ds poseOne = new Pose2ds();
poseOne.setX(-2.097);
poseOne.setY(-0.325);
poseOne.setYaw(1.571);
Pose2ds poseTwo = new Pose2ds();
poseTwo.setX(-0.856);
poseTwo.setY(1.622);
poseTwo.setYaw(0.034);
Pose2ds poseThree = new Pose2ds();
poseThree.setX(1.955);
poseThree.setY(-0.381);
poseThree.setYaw(-1.540);
Pose2ds poseFour = new Pose2ds();
poseFour.setX(3.046);
poseFour.setY(3.219);
poseFour.setYaw(-3.141);
pose2dsNight.add(poseOne);
pose2dsNight.add(poseTwo);
pose2dsNight.add(poseThree);
pose2dsNight.add(poseFour);*/
taskNigth.setPose2ds(pose2dsNight);
//10
RobotAcceptTaskData taskTen = new RobotAcceptTaskData();
taskTen.setSerial("9");
taskTen.setCommand_id(taskDetailDO.getId().toString());
taskTen.setCommand_type(CommandTypeEnum.FORK.getType());
taskTen.setTarget_height(moveHeight);
//11
RobotAcceptTaskData taskEleven = new RobotAcceptTaskData();
taskEleven.setSerial("10");
taskEleven.setCommand_id(taskDetailDO.getId().toString());
taskEleven.setCommand_type(CommandTypeEnum.FORK.getType());
double toLocationTotalHeight = toLocation.getLocationTotalHeight().doubleValue();
BigDecimal b3 = new BigDecimal(Double.toString(toLocationTotalHeight));
BigDecimal b4 = new BigDecimal(Double.toString(liftHeight));
taskEleven.setTarget_height(b3.add(b4).doubleValue());
//12
RobotAcceptTaskData taskTwelve = new RobotAcceptTaskData();
taskTwelve.setSerial("11");
taskTwelve.setCommand_id(taskDetailDO.getId().toString());
taskTwelve.setCommand_type(CommandTypeEnum.MOVE_POSE.getType());
Pose2ds poseEnd = positionMapItemMapper.selectByLocationId(taskDetailDO.getToLocationId());
taskTwelve.setPose2d(poseEnd);
//13
RobotAcceptTaskData taskThirteen = new RobotAcceptTaskData();
taskThirteen.setSerial("12");
taskThirteen.setCommand_id(taskDetailDO.getId().toString());
taskThirteen.setCommand_type(CommandTypeEnum.FORK.getType());
taskThirteen.setTarget_height(toLocationTotalHeight);
//14
RobotAcceptTaskData taskFourteen = new RobotAcceptTaskData();
taskFourteen.setSerial("13");
taskFourteen.setCommand_id(taskDetailDO.getId().toString());
taskFourteen.setCommand_type(CommandTypeEnum.MOVE_POSE.getType());
Pose2ds poseWait = positionMapItemMapper.selectByLocationId(99l);
taskFourteen.setPose2d(poseWait);
/*
Pose2ds poseWait = new Pose2ds();
poseWait.setX(3.046);
poseWait.setY(3.219);
poseWait.setYaw(-3.141);
taskFourteen.setPose2d(poseWait);*/
//15
RobotAcceptTaskData taskFifteen = new RobotAcceptTaskData();
taskFifteen.setSerial("14");
taskFifteen.setCommand_id(taskDetailDO.getId().toString());
taskFifteen.setCommand_type(CommandTypeEnum.FORK.getType());
taskFifteen.setTarget_height(initHeight);
List<RobotAcceptTaskData> data = new ArrayList<>();
data.add(taskOne);
@ -415,7 +539,17 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
data.add(taskFive);
data.add(taskSix);
data.add(taskSeven);
data.add(taskEight);
data.add(taskEigth);
data.add(taskEigth2);
data.add(taskNigth);
data.add(taskTen);
data.add(taskEleven);
data.add(taskTwelve);
data.add(taskThirteen);
data.add(taskFourteen);
data.add(taskFifteen);
robotTaskDO.setData(data);
robotTaskDOS.add(robotTaskDO);
@ -426,6 +560,29 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
updateTaskStatus(robotNo,taskDetailDO);
}
private Pair<String, String> getMadAddressRobotNo(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
WareHouseLocationDO fromLocation, WareHouseLocationDO toLocation) {
String macAddress = "";
String robotNo = taskDetailDO.getRobotNo();
if (ObjectUtil.isNotEmpty(robotNo)) {
macAddress = robots.stream()
.filter(v -> v.getRobotNo().equals(taskDetailDO.getRobotNo()))
.map(RobotInformationDO::getMacAddress)
.findFirst()
.orElse("");
} else {
RobotInformationDO robotInformationDO = robots.stream()
.filter(v -> v.getFloorAreaJson().contains(fromLocation.getAreaId())
&& v.getFloorAreaJson().contains(toLocation.getAreaId()))
.findFirst()
.orElse(new RobotInformationDO());
macAddress = robotInformationDO.getMacAddress();
robotNo = robotInformationDO.getRobotNo();
}
Pair<String,String> pair = new ImmutablePair<>(macAddress,robotNo);
return pair;
}
@Transactional(rollbackFor = Exception.class)
public void updateTaskStatus(String robotNo, RobotTaskDetailDO taskDetailDO) {
robotInformationMapper.updateRobotStatus(robotNo, RobotStatusEnum.DOING.getType());

View File

@ -182,3 +182,12 @@ justauth:
type: REDIS
prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE::
timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟
zn:
task-no: ZN #任务号开头
do_cycle: true #是否开启循环
init_height: 0.0 #初始化高度
scan_height: 0.4 #扫描高度
parm: 5000 #等待时间
lift_height: 0.1 #抬高托盘高度
move_height: 0.1 #行走高度

View File

@ -223,3 +223,12 @@ justauth:
map:
file:
upload-path: /Users/aikai/Documents/map/ # 地图文件上传路径
zn:
task-no: ZN #任务号开头
do_cycle: true #是否开启循环
init_height: 0.0 #初始化高度
scan_height: 0.4 #扫描高度
parm: 5000 #等待时间
lift_height: 0.1 #抬高托盘高度
move_height: 0.1 #行走高度

View File

@ -207,6 +207,3 @@ yudao:
debug: false
zn:
task-no: ZN #任务号开头
do_cycle: true #是否开启循环

View File

@ -30,6 +30,8 @@
<result property="locationStorey" column="location_storey" jdbcType="INTEGER"/>
<result property="locationType" column="location_type" jdbcType="INTEGER"/>
<result property="locationNumber" column="location_number" jdbcType="INTEGER"/>
<result property="mapId" column="map_id" jdbcType="INTEGER"/>
<result property="mapItemId" column="map_item_id" jdbcType="INTEGER"/>
<result property="creator" column="creator" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updater" column="updater" jdbcType="VARCHAR"/>
@ -67,6 +69,8 @@
location_storey,
location_type,
location_number,
map_id,
map_item_id,
creator,
create_time,
updater,
@ -652,6 +656,7 @@
</foreach>
</if>
</where>
order by id asc
</select>
<select id="getLocationByName" resultType="cn.iocoder.yudao.module.system.controller.admin.houselocation.vo.WareHouseLocationRespVO">
<choose>

View File

@ -8,5 +8,258 @@
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO">
<!--@Table ware_position_map_item-->
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="positionMapId" column="position_map_id" jdbcType="INTEGER"/>
<result property="areaId" column="area_id" jdbcType="INTEGER"/>
<result property="laneId" column="lane_id" jdbcType="INTEGER"/>
<result property="locationX" column="location_x" jdbcType="VARCHAR"/>
<result property="locationY" column="location_y" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="dataJson" column="data_json" jdbcType="VARCHAR"/>
<result property="creator" column="creator" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updater" column="updater" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="deleted" column="deleted" jdbcType="INTEGER"/>
</resultMap>
<!--查询单个-->
<sql id="base_sql" >
id,
position_map_id,
area_id,
lane_id,
location_x,
location_y,
type,
data_json,
creator,
create_time,
updater,
update_time,
deleted,
tenant_id
</sql>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="BaseResultMap">
select
id, position_map_id, area_id, lane_id, location_x, location_y, type, data_json, creator, create_time, updater,
update_time, deleted, tenant_id
from ware_position_map_item
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="positionMapId != null">
and position_map_id = #{positionMapId}
</if>
<if test="areaId != null">
and area_id = #{areaId}
</if>
<if test="laneId != null">
and lane_id = #{laneId}
</if>
<if test="locationX != null and locationX != ''">
and location_x = #{locationX}
</if>
<if test="locationY != null and locationY != ''">
and location_y = #{locationY}
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="dataJson != null and dataJson != ''">
and data_json = #{dataJson}
</if>
<if test="creator != null and creator != ''">
and creator = #{creator}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updater != null and updater != ''">
and updater = #{updater}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="deleted != null">
and deleted = #{deleted}
</if>
<if test="tenantId != null">
and tenant_id = #{tenantId}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="BaseResultMap">
select
id, position_map_id, area_id, lane_id, location_x, location_y, type, data_json, creator, create_time, updater,
update_time, deleted, tenant_id
from zn_wcs.ware_position_map_item
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from ware_position_map_item
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="positionMapId != null">
and position_map_id = #{positionMapId}
</if>
<if test="areaId != null">
and area_id = #{areaId}
</if>
<if test="laneId != null">
and lane_id = #{laneId}
</if>
<if test="locationX != null and locationX != ''">
and location_x = #{locationX}
</if>
<if test="locationY != null and locationY != ''">
and location_y = #{locationY}
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="dataJson != null and dataJson != ''">
and data_json = #{dataJson}
</if>
<if test="creator != null and creator != ''">
and creator = #{creator}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updater != null and updater != ''">
and updater = #{updater}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="deleted != null">
and deleted = #{deleted}
</if>
<if test="tenantId != null">
and tenant_id = #{tenantId}
</if>
</where>
</select>
<select id="selectByLocationId" resultType="cn.iocoder.yudao.module.mqtt.api.task.dto.Pose2ds">
select
t1.location_x as x,
t1.location_y as y,
t2.location_yaw as yaw
from
ware_position_map_item t1 ,ware_house_location t2
where t1.id = t2.map_item_id
and t2.id = #{locationId}
</select>
<!--新增所有列-->
<insert id="insertEntity" keyProperty="id" useGeneratedKeys="true">
insert into ware_position_map_item(position_map_id, area_id, lane_id, location_x, location_y, type, data_json,
creator, create_time, updater, update_time, deleted, tenant_id)
values (#{positionMapId}, #{areaId}, #{laneId}, #{locationX}, #{locationY}, #{type}, #{dataJson}, #{creator},
#{createTime}, #{updater}, #{updateTime}, #{deleted}, #{tenantId})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into ware_position_map_item(position_map_id, area_id, lane_id, location_x, location_y, type, data_json,
creator, create_time, updater, update_time, deleted, tenant_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.positionMapId}, #{entity.areaId}, #{entity.laneId}, #{entity.locationX}, #{entity.locationY},
#{entity.type}, #{entity.dataJson}, #{entity.creator}, #{entity.createTime}, #{entity.updater},
#{entity.updateTime}, #{entity.deleted}, #{entity.tenantId})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into ware_position_map_item(position_map_id, area_id, lane_id, location_x, location_y, type, data_json,
creator, create_time, updater, update_time, deleted, tenant_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.positionMapId}, #{entity.areaId}, #{entity.laneId}, #{entity.locationX}, #{entity.locationY},
#{entity.type}, #{entity.dataJson}, #{entity.creator}, #{entity.createTime}, #{entity.updater},
#{entity.updateTime}, #{entity.deleted}, #{entity.tenantId})
</foreach>
on duplicate key update
position_map_id = values(position_map_id),
area_id = values(area_id),
lane_id = values(lane_id),
location_x = values(location_x),
location_y = values(location_y),
type = values(type),
data_json = values(data_json),
creator = values(creator),
create_time = values(create_time),
updater = values(updater),
update_time = values(update_time),
deleted = values(deleted),
tenant_id = values(tenant_id)
</insert>
<!--通过主键修改数据-->
<update id="update">
update ware_position_map_item
<set>
<if test="positionMapId != null">
position_map_id = #{positionMapId},
</if>
<if test="areaId != null">
area_id = #{areaId},
</if>
<if test="laneId != null">
lane_id = #{laneId},
</if>
<if test="locationX != null and locationX != ''">
location_x = #{locationX},
</if>
<if test="locationY != null and locationY != ''">
location_y = #{locationY},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="dataJson != null and dataJson != ''">
data_json = #{dataJson},
</if>
<if test="creator != null and creator != ''">
creator = #{creator},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="deleted != null">
deleted = #{deleted},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from ware_position_map_item
where id = #{id}
</delete>
</mapper>

View File

@ -148,7 +148,7 @@
id, robot_task_id, task_type, release_type, take_type, release_id, take_id, from_location_no, from_location_id,
to_location_no, to_location_id, robot_no, robot_action, task_status, task_stage, start_time, end_time, creator,
create_time, updater, update_time, deleted, tenant_id
from zn_wcs.robot_task_detail
from robot_task_detail
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
@ -333,6 +333,17 @@
order by priority desc, create_time asc ,robot_no desc
</select>
<select id="getDoingTaskIds" resultType="java.lang.Long">
select
distinct
robot_task_id
from
robot_task_detail
where
task_status = '1'
and deleted = '0'
</select>
<!--新增所有列-->
<insert id="insertSelect" keyProperty="id" useGeneratedKeys="true">
insert into robot_task_detail(robot_task_id, task_type, release_type, take_type, release_id, take_id,

View File

@ -236,6 +236,55 @@
deleted = '0'
and montage_task = #{montageTask}
and task_status in ('0','1')
<if test= " ids != null and ids.size() > 0">
AND id not in
<foreach collection="ids" item="id" index="index" open="(" close=")"
separator=",">
#{id}
</foreach>
</if>
</select>
<select id="selectPageList" resultMap="BaseResultMap">
select
DISTINCT
t1.id,
t1.montage_task,
t1.montage_number,
t1.sku_info,
t1.sku_batch,
t1.sku_number,
t1.priority,
t1.other_msg,
t1.do_cycle,
t1.do_move_all,
t1.cycle_number,
t1.remaining_cycle_number,
t1.task_no,
t1.task_status,
t1.task_stage,
t1.start_time,
t1.end_time
from
robot_task t1 left join robot_task_detail t2
on t1.id = t2.robot_task_id
<where>
t1.deleted = '0'
and t2.deleted = '0'
<if test="pageReqVO.taskNo != null and pageReqVO.taskNo != ''">
and t1.task_no like concat('%', #{pageReqVO.taskNo}, '%')
</if>
<if test="pageReqVO.taskStatus != null">
and t1.task_status = #{pageReqVO.taskStatus}
</if>
<if test="pageReqVO.taskStage != null">
and t1.task_stage = #{pageReqVO.taskStage}
</if>
<if test="pageReqVO.robotNo != null">
and t2.robot_no like concat('%', #{pageReqVO.robotNo}, '%')
</if>
</where>
order by t1.create_time desc
</select>