Commit d5626efb authored by ZWT's avatar ZWT

feat(能源管理系统): 组织机构管理

1.修改组织机构管理分页列表功能,优化sql查询逻辑及代码业务处理逻辑,解决组织部分信息获取错误问题,完成接口冒烟测试并添加线上接口文档;
2.开发组织机构管理模块动态列表查询功能,添加线上接口文档并完成接口冒烟测试;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 41de77ea
package pps.core.base.service;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
......@@ -154,14 +155,13 @@ public class BasePowerLineService {
if (Objects.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBasePowerLineViewOutput output = new GetBasePowerLineViewOutput();
XCopyUtils.copyObject(entity, output);
GetBasePowerLineViewOutput output = XCopyUtils.copyNewObject(entity, GetBasePowerLineViewOutput.class);
//设置关联井口
BasePowerLineWellheadViewMapper wellheadViewMapper = context.getBean(BasePowerLineWellheadViewMapper.class);
List<BasePowerLineWellheadView> wellheadViewList = wellheadViewMapper.selectList(BasePowerLineWellheadView.builder()
.lineId(lineId)
.build());
if (!wellheadViewList.isEmpty()) {
if (CollectionUtil.isNotEmpty(wellheadViewList)) {
output.setWellheadOutputs(XCopyUtils.copyNewList(wellheadViewList, GetBasePowerLineWellheadViewOutput.class));
}
//设置关联光伏
......@@ -169,7 +169,7 @@ public class BasePowerLineService {
List<BasePowerLinePlantView> plantViewList = plantViewMapper.selectList(BasePowerLinePlantView.builder()
.lineId(lineId)
.build());
if (!plantViewList.isEmpty()) {
if (CollectionUtil.isNotEmpty(plantViewList)) {
output.setPlantOutputs(XCopyUtils.copyNewList(plantViewList, GetBasePowerLinePlantViewOutput.class));
}
//设置关联储能
......@@ -177,7 +177,7 @@ public class BasePowerLineService {
List<BasePowerLineStorageView> storageViewList = storageViewMapper.selectList(BasePowerLineStorageView.builder()
.lineId(lineId)
.build());
if (!storageViewList.isEmpty()) {
if (CollectionUtil.isNotEmpty(storageViewList)) {
output.setStorageOutputs(XCopyUtils.copyNewList(storageViewList, GetBasePowerLineStorageViewOutput.class));
}
//设置关联柴发
......@@ -185,7 +185,7 @@ public class BasePowerLineService {
List<BasePowerLineDieselView> dieselViewList = dieselViewMapper.selectList(BasePowerLineDieselView.builder()
.lineId(lineId)
.build());
if (!dieselViewList.isEmpty()) {
if (CollectionUtil.isNotEmpty(dieselViewList)) {
output.setDieselOutputs(XCopyUtils.copyNewList(dieselViewList, GetBasePowerLineDieselViewOutput.class));
}
return XSingleResult.success(output);
......@@ -334,7 +334,7 @@ public class BasePowerLineService {
private void saveLineRelation(String lineId, String ouId, PpsUserSession session,
List wellheadInputs, List plantInputs, List storageInputs, List dieselInputs) {
//新增井口配置
if (!wellheadInputs.isEmpty()) {
if (CollectionUtil.isNotEmpty(wellheadInputs)) {
List<BasePowerLineWellheadEnt> wellheads = XCopyUtils.copyNewList(wellheadInputs, BasePowerLineWellheadEnt.class);
for (BasePowerLineWellheadEnt wellhead : wellheads) {
wellhead.setLineId(lineId);
......@@ -344,7 +344,7 @@ public class BasePowerLineService {
BaseEntUtils.batchInsert(BasePowerLineWellheadMapper.class, BasePowerLineWellheadEnt.class, wellheads);
}
//新增光伏配置
if (!plantInputs.isEmpty()) {
if (CollectionUtil.isNotEmpty(plantInputs)) {
List<BasePowerLinePlantEnt> plants = XCopyUtils.copyNewList(plantInputs, BasePowerLinePlantEnt.class);
for (BasePowerLinePlantEnt plant : plants) {
plant.setLineId(lineId);
......@@ -354,7 +354,7 @@ public class BasePowerLineService {
BaseEntUtils.batchInsert(BasePowerLinePlantMapper.class, BasePowerLinePlantEnt.class, plants);
}
//新增储能配置
if (!storageInputs.isEmpty()) {
if (CollectionUtil.isNotEmpty(storageInputs)) {
List<BasePowerLineStorageEnt> storages = XCopyUtils.copyNewList(storageInputs, BasePowerLineStorageEnt.class);
for (BasePowerLineStorageEnt storage : storages) {
storage.setLineId(lineId);
......@@ -364,7 +364,7 @@ public class BasePowerLineService {
BaseEntUtils.batchInsert(BasePowerLineStorageMapper.class, BasePowerLineStorageEnt.class, storages);
}
//新增柴发配置
if (!dieselInputs.isEmpty()) {
if (CollectionUtil.isNotEmpty(dieselInputs)) {
List<BasePowerLineDieselEnt> diesels = XCopyUtils.copyNewList(dieselInputs, BasePowerLineDieselEnt.class);
for (BasePowerLineDieselEnt diesel : diesels) {
diesel.setLineId(lineId);
......
package pps.core.base.service;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
......@@ -72,7 +73,7 @@ public class BasePriceStrategyService {
mapper.insert(entity);
String strategyId = entity.getId();
List<CreateBasePriceStrategyMonthInput> inputMonths = input.getMonths();
if (!inputMonths.isEmpty()) {
if (CollectionUtil.isNotEmpty(inputMonths)) {
List<BasePriceStrategyMonthEnt> monthList = XCopyUtils.copyNewList(inputMonths, BasePriceStrategyMonthEnt.class);
BasePriceStrategyMonthMapper monthMapper = context.getBean(BasePriceStrategyMonthMapper.class);
this.saveStrategyMonthDetail(monthMapper, monthList, strategyId, session);
......@@ -96,14 +97,13 @@ public class BasePriceStrategyService {
String strategyId = input.getId();
return XTransactionHelper.begin(context, () -> {
BasePriceStrategyMapper mapper = context.getBean(BasePriceStrategyMapper.class);
QueryWrapper<BasePriceStrategyEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BasePriceStrategyEnt::getId, strategyId);
BasePriceStrategyEnt entity = mapper.selectOne(queryWrapper);
BasePriceStrategyEnt entity = mapper.selectOne(new LambdaQueryWrapper<BasePriceStrategyEnt>()
.eq(BaseEnt::getId, strategyId));
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
List<UpdateBasePriceStrategyMonthInput> inputMonths = input.getMonths();
if (!inputMonths.isEmpty()) {
if (CollectionUtil.isNotEmpty(inputMonths)) {
List<BasePriceStrategyMonthEnt> monthList = XCopyUtils.copyNewList(inputMonths, BasePriceStrategyMonthEnt.class);
List<Integer> collect = monthList.stream()
.map(BasePriceStrategyMonthEnt::getStrategyMonth)
......@@ -143,17 +143,15 @@ public class BasePriceStrategyService {
@XApiPost
@XText("市电峰谷策略--删除")
public XServiceResult deleteBasePriceStrategy(XContext context, DeleteBasePriceStrategyInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
String strategyId = input.getId();
if (DictUtils.checkStrategyIsReference(context, strategyId)) {
return XServiceResult.error(992, "当前策略已被引用");
}
return XTransactionHelper.begin(context, () -> {
BasePriceStrategyMapper mapper = context.getBean(BasePriceStrategyMapper.class);
QueryWrapper<BasePriceStrategyEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BasePriceStrategyEnt::getId, strategyId);
BasePriceStrategyEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
BasePriceStrategyEnt entity = mapper.selectOne(new LambdaQueryWrapper<BasePriceStrategyEnt>()
.eq(BaseEnt::getId, strategyId));
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
//删除月数据
......@@ -194,7 +192,7 @@ public class BasePriceStrategyService {
BasePriceStrategyEnt::getFixedElectricityPrice)
.eq(BasePriceStrategyEnt::getId, strategyId);
BasePriceStrategyEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
if (Objects.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBasePriceStrategyOutput output = XCopyUtils.copyNewObject(entity, GetBasePriceStrategyOutput.class);
......@@ -204,7 +202,7 @@ public class BasePriceStrategyService {
.lambda()
.select(BasePriceStrategyMonthEnt::getId, BasePriceStrategyMonthEnt::getStrategyMonth)
.eq(BasePriceStrategyMonthEnt::getStrategyId, strategyId));
if (!monthEntList.isEmpty()) {
if (CollectionUtil.isNotEmpty(monthEntList)) {
//查明细
BasePriceStrategyDetailMapper detailMapper = context.getBean(BasePriceStrategyDetailMapper.class);
List<BasePriceStrategyDetailEnt> detailEntList = detailMapper.selectList(new QueryWrapper<BasePriceStrategyDetailEnt>()
......@@ -216,7 +214,7 @@ public class BasePriceStrategyService {
BasePriceStrategyDetailEnt::getElectrovalence,
BasePriceStrategyDetailEnt::getInternalSettlementPrice)
.eq(BasePriceStrategyDetailEnt::getStrategyId, strategyId));
if (!detailEntList.isEmpty()) {
if (CollectionUtil.isNotEmpty(detailEntList)) {
Map<Integer, List<BasePriceStrategyDetailEnt>> collect = detailEntList.stream()
.collect(Collectors.groupingBy(BasePriceStrategyDetailEnt::getStrategyMonth));
for (BasePriceStrategyMonthEnt monthEnt : monthEntList) {
......
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