Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
1dcc9410
Commit
1dcc9410
authored
Jan 08, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
2bc45de5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
29 deletions
+57
-29
taskexecutor/app/base/db/task.base.js
+7
-1
taskexecutor/app/base/db/task/test/testTask.js
+19
-0
taskexecutor/app/base/utils/redisClient.js
+3
-0
taskexecutor/app/base/utils/test.js
+28
-28
No files found.
taskexecutor/app/base/db/task.base.js
View file @
1dcc9410
...
@@ -34,13 +34,16 @@ class TaskBase{
...
@@ -34,13 +34,16 @@ class TaskBase{
}
}
async
postTask
(
params
){
async
postTask
(
params
){
await
this
.
subPostTask
();
await
this
.
subPostTask
();
this
.
redisClient
.
client
.
quit
();
this
.
redisClient
.
subclient
.
quit
();
}
}
async
doTask
(
params
){
async
doTask
(
params
){
try
{
try
{
await
this
.
beforeTask
(
params
);
await
this
.
beforeTask
(
params
);
if
(
!
this
.
isThrough
){
if
(
!
this
.
isThrough
){
await
this
.
subDoTask
(
params
);
await
this
.
subDoTask
(
params
);
await
this
.
postTask
(
params
);
if
(
this
.
isDaemon
){
if
(
this
.
isDaemon
){
var
http
=
require
(
'http'
);
var
http
=
require
(
'http'
);
var
server
=
http
.
createServer
((
req
,
res
)
=>
{
var
server
=
http
.
createServer
((
req
,
res
)
=>
{
...
@@ -48,7 +51,10 @@ class TaskBase{
...
@@ -48,7 +51,10 @@ class TaskBase{
})
})
server
.
listen
(
process
.
env
.
TASK_PORT
);
//监听端口号是3000的服务器
server
.
listen
(
process
.
env
.
TASK_PORT
);
//监听端口号是3000的服务器
console
.
log
(
"is listenning........on "
+
process
.
env
.
TASK_PORT
);
console
.
log
(
"is listenning........on "
+
process
.
env
.
TASK_PORT
);
}
else
{
await
this
.
postTask
(
params
);
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
await
this
.
redisClient
.
unsubscribe
(
this
.
TASK_CHANNEL
);
await
this
.
redisClient
.
unsubscribe
(
this
.
TASK_CHANNEL
);
...
...
taskexecutor/app/base/db/task/test/testTask.js
0 → 100644
View file @
1dcc9410
const
TaskBase
=
require
(
"../../task.base"
);
const
settings
=
require
(
"../../../../config/settings"
);
var
excel
=
require
(
'exceljs'
);
const
system
=
require
(
"../../../system"
);
const
fs
=
require
(
'fs'
);
class
TestTask
extends
TaskBase
{
constructor
(){
super
(
TaskBase
.
getServiceName
(
TestTask
));
}
async
subBeforeTask
(
params
){
console
.
log
(
"前置操作......"
,
this
.
serviceName
);
}
async
subDoTask
(
params
){
console
.
log
(
params
);
console
.
log
(
"TestTask1....."
);
}
}
module
.
exports
=
TestTask
;
\ No newline at end of file
taskexecutor/app/base/utils/redisClient.js
View file @
1dcc9410
...
@@ -149,6 +149,9 @@ class RedisClient {
...
@@ -149,6 +149,9 @@ class RedisClient {
async
incr
(
key
)
{
async
incr
(
key
)
{
return
this
.
client
.
incrAsync
(
key
);
return
this
.
client
.
incrAsync
(
key
);
}
}
async
close
(){
this
.
client
.
quit
();
}
}
}
module
.
exports
=
RedisClient
;
module
.
exports
=
RedisClient
;
...
...
taskexecutor/app/base/utils/test.js
View file @
1dcc9410
var
excel
=
require
(
'exceljs'
);
//
var excel = require('exceljs');
async
function
readxls
(
path
)
{
//
async function readxls(path) {
var
promise
=
new
Promise
((
resv
,
rej
)
=>
{
//
var promise = new Promise((resv, rej) => {
var
workbook
=
new
excel
.
Workbook
();
//
var workbook = new excel.Workbook();
workbook
.
properties
.
date1904
=
true
;
//
workbook.properties.date1904 = true;
workbook
.
xlsx
.
readFile
(
path
)
//
workbook.xlsx.readFile(path)
.
then
(
function
()
{
//
.then(function () {
return
resv
(
workbook
);
//
return resv(workbook);
}).
catch
(
function
(
e
)
{
//
}).catch(function (e) {
return
rej
(
e
);
//
return rej(e);
});
//
});
});
//
});
return
promise
;
//
return promise;
}
//
}
(
async
()
=>
{
//
(async ()=>{
var
wb
=
await
readxls
(
"./GT.xlsx"
);
//
var wb= await readxls("./GT.xlsx");
var
sheet
=
wb
.
getWorksheet
(
1
);
//
var sheet = wb.getWorksheet(1);
sheet
.
eachRow
({
includeEmpty
:
true
},
function
(
row
,
rowNumber
)
{
//
sheet.eachRow({ includeEmpty: true }, function(row, rowNumber) {
if
(
rowNumber
>=
10
&&
rowNumber
<=
10
){
//
if(rowNumber>=10 && rowNumber<=10){
row
.
eachCell
({
includeEmpty
:
true
},
function
(
cell
,
colNumber
)
{
//
row.eachCell({ includeEmpty: true }, function(cell, colNumber) {
if
(
colNumber
==
28
){
//
if(colNumber==28){
var
sval
=
cell
.
value
?(
typeof
cell
.
value
==
"object"
?
cell
.
value
.
result
:
cell
.
value
):
"0"
;
//
var sval=cell.value?(typeof cell.value=="object"?cell.value.result:cell.value):"0";
console
.
log
(
sval
);
//
console.log(sval);
}
//
}
});
//
});
}
//
}
});
//
});
})()
//
})()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment