1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252 |
- import { Injectable } from '@angular/core';
- import Parse from 'parse';
- import { HttpClient } from '@angular/common/http';
- import { updateDept } from './importDept';
- import { ProvierOssAli } from '../app/comp-upload/provider-oss-aliyun';
- import { textbookServer } from './textbook';
- @Injectable({
- providedIn: 'root',
- })
- export class shellServer {
- ossProvider:
- | any
- | { upload: any; signatureUrl: any; download: any }
- | undefined;
- departments: {} | any = {};
- constructor(private http: HttpClient, private tbookSer: textbookServer) {
- this.ossProvider = new ProvierOssAli();
- }
- //格式化链
- async formatNode(id: string): Promise<Array<any>> {
- if (!id) return [];
- if (Object.keys(this.departments).length == 0) {
- let query = new Parse.Query('Department');
- query.select('name', 'parent.objectId');
- query.containedIn('branch', [
- '有关部门(单位)教育司(局)',
- '省级教育行政部门',
- ]);
- query.ascending('createdAt');
- query.limit(4000);
- let r = await query.find();
- this.departments = {
- '66865e1c5d561921fb4d6764': { name: '省级教育行政部门' },
- '66865deea3ac903090a7b30b': { name: '有关部门(单位)教育司(局)' },
- };
- r?.forEach((item) => {
- this.departments[item.id] = item.toJSON();
- });
- // console.log(this.departments);
- }
- try {
- let arr = [
- {
- title: this.departments[id].name,
- },
- ];
- if (this.departments[id]?.parent?.objectId) {
- arr.unshift(
- ...(await this.formatNode(this.departments[id].parent.objectId))
- );
- }
- // let query = new Parse.Query('Department');
- // query.select('name', 'parent.name', 'branch');
- // let r = await query.get(id);
- // let arr = [
- // {
- // title: r.get('name'),
- // key: r.id,
- // branch: r?.get('branch'),
- // parent: r?.get('parent')?.id, //上级
- // },
- // ];
- // if (r?.get('parent')) {
- // arr.unshift(...(await this.formatNode(r?.get('parent').id)));
- // }
- return arr;
- } catch (err) {
- console.warn(err);
- console.log(id);
- return [];
- }
- }
- /* 获取已有联系人出版单位、未注册联系人出版单位 */
- async getUnitList() {
- let title = '未注册出版社';
- let arr = [
- '甘肃人民出版社',
- '河南人民出版社',
- '湖南人民出版社',
- '江苏人民出版社',
- '企业管理出版社',
- '海洋出版社',
- '线装书局',
- '中国工人出版社',
- '中国海关出版社',
- '中国青年出版总社',
- '中国原子能出版社',
- '中国标准出版社',
- '国家图书馆出版社',
- '中国戏剧出版社',
- '北京人民出版社',
- '中国社会科学出版社',
- '新星出版社',
- '河北大学出版社',
- '测试流程开始',
- '北京科学技术出版社',
- '吉林人民出版社',
- '南京东南大学出版社',
- '陕西师范大学出版总社',
- '上海教育出版社',
- '成都西南交大出版社',
- '重庆西南师范大学电子音像出版社',
- ];
- let unitMap: any = {};
- let unitList = new Set<string>(); //单位出版社
- let queryParamsbook: any = {
- where: {
- $or: [
- {
- childrens: {
- $inQuery: {
- where: {
- editionUnit: { $in: arr },
- },
- className: 'EduTextbookVolume',
- },
- },
- },
- ],
- },
- };
- let query = Parse.Query.fromJSON('EduTextbook', queryParamsbook);
- query.equalTo('status', '400');
- query.notEqualTo('isDeleted', true);
- query.notEqualTo('discard', true);
- query.include('user.phone', 'user.name', 'childrens.editionUnit');
- query.select('user.phone', 'user.name', 'childrens.editionUnit');
- query.limit(10000);
- let r = await query.find();
- let tb = `<table border="1px" cellspacing="0" cellpadding="0">
- <thead>
- <tr>
- <th>手机号</th>
- <th>姓名</th>
- <th>关联出版社</th>
- </tr>
- </thead>
- <tbody>
- `;
- let _body = '';
- for (let row = 0; row < r.length; row++) {
- _body += '<tr>';
- _body += '<td>';
- _body += ` ${r[row]?.get('user')?.get('phone') || ''}`;
- _body += '</td>';
- _body += '<td>';
- _body += `${r[row]?.get('user')?.get('name') || ''}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${
- this.fromatFiled(r[row]?.get('childrens'), 'editionUnit') || ''
- }`;
- _body += '</td>';
- _body += '</tr>';
- }
- tb += _body;
- tb += '</tbody>';
- tb += '</table>';
- this.excel(tb, `${title}.xls`);
- return;
- r.forEach((item) => {
- item.get('childrens')?.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: [
- {
- department: {
- $inQuery: {
- where: {
- name: { $in: unitArr },
- },
- className: 'Department',
- },
- },
- },
- ],
- },
- };
- let queryEduProcess = Parse.Query.fromJSON('EduProcess', queryParams);
- queryEduProcess.include('profileSubmitted.user');
- queryEduProcess.select('profileSubmitted.user.phone', 'name');
- queryEduProcess.notEqualTo('isDeleted', true);
- queryEduProcess.limit(1000);
- let list = await queryEduProcess.find();
- // console.log(list);
- let unitPhoneList = new Set<string>(); //出版单位联系人
- let notUnitPhoneList = new Set<string>(); //出版单位联系人
- list.map((item) => {
- if (item?.get('profileSubmitted')?.get('user')?.get('phone')) {
- // unitPhoneList.add(item?.get('profileSubmitted')?.get('user')?.get('phone'))
- unitPhoneList.add(item?.get('name'));
- } else {
- notUnitPhoneList.add(item?.get('name'));
- }
- });
- let a = Array.from(unitPhoneList),
- b = Array.from(notUnitPhoneList);
- console.log('已注册联系:', Array.from(unitPhoneList));
- console.log('未注册联系:', Array.from(notUnitPhoneList));
- return;
- // let len = a.length > b.length ? a.length : b.length
- // let table = `<table border="1px" cellspacing="0" cellpadding="0">
- // <thead>
- // <tr>
- // <th>已注册</th>
- // <th>教材数量</th>
- // <th>未注册</th>
- // <th>教材数量</th>
- // </tr>
- // </thead>
- // <tbody>
- // `;
- // let _body = '';
- // for (let row = 0; row < len; row++) {
- // _body += '<tr>';
- // _body += '<td>';
- // _body += `${a[row] || ''}`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += `${unitMap[a[row]] || ''}`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${b[row] || ''}`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += `${unitMap[b[row]] || ''}`;
- // _body += '</td>';
- // _body += '</tr>';
- // }
- // table += _body;
- // table += '</tbody>';
- // table += '</table>';
- // this.excel(table, `${title}.xls`);
- }
- /* 获取高等教育出版社教材 */
- async getGdjy() {
- let queryParams: any = {
- where: {
- $or: [
- {
- childrens: {
- $inQuery: {
- where: {
- editionUnit: '高等教育出版社',
- },
- className: 'EduTextbookVolume',
- },
- },
- },
- ],
- },
- };
- let query = Parse.Query.fromJSON('EduTextbook', queryParams);
- query.equalTo('status', '400');
- query.notEqualTo('isDeleted', true);
- query.notEqualTo('discard', true);
- query.include('user');
- query.limit(2000);
- 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 (let 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,
- numFiled?: string
- ): string {
- let arr: Array<string | null> = [];
- let isDate = false;
- // 监测空值
- list?.forEach((item: Parse.Object) => {
- if (
- isDate ||
- Object.prototype.toString.call(item.get(filed)).indexOf('Date') != -1
- ) {
- if (numFiled) {
- arr.push(
- this.tbookSer.formatTime('YYYY-mm', item.get(filed)) +
- '(' +
- item.get(numFiled) +
- ')'
- );
- } else {
- arr.push(this.tbookSer.formatTime('YYYY-mm', item.get(filed)));
- }
- isDate = true;
- } else {
- arr.push(item.get(filed));
- // if(filed == 'importantProject'){
- // console.log(item.get(filed));
- // }
- }
- });
- let j = Array.from(arr).join(',');
- if (!isDate || filed != 'printSum') {
- j = Array.from(new Set(arr)).join(' ');
- }
- return j || '-';
- }
- //导出表格
- async exportEduTextbook() {
- 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');
- query.notEqualTo('isDeleted', true);
- query.notEqualTo('discard', true);
- query.equalTo('render', true);
- query.select(
- 'title',
- 'childrens.ISBN',
- 'childrens.author',
- 'childrens.unit',
- 'childrens.printDate',
- 'childrens.printNumber',
- 'childrens.editionUnit',
- 'childrens.carrierShape',
- 'childrens.lang',
- 'childrens.editionFirst',
- 'childrens.editionDate',
- 'childrens.editionNumber',
- 'childrens.printSum',
- 'childrens.importantProject',
- 'childrens.collectFiles',
- 'childrens.collectLink',
- 'childrens.collectDigitFiles',
- 'childrens.collectCheck',
- 'childrens.authorList',
- 'user.department',
- 'department.branch',
- 'code',
- 'discipline',
- 'majorPoniter',
- 'approval',
- 'inviteUnit',
- 'eduProcess.profileSubmitted',
- 'eduProcess.profileSubmitted.email',
- 'eduProcess.profileSubmitted.user.name',
- 'eduProcess.profileSubmitted.user.phone',
- 'type',
- 'major'
- );
- // 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();
- console.log(count);
- 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 = this.tableAuthors;
- let _body = '';
- _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 += ` ${data[row]?.get('code') || ''}`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${data[row]?.get('title') || '-'}`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${
- // data[row]?.get('discipline')?.code +
- // '-' +
- // data[row]?.get('discipline')?.name
- // }`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${
- // data[row]?.get('majorPoniter')?.code +
- // '-' +
- // data[row]?.get('majorPoniter')?.name
- // }`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${data[row]?.get('approval') || '否'}`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${data[row]?.get('inviteUnit') || ''}`;
- // // _body += ` ${inviteUnit || ''}`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${
- // data[row]
- // ?.get('eduProcess')
- // ?.get('profileSubmitted')
- // ?.get('user')
- // ?.get('name') || ''
- // }`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${
- // data[row]
- // ?.get('eduProcess')
- // ?.get('profileSubmitted')
- // ?.get('user')
- // ?.get('phone') || ''
- // }`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${
- // 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 += ` ${this.fromatFiled(
- // data[row]?.get('childrens'),
- // 'ISBN'
- // )}`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += `${this.fromatFiled(
- // data[row]?.get('childrens'),
- // 'editionUnit'
- // )}`;
- // _body += '</td>';
- // _body += '<td>';
- // _body += ` ${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 += ` ${
- // 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>';
- 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 += ` ${i++}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${data[row]?.get('title') || '-'}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${data[row]?.get('code') || ''}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${val.get('editionUnit')}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${val.get('unit')}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${author?.name}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${author?.unit}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${this.tbookSer.formatTime(
- 'YYYY-mm',
- author?.birth
- )}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${author?.nationality}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${author?.job}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${author?.title}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${author?.mobile}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${author?.email}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${author?.work}`;
- _body += '</td>';
- _body += '</tr>';
- }
- });
- });
- }
- return _body;
- }
- /* 格式化拓展表字段教材文件 */
- fromatFiledCollect(list: Array<Parse.Object>, radioValue?: string): string {
- let arr: Array<string | null> = [];
- // 监测空值
- list?.forEach((item: Parse.Object) => {
- if (radioValue) {
- switch (radioValue) {
- case '链接':
- item.get('collectCheck') == '链接' &&
- arr.push('链接:' + item.get('collectLink').url);
- break;
- case '链接和账号密码':
- item.get('collectCheck') == '链接和账号密码' &&
- arr.push(`链接:lian${item.get('collectLink').url}
- 账号:lian${item.get('collectLink').username}
- 密码:lian${item.get('collectLink').password}
- `);
- break;
- default:
- if (item.get('collectCheck') == '上传文件') {
- let list: Array<string> = [];
- item
- .get('collectDigitFiles')
- ?.forEach((i: any) => list.push(i.name));
- arr.push(...list);
- }
- break;
- }
- } else {
- let list: Array<string> = [];
- item.get('collectFiles')?.forEach((i: any) => list.push(i.name));
- arr.push(...list);
- }
- });
- let j = Array.from(arr).join(',');
- return j || '-';
- }
- //导出所有流程申报表格
- async exportEduProcess() {
- try {
- let queryProcs = new Parse.Query('EduProcess');
- queryProcs.include('profileSubmitted', 'profileSubmitted.user');
- queryProcs.select('name', 'profileSubmitted');
- // queryProcs.notEqualTo('branch','66865d66ad23a23355b12aa7')
- 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++) {
- const r = resEduProcess[index];
- // let query = new Parse.Query('EduTextbook');
- let query = new Parse.Query('EduTextbook');
- query.notEqualTo('isDeleted', true);
- query.notEqualTo('discard', true);
- query.equalTo('eduProcess', r.id);
- query.equalTo('render', true);
- query.containedIn('status', ['400']);
- query.ascending('createdAt');
- query.select(
- 'title',
- 'childrens.ISBN',
- 'childrens.author',
- 'childrens.unit',
- 'childrens.printDate',
- 'childrens.printNumber',
- 'childrens.editionUnit',
- 'childrens.carrierShape',
- 'childrens.lang',
- 'childrens.editionFirst',
- 'childrens.editionDate',
- 'childrens.editionNumber',
- 'childrens.printSum',
- 'childrens.importantProject',
- 'childrens.collectFiles',
- 'childrens.collectLink',
- 'childrens.collectDigitFiles',
- 'childrens.collectCheck',
- 'typeNumber',
- 'user.department',
- 'department.branch',
- 'code',
- 'discipline',
- 'majorPoniter',
- 'approval',
- 'inviteUnit',
- // 'eduProcess.profileSubmitted',
- // 'eduProcess.profileSubmitted.email',
- // 'eduProcess.profileSubmitted.user.name',
- // 'eduProcess.profileSubmitted.user.phone',
- 'type',
- 'major'
- );
- query.limit(500);
- let data = await query.find();
- let table = `<table border="1px" cellspacing="0" cellpadding="0">
- <thead>
- <tr>
- <th colspan="10" style="font-size: 20px;font-family: '黑体';">“十四五”普通高等教育本科国家级规划教材推荐汇总表</th>
- </tr>
- <tr>
- <th></th><th></th><th></th><th></th><th></th>
- <th></th><th></th><th></th><th></th><th></th>
- </tr>
- <tr>
- <th></th><th></th><th></th><th></th><th></th>
- <th></th><th></th><th></th><th></th><th></th>
- </tr>
- <tr>
- <th></th><th></th>
- <th style="font-size: 12px;font-family: '黑体';text-align: left;">单位名称(公章):</th>
- <th colspan="3" style="font-size: 12px;font-family: '黑体';text-align: left;">${r?.get(
- 'name'
- )}</th>
- <th></th><th></th><th></th><th></th>
- </tr>
- <tr>
- <th></th><th></th><th></th><th></th><th></th>
- <th></th><th></th><th></th><th></th><th></th>
- </tr>
- <tr>
- <th></th><th></th>
- <th style="font-size: 12px;font-family: '黑体';text-align: left;">申报工作联系人:</th>
- <th colspan="2" style="font-size: 12px;font-family: '黑体';text-align: left;">姓名 ${r
- ?.get('profileSubmitted')
- ?.get('user')
- ?.get('name')}</th>
- <th colspan="2" style="font-size: 12px;font-family: '黑体';text-align: left;">电话 ${r
- ?.get('profileSubmitted')
- ?.get('user')
- ?.get('phone')}</th>
- <th></th><th></th><th></th>
- </tr>
- <tr>
- <th></th><th></th><th></th><th></th><th></th>
- <th></th><th></th><th></th><th></th><th></th>
- </tr>
- <tr>
- <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>
- `;
- let _body = '';
- for (let row = 0; row < data.length; row++) {
- _body += '<tr>';
- _body += '<td>';
- _body += `${row + 1}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${data[row].get('code') || ''}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${data[row].get('title') || '-'}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${
- (data[row].get('discipline')?.code || '') +
- '/' +
- (data[row]?.get('discipline')?.name || '')
- }`;
- _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 += `${
- data[row]?.get('type') == '单本'
- ? '单本'
- : '全册 - ' + data[row]?.get('typeNumber') || '-'
- }`;
- _body += '</td>';
- _body += '<td>';
- _body += `${data[row]?.get('approval') || '-'}`;
- _body += '</td>';
- _body += '<td>';
- _body += `${this.fromatFiled(
- data[row]?.get('childrens'),
- 'editionUnit'
- )}`;
- _body += '</td>';
- _body += '<td>';
- _body += ` ${this.fromatFiled(
- data[row]?.get('childrens'),
- 'editionFirst'
- )}`;
- _body += '</td>';
- _body += '<td>';
- _body += `${this.fromatFiled(
- data[row]?.get('childrens'),
- 'carrierShape'
- )}`;
- _body += '</td>';
- _body += '</tr>';
- }
- table += _body;
- table += '</tbody>';
- table += '</table>';
- let title = r?.get('name') + ' 推荐汇总表';
- this.excel(table, `${title}.xls`);
- }
- } catch (err) {}
- }
- excel(data: any, filename: string) {
- let html =
- "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";
- html +=
- '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';
- html += '<meta http-equiv="content-type" content="application/vnd.ms-excel';
- html += '; charset=UTF-8">';
- html += '<head>';
- html += '</head>';
- html += '<body>';
- html += data;
- html += '</body>';
- html += '</html>';
- let uri =
- 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(html);
- let link = document.createElement('a');
- link.href = uri;
- link.download = `${filename}`;
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- }
- /* 发送出版社及教师通知短信 */
- async sendNoticeMSG() {
- let teacherList = new Set<string>();
- let unitList = new Set<string>(); //单位出版社
- let query = new Parse.Query('EduTextbook');
- query.equalTo('status', '400');
- query.notEqualTo('isDeleted', true);
- query.notEqualTo('discard', true);
- query.include('user.phone', 'childrens.editionUnit');
- query.select('user.phone', 'childrens.editionUnit');
- query.limit(10000);
- let r = await query.find();
- 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);
- let last = teacherArr.slice(5000, 5999);
- last.push(...['13581837652', '13407973043', '18510409671']);
- console.log(last);
- 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: [
- {
- department: {
- $inQuery: {
- where: {
- name: { $in: unitArr },
- },
- className: 'Department',
- },
- },
- },
- ],
- },
- };
- let queryEduProcess = Parse.Query.fromJSON('EduProcess', queryParams);
- queryEduProcess.include('profileSubmitted.user');
- queryEduProcess.select('profileSubmitted.user.phone');
- queryEduProcess.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);
- unitPhoneArr.push(...['13581837652', '13407973043', '18510409671']);
- // Parse.Cloud.run('aliSmsSend', {
- // mobileList: [unitPhoneArr],
- // templateCode: 'SMS_474290139',
- // params: {end_date:'2024-10-20 16:00'},
- // signName: '普通高等教育教材网',
- // });
- console.log('出版社电话:', unitPhoneArr);
- }
- /* 获取10月9号之前上传的教材文件转私有 */
- async getEtxVolCollect() {
- let queryParams: any = {
- where: {
- $or: [
- {
- collectFiles: { $exists: true },
- collectDigitFiles: { $exists: true },
- },
- ],
- },
- };
- let query = Parse.Query.fromJSON('EduTextbookVolume', queryParams);
- query.lessThan('updatedAt', new Date('2024-10-10 18:00'));
- query.select('collectFiles', 'collectDigitFiles');
- query.limit(2000);
- let r = await query.find();
- let urlList: Array<string> = [];
- r.forEach((item) => {
- item?.get('collectFiles')?.forEach((f: any) => {
- urlList.push(f?.url);
- });
- item?.get('collectDigitFiles')?.forEach((d: any) => {
- urlList.push(d?.url);
- });
- });
- console.log(urlList);
- for (let index = 0; index < urlList.length; index++) {
- const u = urlList[index];
- console.log(u);
- // await this.ossProvider?.setACLPrivate(u)
- }
- }
- /* 更新教材个别字段 */
- async updateTextbook() {
- let arr = [];
- let list = updateDept.list6;
- for (let index = 0; index < list.length; index++) {
- const item = list[index];
- // let oldc=item.code.substring(0,item.code.length-1)
- // console.log(oldc);
- let query = new Parse.Query('EduTextbook');
- query.equalTo('code', item.code);
- query.notEqualTo('isDeleted', true);
- // query.equalTo('title',item.title)
- query.include('childrens');
- query.select('childrens');
- let r = await query.find();
- if (r.length < 1 || r.length > 1 || r[0]?.get('childrens').length > 1) {
- // if(r.length !== 1){
- arr.push(item.code);
- continue;
- }
- let eduTextbookVolume = r[0]?.get('childrens')[0];
- item.type.trim() != '暂无' &&
- eduTextbookVolume?.set('carrierShape', item.type.trim());
- item.isbn.trim() != '暂无' &&
- eduTextbookVolume?.set('ISBN', item.isbn.trim());
- await eduTextbookVolume?.save();
- // r[0]?.set('code',item.code)
- r[0]?.set('exportPDF', null);
- await r[0]?.save();
- console.log('update=>', item);
- }
- console.log('update over');
- console.log(arr);
- }
- /* 导出评审系统表格数据 */
- async exportUrl() {
- let unitName = '教材文件excel';
- let query = new Parse.Query('EduTextbook');
- query.notEqualTo('isDeleted', true);
- query.notEqualTo('discard', true);
- query.equalTo('render', true);
- query.select('title', 'code');
- query.containedIn('status', ['400']);
- 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>
- </tr>
- </thead>
- <tbody>
- `;
- let _body = '';
- for (let 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 += `https://145.tbook.com.cn/external/review/detail/${data[row].id}`;
- _body += '</td>';
- _body += '</tr>';
- }
- table += _body;
- table += '</tbody>';
- table += '</table>';
- this.excel(table, `${unitName}.xls`);
- }
- }
|