机器人状态上报、下发任务过滤机器人上报的信息
This commit is contained in:
parent
64f0f0a32d
commit
d29261e7b8
@ -38,8 +38,13 @@ public class MqttCallBack implements MqttCallback {
|
||||
String msg = new String(mqttMessage.getPayload());
|
||||
// log.info("[MQTT]接收当前消息为 :{}", msg);
|
||||
|
||||
MqttService mqttService = MqttFactory.getMqttFactory(topic);
|
||||
mqttService.analysisMessage(msg);
|
||||
try {
|
||||
MqttService mqttService = MqttFactory.getMqttFactory(topic);
|
||||
mqttService.analysisMessage(msg);
|
||||
} catch (Exception e) {
|
||||
log.info("消费失败的消息主题 :{},消息内容 :{}", topic, msg);
|
||||
log.info("消费消息异常 :{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,4 +10,6 @@ public class RobotStatusDataPoseDTO {
|
||||
public String y;
|
||||
public String x;
|
||||
public String yaw;
|
||||
public String floor;
|
||||
public String area;
|
||||
}
|
||||
|
@ -220,4 +220,7 @@ public interface ErrorCodeConstants {
|
||||
// ========== 机器人告警信息 1_002_040_001==========
|
||||
ErrorCode WARN_MSG_NOT_EXISTS = new ErrorCode(1_002_040_001, "机器人告警信息不存在");
|
||||
|
||||
// ========== 机器人告警码值映射 1_002_041_001 ==========
|
||||
ErrorCode WARN_CODE_MAPPING_NOT_EXISTS = new ErrorCode(1_002_041_001, "机器人告警码值映射不存在");
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,31 @@
|
||||
package cn.iocoder.yudao.module.system.api.robot;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDTO;
|
||||
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataErrorDTO;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotStatusCodeConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnMsgDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnCodeMappingMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnMsgMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.RobotWarnType;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotInformationService;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@ -19,6 +35,18 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private RobotInformationService robotInformationService;
|
||||
|
||||
@Resource
|
||||
private RobotWarnCodeMappingMapper warnCodeMappingMapper;
|
||||
|
||||
@Resource
|
||||
private RobotWarnMsgMapper warnMsgMapper;
|
||||
|
||||
@Value("${zn.robot_position_cache_time:600}")
|
||||
private Long robotPositionCacheTime;
|
||||
|
||||
/**
|
||||
* 更新机器人点位/异常/能否做任务
|
||||
* @param robotStatusDataDTO
|
||||
@ -26,23 +54,59 @@ public class RobotStatusApiImpl implements RobotStatusApi {
|
||||
*/
|
||||
@Override
|
||||
public void robotStatusUpdate(RobotStatusDTO robotStatusDataDTO) {
|
||||
TenantContextHolder.setTenantId(1L);
|
||||
if (ObjectUtil.isNotNull(robotStatusDataDTO) || RobotStatusCodeConstant.OK.equals(robotStatusDataDTO.getStatus_code())
|
||||
|| ObjectUtil.isEmpty(robotStatusDataDTO.getMac())) {
|
||||
|
||||
}
|
||||
|
||||
String doTaskKey = RobotTaskChcheConstant.ROBOT_DO_TASK+robotStatusDataDTO.getMac();
|
||||
String haveTrayKey = RobotTaskChcheConstant.ROBOT_HAVE_TRAY+robotStatusDataDTO.getMac();
|
||||
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS +robotStatusDataDTO.getMac();
|
||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED +robotStatusDataDTO.getMac();
|
||||
String pose2dKey = RobotTaskChcheConstant.ROBOT_POSE2D+robotStatusDataDTO.getMac();
|
||||
redisUtil.set(doTaskKey, robotStatusDataDTO.getData().getTask_status(),10*60);
|
||||
redisUtil.set(haveTrayKey,robotStatusDataDTO.getData().getCargo_detected(),10*60);
|
||||
redisUtil.set(pose2dKey,String.valueOf(robotStatusDataDTO.getData().getCargo_detected()),10*60);
|
||||
redisUtil.set(taskStatusKey, robotStatusDataDTO.getData().getTask_status(),robotPositionCacheTime);
|
||||
redisUtil.set(cargoDetectedKey,robotStatusDataDTO.getData().getCargo_detected(),robotPositionCacheTime);
|
||||
redisUtil.set(pose2dKey,String.valueOf(robotStatusDataDTO.getData().getPose2d()),robotPositionCacheTime);
|
||||
|
||||
if (ObjectUtil.isNotNull(robotStatusDataDTO.getData().getErr_code())) {
|
||||
List<RobotStatusDataErrorDTO> errCode = robotStatusDataDTO.getData().getErr_code();
|
||||
String robotNo = robotInformationService.getRobotNoByMac(robotStatusDataDTO.getMac());
|
||||
if (ObjectUtil.isNull(robotNo)) {
|
||||
log.info("查不到机器人编号 :{}",robotStatusDataDTO.getMac());
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> warnCodes =
|
||||
errCode.stream().map(RobotStatusDataErrorDTO::getError_code).collect(Collectors.toList());
|
||||
List<RobotWarnCodeMappingDO> robotWarnCodeMappingDOS =
|
||||
warnCodeMappingMapper.selectList(new LambdaQueryWrapper<RobotWarnCodeMappingDO>()
|
||||
.in(RobotWarnCodeMappingDO::getWarnCode, warnCodes));
|
||||
if (ObjectUtil.isEmpty(robotWarnCodeMappingDOS)) {
|
||||
log.info("查不对应编号的告警信息 :{}", JSON.toJSONString(warnCodes));
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, List<RobotWarnCodeMappingDO>> warnCodeMapping =
|
||||
robotWarnCodeMappingDOS.stream().collect(Collectors.groupingBy(RobotWarnCodeMappingDO::getWarnCode));
|
||||
|
||||
List<RobotWarnMsgDO> warnMsgDOS = new ArrayList<>();
|
||||
|
||||
for (RobotStatusDataErrorDTO robotStatusData : errCode) {
|
||||
List<RobotWarnCodeMappingDO> mappingDOS = warnCodeMapping.get(robotStatusData.getError_code());
|
||||
if (ObjectUtil.isEmpty(mappingDOS)) {
|
||||
log.info("当前告警类型查不到对应的告警信息 :{}",robotStatusData.getError_code());
|
||||
continue;
|
||||
}
|
||||
RobotWarnMsgDO warnMsg = RobotWarnMsgDO.builder().warnLevel(Integer.valueOf(robotStatusData.getCode_level()))
|
||||
.warnCode(robotStatusData.getError_code())
|
||||
.robotNo(robotNo)
|
||||
.warnType(RobotWarnType.ROBOT_WARN.getType())
|
||||
.warnMsg(mappingDOS.get(0).getWarnMsg())
|
||||
.warnSolve(mappingDOS.get(0).getWarnSolve())
|
||||
.build();
|
||||
warnMsgDOS.add(warnMsg);
|
||||
}
|
||||
warnMsgMapper.insertBatch(warnMsgDOS);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,10 +5,10 @@ public class RobotTaskChcheConstant {
|
||||
public static String ROBOT_ELECTRICITY = "robot:information:electricity";
|
||||
|
||||
//机器人能否做任务
|
||||
public static String ROBOT_DO_TASK = "robot:information:do:task";
|
||||
public static String ROBOT_TASK_STATUS = "robot:information:task:status";
|
||||
|
||||
//机器人身上是否有货
|
||||
public static String ROBOT_HAVE_TRAY = "robot:information:have:tray";
|
||||
public static String ROBOT_CARGO_DETECTED = "robot:information:cargo:detected";
|
||||
|
||||
//机器人点位
|
||||
public static String ROBOT_POSE2D = "robot:information:pose2d";
|
||||
|
@ -0,0 +1,97 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.robot;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotWarnCodeMappingService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 机器人告警码值映射")
|
||||
@RestController
|
||||
@RequestMapping("/robot/warn-code-mapping")
|
||||
@Validated
|
||||
public class RobotWarnCodeMappingController {
|
||||
|
||||
@Resource
|
||||
private RobotWarnCodeMappingService warnCodeMappingService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建机器人告警码值映射")
|
||||
@PreAuthorize("@ss.hasPermission('robot:warn-code-mapping:create')")
|
||||
public CommonResult<Long> createWarnCodeMapping(@Valid @RequestBody RobotWarnCodeMappingSaveReqVO createReqVO) {
|
||||
return success(warnCodeMappingService.createWarnCodeMapping(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新机器人告警码值映射")
|
||||
@PreAuthorize("@ss.hasPermission('robot:warn-code-mapping:update')")
|
||||
public CommonResult<Boolean> updateWarnCodeMapping(@Valid @RequestBody RobotWarnCodeMappingSaveReqVO updateReqVO) {
|
||||
warnCodeMappingService.updateWarnCodeMapping(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除机器人告警码值映射")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('robot:warn-code-mapping:delete')")
|
||||
public CommonResult<Boolean> deleteWarnCodeMapping(@RequestParam("id") Long id) {
|
||||
warnCodeMappingService.deleteWarnCodeMapping(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得机器人告警码值映射")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('robot:warn-code-mapping:query')")
|
||||
public CommonResult<RobotWarnCodeMappingRespVO> getWarnCodeMapping(@RequestParam("id") Long id) {
|
||||
RobotWarnCodeMappingDO warnCodeMapping = warnCodeMappingService.getWarnCodeMapping(id);
|
||||
return success(BeanUtils.toBean(warnCodeMapping, RobotWarnCodeMappingRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得机器人告警码值映射分页")
|
||||
@PreAuthorize("@ss.hasPermission('robot:warn-code-mapping:query')")
|
||||
public CommonResult<PageResult<RobotWarnCodeMappingRespVO>> getWarnCodeMappingPage(@Valid RobotWarnCodeMappingPageReqVO pageReqVO) {
|
||||
PageResult<RobotWarnCodeMappingDO> pageResult = warnCodeMappingService.getWarnCodeMappingPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, RobotWarnCodeMappingRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出机器人告警码值映射 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('robot:warn-code-mapping:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportWarnCodeMappingExcel(@Valid RobotWarnCodeMappingPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<RobotWarnCodeMappingDO> list = warnCodeMappingService.getWarnCodeMappingPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "机器人告警码值映射.xls", "数据", RobotWarnCodeMappingRespVO.class,
|
||||
BeanUtils.toBean(list, RobotWarnCodeMappingRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.robot.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 机器人告警码值映射分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class RobotWarnCodeMappingPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "告警等级 (1,2,3,4)")
|
||||
private Integer warnLevel;
|
||||
|
||||
@Schema(description = "能不能继续做任务 (0:不能, 1:能)")
|
||||
private Integer doTask;
|
||||
|
||||
@Schema(description = "告警编号")
|
||||
private String warnCode;
|
||||
|
||||
@Schema(description = "告警信息")
|
||||
private String warnMsg;
|
||||
|
||||
@Schema(description = "告警解决方法")
|
||||
private String warnSolve;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.robot.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 机器人告警码值映射 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class RobotWarnCodeMappingRespVO {
|
||||
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15754")
|
||||
@ExcelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "告警等级 (1,2,3,4)")
|
||||
@ExcelProperty("告警等级 (1,2,3,4)")
|
||||
private Integer warnLevel;
|
||||
|
||||
@Schema(description = "能不能继续做任务 (0:不能, 1:能)")
|
||||
@ExcelProperty("能不能继续做任务 (0:不能, 1:能)")
|
||||
private Integer doTask;
|
||||
|
||||
@Schema(description = "告警编号")
|
||||
@ExcelProperty("告警编号")
|
||||
private String warnCode;
|
||||
|
||||
@Schema(description = "告警信息")
|
||||
@ExcelProperty("告警信息")
|
||||
private String warnMsg;
|
||||
|
||||
@Schema(description = "告警解决方法")
|
||||
@ExcelProperty("告警解决方法")
|
||||
private String warnSolve;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.robot.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 机器人告警码值映射新增/修改 Request VO")
|
||||
@Data
|
||||
public class RobotWarnCodeMappingSaveReqVO {
|
||||
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15754")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "告警等级 (1,2,3,4)")
|
||||
private Integer warnLevel;
|
||||
|
||||
@Schema(description = "能不能继续做任务 (0:不能, 1:能)")
|
||||
private Integer doTask;
|
||||
|
||||
@Schema(description = "告警编号")
|
||||
private String warnCode;
|
||||
|
||||
@Schema(description = "告警信息")
|
||||
private String warnMsg;
|
||||
|
||||
@Schema(description = "告警解决方法")
|
||||
private String warnSolve;
|
||||
|
||||
}
|
@ -21,6 +21,9 @@ public class RobotWarnMsgPageReqVO extends PageParam {
|
||||
@Schema(description = "告警等级 (1,2,3,4)")
|
||||
private Integer warnLevel;
|
||||
|
||||
@Schema(description = "告警类型 (1:告警, 2:用户操作)")
|
||||
private Integer warnType;
|
||||
|
||||
@Schema(description = "告警编号")
|
||||
private String warnCode;
|
||||
|
||||
|
@ -24,6 +24,10 @@ public class RobotWarnMsgRespVO {
|
||||
@ExcelProperty("告警等级 (1,2,3,4)")
|
||||
private Integer warnLevel;
|
||||
|
||||
@Schema(description = "告警类型 (1:告警, 2:用户操作)")
|
||||
@ExcelProperty("告警类型 (1:告警, 2:用户操作)")
|
||||
private Integer warnType;
|
||||
|
||||
@Schema(description = "告警编号")
|
||||
@ExcelProperty("告警编号")
|
||||
private String warnCode;
|
||||
|
@ -20,6 +20,9 @@ public class RobotWarnMsgSaveReqVO {
|
||||
@Schema(description = "告警等级 (1,2,3,4)")
|
||||
private Integer warnLevel;
|
||||
|
||||
@Schema(description = "告警类型 (1:告警, 2:用户操作)")
|
||||
private Integer warnType;
|
||||
|
||||
@Schema(description = "告警编号")
|
||||
private String warnCode;
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.robot;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 机器人告警码值映射 DO
|
||||
*
|
||||
* @author 陈宾顺
|
||||
*/
|
||||
@TableName("robot_warn_code_mapping")
|
||||
@KeySequence("robot_warn_code_mapping_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RobotWarnCodeMappingDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 告警等级 (1,2,3,4)
|
||||
*/
|
||||
private Integer warnLevel;
|
||||
/**
|
||||
* 能不能继续做任务 (0:不能, 1:能)
|
||||
*/
|
||||
private Integer doTask;
|
||||
/**
|
||||
* 告警编号
|
||||
*/
|
||||
private String warnCode;
|
||||
/**
|
||||
* 告警信息
|
||||
*/
|
||||
private String warnMsg;
|
||||
/**
|
||||
* 告警解决方法
|
||||
*/
|
||||
private String warnSolve;
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ public class RobotWarnMsgDO extends BaseDO {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* AGV编号
|
||||
@ -36,6 +36,10 @@ public class RobotWarnMsgDO extends BaseDO {
|
||||
* 告警等级 (1,2,3,4)
|
||||
*/
|
||||
private Integer warnLevel;
|
||||
/**
|
||||
* 告警类型 (1:告警, 2:用户操作)
|
||||
*/
|
||||
private Integer warnType;
|
||||
/**
|
||||
* 告警编号
|
||||
*/
|
||||
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.robot;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 机器人告警码值映射 Mapper
|
||||
*
|
||||
* @author 陈宾顺
|
||||
*/
|
||||
@Mapper
|
||||
public interface RobotWarnCodeMappingMapper extends BaseMapperX<RobotWarnCodeMappingDO> {
|
||||
|
||||
default PageResult<RobotWarnCodeMappingDO> selectPage(RobotWarnCodeMappingPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<RobotWarnCodeMappingDO>()
|
||||
.eqIfPresent(RobotWarnCodeMappingDO::getWarnLevel, reqVO.getWarnLevel())
|
||||
.eqIfPresent(RobotWarnCodeMappingDO::getDoTask, reqVO.getDoTask())
|
||||
.eqIfPresent(RobotWarnCodeMappingDO::getWarnCode, reqVO.getWarnCode())
|
||||
.eqIfPresent(RobotWarnCodeMappingDO::getWarnMsg, reqVO.getWarnMsg())
|
||||
.eqIfPresent(RobotWarnCodeMappingDO::getWarnSolve, reqVO.getWarnSolve())
|
||||
.betweenIfPresent(RobotWarnCodeMappingDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(RobotWarnCodeMappingDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.system.enums.robot;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* robot_warn_msg的告警类型 (1:告警, 2:用户操作)
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum RobotWarnType {
|
||||
|
||||
ROBOT_WARN(1),//告警
|
||||
USER_OPERATE(2);//用户操作
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final Integer type;
|
||||
|
||||
}
|
@ -200,6 +200,7 @@ public class RobotInformationServiceImpl implements RobotInformationService {
|
||||
.eq(RobotInformationDO::getMacAddress, mac)
|
||||
.last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(robotInformationDO)) {
|
||||
redisUtil.set(RobotTaskChcheConstant.ROBOT_NO_MAPPING_MAC + mac,robotInformationDO.getRobotNo());
|
||||
return robotInformationDO.getRobotNo();
|
||||
}
|
||||
return "";
|
||||
|
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.system.service.robot;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
|
||||
/**
|
||||
* 机器人告警码值映射 Service 接口
|
||||
*
|
||||
* @author 陈宾顺
|
||||
*/
|
||||
public interface RobotWarnCodeMappingService {
|
||||
|
||||
/**
|
||||
* 创建机器人告警码值映射
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createWarnCodeMapping(@Valid RobotWarnCodeMappingSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新机器人告警码值映射
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateWarnCodeMapping(@Valid RobotWarnCodeMappingSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除机器人告警码值映射
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteWarnCodeMapping(Long id);
|
||||
|
||||
/**
|
||||
* 获得机器人告警码值映射
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 机器人告警码值映射
|
||||
*/
|
||||
RobotWarnCodeMappingDO getWarnCodeMapping(Long id);
|
||||
|
||||
/**
|
||||
* 获得机器人告警码值映射分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 机器人告警码值映射分页
|
||||
*/
|
||||
PageResult<RobotWarnCodeMappingDO> getWarnCodeMappingPage(RobotWarnCodeMappingPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.system.service.robot;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnCodeMappingSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnCodeMappingMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.WARN_CODE_MAPPING_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 机器人告警码值映射 Service 实现类
|
||||
*
|
||||
* @author 陈宾顺
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class RobotWarnCodeMappingServiceImpl implements RobotWarnCodeMappingService {
|
||||
|
||||
@Resource
|
||||
private RobotWarnCodeMappingMapper warnCodeMappingMapper;
|
||||
|
||||
@Override
|
||||
public Long createWarnCodeMapping(RobotWarnCodeMappingSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
RobotWarnCodeMappingDO warnCodeMapping = BeanUtils.toBean(createReqVO, RobotWarnCodeMappingDO.class);
|
||||
warnCodeMappingMapper.insert(warnCodeMapping);
|
||||
// 返回
|
||||
return warnCodeMapping.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWarnCodeMapping(RobotWarnCodeMappingSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateWarnCodeMappingExists(updateReqVO.getId());
|
||||
// 更新
|
||||
RobotWarnCodeMappingDO updateObj = BeanUtils.toBean(updateReqVO, RobotWarnCodeMappingDO.class);
|
||||
warnCodeMappingMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWarnCodeMapping(Long id) {
|
||||
// 校验存在
|
||||
validateWarnCodeMappingExists(id);
|
||||
// 删除
|
||||
warnCodeMappingMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateWarnCodeMappingExists(Long id) {
|
||||
if (warnCodeMappingMapper.selectById(id) == null) {
|
||||
throw exception(WARN_CODE_MAPPING_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RobotWarnCodeMappingDO getWarnCodeMapping(Long id) {
|
||||
return warnCodeMappingMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<RobotWarnCodeMappingDO> getWarnCodeMappingPage(RobotWarnCodeMappingPageReqVO pageReqVO) {
|
||||
return warnCodeMappingMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.mqtt.api.task.RobotTaskApi;
|
||||
import cn.iocoder.yudao.module.mqtt.api.task.dto.Pose2ds;
|
||||
import cn.iocoder.yudao.module.mqtt.api.task.dto.RobotAcceptTaskDTO;
|
||||
import cn.iocoder.yudao.module.mqtt.api.task.dto.RobotAcceptTaskData;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
|
||||
@ -17,9 +18,9 @@ import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotInformationMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.*;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.tuple.ImmutableTriple;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -72,6 +73,14 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
||||
@Resource
|
||||
private WareHouseLocationMapper locationMapper;
|
||||
|
||||
//货物到位传感器触发状态:被按下则 true,否则 false
|
||||
private static Boolean CARGO_DETECTED = true;
|
||||
//IDLE 和 RUNNING
|
||||
private static String TASK_STATUS = "RUNNING";
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 下发搬运任务
|
||||
*/
|
||||
@ -112,7 +121,30 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
||||
return pair;
|
||||
}
|
||||
|
||||
//todo 还需要根据车机上报的信息,过滤掉不能用的机器人
|
||||
for (RobotInformationDO robot : robots) {
|
||||
String taskStatusKey = RobotTaskChcheConstant.ROBOT_TASK_STATUS +robot.getMacAddress();
|
||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED +robot.getMacAddress();
|
||||
Object taskStatus = redisUtil.get(taskStatusKey);
|
||||
if (ObjectUtil.isEmpty(taskStatus) || TASK_STATUS.equals(taskStatus.toString())) {
|
||||
robot.setRobotStatus(RobotStatusEnum.DOING.getType());
|
||||
continue;
|
||||
}
|
||||
|
||||
Object cargoDetected = redisUtil.get(cargoDetectedKey);
|
||||
if (ObjectUtil.isEmpty(cargoDetected) || CARGO_DETECTED.equals(cargoDetected)) {
|
||||
robot.setRobotStatus(RobotStatusEnum.DOING.getType());
|
||||
}
|
||||
}
|
||||
|
||||
robots = robots.stream()
|
||||
.filter(v -> RobotStatusEnum.STAND_BY.getType().equals(v.getRobotStatus()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (robots.isEmpty()) {
|
||||
log.info("暂无可用的机器人");
|
||||
return pair;
|
||||
}
|
||||
|
||||
|
||||
//拼接任务id
|
||||
List<Long> detailDongIds = robotTaskDetailMapper.getDoingTaskIds();
|
||||
|
@ -226,4 +226,5 @@ zn:
|
||||
parm: 5000 #等待时间
|
||||
lift_height: 0.1 #抬高托盘高度
|
||||
move_height: 0.1 #行走高度
|
||||
lane_auto_move: true #线库是否自动移库 true:线库执行自动移库 、false:线库关闭执行自动移库
|
||||
lane_auto_move: true #线库是否自动移库 true:线库执行自动移库 、false:线库关闭执行自动移库
|
||||
robot_position_cache_time: 600 #机器人上报点位存储时间
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnCodeMappingMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnMsgMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user