Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / components / export / xlsx.js
index ba9527c..896346b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfb54=['Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','Completed','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','XLSX','inspect','Failed','finally','exit','util','path','lodash','json2xls','bluebird','zip-dir','rimraf','../../mysqldb','dbH','../../config/logger','analytics','argv','savename','AnalyticExtractedReport','update','info','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','Setting','split','splitSizeXlsx','then','sequelize','query','SELECT','num','length','range','isInteger','forEach','push','%s\x20limit\x20%d\x20OFFSET\x20%d','QueryTypes','dirname','basename','existsSync','join','mkdirSync','each','%s%d.%s','xlsx','%s.%s','writeFileSync','binary','zip','zip\x20finished'];(function(_0x2d9f6d,_0x107451){var _0x186c03=function(_0x426067){while(--_0x426067){_0x2d9f6d['push'](_0x2d9f6d['shift']());}};_0x186c03(++_0x107451);}(_0xfb54,0x116));var _0x4fb5=function(_0x3b7a0e,_0x2e228d){_0x3b7a0e=_0x3b7a0e-0x0;var _0xd00eab=_0xfb54[_0x3b7a0e];return _0xd00eab;};'use strict';var util=require(_0x4fb5('0x0'));var path=require(_0x4fb5('0x1'));var _=require(_0x4fb5('0x2'));var fs=require('fs');var json2xls=require(_0x4fb5('0x3'));var BPromise=require(_0x4fb5('0x4'));var zipdir=require(_0x4fb5('0x5'));var rimraf=require(_0x4fb5('0x6'));var db=require(_0x4fb5('0x7'))['db'];var dbH=require(_0x4fb5('0x7'))[_0x4fb5('0x8')];var logger=require(_0x4fb5('0x9'))(_0x4fb5('0xa'));var EXTRACTED_REPORT_ID=Number(process[_0x4fb5('0xb')][0x2]);var QUERY=process['argv'][0x3];var PATH=process[_0x4fb5('0xb')][0x4];var EXIT_CODE=0x0;function analyticExtractedReport(_0x53f324,_0x566e80){var _0x1f9674={'status':_0x53f324};var _0x2234a8={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x566e80){_0x1f9674[_0x4fb5('0xc')]=_0x566e80;}return db[_0x4fb5('0xd')][_0x4fb5('0xe')](_0x1f9674,_0x2234a8);}function main(){var _0x27a614=0x1388;var _0x43d570;logger[_0x4fb5('0xf')](util[_0x4fb5('0x10')](_0x4fb5('0x11'),EXTRACTED_REPORT_ID,'XLSX'));return db[_0x4fb5('0x12')]['find']({'where':{'id':0x1},'raw':!![],'attributes':['id',_0x4fb5('0x13'),_0x4fb5('0x14')]})[_0x4fb5('0x15')](function(_0x13a6ed){if(_0x13a6ed){_0x43d570=_0x13a6ed;_0x27a614=_0x43d570['splitSizeXlsx']||0x1388;}})[_0x4fb5('0x15')](function(){return dbH[_0x4fb5('0x16')][_0x4fb5('0x17')](util[_0x4fb5('0x10')]('SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t',QUERY),{'type':dbH['sequelize']['QueryTypes'][_0x4fb5('0x18')]});})['then'](function(_0x3137f9){if(!_0x3137f9[0x0][_0x4fb5('0x19')]){return analyticExtractedReport('Empty');}var _0x9fbd9a=[];var _0x4073ee=0x0;if(_0x43d570[_0x4fb5('0x13')]){if(_0x3137f9&&_0x3137f9[_0x4fb5('0x1a')]){var _0x31e4a7=_[_0x4fb5('0x1b')](_0x3137f9[0x0][_0x4fb5('0x19')]/_0x27a614);var _0x46870f=Number[_0x4fb5('0x1c')](_0x3137f9[0x0][_0x4fb5('0x19')]/_0x27a614)?_0x3137f9[0x0][_0x4fb5('0x19')]%_0x27a614:0x0;_0x31e4a7[_0x4fb5('0x1d')](function(_0x64029c){if(_0x64029c>0x0){_0x4073ee+=_0x27a614;}_0x9fbd9a[_0x4fb5('0x1e')](dbH['sequelize'][_0x4fb5('0x17')](util[_0x4fb5('0x10')](_0x4fb5('0x1f'),QUERY,_0x27a614,_0x4073ee),{'type':dbH[_0x4fb5('0x16')]['QueryTypes'][_0x4fb5('0x18')]}));});if(_0x46870f>0x0){_0x4073ee+=_0x27a614;_0x9fbd9a[_0x4fb5('0x1e')](dbH[_0x4fb5('0x16')][_0x4fb5('0x17')](util[_0x4fb5('0x10')](_0x4fb5('0x1f'),QUERY,_0x46870f,_0x4073ee),{'type':dbH[_0x4fb5('0x16')][_0x4fb5('0x20')][_0x4fb5('0x18')]}));}}}else{_0x9fbd9a['push'](dbH[_0x4fb5('0x16')][_0x4fb5('0x17')](QUERY,{'type':dbH[_0x4fb5('0x16')][_0x4fb5('0x20')][_0x4fb5('0x18')]}));}var _0x3c2a50=path[_0x4fb5('0x21')](PATH);var _0x1c6388=path[_0x4fb5('0x22')](PATH,'.xlsx');var _0x8cdf59=_0x43d570['split']&&_0x9fbd9a[_0x4fb5('0x1a')]>0x1;var _0x277526=[];if(!fs[_0x4fb5('0x23')](path[_0x4fb5('0x24')](_0x3c2a50,_0x1c6388))&&_0x8cdf59){fs[_0x4fb5('0x25')](path[_0x4fb5('0x24')](_0x3c2a50,_0x1c6388));}return BPromise[_0x4fb5('0x26')](_0x9fbd9a,function(_0x5f2261){_0x277526[_0x4fb5('0x1e')](_0x5f2261);})['then'](function(){for(var _0x38268c=0x0;_0x38268c<_0x277526[_0x4fb5('0x1a')];_0x38268c+=0x1){var _0xa5cbaa;var _0x1288f7=_0x277526[_0x38268c];if(_0x8cdf59){_0xa5cbaa=path[_0x4fb5('0x24')](_0x3c2a50,_0x1c6388,util[_0x4fb5('0x10')](_0x4fb5('0x27'),_0x1c6388,_0x38268c,_0x4fb5('0x28')));}else{_0xa5cbaa=path[_0x4fb5('0x24')](_0x3c2a50,util['format'](_0x4fb5('0x29'),_0x1c6388,_0x4fb5('0x28')));}fs[_0x4fb5('0x2a')](_0xa5cbaa,json2xls(_0x1288f7),_0x4fb5('0x2b'));}})[_0x4fb5('0x15')](function(){if(_0x8cdf59){return new Promise(function(_0x104ca3){zipdir(path[_0x4fb5('0x24')](_0x3c2a50,_0x1c6388),{'saveTo':path[_0x4fb5('0x24')](_0x3c2a50,util[_0x4fb5('0x10')](_0x4fb5('0x29'),_0x1c6388,_0x4fb5('0x2c')))},function(_0x292ac0,_0x188b76){rimraf(path[_0x4fb5('0x24')](_0x3c2a50,_0x1c6388),function(){});_0x104ca3(_0x4fb5('0x2d'));});});}})[_0x4fb5('0x15')](function(){logger['info'](util['format'](_0x4fb5('0x2e'),EXTRACTED_REPORT_ID,'XLSX'));return analyticExtractedReport(_0x4fb5('0x2f'),_0x8cdf59?util[_0x4fb5('0x10')](_0x4fb5('0x29'),_0x1c6388,_0x8cdf59?_0x4fb5('0x2c'):_0x4fb5('0x28')):null);});})['catch'](function(_0x70b551){logger[_0x4fb5('0xf')](util[_0x4fb5('0x10')](_0x4fb5('0x30'),EXTRACTED_REPORT_ID,_0x4fb5('0x31')),util[_0x4fb5('0x32')](_0x70b551,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport(_0x4fb5('0x33'));})[_0x4fb5('0x34')](function(){process[_0x4fb5('0x35')](EXIT_CODE);});}main();
\ No newline at end of file
+var _0xa149=['inspect','Failed','finally','exit','util','path','lodash','json2xls','bluebird','zip-dir','rimraf','../../mysqldb','../../config/logger','analytics','argv','AnalyticExtractedReport','info','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','XLSX','then','query','sequelize','QueryTypes','SELECT','num','Empty','split','length','range','isInteger','push','%s\x20limit\x20%d\x20OFFSET\x20%d','dirname','basename','.xlsx','existsSync','join','each','%s%d.%s','%s.%s','xlsx','writeFileSync','binary','zip\x20finished','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','Completed','zip','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xa149,0x18c));var _0x9a14=function(_0x34d54e,_0x55730e){_0x34d54e=_0x34d54e-0x0;var _0x4d4e53=_0xa149[_0x34d54e];return _0x4d4e53;};'use strict';var util=require(_0x9a14('0x0'));var path=require(_0x9a14('0x1'));var _=require(_0x9a14('0x2'));var fs=require('fs');var json2xls=require(_0x9a14('0x3'));var BPromise=require(_0x9a14('0x4'));var zipdir=require(_0x9a14('0x5'));var rimraf=require(_0x9a14('0x6'));var db=require(_0x9a14('0x7'))['db'];var dbH=require(_0x9a14('0x7'))['dbH'];var logger=require(_0x9a14('0x8'))(_0x9a14('0x9'));var EXTRACTED_REPORT_ID=Number(process['argv'][0x2]);var QUERY=process[_0x9a14('0xa')][0x3];var PATH=process[_0x9a14('0xa')][0x4];var EXIT_CODE=0x0;function analyticExtractedReport(_0x286760,_0x17d2e5){var _0x109f69={'status':_0x286760};var _0x26efc5={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x17d2e5){_0x109f69['savename']=_0x17d2e5;}return db[_0x9a14('0xb')]['update'](_0x109f69,_0x26efc5);}function main(){var _0x3d0481=0x1388;var _0x25afa7;logger[_0x9a14('0xc')](util[_0x9a14('0xd')](_0x9a14('0xe'),EXTRACTED_REPORT_ID,_0x9a14('0xf')));return db['Setting']['find']({'where':{'id':0x1},'raw':!![],'attributes':['id','split','splitSizeXlsx']})[_0x9a14('0x10')](function(_0x34c392){if(_0x34c392){_0x25afa7=_0x34c392;_0x3d0481=_0x25afa7['splitSizeXlsx']||0x1388;}})[_0x9a14('0x10')](function(){return dbH['sequelize'][_0x9a14('0x11')](util['format']('SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t',QUERY),{'type':dbH[_0x9a14('0x12')][_0x9a14('0x13')][_0x9a14('0x14')]});})[_0x9a14('0x10')](function(_0x4b414d){if(!_0x4b414d[0x0][_0x9a14('0x15')]){return analyticExtractedReport(_0x9a14('0x16'));}var _0x172d72=[];var _0x8a0666=0x0;if(_0x25afa7[_0x9a14('0x17')]){if(_0x4b414d&&_0x4b414d[_0x9a14('0x18')]){var _0x283e10=_[_0x9a14('0x19')](_0x4b414d[0x0][_0x9a14('0x15')]/_0x3d0481);var _0x3aa654=Number[_0x9a14('0x1a')](_0x4b414d[0x0]['num']/_0x3d0481)?_0x4b414d[0x0]['num']%_0x3d0481:0x0;_0x283e10['forEach'](function(_0x485d6d){if(_0x485d6d>0x0){_0x8a0666+=_0x3d0481;}_0x172d72['push'](dbH[_0x9a14('0x12')][_0x9a14('0x11')](util['format']('%s\x20limit\x20%d\x20OFFSET\x20%d',QUERY,_0x3d0481,_0x8a0666),{'type':dbH['sequelize']['QueryTypes'][_0x9a14('0x14')]}));});if(_0x3aa654>0x0){_0x8a0666+=_0x3d0481;_0x172d72[_0x9a14('0x1b')](dbH[_0x9a14('0x12')][_0x9a14('0x11')](util[_0x9a14('0xd')](_0x9a14('0x1c'),QUERY,_0x3aa654,_0x8a0666),{'type':dbH[_0x9a14('0x12')]['QueryTypes']['SELECT']}));}}}else{_0x172d72[_0x9a14('0x1b')](dbH[_0x9a14('0x12')][_0x9a14('0x11')](QUERY,{'type':dbH['sequelize'][_0x9a14('0x13')][_0x9a14('0x14')]}));}var _0x1e477f=path[_0x9a14('0x1d')](PATH);var _0x16ae46=path[_0x9a14('0x1e')](PATH,_0x9a14('0x1f'));var _0x1545c7=_0x25afa7['split']&&_0x172d72['length']>0x1;var _0x3089e6=[];if(!fs[_0x9a14('0x20')](path[_0x9a14('0x21')](_0x1e477f,_0x16ae46))&&_0x1545c7){fs['mkdirSync'](path['join'](_0x1e477f,_0x16ae46));}return BPromise[_0x9a14('0x22')](_0x172d72,function(_0x3ee854){_0x3089e6[_0x9a14('0x1b')](_0x3ee854);})[_0x9a14('0x10')](function(){for(var _0x47755e=0x0;_0x47755e<_0x3089e6['length'];_0x47755e+=0x1){var _0x7b53f3;var _0x4e171b=_0x3089e6[_0x47755e];if(_0x1545c7){_0x7b53f3=path['join'](_0x1e477f,_0x16ae46,util[_0x9a14('0xd')](_0x9a14('0x23'),_0x16ae46,_0x47755e,'xlsx'));}else{_0x7b53f3=path[_0x9a14('0x21')](_0x1e477f,util['format'](_0x9a14('0x24'),_0x16ae46,_0x9a14('0x25')));}fs[_0x9a14('0x26')](_0x7b53f3,json2xls(_0x4e171b),_0x9a14('0x27'));}})[_0x9a14('0x10')](function(){if(_0x1545c7){return new Promise(function(_0xc9726a){zipdir(path[_0x9a14('0x21')](_0x1e477f,_0x16ae46),{'saveTo':path[_0x9a14('0x21')](_0x1e477f,util[_0x9a14('0xd')]('%s.%s',_0x16ae46,'zip'))},function(_0x4b2707,_0x325ab6){rimraf(path[_0x9a14('0x21')](_0x1e477f,_0x16ae46),function(){});_0xc9726a(_0x9a14('0x28'));});});}})[_0x9a14('0x10')](function(){logger[_0x9a14('0xc')](util[_0x9a14('0xd')](_0x9a14('0x29'),EXTRACTED_REPORT_ID,'XLSX'));return analyticExtractedReport(_0x9a14('0x2a'),_0x1545c7?util[_0x9a14('0xd')](_0x9a14('0x24'),_0x16ae46,_0x1545c7?_0x9a14('0x2b'):_0x9a14('0x25')):null);});})['catch'](function(_0x261476){logger[_0x9a14('0xc')](util['format'](_0x9a14('0x2c'),EXTRACTED_REPORT_ID,'XLSX'),util[_0x9a14('0x2d')](_0x261476,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport(_0x9a14('0x2e'));})[_0x9a14('0x2f')](function(){process[_0x9a14('0x30')](EXIT_CODE);});}main();
\ No newline at end of file