Commit c056a1ef authored by msharma's avatar msharma

MF90BHU007 MANOJ SHARMA CYCLIC ITEM CHECKING


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91479 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ef864aa8
...@@ -11,10 +11,10 @@ package ibase.webitm.ejb.mfg; ...@@ -11,10 +11,10 @@ package ibase.webitm.ejb.mfg;
4. Drop primay key of plan_hdr 4. Drop primay key of plan_hdr
alter table plan_hdr drop constraint plan_hdr_x; alter table plan_hdr drop constraint plan_hdr_x;
alter table plan_hdr drop constraint planhdr_x; alter table plan_hdr drop constraint planhdr_x;
5. Create new primary key with sale_order and line_no 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; 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 6. in of case mfgtype = "O" create workorder instead of mps order
*/ */
import org.w3c.dom.*; import org.w3c.dom.*;
...@@ -125,11 +125,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -125,11 +125,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
HashMap itemCodeMap = new HashMap(); HashMap itemCodeMap = new HashMap();
HashMap siteCodeMap = new HashMap(); HashMap siteCodeMap = new HashMap();
HashMap itemHashMap = new HashMap(); HashMap itemHashMap = new HashMap();
Set itemList = new HashSet(); Set itemList = new HashSet();
Set cyclicCheck = null;
String logInSite = ""; String logInSite = "";
String chgUser = ""; String chgUser = "";
String chgTerm = ""; String chgTerm = "";
HashMap hmap=new HashMap();
int level=0;
CommonConstants commonConstants = new CommonConstants(); CommonConstants commonConstants = new CommonConstants();
...@@ -226,11 +228,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -226,11 +228,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
try try
{ {
//Added by Jiten 07/11/06 //Added by Jiten 07/11/06
this.fw = new FileWriter(CommonConstants.JBOSSHOME+"\\log\\RepeatBom.log"); //this.fw = new FileWriter(CommonConstants.JBOSSHOME+"\\log\\RepeatBom.log");
this.fw=new FileWriter(CommonConstants.JBOSSHOME + File.separator +"log"+File.separator+"RepeatBom.log");
this.fw.write("Site Code Bom Code Item Code CyclicItemCode"+"\r\n"); this.fw.write("Site Code Bom Code Item Code CyclicItemCode"+"\r\n");
//End //End
//Added by jiten 10/11/06 //Added by jiten 10/11/06
this.fw1 = new FileWriter(CommonConstants.JBOSSHOME+"\\log\\SkipItem.log"); //this.fw1 = new FileWriter(CommonConstants.JBOSSHOME+"\\log\\SkipItem.log");
this.fw1=new FileWriter(CommonConstants.JBOSSHOME + File.separator +"log"+File.separator+"SkipItem.log");
this.fw1.write("Site Code Product Code ItemCode Skipped"+"\r\n"); this.fw1.write("Site Code Product Code ItemCode Skipped"+"\r\n");
//End //End
...@@ -420,7 +424,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -420,7 +424,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
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()+"' "
...@@ -476,6 +480,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -476,6 +480,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
finally finally
{ {
try{ try{
if(conn!=null)
{
conn.close();
conn=null;
}
this.fw.flush();//Added by Jiten 07/11/06 this.fw.flush();//Added by Jiten 07/11/06
this.fw.close();//Added by Jiten 07/11/06 this.fw.close();//Added by Jiten 07/11/06
this.fw1.flush();//Added by JIten 10/11/06 this.fw1.flush();//Added by JIten 10/11/06
...@@ -1120,6 +1129,10 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1120,6 +1129,10 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
//System.out.println("populateAllItem(): Supp_Sour:..." + suppSour + " Bom Code:..." + bomCode); //System.out.println("populateAllItem(): Supp_Sour:..." + suppSour + " Bom Code:..." + bomCode);
if( ( (suppSour != null) && (!suppSour.equals("P")) ) && (bomCode != null) ) if( ( (suppSour != null) && (!suppSour.equals("P")) ) && (bomCode != null) )
{ {
Set levelBom=new HashSet();
level=1;
levelBom.add(bomCode);
hmap.put(new Integer(level),levelBom);
//itemHashMap.put( (String)itemArr.get(ctr), new Integer(count) ); //itemHashMap.put( (String)itemArr.get(ctr), new Integer(count) );
System.out.println("itemArr.get(ctr)--"+itemArr.get(ctr)); System.out.println("itemArr.get(ctr)--"+itemArr.get(ctr));
itemList.add((String)itemArr.get(ctr)); itemList.add((String)itemArr.get(ctr));
...@@ -1131,7 +1144,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1131,7 +1144,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
//end //end
validBomItemCode = cyclicItem.itemCode; // 19-01-2007 manoharan validBomItemCode = cyclicItem.itemCode; // 19-01-2007 manoharan
cyclicCheck = new HashSet();
errString = bomExplode((String)siteMapEntry.getKey(), bomCode); errString = bomExplode((String)siteMapEntry.getKey(), bomCode);
itemHashMap.clear(); itemHashMap.clear();
if ( errString != null && errString.trim().length() > 0 ) if ( errString != null && errString.trim().length() > 0 )
...@@ -1139,11 +1152,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1139,11 +1152,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
System.out.println("Error While Calling method bomExplode(String, String):..."+errString); System.out.println("Error While Calling method bomExplode(String, String):..."+errString);
return errString; return errString;
} }
level=0;
hmap.clear();
} }
} }
itemList.clear(); itemList.clear();
} }
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -1155,8 +1170,289 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1155,8 +1170,289 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
return errString; return errString;
} }
private String bomExplode(String siteCode, String bomCode) throws ITMException
{
//PreparedStatement pstmt = null;
Statement pstmt = null;
PreparedStatement pstmtInner1 = null;
PreparedStatement pstmtInner2 = null;
ResultSet rsCount = null;
String sql = "", sqlInner1 = "", sqlInner2 = "";
ResultSet rs = null, rsInner1 = null, rsInner2 = null;
String innerSuppSour = null;
String innerBomCode = null;
PreparedStatement pstmtValidBom = null;
String sqlValidBom = "SELECT CONFIRMED, ACTIVE FROM BOM WHERE BOM_CODE = ?";
ResultSet rsValidBom = null;
boolean bomExists = false;
String logMsg = null;
String confirmedBom = null;
String activeBom = null;
try
{
// 19-01-2007 manoharan
// check whether the bom is valid should be confirmed and active
pstmtValidBom = conn.prepareStatement(sqlValidBom);
pstmtValidBom.setString(1,bomCode);
rsValidBom = pstmtValidBom.executeQuery();
bomExists = false;
while(rsValidBom.next())
{
bomExists = true;
confirmedBom = rsValidBom.getString(1);
activeBom = rsValidBom.getString(2);
}
rsValidBom.close();
pstmtValidBom.close();
//this.fwInvalidBom.write("Site Code Item Code Bom Code Message\r\n");
if(confirmedBom == null || confirmedBom.trim().length() == 0 || confirmedBom.equalsIgnoreCase("N") || activeBom == null || activeBom.trim().length() == 0 || activeBom.equalsIgnoreCase("N"))
{
siteCode = (siteCode.trim() + " ").substring(0,5);
validBomItemCode = (validBomItemCode.trim() + " ").substring(0,10);
bomCode = (bomCode.trim() + " ").substring(0,10);
logMsg = siteCode + " " + validBomItemCode + " " + bomCode + " ";
//========= ========== ========== ========
if(confirmedBom == null || confirmedBom.trim().length() == 0 || confirmedBom.equalsIgnoreCase("N"))
{
logMsg = logMsg + "BOM not confirmed";
}
if(activeBom == null || activeBom.trim().length() == 0 || activeBom.equalsIgnoreCase("N"))
{
logMsg = logMsg + " BOM not active";
}
invaldBomExists = true;
this.fwInvalidBom.write(logMsg + "\r\n");
}
// end 19-01-2007 manoharan
Set levelBom=new HashSet();
sql = "SELECT DISTINCT CASE WHEN ITEM.ITEM_CODE__PLAN IS NULL THEN ITEM.ITEM_CODE ELSE ITEM.ITEM_CODE__PLAN END "
+ " FROM BOMDET, ITEM "
+ " WHERE ITEM.ITEM_CODE = BOMDET.ITEM_CODE "
+" AND BOMDET.BOM_CODE = '"+bomCode+"'";
//pstmt = conn.prepareStatement(sql);
System.out.println(sql);
pstmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
//pstmt.setString(1,bomCode);
rs = pstmt.executeQuery(sql);
int ctr=0;
while(rs.next())
{
System.out.println("rs.getString(1)----"+rs.getString(1));
levelBom.add(rs.getString(1));
ctr=1;
}
level=level+ctr;
hmap.put(new Integer(level),levelBom);
System.out.println("level--"+level);
for(int i=1;i<level;i++)
{
System.out.println("Level Loop Entered---"+i+"---"+hmap.size());
levelBom=(HashSet) hmap.get(new Integer(i));
System.out.println("Level Loop Entered---"+i+"---"+levelBom.size());
Iterator it=levelBom.iterator();
while(it.hasNext())
{
System.out.println("SET Value---"+it.next().toString());
}
}
rs.beforeFirst();
while(rs.next())
{
//System.out.println("Item Code : "+rs.getString(1));
sqlInner1 = "SELECT COUNT(1) FROM ITEM WHERE ITEM_CODE = ?";
pstmtInner1 = conn.prepareStatement(sqlInner1);
pstmtInner1.setString(1,rs.getString(1));
rsCount = pstmtInner1.executeQuery();
//rsCount = stmt.executeQuery("SELECT COUNT(1) FROM ITEM WHERE ITEM_CODE = '" + rs.getString(1) + "'");
if(rsCount.next() && rsCount.getInt(1) > 0)
{
rsCount.close();
pstmtInner1.close();
// Add ItemCode in ItemCodeMap if it not present earlier
innerSuppSour = getSuppSour(siteCode,rs.getString(1));
innerBomCode = getBomCode(siteCode,rs.getString(1));
System.out.println("innerBomCode---------"+innerBomCode);
//System.out.println("bomExplode Function :: Site Code :: "+siteCode+"Bom Code ::"+bomCode+"Item Code ::"+rs.getString(1));
boolean isCyclic=false;
System.out.println("innerSuppSour-----"+innerSuppSour+"----innerBomCode----"+innerBomCode);
// if( ( (innerSuppSour == null) || (innerSuppSour.equals("P")) ) && (innerBomCode == null) )
// {
// System.out.println("level is decremented---"+level);
// level--;
// System.out.println("level is decremented---"+level);
// }
if( ( (innerSuppSour != null) && (!innerSuppSour.equals("P")) ) && (innerBomCode != null) )
{
for(int i=1;i<level;i++)
{
levelBom=(HashSet) hmap.get(new Integer(i));
System.out.println("levelBom.contains(rs.getString(1))--"+level+"---"+i+"---"+levelBom.size()+"--"+levelBom.contains(rs.getString(1)));
if(levelBom.size()>0 && levelBom.contains(rs.getString(1)))
{
System.out.println("levelBom.contains(rs.getString(1))--"+levelBom.contains(rs.getString(1)));
//Added by Jiten 07/11/06//
if(verifier != null && verifier.equalsIgnoreCase("Y"))
{
this.fw.write(cyclicItem.siteCode+" "+cyclicItem.bomCode+" "+cyclicItem.itemCode+" "+rs.getString(1)+"\r\n");
System.out.println("Cyclic Item Code is : " + rs.getString(1));
//return "";
}
else{
System.out.println("Cyclic Item Code is : " + rs.getString(1));
errString = itmDBAccessEJB.getErrorString("","VTMRPITEME","","",conn);
rs.close();
pstmt.close();
return errString;
}
isCyclic=true;
//End//
}
}
if(!itemCodeMap.containsKey(rs.getString(1)))
{
System.out.println("Placing value in itemCodeMap-------"+rs.getString(1));
itemCodeMap.put(rs.getString(1),new Integer(itemCodeMap.size() + 1));
}
/* else
{
itemHashMap.put(rs.getString(1),new Integer(itemHashMap.size()+1));
} */
}
/* if(itemCodeMap.containsKey(rs.getString(1)))
{}
else
{
itemCodeMap.put(rs.getString(1),new Integer(itemCodeMap.size() + 1));
} */
// if( ( (innerSuppSour != null) && (innerSuppSour.equals("P")) ) && (innerBomCode == null) )
// {
// System.out.println("level is decremented-----"+level);
// level--;
// if(level<=0)
// level=0;
// System.out.println("level is decremented-----"+level);
// }
if( ( (innerSuppSour != null) && (!innerSuppSour.equals("P")) ) && (innerBomCode != null) && (isCyclic==false) )
{
//System.out.println("Inner Exploding BOM for site : " + siteCode + " Item : " + rs.getString(1) + " BOM : " + innerBomCode);
validBomItemCode = rs.getString(1);
errString = bomExplode(siteCode, innerBomCode);
if ( errString != null && errString.trim().length() > 0 )
{
System.out.println("Error While Calling method bomExplode(String, String):..."+errString);
rs.close();
pstmt.close();
return errString;
}
}
}
else
{
rsCount.close();
sqlInner2 = "SELECT COUNT(1) FROM BOM WHERE BOM_CODE = ?";
pstmtInner2 = conn.prepareStatement(sqlInner2);
pstmtInner2.setString(1,rs.getString(1));
rsCount = pstmtInner2.executeQuery();
//rsCount = stmt.executeQuery("SELECT COUNT(1) FROM BOM WHERE BOM_CODE = '" + rs.getString(1) + "'");
if(rsCount.next() && rsCount.getInt(1) > 0)
{
rsCount.close();
pstmtInner2.close();
validBomItemCode = "BOMDET:" +rs.getString(1);
errString = bomExplode(siteCode, rs.getString(1));
if ( errString != null && errString.trim().length() > 0 )
{
System.out.println("Error While Calling method bomExplode(String, String):..."+errString);
rs.close();
pstmt.close();
return errString;
}
}
rsCount.close();
}
}
level--;
rs.close();
rs = null;//Added by Jiten 09/11/06 -Sun
}
catch(SQLException se)
{
System.out.println("SQLException :RunMRPPrcEJB :bomExplode(String siteCode, String MatPlan, String bomCode).." +se.getMessage());
se.printStackTrace();
errString = se.getMessage();
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception :RunMRPPrcEJB :bomExplode(String siteCode, String MatPlan, String bomCode):...." + e.getMessage() + ":");
this.errString = genericUtility.createErrorString(e);
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rsInner1 != null)
{
rsInner1.close();
rsInner1 = null;
}
if (pstmtInner1 != null)
{
pstmtInner1.close();
pstmtInner1 = null;
}
if (rsInner1 != null){ rsInner1 = null; }
if (pstmtInner2 != null)
{
pstmtInner2.close();
pstmtInner2 = null;
}
if (rsInner2 != null)
{
rsInner2.close();
rsInner2 = null;
}
this.fw.flush();//Added by Jiten 07/11/06
}
catch(Exception e)
{
System.out.println(e);
throw new ITMException(e);
}
}
return errString;//Moved here as finally does not complete - jiten -03/11/06
}
private String bomExplode(String siteCode, String bomCode) throws ITMException /* private String bomExplode(String siteCode, String bomCode) throws ITMException
{ {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
PreparedStatement pstmtInner1 = null; PreparedStatement pstmtInner1 = null;
...@@ -1170,7 +1466,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1170,7 +1466,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
PreparedStatement pstmtValidBom = null; PreparedStatement pstmtValidBom = null;
String sqlValidBom = "SELECT CONFIRMED, ACTIVE FROM BOM WHERE BOM_CODE = ?"; String sqlValidBom = "SELECT CONFIRMED, ACTIVE FROM BOM WHERE BOM_CODE = ?";
ResultSet rsValidBom = null; ResultSet rsValidBom = null;
boolean bomExists = false; boolean bomExists = false;
String logMsg = null; String logMsg = null;
String confirmedBom = null; String confirmedBom = null;
String activeBom = null; String activeBom = null;
...@@ -1178,7 +1474,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1178,7 +1474,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
ArrayList mainList = new ArrayList(); ArrayList mainList = new ArrayList();
String tempItemCode = ""; String tempItemCode = "";
int setLength=0; int setLength=0;
// end 29/09/10 manoharan // end 29/09/10 manoharan
try try
{ {
...@@ -1217,7 +1513,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1217,7 +1513,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
this.fwInvalidBom.write(logMsg + "\r\n"); this.fwInvalidBom.write(logMsg + "\r\n");
} }
// end 19-01-2007 manoharan // end 19-01-2007 manoharan
Set levelBom=new HashSet();
sql = "SELECT DISTINCT CASE WHEN ITEM.ITEM_CODE__PLAN IS NULL THEN ITEM.ITEM_CODE ELSE ITEM.ITEM_CODE__PLAN END " sql = "SELECT DISTINCT CASE WHEN ITEM.ITEM_CODE__PLAN IS NULL THEN ITEM.ITEM_CODE ELSE ITEM.ITEM_CODE__PLAN END "
+ " FROM BOMDET, ITEM " + " FROM BOMDET, ITEM "
+ " WHERE ITEM.ITEM_CODE = BOMDET.ITEM_CODE " + " WHERE ITEM.ITEM_CODE = BOMDET.ITEM_CODE "
...@@ -1225,26 +1521,50 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1225,26 +1521,50 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomCode); pstmt.setString(1,bomCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
int ctr=0;
while(rs.next()) while(rs.next())
{ {
System.out.println("Item Code : "+rs.getString(1)); System.out.println("Item Code : "+rs.getString(1));
mainList.add(rs.getString(1)); mainList.add(rs.getString(1));
cyclicCheck.add(rs.getString(1));
levelBom.add(rs.getString(1));
ctr=1;
} }
level=level+ctr;
hmap.put(new Integer(level),levelBom);
System.out.println("level--"+level);
rs.close(); rs.close();
pstmt.close(); pstmt.close();
// for(int i=1;i<level;i++)
// {
/*for (int mainCtr = 0; mainCtr < mainList.size() ; mainCtr++) // System.out.println("Level Loop Entered---"+i+"---"+hmap.size());
// levelBom=(HashSet) hmap.get(new Integer(i));
// System.out.println("Level Loop Entered---"+i+"---"+levelBom.size());
// Iterator it=levelBom.iterator();
// while(it.hasNext())
// {
// System.out.println("SET Value---"+it.next().toString());
// }
//
//
//
// }
for (int mainCtr = 0; mainCtr < mainList.size() ; mainCtr++)
{ {
System.out.println("(String) mainList.get(mainCtr)--"+(String) mainList.get(mainCtr)); System.out.println("(String) mainList.get(mainCtr)--"+(String) mainList.get(mainCtr));
}*/ }
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);
mainList.remove(mainCtr);
//System.out.println("Manoj tempItemCode--"+tempItemCode); //System.out.println("Manoj tempItemCode--"+tempItemCode);
setLength=itemList.size(); setLength=itemList.size();
//setLength = cyclicCheck.size();
Iterator itr=itemList.iterator(); Iterator itr=itemList.iterator();
while(itr.hasNext()) while(itr.hasNext())
{ {
...@@ -1256,11 +1576,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1256,11 +1576,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
itemList.add(tempItemCode); itemList.add(tempItemCode);
System.out.println("tempItemCode--"+tempItemCode+"--"+itemList.size()); System.out.println("tempItemCode--"+tempItemCode+"--"+itemList.size());
sqlInner1 = "SELECT COUNT(1) FROM ITEM WHERE ITEM_CODE = ?"; sqlInner1 = "SELECT COUNT(1) FROM ITEM WHERE ITEM_CODE = ?";
pstmtInner1 = conn.prepareStatement(sqlInner1); pstmtInner1 = conn.prepareStatement(sqlInner1);
pstmtInner1.setString(1,tempItemCode); pstmtInner1.setString(1,tempItemCode);
rsCount = pstmtInner1.executeQuery(); rsCount = pstmtInner1.executeQuery();
//rsCount = stmt.executeQuery("SELECT COUNT(1) FROM ITEM WHERE ITEM_CODE = '" + rs.getString(1) + "'"); //rsCount = stmt.executeQuery("SELECT COUNT(1) FROM ITEM WHERE ITEM_CODE = '" + rs.getString(1) + "'");
if(rsCount.next() && rsCount.getInt(1) > 0) if(rsCount.next() && rsCount.getInt(1) > 0)
{ {
...@@ -1273,14 +1593,21 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1273,14 +1593,21 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
innerBomCode = getBomCode(siteCode,tempItemCode); innerBomCode = getBomCode(siteCode,tempItemCode);
System.out.println("Inner Bom Code "+innerSuppSour+"--"+innerBomCode+"--"+tempItemCode); System.out.println("Inner Bom Code "+innerSuppSour+"--"+innerBomCode+"--"+tempItemCode);
//System.out.println("bomExplode Function :: Site Code :: "+siteCode+"Bom Code ::"+bomCode+"Item Code ::"+rs.getString(1)); //System.out.println("bomExplode Function :: Site Code :: "+siteCode+"Bom Code ::"+bomCode+"Item Code ::"+rs.getString(1));
if( ( (innerSuppSour != null) && (!innerSuppSour.equals("P")) ) && (innerBomCode != null) ) if( ( (innerSuppSour != null) && (!innerSuppSour.equals("P")) ) && (innerBomCode != null) )
{ {
System.out.println("itemList.size()--"+verifier+"--"+setLength+"--"+itemList.size()); System.out.println("itemList.size()--"+verifier+"--"+setLength+"--"+itemList.size());
//14.11.2010 Manoj //14.11.2010 Manoj
if(setLength==itemList.size())
{ for(int i=1;i<level;i++)
{
levelBom=(HashSet) hmap.get(new Integer(i));
System.out.println("levelBom.contains(tempItemCode)--"+level+"---"+i+"---"+levelBom.size()+"--"+levelBom.contains(tempItemCode));
if(levelBom.size()>0 && levelBom.contains(tempItemCode))
{
System.out.println("levelBom.contains(tempItemCode)--"+levelBom.contains(tempItemCode));
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());
...@@ -1299,8 +1626,9 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1299,8 +1626,9 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
return errString; return errString;
} }
} }
}
// end 14.11.2010 Manoj // end 14.11.2010 Manoj
} }
if(itemCodeMap.containsKey(tempItemCode)) if(itemCodeMap.containsKey(tempItemCode))
{ {
...@@ -1310,7 +1638,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1310,7 +1638,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
{ {
System.out.println("Test2"); System.out.println("Test2");
itemCodeMap.put(tempItemCode,new Integer(itemCodeMap.size() + 1)); itemCodeMap.put(tempItemCode,new Integer(itemCodeMap.size() + 1));
} }
if( ( (innerSuppSour != null) && (!innerSuppSour.equals("P")) ) && (innerBomCode != null) ) if( ( (innerSuppSour != null) && (!innerSuppSour.equals("P")) ) && (innerBomCode != null) )
{ {
...@@ -1369,7 +1697,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1369,7 +1697,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
} }
} }
if ( rs != null) if ( rs != null)
{ {
rs.close(); rs.close();
...@@ -1440,7 +1768,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1440,7 +1768,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
} }
return errString;//Moved here as finally does not complete - jiten -03/11/06 return errString;//Moved here as finally does not complete - jiten -03/11/06
} } */
// Populating Bom code // Populating Bom code
...@@ -1718,7 +2046,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1718,7 +2046,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
siteCode = (String)siteMapEntry.getKey(); siteCode = (String)siteMapEntry.getKey();
itemCode = (String)itemMapEntry.getKey(); itemCode = (String)itemMapEntry.getKey();
// 01/04/11 in case of made to order only made to order item will be planned // 01/04/11 in case of made to order only made to order item will be planned
/*if ("Y".equals(madeToOrder)) /*if ("Y".equals(madeToOrder))
{ {
...@@ -1832,7 +2160,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1832,7 +2160,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
PreparedStatement pstmtInner = null; PreparedStatement pstmtInner = null;
itemCode = adpElement.getItemCode(); itemCode = adpElement.getItemCode();
siteCode = adpElement.getSiteCode(); siteCode = adpElement.getSiteCode();
try try
...@@ -1907,7 +2235,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -1907,7 +2235,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
// 31, 32 // 31, 32
+" CASE WHEN A.MFG_TYPE IS NULL THEN 'MRP' ELSE A.MFG_TYPE END, A.ROUTE_CODE, " +" CASE WHEN A.MFG_TYPE IS NULL THEN 'MRP' ELSE A.MFG_TYPE END, A.ROUTE_CODE, "
// 33, 34 // 33, 34
+" case when a.mfg_lead_basis is null then 'F' else a.mfg_lead_basis end, case when a.batch_size_lead is null then 0 else a.batch_size_lead end " +" case when a.mfg_lead_basis is null then 'F' else a.mfg_lead_basis end, case when a.batch_size_lead is null then 0 else a.batch_size_lead end "
+" FROM SITEITEM A, ITEM B, ITEMSER C " +" FROM SITEITEM A, ITEM B, ITEMSER C "
+" WHERE A.ITEM_CODE = B.ITEM_CODE " +" WHERE A.ITEM_CODE = B.ITEM_CODE "
+" AND B.ITEM_SER = C.ITEM_SER " +" AND B.ITEM_SER = C.ITEM_SER "
...@@ -2016,7 +2344,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2016,7 +2344,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
String routeCode = rs.getString(32); String routeCode = rs.getString(32);
if (routeCode != null && routeCode.trim().length() > 0 ) if (routeCode != null && routeCode.trim().length() > 0 )
{ {
adpElement.setRouteCode(routeCode); adpElement.setRouteCode(routeCode);
} }
// 22/06/10 manoharan // 22/06/10 manoharan
...@@ -2382,7 +2710,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2382,7 +2710,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
for(int ctr=0;ctr<tempList.size();ctr++) for(int ctr=0;ctr<tempList.size();ctr++)
{ {
ADPElement adpElement = (ADPElement)tempList.get(ctr); ADPElement adpElement = (ADPElement)tempList.get(ctr);
//adpElement = //adpElement =
populateMTODemandSupply(adpElement.getSiteCode(),adpElement.getItemCode(),adpElement); populateMTODemandSupply(adpElement.getSiteCode(),adpElement.getItemCode(),adpElement);
} }
tempList.clear(); tempList.clear();
...@@ -2395,7 +2723,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2395,7 +2723,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
adpElement = populateDemandSupply(adpElement); adpElement = populateDemandSupply(adpElement);
adpeList.set(ctr,adpElement); adpeList.set(ctr,adpElement);
} }
}catch(Exception e){ }catch(Exception e){
throw(e); throw(e);
} }
...@@ -2418,14 +2746,14 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2418,14 +2746,14 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String saleOrder = null; String saleOrder = null;
String lineNo = 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 // 01/04/11 manoharan if made to order is selected and item is of made to order
// don't process here // don't process here
if ("0".equals(madeToOrder) && "O".equals(adpElement.getMfgType())) if ("0".equals(madeToOrder) && "O".equals(adpElement.getMfgType()))
{ {
return adpElement; return adpElement;
...@@ -2515,7 +2843,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2515,7 +2843,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
//rs = stmt.executeQuery(adpQuery); //rs = stmt.executeQuery(adpQuery);
pstmt = conn.prepareStatement(adpQuery); pstmt = conn.prepareStatement(adpQuery);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
//System.out.println("Query Executed for item : " + itemCode); //System.out.println("Query Executed for item : " + itemCode);
String rsItemCode = "",adpItemcode = ""; String rsItemCode = "",adpItemcode = "";
while(rs.next()) while(rs.next())
...@@ -2542,7 +2870,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2542,7 +2870,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
// 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
{ {
...@@ -2564,13 +2892,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2564,13 +2892,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
if(adpElement.getSuppSour().equals("M")) if(adpElement.getSuppSour().equals("M"))
//System.out.println("adpQuery ::"+adpQuery); //System.out.println("adpQuery ::"+adpQuery);
System.out.println("Site Code : "+siteCode+" Item Code : "+itemCode+" Due Date : "+dueDate+" Demand : "+demand+" supply : " + supply); System.out.println("Site Code : "+siteCode+" Item Code : "+itemCode+" Due Date : "+dueDate+" Demand : "+demand+" supply : " + supply);
} }
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
catch(SQLException se) catch(SQLException se)
{ {
...@@ -2598,7 +2926,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2598,7 +2926,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
//ResultSetMetaData rsmd = rs.getMetaData(); //ResultSetMetaData rsmd = rs.getMetaData();
//int noOfColumns = rsmd.getColumnCount(); //int noOfColumns = rsmd.getColumnCount();
//return commented & changed by sabyasachi 25-03-2011 //return commented & changed by sabyasachi 25-03-2011
//return adpElement; //Moved here from finaly - jiten - 03/11/06 //return adpElement; //Moved here from finaly - jiten - 03/11/06
return adpElement; return adpElement;
...@@ -2623,7 +2951,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2623,7 +2951,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String saleOrder = null,rsItemCode = ""; String saleOrder = null,rsItemCode = "";
String lineNo = null; String lineNo = null;
try try
{ {
...@@ -2634,7 +2962,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2634,7 +2962,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
{ {
return; return;
} }
//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;
...@@ -2705,8 +3033,8 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2705,8 +3033,8 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
fout.close(); fout.close();
pstmt = conn.prepareStatement(adpQuery); pstmt = conn.prepareStatement(adpQuery);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while(rs.next()) while(rs.next())
{ {
saleOrder = rs.getString(1); saleOrder = rs.getString(1);
...@@ -2721,31 +3049,31 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2721,31 +3049,31 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
{ {
dueDate = dateFrom; dueDate = dateFrom;
} }
/*if(rsItemCode != null && rsItemCode.trim().equalsIgnoreCase(itemCode.trim()) && (adpElement.getSaleOrder().equals(saleOrder)) && (adpElement.getLineNo().equals(lineNo))) /*if(rsItemCode != null && rsItemCode.trim().equalsIgnoreCase(itemCode.trim()) && (adpElement.getSaleOrder().equals(saleOrder)) && (adpElement.getLineNo().equals(lineNo)))
{ {
adpElement.setDemand(dueDate, demand, saleOrder, lineNo); adpElement.setDemand(dueDate, demand, saleOrder, lineNo);
adpElement.setSupply(dueDate, supply); adpElement.setSupply(dueDate, supply);
adpElement.setStockQty(dueDate, stockQty); adpElement.setStockQty(dueDate, stockQty);
adpElement.setOthSupply(dueDate, othSupply); adpElement.setOthSupply(dueDate, othSupply);
} }
else else
{ */ { */
// 01/04/11 find same item without sales order, if exists remove from array // 01/04/11 find same item without sales order, if exists remove from array
/* /*
int ctr = indexOfADPElement(siteCode, rsItemCode," "," "); int ctr = indexOfADPElement(siteCode, rsItemCode," "," ");
// //
if(ctr > -1) if(ctr > -1)
{ {
adpeList.remove(ctr); adpeList.remove(ctr);
} }
// end 01/04/11*/ // end 01/04/11*/
int ctr = indexOfADPElement(siteCode, rsItemCode,saleOrder,lineNo); int ctr = indexOfADPElement(siteCode, rsItemCode,saleOrder,lineNo);
System.out.println("01/04/11 BHU saleOrder [" + saleOrder + "] lineNo [" + lineNo + "] ctr [" + ctr + "]"); System.out.println("01/04/11 BHU saleOrder [" + saleOrder + "] lineNo [" + lineNo + "] ctr [" + ctr + "]");
if(ctr > -1) if(ctr > -1)
{ {
ADPElement tempADPElement = (ADPElement)adpeList.get(ctr); ADPElement tempADPElement = (ADPElement)adpeList.get(ctr);
tempADPElement.setDemand(dueDate, demand, saleOrder, lineNo); tempADPElement.setDemand(dueDate, demand, saleOrder, lineNo);
tempADPElement.setSupply(dueDate, supply); tempADPElement.setSupply(dueDate, supply);
adpeList.set(ctr,tempADPElement); adpeList.set(ctr,tempADPElement);
...@@ -2763,7 +3091,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2763,7 +3091,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
adpeList.add(newADPElement); adpeList.add(newADPElement);
System.out.println("01/04/11 BHU not found adding saleOrder [" + saleOrder + "] lineNo [" + lineNo + "] ctr [" + ctr + "]"); System.out.println("01/04/11 BHU not found adding saleOrder [" + saleOrder + "] lineNo [" + lineNo + "] ctr [" + ctr + "]");
} }
//} //}
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -2797,7 +3125,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2797,7 +3125,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
//ResultSetMetaData rsmd = rs.getMetaData(); //ResultSetMetaData rsmd = rs.getMetaData();
//int noOfColumns = rsmd.getColumnCount(); //int noOfColumns = rsmd.getColumnCount();
//return commented & changed by sabyasachi 25-03-2011 //return commented & changed by sabyasachi 25-03-2011
//return adpElement; //Moved here from finaly - jiten - 03/11/06 //return adpElement; //Moved here from finaly - jiten - 03/11/06
//return adpElement; //return adpElement;
...@@ -2985,14 +3313,14 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -2985,14 +3313,14 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
// end 10-04-2006 manoharan // end 10-04-2006 manoharan
if (suppSour != null && suppSour.trim().equals("M") && matPlan.trim().equals("Y")) if (suppSour != null && suppSour.trim().equals("M") && matPlan.trim().equals("Y"))
{ {
// 22/06/10 manoharan to calculate due_date based on batch size // 22/06/10 manoharan to calculate due_date based on batch size
// if configured as lead time per batch // if configured as lead time per batch
if (mfgLeadBasis == null) if (mfgLeadBasis == null)
{ {
mfgLeadBasis = "F"; mfgLeadBasis = "F";
} }
if ("B".equals(mfgLeadBasis) && quantity > batchSizeLead ) if ("B".equals(mfgLeadBasis) && quantity > batchSizeLead )
{ {
System.out.println("manohar mfgLeadTime before ["+mfgLeadTime + "]"); System.out.println("manohar mfgLeadTime before ["+mfgLeadTime + "]");
...@@ -3014,13 +3342,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -3014,13 +3342,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
xmlString.append("</Detail>"); xmlString.append("</Detail>");
xmlString.append("</Root>"); xmlString.append("</Root>");
//retXMLStr = explodeBomObj.explodeBom(xmlString.toString(), conn).toString();//Commented by Jiiten as per Kandarp Sir 13/11/06 - //retXMLStr = explodeBomObj.explodeBom(xmlString.toString(), conn).toString();//Commented by Jiiten as per Kandarp Sir 13/11/06 -
retXMLStr = explodeBomObj.explodeBom(xmlString.toString()).toString(); // Added by Jiten 13/11/06 - retXMLStr = explodeBomObj.explodeBom(xmlString.toString()).toString(); // Added by Jiten 13/11/06 -
if (itemCode.trim().equals("BF21135")) if (itemCode.trim().equals("BF21135"))
{ {
System.out.println("14012009 itemCode [" + itemCode + "] explodeBomObj retXMLStr [" + retXMLStr + "]"); System.out.println("14012009 itemCode [" + itemCode + "] explodeBomObj retXMLStr [" + retXMLStr + "]");
} }
if (xmlString == null || xmlString.toString().trim().length() == 0) if (xmlString == null || xmlString.toString().trim().length() == 0)
{ {
errString = "XML String is Either null"; errString = "XML String is Either null";
...@@ -3414,7 +3742,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -3414,7 +3742,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
ResultSet rs = null; ResultSet rs = null;
String sql = null; String sql = null;
ADPElement adpElement = null; ADPElement adpElement = null;
try try
{ {
System.out.println("In updateDemand xmlString [" + xmlString + "]"); System.out.println("In updateDemand xmlString [" + xmlString + "]");
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
...@@ -3486,7 +3814,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -3486,7 +3814,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
newADPElement.setLineNo(lineNo); newADPElement.setLineNo(lineNo);
newADPElement.setDemand(dueDate, quantity, saleOrder, lineNo); newADPElement.setDemand(dueDate, quantity, saleOrder, lineNo);
adpeList.add(newADPElement); 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 );
} }
...@@ -3518,10 +3846,12 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -3518,10 +3846,12 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
{ {
lineNo = " "; lineNo = " ";
} }
System.out.println("adpeList.size()------"+adpeList.size());
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)) System.out.println("adpElement------"+adpElement.getSiteCode()+"----"+adpElement.getItemCode()+"----"+adpElement.getSaleOrder()+"----"+adpElement.getLineNo());
if ( (adpElement.getSiteCode().equals(siteCode)) && (adpElement.getItemCode().equals(itemCode))
&& (adpElement.getSaleOrder().equals(saleOrder)) && (adpElement.getLineNo().equals(lineNo))) && (adpElement.getSaleOrder().equals(saleOrder)) && (adpElement.getLineNo().equals(lineNo)))
{ {
retVal = ctr; retVal = ctr;
...@@ -3915,6 +4245,10 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -3915,6 +4245,10 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
horizonDate = new java.sql.Timestamp(System.currentTimeMillis()); horizonDate = new java.sql.Timestamp(System.currentTimeMillis());
horizonDate.setTime( ((java.util.Date)calen.getTime()).getTime()); horizonDate.setTime( ((java.util.Date)calen.getTime()).getTime());
} }
else // 02/05/11 manoharan
{
horizonDate = dueDate;
}
reqQty = timeMrp.getPlanSupply(); //runningDemand - runningSupply - runningPlanSupply; reqQty = timeMrp.getPlanSupply(); //runningDemand - runningSupply - runningPlanSupply;
if (reqQty > 0) if (reqQty > 0)
...@@ -4327,7 +4661,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -4327,7 +4661,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
mpsOrder.lineNo = adpElement.getLineNo(); mpsOrder.lineNo = adpElement.getLineNo();
mpsOrder.mfgType = adpElement.getMfgType(); mpsOrder.mfgType = adpElement.getMfgType();
// end 01/04/11 manoharan // end 01/04/11 manoharan
mpsList.add(mpsOrder); mpsList.add(mpsOrder);
} }
//Jiten - End 03/11/06 //Jiten - End 03/11/06
...@@ -4555,7 +4889,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -4555,7 +4889,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
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() throws Exception private String InsertPlanDemand() throws Exception
{ {
String errString = ""; String errString = "";
//System.out.println("In Insert Plan Demand()"); //System.out.println("In Insert Plan Demand()");
...@@ -4663,7 +4997,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -4663,7 +4997,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
private String decFormat(double num) private String decFormat(double num)
{ {
NumberFormat nf = new DecimalFormat("##############0.000"); NumberFormat nf = new DecimalFormat("##############0.000");
nf.setMaximumFractionDigits(3); nf.setMaximumFractionDigits(3);
...@@ -4831,7 +5165,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -4831,7 +5165,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
pstmtKeyStr.close(); pstmtKeyStr.close();
pstmtKeyStr = null; pstmtKeyStr = 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());
...@@ -4935,7 +5269,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -4935,7 +5269,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
//added by sabyasachi 30-03-11 //added by sabyasachi 30-03-11
saleOrder = mpsOrder.saleOrder; saleOrder = mpsOrder.saleOrder;
lineNo = mpsOrder.lineNo; lineNo = mpsOrder.lineNo;
//added by sabyasachi ends 30-03-11 //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>";
...@@ -5569,7 +5903,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -5569,7 +5903,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
runningDemand = timeMrp.getRunningDemand(); runningDemand = timeMrp.getRunningDemand();
runningSupply = timeMrp.getRunningSupply(); runningSupply = timeMrp.getRunningSupply();
runningPlanSupply = timeMrp.getRunningPlanSupply(); runningPlanSupply = timeMrp.getRunningPlanSupply();
// 01/04/11 // 01/04/11
if (runningPlanSupply <= 0 && demand <= 0 && supply <= 0 && planSupply <= 0 && runningDemand <= 0 && runningSupply <= 0) if (runningPlanSupply <= 0 && demand <= 0 && supply <= 0 && planSupply <= 0 && runningDemand <= 0 && runningSupply <= 0)
{ {
continue; continue;
...@@ -5661,7 +5995,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -5661,7 +5995,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
pstmtPlanHdr.setString(34,saleOrder); pstmtPlanHdr.setString(34,saleOrder);
pstmtPlanHdr.setString(35,lineNo); pstmtPlanHdr.setString(35,lineNo);
hdrSeq++; hdrSeq++;
pstmtPlanHdr.setInt(36,hdrSeq); pstmtPlanHdr.setInt(36,hdrSeq);
pstmtPlanHdr.addBatch(); pstmtPlanHdr.addBatch();
} }
...@@ -5921,7 +6255,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -5921,7 +6255,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
double reqVal = Double.parseDouble(strValue); double reqVal = Double.parseDouble(strValue);
return reqVal; return reqVal;
} }
private void Write2XSL() throws ITMException private void Write2XSL() throws ITMException
{ {
String errCode = "", date; String errCode = "", date;
...@@ -5970,11 +6304,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -5970,11 +6304,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
HSSFRow row = null; HSSFRow row = null;
HSSFCellStyle cellStyle = null; HSSFCellStyle cellStyle = null;
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
final String[] titles = { final String[] titles = {
"Site Code", "Item Code", "Item Description", "Supply Source", "Demand", "Supply", "Site Code", "Item Code", "Item Description", "Supply Source", "Demand", "Supply",
"Stock Qty", "Other Supply", "Due Date", "Stock Qty", "Other Supply", "Due Date",
"Plan Supply", "Running Demand", "Running Supply", "Running Plan Supply", "Independent Demand", "Plan Supply", "Running Demand", "Running Supply", "Running Plan Supply", "Independent Demand",
"Bom Code","Order Opt","Batch Qty Type","Unit","Min Order Qty","Integral Qty", "Bom Code","Order Opt","Batch Qty Type","Unit","Min Order Qty","Integral Qty",
"Max Qty","Min Qty","Reorder Qty","Yield Perc", "Min Plan %","Batch Qty", "Max Qty","Min Qty","Reorder Qty","Yield Perc", "Min Plan %","Batch Qty",
"Purc Rate", "Pur Lead Time","QC Lead Time", "MFG Lead Time" "Purc Rate", "Pur Lead Time","QC Lead Time", "MFG Lead Time"
...@@ -5982,7 +6316,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -5982,7 +6316,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
// 30 // 30
try try
{ {
HSSFWorkbook wb; HSSFWorkbook wb;
wb = new HSSFWorkbook(); wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("MRPRun"); HSSFSheet sheet = wb.createSheet("MRPRun");
...@@ -6000,32 +6334,32 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6000,32 +6334,32 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(HSSFColor.BLUE.index); font.setColor(HSSFColor.BLUE.index);
style.setFont(font); style.setFont(font);
HSSFCell titleCell = titleRow.createCell((short) 0); HSSFCell titleCell = titleRow.createCell((short) 0);
titleCell.setCellValue(new HSSFRichTextString("MRP - Material Requirements")); titleCell.setCellValue(new HSSFRichTextString("MRP - Material Requirements"));
titleCell.setCellStyle(style); titleCell.setCellStyle(style);
sheet.autoSizeColumn((short) 1); sheet.autoSizeColumn((short) 1);
//titleCell.setCellStyle(styles.get("title")); //titleCell.setCellStyle(styles.get("title"));
HSSFRow headerRow = sheet.createRow(1); HSSFRow headerRow = sheet.createRow(1);
headerRow.setHeightInPoints(40); headerRow.setHeightInPoints(40);
HSSFCell headerCell; HSSFCell headerCell;
for (int cellCtr = 0; cellCtr < titles.length; cellCtr++) for (int cellCtr = 0; cellCtr < titles.length; cellCtr++)
{ {
headerCell = headerRow.createCell((short)cellCtr); headerCell = headerRow.createCell((short)cellCtr);
headerCell.setCellValue(titles[cellCtr]); headerCell.setCellValue(titles[cellCtr]);
} }
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
int insertRow = 2; int insertRow = 2;
for(int adpeCount=0; adpeCount<adpeList.size(); adpeCount++) for(int adpeCount=0; adpeCount<adpeList.size(); adpeCount++)
{ {
flag = true; flag = true;
adpElement = (ADPElement)adpeList.get(adpeCount); adpElement = (ADPElement)adpeList.get(adpeCount);
...@@ -6070,11 +6404,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6070,11 +6404,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
// end 12/04/10 manoharan MF90BHU001 // end 12/04/10 manoharan MF90BHU001
insertRow++; insertRow++;
row = sheet.createRow(insertRow); row = sheet.createRow(insertRow);
for (int j = 0; j < titles.length; j++) for (int j = 0; j < titles.length; j++)
{ {
cell = row.createCell((short)j); cell = row.createCell((short)j);
} }
if(flag) if(flag)
{ {
row.getCell(0).setCellValue(siteCode); row.getCell(0).setCellValue(siteCode);
...@@ -6082,23 +6416,23 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6082,23 +6416,23 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
row.getCell(2).setCellValue(desc); row.getCell(2).setCellValue(desc);
row.getCell(3).setCellValue(suppSour); row.getCell(3).setCellValue(suppSour);
} }
row.getCell(4).setCellValue(demand); row.getCell(4).setCellValue(demand);
row.getCell(5).setCellValue(supply); row.getCell(5).setCellValue(supply);
row.getCell(6).setCellValue(stockQty); row.getCell(6).setCellValue(stockQty);
row.getCell(7).setCellValue(othSupply); row.getCell(7).setCellValue(othSupply);
cell = row.getCell(8); cell = row.getCell(8);
cell.setCellValue(HSSFDateUtil.getExcelDate(dueDate)); cell.setCellValue(HSSFDateUtil.getExcelDate(dueDate));
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy")); cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));
cell.setCellStyle(cellStyle); cell.setCellStyle(cellStyle);
row.getCell(9).setCellValue(planSupply); row.getCell(9).setCellValue(planSupply);
row.getCell(10).setCellValue(runningDemand); row.getCell(10).setCellValue(runningDemand);
row.getCell(11).setCellValue(runningSupply); row.getCell(11).setCellValue(runningSupply);
row.getCell(12).setCellValue(runningPlanSupply); row.getCell(12).setCellValue(runningPlanSupply);
row.getCell(13).setCellValue(independentDemand); row.getCell(13).setCellValue(independentDemand);
if(flag) if(flag)
{ {
row.getCell(14).setCellValue(bomCode); row.getCell(14).setCellValue(bomCode);
...@@ -6118,7 +6452,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6118,7 +6452,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
row.getCell(28).setCellValue(qcLeadTime); row.getCell(28).setCellValue(qcLeadTime);
row.getCell(29).setCellValue(mfgLeadTime); row.getCell(29).setCellValue(mfgLeadTime);
} }
//flag = false; // 25/02/11 manoharan commented as BTPL want the same to be repeated in the excel file //flag = false; // 25/02/11 manoharan commented as BTPL want the same to be repeated in the excel file
} }
} }
...@@ -6127,7 +6461,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6127,7 +6461,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
DocumentBuilder db = dbf.newDocumentBuilder(); DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse( "/IBASEHOME/ibase.xml" ); Document dom = db.parse( "/IBASEHOME/ibase.xml" );
String mrpOutputLocation = ""; String mrpOutputLocation = "";
try try
{ {
mrpOutputLocation = dom.getElementsByTagName( "mrp_output_location" ).item(0).getFirstChild().getNodeValue(); mrpOutputLocation = dom.getElementsByTagName( "mrp_output_location" ).item(0).getFirstChild().getNodeValue();
} }
...@@ -6138,13 +6472,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6138,13 +6472,13 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
throw new ITMException(e); throw new ITMException(e);
} }
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
String curTime = ( new java.text.DecimalFormat( "0000" ) ).format( cal.get(Calendar.YEAR) ) String curTime = ( new java.text.DecimalFormat( "0000" ) ).format( cal.get(Calendar.YEAR) )
+ ( new java.text.DecimalFormat( "00" ) ).format( cal.get(Calendar.MONTH) + 1 ) + ( new java.text.DecimalFormat( "00" ) ).format( cal.get(Calendar.MONTH) + 1 )
+ ( new java.text.DecimalFormat( "00" ) ).format( cal.get(Calendar.DAY_OF_MONTH) ) + ( new java.text.DecimalFormat( "00" ) ).format( cal.get(Calendar.DAY_OF_MONTH) )
+ ( new java.text.DecimalFormat( "00" ) ).format( cal.get(Calendar.HOUR_OF_DAY) ) + ( new java.text.DecimalFormat( "00" ) ).format( cal.get(Calendar.HOUR_OF_DAY) )
+ ( new java.text.DecimalFormat( "00" ) ).format( cal.get(Calendar.MINUTE) ) ; + ( new java.text.DecimalFormat( "00" ) ).format( cal.get(Calendar.MINUTE) ) ;
String fileName = mrpOutputLocation + File.separator+"MRPRun_" + curTime + ".xls"; String fileName = mrpOutputLocation + File.separator+"MRPRun_" + curTime + ".xls";
dom = null; dom = null;
db = null; db = null;
...@@ -6155,7 +6489,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6155,7 +6489,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
if( !outputDir.exists() ) if( !outputDir.exists() )
{ {
String subDirName = ""; String subDirName = "";
if (mrpOutputLocation.indexOf("\\") > 0) if (mrpOutputLocation.indexOf("\\") > 0)
{ {
String subDirs[] = mrpOutputLocation.split( "\\\\" ); String subDirs[] = mrpOutputLocation.split( "\\\\" );
...@@ -6163,7 +6497,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6163,7 +6497,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
System.out.println("windows stype path"); System.out.println("windows stype path");
for( int idx = 1; idx < subDirs.length; idx++ ) for( int idx = 1; idx < subDirs.length; idx++ )
{ {
subDirName = subDirName + File.separator + subDirs[ idx ]; subDirName = subDirName + File.separator + subDirs[ idx ];
System.out.println("subDirs[ idx ] [" + subDirs[ idx ] + "]"); System.out.println("subDirs[ idx ] [" + subDirs[ idx ] + "]");
} }
} }
...@@ -6177,7 +6511,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6177,7 +6511,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
subDirName = subDirName + File.separator + subDirs[ idx ]; subDirName = subDirName + File.separator + subDirs[ idx ];
System.out.println("subDirs[ idx ] [" + subDirs[ idx ] + "]"); System.out.println("subDirs[ idx ] [" + subDirs[ idx ] + "]");
} }
} }
subDirFile = new File( subDirName ); subDirFile = new File( subDirName );
System.out.println("File path [" + subDirName + "]"); System.out.println("File path [" + subDirName + "]");
...@@ -6188,7 +6522,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6188,7 +6522,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
} }
} }
// Write the output to a file // Write the output to a file
//if(wb instanceof XSSFWorkbook) file += "x"; //if(wb instanceof XSSFWorkbook) file += "x";
FileOutputStream out = new FileOutputStream(fileName); FileOutputStream out = new FileOutputStream(fileName);
...@@ -6221,7 +6555,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6221,7 +6555,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
catch(Exception e) catch(Exception e)
{} {}
} }
} }
/** /**
...@@ -6293,7 +6627,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem ...@@ -6293,7 +6627,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal,RunMRPPrcRem
double reqVal = Double.parseDouble(strValue); double reqVal = Double.parseDouble(strValue);
return reqVal; return reqVal;
}*/ }*/
} }
......
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