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

@@ -33,6 +33,8 @@ public enum PmsDeviceResponseEnum {
POWER_CODE_SAME("A00374","台区名称或编号重复"),
POWER_CLIENT_DIS_EMPTY("A00375","发电用电用户参数不可为空"),
DIS_ADD_REPEAT("A00376","当前配网中存在该监测点"),
STATION_REPEAT("A00377","已存在相同电站"),
DEPT_STATION_REPEAT("A00378","单位下存在同名电站"),
POWER_CLIENT_NOT_FIND("A00380","查无此用电用户"),

View File

@@ -38,4 +38,7 @@ public class DistributionMonitorParam {
@ApiModelProperty(value = "III类监测点小类 0.用电用户 1.发电用户 默认用电")
private Integer smallType;
}

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);