Commit d5626efb authored by ZWT's avatar ZWT

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

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

BREAKING CHANGE: 无

Closes 无

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