Commit 2874a4ca by 蒋勇

d

parent aa1372b4
......@@ -12,7 +12,8 @@ class APIBase extends DocBase {
async isExistInNoAuthMainfest(gname, methodname) {
var fullname = gname + "." + methodname;
var lst = [
"rpt.saveRptHistory"
"rpt.saveRptHistory",
"rpt.saveRpt"
];
var x = lst.indexOf(fullname);
return x >= 0;
......
......@@ -62,13 +62,11 @@ class RptAPI extends APIBase{
]
}*/
async saveRpt(pobj,query){
var x=await this.rptService.saveRpt(pobj);
return system.getResult(x);
}
async saveRptHistory(pobj,query){
console.log(JSON.stringify(pobj));
return {};
var x=await this.rptService.saveRptHistory(pobj);
return system.getResult(x);
}
......
......@@ -10,6 +10,7 @@ class RptTypeService extends ServiceBase{
var self=this;
return this.db.transaction(async t=>{
var hisarray=[];
var rptid=hs.rptid;
var batchid=hs.batchid;
var batch=await this.db.models.uploadbatch.findById(batchid);
var hisdata=hs.hisdata;
......@@ -25,11 +26,12 @@ class RptTypeService extends ServiceBase{
rpttypecode:rptcode,
position:hd.position,
valstr:hd.valstr,
desc:hd.desc
desc:hd.desc,
uploadrpt_id:rptid
};
hisarray.push(h);
});
self.db.rpthistory.bulkCreate(hisarray,{transaction:t});
await self.db.models.rpthistory.bulkCreate(hisarray,{transaction:t});
return {};
});
}
......@@ -47,8 +49,8 @@ class RptTypeService extends ServiceBase{
var batchobj={
batchdate:upinfo.date,
companyname:upinfo.companyName,
companyCode:upinfo.companyTaxNum,
name:companyname+"_"+upinfo.date+"_"+upinfo.accountingType,
companycode:upinfo.companyTaxNum,
name:upinfo.companyName+"_"+upinfo.date+"_"+upinfo.accountingType,
batchstatuscode:"parserpt",
taxtypecode:upinfo.valueAddedTax,
timetypecode:upinfo.dateType,
......@@ -57,7 +59,7 @@ class RptTypeService extends ServiceBase{
}
//保存批量
var batchtemp=await this.db.models.uploadbatch.create(batchobj,{transaction:t});
var rpts=[];
var rptresult=[];
Object.keys(upinfo).forEach(k=>{
{
if(k.indexOf("Report")>=0){
......@@ -65,7 +67,7 @@ class RptTypeService extends ServiceBase{
rpts.forEach(rpt=>{
var rptupload={
companyname:upinfo.companyName,
companyCode:upinfo.companyTaxNum,
companycode:upinfo.companyTaxNum,
rpttypecode:rpt.code,
timetypecode:upinfo.dateType,
urlpath:rpt.url,
......@@ -73,16 +75,18 @@ class RptTypeService extends ServiceBase{
company_id:comp.id,
uploadbatch_id:batchtemp.id,
}
rpts.push(rptupload);
rptresult.push(rptupload);
});
}
}
});
//保存报表
await this.db.models.uploadrpt.bulkCreate(rpts,{transaction:t});
await this.db.models.uploadrpt.bulkCreate(rptresult,{transaction:t});
var lstspts=await this.db.models.uploadrpt.findAll({where:{uploadbatch_id:batchtemp.id},transaction:t});
try{
rpts.forEach(async (rpt)=>{
await this.redisClient.notifyConsume("k8stask","docurls",batchtemp.id+"~"+rpt.rptdate+"~"+rpt.rpttypecode+"~"+rpt.urlpath);
lstspts.forEach(async (rpt)=>{
await this.redisClient.notifyConsume("k8stask","docurls",rpt.id+"~"+batchtemp.id+"~"+rpt.rptdate+"~"+rpt.rpttypecode+"~"+rpt.urlpath);
});
}catch(e){
//需要记录要清理的批号历史数据
......
......@@ -125,6 +125,11 @@ class RedisClient {
console.log(channel + ":" + msg);
return this.client.publishAsync(channel, msg);
}
async notifyConsume(channel, consumetarget,val) {
await this.client.rpush(consumetarget,val);
console.log("publish--"+channel + ":" + consumetarget);
return this.client.publishAsync(channel, consumetarget);
}
async rpush(key, val) {
return this.client.rpushAsync(key, val);
}
......
......@@ -3,7 +3,7 @@ var settings={
host: "43.247.184.32",
port: 8967,
password: "Gongsibao2018",
db: 9,
db: 11,
},
database: {
dbname: "fktaxctl",
......
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