|
|
|
@ -7,6 +7,8 @@ import com.gccloud.dataroom.core.constant.PageDesignConstant;
|
|
|
|
|
import com.gccloud.dataroom.core.module.basic.dao.DataRoomPageDao;
|
|
|
|
|
import com.gccloud.dataroom.core.module.basic.entity.PageEntity;
|
|
|
|
|
import com.gccloud.dataroom.core.module.basic.entity.PagePreviewEntity;
|
|
|
|
|
import com.gccloud.dataroom.core.module.biz.component.dao.DataRoomBizUserDao;
|
|
|
|
|
import com.gccloud.dataroom.core.module.biz.component.entity.BizComponentUser;
|
|
|
|
|
import com.gccloud.dataroom.core.module.chart.bean.Chart;
|
|
|
|
|
import com.gccloud.dataroom.core.module.chart.bean.Linkage;
|
|
|
|
|
import com.gccloud.dataroom.core.module.chart.components.datasource.DataSetDataSource;
|
|
|
|
@ -35,16 +37,15 @@ import org.apache.commons.io.FileUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
|
|
|
import org.apache.tomcat.util.http.fileupload.FileItem;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.Base64;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -75,6 +76,9 @@ public class DataRoomPageServiceImpl extends ServiceImpl<DataRoomPageDao, PageEn
|
|
|
|
|
@Resource
|
|
|
|
|
private IDataRoomOssService ossService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private DataRoomBizUserDao userDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageEntity getByCode(String code) {
|
|
|
|
|
if (code.startsWith(IDataRoomPagePreviewService.PREVIEW_KEY)) {
|
|
|
|
@ -85,9 +89,17 @@ public class DataRoomPageServiceImpl extends ServiceImpl<DataRoomPageDao, PageEn
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public String add(DataRoomPageDTO bigScreenPageDTO) {
|
|
|
|
|
|
|
|
|
|
if (!org.springframework.util.StringUtils.hasText(bigScreenPageDTO.getUserId()))
|
|
|
|
|
{
|
|
|
|
|
throw new RuntimeException("userId不能为空!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String code = null;
|
|
|
|
|
if (StringUtils.isBlank(bigScreenPageDTO.getCode())) {
|
|
|
|
|
String code = CodeGenerateUtils.generate(bigScreenPageDTO.getType());
|
|
|
|
|
code = CodeGenerateUtils.generate(bigScreenPageDTO.getType());
|
|
|
|
|
bigScreenPageDTO.setCode(code);
|
|
|
|
|
}
|
|
|
|
|
List<Chart> chartList = bigScreenPageDTO.getChartList();
|
|
|
|
@ -111,6 +123,15 @@ public class DataRoomPageServiceImpl extends ServiceImpl<DataRoomPageDao, PageEn
|
|
|
|
|
AssertUtils.isTrue(!checkCodeRepeat(bigScreenEntity), "编码重复");
|
|
|
|
|
this.save(bigScreenEntity);
|
|
|
|
|
dataRoomExtendClient.afterAdd(bigScreenEntity.getCode());
|
|
|
|
|
|
|
|
|
|
BizComponentUser bizComponentUser = new BizComponentUser();
|
|
|
|
|
bizComponentUser.setUserId(bigScreenPageDTO.getUserId());
|
|
|
|
|
bizComponentUser.setCode(code);
|
|
|
|
|
bizComponentUser.setType(bigScreenPageDTO.getType());
|
|
|
|
|
|
|
|
|
|
userDao.insert(bizComponentUser);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return bigScreenEntity.getCode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -208,17 +229,79 @@ public class DataRoomPageServiceImpl extends ServiceImpl<DataRoomPageDao, PageEn
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// public PageVO<PageEntity> getByCategory(DataRoomSearchDTO searchDTO) {
|
|
|
|
|
// if (StringUtils.isBlank(searchDTO.getType())) {
|
|
|
|
|
// throw new GlobalException("类型不能为空");
|
|
|
|
|
// }
|
|
|
|
|
// LambdaQueryWrapper<PageEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
// queryWrapper.like(StringUtils.isNotBlank(searchDTO.getSearchKey()), PageEntity::getName, searchDTO.getSearchKey());
|
|
|
|
|
// if (StringUtils.isNotBlank(searchDTO.getParentCode())) {
|
|
|
|
|
// queryWrapper.eq(PageEntity::getParentCode, searchDTO.getParentCode());
|
|
|
|
|
// }
|
|
|
|
|
// queryWrapper.eq(PageEntity::getType, searchDTO.getType());
|
|
|
|
|
// queryWrapper.select(PageEntity::getCode);
|
|
|
|
|
// List<PageEntity> idEntityList = this.list(queryWrapper);
|
|
|
|
|
// if (idEntityList == null || idEntityList.isEmpty()) {
|
|
|
|
|
// PageVO<PageEntity> pageVO = new PageVO<>();
|
|
|
|
|
// pageVO.setList(Lists.newArrayList());
|
|
|
|
|
// return pageVO;
|
|
|
|
|
// }
|
|
|
|
|
// List<String> codeList = idEntityList.stream().map(PageEntity::getCode).collect(Collectors.toList());
|
|
|
|
|
// List<String> filterByPermission = permissionClient.filterByPermission(codeList);
|
|
|
|
|
// if (filterByPermission == null || filterByPermission.isEmpty()) {
|
|
|
|
|
// PageVO<PageEntity> pageVO = new PageVO<>();
|
|
|
|
|
// pageVO.setList(Lists.newArrayList());
|
|
|
|
|
// return pageVO;
|
|
|
|
|
// }
|
|
|
|
|
// LambdaQueryWrapper<PageEntity> reQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
// if (idEntityList.size() == filterByPermission.size()) {
|
|
|
|
|
// // 说明没有过滤掉任何一个, 按照原来的条件查询
|
|
|
|
|
// reQueryWrapper = queryWrapper;
|
|
|
|
|
// } else {
|
|
|
|
|
// // 说明过滤掉了一些, 按照过滤后的编码查询
|
|
|
|
|
// reQueryWrapper.in(PageEntity::getCode, filterByPermission);
|
|
|
|
|
// }
|
|
|
|
|
// reQueryWrapper.select(PageEntity::getId, PageEntity::getAppCode, PageEntity::getCode, PageEntity::getName, PageEntity::getParentCode, PageEntity::getOrderNum, PageEntity::getCoverPicture, PageEntity::getUpdateDate);
|
|
|
|
|
// // 优先序号升序,其次创建时间降序
|
|
|
|
|
// reQueryWrapper.orderByAsc(PageEntity::getOrderNum);
|
|
|
|
|
// reQueryWrapper.orderByDesc(PageEntity::getCreateDate);
|
|
|
|
|
// PageVO<PageEntity> page = this.page(searchDTO, reQueryWrapper);
|
|
|
|
|
// List<PageEntity> list = page.getList();
|
|
|
|
|
// if (list == null || list.isEmpty()) {
|
|
|
|
|
// return page;
|
|
|
|
|
// }
|
|
|
|
|
// String urlPrefix = bigScreenConfig.getFile().getBasePath();
|
|
|
|
|
// if (!urlPrefix.endsWith("/")) {
|
|
|
|
|
// urlPrefix += "/";
|
|
|
|
|
// }
|
|
|
|
|
// for (PageEntity pageEntity : list) {
|
|
|
|
|
// String coverPicture = pageEntity.getCoverPicture();
|
|
|
|
|
// if (StringUtils.isBlank(coverPicture)) {
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// if (coverPicture.startsWith("/")) {
|
|
|
|
|
// coverPicture = coverPicture.substring(1);
|
|
|
|
|
// }
|
|
|
|
|
// pageEntity.setCoverPicture(urlPrefix + PathUtils.normalizePath(coverPicture));
|
|
|
|
|
// }
|
|
|
|
|
// return page;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageVO<PageEntity> getByCategory(DataRoomSearchDTO searchDTO) {
|
|
|
|
|
if (StringUtils.isBlank(searchDTO.getType())) {
|
|
|
|
|
throw new GlobalException("类型不能为空");
|
|
|
|
|
}
|
|
|
|
|
// 使用,分割type
|
|
|
|
|
List<String> types = Lists.newArrayList(searchDTO.getType().split(","));
|
|
|
|
|
LambdaQueryWrapper<PageEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.like(StringUtils.isNotBlank(searchDTO.getSearchKey()), PageEntity::getName, searchDTO.getSearchKey());
|
|
|
|
|
if (StringUtils.isNotBlank(searchDTO.getParentCode())) {
|
|
|
|
|
queryWrapper.eq(PageEntity::getParentCode, searchDTO.getParentCode());
|
|
|
|
|
}
|
|
|
|
|
queryWrapper.eq(PageEntity::getType, searchDTO.getType());
|
|
|
|
|
queryWrapper.in(PageEntity::getType, types);
|
|
|
|
|
//查询code code和userId关联
|
|
|
|
|
queryWrapper.select(PageEntity::getCode);
|
|
|
|
|
List<PageEntity> idEntityList = this.list(queryWrapper);
|
|
|
|
|
if (idEntityList == null || idEntityList.isEmpty()) {
|
|
|
|
@ -227,12 +310,15 @@ public class DataRoomPageServiceImpl extends ServiceImpl<DataRoomPageDao, PageEn
|
|
|
|
|
return pageVO;
|
|
|
|
|
}
|
|
|
|
|
List<String> codeList = idEntityList.stream().map(PageEntity::getCode).collect(Collectors.toList());
|
|
|
|
|
List<String> filterByPermission = permissionClient.filterByPermission(codeList);
|
|
|
|
|
List<String> filterByPermission = permissionClient.filterByPermission(codeList,searchDTO.getUserId(),searchDTO.getType());
|
|
|
|
|
if (filterByPermission == null || filterByPermission.isEmpty()) {
|
|
|
|
|
PageVO<PageEntity> pageVO = new PageVO<>();
|
|
|
|
|
pageVO.setList(Lists.newArrayList());
|
|
|
|
|
return pageVO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<PageEntity> reQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
if (idEntityList.size() == filterByPermission.size()) {
|
|
|
|
|
// 说明没有过滤掉任何一个, 按照原来的条件查询
|
|
|
|
@ -241,29 +327,13 @@ public class DataRoomPageServiceImpl extends ServiceImpl<DataRoomPageDao, PageEn
|
|
|
|
|
// 说明过滤掉了一些, 按照过滤后的编码查询
|
|
|
|
|
reQueryWrapper.in(PageEntity::getCode, filterByPermission);
|
|
|
|
|
}
|
|
|
|
|
reQueryWrapper.select(PageEntity::getId, PageEntity::getAppCode, PageEntity::getCode, PageEntity::getName, PageEntity::getParentCode, PageEntity::getOrderNum, PageEntity::getCoverPicture, PageEntity::getUpdateDate);
|
|
|
|
|
reQueryWrapper.select(PageEntity::getId, PageEntity::getCode, PageEntity::getName,
|
|
|
|
|
PageEntity::getParentCode, PageEntity::getOrderNum, PageEntity::getCoverPicture, PageEntity::getUpdateDate, PageEntity::getType);
|
|
|
|
|
// 优先序号升序,其次创建时间降序
|
|
|
|
|
reQueryWrapper.orderByAsc(PageEntity::getOrderNum);
|
|
|
|
|
reQueryWrapper.orderByDesc(PageEntity::getCreateDate);
|
|
|
|
|
PageVO<PageEntity> page = this.page(searchDTO, reQueryWrapper);
|
|
|
|
|
List<PageEntity> list = page.getList();
|
|
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
String urlPrefix = bigScreenConfig.getFile().getUrlPrefix();
|
|
|
|
|
if (!urlPrefix.endsWith("/")) {
|
|
|
|
|
urlPrefix += "/";
|
|
|
|
|
}
|
|
|
|
|
for (PageEntity pageEntity : list) {
|
|
|
|
|
String coverPicture = pageEntity.getCoverPicture();
|
|
|
|
|
if (StringUtils.isBlank(coverPicture)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (coverPicture.startsWith("/")) {
|
|
|
|
|
coverPicture = coverPicture.substring(1);
|
|
|
|
|
}
|
|
|
|
|
pageEntity.setCoverPicture(urlPrefix + PathUtils.normalizePath(coverPicture));
|
|
|
|
|
}
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|