ItEr30S11CUVistaRecursosTempoEmpresaItEr29S13: Fixing problem when there are gaps in the planning.
This commit is contained in:
parent
6dd07417d5
commit
4fa9ad309f
2 changed files with 92 additions and 6 deletions
|
|
@ -82,6 +82,12 @@ import org.zkoss.zul.Div;
|
|||
@Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||
public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
||||
|
||||
/**
|
||||
* Number of days to Thursday since the beginning of the week. In order to
|
||||
* calculate the middle of a week.
|
||||
*/
|
||||
private final static int DAYS_TO_THURSDAY = 3;
|
||||
|
||||
@Autowired
|
||||
private IOrderDAO orderDAO;
|
||||
|
||||
|
|
@ -352,8 +358,13 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
|
||||
fillZeroValueFromStart(writer, start, mapDayAssignments);
|
||||
|
||||
for (LocalDate day : mapDayAssignments.keySet()) {
|
||||
Integer hours = mapDayAssignments.get(day);
|
||||
LocalDate firstDay = firstDay(mapDayAssignments);
|
||||
LocalDate lastDay = lastDay(mapDayAssignments);
|
||||
|
||||
for (LocalDate day = firstDay; day.compareTo(lastDay) <= 0; day = nextDay(day)) {
|
||||
Integer hours = mapDayAssignments.get(day) != null ? mapDayAssignments
|
||||
.get(day)
|
||||
: 0;
|
||||
printLine(writer, day, hours);
|
||||
}
|
||||
|
||||
|
|
@ -365,6 +376,34 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
return uri;
|
||||
}
|
||||
|
||||
private LocalDate firstDay(SortedMap<LocalDate, Integer> mapDayAssignments) {
|
||||
LocalDate date = mapDayAssignments.firstKey();
|
||||
if (zoomByDay()) {
|
||||
return date;
|
||||
} else {
|
||||
return date.dayOfWeek().withMinimumValue().plusDays(
|
||||
DAYS_TO_THURSDAY);
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDate lastDay(SortedMap<LocalDate, Integer> mapDayAssignments) {
|
||||
LocalDate date = mapDayAssignments.lastKey();
|
||||
if (zoomByDay()) {
|
||||
return date;
|
||||
} else {
|
||||
return date.dayOfWeek().withMinimumValue().plusDays(
|
||||
DAYS_TO_THURSDAY);
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDate nextDay(LocalDate date) {
|
||||
if (zoomByDay()) {
|
||||
return date;
|
||||
} else {
|
||||
return date.plusWeeks(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the hours by day for all the {@link DayAssignment} in the list.
|
||||
*
|
||||
|
|
@ -476,4 +515,8 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
return div;
|
||||
}
|
||||
|
||||
private boolean zoomByDay() {
|
||||
return zoomLevel.equals(ZoomLevel.DETAIL_FIVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,12 @@ import org.zkoss.zul.Div;
|
|||
@Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||
public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
||||
|
||||
/**
|
||||
* Number of days to Thursday since the beginning of the week. In order to
|
||||
* calculate the middle of a week.
|
||||
*/
|
||||
private final static int DAYS_TO_THURSDAY = 3;
|
||||
|
||||
@Autowired
|
||||
private IOrderDAO orderDAO;
|
||||
|
||||
|
|
@ -470,8 +476,13 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
|
||||
fillZeroValueFromStart(writer, start, mapDayAssignments);
|
||||
|
||||
for (LocalDate day : mapDayAssignments.keySet()) {
|
||||
Integer hours = mapDayAssignments.get(day);
|
||||
LocalDate firstDay = firstDay(mapDayAssignments);
|
||||
LocalDate lastDay = lastDay(mapDayAssignments);
|
||||
|
||||
for (LocalDate day = firstDay; day.compareTo(lastDay) <= 0; day = nextDay(day)) {
|
||||
Integer hours = mapDayAssignments.get(day) != null ? mapDayAssignments
|
||||
.get(day)
|
||||
: 0;
|
||||
printLine(writer, day, hours);
|
||||
}
|
||||
|
||||
|
|
@ -483,6 +494,34 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
return uri;
|
||||
}
|
||||
|
||||
private LocalDate firstDay(SortedMap<LocalDate, Integer> mapDayAssignments) {
|
||||
LocalDate date = mapDayAssignments.firstKey();
|
||||
if (zoomByDay()) {
|
||||
return date;
|
||||
} else {
|
||||
return date.dayOfWeek().withMinimumValue().plusDays(
|
||||
DAYS_TO_THURSDAY);
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDate lastDay(SortedMap<LocalDate, Integer> mapDayAssignments) {
|
||||
LocalDate date = mapDayAssignments.lastKey();
|
||||
if (zoomByDay()) {
|
||||
return date;
|
||||
} else {
|
||||
return date.dayOfWeek().withMinimumValue().plusDays(
|
||||
DAYS_TO_THURSDAY);
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDate nextDay(LocalDate date) {
|
||||
if (zoomByDay()) {
|
||||
return date;
|
||||
} else {
|
||||
return date.plusWeeks(1);
|
||||
}
|
||||
}
|
||||
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments) {
|
||||
return calculateHoursAdditionByDay(dayAssignments, false, null, null);
|
||||
|
|
@ -584,7 +623,7 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
}
|
||||
}
|
||||
|
||||
if (zoomLevel.equals(ZoomLevel.DETAIL_FIVE)) {
|
||||
if (zoomByDay()) {
|
||||
return map;
|
||||
} else {
|
||||
return groupByWeek(map);
|
||||
|
|
@ -613,7 +652,7 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
}
|
||||
|
||||
private LocalDate getKey(LocalDate date) {
|
||||
return date.dayOfWeek().withMinimumValue().plusDays(3);
|
||||
return date.dayOfWeek().withMinimumValue().plusDays(DAYS_TO_THURSDAY);
|
||||
}
|
||||
|
||||
private void setMaximunValueForChartIfGreater(Integer max) {
|
||||
|
|
@ -631,4 +670,8 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
return div;
|
||||
}
|
||||
|
||||
private boolean zoomByDay() {
|
||||
return zoomLevel.equals(ZoomLevel.DETAIL_FIVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue