use of org.eevolution.model.X_T_MRP_CRP in project adempiere by adempiere.
the class CRPSummary method Summary.
public void Summary(Timestamp start, Timestamp finish, MResource r) {
GregorianCalendar gc1 = new GregorianCalendar();
gc1.setTimeInMillis(start.getTime());
gc1.clear(Calendar.MILLISECOND);
gc1.clear(Calendar.SECOND);
gc1.clear(Calendar.MINUTE);
gc1.clear(Calendar.HOUR_OF_DAY);
GregorianCalendar gc2 = new GregorianCalendar();
gc2.setTimeInMillis(finish.getTime());
gc2.clear(Calendar.MILLISECOND);
gc2.clear(Calendar.SECOND);
gc2.clear(Calendar.MINUTE);
gc2.clear(Calendar.HOUR_OF_DAY);
MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
long hours = 0;
if (t.isTimeSlot())
hours = getHoursAvailable(t.getTimeSlotStart(), t.getTimeSlotStart());
else
hours = 24;
boolean available = false;
ArrayList<Col> list = new ArrayList<Col>();
int col = 0;
int row = 1;
int summary = 0;
Col cols = new Col();
cols.setFrom("Past Due");
cols.setTo(start.toString());
cols.setDays(0);
cols.setCapacity(0);
cols.setLoad(0);
cols.setSummary(0);
list.add(0, cols);
col++;
while (gc1.before(gc2)) {
gc1.add(Calendar.DATE, 1);
switch(gc1.get(Calendar.DAY_OF_WEEK)) {
case Calendar.SUNDAY:
if (t.isOnSunday())
available = true;
break;
case Calendar.MONDAY:
if (t.isOnMonday())
available = true;
break;
case Calendar.TUESDAY:
if (t.isOnTuesday())
available = true;
break;
case Calendar.WEDNESDAY:
if (t.isOnWednesday())
available = true;
break;
case Calendar.THURSDAY:
if (t.isOnThursday())
available = true;
break;
case Calendar.FRIDAY:
if (t.isOnFriday())
available = true;
break;
case Calendar.SATURDAY:
if (t.isOnSaturday())
available = true;
break;
}
if (available) {
cols = new Col();
cols.setFrom(gc1.getTime().toString());
cols.setTo(gc1.getTime().toString());
cols.setDays(1);
Long Hours = new Long(hours);
cols.setCapacity(Hours.intValue());
int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ", r.getS_Resource_ID());
MUOM oum = MUOM.get(getCtx(), C_UOM_ID);
if (oum.isHour()) {
Timestamp date = new Timestamp(gc1.getTimeInMillis());
int seconds = getLoad(r.getS_Resource_ID(), date, date);
cols.setLoad(seconds / 3600);
}
cols.setSummary(summary + cols.getDifference());
summary = cols.getSummary();
list.add(col, cols);
}
}
col = 0;
boolean newrow = true;
Col[] lines = new Col[list.size()];
//set Title
for (int z = 0; z <= lines.length; z++) {
}
for (int i = 0; i <= lines.length; i++) {
if (newrow) {
X_T_MRP_CRP crp = new X_T_MRP_CRP(getCtx(), 0, null);
crp.setDescription("CRP Resource" + r.getName());
//crp.setRange00(lines[i].getFrom() + "/" + lines[i].getTo());
}
switch(col) {
case 0:
col++;
case 1:
col++;
case 2:
col++;
case 3:
col++;
case 4:
col++;
case 5:
col++;
case 6:
col++;
case 7:
col++;
case 8:
col++;
case 9:
col++;
case 10:
col++;
case 11:
col++;
case 12:
col = 0;
newrow = true;
}
col++;
}
}
Aggregations