Commit 90accdb2 by zhaochengxiang

数据地图增加接口

parent 9d285bda
......@@ -49,6 +49,6 @@
"last 1 safari version"
]
},
"proxy": "http://139.198.126.96:9011",
"proxy": "http://139.198.127.28:18762",
"homepage": "http://myhost/data-govern"
}
......@@ -9,8 +9,9 @@ import { reducers } from './reducer';
import * as user from './user';
import * as assets from './assets';
import * as metadata from './metadata';
import * as map from './map';
const funcs = Connect({ user, assets, metadata })
const funcs = Connect({ user, assets, metadata, map })
function* request(args) {
const { type, payload, callback, error } = args.args;
......
import * as service from '../service/map';
import { call } from 'redux-saga/effects';
export function* getAllTopics() {
return yield call(service.getAllTopics);
}
export function* getTableAndTreeModelByTid(payload) {
const tables = yield call(service.getTableModelByTid, payload);
const trees = yield call(service.getTreeModel);
return {tables: tables||[], trees: ((trees||[]).length>0)?trees[0]:{}};
}
import { GetJSON } from "../util/axios"
export function getAllTopics() {
return GetJSON("/datacatalog/countCtrl/queryAllTopics");
}
export function getTableModelByTid(payload) {
return GetJSON("/datacatalog/countCtrl/getTableModelInfoByDirId", payload);
}
export function getTreeModel() {
return GetJSON("/datacatalog/countCtrl/queryAllDirAsTree");
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ class Relation extends React.Component {
componentDidMount() {
const { data, type, history } = this.props;
setTimeout(() => {
const container = document.getElementById(`container${type||''}`);
const width = container.scrollWidth;
const height = container.scrollHeight || 500;
......@@ -68,7 +69,7 @@ class Relation extends React.Component {
outDiv.style.width = 'fit-content';
//outDiv.style.padding = '0px 0px 20px 0px';
outDiv.innerHTML = `
<h4>${e.item.getModel().name||''}</h4>
<h4>${e.item.getModel().text||''}</h4>
`;
return outDiv;
},
......@@ -144,8 +145,8 @@ class Relation extends React.Component {
e.item.get('model').fy = null;
});
graph.on('node:click', function (e) {
const node = e.item;
const model = node.getModel();
// const node = e.item;
// const model = node.getModel();
history && history.push(`${ContextPath}/home`);
});
......@@ -157,6 +158,8 @@ class Relation extends React.Component {
graph.changeSize(container.scrollWidth, container.scrollHeight);
};
}
}, 100);
}
render() {
......
......@@ -4,7 +4,7 @@ import { Card } from 'antd';
class SquareItem extends React.Component {
onItemClick = () => {
const { item, onClick, history } = this.props;
const { item, onClick } = this.props;
if (onClick) {
onClick(item);
}
......@@ -15,11 +15,11 @@ class SquareItem extends React.Component {
return (
<Card title={
<div className='pointer' onClick={this.onItemClick}>
{item.title||''}
{item.dirName||''}
</div>
}>
<p>{`数据资产: ${item.assetCount||''}`}</p>
<p>{`资产编目: ${item.assetDirCount||''}`}</p>
<p>{`数据资产: ${item.tableModelCount}`}</p>
<p>{`资产编目: ${item.subDirCount}`}</p>
</Card>
);
}
......
......@@ -49,7 +49,7 @@ class Tree extends React.Component {
graph.node(function (node) {
return {
label: node.title||'',
label: node.text||'',
labelCfg: {
position: node.children && node.children.length > 0 ? 'left' : 'right',
offset: 5,
......@@ -62,8 +62,8 @@ class Tree extends React.Component {
graph.fitView();
graph.on('node:click', function (e) {
const node = e.item;
const model = node.getModel();
// const node = e.item;
// const model = node.getModel();
history && history.push(`${ContextPath}/home`);
});
......
import React from 'react';
import { Row, Col, Breadcrumb, Card } from 'antd';
import { Row, Col, Breadcrumb } from 'antd';
import { HomeOutlined } from '@ant-design/icons';
import Bar from './Component/Bar';
import HorizontalBar from './Component/HorizontalBar';
import SquareItem from './Component/SquareItem';
import Tree from './Component/Tree';
import Relation from './Component/Relation';
import { dispatchLatest } from '../../../model';
const barData = [
{ name: '主体', value: 38 },
{ name: '品种', value: 52 },
{ name: '批量', value: 61 },
{ name: '融资', value: 145 },
{ name: '资讯', value: 48 },
{ name: '账户', value: 38 },
{ name: '财务', value: 38 },
{ name: '交易', value: 38 },
];
const column = 3;
const horizontalBarData = [
{ name: '资产1', value: 38 },
{ name: '资产2', value: 52 },
{ name: '资产3', value: 61 },
{ name: '资产4', value: 145 },
{ name: '资产5', value: 48 },
{ name: '资产6', value: 38 },
{ name: '资产7', value: 38 },
{ name: '资产8', value: 38 },
{ name: '资产9', value: 38 },
{ name: '资产10', value: 38 },
];
class MapContent extends React.Component {
const data = [
{
title: '公司业务与监管',
assetCount: 3223,
assetDirCount: 20,
children: [
{
title: '公司资料',
assetCount: 3223,
assetDirCount: 20,
children: [
{
title: '公司监管',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '信息披露',
assetCount: 3223,
assetDirCount: 20,
},
]
},
{
title: '公司活动',
assetCount: 3223,
assetDirCount: 20,
constructor(props) {
super(props);
this.state = {
loading: false,
tableModelData: null,
curTableModelData: null,
treeModelData: null,
relationModelData: null,
breadcrumbContents: null
};
}
]
},
{
title: '市场交易',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '清算交收',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '固收业务与监管',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '基金业务与监管',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '会员业务与监管',
assetCount: 3223,
assetDirCount: 20,
componentDidMount() {
const { tid } = this.props;
this.setState({ loadingTableModel: true }, () => {
dispatchLatest({
type: 'map.getTableAndTreeModelByTid',
payload: { dirId: tid },
callback: data => {
this.setState({
loadingTableModel: false,
tableModelData: data.tables||[],
curTableModelData: data.tables||[],
treeModelData: data.trees||{},
relationModelData: this.convertRelationModelData(data.trees||{}),
breadcrumbContents: [{ data: data.tables||[] }]
});
}
})
})
}
];
const treeData = {
title: '深交所',
children: [
{
title: '公司业务与监管',
assetCount: 3223,
assetDirCount: 20,
children: [
{
title: '公司资料',
assetCount: 3223,
assetDirCount: 20,
children: [
{
title: '公司监管',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '信息披露',
assetCount: 3223,
assetDirCount: 20,
},
]
},
{
title: '公司活动',
assetCount: 3223,
assetDirCount: 20,
convertRelationModelData = (data) => {
const _relationData = {
nodes: [],
edges: []
}
]
},
{
title: '市场交易',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '清算交收',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '固收业务与监管',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '基金业务与监管',
assetCount: 3223,
assetDirCount: 20,
},
{
title: '会员业务与监管',
assetCount: 3223,
assetDirCount: 20,
function recursionTreeData(treeData, sid, depth, cluster = '') {
if ((treeData||[]).length === 0) return;
(treeData||[]).forEach((item, index) => {
let _cluster = '';
if (depth === 1) {
_cluster = (index + 1).toString();
} else {
_cluster = cluster;
}
]
};
const relationData = {
nodes: [
{ id: 'node0', name: '深交所', label: '深交所', size: 80, cluster: 'a' },
{ id: 'node1', name: '公司业务与监管', label: '公司业务与监管', size: 60, cluster: 'b' },
{ id: 'node2', name: '市场交易', label: '市场交易', size: 60, cluster: 'c' },
{ id: 'node3', name: '清算交收', label: '清算交收', size: 60, cluster: 'd' },
{ id: 'node4', name: '固定业务与监管', label: '固定业务与监管', size: 60, isLeaf: true, cluster: 'e' },
{ id: 'node5', name: '基金业务与监管', label: '基金业务与监管', size: 60, isLeaf: true, cluster: 'f' },
{ id: 'node6', name: '会员页面与监管', label: '会员页面与监管', size: 60, isLeaf: true, cluster: 'g' },
{ id: 'node7', name: '公司资料', label: '公司资料', size: 40, isLeaf: true, cluster: 'b' },
{ id: 'node8', name: '公司活动', label: '公司活动', size: 40, isLeaf: true, cluster: 'b' },
{ id: 'node9', name: '公司监管', label: '公司监管', size: 40, isLeaf: true, cluster: 'b' },
{ id: 'node10', name: '信息批露', label: '信息批露', size: 40, isLeaf: true, cluster: 'b' },
],
edges: [
{ source: 'node0', target: 'node1' },
{ source: 'node0', target: 'node2' },
{ source: 'node0', target: 'node3' },
{ source: 'node0', target: 'node4' },
{ source: 'node0', target: 'node5' },
{ source: 'node0', target: 'node6' },
{ source: 'node1', target: 'node7' },
{ source: 'node1', target: 'node8' },
{ source: 'node7', target: 'node9' },
{ source: 'node7', target: 'node10' },
],
};
_relationData.nodes.push({ id: item.nodeId, text: item.text||'', label: item.text||'', size: (80-depth*20)>20?(80-depth*20):20, cluster: _cluster, isLeaf: (item.childSize===null || item.childSize===0) });
_relationData.edges.push({ source: sid, target: item.nodeId });
recursionTreeData(item.children||[], item.nodeId, depth+1, _cluster);
})
}
const column = 3;
if (data && data.nodeId) {
class MapContent extends React.Component {
_relationData.nodes.push({ id: data.nodeId, text: data.text||'', label: data.text||'', size: 80, cluster: '0', isLeaf: (data.childSize===null || data.childSize===0) });
recursionTreeData(data.children||[], data.nodeId, 1);
}
constructor(props) {
super(props);
this.state = {
curData: data||[],
breadcrumbContents: [{ data }]
};
return _relationData;
}
onSquareItemClick = (item) => {
......@@ -195,8 +83,8 @@ class MapContent extends React.Component {
if ((item.children||[]).length===0) return;
this.setState({
breadcrumbContents: [...breadcrumbContents, { name: item.title||'', data: item.children||[] }],
curData: item.children||[],
breadcrumbContents: [...breadcrumbContents, { name: item.dirName||'', data: item.children||[] }],
curTableModelData: item.children||[],
});
}
......@@ -205,32 +93,23 @@ class MapContent extends React.Component {
this.setState({
breadcrumbContents: breadcrumbContents.splice(0, index===0?1:(index+1)),
curData: content.data||[],
curTableModelData: content.data||[],
})
}
render() {
const { diagram, type } = this.props;
const { curData, breadcrumbContents } = this.state;
const { curTableModelData, breadcrumbContents, treeModelData, relationModelData } = this.state;
let groups = [];
if (curData) {
for(var i=0;i<data.length;i+=column){
groups.push(curData.slice(i,i+column));
if (curTableModelData) {
for(var i=0;i<curTableModelData.length;i+=column){
groups.push(curTableModelData.slice(i,i+column));
}
}
return (
<Row gutter={10}>
<Col span={8}>
<Card title='数据资产数量'>
<Bar data={barData} />
</Card>
<Card title='数据资产访问TOP10' className='mt-3'>
<HorizontalBar data={horizontalBarData} />
</Card>
</Col>
<Col span={16}>
<>
{
diagram==='square' && <>
{
......@@ -270,13 +149,12 @@ class MapContent extends React.Component {
</>
}
{
diagram==='tree' && <Tree data={treeData} type={type} {...this.props} />
diagram==='tree' && <Tree data={treeModelData} type={type} {...this.props} />
}
{
diagram==='relation' && <Relation data={relationData} type={type} {...this.props} />
diagram==='relation' && <Relation data={relationModelData} type={type} {...this.props} />
}
</Col>
</Row>
</>
);
}
}
......
......@@ -2,6 +2,7 @@ import React from 'react';
import { Tabs, Radio } from 'antd';
import MapContent from './MapContent';
import { dispatchLatest } from '../../../model';
const { TabPane } = Tabs;
......@@ -10,10 +11,28 @@ class Map extends React.Component {
super(props);
this.state = {
diagram: 'square',
tabKey: '1'
tabKey: '0',
loadingTopics: false,
topics: null
};
}
componentDidMount() {
this.setState({ loadingTopics: true }, () => {
dispatchLatest({
type: 'map.getAllTopics',
payload: null,
callback: data => {
this.setState({
loadingTopics: false,
topics: data
});
}
})
})
}
onRadioChange = e => {
this.setState({ diagram: e.target.value });
};
......@@ -23,10 +42,11 @@ class Map extends React.Component {
}
render() {
const { diagram, tabKey } = this.state;
const { diagram, tabKey, topics } = this.state;
return (
<div style={{ backgroundColor: '#fff', height: '100%' }}>
<Tabs
{
topics && topics.length>0 && <Tabs
activeKey={tabKey}
size='large'
centered
......@@ -41,16 +61,17 @@ class Map extends React.Component {
}}
onChange={this.onTabChange}
>
<TabPane tab='业务' key='1' className='p-3' style={{ height: '100%' }}>
{ tabKey==='1' && <MapContent diagram={diagram} type='business' {...this.props} /> }
</TabPane>
<TabPane tab='主题' key='2' className='p-3' style={{ height: '100%' }}>
{ tabKey==='2' && <MapContent diagram={diagram} type='theme' {...this.props} /> }
</TabPane>
<TabPane tab='来源' key='3' className='p-3' style={{ height: '100%' }}>
{ tabKey==='3' && <MapContent diagram={diagram} type='source' {...this.props} /> }
{
topics && topics.map((topic, index) => {
return (
<TabPane tab='业务' key={index.toString()} className='p-3' style={{ height: '100%' }}>
{ tabKey===index.toString() && <MapContent diagram={diagram} tid={topic.id||''} type='business' {...this.props} /> }
</TabPane>
);
})
}
</Tabs>
}
</div>
);
}
......
......@@ -24,16 +24,13 @@ class Manage extends Component {
<ManageLayout
{...this.props}
content={
session && session.userId ? (
<Switch>
<Route path={`${match.path}/map`} component={Map} {...this.props} />
<Route path={`${match.path}/map`} component={Map} />
</Switch>
// session && session.userId ? (
// <Switch>
// <Route path={`${match.path}/map`} component={Map} />
// </Switch>
// ) : (
// <GetSession {...this.props} />
// )
) : (
<GetSession {...this.props} />
)
}
/>
</React.Fragment>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment