From ed4cbb811380fc9ee652f2ef5a9c715f0f0f204b Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Wed, 21 Jan 2009 01:17:29 +0000 Subject: [PATCH] Error to Calculate Start Date finish Date Schedule http://sourceforge.net/tracker2/?func=detail&aid=2525014&group_id=176962&atid=879332 error introducing in 6445 http://adempiere.svn.sourceforge.net/viewvc/adempiere?view=rev&revision=6445 Teo, I do not understand Why you apply a TRUNC for the dates it do not is right in you refactory, so the CRP do not work the way right for the trunc dates, in Manufacturing Management all the dates are management with time. Kind regards Victor Perez www.e-evolution.com --- .../org/eevolution/model/reasoner/CRPReasoner.java | 8 ++++---- base/src/org/eevolution/process/CRP.java | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/base/src/org/eevolution/model/reasoner/CRPReasoner.java b/base/src/org/eevolution/model/reasoner/CRPReasoner.java index 9589c169fd..69df996944 100644 --- a/base/src/org/eevolution/model/reasoner/CRPReasoner.java +++ b/base/src/org/eevolution/model/reasoner/CRPReasoner.java @@ -182,7 +182,7 @@ public class CRPReasoner */ private Timestamp getAvailableDate(MResourceType t, Timestamp dateTime, boolean isScheduleBackward) { - Timestamp date = TimeUtil.trunc(dateTime, TimeUtil.TRUNC_DAY); + Timestamp date = dateTime; int direction = isScheduleBackward ? -1 : +1; for (int i = 0; i <= 7; i++) { @@ -203,21 +203,21 @@ public class CRPReasoner public Timestamp getAvailableDate(MResource r, Timestamp dateTime, boolean isScheduleBackward) { MResourceType t = r.getResourceType(); - Timestamp date = TimeUtil.trunc(dateTime, TimeUtil.TRUNC_DAY); + Timestamp date = dateTime; ArrayList params = new ArrayList(); String whereClause; String orderByClause; int direction; if (isScheduleBackward) { - whereClause = "TRUNC("+MResourceUnAvailable.COLUMNNAME_DateFrom+") < ?"; + whereClause = MResourceUnAvailable.COLUMNNAME_DateFrom+" <= ?"; params.add(date); orderByClause = MResourceUnAvailable.COLUMNNAME_DateFrom+" DESC"; direction = 1; } else { - whereClause = "TRUNC("+MResourceUnAvailable.COLUMNNAME_DateTo+") > ?"; + whereClause = MResourceUnAvailable.COLUMNNAME_DateTo+" >= ?"; params.add(date); orderByClause = MResourceUnAvailable.COLUMNNAME_DateTo; direction = -1; diff --git a/base/src/org/eevolution/process/CRP.java b/base/src/org/eevolution/process/CRP.java index 57048c290c..c0685d4980 100644 --- a/base/src/org/eevolution/process/CRP.java +++ b/base/src/org/eevolution/process/CRP.java @@ -85,7 +85,7 @@ public class CRP extends SvrProcess { private String runCRP() { POResultSet rs = reasoner.getPPOrdersNotCompletedQuery(p_S_Resource_ID, get_TrxName()) - .scroll(); + .scroll(); try { while(rs.hasNext()) @@ -102,7 +102,7 @@ public class CRP extends SvrProcess { return "OK"; } - private void runCRP(MPPOrder order) + public void runCRP(MPPOrder order) { log.fine("PP_Order DocumentNo:" + order.getDocumentNo()); BigDecimal qtyOpen = order.getQtyOpen(); @@ -213,13 +213,12 @@ public class CRP extends SvrProcess { // Total duration of workflow node (seconds) ... // ... its static single parts ... long totalDuration = - //node.getQueuingTime() + + 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 += qty.doubleValue() * node.getDuration(); // Returns the total duration of a node in milliseconds. @@ -315,6 +314,8 @@ public class CRP extends SvrProcess { log.fine(" --> start=" + start + " <---------------------------------------- "); return start; - } + } + + }