...
|
...
|
@@ -7,10 +7,10 @@ const xlsx = require('xlsx'); |
|
|
const mail = require('nodemailer');
|
|
|
const moment = require('moment');
|
|
|
const smtpTransport = require('nodemailer-smtp-transport');
|
|
|
const depart_names = ['创意', '活动', '技术', '零售', '媒体', '品牌', '上游资源', '市场会员', '运维', '战略发展'];
|
|
|
const depart_names = ['活动', '技术', '零售', '媒体', '品牌', '上游资源', '市场会员', '运维', '战略发展'];
|
|
|
const ActivityModel = require('../../admin/models/activity');
|
|
|
|
|
|
let results = [[], [], [], [], [], [], [], [], [], []];
|
|
|
let results = [[], [], [], [], [], [], [], [], []];
|
|
|
|
|
|
let loadExcel = function(path) {
|
|
|
let workbook = xlsx.readFile(path);
|
...
|
...
|
@@ -76,9 +76,9 @@ const excelLoader = { |
|
|
* @returns {Promise.<T>|*}
|
|
|
*/
|
|
|
excelToXml(req, res, next) {
|
|
|
return loadExcel('public/docs/user.xlsx').then(ret => {
|
|
|
return loadExcel('public/docs/users2019.xlsx').then(ret => {
|
|
|
_.each(ret, item => {
|
|
|
let depart_1 = item.depart_1; // 第一级部门
|
|
|
let depart_1 = item.block; // 第一级部门
|
|
|
|
|
|
for (let i = 0; i < depart_names.length; i++) { // 按部门归入相应的数组
|
|
|
if (depart_1.indexOf(depart_names[i]) >= 0) {
|
...
|
...
|
@@ -92,7 +92,8 @@ const excelLoader = { |
|
|
'\t<data>\n';
|
|
|
|
|
|
_.each(results, item_arr => {
|
|
|
let xml_dep_f = '\t\t<department depid="0" name="' + item_arr[0].depart_1 +
|
|
|
console.log(item_arr.length);
|
|
|
let xml_dep_f = '\t\t<department depid="0" name="' + item_arr[0].block +
|
|
|
'" total="' + item_arr.length + '" prizes="0">\n';
|
|
|
let xml_person = '';
|
|
|
|
...
|
...
|
@@ -101,14 +102,14 @@ const excelLoader = { |
|
|
let xml_person_e = '\t\t\t</person>\n';
|
|
|
let depart_arr = [];
|
|
|
|
|
|
if (item.depart_1) {
|
|
|
depart_arr.push(item.depart_1);
|
|
|
if (item.block) {
|
|
|
depart_arr.push(item.block);
|
|
|
}
|
|
|
if (item.depart_2) {
|
|
|
depart_arr.push(item.depart_2);
|
|
|
if (item.center) {
|
|
|
depart_arr.push(item.center);
|
|
|
}
|
|
|
if (item.depart_3) {
|
|
|
depart_arr.push(item.depart_3);
|
|
|
if (item.depart) {
|
|
|
depart_arr.push(item.depart.replace(/\d/g, ''));
|
|
|
}
|
|
|
if (item.depart_4) {
|
|
|
depart_arr.push(item.depart_4);
|
...
|
...
|
@@ -125,7 +126,6 @@ const excelLoader = { |
|
|
'\t\t\t\t<level>0</level>\n';
|
|
|
|
|
|
xml_person += xml_person_f + xml_person_content + xml_person_e;
|
|
|
|
|
|
});
|
|
|
|
|
|
let xml_dep_e = '\t\t</department>\n';
|
...
|
...
|
@@ -140,7 +140,7 @@ const excelLoader = { |
|
|
},
|
|
|
getExcelData(req, res) {
|
|
|
console.log(req);
|
|
|
return loadExcel('public/docs/user.xlsx').then(ret => {
|
|
|
return loadExcel('public/docs/users2019.xlsx').then(ret => {
|
|
|
res.json(ret);
|
|
|
});
|
|
|
},
|
...
|
...
|
|