Commit 2c18e873 authored by manohar's avatar manohar

MF90BHU005 in case of made-to-order sales order reference to be stored in workorder


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91405 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 97e301c9
...@@ -68,10 +68,18 @@ class ADPElement ...@@ -68,10 +68,18 @@ class ADPElement
private String mfgLeadBasis = "F"; private String mfgLeadBasis = "F";
private double batchSizeLead = 0; private double batchSizeLead = 0;
// end 22/06/10 manoharan // end 22/06/10 manoharan
//sabyasachi 17-03-2011
private String saleOrder;
private String lineNo;
//end sabyasachi 17-03-2011
public ADPElement() public ADPElement()
{ {
//System.out.println("New ADPElement Created"); //System.out.println("New ADPElement Created");
this.timeMRPArr = new ArrayList(); this.timeMRPArr = new ArrayList();
this.saleOrder = " ";
this.lineNo = " ";
} }
public void setItemCode(String itemCode) public void setItemCode(String itemCode)
...@@ -198,11 +206,17 @@ class ADPElement ...@@ -198,11 +206,17 @@ class ADPElement
{ {
return this.purcRate; return this.purcRate;
} }
public void setDemand(java.sql.Timestamp dueDate, double demand) //changed method arguments by sabyasachi 29-03-2011
public void setDemand(java.sql.Timestamp dueDate, double demand, String saleOrder, String lineNo)
//public void setDemand(java.sql.Timestamp dueDate, double demand)
{ {
this.demand += demand; this.demand += demand;
this.saleOrder = saleOrder;
this.lineNo = lineNo;
//updateTimeMrp(dueDate, demand, 0, 0, 0,saleOrder,lineNo);
updateTimeMrp(dueDate, demand, 0, 0, 0); updateTimeMrp(dueDate, demand, 0, 0, 0);
} }
//changed method arguments by sabyasachi 29-03-2011 end
public double getDemand() public double getDemand()
{ {
return this.demand; return this.demand;
...@@ -210,6 +224,7 @@ class ADPElement ...@@ -210,6 +224,7 @@ class ADPElement
public void setSupply(java.sql.Timestamp dueDate, double supply) public void setSupply(java.sql.Timestamp dueDate, double supply)
{ {
this.supply += supply; this.supply += supply;
//updateTimeMrp(dueDate, 0, supply, 0, 0," "," ");
updateTimeMrp(dueDate, 0, supply, 0, 0); updateTimeMrp(dueDate, 0, supply, 0, 0);
} }
public double getSupply() public double getSupply()
...@@ -220,6 +235,7 @@ class ADPElement ...@@ -220,6 +235,7 @@ class ADPElement
public void setStockQty(java.sql.Timestamp dueDate, double stockQty) public void setStockQty(java.sql.Timestamp dueDate, double stockQty)
{ {
this.stockQty += stockQty; this.stockQty += stockQty;
//updateTimeMrp(dueDate, 0,0, stockQty,0," "," ");
updateTimeMrp(dueDate, 0,0, stockQty,0); updateTimeMrp(dueDate, 0,0, stockQty,0);
} }
public double getStockQty() public double getStockQty()
...@@ -229,6 +245,7 @@ class ADPElement ...@@ -229,6 +245,7 @@ class ADPElement
public void setOthSupply(java.sql.Timestamp dueDate, double othSupply) public void setOthSupply(java.sql.Timestamp dueDate, double othSupply)
{ {
this.othSupply += othSupply; this.othSupply += othSupply;
//updateTimeMrp(dueDate, 0,0, 0, othSupply," "," ");
updateTimeMrp(dueDate, 0,0, 0, othSupply); updateTimeMrp(dueDate, 0,0, 0, othSupply);
} }
public double getOthSupply() public double getOthSupply()
...@@ -236,9 +253,11 @@ class ADPElement ...@@ -236,9 +253,11 @@ class ADPElement
return this.othSupply; return this.othSupply;
} }
// end 12/04/10 manoharan MF90BHU001 // end 12/04/10 manoharan MF90BHU001
public void setPlanSupply(java.sql.Timestamp dueDate, double supply) public void setPlanSupply(java.sql.Timestamp dueDate, double supply)
{ {
this.planSupply += supply; this.planSupply += supply;
//updateTimeMrp(dueDate, 0, supply, 0, 0," "," ");
updateTimeMrp(dueDate, 0, supply, 0, 0); updateTimeMrp(dueDate, 0, supply, 0, 0);
} }
public double getPlanSupply() public double getPlanSupply()
...@@ -246,6 +265,7 @@ class ADPElement ...@@ -246,6 +265,7 @@ class ADPElement
return this.planSupply; return this.planSupply;
} }
//added by dharmendra on 28th-dec //added by dharmendra on 28th-dec
public void setSuppSour(String suppSour) public void setSuppSour(String suppSour)
{ {
this.suppSour = suppSour; this.suppSour = suppSour;
...@@ -467,8 +487,27 @@ class ADPElement ...@@ -467,8 +487,27 @@ class ADPElement
return this.batchSizeLead; return this.batchSizeLead;
} }
// end 22/06/10 manoharan // end 22/06/10 manoharan
//added by sabyasachi 17-03-11
public void setSaleOrder(String saleOrder)
{
this.saleOrder = saleOrder;
}
public void setLineNo(String lineNo)
{
this.lineNo = lineNo;
}
public String getSaleOrder()
{
return this.saleOrder;
}
public String getLineNo()
{
return this.lineNo;
}
//end added by sabyasachi 17-03-11
//private void updateTimeMrp(java.sql.Timestamp dueDate, double demand, double supply, double stockQty, double othSupply, String saleOrder, String lineNo)
private void updateTimeMrp(java.sql.Timestamp dueDate, double demand, double supply, double stockQty, double othSupply) private void updateTimeMrp(java.sql.Timestamp dueDate, double demand, double supply, double stockQty, double othSupply)
{ {
String errString = ""; String errString = "";
...@@ -477,6 +516,7 @@ class ADPElement ...@@ -477,6 +516,7 @@ class ADPElement
int timeEle = -1, ctr; int timeEle = -1, ctr;
SimpleDateFormat sdt=new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdt=new SimpleDateFormat("yyyy-MM-dd");
dueDate = java.sql.Timestamp.valueOf(sdt.format(dueDate) + " 00:00:00.000"); dueDate = java.sql.Timestamp.valueOf(sdt.format(dueDate) + " 00:00:00.000");
try try
{ {
if (timeMRPArr.size() > 0) if (timeMRPArr.size() > 0)
...@@ -484,6 +524,7 @@ class ADPElement ...@@ -484,6 +524,7 @@ class ADPElement
for (ctr = 0; ctr < timeMRPArr.size(); ctr++) for (ctr = 0; ctr < timeMRPArr.size(); ctr++)
{ {
timeMRP = (TimeMRP)timeMRPArr.get(ctr); timeMRP = (TimeMRP)timeMRPArr.get(ctr);
//if (timeMRP.getDueDate() != null && timeMRP.getSaleOrder().equals(saleOrder) && timeMRP.getLineNo().equals(lineNo))
if (timeMRP.getDueDate() != null) if (timeMRP.getDueDate() != null)
{ {
if (timeMRP.getDueDate().equals(dueDate)) if (timeMRP.getDueDate().equals(dueDate))
...@@ -498,7 +539,10 @@ class ADPElement ...@@ -498,7 +539,10 @@ class ADPElement
{ {
timeMRP = new TimeMRP(); timeMRP = new TimeMRP();
timeMRP.setDueDate(dueDate); timeMRP.setDueDate(dueDate);
//added by sabyasachi 29.03.2011
//timeMRP.setDemand(demand,saleOrder,lineNo);
timeMRP.setDemand(demand); timeMRP.setDemand(demand);
//end added by sabyasachi 29.03.2011
timeMRP.setSupply(supply); timeMRP.setSupply(supply);
// 12/04/10 manoharan MF90BHU001 // 12/04/10 manoharan MF90BHU001
timeMRP.setStockQty(stockQty); timeMRP.setStockQty(stockQty);
...@@ -509,12 +553,17 @@ class ADPElement ...@@ -509,12 +553,17 @@ class ADPElement
else else
{ {
timeMRP = (TimeMRP)this.timeMRPArr.get(timeEle); timeMRP = (TimeMRP)this.timeMRPArr.get(timeEle);
//added by sabyasachi 29.03.2011
//timeMRP.setDemand(demand,saleOrder,lineNo);
timeMRP.setDemand(demand); timeMRP.setDemand(demand);
//end added by sabyasachi 29.03.2011
timeMRP.setSupply(supply); timeMRP.setSupply(supply);
// 12/04/10 manoharan MF90BHU001 // 12/04/10 manoharan MF90BHU001
timeMRP.setStockQty(stockQty); timeMRP.setStockQty(stockQty);
timeMRP.setOthSupply(othSupply); timeMRP.setOthSupply(othSupply);
// end 12/04/10 manoharan MF90BHU001 // end 12/04/10 manoharan MF90BHU001
//timeMRP.setSaleOrder(saleOrder);
//timeMRP.setLineNo(lineNo);
this.timeMRPArr.set(timeEle,timeMRP); this.timeMRPArr.set(timeEle,timeMRP);
} }
updateRunningDemandSupply(dueDate); updateRunningDemandSupply(dueDate);
...@@ -625,4 +674,5 @@ class ADPElement ...@@ -625,4 +674,5 @@ class ADPElement
} }
} }
} }
\ No newline at end of file
...@@ -90,7 +90,7 @@ public class ExplodeBom ...@@ -90,7 +90,7 @@ public class ExplodeBom
// public String explodeBom(String xmlString, Connection conn)//Commented by Jiten as per Kandarp Sir 13/11/06 - Connenction to be opened and to be closed here // public String explodeBom(String xmlString, Connection conn)//Commented by Jiten as per Kandarp Sir 13/11/06 - Connenction to be opened and to be closed here
public String explodeBom(String xmlString)//Added by Jiten 13/11/06 - public String explodeBom(String xmlString) throws Exception //Added by Jiten 13/11/06 -
{ {
utilMethods = new UtilMethods(); // 10/12/07 manoharan utilMethods = new UtilMethods(); // 10/12/07 manoharan
genericUtility = GenericUtility.getInstance(); genericUtility = GenericUtility.getInstance();
...@@ -105,7 +105,7 @@ public class ExplodeBom ...@@ -105,7 +105,7 @@ public class ExplodeBom
ConnDriver connDriver = new ConnDriver();//Added by Jiten 13/11/06 - ConnDriver connDriver = new ConnDriver();//Added by Jiten 13/11/06 -
int iLeadTime = 0; int iLeadTime = 0;
int iiLeadTime = 0; int iiLeadTime = 0;
String sqlLead = null; String sqlLead = null, tempXML = null;
String mfgLeadBasis = "F"; String mfgLeadBasis = "F";
double batchSizeLead = 0; double batchSizeLead = 0;
...@@ -471,6 +471,8 @@ public class ExplodeBom ...@@ -471,6 +471,8 @@ public class ExplodeBom
else else
{ {
pstmtLead.close();
rsLead.close();
mfgLeadBasis = "F"; mfgLeadBasis = "F";
batchSizeLead = 0; batchSizeLead = 0;
...@@ -490,6 +492,11 @@ public class ExplodeBom ...@@ -490,6 +492,11 @@ public class ExplodeBom
pstmtLead.close(); pstmtLead.close();
rsLead.close(); rsLead.close();
} }
else
{
pstmtLead.close();
rsLead.close();
}
} }
if ( "P".equals(suppSourInner) ) if ( "P".equals(suppSourInner) )
{ {
...@@ -587,6 +594,14 @@ public class ExplodeBom ...@@ -587,6 +594,14 @@ public class ExplodeBom
System.out.println("SQLException : ExplodeBom :explodeBom()" +se.getMessage()); System.out.println("SQLException : ExplodeBom :explodeBom()" +se.getMessage());
se.printStackTrace(); se.printStackTrace();
errString = se.getMessage(); errString = se.getMessage();
try {
tempXML = valueXmlString.toString();
tempXML = tempXML.replaceAll("<Root>","");
tempXML = tempXML.replaceAll("</Root>","");
valueXmlString = new StringBuffer("<Root>" + tempXML + "</Detail></Root>");
}
catch (Exception x) {}
throw (se);
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -594,6 +609,14 @@ public class ExplodeBom ...@@ -594,6 +609,14 @@ public class ExplodeBom
this.errString = genericUtility.createErrorString(e); this.errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
try {
tempXML = valueXmlString.toString();
tempXML = tempXML.replaceAll("<Root>","");
tempXML = tempXML.replaceAll("</Root>","");
valueXmlString = new StringBuffer("<Root>" + tempXML + "</Detail></Root>");
}
catch (Exception x) {}
throw (e);
} }
finally finally
{ {
...@@ -602,15 +625,38 @@ public class ExplodeBom ...@@ -602,15 +625,38 @@ public class ExplodeBom
rs.close(); rs.close();
rs = null; rs = null;
} }
if(conn != null){//Added by Jiten 13/11/06 - if (rsLead != null)
{
rsLead.close();
rsLead = null;
}
if (rsInner != null)
{
rsInner.close();
rsInner = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (pstmtInner != null)
{
pstmtInner.close();
pstmtInner = null;
}
if (pstmtLead != null)
{
pstmtLead.close();
pstmtLead = null;
}
if(conn != null)
{//Added by Jiten 13/11/06 -
conn.close(); conn.close();
conn = null; conn = null;
} }
if (pstmt != null) { pstmt = null; }
if (pstmtInner != null) { pstmtInner = null; }
if (pstmtInner != null) { pstmtInner = null; }
if (rs != null) { rs = null; }
if (rsInner != null) { rsInner = null; }
}catch(Exception e){} }catch(Exception e){}
/*if( (errString != null) && (errString.length() > 0) ) /*if( (errString != null) && (errString.length() > 0) )
return errString; return errString;
......
...@@ -19,7 +19,11 @@ public class MPSOrder ...@@ -19,7 +19,11 @@ public class MPSOrder
public String unit = ""; public String unit = "";
public String acctCodeWp = ""; public String acctCodeWp = "";
public String cctrCodeWp = ""; public String cctrCodeWp = "";
//ADDED BY SABYASACHI 30-03-11
public String saleOrder = "";
public String lineNo = "";
public String mfgType = "";
//ADDED BY SABYASACHI ENDS 30-03-11
public double quantity = 0; public double quantity = 0;
public double yieldPerc = 0 ; public double yieldPerc = 0 ;
public double curBatchQty = 0; public double curBatchQty = 0;
......
package ibase.webitm.ejb.mfg; package ibase.webitm.ejb.mfg;
// BD0783 replaced with BD0783 -- 14/01/09 // BD0783 replaced with BD0783 -- 14/01/09
/*
1. truncate table plan_hdr;
2. add sale_order and line_no, seq_no in plan_header
alter table plan_hdr add sale_ordr char(10);
alter table plan_hdr add line_no char(3);
alter table plan_hdr add seq_no number(10);
3. make seq_no not null
alter table plan_hdr modify seq_no number(10) not null;
4. Drop primay key of plan_hdr
alter table plan_hdr drop constraint plan_hdr_x;
alter table plan_hdr drop constraint planhdr_x;
5. Create new primary key with sale_order and line_no
alter table add constraint plan_hdr_x primary key (site_code,item_code,seq_no) using index tablespace itm_mfg_i1;
6. in of case mfgtype = "O" create workorder instead of mps order
*/
import org.w3c.dom.*; import org.w3c.dom.*;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.*; import java.util.*;
...@@ -393,17 +410,17 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -393,17 +410,17 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
} }
/* foreign key defined with on delete cascade // uncommented on 04/04/11 manoharan foreign key defined with on delete cascade
sql = "DELETE FROM PLAN_DET WHERE SITE_CODE >='"+siteCodeFrom+"' " sql = "DELETE FROM PLAN_DET WHERE SITE_CODE >='"+siteCodeFrom+"' "
+ " AND SITE_CODE <= '"+siteCodeTo+ "' " + " AND SITE_CODE <= '"+siteCodeTo+ "' ";
+ " AND ITEM_CODE >= '"+itemCodeFrom+"' " //+ " AND ITEM_CODE >= '"+itemCodeFrom+"' "
+ " AND ITEM_CODE <= '"+itemCodeTo+"'" + lsWhere; //+ " AND ITEM_CODE <= '"+itemCodeTo+"'" ;//+ lsWhere;
Statement stmt = conn.createStatement(); stmt = conn.createStatement();
int deletedInDetail = stmt.executeUpdate(sql); int deletedInDetail = stmt.executeUpdate(sql);
stmt.close(); stmt.close();
System.out.println("Deleted in detail For Material Plan: " + deletedInDetail); System.out.println("Deleted in detail For Material Plan: " + deletedInDetail);
*/
sql = "DELETE FROM PLAN_HDR WHERE SITE_CODE >='"+siteCodeFrom.trim()+"' " sql = "DELETE FROM PLAN_HDR WHERE SITE_CODE >='"+siteCodeFrom.trim()+"' "
+ " AND SITE_CODE <= '"+siteCodeTo+ "' " + lsWhere; + " AND SITE_CODE <= '"+siteCodeTo+ "' " + lsWhere;
//+ " AND ITEM_CODE >= '"+itemCodeFrom.trim()+"' " //+ " AND ITEM_CODE >= '"+itemCodeFrom.trim()+"' "
...@@ -635,7 +652,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -635,7 +652,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
// Fetching Balance Intersite from Entered by User in GUI // Fetching Balance Intersite from Entered by User in GUI
balIntersite = genericUtility.getColumnValue("balance_intersite",dom); balIntersite = genericUtility.getColumnValue("balance_intersite",dom);
if ( balIntersite == null || madeToOrder.trim().length() == 0 ) if ( balIntersite == null || balIntersite.trim().length() == 0 )
{ {
balIntersite = ""; balIntersite = "";
System.out.println("Balance Intersite is Null..."); System.out.println("Balance Intersite is Null...");
...@@ -1125,6 +1142,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1125,6 +1142,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
} }
itemList.clear(); itemList.clear();
} }
} }
catch(Exception e) catch(Exception e)
...@@ -1224,7 +1242,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1224,7 +1242,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
for (int mainCtr = 0; mainCtr < mainList.size() ; mainCtr++) for (int mainCtr = 0; mainCtr < mainList.size() ; mainCtr++)
{ {
tempItemCode = (String) mainList.get(mainCtr); tempItemCode = (String) mainList.get(mainCtr);
//System.out.println("sHAMIM...........................................");
//System.out.println("Manoj tempItemCode--"+tempItemCode); //System.out.println("Manoj tempItemCode--"+tempItemCode);
setLength=itemList.size(); setLength=itemList.size();
Iterator itr=itemList.iterator(); Iterator itr=itemList.iterator();
...@@ -1260,18 +1278,19 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1260,18 +1278,19 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
{ {
System.out.println("itemList.size()--"+verifier+"--"+setLength+"--"+itemList.size()); System.out.println("itemList.size()--"+verifier+"--"+setLength+"--"+itemList.size());
//14.11.2010 Manoj
if(setLength==itemList.size()) if(setLength==itemList.size())
{ {
if(verifier != null && verifier.equalsIgnoreCase("Y")) if(verifier != null && verifier.equalsIgnoreCase("Y"))
{ {
System.out.println("itemList.size()--"+verifier+"--"+setLength+"--"+itemList.size()); System.out.println("itemList.size()--"+verifier+"--"+setLength+"--"+itemList.size());
this.fw.write(cyclicItem.siteCode+" "+cyclicItem.bomCode+" "+cyclicItem.itemCode+" "+rs.getString(1)+"\r\n"); this.fw.write(cyclicItem.siteCode+" "+cyclicItem.bomCode+" "+cyclicItem.itemCode+" "+tempItemCode+"\r\n");
System.out.println("Cyclic Item Code is : " + tempItemCode); System.out.println("Cyclic Item Code is : " + tempItemCode);
//return ""; //return "";
System.out.println("itemList.size()--"+verifier+"--"+setLength+"--"+itemList.size()); System.out.println("itemList.size()--"+verifier+"--"+setLength+"--"+itemList.size());
itemList.clear();
} }
else{ else
{
System.out.println("Cyclic Item Code is : " + tempItemCode); System.out.println("Cyclic Item Code is : " + tempItemCode);
errString = itmDBAccessEJB.getErrorString("","VTMRPITEME","","",conn); errString = itmDBAccessEJB.getErrorString("","VTMRPITEME","","",conn);
rs.close(); rs.close();
...@@ -1280,6 +1299,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1280,6 +1299,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
return errString; return errString;
} }
} }
// end 14.11.2010 Manoj
} }
if(itemCodeMap.containsKey(tempItemCode)) if(itemCodeMap.containsKey(tempItemCode))
...@@ -1349,6 +1369,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1349,6 +1369,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
} }
} }
if ( rs != null) if ( rs != null)
{ {
rs.close(); rs.close();
...@@ -1677,6 +1698,9 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1677,6 +1698,9 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
Iterator itrItem = null; Iterator itrItem = null;
Set setSite = siteCodeMap.entrySet(); Set setSite = siteCodeMap.entrySet();
Iterator itrSite = setSite.iterator(); Iterator itrSite = setSite.iterator();
PreparedStatement pstmt = null;
String sql = "",siteCode = "",itemCode = "",mfgType = "";
ResultSet rs = null;
Set setItem = itemCodeMap.entrySet(); Set setItem = itemCodeMap.entrySet();
//System.out.println("In populateADPElementList()"); //System.out.println("In populateADPElementList()");
...@@ -1692,7 +1716,29 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1692,7 +1716,29 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
Map.Entry itemMapEntry = (Map.Entry)itrItem.next(); Map.Entry itemMapEntry = (Map.Entry)itrItem.next();
siteCode = (String)siteMapEntry.getKey();
itemCode = (String)itemMapEntry.getKey();
// 01/04/11 in case of made to order only made to order item will be planned
/*if ("Y".equals(madeToOrder))
{
sql = "SELECT mfg_type FROM SITEITEM WHERE SITE_CODE = ? AND ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
mfgType = rs.getString(1);
}
rs.close();
pstmt.close();
if (!"O".equals(mfgType))
{
continue;
}
}*/
// end 01/04/11 in case of made to order only made to order item will be planned
adpElement.setSiteCode((String)siteMapEntry.getKey()); adpElement.setSiteCode((String)siteMapEntry.getKey());
adpElement.setItemCode((String)itemMapEntry.getKey()); adpElement.setItemCode((String)itemMapEntry.getKey());
adpElement = setAdpeValues(adpElement); adpElement = setAdpeValues(adpElement);
...@@ -2321,12 +2367,35 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2321,12 +2367,35 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
private void populateADPList() throws Exception private void populateADPList() throws Exception
{ {
ArrayList tempList = new ArrayList();
try{ try{
for(int ctr=0;ctr<adpeList.size();ctr++){
if ("0".equals(madeToOrder))
{
for(int ctr=0;ctr<adpeList.size();ctr++)
{
ADPElement adpElement = (ADPElement)adpeList.get(ctr);
tempList.add(adpElement);
}
//adpeList.clear();
System.out.println("01/04/11 populateADPList madeToOrder [" + madeToOrder + "] tempList.size() [" + tempList.size() + "]");
for(int ctr=0;ctr<tempList.size();ctr++)
{
ADPElement adpElement = (ADPElement)tempList.get(ctr);
//adpElement =
populateMTODemandSupply(adpElement.getSiteCode(),adpElement.getItemCode(),adpElement);
}
tempList.clear();
tempList = null;
}
System.out.println("01/04/11 populateADPList madeToOrder [" + madeToOrder + "] adpeList.size() [" + adpeList.size() + "]");
for(int ctr=0;ctr<adpeList.size();ctr++)
{
ADPElement adpElement = (ADPElement)adpeList.get(ctr); ADPElement adpElement = (ADPElement)adpeList.get(ctr);
adpElement = populateDemandSupply(adpElement); adpElement = populateDemandSupply(adpElement);
adpeList.set(ctr,adpElement); adpeList.set(ctr,adpElement);
} }
}catch(Exception e){ }catch(Exception e){
throw(e); throw(e);
} }
...@@ -2347,12 +2416,21 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2347,12 +2416,21 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
errString = ""; errString = "";
String adpQuery = null; String adpQuery = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String saleOrder = null;
String lineNo = null;
try try
{ {
itemCode = adpElement.getItemCode(); itemCode = adpElement.getItemCode();
siteCode = adpElement.getSiteCode(); siteCode = adpElement.getSiteCode();
// 01/04/11 manoharan if made to order is selected and item is of made to order
// don't process here
if ("0".equals(madeToOrder) && "O".equals(adpElement.getMfgType()))
{
return adpElement;
}
// end 01/04/11 manoharan
//System.out.println("commonConstants.DB_NAME "+CommonConstants.DB_NAME); //System.out.println("commonConstants.DB_NAME "+CommonConstants.DB_NAME);
// 14-02-2007 manoharan // 14-02-2007 manoharan
String sqlFileName = null; String sqlFileName = null;
...@@ -2424,13 +2502,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2424,13 +2502,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
// end 01-10-2007 manoharan // end 01-10-2007 manoharan
//System.out.println("Replaced Values.in SQL....."); //System.out.println("Replaced Values.in SQL.....");
} }
FileOutputStream fout = null; FileOutputStream fout = null;
BufferedWriter bw = null; BufferedWriter bw = null;
fout = new FileOutputStream("demandsupply.sql"); fout = new FileOutputStream("demandsupply.sql");
bw = new BufferedWriter(new OutputStreamWriter(fout)); bw = new BufferedWriter(new OutputStreamWriter(fout));
bw.write(adpQuery); bw.write(adpQuery);
bw.close(); bw.close();
fout.close(); fout.close();
//stmt = conn.createStatement(); //stmt = conn.createStatement();
//System.out.println("Executing Query After Replacement....."); //System.out.println("Executing Query After Replacement.....");
...@@ -2459,22 +2537,21 @@ fout.close(); ...@@ -2459,22 +2537,21 @@ fout.close();
//if else condition added by Jiten as per Manoharan Sir 02/11/06 //if else condition added by Jiten as per Manoharan Sir 02/11/06
if(rsItemCode != null && rsItemCode.trim().equalsIgnoreCase(itemCode.trim())) if(rsItemCode != null && rsItemCode.trim().equalsIgnoreCase(itemCode.trim()))
{ {
adpElement.setDemand(dueDate, demand); adpElement.setDemand(dueDate, demand," "," ");
adpElement.setSupply(dueDate, supply); adpElement.setSupply(dueDate, supply);
// 12/04/10 manoharan MF90BHU001 // 12/04/10 manoharan MF90BHU001
adpElement.setStockQty(dueDate, stockQty); adpElement.setStockQty(dueDate, stockQty);
adpElement.setOthSupply(dueDate, othSupply); adpElement.setOthSupply(dueDate, othSupply);
// end 12/04/10 manoharan MF90BHU001 // end 12/04/10 manoharan MF90BHU001
} }
else else
{ {
System.out.println("Site Code :: "+siteCode+" rsItemCode :: "+rsItemCode+" Item Code :: "+itemCode); System.out.println("Site Code :: "+siteCode+" rsItemCode :: "+rsItemCode+" Item Code :: "+itemCode);
int ctr = indexOfADPElement(siteCode, rsItemCode); int ctr = indexOfADPElement(siteCode, rsItemCode," "," ");
//System.out.println("AdpList : "+adpeList.size()+"Index ctr :: "+ctr);//Added by Jiten 09/11/06 Sun //System.out.println("AdpList : "+adpeList.size()+"Index ctr :: "+ctr);//Added by Jiten 09/11/06 Sun
if(ctr > 0){//if condition added by jiten as per Manoharan Sir 10/11/06 if(ctr > 0){//if condition added by jiten as per Manoharan Sir 10/11/06
ADPElement tempADPElement = (ADPElement)adpeList.get(ctr); ADPElement tempADPElement = (ADPElement)adpeList.get(ctr);
tempADPElement.setDemand(dueDate, demand); tempADPElement.setDemand(dueDate, demand," "," ");
tempADPElement.setSupply(dueDate, supply); tempADPElement.setSupply(dueDate, supply);
adpeList.set(ctr,tempADPElement); adpeList.set(ctr,tempADPElement);
}else if(ctr == -1){//Else if condition added by jiten 10/11/06 as per Tarun Bhai to write for skipped item }else if(ctr == -1){//Else if condition added by jiten 10/11/06 as per Tarun Bhai to write for skipped item
...@@ -2493,6 +2570,7 @@ fout.close(); ...@@ -2493,6 +2570,7 @@ fout.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
catch(SQLException se) catch(SQLException se)
{ {
...@@ -2520,9 +2598,212 @@ fout.close(); ...@@ -2520,9 +2598,212 @@ fout.close();
} }
//ResultSetMetaData rsmd = rs.getMetaData(); //ResultSetMetaData rsmd = rs.getMetaData();
//int noOfColumns = rsmd.getColumnCount(); //int noOfColumns = rsmd.getColumnCount();
return adpElement; //Moved here from finaly - jiten - 03/11/06
//return commented & changed by sabyasachi 25-03-2011
//return adpElement; //Moved here from finaly - jiten - 03/11/06
return adpElement;
//end return commented & changed by sabyasachi 25-03-2011
}
////////////////////////////////////////////////////////////////////////////
private void populateMTODemandSupply(String siteCode, String itemCode,ADPElement adpElement) throws Exception
{
double demand = 0;
double supply = 0;
java.sql.Timestamp dueDate = null;
//String itemCode = null;
//String siteCode = null;
// 12/04/10 manoharan MF90BHU001
double stockQty = 0;
double othSupply = 0;
// end 12/04/10 manoharan MF90BHU001
Statement stmt = null;
ResultSet rs = null;
errString = "";
String adpQuery = null;
PreparedStatement pstmt = null;
String saleOrder = null,rsItemCode = "";
String lineNo = null;
try
{
//itemCode = adpElement.getItemCode();
//siteCode = adpElement.getSiteCode();
//ADPElement adpElement = new ADPElement(); // 01/04/11 manoharan dummy for nothing
if (!"0".equals(madeToOrder) || !"O".equals(adpElement.getMfgType()))
{
return;
}
//System.out.println("commonConstants.DB_NAME "+CommonConstants.DB_NAME);
// 14-02-2007 manoharan
String sqlFileName = null;
sqlFileName = CommonConstants.JBOSSHOME + File.separator +"sql" + File.separator + "madeToOrder" ;
// end 14-02-2007 manoharan
//added by Sabyasachi 30-03-2011
if((CommonConstants.DB_NAME).equalsIgnoreCase("db2"))
{
//System.out.println("Firing DB2 Sql For Site Code :" + siteCode + " Item Code : " + itemCode + " From Date : " + dateFrom + " To Date : "+ dateTo + " StandgOrdTypes : "+ standingOrdTypes +" MadeToOrder " +madeToOrder+ " MadeToStock : " + madeToStock);
// 14-02-2007 manoharan
//String adpQueryOriginal = readFile(CommonConstants.JBOSSHOME + File.separator +"sql" + File.separator + "demandsupplyDB2.sql");
String adpQueryOriginal = readFile(sqlFileName+ "DB2.sql");
// end 14-02-2007 manoharan
String strDateFrom = dateFrom.toString();
strDateFrom = strDateFrom.replaceAll(" ","-");
strDateFrom = strDateFrom.replaceAll(":",".");
String strDateTo = dateTo.toString();
strDateTo = strDateTo.replaceAll(" ","-");
strDateTo = strDateTo.replaceAll(":",".");
/*// 01-10-2007 manoharan
String strRunDate = runDate.toString();
strRunDate = strRunDate.replaceAll(" ","-");
strRunDate = strRunDate.replaceAll(":",".");
// end 01-10-2007 manoharan*/
adpQuery = adpQueryOriginal;
//System.out.println("Afetr Reading File adpQuery..");
adpQuery = adpQuery.replaceAll("@sitecode@",siteCode);
adpQuery = adpQuery.replaceAll("@itemcode@",itemCode);
adpQuery = adpQuery.replaceAll("@fromdate@",dateFromString);
adpQuery = adpQuery.replaceAll("@todate@",dateToString );
adpQuery = adpQuery.replaceAll("@ordtypes@",standingOrdTypes);
adpQuery = adpQuery.replaceAll("@madetoorder@",madeToOrder);
adpQuery = adpQuery.replaceAll("@madetostock@",madeToStock);
// 01-10-2007 manoharan
adpQuery = adpQuery.replaceAll("@rundate@",runDateString );
// end 01-10-2007 manoharan
}
else if((CommonConstants.DB_NAME).equalsIgnoreCase("oracle"))
{
// 14-02-2007 manoharan
//String adpQueryOriginal = readFile(CommonConstants.JBOSSHOME + File.separator +"sql" + File.separator + "demandsupplyOracle.sql");
String adpQueryOriginal = readFile(sqlFileName + "Oracle.sql");
// end 14-02-2007 manoharan
adpQuery = adpQueryOriginal;
//System.out.println("Replacing Values.in SQL.....");
adpQuery = adpQuery.replaceAll("@sitecode@",siteCode);
adpQuery = adpQuery.replaceAll("@itemcode@",itemCode);
adpQuery = adpQuery.replaceAll("@fromdate@",dbDateFrom);
adpQuery = adpQuery.replaceAll("@todate@",dbDateTo);
adpQuery = adpQuery.replaceAll("@ordtypes@",standingOrdTypes);
adpQuery = adpQuery.replaceAll("@madetoorder@",madeToOrder);
adpQuery = adpQuery.replaceAll("@madetostock@",madeToStock);
// 01-10-2007 manoharan
adpQuery = adpQuery.replaceAll("@rundate@",dbRunDate);
// end 01-10-2007 manoharan
//System.out.println("Replaced Values.in SQL.....");
}
FileOutputStream fout = null;
BufferedWriter bw = null;
fout = new FileOutputStream("demandsupply.sql");
bw = new BufferedWriter(new OutputStreamWriter(fout));
bw.write(adpQuery);
bw.close();
fout.close();
pstmt = conn.prepareStatement(adpQuery);
rs = pstmt.executeQuery();
while(rs.next())
{
saleOrder = rs.getString(1);
lineNo = rs.getString(2);
rsItemCode = rs.getString(3);
dueDate = rs.getTimestamp(4);
demand = rs.getDouble(5);
supply = rs.getDouble(6);
stockQty = rs.getDouble(7);
othSupply = rs.getDouble(8);
if (dueDate.compareTo(dateFrom) < 0 )
{
dueDate = dateFrom;
}
/*if(rsItemCode != null && rsItemCode.trim().equalsIgnoreCase(itemCode.trim()) && (adpElement.getSaleOrder().equals(saleOrder)) && (adpElement.getLineNo().equals(lineNo)))
{
adpElement.setDemand(dueDate, demand, saleOrder, lineNo);
adpElement.setSupply(dueDate, supply);
adpElement.setStockQty(dueDate, stockQty);
adpElement.setOthSupply(dueDate, othSupply);
}
else
{ */
// 01/04/11 find same item without sales order, if exists remove from array
/*
int ctr = indexOfADPElement(siteCode, rsItemCode," "," ");
//
if(ctr > -1)
{
adpeList.remove(ctr);
} }
// end 01/04/11*/
int ctr = indexOfADPElement(siteCode, rsItemCode,saleOrder,lineNo);
System.out.println("01/04/11 BHU saleOrder [" + saleOrder + "] lineNo [" + lineNo + "] ctr [" + ctr + "]");
if(ctr > -1)
{
ADPElement tempADPElement = (ADPElement)adpeList.get(ctr);
tempADPElement.setDemand(dueDate, demand, saleOrder, lineNo);
tempADPElement.setSupply(dueDate, supply);
adpeList.set(ctr,tempADPElement);
}
else if(ctr == -1)
{
ADPElement newADPElement = new ADPElement();
newADPElement.setSiteCode(siteCode);
newADPElement.setItemCode(rsItemCode);
newADPElement = setAdpeValues(newADPElement);
newADPElement.setSaleOrder(saleOrder);
newADPElement.setLineNo(lineNo);
newADPElement.setDemand(dueDate, demand, saleOrder, lineNo);
newADPElement.setSupply(dueDate, supply);
adpeList.add(newADPElement);
System.out.println("01/04/11 BHU not found adding saleOrder [" + saleOrder + "] lineNo [" + lineNo + "] ctr [" + ctr + "]");
}
//}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//added by Sabyasachi ends 30-03-2011
}
catch(SQLException se)
{
System.out.println("SQLException :RunMRPPrcEJB : populateDemandSupply(ADPElement).." +se.getMessage());
System.out.println(adpQuery);
se.printStackTrace();
errString = se.getMessage();
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception :RunMRPPrcEJB : populateDemandSupply(ADPElement):...." + e.getMessage() + ":");
this.errString = genericUtility.createErrorString(e);
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
if (pstmt != null) { pstmt = null; }
if (rs != null) { rs = null; }
this.fw1.flush();//Added by jiten 10/11/06
//System.out.println("populateDemandSupply() finally block......");
// return adpElement;
}
//ResultSetMetaData rsmd = rs.getMetaData();
//int noOfColumns = rsmd.getColumnCount();
//return commented & changed by sabyasachi 25-03-2011
//return adpElement; //Moved here from finaly - jiten - 03/11/06
//return adpElement;
//end return commented & changed by sabyasachi 25-03-2011
}
////////////////////////////////////////////////////////////////////////////
private String mrpOptimize() throws RemoteException,ITMException private String mrpOptimize() throws RemoteException,ITMException
{ {
String errString = ""; String errString = "";
...@@ -2747,7 +3028,14 @@ fout.close(); ...@@ -2747,7 +3028,14 @@ fout.close();
} }
else else
{ {
updateDemand(retXMLStr); if ("O".equals(adpElement.getMfgType()))
{
updateDemand(retXMLStr,adpElement.getSaleOrder(),adpElement.getLineNo());
}
else
{
updateDemand(retXMLStr," "," ");
}
} }
} }
} // inner -- if(runningDemand - runningSupply) } // inner -- if(runningDemand - runningSupply)
...@@ -2762,7 +3050,7 @@ fout.close(); ...@@ -2762,7 +3050,7 @@ fout.close();
} }
return adpElement;//errString; return adpElement;//errString;
} }
private void updateSupplySite(String siteCode, String itemCode, double quantity, java.sql.Timestamp dueDate) private void updateSupplySite(String siteCode, String itemCode, double quantity, java.sql.Timestamp dueDate) throws ITMException, Exception
{ {
ADPElement adpElement; ADPElement adpElement;
int found = -1; int found = -1;
...@@ -2773,7 +3061,7 @@ fout.close(); ...@@ -2773,7 +3061,7 @@ fout.close();
adpElement = (ADPElement)adpeList.get(adpeCtr); adpElement = (ADPElement)adpeList.get(adpeCtr);
if (adpElement.getItemCode().trim().equals(itemCode.trim()) && adpElement.getSiteCode().trim().equals(siteCode.trim()) ) if (adpElement.getItemCode().trim().equals(itemCode.trim()) && adpElement.getSiteCode().trim().equals(siteCode.trim()) )
{ {
adpElement.setDemand(dueDate,quantity); adpElement.setDemand(dueDate,quantity," "," ");
found = adpeCtr; found = adpeCtr;
adpeList.set(adpeCtr,adpElement); adpeList.set(adpeCtr,adpElement);
break; break;
...@@ -2785,7 +3073,7 @@ fout.close(); ...@@ -2785,7 +3073,7 @@ fout.close();
adpElement.setItemCode(itemCode); adpElement.setItemCode(itemCode);
adpElement.setSiteCode(siteCode); adpElement.setSiteCode(siteCode);
adpElement = setAdpeValues(adpElement); adpElement = setAdpeValues(adpElement);
adpElement.setDemand(dueDate,quantity); adpElement.setDemand(dueDate,quantity," "," ");
adpeList.add(adpElement); adpeList.add(adpElement);
} }
} }
...@@ -2793,12 +3081,12 @@ fout.close(); ...@@ -2793,12 +3081,12 @@ fout.close();
{ {
System.out.println("Exception :RunMRPPrcEJB :mrpOptimize():" + e.getMessage() + ":"); System.out.println("Exception :RunMRPPrcEJB :mrpOptimize():" + e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
//throw new ITMException(e); throw new ITMException(e);
} }
} }
private void updateIndependentDemand(String siteCode, String itemCode, double quantity, java.sql.Timestamp dueDate, String siteCodeCust) throws ITMException private void updateIndependentDemand(String siteCode, String itemCode, double quantity, java.sql.Timestamp dueDate, String siteCodeCust) throws ITMException, Exception
{ {
ADPElement adpElement; ADPElement adpElement;
int found = -1; int found = -1;
...@@ -2836,7 +3124,7 @@ fout.close(); ...@@ -2836,7 +3124,7 @@ fout.close();
} }
private double calculateQuantity(ADPElement adpElement, java.sql.Timestamp dueDate, double reqQty) private double calculateQuantity(ADPElement adpElement, java.sql.Timestamp dueDate, double reqQty) throws ITMException, Exception
{ {
double demand = 0; double demand = 0;
double supply = 0; double supply = 0;
...@@ -3040,13 +3328,13 @@ fout.close(); ...@@ -3040,13 +3328,13 @@ fout.close();
return reqQty; return reqQty;
} }
private double getMod(double total, double batch) private double getMod(double total, double batch) throws ITMException, Exception
{ {
int multiplier = 0; int multiplier = 0;
multiplier = new Double(Math.floor(total / batch)).intValue(); multiplier = new Double(Math.floor(total / batch)).intValue();
return total - (multiplier * batch); return total - (multiplier * batch);
} }
private double getStkLevel(ADPElement adpElement, java.sql.Timestamp dueDate) private double getStkLevel(ADPElement adpElement, java.sql.Timestamp dueDate) throws ITMException, Exception
{ {
TimeMRP timeMRP = null; TimeMRP timeMRP = null;
int timeEle = -1, ctr; int timeEle = -1, ctr;
...@@ -3098,11 +3386,15 @@ fout.close(); ...@@ -3098,11 +3386,15 @@ fout.close();
{ {
System.out.println("Exception :adpeLEMENT : updateTimeMrp(Date, supply, demand):...." + e.getMessage() + ":"); System.out.println("Exception :adpeLEMENT : updateTimeMrp(Date, supply, demand):...." + e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e);
} }
return retValue; return retValue;
} }
private void updateDemand(String xmlString) private void updateDemand(String xmlString) throws ITMException, Exception
{ updateDemand(xmlString," "," ");
}
private void updateDemand(String xmlString,String saleOrder, String lineNo) throws ITMException, Exception
{ {
Document dom; Document dom;
String siteCode = null; String siteCode = null;
...@@ -3124,6 +3416,7 @@ fout.close(); ...@@ -3124,6 +3416,7 @@ fout.close();
ADPElement adpElement = null; ADPElement adpElement = null;
try try
{ {
System.out.println("In updateDemand xmlString [" + xmlString + "]");
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
nodeList = dom.getElementsByTagName("Detail"); nodeList = dom.getElementsByTagName("Detail");
totalNodes = nodeList.getLength(); totalNodes = nodeList.getLength();
...@@ -3173,12 +3466,28 @@ fout.close(); ...@@ -3173,12 +3466,28 @@ fout.close();
rs.close(); rs.close();
pstmt.close(); pstmt.close();
int index = indexOfADPElement(siteCode, itemCode); int index = indexOfADPElement(siteCode, itemCode," "," ");
if (index != -1) if (index != -1)
{ {
adpElement = (ADPElement)adpeList.get(index); adpElement = (ADPElement)adpeList.get(index);
adpElement.setDemand(dueDate, quantity); if (saleOrder == null || saleOrder.trim().length() == 0 || !"M".equals(adpElement.getSuppSour()))
{
//adpElement = (ADPElement)adpeList.get(index);
adpElement.setDemand(dueDate, quantity," "," ");
adpeList.set(index,adpElement); adpeList.set(index,adpElement);
}
else
{
ADPElement newADPElement = new ADPElement();
newADPElement.setSiteCode(siteCode);
newADPElement.setItemCode(itemCode);
newADPElement = setAdpeValues(newADPElement);
newADPElement.setSaleOrder(saleOrder);
newADPElement.setLineNo(lineNo);
newADPElement.setDemand(dueDate, quantity, saleOrder, lineNo);
adpeList.add(newADPElement);
}
//System.out.println("Material Site " + siteCode + " Item " + itemCode + " Demand " + decFormat(quantity) + "Due Date " + sdate ); //System.out.println("Material Site " + siteCode + " Item " + itemCode + " Demand " + decFormat(quantity) + "Due Date " + sdate );
} }
else else
...@@ -3193,17 +3502,27 @@ fout.close(); ...@@ -3193,17 +3502,27 @@ fout.close();
System.out.println("Exception :RunMRPPrcEJB : updateDemand(String).." +e.getMessage()); System.out.println("Exception :RunMRPPrcEJB : updateDemand(String).." +e.getMessage());
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e);
} }
} }
private int indexOfADPElement(String siteCode, String itemCode) private int indexOfADPElement(String siteCode, String itemCode, String saleOrder, String lineNo) throws ITMException, Exception
{ {
int retVal = -1, ctr = 0; int retVal = -1, ctr = 0;
ADPElement adpElement = null; ADPElement adpElement = null;
if (saleOrder == null || saleOrder.trim().length() == 0)
{
saleOrder = " ";
}
if (lineNo == null || lineNo.trim().length() == 0)
{
lineNo = " ";
}
for (ctr = 0; ctr < adpeList.size(); ctr++) for (ctr = 0; ctr < adpeList.size(); ctr++)
{ {
adpElement = (ADPElement)adpeList.get(ctr); adpElement = (ADPElement)adpeList.get(ctr);
if ( (adpElement.getSiteCode().equals(siteCode)) && (adpElement.getItemCode().equals(itemCode)) ) if ( (adpElement.getSiteCode().equals(siteCode)) && (adpElement.getItemCode().equals(itemCode))
&& (adpElement.getSaleOrder().equals(saleOrder)) && (adpElement.getLineNo().equals(lineNo)))
{ {
retVal = ctr; retVal = ctr;
break; break;
...@@ -3212,7 +3531,7 @@ fout.close(); ...@@ -3212,7 +3531,7 @@ fout.close();
return retVal; return retVal;
} }
private String populateInterSiteDistance() private String populateInterSiteDistance() throws ITMException, Exception
{ {
String siteCode = ""; String siteCode = "";
String siteCodeFrom = ""; String siteCodeFrom = "";
...@@ -3248,12 +3567,14 @@ fout.close(); ...@@ -3248,12 +3567,14 @@ fout.close();
System.out.println("SQLException : populateInterSiteDistance() : " +e.getMessage()); System.out.println("SQLException : populateInterSiteDistance() : " +e.getMessage());
this.errString = genericUtility.createErrorString(e); this.errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e);
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :populateInterSiteDistance():" + e.getMessage() + ":"); System.out.println("Exception :populateInterSiteDistance():" + e.getMessage() + ":");
this.errString = genericUtility.createErrorString(e); this.errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e);
} }
finally finally
{ {
...@@ -3273,7 +3594,7 @@ fout.close(); ...@@ -3273,7 +3594,7 @@ fout.close();
return errString;// Moved here as Finally block does not complete normally - jiten -03/11/06 return errString;// Moved here as Finally block does not complete normally - jiten -03/11/06
} }
private double getDistance(String siteCodeFrom,String siteCodeTo) private double getDistance(String siteCodeFrom,String siteCodeTo) throws ITMException, Exception
{ {
InterSiteDistance interSite = null; InterSiteDistance interSite = null;
int interSiteEle = -1; int interSiteEle = -1;
...@@ -3303,7 +3624,7 @@ fout.close(); ...@@ -3303,7 +3624,7 @@ fout.close();
} }
} }
private void populateSurplusList() private void populateSurplusList() throws ITMException, Exception
{ {
ADPElement adpElement = null; ADPElement adpElement = null;
SurplusStock surplusStock = null; SurplusStock surplusStock = null;
...@@ -3328,7 +3649,7 @@ fout.close(); ...@@ -3328,7 +3649,7 @@ fout.close();
} }
} }
private String getSurplusStockSite(String siteCode,String itemCode,double Qty,ArrayList surplusList) private String getSurplusStockSite(String siteCode,String itemCode,double Qty,ArrayList surplusList) throws ITMException, Exception
{ {
String siteCodeFrom = null; String siteCodeFrom = null;
SurplusStock surplusStock = null; SurplusStock surplusStock = null;
...@@ -3375,7 +3696,7 @@ fout.close(); ...@@ -3375,7 +3696,7 @@ fout.close();
indDemList.clear(); indDemList.clear();
disList.clear(); disList.clear();
} }
public String getDateFromTimeStamp(java.sql.Timestamp timeStampDate, String targetFormat) public String getDateFromTimeStamp(java.sql.Timestamp timeStampDate, String targetFormat) throws ITMException, Exception
{ {
String retStrDate = null; String retStrDate = null;
try try
...@@ -3386,15 +3707,16 @@ fout.close(); ...@@ -3386,15 +3707,16 @@ fout.close();
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :RunMRPPrcEJB :getDateFromTimeStamp(TimeStampDate) " + e); System.out.println("Exception :RunMRPPrcEJB :getDateFromTimeStamp(TimeStampDate) " + e);
throw new ITMException(e);
} }
return retStrDate; return retStrDate;
} }
private String deleteOldPlan(String siteCode, String itemCode) private String deleteOldPlan(String siteCode, String itemCode) throws ITMException, Exception
{ {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String sqlMpsOrder; String sqlMpsOrder, sqlWorkOrder;
String sqlIndent; String sqlIndent;
String sqlDistDemand; String sqlDistDemand;
int rowsDeleted = 0; int rowsDeleted = 0;
...@@ -3413,6 +3735,10 @@ fout.close(); ...@@ -3413,6 +3735,10 @@ fout.close();
+ "WHERE SITE_CODE = ? " + "WHERE SITE_CODE = ? "
+ "AND ITEM_CODE = ? "; + "AND ITEM_CODE = ? ";
sqlWorkOrder = "DELETE FROM WORKORDER "
+ "WHERE SITE_CODE = ? "
+ "AND ITEM_CODE = ? "
+ " AND STATUS in ('M','P')";
sqlDistDemand = "DELETE FROM DIST_DEMAND " sqlDistDemand = "DELETE FROM DIST_DEMAND "
+ " WHERE STATUS = 'P' " + " WHERE STATUS = 'P' "
+ "AND SITE_CODE = ? " + "AND SITE_CODE = ? "
...@@ -3438,6 +3764,13 @@ fout.close(); ...@@ -3438,6 +3764,13 @@ fout.close();
System.out.println("Rows Deleted in MpsOrder :" + rowsDeleted); System.out.println("Rows Deleted in MpsOrder :" + rowsDeleted);
conn.commit(); conn.commit();
pstmt.close(); pstmt.close();
pstmt = conn.prepareStatement(sqlWorkOrder);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
rowsDeleted = pstmt.executeUpdate();
System.out.println("Rows Deleted in WorkOrder :" + rowsDeleted);
conn.commit();
pstmt.close();
} }
if (disPlan.equals("Y")) if (disPlan.equals("Y"))
...@@ -3464,6 +3797,7 @@ fout.close(); ...@@ -3464,6 +3797,7 @@ fout.close();
this.errString = genericUtility.createErrorString(e); this.errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e);
} }
finally finally
{ {
...@@ -3472,7 +3806,7 @@ fout.close(); ...@@ -3472,7 +3806,7 @@ fout.close();
} }
return errString;//Moved here as Finally block does not complete normally - jiten -03/11/06 return errString;//Moved here as Finally block does not complete normally - jiten -03/11/06
} }
private String generatePlanDemand() private String generatePlanDemand() throws ITMException, Exception
{ {
ADPElement adpElement = null; ADPElement adpElement = null;
...@@ -3481,6 +3815,7 @@ fout.close(); ...@@ -3481,6 +3815,7 @@ fout.close();
for (int adpeCtr = 0; adpeCtr < adpeList.size(); adpeCtr++) for (int adpeCtr = 0; adpeCtr < adpeList.size(); adpeCtr++)
{ {
adpElement = (ADPElement)adpeList.get(adpeCtr); adpElement = (ADPElement)adpeList.get(adpeCtr);
System.out.println("01/04/11 SO adpeCtr [" + adpeCtr + "] SO [" + adpElement.getSaleOrder() + "]");
errString = generatePlanDemand(adpElement); errString = generatePlanDemand(adpElement);
if ( errString != null && errString.trim().length() > 0 ) if ( errString != null && errString.trim().length() > 0 )
{ {
...@@ -3494,10 +3829,11 @@ fout.close(); ...@@ -3494,10 +3829,11 @@ fout.close();
System.out.println("Exception :RunMRPPrcEJB :CreatePlanDemand ():" + e.getMessage() + ":"); System.out.println("Exception :RunMRPPrcEJB :CreatePlanDemand ():" + e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e);
} }
return errString; return errString;
} }
private String generatePlanDemand(ADPElement adpElement) private String generatePlanDemand(ADPElement adpElement) throws ITMException, Exception
{ {
PreparedStatement pstmtMpsOrder = null; PreparedStatement pstmtMpsOrder = null;
PreparedStatement pstmtIndent = null; PreparedStatement pstmtIndent = null;
...@@ -3871,6 +4207,12 @@ fout.close(); ...@@ -3871,6 +4207,12 @@ fout.close();
mpsOrder.curBatchQty = batchQty; mpsOrder.curBatchQty = batchQty;
//ld_worder.setitem(ll_row, "std_qty", lc_create_qty) // 04-07-03 //ld_worder.setitem(ll_row, "std_qty", lc_create_qty) // 04-07-03
//ld_worder.setitem(ll_row, "demand_qty", lc_actualdemand) //ld_worder.setitem(ll_row, "demand_qty", lc_actualdemand)
// 01/04/11 manoharan
System.out.println("01/04/11 setting SO in MPS A [" + adpElement.getSaleOrder() + "]");
mpsOrder.saleOrder = adpElement.getSaleOrder();
mpsOrder.lineNo = adpElement.getLineNo();
mpsOrder.mfgType = adpElement.getMfgType();
// end 01/04/11 manoharan
mpsList.add(mpsOrder); mpsList.add(mpsOrder);
} }
...@@ -3945,6 +4287,12 @@ fout.close(); ...@@ -3945,6 +4287,12 @@ fout.close();
mpsOrder.curBatchQty = batchQty; mpsOrder.curBatchQty = batchQty;
//ld_worder.setitem(ll_row, "std_qty", lc_create_qty) // 04-07-03 //ld_worder.setitem(ll_row, "std_qty", lc_create_qty) // 04-07-03
//ld_worder.setitem(ll_row, "demand_qty", lc_actualdemand) //ld_worder.setitem(ll_row, "demand_qty", lc_actualdemand)
// 01/04/11 manoharan
System.out.println("01/04/11 setting SO in MPS 0 [" + adpElement.getSaleOrder() + "]");
mpsOrder.saleOrder = adpElement.getSaleOrder();
mpsOrder.lineNo = adpElement.getLineNo();
mpsOrder.mfgType = adpElement.getMfgType();
// end 01/04/11 manoharan
mpsList.add(mpsOrder); mpsList.add(mpsOrder);
} }
...@@ -3973,6 +4321,13 @@ fout.close(); ...@@ -3973,6 +4321,13 @@ fout.close();
mpsOrder.acctCodeWp = adpElement.getAcctCodeWp(); mpsOrder.acctCodeWp = adpElement.getAcctCodeWp();
mpsOrder.cctrCodeWp = adpElement.getCctrCodeWp(); mpsOrder.cctrCodeWp = adpElement.getCctrCodeWp();
mpsOrder.curBatchQty = balQty; mpsOrder.curBatchQty = balQty;
// 01/04/11 manoharan
System.out.println("01/04/11 setting SO in MPS 1 [" + adpElement.getSaleOrder() + "]");
mpsOrder.saleOrder = adpElement.getSaleOrder();
mpsOrder.lineNo = adpElement.getLineNo();
mpsOrder.mfgType = adpElement.getMfgType();
// end 01/04/11 manoharan
mpsList.add(mpsOrder); mpsList.add(mpsOrder);
} }
//Jiten - End 03/11/06 //Jiten - End 03/11/06
...@@ -3981,6 +4336,8 @@ fout.close(); ...@@ -3981,6 +4336,8 @@ fout.close();
{ {
int findEle = -1; int findEle = -1;
MPSOrder mpsOrder = null; MPSOrder mpsOrder = null;
if (!"O".equals(adpElement.getMfgType())) // 01/04/11 manoharan in case made to order not to club
{
if ( mpsList.size() > 0) if ( mpsList.size() > 0)
{ {
// check for the last ones existence if found add the demand to that // check for the last ones existence if found add the demand to that
...@@ -3995,6 +4352,7 @@ fout.close(); ...@@ -3995,6 +4352,7 @@ fout.close();
} }
} }
} }
}
if (findEle >= 0) if (findEle >= 0)
{ {
mpsOrder.quantity += reqQty; mpsOrder.quantity += reqQty;
...@@ -4024,6 +4382,12 @@ fout.close(); ...@@ -4024,6 +4382,12 @@ fout.close();
mpsOrder.acctCodeWp = adpElement.getAcctCodeWp(); mpsOrder.acctCodeWp = adpElement.getAcctCodeWp();
mpsOrder.cctrCodeWp = adpElement.getCctrCodeWp(); mpsOrder.cctrCodeWp = adpElement.getCctrCodeWp();
mpsOrder.curBatchQty = reqQty; mpsOrder.curBatchQty = reqQty;
// 01/04/11 manoharan
System.out.println("01/04/11 setting SO in MPS 2 [" + adpElement.getSaleOrder() + "]");
mpsOrder.saleOrder = adpElement.getSaleOrder();
mpsOrder.lineNo = adpElement.getLineNo();
mpsOrder.mfgType = adpElement.getMfgType();
// end 01/04/11 manoharan
mpsList.add(mpsOrder); mpsList.add(mpsOrder);
} }
...@@ -4166,6 +4530,7 @@ fout.close(); ...@@ -4166,6 +4530,7 @@ fout.close();
this.errString = genericUtility.createErrorString(e); this.errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e);
} }
finally finally
{ {
...@@ -4190,7 +4555,7 @@ fout.close(); ...@@ -4190,7 +4555,7 @@ fout.close();
return errString;//Moved here from finally as it does not complete normally - jiten - 03/11/06 return errString;//Moved here from finally as it does not complete normally - jiten - 03/11/06
} }
private String InsertPlanDemand() private String InsertPlanDemand() throws Exception
{ {
String errString = ""; String errString = "";
//System.out.println("In Insert Plan Demand()"); //System.out.println("In Insert Plan Demand()");
...@@ -4237,7 +4602,7 @@ fout.close(); ...@@ -4237,7 +4602,7 @@ fout.close();
return ""; return "";
} }
private String getStkOpt(String itemCode,String siteCode) private String getStkOpt(String itemCode,String siteCode) throws Exception
{ {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String sql = ""; String sql = "";
...@@ -4276,6 +4641,7 @@ fout.close(); ...@@ -4276,6 +4641,7 @@ fout.close();
System.out.println("SQLException :RunMRPPrcEJB :getBomCode(String siteCode, String ItemCode).." +e.getMessage()); System.out.println("SQLException :RunMRPPrcEJB :getBomCode(String siteCode, String ItemCode).." +e.getMessage());
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e);
} }
catch(Exception e) catch(Exception e)
...@@ -4284,6 +4650,7 @@ fout.close(); ...@@ -4284,6 +4650,7 @@ fout.close();
this.errString = genericUtility.createErrorString(e); this.errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e);
} }
finally finally
{ {
...@@ -4307,13 +4674,14 @@ fout.close(); ...@@ -4307,13 +4674,14 @@ fout.close();
private String InsertPlanDemand(String winName, java.util.ArrayList list) private String InsertPlanDemand(String winName, java.util.ArrayList list) throws ITMException, Exception
{ {
PreparedStatement pstmtMpsOrder = null; PreparedStatement pstmtMpsOrder = null;
PreparedStatement pstmtIndent = null; PreparedStatement pstmtIndent = null;
PreparedStatement pstmtDistDemand = null; PreparedStatement pstmtDistDemand = null;
PreparedStatement pstmtIndDemand = null; PreparedStatement pstmtIndDemand = null;
PreparedStatement pstmtKeyStr = null; PreparedStatement pstmtKeyStr = null;
PreparedStatement pstmtWorkOrder = null;
ResultSet rs = null; ResultSet rs = null;
String xmlValues = ""; String xmlValues = "";
...@@ -4394,6 +4762,14 @@ fout.close(); ...@@ -4394,6 +4762,14 @@ fout.close();
String tranIdDistDemand = null; String tranIdDistDemand = null;
String tranIdIndent = null; String tranIdIndent = null;
String tranIdMpsOrder = null; String tranIdMpsOrder = null;
//variables added by sabyasachi 30-03-11
String saleOrder = "";
String lineNo = "";
String woKeyStr = null;
String workOrder = null;
PreparedStatement pstmtworkOrder = null;
String sqlWorkOrder = null;
//variables added by sabyasachi ends 30-03-11
try try
{ {
...@@ -4444,25 +4820,47 @@ fout.close(); ...@@ -4444,25 +4820,47 @@ fout.close();
rs.close(); rs.close();
} }
pstmtKeyStr.clearParameters(); pstmtKeyStr.clearParameters();
pstmtKeyStr.setString(1,"w_worder");
rs = pstmtKeyStr.executeQuery();
if(rs.next())
{
woKeyStr = rs.getString("KEY_STRING");
}
rs.close();
rs = null;
pstmtKeyStr.close(); pstmtKeyStr.close();
pstmtKeyStr = null; pstmtKeyStr = null;
rs = null;
// 24/07/08 manoharan // 24/07/08 manoharan
//SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy"); //SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
sqlWorkOrder = "INSERT INTO WORKORDER(TRAN_ID,ORDER_TYPE,ITEM_CODE,SITE_CODE, "
+ "QUANTITY,ORD_DATE,PLAN_DUE_DATE,MRP_RUN_ID, "
+ "ADDN_ORDER,DUE_DATE,STATUS,STATUS_DATE,YIELD_PERC,ROUTE_CODE, "
+ "BOM_CODE,PROJ_CODE,CHG_DATE,CHG_USER,CHG_TERM,UNIT, "
+ "ACCT_CODE__WP,CCTR_CODE__WP,CURRENT_BATCH_QTY,UNIT__STD,"
+ " STD_QTY,CONV__QTY_STDUOM,SALE_ORDER,LINE_NO,WORK_ORDER) "
+ "VALUES ( ?, ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? ,"
+ " ? , ? , ? ,?, ?, ?,?,?)";
pstmtWorkOrder = conn.prepareStatement(sqlWorkOrder);
String sqlMpsOrder = "INSERT INTO MPS_ORDER(TRAN_ID,ORDER_TYPE,ITEM_CODE,SITE_CODE, " String sqlMpsOrder = "INSERT INTO MPS_ORDER(TRAN_ID,ORDER_TYPE,ITEM_CODE,SITE_CODE, "
+ "QUANTITY,ORD_DATE,PLAN_DUE_DATE,MRP_RUN_ID, " + "QUANTITY,ORD_DATE,PLAN_DUE_DATE,MRP_RUN_ID, "
+ "ADDN_ORDER,DUE_DATE,STATUS,STATUS_DATE,YIELD_PERC,ROUTE_CODE, " + "ADDN_ORDER,DUE_DATE,STATUS,STATUS_DATE,YIELD_PERC,ROUTE_CODE, "
+ "BOM_CODE,PROJ_CODE,CHG_DATE,CHG_USER,CHG_TERM,UNIT, " + "BOM_CODE,PROJ_CODE,CHG_DATE,CHG_USER,CHG_TERM,UNIT, "
+ "ACCT_CODE__WP,CCTR_CODE__WP,CURRENT_BATCH_QTY,UNIT__STD,STD_QTY,CONV__QTY_STDUOM) " + "ACCT_CODE__WP,CCTR_CODE__WP,CURRENT_BATCH_QTY,UNIT__STD,STD_QTY,CONV__QTY_STDUOM,SALE_ORDER,LINE_NO) "
+ "VALUES ( ? , ? , ? , ? , ? ," + "VALUES ( ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? ,"
+ " ? , ? , ? ,?, ?, ?)"; + " ? , ? , ? ,?, ?, ?,?,?)";
pstmtMpsOrder = conn.prepareStatement(sqlMpsOrder); pstmtMpsOrder = conn.prepareStatement(sqlMpsOrder);
...@@ -4534,12 +4932,17 @@ fout.close(); ...@@ -4534,12 +4932,17 @@ fout.close();
unit = mpsOrder.unit; unit = mpsOrder.unit;
acctCodeWp = mpsOrder.acctCodeWp; acctCodeWp = mpsOrder.acctCodeWp;
cctrCodeWp = mpsOrder.cctrCodeWp; cctrCodeWp = mpsOrder.cctrCodeWp;
//added by sabyasachi 30-03-11
saleOrder = mpsOrder.saleOrder;
lineNo = mpsOrder.lineNo;
//added by sabyasachi ends 30-03-11
// 20/01/09 manoharan // 20/01/09 manoharan
//xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>"; //xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues ="<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><Root>"; xmlValues ="<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><Root>";
xmlValues = xmlValues + "<Header></Header>"; xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>"; xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id><![CDATA[]]></tran_id>"; xmlValues = xmlValues + "<tran_id><![CDATA[]]></tran_id>";
xmlValues = xmlValues + "<work_order><![CDATA[]]></work_order>";
xmlValues = xmlValues + "<order_type><![CDATA[" + ordType + "]]></order_type>"; xmlValues = xmlValues + "<order_type><![CDATA[" + ordType + "]]></order_type>";
xmlValues = xmlValues + "<item_code><![CDATA[" + itemCode + "]]></item_code>"; xmlValues = xmlValues + "<item_code><![CDATA[" + itemCode + "]]></item_code>";
xmlValues = xmlValues + "<site_code><![CDATA[" + siteCode + "]]></site_code>"; xmlValues = xmlValues + "<site_code><![CDATA[" + siteCode + "]]></site_code>";
...@@ -4563,10 +4966,57 @@ fout.close(); ...@@ -4563,10 +4966,57 @@ fout.close();
xmlValues = xmlValues + "<cctr_code__wp><![CDATA[" + cctrCodeWp + "]]></cctr_code__wp>"; xmlValues = xmlValues + "<cctr_code__wp><![CDATA[" + cctrCodeWp + "]]></cctr_code__wp>";
xmlValues = xmlValues + "<current_batch_qty><![CDATA[" + quantity + "]]></current_batch_qty>"; xmlValues = xmlValues + "<current_batch_qty><![CDATA[" + quantity + "]]></current_batch_qty>";
xmlValues = xmlValues + "</Detail1></Root>"; xmlValues = xmlValues + "</Detail1></Root>";
if ("O".equals(mpsOrder.mfgType))
{
workOrder = getUniqueKey(xmlValues, mpsKeyStr, "work_order", "W-ORD");
pstmtWorkOrder.setString(1, workOrder);
pstmtWorkOrder.setString(2, ordType);
pstmtWorkOrder.setString(3, itemCode);
pstmtWorkOrder.setString(4, siteCode);
pstmtWorkOrder.setDouble(5, quantity);
pstmtWorkOrder.setTimestamp(6, ordDate);
pstmtWorkOrder.setTimestamp(7, planDueDate);
pstmtWorkOrder.setString(8, mrpRunId);
pstmtWorkOrder.setString(9, addnOrder);
pstmtWorkOrder.setTimestamp(10, dueDate);
pstmtWorkOrder.setString(11, "P");
pstmtWorkOrder.setTimestamp(12, statusDate);
pstmtWorkOrder.setDouble(13, yieldPerc);
pstmtWorkOrder.setString(14, routeCode);
pstmtWorkOrder.setString(15, bomCode);
pstmtWorkOrder.setString(16, projCode);
pstmtWorkOrder.setTimestamp(17, chgDate);
pstmtWorkOrder.setString(18, chgUser);
pstmtWorkOrder.setString(19, chgTerm);
pstmtWorkOrder.setString(20, unit);
pstmtWorkOrder.setString(21, acctCodeWp);
pstmtWorkOrder.setString(22, cctrCodeWp);
pstmtWorkOrder.setDouble(23, quantity);
pstmtWorkOrder.setString(24, unit);
pstmtWorkOrder.setDouble(25, quantity);
pstmtWorkOrder.setDouble(26, 1);
if(saleOrder != null && saleOrder.trim().length() > 0)
{
pstmtWorkOrder.setString(27,saleOrder);
}
else
{
pstmtWorkOrder.setNull(27,java.sql.Types.CHAR);
}
if(lineNo != null && lineNo.trim().length() > 0)
{
pstmtWorkOrder.setString(28,lineNo);
}
else
{
pstmtWorkOrder.setNull(28,java.sql.Types.CHAR);
}
pstmtWorkOrder.setString(29,workOrder);
pstmtWorkOrder.addBatch();
}
else
{
tranIdMpsOrder = getUniqueKey(xmlValues, mpsKeyStr, "tran_id", "W-MPS"); tranIdMpsOrder = getUniqueKey(xmlValues, mpsKeyStr, "tran_id", "W-MPS");
//System.out.println("Inserting mpsorder # " + count + " : " + tranIdMpsOrder);
pstmtMpsOrder.setString(1, tranIdMpsOrder); pstmtMpsOrder.setString(1, tranIdMpsOrder);
pstmtMpsOrder.setString(2, ordType); pstmtMpsOrder.setString(2, ordType);
pstmtMpsOrder.setString(3, itemCode); pstmtMpsOrder.setString(3, itemCode);
...@@ -4593,9 +5043,28 @@ fout.close(); ...@@ -4593,9 +5043,28 @@ fout.close();
pstmtMpsOrder.setString(24, unit); pstmtMpsOrder.setString(24, unit);
pstmtMpsOrder.setDouble(25, quantity); pstmtMpsOrder.setDouble(25, quantity);
pstmtMpsOrder.setDouble(26, 1); pstmtMpsOrder.setDouble(26, 1);
if(saleOrder != null && saleOrder.trim().length() > 0)
{
pstmtMpsOrder.setString(27,saleOrder);
}
else
{
pstmtMpsOrder.setNull(27,java.sql.Types.CHAR);
}
if(lineNo != null && lineNo.trim().length() > 0)
{
pstmtMpsOrder.setString(28,lineNo);
}
else
{
pstmtMpsOrder.setNull(28,java.sql.Types.CHAR);
}
//**************pstmtMpsOrder.setDouble(25, demandQty); //**************pstmtMpsOrder.setDouble(25, demandQty);
pstmtMpsOrder.addBatch(); pstmtMpsOrder.addBatch();
}
//System.out.println("Inserting mpsorder # " + count + " : " + tranIdMpsOrder);
} }
} }
...@@ -4843,6 +5312,10 @@ fout.close(); ...@@ -4843,6 +5312,10 @@ fout.close();
} }
} }
int rowsInsertedWorkOrder[] = pstmtWorkOrder.executeBatch();
//Commented by Jiten 31/10/06 - error -null pointer Exception
//pstmtMpsOrder.clearParameters();
pstmtWorkOrder.close();
//int [] insertToIndependentDemandCounts = pstmtMpsOrder.executeBatch() ; //int [] insertToIndependentDemandCounts = pstmtMpsOrder.executeBatch() ;
int rowsInsertedMpsOrder[] = pstmtMpsOrder.executeBatch(); int rowsInsertedMpsOrder[] = pstmtMpsOrder.executeBatch();
//Commented by Jiten 31/10/06 - error -null pointer Exception //Commented by Jiten 31/10/06 - error -null pointer Exception
...@@ -4867,6 +5340,7 @@ fout.close(); ...@@ -4867,6 +5340,7 @@ fout.close();
//pstmtIndDemand.clearParameters();//Commented by Jiten 14/11/06 as giving null pointer exception //pstmtIndDemand.clearParameters();//Commented by Jiten 14/11/06 as giving null pointer exception
pstmtIndDemand.close(); pstmtIndDemand.close();
conn.commit(); conn.commit();
System.out.println("Rows Inserted in Work Order : [" + rowsInsertedWorkOrder.length + "]");
System.out.println("Rows Inserted in Mps Order : [" + rowsInsertedMpsOrder.length + "]"); System.out.println("Rows Inserted in Mps Order : [" + rowsInsertedMpsOrder.length + "]");
System.out.println("Rows Inserted in Indent : [" + rowsInsertedIndent.length + "]"); System.out.println("Rows Inserted in Indent : [" + rowsInsertedIndent.length + "]");
System.out.println("Rows Inserted in Dist Demand : [" + rowsInsertedDistDemand.length + "]"); System.out.println("Rows Inserted in Dist Demand : [" + rowsInsertedDistDemand.length + "]");
...@@ -4893,9 +5367,14 @@ fout.close(); ...@@ -4893,9 +5367,14 @@ fout.close();
this.errString = genericUtility.createErrorString(e); this.errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e);
} }
finally finally
{ {
if (pstmtWorkOrder != null)
{
pstmtWorkOrder = null;
}
if (pstmtMpsOrder != null) if (pstmtMpsOrder != null)
{ {
pstmtMpsOrder = null; pstmtMpsOrder = null;
...@@ -4987,7 +5466,8 @@ fout.close(); ...@@ -4987,7 +5466,8 @@ fout.close();
int mfgLeadTime = 0; int mfgLeadTime = 0;
int minStkDay = 0; int minStkDay = 0;
int maxStkDay = 0; int maxStkDay = 0;
int hdrSeq = 0,seqNo = 0;
String saleOrder, lineNo;
boolean flag = true; boolean flag = true;
java.sql.Timestamp dueDate = null; java.sql.Timestamp dueDate = null;
...@@ -4995,27 +5475,31 @@ fout.close(); ...@@ -4995,27 +5475,31 @@ fout.close();
ADPElement adpElement = null; ADPElement adpElement = null;
try try
{ {
//modified query. added SALE_ORDER & LINE_NO by sabyasachi on 29-03-2011
// 01/04/11 manoharan sale_order,line_no and seq_no added
String sqlPlanHdr = "INSERT INTO PLAN_HDR(SITE_CODE, ITEM_CODE, ITEM_SER, SITE_CODE__SUPP, " String sqlPlanHdr = "INSERT INTO PLAN_HDR(SITE_CODE, ITEM_CODE, ITEM_SER, SITE_CODE__SUPP, "
+ "SUPP_SOUR, BOM_CODE, MIN_QTY, MIN_ORDER_QTY, MIN_STK_DAY, MAX_QTY, " + "SUPP_SOUR, BOM_CODE, MIN_QTY, MIN_ORDER_QTY, MIN_STK_DAY, MAX_QTY, "
+ "MAX_STK_DAY, ITEM_STRU, REO_QTY, PUR_LEAD_TIME, QC_LEAD_TIME, " + "MAX_STK_DAY, ITEM_STRU, REO_QTY, PUR_LEAD_TIME, QC_LEAD_TIME, "
+ "MFG_LEAD_TIME, INTEGRAL_QTY, BATCH_QTY, BATCH_QTY_TYPE, MASTER_SCH, ORDER_OPT, " + "MFG_LEAD_TIME, INTEGRAL_QTY, BATCH_QTY, BATCH_QTY_TYPE, MASTER_SCH, ORDER_OPT, "
+ "YIELD_PERC, MIN_PLAN_PERC, UNIT, APR_CODE, PACK_CODE, EMP_CODE__PUR, " + "YIELD_PERC, MIN_PLAN_PERC, UNIT, APR_CODE, PACK_CODE, EMP_CODE__PUR, "
+ "SUPP_CODE__PREF, PURC_RATE, ACCT_CODE__PH, CCTR_CODE__PH, ACCT_CODE__WP, CCTR_CODE__WP) " + "SUPP_CODE__PREF, PURC_RATE, ACCT_CODE__PH, CCTR_CODE__PH, ACCT_CODE__WP,"
+ " CCTR_CODE__WP,SALE_ORDER,LINE_NO,seq_no) "
+ "VALUES( ? , ? , ? , ? , ? , ? ," + "VALUES( ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? ) "; + " ? , ? , ? , ?, ?, ?) ";
pstmtPlanHdr = conn.prepareStatement(sqlPlanHdr); pstmtPlanHdr = conn.prepareStatement(sqlPlanHdr);
// 12/04/10 manoharan MF90BHU001 stock_qty and oth_supply added // 12/04/10 manoharan MF90BHU001 stock_qty and oth_supply added
String sqlPlanDet = "INSERT INTO PLAN_DET(SITE_CODE, ITEM_CODE, DEMAND, SUPPLY, PLAN_SUPP, " String sqlPlanDet = "INSERT INTO PLAN_DET(SITE_CODE, ITEM_CODE, DEMAND, SUPPLY, PLAN_SUPP, "
+ "RUNNING_DEMAND, RUNNING_SUPP, RUNNING_PLAN_SUPP, IND_DEMAND, DUE_DATE, STOCK_QTY, OTH_SUPPLY) " + "RUNNING_DEMAND, RUNNING_SUPP, RUNNING_PLAN_SUPP, IND_DEMAND, DUE_DATE, "
+ "VALUES( ? , ? , ? , ? , ? , ? ," + " STOCK_QTY, OTH_SUPPLY,SALE_ORDER,LINE_NO,SEQ_NO) "
+ " ? , ? , ? , ?, ?, ? ) "; + " VALUES( ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ?, ?, ?, ?, ? ,?) ";
// end 12/04/10 manoharan MF90BHU001 stock_qty and oth_supply added // end 12/04/10 manoharan MF90BHU001 stock_qty and oth_supply added
pstmtPlanDet = conn.prepareStatement(sqlPlanDet); pstmtPlanDet = conn.prepareStatement(sqlPlanDet);
hdrSeq = 0;
for(int adpeCount=0; adpeCount<adpeList.size(); adpeCount++) for(int adpeCount=0; adpeCount<adpeList.size(); adpeCount++)
{ {
flag = true; flag = true;
...@@ -5054,6 +5538,11 @@ fout.close(); ...@@ -5054,6 +5538,11 @@ fout.close();
cctrCodePh = adpElement.getCctrCodePh(); cctrCodePh = adpElement.getCctrCodePh();
acctCodeWp = adpElement.getAcctCodeWp(); acctCodeWp = adpElement.getAcctCodeWp();
cctrCodeWp = adpElement.getCctrCodeWp(); cctrCodeWp = adpElement.getCctrCodeWp();
//added by sabyasachi on 29-03-2011
saleOrder = adpElement.getSaleOrder();
lineNo = adpElement.getLineNo();
//seqNo = 0;
//added by sabyasachi on 29-03-2011 ends
// 02-03-2007 manoharan not to insert if the plan is not selected // 02-03-2007 manoharan not to insert if the plan is not selected
if(!disPlan.equalsIgnoreCase("Y") && (suppSour.trim().equalsIgnoreCase("D"))) if(!disPlan.equalsIgnoreCase("Y") && (suppSour.trim().equalsIgnoreCase("D")))
{ {
...@@ -5080,6 +5569,11 @@ fout.close(); ...@@ -5080,6 +5569,11 @@ fout.close();
runningDemand = timeMrp.getRunningDemand(); runningDemand = timeMrp.getRunningDemand();
runningSupply = timeMrp.getRunningSupply(); runningSupply = timeMrp.getRunningSupply();
runningPlanSupply = timeMrp.getRunningPlanSupply(); runningPlanSupply = timeMrp.getRunningPlanSupply();
// 01/04/11
if (runningPlanSupply <= 0 && demand <= 0 && supply <= 0 && planSupply <= 0 && runningDemand <= 0 && runningSupply <= 0)
{
continue;
}
independentDemand = timeMrp.getIndependentDemand(); independentDemand = timeMrp.getIndependentDemand();
dueDate = timeMrp.getDueDate(); dueDate = timeMrp.getDueDate();
// 12/04/10 Manoharan MF90BHU001 // 12/04/10 Manoharan MF90BHU001
...@@ -5101,9 +5595,31 @@ fout.close(); ...@@ -5101,9 +5595,31 @@ fout.close();
pstmtPlanDet.setDouble(11,stockQty); pstmtPlanDet.setDouble(11,stockQty);
pstmtPlanDet.setDouble(12,othSupply); pstmtPlanDet.setDouble(12,othSupply);
// end 12/04/10 Manoharan MF90BHU001 // end 12/04/10 Manoharan MF90BHU001
// 01/04/11 manoharan
if(saleOrder != null && saleOrder.trim().length() > 0)
{
pstmtPlanDet.setString(13,saleOrder);
}
else
{
pstmtPlanDet.setNull(13,java.sql.Types.CHAR);
}
if(lineNo != null && lineNo.trim().length() > 0)
{
pstmtPlanDet.setString(14,lineNo);
}
else
{
pstmtPlanDet.setNull(14,java.sql.Types.CHAR);
}
seqNo++;
pstmtPlanDet.setInt(15,seqNo);
// end 01/04/11 manoharan
pstmtPlanDet.addBatch(); pstmtPlanDet.addBatch();
} }
if (seqNo > 0)
{
pstmtPlanHdr.setString(1,siteCode); pstmtPlanHdr.setString(1,siteCode);
pstmtPlanHdr.setString(2,itemCode); pstmtPlanHdr.setString(2,itemCode);
pstmtPlanHdr.setString(3,itemSer); pstmtPlanHdr.setString(3,itemSer);
...@@ -5142,8 +5658,13 @@ fout.close(); ...@@ -5142,8 +5658,13 @@ fout.close();
pstmtPlanHdr.setString(31,cctrCodePh); pstmtPlanHdr.setString(31,cctrCodePh);
pstmtPlanHdr.setString(32,acctCodeWp); pstmtPlanHdr.setString(32,acctCodeWp);
pstmtPlanHdr.setString(33,cctrCodeWp); pstmtPlanHdr.setString(33,cctrCodeWp);
pstmtPlanHdr.setString(34,saleOrder);
pstmtPlanHdr.setString(35,lineNo);
hdrSeq++;
pstmtPlanHdr.setInt(36,hdrSeq);
pstmtPlanHdr.addBatch(); pstmtPlanHdr.addBatch();
}
//System.out.println("Site Code : [" + siteCode + "] Item Code : [" + itemCode + "] Bom Code : [" + bomCode + "] Item Ser : [" + itemSer + "]"); //System.out.println("Site Code : [" + siteCode + "] Item Code : [" + itemCode + "] Bom Code : [" + bomCode + "] Item Ser : [" + itemSer + "]");
} }
int rowsInsertedPlanHdr[] = pstmtPlanHdr.executeBatch(); int rowsInsertedPlanHdr[] = pstmtPlanHdr.executeBatch();
...@@ -5598,7 +6119,7 @@ fout.close(); ...@@ -5598,7 +6119,7 @@ fout.close();
row.getCell(29).setCellValue(mfgLeadTime); row.getCell(29).setCellValue(mfgLeadTime);
} }
flag = false; //flag = false; // 25/02/11 manoharan commented as BTPL want the same to be repeated in the excel file
} }
} }
...@@ -5773,6 +6294,7 @@ fout.close(); ...@@ -5773,6 +6294,7 @@ fout.close();
return reqVal; return reqVal;
}*/ }*/
} }
//Added by Jiten 07/11/06 //Added by Jiten 07/11/06
......
...@@ -19,11 +19,19 @@ public class TimeMRP ...@@ -19,11 +19,19 @@ public class TimeMRP
private double stockQty = 0; private double stockQty = 0;
private double othSupply = 0; private double othSupply = 0;
// end 12/04/10 manoharan MF90BHU001 // end 12/04/10 manoharan MF90BHU001
//added by sabyasachi 17.03.2011
//private String saleOrder = "";
//private String lineNo = "";
//end added by sabyasachi 17.03.2011
boolean createDemand = false; boolean createDemand = false;
public TimeMRP() public TimeMRP()
{ {
// System.out.println("New TimeMRP Created"); // System.out.println("New TimeMRP Created");
//this.saleOrder = " ";
//this.lineNo = " ";
} }
public void setDueDate(java.sql.Timestamp dueDate) public void setDueDate(java.sql.Timestamp dueDate)
...@@ -37,10 +45,16 @@ public class TimeMRP ...@@ -37,10 +45,16 @@ public class TimeMRP
return this.dueDate; return this.dueDate;
} }
//changed method arguments by sabyasachi 29-03-2011
//public void setDemand(double demand,String saleOrder, String lineNo)
public void setDemand(double demand) public void setDemand(double demand)
{ {
this.demand += demand; this.demand += demand;
//this.saleOrder = saleOrder;
//this.lineNo = lineNo;
} }
//changed method definition by sabyasachi 29-03-2011 end
public double getDemand() public double getDemand()
{ {
return this.demand; return this.demand;
...@@ -113,4 +127,22 @@ public class TimeMRP ...@@ -113,4 +127,22 @@ public class TimeMRP
{ {
return this.independentDemand; return this.independentDemand;
} }
//added by sabyasachi 17.03.2011
//public void setSaleOrder(String saleOrder)
//{
// this.saleOrder = saleOrder;
//}
//public String getSaleOrder()
//{
// return this.saleOrder;
//}
//public void setLineNo(String lineNo)
//{
// this.lineNo = lineNo;
//}
//public String getLineNo()
//{
// return this.lineNo;
//}
//end added by sabyasachi 17.03.2011
} }
\ No newline at end of file
...@@ -576,7 +576,7 @@ public String actionHandler(String actionType, String xmlString,String xmlString ...@@ -576,7 +576,7 @@ public String actionHandler(String actionType, String xmlString,String xmlString
+" BOMDET.PEND_STK, BOMDET.POTENCY_INPUT, BOMDET.ISS_VAR_VALTYPE, " +" BOMDET.PEND_STK, BOMDET.POTENCY_INPUT, BOMDET.ISS_VAR_VALTYPE, "
+" BOMDET.SPEC_METADATA, BOMDET.SPEC_DIMENSION , BOMDET.MFG_REF , BOMDET.ITEM_CATEGORY, BOMDET.DISP_CONTAINER_SIZE, " +" BOMDET.SPEC_METADATA, BOMDET.SPEC_DIMENSION , BOMDET.MFG_REF , BOMDET.ITEM_CATEGORY, BOMDET.DISP_CONTAINER_SIZE, "
+" BOMDET.OPERATION_USED " +" BOMDET.OPERATION_USED "
+" FROM BOMDET ,ITEM WHERE ( BOMDET.ITEM_CODE = ITEM.ITEM_CODE (+)) AND " +" FROM BOMDET ,ITEM WHERE ( BOMDET.ITEM_CODE = ITEM.ITEM_CODE ) AND "
+" ( ( BOMDET.BOM_CODE = ? ) ) " ; +" ( ( BOMDET.BOM_CODE = ? ) ) " ;
pstmt = conn.prepareStatement(sql1); pstmt = conn.prepareStatement(sql1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment