Compare commits

...

4 Commits

Author SHA1 Message Date
cbs
133cacbca6 修改MQTTIP 2025-05-30 14:18:27 +08:00
cbs
58755daf70 任务优化 2025-05-30 14:16:30 +08:00
cbs
4683480d39 3D地图任务 2025-05-29 16:28:58 +08:00
cbs
e8419a002f 任务日志添加原始执行车辆编号 2025-05-29 11:44:13 +08:00
41 changed files with 382 additions and 146 deletions

View File

@ -33,8 +33,8 @@ management:
# MQTT
mqtt:
host: tcp://123.57.12.40:1883
# host: tcp://127.0.0.1:1883
# host: tcp://123.57.12.40:1883
host: tcp://127.0.0.1:1883
username: adminuser
password: adminuser
qos: 0

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.api.robot.dto;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotStatusDataPoseDTO;
import lombok.Data;
@Data

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.api.robot.dto;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotStatusDataPoseDTO;
import lombok.Data;
import java.util.List;

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.system.api.robot.vo;
package cn.iocoder.yudao.module.system.api.robot.websocket;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
import lombok.Data;
import java.util.List;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.system.api.robot.dto;
package cn.iocoder.yudao.module.system.api.robot.websocket;
import lombok.Data;
@ -16,6 +16,8 @@ public class RobotStatusDataPoseDTO {
public String floor;
//区域
public String area;
//货叉高度
public Double forkHeight;
//电池剩余容量 废弃 从ROBOT_INFORMATION_SOC 获取电量
// public String batSoc;
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.system.api.robot.websocket;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class WsWareHouseLocationDTO {
@Schema(description = "实际坐标x轴")
private String actualLocationX;
@Schema(description = "实际坐标y轴")
private String actualLocationY;
@Schema(description = "类型: 1添加 0:减少")
private Integer type = 1;
@Schema(description = "所在楼")
public String floor;
@Schema(description = "所在区")
public String area;
}

View File

@ -224,6 +224,7 @@ public interface ErrorCodeConstants {
ErrorCode TASK_CREATE_FAIL = new ErrorCode(1-002-035-110, "任务创建失败:");
ErrorCode ROBOT_DO_TASK_FAIL = new ErrorCode(1-002-035-112, "车机反馈不能接任务");
ErrorCode TASK_COMMONG_FAIL = new ErrorCode(1-002-035-113, "下发失败");
ErrorCode TASK_ASSIGN_OTHER_ROBOT = new ErrorCode(1-002-035-114, "此任务已经转移给其他车辆");
// ========== 机器人任务明细 1-002-036-000 ==========
ErrorCode TASK_DETAIL_NOT_EXISTS = new ErrorCode(1-002-036-001, "车辆任务明细不存在");

View File

@ -42,7 +42,11 @@ public class RobotGenericsStatusApiImpl implements RobotGenericsStatusApi {
String batSoc = robotStatusData.getHwStates().getBatSoc();
if (ObjectUtil.isNotEmpty(batSoc)) {
String[] split = batSoc.split("\\.");
batSoc = split[1].substring(0,2);
batSoc = split[1];
if (batSoc.length() > 2) {
batSoc = batSoc.substring(0,2);
}
if (batSoc.startsWith("0")) {
batSoc = batSoc.substring(1);
}

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
import cn.iocoder.yudao.module.system.api.robot.dto.FloorZoneDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotObstaclesStatusDTO;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotUpdatePalletHeightDTO;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.constant.webSocket.WebSocketConstant;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnMsgSaveReqVO;
@ -60,7 +61,7 @@ public class RobotObstaclesStatusApiImpl implements RobotObstaclesStatusApi{
warnMsg.setWarnMsg(robotNo +" 机器人遇到障碍物");
warnMsgService.createWarnMsg(warnMsg);
webSocketSenderApi.sendObject(floorZoneDTO.getFloor() + "_" + floorZoneDTO.getArea(),
webSocketSenderApi.sendObject(floorZoneDTO.getFloor() + CommonConstant.SYMBOL + floorZoneDTO.getArea(),
WebSocketConstant.AGV_WARN, warnMsg.getWarnMsg());
}
}

View File

@ -1,12 +1,11 @@
package cn.iocoder.yudao.module.system.api.robot;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.api.robot.dto.FloorZoneDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataErrorDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotReactiveStatusDTO;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
import cn.iocoder.yudao.module.system.constant.area.FloorAreaConstant;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.dal.dataobject.log.RobotTaskDetailActionLogDO;
@ -26,8 +25,6 @@ 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.data.redis.core.StringRedisTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@ -74,11 +71,11 @@ public class RobotReactiveStatusApiImpl implements RobotReactiveStatusApi {
FloorZoneDTO floorZone = new FloorZoneDTO();
if (ObjectUtil.isNotEmpty(o)) {
floorZone = JSON.parseObject((String) o, FloorZoneDTO.class);
String oldFloorArea = floorZone.getFloor() + "-" + floorZone.getArea();
String oldFloorArea = floorZone.getFloor() + CommonConstant.SYMBOL + floorZone.getArea();
redisUtil.hdel(oldFloorArea, robotNo);
String newFloorArea = data.getFloorZone().getFloor() + "-" + data.getFloorZone().getArea();
String key = FloorAreaConstant.FLOOR_AREA_ROBOT + floorZone.getFloor() + "-" + floorZone.getArea();
String newFloorArea = data.getFloorZone().getFloor() + CommonConstant.SYMBOL + data.getFloorZone().getArea();
String key = FloorAreaConstant.FLOOR_AREA_ROBOT + floorZone.getFloor() + CommonConstant.SYMBOL + floorZone.getArea();
if (!oldFloorArea.equals(newFloorArea)) {
redisUtil.hdel(key, robotNo);
}
@ -90,7 +87,7 @@ public class RobotReactiveStatusApiImpl implements RobotReactiveStatusApi {
redisUtil.set(floorAreaKey, JSON.toJSONString(floorZone));
Map<String, Object> map = new HashMap<>();
String value = floorZone.getFloor() + "-" + floorZone.getArea();
String value = floorZone.getFloor() + CommonConstant.SYMBOL + floorZone.getArea();
map.put(robotNo, value);
redisUtil.hmset(value, map);
@ -153,7 +150,7 @@ public class RobotReactiveStatusApiImpl implements RobotReactiveStatusApi {
.warnCode(robotStatusData.getErrorCode())
.robotNo(robotNo)
.warnType(RobotWarnType.ROBOT_WARN.getType())
.warnMsg(robotNo + "_" + mappingDOS.getWarnMsg())
.warnMsg(robotNo + CommonConstant.SYMBOL + mappingDOS.getWarnMsg())
.warnSolve(mappingDOS.getWarnSolve())
.build();

View File

@ -6,8 +6,11 @@ import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.mqtt.api.common.CommonApi;
import cn.iocoder.yudao.module.system.api.robot.dto.*;
import cn.iocoder.yudao.module.system.api.robot.processor.RequestProcessor;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotInformationVO;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotReactiveStatusDTO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.config.ratelimiter.SystemRateLimiter;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
import cn.iocoder.yudao.module.system.constant.area.FloorAreaConstant;
import cn.iocoder.yudao.module.system.constant.path.PathPlanningTopicConstant;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
@ -24,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j
@RestController // 提供 RESTful API 接口 Feign 调用
@ -42,9 +47,11 @@ public class RobotStatusApiImpl implements RobotStatusApi {
@Resource
private RequestProcessor processor;
@Autowired
private ThreadPoolTaskExecutor taskExecutor;
private static final ExecutorService executorService = Executors.newFixedThreadPool(5);
/*@Autowired
private ThreadPoolTaskExecutor taskExecutor;
*/
@Resource
private CommonApi commonApi;
@ -57,7 +64,9 @@ public class RobotStatusApiImpl implements RobotStatusApi {
@Override
@SystemRateLimiter(time = 1, count = 150, keyArg = "robotStatusUpdate", message = "机器人上报点位超过限流")
public void robotStatusUpdate(RobotPoseStatusDTO robotStatusDataDTO) {
updateRobotPosed(robotStatusDataDTO);
executorService.execute(() -> {
updateRobotPosed(robotStatusDataDTO);
});
}
/**
@ -87,6 +96,14 @@ public class RobotStatusApiImpl implements RobotStatusApi {
robotStatusDataPoseDTO.setRobotNo(robotNo);
robotStatusDataPoseDTO.setFloor(floorZoneDTO.getFloor());
robotStatusDataPoseDTO.setArea(floorZoneDTO.getArea());
String speedKey = RobotTaskChcheConstant.ROBOT_SPEED_FORK_HEIGHT + robotNo;
Object speedObject = redisUtil.get(speedKey);
if (ObjectUtil.isNotEmpty(speedObject)) {
RobotReactiveStatusDTO data = JSON.parseObject(speedObject.toString(), RobotReactiveStatusDTO.class);
robotStatusDataPoseDTO.setForkHeight(data.getForkHeight());
}
redisUtil.set(pose2dKey, JSON.toJSONString(robotStatusDataPoseDTO), robotPositionCacheTime);
//机器人身上是否有货
@ -104,19 +121,17 @@ public class RobotStatusApiImpl implements RobotStatusApi {
robotInformationVO.setPose2d(robotStatusDataPoseDTO);
Map<String, Object> map = new HashMap<>();
String value = FloorAreaConstant.FLOOR_AREA_ROBOT + floorZoneDTO.getFloor() + "-" + floorZoneDTO.getArea();
String value = FloorAreaConstant.FLOOR_AREA_ROBOT + floorZoneDTO.getFloor() + CommonConstant.SYMBOL + floorZoneDTO.getArea();
map.put(robotStatusDataDTO.getMac(), JSON.toJSONString(robotInformationVO));
redisUtil.hmset(value, map, 20);
// 合并请求 - 这里接受到的数据都丢给 RequestProcessor - 再整合数据通过WebSocket丢给前端
processor.handleRequest(floorZoneDTO.getFloor() + "_" + floorZoneDTO.getArea(),
processor.handleRequest(floorZoneDTO.getFloor() + CommonConstant.SYMBOL + floorZoneDTO.getArea(),
robotStatusDataDTO.getMac(), JSONUtil.toJsonStr(robotInformationVO));
sendToPP(robotStatusDataPoseDTO);
}
private void sendToPP(RobotStatusDataPoseDTO robotStatusDataPoseDTO) {
taskExecutor.execute(() -> {
commonApi.commonMethod(robotStatusDataPoseDTO, PathPlanningTopicConstant.AGV_POSE);
});
commonApi.commonMethod(robotStatusDataPoseDTO, PathPlanningTopicConstant.AGV_POSE);
}
}

View File

@ -1,18 +1,25 @@
package cn.iocoder.yudao.module.system.api.robot;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
import cn.iocoder.yudao.module.mqtt.api.common.CommonApi;
import cn.iocoder.yudao.module.system.api.path.vo.RobotClosePathPlantingDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.FloorZoneDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotCommandStateDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotCompleteTaskDTO;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotSkuInfoDTO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotSkuInfoDTO;
import cn.iocoder.yudao.module.system.api.robot.websocket.WsWareHouseLocationDTO;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
import cn.iocoder.yudao.module.system.constant.area.FloorAreaConstant;
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.RobotExecutionStateConstant;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.constant.webSocket.WebSocketConstant;
import cn.iocoder.yudao.module.system.controller.admin.log.vo.RobotTaskDetailActionLogSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.log.RobotTaskDetailActionLogDO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
@ -51,6 +58,8 @@ import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
import static cn.iocoder.yudao.module.system.service.robot.RobotInformationServiceImpl.key;
@Slf4j
@RestController // 提供 RESTful API 接口 Feign 调用
@Validated
@ -93,6 +102,9 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
@Resource
private CommonApi commonApi;
@Resource
public WebSocketSenderApi webSocketSenderApi;
@Resource
private RobotTaskDetailService taskDetailService;
@ -111,6 +123,9 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
@Value("${zn.robot_doing_action.doing_action_cache_time:2*24*60*60}")
private Long doingActionCacheTime;
@Value("${zn.is_simulation:false}")
private Boolean isSimulation;
@Transactional(rollbackFor = Exception.class)
public void doRobotDoneTask(RobotCompleteTaskDTO robotCompleteTaskDTO) {
log.info("机器人完成任务上报 :{}", JSON.toJSONString(robotCompleteTaskDTO));
@ -177,7 +192,8 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DOING.getType()
, null);
if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())) {
if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())
|| PathTaskTypeEnum.CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType()) ) {
chargeDoing(robotCompleteTaskDTO);
}
}
@ -243,12 +259,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())
|| PathTaskTypeEnum.CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())) {
RobotChargeLogDO build = RobotChargeLogDO
.builder()
.id(robotCompleteTaskDTO.getOrderId())
.taskStatus(ChargeTaskStatusEnum.CHARGEING.getType())
.build();
chargeLogMapper.updateById(build);
chargeLogMapper.updateChargStatusByTaskId(robotCompleteTaskDTO.getOrderId(),ChargeTaskStatusEnum.DONE.getType());
}
taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DONE.getType(), LocalDateTime.now());
@ -277,6 +288,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
toWareHouseLocation.setLocationLock(LocationLockEnum.YES.getType());
toWareHouseLocation.setLocationUseStatus(LocationUseStatusEnum.YES.getType());
locationMapper.updateById(toWareHouseLocation);
pushWareLocation(toWareHouseLocation,robotCompleteTaskDTO.getMac(),ZeroOneEnum.ONE.getType());
}
/**
@ -331,6 +343,25 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
wareHouseLocationDO.setLocationLock(LocationLockEnum.YES.getType());
wareHouseLocationDO.setLocationUseStatus(LocationUseStatusEnum.NO.getType());
locationMapper.updateById(wareHouseLocationDO);
pushWareLocation(wareHouseLocationDO,robotCompleteTaskDTO.getMac(),ZeroOneEnum.ZERO.getType());
}
public void pushWareLocation(WareHouseLocationDO wareHouseLocationDO, String mac, Integer type) {
String floorAreaKey = RobotTaskChcheConstant.ROBOT_FLOOR_AREA + mac;
Object floorAreaObject = redisUtil.get(floorAreaKey);
if (ObjectUtil.isEmpty(floorAreaObject)) {
return;
}
FloorZoneDTO floorZoneDTO = JSONUtil.toBean((String) floorAreaObject, FloorZoneDTO.class);
String floorAreaStr = floorZoneDTO.getFloor() + CommonConstant.SYMBOL + floorZoneDTO.getArea();
WsWareHouseLocationDTO wsWareHouseLocation = new WsWareHouseLocationDTO();
wsWareHouseLocation.setActualLocationX(wareHouseLocationDO.getActualLocationX());
wsWareHouseLocation.setActualLocationY(wareHouseLocationDO.getActualLocationY());
wsWareHouseLocation.setType(type);
wsWareHouseLocation.setFloor(floorZoneDTO.getFloor());
wsWareHouseLocation.setArea(floorZoneDTO.getArea());
log.info("让3D推送修改库存 :{}", JSON.toJSONString(wsWareHouseLocation));
webSocketSenderApi.sendObject(floorAreaStr, WebSocketConstant.THREE_D_CHANGE_STOCK, JSON.toJSONString(wsWareHouseLocation));
}
@ -437,28 +468,18 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
private void chargeDoing(RobotCompleteTaskDTO robotCompleteTaskDTO) {
RobotCommandStateDTO commandStatus = robotCompleteTaskDTO.getCommandStatus();
Integer taskStatus = ChargeTaskStatusEnum.CHARGEING.getType();
//编辑地图会判断这表的状态,所以自动充电任务移动到充电点就改为完成
//自动充电任务移动到充电点就改为完成
if (ObjectUtil.isNotEmpty(commandStatus) && CommandTypeEnum.MOVE_POSES.getType().equals(commandStatus.getCommandType())
&& RobotExecutionStateConstant.DONE.equals(commandStatus.getExecutionState())) {
taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DONE.getType(), LocalDateTime.now());
setTaskDone(robotCompleteTaskDTO);
}
RobotChargeLogDO build = RobotChargeLogDO
.builder()
.id(robotCompleteTaskDTO.getOrderId())
.taskStatus(taskStatus)
.build();
chargeLogMapper.updateById(build);
chargeLogMapper.updateChargStatusByTaskId(robotCompleteTaskDTO.getOrderId(),ChargeTaskStatusEnum.CHARGEING.getType());
}
/**
* 任务完成
*
* @param robotCompleteTaskDTO
*/
private void taskDone(RobotCompleteTaskDTO robotCompleteTaskDTO) {
public RobotTaskDetailDO setTaskDone(RobotCompleteTaskDTO robotCompleteTaskDTO) {
//更新任务状态
RobotTaskDetailDO detailDO = new RobotTaskDetailDO();
detailDO.setId(robotCompleteTaskDTO.getOrderId());
@ -470,7 +491,8 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
RobotTaskDetailDO robotTaskDetailDO = robotTaskDetailMapper.selectById(robotCompleteTaskDTO.getOrderId());
List<RobotTaskDetailDO> taskDetails = robotTaskDetailMapper.queryByTaskId(robotTaskDetailDO.getRobotTaskId());
boolean done =
taskDetails.stream().noneMatch(v -> (v.getTaskStatus().equals(RobotTaskDetailStatusEnum.NEW.getType())));
taskDetails.stream().noneMatch(v -> (v.getTaskStatus().equals(RobotTaskDetailStatusEnum.NEW.getType()) ||
v.getTaskStatus().equals(RobotTaskDetailStatusEnum.DOING.getType())));
if (done) {
RobotTaskDO robotTaskDO = new RobotTaskDO();
robotTaskDO.setId(taskDetails.get(0).getRobotTaskId());
@ -479,6 +501,17 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
robotTaskMapper.updateRobot(robotTaskDO);
taskCycleMapper.deletByRobotTaskId(taskDetails.get(0).getRobotTaskId());
}
return detailDO;
}
/**
* 任务完成
*
* @param robotCompleteTaskDTO
*/
private void taskDone(RobotCompleteTaskDTO robotCompleteTaskDTO) {
RobotTaskDetailDO robotTaskDetailDO = setTaskDone(robotCompleteTaskDTO);
RobotInformationDO robotInformationDO = robotInformationMapper.selectOne(new LambdaQueryWrapperX<RobotInformationDO>()
.eq(RobotInformationDO::getRobotNo, robotTaskDetailDO.getRobotNo()));
@ -492,6 +525,11 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
//同步任务完成给PP
pathPlanningService.updateBehavior(String.valueOf(robotCompleteTaskDTO.getOrderId()), robotTaskDetailDO.getRobotNo()
, "", PathIsReachEnum.END_WORK.getType());
if (!isSimulation) {
String plantingKey = PathPlanningChcheConstant.PATH_PLANNING_TASK + robotCompleteTaskDTO.getOrderId();
redisUtil.del(plantingKey);
}
}
@ -579,6 +617,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
String robotNo = robotInformationService.getRobotNoByMac(robotCompleteTaskDTO.getMac());
logOne.setRobotNo(robotNo);
logOne.setOriginalRobotNo(robotNo);
logOne.setTaskDetailId(robotCompleteTaskDTO.getOrderId());
logOne.setTaskStage(robotTaskDetailDO.getTaskStage());
logOne.setCommandType(PathTaskTypeEnum.getTaskType(robotTaskDetailDO.getTaskType()));

View File

@ -3,6 +3,7 @@ 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.vo.RobotUpdatePalletHeightDTO;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
import cn.iocoder.yudao.module.system.dal.dataobject.config.CommonConfigDO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO;
@ -101,7 +102,7 @@ public class RobotUpdatePalletHeightApiImpl implements RobotUpdatePalletHeightAp
.warnCode(WARN_CODE)
.robotNo(robotNo)
.warnType(RobotWarnType.ROBOT_WARN.getType())
.warnMsg(data.getOrderId() + "_" + "不需要更新库位高度")
.warnMsg(data.getOrderId() + CommonConstant.SYMBOL + "不需要更新库位高度")
.build();
warnMsgMapper.insert(warnMsg);
}

View File

@ -6,4 +6,9 @@ public class CommonConstant {
* MDC请求常亮
*/
public static final String REQUEST_ID = "requestId";
/**
* 拼接的符号 不能改
*/
public static final String SYMBOL = "_";
}

View File

@ -13,6 +13,11 @@ public class WebSocketConstant {
*/
public static String THREE_D_MAP_PUSH = "3d_map_push";
/**
* 3D地图修改库存
*/
public static String THREE_D_CHANGE_STOCK = "3d_change_stock";
/**
* 推送地图点位信息
*/

View File

@ -57,4 +57,6 @@ public class RobotTaskDetailActionLogPageReqVO extends PageParam {
@Schema(description = "是否已经统计(0:未统计、1已经统计)")
private Integer alreadyCounted;
@Schema(description = "这条任务第一次执行的AGV编号")
private String originalRobotNo;
}

View File

@ -69,4 +69,7 @@ public class RobotTaskDetailActionLogRespVO {
@ExcelProperty("是否已经统计(0:未统计、1已经统计)")
private Integer alreadyCounted;
@Schema(description = "这条任务第一次执行的AGV编号")
@ExcelProperty("这条任务第一次执行的AGV编号")
private String originalRobotNo;
}

View File

@ -52,4 +52,7 @@ public class RobotTaskDetailActionLogSaveReqVO {
@Schema(description = "是否已经统计(0:未统计、1已经统计)")
private Integer alreadyCounted;
@Schema(description = "这条任务第一次执行的AGV编号")
private String originalRobotNo;
}

View File

@ -87,5 +87,9 @@ public class RobotTaskDetailActionLogDO extends BaseDO {
* 时长,单位分钟
*/
private Long duration;
/**
* 这条任务第一次执行的AGV编号
*/
private String originalRobotNo;
}

View File

@ -36,4 +36,11 @@ public interface RobotChargeLogMapper extends BaseMapperX<RobotChargeLogDO> {
*/
List<String> getChargeFullRobotNos(@Param("chanceCycle") Integer chanceCycle,
@Param("robotNos") List<String> robotNos);
/**
*
* @param taskDetailId
* @param taskStatus
*/
void updateChargStatusByTaskId(@Param("taskDetailId") Long taskDetailId, @Param("taskStatus") Integer taskStatus);
}

View File

@ -1,13 +1,13 @@
package cn.iocoder.yudao.module.system.api.robot.schedul;
package cn.iocoder.yudao.module.system.schedul;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotInformationVO;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
import cn.iocoder.yudao.module.system.constant.area.FloorAreaConstant;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.constant.webSocket.WebSocketConstant;
import cn.iocoder.yudao.module.system.controller.admin.robot.task.TaskAssignDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
import cn.iocoder.yudao.module.system.service.positionmap.PositionMapService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
@ -67,7 +67,7 @@ public class ScheduledTasks {
}
for (PositionMapDO positionMap : allMap) {
String key = FloorAreaConstant.FLOOR_AREA_ROBOT + positionMap.getFloor() + "-" + positionMap.getArea();
String key = FloorAreaConstant.FLOOR_AREA_ROBOT + positionMap.getFloor() + CommonConstant.SYMBOL + positionMap.getArea();
Map<Object, Object> data = redisUtil.hmget(key);
if (ObjectUtil.isEmpty(data)) {
continue;
@ -86,7 +86,7 @@ public class ScheduledTasks {
});
// log.info("3D发送数据:{}", JSON.toJSONString(map));
webSocketSenderApi.sendObject(key, WebSocketConstant.THREE_D_MAP_PUSH, map);
webSocketSenderApi.sendObject(positionMap.getFloor() + CommonConstant.SYMBOL + positionMap.getArea(), WebSocketConstant.THREE_D_MAP_PUSH, map);
}
}

View File

@ -7,7 +7,7 @@ import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.controller.admin.bulletinboard.vo.BulletinBoardVO;
import cn.iocoder.yudao.module.system.controller.admin.bulletinboard.vo.RobotElectricityLevelVO;

View File

@ -5,25 +5,22 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
import cn.iocoder.yudao.module.system.controller.admin.houselocation.vo.*;
import cn.iocoder.yudao.module.system.controller.admin.log.vo.UserOperationLogSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.dal.mysql.houselocation.WareHouseLocationMapper;
import cn.iocoder.yudao.module.system.enums.common.ZeroOneEnum;
import cn.iocoder.yudao.module.system.enums.robot.LocationEnableEnum;
import cn.iocoder.yudao.module.system.enums.robot.LocationLockEnum;
import cn.iocoder.yudao.module.system.enums.robot.LocationUseStatusEnum;
import cn.iocoder.yudao.module.system.service.log.UserOperationLogService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@ -77,7 +74,7 @@ public class HouseLocationServiceImpl extends ServiceImpl<WareHouseLocationMappe
return;
}
str = "修改库位信息:" + updateReqVO.getLocationNo() + "_" + str;
str = "修改库位信息:" + updateReqVO.getLocationNo() + CommonConstant.SYMBOL + str;
UserOperationLogSaveReqVO operationLog = UserOperationLogSaveReqVO.builder()
.operateAction(str)

View File

@ -60,7 +60,7 @@ public interface RobotTaskDetailActionLogService {
RobotTaskDetailActionLogDO setPreviousTaskDoneByOrderId(Long orderId);
/**
* 获取车辆的最后一条任务
* 获取车辆的最后一条任务(限处理中的任务使用)
* @param robotNo
* @return
*/
@ -84,4 +84,10 @@ public interface RobotTaskDetailActionLogService {
*/
List<RobotTaskDetailActionLogDO> getUnStatisticsDurationLog();
/**
* 获取这台车最后一次执行的任务(查真实的分配记录)
* @param robotNo
* @return
*/
RobotTaskDetailActionLogDO getOriginalLastTaskByRobotNo(String robotNo);
}

View File

@ -2,19 +2,12 @@ package cn.iocoder.yudao.module.system.service.log;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.controller.admin.log.vo.RobotTaskDetailActionLogPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.log.vo.RobotTaskDetailActionLogSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.log.RobotTaskDetailActionLogDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotChargeLogDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO;
import cn.iocoder.yudao.module.system.dal.mysql.log.RobotTaskDetailActionLogMapper;
import cn.iocoder.yudao.module.system.enums.robot.RobotTaskStatusEnum;
import cn.iocoder.yudao.module.system.enums.robot.actionlog.ActionStatusEnum;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import cn.iocoder.yudao.module.system.enums.robot.actionlog.CommandIdEnum;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@ -134,4 +127,18 @@ public class RobotTaskDetailActionLogServiceImpl implements RobotTaskDetailActio
return taskDetailActionLogMapper.getUnStatisticsDurationLog();
}
/**
* 查这台车最后一次分配的任务
* @param robotNo
* @return
*/
@Override
public RobotTaskDetailActionLogDO getOriginalLastTaskByRobotNo(String robotNo) {
return taskDetailActionLogMapper.selectOne(new LambdaQueryWrapperX<RobotTaskDetailActionLogDO>()
.eq(RobotTaskDetailActionLogDO::getOriginalRobotNo, robotNo)
.eq(RobotTaskDetailActionLogDO::getCommandId, CommandIdEnum.TASK.getType())
.orderByDesc(RobotTaskDetailActionLogDO::getCreateTime)
.last("limit 1"));
}
}

View File

@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.mqtt.api.path.dto.*;
import cn.iocoder.yudao.module.mqtt.api.path.task.TaskPathPlanningDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.FloorZoneDTO;
import cn.iocoder.yudao.module.system.api.robot.vo.PathPlanningMovePoseVO;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
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.RobotTaskChcheConstant;
@ -503,7 +504,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
String floorAreaKey = RobotTaskChcheConstant.ROBOT_FLOOR_AREA + mac;
Object floorAreaObject = redisUtil.get(floorAreaKey);
FloorZoneDTO floorZoneDTO = JSONUtil.toBean((String) floorAreaObject, FloorZoneDTO.class);
webSocketSenderApi.sendObject(floorZoneDTO.getFloor() + "_" + floorZoneDTO.getArea(),
webSocketSenderApi.sendObject(floorZoneDTO.getFloor() + CommonConstant.SYMBOL + floorZoneDTO.getArea(),
WebSocketConstant.PLANNING_MOVE_POSE, message);
}
@ -546,7 +547,7 @@ public class PathPlanningServiceImpl implements PathPlanningService {
}
List<PositionMapItemDO> itemDOList = new ArrayList<>();
List<PositionMapItemDO> items = positionMapItemService.getPositionMapItemByMapAndType(positionMap.getId(), PositionMapItemEnum.WAIT.getType());
List<PositionMapItemDO> items = positionMapItemService.getPositionMapItemByMapAndType(positionMap.getId(), PositionMapItemEnum.STOP.getType());
if (ObjectUtil.isEmpty(items) || items.size() < robots.size()) {
List<PositionMapItemDO> itemPoses = positionMapItemService.getPositionMapItemByMapAndType(positionMap.getId(), PositionMapItemEnum.PATH.getType());
itemDOList.addAll(itemPoses);

View File

@ -50,6 +50,7 @@ import cn.iocoder.yudao.module.system.service.log.RobotTaskDetailActionLogServic
import cn.iocoder.yudao.module.system.service.log.UserOperationLogService;
import cn.iocoder.yudao.module.system.service.robot.RobotInformationService;
import cn.iocoder.yudao.module.system.service.robot.RobotTaskDetailService;
import cn.iocoder.yudao.module.system.service.robot.RobotTaskService;
import cn.iocoder.yudao.module.system.service.robot.mapstop.RobotMapStopService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import cn.iocoder.yudao.module.system.util.redis.RedissonUtils;
@ -57,6 +58,7 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -123,6 +125,10 @@ public class RemoteControllerInformationServiceImpl extends ServiceImpl<RemoteCo
@Resource
private RobotTaskDetailService taskDetailService;
@Resource
@Lazy
private RobotTaskService taskService;
@Resource
private ControllerTaskTransferLogService controllerTaskTransferLogService;
@ -324,7 +330,12 @@ public class RemoteControllerInformationServiceImpl extends ServiceImpl<RemoteCo
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return doRobotChangeMode(remoteMode, remoteIp, robotNo,remoteControllerPort,remoteControllerIp);
RemoteRobotTransferDTO dto = doRobotChangeMode(remoteMode, remoteIp, robotNo, remoteControllerPort, remoteControllerIp);
if (!RemoteModeEnum.AUTOMATIC.getType().equals(remoteMode)) {
taskService.chargeDone(robotNo);
}
return dto;
} finally {
lock.unlock();
}

View File

@ -4,10 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.mqtt.api.task.dto.RobotSimulationPoseDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.FloorZoneDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDTO;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotInformationVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.*;
import cn.iocoder.yudao.module.system.controller.admin.statistics.dto.RobotStatusClassificationDTO;
import cn.iocoder.yudao.module.system.controller.admin.statistics.dto.RobotTaskManualInterventionDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.config.CommonConfigDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;

View File

@ -21,8 +21,9 @@ import cn.iocoder.yudao.module.mqtt.enums.task.ExecutionTypeEnum;
import cn.iocoder.yudao.module.system.api.robot.processor.RequestProcessor;
import cn.iocoder.yudao.module.system.api.robot.dto.FloorZoneDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotInformationVO;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
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;
@ -57,6 +58,8 @@ import cn.iocoder.yudao.module.system.enums.item.UseStatusEnum;
import cn.iocoder.yudao.module.system.enums.path.PathTaskTypeEnum;
import cn.iocoder.yudao.module.system.enums.path.PathTaskTypeToRobotEnum;
import cn.iocoder.yudao.module.system.enums.redis.RobotCacheLockEnum;
import cn.iocoder.yudao.module.system.enums.robot.LocationLockEnum;
import cn.iocoder.yudao.module.system.enums.robot.LocationUseStatusEnum;
import cn.iocoder.yudao.module.system.enums.robot.RobotStatusEnum;
import cn.iocoder.yudao.module.system.enums.robot.RobotTaskDetailStatusEnum;
import cn.iocoder.yudao.module.system.enums.robot.RobotTaskModelEnum;
@ -92,6 +95,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
@ -162,6 +166,9 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
@Value("${zn.full_electricity:95}")
private String fullElectricity;
@Value("${zn.path_planning.task_chche_time:604800}")
private Long taskChcheTime;
@Resource
private RobotCameraService cameraService;
@ -313,6 +320,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
/**
* 查询车辆所在的地图id
*
* @param robotNo
* @return
*/
@ -444,14 +452,14 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
Object o = redisUtil.get(floorAreaKey);
if (ObjectUtil.isNotEmpty(o)) {
FloorZoneDTO floorZone = JSON.parseObject((String) o, FloorZoneDTO.class);
String oldFloorArea = floorZone.getFloor() + "-" + floorZone.getArea();
String oldFloorArea = floorZone.getFloor() + CommonConstant.SYMBOL + floorZone.getArea();
redisUtil.hdel(oldFloorArea, robotInformationDO.getRobotNo());
redisUtil.del(floorAreaKey);
if (ObjectUtil.isNotEmpty(o)) {
String newFloorAreaKey = RobotTaskChcheConstant.ROBOT_FLOOR_AREA + updateReqVO.getMacAddress();
redisUtil.set(newFloorAreaKey, JSON.toJSONString(floorZone));
Map<String, Object> map = new HashMap<>();
String value = floorZone.getFloor() + "-" + floorZone.getArea();
String value = floorZone.getFloor() + CommonConstant.SYMBOL + floorZone.getArea();
map.put(updateReqVO.getRobotNo(), value);
redisUtil.hmset(value, map);
}
@ -504,7 +512,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
Object o = redisUtil.get(floorAreaKey);
if (ObjectUtil.isNotEmpty(o)) {
FloorZoneDTO floorZone = JSON.parseObject((String) o, FloorZoneDTO.class);
String oldFloorArea = floorZone.getFloor() + "-" + floorZone.getArea();
String oldFloorArea = floorZone.getFloor() + CommonConstant.SYMBOL + floorZone.getArea();
redisUtil.hdel(oldFloorArea, robotInformationDO.getRobotNo());
redisUtil.del(floorAreaKey);
}
@ -898,7 +906,7 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
robotInformationVO.setPose2d(robotStatusDataPoseDTO);
// 模拟请求
processor.handleRequest(robotStatusDataDTO.getData().getFloor_zone().getFloor() + "_" + robotStatusDataDTO.getData().getFloor_zone().getArea(),
processor.handleRequest(robotStatusDataDTO.getData().getFloor_zone().getFloor() + CommonConstant.SYMBOL + robotStatusDataDTO.getData().getFloor_zone().getArea(),
robotStatusDataDTO.getMac(), JSONUtil.toJsonStr(robotInformationVO));
}
@ -1073,10 +1081,16 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
@Transactional(rollbackFor = Exception.class)
public void doTaskContinue(String robotNo) {
RobotTaskDetailActionLogDO actionLog = taskDetailActionLogService.getLastTaskByRobotNo(robotNo,CommandIdEnum.TASK.getType());
RobotTaskDetailActionLogDO actionLog = taskDetailActionLogService.getOriginalLastTaskByRobotNo(robotNo);
if (ObjectUtil.isEmpty(actionLog)) {
throw exception(ROBOT_LAST_TASK_NO_EXISTS);
}
if (!actionLog.getRobotNo().equals(actionLog.getOriginalRobotNo())) {
throw exception0(TASK_ASSIGN_OTHER_ROBOT.getCode(), TASK_ASSIGN_OTHER_ROBOT.getMsg() + actionLog.getRobotNo(),
TASK_ASSIGN_OTHER_ROBOT.getMsg() + actionLog.getRobotNo());
}
String mac = getMacByRobotNo(robotNo);
robotCloseTaskDetail(actionLog.getTaskDetailId() + "", mac, actionLog.getCommandType());
@ -1158,6 +1172,10 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
List<TaskToPathPlanningDTO> pathPlanningList = new ArrayList<>();
pathPlanningList.add(pathPlanning);
String plantingKey = PathPlanningChcheConstant.PATH_PLANNING_TASK + pathPlanning.getOrderId();
redisUtil.set(plantingKey, JSON.toJSONString(pathPlanning), taskChcheTime);
log.info("任务下发给PP :{}", JSON.toJSONString(pathPlanningList));
commonApi.commonMethod(pathPlanningList, PathPlanningTopicConstant.TASK_ASSIGNMENT_REQUEST);
}
@ -1175,7 +1193,8 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
takeTask(pathPlanning, isRemote);
} else if (PathTaskTypeEnum.RELEASE.getType().equals(actionLog.getCommandType())) {
releaseTask(pathPlanning);
} else if (PathTaskTypeEnum.MOVE.getType().equals(actionLog.getCommandType())) {
} else if (PathTaskTypeEnum.MOVE.getType().equals(actionLog.getCommandType())
|| PathTaskTypeEnum.MOVE_TO_POINT.getType().equals(actionLog.getCommandType())) {
}
}
@ -1214,11 +1233,14 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
* @param pathPlanning
*/
private void takeReleaseTask(TaskToPathPlanningDTO pathPlanning, Boolean isRemote) {
RobotTaskDetailDO robotTaskDetail = checkTaskDone(pathPlanning.getOrderId());
if (!RobotTaskStageEnum.TAKEING.getType().equals(robotTaskDetail.getTaskStage())
&& !RobotTaskStageEnum.GO_TAKE.getType().equals(robotTaskDetail.getTaskStage())
&& !RobotTaskStageEnum.UN_START.getType().equals(robotTaskDetail.getTaskStage())) {
//只要放货
String robotNo = pathPlanning.getRobotNoLimitationAreaDTOS().get(0).getRobotNo();
String mac = getMacByRobotNo(robotNo);
String cargoDetectedKey = RobotTaskChcheConstant.ROBOT_CARGO_DETECTED + mac;
Object cargoDetected = redisUtil.get(cargoDetectedKey);
if (ObjectUtil.isNotEmpty(cargoDetected) && RobotStatusCodeConstant.CARGO_DETECTED.equals(Boolean.parseBoolean(String.valueOf(cargoDetected)))) {
//说明取货完成
pathPlanning.setTakeLevel(null);
pathPlanning.setTakeGroupId(null);
pathPlanning.setTakeLocationNumber(null);
@ -1226,7 +1248,15 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
pathPlanning.setTakeOffsetHeight(null);
pathPlanning.setTakeOffsetHeight(null);
pathPlanning.setTaskType(PathTaskTypeToRobotEnum.DROP_OFF_GOODS.getType());
} else {
WareHouseLocationDO wareHouseLocation = wareHouseLocationMapper.selectById(robotTaskDetail.getFromLocationId());
if (wareHouseLocation.getTaskId().equals(robotTaskDetail.getTakeId()) && LocationLockEnum.NO.getType().equals(wareHouseLocation.getLocationLock())) {
wareHouseLocation.setSkuInfo(null);
wareHouseLocation.setSkuNumber(0L);
wareHouseLocation.setLocationLock(LocationLockEnum.YES.getType());
wareHouseLocation.setLocationUseStatus(LocationUseStatusEnum.NO.getType());
wareHouseLocationMapper.updateById(wareHouseLocation);
}
}else {
takeCheck(robotTaskDetail.getFromLocationId(), robotTaskDetail.getRobotTaskId(), isRemote);
}
releaseCheck(robotTaskDetail.getToLocationId(), robotTaskDetail.getRobotTaskId());
@ -1511,14 +1541,15 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
@Override
@Transactional(rollbackFor = Exception.class)
public void rmoteTransferTaskToNewFreeRobo(String oldRobotNo, Long id, String robotNo) {
RobotTaskDetailActionLogDO actionLog = taskDetailActionLogService.getLastTaskByRobotNo(robotNo,CommandIdEnum.TASK.getType());
RobotTaskDetailActionLogDO actionLog = taskDetailActionLogService.getOriginalLastTaskByRobotNo(oldRobotNo);
if (ObjectUtil.isEmpty(actionLog)) {
log.info("车辆前一个任务不存在或已经完成");
throw exception(ROBOT_LAST_TASK_NO_EXISTS);
}
if (!actionLog.getTaskDetailId().equals(id)) {
log.info("车辆最新的任务id是 {}, 车辆的前一个任务是 :{}", id, actionLog.getTaskDetailId());
throw exception(ROBOT_LAST_TASK_NO_EXISTS);
if (!oldRobotNo.equals(actionLog.getRobotNo())) {
log.info("此任务已经被转移到车辆 :{}", actionLog.getRobotNo());
throw exception0(TASK_ASSIGN_OTHER_ROBOT.getCode(), TASK_ASSIGN_OTHER_ROBOT.getMsg() + actionLog.getRobotNo(),
TASK_ASSIGN_OTHER_ROBOT.getMsg() + actionLog.getRobotNo());
}
if (ActionStatusEnum.DONE.getType().equals(actionLog.getActionStatus())) {
@ -1562,6 +1593,9 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
resendToPPData(pathPlanning, actionLog, robotInformationDO, true);
String plantingKey = PathPlanningChcheConstant.PATH_PLANNING_TASK + pathPlanning.getOrderId();
redisUtil.set(plantingKey, JSON.toJSONString(pathPlanning), taskChcheTime);
List<TaskToPathPlanningDTO> pathPlanningList = new ArrayList<>();
pathPlanningList.add(pathPlanning);
log.info("远遥任务转移, 任务下发给PP :{}", JSON.toJSONString(pathPlanningList));

View File

@ -109,4 +109,10 @@ public interface RobotTaskService extends IService<RobotTaskDO> {
* 校验是否存在未完成的任务
*/
void checkHaveDoingTask();
/**
* 设置车辆充电完成
* @param robotNo
*/
void chargeDone(String robotNo);
}

View File

@ -1,9 +1,7 @@
package cn.iocoder.yudao.module.system.service.robot;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@ -14,7 +12,6 @@ import cn.iocoder.yudao.module.mqtt.api.common.CommonApi;
import cn.iocoder.yudao.module.mqtt.api.task.dto.*;
import cn.iocoder.yudao.module.mqtt.enums.task.ExecutionTypeEnum;
import cn.iocoder.yudao.module.system.api.path.vo.RobotClosePathPlantingDTO;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.constant.path.PathPlanningTopicConstant;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.constant.robot.RobotTopicConstant;
@ -59,13 +56,11 @@ import cn.iocoder.yudao.module.system.enums.robot.task.RobotCommandTypeEnum;
//import cn.iocoder.yudao.module.system.service.robot.job.RobotCommonTaskService;
import cn.iocoder.yudao.module.system.enums.robot.task.RobotTaskManualInterventionEnum;
import cn.iocoder.yudao.module.system.enums.robot.task.RobotTaskStageEnum;
import cn.iocoder.yudao.module.system.enums.wait.WaitStatusEnum;
import cn.iocoder.yudao.module.system.service.information.DeviceInformationService;
import cn.iocoder.yudao.module.system.service.log.RobotTaskDetailActionLogService;
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.statistics.RobotWorkingHoursStatisticsService;
import cn.iocoder.yudao.module.system.service.wait.MoveToWaitService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import cn.iocoder.yudao.module.system.util.redis.RedissonUtils;
import com.alibaba.fastjson.JSON;
@ -558,33 +553,34 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(taskAssignDTO.getOrderType())
|| PathTaskTypeEnum.CHARGE.getType().equals(taskAssignDTO.getOrderType())) {
robotChargeLogs = chargeLogMapper.selectById(taskAssignDTO.getOrderId());
robotChargeLogs.setTaskStatus(ChargeTaskStatusEnum.DOING.getType());
chargeLogMapper.updateById(robotChargeLogs);
robotChargeLogs = chargeLogMapper.selectOne(new LambdaQueryWrapperX<RobotChargeLogDO>()
.eq(RobotChargeLogDO::getTaskDetailId, taskAssignDTO.getOrderId())
.orderByDesc(RobotChargeLogDO::getCreateTime)
.last("limit 1"));
chargeLogMapper.updateChargStatusByTaskId(taskAssignDTO.getOrderId(),ChargeTaskStatusEnum.CHARGEING.getType());
robotStatus = RobotStatusEnum.CHARGE.getType();
if (ObjectUtil.isNotEmpty(robotChargeLogs.getTaskDetailId())) {
if (ObjectUtil.isNotEmpty(robotChargeLogs) && ObjectUtil.isNotEmpty(robotChargeLogs.getTaskDetailId())) {
deviceNoMap.put(robotChargeLogs.getTaskDetailId(), robotChargeLogs.getDeviceNo());
}
if (ObjectUtil.isNotEmpty(robotChargeLogs) && ObjectUtil.isNotEmpty(robotChargeLogs.getDeviceNo())) {
setDeviceUseing(robotChargeLogs.getDeviceNo(), taskAssignDTO.getRobotNo());
}
}
chargeDone(taskAssignDTO.getRobotNo());
// chargeDone(taskAssignDTO.getRobotNo());
robotInformationMapper.updateRobotListStatus(taskAssignDTO.getRobotNo(), robotStatus, taskAssignDTO.getOrderId());
RobotTaskDO robotTaskDO = setTaskDoing(taskAssignDTO.getOrderId(), taskAssignDTO.getRobotNo(), deviceNoMap, taskAssignDTO.getWaitId());
if (ObjectUtil.isNotEmpty(robotChargeLogs) && ObjectUtil.isNotEmpty(robotChargeLogs.getDeviceNo())) {
setDeviceUseing(robotChargeLogs.getDeviceNo(), taskAssignDTO.getRobotNo());
}
RobotTaskDetailActionLogSaveReqVO logOne = new RobotTaskDetailActionLogSaveReqVO();
logOne.setCommandType(taskAssignDTO.getOrderType());
String actionMsg = taskAssignDTO.getRobotActionMsg() + robotTaskDO.getTaskNo();
logOne.setActionMsg(actionMsg);
logOne.setRobotNo(taskAssignDTO.getRobotNo());
logOne.setOriginalRobotNo(taskAssignDTO.getRobotNo());
logOne.setStartTime(LocalDateTime.now());
logOne.setTaskNo(robotTaskDO.getTaskNo());
logOne.setCommandId(-1L);
@ -1463,10 +1459,12 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
*
* @param robotNo
*/
private void chargeDone(String robotNo) {
@Override
public void chargeDone(String robotNo) {
RobotInformationDO robotInformationDO = robotInformationMapper.selectOne(new LambdaQueryWrapperX<RobotInformationDO>()
.eq(RobotInformationDO::getRobotNo, robotNo));
if (!RobotStatusEnum.CHARGE.getType().equals(robotInformationDO.getRobotStatus())) {
log.info("车辆非充电状态:{}",robotNo);
return;
}

View File

@ -1,16 +1,12 @@
package cn.iocoder.yudao.module.system.service.robot;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.module.system.api.robot.vo.RobotInformationVO;
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.controller.admin.robot.warn.RobotWarnCodeMappingVO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotWarnCodeMappingDO;
import cn.iocoder.yudao.module.system.dal.mysql.robot.RobotWarnCodeMappingMapper;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -18,18 +14,11 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.apache.commons.io.FileUtils;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
@ -37,7 +26,6 @@ import java.util.function.Function;
import java.util.stream.Collectors;
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;

View File

@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
import cn.iocoder.yudao.module.system.constant.CommonConstant;
import cn.iocoder.yudao.module.system.constant.webSocket.WebSocketConstant;
import cn.iocoder.yudao.module.system.controller.admin.log.vo.UserOperationLogSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotWarnMsgPageReqVO;
@ -118,7 +119,7 @@ public class RobotWarnMsgServiceImpl extends ServiceImpl<RobotWarnMsgMapper, Rob
return;
}
for (PositionMapDO positionMapDO : positionMapDOS) {
webSocketSenderApi.sendObject(positionMapDO.getFloor() + "_" + positionMapDO.getArea(),
webSocketSenderApi.sendObject(positionMapDO.getFloor() + CommonConstant.SYMBOL + positionMapDO.getArea(),
WebSocketConstant.AGV_WARN, JSONUtil.toJsonStr(errorMsg));
}
@ -177,13 +178,26 @@ public class RobotWarnMsgServiceImpl extends ServiceImpl<RobotWarnMsgMapper, Rob
@Override
public Map<String, List<RobotWarnMsgClassificationDTO>> robotWarnMsgClassification(String type) {
if (TimeTypeEnum.WEEK.getType().equals(type)) {
List<RobotWarnMsgClassificationDTO> data = warnMsgMapper.getRobotWarnMsgClassification(type);
if (ObjectUtil.isEmpty(data)) {
return null;
}
return data.stream().collect(Collectors.groupingBy(RobotWarnMsgClassificationDTO::getWarnTime));
Map<String, List<RobotWarnMsgClassificationDTO>> map =
data.stream().collect(Collectors.groupingBy(RobotWarnMsgClassificationDTO::getWarnTime));
Calendar now = Calendar.getInstance();
now.setTime(new Date());
for (int i = 0; i < 7; i++) {
String timeStr = DateUtils.getYYYMMDD(now.getTime());
if (!map.containsKey(timeStr)) {
map.put(timeStr,new ArrayList<>());
}
now.set(Calendar.DATE, now.get(Calendar.DATE) - 1);
}
return map;
}
//季度是90天分成10份是9. getMonthData已经扣了1所以是8
@ -198,7 +212,7 @@ public class RobotWarnMsgServiceImpl extends ServiceImpl<RobotWarnMsgMapper, Rob
/**
* 按月查询
*
* @param data
* @param day
* @return
*/
private LinkedHashMap<String, List<RobotWarnMsgClassificationDTO>> getMonthData(int day) {
@ -220,7 +234,7 @@ public class RobotWarnMsgServiceImpl extends ServiceImpl<RobotWarnMsgMapper, Rob
String endTime = DateUtils.getYYYMMDD(endDate);
List<RobotWarnMsgClassificationDTO> data = warnMsgMapper.getRobotWarnMsgByTime(startTime, endTime);
String key = startKeyDateStr + "_" + endTime;
String key = startKeyDateStr + CommonConstant.SYMBOL + endTime;
map.put(key, data);
}
return map;

View File

@ -15,7 +15,9 @@ import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
@ -90,6 +92,7 @@ public class RobotCameraServiceImpl extends ServiceImpl<RobotCameraMapper, Robot
/**
* 判断IP是否存在
*
* @param cameraAddVOList
*/
@Override
@ -107,7 +110,7 @@ public class RobotCameraServiceImpl extends ServiceImpl<RobotCameraMapper, Robot
}
List<String> ips = robotCameraDOs.stream().map(RobotCameraDO::getCameraIp).collect(Collectors.toList());
String join = StringUtils.join(ips, ",");
throw exception(CAMERA_IP_EXIST,"以下摄像头IP已经存在 "+join);
throw exception(CAMERA_IP_EXIST, "以下摄像头IP已经存在 " + join);
}
@Override
@ -116,20 +119,47 @@ public class RobotCameraServiceImpl extends ServiceImpl<RobotCameraMapper, Robot
List<RobotCameraDO> cameraDOList = BeanUtils.toBean(cameraAddVOList, RobotCameraDO.class);
for (RobotCameraDO robotCameraDO : cameraDOList) {
try {
if (ObjectUtil.isEmpty(robotCameraDO.getId())) {
robotCameraDO.setCameraAccount(AESEncryptionUtil.encrypt(robotCameraDO.getCameraAccount(),cameraSecretKey));
robotCameraDO.setCameraPassword(AESEncryptionUtil.encrypt(robotCameraDO.getCameraPassword(),cameraSecretKey));
}
setCameraAccountAndPassword(robotCameraDO);
} catch (Exception e) {
throw new RuntimeException(e);
throw exception(CAMERA_DECRYPTION_FAILED);
}
robotCameraDO.setRobotNo(robotNo);
}
cameraMapper.insert(cameraDOList);
}
private void setCameraAccountAndPassword(RobotCameraDO robotCameraDO) {
if (ObjectUtil.isEmpty(robotCameraDO.getId())) {
try {
robotCameraDO.setCameraAccount(AESEncryptionUtil.encrypt(robotCameraDO.getCameraAccount(), cameraSecretKey));
robotCameraDO.setCameraPassword(AESEncryptionUtil.encrypt(robotCameraDO.getCameraPassword(), cameraSecretKey));
} catch (Exception e) {
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);
}
}
/**
* 根据车辆编号删除
*
* @param robotNo
*/
@Override

View File

@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.constant.robot.RobotTaskChcheConstant;
import cn.iocoder.yudao.module.system.controller.admin.config.vo.CommonConfigVO;
import cn.iocoder.yudao.module.system.controller.admin.robot.vo.RobotTaskDetailAddVO;
@ -30,7 +30,6 @@ import cn.iocoder.yudao.module.system.enums.device.DeviceUseStatusEnum;
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.service.positionmap.PositionMapItemService;
import cn.iocoder.yudao.module.system.service.robot.pathplanning.RobotPathPlanningService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import com.alibaba.fastjson.JSON;

View File

@ -4,7 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.api.robot.dto.RobotStatusDataPoseDTO;
import cn.iocoder.yudao.module.system.api.robot.websocket.RobotStatusDataPoseDTO;
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.config.vo.CommonConfigVO;

View File

@ -34,6 +34,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.RobotTaskService;
import cn.iocoder.yudao.module.system.service.robot.job.DistributeTasksService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import com.alibaba.fastjson.JSON;
@ -42,6 +43,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -105,6 +107,10 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
@Resource
private CommonApi commonApi;
@Resource
@Lazy
private RobotTaskService taskService;
/**
* 下发任务给PP
*/
@ -250,6 +256,9 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
List<RobotTaskDetailAddVO> taskDetails = new ArrayList<>();
List<RobotTaskDO> tasks = new ArrayList<>();
for (PositionMapItemDO v : robotMapItems) {
taskService.chargeDone(v.getRobotNo());
RobotTaskDO task = new RobotTaskDO();
String incrementByKey = redisUtil.getIncrementByKey(RobotCacheLockEnum.MOVE_TASK_NO.getKey());
task.setTaskNo(moveTaskNo + DateUtils.getYearMonthDay() + incrementByKey);
@ -392,6 +401,10 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
//前一个任务是仅取货
List<String> robotDoTake = getRobotDoTake(robots);
for (RobotInformationDO robot : robots) {
taskService.chargeDone(robot.getRobotNo());
}
List<PositionMapItemDO> positionMapItems = positionMapItemMapper.selectList(new LambdaQueryWrapperX<PositionMapItemDO>()
.eq(PositionMapItemDO::getType, PositionMapItemEnum.STOP.getType())
.eq(PositionMapItemDO::getUseStatus, UseStatusEnum.FREE.getType()));
@ -469,7 +482,7 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
pathPlanning.setReleaseLocationNumber(taskDetailDO.getToLocationNumber());
pathPlanning.setReleasePointId(toLocation.getMapItemId());
pathPlanningSetReleaseHeight(pathPlanning,toLocation);
pathPlanningSetReleaseHeight(pathPlanning, toLocation);
pathPlanning.setReleaseLevel(toLocation.getLocationStorey());
pathPlanning.setReleaseOffsetHeight(offsetHeight);
if (ObjectUtil.isNotEmpty(taskDetailDO.getToLaneId())) {
@ -493,18 +506,19 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
/**
* 设置放货高度
*
* @param pathPlanning
* @param toLocation
*/
private void pathPlanningSetReleaseHeight(TaskToPathPlanningDTO pathPlanning, WareHouseLocationDO toLocation) {
if ( ZeroOneEnum.ONE.getType().equals(toLocation.getLocationStorey())) {
if (ZeroOneEnum.ONE.getType().equals(toLocation.getLocationStorey())) {
pathPlanning.setReleaseHeight(0.0);
return;
}
WareHouseLocationDO nextLocation = locationMapper.selectOne(new LambdaQueryWrapperX<WareHouseLocationDO>()
.eq(WareHouseLocationDO::getId, toLocation.getMapItemId())
.eq(WareHouseLocationDO::getLocationStorey, toLocation.getLocationStorey()-1)
.eq(WareHouseLocationDO::getLocationStorey, toLocation.getLocationStorey() - 1)
.last("limit 1"));
if (ObjectUtil.isNotEmpty(nextLocation) && ObjectUtil.isNotEmpty(nextLocation.getLocationTotalHeight())) {
pathPlanning.setReleaseHeight(Double.valueOf(nextLocation.getLocationTotalHeight() + ""));
@ -513,7 +527,7 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
Integer locationStorey = toLocation.getLocationStorey() - 1;
double height = locationStorey * defaultTrayHeight;
log.info("放货设置默认高度 :{}",pathPlanning.getReleaseHeight());
log.info("放货设置默认高度 :{}", pathPlanning.getReleaseHeight());
pathPlanning.setReleaseHeight(height);
}
@ -530,7 +544,7 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
}
Integer locationStorey = fromLocation.getLocationStorey();
double height = locationStorey * defaultTrayHeight;
log.info("取货设置默认取货高度 :{}",height);
log.info("取货设置默认取货高度 :{}", height);
pathPlanning.setTakeHeight(height);
}

View File

@ -8,6 +8,13 @@ import java.util.Base64;
public class AESEncryptionUtil {
private static final String AES_ALGORITHM = "AES";
/**
* 加密
* @param plaintext
* @param key
* @return
* @throws Exception
*/
public static String encrypt(String plaintext, String key) throws Exception {
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), AES_ALGORITHM);
Cipher cipher = Cipher.getInstance(AES_ALGORITHM);
@ -16,6 +23,13 @@ public class AESEncryptionUtil {
return Base64.getEncoder().encodeToString(encryptedBytes);
}
/**
* 解密
* @param ciphertext
* @param key
* @return
* @throws Exception
*/
public static String decrypt(String ciphertext, String key) throws Exception {
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), AES_ALGORITHM);
Cipher cipher = Cipher.getInstance(AES_ALGORITHM);

View File

@ -2,6 +2,17 @@
<!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.RobotChargeLogMapper">
<update id="updateChargStatusByTaskId">
update
robot_charge_log
set
task_status = #{taskStatus}
where
task_detail_id = #{taskDetailId}
and deleted = '0'
</update>
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。

View File

@ -55,12 +55,6 @@
<when test="type == 1">
AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt;= date(create_time)
</when>
<when test="type == 2">
AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= date(create_time)
</when>
<when test="type == 3">
AND DATE_SUB(CURDATE(), INTERVAL 90 DAY) &lt;= date(create_time)
</when>
</choose>
</where>
GROUP BY warnTime ,warn_level