From 6553f990565b53c796a6822972ed31595158e20a Mon Sep 17 00:00:00 2001 From: rustdreamer Date: Wed, 27 Sep 2023 13:27:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.controller.ts | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/app.controller.ts b/src/app.controller.ts index a623344..c3c0d00 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -230,28 +230,49 @@ export class AppController { @ApiBearerAuth() async getVisiotr(@Query() { identity_card_no }: QueryVisitorByNumberDto, @Req() req: any) { let date = new Date().toDateString(); - const node_other_visitor: any = await this.nodeOtherVisitorRepository.findOne({ + let node_other_visitor; + const node_other_visitors: any = await this.nodeOtherVisitorRepository.findOne({ where: { identity_card_no, end_time: IsNull() }, order: { created_date: "DESC" } }); - // console.log('node_other_visitor', node_other_visitor) - if (node_other_visitor) { + await bluebird.each(node_other_visitors, async (item) => { const node_visitor = await this.nodeVisitorRepository.findOne({ - where: { id: node_other_visitor.node_visitor_id } + where: { id: item.node_visitor_id } }) // console.log('node_visitor', node_visitor) // console.log('new Date(node_visitor.start_date)', new Date(node_visitor.start_date)) // console.log('new Date(node_visitor.end_date)', new Date(node_visitor.end_date)) // console.log('new Date(date)', new Date(date)) if (node_visitor && new Date(node_visitor.start_date) <= new Date(date) && new Date(node_visitor.end_date) >= new Date(date)) { - node_other_visitor.info = node_visitor; - } else { - return null; + item.info = node_visitor; + node_other_visitor = item; } + }) + // console.log('node_other_visitor', node_other_visitor) + // const node_other_visitor: any = await this.nodeOtherVisitorRepository.findOne({ + // where: { identity_card_no, end_time: IsNull() }, + // order: { + // created_date: "DESC" + // } + // }); + // // console.log('node_other_visitor', node_other_visitor) + // if (node_other_visitor) { + // const node_visitor = await this.nodeVisitorRepository.findOne({ + // where: { id: node_other_visitor.node_visitor_id } + // }) + // // console.log('node_visitor', node_visitor) + // // console.log('new Date(node_visitor.start_date)', new Date(node_visitor.start_date)) + // // console.log('new Date(node_visitor.end_date)', new Date(node_visitor.end_date)) + // // console.log('new Date(date)', new Date(date)) + // if (node_visitor && new Date(node_visitor.start_date) <= new Date(date) && new Date(node_visitor.end_date) >= new Date(date)) { + // node_other_visitor.info = node_visitor; + // } else { + // return null; + // } - } + // } return node_other_visitor }