维护车辆信息

This commit is contained in:
cbs 2025-06-05 17:37:17 +08:00
parent 4f6fd7d807
commit 2f9c8a38bc
18 changed files with 190 additions and 25 deletions

View File

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

View File

@ -236,11 +236,11 @@ public interface ErrorCodeConstants {
ErrorCode PATH_PLANNING_DOING_DISTRIBUTE = new ErrorCode(1-002-037-002, "有正在分配的PP任务!");
// ========== 地图信息 1-002-038-000 ==========
ErrorCode AGV_UPLOAD_INFORMATION_DOES_NOT_INCLUDE_FLOOR_OR_AREA_INFORMATION = new ErrorCode(1_002_038_001, "AGV上传信息未包含楼层或区域信息");
ErrorCode AGV_FILE_UPLOAD_CONTENT_IS_EMPTY = new ErrorCode(1_002_038_002, "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, "车辆文件上传内容为空");
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_IMAGE_CONVERSION_TO_BASE64_FAILED = new ErrorCode(1_002_038_005, "AGV图片转base64失败");
ErrorCode AGV_MAP_NOT_FOUND = new ErrorCode(1_002_038_004, "找不到车辆地图信息");
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 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, "已有库位在其它区域内");

View File

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

View File

@ -54,4 +54,17 @@ public interface DeviceInformationMapper extends BaseMapperX<DeviceInformationDO
* @param 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
*/
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.dal.dataobject.remote.RemoteControllerInformationDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 远遥设备信息 Mapper
@ -33,4 +34,12 @@ public interface RemoteControllerInformationMapper extends BaseMapperX<RemoteCon
* @return
*/
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
*/
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.dal.dataobject.wait.MoveToWaitDO;
import org.apache.ibatis.annotations.Param;
/**
* 车辆前往等待点记录 Mapper
*
@ -26,4 +28,10 @@ public interface MoveToWaitMapper extends BaseMapperX<MoveToWaitDO> {
.orderByDesc(MoveToWaitDO::getId));
}
/**
* 更新车辆编号
* @param oldRobotNo
* @param newRobotNo
*/
void updateRobotNo(@Param("oldRobotNo") String oldRobotNo, @Param("newRobotNo") String newRobotNo);
}

View File

@ -167,7 +167,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
*/
@Override
public void synchronousAllItem(PositionMapSaveReqVO data) {
log.info("synchronousAllItem----start");
log.info("开始同步点位信息");
List<PositionMapDO> positionMapDOS = positionMapMapper.selectList(new LambdaQueryWrapperX<PositionMapDO>()
.eq(ObjectUtil.isNotEmpty(data.getFloor()), PositionMapDO::getFloor, data.getFloor())
.eq(ObjectUtil.isNotEmpty(data.getArea()), PositionMapDO::getArea, data.getArea()));
@ -187,11 +187,10 @@ public class PathPlanningServiceImpl implements PathPlanningService {
relatedPathNode.setType(PathTypeEnum.INIT.getType());
relatedPathNode.setControl_nodes(positionMapItemSynDTOS);
log.info("synchronousAllItem----doing :{}",JSON.toJSONString(relatedPathNode));
commonApi.commonMethod(relatedPathNode, PathPlanningTopicConstant.SYNCHRONOUS_ALL_MAP_NODE);
}
log.info("synchronousAllItem----end");
log.info("同步点位信息结束");
}
/**

View File

@ -587,7 +587,6 @@ public class RemoteControllerInformationServiceImpl extends ServiceImpl<RemoteCo
*/
@Transactional(rollbackFor = Exception.class)
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.remote.RemoteControllerInformationMapper;
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.device.DeviceTypeEnum;
import cn.iocoder.yudao.module.system.enums.device.DeviceUseStatusEnum;
@ -172,6 +174,14 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
@Resource
private RobotCameraService cameraService;
@Resource
private RobotChargeLogMapper chargeLogMapper;
@Resource
private RobotWorkingHoursStatisticsMapper robotWorkingHoursStatisticsMapper;
@Resource
private MoveToWaitMapper moveToWaitMapper;
@Resource
private RemoteControllerInformationMapper controllerInformationMapper;
@ -414,16 +424,12 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
checkIpAndPort(updateObj);
if (!updateReqVO.getRobotNo().equals(robotInformationDO.getRobotNo())) {
updateRobotNo(robotInformationDO.getRobotNo(),updateReqVO.getRobotNo());
}
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于地图关系表 -----
List<List<Long>> list = CollectionUtils.compareLists(
@ -475,6 +481,36 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
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
@Transactional(rollbackFor = Exception.class)
public void deleteInformation(Long id) {
@ -482,6 +518,13 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
validateInformationExists(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());
List<RobotTaskDO> list = taskMapper.selectDoingTaskByRobotNo(robotInformationDO.getRobotNo());
@ -519,6 +562,13 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
redisUtil.hdel(oldFloorArea, robotInformationDO.getRobotNo());
redisUtil.del(floorAreaKey);
}
deleteRobot(robotInformationDO.getRobotNo());
}
private void deleteRobot(String robotNo) {
deviceInformationMapper.clearRobotNo(robotNo);
positionMapItemMapper.clearRobotNo(robotNo);
}
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.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -207,7 +208,7 @@ public class RobotTaskDetailServiceImpl implements RobotTaskDetailService {
informationService.setRobotFree(robotTaskDetailDO.getRobotNo());
actionLog.setActionStatus(ActionStatusEnum.DONE.getType());
taskDetailActionLogService.updateTaskDetailActionLogs(Arrays.asList(actionLog));
taskDetailActionLogService.updateTaskDetailActionLogs(Collections.singletonList(actionLog));
taskDetailActionLogService.setPreviousTaskDoneByOrderId(taskDetailId);
if (RobotTaskStageEnum.DONE.getType().equals(taskStage)

View File

@ -119,7 +119,6 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
public void sendTaskToPP() {
TenantContextHolder.setTenantId(1L);
log.info("-------循环任务开始查找车子和任务------");
Pair<List<RobotInformationDO>, List<RobotTaskDetailDO>> robotAndTaskDetails =
distributeTasksService.getRobotAndTaskDetails();

View File

@ -36,4 +36,26 @@
where
position_map_id = #{mapId}
</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>

View File

@ -158,4 +158,24 @@
set deleted = 1
where position_map_id = #{mapId}
</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>

View File

@ -1,6 +1,15 @@
<?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">
<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 增删改查即可。

View File

@ -1,6 +1,15 @@
<?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">
<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 增删改查即可。

View File

@ -9,4 +9,13 @@
文档可见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>