文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit d93380d3 by 李景熙

Merge branch 'develop' of https://gitlab.redhtc.com/Berlincen/DA-Platform into develop

parents 37067ecf a07a7af0
......@@ -51,15 +51,6 @@
<!-- 文本界面 -->
<div class="content" @mouseup="highlight()" v-html="content"></div>
<!-- 文本界面 -->
<!-- 表格界面 -->
<div @click="highlight()">
<el-table :data="tableData" border style="width: 100%">
<el-table-column prop="date" label="日期" width="180"></el-table-column>
<el-table-column prop="name" label="姓名" width="180"></el-table-column>
<el-table-column prop="address" label="地址"></el-table-column>
</el-table>
</div>
<!-- 表格界面 -->
<br />
<div>
<el-button type="primary" @click="submit()">提交</el-button>
......@@ -122,34 +113,36 @@ export default {
// 文章列表
textData: [],
// templete
treeDataExample:[{
label: "宏观稳定性",
children: [
{
label: "不稳定"
},
{
label: "基本稳定"
},
{
label: "稳定"
}
]
},
{
label: "确定性程度",
children: [
{
label: "确定"
},
{
label: "基本确定"
},
{
label: "不确定"
}
]
}],
// treeDataExample: [
// {
// label: "宏观稳定性",
// children: [
// {
// label: "不稳定"
// },
// {
// label: "基本稳定"
// },
// {
// label: "稳定"
// }
// ]
// },
// {
// label: "确定性程度",
// children: [
// {
// label: "确定"
// },
// {
// label: "基本确定"
// },
// {
// label: "不确定"
// }
// ]
// }
// ],
treeData: [],
defaultProps: {
......@@ -160,34 +153,67 @@ export default {
ifAlert: false, // 弹窗
// 实体
value: "",
optionsExample: [{
value: "选项1",
label: "滑坡"
},
{
value: "选项2",
label: "山体"
},
{
value: "选项3",
label: "河流"
},
{
value: "选项4",
label: "时间"
}],
// optionsExample: [
// {
// value: "选项1",
// label: "滑坡"
// },
// {
// value: "选项2",
// label: "山体"
// },
// {
// value: "选项3",
// label: "河流"
// },
// {
// value: "选项4",
// label: "时间"
// }
// ],
options: [],
// table
tableData: []
};
},
beforeMount() {
// 从通用传来文本信息 // TODO 区分text和table
// 从通用传来文本信息
// TODO quary instead of params to fix the bug during refreshing
this.file = JSON.parse(decodeURIComponent(this.$route.params.file));
this.task = JSON.parse(decodeURIComponent(this.$route.params.task));
},
methods: {
// 分出表格
checkTable() {
console.log(this.file.url);
if (
this.file.url
.split("")
.reverse()
.join("")
.substring(0, 4)
.split("")
.reverse()
.join("") == "xlsx"
) {
var params = {
file: encodeURIComponent(JSON.stringify(this.file)),
task: encodeURIComponent(JSON.stringify(this.task))
};
this.$router.push({ name: "table", params });
} else if (
this.file.url
.split("")
.reverse()
.join("")
.substring(0, 3)
.split("")
.reverse()
.join("") == "txt"
) {
this.insertDocument();
}
},
// 插入数据库
insertDocument() {
console.log("userId" + this.$store.state.userInfo.userId);
......@@ -198,7 +224,7 @@ export default {
url: "/textAnnotation/insertDocument",
data: {
templateId: 1, // TODO 模板id
annotatorId: this.$store.state.userInfo.userId, // TODO 标注者信息
annotatorId: this.$store.state.userInfo.userId,
textUrl: this.file.url,
type: "text",
fileId: this.file.id
......@@ -278,17 +304,12 @@ export default {
}
}).then(res => {
if (res.return_code == 200) {
console.log(res.result)
//console.log(res.result)
// 实体
this.token.entityId = JSON.stringify(res.result.templateId) // 现在的实体与模板相近,所以就先固定了
this.options.push(res.result.templateName)
this.token.entityId = JSON.stringify(res.result.templateId); // 现在的实体与模板相近,所以就先固定了
this.options.push(res.result.templateName);
// 属性
this.treeData = res.result.entityList
console.log("hello");
console.log(this.optionsExample)
console.log(this.treeDataExample)
console.log(this.options)
console.log(this.treeData)
this.treeData = res.result.entityList;
} else {
this.$message({
message: res.return_info,
......@@ -301,8 +322,7 @@ export default {
highlight() {
if (window.getSelection().toString() != "") {
// 禁止重复标注
var i;
for (i = 0; i < this.tokenList.length; i++) {
for (var i = 0; i < this.tokenList.length; i++) {
if (window.getSelection().toString() == this.tokenList[i].word)
return;
}
......@@ -310,10 +330,10 @@ export default {
this.token.word = window.getSelection().toString();
this.token.begin = window.getSelection().anchorOffset; //开始位置
this.token.end = window.getSelection().focusOffset; //结束位置
console.log("token: " + JSON.stringify(this.token));
//console.log("token: " + JSON.stringify(this.token));
}
},
// 添加标注 // TODO templete列表传输
// 添加标注
handleCheckChange() {
this.ifAlert = false;
this.token.entityId = this.value; // 实体
......@@ -504,7 +524,7 @@ export default {
}
},
mounted: function() {
this.insertDocument();
this.checkTable();
}
};
</script>
......
......@@ -18,3 +18,8 @@ class DevelopmentConfig(object):
'username': 'admin',
'password': 'admin'
}
# MONGODB_SETTINGS = {
# 'host': 'localhost',
# 'port': 27017,
# }
......@@ -99,42 +99,42 @@ def create_images(image_list):
return res
# 图层实体
class LayerEntity(db.EmbeddedDocument):
layerId = db.IntField(required=True)
layerName = db.StringField(required=True)
layerUrl = db.StringField(required=True)
def to_json(self):
return {'layerId': self.layerId,
'layerName': self.layerName,
'layerUrl': self.layerUrl}
# # 图层实体
# class LayerEntity(db.EmbeddedDocument):
# layerId = db.IntField(required=True)
# layerName = db.StringField(required=True)
# layerUrl = db.StringField(required=True)
#
# def to_json(self):
# return {'layerId': self.layerId,
# 'layerName': self.layerName,
# 'layerUrl': self.layerUrl}
# 图层标注的数据库
class Layer(db.Document):
relationId = db.IntField(required=True, unique=True)
layerEntityList = db.ListField(db.EmbeddedDocumentField(LayerEntity))
# layerEntityList = db.ListField(db.EmbeddedDocumentField(LayerEntity))
labelList = db.ListField(db.EmbeddedDocumentField(Label))
def to_json(self):
return {'relationId': self.relationId,
'layerEntityList': [i.to_json() for i in self.layerEntityList],
# 'layerEntityList': [i.to_json() for i in self.layerEntityList],
'labelList': [i.to_json() for i in self.labelList]
}
# 根据json列表创建对象列表
def create_layer_entities(layer_entity_list):
res = []
for i in layer_entity_list:
layer_entity = LayerEntity(
layerId=i['layerId'],
layerName=i['layerName'],
layerUrl=i['layerUrl']
)
res.append(layer_entity)
return res
# # 根据json列表创建对象列表
# def create_layer_entities(layer_entity_list):
# res = []
# for i in layer_entity_list:
# layer_entity = LayerEntity(
# layerId=i['layerId'],
# layerName=i['layerName'],
# layerUrl=i['layerUrl']
# )
# res.append(layer_entity)
# return res
# 根据json列表创建对象列表
......@@ -147,7 +147,7 @@ def create_layers(layer_list):
obj.delete()
layer = Layer(
relationId=i['relationId'],
layerEntityList=create_layer_entities(i['layerEntityList']),
# layerEntityList=create_layer_entities(i['layerEntityList']),
labelList=create_labels(i['labelList'])
)
layer.save()
......@@ -172,12 +172,12 @@ class LandmarkEntity(db.EmbeddedDocument):
# 地标存储表
class Landmark(db.Document):
relationId = db.IntField(required=True, unique=True)
layerEntityList = db.ListField(db.EmbeddedDocumentField(LayerEntity))
# layerEntityList = db.ListField(db.EmbeddedDocumentField(LayerEntity))
landmarkEntityList = db.ListField(db.EmbeddedDocumentField(LandmarkEntity))
def to_json(self):
return {'relationId': self.relationId,
'layerEntityList': [i.to_json() for i in self.layerEntityList],
# 'layerEntityList': [i.to_json() for i in self.layerEntityList],
'landmarkEntityList': [i.to_json() for i in self.landmarkEntityList]
}
......@@ -200,9 +200,13 @@ def create_landmark_entities(landmark_entity_list):
def create_landmarks(landmark_list):
res = []
for i in landmark_list:
rid = i['relationId']
obj = Landmark.objects(relationId=rid)
if obj:
obj.delete()
landmark = Landmark(
relationId=i['relationId'],
layerEntityList=create_layer_entities(i['layerEntityList']),
# layerEntityList=create_layer_entities(i['layerEntityList']),
landmarkEntityList=create_landmark_entities(i['landmarkEntityList'])
)
res.append(landmark)
......@@ -232,25 +236,37 @@ def saveImage(image_list):
# 获取图层
def getLayer(relation_list):
def getLayer(relation_id):
try:
layer_list = Layer.objects(relationId__in=relation_list)
landmark_list = Landmark.objects(relationId__in=relation_list)
layer_data = [layer.to_json() for layer in layer_list]
landmark_data = [landmark.to_json() for landmark in landmark_list]
return Result(1, [{'layer num': len(layer_data), 'landmark num': len(landmark_data)}],
{'layerList': layer_data, 'landmarkList': landmark_data})
layer_info = Layer.objects(relationId=relation_id).first()
layer_data = None
if layer_info:
layer_data = layer_info.to_json()
landmark_info = Landmark.objects(relationId=relation_id).first()
landmark_data = None
if landmark_info:
landmark_data = landmark_info.to_json()
return Result(1, "success", {'layerInfo': layer_data, 'landmarkList': landmark_data})
except Exception as e:
traceback.print_exc()
return Result(0, repr(e), {})
# 保存图层标注结果
def saveLayer(layer_list, landmark_list):
def saveLayer(layer_info, landmark_info):
try:
layers = create_layers(layer_list)
landmarks = create_landmarks(landmark_list)
return Result(1, [{'layer num': len(layers), 'landmark num': len(landmarks)}], {})
layer_list = [layer_info]
layer_data = create_layers(layer_list)[0]
if landmark_info is not None:
landmark_list = [landmark_info]
landmark_data = create_landmarks(landmark_list)[0]
# print(landmark_data.to_json())
# print(layer_data.to_json())
return Result(1, "success", {})
except Exception as e:
traceback.print_exc()
return Result(0, repr(e), {})
......@@ -3,11 +3,11 @@ from flask import Blueprint, jsonify, request
from dao import Image
image = Blueprint("image", __name__, url_prefix="/api/image")
image = Blueprint("image", __name__, url_prefix="/api")
# 获取图片
@image.route("/getImage", methods=["POST"])
@image.route("/image/getImage", methods=["POST"])
def get_image():
data = json.loads(request.data)
relation_list = data['relationList']
......@@ -22,7 +22,7 @@ def get_image():
# 保存图片标注结果
@image.route("/saveImage", methods=["POST"])
@image.route("/image/saveImage", methods=["POST"])
def save_image():
data = json.loads(request.data)
image_list = data['imageList']
......@@ -36,10 +36,10 @@ def save_image():
# 获取图层
@image.route("/getLayer", methods=["POST"])
@image.route("/layer/getLayer", methods=["POST"])
def get_layer():
data = json.loads(request.data)
relation_list = data['relationList']
relation_list = data['relationId']
layer = Image.getLayer(relation_list)
res = {
'code': layer.code,
......@@ -50,12 +50,14 @@ def get_layer():
# 保存图层标注结果
@image.route("/saveLayer", methods=["POST"])
@image.route("/layer/saveLayer", methods=["POST"])
def save_layer():
data = json.loads(request.data)
layer_list = data['layerList']
landmark_list = data['landmarkList']
ret = Image.saveLayer(layer_list, landmark_list)
layer_info = data['layerInfo']
landmark_info = None
if 'landmarkInfo' in data:
landmark_info = data['landmarkInfo']
ret = Image.saveLayer(layer_info, landmark_info)
res = {
'code': ret.code,
'message': ret.message,
......@@ -105,16 +107,8 @@ def save_layer():
# 保存图层标注结果的测试数据
# {
# "layerList": [
# {
# "layerInfo": {
# "relationId": 8,
# "layerEntityList": [
# {
# "layerId": 7,
# "layerName": "layerNo1",
# "layerUrl": "www.layerNo1.com"
# }
# ],
# "labelList": [
# {
# "labelId": 181,
......@@ -128,18 +122,9 @@ def save_layer():
# ]
# }
# ]
# }
# ],
# "landmarkList": [
# {
# "relationId": 1,
# "layerEntityList": [
# {
# "layerId": 3,
# "layerName": "layerNo3",
# "layerUrl": "www.layerNo3.com"
# }
# ],
# },
# "landmarkInfo": {
# "relationId": 181,
# "landmarkEntityList": [
# {
# "landmarkId": 31,
......@@ -149,5 +134,4 @@ def save_layer():
# }
# ]
# }
# ]
# }
\ No newline at end of file
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