任务优化

This commit is contained in:
cbs 2025-05-30 14:16:30 +08:00
parent 4683480d39
commit 58755daf70
11 changed files with 154 additions and 53 deletions

View File

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

View File

@ -27,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j @Slf4j
@RestController // 提供 RESTful API 接口 Feign 调用 @RestController // 提供 RESTful API 接口 Feign 调用
@ -45,9 +47,11 @@ public class RobotStatusApiImpl implements RobotStatusApi {
@Resource @Resource
private RequestProcessor processor; private RequestProcessor processor;
@Autowired private static final ExecutorService executorService = Executors.newFixedThreadPool(5);
private ThreadPoolTaskExecutor taskExecutor;
/*@Autowired
private ThreadPoolTaskExecutor taskExecutor;
*/
@Resource @Resource
private CommonApi commonApi; private CommonApi commonApi;
@ -60,7 +64,9 @@ public class RobotStatusApiImpl implements RobotStatusApi {
@Override @Override
@SystemRateLimiter(time = 1, count = 150, keyArg = "robotStatusUpdate", message = "机器人上报点位超过限流") @SystemRateLimiter(time = 1, count = 150, keyArg = "robotStatusUpdate", message = "机器人上报点位超过限流")
public void robotStatusUpdate(RobotPoseStatusDTO robotStatusDataDTO) { public void robotStatusUpdate(RobotPoseStatusDTO robotStatusDataDTO) {
executorService.execute(() -> {
updateRobotPosed(robotStatusDataDTO); updateRobotPosed(robotStatusDataDTO);
});
} }
/** /**
@ -126,8 +132,6 @@ public class RobotStatusApiImpl implements RobotStatusApi {
} }
private void sendToPP(RobotStatusDataPoseDTO robotStatusDataPoseDTO) { private void sendToPP(RobotStatusDataPoseDTO robotStatusDataPoseDTO) {
taskExecutor.execute(() -> {
commonApi.commonMethod(robotStatusDataPoseDTO, PathPlanningTopicConstant.AGV_POSE); commonApi.commonMethod(robotStatusDataPoseDTO, PathPlanningTopicConstant.AGV_POSE);
});
} }
} }

View File

@ -192,7 +192,8 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DOING.getType() taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DOING.getType()
, null); , 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); chargeDoing(robotCompleteTaskDTO);
} }
} }
@ -258,12 +259,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType()) if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())
|| PathTaskTypeEnum.CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())) { || PathTaskTypeEnum.CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())) {
RobotChargeLogDO build = RobotChargeLogDO chargeLogMapper.updateChargStatusByTaskId(robotCompleteTaskDTO.getOrderId(),ChargeTaskStatusEnum.DONE.getType());
.builder()
.id(robotCompleteTaskDTO.getOrderId())
.taskStatus(ChargeTaskStatusEnum.CHARGEING.getType())
.build();
chargeLogMapper.updateById(build);
} }
taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DONE.getType(), LocalDateTime.now()); taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DONE.getType(), LocalDateTime.now());
@ -472,28 +468,18 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
private void chargeDoing(RobotCompleteTaskDTO robotCompleteTaskDTO) { private void chargeDoing(RobotCompleteTaskDTO robotCompleteTaskDTO) {
RobotCommandStateDTO commandStatus = robotCompleteTaskDTO.getCommandStatus(); RobotCommandStateDTO commandStatus = robotCompleteTaskDTO.getCommandStatus();
Integer taskStatus = ChargeTaskStatusEnum.CHARGEING.getType();
//编辑地图会判断这表的状态,所以自动充电任务移动到充电点就改为完成 //自动充电任务移动到充电点就改为完成
if (ObjectUtil.isNotEmpty(commandStatus) && CommandTypeEnum.MOVE_POSES.getType().equals(commandStatus.getCommandType()) if (ObjectUtil.isNotEmpty(commandStatus) && CommandTypeEnum.MOVE_POSES.getType().equals(commandStatus.getCommandType())
&& RobotExecutionStateConstant.DONE.equals(commandStatus.getExecutionState())) { && RobotExecutionStateConstant.DONE.equals(commandStatus.getExecutionState())) {
taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DONE.getType(), LocalDateTime.now()); taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DONE.getType(), LocalDateTime.now());
setTaskDone(robotCompleteTaskDTO);
} }
RobotChargeLogDO build = RobotChargeLogDO chargeLogMapper.updateChargStatusByTaskId(robotCompleteTaskDTO.getOrderId(),ChargeTaskStatusEnum.CHARGEING.getType());
.builder()
.id(robotCompleteTaskDTO.getOrderId())
.taskStatus(taskStatus)
.build();
chargeLogMapper.updateById(build);
} }
/** public RobotTaskDetailDO setTaskDone(RobotCompleteTaskDTO robotCompleteTaskDTO) {
* 任务完成
*
* @param robotCompleteTaskDTO
*/
private void taskDone(RobotCompleteTaskDTO robotCompleteTaskDTO) {
//更新任务状态 //更新任务状态
RobotTaskDetailDO detailDO = new RobotTaskDetailDO(); RobotTaskDetailDO detailDO = new RobotTaskDetailDO();
detailDO.setId(robotCompleteTaskDTO.getOrderId()); detailDO.setId(robotCompleteTaskDTO.getOrderId());
@ -505,7 +491,8 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
RobotTaskDetailDO robotTaskDetailDO = robotTaskDetailMapper.selectById(robotCompleteTaskDTO.getOrderId()); RobotTaskDetailDO robotTaskDetailDO = robotTaskDetailMapper.selectById(robotCompleteTaskDTO.getOrderId());
List<RobotTaskDetailDO> taskDetails = robotTaskDetailMapper.queryByTaskId(robotTaskDetailDO.getRobotTaskId()); List<RobotTaskDetailDO> taskDetails = robotTaskDetailMapper.queryByTaskId(robotTaskDetailDO.getRobotTaskId());
boolean done = 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) { if (done) {
RobotTaskDO robotTaskDO = new RobotTaskDO(); RobotTaskDO robotTaskDO = new RobotTaskDO();
robotTaskDO.setId(taskDetails.get(0).getRobotTaskId()); robotTaskDO.setId(taskDetails.get(0).getRobotTaskId());
@ -514,6 +501,17 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
robotTaskMapper.updateRobot(robotTaskDO); robotTaskMapper.updateRobot(robotTaskDO);
taskCycleMapper.deletByRobotTaskId(taskDetails.get(0).getRobotTaskId()); 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>() RobotInformationDO robotInformationDO = robotInformationMapper.selectOne(new LambdaQueryWrapperX<RobotInformationDO>()
.eq(RobotInformationDO::getRobotNo, robotTaskDetailDO.getRobotNo())); .eq(RobotInformationDO::getRobotNo, robotTaskDetailDO.getRobotNo()));

View File

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

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.log.UserOperationLogService;
import cn.iocoder.yudao.module.system.service.robot.RobotInformationService; 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.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.service.robot.mapstop.RobotMapStopService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil; import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import cn.iocoder.yudao.module.system.util.redis.RedissonUtils; 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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -123,6 +125,10 @@ public class RemoteControllerInformationServiceImpl extends ServiceImpl<RemoteCo
@Resource @Resource
private RobotTaskDetailService taskDetailService; private RobotTaskDetailService taskDetailService;
@Resource
@Lazy
private RobotTaskService taskService;
@Resource @Resource
private ControllerTaskTransferLogService controllerTaskTransferLogService; private ControllerTaskTransferLogService controllerTaskTransferLogService;
@ -324,7 +330,12 @@ public class RemoteControllerInformationServiceImpl extends ServiceImpl<RemoteCo
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(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 { } finally {
lock.unlock(); lock.unlock();
} }

View File

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

View File

@ -553,27 +553,27 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(taskAssignDTO.getOrderType()) if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(taskAssignDTO.getOrderType())
|| PathTaskTypeEnum.CHARGE.getType().equals(taskAssignDTO.getOrderType())) { || PathTaskTypeEnum.CHARGE.getType().equals(taskAssignDTO.getOrderType())) {
robotChargeLogs = chargeLogMapper.selectById(taskAssignDTO.getOrderId()); robotChargeLogs = chargeLogMapper.selectOne(new LambdaQueryWrapperX<RobotChargeLogDO>()
.eq(RobotChargeLogDO::getTaskDetailId, taskAssignDTO.getOrderId())
robotChargeLogs.setTaskStatus(ChargeTaskStatusEnum.DOING.getType()); .orderByDesc(RobotChargeLogDO::getCreateTime)
chargeLogMapper.updateById(robotChargeLogs); .last("limit 1"));
chargeLogMapper.updateChargStatusByTaskId(taskAssignDTO.getOrderId(),ChargeTaskStatusEnum.CHARGEING.getType());
robotStatus = RobotStatusEnum.CHARGE.getType(); robotStatus = RobotStatusEnum.CHARGE.getType();
if (ObjectUtil.isNotEmpty(robotChargeLogs) && ObjectUtil.isNotEmpty(robotChargeLogs.getTaskDetailId())) {
if (ObjectUtil.isNotEmpty(robotChargeLogs.getTaskDetailId())) {
deviceNoMap.put(robotChargeLogs.getTaskDetailId(), robotChargeLogs.getDeviceNo()); deviceNoMap.put(robotChargeLogs.getTaskDetailId(), robotChargeLogs.getDeviceNo());
} }
}
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())) { if (ObjectUtil.isNotEmpty(robotChargeLogs) && ObjectUtil.isNotEmpty(robotChargeLogs.getDeviceNo())) {
setDeviceUseing(robotChargeLogs.getDeviceNo(), taskAssignDTO.getRobotNo()); setDeviceUseing(robotChargeLogs.getDeviceNo(), taskAssignDTO.getRobotNo());
} }
}
// chargeDone(taskAssignDTO.getRobotNo());
robotInformationMapper.updateRobotListStatus(taskAssignDTO.getRobotNo(), robotStatus, taskAssignDTO.getOrderId());
RobotTaskDO robotTaskDO = setTaskDoing(taskAssignDTO.getOrderId(), taskAssignDTO.getRobotNo(), deviceNoMap, taskAssignDTO.getWaitId());
RobotTaskDetailActionLogSaveReqVO logOne = new RobotTaskDetailActionLogSaveReqVO(); RobotTaskDetailActionLogSaveReqVO logOne = new RobotTaskDetailActionLogSaveReqVO();
logOne.setCommandType(taskAssignDTO.getOrderType()); logOne.setCommandType(taskAssignDTO.getOrderType());
@ -1459,10 +1459,12 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
* *
* @param robotNo * @param robotNo
*/ */
private void chargeDone(String robotNo) { @Override
public void chargeDone(String robotNo) {
RobotInformationDO robotInformationDO = robotInformationMapper.selectOne(new LambdaQueryWrapperX<RobotInformationDO>() RobotInformationDO robotInformationDO = robotInformationMapper.selectOne(new LambdaQueryWrapperX<RobotInformationDO>()
.eq(RobotInformationDO::getRobotNo, robotNo)); .eq(RobotInformationDO::getRobotNo, robotNo));
if (!RobotStatusEnum.CHARGE.getType().equals(robotInformationDO.getRobotStatus())) { if (!RobotStatusEnum.CHARGE.getType().equals(robotInformationDO.getRobotStatus())) {
log.info("车辆非充电状态:{}",robotNo);
return; return;
} }

View File

@ -15,7 +15,9 @@ import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -90,6 +92,7 @@ public class RobotCameraServiceImpl extends ServiceImpl<RobotCameraMapper, Robot
/** /**
* 判断IP是否存在 * 判断IP是否存在
*
* @param cameraAddVOList * @param cameraAddVOList
*/ */
@Override @Override
@ -116,20 +119,47 @@ public class RobotCameraServiceImpl extends ServiceImpl<RobotCameraMapper, Robot
List<RobotCameraDO> cameraDOList = BeanUtils.toBean(cameraAddVOList, RobotCameraDO.class); List<RobotCameraDO> cameraDOList = BeanUtils.toBean(cameraAddVOList, RobotCameraDO.class);
for (RobotCameraDO robotCameraDO : cameraDOList) { for (RobotCameraDO robotCameraDO : cameraDOList) {
try { try {
if (ObjectUtil.isEmpty(robotCameraDO.getId())) { setCameraAccountAndPassword(robotCameraDO);
robotCameraDO.setCameraAccount(AESEncryptionUtil.encrypt(robotCameraDO.getCameraAccount(),cameraSecretKey));
robotCameraDO.setCameraPassword(AESEncryptionUtil.encrypt(robotCameraDO.getCameraPassword(),cameraSecretKey));
}
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw exception(CAMERA_DECRYPTION_FAILED);
} }
robotCameraDO.setRobotNo(robotNo); robotCameraDO.setRobotNo(robotNo);
} }
cameraMapper.insert(cameraDOList); 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 * @param robotNo
*/ */
@Override @Override

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.*;
import cn.iocoder.yudao.module.system.enums.robot.charge.ChargeModelEnum; 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.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.service.robot.job.DistributeTasksService;
import cn.iocoder.yudao.module.system.util.redis.RedisUtil; import cn.iocoder.yudao.module.system.util.redis.RedisUtil;
import com.alibaba.fastjson.JSON; 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.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -105,6 +107,10 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
@Resource @Resource
private CommonApi commonApi; private CommonApi commonApi;
@Resource
@Lazy
private RobotTaskService taskService;
/** /**
* 下发任务给PP * 下发任务给PP
*/ */
@ -250,6 +256,9 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
List<RobotTaskDetailAddVO> taskDetails = new ArrayList<>(); List<RobotTaskDetailAddVO> taskDetails = new ArrayList<>();
List<RobotTaskDO> tasks = new ArrayList<>(); List<RobotTaskDO> tasks = new ArrayList<>();
for (PositionMapItemDO v : robotMapItems) { for (PositionMapItemDO v : robotMapItems) {
taskService.chargeDone(v.getRobotNo());
RobotTaskDO task = new RobotTaskDO(); RobotTaskDO task = new RobotTaskDO();
String incrementByKey = redisUtil.getIncrementByKey(RobotCacheLockEnum.MOVE_TASK_NO.getKey()); String incrementByKey = redisUtil.getIncrementByKey(RobotCacheLockEnum.MOVE_TASK_NO.getKey());
task.setTaskNo(moveTaskNo + DateUtils.getYearMonthDay() + incrementByKey); task.setTaskNo(moveTaskNo + DateUtils.getYearMonthDay() + incrementByKey);
@ -392,6 +401,10 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
//前一个任务是仅取货 //前一个任务是仅取货
List<String> robotDoTake = getRobotDoTake(robots); List<String> robotDoTake = getRobotDoTake(robots);
for (RobotInformationDO robot : robots) {
taskService.chargeDone(robot.getRobotNo());
}
List<PositionMapItemDO> positionMapItems = positionMapItemMapper.selectList(new LambdaQueryWrapperX<PositionMapItemDO>() List<PositionMapItemDO> positionMapItems = positionMapItemMapper.selectList(new LambdaQueryWrapperX<PositionMapItemDO>()
.eq(PositionMapItemDO::getType, PositionMapItemEnum.STOP.getType()) .eq(PositionMapItemDO::getType, PositionMapItemEnum.STOP.getType())
.eq(PositionMapItemDO::getUseStatus, UseStatusEnum.FREE.getType())); .eq(PositionMapItemDO::getUseStatus, UseStatusEnum.FREE.getType()));
@ -493,6 +506,7 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
/** /**
* 设置放货高度 * 设置放货高度
*
* @param pathPlanning * @param pathPlanning
* @param toLocation * @param toLocation
*/ */

View File

@ -8,6 +8,13 @@ import java.util.Base64;
public class AESEncryptionUtil { public class AESEncryptionUtil {
private static final String AES_ALGORITHM = "AES"; private static final String AES_ALGORITHM = "AES";
/**
* 加密
* @param plaintext
* @param key
* @return
* @throws Exception
*/
public static String encrypt(String plaintext, String key) throws Exception { public static String encrypt(String plaintext, String key) throws Exception {
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), AES_ALGORITHM); SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), AES_ALGORITHM);
Cipher cipher = Cipher.getInstance(AES_ALGORITHM); Cipher cipher = Cipher.getInstance(AES_ALGORITHM);
@ -16,6 +23,13 @@ public class AESEncryptionUtil {
return Base64.getEncoder().encodeToString(encryptedBytes); return Base64.getEncoder().encodeToString(encryptedBytes);
} }
/**
* 解密
* @param ciphertext
* @param key
* @return
* @throws Exception
*/
public static String decrypt(String ciphertext, String key) throws Exception { public static String decrypt(String ciphertext, String key) throws Exception {
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), AES_ALGORITHM); SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), AES_ALGORITHM);
Cipher cipher = Cipher.getInstance(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"> <!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"> <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 增删改查即可。 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。