infoService.js 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311
  1. 'use strict';
  2. const Service = require('egg').Service;
  3. const gm = require('gm');
  4. const qr = require('qr-image');
  5. const moment = require('moment');
  6. class InfoService extends Service {
  7. // 单条查询
  8. async one(id) {
  9. const { model } = this.ctx;
  10. return await model.InfoModel.findById(id);
  11. }
  12. // 不分页查询
  13. async list(data) {
  14. const { model } = this.ctx;
  15. return await model.InfoModel.find(data).sort({ time: -1 });
  16. }
  17. // 不分页查询
  18. async noVisitList(data) {
  19. const { model } = this.ctx;
  20. const noVisitData = [];
  21. const noVisitList = await model.InfoModel.aggregate(
  22. [
  23. { $match: { status: '3', userid: this.app.mongoose.Types.ObjectId(data.userid) } },
  24. {
  25. $lookup: {
  26. from: 'visit',
  27. localField: '_id',
  28. foreignField: 'infoId',
  29. as: 'inventory_docs',
  30. },
  31. },
  32. { $group: {
  33. _id: '$_id',
  34. name: { $first: '$name' },
  35. userid: { $first: '$userid' },
  36. time: { $first: '$inventory_docs.visitTime' },
  37. regularsInfo: { $first: '$regularsInfo' },
  38. },
  39. },
  40. {
  41. $unwind: { path: '$time' },
  42. },
  43. { $sort: { time: -1 } },
  44. { $group: {
  45. _id: '$_id',
  46. name: { $first: '$name' },
  47. userid: { $first: '$userid' },
  48. time: { $first: '$time' },
  49. regularsInfo: { $first: '$regularsInfo' },
  50. },
  51. },
  52. ]
  53. );
  54. const visitList = await model.InfoModel.aggregate(
  55. [
  56. { $match: { status: '3', userid: this.app.mongoose.Types.ObjectId(data.userid) } },
  57. {
  58. $lookup: {
  59. from: 'visit',
  60. localField: '_id',
  61. foreignField: 'infoId',
  62. as: 'inventory_docs',
  63. },
  64. },
  65. ]
  66. );
  67. if (visitList.map(item => {
  68. if (item.inventory_docs.length === 0) {
  69. const visitCount = JSON.parse(item.regularsInfo).visitCount;
  70. const time = item.time.getTime();
  71. let is = null;
  72. switch (visitCount) {
  73. case '每天':
  74. is = time >= moment().subtract(1, 'day').valueOf();
  75. break;
  76. case '每周':
  77. is = time >= moment().subtract(7, 'day').valueOf();
  78. break;
  79. case '每月':
  80. is = time >= moment().subtract(1, 'month').valueOf();
  81. break;
  82. case '每季':
  83. is = time >= moment().subtract(3, 'month').valueOf();
  84. break;
  85. default:
  86. is = true;
  87. }
  88. if (!is) {
  89. noVisitData.push({ _id: item._id, name: item.name, userid: item.userid, visitCount: JSON.parse(item.regularsInfo).visitCount, visitCountExt: JSON.parse(item.regularsInfo).visitCountExt });
  90. }
  91. }
  92. })) {
  93. noVisitList.map(item => {
  94. const visitCount = JSON.parse(item.regularsInfo).visitCount;
  95. const time = item.time.getTime();
  96. let is = null;
  97. switch (visitCount) {
  98. case '每天':
  99. is = time >= moment().subtract(1, 'day').valueOf();
  100. break;
  101. case '每周':
  102. is = time >= moment().subtract(7, 'day').valueOf();
  103. break;
  104. case '每月':
  105. is = time >= moment().subtract(1, 'month').valueOf();
  106. break;
  107. case '每季':
  108. is = time >= moment().subtract(3, 'month').valueOf();
  109. break;
  110. default:
  111. is = true;
  112. }
  113. if (!is) {
  114. noVisitData.push({ ...item, visitCount: JSON.parse(item.regularsInfo).visitCount, visitCountExt: JSON.parse(item.regularsInfo).visitCountExt });
  115. }
  116. });
  117. }
  118. return noVisitData;
  119. }
  120. // 根据户id查询
  121. async listByFid(data) {
  122. const { model } = this.ctx;
  123. return await model.InfoModel.find(data);
  124. }
  125. // 根据身份证号查询
  126. async listByNumber(data) {
  127. const { model } = this.ctx;
  128. return await model.InfoModel.find(data);
  129. }
  130. // 分页查询
  131. async listForPage(data) {
  132. const { model } = this.ctx;
  133. const page = data.page;
  134. const rows = Number.parseInt(data.rows) || this.app.config.defaultPageSize;
  135. delete data.page;
  136. delete data.rows;
  137. const where = {};
  138. if (data.dept1) {
  139. where.dept1 = this.app.mongoose.Types.ObjectId(data.dept1);// 省
  140. }
  141. if (data.dept2) {
  142. where.dept2 = this.app.mongoose.Types.ObjectId(data.dept2);// 市
  143. }
  144. if (data.dept3) {
  145. where.dept3 = this.app.mongoose.Types.ObjectId(data.dept3);// 区
  146. }
  147. if (data.dept4) {
  148. where.dept4 = this.app.mongoose.Types.ObjectId(data.dept4);// 乡
  149. }
  150. if (data.dept5) {
  151. where.dept5 = this.app.mongoose.Types.ObjectId(data.dept5);// 社区
  152. }
  153. // userid.loginName
  154. if (data.cjname) {
  155. // where.userName = { $regex: data.cjname }; // 管理员
  156. // where['userInfo.loginName'] = { $regex: data.cjname };
  157. const result = await model.SysUserModel.find({ loginName: { $regex: data.cjname } });
  158. if (result.length > 0) {
  159. where.userid = result[0]._id;
  160. } else {
  161. return '';
  162. }
  163. }
  164. // 状态
  165. if (data.status) {
  166. where.status = '' + data.status;
  167. }
  168. // 老人常用联系电话
  169. if (data.phone) {
  170. where.phone = { $regex: data.phone };
  171. }
  172. // 老人姓名
  173. if (data.name) {
  174. where.name = { $regex: data.name };
  175. }
  176. // 老人年龄
  177. if (data.age) {
  178. const myDate = new Date();
  179. const year = myDate.getFullYear();
  180. const month = (myDate.getMonth() + 1) > 9 ? (myDate.getMonth() + 1) : '0' + (myDate.getMonth() + 1);
  181. const day = myDate.getDate() > 9 ? (myDate.getDate()) : '0' + (myDate.getDate());
  182. if (data.age > 0) {
  183. where.idNumber = { $ne: '' };
  184. where.birthday = { $lte: '' + year + month + day - (data.age * 10000) + '' };
  185. } else {
  186. where.idNumber = { $ne: '' };
  187. where.birthday = { $gte: '' + year + month + day - (-data.age * 10000) + '' };
  188. }
  189. }
  190. // 关爱服务需求
  191. if (data.demand) {
  192. const ts = data.demand.split(',');
  193. where.demand = { $in: ts };
  194. }
  195. // 老人类别
  196. if (data.oldType) {
  197. const ts = data.oldType.split(',');
  198. where.oldType = { $in: ts };
  199. }
  200. // 离线采集
  201. if (data.online) {
  202. if (data.online == 'false') {
  203. where.online = data.online;
  204. }
  205. if (data.online == 'true') {
  206. // where.online = data.online;
  207. where.$or = [{ online: { $exists: false } }, { online: data.online }];
  208. }
  209. }
  210. // 身份证号码搜索
  211. if (data.idNumber) {
  212. where.idNumber = { $regex: data.idNumber };
  213. }
  214. // 老年人能力状况(公众号和小程序的括号不一致)
  215. if (data.ability) {
  216. // where.ability = data.ability;
  217. where.ability = { $regex: '^' + data.ability };
  218. }
  219. // 时间
  220. if (data.startTime && data.endTime) {
  221. where.time = { $gte: new Date(data.startTime + ' 00:00:00'), $lt: new Date(data.endTime + ' 23:59:59') };
  222. }
  223. // if (data.isDeath) {
  224. // if (data.isDeath == '1') {
  225. // where.isDeath = data.isDeath;
  226. // } else {
  227. // where.$or = [{ isDeath: { $exists: false } }, { isDeath: data.isDeath }];
  228. // }
  229. // }
  230. // 是否是党员
  231. // if (data.partyMember) {
  232. // if (data.partyMember == '1') {
  233. // where.partyMember = data.partyMember;
  234. // } else {
  235. // where.$or = [{ partyMember: { $exists: false } }, { partyMember: data.partyMember }];
  236. // }
  237. // }
  238. // 自主填报
  239. if (data.ownerId === 'true') {
  240. where.ownerId = { $ne: null };
  241. } else if (data.ownerId === 'false') {
  242. where.ownerId = { $eq: null };
  243. }
  244. if (data.partyMember == 1) {
  245. where.partyMember = { $eq: 1 };
  246. } else if (data.partyMember == '0') {
  247. where.partyMember = { $in: [ 0, null ] };
  248. } else {
  249. delete data.partyMember;
  250. }
  251. if (data.isDeath == 1) {
  252. where.isDeath = { $eq: 1 };
  253. } else if (data.isDeath == '0') {
  254. where.isDeath = { $in: [ 0, null ] };
  255. } else {
  256. delete data.isDeath;
  257. }
  258. this.ctx.logger.info('条件===============================================', where);
  259. const pop = [
  260. {
  261. path: 'userid',
  262. select: 'loginName userName',
  263. },
  264. {
  265. path: 'dept1',
  266. select: 'name',
  267. },
  268. {
  269. path: 'dept2',
  270. select: 'name',
  271. },
  272. {
  273. path: 'dept3',
  274. select: 'name',
  275. },
  276. {
  277. path: 'dept4',
  278. select: 'name',
  279. },
  280. {
  281. path: 'dept5',
  282. select: 'name',
  283. },
  284. // {
  285. // path: 'fid',
  286. // select: 'openId',
  287. // },
  288. ];
  289. const fidCount = await model.InfoModel.aggregate([
  290. { $match: where },
  291. { $group: { _id: '$fid', count: { $sum: 1 } } },
  292. { $group: { _id: null, count: { $sum: 1 } } },
  293. { $project: { _id: 0, count: '$count' } },
  294. ]);
  295. const total = await model.InfoModel.find(where).populate(pop).countDocuments();
  296. const result = await model.InfoModel.find(where).populate(pop).skip((page - 1) * rows)
  297. .limit(rows)
  298. .sort({ time: -1 });
  299. return {
  300. fidCount: fidCount[0] !== undefined ? fidCount[0].count : 0,
  301. count: total,
  302. list: result,
  303. };
  304. }
  305. // 添加
  306. async add(data) {
  307. const { model } = this.ctx;
  308. const result = await model.InfoModel.create(data);
  309. return result;
  310. }
  311. // 修改
  312. async update(id, data) {
  313. const { model } = this.ctx;
  314. const status = data.status;
  315. delete data.status;
  316. // console.log('data', data);
  317. if (data.idNumber && data.idNumber !== '') {
  318. const birthday = data.idNumber.substr(6, 8);
  319. data.birthday = birthday;
  320. }
  321. // 身份证修改为空时,将birthday置空
  322. if (data.idNumber == '') {
  323. data.birthday = '';
  324. }
  325. data.time = Date.now();
  326. if (data.health) {
  327. data.health = JSON.parse(data.health);
  328. }
  329. if (data.disabilityCategory) {
  330. data.disabilityCategory = JSON.parse(data.disabilityCategory);
  331. }
  332. if (data.majorDiseases) {
  333. data.majorDiseases = JSON.parse(data.majorDiseases);
  334. }
  335. if (data.oldType) {
  336. data.oldType = JSON.parse(data.oldType);
  337. }
  338. if (data.demand) {
  339. data.demand = JSON.parse(data.demand);
  340. }
  341. if (data.lookAfter) {
  342. data.lookAfter = JSON.parse(data.lookAfter);
  343. }
  344. if (data.accompany) {
  345. data.accompany = JSON.parse(data.accompany);
  346. }
  347. if (data.rescueState) {
  348. data.rescueState = JSON.parse(data.rescueState);
  349. }
  350. if (data.sourceOfIncome) {
  351. data.sourceOfIncome = JSON.parse(data.sourceOfIncome);
  352. }
  353. const result = await model.InfoModel.updateOne({ _id: id }, data);
  354. // 修改采集状态
  355. delete data.time;
  356. await this.ctx.service.infoService.updateStatus(id, data);
  357. return result;
  358. }
  359. // 检查采集状态
  360. async checkInfoStatus(id) {
  361. const ctx = this.ctx;
  362. const flag = true;
  363. const oneInfo = await this.ctx.service.infoService.one(id);
  364. if (oneInfo) {
  365. // 姓名
  366. if (oneInfo.name && oneInfo.name !== '') {
  367. } else {
  368. ctx.logger.info('name', flag);
  369. console.log('name', flag);
  370. return flag;
  371. }
  372. // 性别
  373. if (oneInfo.sex && oneInfo.sex !== '') {
  374. } else {
  375. ctx.logger.info('sex', flag);
  376. console.log('sex', flag);
  377. return flag;
  378. }
  379. // 民族
  380. if (oneInfo.nation && oneInfo.nation !== '') {
  381. } else {
  382. ctx.logger.info('nation', flag);
  383. console.log('nation', flag);
  384. return flag;
  385. }
  386. // 身份证
  387. if (oneInfo.idNumber && oneInfo.idNumber !== '') {
  388. } else {
  389. ctx.logger.info('idNumber', flag);
  390. console.log('idNumber', flag);
  391. return flag;
  392. }
  393. // 生日
  394. if (oneInfo.birthday && oneInfo.birthday !== '') {
  395. } else {
  396. ctx.logger.info('birthday', flag);
  397. console.log('birthday', flag);
  398. return flag;
  399. }
  400. // 电话
  401. if (oneInfo.phone && oneInfo.phone !== '') {
  402. } else {
  403. ctx.logger.info('phone', flag);
  404. console.log('phone', flag);
  405. return flag;
  406. }
  407. // 户籍地址
  408. if (oneInfo.nativePlace && oneInfo.nativePlace !== '') {
  409. } else {
  410. ctx.logger.info('nativePlace', flag);
  411. console.log('nativePlace', flag);
  412. return flag;
  413. }
  414. // 现居地址
  415. if (oneInfo.address && oneInfo.address !== '') {
  416. } else {
  417. ctx.logger.info('address', flag);
  418. console.log('address', flag);
  419. return flag;
  420. }
  421. // 婚姻及配偶情况
  422. if (oneInfo.partnerState && oneInfo.partnerState !== '') {
  423. if (oneInfo.partnerState == '已婚') {
  424. if (oneInfo.partnerName && oneInfo.partnerName !== '') {
  425. } else {
  426. ctx.logger.info('partnerName', flag);
  427. console.log('partnerName', flag);
  428. return flag;
  429. }
  430. if (oneInfo.partnerIdNumber && oneInfo.partnerIdNumber !== '') {
  431. } else {
  432. ctx.logger.info('partnerIdNumber', flag);
  433. console.log('partnerIdNumber', flag);
  434. return flag;
  435. }
  436. }
  437. } else {
  438. ctx.logger.info('partnerState', flag);
  439. console.log('partnerState', flag);
  440. return flag;
  441. }
  442. // 是否为失独家庭
  443. if (oneInfo.isLoss && oneInfo.isLoss !== '') {
  444. } else {
  445. ctx.logger.info('isLoss', flag);
  446. console.log('isLoss', flag);
  447. return flag;
  448. }
  449. // 老年人能力状况
  450. if (oneInfo.ability && oneInfo.ability !== '') {
  451. } else {
  452. ctx.logger.info('ability', flag);
  453. console.log('ability', flag);
  454. return flag;
  455. }
  456. // 健康状况
  457. if (oneInfo.health && oneInfo.health.length > 0) {
  458. if (oneInfo.health.indexOf('残疾') !== -1) {
  459. if (oneInfo.disabilityCategory && oneInfo.disabilityCategory.length > 0) {
  460. } else {
  461. ctx.logger.info('disabilityCategory', flag);
  462. console.log('disabilityCategory', flag);
  463. return flag;
  464. }
  465. if (oneInfo.disabilityLevel && oneInfo.disabilityLevel !== '') {
  466. } else {
  467. ctx.logger.info('disabilityLevel', flag);
  468. console.log('disabilityLevel', flag);
  469. return flag;
  470. }
  471. }
  472. if (oneInfo.health.indexOf('患重特大疾病') !== -1) {
  473. if (oneInfo.majorDiseases && oneInfo.majorDiseases.length > 0) {
  474. } else {
  475. ctx.logger.info('majorDiseases', flag);
  476. console.log('majorDiseases', flag);
  477. return flag;
  478. }
  479. }
  480. } else {
  481. return flag;
  482. }
  483. // 生活经济状况
  484. if (oneInfo.livingCondition && oneInfo.livingCondition !== '') {
  485. } else {
  486. ctx.logger.info('livingCondition', flag);
  487. console.log('livingCondition', flag);
  488. return flag;
  489. }
  490. // 收入来源
  491. if (oneInfo.sourceOfIncome && oneInfo.sourceOfIncome.length > 0) {
  492. if (oneInfo.sourceOfIncome.indexOf('其它') !== -1) {
  493. if (oneInfo.sourceOfIncomeExt && oneInfo.sourceOfIncomeExt !== '') {
  494. } else {
  495. ctx.logger.info('sourceOfIncomeExt', flag);
  496. console.log('sourceOfIncomeExt', flag);
  497. return flag;
  498. }
  499. }
  500. } else {
  501. ctx.logger.info('sourceOfIncome', flag);
  502. console.log('sourceOfIncome', flag);
  503. return flag;
  504. }
  505. // 本人上年度可支配收入
  506. if (oneInfo.income && oneInfo.income !== '') {
  507. } else {
  508. ctx.logger.info('income', flag);
  509. console.log('income', flag);
  510. return flag;
  511. }
  512. // 家庭救助帮扶情况
  513. if (oneInfo.rescueState && oneInfo.rescueState.length > 0) {
  514. } else {
  515. ctx.logger.info('rescueState', flag);
  516. console.log('rescueState', flag);
  517. return flag;
  518. }
  519. // 陪伴居住情况
  520. if (oneInfo.accompany && oneInfo.accompany.length > 0) {
  521. if (oneInfo.accompany.indexOf('其他情形') !== -1) {
  522. if (oneInfo.accompanyExt && oneInfo.accompanyExt !== '') {
  523. } else {
  524. ctx.logger.info('accompanyExt', flag);
  525. console.log('accompanyExt', flag);
  526. return flag;
  527. }
  528. }
  529. } else {
  530. ctx.logger.info('accompany', flag);
  531. console.log('accompany', flag);
  532. return flag;
  533. }
  534. // 日常生活照料人
  535. if (oneInfo.lookAfter && oneInfo.lookAfter.length > 0) {
  536. if (oneInfo.lookAfter.indexOf('其他人员') !== -1) {
  537. if (oneInfo.lookAfterExt && oneInfo.lookAfterExt !== '') {
  538. } else {
  539. ctx.logger.info('lookAfterExt', flag);
  540. console.log('lookAfterExt', flag);
  541. return flag;
  542. }
  543. }
  544. if (oneInfo.lookAfter.indexOf('无人照料') !== -1) {
  545. } else {
  546. if (oneInfo.mainLookName && oneInfo.mainLookName !== '') {
  547. } else {
  548. ctx.logger.info('mainLookName', flag);
  549. console.log('mainLookName', flag);
  550. return flag;
  551. }
  552. if (oneInfo.mainLookSex && oneInfo.mainLookSex !== '') {
  553. } else {
  554. ctx.logger.info('mainLookSex', flag);
  555. console.log('mainLookSex', flag);
  556. return flag;
  557. }
  558. if (oneInfo.mainLookPhone && oneInfo.mainLookPhone !== '') {
  559. } else {
  560. ctx.logger.info('mainLookPhone', flag);
  561. console.log('mainLookPhone', flag);
  562. return flag;
  563. }
  564. }
  565. } else {
  566. ctx.logger.info('lookAfter', flag);
  567. console.log('lookAfter', flag);
  568. return flag;
  569. }
  570. // 关爱服务需求
  571. if (oneInfo.demand && oneInfo.demand.length > 0) {
  572. if (oneInfo.demand.indexOf('其它') !== -1) {
  573. if (oneInfo.demandExt && oneInfo.demandExt !== '') {
  574. } else {
  575. ctx.logger.info('demandExt', flag);
  576. console.log('demandExt', flag);
  577. return flag;
  578. }
  579. }
  580. } else {
  581. ctx.logger.info('demand', flag);
  582. console.log('demand', flag);
  583. return flag;
  584. }
  585. // 老年人类别
  586. if (oneInfo.oldType && oneInfo.oldType.length > 0) {
  587. } else {
  588. ctx.logger.info('oldType', flag);
  589. console.log('oldType', flag);
  590. return flag;
  591. }
  592. // 老年人照片
  593. if (oneInfo.photo && oneInfo.photo !== '') {
  594. } else {
  595. ctx.logger.info('photo', flag);
  596. console.log('photo', flag);
  597. return flag;
  598. }
  599. // 定位信息
  600. if (oneInfo.photoAndLocation && oneInfo.photoAndLocation !== '') {
  601. } else {
  602. ctx.logger.info('photoAndLocation', flag);
  603. console.log('photoAndLocation', flag);
  604. return flag;
  605. }
  606. // 子女
  607. if (oneInfo.childInfo) {
  608. const childs = JSON.parse(oneInfo.childInfo);
  609. if (childs.length > 0) {
  610. // 检查子女信息是否填全
  611. for (let index = 0; index < childs.length; index++) {
  612. const child = childs[index];
  613. if (child.name && child.name !== '') {
  614. } else {
  615. ctx.logger.info('childName', flag);
  616. console.log('childName', flag);
  617. return flag;
  618. }
  619. if (child.phone && child.phone !== '') {
  620. } else {
  621. ctx.logger.info('childPhone', flag);
  622. console.log('childPhone', flag);
  623. return flag;
  624. }
  625. // 子女配偶
  626. if (child.isHasPartner && child.isHasPartner !== '') {
  627. if (child.isHasPartner == '是') {
  628. if (child.name2 && child.name2 !== '') {
  629. } else {
  630. ctx.logger.info('childPartnerName', flag);
  631. console.log('childPartnerName', flag);
  632. return flag;
  633. }
  634. if (child.phone2 && child.phone2 !== '') {
  635. } else {
  636. ctx.logger.info('childPartnerphone2', flag);
  637. console.log('childPartnerphone2', flag);
  638. return flag;
  639. }
  640. }
  641. // ctx.logger.info('child.isHasPartner == 1', flag);
  642. } else {
  643. ctx.logger.info('childisHasPartner', flag);
  644. console.log('childisHasPartner', flag);
  645. return flag;
  646. }
  647. // 是否外出
  648. if (child.isHasGoOut && child.isHasGoOut !== '' && child.isHasGoOut == '否') {
  649. // if (child.isHasGoOut == '是') {
  650. // }
  651. } else {
  652. if (child.outgoingplace && child.outgoingplace !== '') {
  653. } else {
  654. ctx.logger.info('child.outgoingplace', flag);
  655. console.log('child.outgoingplace', flag);
  656. return flag;
  657. }
  658. if (child.outgoingTime && child.outgoingTime !== '') {
  659. } else {
  660. ctx.logger.info('child.outgoingTime', flag);
  661. console.log('child.outgoingTime', flag);
  662. return flag;
  663. }
  664. if (child.outgoingCause && child.outgoingCause !== '') {
  665. } else {
  666. ctx.logger.info('child.outgoingCause', flag);
  667. console.log('child.outgoingCause', flag);
  668. return flag;
  669. }
  670. }
  671. // if (child.outgoingplace && child.outgoingplace !== '') {
  672. // } else {
  673. // // ctx.logger.info('outgoingplace', flag);
  674. // console.log('outgoingplace', flag);
  675. // return flag;
  676. // }
  677. // if (child.outgoingTime && child.outgoingTime !== '') {
  678. // } else {
  679. // // ctx.logger.info('outgoingTime', flag);
  680. // console.log('outgoingTime', flag);
  681. // return flag;
  682. // }
  683. // if (child.outgoingCause && child.outgoingCause !== '') {
  684. // } else {
  685. // // ctx.logger.info('outgoingCause', flag);
  686. // console.log('outgoingCause', flag);
  687. // return flag;
  688. // }
  689. if (child.visit && child.visit !== '') {
  690. } else {
  691. ctx.logger.info('child.visit', flag);
  692. console.log('child.visit', flag);
  693. return flag;
  694. }
  695. }
  696. }
  697. } else {
  698. return flag;
  699. }
  700. // 其他赡养人
  701. if (oneInfo.otherInfo) {
  702. const others = JSON.parse(oneInfo.otherInfo);
  703. if (others) {
  704. // 检查赡养人信息是否填全
  705. if (others.name && others.name !== '') {
  706. } else {
  707. ctx.logger.info('others.name', flag);
  708. console.log('others.name', flag);
  709. return flag;
  710. }
  711. if (others.sex && others.sex !== '') {
  712. } else {
  713. ctx.logger.info('others.sex', flag);
  714. console.log('others.sex', flag);
  715. return flag;
  716. }
  717. if (others.phone && others.phone !== '') {
  718. } else {
  719. ctx.logger.info('others.phone', flag);
  720. console.log('others.phone', flag);
  721. return flag;
  722. }
  723. // 与被赡养人关系
  724. if (others.relation && others.relation !== '') {
  725. if (others.relation == '其他') {
  726. if (others.relationExt && others.relationExt !== '') {
  727. } else {
  728. ctx.logger.info('others.relationExt', flag);
  729. console.log('others.relationExt', flag);
  730. return flag;
  731. }
  732. }
  733. } else {
  734. ctx.logger.info('others.relation', flag);
  735. console.log('others.relation', flag);
  736. return flag;
  737. }
  738. // 配偶
  739. if (others.isHasPartner && others.isHasPartner !== '') {
  740. if (others.isHasPartner == '是') {
  741. if (others.name2 && others.name2 !== '') {
  742. } else {
  743. ctx.logger.info('others.name2', flag);
  744. console.log('others.name2', flag);
  745. return flag;
  746. }
  747. if (others.phone2 && others.phone2 !== '') {
  748. } else {
  749. ctx.logger.info('others.phone2', flag);
  750. console.log('others.phone2', flag);
  751. return flag;
  752. }
  753. }
  754. } else {
  755. ctx.logger.info('others.isHasPartner', flag);
  756. console.log('others.isHasPartner', flag);
  757. return flag;
  758. }
  759. // 是否外出
  760. if (others.isHasGoOut && others.isHasGoOut !== '' && others.isHasGoOut == '否') {
  761. } else {
  762. if (others.outgoingplace && others.outgoingplace !== '') {
  763. } else {
  764. ctx.logger.info('others.outgoingplace', flag);
  765. console.log('others.outgoingplace', flag);
  766. return flag;
  767. }
  768. if (others.outgoingTime && others.outgoingTime !== '') {
  769. } else {
  770. ctx.logger.info('others.outgoingTime', flag);
  771. console.log('others.outgoingTime', flag);
  772. return flag;
  773. }
  774. if (others.outgoingCause && others.outgoingCause !== '') {
  775. } else {
  776. ctx.logger.info('others.outgoingCause', flag);
  777. console.log('others.outgoingCause', flag);
  778. return flag;
  779. }
  780. }
  781. if (others.visit && others.visit !== '') {
  782. } else {
  783. ctx.logger.info('others.visit', flag);
  784. console.log('others.visit', flag);
  785. return flag;
  786. }
  787. }
  788. }
  789. // 巡访联系人信息
  790. if (oneInfo.regularsInfo && oneInfo.regularsInfo !== '') {
  791. const regulars = JSON.parse(oneInfo.regularsInfo);
  792. if (regulars) {
  793. // 检查巡访联系人信息是否填全
  794. if (regulars.visitMode && regulars.visitMode !== '' && regulars.visitMode !== '[]') {
  795. if (regulars.visitMode.indexOf('其它') !== -1) {
  796. if (regulars.visitModeExt && regulars.visitModeExt !== '') {
  797. } else {
  798. ctx.logger.info('regulars.visitModeExt', flag);
  799. console.log('regulars.visitModeExt', flag);
  800. return flag;
  801. }
  802. }
  803. } else {
  804. ctx.logger.info('regulars.visitMode', flag);
  805. console.log('regulars.visitMode', flag);
  806. return flag;
  807. }
  808. if (regulars.visitCount && regulars.visitCount !== '') {
  809. if (regulars.visitCount == '其它') {
  810. if (regulars.visitCountExt && regulars.visitCountExt !== '') {
  811. } else {
  812. ctx.logger.info('regulars.visitCountExt', flag);
  813. console.log('regulars.visitCountExt', flag);
  814. return flag;
  815. }
  816. }
  817. } else {
  818. ctx.logger.info('regulars.visitCount', flag);
  819. console.log('regulars.visitCount', flag);
  820. return flag;
  821. }
  822. } else {
  823. ctx.logger.info('regulars', flag);
  824. console.log('regulars', flag);
  825. return flag;
  826. }
  827. } else {
  828. ctx.logger.info('regularsInfo', flag);
  829. console.log('regularsInfo ', flag);
  830. return flag;
  831. }
  832. ctx.logger.info('false', flag);
  833. console.log('false', flag);
  834. return false;
  835. }
  836. ctx.logger.info('true', flag);
  837. console.log('true', flag);
  838. return flag;
  839. }
  840. // 审核成功时,不允许修改为空
  841. async checkInfoUpdate(oneInfo) {
  842. const ctx = this.ctx;
  843. let flag = true;
  844. Object.keys(oneInfo).forEach(item => {
  845. if (item == 'childInfo') {
  846. return flag;
  847. }
  848. if (item == 'otherInfo') {
  849. return flag;
  850. }
  851. if (item == 'regularsInfo') {
  852. return flag;
  853. }
  854. if (!oneInfo[item] || oneInfo[item] == '' || oneInfo[item] == '[]') {
  855. // 当值不存在,为'',为 '[]'时,不可以修改
  856. flag = false;
  857. }
  858. });
  859. // console.log('完成');
  860. return flag;// 可以修改
  861. }
  862. // 修改采集状态
  863. async updateStatus(id, data) { // data 修改内容
  864. const { ctx } = this;
  865. const { model } = this.ctx;
  866. const oneInfo = await this.ctx.service.infoService.one(id);
  867. // 检查采集状态是否完成
  868. const checkStatus = await this.ctx.service.infoService.checkInfoStatus(id);
  869. const status = checkStatus ? '0' : '1';
  870. // ctx.logger.info('status=================', status)
  871. let query = {};
  872. // 审核完成后,采集状态不允许修改
  873. if (oneInfo.status == '3') {
  874. query = { status: oneInfo.status };
  875. } else {
  876. query = { status };
  877. }
  878. if (status == '1') {
  879. if (this.isNoNull(oneInfo, 'pic')) {
  880. // pic != '' 是否修改了name idNumber
  881. if (data.name || data.idNumber) {
  882. // 根据修改的name,idNumber重新生成二维码
  883. const picUrl = await this.ctx.service.infoService.createImage(oneInfo._id, data.name, data.idNumber);
  884. // update 图片地址
  885. console.log('我修改了图片');
  886. query.pic = picUrl;
  887. }
  888. } else {
  889. // 生成二维码
  890. const picUrl = await this.ctx.service.infoService.createImage(oneInfo._id, oneInfo.name, oneInfo.idNumber);
  891. console.log('我未修改了图片');
  892. // add图片地址
  893. query.pic = picUrl;
  894. }
  895. }
  896. const result = await model.InfoModel.updateOne({ _id: id }, query);
  897. return result;
  898. }
  899. // 生成二维码
  900. async createImage(id, name, idNumber) {
  901. const { service } = this;
  902. if (id && name && idNumber && id !== '' && name !== '' && idNumber !== '') {
  903. // 生成二维码
  904. const qr_png = qr.image(this.app.config.weiXinUrl + id, { type: 'png' });
  905. let number = '';
  906. if (idNumber && idNumber !== '') {
  907. number = idNumber.substring(0, 4) + 'xxxxxxxxxxx' + idNumber.substring(15, 18);
  908. }
  909. // 添加水印
  910. const fileStream = await service.infoService.handleImage(qr_png, name, number);
  911. const fileName = name + '_' + (number || '') + '_' + Date.now() + '.png';
  912. // TODO 传图至OSS -CH (已完成)
  913. await this.ctx.oss.get('bucket1').putStream(this.app.config.scanAliOSSPath + fileName, fileStream);
  914. const url = this.app.config.scanPathPre + fileName;
  915. return url;
  916. }
  917. return '';
  918. }
  919. isNoNull(obj, key) {
  920. return obj.hasOwnProperty(key) && obj[key];
  921. }
  922. // gm 二维码添加文字水印
  923. async handleImage(qr_png, name, number) {
  924. return new Promise((resolve, reject) => {
  925. // 添加水印
  926. gm(qr_png)
  927. .font('./app/public/font/msyh.ttf') // 设置字体
  928. .fill('#000000') // 设置颜色
  929. .fontSize('12px') // 设置字号
  930. .drawText(0, 5, name + (number || ''), 'South') // 设定位置
  931. .stream(function(err, stdout, stderr) {
  932. if (!err) {
  933. resolve(stdout);
  934. } else {
  935. reject(err.message);
  936. console.log('err.message:', err.message);
  937. }
  938. });
  939. console.log('done!');
  940. });
  941. }
  942. // 删除
  943. async dele(id) {
  944. const { model } = this.ctx;
  945. const result = await model.InfoModel.deleteOne({ _id: id });
  946. return result;
  947. }
  948. // 审批
  949. async approval(id, data) {
  950. const { model } = this.ctx;
  951. const status = data.status;
  952. if (id) {
  953. const oneInfo = await this.ctx.service.infoService.one(id);
  954. if (oneInfo) {
  955. if (oneInfo.status == '2') {
  956. if (status == '3') {
  957. // 审批成功 修改状态==3
  958. const result = await model.InfoModel.updateOne({ _id: id }, data);
  959. // 自主上报采集不加积分
  960. if (!oneInfo.ownerId) {
  961. // 判断是否是离线采集,离线采集没有积分
  962. if (oneInfo.online && oneInfo.online == 'false') {
  963. // 无积分
  964. } else {
  965. // 添加积分记录
  966. const oneValue = await this.ctx.service.valueService.list({ fid: oneInfo.fid });
  967. if (oneValue.length <= 0) {
  968. const addQuery = {};
  969. addQuery.dept1 = oneInfo.dept1;
  970. addQuery.dept2 = oneInfo.dept2;
  971. addQuery.dept3 = oneInfo.dept3;
  972. addQuery.dept4 = oneInfo.dept4;
  973. addQuery.dept5 = oneInfo.dept5;
  974. // addQuery.dept1 = this.app.mongoose.Types.ObjectId(oneInfo.dept1);
  975. // addQuery.dept2 = this.app.mongoose.Types.ObjectId(oneInfo.dept2);
  976. // addQuery.dept3 = this.app.mongoose.Types.ObjectId(oneInfo.dept3);
  977. // addQuery.dept4 = this.app.mongoose.Types.ObjectId(oneInfo.dept4);
  978. // addQuery.dept5 = this.app.mongoose.Types.ObjectId(oneInfo.dept5);
  979. addQuery.type = '0';
  980. addQuery.fid = oneInfo.fid;
  981. addQuery.userid = oneInfo.userid;
  982. // addQuery.userName = oneInfo.userName;
  983. addQuery.infoId = oneInfo._id;
  984. await model.ValueModel.create(addQuery);
  985. }
  986. return result;
  987. }
  988. }
  989. } else if (status == '4') {
  990. // 修改状态==4 审核失败
  991. const result = await model.InfoModel.updateOne({ _id: id }, data);
  992. return result;
  993. }
  994. }
  995. if (oneInfo.status == '1') {
  996. if (status == '2') {
  997. // 修改状态==2 审批中
  998. const result = await model.InfoModel.updateOne({ _id: id }, data);
  999. return result;
  1000. } else if (status == '4') {
  1001. // 修改状态==4
  1002. const result = await model.InfoModel.updateOne({ _id: id }, data);
  1003. return result;
  1004. }
  1005. }
  1006. }
  1007. }
  1008. return '';
  1009. }
  1010. async isDeath(id, data) {
  1011. const { model } = this.ctx;
  1012. const result = await model.InfoModel.updateOne({ _id: id }, data);
  1013. return result;
  1014. }
  1015. // 修改离线状态
  1016. // async updateOffLine(id, offLineStatus) {
  1017. // const { model } = this.ctx;
  1018. // const result = await model.InfoModel.updateOne({ _id: id }, { offLine: offLineStatus });
  1019. // return result;
  1020. // }
  1021. /**
  1022. * 筛选----身份证重复录入
  1023. * */
  1024. async groupByNumber(data) {
  1025. const { model } = this.ctx;
  1026. const page = data.page || 1;
  1027. const rows = Number.parseInt(data.rows) || this.app.config.defaultPageSize;
  1028. delete data.page;
  1029. delete data.rows;
  1030. const where = {};
  1031. if (data.dept1) {
  1032. where.dept1 = this.app.mongoose.Types.ObjectId(data.dept1);// 省
  1033. }
  1034. if (data.dept2) {
  1035. where.dept2 = this.app.mongoose.Types.ObjectId(data.dept2); // 市
  1036. }
  1037. if (data.dept3) {
  1038. where.dept3 = this.app.mongoose.Types.ObjectId(data.dept3); // 区
  1039. }
  1040. if (data.dept4) {
  1041. where.dept4 = this.app.mongoose.Types.ObjectId(data.dept4); // 乡
  1042. }
  1043. if (data.dept5) {
  1044. where.dept5 = this.app.mongoose.Types.ObjectId(data.dept5); // 社区
  1045. }
  1046. where.$and = [{ idNumber: { $exists: true } }, { idNumber: { $ne: '' } }];
  1047. const countResult = await model.InfoModel.aggregate([
  1048. { $match: where },
  1049. { $group: {
  1050. _id: '$idNumber',
  1051. count: { $sum: 1 },
  1052. } },
  1053. { $match: { count: { $gt: 1 } } },
  1054. {
  1055. $count: 'count', // 总数
  1056. },
  1057. ]);
  1058. const result = await model.InfoModel.aggregate([
  1059. { $match: where },
  1060. { $group: {
  1061. _id: '$idNumber',
  1062. count: { $sum: 1 },
  1063. } },
  1064. { $match: { count: { $gt: 1 } } },
  1065. {
  1066. $sort: { time: -1 },
  1067. },
  1068. {
  1069. $skip: rows * (parseInt(page) - 1),
  1070. },
  1071. {
  1072. $limit: rows,
  1073. },
  1074. ]).allowDiskUse(true);
  1075. const returmData = {};
  1076. returmData.list = result;
  1077. returmData.count = 0;
  1078. if (countResult.length > 0) {
  1079. returmData.count = countResult[0].count;
  1080. }
  1081. returmData.page = data.page;
  1082. returmData.pageSize = data.rows;
  1083. return returmData;
  1084. }
  1085. async exportData(data) {
  1086. const { model } = this.ctx;
  1087. const where = {};
  1088. if (data.dept1) {
  1089. where.dept1 = data.dept1;// 省
  1090. }
  1091. if (data.dept2) {
  1092. where.dept2 = data.dept2; // 市
  1093. }
  1094. if (data.dept3) {
  1095. where.dept3 = data.dept3; // 区
  1096. }
  1097. if (data.dept4) {
  1098. where.dept4 = data.dept4; // 乡
  1099. }
  1100. if (data.dept5) {
  1101. where.dept5 = data.dept5; // 社区
  1102. }
  1103. // userid.loginName
  1104. if (data.cjname) {
  1105. // where.userName = { $regex: data.cjname }; // 管理员
  1106. // where['userInfo.loginName'] = { $regex: data.cjname };
  1107. const result = await model.SysUserModel.find({ loginName: { $regex: data.cjname } });
  1108. if (result.length > 0) {
  1109. where.userid = result[0]._id;
  1110. } else {
  1111. return '';
  1112. }
  1113. }
  1114. // 状态
  1115. where.status = '3';
  1116. // 老人常用联系电话
  1117. if (data.phone) {
  1118. where.phone = { $regex: data.phone };
  1119. }
  1120. // 老人姓名
  1121. if (data.name) {
  1122. where.name = { $regex: data.name };
  1123. }
  1124. // 老人年龄
  1125. if (data.age) {
  1126. const myDate = new Date();
  1127. const year = myDate.getFullYear();
  1128. const month = (myDate.getMonth() + 1) > 9 ? (myDate.getMonth() + 1) : '0' + (myDate.getMonth() + 1);
  1129. const day = myDate.getDate() > 9 ? (myDate.getDate()) : '0' + (myDate.getDate());
  1130. if (data.age > 0) {
  1131. where.idNumber = { $ne: '' };
  1132. where.birthday = { $lte: '' + year + month + day - (data.age * 10000) };
  1133. } else {
  1134. where.idNumber = { $ne: '' };
  1135. where.birthday = { $gte: '' + year + month + day - (-data.age * 10000) };
  1136. }
  1137. }
  1138. // 关爱服务需求
  1139. if (data.demand) {
  1140. // console.log('oldtype', data.oldType)
  1141. if (data.demand.indexOf(',') > -1) {
  1142. const ts = data.demand.split(',');
  1143. where.demand = { $in: ts };
  1144. } else {
  1145. where.demand = { $in: data.demand };
  1146. }
  1147. }
  1148. // 老人类别
  1149. if (data.oldType) {
  1150. // console.log('oldtype', data.oldType)
  1151. if (data.oldType.indexOf(',') > -1) {
  1152. const ts = data.oldType.split(',');
  1153. where.oldType = { $in: ts };
  1154. } else {
  1155. where.oldType = { $in: data.oldType };
  1156. }
  1157. }
  1158. // 离线采集
  1159. if (data.online) {
  1160. if (data.online == 'false') {
  1161. where.online = data.online;
  1162. }
  1163. if (data.online == 'true') {
  1164. // where.online = data.online;
  1165. where.$or = [{ online: { $exists: false } }, { online: data.online }];
  1166. }
  1167. }
  1168. // 身份证号码搜索
  1169. if (data.idNumber) {
  1170. where.idNumber = { $regex: data.idNumber };
  1171. }
  1172. // 老年人能力状况
  1173. if (data.ability) {
  1174. where.ability = data.ability;
  1175. }
  1176. this.ctx.logger.info('条件', where);
  1177. const pop = [
  1178. {
  1179. path: 'userid',
  1180. select: 'loginName userName',
  1181. },
  1182. {
  1183. path: 'dept1',
  1184. select: 'name',
  1185. },
  1186. {
  1187. path: 'dept2',
  1188. select: 'name',
  1189. },
  1190. {
  1191. path: 'dept3',
  1192. select: 'name',
  1193. },
  1194. {
  1195. path: 'dept4',
  1196. select: 'name',
  1197. },
  1198. {
  1199. path: 'dept5',
  1200. select: 'name',
  1201. },
  1202. ];
  1203. const result = await model.InfoModel.find(where, { dept1: 1, dept2: 1, dept3: 1, dept4: 1, dept5: 1, name: 1, sex: 1, nation: 1, idNumber: 1,
  1204. nativePlace: 1, address: 1, userid: 1, status: 1, phone: 1, ability: 1, demand: 1, birthday: 1, oldType: 1 }).sort({ time: -1 });
  1205. return result;
  1206. }
  1207. async yestdayNum(data, user) {
  1208. const { model } = this.ctx;
  1209. const level = user.dept.level;
  1210. const match = {};
  1211. // admin的dept 存在冲突,所以它不需要结合
  1212. if (user.role._id != this.app.config.defaultAdminRoleId) {
  1213. match['dept' + level] = this.app.mongoose.Types.ObjectId(user.dept._id);
  1214. }
  1215. match.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
  1216. this.ctx.logger.info('条件===============================================', match);
  1217. const finalarr = [];
  1218. const vote = {};
  1219. const nodonem = {};
  1220. if (user.role._id != this.app.config.defaultAdminRoleId) {
  1221. nodonem['dept' + level] = this.app.mongoose.Types.ObjectId(user.dept._id);
  1222. }
  1223. nodonem.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
  1224. nodonem.status = 0;
  1225. const writenostum = {};
  1226. if (user.role._id != this.app.config.defaultAdminRoleId) {
  1227. writenostum['dept' + level] = this.app.mongoose.Types.ObjectId(user.dept._id);
  1228. }
  1229. writenostum.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
  1230. writenostum.status = 1;
  1231. const stuingm = {};
  1232. if (user.role._id != this.app.config.defaultAdminRoleId) {
  1233. stuingm['dept' + level] = this.app.mongoose.Types.ObjectId(user.dept._id);
  1234. }
  1235. stuingm.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
  1236. stuingm.status = 2;
  1237. const stuedm = {};
  1238. if (user.role._id != this.app.config.defaultAdminRoleId) {
  1239. stuedm['dept' + level] = this.app.mongoose.Types.ObjectId(user.dept._id);
  1240. }
  1241. stuedm.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
  1242. stuedm.status = 3;
  1243. const fullstum = {};
  1244. if (user.role._id != this.app.config.defaultAdminRoleId) {
  1245. fullstum['dept' + level] = this.app.mongoose.Types.ObjectId(user.dept._id);
  1246. }
  1247. fullstum.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
  1248. fullstum.status = 4;
  1249. const sumnum = await model.InfoModel.find(match).countDocuments();
  1250. const nodone = await model.InfoModel.find(nodonem).countDocuments();
  1251. const writenostu = await model.InfoModel.find(writenostum).countDocuments();
  1252. const stuing = await model.InfoModel.find(stuingm).countDocuments();
  1253. const stued = await model.InfoModel.find(stuedm).countDocuments();
  1254. const fullstu = await model.InfoModel.find(fullstum).countDocuments();
  1255. vote.sumnum = sumnum;
  1256. vote.nodone = nodone;
  1257. vote.writenostu = writenostu;
  1258. vote.stuing = stuing;
  1259. vote.stued = stued;
  1260. vote.fullstu = fullstu;
  1261. finalarr.push(vote);
  1262. return finalarr;
  1263. }
  1264. }
  1265. module.exports = InfoService;