Commit d0f4db97 authored by ZWT's avatar ZWT

得到的

parent 8d95f85a
......@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.core.base.entity.BaseDataEnt;
import pps.core.base.entity.BaseDataImportLogEnt;
import pps.core.base.entity.BaseModelValEnt;
import pps.core.base.enums.ImportFieldDic;
import pps.core.base.mapper.BaseDataImportLogMapper;
import pps.core.base.mapper.BaseDataMapper;
import pps.core.base.mapper.BaseModelValMapper;
......@@ -34,7 +33,6 @@ import xstartup.feature.mybatis.helper.XMapperHelper;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@XService
public class BaseDataService {
......@@ -192,83 +190,6 @@ public class BaseDataService {
return XMapperHelper.query(mapper, input, BaseDataEnt.class, QueryBaseDataOutput.class);
}
// @XText("下载导入模板")
// @XApiGet
// public XFileResult downloadImportTemplate(XContext context) {
// String fileSavePath = XStorageTool.getAbsolutePath("/temp/excel/导入模板_" + DateUtil.formatDate(new Date()) + ".xlsx");
// String templateFilePath = "template/import_template.xlsx";
// InputStream templateInputStream = this.getClass().getClassLoader().getResourceAsStream(templateFilePath);
// byte[] excelContent = ExportExcelUtils.genSingleExcelFileData(templateInputStream, null);
// try {
// ExportExcelUtils.outputFileData(excelContent, fileSavePath);
// } catch (Exception e) {
// context.getLogger().error(e);
// }
// return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath);
// }
//
// @XText("新增导入")
// @XApiUpload
// public XServiceResult importFile(XContext context, ImportFileInput input) {
// List<String> headerList = getExcelHeaderList();
// List<Map<String, Object>> mapList = ExcelUtils.readExcel(input.getFile().getInputStream(), input.getFile().getFileName(), headerList, 0);
// try {
// List<BaseDataView> dataList = new ArrayList<>(mapList.size());
// Date minDate = null;
// Date maxDate = null;
// for (Map<String, Object> objectMap : mapList) {
// BaseDataView dataView = BeanUtil.toBean(objectMap, BaseDataView.class);
// dataView.setOuId(input.getWellOuId());
// dataView.setLineId(input.getLineId());
// if (ObjectUtil.isNotNull(dataView.getDataDate())) {
// if (ObjectUtil.isNull(minDate)) {
// minDate = dataView.getDataDate();
// maxDate = dataView.getDataDate();
// }
// if (DateUtil.compare(minDate, dataView.getDataDate()) > 0) {
// minDate = dataView.getDataDate();
// } else if (DateUtil.compare(maxDate, dataView.getDataDate()) < 0) {
// maxDate = dataView.getDataDate();
// }
// }
// dataList.add(dataView);
// }
// if (ObjectUtil.isNull(minDate)) {
// return XServiceResult.error(1000, "日期错误");
// }
// BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
// mapper.delete(new LambdaQueryWrapper<BaseDataEnt>()
// .eq(BaseDataEnt::getLineId, input.getLineId())
// .ge(BaseDataEnt::getDataDate, minDate)
// .le(BaseDataEnt::getDataDate, maxDate));
// BaseDataViewMapper viewMapper = context.getBean(BaseDataViewMapper.class);
// viewMapper.batchInsert(dataList);
// BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class);
// BaseDataImportLogEnt ent = new BaseDataImportLogEnt();
// ent.setOuId(input.getWellOuId());
// ent.setLineId(input.getLineId());
// ent.setBeginDate(minDate);
// ent.setEndDate(maxDate);
// ent.setCreateTime(new Date());
// logMapper.insert(ent);
// } catch (Exception e) {
// return XServiceResult.error(-1, e.getMessage());
// }
// return XServiceResult.OK;
// }
private List<String> getExcelHeaderList() {
List<Map<String, Object>> fieldList = new ArrayList<>();
for (ImportFieldDic value : ImportFieldDic.values()) {
Map<String, Object> map = new HashMap<>();
map.put("col", value.getCol());
map.put("sort", value.getSort());
fieldList.add(map);
}
fieldList.sort(Comparator.comparing(o -> ((Integer) o.get("sort"))));
return fieldList.stream().map(x -> ((String) x.get("col"))).collect(Collectors.toList());
}
@XText("获取预算")
@XApiGet
public XServiceResult calcBaseData(XContext context, CalcBaseDataInput calcBaseDataInput) {
......
......@@ -239,10 +239,10 @@ public class BasePowerLineCloudServiceImpl implements IBasePowerLineCloudService
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
BaseWellheadEnt baseWellheadEnt = mapper.selectOne(
new QueryWrapper<BaseWellheadEnt>()
.select("IFNULL( SUM( service_rating ), 0 ) AS service_rating")
.select("IFNULL( SUM( SERVICE_RATING ), 0 ) AS SERVICE_RATING")
.lambda()
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.apply("id IN ( SELECT wellhead_id FROM base_power_line_wellhead WHERE line_id = {0} AND is_deleted = 1 )", input.getLineId())
.apply("ID IN ( SELECT WELLHEAD_ID FROM BASE_POWER_LINE_WELLHEAD WHERE LINE_ID = {0} AND IS_DELETED = 1 )", input.getLineId())
);
return XSingleResult.success(GetBasePowerLineWellheadViewOutput.builder()
.serviceRating(Optional.ofNullable(baseWellheadEnt)
......
......@@ -196,7 +196,7 @@ public class BasePriceStrategyService {
.select(BasePriceStrategyMonthEnt::getId, BasePriceStrategyMonthEnt::getStrategyMonth)
.eq(BasePriceStrategyMonthEnt::getStrategyId, strategyId)
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.last(" ORDER BY strategy_month + 0 ")
.last(" ORDER BY STRATEGY_MONTH + 0 ")
);
if (CollUtil.isNotEmpty(monthEntList)) {
List<GetBasePriceStrategyMonthOutput> months = XCopyUtils.copyNewList(monthEntList, GetBasePriceStrategyMonthOutput.class);
......
......@@ -195,8 +195,8 @@ public class WindPredictionFutureService {
//实际发电量
ThirdWindPowerGenerationMapper generationMapper = context.getBean(ThirdWindPowerGenerationMapper.class);
List<ThirdWindPowerGenerationEnt> generationList = generationMapper.selectList(new QueryWrapper<ThirdWindPowerGenerationEnt>()
.select("IFNULL( SUM( actual_power ), 0 ) AS actual_power", "collect_time")
.groupBy("collect_time")
.select("IFNULL( SUM( ACTUAL_POWER ), 0 ) AS ACTUAL_POWER", "COLLECT_TIME")
.groupBy("COLLECT_TIME")
.lambda()
.in(ThirdWindPowerGenerationEnt::getStationId, stationIds)
.eq(ThirdWindPowerGenerationEnt::getSystemSource, ServiceUtil.getOilFieldCode(context))
......@@ -278,8 +278,8 @@ public class WindPredictionFutureService {
beginTime = DateUtil.beginOfMonth(now);
endTime = DateUtil.endOfMonth(now);
map = mapper.selectList(new QueryWrapper<ThirdWindPowerGenerationUpdateEnt>()
.select("DAY( collect_time ) AS actual_wind_direction", "IFNULL( AVG( actual_wind_speed ), 0 ) AS actual_wind_speed")
.groupBy("DAY( collect_time )")
.select("DAY( COLLECT_TIME ) AS ACTUAL_WIND_DIRECTION", "IFNULL( AVG( ACTUAL_WIND_SPEED ), 0 ) AS ACTUAL_WIND_SPEED")
.groupBy("DAY( COLLECT_TIME )")
.lambda()
.between(ThirdWindPowerGenerationUpdateEnt::getCollectTime, beginTime, endTime)
.in(ThirdWindPowerGenerationUpdateEnt::getStationId, collect)
......@@ -300,8 +300,8 @@ public class WindPredictionFutureService {
beginTime = DateUtil.beginOfYear(now);
endTime = DateUtil.endOfYear(now);
map = mapper.selectList(new QueryWrapper<ThirdWindPowerGenerationUpdateEnt>()
.select("MONTH( collect_time ) AS actual_wind_direction", "IFNULL( AVG( actual_wind_speed ), 0 ) AS actual_wind_speed")
.groupBy("MONTH( collect_time )")
.select("MONTH( COLLECT_TIME ) AS ACTUAL_WIND_DIRECTION", "IFNULL( AVG( ACTUAL_WIND_SPEED ), 0 ) AS ACTUAL_WIND_SPEED")
.groupBy("MONTH( COLLECT_TIME )")
.lambda()
.between(ThirdWindPowerGenerationUpdateEnt::getCollectTime, beginTime, endTime)
.in(ThirdWindPowerGenerationUpdateEnt::getStationId, collect)
......@@ -321,9 +321,9 @@ public class WindPredictionFutureService {
}
//风速统计
ThirdWindPowerGenerationUpdateEnt windSpeed = mapper.selectOne(new QueryWrapper<ThirdWindPowerGenerationUpdateEnt>()
.select("IFNULL( ROUND( MAX( actual_wind_speed ), 2 ), 0 ) AS max_wind_speed",
"IFNULL( ROUND( MIN( actual_wind_speed ), 2 ), 0 ) AS min_wind_speed",
"IFNULL( ROUND( AVG( actual_wind_speed ), 2 ), 0 ) AS avg_wind_speed")
.select("IFNULL( ROUND( MAX( ACTUAL_WIND_SPEED ), 2 ), 0 ) AS MAX_WIND_SPEED",
"IFNULL( ROUND( MIN( ACTUAL_WIND_SPEED ), 2 ), 0 ) AS MIN_WIND_SPEED",
"IFNULL( ROUND( AVG( ACTUAL_WIND_SPEED ), 2 ), 0 ) AS AVG_WIND_SPEED")
.lambda()
.between(ThirdWindPowerGenerationUpdateEnt::getCollectTime, beginTime, endTime)
.eq(ThirdWindPowerGenerationUpdateEnt::getSystemSource, oilFieldCode)
......@@ -369,7 +369,7 @@ public class WindPredictionFutureService {
//分组查询风向
ThirdWindPowerGenerationMapper futureMapper = context.getBean(ThirdWindPowerGenerationMapper.class);
List<ThirdWindPowerGenerationEnt> list = futureMapper.selectList(new QueryWrapper<ThirdWindPowerGenerationEnt>()
.select("actual_wind_direction", "COUNT( 1 ) AS actual_wind_speed")
.select("ACTUAL_WIND_DIRECTION", "COUNT( 1 ) AS ACTUAL_WIND_SPEED")
.lambda()
.between(ThirdWindPowerGenerationEnt::getCollectTime, beginTime, endTime)
.in(ThirdWindPowerGenerationEnt::getStationId, turbineList.stream()
......@@ -538,7 +538,7 @@ public class WindPredictionFutureService {
output.setActualWindSpeed(selectOne.getActualWindSpeed());
//总计数据
selectOne = bean.selectOne(new QueryWrapper<ThirdWindPowerGenerationUpdateEnt>()
.select("SUM( actual_generation ) AS actual_generation")
.select("SUM( ACTUAL_GENERATION ) AS ACTUAL_GENERATION")
.lambda()
.eq(ThirdWindPowerGenerationUpdateEnt::getSystemSource, oilFieldCode)
.eq(ThirdWindPowerGenerationUpdateEnt::getStationId, input.getStationId())
......@@ -573,7 +573,7 @@ public class WindPredictionFutureService {
//查数据
ThirdWindPowerGenerationMapper generationMapper = context.getBean(ThirdWindPowerGenerationMapper.class);
List<ThirdWindPowerGenerationEnt> list = generationMapper.selectList(new QueryWrapper<ThirdWindPowerGenerationEnt>()
.select("collect_time", "IFNULL( SUM( actual_power ), 0 ) AS actual_power")
.select("COLLECT_TIME", "IFNULL( SUM( ACTUAL_POWER ), 0 ) AS ACTUAL_POWER")
.lambda()
.between(ThirdWindPowerGenerationEnt::getCollectTime, beginTime, endTime)
.eq(ThirdWindPowerGenerationEnt::getStationId, input.getStationId())
......@@ -619,8 +619,8 @@ public class WindPredictionFutureService {
//查本年发电
ThirdWindPowerGenerationUpdateMapper generationMapper = context.getBean(ThirdWindPowerGenerationUpdateMapper.class);
List<ThirdWindPowerGenerationUpdateEnt> list = generationMapper.selectList(new QueryWrapper<ThirdWindPowerGenerationUpdateEnt>()
.select("IFNULL( SUM( actual_generation ), 0 ) AS actual_generation", "MONTH ( collect_time ) AS actual_wind_direction")
.groupBy("MONTH ( collect_time )")
.select("IFNULL( SUM( ACTUAL_GENERATION ), 0 ) AS ACTUAL_GENERATION", "MONTH ( COLLECT_TIME ) AS ACTUAL_WIND_DIRECTION")
.groupBy("MONTH ( COLLECT_TIME )")
.lambda()
.eq(ThirdWindPowerGenerationUpdateEnt::getStationId, input.getStationId())
.eq(ThirdWindPowerGenerationUpdateEnt::getSystemSource, oilFieldCode)
......@@ -654,8 +654,8 @@ public class WindPredictionFutureService {
beginOfYear = DateUtil.offset(beginOfYear, DateField.YEAR, -1);
endOfYear = DateUtil.offset(endOfYear, DateField.YEAR, -1);
list = generationMapper.selectList(new QueryWrapper<ThirdWindPowerGenerationUpdateEnt>()
.select("IFNULL( SUM( actual_generation ), 0 ) AS actual_generation", "MONTH ( collect_time ) AS actual_wind_direction")
.groupBy("MONTH ( collect_time )")
.select("IFNULL( SUM( ACTUAL_GENERATION ), 0 ) AS ACTUAL_GENERATION", "MONTH ( COLLECT_TIME ) AS ACTUAL_WIND_DIRECTION")
.groupBy("MONTH ( COLLECT_TIME )")
.lambda()
.eq(ThirdWindPowerGenerationUpdateEnt::getStationId, input.getStationId())
.eq(ThirdWindPowerGenerationUpdateEnt::getSystemSource, oilFieldCode)
......
......@@ -405,8 +405,8 @@ public class SpaceOptimizeBaseService {
SpaceInstitutionDurationMapper durationMapper = context.getBean(SpaceInstitutionDurationMapper.class);
List<SpaceInstitutionDurationEnt> durationList = durationMapper.selectList(new QueryWrapper<SpaceInstitutionDurationEnt>()
.select("*",
"STR_TO_DATE( CONCAT( open_well_time, ':00' ), '%H:%i:%s' ) AS openTime",
"STR_TO_DATE( CONCAT( close_well_time, ':00' ), '%H:%i:%s' ) AS closeTime"
"STR_TO_DATE( CONCAT( OPEN_WELL_TIME, ':00' ), '%H:%i:%s' ) AS openTime",
"STR_TO_DATE( CONCAT( CLOSE_WELL_TIME, ':00' ), '%H:%i:%s' ) AS closeTime"
)
.lambda()
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
......@@ -2326,9 +2326,7 @@ public class SpaceOptimizeBaseService {
}
}
//保存结果
for (SpaceOptimizeDurationDTO dto : tempDurationDTOList) {
durationDTOList.add(dto);
}
CollUtil.addAll(durationDTOList, tempDurationDTOList);
}
}
}
......@@ -2508,9 +2506,7 @@ public class SpaceOptimizeBaseService {
}
}
//保存结果
for (SpaceOptimizeDurationDTO dto : tempDurationDTOList) {
durationDTOList.add(dto);
}
CollUtil.addAll(durationDTOList, tempDurationDTOList);
}
}
}
......@@ -3567,9 +3563,7 @@ public class SpaceOptimizeBaseService {
}
}
if (CollUtil.isNotEmpty(tempList)) {
for (SpaceOptimizeDurationDTO temp : tempList) {
optimizeDurationDTOList.add(temp);
}
CollUtil.addAll(optimizeDurationDTOList, tempList);
}
}
}
......
package pps.core.middle.service;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.validation.constraints.NotNull;
import pps.core.middle.entity.StationMappingEnt;
import pps.core.middle.mapper.StationMappingMapper;
import pps.core.middle.service.data.station_mapping.GetStationMappingInput;
import pps.core.middle.service.data.station_mapping.GetStationMappingOutput;
import xstartup.annotation.XService;
import xstartup.base.XContext;
import xstartup.base.XStartup;
import xstartup.data.XServiceResult;
import xstartup.data.XSingleResult;
import xstartup.feature.api.annotation.XApiAnonymous;
import xstartup.feature.api.annotation.XApiGet;
......@@ -106,30 +95,6 @@ public class StationMappingService {
}
}
@XApiAnonymous
@XApiGet(anonymous = true)
public XSingleResult<GetStationMappingOutput> getStationMapping(XContext context, GetStationMappingInput input) {
StationMappingMapper mapper = context.getBean(StationMappingMapper.class);
List<StationMappingEnt> list = mapper.selectList(new LambdaQueryWrapper<>());
for (StationMappingEnt stationMappingEnt : list) {
context.getLogger().info(JSONUtil.toJsonStr(stationMappingEnt));
}
try {
String storeDir = XStartup.getCurrent().getProperty("weather.file.temp.path");
StringBuilder stringBuilder = new StringBuilder(storeDir)
.append(File.separator)
.append(DateTime.now().toString("yyyyMMdd"));
String filePath = stringBuilder.append(File.separator).append("test.json").toString();
String url = "http://192.168.100.128/tqfj/202410181200天气预测数据SY.json";
HttpUtil.downloadFile(url, filePath);
context.getLogger().info(filePath);
context.getLogger().info(FileUtil.readUtf8String(filePath));
} catch (Exception e) {
context.getLogger().error(e.getMessage(), e);
}
return XSingleResult.success();
}
@XApiAnonymous
@XApiGet(anonymous = true)
public XServiceResult test(XContext context) throws SQLException {
......
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