Răsfoiți Sursa

短信、教材等脚本

cehn 1 lună în urmă
părinte
comite
469ef2bcc5
1 a modificat fișierele cu 103 adăugiri și 11 ștergeri
  1. 103 11
      projects/textbook/src/services/textbook.ts

+ 103 - 11
projects/textbook/src/services/textbook.ts

@@ -236,6 +236,7 @@ export class textbookServer {
 
   /* 获取已有联系人出版单位、未注册联系人出版单位 */
   async getUnitList() {
+    let unitMap:any = {}
     let unitList = new Set<string>(); //单位出版社
     let query = new Parse.Query('EduTextbook');
     query.equalTo('status', '400');
@@ -243,15 +244,23 @@ export class textbookServer {
     query.notEqualTo('discard', true);
     query.include('user.phone', 'childrens.editionUnit');
     query.select('user.phone', 'childrens.editionUnit')
-    query.limit(1000);
+    query.limit(10000);
     let r = await query.find();
     r.forEach((item) => {
       item
         .get('childrens')
-        ?.forEach((child: any) => unitList.add(child?.get('editionUnit')));
+        ?.forEach((child: any) =>{
+          if(!child?.get('editionUnit')){
+            console.log(item);
+          }
+          unitList.add(child?.get('editionUnit'))
+          unitMap[child?.get('editionUnit')] = unitMap[child?.get('editionUnit')] ? unitMap[child?.get('editionUnit')]+1 : 1
+        });
     });
     let unitArr = Array.from(unitList);
     console.log('已被选择的申报单位:',unitArr);
+    console.log(unitMap);
+    
     let queryParams: any = {
       where: {
         $or: [
@@ -271,7 +280,7 @@ export class textbookServer {
     let queryEduProcess = Parse.Query.fromJSON('EduProcess', queryParams);
     queryEduProcess.include('profileSubmitted.user');
     queryEduProcess.select('profileSubmitted.user.phone','name')
-    query.limit(1000)
+    queryEduProcess.limit(1000)
     let list = await queryEduProcess.find();
     // console.log(list);
     let unitPhoneList = new Set<string>(); //出版单位联系人
@@ -292,7 +301,9 @@ export class textbookServer {
           <thead>
             <tr>
               <th>已注册</th>
+              <th>教材数量</th>
               <th>未注册</th>
+              <th>教材数量</th>
             </tr>
           </thead>
           <tbody>
@@ -305,10 +316,18 @@ export class textbookServer {
         _body += `${a[row] || ''}`;
         _body += '</td>';
 
+        _body += '<td>';
+        _body += `${unitMap[a[row]] || ''}`;
+        _body += '</td>';
+
         _body += '<td>';
         _body += ` &nbsp;${b[row] || ''}`;
         _body += '</td>';
 
+        _body += '<td>';
+        _body += `${unitMap[b[row]] || ''}`;
+        _body += '</td>';
+
         _body += '</tr>';
       }
       table += _body;
@@ -317,6 +336,64 @@ export class textbookServer {
       let title = '出版社';
       this.excel(table, `${title}.xls`);
   }
+
+  /* 获取高等教育出版社教材 */
+  async getGdjy(){
+    let query = new Parse.Query('EduTextbook');
+    query.equalTo('status', '400');
+    query.notEqualTo('isDeleted', true);
+    query.notEqualTo('discard', true);
+    query.include('user');
+    // query.select('user')
+    query.limit(2000);
+    query.equalTo('title','高等教育出版社')
+    let data = await query.find()
+    console.log(data);
+     let table = `<table border="1px" cellspacing="0" cellpadding="0">
+          <thead>
+            <tr>
+              <th>教材名称</th>
+              <th>申报编号</th>
+              <th>用户名</th>
+              <th>手机号</th>
+              <th>专业类</th>
+            </tr>
+          </thead>
+          <tbody>
+          `;
+
+      let _body = '';
+      for (var row = 0; row < data.length; row++) {
+        _body += '<tr>';
+        _body += '<td>';
+        _body += `${data[row]?.get('title') || ''}`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += `${data[row]?.get('code') || ''}`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += `${data[row]?.get('user')?.get('name') || ''}`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += `${data[row]?.get('user')?.get('phone') || ''}`;
+        _body += '</td>';
+
+        _body += '<td>';
+        _body += `${(data[row]?.get('discipline')?.code + '/'+ data[row]?.get('discipline')?.name) || ''}`;
+        _body += '</td>';
+
+        _body += '</tr>';
+      }
+      table += _body;
+      table += '</tbody>';
+      table += '</table>';
+      let title = '高等教育出版社';
+      this.excel(table, `${title}.xls`);
+  }
+
   /* 格式化拓展表字段 */
   fromatFiled(list: Array<Parse.Object>, filed: string): string {
     let arr: Array<string | null> = [];
@@ -520,7 +597,7 @@ export class textbookServer {
     query.notEqualTo('discard', true);
     query.include('user.phone', 'childrens.editionUnit');
     query.select('user.phone', 'childrens.editionUnit')
-    query.limit(1000);
+    query.limit(10000);
     let r = await query.find();
     r.forEach((item) => {
       teacherList.add(item?.get('user')?.get('phone'));
@@ -532,13 +609,28 @@ export class textbookServer {
     let unitArr = Array.from(unitList);
     console.log('教师电话:',teacherArr);
     // console.log(unitArr);
+    let last = teacherArr.slice(5000,5999)
+    last.push(...['13581837652','13407973043','18510409671'])
+    console.log(last);
 
-    // Parse.Cloud.run('aliSmsSend', {
-    //   mobileList: [teacherArr],
-    //   templateCode: 'SMS_474205136',
-    //   params: {},
-    //   signName: '普通高等教育教材网',
-    // });
+    let arr:any = [
+      // teacherArr.slice(0,999), 
+      // teacherArr.slice(1000,1999),
+      // teacherArr.slice(2000,2999),
+      // teacherArr.slice(3000,3999),
+      // teacherArr.slice(4000,4999),
+      last
+    ]
+    // arr.forEach((list:any)=> {
+    //   Parse.Cloud.run('aliSmsSend', {
+    //     mobileList: [list],
+    //     templateCode: 'SMS_474205136',
+    //     params: {},
+    //     signName: '普通高等教育教材网',
+    //   });
+    // })
+
+    return
     let queryParams: any = {
       where: {
         $or: [
@@ -558,7 +650,7 @@ export class textbookServer {
     let queryEduProcess = Parse.Query.fromJSON('EduProcess', queryParams);
     queryEduProcess.include('profileSubmitted.user');
     queryEduProcess.select('profileSubmitted.user.phone')
-    query.limit(1000)
+    queryEduProcess.limit(1000)
     let list = await queryEduProcess.find();
     // console.log(list);
     let unitPhoneList = new Set<string>(); //出版单位联系人