我正忙于添加功能,将服务费用的开始和结束日期添加到服务费用中。服务费目前包含最低提款金额,费用以及开始和结束日期。
要求是您可以拥有多个不同的最低提款金额,所有这些金额都有自己的期间(开始和结束日期)。尽管允许有差距,但允许具有相同最小提款金额的项目的期间重叠。最终要求是您可以在任何给定时间设置不同的最低提款金额,即如果金额设置为5,您可以在任何给定时间点获得5个不同的服务费用。
现在我的问题是最后一部分,确保在任何给定的时间点只有一定数量的句号活跃。
让事情变得更加困难..我不能使用Calendar类,因为我在GWT中这样做只支持Date类..
这是我到目前为止所拥有的......
private boolean checkDates() {
int maxSlates = orgs.getMaxSlates();
for (WfScServiceCharge wfsc : serviceCharges) {
Date startDate = wfsc.getScEffectiveStart();
Date endDate = wfsc.getScEffectiveEnd();
int slates = 0;
for (WfScServiceCharge wfsc2 : serviceCharges) {
// dont check slate against itself
if (!wfsc.equals(wfsc2)) {
// check slates with same min withdraw amounts
if (wfsc.getScMinWithdrawAmount() == wfsc2.getScMinWithdrawAmount()) {
// check that periods dont overlap
if ((startDate.after(wfsc2.getScEffectiveStart()) && startDate
.before(wfsc2.getScEffectiveEnd()))
|| (endDate.after(wfsc2.getScEffectiveStart()) && endDate
.before(wfsc2.getScEffectiveEnd()))) {
Window
.alert("Period clashes with an already configured"
+ " period for a service charge with the same minimum withdrawal amount.");
return false;
}
}
// check number of distinct slates for any given period
// THIS IS WHERE I NEED HELP!
if (wfsc2.getScEffectiveStart().compareTo(startDate) >= 0
|| wfsc2.getScEffectiveEnd().compareTo(endDate) <= 0) {
slates++;
}
if (slates > maxSlates) {
Window.alert("Maximum amount of slates reached for time period. "
+ "Please change the period that this slate needs to fall in.");
return false;
}
}
}
}
return true;
}