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