转换点绑定校验
This commit is contained in:
parent
5d830c5165
commit
681d8d7dc2
@ -307,5 +307,6 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 区域变更点绑定 1_002_057_001 ==========
|
||||
ErrorCode POSITION_CHANGE_POINT_BINDING_NOT_EXISTS = new ErrorCode(1_002_057_001, "区域变更点绑定不存在");
|
||||
ErrorCode POSITION_CHANGE_POINT_SAME_MAP = new ErrorCode(1_002_057_001, "区域变更点绑定,不能是同一张地图");
|
||||
ErrorCode POSITION_CHANGE_POINT_SAME_MAP = new ErrorCode(1_002_057_002, "区域变更点绑定,不能是同一张地图");
|
||||
ErrorCode POSITION_CHANGE_POINT_ALREADY_BINDING = new ErrorCode(1_002_057_003, "请勿重复绑定区域变更点");
|
||||
}
|
||||
|
@ -31,4 +31,6 @@ public class PositionChangePointBindingPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "startingPointId的地图id")
|
||||
private Long positionMapId;
|
||||
}
|
@ -36,4 +36,8 @@ public class PositionChangePointBindingRespVO {
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "startingPointId的地图id")
|
||||
@ExcelProperty("startingPointId的地图id")
|
||||
private Long positionMapId;
|
||||
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.positionmap.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
@ -24,4 +26,7 @@ public class PositionChangePointBindingSaveReqVO {
|
||||
@Schema(description = "点位2自增排序")
|
||||
private Long endPointSortNum;
|
||||
|
||||
@Schema(description = "startingPointId的地图id")
|
||||
private Long positionMapId;
|
||||
|
||||
}
|
@ -25,7 +25,7 @@ public class PositionChangePointBindingDO extends BaseDO {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 点位1的id
|
||||
@ -43,5 +43,10 @@ public class PositionChangePointBindingDO extends BaseDO {
|
||||
* 点位2自增排序
|
||||
*/
|
||||
private Long endPointSortNum;
|
||||
/**
|
||||
* 地图id
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private Long positionMapId;
|
||||
|
||||
}
|
@ -25,7 +25,7 @@ public class PositionMapDO extends BaseDO {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 楼层
|
||||
|
@ -27,6 +27,8 @@ public class NodeProcessingContext {
|
||||
@Autowired
|
||||
private MapNodeStrategyImpl mapNodeStrategyImpl;
|
||||
@Autowired
|
||||
private ChangeNodeStrategyImpl changeNodeStrategyImpl;
|
||||
@Autowired
|
||||
private HouseLocationStrategyImpl houseLocationStrategyImpl;
|
||||
@Autowired
|
||||
private ParkingSpotStrategyImpl parkingSpotStrategyImpl;
|
||||
@ -47,7 +49,7 @@ public class NodeProcessingContext {
|
||||
// 停车点
|
||||
strategyMap.put(NodeTypeEnum.PARKING.getType(), parkingSpotStrategyImpl);
|
||||
// 路径点
|
||||
strategyMap.put(NodeTypeEnum.CHANGE.getType(), mapNodeStrategyImpl);
|
||||
strategyMap.put(NodeTypeEnum.CHANGE.getType(), changeNodeStrategyImpl);
|
||||
// 等待点
|
||||
strategyMap.put(NodeTypeEnum.WAIT.getType(), mapNodeStrategyImpl);
|
||||
// 文字点
|
||||
|
@ -0,0 +1,81 @@
|
||||
package cn.iocoder.yudao.module.system.handler.mapnode.strategy;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.NodeBaseDTO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionChangePointBindingDO;
|
||||
import cn.iocoder.yudao.module.system.service.positionmap.PositionChangePointBindingService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.HOUSE_LOCATION_HAVE_TASK;
|
||||
|
||||
@Component
|
||||
public class ChangeNodeStrategyImpl implements NodeProcessingStrategy {
|
||||
|
||||
@Resource
|
||||
private PositionChangePointBindingService positionChangePointBindingService;
|
||||
|
||||
@Override
|
||||
public void processNodes(Long positionMapId, List<NodeBaseDTO> nodeBaseDTOS) {
|
||||
|
||||
List<PositionChangePointBindingDO> newList = new ArrayList<>();
|
||||
// -- 拿到这个地图所绑定的设备 -
|
||||
List<PositionChangePointBindingDO> oldList = positionChangePointBindingService.getPositionChangePointBindingByMapId(positionMapId);
|
||||
|
||||
List<Long> startPointIds = new ArrayList<>();
|
||||
List<Long> endPointIds = new ArrayList<>();
|
||||
List<Long> sortNums = new ArrayList<>();
|
||||
|
||||
for (NodeBaseDTO item : nodeBaseDTOS) {
|
||||
if (ObjectUtil.isEmpty(item.getDataJson())) {
|
||||
continue;
|
||||
}
|
||||
PositionChangePointBindingDO positionChangePointBindingDO = new PositionChangePointBindingDO();
|
||||
NodeBaseDTO nodeBase = JSONUtil.toBean(item.getDataJson(), NodeBaseDTO.class);
|
||||
|
||||
if (sortNums.contains(nodeBase.getSortNum())) {
|
||||
throw exception0(HOUSE_LOCATION_HAVE_TASK.getCode(), "以下点位已经被选中: " + nodeBase.getSortNum(), nodeBase.getSortNum());
|
||||
}
|
||||
|
||||
positionChangePointBindingDO.setPositionMapId(positionMapId);
|
||||
positionChangePointBindingDO.setStartingPointId(item.getId());
|
||||
positionChangePointBindingDO.setStartingPointSortNum(item.getSortNum());
|
||||
positionChangePointBindingDO.setEndPointId(nodeBase.getId());
|
||||
positionChangePointBindingDO.setEndPointSortNum(nodeBase.getSortNum());
|
||||
newList.add(positionChangePointBindingDO);
|
||||
startPointIds.add(item.getId());
|
||||
endPointIds.add(nodeBase.getId());
|
||||
sortNums.add(item.getSortNum());
|
||||
sortNums.add(nodeBase.getSortNum());
|
||||
}
|
||||
|
||||
//判断这些点是否被绑定过
|
||||
if (ObjectUtil.isNotEmpty(endPointIds)) {
|
||||
List<PositionChangePointBindingDO> existList = positionChangePointBindingService.getByMapIdAndEndPointIds(positionMapId, endPointIds);
|
||||
if (ObjectUtil.isNotEmpty(existList)) {
|
||||
List<Long> sortNumList = existList.stream().map(PositionChangePointBindingDO::getEndPointSortNum).collect(Collectors.toList());
|
||||
String join = StringUtils.join(sortNumList, ",");
|
||||
throw exception0(HOUSE_LOCATION_HAVE_TASK.getCode(), "以下区域变更点已经被其他地图绑定:"+join,join);
|
||||
}
|
||||
|
||||
List<PositionChangePointBindingDO> existBindingList = positionChangePointBindingService.getByMapIdAndStartPointIds(positionMapId, endPointIds,startPointIds);
|
||||
if (ObjectUtil.isNotEmpty(existBindingList)) {
|
||||
List<Long> sortNumList = existBindingList.stream().map(PositionChangePointBindingDO::getStartingPointSortNum).collect(Collectors.toList());
|
||||
String join = StringUtils.join(sortNumList, ",");
|
||||
throw exception0(HOUSE_LOCATION_HAVE_TASK.getCode(), "以下区域变更点绑定的点位错乱(出现A绑定B,B绑定C的情况):"+join,join);
|
||||
}
|
||||
}
|
||||
|
||||
List<List<PositionChangePointBindingDO>> list = CollectionUtils.compareLists(oldList, newList,
|
||||
(oldVal, newVal) -> ObjectUtil.equal(oldVal.getEndPointId(), newVal.getEndPointId()));
|
||||
positionChangePointBindingService.batchEditOrDel(list);
|
||||
}
|
||||
}
|
@ -61,4 +61,33 @@ public interface PositionChangePointBindingService extends IService<PositionChan
|
||||
* @return
|
||||
*/
|
||||
List<PositionAllChangePointBindingDTO> getAllPositionChangePointBinding();
|
||||
|
||||
/**
|
||||
* 根据地图id查询
|
||||
* @param positionMapId
|
||||
* @return
|
||||
*/
|
||||
List<PositionChangePointBindingDO> getPositionChangePointBindingByMapId(Long positionMapId);
|
||||
|
||||
/**
|
||||
* 批量新增删除修改
|
||||
* @param list
|
||||
*/
|
||||
void batchEditOrDel(List<List<PositionChangePointBindingDO>> list);
|
||||
|
||||
/**
|
||||
* 不在此地图id的被绑定变更点
|
||||
* @param positionMapId
|
||||
* @param endPointIds
|
||||
* @return
|
||||
*/
|
||||
List<PositionChangePointBindingDO> getByMapIdAndEndPointIds(Long positionMapId, List<Long> endPointIds);
|
||||
|
||||
/**
|
||||
* 不在此地图id的绑定变更点
|
||||
* @param positionMapId
|
||||
* @param startPointIds
|
||||
* @return
|
||||
*/
|
||||
List<PositionChangePointBindingDO> getByMapIdAndStartPointIds(Long positionMapId, List<Long> endPointIds, List<Long> startPointIds);
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.mqtt.api.path.dto.PositionAllChangePointBindingDT
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.dto.PositionChangePointBindingDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionChangePointBindingPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.positionmap.vo.PositionChangePointBindingSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.houselocation.WareHouseLocationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionChangePointBindingDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO;
|
||||
@ -25,7 +27,9 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
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.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@ -44,6 +48,7 @@ public class PositionChangePointBindingServiceImpl extends ServiceImpl<PositionC
|
||||
private PositionMapItemService positionMapItemService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createPositionChangePointBinding(PositionChangePointBindingSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
PositionChangePointBindingDO positionChangePointBinding = BeanUtils.toBean(createReqVO, PositionChangePointBindingDO.class);
|
||||
@ -55,11 +60,24 @@ public class PositionChangePointBindingServiceImpl extends ServiceImpl<PositionC
|
||||
throw exception(POSITION_CHANGE_POINT_SAME_MAP);
|
||||
}
|
||||
|
||||
PositionChangePointBindingDO startPosition = positionChangePointBindingMapper.selectOne(new LambdaQueryWrapperX<PositionChangePointBindingDO>()
|
||||
.eq(PositionChangePointBindingDO::getStartingPointId, createReqVO.getStartingPointId()).last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(startPosition)) {
|
||||
throw exception(POSITION_CHANGE_POINT_ALREADY_BINDING);
|
||||
}
|
||||
|
||||
PositionChangePointBindingDO endPosition = positionChangePointBindingMapper.selectOne(new LambdaQueryWrapperX<PositionChangePointBindingDO>()
|
||||
.eq(PositionChangePointBindingDO::getStartingPointId, createReqVO.getEndPointId()).last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(endPosition)) {
|
||||
throw exception(POSITION_CHANGE_POINT_ALREADY_BINDING);
|
||||
}
|
||||
|
||||
// 返回
|
||||
return positionChangePointBinding.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePositionChangePointBinding(PositionChangePointBindingSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validatePositionChangePointBindingExists(updateReqVO.getId());
|
||||
@ -86,7 +104,7 @@ public class PositionChangePointBindingServiceImpl extends ServiceImpl<PositionC
|
||||
public PositionChangePointBindingDTO getPositionChangePointBinding(Long mapItemId) {
|
||||
PositionChangePointBindingDTO positionChangePointBinding = new PositionChangePointBindingDTO();
|
||||
PositionChangePointBindingDO position = positionChangePointBindingMapper.selectOne(new LambdaQueryWrapperX<PositionChangePointBindingDO>()
|
||||
.eq(PositionChangePointBindingDO::getStartingPointId, mapItemId));
|
||||
.eq(PositionChangePointBindingDO::getStartingPointId, mapItemId).last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(position)) {
|
||||
positionChangePointBinding.setId(position.getId());
|
||||
positionChangePointBinding.setSortNum(position.getEndPointSortNum());
|
||||
@ -95,7 +113,7 @@ public class PositionChangePointBindingServiceImpl extends ServiceImpl<PositionC
|
||||
}
|
||||
|
||||
PositionChangePointBindingDO startPosition = positionChangePointBindingMapper.selectOne(new LambdaQueryWrapperX<PositionChangePointBindingDO>()
|
||||
.eq(PositionChangePointBindingDO::getEndPointId, mapItemId));
|
||||
.eq(PositionChangePointBindingDO::getEndPointId, mapItemId).last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(startPosition)) {
|
||||
positionChangePointBinding.setId(startPosition.getId());
|
||||
positionChangePointBinding.setSortNum(startPosition.getStartingPointSortNum());
|
||||
@ -115,5 +133,41 @@ public class PositionChangePointBindingServiceImpl extends ServiceImpl<PositionC
|
||||
return positionChangePointBindingMapper.getAllPositionChangePointBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionChangePointBindingDO> getPositionChangePointBindingByMapId(Long positionMapId) {
|
||||
return positionChangePointBindingMapper.selectList(new LambdaQueryWrapperX<PositionChangePointBindingDO>()
|
||||
.eq(PositionChangePointBindingDO::getPositionMapId, positionMapId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchEditOrDel(List<List<PositionChangePointBindingDO>> list) {
|
||||
//批量添加、修改、删除
|
||||
//批量添加、修改、删除
|
||||
if (isNotEmpty(list.get(0))) {
|
||||
positionChangePointBindingMapper.insertBatch(list.get(0));
|
||||
}
|
||||
if (isNotEmpty(list.get(1))) {
|
||||
positionChangePointBindingMapper.updateBatch(list.get(1));
|
||||
}
|
||||
if (isNotEmpty(list.get(2))) {
|
||||
positionChangePointBindingMapper.deleteByIds(convertList(list.get(2), PositionChangePointBindingDO::getId));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionChangePointBindingDO> getByMapIdAndEndPointIds(Long positionMapId, List<Long> endPointIds) {
|
||||
return positionChangePointBindingMapper.selectList(new LambdaQueryWrapperX<PositionChangePointBindingDO>()
|
||||
.ne(PositionChangePointBindingDO::getPositionMapId, positionMapId)
|
||||
.in(PositionChangePointBindingDO::getEndPointId,endPointIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionChangePointBindingDO> getByMapIdAndStartPointIds(Long positionMapId, List<Long> endPointIds, List<Long> startPointIds) {
|
||||
return positionChangePointBindingMapper.selectList(new LambdaQueryWrapperX<PositionChangePointBindingDO>()
|
||||
.ne(PositionChangePointBindingDO::getPositionMapId, positionMapId)
|
||||
.in(PositionChangePointBindingDO::getStartingPointId,endPointIds)
|
||||
.notIn(PositionChangePointBindingDO::getEndPointId,startPointIds));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -701,7 +701,8 @@ public class RobotPathPlanningServiceImpl implements RobotPathPlanningService {
|
||||
} else if (RobotTaskTypeEnum.TAKE.getType().equals(v.getTaskType())) {
|
||||
//仅取货
|
||||
takeSetTask(list, v, fromLane, toLane, fromLocation, toLocation, toHaveFrom, fromHaveTo);
|
||||
} else if (RobotTaskTypeEnum.PARK.getType().equals(v.getTaskType())) {
|
||||
} else if (RobotTaskTypeEnum.PARK.getType().equals(v.getTaskType())
|
||||
|| RobotTaskTypeEnum.MOVE_TO_POINT.getType().equals(v.getTaskType())) {
|
||||
list.add(v);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user