Commit 3b33d396 authored by pdas's avatar pdas

REQUEST ID- DI2ASUN029

PB MIGRATION FOR PRICELIST ITEMCHANGE AND CONFIRMATION


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98015 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8042eedf
package ibase.webitm.ejb.dis;
import ibase.utility.EMail;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.mfg.ExplodeBom;
import ibase.webitm.ejb.mfg.adv.RcpBackflushConfirm;
import ibase.webitm.ejb.sys.*;
import ibase.system.config.*;
import ibase.webitm.utility.ITMException;
import java.text.*;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.*;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.dis.*;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import javax.ejb.Stateless;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
//import org.drools.runtime.pipeline.SmooksTransformerProvider;
import org.w3c.dom.*;
import javax.xml.rpc.ParameterMode;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.parsers.*;
import java.text.SimpleDateFormat;
import ibase.utility.CommonConstants;
import ibase.utility.GenericUtility;
import ibase.webitm.ejb.E12CreateBatchLoadEjb;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.sys.CreateRCPXML;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import com.ibm.db2.jcc.b.SQLException;
@Stateless
public class PriceListConf extends ActionHandlerEJB implements PriceListConfLocal, PriceListConfRemote
{
String userId = "", termId = "",lckGroup="" ;
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
CommonConstants commonConstants = new CommonConstants();
ibase.webitm.ejb.sys.UtilMethods utilMethods = ibase.webitm.ejb.sys.UtilMethods.getInstance();
// overloaded method added to call the confirm method from postsave component - 25/11/11 - Gulzar
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String retString = "";
boolean isConn= false;
Connection conn = null;
try
{
retString = confirm( tranID, xtraParams, forcedFlag, conn, isConn );
if ( retString != null && retString.length() > 0 )
{
throw new Exception("Exception while calling confirm for tran Id:["+tranID+"]");
}
}
catch(Exception exception)
{
System.out.println("Exception in [InvHoldConfEJB] getCurrdateAppFormat " + exception.getMessage());
}
return retString;
}
public String confirm(String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus ) throws RemoteException,ITMException
{
PreparedStatement pstmtSql = null;
ResultSet rs = null;
FinCommon finCommon = null;
GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = null;
ValidatorEJB validatorEJB = null;
System.out.println("tran id = "+tranId);
//boolean connStatus=false;
String chgUser="";
String retString = "";
String sql = "";
String conf = "";
String siteRcp = "";
String loginEmpCode = "";
String confirm = "";
try
{
if ( conn == null )
{
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
connStatus = true;
}
finCommon = new FinCommon();
genericUtility = new GenericUtility();
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
loginEmpCode =validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
System.out.println("Printing loginEmpCode---1-----"+loginEmpCode+"--");
sql = "select confirmed,chg_user from pricelist_hdr where tran_id = ?";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1,tranId);
rs = pstmtSql.executeQuery();
if(rs.next())
{
confirm = rs.getString("confirmed") == null ?"N":rs.getString("confirmed");
chgUser = rs.getString("chg_user") == null ?" ":rs.getString("chg_user");
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
if(chgUser==null || chgUser.trim().length()==0)
{
chgUser="SYSTEM";
}
if("null".equalsIgnoreCase(loginEmpCode) || loginEmpCode==null || loginEmpCode.trim().length()==0)
{
sql="select emp_code from users where code=?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setString(1,chgUser);
rs=pstmtSql.executeQuery();
if(rs.next())
{
loginEmpCode=rs.getString(1);
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
System.out.println("Printing loginEmpCode---2-----"+loginEmpCode+"--");
}
if(confirm != null && confirm.equalsIgnoreCase("N"))
{
retString =confirmPlist(tranId,conn, xtraParams);
System.out.println("err String ="+retString);
if(retString != null && retString.trim().length() > 0)
{
return retString;
}
if(retString != null && retString.trim().length() > 0)
{
return retString;
}
if(retString == null || retString.trim().length() == 0)
{
if("null".equalsIgnoreCase(loginEmpCode) || loginEmpCode==null || loginEmpCode.trim().length()==0)
{
loginEmpCode="E03952";
}
System.out.println("loginEmpCode--3-"+loginEmpCode);
sql = "update pricelist_hdr set confirmed = 'Y', conf_date = ?,emp_code__aprv = ? where tran_id = ?";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setDate(1, new java.sql.Date(new java.util.Date().getTime()));
pstmtSql.setString(2, loginEmpCode);
pstmtSql.setString(3, tranId);
int updateCoount = pstmtSql.executeUpdate();
System.out.println("no of row update = "+updateCoount);
pstmtSql.close();
pstmtSql = null;
if(updateCoount > 0)
{
retString = itmDBAccessEJB.getErrorString("","VTCICONF3","","",conn);
}
}
else
{
return retString;
}
}
else
{
System.out.println("The Selected transaction is already confirmed");
retString = itmDBAccessEJB.getErrorString("","VTMCONF1","","",conn);
return retString;
}
System.out.println("115 err String from confirm method.....");
}
/*try
{
if ( conn == null )
{
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
connStatus = true;
}
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
if (userId == null || userId.trim().length() == 0)
{
userId = "SYSTEM";
}
if (termId == null || termId.trim().length() == 0)
{
termId = "SYSTEM";
}
sql = "SELECT CONFIRMED FROM pricelist_hdr WHERE TRAN_ID= ?";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1, tranId);
rs = pstmtSql.executeQuery();
if ( rs.next() )
{
conf = rs.getString("CONFIRMED");
}
if(pstmtSql != null)
{
pstmtSql.close();
pstmtSql = null;
}
if ( rs != null)
{
rs.close();
rs = null;
}
if( conf.equalsIgnoreCase("Y") )
{
retString = itmDBAccessLocal.getErrorString("","VTCONF1","");
return retString;
}
else
{
retString = confirmPlist(tranId,conn, xtraParams);
if (retString == null || retString.trim().length() == 0)
{
////////////////////// EDI creation
String ediOption = "";
String dataStr = "";
sql = "SELECT EDI_OPTION FROM TRANSETUP WHERE TRAN_WINDOW = 'w_pricelist_tran' ";
pstmtSql = conn.prepareStatement(sql);
rs = pstmtSql.executeQuery();
if ( rs.next() )
{
ediOption = rs.getString("EDI_OPTION");
}
rs.close();rs = null;
pstmtSql.close();pstmtSql = null;
if ( "1".equals(ediOption.trim()) )
{
CreateRCPXML createRCPXML = new CreateRCPXML("w_pricelist_tran","tran_id");
dataStr = createRCPXML.getTranXML( tranId, conn );
System.out.println( "dataStr =[ "+ dataStr + "]" );
Document ediDataDom = genericUtility.parseString(dataStr);
E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb();
retString = e12CreateBatchLoad.createBatchLoad( ediDataDom, "w_pricelist_tran", "0", xtraParams, conn );
createRCPXML = null;
e12CreateBatchLoad = null;
if( retString != null && "SUCCESS".equals(retString) )
{
System.out.println("retString from batchload = ["+retString+"]");
}
}
/////////////////////
if( connStatus )//Condition added - 25/11/11 - Gulzar as confirm method is called from post save component
{
conn.commit();
retString = itmDBAccessLocal.getErrorString("","VTMCONF2","");
}
}
else
{
conn.rollback();
}
}
}*/
catch( Exception e)
{
if(conn!=null)
{
try {
conn.rollback();
}
/*catch (SQLException ex)
{
System.out.println("Exception : "+e);
e.printStackTrace();
throw new ITMException(e);
}*/ catch (java.sql.SQLException e1) {
e1.printStackTrace();
}
}
System.out.println("Exception : "+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(retString != null && retString.trim().length() > 0)
{
if( conn != null && !conn.isClosed() && connStatus )
{
if(retString.indexOf("VTCICONF3") > -1)
{
conn.commit();
}
else
{
conn.rollback();
}
conn.close();
conn = null;
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmtSql != null)
{
pstmtSql.close();
pstmtSql = null;
}
//conn.close();
}
catch(Exception e)
{
System.out.println("Exception : "+e);e.printStackTrace();
throw new ITMException(e);
}
}
return retString;
}
private String insertPricelist(String tranId,HashMap PList,ArrayList PricelistGen, Connection conn, String xtraParams) throws RemoteException, ITMException
{
PreparedStatement pstmtSql ,pstmtInsert= null;
ResultSet rs = null;
String dbName = "";
String sql = "";
String retString = "";
String errCode="",AutoExpire="",LotFrBrow="",LotNoToBrow="",LotNoFrom="",OldLotNo="",Set="",NewStr="",OrigStr="",edioption="";
int DayDiff=0;
java.sql.Timestamp ValidUpTo=null,EffDate=null;
int LineNo=0,RowCount=0,Count=0,OldLen=0,New=0;
double SlabNo=0.0;
double NewLen=0.0,slabno=0.0,cnt=0.0;
double MinQtyBrow=0.0;
double MaxQtyBrow=0.0;
double minrate=0.0;
double rate1=0.0;
double minqty=0.0,maxqty=0.0;
String ratetype="";
String refNo1="";
String refNoold1="";
String chgref1="";
double maxrate1=0.0;
String PriceListParent1="",orderType1="";
int Ctr=0,countup=0,Len=0,Len1=0;
java.sql.Timestamp ChgDate=null,efffromdt=null,validupto=null;
java.sql.Timestamp chgDate = null,validupto1=null;
String lotnofr="",lotnoto="",currentlotnofr="",currentlotnoto="",nextlotnofr="",LotNoTo="",currentlotnofrtemp="",currentlotnototemp="";
//String LotNoFrom="",LotNoTo="";
boolean recordfound;
//HashMap PlGen=null;
String plist="",itemcode="",unit="",listtype="";
String plist1="",refNoold="";
int cnt1=0,UpdCnt=0;
String LotNoFroma[] = null, LotNoToa[]=null;
char left1=0,left2=0,left3 = 0,left4=0;
int updCnt = 0;
String mid1="",mid2="",mid3="",mid4="";
java.text.SimpleDateFormat sdf = null;
String lotnofrom="",lotnoto1="";
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
termId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "termId" );
try
{
DistCommon distCommon = new DistCommon();
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
dbName = CommonConstants.DB_NAME;
System.out.println("Insert Price List@@@@@@@@@@@");
AutoExpire=distCommon.getDisparams("999999","AUTO_EXPIRE_PL", conn);
System.out.println("Autoexpire Value is:"+AutoExpire);
if (AutoExpire == null)
{
AutoExpire = "";
}
else if(AutoExpire.equalsIgnoreCase("Y"))
{
System.out.println("Insert Autoexpire@@@@@@@@@");
//PList=new HashMap();
plist = (String)PList.get("price_list");
System.out.println("Price list value is"+plist);
itemcode = (String)PList.get("item_code");
System.out.println("item code in price list"+itemcode);
unit = (String)PList.get("unit");
listtype = (String)PList.get("list_type");
//rate1=(Double)PList.get("rate");
//ratetype=(String)PList.get("rate_type");
//minrate=(Double)PList.get("min_rate");
//maxrate1=(Double)PList.get("max_rate");
//refNo1=(String)PList.get("ref_No");
//refNoold1=(String)PList.get("ref_No_old");
//PriceListParent1=(String)PList.get("Price_List__Parent");
//orderType1=(String)PList.get("order_Type");
//chgref1=(String)PList.get("chg_ref_no");
PricelistGen.add(PList);
lotnofrom=(String)PList.get("lot_no__from");
System.out.println("lot no from "+lotnofrom);
lotnoto1=(String)PList.get("lot_no__to");
System.out.println("lot no to "+lotnoto1);
validupto1=(java.sql.Timestamp)PList.get("valid_upto");
System.out.println("List Sizeeeeeee"+PricelistGen.size());
minqty=(Double)PList.get("min_qty");
System.out.println("min qty in list"+minqty);
maxqty=(Double)PList.get("max_qty");
sql="select valid_upto,eff_from,slab_no,lot_no__from,lot_no__to,min_qty,max_qty from pricelist where price_list=? and item_code=? ";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1,plist);
pstmtSql.setString(2,itemcode);
rs = pstmtSql.executeQuery();
for (Ctr =0; Ctr < PricelistGen.size(); Ctr++)
{
System.out.println("Insert For loooopppp");
PList=new HashMap();
PList = (HashMap)PricelistGen.get(Ctr);
if(rs.next())
{
ValidUpTo=rs.getTimestamp("valid_upto");
System.out.println("Valid upto in price list"+ValidUpTo);
EffDate=rs.getTimestamp("eff_from");
SlabNo=rs.getDouble("slab_no");
System.out.println("slabbbb_no1111111111111111111111"+SlabNo);
LotFrBrow=rs.getString("lot_no__from");
LotNoToBrow=rs.getString("lot_no__to");
MinQtyBrow=rs.getDouble("min_qty");
MaxQtyBrow=rs.getDouble("max_qty");
System.out.println("Minimum value is@@@@@@@@@"+MinQtyBrow);
}
System.out.println("check if conditionn");
DayDiff=(int)utilMethods.DaysAfter(ValidUpTo,validupto1);
System.out.println("check"+DayDiff);
if(DayDiff<=0 && LotFrBrow.trim()== lotnofrom && LotNoToBrow.trim()==lotnoto1)
{
ValidUpTo=utilMethods.RelativeDate((java.sql.Timestamp)PList.get("eff_from"), -1 );
if( dbName.equalsIgnoreCase("db2"))
{
//validupto=new java.sql.Timestamp(System.currentTimeMillis());
//sdf = new java.text.SimpleDateFormat(genericUtility
// .getApplDateFormat());
//=sdf.format(ValidUpTo);
//validupto=datetime(ValidUpTo);
sql="update pricelist set valid_upto = ? where price_list =? and item_code = ? and unit = ? and list_type = ? and slab_no = ?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, validupto);
pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit);
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, SlabNo);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
else
{
sql="update pricelist set valid_upto = ? where price_list =? and item_code = ? and unit = ? and list_type = ? and slab_no = ?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, ValidUpTo);
pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit);
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, SlabNo);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
}
}// for end
}// end autoexpire if
///////////////
// astr_PL.list_type = 'B'
listtype = (String)PList.get("list_type");
System.out.println("check price listttttttttttttttt type"+listtype);
if(listtype.equalsIgnoreCase("B"))
{
LotNoFrom=(String)PList.get("lot_no__from");
System.out.println("@@@@@lot number from"+LotNoFrom);
sql="select count(1) from pricelist where price_list = ? and item_code = ? and unit = ? and list_type = ? and lot_no__from <= ? and lot_no__to >= ? and min_qty <= ? and max_qty >= ?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setString(1,plist);
pstmtSql.setString(2,itemcode);
pstmtSql.setString(3,unit);
pstmtSql.setString(4,listtype);
pstmtSql.setString(5,lotnofrom);
pstmtSql.setString(6,lotnoto1);
pstmtSql.setDouble(7,minqty);
pstmtSql.setDouble(8,maxqty);
rs=pstmtSql.executeQuery();
if(rs.next())
{
Count=rs.getInt(1);
}
System.out.println("llCount-------->>["+Count+"]");
if(rs != null)
{
rs.close();
rs=null;
}
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
if(Count > 0)
{
System.out.println("insert in count");
Len=LotNoFrom.trim().length();
Ctr=1;
String s2=LotNoFrom.trim();
System.out.println("s22222222222222"+s2);
String mid="";
char left=0;
char right= s2.charAt(s2.length()-1);
System.out.println("right s22222222222222"+right);
if(Character.isDigit(right) )
{
do
{
if(Character.isDigit(right))
{
left=s2.charAt(0);
System.out.println("left s222222222222"+left);
if(left =='0')
{
if(s2.length()>2)
{
mid=s2.substring(2);
System.out.println("middle s2222222222"+mid);
Set=Set + '0';
}
}
else
{
OldLen = LotNoFrom.trim().length();
New = OldLen - 1;
String new1=Integer.toString(New);
NewLen = new1.trim().length();
if(OldLen != NewLen);
{
int diff3=(int) (OldLen - NewLen);
for(int s3=0;s3<diff3;s3++)
{
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String"+NewStr);
}
}
}
}
else
{
OrigStr = Character.toString(left);
Set = Set + OrigStr;
LotNoFrom = (mid + 1);
}
Ctr++;
}while(Ctr<=Len);
if(New==0)
{
LotNoFrom = Set +NewStr.trim();
}
else
{
String a1=Integer.toString(New);
LotNoFrom = Set + NewStr.trim() +a1.trim();
}
sql="update pricelist set lot_no__to = ? where price_list = ? and item_code = ? and unit = ? and list_type = ? and lot_no__from <= ? and lot_no__to >= ? and min_qty <= ? and max_qty >= ?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setString(1,LotNoFrom);
pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit);
pstmtSql.setString(5,listtype);
pstmtSql.setString(6, lotnofrom);
pstmtSql.setString(7, lotnoto1);
pstmtSql.setDouble(8, minqty);
pstmtSql.setDouble(9, maxqty);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated@@@@@@@@------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}//end if
}
}
//to expire the pricelist in case of revise circular of old circular.
//change the valid upto date of price before the eff from date and batch no less then the
//plist1 = (String)PList.get("price_list");
refNoold=(String)PList.get("ref_no_old");
if(listtype.equalsIgnoreCase("B"))
{
LotNoFrom=(String)PList.get("lot_no__from");
System.out.println("@@@@@lot number from"+LotNoFrom);
if(refNoold !=null && refNoold.trim().length() > 0)
{
sql="select count(*) from pricelist where price_list= ? and item_code = ? and unit = ? and lot_no__from >= ? and list_type = ? and min_qty >= ? and max_qty <= ? and ref_no = ?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setString(1, plist);
pstmtSql.setString(2, itemcode);
pstmtSql.setString(3, unit);
pstmtSql.setString(4, lotnofrom);
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, minqty);
pstmtSql.setDouble(7, maxqty);
pstmtSql.setString(8, refNoold);
rs = pstmtSql.executeQuery();
System.out.println("COUNT"+countup);
if (rs.next())
{
countup = rs.getInt(1);
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
}
else
{
sql="select count(*) from pricelist where price_list= ? and item_code = ? and unit = ? and lot_no__from >= ? and list_type = ? and min_qty >= ? and max_qty <= ? and ref_no is null ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setString(1, plist);
pstmtSql.setString(2, itemcode);
pstmtSql.setString(3, unit);
pstmtSql.setString(4, lotnofrom);
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, minqty);
pstmtSql.setDouble(7, maxqty);
pstmtSql.setString(8, refNoold);
rs = pstmtSql.executeQuery();
System.out.println("COUNT"+countup);
if (rs.next())
{
countup = rs.getInt(1);
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
}
if(countup>0)
{
if(refNoold !=null && refNoold.trim().length() > 0)
{
sql="select slab_no,eff_from ,lot_no__from from pricelist where price_list = ? and item_code = ? and unit = ? and lot_no__from >= ? and list_type = ? and min_qty >= ? and max_qty <= ? and ref_no = ?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setDouble(1, slabno);
pstmtSql.setTimestamp(2, efffromdt);
pstmtSql.setString(3, LotNoFrom);
rs = pstmtSql.executeQuery();
if (rs.next())
{
plist=rs.getString(1);
itemcode=rs.getString(2);
unit=rs.getString(3);
lotnofrom=rs.getString(4);
listtype=rs.getString(5);
minqty=rs.getDouble(6);
maxqty=rs.getDouble(7);
refNoold=rs.getString(8);
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
}
else
{
sql="select slab_no,eff_from ,lot_no__from from pricelist where price_list = ? and item_code = ? and unit = ? and lot_no__from >= ? and list_type = ? and min_qty >= ? and max_qty <= ? and ref_no is null";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setDouble(1, slabno);
pstmtSql.setTimestamp(2, efffromdt);
pstmtSql.setString(3, lotnofrom);
rs = pstmtSql.executeQuery();
if (rs.next())
{
plist=rs.getString(1);
itemcode=rs.getString(2);
unit=rs.getString(3);
LotFrBrow=rs.getString(4);
listtype=rs.getString(5);
minqty=rs.getDouble(6);
maxqty=rs.getDouble(7);
refNoold=rs.getString(8);
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
}
ValidUpTo=utilMethods.RelativeDate((java.sql.Timestamp)PList.get("eff_from"), -1 );
Len=LotNoFrom.trim().length();
String s=LotNoFrom.trim();
System.out.println("String s"+s);
Ctr=1;
OrigStr="";
Set = "";
NewStr = "";
char right1= s.charAt(s.length()-1);
// char lotnoform=LotNoFrom .charAt(Len-1);
//LotNoFrom.sub
if(Character.isDigit(right1) )
{
do
{
if(Character.isDigit(right1) )
{
left1=s.charAt(0);
if(left1=='0')
{
if(s.length() > 2)
{
mid1= s.substring(2);
Set=Set + '0';
}
}
else
{
OldLen = LotNoFrom.trim().length();
New = OldLen - 1;
String new1=Integer.toString(New);
NewLen = new1.trim().length();
if(OldLen != NewLen);
{
int diff2=(int) (OldLen - NewLen);
for(int s2=0;s2<diff2;s2++)
{
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String"+NewStr);
}
}
}
}
else
{
OrigStr = Character.toString(left1);
Set = Set + OrigStr;
LotNoFrom = (mid1+ 1);
}
Ctr++;
}while(Ctr <= Len);
if(New==0)
{
LotNoFrom = Set +NewStr.trim();
}
else
{
String a1=Integer.toString(New);
LotNoFrom = Set + NewStr.trim() +a1.trim();
}
if( dbName.equalsIgnoreCase("db2"))
{
//validupto=datetime(ValidUpTo);
if(refNoold !=null && refNoold.trim().length() > 0)
{
sql="update pricelist set valid_upto = ? lot_no__to = ? where price_list = ? and item_code = ? and unit =? and list_type = ? and min_qty >= ? and max_qty <= ? and slab_no = ? and ref_no =?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, validupto);
pstmtSql.setString(2, LotNoFrom);
pstmtSql.setString(3, plist);
pstmtSql.setString(4, itemcode);
pstmtSql.setString(5, unit);
pstmtSql.setString(6, listtype);
pstmtSql.setDouble(7, minqty);
pstmtSql.setDouble(8, maxqty);
pstmtSql.setDouble(9, SlabNo);
pstmtSql.setString(10, refNoold);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated11111111111------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
else
{
sql="update pricelist set valid_upto = ? lot_no__to = ? where price_list = ? and item_code = ? and unit =? and list_type = ? and min_qty >= ? and max_qty <= ? and slab_no = ? and ref_no is null ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, validupto);
pstmtSql.setString(2, LotNoFrom);
pstmtSql.setString(3, plist);
pstmtSql.setString(4, itemcode);
pstmtSql.setString(5, unit);
pstmtSql.setString(6, listtype);
pstmtSql.setDouble(7, minqty);
pstmtSql.setDouble(8, maxqty);
pstmtSql.setDouble(9, SlabNo);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated11111111111------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
}
else
{
if(refNoold !=null && refNoold.trim().length() > 0)
{
sql="update pricelist set valid_upto = ? lot_no__to = ? where price_list = ? and item_code = ? and unit =? and list_type = ? and min_qty >= ? and max_qty <= ? and slab_no = ? and ref_no =?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1,ValidUpTo);
pstmtSql.setString(2, LotNoFrom);
pstmtSql.setString(3, plist);
pstmtSql.setString(4, itemcode);
pstmtSql.setString(5, unit);
pstmtSql.setString(6, listtype);
pstmtSql.setDouble(7, minqty);
pstmtSql.setDouble(8, maxqty);
pstmtSql.setDouble(9, SlabNo);
pstmtSql.setString(10, refNoold);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated11111111111------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
else
{
sql="update pricelist set valid_upto = ? ,lot_no__to = ? where price_list = ? and item_code = ? and unit =? and list_type = ? and min_qty >= ? and max_qty <= ? and slab_no = ? and ref_no is null ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, ValidUpTo);
pstmtSql.setString(2, LotNoFrom);
pstmtSql.setString(3, plist);
pstmtSql.setString(4, itemcode);
pstmtSql.setString(5, unit);
pstmtSql.setString(6, listtype);
pstmtSql.setDouble(7, minqty);
pstmtSql.setDouble(8, maxqty);
pstmtSql.setDouble(9, SlabNo);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated11111111111------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
}
}
}
}
recordfound = false;
if(listtype.equalsIgnoreCase("B"))
{
LotNoFrom=(String)PList.get("lot_no__from");
System.out.println("@@@@@lot number from2222222222222"+LotNoFrom);
sql="select count(1) from pricelist where price_list = ? and item_code = ? and unit = ? and list_type = ? and lot_no__from <= ? and lot_no__to >= ? and min_qty <= ? and max_qty >= ?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setString(1,plist);
pstmtSql.setString(2,itemcode);
pstmtSql.setString(3,unit);
pstmtSql.setString(4,listtype);
pstmtSql.setString(5,LotFrBrow);
pstmtSql.setString(6,LotNoToBrow);
pstmtSql.setDouble(7,minqty);
pstmtSql.setDouble(8,maxqty);
rs=pstmtSql.executeQuery();
if(rs.next())
{
cnt=rs.getInt(1);
}
System.out.println("llCount22222222222-------->>["+cnt+"]");
if(rs != null)
{
rs.close();
rs=null;
}
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
if(cnt > 0)
{
LotNoFrom=(String)PList.get("lot_no__from");
LotNoTo=(String)PList.get("lot_no__to");
nextlotnofr=LotNoFrom;
sql="select lot_no__from, lot_no__to from pricelist where price_list = ? and item_code = ? and unit = ? and list_type = ? and lot_no__from <= ? and lot_no__to >= ? and min_qty <= ? and max_qty >= ? order by lot_no__from";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setString(1,plist);
pstmtSql.setString(2,itemcode);
pstmtSql.setString(3,unit);
pstmtSql.setString(4,listtype);
pstmtSql.setString(5,lotnofrom);
pstmtSql.setString(6,LotNoToBrow);
pstmtSql.setDouble(7,minqty);
pstmtSql.setDouble(8,maxqty);
rs=pstmtSql.executeQuery();
while(rs.next())
{
currentlotnofr=rs.getString(1);
currentlotnoto=rs.getString(2);
}
recordfound = true;
currentlotnofrtemp = currentlotnofr;
currentlotnototemp= currentlotnoto;
Len=currentlotnofr.trim().length();
Ctr =1;
OrigStr = "";
Set ="";
NewStr ="";
New = 0;
String x=LotNoFrom.trim();
System.out.println("@@@@@x"+x);
String y=currentlotnofr.trim();
System.out.println("@@@@@x"+y);
if(x.length()<y.length())
{
char right3= y.charAt(y.length()-1);
if(Character.isDigit(right3) )
{
do
{
if(Character.isDigit(right3) )
{
left3=y.charAt(0);
if(left3=='0')
{
if(y.length()>2)
{
mid3= y.substring(2);
Set=Set + '0';
}
}
else
{
OldLen = currentlotnofr.trim().length();
New = OldLen - 1;
String new1=Integer.toString(New);
NewLen = new1.trim().length();
if(OldLen != NewLen);
{
int diff1=(int) (OldLen - NewLen);
for(int s=0;s<diff1;s++)
{
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String"+NewStr);
}
}
}
}
else
{ OrigStr = Character.toString(left3);
Set = Set + OrigStr;
LotNoFrom = (mid3 + 1);
}
Ctr++;
}while(Ctr <= Len);
// lotnoto = Set + trim(ls_NewStr) +string(ll_New)
//ls_lot_no__fr = ls_next_lot_no_fr
String a2=Integer.toString(New);
lotnoto = Set + NewStr.trim() +a2.trim();
lotnofr = nextlotnofr;
}
}
Len1=currentlotnoto.trim().length();
Ctr =1;
OrigStr = "";
Set ="";
NewStr ="";
New = 0;
String p=LotNoFrom.trim();
String q=currentlotnofr.trim();
if(p.length()<q.length())
{
char right4= y.charAt(y.length()-1);
if(Character.isDigit(right4) )
{
do
{
if(Character.isDigit(right4) )
{
left4 =y.charAt(0);
if(left4=='0')
{
if(y.length()>2)
{
mid4= y.substring(2);
Set=Set + '0';
}
}
else
{
OldLen = currentlotnoto.trim().length();
New = OldLen - 1;
String new1=Integer.toString(New);
NewLen = new1.trim().length();
if(OldLen != NewLen);
{
int diff=(int) (OldLen - NewLen);
for(int s=0;s<diff;s++)
{
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String"+NewStr);
}
//NewStr = fill('0',OldLen - NewLen);
}
}
}
else
{ OrigStr = Character.toString(left4);
Set = Set + OrigStr;
LotNoFrom = (mid4+ 1);
}
Ctr++;
}while(Ctr <= Len);
// lotnoto = Set + trim(ls_NewStr) +string(ll_New)
//ls_lot_no__fr = ls_next_lot_no_fr
String a2=Integer.toString(New);
lotnofr = Set + NewStr.trim() +a2.trim();
lotnofr = nextlotnofr;
}
}
int temp=0;
if(currentlotnofrtemp != LotNoFrom)
{
temp =Integer.parseInt(LotNoFrom);
int temp1=Integer.parseInt(LotNoTo);
nextlotnofr=LotNoFroma[temp]+1;
lotnoto=LotNoToa[temp1]+1;
}
//int tempnew=0;
/* if(currentlotnototemp <= LotNoTo)
{
tempnew =Integer.parseInt(LotNoFrom);
int temp2=Integer.parseInt(LotNoTo);
nextlotnofr=LotNoFroma[temp]+1;
lotnoto=LotNoToa[temp2]+1;
}*/
for(int i=1;i<temp;i++)
{
lotnofr = LotNoFroma[i];
lotnoto = LotNoToa[i];
sql="select max(slab_no) from pricelist where price_list = ? AND item_code = ? ";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1, plist);
pstmtSql.setString(2, itemcode);
rs = pstmtSql.executeQuery();
if ( rs.next() )
{
LineNo = rs.getInt(1);
System.out.println("line no@@@@@@@"+LineNo);
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
if( LineNo == 0)
{
System.out.println("Insert line no");
LineNo++;
sql="insert into pricelist (price_list, item_code,unit,list_type,slab_no,eff_from,valid_upto,lot_no__from,lot_no__to,min_qty,max_qty,rate,rate_type,min_rate,chg_date,chg_user,chg_term,max_rate,order_type, price_list__parent, chg_ref_no, ref_no,ref_no_old )" +
"VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmtInsert = conn.prepareStatement(sql);
pstmtInsert.setString(1, plist);
pstmtInsert.setString(2, itemcode);
pstmtInsert.setString(3, unit);
pstmtInsert.setString(4, listtype);
pstmtInsert.setDouble(5, LineNo);
pstmtInsert.setTimestamp(6, validupto1);
pstmtInsert.setTimestamp(7, ValidUpTo);
pstmtInsert.setString(8,lotnofr);
pstmtInsert.setString(9, lotnoto);
pstmtInsert.setDouble(10, minqty);
pstmtInsert.setDouble(11, maxqty);
pstmtInsert.setDouble(12, rate1);
pstmtInsert.setString(13, ratetype);
pstmtInsert.setDouble(14, minrate);
chgDate = new java.sql.Timestamp(System.currentTimeMillis());
pstmtInsert.setTimestamp(15, chgDate);
pstmtInsert.setString(16, userId);
pstmtInsert.setString(17, termId);
pstmtInsert.setDouble(18, maxrate1);
pstmtInsert.setString(19, orderType1);
pstmtInsert.setString(20, PriceListParent1);
pstmtInsert.setString(21, chgref1);
pstmtInsert.setString(22, refNo1);
pstmtInsert.setString(23, refNoold1);
UpdCnt = pstmtInsert.executeUpdate();
pstmtInsert.close();
pstmtInsert = null;
}
}
}
}
if(LineNo == 0)
{
sql="select max(slab_no) from pricelist where price_list = ? AND item_code = ? ";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1, plist);
pstmtSql.setString(2, itemcode);
rs = pstmtSql.executeQuery();
if ( rs.next() )
{
LineNo = rs.getInt(1);
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
}
System.out
.println("Record found@@@@@@@@@@@@@"+recordfound);
if(recordfound == false)
{
LineNo++;
sql="insert into pricelist (price_list,item_code,unit,list_type,slab_no,eff_from,valid_upto,lot_no__from,lot_no__to,min_qty,max_qty,rate,rate_type,min_rate,chg_date,chg_user,chg_term,max_rate,order_type,price_list__parent, chg_ref_no, ref_no,ref_no_old )" +
"VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmtInsert = conn.prepareStatement(sql);
pstmtInsert.setString(1, plist);
pstmtInsert.setString(2, itemcode);
pstmtInsert.setString(3, unit);
pstmtInsert.setString(4, listtype);
pstmtInsert.setDouble(5, slabno);
pstmtInsert.setTimestamp(6, EffDate);
pstmtInsert.setTimestamp(7, ValidUpTo);
pstmtInsert.setString(8,lotnofr);
pstmtInsert.setString(9, lotnoto);
pstmtInsert.setDouble(10, minqty);
pstmtInsert.setDouble(11, maxqty);
pstmtInsert.setDouble(12, rate1);
pstmtInsert.setString(13, ratetype);
pstmtInsert.setDouble(14, minrate);
chgDate = new java.sql.Timestamp(System.currentTimeMillis());
pstmtInsert.setTimestamp(15, chgDate);
pstmtInsert.setString(16, userId);
pstmtInsert.setString(17, termId);
pstmtInsert.setDouble(18, maxrate1);
pstmtInsert.setString(19, orderType1);
pstmtInsert.setString(20, PriceListParent1);
pstmtInsert.setString(21, chgref1);
pstmtInsert.setString(22, refNo1);
pstmtInsert.setString(23, refNoold1);
UpdCnt = pstmtInsert.executeUpdate();
pstmtInsert.close();
pstmtInsert = null;
}
System.out.println("Insert completed");
chgDate = new java.sql.Timestamp(System.currentTimeMillis());
String sql1="update pricelist set chg_user =?,chg_term = ?,chg_date = ? where price_list =? and item_code=? and unit = ? and list_type =?";
pstmtSql = conn.prepareStatement(sql1);
chgDate = new java.sql.Timestamp(System.currentTimeMillis());
pstmtSql.setString(1, userId);
pstmtSql.setString(2, termId);
pstmtSql.setTimestamp(3, chgDate);
pstmtSql.setString(4,plist);
pstmtSql.setString(5,itemcode);
pstmtSql.setString(6, unit);
pstmtSql.setString(7, listtype);
updCnt = pstmtSql.executeUpdate();
pstmtSql.close();
pstmtSql = null;
}//try end
catch(Exception e)
{
System.out.println(e.getMessage());
System.out.println("Exception : "+e);
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
public String confirmPlist(String tranId, Connection conn, String xtraParams) throws RemoteException, ITMException
{
PreparedStatement pstmtSql = null;
ResultSet rs = null;
String sql = "";
String dbName = "";
String retString = "";
String errCode="", priceList="",confirmed="",empcode="", itemCode="", lotNoForm="";
String lotNoTo ="", rateType="", chgref="", listType="", PriceListParent="",PriceList="";
String orderType="", manageType="", plist1="",plist2="",plist3="",plist4="",plist5="",plist6="",plist7="",plist8="";
String plist9="",plist10="", plist11="",plist12="",unit="", refNoold="",refNO="",data="",calc="",Str="";
String calcmeth="",plisttar="";
java.sql.Timestamp tranDate = null,confDate=null, efffrom=null,validup= null;
double rate=0.0;
double minrate=0.0;
double maxrate=0.0;
double rate1=0.0;
double rate2=0.0;
double rate3=0.0;
double rate4=0.0;
double rate5=0.0;
double rate6=0.0;
double rate7=0.0;
double rate8=0.0;
double rate9=0.0;
double rate10=0.0;
double rate11=0.0;
double rate12=0.0;
double minqty=0.0;
double maxqty=0.0;
int lineno=0;
String loginEmpCode = "";
ArrayList PricelistGen = new ArrayList();
HashMap PList=null;
try
{
DistCommon distCommon = new DistCommon();
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
ValidatorEJB validatorEJB = null;
System.out.println("Printing loginEmpCode---1-----"+loginEmpCode+"--");
dbName = CommonConstants.DB_NAME;
if( dbName.equalsIgnoreCase("db2"))
{
sql="select tran_date, price_list,confirmed,conf_date from pricelist_hdr where tran_id =? for update with RS ";
}
else if ( dbName.equalsIgnoreCase("mysql") )
{
sql="select tran_date, price_list,confirmed,conf_date from pricelist_hdr where tran_id =? for update";
}
else if(dbName.equalsIgnoreCase("mssql"))
{
sql="select tran_date, price_list,confirmed,conf_date from pricelist_hdr where tran_id =?";
}
else
{
sql="select tran_date, price_list,confirmed,conf_date from pricelist_hdr where tran_id =? for update nowait";
}
try
{
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1, tranId);
rs = pstmtSql.executeQuery();
if ( rs.next() )
{
tranDate= rs.getTimestamp(1);
priceList = rs.getString(2);
confirmed=rs.getString(3);
confDate=rs.getTimestamp(4);
pstmtSql.close();
pstmtSql = null;
rs.close();
rs = null;
}
else
{
pstmtSql.close();
pstmtSql = null;
rs.close();
rs = null;
retString = itmDBAccessLocal.getErrorString("","VTLCKERR","");
return retString;
}
}
catch(Exception e)
{
retString = itmDBAccessLocal.getErrorString("","VTLCKERR","");
throw new ITMException(e);
}
sql="select d.item_code,d.lot_no__from,d.lot_no__to,d.rate,d.rate_type,d.min_rate,d.max_rate,d.chg_ref_no,d.eff_from,d.valid_upto,m.price_list,m.list_type ,m.price_list__parent,m.order_type,m.manage_type,d.min_qty ,d.max_qty,d.unit,d.line_no,h.ref_no,ref_no_old,h.calc_basis from pricelist_hdr h, pricelist_det d, pricelist_mst m where h.tran_id = d.tran_id and h.price_list = m.price_list and h.tran_id = ?";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1, tranId);
rs = pstmtSql.executeQuery();
while ( rs.next() )
{
PList = new HashMap();
PList.put("item_code",itemCode=rs.getString("item_code"));
PList.put("lot_no__from",lotNoForm=rs.getString("lot_no__from"));
PList.put("lot_no__to",lotNoTo=rs.getString("lot_no__to"));
PList.put("rate",rate = rs.getDouble("rate"));
PList.put("rate_type",rateType=rs.getString("rate_type"));
PList.put("min_rate",minrate=rs.getDouble("min_rate"));
PList.put("max_rate",maxrate=rs.getDouble("max_rate"));
PList.put("chg_ref_no",chgref=rs.getString("chg_ref_no"));
PList.put("eff_from",efffrom=rs.getTimestamp("eff_from"));
PList.put("valid_upto",validup=rs.getTimestamp("valid_upto"));
PList.put("price_list",PriceList=rs.getString("price_list"));
PList.put("list_type",listType=rs.getString("list_type"));
PList.put("price_list__parent",PriceListParent=rs.getString("price_list__parent"));
PList.put("order_type",orderType=rs.getString("order_type"));
PList.put("manage_type",manageType =rs.getString("manage_type"));
PList.put("min_qty",minqty=rs.getDouble("min_qty"));
PList.put("max_qty",maxqty=rs.getDouble("max_qty"));
PList.put("unit",unit=rs.getString("unit"));
PList.put("line_no",lineno=rs.getInt("line_no"));
PList.put("ref_no",refNO=rs.getString("ref_no"));
PList.put("ref_no_old",refNoold=rs.getString("ref_no_old"));
PList.put("calc_basis",calc=rs.getString("calc_basis"));
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
/*PList = new HashMap();
PList.put(PriceList,"PriceList");
PList.put(itemCode, "item_code");
PList.put(unit,"unit");
PList.put(listType,"list_type");
PList.put(validup,"valid_upto");
PList.put(lotNoForm,"lot_no__from");
PList.put(lotNoTo,"lot_no__to");
PList.put(minqty,"min_qty");
PList.put(maxqty,"max_qty");
PList.put(rate,"rate");
PList.put(rateType,"rate_type");
PList.put(minrate,"min_rate");
PList.put(maxrate,"max_rate");
PList.put(orderType,"order_type");
PList.put(PriceListParent,"price_list__parent");
PList.put(chgref,"chg_ref_no");
PList.put(refNO,"ref_no");
PList.put(refNoold,"ref_no_old");
PList.put(calc,"calc_basis");*/
PricelistGen.add(PList);
System.out.println("@@@@@@@@@@@@@Price list@@@@@@@@@@@@@@@@"+PricelistGen);
retString = insertPricelist(tranId,PList,PricelistGen, conn,xtraParams);
if ( retString != null && retString.trim().length() > 0)
{
return retString;
}
sql="select calc_method, price_list__tar , price_list__parent from pricelist_mst_det where price_list = ? order by line_no ";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1, PriceList);
rs = pstmtSql.executeQuery();
while ( rs.next() )
{
calcmeth=rs.getString(1);
plisttar=rs.getString(2);
PriceListParent=rs.getString(3);
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
PList.put(plisttar,"price_list__tar");
PList.put(PriceListParent,"price_list__parentfrom");
// PList.put(PriceListParent,"rate");
//retString= CalcRate(plisttar,data,calcmeth,errCode);
if ( retString != null && retString.trim().length() > 0)
{
return retString;
}
}
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
System.out.println("Exception : "+e);
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
}
package ibase.webitm.ejb.dis;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.sql.Connection;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface PriceListConfLocal extends ActionHandlerLocal
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus ) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.sql.Connection;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface PriceListConfRemote extends ActionHandlerRemote
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
//new method by gulzar - 25/11/11 to call from postsave component
public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus ) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class PriceListGenIC extends ValidatorEJB implements PriceListGenLocal, PriceListGenRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
FinCommon finCommon = null;
ValidatorEJB validator = null;
Date effFrom = null;
UtilMethods utilMethods = UtilMethods.getInstance();
String dateStr = "";
String errFldName = "";
String errorType ="";
@Override
public String wfValData() throws RemoteException,ITMException
{
return "";
}
@Override
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
@Override
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String errString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("Val xmlString :: " + xmlString);
System.out.println("Val xmlString1 :: " + xmlString1);
System.out.println("Val 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);
}
@Override
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 = null;
String errString = "";
String errCode = "";
String errorType = "";
String userId = "";
String sql = "";
String itemCode = "";
String refNo = "";
String keyFlag = "";
String manageType = "";
String priceListParent = "";
String priceList = "";
String priceListTar = "";
String calcMethod = "";
String tranId = "";
String sql1 = "";
String active = "";
Date validUpto = null;
String validUptoStr = "";
String effFromStr = "";
String minRateStr = "";
String rateStr = "";
int rate = 0;
int minRate = 0;
int ctr = 0;
int count = 0;
int currentFormNo = 0;
int minQty = 0;
String minQtyStr = "";
String maxQtyStr = "";
int maxQty = 0;
int childNodeListLength;
StringBuffer valueXmlString = new StringBuffer();
ArrayList<String> errList = new ArrayList();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer(
"<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try {
conn = connDriver.getConnectDB("DriverITM");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
genericUtility.getApplDateFormat());
SimpleDateFormat dbDateFormat = new SimpleDateFormat(genericUtility
.getInstance().getDBDateFormat());
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
conn = connDriver.getConnectDB("DriverITM");
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:
System.out.println("testing case 1 for validation ");
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();
System.out.println("pricelist>>>><<<<");
priceList = genericUtility.getColumnValue("price_list",dom);
if (childNodeName.equalsIgnoreCase("price_list"))
{
if (priceList != null && priceList.trim().length() > 0)
{
sql1 = "select count(*) from pricelist_mst where price_list = ?";
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1, priceList);
rs = pstmt.executeQuery();
if (rs.next()) {
count = rs.getInt(1);
System.out.println("Count is " + count);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (count == 0) {
errCode = "VTPLIST";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = "Select manage_type from pricelist_mst where price_list = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, priceList);
rs = pstmt.executeQuery();
if (rs.next()) {
manageType = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (errCode == null || errCode.trim().length() == 0)
{
if (manageType.equalsIgnoreCase("M"))
{
errCode = "VTMTYPE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
}
else if (childNodeName.equalsIgnoreCase("tran_id"))
{
tranId = genericUtility.getColumnValue("tran_id", dom);
sql = "select key_flag from transetup where tran_window = 'w_pricelist_tran' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()) {
keyFlag = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (keyFlag == null) {
keyFlag = "M";
tranId = genericUtility.getColumnValue("tran_id",
dom);
}
if (keyFlag.equalsIgnoreCase("M")
&& (tranId == null || tranId.trim().length() == 0)) {
errCode = "VMCODNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else if (editFlag.equalsIgnoreCase("A"))
{
sql = "select count(*) from pricelist_hdr where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next()) {
count = rs.getInt(1);
}
if (count > 0) {
errCode = "VMDUPL1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if (childNodeName.equalsIgnoreCase("ref_no")
|| childNodeName.equalsIgnoreCase("ref_no_old")) {
refNo = genericUtility.getColumnValue(childNodeName,
dom);
if (refNo == null) {
errCode = "VTREFNONUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr =0;
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("testing case 2 for validation ");
if (childNodeName.equalsIgnoreCase("item_code")) {
itemCode = genericUtility.getColumnValue("item_code",
dom);
sql = "select count(*) from item where item_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next()) {
count = rs.getInt(1);
}
if (count == 0) {
errCode = "VMITEM_CD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
} else {
sql1 = "select active from item where item_code = ?";
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next()) {
active = rs.getString(1);
}
if (active.equalsIgnoreCase("N")) {
errCode = "VTITEM4";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
else if (childNodeName.equalsIgnoreCase("min_qty")) {
minQtyStr = genericUtility.getColumnValue("min_qty",
dom);
minQty = minQtyStr == null ? 0 : minQtyStr.trim().length() == 0 ? 0 : Integer.parseInt(minQtyStr.trim());
maxQtyStr = genericUtility.getColumnValue("max_qty",
dom);
maxQty = maxQtyStr == null ? 0 : maxQtyStr.trim().length() == 0 ? 0 : Integer.parseInt(maxQtyStr.trim());
if (maxQty < minQty) {
errCode = "VMMINQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
else if (childNodeName.equalsIgnoreCase("min_rate")) {
minRateStr = genericUtility.getColumnValue("min_rate",
dom);
rateStr = genericUtility.getColumnValue("rate", dom);
if((minRateStr.trim().length() > 0||minRateStr !=null )&& (rateStr.trim().length() >0 ||rateStr != null ))
{
minRate = Integer.parseInt(minRateStr);
rate = Integer.parseInt(rateStr);
if (rate < minRate) {
errCode = "VMMINRATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
else if (childNodeName.equalsIgnoreCase("valid_upto")) {
System.out.println("validupto chidnode name" + childNodeName);
validUptoStr = checkNull(genericUtility.getColumnValue(
"valid_upto", dom));
effFromStr = checkNull(genericUtility.getColumnValue("eff_from",
dom));
System.out.println("Valid upto" + validUptoStr);
if((validUptoStr.trim().length() > 0 && validUptoStr!=null) && (effFromStr.trim().length()> 0 &&effFromStr!=null ))
{
System.out.println("Inside validupto condition");
//stmtMaster.setTimestamp( 1, java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString( ldtTranDateFrom, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())));
SimpleDateFormat sdf1=new SimpleDateFormat("dd/MM/yy");
effFrom=sdf1.parse(effFromStr);
validUpto=sdf1.parse(validUptoStr);
if (validUpto.before(effFrom)) {
errCode = "VTVALUPTOE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
break;
}
int errListSize = errList.size();
int cnt = 0;
if(errList != null && errListSize > 0)
{
for(cnt = 0; cnt < errListSize; cnt ++)
{
errCode = errList.get((int) cnt);
System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode);
if(errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if(errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println("Exception : " + e);
e.printStackTrace();
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();
throw new ITMException( d );
}
//System.out.println("[SOrderFormEJB] Connection is Closed");
}
errString = errStringXml.toString();
return errString;
}
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("xmlString:>>>>>>>>>>>>>>>>>>>>>>>>>> " +xmlString);
System.out.println("xmlString1:>>>>>>>>>>>>>>>>>>>>>>>>>> " +xmlString1);
System.out.println("xmlString2:>>>>>>>>>>>>>>>>>>>>>>>>>> " +xmlString2);
System.out.println("objContext:>>>>>>>>>>>>>>>>>>>>>>>>>> " +objContext);
System.out.println("currentColumn:>>>>>>>>>>>>>>>>>>>>>>>>>> " +currentColumn);
System.out.println("editFlag:>>>>>>>>>>>>>>>>>>>>>>>>>> " +editFlag);
System.out.println("xtraParams:>>>>>>>>>>>>>>>>>>>>>>>>>> " +xtraParams);
try
{
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
}
System.out.println("dom : " + genericUtility.serializeDom(dom));
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = parseString(xmlString1);
}
System.out.println("dom1" +genericUtility.serializeDom(dom1));
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = parseString(xmlString2);
}
System.out.println("dom2" + genericUtility.serializeDom(dom2));
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
} catch (Exception e)
{
System.out.println("Exception : [PriceListGen][itemChanged( String, String )] :==>\n"+ e.getMessage());
}
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();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Node parentNode1 = null;
String descr = "";
String itemCode = "";
String childNodeName = null;
String currCode = "";
String defCrTerm = "";
String calcMethod = "";
String calcMethodDescr = "";
String rateStr = "";
String rateNo = "";
int rate = 0;
String columnValue = "";
String priceList = "";
String unit = "";
String expr = "";
String formula = "";
String sql = "";
int ctr = 0;
String errString = "";
String plist1 = "", plist2 = "", plist3 = "", plist4 = "", plist5 = "", plist6 = "", plist7 = "", plist8 = "", plist9 = "", plist10 = "", plist11 = "", plist12 = "";
int currentFormNo = 0;
double lineNo = 0;
String liNoStr = "";
String sql1 = "";
String sql2 = "";
String pdescr ="";
String effFromStr = "";
Connection conn = null;
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
ResultSet rs = null, rs1 = null, rs2 = null;
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
int liNo = 0;
try {
System.out.println("dom : " + genericUtility.serializeDom(dom));
System.out.println("dom1" +genericUtility.serializeDom(dom1));
System.out.println("dom2" + genericUtility.serializeDom(dom2));
System.out.println("objContext" + objContext);
System.out.println("currentColumn"+currentColumn);
System.out.println("editFlag" +editFlag);
System.out.println("xtraParams" + xtraParams);
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
System.out.println("editFlag@@ : ["+editFlag+"]");
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
genericUtility.getApplDateFormat());
String currDate = simpleDateFormat.format(currentDate.getTime());
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();
ctr = 0;
valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength();
do {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue = childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}
while (ctr < childNodeListLength
&& !childNodeName.equals(currentColumn));
System.out.println("currentColumn[" + currentColumn + "]columnValue ==> '" + columnValue + "'");
System.out.println("testing case 1 for item change");
System.out.println("currentColumn"+currentColumn);
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
java.sql.Timestamp date1 =null ;
date1 = new java.sql.Timestamp(System.currentTimeMillis()) ;
dateStr = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(date1);
System.out.println("inside item 1234566775578457878 ");
valueXmlString.append("<tran_date>")
.append("<![CDATA[" + dateStr + "]]>")
.append("</tran_date>");
System.out.println("CHILDNODENAME14153453412341524545454524534" + childNodeName);
}
else if (currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
Timestamp date2 = new java.sql.Timestamp(System.currentTimeMillis()) ;
dateStr = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(date2);
System.out.println("inside item 1234566775578457878 ");
valueXmlString.append("<tran_date>")
.append("<![CDATA[" + dateStr + "]]>")
.append("</tran_date>");
System.out.println("@@@@@@@@ itm_defaultedit called @@@@@@@@");
System.out.println("Childnodename itmdefaultedit" + childNodeName );
}
/*if (currentColumn.trim().equalsIgnoreCase("price_list"))
{
System.out.println("currentColumn " + currentColumn );
priceList = genericUtility.getColumnValue("price_list",
dom);
sql = "Select descr from pricelist_mst where price_list = ?";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
pstmt.setString(1, pdescr);
if (rs.next())
{
priceList = rs.getString(1) == null ? "" : rs
.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<descr>")
.append("<![CDATA[" + pdescr + "]]>")
.append("</descr>");
}*/
else if (currentColumn.trim().equalsIgnoreCase("price_list"))
{
System.out.println("currentColumn1123512561564567346725672562788ASAAA" + currentColumn);
priceList = genericUtility.getColumnValue("price_list",dom);
sql = "Select descr from pricelist_mst where price_list =?";
System.out.println("PRICELIST" + priceList);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,priceList );
rs = pstmt.executeQuery();
if (rs.next())
{
pdescr = rs.getString(1) == null ? "" : rs
.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("PRICELIST DESCR" +pdescr );
valueXmlString.append("<descr>")
.append("<![CDATA[" + pdescr + "]]>")
.append("</descr>");
}
valueXmlString.append("</Detail1>");
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
do {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn.trim())) {
if (childNode.getFirstChild() != null) {
columnValue = childNode.getFirstChild()
.getNodeValue();
}
}
ctr++;
} while (ctr < childNodeListLength
&& !childNodeName.equals(currentColumn));
// System.out.println("currentColumn..." + currentColumn);
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
priceList = genericUtility.getColumnValue("price_list", dom);
sql = "Select plist_1,plist_2,plist_3,plist_4,plist_5,plist_6,plist_7,plist_8,plist_9,plist_10,plist_11,plist_12 from pricelist_mst where price_list = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, priceList);
rs = pstmt.executeQuery();
if (rs.next()) {
plist1 = rs.getString("plist_1");
plist2 = rs.getString("plist_2");
plist3 = rs.getString("plist_3");
plist4 = rs.getString("plist_4");
plist5 = rs.getString("plist_5");
plist6 = rs.getString("plist_6");
plist7 = rs.getString("plist_7");
plist8 = rs.getString("plist_8");
plist9 = rs.getString("plist_9");
plist10 = rs.getString("plist_10");
plist11 = rs.getString("plist_11");
plist12 = rs.getString("plist_12");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<rate_1_t>")
.append("<![CDATA[" + plist1 + "]]>")
.append("</rate_1_t>");
valueXmlString.append("<rate_2_t>")
.append("<![CDATA[" + plist2 + "]]>")
.append("</rate_2_t>");
valueXmlString.append("<rate_3_t>")
.append("<![CDATA[" + plist3 + "]]>")
.append("</rate_3_t>");
valueXmlString.append("<rate_4_t>")
.append("<![CDATA[" + plist4 + "]]>")
.append("</rate_4_t>");
valueXmlString.append("<rate_5_t>")
.append("<![CDATA[" + plist5 + "]]>")
.append("</rate_5_t>");
valueXmlString.append("<rate_6_t>")
.append("<![CDATA[" + plist6 + "]]>")
.append("</rate_6_t>");
valueXmlString.append("<rate_7_t>")
.append("<![CDATA[" + plist7 + "]]>")
.append("</rate_7_t>");
valueXmlString.append("<rate_8_t>")
.append("<![CDATA[" + plist8 + "]]>")
.append("</rate_8_t>");
valueXmlString.append("<rate_9_t>")
.append("<![CDATA[" + plist9 + "]]>")
.append("</rate_9_t>");
valueXmlString.append("<rate_10_t>")
.append("<![CDATA[" + plist10 + "]]>")
.append("</rate_10_t>");
valueXmlString.append("<rate_11_t>")
.append("<![CDATA[" + plist11 + "]]>")
.append("</rate_11_t>");
valueXmlString.append("<rate_12_t>")
.append("<![CDATA[" + plist12 + "]]>")
.append("</rate_12_t>");
effFrom = new java.sql.Timestamp(System.currentTimeMillis()) ;
effFrom = utilMethods.RelativeDate(effFrom, 1);
effFromStr = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(effFrom);
valueXmlString.append("<eff_from>")
.append("<![CDATA[" + effFromStr + "]]>")
.append("</eff_from>");
// effFrom = new
// SimpleDateFormat(genericUtility.getApplDateFormat()).format(effFrom);
valueXmlString.append("<list_type protect = \"0\">")
.append("<![CDATA[" + 0 + "]]>")
.append("</list_type>");
valueXmlString.append("<order_type protect = \"0\">")
.append("<![CDATA[" + 0 + "]]>")
.append("</order_type>");
}
else if (currentColumn.trim().equalsIgnoreCase("itm_default_edit"))
{
/*if (currentColumn.equalsIgnoreCase("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code",dom);
sql = "Select descr, unit from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString(1));
unit = checkNull(rs.getString(2));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
/*java.sql.Timestamp date1 =null ;
date1 = new java.sql.Timestamp(System.currentTimeMillis()) ;
effFromStr = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(date1);
System.out.println("inside item 1234566775578457878 ");
effFrom = new java.sql.Timestamp(System.currentTimeMillis()) ;
effFromStr = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(effFrom);
valueXmlString.append("<eff_from>")
.append("<![CDATA[" + effFromStr + "]]>")
.append("</eff_from>");
valueXmlString.append("<descr>")
.append("<![CDATA[" + descr + "]]>")
.append("</descr>");
valueXmlString.append("<unit>")
.append("<![CDATA[" + unit + "]]>")
.append("</unit>");
}*/
priceList = genericUtility.getColumnValue("price_list", dom);
sql = "Select plist_1,plist_2,plist_3,plist_4,plist_5,plist_6,plist_7,plist_8,plist_9,plist_10,plist_11,plist_12 from pricelist_mst where price_list = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, priceList);
rs = pstmt.executeQuery();
if (rs.next()) {
plist1 = rs.getString("plist_1");
plist2 = rs.getString("plist_2");
plist3 = rs.getString("plist_3");
plist4 = rs.getString("plist_4");
plist5 = rs.getString("plist_5");
plist6 = rs.getString("plist_6");
plist7 = rs.getString("plist_7");
plist8 = rs.getString("plist_8");
plist9 = rs.getString("plist_9");
plist10 = rs.getString("plist_10");
plist11 = rs.getString("plist_11");
plist12 = rs.getString("plist_12");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<rate_1_t>")
.append("<![CDATA[" + plist1 + "]]>")
.append("</rate_1_t>");
valueXmlString.append("<rate_2_t>")
.append("<![CDATA[" + plist2 + "]]>")
.append("</rate_2_t>");
valueXmlString.append("<rate_3_t>")
.append("<![CDATA[" + plist3 + "]]>")
.append("</rate_3_t>");
valueXmlString.append("<rate_4_t>")
.append("<![CDATA[" + plist4 + "]]>")
.append("</rate_4_t>");
valueXmlString.append("<rate_5_t>")
.append("<![CDATA[" + plist5 + "]]>")
.append("</rate_5_t>");
valueXmlString.append("<rate_6_t>")
.append("<![CDATA[" + plist6 + "]]>")
.append("</rate_6_t>");
valueXmlString.append("<rate_7_t>")
.append("<![CDATA[" + plist7 + "]]>")
.append("</rate_7_t>");
valueXmlString.append("<rate_8_t>")
.append("<![CDATA[" + plist8 + "]]>")
.append("</rate_8_t>");
valueXmlString.append("<rate_9_t>")
.append("<![CDATA[" + plist9 + "]]>")
.append("</rate_9_t>");
valueXmlString.append("<rate_10_t>")
.append("<![CDATA[" + plist10 + "]]>")
.append("</rate_10_t>");
valueXmlString.append("<rate_11_t>")
.append("<![CDATA[" + plist11 + "]]>")
.append("</rate_11_t>");
valueXmlString.append("<rate_12_t>")
.append("<![CDATA[" + plist12 + "]]>")
.append("</rate_12_t>");
effFrom = new java.sql.Timestamp(System.currentTimeMillis()) ;
effFrom = utilMethods.RelativeDate(effFrom, 1);
effFromStr = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(effFrom);
valueXmlString.append("<eff_from>")
.append("<![CDATA[" + effFromStr + "]]>")
.append("</eff_from>");
// effFrom = new
// SimpleDateFormat(genericUtility.getApplDateFormat()).format(effFrom);
valueXmlString.append("<list_type protect = \"0\">")
.append("<![CDATA[" + 0 + "]]>")
.append("</list_type>");
valueXmlString.append("<order_type protect = \"0\">")
.append("<![CDATA[" + 0 + "]]>")
.append("</order_type>");
HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
hashMap.put("rate", 1);
hashMap.put("rate_1", 2);
hashMap.put("rate_2", 3);
hashMap.put("rate_3", 4);
hashMap.put("rate_4", 5);
hashMap.put("rate_5", 6);
hashMap.put("rate_6", 7);
hashMap.put("rate_7", 8);
hashMap.put("rate_8", 9);
hashMap.put("rate_9", 10);
hashMap.put("rate_10", 11);
hashMap.put("rate_11", 12);
if (hashMap.containsKey("rate"))
{
System.out.println("ratevalue:" + hashMap.get("rate"));
valueXmlString.append("<min_rate>")
.append("<![CDATA[" + rate + "]]>")
.append("</min_rate>");
valueXmlString.append("<max_rate>")
.append("<![CDATA[" + rate + "]]>")
.append("</max_rate>");
} else if (hashMap.containsKey(childNodeName))
{
System.out.println("ratevalue:" + hashMap.get(childNodeName));
for (int i = hashMap.get(childNodeName); i < hashMap.size(); i++)
{
sql = "DECLARE CUR_RATE_1 DYNAMIC CURSOR FOR SQLSA ";
pstmt = conn.prepareStatement(sql);
liNoStr = Integer.toString(i);
rateStr = "rate" + liNoStr + "_formula";
rateNo = "rate" + liNoStr;
sql1 = "Select "
+ rateStr
+ " From Pricelist_mst Where price_list = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, priceList);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
rate = rs1.getInt(1);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
sql2 = "PREPARE SQLSA FROM " + sql1
+ "OPEN DYNAMIC CUR_RATE_1 using :"
+ priceList + ";"
+ "FETCH CUR_RATE_1; CLOSE CUR_RATE_1 ;";
pstmt2 = conn.prepareStatement(sql2);
rs2 = pstmt2.executeQuery();
if (rs2.next())
{
formula = rs2.getString(1);
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
}
}
}
if (currentColumn.equalsIgnoreCase("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code",dom);
sql = "Select descr, unit from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString(1));
unit = checkNull(rs.getString(2));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
effFrom = new java.sql.Timestamp(System.currentTimeMillis()) ;
effFrom = utilMethods.RelativeDate(effFrom, 1);
effFromStr = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(effFrom);
valueXmlString.append("<eff_from>")
.append("<![CDATA[" + effFromStr + "]]>")
.append("</eff_from>");
valueXmlString.append("<item_descr>")
.append("<![CDATA[" + descr + "]]>")
.append("</item_descr>");
valueXmlString.append("<unit>")
.append("<![CDATA[" + unit + "]]>")
.append("</unit>");
}
valueXmlString.append("</Detail2>");
break;
}
valueXmlString.append("</Root>");
} catch (Exception e)
{
System.out.println(e.getMessage());
System.out.println("Exception : " + e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn!=null)
{
if(rs != null )rs.close();
if(rs1 != null )rs1.close();
if(rs2 != null )rs2.close();
rs = null;
rs1 = null;
rs2 = null;
if(pstmt != null )pstmt.close();
if(pstmt1 != null )pstmt1.close();
if(pstmt2 != null )pstmt2.close();
pstmt =null;
pstmt1 =null;
pstmt2 =null;
conn.close();
}
conn = null;
}catch(Exception d)
{
d.printStackTrace();
throw new ITMException( d );
}
}
return valueXmlString.toString();
}
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 checkNull(String input)
{
if (input == null)
{
input = "";
}
return input;
}
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface PriceListGenLocal extends ValidatorLocal {
public String wfValData() throws RemoteException,ITMException;
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() 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;
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
public interface PriceListGenRemote extends ValidatorRemote{
public String wfValData() throws RemoteException,ITMException;
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() 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