shell.ts 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. import { Injectable } from '@angular/core';
  2. import Parse from 'parse';
  3. import { HttpClient } from '@angular/common/http';
  4. import { updateDept } from './importDept';
  5. import { ProvierOssAli } from '../app/comp-upload/provider-oss-aliyun';
  6. import { textbookServer } from './textbook';
  7. @Injectable({
  8. providedIn: 'root',
  9. })
  10. export class shellServer {
  11. ossProvider:
  12. | any
  13. | { upload: any; signatureUrl: any; download: any }
  14. | undefined;
  15. departments: {} | any = {};
  16. constructor(private http: HttpClient, private tbookSer: textbookServer) {
  17. this.ossProvider = new ProvierOssAli();
  18. }
  19. //格式化链
  20. async formatNode(id: string): Promise<Array<any>> {
  21. if (!id) return [];
  22. if (Object.keys(this.departments).length == 0) {
  23. let query = new Parse.Query('Department');
  24. query.select('name', 'parent.objectId');
  25. query.containedIn('branch', [
  26. '有关部门(单位)教育司(局)',
  27. '省级教育行政部门',
  28. ]);
  29. query.ascending('createdAt');
  30. query.limit(4000);
  31. let r = await query.find();
  32. this.departments = {
  33. '66865e1c5d561921fb4d6764': { name: '省级教育行政部门' },
  34. '66865deea3ac903090a7b30b': { name: '有关部门(单位)教育司(局)' },
  35. };
  36. r?.forEach((item) => {
  37. this.departments[item.id] = item.toJSON();
  38. });
  39. // console.log(this.departments);
  40. }
  41. try {
  42. let arr = [
  43. {
  44. title: this.departments[id].name,
  45. },
  46. ];
  47. if (this.departments[id]?.parent?.objectId) {
  48. arr.unshift(
  49. ...(await this.formatNode(this.departments[id].parent.objectId))
  50. );
  51. }
  52. // let query = new Parse.Query('Department');
  53. // query.select('name', 'parent.name', 'branch');
  54. // let r = await query.get(id);
  55. // let arr = [
  56. // {
  57. // title: r.get('name'),
  58. // key: r.id,
  59. // branch: r?.get('branch'),
  60. // parent: r?.get('parent')?.id, //上级
  61. // },
  62. // ];
  63. // if (r?.get('parent')) {
  64. // arr.unshift(...(await this.formatNode(r?.get('parent').id)));
  65. // }
  66. return arr;
  67. } catch (err) {
  68. console.warn(err);
  69. console.log(id);
  70. return [];
  71. }
  72. }
  73. /* 获取已有联系人出版单位、未注册联系人出版单位 */
  74. async getUnitList() {
  75. let title = '未注册出版社';
  76. let arr = [
  77. '甘肃人民出版社',
  78. '河南人民出版社',
  79. '湖南人民出版社',
  80. '江苏人民出版社',
  81. '企业管理出版社',
  82. '海洋出版社',
  83. '线装书局',
  84. '中国工人出版社',
  85. '中国海关出版社',
  86. '中国青年出版总社',
  87. '中国原子能出版社',
  88. '中国标准出版社',
  89. '国家图书馆出版社',
  90. '中国戏剧出版社',
  91. '北京人民出版社',
  92. '中国社会科学出版社',
  93. '新星出版社',
  94. '河北大学出版社',
  95. '测试流程开始',
  96. '北京科学技术出版社',
  97. '吉林人民出版社',
  98. '南京东南大学出版社',
  99. '陕西师范大学出版总社',
  100. '上海教育出版社',
  101. '成都西南交大出版社',
  102. '重庆西南师范大学电子音像出版社',
  103. ];
  104. let unitMap: any = {};
  105. let unitList = new Set<string>(); //单位出版社
  106. let queryParamsbook: any = {
  107. where: {
  108. $or: [
  109. {
  110. childrens: {
  111. $inQuery: {
  112. where: {
  113. editionUnit: { $in: arr },
  114. },
  115. className: 'EduTextbookVolume',
  116. },
  117. },
  118. },
  119. ],
  120. },
  121. };
  122. let query = Parse.Query.fromJSON('EduTextbook', queryParamsbook);
  123. query.equalTo('status', '400');
  124. query.notEqualTo('isDeleted', true);
  125. query.notEqualTo('discard', true);
  126. query.include('user.phone', 'user.name', 'childrens.editionUnit');
  127. query.select('user.phone', 'user.name', 'childrens.editionUnit');
  128. query.limit(10000);
  129. let r = await query.find();
  130. let tb = `<table border="1px" cellspacing="0" cellpadding="0">
  131. <thead>
  132. <tr>
  133. <th>手机号</th>
  134. <th>姓名</th>
  135. <th>关联出版社</th>
  136. </tr>
  137. </thead>
  138. <tbody>
  139. `;
  140. let _body = '';
  141. for (let row = 0; row < r.length; row++) {
  142. _body += '<tr>';
  143. _body += '<td>';
  144. _body += `&nbsp;${r[row]?.get('user')?.get('phone') || ''}`;
  145. _body += '</td>';
  146. _body += '<td>';
  147. _body += `${r[row]?.get('user')?.get('name') || ''}`;
  148. _body += '</td>';
  149. _body += '<td>';
  150. _body += ` &nbsp;${
  151. this.fromatFiled(r[row]?.get('childrens'), 'editionUnit') || ''
  152. }`;
  153. _body += '</td>';
  154. _body += '</tr>';
  155. }
  156. tb += _body;
  157. tb += '</tbody>';
  158. tb += '</table>';
  159. this.excel(tb, `${title}.xls`);
  160. return;
  161. r.forEach((item) => {
  162. item.get('childrens')?.forEach((child: any) => {
  163. if (!child?.get('editionUnit')) {
  164. console.log(item);
  165. }
  166. unitList.add(child?.get('editionUnit'));
  167. unitMap[child?.get('editionUnit')] = unitMap[child?.get('editionUnit')]
  168. ? unitMap[child?.get('editionUnit')] + 1
  169. : 1;
  170. });
  171. });
  172. let unitArr = Array.from(unitList);
  173. console.log('已被选择的申报单位:', unitArr);
  174. console.log(unitMap);
  175. let queryParams: any = {
  176. where: {
  177. $or: [
  178. {
  179. department: {
  180. $inQuery: {
  181. where: {
  182. name: { $in: unitArr },
  183. },
  184. className: 'Department',
  185. },
  186. },
  187. },
  188. ],
  189. },
  190. };
  191. let queryEduProcess = Parse.Query.fromJSON('EduProcess', queryParams);
  192. queryEduProcess.include('profileSubmitted.user');
  193. queryEduProcess.select('profileSubmitted.user.phone', 'name');
  194. queryEduProcess.notEqualTo('isDeleted', true);
  195. queryEduProcess.limit(1000);
  196. let list = await queryEduProcess.find();
  197. // console.log(list);
  198. let unitPhoneList = new Set<string>(); //出版单位联系人
  199. let notUnitPhoneList = new Set<string>(); //出版单位联系人
  200. list.map((item) => {
  201. if (item?.get('profileSubmitted')?.get('user')?.get('phone')) {
  202. // unitPhoneList.add(item?.get('profileSubmitted')?.get('user')?.get('phone'))
  203. unitPhoneList.add(item?.get('name'));
  204. } else {
  205. notUnitPhoneList.add(item?.get('name'));
  206. }
  207. });
  208. let a = Array.from(unitPhoneList),
  209. b = Array.from(notUnitPhoneList);
  210. console.log('已注册联系:', Array.from(unitPhoneList));
  211. console.log('未注册联系:', Array.from(notUnitPhoneList));
  212. return;
  213. // let len = a.length > b.length ? a.length : b.length
  214. // let table = `<table border="1px" cellspacing="0" cellpadding="0">
  215. // <thead>
  216. // <tr>
  217. // <th>已注册</th>
  218. // <th>教材数量</th>
  219. // <th>未注册</th>
  220. // <th>教材数量</th>
  221. // </tr>
  222. // </thead>
  223. // <tbody>
  224. // `;
  225. // let _body = '';
  226. // for (let row = 0; row < len; row++) {
  227. // _body += '<tr>';
  228. // _body += '<td>';
  229. // _body += `${a[row] || ''}`;
  230. // _body += '</td>';
  231. // _body += '<td>';
  232. // _body += `${unitMap[a[row]] || ''}`;
  233. // _body += '</td>';
  234. // _body += '<td>';
  235. // _body += ` &nbsp;${b[row] || ''}`;
  236. // _body += '</td>';
  237. // _body += '<td>';
  238. // _body += `${unitMap[b[row]] || ''}`;
  239. // _body += '</td>';
  240. // _body += '</tr>';
  241. // }
  242. // table += _body;
  243. // table += '</tbody>';
  244. // table += '</table>';
  245. // this.excel(table, `${title}.xls`);
  246. }
  247. /* 获取高等教育出版社教材 */
  248. async getGdjy() {
  249. let queryParams: any = {
  250. where: {
  251. $or: [
  252. {
  253. childrens: {
  254. $inQuery: {
  255. where: {
  256. editionUnit: '高等教育出版社',
  257. },
  258. className: 'EduTextbookVolume',
  259. },
  260. },
  261. },
  262. ],
  263. },
  264. };
  265. let query = Parse.Query.fromJSON('EduTextbook', queryParams);
  266. query.equalTo('status', '400');
  267. query.notEqualTo('isDeleted', true);
  268. query.notEqualTo('discard', true);
  269. query.include('user');
  270. query.limit(2000);
  271. let data = await query.find();
  272. console.log(data);
  273. let table = `<table border="1px" cellspacing="0" cellpadding="0">
  274. <thead>
  275. <tr>
  276. <th>教材名称</th>
  277. <th>申报编号</th>
  278. <th>用户名</th>
  279. <th>手机号</th>
  280. <th>专业类</th>
  281. </tr>
  282. </thead>
  283. <tbody>
  284. `;
  285. let _body = '';
  286. for (let row = 0; row < data.length; row++) {
  287. _body += '<tr>';
  288. _body += '<td>';
  289. _body += `${data[row]?.get('title') || ''}`;
  290. _body += '</td>';
  291. _body += '<td>';
  292. _body += `&nbsp;${data[row]?.get('code') || ''}`;
  293. _body += '</td>';
  294. _body += '<td>';
  295. _body += `${data[row]?.get('user')?.get('name') || ''}`;
  296. _body += '</td>';
  297. _body += '<td>';
  298. _body += `${data[row]?.get('user')?.get('phone') || ''}`;
  299. _body += '</td>';
  300. _body += '<td>';
  301. _body += `${
  302. data[row]?.get('discipline')?.code +
  303. '/' +
  304. data[row]?.get('discipline')?.name || ''
  305. }`;
  306. _body += '</td>';
  307. _body += '</tr>';
  308. }
  309. table += _body;
  310. table += '</tbody>';
  311. table += '</table>';
  312. let title = '高等教育出版社';
  313. this.excel(table, `${title}.xls`);
  314. }
  315. /* 格式化拓展表字段 */
  316. fromatFiled(
  317. list: Array<Parse.Object>,
  318. filed: string,
  319. numFiled?: string
  320. ): string {
  321. let arr: Array<string | null> = [];
  322. let isDate = false;
  323. // 监测空值
  324. list?.forEach((item: Parse.Object) => {
  325. if (
  326. isDate ||
  327. Object.prototype.toString.call(item.get(filed)).indexOf('Date') != -1
  328. ) {
  329. if (numFiled) {
  330. arr.push(
  331. this.tbookSer.formatTime('YYYY-mm', item.get(filed)) +
  332. '(' +
  333. item.get(numFiled) +
  334. ')'
  335. );
  336. } else {
  337. arr.push(this.tbookSer.formatTime('YYYY-mm', item.get(filed)));
  338. }
  339. isDate = true;
  340. } else {
  341. arr.push(item.get(filed));
  342. // if(filed == 'importantProject'){
  343. // console.log(item.get(filed));
  344. // }
  345. }
  346. });
  347. let j = Array.from(arr).join(',');
  348. if (!isDate || filed != 'printSum') {
  349. j = Array.from(new Set(arr)).join(' ');
  350. }
  351. return j || '-';
  352. }
  353. //导出表格
  354. async exportEduTextbook() {
  355. let unitName = '全部教材作者';
  356. try {
  357. // let queryParams: any = {
  358. // where: {
  359. // $or: [
  360. // {
  361. // childrens: {
  362. // $inQuery: {
  363. // where: {
  364. // // editionUnit: unitName,
  365. // // collectStatus: { $ne: '200' },
  366. // collectStatus: '200',
  367. // },
  368. // className: 'EduTextbookVolume',
  369. // },
  370. // },
  371. // },
  372. // ],
  373. // },
  374. // };
  375. // let query = Parse.Query.fromJSON('EduTextbook', queryParams);
  376. let query = new Parse.Query('EduTextbook');
  377. query.notEqualTo('isDeleted', true);
  378. query.notEqualTo('discard', true);
  379. query.equalTo('render', true);
  380. query.select(
  381. 'title',
  382. 'childrens.ISBN',
  383. 'childrens.author',
  384. 'childrens.unit',
  385. 'childrens.printDate',
  386. 'childrens.printNumber',
  387. 'childrens.editionUnit',
  388. 'childrens.carrierShape',
  389. 'childrens.lang',
  390. 'childrens.editionFirst',
  391. 'childrens.editionDate',
  392. 'childrens.editionNumber',
  393. 'childrens.printSum',
  394. 'childrens.importantProject',
  395. 'childrens.collectFiles',
  396. 'childrens.collectLink',
  397. 'childrens.collectDigitFiles',
  398. 'childrens.collectCheck',
  399. 'childrens.authorList',
  400. 'user.department',
  401. 'department.branch',
  402. 'code',
  403. 'discipline',
  404. 'majorPoniter',
  405. 'approval',
  406. 'inviteUnit',
  407. 'eduProcess.profileSubmitted',
  408. 'eduProcess.profileSubmitted.email',
  409. 'eduProcess.profileSubmitted.user.name',
  410. 'eduProcess.profileSubmitted.user.phone',
  411. 'type',
  412. 'major'
  413. );
  414. // query.containedIn('status', ['102', '103', '200', '201', '400']);
  415. query.containedIn('status', ['400']);
  416. // query.containedIn('objectId',updateDept.list5)
  417. query.ascending('createdAt');
  418. let count = await query.count();
  419. console.log(count);
  420. query.limit(10000);
  421. query.skip(0);
  422. let data = await query.find();
  423. // let table = `<table border="1px" cellspacing="0" cellpadding="0">
  424. // <thead>
  425. // <tr>
  426. // <th>申报编号</th>
  427. // <th>申报教材名称</th>
  428. // <th>教材所属学科专业类</th>
  429. // <th>教材应用对象及所属学科专业类</th>
  430. // <th>是否为重点立项教材</th>
  431. // <th>申报部门</th>
  432. // <th>申报部门工作联系人</th>
  433. // <th>申报部门工作联系人手机号</th>
  434. // <th>申报部门工作联系人邮箱</th>
  435. // <th>申报类型</th>
  436. // <th>第一主编(作者)</th>
  437. // <th>第一主编(作者)单位</th>
  438. // <th>教材主要语种类型</th>
  439. // <th>国际标准书号(ISBN)</th>
  440. // <th>出版单位</th>
  441. // <th>初版时间</th>
  442. // <th>载体形式</th>
  443. // <th>本版出版时间及版次</th>
  444. // <th>最新印次时间及印次</th>
  445. // <th>初版以来合计印数</th>
  446. // <th>初版以来是否曾列为重点项目</th>
  447. // <th>适用专业代码(六位)及名称</th>
  448. // <th>申报状态</th>
  449. // <th>源文件状态</th>
  450. // <th>纸质教材PDF名称</th>
  451. // <th>数字教材链接</th>
  452. // <th>链接和账号密码</th>
  453. // <th>数字教材文件名称</th>
  454. // </tr>
  455. // </thead>
  456. // <tbody>
  457. // `;
  458. let table = this.tableAuthors;
  459. let _body = '';
  460. _body = await this.authors_body(data);
  461. // for (let row = 0; row < data.length; row++) {
  462. // let inviteUnit = data[row]?.get('inviteUnit');
  463. // if (
  464. // data[row]?.get('department')?.get('branch') == '省级教育行政部门' ||
  465. // data[row]?.get('department')?.get('branch') ==
  466. // '有关部门(单位)教育司(局)'
  467. // ) {
  468. // let parentMap = await this.formatNode(
  469. // data[row]?.get('user')?.get('department')?.id
  470. // );
  471. // inviteUnit = parentMap[2]?.title;
  472. // }
  473. // _body += '<tr>';
  474. // _body += '<td>';
  475. // _body += `&nbsp;${data[row]?.get('code') || ''}`;
  476. // _body += '</td>';
  477. // _body += '<td>';
  478. // _body += `&nbsp;${data[row]?.get('title') || '-'}`;
  479. // _body += '</td>';
  480. // _body += '<td>';
  481. // _body += `&nbsp;${
  482. // data[row]?.get('discipline')?.code +
  483. // '-' +
  484. // data[row]?.get('discipline')?.name
  485. // }`;
  486. // _body += '</td>';
  487. // _body += '<td>';
  488. // _body += `&nbsp;${
  489. // data[row]?.get('majorPoniter')?.code +
  490. // '-' +
  491. // data[row]?.get('majorPoniter')?.name
  492. // }`;
  493. // _body += '</td>';
  494. // _body += '<td>';
  495. // _body += `&nbsp;${data[row]?.get('approval') || '否'}`;
  496. // _body += '</td>';
  497. // _body += '<td>';
  498. // _body += `&nbsp;${data[row]?.get('inviteUnit') || ''}`;
  499. // // _body += `&nbsp;${inviteUnit || ''}`;
  500. // _body += '</td>';
  501. // _body += '<td>';
  502. // _body += `&nbsp;${
  503. // data[row]
  504. // ?.get('eduProcess')
  505. // ?.get('profileSubmitted')
  506. // ?.get('user')
  507. // ?.get('name') || ''
  508. // }`;
  509. // _body += '</td>';
  510. // _body += '<td>';
  511. // _body += `&nbsp;${
  512. // data[row]
  513. // ?.get('eduProcess')
  514. // ?.get('profileSubmitted')
  515. // ?.get('user')
  516. // ?.get('phone') || ''
  517. // }`;
  518. // _body += '</td>';
  519. // _body += '<td>';
  520. // _body += `&nbsp;${
  521. // data[row]?.get('eduProcess')?.get('profileSubmitted')?.get('email') ||
  522. // ''
  523. // }`;
  524. // _body += '</td>';
  525. // _body += '<td>';
  526. // _body += `${
  527. // data[row]?.get('type') == '单本'
  528. // ? '单本'
  529. // : '全册 - ' + data[row]?.get('childrens')?.length || '-'
  530. // }`;
  531. // _body += '</td>';
  532. // _body += '<td>';
  533. // _body += `${this.fromatFiled(data[row]?.get('childrens'), 'author')}`;
  534. // _body += '</td>';
  535. // _body += '<td>';
  536. // _body += `${this.fromatFiled(data[row]?.get('childrens'), 'unit')}`;
  537. // _body += '</td>';
  538. // _body += '<td>';
  539. // _body += `${this.fromatFiled(data[row]?.get('childrens'), 'lang')}`;
  540. // _body += '</td>';
  541. // _body += '<td>';
  542. // _body += `&nbsp;${this.fromatFiled(
  543. // data[row]?.get('childrens'),
  544. // 'ISBN'
  545. // )}`;
  546. // _body += '</td>';
  547. // _body += '<td>';
  548. // _body += `${this.fromatFiled(
  549. // data[row]?.get('childrens'),
  550. // 'editionUnit'
  551. // )}`;
  552. // _body += '</td>';
  553. // _body += '<td>';
  554. // _body += `&nbsp;${this.fromatFiled(
  555. // data[row]?.get('childrens'),
  556. // 'editionFirst'
  557. // )}`;
  558. // _body += '</td>';
  559. // _body += '<td>';
  560. // _body += `${this.fromatFiled(
  561. // data[row]?.get('childrens'),
  562. // 'carrierShape'
  563. // )}`;
  564. // _body += '</td>';
  565. // _body += '<td>';
  566. // _body += `${this.fromatFiled(
  567. // data[row]?.get('childrens'),
  568. // 'editionDate',
  569. // 'editionNumber'
  570. // )}`;
  571. // _body += '</td>';
  572. // _body += '<td>';
  573. // _body += `${this.fromatFiled(
  574. // data[row]?.get('childrens'),
  575. // 'printDate',
  576. // 'printNumber'
  577. // )}`;
  578. // _body += '</td>';
  579. // _body += '<td>';
  580. // _body += `${this.fromatFiled(data[row]?.get('childrens'), 'printSum')}`;
  581. // _body += '</td>';
  582. // _body += '<td>';
  583. // _body += `${this.fromatFiled(
  584. // data[row]?.get('childrens'),
  585. // 'importantProject'
  586. // )}`;
  587. // _body += '</td>';
  588. // _body += '<td>';
  589. // _body += `&nbsp;${
  590. // data[row]?.get('major')?.code + '-' + data[row]?.get('major')?.name
  591. // }`;
  592. // _body += '</td>';
  593. // _body += '<td>';
  594. // _body += `已报送`;
  595. // _body += '</td>';
  596. // _body += '<td>';
  597. // _body += `已上传`;
  598. // _body += '</td>';
  599. // _body += '<td>';
  600. // _body += `${this.fromatFiledCollect(data[row]?.get('childrens'))}`;
  601. // _body += '</td>';
  602. // _body += '<td>';
  603. // _body += `${this.fromatFiledCollect(
  604. // data[row]?.get('childrens'),
  605. // '链接'
  606. // )}`;
  607. // _body += '</td>';
  608. // _body += '<td>';
  609. // _body += `${this.fromatFiledCollect(
  610. // data[row]?.get('childrens'),
  611. // '链接和账号密码'
  612. // )}`;
  613. // _body += '</td>';
  614. // _body += '<td>';
  615. // _body += `${this.fromatFiledCollect(
  616. // data[row]?.get('childrens'),
  617. // '上传文件'
  618. // )}`;
  619. // _body += '</td>';
  620. // _body += '</tr>';
  621. // }
  622. table += _body;
  623. table += '</tbody>';
  624. table += '</table>';
  625. this.excel(table, `${unitName}.xls`);
  626. } catch (err) {
  627. console.log(err);
  628. }
  629. }
  630. // 导出作者
  631. tableAuthors: string = `<table border="1px" cellspacing="0" cellpadding="0">
  632. <thead>
  633. <tr>
  634. <th>序号</th>
  635. <th>申报教材名称</th>
  636. <th>申报编号</th>
  637. <th>出版单位</th>
  638. <th>主编所在单位</th>
  639. <th>姓名</th>
  640. <th>单位</th>
  641. <th>出生年月</th>
  642. <th>国籍</th>
  643. <th>职务</th>
  644. <th>职称</th>
  645. <th>手机号码</th>
  646. <th>电子邮箱</th>
  647. <th>主编/副主编/其他编者</th>
  648. </tr>
  649. </thead>
  650. <tbody>
  651. `;
  652. async authors_body(data: Array<Parse.Object>): Promise<string> {
  653. let _body = '';
  654. let i = 1;
  655. for (let row = 0; row < data.length; row++) {
  656. // let inviteUnit = data[row]?.get('inviteUnit');
  657. // if (
  658. // data[row]?.get('department')?.get('branch') == '省级教育行政部门' ||
  659. // data[row]?.get('department')?.get('branch') ==
  660. // '有关部门(单位)教育司(局)'
  661. // ) {
  662. // let parentMap = await this.formatNode(
  663. // data[row]?.get('user')?.get('department')?.id
  664. // );
  665. // inviteUnit = parentMap[2]?.title;
  666. // }
  667. data[row]?.get('childrens').forEach((val: Parse.Object) => {
  668. let authorSet = new Set();
  669. val.get('authorList').forEach((author: any) => {
  670. //避免重复
  671. if (!authorSet.has(author.name)) {
  672. authorSet.add(author.name);
  673. _body += '<tr>';
  674. _body += '<td>';
  675. _body += `&nbsp;${i++}`;
  676. _body += '</td>';
  677. _body += '<td>';
  678. _body += `&nbsp;${data[row]?.get('title') || '-'}`;
  679. _body += '</td>';
  680. _body += '<td>';
  681. _body += `&nbsp;${data[row]?.get('code') || ''}`;
  682. _body += '</td>';
  683. _body += '<td>';
  684. _body += `&nbsp;${val.get('editionUnit')}`;
  685. _body += '</td>';
  686. _body += '<td>';
  687. _body += `&nbsp;${val.get('unit')}`;
  688. _body += '</td>';
  689. _body += '<td>';
  690. _body += `&nbsp;${author?.name}`;
  691. _body += '</td>';
  692. _body += '<td>';
  693. _body += `&nbsp;${author?.unit}`;
  694. _body += '</td>';
  695. _body += '<td>';
  696. _body += `&nbsp;${this.tbookSer.formatTime(
  697. 'YYYY-mm',
  698. author?.birth
  699. )}`;
  700. _body += '</td>';
  701. _body += '<td>';
  702. _body += `&nbsp;${author?.nationality}`;
  703. _body += '</td>';
  704. _body += '<td>';
  705. _body += `&nbsp;${author?.job}`;
  706. _body += '</td>';
  707. _body += '<td>';
  708. _body += `&nbsp;${author?.title}`;
  709. _body += '</td>';
  710. _body += '<td>';
  711. _body += `&nbsp;${author?.mobile}`;
  712. _body += '</td>';
  713. _body += '<td>';
  714. _body += `&nbsp;${author?.email}`;
  715. _body += '</td>';
  716. _body += '<td>';
  717. _body += `&nbsp;${author?.work}`;
  718. _body += '</td>';
  719. _body += '</tr>';
  720. }
  721. });
  722. });
  723. }
  724. return _body;
  725. }
  726. /* 格式化拓展表字段教材文件 */
  727. fromatFiledCollect(list: Array<Parse.Object>, radioValue?: string): string {
  728. let arr: Array<string | null> = [];
  729. // 监测空值
  730. list?.forEach((item: Parse.Object) => {
  731. if (radioValue) {
  732. switch (radioValue) {
  733. case '链接':
  734. item.get('collectCheck') == '链接' &&
  735. arr.push('链接:' + item.get('collectLink').url);
  736. break;
  737. case '链接和账号密码':
  738. item.get('collectCheck') == '链接和账号密码' &&
  739. arr.push(`链接:lian${item.get('collectLink').url}
  740. 账号:lian${item.get('collectLink').username}
  741. 密码:lian${item.get('collectLink').password}
  742. `);
  743. break;
  744. default:
  745. if (item.get('collectCheck') == '上传文件') {
  746. let list: Array<string> = [];
  747. item
  748. .get('collectDigitFiles')
  749. ?.forEach((i: any) => list.push(i.name));
  750. arr.push(...list);
  751. }
  752. break;
  753. }
  754. } else {
  755. let list: Array<string> = [];
  756. item.get('collectFiles')?.forEach((i: any) => list.push(i.name));
  757. arr.push(...list);
  758. }
  759. });
  760. let j = Array.from(arr).join(',');
  761. return j || '-';
  762. }
  763. //导出所有流程申报表格
  764. async exportEduProcess() {
  765. try {
  766. let queryProcs = new Parse.Query('EduProcess');
  767. queryProcs.include('profileSubmitted', 'profileSubmitted.user');
  768. queryProcs.select('name', 'profileSubmitted');
  769. // queryProcs.notEqualTo('branch','66865d66ad23a23355b12aa7')
  770. queryProcs.notEqualTo('isDeleted', true);
  771. queryProcs.greaterThan('num', 0);
  772. queryProcs.limit(300);
  773. let resEduProcess = await queryProcs.find();
  774. console.log(resEduProcess.length);
  775. for (let index = 0; index < resEduProcess.length; index++) {
  776. const r = resEduProcess[index];
  777. // let query = new Parse.Query('EduTextbook');
  778. let query = new Parse.Query('EduTextbook');
  779. query.notEqualTo('isDeleted', true);
  780. query.notEqualTo('discard', true);
  781. query.equalTo('eduProcess', r.id);
  782. query.equalTo('render', true);
  783. query.containedIn('status', ['400']);
  784. query.ascending('createdAt');
  785. query.select(
  786. 'title',
  787. 'childrens.ISBN',
  788. 'childrens.author',
  789. 'childrens.unit',
  790. 'childrens.printDate',
  791. 'childrens.printNumber',
  792. 'childrens.editionUnit',
  793. 'childrens.carrierShape',
  794. 'childrens.lang',
  795. 'childrens.editionFirst',
  796. 'childrens.editionDate',
  797. 'childrens.editionNumber',
  798. 'childrens.printSum',
  799. 'childrens.importantProject',
  800. 'childrens.collectFiles',
  801. 'childrens.collectLink',
  802. 'childrens.collectDigitFiles',
  803. 'childrens.collectCheck',
  804. 'typeNumber',
  805. 'user.department',
  806. 'department.branch',
  807. 'code',
  808. 'discipline',
  809. 'majorPoniter',
  810. 'approval',
  811. 'inviteUnit',
  812. // 'eduProcess.profileSubmitted',
  813. // 'eduProcess.profileSubmitted.email',
  814. // 'eduProcess.profileSubmitted.user.name',
  815. // 'eduProcess.profileSubmitted.user.phone',
  816. 'type',
  817. 'major'
  818. );
  819. query.limit(500);
  820. let data = await query.find();
  821. let table = `<table border="1px" cellspacing="0" cellpadding="0">
  822. <thead>
  823. <tr>
  824. <th colspan="10" style="font-size: 20px;font-family: '黑体';">“十四五”普通高等教育本科国家级规划教材推荐汇总表</th>
  825. </tr>
  826. <tr>
  827. <th></th><th></th><th></th><th></th><th></th>
  828. <th></th><th></th><th></th><th></th><th></th>
  829. </tr>
  830. <tr>
  831. <th></th><th></th><th></th><th></th><th></th>
  832. <th></th><th></th><th></th><th></th><th></th>
  833. </tr>
  834. <tr>
  835. <th></th><th></th>
  836. <th style="font-size: 12px;font-family: '黑体';text-align: left;">单位名称(公章):</th>
  837. <th colspan="3" style="font-size: 12px;font-family: '黑体';text-align: left;">${r?.get(
  838. 'name'
  839. )}</th>
  840. <th></th><th></th><th></th><th></th>
  841. </tr>
  842. <tr>
  843. <th></th><th></th><th></th><th></th><th></th>
  844. <th></th><th></th><th></th><th></th><th></th>
  845. </tr>
  846. <tr>
  847. <th></th><th></th>
  848. <th style="font-size: 12px;font-family: '黑体';text-align: left;">申报工作联系人:</th>
  849. <th colspan="2" style="font-size: 12px;font-family: '黑体';text-align: left;">姓名 ${r
  850. ?.get('profileSubmitted')
  851. ?.get('user')
  852. ?.get('name')}</th>
  853. <th colspan="2" style="font-size: 12px;font-family: '黑体';text-align: left;">电话 ${r
  854. ?.get('profileSubmitted')
  855. ?.get('user')
  856. ?.get('phone')}</th>
  857. <th></th><th></th><th></th>
  858. </tr>
  859. <tr>
  860. <th></th><th></th><th></th><th></th><th></th>
  861. <th></th><th></th><th></th><th></th><th></th>
  862. </tr>
  863. <tr>
  864. <th>序号</th>
  865. <th>申报编号</th>
  866. <th>申报教材名称</th>
  867. <th>教材所属专业类</th>
  868. <th>第一主编/作者</th>
  869. <th>第一主编(作者)单位</th>
  870. <th>申报类型</th>
  871. <th>是否为重点建设教材</th>
  872. <th>出版单位</th>
  873. <th>初版时间</th>
  874. <th>载体形式</th>
  875. </tr>
  876. </thead>
  877. <tbody>
  878. `;
  879. let _body = '';
  880. for (let row = 0; row < data.length; row++) {
  881. _body += '<tr>';
  882. _body += '<td>';
  883. _body += `${row + 1}`;
  884. _body += '</td>';
  885. _body += '<td>';
  886. _body += `&nbsp;${data[row].get('code') || ''}`;
  887. _body += '</td>';
  888. _body += '<td>';
  889. _body += ` &nbsp;${data[row].get('title') || '-'}`;
  890. _body += '</td>';
  891. _body += '<td>';
  892. _body += ` &nbsp;${
  893. (data[row].get('discipline')?.code || '') +
  894. '/' +
  895. (data[row]?.get('discipline')?.name || '')
  896. }`;
  897. _body += '</td>';
  898. _body += '<td>';
  899. _body += `${this.fromatFiled(data[row]?.get('childrens'), 'author')}`;
  900. _body += '</td>';
  901. _body += '<td>';
  902. _body += `${this.fromatFiled(data[row]?.get('childrens'), 'unit')}`;
  903. _body += '</td>';
  904. _body += '<td>';
  905. _body += `${
  906. data[row]?.get('type') == '单本'
  907. ? '单本'
  908. : '全册 - ' + data[row]?.get('typeNumber') || '-'
  909. }`;
  910. _body += '</td>';
  911. _body += '<td>';
  912. _body += `${data[row]?.get('approval') || '-'}`;
  913. _body += '</td>';
  914. _body += '<td>';
  915. _body += `${this.fromatFiled(
  916. data[row]?.get('childrens'),
  917. 'editionUnit'
  918. )}`;
  919. _body += '</td>';
  920. _body += '<td>';
  921. _body += `&nbsp;${this.fromatFiled(
  922. data[row]?.get('childrens'),
  923. 'editionFirst'
  924. )}`;
  925. _body += '</td>';
  926. _body += '<td>';
  927. _body += `${this.fromatFiled(
  928. data[row]?.get('childrens'),
  929. 'carrierShape'
  930. )}`;
  931. _body += '</td>';
  932. _body += '</tr>';
  933. }
  934. table += _body;
  935. table += '</tbody>';
  936. table += '</table>';
  937. let title = r?.get('name') + ' 推荐汇总表';
  938. this.excel(table, `${title}.xls`);
  939. }
  940. } catch (err) {}
  941. }
  942. excel(data: any, filename: string) {
  943. let html =
  944. "<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'>";
  945. html +=
  946. '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';
  947. html += '<meta http-equiv="content-type" content="application/vnd.ms-excel';
  948. html += '; charset=UTF-8">';
  949. html += '<head>';
  950. html += '</head>';
  951. html += '<body>';
  952. html += data;
  953. html += '</body>';
  954. html += '</html>';
  955. let uri =
  956. 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(html);
  957. let link = document.createElement('a');
  958. link.href = uri;
  959. link.download = `${filename}`;
  960. document.body.appendChild(link);
  961. link.click();
  962. document.body.removeChild(link);
  963. }
  964. /* 发送出版社及教师通知短信 */
  965. async sendNoticeMSG() {
  966. let teacherList = new Set<string>();
  967. let unitList = new Set<string>(); //单位出版社
  968. let query = new Parse.Query('EduTextbook');
  969. query.equalTo('status', '400');
  970. query.notEqualTo('isDeleted', true);
  971. query.notEqualTo('discard', true);
  972. query.include('user.phone', 'childrens.editionUnit');
  973. query.select('user.phone', 'childrens.editionUnit');
  974. query.limit(10000);
  975. let r = await query.find();
  976. r.forEach((item) => {
  977. teacherList.add(item?.get('user')?.get('phone'));
  978. item
  979. .get('childrens')
  980. ?.forEach((child: any) => unitList.add(child?.get('editionUnit')));
  981. });
  982. let teacherArr = Array.from(teacherList);
  983. let unitArr = Array.from(unitList);
  984. console.log('教师电话:', teacherArr);
  985. // console.log(unitArr);
  986. let last = teacherArr.slice(5000, 5999);
  987. last.push(...['13581837652', '13407973043', '18510409671']);
  988. console.log(last);
  989. let arr: any = [
  990. // teacherArr.slice(0,999),
  991. // teacherArr.slice(1000,1999),
  992. // teacherArr.slice(2000,2999),
  993. // teacherArr.slice(3000,3999),
  994. // teacherArr.slice(4000,4999),
  995. last,
  996. ];
  997. // arr.forEach((list:any)=> {
  998. // Parse.Cloud.run('aliSmsSend', {
  999. // mobileList: [list],
  1000. // templateCode: 'SMS_474205136',
  1001. // params: {},
  1002. // signName: '普通高等教育教材网',
  1003. // });
  1004. // })
  1005. // return
  1006. let queryParams: any = {
  1007. where: {
  1008. $or: [
  1009. {
  1010. department: {
  1011. $inQuery: {
  1012. where: {
  1013. name: { $in: unitArr },
  1014. },
  1015. className: 'Department',
  1016. },
  1017. },
  1018. },
  1019. ],
  1020. },
  1021. };
  1022. let queryEduProcess = Parse.Query.fromJSON('EduProcess', queryParams);
  1023. queryEduProcess.include('profileSubmitted.user');
  1024. queryEduProcess.select('profileSubmitted.user.phone');
  1025. queryEduProcess.limit(1000);
  1026. let list = await queryEduProcess.find();
  1027. // console.log(list);
  1028. let unitPhoneList = new Set<string>(); //出版单位联系人
  1029. list.map((item) => {
  1030. if (item?.get('profileSubmitted')?.get('user')?.get('phone')) {
  1031. unitPhoneList.add(
  1032. item?.get('profileSubmitted')?.get('user')?.get('phone')
  1033. );
  1034. }
  1035. });
  1036. let unitPhoneArr = Array.from(unitPhoneList);
  1037. unitPhoneArr.push(...['13581837652', '13407973043', '18510409671']);
  1038. // Parse.Cloud.run('aliSmsSend', {
  1039. // mobileList: [unitPhoneArr],
  1040. // templateCode: 'SMS_474290139',
  1041. // params: {end_date:'2024-10-20 16:00'},
  1042. // signName: '普通高等教育教材网',
  1043. // });
  1044. console.log('出版社电话:', unitPhoneArr);
  1045. }
  1046. /* 获取10月9号之前上传的教材文件转私有 */
  1047. async getEtxVolCollect() {
  1048. let queryParams: any = {
  1049. where: {
  1050. $or: [
  1051. {
  1052. collectFiles: { $exists: true },
  1053. collectDigitFiles: { $exists: true },
  1054. },
  1055. ],
  1056. },
  1057. };
  1058. let query = Parse.Query.fromJSON('EduTextbookVolume', queryParams);
  1059. query.lessThan('updatedAt', new Date('2024-10-10 18:00'));
  1060. query.select('collectFiles', 'collectDigitFiles');
  1061. query.limit(2000);
  1062. let r = await query.find();
  1063. let urlList: Array<string> = [];
  1064. r.forEach((item) => {
  1065. item?.get('collectFiles')?.forEach((f: any) => {
  1066. urlList.push(f?.url);
  1067. });
  1068. item?.get('collectDigitFiles')?.forEach((d: any) => {
  1069. urlList.push(d?.url);
  1070. });
  1071. });
  1072. console.log(urlList);
  1073. for (let index = 0; index < urlList.length; index++) {
  1074. const u = urlList[index];
  1075. console.log(u);
  1076. // await this.ossProvider?.setACLPrivate(u)
  1077. }
  1078. }
  1079. /* 更新教材个别字段 */
  1080. async updateTextbook() {
  1081. let arr = [];
  1082. let list = updateDept.list6;
  1083. for (let index = 0; index < list.length; index++) {
  1084. const item = list[index];
  1085. // let oldc=item.code.substring(0,item.code.length-1)
  1086. // console.log(oldc);
  1087. let query = new Parse.Query('EduTextbook');
  1088. query.equalTo('code', item.code);
  1089. query.notEqualTo('isDeleted', true);
  1090. // query.equalTo('title',item.title)
  1091. query.include('childrens');
  1092. query.select('childrens');
  1093. let r = await query.find();
  1094. if (r.length < 1 || r.length > 1 || r[0]?.get('childrens').length > 1) {
  1095. // if(r.length !== 1){
  1096. arr.push(item.code);
  1097. continue;
  1098. }
  1099. let eduTextbookVolume = r[0]?.get('childrens')[0];
  1100. item.type.trim() != '暂无' &&
  1101. eduTextbookVolume?.set('carrierShape', item.type.trim());
  1102. item.isbn.trim() != '暂无' &&
  1103. eduTextbookVolume?.set('ISBN', item.isbn.trim());
  1104. await eduTextbookVolume?.save();
  1105. // r[0]?.set('code',item.code)
  1106. r[0]?.set('exportPDF', null);
  1107. await r[0]?.save();
  1108. console.log('update=>', item);
  1109. }
  1110. console.log('update over');
  1111. console.log(arr);
  1112. }
  1113. /* 导出评审系统表格数据 */
  1114. async exportUrl() {
  1115. let unitName = '教材文件excel';
  1116. let query = new Parse.Query('EduTextbook');
  1117. query.notEqualTo('isDeleted', true);
  1118. query.notEqualTo('discard', true);
  1119. query.equalTo('render', true);
  1120. query.select('title', 'code');
  1121. query.containedIn('status', ['400']);
  1122. query.limit(10000);
  1123. query.skip(0);
  1124. let data = await query.find();
  1125. let table = `<table border="1px" cellspacing="0" cellpadding="0">
  1126. <thead>
  1127. <tr>
  1128. <th>教材名称</th>
  1129. <th>申报编号</th>
  1130. <th>文件链接</th>
  1131. </tr>
  1132. </thead>
  1133. <tbody>
  1134. `;
  1135. let _body = '';
  1136. for (let row = 0; row < data.length; row++) {
  1137. _body += '<tr>';
  1138. _body += '<td>';
  1139. _body += `${data[row]?.get('title') || '-'}`;
  1140. _body += '</td>';
  1141. _body += '<td>';
  1142. _body += `&nbsp;${data[row]?.get('code') || ''}`;
  1143. _body += '</td>';
  1144. _body += '<td>';
  1145. _body += `https://145.tbook.com.cn/external/review/detail/${data[row].id}`;
  1146. _body += '</td>';
  1147. _body += '</tr>';
  1148. }
  1149. table += _body;
  1150. table += '</tbody>';
  1151. table += '</table>';
  1152. this.excel(table, `${unitName}.xls`);
  1153. }
  1154. }