pms台账新增校验

This commit is contained in:
2023-01-09 11:46:47 +08:00
parent 44390529b4
commit 865cdc97d6
3 changed files with 34 additions and 0 deletions

View File

@@ -3,6 +3,8 @@ package com.njcn.device.pms.service.majornetwork.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.enums.PmsDeviceResponseEnum;
import com.njcn.device.pms.mapper.majornetwork.StatationStatMapper;
import com.njcn.device.pms.pojo.dto.PmsStatationStatInfoDTO;
import com.njcn.device.pms.pojo.param.StatationStatParam;
@@ -18,6 +20,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
* <p>
@@ -46,6 +49,21 @@ public class StatationStatServiceImpl extends ServiceImpl<StatationStatMapper, S
@Override
public boolean addStatationStat(StatationStatParam statationStatParam) {
StatationStat statationStatValid = this.getById(statationStatParam.getPowerId());
if(Objects.nonNull(statationStatValid)){
throw new BusinessException(PmsDeviceResponseEnum.STATION_REPEAT);
}
//校验同一单位下不能出现同名电站
LambdaQueryWrapper<StatationStat> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(StatationStat::getOrgId,statationStatParam.getOrgId())
.eq(StatationStat::getPowerName,statationStatParam.getPowerName());
int count = this.count(lambdaQueryWrapper);
if(count>0){
throw new BusinessException(PmsDeviceResponseEnum.DEPT_STATION_REPEAT);
}
StatationStat statationStat = new StatationStat();
BeanUtils.copyProperties(statationStatParam, statationStat);
statationStat.setStatus(DataStateEnum.ENABLE.getCode());
@@ -54,6 +72,17 @@ public class StatationStatServiceImpl extends ServiceImpl<StatationStatMapper, S
@Override
public boolean updateStatationStat(StatationStatParam statationStatParam) {
//校验同一单位下不能出现同名电站
LambdaQueryWrapper<StatationStat> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(StatationStat::getOrgId,statationStatParam.getOrgId())
.eq(StatationStat::getPowerName,statationStatParam.getPowerName())
.ne(StatationStat::getPowerId,statationStatParam.getPowerId());
int count = this.count(lambdaQueryWrapper);
if(count>0){
throw new BusinessException(PmsDeviceResponseEnum.DEPT_STATION_REPEAT);
}
StatationStat statationStat = new StatationStat();
BeanUtils.copyProperties(statationStatParam, statationStat);
return this.updateById(statationStat);