Merge pull request #727 from dataease/dev

Dev
This commit is contained in:
fit2cloudrd 2021-08-31 10:07:36 +08:00 committed by GitHub
commit caf7bf65be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 230 additions and 69 deletions

View File

@ -214,7 +214,7 @@
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.3</version>
<version>1.14.2</version>
</dependency>
<dependency>
@ -226,7 +226,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.20</version>
<version>1.21</version>
</dependency>
<dependency>
@ -255,7 +255,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
<version>4.5.13</version>
</dependency>
<!-- 反射工具包 -->
<dependency>

View File

@ -57,13 +57,11 @@ public class ExcelReaderUtil {
ExcelXlsxReader excelXlsxReader = new ExcelXlsxReader();
excelXlsxReader.process(inputStream);
System.out.println(excelXlsxReader.totalSheets.size());
System.out.println(excelXlsxReader.totalSheets.get(1).getExcelLable());
for (TableFiled field : excelXlsxReader.totalSheets.get(1).getFields()) {
System.out.println(excelXlsxReader.totalSheets.get(0).getExcelLable());
for (TableFiled field : excelXlsxReader.totalSheets.get(0).getFields()) {
System.out.println(new Gson().toJson(field));
}
System.out.println(excelXlsxReader.totalSheets.get(0).getData().get(0));
System.out.println(excelXlsxReader.totalSheets.get(0).getData().get(1));
System.out.println(excelXlsxReader.totalSheets.get(0).getData().get(2));
} else {
throw new Exception("文件格式错误fileName的扩展名只能是xls或xlsx。");
@ -71,7 +69,7 @@ public class ExcelReaderUtil {
}
public static void main(String[] args) throws Exception {
String file ="赤收管理 2.xlsx";
String file ="Metersphere_case_DataEase功能用例.xlsx";
ExcelReaderUtil.readExcel(file, new FileInputStream("/Users/taojinlong/Desktop/" + file));
}
}

View File

@ -237,6 +237,14 @@ public class ExcelXlsxReader extends DefaultHandler {
if (isTElement) {//这个程序没经过
//将单元格内容加入rowlist中在这之前先去掉字符串前后的空白符
String value = lastIndex.trim();
if(curRow==1){
TableFiled tableFiled = new TableFiled();
tableFiled.setFieldType("TEXT");
tableFiled.setFieldSize(65533);
tableFiled.setFieldName(value);
tableFiled.setRemarks(value);
this.fields.add(tableFiled);
}
cellList.add(curCol, value);
curCol++;
isTElement = false;
@ -432,6 +440,10 @@ public class ExcelXlsxReader extends DefaultHandler {
}
}
}
if(curCol==1){
System.out.println(type);
System.out.println(nextDataType);
}
return thisStr;
}

View File

@ -46,6 +46,12 @@ public class DataSetTableController {
}
}
@ApiOperation("修改")
@PostMapping("alter")
public void alter(@RequestBody DataSetTableRequest request) throws Exception {
dataSetTableService.alter(request);
}
@ApiOperation("删除")
@PostMapping("delete/{id}")
public void delete(@PathVariable String id) throws Exception {

View File

@ -6,7 +6,6 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.base.domain.SysMsgChannel;
import io.dataease.base.domain.SysMsgSetting;
import io.dataease.base.domain.SysMsgType;
import io.dataease.commons.exception.DEException;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.PageUtils;
import io.dataease.commons.utils.Pager;
@ -71,6 +70,12 @@ public class MsgController {
sysMsgService.setBatchReaded(msgIds);
}
@ApiOperation("全部设置已读")
@PostMapping("/allRead")
public void allRead() {
sysMsgService.setAllRead();
}
@ApiOperation("批量删除")
@PostMapping("/batchDelete")
public void batchDelete(@RequestBody List<Long> msgIds) {

View File

@ -7,6 +7,7 @@ import io.dataease.base.mapper.*;
import io.dataease.base.mapper.ext.ExtDataSourceMapper;
import io.dataease.base.mapper.ext.query.GridExample;
import io.dataease.commons.exception.DEException;
import io.dataease.commons.model.AuthURD;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.CommonThreadPool;
import io.dataease.commons.utils.LogUtil;
@ -25,6 +26,8 @@ import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator;
import io.dataease.service.dataset.DataSetGroupService;
import io.dataease.service.message.DeMsgutil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -34,7 +37,10 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@Service
@ -238,7 +244,8 @@ public class DatasourceService {
public void updateDatasourceStatus(){
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
datasources.forEach(datasource -> {
checkAndUpdateDatasourceStatus(datasource);
// checkAndUpdateDatasourceStatus(datasource);
checkAndUpdateDatasourceStatus(datasource, true);
});
}
@ -255,4 +262,43 @@ public class DatasourceService {
datasourceMapper.updateByPrimaryKeySelective(datasource);
}
}
private void checkAndUpdateDatasourceStatus(Datasource datasource, Boolean withMsg){
try {
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(datasource);
datasourceProvider.checkStatus(datasourceRequest);
datasource.setStatus("Success");
datasourceMapper.updateByPrimaryKeySelective(datasource);
} catch (Exception e) {
Datasource temp = datasourceMapper.selectByPrimaryKey(datasource.getId());
datasource.setStatus("Error");
if (!StringUtils.equals(temp.getStatus(), "Error")) {
sendWebMsg(datasource);
datasourceMapper.updateByPrimaryKeySelective(datasource);
}
}
}
private void sendWebMsg(Datasource datasource) {
String id = datasource.getId();
AuthURD authURD = AuthUtils.authURDR(id);
Set<Long> userIds = AuthUtils.userIdsByURD(authURD);
Long typeId = 8L;// 代表数据源失效
Gson gson = new Gson();
userIds.forEach(userId -> {
Map<String, Object> param = new HashMap<>();
param.put("id", id);
param.put("name", datasource.getName());
String content = "数据源【" + datasource.getName() + "】无效";
DeMsgutil.sendMsg(userId, typeId, 1L, content, gson.toJson(param));
});
}
}

View File

@ -121,7 +121,7 @@ public class MapUtils {
}
private static AreaEntity root() {
return AreaEntity.builder().code("100000").name("中华人共和国").build();
return AreaEntity.builder().code("100000").name("中华人共和国").build();
}
public static void recursionWrite(List<AreaEntity> areaEntityList) {

View File

@ -121,6 +121,8 @@ public class DorisQueryProvider extends QueryProvider {
fieldName = String.format(DorisConstants.FROM_UNIXTIME, cast, DorisConstants.DEFAULT_DATE_FORMAT);
} else if (f.getDeType() == 2) {
fieldName = String.format(DorisConstants.CAST, originField, DorisConstants.DEFAULT_INT_FORMAT);
} else if (f.getDeType() == 3) {
fieldName = String.format(DorisConstants.CAST, originField, DorisConstants.DEFAULT_FLOAT_FORMAT);
} else {
fieldName = originField;
}

View File

@ -37,6 +37,7 @@ public class SqlserverQueryProvider extends QueryProvider {
@Override
public Integer transFieldType(String field) {
field = field.toUpperCase();
switch (field) {
case "CHAR":
case "NCHAR":

View File

@ -251,6 +251,11 @@ public class DataSetTableService {
return datasetTable;
}
public void alter(DataSetTableRequest request)throws Exception {
checkName(request);
datasetTableMapper.updateByPrimaryKeySelective(request);
}
public void delete(String id) throws Exception {
DatasetTable table = datasetTableMapper.selectByPrimaryKey(id);
datasetTableMapper.deleteByPrimaryKey(id);

View File

@ -312,4 +312,12 @@ public class SysMsgService {
return sourceLists;
}
public void setAllRead() {
SysMsg record = new SysMsg();
record.setStatus(true);
SysMsgExample example = new SysMsgExample();
example.createCriteria().andUserIdEqualTo(AuthUtils.getUser().getUserId()).andStatusEqualTo(false);
sysMsgMapper.updateByExampleSelective(record, example);
}
}

View File

@ -0,0 +1,7 @@
-- ----------------------------
-- Records of sys_msg_type
-- ----------------------------
BEGIN;
INSERT INTO `sys_msg_type` VALUES (7, 0, 'i18n_msg_type_ds_invalid', 'datasource', 'to-msg-ds');
INSERT INTO `sys_msg_type` VALUES (8, 7, 'i18n_msg_type_ds_invalid', 'datasource', 'to-msg-ds');
COMMIT;

View File

@ -43,6 +43,15 @@ export function addTable(data) {
})
}
export function alter(data) {
return request({
url: '/dataset/table/alter',
method: 'post',
loading: true,
data
})
}
export function delTable(tableId) {
return request({
url: '/dataset/table/delete/' + tableId,

View File

@ -35,6 +35,14 @@ export function batchRead(data) {
})
}
export function allRead() {
return request({
url: '/api/sys_msg/allRead',
method: 'post',
loading: true
})
}
export function batchDelete(data) {
return request({
url: '/api/sys_msg/batchDelete',

View File

@ -72,6 +72,7 @@
<de-out-widget
v-else-if="item.type==='custom'"
:id="'component' + item.id"
ref="wrapperChild"
class="component"
:style="getComponentStyleDefault(item.style)"
:prop-value="item.propValue"

View File

@ -2,7 +2,7 @@
<el-input
v-if="options!== null && options.attrs!==null"
v-model="values"
v-model="value"
resize="vertical"
:placeholder="$t(options.attrs.placeholder)"
@keypress.enter.native="search"
@ -31,22 +31,30 @@ export default {
return {
options: null,
operator: 'like',
values: null,
value: null,
canEdit: false
}
},
created() {
this.options = this.element.options
if (this.inDraw && this.options.value && this.options.value.length > 0) {
this.value = this.options.value[0]
}
},
methods: {
search() {
// this.options.value && this.setCondition()
this.options.value = []
if (this.inDraw && this.value) {
this.options.value = [this.value]
}
this.setCondition()
},
setCondition() {
const param = {
component: this.element,
value: !this.values ? [] : Array.isArray(this.values) ? this.values : [this.values],
value: !this.options.value ? [] : Array.isArray(this.options.value) ? this.options.value : [this.options.value],
operator: this.operator
}
this.inDraw && this.$store.commit('addViewFilter', param)

View File

@ -66,6 +66,12 @@ export default {
},
created() {
this.options = this.element.options
if (this.inDraw && this.options.value && this.options.value.length > 0) {
this.form.min = this.options.value[0]
if (this.options.value.length > 1) {
this.form.max = this.options.value[1]
}
}
},
methods: {
searchWithKey(index) {
@ -134,6 +140,7 @@ export default {
if (!valid) {
return false
}
this.setCondition()
this.styleChange()
})
@ -145,6 +152,8 @@ export default {
value: [this.form.min, this.form.max],
operator: this.operator
}
this.inDraw && (this.options.value = param.value)
if (this.form.min && this.form.max) {
this.inDraw && this.$store.commit('addViewFilter', param)
return

View File

@ -1351,6 +1351,7 @@ export default {
read_time: 'Read Time',
type: 'Message Type',
mark_readed: 'Mark As Read',
all_mark_readed: 'Mark All As Read',
please_select: 'Please select at least one message',
mark_success: 'Mark read successfully',
receive_manage: 'Receive Manage',
@ -1360,6 +1361,7 @@ export default {
i18n_msg_type_dataset_sync_success: 'Dataset synchronization successful',
i18n_msg_type_dataset_sync_faild: 'Dataset synchronization failed',
i18n_msg_type_all: 'All type',
i18n_msg_type_ds_invalid: 'Datasource invalid',
channel_inner_msg: 'On site news'
},
denumberrange: {

View File

@ -1350,6 +1350,7 @@ export default {
read_time: '查看時間',
type: '消息類型',
mark_readed: '標記已讀',
all_mark_readed: '全部已讀',
please_select: '請至少選擇一條消息',
mark_success: '標記已讀成功',
receive_manage: '接收管理',
@ -1358,6 +1359,7 @@ export default {
i18n_msg_type_dataset_sync: '數據集同步',
i18n_msg_type_dataset_sync_success: '數據集同步成功',
i18n_msg_type_dataset_sync_faild: '數據集同步失敗',
i18n_msg_type_ds_invalid: '數據源失效',
i18n_msg_type_all: '全部類型',
channel_inner_msg: '站內消息'
},

View File

@ -1353,6 +1353,7 @@ export default {
read_time: '查看时间',
type: '消息类型',
mark_readed: '标记已读',
all_mark_readed: '全部已读',
please_select: '请至少选择一条消息',
mark_success: '标记已读成功',
receive_manage: '接收管理',
@ -1361,6 +1362,7 @@ export default {
i18n_msg_type_dataset_sync: '数据集同步',
i18n_msg_type_dataset_sync_success: '数据集同步成功',
i18n_msg_type_dataset_sync_faild: '数据集同步失败',
i18n_msg_type_ds_invalid: '数据源失效',
i18n_msg_type_all: '全部类型',
channel_inner_msg: '站内消息'
},

View File

@ -349,3 +349,7 @@ div:focus {
width: 5px;
height: 5px;
}
.el-color-dropdown__link-btn {
display: none!important;
}

View File

@ -54,6 +54,7 @@ export function baseTreemapOption(chart_option, chart) {
// y.type = 'treemap'
chart_option.series[0].data.push(y)
}
chart_option.series[0].name = chart.data.series[0].name
}
}
// console.log(chart_option);

View File

@ -55,7 +55,7 @@
<span>
<i class="el-icon-sort" />
<span>{{ $t('chart.sort') }}</span>
<span class="summary-span">({{ $t('chart.'+item.sort) }})</span>
<span class="summary-span-item">({{ $t('chart.'+item.sort) }})</span>
</span>
<i class="el-icon-arrow-right el-icon--right" />
</span>
@ -171,11 +171,6 @@ export default {
font-size: 12px;
}
.summary-span{
margin-left: 4px;
color: #878d9f;;
}
.inner-dropdown-menu{
display: flex;
justify-content: space-between;
@ -185,7 +180,7 @@ export default {
.item-span-style{
display: inline-block;
width: 100px;
width: 80px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;

View File

@ -227,7 +227,7 @@ export default {
.item-span-style{
display: inline-block;
width: 100px;
width: 80px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;

View File

@ -237,7 +237,7 @@ export default {
.item-span-style{
display: inline-block;
width: 70px;
width: 80px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;

View File

@ -341,7 +341,7 @@
</template>
<script>
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, post, isKettleRunning} from '@/api/dataset/dataset'
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, post, isKettleRunning, alter} from '@/api/dataset/dataset'
import GroupMoveSelector from './GroupMoveSelector'
import DsMoveSelector from './DsMoveSelector'
@ -419,23 +419,12 @@ export default {
}
},
computed: {
// sceneData: function() {
// // this.tableTree()
// // console.log(this.$store.state.dataset.sceneData)
// this.refreshNodeBy(this.currGroup.id)
// return this.$store.state.dataset.sceneData
// }
},
created() {
this.kettleState()
},
watch: {
search(val) {
// if (val && val !== '') {
// this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.includes(val) })))
// } else {
// this.tableData = JSON.parse(JSON.stringify(this.tables))
// }
this.$emit('switchComponent', { name: '' })
this.tData = []
this.expandedArray = []
@ -526,7 +515,6 @@ export default {
},
saveGroup(group) {
// console.log(group);
this.$refs['groupForm'].validate((valid) => {
if (valid) {
addGroup(group).then(res => {
@ -536,45 +524,30 @@ export default {
type: 'success',
showClose: true
})
// this.tree(this.groupForm)
this.refreshNodeBy(group.pid)
})
} else {
// this.$message({
// message: this.$t('commons.input_error'),
// type: 'error',
// showClose: true
// })
return false
}
})
},
saveTable(table) {
// console.log(table)
table.mode = parseInt(table.mode)
this.$refs['tableForm'].validate((valid) => {
if (valid) {
table.isRename = true
addTable(table).then(response => {
alter(table).then(response => {
this.closeTable()
this.$message({
message: this.$t('dataset.save_success'),
type: 'success',
showClose: true
})
// this.tableTree()
this.refreshNodeBy(table.sceneId)
// this.$router.push('/dataset/home')
// this.$emit('switchComponent', { name: 'ViewTable', param: table.id })
this.$store.dispatch('dataset/setTable', new Date().getTime())
})
} else {
// this.$message({
// message: this.$t('commons.input_content'),
// type: 'error',
// showClose: true
// })
return false
}
})
@ -796,14 +769,10 @@ export default {
}
},
saveMoveDs() {
// if (this.tDs && this.tDs.type === 'group') {
// return
// }
this.dsForm.sceneId = this.tDs.id
this.dsForm.isRename = true
addTable(this.dsForm).then(res => {
alter(this.dsForm).then(res => {
this.closeMoveDs()
// this.tableTree()
this.refreshNodeBy(this.dsForm.sceneId)
})
},

View File

@ -18,7 +18,7 @@
>
<template #toolbar>
<el-button :disabled="multipleSelection.length === 0" @click="markReaded">{{ $t('webmsg.mark_readed') }}</el-button>
<!-- <fu-table-button v-permission="['user:add']" icon="el-icon-circle-plus-outline" :label="$t('user.create')" @click="create" /> -->
<el-button @click="allMarkReaded">{{ $t('webmsg.all_mark_readed') }}</el-button>
</template>
<el-table-column
type="selection"
@ -61,7 +61,7 @@
import LayoutContent from '@/components/business/LayoutContent'
import ComplexTable from '@/components/business/complex-table'
import { query, updateStatus, batchRead } from '@/api/system/msg'
import { query, updateStatus, batchRead, allRead } from '@/api/system/msg'
import { msgTypes, getTypeName, loadMsgTypes } from '@/utils/webMsg'
import bus from '@/utils/bus'
import { addOrder, formatOrders } from '@/utils/index'
@ -166,6 +166,12 @@ export default {
this.search()
})
},
allMarkReaded() {
allRead().then(res => {
this.$success(this.$t('webmsg.mark_success'))
this.search()
})
},
markReaded() {
if (this.multipleSelection.length === 0) {
this.$warning(this.$t('webmsg.please_select'))

View File

@ -55,6 +55,9 @@ export default {
},
refreshTree() {
this.$refs.dsTree && this.$refs.dsTree.queryTreeDatas()
},
msg2Current(sourceParam) {
this.$refs.dsTree && this.$refs.dsTree.markInvalid(sourceParam)
}
}
}

View File

@ -41,11 +41,11 @@
<svg-icon icon-class="datasource" class="ds-icon-scene" />
</span>
<span v-if="data.status === 'Error'">
<svg-icon icon-class="exclamationmark" class="ds-icon-scene" />
<el-tooltip v-if="data.status === 'Error'" style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" effect="dark" :content="$t('datasource.in_valid')" placement="right">
<el-button type="text" > {{ data.name }} </el-button>
</el-tooltip>
</span>
<svg-icon icon-class="exclamationmark" class="ds-icon-scene" />
<el-tooltip v-if="data.status === 'Error'" style="margin-left: 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" effect="dark" :content="$t('datasource.in_valid')" placement="right">
<el-button type="text" :style="!!data.msgNode ? {'color': 'red'} : {}"> {{ data.name }} </el-button>
</el-tooltip>
</span>
<span v-if="data.type === 'folder'">
<i class="el-icon-folder" />
</span>
@ -129,6 +129,11 @@ export default {
const newArr = []
for (let index = 0; index < array.length; index++) {
const element = array[index]
if (this.msgNodeId) {
if (element.id === this.msgNodeId) {
element.msgNode = true
}
}
if (!(element.type in types)) {
types[element.type] = []
// newArr.push(...element, ...{ children: types[element.type] })
@ -147,7 +152,7 @@ export default {
return 'SQL Server'
} else if (type === 'oracle') {
return 'Oracle'
}else if (type === 'pg') {
} else if (type === 'pg') {
return 'PostgreSQL'
}
},
@ -208,6 +213,21 @@ export default {
component,
componentParam
})
},
markInvalid(msgParam) {
const param = JSON.parse(msgParam)
const msgNodeId = param.id
this.msgNodeId = msgNodeId
this.$nextTick(() => {
this.tData.forEach(folder => {
const nodes = folder.children
nodes.forEach(node => {
if (node.id === msgNodeId) {
node.msgNode = true
}
})
})
})
}
}
}
@ -303,4 +323,10 @@ export default {
height: 100%;
overflow-y: auto;
}
.msg-node-class {
color: red;
>>> i{
color: red;
}
}
</style>

View File

@ -1,7 +1,7 @@
<template>
<de-container v-loading="$store.getters.loadingMap[$store.getters.currentPath]" style="background-color: #f7f8fa">
<de-main-container>
<ds-main />
<ds-main ref="dsMain" />
</de-main-container>
</de-container>
</template>
@ -10,7 +10,7 @@
import DeMainContainer from '@/components/dataease/DeMainContainer'
import DeContainer from '@/components/dataease/DeContainer'
import DsMain from './DsMain'
import bus from '@/utils/bus'
export default {
name: 'Panel',
components: { DeMainContainer, DeContainer, DsMain },
@ -22,10 +22,36 @@ export default {
}
},
mounted() {
bus.$on('to-msg-ds', params => {
this.toMsgDs(params)
})
},
created() {
this.$store.dispatch('app/toggleSideBarHide', true)
const routerParam = this.$router.currentRoute.params
this.toMsgDs(routerParam)
},
methods: {
toMsgDs(routerParam) {
if (routerParam !== null && routerParam.msgNotification) {
const panelShareTypeIds = [7, 8]
//
if (panelShareTypeIds.includes(routerParam.msgType)) { //
if (routerParam.sourceParam) {
try {
// const msgParam = JSON.parse(routerParam.sourceParam)
// this.param = msgParam.id
// this.component = ViewTable
this.$nextTick(() => {
this.$refs.dsMain && this.$refs.dsMain.msg2Current && this.$refs.dsMain.msg2Current(routerParam.sourceParam)
})
} catch (error) {
console.error(error)
}
}
}
}
}
}
}
</script>