Skip to content

Commit

Permalink
OPD Weekly Report issue fix (#10627)
Browse files Browse the repository at this point in the history
Co-authored-by: imexh <[email protected]>
  • Loading branch information
ImeshRanawellaSG and imexh authored Feb 19, 2025
1 parent fd00a63 commit 5d81fd0
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/main/java/com/divudi/bean/common/ReportsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@
import javax.persistence.TemporalType;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.time.YearMonth;
import java.time.LocalDate;
import java.time.Month;
import java.time.ZoneId;
import java.time.*;
import java.util.*;
import java.util.List;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -1974,20 +1971,33 @@ public List<Integer> getDaysOfWeek(final int weekOfMonth) {
}

final YearMonth yearMonth = YearMonth.of(LocalDate.now().getYear(), month);
final LocalDate firstDayOfMonth = yearMonth.atDay(1);

List<Integer> daysOfWeek = new ArrayList<>();

LocalDate firstDayOfMonth = yearMonth.atDay(1);
int firstDayOfTargetWeek = (weekOfMonth - 1) * 7 + 1;

for (int i = 0; i < 7; i++) {
LocalDate day = firstDayOfMonth.plusDays(firstDayOfTargetWeek - 1 + i);
LocalDate firstSunday = firstDayOfMonth;
while (firstSunday.getDayOfWeek() != DayOfWeek.SUNDAY) {
firstSunday = firstSunday.plusDays(1);
}

if (day.getMonth() != yearMonth.getMonth()) {
break;
if (weekOfMonth == 1) {
LocalDate currentDay = firstDayOfMonth;
while (currentDay.getDayOfWeek() != DayOfWeek.SUNDAY && currentDay.getMonthValue() == month.getValue()) {
daysOfWeek.add(currentDay.getDayOfMonth());
currentDay = currentDay.plusDays(1);
}
} else {
LocalDate firstDayOfWeek = firstSunday.plusWeeks(weekOfMonth - 2);

for (int i = 0; i < 7; i++) {
LocalDate day = firstDayOfWeek.plusDays(i);

daysOfWeek.add(day.getDayOfMonth());
if (day.getMonthValue() != month.getValue()) {
break;
}

daysOfWeek.add(day.getDayOfMonth());
}
}

return daysOfWeek;
Expand Down Expand Up @@ -2097,12 +2107,6 @@ private ReportTemplateRowBundle generateWeeklyBillItems(List<BillTypeAtomic> bts
jpql += "AND bill.billTypeAtomic in :bts ";
parameters.put("bts", bts);

// if (visitType != null) {
// if (visitType.equalsIgnoreCase("IP") || visitType.equalsIgnoreCase("OP")) {
// jpql += "AND bill.ipOpOrCc = :type ";
// parameters.put("type", visitType);
// }
// }
if (getSearchKeyword().getItemName() != null && !getSearchKeyword().getItemName().trim().isEmpty()) {
jpql += "AND ((bill.billPackege.name) like :itemName ) ";
parameters.put("itemName", "%" + getSearchKeyword().getItemName().trim().toUpperCase() + "%");
Expand Down

0 comments on commit 5d81fd0

Please sign in to comment.