Commit e7246859 by 蒋勇

d

parent 6e78db5d
......@@ -14,7 +14,8 @@ class APIBase extends DocBase {
var lst = [
"rpt.saveRptHistory",
"rpt.saveRpt",
"rpt.queryStatus"
"rpt.queryStatus",
"rpt.queryReport"
];
var x = lst.indexOf(fullname);
return x >= 0;
......
......@@ -75,6 +75,18 @@ class RptAPI extends APIBase{
var x=await this.rptService.queryStatus(pobj);
return system.getResult(x);
}
async queryReport(pobj,query){
console.log(JSON.stringify(pobj));
if(pobj){
var x=await this.rptService.queryReport(pobj.batchid);
return system.getResult(x);
}else{
return system.getResult(null);
}
}
exam(){
return "xxx";
}
......
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("result", {
BatchNo: {
type:DataTypes.INTEGER,
allowNull: false,
},
indexName: {
type:DataTypes.STRING,
allowNull: false,
},
status: {
type:DataTypes.INTEGER,
allowNull: false,
}
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'result_set',
validate: {
},
indexes:[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
......@@ -55,6 +55,16 @@ class RptTypeService extends ServiceBase{
}
}});
}
async queryReport(batchid){
var rs=await this.db.models.result.findAll({where:{"BatchNo":batchid},attributes:["indexName","status"],raw:true});
var tmp={};
rs.forEach((item=>{
tmp[item.indexName]=Number(item.status);
}));
var rptdata=await this.apiCallWithoutAk("http://123.57.217.203:30001/gsb/api/report",tmp);
return rptdata;
}
async saveRpt(upinfo){
return this.db.transaction(async t=>{
//构建批量对象
......
......@@ -27,6 +27,12 @@ class ServiceBase {
}
return null;
}
async apiCallWithoutAk(url,params){
var acck="noak";
//按照访问token
var restResult=await this.restS.execPostWithAK(params,url,acck);
return restResult;
}
async apiCallWithAkNoWait(url,params){
var acckapp=await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey);
var acck=acckapp.accessKey;
......
......@@ -105,6 +105,7 @@ class RestClient{
}
async execPostWithAK(subData, url,ak){
let cmd=this.FetchPostCmdWithAK(subData,url,ak);
console.log(cmd);
var result=await this.exec(cmd,{
maxBuffer:1024*1024*15
});
......
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