Эх сурвалжийг харах

shell 新增导出作者信息脚本

warrior 2 сар өмнө
parent
commit
697d151fc9

+ 364 - 264
projects/textbook/src/services/shell.ts

@@ -374,28 +374,28 @@ export class shellServer {
   }
   //导出表格
   async exportEduTextbook() {
-    let unitName = '全部教材';
+    let unitName = '全部教材作者';
     try {
-      let queryParams: any = {
-        where: {
-          $or: [
-            {
-              childrens: {
-                $inQuery: {
-                  where: {
-                    // editionUnit: unitName,
-                    // collectStatus: { $ne: '200' },
-                    collectStatus: '200',
-                  },
-                  className: 'EduTextbookVolume',
-                },
-              },
-            },
-          ],
-        },
-      };
-      let query = Parse.Query.fromJSON('EduTextbook', queryParams);
-      // let query = new Parse.Query('EduTextbook');
+      // let queryParams: any = {
+      //   where: {
+      //     $or: [
+      //       {
+      //         childrens: {
+      //           $inQuery: {
+      //             where: {
+      //               // editionUnit: unitName,
+      //               // collectStatus: { $ne: '200' },
+      //               collectStatus: '200',
+      //             },
+      //             className: 'EduTextbookVolume',
+      //           },
+      //         },
+      //       },
+      //     ],
+      //   },
+      // };
+      // let query = Parse.Query.fromJSON('EduTextbook', queryParams);
+      let query = new Parse.Query('EduTextbook');
       query.notEqualTo('isDeleted', true);
       query.notEqualTo('discard', true);
       query.equalTo('render', true);
@@ -419,6 +419,7 @@ export class shellServer {
         'childrens.collectLink',
         'childrens.collectDigitFiles',
         'childrens.collectCheck',
+        'childrens.authorList',
 
         'user.department',
         'department.branch',
@@ -443,255 +444,354 @@ export class shellServer {
       query.limit(10000);
       query.skip(0);
       let data = await query.find();
-      let table = `<table border="1px" cellspacing="0" cellpadding="0">
-        <thead>
-          <tr>
-            <th>申报编号</th>
-            <th>申报教材名称</th>
-            <th>教材所属学科专业类</th>
-            <th>教材应用对象及所属学科专业类</th>
-            <th>是否为重点立项教材</th>
-            <th>申报部门</th>
-            <th>申报部门工作联系人</th>
-            <th>申报部门工作联系人手机号</th>
-            <th>申报部门工作联系人邮箱</th>
-            <th>申报类型</th>
-            <th>第一主编(作者)</th>
-            <th>第一主编(作者)单位</th>
-            <th>教材主要语种类型</th>
-            <th>国际标准书号(ISBN)</th>
-            <th>出版单位</th>
-            <th>初版时间</th>
-            <th>载体形式</th>
-            <th>本版出版时间及版次</th>
-            <th>最新印次时间及印次</th>
-            <th>初版以来合计印数</th>
-            <th>初版以来是否曾列为重点项目</th>
-            <th>适用专业代码(六位)及名称</th>
-            <th>申报状态</th>
-            <th>源文件状态</th>
-
-            <th>纸质教材PDF名称</th>
-            <th>数字教材链接</th>
-            <th>链接和账号密码</th>
-            <th>数字教材文件名称</th>
-
-          </tr>
-        </thead>
-        <tbody>
-        `;
       // let table = `<table border="1px" cellspacing="0" cellpadding="0">
-      // <thead>
-      //   <tr>
-      //     <th>申报编号</th>
-      //     <th>申报教材名称</th>
-      //     <th>所属单位</th>
-      //     <th>单位联系人</th>
-      //     <th>联系人电话</th>
-      //     <th>联系人邮箱</th>
-      //   </tr>
-      // </thead>
-      // <tbody>
-      // `;
+      //   <thead>
+      //     <tr>
+      //       <th>申报编号</th>
+      //       <th>申报教材名称</th>
+      //       <th>教材所属学科专业类</th>
+      //       <th>教材应用对象及所属学科专业类</th>
+      //       <th>是否为重点立项教材</th>
+      //       <th>申报部门</th>
+      //       <th>申报部门工作联系人</th>
+      //       <th>申报部门工作联系人手机号</th>
+      //       <th>申报部门工作联系人邮箱</th>
+      //       <th>申报类型</th>
+      //       <th>第一主编(作者)</th>
+      //       <th>第一主编(作者)单位</th>
+      //       <th>教材主要语种类型</th>
+      //       <th>国际标准书号(ISBN)</th>
+      //       <th>出版单位</th>
+      //       <th>初版时间</th>
+      //       <th>载体形式</th>
+      //       <th>本版出版时间及版次</th>
+      //       <th>最新印次时间及印次</th>
+      //       <th>初版以来合计印数</th>
+      //       <th>初版以来是否曾列为重点项目</th>
+      //       <th>适用专业代码(六位)及名称</th>
+      //       <th>申报状态</th>
+      //       <th>源文件状态</th>
+
+      //       <th>纸质教材PDF名称</th>
+      //       <th>数字教材链接</th>
+      //       <th>链接和账号密码</th>
+      //       <th>数字教材文件名称</th>
+
+      //     </tr>
+      //   </thead>
+      //   <tbody>
+      //   `;
+      let table = this.tableAuthors;
       let _body = '';
-      for (let row = 0; row < data.length; row++) {
-        // console.log(data[row]?.get('user')?.get('department'));
-        let inviteUnit = data[row]?.get('inviteUnit');
-        if (
-          data[row]?.get('department')?.get('branch') == '省级教育行政部门' ||
-          data[row]?.get('department')?.get('branch') ==
-            '有关部门(单位)教育司(局)'
-        ) {
-          let parentMap = await this.formatNode(
-            data[row]?.get('user')?.get('department')?.id
-          );
-          inviteUnit = parentMap[2]?.title;
-        }
-        _body += '<tr>';
-        _body += '<td>';
-        _body += `&nbsp;${data[row]?.get('code') || ''}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${data[row]?.get('title') || '-'}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${
-          data[row]?.get('discipline')?.code +
-          '-' +
-          data[row]?.get('discipline')?.name
-        }`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${
-          data[row]?.get('majorPoniter')?.code +
-          '-' +
-          data[row]?.get('majorPoniter')?.name
-        }`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${data[row]?.get('approval') || '否'}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${data[row]?.get('inviteUnit') || ''}`;
-        // _body += `&nbsp;${inviteUnit || ''}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${
-          data[row]
-            ?.get('eduProcess')
-            ?.get('profileSubmitted')
-            ?.get('user')
-            ?.get('name') || ''
-        }`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${
-          data[row]
-            ?.get('eduProcess')
-            ?.get('profileSubmitted')
-            ?.get('user')
-            ?.get('phone') || ''
-        }`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${
-          data[row]?.get('eduProcess')?.get('profileSubmitted')?.get('email') ||
-          ''
-        }`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${
-          data[row]?.get('type') == '单本'
-            ? '单本'
-            : '全册 - ' + data[row]?.get('childrens')?.length || '-'
-        }`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiled(data[row]?.get('childrens'), 'author')}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiled(data[row]?.get('childrens'), 'unit')}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiled(data[row]?.get('childrens'), 'lang')}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${this.fromatFiled(
-          data[row]?.get('childrens'),
-          'ISBN'
-        )}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiled(
-          data[row]?.get('childrens'),
-          'editionUnit'
-        )}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${this.fromatFiled(
-          data[row]?.get('childrens'),
-          'editionFirst'
-        )}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiled(
-          data[row]?.get('childrens'),
-          'carrierShape'
-        )}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiled(
-          data[row]?.get('childrens'),
-          'editionDate',
-          'editionNumber'
-        )}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiled(
-          data[row]?.get('childrens'),
-          'printDate',
-          'printNumber'
-        )}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiled(data[row]?.get('childrens'), 'printSum')}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiled(
-          data[row]?.get('childrens'),
-          'importantProject'
-        )}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `&nbsp;${
-          data[row]?.get('major')?.code + '-' + data[row]?.get('major')?.name
-        }`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `已报送`;
-        _body += '</td>';
-        _body += '<td>';
-        _body += `已上传`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiledCollect(data[row]?.get('childrens'))}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiledCollect(
-          data[row]?.get('childrens'),
-          '链接'
-        )}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiledCollect(
-          data[row]?.get('childrens'),
-          '链接和账号密码'
-        )}`;
-        _body += '</td>';
-
-        _body += '<td>';
-        _body += `${this.fromatFiledCollect(
-          data[row]?.get('childrens'),
-          '上传文件'
-        )}`;
-        _body += '</td>';
-
-        _body += '</tr>';
-      }
+      _body = await this.authors_body(data);
+      // for (let row = 0; row < data.length; row++) {
+      //   let inviteUnit = data[row]?.get('inviteUnit');
+      //   if (
+      //     data[row]?.get('department')?.get('branch') == '省级教育行政部门' ||
+      //     data[row]?.get('department')?.get('branch') ==
+      //       '有关部门(单位)教育司(局)'
+      //   ) {
+      //     let parentMap = await this.formatNode(
+      //       data[row]?.get('user')?.get('department')?.id
+      //     );
+      //     inviteUnit = parentMap[2]?.title;
+      //   }
+      //   _body += '<tr>';
+      //   _body += '<td>';
+      //   _body += `&nbsp;${data[row]?.get('code') || ''}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${data[row]?.get('title') || '-'}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${
+      //     data[row]?.get('discipline')?.code +
+      //     '-' +
+      //     data[row]?.get('discipline')?.name
+      //   }`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${
+      //     data[row]?.get('majorPoniter')?.code +
+      //     '-' +
+      //     data[row]?.get('majorPoniter')?.name
+      //   }`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${data[row]?.get('approval') || '否'}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${data[row]?.get('inviteUnit') || ''}`;
+      //   // _body += `&nbsp;${inviteUnit || ''}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${
+      //     data[row]
+      //       ?.get('eduProcess')
+      //       ?.get('profileSubmitted')
+      //       ?.get('user')
+      //       ?.get('name') || ''
+      //   }`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${
+      //     data[row]
+      //       ?.get('eduProcess')
+      //       ?.get('profileSubmitted')
+      //       ?.get('user')
+      //       ?.get('phone') || ''
+      //   }`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${
+      //     data[row]?.get('eduProcess')?.get('profileSubmitted')?.get('email') ||
+      //     ''
+      //   }`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${
+      //     data[row]?.get('type') == '单本'
+      //       ? '单本'
+      //       : '全册 - ' + data[row]?.get('childrens')?.length || '-'
+      //   }`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiled(data[row]?.get('childrens'), 'author')}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiled(data[row]?.get('childrens'), 'unit')}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiled(data[row]?.get('childrens'), 'lang')}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${this.fromatFiled(
+      //     data[row]?.get('childrens'),
+      //     'ISBN'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiled(
+      //     data[row]?.get('childrens'),
+      //     'editionUnit'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${this.fromatFiled(
+      //     data[row]?.get('childrens'),
+      //     'editionFirst'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiled(
+      //     data[row]?.get('childrens'),
+      //     'carrierShape'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiled(
+      //     data[row]?.get('childrens'),
+      //     'editionDate',
+      //     'editionNumber'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiled(
+      //     data[row]?.get('childrens'),
+      //     'printDate',
+      //     'printNumber'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiled(data[row]?.get('childrens'), 'printSum')}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiled(
+      //     data[row]?.get('childrens'),
+      //     'importantProject'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `&nbsp;${
+      //     data[row]?.get('major')?.code + '-' + data[row]?.get('major')?.name
+      //   }`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `已报送`;
+      //   _body += '</td>';
+      //   _body += '<td>';
+      //   _body += `已上传`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiledCollect(data[row]?.get('childrens'))}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiledCollect(
+      //     data[row]?.get('childrens'),
+      //     '链接'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiledCollect(
+      //     data[row]?.get('childrens'),
+      //     '链接和账号密码'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '<td>';
+      //   _body += `${this.fromatFiledCollect(
+      //     data[row]?.get('childrens'),
+      //     '上传文件'
+      //   )}`;
+      //   _body += '</td>';
+
+      //   _body += '</tr>';
+      // }
       table += _body;
       table += '</tbody>';
       table += '</table>';
-      // let title = '已提交教材';
       this.excel(table, `${unitName}.xls`);
     } catch (err) {
       console.log(err);
     }
   }
+  // 导出作者
+  tableAuthors: string = `<table border="1px" cellspacing="0" cellpadding="0">
+      <thead>
+        <tr>
+        <th>序号</th>
+        <th>申报教材名称</th>
+          <th>申报编号</th>
+          <th>出版单位</th>
+          <th>主编所在单位</th>
+          <th>姓名</th>
+          <th>单位</th>
+          <th>出生年月</th>
+          <th>国籍</th>
+          <th>职务</th>
+          <th>职称</th>
+          <th>手机号码</th>
+          <th>电子邮箱</th>
+          <th>主编/副主编/其他编者</th>
+        </tr>
+      </thead>
+      <tbody>
+      `;
+  async authors_body(data: Array<Parse.Object>): Promise<string> {
+    let _body = '';
+    let i = 1;
+    for (let row = 0; row < data.length; row++) {
+      // let inviteUnit = data[row]?.get('inviteUnit');
+      // if (
+      //   data[row]?.get('department')?.get('branch') == '省级教育行政部门' ||
+      //   data[row]?.get('department')?.get('branch') ==
+      //     '有关部门(单位)教育司(局)'
+      // ) {
+      //   let parentMap = await this.formatNode(
+      //     data[row]?.get('user')?.get('department')?.id
+      //   );
+      //   inviteUnit = parentMap[2]?.title;
+      // }
+      data[row]?.get('childrens').forEach((val: Parse.Object) => {
+        let authorSet = new Set();
+        val.get('authorList').forEach((author: any) => {
+          //避免重复
+          if (!authorSet.has(author.name)) {
+            authorSet.add(author.name);
+
+            _body += '<tr>';
+
+            _body += '<td>';
+            _body += `&nbsp;${i++}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${data[row]?.get('title') || '-'}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${data[row]?.get('code') || ''}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${val.get('editionUnit')}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${val.get('unit')}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${author?.name}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${author?.unit}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${this.tbookSer.formatTime(
+              'YYYY-mm',
+              author?.birth
+            )}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${author?.nationality}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${author?.job}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${author?.title}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${author?.mobile}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${author?.email}`;
+            _body += '</td>';
+
+            _body += '<td>';
+            _body += `&nbsp;${author?.work}`;
+            _body += '</td>';
+
+            _body += '</tr>';
+          }
+        });
+      });
+    }
+    return _body;
+  }
 
   /* 格式化拓展表字段教材文件 */
   fromatFiledCollect(list: Array<Parse.Object>, radioValue?: string): string {
@@ -738,9 +838,9 @@ export class shellServer {
       queryProcs.include('profileSubmitted', 'profileSubmitted.user');
       queryProcs.select('name', 'profileSubmitted');
       // queryProcs.notEqualTo('branch','66865d66ad23a23355b12aa7')
-      queryProcs.notEqualTo('isDeleted',true)
-      queryProcs.greaterThan('num',0)
-      queryProcs.limit(300)
+      queryProcs.notEqualTo('isDeleted', true);
+      queryProcs.greaterThan('num', 0);
+      queryProcs.limit(300);
       let resEduProcess = await queryProcs.find();
       console.log(resEduProcess.length);
       for (let index = 0; index < resEduProcess.length; index++) {
@@ -918,7 +1018,7 @@ export class shellServer {
         table += _body;
         table += '</tbody>';
         table += '</table>';
-        let title = r?.get('name')+' 推荐汇总表';
+        let title = r?.get('name') + ' 推荐汇总表';
         this.excel(table, `${title}.xls`);
       }
     } catch (err) {}