|
@@ -626,37 +626,46 @@ module.exports = app => {
|
|
|
);
|
|
|
});
|
|
|
}
|
|
|
- const pageRst = JSON.parse(fs.readFileSync('D:/GitHome/temp/计量excel原始数据_A3BZ6_5384_112表(清单).js', 'utf-8'));
|
|
|
- const runnableRst = [];
|
|
|
-
|
|
|
- const pageBrkSize = 6291456; // 6M, 1024*1024*6
|
|
|
- // const pageBrkSize = 1048576; // 1M, 1024*1024*1
|
|
|
- const picSize = await _chkRawPicSize(pageRst, baseDir);
|
|
|
- if (picSize > pageBrkSize) {
|
|
|
- let pageBrkAmt = Math.floor(pageRst.items.length / Math.ceil(picSize / pageBrkSize));
|
|
|
- console.log('pageBrkAmt:' + pageBrkAmt);
|
|
|
- if (pageBrkAmt < 10) {
|
|
|
- // 不用管
|
|
|
- } else if (pageBrkAmt < 100) {
|
|
|
- pageBrkAmt = Math.floor(pageBrkAmt / 10) * 10;
|
|
|
- } else if (pageBrkAmt < 1000) {
|
|
|
- pageBrkAmt = Math.floor(pageBrkAmt / 100) * 100;
|
|
|
+ try {
|
|
|
+ console.log('start:');
|
|
|
+ const pageRst = JSON.parse(fs.readFileSync('D:/GitHome/temp/计量excel原始数据_A3BZ6_5384_112表(清单).js', 'utf-8'));
|
|
|
+ console.log('read it');
|
|
|
+ const runnableRst = [];
|
|
|
+
|
|
|
+ const pageBrkSize = 6291456; // 6M, 1024*1024*6
|
|
|
+ // const pageBrkSize = 1048576; // 1M, 1024*1024*1
|
|
|
+ console.log('pageBrkSize:' + pageBrkSize);
|
|
|
+ const picSize = await _chkRawPicSize(pageRst, baseDir);
|
|
|
+ console.log('picSize:' + picSize);
|
|
|
+ if (picSize > pageBrkSize) {
|
|
|
+ let pageBrkAmt = Math.floor(pageRst.items.length / Math.ceil(picSize / pageBrkSize));
|
|
|
+ console.log('pageBrkAmt:' + pageBrkAmt);
|
|
|
+ if (pageBrkAmt < 10) {
|
|
|
+ // 不用管
|
|
|
+ } else if (pageBrkAmt < 100) {
|
|
|
+ pageBrkAmt = Math.floor(pageBrkAmt / 10) * 10;
|
|
|
+ } else if (pageBrkAmt < 1000) {
|
|
|
+ pageBrkAmt = Math.floor(pageBrkAmt / 100) * 100;
|
|
|
+ } else {
|
|
|
+ // 暂时不管
|
|
|
+ }
|
|
|
+ const newRptNames = []; // 这个为导出控制分页用
|
|
|
+ const newPageDataRst = _resetPageDataByBreaks([pageRst], pageBrkAmt, ['工程计量表(计量单元-清单)'], newRptNames);
|
|
|
+ for (let dtlIdx = 0; dtlIdx < newPageDataRst.length; dtlIdx++) {
|
|
|
+ runnableRst.push(getExcelByPageData(newPageDataRst[dtlIdx], newRptNames[dtlIdx], null));
|
|
|
+ }
|
|
|
} else {
|
|
|
- // 暂时不管
|
|
|
+ runnableRst.push(getExcelByPageData(pageRst, '工程计量表(计量单元-清单)', null));
|
|
|
}
|
|
|
- const newRptNames = []; // 这个为导出控制分页用
|
|
|
- const newPageDataRst = _resetPageDataByBreaks([pageRst], pageBrkAmt, ['工程计量表(计量单元-清单)'], newRptNames);
|
|
|
- for (let dtlIdx = 0; dtlIdx < newPageDataRst.length; dtlIdx++) {
|
|
|
- runnableRst.push(getExcelByPageData(newPageDataRst[dtlIdx], newRptNames[dtlIdx], null));
|
|
|
- }
|
|
|
- } else {
|
|
|
- runnableRst.push(getExcelByPageData(pageRst, '工程计量表(计量单元-清单)', null));
|
|
|
- }
|
|
|
|
|
|
|
|
|
- const uuidRst = await Promise.all(runnableRst);
|
|
|
- ctx.body = { data: uuidRst, waterMarkStr: null };
|
|
|
- ctx.status = 201;
|
|
|
+ const uuidRst = await Promise.all(runnableRst);
|
|
|
+ ctx.body = { data: uuidRst, waterMarkStr: null };
|
|
|
+ ctx.status = 201;
|
|
|
+ } catch (ex) {
|
|
|
+ console.log(ex.toString());
|
|
|
+ ctx.status = 500;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async createExcelFilesInOneBookEx(ctx) {
|
|
@@ -1482,9 +1491,17 @@ async function _chkRawPicSize(pageData, baseDir) {
|
|
|
// signature_cells PROP_SIGNATURE_CELLS
|
|
|
}
|
|
|
}
|
|
|
+ // console.log(picKeys);
|
|
|
for (const pKey of picKeys) {
|
|
|
const filePath = `${baseDir}/app${pKey}`;
|
|
|
- const isExist = await isFileExisted(filePath);
|
|
|
+ console.log('filePath: ' + filePath);
|
|
|
+ let isExist = false;
|
|
|
+ try {
|
|
|
+ isExist = await isFileExisted(filePath);
|
|
|
+ } catch (ex) {
|
|
|
+ isExist = false;
|
|
|
+ }
|
|
|
+ console.log('isExist: ' + isExist);
|
|
|
if (isExist) {
|
|
|
const obj = fs.statSync(filePath);
|
|
|
if (obj) {
|