cehn 6 months ago
parent
commit
f6fc622587
1 changed files with 110 additions and 109 deletions
  1. 110 109
      projects/textbook/src/services/textbook.ts

+ 110 - 109
projects/textbook/src/services/textbook.ts

@@ -274,43 +274,40 @@ export class textbookServer {
     //     count++
     //   }
     // }
-    let arr = [];
-    let query = new Parse.Query('EduTextbook');
-    query.notEqualTo('isDeleted', true);
-    query.notEqualTo('discard', true);
-    query.equalTo('render', true);
-    query.select(
-      'title',
-      'childrens.ISBN',
-      'childrens.author',
-      'childrens.editionUnit',
-      'inviteUnit'
-    );
-    query.limit(3000);
-    query.containedIn('status', ['400']);
-    let eduTextbook = await query.find();
-    for (let index = 0; index < eduTextbook.length; index++) {
-      const item = eduTextbook[index];
-      let ISBN = '',
-        author = '',
-        editionUnit = '';
-      item?.get('childrens').forEach((children: any) => {
-        ISBN = children?.get('ISBN') + ' ' + ISBN;
-        author = children?.get('author') + ' ' + author;
-        editionUnit = children?.get('editionUnit') + ' ' + editionUnit;
-      });
-      arr.push({
-        教材名称: item?.get('title'),
-        ISBN: ISBN,
-        作者: author,
-        出版社: editionUnit,
-        所属院校: item?.get('inviteUnit'),
-      });
-      // item?.set('deadline', new Date('2024-09-30 16:00'));
-      // await item?.save()
-      // count++
-    }
-    console.log(arr);
+    // let arr = [];
+    // let query = new Parse.Query('EduTextbook');
+    // query.notEqualTo('isDeleted', true);
+    // query.notEqualTo('discard', true);
+    // query.equalTo('render', true);
+    // query.select(
+    //   'title',
+    //   'childrens.ISBN',
+    //   'childrens.author',
+    //   'childrens.editionUnit',
+    //   'inviteUnit'
+    // );
+    // query.limit(3000);
+    // query.containedIn('status', ['400']);
+    // let eduTextbook = await query.find();
+    // for (let index = 0; index < eduTextbook.length; index++) {
+    //   const item = eduTextbook[index];
+    //   let ISBN = '',
+    //     author = '',
+    //     editionUnit = '';
+    //   item?.get('childrens').forEach((children: any) => {
+    //     ISBN = children?.get('ISBN') + ' ' + ISBN;
+    //     author = children?.get('author') + ' ' + author;
+    //     editionUnit = children?.get('editionUnit') + ' ' + editionUnit;
+    //   });
+    //   arr.push({
+    //     教材名称: item?.get('title'),
+    //     ISBN: ISBN,
+    //     作者: author,
+    //     出版社: editionUnit,
+    //     所属院校: item?.get('inviteUnit'),
+    //   });
+    // }
+    // console.log(arr);
   }
   /* 格式化拓展表字段 */
   fromatFiled(list: Array<Parse.Object>, filed: string): string {
@@ -340,7 +337,7 @@ export class textbookServer {
       let query = new Parse.Query('EduTextbook');
       query.notEqualTo('isDeleted', true);
       query.notEqualTo('discard', true);
-      // query.equalTo('render', true);
+      query.equalTo('render', true);
       query.select(
         'title',
         'childrens.ISBN',
@@ -353,115 +350,119 @@ export class textbookServer {
         'department.branch',
         'code',
         // 'eduProcess.profileSubmitted',
-        'eduProcess.profileSubmitted.email',
-        'eduProcess.profileSubmitted.user.name',
-        'eduProcess.profileSubmitted.user.phone'
+        // 'eduProcess.profileSubmitted.email',
+        // 'eduProcess.profileSubmitted.user.name',
+        // 'eduProcess.profileSubmitted.user.phone'
       );
-      query.limit(3000);
-      // query.containedIn('status', ['102','103', '200', '201', '400']);
+      query.containedIn('status', ['102','103', '200', '201', '400']);
       // query.containedIn('status',['400'])
-      query.containedIn('objectId',updateDept.list5)
+      // query.containedIn('objectId',updateDept.list5)
+      query.ascending('createdAt')
+      let count = await query.count()
+      console.log(count);
+      query.limit(2000);
+      query.skip(2000)
       let data = await query.find();
-      // let table = `<table border="1px" cellspacing="0" cellpadding="0">
-      //     <thead>
-      //       <tr>
-      //         <th>序号</th>
-      //         <th>申报教材名称</th>
-      //         <th>第一主编/作者</th>
-      //         <th>ISBN</th>
-      //         <th>出版单位</th>
-      //         <th>所属院校</th>
-      //         <th>最新印次和时间</th>
-      //       </tr>
-      //     </thead>
-      //     <tbody>
-      //     `;
-          let table = `<table border="1px" cellspacing="0" cellpadding="0">
+      let table = `<table border="1px" cellspacing="0" cellpadding="0">
           <thead>
             <tr>
               <th>序号</th>
               <th>申报教材名称</th>
-              <th>code</th>
-              <th>所属单位</th>
-              <th>单位联系人</th>
-              <th>联系人电话</th>
-              <th>联系人邮箱</th>
+              <th>第一主编/作者</th>
+              <th>ISBN</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>code</th>
+          //     <th>所属单位</th>
+          //     <th>单位联系人</th>
+          //     <th>联系人电话</th>
+          //     <th>联系人邮箱</th>
+          //   </tr>
+          // </thead>
+          // <tbody>
+          // `;
       let _body = '';
       for (var 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;
-        // }
+        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 += `${row + 1}`;
+        _body += `${row + 2001}`;
         _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;${data[row].get('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 += `${this.fromatFiled(data[row]?.get('childrens'), 'author')}`;
+        // _body += `&nbsp;${data[row].get('code') || ''}`;
         // _body += '</td>';
 
         // _body += '<td>';
-        // _body += `&nbsp;${this.fromatFiled(
-        //   data[row]?.get('childrens'),
-        //   'ISBN'
-        // )}`;
+        // _body += `&nbsp;${data[row].get('inviteUnit') || ''}`;
         // _body += '</td>';
 
         // _body += '<td>';
-        // _body += `${this.fromatFiled(
-        //   data[row]?.get('childrens'),
-        //   'editionUnit'
-        // )}`;
+        // _body += `&nbsp;${data[row]?.get('eduProcess')?.get('profileSubmitted')?.get('user')?.get('name') || ''}`;
         // _body += '</td>';
 
         // _body += '<td>';
-        // _body += `${inviteUnit}`;
+        // _body += `&nbsp;${data[row]?.get('eduProcess')?.get('profileSubmitted')?.get('user')?.get('phone') || ''}`;
         // _body += '</td>';
 
         // _body += '<td>';
-        // _body += `${this.fromatFiled(
-        //   data[row]?.get('childrens'),
-        //   'printDate'
-        // )}`;
+        // _body += `&nbsp;${data[row]?.get('eduProcess')?.get('profileSubmitted')?.get('email') || ''}`;
         // _body += '</td>';
 
+        _body += '<td>';
+        _body += `${this.fromatFiled(data[row]?.get('childrens'), 'author')}`;
+        _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 += `${inviteUnit}`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += `${this.fromatFiled(
+          data[row]?.get('childrens'),
+          'printDate'
+        )}`;
+        _body += '</td>';
+
         _body += '</tr>';
       }
       table += _body;