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