Commit c217a821 by 王悦

fix

parent 7ebe8a19
...@@ -188,9 +188,8 @@ class TrademarkCtl extends CtlBase { ...@@ -188,9 +188,8 @@ class TrademarkCtl extends CtlBase {
uploadid = q.upload_id; uploadid = q.upload_id;
body.upload_id = uploadid; body.upload_id = uploadid;
} }
let rtn = await this.execClient.execPost(body, pushurl); let rtn = await this.execClient.request("POST",pushurl,body);
console.log("=====================>批量发布返回", rtn); let data = rtn.body
let data = JSON.parse(rtn.stdout);
if (data.status == 1) { if (data.status == 1) {
let tradedb = []; let tradedb = [];
this.notify({ this.notify({
...@@ -258,7 +257,6 @@ class TrademarkCtl extends CtlBase { ...@@ -258,7 +257,6 @@ class TrademarkCtl extends CtlBase {
} }
upload.total = data.length; upload.total = data.length;
await upload.save(); await upload.save();
let pros = []
for (let i = 0; i < data.length; i += 20) { for (let i = 0; i < data.length; i += 20) {
let item = data.slice(i, i + 20); let item = data.slice(i, i + 20);
item.forEach(e => { item.forEach(e => {
...@@ -272,9 +270,8 @@ class TrademarkCtl extends CtlBase { ...@@ -272,9 +270,8 @@ class TrademarkCtl extends CtlBase {
pushd.userid = p.actionBody.userid; pushd.userid = p.actionBody.userid;
pushd.company_id = p.actionBody.company_id; pushd.company_id = p.actionBody.company_id;
pushd.channel_name = p.actionBody.channel_name; pushd.channel_name = p.actionBody.channel_name;
pros.push(this.publish(pushd, {upload_id: uploadid})) await this.publish(pushd, {upload_id: uploadid})
} }
await Promise.all(pros)
return { return {
status: 1, status: 1,
msg: "ok" msg: "ok"
......
...@@ -2,6 +2,8 @@ var childproc = require('child_process'); ...@@ -2,6 +2,8 @@ var childproc = require('child_process');
const util = require('util'); const util = require('util');
const exec = util.promisify(require('child_process').exec); const exec = util.promisify(require('child_process').exec);
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
const request = require('request');
const querystring = require('querystring');
class ExecClient { class ExecClient {
constructor() { constructor() {
this.cmdPostPattern = "curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}"; this.cmdPostPattern = "curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}";
...@@ -22,7 +24,23 @@ class ExecClient { ...@@ -22,7 +24,23 @@ class ExecClient {
}); });
return {stdout, stderr}; return {stdout, stderr};
} }
async request(method, url, data){
return new Promise((resolve, reject) => {
request({
url: url + (method.toUpperCase() === "GET" ? "?" + querystring.stringify(data) : ""),
method: method,
json: true,
body: method.toUpperCase() === "POST" ? data : "",
}, function (error, response, body) {
if (error)
reject(error);
else if (response.statusCode !== 200)
reject(body);
else
resolve(response);
});
})
}
async exec2(cmd) { async exec2(cmd) {
return exec(cmd, {encoding: "base64"}); return exec(cmd, {encoding: "base64"});
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@alicloud/pop-core": "^1.7.7", "@alicloud/pop-core": "^1.7.7",
"md5": "^2.3.0",
"after": "^0.8.2", "after": "^0.8.2",
"ali-oss": "^4.12.2", "ali-oss": "^4.12.2",
"amqplib": "^0.8.0", "amqplib": "^0.8.0",
...@@ -39,6 +38,7 @@ ...@@ -39,6 +38,7 @@
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"log4js": "^2.11.0", "log4js": "^2.11.0",
"marked": "^1.1.1", "marked": "^1.1.1",
"md5": "^2.3.0",
"method-override": "^2.3.10", "method-override": "^2.3.10",
"moment": "^2.26.0", "moment": "^2.26.0",
"morgan": "^1.9.0", "morgan": "^1.9.0",
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
"pdfcrowd": "^4.2.0", "pdfcrowd": "^4.2.0",
"pinyin": "^2.8.3", "pinyin": "^2.8.3",
"qr-image": "^3.2.0", "qr-image": "^3.2.0",
"request": "^2.88.2",
"sequelize": "^4.37.8", "sequelize": "^4.37.8",
"sequelize-cli": "^4.1.1", "sequelize-cli": "^4.1.1",
"serve-favicon": "^2.4.5", "serve-favicon": "^2.4.5",
......
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