|
@@ -269,15 +269,17 @@ module.exports = {
|
|
|
let params = JSON.parse(req.body.params),
|
|
|
prj_id = params.prj_id,
|
|
|
rpt_ids = params.rpt_ids.split(','),
|
|
|
+ pageSize = params.pageSize,
|
|
|
+ orientation = params.orientation,
|
|
|
customizeCfg = params.custCfg,
|
|
|
option = params.option;
|
|
|
let user_id = req.session.sessionUser.id;
|
|
|
- let parallelFucs = [];
|
|
|
+ let parallelFunctions = [];
|
|
|
let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
for (let id of rpt_ids) {
|
|
|
- parallelFucs.push((function (rpt_id) {
|
|
|
+ parallelFunctions.push((function (rpt_id) {
|
|
|
return function (cb) {
|
|
|
- getAllPagesCommon(user_id, prj_id, rpt_id, null, null, customizeCfg, dftOption, function (err, pageRst) {
|
|
|
+ getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, dftOption, function (err, pageRst) {
|
|
|
if(err){
|
|
|
cb(err);
|
|
|
}
|
|
@@ -288,7 +290,7 @@ module.exports = {
|
|
|
}
|
|
|
})(parseInt(id)));
|
|
|
}
|
|
|
- async.parallel(parallelFucs, function (err, pageRstArray) {
|
|
|
+ async.parallel(parallelFunctions, function (err, pageRstArray) {
|
|
|
if (err) {
|
|
|
callback(req, res, '数据有误', null);
|
|
|
} else {
|
|
@@ -312,14 +314,107 @@ module.exports = {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- getTestReportAllPages: function(req, res){
|
|
|
- let rpt_id = req.body.ID;
|
|
|
- let pageSize = req.body.pageSize;
|
|
|
- getAllPagesCommonOrg(rpt_id, pageSize, JV.PAGING_OPTION_NORMAL, function(err, pageRst){
|
|
|
- //fs.writeFileSync('D:/GitHome/ConstructionOperation/tmp/testRpt.js', JSON.stringify(pageRst));
|
|
|
- callback(req, res, err, pageRst);
|
|
|
+ createExcelFilesInOneBook: function (req, res) {
|
|
|
+ let params = JSON.parse(req.body.params),
|
|
|
+ prj_id = params.prj_id,
|
|
|
+ rpt_ids = params.rpt_ids,
|
|
|
+ rptName = params.rptName,
|
|
|
+ pageSize = params.pageSize,
|
|
|
+ orientation = params.orientation,
|
|
|
+ customizeCfg = params.custCfg,
|
|
|
+ option = params.option;
|
|
|
+ let user_id = req.session.sessionUser.id;
|
|
|
+ let parallelFunctions = [];
|
|
|
+ let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
+ for (let idx = 0; idx < rpt_ids.length; idx++) {
|
|
|
+ let r_id = rpt_ids[idx];
|
|
|
+ parallelFunctions.push((function (rpt_id) {
|
|
|
+ return function (cb) {
|
|
|
+ getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, dftOption, function (err, pageRst) {
|
|
|
+ if(err){
|
|
|
+ cb(err);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ cb(err, pageRst);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })(parseInt(r_id)));
|
|
|
+ }
|
|
|
+ async.parallel(parallelFunctions, function (err, pageRstArray) {
|
|
|
+ if (err) {
|
|
|
+ callback(req, res, '数据有误', null);
|
|
|
+ } else {
|
|
|
+ rpt_xl_util.exportExcelInOneBook(pageRstArray, pageSize, rptName, function(uuidName){
|
|
|
+ let fileRst = {uuid: uuidName, reportName: rptName};
|
|
|
+ callback(req, res, err, fileRst);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ createExcelFiles: function (req, res) {
|
|
|
+ let params = JSON.parse(req.body.params),
|
|
|
+ prj_id = params.prj_id,
|
|
|
+ rpt_ids = params.rpt_ids,
|
|
|
+ rpt_names = params.rpt_names,
|
|
|
+ pageSize = params.pageSize,
|
|
|
+ orientation = params.orientation,
|
|
|
+ isOneSheet = params.isOneSheet,
|
|
|
+ customizeCfg = params.custCfg,
|
|
|
+ option = params.option;
|
|
|
+ let user_id = req.session.sessionUser.id;
|
|
|
+ let parallelFunctions = [];
|
|
|
+ let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
+ for (let idx = 0; idx < rpt_ids.length; idx++) {
|
|
|
+ let r_id = rpt_ids[idx];
|
|
|
+ let r_name = rpt_names[idx];
|
|
|
+ parallelFunctions.push((function (rpt_id, rpt_name) {
|
|
|
+ return function (cb) {
|
|
|
+ getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, dftOption, function (err, pageRst) {
|
|
|
+ if(err){
|
|
|
+ cb(err);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ rpt_xl_util.exportExcel(pageRst, pageSize, rpt_name, isOneSheet, null, null, function(uuidName){
|
|
|
+ let fileRst = {uuid: uuidName, reportName: rpt_name};
|
|
|
+ cb(err, fileRst);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })(parseInt(r_id), r_name));
|
|
|
+ }
|
|
|
+ async.parallel(parallelFunctions, function (err, fileRstArray) {
|
|
|
+ if (err) {
|
|
|
+ callback(req, res, '数据有误', null);
|
|
|
+ } else {
|
|
|
+ // console.log(err);
|
|
|
+ callback(req, res, err, fileRstArray);
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
+ getFileByUUID: function (req, res) {
|
|
|
+ let uuid = req.params.uuid,
|
|
|
+ rptName = req.params.rptName,
|
|
|
+ suffix = "." + req.params.suffix
|
|
|
+ ;
|
|
|
+ // let user_id = req.session.sessionUser.id; //未来要校验user id
|
|
|
+ try {
|
|
|
+ res.setHeader('Content-Type', 'application/vnd.openxmlformats');
|
|
|
+ let rptNameURI = encodeURI(rptName);
|
|
|
+ res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + suffix + "\"; filename*=utf-8''" + rptNameURI + suffix );
|
|
|
+ let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + uuid + suffix);
|
|
|
+ filestream.on('data', function(chunk) {
|
|
|
+ res.write(chunk);
|
|
|
+ });
|
|
|
+ filestream.on('end', function() {
|
|
|
+ res.end();
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ },
|
|
|
getExcel: function(req, res) {
|
|
|
let prj_id = req.params.prj_id,
|
|
|
rpt_id = req.params.rpt_id,
|
|
@@ -327,16 +422,18 @@ module.exports = {
|
|
|
orientation = req.params.orientation,
|
|
|
rptName = req.params.rptName,
|
|
|
isOneSheet = req.params.isOneSheet,
|
|
|
- option = req.params.option;
|
|
|
+ option = req.params.option
|
|
|
+ ;
|
|
|
+ let customizeCfg = null;
|
|
|
let user_id = req.session.sessionUser.id;
|
|
|
let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
- getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, null, dftOption, function(err, pageRst){
|
|
|
+ getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, dftOption, function(err, pageRst){
|
|
|
try {
|
|
|
- rpt_xl_util.exportExcel(pageRst, pageSize, rptName, isOneSheet, null, null, function(newName){
|
|
|
+ rpt_xl_util.exportExcel(pageRst, pageSize, rptName, isOneSheet, null, null, function(uuidName){
|
|
|
res.setHeader('Content-Type', 'application/vnd.openxmlformats');
|
|
|
let rptNameURI = encodeURI(rptName);
|
|
|
res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".xlsx\"; filename*=utf-8''" + rptNameURI + '.xlsx' );
|
|
|
- let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + newName + '.xlsx');
|
|
|
+ let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + uuidName + '.xlsx');
|
|
|
filestream.on('data', function(chunk) {
|
|
|
res.write(chunk);
|
|
|
});
|
|
@@ -356,10 +453,10 @@ module.exports = {
|
|
|
rptName = req.params.rptName,
|
|
|
option = req.params.option;
|
|
|
let user_id = req.session.sessionUser.id;
|
|
|
- let parallelFucs = [];
|
|
|
+ let parallelFunctions = [];
|
|
|
let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
for (let id of rpt_ids) {
|
|
|
- parallelFucs.push((function (rpt_id) {
|
|
|
+ parallelFunctions.push((function (rpt_id) {
|
|
|
return function (cb) {
|
|
|
getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, null, null, dftOption, function (err, pageRst) {
|
|
|
if(err){
|
|
@@ -372,7 +469,7 @@ module.exports = {
|
|
|
}
|
|
|
})(parseInt(id)));
|
|
|
}
|
|
|
- async.parallel(parallelFucs, function (err, pageRstArray) {
|
|
|
+ async.parallel(parallelFunctions, function (err, pageRstArray) {
|
|
|
if (err) {
|
|
|
callback(req, res, '数据有误', null);
|
|
|
} else {
|
|
@@ -391,6 +488,82 @@ module.exports = {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ createPdfFiles: function (req, res) {
|
|
|
+ let params = JSON.parse(req.body.params),
|
|
|
+ prj_id = params.prj_id,
|
|
|
+ rpt_ids = params.rpt_ids,
|
|
|
+ rpt_names = params.rpt_names,
|
|
|
+ pageSize = params.pageSize,
|
|
|
+ orientation = params.orientation,
|
|
|
+ customizeCfg = params.custCfg,
|
|
|
+ option = params.option;
|
|
|
+ let user_id = req.session.sessionUser.id;
|
|
|
+ let parallelFunctions = [];
|
|
|
+ let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
+ for (let idx = 0; idx < rpt_ids.length; idx++) {
|
|
|
+ let r_id = rpt_ids[idx];
|
|
|
+ let r_name = rpt_names[idx];
|
|
|
+ parallelFunctions.push((function (rpt_id, rpt_name) {
|
|
|
+ return function (cb) {
|
|
|
+ getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, dftOption, function (err, pageRst) {
|
|
|
+ if(err){
|
|
|
+ cb(err);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ rpt_pdf_util.export_pdf_file(pageRst, pageSize, rpt_name, function(uuidName){
|
|
|
+ let fileRst = {uuid: uuidName, reportName: rpt_name};
|
|
|
+ cb(err, fileRst);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })(parseInt(r_id), r_name));
|
|
|
+ }
|
|
|
+ async.parallel(parallelFunctions, function (err, fileRstArray) {
|
|
|
+ if (err) {
|
|
|
+ callback(req, res, '数据有误', null);
|
|
|
+ } else {
|
|
|
+ // console.log(err);
|
|
|
+ callback(req, res, err, fileRstArray);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getPDF:function (req, res) {
|
|
|
+ let prj_id = req.params.prj_id,
|
|
|
+ rpt_id = req.params.rpt_id,
|
|
|
+ pageSize = req.params.size,
|
|
|
+ orientation = req.params.orientation,
|
|
|
+ rptName = req.params.rptName
|
|
|
+ ;
|
|
|
+ let user_id = req.session.sessionUser.id;
|
|
|
+ getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, null, JV.PAGING_OPTION_NORMAL, function(err, pageRst){
|
|
|
+ rpt_pdf_util.export_pdf_file(pageRst, pageSize, rptName,function (uuidName) {
|
|
|
+ res.setHeader('Content-Type', 'application/vnd.openxmlformats');
|
|
|
+ // res.setHeader("Content-Disposition", "attachment; filename=" + strUtil.getPinYinCamelChars(rptName) + ".pdf");
|
|
|
+ let rptNameURI = encodeURI(rptName);
|
|
|
+ res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".pdf\"; filename*=utf-8''" + rptNameURI + ".pdf" );
|
|
|
+
|
|
|
+ let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + uuidName + '.pdf');
|
|
|
+ filestream.on('data', function(chunk) {
|
|
|
+ res.write(chunk);
|
|
|
+ });
|
|
|
+ filestream.on('end', function() {
|
|
|
+ res.end();
|
|
|
+ });
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ getTestReportAllPages: function(req, res){
|
|
|
+ let rpt_id = req.body.ID;
|
|
|
+ let pageSize = req.body.pageSize;
|
|
|
+ getAllPagesCommonOrg(rpt_id, pageSize, JV.PAGING_OPTION_NORMAL, function(err, pageRst){
|
|
|
+ //fs.writeFileSync('D:/GitHome/ConstructionOperation/tmp/testRpt.js', JSON.stringify(pageRst));
|
|
|
+ callback(req, res, err, pageRst);
|
|
|
+ })
|
|
|
+ },
|
|
|
getTestExcel: function(req, res) {
|
|
|
let rpt_id = req.params.id,
|
|
|
pageSize = req.params.size,
|
|
@@ -401,10 +574,10 @@ module.exports = {
|
|
|
getAllPagesCommonOrg(rpt_id, pageSize, dftOption, function(err, pageRst){
|
|
|
fs.writeFileSync('D:/GitHome/ConstructionOperation/tmp/testRpt.js', JSON.stringify(pageRst));
|
|
|
try {
|
|
|
- rpt_xl_util.exportExcel(pageRst, pageSize, rptName, isOneSheet, null, null, function(newName){
|
|
|
+ rpt_xl_util.exportExcel(pageRst, pageSize, rptName, isOneSheet, null, null, function(uuidName){
|
|
|
res.setHeader('Content-Type', 'application/vnd.openxmlformats');
|
|
|
res.setHeader("Content-Disposition", "attachment; filename=" + strUtil.getPinYinCamelChars(rptName) + ".xlsx");
|
|
|
- let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + newName + '.xlsx');
|
|
|
+ let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + uuidName + '.xlsx');
|
|
|
filestream.on('data', function(chunk) {
|
|
|
res.write(chunk);
|
|
|
});
|
|
@@ -422,10 +595,10 @@ module.exports = {
|
|
|
pageSize = req.params.size,
|
|
|
rptName = req.params.rptName,
|
|
|
option = req.params.option;
|
|
|
- let parallelFucs = [];
|
|
|
+ let parallelFunctions = [];
|
|
|
let dftOption = option||JV.PAGING_OPTION_NORMAL;
|
|
|
for (let id of rpt_ids) {
|
|
|
- parallelFucs.push((function (rpt_id) {
|
|
|
+ parallelFunctions.push((function (rpt_id) {
|
|
|
return function (cb) {
|
|
|
getAllPagesCommonOrg(rpt_id, pageSize, dftOption, function (err, pageRst) {
|
|
|
if(err){
|
|
@@ -438,7 +611,7 @@ module.exports = {
|
|
|
}
|
|
|
})(parseInt(id)));
|
|
|
}
|
|
|
- async.parallel(parallelFucs, function (err, pageRstArray) {
|
|
|
+ async.parallel(parallelFunctions, function (err, pageRstArray) {
|
|
|
if (err) {
|
|
|
callback(req, res, '数据有误', null);
|
|
|
} else {
|
|
@@ -457,46 +630,19 @@ module.exports = {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- getPDF:function (req, res) {
|
|
|
- let prj_id = req.params.prj_id,
|
|
|
- rpt_id = req.params.rpt_id,
|
|
|
- pageSize = req.params.size,
|
|
|
- orientation = req.params.orientation,
|
|
|
- rptName = req.params.rptName
|
|
|
- ;
|
|
|
- let user_id = req.session.sessionUser.id;
|
|
|
- getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, null, JV.PAGING_OPTION_NORMAL, function(err, pageRst){
|
|
|
- rpt_pdf_util.export_pdf_file(pageRst, pageSize, rptName,function (newName) {
|
|
|
- res.setHeader('Content-Type', 'application/vnd.openxmlformats');
|
|
|
- // res.setHeader("Content-Disposition", "attachment; filename=" + strUtil.getPinYinCamelChars(rptName) + ".pdf");
|
|
|
- let rptNameURI = encodeURI(rptName);
|
|
|
- res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".pdf\"; filename*=utf-8''" + rptNameURI + ".pdf" );
|
|
|
-
|
|
|
- let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + newName + '.pdf');
|
|
|
- filestream.on('data', function(chunk) {
|
|
|
- res.write(chunk);
|
|
|
- });
|
|
|
- filestream.on('end', function() {
|
|
|
- res.end();
|
|
|
- });
|
|
|
- })
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- },
|
|
|
getTestPDF:function (req, res) {
|
|
|
let rpt_id = req.params.id,
|
|
|
pageSize = req.params.size,
|
|
|
rptName = req.params.rptName;
|
|
|
|
|
|
getAllPagesCommonOrg(rpt_id, pageSize, JV.PAGING_OPTION_NORMAL, function(err, pageRst){
|
|
|
- rpt_pdf_util.export_pdf_file(pageRst, pageSize, rptName,function (newName) {
|
|
|
+ rpt_pdf_util.export_pdf_file(pageRst, pageSize, rptName,function (uuidName) {
|
|
|
res.setHeader('Content-Type', 'application/vnd.openxmlformats');
|
|
|
// res.setHeader("Content-Disposition", "attachment; filename=" + strUtil.getPinYinCamelChars(rptName) + ".pdf");
|
|
|
let rptNameURI = encodeURI(rptName);
|
|
|
res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".pdf\"; filename*=utf-8''" + rptNameURI + ".pdf" );
|
|
|
|
|
|
- let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + newName + '.pdf');
|
|
|
+ let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + uuidName + '.pdf');
|
|
|
filestream.on('data', function(chunk) {
|
|
|
res.write(chunk);
|
|
|
});
|