Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
ty 9 months ago
parent
commit
aa33162dfd
  1. 11
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java
  2. 7
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/dto/robot/RobotInstanceDTO.java
  3. 5
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java
  4. 41
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java
  5. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java
  6. 4
      hzims-service/inspect/src/main/resources/db/2.0.0.sql.1

11
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java

@ -148,10 +148,19 @@ public class RobotController extends BladeController {
return R.status(st_robotService.generateDeviceInstance(device));
}
@PostMapping("/getRealDataByRobotCode")
@GetMapping("/getRealDataByRobotCode")
@ApiOperationSupport(order = 11)
@ApiOperation(value = "获取机器人各项属性实时数据", notes = "获取机器人各项属性实时数据")
public R<List<RobotRealDataVO>> getRealDataByRobotCode(@RequestParam @ApiParam(value = "机器人编号", required = true) String robotCode) {
return R.data(st_robotService.getRealDataByRobotCode(robotCode));
}
@GetMapping("/getRobotSoeData")
@ApiOperationSupport(order = 12)
@ApiOperation(value = "获取机器人告警", notes = "获取机器人告警")
public R<IPage> getRobotSoeData(@RequestParam @ApiParam("机器人编号") String robotCode,
@RequestParam @ApiParam("开始时间") String startTime,
@RequestParam @ApiParam("结束时间") String endTime, Query query) {
return R.data(st_robotService.getRobotSoeData(robotCode,startTime,endTime,query));
}
}

7
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/dto/robot/RobotInstanceDTO.java

@ -22,13 +22,12 @@ public class RobotInstanceDTO implements Serializable {
@NotBlank(message = "机器人名称不能为空")
private String deviceName;
@ApiModelProperty("站点编号")
private String stationCode;
@ApiModelProperty("模型标识")
private String modelSignage;
@ApiModelProperty("站点编号")
@NotBlank(message = "站点编号不能为空")
private String projectId;
@ApiModelProperty("标准设备需要传入密钥")
private String secretKey;

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

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.ai.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData;
import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO;
import com.hnac.hzinfo.inspect.ai.vo.RobotVO;
@ -7,8 +8,10 @@ import com.hnac.hzinfo.inspect.ai.vo.robot.RobotRealDataVO;
import com.hnac.hzinfo.sdk.v5.device.vo.VirtualDeviceDTO;
import org.springblade.core.mp.base.BaseService;
import com.hnac.hzinfo.inspect.ai.entity.RobotEntity;
import org.springblade.core.mp.support.Query;
import java.util.List;
import java.util.Map;
/**
* 服务类
@ -37,4 +40,6 @@ public interface IRobotService extends BaseService<RobotEntity> {
* @return 实时数据
*/
List<RobotRealDataVO> getRealDataByRobotCode(String robotCode);
IPage getRobotSoeData(String robotCode, String startTime, String endTime, Query query);
}

41
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotServiceImpl.java

@ -2,6 +2,7 @@ package com.hnac.hzinfo.inspect.ai.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
@ -29,14 +30,17 @@ import com.hnac.hzinfo.inspect.ai.entity.RobotEntity;
import com.hnac.hzinfo.inspect.ai.mapper.RobotMapper;
import com.hnac.hzinfo.inspect.ai.service.IRobotService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.cache.ParamCache;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -81,7 +85,9 @@ public class RobotServiceImpl extends BaseServiceImpl<RobotMapper, RobotEntity>
device.setModelSignage(Func.isNotEmpty(device.getModelSignage()) ? device.getModelSignage() : modelSignage);
VirtualDeviceDTO req = BeanUtil.copy(device, VirtualDeviceDTO.class);
req.setIsStandard(1);
req.setProjectId(device.getStationCode());
req.setProtocolSignage("standard");
req.setSecretKey(device.getSecretKey());
R<Long> saveResult = deviceClient.saveVirtualDevice(req);
Assert.isTrue(saveResult.isSuccess(),() -> {
throw new ServiceException("生成设备实例失败,报错信息为:" + saveResult.getMsg());
@ -89,27 +95,46 @@ public class RobotServiceImpl extends BaseServiceImpl<RobotMapper, RobotEntity>
LambdaUpdateWrapper<RobotEntity> luw = Wrappers.<RobotEntity>lambdaUpdate()
.set(RobotEntity::getIsDeviceInstance, true)
.eq(RobotEntity::getCode, device.getDeviceCode());
return this.update(luw);
this.update(luw);
return true;
}
}
@Override
public List<RobotRealDataVO> getRealDataByRobotCode(String robotCode) {
Result<List<DeviceInstanceAttrVO>> attrResult = deviceClient.getDeviceInstaceAttrsByDeviceCodes(Lists.newArrayList(robotCode));
Assert.isTrue(attrResult.isSuccess(),() -> {
throw new ServiceException("获取设备实例物模型失败!");
});
DeviceRealDataPO po = new DeviceRealDataPO();
po.setDeviceCode(robotCode);
po.setSignages(attrResult.getData().stream().map(DeviceInstanceAttrVO::getSignage).collect(Collectors.toList()));
Result<List<List<Map<String, RealDataRedisVO>>>> realDataResult = deviceDataClient.getDeviceRealDataByCodes(Lists.newArrayList(po));
Assert.isTrue(realDataResult.isSuccess(),() -> {
throw new ServiceException("获取设备实例实时数据失败!");
});
List<RobotRealDataVO> result = realDataResult.getData().stream()
.flatMap(l -> l.stream())
.flatMap(m -> m.entrySet().stream().map(k -> BeanUtil.copy(m.get(k), RobotRealDataVO.class)))
.collect(Collectors.toList());
.flatMap(m -> m.entrySet().stream().map(k -> {
RobotRealDataVO data = BeanUtil.copy(k.getValue(), RobotRealDataVO.class);
data.setAttrName(k.getValue().getN());
return data;
})).collect(Collectors.toList());
return result;
}
@Override
public IPage getRobotSoeData(String robotCode, String startTime, String endTime, Query query) {
RobotEntity request = new RobotEntity();
request.setCode(robotCode);
RobotEntity robot = this.getOne(Wrappers.<RobotEntity>lambdaQuery().eq(RobotEntity::getCode, robotCode));
Assert.isTrue(ObjectUtil.isNotEmpty(robot) && StringUtil.isNotBlank(robot.getStationCode()),() -> {
throw new ServiceException("该机器人未绑定站点,无法获取告警数据!");
});
Result<Map<String, Object>> deviceSoeDataResult = deviceDataClient.getDeviceSoeData(robot.getStationCode(), 1, robotCode, null,
startTime, endTime, true, query.getCurrent(), query.getSize());
Assert.isTrue(deviceSoeDataResult.isSuccess(), () -> {
throw new ServiceException("获取机器人告警信息失败!");
});
Map<String, Object> deviceSoeData = deviceSoeDataResult.getData();
IPage result = Condition.getPage(query);
result.setRecords((List) deviceSoeData.get("data"));
result.setTotal(Long.valueOf((int) deviceSoeData.get("total")));
return result;
}

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/vo/robot/RobotRealDataVO.java

@ -11,7 +11,7 @@ import java.io.Serializable;
@Data
@EqualsAndHashCode
public class RobotRealDataVO extends RealDataRedisVO implements Serializable {
public class RobotRealDataVO implements Serializable {
@ApiModelProperty("数据上送时间")
private String ts;

4
hzims-service/inspect/src/main/resources/db/2.0.0.sql.1

@ -1,6 +1,6 @@
ALTER TABLE `hzims-inspect`.`hz_st_ex_task_user` MODIFY COLUMN `CLAIM_STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '领用状态 0:未领用 1:已领用 每条任务可以存在多个用户,但是只有一个领用人' AFTER `USER_ID`;
ALTER TABLE `hz_st_ex_task_user` MODIFY COLUMN `CLAIM_STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '领用状态 0:未领用 1:已领用 每条任务可以存在多个用户,但是只有一个领用人' AFTER `USER_ID`;
ALTER TABLE `hzims-inspect`.`hz_st_ex_task_user` ADD COLUMN `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `TENANT_ID`;
ALTER TABLE `hz_st_ex_task_user` ADD COLUMN `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `TENANT_ID`;
alter table `hz_st_ex_task` add column `hik_video_task_id` varchar(50) default null comment '海康录制视频任务ID';
alter table `hz_st_ex_task` add column `video_start_time` datetime default null comment '视频录制开始时间';

Loading…
Cancel
Save