Commit 60bf2cc7 authored by ZWT's avatar ZWT

feat(能源管理系统): 基础信息配置

1.修改基础信息配置-井口配置模块删除接口,增加私有方法校验井口是否已被线路引用;
2.修改基础信息配置-光伏电站配置模块删除接口,增加私有方法校验光伏电站是否已被线路引用;
3.修改基础信息配置-储能设备配置模块删除接口,增加私有方法校验储能设备是否已被线路引用;
4.修改基础信息配置-柴发设备配置模块删除接口,增加私有方法校验柴发设备是否已被线路引用;
5.修改基础信息配置-市电峰谷模块新增/修改接口,优化市电峰谷关联信息批量新增逻辑;
6.修改基础信息配置-输电线路配置模块新增/修改接口,优化输电线路关联信息批量新增逻辑;
7.修改基础信息配置-间开制度管理模块新增/修改接口,优化间开制度关联信息批量新增逻辑;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent ceb2a46c
......@@ -3,6 +3,8 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.commons.lang3.StringUtils;
import pps.core.base.entity.BasePowerLineWellheadEnt;
import pps.core.base.entity.BaseWellheadEnt;
import pps.core.base.mapper.BasePowerLineWellheadMapper;
......@@ -24,6 +26,7 @@ import xstartup.feature.api.annotation.XApiAnonymous;
import xstartup.feature.api.annotation.XApiGet;
import xstartup.feature.api.annotation.XApiPost;
import xstartup.feature.mybatis.helper.XMapperHelper;
import xstartup.helper.XTransactionHelper;
import java.util.List;
import java.util.Objects;
......@@ -42,24 +45,26 @@ public class BaseWellheadService extends BaseService {
@XApiAnonymous
@XApiPost
public XServiceResult createBaseWellhead(XContext context, CreateBaseWellheadInput input) {
return XTransactionHelper.begin(context, () -> {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
BaseWellheadEnt entity = new BaseWellheadEnt();
XCopyUtils.copyObject(input, entity);
BaseWellheadEnt entity = XCopyUtils.copyNewObject(input, BaseWellheadEnt.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.insert(entity);
return XServiceResult.OK;
});
}
@XText("更新")
@XApiAnonymous
@XApiPost
public XServiceResult updateBaseWellhead(XContext context, UpdateBaseWellheadInput input) {
return XTransactionHelper.begin(context, () -> {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
QueryWrapper<BaseWellheadEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseWellheadEnt::getId, input.getId());
BaseWellheadEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
BaseWellheadEnt entity = mapper.selectOne(new LambdaUpdateWrapper<BaseWellheadEnt>()
.eq(BaseModel::getId, input.getId())
);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -67,6 +72,7 @@ public class BaseWellheadService extends BaseService {
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@XText("删除")
......@@ -77,10 +83,11 @@ public class BaseWellheadService extends BaseService {
if (this.checkWellheadIsReference(context, wellheadId)) {
return XServiceResult.error(992, "当前井口已被引用");
}
return XTransactionHelper.begin(context, () -> {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
QueryWrapper<BaseWellheadEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseWellheadEnt::getId, wellheadId);
BaseWellheadEnt entity = mapper.selectOne(queryWrapper);
BaseWellheadEnt entity = mapper.selectOne(new LambdaUpdateWrapper<BaseWellheadEnt>()
.eq(BaseModel::getId, wellheadId)
);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
......@@ -91,6 +98,7 @@ public class BaseWellheadService extends BaseService {
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@XText("根据ID获取详情")
......@@ -120,7 +128,7 @@ public class BaseWellheadService extends BaseService {
QueryWrapper<BaseWellheadEnt> queryWrapper = new QueryWrapper<>();
List<String> allListByOuId = this.getAllListByOuId(context, input.getOuId());
queryWrapper.lambda()
.notExists("1".equals(excludeIdFlag), "SELECT 1 FROM base_power_line_wellhead w WHERE w.ou_id = {0} AND base_wellhead.id = w.wellhead_id AND w.is_deleted = 1", input.getOuId())
.notExists(StringUtils.equals("1", excludeIdFlag), "SELECT 1 FROM base_power_line_wellhead w WHERE w.ou_id = {0} AND base_wellhead.id = w.wellhead_id AND w.is_deleted = 1", input.getOuId())
.eq(BaseWellheadEnt::getIsDeleted, BusinessConstant.ONE)
.in(CollUtil.isNotEmpty(allListByOuId), BaseWellheadEnt::getOuId, allListByOuId)
.orderByDesc(BaseWellheadEnt::getModifyTime);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment