feats: import list data function.

Signed-off-by: feihu.wang <wfh45678@163.com>
This commit is contained in:
feihu.wang
2019-12-03 18:03:37 +08:00
parent 40d0be2634
commit f999b5183b
9 changed files with 109 additions and 34 deletions

14
pom.xml
View File

@@ -87,7 +87,19 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version>
</dependency>
<dependency>

View File

@@ -76,6 +76,13 @@
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>
<build>

View File

@@ -55,7 +55,7 @@ public class ExcelUtils {
// 创建第一种字体样式(用于列名)
f.setFontHeightInPoints((short) 10);
f.setColor(IndexedColors.BLACK.getIndex());
f.setBoldweight(Font.BOLDWEIGHT_BOLD);
// f.setBoldweight(Font.BOLDWEIGHT_BOLD);
// 创建第二种字体样式(用于值)
f2.setFontHeightInPoints((short) 10);
@@ -67,19 +67,19 @@ public class ExcelUtils {
// 设置第一种单元格的样式(用于列名)
cs.setFont(f);
cs.setBorderLeft(CellStyle.BORDER_THIN);
cs.setBorderRight(CellStyle.BORDER_THIN);
cs.setBorderTop(CellStyle.BORDER_THIN);
cs.setBorderBottom(CellStyle.BORDER_THIN);
cs.setAlignment(CellStyle.ALIGN_CENTER);
// cs.setBorderLeft(CellStyle.BORDER_THIN);
// cs.setBorderRight(CellStyle.BORDER_THIN);
// cs.setBorderTop(CellStyle.BORDER_THIN);
// cs.setBorderBottom(CellStyle.BORDER_THIN);
// cs.setAlignment(CellStyle.ALIGN_CENTER);
// 设置第二种单元格的样式(用于值)
cs2.setFont(f2);
cs2.setBorderLeft(CellStyle.BORDER_THIN);
cs2.setBorderRight(CellStyle.BORDER_THIN);
cs2.setBorderTop(CellStyle.BORDER_THIN);
cs2.setBorderBottom(CellStyle.BORDER_THIN);
cs2.setAlignment(CellStyle.ALIGN_CENTER);
// cs2.setBorderLeft(CellStyle.BORDER_THIN);
// cs2.setBorderRight(CellStyle.BORDER_THIN);
// cs2.setBorderTop(CellStyle.BORDER_THIN);
// cs2.setBorderBottom(CellStyle.BORDER_THIN);
// cs2.setAlignment(CellStyle.ALIGN_CENTER);
//设置列名
for(int i=0;i<columnNames.length;i++){
Cell cell = row.createCell(i);

View File

@@ -96,5 +96,14 @@ public class DataListRecordVO implements Serializable{
this.opt = opt;
}
@Override
public String toString() {
return "DataListRecordVO{" +
"id=" + id +
", dataListId=" + dataListId +
", dataRecord='" + dataRecord + '\'' +
", modelId=" + modelId +
", opt='" + opt + '\'' +
'}';
}
}

View File

@@ -161,7 +161,7 @@ public class EventServiceImpl implements EventService {
// 创建第一种字体样式(用于列名)
f.setFontHeightInPoints((short) 10);
f.setColor(IndexedColors.BLACK.getIndex());
f.setBoldweight(Font.BOLDWEIGHT_BOLD);
// f.setBoldweight(Font.BOLDWEIGHT_BOLD);
// 创建第二种字体样式(用于值)
f2.setFontHeightInPoints((short) 10);
@@ -173,19 +173,19 @@ public class EventServiceImpl implements EventService {
// 设置第一种单元格的样式(用于列名)
cs.setFont(f);
cs.setBorderLeft(CellStyle.BORDER_THIN);
cs.setBorderRight(CellStyle.BORDER_THIN);
cs.setBorderTop(CellStyle.BORDER_THIN);
cs.setBorderBottom(CellStyle.BORDER_THIN);
cs.setAlignment(CellStyle.ALIGN_CENTER);
// cs.setBorderLeft(CellStyle.BORDER_THIN);
// cs.setBorderRight(CellStyle.BORDER_THIN);
// cs.setBorderTop(CellStyle.BORDER_THIN);
// cs.setBorderBottom(CellStyle.BORDER_THIN);
// cs.setAlignment(CellStyle.ALIGN_CENTER);
// 设置第二种单元格的样式(用于值)
cs2.setFont(f2);
cs2.setBorderLeft(CellStyle.BORDER_THIN);
cs2.setBorderRight(CellStyle.BORDER_THIN);
cs2.setBorderTop(CellStyle.BORDER_THIN);
cs2.setBorderBottom(CellStyle.BORDER_THIN);
cs2.setAlignment(CellStyle.ALIGN_CENTER);
// cs2.setBorderLeft(CellStyle.BORDER_THIN);
// cs2.setBorderRight(CellStyle.BORDER_THIN);
// cs2.setBorderTop(CellStyle.BORDER_THIN);
// cs2.setBorderBottom(CellStyle.BORDER_THIN);
// cs2.setAlignment(CellStyle.ALIGN_CENTER);
// 设置列名
for (int i = 0; i < titleList4Field.size(); i++) {
Cell cell = row.createCell(i);

View File

@@ -306,6 +306,7 @@ public class DataListsServiceImpl implements DataListsService, SubscribeHandle {
public CommonResult batchImportDataRecord(List<DataListRecordVO> list, Long dataListId) {
CommonResult result = new CommonResult();
for (DataListRecordVO dataListRecord : list) {
dataListRecord.setDataListId(dataListId);
int count = dataListDal.saveRecord(dataListRecord);
if (count > 0) {
// 通知更新

View File

@@ -256,9 +256,13 @@ public class ModelServiceImpl implements ModelService, SubscribeHandle {
String columns = plugin.getMeta();
if (columns == null) {
String fieldType = plugin.getType();
String elaType = convertFieldType2ElasticType(fieldType);
String tmp = String.format(base, elaType);
preItemJson.put(item.getDestField(), JSON.parseObject(tmp));
if(fieldType.equals("JSON")) {
//TODO: json类型需要另外处理
} else {
String elaType = convertFieldType2ElasticType(fieldType);
String tmp = String.format(base, elaType);
preItemJson.put(item.getDestField(), JSON.parseObject(tmp));
}
} else {
String meta = plugin.getMeta();
List<JSONObject> fieldsJson = JSON.parseArray(meta, JSONObject.class);

View File

@@ -1,5 +1,5 @@
import React from 'react';
import {Button,Checkbox,Select,Radio,Switch,Form,Row,Col,Icon,Modal,Input,InputNumber,Cascader,Tooltip } from 'antd';
import {Button,Checkbox,Select,Radio,Switch,Form,Row,Col,Icon,Modal,Input,InputNumber,Cascader,Tooltip,Upload, message } from 'antd';
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
@@ -15,13 +15,17 @@ export default class AddDataListRecord extends React.Component{
this.state={
visible:false,
importVisible: false,
dataRecord:'',
fieldNum:this.props.metaList.length
}
}
componentDidMount() {
console.log(this.props);
}
handleChange=(index,e)=>{
var value=e.target.value;
var valueArr=this.state.dataRecord.split(',');
@@ -48,8 +52,15 @@ export default class AddDataListRecord extends React.Component{
showModal=()=>{
this.setState({
dataRecord:'',
visible:true
dataRecord: '',
visible: true
})
}
showModal2=()=>{
this.setState({
importVisible:true
})
}
@@ -58,7 +69,7 @@ export default class AddDataListRecord extends React.Component{
param.dataListId=this.props.dataListId;
param.dataRecord=this.state.dataRecord;
FetchUtil('/datalistrecord/','PUT',JSON.stringify(param),
FetchUtil('/datalistrecord/','PUT', JSON.stringify(param),
(data) => {
this.setState({
visible:false
@@ -73,15 +84,39 @@ export default class AddDataListRecord extends React.Component{
})
}
handleCancel2=()=>{
this.setState({
importVisible:false
})
}
render(){
const formItemLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 16 },
};
const uploadProps = {
name: 'file',
data: {"dataListId": this.props.dataListId},
action: '/services/v1/datalistrecord/batchImportDataRecord',
headers: {
"x-auth-token": localStorage.getItem('x-auth-token'),
},
onChange(info) {
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
message.success(`${info.file.name} file uploaded successfully`);
} else if (info.file.status === 'error') {
message.error(`${info.file.name} file upload failed.`);
}
},
};
let valueArr=this.state.dataRecord.split(',');
return (
<span>
<Button onClick={this.showModal} type="primary">新增</Button>
<Button onClick={this.showModal} type="primary">新增</Button> &nbsp;&nbsp;
<Button onClick={this.showModal2} type="primary">导入数据</Button>
<Modal title="新增记录" visible={this.state.visible} onOk={this.handleSubmit} onCancel={this.handleCancel}>
<Form horizontal form={this.props.form}>
{this.props.metaList.map(function(info,i){
@@ -93,6 +128,13 @@ export default class AddDataListRecord extends React.Component{
}.bind(this))}
</Form>
</Modal>
<Modal title="导入数据" visible={this.state.importVisible} onCancel={this.handleCancel2} onOk={this.handleCancel2}>
<Upload {...uploadProps}>
<Button>
<Icon type="upload" /> Click to Upload
</Button>
</Upload>
</Modal>
</span>
);
}

View File

@@ -55,7 +55,7 @@ class Welcome extends React.Component{
<div>
<div className="ibox">
<div className="ibox-content">
<h2>欢迎登录反欺诈系统管理平台</h2>
<h2>欢迎登录风控引擎管理平台</h2>
</div>
</div>
</div>