diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/entity/RobotEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/entity/RobotEntity.java index e179398..efd4f1a 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/entity/RobotEntity.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/entity/RobotEntity.java @@ -1,5 +1,6 @@ package com.hnac.hzinfo.inspect.ai.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.hnac.hzinfo.inspect.utils.QueryField; import com.hnac.hzinfo.inspect.utils.SqlCondition; @@ -72,4 +73,8 @@ public class RobotEntity extends TenantEntity { @ApiModelProperty(value = "描述信息") private Long remark; + @ApiModelProperty("用户名称") + @TableField(exist = false) + private String userName; + } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java index 18f48a0..740a04d 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java @@ -29,6 +29,8 @@ import org.springblade.core.oss.OssTemplate; import org.springblade.core.oss.model.BladeFile; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -39,6 +41,7 @@ import com.hnac.hzinfo.inspect.ai.service.IRobotService; import java.util.List; import java.util.Map; +import java.util.Optional; /** * 控制器 @@ -80,6 +83,10 @@ public class RobotController extends BladeController { public R> list(@ApiIgnore @RequestParam Map st_robot, Query query) { QueryWrapper queryWrapper = Condition.getQueryWrapper( st_robot, RobotEntity.class); IPage pages = st_robotService.page(Condition.getPage(query), queryWrapper); + pages.getRecords().stream().filter(robot -> Func.isNotEmpty(robot.getUserId())).forEach(robotEntity -> { + User user = UserCache.getUser(robotEntity.getUserId()); + robotEntity.setUserName(Optional.ofNullable(user).map(User::getName).orElse(null)); + }); return R.data(pages); } @@ -157,7 +164,7 @@ public class RobotController extends BladeController { @ApiOperationSupport(order = 11) @ApiOperation(value = "获取机器人各项属性实时数据", notes = "获取机器人各项属性实时数据") @Operate(label = "获取机器人实时数据",type = BusinessType.QUERY,ignore = false) - public R> getRealDataByRobotCode(@RequestParam @ApiParam(value = "机器人编号", required = true) String robotCode) { + public R>> getRealDataByRobotCode(@RequestParam @ApiParam(value = "机器人编号", required = true) String robotCode) { return R.data(st_robotService.getRealDataByRobotCode(robotCode)); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java index 67a9929..ca7fc40 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java @@ -39,7 +39,7 @@ public interface IRobotService extends BaseService { * @param robotCode 机器人编号 * @return 实时数据 */ - List getRealDataByRobotCode(String robotCode); + Map> getRealDataByRobotCode(String robotCode); IPage getRobotSoeData(String robotCode, String startTime, String endTime, Query query); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java index 141abef..aa30f6b 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java @@ -47,6 +47,8 @@ import org.springframework.util.Assert; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -105,13 +107,11 @@ public class RobotServiceImpl extends BaseServiceImpl } @Override - public List getRealDataByRobotCode(String robotCode) { + public Map> getRealDataByRobotCode(String robotCode) { R> paramDeviceAttrR = deviceClient.getOnlineAttr(robotCode); Assert.isTrue(paramDeviceAttrR.isSuccess(), () -> { throw new ServiceException("获取设备实例属性失败!"); }); - - DeviceRealDataPO po = new DeviceRealDataPO(); po.setDeviceCode(robotCode); Result>>> realDataResult = deviceDataClient.getDeviceRealDataByCodes(Lists.newArrayList(po)); @@ -123,9 +123,12 @@ public class RobotServiceImpl extends BaseServiceImpl .flatMap(m -> m.entrySet().stream().map(k -> { RobotRealDataVO data = BeanUtil.copy(k.getValue(), RobotRealDataVO.class); data.setAttrName(k.getValue().getN()); + Optional attrOptional = paramDeviceAttrR.getData().stream().filter(deviceAttr -> k.getValue().getN().equals(deviceAttr.getName())).findFirst(); + data.setModelClassifyId(attrOptional.get().getModelClassifyId()); + data.setModelClassifyName(attrOptional.get().getModelClassifyName()); return data; })).collect(Collectors.toList()); - return result; + return result.stream().collect(Collectors.groupingBy(RobotRealDataVO::getModelClassifyName)); } @Override diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java index 7a50091..f3371a7 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java @@ -12,6 +12,13 @@ import java.io.Serializable; @Data @EqualsAndHashCode public class RobotRealDataVO implements Serializable { + + @ApiModelProperty("模型分类") + private Long modelClassifyId; + + @ApiModelProperty("模型分类名称") + private String modelClassifyName; + @ApiModelProperty("数据上送时间") private String ts;