main
rustdreamer 2 years ago
parent bb5010cd06
commit 6553f99056

@ -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
}

Loading…
Cancel
Save