修改定版bug
This commit is contained in:
@@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.mapper.govern.voltage.SgMachineMapper;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgUserParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgUser;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO;
|
||||
import com.njcn.advance.service.govern.voltage.ISgMachineService;
|
||||
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
|
||||
@@ -56,12 +58,34 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
|
||||
@Override
|
||||
public String addMachine(SgMachineParam sgMachineParam) {
|
||||
SgMachine sgMachine = new SgMachine();
|
||||
checkMachineName(sgMachineParam, false);
|
||||
|
||||
BeanUtil.copyProperties(sgMachineParam, sgMachine);
|
||||
//默认为正常状态
|
||||
sgMachine.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(sgMachine);
|
||||
return sgMachine.getId();
|
||||
}
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的业务用户
|
||||
*/
|
||||
private void checkMachineName(SgMachineParam sgMachineParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<SgMachine> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgUserLambdaQueryWrapper
|
||||
.eq(SgMachine::getName, sgMachineParam.getName())
|
||||
.eq(SgMachine::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (sgMachineParam instanceof SgMachineParam.SgMachineUpdateParam) {
|
||||
sgUserLambdaQueryWrapper.ne(SgMachine::getId, ((SgMachineParam.SgMachineUpdateParam) sgMachineParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(sgUserLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新设备
|
||||
@@ -70,6 +94,8 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
|
||||
@Override
|
||||
public boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam) {
|
||||
SgMachine sgMachine = new SgMachine();
|
||||
checkMachineName(updateParam, true);
|
||||
|
||||
BeanUtil.copyProperties(updateParam, sgMachine);
|
||||
return this.updateById(sgMachine);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@ package com.njcn.advance.service.govern.voltage.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.mapper.govern.voltage.SgSensitiveUnitMapper;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO;
|
||||
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
|
||||
@@ -54,12 +57,34 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
|
||||
@Override
|
||||
public String addSensitiveUnit(SgSensitiveUnitParam sgSensitiveUnitParam) {
|
||||
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
||||
checkSensitiveUnitName(sgSensitiveUnitParam, false);
|
||||
|
||||
BeanUtil.copyProperties(sgSensitiveUnitParam, sgSensitiveUnit);
|
||||
//默认为正常状态
|
||||
sgSensitiveUnit.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(sgSensitiveUnit);
|
||||
return sgSensitiveUnit.getId();
|
||||
}
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的业务用户
|
||||
*/
|
||||
private void checkSensitiveUnitName(SgSensitiveUnitParam sgSensitiveUnitParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<SgSensitiveUnit> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgUserLambdaQueryWrapper
|
||||
.eq(SgSensitiveUnit::getName, sgSensitiveUnitParam.getName())
|
||||
.eq(SgSensitiveUnit::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (sgSensitiveUnitParam instanceof SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) {
|
||||
sgUserLambdaQueryWrapper.ne(SgSensitiveUnit::getId, ((SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) sgSensitiveUnitParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(sgUserLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新元器件
|
||||
@@ -69,6 +94,8 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
|
||||
@Override
|
||||
public boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam) {
|
||||
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
||||
checkSensitiveUnitName(updateParam, true);
|
||||
|
||||
BeanUtil.copyProperties(updateParam, sgSensitiveUnit);
|
||||
return this.updateById(sgSensitiveUnit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user