forked from github/dataease
Merge pull request #11823 from dataease/pr@dev-v2@fixDS
Pr@dev v2@fix ds
This commit is contained in:
commit
08a6b2676b
@ -3,6 +3,7 @@ package io.dataease.exportCenter.manage;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.api.chart.dto.ViewDetailField;
|
||||
import io.dataease.api.chart.request.ChartExcelRequest;
|
||||
import io.dataease.api.chart.request.ChartExcelRequestInner;
|
||||
@ -10,6 +11,7 @@ import io.dataease.api.dataset.dto.DataSetExportRequest;
|
||||
import io.dataease.api.dataset.union.DatasetGroupInfoDTO;
|
||||
import io.dataease.api.dataset.union.UnionDTO;
|
||||
import io.dataease.extensions.datasource.api.PluginManageApi;
|
||||
import io.dataease.extensions.view.dto.DatasetRowPermissionsTreeObj;
|
||||
import io.dataease.model.ExportTaskDTO;
|
||||
import io.dataease.api.permissions.dataset.dto.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.auth.bo.TokenUserBO;
|
||||
@ -78,22 +80,24 @@ public class ExportCenterManage {
|
||||
DataVisualizationServer dataVisualizationServer;
|
||||
@Resource
|
||||
private CoreChartViewMapper coreChartViewMapper;
|
||||
@Resource
|
||||
private PermissionManage permissionManage;
|
||||
@Autowired
|
||||
private WsService wsService;
|
||||
@Autowired(required = false)
|
||||
private PluginManageApi pluginManage;
|
||||
@Resource
|
||||
private SysParameterManage sysParameterManage;
|
||||
@Value("${export.core.size:10}")
|
||||
@Value("${dataease.export.core.size:10}")
|
||||
private int core;
|
||||
@Value("${export.max.size:10}")
|
||||
@Value("${dataease.export.max.size:10}")
|
||||
private int max;
|
||||
|
||||
@Value("${export.dataset.limit:100000}")
|
||||
@Value("${dataease.export.dataset.limit:100000}")
|
||||
private int limit;
|
||||
private final static String DATA_URL_TITLE = "data:image/jpeg;base64,";
|
||||
private static final String exportData_path = "/opt/dataease2.0/data/exportData/";
|
||||
@Value("${extract.page.size:50000}")
|
||||
@Value("${dataease.export.page.size:50000}")
|
||||
private Integer extractPageSize;
|
||||
static private List<String> STATUS = Arrays.asList("SUCCESS", "FAILED", "PENDING", "IN_PROGRESS", "ALL");
|
||||
private ScheduledThreadPoolExecutor scheduledThreadPoolExecutor;
|
||||
@ -108,8 +112,6 @@ public class ExportCenterManage {
|
||||
@Resource
|
||||
private DatasetSQLManage datasetSQLManage;
|
||||
@Resource
|
||||
private PermissionManage permissionManage;
|
||||
@Resource
|
||||
private DatasetTableFieldManage datasetTableFieldManage;
|
||||
@Resource
|
||||
private DatasetDataManage datasetDataManage;
|
||||
@ -347,7 +349,7 @@ public class ExportCenterManage {
|
||||
datasetTableFieldDTO.setFieldShortName(ele.getDataeaseName());
|
||||
return datasetTableFieldDTO;
|
||||
}).collect(Collectors.toList());
|
||||
dto.setAllFields(allFields);
|
||||
|
||||
Map<String, Object> sqlMap = datasetSQLManage.getUnionSQLForEdit(dto, null);
|
||||
String sql = (String) sqlMap.get("sql");
|
||||
if (ObjectUtils.isEmpty(allFields)) {
|
||||
@ -358,6 +360,7 @@ public class ExportCenterManage {
|
||||
if (ObjectUtils.isEmpty(allFields)) {
|
||||
DEException.throwException(Translator.get("i18n_no_column_permission"));
|
||||
}
|
||||
dto.setAllFields(allFields);
|
||||
datasetDataManage.buildFieldName(sqlMap, allFields);
|
||||
Map<Long, DatasourceSchemaDTO> dsMap = (Map<Long, DatasourceSchemaDTO>) sqlMap.get("dsMap");
|
||||
DatasourceUtils.checkDsStatus(dsMap);
|
||||
@ -373,12 +376,19 @@ public class ExportCenterManage {
|
||||
}
|
||||
sql = Utils.replaceSchemaAlias(sql, dsMap);
|
||||
}
|
||||
|
||||
List<DataSetRowPermissionsTreeDTO> rowPermissionsTree = new ArrayList<>();
|
||||
TokenUserBO user = AuthUtils.getUser();
|
||||
if (user != null) {
|
||||
rowPermissionsTree = permissionManage.getRowPermissionsTree(dto.getId(), user.getUserId());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(request.getExpressionTree())) {
|
||||
Gson gson = new Gson();
|
||||
DatasetRowPermissionsTreeObj datasetRowPermissionsTreeObj = gson.fromJson(request.getExpressionTree(), DatasetRowPermissionsTreeObj.class);
|
||||
permissionManage.getField(datasetRowPermissionsTreeObj);
|
||||
DataSetRowPermissionsTreeDTO dataSetRowPermissionsTreeDTO = new DataSetRowPermissionsTreeDTO();
|
||||
dataSetRowPermissionsTreeDTO.setTree(datasetRowPermissionsTreeObj);
|
||||
rowPermissionsTree.add(dataSetRowPermissionsTreeDTO);
|
||||
}
|
||||
|
||||
Provider provider;
|
||||
if (crossDs) {
|
||||
@ -410,7 +420,7 @@ public class ExportCenterManage {
|
||||
datasourceRequest.setDsList(dsMap);
|
||||
Map<String, Object> previewData = datasetDataManage.buildPreviewData(provider.fetchResultField(datasourceRequest), allFields, desensitizationList);
|
||||
List<Map<String, Object>> data = (List<Map<String, Object>>) previewData.get("data");
|
||||
if (p == 1L) {
|
||||
if (p == 0L) {
|
||||
CellStyle cellStyle = wb.createCellStyle();
|
||||
Font font = wb.createFont();
|
||||
font.setFontHeightInPoints((short) 12);
|
||||
|
@ -9,7 +9,7 @@ import java.io.Serializable;
|
||||
* </p>
|
||||
*
|
||||
* @author fit2cloud
|
||||
* @since 2024-08-26
|
||||
* @since 2024-08-28
|
||||
*/
|
||||
@TableName("core_font")
|
||||
public class CoreFont implements Serializable {
|
||||
@ -51,6 +51,10 @@ public class CoreFont implements Serializable {
|
||||
*/
|
||||
private Boolean isBuiltin;
|
||||
|
||||
private Double size;
|
||||
|
||||
private String sizeType;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -107,6 +111,22 @@ public class CoreFont implements Serializable {
|
||||
this.isBuiltin = isBuiltin;
|
||||
}
|
||||
|
||||
public Double getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Double size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getSizeType() {
|
||||
return sizeType;
|
||||
}
|
||||
|
||||
public void setSizeType(String sizeType) {
|
||||
this.sizeType = sizeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CoreFont{" +
|
||||
@ -117,6 +137,8 @@ public class CoreFont implements Serializable {
|
||||
", isDefault = " + isDefault +
|
||||
", updateTime = " + updateTime +
|
||||
", isBuiltin = " + isBuiltin +
|
||||
", size = " + size +
|
||||
", sizeType = " + sizeType +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* </p>
|
||||
*
|
||||
* @author fit2cloud
|
||||
* @since 2024-08-26
|
||||
* @since 2024-08-28
|
||||
*/
|
||||
@Mapper
|
||||
public interface CoreFontMapper extends BaseMapper<CoreFont> {
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.dataease.font.manage;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import io.dataease.api.font.dto.FontDto;
|
||||
import io.dataease.chart.dao.auto.entity.CoreChartView;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.font.dao.auto.entity.CoreFont;
|
||||
import io.dataease.font.dao.auto.mapper.CoreFontMapper;
|
||||
@ -10,6 +12,7 @@ import io.dataease.utils.FileUtils;
|
||||
import io.dataease.utils.IDUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -25,6 +28,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -51,6 +55,11 @@ public class FontManage {
|
||||
}
|
||||
|
||||
public FontDto create(FontDto fontDto) {
|
||||
QueryWrapper<CoreFont> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("name", fontDto.getName());
|
||||
if (CollectionUtils.isNotEmpty(coreFontMapper.selectList(queryWrapper))) {
|
||||
DEException.throwException("存在重名字库");
|
||||
}
|
||||
fontDto.setId(IDUtils.snowID());
|
||||
CoreFont coreFont = new CoreFont();
|
||||
BeanUtils.copyBean(coreFont, fontDto);
|
||||
@ -64,6 +73,13 @@ public class FontManage {
|
||||
if (ObjectUtils.isEmpty(fontDto.getId())) {
|
||||
return create(fontDto);
|
||||
}
|
||||
if (fontDto.getIsDefault()) {
|
||||
UpdateWrapper<CoreFont> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.ne("id", fontDto.getId());
|
||||
CoreFont record = new CoreFont();
|
||||
record.setIsDefault(false);
|
||||
coreFontMapper.update(record, updateWrapper);
|
||||
}
|
||||
CoreFont coreFont = new CoreFont();
|
||||
BeanUtils.copyBean(coreFont, fontDto);
|
||||
coreFont.setUpdateTime(System.currentTimeMillis());
|
||||
@ -88,18 +104,25 @@ public class FontManage {
|
||||
coreFontMapper.update(record, queryWrapper);
|
||||
}
|
||||
|
||||
public String upload(MultipartFile file) {
|
||||
public FontDto upload(MultipartFile file) {
|
||||
String fileUuid = UUID.randomUUID().toString();
|
||||
return saveFile(file, fileUuid);
|
||||
}
|
||||
|
||||
public void download(Long id, HttpServletResponse response) {
|
||||
CoreFont coreFont = coreFontMapper.selectById(id);
|
||||
public void download(String file, HttpServletResponse response) {
|
||||
|
||||
QueryWrapper<CoreFont> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("file_trans_name", file);
|
||||
List<CoreFont> coreFonts = coreFontMapper.selectList(queryWrapper);
|
||||
if (CollectionUtils.isNotEmpty(coreFonts)) {
|
||||
DEException.throwException("不存在的字库文件");
|
||||
}
|
||||
|
||||
try {
|
||||
response.setContentType("application/x-download");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + coreFont.getFileTransName());
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + coreFonts.get(0).getFileTransName());
|
||||
try (ServletOutputStream out = response.getOutputStream();
|
||||
InputStream stream = new FileInputStream(path + coreFont.getFileTransName())) {
|
||||
InputStream stream = new FileInputStream(path + coreFonts.get(0).getFileTransName())) {
|
||||
byte buff[] = new byte[1024];
|
||||
int length;
|
||||
while ((length = stream.read(buff)) > 0) {
|
||||
@ -125,8 +148,8 @@ public class FontManage {
|
||||
return fontDtos;
|
||||
}
|
||||
|
||||
private static String saveFile(MultipartFile file, String fileNameUUID) throws DEException {
|
||||
String fileTransName = "";
|
||||
private static FontDto saveFile(MultipartFile file, String fileNameUUID) throws DEException {
|
||||
FontDto fontDto = new FontDto();
|
||||
try {
|
||||
String filename = file.getOriginalFilename();
|
||||
String suffix = filename.substring(filename.lastIndexOf(".") + 1);
|
||||
@ -136,11 +159,29 @@ public class FontManage {
|
||||
fileOutputStream.write(file.getBytes());
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
fileTransName = fileNameUUID + "." + suffix;
|
||||
fontDto.setFileTransName(fileNameUUID + "." + suffix);
|
||||
|
||||
long length = file.getSize();
|
||||
String unit = "MB";
|
||||
Double size = 0.0;
|
||||
if ((double) length / 1024 / 1024 > 1) {
|
||||
if ((double) length / 1024 / 1024 / 1024 > 1) {
|
||||
unit = "GB";
|
||||
size = Double.valueOf(String.format("%.2f", (double) length / 1024 / 1024 / 1024));
|
||||
} else {
|
||||
size = Double.valueOf(String.format("%.2f", (double) length / 1024 / 1024));
|
||||
}
|
||||
} else {
|
||||
unit = "KB";
|
||||
size = Double.valueOf(String.format("%.2f", (double) length / 1024));
|
||||
}
|
||||
fontDto.setSize(size);
|
||||
fontDto.setSizeType(unit);
|
||||
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(e);
|
||||
}
|
||||
return fileTransName;
|
||||
return fontDto;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,13 +45,13 @@ public class FontServer implements FontApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upload(MultipartFile file) throws DEException {
|
||||
public FontDto upload(MultipartFile file) throws DEException {
|
||||
return fontManage.upload(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(Long id, HttpServletResponse response) throws DEException {
|
||||
fontManage.download(id, response);
|
||||
public void download(String file, HttpServletResponse response) throws DEException {
|
||||
fontManage.download(file, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,3 +84,5 @@ CREATE TABLE `core_font`
|
||||
`is_BuiltIn` tinyint(1) default 0 COMMENT '是否内置',
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
ALTER TABLE `core_font` ADD COLUMN `size` DOUBLE NULL AFTER `is_BuiltIn`;
|
||||
ALTER TABLE `core_font` ADD COLUMN `size_type` varchar(255) NULL AFTER `size`;
|
||||
|
@ -10,16 +10,15 @@ const state = reactive({
|
||||
})
|
||||
const loading = ref(false)
|
||||
const upload = ref()
|
||||
const uploadFile = ref('')
|
||||
const fileName = ref('')
|
||||
const uploadExcel = () => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', state.fileList.raw)
|
||||
fileName.value = state.fileList.raw.name
|
||||
ruleForm.fileName = state.fileList.raw.name
|
||||
loading.value = true
|
||||
return uploadFontFile(formData)
|
||||
.then(res => {
|
||||
uploadFile.value = res.data
|
||||
ruleForm.size = res.data.size
|
||||
ruleForm.fileTransName = res.data.fileTransName
|
||||
upload.value?.clearFiles()
|
||||
loading.value = false
|
||||
})
|
||||
@ -42,6 +41,8 @@ const defaultForm = {
|
||||
name: '',
|
||||
fileName: '',
|
||||
fileTransName: '',
|
||||
size: 0,
|
||||
sizeType: '',
|
||||
isDefault: 0,
|
||||
isBuiltin: 0,
|
||||
updateTime: 0
|
||||
@ -86,12 +87,9 @@ const confirm = () => {
|
||||
ruleFormRef.value.validate(val => {
|
||||
if (val) {
|
||||
if (action.value === 'uploadFile') {
|
||||
if (uploadFile.value === '') {
|
||||
if (ruleForm.fileTransName === '') {
|
||||
ElMessage.error('请上传字库文件')
|
||||
return
|
||||
} else {
|
||||
ruleForm.fileTransName = uploadFile.value
|
||||
ruleForm.fileName = fileName.value
|
||||
}
|
||||
}
|
||||
edit(ruleForm).then(res => {
|
||||
@ -144,8 +142,8 @@ const confirm = () => {
|
||||
<FontInfo
|
||||
@del="fontDel"
|
||||
v-show="state.fileList"
|
||||
size="52.2M"
|
||||
name="OsakaMono.ttf"
|
||||
:size="ruleForm.size + ruleForm.sizeType"
|
||||
:name="ruleForm.fileName"
|
||||
></FontInfo>
|
||||
<el-upload
|
||||
action=""
|
||||
|
@ -42,10 +42,10 @@ public interface FontApi {
|
||||
public void changeDefault(@RequestBody FontDto fontDto);
|
||||
|
||||
@PostMapping("/uploadFile")
|
||||
String upload(@RequestParam("file") MultipartFile file) throws DEException;
|
||||
FontDto upload(@RequestParam("file") MultipartFile file) throws DEException;
|
||||
|
||||
@GetMapping("/download/{id}")
|
||||
void download(@PathVariable("id") Long id, HttpServletResponse response) throws DEException;
|
||||
@GetMapping("/download/{file}")
|
||||
void download(@PathVariable("file") String file, HttpServletResponse response) throws DEException;
|
||||
|
||||
@GetMapping("/defaultFont")
|
||||
List<FontDto> defaultFont() throws DEException;
|
||||
|
@ -30,5 +30,7 @@ public class FontDto {
|
||||
private Boolean isDefault;
|
||||
private Long updateTime;
|
||||
private Boolean isBuiltin;
|
||||
private Double size;
|
||||
private String sizeType;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ public class ConnectionObj implements AutoCloseable {
|
||||
}
|
||||
|
||||
if (session != null) {
|
||||
System.out.println("session.disconnect()");
|
||||
session.disconnect();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user