|
|
@ -1,31 +1,31 @@ |
|
|
|
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.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.device.IDeviceClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.Constants; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO; |
|
|
|
import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO; |
|
|
|
|
|
|
|
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.log.annotation.Business; |
|
|
|
import com.hnac.hzinfo.inspect.task.TaskContants; |
|
|
|
import com.hnac.hzinfo.log.annotation.Operate; |
|
|
|
import com.hnac.hzinfo.inspect.task.entity.TaskEntity; |
|
|
|
import com.hnac.hzinfo.log.contants.BusinessType; |
|
|
|
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; |
|
|
@ -35,20 +35,14 @@ import com.hnac.hzinfo.inspect.ai.mapper.RobotMapper; |
|
|
|
import com.hnac.hzinfo.inspect.ai.service.IRobotService; |
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -62,8 +56,9 @@ import java.util.stream.Collectors; |
|
|
|
public class RobotServiceImpl extends BaseServiceImpl<RobotMapper, RobotEntity> implements IRobotService { |
|
|
|
public class RobotServiceImpl extends BaseServiceImpl<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 获取 机器人信息 |
|
|
@ -87,6 +82,14 @@ public class RobotServiceImpl extends BaseServiceImpl<RobotMapper, RobotEntity> |
|
|
|
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); |
|
|
@ -151,5 +154,31 @@ public class RobotServiceImpl extends BaseServiceImpl<RobotMapper, RobotEntity> |
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|