Commit c79ff174a158a7d7aeba009c9987f24a9ae5a7ee
1 parent
3b1831de7d
Exists in
master
and in
6 other branches
追访记录
Showing 1 changed file with 53 additions and 7 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyAfterVisitServiceImpl.java
View file @
c79ff17
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | import org.springframework.data.mongodb.core.query.Update; |
36 | 36 | import org.springframework.stereotype.Service; |
37 | 37 | |
38 | +import java.math.BigInteger; | |
38 | 39 | import java.util.*; |
39 | 40 | import java.util.concurrent.*; |
40 | 41 | import java.util.regex.Pattern; |
... | ... | @@ -397,8 +398,17 @@ |
397 | 398 | Date s1 = DateUtil.parseYMDHMS(startAppointmentTime); |
398 | 399 | Date e1 = DateUtil.parseYMDHMS(endAppointmentTime); |
399 | 400 | |
400 | - Date e2 = getEndDate(beyondDay); | |
401 | - Date s2 = getStartDate(beyondDay); | |
401 | + Date s2; | |
402 | + Date e2; | |
403 | + if (beyondDay < 0) { | |
404 | + beyondDay = new BigInteger(beyondDay.toString()).abs().intValue(); | |
405 | + e2 = getEndDateByLtZero(beyondDay); | |
406 | + s2 = getStartDateByLtZero(beyondDay); | |
407 | + } else { | |
408 | + e2 = getEndDate(beyondDay); | |
409 | + s2 = getStartDate(beyondDay); | |
410 | + } | |
411 | + | |
402 | 412 | Date date = new Date(); |
403 | 413 | // 交集 |
404 | 414 | boolean a = s2.before(e1) && e1.after(e2) && s1.before(s2) && date.after(s2) && date.before(e1); |
405 | 415 | |
406 | 416 | |
... | ... | @@ -426,13 +436,23 @@ |
426 | 436 | query.addCriteria(Criteria.where("appointmentTime").gte(startDate).lte(date)); |
427 | 437 | } |
428 | 438 | if (!appointmentTimeBoolean && nonNull) { |
429 | - Date end = getEndDate(beyondDay); | |
430 | - Date start = getStartDate(beyondDay); | |
439 | + Date end; | |
440 | + Date start; | |
431 | 441 | Date date = new Date(); |
432 | - if (date.before(start) || date.after(end)){ | |
433 | - return new BaseResponse(); | |
442 | + if (beyondDay > 0) { | |
443 | + end = getEndDate(beyondDay); | |
444 | + start = getStartDate(beyondDay); | |
445 | + if (date.before(start) || date.after(end)) { | |
446 | + return new BaseResponse(); | |
447 | + } | |
448 | + query.addCriteria(Criteria.where("appointmentTime").gte(start).lte(date)); | |
449 | + } else { | |
450 | + // 针对逾期天数为负数 | |
451 | + beyondDay = new BigInteger(beyondDay.toString()).abs().intValue(); | |
452 | + start = getStartDateByLtZero(beyondDay); | |
453 | + end = getEndDateByLtZero(beyondDay); | |
454 | + query.addCriteria(Criteria.where("appointmentTime").gte(start).lte(end)); | |
434 | 455 | } |
435 | - query.addCriteria(Criteria.where("appointmentTime").gte(start).lte(date)); | |
436 | 456 | } |
437 | 457 | |
438 | 458 | |
... | ... | @@ -528,6 +548,19 @@ |
528 | 548 | return end; |
529 | 549 | } |
530 | 550 | |
551 | + private Date getEndDateByLtZero(Integer beyondDay) { | |
552 | + Calendar instance = Calendar.getInstance(); | |
553 | + instance.setTime(new Date()); | |
554 | + instance.add(Calendar.DATE, beyondDay); | |
555 | + instance.set(Calendar.HOUR_OF_DAY, 23); | |
556 | + instance.set(Calendar.MINUTE, 59); | |
557 | + instance.set(Calendar.SECOND, 59); | |
558 | + instance.set(Calendar.MILLISECOND, 999); | |
559 | + Date end = instance.getTime(); | |
560 | + return end; | |
561 | + } | |
562 | + | |
563 | + | |
531 | 564 | private Date getStartDate(Integer beyondDay) { |
532 | 565 | Calendar instance = Calendar.getInstance(); |
533 | 566 | instance.setTime(new Date()); |
... | ... | @@ -539,6 +572,19 @@ |
539 | 572 | Date start = instance.getTime(); |
540 | 573 | return start; |
541 | 574 | } |
575 | + | |
576 | + private Date getStartDateByLtZero(Integer beyondDay) { | |
577 | + Calendar instance = Calendar.getInstance(); | |
578 | + instance.setTime(new Date()); | |
579 | + instance.add(Calendar.DATE, beyondDay); | |
580 | + instance.set(Calendar.HOUR_OF_DAY, 00); | |
581 | + instance.set(Calendar.MINUTE, 00); | |
582 | + instance.set(Calendar.SECOND, 00); | |
583 | + instance.set(Calendar.MILLISECOND, 000); | |
584 | + Date start = instance.getTime(); | |
585 | + return start; | |
586 | + } | |
587 | + | |
542 | 588 | |
543 | 589 | /** |
544 | 590 | * 递归获取预约建档的儿童信息 |