Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / components / export / xlsx.js
index 92d1656..e7bab91 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x05be=['push','%s\x20limit\x20%d\x20OFFSET\x20%d','SELECT','dirname','basename','.xlsx','existsSync','join','each','%s%d.%s','xlsx','binary','zip','info','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','Completed','%s.%s','catch','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','inspect','Failed','finally','util','lodash','json2xls','bluebird','zip-dir','rimraf','../../mysqldb','../../config/logger','analytics','argv','savename','AnalyticExtractedReport','format','XLSX','Setting','find','split','splitSizeXlsx','then','sequelize','query','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','QueryTypes','num','length'];(function(_0x8e8597,_0x4d3ff3){var _0x20d704=function(_0x2dad62){while(--_0x2dad62){_0x8e8597['push'](_0x8e8597['shift']());}};_0x20d704(++_0x4d3ff3);}(_0x05be,0xa3));var _0xe05b=function(_0x494595,_0x34c39a){_0x494595=_0x494595-0x0;var _0x4e0f78=_0x05be[_0x494595];return _0x4e0f78;};'use strict';var util=require(_0xe05b('0x0'));var path=require('path');var _=require(_0xe05b('0x1'));var fs=require('fs');var json2xls=require(_0xe05b('0x2'));var BPromise=require(_0xe05b('0x3'));var zipdir=require(_0xe05b('0x4'));var rimraf=require(_0xe05b('0x5'));var db=require('../../mysqldb')['db'];var dbH=require(_0xe05b('0x6'))['dbH'];var logger=require(_0xe05b('0x7'))(_0xe05b('0x8'));var EXTRACTED_REPORT_ID=Number(process[_0xe05b('0x9')][0x2]);var QUERY=process[_0xe05b('0x9')][0x3];var PATH=process[_0xe05b('0x9')][0x4];var EXIT_CODE=0x0;function analyticExtractedReport(_0x1edcc1,_0x33ad15){var _0x5b030c={'status':_0x1edcc1};var _0x1152bf={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x33ad15){_0x5b030c[_0xe05b('0xa')]=_0x33ad15;}return db[_0xe05b('0xb')]['update'](_0x5b030c,_0x1152bf);}function main(){var _0x2f8bfe=0x1388;var _0xbab4dd;logger['info'](util[_0xe05b('0xc')]('Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format',EXTRACTED_REPORT_ID,_0xe05b('0xd')));return db[_0xe05b('0xe')][_0xe05b('0xf')]({'where':{'id':0x1},'raw':!![],'attributes':['id',_0xe05b('0x10'),_0xe05b('0x11')]})[_0xe05b('0x12')](function(_0x2ea0ee){if(_0x2ea0ee){_0xbab4dd=_0x2ea0ee;_0x2f8bfe=_0xbab4dd[_0xe05b('0x11')]||0x1388;}})[_0xe05b('0x12')](function(){return dbH[_0xe05b('0x13')][_0xe05b('0x14')](util[_0xe05b('0xc')](_0xe05b('0x15'),QUERY),{'type':dbH[_0xe05b('0x13')][_0xe05b('0x16')]['SELECT']});})[_0xe05b('0x12')](function(_0x23717){if(!_0x23717[0x0][_0xe05b('0x17')]){return analyticExtractedReport('Empty');}var _0x33aaed=[];var _0x2291c3=0x0;var _0x1dc714=!![];if(_0xbab4dd[_0xe05b('0x10')]){if(_0x23717&&_0x23717[_0xe05b('0x18')]){var _0x3bd291=_0x23717[0x0][_0xe05b('0x17')]%(_0x2291c3+_0x2f8bfe);for(;_0x1dc714;_0x2291c3+=_0x2f8bfe,_0x3bd291=_0x23717[0x0]['num']%(_0x2291c3+_0x2f8bfe)){if(_0x3bd291==0x0||_0x3bd291==_0x23717[0x0]['num']){_0x1dc714=![];}_0x33aaed[_0xe05b('0x19')](dbH[_0xe05b('0x13')][_0xe05b('0x14')](util[_0xe05b('0xc')](_0xe05b('0x1a'),QUERY,_0x2f8bfe,_0x2291c3),{'type':dbH[_0xe05b('0x13')][_0xe05b('0x16')][_0xe05b('0x1b')]}));}}}else{_0x33aaed[_0xe05b('0x19')](dbH[_0xe05b('0x13')]['query'](QUERY,{'type':dbH[_0xe05b('0x13')][_0xe05b('0x16')]['SELECT']}));}var _0x30cac6=path[_0xe05b('0x1c')](PATH);var _0x465797=path[_0xe05b('0x1d')](PATH,_0xe05b('0x1e'));var _0x2cf6c2=_0xbab4dd[_0xe05b('0x10')]&&_0x33aaed[_0xe05b('0x18')]>0x1;var _0x1cf7a1=[];if(!fs[_0xe05b('0x1f')](path[_0xe05b('0x20')](_0x30cac6,_0x465797))&&_0x2cf6c2){fs['mkdirSync'](path[_0xe05b('0x20')](_0x30cac6,_0x465797));}return BPromise[_0xe05b('0x21')](_0x33aaed,function(_0x5729f0){_0x1cf7a1[_0xe05b('0x19')](_0x5729f0);})['then'](function(){for(var _0x3d9994=0x0;_0x3d9994<_0x1cf7a1[_0xe05b('0x18')];_0x3d9994+=0x1){var _0x5a3b5d;var _0x2b33c6=_0x1cf7a1[_0x3d9994];if(_0x2cf6c2){_0x5a3b5d=path[_0xe05b('0x20')](_0x30cac6,_0x465797,util[_0xe05b('0xc')](_0xe05b('0x22'),_0x465797,_0x3d9994,_0xe05b('0x23')));}else{_0x5a3b5d=path[_0xe05b('0x20')](_0x30cac6,util['format']('%s.%s',_0x465797,'xlsx'));}fs['writeFileSync'](_0x5a3b5d,json2xls(_0x2b33c6),_0xe05b('0x24'));}})[_0xe05b('0x12')](function(){if(_0x2cf6c2){zipdir(path[_0xe05b('0x20')](_0x30cac6,_0x465797),{'saveTo':path[_0xe05b('0x20')](_0x30cac6,util['format']('%s.%s',_0x465797,_0xe05b('0x25')))},function(_0x4fa072,_0xa8dacc){});rimraf(path['join'](_0x30cac6,_0x465797),function(){});}})[_0xe05b('0x12')](function(){logger[_0xe05b('0x26')](util[_0xe05b('0xc')](_0xe05b('0x27'),EXTRACTED_REPORT_ID,_0xe05b('0xd')));return analyticExtractedReport(_0xe05b('0x28'),_0x2cf6c2?util['format'](_0xe05b('0x29'),_0x465797,_0x2cf6c2?_0xe05b('0x25'):_0xe05b('0x23')):null);});})[_0xe05b('0x2a')](function(_0x45b6fa){logger['info'](util[_0xe05b('0xc')](_0xe05b('0x2b'),EXTRACTED_REPORT_ID,_0xe05b('0xd')),util[_0xe05b('0x2c')](_0x45b6fa,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport(_0xe05b('0x2d'));})[_0xe05b('0x2e')](function(){process['exit'](EXIT_CODE);});}main();
\ No newline at end of file
+var _0xbf17=['Failed','finally','exit','util','path','lodash','bluebird','zip-dir','rimraf','../../mysqldb','dbH','../../config/logger','analytics','argv','savename','AnalyticExtractedReport','update','info','format','find','splitSizeXlsx','then','query','sequelize','num','split','length','range','isInteger','forEach','push','QueryTypes','SELECT','%s\x20limit\x20%d\x20OFFSET\x20%d','.xlsx','existsSync','join','mkdirSync','each','%s%d.%s','%s.%s','writeFileSync','binary','zip','zip\x20finished','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','XLSX','Completed','catch','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','inspect'];(function(_0x46cd49,_0x5db390){var _0x44c67d=function(_0x4de579){while(--_0x4de579){_0x46cd49['push'](_0x46cd49['shift']());}};_0x44c67d(++_0x5db390);}(_0xbf17,0x69));var _0x7bf1=function(_0x28c132,_0x1f5027){_0x28c132=_0x28c132-0x0;var _0x12109d=_0xbf17[_0x28c132];return _0x12109d;};'use strict';var util=require(_0x7bf1('0x0'));var path=require(_0x7bf1('0x1'));var _=require(_0x7bf1('0x2'));var fs=require('fs');var json2xls=require('json2xls');var BPromise=require(_0x7bf1('0x3'));var zipdir=require(_0x7bf1('0x4'));var rimraf=require(_0x7bf1('0x5'));var db=require(_0x7bf1('0x6'))['db'];var dbH=require(_0x7bf1('0x6'))[_0x7bf1('0x7')];var logger=require(_0x7bf1('0x8'))(_0x7bf1('0x9'));var EXTRACTED_REPORT_ID=Number(process['argv'][0x2]);var QUERY=process['argv'][0x3];var PATH=process[_0x7bf1('0xa')][0x4];var EXIT_CODE=0x0;function analyticExtractedReport(_0x24080b,_0x49df0d){var _0x1b6d7a={'status':_0x24080b};var _0x8c3df4={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x49df0d){_0x1b6d7a[_0x7bf1('0xb')]=_0x49df0d;}return db[_0x7bf1('0xc')][_0x7bf1('0xd')](_0x1b6d7a,_0x8c3df4);}function main(){var _0x5d92df=0x1388;var _0x1dc744;logger[_0x7bf1('0xe')](util[_0x7bf1('0xf')]('Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format',EXTRACTED_REPORT_ID,'XLSX'));return db['Setting'][_0x7bf1('0x10')]({'where':{'id':0x1},'raw':!![],'attributes':['id','split','splitSizeXlsx']})['then'](function(_0xb398e9){if(_0xb398e9){_0x1dc744=_0xb398e9;_0x5d92df=_0x1dc744[_0x7bf1('0x11')]||0x1388;}})[_0x7bf1('0x12')](function(){return dbH['sequelize'][_0x7bf1('0x13')](util[_0x7bf1('0xf')]('SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t',QUERY),{'type':dbH[_0x7bf1('0x14')]['QueryTypes']['SELECT']});})['then'](function(_0x22abb6){if(!_0x22abb6[0x0][_0x7bf1('0x15')]){return analyticExtractedReport('Empty');}var _0x1b4874=[];var _0x330e7b=0x0;if(_0x1dc744[_0x7bf1('0x16')]){if(_0x22abb6&&_0x22abb6[_0x7bf1('0x17')]){var _0x17dc4a=_[_0x7bf1('0x18')](_0x22abb6[0x0][_0x7bf1('0x15')]/_0x5d92df);var _0x2d3d4d=Number[_0x7bf1('0x19')](_0x22abb6[0x0][_0x7bf1('0x15')]/_0x5d92df)?_0x22abb6[0x0][_0x7bf1('0x15')]%_0x5d92df:0x0;_0x17dc4a[_0x7bf1('0x1a')](function(_0x184eee){if(_0x184eee>0x0){_0x330e7b+=_0x5d92df;}_0x1b4874[_0x7bf1('0x1b')](dbH[_0x7bf1('0x14')][_0x7bf1('0x13')](util[_0x7bf1('0xf')]('%s\x20limit\x20%d\x20OFFSET\x20%d',QUERY,_0x5d92df,_0x330e7b),{'type':dbH[_0x7bf1('0x14')][_0x7bf1('0x1c')][_0x7bf1('0x1d')]}));});if(_0x2d3d4d>0x0){_0x330e7b+=_0x5d92df;_0x1b4874['push'](dbH[_0x7bf1('0x14')]['query'](util['format'](_0x7bf1('0x1e'),QUERY,_0x2d3d4d,_0x330e7b),{'type':dbH['sequelize'][_0x7bf1('0x1c')][_0x7bf1('0x1d')]}));}}}else{_0x1b4874[_0x7bf1('0x1b')](dbH[_0x7bf1('0x14')]['query'](QUERY,{'type':dbH['sequelize'][_0x7bf1('0x1c')]['SELECT']}));}var _0x11c229=path['dirname'](PATH);var _0x4be9e1=path['basename'](PATH,_0x7bf1('0x1f'));var _0x4b9978=_0x1dc744[_0x7bf1('0x16')]&&_0x1b4874[_0x7bf1('0x17')]>0x1;var _0x3597e5=[];if(!fs[_0x7bf1('0x20')](path[_0x7bf1('0x21')](_0x11c229,_0x4be9e1))&&_0x4b9978){fs[_0x7bf1('0x22')](path[_0x7bf1('0x21')](_0x11c229,_0x4be9e1));}return BPromise[_0x7bf1('0x23')](_0x1b4874,function(_0x7182b8){_0x3597e5[_0x7bf1('0x1b')](_0x7182b8);})[_0x7bf1('0x12')](function(){for(var _0x2b78ee=0x0;_0x2b78ee<_0x3597e5[_0x7bf1('0x17')];_0x2b78ee+=0x1){var _0x57ce4e;var _0x5309b1=_0x3597e5[_0x2b78ee];if(_0x4b9978){_0x57ce4e=path['join'](_0x11c229,_0x4be9e1,util[_0x7bf1('0xf')](_0x7bf1('0x24'),_0x4be9e1,_0x2b78ee,'xlsx'));}else{_0x57ce4e=path['join'](_0x11c229,util[_0x7bf1('0xf')](_0x7bf1('0x25'),_0x4be9e1,'xlsx'));}fs[_0x7bf1('0x26')](_0x57ce4e,json2xls(_0x5309b1),_0x7bf1('0x27'));}})[_0x7bf1('0x12')](function(){if(_0x4b9978){return new Promise(function(_0x509955){zipdir(path['join'](_0x11c229,_0x4be9e1),{'saveTo':path['join'](_0x11c229,util['format'](_0x7bf1('0x25'),_0x4be9e1,_0x7bf1('0x28')))},function(_0x58bb34,_0x15de22){rimraf(path[_0x7bf1('0x21')](_0x11c229,_0x4be9e1),function(){});_0x509955(_0x7bf1('0x29'));});});}})['then'](function(){logger[_0x7bf1('0xe')](util['format'](_0x7bf1('0x2a'),EXTRACTED_REPORT_ID,_0x7bf1('0x2b')));return analyticExtractedReport(_0x7bf1('0x2c'),_0x4b9978?util[_0x7bf1('0xf')](_0x7bf1('0x25'),_0x4be9e1,_0x4b9978?_0x7bf1('0x28'):'xlsx'):null);});})[_0x7bf1('0x2d')](function(_0x2c4be7){logger[_0x7bf1('0xe')](util[_0x7bf1('0xf')](_0x7bf1('0x2e'),EXTRACTED_REPORT_ID,'XLSX'),util[_0x7bf1('0x2f')](_0x2c4be7,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport(_0x7bf1('0x30'));})[_0x7bf1('0x31')](function(){process[_0x7bf1('0x32')](EXIT_CODE);});}main();
\ No newline at end of file