Commit fcbda70e authored by prane's avatar prane

component merged used for mrp enhancement process

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@213437 ce508802-f39f-4f6c-b175-0d175dae99d5
parent aa3aaae3
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
public class InvDemSuppTraceBean
{
/**
* update Demand/Supply data in inv_dem_supp
*
* @param demandSupplyMap HashMap with demand/supply details
* @param conn Database connection
* @return Error code if fails
* @exception ITMException
*/
public String updateDemandSupply(HashMap demandSupplyMap, Connection conn) throws ITMException,Exception
{
String sql = "";
String sqlUpd = "";
String errString = "";
ResultSet rs = null ;
PreparedStatement pstmt = null;
PreparedStatement pstmtUpd = null;
//Timestamp chgDate = new java.sql.Timestamp(System.currentTimeMillis());
E12GenericUtility genericUtility = new E12GenericUtility();
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
Timestamp chgDate = java.sql.Timestamp.valueOf(sdf1.format(new java.util.Date()).toString() + " 00:00:00.0");
BaseLogger.log("3", null, null, ">>>>>>:UPDATE DEMANDSUPPLY MAP::<<<<<<");
BaseLogger.log("3", null, null, ">>>>>>:"+demandSupplyMap);
String siteCode = (String)demandSupplyMap.get("site_code");
String itemCode = (String)demandSupplyMap.get("item_code");
String refSer = (String)demandSupplyMap.get("ref_ser");
String refId = (String)demandSupplyMap.get("ref_id");
String refLine = (String)demandSupplyMap.get("ref_line");
Timestamp dueDate = (Timestamp)demandSupplyMap.get("due_date");
double demandQty = ((Double)demandSupplyMap.get("demand_qty")).doubleValue();
double supplyQty = ((Double)demandSupplyMap.get("supply_qty")).doubleValue();
String changeType = (String)demandSupplyMap.get("change_type");
String chgProcess = (String)demandSupplyMap.get("chg_process");
String chgUser = (String)demandSupplyMap.get("chg_user");
String chgTerm = (String)demandSupplyMap.get("chg_term");
refLine = " " + refLine;
refLine = refLine.substring(refLine.length() - 3, refLine.length());
java.sql.Date tranDate = new java.sql.Date(System.currentTimeMillis());
int updCnt = 0;
int demSuppCnt = 0;
double qtyBefore = 0.0;
double chgQty = 0.0;
double qtyAfter = 0.0;
String tranId = "";
try
{
sql = " select count(1) from INV_DEM_SUPP "
+ " where site_code = ?"
+ " and item_code = ?"
+ " and ref_ser = ?"
+ " and ref_id = ?"
+ " and ref_line = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
pstmt.setString(3,refSer);
pstmt.setString(4,refId);
pstmt.setString(5,refLine);
rs = pstmt.executeQuery();
if(rs.next())
{
demSuppCnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(demSuppCnt > 0)
{
if( demandQty != 0 )
{
sql = "select DEMAND_QTY from INV_DEM_SUPP"
+ " where site_code = ?"
+ " and item_code = ?"
+ " and ref_ser = ?"
+ " and ref_id = ?"
+ " and ref_line = ?";
}
else
{
sql = "select SUPPLY_QTY from INV_DEM_SUPP"
+ " where site_code = ?"
+ " and item_code = ?"
+ " and ref_ser = ?"
+ " and ref_id = ?"
+ " and ref_line = ?";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
pstmt.setString(3,refSer);
pstmt.setString(4,refId);
pstmt.setString(5,refLine);
rs = pstmt.executeQuery();
if(rs.next())
{
qtyBefore = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}// end if(count > 0)
if(demandQty != 0)
{ qtyAfter = qtyBefore + demandQty;
chgQty = demandQty;
}else {
qtyAfter = qtyBefore + supplyQty;
chgQty = supplyQty;
}
if(demSuppCnt > 0)
{
changeType = "C";
sql = "update INV_DEM_SUPP set DEMAND_QTY = DEMAND_QTY + ?, SUPPLY_QTY = SUPPLY_QTY + ? "
+ " where site_code = ?"
+ " and item_code = ?"
+ " and ref_ser = ?"
+ " and ref_id = ?"
+ " and ref_line = ?";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, demandQty);
pstmtUpd.setDouble(2, supplyQty);
pstmtUpd.setString(3,siteCode);
pstmtUpd.setString(4,itemCode );
pstmtUpd.setString(5,refSer);
pstmtUpd.setString(6,refId);
pstmtUpd.setString(7,refLine);
updCnt = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
BaseLogger.log("3", null, null, "INV_DEM_SUPP Updated........>>"+updCnt);
}
else
{
changeType = "A";
sql = "INSERT INTO INV_DEM_SUPP(SITE_CODE, ITEM_CODE, REF_SER, REF_ID, REF_LINE, DUE_DATE, DEMAND_QTY, SUPPLY_QTY, CHG_DATE, CHG_USER, CHG_TERM) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1,siteCode);
pstmtUpd.setString(2,itemCode );
pstmtUpd.setString(3,refSer);
pstmtUpd.setString(4,refId);
pstmtUpd.setString(5,refLine);
pstmtUpd.setTimestamp(6,dueDate);
pstmtUpd.setDouble(7,demandQty);
pstmtUpd.setDouble(8,supplyQty);
pstmtUpd.setTimestamp(9,chgDate);
pstmtUpd.setString(10,chgUser);
pstmtUpd.setString(11,chgTerm);
updCnt = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
BaseLogger.log("3", null, null, "INV_DEM_SUPP insert........>>"+updCnt);
}
sql = "INSERT INTO INV_DEM_SUPP_TRACE (TRAN_ID, TRAN_DATE, SITE_CODE, ITEM_CODE, REF_SER, REF_ID, REF_LINE, CHANGE_TYPE, CHG_PROCESS, CHG_QTY, QTY_BEFORE, QTY_AFTER, CHG_DATE, CHG_USER, CHG_TERM)"
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setString(1,tranId);
pstmtUpd.setDate(2,tranDate);
pstmtUpd.setString(3,siteCode);
pstmtUpd.setString(4,itemCode );
pstmtUpd.setString(5,refSer);
pstmtUpd.setString(6,refId);
pstmtUpd.setString(7,refLine);
pstmtUpd.setString(8,changeType);
pstmtUpd.setString(9,chgProcess );
pstmtUpd.setDouble(10,chgQty);
pstmtUpd.setDouble(11,qtyBefore);
pstmtUpd.setDouble(12,qtyAfter);
pstmtUpd.setTimestamp(13,chgDate);
pstmtUpd.setString(14,chgUser);
pstmtUpd.setString(15,chgTerm);
updCnt = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
BaseLogger.log("3", null, null, "INV_DEM_SUPP_TRACE Updated........"+updCnt);
}
catch(SQLException e)
{
/*try{
conn.rollback();
}catch(Exception ee2)
{
throw new ITMException(ee2);
}*/
BaseLogger.log("0", null, null, "SQLException :updateDemandSupply : " + sqlUpd + "\n" +e.getMessage());
BaseLogger.log("0", null, null, "SITE_CODE : " + siteCode);
BaseLogger.log("0", null, null, "ITEM_CODE : " + itemCode);
BaseLogger.log("0", null, null, "CHANGETYPE : "+ changeType);
BaseLogger.log("0", null, null, "CHGPROCESS : "+ chgProcess);
BaseLogger.log("0", null, null, "REF_SER : " + refSer);
BaseLogger.log("0", null, null, "REF_ID : " + refId);
BaseLogger.log("0", null, null, "REF_LINE : "+ refLine);
//errString = e.getMessage();
errString = sql + siteCode + itemCode + refId + refSer + refLine;
errString = getErrorXML(errString,e.getMessage(), "DS0000", "");
e.printStackTrace();
return errString;
//throw new ITMException(e);
}
catch(Exception e)
{
/*try{
conn.rollback();
}catch(Exception ee2)
{
throw new ITMException(ee2);
}*/
BaseLogger.log("0", null, null, "Exception :updateDemandSupply :" + sqlUpd + "\n" +e.getMessage());
BaseLogger.log("0", null, null, "SITE_CODE : " + siteCode);
BaseLogger.log("0", null, null, "ITEM_CODE : " + itemCode);
BaseLogger.log("0", null, null, "CHANGETYPE : "+ changeType);
BaseLogger.log("0", null, null, "CHGPROCESS : "+ chgProcess);
BaseLogger.log("0", null, null, "REF_SER : " + refSer);
BaseLogger.log("0", null, null, "REF_ID : " + refId);
BaseLogger.log("0", null, null, "REF_LINE : "+ refLine);
//errString = e.getMessage();
errString = siteCode + itemCode + refSer + refId + refLine;
errString = getErrorXML(errString,e.getMessage(), "DS0000", "");
e.printStackTrace();
return errString;
//throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmtUpd != null)
{
pstmtUpd.close();
pstmtUpd = null;
}
}
catch(Exception e)
{
/*try{ conn.rollback();
}catch(Exception ee2){
throw new ITMException(ee2);
}*/
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
public String getErrorXML(String messageValue,String message ,String errorId, String traceInfo) throws RemoteException,ITMException
{
System.out.println("getErrorXML..........");
String errString = "";
try
{
errString = "";
StringBuffer valueXmlErrorString = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<Errors>\r\n" );
valueXmlErrorString.append("<error id=\"").append(errorId).append("\" type=\"E\"").append(" column_name=\"description\"").append(">");
valueXmlErrorString.append("<message><![CDATA[").append(message).append("]]></message>\r\n");
valueXmlErrorString.append("<description><![CDATA[").append(messageValue).append("]]></description>\r\n");
valueXmlErrorString.append("<type>E</type>\r\n");
valueXmlErrorString.append("<option></option>\r\n");
valueXmlErrorString.append("<time></time>\r\n");
valueXmlErrorString.append("<alarm></alarm>\r\n");
valueXmlErrorString.append("<source></source>\r\n");
valueXmlErrorString.append("<trace>Error : "+traceInfo+" </trace>\r\n");
valueXmlErrorString.append("<redirect>1</redirect>\r\n");
valueXmlErrorString.append("</error>\r\n");
valueXmlErrorString.append("</Errors>\r\n");
valueXmlErrorString.append("</Header>\r\n");
valueXmlErrorString.append( "</Root>\r\n" );
System.out.println( "\n****valueXmlErrorString :" + valueXmlErrorString.toString() + ":********" );
errString =valueXmlErrorString.toString();
System.out.println("Modified error string"+errString);
}
catch (Exception ex)
{
ex.printStackTrace();
}
return errString;
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import javax.ejb.Stateless;
@Stateless
public class UpdateDemSuppSummaryIC extends ValidatorEJB implements UpdateDemSuppSummaryICLocal, UpdateDemSuppSummaryICRemote
{
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;
String valueXmlString = "";
System.out.println("\n\nxmlString............."+xmlString);
System.out.println("\n\nxmlString1............"+xmlString1);
System.out.println("\n\nxmlString2............"+xmlString2);
try
{
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 :: InvDemSuppSummaryIC :: itemChanged( String, String ) :==>\n" + e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
E12GenericUtility genericUtility = null;
SimpleDateFormat simpleDateFormat = null;
try
{
genericUtility= new E12GenericUtility();
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:
valueXmlString.append("<Detail1>");
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("0").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("</Detail1>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
System.out.println("Exception :: InvDemSuppSummaryIC :: itemChanged::==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return valueXmlString.toString();
}
}
\ No newline at end of file
/********************************************************
Title : InvDemSuppSummaryICLocal
Date : 19/07/12
Developer: Pavan Rane
********************************************************/
package ibase.webitm.ejb.mfg;
import javax.ejb.*;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import org.w3c.dom.Document;
@Local
public interface UpdateDemSuppSummaryICLocal extends ValidatorLocal
{
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 : InvDemSuppSummaryICRemote
Date : 19/07/12
Developer: Pavan Rane
********************************************************/
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 UpdateDemSuppSummaryICRemote extends ValidatorRemote
{
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;
}
package ibase.webitm.ejb.mfg;
import java.sql.*;
import java.util.*;
import org.w3c.dom.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.utility.BaseLogger;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
import javax.ejb.Stateless;
@Stateless
public class UpdateDemSuppSummaryPrc extends ProcessEJB implements UpdateDemSuppSummaryPrcLocal ,UpdateDemSuppSummaryPrcRemote //SessionBean
{
E12GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = null;
CommonConstants commonConstants = null;
long startTime = 0;
public String process() throws RemoteException,ITMException
{
return "";
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
Document detailDom = null;
Document headerDom = null;
long endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0;
try
{
genericUtility = new E12GenericUtility();
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
}
startTime = System.currentTimeMillis();
retStr = process(headerDom, detailDom, windowName, xtraParams);
endTime = System.currentTimeMillis();
totalTime = endTime - startTime;
BaseLogger.log("2", null, null, "Total Time Spend : " + totalTime + " Milliseconds");
totSecs = (int) (((double) 1 / 1000) * (totalTime));
totalHrs = (int) (totSecs / 3600);
totlMts = (int) (((totSecs - (totalHrs * 3600)) / 60));
totSecs = (int) (totSecs - ((totalHrs * 3600) + (totlMts * 60)));
BaseLogger.log("2", null, null, "Total Time Spend on Process[" + totalHrs + "] Hours [" + totlMts + "] Minutes [" + totSecs + "] seconds");
}
catch (Exception e)
{
BaseLogger.log("0", null, null, "Exception :InvDemSuppSummaryPrc :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
double demand = 0.0;
double supply = 0.0;
int currentRec = 0;
String chgUser = "";
String chgTerm = "";
String itemCode = "";
String tranId = "";
String lineNo = "";
String tranSer = "";
String siteCode = "";
String errString="";
String adpQuery = "";
String siteCodeFrom = "";
String siteCodeTo = "";
String itemCodeFrom= "";
String itemCodeTo = "";
String sDateFrom = "";
String sDateTo = "";
String itemSerFrom = "";
String itemSerTo = "";
String dbDateFrom = "";
String dbDateTo = "";
String standingOrdTypes = "";
String sqlFileName = "";
Timestamp dueDate = null;
ArrayList arrStdOrdType = null;
HashMap demandSupplyMap = null;
InvDemSuppTraceBean invDemSuppTraceBean = null;
Connection conn = null;
try
{
if(conn==null)
{
conn = getConnection();
conn.setAutoCommit(false);
}
genericUtility= new E12GenericUtility();
itmDBAccessEJB = new ITMDBAccessEJB();
commonConstants = new CommonConstants();
invDemSuppTraceBean = new InvDemSuppTraceBean();
demandSupplyMap = new HashMap();
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
siteCodeFrom = genericUtility.getColumnValue("site_code__from", headerDom);
BaseLogger.log("3", null, null, "Site Code From............." + siteCodeFrom);
if (siteCodeFrom == null || siteCodeFrom.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "VPSTCDFR1", "", "", conn);
return errString;
}
siteCodeTo = genericUtility.getColumnValue("site_code__to", headerDom);
BaseLogger.log("3", null, null, "Site Code To..............." + siteCodeTo);
if (siteCodeTo == null || siteCodeTo.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "VPSTCDTO1", "", "", conn);
return errString;
}
itemCodeFrom = genericUtility.getColumnValue("item_code__from", headerDom);
BaseLogger.log("3", null, null, "Item Code From............." + itemCodeFrom);
if (itemCodeFrom == null || itemCodeFrom.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "NULLITMC", "", "", conn);
return errString;
}
itemCodeTo = genericUtility.getColumnValue("item_code__to", headerDom);
BaseLogger.log("3", null, null, "Item Code To............." + itemCodeTo);
if (itemCodeTo == null || itemCodeTo.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "NULLITMC", "", "", conn);
return errString;
}
sDateFrom = genericUtility.getColumnValue("date_from", headerDom);
BaseLogger.log("3", null, null, "From Date............." + sDateFrom);
if (sDateFrom == null || sDateFrom.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "VPFROMBTBK", "", "", conn);
return errString;
}
sDateTo = genericUtility.getColumnValue("date_to", headerDom);
BaseLogger.log("3", null, null, "To Date............." + sDateTo);
if (sDateTo == null || sDateTo.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "BLKTODT", "", "", conn);
return errString;
}
itemSerFrom = genericUtility.getColumnValue("item_ser__from", headerDom);
BaseLogger.log("3", null, null, "Item Series From............." + itemSerFrom);
if (itemSerFrom == null || itemSerFrom.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "VMITMSER1 ", "", "", conn);
return errString;
}
itemSerTo = genericUtility.getColumnValue("item_ser__to", headerDom);
BaseLogger.log("3", null, null, "To Item Series............." + itemSerTo);
if (itemSerTo == null || itemSerTo.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "VMITMSER1 ", "", "", conn);
return errString;
}
sDateFrom = genericUtility.getColumnValue("date_from", headerDom);
sDateTo = genericUtility.getColumnValue("date_to", headerDom);
dbDateFrom = sDateFrom;
dbDateTo = sDateTo;
sDateFrom = genericUtility.getValidDateString(sDateFrom, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
dbDateFrom = genericUtility.getValidDateString(dbDateFrom, genericUtility.getApplDateFormat(), "dd-MMM-yyyy");
BaseLogger.log("3", null, null, "sDateFrom : " + sDateFrom);
//dateFrom = java.sql.Timestamp.valueOf(sDateFrom + " 00:00:00");
sDateTo = genericUtility.getValidDateString(sDateTo, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
dbDateTo = genericUtility.getValidDateString(dbDateTo, genericUtility.getApplDateFormat(), "dd-MMM-yyyy");
//dateTo = java.sql.Timestamp.valueOf(sDateTo + " 00:00:00");
BaseLogger.log("3", null, null, "Db Date from :" + dbDateFrom);
BaseLogger.log("3", null, null, "Db Date to :" + dbDateTo);
standingOrdTypes = itmDBAccessEJB.getEnvDis("999999", "STANDING_ORDTYPES", conn);
if (standingOrdTypes.equals("NULLFOUND")){
standingOrdTypes = "";
}
arrStdOrdType = genericUtility.getTokenList(standingOrdTypes, ",");
standingOrdTypes = "";
for (int index = 0; index < arrStdOrdType.size(); index++)
{
if (index == arrStdOrdType.size() - 1)
{
standingOrdTypes = standingOrdTypes.concat("'").concat((String) arrStdOrdType.get(index)).concat("'");
} else
{
standingOrdTypes = standingOrdTypes.concat("'").concat((String) arrStdOrdType.get(index)).concat("',");
}
}
BaseLogger.log("3", null, null,"Final standingOrdTypes :" + standingOrdTypes);
sqlFileName = CommonConstants.JBOSSHOME + File.separator + "sql" + File.separator + "demandSupplyOverwriteOracle.sql";
BaseLogger.log("9", null, null, "Reading SQL.....adpQuery >>> "+sqlFileName);//NLSQLINPUT
adpQuery = checkNull(readFile(sqlFileName));
BaseLogger.log("9", null, null, "Replacing Values.in SQL.....adpQuery >>> "+adpQuery);
adpQuery = adpQuery.replaceAll("@sitecodeFr@", siteCodeFrom);
adpQuery = adpQuery.replaceAll("@sitecodeTo@", siteCodeTo);
adpQuery = adpQuery.replaceAll("@itemcodeFr@", itemCodeFrom);
adpQuery = adpQuery.replaceAll("@itemcodeTo@", itemCodeTo);
adpQuery = adpQuery.replaceAll("@itemserFr@", itemSerFrom);
adpQuery = adpQuery.replaceAll("@itemserTo@", itemSerTo);
adpQuery = adpQuery.replaceAll("@fromdate@", dbDateFrom);
adpQuery = adpQuery.replaceAll("@todate@", dbDateTo);
adpQuery = adpQuery.replaceAll("@ordtypes@", standingOrdTypes);
BaseLogger.log("9", null, null, "Replacing Values.in SQL.....adpQuery >>> "+adpQuery+"\n\n\n\n");
pstmt = conn.prepareStatement(adpQuery);
rs = pstmt.executeQuery();
while (rs.next())
{
currentRec ++;
BaseLogger.log("2", null, null, ">>>>>>>>>>>>>>>>>>>>>Current ["+currentRec+"]");
itemCode = checkNull(rs.getString("item_code"));
dueDate = rs.getTimestamp("due_date");
demand = rs.getDouble("demand");
supply = rs.getDouble("supply");
tranId = checkNull(rs.getString("tran_id"));
lineNo = checkNull(rs.getString("line_no"));
tranSer = checkNull(rs.getString("tran_ser"));
siteCode = checkNull(rs.getString("site_code"));
demandSupplyMap.put("site_code", siteCode);
demandSupplyMap.put("item_code", itemCode);
demandSupplyMap.put("ref_ser", tranSer);
demandSupplyMap.put("ref_id", tranId);
demandSupplyMap.put("ref_line", lineNo);
demandSupplyMap.put("due_date", dueDate);
demandSupplyMap.put("demand_qty", demand);
demandSupplyMap.put("supply_qty", supply);
demandSupplyMap.put("change_type", "C");
demandSupplyMap.put("chg_process", "P");
demandSupplyMap.put("chg_user", chgUser);
demandSupplyMap.put("chg_term", chgTerm);
//Common component called to overwrite Demand/Supply
errString = invDemSuppTraceBean.updateDemandSupply(demandSupplyMap, conn);
demandSupplyMap.clear();
if(errString != null && errString.trim().length() > 0)
{
BaseLogger.log("2", null, null, "Pavan Afer update errString::>>"+errString+"<<");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
return errString;
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
BaseLogger.log("2", null, null, "Pavan errString::>>"+errString+"<<");
//Error on No data found!
if(currentRec == 0)
{
errString = itmDBAccessEJB.getErrorString( "", "NODATAERR", getUserInfo().getLoginCode(), "", conn );
}
}//outer try
catch (SQLException se)
{
BaseLogger.log("0", null, null, "SQLException :InvDemSuppSummaryPrc : " + "\n" +se.getMessage() );
/*BaseLogger.log("0", null, null, "SITE_CODE : [" + siteCode + "]");
BaseLogger.log("0", null, null, "ITEM_CODE : [" + itemCode + "]");
BaseLogger.log("0", null, null, "TRAN_SER : ["+ tranSer + "]");
BaseLogger.log("0", null, null, "TRAN_ID [: "+ tranId + "]");
BaseLogger.log("0", null, null, "LINE_NO : ["+ lineNo + "]");
BaseLogger.log("0", null, null, "DUE_DATE [: "+ dueDate + "]");
BaseLogger.log("0", null, null, "DEMAND [: "+ demand + "]");
BaseLogger.log("0", null, null, "SUPPLY [: "+ supply + "]");*/
BaseLogger.log("0", null, null, "errString [: "+ errString + "]");
se.printStackTrace();
throw new ITMException(se);
}
catch (Exception e)
{
BaseLogger.log("0", null, null, "Exception :InvDemSuppSummaryPrc : " + adpQuery + "\n" +e.getMessage());
/*BaseLogger.log("0", null, null, "SITE_CODE : [" + siteCode + "]");
BaseLogger.log("0", null, null, "ITEM_CODE : [" + itemCode + "]");
BaseLogger.log("0", null, null, "TRAN_SER : ["+ tranSer + "]");
BaseLogger.log("0", null, null, "TRAN_ID [: "+ tranId + "]");
BaseLogger.log("0", null, null, "LINE_NO : ["+ lineNo + "]");
BaseLogger.log("0", null, null, "DUE_DATE [: "+ dueDate + "]");
BaseLogger.log("0", null, null, "DEMAND [: "+ demand + "]");
BaseLogger.log("0", null, null, "SUPPLY [: "+ supply + "]");*/
BaseLogger.log("0", null, null, "errString [: "+ errString + "]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
BaseLogger.log("0", null, null, "Finally Closing Connection....");
try
{
if(errString == null || errString.trim().length() == 0)
{
if(conn != null)
{
conn.commit();
}
BaseLogger.log("2", null, null, "Connection commit");
errString = itmDBAccessEJB.getErrorString( "", "PROCSUCC", getUserInfo().getLoginCode(), "", conn );
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception se){}
}//
return errString;
}//process()
private String readFile(String file) throws Exception
{
BaseLogger.log("2", null, null, "readFile.....finally called");
String sqlQry = "";
FileInputStream fin = null;
BufferedReader br = null;
try
{
fin = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(fin));
String tempStr = "";
while ((tempStr = br.readLine()) != null)
{
sqlQry = sqlQry + tempStr;
}
} catch (FileNotFoundException fe)
{
BaseLogger.log("0", null, null, "FileNotFoundException :UpdateDemSuppSummaryPrc :readFile(String).." + fe.getMessage());
fe.printStackTrace();
throw new ITMException(fe);
}
catch (Exception e)
{
BaseLogger.log("0", null, null, "Exception :UpdateDemSuppSummaryPrc :readFile(String).." + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if(br != null)
{
br.close();
br = null;
}
if(fin != null)
{
fin.close();
fin = null;
}
}
return sqlQry;
}
// for check null
private String checkNullTrim( String input )
{
return E12GenericUtility.checkNull(input);
}
private String checkNull( String input )
{
if( input == null || "null".equals(input) )
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface UpdateDemSuppSummaryPrcLocal extends ibase.webitm.ejb.ProcessLocal//, EJBObject
{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface UpdateDemSuppSummaryPrcRemote extends ibase.webitm.ejb.ProcessRemote //, EJBObject
{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, 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