Browse Source

# 巡检机器人数据看板

zhongwei
haungxing 8 months ago
parent
commit
de6d4fd25d
  1. 5
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/entity/RobotEntity.java
  2. 9
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java
  3. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java
  4. 11
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java
  5. 7
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java

5
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;
}

9
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<IPage<RobotEntity>> list(@ApiIgnore @RequestParam Map<String,Object> st_robot, Query query) {
QueryWrapper<RobotEntity> queryWrapper = Condition.getQueryWrapper( st_robot, RobotEntity.class);
IPage<RobotEntity> 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<List<RobotRealDataVO>> getRealDataByRobotCode(@RequestParam @ApiParam(value = "机器人编号", required = true) String robotCode) {
public R<Map<String,List<RobotRealDataVO>>> getRealDataByRobotCode(@RequestParam @ApiParam(value = "机器人编号", required = true) String robotCode) {
return R.data(st_robotService.getRealDataByRobotCode(robotCode));
}

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java

@ -39,7 +39,7 @@ public interface IRobotService extends BaseService<RobotEntity> {
* @param robotCode 机器人编号
* @return 实时数据
*/
List<RobotRealDataVO> getRealDataByRobotCode(String robotCode);
Map<String,List<RobotRealDataVO>> getRealDataByRobotCode(String robotCode);
IPage getRobotSoeData(String robotCode, String startTime, String endTime, Query query);
}

11
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<RobotMapper, RobotEntity>
}
@Override
public List<RobotRealDataVO> getRealDataByRobotCode(String robotCode) {
public Map<String,List<RobotRealDataVO>> getRealDataByRobotCode(String robotCode) {
R<List<DeviceInstanceAttrVO>> paramDeviceAttrR = deviceClient.getOnlineAttr(robotCode);
Assert.isTrue(paramDeviceAttrR.isSuccess(), () -> {
throw new ServiceException("获取设备实例属性失败!");
});
DeviceRealDataPO po = new DeviceRealDataPO();
po.setDeviceCode(robotCode);
Result<List<List<Map<String, RealDataRedisVO>>>> realDataResult = deviceDataClient.getDeviceRealDataByCodes(Lists.newArrayList(po));
@ -123,9 +123,12 @@ public class RobotServiceImpl extends BaseServiceImpl<RobotMapper, RobotEntity>
.flatMap(m -> m.entrySet().stream().map(k -> {
RobotRealDataVO data = BeanUtil.copy(k.getValue(), RobotRealDataVO.class);
data.setAttrName(k.getValue().getN());
Optional<DeviceInstanceAttrVO> 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

7
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;

Loading…
Cancel
Save