添加处理中任务的校验

This commit is contained in:
cbs 2025-03-28 15:59:30 +08:00
parent 01ce2f4226
commit 28142919c8
17 changed files with 164 additions and 25 deletions

View File

@ -178,7 +178,7 @@ public interface ErrorCodeConstants {
// ========== 库位 1-002-032-000 ========== // ========== 库位 1-002-032-000 ==========
ErrorCode HOUSE_LOCATION_NOT_EXISTS = new ErrorCode(1-002-032-001, "库位不存在"); ErrorCode HOUSE_LOCATION_NOT_EXISTS = new ErrorCode(1-002-032-001, "库位不存在");
ErrorCode HOUSE_LOCATION_NO_EXIST = new ErrorCode(1-002-032-002, "库位编号重复"); ErrorCode HOUSE_LOCATION_HAVE_TASK = new ErrorCode(1-002-032-002, "库位存在处理中的任务");
// ========== 车辆类型 1-002-033-000========== // ========== 车辆类型 1-002-033-000==========
ErrorCode MODEL_NOT_EXISTS = new ErrorCode(1-002-033-001, "车辆类型不存在"); ErrorCode MODEL_NOT_EXISTS = new ErrorCode(1-002-033-001, "车辆类型不存在");
@ -191,6 +191,7 @@ public interface ErrorCodeConstants {
ErrorCode ROBOT_LAST_TASK_DELETE = new ErrorCode(1-002-034-005, "超过限制的时间,无法继续执行前一个任务"); ErrorCode ROBOT_LAST_TASK_DELETE = new ErrorCode(1-002-034-005, "超过限制的时间,无法继续执行前一个任务");
ErrorCode ROBOT_NOT_FOUND_WAIT_ITEM = new ErrorCode(1-002-034-006, "没有空闲的停车点"); ErrorCode ROBOT_NOT_FOUND_WAIT_ITEM = new ErrorCode(1-002-034-006, "没有空闲的停车点");
ErrorCode ROBOT_NOT_FOUND_FREE_CHARGING_STATION = new ErrorCode(1-002-034-007, "没有空闲的充电桩"); ErrorCode ROBOT_NOT_FOUND_FREE_CHARGING_STATION = new ErrorCode(1-002-034-007, "没有空闲的充电桩");
ErrorCode ROBOT_HAVE_DOING_TASK = new ErrorCode(1-002-034-010, "车辆有处理中的任务");
// ========== 机器人任务主表 1-002-035-000 ========== // ========== 机器人任务主表 1-002-035-000 ==========
ErrorCode TASK_NOT_EXISTS = new ErrorCode(1-002-035-001, "机器人任务主表不存在"); ErrorCode TASK_NOT_EXISTS = new ErrorCode(1-002-035-001, "机器人任务主表不存在");

View File

@ -142,10 +142,11 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
/** /**
* 上一条明细设置为完成 * 上一条明细设置为完成
*
* @param mac * @param mac
* @return * @return
*/ */
public RobotTaskDetailActionLogDO setLastLogDone(String mac){ public RobotTaskDetailActionLogDO setLastLogDone(String mac) {
String robotNo = robotInformationService.getRobotNoByMac(mac); String robotNo = robotInformationService.getRobotNoByMac(mac);
return taskDetailActionLogService.setPreviousTaskDoneByRobotNo(robotNo); return taskDetailActionLogService.setPreviousTaskDoneByRobotNo(robotNo);
} }
@ -158,7 +159,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
RobotTaskDetailActionLogDO lastLog = setLastLogDone(robotCompleteTaskDTO.getMac()); RobotTaskDetailActionLogDO lastLog = setLastLogDone(robotCompleteTaskDTO.getMac());
if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())) { if (PathTaskTypeEnum.AUTO_CHARGE.getType().equals(robotCompleteTaskDTO.getOrderType())) {
chargeDoing(robotCompleteTaskDTO, robotDoingActionKey,lastLog); chargeDoing(robotCompleteTaskDTO, robotDoingActionKey, lastLog);
} else if (PathTaskTypeEnum.MOVE_TO_WAIT.getType().equals(robotCompleteTaskDTO.getOrderType())) { } else if (PathTaskTypeEnum.MOVE_TO_WAIT.getType().equals(robotCompleteTaskDTO.getOrderType())) {
RobotTaskDetailActionLogDO logOne = new RobotTaskDetailActionLogDO(); RobotTaskDetailActionLogDO logOne = new RobotTaskDetailActionLogDO();
logOne.setActionMsg("车辆正在前往等待点"); logOne.setActionMsg("车辆正在前往等待点");
@ -178,10 +179,10 @@ 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()))
&& ObjectUtil.isNotEmpty(robotCompleteTaskDTO.getCommandStatus()) && ObjectUtil.isNotEmpty(robotCompleteTaskDTO.getCommandStatus())
&& CommandTypeEnum.MOVE_POSES.getType().equals(robotCompleteTaskDTO.getCommandStatus().getCommandType()) && CommandTypeEnum.MOVE_POSES.getType().equals(robotCompleteTaskDTO.getCommandStatus().getCommandType())
&& RobotExecutionStateConstant.DONE.equals(robotCompleteTaskDTO.getCommandStatus().getExecutionState())) { && RobotExecutionStateConstant.DONE.equals(robotCompleteTaskDTO.getCommandStatus().getExecutionState())) {
log.info("充电任务准备让充电设备自动伸出 :{}",robotCompleteTaskDTO.getOrderId()); log.info("充电任务准备让充电设备自动伸出 :{}", robotCompleteTaskDTO.getOrderId());
RobotChargeLogDO robotChargeLog = chargeLogMapper.selectById(robotCompleteTaskDTO.getOrderId()); RobotChargeLogDO robotChargeLog = chargeLogMapper.selectById(robotCompleteTaskDTO.getOrderId());
deviceInformationService.chargeDeviceExtend(robotChargeLog.getDeviceNo()); deviceInformationService.chargeDeviceExtend(robotChargeLog.getDeviceNo());
} }
@ -189,7 +190,8 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
sendStartDoActionToPP(robotCompleteTaskDTO.getCommandStatus(), robotCompleteTaskDTO.getMac(), sendStartDoActionToPP(robotCompleteTaskDTO.getCommandStatus(), robotCompleteTaskDTO.getMac(),
String.valueOf(robotCompleteTaskDTO.getOrderId())); String.valueOf(robotCompleteTaskDTO.getOrderId()));
taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DOING.getType()); taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DOING.getType()
, null);
} }
/** /**
@ -241,7 +243,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
.build(); .build();
chargeLogMapper.updateById(build); chargeLogMapper.updateById(build);
} }
taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DONE.getType()); taskDetailActionLogMapper.updateActionStatus(robotCompleteTaskDTO.getOrderId(), ActionStatusEnum.DONE.getType(), LocalDateTime.now());
} }
@ -326,7 +328,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
* *
* @param robotCompleteTaskDTO * @param robotCompleteTaskDTO
*/ */
private void chargeDoing(RobotCompleteTaskDTO robotCompleteTaskDTO, String robotDoingActionKey,RobotTaskDetailActionLogDO lastLog) { private void chargeDoing(RobotCompleteTaskDTO robotCompleteTaskDTO, String robotDoingActionKey, RobotTaskDetailActionLogDO lastLog) {
RobotTaskDetailActionLogDO logOne = new RobotTaskDetailActionLogDO(); RobotTaskDetailActionLogDO logOne = new RobotTaskDetailActionLogDO();
RobotCommandStateDTO commandStatus = robotCompleteTaskDTO.getCommandStatus(); RobotCommandStateDTO commandStatus = robotCompleteTaskDTO.getCommandStatus();
Integer taskStatus = ChargeTaskStatusEnum.CHARGEING.getType(); Integer taskStatus = ChargeTaskStatusEnum.CHARGEING.getType();
@ -476,6 +478,7 @@ public class RobotTaskStatusApiImpl implements RobotTaskStatusApi {
logOne.setTaskStage(robotTaskDetailDO.getTaskStage()); logOne.setTaskStage(robotTaskDetailDO.getTaskStage());
logOne.setCommandType(PathTaskTypeEnum.getTaskType(robotTaskDetailDO.getTaskType())); logOne.setCommandType(PathTaskTypeEnum.getTaskType(robotTaskDetailDO.getTaskType()));
logOne.setTaskNo(robotTask.getTaskNo()); logOne.setTaskNo(robotTask.getTaskNo());
logOne.setActionStatus(ActionStatusEnum.DOING.getType());
logOne.setStartTime(LocalDateTime.now()); logOne.setStartTime(LocalDateTime.now());
taskDetailActionLogMapper.insert(logOne); taskDetailActionLogMapper.insert(logOne);
redisUtil.set(robotDoingActionKey, logOne.getActionMsg(), doingActionCacheTime); redisUtil.set(robotDoingActionKey, logOne.getActionMsg(), doingActionCacheTime);

View File

@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.system.api.path.PathApi;
import cn.iocoder.yudao.module.system.controller.admin.log.vo.UserOperationLogSaveReqVO; import cn.iocoder.yudao.module.system.controller.admin.log.vo.UserOperationLogSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseDTO; import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseDTO;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapItemRespVO; import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionMapItemRespVO;
@ -48,6 +49,9 @@ public class PositionMapItemController {
@Resource @Resource
private UserOperationLogService userOperationLogService; private UserOperationLogService userOperationLogService;
@Resource
private PathApi pathApi;
// -- 前端给所有的节点信息 - // -- 前端给所有的节点信息 -
@PostMapping("/batchSaveOrEditOrDel") @PostMapping("/batchSaveOrEditOrDel")
@Operation(summary = "批量新增编辑删除节点") @Operation(summary = "批量新增编辑删除节点")
@ -71,6 +75,8 @@ public class PositionMapItemController {
.nickName(SecurityFrameworkUtils.getLoginUserNickname()).build(); .nickName(SecurityFrameworkUtils.getLoginUserNickname()).build();
userOperationLogService.createUserOperationLog(operationLog); userOperationLogService.createUserOperationLog(operationLog);
pathApi.pathInitData();
return success(true); return success(true);
} }

View File

@ -8,6 +8,8 @@ import cn.iocoder.yudao.module.system.dal.dataobject.log.RobotTaskDetailActionLo
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
/** /**
* 车辆动作记录 Mapper * 车辆动作记录 Mapper
* *
@ -36,5 +38,6 @@ public interface RobotTaskDetailActionLogMapper extends BaseMapperX<RobotTaskDet
* @param actionStatus * @param actionStatus
*/ */
void updateActionStatus(@Param("taskDetailId") Long taskDetailId, void updateActionStatus(@Param("taskDetailId") Long taskDetailId,
@Param("actionStatus") int actionStatus); @Param("actionStatus") int actionStatus,
@Param("time") LocalDateTime time);
} }

View File

@ -115,4 +115,11 @@ public interface RobotTaskDetailMapper extends BaseMapperX<RobotTaskDetailDO> {
* @param ids * @param ids
*/ */
void updateDoneByIds(@Param("ids") List<Long> ids); void updateDoneByIds(@Param("ids") List<Long> ids);
/**
* 查询此库位处理中的任务
* @param ids
* @return
*/
List<RobotTaskDetailDO> getDoingTaskDetailByLocationIds(@Param("ids") List<Long> ids);
} }

View File

@ -79,4 +79,11 @@ public interface RobotTaskMapper extends BaseMapperX<RobotTaskDO> {
* @param ids * @param ids
*/ */
void updateDoneByIds(@Param("ids") List<Long> ids); void updateDoneByIds(@Param("ids") List<Long> ids);
/**
* 查询车辆当前在做的任务
* @param robotNo
* @return
*/
List<RobotTaskDO> selectDoingTaskByRobotNo(@Param("robotNo") String robotNo);
} }

View File

@ -9,7 +9,9 @@ public enum ActionStatusEnum {
UN_DO(0,"未开始"), UN_DO(0,"未开始"),
DOING(1,"正在进行"), DOING(1,"正在进行"),
DONE(2,"完成"); DONE(2,"完成"),
CLOSE(3,"已取消"),
EXCEPTION(4,"异常");
/** /**
* 类型 * 类型
*/ */

View File

@ -8,8 +8,11 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.system.controller.admin.houselocation.vo.WareHouseLocationRespVO; import cn.iocoder.yudao.module.system.controller.admin.houselocation.vo.WareHouseLocationRespVO;
import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseDTO; import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO; import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
import cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO;
import cn.iocoder.yudao.module.system.service.houselocation.HouseLocationService; import cn.iocoder.yudao.module.system.service.houselocation.HouseLocationService;
import cn.iocoder.yudao.module.system.service.robot.RobotTaskDetailService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -18,15 +21,21 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.hutool.core.collection.CollUtil.isNotEmpty;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.HOUSE_LOCATION_NO_EXIST; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.TASK_DETAIL_CHANGE_ROBOT; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId; import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId;
@Slf4j @Slf4j
@Component @Component
public class HouseLocationStrategyImpl implements NodeProcessingStrategy { public class HouseLocationStrategyImpl implements NodeProcessingStrategy {
@Resource @Resource
private HouseLocationService houseLocationService; private HouseLocationService houseLocationService;
@Resource
private RobotTaskDetailService taskDetailService;
//库位编号格式 - 第一个通配符为地图id 第二个通配符为随机数四位最后一个通配符为库位点层数 //库位编号格式 - 第一个通配符为地图id 第二个通配符为随机数四位最后一个通配符为库位点层数
private static final String KW_NO_FORMAT = "KW-%s-%s-%s"; private static final String KW_NO_FORMAT = "KW-%s-%s-%s";
@ -83,6 +92,35 @@ public class HouseLocationStrategyImpl implements NodeProcessingStrategy {
List<WareHouseLocationDO> oldList = houseLocationService.getByMapId(positionMapId); List<WareHouseLocationDO> oldList = houseLocationService.getByMapId(positionMapId);
List<List<WareHouseLocationDO>> list = CollectionUtils.compareLists(oldList, newList, List<List<WareHouseLocationDO>> list = CollectionUtils.compareLists(oldList, newList,
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId())); (oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId()));
if (isNotEmpty(list.get(2))) {
checkLocationHaveDoingTask(list);
}
houseLocationService.batchSaveOrEditOrDel(positionMapId, list); houseLocationService.batchSaveOrEditOrDel(positionMapId, list);
} }
/**
* 校验要删除的库位是否有处理中的任务
* @param list
*/
public void checkLocationHaveDoingTask(List<List<WareHouseLocationDO>> list) {
List<Long> ids = convertList(list.get(2), WareHouseLocationDO::getId);
List<RobotTaskDetailDO> details = taskDetailService.getDoingTaskDetailByLocationIds(ids);
if (ObjectUtil.isNotEmpty(details)) {
List<String> locationNos = new ArrayList<>();
for (RobotTaskDetailDO detail : details) {
if (ObjectUtil.isNotEmpty(detail.getFromLocationId()) && ids.contains(detail.getFromLocationId())) {
locationNos.add(detail.getFromLocationNo());
continue;
}
if (ObjectUtil.isNotEmpty(detail.getToLocationId()) && ids.contains(detail.getToLocationId())) {
locationNos.add(detail.getToLocationNo());
}
}
String join = StringUtils.join(locationNos, ",");
throw exception0(HOUSE_LOCATION_HAVE_TASK.getCode(), "以下库位存在处理中的任务:"+join,join);
}
}
} }

View File

@ -59,7 +59,7 @@ public interface RobotTaskDetailActionLogService {
void addLogInCache(List<RobotTaskDetailActionLogDO> logs); void addLogInCache(List<RobotTaskDetailActionLogDO> logs);
/** /**
* 设置上一条数据完成 * 设置上一条数据完成非主任务
* @param robotNo * @param robotNo
* @return * @return
*/ */

View File

@ -103,10 +103,10 @@ public class RobotTaskDetailActionLogServiceImpl implements RobotTaskDetailActio
.eq(RobotTaskDetailActionLogDO::getRobotNo, robotNo) .eq(RobotTaskDetailActionLogDO::getRobotNo, robotNo)
.orderByDesc(RobotTaskDetailActionLogDO::getCreateTime) .orderByDesc(RobotTaskDetailActionLogDO::getCreateTime)
.last("limit 1")); .last("limit 1"));
if (ObjectUtil.isNotEmpty(lastLog)) { if (ObjectUtil.isNotEmpty(lastLog) && ObjectUtil.isEmpty(lastLog.getCommandId())) {
lastLog.setEndTime(LocalDateTime.now()); lastLog.setEndTime(LocalDateTime.now());
lastLog.setActionStatus(ActionStatusEnum.DONE.getType()); lastLog.setActionStatus(ActionStatusEnum.DONE.getType());
taskDetailActionLogMapper.selectById(lastLog); taskDetailActionLogMapper.updateById(lastLog);
} }
return lastLog; return lastLog;
} }

View File

@ -258,14 +258,22 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void deleteInformation(Long id) { public void deleteInformation(Long id) {
// 校验存在
validateInformationExists(id);
RobotInformationDO robotInformationDO = informationMapper.selectById(id); RobotInformationDO robotInformationDO = informationMapper.selectById(id);
List<RobotTaskDO> list = taskMapper.selectDoingTaskByRobotNo(robotInformationDO.getRobotNo());
if (ObjectUtil.isNotEmpty(list)) {
throw exception(ROBOT_HAVE_DOING_TASK);
}
UserOperationLogSaveReqVO operationLog = UserOperationLogSaveReqVO.builder() UserOperationLogSaveReqVO operationLog = UserOperationLogSaveReqVO.builder()
.operateAction("删除车辆 " + robotInformationDO.getRobotNo()) .operateAction("删除车辆 " + robotInformationDO.getRobotNo())
.nickName(SecurityFrameworkUtils.getLoginUserNickname()).build(); .nickName(SecurityFrameworkUtils.getLoginUserNickname()).build();
userOperationLogService.createUserOperationLog(operationLog); userOperationLogService.createUserOperationLog(operationLog);
// 校验存在
validateInformationExists(id);
// 删除 // 删除
informationMapper.deleteById(id); informationMapper.deleteById(id);
} }

View File

@ -73,4 +73,11 @@ public interface RobotTaskDetailService {
* @return * @return
*/ */
void manuallyCompleted(Long id); void manuallyCompleted(Long id);
/**
* 查询此库位处理中的任务
* @param ids 库位id
* @return
*/
List<RobotTaskDetailDO> getDoingTaskDetailByLocationIds(List<Long> ids);
} }

View File

@ -26,6 +26,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import java.util.Collections;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -152,4 +153,9 @@ public class RobotTaskDetailServiceImpl implements RobotTaskDetailService {
String mac = informationService.getMacByRobotNo(robotTaskDetailDO.getRobotNo()); String mac = informationService.getMacByRobotNo(robotTaskDetailDO.getRobotNo());
informationService.robotCloseTaskDetail(String.valueOf(taskDetailId),mac,""); informationService.robotCloseTaskDetail(String.valueOf(taskDetailId),mac,"");
} }
@Override
public List<RobotTaskDetailDO> getDoingTaskDetailByLocationIds(List<Long> ids) {
return taskDetailMapper.getDoingTaskDetailByLocationIds(ids);
}
} }

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.system.service.robot; package cn.iocoder.yudao.module.system.service.robot;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -239,7 +240,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
.collect(Collectors.joining(" ")); .collect(Collectors.joining(" "));
if (ObjectUtil.isNotEmpty(robotNo)) { if (ObjectUtil.isNotEmpty(robotNo)) {
throw exception0(TASK_CHECK_EXCEPTION.getCode(), "以下机器人已被禁用 ", robotNo); throw exception0(TASK_CHECK_EXCEPTION.getCode(), "以下机器人已被禁用 " +robotNo, robotNo);
} }
} }
//校验任务号是否重复 //校验任务号是否重复
@ -487,6 +488,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
Integer robotStatus = RobotStatusEnum.DOING.getType(); Integer robotStatus = RobotStatusEnum.DOING.getType();
RobotChargeLogDO robotChargeLogs = null; RobotChargeLogDO robotChargeLogs = null;
String taskNo ="";
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.selectById(taskAssignDTO.getOrderId());
@ -495,13 +497,19 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
chargeLogMapper.updateById(robotChargeLogs); chargeLogMapper.updateById(robotChargeLogs);
robotStatus = RobotStatusEnum.CHARGE.getType(); robotStatus = RobotStatusEnum.CHARGE.getType();
if (ObjectUtil.isNotEmpty(robotChargeLogs.getTaskDetailId())) { if (ObjectUtil.isNotEmpty(robotChargeLogs.getTaskDetailId())) {
deviceNoMap.put(robotChargeLogs.getTaskDetailId(), robotChargeLogs.getDeviceNo()); deviceNoMap.put(robotChargeLogs.getTaskDetailId(), robotChargeLogs.getDeviceNo());
}else {
String signDate = DateUtil.date().setTimeZone(TimeZone.getTimeZone("UTC")).toString("yyyyMMdd'T'HHmmss'Z'");
taskNo = "AUTO_CHARGE_"+ signDate;
} }
detailId = ObjectUtil.isNotEmpty(robotChargeLogs.getTaskDetailId()) ? robotChargeLogs.getTaskDetailId() : null; detailId = ObjectUtil.isNotEmpty(robotChargeLogs.getTaskDetailId()) ? robotChargeLogs.getTaskDetailId() : null;
} else if (PathTaskTypeEnum.MOVE_TO_WAIT.getType().equals(taskAssignDTO.getOrderType())) { } else if (PathTaskTypeEnum.MOVE_TO_WAIT.getType().equals(taskAssignDTO.getOrderType())) {
moveToWaitService.updateWaitStatusAndItrmId(taskAssignDTO.getOrderId(), WaitStatusEnum.GO_TO_WAIT.getType(), taskAssignDTO.getWaitId()); moveToWaitService.updateWaitStatusAndItrmId(taskAssignDTO.getOrderId(), WaitStatusEnum.GO_TO_WAIT.getType(), taskAssignDTO.getWaitId());
String signDate = DateUtil.date().setTimeZone(TimeZone.getTimeZone("UTC")).toString("yyyyMMdd'T'HHmmss'Z'");
taskNo = "MOVE_TO_WAIT_"+ signDate;
} else { } else {
detailId = taskAssignDTO.getOrderId(); detailId = taskAssignDTO.getOrderId();
} }
@ -511,7 +519,8 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
robotInformationMapper.updateRobotListStatus(taskAssignDTO.getRobotNo(), robotStatus, taskAssignDTO.getOrderId()); robotInformationMapper.updateRobotListStatus(taskAssignDTO.getRobotNo(), robotStatus, taskAssignDTO.getOrderId());
if (ObjectUtil.isNotEmpty(detailId)) { if (ObjectUtil.isNotEmpty(detailId)) {
setTaskDoing(detailId, taskAssignDTO.getRobotNo(), deviceNoMap, taskAssignDTO.getWaitId()); RobotTaskDO robotTaskDO = setTaskDoing(detailId, taskAssignDTO.getRobotNo(), deviceNoMap, taskAssignDTO.getWaitId());
taskNo = robotTaskDO.getTaskNo();
} }
if (ObjectUtil.isNotEmpty(robotChargeLogs)) { if (ObjectUtil.isNotEmpty(robotChargeLogs)) {
@ -522,6 +531,8 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
logOne.setCommandType(taskAssignDTO.getOrderType()); logOne.setCommandType(taskAssignDTO.getOrderType());
logOne.setActionMsg(taskAssignDTO.getRobotActionMsg()); logOne.setActionMsg(taskAssignDTO.getRobotActionMsg());
logOne.setRobotNo(taskAssignDTO.getRobotNo()); logOne.setRobotNo(taskAssignDTO.getRobotNo());
logOne.setStartTime(LocalDateTime.now());
logOne.setTaskNo(taskNo);
logOne.setCommandId(-1L); logOne.setCommandId(-1L);
logOne.setTaskDetailId(taskAssignDTO.getOrderId()); logOne.setTaskDetailId(taskAssignDTO.getOrderId());
taskDetailActionLogMapper.insert(logOne); taskDetailActionLogMapper.insert(logOne);
@ -621,7 +632,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
build.setHeight(height); build.setHeight(height);
} }
public RobotTaskDetailDO setTaskDoing(Long detailId, String robotNo, Map<Long, String> deviceNoMap, public RobotTaskDO setTaskDoing(Long detailId, String robotNo, Map<Long, String> deviceNoMap,
String waitId) { String waitId) {
RobotTaskDetailDO taskDetailDO = taskDetailMapper.selectById(detailId); RobotTaskDetailDO taskDetailDO = taskDetailMapper.selectById(detailId);
taskDetailDO.setTaskStatus(RobotTaskDetailStatusEnum.DOING.getType()); taskDetailDO.setTaskStatus(RobotTaskDetailStatusEnum.DOING.getType());
@ -643,7 +654,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
RobotTaskDO task = taskMapper.selectById(taskDetailDO.getRobotTaskId()); RobotTaskDO task = taskMapper.selectById(taskDetailDO.getRobotTaskId());
task.setTaskStatus(RobotTaskStatusEnum.DOING.getType()); task.setTaskStatus(RobotTaskStatusEnum.DOING.getType());
taskMapper.updateById(task); taskMapper.updateById(task);
return taskDetailDO; return task;
} }
/** /**

View File

@ -13,7 +13,8 @@
update update
robot_task_detail_action_log robot_task_detail_action_log
set set
action_status = #{actionStatus} action_status = #{actionStatus},
end_time = #{time}
where where
task_detail_id = #{taskDetailId} task_detail_id = #{taskDetailId}
and command_id = '-1' and command_id = '-1'

View File

@ -246,7 +246,30 @@
t1.task_type = '5' t1.task_type = '5'
and t1.task_status = '2' and t1.task_status = '2'
</select> </select>
<select id="getDoingTaskDetailByLocationIds"
resultType="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO">
select
t2.*
from
robot_task t1 left join robot_task_detail t2
on t1.id = t2.robot_task_id
where
t1.deleted = '0'
and t2.deleted = '0'
and t2.task_status in('0','1')
and t1.task_status in('0','1')
and (t2.to_location_id in
<foreach collection="ids" item="locationId" index="index" open="(" close=")"
separator=",">
#{locationId}
</foreach> or
t2.from_location_id in
<foreach collection="ids" item="locationId" index="index" open="(" close=")"
separator=",">
#{locationId}
</foreach>
)
</select>
<!--通过主键修改数据--> <!--通过主键修改数据-->

View File

@ -328,6 +328,22 @@
order by t1.create_time desc order by t1.create_time desc
</select> </select>
<select id="selectDoingTaskByRobotNo"
resultType="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDO">
select
DISTINCT
t1.*
from
robot_task t1 left join robot_task_detail t2
on t1.id = t2.robot_task_id
where
t1.deleted = '0'
and t2.deleted = '0'
and t2.robot_no = #{robotNo}
and t1.task_status in ('0','1')
and t2.task_status in ('0','1')
</select>
<!--新增所有列--> <!--新增所有列-->
<insert id="insertEntity" keyProperty="id" useGeneratedKeys="true"> <insert id="insertEntity" keyProperty="id" useGeneratedKeys="true">