| @@ -8,6 +8,7 @@ import java.util.Calendar; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import org.apache.commons.collections4.CollectionUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.joda.time.DateTime; | |||
| import org.joda.time.Months; | |||
| @@ -540,7 +541,7 @@ public class WxRentContractHelper { | |||
| System.out.println("首1月>>>>"+DateUtils.date2String(start)+">>>"+DateUtils.date2String(lastMonthDay)+">>>>"+total.toPlainString()); | |||
| //中间月份 | |||
| Date newStartDate = DateUtils.getDaySet(lastMonthDay,Calendar.DATE,1); | |||
| Date newStartDate = DateUtils.getDaySet(lastMonthDay,Calendar.SECOND,1); | |||
| int months = getMonths(sdM.format(newStartDate)+"-01",sdM.format(end)+"-01"); | |||
| for (int i = 0 ; i < months; i++) { | |||
| Date currentMonthEnd = DateUtils.getLastDayForMonth(newStartDate); | |||
| @@ -549,7 +550,7 @@ public class WxRentContractHelper { | |||
| }else { | |||
| NeedPayDTO _np = getCurrentMonthPay(newStartDate, currentMonthEnd, price, decimalSize, _validDays, dayPriceCalcute, monthAvageDays); | |||
| System.out.println(i+2+"月>>>>"+DateUtils.date2String(newStartDate)+">>>>"+DateUtils.date2String(currentMonthEnd)+">>>>"+_np.getMoney().toPlainString()); | |||
| newStartDate = DateUtils.getDaySet(currentMonthEnd,Calendar.DATE,1); | |||
| newStartDate = DateUtils.getDaySet(currentMonthEnd,Calendar.SECOND,1); | |||
| total = total.add(_np.getMoney()); | |||
| } | |||
| } | |||
| @@ -575,16 +576,12 @@ public class WxRentContractHelper { | |||
| } | |||
| List<Date> validDays = new ArrayList<Date>(); | |||
| validDays.addAll(allDaysFrees); | |||
| if (null != freeDays && freeDays.size() > 0 ) { | |||
| allDaysFrees.retainAll(freeDays); | |||
| } | |||
| if (null != freeDays && freeDays.size() > 0 && null != allDaysFrees && allDaysFrees.size() > 0 ) { | |||
| validDays.removeAll(allDaysFrees); | |||
| } | |||
| if (validDays.size() <= 0 ) { | |||
| return null; | |||
| if (null != freeDays) { | |||
| List<Date> curfreeDays = (List<Date>)CollectionUtils.intersection(allDaysFrees, freeDays); | |||
| if (null != curfreeDays) { | |||
| validDays.removeAll(curfreeDays); | |||
| } | |||
| } | |||
| return validDays; | |||
| } | |||
| @@ -775,18 +772,24 @@ public class WxRentContractHelper { | |||
| } | |||
| public static void main(String[] args) { | |||
| Date start = DateUtils.str2Date("2024-08-05 00:00:00").getTime(); | |||
| Date end = DateUtils.str2Date("2025-11-04 23:59:59").getTime(); | |||
| Date d1 = DateUtils.str2Date("2024-07-31 00:00:00").getTime(); | |||
| Date d2 = DateUtils.str2Date("2024-08-03 00:00:00").getTime(); | |||
| Date d3 = DateUtils.str2Date("2024-08-06 00:00:00").getTime(); | |||
| Date d4 = DateUtils.str2Date("2024-08-31 00:00:00").getTime(); | |||
| Date d5 = DateUtils.str2Date("2024-09-01 00:00:00").getTime(); | |||
| Date d6 = DateUtils.str2Date("2024-09-11 00:00:00").getTime(); | |||
| Date d7 = DateUtils.str2Date("2024-09-30 00:00:00").getTime(); | |||
| Date start = DateUtils.str2Date("2024-09-01 00:00:00").getTime(); | |||
| Date end = DateUtils.str2Date("2024-09-30 23:59:59").getTime(); | |||
| List<Date> freeDays = new ArrayList<Date>(); | |||
| Date d1 = DateUtils.str2Date("2024-00-01 00:00:00").getTime(); | |||
| Date d2 = DateUtils.str2Date("2024-09-30 23:59:59").getTime(); | |||
| System.out.println(getValidDays(start,end,DateUtils.getAllDays(d1, d2))); | |||
| // Date start = DateUtils.str2Date("2024-08-05 00:00:00").getTime(); | |||
| // Date end = DateUtils.str2Date("2025-11-04 23:59:59").getTime(); | |||
| // | |||
| // Date d1 = DateUtils.str2Date("2024-07-31 00:00:00").getTime(); | |||
| // Date d2 = DateUtils.str2Date("2024-08-03 00:00:00").getTime(); | |||
| // Date d3 = DateUtils.str2Date("2024-08-06 00:00:00").getTime(); | |||
| // Date d4 = DateUtils.str2Date("2024-08-31 00:00:00").getTime(); | |||
| // Date d5 = DateUtils.str2Date("2024-09-01 00:00:00").getTime(); | |||
| // Date d6 = DateUtils.str2Date("2024-09-11 00:00:00").getTime(); | |||
| // Date d7 = DateUtils.str2Date("2024-09-30 00:00:00").getTime(); | |||
| // | |||
| // List<Date> freeDays = new ArrayList<Date>(); | |||
| // freeDays.add(d1); | |||
| // freeDays.add(d2); | |||
| // freeDays.add(d3); | |||
| @@ -795,7 +798,7 @@ public class WxRentContractHelper { | |||
| // freeDays.add(d6); | |||
| // freeDays.add(d7); | |||
| System.out.println(DateUtils.getDaySet(d1, Calendar.DATE, -1)); | |||
| // System.out.println(DateUtils.getDaySet(d1, Calendar.DATE, -1)); | |||
| //String dayMoney = getNeedPay(freeDays, 2, new BigDecimal(10), start, end, EnumRentDayPriceCalcute.AVERAGE_DAYS, 30); | |||
| //System.out.println(dayMoney); | |||