feat:合并master分支到optimize分支

main
liu.tao3 2 years ago
commit aab1946633

41
.gitignore vendored

@ -3,6 +3,7 @@ gc-starter-dashboard-ui
chuangDa chuangDa
chuangDa.zip chuangDa.zip
deploy.sh deploy.sh
bigScreen
dist dist
gc-starter-lowcode-ui gc-starter-lowcode-ui
### VisualStudioCode template ### VisualStudioCode template
@ -277,8 +278,6 @@ dist
# TODO: where does this rule come from? # TODO: where does this rule come from?
docs/_book docs/_book
# TODO: where does this rule come from?
test/
### Windows template ### Windows template
# Windows thumbnail cache files # Windows thumbnail cache files
@ -370,3 +369,41 @@ GitHub.sublime-settings
lib lib
gc-starter-lowcode-ui gc-starter-lowcode-ui
libApp libApp
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
# 忽略配置文件提交
application-*.yml
!application-demo.yml

@ -1,41 +0,0 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
# 忽略配置文件提交
application-*.yml
!application-demo.yml
logs
upload.sh

@ -21,7 +21,7 @@
<dependency> <dependency>
<groupId>com.gccloud</groupId> <groupId>com.gccloud</groupId>
<artifactId>dataset-core</artifactId> <artifactId>dataset-core</artifactId>
<version>0.0.1.2023062001.Alpha</version> <version>0.0.1.2023062101.Alpha</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

@ -26,25 +26,25 @@
</encoder> </encoder>
</appender> </appender>
<!-- <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">--> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- &lt;!&ndash; 追加日志到原文件结尾 &ndash;&gt;--> <!-- 追加日志到原文件结尾 -->
<!-- <Prudent>true</Prudent>--> <Prudent>true</Prudent>
<!-- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">--> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!-- &lt;!&ndash;格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度 %method 方法名 %L 行数 %msg日志消息%n是换行符&ndash;&gt;--> <!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度 %method 方法名 %L 行数 %msg日志消息%n是换行符-->
<!-- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %X{traceId:-} [%thread] %-5level %logger{56}.%method:%L - %msg%n</pattern>--> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %X{traceId:-} [%thread] %-5level %logger{56}.%method:%L - %msg%n</pattern>
<!-- <charset>utf-8</charset>--> <charset>utf-8</charset>
<!-- </encoder>--> </encoder>
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">--> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- &lt;!&ndash;日志文件输出的文件名 每小时生成日志文件&ndash;&gt;--> <!--日志文件输出的文件名 每小时生成日志文件-->
<!-- <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>--> <FileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!-- &lt;!&ndash;日志文件保留天数&ndash;&gt;--> <!--日志文件保留天数-->
<!-- <MaxHistory>30</MaxHistory>--> <MaxHistory>30</MaxHistory>
<!-- &lt;!&ndash; 除按日志记录之外还配置了日志文件不能超过100M(默认)若超过100M日志文件会以索引0开始 &ndash;&gt;--> <!-- 除按日志记录之外还配置了日志文件不能超过100M(默认)若超过100M日志文件会以索引0开始 -->
<!-- <maxFileSize>100MB</maxFileSize>--> <maxFileSize>100MB</maxFileSize>
<!-- &lt;!&ndash; 日志文件大小和超过10GMB会清空之前的 &ndash;&gt;--> <!-- 日志文件大小和超过10GMB会清空之前的 -->
<!-- <totalSizeCap>10GB</totalSizeCap>--> <totalSizeCap>10GB</totalSizeCap>
<!-- </rollingPolicy>--> </rollingPolicy>
<!-- </appender>--> </appender>
<!-- SpringBoot 默认的 --> <!-- SpringBoot 默认的 -->
<logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR"/> <logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR"/>
@ -70,7 +70,7 @@
</springProfile> </springProfile>
<root level="INFO"> <root level="INFO">
<!-- <appender-ref ref="FILE"/>--> <appender-ref ref="FILE"/>
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
</root> </root>

@ -0,0 +1,353 @@
import com.alibaba.druid.pool.DruidDataSource;
import com.gccloud.common.utils.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author hongyang
* @version 1.0
* @date 2023/6/20 15:29
*/
@Slf4j
@RunWith(SpringRunner.class)
public class DataMigrationTest {
/**
*
*
* 1. doc/update.sql
* 2.
*/
@Test
public void dataMigration() {
// 设置数据源
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/dataroom?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF-8");
dataSource.setUsername("root");
dataSource.setPassword("pwd");
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
// 处理数据源
log.info("开始处理数据源");
handleDataSource(jdbcTemplate);
// 处理分类
log.info("开始处理分类");
handleCategory(jdbcTemplate);
// 处理数据集
log.info("开始处理数据集");
handleDataset(jdbcTemplate);
}
/**
*
* @param jdbcTemplate
*/
private static void handleDataSource(JdbcTemplate jdbcTemplate) {
String migrateSql = "INSERT INTO ds_datasource (id, source_name, source_type, driver_class_name, url, host, port, username, password, module_code, editable, remark, update_date, create_date, del_flag)\n" +
"SELECT id, source_name, source_type, driver_class_name, url, host, port, username, password, module_code, editable, remark, update_date, create_date, del_flag\n" +
"FROM big_screen_datasource_config where del_flag = 0";
jdbcTemplate.execute(migrateSql);
String updateSql = "UPDATE ds_datasource SET source_type = 'PostgreSQL' where source_type = 'TelePG'";
jdbcTemplate.execute(updateSql);
String updateSql2 = "UPDATE ds_datasource SET source_type = 'Mysql' where source_type = 'TeleDB'";
jdbcTemplate.execute(updateSql2);
log.info("数据源数据迁移完成");
}
/**
* idsSQL
*/
public static final String updateSql = "update ds_category_tree set ids = '%s' where id = '%s'";
/**
*
* @param jdbcTemplate
*/
private static void handleCategory(JdbcTemplate jdbcTemplate) {
String migrateSql = "INSERT INTO ds_category_tree (id, name, parent_id, type, module_code, update_date, create_date, del_flag)\n" +
"SELECT id, name, parent_id, table_name, module_code, update_date, create_date, del_flag\n" +
"FROM big_screen_category_tree where del_flag = 0";
jdbcTemplate.execute(migrateSql);
String sql = "select * from ds_category_tree where del_flag = 0";
List<Map<String, Object>> categoryList = jdbcTemplate.queryForList(sql);
// 根据parent_id组装成树形结构将子节点放到父节点的children中并组装ids
Map<String, Map<String, Object>> categoryMap = Maps.newHashMap();
categoryList.forEach(category -> categoryMap.put(category.get("id").toString(), category));
categoryList.forEach(category -> {
String parentId = category.get("parent_id").toString();
if (StringUtils.isBlank(parentId) || "0".equals(parentId)) {
return;
}
Map<String, Object> parentCategory = categoryMap.get(parentId);
if (parentCategory == null) {
return;
}
List<Map<String, Object>> children = (List<Map<String, Object>>) parentCategory.get("children");
if (children == null) {
children = Lists.newArrayList();
parentCategory.put("children", children);
}
children.add(category);
});
// 取出根节点
List<Map<String, Object>> rootCategoryList = categoryList.stream().filter(category -> {
String parentId = category.get("parent_id").toString();
return StringUtils.isBlank(parentId) || "0".equals(parentId);
}).collect(Collectors.toList());
// 处理ids
handleIds(rootCategoryList, "");
List<String> updateSqlList = Lists.newArrayList();
// 类型修改
updateSqlList.add("update ds_category_tree set type = 'dataset' where type = 'r_dataset'");
// 组装update sql
getUpdateSql(rootCategoryList, updateSqlList);
// 批量执行update sql
jdbcTemplate.batchUpdate(updateSqlList.toArray(new String[0]));
log.info("分类树数据迁移完成");
}
/**
* ids
* @param categoryList
* @param parentIds
*/
private static void handleIds(List<Map<String, Object>> categoryList, String parentIds) {
if (categoryList == null || categoryList.isEmpty()) {
return;
}
categoryList.forEach(category -> {
String id = category.get("id").toString();
String ids = parentIds + "," + id;
if (StringUtils.isBlank(parentIds)) {
ids = id;
}
category.put("ids", ids);
List<Map<String, Object>> children = (List<Map<String, Object>>) category.get("children");
handleIds(children, ids);
});
}
/**
* update sql
* @param categoryList
* @param updateSqlList
*/
private static void getUpdateSql(List<Map<String, Object>> categoryList, List<String> updateSqlList) {
if (categoryList == null || categoryList.isEmpty()) {
return;
}
categoryList.forEach(category -> {
String id = category.get("id").toString();
String ids = category.get("ids").toString();
updateSqlList.add(String.format(updateSql, ids, id));
List<Map<String, Object>> children = (List<Map<String, Object>>) category.get("children");
getUpdateSql(children, updateSqlList);
});
}
/**
* SQL
*/
public static final String insertSql = "INSERT INTO ds_dataset (id, name, code, type_id, remark, dataset_type, module_code, editable, source_id, cache, config) VALUES ('%s', '%s', '%s', %s, '%s', '%s', '%s', %s, %s, %s, '%s');";
/**
*
* @param jdbcTemplate
*/
private static void handleDataset(JdbcTemplate jdbcTemplate) {
// 新增SQL集合
List<String> insertSqlList = Lists.newArrayList();
// 处理JSON类型的数据集
String sql = "select * from big_screen_dataset where dataset_type = 'json' and del_flag = 0";
List<Map<String, Object>> jsonDatasetList = jdbcTemplate.queryForList(sql);
for (Map<String, Object> dataset : jsonDatasetList) {
String data = dataset.get("data").toString();
// 解析data
JSONObject dataJson = JSON.parseObject(data);
Object json = dataJson.get("json");
JSONObject fieldDesc = dataJson.getJSONObject("fieldDesc");
// 遍历fieldDesc取出key和value
Set<String> keySet = fieldDesc.keySet();
List<Map<String, Object>> fieldList = Lists.newArrayList();
for (String key : keySet) {
Object value = fieldDesc.get(key);
Map<String, Object> fieldMap = Maps.newHashMap();
fieldMap.put("fieldName", key);
fieldMap.put("fieldDesc", value);
fieldList.add(fieldMap);
}
JSONObject jsonConfig = new JSONObject();
jsonConfig.put("fieldList", fieldList);
String jsonStr = JSON.toJSONString(json);
jsonConfig.put("json", escape(jsonStr));
jsonConfig.put("fieldDesc", fieldDesc);
jsonConfig.put("className", "com.gccloud.dataset.entity.config.JsonDataSetConfig");
String config = JSON.toJSONString(jsonConfig);
String insertSql = getInsertSql(dataset, config);
insertSqlList.add(insertSql);
}
// 处理script类型的数据集
sql = "select * from big_screen_dataset where dataset_type = 'script' and del_flag = 0";
List<Map<String, Object>> scriptDatasetList = jdbcTemplate.queryForList(sql);
for (Map<String, Object> dataset : scriptDatasetList) {
String data = dataset.get("data").toString();
// 解析data
JSONObject dataJson = JSON.parseObject(data);
Object script = dataJson.get("script");
Object paramsList = dataJson.get("paramsList");
JSONObject fieldDesc = dataJson.getJSONObject("fieldDesc");
// 遍历fieldDesc取出key和value
Set<String> keySet = fieldDesc.keySet();
List<Map<String, Object>> fieldList = Lists.newArrayList();
for (String key : keySet) {
Object value = fieldDesc.get(key);
Map<String, Object> fieldMap = Maps.newHashMap();
fieldMap.put("fieldName", key);
fieldMap.put("fieldDesc", value);
fieldList.add(fieldMap);
}
JSONObject jsonConfig = new JSONObject();
jsonConfig.put("fieldList", fieldList);
jsonConfig.put("script", escape(script.toString()));
jsonConfig.put("paramsList", paramsList);
jsonConfig.put("fieldDesc", fieldDesc);
jsonConfig.put("className", "com.gccloud.dataset.entity.config.GroovyDataSetConfig");
String config = JSON.toJSONString(jsonConfig);
String insertSql = getInsertSql(dataset, config);
insertSqlList.add(insertSql);
}
// 处理original类型的数据集
sql = "select a.*,b.* from big_screen_dataset a left join big_screen_datasets_original b on a.dataset_rel_id = b.id where a.dataset_rel_id is not null and a.dataset_type = 'original' and a.del_flag = 0 and b.del_flag =0";
List<Map<String, Object>> originalDatasetList = jdbcTemplate.queryForList(sql);
for (Map<String, Object> dataset : originalDatasetList) {
String sourceId = dataset.get("source_id").toString();
String tableName = dataset.get("table_name").toString();
Object repeatStatus = dataset.get("repeat_status");
Object fieldDesc = dataset.get("field_desc");
JSONObject fieldDescObj = JSON.parseObject(fieldDesc.toString());
String fieldInfo = dataset.get("field_info").toString();
JSONArray fieldJson = JSON.parseArray(dataset.get("field_json").toString());
List<Map<String, Object>> fieldList = Lists.newArrayList();
fieldJson.toList().forEach(field -> {
Map<String, Object> fieldMap = Maps.newHashMap();
fieldMap.put("fieldName", ((Map) field).get("columnName"));
fieldMap.put("fieldType", ((Map) field).get("columnType"));
fieldMap.put("orderNum", ((Map) field).get("orderNum"));
fieldMap.put("sourceTable", ((Map) field).get("sourceTable"));
fieldMap.put("fieldDesc", ((Map) field).get("fieldDesc"));
fieldList.add(fieldMap);
});
JSONObject jsonConfig = new JSONObject();
jsonConfig.put("sourceId", sourceId);
jsonConfig.put("tableName", tableName);
jsonConfig.put("repeatStatus", repeatStatus);
jsonConfig.put("fieldDesc", fieldDescObj);
jsonConfig.put("fieldInfo", fieldInfo);
jsonConfig.put("fieldList", fieldList);
jsonConfig.put("className", "com.gccloud.dataset.entity.config.OriginalDataSetConfig");
String config = JSON.toJSONString(jsonConfig);
String insertSql = getInsertSql(dataset, config);
insertSqlList.add(insertSql);
}
// 处理custom、storedProcedure类型的数据集
sql = "select a.*, b.*\n" +
"from big_screen_dataset a\n" +
" left join big_screen_datasets_custom b on a.dataset_rel_id = b.id\n" +
"where a.dataset_rel_id is not null\n" +
" and ( a.dataset_type = 'storedProcedure' or a.dataset_type = 'custom')\n" +
" and a.del_flag = 0\n" +
" and b.del_flag = 0\n";
List<Map<String, Object>> customDatasetList = jdbcTemplate.queryForList(sql);
for (Map<String, Object> dataset : customDatasetList) {
String sourceId = dataset.get("source_id").toString();
String sqlProcess = dataset.get("sql_process").toString();
Object fieldDesc = dataset.get("field_desc");
JSONObject fieldDescObj = JSON.parseObject(fieldDesc.toString());
Object paramList = dataset.get("param_config");
JSONArray fieldJson = JSON.parseArray(dataset.get("field_json").toString());
List<Map<String, Object>> fieldList = Lists.newArrayList();
fieldJson.toList().forEach(field -> {
Map<String, Object> fieldMap = Maps.newHashMap();
fieldMap.put("fieldName", ((Map) field).get("columnName"));
fieldMap.put("fieldType", ((Map) field).get("columnType"));
fieldMap.put("orderNum", ((Map) field).get("orderNum"));
fieldMap.put("sourceTable", ((Map) field).get("sourceTable"));
fieldMap.put("fieldDesc", ((Map) field).get("fieldDesc"));
fieldList.add(fieldMap);
});
JSONObject jsonConfig = new JSONObject();
jsonConfig.put("sourceId", sourceId);
jsonConfig.put("sqlProcess", escape(sqlProcess));
jsonConfig.put("fieldDesc", fieldDescObj);
jsonConfig.put("fieldList", fieldList);
JSONArray paramsList = new JSONArray();
if (StringUtils.isNotBlank(paramList.toString())) {
paramsList = JSON.parseArray(paramList.toString());
}
jsonConfig.put("paramsList", paramsList);
if (dataset.get("dataset_type").toString().equals("storedProcedure")) {
jsonConfig.put("className", "com.gccloud.dataset.entity.config.StoredProcedureDataSetConfig");
} else {
jsonConfig.put("className", "com.gccloud.dataset.entity.config.CustomDataSetConfig");
}
String config = JSON.toJSONString(jsonConfig);
String insertSql = getInsertSql(dataset, config);
insertSqlList.add(insertSql);
}
// 批量新增
insertSqlList.forEach(jdbcTemplate::execute);
log.info("数据集配置迁移完成");
}
/**
* sql
* @param dataset
* @param config
* @return
*/
private static String getInsertSql(Map<String, Object> dataset, String config) {
String id = dataset.get("id").toString();
String name = dataset.get("name").toString();
String type_id = dataset.get("type_id") == null ? "null" : dataset.get("type_id").toString();
String remark = dataset.get("remark").toString();
String dataset_type = dataset.get("dataset_type").toString();
String module_code = "";
String editable = dataset.get("editable").toString();
String source_id = dataset.get("source_id") == null ? "null" : dataset.get("source_id").toString();
String code = "";
String cache = "0";
return String.format(insertSql, id, name, code, type_id, remark, dataset_type, module_code, editable, source_id, cache, config);
}
/**
*
* @param str
* @return
*/
private static String escape(String str) {
str = str.replace("\\", "\\\\");
str = str.replace("'", "\\'");
str = str.replace("\"", "\\\"");
str = str.replace("\n", "\\n");
str = str.replace("\r", "\\r");
str = str.replace("\t", "\\t");
return str;
}
}

@ -0,0 +1,175 @@
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* sql
* @author hongyang
* @version 1.0
* @date 2023/5/30 13:55
*/
@Slf4j
@RunWith(SpringRunner.class)
public class GetResourceSqlTest {
/**
*
*/
public static final String FOLDER_PATH = "/Users/liuchengbiao/Desktop/大屏资源";
/**
* gc.file.basePath
*/
public static final String FILE_BASE_PATH = "/root/bigscreen/file";
/**
* gc.file.urlPrefix
*/
public static final String FILE_URL_PREFIX = "http://gcpaas.gccloud.com/bigScreenServer/static";
/**
*
*/
public static final String FILE_GROUP_CODE = "other";
@Test
public void getResourceSql() {
List<String> sqlList = new ArrayList<>();
// 需要处理的文件夹
File folder = new File(FOLDER_PATH);
if (!folder.exists() || !folder.isDirectory()) {
log.error("文件夹不存在");
return;
}
File[] subFiles = folder.listFiles();
if (subFiles == null) {
log.error("文件夹为空");
return;
}
for (File subFile : subFiles) {
String typeCode = FILE_GROUP_CODE;
if (subFile.isDirectory()) {
// 获取文件夹名称
String folderName = subFile.getName();
// 生成编码
typeCode = RandomStringUtils.randomAlphanumeric(10).toLowerCase();
// 创建时间
String currentDate = getCurrentDateTime();
String insertTypeSql = "INSERT INTO big_screen_type (name, code, type, order_num, update_date, create_date, del_flag) VALUES ('%s', '%s', '%s', %s, '%s', '%s', %s);";
String insertTypeSqlFormat = String.format(insertTypeSql, folderName, typeCode, "resourceCatalog", 0, currentDate, currentDate, 0);
sqlList.add("# 分组");
sqlList.add(insertTypeSqlFormat);
sqlList.add("# 资源");
}
handleFile(subFile, "", sqlList, typeCode);
}
// 将sql输出到文件
String sql = String.join("\n", sqlList);
String fileName = "big_screen_file.sql";
String filePath = FOLDER_PATH + "/" + fileName;
// 写入文件
try {
FileUtils.write(new File(filePath), sql, "UTF-8");
} catch (Exception e) {
log.error("写入sql文件失败");
log.error(ExceptionUtils.getStackTrace(e));
}
log.info("sql生成到文件{}", FOLDER_PATH + "/big_screen_file.sql");
log.info("重命名后的文件路径:{}", FOLDER_PATH + "_重命名");
}
/**
* /
* @param file /
* @param relativePath FOLDER_PATH
* @param sqlList sql
*/
private static void handleFile(File file, String relativePath, List<String> sqlList, String typeCode) {
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files == null) {
return;
}
for (File subFile : files) {
String subRelativePath = relativePath + "/" + file.getName();
handleFile(subFile, subRelativePath, sqlList, typeCode);
}
return;
}
// 原始文件名
String originalName = file.getName();
// 文件后缀
String extension = getFileExtension(originalName);
// 新文件名
String newFileName = IdWorker.getIdStr()+ "." + extension;
// 新文件路径
String newPath = FOLDER_PATH + "_重命名" + relativePath + "/" + newFileName;
// 复制文件
Path sourcePath = file.toPath();
Path targetPath = new File(newPath).toPath();
try {
// 创建文件夹
Files.createDirectories(targetPath.getParent());
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
log.error(ExceptionUtils.getStackTrace(e));
}
// 在服务器上的文件路径
String path = FILE_BASE_PATH + relativePath;
// 文件访问地址
String url = FILE_URL_PREFIX + relativePath + "/" + newFileName;
// 替换可能存在的反斜杠
url = url.replace("\\", "/");
// 文件大小
long size = file.length();
// 创建时间
String currentDate = getCurrentDateTime();
// 生成sql
String sql = String.format("INSERT INTO big_screen_file (module, original_name, new_name, extension, path, url, size, download_count, create_date, update_date, del_flag) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d);",
typeCode, originalName, newFileName, extension, path, url, size, 0, currentDate, currentDate, 0);
sqlList.add(sql);
}
/**
*
* @param fileName
* @return
*/
private static String getFileExtension(String fileName) {
int dotIndex = fileName.lastIndexOf('.');
if (dotIndex > 0 && dotIndex < fileName.length() - 1) {
return fileName.substring(dotIndex + 1);
}
return "";
}
/**
*
* @return
*/
private static String getCurrentDateTime() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date currentDate = new Date();
return dateFormat.format(currentDate);
}
}

@ -1,2 +1,60 @@
UPDATE big_screen_page SET config = REPLACE(config, '"className":"com.gccloud.bigscreen', '"className":"com.gccloud.dataroom') WHERE type = 'bigScreen';
UPDATE big_screen_page SET config = REPLACE(config, '"className":"com.gccloud.dataroom.core.module.manage.dto.BigScreenPageDTO', '"className":"com.gccloud.dataroom.core.module.manage.dto.DataRoomPageDTO') WHERE type = 'bigScreen'; -- 更新大屏配置的类名
UPDATE big_screen_page SET config = REPLACE(config, '"className":"com.gccloud.bigscreen', '"className":"com.gccloud.dataroom');
UPDATE big_screen_page SET config = REPLACE(config, '"className":"com.gccloud.dataroom.core.module.manage.dto.BigScreenPageDTO', '"className":"com.gccloud.dataroom.core.module.manage.dto.DataRoomPageDTO');
-- 新增数据集相关的表
DROP TABLE IF EXISTS `ds_category_tree`;
CREATE TABLE `ds_category_tree` (
`id` bigint(64) NOT NULL AUTO_INCREMENT COMMENT '主键',
`ids` text COMMENT 'id序列',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`parent_id` bigint(64) DEFAULT NULL COMMENT '父级ID',
`type` varchar(255) NOT NULL,
`module_code` varchar(255) DEFAULT NULL,
`update_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
`create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`del_flag` tinyint(2) NOT NULL DEFAULT '0' COMMENT '删除标识',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='数据集种类树';
DROP TABLE IF EXISTS `ds_datasource`;
CREATE TABLE `ds_datasource` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`source_name` varchar(255) DEFAULT NULL COMMENT '数据源名称',
`source_type` varchar(255) DEFAULT NULL COMMENT '数据源类型',
`driver_class_name` varchar(255) DEFAULT NULL COMMENT '连接驱动',
`url` varchar(255) DEFAULT NULL COMMENT '连接url',
`host` varchar(255) DEFAULT NULL COMMENT '主机',
`port` int(16) DEFAULT NULL COMMENT '端口',
`username` varchar(255) DEFAULT NULL COMMENT '用户名',
`password` text COMMENT '密码',
`module_code` varchar(255) DEFAULT NULL COMMENT '模块编码',
`editable` tinyint(2) DEFAULT '0' COMMENT '是否可编辑0 不可编辑 1 可编辑',
`remark` varchar(255) DEFAULT NULL,
`update_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
`create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`del_flag` tinyint(2) NOT NULL DEFAULT '0' COMMENT '删除标识',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='数据源配置表';
DROP TABLE IF EXISTS `ds_dataset`;
CREATE TABLE `ds_dataset` (
`id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '名称',
`code` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '编码',
`type_id` varchar(255) DEFAULT NULL COMMENT '种类ID',
`remark` text CHARACTER SET utf8 COMMENT '描述',
`dataset_type` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '数据集类型(自定义数据集 custom、模型数据集model、原始数据集original、API数据集api、JSON数据集 json',
`module_code` varchar(255) COLLATE utf8_general_mysql500_ci DEFAULT NULL COMMENT '模块编码',
`editable` tinyint(2) NOT NULL DEFAULT '0' COMMENT '是否可编辑0 不可编辑 1 可编辑',
`source_id` bigint(32) DEFAULT NULL COMMENT '数据源ID',
`cache` tinyint(1) DEFAULT 0 NOT NULL COMMENT '是否对执行结构缓存 0 不缓存 1 缓存',
`config` longtext COMMENT '数据集配置',
`update_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
`create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`del_flag` tinyint(2) NOT NULL DEFAULT '0' COMMENT '删除标识',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_mysql500_ci COMMENT='数据集表';

@ -11,7 +11,7 @@
> >
<div class="bs-table-box"> <div class="bs-table-box">
<el-table <el-table
:data="outputFieldList" :data="insideFieldList"
:border="true" :border="true"
align="center" align="center"
class="bs-el-table" class="bs-el-table"
@ -72,11 +72,14 @@ export default {
data () { data () {
return { return {
dialogVisible: false, dialogVisible: false,
structurePreviewListCopy: [] structurePreviewListCopy: [],
//
insideFieldList: []
} }
}, },
methods: { methods: {
open () { open () {
this.insideFieldList = cloneDeep(this.outputFieldList)
this.dialogVisible = true this.dialogVisible = true
}, },
close () { close () {
@ -89,11 +92,12 @@ export default {
this.dialogVisible = false this.dialogVisible = false
}, },
setField () { setField () {
if (this.outputFieldList.length) { if (this.insideFieldList.length) {
this.fieldDesc = {} this.fieldDesc = {}
this.outputFieldList.forEach(key => { this.insideFieldList.forEach(key => {
this.fieldDesc[key.fieldName] = key.fieldDesc this.fieldDesc[key.fieldName] = key.fieldDesc
}) })
this.$emit('setFieldList', this.insideFieldList)
} else { } else {
this.fieldDesc = null this.fieldDesc = null
} }

@ -9,7 +9,7 @@
<template slot="content"> <template slot="content">
<div class="page-header"> <div class="page-header">
<div class="page-header-left"> <div class="page-header-left">
{{ !isEdit ? 'js数据集详情' : dataForm.id ? 'js数据集编辑' : 'js数据集新增' }} {{ !isEdit ? 'JS数据集详情' : dataForm.id ? 'JS数据集编辑' : 'JS数据集新增' }}
</div> </div>
<div class="page-header-right"> <div class="page-header-right">
<el-button <el-button
@ -140,7 +140,7 @@
<div style="text-align: center; padding: 16px 0;"> <div style="text-align: center; padding: 16px 0;">
<el-button <el-button
type="primary" type="primary"
@click="toExecute" @click="scriptExecute()"
> >
执行 执行
</el-button> </el-button>
@ -154,7 +154,7 @@
<div class="right-setting"> <div class="right-setting">
<div class="paramConfig"> <div class="paramConfig">
<div class="title-style bs-title-style"> <div class="title-style bs-title-style">
方法参数 动态参数
<el-button <el-button
type="text" type="text"
style="float: right;border: none;margin-top: -4px;" style="float: right;border: none;margin-top: -4px;"
@ -200,7 +200,7 @@
</div> </div>
<div class="field-wrap bs-field-wrap bs-scrollbar"> <div class="field-wrap bs-field-wrap bs-scrollbar">
<div <div
v-for="(field,key) in outputFieldList" v-for="(field, key) in outputFieldList"
:key="key" :key="key"
class="field-item" class="field-item"
@click="$refs.outputFieldDialog.open()" @click="$refs.outputFieldDialog.open()"
@ -338,6 +338,7 @@
<OutputFieldDialog <OutputFieldDialog
ref="outputFieldDialog" ref="outputFieldDialog"
:output-field-list="outputFieldList" :output-field-list="outputFieldList"
@setFieldList="(list) => { outputFieldList = list }"
/> />
</el-scrollbar> </el-scrollbar>
<FieldFillDialog <FieldFillDialog
@ -369,7 +370,7 @@ export default {
props: { props: {
config: { config: {
type: Object, type: Object,
default: () => {} default: () => { }
}, },
isEdit: { isEdit: {
type: Boolean, type: Boolean,
@ -448,8 +449,10 @@ export default {
} }
}, },
watch: { watch: {
'dataForm.config.script' () { 'dataForm.config.script' (val) {
this.passTest = false if (!val) {
this.passTest = false
}
} }
}, },
mounted () { mounted () {
@ -603,10 +606,14 @@ export default {
const javascript = this.dataForm.config.script const javascript = this.dataForm.config.script
let scriptMethod = null let scriptMethod = null
try { try {
scriptMethod = eval(`(${javascript})`) const scriptAfterReplacement = javascript.replace(/\${(.*?)}/g, (match, p) => {
return `'${this.dataForm.config.paramsList.find(param => param.name === p).value}'`
})
// eslint-disable-next-line no-new-func
scriptMethod = new Function(scriptAfterReplacement)
} catch (error) { } catch (error) {
this.passTest = false this.passTest = false
this.$message.error('脚本执行错误,请检查脚本') this.$message.error(`脚本执行错误,请检查脚本,具体错误:${error}`)
return return
} }
// //
@ -625,13 +632,29 @@ export default {
} }
}) })
}) })
this.outputFieldList = keys.map(item => { if (this.outputFieldList.length === 0) {
return { this.outputFieldList = keys.map(item => {
fieldName: item, return {
fieldDesc: '' fieldName: item,
} fieldDesc: ''
}) }
if (this.outputFieldList.length && this.fieldDesc) { })
}
// keysoutputFieldListoutputFieldList
if (this.outputFieldList.length !== keys.length) {
const newKeys = keys.filter(item => {
return !this.outputFieldList.some(key => {
return key.fieldName === item
})
})
newKeys.forEach(item => {
this.outputFieldList.push({
fieldName: item,
fieldDesc: ''
})
})
}
if (this.outputFieldList.length && this.fieldDesc && !isInit) {
this.buildFieldDesc() this.buildFieldDesc()
} }
// //
@ -651,15 +674,15 @@ export default {
} }
}, },
// //
toExecute () { // toExecute () {
// if (this.dataForm.config.paramsList.length) { // if (this.dataForm.config.paramsList.length) {
// this.isSet = false // this.isSet = false
// this.paramsVisible = true // this.paramsVisible = true
// } else { // } else {
// //
this.scriptExecute() // this.scriptExecute()
// } // }
}, // },
// //
clearType () { clearType () {
this.typeName = '' this.typeName = ''
@ -697,151 +720,152 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../../packages/assets/style/bsTheme.scss'; @import '../../../packages/assets/style/bsTheme.scss';
.data-set-scrollbar { .data-set-scrollbar {
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
overflow-x: none; overflow-x: none;
.el-scrollbar__view { .el-scrollbar__view {
height: 100%; height: 100%;
}
}
/deep/ .el-input__inner {
width: 100% !important;
} }
}
.page-header { /deep/ .el-input__inner {
display: flex; width: 100% !important;
position: relative; }
.page-header-right { .page-header {
position: absolute; display: flex;
right: 16px; position: relative;
}
}
.sql-config { .page-header-right {
padding: 0 16px; position: absolute;
right: 16px;
} }
}
.operation { .sql-config {
/deep/ .el-select { padding: 0 16px;
width: 200px !important; }
margin-right: 16px;
}
display: flex; .operation {
/deep/ .el-select {
width: 200px !important;
margin-right: 16px;
} }
/deep/ .CodeMirror { display: flex;
height: 180px !important; }
font-family: Helvetica, Tahoma;
}
.no-border { /deep/ .CodeMirror {
border: 0; height: 180px !important;
} font-family: Helvetica, Tahoma;
}
/deep/ .fieldDescCheck { .no-border {
.el-dialog__body { border: 0;
height: fit-content !important; }
min-height: unset !important;
}
}
.title-style { /deep/ .fieldDescCheck {
padding: 8px 12px; .el-dialog__body {
background-color: #f6f7fb; height: fit-content !important;
border-left: 5px solid var(--bs-el-color-primary); min-height: unset !important;
margin: 16px 16px 0 0;
} }
}
.field-wrap { .title-style {
// max-height: 110px; padding: 8px 12px;
overflow: auto; background-color: #f6f7fb;
margin-right: 16px; border-left: 5px solid var(--bs-el-color-primary);
cursor: pointer; margin: 16px 16px 0 0;
}
.field-item { .field-wrap {
line-height: 32px; // max-height: 110px;
padding: 0 12px 0 16px; overflow: auto;
margin-right: 16px;
cursor: pointer;
.edit_field { .field-item {
display: none; line-height: 32px;
} padding: 0 12px 0 16px;
.edit_field {
display: none;
}
&:hover { &:hover {
background-color: #f2f7fe; background-color: #f2f7fe;
.edit_field { .edit_field {
display: block; display: block;
}
} }
} }
} }
}
.right-setting { .right-setting {
height: 358px; height: 358px;
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.paramConfig { .paramConfig {
max-height: 179px; max-height: 179px;
.field-wrap { .field-wrap {
max-height: 127px; max-height: 127px;
}
} }
}
.structure { .structure {
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
.field-wrap { .field-wrap {
height: calc(100% - 40px); height: calc(100% - 40px);
}
} }
} }
}
.result-view { .result-view {
font-size: 14px; font-size: 14px;
font-weight: 600; font-weight: 600;
color: var(--bs-el-text); color: var(--bs-el-text);
position: relative; position: relative;
padding: 16px 0; padding: 16px 0;
padding-left: 12px; padding-left: 12px;
border-bottom: 1px solid var(--bs-background-1); border-bottom: 1px solid var(--bs-background-1);
&::before { &::before {
content: ""; content: "";
height: 14px; height: 14px;
position: absolute; position: absolute;
left: 0; left: 0;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
border-left: 4px solid var(--bs-el-color-primary); border-left: 4px solid var(--bs-el-color-primary);
}
} }
}
/deep/ .bs-table-box.is-Edit .el-table { /deep/ .bs-table-box.is-Edit .el-table {
max-height: unset !important; max-height: unset !important;
.el-table__body-wrapper { .el-table__body-wrapper {
max-height: unset !important; max-height: unset !important;
}
} }
}
.bs-table-box { .bs-table-box {
padding: 0; padding: 0;
height: 100% !important; height: 100% !important;
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
.tree-box{
padding: 0; .tree-box {
} padding: 0;
</style> }
</style>

@ -3307,27 +3307,6 @@
"whatwg-fetch": "^3.6.2" "whatwg-fetch": "^3.6.2"
}, },
"dependencies": { "dependencies": {
"@vue/vue-loader-v15": {
"version": "npm:vue-loader@15.10.1",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-15.10.1.tgz",
"integrity": "sha512-SaPHK1A01VrNthlix6h1hq4uJu7S/z0kdLUb6klubo738NeQoLbS6V9/d8Pv19tU0XdQKju3D1HSKuI8wJ5wMA==",
"dev": true,
"requires": {
"@vue/component-compiler-utils": "^3.1.0",
"hash-sum": "^1.0.2",
"loader-utils": "^1.1.0",
"vue-hot-reload-api": "^2.3.0",
"vue-style-loader": "^4.1.0"
},
"dependencies": {
"hash-sum": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/hash-sum/-/hash-sum-1.0.2.tgz",
"integrity": "sha512-fUs4B4L+mlt8/XAtSOGMUO1TXmAelItBPtJG7CyHJfYTdDjwisntGO2JQz7oUsatOY9o68+57eziUVNw/mRHmA==",
"dev": true
}
}
},
"acorn-walk": { "acorn-walk": {
"version": "8.2.0", "version": "8.2.0",
"resolved": "https://registry.npmmirror.com/acorn-walk/-/acorn-walk-8.2.0.tgz", "resolved": "https://registry.npmmirror.com/acorn-walk/-/acorn-walk-8.2.0.tgz",
@ -3399,26 +3378,6 @@
"tapable": "^2.0.0" "tapable": "^2.0.0"
} }
}, },
"json5": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
}
},
"loader-utils": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz",
"integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^1.0.1"
}
},
"ms": { "ms": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.2.tgz",
@ -3636,6 +3595,47 @@
"lodash": "^4.17.4" "lodash": "^4.17.4"
} }
}, },
"@vue/vue-loader-v15": {
"version": "npm:vue-loader@15.10.1",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-15.10.1.tgz",
"integrity": "sha512-SaPHK1A01VrNthlix6h1hq4uJu7S/z0kdLUb6klubo738NeQoLbS6V9/d8Pv19tU0XdQKju3D1HSKuI8wJ5wMA==",
"dev": true,
"requires": {
"@vue/component-compiler-utils": "^3.1.0",
"hash-sum": "^1.0.2",
"loader-utils": "^1.1.0",
"vue-hot-reload-api": "^2.3.0",
"vue-style-loader": "^4.1.0"
},
"dependencies": {
"hash-sum": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/hash-sum/-/hash-sum-1.0.2.tgz",
"integrity": "sha512-fUs4B4L+mlt8/XAtSOGMUO1TXmAelItBPtJG7CyHJfYTdDjwisntGO2JQz7oUsatOY9o68+57eziUVNw/mRHmA==",
"dev": true
},
"json5": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
}
},
"loader-utils": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz",
"integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^1.0.1"
}
}
}
},
"@vue/vue2-jest": { "@vue/vue2-jest": {
"version": "27.0.0", "version": "27.0.0",
"resolved": "https://registry.npmmirror.com/@vue/vue2-jest/-/vue2-jest-27.0.0.tgz", "resolved": "https://registry.npmmirror.com/@vue/vue2-jest/-/vue2-jest-27.0.0.tgz",

@ -2,10 +2,10 @@
<div class="side-catalog-wrap"> <div class="side-catalog-wrap">
<el-scrollbar class="side-catalog-box"> <el-scrollbar class="side-catalog-box">
<div <div
v-for="(com,index) in componentList" v-for="(com, index) in componentList"
:key="index" :key="index"
class="component-item-box" class="component-item-box"
:class="{'active-catalog':activeType === com.type}" :class="{ 'active-catalog': activeType === com.type }"
@click="componentHandle(com)" @click="componentHandle(com)"
> >
{{ com.name }} {{ com.name }}
@ -16,7 +16,7 @@
<script> <script>
export default { export default {
components: { }, components: {},
data () { data () {
return { return {
componentList: [ componentList: [
@ -36,13 +36,24 @@ export default {
activeType: 'component' activeType: 'component'
} }
}, },
mounted () { created () {
const type = this.$route?.query?.type
if (type) {
this.componentHandle(this.componentList.find(item => item.type === type))
} else {
this.componentHandle(this.componentList[0])
}
}, },
methods: { methods: {
// //
componentHandle (com) { componentHandle (com) {
this.activeType = com.type this.activeType = com.type
this.$emit('getPageInfo', com.type) this.$router.push({
path: window.BS_CONFIG?.routers?.componentUrl || '/big-screen-components',
query: {
type: com.type
}
})
} }
} }
} }

@ -1,11 +1,7 @@
<template> <template>
<div class="bs-manage-main-wrap"> <div class="bs-manage-main-wrap">
<side-menu <side-menu />
@getPageInfo="getPageInfo" <menu-content />
/>
<menu-content
:catalog-info="catalogInfo"
/>
</div> </div>
</template> </template>
<script> <script>
@ -18,15 +14,10 @@ export default {
components: { SideMenu, MenuContent }, components: { SideMenu, MenuContent },
data () { data () {
return { return {
catalogInfo: 'component'
} }
}, },
mounted () {}, mounted () { },
methods: { methods: {}
getPageInfo (type) {
this.catalogInfo = type
}
}
} }
</script> </script>

@ -28,11 +28,7 @@
<data-set-select <data-set-select
:dataset-name="datasetName" :dataset-name="datasetName"
:ds-id="config.dataSource.businessKey" :ds-id="config.dataSource.businessKey"
@getDsId=" @getDsId="dsId => { getDataSetDetailsById(dsId, 'treeTable');}"
dsId => {
getDataSetDetailsById(dsId, 'treeTable');
}
"
/> />
</el-form-item> </el-form-item>
</div> </div>
@ -713,57 +709,58 @@ export default {
}, },
// //
getDataSetDetailsById (id, type) { getDataSetDetailsById (id, type) {
this.config.dataSource.businessKey = id if (id) {
getDataSetDetails(id).then(res => { this.config.dataSource.businessKey = id
this.fieldsList = res.fields getDataSetDetails(id).then(res => {
// this.fieldsList = res.fields
if (type === 'initial') { //
for (const key in this.config.dataSource.params) { if (type === 'initial') {
const param = res?.params?.find(field => field.name === key) for (const key in this.config.dataSource.params) {
this.params.push({ const param = res?.params?.find(field => field.name === key)
name: key, this.params.push({
value: this.config.dataSource.params[key], name: key,
type: param?.type, value: this.config.dataSource.params[key],
remark: param?.remark type: param?.type,
}) remark: param?.remark
})
}
} else {
this.params = res.params
} }
} else {
this.params = res.params
}
this.datasetName = res.name this.datasetName = res.name
// dataModel, // dataModel,
this.config.option.displayOption.params.enable = res.type !== 'dataModel' this.config.option.displayOption.params.enable = res.type !== 'dataModel'
// inparams // inparams
if (res.type !== 'dataModel') { if (res.type !== 'dataModel') {
this.config.inParams = this.config.inParams =
this.params?.map(param => { this.params?.map(param => {
return { return {
name: param.remark, // name: param.remark, //
code: param.name // code: param.name //
} }
}) || [] }) || []
} else { } else {
this.config.inParams = this.config.inParams =
this.fieldsList?.map(field => { this.fieldsList?.map(field => {
return { return {
name: field.fieldDesc, // name: field.fieldDesc, //
code: field.fieldName // code: field.fieldName //
} }
}) || [] }) || []
}
//
this.config.paramsList = this.params
if (type === 'treeTable') {
const enumeration = {
dataSetType: '1', //
dataSetKey: '', //
itemKeyName: '', //
itemValueName: '', // value
params: []
} }
this.config.fields =
//
this.config.paramsList = this.params
if (type === 'treeTable') {
const enumeration = {
dataSetType: '1', //
dataSetKey: '', //
itemKeyName: '', //
itemValueName: '', // value
params: []
}
this.config.fields =
this.params?.map(param => { this.params?.map(param => {
return { return {
name: param.name, name: param.name,
@ -776,8 +773,9 @@ export default {
queryRule: 'like' queryRule: 'like'
} }
}) || [] }) || []
} }
}) })
}
}, },
// //
dimensionFieldListChange (list) { dimensionFieldListChange (list) {

@ -154,7 +154,9 @@ export default {
this.windowSize() this.windowSize()
}, },
mounted () { mounted () {
this.startTimer() if (this.pageInfo.pageConfig.refreshConfig && this.pageInfo.pageConfig.refreshConfig.length > 0) {
this.startTimer()
}
}, },
beforeDestroy () { beforeDestroy () {
this.stopTimer() this.stopTimer()

@ -13,7 +13,10 @@
</div> </div>
</div> </div>
<div class="right-btn-wrap"> <div class="right-btn-wrap">
<CusBtn> <CusBtn
:loading="loading"
@click.native="createdImg()"
>
生成图片 生成图片
</CusBtn> </CusBtn>
<CusBtn <CusBtn
@ -104,6 +107,7 @@
</div> </div>
</template> </template>
<script> <script>
import { toJpeg, toPng } from 'html-to-image'
import CusBtn from 'packages/BigScreenDesign/BtnLoading' import CusBtn from 'packages/BigScreenDesign/BtnLoading'
// import MonacoEditor from 'packages/MonacoEditor' // import MonacoEditor from 'packages/MonacoEditor'
import BizComponentPreview from './Preview' import BizComponentPreview from './Preview'
@ -115,6 +119,13 @@ import 'codemirror/theme/material-darker.css'
import 'codemirror/addon/selection/active-line.js' import 'codemirror/addon/selection/active-line.js'
import 'codemirror/mode/vue/vue.js' import 'codemirror/mode/vue/vue.js'
import {
showSize,
dataURLtoBlob,
translateBlobToBase64
} from 'packages/js/utils/compressImg'
import * as imageConversion from 'image-conversion'
export default { export default {
name: 'BizComponentDesign', name: 'BizComponentDesign',
components: { components: {
@ -220,18 +231,72 @@ export default {
}, },
backManagement () { backManagement () {
this.$router.push({ this.$router.push({
path: window.BS_CONFIG?.routers?.componentUrl || '/big-screen-components' path: window.BS_CONFIG?.routers?.componentUrl || '/big-screen-components',
query: {
type: 'bizComponent'
}
}) })
}, },
save () { save () {
this.loading = true this.loading = true
updateBizComponent(this.form).then(() => { const node = document.querySelector('.bs-preview-inner')
this.$message.success('保存成功') toJpeg(node, { quality: 0.2 })
}).catch(() => { .then((dataUrl) => {
this.$message.error('保存失败') const that = this
}).finally(() => { if (showSize(dataUrl) > 200) {
this.loading = false const url = dataURLtoBlob(dataUrl)
}) // 500KB,500,
imageConversion
.compressAccurately(url, {
size: 200, // 100kb
width: 1280, // 1280
height: 720 // 720
})
.then((res) => {
translateBlobToBase64(res, function (e) {
this.form.coverPicture = e.result
updateBizComponent(this.form)
.then((res) => {
that.$message.success('保存成功')
})
.finally(() => {
that.loading = false
})
})
})
} else {
this.form.coverPicture = dataUrl
updateBizComponent(this.form)
.then(() => {
this.$message.success('保存成功')
})
.finally(() => {
this.loading = false
})
}
})
.catch(() => {
this.loading = false
})
},
createdImg () {
this.loading = true
const node = document.querySelector('.bs-preview-inner')
toPng(node)
.then((dataUrl) => {
const link = document.createElement('a')
link.download = `${this.form.name}.png`
link.href = dataUrl
link.click()
link.addEventListener('click', () => {
link.remove()
})
this.loading = false
})
.catch(() => {
this.$message.warning('出现未知错误,请重试')
this.loading = false
})
} }
} }
} }

@ -120,7 +120,7 @@
</div> </div>
<div class="big-screen-card-img"> <div class="big-screen-card-img">
<el-image <el-image
:src="catalogInfo !== 'system'?screen.coverPicture:screen.img" :src="catalogInfo !== 'system' ? screen.coverPicture : screen.img"
fit="fill" fit="fill"
style="width: 100%; height: 100%" style="width: 100%; height: 100%"
> >
@ -201,16 +201,12 @@ import innerRemoteComponents, { getRemoteComponents } from 'packages/RemoteCompo
export default { export default {
name: 'BigScreenList', name: 'BigScreenList',
mixins: [pageMixins], mixins: [pageMixins],
props: { props: { },
catalogInfo: {
type: String,
default: ''
}
},
components: { EditForm, CatalogEditForm }, components: { EditForm, CatalogEditForm },
data () { data () {
return { return {
name: '', name: '',
catalogInfo: 'component',
catalogVisible: false, catalogVisible: false,
templateLoading: false, templateLoading: false,
searchKey: '', searchKey: '',
@ -230,7 +226,6 @@ export default {
} }
}, },
code () { code () {
// return this.catalogInfo?.page?.code
return '' return ''
}, },
gridComputed () { gridComputed () {
@ -238,7 +233,8 @@ export default {
} }
}, },
watch: { watch: {
catalogInfo () { $route (val) {
this.catalogInfo = val.query.type || 'component'
this.reset() this.reset()
this.init() this.init()
}, },
@ -247,6 +243,7 @@ export default {
} }
}, },
mounted () { mounted () {
this.catalogInfo = this.$route.query.type || 'component'
this.init() this.init()
}, },
methods: { methods: {

@ -138,7 +138,6 @@ export default {
methods: { methods: {
// //
openAddForm (type, componentName) { openAddForm (type, componentName) {
console.log()
this.dialogVisible = false this.dialogVisible = false
this.$emit('openAddForm', type, componentName) this.$emit('openAddForm', type, componentName)
} }

@ -945,7 +945,6 @@ export default {
this.currentCount = data.data.currentCount this.currentCount = data.data.currentCount
this.tableLoading = false this.tableLoading = false
}).catch((e) => { }).catch((e) => {
console.log(e)
this.dataPreviewList = [] this.dataPreviewList = []
this.structurePreviewList = [] this.structurePreviewList = []
this.structurePreviewListCopy = [] this.structurePreviewListCopy = []

@ -667,6 +667,8 @@ export default {
this.dataForm.paramsList = res.config.paramsList ? res.config.paramsList : [] this.dataForm.paramsList = res.config.paramsList ? res.config.paramsList : []
this.dataForm.fieldDesc = res.config.fieldDesc this.dataForm.fieldDesc = res.config.fieldDesc
this.dataForm.fieldList = res.config.fieldList this.dataForm.fieldList = res.config.fieldList
this.paramsListCopy = _.cloneDeep(this.dataForm.paramsList)
this.scriptExecute(true) this.scriptExecute(true)
}) })
}, },
@ -770,7 +772,6 @@ export default {
} }
}) })
} }
console.log(this.structurePreviewList)
if (this.structurePreviewList.length && this.dataForm.fieldDesc) { if (this.structurePreviewList.length && this.dataForm.fieldDesc) {
this.buildFieldDesc() this.buildFieldDesc()
} }
@ -778,7 +779,6 @@ export default {
this.saveLoading = false this.saveLoading = false
this.passTest = true this.passTest = true
}).catch((e) => { }).catch((e) => {
console.log(e)
this.passTest = false this.passTest = false
this.saveLoading = false this.saveLoading = false
}) })

@ -460,7 +460,7 @@ export default {
{ name: '全部', datasetType: '' }, { name: '全部', datasetType: '' },
{ name: '原始数据集', datasetType: 'original', componentName: 'OriginalEditForm' }, { name: '原始数据集', datasetType: 'original', componentName: 'OriginalEditForm' },
{ name: '自助数据集', datasetType: 'custom', componentName: 'CustomEditForm' }, { name: '自助数据集', datasetType: 'custom', componentName: 'CustomEditForm' },
{ name: '存储过程数据集', datasetType: 'storedProcedure', componentName: 'CustomEditForm' }, { name: '存储过程数据集', datasetType: 'storedProcedure', componentName: 'StoredProcedureEditForm' },
{ name: 'JSON数据集', datasetType: 'json', componentName: 'JsonEditForm' }, { name: 'JSON数据集', datasetType: 'json', componentName: 'JsonEditForm' },
{ name: '脚本数据集', datasetType: 'script', componentName: 'ScriptEditForm' } { name: '脚本数据集', datasetType: 'script', componentName: 'ScriptEditForm' }
] ]

@ -71,6 +71,19 @@ export default {
size: size, size: size,
type: config.type type: config.type
}).then((data) => { }).then((data) => {
if (data.executionByFrontend) {
try {
const scriptAfterReplacement = data.data.replace(/\${(.*?)}/g, (match, p) => {
// 根据parmas的key获取value
return `'${this.config.dataSource?.params[p]}' || '${p}'`
})
// eslint-disable-next-line no-new-func
const scriptMethod = new Function(scriptAfterReplacement)
data.data = scriptMethod()
} catch (error) {
console.error('数据集脚本执行失败', error)
}
}
config = this.dataFormatting(config, data) config = this.dataFormatting(config, data)
this.changeChartConfig(config) this.changeChartConfig(config)
}).catch((err) => { }).catch((err) => {
@ -97,6 +110,19 @@ export default {
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getUpdateChartInfo(params).then((data) => { getUpdateChartInfo(params).then((data) => {
if (data.executionByFrontend) {
try {
const scriptAfterReplacement = data.data.replace(/\${(.*?)}/g, (match, p) => {
// 根据parmas的key获取value
return `'${this.config.dataSource?.params[p]}' || '${p}'`
})
// eslint-disable-next-line no-new-func
const scriptMethod = new Function(scriptAfterReplacement)
data.data = scriptMethod()
} catch (error) {
console.error('数据集脚本执行失败', error)
}
}
config = this.dataFormatting(config, data) config = this.dataFormatting(config, data)
// this.changeChartConfig(config) // this.changeChartConfig(config)
if (this.chart) { if (this.chart) {

@ -133,7 +133,6 @@ export default {
} }
if ((event.ctrlKey || event.metaKey) && event.keyCode === 86) { if ((event.ctrlKey || event.metaKey) && event.keyCode === 86) {
console.log('粘贴')
// 粘贴 // 粘贴
this.pasteCharts() this.pasteCharts()
} }

@ -38,7 +38,6 @@ export default {
// 初始化缓存数据集字段 // 初始化缓存数据集字段
getCacheDataFields ({ commit, dispatch }, { dataSetId }) { getCacheDataFields ({ commit, dispatch }, { dataSetId }) {
getDataSetDetails(dataSetId).then(data => { getDataSetDetails(dataSetId).then(data => {
console.log(2, data)
commit('changeCacheDataFields', { dataSetId, data }) commit('changeCacheDataFields', { dataSetId, data })
commit('changeCacheDataParams', { dataSetId, data }) commit('changeCacheDataParams', { dataSetId, data })
}) })
@ -65,6 +64,7 @@ export function handleResData (data) {
} }
// 如果pageConfig中的cacheDataSets为null赋值[] // 如果pageConfig中的cacheDataSets为null赋值[]
pageInfo.pageConfig.cacheDataSets = pageInfo.pageConfig.cacheDataSets || [] pageInfo.pageConfig.cacheDataSets = pageInfo.pageConfig.cacheDataSets || []
pageInfo.pageConfig.refreshConfig = pageInfo.pageConfig.refreshConfig || []
pageInfo.chartList.forEach((chart) => { pageInfo.chartList.forEach((chart) => {
if (!['customComponent', 'remoteComponent'].includes(chart.type)) { if (!['customComponent', 'remoteComponent'].includes(chart.type)) {
chart.option = _.cloneDeep(setModules[chart.type]) chart.option = _.cloneDeep(setModules[chart.type])

@ -26,6 +26,7 @@ export const defaultData = {
themeJson: {}, // 自定义主题配置 themeJson: {}, // 自定义主题配置
// 缓存的数据集 { name: '', dataSetId: '' } // 缓存的数据集 { name: '', dataSetId: '' }
cacheDataSets: [], cacheDataSets: [],
refreshConfig: [],
// 自适应模式 无(none) 、自动(auto)、宽度铺满(fitWidth)、高度铺满(fitHeight)和 双向铺满cover 5 种自适应模式 // 自适应模式 无(none) 、自动(auto)、宽度铺满(fitWidth)、高度铺满(fitHeight)和 双向铺满cover 5 种自适应模式
fitMode: 'none' fitMode: 'none'
}, },

@ -39,7 +39,8 @@ module.exports = {
chunks: 'all' chunks: 'all'
} }
}, },
publicPath: process.env.VUE_APP_HISTORY === 'y' ? process.env.VUE_APP_BASE : './', publicPath:
process.env.VUE_APP_HISTORY === 'y' ? process.env.VUE_APP_BASE : './',
outputDir: 'bigScreen', outputDir: 'bigScreen',
assetsDir: 'static', assetsDir: 'static',
lintOnSave: false, lintOnSave: false,

Loading…
Cancel
Save