Commit 97e53dbb authored by ZWT's avatar ZWT

feat(能源管理系统): 测试问题修复

1.修改基础信息配置--井口配置模块,新增/修改接口,增加井口编号重复校验及必填项校验逻辑;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent c96883fa
......@@ -16,6 +16,7 @@ public enum BusinessError implements XError {
StrategyReference(2004, "当前策略已被引用"),
WellheadReferenceLine(2005, "当前井口已被线路引用"),
WellheadReferenceSpace(2006, "当前井口已被间开引用"),
WellNumberExists(2007, "井号已存在"),
;
private int code;
......
......@@ -44,12 +44,25 @@ import java.util.Objects;
@XService
public class BaseWellheadService {
@XText("新增")
/**
* 井口配置模块--新增
* POST /base/base-wellhead/create-base-wellhead
* 接口ID:105357657
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105357657
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("井口配置模块--新增")
@XApiAnonymous
@XApiPost
public XServiceResult createBaseWellhead(XContext context, CreateBaseWellheadInput input) {
return XTransactionHelper.begin(context, () -> {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
if (this.checkWellNumberExists(mapper, input.getWellNumber(), null)) {
return XServiceResult.error(context, BusinessError.WellNumberExists);
}
return XTransactionHelper.begin(context, () -> {
BaseWellheadEnt entity = XCopyUtils.copyNewObject(input, BaseWellheadEnt.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
......@@ -58,12 +71,25 @@ public class BaseWellheadService {
});
}
@XText("更新")
/**
* 井口配置模块--修改
* POST /base/base-wellhead/update-base-wellhead
* 接口ID:105426967
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105426967
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("井口配置模块--修改")
@XApiAnonymous
@XApiPost
public XServiceResult updateBaseWellhead(XContext context, UpdateBaseWellheadInput input) {
return XTransactionHelper.begin(context, () -> {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
if (this.checkWellNumberExists(mapper, input.getWellNumber(), input.getId())) {
return XServiceResult.error(context, BusinessError.WellNumberExists);
}
return XTransactionHelper.begin(context, () -> {
BaseWellheadEnt entity = this.selectOneByWellheadId(input.getId(), mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
......@@ -76,7 +102,17 @@ public class BaseWellheadService {
});
}
@XText("删除")
/**
* 井口配置模块--删除
* POST /base/base-wellhead/delete-base-wellhead
* 接口ID:105430749
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105430749
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("井口配置模块--删除")
@XApiAnonymous
@XApiPost
public XServiceResult deleteBaseWellhead(XContext context, DeleteBaseWellheadInput input) {
......@@ -103,7 +139,17 @@ public class BaseWellheadService {
});
}
@XText("根据ID获取详情")
/**
* 井口配置模块--详情
* GET /base/base-wellhead/get-base-wellhead
* 接口ID:105325952
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105325952
*
* @param context 上下文
* @param input 输入
* @return {@link XSingleResult}<{@link GetBaseWellheadOutput}>
*/
@XText("井口配置模块--详情")
@XApiAnonymous
@XApiGet
public XSingleResult<GetBaseWellheadOutput> getBaseWellhead(XContext context, GetBaseWellheadInput input) {
......@@ -117,7 +163,7 @@ public class BaseWellheadService {
}
/**
* 分页查询
* 井口配置模块--分页查询
* GET /base/base-wellhead/query-base-wellhead
* 接口ID:105431641
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105431641
......@@ -126,7 +172,7 @@ public class BaseWellheadService {
* @param input 输入
* @return {@link XPageResult}<{@link QueryBaseWellheadOutput}>
*/
@XText("分页查询")
@XText("井口配置模块--分页查询")
@XApiAnonymous
@XApiGet
public XPageResult<QueryBaseWellheadOutput> queryBaseWellhead(XContext context, QueryBaseWellheadInput input) {
......@@ -191,4 +237,21 @@ public class BaseWellheadService {
.eq(BaseModel::getId, wellheadId)
);
}
/**
* 检查井编号存在
*
* @param mapper 映射器
* @param wellNumber 井号
* @param id id
* @return boolean
*/
private boolean checkWellNumberExists(BaseWellheadMapper mapper, String wellNumber, String id) {
Long count = mapper.selectCount(new LambdaQueryWrapper<BaseWellheadEnt>()
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.eq(BaseWellheadEnt::getWellNumber, wellNumber)
.ne(StringUtils.isNotEmpty(id), BaseModel::getId, id)
);
return count > 0;
}
}
package pps.core.base.service.data.base_wellhead;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import xstartup.annotation.XText;
import java.math.BigDecimal;
/**
* 井口配置
*
* @author ZWT
* @date 2023/10/20
*/
@Data
public class CreateBaseWellheadInput {
@XText("组织机构ID")
@NotBlank(message = "缺少组织机构ID")
private String ouId;
@XText("组织机构name")
private String ouName;
@XText("井号")
@NotBlank(message = "缺少井号")
private String wellNumber;
@XText("运行类型key(字典获取)")
@NotBlank(message = "缺少运行类型")
private String runTypeKey;
@XText("运行类型name(字典获取)")
private String runTypeName;
@XText("运行功率(KW)")
@NotNull(message = "缺少运行功率")
private BigDecimal serviceRating;
public String getOuId() {
return this.ouId;
}
public void setOuId(String value) {
this.ouId = value;
}
public String getWellNumber() {
return this.wellNumber;
}
public void setWellNumber(String value) {
this.wellNumber = value;
}
public String getRunTypeKey() {
return this.runTypeKey;
}
public void setRunTypeKey(String value) {
this.runTypeKey = value;
}
public BigDecimal getServiceRating() {
return this.serviceRating;
}
public void setServiceRating(BigDecimal value) {
this.serviceRating = value;
}
public String getOuName() {
return ouName;
}
public void setOuName(String ouName) {
this.ouName = ouName;
}
public String getRunTypeName() {
return runTypeName;
}
public void setRunTypeName(String runTypeName) {
this.runTypeName = runTypeName;
}
}
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