Commit 1dcc9410 by 蒋勇

d

parent 2bc45de5
...@@ -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);
......
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
...@@ -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;
......
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);
} // }
}); // });
} // }
}); // });
})() // })()
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