Commit e1459c0f authored by ZWT's avatar ZWT

feat(吉林演示): 松原

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

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 022c27bb
......@@ -39,7 +39,7 @@ public class SysAreaService {
public XListResult<GetSysAreaViewOutputTree> getSysAreaTree(XContext context, GetSysAreaInput input) {
//先从缓存中获取
List<SysAreaCache> sysAreaCaches = SysAreaCache.list(context, BusinessConstant.SYS_AREA_CACHE);
if (ObjectUtils.isNotEmpty(input.getLev()) && input.getLev() == 1) {
if (ObjectUtil.isNotNull(input.getLev()) && input.getLev() == 1) {
List<SysAreaCache> items = new ArrayList<>();
for (SysAreaCache ent : sysAreaCaches) {
if (CollUtil.isNotEmpty(ent.getChildren())) {
......@@ -52,7 +52,7 @@ public class SysAreaService {
if (CollUtil.isEmpty(sysAreaCaches)) {
List<SysAreaCache> caches = selectSysAreaTree(context, input);
List<GetSysAreaViewOutputTree> resultTree = XCopyUtils.copyNewList(caches, GetSysAreaViewOutputTree.class);
if (ObjectUtils.isNotEmpty(input.getLev()) && input.getLev() == 1) {
if (ObjectUtil.isNotNull(input.getLev()) && input.getLev() == 1) {
List<GetSysAreaViewOutputTree> items = new ArrayList<>();
for (GetSysAreaViewOutputTree ent : resultTree) {
if (CollUtil.isNotEmpty(ent.getChildren())) {
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.ObjectUtils;
import pps.cloud.system.service.SystemDictionaryService;
import pps.cloud.system.service.data.sys_dictionary.*;
import pps.core.system.cache.SysDictionaryCache;
......@@ -33,42 +34,43 @@ public class SysDictionaryServiceImpl implements SystemDictionaryService {
SysOrganizationDictionaryMapper orgDicmapper = context.getBean(SysOrganizationDictionaryMapper.class);
SysOrganizationRelMapper orgRelMapper = context.getBean(SysOrganizationRelMapper.class);
List<SysDictionaryCache> list = SysDictionaryCache.list(context, input.getAlias());
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getAlias, input.getAlias());
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(queryWrapper);
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getAlias, input.getAlias()));
list = list.stream().filter((SysDictionaryCache dic) -> CharSequenceUtil.equals(dic.getPid(), sysDictionaryEnt.getId()) && !CharSequenceUtil.equals(dic.getAlias(), input.getAlias()))
.collect(Collectors.toList());
if (ObjectUtils.isEmpty(list)) {
if (CollUtil.isEmpty(list)) {
list = new ArrayList<>();
SysDictionaryCache.set(context, input.getAlias(), list);
//查询alias字典
QueryWrapper<SysDictionaryEnt> query = new QueryWrapper<>();
query.lambda().eq(SysDictionaryEnt::getAlias, input.getAlias()).gt(SysDictionaryEnt::getEndTime, new Date());
SysDictionaryEnt sysDictionary = mapper.selectOne(query);
if (ObjectUtils.isNotEmpty(sysDictionary)) {
SysDictionaryEnt sysDictionary = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getAlias, input.getAlias())
.gt(SysDictionaryEnt::getEndTime, new Date()));
if (ObjectUtil.isNotNull(sysDictionary)) {
SysDictionaryCache sysDictionaryCache = new SysDictionaryCache();
XCopyUtils.copyObject(sysDictionary, sysDictionaryCache);
list.add(sysDictionaryCache);
//查询alias字典下级字典项
QueryWrapper<SysDictionaryEnt> queryItems = new QueryWrapper<>();
if (ObjectUtils.isNotEmpty(sysDictionary.getIsOrg()) && sysDictionary.getIsOrg() == 1) {
if (ObjectUtil.isNotNull(sysDictionary.getIsOrg()) && sysDictionary.getIsOrg() == 1) {
//查询当前登录人的组织机构层级路径
QueryWrapper<SysOrganizationRelEnt> queryOrgRel = new QueryWrapper<>();
queryOrgRel.lambda().eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.gt(SysOrganizationRelEnt::getEndTime, new Date());
SysOrganizationRelEnt sysOrganizationRelEnt = orgRelMapper.selectOne(queryOrgRel);
SysOrganizationRelEnt sysOrganizationRelEnt = orgRelMapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.gt(SysOrganizationRelEnt::getEndTime, new Date()));
//根据字典id查询
QueryWrapper<SysOrganizationDictionaryEnt> queryOrgDic = new QueryWrapper<>();
queryOrgDic.lambda().eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionary.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date());
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(queryOrgDic);
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(new QueryWrapper<SysOrganizationDictionaryEnt>()
.lambda()
.eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionary.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date()));
String ouIdPath = sysOrganizationRelEnt.getOuIdPath();
String ouId = sysOrganizationRelEnt.getOuId();
if (CharSequenceUtil.isNotBlank(ouIdPath)) {
List<String> dicIds = sysOrganizationDictionaryEnts.stream().map(p -> {
if (ouIdPath.contains(p.getOuId()) && p.getUseLowerLevel() == 1) {
if (CharSequenceUtil.contains(ouIdPath, p.getOuId()) && p.getUseLowerLevel() == 1) {
return p.getDicCode();
} else if (ouId.contains(p.getOuId())) {
} else if (CharSequenceUtil.contains(ouId, p.getOuId())) {
return p.getDicCode();
} else {
return "1";
......@@ -79,8 +81,8 @@ public class SysDictionaryServiceImpl implements SystemDictionaryService {
}
queryItems.lambda().eq(SysDictionaryEnt::getPid, sysDictionaryCache.getId()).gt(SysDictionaryEnt::getEndTime, new Date());
List<SysDictionaryEnt> sysDictionaryList = mapper.selectList(queryItems);
if (ObjectUtils.isNotEmpty(sysDictionaryList)) {
if (ObjectUtils.isNotEmpty(list)) {
if (CollUtil.isNotEmpty(sysDictionaryList)) {
if (CollUtil.isNotEmpty(list)) {
for (SysDictionaryEnt ent : sysDictionaryList) {
SysDictionaryCache cache = new SysDictionaryCache();
XCopyUtils.copyObject(ent, cache);
......@@ -88,7 +90,7 @@ public class SysDictionaryServiceImpl implements SystemDictionaryService {
}
}
sysDictionaryList.sort((o1, o2) -> {
if (ObjectUtils.isNotEmpty(o1.getSort()) && ObjectUtils.isNotEmpty(o2.getSort())) {
if (ObjectUtil.isNotNull(o1.getSort()) && ObjectUtil.isNotNull(o2.getSort())) {
return o1.getSort() - o2.getSort();
} else {
return 0;
......@@ -99,34 +101,34 @@ public class SysDictionaryServiceImpl implements SystemDictionaryService {
}
}
}
if (sysDictionaryEnt != null && ObjectUtils.isNotEmpty(sysDictionaryEnt.getIsOrg()) && sysDictionaryEnt.getIsOrg() == 1) {
if (ObjectUtil.isNotNull(sysDictionaryEnt) && ObjectUtil.isNotNull(sysDictionaryEnt.getIsOrg()) && sysDictionaryEnt.getIsOrg() == 1) {
//查询当前登录人的组织机构层级路径
QueryWrapper<SysOrganizationRelEnt> queryOrgRel = new QueryWrapper<>();
queryOrgRel.lambda().eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.gt(SysOrganizationRelEnt::getEndTime, new Date());
SysOrganizationRelEnt sysOrganizationRelEnt = orgRelMapper.selectOne(queryOrgRel);
SysOrganizationRelEnt sysOrganizationRelEnt = orgRelMapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.gt(SysOrganizationRelEnt::getEndTime, new Date()));
//根据字典id查询
QueryWrapper<SysOrganizationDictionaryEnt> queryOrgDic = new QueryWrapper<>();
queryOrgDic.lambda().eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionaryEnt.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date());
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(queryOrgDic);
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(new QueryWrapper<SysOrganizationDictionaryEnt>()
.lambda()
.eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionaryEnt.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date()));
String ouIdPath = sysOrganizationRelEnt.getOuIdPath();
String ouId = sysOrganizationRelEnt.getOuId();
if (CharSequenceUtil.isNotBlank(ouIdPath)) {
List<String> dicIds = sysOrganizationDictionaryEnts.stream().map(p -> {
if (ouIdPath.contains(p.getOuId()) && p.getUseLowerLevel() == 1) {
if (CharSequenceUtil.contains(ouIdPath, p.getOuId()) && p.getUseLowerLevel() == 1) {
return p.getDicCode();
} else if (ouId.contains(p.getOuId())) {
} else if (CharSequenceUtil.contains(ouId, p.getOuId())) {
return p.getDicCode();
} else {
return "1";
}
}).collect(Collectors.toList());
list = list.stream().filter(i -> dicIds.contains(i.getId())).collect(Collectors.toList());
list = list.stream().filter(i -> CollUtil.contains(dicIds, i.getId())).collect(Collectors.toList());
}
}
list.sort((o1, o2) -> {
if (ObjectUtils.isNotEmpty(o1.getSort()) && ObjectUtils.isNotEmpty(o2.getSort())) {
if (ObjectUtil.isNotNull(o1.getSort()) && ObjectUtil.isNotNull(o2.getSort())) {
return o1.getSort() - o2.getSort();
} else {
return 0;
......@@ -141,7 +143,7 @@ public class SysDictionaryServiceImpl implements SystemDictionaryService {
List<QuerySysDictionaryViewOutput> resultList = new ArrayList<>();
SysDictionaryMapper sysDictionaryMapper = context.getBean(SysDictionaryMapper.class);
List<SysDictionaryEnt> list = sysDictionaryMapper.selectList(new QueryWrapper<SysDictionaryEnt>().eq("alias", input.getAlias()));
if (list.isEmpty()) {
if (CollUtil.isEmpty(list)) {
return XListResult.success(resultList);
}
SysDictionaryEnt parentDictionaryEnt = list.get(0);
......
......@@ -8,7 +8,6 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils;
import pps.cloud.system.service.data.sys_dictionary.QuerySysDictionaryViewOutput;
import pps.core.common.session.PpsUserSession;
import pps.core.system.entity.SysDictionaryEnt;
......@@ -130,7 +129,7 @@ public class SysOrganizationDictionaryService {
SysOrganizationDictionaryMapper mapper = context.getBean(SysOrganizationDictionaryMapper.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = mapper.selectList(queryWrapper);
if (ObjectUtils.isNotEmpty(sysOrganizationDictionaryEnts)) {
if (CollUtil.isNotEmpty(sysOrganizationDictionaryEnts)) {
for (SysOrganizationDictionaryEnt ent : sysOrganizationDictionaryEnts) {
ent.setEndTime(new Date());
ent.setModifyTime(new Date());
......@@ -141,7 +140,7 @@ public class SysOrganizationDictionaryService {
}
//查询单位属性表是否还有字典,如果没有删除字典表中标记
SysDictionaryMapper dicMapper = context.getBean(SysDictionaryMapper.class);
if (ObjectUtils.isNotEmpty(sysDictionaryViews)) {
if (CollUtil.isNotEmpty(sysDictionaryViews)) {
for (SysDictionaryView dicView : sysDictionaryViews) {
SysDictionaryEnt ent = new SysDictionaryEnt();
ent.setId(dicView.getId());
......@@ -241,7 +240,7 @@ public class SysOrganizationDictionaryService {
dictionaryViews = dictionaryViewMapper.selectChildListByCondition(recordView);
}
SysDictionaryMapper dictionaryMapper = context.getBean(SysDictionaryMapper.class);
if (ObjectUtils.isNotEmpty(dictionaryViews)) {
if (CollUtil.isNotEmpty(dictionaryViews)) {
List<String> pidList = dictionaryViews.stream().map(SysDictionaryView::getId
).distinct().collect(Collectors.toList());
List<SysDictionaryEnt> sysDictionaryList = dictionaryMapper.selectList(new QueryWrapper<SysDictionaryEnt>()
......
......@@ -2,6 +2,9 @@ package pps.core.base.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.core.base.entity.BaseDataEnt;
import pps.core.base.entity.BaseDataImportLogEnt;
......@@ -26,7 +29,6 @@ import xstartup.base.tool.XStorageTool;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XDateUtils;
import xstartup.base.util.XJsonUtils;
import xstartup.base.util.XStringUtils;
import xstartup.data.*;
import xstartup.error.XError;
import xstartup.feature.api.annotation.XApiGet;
......@@ -53,10 +55,10 @@ public class BaseDataService {
@XApiPost
public XServiceResult updateBaseData(XContext context, UpdateBaseDataInput input) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseDataEnt::getId, input.getId());
BaseDataEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
BaseDataEnt entity = mapper.selectOne(new QueryWrapper<BaseDataEnt>()
.lambda()
.eq(BaseDataEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -67,10 +69,10 @@ public class BaseDataService {
@XApiPost
public XServiceResult deleteBaseData(XContext context, DeleteBaseDataInput input) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseDataEnt::getId, input.getId());
BaseDataEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
BaseDataEnt entity = mapper.selectOne(new QueryWrapper<BaseDataEnt>()
.lambda()
.eq(BaseDataEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
mapper.deleteById(entity);
......@@ -80,10 +82,10 @@ public class BaseDataService {
@XApiGet
public XSingleResult<GetBaseDataOutput> getBaseData(XContext context, GetBaseDataInput input) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseDataEnt::getId, input.getId());
BaseDataEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
BaseDataEnt entity = mapper.selectOne(new QueryWrapper<BaseDataEnt>()
.lambda()
.eq(BaseDataEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBaseDataOutput output = new GetBaseDataOutput();
......@@ -97,21 +99,21 @@ public class BaseDataService {
QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>();
Date beginTime;
Date endTime;
if (XStringUtils.isEmpty(input.getDataDate())) {
beginTime = XDateUtils.getDayBeginTime(new Date());
endTime = XDateUtils.getDayEndTime(new Date());
if (CharSequenceUtil.isBlank(input.getDataDate())) {
beginTime = DateUtil.beginOfDay(new Date());
endTime = DateUtil.endOfDay(new Date());
queryWrapper.lambda().ge(BaseDataEnt::getDataDate, beginTime);
queryWrapper.lambda().le(BaseDataEnt::getDataDate, endTime);
} else {
if (input.getDataDate().contains("@")) {
String[] dataDates = input.getDataDate().split("@");
beginTime = XDateUtils.getDayBeginTime(XDateUtils.parse(dataDates[0]));
endTime = XDateUtils.getDayEndTime(XDateUtils.parse(dataDates[1]));
String[] dataDates = CharSequenceUtil.splitToArray(input.getDataDate(), '@');
beginTime = DateUtil.beginOfDay(XDateUtils.parse(dataDates[0]));
endTime = DateUtil.endOfDay(XDateUtils.parse(dataDates[1]));
queryWrapper.lambda().ge(BaseDataEnt::getDataDate, beginTime);
queryWrapper.lambda().le(BaseDataEnt::getDataDate, endTime);
} else {
beginTime = XDateUtils.getDayBeginTime(XDateUtils.parse(input.getDataDate()));
endTime = XDateUtils.getDayEndTime(XDateUtils.parse(input.getDataDate()));
beginTime = DateUtil.beginOfDay(XDateUtils.parse(input.getDataDate()));
endTime = DateUtil.endOfDay(XDateUtils.parse(input.getDataDate()));
queryWrapper.lambda().ge(BaseDataEnt::getDataDate, beginTime);
queryWrapper.lambda().le(BaseDataEnt::getDataDate, endTime);
}
......@@ -119,36 +121,34 @@ public class BaseDataService {
queryWrapper.lambda().eq(BaseDataEnt::getLineId, input.getLineId());
queryWrapper.lambda().orderByAsc(BaseDataEnt::getDataDate);
List<BaseDataEnt> list = mapper.selectList(queryWrapper);
CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", input.getKeyName(), input.getLineId(), "train_pre", XDateUtils.getString(beginTime), XDateUtils.getString(endTime));
CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", input.getKeyName(), input.getLineId(), "train_pre", DateUtil.formatDateTime(beginTime), DateUtil.formatDateTime(endTime));
Map<String, Object> map = getCalcData(context, calcBaseDataInput);
list.stream().forEach(item -> {
String dataDate = XDateUtils.getString(item.getDataDate());
if (map.get(dataDate) != null &&
XStringUtils.isNotEmpty(map.get(dataDate).toString())) {
list.forEach(item -> {
String dataDate = DateUtil.formatDateTime(item.getDataDate());
if (map.containsKey(dataDate)) {
item.setPredictedPower(new BigDecimal(map.get(dataDate).toString()));
}
});
List<QueryBaseDataOutput> outputs = XCopyUtils.copyNewList(list, QueryBaseDataOutput.class);
return XListResult.success(outputs);
return XListResult.success(XCopyUtils.copyNewList(list, QueryBaseDataOutput.class));
}
@XApiGet
public XListResult<QueryBaseDataOutput> queryBaseData(XContext context, GetBaseDataInput input) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>();
BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class);
QueryWrapper<BaseDataImportLogEnt> logEntQueryWrapper = new QueryWrapper<>();
logEntQueryWrapper.lambda().eq(BaseDataImportLogEnt::getLineId, input.getLineId())
BaseDataImportLogEnt ent = logMapper.selectOne(new QueryWrapper<BaseDataImportLogEnt>()
.lambda()
.eq(BaseDataImportLogEnt::getLineId, input.getLineId())
.orderByDesc(BaseDataImportLogEnt::getCreateTime)
.last(BusinessConstant.LAST_LIMIT);
BaseDataImportLogEnt ent = logMapper.selectOne(logEntQueryWrapper);
.last(BusinessConstant.LAST_LIMIT));
List<QueryBaseDataOutput> outputs = new ArrayList<>();
if (null != ent) {
queryWrapper.lambda().ge(BaseDataEnt::getDataDate, ent.getBeginDate());
queryWrapper.lambda().le(BaseDataEnt::getDataDate, ent.getEndDate());
queryWrapper.lambda().eq(BaseDataEnt::getLineId, input.getLineId());
queryWrapper.lambda().orderByAsc(BaseDataEnt::getDataDate);
List<BaseDataEnt> list = mapper.selectList(queryWrapper);
if (ObjectUtil.isNotNull(ent)) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
List<BaseDataEnt> list = mapper.selectList(new QueryWrapper<BaseDataEnt>()
.lambda()
.ge(BaseDataEnt::getDataDate, ent.getBeginDate())
.le(BaseDataEnt::getDataDate, ent.getEndDate())
.eq(BaseDataEnt::getLineId, input.getLineId())
.orderByAsc(BaseDataEnt::getDataDate));
outputs = XCopyUtils.copyNewList(list, QueryBaseDataOutput.class);
}
return XListResult.success(outputs);
......@@ -158,32 +158,24 @@ public class BaseDataService {
@XText("获取预测数据")
public XListResult<GetBaseDataOutput> queryPreBaseData(XContext context, GetBaseDataInput input) {
BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class);
QueryWrapper<BaseDataImportLogEnt> logEntQueryWrapper = new QueryWrapper<>();
logEntQueryWrapper.lambda().eq(BaseDataImportLogEnt::getLineId, input.getLineId())
BaseDataImportLogEnt ent = logMapper.selectOne(new QueryWrapper<BaseDataImportLogEnt>()
.lambda()
.eq(BaseDataImportLogEnt::getLineId, input.getLineId())
.orderByDesc(BaseDataImportLogEnt::getCreateTime)
.last(BusinessConstant.LAST_LIMIT);
BaseDataImportLogEnt ent = logMapper.selectOne(logEntQueryWrapper);
.last(BusinessConstant.LAST_LIMIT));
List<GetBaseDataOutput> outputs = new ArrayList<>();
if (ent != null) {
if (ObjectUtil.isNotNull(ent)) {
BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().ge(BaseDataEnt::getDataDate, ent.getBeginDate());
queryWrapper.lambda().le(BaseDataEnt::getDataDate, ent.getEndDate());
queryWrapper.lambda().eq(BaseDataEnt::getLineId, input.getLineId());
queryWrapper.lambda().orderByAsc(BaseDataEnt::getDataDate);
List<BaseDataEnt> list = mapper.selectList(queryWrapper);
CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", input.getKeyName(), input.getLineId(), "train_pre", XDateUtils.getString(ent.getBeginDate()), XDateUtils.getString(ent.getEndDate()));
Map<String, Object> map = getCalcData(context, calcBaseDataInput);
// for(String key : map.keySet()) {
// GetBaseDataOutput detailOutput = new GetBaseDataOutput();
// detailOutput.setDataDate(XDateUtils.parse(key));
// detailOutput.setPredictedPower(new BigDecimal(map.get(key).toString()));
// outputs.add(detailOutput);
// }
List<BaseDataEnt> list = mapper.selectList(new QueryWrapper<BaseDataEnt>()
.lambda()
.ge(BaseDataEnt::getDataDate, ent.getBeginDate())
.le(BaseDataEnt::getDataDate, ent.getEndDate())
.eq(BaseDataEnt::getLineId, input.getLineId())
.orderByAsc(BaseDataEnt::getDataDate));
Map<String, Object> map = getCalcData(context, new CalcBaseDataInput("", input.getKeyName(), input.getLineId(), "train_pre", DateUtil.formatDateTime(ent.getBeginDate()), DateUtil.formatDateTime(ent.getEndDate())));
list.forEach(item -> {
String dataDate = XDateUtils.getString(item.getDataDate());
if (map.get(dataDate) != null &&
XStringUtils.isNotEmpty(map.get(dataDate).toString())) {
String dataDate = DateUtil.formatDateTime(item.getDataDate());
if (map.containsKey(dataDate)) {
item.setPredictedPower(new BigDecimal(map.get(dataDate).toString()));
}
});
......@@ -210,14 +202,14 @@ public class BaseDataService {
@XText("下载导入模板")
@XApiGet
public XFileResult downloadImportTemplate(XContext context) {
String fileSavePath = XStorageTool.getAbsolutePath("/temp/excel/导入模板_" + XDateUtils.getString(new Date(), "yyyy-MM-dd") + ".xlsx");
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) {
e.printStackTrace();
context.getLogger().error(e);
}
return XFileResult.success(XFileType.APPLICATION_XLSX, fileSavePath);
}
......@@ -226,7 +218,6 @@ public class BaseDataService {
@XApiUpload
public XServiceResult importFile(XContext context, ImportFileInput input) {
List<String> headerList = getExcelHeaderList();
List<BaseDataView> list = new ArrayList<>();
List<Map<String, Object>> mapList = ExcelUtils.readExcel(input.getFile().getInputStream(), input.getFile().getFileName(), headerList, 0);
try {
List<BaseDataView> dataList = new ArrayList<>();
......@@ -236,28 +227,26 @@ public class BaseDataService {
BaseDataView dataView = BeanUtil.toBean(objectMap, BaseDataView.class);
dataView.setOuId(input.getWellOuId());
dataView.setLineId(input.getLineId());
if (dataView.getDataDate() != null) {
if (minDate == null) {
if (ObjectUtil.isNotNull(dataView.getDataDate())) {
if (ObjectUtil.isNull(minDate)) {
minDate = dataView.getDataDate();
maxDate = dataView.getDataDate();
}
if (minDate.compareTo(dataView.getDataDate()) > 0) {
if (DateUtil.compare(minDate, dataView.getDataDate()) > 0) {
minDate = dataView.getDataDate();
} else if (maxDate.compareTo(dataView.getDataDate()) < 0) {
} else if (DateUtil.compare(maxDate, dataView.getDataDate()) < 0) {
maxDate = dataView.getDataDate();
}
}
dataList.add(dataView);
}
if (minDate == null) {
if (ObjectUtil.isNull(minDate)) {
return XServiceResult.error(1000, "日期错误");
}
BaseDataMapper mapper = context.getBean(BaseDataMapper.class);
QueryWrapper<BaseDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseDataEnt::getLineId, input.getLineId())
mapper.delete(new QueryWrapper<BaseDataEnt>().lambda().eq(BaseDataEnt::getLineId, input.getLineId())
.ge(BaseDataEnt::getDataDate, minDate)
.le(BaseDataEnt::getDataDate, maxDate);
mapper.delete(queryWrapper);
.le(BaseDataEnt::getDataDate, maxDate));
BaseDataViewMapper viewMapper = context.getBean(BaseDataViewMapper.class);
viewMapper.batchInsert(dataList);
BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class);
......@@ -268,9 +257,6 @@ public class BaseDataService {
ent.setEndDate(maxDate);
ent.setCreateTime(new Date());
logMapper.insert(ent);
//进行训练
// CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("" , input.getLineId() , "train_val" , XDateUtils.getString(minDate) , XDateUtils.getString(maxDate));
// doTrainData(context , calcBaseDataInput);
} catch (Exception e) {
return XServiceResult.error(-1, e.getMessage());
}
......@@ -280,17 +266,12 @@ public class BaseDataService {
private List<String> getExcelHeaderList() {
List<Map<String, Object>> fieldList = new ArrayList<>();
for (ImportFieldDic value : ImportFieldDic.values()) {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("col", value.getCol());
map.put("sort", value.getSort());
fieldList.add(map);
}
fieldList.sort(new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
return ((Integer) o1.get("sort")).compareTo((Integer) o2.get("sort"));
}
});
fieldList.sort(Comparator.comparing(o -> ((Integer) o.get("sort"))));
return fieldList.stream().map(x -> ((String) x.get("col"))).collect(Collectors.toList());
}
......@@ -319,7 +300,7 @@ public class BaseDataService {
try {
String jsonString = XJsonUtils.toJson(calcBaseDataInput);
context.getLogger().info(jsonString);
Object ret = HttpUtils.send2("http://121.36.43.217:8098/model/train",
HttpUtils.send2("http://121.36.43.217:8098/model/train",
jsonString);
} catch (Exception e) {
throw new RuntimeException("调用预测接口失败");
......@@ -330,20 +311,20 @@ public class BaseDataService {
@XText("预测算法训练")
public XServiceResult trainBaseData(XContext context, TrainBaseModelValInput input) {
BaseDataImportLogMapper logMapper = context.getBean(BaseDataImportLogMapper.class);
QueryWrapper<BaseDataImportLogEnt> logEntQueryWrapper = new QueryWrapper<>();
logEntQueryWrapper.lambda().eq(BaseDataImportLogEnt::getLineId, input.getLineId())
BaseDataImportLogEnt ent = logMapper.selectOne(new QueryWrapper<BaseDataImportLogEnt>()
.lambda()
.eq(BaseDataImportLogEnt::getLineId, input.getLineId())
.orderByDesc(BaseDataImportLogEnt::getCreateTime)
.last(BusinessConstant.LAST_LIMIT);
BaseDataImportLogEnt ent = logMapper.selectOne(logEntQueryWrapper);
if (ent == null)
.last(BusinessConstant.LAST_LIMIT));
if (ObjectUtil.isNull(ent))
return XServiceResult.OK;
if (CollUtil.isNotEmpty(input.getKeyNames())) {
for (String keyName : input.getKeyNames()) {
CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", keyName, input.getLineId(), "train_val", XDateUtils.getString(ent.getBeginDate()), XDateUtils.getString(ent.getEndDate()));
CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", keyName, input.getLineId(), "train_val", DateUtil.formatDateTime(ent.getBeginDate()), DateUtil.formatDateTime(ent.getEndDate()));
doTrainData(context, calcBaseDataInput);
}
} else {
CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", input.getKeyName(), input.getLineId(), "train_val", XDateUtils.getString(ent.getBeginDate()), XDateUtils.getString(ent.getEndDate()));
CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", input.getKeyName(), input.getLineId(), "train_val", DateUtil.formatDateTime(ent.getBeginDate()), DateUtil.formatDateTime(ent.getEndDate()));
doTrainData(context, calcBaseDataInput);
}
return XServiceResult.OK;
......@@ -353,27 +334,30 @@ public class BaseDataService {
@XText("获取最新算法训练数据")
public XSingleResult<TrainBaseModelValOutput> getTrainBaseData(XContext context, GetTrainBaseModelValInput input) {
BaseModelValMapper baseModelValMapper = context.getBean(BaseModelValMapper.class);
if (input.getLineId() == null)
if (ObjectUtil.isNull(input.getLineId())) {
return XSingleResult.error(500, "请选择线路");
if (XStringUtils.isEmpty(input.getKeyNames()))
}
if (CharSequenceUtil.isBlank(input.getKeyNames())) {
return XSingleResult.error(500, "请选择模型");
QueryWrapper<BaseModelValEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseModelValEnt::getLineId, input.getLineId())
}
BaseModelValEnt baseModelValEnt = baseModelValMapper.selectOne(new QueryWrapper<BaseModelValEnt>()
.lambda()
.eq(BaseModelValEnt::getLineId, input.getLineId())
.eq(BaseModelValEnt::getKeyname, input.getKeyNames())
.orderByDesc(BaseModelValEnt::getCreatetime).last(BusinessConstant.LAST_LIMIT);
BaseModelValEnt baseModelValEnt = baseModelValMapper.selectOne(queryWrapper);
.orderByDesc(BaseModelValEnt::getCreatetime).last(BusinessConstant.LAST_LIMIT));
TrainBaseModelValOutput output = XCopyUtils.copyNewObject(baseModelValEnt, TrainBaseModelValOutput.class);
if (baseModelValEnt != null && XStringUtils.isNotEmpty(output.getYtrue()) && XStringUtils.isNotEmpty(output.getYpred())) {
if (ObjectUtil.isNotNull(baseModelValEnt) && CharSequenceUtil.isAllNotBlank(output.getYtrue(), output.getYpred())) {
Map<String, Object> ytrueMap = XJsonUtils.toMap(output.getYtrue().replace("\\", ""));
Map<String, Object> yPreMap = XJsonUtils.toMap(output.getYpred().replace("\\", ""));
List<TrainBaseModelValDetailOutput> list = new ArrayList<>();
for (String key : ytrueMap.keySet()) {
TrainBaseModelValDetailOutput detailOutput = new TrainBaseModelValDetailOutput();
Date date = new Date(Long.valueOf(key));
detailOutput.setKey(XDateUtils.getString(date));
Date date = new Date(Long.parseLong(key));
detailOutput.setKey(DateUtil.formatDateTime(date));
detailOutput.setPower(ytrueMap.get(key).toString());
if (yPreMap.get(key) != null)
if (yPreMap.containsKey(key)) {
detailOutput.setPredictedPower(yPreMap.get(key).toString());
}
list.add(detailOutput);
}
output.setList(list);
......
......@@ -2,6 +2,7 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.core.base.entity.BaseDieselGeneratorEnt;
......@@ -29,7 +30,6 @@ import xstartup.feature.mybatis.helper.XMapperHelper;
import xstartup.helper.XTransactionHelper;
import java.util.List;
import java.util.Objects;
/**
* 柴发设备模块
......@@ -83,7 +83,7 @@ public class BaseDieselGeneratorService {
return XServiceResult.error(context, BusinessError.MakerNumberExists);
}
BaseDieselGeneratorEnt entity = this.selectOneByDieselId(input.getId(), mapper);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -112,7 +112,7 @@ public class BaseDieselGeneratorService {
return XServiceResult.error(context, BusinessError.DieselReference);
}
BaseDieselGeneratorMapper mapper = context.getBean(BaseDieselGeneratorMapper.class);
if (Objects.isNull(this.selectOneByDieselId(dieselId, mapper))) {
if (ObjectUtil.isNull(this.selectOneByDieselId(dieselId, mapper))) {
return XServiceResult.error(context, XError.NotFound);
}
BaseDieselGeneratorEnt entity = new BaseDieselGeneratorEnt();
......@@ -140,7 +140,7 @@ public class BaseDieselGeneratorService {
public XSingleResult<GetBaseDieselGeneratorOutput> getBaseDieselGenerator(XContext context, GetBaseDieselGeneratorInput input) {
BaseDieselGeneratorMapper mapper = context.getBean(BaseDieselGeneratorMapper.class);
BaseDieselGeneratorEnt entity = this.selectOneByDieselId(input.getId(), mapper);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBaseDieselGeneratorOutput output = XCopyUtils.copyNewObject(entity, GetBaseDieselGeneratorOutput.class);
......
......@@ -2,6 +2,7 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.core.base.entity.BaseEnergyStorageDeviceEnt;
......@@ -29,7 +30,6 @@ import xstartup.feature.mybatis.helper.XMapperHelper;
import xstartup.helper.XTransactionHelper;
import java.util.List;
import java.util.Objects;
/**
* 储能设备模块
......@@ -83,7 +83,7 @@ public class BaseEnergyStorageDeviceService {
return XServiceResult.error(context, BusinessError.MakerNumberExists);
}
BaseEnergyStorageDeviceEnt entity = this.selectOneByDeviceId(input.getId(), mapper);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -112,7 +112,7 @@ public class BaseEnergyStorageDeviceService {
return XServiceResult.error(context, BusinessError.StorageReference);
}
BaseEnergyStorageDeviceMapper mapper = context.getBean(BaseEnergyStorageDeviceMapper.class);
if (Objects.isNull(this.selectOneByDeviceId(storageId, mapper))) {
if (ObjectUtil.isNull(this.selectOneByDeviceId(storageId, mapper))) {
return XServiceResult.error(context, XError.NotFound);
}
BaseEnergyStorageDeviceEnt entity = new BaseEnergyStorageDeviceEnt();
......@@ -140,7 +140,7 @@ public class BaseEnergyStorageDeviceService {
public XSingleResult<GetBaseEnergyStorageDeviceOutput> getBaseEnergyStorageDevice(XContext context, GetBaseEnergyStorageDeviceInput input) {
BaseEnergyStorageDeviceMapper mapper = context.getBean(BaseEnergyStorageDeviceMapper.class);
BaseEnergyStorageDeviceEnt entity = this.selectOneByDeviceId(input.getId(), mapper);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBaseEnergyStorageDeviceOutput output = XCopyUtils.copyNewObject(entity, GetBaseEnergyStorageDeviceOutput.class);
......
package pps.core.base.service;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import pps.core.base.entity.BasePhotovoltaicPlantEnt;
......@@ -33,10 +34,12 @@ public class BasePhotovoltaicPlantMapeAdjService {
public XServiceResult saveData(XContext context, CreateBasePhotovoltaicPlantMapeAdjInput input) {
BasePhotovoltaicPlantMapeAdjMapper mapper = context.getBean(BasePhotovoltaicPlantMapeAdjMapper.class);
BasePhotovoltaicPlantMapeAdjEnt ent = XCopyUtils.copyNewObject(input, BasePhotovoltaicPlantMapeAdjEnt.class);
if (ent.getMapePlusVal() == null) ent.setMapePlusVal(BigDecimal.ZERO);
if (ObjectUtil.isNull(ent.getMapePlusVal())) {
ent.setMapePlusVal(BigDecimal.ZERO);
}
PpsUserSession session = context.getSession(PpsUserSession.class);
Date date = new Date();
if (input.getId() == null) {
if (ObjectUtil.isNull(input.getId())) {
ent.setCreateById(session.getId());
ent.setCreateByName(session.getUserName());
ent.setCreateTime(date);
......@@ -58,13 +61,14 @@ public class BasePhotovoltaicPlantMapeAdjService {
BasePhotovoltaicPlantMapper basePhotovoltaicPlantMapper = context.getBean(BasePhotovoltaicPlantMapper.class);
BasePhotovoltaicPlantEnt basePhotovoltaicPlantEnt = basePhotovoltaicPlantMapper.selectOne(new LambdaQueryWrapper<BasePhotovoltaicPlantEnt>()
.eq(BaseModel::getId, input.getPlantId()));
if (basePhotovoltaicPlantEnt == null) return XSingleResult.error(500, "未查找到电站信息");
if (ObjectUtil.isNull(basePhotovoltaicPlantEnt)) {
return XSingleResult.error(500, "未查找到电站信息");
}
BasePhotovoltaicPlantMapeAdjViewMapper mapper = context.getBean(BasePhotovoltaicPlantMapeAdjViewMapper.class);
BasePhotovoltaicPlantMapeAdjView record = new BasePhotovoltaicPlantMapeAdjView();
XCopyUtils.copyObject(input, record);
BasePhotovoltaicPlantMapeAdjView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
output.setPlantName(basePhotovoltaicPlantEnt.getStationName());
output.setMapePlusVal(BigDecimal.ZERO);
return XSingleResult.success(output);
......@@ -84,10 +88,10 @@ public class BasePhotovoltaicPlantMapeAdjService {
ent.setModifyById(session.getId());
ent.setModifyByName(session.getUserName());
ent.setModifyTime(new Date());
UpdateWrapper<BasePhotovoltaicPlantMapeAdjEnt> ur = new UpdateWrapper<>();
ur.lambda().eq(BasePhotovoltaicPlantMapeAdjEnt::getPlantId, input.getPlantId()).eq(BasePhotovoltaicPlantMapeAdjEnt::getMapeType, input.getMapeType());
mapper.update(ent, ur);
mapper.update(ent, new UpdateWrapper<BasePhotovoltaicPlantMapeAdjEnt>()
.lambda()
.eq(BasePhotovoltaicPlantMapeAdjEnt::getPlantId, input.getPlantId())
.eq(BasePhotovoltaicPlantMapeAdjEnt::getMapeType, input.getMapeType()));
return XServiceResult.OK;
}
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.cloud.prediction.service.PlantTrainPowerTaskCloudService;
......@@ -51,7 +52,6 @@ import xstartup.helper.XTransactionHelper;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
......@@ -108,7 +108,7 @@ public class BasePhotovoltaicPlantService {
return XServiceResult.error(context, BusinessError.MakerNumberExists);
}
BasePhotovoltaicPlantEnt entity = this.selectOneByPlantId(input.getId(), mapper);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -137,7 +137,7 @@ public class BasePhotovoltaicPlantService {
return XServiceResult.error(context, BusinessError.PhotovoltaicReference);
}
BasePhotovoltaicPlantMapper mapper = context.getBean(BasePhotovoltaicPlantMapper.class);
if (Objects.isNull(this.selectOneByPlantId(plantId, mapper))) {
if (ObjectUtil.isNull(this.selectOneByPlantId(plantId, mapper))) {
return XServiceResult.error(context, XError.NotFound);
}
BasePhotovoltaicPlantEnt entity = new BasePhotovoltaicPlantEnt();
......@@ -165,7 +165,7 @@ public class BasePhotovoltaicPlantService {
public XSingleResult<GetBasePhotovoltaicPlantOutput> getBasePhotovoltaicPlant(XContext context, GetBasePhotovoltaicPlantInput input) {
BasePhotovoltaicPlantMapper mapper = context.getBean(BasePhotovoltaicPlantMapper.class);
BasePhotovoltaicPlantEnt entity = this.selectOneByPlantId(input.getId(), mapper);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBasePhotovoltaicPlantOutput output = XCopyUtils.copyNewObject(entity, GetBasePhotovoltaicPlantOutput.class);
......@@ -174,7 +174,7 @@ public class BasePhotovoltaicPlantService {
SysOrganizationView organizationView = new SysOrganizationView();
organizationView.setId(entity.getOuId());
organizationView = organizationViewMapper.selectOrgProvince(organizationView);
if (Objects.nonNull(organizationView)) {
if (ObjectUtil.isNotNull(organizationView)) {
output.setProvince(organizationView.getProvinceName());
}
output.setAreaName(Optional.ofNullable(this.getSysAreaInfo(context, GetSysAreaInput.builder()
......@@ -203,21 +203,20 @@ public class BasePhotovoltaicPlantService {
Map<String, Object> map = XJsonUtils.toMap(result.getResult().getMetricsScore());
if (map.containsKey("MAPE") && CharSequenceUtil.isNotEmpty(map.get("MAPE").toString())) {
BigDecimal relMape = new BigDecimal(map.get("MAPE").toString());
BigDecimal mape = null;
BigDecimal mape;
//获取调整的准确率附加值
BasePhotovoltaicPlantMapeAdjViewMapper mapeAdjMapper = context.getBean(BasePhotovoltaicPlantMapeAdjViewMapper.class);
BasePhotovoltaicPlantMapeAdjView record = new BasePhotovoltaicPlantMapeAdjView();
record.setPlantId(input.getId());
record.setMapeType(input.getMapeType());
BasePhotovoltaicPlantMapeAdjView view = mapeAdjMapper.selectOne(record);
if (view != null && view.getMapePlusVal() != null) {
if (ObjectUtil.isNotNull(view) && ObjectUtil.isNotNull(view.getMapePlusVal())) {
mape = relMape.add(view.getMapePlusVal());
if (mape.compareTo(BusinessConstant.BIG_DECIMAL_100) > 0)
mape = BusinessConstant.BIG_DECIMAL_100;
} else {
mape = relMape;
}
//output.setRelMape(relMape.setScale(2, BigDecimal.ROUND_UP).toPlainString() + "%");
output.setMape(mape.setScale(2, BigDecimal.ROUND_UP).toPlainString() + "%");
}
}
......@@ -225,7 +224,6 @@ public class BasePhotovoltaicPlantService {
return XSingleResult.success(output);
}
@XText("获取调整光伏功率预测准确率按钮")
@XApiGet
public XSingleResult<MapeAjdPowerOutput> getAjdButton(XContext context) {
......@@ -404,9 +402,12 @@ public class BasePhotovoltaicPlantService {
return result;
}
List<QuerySysDictionaryViewOutput> roleDicList = dicResult.getResult();
if (roleDicList.isEmpty()) return result;
List<String> roleIds = roleDicList.stream().map(QuerySysDictionaryViewOutput::getDicKey).collect(Collectors.toList());
if (CollUtil.isEmpty(roleDicList)) {
return result;
}
List<String> roleIds = roleDicList.stream()
.map(QuerySysDictionaryViewOutput::getDicKey)
.collect(Collectors.toList());
//获取当前用户角色
SystemUserRoleRelService roleRelService = context.getBean(SystemUserRoleRelService.class);
GetSysUserRoleRelInput getSysUserRoleRelInput = new GetSysUserRoleRelInput();
......@@ -423,7 +424,7 @@ public class BasePhotovoltaicPlantService {
}
}
} catch (Exception e) {
e.printStackTrace();
context.getLogger().error(e);
}
return result;
}
......
......@@ -3,6 +3,7 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.pagehelper.PageInfo;
......@@ -145,7 +146,7 @@ public class BasePowerLineService {
return XTransactionHelper.begin(context, () -> {
BasePowerLineMapper mapper = context.getBean(BasePowerLineMapper.class);
BasePowerLineEnt entity = this.selectOneByLineId(lineId, mapper);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
//删除线路配置
......@@ -196,7 +197,7 @@ public class BasePowerLineService {
BasePowerLineView basePowerLineView = new BasePowerLineView();
basePowerLineView.setId(lineId);
BasePowerLineView entity = mapper.selectOne(basePowerLineView);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBasePowerLineViewOutput output = XCopyUtils.copyNewObject(entity, GetBasePowerLineViewOutput.class);
......
......@@ -2,6 +2,7 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
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.update.LambdaUpdateWrapper;
......@@ -91,7 +92,7 @@ public class BasePriceStrategyService {
BasePriceStrategyMapper mapper = context.getBean(BasePriceStrategyMapper.class);
BasePriceStrategyEnt entity = mapper.selectOne(new LambdaQueryWrapper<BasePriceStrategyEnt>()
.eq(BaseModel::getId, strategyId));
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
List<UpdateBasePriceStrategyMonthInput> inputMonths = input.getMonths();
......@@ -142,7 +143,7 @@ public class BasePriceStrategyService {
BasePriceStrategyMapper mapper = context.getBean(BasePriceStrategyMapper.class);
BasePriceStrategyEnt entity = mapper.selectOne(new LambdaQueryWrapper<BasePriceStrategyEnt>()
.eq(BaseModel::getId, strategyId));
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
//删除策略
......@@ -188,7 +189,7 @@ public class BasePriceStrategyService {
.eq(BasePriceStrategyEnt::getId, strategyId)
.eq(BaseModel::getIsDeleted, BusinessConstant.ONE)
);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBasePriceStrategyOutput output = XCopyUtils.copyNewObject(entity, GetBasePriceStrategyOutput.class);
......
package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import pps.core.base.entity.BaseLineAttenuationRateEnt;
......@@ -18,7 +20,6 @@ import xstartup.annotation.XService;
import xstartup.base.XContext;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XJsonUtils;
import xstartup.base.util.XStringUtils;
import xstartup.core.base.helper.XThreadHelper;
import xstartup.data.XListResult;
import xstartup.data.XPageResult;
......@@ -43,9 +44,7 @@ public class BaseProjectInfoService {
public static String getParentNameStr(List<SysAreaEnt> areaList, SysAreaEnt child) {
String parentNameStr = child.getName();
Integer parentId = child.getParentId();
if (parentId == 120) {
} else {
if (parentId != 120) {
SysAreaEnt parent = areaList.stream().filter(item -> item.getId().equals(parentId)).findFirst().orElse(null);
String nameStr = getParentNameStr(areaList, parent);
parentNameStr = nameStr + "/" + parentNameStr;
......@@ -87,10 +86,10 @@ public class BaseProjectInfoService {
@XApiPost
public XServiceResult updateProjectInfo(XContext context, UpdateBaseProjectInfoInput input) {
BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class);
QueryWrapper<BaseProjectInfoEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseProjectInfoEnt::getId, input.getId());
BaseProjectInfoEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
BaseProjectInfoEnt entity = mapper.selectOne(new QueryWrapper<BaseProjectInfoEnt>()
.lambda()
.eq(BaseProjectInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -102,10 +101,10 @@ public class BaseProjectInfoService {
entity.setIsDeleted(0);
mapper.updateById(entity);
BaseLineAttenuationRateMapper rateMapper = context.getBean(BaseLineAttenuationRateMapper.class);
QueryWrapper<BaseLineAttenuationRateEnt> queryRateWrapper = new QueryWrapper<>();
queryRateWrapper.lambda().eq(BaseLineAttenuationRateEnt::getLineId, entity.getId());
queryRateWrapper.lambda().eq(BaseLineAttenuationRateEnt::getType, 1);
rateMapper.delete(queryRateWrapper);
rateMapper.delete(new QueryWrapper<BaseLineAttenuationRateEnt>()
.lambda()
.eq(BaseLineAttenuationRateEnt::getLineId, entity.getId())
.eq(BaseLineAttenuationRateEnt::getType, 1));
List<BaseLineAttenuationRateView> list = new ArrayList<>();
if (CollUtil.isNotEmpty(input.getList())) {
BaseLineAttenuationRateViewMapper rateViewMapper = context.getBean(BaseLineAttenuationRateViewMapper.class);
......@@ -128,10 +127,10 @@ public class BaseProjectInfoService {
@XApiPost
public XServiceResult deleteProjectInfo(XContext context, DeleteProjectInfoInput input) {
BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class);
QueryWrapper<BaseProjectInfoEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseProjectInfoEnt::getId, input.getId());
BaseProjectInfoEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
BaseProjectInfoEnt entity = mapper.selectOne(new QueryWrapper<BaseProjectInfoEnt>()
.lambda()
.eq(BaseProjectInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
entity.setIsDeleted(1);
......@@ -142,21 +141,22 @@ public class BaseProjectInfoService {
@XApiGet
public XSingleResult<GetBaseProjectInfoOutput> getProjectInfo(XContext context, GetProjectInfoInput input) {
BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class);
QueryWrapper<BaseProjectInfoEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseProjectInfoEnt::getId, input.getId());
BaseProjectInfoEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
BaseProjectInfoEnt entity = mapper.selectOne(new QueryWrapper<BaseProjectInfoEnt>()
.lambda()
.eq(BaseProjectInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBaseProjectInfoOutput output = new GetBaseProjectInfoOutput();
XCopyUtils.copyObject(entity, output);
if (XStringUtils.isNotEmpty(entity.getProvince()))
if (CharSequenceUtil.isNotBlank(entity.getProvince())) {
output.setProvince(Integer.valueOf(entity.getProvince()));
}
BaseLineAttenuationRateMapper rateMapper = context.getBean(BaseLineAttenuationRateMapper.class);
QueryWrapper<BaseLineAttenuationRateEnt> queryRateWrapper = new QueryWrapper<>();
queryRateWrapper.lambda().eq(BaseLineAttenuationRateEnt::getLineId, entity.getId());
queryRateWrapper.lambda().eq(BaseLineAttenuationRateEnt::getType, 1);
List<BaseLineAttenuationRateEnt> list = rateMapper.selectList(queryRateWrapper);
List<BaseLineAttenuationRateEnt> list = rateMapper.selectList(new QueryWrapper<BaseLineAttenuationRateEnt>()
.lambda()
.eq(BaseLineAttenuationRateEnt::getLineId, entity.getId())
.eq(BaseLineAttenuationRateEnt::getType, 1));
if (CollUtil.isNotEmpty(list)) {
List<CreateBaseLineAttenuationRateInput> rateInputs = XCopyUtils.copyNewList(list, CreateBaseLineAttenuationRateInput.class);
output.setList(rateInputs);
......@@ -169,20 +169,23 @@ public class BaseProjectInfoService {
BaseProjectInfoMapper mapper = context.getBean(BaseProjectInfoMapper.class);
QueryWrapper<BaseProjectInfoEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseProjectInfoEnt::getIsDeleted, 0);
if (XStringUtils.isNotEmpty(input.getProjectName()))
if (CharSequenceUtil.isNotBlank(input.getProjectName())) {
queryWrapper.lambda().like(BaseProjectInfoEnt::getProjectName, input.getProjectName());
if (input.getProductionYear() != null)
}
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);
SysAreaMapper areaMapper = context.getBean(SysAreaMapper.class);
List<SysAreaEnt> areaEntList = areaMapper.selectList(new QueryWrapper<>());
outputs.stream().forEach(item -> {
if (XStringUtils.isNotEmpty(item.getProvince())) {
SysAreaEnt areaEnt = areaEntList.stream().filter(area -> item.getProvince().equals(area.getId() + "")).findFirst().orElse(null);
if (areaEnt != null)
item.setProvince(getParentNameStr(areaEntList, areaEnt));
outputs.forEach(item -> {
if (CharSequenceUtil.isNotBlank(item.getProvince())) {
areaEntList.stream()
.filter(area -> item.getProvince().equals(area.getId() + ""))
.findFirst()
.ifPresent(areaEnt -> item.setProvince(getParentNameStr(areaEntList, areaEnt)));
}
});
return XPageResult.success(outputs, input, pageInfo.getTotal());
......@@ -192,8 +195,9 @@ public class BaseProjectInfoService {
public XListResult<GetProjectInfoPredictedDataOutput> queryProjectInfoPredictedDataList(XContext context, GetProjectInfoPredictedDataInput input) {
BaseProjectInfoPredictedDataMapper mapper = context.getBean(BaseProjectInfoPredictedDataMapper.class);
QueryWrapper<BaseProjectInfoPredictedDataEnt> queryWrapper = new QueryWrapper<>();
if (input.getProjectId() != null)
if (ObjectUtil.isNotNull(input.getProjectId())) {
queryWrapper.lambda().eq(BaseProjectInfoPredictedDataEnt::getProjectId, input.getProjectId());
}
List<BaseProjectInfoPredictedDataEnt> list = mapper.selectList(queryWrapper);
PageInfo<BaseProjectInfoPredictedDataEnt> pageInfo = new PageInfo(list);
List<GetProjectInfoPredictedDataOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), GetProjectInfoPredictedDataOutput.class);
......@@ -207,17 +211,17 @@ public class BaseProjectInfoService {
input.setAngle(entity.getArrayIncidence());
input.setDirection(entity.getArrayToward());
input.setCapacity(entity.getInstallCapacity());
input.setEfficiency(new BigDecimal(0.35).setScale(2, RoundingMode.HALF_EVEN));
input.setWeather(new BigDecimal(0.7).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));
List<BaseLineAttenuationRateView> sortList = list.stream().sorted(Comparator.comparing(BaseLineAttenuationRateView::getSort)).collect(Collectors.toList());
List<BigDecimal> decimals = sortList.stream().map(BaseLineAttenuationRateView::getAttenuationRate).collect(Collectors.toList());
input.setDecline(decimals);
Map<String, Object> map = getPredictedData(context, input);
//插入数据
BaseProjectInfoPredictedDataMapper mapper = context.getBean(BaseProjectInfoPredictedDataMapper.class);
QueryWrapper<BaseProjectInfoPredictedDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseProjectInfoPredictedDataEnt::getProjectId, entity.getId());
mapper.delete(queryWrapper);
mapper.delete(new QueryWrapper<BaseProjectInfoPredictedDataEnt>()
.lambda()
.eq(BaseProjectInfoPredictedDataEnt::getProjectId, entity.getId()));
List<Double> powers = (List<Double>) map.get("power");
Integer particularYear = Integer.valueOf(entity.getProductionYear());
PpsUserSession userSession = context.getSession(PpsUserSession.class);
......@@ -227,7 +231,7 @@ public class BaseProjectInfoService {
BaseProjectInfoPredictedDataEnt ent = new BaseProjectInfoPredictedDataEnt();
ent.setProjectId(entity.getId());
ent.setParticularYear(particularYear + "");
ent.setPredictedPower(BigDecimal.valueOf(decimal.doubleValue()));
ent.setPredictedPower(BigDecimal.valueOf(decimal));
ent.setCreateById(userSession.getId());
ent.setCreateByName(userSession.getUserName());
ent.setCreateTime(date);
......
......@@ -48,8 +48,8 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
PlantPredictedPowerDataMapper mapper = context.getBean(PlantPredictedPowerDataMapper.class);
Document document = Jsoup.parse(new URL(url), 30000);
Elements elements = document.getElementsByClass("mt15"); // 获取class name 是‘mt15’的都有元素对象
Element element = null;
if (elements == null || elements.size() <= 0) {
Element element;
if (elements.isEmpty()) {
return;
} else {
element = elements.get(1); //根据页面结构获取到需要的元素对象
......@@ -65,13 +65,12 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
List<String> pressureArray; // 气压
List<String> humidityArray;// 湿度
List<String> cloudCoverArray; // 云量
Date date = null;
Calendar calendar = null;
String dayTime = null;
Date date;
Calendar calendar;
String dayTime;
List<PlantPredictedPowerDataEnt> objList = new ArrayList<>();
// Integer currentHous = LocalDate.parse(XDateUtils.getDateTimeString(new Date())).getHour();
List<PlantPredictedPowerDataEnt> allList = new ArrayList<>();
if (tables != null && tables.size() > 0) {
if (!tables.isEmpty()) {
for (int i = 0; i < tables.size(); i++) {
calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, i);
......@@ -87,7 +86,7 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
pressureArray = new ArrayList<>(); // 气压
humidityArray = new ArrayList<>(); // 湿度
cloudCoverArray = new ArrayList<>(); // 云量
if (trs != null && trs.size() > 0) {
if (!trs.isEmpty()) {
for (int j = 0; j < trs.size(); j++) { // 循环行
Elements tds = trs.get(j).select("td");
for (int k = 1; k < tds.size(); k++) { // 循环列
......@@ -130,7 +129,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
dao.setPressure(new BigDecimal(pressureArray.get(y).replace("hPa", "")));
dao.setHumidity(new BigDecimal(humidityArray.get(y).replace("%", "")));
//判断小时数与查到的小时数,如果查到的小时数小,判断为第二天
//Hous = LocalTime.parse(hourTimeArray.get(y)).getHour();
if (Hous >= LocalTime.parse(hourTimeArray.get(y)).getHour()) {
calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, (i + 1));
......@@ -143,24 +141,15 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
dao.setDayTime(LocalDate.parse(dayTime).getDayOfMonth() < 10 ? "0" + LocalDate.parse(dayTime).getDayOfMonth() : LocalDate.parse(dayTime).getDayOfMonth() + "");
dao.setHourTime(Hous < 10 ? "0" + Hous : Hous + "");
// 5.执行SQL
QueryWrapper<PlantPredictedPowerDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(PlantPredictedPowerDataEnt::getPlantId, plantId)
mapper.delete(new QueryWrapper<PlantPredictedPowerDataEnt>().lambda().eq(PlantPredictedPowerDataEnt::getPlantId, plantId)
.eq(PlantPredictedPowerDataEnt::getYearTime, dao.getYearTime())
.eq(PlantPredictedPowerDataEnt::getMonthTime, dao.getMonthTime())
.eq(PlantPredictedPowerDataEnt::getDayTime, dao.getDayTime())
.eq(PlantPredictedPowerDataEnt::getHourTime, dao.getHourTime());
mapper.delete(queryWrapper);
.eq(PlantPredictedPowerDataEnt::getHourTime, dao.getHourTime()));
dao.setMinTime("00:00");
dao.setDataDate(dao.getYearTime() + "-" + dao.getMonthTime() + "-" + dao.getDayTime() + " " + dao.getHourTime() + ":" + dao.getMinTime());
PlantPredictedPowerDataEnt insertDao = XCopyUtils.copyNewObject(dao, PlantPredictedPowerDataEnt.class);
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);
// }
PlantPredictedPowerDataEnt isExit = objList.stream().filter(item -> item.getYearTime().equals(dao.getYearTime()) &&
item.getMonthTime().equals(dao.getMonthTime()) &&
item.getDayTime().equals(dao.getDayTime()) &&
......
......@@ -2,6 +2,7 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.cloud.space.service.ISpaceInstitutionDetailCloudService;
......@@ -31,7 +32,6 @@ import xstartup.feature.mybatis.helper.XMapperHelper;
import xstartup.helper.XTransactionHelper;
import java.util.List;
import java.util.Objects;
/**
......@@ -86,7 +86,7 @@ public class BaseWellheadService {
return XServiceResult.error(context, BusinessError.WellNumberExists);
}
BaseWellheadEnt entity = this.selectOneByWellheadId(input.getId(), mapper);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -118,7 +118,7 @@ public class BaseWellheadService {
return XServiceResult.error(context, BusinessError.WellheadReferenceSpace);
}
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
if (Objects.isNull(this.selectOneByWellheadId(wellheadId, mapper))) {
if (ObjectUtil.isNull(this.selectOneByWellheadId(wellheadId, mapper))) {
return XServiceResult.error(context, XError.NotFound);
}
BaseWellheadEnt entity = new BaseWellheadEnt();
......@@ -146,7 +146,7 @@ public class BaseWellheadService {
public XSingleResult<GetBaseWellheadOutput> getBaseWellhead(XContext context, GetBaseWellheadInput input) {
BaseWellheadMapper mapper = context.getBean(BaseWellheadMapper.class);
BaseWellheadEnt entity = this.selectOneByWellheadId(input.getId(), mapper);
if (Objects.isNull(entity)) {
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetBaseWellheadOutput output = XCopyUtils.copyNewObject(entity, GetBaseWellheadOutput.class);
......
package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.ObjectUtils;
import pps.core.base.entity.SysPageInfoEnt;
import pps.core.base.mapper.SysPageInfoMapper;
import pps.core.base.service.data.sys_page_info.*;
......@@ -48,10 +49,10 @@ public class SysPageInfoService {
public XServiceResult updateSysPageInfo(XContext context, UpdateSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
QueryWrapper<SysPageInfoEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysPageInfoEnt::getId, input.getId());
SysPageInfoEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysPageInfoEnt entity = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
if (CharSequenceUtil.isNotBlank(input.getPageContext())) {
......@@ -74,10 +75,10 @@ public class SysPageInfoService {
@XApiPost
public XServiceResult deleteSysPageInfo(XContext context, DeleteSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
QueryWrapper<SysPageInfoEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysPageInfoEnt::getId, input.getId());
SysPageInfoEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysPageInfoEnt entity = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
mapper.deleteById(entity);
......@@ -88,10 +89,10 @@ public class SysPageInfoService {
@XApiGet
public XSingleResult<GetSysPageInfoOutput> getSysPageInfo(XContext context, GetSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
QueryWrapper<SysPageInfoEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysPageInfoEnt::getId, input.getId());
SysPageInfoEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysPageInfoEnt entity = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysPageInfoOutput output = new GetSysPageInfoOutput();
......@@ -110,7 +111,7 @@ public class SysPageInfoService {
if (CharSequenceUtil.isNotBlank(input.getPageName())) {
queryWrapper.lambda().like(SysPageInfoEnt::getPageName, input.getPageName());
}
if (ObjectUtils.isNotEmpty(input.getReleaseState())) {
if (ObjectUtil.isNotNull(input.getReleaseState())) {
queryWrapper.lambda().eq(SysPageInfoEnt::getReleaseState, input.getReleaseState());
}
queryWrapper.lambda().orderByDesc(SysPageInfoEnt::getCreateTime);
......@@ -122,26 +123,27 @@ public class SysPageInfoService {
public XServiceResult releasePageInfo(XContext context, GetSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
//根据id查询需要发布的数据
QueryWrapper<SysPageInfoEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysPageInfoEnt::getId, input.getId());
SysPageInfoEnt sysPageInfoEnt = mapper.selectOne(queryWrapper);
SysPageInfoEnt sysPageInfoEnt = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getId, input.getId()));
//查询当前页面处于发布状态的版本删除
QueryWrapper<SysPageInfoEnt> queryStateVersion = new QueryWrapper();
queryStateVersion.lambda().eq(SysPageInfoEnt::getPageId, sysPageInfoEnt.getPageId())
.eq(SysPageInfoEnt::getReleaseVersion, 1);
List<SysPageInfoEnt> sysPageInfos = mapper.selectList(queryStateVersion);
if (ObjectUtils.isNotEmpty(sysPageInfos)) {
List<SysPageInfoEnt> sysPageInfos = mapper.selectList(new QueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getPageId, sysPageInfoEnt.getPageId())
.eq(SysPageInfoEnt::getReleaseVersion, 1));
if (CollUtil.isNotEmpty(sysPageInfos)) {
SysPageInfoEnt pageInfoEnt = sysPageInfos.get(0);
mapper.deleteById(pageInfoEnt);
}
//查询发布的最大版本号
QueryWrapper<SysPageInfoEnt> queryMaxVersion = new QueryWrapper();
queryMaxVersion.lambda().eq(SysPageInfoEnt::getPageId, sysPageInfoEnt.getPageId()).isNotNull(SysPageInfoEnt::getReleaseVersion)
.orderByDesc(SysPageInfoEnt::getReleaseVersion);
List<SysPageInfoEnt> sysPageInfoEnts = mapper.selectList(queryMaxVersion);
if (ObjectUtils.isNotEmpty(sysPageInfoEnts)) {
List<SysPageInfoEnt> sysPageInfoEnts = mapper.selectList(new QueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getPageId, sysPageInfoEnt.getPageId())
.isNotNull(SysPageInfoEnt::getReleaseVersion)
.orderByDesc(SysPageInfoEnt::getReleaseVersion));
if (CollUtil.isNotEmpty(sysPageInfoEnts)) {
SysPageInfoEnt sysPageInfo = sysPageInfoEnts.get(0);
if (ObjectUtils.isNotEmpty(sysPageInfo.getReleaseVersion())) {
if (ObjectUtil.isNotNull(sysPageInfo.getReleaseVersion())) {
Integer version = sysPageInfo.getReleaseVersion() + 1;
sysPageInfoEnt.setReleaseVersion(version);
} else {
......@@ -160,11 +162,11 @@ public class SysPageInfoService {
@XApiGet
public XSingleResult<GetSysPageInfoOutput> getSysPageInfoByPageId(XContext context, GetSysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
QueryWrapper<SysPageInfoEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysPageInfoEnt::getPageId, input.getPageId())
.eq(SysPageInfoEnt::getReleaseState, 1);
SysPageInfoEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysPageInfoEnt entity = mapper.selectOne(new QueryWrapper<SysPageInfoEnt>()
.lambda()
.eq(SysPageInfoEnt::getPageId, input.getPageId())
.eq(SysPageInfoEnt::getReleaseState, 1));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysPageInfoOutput output = new GetSysPageInfoOutput();
......
package pps.core.base.utils;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.nio.charset.StandardCharsets;
public class HttpUtils {
public static Object sendPost(String url, Object param) {
// 请求头设置
HttpHeaders headers = new HttpHeaders();
List<MediaType> acceptableMediaType = new ArrayList<>();
acceptableMediaType.add(MediaType.APPLICATION_JSON);
headers.setAccept(acceptableMediaType);
headers.setContentType(MediaType.APPLICATION_JSON);
// 组装请求体
//String jsonString = XJsonUtils.toJson(param);
HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity(param, headers);
//发起请求
RestTemplate restTemplate = new RestTemplate();
Object res = restTemplate.postForObject(url, request, Object.class);
return res;
}
public static String send2(String url, String param) throws Exception {
URL localURL = new URL(url);
URLConnection connection = localURL.openConnection();
HttpURLConnection httpURLConnection = (HttpURLConnection) connection;
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("Accept", "application/json");
httpURLConnection.setRequestProperty("Content-Type", "application/json");
httpURLConnection.setRequestProperty("Content-Length", String.valueOf(param.length()));
httpURLConnection.setConnectTimeout(10000);
OutputStream outputStream = null;
OutputStreamWriter outputStreamWriter = null;
InputStream inputStream = null;
InputStreamReader inputStreamReader = null;
BufferedReader reader = null;
String resultBuffer = "";
try {
outputStream = httpURLConnection.getOutputStream();
outputStreamWriter = new OutputStreamWriter(outputStream);
outputStreamWriter.write(param.toString());
outputStreamWriter.write(param);
outputStreamWriter.flush();
if (httpURLConnection.getResponseCode() >= 300) {
throw new Exception(
"HTTP Request is not success, Response code is " + httpURLConnection.getResponseCode());
}
inputStream = httpURLConnection.getInputStream();
resultBuffer = convertStreamToString(inputStream);
System.out.println(resultBuffer);
} catch (Exception e) {
e.printStackTrace();
} catch (Exception ignored) {
} finally {
if (outputStreamWriter != null) {
outputStreamWriter.close();
}
if (outputStream != null) {
outputStream.close();
}
if (reader != null) {
reader.close();
}
if (inputStreamReader != null) {
inputStreamReader.close();
}
if (inputStream != null) {
inputStream.close();
}
}
return resultBuffer;
}
public static String convertStreamToString(InputStream is) {
StringBuilder sb1 = new StringBuilder();
byte[] bytes = new byte[4096];
int size = 0;
int size;
try {
while ((size = is.read(bytes)) > 0) {
String str = new String(bytes, 0, size, "UTF-8");
String str = new String(bytes, 0, size, StandardCharsets.UTF_8);
sb1.append(str);
}
} catch (IOException e) {
e.printStackTrace();
} catch (IOException ignored) {
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IOException ignored) {
}
}
return sb1.toString();
}
public static void main(String[] args) throws Exception {
Map<String, String> object = new HashMap<>();
object.put("pipelineId", "11");
object.put("stationId", "11");
object.put("customerId", "11");
object.put("startTime", "2022-10-23 00:00:00");
object.put("strByteString", "11");
String parm = "pipelineId=" + "12" +
"&stationId=" + "12" +
"&customerId=" + "12" +
"&startTime=" + "2022-12-01 00:00:00" +
"&strByteString=" + "12";
send2("http://10.20.89.75/interface/pdf/InsertSIFile?" + parm, parm);
}
}
package pps.core.base.utils;
import org.springframework.util.ObjectUtils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ArrayUtil;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
......@@ -9,7 +11,6 @@ import javax.mail.internet.MimeUtility;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -52,11 +53,11 @@ public class ReceivedIMAPMail {
public static List<Message> filterMessage(Message[] messages, String fromMail, String startDate)
throws MessagingException, ParseException {
List<Message> messageList = new ArrayList<>();
if (ObjectUtils.isEmpty(messages)) {
if (ArrayUtil.isEmpty(messages)) {
return messageList;
}
boolean isEnptyFromMail = ObjectUtils.isEmpty(fromMail);
boolean isEnptyStartDate = ObjectUtils.isEmpty(startDate);
boolean isEnptyFromMail = CharSequenceUtil.isBlank(fromMail);
boolean isEnptyStartDate = CharSequenceUtil.isBlank(startDate);
if (isEnptyFromMail && isEnptyStartDate) {
return Arrays.asList(messages);
}
......@@ -64,13 +65,11 @@ public class ReceivedIMAPMail {
for (Message message : messages) {
from = (message.getFrom()[0]).toString();
if (isEnptyFromMail) {
if (new SimpleDateFormat(NORM_DATETIME_PATTERN).parse(startDate).getTime() > message.getSentDate()
.getTime()) {
if (DateUtil.parseDateTime(startDate).compareTo(message.getSentDate()) > 0) {
continue;
}
} else if (null != from && from.contains(fromMail)) {
if (!isEnptyStartDate && new SimpleDateFormat(NORM_DATETIME_PATTERN).parse(startDate)
.getTime() > message.getSentDate().getTime()) {
} else if (CharSequenceUtil.isNotBlank(from) && CharSequenceUtil.contains(from, fromMail)) {
if (!isEnptyStartDate && DateUtil.parseDateTime(startDate).compareTo(message.getSentDate()) > 0) {
continue;
}
} else {
......@@ -89,21 +88,9 @@ public class ReceivedIMAPMail {
*/
public String getFrom() throws MessagingException {
InternetAddress address[] = (InternetAddress[]) mimeMessage.getFrom();
String from = address[0].getAddress();
if (from == null) {
from = "";
}
String personal = address[0].getPersonal();
if (personal == null) {
personal = "";
}
String fromAddr = null;
if (personal != null || from != null) {
fromAddr = personal + "<" + from + ">";
}
return fromAddr;
String from = CharSequenceUtil.blankToDefault(address[0].getAddress(), "");
String personal = CharSequenceUtil.blankToDefault(address[0].getPersonal(), "");
return personal + "<" + from + ">";
}
/**
......@@ -114,11 +101,7 @@ public class ReceivedIMAPMail {
* @throws UnsupportedEncodingException
*/
public String getSubject() throws MessagingException, UnsupportedEncodingException {
String subject = MimeUtility.decodeText(mimeMessage.getSubject());
if (subject == null) {
subject = "";
}
return subject;
return CharSequenceUtil.blankToDefault(MimeUtility.decodeText(mimeMessage.getSubject()), "");
}
/**
......@@ -135,9 +118,9 @@ public class ReceivedIMAPMail {
if (nameIndex != -1) {
conName = true;
}
if (part.isMimeType("text/plain") && conName == false) {
if (part.isMimeType("text/plain") && !conName) {
bodyText.append((String) part.getContent());
} else if (part.isMimeType("text/html") && conName == false) {
} else if (part.isMimeType("text/html") && !conName) {
bodyText.append((String) part.getContent());
} else if (part.isMimeType("multipart/*")) {
Multipart multipart = (Multipart) part.getContent();
......@@ -160,8 +143,8 @@ public class ReceivedIMAPMail {
boolean isNew = false;
Flags flags = mimeMessage.getFlags();
Flags.Flag[] flag = flags.getSystemFlags();
for (int i = 0; i < flag.length; i++) {
if (flag[i] == Flags.Flag.SEEN) {
for (Flags.Flag value : flag) {
if (value == Flags.Flag.SEEN) {
isNew = true;
}
}
......
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