Commit d33d8b91 authored by tianchao's avatar tianchao
parents 3ad9b36a b5a578ba
......@@ -16,6 +16,8 @@ public enum BusinessError implements XError {
StrategyReference(2004, "当前策略已被引用"),
WellheadReferenceLine(2005, "当前井口已被线路引用"),
WellheadReferenceSpace(2006, "当前井口已被间开引用"),
WellNumberExists(2007, "井号已存在"),
MakerNumberExists(2008, "出场编号已存在"),
;
private int code;
......
......@@ -42,39 +42,73 @@ import java.util.Objects;
@XService
public class BaseDieselGeneratorService {
@XText("新增")
/**
* 柴发设备模块--新增
* POST /base/base-diesel-generator/create-base-diesel-generator
* 接口ID:105601993
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105601993
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("柴发设备模块--新增")
@XApiAnonymous
@XApiPost
public XServiceResult createBaseDieselGenerator(XContext context, CreateBaseDieselGeneratorInput input) {
BaseDieselGeneratorMapper mapper = context.getBean(BaseDieselGeneratorMapper.class);
if (this.checkMakerNumberExists(mapper, input.getMakerNumber(), null)) {
return XServiceResult.error(context, BusinessError.MakerNumberExists);
}
BaseDieselGeneratorEnt entity = XCopyUtils.copyNewObject(input, BaseDieselGeneratorEnt.class);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BaseDieselGeneratorMapper mapper = context.getBean(BaseDieselGeneratorMapper.class);
BaseDieselGeneratorEnt entity = XCopyUtils.copyNewObject(input, BaseDieselGeneratorEnt.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.insert(entity);
return XServiceResult.OK;
});
}
@XText("更新")
/**
* 柴发设备模块--修改
* POST /base/base-diesel-generator/update-base-diesel-generator
* 接口ID:105601994
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105601994
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("柴发设备模块--修改")
@XApiAnonymous
@XApiPost
public XServiceResult updateBaseDieselGenerator(XContext context, UpdateBaseDieselGeneratorInput input) {
BaseDieselGeneratorMapper mapper = context.getBean(BaseDieselGeneratorMapper.class);
if (this.checkMakerNumberExists(mapper, input.getMakerNumber(), input.getId())) {
return XServiceResult.error(context, BusinessError.MakerNumberExists);
}
BaseDieselGeneratorEnt entity = this.selectOneByDieselId(input.getId(), mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BaseDieselGeneratorMapper mapper = context.getBean(BaseDieselGeneratorMapper.class);
BaseDieselGeneratorEnt entity = this.selectOneByDieselId(input.getId(), mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@XText("删除")
/**
* 柴发设备模块--删除
* POST /base/base-diesel-generator/delete-base-diesel-generator
* 接口ID:105601998
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105601998
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("柴发设备模块--删除")
@XApiAnonymous
@XApiPost
public XServiceResult deleteBaseDieselGenerator(XContext context, DeleteBaseDieselGeneratorInput input) {
......@@ -82,23 +116,31 @@ public class BaseDieselGeneratorService {
if (this.checkDieselIsReference(context, dieselId)) {
return XServiceResult.error(context, BusinessError.DieselReference);
}
BaseDieselGeneratorMapper mapper = context.getBean(BaseDieselGeneratorMapper.class);
if (Objects.isNull(this.selectOneByDieselId(dieselId, mapper))) {
return XServiceResult.error(context, XError.NotFound);
}
BaseDieselGeneratorEnt entity = new BaseDieselGeneratorEnt();
entity.setId(dieselId);
entity.setIsDeleted(BusinessConstant.ZERO);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BaseDieselGeneratorMapper mapper = context.getBean(BaseDieselGeneratorMapper.class);
BaseDieselGeneratorEnt entity = this.selectOneByDieselId(dieselId, mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
entity = new BaseDieselGeneratorEnt();
entity.setId(dieselId);
entity.setIsDeleted(BusinessConstant.ZERO);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@XText("根据id获取详情")
/**
* 柴发设备模块--详情
* GET /base/base-diesel-generator/get-base-diesel-generator
* 接口ID:105601991
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105601991
*
* @param context 上下文
* @param input 输入
* @return {@link XSingleResult}<{@link GetBaseDieselGeneratorOutput}>
*/
@XText("柴发设备模块--详情")
@XApiAnonymous
@XApiGet
public XSingleResult<GetBaseDieselGeneratorOutput> getBaseDieselGenerator(XContext context, GetBaseDieselGeneratorInput input) {
......@@ -112,7 +154,7 @@ public class BaseDieselGeneratorService {
}
/**
* 分页查询
* 柴发设备模块--分页查询
* GET /base/base-diesel-generator/query-base-diesel-generator
* 接口ID:105601992
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105601992
......@@ -121,7 +163,7 @@ public class BaseDieselGeneratorService {
* @param input 输入
* @return {@link XPageResult}<{@link QueryBaseDieselGeneratorOutput}>
*/
@XText("分页查询")
@XText("柴发设备模块--分页查询")
@XApiAnonymous
@XApiGet
public XPageResult<QueryBaseDieselGeneratorOutput> queryBaseDieselGenerator(XContext context, QueryBaseDieselGeneratorInput input) {
......@@ -132,6 +174,7 @@ public class BaseDieselGeneratorService {
if (StringUtils.isNotEmpty(input.getLineId())) {
queryWrapper.lambda()
.notExists(!StringUtils.equals(BusinessConstant.LINE_FLAG_ID, input.getLineId()), "SELECT 1 FROM base_power_line_diesel w WHERE base_diesel_generator.id = w.diesel_id AND w.is_deleted = 1 AND w.line_id <> {0}", input.getLineId())
.notExists(StringUtils.equals(BusinessConstant.LINE_FLAG_ID, input.getLineId()), "SELECT 1 FROM base_power_line_diesel w WHERE base_diesel_generator.id = w.diesel_id AND w.is_deleted = 1")
.eq(BaseDieselGeneratorEnt::getOuId, input.getOuId());
} else {
List<String> allListByOuId = ServiceUtil.getOrgIdsByPath(context, input.getOuId());
......@@ -176,4 +219,21 @@ public class BaseDieselGeneratorService {
.eq(BaseModel::getId, dieselId)
);
}
/**
* 检查编号是否存在
*
* @param mapper 映射器
* @param makerNumber 出场编号
* @param id id
* @return boolean
*/
private boolean checkMakerNumberExists(BaseDieselGeneratorMapper mapper, String makerNumber, String id) {
Long count = mapper.selectCount(new LambdaQueryWrapper<BaseDieselGeneratorEnt>()
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.eq(BaseDieselGeneratorEnt::getMakerNumber, makerNumber)
.ne(StringUtils.isNotEmpty(id), BaseModel::getId, id)
);
return count > 0;
}
}
\ No newline at end of file
......@@ -42,39 +42,73 @@ import java.util.Objects;
@XService
public class BaseEnergyStorageDeviceService {
@XText("新增")
/**
* 储能设备模块--新增
* POST /base/base-energy-storage-device/create-base-energy-storage-device
* 接口ID:105602202
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105602202
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("储能设备模块--新增")
@XApiAnonymous
@XApiPost
public XServiceResult createBaseEnergyStorageDevice(XContext context, CreateBaseEnergyStorageDeviceInput input) {
BaseEnergyStorageDeviceMapper mapper = context.getBean(BaseEnergyStorageDeviceMapper.class);
if (this.checkMakerNumberExists(mapper, input.getMakerNumber(), null)) {
return XServiceResult.error(context, BusinessError.MakerNumberExists);
}
BaseEnergyStorageDeviceEnt entity = XCopyUtils.copyNewObject(input, BaseEnergyStorageDeviceEnt.class);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BaseEnergyStorageDeviceMapper mapper = context.getBean(BaseEnergyStorageDeviceMapper.class);
BaseEnergyStorageDeviceEnt entity = XCopyUtils.copyNewObject(input, BaseEnergyStorageDeviceEnt.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.insert(entity);
return XServiceResult.OK;
});
}
@XText("更新")
/**
* 储能设备模块--修改
* POST /base/base-energy-storage-device/update-base-energy-storage-device
* 接口ID:105602203
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105602203
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("储能设备模块--修改")
@XApiAnonymous
@XApiPost
public XServiceResult updateBaseEnergyStorageDevice(XContext context, UpdateBaseEnergyStorageDeviceInput input) {
BaseEnergyStorageDeviceMapper mapper = context.getBean(BaseEnergyStorageDeviceMapper.class);
if (this.checkMakerNumberExists(mapper, input.getMakerNumber(), input.getId())) {
return XServiceResult.error(context, BusinessError.MakerNumberExists);
}
BaseEnergyStorageDeviceEnt entity = this.selectOneByDeviceId(input.getId(), mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BaseEnergyStorageDeviceMapper mapper = context.getBean(BaseEnergyStorageDeviceMapper.class);
BaseEnergyStorageDeviceEnt entity = this.selectOneByDeviceId(input.getId(), mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@XText("删除")
/**
* 储能设备模块--删除
* POST /base/base-energy-storage-device/delete-base-energy-storage-device
* 接口ID:105602204
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105602204
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("储能设备模块--删除")
@XApiAnonymous
@XApiPost
public XServiceResult deleteBaseEnergyStorageDevice(XContext context, DeleteBaseEnergyStorageDeviceInput input) {
......@@ -82,23 +116,31 @@ public class BaseEnergyStorageDeviceService {
if (this.checkStorageIsReference(context, storageId)) {
return XServiceResult.error(context, BusinessError.StorageReference);
}
BaseEnergyStorageDeviceMapper mapper = context.getBean(BaseEnergyStorageDeviceMapper.class);
if (Objects.isNull(this.selectOneByDeviceId(storageId, mapper))) {
return XServiceResult.error(context, XError.NotFound);
}
BaseEnergyStorageDeviceEnt entity = new BaseEnergyStorageDeviceEnt();
entity.setId(storageId);
entity.setIsDeleted(BusinessConstant.ZERO);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BaseEnergyStorageDeviceMapper mapper = context.getBean(BaseEnergyStorageDeviceMapper.class);
BaseEnergyStorageDeviceEnt entity = this.selectOneByDeviceId(storageId, mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
entity = new BaseEnergyStorageDeviceEnt();
entity.setId(storageId);
entity.setIsDeleted(BusinessConstant.ZERO);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@XText("根据id获取详情")
/**
* 储能设备模块--详情
* GET /base/base-energy-storage-device/get-base-energy-storage-device
* 接口ID:105602200
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105602200
*
* @param context 上下文
* @param input 输入
* @return {@link XSingleResult}<{@link GetBaseEnergyStorageDeviceOutput}>
*/
@XText("储能设备模块--详情")
@XApiAnonymous
@XApiGet
public XSingleResult<GetBaseEnergyStorageDeviceOutput> getBaseEnergyStorageDevice(XContext context, GetBaseEnergyStorageDeviceInput input) {
......@@ -112,7 +154,7 @@ public class BaseEnergyStorageDeviceService {
}
/**
* 分页查询
* 储能设备模块--分页查询
* GET /base/base-energy-storage-device/query-base-energy-storage-device
* 接口ID:105602201
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105602201
......@@ -121,7 +163,7 @@ public class BaseEnergyStorageDeviceService {
* @param input 输入
* @return {@link XPageResult}<{@link QueryBaseEnergyStorageDeviceOutput}>
*/
@XText("分页查询")
@XText("储能设备模块--分页查询")
@XApiAnonymous
@XApiGet
public XPageResult<QueryBaseEnergyStorageDeviceOutput> queryBaseEnergyStorageDevice(XContext context, QueryBaseEnergyStorageDeviceInput input) {
......@@ -132,6 +174,7 @@ public class BaseEnergyStorageDeviceService {
if (StringUtils.isNotEmpty(input.getLineId())) {
queryWrapper.lambda()
.notExists(!StringUtils.equals(BusinessConstant.LINE_FLAG_ID, input.getLineId()), "SELECT 1 FROM base_power_line_storage w WHERE base_energy_storage_device.id = w.storage_id AND w.is_deleted = 1 AND w.line_id <> {0}", input.getLineId())
.notExists(StringUtils.equals(BusinessConstant.LINE_FLAG_ID, input.getLineId()), "SELECT 1 FROM base_power_line_storage w WHERE base_energy_storage_device.id = w.storage_id AND w.is_deleted = 1")
.eq(BaseEnergyStorageDeviceEnt::getOuId, input.getOuId());
} else {
List<String> allListByOuId = ServiceUtil.getOrgIdsByPath(context, input.getOuId());
......@@ -176,4 +219,21 @@ public class BaseEnergyStorageDeviceService {
.eq(BaseModel::getId, deviceId)
);
}
/**
* 检查编号是否存在
*
* @param mapper 映射器
* @param makerNumber 出场编号
* @param id id
* @return boolean
*/
private boolean checkMakerNumberExists(BaseEnergyStorageDeviceMapper mapper, String makerNumber, String id) {
Long count = mapper.selectCount(new LambdaQueryWrapper<BaseEnergyStorageDeviceEnt>()
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.eq(BaseEnergyStorageDeviceEnt::getMakerNumber, makerNumber)
.ne(StringUtils.isNotEmpty(id), BaseModel::getId, id)
);
return count > 0;
}
}
\ No newline at end of file
......@@ -68,11 +68,13 @@ public class BasePhotovoltaicPlantService {
@XApiAnonymous
@XApiPost
public XServiceResult createBasePhotovoltaicPlant(XContext context, CreateBasePhotovoltaicPlantInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
BasePhotovoltaicPlantMapper mapper = context.getBean(BasePhotovoltaicPlantMapper.class);
if (StringUtils.isNotEmpty(input.getMakerNumber()) && this.checkMakerNumberExists(mapper, input.getMakerNumber(), null)) {
return XServiceResult.error(context, BusinessError.MakerNumberExists);
}
BasePhotovoltaicPlantEnt entity = XCopyUtils.copyNewObject(input, BasePhotovoltaicPlantEnt.class);
BaseUtils.setBaseModelDefault(entity, session);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BasePhotovoltaicPlantMapper mapper = context.getBean(BasePhotovoltaicPlantMapper.class);
mapper.insert(entity);
return XServiceResult.OK;
});
......@@ -92,21 +94,33 @@ public class BasePhotovoltaicPlantService {
@XApiAnonymous
@XApiPost
public XServiceResult updateBasePhotovoltaicPlant(XContext context, UpdateBasePhotovoltaicPlantInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
BasePhotovoltaicPlantMapper mapper = context.getBean(BasePhotovoltaicPlantMapper.class);
if (StringUtils.isNotEmpty(input.getMakerNumber()) && this.checkMakerNumberExists(mapper, input.getMakerNumber(), input.getId())) {
return XServiceResult.error(context, BusinessError.MakerNumberExists);
}
BasePhotovoltaicPlantEnt entity = this.selectOneByPlantId(input.getId(), mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
BaseUtils.setBaseModelDefault(entity, session);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@XText("删除")
/**
* 光伏电站模块--删除
* POST /base/base-photovoltaic-plant/delete-base-photovoltaic-plant
* 接口ID:105466280
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105466280
*
* @param context 上下文
* @param input 输入
* @return {@link XServiceResult}
*/
@XText("光伏电站模块--删除")
@XApiAnonymous
@XApiPost
public XServiceResult deleteBasePhotovoltaicPlant(XContext context, DeleteBasePhotovoltaicPlantInput input) {
......@@ -114,17 +128,15 @@ public class BasePhotovoltaicPlantService {
if (this.checkPhotovoltaicIsReference(context, plantId)) {
return XServiceResult.error(context, BusinessError.PhotovoltaicReference);
}
BasePhotovoltaicPlantMapper mapper = context.getBean(BasePhotovoltaicPlantMapper.class);
if (Objects.isNull(this.selectOneByPlantId(plantId, mapper))) {
return XServiceResult.error(context, XError.NotFound);
}
BasePhotovoltaicPlantEnt entity = new BasePhotovoltaicPlantEnt();
entity.setId(plantId);
entity.setIsDeleted(BusinessConstant.ZERO);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BasePhotovoltaicPlantMapper mapper = context.getBean(BasePhotovoltaicPlantMapper.class);
BasePhotovoltaicPlantEnt entity = this.selectOneByPlantId(plantId, mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
entity = new BasePhotovoltaicPlantEnt();
entity.setId(plantId);
entity.setIsDeleted(BusinessConstant.ZERO);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
......@@ -186,6 +198,7 @@ public class BasePhotovoltaicPlantService {
if (StringUtils.isNotEmpty(input.getLineId())) {
queryWrapper.lambda()
.notExists(!StringUtils.equals(BusinessConstant.LINE_FLAG_ID, input.getLineId()), "SELECT 1 FROM base_power_line_plant w WHERE base_photovoltaic_plant.id = w.plant_id AND w.is_deleted = 1 AND w.line_id <> {0}", input.getLineId())
.notExists(StringUtils.equals(BusinessConstant.LINE_FLAG_ID, input.getLineId()), "SELECT 1 FROM base_power_line_plant w WHERE base_photovoltaic_plant.id = w.plant_id AND w.is_deleted = 1")
.eq(BasePhotovoltaicPlantEnt::getOuId, input.getOuId());
} else {
List<String> allListByOuId = ServiceUtil.getOrgIdsByPath(context, input.getOuId());
......@@ -283,4 +296,21 @@ public class BasePhotovoltaicPlantService {
singleResult.throwIfFail();
return singleResult.getResult();
}
/**
* 检查编号是否存在
*
* @param mapper 映射器
* @param makerNumber 出场编号
* @param id id
* @return boolean
*/
private boolean checkMakerNumberExists(BasePhotovoltaicPlantMapper mapper, String makerNumber, String id) {
Long count = mapper.selectCount(new LambdaQueryWrapper<BasePhotovoltaicPlantEnt>()
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.eq(BasePhotovoltaicPlantEnt::getMakerNumber, makerNumber)
.ne(StringUtils.isNotEmpty(id), BaseModel::getId, id)
);
return count > 0;
}
}
......@@ -44,39 +44,73 @@ 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) {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
if (this.checkWellNumberExists(mapper, input.getWellNumber(), null)) {
return XServiceResult.error(context, BusinessError.WellNumberExists);
}
BaseWellheadEnt entity = XCopyUtils.copyNewObject(input, BaseWellheadEnt.class);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
BaseWellheadEnt entity = XCopyUtils.copyNewObject(input, BaseWellheadEnt.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.insert(entity);
return XServiceResult.OK;
});
}
@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) {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
if (this.checkWellNumberExists(mapper, input.getWellNumber(), input.getId())) {
return XServiceResult.error(context, BusinessError.WellNumberExists);
}
BaseWellheadEnt entity = this.selectOneByWellheadId(input.getId(), mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
BaseWellheadEnt entity = this.selectOneByWellheadId(input.getId(), mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@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) {
......@@ -87,23 +121,31 @@ public class BaseWellheadService {
if (this.checkWellheadIsSpaceReference(context, wellheadId)) {
return XServiceResult.error(context, BusinessError.WellheadReferenceSpace);
}
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
if (Objects.isNull(this.selectOneByWellheadId(wellheadId, mapper))) {
return XServiceResult.error(context, XError.NotFound);
}
BaseWellheadEnt entity = new BaseWellheadEnt();
entity.setId(wellheadId);
entity.setIsDeleted(BusinessConstant.ZERO);
BaseUtils.setBaseModelDefault(entity, context.getSession(PpsUserSession.class));
return XTransactionHelper.begin(context, () -> {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
BaseWellheadEnt entity = this.selectOneByWellheadId(wellheadId, mapper);
if (Objects.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
entity = new BaseWellheadEnt();
entity.setId(wellheadId);
entity.setIsDeleted(BusinessConstant.ZERO);
PpsUserSession session = context.getSession(PpsUserSession.class);
BaseUtils.setBaseModelDefault(entity, session);
mapper.updateById(entity);
return XServiceResult.OK;
});
}
@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 +159,7 @@ public class BaseWellheadService {
}
/**
* 分页查询
* 井口配置模块--分页查询
* GET /base/base-wellhead/query-base-wellhead
* 接口ID:105431641
* 接口地址:https://app.apifox.com/project/3196988/apis/api-105431641
......@@ -126,7 +168,7 @@ public class BaseWellheadService {
* @param input 输入
* @return {@link XPageResult}<{@link QueryBaseWellheadOutput}>
*/
@XText("分页查询")
@XText("井口配置模块--分页查询")
@XApiAnonymous
@XApiGet
public XPageResult<QueryBaseWellheadOutput> queryBaseWellhead(XContext context, QueryBaseWellheadInput input) {
......@@ -135,6 +177,7 @@ public class BaseWellheadService {
if (StringUtils.isNotEmpty(input.getLineId())) {
queryWrapper.lambda()
.notExists(!StringUtils.equals(BusinessConstant.LINE_FLAG_ID, input.getLineId()), "SELECT 1 FROM base_power_line_wellhead w WHERE base_wellhead.id = w.wellhead_id AND w.is_deleted = 1 AND w.line_id <> {0}", input.getLineId())
.notExists(StringUtils.equals(BusinessConstant.LINE_FLAG_ID, input.getLineId()), "SELECT 1 FROM base_power_line_wellhead w WHERE base_wellhead.id = w.wellhead_id AND w.is_deleted = 1")
.eq(BaseWellheadEnt::getOuId, input.getOuId());
} else {
List<String> allListByOuId = ServiceUtil.getOrgIdsByPath(context, input.getOuId());
......@@ -191,4 +234,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_diesel_generator;
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 CreateBaseDieselGeneratorInput {
@XText("组织机构ID")
@NotBlank(message = "缺少组织机构ID")
private String ouId;
@XText("组织机构name")
private String ouName;
@XText("设备名称")
@NotBlank(message = "缺少设备名称")
private String deviceName;
@XText("出厂编号")
@NotBlank(message = "缺少出厂编号")
private String makerNumber;
@XText("柴发设备机组型号key(字典获取)")
......@@ -26,9 +38,10 @@ public class CreateBaseDieselGeneratorInput {
private String unitTypeName;
@XText("常用功率(KW)")
@NotNull(message = "缺少常用功率")
private BigDecimal normalPower;
@XText("备用功率(KW)")
@NotNull(message = "缺少备用功率")
private BigDecimal standbyPower;
}
......@@ -2,9 +2,16 @@ package pps.core.base.service.data.base_diesel_generator;
import lombok.Data;
import xstartup.annotation.XText;
/**
* 柴发设备
*
* @author ZWT
* @date 2023/10/20
*/
@Data
public class DeleteBaseDieselGeneratorInput {
@XText("ID")
private String id;
}
......@@ -2,9 +2,16 @@ package pps.core.base.service.data.base_diesel_generator;
import lombok.Data;
import xstartup.annotation.XText;
/**
* 柴发设备
*
* @author ZWT
* @date 2023/10/20
*/
@Data
public class GetBaseDieselGeneratorInput {
@XText("ID")
private String id;
}
package pps.core.base.service.data.base_diesel_generator;
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 UpdateBaseDieselGeneratorInput {
@XText("ID")
@NotBlank(message = "缺少设备ID")
private String id;
@XText("组织机构ID")
@NotBlank(message = "缺少组织机构ID")
private String ouId;
@XText("组织机构name")
private String ouName;
@XText("设备名称")
@NotBlank(message = "缺少设备名称")
private String deviceName;
@XText("出厂编号")
@NotBlank(message = "缺少出厂编号")
private String makerNumber;
@XText("柴发设备机组型号key(字典获取)")
......@@ -28,9 +42,10 @@ public class UpdateBaseDieselGeneratorInput {
private String unitTypeName;
@XText("常用功率(KW)")
@NotNull(message = "缺少常用功率")
private BigDecimal normalPower;
@XText("备用功率(KW)")
@NotNull(message = "缺少备用功率")
private BigDecimal standbyPower;
}
package pps.core.base.service.data.base_energy_storage_device;
import com.baomidou.mybatisplus.annotation.TableField;
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 CreateBaseEnergyStorageDeviceInput {
@XText("组织机构ID")
@NotBlank(message = "缺少组织机构ID")
private String ouId;
@XText("组织机构name")
private String ouName;
@XText("设备名称")
@NotBlank(message = "缺少设备名称")
private String deviceName;
@XText("出厂编号")
@NotBlank(message = "缺少出厂编号")
private String makerNumber;
@XText("储能设备规格型号key(字典获取)")
......@@ -27,20 +38,22 @@ public class CreateBaseEnergyStorageDeviceInput {
private String storageModelName;
@XText("设备容量(KWh)")
@NotNull(message = "缺少设备容量")
private BigDecimal apparatusCapacity;
@XText("额定放电功率(KW)")
@NotNull(message = "缺少额定放电功率")
private BigDecimal ratedDischargePower;
@XText("额定充电功率(KW)")
@NotNull(message = "缺少额定充电功率")
private BigDecimal ratedChargingPower;
@XText("额定放电深度")
@TableField
@NotNull(message = "缺少额定放电深度")
private BigDecimal ratedDischargeDepth;
@XText("额定放电效率")
@TableField
@NotNull(message = "缺少额定放电效率")
private BigDecimal ratedDischargeEfficiency;
}
......@@ -2,8 +2,16 @@ package pps.core.base.service.data.base_energy_storage_device;
import lombok.Data;
import xstartup.annotation.XText;
/**
* 储能设备
*
* @author ZWT
* @date 2023/10/20
*/
@Data
public class DeleteBaseEnergyStorageDeviceInput {
@XText("ID")
private String id;
}
......@@ -2,8 +2,16 @@ package pps.core.base.service.data.base_energy_storage_device;
import lombok.Data;
import xstartup.annotation.XText;
/**
* 储能设备
*
* @author ZWT
* @date 2023/10/20
*/
@Data
public class GetBaseEnergyStorageDeviceInput {
@XText("ID")
private String id;
}
package pps.core.base.service.data.base_energy_storage_device;
import com.baomidou.mybatisplus.annotation.TableField;
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 UpdateBaseEnergyStorageDeviceInput {
@XText("ID")
@NotBlank(message = "缺少设备ID")
private String id;
@XText("组织机构ID")
@NotBlank(message = "缺少组织机构ID")
private String ouId;
@XText("组织机构name")
private String ouName;
@XText("设备名称")
@NotBlank(message = "缺少设备名称")
private String deviceName;
@XText("出厂编号")
@NotBlank(message = "缺少出厂编号")
private String makerNumber;
@XText("储能设备规格型号key(字典获取)")
......@@ -29,20 +42,22 @@ public class UpdateBaseEnergyStorageDeviceInput {
private String storageModelName;
@XText("设备容量(KWh)")
@NotNull(message = "缺少设备容量")
private BigDecimal apparatusCapacity;
@XText("额定放电功率(KW)")
@NotNull(message = "缺少额定放电功率")
private BigDecimal ratedDischargePower;
@XText("额定充电功率(KW)")
@NotNull(message = "缺少额定充电功率")
private BigDecimal ratedChargingPower;
@XText("额定放电深度")
@TableField
@NotNull(message = "缺少额定放电深度")
private BigDecimal ratedDischargeDepth;
@XText("额定放电效率")
@TableField
@NotNull(message = "缺少额定放电效率")
private BigDecimal ratedDischargeEfficiency;
}
package pps.core.base.service.data.base_photovoltaic_plant;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import xstartup.annotation.XText;
......@@ -15,9 +17,14 @@ import java.math.BigDecimal;
public class CreateBasePhotovoltaicPlantInput {
@XText("组织机构ID")
@NotBlank(message = "缺少组织机构ID")
private String ouId;
@XText("组织机构name")
private String ouName;
@XText("电站名称")
@NotBlank(message = "缺少电站名称")
private String stationName;
@XText("出厂编号")
......@@ -26,30 +33,34 @@ public class CreateBasePhotovoltaicPlantInput {
@XText("光伏设备规格型号key(字典获取)")
private String photovoltaicModelKey;
@XText("光伏设备规格型号name(字典获取)")
private String photovoltaicModelName;
@XText("安装倾角")
@NotNull(message = "缺少安装倾角")
private BigDecimal mountingAngle;
@XText("装机总量(KWP)")
@NotNull(message = "缺少装机总量")
private BigDecimal totalPower;
@XText("阵列朝向")
@NotNull(message = "缺少阵列朝向")
private BigDecimal arrayOrientation;
@XText("组织机构name")
private String ouName;
@XText("光伏设备规格型号name(字典获取)")
private String photovoltaicModelName;
@XText("经度(°)")
@NotNull(message = "缺少经度")
private BigDecimal longitude;
@XText("纬度(°)")
@NotNull(message = "缺少纬度")
private BigDecimal latitude;
@XText("高程(m)")
@NotNull(message = "缺少高程")
private BigDecimal elevation;
@XText("地区编码")
@NotNull(message = "缺少地区编码")
private Integer areaCode;
}
package pps.core.base.service.data.base_photovoltaic_plant;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import xstartup.annotation.XText;
......@@ -15,12 +17,18 @@ import java.math.BigDecimal;
public class UpdateBasePhotovoltaicPlantInput {
@XText("ID")
@NotBlank(message = "缺少电站ID")
private String id;
@XText("组织机构ID")
@NotBlank(message = "缺少组织机构ID")
private String ouId;
@XText("组织机构name")
private String ouName;
@XText("电站名称")
@NotBlank(message = "缺少电站名称")
private String stationName;
@XText("出厂编号")
......@@ -29,30 +37,34 @@ public class UpdateBasePhotovoltaicPlantInput {
@XText("光伏设备规格型号key(字典获取)")
private String photovoltaicModelKey;
@XText("光伏设备规格型号name(字典获取)")
private String photovoltaicModelName;
@XText("安装倾角")
@NotNull(message = "缺少安装倾角")
private BigDecimal mountingAngle;
@XText("装机总量(KWP)")
@NotNull(message = "缺少装机总量")
private BigDecimal totalPower;
@XText("阵列朝向")
@NotNull(message = "缺少阵列朝向")
private BigDecimal arrayOrientation;
@XText("组织机构name")
private String ouName;
@XText("光伏设备规格型号name(字典获取)")
private String photovoltaicModelName;
@XText("经度(°)")
@NotNull(message = "缺少经度")
private BigDecimal longitude;
@XText("纬度(°)")
@NotNull(message = "缺少纬度")
private BigDecimal latitude;
@XText("高程(m)")
@NotNull(message = "缺少高程")
private BigDecimal elevation;
@XText("地区编码")
@NotNull(message = "缺少地区编码")
private Integer areaCode;
}
\ No newline at end of file
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;
}
}
package pps.core.base.service.data.base_wellhead;
import lombok.Data;
import xstartup.annotation.XText;
/**
* 井口配置
*
* @author ZWT
* @date 2023/10/20
*/
@Data
public class DeleteBaseWellheadInput {
@XText("ID")
private String id;
public String getId() {
return this.id;
}
public void setId(String value) {
this.id = value;
}
}
package pps.core.base.service.data.base_wellhead;
import lombok.Data;
import xstartup.annotation.XText;
/**
* 井口配置
*
* @author ZWT
* @date 2023/10/20
*/
@Data
public class GetBaseWellheadInput {
@XText("ID")
private String id;
public String getId() {
return this.id;
}
public void setId(String value) {
this.id = value;
}
}
......@@ -8,7 +8,7 @@ import xstartup.base.data.XPageInput;
import java.math.BigDecimal;
/**
* 井口
* 井口配置
*
* @author ZWT
* @date 2023/09/25
......
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 UpdateBaseWellheadInput {
@XText("ID")
@NotBlank(message = "缺少井口ID")
private String id;
@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 getId() {
return this.id;
}
public void setId(String value) {
this.id = value;
}
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;
}
}
......@@ -332,8 +332,11 @@ public class SpaceCalibrationService {
private SpaceCalibrationPeriodEnt getPeriodEntByParam(SpaceCalibrationPeriodMapper mapper, String lineId, String ouId) {
return mapper.selectOne(
new LambdaQueryWrapper<SpaceCalibrationPeriodEnt>()
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.eq(SpaceCalibrationPeriodEnt::getLineId, lineId)
.eq(SpaceCalibrationPeriodEnt::getOuId, ouId)
.orderByDesc(BaseModel::getModifyTime)
.last("LIMIT 1")
);
}
......
......@@ -102,7 +102,7 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
}
Integer isCurrentBasic = entity.getIsCurrentBasic();
if (isCurrentBasic.equals(0)) {
return XServiceResult.error(992, "基础制度无法修改");
return XServiceResult.error(context, BusinessError.CannotBeDeleted);
}
PpsUserSession session = context.getSession(PpsUserSession.class);
this.updateInstitutionDetail(context, session, mapper, institutionId, input, entity);
......@@ -290,20 +290,20 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
@XApiPost
@XText("基础间开配置--设为基础制度")
public XServiceResult updateBasicInstitution(XContext context, UpdateSpaceInstitutionDetailInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
String ouId = input.getOuId();
String lineId = input.getLineId();
String institutionId = input.getId();
SpaceInstitutionDetailMapper mapper = context.getBean(SpaceInstitutionDetailMapper.class);
SpaceInstitutionDetailEnt detail = this.getInstitutionDetail(mapper, institutionId);
if (Objects.isNull(detail)) {
return XServiceResult.error(context, XError.NotFound);
}
Integer isCurrentBasic = detail.getIsCurrentBasic();
if (isCurrentBasic.equals(BusinessConstant.ZERO)) {
return XServiceResult.error(context, BusinessError.RepeatSetting);
}
PpsUserSession session = context.getSession(PpsUserSession.class);
return XTransactionHelper.begin(context, () -> {
SpaceInstitutionDetailMapper mapper = context.getBean(SpaceInstitutionDetailMapper.class);
SpaceInstitutionDetailEnt detail = this.getInstitutionDetail(mapper, institutionId);
if (Objects.isNull(detail)) {
return XServiceResult.error(context, XError.NotFound);
}
Integer isCurrentBasic = detail.getIsCurrentBasic();
if (isCurrentBasic.equals(BusinessConstant.ZERO)) {
return XServiceResult.error(context, BusinessError.RepeatSetting);
}
//关闭当前基础制度
mapper.update(null, new LambdaUpdateWrapper<SpaceInstitutionDetailEnt>()
.eq(SpaceInstitutionDetailEnt::getOuId, ouId)
......@@ -324,6 +324,8 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
);
//长期/中短期制度优化初始化
this.institutionOptimizeInitialize(context, detail);
//校准周期初始化
this.calibrationHistoryInitialize(context, detail, session);
return XServiceResult.OK;
});
}
......@@ -343,7 +345,6 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
if (StringUtils.isEmpty(historyId)) {
return XServiceResult.error(context, BusinessError.LackOfHistoryRecord);
}
PpsUserSession session = context.getSession(PpsUserSession.class);
String institutionId = input.getId();
SpaceInstitutionDetailMapper mapper = context.getBean(SpaceInstitutionDetailMapper.class);
SpaceInstitutionDetailEnt detail = this.getInstitutionDetail(mapper, institutionId);
......@@ -358,10 +359,13 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
if (DateUtil.date().compareTo(calibrationDate) > 0) {
return XServiceResult.error(context, BusinessError.Expired);
}
PpsUserSession session = context.getSession(PpsUserSession.class);
return XTransactionHelper.begin(context, () -> {
this.updateInstitutionDetail(context, session, mapper, institutionId, input, detail);
//制度优化
this.institutionOptimizeInitialize(context, detail);
//校准周期初始化
this.calibrationHistoryInitialize(context, detail, session);
return XServiceResult.OK;
});
}
......@@ -583,6 +587,67 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
}
}
/**
* 校准周期初始化
*
* @param context 上下文
* @param detail 细节
*/
private void calibrationHistoryInitialize(XContext context, SpaceInstitutionDetailEnt detail, PpsUserSession session) {
//查最近的校准历史
SpaceCalibrationHistoryMapper mapper = context.getBean(SpaceCalibrationHistoryMapper.class);
SpaceCalibrationHistoryEnt historyEnt = mapper.selectOne(new LambdaQueryWrapper<SpaceCalibrationHistoryEnt>()
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.eq(SpaceCalibrationHistoryEnt::getInstitutionId, detail.getId())
.orderByDesc(SpaceCalibrationHistoryEnt::getCalibrationDate)
.last("LIMIT 1")
);
DateTime now = DateUtil.beginOfDay(DateUtil.date());
boolean isCreate = false;
if (Objects.nonNull(historyEnt)) {
//判断当前时间是否大于等于校准日期
Date calibrationDate = historyEnt.getCalibrationDate();
if (DateUtil.compare(now, calibrationDate) >= 0) {
isCreate = true;
}
} else {
isCreate = true;
}
//新增
if (isCreate) {
//查周期配置
SpaceCalibrationPeriodMapper periodMapper = context.getBean(SpaceCalibrationPeriodMapper.class);
SpaceCalibrationPeriodEnt periodEnt = periodMapper.selectOne(new LambdaQueryWrapper<SpaceCalibrationPeriodEnt>()
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.eq(SpaceCalibrationPeriodEnt::getLineId, detail.getLineId())
.eq(SpaceCalibrationPeriodEnt::getOuId, detail.getOuId())
.orderByDesc(BaseModel::getModifyTime)
.last("LIMIT 1")
);
if (Objects.nonNull(periodEnt)) {
mapper.insert(this.createCalibrationHistory(session, detail, now, Integer.valueOf(periodEnt.getDayNumber())));
}
}
}
/**
* 创建校准历史记录
*
* @param detail 细节
* @param date 日期
* @param dayNumber 天数
* @return {@link SpaceCalibrationHistoryEnt}
*/
private SpaceCalibrationHistoryEnt createCalibrationHistory(PpsUserSession session, SpaceInstitutionDetailEnt detail, Date date, Integer dayNumber) {
SpaceCalibrationHistoryEnt historyEnt = new SpaceCalibrationHistoryEnt();
BaseUtils.setBaseModelDefault(historyEnt, session);
historyEnt.setLineId(detail.getLineId());
historyEnt.setInstitutionId(detail.getId());
historyEnt.setExecutionCycle(BaseUtils.getExecutionCycleForCalibration(date, dayNumber));
historyEnt.setCalibrationDate(DateUtil.beginOfDay(DateUtil.offsetDay(date, dayNumber + 1)));
return historyEnt;
}
/**
* 条件查询输电线路井口列表
*
......@@ -658,17 +723,17 @@ public class SpaceInstitutionDetailService extends SpaceOptimizeBaseService {
*/
private void updateInstitutionDetail(XContext context, PpsUserSession session, SpaceInstitutionDetailMapper mapper, String institutionId,
UpdateSpaceInstitutionDetailInput input, SpaceInstitutionDetailEnt entity) {
//删除之前关联的信息
SpaceInstitutionWellheadMapper wellheadMapper = context.getBean(SpaceInstitutionWellheadMapper.class);
wellheadMapper.delete(new LambdaQueryWrapper<SpaceInstitutionWellheadEnt>()
.eq(SpaceInstitutionWellheadEnt::getInstitutionId, institutionId)
);
SpaceInstitutionDurationMapper durationMapper = context.getBean(SpaceInstitutionDurationMapper.class);
durationMapper.delete(new LambdaQueryWrapper<SpaceInstitutionDurationEnt>()
.eq(SpaceInstitutionDurationEnt::getInstitutionId, institutionId)
);
List<UpdateSpaceInstitutionWellheadInput> wellheadList = input.getWellheadList();
if (CollUtil.isNotEmpty(wellheadList)) {
//删除之前关联的信息
SpaceInstitutionWellheadMapper wellheadMapper = context.getBean(SpaceInstitutionWellheadMapper.class);
wellheadMapper.delete(new LambdaQueryWrapper<SpaceInstitutionWellheadEnt>()
.eq(SpaceInstitutionWellheadEnt::getInstitutionId, institutionId)
);
SpaceInstitutionDurationMapper durationMapper = context.getBean(SpaceInstitutionDurationMapper.class);
durationMapper.delete(new LambdaQueryWrapper<SpaceInstitutionDurationEnt>()
.eq(SpaceInstitutionDurationEnt::getInstitutionId, institutionId)
);
//重新添加关联信息
this.saveInstitutionWellhead(context, session, institutionId, wellheadList);
}
......
......@@ -97,17 +97,12 @@ public class SpaceOptimizeBaseService {
throw new XServiceException(BusinessError.DidNotFindWellhead);
}
this.setServiceRatingForSpaceWellheadList(context, spaceWellheadList);
//取线路关联的所有光伏电站ID
List<DynamicQueryBasePowerLinePlantOutput> plantList = this.getPowerLinePlantListByLineIds(context, lineIds);
if (CollUtil.isEmpty(plantList)) {
//未发现可用光伏电站
throw new XServiceException(BusinessError.DidNotFindPlant);
}
return SpaceOptimizeLineRelation.builder()
.wellheadsByInstitutionIdIdMap(spaceWellheadList.stream()
.collect(Collectors.groupingBy(SpaceInstitutionWellheadView::getInstitutionId)))
.plantIdsByLineIdMap(
plantList.stream()
//取线路关联的所有光伏电站ID
this.getPowerLinePlantListByLineIds(context, lineIds).stream()
.collect(
Collectors.groupingBy(DynamicQueryBasePowerLinePlantOutput::getLineId,
Collectors.mapping(DynamicQueryBasePowerLinePlantOutput::getPlantId, Collectors.toList()))
......@@ -183,8 +178,10 @@ public class SpaceOptimizeBaseService {
//光伏出力峰值>=线路哪部分井口运行功率:满足的部分井口采用绿电消纳优先,不满足的井采用消峰平谷
else {
List<SpaceInstitutionWellheadView> highWellheadList = collect.get(true);
this.greenElectricityConsumptionStrategy(wellheadDTOList, unOptimizeDurationList, durationDTOList,
highWellheadList, avgPowerList, durationMap, detail, periodId);
if (CollUtil.isNotEmpty(highWellheadList)) {
this.greenElectricityConsumptionStrategy(wellheadDTOList, unOptimizeDurationList, durationDTOList,
highWellheadList, avgPowerList, durationMap, detail, periodId);
}
this.peakEliminationAndValleyLevelingStrategy(context, wellheadDTOList, unOptimizeDurationList, durationDTOList,
lowWellheadList, durationMap, detail, monthNum, periodId);
}
......@@ -288,11 +285,20 @@ public class SpaceOptimizeBaseService {
}
}
DynamicQueryPlantPredictedPowerOutput start = avgPowerList.get(firstIndex);
DateTime startTimeOptimize = DateUtil.date(start.getCreateTime());
firstStartTime = startTimeOptimize;
//计算第一次关井时间,按照间开时间段顺延
int startDuration = (int) startTime.between(endTime, DateUnit.MINUTE);
DateTime endTimeOptimize = startTimeOptimize.offsetNew(DateField.MINUTE, startDuration);
DateTime startTimeOptimize;
DateTime endTimeOptimize;
//判断发电量是否为正数
if (start.getPower().compareTo(BigDecimal.ZERO) > 0) {
startTimeOptimize = DateUtil.date(start.getCreateTime());
firstStartTime = startTimeOptimize;
//计算第一次关井时间,按照间开时间段顺延
int startDuration = (int) startTime.between(endTime, DateUnit.MINUTE);
endTimeOptimize = startTimeOptimize.offsetNew(DateField.MINUTE, startDuration);
} else {
startTimeOptimize = startTime;
firstStartTime = startTime;
endTimeOptimize = endTime;
}
this.createDurationOffGridPeriod(offGridPeriodList, wellheadId, startTimeOptimize, endTimeOptimize);
//计算时间偏移,取时间间隔(分钟)
between = BaseUtils.getTimeDifferenceMinute(startTimeOptimize, startTime);
......@@ -312,18 +318,22 @@ public class SpaceOptimizeBaseService {
}
}
}
DateTime startTimeOptimize;
DateTime endTimeOptimize;
//计算未优化启动间隔
int openDuration = (int) startTime.between(endTime, DateUnit.MINUTE);
if (startIndex > -1) {
DynamicQueryPlantPredictedPowerOutput start = avgPowerList.get(startIndex);
DateTime startTimeOptimize = DateUtil.date(start.getCreateTime());
//计算未优化启动间隔
int openDuration = (int) startTime.between(endTime, DateUnit.MINUTE);
DateTime endTimeOptimize = startTimeOptimize.offsetNew(DateField.MINUTE, openDuration);
this.createDurationOffGridPeriod(offGridPeriodList, wellheadId, startTimeOptimize, endTimeOptimize);
//取时间间隔(分钟)
between = BaseUtils.getTimeDifferenceMinute(endTimeOptimize, endTime);
startTimeOptimize = DateUtil.date(start.getCreateTime());
endTimeOptimize = startTimeOptimize.offsetNew(DateField.MINUTE, openDuration);
} else {
//无法优化
endTimeOptimize = startTimeOffset.offsetNew(DateField.MINUTE, openDuration);
startTimeOptimize = startTimeOffset;
}
this.createDurationOffGridPeriod(offGridPeriodList, wellheadId, startTimeOptimize, endTimeOptimize);
//取时间间隔(分钟)
between = BaseUtils.getTimeDifferenceMinute(endTimeOptimize, endTime);
}
} else {
DateTime offset = startTime.offsetNew(DateField.MINUTE, between);
......@@ -406,7 +416,7 @@ public class SpaceOptimizeBaseService {
DynamicQueryPlantPredictedPowerOutput avg = subAvgPowerList.get(i);
DateTime createTime = DateUtil.date(avg.getCreateTime());
//计算时间范围:大于等于开始时间,小于等于结束时间
if (createTime.compareTo(openTime) >= 0 && createTime.compareTo(closeTime) <= 0) {
if (createTime.compareTo(openTime) >= 0 && createTime.compareTo(closeTime) < 0) {
String endString = createTime.offsetNew(DateField.MINUTE, 15).toString(BusinessConstant.MINUTES_FORMAT);
String startString = createTime.toString(BusinessConstant.MINUTES_FORMAT);
if (StringUtils.equals(endString, BusinessConstant.START_OF_DAY_TIME)) {
......@@ -485,7 +495,7 @@ public class SpaceOptimizeBaseService {
temporarilyList.add(durationDTO);
if (i == size - 1) {
SpaceOptimizeDurationDTO begin = temporarilyList.get(0);
begin.setCloseWellTime(end.getCloseWellTime());
begin.setCloseWellTime(durationDTO.getCloseWellTime());
finallyList.add(begin);
}
}
......@@ -763,35 +773,16 @@ public class SpaceOptimizeBaseService {
List<SpaceOptimizeDurationDTO> durationDTOList, List<SpaceInstitutionWellheadView> wellheadViewList,
Map<String, List<SpaceInstitutionDurationEnt>> durationMap, SpaceInstitutionDetailEnt detail,
int monthNum, String periodId) {
//通过线路ID和月份获取市电峰谷策略明细配置
List<GetBasePriceStrategyDetailOutput> strategyDetailList = ServiceUtil.getStrategyDetailList(context,
GetBasePriceStrategyDetailInput.builder()
.lineId(detail.getLineId())
.strategyMonth(String.valueOf(monthNum))
.build()
);
if (CollUtil.isEmpty(strategyDetailList)) {
//没有配置,不优化
return;
}
//获取第一段谷电阶段的开始时间为第一口井的开井时间
Optional<GetBasePriceStrategyDetailOutput> low = strategyDetailList.stream()
.filter(s -> !StringUtils.isAnyBlank(s.getEndTime(), s.getStartTime()) && StringUtils.equals("LOW", s.getPeriodTypeKey()))
.findFirst();
if (!low.isPresent()) {
//没有谷电,不优化
return;
}
GetBasePriceStrategyDetailOutput strategyDetailOutput = low.get();
//第一口井启动时间
DateTime firstStartTime = DateUtil.parse(strategyDetailOutput.getStartTime() + BusinessConstant.INITIALIZATION_SECOND, BusinessConstant.TIME_FORMAT);
DateTime firstEndTime = DateUtil.parse(strategyDetailOutput.getEndTime() + BusinessConstant.INITIALIZATION_SECOND, BusinessConstant.TIME_FORMAT);
//判断是否第一口井
boolean isFirstWellhead;
//时间差
int between = 0;
//启动间隔累积
int startInterval = 0;
//第一口井启动时间
DateTime firstStartTime = null;
//第一口井结束时间
DateTime firstEndTime = null;
for (int w = 0, wellheadSize = wellheadViewList.size(); w < wellheadSize; w++) {
SpaceInstitutionWellheadView wellhead = wellheadViewList.get(w);
String wellheadId = wellhead.getWellheadId();
......@@ -821,12 +812,43 @@ public class SpaceOptimizeBaseService {
if (d == 0) {
//第一口井的启动时间
if (isFirstWellhead) {
String startTimeString;
//通过线路ID和月份获取市电峰谷策略明细配置
List<GetBasePriceStrategyDetailOutput> strategyDetailList = ServiceUtil.getStrategyDetailList(context,
GetBasePriceStrategyDetailInput.builder()
.lineId(detail.getLineId())
.strategyMonth(String.valueOf(monthNum))
.build()
);
if (CollUtil.isNotEmpty(strategyDetailList)) {
//获取第一段谷电阶段的开始时间为第一口井的开井时间
Optional<GetBasePriceStrategyDetailOutput> low = strategyDetailList.stream()
.filter(s -> !StringUtils.isAnyBlank(s.getEndTime(), s.getStartTime()) && StringUtils.equals("LOW", s.getPeriodTypeKey()))
.findFirst();
if (low.isPresent()) {
GetBasePriceStrategyDetailOutput strategyDetailOutput = low.get();
//第一口井启动时间
firstStartTime = DateUtil.parse(strategyDetailOutput.getStartTime() + BusinessConstant.INITIALIZATION_SECOND, BusinessConstant.TIME_FORMAT);
firstEndTime = DateUtil.parse(strategyDetailOutput.getEndTime() + BusinessConstant.INITIALIZATION_SECOND, BusinessConstant.TIME_FORMAT);
startTimeString = strategyDetailOutput.getStartTime();
} else {
//没有谷电,不优化
firstStartTime = startTime;
firstEndTime = endTime;
startTimeString = duration.getOpenWellTime();
}
} else {
//没有配置,不优化
firstStartTime = startTime;
firstEndTime = endTime;
startTimeString = duration.getOpenWellTime();
}
//计算优化后的时间差优化后的第一口井开井时间-优化前第一次开井时间
int startDuration = (int) startTime.between(endTime, DateUnit.MINUTE);
//第一次关井时间按照启动时长顺延
DateTime endTimeOptimize = firstStartTime.offsetNew(DateField.MINUTE, startDuration);
this.createOptimizeDuration(durationDTOList, periodId, recordId, wellheadId, null,
strategyDetailOutput.getStartTime(), endTimeOptimize.toString(BusinessConstant.MINUTES_FORMAT)
startTimeString, endTimeOptimize.toString(BusinessConstant.MINUTES_FORMAT)
);
//取时间间隔(分钟)
between = BaseUtils.getTimeDifferenceMinute(endTimeOptimize, endTime);
......
......@@ -57,6 +57,8 @@
FROM space_institution_detail d
JOIN space_calibration_history h ON d.id = h.institution_id
WHERE h.is_deleted = 1
AND d.is_deleted = 1
AND d.is_current_basic = 0
AND h.line_id = #{lineId}
ORDER BY h.calibration_date DESC
</select>
......
......@@ -44,54 +44,56 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower
String endTime = input.getEndTime();
Integer dateType = input.getDateType();
List list = null;
switch (dateType) {
case 0:
PlantPredictedPowerLongTermDataMapper longTermDataMapper = context.getBean(PlantPredictedPowerLongTermDataMapper.class);
list = longTermDataMapper.selectList(
new QueryWrapper<PlantPredictedPowerLongTermDataEnt>()
.select("year_time",
"month_time",
"hour_time",
"min_time",
"IFNULL( AVG( power ), 0 ) AS power",
"STR_TO_DATE( CONCAT( hour_time, ':', min_time ), '%H:%i:%s' ) AS create_time")
.lambda()
.eq(StringUtils.isNotBlank(plantId), PlantPredictedPowerLongTermDataEnt::getPlantId, plantId)
.in(CollUtil.isNotEmpty(plantIds), PlantPredictedPowerLongTermDataEnt::getPlantId, plantIds)
.eq(StringUtils.isNotBlank(yearTime), PlantPredictedPowerLongTermDataEnt::getYearTime, yearTime)
.eq(StringUtils.isNotBlank(monthTime), PlantPredictedPowerLongTermDataEnt::getMonthTime, monthTime)
.between(!StringUtils.isAnyBlank(startTime, endTime), PlantPredictedPowerLongTermDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerLongTermDataEnt::getYearTime,
PlantPredictedPowerLongTermDataEnt::getMonthTime,
PlantPredictedPowerLongTermDataEnt::getHourTime,
PlantPredictedPowerLongTermDataEnt::getMinTime)
.orderByAsc(PlantPredictedPowerLongTermDataEnt::getHourTime)
);
break;
case 1:
PlantPredictedPowerDataMapper mapper = context.getBean(PlantPredictedPowerDataMapper.class);
list = mapper.selectList(
new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("year_time",
"month_time",
"hour_time",
"min_time",
"IFNULL( AVG( power ), 0 ) AS power",
"STR_TO_DATE( CONCAT( hour_time, ':', min_time ), '%H:%i:%s' ) AS create_time")
.lambda()
.eq(StringUtils.isNotBlank(plantId), PlantPredictedPowerDataEnt::getPlantId, plantId)
.in(CollUtil.isNotEmpty(plantIds), PlantPredictedPowerDataEnt::getPlantId, plantIds)
.eq(StringUtils.isNotBlank(yearTime), PlantPredictedPowerDataEnt::getYearTime, yearTime)
.eq(StringUtils.isNotBlank(monthTime), PlantPredictedPowerDataEnt::getMonthTime, monthTime)
.between(!StringUtils.isAnyBlank(startTime, endTime), PlantPredictedPowerDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerDataEnt::getYearTime,
PlantPredictedPowerDataEnt::getMonthTime,
PlantPredictedPowerDataEnt::getHourTime,
PlantPredictedPowerDataEnt::getMinTime)
.orderByAsc(PlantPredictedPowerDataEnt::getHourTime)
);
break;
default:
if (CollUtil.isNotEmpty(plantIds)) {
switch (dateType) {
case 0:
PlantPredictedPowerLongTermDataMapper longTermDataMapper = context.getBean(PlantPredictedPowerLongTermDataMapper.class);
list = longTermDataMapper.selectList(
new QueryWrapper<PlantPredictedPowerLongTermDataEnt>()
.select("year_time",
"month_time",
"hour_time",
"min_time",
"IFNULL( AVG( power ), 0 ) AS power",
"STR_TO_DATE( CONCAT( hour_time, ':', min_time ), '%H:%i:%s' ) AS create_time")
.lambda()
.eq(StringUtils.isNotBlank(plantId), PlantPredictedPowerLongTermDataEnt::getPlantId, plantId)
.in(PlantPredictedPowerLongTermDataEnt::getPlantId, plantIds)
.eq(StringUtils.isNotBlank(yearTime), PlantPredictedPowerLongTermDataEnt::getYearTime, yearTime)
.eq(StringUtils.isNotBlank(monthTime), PlantPredictedPowerLongTermDataEnt::getMonthTime, monthTime)
.between(!StringUtils.isAnyBlank(startTime, endTime), PlantPredictedPowerLongTermDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerLongTermDataEnt::getYearTime,
PlantPredictedPowerLongTermDataEnt::getMonthTime,
PlantPredictedPowerLongTermDataEnt::getHourTime,
PlantPredictedPowerLongTermDataEnt::getMinTime)
.orderByAsc(PlantPredictedPowerLongTermDataEnt::getHourTime, PlantPredictedPowerLongTermDataEnt::getMinTime)
);
break;
case 1:
PlantPredictedPowerDataMapper mapper = context.getBean(PlantPredictedPowerDataMapper.class);
list = mapper.selectList(
new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("year_time",
"month_time",
"hour_time",
"min_time",
"IFNULL( AVG( power ), 0 ) AS power",
"STR_TO_DATE( CONCAT( hour_time, ':', min_time ), '%H:%i:%s' ) AS create_time")
.lambda()
.eq(StringUtils.isNotBlank(plantId), PlantPredictedPowerDataEnt::getPlantId, plantId)
.in(PlantPredictedPowerDataEnt::getPlantId, plantIds)
.eq(StringUtils.isNotBlank(yearTime), PlantPredictedPowerDataEnt::getYearTime, yearTime)
.eq(StringUtils.isNotBlank(monthTime), PlantPredictedPowerDataEnt::getMonthTime, monthTime)
.between(!StringUtils.isAnyBlank(startTime, endTime), PlantPredictedPowerDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerDataEnt::getYearTime,
PlantPredictedPowerDataEnt::getMonthTime,
PlantPredictedPowerDataEnt::getHourTime,
PlantPredictedPowerDataEnt::getMinTime)
.orderByAsc(PlantPredictedPowerDataEnt::getHourTime, PlantPredictedPowerDataEnt::getMinTime)
);
break;
default:
}
}
List<DynamicQueryPlantPredictedPowerOutput> outputs;
if (CollUtil.isEmpty(list)) {
......@@ -119,40 +121,42 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower
String endTime = input.getEndTime();
Integer dateType = input.getDateType();
List list = null;
switch (dateType) {
case 0:
PlantPredictedPowerLongTermDataMapper longTermDataMapper = context.getBean(PlantPredictedPowerLongTermDataMapper.class);
list = longTermDataMapper.selectList(
new QueryWrapper<PlantPredictedPowerLongTermDataEnt>()
.select("hour_time",
"IFNULL( AVG( power ), 0 ) AS power")
.lambda()
.eq(StringUtils.isNotBlank(plantId), PlantPredictedPowerLongTermDataEnt::getPlantId, plantId)
.in(CollUtil.isNotEmpty(plantIds), PlantPredictedPowerLongTermDataEnt::getPlantId, plantIds)
.eq(StringUtils.isNotBlank(yearTime), PlantPredictedPowerLongTermDataEnt::getYearTime, yearTime)
.eq(StringUtils.isNotBlank(monthTime), PlantPredictedPowerLongTermDataEnt::getMonthTime, monthTime)
.between(!StringUtils.isAnyBlank(startTime, endTime), PlantPredictedPowerLongTermDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerLongTermDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerLongTermDataEnt::getHourTime)
);
break;
case 1:
PlantPredictedPowerDataMapper mapper = context.getBean(PlantPredictedPowerDataMapper.class);
list = mapper.selectList(
new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("hour_time",
"IFNULL( AVG( power ), 0 ) AS power")
.lambda()
.eq(StringUtils.isNotBlank(plantId), PlantPredictedPowerDataEnt::getPlantId, plantId)
.in(CollUtil.isNotEmpty(plantIds), PlantPredictedPowerDataEnt::getPlantId, plantIds)
.eq(StringUtils.isNotBlank(yearTime), PlantPredictedPowerDataEnt::getYearTime, yearTime)
.eq(StringUtils.isNotBlank(monthTime), PlantPredictedPowerDataEnt::getMonthTime, monthTime)
.between(!StringUtils.isAnyBlank(startTime, endTime), PlantPredictedPowerDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerDataEnt::getHourTime)
);
break;
default:
if (CollUtil.isNotEmpty(plantIds)) {
switch (dateType) {
case 0:
PlantPredictedPowerLongTermDataMapper longTermDataMapper = context.getBean(PlantPredictedPowerLongTermDataMapper.class);
list = longTermDataMapper.selectList(
new QueryWrapper<PlantPredictedPowerLongTermDataEnt>()
.select("hour_time",
"IFNULL( AVG( power ), 0 ) AS power")
.lambda()
.eq(StringUtils.isNotBlank(plantId), PlantPredictedPowerLongTermDataEnt::getPlantId, plantId)
.in(PlantPredictedPowerLongTermDataEnt::getPlantId, plantIds)
.eq(StringUtils.isNotBlank(yearTime), PlantPredictedPowerLongTermDataEnt::getYearTime, yearTime)
.eq(StringUtils.isNotBlank(monthTime), PlantPredictedPowerLongTermDataEnt::getMonthTime, monthTime)
.between(!StringUtils.isAnyBlank(startTime, endTime), PlantPredictedPowerLongTermDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerLongTermDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerLongTermDataEnt::getHourTime)
);
break;
case 1:
PlantPredictedPowerDataMapper mapper = context.getBean(PlantPredictedPowerDataMapper.class);
list = mapper.selectList(
new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("hour_time",
"IFNULL( AVG( power ), 0 ) AS power")
.lambda()
.eq(StringUtils.isNotBlank(plantId), PlantPredictedPowerDataEnt::getPlantId, plantId)
.in(PlantPredictedPowerDataEnt::getPlantId, plantIds)
.eq(StringUtils.isNotBlank(yearTime), PlantPredictedPowerDataEnt::getYearTime, yearTime)
.eq(StringUtils.isNotBlank(monthTime), PlantPredictedPowerDataEnt::getMonthTime, monthTime)
.between(!StringUtils.isAnyBlank(startTime, endTime), PlantPredictedPowerDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerDataEnt::getHourTime)
);
break;
default:
}
}
List<DynamicQueryPlantPredictedPowerOutput> outputs;
if (CollUtil.isEmpty(list)) {
......
......@@ -59,6 +59,7 @@ public class StoragePredictedPowerCloudServiceImpl implements IStoragePredictedP
StoragePredictedPowerDataEnt::getMonthTime,
StoragePredictedPowerDataEnt::getHourTime,
StoragePredictedPowerDataEnt::getMinTime)
.orderByAsc(StoragePredictedPowerDataEnt::getHourTime, StoragePredictedPowerDataEnt::getMinTime)
);
List<DynamicQueryStoragePredictedPowerOutput> outputs;
if (CollUtil.isEmpty(list)) {
......
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