Commit 9bb97721 by 蒋勇

d

parent 9e723c32
......@@ -65,6 +65,10 @@ class RptAPI extends APIBase{
var x=await this.rptService.saveRpt(pobj);
return system.getResult(x);
}
async saveRptHistory(pobj,query){
var x=await this.rptService.saveRptHistory(pobj);
return system.getResult(x);
}
exam(){
return "xxx";
}
......
......@@ -6,6 +6,33 @@ class RptTypeService extends ServiceBase{
super("auth",ServiceBase.getDaoName(RptTypeService));
this.redisClient=system.getObject("util.redisClient");
}
async saveRptHistory(hs){
var self=this;
return this.db.transaction(async t=>{
var hisarray=[];
var batchid=hs.batchid;
var batch=await this.db.models.uploadbatch.findById(batchid);
var hisdata=hs.hisdata;
var rptdate=hs.rptdate;
var rptcode=hs.rptcode;
hisdata.forEach(hd=>{
var h={
companycode:batch.companycode,
companyname:batch.companyname,
timetypecode:batch.timetypecode,
batchdate:batch.batchdate,
dateym:rptdate,
rpttypecode:rptcode,
position:hd.position,
valstr:hd.valstr,
desc:hd.desc
};
hisarray.push(h);
});
self.db.rpthistory.bulkCreate(hisarray,{transaction:t});
return {};
});
}
async saveRpt(upinfo){
return this.db.transaction(async t=>{
//构建批量对象
......@@ -55,7 +82,7 @@ class RptTypeService extends ServiceBase{
await this.db.models.uploadrpt.bulkCreate(rpts,{transaction:t});
try{
rpts.forEach((rpt)=>{
await this.redisClient.notifyConsume("k8stask","docurls",rpt.rpttypecode+"~"+rpt.urlpath);
await this.redisClient.notifyConsume("k8stask","docurls",rpt.rptdate+"~"+rpt.rpttypecode+"~"+rpt.urlpath);
});
}catch(e){
//需要记录要清理的批号历史数据
......
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