车辆信息状态
This commit is contained in:
parent
12eb16047c
commit
c381315892
@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -28,6 +29,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.module.system.config.SystemJobConfiguration.NOTIFY_THREAD_POOL_TASK_EXECUTOR;
|
||||
|
||||
@Slf4j
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
@ -48,12 +51,16 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
@Value("${zn.robot_position_cache_time:600}")
|
||||
private Long robotPositionCacheTime;
|
||||
|
||||
@Value("${zn.robot_error_level_time:30}")
|
||||
private Long robotErrorLevelTime;
|
||||
|
||||
/**
|
||||
* 更新机器人点位/异常/能否做任务
|
||||
* @param robotStatusDataDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Async(NOTIFY_THREAD_POOL_TASK_EXECUTOR)
|
||||
public void robotStatusUpdate(RobotStatusDTO robotStatusDataDTO) {
|
||||
TenantContextHolder.setTenantId(1L);
|
||||
if (ObjectUtil.isEmpty(robotStatusDataDTO) || ObjectUtil.isEmpty(robotStatusDataDTO.getMac())) {
|
||||
@ -99,7 +106,17 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
|
||||
List<RobotWarnMsgDO> warnMsgDOS = new ArrayList<>();
|
||||
|
||||
//机器人异常等级
|
||||
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL +robotStatusDataDTO.getMac();
|
||||
Object errorLevel = redisUtil.get(errorLevelKey);
|
||||
|
||||
Integer level = ObjectUtil.isEmpty(errorLevel) ? 0 : Integer.valueOf(errorLevel.toString());
|
||||
|
||||
for (RobotStatusDataErrorDTO robotStatusData : errCode) {
|
||||
if (level.intValue() < Integer.valueOf(robotStatusData.getCode_level()).intValue()) {
|
||||
level = Integer.valueOf(robotStatusData.getCode_level());
|
||||
}
|
||||
|
||||
List<RobotWarnCodeMappingDO> mappingDOS = warnCodeMapping.get(robotStatusData.getError_code());
|
||||
if (ObjectUtil.isEmpty(mappingDOS)) {
|
||||
log.info("当前告警类型查不到对应的告警信息 :{}",robotStatusData.getError_code());
|
||||
@ -114,6 +131,8 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
.build();
|
||||
warnMsgDOS.add(warnMsg);
|
||||
}
|
||||
redisUtil.set(errorLevelKey,level,robotErrorLevelTime);
|
||||
|
||||
warnMsgMapper.insertBatch(warnMsgDOS);
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,7 @@ public class RobotTaskChcheConstant {
|
||||
|
||||
//机器人充电模式 1:自动充电、2:机会充电、3:充满电 (拼接的是机器人编号)
|
||||
public static String ROBOT_CHARGE_MODEL = "robot:information:charge:model";
|
||||
|
||||
//机器人异常等级 (拼接的是mac地址)
|
||||
public static String ROBOT_ERROR_LEVEL = "robot:information:error:level";
|
||||
}
|
||||
|
@ -114,4 +114,12 @@ public class RobotInformationController {
|
||||
return success(BeanUtils.toBean(result, RobotInformationRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得车辆信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('robot:information:list')")
|
||||
public CommonResult<PageResult<RobotInformationPageRespVO>> getRobotList(@Valid RobotInformationPageReqVO pageReqVO) {
|
||||
pageReqVO.setPageSize(300);
|
||||
PageResult<RobotInformationPageRespVO> pageResult = informationService.getInformationPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, RobotInformationPageRespVO.class));
|
||||
}
|
||||
}
|
@ -36,8 +36,24 @@ public class RobotInformationPageRespVO {
|
||||
@ExcelProperty("电量")
|
||||
private String electricity;
|
||||
|
||||
@Schema(description = "状态(0:待命、1:任务中、2:锁定、3:离线、4:充电中、5:故障)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("状态(0:待命、1:任务中、2:锁定、3:离线、4:充电中、5:故障)")
|
||||
@Schema(description = "在线状态/离线状态(0:离线、1:在线)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("在线状态/离线状态(0:离线、1:在线)")
|
||||
private Integer onlineStatus = 0;
|
||||
|
||||
@Schema(description = "车机状态(0:空闲、1:锁定、2:异常)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("车机状态(0:空闲、1:锁定、2:异常)")
|
||||
private Integer robotEssenceStatus = 0;
|
||||
|
||||
@Schema(description = "任务状态(0:待命中、1:处理中、2:充电中)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("任务状态(0:待命中、1:处理中、2:充电中)")
|
||||
private Integer robotTaskStatus = 0;
|
||||
|
||||
@Schema(description = "异常等级(0,1,2,3,4)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("异常等级(0,1,2,3,4)")
|
||||
private Integer robotCodeLevel = 0;
|
||||
|
||||
@Schema(description = "AGV状态(0:暂停且无任务、1:暂停(有处理中的任务)、2:任务中、3:待命)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("AGV状态(0:暂停且无任务、1:暂停(有处理中的任务)、2:任务中、3:待命)")
|
||||
private Integer robotStatus;
|
||||
|
||||
@Schema(description = "自动充电电量")
|
||||
@ -58,7 +74,7 @@ public class RobotInformationPageRespVO {
|
||||
@Schema(description = "mac地址")
|
||||
private String macAddress;
|
||||
|
||||
@Schema(description = "任务模式(0:拒收任务、1:正常)")
|
||||
@Schema(description = "任务模式(0:拒收任务(锁定)、1:正常)")
|
||||
private Integer robotTaskModel;
|
||||
|
||||
@Schema(description = "楼层/区域(json)")
|
||||
|
@ -171,38 +171,37 @@ public class RobotInformationServiceImpl implements RobotInformationService {
|
||||
v.setElectricity(robotStatusDataPoseDTO.getBat_soc());
|
||||
v.setFloor(robotStatusDataPoseDTO.getFloor());
|
||||
v.setArea(robotStatusDataPoseDTO.getArea());
|
||||
}else if (ObjectUtil.isEmpty(object)) {
|
||||
//离线
|
||||
v.setOnlineStatus(1);
|
||||
}
|
||||
|
||||
if (RobotTaskModelEnum.REJECTION.getType().equals(v.getRobotTaskModel())) {
|
||||
v.setRobotStatus(RobotInformationPageStatusEnum.DOLOCK.getType());
|
||||
v.setMsg("车辆已经锁定");
|
||||
}else if (ObjectUtil.isEmpty(object)) {
|
||||
v.setRobotStatus(RobotInformationPageStatusEnum.OFFLINE.getType());
|
||||
v.setMsg("车辆已经离线");
|
||||
}else if (RobotStatusEnum.STAND_BY.getType().equals(v.getRobotStatus())) {
|
||||
//查看机器人最后做的任务是不是充电
|
||||
RobotTaskDetailDO robotTaskDetailDO = taskDetailMapper.selectOne(new LambdaQueryWrapper<RobotTaskDetailDO>()
|
||||
.eq(RobotTaskDetailDO::getRobotNo, v.getRobotNo())
|
||||
.orderByDesc(RobotTaskDetailDO::getCreateTime)
|
||||
.last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(robotTaskDetailDO)
|
||||
&& RobotTaskTypeEnum.CHARGE.getType().equals(robotTaskDetailDO.getTaskType())
|
||||
&& RobotTaskStatusEnum.DOING.getType().equals(robotTaskDetailDO.getTaskStatus())) {
|
||||
v.setRobotStatus(RobotInformationPageStatusEnum.CHARGE.getType());
|
||||
v.setMsg("车辆正在充电");
|
||||
}else {
|
||||
v.setRobotStatus(RobotInformationPageStatusEnum.STANDBY.getType());
|
||||
v.setMsg("车辆正在待命");
|
||||
v.setRobotEssenceStatus(v.getRobotTaskModel());
|
||||
//设置异常
|
||||
String errorLevelKey = RobotTaskChcheConstant.ROBOT_ERROR_LEVEL +v.getMacAddress();
|
||||
Object errorLevel = redisUtil.get(errorLevelKey);
|
||||
if (ObjectUtil.isNotEmpty(errorLevel) && Integer.valueOf(errorLevel.toString()).intValue() >= 3) {
|
||||
v.setRobotEssenceStatus(2);
|
||||
}
|
||||
|
||||
if (RobotStatusEnum.STAND_BY.getType().equals(v.getRobotStatus())) {
|
||||
//待命中
|
||||
v.setRobotTaskStatus(0);
|
||||
v.setMsg("车辆正在待命中");
|
||||
}else if (RobotStatusEnum.CHARGE.getType().equals(v.getRobotStatus())) {
|
||||
//充电中
|
||||
v.setRobotTaskStatus(2);
|
||||
v.setMsg("车辆正在充电");
|
||||
}else {
|
||||
//任务中
|
||||
v.setRobotTaskStatus(1);
|
||||
if (RobotStatusEnum.DOING.getType().equals(v.getRobotStatus()) && ObjectUtil.isNotEmpty(action)) {
|
||||
v.setRobotStatus(1);
|
||||
CommandTypeEnum commandType = CommandTypeEnum.getCommandType(String.valueOf(action));
|
||||
if (ObjectUtil.isNotEmpty(commandType)) {
|
||||
v.setMsg("车辆正在"+commandType.getMsg());
|
||||
}
|
||||
}
|
||||
}else if (RobotStatusEnum.DOING.getType().equals(v.getRobotStatus()) && ObjectUtil.isNotEmpty(action)) {
|
||||
v.setRobotStatus(RobotInformationPageStatusEnum.INTASK.getType());
|
||||
CommandTypeEnum commandType = CommandTypeEnum.getCommandType(String.valueOf(action));
|
||||
if (ObjectUtil.isNotEmpty(commandType)) {
|
||||
v.setMsg("车辆正在"+commandType.getMsg());
|
||||
}
|
||||
} else {
|
||||
v.setRobotStatus(RobotInformationPageStatusEnum.FAULT.getType());
|
||||
v.setMsg("车辆发生异常");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -227,6 +227,7 @@ zn:
|
||||
lift_height: 0.1 #抬高托盘高度
|
||||
move_height: 0.1 #行走高度
|
||||
lane_auto_move: true #线库是否自动移库 true:线库执行自动移库 、false:线库关闭执行自动移库
|
||||
robot_position_cache_time: 10 #机器人上报点位存储时间
|
||||
robot_position_cache_time: 10 #机器人上报点位存储时间(秒)
|
||||
cycle_do_auto_move: true #存在循环的任务,是否开启自动移库. true:存在循环任务,开启自动移库; false:有循环任务不自动移库
|
||||
full_electricity: 100 #机器人充满电的电量
|
||||
full_electricity: 100 #机器人充满电的电量
|
||||
robot_error_level_time: 30 #机器人异常存储时间(秒)
|
Loading…
Reference in New Issue
Block a user