Commit a3b7a33f authored by rzore's avatar rzore

changes made for getting data from sprs_stockist also

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@210157 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 090d8605
......@@ -5,6 +5,7 @@ import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless;
......@@ -59,22 +60,49 @@ public class SprsCustInfo extends ValidatorEJB
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB(tranDb );
sqlCurrYear.append("SELECT SC.SC_CODE AS strg_code " )
.append("FROM STRG_CUSTOMER SC, ")
.append("STRG_SERIES SS " )
.append("WHERE SS.SC_CODE=SC.SC_CODE " )
.append("AND SS.SALES_PERS= '"+empCode+"' " )
.append("AND SS.SC_CODE IN " )
.append("(SELECT SC_CODE " )
.append("FROM STRG_STATUS_HIST " )
.append("WHERE STATUS='Y' " )
.append("AND SALES_PERS=SS.SALES_PERS " )
.append("AND SC_CODE=SC.SC_CODE AND SYSDATE BETWEEN EFF_DATE AND VALID_UPTO) " )
.append("AND SS.STATUS='Y'");
// changes made by rupali on 19/10/19 for getting data from sprs_stockist also [start]
String stockistTable = getSfaParmValue(empCode,"GET_STOCKIST_DETAILS",conn);
if(stockistTable.equalsIgnoreCase("SPRS_STOCKIST"))
{
sqlCurrYear.append("SELECT SC.SC_CODE AS strg_code " )
.append("FROM STRG_CUSTOMER SC, ")
.append("STRG_SERIES SS " )
.append("WHERE SS.SC_CODE=SC.SC_CODE " )
.append("AND SS.SALES_PERS= '"+empCode+"' " )
.append("AND SS.SC_CODE IN " )
.append("(SELECT SC_CODE " )
.append("FROM STRG_STATUS_HIST " )
.append("WHERE STATUS='Y' " )
.append("AND SALES_PERS=SS.SALES_PERS " )
.append("AND SC_CODE=SC.SC_CODE AND SYSDATE BETWEEN EFF_DATE AND VALID_UPTO) " )
.append("AND SS.STATUS='Y' ")
.append("UNION ")
.append("SELECT CUST.CUST_CODE FROM CUSTOMER CUST, SPRS_STOCKIST SS ")
.append("WHERE SS.CUST_CODE = CUST.CUST_CODE AND SS.SPRS_CODE = '"+empCode+"' ")
.append("AND SS.STATUS='Y' ");
}
// changes made by rupali on 19/10/19 for getting data from sprs_stockist also [end]
else
{
sqlCurrYear.append("SELECT SC.SC_CODE AS strg_code " )
.append("FROM STRG_CUSTOMER SC, ")
.append("STRG_SERIES SS " )
.append("WHERE SS.SC_CODE=SC.SC_CODE " )
.append("AND SS.SALES_PERS= '"+empCode+"' " )
.append("AND SS.SC_CODE IN " )
.append("(SELECT SC_CODE " )
.append("FROM STRG_STATUS_HIST " )
.append("WHERE STATUS='Y' " )
.append("AND SALES_PERS=SS.SALES_PERS " )
.append("AND SC_CODE=SC.SC_CODE AND SYSDATE BETWEEN EFF_DATE AND VALID_UPTO) " )
.append("AND SS.STATUS='Y'");
}
System.out.println("SQL QUERY EXECUTED ::::::::::::::::: " + sqlCurrYear );
pStmt = conn.prepareStatement( sqlCurrYear.toString() );
rs = pStmt.executeQuery();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String fromDate = sdf.format(new java.util.Date());
......@@ -261,4 +289,165 @@ public class SprsCustInfo extends ValidatorEJB
return jsonObj;
}
*/
public String getSfaParmValue(String userId,String paramName,Connection connectionObject) throws ITMException//Chnaged by sachin satre on 11-nov-16
{
PreparedStatement pstmt = null;
ResultSet rs = null;
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
String empSite="";
String itemSer="";
String paramValue="";
PreparedStatement allPstmt = null;
ResultSet allRs = null;
boolean isLocalConn =false;
try
{
if(connectionObject == null)
{
connectionObject = getConnection();
isLocalConn =true;
}
String sql = "SELECT SITE_CODE__DEF FROM USERS WHERE CODE = ? ";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if( rs.next() )
{
empSite = checkNull(rs.getString("SITE_CODE__DEF"));
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
String getSalesPerData = " SELECT SALES_PERS.ITEM_SER,ITEMSER.DESCR FROM ITEMSER LEFT OUTER JOIN SALES_PERS ON ITEMSER.ITEM_SER = SALES_PERS.ITEM_SER "+
" WHERE SALES_PERS.SALES_PERS = ? ";
pstmt = connectionObject.prepareStatement(getSalesPerData);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if( rs.next() )
{
itemSer = checkNull(rs.getString("ITEM_SER"));
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
sql=" SELECT PARM_VALUE "+
" FROM SFAPARM "+
" WHERE ORG_UNIT =? "+
" AND ACTIVE='Y' "+
" AND PARM_NAME= ? ";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, empSite+"_"+itemSer);
pstmt.setString(2, paramName);
rs = pstmt.executeQuery();
if(rs.next())
{
paramValue = checkNull(rs.getString(1));
}
else
{
pstmt1 = connectionObject.prepareStatement(sql);
pstmt1.setString(1, itemSer);
pstmt1.setString(2, paramName);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
paramValue = checkNull(rs1.getString(1));
}
else
{
allPstmt = connectionObject.prepareStatement(sql);
allPstmt.setString(1, "ALL");
allPstmt.setString(2, paramName);
allRs = allPstmt.executeQuery();
if(allRs.next())
{
paramValue = checkNull(allRs.getString(1));
}
}
if ( allRs != null )
{
allRs.close();
allRs = null;
}
if ( allPstmt != null )
{
allPstmt.close();
allPstmt = null;
}
if ( rs1 != null )
{
rs1.close();
rs1 = null;
}
if ( pstmt1 != null )
{
pstmt1.close();
pstmt1 = null;
}
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( isLocalConn && connectionObject != null && ! connectionObject.isClosed() )
{
connectionObject.close();
connectionObject = null;
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
return paramValue;
}
}
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