MQTT消费
This commit is contained in:
parent
0072a4e4d0
commit
2e03d0780c
@ -47,7 +47,7 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
@Resource
|
||||
private RequestProcessor processor;
|
||||
|
||||
private static final ExecutorService executorService = Executors.newFixedThreadPool(5);
|
||||
private static final ExecutorService executorService = Executors.newFixedThreadPool(20);
|
||||
|
||||
@Resource
|
||||
private CommonApi commonApi;
|
||||
@ -109,11 +109,9 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
|
||||
redisUtil.set(pose2dKey, JSON.toJSONString(robotStatusDataPoseDTO), robotPositionCacheTime);
|
||||
|
||||
//机器人身上是否有货
|
||||
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS + robotStatusDataDTO.getMac();
|
||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robotStatusDataDTO.getMac();
|
||||
redisUtil.set(taskStatusKey, robotStatusDataDTO.getTaskStatus(), robotPositionCacheTime);
|
||||
redisUtil.set(cargoDetectedKey, robotStatusDataDTO.getCargoDetected(), robotPositionCacheTime);
|
||||
executorService.execute(() ->{
|
||||
sendToPP(robotStatusDataPoseDTO);
|
||||
});
|
||||
|
||||
// -- 通过mac 地址获取车辆信息 - (并且加入到缓存中)
|
||||
Map<String, RobotInformationVO> robotInformationVOS = robotInformationService.getAllRobotByRedis();
|
||||
@ -123,15 +121,27 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
}
|
||||
robotInformationVO.setPose2d(robotStatusDataPoseDTO);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String value = FloorAreaConstant.FLOOR_AREA_ROBOT + floorZoneDTO.getFloor() + CommonConstant.SYMBOL + floorZoneDTO.getArea();
|
||||
map.put(robotStatusDataDTO.getMac(), JSON.toJSONString(robotInformationVO));
|
||||
redisUtil.hmset(value, map, 20);
|
||||
RobotInformationVO finalRobotInformationVO = robotInformationVO;
|
||||
|
||||
executorService.execute(() ->{
|
||||
//机器人身上是否有货
|
||||
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS + robotStatusDataDTO.getMac();
|
||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + robotStatusDataDTO.getMac();
|
||||
redisUtil.set(taskStatusKey, robotStatusDataDTO.getTaskStatus(), robotPositionCacheTime);
|
||||
redisUtil.set(cargoDetectedKey, robotStatusDataDTO.getCargoDetected(), robotPositionCacheTime);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String value = FloorAreaConstant.FLOOR_AREA_ROBOT + floorZoneDTO.getFloor() + CommonConstant.SYMBOL + floorZoneDTO.getArea();
|
||||
map.put(robotStatusDataDTO.getMac(), JSON.toJSONString(finalRobotInformationVO));
|
||||
redisUtil.hmset(value, map, 20);
|
||||
});
|
||||
|
||||
executorService.execute(() ->{
|
||||
// 合并请求 - 这里接受到的数据都丢给 RequestProcessor - 再整合数据通过WebSocket丢给前端
|
||||
processor.handleRequest(floorZoneDTO.getFloor() + CommonConstant.SYMBOL + floorZoneDTO.getArea(),
|
||||
robotStatusDataDTO.getMac(), JSONUtil.toJsonStr(finalRobotInformationVO));
|
||||
});
|
||||
|
||||
|
||||
// 合并请求 - 这里接受到的数据都丢给 RequestProcessor - 再整合数据通过WebSocket丢给前端
|
||||
processor.handleRequest(floorZoneDTO.getFloor() + CommonConstant.SYMBOL + floorZoneDTO.getArea(),
|
||||
robotStatusDataDTO.getMac(), JSONUtil.toJsonStr(robotInformationVO));
|
||||
sendToPP(robotStatusDataPoseDTO);
|
||||
}
|
||||
|
||||
private void sendToPP(RobotStatusDataPoseDTO robotStatusDataPoseDTO) {
|
||||
|
@ -95,6 +95,7 @@ public interface PositionMapItemMapper extends BaseMapperX<PositionMapItemDO> {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@MapKey("id")
|
||||
Map<Long, Long> selectSortNumByIds(@Param("ids") List<Long> ids);
|
||||
/*@MapKey("id")
|
||||
Map<Long, Long> selectSortNumByIds(@Param("ids") List<Long> ids);*/
|
||||
List<PositionMapItemDO> selectSortNumByIds(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapLinePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapLineSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapLineDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapItemMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.positionmap.PositionMapLineMapper;
|
||||
@ -65,7 +66,10 @@ public class PositionMapLineServiceImpl extends ServiceImpl<PositionMapLineMappe
|
||||
List<Long> endPointIds = addList.stream().map(PositionMapLineDO::getEndPointId).collect(Collectors.toList());
|
||||
//合并startPointIds 和 endPointIds 并且去重
|
||||
Set<Long> pointIds = CollUtil.unionDistinct(startPointIds, endPointIds);
|
||||
map = positionMapItemMapper.selectSortNumByIds(new ArrayList<>(pointIds));
|
||||
List<PositionMapItemDO> positionMapItemDOS = positionMapItemMapper.selectSortNumByIds(new ArrayList<>(pointIds));
|
||||
if (ObjectUtil.isNotEmpty(positionMapItemDOS)) {
|
||||
map = positionMapItemDOS.stream().collect(Collectors.toMap(PositionMapItemDO::getId, PositionMapItemDO::getSortNum));
|
||||
}
|
||||
}
|
||||
for (PositionMapLineDO positionMapLineDO : newList) {
|
||||
positionMapLineDO.setPositionMapId(positionMapId);
|
||||
|
@ -86,7 +86,7 @@
|
||||
(#{item.positionMapId}, #{item.actualLocationX}, #{item.actualLocationY}, #{item.type})
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="selectSortNumByIds" resultType="map">
|
||||
<select id="selectSortNumByIds" resultType="cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO">
|
||||
select
|
||||
id,
|
||||
sort_num as sortNum
|
||||
|
Loading…
Reference in New Issue
Block a user