Commit 68b5956f authored by ZWT's avatar ZWT

feat(吉林演示): 松原

1.修改系统首页大屏总览接口,增加区分组织机构逻辑,完成接口冒烟测试;
2.修改系统首页获取井场列表接口,增加区分组织机构逻辑,完成接口冒烟测试;
3.修改系统首页井场功能下钻后提示报错问题,修改用电功率数据获取逻辑,修复报错问题;
4.修改输电线路分页列表查询接口,增加查询条件,在查询父线路列表时只查询10千伏线路,修改线上接口文档同时完成接口冒烟测试;
5.修改系统首页井场实时监控接口,增加区分组织机构逻辑,完成接口冒烟测试;
6.修改系统首页用能分析接口,增加区分组织机构逻辑,完成接口冒烟测试;
7.修改系统首页井场用能分析(双坐标轴)接口,增加区分组织机构逻辑,完成接口冒烟测试;
8.修改系统首页累积用电接口,增加区分组织机构逻辑,完成接口冒烟测试;
9.修改系统首页光伏实时监控接口,增加区分组织机构逻辑,完成接口冒烟测试;
10.修改系统首页井场效果评价接口,增加区分组织机构逻辑,完成接口冒烟测试;
11.修改系统首页先导实验井间开制度接口,增加区分组织机构逻辑,完成接口冒烟测试;
12.修改极短期间开优化模块井口生产情况油井状态接口,增加区分组织机构逻辑,完成接口冒烟测试;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent b4f8cb22
...@@ -2,9 +2,11 @@ package pps.core.base.service; ...@@ -2,9 +2,11 @@ package pps.core.base.service;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.core.base.entity.BaseDataEnt; import pps.core.base.entity.BaseDataEnt;
import pps.core.base.entity.BaseDataImportLogEnt; import pps.core.base.entity.BaseDataImportLogEnt;
...@@ -27,7 +29,6 @@ import xstartup.base.XContext; ...@@ -27,7 +29,6 @@ import xstartup.base.XContext;
import xstartup.base.data.CustomQueryInput; import xstartup.base.data.CustomQueryInput;
import xstartup.base.tool.XStorageTool; import xstartup.base.tool.XStorageTool;
import xstartup.base.util.XCopyUtils; import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XDateUtils;
import xstartup.base.util.XJsonUtils; import xstartup.base.util.XJsonUtils;
import xstartup.data.*; import xstartup.data.*;
import xstartup.error.XError; import xstartup.error.XError;
...@@ -55,8 +56,7 @@ public class BaseDataService { ...@@ -55,8 +56,7 @@ public class BaseDataService {
@XApiPost @XApiPost
public XServiceResult updateBaseData(XContext context, UpdateBaseDataInput input) { public XServiceResult updateBaseData(XContext context, UpdateBaseDataInput input) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class); BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
BaseDataEnt entity = mapper.selectOne(new QueryWrapper<BaseDataEnt>() BaseDataEnt entity = mapper.selectOne(new LambdaQueryWrapper<BaseDataEnt>()
.lambda()
.eq(BaseDataEnt::getId, input.getId())); .eq(BaseDataEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
...@@ -69,8 +69,7 @@ public class BaseDataService { ...@@ -69,8 +69,7 @@ public class BaseDataService {
@XApiPost @XApiPost
public XServiceResult deleteBaseData(XContext context, DeleteBaseDataInput input) { public XServiceResult deleteBaseData(XContext context, DeleteBaseDataInput input) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class); BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
BaseDataEnt entity = mapper.selectOne(new QueryWrapper<BaseDataEnt>() BaseDataEnt entity = mapper.selectOne(new LambdaQueryWrapper<BaseDataEnt>()
.lambda()
.eq(BaseDataEnt::getId, input.getId())); .eq(BaseDataEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
...@@ -82,8 +81,7 @@ public class BaseDataService { ...@@ -82,8 +81,7 @@ public class BaseDataService {
@XApiGet @XApiGet
public XSingleResult<GetBaseDataOutput> getBaseData(XContext context, GetBaseDataInput input) { public XSingleResult<GetBaseDataOutput> getBaseData(XContext context, GetBaseDataInput input) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class); BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
BaseDataEnt entity = mapper.selectOne(new QueryWrapper<BaseDataEnt>() BaseDataEnt entity = mapper.selectOne(new LambdaQueryWrapper<BaseDataEnt>()
.lambda()
.eq(BaseDataEnt::getId, input.getId())); .eq(BaseDataEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound); return XSingleResult.error(context, XError.NotFound);
...@@ -96,30 +94,31 @@ public class BaseDataService { ...@@ -96,30 +94,31 @@ public class BaseDataService {
@XApiGet @XApiGet
public XListResult<QueryBaseDataOutput> queryBaseDataCopy(XContext context, GetBaseDataInput input) { public XListResult<QueryBaseDataOutput> queryBaseDataCopy(XContext context, GetBaseDataInput input) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class); BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>(); LambdaQueryWrapper<BaseDataEnt> queryWrapper = new LambdaQueryWrapper<BaseDataEnt>()
.eq(BaseDataEnt::getLineId, input.getLineId())
.orderByAsc(BaseDataEnt::getDataDate);
Date beginTime; Date beginTime;
Date endTime; Date endTime;
if (CharSequenceUtil.isBlank(input.getDataDate())) { if (CharSequenceUtil.isBlank(input.getDataDate())) {
beginTime = DateUtil.beginOfDay(new Date()); DateTime date = DateUtil.date();
endTime = DateUtil.endOfDay(new Date()); beginTime = DateUtil.beginOfDay(date);
queryWrapper.lambda().ge(BaseDataEnt::getDataDate, beginTime); endTime = DateUtil.endOfDay(date);
queryWrapper.lambda().le(BaseDataEnt::getDataDate, endTime); queryWrapper.ge(BaseDataEnt::getDataDate, beginTime)
.le(BaseDataEnt::getDataDate, endTime);
} else { } else {
if (input.getDataDate().contains("@")) { if (CharSequenceUtil.contains(input.getDataDate(), '@')) {
String[] dataDates = CharSequenceUtil.splitToArray(input.getDataDate(), '@'); String[] dataDates = CharSequenceUtil.splitToArray(input.getDataDate(), '@');
beginTime = DateUtil.beginOfDay(XDateUtils.parse(dataDates[0])); beginTime = DateUtil.beginOfDay(DateUtil.parseDateTime(dataDates[0]));
endTime = DateUtil.endOfDay(XDateUtils.parse(dataDates[1])); endTime = DateUtil.endOfDay(DateUtil.parseDateTime(dataDates[1]));
queryWrapper.lambda().ge(BaseDataEnt::getDataDate, beginTime); queryWrapper.ge(BaseDataEnt::getDataDate, beginTime)
queryWrapper.lambda().le(BaseDataEnt::getDataDate, endTime); .le(BaseDataEnt::getDataDate, endTime);
} else { } else {
beginTime = DateUtil.beginOfDay(XDateUtils.parse(input.getDataDate())); beginTime = DateUtil.beginOfDay(DateUtil.parseDateTime(input.getDataDate()));
endTime = DateUtil.endOfDay(XDateUtils.parse(input.getDataDate())); endTime = DateUtil.endOfDay(DateUtil.parseDateTime(input.getDataDate()));
queryWrapper.lambda().ge(BaseDataEnt::getDataDate, beginTime); queryWrapper.ge(BaseDataEnt::getDataDate, beginTime)
queryWrapper.lambda().le(BaseDataEnt::getDataDate, endTime); .le(BaseDataEnt::getDataDate, endTime);
} }
} }
queryWrapper.lambda().eq(BaseDataEnt::getLineId, input.getLineId());
queryWrapper.lambda().orderByAsc(BaseDataEnt::getDataDate);
List<BaseDataEnt> list = mapper.selectList(queryWrapper); List<BaseDataEnt> list = mapper.selectList(queryWrapper);
CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", input.getKeyName(), input.getLineId(), "train_pre", DateUtil.formatDateTime(beginTime), DateUtil.formatDateTime(endTime)); CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", input.getKeyName(), input.getLineId(), "train_pre", DateUtil.formatDateTime(beginTime), DateUtil.formatDateTime(endTime));
Map<String, Object> map = getCalcData(context, calcBaseDataInput); Map<String, Object> map = getCalcData(context, calcBaseDataInput);
...@@ -135,16 +134,14 @@ public class BaseDataService { ...@@ -135,16 +134,14 @@ public class BaseDataService {
@XApiGet @XApiGet
public XListResult<QueryBaseDataOutput> queryBaseData(XContext context, GetBaseDataInput input) { public XListResult<QueryBaseDataOutput> queryBaseData(XContext context, GetBaseDataInput input) {
BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class); BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class);
BaseDataImportLogEnt ent = logMapper.selectOne(new QueryWrapper<BaseDataImportLogEnt>() BaseDataImportLogEnt ent = logMapper.selectOne(new LambdaQueryWrapper<BaseDataImportLogEnt>()
.lambda()
.eq(BaseDataImportLogEnt::getLineId, input.getLineId()) .eq(BaseDataImportLogEnt::getLineId, input.getLineId())
.orderByDesc(BaseDataImportLogEnt::getCreateTime) .orderByDesc(BaseDataImportLogEnt::getCreateTime)
.last(BusinessConstant.LAST_LIMIT)); .last(BusinessConstant.LAST_LIMIT));
List<QueryBaseDataOutput> outputs = new ArrayList<>(); List<QueryBaseDataOutput> outputs = new ArrayList<>();
if (ObjectUtil.isNotNull(ent)) { if (ObjectUtil.isNotNull(ent)) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class); BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
List<BaseDataEnt> list = mapper.selectList(new QueryWrapper<BaseDataEnt>() List<BaseDataEnt> list = mapper.selectList(new LambdaQueryWrapper<BaseDataEnt>()
.lambda()
.ge(BaseDataEnt::getDataDate, ent.getBeginDate()) .ge(BaseDataEnt::getDataDate, ent.getBeginDate())
.le(BaseDataEnt::getDataDate, ent.getEndDate()) .le(BaseDataEnt::getDataDate, ent.getEndDate())
.eq(BaseDataEnt::getLineId, input.getLineId()) .eq(BaseDataEnt::getLineId, input.getLineId())
...@@ -158,16 +155,14 @@ public class BaseDataService { ...@@ -158,16 +155,14 @@ public class BaseDataService {
@XText("获取预测数据") @XText("获取预测数据")
public XListResult<GetBaseDataOutput> queryPreBaseData(XContext context, GetBaseDataInput input) { public XListResult<GetBaseDataOutput> queryPreBaseData(XContext context, GetBaseDataInput input) {
BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class); BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class);
BaseDataImportLogEnt ent = logMapper.selectOne(new QueryWrapper<BaseDataImportLogEnt>() BaseDataImportLogEnt ent = logMapper.selectOne(new LambdaQueryWrapper<BaseDataImportLogEnt>()
.lambda()
.eq(BaseDataImportLogEnt::getLineId, input.getLineId()) .eq(BaseDataImportLogEnt::getLineId, input.getLineId())
.orderByDesc(BaseDataImportLogEnt::getCreateTime) .orderByDesc(BaseDataImportLogEnt::getCreateTime)
.last(BusinessConstant.LAST_LIMIT)); .last(BusinessConstant.LAST_LIMIT));
List<GetBaseDataOutput> outputs = new ArrayList<>(); List<GetBaseDataOutput> outputs = new ArrayList<>();
if (ObjectUtil.isNotNull(ent)) { if (ObjectUtil.isNotNull(ent)) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class); BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
List<BaseDataEnt> list = mapper.selectList(new QueryWrapper<BaseDataEnt>() List<BaseDataEnt> list = mapper.selectList(new LambdaQueryWrapper<BaseDataEnt>()
.lambda()
.ge(BaseDataEnt::getDataDate, ent.getBeginDate()) .ge(BaseDataEnt::getDataDate, ent.getBeginDate())
.le(BaseDataEnt::getDataDate, ent.getEndDate()) .le(BaseDataEnt::getDataDate, ent.getEndDate())
.eq(BaseDataEnt::getLineId, input.getLineId()) .eq(BaseDataEnt::getLineId, input.getLineId())
...@@ -188,7 +183,8 @@ public class BaseDataService { ...@@ -188,7 +183,8 @@ public class BaseDataService {
public XPageResult<QueryBaseDataOutput> queryBaseDataList(XContext context, QueryBaseDataInput input) { public XPageResult<QueryBaseDataOutput> queryBaseDataList(XContext context, QueryBaseDataInput input) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class); BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>(); QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseDataEnt::getLineId, input.getLineId()) queryWrapper.lambda()
.eq(BaseDataEnt::getLineId, input.getLineId())
.eq(BaseDataEnt::getDataDate, input.getDataDate()); .eq(BaseDataEnt::getDataDate, input.getDataDate());
return XMapperHelper.query(mapper, input, queryWrapper, QueryBaseDataOutput.class); return XMapperHelper.query(mapper, input, queryWrapper, QueryBaseDataOutput.class);
} }
...@@ -220,7 +216,7 @@ public class BaseDataService { ...@@ -220,7 +216,7 @@ public class BaseDataService {
List<String> headerList = getExcelHeaderList(); List<String> headerList = getExcelHeaderList();
List<Map<String, Object>> mapList = ExcelUtils.readExcel(input.getFile().getInputStream(), input.getFile().getFileName(), headerList, 0); List<Map<String, Object>> mapList = ExcelUtils.readExcel(input.getFile().getInputStream(), input.getFile().getFileName(), headerList, 0);
try { try {
List<BaseDataView> dataList = new ArrayList<>(); List<BaseDataView> dataList = new ArrayList<>(mapList.size());
Date minDate = null; Date minDate = null;
Date maxDate = null; Date maxDate = null;
for (Map<String, Object> objectMap : mapList) { for (Map<String, Object> objectMap : mapList) {
...@@ -244,7 +240,8 @@ public class BaseDataService { ...@@ -244,7 +240,8 @@ public class BaseDataService {
return XServiceResult.error(1000, "日期错误"); return XServiceResult.error(1000, "日期错误");
} }
BaseDataMapper mapper = context.getBean(BaseDataMapper.class); BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
mapper.delete(new QueryWrapper<BaseDataEnt>().lambda().eq(BaseDataEnt::getLineId, input.getLineId()) mapper.delete(new LambdaQueryWrapper<BaseDataEnt>()
.eq(BaseDataEnt::getLineId, input.getLineId())
.ge(BaseDataEnt::getDataDate, minDate) .ge(BaseDataEnt::getDataDate, minDate)
.le(BaseDataEnt::getDataDate, maxDate)); .le(BaseDataEnt::getDataDate, maxDate));
BaseDataViewMapper viewMapper = context.getBean(BaseDataViewMapper.class); BaseDataViewMapper viewMapper = context.getBean(BaseDataViewMapper.class);
...@@ -311,8 +308,7 @@ public class BaseDataService { ...@@ -311,8 +308,7 @@ public class BaseDataService {
@XText("预测算法训练") @XText("预测算法训练")
public XServiceResult trainBaseData(XContext context, TrainBaseModelValInput input) { public XServiceResult trainBaseData(XContext context, TrainBaseModelValInput input) {
BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class); BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class);
BaseDataImportLogEnt ent = logMapper.selectOne(new QueryWrapper<BaseDataImportLogEnt>() BaseDataImportLogEnt ent = logMapper.selectOne(new LambdaQueryWrapper<BaseDataImportLogEnt>()
.lambda()
.eq(BaseDataImportLogEnt::getLineId, input.getLineId()) .eq(BaseDataImportLogEnt::getLineId, input.getLineId())
.orderByDesc(BaseDataImportLogEnt::getCreateTime) .orderByDesc(BaseDataImportLogEnt::getCreateTime)
.last(BusinessConstant.LAST_LIMIT)); .last(BusinessConstant.LAST_LIMIT));
...@@ -340,8 +336,7 @@ public class BaseDataService { ...@@ -340,8 +336,7 @@ public class BaseDataService {
if (CharSequenceUtil.isBlank(input.getKeyNames())) { if (CharSequenceUtil.isBlank(input.getKeyNames())) {
return XSingleResult.error(500, "请选择模型"); return XSingleResult.error(500, "请选择模型");
} }
BaseModelValEnt baseModelValEnt = baseModelValMapper.selectOne(new QueryWrapper<BaseModelValEnt>() BaseModelValEnt baseModelValEnt = baseModelValMapper.selectOne(new LambdaQueryWrapper<BaseModelValEnt>()
.lambda()
.eq(BaseModelValEnt::getLineId, input.getLineId()) .eq(BaseModelValEnt::getLineId, input.getLineId())
.eq(BaseModelValEnt::getKeyname, input.getKeyNames()) .eq(BaseModelValEnt::getKeyname, input.getKeyNames())
.orderByDesc(BaseModelValEnt::getCreatetime).last(BusinessConstant.LAST_LIMIT)); .orderByDesc(BaseModelValEnt::getCreatetime).last(BusinessConstant.LAST_LIMIT));
......
...@@ -175,9 +175,9 @@ public class BaseDieselGeneratorService { ...@@ -175,9 +175,9 @@ public class BaseDieselGeneratorService {
.in(CollUtil.isNotEmpty(allListByOuId), BaseDieselGeneratorEnt::getOuId, allListByOuId); .in(CollUtil.isNotEmpty(allListByOuId), BaseDieselGeneratorEnt::getOuId, allListByOuId);
} }
queryWrapper.lambda() queryWrapper.lambda()
.eq(BaseDieselGeneratorEnt::getIsDeleted, BusinessConstant.ONE)
.like(CharSequenceUtil.isNotEmpty(ouName), BaseDieselGeneratorEnt::getOuName, ouName) .like(CharSequenceUtil.isNotEmpty(ouName), BaseDieselGeneratorEnt::getOuName, ouName)
.like(CharSequenceUtil.isNotEmpty(deviceName), BaseDieselGeneratorEnt::getDeviceName, deviceName) .like(CharSequenceUtil.isNotEmpty(deviceName), BaseDieselGeneratorEnt::getDeviceName, deviceName)
.eq(BaseDieselGeneratorEnt::getIsDeleted, BusinessConstant.ONE)
.orderByAsc(BaseDieselGeneratorEnt::getOuName, BaseDieselGeneratorEnt::getDeviceName); .orderByAsc(BaseDieselGeneratorEnt::getOuName, BaseDieselGeneratorEnt::getDeviceName);
return XMapperHelper.query(mapper, input, queryWrapper, QueryBaseDieselGeneratorOutput.class); return XMapperHelper.query(mapper, input, queryWrapper, QueryBaseDieselGeneratorOutput.class);
} }
......
...@@ -175,9 +175,9 @@ public class BaseEnergyStorageDeviceService { ...@@ -175,9 +175,9 @@ public class BaseEnergyStorageDeviceService {
.in(CollUtil.isNotEmpty(allListByOuId), BaseEnergyStorageDeviceEnt::getOuId, allListByOuId); .in(CollUtil.isNotEmpty(allListByOuId), BaseEnergyStorageDeviceEnt::getOuId, allListByOuId);
} }
queryWrapper.lambda() queryWrapper.lambda()
.eq(BaseEnergyStorageDeviceEnt::getIsDeleted, BusinessConstant.ONE)
.like(CharSequenceUtil.isNotEmpty(ouName), BaseEnergyStorageDeviceEnt::getOuName, ouName) .like(CharSequenceUtil.isNotEmpty(ouName), BaseEnergyStorageDeviceEnt::getOuName, ouName)
.like(CharSequenceUtil.isNotEmpty(deviceName), BaseEnergyStorageDeviceEnt::getDeviceName, deviceName) .like(CharSequenceUtil.isNotEmpty(deviceName), BaseEnergyStorageDeviceEnt::getDeviceName, deviceName)
.eq(BaseEnergyStorageDeviceEnt::getIsDeleted, BusinessConstant.ONE)
.orderByAsc(BaseEnergyStorageDeviceEnt::getOuName, BaseEnergyStorageDeviceEnt::getDeviceName); .orderByAsc(BaseEnergyStorageDeviceEnt::getOuName, BaseEnergyStorageDeviceEnt::getDeviceName);
return XMapperHelper.query(mapper, input, queryWrapper, QueryBaseEnergyStorageDeviceOutput.class); return XMapperHelper.query(mapper, input, queryWrapper, QueryBaseEnergyStorageDeviceOutput.class);
} }
......
...@@ -2,7 +2,7 @@ package pps.core.base.service; ...@@ -2,7 +2,7 @@ package pps.core.base.service;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import pps.core.base.entity.BasePhotovoltaicPlantEnt; import pps.core.base.entity.BasePhotovoltaicPlantEnt;
import pps.core.base.entity.BasePhotovoltaicPlantMapeAdjEnt; import pps.core.base.entity.BasePhotovoltaicPlantMapeAdjEnt;
import pps.core.base.entity.BasePhotovoltaicPlantMapeAdjView; import pps.core.base.entity.BasePhotovoltaicPlantMapeAdjView;
...@@ -88,8 +88,7 @@ public class BasePhotovoltaicPlantMapeAdjService { ...@@ -88,8 +88,7 @@ public class BasePhotovoltaicPlantMapeAdjService {
ent.setModifyById(session.getId()); ent.setModifyById(session.getId());
ent.setModifyByName(session.getUserName()); ent.setModifyByName(session.getUserName());
ent.setModifyTime(new Date()); ent.setModifyTime(new Date());
mapper.update(ent, new UpdateWrapper<BasePhotovoltaicPlantMapeAdjEnt>() mapper.update(ent, new LambdaUpdateWrapper<BasePhotovoltaicPlantMapeAdjEnt>()
.lambda()
.eq(BasePhotovoltaicPlantMapeAdjEnt::getPlantId, input.getPlantId()) .eq(BasePhotovoltaicPlantMapeAdjEnt::getPlantId, input.getPlantId())
.eq(BasePhotovoltaicPlantMapeAdjEnt::getMapeType, input.getMapeType())); .eq(BasePhotovoltaicPlantMapeAdjEnt::getMapeType, input.getMapeType()));
return XServiceResult.OK; return XServiceResult.OK;
......
...@@ -50,6 +50,7 @@ import xstartup.feature.mybatis.helper.XMapperHelper; ...@@ -50,6 +50,7 @@ import xstartup.feature.mybatis.helper.XMapperHelper;
import xstartup.helper.XTransactionHelper; import xstartup.helper.XTransactionHelper;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
...@@ -217,7 +218,7 @@ public class BasePhotovoltaicPlantService { ...@@ -217,7 +218,7 @@ public class BasePhotovoltaicPlantService {
} else { } else {
mape = relMape; mape = relMape;
} }
output.setMape(mape.setScale(2, BigDecimal.ROUND_UP).toPlainString() + "%"); output.setMape(mape.setScale(2, RoundingMode.UP).toPlainString() + "%");
} }
} }
} }
...@@ -259,8 +260,8 @@ public class BasePhotovoltaicPlantService { ...@@ -259,8 +260,8 @@ public class BasePhotovoltaicPlantService {
.in(CollUtil.isNotEmpty(allListByOuId), BasePhotovoltaicPlantEnt::getOuId, allListByOuId); .in(CollUtil.isNotEmpty(allListByOuId), BasePhotovoltaicPlantEnt::getOuId, allListByOuId);
} }
queryWrapper.lambda() queryWrapper.lambda()
.like(CharSequenceUtil.isNotEmpty(stationName), BasePhotovoltaicPlantEnt::getStationName, stationName)
.eq(BasePhotovoltaicPlantEnt::getIsDeleted, BusinessConstant.ONE) .eq(BasePhotovoltaicPlantEnt::getIsDeleted, BusinessConstant.ONE)
.like(CharSequenceUtil.isNotEmpty(stationName), BasePhotovoltaicPlantEnt::getStationName, stationName)
.orderByAsc(BasePhotovoltaicPlantEnt::getOuName, BasePhotovoltaicPlantEnt::getStationName); .orderByAsc(BasePhotovoltaicPlantEnt::getOuName, BasePhotovoltaicPlantEnt::getStationName);
return XMapperHelper.query(mapper, input, queryWrapper, QueryBasePhotovoltaicPlantOutput.class); return XMapperHelper.query(mapper, input, queryWrapper, QueryBasePhotovoltaicPlantOutput.class);
} }
......
...@@ -96,7 +96,7 @@ public class BasePowerLineService { ...@@ -96,7 +96,7 @@ public class BasePowerLineService {
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
BasePowerLineMapper mapper = context.getBean(BasePowerLineMapper.class); BasePowerLineMapper mapper = context.getBean(BasePowerLineMapper.class);
BasePowerLineEnt entity = this.selectOneByLineId(lineId, mapper); BasePowerLineEnt entity = this.selectOneByLineId(lineId, mapper);
if (Objects.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
} }
//删除井口关联信息 //删除井口关联信息
...@@ -305,14 +305,14 @@ public class BasePowerLineService { ...@@ -305,14 +305,14 @@ public class BasePowerLineService {
BasePowerLineMapper mapper = context.getBean(BasePowerLineMapper.class); BasePowerLineMapper mapper = context.getBean(BasePowerLineMapper.class);
List<BasePowerLineEnt> selectList = mapper.selectList(new LambdaQueryWrapper<BasePowerLineEnt>() List<BasePowerLineEnt> selectList = mapper.selectList(new LambdaQueryWrapper<BasePowerLineEnt>()
.select(BaseModel::getId, BasePowerLineEnt::getLineName) .select(BaseModel::getId, BasePowerLineEnt::getLineName)
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
.eq(CharSequenceUtil.isNotBlank(lineId), BaseModel::getId, lineId) .eq(CharSequenceUtil.isNotBlank(lineId), BaseModel::getId, lineId)
.eq(CharSequenceUtil.isNotBlank(ouId), BasePowerLineEnt::getOuId, ouId) .eq(CharSequenceUtil.isNotBlank(ouId), BasePowerLineEnt::getOuId, ouId)
.eq(CharSequenceUtil.isNotBlank(upperLineId), BasePowerLineEnt::getUpperLineId, upperLineId) .eq(CharSequenceUtil.isNotBlank(upperLineId), BasePowerLineEnt::getUpperLineId, upperLineId)
.like(CharSequenceUtil.isNotBlank(lineName), BasePowerLineEnt::getLineName, lineName)
.eq(CharSequenceUtil.isNotBlank(gridTypeKey), BasePowerLineEnt::getGridTypeKey, gridTypeKey) .eq(CharSequenceUtil.isNotBlank(gridTypeKey), BasePowerLineEnt::getGridTypeKey, gridTypeKey)
.eq(CharSequenceUtil.isNotBlank(lineTypeKey), BasePowerLineEnt::getLineTypeKey, lineTypeKey) .eq(CharSequenceUtil.isNotBlank(lineTypeKey), BasePowerLineEnt::getLineTypeKey, lineTypeKey)
.eq(CharSequenceUtil.isNotBlank(strategyId), BasePowerLineEnt::getStrategyId, strategyId) .eq(CharSequenceUtil.isNotBlank(strategyId), BasePowerLineEnt::getStrategyId, strategyId)
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE) .like(CharSequenceUtil.isNotBlank(lineName), BasePowerLineEnt::getLineName, lineName)
.orderByAsc(BasePowerLineEnt::getLineTypeKey, BasePowerLineEnt::getLineName) .orderByAsc(BasePowerLineEnt::getLineTypeKey, BasePowerLineEnt::getLineName)
); );
List<DynamicQueryBasePowerLineOutput> lineOutputList = XCopyUtils.copyNewList(selectList, DynamicQueryBasePowerLineOutput.class); List<DynamicQueryBasePowerLineOutput> lineOutputList = XCopyUtils.copyNewList(selectList, DynamicQueryBasePowerLineOutput.class);
......
...@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil; ...@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod; import com.github.pagehelper.page.PageMethod;
...@@ -103,15 +102,13 @@ public class BasePriceStrategyService { ...@@ -103,15 +102,13 @@ public class BasePriceStrategyService {
.collect(Collectors.toList()); .collect(Collectors.toList());
BasePriceStrategyMonthMapper monthMapper = context.getBean(BasePriceStrategyMonthMapper.class); BasePriceStrategyMonthMapper monthMapper = context.getBean(BasePriceStrategyMonthMapper.class);
//删除月信息 //删除月信息
monthMapper.delete(new QueryWrapper<BasePriceStrategyMonthEnt>() monthMapper.delete(new LambdaQueryWrapper<BasePriceStrategyMonthEnt>()
.lambda()
.eq(BasePriceStrategyMonthEnt::getStrategyId, strategyId) .eq(BasePriceStrategyMonthEnt::getStrategyId, strategyId)
.in(BasePriceStrategyMonthEnt::getStrategyMonth, collect) .in(BasePriceStrategyMonthEnt::getStrategyMonth, collect)
); );
BasePriceStrategyDetailMapper detailMapper = context.getBean(BasePriceStrategyDetailMapper.class); BasePriceStrategyDetailMapper detailMapper = context.getBean(BasePriceStrategyDetailMapper.class);
//删除详情 //删除详情
detailMapper.delete(new QueryWrapper<BasePriceStrategyDetailEnt>() detailMapper.delete(new LambdaQueryWrapper<BasePriceStrategyDetailEnt>()
.lambda()
.eq(BasePriceStrategyDetailEnt::getStrategyId, strategyId) .eq(BasePriceStrategyDetailEnt::getStrategyId, strategyId)
.in(BasePriceStrategyDetailEnt::getStrategyMonth, collect) .in(BasePriceStrategyDetailEnt::getStrategyMonth, collect)
); );
...@@ -281,10 +278,10 @@ public class BasePriceStrategyService { ...@@ -281,10 +278,10 @@ public class BasePriceStrategyService {
List<BasePriceStrategyEnt> selectList = mapper.selectList(new LambdaQueryWrapper<BasePriceStrategyEnt>() List<BasePriceStrategyEnt> selectList = mapper.selectList(new LambdaQueryWrapper<BasePriceStrategyEnt>()
.select(BaseModel::getId, BasePriceStrategyEnt::getPolicyName) .select(BaseModel::getId, BasePriceStrategyEnt::getPolicyName)
.eq(CharSequenceUtil.isNotBlank(id), BaseModel::getId, id) .eq(CharSequenceUtil.isNotBlank(id), BaseModel::getId, id)
.like(CharSequenceUtil.isNotBlank(policyName), BasePriceStrategyEnt::getPolicyName, policyName)
.eq(Objects.nonNull(areaCode), BasePriceStrategyEnt::getAreaCode, areaCode) .eq(Objects.nonNull(areaCode), BasePriceStrategyEnt::getAreaCode, areaCode)
.eq(Objects.nonNull(strategyYear), BasePriceStrategyEnt::getStrategyYear, strategyYear) .eq(Objects.nonNull(strategyYear), BasePriceStrategyEnt::getStrategyYear, strategyYear)
.eq(Objects.nonNull(isFixedPrice), BasePriceStrategyEnt::getIsFixedPrice, isFixedPrice) .eq(Objects.nonNull(isFixedPrice), BasePriceStrategyEnt::getIsFixedPrice, isFixedPrice)
.like(CharSequenceUtil.isNotBlank(policyName), BasePriceStrategyEnt::getPolicyName, policyName)
.orderByDesc(BaseModel::getModifyTime) .orderByDesc(BaseModel::getModifyTime)
); );
List<DynamicQueryBasePriceStrategyOutput> strategyOutputList = XCopyUtils.copyNewList(selectList, DynamicQueryBasePriceStrategyOutput.class); List<DynamicQueryBasePriceStrategyOutput> strategyOutputList = XCopyUtils.copyNewList(selectList, DynamicQueryBasePriceStrategyOutput.class);
......
...@@ -3,6 +3,7 @@ package pps.core.base.service; ...@@ -3,6 +3,7 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import pps.core.base.entity.BaseLineAttenuationRateEnt; import pps.core.base.entity.BaseLineAttenuationRateEnt;
...@@ -36,21 +37,6 @@ import java.util.stream.Collectors; ...@@ -36,21 +37,6 @@ import java.util.stream.Collectors;
@XService @XService
public class BaseProjectInfoService { public class BaseProjectInfoService {
/**
* 根据子节点获取最上层节点
*
* @return
*/
public static String getParentNameStr(List<SysAreaEnt> areaList, SysAreaEnt child) {
String parentNameStr = child.getName();
Integer parentId = child.getParentId();
if (parentId != 120) {
SysAreaEnt parent = areaList.stream().filter(item -> item.getId().equals(parentId)).findFirst().orElse(null);
String nameStr = getParentNameStr(areaList, parent);
parentNameStr = nameStr + "/" + parentNameStr;
}
return parentNameStr;
}
@XApiPost @XApiPost
public XServiceResult createProjectInfo(XContext context, CreateBaseProjectInfoInput input) { public XServiceResult createProjectInfo(XContext context, CreateBaseProjectInfoInput input) {
...@@ -86,8 +72,7 @@ public class BaseProjectInfoService { ...@@ -86,8 +72,7 @@ public class BaseProjectInfoService {
@XApiPost @XApiPost
public XServiceResult updateProjectInfo(XContext context, UpdateBaseProjectInfoInput input) { public XServiceResult updateProjectInfo(XContext context, UpdateBaseProjectInfoInput input) {
BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class); BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class);
BaseProjectInfoEnt entity = mapper.selectOne(new QueryWrapper<BaseProjectInfoEnt>() BaseProjectInfoEnt entity = mapper.selectOne(new LambdaQueryWrapper<BaseProjectInfoEnt>()
.lambda()
.eq(BaseProjectInfoEnt::getId, input.getId())); .eq(BaseProjectInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
...@@ -101,8 +86,7 @@ public class BaseProjectInfoService { ...@@ -101,8 +86,7 @@ public class BaseProjectInfoService {
entity.setIsDeleted(0); entity.setIsDeleted(0);
mapper.updateById(entity); mapper.updateById(entity);
BaseLineAttenuationRateMapper rateMapper = context.getBean(BaseLineAttenuationRateMapper.class); BaseLineAttenuationRateMapper rateMapper = context.getBean(BaseLineAttenuationRateMapper.class);
rateMapper.delete(new QueryWrapper<BaseLineAttenuationRateEnt>() rateMapper.delete(new LambdaQueryWrapper<BaseLineAttenuationRateEnt>()
.lambda()
.eq(BaseLineAttenuationRateEnt::getLineId, entity.getId()) .eq(BaseLineAttenuationRateEnt::getLineId, entity.getId())
.eq(BaseLineAttenuationRateEnt::getType, 1)); .eq(BaseLineAttenuationRateEnt::getType, 1));
List<BaseLineAttenuationRateView> list = new ArrayList<>(); List<BaseLineAttenuationRateView> list = new ArrayList<>();
...@@ -127,8 +111,7 @@ public class BaseProjectInfoService { ...@@ -127,8 +111,7 @@ public class BaseProjectInfoService {
@XApiPost @XApiPost
public XServiceResult deleteProjectInfo(XContext context, DeleteProjectInfoInput input) { public XServiceResult deleteProjectInfo(XContext context, DeleteProjectInfoInput input) {
BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class); BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class);
BaseProjectInfoEnt entity = mapper.selectOne(new QueryWrapper<BaseProjectInfoEnt>() BaseProjectInfoEnt entity = mapper.selectOne(new LambdaQueryWrapper<BaseProjectInfoEnt>()
.lambda()
.eq(BaseProjectInfoEnt::getId, input.getId())); .eq(BaseProjectInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
...@@ -141,8 +124,7 @@ public class BaseProjectInfoService { ...@@ -141,8 +124,7 @@ public class BaseProjectInfoService {
@XApiGet @XApiGet
public XSingleResult<GetBaseProjectInfoOutput> getProjectInfo(XContext context, GetProjectInfoInput input) { public XSingleResult<GetBaseProjectInfoOutput> getProjectInfo(XContext context, GetProjectInfoInput input) {
BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class); BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class);
BaseProjectInfoEnt entity = mapper.selectOne(new QueryWrapper<BaseProjectInfoEnt>() BaseProjectInfoEnt entity = mapper.selectOne(new LambdaQueryWrapper<BaseProjectInfoEnt>()
.lambda()
.eq(BaseProjectInfoEnt::getId, input.getId())); .eq(BaseProjectInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound); return XSingleResult.error(context, XError.NotFound);
...@@ -153,8 +135,7 @@ public class BaseProjectInfoService { ...@@ -153,8 +135,7 @@ public class BaseProjectInfoService {
output.setProvince(Integer.valueOf(entity.getProvince())); output.setProvince(Integer.valueOf(entity.getProvince()));
} }
BaseLineAttenuationRateMapper rateMapper = context.getBean(BaseLineAttenuationRateMapper.class); BaseLineAttenuationRateMapper rateMapper = context.getBean(BaseLineAttenuationRateMapper.class);
List<BaseLineAttenuationRateEnt> list = rateMapper.selectList(new QueryWrapper<BaseLineAttenuationRateEnt>() List<BaseLineAttenuationRateEnt> list = rateMapper.selectList(new LambdaQueryWrapper<BaseLineAttenuationRateEnt>()
.lambda()
.eq(BaseLineAttenuationRateEnt::getLineId, entity.getId()) .eq(BaseLineAttenuationRateEnt::getLineId, entity.getId())
.eq(BaseLineAttenuationRateEnt::getType, 1)); .eq(BaseLineAttenuationRateEnt::getType, 1));
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
...@@ -167,23 +148,18 @@ public class BaseProjectInfoService { ...@@ -167,23 +148,18 @@ public class BaseProjectInfoService {
@XApiGet @XApiGet
public XPageResult<QueryBaseProjectInfoOutput> queryProjectInfoList(XContext context, QueryProjectInfoInput input) { public XPageResult<QueryBaseProjectInfoOutput> queryProjectInfoList(XContext context, QueryProjectInfoInput input) {
BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class); BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class);
QueryWrapper<BaseProjectInfoEnt> queryWrapper = new QueryWrapper<>(); List<BaseProjectInfoEnt> list = mapper.selectList(new LambdaQueryWrapper<BaseProjectInfoEnt>()
queryWrapper.lambda().eq(BaseProjectInfoEnt::getIsDeleted, 0); .like(CharSequenceUtil.isNotBlank(input.getProjectName()), BaseProjectInfoEnt::getProjectName, input.getProjectName())
if (CharSequenceUtil.isNotBlank(input.getProjectName())) { .like(CharSequenceUtil.isNotBlank(input.getProductionYear()), BaseProjectInfoEnt::getProductionYear, input.getProductionYear())
queryWrapper.lambda().like(BaseProjectInfoEnt::getProjectName, input.getProjectName()); );
} PageInfo<BaseProjectInfoEnt> pageInfo = new PageInfo<>(list);
if (CharSequenceUtil.isNotBlank(input.getProductionYear())) {
queryWrapper.lambda().like(BaseProjectInfoEnt::getProductionYear, input.getProductionYear());
}
List<BaseProjectInfoEnt> list = mapper.selectList(queryWrapper);
PageInfo<BaseProjectInfoEnt> pageInfo = new PageInfo(list);
List<QueryBaseProjectInfoOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), QueryBaseProjectInfoOutput.class); List<QueryBaseProjectInfoOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), QueryBaseProjectInfoOutput.class);
SysAreaMapper areaMapper = context.getBean(SysAreaMapper.class); SysAreaMapper areaMapper = context.getBean(SysAreaMapper.class);
List<SysAreaEnt> areaEntList = areaMapper.selectList(new QueryWrapper<>()); List<SysAreaEnt> areaEntList = areaMapper.selectList(new QueryWrapper<>());
outputs.forEach(item -> { outputs.forEach(item -> {
if (CharSequenceUtil.isNotBlank(item.getProvince())) { if (CharSequenceUtil.isNotBlank(item.getProvince())) {
areaEntList.stream() areaEntList.stream()
.filter(area -> item.getProvince().equals(area.getId() + "")) .filter(area -> CharSequenceUtil.equals(item.getProvince(), area.getId().toString()))
.findFirst() .findFirst()
.ifPresent(areaEnt -> item.setProvince(getParentNameStr(areaEntList, areaEnt))); .ifPresent(areaEnt -> item.setProvince(getParentNameStr(areaEntList, areaEnt)));
} }
...@@ -194,12 +170,10 @@ public class BaseProjectInfoService { ...@@ -194,12 +170,10 @@ public class BaseProjectInfoService {
@XApiGet @XApiGet
public XListResult<GetProjectInfoPredictedDataOutput> queryProjectInfoPredictedDataList(XContext context, GetProjectInfoPredictedDataInput input) { public XListResult<GetProjectInfoPredictedDataOutput> queryProjectInfoPredictedDataList(XContext context, GetProjectInfoPredictedDataInput input) {
BaseProjectInfoPredictedDataMapper mapper = context.getBean(BaseProjectInfoPredictedDataMapper.class); BaseProjectInfoPredictedDataMapper mapper = context.getBean(BaseProjectInfoPredictedDataMapper.class);
QueryWrapper<BaseProjectInfoPredictedDataEnt> queryWrapper = new QueryWrapper<>(); List<BaseProjectInfoPredictedDataEnt> list = mapper.selectList(new LambdaQueryWrapper<BaseProjectInfoPredictedDataEnt>()
if (ObjectUtil.isNotNull(input.getProjectId())) { .eq(ObjectUtil.isNotNull(input.getProjectId()), BaseProjectInfoPredictedDataEnt::getProjectId, input.getProjectId())
queryWrapper.lambda().eq(BaseProjectInfoPredictedDataEnt::getProjectId, input.getProjectId()); );
} PageInfo<BaseProjectInfoPredictedDataEnt> pageInfo = new PageInfo<>(list);
List<BaseProjectInfoPredictedDataEnt> list = mapper.selectList(queryWrapper);
PageInfo<BaseProjectInfoPredictedDataEnt> pageInfo = new PageInfo(list);
List<GetProjectInfoPredictedDataOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), GetProjectInfoPredictedDataOutput.class); List<GetProjectInfoPredictedDataOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), GetProjectInfoPredictedDataOutput.class);
return XListResult.success(outputs); return XListResult.success(outputs);
} }
...@@ -213,14 +187,13 @@ public class BaseProjectInfoService { ...@@ -213,14 +187,13 @@ public class BaseProjectInfoService {
input.setCapacity(entity.getInstallCapacity()); input.setCapacity(entity.getInstallCapacity());
input.setEfficiency(new BigDecimal("0.35").setScale(2, RoundingMode.HALF_EVEN)); input.setEfficiency(new BigDecimal("0.35").setScale(2, RoundingMode.HALF_EVEN));
input.setWeather(new BigDecimal("0.7").setScale(2, RoundingMode.HALF_EVEN)); input.setWeather(new BigDecimal("0.7").setScale(2, RoundingMode.HALF_EVEN));
List<BaseLineAttenuationRateView> sortList = list.stream().sorted(Comparator.comparing(BaseLineAttenuationRateView::getSort)).collect(Collectors.toList()); list.sort(Comparator.comparing(BaseLineAttenuationRateView::getSort));
List<BigDecimal> decimals = sortList.stream().map(BaseLineAttenuationRateView::getAttenuationRate).collect(Collectors.toList()); List<BigDecimal> decimals = list.stream().map(BaseLineAttenuationRateView::getAttenuationRate).collect(Collectors.toList());
input.setDecline(decimals); input.setDecline(decimals);
Map<String, Object> map = getPredictedData(context, input); Map<String, Object> map = getPredictedData(context, input);
//插入数据 //插入数据
BaseProjectInfoPredictedDataMapper mapper = context.getBean(BaseProjectInfoPredictedDataMapper.class); BaseProjectInfoPredictedDataMapper mapper = context.getBean(BaseProjectInfoPredictedDataMapper.class);
mapper.delete(new QueryWrapper<BaseProjectInfoPredictedDataEnt>() mapper.delete(new LambdaQueryWrapper<BaseProjectInfoPredictedDataEnt>()
.lambda()
.eq(BaseProjectInfoPredictedDataEnt::getProjectId, entity.getId())); .eq(BaseProjectInfoPredictedDataEnt::getProjectId, entity.getId()));
List<Double> powers = (List<Double>) map.get("power"); List<Double> powers = (List<Double>) map.get("power");
Integer particularYear = Integer.valueOf(entity.getProductionYear()); Integer particularYear = Integer.valueOf(entity.getProductionYear());
...@@ -255,4 +228,20 @@ public class BaseProjectInfoService { ...@@ -255,4 +228,20 @@ public class BaseProjectInfoService {
throw new RuntimeException("调用预测接口失败"); throw new RuntimeException("调用预测接口失败");
} }
} }
/**
* 根据子节点获取最上层节点
*
* @return
*/
private String getParentNameStr(List<SysAreaEnt> areaList, SysAreaEnt child) {
String parentNameStr = child.getName();
Integer parentId = child.getParentId();
if (!parentId.equals(120)) {
SysAreaEnt parent = areaList.stream().filter(item -> item.getId().equals(parentId)).findFirst().orElse(null);
String nameStr = getParentNameStr(areaList, parent);
parentNameStr = nameStr + "/" + parentNameStr;
}
return parentNameStr;
}
} }
package pps.core.base.service; package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
...@@ -22,7 +25,6 @@ import pps.core.common.constant.BusinessConstant; ...@@ -22,7 +25,6 @@ import pps.core.common.constant.BusinessConstant;
import xstartup.annotation.XService; import xstartup.annotation.XService;
import xstartup.base.XContext; import xstartup.base.XContext;
import xstartup.base.util.XCopyUtils; import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XStringUtils;
import xstartup.core.base.helper.XThreadHelper; import xstartup.core.base.helper.XThreadHelper;
import xstartup.data.XServiceResult; import xstartup.data.XServiceResult;
import xstartup.feature.api.annotation.XApiGet; import xstartup.feature.api.annotation.XApiGet;
...@@ -181,17 +183,17 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -181,17 +183,17 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
dao.setHumidity(humidity_1.add(humidity_2.subtract(humidity_1).multiply(new BigDecimal(0.3 * y)))); dao.setHumidity(humidity_1.add(humidity_2.subtract(humidity_1).multiply(new BigDecimal(0.3 * y))));
date = sdf.parse(objList.get(i).getYearTime() + "-" + objList.get(i).getMonthTime() + "-" + objList.get(i).getDayTime()); date = sdf.parse(objList.get(i).getYearTime() + "-" + objList.get(i).getMonthTime() + "-" + objList.get(i).getDayTime());
String Hour; String Hour;
if (23 == Integer.valueOf(objList.get(i).getHourTime())) { if (23 == Integer.parseInt(objList.get(i).getHourTime())) {
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.DAY_OF_MONTH, 1);
date = calendar.getTime(); date = calendar.getTime();
Hour = "0" + (y - 1); Hour = "0" + (y - 1);
} else { } else {
if ((Integer.valueOf(objList.get(i).getHourTime()) + y) < 10) { if ((Integer.parseInt(objList.get(i).getHourTime()) + y) < 10) {
Hour = "0" + (Integer.valueOf(objList.get(i).getHourTime()) + y); Hour = "0" + (Integer.parseInt(objList.get(i).getHourTime()) + y);
} else { } else {
Hour = (Integer.valueOf(objList.get(i).getHourTime()) + y) + ""; Hour = (Integer.parseInt(objList.get(i).getHourTime()) + y) + "";
} }
} }
dayTime = sdf.format(date); dayTime = sdf.format(date);
...@@ -211,13 +213,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -211,13 +213,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
dao.setDataDate(dao.getYearTime() + "-" + dao.getMonthTime() + "-" + dao.getDayTime() + " " + dao.getHourTime() + ":" + dao.getMinTime()); dao.setDataDate(dao.getYearTime() + "-" + dao.getMonthTime() + "-" + dao.getDayTime() + " " + dao.getHourTime() + ":" + dao.getMinTime());
PlantPredictedPowerDataEnt insertDao = XCopyUtils.copyNewObject(dao, PlantPredictedPowerDataEnt.class); PlantPredictedPowerDataEnt insertDao = XCopyUtils.copyNewObject(dao, PlantPredictedPowerDataEnt.class);
allList.add(insertDao); allList.add(insertDao);
// for (String time : timeList){
// dao.setMinTime(time);
// dao.setDataDate(dao.getYearTime() + "-" + dao.getMonthTime() + "-" + dao.getDayTime() +" " + dao.getHourTime() + ":" + dao.getMinTime());
// PlantPredictedPowerDataEnt insertDao = XCopyUtils.copyNewObject(dao , PlantPredictedPowerDataEnt.class);
// // mapper.insert(insertDao);
// allList.add(insertDao);
// }
} }
} }
List<PlantPredictedPowerDataEnt> batchList = new ArrayList<>(); List<PlantPredictedPowerDataEnt> batchList = new ArrayList<>();
...@@ -234,25 +229,25 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -234,25 +229,25 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
int I_i = i + 1; int I_i = i + 1;
BigDecimal temperature_1 = sortList.get(i).getTemperature() == null ? new BigDecimal(0) : sortList.get(i).getTemperature(); BigDecimal temperature_1 = sortList.get(i).getTemperature() == null ? new BigDecimal(0) : sortList.get(i).getTemperature();
BigDecimal temperature_2 = sortList.get(I_i).getTemperature() == null ? new BigDecimal(0) : sortList.get(I_i).getTemperature(); BigDecimal temperature_2 = sortList.get(I_i).getTemperature() == null ? new BigDecimal(0) : sortList.get(I_i).getTemperature();
dao.setTemperature(temperature_1.add(temperature_2.subtract(temperature_1).multiply(new BigDecimal(0.3 * (y + 1))))); dao.setTemperature(temperature_1.add(temperature_2.subtract(temperature_1).multiply(BigDecimal.valueOf(0.3 * (y + 1)))));
BigDecimal humidity_1 = sortList.get(i).getHumidity() == null ? new BigDecimal(0) : sortList.get(i).getHumidity(); BigDecimal humidity_1 = sortList.get(i).getHumidity() == null ? new BigDecimal(0) : sortList.get(i).getHumidity();
BigDecimal humidity_2 = sortList.get(I_i).getHumidity() == null ? new BigDecimal(0) : sortList.get(I_i).getHumidity(); BigDecimal humidity_2 = sortList.get(I_i).getHumidity() == null ? new BigDecimal(0) : sortList.get(I_i).getHumidity();
dao.setHumidity(humidity_1.add(humidity_2.subtract(humidity_1).multiply(new BigDecimal(0.3 * (y + 1))))); dao.setHumidity(humidity_1.add(humidity_2.subtract(humidity_1).multiply(BigDecimal.valueOf(0.3 * (y + 1)))));
BigDecimal windSpeed_1 = sortList.get(i).getWindSpeed() == null ? new BigDecimal(0) : sortList.get(i).getWindSpeed(); BigDecimal windSpeed_1 = sortList.get(i).getWindSpeed() == null ? new BigDecimal(0) : sortList.get(i).getWindSpeed();
BigDecimal windSpeed_2 = sortList.get(I_i).getWindSpeed() == null ? new BigDecimal(0) : sortList.get(I_i).getWindSpeed(); BigDecimal windSpeed_2 = sortList.get(I_i).getWindSpeed() == null ? new BigDecimal(0) : sortList.get(I_i).getWindSpeed();
dao.setWindSpeed(windSpeed_1.add(windSpeed_2.subtract(windSpeed_1).multiply(new BigDecimal(0.3 * (y + 1))))); dao.setWindSpeed(windSpeed_1.add(windSpeed_2.subtract(windSpeed_1).multiply(BigDecimal.valueOf(0.3 * (y + 1)))));
BigDecimal pressure_1 = sortList.get(i).getPressure() == null ? new BigDecimal(0) : sortList.get(i).getPressure(); BigDecimal pressure_1 = sortList.get(i).getPressure() == null ? new BigDecimal(0) : sortList.get(i).getPressure();
BigDecimal pressure_2 = sortList.get(I_i).getPressure() == null ? new BigDecimal(0) : sortList.get(I_i).getPressure(); BigDecimal pressure_2 = sortList.get(I_i).getPressure() == null ? new BigDecimal(0) : sortList.get(I_i).getPressure();
dao.setPressure(pressure_1.add(pressure_2.subtract(pressure_1).multiply(new BigDecimal(0.3 * (y + 1))))); dao.setPressure(pressure_1.add(pressure_2.subtract(pressure_1).multiply(BigDecimal.valueOf(0.3 * (y + 1)))));
BigDecimal planeIrradiance_1 = sortList.get(i).getPlaneIrradiance() == null ? new BigDecimal(0) : sortList.get(i).getPlaneIrradiance(); BigDecimal planeIrradiance_1 = sortList.get(i).getPlaneIrradiance() == null ? new BigDecimal(0) : sortList.get(i).getPlaneIrradiance();
BigDecimal planeIrradiance_2 = sortList.get(I_i).getPlaneIrradiance() == null ? new BigDecimal(0) : sortList.get(I_i).getPlaneIrradiance(); BigDecimal planeIrradiance_2 = sortList.get(I_i).getPlaneIrradiance() == null ? new BigDecimal(0) : sortList.get(I_i).getPlaneIrradiance();
dao.setPlaneIrradiance(planeIrradiance_1.add(planeIrradiance_2.subtract(planeIrradiance_1).multiply(new BigDecimal(0.3 * (y + 1))))); dao.setPlaneIrradiance(planeIrradiance_1.add(planeIrradiance_2.subtract(planeIrradiance_1).multiply(BigDecimal.valueOf(0.3 * (y + 1)))));
BigDecimal horizontalIrradiance_1 = sortList.get(i).getHorizontalIrradiance() == null ? new BigDecimal(0) : sortList.get(i).getHorizontalIrradiance(); BigDecimal horizontalIrradiance_1 = sortList.get(i).getHorizontalIrradiance() == null ? new BigDecimal(0) : sortList.get(i).getHorizontalIrradiance();
BigDecimal horizontalIrradiance_2 = sortList.get(I_i).getHorizontalIrradiance() == null ? new BigDecimal(0) : sortList.get(I_i).getHorizontalIrradiance(); BigDecimal horizontalIrradiance_2 = sortList.get(I_i).getHorizontalIrradiance() == null ? new BigDecimal(0) : sortList.get(I_i).getHorizontalIrradiance();
dao.setHorizontalIrradiance(horizontalIrradiance_1.add(horizontalIrradiance_2.subtract(horizontalIrradiance_1).multiply(new BigDecimal(0.3 * (y + 1))))); dao.setHorizontalIrradiance(horizontalIrradiance_1.add(horizontalIrradiance_2.subtract(horizontalIrradiance_1).multiply(BigDecimal.valueOf(0.3 * (y + 1)))));
BigDecimal power_1 = sortList.get(i).getPower() == null ? new BigDecimal(0) : sortList.get(i).getPower(); BigDecimal power_1 = sortList.get(i).getPower() == null ? new BigDecimal(0) : sortList.get(i).getPower();
BigDecimal power_2 = sortList.get(I_i).getPower() == null ? new BigDecimal(0) : sortList.get(I_i).getPower(); BigDecimal power_2 = sortList.get(I_i).getPower() == null ? new BigDecimal(0) : sortList.get(I_i).getPower();
dao.setPower(power_1.add(power_2.subtract(power_1).multiply(new BigDecimal(0.3 * (y + 1))))); dao.setPower(power_1.add(power_2.subtract(power_1).multiply(BigDecimal.valueOf(0.3 * (y + 1)))));
batchList.add(dao); batchList.add(dao);
} }
} }
...@@ -261,20 +256,13 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -261,20 +256,13 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
batchList = new ArrayList<>(); batchList = new ArrayList<>();
} }
} }
if (batchList.size() > 0) if (CollUtil.isNotEmpty(batchList)) {
dataViewMapper.insertBatch(batchList); dataViewMapper.insertBatch(batchList);
// for (PlantPredictedPowerDataEnt item :allList ){ }
//
// batchList.add(item);
// if(batchList.size() > 0){
// dataViewMapper.insertBatch(batchList);
// batchList = new ArrayList<>();
// }
// }
//训练接口http://127.0.0.1:10098/aiprediction/xgbtrain?plantId=018a64635ac47cf58895147b0e1bf7e3 //训练接口http://127.0.0.1:10098/aiprediction/xgbtrain?plantId=018a64635ac47cf58895147b0e1bf7e3
//自动调用预测接口 //自动调用预测接口
HttpUtils.send2("http://127.0.0.1:10098/aiprediction/xgbreason?plantId=" + plantId, HttpUtils.send2("http://127.0.0.1:10098/aiprediction/xgbreason?plantId=" + plantId, "");
"");
} }
} catch (Exception e) { } catch (Exception e) {
context.getLogger().error(e.getMessage()); context.getLogger().error(e.getMessage());
...@@ -287,8 +275,8 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -287,8 +275,8 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
WeatherDataMapper mapper = context.getBean(WeatherDataMapper.class); WeatherDataMapper mapper = context.getBean(WeatherDataMapper.class);
Document document = Jsoup.parse(new URL(url), 30000); Document document = Jsoup.parse(new URL(url), 30000);
Elements elements = document.getElementsByClass("mt15"); // 获取class name 是‘mt15’的都有元素对象 Elements elements = document.getElementsByClass("mt15"); // 获取class name 是‘mt15’的都有元素对象
Element element = null; Element element;
if (elements == null || elements.size() <= 0) { if (elements.isEmpty()) {
return; return;
} else { } else {
element = elements.get(1); //根据页面结构获取到需要的元素对象 element = elements.get(1); //根据页面结构获取到需要的元素对象
...@@ -309,29 +297,29 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -309,29 +297,29 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
String dayTime; String dayTime;
BaseWatherEnt dao; BaseWatherEnt dao;
List<BaseWatherEnt> objList = new ArrayList<>(); List<BaseWatherEnt> objList = new ArrayList<>();
if (tables != null && tables.size() > 0) { if (!tables.isEmpty()) {
for (int i = 0; i < tables.size(); i++) { for (int i = 0; i < tables.size(); i++) {
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, i); calendar.add(Calendar.DATE, i);
date = calendar.getTime(); date = calendar.getTime();
dayTime = sdf.format(date); dayTime = sdf.format(date);
Elements trs = tables.get(i).select("tr"); Elements trs = tables.get(i).select("tr");
hourTimeArray = new ArrayList<>();// 时间 hourTimeArray = new ArrayList<>(10);// 时间
weatherArray = new ArrayList<>(); // 天气 weatherArray = new ArrayList<>(10); // 天气
temperatureArray = new ArrayList<>(); // 气温 temperatureArray = new ArrayList<>(10); // 气温
precipitationArray = new ArrayList<>(); // 降水 precipitationArray = new ArrayList<>(10); // 降水
windSpeedArray = new ArrayList<>(); // 风速 windSpeedArray = new ArrayList<>(10); // 风速
windDirectionArray = new ArrayList<>(); // 风向 windDirectionArray = new ArrayList<>(10); // 风向
pressureArray = new ArrayList<>(); // 气压 pressureArray = new ArrayList<>(10); // 气压
humidityArray = new ArrayList<>(); // 湿度 humidityArray = new ArrayList<>(10); // 湿度
cloudCoverArray = new ArrayList<>(); // 云量 cloudCoverArray = new ArrayList<>(10); // 云量
if (trs != null && trs.size() > 0) { if (!trs.isEmpty()) {
for (int j = 0; j < trs.size(); j++) { // 循环行 for (int j = 0; j < trs.size(); j++) { // 循环行
Elements tds = trs.get(j).select("td"); Elements tds = trs.get(j).select("td");
for (int k = 1; k < tds.size(); k++) { // 循环列 for (int k = 1; k < tds.size(); k++) { // 循环列
Element td = tds.get(k); Element td = tds.get(k);
String td_text; String td_text;
if ("wicon".equals(td.className())) if (CharSequenceUtil.equals("wicon", td.className()))
td_text = td.getElementsByTag("img").attr("src"); td_text = td.getElementsByTag("img").attr("src");
else else
td_text = td.text(); td_text = td.text();
...@@ -385,11 +373,10 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -385,11 +373,10 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
} else } else
continue; continue;
// 5.执行SQL // 5.执行SQL
QueryWrapper<BaseWatherEnt> queryWrapper = new QueryWrapper<>(); mapper.delete(new LambdaQueryWrapper<BaseWatherEnt>()
queryWrapper.lambda().eq(BaseWatherEnt::getProvinceCode, dao.getProvinceCode()) .eq(BaseWatherEnt::getProvinceCode, dao.getProvinceCode())
.eq(BaseWatherEnt::getCityCode, dao.getCityCode()) .eq(BaseWatherEnt::getCityCode, dao.getCityCode())
.eq(BaseWatherEnt::getDataDate, dao.getDayTime() + ' ' + dao.getHourTime()); .eq(BaseWatherEnt::getDataDate, dao.getDayTime() + ' ' + dao.getHourTime()));
mapper.delete(queryWrapper);
dao.setDataDate(dao.getDayTime() + ' ' + dao.getHourTime()); dao.setDataDate(dao.getDayTime() + ' ' + dao.getHourTime());
mapper.insert(dao); mapper.insert(dao);
objList.add(dao); objList.add(dao);
...@@ -406,22 +393,22 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -406,22 +393,22 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
dao.setProvinceName(provinceName); dao.setProvinceName(provinceName);
dao.setWeather(objList.get(i).getWeather()); dao.setWeather(objList.get(i).getWeather());
int I_i = i + 1; int I_i = i + 1;
Double temperature_1 = Double.parseDouble(objList.get(i).getTemperature()); double temperature_1 = Double.parseDouble(objList.get(i).getTemperature());
Double temperature_2 = Double.parseDouble(objList.get(I_i).getTemperature()); double temperature_2 = Double.parseDouble(objList.get(I_i).getTemperature());
dao.setTemperature((temperature_1 + (temperature_2 - temperature_1) * (0.3 * y)) + "℃"); dao.setTemperature((temperature_1 + (temperature_2 - temperature_1) * (0.3 * y)) + "℃");
dao.setPrecipitation(objList.get(i).getPrecipitation()); dao.setPrecipitation(objList.get(i).getPrecipitation());
Double windspeed_1 = Double.parseDouble(objList.get(i).getWindSpeed()); double windspeed_1 = Double.parseDouble(objList.get(i).getWindSpeed());
Double windspeed_2 = Double.parseDouble(objList.get(I_i).getWindSpeed()); double windspeed_2 = Double.parseDouble(objList.get(I_i).getWindSpeed());
dao.setWindSpeed((windspeed_1 + (windspeed_2 - windspeed_1) * (0.3 * y)) + "m/s"); dao.setWindSpeed((windspeed_1 + (windspeed_2 - windspeed_1) * (0.3 * y)) + "m/s");
dao.setWindDirection(objList.get(i).getWindDirection()); dao.setWindDirection(objList.get(i).getWindDirection());
Double pressure_1 = Double.parseDouble(objList.get(i).getPressure()); double pressure_1 = Double.parseDouble(objList.get(i).getPressure());
Double pressure_2 = Double.parseDouble(objList.get(I_i).getPressure()); double pressure_2 = Double.parseDouble(objList.get(I_i).getPressure());
dao.setPressure((pressure_1 + (pressure_2 - pressure_1) * (0.3 * y)) + "hPa"); dao.setPressure((pressure_1 + (pressure_2 - pressure_1) * (0.3 * y)) + "hPa");
Double humidity_1 = Double.parseDouble(objList.get(i).getHumidity()); double humidity_1 = Double.parseDouble(objList.get(i).getHumidity());
Double humidity_2 = Double.parseDouble(objList.get(I_i).getHumidity()); double humidity_2 = Double.parseDouble(objList.get(I_i).getHumidity());
dao.setHumidity((humidity_1 + (humidity_2 - humidity_1) * (0.3 * y)) + "%"); dao.setHumidity((humidity_1 + (humidity_2 - humidity_1) * (0.3 * y)) + "%");
Double cloudcover_1 = Double.parseDouble(objList.get(i).getCloudCover()); double cloudcover_1 = Double.parseDouble(objList.get(i).getCloudCover());
Double cloudcover_2 = Double.parseDouble(objList.get(I_i).getCloudCover()); double cloudcover_2 = Double.parseDouble(objList.get(I_i).getCloudCover());
dao.setCloudCover((cloudcover_1 + (cloudcover_2 - cloudcover_1) * (0.3 * y)) + "%"); dao.setCloudCover((cloudcover_1 + (cloudcover_2 - cloudcover_1) * (0.3 * y)) + "%");
if (23 == LocalTime.parse(objList.get(i).getHourTime()).getHour()) { if (23 == LocalTime.parse(objList.get(i).getHourTime()).getHour()) {
date = sdf.parse(objList.get(i).getDayTime()); date = sdf.parse(objList.get(i).getDayTime());
...@@ -433,7 +420,7 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -433,7 +420,7 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
dao.setHourTime("0" + (y - 1) + ":00:00"); dao.setHourTime("0" + (y - 1) + ":00:00");
} else { } else {
dao.setDayTime(objList.get(i).getDayTime()); dao.setDayTime(objList.get(i).getDayTime());
String Hour = ""; String Hour;
if ((LocalTime.parse(objList.get(i).getHourTime()).getHour() + y) < 10) { if ((LocalTime.parse(objList.get(i).getHourTime()).getHour() + y) < 10) {
Hour = "0" + (LocalTime.parse(objList.get(i).getHourTime()).getHour() + y) + ":00:00"; Hour = "0" + (LocalTime.parse(objList.get(i).getHourTime()).getHour() + y) + ":00:00";
} else { } else {
...@@ -442,11 +429,9 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -442,11 +429,9 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
dao.setHourTime(Hour); dao.setHourTime(Hour);
} }
// 5.执行SQL // 5.执行SQL
QueryWrapper<BaseWatherEnt> queryWrapper = new QueryWrapper<>(); mapper.delete(new LambdaQueryWrapper<BaseWatherEnt>().eq(BaseWatherEnt::getProvinceCode, dao.getProvinceCode())
queryWrapper.lambda().eq(BaseWatherEnt::getProvinceCode, dao.getProvinceCode())
.eq(BaseWatherEnt::getCityCode, dao.getCityCode()) .eq(BaseWatherEnt::getCityCode, dao.getCityCode())
.eq(BaseWatherEnt::getDataDate, dao.getDayTime() + ' ' + dao.getHourTime()); .eq(BaseWatherEnt::getDataDate, dao.getDayTime() + ' ' + dao.getHourTime()));
mapper.delete(queryWrapper);
dao.setDataDate(dao.getDayTime() + ' ' + dao.getHourTime()); dao.setDataDate(dao.getDayTime() + ' ' + dao.getHourTime());
mapper.insert(dao); mapper.insert(dao);
} }
...@@ -467,7 +452,7 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -467,7 +452,7 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
view.setIsDeleted(BusinessConstant.ONE); view.setIsDeleted(BusinessConstant.ONE);
List<BasePhotovoltaicPlantView> plantList = mapper.selectPlantDetailList(view); List<BasePhotovoltaicPlantView> plantList = mapper.selectPlantDetailList(view);
for (BasePhotovoltaicPlantView item : plantList) { for (BasePhotovoltaicPlantView item : plantList) {
if (XStringUtils.isNotEmpty(item.getCityCode()) && XStringUtils.isNotEmpty(item.getProvinceCode())) { if (CharSequenceUtil.isAllNotBlank(item.getCityCode(), item.getProvinceCode())) {
insertData(context, item.getId(), item.getProvinceCode(), item.getCityCode(), 1); insertData(context, item.getId(), item.getProvinceCode(), item.getCityCode(), 1);
} }
} }
...@@ -481,43 +466,37 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -481,43 +466,37 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
public XServiceResult crawlBaseWatherData(XContext context) { public XServiceResult crawlBaseWatherData(XContext context) {
try { try {
//请求省份接口。获取省份列表 //请求省份接口。获取省份列表
String provinceStr = HttpUtils.send2(provinceUrl, String provinceStr = HttpUtils.send2(provinceUrl, "");
"");
//解析省份列表字符串,把字符串解析成json对象 //解析省份列表字符串,把字符串解析成json对象
JSONObject jsonObject = JSONObject.parseObject(provinceStr); JSONObject jsonObject = JSONObject.parseObject(provinceStr);
//处理json对象,变为数组 //处理json对象,变为数组
String[] provinceList = jsonObject.getString("data").split("\\|"); String[] provinceList = CharSequenceUtil.splitToArray(jsonObject.getString("data"), '|');
for (String proStr : provinceList) { for (String proStr : provinceList) {
if (proStr != null && proStr != "") { if (CharSequenceUtil.isNotBlank(proStr)) {
String[] pro = proStr.split(","); String[] pro = CharSequenceUtil.splitToArray(proStr, ',');
String provinceCode = pro[0];//省编码 String provinceCode = pro[0];//省编码
String provinceName = pro[1];//省名称 String provinceName = pro[1];//省名称
//甘肃 .陕西 (全国周期抓取耗费时间超长,共有2400个城市) //甘肃 .陕西 (全国周期抓取耗费时间超长,共有2400个城市)
if (provinceCode.equals("AJL")) { if (CharSequenceUtil.equals(provinceCode, "AJL")) {
//请求省份下的区信息 //请求省份下的区信息
String cityString = HttpUtils.send2(cityUrl + provinceCode, ""); String cityString = HttpUtils.send2(cityUrl + provinceCode, "");
//解析区json,把字符串解析成json对象 //解析区json,把字符串解析成json对象
JSONObject cityObj = JSONObject.parseObject(cityString); JSONObject cityObj = JSONObject.parseObject(cityString);
//处理json对象,变为数组 //处理json对象,变为数组
String[] cityList = cityObj.getString("data").split("\\|"); String[] cityList = CharSequenceUtil.splitToArray(cityObj.getString("data"), '|');
for (String cityStr : cityList) { for (String cityStr : cityList) {
if (cityStr != null && cityStr != "") { if (CharSequenceUtil.isNotBlank(cityStr)) {
String[] city = cityStr.split(","); String[] city = CharSequenceUtil.splitToArray(cityStr, ',');
String cityCode = city[0];//区编码 String cityCode = city[0];//区编码
String cityName = city[1];//区名称 String cityName = city[1];//区名称
XThreadHelper.async(new Runnable() { XThreadHelper.async(() -> insertData(context, provinceCode, provinceName, cityCode, cityName, 1));
@Override
public void run() {
insertData(context, provinceCode, provinceName, cityCode, cityName, 1);
}
});
} }
} }
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
context.getLogger().error(e);
} }
return XServiceResult.OK; return XServiceResult.OK;
} }
......
package pps.core.base.service; package pps.core.base.service;
import cn.hutool.core.text.CharSequenceUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
...@@ -36,7 +37,7 @@ public class BaseWatherService { ...@@ -36,7 +37,7 @@ public class BaseWatherService {
Document document = Jsoup.parse(new URL(url), 30000); Document document = Jsoup.parse(new URL(url), 30000);
Elements elements = document.getElementsByClass("mt15"); // 获取class name 是‘mt15’的都有元素对象 Elements elements = document.getElementsByClass("mt15"); // 获取class name 是‘mt15’的都有元素对象
Element element; Element element;
if (elements == null || elements.size() <= 0) { if (elements.isEmpty()) {
return; return;
} else { } else {
element = elements.get(1); //根据页面结构获取到需要的元素对象 element = elements.get(1); //根据页面结构获取到需要的元素对象
...@@ -57,7 +58,7 @@ public class BaseWatherService { ...@@ -57,7 +58,7 @@ public class BaseWatherService {
String dayTime; String dayTime;
BaseWatherEnt dao; BaseWatherEnt dao;
List<BaseWatherEnt> objList = new ArrayList<>(); List<BaseWatherEnt> objList = new ArrayList<>();
if (tables != null && tables.size() > 0) { if (!tables.isEmpty()) {
for (int i = 0; i < tables.size(); i++) { for (int i = 0; i < tables.size(); i++) {
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, i); calendar.add(Calendar.DATE, i);
...@@ -73,7 +74,7 @@ public class BaseWatherService { ...@@ -73,7 +74,7 @@ public class BaseWatherService {
pressureArray = new ArrayList<>(); // 气压 pressureArray = new ArrayList<>(); // 气压
humidityArray = new ArrayList<>(); // 湿度 humidityArray = new ArrayList<>(); // 湿度
cloudCoverArray = new ArrayList<>(); // 云量 cloudCoverArray = new ArrayList<>(); // 云量
if (trs != null && trs.size() > 0) { if (!trs.isEmpty()) {
for (int j = 0; j < trs.size(); j++) { // 循环行 for (int j = 0; j < trs.size(); j++) { // 循环行
Elements tds = trs.get(j).select("td"); Elements tds = trs.get(j).select("td");
for (int k = 1; k < tds.size(); k++) { // 循环列 for (int k = 1; k < tds.size(); k++) { // 循环列
...@@ -133,11 +134,9 @@ public class BaseWatherService { ...@@ -133,11 +134,9 @@ public class BaseWatherService {
} else } else
continue; continue;
// 5.执行SQL // 5.执行SQL
QueryWrapper<BaseWatherEnt> queryWrapper = new QueryWrapper<>(); mapper.delete(new LambdaQueryWrapper<BaseWatherEnt>().eq(BaseWatherEnt::getProvinceCode, dao.getProvinceCode())
queryWrapper.lambda().eq(BaseWatherEnt::getProvinceCode, dao.getProvinceCode())
.eq(BaseWatherEnt::getCityCode, dao.getCityCode()) .eq(BaseWatherEnt::getCityCode, dao.getCityCode())
.eq(BaseWatherEnt::getDataDate, dao.getDayTime() + ' ' + dao.getHourTime()); .eq(BaseWatherEnt::getDataDate, dao.getDayTime() + ' ' + dao.getHourTime()));
mapper.delete(queryWrapper);
dao.setDataDate(dao.getDayTime() + ' ' + dao.getHourTime()); dao.setDataDate(dao.getDayTime() + ' ' + dao.getHourTime());
mapper.insert(dao); mapper.insert(dao);
objList.add(dao); objList.add(dao);
...@@ -154,22 +153,22 @@ public class BaseWatherService { ...@@ -154,22 +153,22 @@ public class BaseWatherService {
dao.setProvinceName(provinceName); dao.setProvinceName(provinceName);
dao.setWeather(objList.get(i).getWeather()); dao.setWeather(objList.get(i).getWeather());
int I_i = i + 1; int I_i = i + 1;
Double temperature_1 = Double.parseDouble(objList.get(i).getTemperature()); double temperature_1 = Double.parseDouble(objList.get(i).getTemperature());
Double temperature_2 = Double.parseDouble(objList.get(I_i).getTemperature()); double temperature_2 = Double.parseDouble(objList.get(I_i).getTemperature());
dao.setTemperature((temperature_1 + (temperature_2 - temperature_1) * (0.3 * y)) + "℃"); dao.setTemperature((temperature_1 + (temperature_2 - temperature_1) * (0.3 * y)) + "℃");
dao.setPrecipitation(objList.get(i).getPrecipitation()); dao.setPrecipitation(objList.get(i).getPrecipitation());
Double windspeed_1 = Double.parseDouble(objList.get(i).getWindSpeed()); double windspeed_1 = Double.parseDouble(objList.get(i).getWindSpeed());
Double windspeed_2 = Double.parseDouble(objList.get(I_i).getWindSpeed()); double windspeed_2 = Double.parseDouble(objList.get(I_i).getWindSpeed());
dao.setWindSpeed((windspeed_1 + (windspeed_2 - windspeed_1) * (0.3 * y)) + "m/s"); dao.setWindSpeed((windspeed_1 + (windspeed_2 - windspeed_1) * (0.3 * y)) + "m/s");
dao.setWindDirection(objList.get(i).getWindDirection()); dao.setWindDirection(objList.get(i).getWindDirection());
Double pressure_1 = Double.parseDouble(objList.get(i).getPressure()); double pressure_1 = Double.parseDouble(objList.get(i).getPressure());
Double pressure_2 = Double.parseDouble(objList.get(I_i).getPressure()); double pressure_2 = Double.parseDouble(objList.get(I_i).getPressure());
dao.setPressure((pressure_1 + (pressure_2 - pressure_1) * (0.3 * y)) + "hPa"); dao.setPressure((pressure_1 + (pressure_2 - pressure_1) * (0.3 * y)) + "hPa");
Double humidity_1 = Double.parseDouble(objList.get(i).getHumidity()); double humidity_1 = Double.parseDouble(objList.get(i).getHumidity());
Double humidity_2 = Double.parseDouble(objList.get(I_i).getHumidity()); double humidity_2 = Double.parseDouble(objList.get(I_i).getHumidity());
dao.setHumidity((humidity_1 + (humidity_2 - humidity_1) * (0.3 * y)) + "%"); dao.setHumidity((humidity_1 + (humidity_2 - humidity_1) * (0.3 * y)) + "%");
Double cloudcover_1 = Double.parseDouble(objList.get(i).getCloudCover()); double cloudcover_1 = Double.parseDouble(objList.get(i).getCloudCover());
Double cloudcover_2 = Double.parseDouble(objList.get(I_i).getCloudCover()); double cloudcover_2 = Double.parseDouble(objList.get(I_i).getCloudCover());
dao.setCloudCover((cloudcover_1 + (cloudcover_2 - cloudcover_1) * (0.3 * y)) + "%"); dao.setCloudCover((cloudcover_1 + (cloudcover_2 - cloudcover_1) * (0.3 * y)) + "%");
if (23 == LocalTime.parse(objList.get(i).getHourTime()).getHour()) { if (23 == LocalTime.parse(objList.get(i).getHourTime()).getHour()) {
date = sdf.parse(objList.get(i).getDayTime()); date = sdf.parse(objList.get(i).getDayTime());
...@@ -190,11 +189,10 @@ public class BaseWatherService { ...@@ -190,11 +189,10 @@ public class BaseWatherService {
dao.setHourTime(Hour); dao.setHourTime(Hour);
} }
// 5.执行SQL // 5.执行SQL
QueryWrapper<BaseWatherEnt> queryWrapper = new QueryWrapper<>(); mapper.delete(new LambdaQueryWrapper<BaseWatherEnt>()
queryWrapper.lambda().eq(BaseWatherEnt::getProvinceCode, dao.getProvinceCode()) .eq(BaseWatherEnt::getProvinceCode, dao.getProvinceCode())
.eq(BaseWatherEnt::getCityCode, dao.getCityCode()) .eq(BaseWatherEnt::getCityCode, dao.getCityCode())
.eq(BaseWatherEnt::getDataDate, dao.getDayTime() + ' ' + dao.getHourTime()); .eq(BaseWatherEnt::getDataDate, dao.getDayTime() + ' ' + dao.getHourTime()));
mapper.delete(queryWrapper);
dao.setDataDate(dao.getDayTime() + ' ' + dao.getHourTime()); dao.setDataDate(dao.getDayTime() + ' ' + dao.getHourTime());
mapper.insert(dao); mapper.insert(dao);
} }
...@@ -216,23 +214,23 @@ public class BaseWatherService { ...@@ -216,23 +214,23 @@ public class BaseWatherService {
//解析省份列表字符串,把字符串解析成json对象 //解析省份列表字符串,把字符串解析成json对象
JSONObject jsonObject = JSONObject.parseObject(provinceStr); JSONObject jsonObject = JSONObject.parseObject(provinceStr);
//处理json对象,变为数组 //处理json对象,变为数组
String[] provinceList = jsonObject.getString("data").split("\\|"); String[] provinceList = CharSequenceUtil.splitToArray(jsonObject.getString("data"), '|');
for (String proStr : provinceList) { for (String proStr : provinceList) {
if (proStr != null && proStr != "") { if (CharSequenceUtil.isNotBlank(proStr)) {
String[] pro = proStr.split(","); String[] pro = CharSequenceUtil.splitToArray(proStr, ',');
String provinceCode = pro[0];//省编码 String provinceCode = pro[0];//省编码
String provinceName = pro[1];//省名称 String provinceName = pro[1];//省名称
//甘肃 .陕西 (全国周期抓取耗费时间超长,共有2400个城市) //甘肃 .陕西 (全国周期抓取耗费时间超长,共有2400个城市)
if (provinceCode.equals("AJL")) { if (CharSequenceUtil.equals(provinceCode, "AJL")) {
//请求省份下的区信息 //请求省份下的区信息
String cityString = HttpUtils.send2(cityUrl + provinceCode, ""); String cityString = HttpUtils.send2(cityUrl + provinceCode, "");
//解析区json,把字符串解析成json对象 //解析区json,把字符串解析成json对象
JSONObject cityObj = JSONObject.parseObject(cityString); JSONObject cityObj = JSONObject.parseObject(cityString);
//处理json对象,变为数组 //处理json对象,变为数组
String[] cityList = cityObj.getString("data").split("\\|"); String[] cityList = CharSequenceUtil.splitToArray(cityObj.getString("data"), '|');
for (String cityStr : cityList) { for (String cityStr : cityList) {
if (cityStr != null && cityStr != "") { if (CharSequenceUtil.isNotBlank(cityStr)) {
String[] city = cityStr.split(","); String[] city = CharSequenceUtil.splitToArray(cityStr, ',');
String cityCode = city[0];//区编码 String cityCode = city[0];//区编码
String cityName = city[1];//区名称 String cityName = city[1];//区名称
XThreadHelper.async(() -> insertData(context, provinceCode, provinceName, cityCode, cityName, 1)); XThreadHelper.async(() -> insertData(context, provinceCode, provinceName, cityCode, cityName, 1));
...@@ -242,7 +240,7 @@ public class BaseWatherService { ...@@ -242,7 +240,7 @@ public class BaseWatherService {
} }
} }
} catch (Exception e) { } catch (Exception e) {
context.getLogger().error(e.getMessage());
} }
return XServiceResult.OK; return XServiceResult.OK;
} }
......
...@@ -422,7 +422,8 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService { ...@@ -422,7 +422,8 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
); );
// 5.执行SQL // 5.执行SQL
allList.add(dao); allList.add(dao);
PlantPredictedPowerDataEnt isExit = objList.stream().filter(item -> PlantPredictedPowerDataEnt isExit = objList.stream()
.filter(item ->
CharSequenceUtil.equals(item.getYearTime(), dao.getYearTime()) && CharSequenceUtil.equals(item.getYearTime(), dao.getYearTime()) &&
CharSequenceUtil.equals(item.getMonthTime(), dao.getMonthTime()) && CharSequenceUtil.equals(item.getMonthTime(), dao.getMonthTime()) &&
CharSequenceUtil.equals(item.getDayTime(), dao.getDayTime()) && CharSequenceUtil.equals(item.getDayTime(), dao.getDayTime()) &&
......
...@@ -125,9 +125,8 @@ public class ExcelService { ...@@ -125,9 +125,8 @@ public class ExcelService {
.registerWriteHandler(new CascadeWriteHandler(provNameList, siteMap)) .registerWriteHandler(new CascadeWriteHandler(provNameList, siteMap))
.autoCloseStream(Boolean.TRUE) .autoCloseStream(Boolean.TRUE)
.build() .build()
.write(list, .write(list, EasyExcelUtil.writeSelectedSheet(ExcelPhotovoltaicPlantTemplate.class, 0, "光伏电站配置"))
EasyExcelUtil.writeSelectedSheet(ExcelPhotovoltaicPlantTemplate.class, 0, "光伏电站配置") .finish();
).finish();
return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath); return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath);
} }
...@@ -171,9 +170,8 @@ public class ExcelService { ...@@ -171,9 +170,8 @@ public class ExcelService {
.registerWriteHandler(ExcelStyleTool.getStyleStrategy()) .registerWriteHandler(ExcelStyleTool.getStyleStrategy())
.autoCloseStream(Boolean.TRUE) .autoCloseStream(Boolean.TRUE)
.build() .build()
.write(list, .write(list, EasyExcelUtil.writeSelectedSheet(ExcelWellheadTemplate.class, 0, "井口配置"))
EasyExcelUtil.writeSelectedSheet(ExcelWellheadTemplate.class, 0, "井口配置") .finish();
).finish();
return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath); return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath);
} }
...@@ -218,9 +216,8 @@ public class ExcelService { ...@@ -218,9 +216,8 @@ public class ExcelService {
.registerWriteHandler(ExcelStyleTool.getStyleStrategy()) .registerWriteHandler(ExcelStyleTool.getStyleStrategy())
.autoCloseStream(Boolean.TRUE) .autoCloseStream(Boolean.TRUE)
.build() .build()
.write(list, .write(list, EasyExcelUtil.writeSelectedSheet(ExcelDieselGeneratorTemplate.class, 0, "柴发设备配置"))
EasyExcelUtil.writeSelectedSheet(ExcelDieselGeneratorTemplate.class, 0, "柴发设备配置") .finish();
).finish();
return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath); return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath);
} }
...@@ -268,9 +265,8 @@ public class ExcelService { ...@@ -268,9 +265,8 @@ public class ExcelService {
.registerWriteHandler(ExcelStyleTool.getStyleStrategy()) .registerWriteHandler(ExcelStyleTool.getStyleStrategy())
.autoCloseStream(Boolean.TRUE) .autoCloseStream(Boolean.TRUE)
.build() .build()
.write(list, .write(list, EasyExcelUtil.writeSelectedSheet(ExcelEnergyStorageDeviceTemplate.class, 0, "储能设备配置"))
EasyExcelUtil.writeSelectedSheet(ExcelEnergyStorageDeviceTemplate.class, 0, "储能设备配置") .finish();
).finish();
return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath); return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath);
} }
...@@ -320,9 +316,8 @@ public class ExcelService { ...@@ -320,9 +316,8 @@ public class ExcelService {
.registerWriteHandler(ExcelStyleTool.getStyleStrategy()) .registerWriteHandler(ExcelStyleTool.getStyleStrategy())
.autoCloseStream(Boolean.TRUE) .autoCloseStream(Boolean.TRUE)
.build() .build()
.write(list, .write(list, EasyExcelUtil.writeSelectedSheet(ExcelPriceStrategyTemplate.class, 0, "市电峰谷配置"))
EasyExcelUtil.writeSelectedSheet(ExcelPriceStrategyTemplate.class, 0, "市电峰谷配置") .finish();
).finish();
return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath); return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath);
} }
...@@ -350,8 +345,8 @@ public class ExcelService { ...@@ -350,8 +345,8 @@ public class ExcelService {
//封装并校验电站名称(校验电站名称是否重复,重复不导入),并插入数据 //封装并校验电站名称(校验电站名称是否重复,重复不导入),并插入数据
Set<String> collect = context.getBean(BasePhotovoltaicPlantMapper.class) Set<String> collect = context.getBean(BasePhotovoltaicPlantMapper.class)
.selectList(new LambdaQueryWrapper<BasePhotovoltaicPlantEnt>() .selectList(new LambdaQueryWrapper<BasePhotovoltaicPlantEnt>()
.eq(BaseModel::getIsDeleted, 1) .eq(BaseModel::getIsDeleted, 1))
).stream() .stream()
.map(BasePhotovoltaicPlantEnt::getStationName) .map(BasePhotovoltaicPlantEnt::getStationName)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<Integer> errorRowList = new ArrayList<>(list.size()); List<Integer> errorRowList = new ArrayList<>(list.size());
...@@ -417,8 +412,8 @@ public class ExcelService { ...@@ -417,8 +412,8 @@ public class ExcelService {
//封装并校验井号(校验井号是否重复,重复不导入),并插入数据 //封装并校验井号(校验井号是否重复,重复不导入),并插入数据
Set<String> collect = context.getBean(BaseWellheadMapper.class) Set<String> collect = context.getBean(BaseWellheadMapper.class)
.selectList(new LambdaQueryWrapper<BaseWellheadEnt>() .selectList(new LambdaQueryWrapper<BaseWellheadEnt>()
.eq(BaseModel::getIsDeleted, 1) .eq(BaseModel::getIsDeleted, 1))
).stream() .stream()
.map(BaseWellheadEnt::getWellNumber) .map(BaseWellheadEnt::getWellNumber)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<Integer> errorRowList = new ArrayList<>(list.size()); List<Integer> errorRowList = new ArrayList<>(list.size());
...@@ -477,8 +472,8 @@ public class ExcelService { ...@@ -477,8 +472,8 @@ public class ExcelService {
//封装并校验设备名称(校验设备名称是否重复,重复不导入),并插入数据 //封装并校验设备名称(校验设备名称是否重复,重复不导入),并插入数据
Set<String> collect = context.getBean(BaseDieselGeneratorMapper.class) Set<String> collect = context.getBean(BaseDieselGeneratorMapper.class)
.selectList(new LambdaQueryWrapper<BaseDieselGeneratorEnt>() .selectList(new LambdaQueryWrapper<BaseDieselGeneratorEnt>()
.eq(BaseModel::getIsDeleted, 1) .eq(BaseModel::getIsDeleted, 1))
).stream() .stream()
.map(BaseDieselGeneratorEnt::getDeviceName) .map(BaseDieselGeneratorEnt::getDeviceName)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<Integer> errorRowList = new ArrayList<>(list.size()); List<Integer> errorRowList = new ArrayList<>(list.size());
...@@ -537,8 +532,8 @@ public class ExcelService { ...@@ -537,8 +532,8 @@ public class ExcelService {
//封装并校验设备名称(校验设备名称是否重复,重复不导入),并插入数据 //封装并校验设备名称(校验设备名称是否重复,重复不导入),并插入数据
Set<String> collect = context.getBean(BaseEnergyStorageDeviceMapper.class) Set<String> collect = context.getBean(BaseEnergyStorageDeviceMapper.class)
.selectList(new LambdaQueryWrapper<BaseEnergyStorageDeviceEnt>() .selectList(new LambdaQueryWrapper<BaseEnergyStorageDeviceEnt>()
.eq(BaseModel::getIsDeleted, 1) .eq(BaseModel::getIsDeleted, 1))
).stream() .stream()
.map(BaseEnergyStorageDeviceEnt::getDeviceName) .map(BaseEnergyStorageDeviceEnt::getDeviceName)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<Integer> errorRowList = new ArrayList<>(list.size()); List<Integer> errorRowList = new ArrayList<>(list.size());
......
...@@ -3,6 +3,7 @@ package pps.core.base.service; ...@@ -3,6 +3,7 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.core.base.entity.SysPageInfoEnt; import pps.core.base.entity.SysPageInfoEnt;
import pps.core.base.mapper.SysPageInfoMapper; import pps.core.base.mapper.SysPageInfoMapper;
...@@ -49,8 +50,7 @@ public class SysPageInfoService { ...@@ -49,8 +50,7 @@ public class SysPageInfoService {
public XServiceResult updateSysPageInfo(XContext context, UpdateSysPageInfoInput input) { public XServiceResult updateSysPageInfo(XContext context, UpdateSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class); SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
PpsUserSession session = context.getSession(PpsUserSession.class); PpsUserSession session = context.getSession(PpsUserSession.class);
SysPageInfoEnt entity = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>() SysPageInfoEnt entity = mapper.selectOne(new LambdaQueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getId, input.getId())); .eq(SysPageInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
...@@ -75,8 +75,7 @@ public class SysPageInfoService { ...@@ -75,8 +75,7 @@ public class SysPageInfoService {
@XApiPost @XApiPost
public XServiceResult deleteSysPageInfo(XContext context, DeleteSysPageInfoInput input) { public XServiceResult deleteSysPageInfo(XContext context, DeleteSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class); SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
SysPageInfoEnt entity = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>() SysPageInfoEnt entity = mapper.selectOne(new LambdaQueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getId, input.getId())); .eq(SysPageInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound); return XServiceResult.error(context, XError.NotFound);
...@@ -89,8 +88,7 @@ public class SysPageInfoService { ...@@ -89,8 +88,7 @@ public class SysPageInfoService {
@XApiGet @XApiGet
public XSingleResult<GetSysPageInfoOutput> getSysPageInfo(XContext context, GetSysPageInfoInput input) { public XSingleResult<GetSysPageInfoOutput> getSysPageInfo(XContext context, GetSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class); SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
SysPageInfoEnt entity = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>() SysPageInfoEnt entity = mapper.selectOne(new LambdaQueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getId, input.getId())); .eq(SysPageInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound); return XSingleResult.error(context, XError.NotFound);
...@@ -105,16 +103,11 @@ public class SysPageInfoService { ...@@ -105,16 +103,11 @@ public class SysPageInfoService {
public XPageResult<QuerySysPageInfoOutput> querySysPageInfo(XContext context, QuerySysPageInfoInput input) { public XPageResult<QuerySysPageInfoOutput> querySysPageInfo(XContext context, QuerySysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class); SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
QueryWrapper<SysPageInfoEnt> queryWrapper = new QueryWrapper<>(); QueryWrapper<SysPageInfoEnt> queryWrapper = new QueryWrapper<>();
if (CharSequenceUtil.isNotBlank(input.getPageId())) { queryWrapper.lambda()
queryWrapper.lambda().eq(SysPageInfoEnt::getPageId, input.getPageId()); .eq(CharSequenceUtil.isNotBlank(input.getPageId()), SysPageInfoEnt::getPageId, input.getPageId())
} .eq(ObjectUtil.isNotNull(input.getReleaseState()), SysPageInfoEnt::getReleaseState, input.getReleaseState())
if (CharSequenceUtil.isNotBlank(input.getPageName())) { .like(CharSequenceUtil.isNotBlank(input.getPageName()), SysPageInfoEnt::getPageName, input.getPageName())
queryWrapper.lambda().like(SysPageInfoEnt::getPageName, input.getPageName()); .orderByDesc(SysPageInfoEnt::getCreateTime);
}
if (ObjectUtil.isNotNull(input.getReleaseState())) {
queryWrapper.lambda().eq(SysPageInfoEnt::getReleaseState, input.getReleaseState());
}
queryWrapper.lambda().orderByDesc(SysPageInfoEnt::getCreateTime);
return XMapperHelper.query(mapper, input, queryWrapper, QuerySysPageInfoOutput.class); return XMapperHelper.query(mapper, input, queryWrapper, QuerySysPageInfoOutput.class);
} }
...@@ -123,12 +116,10 @@ public class SysPageInfoService { ...@@ -123,12 +116,10 @@ public class SysPageInfoService {
public XServiceResult releasePageInfo(XContext context, GetSysPageInfoInput input) { public XServiceResult releasePageInfo(XContext context, GetSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class); SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
//根据id查询需要发布的数据 //根据id查询需要发布的数据
SysPageInfoEnt sysPageInfoEnt = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>() SysPageInfoEnt sysPageInfoEnt = mapper.selectOne(new LambdaQueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getId, input.getId())); .eq(SysPageInfoEnt::getId, input.getId()));
//查询当前页面处于发布状态的版本删除 //查询当前页面处于发布状态的版本删除
List<SysPageInfoEnt> sysPageInfos = mapper.selectList(new QueryWrapper<SysPageInfoEnt>() List<SysPageInfoEnt> sysPageInfos = mapper.selectList(new LambdaQueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getPageId, sysPageInfoEnt.getPageId()) .eq(SysPageInfoEnt::getPageId, sysPageInfoEnt.getPageId())
.eq(SysPageInfoEnt::getReleaseVersion, 1)); .eq(SysPageInfoEnt::getReleaseVersion, 1));
if (CollUtil.isNotEmpty(sysPageInfos)) { if (CollUtil.isNotEmpty(sysPageInfos)) {
...@@ -136,16 +127,14 @@ public class SysPageInfoService { ...@@ -136,16 +127,14 @@ public class SysPageInfoService {
mapper.deleteById(pageInfoEnt); mapper.deleteById(pageInfoEnt);
} }
//查询发布的最大版本号 //查询发布的最大版本号
List<SysPageInfoEnt> sysPageInfoEnts = mapper.selectList(new QueryWrapper<SysPageInfoEnt>() List<SysPageInfoEnt> sysPageInfoEnts = mapper.selectList(new LambdaQueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getPageId, sysPageInfoEnt.getPageId()) .eq(SysPageInfoEnt::getPageId, sysPageInfoEnt.getPageId())
.isNotNull(SysPageInfoEnt::getReleaseVersion) .isNotNull(SysPageInfoEnt::getReleaseVersion)
.orderByDesc(SysPageInfoEnt::getReleaseVersion)); .orderByDesc(SysPageInfoEnt::getReleaseVersion));
if (CollUtil.isNotEmpty(sysPageInfoEnts)) { if (CollUtil.isNotEmpty(sysPageInfoEnts)) {
SysPageInfoEnt sysPageInfo = sysPageInfoEnts.get(0); SysPageInfoEnt sysPageInfo = sysPageInfoEnts.get(0);
if (ObjectUtil.isNotNull(sysPageInfo.getReleaseVersion())) { if (ObjectUtil.isNotNull(sysPageInfo.getReleaseVersion())) {
Integer version = sysPageInfo.getReleaseVersion() + 1; sysPageInfoEnt.setReleaseVersion(sysPageInfo.getReleaseVersion() + 1);
sysPageInfoEnt.setReleaseVersion(version);
} else { } else {
sysPageInfoEnt.setReleaseVersion(1); sysPageInfoEnt.setReleaseVersion(1);
} }
...@@ -162,8 +151,7 @@ public class SysPageInfoService { ...@@ -162,8 +151,7 @@ public class SysPageInfoService {
@XApiGet @XApiGet
public XSingleResult<GetSysPageInfoOutput> getSysPageInfoByPageId(XContext context, GetSysPageInfoInput input) { public XSingleResult<GetSysPageInfoOutput> getSysPageInfoByPageId(XContext context, GetSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class); SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
SysPageInfoEnt entity = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>() SysPageInfoEnt entity = mapper.selectOne(new LambdaQueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getPageId, input.getPageId()) .eq(SysPageInfoEnt::getPageId, input.getPageId())
.eq(SysPageInfoEnt::getReleaseState, 1)); .eq(SysPageInfoEnt::getReleaseState, 1));
if (ObjectUtil.isNull(entity)) { if (ObjectUtil.isNull(entity)) {
......
...@@ -23,8 +23,6 @@ import java.util.List; ...@@ -23,8 +23,6 @@ import java.util.List;
*/ */
public class ReceivedIMAPMail { public class ReceivedIMAPMail {
public static String NORM_DATETIME_PATTERN = "yyyy-MM-dd hh:mm:ss";
private MimeMessage mimeMessage; private MimeMessage mimeMessage;
/** /**
...@@ -146,6 +144,7 @@ public class ReceivedIMAPMail { ...@@ -146,6 +144,7 @@ public class ReceivedIMAPMail {
for (Flags.Flag value : flag) { for (Flags.Flag value : flag) {
if (value == Flags.Flag.SEEN) { if (value == Flags.Flag.SEEN) {
isNew = true; isNew = true;
break;
} }
} }
return isNew; return isNew;
......
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