Compare commits

...

4 Commits

Author SHA1 Message Date
cbs
59c24c1a7e 打印日志 2025-06-06 09:05:25 +08:00
cbs
2f9c8a38bc 维护车辆信息 2025-06-05 17:37:17 +08:00
cbs
4f6fd7d807 代码优化 2025-06-04 17:01:13 +08:00
cbs
fc8c96e5c2 设备使用状态 2025-06-04 08:55:11 +08:00
34 changed files with 271 additions and 57 deletions

View File

@ -1,6 +1,7 @@
package cn.iododer.yudao.module.mqtt.api.common; package cn.iododer.yudao.module.mqtt.api.common;
import cn.iocoder.yudao.module.mqtt.api.common.CommonApi; import cn.iocoder.yudao.module.mqtt.api.common.CommonApi;
import cn.iododer.yudao.module.mqtt.config.MqttFactory;
import cn.iododer.yudao.module.mqtt.util.MqttUtils; import cn.iododer.yudao.module.mqtt.util.MqttUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -23,9 +24,9 @@ public class CommonApiImpl implements CommonApi {
String str = JSON.toJSONString(obj); String str = JSON.toJSONString(obj);
mqttUtils.pub(topic, JSON.toJSONString(obj)); mqttUtils.pub(topic, JSON.toJSONString(obj));
if (str.length() > 510) { if (str.length() > 510) {
// log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str.substring(0, 500)); log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str.substring(0, 500));
}else { }else {
// log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str); log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str);
} }
} catch (MqttException e) { } catch (MqttException e) {
log.info("MQTT消息发送异常 :{}",e); log.info("MQTT消息发送异常 :{}",e);
@ -37,9 +38,9 @@ public class CommonApiImpl implements CommonApi {
try { try {
mqttUtils.pub(topic, str); mqttUtils.pub(topic, str);
if (str.length() > 510) { if (str.length() > 510) {
// log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str.substring(0, 500)); log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str.substring(0, 500));
}else { }else {
// log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str); log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str);
} }
} catch (MqttException e) { } catch (MqttException e) {
log.info("MQTT消息发送异常 :{}",e); log.info("MQTT消息发送异常 :{}",e);

View File

@ -35,6 +35,7 @@ management:
mqtt: mqtt:
# host: tcp://123.57.12.40:1883 # host: tcp://123.57.12.40:1883
host: tcp://127.0.0.1:1883 host: tcp://127.0.0.1:1883
# host: tcp://10.10.7.195:1883
username: adminuser username: adminuser
password: adminuser password: adminuser
qos: 2 qos: 2

View File

@ -19,4 +19,9 @@ public class RobotSkuInfoDTO {
* 物料数量 * 物料数量
*/ */
private Long skuNumber; private Long skuNumber;
/**
* 层数
*/
private Integer locationStorey;
} }

View File

@ -236,11 +236,11 @@ public interface ErrorCodeConstants {
ErrorCode PATH_PLANNING_DOING_DISTRIBUTE = new ErrorCode(1-002-037-002, "有正在分配的PP任务!"); ErrorCode PATH_PLANNING_DOING_DISTRIBUTE = new ErrorCode(1-002-037-002, "有正在分配的PP任务!");
// ========== 地图信息 1-002-038-000 ========== // ========== 地图信息 1-002-038-000 ==========
ErrorCode AGV_UPLOAD_INFORMATION_DOES_NOT_INCLUDE_FLOOR_OR_AREA_INFORMATION = new ErrorCode(1_002_038_001, "AGV上传信息未包含楼层或区域信息"); ErrorCode AGV_UPLOAD_INFORMATION_DOES_NOT_INCLUDE_FLOOR_OR_AREA_INFORMATION = new ErrorCode(1_002_038_001, "车辆上传信息未包含楼层或区域信息");
ErrorCode AGV_FILE_UPLOAD_CONTENT_IS_EMPTY = new ErrorCode(1_002_038_002, "AGV文件上传内容为空"); ErrorCode AGV_FILE_UPLOAD_CONTENT_IS_EMPTY = new ErrorCode(1_002_038_002, "车辆文件上传内容为空");
ErrorCode PLEASE_UPLOAD_PNG_AND_YAML_FILES = new ErrorCode(1_002_038_003, "请上传png和yaml两个文件并且文件内容不为空"); ErrorCode PLEASE_UPLOAD_PNG_AND_YAML_FILES = new ErrorCode(1_002_038_003, "请上传png和yaml两个文件并且文件内容不为空");
ErrorCode AGV_MAP_NOT_FOUND = new ErrorCode(1_002_038_004, "找不到AGV地图信息"); ErrorCode AGV_MAP_NOT_FOUND = new ErrorCode(1_002_038_004, "找不到车辆地图信息");
ErrorCode AGV_IMAGE_CONVERSION_TO_BASE64_FAILED = new ErrorCode(1_002_038_005, "AGV图片转base64失败"); ErrorCode AGV_IMAGE_CONVERSION_TO_BASE64_FAILED = new ErrorCode(1_002_038_005, "车辆图片转base64失败");
ErrorCode THE_LINE_LIBRARY_POINTS_ARE_NOT_LOCATED_IN_THE_SAME_AREA = new ErrorCode(1_002_038_006, "线库点位不在同一区域内"); ErrorCode THE_LINE_LIBRARY_POINTS_ARE_NOT_LOCATED_IN_THE_SAME_AREA = new ErrorCode(1_002_038_006, "线库点位不在同一区域内");
ErrorCode THERE_ARE_ALREADY_STORAGE_LOCATIONS_IN_OTHER_LINE_WAREHOUSES = new ErrorCode(1_002_038_007, "已有库位在其他线库内"); ErrorCode THERE_ARE_ALREADY_STORAGE_LOCATIONS_IN_OTHER_LINE_WAREHOUSES = new ErrorCode(1_002_038_007, "已有库位在其他线库内");
ErrorCode THERE_ARE_ALREADY_STORAGE_LOCATIONS_IN_OTHER_STORAGE_AREAS = new ErrorCode(1_002_038_008, "已有库位在其它区域内"); ErrorCode THERE_ARE_ALREADY_STORAGE_LOCATIONS_IN_OTHER_STORAGE_AREAS = new ErrorCode(1_002_038_008, "已有库位在其它区域内");

View File

@ -88,7 +88,6 @@ public class PathApiImpl implements PathApi {
} finally { } finally {
MDC.clear(); MDC.clear();
} }
// taskService.ppDistributionTask(message); 废弃了
}); });
} }

View File

@ -49,9 +49,6 @@ public class RobotStatusApiImpl implements RobotStatusApi {
private static final ExecutorService executorService = Executors.newFixedThreadPool(5); private static final ExecutorService executorService = Executors.newFixedThreadPool(5);
/*@Autowired
private ThreadPoolTaskExecutor taskExecutor;
*/
@Resource @Resource
private CommonApi commonApi; private CommonApi commonApi;

View File

@ -338,6 +338,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
robotSkuInfo.setHaveSku(ZeroOneEnum.ONE.getType()); robotSkuInfo.setHaveSku(ZeroOneEnum.ONE.getType());
robotSkuInfo.setSkuNumber(wareHouseLocationDO.getSkuNumber()); robotSkuInfo.setSkuNumber(wareHouseLocationDO.getSkuNumber());
robotSkuInfo.setSkuInfo(wareHouseLocationDO.getSkuInfo()); robotSkuInfo.setSkuInfo(wareHouseLocationDO.getSkuInfo());
robotSkuInfo.setLocationStorey(wareHouseLocationDO.getLocationStorey());
redisUtil.set(RobotTaskChcheConstant.ROBOT_TASK_SKU_INFO + robotCompleteTaskDTO.getMac(), JSON.toJSONString(robotSkuInfo)); redisUtil.set(RobotTaskChcheConstant.ROBOT_TASK_SKU_INFO + robotCompleteTaskDTO.getMac(), JSON.toJSONString(robotSkuInfo));
wareHouseLocationDO.setSkuInfo(null); wareHouseLocationDO.setSkuInfo(null);
wareHouseLocationDO.setSkuNumber(0L); wareHouseLocationDO.setSkuNumber(0L);

View File

@ -47,7 +47,7 @@ public class RequestProcessor {
private void sendData(String map, Map<String, String> data) { private void sendData(String map, Map<String, String> data) {
// -- 发送给对应的websocket // -- 发送给对应的websocket
// System.out.println("key:" + map + "发送数据:" + data); // System.out.println("key:" + map + "发送数据:" + data);
// log.info("key:" + map + "发送数据:" + data); log.info("key:" + map + "发送数据:" + data);
webSocketSenderApi.sendObject(map, WebSocketConstant.MAP_PUSH, data); webSocketSenderApi.sendObject(map, WebSocketConstant.MAP_PUSH, data);
} }

View File

@ -74,8 +74,8 @@ public class DeviceInformationPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
@Schema(description = "设备使用状态(IDLE:空闲、USEING:使用中)") @Schema(description = "设备使用状态(0:空闲、1:使用中)")
private String deviceUseStatus; private Integer deviceUseStatus;
@Schema(description = "设备专有属性1自动充电类型充电桩、2手动充电类型充电桩") @Schema(description = "设备专有属性1自动充电类型充电桩、2手动充电类型充电桩")
private Integer deviceAttribute; private Integer deviceAttribute;

View File

@ -91,9 +91,9 @@ public class DeviceInformationRespVO {
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "设备使用状态(IDLE:空闲、USEING:使用中)") @Schema(description = "设备使用状态(0:空闲、1:使用中)")
@ExcelProperty("设备使用状态(IDLE:空闲、USEING:使用中)") @ExcelProperty("设备使用状态(0:空闲、1:使用中)")
private String deviceUseStatus; private Integer deviceUseStatus;
@Schema(description = "设备专有属性1自动充电类型充电桩、2手动充电类型充电桩") @Schema(description = "设备专有属性1自动充电类型充电桩、2手动充电类型充电桩")
@ExcelProperty("设备专有属性1自动充电类型充电桩、2手动充电类型充电桩") @ExcelProperty("设备专有属性1自动充电类型充电桩、2手动充电类型充电桩")

View File

@ -72,8 +72,8 @@ public class DeviceInformationSaveReqVO {
@Schema(description = "设备最后通讯时间") @Schema(description = "设备最后通讯时间")
private LocalDateTime deviceLastTime; private LocalDateTime deviceLastTime;
@Schema(description = "设备使用状态(IDLE:空闲、USEING:使用中)") @Schema(description = "设备使用状态(0:空闲、1:使用中)")
private String deviceUseStatus; private Integer deviceUseStatus;
@Schema(description = "设备专有属性1自动充电类型充电桩、2手动充电类型充电桩") @Schema(description = "设备专有属性1自动充电类型充电桩、2手动充电类型充电桩")
private Integer deviceAttribute; private Integer deviceAttribute;

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.tool;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationSaveReqVO; import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotInformationSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.tool.dto.SendMsgToMqttDTO;
import cn.iocoder.yudao.module.system.service.tool.ToolsService; import cn.iocoder.yudao.module.system.service.tool.ToolsService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -55,4 +56,12 @@ public class ToolsController {
toolsService.simulationPose(); toolsService.simulationPose();
return success("同步完成"); return success("同步完成");
} }
@PostMapping("/sendMsgToMQTT")
@Operation(summary = "发送消息给MQTT")
@PermitAll
public CommonResult<String> sendMsgToMQTT( @RequestBody SendMsgToMqttDTO dto) {
toolsService.sendMsgToMQTT(dto);
return success("发送完成");
}
} }

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.system.controller.admin.tool.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class SendMsgToMqttDTO {
@Schema(description = "消息")
private String msg;
@Schema(description = "主题topic")
private String topic;
}

View File

@ -112,9 +112,9 @@ public class DeviceInformationDO extends BaseDO {
*/ */
private LocalDateTime deviceLastTime; private LocalDateTime deviceLastTime;
/** /**
* 设备使用状态IDLE:空闲USEING:使用中 * 设备使用状态0:空闲1:使用中
*/ */
private String deviceUseStatus; private Integer deviceUseStatus;
/** /**
* 设备专有属性1自动充电类型充电桩2手动充电类型充电桩 * 设备专有属性1自动充电类型充电桩2手动充电类型充电桩
*/ */

View File

@ -39,7 +39,7 @@ public interface DeviceInformationMapper extends BaseMapperX<DeviceInformationDO
* @param lastUser * @param lastUser
*/ */
void updateDeviceUseStatus(@Param("deviceNo") String deviceNo, void updateDeviceUseStatus(@Param("deviceNo") String deviceNo,
@Param("deviceUseStatus") String deviceUseStatus, @Param("deviceUseStatus") Integer deviceUseStatus,
@Param("lastUser") String lastUser); @Param("lastUser") String lastUser);
/** /**
@ -47,11 +47,24 @@ public interface DeviceInformationMapper extends BaseMapperX<DeviceInformationDO
* @param lastUser * @param lastUser
*/ */
void setDeviceReleaseByLastUser(@Param("lastUser") String lastUser, void setDeviceReleaseByLastUser(@Param("lastUser") String lastUser,
@Param("deviceUseStatus") String deviceUseStatus); @Param("deviceUseStatus") Integer deviceUseStatus);
/** /**
* 根据地图id删除 * 根据地图id删除
* @param mapId * @param mapId
*/ */
void deleteDeviceByMapId(@Param("mapId") Long mapId); void deleteDeviceByMapId(@Param("mapId") Long mapId);
/**
* 更新车辆编号
* @param oldRobotNo
* @param newRobotNo
*/
void updateRobotNo(@Param("oldRobotNo") String oldRobotNo, @Param("newRobotNo") String newRobotNo);
/**
* 清除车辆编号
* @param robotNo
*/
void clearRobotNo(@Param("robotNo") String robotNo);
} }

View File

@ -74,4 +74,17 @@ public interface PositionMapItemMapper extends BaseMapperX<PositionMapItemDO> {
* @param mapId * @param mapId
*/ */
void deleteByMapId(@Param("mapId") Long mapId); void deleteByMapId(@Param("mapId") Long mapId);
/**
* 更新车辆编号
* @param oldRobotNo
* @param newRobotNo
*/
void updateRobotNo(@Param("oldRobotNo") String oldRobotNo, @Param("newRobotNo") String newRobotNo);
/**
* 释放车辆
* @param robotNo
*/
void clearRobotNo(@Param("robotNo") String robotNo);
} }

View File

@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.remote.vo.RemoteControllerInformationPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.remote.vo.RemoteControllerInformationPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.remote.RemoteControllerInformationDO; import cn.iocoder.yudao.module.system.dal.dataobject.remote.RemoteControllerInformationDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* 远遥设备信息 Mapper * 远遥设备信息 Mapper
@ -33,4 +34,12 @@ public interface RemoteControllerInformationMapper extends BaseMapperX<RemoteCon
* @return * @return
*/ */
List<String> getRemoteControllerRobotNos(); List<String> getRemoteControllerRobotNos();
/**
* 更新车辆编号
* @param oldRobotNo
* @param newRobotNo
*/
void updateRobotNo(@Param("oldRobotNo") String oldRobotNo, @Param("newRobotNo") String newRobotNo);
} }

View File

@ -38,4 +38,11 @@ public interface RobotMapStopMapper extends BaseMapperX<RobotMapStopDO> {
* @param robotNos * @param robotNos
*/ */
void deleteRobotMapStopByRobotNos(@Param("robotNos") List<String> robotNos); void deleteRobotMapStopByRobotNos(@Param("robotNos") List<String> robotNos);
/**
* 更新车辆编号
* @param oldRobotNo
* @param newRobotNo
*/
void updateRobotNo(@Param("oldRobotNo") String oldRobotNo, @Param("newRobotNo") String newRobotNo);
} }

View File

@ -9,6 +9,8 @@ import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.wait.vo.*; import cn.iocoder.yudao.module.system.controller.admin.wait.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.wait.MoveToWaitDO; import cn.iocoder.yudao.module.system.dal.dataobject.wait.MoveToWaitDO;
import org.apache.ibatis.annotations.Param;
/** /**
* 车辆前往等待点记录 Mapper * 车辆前往等待点记录 Mapper
* *
@ -26,4 +28,10 @@ public interface MoveToWaitMapper extends BaseMapperX<MoveToWaitDO> {
.orderByDesc(MoveToWaitDO::getId)); .orderByDesc(MoveToWaitDO::getId));
} }
/**
* 更新车辆编号
* @param oldRobotNo
* @param newRobotNo
*/
void updateRobotNo(@Param("oldRobotNo") String oldRobotNo, @Param("newRobotNo") String newRobotNo);
} }

View File

@ -9,13 +9,13 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum DeviceUseStatusEnum { public enum DeviceUseStatusEnum {
IDLE("IDLE", "空闲"), IDLE(0, "空闲"),
USEING("USEING", "使用中"); USEING(1, "使用中");
/** /**
* 类型 * 类型
*/ */
private final String type; private final Integer type;
/** /**
* 说明 * 说明
*/ */

View File

@ -59,6 +59,7 @@ import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -166,7 +167,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
*/ */
@Override @Override
public void synchronousAllItem(PositionMapSaveReqVO data) { public void synchronousAllItem(PositionMapSaveReqVO data) {
log.info("synchronousAllItem----start"); log.info("开始同步点位信息");
List<PositionMapDO> positionMapDOS = positionMapMapper.selectList(new LambdaQueryWrapperX<PositionMapDO>() List<PositionMapDO> positionMapDOS = positionMapMapper.selectList(new LambdaQueryWrapperX<PositionMapDO>()
.eq(ObjectUtil.isNotEmpty(data.getFloor()), PositionMapDO::getFloor, data.getFloor()) .eq(ObjectUtil.isNotEmpty(data.getFloor()), PositionMapDO::getFloor, data.getFloor())
.eq(ObjectUtil.isNotEmpty(data.getArea()), PositionMapDO::getArea, data.getArea())); .eq(ObjectUtil.isNotEmpty(data.getArea()), PositionMapDO::getArea, data.getArea()));
@ -186,11 +187,10 @@ public class PathPlanningServiceImpl implements PathPlanningService {
relatedPathNode.setType(PathTypeEnum.INIT.getType()); relatedPathNode.setType(PathTypeEnum.INIT.getType());
relatedPathNode.setControl_nodes(positionMapItemSynDTOS); relatedPathNode.setControl_nodes(positionMapItemSynDTOS);
log.info("synchronousAllItem----doing :{}",JSON.toJSONString(relatedPathNode));
commonApi.commonMethod(relatedPathNode, PathPlanningTopicConstant.SYNCHRONOUS_ALL_MAP_NODE); commonApi.commonMethod(relatedPathNode, PathPlanningTopicConstant.SYNCHRONOUS_ALL_MAP_NODE);
} }
log.info("synchronousAllItem----end"); log.info("同步点位信息结束");
} }
/** /**
@ -499,6 +499,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
*/ */
@Override @Override
public void pathPlanningMovePose(String message) { public void pathPlanningMovePose(String message) {
log.info("车辆即将行走的点位 :{}",message);
PathPlanningMovePoseVO robotStatusData = JSON.parseObject(message, PathPlanningMovePoseVO.class); PathPlanningMovePoseVO robotStatusData = JSON.parseObject(message, PathPlanningMovePoseVO.class);
String mac = robotInformationService.getMacByRobotNo(robotStatusData.getRobotNo()); String mac = robotInformationService.getMacByRobotNo(robotStatusData.getRobotNo());
String floorAreaKey = RobotTaskChcheConstant.ROBOT_FLOOR_AREA + mac; String floorAreaKey = RobotTaskChcheConstant.ROBOT_FLOOR_AREA + mac;
@ -546,13 +547,14 @@ public class PathPlanningServiceImpl implements PathPlanningService {
return; return;
} }
List<PositionMapItemDO> itemDOList = new ArrayList<>(); List<PositionMapItemDO> itemDOList = new LinkedList<>();
List<PositionMapItemDO> items = positionMapItemService.getPositionMapItemByMapAndType(positionMap.getId(), PositionMapItemEnum.STOP.getType()); List<PositionMapItemDO> items = positionMapItemService.getPositionMapItemByMapAndType(positionMap.getId(), PositionMapItemEnum.STOP.getType());
if (ObjectUtil.isEmpty(items) || items.size() < robots.size()) { if (ObjectUtil.isNotEmpty(items)) {
itemDOList.addAll(items);
}
if ( itemDOList.size() < robots.size()) {
List<PositionMapItemDO> itemPoses = positionMapItemService.getPositionMapItemByMapAndType(positionMap.getId(), PositionMapItemEnum.PATH.getType()); List<PositionMapItemDO> itemPoses = positionMapItemService.getPositionMapItemByMapAndType(positionMap.getId(), PositionMapItemEnum.PATH.getType());
itemDOList.addAll(itemPoses); itemDOList.addAll(itemPoses);
} else {
itemDOList = items;
} }
List<SimulationRobotPoseDTO> simulationList = new ArrayList<>(); List<SimulationRobotPoseDTO> simulationList = new ArrayList<>();

View File

@ -174,7 +174,8 @@ public class PositionMapItemServiceImpl extends ServiceImpl<PositionMapItemMappe
public List<PositionMapItemDO> getPositionMapItemByMapAndType(Long mapId, Integer type) { public List<PositionMapItemDO> getPositionMapItemByMapAndType(Long mapId, Integer type) {
return positionMapItemMapper.selectList(new LambdaQueryWrapperX<PositionMapItemDO>() return positionMapItemMapper.selectList(new LambdaQueryWrapperX<PositionMapItemDO>()
.eq(PositionMapItemDO::getPositionMapId, mapId) .eq(PositionMapItemDO::getPositionMapId, mapId)
.eq(PositionMapItemDO::getType, type)); .eq(PositionMapItemDO::getType, type)
.orderByDesc(PositionMapItemDO::getId));
} }
/** /**

View File

@ -587,7 +587,6 @@ public class RemoteControllerInformationServiceImpl extends ServiceImpl<RemoteCo
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public RemoteRobotTransferDTO doRobotChangeMode(Integer remoteMode, String remoteIp, String robotNo,int remoteControllerPort,String remoteControllerIp) { public RemoteRobotTransferDTO doRobotChangeMode(Integer remoteMode, String remoteIp, String robotNo,int remoteControllerPort,String remoteControllerIp) {
log.info("切换模式的车辆 :{}", robotNo);
//后续判断下如果协控中能不能切换模式 //后续判断下如果协控中能不能切换模式

View File

@ -50,6 +50,8 @@ import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapItemMappe
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapMapper; import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapMapper;
import cn.iocoder.yudao.module.system.dal.mysql.remote.RemoteControllerInformationMapper; import cn.iocoder.yudao.module.system.dal.mysql.remote.RemoteControllerInformationMapper;
import cn.iocoder.yudao.module.system.dal.mysql.robot.*; import cn.iocoder.yudao.module.system.dal.mysql.robot.*;
import cn.iocoder.yudao.module.system.dal.mysql.statistics.RobotWorkingHoursStatisticsMapper;
import cn.iocoder.yudao.module.system.dal.mysql.wait.MoveToWaitMapper;
import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum; import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum;
import cn.iocoder.yudao.module.system.enums.device.DeviceTypeEnum; import cn.iocoder.yudao.module.system.enums.device.DeviceTypeEnum;
import cn.iocoder.yudao.module.system.enums.device.DeviceUseStatusEnum; import cn.iocoder.yudao.module.system.enums.device.DeviceUseStatusEnum;
@ -172,6 +174,14 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
@Resource @Resource
private RobotCameraService cameraService; private RobotCameraService cameraService;
@Resource
private RobotChargeLogMapper chargeLogMapper;
@Resource
private RobotWorkingHoursStatisticsMapper robotWorkingHoursStatisticsMapper;
@Resource
private MoveToWaitMapper moveToWaitMapper;
@Resource @Resource
private RemoteControllerInformationMapper controllerInformationMapper; private RemoteControllerInformationMapper controllerInformationMapper;
@ -414,16 +424,12 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
checkIpAndPort(updateObj); checkIpAndPort(updateObj);
if (!updateReqVO.getRobotNo().equals(robotInformationDO.getRobotNo())) {
updateRobotNo(robotInformationDO.getRobotNo(),updateReqVO.getRobotNo());
}
informationMapper.updateById(updateObj); informationMapper.updateById(updateObj);
if (!robotInformationDO.getRobotNo().equals(updateReqVO.getRobotNo())) {
List<RobotMapStopDO> robotMapStops = mapStopMapper.selectList(new LambdaQueryWrapperX<RobotMapStopDO>()
.eq(RobotMapStopDO::getRobotNo, robotInformationDO.getRobotNo()));
if (ObjectUtil.isNotEmpty(robotMapStops)) {
robotMapStops.forEach(v -> v.setRobotNo(updateReqVO.getRobotNo()));
mapStopMapper.updateById(robotMapStops);
}
}
// 更新AGV于地图关系表 ----- // 更新AGV于地图关系表 -----
List<List<Long>> list = CollectionUtils.compareLists( List<List<Long>> list = CollectionUtils.compareLists(
@ -475,6 +481,36 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
commonApi.commonMethod(RobotDimensions, PathPlanningTopicConstant.SEND_ROBOT_DIMENSIONS); commonApi.commonMethod(RobotDimensions, PathPlanningTopicConstant.SEND_ROBOT_DIMENSIONS);
} }
/**
* 跟新车辆编号
* @param oldRobotNo
* @param newRobotNo
*/
@Transactional(rollbackFor = Exception.class)
public void updateRobotNo(String oldRobotNo, String newRobotNo) {
deviceInformationMapper.updateRobotNo(oldRobotNo,newRobotNo);
controllerInformationMapper.updateRobotNo(oldRobotNo,newRobotNo);
RobotChargeLogDO robotChargeLog = chargeLogMapper.selectOne(new LambdaQueryWrapperX<RobotChargeLogDO>()
.eq(RobotChargeLogDO::getRobotNo, oldRobotNo)
.orderByDesc(RobotChargeLogDO::getCreateTime)
.last("limit 1"));
if (ObjectUtil.isNotEmpty(robotChargeLog)) {
robotChargeLog.setRobotNo(newRobotNo);
chargeLogMapper.updateById(robotChargeLog);
}
//这表暂时不改
// robotWorkingHoursStatisticsMapper
mapStopMapper.updateRobotNo(oldRobotNo,newRobotNo);
moveToWaitMapper.updateRobotNo(oldRobotNo,newRobotNo);
positionMapItemMapper.updateRobotNo(oldRobotNo,newRobotNo);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteInformation(Long id) { public void deleteInformation(Long id) {
@ -482,6 +518,13 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
validateInformationExists(id); validateInformationExists(id);
RobotInformationDO robotInformationDO = informationMapper.selectById(id); RobotInformationDO robotInformationDO = informationMapper.selectById(id);
RemoteControllerInformationDO remoteControllerInformation = controllerInformationMapper.selectOne(new LambdaQueryWrapper<RemoteControllerInformationDO>()
.eq(RemoteControllerInformationDO::getRobotNo, robotInformationDO.getRobotNo())
.last("limit 1"));
if (ObjectUtil.isNotEmpty(remoteControllerInformation)) {
throw exception(ROBOT_DOING_REMOTE);
}
cameraService.deleteCameraByRobotNo(robotInformationDO.getRobotNo()); cameraService.deleteCameraByRobotNo(robotInformationDO.getRobotNo());
List<RobotTaskDO> list = taskMapper.selectDoingTaskByRobotNo(robotInformationDO.getRobotNo()); List<RobotTaskDO> list = taskMapper.selectDoingTaskByRobotNo(robotInformationDO.getRobotNo());
@ -506,6 +549,9 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
List<RobotDimensionsDTO> RobotDimensions = informationMapper.selectRobotDimensions(); List<RobotDimensionsDTO> RobotDimensions = informationMapper.selectRobotDimensions();
commonApi.commonMethod(RobotDimensions, PathPlanningTopicConstant.SEND_ROBOT_DIMENSIONS); commonApi.commonMethod(RobotDimensions, PathPlanningTopicConstant.SEND_ROBOT_DIMENSIONS);
String pose2dKey = RobotTaskChcheConstant.ROBOT_INFORMATION_POSE_BAT + robotInformationDO.getMacAddress();
redisUtil.del(pose2dKey);
redisUtil.del(key); redisUtil.del(key);
//地图相关 //地图相关
String floorAreaKey = RobotTaskChcheConstant.ROBOT_FLOOR_AREA + robotInformationDO.getMacAddress(); String floorAreaKey = RobotTaskChcheConstant.ROBOT_FLOOR_AREA + robotInformationDO.getMacAddress();
@ -516,6 +562,13 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
redisUtil.hdel(oldFloorArea, robotInformationDO.getRobotNo()); redisUtil.hdel(oldFloorArea, robotInformationDO.getRobotNo());
redisUtil.del(floorAreaKey); redisUtil.del(floorAreaKey);
} }
deleteRobot(robotInformationDO.getRobotNo());
}
private void deleteRobot(String robotNo) {
deviceInformationMapper.clearRobotNo(robotNo);
positionMapItemMapper.clearRobotNo(robotNo);
} }
public void releaseRobotStop(RobotInformationDO robotInformationDO) { public void releaseRobotStop(RobotInformationDO robotInformationDO) {

View File

@ -48,6 +48,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -207,7 +208,7 @@ public class RobotTaskDetailServiceImpl implements RobotTaskDetailService {
informationService.setRobotFree(robotTaskDetailDO.getRobotNo()); informationService.setRobotFree(robotTaskDetailDO.getRobotNo());
actionLog.setActionStatus(ActionStatusEnum.DONE.getType()); actionLog.setActionStatus(ActionStatusEnum.DONE.getType());
taskDetailActionLogService.updateTaskDetailActionLogs(Arrays.asList(actionLog)); taskDetailActionLogService.updateTaskDetailActionLogs(Collections.singletonList(actionLog));
taskDetailActionLogService.setPreviousTaskDoneByOrderId(taskDetailId); taskDetailActionLogService.setPreviousTaskDoneByOrderId(taskDetailId);
if (RobotTaskStageEnum.DONE.getType().equals(taskStage) if (RobotTaskStageEnum.DONE.getType().equals(taskStage)

View File

@ -111,7 +111,7 @@ public class AutoChargeServiceImpl implements AutoChargeService {
List<DeviceInformationDO> deviceInformationDOS = deviceInformationMapper.selectList(new LambdaQueryWrapperX<DeviceInformationDO>() List<DeviceInformationDO> deviceInformationDOS = deviceInformationMapper.selectList(new LambdaQueryWrapperX<DeviceInformationDO>()
.eq(DeviceInformationDO::getDeviceEnable, ZeroOneEnum.ONE.getType()) .eq(DeviceInformationDO::getDeviceEnable, ZeroOneEnum.ONE.getType())
.eq(DeviceInformationDO::getDeviceUseStatus, DeviceUseStatusEnum.IDLE.getType()) .eq(DeviceInformationDO::getDeviceUseStatus, ZeroOneEnum.ZERO.getType())
.eq(DeviceInformationDO::getDeviceType, DeviceTypeEnum.CHARGING_STATION.getType())); .eq(DeviceInformationDO::getDeviceType, DeviceTypeEnum.CHARGING_STATION.getType()));
if (ObjectUtil.isEmpty(deviceInformationDOS)) { if (ObjectUtil.isEmpty(deviceInformationDOS)) {
@ -131,7 +131,7 @@ public class AutoChargeServiceImpl implements AutoChargeService {
} }
List<RobotInformationDO> moveToWaitRobots = getCanLeaveChargingRobots(chargeIngRobots, chargeConfig, robots.size()); List<RobotInformationDO> moveToWaitRobots = getCanLeaveChargingRobots(chargeIngRobots, chargeConfig, robots.size());
if (ObjectUtil.isEmpty(moveToWaitRobots)) { if (ObjectUtil.isEmpty(moveToWaitRobots)) {
log.info("充电中的车辆未充满电"); log.info("充电中的车辆未达到离开的阀值");
return; return;
} }
robotPathPlanningService.moveRobotToWait(moveToWaitRobots); robotPathPlanningService.moveRobotToWait(moveToWaitRobots);
@ -213,6 +213,7 @@ public class AutoChargeServiceImpl implements AutoChargeService {
Boolean adequateBatteryCapacity = remainingElectricityBigger(chargeConfig, robot); Boolean adequateBatteryCapacity = remainingElectricityBigger(chargeConfig, robot);
if (adequateBatteryCapacity) { if (adequateBatteryCapacity) {
robot.setRobotStatus(RobotStatusEnum.STAND_BY.getType());
String socKey = RobotTaskChcheConstant.ROBOT_INFORMATION_SOC + robot.getMacAddress(); String socKey = RobotTaskChcheConstant.ROBOT_INFORMATION_SOC + robot.getMacAddress();
Object o = redisUtil.get(socKey); Object o = redisUtil.get(socKey);
Integer soc = ObjectUtil.isEmpty(o) ? 0 : Integer.parseInt(o.toString()); Integer soc = ObjectUtil.isEmpty(o) ? 0 : Integer.parseInt(o.toString());

View File

@ -119,7 +119,6 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
public void sendTaskToPP() { public void sendTaskToPP() {
TenantContextHolder.setTenantId(1L); TenantContextHolder.setTenantId(1L);
log.info("-------循环任务开始查找车子和任务------");
Pair<List<RobotInformationDO>, List<RobotTaskDetailDO>> robotAndTaskDetails = Pair<List<RobotInformationDO>, List<RobotTaskDetailDO>> robotAndTaskDetails =
distributeTasksService.getRobotAndTaskDetails(); distributeTasksService.getRobotAndTaskDetails();
@ -218,19 +217,20 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
List<PositionMapItemDO> robotMapItems = new ArrayList<>(); List<PositionMapItemDO> robotMapItems = new ArrayList<>();
if (ObjectUtil.isNotEmpty(existMapItems)) { if (ObjectUtil.isNotEmpty(existMapItems)) {
for (PositionMapItemDO positionMapItem : positionMapItems) { for (PositionMapItemDO positionMapItem : existMapItems) {
robotNos.removeIf(v -> v.equals(positionMapItem.getRobotNo())); if (ObjectUtil.isEmpty(robots)) {
if (UseStatusEnum.USEING.getType().equals(positionMapItem.getUseStatus())) { break;
continue;
} }
robotNos.removeIf(v -> v.equals(positionMapItem.getRobotNo()));
positionMapItem.setUseStatus(UseStatusEnum.PRE_OCCUPANCY.getType()); positionMapItem.setUseStatus(UseStatusEnum.PRE_OCCUPANCY.getType());
robotMapItems.add(positionMapItem); robotMapItems.add(positionMapItem);
positionMapItems.removeIf(v -> v.getId().equals(positionMapItem.getId()));
} }
} }
if (ObjectUtil.isNotEmpty(robotNos)) { if (ObjectUtil.isNotEmpty(robotNos)) {
List<PositionMapItemDO> emptyMapItems = positionMapItems.stream() List<PositionMapItemDO> emptyMapItems = positionMapItems.stream()
.filter(v -> ObjectUtil.isEmpty(v.getRobotNo())) .filter(v -> UseStatusEnum.FREE.getType().equals(v.getUseStatus()))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(emptyMapItems)) { if (ObjectUtil.isNotEmpty(emptyMapItems)) {
for (PositionMapItemDO positionMapItem : emptyMapItems) { for (PositionMapItemDO positionMapItem : emptyMapItems) {
@ -250,11 +250,8 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
return; return;
} }
Map<String, PositionMapItemDO> positionMap =
robotMapItems.stream().collect(Collectors.toMap(PositionMapItemDO::getRobotNo, Function.identity()));
Map<Long, Long> sortMap = positionMapItems.stream().collect(Collectors.toMap(PositionMapItemDO::getId, PositionMapItemDO::getSortNum)); Map<Long, Long> sortMap = positionMapItems.stream().collect(Collectors.toMap(PositionMapItemDO::getId, PositionMapItemDO::getSortNum));
//机器人不能行走的区域 //机器人不能行走的区域
List<TaskRobotNoLimittationAreaDTO> robotNoLimitationArea = getRobotNoLimitationArea(robots); List<TaskRobotNoLimittationAreaDTO> robotNoLimitationArea = getRobotNoLimitationArea(robots);
Map<String, TaskRobotNoLimittationAreaDTO> robotNoLimittationAreaDTOMap = Map<String, TaskRobotNoLimittationAreaDTO> robotNoLimittationAreaDTOMap =
@ -296,7 +293,7 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
.build(); .build();
TaskRobotNoLimittationAreaDTO taskRobotNoLimittationAreaDTO = robotNoLimittationAreaDTOMap.get(v.getRobotNo()); TaskRobotNoLimittationAreaDTO taskRobotNoLimittationAreaDTO = robotNoLimittationAreaDTOMap.get(v.getRobotNo());
List<TaskRobotNoLimittationAreaDTO> robotNoLimitions = Arrays.asList(taskRobotNoLimittationAreaDTO); List<TaskRobotNoLimittationAreaDTO> robotNoLimitions = Collections.singletonList(taskRobotNoLimittationAreaDTO);
pathPlanning.setRobotNoLimitationAreaDTOS(robotNoLimitions); pathPlanning.setRobotNoLimitationAreaDTOS(robotNoLimitions);
String key = PathPlanningChcheConstant.PATH_PLANNING_TASK + pathPlanning.getOrderId(); String key = PathPlanningChcheConstant.PATH_PLANNING_TASK + pathPlanning.getOrderId();

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.system.service.tool; package cn.iocoder.yudao.module.system.service.tool;
import cn.iocoder.yudao.module.system.controller.admin.tool.dto.SendMsgToMqttDTO;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@ -14,4 +16,10 @@ public interface ToolsService {
String updateWarnCode(); String updateWarnCode();
void simulationPose(); void simulationPose();
/**
* 发送消息给MQTT
* @param dto
*/
void sendMsgToMQTT(SendMsgToMqttDTO dto);
} }

View File

@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.system.constant.robot.RobotTopicConstant;
import cn.iocoder.yudao.module.system.controller.admin.config.dto.TaskOrderConfigDTO; import cn.iocoder.yudao.module.system.controller.admin.config.dto.TaskOrderConfigDTO;
import cn.iocoder.yudao.module.system.controller.admin.config.vo.CommonConfigVO; import cn.iocoder.yudao.module.system.controller.admin.config.vo.CommonConfigVO;
import cn.iocoder.yudao.module.system.controller.admin.tool.dto.CleanAgvDTO; import cn.iocoder.yudao.module.system.controller.admin.tool.dto.CleanAgvDTO;
import cn.iocoder.yudao.module.system.controller.admin.tool.dto.SendMsgToMqttDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.config.CommonConfigDO; import cn.iocoder.yudao.module.system.dal.dataobject.config.CommonConfigDO;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO; import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO; import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO;
@ -244,6 +245,11 @@ public class ToolsServiceImpl implements ToolsService {
} }
} }
@Override
public void sendMsgToMQTT(SendMsgToMqttDTO dto) {
commonApi.commonMethodStr(dto.getMsg(),dto.getTopic());
}
public void addWarnMsg() { public void addWarnMsg() {
RobotWarnMsgDO warnMsg = RobotWarnMsgDO.builder().warnLevel(4) RobotWarnMsgDO warnMsg = RobotWarnMsgDO.builder().warnLevel(4)

View File

@ -36,4 +36,26 @@
where where
position_map_id = #{mapId} position_map_id = #{mapId}
</update> </update>
<update id="updateRobotNo">
update
device_information
set
last_user = #{newRobotNo}
where
last_user = #{oldRobotNo}
and deleted = '0'
and device_type = '1'
</update>
<update id="clearRobotNo">
update
device_information
set
last_user = '',
device_use_status = '0'
where
last_user = #{robotNo}
and deleted = '0'
and device_type = '1'
</update>
</mapper> </mapper>

View File

@ -158,4 +158,24 @@
set deleted = 1 set deleted = 1
where position_map_id = #{mapId} where position_map_id = #{mapId}
</update> </update>
<update id="updateRobotNo">
update
ware_position_map_item
set
robot_no = #{newRobotNo}
where
robot_no = #{oldRobotNo}
and deleted = '0'
</update>
<update id="clearRobotNo">
update
ware_position_map_item
set
robot_no = '',
use_status = '0'
where
robot_no = #{robotNo}
and deleted = '0'
</update>
</mapper> </mapper>

View File

@ -1,6 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.remote.RemoteControllerInformationMapper"> <mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.remote.RemoteControllerInformationMapper">
<update id="updateRobotNo">
update
remote_controller_information
set
robot_no = #{newRobotNo}
where
robot_no = #{oldRobotNo}
and deleted = '0'
</update>
<!-- <!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。

View File

@ -1,6 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.robot.RobotMapStopMapper"> <mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.robot.RobotMapStopMapper">
<update id="updateRobotNo">
update
robot_map_stop
set
robot_no = #{newRobotNo}
where
robot_no = #{oldRobotNo}
and deleted = '0'
</update>
<!-- <!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。

View File

@ -9,4 +9,13 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/ 文档可见https://www.iocoder.cn/MyBatis/x-plugins/
--> -->
<update id="updateRobotNo">
update
robot_move_to_wait
set
robot_no = #{newRobotNo}
where
robot_no = #{oldRobotNo}
and deleted = '0'
</update>
</mapper> </mapper>