|
|
@ -1,46 +1,48 @@ |
|
|
|
package com.hnac.hzinfo.inspect.ai.service.impl; |
|
|
|
package com.hnac.hzinfo.inspect.ai.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO; |
|
|
|
import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO; |
|
|
|
|
|
|
|
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 com.hnac.hzinfo.inspect.ai.vo.RemoteControlDTO; |
|
|
|
import com.hnac.hzinfo.inspect.ai.vo.RobotVO; |
|
|
|
import com.hnac.hzinfo.inspect.ai.vo.RobotVO; |
|
|
|
import com.hnac.hzinfo.inspect.ai.vo.robot.RobotRealDataVO; |
|
|
|
import com.hnac.hzinfo.inspect.ai.vo.robot.RobotRealDataVO; |
|
|
|
import com.hnac.hzinfo.inspect.ai.wrapper.RobotWrapper; |
|
|
|
import com.hnac.hzinfo.inspect.ai.wrapper.RobotWrapper; |
|
|
|
import com.hnac.hzinfo.inspect.constants.ParamConstants; |
|
|
|
import com.hnac.hzinfo.inspect.constants.ParamConstants; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.task.TaskContants; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.task.entity.TaskEntity; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.task.service.ITaskService; |
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.control.ControlClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.control.dto.ControlDTO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.po.DeviceRealDataPO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.po.DeviceRealDataPO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.RealDataRedisVO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.RealDataRedisVO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.VirtualDeviceDTO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.VirtualDeviceDTO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.project.ProjectClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
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.Condition; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
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.springblade.system.cache.ParamCache; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.*; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
import java.util.function.Function; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -54,8 +56,9 @@ import java.util.stream.Collectors; |
|
|
|
public class RobotServiceImpl extends ServiceImpl<RobotMapper, RobotEntity> implements IRobotService { |
|
|
|
public class RobotServiceImpl extends ServiceImpl<RobotMapper, RobotEntity> implements IRobotService { |
|
|
|
|
|
|
|
|
|
|
|
private final DeviceClient deviceClient; |
|
|
|
private final DeviceClient deviceClient; |
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
|
|
|
|
private final DeviceDataClient deviceDataClient; |
|
|
|
private final DeviceDataClient deviceDataClient; |
|
|
|
|
|
|
|
private final ControlClient controlClient; |
|
|
|
|
|
|
|
private final ProjectClient projectClient; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 根据用户id 获取 机器人信息 |
|
|
|
* 根据用户id 获取 机器人信息 |
|
|
@ -75,10 +78,19 @@ public class RobotServiceImpl extends ServiceImpl<RobotMapper, RobotEntity> impl |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Boolean generateDeviceInstance(RobotInstanceDTO device) { |
|
|
|
public Boolean generateDeviceInstance(RobotInstanceDTO device) { |
|
|
|
if(deviceClient.isDeviceCodeExist(device.getDeviceCode()).isSuccess()) { |
|
|
|
// fixme 响应接口变化了
|
|
|
|
|
|
|
|
if("true".equals(deviceClient.isDeviceCodeExist(device.getDeviceCode()).getData())) { |
|
|
|
throw new ServiceException("该机器人已经创建过设备实例,无需再创建!"); |
|
|
|
throw new ServiceException("该机器人已经创建过设备实例,无需再创建!"); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
|
|
|
|
Result<List<ProjectVO>> projectVOResult = projectClient.getProjectIds(Collections.singletonList(device.getStationCode())); |
|
|
|
|
|
|
|
Assert.isTrue(projectVOResult.isSuccess(),() -> { |
|
|
|
|
|
|
|
throw new ServiceException("获取站点信息失败!"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
List<ProjectVO> projectVOList = projectVOResult.getData(); |
|
|
|
|
|
|
|
if (projectVOList==null||projectVOList.isEmpty()){ |
|
|
|
|
|
|
|
throw new ServiceException("数据平台不存在该站点信息!"); |
|
|
|
|
|
|
|
} |
|
|
|
String modelSignage = ParamCache.getValue(ParamConstants.ROBOT_MODEL_CODE); |
|
|
|
String modelSignage = ParamCache.getValue(ParamConstants.ROBOT_MODEL_CODE); |
|
|
|
device.setModelSignage(Func.isNotEmpty(device.getModelSignage()) ? device.getModelSignage() : modelSignage); |
|
|
|
device.setModelSignage(Func.isNotEmpty(device.getModelSignage()) ? device.getModelSignage() : modelSignage); |
|
|
|
VirtualDeviceDTO req = BeanUtil.copy(device, VirtualDeviceDTO.class); |
|
|
|
VirtualDeviceDTO req = BeanUtil.copy(device, VirtualDeviceDTO.class); |
|
|
@ -118,6 +130,7 @@ public class RobotServiceImpl extends ServiceImpl<RobotMapper, RobotEntity> impl |
|
|
|
Optional<DeviceInstanceAttrVO> attrOptional = paramDeviceAttrR.getData().stream().filter(deviceAttr -> k.getValue().getN().equals(deviceAttr.getName())).findFirst(); |
|
|
|
Optional<DeviceInstanceAttrVO> attrOptional = paramDeviceAttrR.getData().stream().filter(deviceAttr -> k.getValue().getN().equals(deviceAttr.getName())).findFirst(); |
|
|
|
data.setModelClassifyId(attrOptional.get().getModelClassifyId()); |
|
|
|
data.setModelClassifyId(attrOptional.get().getModelClassifyId()); |
|
|
|
data.setModelClassifyName(attrOptional.get().getModelClassifyName()); |
|
|
|
data.setModelClassifyName(attrOptional.get().getModelClassifyName()); |
|
|
|
|
|
|
|
data.setUnits(attrOptional.get().getUnits()); |
|
|
|
return data; |
|
|
|
return data; |
|
|
|
})).collect(Collectors.toList()); |
|
|
|
})).collect(Collectors.toList()); |
|
|
|
return result.stream().collect(Collectors.groupingBy(RobotRealDataVO::getModelClassifyName)); |
|
|
|
return result.stream().collect(Collectors.groupingBy(RobotRealDataVO::getModelClassifyName)); |
|
|
@ -134,7 +147,7 @@ public class RobotServiceImpl extends ServiceImpl<RobotMapper, RobotEntity> impl |
|
|
|
Result<Map<String, Object>> deviceSoeDataResult = deviceDataClient.getDeviceSoeData(robot.getStationCode(), 1, robotCode, null, |
|
|
|
Result<Map<String, Object>> deviceSoeDataResult = deviceDataClient.getDeviceSoeData(robot.getStationCode(), 1, robotCode, null, |
|
|
|
startTime, endTime, true, query.getCurrent(), query.getSize()); |
|
|
|
startTime, endTime, true, query.getCurrent(), query.getSize()); |
|
|
|
Assert.isTrue(deviceSoeDataResult.isSuccess(), () -> { |
|
|
|
Assert.isTrue(deviceSoeDataResult.isSuccess(), () -> { |
|
|
|
throw new ServiceException("获取机器人告警信息失败!"); |
|
|
|
throw new ServiceException(deviceSoeDataResult.getMsg()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
Map<String, Object> deviceSoeData = deviceSoeDataResult.getData(); |
|
|
|
Map<String, Object> deviceSoeData = deviceSoeDataResult.getData(); |
|
|
|
IPage result = Condition.getPage(query); |
|
|
|
IPage result = Condition.getPage(query); |
|
|
@ -143,5 +156,31 @@ public class RobotServiceImpl extends ServiceImpl<RobotMapper, RobotEntity> impl |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Object remoteControl(RemoteControlDTO dto) { |
|
|
|
|
|
|
|
ControlDTO controlDTO=new ControlDTO(); |
|
|
|
|
|
|
|
BeanUtil.copy(dto,controlDTO); |
|
|
|
|
|
|
|
controlDTO.setProjectId(dto.getStationCode()); |
|
|
|
|
|
|
|
controlDTO.setOperator(String.valueOf(AuthUtil.getUserId())); |
|
|
|
|
|
|
|
Result<Object> result = controlClient.sendToDevice(controlDTO); |
|
|
|
|
|
|
|
Assert.isTrue(result.isSuccess(),()->{ |
|
|
|
|
|
|
|
throw new ServiceException("修改遥控失败!"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RobotEntity robotEntity = this.getOne(new LambdaQueryWrapper<RobotEntity>().eq(RobotEntity::getCode, dto.getDeviceCode())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//机器人停机任务置为未完成
|
|
|
|
|
|
|
|
List<String> taskStatus = Arrays.asList(TaskContants.TaskStatusEnum.INIT_STATUS.getStatus(), TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus(), TaskContants.TaskStatusEnum.PAUSE_STATUS.getStatus()); |
|
|
|
|
|
|
|
ITaskService taskService = SpringUtil.getBean(ITaskService.class); |
|
|
|
|
|
|
|
List<TaskEntity> robotTaskEntities=taskService.getListByUserIdAndStatus(robotEntity.getUserId(),taskStatus,DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
if (!robotTaskEntities.isEmpty()){ |
|
|
|
|
|
|
|
robotTaskEntities.forEach(item->item.setStatus(Integer.valueOf(TaskContants.TaskStatusEnum.UNFINISH_STATUS.getStatus()))); |
|
|
|
|
|
|
|
taskService.saveOrUpdateBatch(robotTaskEntities); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result.getData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|