车辆编号重复性校验
This commit is contained in:
parent
a049eae075
commit
1ab7083c9e
@ -88,4 +88,8 @@ public interface RobotInformationMapper extends BaseMapperX<RobotInformationDO>
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<RobotInformationDO> getListByMapId(@Param("mapId") Long mapId);
|
List<RobotInformationDO> getListByMapId(@Param("mapId") Long mapId);
|
||||||
|
|
||||||
|
RobotInformationDO selectByRobotNoAndIdNotIn(@Param("robotNo") String robotNo, @Param("id") Long id);
|
||||||
|
|
||||||
|
RobotInformationDO selectByMacAndIdNotIn(@Param("macAddress") String macAddress,@Param("id") Long id);
|
||||||
}
|
}
|
||||||
|
@ -184,20 +184,17 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createInformation(RobotInformationSaveReqVO createReqVO) {
|
public Long createInformation(RobotInformationSaveReqVO createReqVO) {
|
||||||
//判断mac地址是否重复
|
|
||||||
RobotInformationDO existRobotMac = informationMapper.selectOne(new LambdaQueryWrapper<RobotInformationDO>()
|
|
||||||
.eq(RobotInformationDO::getMacAddress, createReqVO.getMacAddress())
|
|
||||||
.last("limit 1"));
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(existRobotMac)) {
|
RobotInformationDO existRobotInformationDO =
|
||||||
|
informationMapper.selectByMacAndIdNotIn(createReqVO.getMacAddress(),null);
|
||||||
|
if (ObjectUtil.isNotEmpty(existRobotInformationDO)) {
|
||||||
throw exception(ROBOT_MAC_ADDRESS_EXISTS);
|
throw exception(ROBOT_MAC_ADDRESS_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断机器人编号
|
HashSet<String> set = new HashSet<>();
|
||||||
RobotInformationDO existRobotNo = informationMapper.selectOne(new LambdaQueryWrapper<RobotInformationDO>()
|
set.add(createReqVO.getRobotNo());
|
||||||
.eq(RobotInformationDO::getRobotNo, createReqVO.getRobotNo())
|
List<RobotInformationDO> robots = informationMapper.selectByRobotNos(set);
|
||||||
.last("limit 1"));
|
if (ObjectUtil.isNotEmpty(robots)) {
|
||||||
if (ObjectUtil.isNotEmpty(existRobotNo)) {
|
|
||||||
throw exception(ROBOT_ROBOT_NO_EXISTS);
|
throw exception(ROBOT_ROBOT_NO_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,24 +390,22 @@ public class RobotInformationServiceImpl extends ServiceImpl<RobotInformationMap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//校验MAC地址
|
if (!updateReqVO.getRobotNo().equals(robotInformationDO.getRobotNo())) {
|
||||||
RobotInformationDO query = new RobotInformationDO();
|
RobotInformationDO existRobotInformationDO =
|
||||||
query.setMacAddress(updateReqVO.getMacAddress());
|
informationMapper.selectByRobotNoAndIdNotIn(updateReqVO.getRobotNo(),updateReqVO.getId());
|
||||||
List<RobotInformationDO> existRobot = informationMapper.queryAllByLimit(query);
|
if (ObjectUtil.isNotEmpty(existRobotInformationDO)) {
|
||||||
boolean exist = existRobot.stream().anyMatch(v -> (v.getMacAddress().equals(updateReqVO.getMacAddress())
|
throw exception(ROBOT_ROBOT_NO_EXISTS);
|
||||||
&& !v.getId().equals(updateReqVO.getId())));
|
}
|
||||||
if (exist) {
|
|
||||||
throw exception(ROBOT_MAC_ADDRESS_EXISTS);
|
|
||||||
}
|
}
|
||||||
//校验机器人编号
|
|
||||||
query.setMacAddress(null);
|
if (!updateReqVO.getMacAddress().equals(robotInformationDO.getMacAddress())) {
|
||||||
query.setRobotNo(updateReqVO.getRobotNo());
|
RobotInformationDO existRobotInformationDO =
|
||||||
List<RobotInformationDO> existRobotNo = informationMapper.queryAllByLimit(query);
|
informationMapper.selectByMacAndIdNotIn(updateReqVO.getMacAddress(),updateReqVO.getId());
|
||||||
boolean robotNoExist = existRobotNo.stream().anyMatch(v -> (v.getRobotNo().equals(updateReqVO.getRobotNo())
|
if (ObjectUtil.isNotEmpty(existRobotInformationDO)) {
|
||||||
&& !v.getId().equals(updateReqVO.getId())));
|
throw exception(ROBOT_MAC_ADDRESS_EXISTS);
|
||||||
if (robotNoExist) {
|
}
|
||||||
throw exception(ROBOT_ROBOT_NO_EXISTS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//校验IP
|
//校验IP
|
||||||
RobotInformationDO existRobotIp = informationMapper.selectOne(new LambdaQueryWrapper<RobotInformationDO>()
|
RobotInformationDO existRobotIp = informationMapper.selectOne(new LambdaQueryWrapper<RobotInformationDO>()
|
||||||
.eq(RobotInformationDO::getRobotIp, updateReqVO.getRobotIp())
|
.eq(RobotInformationDO::getRobotIp, updateReqVO.getRobotIp())
|
||||||
|
@ -160,8 +160,7 @@
|
|||||||
from
|
from
|
||||||
robot_information
|
robot_information
|
||||||
where
|
where
|
||||||
deleted = '0'
|
robot_no in
|
||||||
and robot_no in
|
|
||||||
<foreach collection="robotNos" item="robotNo" index="index" open="(" close=")"
|
<foreach collection="robotNos" item="robotNo" index="index" open="(" close=")"
|
||||||
separator=",">
|
separator=",">
|
||||||
#{robotNo}
|
#{robotNo}
|
||||||
@ -199,4 +198,28 @@
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectByRobotNoAndIdNotIn"
|
||||||
|
resultType="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO">
|
||||||
|
select
|
||||||
|
<include refid="base_sql"></include>
|
||||||
|
from
|
||||||
|
robot_information
|
||||||
|
where
|
||||||
|
robot_no = #{robotNo}
|
||||||
|
and id != #{id}
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
<select id="selectByMacAndIdNotIn"
|
||||||
|
resultType="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotInformationDO">
|
||||||
|
select
|
||||||
|
<include refid="base_sql"></include>
|
||||||
|
from
|
||||||
|
robot_information
|
||||||
|
where
|
||||||
|
mac_address = #{macAddress}
|
||||||
|
<if test="id != null">
|
||||||
|
and id != #{id}
|
||||||
|
</if>
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user