Commit 3f3f6bd2 authored by cpatil's avatar cpatil

modify n prepare for MRP ( available to promise )


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94150 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 96b3e9a1
package ibase.webitm.ejb.mfg;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.*;
import ibase.webitm.utility.GenericUtility;
import ibase.utility.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import javax.naming.InitialContext;
import ibase.webitm.ejb.mfg.MRPWizardEJB;
public class MRPWizardBean
{
private ibase.utility.UserInfoBean userInfo = null;
private HttpSession sessionCtx = null;
private String objName = "";
private String user_lang ="en";
private String user_country = "US";
public MRPWizardBean( String objName, HttpSession sessionCtx ) throws ITMException
{
try
{
this.objName = objName;
this.sessionCtx = sessionCtx;
this.userInfo = ( ibase.utility.UserInfoBean ) this.sessionCtx.getAttribute("USER_INFO");
}
catch (Exception e)
{
throw new ITMException(e);
}
}
public MRPWizardBean() throws ITMException
{
}
private String getXSLFileName( String xslFileName )throws ITMException
{
String retFileName = null;
try
{
String defaultPath = null;
if( CommonConstants.APPLICATION_CONTEXT != null )
{
defaultPath = CommonConstants.APPLICATION_CONTEXT + CommonConstants.ITM_CONTEXT + File.separator;
}
else
{
defaultPath = ".." + File.separator + "webapps" + File.separator + "ibase" + File.separator + CommonConstants.ITM_CONTEXT + File.separator;
}
File xslPath = new File( defaultPath + File.separator + "xsl" + File.separator + CommonConstants.THEME + File.separator + "WIZARD");
if ( !xslPath.exists() )
{
xslPath.mkdir();
}
System.out.println( " xslPath [" + xslPath +"] xslFileName ["+xslFileName +"]");
File xslFile = new File(xslPath , xslFileName);
if( xslFile.exists() )
{
retFileName = xslFile.getAbsolutePath();
}
else
{
throw new ITMException( new Exception( retFileName + " Wizard XSL file Not Found") );
}
}
catch (Exception e)
{
throw new ITMException(e);
}
return retFileName;
}
private String getXMLFile( String xslFileName )throws ITMException
{
String retFileName = null;
try
{
String defaultPath = null;
if( CommonConstants.APPLICATION_CONTEXT != null )
{
defaultPath = CommonConstants.APPLICATION_CONTEXT + CommonConstants.ITM_CONTEXT + File.separator;
}
else
{
defaultPath = ".." + File.separator + "webapps" + File.separator + "ibase" + File.separator + CommonConstants.ITM_CONTEXT + File.separator;
}
File xslPath = new File( defaultPath + File.separator + "xsl" + File.separator + CommonConstants.THEME + File.separator + "WIZARD");
if ( !xslPath.exists() )
{
xslPath.mkdir();
}
System.out.println( " xslPath [" + xslPath +"] xslFileName ["+xslFileName +"]");
File xslFile = new File(xslPath , xslFileName);
if( xslFile.exists() )
{
retFileName = xslFile.getAbsolutePath();
}
else
{
throw new ITMException( new Exception( retFileName + " Wizard XSL file Not Found") );
}
}
catch (Exception e)
{
throw new ITMException(e);
}
return retFileName;
}
public String checkNull(String input)
{
if (input == null || "null".equalsIgnoreCase(input))
{
input = "";
}
return input.trim();
}
}
package ibase.webitm.ejb.mfg;
import java.util.*;
import java.sql.*;
import org.w3c.dom.*;
import java.text.SimpleDateFormat;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.InvAllocTrace;
import ibase.webitm.ejb.dis.StockAllocationPrc;
import ibase.webitm.ejb.dis.StockAllocationPrc.*;
import ibase.webitm.ejb.dis.StockUpdate;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator;
public class MrpWizPrsSaveBean
{
public String preSaveForm(String xmlString1 )throws ITMException
{
Document dom = null;
System.out.println("@@@@@@@@@---------MrpWizPrsSaveBean EJB called...");
try
{
System.out.println("@@@@@@@xmlString1["+xmlString1+"]@@@@@@@");
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
executepreSaveForm(dom);
}
}
catch(Exception e)
{
System.out.println("Exception :MrpWizPrsSaveBean ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return "";
}
private String executepreSaveForm(Document dom )throws ITMException
{
PreparedStatement pstmt = null;
String sql = "", itemCode = "", effDate = "", itemSer = "";
int updCnt = 0;
//java.util.Date effDate1 = null, preDate = null;
GenericUtility genericUtility = GenericUtility.getInstance();
NodeList hdrDom = null;
//Node currDetail = null;
String saleOrder="",lineNo="", siteCode="", lotNo="", locCode="", lotSl="", tranSer="", runningSupplyStr="", qtyReqdStr="",allocQtyStr="";
double runningSupply=0,qtyReqd=0;
String tranId="",refId="",refLineNo="",unit="",errString="";
double quantity=0,qtyAllocated=0,totAllocQty=0,allocQty=0;
int cnt=0;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String supplyStr="",availableSupplyStr="";
InvAllocTrace invallocTrace = new InvAllocTrace();
StockAllocationPrc stockAllocationPrc = new StockAllocationPrc() ;
try
{
conn = connDriver.getConnectDB("DriverITM");
NodeList hdrDommList = dom.getElementsByTagName("Detail4");
System.out.println("len===["+hdrDommList.getLength()+"]");
for (int dtlCtr = 0; dtlCtr < hdrDommList.getLength(); dtlCtr++)
{
Node detailListNode = hdrDommList.item(dtlCtr);
NodeList detail4List= detailListNode.getChildNodes();
System.out.println("@@@@@@@@@node name[" + detailListNode.getNodeName()+"]");
if("Detail4".equalsIgnoreCase(detailListNode.getNodeName()))
{
System.out.println("@@@@inside detail4----------------");
for (int cntr = 0; cntr < detail4List.getLength(); cntr++)
{
Node detail4Node = detail4List.item(cntr);
NodeList detail4NodeList = detail4Node.getChildNodes();
System.out.println("@@@@@@@@@refrenceNode ["+detail4NodeList.getLength()+"]node name[" + detail4Node.getNodeName()+"]");
if("sale_order".equalsIgnoreCase( detail4Node.getNodeName()))
{
saleOrder = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("line_no".equalsIgnoreCase( detail4Node.getNodeName()))
{
lineNo = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("site_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
siteCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("item_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
itemCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("lot_no".equalsIgnoreCase( detail4Node.getNodeName()))
{
lotNo = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("lot_sl".equalsIgnoreCase( detail4Node.getNodeName()))
{
lotSl = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("loc_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
locCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("tran_ser".equalsIgnoreCase( detail4Node.getNodeName()))
{
tranSer = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("running_supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
runningSupplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("qty_reqd".equalsIgnoreCase( detail4Node.getNodeName()))
{
qtyReqdStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("alloc_qty".equalsIgnoreCase( detail4Node.getNodeName()))
{
allocQtyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
supplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("available_supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
availableSupplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
}
}
System.out.println("@@@@ctr["+dtlCtr+"]saleOrder["+saleOrder+"]-lineNo["+lineNo+"]-qtyReqd["+qtyReqdStr+"]@@@");
System.out.println("@@@@ctr["+dtlCtr+"]siteCode["+siteCode+"]-itemCode["+itemCode+"]-lotNo["+lotNo+"]-lotSl["+lotSl+"]-locCode["+locCode+"]-tranSer["+tranSer+"]allocQtyStr["+allocQtyStr+"]@@@");
if( runningSupplyStr.trim().length() > 0)
{
runningSupply = runningSupplyStr==null?0:Double.parseDouble(runningSupplyStr);
}
if( qtyReqdStr.trim().length() > 0)
{
qtyReqd = qtyReqdStr==null?0:Double.parseDouble(qtyReqdStr);
}
if( allocQtyStr.trim().length() > 0)
{
allocQty = allocQtyStr==null?0:Double.parseDouble(allocQtyStr);
}
/*
HashMap stkUpdMap = new HashMap();
stkUpdMap.put("sorder_no", saleOrder);
stkUpdMap.put("site_code", siteCode);
stkUpdMap.put("item_code", itemCode);
stkUpdMap.put("lot_no", lotNo);
stkUpdMap.put("lot_sl", lotSl);
stkUpdMap.put("loc_code", locCode);
stkUpdMap.put("tran_ser", tranSer);
stkUpdMap.put("line_no", lineNo);
stkUpdMap.put("quantity", allocQty);
*/
invallocTrace.setRefSer("MRPWIZ");
invallocTrace.setRefId(saleOrder);
invallocTrace.setRefLine(lineNo);
invallocTrace.setSiteCode(siteCode);
invallocTrace.setItemCode(itemCode);
invallocTrace.setLocCode(locCode);
invallocTrace.setLotNo(lotNo);
invallocTrace.setLotSl(lotSl);
invallocTrace.setAllocQty(allocQty);
//invallocTrace.setChgUser(chgUser);
//invallocTrace.setChgTerm(chgTerm);
//invallocTrace.setChgWin("W_SORDALLOC" );
errString = stockAllocationPrc.updateInvallocTrace(invallocTrace, conn);
if (errString != null && errString.trim().length() > 0)
{
System.out.println("@@@@@@rolledback errString :::"+ errString );
conn.rollback();
return errString;
}
}//end if
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in MrpWizPrsSaveBean :"+sqx);
sqx.printStackTrace();
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in MrpWizPrsSaveBean :"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (errString == null || errString.trim().length() == 0)
{
System.out.println("@@@@@@commit errString :::"+ errString );
conn.commit();
//return errString;
}
if (pstmt!= null)
{
pstmt = null;
}
if( conn != null )
{
conn.close();
conn=null;
}
}
catch(Exception e)
{
System.out.println("The SQLException occurs in MrpWizPrsSaveBean :"+e);
e.printStackTrace();
throw new ITMException(e);
}
}
return "";
}
/*
private String generateTranId( String windowName, String siteCode, Connection conn )throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
java.sql.Timestamp currDate = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis());
String currDateStr = sdfAppl.format(currDate);
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? "; // w_mrp_allocate
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + currDateStr + "</tran_date>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e){}
}
return tranId;
}//generateTranTd()
*/
/*
private String updateInvallocTrace(InvAllocTrace invallocTrace, Connection conn) throws ITMException
{
String errString = "";
String errCode = "" ;
String sql = null;
String sqlUpdate = null;
String keyStringQuery = null;
java.sql.Date tranDate = invallocTrace.getTranDate();
String refSer = invallocTrace.getRefSer();
String refId = invallocTrace.getRefId();
String refLine = invallocTrace.getRefLine();
String siteCode = invallocTrace.getSiteCode();
String itemCode = invallocTrace.getItemCode();
String locCode = invallocTrace.getLocCode();
String lotNo = invallocTrace.getLotNo();
String lotSl = invallocTrace.getLotSl();
double allocQty = invallocTrace.getAllocQty();
String chgUser = invallocTrace.getChgUser();
String chgTerm = invallocTrace.getChgTerm();
String chgWin = invallocTrace.getChgWin();
java.sql.Date chgDate = new java.sql.Date(System.currentTimeMillis());
//Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rSet = null ;
Statement stmt = null;
String tranId = null;
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try
{
keyStringQuery = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE UPPER(TRAN_WINDOW) = 'T_ALLOCTRACE'";
System.out.println("keyStringQuery--------->>"+keyStringQuery);
//ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
//connDriver = null;
stmt = conn.createStatement();
rSet = stmt.executeQuery(keyStringQuery);
System.out.println("keyString :"+rSet.toString());
String tranSer1 = "";
String keyString = "";
String keyCol = "";
if (rSet.next())
{
keyString = rSet.getString(1);
keyCol = rSet.getString(2);
tranSer1 = rSet.getString(3);
}
java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
String tranDateStr = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer1 :"+tranSer1);
String xmlValues = "";
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
//Added by Manoj dtd 10/09/2012 to generate key
xmlValues = xmlValues + "<dummy>D</dummy>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
//Added by Manoj dtd 10/09/2012 to generate key
xmlValues = xmlValues + "<tran_date>" + tranDateStr + "</tran_date>";
xmlValues = xmlValues +"</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", commonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
sql = "INSERT INTO INVALLOC_TRACE (TRAN_ID, TRAN_DATE, REF_SER, REF_ID,"
+"REF_LINE,ITEM_CODE, SITE_CODE, LOC_CODE,LOT_NO, LOT_SL, ALLOC_QTY, CHG_WIN,"
+"CHG_USER, CHG_TERM, CHG_DATE )VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
System.out.println("trans id="+tranId);
System.out.println("tranDate="+tranDate);
System.out.println("refSer="+refSer);
System.out.println("refId="+refId);
System.out.println("refLine="+refLine);
System.out.println("itemCode="+itemCode);
System.out.println("siteCode="+siteCode);
System.out.println("locCode="+locCode);
System.out.println("lotNo="+lotNo);
System.out.println("LOT_SL="+lotSl);
System.out.println("LLOC_QTY="+allocQty);
System.out.println("chgWin="+chgWin);
System.out.println("chgUser="+chgUser);
System.out.println("chgTerm="+chgTerm);
System.out.println("chgDate="+chgDate);
pstmt.setString(1,tranId);
pstmt.setDate(2,tranDate);
pstmt.setString(3,refSer);
pstmt.setString(4,refId);
pstmt.setString(5,refLine);
pstmt.setString(6,itemCode );
pstmt.setString(7,siteCode);
pstmt.setString(8,locCode);
pstmt.setString(9,lotNo );
pstmt.setString(10,lotSl);
pstmt.setDouble(11,allocQty);
pstmt.setString(12,chgWin);
pstmt.setString(13,chgUser);
pstmt.setString(14,chgTerm);
pstmt.setDate(15,chgDate);
pstmt.executeUpdate();
System.out.println("insertion of sql inside updateInvallocTrace success on date "+ chgDate);
System.out.println("Stock Updated...............................");
if(allocQty >= 0)
{
sqlUpdate = "UPDATE STOCK SET ALLOC_QTY =(CASE WHEN ALLOC_QTY IS NULL THEN 0 ELSE ALLOC_QTY END) + ? "
+"WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ?";
pstmt = conn.prepareStatement(sqlUpdate);
pstmt.setDouble(1,allocQty);
pstmt.setString(2,itemCode);
pstmt.setString(3, siteCode);
pstmt.setString(4,locCode);
pstmt.setString(5,lotNo);
pstmt.setString(6,lotSl);
pstmt.executeUpdate();
}
System.out.println("Updated End.");
}
catch(SQLException e)
{
System.out.println("SQLException :updateInvallocTrace : " + sqlUpdate + "\n" +e.getMessage());
System.out.println("ALLOC_QTY : " + allocQty);
System.out.println("ITEM_CODE : " + itemCode);
System.out.println("SITE_CODE : " + siteCode);
System.out.println("LOC_CODE : " + locCode);
System.out.println("LOT_NO : " + lotNo);
System.out.println("LOT_SL : " + lotSl);
errString = e.getMessage();
e.printStackTrace();
return errString;
}
catch(Exception e)
{
System.out.println("manohar :updateInvallocTrace connection rollback:" + sqlUpdate + "\n" +e.getMessage());
errString = e.getMessage();
e.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
e = e1;
}
return errString;
}
finally
{
try
{
//if(conn != null)
//{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(stmt != null)
{
stmt.close();
stmt = null;
}
//conn.close();
//conn = null;
//}
}
catch(Exception e)
{
errString = e.getMessage();
e.printStackTrace();
return errString;
}
return errString;
}
}
*/
}
\ No newline at end of file
......@@ -31,6 +31,7 @@ import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator;
import ibase.system.config.*;
......@@ -139,7 +140,15 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
StringBuffer xmlDataString = null; // sachin on 26/6/13
String wnName=""; // sachin on 26/6/13
String sorderList = "0";//Manoj dtd 17/10/2013
String itemCodeList = "0";//Manoj dtd 17/10/2013
boolean isDetailReq = false;//Manoj dtd 17/10/2013
ArrayList IPD_INDEPENDENT = new ArrayList();
ArrayList IPD_INDENT = new ArrayList();
ArrayList IPD_MPS_ORDER = new ArrayList();
ArrayList IPD_DIST = new ArrayList();
//String IPD_INDEPENDENT = "",IPD_INDENT = "",IPD_MPS_ORDER = "",IPD_DIST = ""; //cpatil on 15/01/14
/*
* public void ejbCreate() throws RemoteException, CreateException { try {
* System.out.println("RunMRPPrcEJB ejbCreate called........."); } catch
......@@ -209,9 +218,15 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
this.wnName=windowName;
System.out.println("win name is ==>"+wnName);
System.out.println("windowName is ==>"+windowName);
// System.out.println("Initial Size of Item Has Map :" +
// itemHashMap.size());
//if("w_runmrp_det".equalsIgnoreCase(windowName))
if("w_mrp_run_wiz".equalsIgnoreCase(windowName))
{
isDetailReq=true;
}
if (genericUtility == null)
{
genericUtility = GenericUtility.getInstance();
......@@ -234,7 +249,8 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
{
context = "2";
}
//sorderList= genericUtility.getColumnValue("sale_order_list", dom);
itemCodeList = genericUtility.getColumnValue("item_code_list", dom); // added by cpatil
// Added by Jiten 07/11/06
// this.fw = new
// FileWriter(CommonConstants.JBOSSHOME+"\\log\\RepeatBom.log");
......@@ -381,14 +397,20 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
}
// 31/01/2008 manoharan not to insert plan demand in case of
// verification
System.out.println("@@@@@@@@@@@cpatil verifier["+verifier+"]");
if (verifier != null && verifier.equalsIgnoreCase("N"))
{
//Condition added by Manoj dtd 01/01/2013
//if(!isDetailReq)
//{
errString = InsertPlanDemand();
if (errString != null && errString.trim().length() > 0)
{
System.out.println("Error While inserting Plan Demand:..." + errString);
return errString;
}
//}
// Added by Jiten
String sql = "";
String lsWhere = "";
......@@ -434,14 +456,19 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
lsWhere = " AND SUPP_SOUR IN (" + lsWhere + ")";
}
}
//Condition added by Manoj dtd 01/01/2013
if(!isDetailReq)
{
// uncommented on 04/04/11 manoharan foreign key defined with on
// delete cascade
sql = "DELETE FROM PLAN_DET WHERE SITE_CODE >='" + siteCodeFrom + "' " + " AND SITE_CODE <= '" + siteCodeTo + "' ";
// + " AND ITEM_CODE >= '"+itemCodeFrom+"' "
// + " AND ITEM_CODE <= '"+itemCodeTo+"'" ;//+ lsWhere;
System.out.println("Delete plan_hdr Sql : " + sql);
stmt = conn.createStatement();
int deletedInDetail = stmt.executeUpdate(sql);
System.out.println("Deleted in Detail For Material Plan: " + deletedInDetail);
stmt.close();
System.out.println("Deleted in detail For Material Plan: " + deletedInDetail);
......@@ -476,8 +503,12 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
if (errString != null && errString.trim().length() > 0)
{
System.out.println("Error While inserting Plan HdrDet:..." + errString);
return errString;
}
}
}
resultString = setValuesInBrow();
......@@ -498,6 +529,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
{
try
{
if (errString != null && errString.trim().length() > 0)
{
conn.rollback();
}
if (conn != null)
{
conn.close();
......@@ -987,12 +1023,17 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
Set setSite = siteCodeMap.entrySet();
Iterator itrSite = setSite.iterator();
String subQuery=" ";
// System.out.println("Database Name:............"+CommonConstants.DB_NAME);
try
{
if(isDetailReq)
{
// subQuery=" AND C.ITEM_CODE IN(SELECT ITEM_CODE__ORD FROM SORDER WHERE SALE_ORDER IN("+sorderList+") ";
subQuery=" AND C.ITEM_CODE IN(SELECT ITEM_CODE__ORD FROM SORDDET WHERE SALE_ORDER||ITEM_CODE IN("+itemCodeList+") )";
}
if ((CommonConstants.DB_NAME).equalsIgnoreCase("db2"))
{
sql = "SELECT CASE WHEN C.ITEM_CODE__PLAN IS NULL THEN C.ITEM_CODE ELSE C.ITEM_CODE__PLAN END ITEM_CODE,";
......@@ -1006,7 +1047,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
sql = sql + "AND CASE WHEN A.MASTER_SCH IS NULL THEN 'Y' ELSE A.MASTER_SCH END <> 'N' ";
sql = sql + "AND B.VALID_UPTO IS NULL ";
sql = sql + "AND C.ITEM_SER >=? ";
sql = sql + "AND C.ITEM_SER <=? ORDER BY ITEM_CODE ASC";
sql = sql + "AND C.ITEM_SER <=? "+subQuery+" ORDER BY ITEM_CODE ASC";
} else
{
sql = "SELECT CASE WHEN C.ITEM_CODE__PLAN IS NULL THEN C.ITEM_CODE ELSE C.ITEM_CODE__PLAN END ITEM_CODE, ";
......@@ -1021,7 +1062,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
sql = sql + "AND CASE WHEN A.MASTER_SCH IS NULL THEN 'Y' ELSE A.MASTER_SCH END <> 'N' ";
sql = sql + "AND B.VALID_UPTO IS NULL ";
sql = sql + "AND C.ITEM_SER >= ? ";
sql = sql + "AND C.ITEM_SER <= ? ORDER BY ITEM_CODE ASC";
sql = sql + "AND C.ITEM_SER <= ? "+subQuery+" ORDER BY ITEM_CODE ASC";
}
......@@ -1031,6 +1072,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
pstmt.setString(2, itemCodeTo);
pstmt.setString(4, itemSerFrom);
pstmt.setString(5, itemSerTo);
while (itrSite.hasNext())
{
Map.Entry siteMapEntry = (Map.Entry) itrSite.next();
......@@ -1209,6 +1251,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
confirmedBom = rsValidBom.getString(1);
activeBom = rsValidBom.getString(2);
}
System.out.println("confirmedBom---"+confirmedBom+"---activeBom---"+activeBom);
rsValidBom.close();
pstmtValidBom.close();
// this.fwInvalidBom.write("Site Code Item Code Bom Code Message\r\n");
......@@ -2552,6 +2595,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
if ("0".equals(madeToOrder))
{
System.out.println("adpeList.size()-------------"+adpeList.size());
for (int ctr = 0; ctr < adpeList.size(); ctr++)
{
ADPElement adpElement = (ADPElement) adpeList.get(ctr);
......@@ -2575,6 +2619,30 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
ADPElement adpElement = (ADPElement) adpeList.get(ctr);
adpElement = populateDemandSupply(adpElement);
adpeList.set(ctr, adpElement);
System.out.println("SaleSales order set in ADPElement---"+adpElement.getSiteCode()+"---"+adpElement.getItemCode()+"---"+adpElement.getSaleOrder()+"----"+adpElement.getLineNo());
if(isDetailReq)
{
ArrayList<HashMap<String, ADPElement>> detList=adpElement.getDetList();
for(int l=0;l<detList.size();l++)
{
HashMap<String,ADPElement> detMap=detList.get(l);
Set keyset=detMap.keySet();
Iterator<String> itr=keyset.iterator();
while(itr.hasNext())
{
String key=itr.next();
System.out.println("key----"+key);
if(key!=null && (checkNull(key).trim()).length()>0)
{
System.out.println("detMap.get(key).getPendingPO()---"+detMap.get(key).getPendingPO());
}
}
}
}
//System.out.println("Detail level Demand Supply set in ADPElement---"+adpElement.getDetMap());
}
} catch (Exception e)
......@@ -2617,6 +2685,18 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
PreparedStatement pstmt = null;
String saleOrder = null;
String lineNo = null;
//Added By Manoj dtd 31/10/2013
String tranId="";
String tranSer="";
double prevdemand=0;
double prevsupply=0;
double prevstockQty=0;
double prevothSupply=0;
double prevpendPOQty=0;
double prevpendDOQty=0;
double prevpendIndQty=0;
double prevpendDRQty=0;
try
{
itemCode = adpElement.getItemCode();
......@@ -2624,14 +2704,19 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// 01/04/11 manoharan if made to order is selected and item is of
// made to order
// don't process here
System.out.println("siteCode----"+siteCode+"itemCode----"+itemCode);
System.out.println("madeToOrder---"+madeToOrder+"----adpElement.getMfgType()----"+adpElement.getMfgType());
/* Commented by Manoj dtd 30/12/2013 calling same method for all items
if ("0".equals(madeToOrder) && "O".equals(adpElement.getMfgType()))
{
return adpElement;
}
}*/
// end 01/04/11 manoharan
// System.out.println("commonConstants.DB_NAME "+CommonConstants.DB_NAME);
// 14-02-2007 manoharan
String sqlFileName = null;
System.out.println("matPlan---"+matPlan+"----mfgPlan----"+mfgPlan);
System.out.println("isDetailReq2------"+isDetailReq);
if (matPlan.equalsIgnoreCase("N") && mfgPlan.equalsIgnoreCase("N"))
{
sqlFileName = CommonConstants.JBOSSHOME + File.separator + "sql" + File.separator + "demandsupplyforecastonly";
......@@ -2639,9 +2724,21 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
{
sqlFileName = CommonConstants.JBOSSHOME + File.separator + "sql" + File.separator + "demandsupplymaterial";
} else
{
//Condition Added By manoj dtd 31/10/2013 to get demand supply at detail level
System.out.println("isDetailReq------"+isDetailReq);
if(isDetailReq)
{
sqlFileName = CommonConstants.JBOSSHOME + File.separator + "sql" + File.separator + "demandsupplyDetail";
}
else
{
sqlFileName = CommonConstants.JBOSSHOME + File.separator + "sql" + File.separator + "demandsupply";
}
}
System.out.println("sqlFileName---"+sqlFileName);
// end 14-02-2007 manoharan
if ((CommonConstants.DB_NAME).equalsIgnoreCase("db2"))
......@@ -2740,7 +2837,12 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
pendIndQty = rs.getDouble(9);
pendPOQty = rs.getDouble(7);
System.out.println("isDetailReq3------"+isDetailReq);
if(isDetailReq)
{
tranId=rs.getString("tran_id");
tranSer=rs.getString("tran_ser");
}
// End Changes by Gulzar on 4/18/2012
// 18-11-2006 manoharan if dueDate < dateFrom then set the
......@@ -2753,8 +2855,18 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// end 18-11-2006 manoharan
// if else condition added by Jiten as per Manoharan Sir
// 02/11/06
System.out.println("2804--isDetailReq------"+isDetailReq+"----"+rsItemCode+"---"+itemCode);
if (rsItemCode != null && rsItemCode.trim().equalsIgnoreCase(itemCode.trim()))
{
System.out.println("dueDate---demand---supply"+dueDate+"---"+demand+"---"+supply);
//Condition added by Manoj dtd 30/12/2013 to set emand =0
if("0".equals(madeToOrder) && "O".equals(adpElement.getMfgType()))
{
demand=0;
}
adpElement.setDemand(dueDate, demand, " ", " ");
adpElement.setSupply(dueDate, supply);
// // 12/04/10 manoharan MF90BHU001
......@@ -2767,8 +2879,68 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
adpElement.setPendingDO(dueDate, pendDOQty);
adpElement.setPendingIndent(dueDate, pendIndQty);
adpElement.setPendingDR(dueDate, pendDRQty);
if(isDetailReq)
{
/*
//Changes by Manoj dtd 31/10/2013 regarding Detail level data
adpElement.setDemand(dueDate, demand, " ", " ");
adpElement.setSupply(dueDate, supply);
// // 12/04/10 manoharan MF90BHU001
adpElement.setStockQty(dueDate, stockQty);
adpElement.setOthSupply(dueDate, othSupply);
// // end 12/04/10 manoharan MF90BHU001
//
// // Changes made by Gulzar on 4/18/2012
adpElement.setPendingPO(dueDate, pendPOQty);
adpElement.setPendingDO(dueDate, pendDOQty);
adpElement.setPendingIndent(dueDate, pendIndQty);
adpElement.setPendingDR(dueDate, pendDRQty);
prevdemand+=demand;
prevsupply+=supply;
prevstockQty+=stockQty;
prevothSupply+=othSupply;
prevpendPOQty+=pendPOQty;
prevpendDOQty+=pendDOQty;
prevpendIndQty+=pendIndQty;
prevpendDRQty+=pendDRQty;*/
ADPElement detADPElement=new ADPElement();
detADPElement.setDemand(dueDate, demand, " ", " ");
detADPElement.setSupply(dueDate, supply);
detADPElement.setStockQty(dueDate, stockQty);
detADPElement.setOthSupply(dueDate, othSupply);
detADPElement.setPendingPO(dueDate, pendPOQty);
detADPElement.setPendingDO(dueDate, pendDOQty);
detADPElement.setPendingIndent(dueDate, pendIndQty);
detADPElement.setPendingDR(dueDate, pendDRQty);
System.out.println("Setting SaleOrder in Detail record---"+adpElement.getSaleOrder());
System.out.println("Setting Line No in Detail record---"+adpElement.getLineNo());
detADPElement.setSaleOrder(adpElement.getSaleOrder());
detADPElement.setLineNo(adpElement.getLineNo());
System.out.println("detADPElement.getPendingPO()----"+detADPElement.getPendingPO());
HashMap<String, ADPElement> detMap=new HashMap<String, ADPElement>();
System.out.println("tranId#tranSer----"+tranId+"#"+tranSer);
detMap.put(tranId+"#"+tranSer, detADPElement);
ArrayList<HashMap<String, ADPElement>> alist=adpElement.getDetList();
System.out.println("alist.size()-1---"+alist.size());
if(detMap.size()>0)
{
alist.add( detMap);
}
System.out.println("alist.size()-2---"+alist.size());
//adpElement.setDetMap(detMap);
adpElement.setDetList(alist);
detMap=null;
detADPElement=null;
alist=null;
}
// End Changes by Gulzar on 4/18/2012
} else
{
System.out.println("Site Code :: " + siteCode + " rsItemCode :: " + rsItemCode + " Item Code :: " + itemCode);
......@@ -2789,8 +2961,10 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
}
}
// End addding
System.out.println(adpElement.getSupply());
if (demand != 0 || supply != 0)
{
if (adpElement.getSuppSour().equals("M"))
// System.out.println("adpQuery ::"+adpQuery);
System.out.println("Site Code : " + siteCode + " Item Code : " + itemCode + " Due Date : " + dueDate + " Demand : " + demand + " supply : " + supply);
......@@ -2867,12 +3041,17 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
String saleOrder = null, rsItemCode = "";
String lineNo = null;
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
try
{
// itemCode = adpElement.getItemCode();
// siteCode = adpElement.getSiteCode();
// ADPElement adpElement = new ADPElement(); // 01/04/11 manoharan
// dummy for nothing
System.out.println(adpElement.getItemCode()+"---"+adpElement.getSiteCode()+"---"+adpElement.getSaleOrder()+"---"+adpElement.getLineNo());
System.out.println("madeToOrder---"+madeToOrder+"----adpElement.getMfgType()----"+adpElement.getMfgType());
if (!"0".equals(madeToOrder) || !"O".equals(adpElement.getMfgType()))
{
return;
......@@ -2924,6 +3103,8 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// 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
......@@ -2945,6 +3126,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
adpQuery = adpQuery.replaceAll("@rundate@", dbRunDate);
// end 01-10-2007 manoharan
// System.out.println("Replaced Values.in SQL.....");
}
FileOutputStream fout = null;
BufferedWriter bw = null;
......@@ -2974,11 +3156,53 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
pendIndQty = rs.getDouble(11);
pendDRQty = rs.getDouble(12);
// End Changes by Gulzar on 4/18/2012
// cpatil start
System.out.println("@@@@@saleOrder["+saleOrder+"]["+adpElement.getSaleOrder()+"]lineNo["+lineNo+"]["+adpElement.getLineNo()+"]@@@@@@@@@@@");
System.out.println("@@@@@@@@@@@sorderList["+sorderList+"]@@@@@@@@@itemCodeList["+itemCodeList+"]");
if(!(itemCodeList.indexOf(saleOrder+rsItemCode) > -1 ))
{
//if(!(itemCodeList.indexOf(rsItemCode) > -1 ))
//{
continue;
//}
}
adpElement.setSaleOrder(saleOrder);
adpElement.setLineNo(lineNo);
// cpatil end
if (dueDate.compareTo(dateFrom) < 0)
{
dueDate = dateFrom;
}
pstmt1=conn.prepareStatement("SELECT ITEM_CODE FROM BOMDET WHERE BOM_CODE IN(SELECT BOM_CODE FROM BOM WHERE ITEM_CODE=? AND CONFIRMED='Y')");
pstmt1.setString(1,rsItemCode);
rs1=pstmt1.executeQuery();
String bomitemCode="";
String tmpitemCode="";
while(rs1.next())
{
tmpitemCode=rs1.getString(1);
for(int ctr=0;ctr<adpeList.size();ctr++)
{
ADPElement tempADPElement = (ADPElement) adpeList.get(ctr);
bomitemCode=tempADPElement.getItemCode();
System.out.println("bomitemCode----"+bomitemCode+"---tmpitemCode---"+tmpitemCode);
if(bomitemCode.equalsIgnoreCase(tmpitemCode))
{
System.out.println("Setting SaleOrder and lineNo for Semi finish items---"+saleOrder+"---"+lineNo);
tempADPElement.setSaleOrder(saleOrder);
tempADPElement.setLineNo(lineNo);
break;
}
}
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
/*
* if(rsItemCode != null &&
* rsItemCode.trim().equalsIgnoreCase(itemCode.trim()) &&
......@@ -2996,13 +3220,17 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
* 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 + "]");
System.out.println("01/04/11 BHU saleOrder [" + saleOrder + "] lineNo [" + lineNo + "] ctr [" + ctr + "] [--"+rsItemCode+"]");
if (ctr > -1)
{
ADPElement tempADPElement = (ADPElement) adpeList.get(ctr);
System.out.println("3155---saleOrder---"+saleOrder+"---lineNo---"+lineNo);
tempADPElement.setDemand(dueDate, demand, saleOrder, lineNo);
System.out.println("3155---saleOrder---"+saleOrder+"---lineNo---"+lineNo);
tempADPElement.setSupply(dueDate, supply);
adpeList.set(ctr, tempADPElement);
} else if (ctr == -1)
......@@ -3015,11 +3243,27 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
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 + "]");
System.out.println("01/04/11 BHU not found adding saleOrder [" + saleOrder + "] lineNo [" + lineNo + "] ctr [" + ctr + "] rsItemCode ["+rsItemCode+"");
}
/*
System.out.println("@@@@@@@@@ cpatil---------startadpeList.size()["+adpeList.size()+"]");
for( int cctrr=0; cctrr < adpeList.size(); cctrr++)
{
ADPElement tempADPElement2 = (ADPElement) adpeList.get(cctrr);
tempADPElement2.setSaleOrder(saleOrder);
tempADPElement2.setLineNo(lineNo);
adpeList.set(cctrr, tempADPElement2);
}
System.out.println("@@@@@@@@@ cpatil---------end");
*/
// }
}
System.out.println("3176----adpElement.getSaleOrder----"+adpElement.getSaleOrder()+"---"+adpElement.getItemCode());
rs.close();
rs = null;
pstmt.close();
......@@ -3069,6 +3313,12 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
ADPElement adpElement = null;
try
{
for (int ctr = 0; ctr < adpeList.size(); ctr++)
{
adpElement = (ADPElement) adpeList.get(ctr);
System.out.println("3237---"+adpElement.getSiteCode()+"---"+adpElement.getItemCode()+"---"+adpElement.getDemand()+"---"+adpElement.getSupply()+"---"+adpElement.getStockQty()+"---"+adpElement.getSaleOrder());
}
for (int cycle = 1; cycle <= processCycle; cycle++)
{
System.out.println("Processing level no : " + cycle + " of " + processCycle);
......@@ -3085,9 +3335,17 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
return errString;
}
}
System.out.println("3250---"+adpElement.getSiteCode()+"---"+adpElement.getItemCode()+"---"+adpElement.getDemand()+"---"+adpElement.getSupply()+"---"+adpElement.getStockQty()+"---"+adpElement.getSaleOrder());
adpElement = mrpOptimize(adpElement);
adpeList.set(adpeCtr, adpElement);
}
System.out.println("cycle-----"+cycle);
for (int ctr = 0; ctr < adpeList.size(); ctr++)
{
adpElement = (ADPElement) adpeList.get(ctr);
System.out.println("3263---"+adpElement.getSiteCode()+"---"+adpElement.getItemCode()+"---"+adpElement.getDemand()+"---"+adpElement.getSupply()+"---"+adpElement.getStockQty()+"---"+adpElement.getSaleOrder());
}
}
} catch (Exception e)
{
......@@ -3151,12 +3409,14 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
if ((demand - supply) > 0)
{
ArrayList timeMRParr = adpElement.getTimeMrpList();
System.out.println(" 3323----timeMRParr.size()---"+timeMRParr.size());
for (int timeCtr = 0; timeCtr < timeMRParr.size(); timeCtr++)
{
TimeMRP timeMrp = (TimeMRP) timeMRParr.get(timeCtr);
runningDemand = timeMrp.getRunningDemand();
runningSupply = timeMrp.getRunningSupply();
runningPlanSupply = timeMrp.getRunningPlanSupply();
System.out.println("3337---runningDemand---"+runningDemand+"---runningSupply---"+runningSupply+"---runningPlanSupply---"+runningPlanSupply);
if ((suppSour.equals("M")) || (suppSour.equals("C"))) // &&
// orderOpt.equals("B")
// )
......@@ -3188,6 +3448,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// 10-04-2006 manoharan
quantity = calculateQuantity(adpElement, dueDate, quantity);
System.out.println("3369----quantity----"+quantity);
}
/*
......@@ -3296,7 +3557,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// explodeBomObj.explodeBom(xmlString.toString(),
// conn).toString();//Commented by Jiiten as per
// Kandarp Sir 13/11/06 -
System.out.println("xmlString--------"+xmlString);
retXMLStr = explodeBomObj.explodeBom(xmlString.toString()).toString(); // Added
// by
// Jiten
......@@ -3314,6 +3575,14 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
} else
{
System.out.println("retXMLStr-----"+retXMLStr);
System.out.println("3474---adpElement.getMfgType()----"+adpElement.getMfgType());
if(isDetailReq)
{
updateDemand(retXMLStr, adpElement.getSaleOrder(), adpElement.getLineNo());
}
else
{
if ("O".equals(adpElement.getMfgType()))
{
updateDemand(retXMLStr, adpElement.getSaleOrder(), adpElement.getLineNo());
......@@ -3322,6 +3591,8 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
updateDemand(retXMLStr, " ", " ");
}
}
}
}
} // inner -- if(runningDemand - runningSupply)
} // inner -- for(timectr)
......@@ -3877,16 +4148,61 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
}
rs.close();
pstmt.close();
int index = indexOfADPElement(siteCode, itemCode, " ", " ");
//int index = indexOfADPElement(siteCode, itemCode, " ", " ");//Commented by manoj dtd 19/11/2013
System.out.println("4040---siteCode----"+siteCode+"---itemCode---"+itemCode+"---saleOrder---"+saleOrder+"---lineNo---"+lineNo);
int index=0;
if(isDetailReq)
{
index = indexOfADPElement(siteCode, itemCode);
}
else
{
index = indexOfADPElement(siteCode, itemCode, saleOrder,lineNo);
}
System.out.println("4072----index---"+index);
if (index != -1)
{
adpElement = (ADPElement) adpeList.get(index);
//ADPElement tmpadpElement=new ADPElement();
//tmpadpElement=adpElement;
System.out.println("adpElement.getItemCode()----"+adpElement.getItemCode()+"saleOrder----"+saleOrder+"---adpElement.getSuppSour()---"+adpElement.getSuppSour());
if(isDetailReq)
{
adpElement.setDemand(dueDate, quantity, saleOrder, lineNo);
adpeList.set(index, adpElement);
/*ADPElement newADPElement = new ADPElement();
newADPElement.setSiteCode(siteCode);
newADPElement.setItemCode(itemCode);
newADPElement = setAdpeValues(newADPElement);
newADPElement.setSaleOrder(saleOrder);
newADPElement.setLineNo(lineNo);
newADPElement.setSupply(dueDate, adpElement.getSupply());
newADPElement.setDemand(dueDate, quantity, saleOrder, lineNo);
//adpeList.remove(index);
//adpeList.set(index,newADPElement);
adpElement.setSupply(dueDate,-1*quantity);
adpeList.add(newADPElement);*/
}
else
{
if (saleOrder == null || saleOrder.trim().length() == 0 || !"M".equals(adpElement.getSuppSour()))
//if (saleOrder == null || saleOrder.trim().length() == 0 )
{
// adpElement = (ADPElement)adpeList.get(index);
adpElement.setDemand(dueDate, quantity, " ", " ");
//adpElement.setDemand(dueDate, quantity, " ", " ");//Commented by Manoj dtd 19/11/2013 to set Sales order and line no
adpElement.setDemand(dueDate, quantity, saleOrder, lineNo);
adpeList.set(index, adpElement);
} else
}
else
{
ADPElement newADPElement = new ADPElement();
newADPElement.setSiteCode(siteCode);
......@@ -3898,6 +4214,8 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
adpeList.add(newADPElement);
}
}
//tmpadpList.add()
/* added by sachin */
if (wnName.trim().equals("w_requirement"))
......@@ -3922,7 +4240,9 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
}
/* added by sachin on 26/06/13 */
if (wnName.trim().equals("w_requirement"))
//if (wnName.trim().equals("w_requirement"))
System.out.println("checkNull(wnName)-------"+checkNull(wnName));
if ("w_requirement".equalsIgnoreCase(checkNull(wnName)))
{
xmlDataString = new StringBuffer("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><Root>");
Iterator it = qtyMap.keySet().iterator();
......@@ -3988,8 +4308,9 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
xmlDataString.append("</Detail" + context + ">");
}
xmlDataString.append("</Root>");
}
System.out.println("XML String For Requirement =" + xmlDataString.toString());
}
/* End Added by sachin on 26/06/13 */
} catch (Exception e)
......@@ -4019,7 +4340,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
for (ctr = 0; ctr < adpeList.size(); ctr++)
{
adpElement = (ADPElement) adpeList.get(ctr);
System.out.println("adpElement------" + adpElement.getSiteCode() + "----" + adpElement.getItemCode() + "----" + adpElement.getSaleOrder() + "----" + adpElement.getLineNo());
//System.out.println("adpElement------" + adpElement.getSiteCode() + "----" + adpElement.getItemCode() + "----" + adpElement.getSaleOrder() + "----" + adpElement.getLineNo()+"----"+(adpElement.getSaleOrder().equals(saleOrder))+"----"+(adpElement.getLineNo().equals(lineNo)));
if ((adpElement.getSiteCode().equals(siteCode)) && (adpElement.getItemCode().equals(itemCode)) && (adpElement.getSaleOrder().equals(saleOrder)) && (adpElement.getLineNo().equals(lineNo)))
{
retVal = ctr;
......@@ -4028,6 +4349,24 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
}
return retVal;
}
private int indexOfADPElement(String siteCode, String itemCode) throws ITMException, Exception
{
int retVal = -1, ctr = 0;
ADPElement adpElement = null;
System.out.println("adpeList.size()------" + adpeList.size());
for (ctr = 0; ctr < adpeList.size(); ctr++)
{
adpElement = (ADPElement) adpeList.get(ctr);
System.out.println("adpElement------" + adpElement.getSiteCode() + "----" + adpElement.getItemCode());
if ((adpElement.getSiteCode().equals(siteCode)) && (adpElement.getItemCode().equals(itemCode)))
{
retVal = ctr;
break;
}
}
return retVal;
}
private String populateInterSiteDistance() throws ITMException, Exception
{
......@@ -4308,6 +4647,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
try
{
for (int adpeCtr = 0; adpeCtr < adpeList.size(); adpeCtr++)
{
adpElement = (ADPElement) adpeList.get(adpeCtr);
System.out.println("4571---adpElement----"+adpElement.getSiteCode()+"---"+adpElement.getItemCode()+"---"+adpElement.getDemand()+"---"+adpElement.getSupply());
}
for (int adpeCtr = 0; adpeCtr < adpeList.size(); adpeCtr++)
{
adpElement = (ADPElement) adpeList.get(adpeCtr);
......@@ -4418,7 +4762,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
reqQty = timeMrp.getPlanSupply(); // runningDemand -
// runningSupply -
// runningPlanSupply;
System.out.println("@@@@@@cpatil-reqQty["+reqQty+"]orderOpt["+orderOpt+"]independentDemand["+independentDemand+"]batchQty["+batchQty+"]");
if (reqQty > 0)
{
// System.out.println("Plan Supply :" + reqQty +
......@@ -4456,7 +4800,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
{
multiplier = 1;
}
System.out.println("@@@@@@cpatil-multiplier["+multiplier+"]");
createQty = batchQty;
for (int planCtr = 0; planCtr < multiplier; planCtr++)
{
......@@ -4475,7 +4819,9 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
indDem.siteCodeCust = adpElement.getSiteCodeCust();
indDemList.add(indDem);
}
System.out.println("@@@@@@cpatil-indDemList["+indDemList+"]");
} else if (orderOpt.equals("C"))
{
int findEle = -1;
......@@ -4517,6 +4863,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
indDemList.add(newIndDem);
}
System.out.println("@@@@@@cpatil22-indDemList["+indDemList+"]");
}
} // (suppSour.equals("D") && disPlan.equals("Y") &&
......@@ -4585,6 +4932,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
indList.add(indent);
}
System.out.println("@@@@@@cpatil333-indList["+indList+"]");
} else if (orderOpt.equals("C"))
{
int findEle = -1;
......@@ -5067,9 +5415,10 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
String errString = "";
// System.out.println("In Insert Plan Demand()");
System.out.println("Ind Dem List Size out :" + indDemList.size());
if (indDemList.size() > 0)
{
// System.out.println("Ind Dem List Size :" + indDemList.size());
System.out.println("Ind Dem List Size :" + indDemList.size());
errString = InsertPlanDemand("W_INDEPENDENT_DEMAND", indDemList);
if (errString != null && errString.trim().length() > 0)
{
......@@ -5275,9 +5624,12 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
PreparedStatement pstmtworkOrder = null;
String sqlWorkOrder = null;
// variables added by sabyasachi ends 30-03-11
DistCommon dcommon=new DistCommon();
String lotSL="",WOtranId="";
try
{
System.out.println("@@@@@@@@@cpatil:InsertPlanDemand called----winName["+winName+"] list["+list+"]--------");
/*
* keyStringQuery =
......@@ -5287,6 +5639,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
* pstmtKeyStr.executeQuery(); if(rs.next()) { mpsKeyStr =
* rs.getString("KEY_STRING"); rs.close(); }
*/
lotSL=dcommon.getDisparams("999999","MFG_LOT_SL",conn);
keyStringQuery = "SELECT KEY_STRING FROM TRANSETUP WHERE TRAN_WINDOW = 'w_mps_order' ";
pstmtKeyStr = conn.prepareStatement(keyStringQuery);
rs = pstmtKeyStr.executeQuery();
......@@ -5338,7 +5691,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
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 ( ?, ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? ," + " ? , ? , ? ,?, ?, ?,?,?)";
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,LOT_SL) " + "VALUES ( ?, ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? ," + " ? , ? , ? , ? , ? ," + " ? , ? , ? ,?, ?, ?,?,?,?)";
pstmtWorkOrder = conn.prepareStatement(sqlWorkOrder);
......@@ -5474,7 +5827,10 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
pstmtWorkOrder.setNull(28, java.sql.Types.CHAR);
}
pstmtWorkOrder.setString(29, workOrder);
pstmtWorkOrder.setString(30,lotSL);
pstmtWorkOrder.addBatch();
WOtranId = workOrder;
} else
{
tranIdMpsOrder = getUniqueKey(xmlValues, mpsKeyStr, "tran_id", "W-MPS");
......@@ -5521,14 +5877,30 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// **************pstmtMpsOrder.setDouble(25, demandQty);
pstmtMpsOrder.addBatch();
WOtranId = tranIdMpsOrder;
}
// System.out.println("Inserting mpsorder # " + count +
// " : " + tranIdMpsOrder);
HashMap valueMap = new HashMap();
valueMap.put("item_code", itemCode);
valueMap.put("site_code", siteCode);
valueMap.put("ord_type", ordType);
valueMap.put("quantity", quantity);
valueMap.put("tran_ser", "Work Order");
valueMap.put("tran_id", WOtranId);
valueMap.put("unit",unit);
IPD_MPS_ORDER.add(valueMap);
System.out.println("IPD_MPS_ORDER valueMap["+valueMap+"]");
}
} else if (winName.equalsIgnoreCase("W_INDENT"))
System.out.println("@@@@@cpatil:IPD_MPS_ORDER["+IPD_MPS_ORDER+"]");
}
else if (winName.equalsIgnoreCase("W_INDENT"))
{
System.out.println("@@@@@cpatillist.size()["+list.size()+"]");
for (int count = 0; count < list.size(); count++)
{
indent = (Indent) list.get(count);
......@@ -5637,7 +6009,20 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
pstmtIndent.setDouble(31, convQtyStdUom);
pstmtIndent.addBatch();
HashMap valueMap = new HashMap();
valueMap.put("item_code", itemCode);
valueMap.put("site_code", siteCode);
valueMap.put("ord_type", "");
valueMap.put("quantity", quantity);
valueMap.put("tran_ser", "Indent");
valueMap.put("tran_id", tranIdIndent);
valueMap.put("unit",unitStd);
IPD_INDENT.add(valueMap);
System.out.println("IPD_INDENT valueMap["+valueMap+"]");
}
System.out.println("@@@@@cpatil:IPD_INDENT["+IPD_INDENT+"]");
} else if (winName.equalsIgnoreCase("W_DIST_DEMAND"))
{
for (int count = 0; count < list.size(); count++)
......@@ -5672,7 +6057,8 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
xmlValues = xmlValues + "<item_code><![CDATA[" + itemCode + "]]></item_code>";
xmlValues = xmlValues + "<plan_due_date><![CDATA[" + planDueDateStr + "]]></plan_due_date>";
xmlValues = xmlValues + "<due_date><![CDATA[" + dueDateStr + "]]></due_date>";
xmlValues = xmlValues + "<qty_required><![CDATA[" + qtyRequired + "]]></qty_required>";
//System.out.println("@@@@@@cpatilround(qtyRequired,3)["+round(qtyRequired,3)+"]");
xmlValues = xmlValues + "<qty_required><![CDATA[" + round(qtyRequired,3) + "]]></qty_required>";
xmlValues = xmlValues + "<unit><![CDATA[" + unit + "]]></unit>";
xmlValues = xmlValues + "<site_code__source><![CDATA[" + siteCodeSrc + "]]></site_code__source>";
xmlValues = xmlValues + "<status><![CDATA[" + status + "]]></status>";
......@@ -5703,7 +6089,21 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
pstmtDistDemand.setString(14, chgTerm);
pstmtDistDemand.addBatch();
}
pstmtIndent.addBatch();
HashMap valueMap = new HashMap();
valueMap.put("item_code", itemCode);
valueMap.put("site_code", siteCode);
valueMap.put("ord_type", "");
valueMap.put("quantity", qtyRequired);
valueMap.put("tran_ser", "Distribution Demand");
valueMap.put("tran_id", tranIdDistDemand);
valueMap.put("unit",unit);
IPD_DIST.add(valueMap);
System.out.println("IPD_DIST valueMap["+valueMap+"]");
}
System.out.println("@@@@@cpatil:IPD_DIST["+IPD_DIST+"]");
} else if (winName.equalsIgnoreCase("W_INDEPENDENT_DEMAND"))
{
for (int count = 0; count < list.size(); count++)
......@@ -5772,7 +6172,20 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
pstmtIndDemand.addBatch();
pstmtIndent.addBatch();
HashMap valueMap = new HashMap();
valueMap.put("item_code", itemCode);
valueMap.put("site_code", siteCode);
valueMap.put("ord_type", "");
valueMap.put("quantity", quantity);
valueMap.put("tran_ser", "Independent Demand");
valueMap.put("tran_id", tranIdIndDemand);
valueMap.put("unit",unit);
IPD_INDEPENDENT.add(valueMap);
System.out.println("IPD_INDEPENDENT valueMap["+valueMap+"]");
}
System.out.println("@@@@@cpatil:IPD_INDEPENDENT["+IPD_INDEPENDENT+"]");
}
int rowsInsertedWorkOrder[] = pstmtWorkOrder.executeBatch();
......@@ -5857,6 +6270,11 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// normally
}
private double round(double round,int scale) throws ITMException
{
return Math.round(round*Math.pow(10, scale))/Math.pow(10, scale);
}
private String getUniqueKey(String xmlValues, String keyString, String keyCol, String tranSer) throws ITMException
{
String uniqueKey = null;
......@@ -5960,6 +6378,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// end 12/04/10 manoharan MF90BHU001 stock_qty and oth_supply added
pstmtPlanDet = conn.prepareStatement(sqlPlanDet);
hdrSeq = 0;
System.out.println("adpeList.size()----"+adpeList.size());
for (int adpeCount = 0; adpeCount < adpeList.size(); adpeCount++)
{
flag = true;
......@@ -5967,6 +6386,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
siteCode = adpElement.getSiteCode();
itemCode = adpElement.getItemCode();
System.out.println("itemCode----"+itemCode+"---siteCode---"+siteCode);
itemSer = adpElement.getItemSer();
siteCodeSupp = adpElement.getSiteCodeSupp();
suppSour = adpElement.getSuppSour();
......@@ -6244,17 +6664,155 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
double pendIndQty = 0;
double pendDRQty = 0;
// End changes by gulzar on 4/18/2012
int count1=0,count2=0;
ADPElement adpElement = null;
//HashMap<String, ADPElement> detailMap = null;//Added by Manoj dtd 02/11/2013 to set Detail data in xml
ArrayList<HashMap<String, ADPElement>> detList=null;
String saleOrder="",itemCodeDescr="",sourceSupplyFlag="";
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
HashMap sourceSupplyMap = new HashMap();
String tranSer2="";
try
{
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?><Root>\r\n");
int count = 0;
Set sorderItemSet=new TreeSet();
//test
System.out.println("@@@@@@@@@@@ cpatil start 15/01/14");
valueXmlString.append("<Detail" + context + ">");
System.out.println("cpatil--------IPD_MPS_ORDER["+IPD_MPS_ORDER+"]");
ArrayList IPD_MPS_ORDER_List = new ArrayList();
ArrayList IPD_INDENT_List = new ArrayList();
ArrayList IPD_DIST_List = new ArrayList();
ArrayList IPD_INDEPENDENT_List = new ArrayList();
for (int ctr3=0; ctr3 < IPD_MPS_ORDER.size();ctr3++)
{
count1++;
HashMap tempMap = new HashMap();
tempMap = (HashMap) IPD_MPS_ORDER.get(ctr3);
String siteCodeMap = tempMap.get("site_code")==null?" ":tempMap.get("site_code").toString();
String itemCodeMap = tempMap.get("item_code")==null?" ":tempMap.get("item_code").toString();
String tranIdCodeMap = tempMap.get("tran_id")==null?" ":tempMap.get("tran_id").toString();
String tranSerMap = tempMap.get("tran_ser")==null?" ":tempMap.get("tran_ser").toString();
String quantityMap = tempMap.get("quantity")==null?" ":tempMap.get("quantity").toString();
String unitMap = tempMap.get("unit")==null?" ":tempMap.get("unit").toString();
valueXmlString.append("<Detail4 domID='" + count1 + "' >\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCodeMap + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCodeMap + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + setDescription("descr","item","item_code",itemCodeMap,conn) + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("<![CDATA[" + tranIdCodeMap + "]]>").append("</tran_id>\r\n");
valueXmlString.append("<tran_ser protect = '1'>").append("<![CDATA[" + tranSerMap + "]]>").append("</tran_ser>\r\n");
valueXmlString.append("<planned_quantity protect = '1'>").append("<![CDATA[" + quantityMap + "]]>").append("</planned_quantity>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + unitMap + "]]>").append("</unit>\r\n");
valueXmlString.append("</Detail4>");
IPD_MPS_ORDER_List.add(siteCodeMap+itemCodeMap);
}
System.out.println("cpatil--------IPD_INDENT["+IPD_INDENT+"]");
for (int ctr3=0; ctr3 < IPD_INDENT.size();ctr3++)
{
count1++;
HashMap tempMap = new HashMap();
tempMap = (HashMap) IPD_INDENT.get(ctr3);
String siteCodeMap = tempMap.get("site_code")==null?" ":tempMap.get("site_code").toString();
String itemCodeMap = tempMap.get("item_code")==null?" ":tempMap.get("item_code").toString();
String tranIdCodeMap = tempMap.get("tran_id")==null?" ":tempMap.get("tran_id").toString();
String tranSerMap = tempMap.get("tran_ser")==null?" ":tempMap.get("tran_ser").toString();
String quantityMap = tempMap.get("quantity")==null?" ":tempMap.get("quantity").toString();
String unitMap = tempMap.get("unit")==null?" ":tempMap.get("unit").toString();
valueXmlString.append("<Detail4 domID='" + count1 + "' >\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCodeMap + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCodeMap + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + setDescription("descr","item","item_code",itemCodeMap,conn) + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("<![CDATA[" + tranIdCodeMap + "]]>").append("</tran_id>\r\n");
valueXmlString.append("<tran_ser protect = '1'>").append("<![CDATA[" + tranSerMap + "]]>").append("</tran_ser>\r\n");
valueXmlString.append("<planned_quantity protect = '1'>").append("<![CDATA[" + quantityMap + "]]>").append("</planned_quantity>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + unitMap + "]]>").append("</unit>\r\n");
valueXmlString.append("</Detail4>");
IPD_INDENT_List.add(siteCodeMap+itemCodeMap);
}
System.out.println("cpatil--------IPD_DIST["+IPD_DIST+"]");
for (int ctr3=0; ctr3 < IPD_DIST.size();ctr3++)
{
count1++;
HashMap tempMap = new HashMap();
tempMap = (HashMap) IPD_DIST.get(ctr3);
String siteCodeMap = tempMap.get("site_code")==null?" ":tempMap.get("site_code").toString();
String itemCodeMap = tempMap.get("item_code")==null?" ":tempMap.get("item_code").toString();
String tranIdCodeMap = tempMap.get("tran_id")==null?" ":tempMap.get("tran_id").toString();
String tranSerMap = tempMap.get("tran_ser")==null?" ":tempMap.get("tran_ser").toString();
String quantityMap = tempMap.get("quantity")==null?" ":tempMap.get("quantity").toString();
String unitMap = tempMap.get("unit")==null?" ":tempMap.get("unit").toString();
valueXmlString.append("<Detail4 domID='" + count1 + "' >\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCodeMap + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCodeMap + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + setDescription("descr","item","item_code",itemCodeMap,conn) + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("<![CDATA[" + tranIdCodeMap + "]]>").append("</tran_id>\r\n");
valueXmlString.append("<tran_ser protect = '1'>").append("<![CDATA[" + tranSerMap + "]]>").append("</tran_ser>\r\n");
valueXmlString.append("<planned_quantity protect = '1'>").append("<![CDATA[" + quantityMap + "]]>").append("</planned_quantity>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + unitMap + "]]>").append("</unit>\r\n");
valueXmlString.append("</Detail4>");
IPD_DIST_List.add(siteCodeMap+itemCodeMap);
}
System.out.println("cpatil--------IPD_INDEPENDENT["+IPD_INDEPENDENT+"]");
for (int ctr3=0; ctr3 < IPD_INDEPENDENT.size();ctr3++)
{
count1++;
HashMap tempMap = new HashMap();
tempMap = (HashMap) IPD_INDEPENDENT.get(ctr3);
String siteCodeMap = tempMap.get("site_code")==null?" ":tempMap.get("site_code").toString();
String itemCodeMap = tempMap.get("item_code")==null?" ":tempMap.get("item_code").toString();
String tranIdCodeMap = tempMap.get("tran_id")==null?" ":tempMap.get("tran_id").toString();
String tranSerMap = tempMap.get("tran_ser")==null?" ":tempMap.get("tran_ser").toString();
String quantityMap = tempMap.get("quantity")==null?" ":tempMap.get("quantity").toString();
String unitMap = tempMap.get("unit")==null?" ":tempMap.get("unit").toString();
valueXmlString.append("<Detail4 domID='" + count1 + "' >\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCodeMap + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCodeMap + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + setDescription("descr","item","item_code",itemCodeMap,conn) + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("<![CDATA[" + tranIdCodeMap + "]]>").append("</tran_id>\r\n");
valueXmlString.append("<tran_ser protect = '1'>").append("<![CDATA[" + tranSerMap + "]]>").append("</tran_ser>\r\n");
valueXmlString.append("<planned_quantity protect = '1'>").append("<![CDATA[" + quantityMap + "]]>").append("</planned_quantity>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + unitMap + "]]>").append("</unit>\r\n");
valueXmlString.append("</Detail4>");
IPD_INDEPENDENT_List.add(siteCodeMap+itemCodeMap);
}
valueXmlString.append("</Detail" + context + ">");
System.out.println("@@@@@@@@@@@ cpatil end 15/01/14");
//test end
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("Printing adpeList.size()---" + adpeList.size());
for (int adpeCount = 0; adpeCount < adpeList.size(); adpeCount++)
{
flag = true;
adpElement = (ADPElement) adpeList.get(adpeCount);
System.out.println("Printing adpeCount---" + adpeCount);
......@@ -6278,9 +6836,25 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
purLeadTime = adpElement.getPurLeadTime();
mfgLeadTime = adpElement.getMfgLeadTime();
desc = adpElement.getItemDescr();
saleOrder = adpElement.getSaleOrder();
ArrayList timeMRParr = adpElement.getTimeMrpList();
System.out.println("Printing timeMRParr.size()---" + timeMRParr.size());
//detailMap=adpElement.getDetMap();//Added by Manoj dtd 02/11/2013
//HashMap<String,ADPElement> detailMap=adpElement.getDetMap();
/*Set keyset=detailMap.keySet();
Iterator<String> itr1=keyset.iterator();
while(itr1.hasNext())
{
String key=itr1.next();
System.out.println("key----"+key);
if(key!=null && (checkNull(key).trim()).length()>0)
{
System.out.println("detMap.get(key).getPendingPO()---"+detailMap.get(key).getPendingPO()+"----detailMap.get(key).getStockQty()---"+detailMap.get(key).getStockQty());
}
}*/
detList=adpElement.getDetList();
for (int timeCtr = 0; timeCtr < timeMRParr.size(); timeCtr++)
{
System.out.println("Printing timeCtr---" + timeCtr);
......@@ -6309,8 +6883,208 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
// added by akhilesh on
count++;
System.out.println("@@@@@@@@@@@isDetailReq["+isDetailReq+"]");
if(isDetailReq) // cpatil
{
System.out.println("@@@@@@@@@["+siteCode+"]["+itemCode+ "]@@@@@@@@@sorderItemSet["+sorderItemSet+"]saleOrder["+saleOrder+"]isDetailReq["+isDetailReq+"]");
if( sorderItemSet != null && sorderItemSet.contains(siteCode+itemCode)) // +saleOrder
{
System.out.println("@@@@@@@@@@@@@@@@@@@ continue");
continue;
}
else
{
System.out.println("@@@@@@@@@ added ["+siteCode+"]["+itemCode+"]["+saleOrder+"]@@@@@");
sorderItemSet.add( siteCode+itemCode ); //+saleOrder
}
}
System.out.println("@@@@@@@@ test continue not found--["+siteCode+"]-["+itemCode+"]--@@sorderItemSet["+sorderItemSet+"]");
//valueXmlString.append("<Detail" + context + " domID='" + count + "' >\r\n");
if(!(isDetailReq))
{
valueXmlString.append("<Detail" + context + " domID='" + count + "' >\r\n");
if (flag)
}
else
{
valueXmlString.append("<Detail" + context + ">\r\n ");
}
if(isDetailReq)
{
//valueXmlString.append("<sale_order protect = '1'>").append("<![CDATA[" + adpElement.getSaleOrder() + "]]>").append("</sale_order>\r\n");
//valueXmlString.append("<line_no protect = '1'>").append("<![CDATA[" + adpElement.getLineNo() + "]]>").append("</line_no>\r\n");
String refId=adpElement.getRefId();
System.out.println("@@@@@@@@@@@@refId["+refId+"]");
if(refId!=null && refId.trim().length()>0)
{
System.out.println("@@@@@@@@@ inside reference");
String refArray[]=refId.split("#");
valueXmlString.append("<reference protect = '1'>");
System.out.println("@@@@@@@@@@@@ refArray.length["+refArray.length+"]["+refArray+"]");
if(refArray.length>0)
{
for(int refcnt=0;refcnt<refArray.length;refcnt++)
{
System.out.println("@@@@@@@@@@@@inside order");
count2++;
valueXmlString.append("<order protect = '1' domID='" + count2 + "'>\r\n");
String refOrd=refArray[refcnt];
String refOrdArray[]=refOrd.split("@");
if(refOrdArray.length>0)
{
valueXmlString.append("<sale_order protect = '1'>").append("<![CDATA[" + refOrdArray[0] + "]]>").append("</sale_order>\r\n");
valueXmlString.append("<line_no protect = '1'>").append("<![CDATA[" + refOrdArray[1] + "]]>").append("</line_no>\r\n");
valueXmlString.append("<qty_reqd protect = '1'>").append("<![CDATA[" + round( refOrdArray[2]==null?0:Double.parseDouble(refOrdArray[2]),3) + "]]>").append("</qty_reqd>\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + setDescription("descr","item","item_code",itemCode,conn) + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<supp_sour protect = '1'>").append("<![CDATA[" + suppSour + "]]>").append("</supp_sour>\r\n");
valueXmlString.append("<running_supply protect = '1'>").append("<![CDATA[" + getRequiredDecimal(runningSupply, 3) + "]]>").append("</running_supply>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + unit + "]]>").append("</unit>\r\n");
//valueXmlString.append("<tran_ser_flag protect = '1'>").append("<![CDATA[" + tranSerFlag(siteCode+itemCode,IPD_DIST_List,IPD_INDENT_List,IPD_INDEPENDENT_List,IPD_MPS_ORDER_List) + "]]>").append("</tran_ser_flag>\r\n");
Boolean tranSerflag = tranSerFlag(siteCode+itemCode,IPD_DIST_List,IPD_INDENT_List,IPD_INDEPENDENT_List,IPD_MPS_ORDER_List);
/**///test
//valueXmlString.append("<Deatail4 protect = '1'>");
{
flag = false;
//int count1=0;
for(int k=0;k<detList.size();k++)
{
Set keySet=detList.get(k).keySet();
Iterator<String> itr=keySet.iterator();
while(itr.hasNext())
{
String mapKey=itr.next();
System.out.println("mapKey---"+mapKey);
boolean populateDet=false;
if(mapKey!=null && checkNull(mapKey).trim().length()>0)
{
populateDet=true;
}
if(populateDet)
{
ADPElement detadpElement=detList.get(k).get(mapKey);
ArrayList dettimeMRParr = detadpElement.getTimeMrpList();
for (int dettimeCtr = 0; dettimeCtr < dettimeMRParr.size(); dettimeCtr++)
{
count1++;
//valueXmlString.append("<Detail3 domID='" + count1 + "' >\r\n");
TimeMRP timeMrp1 = (TimeMRP) dettimeMRParr.get(dettimeCtr);
System.out.println("Printing timeMrp---" + timeMrp1);
demand = timeMrp1.getDemand();
supply = timeMrp1.getSupply();
planSupply = timeMrp1.getPlanSupply();
runningDemand = timeMrp1.getRunningDemand();
runningSupply = timeMrp1.getRunningSupply();
runningPlanSupply = timeMrp1.getRunningPlanSupply();
independentDemand = timeMrp1.getIndependentDemand();
stockQty = timeMrp1.getStockQty();
othSupply = timeMrp1.getOthSupply();
pendPOQty = timeMrp1.getPendingPO();
pendDOQty = timeMrp1.getPendingDO();
pendIndQty = timeMrp1.getPendingIndent();
pendDRQty = timeMrp1.getPendingDR();
String tranId=mapKey.split("#")[0];
tranSer2=mapKey.split("#")[1];
String stkKey[]=tranId.split("@");
//valueXmlString.append("<supp_detail protect = '1'>");
/*
if("STK".equalsIgnoreCase(tranSer))
{
if(stkKey.length>0)
{
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + stkKey[0] + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + stkKey[1] + "]]>").append("</item_code>\r\n");
valueXmlString.append("<lot_no protect = '1'>").append("<![CDATA[" + stkKey[2] + "]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl protect = '1'>").append("<![CDATA[" + stkKey[3] + "]]>").append("</lot_sl>\r\n");
valueXmlString.append("<loc_code protect = '1'>").append("<![CDATA[" + stkKey[4] + "]]>").append("</loc_code>\r\n");
}
}
else
{
valueXmlString.append("<tran_id protect = '1'>").append("<![CDATA[" + stkKey[0] + "]]>").append("</tran_id>\r\n");
valueXmlString.append("<line_no protect = '1'>").append("<![CDATA[" + stkKey[1] + "]]>").append("</line_no>\r\n");
}
valueXmlString.append("<tran_ser protect = '1'>").append("<![CDATA[" + tranSer + "]]>").append("</tran_ser>\r\n");
sourceSupplyFlag="";
if( tranSerflag == true )
{
sourceSupplyFlag = "P";
//sourceSupplyMap.put("planned", "P");
}
if( "Stock".equalsIgnoreCase(tranSer) )
{
sourceSupplyFlag = sourceSupplyFlag + "S";
//sourceSupplyMap.put("stock", "S");
}
if("Work Order".equalsIgnoreCase(tranSer) || "Dist Issue".equalsIgnoreCase(tranSer) || "Dist Receipt".equalsIgnoreCase(tranSer) || "Purchase Order".equalsIgnoreCase(tranSer) || "Indent".equalsIgnoreCase(tranSer))
{
sourceSupplyFlag = sourceSupplyFlag + "W";
//sourceSupplyMap.put("wip", "W");
}
valueXmlString.append("<source_supply protect = '1'>").append("<![CDATA[" + sourceSupplyFlag + "]]>").append("</source_supply>\r\n");
// valueXmlString.append("</supp_detail>");
*/
// valueXmlString.append("</Detail3>");
}
}
}
}
}
sourceSupplyFlag="";
if( tranSerflag == true )
{
sourceSupplyFlag = "P";
//sourceSupplyMap.put("planned", "P");
}
if( "Stock".equalsIgnoreCase(tranSer2) )
{
sourceSupplyFlag = sourceSupplyFlag + "S";
//sourceSupplyMap.put("stock", "S");
}
if("Work Order".equalsIgnoreCase(tranSer2) || "Dist Issue".equalsIgnoreCase(tranSer2) || "Dist Receipt".equalsIgnoreCase(tranSer2) || "Purchase Order".equalsIgnoreCase(tranSer2) || "Indent".equalsIgnoreCase(tranSer2))
{
sourceSupplyFlag = sourceSupplyFlag + "W";
//sourceSupplyMap.put("wip", "W");
}
valueXmlString.append("<source_supply protect = '1'>").append("<![CDATA[" + sourceSupplyFlag + "]]>").append("</source_supply>\r\n");
// valueXmlString.append("</Deatail4>");
/**////test
}
valueXmlString.append("</order>");
}
}
valueXmlString.append("</reference>");
}
//valueXmlString.append("<reference protect = '1'>").append("<![CDATA[" + adpElement.getRefId() + "]]>").append("</reference>\r\n");
}
if (flag || isDetailReq)
{
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>\r\n");
......@@ -6322,7 +7096,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
valueXmlString.append("<supp_sour protect = '1'>").append("<![CDATA[" + "" + "]]>").append("</supp_sour>\r\n");
}
valueXmlString.append("<demand protect = '1'>").append("<![CDATA[" + getRequiredDecimal(demand, 3) + "]]>").append("</demand>\r\n");
valueXmlString.append("<supply protect = '1'>").append("<![CDATA[" + getRequiredDecimal(supply, 3) + "]]>").append("</supply>\r\n");
valueXmlString.append("<supply protect = '1'>").append("<![CDATA[" + round(supply, 3) + "]]>").append("</supply>\r\n");
valueXmlString.append("<due_date protect = '1'>").append("<![CDATA[" + dueDateStr + "]]>").append("</due_date>\r\n");
valueXmlString.append("<plan_supply protect = '1'>").append("<![CDATA[" + getRequiredDecimal(planSupply, 3) + "]]>").append("</plan_supply>\r\n");
valueXmlString.append("<running_demand protect = '1'>").append("<![CDATA[" + getRequiredDecimal(runningDemand, 3) + "]]>").append("</running_demand>\r\n");
......@@ -6387,7 +7161,7 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
valueXmlString.append("<pending_dr protect = '1'>").append("<![CDATA[" + getRequiredDecimal(pendDRQty, 3) + "]]>").append("</pending_dr>\r\n");
}
valueXmlString.append("</Detail" + context + ">");
System.out.println("Printing valueXmlString----" + valueXmlString);
// ended by akhilesh
......@@ -6516,13 +7290,134 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
*/
}
flag = false;
//int count1=0;
for(int k=0;k<detList.size();k++)
{
Set keySet=detList.get(k).keySet();
Iterator<String> itr=keySet.iterator();
while(itr.hasNext())
{
String mapKey=itr.next();
System.out.println("mapKey---"+mapKey);
boolean populateDet=false;
if(mapKey!=null && checkNull(mapKey).trim().length()>0)
{
populateDet=true;
}
if(populateDet)
{
ADPElement detadpElement=detList.get(k).get(mapKey);
//siteCode = detadpElement.getSiteCode();
//itemCode = detadpElement.getItemCode();
//maxQty = detadpElement.getMaxQty();
//minQty = detadpElement.getMinQty();
//suppSour = detadpElement.getSuppSour();
//orderOpt = detadpElement.getOrderOpt();
//bomCode = detadpElement.getBomCode();
//unit = detadpElement.getUnit();
//batchQtyType = detadpElement.getBatchQtyType();
//minOrderQty = detadpElement.getMinOrderQty();
//integralQty = detadpElement.getIntegralQty();
//reorderQty = detadpElement.getReoQty();
//yieldPerc = detadpElement.getYieldPerc();
//minPlanPerc = detadpElement.getMinPlanPerc();
//batchQty = detadpElement.getBatchQty();
//purcRate = detadpElement.getPurcRate();
//qcLeadTime = detadpElement.getQcLeadTime();
//purLeadTime = detadpElement.getPurLeadTime();
//mfgLeadTime = detadpElement.getMfgLeadTime();
//desc = detadpElement.getItemDescr();
ArrayList dettimeMRParr = detadpElement.getTimeMrpList();
for (int dettimeCtr = 0; dettimeCtr < dettimeMRParr.size(); dettimeCtr++)
{
count1++;
valueXmlString.append("<Detail4 domID='" + count1 + "' >\r\n");
TimeMRP timeMrp1 = (TimeMRP) dettimeMRParr.get(dettimeCtr);
System.out.println("Printing timeMrp---" + timeMrp1);
demand = timeMrp1.getDemand();
supply = timeMrp1.getSupply();
planSupply = timeMrp1.getPlanSupply();
runningDemand = timeMrp1.getRunningDemand();
runningSupply = timeMrp1.getRunningSupply();
runningPlanSupply = timeMrp1.getRunningPlanSupply();
independentDemand = timeMrp1.getIndependentDemand();
//dueDateStr = simpleDateFormat.format(timeMrp1.getDueDate());
stockQty = timeMrp1.getStockQty();
othSupply = timeMrp1.getOthSupply();
pendPOQty = timeMrp1.getPendingPO();
pendDOQty = timeMrp1.getPendingDO();
pendIndQty = timeMrp1.getPendingIndent();
pendDRQty = timeMrp1.getPendingDR();
String tranId=mapKey.split("#")[0];
String tranSer=mapKey.split("#")[1];
String stkKey[]=tranId.split("@");
// valueXmlString.append("<supp_detail protect = '1'>");
if("Stock".equalsIgnoreCase(tranSer))
{
if(stkKey.length>0)
{
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + stkKey[0] + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + stkKey[1] + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + setDescription("descr","item","item_code",stkKey[1],conn) + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<lot_no protect = '1'>").append("<![CDATA[" + stkKey[2] + "]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl protect = '1'>").append("<![CDATA[" + stkKey[3] + "]]>").append("</lot_sl>\r\n");
valueXmlString.append("<loc_code protect = '1'>").append("<![CDATA[" + stkKey[4] + "]]>").append("</loc_code>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + setDescription("unit", "item", "item_code", stkKey[1], conn) + "]]>").append("</unit>\r\n");
}
}
else
{ //setDescription("descr","item","item_code",stkKey[1])
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + setDescription("descr","item","item_code",itemCode,conn) + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("<![CDATA[" + stkKey[0] + "]]>").append("</tran_id>\r\n");
valueXmlString.append("<line_no protect = '1'>").append("<![CDATA[" + stkKey[1] + "]]>").append("</line_no>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + setDescription("unit", "item", "item_code", itemCode, conn) + "]]>").append("</unit>\r\n");
}
valueXmlString.append("<tran_ser protect = '1'>").append("<![CDATA[" + tranSer + "]]>").append("</tran_ser>\r\n");
// valueXmlString.append("</supp_detail>");
valueXmlString.append("<demand protect = '1'>").append("<![CDATA[" + getRequiredDecimal(demand, 3) + "]]>").append("</demand>\r\n");
valueXmlString.append("<supply protect = '1'>").append("<![CDATA[" + round(supply, 3) + "]]>").append("</supply>\r\n");
valueXmlString.append("<plan_supply protect = '1'>").append("<![CDATA[" + getRequiredDecimal(planSupply, 3) + "]]>").append("</plan_supply>\r\n");
valueXmlString.append("<running_demand protect = '1'>").append("<![CDATA[" + getRequiredDecimal(runningDemand, 3) + "]]>").append("</running_demand>\r\n");
valueXmlString.append("<running_supply protect = '1'>").append("<![CDATA[" + getRequiredDecimal(runningSupply, 3) + "]]>").append("</running_supply>\r\n");
valueXmlString.append("<running_plan_supply protect = '1'>").append("<![CDATA[" + getRequiredDecimal(runningPlanSupply, 3) + "]]>").append("</running_plan_supply>\r\n");
valueXmlString.append("<independent_demand protect = '1'>").append("<![CDATA[" + getRequiredDecimal(independentDemand, 3) + "]]>").append("</independent_demand>\r\n");
valueXmlString.append("<stock_qty protect = '1'>").append("<![CDATA[" + getRequiredDecimal(stockQty, 3) + "]]>").append("</stock_qty>\r\n");
valueXmlString.append("<oth_supply protect = '1'>").append("<![CDATA[" + getRequiredDecimal(othSupply, 3) + "]]>").append("</oth_supply>\r\n");
valueXmlString.append("<pending_po protect = '1'>").append("<![CDATA[" + getRequiredDecimal(pendPOQty, 3) + "]]>").append("</pending_po>\r\n");
valueXmlString.append("<pending_do protect = '1'>").append("<![CDATA[" + getRequiredDecimal(pendDOQty, 3) + "]]>").append("</pending_do>\r\n");
valueXmlString.append("<pending_indent protect = '1'>").append("<![CDATA[" + getRequiredDecimal(pendIndQty, 3) + "]]>").append("</pending_indent>\r\n");
valueXmlString.append("<pending_dr protect = '1'>").append("<![CDATA[" + getRequiredDecimal(pendDRQty, 3) + "]]>").append("</pending_dr>\r\n");
valueXmlString.append("</Detail4>");
}
}
}
}
valueXmlString.append("</Detail" + context + ">");
}
}
valueXmlString.append("</Root>");
System.out.println("Printing valueXmlString----2---" + valueXmlString);
System.out.println("Printing context-------" + context);
// context=2;
if (context != null && context.trim().length() > 0 && context.equals("3"))
if (context != null && context.trim().length() > 0 && context.equals("2")) //3
{
resultString = valueXmlString.toString();
} else
......@@ -6558,6 +7453,43 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
return resultString;
}
private Boolean tranSerFlag(String value, ArrayList iPD_DIST_List,ArrayList iPD_INDENT_List, ArrayList iPD_INDEPENDENT_List, ArrayList iPD_MPS_ORDER_List)
{
//String sourceSupplyFlag="";
Boolean flag = false;
System.out.println("@@@@@@@@@cpatil--value["+value+"]--iPD_DIST_List["+iPD_DIST_List+"]@@@@iPD_INDENT_List["+iPD_INDENT_List+"]@@@@iPD_INDEPENDENT_List["+iPD_INDEPENDENT_List+"]@@@@iPD_MPS_ORDER_List["+iPD_MPS_ORDER_List+"]@@@@");
if(iPD_DIST_List.contains(value) || iPD_INDENT_List.contains(value) || iPD_INDEPENDENT_List.contains(value) || iPD_MPS_ORDER_List.contains(value))
{
flag = true;
}
System.out.println("@@@@@cpatiltranSerFlag["+flag+"]");
return flag;
}
private String setDescription(String field, String table,
String field2, String value,Connection conn) throws SQLException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String descr="",sql="";
sql = "select "+ field +" from "+ table +" where "+ field2 +" = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, value );
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString(1));
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("@@@@@@@@cpatil-Descr["+descr+"]");
return descr;
}
public double getRequiredDecimal(double actVal, int prec)
{
NumberFormat numberFormat = NumberFormat.getIntegerInstance();
......@@ -6792,7 +7724,8 @@ public class RunMRPPrc extends ProcessEJB implements RunMRPPrcLocal, RunMRPPrcRe
try
{
mrpOutputLocation = dom.getElementsByTagName("mrp_output_location").item(0).getFirstChild().getNodeValue();
} catch (Exception e)
}
catch (Exception e)
{
System.out.println("Exception :RunMRPPrcEJB :setValuesInBrow():" + e.getMessage() + ":");
e.printStackTrace();
......
/********************************************************
Title : RunMRPWiz (MF3HSUP005)
Date : 27/NOV/13
Developer: Kunal Mandhre
********************************************************/
package ibase.webitm.ejb.mfg;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless;
import java.sql.Timestamp;
@Stateless
public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWizRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
//method for validation
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = "";
System.out.println("wfValdata() called for RunMRPWiz");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("@@@@@@@@@@@@@@@xmlString["+xmlString+"]@@@@@@@@@@@@@@@@@@");
System.out.println("@@@@@@@@@@@@@@@xmlString1["+xmlString1+"]@@@@@@@@@@@@@@@@@@");
System.out.println("@@@@@@@@@@@@@@@xmlString2["+xmlString2+"]@@@@@@@@@@@@@@@@@@");
if (xmlString != null && xmlString.trim().length() > 0 )
{
dom = parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0 )
{
dom1 = parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
}
catch(Exception e)
{
throw new ITMException(e);
}
return(errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = "";
String errString = "";
int ctr,currentFormNo=0;
int childNodeListLength;
int count = 0;
String siteCodeFrom = "";
String siteCodeTo = "";
String itemCodeFrom = "";
String itemCodeTo = "";
String itemSerFrom = "";
String itemSerTo = "";
String errCode = "";
String userId = "";
String sql = "";
String itemcodeTo = "";
//String itemSerTo = "";
//String itemSerFrom = "";
Connection conn = null;
SimpleDateFormat simpleDateFormat = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"userId");
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
int cnt;
System.out.println("childNodeName 0. : " + childNodeName);
if (childNodeName.equals("date_to"))
{
if (childNode.getFirstChild() == null || genericUtility.getColumnValue("date_from",dom) == null)
{
errCode = "VMRPDATE1";
errString = getErrorString("date_to",errCode,userId);
break;
}
String df = genericUtility.getColumnValue("date_from",dom);
String dt = genericUtility.getColumnValue("date_to",dom);
System.out.println("date From -->" + df );
System.out.println("date To -->" + dt );
System.out.println("Parsed " + simpleDateFormat.parse(df));
java.util.Date fromDate = new Date(simpleDateFormat.parse(genericUtility.getColumnValue("date_from",dom)).getTime());
java.util.Date toDate = new Date(simpleDateFormat.parse(genericUtility.getColumnValue("date_to",dom)).getTime());
if(fromDate.after(toDate))
{
System.out.println("Error...");
errCode = "VMRPDATE1";
errString = getErrorString("date_to",errCode,userId);
break;
}
else
System.out.println("No Error...");
}
if (childNodeName.equals("site_code__to"))
{
if (childNode.getFirstChild() == null || genericUtility.getColumnValue("site_code__from",dom) == null)
{
errCode = "VMRPSITE1";
errString = getErrorString("site_code__to",errCode,userId);
break;
}
siteCodeFrom = genericUtility.getColumnValue("site_code__from",dom);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom);
if(siteCodeTo.compareTo(siteCodeFrom)<0)
{
errCode = "VMRPSITE1";
errString = getErrorString("site_code__to",errCode,userId);
break;
}
count = 0;
}
}
}
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
//System.out.println("Closing Connection.....");
conn.close();
conn = null;
}catch(Exception se){}
}
System.out.println("@@@@@@ errString["+errString+"]");
return errString;
}
// method for item change
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
System.out.println("itemChanged() called for RunMRPWiz");
String valueXmlString = "";
try
{
System.out.println("xmlString:::"+xmlString);
System.out.println("xmlString1:::"+xmlString1);
System.out.println("xmlString2:::"+xmlString2);
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [RunMRPWiz][itemChanged( String, String )] :==>\n" + e.getMessage());
}
return valueXmlString;
}
// method for item change
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String childNodeName = null;
String sql = "";
String siteCodeTo = "" , siteCodeFr = "" ,saleOrder = "" ,itemCode = "" , siteCode = "" ;
String mrpGetData = "", itemCodeList = "" , winName = "", saleOrderList="";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0 , currentFormNo = 0 ,lineNo = 0 ,domID = 0;
java.sql.Timestamp dateTo = null ,dateFr = null;
Document argDom = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
SimpleDateFormat simpleDateFormat = null;
String lineNoStr="",mrpGetDataNodeName="",qtyReqd="",referenceChildNodeName="", Detail4ChildNodeName="";
NodeList mrpGetDataList=null,referenceList=null,orderList=null,Detail4List=null,suppDetailsList=null,childNodeList22=null;
Node mrpGetDataNode =null, referenceChildNode=null, Detail4ChildNode=null,mrpGetDataNode2=null;
Node referenceListNode=null;
String lotNo="",lotSl="",locCode="",tranSer="",siteCodeSupp="",itemCodeSupp="",runningSupply="";
Document mrpGetDataDom=null;
NodeList referenceList22=null;
ArrayList ValueList = new ArrayList();
HashMap keyMap = new HashMap();
ArrayList keyList = new ArrayList(); int i=0;
ArrayList trmpQty=null;
NodeList orderListList22=null;
//String mrpGetDataNodeName="",qtyReqd="",referenceChildNodeName="", Detail4ChildNodeName="";
//NodeList mrpGetDataList=null,referenceList=null,orderList=null,Detail4List=null,suppDetailsList=null,childNodeList22=null;
//Node mrpGetDataNode =null, referenceChildNode=null, Detail4ChildNode=null,mrpGetDataNode2=null;
//Node referenceListNode=null;
//String lotNo="",lotSl="",locCode="",tranSer="",siteCodeSupp="",itemCodeSupp="",runningSupply="",editFlag="";
//Document mrpGetDataDom=null; NodeList referenceList22=null; ArrayList ValueList = new ArrayList();
//HashMap keyMap = new HashMap<String, ArrayList>();
//ArrayList keyList = null;
//ArrayList finalKeyList = new ArrayList();
//int i=0;
//ArrayList trmpQty=null;
//NodeList orderListList22=null;
HashMap valueMap= null;
ArrayList valueList = new ArrayList();
String refLineNo="",refId="";
ArrayList detail2keyList = null;
Boolean detail2Flag = false, detail4Flag=false;
String custCode="",custName="",quantity="",unit="";
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
System.out.println("currentColumn===="+currentColumn);
if(currentColumn.trim().equals("itm_default"))
{
Calendar cal = Calendar.getInstance();
Date d = new Date();
cal.setTime(d);
cal.set(Calendar.DATE,1);
d = cal.getTime();
String fromDate = simpleDateFormat.format(d);
cal.setTime(d);
cal.add(Calendar.MONTH,3);
cal.set(Calendar.DATE,0);
d = cal.getTime();
String toDate = simpleDateFormat.format(d);
System.out.println("From Date :" + fromDate + " To Date :" + toDate);
valueXmlString.append("<date_from>").append(fromDate).append("</date_from>");
valueXmlString.append("<date_to>").append(toDate).append("</date_to>");
valueXmlString.append("<site_code__from>").append("00").append("</site_code__from>");
valueXmlString.append("<site_code__to>").append("ZZ").append("</site_code__to>");
/*
valueXmlString.append("<item_code__from>").append("0").append("</item_code__from>");
valueXmlString.append("<item_code__to>").append("ZZ").append("</item_code__to>");
valueXmlString.append("<item_ser__from>").append("0").append("</item_ser__from>");
valueXmlString.append("<item_ser__to>").append("ZZ").append("</item_ser__to>");
valueXmlString.append("<process_cycle>").append("0").append("</process_cycle>");
valueXmlString.append("<run_date>").append(runDate).append("</run_date>"); // 01-10-2007 manoharan
valueXmlString.append("<dis_plan>").append("Y").append("</dis_plan>");
valueXmlString.append("<mfg_plan>").append("Y").append("</mfg_plan>");
valueXmlString.append("<mat_plan>").append("Y").append("</mat_plan>");
valueXmlString.append("<made_to_stock>").append("0").append("</made_to_stock>");
valueXmlString.append("<made_to_order>").append("0").append("</made_to_order>");
valueXmlString.append("<balance_intersite>").append("N").append("</balance_intersite>");
//valueXmlString.append("<cons_supp>").append("1").append("</cons_supp>");
valueXmlString.append("<gen_ind>").append("Y").append("</gen_ind>");
*/
}
valueXmlString.append("</Detail1>");
break;
case 2 :
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom1);
siteCodeFr = genericUtility.getColumnValue("site_code__from",dom1);
System.out.println("siteCodeTo="+siteCodeTo+ " siteCodeFr ="+siteCodeFr);
//sDateTo = genericUtility.getValidDateString(genericUtility.getColumnValue("date_from",dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
dateFr = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("date_from",dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00");
dateTo = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("date_to",dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00");
sql = " SELECT sorditem.sale_order,sorditem.line_no, sorditem.site_code, item.item_code__plan as item_code,sorditem.due_date as due_date, "
+" ((case when sorditem.quantity is null then 0 else sorditem.quantity end - case when sorditem.qty_alloc is null then 0 else sorditem.qty_alloc end - case when sorditem.qty_desp is null then 0 else sorditem.qty_desp end ) * case when sorditem.conv__qty_stdqty is null then 1 else sorditem.conv__qty_stdqty end ) as demand,"
+" 0 as supply, 0 as stock_qty, 0 as oth_supply , sorder.cust_code, customer.cust_name ,sorditem.quantity,sorditem.unit "
+" FROM sorder,sorditem, item ,customer"
+" WHERE ( sorditem.item_code = item.item_code ) and (sorder.sale_order = sorditem.sale_order ) "
+" and (case when sorder.confirmed is null then 'N' else sorder.confirmed end = 'Y' ) "
// +" and (case when sorditem.consume_fc is null then 'Y' else sorditem.consume_fc end = 'N' )"
+" and sorditem.site_code >= ? AND sorditem.site_code <= ? "
+" and (sorditem.due_date >= ? ) and (sorditem.due_date <= ? ) "
+" and ( case when sorder.status is null then 'P' else sorder.status end = 'P')"
+" and item.mfg_type = 'O' "
+" and (sorder.cust_code = customer.cust_code )";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCodeFr);
pstmt.setString(2,siteCodeTo);
pstmt.setTimestamp(3,dateFr);
pstmt.setTimestamp(4,dateTo);
rs = pstmt.executeQuery();
while(rs.next())
{
saleOrder = checkNull(rs.getString("sale_order"));
lineNo = rs.getInt("line_no") ;
itemCode = checkNull(rs.getString("item_code"));
siteCode = checkNull(rs.getString("site_code"));
custCode = checkNull(rs.getString("cust_code"));
custName = checkNull(rs.getString("cust_name"));
quantity = checkNull(rs.getString("quantity"));
unit = checkNull(rs.getString("unit"));
System.out.println(saleOrder+"@"+lineNo+"@"+itemCode);
domID ++;
valueXmlString.append( "<Detail2 domID='"+ domID +"' selected = 'N'>\r\n" );
valueXmlString.append( "<sale_order><![CDATA[" ).append(saleOrder).append( "]]></sale_order>\r\n" );
valueXmlString.append( "<line_no><![CDATA[" ).append(lineNo).append( "]]></line_no>\r\n" );
valueXmlString.append( "<site_code><![CDATA[" ).append(siteCode).append( "]]></site_code>\r\n" );
valueXmlString.append( "<item_code><![CDATA[" ).append(itemCode).append( "]]></item_code>\r\n" );
valueXmlString.append( "<item_code_descr><![CDATA[" ).append(setDescription("descr","item","item_code",itemCode,conn)).append("]]></item_code_descr>\r\n" );
valueXmlString.append( "<cust_code><![CDATA[" ).append(custCode).append( "]]></cust_code>\r\n" );
valueXmlString.append( "<cust_name><![CDATA[" ).append(custName).append("]]></cust_name>\r\n" );
valueXmlString.append( "<quantity><![CDATA[" ).append(quantity).append("]]></quantity>\r\n" );
valueXmlString.append( "<unit><![CDATA[" ).append(unit).append("]]></unit>\r\n" );
valueXmlString.append( "</Detail2>\r\n" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
break;
case 3 :
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom1);
siteCodeFr = genericUtility.getColumnValue("site_code__from",dom1);
System.out.println("siteCodeTo="+siteCodeTo+ " siteCodeFr ="+siteCodeFr);
NodeList detail2List = dom2.getElementsByTagName("Detail2");
System.out.println("len==="+detail2List.getLength());
for ( int ctr1 = 0; ctr1 < detail2List.getLength(); ctr1++ ) //Loop for each node of current detail
{
saleOrder = checkNull(genericUtility.getColumnValueFromNode( "sale_order", detail2List.item(ctr1) ));
itemCode = checkNull(genericUtility.getColumnValueFromNode( "item_code", detail2List.item(ctr1) ));
System.out.println("sale_order=="+saleOrder+"itemCode=="+itemCode);
System.out.println("ctr1=="+ctr1);
if(ctr1 > 0)
itemCodeList = itemCodeList + ",'"+saleOrder+itemCode+"'" ;
else
itemCodeList = "'"+saleOrder+itemCode+"'" ;
System.out.println("itemCodeList=="+itemCodeList);
}
/*
for ( int ctr1 = 0; ctr1 < detail2List.getLength(); ctr1++ ) //Loop for each node of current detail
{
saleOrder = checkNull(genericUtility.getColumnValueFromNode( "sale_order", detail2List.item(ctr1) ));
System.out.println("sale_order=="+saleOrder);
System.out.println("ctr1=="+ctr1);
if(ctr1 > 0)
saleOrderList = saleOrderList +","+ "'"+saleOrder+"'" ;
else
saleOrderList = "'"+saleOrder+"'" ;
System.out.println("saleOrderList=="+saleOrderList);
}
*/
//sDateTo = genericUtility.getValidDateString(genericUtility.getColumnValue("date_from",dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
dateFr = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("date_from",dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00");
dateTo = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("date_to",dom1), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00");
StringBuffer argData = new StringBuffer();
argData = new StringBuffer("<?xml version=\"1.0\"?><Root><Header><editFlag>");
argData.append(editFlag).append("</editFlag></Header>");
argData.append("<Detail\r\n>");
argData.append("<date_from>").append(genericUtility.getColumnValue("date_from",dom1)).append("</date_from>\r\n");
argData.append("<date_to>").append(genericUtility.getColumnValue("date_to",dom1)).append("</date_to>\r\n");
argData.append("<item_code_list>").append(itemCodeList).append("</item_code_list>\r\n");
argData.append("<site_code__from>").append(siteCodeFr).append("</site_code__from>\r\n");
argData.append("<site_code__to>").append(siteCodeTo).append("</site_code__to\r\n>");
argData.append("<item_code__from>").append("00").append("</item_code__from>\r\n");
argData.append("<item_code__to>").append("ZZ").append("</item_code__to>\r\n");
argData.append("<item_ser__from>").append("0").append("</item_ser__from>\r\n");
argData.append("<item_ser__to>").append("ZZ").append("</item_ser__to>\r\n");
argData.append("<process_cycle>").append("4").append("</process_cycle>\r\n");
argData.append("<run_date>").append(simpleDateFormat.format(new Date())).append("</run_date>\r\n"); // 01-10-2007
// manoharan
argData.append("<dis_plan>").append("Y").append("</dis_plan>\r\n"); //N
argData.append("<mfg_plan>").append("Y").append("</mfg_plan>\r\n");
argData.append("<mat_plan>").append("Y").append("</mat_plan>\r\n"); // change from N
argData.append("<made_to_stock>").append("1").append("</made_to_stock>\r\n"); //0
argData.append("<made_to_order>").append("0").append("</made_to_order>\r\n");
argData.append("<balance_intersite>").append("N").append("</balance_intersite>\r\n");
argData.append("<gen_ind>").append("Y").append("</gen_ind>\r\n"); //N
argData.append("<wizard>").append("").append("</wizard>\r\n"); //3
argData.append("<sale_order_list>").append(saleOrderList).append("</sale_order_list>\r\n");
argData.append("<verifier>").append("N").append("</verifier>\r\n");
argData.append("</Detail>");
argData.append("</Root>");
System.out.println("argData=="+argData);
argDom = genericUtility.parseString(argData.toString());
RunMRPPrc runMRPObj = new RunMRPPrc();
parentNode = parentNodeList.item(0);
winName = this.getWinName(parentNode);
mrpGetData = runMRPObj.getData(argDom, dom2, winName, xtraParams);
System.out.println("mrpGetData =[" + mrpGetData + "]");
if( mrpGetData != null )
{
System.out.println("@@@@@@@@@ returning mrpGetData------------");
return mrpGetData;
}
//System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ cp code----start@@@@@@@@@");
/*
System.out.println("@@@@@@@@@@@@@@@@@@@final mrpGetData =[" + mrpGetData + "]@@@@@@@@@@@@@@@@@@@@@@");
if (mrpGetData != null && mrpGetData.trim().length() != 0)
{
mrpGetDataDom = genericUtility.parseString(mrpGetData);
}
mrpGetDataList = mrpGetDataDom.getElementsByTagName("Detail2");
System.out.println("len===["+mrpGetDataList.getLength()+"]");
for (int dtlCtr = 0; dtlCtr < mrpGetDataList.getLength(); dtlCtr++)
{
Node detailListNode = mrpGetDataList.item(dtlCtr);
NodeList refrenceList= detailListNode.getChildNodes();
detail2Flag = false;
detail4Flag=false;
keyList = new ArrayList();
valueMap = new HashMap();
ValueList.clear();
if("Detail2".equalsIgnoreCase(detailListNode.getNodeName()))
{
detail2Flag = true;
detail2keyList = new ArrayList();
for (int cntr = 0; cntr < refrenceList.getLength(); cntr++)
{
Node refrenceNode = refrenceList.item(cntr);
orderList = refrenceNode.getChildNodes();
//System.out.println("@@@@@@@@@refrenceNode node name[" + refrenceNode.getNodeName()+"]");
if("reference".equalsIgnoreCase(refrenceNode.getNodeName()))
{
for (int nodCtr = 0; nodCtr < orderList .getLength(); nodCtr++)
{
Node orderNode=orderList.item(nodCtr);
NodeList orderDtlList=orderNode.getChildNodes();
// System.out.println("@@@@@@@@@orderNode node name[" + orderNode.getNodeName()+"]");
if("order".equalsIgnoreCase(orderNode.getNodeName()))
{
for (int cn = 0; cn < orderDtlList .getLength(); cn++)
{
String nodeName=orderDtlList.item(cn).getNodeName();
if("sale_order".equalsIgnoreCase(nodeName))
{
saleOrder = orderDtlList.item(cn).getFirstChild().getNodeValue();
}
if("line_no".equalsIgnoreCase(nodeName))
{
lineNoStr = orderDtlList.item(cn).getFirstChild().getNodeValue();
}
if("qty_reqd".equalsIgnoreCase(nodeName))
{
qtyReqd = orderDtlList.item(cn).getFirstChild().getNodeValue();
}
}
saleOrder = saleOrder==null?" ":saleOrder;
lineNoStr = lineNoStr==null?" ":lineNoStr;
qtyReqd = qtyReqd==null?" ":qtyReqd;
System.out.println("@@@@ctr["+dtlCtr+"]saleOrder["+saleOrder+"]-lineNo["+lineNoStr+"]-qtyReqd["+qtyReqd+"]@@@");
keyList.add(saleOrder+"@"+lineNoStr);
detail2keyList.add(saleOrder+"@"+lineNoStr);
keyList = new ArrayList();
valueMap.put("qty_reqd", qtyReqd);
System.out.println("test");
if( keyMap.get(saleOrder+"@"+lineNoStr) != null)
{
valueList = (ArrayList) keyMap.get(saleOrder+"@"+lineNoStr);
}
valueList.add(valueMap);
keyMap.put(saleOrder+"@"+lineNoStr, valueList );
}
}
}
if("Detail4".equalsIgnoreCase(refrenceNode.getNodeName()))
{
detail4Flag = true;
for (int nodCtr = 0; nodCtr < orderList .getLength(); nodCtr++)
{
Node detail4Node=orderList.item(nodCtr);
NodeList suppDetailList=detail4Node.getChildNodes();
//System.out.println("@@@@@@@@@orderNode node name[" + detail4Node.getNodeName()+"]");
if("supp_detail".equalsIgnoreCase(detail4Node.getNodeName()))
{
for (int cn = 0; cn < suppDetailList .getLength(); cn++)
{
String nodeName=suppDetailList.item(cn).getNodeName();
if("site_code".equalsIgnoreCase(nodeName))
{
siteCodeSupp = suppDetailList.item(cn).getFirstChild().getNodeValue();
}
if("item_code".equalsIgnoreCase(nodeName))
{
itemCodeSupp = suppDetailList.item(cn).getFirstChild().getNodeValue();
}
if("lot_no".equalsIgnoreCase(nodeName))
{
lotNo = suppDetailList.item(cn).getFirstChild().getNodeValue();
}
if("lot_sl".equalsIgnoreCase(nodeName))
{
lotSl = suppDetailList.item(cn).getFirstChild().getNodeValue();
}
if("loc_code".equalsIgnoreCase(nodeName))
{
locCode = suppDetailList.item(cn).getFirstChild().getNodeValue();
}
if("tran_ser".equalsIgnoreCase(nodeName))
{
tranSer = suppDetailList.item(cn).getFirstChild().getNodeValue();
} // tran_id line_no
if("tran_id".equalsIgnoreCase(nodeName))
{
refId = suppDetailList.item(cn).getFirstChild().getNodeValue();
}
if("line_no".equalsIgnoreCase(nodeName))
{
refLineNo = suppDetailList.item(cn).getFirstChild().getNodeValue();
}
}
siteCodeSupp = siteCodeSupp==null?" ":siteCodeSupp;
itemCodeSupp = itemCodeSupp==null?" ":itemCodeSupp;
lotNo = lotNo==null?" ":lotNo;
lotSl = lotSl==null?" ":lotSl;
locCode = locCode==null?" ":locCode;
tranSer = tranSer==null?" ":tranSer;
refId = refId==null?" ":refId;
refLineNo = refLineNo==null?" ":refLineNo;
}
if( "running_supply".equalsIgnoreCase(detail4Node.getNodeName()) )
{
runningSupply = orderList.item(nodCtr).getFirstChild().getNodeValue();
runningSupply = runningSupply==null?" ":runningSupply;
}
}
System.out.println("@@@@ctr["+dtlCtr+"]siteCodeSupp["+siteCodeSupp+"]-itemCodeSupp["+itemCodeSupp+"]-lotNo["+lotNo+"]-lotSl["+lotSl+"]-locCode["+locCode+"]-tranSer["+tranSer+"]@@@");
HashMap tempValueMap = new HashMap();
System.out.println("@@@@@@@@@@@@ for detail2keyList---["+detail2keyList.size()+"]-----");
//ArrayList finalList = null;
if( detail2Flag==false || detail4Flag == false)
{
// detail2keyList.clear();
}
for(int j=0 ; j < detail2keyList.size() ; j++ )
{
String key = detail2keyList.get(j).toString();
//HashMap tempValueMap = new HashMap();
ArrayList tempArrayList = new ArrayList();
tempArrayList = (ArrayList) keyMap.get(key);
for( int tmpListCtr=0; tmpListCtr < tempArrayList.size() ; tmpListCtr ++ )
{
tempValueMap = (HashMap) tempArrayList.get(tmpListCtr);
tempValueMap.put("site_code_supp",siteCodeSupp);
tempValueMap.put("item_code_supp",itemCodeSupp);
tempValueMap.put("lot_no",lotNo);
tempValueMap.put("lot_sl",lotSl);
tempValueMap.put("loc_code",locCode);
tempValueMap.put("tran_ser",tranSer);
tempValueMap.put("running_supply",runningSupply);
tempValueMap.put("ref_id",refId);
tempValueMap.put("ref_line_no",refLineNo);
// System.out.println("@@@@@tempValueMap["+tempValueMap+"]@@@@@@@");
tempArrayList.set(tmpListCtr, tempValueMap);
}
keyMap.put(key, tempArrayList);
// System.out.println("@@@@@keyMap["+keyMap+"]@@@@@@@");
}
}
}
}
}
ArrayList tempList = null;
valueXmlString = new StringBuffer();
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><Header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></Header>");
valueXmlString.append("<Detail3\r\n>");
Set s1=keyMap.entrySet();
Iterator itr=s1.iterator();
System.out.println("@@@@@final---keyMap["+keyMap+"]]");
while(itr.hasNext())
{
//System.out.println("@@@@@final---keyMap["+keyMap+"]@@@@@@@");
Map.Entry m=(Map.Entry)itr.next();
{
//System.out.println("@@@@@@@@@@@m["+m+"]@@@@@@@@@");
tempList = new ArrayList();
String keyListStr = m.getKey().toString();
//System.out.println("@@@@@keyListStr["+keyListStr+"]@@@@["+keyMap.get("076ORE0009@ 1")+"]");
tempList = (ArrayList) keyMap.get(keyListStr);
String[] keyStr = keyListStr.split("@");
String so = keyStr[0];
String soLineNo = keyStr[1];
//System.out.println("@@@@@@@@@@@@tempList["+tempList.size()+"]keyListStr["+keyListStr+"]["+tempList+"]");
if( tempList != null)
{
for( int tempListCtr = 0 ; tempListCtr < tempList.size() ; tempListCtr++ )
{
System.out.println("@@@@@@@@tempListCtr["+tempListCtr+"]");
HashMap innerValueMap = new HashMap();
innerValueMap = (HashMap) tempList.get(tempListCtr);
valueXmlString.append("<sale_order>").append(so).append("</sale_order>\r\n");
valueXmlString.append("<line_no>").append(soLineNo).append("</line_no>\r\n");
valueXmlString.append("<site_code>").append( innerValueMap.get("site_code_supp")==null?" ":innerValueMap.get("site_code_supp").toString()).append("</site_code>\r\n");
valueXmlString.append("<item_code>").append( innerValueMap.get("item_code_supp")==null?" ":innerValueMap.get("item_code_supp").toString()).append("</item_code>\r\n");
valueXmlString.append("<lot_no>").append( innerValueMap.get("lot_no")==null?" ":innerValueMap.get("lot_no").toString()).append("</lot_no>\r\n");
valueXmlString.append("<lot_sl>").append( innerValueMap.get("lot_sl")==null?" ":innerValueMap.get("lot_sl").toString()).append("</lot_sl>\r\n");
valueXmlString.append("<loc_code>").append( innerValueMap.get("loc_code")==null?" ":innerValueMap.get("loc_code").toString()).append("</loc_code>\r\n");
valueXmlString.append("<tran_ser>").append( innerValueMap.get("tran_ser")==null?" ":innerValueMap.get("tran_ser").toString()).append("</tran_ser>\r\n");
valueXmlString.append("<running_supply>").append( innerValueMap.get("running_supply")==null?" ":innerValueMap.get("running_supply").toString()).append("</running_supply>\r\n");
valueXmlString.append("<qty_reqd>").append( innerValueMap.get("qty_reqd")==null?" ":innerValueMap.get("qty_reqd").toString()).append("</qty_reqd>\r\n");
valueXmlString.append("<running_supply>").append( innerValueMap.get("running_supply")==null?" ":innerValueMap.get("running_supply").toString()).append("</running_supply>\r\n");
valueXmlString.append("<qty_reqd>").append( innerValueMap.get("qty_reqd")==null?" ":innerValueMap.get("qty_reqd").toString()).append("</qty_reqd>\r\n");
valueXmlString.append("<ref_id>").append( innerValueMap.get("ref_id")==null?" ":innerValueMap.get("ref_id").toString()).append("</ref_id>\r\n");
valueXmlString.append("<ref_line_no>").append( innerValueMap.get("ref_line_no")==null?" ":innerValueMap.get("ref_line_no").toString()).append("</ref_line_no>\r\n");
}
}
// tempList.clear();
// System.out.println("@@@@@@@@@@@@@@@@@@@@@single line ["+finalDetail3+"]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
}
}
valueXmlString.append("</Detail3>"); valueXmlString.append("</Root>");
System.out.println("@@@@@@@@@@@@@@@@@@@@@final xml ["+valueXmlString+"]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
*/
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ cp code----end@@@@@@@@@");
}
break;
case 4 :
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("@@@@@@@@@@case4 called @@@@@@@@@@@@@");
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
//saleOrder = genericUtility.getColumnValue("sale_order",dom1);
NodeList detail3List = dom2.getElementsByTagName("Detail3");
System.out.println("len==="+detail3List.getLength());
for ( int ctr1 = 0; ctr1 < detail3List.getLength(); ctr1++ ) //Loop for each node of current detail
{
saleOrder = checkNull(genericUtility.getColumnValueFromNode( "sale_order", detail3List.item(ctr1) ));
lineNoStr = checkNull(genericUtility.getColumnValueFromNode( "line_no", detail3List.item(ctr1) ));
saleOrder = checkNull(genericUtility.getColumnValueFromNode( "sale_order", detail3List.item(ctr1) ));
System.out.println("saleOrder=="+saleOrder+"]--lineNoStr["+lineNoStr+"]");
System.out.println("ctr1=="+ctr1);
}
}
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private String setDescription(String field, String table,
String field2, String value,Connection conn) throws SQLException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String descr="",sql="";
sql = "select "+ field +" from "+ table +" where "+ field2 +" = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, value );
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString("descr"));
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("@@@@@@@@cpatil-Descr["+descr+"]");
return descr;
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
private String errorType(Connection conn , String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql); pstmt.setString(1,errorCode);
rs = pstmt.executeQuery();
while(rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e) { e.printStackTrace();
}
}
return msgType;
}
private String getWinName(Node node) throws Exception
{
String objName = "";
NamedNodeMap attrMap = node.getAttributes();
objName = attrMap.getNamedItem("objName").getNodeValue();
System.out.println(" Object Name is==>" + objName);
return "w_" + objName;
}
//}
//}
//}
//}
//}
//}
//}
//}
//}
}
\ No newline at end of file
/********************************************************
Title : RunMRPWizLocal
Date : 27/NOV/13
Developer: Kunal Mandhre
********************************************************/
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
@Local
public interface RunMRPWizLocal extends ValidatorLocal
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
/********************************************************
Title : RunMRPWizRemote
Date : 27/NOV/13
Developer: Kunal Mandhre
********************************************************/
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
@Remote
public interface RunMRPWizRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
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