Commit 2874a4ca by 蒋勇

d

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