Compare commits

..

No commits in common. "0d10b907f367bdf75a08e76e2683d8d5794d470f" and "9ee9fc7994e3e6165515013f6535fff073008c1a" have entirely different histories.

60 changed files with 342 additions and 1358 deletions

View File

@ -92,18 +92,6 @@ public class PositionMapLineDTO {
@Schema(description = "膨胀区域右")
private BigDecimal expansionZoneRight;
@Schema(description = "起点宽")
private BigDecimal beginWidth;
@Schema(description = "起点高")
private BigDecimal beginHigh;
@Schema(description = "终点宽")
private BigDecimal endWidth;
@Schema(description = "终点高")
private BigDecimal endHigh;
@Schema(description = "车头朝向( 0:正正 1:正反 2:反正 3:反反)", example = "15890")
private Integer toward;

View File

@ -1,24 +0,0 @@
package cn.iocoder.yudao.module.mqtt.api.path.task;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 下发任务给PP机器人不能行走的楼层和区域
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TaskLimitationAreaDTO {
@Schema(description = "楼层", example = "20863")
private Integer floor;
@Schema(description = "区域", example = "20863")
private String area;
}

View File

@ -1,25 +0,0 @@
package cn.iocoder.yudao.module.mqtt.api.path.task;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 下发任务给PP机器人不能行走的楼层和区域
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TaskRobotNoLimittationAreaDTO {
@Schema(description = "机器人编号")
private String robotNo;
@Schema(description = "机器人不能行走的楼层和区域")
private List<TaskLimitationAreaDTO> limitationAreaList;
}

View File

@ -1,10 +1,7 @@
package cn.iocoder.yudao.module.mqtt.api.path.task;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@ -12,43 +9,16 @@ import java.util.List;
* 发送任务给PP
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TaskToPathPlanningDTO {
@Schema(description = "robot_task_detail/robot_charge_log 的 id")
private Long id;
@Schema(description = "robot_task_detail 的 id")
private String id;
@Schema(description = "任务类型(TASK:robot_task的任务、CHARGE:充电任务)")
private String type;
@Schema(description = "能执行此任务的机器人编号")
private List<String> robotNoList;
//线库: LINE + 线库号
//普通库位: POINT + 点位号
@Schema(description = "取货的组编号")
private String takeGroupId;
@Schema(description = "取货任务, 组序号, 越大越先执行")
private Long takeLocationNumber;
@Schema(description = "取货任务的终点id")
private Long takePointId;
//线库: LINE + 线库号
//普通库位: POINT + 点位号
@Schema(description = "放货的组编号(可能为空)")
private String releaseGroupId;
@Schema(description = "放货任务, 组序号, 越大越先执行(可能为空)")
private Long releaseLocationNumber;
@Schema(description = "放货任务的终点id")
private Long releasePointId;
@Schema(description = "优先级(不同的组编号时:越大越先执行, 相同组编号时:组序号越大的越先执行)")
private Long priority;
@Schema(description = "能执行此任务的机器人编号, 和机器人不能行走的区域")
private List<TaskRobotNoLimittationAreaDTO> robotNoLimitationAreaDTOS;
@Schema(description = "取的编号: 线库id+点位id")
private String takeId;
}

View File

@ -1,17 +0,0 @@
package cn.iocoder.yudao.module.mqtt.enums.path;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*TaskToPathPlanningDTO的type
*/
@Getter
@AllArgsConstructor
public enum TaskTypeEnum {
TASK("TASK"), // 客户下发的任务 robot_task_detail的数据
CHARGE("CHARGE"), // 充电
;
private final String type;
}

View File

@ -45,10 +45,6 @@ public class PathPlanningTopicConstant {
*/
public static String UPDATE_MAP_NODE = "UPDATE_MAP_NODE";
/**
* 下发任务给给PP
*/
public static String SEND_TASK_TO_PP = "SEND_TASK_TO_PP";
}

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.system.controller.admin.bulletinboard.vo;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.DeviceStatusInfoVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationStatisticsVO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnMsgDO;
@ -23,8 +22,4 @@ public class BulletinBoardVO {
private RobotInformationStatisticsVO statistics;
@Schema(description = "车辆异常信息")
private List<RobotWarnMsgDO> robotWarnMsgDOS;
@Schema(description = "车辆信息")
List<RobotElectricityLevelVO> robotElectricityLevelVOS;
@Schema(description = "设备信息")
private List<DeviceStatusInfoVO> deviceStatusInfoVOS;
}

View File

@ -9,20 +9,8 @@ import lombok.ToString;
public class RobotElectricityLevelVO {
@Schema(description = "AGV编号")
private String robotNo;
@Schema(description = "设备mac地址")
private String macAddress;
@Schema(description = "待命 0否 1是")
private Integer standby = 0;
@Schema(description = "任务中 0否 1是")
private Integer inTask = 0;
@Schema(description = "锁定 0否 1是")
private Integer doLock = 0;
@Schema(description = "离线 0否 1是")
private Integer offline = 0;
@Schema(description = "充电中 0否 1是")
private Integer charge = 0;
@Schema(description = "故障 0否 1是")
private Integer fault = 0;
@Schema(description = "状态")
private String status;
@Schema(description = "电量")
private String batSoc;
}

View File

@ -3,11 +3,8 @@ package cn.iocoder.yudao.module.system.controller.admin.housearea;
import cn.iocoder.yudao.module.system.controller.admin.housearea.vo.HouseAreaPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.housearea.vo.HouseAreaRespVO;
import cn.iocoder.yudao.module.system.controller.admin.housearea.vo.HouseAreaSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.houselane.vo.WareHouseLanePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.houselane.vo.WareHouseLaneRespVO;
import cn.iocoder.yudao.module.system.controller.admin.houselane.vo.WareHouseLaneSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.housearea.HouseAreaDO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselane.WareHouseLaneDO;
import cn.iocoder.yudao.module.system.service.housearea.HouseAreaService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -90,12 +87,4 @@ public class HouseAreaController {
return success(BeanUtils.toBean(list, HouseAreaRespVO.class));
}
@DeleteMapping("/delete")
@Operation(summary = "删除库区")
@Parameter(name = "id", description = "菜单编号", required= true, example = "1024")
public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
houseAreaService.delete(id);
return success(true);
}
}

View File

@ -28,10 +28,6 @@ public class HouseAreaRespVO {
@ExcelProperty("库区说明")
private String areaMsg;
@Schema(description = "物料信息")
@ExcelProperty("物料信息")
private String skuInfo;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;

View File

@ -1,15 +1,10 @@
package cn.iocoder.yudao.module.system.controller.admin.houselane;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.housearea.vo.HouseAreaPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.housearea.vo.HouseAreaRespVO;
import cn.iocoder.yudao.module.system.controller.admin.houselane.vo.WareHouseLanePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.houselane.vo.WareHouseLaneRespVO;
import cn.iocoder.yudao.module.system.controller.admin.houselane.vo.WareHouseLaneSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.housearea.HouseAreaDO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselane.WareHouseLaneDO;
import cn.iocoder.yudao.module.system.service.houselane.WareHouseLaneService;
import io.swagger.v3.oas.annotations.Operation;
@ -67,20 +62,4 @@ public class WareHouseLaneController {
.orderByAsc(WareHouseLaneDO::getId));
return success(BeanUtils.toBean(list, WareHouseLaneRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得线库分页")
@PreAuthorize("@ss.hasPermission('ware:house-area:query')")
public CommonResult<PageResult<WareHouseLaneRespVO>> getHouseAreaPage(@Valid WareHouseLanePageReqVO pageReqVO) {
PageResult<WareHouseLaneDO> pageResult = houseLaneService.getHouseLanePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, WareHouseLaneRespVO.class));
}
@DeleteMapping("/delete")
@Operation(summary = "删除线库")
@Parameter(name = "id", description = "菜单编号", required= true, example = "1024")
public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
houseLaneService.delete(id);
return success(true);
}
}

View File

@ -59,7 +59,7 @@ public class PathPlanningController {
return success("同步完成");
}
@PostMapping("/item/all")
@PostMapping("/all/item")
@Operation(summary = "同步ware_position_map_item的点位信息")
@PreAuthorize("@ss.hasPermission('robot:information:synchronousItem')")
public CommonResult<String> synchronousAllItem(@RequestBody PositionMapSaveReqVO positionMapSaveReqVO) {

View File

@ -1,10 +1,8 @@
package cn.iocoder.yudao.module.system.controller.admin.positionmap;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.enums.NodeTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseDTO;
@ -12,25 +10,22 @@ import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMa
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO;
import cn.iocoder.yudao.module.system.handler.mapnode.NodeProcessingContext;
import cn.iocoder.yudao.module.system.service.positionmap.PositionMapItemService;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Slf4j
@Tag(name = "管理后台 - 仓库点位地图子表")
@RestController
@RequestMapping("/system/position-map-item")
@ -50,15 +45,12 @@ public class PositionMapItemController {
Map<Integer, List<NodeBaseDTO>> map = nodeBaseDTOS.stream().collect(Collectors.groupingBy(NodeBaseDTO::getType));
// -- 获取到对应地图的所有点位
List<PositionMapItemDO> oldList = positionMapItemService.getByMapId(positionMapId);
List<PositionMapItemDO> newAllList = new ArrayList<>();
Map<Integer, List<PositionMapItemDO>> oldMap = oldList.stream().collect(Collectors.groupingBy(PositionMapItemDO::getType));
for (Integer key : NodeTypeEnum.getAllTypes()) {
List<NodeBaseDTO> nodeBaseDTOList = CollectionUtil.isEmpty(map.get(key)) ? Collections.emptyList() : map.get(key);
List<PositionMapItemDO> newList = nodeProcessingContext.processNodesByStrategy(positionMapId, key, nodeBaseDTOList);
newAllList.addAll(newList);
List<PositionMapItemDO> oldItemList = CollectionUtil.isEmpty(oldMap.get(key)) ? Collections.emptyList() : oldMap.get(key);
nodeProcessingContext.processNodesByStrategy(positionMapId, oldItemList, key, nodeBaseDTOList);
}
List<List<PositionMapItemDO>> list = CollectionUtils.compareLists(oldList, newAllList,
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId()));
positionMapItemService.batchSaveOrEditOrDel(positionMapId, list);
return success(true);
}

View File

@ -31,9 +31,6 @@ public class NodeBaseDTO {
@Schema(description = "实际坐标y轴")
private String actualLocationY;
@Schema(description = "点位自增排序")
private Long sortNum;
@Schema(description = "类型 1.路径点位 2.库位点 3.充电桩 4.停车点 5.区域变更点 6.等待点 --- 后续补充", example = "1")
private Integer type;

View File

@ -90,18 +90,6 @@ public class PositionMapLineDTO {
@Schema(description = "膨胀区域右")
private BigDecimal expansionZoneRight;
@Schema(description = "起点宽")
private BigDecimal beginWidth;
@Schema(description = "起点高")
private BigDecimal beginHigh;
@Schema(description = "终点宽")
private BigDecimal endWidth;
@Schema(description = "终点高")
private BigDecimal endHigh;
@Schema(description = "车头朝向( 0:正正 1:正反 2:反正 3:反反)")
private Integer toward;
}

View File

@ -32,9 +32,6 @@ public class PositionMapItemPageReqVO extends PageParam {
@Schema(description = "坐标y轴")
private String locationY;
@Schema(description = "点位自增排序")
private Long sortNum;
@Schema(description = "类型 1.路径点位 2.库位点 3.充电桩 4.停车点 5.区域变更点 6.等待点 --- 后续补充", example = "1")
private Integer type;

View File

@ -52,9 +52,6 @@ public class PositionMapItemRespVO {
@ExcelProperty("类型 1.路径点位 2.库位点 3.充电桩 4.停车点 5.区域变更点 6.等待点 --- 后续补充")
private Integer type;
@Schema(description = "点位自增排序")
private Long sortNum;
@Schema(description = "对应各个类型的独有属性Json格式 例如({库位长度:1,库位宽度:2,库位方向:单向}", example = "1")
private String dataJson;

View File

@ -27,9 +27,6 @@ public class PositionMapItemSaveReqVO {
@Schema(description = "坐标y轴")
private String locationY;
@Schema(description = "点位自增排序")
private Long sortNum;
@Schema(description = "类型 1.路径点位 2.库位点 3.充电桩 4.停车点 5.区域变更点 6.等待点 --- 后续补充", example = "1")
private Integer type;

View File

@ -85,18 +85,6 @@ public class PositionMapLinePageReqVO extends PageParam {
@Schema(description = "膨胀区域右", example = "15890")
private BigDecimal expansionZoneRight;
@Schema(description = "起点宽")
private BigDecimal beginWidth;
@Schema(description = "起点高")
private BigDecimal beginHigh;
@Schema(description = "终点宽")
private BigDecimal endWidth;
@Schema(description = "终点高")
private BigDecimal endHigh;
@Schema(description = "行走方法 0.直线 1.曲线")
private Integer method;

View File

@ -94,18 +94,6 @@ public class PositionMapLineRespVO {
@ExcelProperty("膨胀区域右")
private BigDecimal expansionZoneRight;
@Schema(description = "起点宽")
private BigDecimal beginWidth;
@Schema(description = "起点高")
private BigDecimal beginHigh;
@Schema(description = "终点宽")
private BigDecimal endWidth;
@Schema(description = "终点高")
private BigDecimal endHigh;
@Schema(description = "行走方法 0.直线 1.曲线")
@ExcelProperty("行走方法 0.直线 1.曲线")
private Integer method;

View File

@ -82,18 +82,6 @@ public class PositionMapLineSaveReqVO {
@Schema(description = "膨胀区域右", example = "15890")
private BigDecimal expansionZoneRight;
@Schema(description = "起点宽")
private BigDecimal beginWidth;
@Schema(description = "起点高")
private BigDecimal beginHigh;
@Schema(description = "终点宽")
private BigDecimal endWidth;
@Schema(description = "终点高")
private BigDecimal endHigh;
@Schema(description = "行走方法 0.直线 1.曲线")
private Integer method;

View File

@ -1,26 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.robot.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 设备状态数量信息
*
* @author 艾楷
*/
@Data
public class DeviceStatusInfoVO {
@Schema(description = "设备类型")
private Integer deviceType;
@Schema(description = "总数量")
private Integer totalNum = 0;
@Schema(description = "正常数量")
private Integer normalNum = 0;
@Schema(description = "异常数量")
private Integer abnormalNum = 0;
}

View File

@ -1,22 +0,0 @@
package cn.iocoder.yudao.module.system.controller.admin.robot.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class RobotInfoStatusVO {
@Schema(description = "设备mac地址")
private String macAddress;
@Schema(description = "待命 0否 1是")
private Integer standby = 0;
@Schema(description = "任务中 0否 1是")
private Integer inTask = 0;
@Schema(description = "锁定 0否 1是")
private Integer doLock = 0;
@Schema(description = "离线 0否 1是")
private Integer offline = 0;
@Schema(description = "充电中 0否 1是")
private Integer charge = 0;
@Schema(description = "故障 0否 1是")
private Integer fault = 0;
}

View File

@ -40,8 +40,8 @@ public class RobotInformationPageRespVO {
@ExcelProperty("在线状态/离线状态0离线、1在线")
private Integer onlineStatus = 0;
@Schema(description = "车机状态0锁定、 1空闲、、2:异常)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("车机状态0锁定、 1空闲、、2:异常)")
@Schema(description = "车机状态0空闲、1锁定、2:异常)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("车机状态0空闲、1锁定、2:异常)")
private Integer robotEssenceStatus = 0;
@Schema(description = "任务状态0待命中、1处理中、2:充电中)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")

View File

@ -70,12 +70,5 @@ public class RobotInformationRespVO {
@ExcelProperty("是否自动充电0:手动充电,1:自动充电)")
private Integer chargeType;
@Schema(description = "楼层")
@ExcelProperty("楼层")
public String floor;
@Schema(description = "区域")
@ExcelProperty("区域")
public String area;
}

View File

@ -43,6 +43,9 @@ public class RobotTaskDetailAddVO {
@Schema(description = "放货线库id")
private Long toLaneId;
@Schema(description = "取货库位的排序的位置,越大越优先堆放")
private Long locationNumber;
@Schema(description = "计算后的来源库位编号(前端不用传此字段)")
private String fromLocationNo;
@Schema(description = "计算后的来源库位id(前端不用传此字段)")
@ -60,18 +63,6 @@ public class RobotTaskDetailAddVO {
@Schema(description = "优先级(前端不用传此字段)")
private Long priority;
@Schema(description = "取货库位的排序")
private Long fromLocationNumber;
@Schema(description = "放货库位的排序")
private Long toLocationNumber;
@Schema(description = "取货库位ware_position_map的id")
private Long fromMapId;
@Schema(description = "放货库位ware_position_map的id")
private Long toMapId;
public Long getPriority() {
if (ObjectUtil.isEmpty(priority)) {
priority = 0l;

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.system.controller.admin.robot.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@ -53,6 +52,9 @@ public class RobotTaskDetailPageReqVO extends PageParam {
@Schema(description = "放货线库id")
private Long toLaneId;
@Schema(description = "取货库位的排序的位置,越大越优先堆放")
private Long locationNumber;
@Schema(description = "任务状态(0:未开始、1执行中、2已完成、3已取消)", example = "1")
private Integer taskStatus;
@ -81,16 +83,4 @@ public class RobotTaskDetailPageReqVO extends PageParam {
private Integer needLock;
@Schema(description = "所选车辆电量(充电模式)")
private Integer electricity;
@Schema(description = "取货库位的排序")
private Long fromLocationNumber;
@Schema(description = "放货库位的排序")
private Long toLocationNumber;
@Schema(description = "取货库位ware_position_map的id")
private Long fromMapId;
@Schema(description = "放货库位ware_position_map的id")
private Long toMapId;
}

View File

@ -86,6 +86,10 @@ public class RobotTaskDetailRespVO {
@ExcelProperty("放货线库id")
private Long toLaneId;
@Schema(description = "取货库位的排序的位置,越大越优先堆放")
@ExcelProperty("取货库位的排序的位置,越大越优先堆放")
private Long locationNumber;
@Schema(description = "取货层数")
@ExcelProperty("取货层数")
private Integer fromLocationStorey;
@ -102,19 +106,4 @@ public class RobotTaskDetailRespVO {
@ExcelProperty("所选车辆电量(充电模式)")
private Integer electricity;
@Schema(description = "取货库位的排序")
@ExcelProperty("取货库位的排序")
private Long fromLocationNumber;
@Schema(description = "放货库位的排序")
@ExcelProperty("放货库位的排序")
private Long toLocationNumber;
@Schema(description = "取货库位ware_position_map的id")
@ExcelProperty("取货库位ware_position_map的id")
private Long fromMapId;
@Schema(description = "放货库位ware_position_map的id")
@ExcelProperty("放货库位ware_position_map的id")
private Long toMapId;
}

View File

@ -44,6 +44,9 @@ public class RobotTaskDetailSaveReqVO {
@Schema(description = "放货线库id")
private Long toLaneId;
@Schema(description = "取货库位的排序的位置,越大越优先堆放")
private Long locationNumber;
@Schema(description = "计算后的来源库位编号")
private String fromLocationNo;
@Schema(description = "计算后的来源库位id")
@ -82,16 +85,4 @@ public class RobotTaskDetailSaveReqVO {
@Schema(description = "所选车辆电量(充电模式)")
private Integer electricity;
@Schema(description = "取货库位的排序")
private Long fromLocationNumber;
@Schema(description = "放货库位的排序")
private Long toLocationNumber;
@Schema(description = "取货库位ware_position_map的id")
private Long fromMapId;
@Schema(description = "放货库位ware_position_map的id")
private Long toMapId;
}

View File

@ -32,7 +32,6 @@ public class PositionMapItemDO extends BaseDO {
/**
* 库区id
*/
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Long areaId;
/**
* 线库id
@ -55,10 +54,6 @@ public class PositionMapItemDO extends BaseDO {
* 实际坐标y轴
*/
private String actualLocationY;
/**
* 点位自增排序
*/
private Long sortNum;
/**
* 类型 1.路径点位 2.库位点 3.充电桩 4.停车点 5.区域变更点 6.等待点 --- 后续补充
*/

View File

@ -122,27 +122,6 @@ public class PositionMapLineDO extends BaseDO {
* 膨胀区域右
*/
private BigDecimal expansionZoneRight;
/**
* 起点宽
*/
private BigDecimal beginWidth;
/**
* 起点高
*/
private BigDecimal beginHigh;
/**
* 终点宽
*/
private BigDecimal endWidth;
/**
* 终点高
*/
private BigDecimal endHigh;
/**
* 行走方法 0.直线 1.曲线
*/

View File

@ -68,13 +68,9 @@ public class RobotTaskDetailDO extends BaseDO {
*/
private Long toLaneId;
/**
* 取货库位的排序
* 取货库位的排序的位置,越大越优先堆放
*/
private Long fromLocationNumber;
/**
* 放货库位的排序
*/
private Long toLocationNumber;
private Long locationNumber;
/**
* 计算后的目标库位编号
*/
@ -127,14 +123,4 @@ public class RobotTaskDetailDO extends BaseDO {
* 所选车辆电量(充电模式)
*/
private Integer electricity;
/**
* ware_position_map的id
*/
private Long fromMapId;
/**
* ware_position_map的id
*/
private Long toMapId;
}

View File

@ -20,7 +20,6 @@ public interface WareHouseLaneMapper extends BaseMapperX<WareHouseLaneDO> {
default PageResult<WareHouseLaneDO> selectPage(WareHouseLanePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<WareHouseLaneDO>()
.eqIfPresent(WareHouseLaneDO::getPositionMapId, reqVO.getPositionMapId())
.likeIfPresent(WareHouseLaneDO::getLaneName, reqVO.getLaneName())
.eqIfPresent(WareHouseLaneDO::getLaneMsg, reqVO.getLaneMsg())
.betweenIfPresent(WareHouseLaneDO::getCreateTime, reqVO.getCreateTime())

View File

@ -8,7 +8,6 @@ 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;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -32,7 +31,6 @@ public interface PositionMapItemMapper extends BaseMapperX<PositionMapItemDO> {
/**
* 根据库位id查询
*
* @param locationId
* @return
*/
@ -40,24 +38,8 @@ public interface PositionMapItemMapper extends BaseMapperX<PositionMapItemDO> {
/**
* 根据position_map_id 查询
*
* @param positionMapId
* @return
*/
List<PositionMapItemSynDTO> getAllByMapId(Long positionMapId);
/**
* 将areaId设为空
*
* @param mapId
* @param areaId
*/
void emptyAreaId(@Param("mapId") Long mapId, @Param("areaId") Long areaId);
/**
* 将laneId设为空
* @param mapId
* @param laneId
*/
void emptyLaneId(@Param("mapId") Long mapId, @Param("laneId") Long laneId);
}

View File

@ -86,6 +86,12 @@ public interface RobotTaskDetailMapper extends BaseMapperX<RobotTaskDetailDO> {
void updateRobotDetailById(RobotTaskDetailDO detailDO);
/**
* 查询正在处理中的任务主表id
* @return
*/
List<Long> getDoingTaskIds();
/**
* 获取未进行的充电任务
* @return

View File

@ -9,15 +9,16 @@ import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseD
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO;
import cn.iocoder.yudao.module.system.handler.mapnode.strategy.*;
import cn.iocoder.yudao.module.system.service.positionmap.PositionMapItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Component
public class NodeProcessingContext {
@ -56,14 +57,18 @@ public class NodeProcessingContext {
}
@Transactional(rollbackFor = Exception.class)
public List<PositionMapItemDO> processNodesByStrategy(Long positionMapId, int key, List<NodeBaseDTO> nodeBaseDTOS) {
public void processNodesByStrategy(Long positionMapId, List<PositionMapItemDO> oldItemList, int key, List<NodeBaseDTO> nodeBaseDTOS) {
// -- 获取对应的策略 - 如果没有对应的直接 return
NodeProcessingStrategy strategy = strategyMap.get(key);
if (strategy == null) {
return Collections.emptyList();
return;
}
// 策略模式 策略实现 - 组装好数据后返回给上一层
// 策略模式 策略实现
strategy.processNodes(positionMapId, nodeBaseDTOS);
return BeanUtil.copyToList(nodeBaseDTOS, PositionMapItemDO.class);
List<PositionMapItemDO> newList = BeanUtil.copyToList(nodeBaseDTOS, PositionMapItemDO.class);
List<List<PositionMapItemDO>> list = CollectionUtils.compareLists(oldItemList, newList,
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId()));
positionMapItemService.batchSaveOrEditOrDel(positionMapId, list);
}
}

View File

@ -24,8 +24,6 @@ public class DeviceStrategyImpl implements NodeProcessingStrategy {
// -- 策略3 处理设备点
// -- 将data里面的json 数据转为实体类 - 再对比节点id - 然后做新增删除修改操作
List<DeviceInformationDO> newList = new ArrayList<>();
// -- 拿到这个地图所绑定的设备 -
List<DeviceInformationDO> oldList = deviceInformationService.getDeviceInfoBindByMapId(positionMapId);
nodeBaseDTOS.forEach(item -> {
if (item.getId() == null) {
item.setId(getId());
@ -36,14 +34,16 @@ public class DeviceStrategyImpl implements NodeProcessingStrategy {
deviceInformationDO.setLocationY(item.getLocationY());
deviceInformationDO.setActualLocationX(item.getActualLocationX());
deviceInformationDO.setActualLocationY(item.getActualLocationY());
deviceInformationDO.setPositionMapId(positionMapId);
deviceInformationDO.setPositionMapItemId(item.getId());
newList.add(deviceInformationDO);
item.setDataJson(JSONUtil.toJsonStr(deviceInformationDO));
});
List<DeviceInformationDO> oldList = deviceInformationService.getByMapId(positionMapId);
List<List<DeviceInformationDO>> list = CollectionUtils.compareLists(oldList, newList,
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId()));
deviceInformationService.batchEditOrDel(list);
deviceInformationService.batchSaveOrEditOrDel(positionMapId, list);
}
}

View File

@ -1,14 +1,12 @@
package cn.iocoder.yudao.module.system.handler.mapnode.strategy;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.service.houselocation.HouseLocationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@ -16,13 +14,11 @@ import java.util.ArrayList;
import java.util.List;
import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId;
@Slf4j
@Component
public class HouseLocationStrategyImpl implements NodeProcessingStrategy {
@Resource
private HouseLocationService houseLocationService;
//库位编号格式 - 第一个通配符为地图id 第二个通配符为随机数四位最后一个通配符为库位点层数
private static final String KW_NO_FORMAT = "KW-%s-%s-%s";
@Override
public void processNodes(Long positionMapId, List<NodeBaseDTO> nodeBaseDTOS) {
@ -38,7 +34,7 @@ public class HouseLocationStrategyImpl implements NodeProcessingStrategy {
List<WareHouseLocationDO> wareHouseLocationDOS = JSONUtil.toList(item.getDataJson(), WareHouseLocationDO.class);
// -- 筛选出 库位编号不为空 - 并且第最后一组数据 最大的值 - 如果没有则为0
int max = wareHouseLocationDOS.stream().map(WareHouseLocationDO::getLocationNo).filter(StrUtil::isNotEmpty)
.mapToInt(s -> Integer.parseInt(s.substring(s.length() - 1))).max().orElse(1);
.mapToInt(s -> Integer.parseInt(s.split("_")[2])).max().orElse(0);
for (WareHouseLocationDO wareHouseLocationDO : wareHouseLocationDOS) {
wareHouseLocationDO.setLocationX(item.getLocationX());
wareHouseLocationDO.setLocationY(item.getLocationY());
@ -49,8 +45,7 @@ public class HouseLocationStrategyImpl implements NodeProcessingStrategy {
}
if (StrUtil.isEmpty(wareHouseLocationDO.getLocationNo())) {
// -- 生成库位编号 -
String locationNo = String.format(KW_NO_FORMAT, positionMapId, RandomUtil.randomNumbers(4), max++);
wareHouseLocationDO.setLocationNo(locationNo);
wareHouseLocationDO.setLocationNo(positionMapId + "_" + item.getId() + "_" + max++);
}
wareHouseLocationDO.setMapId(positionMapId);
wareHouseLocationDO.setMapItemId(item.getId());

View File

@ -1,10 +1,19 @@
package cn.iocoder.yudao.module.system.handler.mapnode.strategy;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.service.houselocation.HouseLocationService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId;
@Component
public class MapNodeStrategyImpl implements NodeProcessingStrategy {

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.system.service.bulletinboard;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.json.JSONUtil;
@ -10,15 +9,11 @@ import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.controller.admin.bulletinboard.vo.BulletinBoardVO;
import cn.iocoder.yudao.module.system.controller.admin.bulletinboard.vo.RobotElectricityLevelVO;
import cn.iocoder.yudao.module.system.controller.admin.bulletinboard.vo.TaskStatusVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.DeviceStatusInfoVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInfoStatusVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationStatisticsVO;
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
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.RobotWarnMsgDO;
import cn.iocoder.yudao.module.system.enums.robot.RobotTaskDetailStatusEnum;
import cn.iocoder.yudao.module.system.service.information.DeviceInformationService;
import cn.iocoder.yudao.module.system.service.robot.RobotInformationService;
import cn.iocoder.yudao.module.system.service.robot.RobotTaskService;
import cn.iocoder.yudao.module.system.service.robot.RobotWarnMsgService;
@ -31,7 +26,6 @@ import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -50,8 +44,6 @@ public class BulletinBoardServiceImpl implements BulletinBoardService {
private RobotInformationService robotInformationService;
@Resource
private RedisUtil redisUtil;
@Resource
private DeviceInformationService deviceInformationService;
@Override
public BulletinBoardVO getBulletinBoard() {
@ -102,49 +94,21 @@ public class BulletinBoardServiceImpl implements BulletinBoardService {
vo.setStatistics(statisticsVO);
// 车辆异常信息
vo.setRobotWarnMsgDOS(robotWarnMsgDOS);
List<RobotElectricityLevelVO> robotElectricityLevelVOS = new ArrayList<>();
List<RobotInformationDO> allRobot = robotInformationService.getAllRobot();
List<RobotInfoStatusVO> agvListStatusInfo = robotInformationService.getAGVListStatusInfo();
Map<String, RobotInfoStatusVO> map = agvListStatusInfo.stream().collect(Collectors.toMap(RobotInfoStatusVO::getMacAddress, Function.identity()));
for (RobotInformationDO robotInformationDO : allRobot) {
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + robotInformationDO.getMacAddress();
Object object = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
if (robotStatusDataPoseDTO != null) {
RobotElectricityLevelVO robotElectricityLevelVO = new RobotElectricityLevelVO();
//todo 这里缺少一个状态
RobotInfoStatusVO item = map.get(robotInformationDO.getMacAddress());
if (item != null) {
BeanUtil.copyProperties(item, robotElectricityLevelVO);
}
robotElectricityLevelVO.setRobotNo(robotInformationDO.getRobotNo());
robotElectricityLevelVO.setBatSoc(robotStatusDataPoseDTO.getBat_soc());
robotElectricityLevelVOS.add(robotElectricityLevelVO);
}
}
vo.setRobotElectricityLevelVOS(robotElectricityLevelVOS);
// - 获取所有设备
List<DeviceInformationDO> deviceInformationDOS = deviceInformationService.list();
//根据设备类型分组
Map<Integer, List<DeviceInformationDO>> deviceMap = deviceInformationDOS.stream().collect(Collectors.groupingBy(DeviceInformationDO::getDeviceType));
List<DeviceStatusInfoVO> deviceStatusInfoVOS = new ArrayList<>();
for (Map.Entry<Integer, List<DeviceInformationDO>> entry : deviceMap.entrySet()) {
Integer deviceType = entry.getKey();
DeviceStatusInfoVO deviceStatusInfoVO = new DeviceStatusInfoVO();
deviceStatusInfoVO.setDeviceType(deviceType);
List<DeviceInformationDO> deviceInformationDOList = entry.getValue();
if (CollectionUtil.isEmpty(deviceInformationDOList)) {
deviceStatusInfoVOS.add(deviceStatusInfoVO);
continue;
}
deviceStatusInfoVO.setTotalNum(deviceInformationDOList.size());
long count = deviceInformationDOList.stream().filter(a -> a.getDeviceStatus().equals(3)).count();
deviceStatusInfoVO.setNormalNum((int) count);
deviceStatusInfoVO.setAbnormalNum(deviceStatusInfoVO.getTotalNum() - deviceStatusInfoVO.getNormalNum());
deviceStatusInfoVOS.add(deviceStatusInfoVO);
}
vo.setDeviceStatusInfoVOS(deviceStatusInfoVOS);
return vo;
return null;
}
}

View File

@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
@ -172,9 +171,7 @@ public class DictDataServiceImpl implements DictDataService {
@Override
public List<DictDataDO> getDictDataListByDictType(String dictType) {
List<DictDataDO> list = dictDataMapper.selectList(new LambdaQueryWrapperX<DictDataDO>()
.eq(DictDataDO::getDictType, dictType)
.eq(DictDataDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
List<DictDataDO> list = dictDataMapper.selectList(DictDataDO::getDictType, dictType);
list.sort(Comparator.comparing(DictDataDO::getSort));
return list;
}

View File

@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.housearea.vo.HouseAreaPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.housearea.vo.HouseAreaSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.housearea.HouseAreaDO;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
import java.util.List;
@ -14,7 +13,7 @@ import java.util.List;
*
* @author 陈宾顺
*/
public interface HouseAreaService extends IService<HouseAreaDO> {
public interface HouseAreaService {
/**
* 创建库区
@ -63,15 +62,7 @@ public interface HouseAreaService extends IService<HouseAreaDO> {
/**
* 获得全部库区
*
* @return
*/
List<HouseAreaDO> getHouseAreaList(Long positionMapId);
/**
* 删除库区
*
* @param id
*/
void delete(Long id);
}

View File

@ -18,9 +18,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.housearea.HouseAreaMapper;
import cn.iocoder.yudao.module.system.service.houselocation.HouseLocationService;
import cn.iocoder.yudao.module.system.service.positionmap.PositionMapItemService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
@ -40,7 +38,7 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.THERE_ARE_
*/
@Service
@Validated
public class HouseAreaServiceImpl extends ServiceImpl<HouseAreaMapper, HouseAreaDO> implements HouseAreaService {
public class HouseAreaServiceImpl implements HouseAreaService {
@Resource
private HouseAreaMapper houseAreaMapper;
@ -68,7 +66,6 @@ public class HouseAreaServiceImpl extends ServiceImpl<HouseAreaMapper, HouseArea
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteHouseArea(Long id) {
// 校验存在
validateHouseAreaExists(id);
@ -93,7 +90,6 @@ public class HouseAreaServiceImpl extends ServiceImpl<HouseAreaMapper, HouseArea
}
@Override
@Transactional(rollbackFor = Exception.class)
public void createOrEditOrDel(HouseAreaSaveReqVO createReqVO) {
HouseAreaDO houseArea = BeanUtil.copyProperties(createReqVO, HouseAreaDO.class);
houseAreaMapper.insertOrUpdate(houseArea);
@ -166,14 +162,4 @@ public class HouseAreaServiceImpl extends ServiceImpl<HouseAreaMapper, HouseArea
.orderByAsc(HouseAreaDO::getId));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
HouseAreaDO areaDO = this.getById(id);
this.removeById(id);
//获取当前库区所对应的地图
// 点位中包含库区id的数据设为null
positionMapItemService.emptyAreaId(areaDO.getPositionMapId(), id);
}
}

View File

@ -39,9 +39,4 @@ public interface WareHouseLaneService extends IService<WareHouseLaneDO> {
*/
void createOrEditOrDel(@Valid WareHouseLaneSaveReqVO createReqVO);
/**
* 删除线库
* @param id
*/
void delete(Long id);
}

View File

@ -7,11 +7,9 @@ import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.enums.NodeTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.houselane.vo.WareHouseLanePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.houselane.vo.WareHouseLaneSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.PositionMapConditionDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.housearea.HouseAreaDO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselane.WareHouseLaneDO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO;
@ -144,13 +142,4 @@ public class WareHouseLaneServiceImpl extends ServiceImpl<WareHouseLaneMapper, W
houseLocationService.updateBatchById(wareHouseLocationList);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
WareHouseLaneDO wareHouseLaneDO = this.getById(id);
this.removeById(id);
// 点位中包含线库id的数据设为null
positionMapItemService.emptyLaneId(wareHouseLaneDO.getPositionMapId(), id);
}
}

View File

@ -12,7 +12,6 @@ import cn.iocoder.yudao.module.system.dal.mysql.houselocation.WareHouseLocationM
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
@ -36,7 +35,6 @@ public class HouseLocationServiceImpl extends ServiceImpl<WareHouseLocationMappe
private WareHouseLocationMapper houseLocationMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createHouseLocation(WareHouseLocationSaveReqVO createReqVO) {
// 插入
WareHouseLocationDO houseLocation = BeanUtils.toBean(createReqVO, WareHouseLocationDO.class);
@ -46,7 +44,6 @@ public class HouseLocationServiceImpl extends ServiceImpl<WareHouseLocationMappe
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateHouseLocation(WareHouseLocationSaveReqVO updateReqVO) {
// 校验存在
validateHouseLocationExists(updateReqVO.getId());
@ -56,7 +53,6 @@ public class HouseLocationServiceImpl extends ServiceImpl<WareHouseLocationMappe
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteHouseLocation(Long id) {
// 校验存在
validateHouseLocationExists(id);
@ -93,7 +89,6 @@ public class HouseLocationServiceImpl extends ServiceImpl<WareHouseLocationMappe
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchSaveOrEditOrDel(Long positionMapId, List<List<WareHouseLocationDO>> list) {
//批量添加修改删除
if (isNotEmpty(list.get(0))) {

View File

@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.system.controller.admin.information.dto.Statistic
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
import java.util.List;
@ -18,7 +17,7 @@ import java.util.Map;
*
* @author 陈宾顺
*/
public interface DeviceInformationService extends IService<DeviceInformationDO> {
public interface DeviceInformationService {
/**
* 创建设备信息
@ -61,9 +60,10 @@ public interface DeviceInformationService extends IService<DeviceInformationDO>
/**
* 批量新增删除修改
*
* @param positionMapId
* @param list
*/
void batchEditOrDel(List<List<DeviceInformationDO>> list);
void batchSaveOrEditOrDel(Long positionMapId, List<List<DeviceInformationDO>> list);
/**
* 通过地图id获取设备列表
@ -90,31 +90,20 @@ public interface DeviceInformationService extends IService<DeviceInformationDO>
/**
* 获得设备信息分类列表
*
* @return
*/
Map<Integer, List<DeviceInformationDO>> classification();
/**
* 统计设备
*
* @return
*/
List<StatisticsInformationDTO> getDeviceNumber();
/**
* 查看全部设备
*
* @param pageReqVO
* @return
*/
List<DeviceInformationDO> getInformationList(@Valid DeviceInformationPageReqVO pageReqVO);
/**
* 获取设备信息 通过地图id - 并且设备有绑定具体点位 即点位id不为空
*
* @param positionMapId
* @return
*/
List<DeviceInformationDO> getDeviceInfoBindByMapId(Long positionMapId);
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.grpc.api.GrpcServiceApi;
import cn.iocoder.yudao.module.system.constant.device.DeviceChcheConstant;
import cn.iocoder.yudao.module.system.controller.admin.information.dto.DeviceInformationDTO;
import cn.iocoder.yudao.module.system.controller.admin.information.dto.MapBindDeviceInfoDTO;
@ -12,13 +13,13 @@ import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInfo
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
import cn.iocoder.yudao.module.system.dal.mysql.config.CommonConfigMapper;
import cn.iocoder.yudao.module.system.dal.mysql.information.DeviceInformationMapper;
import cn.iocoder.yudao.module.system.enums.device.DeviceStatusEnum;
import cn.iocoder.yudao.module.system.enums.device.PictureConfigEnum;
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -32,6 +33,7 @@ import java.util.stream.Collectors;
import static cn.hutool.core.collection.CollUtil.isNotEmpty;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.INFORMATION_MAC_EXIST;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.INFORMATION_NOT_EXISTS;
@ -43,7 +45,7 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.INFORMATIO
@Service
@Validated
@Slf4j
public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationMapper, DeviceInformationDO> implements DeviceInformationService {
public class DeviceInformationServiceImpl implements DeviceInformationService {
@Resource
private DeviceInformationMapper informationMapper;
@ -51,14 +53,18 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
@Resource
private DictDataService dictDataService;
@Resource
private GrpcServiceApi grpcServiceApi;
@Resource
private RedisUtil redisUtil;
@Override
public Long createInformation(DeviceInformationSaveReqVO createReqVO) {
// -- 先判断库里是否有相通的mac地址数据
long count = this.count(new LambdaQueryWrapper<DeviceInformationDO>().eq(DeviceInformationDO::getMacAddress, createReqVO.getMacAddress()));
if (count > 0L) {
DeviceInformationPageReqVO pageReqVO = new DeviceInformationPageReqVO();
pageReqVO.setMacAddress(createReqVO.getMacAddress());
PageResult<DeviceInformationDO> pageResult = informationMapper.selectPage(pageReqVO);
if (ObjectUtil.isNotEmpty(pageResult.getList())) {
throw exception(INFORMATION_MAC_EXIST);
}
@ -84,15 +90,6 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
public void updateInformation(DeviceInformationSaveReqVO updateReqVO) {
// 校验存在
validateInformationExists(updateReqVO.getId());
//默认图片
if (PictureConfigEnum.DEFAULT.getType().equals(updateReqVO.getPictureConfig())) {
List<DictDataDO> deviceType = dictDataService.getDictDataListByDictType("device_type");
DictDataDO dictDataDO = deviceType.stream()
.filter(v -> Integer.valueOf(v.getValue()).equals(updateReqVO.getDeviceType()))
.findFirst()
.orElse(new DictDataDO());
updateReqVO.setUrl(dictDataDO.getRemark());
}
// 更新
DeviceInformationDO updateObj = BeanUtils.toBean(updateReqVO, DeviceInformationDO.class);
informationMapper.updateById(updateObj);
@ -117,7 +114,7 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
// 校验存在
validateInformationExists(id);
DeviceInformationDO deviceInformationDO = informationMapper.selectById(id);
String deviceKey = DeviceChcheConstant.DEVICE_LAST_TIME + deviceInformationDO.getMacAddress();
String deviceKey = DeviceChcheConstant.DEVICE_LAST_TIME +deviceInformationDO.getMacAddress();
Object object = redisUtil.get(deviceKey);
if (ObjectUtil.isEmpty(object)) {
deviceInformationDO.setDeviceStatus(DeviceStatusEnum.OFF_LINE.getType());
@ -125,11 +122,11 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
}
try {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime curTimeLDT = LocalDateTime.parse((String) object, df);
LocalDateTime curTimeLDT = LocalDateTime.parse((String)object, df);
deviceInformationDO.setDeviceLastTime(curTimeLDT);
deviceInformationDO.setDeviceStatus(DeviceStatusEnum.ON_LINE.getType());
} catch (Exception e) {
log.info("查询设备最后通讯时间异常 :{}", e.getMessage());
log.info("查询设备最后通讯时间异常 :{}",e.getMessage());
}
return deviceInformationDO;
}
@ -141,19 +138,16 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
@Override
@Transactional(rollbackFor = Exception.class)
public void batchEditOrDel(List<List<DeviceInformationDO>> list) {
public void batchSaveOrEditOrDel(Long positionMapId, List<List<DeviceInformationDO>> list) {
//批量添加修改删除
List<DeviceInformationDO> editList = new ArrayList<>();
if (isNotEmpty(list.get(0)) || isNotEmpty(list.get(1))) {
editList.addAll(list.get(0));
editList.addAll(list.get(1));
if (isNotEmpty(list.get(0))) {
informationMapper.insertBatch(list.get(0));
}
if (isNotEmpty(list.get(1))) {
informationMapper.updateBatch(list.get(1));
}
if (isNotEmpty(list.get(2))) {
list.get(2).forEach(a -> a.setPositionMapItemId(null));
editList.addAll(list.get(2));
}
if (isNotEmpty(editList)){
informationMapper.updateBatch(editList);
informationMapper.deleteByIds(convertList(list.get(2), DeviceInformationDO::getId));
}
}
@ -176,7 +170,6 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
/**
* 获得设备信息分类列表
*
* @return
*/
@Override
@ -188,7 +181,7 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
// todo 需要设置设备通讯的时间
for (DeviceInformationDO deviceInformationDO : deviceInformationDOS) {
String deviceKey = DeviceChcheConstant.DEVICE_LAST_TIME + deviceInformationDO.getMacAddress();
String deviceKey = DeviceChcheConstant.DEVICE_LAST_TIME +deviceInformationDO.getMacAddress();
Object object = redisUtil.get(deviceKey);
if (ObjectUtil.isEmpty(object)) {
deviceInformationDO.setDeviceStatus(DeviceStatusEnum.OFF_LINE.getType());
@ -196,11 +189,11 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
}
try {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime curTimeLDT = LocalDateTime.parse((String) object, df);
LocalDateTime curTimeLDT = LocalDateTime.parse((String)object, df);
deviceInformationDO.setDeviceLastTime(curTimeLDT);
deviceInformationDO.setDeviceStatus(DeviceStatusEnum.ON_LINE.getType());
} catch (Exception e) {
log.info("查询设备最后通讯时间异常 :{}", e.getMessage());
log.info("查询设备最后通讯时间异常 :{}",e.getMessage());
}
}
@ -209,8 +202,8 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
.collect(Collectors.groupingBy(DeviceInformationDO::getDeviceType));
ArrayList<Map.Entry<Integer, List<DeviceInformationDO>>> list = new ArrayList<Map.Entry<Integer, List<DeviceInformationDO>>>(collect.entrySet());
Collections.sort(list, new Comparator<Map.Entry<Integer, List<DeviceInformationDO>>>() {
public int compare(Map.Entry<Integer, List<DeviceInformationDO>> o1, Map.Entry<Integer, List<DeviceInformationDO>> o2) {
Collections.sort(list, new Comparator<Map.Entry<Integer, List<DeviceInformationDO>>>() {
public int compare(Map.Entry<Integer, List<DeviceInformationDO>> o1, Map.Entry<Integer, List<DeviceInformationDO>> o2) {
return o1.getKey().compareTo(o2.getKey()); // 按照值排序
}
});
@ -220,7 +213,6 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
/**
* 统计设备
*
* @return
*/
@Override
@ -260,7 +252,7 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
// todo 需要设置设备通讯的时间
for (DeviceInformationDO deviceInformationDO : deviceInformationDOS) {
String deviceKey = DeviceChcheConstant.DEVICE_LAST_TIME + deviceInformationDO.getMacAddress();
String deviceKey = DeviceChcheConstant.DEVICE_LAST_TIME +deviceInformationDO.getMacAddress();
Object object = redisUtil.get(deviceKey);
if (ObjectUtil.isEmpty(object)) {
deviceInformationDO.setDeviceStatus(DeviceStatusEnum.OFF_LINE.getType());
@ -268,24 +260,17 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
}
try {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime curTimeLDT = LocalDateTime.parse((String) object, df);
LocalDateTime curTimeLDT = LocalDateTime.parse((String)object, df);
deviceInformationDO.setDeviceLastTime(curTimeLDT);
deviceInformationDO.setDeviceStatus(DeviceStatusEnum.ON_LINE.getType());
} catch (Exception e) {
log.info("查询设备最后通讯时间异常 :{}", e.getMessage());
log.info("查询设备最后通讯时间异常 :{}",e.getMessage());
}
}
return deviceInformationDOS;
}
@Override
public List<DeviceInformationDO> getDeviceInfoBindByMapId(Long positionMapId) {
return informationMapper.selectList(new LambdaQueryWrapperX<DeviceInformationDO>()
.eq(DeviceInformationDO::getPositionMapId, positionMapId)
.isNotNull(DeviceInformationDO::getPositionMapItemId));
}
@Override
public void mapBindDeviceInfo(MapBindDeviceInfoDTO dto) {
DeviceInformationDO deviceInformationDO = informationMapper.selectById(dto.getDeviceInfoId());

View File

@ -77,19 +77,4 @@ public interface PositionMapItemService extends IService<PositionMapItemDO> {
* @return
*/
List<PositionMapItemDO> getByCondition(PositionMapConditionDTO positionMapConditionDTO);
/**
* 清空areaId
*
* @param mapId
* @param areaId
*/
void emptyAreaId(Long mapId, Long areaId);
/**
* 清空laneId
* @param mapId
* @param laneId
*/
void emptyLaneId(Long mapId, Long laneId);
}

View File

@ -10,7 +10,6 @@ import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItem
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapItemMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
@ -70,7 +69,6 @@ public class PositionMapItemServiceImpl extends ServiceImpl<PositionMapItemMappe
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchSaveOrEditOrDel(Long positionMapId, List<List<PositionMapItemDO>> list) {
//批量添加修改删除
if (isNotEmpty(list.get(0))) {
@ -97,15 +95,5 @@ public class PositionMapItemServiceImpl extends ServiceImpl<PositionMapItemMappe
.eqIfPresent(PositionMapItemDO::getLaneId, dto.getLaneId()));
}
@Override
public void emptyAreaId(Long positionMapId, Long areaId) {
positionMapItemMapper.emptyAreaId(positionMapId, areaId);
}
@Override
public void emptyLaneId(Long mapId, Long laneId) {
positionMapItemMapper.emptyLaneId(mapId, laneId);
}
}

View File

@ -54,6 +54,8 @@ public class PositionMapServiceImpl extends ServiceImpl<PositionMapMapper, Posit
private PositionMapMapper positionMapMapper;
@Value("${map.file.upload-path}")
private String UPLOAD_DIR;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Override
public Long createPositionMap(PositionMapSaveReqVO createReqVO) {

View File

@ -63,12 +63,6 @@ public interface RobotInformationService extends IService<RobotInformationDO> {
*/
RobotInformationStatisticsVO statisticsInformation();
/**
* 获取所有AGV状态
* @return
*/
List<RobotInfoStatusVO> getAGVListStatusInfo();
/**
* 查询能正常使用的车辆
*

View File

@ -142,15 +142,6 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
RobotInformationDO robotInformationDO = informationMapper.selectById(id);
RobotInformationRespVO bean = BeanUtils.toBean(robotInformationDO, RobotInformationRespVO.class);
setPositionMapList(bean);
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + bean.getMacAddress();
Object object = redisUtil.get(pose2dKey);
RobotStatusDataPoseDTO robotStatusDataPoseDTO = JSONUtil.toBean((String) object, RobotStatusDataPoseDTO.class);
if (ObjectUtil.isNotEmpty(object) && ObjectUtil.isNotEmpty(robotStatusDataPoseDTO)) {
bean.setElectricity(robotStatusDataPoseDTO.getBat_soc());
bean.setFloor(robotStatusDataPoseDTO.getFloor());
bean.setArea(robotStatusDataPoseDTO.getArea());
}
return bean;
}
@ -197,7 +188,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
}
if (RobotStatisticsTypeEnum.DOLOCK.getType().equals(pageReqVO.getRobotStatisticsType())
&& v.getRobotEssenceStatus().equals(0)) {
&& v.getRobotEssenceStatus().equals(1)) {
resultList.add(v);
continue;
}
@ -245,7 +236,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
//设置异常
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL + v.getMacAddress();
Object errorLevel = redisUtil.get(errorLevelKey);
if (ObjectUtil.isNotEmpty(errorLevel)) {
if (ObjectUtil.isNotEmpty(errorLevel) && Integer.valueOf(errorLevel.toString()).intValue() >= 3) {
v.setRobotEssenceStatus(2);
}
@ -344,48 +335,6 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
return info;
}
@Override
public List<RobotInfoStatusVO> getAGVListStatusInfo() {
List<RobotInfoStatusVO> list = new ArrayList<>();
// -- 先从缓存中 获取AGV状态信息 - 如果没有的话 - 再从数据库中获取 - 并且缓存到redis中
List<RobotInformationDO> robotInformationDO = informationMapper.selectList();
if (robotInformationDO == null) {
return list;
}
for (RobotInformationDO informationDO : robotInformationDO) {
RobotInfoStatusVO vo = new RobotInfoStatusVO();
//0待命1任务中2锁定3离线4:充电中5:故障
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT_SOC + informationDO.getMacAddress();
Object object = redisUtil.get(pose2dKey);
if (ObjectUtil.isEmpty(object)) {
//离线
vo.setOffline(1);
}
if (RobotTaskModelEnum.REJECTION.getType().equals(informationDO.getRobotTaskModel())) {
//锁定
vo.setDoLock(1);
}
//设置异常
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL + informationDO.getMacAddress();
Object errorLevel = redisUtil.get(errorLevelKey);
if (ObjectUtil.isNotEmpty(errorLevel) && Integer.parseInt(errorLevel.toString()) >= 3) {
vo.setFault(1);
}
if (RobotStatusEnum.STAND_BY.getType().equals(informationDO.getRobotStatus())) {
//待命中
vo.setStandby(1);
} else if (RobotStatusEnum.CHARGE.getType().equals(informationDO.getRobotStatus())) {
//充电中
vo.setCharge(1);
} else {
//任务中
vo.setInTask(1);
}
list.add(vo);
}
return list;
}
/**
* @return
*/

View File

@ -313,8 +313,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper,RobotTaskD
robotTaskDetailAddVo.setToLocationId(releaseStockList.get(i).getId());
robotTaskDetailAddVo.setFromLaneId(stockList.get(i).getLaneId());
robotTaskDetailAddVo.setToLaneId(releaseStockList.get(i).getLaneId());
robotTaskDetailAddVo.setFromLocationNumber(stockList.get(i).getLocationNumber());
robotTaskDetailAddVo.setFromMapId(stockList.get(i).getMapId());
robotTaskDetailAddVo.setLocationNumber(stockList.get(i).getLocationNumber());
robotTaskDetailAddVo.setRobotTaskId(taskId);
robotTaskDetailAddVo.setPriority(robotTaskVo.getPriority());
robotTaskDetailAddVo.setFromLocationStorey(stockList.get(i).getLocationStorey());
@ -441,9 +440,8 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper,RobotTaskD
*/
@Transactional(rollbackFor = Exception.class)
public void doPark(RobotTaskDetailAddVO robotTaskVo, List<Long> locationIds) {
// todo 停车后续停到等待点
/*setToLocation(robotTaskVo,getMapIdsByRobotNo(robotTaskVo.getRobotNo()),locationIds);
locationIds.add(robotTaskVo.getToLocationId());*/
setToLocation(robotTaskVo,getMapIdsByRobotNo(robotTaskVo.getRobotNo()),locationIds);
locationIds.add(robotTaskVo.getToLocationId());
}
/**
@ -476,8 +474,6 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper,RobotTaskD
robotTaskVo.setToLocationId(robotTaskVo.getReleaseId());
robotTaskVo.setToLocationStorey(locationDO.getLocationStorey());
robotTaskVo.setToLaneId(locationDO.getLaneId());
robotTaskVo.setToLocationNumber(locationDO.getLocationNumber());
robotTaskVo.setToMapId(locationDO.getMapId());
if (ObjectUtil.isNotEmpty(mapIds) && !mapIds.contains(locationDO.getMapId())) {
log.error("机器人不能在此放货库位放货 :{}, 机器人编号 :{}", locationDO.getLocationNo(),robotTaskVo.getRobotNo());
throw new RuntimeException("机器人不能在此放货库位放货 "+ robotTaskVo.getReleaseId());
@ -494,8 +490,6 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper,RobotTaskD
robotTaskVo.setToLocationId(wareHouseLocationDO.getId());
robotTaskVo.setToLocationStorey(wareHouseLocationDO.getLocationStorey());
robotTaskVo.setToLaneId(wareHouseLocationDO.getLaneId());
robotTaskVo.setToLocationNumber(wareHouseLocationDO.getLocationNumber());
robotTaskVo.setToMapId(wareHouseLocationDO.getMapId());
}
}
@ -514,8 +508,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper,RobotTaskD
robotTaskVo.setFromLocationId(robotTaskVo.getTakeId());
robotTaskVo.setFromLocationStorey(locationDO.getLocationStorey());
robotTaskVo.setFromLaneId(locationDO.getLaneId());
robotTaskVo.setFromLocationNumber(locationDO.getLocationNumber());
robotTaskVo.setFromMapId(locationDO.getMapId());
robotTaskVo.setLocationNumber(locationDO.getLocationNumber());
if (ObjectUtil.isNotEmpty(mapIds) && !mapIds.contains(locationDO.getMapId())) {
log.error("机器人不能在此取货库位取货 :{}, 机器人编号 :{}", locationDO.getLocationNo(),robotTaskVo.getRobotNo());
throw new RuntimeException("机器人不能在此取货库位取货 "+ robotTaskVo.getTakeId());
@ -532,8 +525,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper,RobotTaskD
robotTaskVo.setFromLocationId(wareHouseLocationDO.getId());
robotTaskVo.setFromLocationStorey(wareHouseLocationDO.getLocationStorey());
robotTaskVo.setFromLaneId(wareHouseLocationDO.getLaneId());
robotTaskVo.setFromLocationNumber(wareHouseLocationDO.getLocationNumber());
robotTaskVo.setFromMapId(wareHouseLocationDO.getMapId());
robotTaskVo.setLocationNumber(wareHouseLocationDO.getLocationNumber());
}
}

View File

@ -179,8 +179,6 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
return pair;
}
log.info("完成查找车子");
//拼接任务id
/*List<Long> detailDongIds = robotTaskDetailMapper.getDoingTaskIds();
List<Long> montageTaskIds = robotTaskMapper.getUnDoAndDoingTaskIds(MontageTaskEnum.YES.getType(), detailDongIds);
@ -202,8 +200,6 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
.map(RobotTaskDO::getId)
.collect(Collectors.toList());
log.info("完成查找主任务");
if (ObjectUtil.isEmpty(montageTaskIds) && ObjectUtil.isEmpty(singleTaskIds)) {
log.info("暂无需要处理的主任务");
return pair;

View File

@ -384,9 +384,9 @@ public class RobotTaskAutoMoveServiceImpl implements RobotTaskAutoMoveService {
List<WareHouseLocationDO> locations = new ArrayList<>();
RobotTaskDetailDO robotTaskDetail = detaiMap.getValue()
.stream()
.min(Comparator.comparing(RobotTaskDetailDO::getFromLocationNumber)).get();
if (ObjectUtil.isNotEmpty(robotTaskDetail) && ObjectUtil.isNotEmpty(robotTaskDetail.getFromLocationNumber())) {
WareHouseLocationDO location = WareHouseLocationDO.builder().locationNumber(robotTaskDetail.getFromLocationNumber())
.min(Comparator.comparing(RobotTaskDetailDO::getLocationNumber)).get();
if (ObjectUtil.isNotEmpty(robotTaskDetail) && ObjectUtil.isNotEmpty(robotTaskDetail.getLocationNumber())) {
WareHouseLocationDO location = WareHouseLocationDO.builder().locationNumber(robotTaskDetail.getLocationNumber())
.locationUseStatus(LocationUseStatusEnum.YES.getType())
// .locationLock(LocationLockEnum.YES.getType())
.laneId(detaiMap.getKey()).build();

View File

@ -1,37 +1,19 @@
package cn.iocoder.yudao.module.system.service.robot.pathplanning;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.mqtt.api.path.PathPlanningApi;
import cn.iocoder.yudao.module.mqtt.api.path.task.TaskLimitationAreaDTO;
import cn.iocoder.yudao.module.mqtt.api.path.task.TaskRobotNoLimittationAreaDTO;
import cn.iocoder.yudao.module.mqtt.api.path.task.TaskToPathPlanningDTO;
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.mqtt.enums.path.TaskTypeEnum;
import cn.iocoder.yudao.module.system.constant.path.PathPlanningTopicConstant;
import cn.iocoder.yudao.module.system.constant.robot.RobotTopicConstant;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
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.config.CommonConfigMapper;
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.PositionMapMapper;
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 cn.iocoder.yudao.module.system.service.robot.job.DistributeTasksService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -40,11 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.List;
@Service
@Validated
@ -83,12 +61,6 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
@Value("${zn.full_electricity:100}")
private String fullElectricity;
@Value("${zn.task_need_single:true}")
private Boolean taskNeedSingle;
@Value("${zn.location_number_reduce:100000000}")
private Long locationNumberReduce;
@Resource
private CommonConfigMapper configMapper;
@ -102,12 +74,6 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
@Autowired
private DistributeTasksService distributeTasksService;
@Resource
private PositionMapMapper positionMapMapper;
@Resource
private PathPlanningApi pathPlanningApi;
/**
* 下发任务给PP
*/
@ -115,7 +81,6 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
@Transactional(rollbackFor = Exception.class)
public void sendTaskToPP() {
TenantContextHolder.setTenantId(1L);
log.info("-------开始查找车子和任务------");
Pair<List<RobotInformationDO>, List<RobotTaskDetailDO>> robotAndTaskDetails =
distributeTasksService.getRobotAndTaskDetails();
@ -130,618 +95,47 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
return;
}
log.info("-------查找到车子和任务------");
distributeTasksToPP(robots, taskDetailDOS);
}
@Transactional(rollbackFor = Exception.class)
public void distributeTasksToPP(List<RobotInformationDO> robots, List<RobotTaskDetailDO> taskDetailDOS) {
//目前一个点位/线库 只能派一辆车去做
taskDetailDOS = getSingleTask(taskDetailDOS);
if (ObjectUtil.isEmpty(taskDetailDOS)) {
log.info("相同的点位/线库,目前有处理中的任务, 无法派单给PP");
return;
}
List<TaskToPathPlanningDTO> pathPlanningList = new ArrayList<>();
Set<Long> locationIds = new HashSet<>();
Set<Long> fromLocationIds = taskDetailDOS.stream().map(RobotTaskDetailDO::getFromLocationId).collect(Collectors.toSet());
Set<Long> toLocationIds = taskDetailDOS.stream().map(RobotTaskDetailDO::getToLocationId).collect(Collectors.toSet());
locationIds.addAll(fromLocationIds);
locationIds.addAll(toLocationIds);
List<WareHouseLocationDO> locations = locationMapper.selectList(new LambdaQueryWrapperX<WareHouseLocationDO>()
.in(WareHouseLocationDO::getId, locationIds));
List<PositionMapDO> positionMapDOS = positionMapMapper.selectList(new LambdaQueryWrapperX<PositionMapDO>());
Map<Long, WareHouseLocationDO> locationDOMap =
locations.stream().collect(Collectors.toMap(v -> v.getId(), Function.identity()));
for (RobotTaskDetailDO taskDetailDO : taskDetailDOS) {
TaskToPathPlanningDTO pathPlanning = TaskToPathPlanningDTO.builder()
.id(taskDetailDO.getId())
.type(TaskTypeEnum.TASK.getType())
.priority(taskDetailDO.getPriority())
.build();
//能执行此任务的机器人 不能走的区域
List<TaskRobotNoLimittationAreaDTO> robotNoLimitationArea = getRobotNoLimitationArea(robots, positionMapDOS,
taskDetailDO.getRobotNo());
if (ObjectUtil.isEmpty(robotNoLimitationArea)) {
log.info("此任务明细,已经指定了机器人编号, 没有对应的机器人能执行此任务 :{}, 机器人编号:{}", taskDetailDO.getId(), taskDetailDO.getRobotNo());
continue;
}
pathPlanning.setRobotNoLimitationAreaDTOS(robotNoLimitationArea);
//取是线库
if (ObjectUtil.isNotEmpty(taskDetailDO.getFromLocationId())
&& ObjectUtil.isNotEmpty(taskDetailDO.getFromLaneId())) {
pathPlanning.setTakeGroupId("LINE_" + taskDetailDO.getFromLaneId());
pathPlanning.setTakeLocationNumber(Math.abs(locationNumberReduce - taskDetailDO.getFromLocationNumber()));
pathPlanning.setTakePointId(locationDOMap.get(taskDetailDO.getFromLocationId()).getMapItemId());
} else if (ObjectUtil.isNotEmpty(taskDetailDO.getFromLocationId())
&& ObjectUtil.isEmpty(taskDetailDO.getFromLaneId())) {
//取的是普通点位
pathPlanning.setTakeGroupId("POINT_" + taskDetailDO.getFromMapId());
pathPlanning.setTakeLocationNumber(Math.abs(locationNumberReduce - taskDetailDO.getFromLocationNumber()));
pathPlanning.setTakePointId(locationDOMap.get(taskDetailDO.getFromLocationId()).getMapItemId());
}
//放是线库
if (ObjectUtil.isNotEmpty(taskDetailDO.getToLocationId())
&& ObjectUtil.isNotEmpty(taskDetailDO.getToLaneId())) {
pathPlanning.setReleaseGroupId("LINE_" + taskDetailDO.getToLaneId());
pathPlanning.setReleaseLocationNumber(Math.abs(locationNumberReduce - taskDetailDO.getToLocationNumber()));
pathPlanning.setReleasePointId(locationDOMap.get(taskDetailDO.getToLocationId()).getMapItemId());
} else if (ObjectUtil.isNotEmpty(taskDetailDO.getToLocationId())
&& ObjectUtil.isEmpty(taskDetailDO.getToLaneId())) {
//放的是普通点位
pathPlanning.setReleaseGroupId("POINT_" + taskDetailDO.getToMapId());
pathPlanning.setReleaseLocationNumber(Math.abs(locationNumberReduce - taskDetailDO.getToLocationNumber()));
pathPlanning.setReleasePointId(locationDOMap.get(taskDetailDO.getToLocationId()).getMapItemId());
}
pathPlanningList.add(pathPlanning);
}
if (ObjectUtil.isNotEmpty(pathPlanningList)) {
pathPlanningApi.synchronousLineObject(pathPlanningList, PathPlanningTopicConstant.SEND_TASK_TO_PP);
}
}
/**
* 设置机器人编号及不能行走的区域
*
* @param robots
* @param positionMapDOS
*/
private List<TaskRobotNoLimittationAreaDTO> getRobotNoLimitationArea(List<RobotInformationDO> robots,
List<PositionMapDO> positionMapDOS,
String robotNo) {
List<TaskRobotNoLimittationAreaDTO> robotNoLimitationAreaDTOS = new ArrayList<>();
for (RobotInformationDO robot : robots) {
if (ObjectUtil.isNotEmpty(robotNo) && !robot.getRobotNo().equals(robotNo)) {
continue;
}
TaskRobotNoLimittationAreaDTO robotNoLimitationAreaDTO = new TaskRobotNoLimittationAreaDTO();
List<TaskLimitationAreaDTO> limitationAreaList = new ArrayList<>();
robotNoLimitationAreaDTO.setRobotNo(robot.getRobotNo());
for (PositionMapDO v : positionMapDOS) {
if (!robot.getFloorAreaJson().contains(v.getId())) {
TaskLimitationAreaDTO taskLimitationAreaDTO = new TaskLimitationAreaDTO(v.getFloor(), v.getArea());
limitationAreaList.add(taskLimitationAreaDTO);
}
}
robotNoLimitationAreaDTO.setLimitationAreaList(limitationAreaList);
robotNoLimitationAreaDTOS.add(robotNoLimitationAreaDTO);
}
return robotNoLimitationAreaDTOS;
}
/**
* 目前一个点位/线库 只能派一辆车去做
*
* @param taskDetailDOS
* @return
*/
private List<RobotTaskDetailDO> getSingleTask(List<RobotTaskDetailDO> taskDetailDOS) {
//剔除目前正在做的线库和点位
if (!taskNeedSingle) {
return taskDetailDOS;
}
log.info("---------处理:一个点位/线库 只派一台车 开始-------------");
//不能分配任务的线库id
Set<Long> laneIds = new HashSet<>();
//不能分配任务的点位id
Set<Long> mapIds = new HashSet<>();
List<RobotTaskDetailDO> doingTaskDetails = robotTaskDetailMapper.selectList(new LambdaQueryWrapperX<RobotTaskDetailDO>()
.eq(RobotTaskDetailDO::getTaskStatus, RobotTaskDetailStatusEnum.DOING.getType()));
if (ObjectUtil.isNotEmpty(doingTaskDetails)) {
for (RobotTaskDetailDO detail : doingTaskDetails) {
if (RobotTaskTypeEnum.TAKE_RELEASE.getType().equals(detail.getTaskType())
|| RobotTaskTypeEnum.MOVE.getType().equals(detail.getTaskType())
|| RobotTaskTypeEnum.TAKE.getType().equals(detail.getTaskType())
|| RobotTaskTypeEnum.RELEASE.getType().equals(detail.getTaskType())) {
laneIds.add(detail.getFromLaneId());
laneIds.add(detail.getToLaneId());
mapIds.add(detail.getFromMapId());
mapIds.add(detail.getToMapId());
}
}
}
//过滤处理中的, 不能分配的任务;
List<RobotTaskDetailDO> detailDOS = taskDetailDOS.stream()
.filter(v -> !laneIds.contains(v.getFromLaneId())
&& !laneIds.contains(v.getToLaneId())
&& !RobotTaskTypeEnum.PARK.getType().equals(v.getTaskType()) //停车在充电的任务做
&& !RobotTaskTypeEnum.CHARGE.getType().equals(v.getTaskType()) //停车在充电的任务做
&& !mapIds.contains(v.getFromMapId())
&& !mapIds.contains(v.getToMapId()))
.collect(Collectors.toList());
if (ObjectUtil.isEmpty(detailDOS)) {
log.info("过滤处理中的任务对应的线库id和点位id后任务数据为空");
return detailDOS;
}
//取货线库
Map<Long, RobotTaskDetailDO> fromLaneMap = detailDOS.stream()
.filter(v -> ObjectUtil.isNotEmpty(v.getFromLaneId()))
.collect(Collectors.groupingBy(RobotTaskDetailDO::getFromLaneId,
Collectors.collectingAndThen(Collectors.minBy(Comparator.comparingLong(RobotTaskDetailDO::getFromLocationNumber)), Optional::get)));
//放货线库
Map<Long, RobotTaskDetailDO> toLaneMap = detailDOS.stream()
.filter(v -> ObjectUtil.isNotEmpty(v.getToLaneId()))
.collect(Collectors.groupingBy(RobotTaskDetailDO::getToLaneId,
Collectors.collectingAndThen(Collectors.maxBy(Comparator.comparingLong(RobotTaskDetailDO::getToLocationNumber)), Optional::get)));
//取货点位
Map<Long, RobotTaskDetailDO> fromLocationMap = detailDOS.stream()
.filter(v -> ObjectUtil.isEmpty(v.getFromLaneId()) && ObjectUtil.isNotEmpty(v.getFromMapId()))
.collect(Collectors.groupingBy(RobotTaskDetailDO::getFromMapId,
Collectors.collectingAndThen(Collectors.minBy(Comparator.comparingLong(RobotTaskDetailDO::getFromLocationNumber)), Optional::get)));
//放货点位
Map<Long, RobotTaskDetailDO> toLocationMap = detailDOS.stream()
.filter(v -> ObjectUtil.isEmpty(v.getToLaneId()) && ObjectUtil.isNotEmpty(v.getToMapId()))
.collect(Collectors.groupingBy(RobotTaskDetailDO::getToMapId,
Collectors.collectingAndThen(Collectors.maxBy(Comparator.comparingLong(RobotTaskDetailDO::getToLocationNumber)), Optional::get)));
//返回的数据
List<RobotTaskDetailDO> list = new ArrayList<>();
for (RobotTaskDetailDO v : detailDOS) {
RobotTaskDetailDO fromLane = ObjectUtil.isNotEmpty(v.getFromLaneId()) ? fromLaneMap.get(v.getFromLaneId()) : null;
RobotTaskDetailDO toLane = ObjectUtil.isNotEmpty(v.getToLaneId()) ? toLaneMap.get(v.getToLaneId()) : null;
RobotTaskDetailDO fromLocation = ObjectUtil.isNotEmpty(v.getFromMapId()) ? fromLocationMap.get(v.getFromMapId()) : null;
RobotTaskDetailDO toLocation = ObjectUtil.isNotEmpty(v.getToMapId()) ? toLocationMap.get(v.getToMapId()) : null;
//取放模式
if (RobotTaskTypeEnum.TAKE_RELEASE.getType().equals(v.getTaskType())) {
takeReleaseSetTask(list, v, fromLane, toLane, fromLocation, toLocation);
} else if (RobotTaskTypeEnum.MOVE.getType().equals(v.getTaskType())
|| RobotTaskTypeEnum.RELEASE.getType().equals(v.getTaskType())) {
//移动和仅放货
moveSetTask(list, v, fromLane, toLane, fromLocation, toLocation);
} else if (RobotTaskTypeEnum.TAKE.getType().equals(v.getTaskType())) {
//仅取货
takeSetTask(list, v, fromLane, toLane, fromLocation, toLocation);
}
}
log.info("---------处理:一个点位/线库 只派一台车 结束-------------");
return list;
}
/**
* 仅取货设置任务
*
* @param list
* @param v
* @param fromLane
* @param toLane
* @param fromLocation
* @param toLocation
*/
private void takeSetTask(List<RobotTaskDetailDO> list, RobotTaskDetailDO v, RobotTaskDetailDO fromLane,
RobotTaskDetailDO toLane, RobotTaskDetailDO fromLocation, RobotTaskDetailDO toLocation) {
if (!(ObjectUtil.isNotEmpty(fromLocation) && fromLocation.getFromLocationNumber().equals(v.getFromLocationNumber()))) {
log.info("下发任务给PP--仅取货--排序不符合 :{}", v.getId());
return;
}
//终点是线库
if (ObjectUtil.isNotEmpty(v.getFromLaneId()) && ObjectUtil.isNotEmpty(fromLane)
&& fromLane.getFromLocationNumber().equals(v.getFromLocationNumber())) {
list.add(v);
//终点是普通库位
} else if (ObjectUtil.isEmpty(v.getFromLaneId())) {
list.add(v);
}
}
/**
* 移动设置任务
*
* @param list
* @param v
*/
private void moveSetTask(List<RobotTaskDetailDO> list, RobotTaskDetailDO v, RobotTaskDetailDO fromLane,
RobotTaskDetailDO toLane,
RobotTaskDetailDO fromLocation, RobotTaskDetailDO toLocation) {
if (!(ObjectUtil.isNotEmpty(toLocation) && toLocation.getToLocationNumber().equals(v.getToLocationNumber()))) {
log.info("下发任务给PP--移动任务--排序不符合 :{}", v.getId());
return;
}
//终点是线库
if (ObjectUtil.isNotEmpty(v.getToLaneId()) && ObjectUtil.isNotEmpty(toLane)
&& toLane.getToLocationNumber().equals(v.getToLocationNumber())) {
list.add(v);
//终点是普通库位
} else if (ObjectUtil.isEmpty(v.getToLaneId())) {
list.add(v);
}
}
/**
* 取放设置任务
*
* @param list
* @param v
*/
private void takeReleaseSetTask(List<RobotTaskDetailDO> list, RobotTaskDetailDO v, RobotTaskDetailDO fromLane, RobotTaskDetailDO toLane,
RobotTaskDetailDO fromLocation, RobotTaskDetailDO toLocation) {
if (!(ObjectUtil.isNotEmpty(fromLocation) && fromLocation.getFromLocationNumber().equals(v.getFromLocationNumber())
&& ObjectUtil.isNotEmpty(toLocation) && toLocation.getToLocationNumber().equals(v.getToLocationNumber()))) {
log.info("下发任务给PP--取放任务--取/放的排序不符合 :{}", v.getId());
return;
}
//取放都是线库
if (ObjectUtil.isNotEmpty(v.getFromLaneId()) && ObjectUtil.isNotEmpty(v.getToLaneId())
&& ObjectUtil.isNotEmpty(fromLane)
&& fromLane.getFromLocationNumber().equals(v.getFromLocationNumber())
&& ObjectUtil.isNotEmpty(toLane)
&& toLane.getToLocationNumber().equals(v.getToLocationNumber())) {
list.add(v);
//取是线库放是点位
} else if (ObjectUtil.isNotEmpty(v.getFromLaneId()) && ObjectUtil.isEmpty(v.getToLaneId())
&& ObjectUtil.isNotEmpty(fromLane)
&& fromLane.getFromLocationNumber().equals(v.getFromLocationNumber())) {
list.add(v);
//取是点位放是线库
} else if (ObjectUtil.isEmpty(v.getFromLaneId()) && ObjectUtil.isNotEmpty(v.getToLaneId())
&& ObjectUtil.isNotEmpty(toLane)
&& toLane.getToLocationNumber().equals(v.getToLocationNumber())) {
list.add(v);
//取放都是点位
} else if (ObjectUtil.isEmpty(v.getFromLaneId()) && ObjectUtil.isEmpty(v.getToLaneId())) {
list.add(v);
}
}
public 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 ->
ObjectUtil.isNotEmpty(v.getMacAddress())
&& v.getFloorAreaJson().contains(fromLocation.getMapId())
&& v.getFloorAreaJson().contains(toLocation.getMapId()))
.findFirst()
.orElse(new RobotInformationDO());
macAddress = robotInformationDO.getMacAddress();
robotNo = robotInformationDO.getRobotNo();
}
Pair<String, String> pair = new ImmutablePair<>(macAddress, robotNo);
return pair;
}
/**
* 取放货
*
* @param taskDetailDO
* @param robots
* @param robotTaskDOS
*/
@Transactional(rollbackFor = Exception.class)
public void doTakeReleaseDistribute(RobotTaskDetailDO taskDetailDO, List<RobotInformationDO> robots,
List<RobotAcceptTaskDTO> robotTaskDOS, Set<Long> taskIdSet,
List<RobotTaskDetailDO> updateTaskDetail, Set<String> robotNos,
Set<Long> doingLocationIds, Map<Long, WareHouseLocationDO> locationMp,
List<TaskToPathPlanningDTO> taskToPathPlanningDTOS) {
WareHouseLocationDO fromLocation = locationMp.get(taskDetailDO.getFromLocationId());
WareHouseLocationDO toLocation = locationMp.get(taskDetailDO.getToLocationId());
TaskToPathPlanningDTO taskToPathPlanningDTO = new TaskToPathPlanningDTO();
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;
}
// 取货/放货 校验有没有其他库位挡住
Boolean fromCanMove = checkCanMove(fromLocation, doingLocationIds);
if (!fromCanMove) {
return;
}
Boolean toCanMove = checkCanMove(toLocation, doingLocationIds);
if (!toCanMove) {
return;
}
RobotAcceptTaskDTO robotTaskDO = new RobotAcceptTaskDTO();
robotTaskDO.setOrder_id(taskDetailDO.getId().toString());
robotTaskDO.setOrder_type("出库");//未定
robotTaskDO.setTopic(RobotTopicConstant.ROBOT_TASK_TOPIC + macAddress);
//1
RobotAcceptTaskData taskOne = new RobotAcceptTaskData();
taskOne.setSerial("1");
taskOne.setCommand_id(taskDetailDO.getId().toString());
taskOne.setCommand_type(CommandTypeEnum.MOVE_POSES.getType());
List<Pose2ds> pose2ds = new ArrayList<>();
Pose2ds pose2 = positionMapItemMapper.selectByLocationId(taskDetailDO.getFromLocationId());
pose2ds.add(pose2);
taskOne.setPose2ds(pose2ds);
//2
RobotAcceptTaskData taskTwo = new RobotAcceptTaskData();
taskTwo.setSerial("1");
taskTwo.setCommand_id(taskDetailDO.getId().toString());
taskTwo.setCommand_type(CommandTypeEnum.FORK.getType());
taskTwo.setTarget_height(initHeight);
//3
RobotAcceptTaskData taskThree = new RobotAcceptTaskData();
taskThree.setSerial("2");
taskThree.setCommand_id(taskDetailDO.getId().toString());
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.WAIT.getType());
taskFour.setParm(parm);
//5
RobotAcceptTaskData taskFive = new RobotAcceptTaskData();
taskFive.setSerial("4");
taskFive.setCommand_id(taskDetailDO.getId().toString());
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());
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_TO_PALLET_POSE.getType());
//8
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);
}
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);
data.add(taskTwo);
data.add(taskThree);
data.add(taskFour);
data.add(taskFive);
data.add(taskSix);
data.add(taskSeven);
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);
final String mac = macAddress;
robots.removeIf(v -> v.getMacAddress().equals(mac));
taskDetailDO.setRobotNo(robotNo);
taskDetailDO.setStartTime(LocalDateTime.now());
taskDetailDO.setTaskStatus(RobotTaskDetailStatusEnum.DOING.getType());
updateTaskDetail.add(taskDetailDO);
robotNos.add(robotNo);
taskIdSet.add(taskDetailDO.getRobotTaskId());
}
/**
* 校验当前库位能否取放
*
* @param fromLocation
* @return false : 有货不能移动 true: 没货 能移动
*/
private Boolean checkCanMove(WareHouseLocationDO fromLocation, Set<Long> locationIds) {
Long laneId = fromLocation.getLaneId();
if (ObjectUtil.isEmpty(laneId)) {
Set<Long> doingLocationIds = new HashSet<>();
doingLocationIds.add(fromLocation.getId());
List<WareHouseLocationDO> locationDOS = locationMapper.selectNeedMoveLocation(doingLocationIds);
locationDOS = locationDOS.stream()
.filter(v -> !locationIds.contains(v.getId()))
.collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(locationDOS)) {
// todo 后续记录到异常表
log.info("普通库位--库位上有其他货物, 库位号:{} ,无法进行移动 :{}", fromLocation.getLocationNo(), locationDOS);
return false;
}
} else {
List<WareHouseLocationDO> locations = new ArrayList<>();
WareHouseLocationDO location = WareHouseLocationDO.builder().locationNumber(fromLocation.getLocationNumber())
.locationUseStatus(LocationUseStatusEnum.YES.getType())
.laneId(fromLocation.getLaneId()).build();
locations.add(location);
List<WareHouseLocationDO> wareHouseLocationDOS = locationMapper.selectLocationByList(locations);
wareHouseLocationDOS = wareHouseLocationDOS.stream()
.filter(v -> !locationIds.contains(v.getId()))
.collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(wareHouseLocationDOS)) {
// todo 后续记录到异常表
log.info("线库-当前库位上有其他货物, 库位号:{},无法进行移动 :{}", fromLocation.getLocationNo(), wareHouseLocationDOS);
return false;
}
}
locationIds.add(fromLocation.getId());
return true;
}
}

View File

@ -231,5 +231,3 @@ zn:
cycle_do_auto_move: true #存在循环的任务,是否开启自动移库. true:存在循环任务,开启自动移库; false有循环任务不自动移库
full_electricity: 100 #机器人充满电的电量
robot_error_level_time: 30 #机器人异常存储时间(秒)
task_need_single: true #机器人对同一线库/点位是不是只能有一台机器人做任务 (true:一个点位/线库,只有一台机器人)
location_number_reduce: 100000000 #库位排序的差值(下发取货任务,将库位排序减去此值,然后取绝对值)

View File

@ -267,18 +267,6 @@
</set>
where id = #{id}
</update>
<update id="emptyAreaId">
update ware_position_map_item
set area_id = null
where position_map_id = #{mapId}
and area_id = #{areaId}
</update>
<update id="emptyLaneId">
update ware_position_map_item
set lane_id = null
where position_map_id = #{mapId}
and lane_id = #{laneId}
</update>
<!--通过主键删除-->
<delete id="deleteById">

View File

@ -15,10 +15,7 @@
<result property="fromLocationId" column="from_location_id" jdbcType="INTEGER"/>
<result property="fromLaneId" column="from_lane_id" jdbcType="INTEGER"/>
<result property="toLaneId" column="to_lane_id" jdbcType="INTEGER"/>
<result property="fromLocationNumber" column="from_location_number" jdbcType="INTEGER"/>
<result property="toLocationNumber" column="to_location_number" jdbcType="INTEGER"/>
<result property="fromMapId" column="from_map_id" jdbcType="INTEGER"/>
<result property="toMapId" column="to_map_id" jdbcType="INTEGER"/>
<result property="locationNumber" column="location_number" jdbcType="INTEGER"/>
<result property="toLocationNo" column="to_location_no" jdbcType="VARCHAR"/>
<result property="toLocationId" column="to_location_id" jdbcType="INTEGER"/>
<result property="fromLocationStorey" column="from_location_storey" jdbcType="INTEGER"/>
@ -50,6 +47,7 @@
from_location_id,
from_lane_id,
to_lane_id,
location_number
to_location_no,
to_location_id,
robot_no,
@ -66,13 +64,174 @@
tenant_id,
from_location_storey,
to_location_storey,
priority,
from_location_number,
to_location_number,
from_map_id,
to_map_id
priority
</sql>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="BaseResultMap">
select
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 robot_task_detail
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="robotTaskId != null">
and robot_task_id = #{robotTaskId}
</if>
<if test="taskType != null">
and task_type = #{taskType}
</if>
<if test="releaseType != null">
and release_type = #{releaseType}
</if>
<if test="takeType != null">
and take_type = #{takeType}
</if>
<if test="releaseId != null">
and release_id = #{releaseId}
</if>
<if test="takeId != null">
and take_id = #{takeId}
</if>
<if test="fromLocationNo != null and fromLocationNo != ''">
and from_location_no = #{fromLocationNo}
</if>
<if test="fromLocationId != null">
and from_location_id = #{fromLocationId}
</if>
<if test="toLocationNo != null and toLocationNo != ''">
and to_location_no = #{toLocationNo}
</if>
<if test="toLocationId != null">
and to_location_id = #{toLocationId}
</if>
<if test="robotNo != null and robotNo != ''">
and robot_no = #{robotNo}
</if>
<if test="robotAction != null and robotAction != ''">
and robot_action = #{robotAction}
</if>
<if test="taskStatus != null">
and task_status = #{taskStatus}
</if>
<if test="taskStage != null">
and task_stage = #{taskStage}
</if>
<if test="startTime != null">
and start_time = #{startTime}
</if>
<if test="endTime != null">
and end_time = #{endTime}
</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, 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 robot_task_detail
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from robot_task_detail
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="robotTaskId != null">
and robot_task_id = #{robotTaskId}
</if>
<if test="taskType != null">
and task_type = #{taskType}
</if>
<if test="releaseType != null">
and release_type = #{releaseType}
</if>
<if test="takeType != null">
and take_type = #{takeType}
</if>
<if test="releaseId != null">
and release_id = #{releaseId}
</if>
<if test="takeId != null">
and take_id = #{takeId}
</if>
<if test="fromLocationNo != null and fromLocationNo != ''">
and from_location_no = #{fromLocationNo}
</if>
<if test="fromLocationId != null">
and from_location_id = #{fromLocationId}
</if>
<if test="toLocationNo != null and toLocationNo != ''">
and to_location_no = #{toLocationNo}
</if>
<if test="toLocationId != null">
and to_location_id = #{toLocationId}
</if>
<if test="robotNo != null and robotNo != ''">
and robot_no = #{robotNo}
</if>
<if test="robotAction != null and robotAction != ''">
and robot_action = #{robotAction}
</if>
<if test="taskStatus != null">
and task_status = #{taskStatus}
</if>
<if test="taskStage != null">
and task_stage = #{taskStage}
</if>
<if test="startTime != null">
and start_time = #{startTime}
</if>
<if test="endTime != null">
and end_time = #{endTime}
</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="queryDoingTaskByIds" resultMap="BaseResultMap">
@ -180,6 +339,16 @@
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>
<select id="getChargeTaskDetail"
resultType="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO">
@ -197,20 +366,29 @@
and t2.task_type = '3'
</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,
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)
values (#{robotTaskId}, #{taskType}, #{releaseType}, #{takeType}, #{releaseId}, #{takeId}, #{fromLocationNo},
#{fromLocationId}, #{toLocationNo}, #{toLocationId}, #{robotNo}, #{robotAction}, #{taskStatus},
#{taskStage}, #{startTime}, #{endTime}, #{creator}, #{createTime}, #{updater}, #{updateTime},
#{deleted}, #{tenantId})
</insert>
<!--keyProperty="id" useGeneratedKeys="true"-->
<insert id="insertBatchList" >
insert into robot_task_detail(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,from_location_storey,
to_location_storey,priority,from_lane_id,to_lane_id,from_location_number,to_location_number,
from_map_id,to_map_id)
to_location_storey,priority,from_lane_id,to_lane_id,location_number)
values
<foreach collection="taskDetailList" item="entity" separator=",">
(#{entity.robotTaskId}, #{entity.taskType}, #{entity.releaseType}, #{entity.takeType}, #{entity.releaseId},
#{entity.takeId}, #{entity.fromLocationNo}, #{entity.fromLocationId}, #{entity.toLocationNo},
#{entity.toLocationId}, #{entity.robotNo}, #{entity.fromLocationStorey}, #{entity.toLocationStorey}
, #{entity.priority}, #{entity.fromLaneId}, #{entity.toLaneId}, #{entity.fromLocationNumber},
#{entity.toLocationNumber}, #{entity.fromMapId}, #{entity.toMapId})
, #{entity.priority}, #{entity.fromLaneId}, #{entity.toLaneId}, #{entity.locationNumber})
</foreach>
</insert>