Ver código fonte

优化导出教材excel、管理员发送短信按钮

cehn 5 meses atrás
pai
commit
a0284e8107

+ 1 - 1
projects/textbook/src/app/textbook/textbook.component.ts

@@ -400,6 +400,7 @@ export class TextbookComponent implements OnInit {
     } else {
       query.notEqualTo('discard', true);
     }
+    query.include('department', 'childrens', 'user');
     if (exported?.excel) {
       query.limit(1000);
       if (exported?.id) {
@@ -409,7 +410,6 @@ export class TextbookComponent implements OnInit {
       this.loading = false;
       return r;
     }
-    query.include('department', 'childrens', 'user');
     this.count = await query.count();
     query.limit(this.limit);
     query.skip(this.limit * (this.pageIndex - 1));

+ 9 - 0
projects/textbook/src/modules/nav-admin/page-process/process-list/process-list.component.html

@@ -8,6 +8,15 @@
   </nz-page-header-title>
   <nz-page-header-extra>
     <nz-space>
+      <button
+        style="background: #c6233f; border: 1px #c6233f"
+        *nzSpaceItem
+        nz-button
+        nzType="primary"
+        (click)="sendNoticeMSG()"
+      >
+        批量提醒
+      </button>
       <button
         style="background: #3e49b3; border: 1px #3e49b3"
         *nzSpaceItem

+ 19 - 0
projects/textbook/src/modules/nav-admin/page-process/process-list/process-list.component.ts

@@ -28,6 +28,7 @@ import { NzModalService } from 'ng-zorro-antd/modal';
 import { NzPopoverModule } from 'ng-zorro-antd/popover';
 import { setHours } from 'date-fns';
 import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
+import { textbookServer } from '../../../../services/textbook';
 interface nodes {
   title: string;
   key: string;
@@ -235,6 +236,7 @@ export class ProcessListComponent implements OnInit {
   collectEndData:any
 
   constructor(
+    public tbookSer: textbookServer,
     private route: Router,
     private activeRoute: ActivatedRoute,
     private nzContextMenuService: NzContextMenuService,
@@ -572,4 +574,21 @@ export class ProcessListComponent implements OnInit {
     this.getEduProcess()
     this.showModal = false
   }
+
+  /* 短信通知 */
+  sendNoticeMSG(){
+    this.modal.confirm({
+      nzTitle: '短信通知',
+      nzContent: '发送短信提醒所有已提交教材的教师及对应出版单位',
+      nzOkText: '发送',
+      nzOkType: 'primary',
+      nzOkDanger: true,
+      nzOnOk: () => {
+        this.tbookSer.sendNoticeMSG()
+        this.message.success('已发送')
+      },
+      nzCancelText: '取消',
+      nzOnCancel: () => console.log('Cancel')
+    });
+  }
 }

+ 87 - 37
projects/textbook/src/services/textbook.ts

@@ -319,7 +319,11 @@ export class textbookServer {
         isDate ||
         Object.prototype.toString.call(item.get(filed)).indexOf('Date') != -1
       ) {
-        arr.push(this.formatTime('YYYY-mm-dd', item.get(filed)) + '/'+ item.get('printNumber'));
+        arr.push(
+          this.formatTime('YYYY-mm-dd', item.get(filed)) +
+            '/' +
+            item.get('printNumber')
+        );
         isDate = true;
       } else {
         arr.push(item.get(filed));
@@ -348,20 +352,20 @@ export class textbookServer {
         'inviteUnit',
         'user.department',
         'department.branch',
-        'code',
+        'code'
         // 'eduProcess.profileSubmitted',
         // 'eduProcess.profileSubmitted.email',
         // 'eduProcess.profileSubmitted.user.name',
         // 'eduProcess.profileSubmitted.user.phone'
       );
-      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.ascending('createdAt')
-      let count = await query.count()
+      query.ascending('createdAt');
+      let count = await query.count();
       console.log(count);
       query.limit(2000);
-      query.skip(2000)
+      query.skip(2000);
       let data = await query.find();
       let table = `<table border="1px" cellspacing="0" cellpadding="0">
           <thead>
@@ -377,20 +381,20 @@ export class textbookServer {
           </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 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'));
@@ -497,26 +501,72 @@ export class textbookServer {
     document.body.removeChild(link);
   }
 
-  /* 获取所有未上传签名页附件教材 */
-  async get_authorSignPDF_def() {
+  /* 发送出版社及教师通知短信 */
+  async sendNoticeMSG() {
+    let teacherList = new Set<string>();
+    let unitList = new Set<string>(); //单位出版社
+
     let query = new Parse.Query('EduTextbook');
-    // let query = Parse.Query.fromJSON('EduTextbook', {
-    //   where: {
-    //     status:{$in: ['102','103','200','201','300']},
-    //     authorSignPDF
-    //   },
-    // });
-    let list: any = [];
+    query.equalTo('status', '400');
     query.notEqualTo('isDeleted', true);
-    query.containedIn('status', ['102', '103', '200', '201', '300']);
-    query.doesNotExist('authorSignPDF.url');
-    query.exists('code');
-    query.select('code');
+    query.notEqualTo('discard', true);
+    query.include('user.phone', 'childrens.editionUnit');
+    query.select('user.phone', 'childrens.editionUnit')
     query.limit(1000);
-    query.greaterThanOrEqualTo('createdAt', new Date('2024/8/5 00:00'));
     let r = await query.find();
-    // console.log(r);
-    r.forEach((item) => list.push(item.get('code')));
-    console.log(list);
+    r.forEach((item) => {
+      teacherList.add(item?.get('user')?.get('phone'));
+      item
+        .get('childrens')
+        ?.forEach((child: any) => unitList.add(child?.get('editionUnit')));
+    });
+    let teacherArr = Array.from(teacherList);
+    let unitArr = Array.from(unitList);
+    console.log('教师电话:',teacherArr);
+    // console.log(unitArr);
+
+    // Parse.Cloud.run('aliSmsSend', {
+    //   mobileList: [teacherArr],
+    //   templateCode: 'SMS_468870790',
+    //   params: {},
+    //   signName: '普通高等教育教材网',
+    // });
+    let queryParams: any = {
+      where: {
+        $or: [
+          {
+            department: {
+              $inQuery: {
+                where: {
+                  name: { $in: unitArr },
+                },
+                className: 'Department',
+              }
+            },
+          },
+        ],
+      },
+    };
+    let queryEduProcess = Parse.Query.fromJSON('EduProcess', queryParams);
+    queryEduProcess.include('profileSubmitted.user');
+    queryEduProcess.select('profileSubmitted.user.phone')
+    query.limit(1000)
+    let list = await queryEduProcess.find();
+    // console.log(list);
+    let unitPhoneList = new Set<string>(); //出版单位联系人
+    list.map(item=> {
+      if(item?.get('profileSubmitted')?.get('user')?.get('phone')){
+        unitPhoneList.add(item?.get('profileSubmitted')?.get('user')?.get('phone'))
+      }
+    })
+    let unitPhoneArr = Array.from(unitPhoneList)
+    // Parse.Cloud.run('aliSmsSend', {
+    //   mobileList: [unitPhoneArr],
+    //   templateCode: 'SMS_468870790',
+    //   params: {},
+    //   signName: '普通高等教育教材网',
+    // });
+    console.log('出版社电话:',unitPhoneArr);
+    
   }
 }