CRP: fix indentation
This commit is contained in:
parent
6a953c5e12
commit
47324c4dbd
|
@ -49,11 +49,11 @@ public class CRP extends SvrProcess {
|
|||
private String p_ScheduleType;
|
||||
private CRPReasoner reasoner;
|
||||
|
||||
public CRP() {
|
||||
public CRP() {
|
||||
|
||||
super();
|
||||
reasoner = new CRPReasoner();
|
||||
}
|
||||
super();
|
||||
reasoner = new CRPReasoner();
|
||||
}
|
||||
|
||||
protected void prepare() {
|
||||
|
||||
|
@ -74,320 +74,320 @@ public class CRP extends SvrProcess {
|
|||
String name = para[i].getParameterName();
|
||||
if (name.equals("S_Resource_ID")) {
|
||||
|
||||
p_S_Resource_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
p_S_Resource_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
}
|
||||
else if (name.equals("ScheduleType")) {
|
||||
|
||||
p_ScheduleType = ((String)para[i].getParameter());
|
||||
}
|
||||
else {
|
||||
else {
|
||||
|
||||
log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name);
|
||||
}
|
||||
log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String doIt() throws Exception {
|
||||
protected String doIt() throws Exception {
|
||||
|
||||
return runCRP();
|
||||
}
|
||||
return runCRP();
|
||||
}
|
||||
|
||||
private String runCRP() {
|
||||
private String runCRP() {
|
||||
|
||||
MPPOrderWorkflow owf = null;
|
||||
MPPOrderNode node = null;
|
||||
MResource resource = null;
|
||||
MResourceType resourceType = null;
|
||||
MPPOrderWorkflow owf = null;
|
||||
MPPOrderNode node = null;
|
||||
MResource resource = null;
|
||||
MResourceType resourceType = null;
|
||||
|
||||
BigDecimal qtyOpen = null;
|
||||
BigDecimal qtyOpen = null;
|
||||
|
||||
Timestamp date = null;
|
||||
Timestamp dateStart = null;
|
||||
Timestamp dateFinish = null;
|
||||
Timestamp date = null;
|
||||
Timestamp dateStart = null;
|
||||
Timestamp dateFinish = null;
|
||||
|
||||
long nodeMillis = 0;
|
||||
int nodeId = -1;
|
||||
long nodeMillis = 0;
|
||||
int nodeId = -1;
|
||||
|
||||
resource = new MResource(Env.getCtx(), p_S_Resource_ID, null);
|
||||
MPPOrder[] orders = reasoner.getPPOrdersNotCompleted(resource);
|
||||
log.log(Level.INFO,"MPP_Order[] : " + orders.length);
|
||||
for(int i = 0; i < orders.length; i++) {
|
||||
resource = new MResource(Env.getCtx(), p_S_Resource_ID, null);
|
||||
MPPOrder[] orders = reasoner.getPPOrdersNotCompleted(resource);
|
||||
log.log(Level.INFO,"MPP_Order[] : " + orders.length);
|
||||
for(int i = 0; i < orders.length; i++) {
|
||||
|
||||
qtyOpen = orders[i].getQtyOrdered().subtract(orders[i].getQtyDelivered()).subtract(orders[i].getQtyScrap());
|
||||
owf = reasoner.getPPOrderWorkflow(orders[i]);
|
||||
qtyOpen = orders[i].getQtyOrdered().subtract(orders[i].getQtyDelivered()).subtract(orders[i].getQtyScrap());
|
||||
owf = reasoner.getPPOrderWorkflow(orders[i]);
|
||||
if(owf == null) {
|
||||
|
||||
return Msg.translate(Env.getCtx(), "Error");
|
||||
}
|
||||
|
||||
// Schedule Fordward
|
||||
if (p_ScheduleType.equals(FORWARD_SCHEDULING)) {
|
||||
log.log(Level.FINE,"MPP_Order DocumentNo:" + orders[i].getDocumentNo());
|
||||
log.log(Level.FINE,"MPP_Order Workflow:" + owf.getName());
|
||||
date = orders[i].getDateStartSchedule();
|
||||
nodeId = owf.getPP_Order_Node_ID();
|
||||
while(nodeId != 0) {
|
||||
// Schedule Fordward
|
||||
if (p_ScheduleType.equals(FORWARD_SCHEDULING)) {
|
||||
log.log(Level.FINE,"MPP_Order DocumentNo:" + orders[i].getDocumentNo());
|
||||
log.log(Level.FINE,"MPP_Order Workflow:" + owf.getName());
|
||||
date = orders[i].getDateStartSchedule();
|
||||
nodeId = owf.getPP_Order_Node_ID();
|
||||
while(nodeId != 0) {
|
||||
|
||||
node = new MPPOrderNode(getCtx(),nodeId , get_TrxName());
|
||||
log.log(Level.FINE,"MPP_Order Node:" + node.getName() + " Description:" + node.getDescription());
|
||||
resource = new MResource(Env.getCtx(), node.getS_Resource_ID(), null);
|
||||
resourceType = new MResourceType(Env.getCtx(), resource.getS_ResourceType_ID(), null);
|
||||
node = new MPPOrderNode(getCtx(),nodeId , get_TrxName());
|
||||
log.log(Level.FINE,"MPP_Order Node:" + node.getName() + " Description:" + node.getDescription());
|
||||
resource = new MResource(Env.getCtx(), node.getS_Resource_ID(), null);
|
||||
resourceType = new MResourceType(Env.getCtx(), resource.getS_ResourceType_ID(), null);
|
||||
|
||||
// Checks, whether the resource type is principal available on one day a week.
|
||||
// If not, process breaks with a Info message about.
|
||||
if(!reasoner.checkResourceTypeAvailability(resourceType)) {
|
||||
// Checks, whether the resource type is principal available on one day a week.
|
||||
// If not, process breaks with a Info message about.
|
||||
if(!reasoner.checkResourceTypeAvailability(resourceType)) {
|
||||
|
||||
return Msg.getMsg(Env.getCtx(), "ResourceNotInSlotDay");
|
||||
}
|
||||
return Msg.getMsg(Env.getCtx(), "ResourceNotInSlotDay");
|
||||
}
|
||||
|
||||
nodeMillis = calculateMillisFor(node, resourceType, qtyOpen, owf.getDurationBaseSec());
|
||||
dateFinish = scheduleForward(date, nodeMillis ,resource, resourceType);
|
||||
nodeMillis = calculateMillisFor(node, resourceType, qtyOpen, owf.getDurationBaseSec());
|
||||
dateFinish = scheduleForward(date, nodeMillis ,resource, resourceType);
|
||||
|
||||
node.setDateStartSchedule(date);
|
||||
node.setDateFinishSchedule(dateFinish);
|
||||
node.save(get_TrxName());
|
||||
date = node.getDateFinishSchedule();
|
||||
nodeId = owf.getNext(nodeId,getAD_Client_ID());
|
||||
if (nodeId == 0)
|
||||
log.log(Level.FINE,"---------------MPP_Order Node Next not exist:" );
|
||||
}
|
||||
if (node!=null)
|
||||
orders[i].setDateFinishSchedule(node.getDateFinishSchedule());
|
||||
}
|
||||
// Schedule backward
|
||||
else if (p_ScheduleType.equals(BACKWARD_SCHEDULING)) {
|
||||
node.setDateStartSchedule(date);
|
||||
node.setDateFinishSchedule(dateFinish);
|
||||
node.save(get_TrxName());
|
||||
date = node.getDateFinishSchedule();
|
||||
nodeId = owf.getNext(nodeId,getAD_Client_ID());
|
||||
if (nodeId == 0)
|
||||
log.log(Level.FINE,"---------------MPP_Order Node Next not exist:" );
|
||||
}
|
||||
if (node!=null)
|
||||
orders[i].setDateFinishSchedule(node.getDateFinishSchedule());
|
||||
}
|
||||
// Schedule backward
|
||||
else if (p_ScheduleType.equals(BACKWARD_SCHEDULING)) {
|
||||
|
||||
log.log(Level.FINE,"MPP_Order DocumentNo:" + orders[i].getDocumentNo());
|
||||
log.log(Level.FINE,"MPP_Order Workflow:" + owf.getName());
|
||||
date = orders[i].getDateFinishSchedule();
|
||||
nodeId = owf.getLast(0, getAD_Client_ID());
|
||||
log.log(Level.FINE,"MPP_Order DocumentNo:" + orders[i].getDocumentNo());
|
||||
log.log(Level.FINE,"MPP_Order Workflow:" + owf.getName());
|
||||
date = orders[i].getDateFinishSchedule();
|
||||
nodeId = owf.getLast(0, getAD_Client_ID());
|
||||
|
||||
while(nodeId != 0) {
|
||||
while(nodeId != 0) {
|
||||
|
||||
node = new MPPOrderNode(getCtx(),nodeId , get_TrxName());
|
||||
log.log(Level.FINE,"MPP_Order Node:" + node.getName() + " Description:" + node.getDescription());
|
||||
resource = new MResource(Env.getCtx(), node.getS_Resource_ID(), null);
|
||||
resourceType = new MResourceType(Env.getCtx(), resource.getS_ResourceType_ID(), null);
|
||||
node = new MPPOrderNode(getCtx(),nodeId , get_TrxName());
|
||||
log.log(Level.FINE,"MPP_Order Node:" + node.getName() + " Description:" + node.getDescription());
|
||||
resource = new MResource(Env.getCtx(), node.getS_Resource_ID(), null);
|
||||
resourceType = new MResourceType(Env.getCtx(), resource.getS_ResourceType_ID(), null);
|
||||
|
||||
// Checks, whether the resource type is principal available on one day a week.
|
||||
// If not, process breaks with a Info message about.
|
||||
if(!reasoner.checkResourceTypeAvailability(resourceType)) {
|
||||
// Checks, whether the resource type is principal available on one day a week.
|
||||
// If not, process breaks with a Info message about.
|
||||
if(!reasoner.checkResourceTypeAvailability(resourceType)) {
|
||||
|
||||
return Msg.getMsg(Env.getCtx(), "ResourceNotInSlotDay");
|
||||
}
|
||||
return Msg.getMsg(Env.getCtx(), "ResourceNotInSlotDay");
|
||||
}
|
||||
|
||||
nodeMillis = calculateMillisFor(node, resourceType, qtyOpen, owf.getDurationBaseSec());
|
||||
dateStart = scheduleBackward(date, nodeMillis ,resource, resourceType);
|
||||
nodeMillis = calculateMillisFor(node, resourceType, qtyOpen, owf.getDurationBaseSec());
|
||||
dateStart = scheduleBackward(date, nodeMillis ,resource, resourceType);
|
||||
|
||||
node.setDateStartSchedule(dateStart);
|
||||
node.setDateFinishSchedule(date);
|
||||
node.save(get_TrxName());
|
||||
node.setDateFinishSchedule(date);
|
||||
node.save(get_TrxName());
|
||||
|
||||
date = node.getDateStartSchedule();
|
||||
nodeId = owf.getPrevious(nodeId,getAD_Client_ID());
|
||||
if (nodeId == 0)
|
||||
log.log(Level.FINE,"MPP_Order Node Previos not exist:" );
|
||||
date = node.getDateStartSchedule();
|
||||
nodeId = owf.getPrevious(nodeId,getAD_Client_ID());
|
||||
if (nodeId == 0)
|
||||
log.log(Level.FINE,"MPP_Order Node Previos not exist:" );
|
||||
|
||||
}
|
||||
if (node != null)
|
||||
orders[i].setDateStartSchedule(node.getDateStartSchedule()) ;
|
||||
}
|
||||
|
||||
orders[i].save(get_TrxName());
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
|
||||
private long calculateMillisFor(MPPOrderNode node, MResourceType type, BigDecimal qty, long commonBase) {
|
||||
|
||||
// A day of 24 hours in milliseconds
|
||||
double aDay24 = 24*60*60*1000;
|
||||
|
||||
// Initializing available time as complete day in milliseconds.
|
||||
double actualDay = aDay24;
|
||||
|
||||
// If resource type is timeslot, updating to available time of the resource.
|
||||
if (type.isTimeSlot()) {
|
||||
|
||||
actualDay = (double)DateTimeUtil.getTimeDifference(type.getTimeSlotStart(), type.getTimeSlotEnd());
|
||||
}
|
||||
if (node != null)
|
||||
orders[i].setDateStartSchedule(node.getDateStartSchedule()) ;
|
||||
}
|
||||
|
||||
// Available time factor of the resource of the workflow node
|
||||
BigDecimal factorAvailablility = new BigDecimal((actualDay / aDay24));
|
||||
orders[i].save(get_TrxName());
|
||||
}
|
||||
|
||||
// Total duration of workflow node (seconds) ...
|
||||
// ... its static single parts ...
|
||||
BigDecimal totalDuration = new BigDecimal(
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//node.getQueuingTime()
|
||||
node.getSetupTimeRequiered() // Use the present required setup time to notice later changes
|
||||
+ node.getMovingTime()
|
||||
+ node.getWaitingTime()
|
||||
);
|
||||
// ... and its qty dependend working time ... (Use the present required duration time to notice later changes)
|
||||
//totalDuration = totalDuration.add(qty.multiply(new BigDecimal(node.getDurationRequiered())));
|
||||
totalDuration = totalDuration.add(qty.multiply(new BigDecimal(node.getDuration())));
|
||||
// ... converted to common base.
|
||||
totalDuration = totalDuration.multiply(new BigDecimal(commonBase));
|
||||
private long calculateMillisFor(MPPOrderNode node, MResourceType type, BigDecimal qty, long commonBase) {
|
||||
|
||||
// Returns the total duration of a node in milliseconds.
|
||||
return totalDuration.multiply(new BigDecimal(1000)).longValue();
|
||||
}
|
||||
// A day of 24 hours in milliseconds
|
||||
double aDay24 = 24*60*60*1000;
|
||||
|
||||
private Timestamp scheduleForward(Timestamp start, long nodeDuration, MResource r, MResourceType t) {
|
||||
// Initializing available time as complete day in milliseconds.
|
||||
double actualDay = aDay24;
|
||||
|
||||
// Checks, whether the resource is available at this day and recall with
|
||||
// next day, if not.
|
||||
if(!reasoner.checkResourceAvailability(start, r)) {
|
||||
// If resource type is timeslot, updating to available time of the resource.
|
||||
if (type.isTimeSlot()) {
|
||||
|
||||
actualDay = (double)DateTimeUtil.getTimeDifference(type.getTimeSlotStart(), type.getTimeSlotEnd());
|
||||
}
|
||||
|
||||
// Available time factor of the resource of the workflow node
|
||||
BigDecimal factorAvailablility = new BigDecimal((actualDay / aDay24));
|
||||
|
||||
// Total duration of workflow node (seconds) ...
|
||||
// ... its static single parts ...
|
||||
BigDecimal totalDuration = new BigDecimal(
|
||||
|
||||
//node.getQueuingTime()
|
||||
node.getSetupTimeRequiered() // Use the present required setup time to notice later changes
|
||||
+ node.getMovingTime()
|
||||
+ node.getWaitingTime()
|
||||
);
|
||||
// ... and its qty dependend working time ... (Use the present required duration time to notice later changes)
|
||||
//totalDuration = totalDuration.add(qty.multiply(new BigDecimal(node.getDurationRequiered())));
|
||||
totalDuration = totalDuration.add(qty.multiply(new BigDecimal(node.getDuration())));
|
||||
// ... converted to common base.
|
||||
totalDuration = totalDuration.multiply(new BigDecimal(commonBase));
|
||||
|
||||
// Returns the total duration of a node in milliseconds.
|
||||
return totalDuration.multiply(new BigDecimal(1000)).longValue();
|
||||
}
|
||||
|
||||
private Timestamp scheduleForward(Timestamp start, long nodeDuration, MResource r, MResourceType t) {
|
||||
|
||||
// Checks, whether the resource is available at this day and recall with
|
||||
// next day, if not.
|
||||
if(!reasoner.checkResourceAvailability(start, r)) {
|
||||
|
||||
//return scheduleForward(Util.incrementDay(start), nodeDuration, r, t);
|
||||
return scheduleForward(org.compiere.util.TimeUtil.addDays(start, 1) , nodeDuration, r, t);
|
||||
return scheduleForward(org.compiere.util.TimeUtil.addDays(start, 1) , nodeDuration, r, t);
|
||||
|
||||
}
|
||||
// Checks, whether the resource type (only if date slot) is available at
|
||||
// this day and recall with next day, if not.
|
||||
else if(t.isDateSlot()) {
|
||||
}
|
||||
// Checks, whether the resource type (only if date slot) is available at
|
||||
// this day and recall with next day, if not.
|
||||
else if(t.isDateSlot()) {
|
||||
|
||||
if(!reasoner.checkResourceTypeAvailability(start, t)) {
|
||||
|
||||
//return scheduleForward(DateTimeUtil.incrementDay(start), nodeDuration, r, t);
|
||||
return scheduleForward(org.compiere.util.TimeUtil.addDays(start, 1), nodeDuration, r, t);
|
||||
return scheduleForward(org.compiere.util.TimeUtil.addDays(start, 1), nodeDuration, r, t);
|
||||
}
|
||||
}
|
||||
|
||||
Timestamp dayStart = null;
|
||||
// Retrieve the principal days start time, dependent on timeslot or not
|
||||
if(t.isTimeSlot()) {
|
||||
// Retrieve the principal days start time, dependent on timeslot or not
|
||||
if(t.isTimeSlot()) {
|
||||
|
||||
dayStart = DateTimeUtil.getDayBorder(start, t.getTimeSlotStart(), false);
|
||||
}
|
||||
else {
|
||||
dayStart = DateTimeUtil.getDayBorder(start, t.getTimeSlotStart(), false);
|
||||
}
|
||||
else {
|
||||
|
||||
dayStart = DateTimeUtil.getDayBorder(start, null, false);
|
||||
}
|
||||
dayStart = DateTimeUtil.getDayBorder(start, null, false);
|
||||
}
|
||||
|
||||
Timestamp dayEnd = null;
|
||||
// Retrieve the days end time, dependent on timeslot or not
|
||||
if(t.isTimeSlot()) {
|
||||
Timestamp dayEnd = null;
|
||||
// Retrieve the days end time, dependent on timeslot or not
|
||||
if(t.isTimeSlot()) {
|
||||
|
||||
dayEnd = DateTimeUtil.getDayBorder(start, t.getTimeSlotEnd(), true);
|
||||
}
|
||||
else {
|
||||
dayEnd = DateTimeUtil.getDayBorder(start, t.getTimeSlotEnd(), true);
|
||||
}
|
||||
else {
|
||||
|
||||
dayEnd = DateTimeUtil.getDayBorder(start, null, true);
|
||||
}
|
||||
dayEnd = DateTimeUtil.getDayBorder(start, null, true);
|
||||
}
|
||||
|
||||
// If working has already begon at this day and the value is in the range of the
|
||||
// resource's availability, switch start time to the given again
|
||||
// If working has already begon at this day and the value is in the range of the
|
||||
// resource's availability, switch start time to the given again
|
||||
if(start.after(dayStart) && start.before(dayEnd)) {
|
||||
|
||||
dayStart = start;
|
||||
}
|
||||
dayStart = start;
|
||||
}
|
||||
|
||||
// The available time at this day in milliseconds
|
||||
long availableDayDuration = DateTimeUtil.getTimeDifference(dayStart, dayEnd);
|
||||
// The available time at this day in milliseconds
|
||||
long availableDayDuration = DateTimeUtil.getTimeDifference(dayStart, dayEnd);
|
||||
|
||||
Timestamp retValue = null;
|
||||
// The work can be finish on this day.
|
||||
if(availableDayDuration >= nodeDuration) {
|
||||
Timestamp retValue = null;
|
||||
// The work can be finish on this day.
|
||||
if(availableDayDuration >= nodeDuration) {
|
||||
|
||||
retValue = new Timestamp(dayStart.getTime()+nodeDuration);
|
||||
}
|
||||
// Otherwise recall with next day and the remained node duration.
|
||||
else {
|
||||
retValue = new Timestamp(dayStart.getTime()+nodeDuration);
|
||||
}
|
||||
// Otherwise recall with next day and the remained node duration.
|
||||
else {
|
||||
|
||||
//retValue = scheduleForward(DateTimeUtil.incrementDay(DateTimeUtil.getDayBorder(start, null, false)), nodeDuration-availableDayDuration, r, t);
|
||||
retValue = scheduleForward(org.compiere.util.TimeUtil.addDays(DateTimeUtil.getDayBorder(start, null, false),1), nodeDuration-availableDayDuration, r, t);
|
||||
}
|
||||
retValue = scheduleForward(org.compiere.util.TimeUtil.addDays(DateTimeUtil.getDayBorder(start, null, false),1), nodeDuration-availableDayDuration, r, t);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
return retValue;
|
||||
}
|
||||
|
||||
private Timestamp scheduleBackward(Timestamp end, long nodeDuration, MResource r, MResourceType t) {
|
||||
private Timestamp scheduleBackward(Timestamp end, long nodeDuration, MResource r, MResourceType t) {
|
||||
|
||||
log.log(Level.FINE,"scheduleBackward --> end " +end);
|
||||
log.log(Level.FINE,"scheduleBackward --> nodeDuration " +nodeDuration);
|
||||
log.log(Level.FINE,"scheduleBackward --> ResourceType " + t);
|
||||
log.log(Level.FINE,"scheduleBackward --> end " +end);
|
||||
log.log(Level.FINE,"scheduleBackward --> nodeDuration " +nodeDuration);
|
||||
log.log(Level.FINE,"scheduleBackward --> ResourceType " + t);
|
||||
|
||||
// Checks, whether the resource is available at this day and recall with
|
||||
// next day, if not.
|
||||
if(!reasoner.checkResourceAvailability(end, r)) {
|
||||
// Checks, whether the resource is available at this day and recall with
|
||||
// next day, if not.
|
||||
if(!reasoner.checkResourceAvailability(end, r)) {
|
||||
|
||||
//return scheduleBackward(DateTimeUtil.decrementDay(end), nodeDuration, r, t);
|
||||
return scheduleBackward(org.compiere.util.TimeUtil.addDays(end , -1), nodeDuration, r, t);
|
||||
return scheduleBackward(org.compiere.util.TimeUtil.addDays(end , -1), nodeDuration, r, t);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Checks, whether the resource type (only if date slot) is available on
|
||||
// this day and recall with next day, if not.
|
||||
// Checks, whether the resource type (only if date slot) is available on
|
||||
// this day and recall with next day, if not.
|
||||
if(t.isDateSlot()) {
|
||||
|
||||
if(!reasoner.checkResourceTypeAvailability(end, t)) {
|
||||
|
||||
//return scheduleBackward(DateTimeUtil.decrementDay(end), nodeDuration, r, t);
|
||||
return scheduleBackward(org.compiere.util.TimeUtil.addDays(end , -1), nodeDuration, r, t);
|
||||
return scheduleBackward(org.compiere.util.TimeUtil.addDays(end , -1), nodeDuration, r, t);
|
||||
}
|
||||
}
|
||||
|
||||
Timestamp dayEnd = null;
|
||||
// Retrieve the principal days end time, dependent on timeslot or not
|
||||
if(t.isTimeSlot()) {
|
||||
// Retrieve the principal days end time, dependent on timeslot or not
|
||||
if(t.isTimeSlot()) {
|
||||
|
||||
dayEnd = DateTimeUtil.getDayBorder(end, t.getTimeSlotEnd(), true);
|
||||
}
|
||||
else {
|
||||
dayEnd = DateTimeUtil.getDayBorder(end, t.getTimeSlotEnd(), true);
|
||||
}
|
||||
else {
|
||||
|
||||
dayEnd = DateTimeUtil.getDayBorder(end, null, true);
|
||||
}
|
||||
dayEnd = DateTimeUtil.getDayBorder(end, null, true);
|
||||
}
|
||||
|
||||
log.log(Level.FINE,"scheduleBackward --> dayEnd " + dayEnd);
|
||||
log.log(Level.FINE,"scheduleBackward --> dayEnd " + dayEnd);
|
||||
|
||||
Timestamp dayStart = null;
|
||||
// Retrieve the start end time, dependent on timeslot or not
|
||||
if(t.isTimeSlot()) {
|
||||
Timestamp dayStart = null;
|
||||
// Retrieve the start end time, dependent on timeslot or not
|
||||
if(t.isTimeSlot()) {
|
||||
|
||||
dayStart = DateTimeUtil.getDayBorder(end, t.getTimeSlotStart(), false);
|
||||
}
|
||||
else {
|
||||
dayStart = DateTimeUtil.getDayBorder(end, t.getTimeSlotStart(), false);
|
||||
}
|
||||
else {
|
||||
|
||||
dayStart = DateTimeUtil.getDayBorder(end, null, false);
|
||||
}
|
||||
dayStart = DateTimeUtil.getDayBorder(end, null, false);
|
||||
}
|
||||
|
||||
log.log(Level.FINE,"scheduleBackward --> dayStart " + dayStart);
|
||||
log.log(Level.FINE,"scheduleBackward --> dayStart " + dayStart);
|
||||
|
||||
// If working has already begon at this day and the value is in the range of the
|
||||
// resource's availability, switch end time to the given again
|
||||
if(end.before(dayEnd) && end.after(dayStart)) {
|
||||
// If working has already begon at this day and the value is in the range of the
|
||||
// resource's availability, switch end time to the given again
|
||||
if(end.before(dayEnd) && end.after(dayStart)) {
|
||||
|
||||
dayEnd = end;
|
||||
}
|
||||
dayEnd = end;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// The available time at this day in milliseconds
|
||||
long availableDayDuration = DateTimeUtil.getTimeDifference(dayStart, dayEnd);
|
||||
// The available time at this day in milliseconds
|
||||
long availableDayDuration = DateTimeUtil.getTimeDifference(dayStart, dayEnd);
|
||||
|
||||
log.log(Level.FINE,"scheduleBackward --> availableDayDuration " + availableDayDuration );
|
||||
log.log(Level.FINE,"scheduleBackward --> availableDayDuration " + availableDayDuration );
|
||||
|
||||
Timestamp retValue = null;
|
||||
// The work can be finish on this day.
|
||||
if(availableDayDuration >= nodeDuration) {
|
||||
log.log(Level.FINE,"scheduleBackward --> availableDayDuration >= nodeDuration true " + availableDayDuration + "|" + nodeDuration );
|
||||
retValue = new Timestamp(dayEnd.getTime()-nodeDuration);
|
||||
}
|
||||
// Otherwise recall with previous day and the remained node duration.
|
||||
else {
|
||||
Timestamp retValue = null;
|
||||
// The work can be finish on this day.
|
||||
if(availableDayDuration >= nodeDuration) {
|
||||
log.log(Level.FINE,"scheduleBackward --> availableDayDuration >= nodeDuration true " + availableDayDuration + "|" + nodeDuration );
|
||||
retValue = new Timestamp(dayEnd.getTime()-nodeDuration);
|
||||
}
|
||||
// Otherwise recall with previous day and the remained node duration.
|
||||
else {
|
||||
|
||||
//retValue = scheduleBackward(DateTimeUtil.getDayBorder(end, null, true)), nodeDuration-availableDayDuration, r, t);
|
||||
log.log(Level.FINE,"scheduleBackward --> availableDayDuration >= nodeDuration false " + availableDayDuration + "|" + nodeDuration );
|
||||
log.log(Level.FINE,"scheduleBackward --> nodeDuration-availableDayDuration " + (nodeDuration-availableDayDuration) );
|
||||
retValue = scheduleBackward(org.compiere.util.TimeUtil.addDays(DateTimeUtil.getDayBorder(end, null, true), -1), nodeDuration-availableDayDuration, r, t);
|
||||
}
|
||||
log.log(Level.FINE,"scheduleBackward --> availableDayDuration >= nodeDuration false " + availableDayDuration + "|" + nodeDuration );
|
||||
log.log(Level.FINE,"scheduleBackward --> nodeDuration-availableDayDuration " + (nodeDuration-availableDayDuration) );
|
||||
retValue = scheduleBackward(org.compiere.util.TimeUtil.addDays(DateTimeUtil.getDayBorder(end, null, true), -1), nodeDuration-availableDayDuration, r, t);
|
||||
}
|
||||
|
||||
log.log(Level.FINE,"scheduleBackward --> retValue " + retValue);
|
||||
return retValue;
|
||||
}
|
||||
log.log(Level.FINE,"scheduleBackward --> retValue " + retValue);
|
||||
return retValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue