owl-cli 6.169.0 → 6.170.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,107 +11,131 @@ function main(){
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
var s = null;
|
|
15
|
-
var url = batchImport.importFile[0].url;
|
|
16
|
-
if(!url){
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if(url.endsWith(".zip")){
|
|
20
|
-
s = $.unzipUrl(url,batchImport.zipPass,batchImport.contentFileName);
|
|
21
|
-
}
|
|
22
|
-
else{
|
|
23
|
-
s = $.get(url);
|
|
24
|
-
}
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
try{
|
|
16
|
+
var s = null;
|
|
17
|
+
var url = batchImport.importFile[0].url;
|
|
18
|
+
if(!url){
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if(url.endsWith(".zip")){
|
|
22
|
+
s = $.unzipUrl(url,batchImport.zipPass,batchImport.contentFileName);
|
|
23
|
+
}
|
|
24
|
+
else{
|
|
25
|
+
s = $.get(url);
|
|
26
|
+
}
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
var now = new Date().getTime();
|
|
29
|
+
var log = {
|
|
30
|
+
objId:batchImport.id,
|
|
31
|
+
startTime:now,
|
|
32
|
+
endTime:now,
|
|
33
|
+
name:"批量导入" + batchImport.id,
|
|
34
|
+
remark:"下载完成,文件长度" + s.length
|
|
36
35
|
|
|
37
|
-
var contentType = batchImport.contentType;
|
|
38
|
-
if(!contentType){
|
|
39
|
-
if(s.startsWith("[")){
|
|
40
|
-
contentType = "json";
|
|
41
36
|
}
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
owl_process_job_logService.add(log);
|
|
38
|
+
|
|
39
|
+
var contentType = batchImport.contentType;
|
|
40
|
+
if(!contentType){
|
|
41
|
+
if(s.startsWith("[")){
|
|
42
|
+
contentType = "json";
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
contentType = "jsonl";
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
|
-
|
|
46
|
-
var rows = null;
|
|
48
|
+
var rows = null;
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
if(contentType==="jsonl"){
|
|
51
|
+
rows = s.split("\n");
|
|
52
|
+
}
|
|
53
|
+
else{
|
|
54
|
+
rows = JSON.parse(s);
|
|
55
|
+
}
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
var log = {
|
|
58
|
+
objId:batchImport.id,
|
|
59
|
+
name:"批量导入" + batchImport.id,
|
|
60
|
+
remark:"读取记录完成,记录数" + rows.length
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
}
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
owl_process_job_logService.add(log);
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var row = rows[i];
|
|
67
|
-
try{
|
|
66
|
+
var nImported = 0;
|
|
67
|
+
for(var i=0; i<rows.length; i++){
|
|
68
68
|
var row = rows[i];
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
rec =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
try{
|
|
70
|
+
var row = rows[i];
|
|
71
|
+
var rec = null;
|
|
72
|
+
if(contentType==="jsonl") {
|
|
73
|
+
rec = JSON.parse(row);
|
|
74
|
+
}
|
|
75
|
+
else{
|
|
76
|
+
rec = row;
|
|
77
|
+
}
|
|
76
78
|
@projectCodeService.add( rec);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
nImported++;
|
|
80
|
+
|
|
81
|
+
if(i%1000==0){
|
|
82
|
+
var now = new Date().getTime();
|
|
83
|
+
var log = {
|
|
84
|
+
objId:batchImport.id,
|
|
85
|
+
startTime:now,
|
|
86
|
+
endTime:now,
|
|
87
|
+
name:"批量导入" + batchImport.id,
|
|
88
|
+
remark:"成功导入记录:" + i
|
|
89
|
+
}
|
|
90
|
+
owl_process_job_logService.add(log);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch(e){
|
|
80
94
|
var now = new Date().getTime();
|
|
81
95
|
var log = {
|
|
82
96
|
objId:batchImport.id,
|
|
83
97
|
startTime:now,
|
|
84
98
|
endTime:now,
|
|
85
99
|
name:"批量导入" + batchImport.id,
|
|
86
|
-
remark:"
|
|
100
|
+
remark:"错误记录,行号" + i + ",内容:" + row
|
|
87
101
|
}
|
|
88
102
|
owl_process_job_logService.add(log);
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
|
-
catch(e){
|
|
92
|
-
var now = new Date().getTime();
|
|
93
|
-
var log = {
|
|
94
|
-
objId:batchImport.id,
|
|
95
|
-
startTime:now,
|
|
96
|
-
endTime:now,
|
|
97
|
-
name:"批量导入" + batchImport.id,
|
|
98
|
-
remark:"错误记录,行号" + i + ",内容:" + row
|
|
99
|
-
}
|
|
100
|
-
owl_process_job_logService.add(log);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
105
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
var now = new Date().getTime();
|
|
107
|
+
var log = {
|
|
108
|
+
objId:batchImport.id,
|
|
109
|
+
startTime:now,
|
|
110
|
+
endTime:now,
|
|
111
|
+
name:"批量导入" + batchImport.id,
|
|
112
|
+
remark:"导入成功"+ nImported + "条记录"
|
|
113
|
+
}
|
|
114
|
+
owl_process_job_logService.add(log);
|
|
115
|
+
|
|
116
|
+
batchImport.state = "success";
|
|
117
|
+
owl_batch_importService.update(batchImport);
|
|
118
|
+
}catch(e){
|
|
119
|
+
var msg = "";
|
|
120
|
+
if(typeof e === "string"){
|
|
121
|
+
msg = e;
|
|
122
|
+
}
|
|
123
|
+
else{
|
|
124
|
+
msg = e.msg;
|
|
125
|
+
}
|
|
126
|
+
var now = new Date().getTime();
|
|
127
|
+
var log = {
|
|
128
|
+
objId:batchImport.id,
|
|
129
|
+
startTime:now,
|
|
130
|
+
endTime:now,
|
|
131
|
+
name:"批量导入" + batchImport.id,
|
|
132
|
+
remark:"出现错误:" + msg
|
|
133
|
+
}
|
|
134
|
+
owl_process_job_logService.add(log);
|
|
135
|
+
batchImport.state = "failed";
|
|
136
|
+
owl_batch_importService.update(batchImport);
|
|
111
137
|
}
|
|
112
|
-
owl_process_job_logService.add(log);
|
|
113
138
|
|
|
114
|
-
batchImport.state = "success";
|
|
115
139
|
}
|
|
116
140
|
main();
|
|
117
141
|
|