Commit c217a821 by 王悦

fix

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