Commit 82db3309 authored by skumbhar's avatar skumbhar

changes in functionality


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94190 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b8c375ca
......@@ -11,14 +11,17 @@ import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.io.File;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
......@@ -31,6 +34,11 @@ import org.w3c.dom.NodeList;
@Stateless
public class InterCompReconcile extends ValidatorEJB implements InterCompReconcileProcessLocal, InterCompReconcileProcessRemote {
GenericUtility genericUtility = GenericUtility.getInstance();
String userId = null;
String chgUser = null;
String chgTerm = null;
public InterCompReconcile() {
System.out.println("^^^^^^^ inside Inter Compompany Reconciliation ^^^^^^^");
}
......@@ -91,9 +99,6 @@ public class InterCompReconcile extends ValidatorEJB implements InterCompReconci
String errString = "";
String errCode = "";
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
String userId = "",firstValue = "",secondValue = "";
Date tranDate1,tranDate2;
......@@ -222,17 +227,12 @@ public class InterCompReconcile extends ValidatorEJB implements InterCompReconci
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 siteCodeTo = "", siteCodeFr = "", fromTranDate = "", toTranDate = "", insertQuery = "", path = "", objName = "intercomp_reconcile";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0 , currentFormNo = 0 ,lineNo = 0 ,domID = 0;
java.sql.Timestamp dateTo = null ,dateFr = null;
Document argDom = null;
int currentFormNo = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
......@@ -245,7 +245,11 @@ public class InterCompReconcile extends ValidatorEJB implements InterCompReconci
conn.setAutoCommit(false);
connDriver = null;
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "userId");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
......@@ -257,7 +261,8 @@ public class InterCompReconcile extends ValidatorEJB implements InterCompReconci
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength();
System.out.println("DOM2 Elements["+genericUtility.serializeDom(dom2).toString()+"]");
//int childNodeListLength = childNodeList.getLength();
if(currentColumn.trim().equals("itm_default")) {
Calendar cal = Calendar.getInstance();
Date d = new Date();
......@@ -282,83 +287,26 @@ public class InterCompReconcile extends ValidatorEJB implements InterCompReconci
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("DOM2 Elements["+genericUtility.serializeDom(dom2).toString()+"]");
//childNodeListLength = childNodeList.getLength();
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
siteCodeTo = genericUtility.getColumnValue("site_code_to",dom1);
siteCodeFr = genericUtility.getColumnValue("site_code_fr",dom1);
System.out.println("siteCodeTo="+siteCodeTo+ " siteCodeFr ="+siteCodeFr);
fromTranDate = genericUtility.getColumnValue("from_tran_date", dom);
toTranDate = genericUtility.getColumnValue("to_tran_date", dom);
System.out.println("siteCodeTo="+siteCodeTo+ " siteCodeFr ="+siteCodeFr);
String fileName = CommonConstants.JBOSSHOME + File.separator + "sql" + File.separator + "oracle/relatePartyConsoleSupply.xml";
String xmlString = genericUtility.readFile(fileName);
System.out.println("fileName---->" + fileName + "\nxmlString------------------->>>>>>" + xmlString);
path = CommonConstants.JBOSSHOME + File.separator + "sql" + File.separator + "oracle/relatePartyConsoleSupply.sql";
String adpQuery = genericUtility.readFile(path);
insertQuery = "Insert Into Intercomp_Reco_Trace ( Tran_Id,Tran_Date,Ref_Ser,Ref_Id,Ref_Ser__To,Ref_Id__To,Site_Code,Site_Code__To,Amount,Chg_Date,Chg_User,Chg_Term) values (?,?,?,?, ?,?,?,?, ?,?,?,? )";
valueXmlString.append("<site_code_fr><![CDATA[").append(siteCodeFr).append("]]></site_code_fr>");
valueXmlString.append("<site_code_to><![CDATA[").append(siteCodeTo).append("]]></site_code_to>");
valueXmlString.append("<Detail2>");
valueXmlString.append(xmlString);
valueXmlString.append(getXMLTransData(conn,adpQuery,insertQuery,objName,new StringBuffer(genericUtility.serializeDom(dom))));
valueXmlString.append("</Detail2>");
/*parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
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;
}
......@@ -437,7 +385,7 @@ public class InterCompReconcile extends ValidatorEJB implements InterCompReconci
PreparedStatement pstmt = null;
String sql="select count(1) from "+table_name+" where "+whrCondCol+" = ?";
System.out.println("SQL in getDBRowCount method : "+sql);
//System.out.println("SQL in getDBRowCount method : "+sql);
try
{
pstmt = conn.prepareStatement(sql);
......@@ -482,4 +430,147 @@ public class InterCompReconcile extends ValidatorEJB implements InterCompReconci
}
return count;
}
private StringBuffer getXMLTransData(Connection conn, String sql, String insertSql, String objName, StringBuffer stringBuffer) throws Exception
{
StringBuffer valueXmlString = new StringBuffer("");
TransIDGenerator generator = null;
if(conn!=null){
ResultSet rs=null;
PreparedStatement pstmt = null;
int columnCnt = 0;
int columnItr = 0, detailListCnt = 1;
ResultSetMetaData resultSetMetaData = null;
ArrayList<ArrayList<String>> arrayListData = null;
ArrayList<String> traceData = null;
try {
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if ( rs != null ) {
resultSetMetaData = rs.getMetaData();
columnCnt = resultSetMetaData.getColumnCount();
while(rs.next())
{
valueXmlString.append("<Detail domID='"+ detailListCnt++ +"' selected = 'N'>\r\n");
for (columnItr = 1;columnItr <= columnCnt;columnItr++) {
valueXmlString.append("<");
valueXmlString.append(resultSetMetaData.getColumnLabel(columnItr));
valueXmlString.append(">");
valueXmlString.append("<![CDATA[");
valueXmlString.append(rs.getString(columnItr) == null ? "" : rs.getString(columnItr).trim());
valueXmlString.append("]]>");
valueXmlString.append("</");
valueXmlString.append(resultSetMetaData.getColumnLabel(columnItr));
valueXmlString.append(">\r\n");
}
valueXmlString.append("</Detail>\r\n");
}
arrayListData = buildTraceData(rs);
pstmt = null;
rs = null;
}
if(arrayListData != null && arrayListData.size() > 0)
{
String keyString = null;
sql = null;
sql = "SELECT KEY_STRING FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "w_"+objName);
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
rs.close();
}
pstmt = null;
pstmt = conn.prepareStatement(insertSql);
generator = new TransIDGenerator(stringBuffer.toString(),userId,CommonConstants.DB_NAME);
String uniqueKey = generator.generateTranSeqID("INCORE", "tran_id", keyString, conn);
for (int itr = 0;itr < arrayListData.size();itr++) {
traceData = arrayListData.get(itr);
pstmt.setString(1, uniqueKey);
for (int cnt = 0;cnt < traceData.size();cnt++) {
pstmt.setString(cnt+2, traceData.get(cnt));
}
pstmt.addBatch();
}
int rowsInsertedWorkOrder[] = pstmt.executeBatch();
pstmt.close();
conn.commit();
uniqueKey = null;
}
}
catch(SQLException e) {
System.out.println("SQL Exception In getXMLTransData method of InterCompReconcileProcess Class : "+e.getMessage());
e.printStackTrace();
}
catch(Exception ex) {
System.out.println("Exception In getXMLTransData method of InterCompReconcileProcess Class : "+ex.getMessage());
ex.printStackTrace();
} finally {
try{
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
}catch (SQLException se) {
se.printStackTrace();
}
sql = null;
insertSql = null;
objName = null;
stringBuffer = null;
}
}else{
try {
throw new SQLException("Connection passed to InterCompReconcileProcess.getXMLTransData() method is null");
} catch (SQLException e) {
e.printStackTrace();
}
}
return valueXmlString;
}
private ArrayList<ArrayList<String>> buildTraceData(ResultSet rs) throws Exception
{
ArrayList<ArrayList<String>> arrayListData = new ArrayList<ArrayList<String>>();
try {
ArrayList<String> traceData = null;
if ( rs != null ) {
//rs.first();
//System.out.println("Position of RS["+rs.getRow()+"]");
while(rs.next())
{
traceData = new ArrayList<String>();
arrayListData.add(traceData);
}
}
traceData = null;
} catch(SQLException e) {
System.out.println("SQL Exception In getXMLTransData method of InterCompReconcileProcess Class : "+e.getMessage());
e.printStackTrace();
} catch(Exception ex) {
System.out.println("Exception In getXMLTransData method of InterCompReconcileProcess Class : "+ex.getMessage());
ex.printStackTrace();
} finally {
try{
if(rs!=null){
rs.close();
rs = null;
}
}catch (SQLException se) {
se.printStackTrace();
}
}
return arrayListData;
}
}
\ No newline at end of file
......@@ -12,7 +12,6 @@ import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.io.BufferedReader;
import java.io.BufferedWriter;
......@@ -26,14 +25,8 @@ import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import org.w3c.dom.Document;
import javax.ejb.Stateless;
@Stateless
......@@ -43,7 +36,6 @@ public class InterCompReconcileProcess extends ProcessEJB implements InterCompRe
Connection conn = null;
GenericUtility genericUtility = GenericUtility.getInstance();
String userId = null;
String chgUser = null;
String chgTerm = null;
......@@ -75,23 +67,12 @@ public class InterCompReconcileProcess extends ProcessEJB implements InterCompRe
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException, ITMException {
System.out.println("^^^^^^^ Inside InterCompReconcileProcessEJB -> Process Method 2 ^^^^^^^");
String retString = "";//potentialCusB = "", scoreB = "", statusB = "", remarkB = "";
/*String potentialCusC = "", scoreC = "", statusC = "", remarkC = "";
String potentialCusG = "", scoreG = "", statusG = "", remarkG = "";
String custCode = "";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;*/
String retString = "";
PreparedStatement pStmt = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
ConnDriver connDriver = new ConnDriver();
boolean isError = false;
/*boolean okFlag = false;
String custName = "", add1 = "", add2 = "", add3 = "", stanCode = "";
String salesPers = "", panNo = "", voterId = "", aadhaarNo = "", passportNo = "";
boolean insertCustomer = false;*/
try {
System.out.println("getting==================>");
conn = connDriver.getConnectDB("DriverITM");
......@@ -106,204 +87,6 @@ public class InterCompReconcileProcess extends ProcessEJB implements InterCompRe
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
CommonConstants.setIBASEHOME();
/*parentNodeList = detailDom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
for (int i = 0; i < childNodeList.getLength(); i++) {
childNode = childNodeException class is **class java.lang.NullPointerException**
List.item(i);
if ("potential_cus_b".equalsIgnoreCase(childNode.getNodeName())) {
potentialCusB = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("score".equalsIgnoreCase(childNode.getNodeName())) {
scoreB = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("status".equalsIgnoreCase(childNode.getNodeName())) {
statusB = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("remark".equalsIgnoreCase(childNode.getNodeName())) {
remarkB = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("potential_cus_c".equalsIgnoreCase(childNode.getNodeName())) {
potentialCusC = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("score_c".equalsIgnoreCase(childNode.getNodeName())) {
scoreC = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("status_c".equalsIgnoreCase(childNode.getNodeName())) {
statusC = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("remark_c".equalsIgnoreCase(childNode.getNodeName())) {
remarkC = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("potential_cus_g".equalsIgnoreCase(childNode.getNodeName())) {
potentialCusG = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("score_g".equalsIgnoreCase(childNode.getNodeName())) {
scoreG = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("status_g".equalsIgnoreCase(childNode.getNodeName())) {
statusG = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("remark_g".equalsIgnoreCase(childNode.getNodeName())) {
remarkG = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
// else if ("sugg_cust_code".equalsIgnoreCase(childNode.getNodeName())) {
// suggCustCode = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
// }
else if ("app_name_b".equalsIgnoreCase(childNode.getNodeName())) {
custName = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("pre_add1".equalsIgnoreCase(childNode.getNodeName())) {
add1 = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("pre_add2".equalsIgnoreCase(childNode.getNodeName())) {
add2 = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("pre_add3".equalsIgnoreCase(childNode.getNodeName())) {
add3 = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
} else if ("stan_code".equalsIgnoreCase(childNode.getNodeName())) {
stanCode = childNode.getFirstChild() == null ? "" : childNode.getFirstChild().getNodeValue();
}
}
potentialCusB = potentialCusB == null ? "" : potentialCusB.trim();
scoreB = scoreB == null ? "" : scoreB.trim();
statusB = statusB == null ? "" : statusB.trim();
remarkB = remarkB == null ? "" : remarkB.trim();
potentialCusC = potentialCusC == null ? "" : potentialCusC.trim();
scoreC = scoreC == null ? "" : scoreC.trim();
statusC = statusC == null ? "" : statusC.trim();
remarkC = remarkC == null ? "" : remarkC.trim();
potentialCusG = potentialCusG == null ? "" : potentialCusG.trim();
scoreG = scoreG == null ? "" : scoreG.trim();
statusG = statusG == null ? "" : statusG.trim();
remarkG = remarkG == null ? "" : remarkG.trim();
// suggCustCode = suggCustCode == null ? "" : suggCustCode.trim();
custName = custName == null ? "" : custName.trim();
// add1 = add1 == null ? "" : add1.trim();
// add2 = add2 == null ? "" : add2.trim();
// add3 = add3 == null ? "" : add3.trim();
// stanCode = stanCode == null ? "" : stanCode.trim();
if (potentialCusB.length() > 0) {
if ("P".equalsIgnoreCase(statusB)) {
sql = "select pre_add1, pre_add2, pre_add3, stan_code__pre, sales_pers, pan_no, voter_id, aadhaar_no, passport_no, cust_code from f_potential_cus where tran_id = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, potentialCusB);
rs = pStmt.executeQuery();
if (rs.next()) {
add1 = rs.getString(1) == null ? "" : rs.getString(1).trim();
add2 = rs.getString(2) == null ? "" : rs.getString(2).trim();
add3 = rs.getString(3) == null ? "" : rs.getString(3).trim();
stanCode = rs.getString(4) == null ? "" : rs.getString(4).trim();
salesPers = rs.getString(5) == null ? "" : rs.getString(5).trim();
panNo = rs.getString(6) == null ? "" : rs.getString(6).trim();
voterId = rs.getString(7) == null ? "" : rs.getString(7).trim();
aadhaarNo = rs.getString(8) == null ? "" : rs.getString(8).trim();
passportNo = rs.getString(9) == null ? "" : rs.getString(9).trim();
custCode = rs.getString(10) == null ? "" : rs.getString(10).trim();
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
if (custCode.length() > 0) {
int cnt = 0;
sql = " select count(1) from customer where cust_code = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, custCode);
rs = pStmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
if (cnt == 0)
insertCustomer = true;
} else if (custCode.length() == 0) {
insertCustomer = true;
}
InsertIntoCustomerMaster insertIntoCustomerMaster = new InsertIntoCustomerMaster();
ArrayList<String> headerList = new ArrayList<String>();
//headerList.add(0, suggCustCode);
headerList.add(0, "");
headerList.add(1, custName);
headerList.add(2, add1);
headerList.add(3, add2);
headerList.add(4, add3);
headerList.add(5, stanCode);
headerList.add(6, panNo);
headerList.add(7, voterId);
headerList.add(8, aadhaarNo);
headerList.add(9, passportNo);
headerList.add(10, salesPers);
String retCode = "";
if (insertCustomer)
retCode = insertIntoCustomerMaster.insertIntoCustomer(conn, headerList, xtraParams);
else
retCode = custCode;
if ("FAIL".equalsIgnoreCase(retCode)) {
isError = true;
okFlag = false;
} else {
custCode = retCode;
custCode = custCode == null ? "" : custCode.trim();
if (custCode.length() > 0)
okFlag = true;
else
okFlag = false;
}
sql = "update f_potential_cus set cibil_score = ?, cibil_status = ?, cibil_remark = ?, cust_code = ? where tran_id = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, scoreB);
pStmt.setString(2, statusB);
pStmt.setString(3, remarkB);
//pStmt.setString(4, suggCustCode);
pStmt.setString(4, custCode);
pStmt.setString(5, potentialCusB);
pStmt.executeUpdate();
pStmt.close();
pStmt = null;
// okFlag = insertIntoCustomerMaster.insertIntoCustomer(conn, headerList, xtraParams);
// if (!okFlag) {
// isError = true;
// }
}
}
if (okFlag) {
if (potentialCusC.length() > 0) {
sql = "update f_potential_cus set cibil_score = ?, cibil_status = ?, cibil_remark = ? where tran_id = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, scoreC);
pStmt.setString(2, statusC);
pStmt.setString(3, remarkC);
pStmt.setString(4, potentialCusC);
pStmt.executeUpdate();
pStmt.close();
pStmt = null;
}
if (potentialCusG.length() > 0) {
sql = "update f_potential_cus set cibil_score = ?, cibil_status = ?, cibil_remark = ? where tran_id = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, scoreG);
pStmt.setString(2, statusG);
pStmt.setString(3, remarkG);
pStmt.setString(4, potentialCusG);
pStmt.executeUpdate();
pStmt.close();
pStmt = null;
}
GenericClass vfmGenericClass = new GenericClass();
retString = vfmGenericClass.invokeWorkflow(conn, potentialCusB, xtraParams, "w_fpotentialcus", "fpotentialcus");
if ("success".equalsIgnoreCase(retString)) {
retString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWS", "");
return retString;
} else {
retString = new ITMDBAccessEJB().getErrorString("", "VFMWRKFLWF", "");
return retString;
}
}*/
} catch (Exception e) {
isError = true;
retString = itmDBAccessEJB.getErrorString("", "VTCBFAIL", "", "", conn);
......@@ -335,7 +118,7 @@ List.item(i);
ResultSet rs = null;
errString = "";
String adpQuery = null,insertQuery = null,objName = "intercomp_reconcile";
String adpQuery = null;
PreparedStatement pstmt = null;
StringBuffer valueXmlString = new StringBuffer("");
try
......@@ -384,106 +167,6 @@ List.item(i);
writeFile(adpQuery,path + "oracle/relatePartyConsoleSupply.sql");
StringBuffer staticXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
staticXmlString.append("<![CDATA[No]]></editFlag> </header>");
staticXmlString.append("<Detail1>");
staticXmlString.append("<from_tran_date><![CDATA[").append(fromTranDate).append("]]></from_tran_date>");
staticXmlString.append("<to_tran_date><![CDATA[").append(toTranDate).append("]]></to_tran_date>");
staticXmlString.append("<site_code_fr><![CDATA[").append(fromSiteCode).append("]]></site_code_fr>");
staticXmlString.append("<site_code_to><![CDATA[").append(toSiteCode).append("]]></site_code_to>");
staticXmlString.append("</Detail1></Root>");
insertQuery = "Insert Into Intercomp_Reco_Trace ( Tran_Id,Tran_Date,Ref_Ser,Ref_Id,Ref_Ser__To,Ref_Id__To,Site_Code,Site_Code__To,Amount,Chg_Date,Chg_User,Chg_Term) values (?,?,?,?, ?,?,?,?, ?,?,?,? )";
//valueXmlString.append("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
valueXmlString.append(getXMLTransData(conn,adpQuery,insertQuery,objName,staticXmlString));
//valueXmlString.append("</Root>");
writeFile(valueXmlString.toString(),path + "oracle/relatePartyConsoleSupply.xml");
/*pstmt = conn.prepareStatement(adpQuery);
rs = pstmt.executeQuery();
String rsItemCode = "", adpItemcode = "";
while (rs.next())
{
rsItemCode = rs.getString(1);// Added by JIten 02/11/06 as per
// Manoharan Sir
dueDate = rs.getTimestamp(2);
demand = rs.getDouble(3);
supply = rs.getDouble(4);
// 12/04/10 manoharan MF90BHU001 stock and other supply to be
// separated
stockQty = rs.getDouble(5);
othSupply = rs.getDouble(6);
// end 12/04/10 manoharan
// Changes made by Gulzar on 4/18/2012
pendDOQty = rs.getDouble(8);
pendDRQty = rs.getDouble(10);
pendIndQty = rs.getDouble(9);
pendPOQty = rs.getDouble(7);
// End Changes by Gulzar on 4/18/2012
// 18-11-2006 manoharan if dueDate < dateFrom then set the
// dueDate as dateFrom
if (dueDate.compareTo(dateFrom) < 0)
{
dueDate = dateFrom;
}
// end 18-11-2006 manoharan
// if else condition added by Jiten as per Manoharan Sir
// 02/11/06
if (rsItemCode != null && rsItemCode.trim().equalsIgnoreCase(itemCode.trim()))
{
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);
// End Changes by Gulzar on 4/18/2012
} else
{
System.out.println("Site Code :: " + siteCode + " rsItemCode :: " + rsItemCode + " Item Code :: " + itemCode);
int ctr = indexOfADPElement(siteCode, rsItemCode, " ", " ");
// System.out.println("AdpList : "+adpeList.size()+"Index ctr :: "+ctr);//Added
// by Jiten 09/11/06 Sun
if (ctr > 0)
{// if condition added by jiten as per Manoharan Sir
// 10/11/06
ADPElement tempADPElement = (ADPElement) adpeList.get(ctr);
tempADPElement.setDemand(dueDate, demand, " ", " ");
tempADPElement.setSupply(dueDate, supply);
adpeList.set(ctr, tempADPElement);
} else if (ctr == -1)
{// Else if condition added by jiten 10/11/06 as per Tarun
// Bhai to write for skipped item
this.fw1.write(siteCode + " " + itemCode + " " + rsItemCode + "\r\n");
}
}
// End addding
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);
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;*/
} catch (SQLException se)
{
System.out.println("SQLException :InterCompReconcileProcess : populateSQLQuery(ADPElement).." + se.getMessage());
......@@ -508,7 +191,6 @@ List.item(i);
{
rs = null;
}
//this.fw1.flush();// Added by jiten 10/11/06
}
return valueXmlString.toString();
}
......@@ -574,147 +256,4 @@ List.item(i);
throw new ITMException(e);
}
}
private StringBuffer getXMLTransData(Connection conn, String sql, String insertSql, String objName, StringBuffer stringBuffer) throws Exception
{
StringBuffer valueXmlString = new StringBuffer("");
TransIDGenerator generator = null;
if(conn!=null){
ResultSet rs=null;
PreparedStatement pstmt = null;
int columnCnt = 0;
int columnItr = 0, detailListCnt = 1;
ResultSetMetaData resultSetMetaData = null;
ArrayList<ArrayList<String>> arrayListData = null;
ArrayList<String> traceData = null;
try {
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if ( rs != null ) {
resultSetMetaData = rs.getMetaData();
columnCnt = resultSetMetaData.getColumnCount();
while(rs.next())
{
valueXmlString.append("<Detail domID='"+ detailListCnt++ +"' selected = 'N'>\r\n");
for (columnItr = 1;columnItr <= columnCnt;columnItr++) {
valueXmlString.append("<");
valueXmlString.append(resultSetMetaData.getColumnLabel(columnItr));
valueXmlString.append(">");
valueXmlString.append("<![CDATA[");
valueXmlString.append(rs.getString(columnItr) == null ? "" : rs.getString(columnItr).trim());
valueXmlString.append("]]>");
valueXmlString.append("</");
valueXmlString.append(resultSetMetaData.getColumnLabel(columnItr));
valueXmlString.append(">\r\n");
}
valueXmlString.append("</Detail>\r\n");
}
arrayListData = buildTraceData(rs);
pstmt = null;
rs = null;
}
if(arrayListData != null && arrayListData.size() > 0)
{
String keyString = null;
sql = null;
sql = "SELECT KEY_STRING FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "w_"+objName);
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
rs.close();
}
pstmt = null;
pstmt = conn.prepareStatement(insertSql);
generator = new TransIDGenerator(stringBuffer.toString(),userId,CommonConstants.DB_NAME);
String uniqueKey = generator.generateTranSeqID("INCORE", "tran_id", keyString, conn);
for (int itr = 0;itr < arrayListData.size();itr++) {
traceData = arrayListData.get(itr);
pstmt.setString(1, uniqueKey);
for (int cnt = 0;cnt < traceData.size();cnt++) {
pstmt.setString(cnt+2, traceData.get(cnt));
}
pstmt.addBatch();
}
int rowsInsertedWorkOrder[] = pstmt.executeBatch();
pstmt.close();
conn.commit();
uniqueKey = null;
}
}
catch(SQLException e) {
System.out.println("SQL Exception In getXMLTransData method of InterCompReconcileProcess Class : "+e.getMessage());
e.printStackTrace();
}
catch(Exception ex) {
System.out.println("Exception In getXMLTransData method of InterCompReconcileProcess Class : "+ex.getMessage());
ex.printStackTrace();
} finally {
try{
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
}catch (SQLException se) {
se.printStackTrace();
}
sql = null;
insertSql = null;
objName = null;
stringBuffer = null;
}
}else{
try {
throw new SQLException("Connection passed to InterCompReconcileProcess.getXMLTransData() method is null");
} catch (SQLException e) {
e.printStackTrace();
}
}
return valueXmlString;
}
private ArrayList<ArrayList<String>> buildTraceData(ResultSet rs) throws Exception
{
ArrayList<ArrayList<String>> arrayListData = new ArrayList<ArrayList<String>>();
try {
ArrayList<String> traceData = null;
if ( rs != null ) {
rs.first();
while(rs.next())
{
traceData = new ArrayList<String>();
arrayListData.add(traceData);
}
}
traceData = null;
} catch(SQLException e) {
System.out.println("SQL Exception In getXMLTransData method of InterCompReconcileProcess Class : "+e.getMessage());
e.printStackTrace();
} catch(Exception ex) {
System.out.println("Exception In getXMLTransData method of InterCompReconcileProcess Class : "+ex.getMessage());
ex.printStackTrace();
} finally {
try{
if(rs!=null){
rs.close();
rs = null;
}
}catch (SQLException se) {
se.printStackTrace();
}
}
return arrayListData;
}
}
\ No newline at end of file
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