任务下发校验
This commit is contained in:
parent
3479492b3d
commit
b0ac304a8f
@ -31,7 +31,7 @@
|
||||
<!-- 启动服务时,是否清理历史日志,一般不建议清理 -->
|
||||
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
|
||||
<!-- 日志文件,到达多少容量,进行滚动 -->
|
||||
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<!-- 日志文件的总大小,0 表示不限制 -->
|
||||
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
|
||||
<!-- 日志文件的保留天数 -->
|
||||
|
@ -62,7 +62,7 @@ public class RobotReactiveStatusApiImpl implements RobotReactiveStatusApi {
|
||||
@Override
|
||||
public void robotReactiveStatus(String message) {
|
||||
TenantContextHolder.setTenantId(1L);
|
||||
log.info("车辆所在楼层和异常信息 :{}", message);
|
||||
// log.info("车辆所在楼层和异常信息 :{}", message);
|
||||
RobotReactiveStatusDTO data = JSON.parseObject(message, RobotReactiveStatusDTO.class);
|
||||
String floorAreaKey = RobotTaskChcheConstant.ROBOT_FLOOR_AREA + data.getMac();
|
||||
String robotNo = robotInformationService.getRobotNoByMac(data.getMac());
|
||||
|
@ -47,7 +47,7 @@ public class RequestProcessor {
|
||||
private void sendData(String map, Map<String, String> data) {
|
||||
// -- 发送给对应的websocket
|
||||
// System.out.println("key:" + map + "发送数据:" + data);
|
||||
log.info("key:" + map + "发送数据:" + data);
|
||||
// log.info("key:" + map + "发送数据:" + data);
|
||||
webSocketSenderApi.sendObject(map, WebSocketConstant.MAP_PUSH, data);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class DeviceInformationPageReqVO extends PageParam {
|
||||
@Schema(description = "深度")
|
||||
private BigDecimal locationDeep;
|
||||
|
||||
//1:充电桩,2:输送线,3:码垛机,4:自动门,5:提升机,6:信号灯,7:按钮盒,8:拆垛机
|
||||
//1:充电桩,2:输送线,3:码垛机,4:自动门,5:提升机,6:信号灯,7:按钮盒,8:拆垛机, 9:摄像头
|
||||
@Schema(description = "设备类型 字典device_type", example = "2")
|
||||
private Integer deviceType;
|
||||
|
||||
@ -89,4 +89,7 @@ public class DeviceInformationPageReqVO extends PageParam {
|
||||
@Schema(description = "最后使用者")
|
||||
private String lastUser;
|
||||
|
||||
@Schema(description = "摄像头类型(1 枪机 2半球 3球机 4云台枪机)")
|
||||
private String cameraType;
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class DeviceInformationRespVO {
|
||||
@ExcelProperty("深度")
|
||||
private BigDecimal locationDeep;
|
||||
|
||||
//1:充电桩,2:输送线,3:码垛机,4:自动门,5:提升机,6:信号灯,7:按钮盒,8:拆垛机
|
||||
//1:充电桩,2:输送线,3:码垛机,4:自动门,5:提升机,6:信号灯,7:按钮盒,8:拆垛机, 9:摄像头
|
||||
@Schema(description = "设备类型 字典device_type", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("设备类型 字典device_type")
|
||||
private Integer deviceType;
|
||||
@ -120,4 +120,8 @@ public class DeviceInformationRespVO {
|
||||
@ExcelProperty("最后使用者")
|
||||
private String lastUser;
|
||||
|
||||
@Schema(description = "摄像头类型(1 枪机 2半球 3球机 4云台枪机)")
|
||||
@ExcelProperty("摄像头类型(1 枪机 2半球 3球机 4云台枪机)")
|
||||
private String cameraType;
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class DeviceInformationSaveReqVO {
|
||||
@Schema(description = "深度")
|
||||
private BigDecimal locationDeep;
|
||||
|
||||
//1:充电桩,2:输送线,3:码垛机,4:自动门,5:提升机,6:信号灯,7:按钮盒,8:拆垛机
|
||||
//1:充电桩,2:输送线,3:码垛机,4:自动门,5:提升机,6:信号灯,7:按钮盒,8:拆垛机 9:摄像头
|
||||
@Schema(description = "设备类型 字典device_type", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "设备类型不能为空")
|
||||
private Integer deviceType;
|
||||
@ -89,4 +89,7 @@ public class DeviceInformationSaveReqVO {
|
||||
@Schema(description = "最后使用者")
|
||||
private String lastUser;
|
||||
|
||||
@Schema(description = "摄像头类型(1 枪机 2半球 3球机 4云台枪机)")
|
||||
private String cameraType;
|
||||
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class DeviceInformationDO extends BaseDO {
|
||||
*/
|
||||
private BigDecimal locationDeep;
|
||||
/**
|
||||
* 1:充电桩,2:输送线,3:码垛机,4:自动门,5:提升机,6:信号灯,7:按钮盒,8:拆垛机
|
||||
* 1:充电桩,2:输送线,3:码垛机,4:自动门,5:提升机,6:信号灯,7:按钮盒,8:拆垛机, 9:摄像头
|
||||
* 设备类型 字典device_type
|
||||
*/
|
||||
private Integer deviceType;
|
||||
@ -135,4 +135,8 @@ public class DeviceInformationDO extends BaseDO {
|
||||
*/
|
||||
private String lastUser;
|
||||
|
||||
/**
|
||||
* 摄像头类型(1 枪机 2半球 3球机 4云台枪机)
|
||||
*/
|
||||
private String cameraType;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ public class PositionMapDO extends BaseDO {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 楼层
|
||||
|
@ -14,7 +14,8 @@ public enum DeviceTypeEnum {
|
||||
HOIST(5, "提升机"),
|
||||
SIGNAL_LIGHT(6, "信号灯"),
|
||||
BUTTON_BOX(7, "按钮盒"),
|
||||
DISMANTLING_MACHINE(8, "拆垛机");
|
||||
DISMANTLING_MACHINE(8, "拆垛机"),
|
||||
CAMERA(9, "摄像头");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
|
@ -32,6 +32,7 @@ import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
||||
import cn.iocoder.yudao.module.system.service.log.UserOperationLogService;
|
||||
import cn.iocoder.yudao.module.system.service.positionmap.PositionMapItemService;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotWarnMsgService;
|
||||
import cn.iocoder.yudao.module.system.util.aes.AESEncryptionUtil;
|
||||
import cn.iocoder.yudao.module.system.util.modbus3.ModbusUtils;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@ -42,6 +43,7 @@ import com.serotonin.modbus4j.ModbusMaster;
|
||||
import com.serotonin.modbus4j.exception.ModbusInitException;
|
||||
import com.serotonin.modbus4j.exception.ModbusTransportException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -92,6 +94,9 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
@Resource
|
||||
private PositionMapItemService positionMapItemService;
|
||||
|
||||
@Value("${zn.camera_secret_key}")
|
||||
private String cameraSecretKey;
|
||||
|
||||
@Override
|
||||
public Long createInformation(DeviceInformationSaveReqVO createReqVO) {
|
||||
// -- 先判断库里是否有相通的mac地址数据
|
||||
@ -110,6 +115,13 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
createReqVO.setUrl(dictDataDO.getRemark());
|
||||
}
|
||||
|
||||
if (DeviceTypeEnum.CAMERA.getType().equals(createReqVO.getDeviceType())) {
|
||||
try {
|
||||
createReqVO.setDeviceNo(AESEncryptionUtil.getEncrypt(createReqVO.getDeviceNo(), cameraSecretKey));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
// 插入
|
||||
DeviceInformationDO information = BeanUtils.toBean(createReqVO, DeviceInformationDO.class);
|
||||
information.setDeviceStatus(1);
|
||||
@ -138,6 +150,13 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
updateReqVO.setUrl(dictDataDO.getRemark());
|
||||
}
|
||||
// 更新
|
||||
if (DeviceTypeEnum.CAMERA.getType().equals(updateReqVO.getDeviceType())) {
|
||||
try {
|
||||
updateReqVO.setDeviceNo(AESEncryptionUtil.getEncrypt(updateReqVO.getDeviceNo(), cameraSecretKey));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
DeviceInformationDO updateObj = BeanUtils.toBean(updateReqVO, DeviceInformationDO.class);
|
||||
informationMapper.updateById(updateObj);
|
||||
|
||||
@ -150,11 +169,11 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
data.setMapImageUrl(updateObj.getMapImageUrl());*/
|
||||
|
||||
Gson gson = new Gson();
|
||||
Map<Object,Object> map = new HashMap();
|
||||
Map<Object, Object> map = new HashMap();
|
||||
map = gson.fromJson(dataJson, map.getClass());
|
||||
map.put("deviceType",updateObj.getDeviceType());
|
||||
map.put("deviceNo",updateObj.getDeviceNo());
|
||||
map.put("mapImageUrl",updateObj.getMapImageUrl());
|
||||
map.put("deviceType", updateObj.getDeviceType());
|
||||
map.put("deviceNo", updateObj.getDeviceNo());
|
||||
map.put("mapImageUrl", updateObj.getMapImageUrl());
|
||||
|
||||
positionMapItem.setDataJson(JSON.toJSONString(map));
|
||||
positionMapItemService.updateById(positionMapItem);
|
||||
@ -228,7 +247,7 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
editList.addAll(list.get(1));
|
||||
}
|
||||
if (isNotEmpty(list.get(2))) {
|
||||
list.get(2).forEach( a -> {
|
||||
list.get(2).forEach(a -> {
|
||||
a.setPositionMapItemId(null);
|
||||
a.setPositionMapId(null);
|
||||
});
|
||||
@ -349,7 +368,9 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
&& ObjectUtil.isNotEmpty(positionMapDO)) {
|
||||
deviceInformationDO.setFloor(positionMapDO.getFloor() + "");
|
||||
deviceInformationDO.setArea(positionMapDO.getArea());
|
||||
deviceInformationDO.setDeviceLocation(positionMapDO.getFloor()+"层-"+positionMapDO.getArea());
|
||||
String map = positionMapDO.getFloor() + "层-" + positionMapDO.getArea();
|
||||
String deviceLocation = ObjectUtil.isEmpty(deviceInformationDO.getDeviceLocation()) ? map : map + deviceInformationDO.getDeviceLocation();
|
||||
deviceInformationDO.setDeviceLocation(deviceLocation);
|
||||
}
|
||||
|
||||
String deviceKey = DeviceChcheConstant.DEVICE_LAST_TIME + deviceInformationDO.getMacAddress();
|
||||
@ -405,12 +426,13 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
warnMsgService.addWarnMsg(deviceNo + " 没有设备IP和端口");
|
||||
return;
|
||||
}
|
||||
log.info("设备伸出 :{}",deviceNo);
|
||||
log.info("设备伸出 :{}", deviceNo);
|
||||
extend(deviceInformationDO.getDeviceIp(), Integer.parseInt(deviceInformationDO.getDevicePort()), deviceNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 充电任务,缩
|
||||
*
|
||||
* @param deviceNo
|
||||
*/
|
||||
@Override
|
||||
@ -430,7 +452,7 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
log.info("没有设备IP、端口不能缩回 :{}", deviceNo);
|
||||
return;
|
||||
}
|
||||
log.info("设备缩回 :{}",deviceNo);
|
||||
log.info("设备缩回 :{}", deviceNo);
|
||||
shrink(deviceInformationDO.getDeviceIp(), Integer.parseInt(deviceInformationDO.getDevicePort()), deviceNo);
|
||||
}
|
||||
|
||||
@ -464,7 +486,7 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
log.info("充电设备缩回时,出现异常 :{}", ip);
|
||||
warnMsgService.addWarnMsg(deviceNo + " 充电设备缩回失败");
|
||||
success = false;
|
||||
}finally {
|
||||
} finally {
|
||||
if (ObjectUtil.isNotEmpty(asciiMaster)) {
|
||||
asciiMaster.destroy();
|
||||
}
|
||||
@ -478,6 +500,7 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
|
||||
/**
|
||||
* 控制设备伸缩
|
||||
*
|
||||
* @param ip
|
||||
* @param port
|
||||
*/
|
||||
@ -496,7 +519,7 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
||||
log.info("充电设备伸出时,出现异常 :{}", ip);
|
||||
warnMsgService.addWarnMsg(deviceNo + " 充电设备伸出失败");
|
||||
success = false;
|
||||
}finally {
|
||||
} finally {
|
||||
if (ObjectUtil.isNotEmpty(asciiMaster)) {
|
||||
asciiMaster.destroy();
|
||||
}
|
||||
|
@ -256,15 +256,27 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
|
||||
|
||||
//移动点位是否为空闲/重复、 处理中的任务
|
||||
List<Long> pointList = new ArrayList<>();
|
||||
List<String> takeRobotNos = new ArrayList<>();
|
||||
List<String> releaseRobotNos = new ArrayList<>();
|
||||
|
||||
for (RobotTaskDetailAddVO robotTaskDetail : createReqVO.getTaskDetailList()) {
|
||||
if (!RobotTaskTypeEnum.MOVE_TO_POINT.getType().equals(robotTaskDetail.getTaskType())) {
|
||||
continue;
|
||||
if (RobotTaskTypeEnum.MOVE_TO_POINT.getType().equals(robotTaskDetail.getTaskType())) {
|
||||
if (pointList.contains(robotTaskDetail.getReleaseId())) {
|
||||
PositionMapItemDO positionMapItem = positionMapItemService.getPositionMapItem(robotTaskDetail.getReleaseId());
|
||||
throw exception0(TASK_CHECK_EXCEPTION.getCode(), "以下移动的点位重复 " + positionMapItem.getSortNum(), positionMapItem.getSortNum());
|
||||
}
|
||||
pointList.add(robotTaskDetail.getReleaseId());
|
||||
}else if (RobotTaskTypeEnum.TAKE.getType().equals(robotTaskDetail.getTaskType())) {
|
||||
if (takeRobotNos.contains(robotTaskDetail.getRobotNo())) {
|
||||
throw exception0(TASK_CHECK_EXCEPTION.getCode(), "一辆车只能有一个仅取货任务 " + robotTaskDetail.getRobotNo(), robotTaskDetail.getRobotNo());
|
||||
}
|
||||
takeRobotNos.add(robotTaskDetail.getRobotNo());
|
||||
}else if (RobotTaskTypeEnum.RELEASE.getType().equals(robotTaskDetail.getTaskType())) {
|
||||
if (releaseRobotNos.contains(robotTaskDetail.getRobotNo())) {
|
||||
throw exception0(TASK_CHECK_EXCEPTION.getCode(), "一辆车只能有一个仅放货任务 " + robotTaskDetail.getRobotNo(), robotTaskDetail.getRobotNo());
|
||||
}
|
||||
releaseRobotNos.add(robotTaskDetail.getRobotNo());
|
||||
}
|
||||
if (pointList.contains(robotTaskDetail.getReleaseId())) {
|
||||
PositionMapItemDO positionMapItem = positionMapItemService.getPositionMapItem(robotTaskDetail.getReleaseId());
|
||||
throw exception0(TASK_CHECK_EXCEPTION.getCode(), "以下移动的点位重复 " + positionMapItem.getSortNum(), positionMapItem.getSortNum());
|
||||
}
|
||||
pointList.add(robotTaskDetail.getReleaseId());
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(pointList)) {
|
||||
@ -285,6 +297,28 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
|
||||
String sortNumStr = getSortNumStr(doingTaskItemIds);
|
||||
throw exception0(TASK_CHECK_EXCEPTION.getCode(), "以下移动的点位存在处理中的任务 " + sortNumStr, sortNumStr);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(takeRobotNos)) {
|
||||
RobotTaskDetailDO takeTask = taskDetailMapper.selectOne(new LambdaQueryWrapperX<RobotTaskDetailDO>()
|
||||
.in(RobotTaskDetailDO::getRobotNo, takeRobotNos)
|
||||
.in(RobotTaskDetailDO::getTaskStatus,RobotTaskStatusEnum.NEW.getType(), RobotTaskStatusEnum.DOING.getType())
|
||||
.eq(RobotTaskDetailDO::getTaskType, RobotTaskTypeEnum.TAKE.getType())
|
||||
.last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(takeTask)) {
|
||||
throw exception0(TASK_CHECK_EXCEPTION.getCode(), "一辆车只能有一个仅取货任务 " + takeTask.getRobotNo(), takeTask.getRobotNo());
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(releaseRobotNos)) {
|
||||
RobotTaskDetailDO releaseTask = taskDetailMapper.selectOne(new LambdaQueryWrapperX<RobotTaskDetailDO>()
|
||||
.in(RobotTaskDetailDO::getRobotNo, releaseRobotNos)
|
||||
.in(RobotTaskDetailDO::getTaskStatus,RobotTaskStatusEnum.NEW.getType(), RobotTaskStatusEnum.DOING.getType())
|
||||
.eq(RobotTaskDetailDO::getTaskType, RobotTaskTypeEnum.RELEASE.getType())
|
||||
.last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(releaseTask)) {
|
||||
throw exception0(TASK_CHECK_EXCEPTION.getCode(), "一辆车只能有一个仅放货任务 " + releaseTask.getRobotNo(), releaseTask.getRobotNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getSortNumStr(List<Long> pointList) {
|
||||
@ -1123,7 +1157,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
|
||||
robotTaskVo.setToMapItemId(locationDO.getMapItemId());
|
||||
if (ObjectUtil.isNotEmpty(mapIds) && !mapIds.contains(locationDO.getMapId())) {
|
||||
log.error("机器人不能在此放货库位放货 :{}, 机器人编号 :{}", locationDO.getLocationNo(), robotTaskVo.getRobotNo());
|
||||
throw exception0(TASK_CREATE_FAIL.getCode(), "机器人不能在此放货库位放货 " + robotTaskVo.getReleaseId());
|
||||
throw exception0(TASK_CREATE_FAIL.getCode(), "车辆不能在此放货库位放货,检查车辆能走的区域 " + robotTaskVo.getRobotNo());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(takeMapItemIds) && takeMapItemIds.contains(locationDO.getMapItemId())) {
|
||||
log.error("此点位存在取货任务 :{}", locationDO.getLocationNo());
|
||||
|
@ -137,23 +137,8 @@ public class RobotCameraServiceImpl extends ServiceImpl<RobotCameraMapper, Robot
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
robotCameraDO.setCameraAccount(getEncrypt(robotCameraDO.getCameraAccount()));
|
||||
robotCameraDO.setCameraPassword(getEncrypt(robotCameraDO.getCameraPassword()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getEncrypt(String str){
|
||||
try {
|
||||
AESEncryptionUtil.decrypt(str, cameraSecretKey);
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
return AESEncryptionUtil.encrypt(str, cameraSecretKey);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
robotCameraDO.setCameraAccount(AESEncryptionUtil.getEncrypt(robotCameraDO.getCameraAccount(),cameraSecretKey));
|
||||
robotCameraDO.setCameraPassword(AESEncryptionUtil.getEncrypt(robotCameraDO.getCameraPassword(),cameraSecretKey));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,11 +98,11 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
||||
}
|
||||
|
||||
//机器人最后做的任务
|
||||
List<RobotTaskDetailDO> lastTaskDetails = robotTaskDetailMapper.getLastTaskGroupByRobotNo();
|
||||
/*List<RobotTaskDetailDO> lastTaskDetails = robotTaskDetailMapper.getLastTaskGroupByRobotNo();
|
||||
Map<String, RobotTaskDetailDO> lastTaskDetailMap = null;
|
||||
if (ObjectUtil.isNotEmpty(lastTaskDetails)) {
|
||||
lastTaskDetailMap = lastTaskDetails.stream().collect(Collectors.toMap(v -> v.getRobotNo(), Function.identity()));
|
||||
}
|
||||
}*/
|
||||
|
||||
CommonConfigVO chargeConfig = JSONUtil.toBean(commonConfigDO.getConfigStr(), CommonConfigVO.class);
|
||||
|
||||
@ -113,7 +113,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
||||
}
|
||||
|
||||
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) || !RobotStatusCodeConstant.CAN_DO_TASK.equals(Boolean.parseBoolean(String.valueOf(taskStatus)))) {
|
||||
robot.setRobotStatus(RobotStatusEnum.DOING.getType());
|
||||
@ -121,12 +121,12 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
||||
continue;
|
||||
}
|
||||
|
||||
Object cargoDetected = redisUtil.get(cargoDetectedKey);
|
||||
|
||||
//取货的,先执行放货再去充电
|
||||
if (ObjectUtil.isNotEmpty(lastTaskDetailMap) && ObjectUtil.isNotEmpty(lastTaskDetailMap.get(robot.getRobotNo()))) {
|
||||
/*if (ObjectUtil.isNotEmpty(lastTaskDetailMap) && ObjectUtil.isNotEmpty(lastTaskDetailMap.get(robot.getRobotNo()))) {
|
||||
robot.setRobotStatus(RobotStatusEnum.LAST_TASK_IS_TAKE.getType());
|
||||
continue;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (ObjectUtil.isNotEmpty(chargeConfig) && ObjectUtil.isNotEmpty(chargeConfig.getStartAutoCharge())) {
|
||||
String socKey = RobotTaskChcheConstant.ROBOT_INFORMATION_SOC +robot.getMacAddress();
|
||||
@ -146,11 +146,7 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(cargoDetected) || RobotStatusCodeConstant.CARGO_DETECTED.equals(Boolean.parseBoolean(String.valueOf(cargoDetected)))) {
|
||||
robot.setRobotStatus(RobotStatusEnum.DOING.getType());
|
||||
log.info("车机上报传感器被按下--不允许接任务 :{}",robot.getRobotNo());
|
||||
continue;
|
||||
}
|
||||
|
||||
//自动充电的车子,电量到达设定的阀值,也能执行任务
|
||||
/*if (ChargeTypeEnum.AUTOMATIC.getType().equals(robot.getChargeType())
|
||||
&& RobotStatusEnum.CHARGE.getType().equals(robot.getRobotStatus())) {
|
||||
@ -162,15 +158,15 @@ public class DistributeTasksServiceImpl implements DistributeTasksService {
|
||||
}
|
||||
}
|
||||
|
||||
robots = robots.stream()
|
||||
/*robots = robots.stream()
|
||||
.filter(v -> (RobotStatusEnum.STAND_BY.getType().equals(v.getRobotStatus())
|
||||
|| RobotStatusEnum.LAST_TASK_IS_TAKE.getType().equals(v.getRobotStatus())))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toList());*/
|
||||
|
||||
if (robots.isEmpty()) {
|
||||
/*if (robots.isEmpty()) {
|
||||
log.info("暂无可用的机器人,可能正在充电,可能车机上报不允许接任务");
|
||||
return pair;
|
||||
}
|
||||
}*/
|
||||
|
||||
log.info("完成查找车子");
|
||||
|
||||
|
@ -12,6 +12,8 @@ import cn.iocoder.yudao.module.mqtt.api.path.task.TaskRobotNoLimittationAreaDTO;
|
||||
import cn.iocoder.yudao.module.mqtt.api.path.task.TaskToPathPlanningDTO;
|
||||
import cn.iocoder.yudao.module.system.constant.path.PathPlanningChcheConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.path.PathPlanningTopicConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotStatusCodeConstant;
|
||||
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotTaskDetailAddVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
|
||||
@ -34,6 +36,7 @@ import cn.iocoder.yudao.module.system.enums.redis.RobotCacheLockEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.*;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.charge.ChargeModelEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.robot.information.ChargeTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotInformationService;
|
||||
import cn.iocoder.yudao.module.system.service.robot.RobotTaskService;
|
||||
import cn.iocoder.yudao.module.system.service.robot.job.DistributeTasksService;
|
||||
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
|
||||
@ -111,6 +114,10 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
@Lazy
|
||||
private RobotTaskService taskService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private RobotInformationService informationService;
|
||||
|
||||
/**
|
||||
* 下发任务给PP
|
||||
*/
|
||||
@ -230,7 +237,7 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
|
||||
if (ObjectUtil.isNotEmpty(robotNos)) {
|
||||
List<PositionMapItemDO> emptyMapItems = positionMapItems.stream()
|
||||
.filter(v -> UseStatusEnum.FREE.getType().equals(v.getUseStatus()))
|
||||
.filter(v -> UseStatusEnum.FREE.getType().equals(v.getUseStatus()))
|
||||
.collect(Collectors.toList());
|
||||
if (ObjectUtil.isNotEmpty(emptyMapItems)) {
|
||||
for (PositionMapItemDO positionMapItem : emptyMapItems) {
|
||||
@ -404,7 +411,7 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
List<TaskRobotNoLimittationAreaDTO> robotNoLimitationArea = pair.getLeft();
|
||||
|
||||
//前一个任务是仅取货
|
||||
List<String> robotDoTake = getRobotDoTake(robots);
|
||||
// List<String> robotDoTake = getRobotDoTake(robots);
|
||||
|
||||
for (RobotInformationDO robot : robots) {
|
||||
taskService.chargeDone(robot.getRobotNo());
|
||||
@ -445,10 +452,17 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
moveToPoint(pathPlanning, taskDetailDO);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(robotDoTake) && ObjectUtil.isNotEmpty(taskDetailDO.getRobotNo())
|
||||
&& robotDoTake.contains(taskDetailDO.getRobotNo())
|
||||
&& !RobotTaskTypeEnum.RELEASE.getType().equals(taskDetailDO.getTaskType())) {
|
||||
log.info("机器人前一个任务是仅取货,当前任务非仅放货,所以当前任务不执行 :{}", taskDetailDO.getId());
|
||||
String mac = informationService.getMacByRobotNo(taskDetailDO.getRobotNo());
|
||||
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + mac;
|
||||
Object cargoDetected = redisUtil.get(cargoDetectedKey);
|
||||
log.info("传感器是否按下 :{}", cargoDetected);
|
||||
if (ObjectUtil.isEmpty(cargoDetected) || (RobotStatusCodeConstant.CARGO_DETECTED.equals(Boolean.parseBoolean(String.valueOf(cargoDetected)))
|
||||
&& !RobotTaskTypeEnum.RELEASE.getType().equals(taskDetailDO.getTaskType()))) {
|
||||
log.info("车机上报传感器为空, 或者 被按下且任务非仅放货任务 :{} ,任务id :{}", taskDetailDO.getRobotNo(), taskDetailDO.getId());
|
||||
continue;
|
||||
} else if (!RobotStatusCodeConstant.CARGO_DETECTED.equals(Boolean.parseBoolean(String.valueOf(cargoDetected)))
|
||||
&& RobotTaskTypeEnum.RELEASE.getType().equals(taskDetailDO.getTaskType())) {
|
||||
log.info("仅放货任务,传感器未被按下,所以不执行任务 :{}, 任务id :{}", taskDetailDO.getRobotNo(), taskDetailDO.getId());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -457,7 +471,11 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
robotNoLimitions = robotNoLimitationArea;
|
||||
} else {
|
||||
TaskRobotNoLimittationAreaDTO taskRobotNoLimittationAreaDTO = robotDoReleaseMap.get(taskDetailDO.getRobotNo());
|
||||
robotNoLimitions = Arrays.asList(taskRobotNoLimittationAreaDTO);
|
||||
if (ObjectUtil.isEmpty(taskRobotNoLimittationAreaDTO)) {
|
||||
log.info("车辆没有能行走的区域 :{}", taskDetailDO.getRobotNo());
|
||||
continue;
|
||||
}
|
||||
robotNoLimitions = Collections.singletonList(taskRobotNoLimittationAreaDTO);
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(robotNoLimitions)) {
|
||||
@ -587,14 +605,14 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
}
|
||||
}
|
||||
|
||||
if (positionMapDOS.size() == limitationAreaList.size()) {
|
||||
log.info("车辆不能行走所有的区域所以不下发任务 :{}", robot.getRobotNo());
|
||||
continue;
|
||||
}
|
||||
robotNoLimitationAreaDTO.setLimitationAreaList(limitationAreaList);
|
||||
|
||||
if (RobotStatusEnum.LAST_TASK_IS_TAKE.getType().equals(robot.getRobotStatus())) {
|
||||
map.put(robot.getRobotNo(), robotNoLimitationAreaDTO);
|
||||
} else {
|
||||
robotNoLimitationAreaDTOS.add(robotNoLimitationAreaDTO);
|
||||
map.put(robot.getRobotNo(), robotNoLimitationAreaDTO);
|
||||
}
|
||||
robotNoLimitationAreaDTOS.add(robotNoLimitationAreaDTO);
|
||||
map.put(robot.getRobotNo(), robotNoLimitationAreaDTO);
|
||||
|
||||
}
|
||||
return ImmutablePair.of(robotNoLimitationAreaDTOS, map);
|
||||
|
@ -48,4 +48,25 @@ public class AESEncryptionUtil {
|
||||
String decryptedText = decrypt(encryptedText, key);
|
||||
System.out.println("Decrypted Text: " + decryptedText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取解密后数据
|
||||
* @param str
|
||||
* @param cameraSecretKey
|
||||
* @return
|
||||
*/
|
||||
public static String getEncrypt(String str, String cameraSecretKey){
|
||||
try {
|
||||
AESEncryptionUtil.decrypt(str, cameraSecretKey);
|
||||
return str;
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
return AESEncryptionUtil.encrypt(str, cameraSecretKey);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user