Commit 5c0517ae authored by ZWT's avatar ZWT

feat(能源管理系统): 间开制度管理

1.间开制度管理-基础间开配置模块新增功能,完成接口冒烟测试并生成接口文档;
2.排查无法获取mapper对象导致空指针异常问题,space模块添加mapper配置类;
3.间开制度管理-基础间开配置模块修改功能,完成接口冒烟测试并生成接口文档;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent dfa606cb
package pps.core.space.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.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import pps.core.common.entity.BaseModel;
import pps.core.common.session.PpsUserSession;
import pps.core.common.utils.BaseUtils;
import pps.core.space.entity.SpaceInstitutionDetailEnt;
......@@ -16,6 +18,7 @@ import pps.core.space.mapper.SpaceInstitutionDurationMapper;
import pps.core.space.mapper.SpaceInstitutionWellheadViewMapper;
import pps.core.space.service.data.space_institution_detail.*;
import pps.core.space.service.data.space_institution_wellhead.CreateSpaceInstitutionWellheadInput;
import pps.core.space.service.data.space_institution_wellhead.UpdateSpaceInstitutionWellheadInput;
import xstartup.annotation.XService;
import xstartup.annotation.XText;
import xstartup.base.XContext;
......@@ -32,6 +35,7 @@ import xstartup.feature.mybatis.helper.XMapperHelper;
import xstartup.helper.XTransactionHelper;
import java.util.List;
import java.util.Objects;
/**
* 基础间开配置模块
......@@ -67,32 +71,13 @@ public class SpaceInstitutionDetailService {
String institutionId = entity.getId();
List<CreateSpaceInstitutionWellheadInput> wellheadList = input.getWellheadList();
if (CollUtil.isNotEmpty(wellheadList)) {
List<SpaceInstitutionDurationEnt> durationList;
SpaceInstitutionWellheadViewMapper wellheadMapper = context.getBean(SpaceInstitutionWellheadViewMapper.class);
List<SpaceInstitutionWellheadView> wellheads = XCopyUtils.copyNewList(wellheadList, SpaceInstitutionWellheadView.class);
for (SpaceInstitutionWellheadView wellhead : wellheads) {
wellhead.setInstitutionId(institutionId);
BaseUtils.setBaseModelDefault(wellhead, session);
wellheadMapper.insert(wellhead);
String wellheadId = wellhead.getWellheadId();
String configId = wellhead.getId();
durationList = wellhead.getDurationList();
if (CollUtil.isNotEmpty(durationList)) {
durationList.forEach(d -> {
d.setWellheadId(wellheadId);
d.setConfigId(configId);
d.setInstitutionId(institutionId);
BaseUtils.setBaseModelDefault(d, session);
});
BaseUtils.batchInsert(SpaceInstitutionDurationMapper.class, SpaceInstitutionDurationEnt.class, durationList);
}
}
this.saveInstitutionWellhead(session, institutionId, wellheadList, wellheadMapper);
}
return XServiceResult.OK;
});
}
/**
* 基础间开配置--修改
*
......@@ -104,16 +89,42 @@ public class SpaceInstitutionDetailService {
@XApiPost
@XText("基础间开配置--修改")
public XServiceResult updateSpaceInstitutionDetail(XContext context, UpdateSpaceInstitutionDetailInput input) {
SpaceInstitutionDetailMapper mapper = context.getBean(SpaceInstitutionDetailMapper.class);
QueryWrapper<SpaceInstitutionDetailEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SpaceInstitutionDetailEnt::getId, input.getId());
SpaceInstitutionDetailEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
mapper.updateById(entity);
return XServiceResult.OK;
PpsUserSession session = new PpsUserSession();
session.setId("123");
session.setUserName("ceshi");
// PpsUserSession session = context.getSession(PpsUserSession.class);
String institutionId = input.getId();
return XTransactionHelper.begin(context, () -> {
SpaceInstitutionDetailMapper mapper = context.getBean(SpaceInstitutionDetailMapper.class);
SpaceInstitutionDetailEnt entity = mapper.selectOne(new LambdaQueryWrapper<SpaceInstitutionDetailEnt>()
.eq(BaseModel::getId, institutionId)
);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
Integer isCurrentBasic = entity.getIsCurrentBasic();
if (isCurrentBasic.equals(0)) {
return XServiceResult.error(992, "基础制度无法修改");
}
List<UpdateSpaceInstitutionWellheadInput> wellheadList = input.getWellheadList();
if (CollUtil.isNotEmpty(wellheadList)) {
//删除之前关联的信息
SpaceInstitutionWellheadViewMapper wellheadMapper = context.getBean(SpaceInstitutionWellheadViewMapper.class);
wellheadMapper.delete(new LambdaQueryWrapper<SpaceInstitutionWellheadView>()
.eq(SpaceInstitutionWellheadView::getInstitutionId, institutionId)
);
SpaceInstitutionDurationMapper durationMapper = context.getBean(SpaceInstitutionDurationMapper.class);
durationMapper.delete(new LambdaQueryWrapper<SpaceInstitutionDurationEnt>()
.eq(SpaceInstitutionDurationEnt::getInstitutionId, institutionId)
);
//重新添加关联信息
this.saveInstitutionWellhead(session, institutionId, wellheadList, wellheadMapper);
}
XCopyUtils.copyObject(input, entity);
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@XApiAnonymous
......@@ -208,7 +219,34 @@ public class SpaceInstitutionDetailService {
/*-----------------------------------private-----------------------------------*/
private void saveInstitutionWellhead(PpsUserSession session) {
/**
* 保存策略关联信息
*
* @param session 一场
* @param institutionId 机构id
* @param wellheadList 井口一览表
* @param wellheadMapper 井口测绘仪
*/
private void saveInstitutionWellhead(PpsUserSession session, String institutionId, List wellheadList,
SpaceInstitutionWellheadViewMapper wellheadMapper) {
List<SpaceInstitutionWellheadView> wellheads = XCopyUtils.copyNewList(wellheadList, SpaceInstitutionWellheadView.class);
List<SpaceInstitutionDurationEnt> durationList;
for (SpaceInstitutionWellheadView wellhead : wellheads) {
wellhead.setInstitutionId(institutionId);
BaseUtils.setBaseModelDefault(wellhead, session);
wellheadMapper.insert(wellhead);
String wellheadId = wellhead.getWellheadId();
String configId = wellhead.getId();
durationList = wellhead.getDurationList();
if (CollUtil.isNotEmpty(durationList)) {
durationList.forEach(d -> {
d.setWellheadId(wellheadId);
d.setConfigId(configId);
d.setInstitutionId(institutionId);
BaseUtils.setBaseModelDefault(d, session);
});
BaseUtils.batchInsert(SpaceInstitutionDurationMapper.class, SpaceInstitutionDurationEnt.class, durationList);
}
}
}
}
package pps.core.space.service.data.space_institution_detail;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import pps.core.space.service.data.space_institution_wellhead.UpdateSpaceInstitutionWellheadInput;
import xstartup.annotation.XText;
......@@ -17,6 +18,7 @@ import java.util.List;
public class UpdateSpaceInstitutionDetailInput {
@XText("ID")
@NotBlank(message = "缺少间开制度ID")
private String id;
@XText("组织机构ID")
......@@ -37,15 +39,6 @@ public class UpdateSpaceInstitutionDetailInput {
@XText("制度结束时间")
private Date institutionEndDate;
@XText("优化至")
private Date optimizeDeadline;
@XText("优化状态(0_已优化,1_未优化)")
private Integer optimizeState;
@XText("当前基础制度(0_是,1_否)")
private Integer isCurrentBasic;
@XText("启动间隔(分钟)")
private Integer startInterval;
......
package pps.core.space.service.data.space_institution_duration;
import xstartup.annotation.XText;
import java.util.Date;
public class CreateSpaceInstitutionDurationOutput {
@XText("ID")
private String id;
@XText("是否删除(0_是,1_否)")
private Integer isDeleted;
@XText("创建人ID")
private String createById;
@XText("创建人名称")
private String createByName;
@XText("创建时间")
private Date createTime;
@XText("修改人ID")
private String modifyById;
@XText("修改人名称")
private String modifyByName;
@XText("修改时间")
private Date modifyTime;
@XText("间开制度ID")
private String institutionId;
@XText("间开制度井口配置ID")
private String configId;
@XText("井口ID")
private String wellheadId;
@XText("发电类型key(字典获取)")
private String generationTypeKey;
@XText("开井时间")
private String openWellTime;
@XText("关井时间")
private String closeWellTime;
public String getId() {
return this.id;
}
public void setId(String value) {
this.id = value;
}
public Integer getIsDeleted() {
return this.isDeleted;
}
public void setIsDeleted(Integer value) {
this.isDeleted = value;
}
public String getCreateById() {
return this.createById;
}
public void setCreateById(String value) {
this.createById = value;
}
public String getCreateByName() {
return this.createByName;
}
public void setCreateByName(String value) {
this.createByName = value;
}
public Date getCreateTime() {
return this.createTime;
}
public void setCreateTime(Date value) {
this.createTime = value;
}
public String getModifyById() {
return this.modifyById;
}
public void setModifyById(String value) {
this.modifyById = value;
}
public String getModifyByName() {
return this.modifyByName;
}
public void setModifyByName(String value) {
this.modifyByName = value;
}
public Date getModifyTime() {
return this.modifyTime;
}
public void setModifyTime(Date value) {
this.modifyTime = value;
}
public String getInstitutionId() {
return this.institutionId;
}
public void setInstitutionId(String value) {
this.institutionId = value;
}
public String getConfigId() {
return this.configId;
}
public void setConfigId(String value) {
this.configId = value;
}
public String getWellheadId() {
return this.wellheadId;
}
public void setWellheadId(String value) {
this.wellheadId = value;
}
public String getGenerationTypeKey() {
return this.generationTypeKey;
}
public void setGenerationTypeKey(String value) {
this.generationTypeKey = value;
}
public String getOpenWellTime() {
return this.openWellTime;
}
public void setOpenWellTime(String value) {
this.openWellTime = value;
}
public String getCloseWellTime() {
return this.closeWellTime;
}
public void setCloseWellTime(String value) {
this.closeWellTime = value;
}
}
package pps.core.space.service.data.space_institution_duration;
import lombok.Data;
import xstartup.annotation.XText;
import java.util.Date;
/**
* 间开制度小间开时段配置
*
* @author ZWT
* @date 2023/09/05
*/
@Data
public class UpdateSpaceInstitutionDurationInput {
@XText("ID")
private String id;
@XText("是否删除(0_是,1_否)")
private Integer isDeleted;
@XText("创建人ID")
private String createById;
@XText("创建人名称")
private String createByName;
@XText("创建时间")
private Date createTime;
@XText("修改人ID")
private String modifyById;
@XText("修改人名称")
private String modifyByName;
@XText("修改时间")
private Date modifyTime;
@XText("间开制度ID")
private String institutionId;
@XText("间开制度井口配置ID")
private String configId;
@XText("井口ID")
private String wellheadId;
@XText("发电类型key(字典获取)")
private String generationTypeKey;
@XText("开井时间")
private String openWellTime;
@XText("关井时间")
private String closeWellTime;
public String getId() {
return this.id;
}
public void setId(String value) {
this.id = value;
}
public Integer getIsDeleted() {
return this.isDeleted;
}
public void setIsDeleted(Integer value) {
this.isDeleted = value;
}
public String getCreateById() {
return this.createById;
}
public void setCreateById(String value) {
this.createById = value;
}
public String getCreateByName() {
return this.createByName;
}
public void setCreateByName(String value) {
this.createByName = value;
}
public Date getCreateTime() {
return this.createTime;
}
public void setCreateTime(Date value) {
this.createTime = value;
}
public String getModifyById() {
return this.modifyById;
}
public void setModifyById(String value) {
this.modifyById = value;
}
public String getModifyByName() {
return this.modifyByName;
}
public void setModifyByName(String value) {
this.modifyByName = value;
}
public Date getModifyTime() {
return this.modifyTime;
}
public void setModifyTime(Date value) {
this.modifyTime = value;
}
public String getInstitutionId() {
return this.institutionId;
}
public void setInstitutionId(String value) {
this.institutionId = value;
}
public String getConfigId() {
return this.configId;
}
public void setConfigId(String value) {
this.configId = value;
}
public String getWellheadId() {
return this.wellheadId;
}
public void setWellheadId(String value) {
this.wellheadId = value;
}
public String getGenerationTypeKey() {
return this.generationTypeKey;
}
public void setGenerationTypeKey(String value) {
this.generationTypeKey = value;
}
public String getOpenWellTime() {
return this.openWellTime;
}
public void setOpenWellTime(String value) {
this.openWellTime = value;
}
public String getCloseWellTime() {
return this.closeWellTime;
}
public void setCloseWellTime(String value) {
this.closeWellTime = value;
}
}
package pps.core.space.service.data.space_institution_duration;
import xstartup.annotation.XText;
import java.util.Date;
public class UpdateSpaceInstitutionDurationOutput {
@XText("ID")
private String id;
@XText("是否删除(0_是,1_否)")
private Integer isDeleted;
@XText("创建人ID")
private String createById;
@XText("创建人名称")
private String createByName;
@XText("创建时间")
private Date createTime;
@XText("修改人ID")
private String modifyById;
@XText("修改人名称")
private String modifyByName;
@XText("修改时间")
private Date modifyTime;
@XText("间开制度ID")
private String institutionId;
@XText("间开制度井口配置ID")
private String configId;
@XText("井口ID")
private String wellheadId;
@XText("发电类型key(字典获取)")
private String generationTypeKey;
@XText("开井时间")
private String openWellTime;
@XText("关井时间")
private String closeWellTime;
public String getId() {
return this.id;
}
public void setId(String value) {
this.id = value;
}
public Integer getIsDeleted() {
return this.isDeleted;
}
public void setIsDeleted(Integer value) {
this.isDeleted = value;
}
public String getCreateById() {
return this.createById;
}
public void setCreateById(String value) {
this.createById = value;
}
public String getCreateByName() {
return this.createByName;
}
public void setCreateByName(String value) {
this.createByName = value;
}
public Date getCreateTime() {
return this.createTime;
}
public void setCreateTime(Date value) {
this.createTime = value;
}
public String getModifyById() {
return this.modifyById;
}
public void setModifyById(String value) {
this.modifyById = value;
}
public String getModifyByName() {
return this.modifyByName;
}
public void setModifyByName(String value) {
this.modifyByName = value;
}
public Date getModifyTime() {
return this.modifyTime;
}
public void setModifyTime(Date value) {
this.modifyTime = value;
}
public String getInstitutionId() {
return this.institutionId;
}
public void setInstitutionId(String value) {
this.institutionId = value;
}
public String getConfigId() {
return this.configId;
}
public void setConfigId(String value) {
this.configId = value;
}
public String getWellheadId() {
return this.wellheadId;
}
public void setWellheadId(String value) {
this.wellheadId = value;
}
public String getGenerationTypeKey() {
return this.generationTypeKey;
}
public void setGenerationTypeKey(String value) {
this.generationTypeKey = value;
}
public String getOpenWellTime() {
return this.openWellTime;
}
public void setOpenWellTime(String value) {
this.openWellTime = value;
}
public String getCloseWellTime() {
return this.closeWellTime;
}
public void setCloseWellTime(String value) {
this.closeWellTime = value;
}
}
package pps.core.space.service.data.space_institution_wellhead;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import pps.core.space.service.data.space_institution_duration.UpdateSpaceInstitutionDurationInput;
import xstartup.annotation.XText;
import java.math.BigDecimal;
import java.util.List;
/**
* 间开制度井口配置
......@@ -13,16 +16,13 @@ import java.math.BigDecimal;
*/
@Data
public class UpdateSpaceInstitutionWellheadInput {
@XText("ID")
private String id;
@XText("间开制度ID")
private String institutionId;
@XText("井口ID")
@NotBlank(message = "缺少井口ID")
private String wellheadId;
@XText("井号")
@NotBlank(message = "缺少井号")
private String wellNumber;
@XText("运行类型key(字典获取)")
......@@ -45,4 +45,10 @@ public class UpdateSpaceInstitutionWellheadInput {
@XText("运行时长(小时/天)")
private BigDecimal runDuration;
/**
* 间开制度小间开时段配置
*/
@XText("间开制度小间开时段配置")
private List<UpdateSpaceInstitutionDurationInput> durationList;
}
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