Commit 7988f5bd authored by dhirajchavan's avatar dhirajchavan

Added Code conn=getConnection().


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@102865 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e80ce3c7
package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless;
@Stateless
public class DiscListAplIC extends ValidatorEJB implements DiscListAplICLocal,DiscListAplICRemote{
E12GenericUtility genericUtility= new E12GenericUtility();
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
{
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)
{
System.out.println("Exception : [DiscListAplIC][wfValData( String, String )] :==>\n" + e.getMessage());
throw new ITMException(e);
}
return(errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String lineNo = "";
String ResId="";
String childNodeName = null;
String profileId="";
String sql="";
String errString = "";
String errCode = "";
String userId = "";
String errorType = "";
int ct=0;
int count = 0;
int ctr=0,seriesCount1=0;
int currentFormNo = 0;
int childNodeListLength;
NodeList parentNodeList = null;
NodeList parentNodeList123 = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null;
PreparedStatement pstmt = null ;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
System.out.println("editFlag=["+editFlag+"]");
String discList="",seqNo="";
double discRate1=0.0,discRateChkNeg=0.0;
int ctr1 = 0;
try
{
/*conn = connDriver.getConnectDB("DriverITM");
*
*
*/
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo>>>>>>>>>>>>>>>>>:"+currentFormNo);
}
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for( ctr = 0; ctr < childNodeListLength;ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
int seriesCount=0;
discList = genericUtility.getColumnValue("disc_list", dom);
String discListType = genericUtility.getColumnValue("disc_list_type", dom);
seqNo = genericUtility.getColumnValue("seq_no", dom);
if(editFlag.equals("A"))
{
String Sql = "SELECT COUNT(1) AS COUNT FROM disc_list_appl WHERE disc_list=? and disc_list_type =? ";
pstmt = conn.prepareStatement(Sql);
pstmt.setString(1,discList);
pstmt.setString(2,discListType);
// pstmt.setString(7,userId);
rs = pstmt.executeQuery();
System.out.println("Sql" + Sql);
if (rs.next()) {
seriesCount1 = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Duplicate count@@"+seriesCount1);
if (seriesCount1 > 0) {
errString = getErrorString(" ", "VMDUPREC", userId);
break;
}
}
/* if (seriesCount1 > 0) {
errString = getErrorString(" ", "VMDUPREC", userId);
break;
}
*/
if(childNodeName.equalsIgnoreCase("disc_list"))
{
discList = checkNull(genericUtility.getColumnValue("disc_list", dom));
System.out.println("discList="+discList);
if(discList == null || discList.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMDISLCB",userId);
break ;
}
else
{
sql = " select count ( *) from disc_list where disc_list = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, discList);
rs = pstmt.executeQuery();
if(rs.next())
{
ct = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(ct == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMDISCLNV ",userId);
break ;
}
}
}else if(childNodeName.equalsIgnoreCase("seq_no"))
{
seqNo = checkNull(genericUtility.getColumnValue("seq_no", dom));
System.out.println("seqNo="+seqNo);
if(seqNo == null || seqNo.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMDISSNB",userId);
break ;
}
}
//seq_no
}
break;
case 2 :
int seriesCount = 0,editFlagcnt=0;
String from_date="";
String to_date="",discRate="",discType="";
Timestamp fromDate=null;
Timestamp toDate=null;
System.out.println( "Detail 2 Validation called " );
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
System.out.println("parentNode@@@"+parentNode);
childNodeList = parentNode.getChildNodes();
System.out.println("childNodeList@@@"+childNodeList);
childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength@@"+childNodeListLength);
NodeList detail2List = dom2.getElementsByTagName("Detail2");
int noOfParentD = detail2List.getLength();
if(noOfParentD>1){
System.out.println("condition");
errString = itmDBAccessEJB.getErrorString("","VMRECNALW",userId);
break ;
}
for( ctr = 0; ctr < childNodeListLength;ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
discList = genericUtility.getColumnValue("disc_list", dom);
String discListType = genericUtility.getColumnValue("disc_list_type", dom);
discRate= genericUtility.getColumnValue("disc_rate", dom);
discType = genericUtility.getColumnValue("disc_type", dom);
System.out.println("discRate@@"+discRate);
System.out.println("Edit flag"+editFlag);
from_date=checkNull(genericUtility.getColumnValue("from_date", dom));
to_date=checkNull(genericUtility.getColumnValue("to_date", dom));
if(from_date !=null && from_date.trim().length()>0 )
{
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(from_date, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
if(to_date !=null && to_date.trim().length()>0 )
{
toDate = Timestamp.valueOf(genericUtility.getValidDateString(to_date, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
System.out.println("fromdate@@@@"+fromDate);
System.out.println("todate@@@@"+toDate);
if(editFlag.equals("A"))
{
String Sql = "SELECT COUNT(1) AS COUNT FROM disc_list_rate WHERE disc_list=? AND disc_list_type=? ";//and chg_user=? ";
pstmt = conn.prepareStatement(Sql);
pstmt.setString(1,discList);
pstmt.setString(2,discListType);
/* pstmt.setTimestamp(3,fromDate);
pstmt.setTimestamp(4,toDate);
pstmt.setString(5,discRate);
pstmt.setString(6,discType);*/
// pstmt.setString(7,userId);
rs = pstmt.executeQuery();
System.out.println("Sql" + Sql);
if (rs.next()) {
seriesCount = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Duplicate count@@"+seriesCount);
System.out.println("editFlag@@"+editFlag);
if (seriesCount > 0) {
errString = getErrorString(" ", "VMDUPREC", userId);
break;
}
}
if(childNodeName.equalsIgnoreCase("disc_list"))
{
String discList1="";
discList1 = genericUtility.getColumnValue("disc_list", dom);
if(discList1 == null || discList1.trim().length() == 0)
{
System.out.println("discList id is" + discList1);
errString = itmDBAccessEJB.getErrorString("","VMNUPROID ",userId);
break ;
}
/* else
{
sql = " select count ( *) from disc_list where disc_list = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, discList1);
rs = pstmt.executeQuery();
if(rs.next())
{
ct = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(ct == 0)
{
errString = itmDBAccessEJB.getErrorString("disc_list","VTINVPROID ",userId);
break ;
}
}*/
}else if (childNodeName.equalsIgnoreCase("from_date"))
{
System.out.println("INSIDE FROM DATE ");
from_date = checkNull(this.genericUtility.getColumnValue("from_date", dom));
System.out.println("from_date@@@"+from_date);
if(from_date == null || from_date.trim().length() == 0 )
{
errString = itmDBAccessEJB.getErrorString("from_date","VMFRMDTNB",userId);
break ;
}
/*else if(from_date !=null && from_date.trim().length() > 0)
{
System.out.println("eff_from"+from_date);
System.out.println("valid_upto"+to_date);
if(from_date !=null && from_date.trim().length()>0 )
{
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(from_date, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
if(to_date !=null && to_date.trim().length()>0 )
{
toDate = Timestamp.valueOf(genericUtility.getValidDateString(to_date, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}System.out.println("fromDate@@@"+fromDate);
System.out.println("toDate@@@"+toDate);
if(fromDate != null && toDate.before(fromDate))
{
System.out.println("In COndition@from Date");
errString = itmDBAccessEJB.getErrorString("from_date","VMFRMDGT",userId);
break ;
}
}*/
}else if(childNodeName.equalsIgnoreCase("to_date"))
{
System.out.println("validation VALID_UPTO executed");
from_date = checkNull(this.genericUtility.getColumnValue("from_date", dom));
to_date = checkNull(this.genericUtility.getColumnValue("to_date", dom));
System.out.println(" from_date " +from_date);
System.out.println(" TO_DATE " +to_date);
/* if( (from_date == null || from_date.trim().length() == 0)&&(to_date == null || to_date.trim().length() == 0))
{
errString = itmDBAccessEJB.getErrorString("","VMFRMDTNB",userId);
break ;
}
*/
if(to_date == null || to_date.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("to_date","VMTODTNB",userId);
break ;
}
else if(to_date !=null && to_date.trim().length() > 0)
{
if(from_date !=null && from_date.trim().length()>0 )
{
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(from_date, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
if(to_date !=null && to_date.trim().length()>0 )
{
toDate = Timestamp.valueOf(genericUtility.getValidDateString(to_date, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
} System.out.println("fromDate@@@"+fromDate);
System.out.println("toDate@@@"+toDate);
if(toDate != null && toDate.before(fromDate))
{
System.out.println("In COndition");
errString = itmDBAccessEJB.getErrorString("to_date","VMTODTLT",userId);
break ;
}
}
}
else if(childNodeName.equalsIgnoreCase("disc_rate"))
{
String discRate2="";
discRate2= genericUtility.getColumnValue("disc_rate", dom);
System.out.println("discRate@@"+discRate1);
discRateChkNeg= discRate2 == null ? 0 : Double.parseDouble(discRate);
System.out.println("discRateChkNeg["+discRateChkNeg+"]");
if(discRateChkNeg<=0)
{
System.out.println("Rate is@"+discRateChkNeg);
errString = itmDBAccessEJB.getErrorString("disc_rate","VMNEGRT",userId);
break ;
}
}else if(childNodeName.equalsIgnoreCase("disc_type"))
{
String discType1="";
discType1 = genericUtility.getColumnValue("disc_type", dom);
System.out.println("discType["+discType1+"]");
/* discRate= genericUtility.getColumnValue("disc_rate", dom);
System.out.println("discRate@@"+discRate);
*/
if((discType.equals("P")||discType.equalsIgnoreCase("P"))&& (discRateChkNeg>100))
{
System.out.println("If Dist Type is ["+discType+"]");
errString = itmDBAccessEJB.getErrorString("disc_type","VMINVDRT",userId);
break ;
}
}
}
break;
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
errString=e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if(conn!=null)
{
if(rs != null )rs.close();
rs = null;
if(pstmt != null )pstmt.close();
pstmt =null;
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
}
System.out.println("ErrString ::"+errString);
return errString;
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom1 = null;
Document dom = null;
Document dom2 = null;
String valueXmlString = "";
//GenericUtility genericUtility = GenericUtility.getInstance();
try
{
if (xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :disc_listIC:itemChanged(String,String,String,String,String,String):" + e.getMessage() + ":");
valueXmlString = genericUtility.createErrorString(e);
e.printStackTrace();
}
System.out.println("returning from disc_listitemChanged");
return (valueXmlString);
}
@Override
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
StringBuffer valueXmlString = new StringBuffer();
String errString="";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null,pstmt=null;
ResultSet rs = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String sql = "";
int currentFormNo = 0;
int ctr=0;
String childNodeName = null;
String columnValue = null;
/* String profileId = "",profileName="";
String profileIdItmDe="" , profileIdItmDedesc="";;
String profileIdDetail="",profileIdDetaildesc="";
String resId="",resoucrDesc="";
String itmEditprofile="",itmEditResid="",itmEditline="",itmDesc="";
*/
String descList="",listDescr="",discDesc="";
// ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try
{
String userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo@@"+currentFormNo);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
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();
System.out.println("columnValue@@"+columnValue);
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
if (currentColumn.trim().equalsIgnoreCase("disc_list"))
{
descList = genericUtility.getColumnValue("disc_list", dom);
System.out.println("descList@@@"+descList);
descList = descList == null ? "" : descList.trim();
sql = "select descr from disc_list where disc_list =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, descList);
rs = pStmt.executeQuery();
if (rs.next())
{
listDescr = rs.getString(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
listDescr = listDescr == null ? "" : listDescr.trim();
valueXmlString.append("<disc_list>").append(descList).append("</disc_list>");
valueXmlString.append("<descr>").append(listDescr).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();
System.out.println("columnValue@@"+columnValue);
}
}
ctr++;
}
while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
if (currentColumn.trim().equalsIgnoreCase("itm_default")) {
descList = genericUtility.getColumnValue("disc_list",dom);
System.out.println("@@@@@3 descList [" + descList + "]");
//profileIdItmDe = profileIdItmDe == null ? "" : profileIdItmDe.trim();
valueXmlString.append("<disc_list>").append("<![CDATA[" + descList + "]]>").append("</disc_list>");
//System.out.println("profileIdItmDe["+profileIdItmDe+"]");
sql = "select descr from disc_list where disc_list =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, descList);
rs = pStmt.executeQuery();
if (rs.next())
{
discDesc = rs.getString(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
discDesc = discDesc == null ? "" : discDesc.trim();
System.out.println("disc_listDESCR["+discDesc+"]");
valueXmlString.append("<disc_list>").append("<![CDATA[" + descList + "]]>").append("</disc_list>");
valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
/*if (!editFlag.equalsIgnoreCase("E"))
{
System.out.println("Edit Falg is "+ editFlag);
valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
}*/
/*if(childNodeListLength==1)
{
}*/
}
else if (currentColumn.trim().equalsIgnoreCase("disc_list"))
{
descList = genericUtility.getColumnValue("disc_list",dom);
sql = "select descr from disc_list where disc_list =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, descList);
rs = pStmt.executeQuery();
if (rs.next())
{
discDesc = rs.getString(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
discDesc = discDesc == null ? "" : discDesc.trim();
System.out.println("disc_listDESCR["+discDesc+"]");
valueXmlString.append("<disc_list>").append("<![CDATA[" + descList + "]]>").append("</disc_list>");
valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
/* descList=genericUtility.getColumnValue("disc_list", dom1);
itmEditResid=genericUtility.getColumnValue("res_id", dom);
itmEditline=genericUtility.getColumnValue("line_no", dom);
descList = descList == null ? "" : descList.trim();
System.out.println("descList["+descList+"]");
sql = "select descr from disc_list where disc_list=? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, descList);
rs = pStmt.executeQuery();
if (rs.next())
{
discDesc = rs.getString(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
System.out.println("itm_defaultedit@@"+discDesc);
discDesc = discDesc == null ? "" : discDesc.trim();
System.out.println("discDesc["+discDesc+"]");
valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
if (!editFlag.equalsIgnoreCase("E"))
{
System.out.println("IN IF EditFlag["+editFlag+"]");
//valueXmlString.append("<profile_id protect = \"0\" >").append("<![CDATA[" + itmEditprofile + "]]>").append("</profile_id>");
valueXmlString.append("<disc_list>").append("<![CDATA[" + descList + "]]>").append("</disc_list>");
valueXmlString.append("<descr protect = \"0\" >").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
//valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
}*/
}
/*else if(currentColumn.trim().equalsIgnoreCase("res_id"))
{}*/
valueXmlString.append("</Detail2>");
break;
}
valueXmlString.append("</Root>\r\n");
}
catch (Exception e)
{
System.out.println("Exception :DiscListRateICitemChange•••••••(Document,String):" + e.getMessage() + ":");
valueXmlString.delete(0, valueXmlString.length());
e.printStackTrace();
/*errString=e.getMessage();
throw new ITMException(e);*/
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pStmt != null )
{
pStmt.close();
pStmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
System.out.println("\n***** ValueXmlString :" + valueXmlString + ":*******");
return valueXmlString.toString();
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input.trim();
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
@Local
public interface DiscListAplICLocal {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
@Remote
public interface DiscListAplICRemote {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless;
@Stateless
public class DiscListIC extends ValidatorEJB implements DiscListICLocal,DiscListICRemote{
E12GenericUtility genericUtility=new E12GenericUtility();
public String wfValData() throws RemoteException, ITMException {
return "";
}
public String itemChanged() throws RemoteException, ITMException {
return "";
}
public String wfValData(String xmlString, String xmlString1,
String xmlString2, String objContext, String editFlag,
String xtraParams) throws RemoteException, ITMException {
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try {
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0) {
dom2 = parseString(xmlString2);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag,
xtraParams);
} catch (Exception e) {
System.out.println("Exception : DistListIC : wfValData(String xmlString) : ==>\n"+ e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1, Document dom2,
String objContext, String editFlag, String xtraParams)
throws RemoteException, ITMException
{
String errString = " ";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
String errCode = null;
String userId = null;
int cnt = 0;
int ctr = 0;
int currentFormNo = 0;
int childNodeListLength;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String discList="",descr="",shDescr="",calcType="";
//Timestamp eff_from1=null, valid_upto1=null;
ConnDriver connDriver = new ConnDriver();
try {
System.out.println("wfValData called");
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
switch (currentFormNo) {
case 1:
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
System.out.println("COUNT OF CHILD NODE LIST"+childNodeListLength);
System.out.println("COUNT OF CHILD NODE LIST(ctr<childnodelist)"+ctr);
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNode@@"+childNode);
int seriCount = 0;
discList = genericUtility.getColumnValue("disc_list", dom);
descr = genericUtility.getColumnValue("descr", dom);
shDescr=checkNull(genericUtility.getColumnValue("sh_descr", dom));
calcType=checkNull(genericUtility.getColumnValue("calc_type", dom));
String Sql = "SELECT COUNT(1) AS COUNT FROM disc_list WHERE disc_list=? AND descr=? and sh_descr=? and calc_type=?";
pstmt = conn.prepareStatement(Sql);
pstmt.setString(1,discList);
pstmt.setString(2,descr);
pstmt.setString(3,shDescr);
pstmt.setString(4,calcType);
rs = pstmt.executeQuery();
System.out.println("Sql@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" + Sql);
if (rs.next())
{
seriCount = rs.getInt("COUNT");
}
System.out.println("COunt is@@@@@@@@@dhiraj$$$$$$$$$"+seriCount);
System.out.println("editFlag"+editFlag);
if (!editFlag.equalsIgnoreCase("E"))
{
System.out.println("@@@@@Start point@@@@I am at --(!editFlag.equalsIgnoreCase----)$$$$$$$$$");
if (seriCount > 0)
{
System.out.println("@@@@@middle point@@@@I am at --(!editFlag.equalsIgnoreCase----)$$$$$$$$$");
errString = getErrorString(" ", "VMDUPREC1", userId);
System.out.println("@@@@@before break point@@@@I am at --(!editFlag.equalsIgnoreCase----)$$$$$$$$$");
break;
}
}
if (childNodeName.equalsIgnoreCase("disc_list"))
{
discList = genericUtility.getColumnValue("disc_list", dom);
//discList = genericUtility.getColumnValue("disc_list",dom);
if (discList == null || discList.trim().length() == 0)
{
errString = getErrorString(" ", "VMDISCNE", userId);
break;
}
if(editFlag.equals("A"))
{
if(discList != null && discList.trim().length() > 0)
{
sql = "select count(1) from disc_list where disc_list = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, discList);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (cnt == 1) {
errString = getErrorString(" ", "VMDISDUP", userId);
break;
}
}}
} else if (childNodeName.equalsIgnoreCase("descr"))
{
descr = genericUtility.getColumnValue("descr", dom);
if (descr == null )
{
errString = getErrorString(" ", "VMDESCNB", userId);
break;
}
}
else if(childNodeName.equalsIgnoreCase("sh_descr"))
{
shDescr = genericUtility.getColumnValue("sh_descr",dom);
if(shDescr == null || shDescr.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMSDESCNB",userId);
break ;
}
}
else if(childNodeName.equalsIgnoreCase("calc_type"))
{
calcType = checkNull(genericUtility.getColumnValue("calc_type",dom));
System.out.println(" calcType @@" +calcType);
if(calcType == null || calcType.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMCALCT ",userId);
break ;
}
}
}
break;
}
} catch (Exception e) {
System.out.println("Exception ::" + e);
e.printStackTrace();
errCode = "VALEXCEP";
errString = getErrorString("", errCode, userId);
} finally {
try {
if (conn != null) {
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (rs != null) {
rs.close();
rs = null;
}
conn.close();
}
conn = null;
} catch (Exception d) {
d.printStackTrace();
}
System.out.println(" < DistListIC > CONNECTION IS CLOSED");
}
System.out.println("@@@@@@@@dhiraj@@@@@@@@@@ErrString ::" + errString);
return errString;
}// END OF VALIDATION
@Override
public String itemChanged(String xmlString, String xmlString1,
String xmlString2, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException,
ITMException {
Document dom1 = null;
Document dom = null;
Document dom2 = null;
String valueXmlString = "";
//GenericUtility genericUtility = GenericUtility.getInstance();
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0) {
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
dom2 = genericUtility.parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext,
currentColumn, editFlag, xtraParams);
} catch (Exception e) {
System.out
.println("Exception :DistListIC:itemChanged(String,String,String,String,String,String):"
+ e.getMessage() + ":");
valueXmlString = genericUtility.createErrorString(e);
e.printStackTrace();
}
System.out.println("returning from DistListIC:itemChanged");
return (valueXmlString);
}
/* @Override
public String itemChanged(Document dom, Document dom1, Document dom2,
String objContext, String currentColumn, String editFlag,
String xtraParams) throws RemoteException, ITMException {
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
int currentFormNo = 0;
//GenericUtility genericUtility;
String siteCode = "", sitedescr = "";
String custname = "";
String descList="",discDesc="";
String itemSerDescr="",empCode="",descr="",empCode1="";
try {
//genericUtility = genericUtility.getInstance();
// siteCode = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
ConnDriver conndriver = new ConnDriver();
conn = conndriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
conndriver = null;
if (objContext != null && objContext.trim().length() > 0)
currentFormNo = Integer.parseInt(objContext);
currentColumn = currentColumn == null ? "" : currentColumn.trim();
System.out.println("currentColumn : " + currentColumn);
valueXmlString = new StringBuffer(
"<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("current form no: " + currentFormNo);
System.out.println("dom:::::::::: : "
+ genericUtility.serializeDom(dom));
System.out.println("dom11111111111111:::::::::: : "
+ genericUtility.serializeDom(dom1));
System.out.println("dom222222222222222:::::::::: : "
+ genericUtility.serializeDom(dom2));
switch (currentFormNo) {
case 1:
valueXmlString.append("<Detail1>");
if ("itm_default".equalsIgnoreCase(currentColumn)) {
System.out.println("itm_default : ");
System.out.println("Content of xtraParams ..> "
+ xtraParams);
// tranDate = (sdf.format(timestamp).toString()).trim();
}
if (currentColumn.trim().equalsIgnoreCase("disc_list")) {
if (!editFlag.equalsIgnoreCase("E"))
{
String descList="",discDesc="";
descList=genericUtility.getColumnValue("disc_list", dom);
sql = "select descr from disc_list where disc_list=? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, descList);
rs = pStmt.executeQuery();
if (rs.next())
{
discDesc = rs.getString(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
System.out.println("itm_defaultedit@discDescription@"+discDesc);
discDesc = discDesc == null ? "" : discDesc.trim();
System.out.println("discDesc["+discDesc+"]");
System.out.println("IN IF EditFlag["+editFlag+"]");
//valueXmlString.append("<profile_id protect = \"0\" >").append("<![CDATA[" + itmEditprofile + "]]>").append("</profile_id>");
//valueXmlString.append("<disc_list>").append("<![CDATA[" + descList + "]]>").append("</disc_list>");
valueXmlString.append("<descr protect = \"0\" >").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
//valueXmlString.append("<descr protect = \"0\" >").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
//valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
//valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
}
}
sql = "select descr from disc_list where disc_list=? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, descList);
rs = pStmt.executeQuery();
if (rs.next())
{
discDesc = rs.getString(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
System.out.println("itm_defaultedit@discDescription@"+discDesc);
discDesc = discDesc == null ? "" : discDesc.trim();
System.out.println("discDesc["+discDesc+"]");
if (!editFlag.equalsIgnoreCase("E"))
{
descList=genericUtility.getColumnValue("disc_list", dom);
sql = "select descr from disc_list where disc_list=? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, descList);
rs = pStmt.executeQuery();
if (rs.next())
{
discDesc = rs.getString(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
System.out.println("itm_defaultedit@discDescription@"+discDesc);
discDesc = discDesc == null ? "" : discDesc.trim();
System.out.println("discDesc["+discDesc+"]");
System.out.println("IN IF EditFlag["+editFlag+"]");
//valueXmlString.append("<profile_id protect = \"0\" >").append("<![CDATA[" + itmEditprofile + "]]>").append("</profile_id>");
//valueXmlString.append("<disc_list>").append("<![CDATA[" + descList + "]]>").append("</disc_list>");
valueXmlString.append("<descr protect = \"0\" >").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
//valueXmlString.append("<descr protect = \"0\" >").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
//valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
//valueXmlString.append("<descr>").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
}
valueXmlString.append("<descr protect = \"0\" >").append("<![CDATA[" + discDesc + "]]>").append("</descr>");
valueXmlString.append("</Detail1 >");
break;
}
valueXmlString.append("</Root>\r\n");
} catch (Exception e) {
System.out
.println("Exception :EmpPoLimitIC•@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@••••••(Document,String):"
+ e.getMessage() + ":");
valueXmlString.delete(0, valueXmlString.length());
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
System.out.println("\n***** ValueXmlString :" + valueXmlString
+ ":*******");
return valueXmlString.toString();
}*/
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
@Local
public interface DiscListICLocal {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
@Remote
public interface DiscListICRemote {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
/*
* Added By Dhiraj Chavan
* Req#-D16BSUN009
* DATE -30-JUNE-2016
*
* */
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.Calendar;
import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class PoStatChgConf extends ActionHandlerEJB implements PoStatChgConfLocal,PoStatChgConfRemote
{
E12GenericUtility genericUtility= new E12GenericUtility();
public String actionHandler() throws RemoteException, ITMException
{
return "";
}
public String actionHandler(String tranId, String xtraParams, String forcedFlag)
throws RemoteException, ITMException
{
String returnString = null;
System.out.println(".......tranId......." + tranId);
System.out.println(".......xtraParams..." + xtraParams);
System.out.println(".......forcedFlag..." + forcedFlag);
if ((tranId != null) && (tranId.trim().length() > 0))
{
returnString = confirm(tranId, xtraParams, forcedFlag);
System.out.println("returnString@@dhiraj@@"+returnString);
}
return returnString;
}
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException
{
System.out.println("POrderAmdConf confirm called..............");
String confirmed = "";
String sql = "",sql1="";
// String sql1 = "";
// int status = 0;
double quantity = 0.0,ordQty=0.0,indQty=0.0,qty=0.0,totalQty=0.0,dlvQty=0.0;
// Date lrDate = null;
//Connection conn = null;
PreparedStatement pstmt = null,pstmt1 = null;
// PreparedStatement pstmt1 = null;
ITMDBAccessEJB itmDBAccessEJB = null;
String errString = "", errCode = "",indNo="",errString1="";
ResultSet rs = null,rs1 = null;
// ResultSet rs1 = null;
String purcOrder = "", poStatus = "",lineNo="", amdNo = "",statusReason="", workflowStatus = "",poHdrStatus="",indentNo="",status="";
int recCnt = 0, cnt = 0,statusCnt=0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
//purcOrder=genericUtility.getColumnValue("purc_order",dom);
itmDBAccessEJB = new ITMDBAccessEJB();
DistCommon distCommon = new DistCommon();
Connection conn = null;
try {
ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
conn.setAutoCommit(false);
connDriver = null;
} catch (Exception e) {
System.out.println("Exception :POStatChgConf :ejbCreate :==>"
+ e);
e.printStackTrace();
}
try
{
int updCnt=0;
Timestamp sysDate1 = null;
SimpleDateFormat sdf1 = null;
String sysDateStr1 = "";
//DistCommon distCommon = new DistCommon();
Calendar currentDate = Calendar.getInstance();
sdf1 = new SimpleDateFormat(
genericUtility.getApplDateFormat());
sysDateStr1 = sdf1.format(currentDate.getTime());
System.out
.println("after conf method Now the date is :=> "
+ sysDateStr1);
sysDate1 = Timestamp.valueOf(genericUtility
.getValidDateString(sysDateStr1,
genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat())
+ " 00:00:00.0");
String userId = genericUtility.getValueFromXTRA_PARAMS(
xtraParams, "loginCode");
double poDetQty=0,quantityStduom=0,orderQty=0,convIndOrdQty=0;
String unit="",unitStd="",itemCode="";
sql = " Select purc_order,confirmed,status_reason from porder_stat_chg Where tran_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
if(rs.next())
{
purcOrder=rs.getString(1);
confirmed=rs.getString(2);
statusReason=rs.getString(3);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(confirmed.equals("C")||confirmed.equalsIgnoreCase("C"))
{
errString = itmDBAccessEJB.getErrorString("", "VTRECONF", "",
"", conn);
return errString;
}
sql = " Select count(*) from porcp Where purc_order=? and confirmed = 'N' and tran_ser='P-RCP' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs=pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt>0)
{
errCode = "VTPORCPCN";
errCode = itmDBAccessLocal.getErrorString("", errCode, "");
return errCode;
}
sql = " Select count(*) from porcp Where purc_order=? and confirmed = 'N' and tran_ser='P-RET' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs=pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt>0)
{
errCode = "VTPORETCL";
errCode = itmDBAccessLocal.getErrorString("", errCode, "");
return errCode;
}
sql = " Select status from porder Where purc_order=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs=pstmt.executeQuery();
if(rs.next())
{
status=rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(status.equals("C"))
{
int count=0;
System.out.println("@tranID@@"+purcOrder);
sql1 = " select quantity,ind_no,dlv_qty,unit,unit__std,item_code,line_no from porddet where purc_order=? and status='C' and (dlv_qty<quantity) ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, purcOrder);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
count++;
System.out.println("whileCount@@"+count);
quantity = rs1.getDouble(1);
indNo = rs1.getString(2);
dlvQty = rs1.getDouble(3);
unit=rs1.getString(4);
unitStd=rs1.getString(5);
itemCode=rs1.getString(6);
lineNo=rs1.getString(7);
System.out.println("@quantity@@"+quantity);
System.out.println("@indNo@@"+indNo);
System.out.println("@dlvQty@@"+dlvQty);
System.out.println("@unit@@"+unit);
System.out.println("@unitStd@@"+unitStd);
System.out.println("@itemCode@@"+itemCode);
if(indNo!=null)
{
System.out.println("INDENT NUMBER FOUND"+indNo);
sql = " Select ord_qty,quantity__stduom from indent Where ind_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, indNo);
rs=pstmt.executeQuery();
if(rs.next())
{
orderQty=rs.getDouble(1);
quantityStduom=rs.getDouble(2);
}
System.out.println("orderQty@@"+orderQty);
System.out.println("quantityStduom@@"+quantityStduom);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
poDetQty=quantity-dlvQty;
System.out.println("[quantity-dlvQty][::"+poDetQty+"::]");
//conversion function
convIndOrdQty=distCommon.convQtyFactor(unit, unitStd, itemCode, poDetQty, conn) ;
System.out.println("convIndOrdQty"+convIndOrdQty);
double indOrdQty=orderQty+convIndOrdQty;
System.out.println("indOrdQty@Partly@[orderQty+convIndOrdQty]"+indOrdQty);
sql = " update porder set status='O' ,status_reason=? where purc_order=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, statusReason);
pstmt.setString(2, purcOrder);
//pstmt.setString(2, purcOrder);
updCnt=pstmt.executeUpdate();
System.out.println("porder updated@@@"+updCnt);
// rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = " update porddet set status='O' where ind_no=? and purc_order=? and line_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, indNo);
pstmt.setString(2, purcOrder);
pstmt.setString(3, lineNo);
updCnt=pstmt.executeUpdate();
System.out.println("porddet updated@@@"+updCnt);
//rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(indOrdQty==quantityStduom)
{
System.out.println("(indOrdQty==quantityStduom)");
sql=null;
sql = " update indent set status='L' ,ord_qty="+indOrdQty+" ,status_date=? where ind_no=? ";
}else
{
System.out.println("(indOrdQty!=quantityStduom)@NOT EQUAL");
sql=null;
sql = " update indent set status='O' ,ord_qty="+indOrdQty+" ,status_date=? where ind_no=? ";
}
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDate1);
pstmt.setString(2, indNo);
updCnt=pstmt.executeUpdate();
System.out.println("Indent Updated"+updCnt);
//rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql=null;
}
else//without indent condition
{
System.out.println("without indent condition with status C");
sql = " update porder set status='O' ,status_reason=? where purc_order=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, statusReason);
pstmt.setString(2, purcOrder);
//pstmt.setString(2, purcOrder);
updCnt=pstmt.executeUpdate();
System.out.println("porder updCnt"+updCnt);
//rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = " update porddet set status='O' where purc_order=? and line_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
pstmt.setString(2, lineNo);
updCnt=pstmt.executeUpdate();
System.out.println("porddet updCnt"+updCnt);
//rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}else if(status.equals("O"))
{
System.out.println("comming into status O condition@@");
int count=0;
System.out.println("@tranID@@"+purcOrder);
sql1 = " select quantity,ind_no,dlv_qty,unit,unit__std,item_code,line_no from porddet where purc_order=? and status='C' and (dlv_qty<quantity) ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, purcOrder);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
count++;
System.out.println("whileCount@@"+count);
quantity = rs1.getDouble(1);
indNo = rs1.getString(2);
dlvQty = rs1.getDouble(3);
unit=rs1.getString(4);
unitStd=rs1.getString(5);
itemCode=rs1.getString(6);
lineNo=rs1.getString(7);
System.out.println("@quantity@@"+quantity);
System.out.println("@indNo@@"+indNo);
System.out.println("@dlvQty@@"+dlvQty);
System.out.println("@unit@@"+unit);
System.out.println("@unitStd@@"+unitStd);
System.out.println("@itemCode@@"+itemCode);
if(indNo!=null)
{
System.out.println("INDENT NUMBER FOUND"+indNo);
sql = " Select ord_qty,quantity__stduom from indent Where ind_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, indNo);
rs=pstmt.executeQuery();
if(rs.next())
{
orderQty=rs.getDouble(1);
quantityStduom=rs.getDouble(2);
}
System.out.println("orderQty@@"+orderQty);
System.out.println("quantityStduom@@"+quantityStduom);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
poDetQty=quantity-dlvQty;
System.out.println("[quantity-dlvQty][::"+poDetQty+"::]");
//conversion function
convIndOrdQty=distCommon.convQtyFactor(unit, unitStd, itemCode, poDetQty, conn) ;
System.out.println("convIndOrdQty"+convIndOrdQty);
double indOrdQty=orderQty+convIndOrdQty;
System.out.println("indOrdQty@Partly@[orderQty+convIndOrdQty]"+indOrdQty);
sql = " update porder set status='O' ,status_reason=? where purc_order=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, statusReason);
pstmt.setString(2, purcOrder);
//pstmt.setString(2, purcOrder);
updCnt=pstmt.executeUpdate();
System.out.println("porder updated@@@"+updCnt);
// rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = " update porddet set status='O' where ind_no=? and purc_order=? and line_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, indNo);
pstmt.setString(2, purcOrder);
pstmt.setString(3, lineNo);
updCnt=pstmt.executeUpdate();
System.out.println("porddet updated@@@"+updCnt);
//rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(indOrdQty==quantityStduom)
{
System.out.println("(indOrdQty==quantityStduom)");
sql=null;
sql = " update indent set status='L' ,ord_qty="+indOrdQty+" ,status_date=? where ind_no=? ";
}else
{
System.out.println("(indOrdQty!=quantityStduom)@NOT EQUAL");
sql=null;
sql = " update indent set status='O' ,ord_qty="+indOrdQty+" ,status_date=? where ind_no=? ";
}
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDate1);
pstmt.setString(2, indNo);
updCnt=pstmt.executeUpdate();
System.out.println("Indent Updated"+updCnt);
//rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql=null;
}
else//without indent condition
{
System.out.println("without indent condition with status C");
sql = " update porder set status='O' ,status_reason=? where purc_order=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, statusReason);
pstmt.setString(2, purcOrder);
//pstmt.setString(2, purcOrder);
updCnt=pstmt.executeUpdate();
System.out.println("porder updCnt"+updCnt);
//rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = " update porddet set status='O' where purc_order=? and line_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
pstmt.setString(2, lineNo);
updCnt=pstmt.executeUpdate();
System.out.println("porddet updCnt"+updCnt);
//rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
else if(status.equals("X"))
{
System.out.println("Comming into status=X");
sql = " Select count(1) from porddet Where status='C' and purc_order=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs=pstmt.executeQuery();
if(rs.next())
{
statusCnt=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("statusCnt@@@"+statusCnt);
/* if(statusCnt==0)
{
sql=null;
sql1 = " select quantity,ind_no,dlv_qty,unit,unit__std,item_code,line_no from porddet where purc_order=? and status='O' ";
}else*/
//{
//sql=null;
sql1 = " select quantity,ind_no,dlv_qty,unit,unit__std,item_code,line_no from porddet where purc_order=? and (dlv_qty<quantity) ";
//}
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, purcOrder);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
quantity = rs1.getDouble(1);
indNo = rs1.getString(2);
dlvQty = rs1.getDouble(3);
unit=rs1.getString(4);
unitStd=rs1.getString(5);
itemCode=rs1.getString(6);
lineNo=rs1.getString(7);
System.out.println("@quantity@@"+quantity);
System.out.println("@indNo@@"+indNo);
System.out.println("@dlvQty@@"+dlvQty);
System.out.println("@unit@@"+unit);
System.out.println("@unitStd@@"+unitStd);
System.out.println("@itemCode@@"+itemCode);
if(indNo!=null)
{
System.out.println("INDENT NUMBER FOUND"+indNo);
sql = " Select ord_qty,quantity__stduom from indent Where ind_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, indNo);
rs=pstmt.executeQuery();
if(rs.next())
{
orderQty=rs.getDouble(1);
quantityStduom=rs.getDouble(2);
}
System.out.println("orderQty@@"+orderQty);
System.out.println("quantityStduom@@"+quantityStduom);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
poDetQty=quantity-dlvQty;
System.out.println("[quantity-dlvQty][::"+poDetQty+"::]");
//conversion function
convIndOrdQty=distCommon.convQtyFactor(unit, unitStd, itemCode, poDetQty, conn) ;
System.out.println("convIndOrdQty"+convIndOrdQty);
double indOrdQty=orderQty+convIndOrdQty;
System.out.println("indOrdQty@Partly@[orderQty+convIndOrdQty]"+indOrdQty);
if(indOrdQty==quantityStduom)
{
System.out.println("(indOrdQty==quantityStduom)");
sql=null;
sql = " update indent set status='L' ,ord_qty="+indOrdQty+" ,status_date=? where ind_no=? ";
}else
{
System.out.println("(indOrdQty!=quantityStduom)@NOT EQUAL");
sql=null;
sql = " update indent set status='O' ,ord_qty="+indOrdQty+" ,status_date=? where ind_no=? ";
}
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDate1);
pstmt.setString(2, indNo);
updCnt=pstmt.executeUpdate();
System.out.println("Indent Updated"+updCnt);
//rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql=null;
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
sql = " update porder set status='O' ,status_reason=? where purc_order=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, statusReason);
pstmt.setString(2, purcOrder);
//pstmt.setString(2, purcOrder);
updCnt=pstmt.executeUpdate();
System.out.println("porder updated"+updCnt);
//rs.close();
//rs = null;
pstmt.close();
pstmt = null;
//}
}
try {
//Timestamp sysDate1 = null;
System.out.println("TranID@"+tranId);
sql = " update porder_stat_chg set CONFIRMED='C' ,conf_date=? where tran_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDate1);
pstmt.setString(2, tranId);
//pstmt.setString(2, purcOrder);
updCnt=pstmt.executeUpdate();
System.out.println("porder_stat_chg updated"+updCnt);
//rs.close();
//rs = null;
pstmt.close();
pstmt = null;
if(updCnt>0){
System.out.println("Comming into Success messages");
errString1 = itmDBAccessEJB.getErrorString(" ", "VTTRNCNF", userId);
return errString1;
}
} catch (Exception e) {
e.printStackTrace();
if(errString1==null)
{System.out.println("got errString exception"+e.getMessage());
conn.rollback();
conn.close();
}
}
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Unable to Confirmed@@");
throw new ITMException(e);
}
finally
{
try
{
System.out.println( ">>>>>>>>>>>>>In finaly errString:"+errString);
if (errString != null && errString.trim().length() > 0 && !("d".equalsIgnoreCase(errString)))
{
conn.rollback();
System.out.println("Transaction rollback... ");
conn.close();
conn = null;
}
else
{
System.out.println(" Confirmed Success@@");
conn.commit(); // test
System.out.println("@@@@ Transaction commit... ");
conn.close();
conn = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("errString[" + errString + "]:::::::::::errCode[" + errCode + "]");
return errString;
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface PoStatChgConfLocal extends ActionHandlerLocal
{
public String actionHandler() throws RemoteException,ITMException;
//public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface PoStatChgConfRemote extends ActionHandlerRemote
{
public String actionHandler() throws RemoteException,ITMException;
//public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag) 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.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.ejb.Stateless;
import org.bouncycastle.asn1.cms.TimeStampAndCRL;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//import com.sun.org.apache.bcel.internal.generic.RETURN;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
@Stateless
public class PoStatChgIC extends ValidatorEJB implements PoStatChgICLocal,PoStatChgICRemote{
E12GenericUtility genericUtility=new E12GenericUtility();
public String wfValData() throws RemoteException, ITMException {
return "";
}
public String itemChanged() throws RemoteException, ITMException {
return "";
}
public String wfValData(String xmlString, String xmlString1,
String xmlString2, String objContext, String editFlag,
String xtraParams) throws RemoteException, ITMException {
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try {
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0) {
dom2 = parseString(xmlString2);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag,
xtraParams);
} catch (Exception e) {
System.out.println("Exception : EmpPoLimit : wfValData(String xmlString) : ==>\n"+ e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1, Document dom2,
String objContext, String editFlag, String xtraParams)
throws RemoteException, ITMException
{
String errString = " ",confirmed="";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
String errCode = null;
String userId = null;
int cnt = 0,gimCnt=0;
int ctr = 0;
String purcOrder="";
int currentFormNo = 0;
int childNodeListLength;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
Timestamp effDate=null;
Timestamp validDate=null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String status="";
//Timestamp eff_from1=null, valid_upto1=null;
ConnDriver connDriver = new ConnDriver();
try {
System.out.println("wfValData called");
conn = getConnection();
/*conn = connDriver.getConnectDB("DriverITM");*/
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
switch (currentFormNo) {
case 1:
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
System.out.println("COUNT OF CHILD NODE LIST"+childNodeListLength);
System.out.println("COUNT OF CHILD NODE LIST(ctr<childnodelist)"+ctr);
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNode@@"+childNode);
int seriCount = 0;
if (childNodeName.equalsIgnoreCase("purc_order"))
{
purcOrder = genericUtility.getColumnValue("purc_order",dom);
if (purcOrder == null)
{
errString = getErrorString(" ", "VTPUREPT", userId);
break;
}
if(purcOrder != null && purcOrder.trim().length() > 0)
{
sql = "select count(1) from porder where purc_order = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
sql = "select confirmed from PORDER_STAT_CHG where purc_order = ? and confirmed='U'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs = pstmt.executeQuery();
if (rs.next()) {
//status = rs.getString(1);
confirmed=rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println("confirmed@postatchg@@"+confirmed);
if(confirmed.equals("U")||confirmed.equalsIgnoreCase("U"))
{
errCode = "VMUNCPO";
errString = getErrorString("purc_order",
errCode, userId);
break;
}
sql = "select status,confirmed from porder where purc_order = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs = pstmt.executeQuery();
if (rs.next()) {
status = rs.getString(1);
confirmed=rs.getString(2);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
sql = "select count(1) from porddet where purc_order = ? and (dlv_qty<quantity) and status='C' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, purcOrder);
rs = pstmt.executeQuery();
if (rs.next()) {
gimCnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (cnt == 0) {
errCode = "VMPURINV";
errString = getErrorString("purc_order",
errCode, userId);
break;
}
if (confirmed.equals("N")) {
System.out.println("not confirmed po");
errCode = "VTPOUNC";
errString = getErrorString("purc_order",
errCode, userId);
break;
}
if (status.equals("O") ) {
if(gimCnt>0)
{
System.out.println("allow to open@gimCnt>0");
break;
}
System.out.println("Already open");
errCode = "VMPOENC";
errString = getErrorString("purc_order",
errCode, userId);
break;
}
if(gimCnt==0 && status.equals("C")){
//only for one indent and one line of PO with full RCP
System.out.println("Gim count found");
errCode = "VTLNDNF";
errString = getErrorString("purc_order",
errCode, userId);
break;
}
}
} /*
if (!editFlag.equalsIgnoreCase("E")) {
System.out.println("Comming to !editFlag condition");
sql=null;
sql=" select COUNT(1) from emp_po_limit where emp_code=? and item_ser=? and ( ( ? BETWEEN eff_from AND valid_upto ) OR (? BETWEEN eff_from AND valid_upto ))";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,empCode);
pstmt.setString(2,itemSeries);
pstmt.setTimestamp(3,effDate);
pstmt.setTimestamp(4,validDate);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
System.out.println("CHECKING DUPLICATE PERIOD"+cnt);
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt > 0) {
errString = itmDBAccessEJB.getErrorString("","VMRECD ",userId);
break ;
}
}*/
}
break;
}
} catch (Exception e) {
System.out.println("Exception ::" + e);
e.printStackTrace();
errCode = "VALEXCEP";
errString = getErrorString("", errCode, userId);
} finally {
try {
if (conn != null) {
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (rs != null) {
rs.close();
rs = null;
}
conn.close();
}
conn = null;
} catch (Exception d) {
d.printStackTrace();
}
System.out.println(" < PoStatChgEJB > CONNECTION IS CLOSED");
}
System.out.println("@@@@@@@@dhiraj@@@@@@@@@@ErrString ::" + errString);
return errString;
}// END OF VALIDATION
@Override
public String itemChanged(String xmlString, String xmlString1,
String xmlString2, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException,
ITMException {
Document dom1 = null;
Document dom = null;
Document dom2 = null;
String valueXmlString = "";
//GenericUtility genericUtility = GenericUtility.getInstance();
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0) {
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
dom2 = genericUtility.parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext,
currentColumn, editFlag, xtraParams);
} catch (Exception e) {
System.out
.println("Exception :PoStatChgEJBValid:itemChanged(String,String,String,String,String,String):"
+ e.getMessage() + ":");
valueXmlString = genericUtility.createErrorString(e);
e.printStackTrace();
}
System.out.println("returning from PoStatChgEJBValid itemChanged");
return (valueXmlString);
}
@Override
public String itemChanged(Document dom, Document dom1, Document dom2,
String objContext, String currentColumn, String editFlag,
String xtraParams) throws RemoteException, ITMException {
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pStmt = null;
Statement Stmt=null;
ResultSet rs = null;
String sql = "";
int currentFormNo = 0;
//GenericUtility genericUtility;
String siteCode = "", sitedescr = "";
String purcOrder="",suppName="";
String tranDate="",empCodeApr="",suppCode="",purcOrder1="",totAmt="";
String empFname="",empMname="",empLname="",confirmed="",status="";
double totAmt1=0.0;
String itemSerDescr="",empCode="",descr="",empCode1="",siteDescr="";
String siteCodeOrd="",ordDescrSite="",siteCodeDlv="",dlvDescrSite="";
//SimpleDateFormat sdf = null;
Timestamp today = null;
java.sql.Timestamp confDate=null;
String tran_Date=null;
try {
//genericUtility = genericUtility.getInstance();
// siteCode = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(
genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDate);
ConnDriver conndriver = new ConnDriver();
//conn = conndriver.getConnectDB("DriverITM");
conn = getConnection();
conn.setAutoCommit(false);
conndriver = null;
if (objContext != null && objContext.trim().length() > 0)
currentFormNo = Integer.parseInt(objContext);
currentColumn = currentColumn == null ? "" : currentColumn.trim();
System.out.println("currentColumn : " + currentColumn);
valueXmlString = new StringBuffer(
"<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("current form no: " + currentFormNo);
System.out.println("dom:::::::::: : "
+ genericUtility.serializeDom(dom));
System.out.println("dom11111111111111:::::::::: : "
+ genericUtility.serializeDom(dom1));
System.out.println("dom222222222222222:::::::::: : "
+ genericUtility.serializeDom(dom2));
String loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
String chguserhdr = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
String chgtermhdr = getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
//loginEmpCode
Timestamp currDate = getCurrdateAppFormat();
String loginEmpCode = getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
switch (currentFormNo) {
case 1:
valueXmlString.append("<Detail1>");
if ("itm_default".equalsIgnoreCase(currentColumn)) {
System.out.println("itm_default : ");
System.out.println("Content of xtraParams ..> "
+ xtraParams);
/* String tranId="";
try
{
String windowName="W_POSTAT_CHG";
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE UPPER(TRAN_WINDOW)= '"+windowName+"'";
Stmt = conn.createStatement();
rs = Stmt.executeQuery(sql);
String tranSer1 = "";
String keyString = "";
String keyCol = "";
if (rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer1 :"+tranSer1);
//System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(dom, "SYSTEM", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
rs.close();
rs = null;
Stmt.close();
Stmt = null;
}
catch (SQLException ex)
{
System.out.println("Exception ::" +sql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
*/
if (loginSite != null || loginEmpCode!=null )
{
sql = "select descr from site where site_code = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, loginSite);
rs = pStmt.executeQuery();
if (rs.next())
{
siteDescr = rs.getString("descr");
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
sql = "select emp_fname,emp_mname,emp_lname from employee where emp_code = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, loginEmpCode);
rs = pStmt.executeQuery();
if (rs.next())
{
empFname = rs.getString(1);
empMname = rs.getString(2);
empLname = rs.getString(3);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
/*StockUpdate stockupd=new StockUpdate();
TransIDGenerator tg=new TransIDGenerator(xmlString, loginUser, database);
*/
//loginEmpCode tran_date
///tranId
//valueXmlString.append("<tran_id>").append("<![CDATA[" + tranId + "]]>").append("</tran_id>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + sysDate + "]]>").append("</tran_date>");
valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + siteDescr + "]]>").append("</descr>");
valueXmlString.append("<emp_code__aprv>").append(loginEmpCode)
.append("</emp_code__aprv>\r\n");
valueXmlString.append("<emp_code__aprv>").append("<![CDATA[" + loginEmpCode + "]]>").append("</emp_code__aprv>");
valueXmlString.append("<fname>").append("<![CDATA[" + empFname + "]]>").append("</fname>");
valueXmlString.append("<mname>").append("<![CDATA[" + empMname + "]]>").append("</mname>");
valueXmlString.append("<lname>").append("<![CDATA[" + empLname + "]]>").append("</lname>");
valueXmlString.append("<conf_date>").append("<![CDATA[" + sysDate + "]]>").append("</conf_date>");
valueXmlString.append("<add_date>").append("<![CDATA[" + sysDate + "]]>").append("</add_date>");
// tranDate = (sdf.format(timestamp).toString()).trim();
}
if (currentColumn.trim().equalsIgnoreCase("purc_order")) {
purcOrder = genericUtility.getColumnValue("purc_order", dom);
tranDate = genericUtility.getColumnValue("tran_date", dom);
siteCode = genericUtility.getColumnValue("site_code", dom);
empCodeApr = genericUtility.getColumnValue("emp_code_apr", dom);
suppCode= genericUtility.getColumnValue("supp_code", dom);
sql = " select tot_amt,emp_code__aprv,supp_code,site_code__dlv,confirmed,conf_date,status from porder where purc_order=?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, purcOrder);
rs = pStmt.executeQuery();
if (rs.next()) {
totAmt1 = rs.getDouble(1);
empCodeApr=rs.getString(2);
suppCode=rs.getString(3);
siteCode=rs.getString(4);
confirmed=rs.getString(5);
confDate=rs.getTimestamp(6);
status=rs.getString(7);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
sql = " select emp_fname,emp_mname,emp_lname from employee where emp_code=?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, empCodeApr);
rs = pStmt.executeQuery();
if (rs.next()) {
empFname = rs.getString(1);
empMname = rs.getString(2);
empLname = rs.getString(3);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
sql = " select supp_name from supplier where supp_code=?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, suppCode);
rs = pStmt.executeQuery();
if (rs.next()) {
suppName = rs.getString(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
sql = " select site_code__ord,site_code__dlv from porder where purc_order=?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, purcOrder);
rs = pStmt.executeQuery();
if (rs.next()) {
siteCodeOrd = rs.getString(1);
siteCodeDlv = rs.getString(2);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
sql = " select site_code,descr from site where site_code=?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, siteCodeOrd);
rs = pStmt.executeQuery();
if (rs.next()) {
siteCodeOrd = rs.getString(1);
ordDescrSite = rs.getString(2);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
sql = " select site_code,descr from site where site_code=?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, siteCodeDlv);
rs = pStmt.executeQuery();
if (rs.next()) {
siteCodeDlv = rs.getString(1);
dlvDescrSite = rs.getString(2);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
System.out.println("totAmt1@@" + totAmt1);
valueXmlString.append("<site_code>").append("<![CDATA[" + siteCodeDlv + "]]>").append("</site_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + dlvDescrSite + "]]>").append("</descr>");
valueXmlString.append("<site_code__ord>").append("<![CDATA[" + siteCodeOrd + "]]>").append("</site_code__ord>");
valueXmlString.append("<site_descr>").append("<![CDATA[" + ordDescrSite + "]]>").append("</site_descr>");
valueXmlString.append("<emp_code__aprv>").append("<![CDATA[" + loginEmpCode + "]]>").append("</emp_code__aprv>");
valueXmlString.append("<fname>").append("<![CDATA[" + empFname + "]]>").append("</fname>");
valueXmlString.append("<mname>").append("<![CDATA[" + empMname + "]]>").append("</mname>");
valueXmlString.append("<lname>").append("<![CDATA[" + empLname + "]]>").append("</lname>");
valueXmlString.append("<supp_code>").append("<![CDATA[" + suppCode + "]]>").append("</supp_code>");
valueXmlString.append("<supp_name>").append("<![CDATA[" + suppName + "]]>").append("</supp_name>");
valueXmlString.append("<tot_amt>").append("<![CDATA[" + totAmt1 + "]]>").append("</tot_amt>");
/*valueXmlString.append("<status>").append("<![CDATA[" + status + "]]>").append("</status>");
valueXmlString.append("<confirmed>").append("<![CDATA[" + confirmed + "]]>").append("</confirmed>");
*/
valueXmlString.append("<conf_date>").append("<![CDATA[" + sysDate + "]]>").append("</conf_date>");
}
valueXmlString.append("</Detail1 >");
break;
}
valueXmlString.append("</Root>\r\n");
} catch (Exception e) {
System.out
.println("Exception :PoStatChgIC•@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@••••••(Document,String):"
+ e.getMessage() + ":");
valueXmlString.delete(0, valueXmlString.length());
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
System.out.println("\n***** ValueXmlString :" + valueXmlString
+ ":*******");
return valueXmlString.toString();
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
private java.sql.Timestamp getCurrdateAppFormat()
{
String currAppdate ="";
java.sql.Timestamp currDate = null;
try
{
Object date = null;
currDate =new java.sql.Timestamp(System.currentTimeMillis()) ;
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate).toString();
}
catch(Exception e)
{
System.out.println("Exception in :::calcFrsBal"+e.getMessage());
}
return currDate;
//LINE COMMENTED BY MSALAM AS TIMESTAMP IS NEEDED
//return (currAppdate);
}
}
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;
@Local
public interface PoStatChgICLocal extends ValidatorLocal{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
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.Remote;
@Remote
public interface PoStatChgICRemote extends ValidatorRemote{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
......@@ -3,8 +3,10 @@ package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
//import ibase.webitm.utility.GenericUtility;
import java.sql.*;
import javax.ejb.*;
import ibase.webitm.ejb.*;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.utility.CommonConstants;
......@@ -25,6 +27,7 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
//GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility= new E12GenericUtility();
DecimalFormat df = new DecimalFormat( "##.00" );
ibase.webitm.ejb.sys.UtilMethods utilMethods = ibase.webitm.ejb.sys.UtilMethods.getInstance();
public String postSaveRec() throws RemoteException,ITMException
{
......@@ -65,6 +68,9 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
PreparedStatement upDtPlPStmt = null;
PreparedStatement chkPlpstmt = null;
PreparedStatement dateOverpstmt = null;
PreparedStatement pstmtSql = null;
ArrayList PricelistGen = new ArrayList();
HashMap PList=null;
int ctr = 0;
String sql = "";
ResultSet rs = null;
......@@ -75,6 +81,38 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
String update_flag = null;
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
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="",chgRefNo="";
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 = "";
String insPriceList = "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, "
......@@ -152,7 +190,50 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
java.sql.Timestamp effFrom = Timestamp.valueOf(genericUtility.getValidDateString(pricelistEffRom, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
java.sql.Timestamp validUpto = Timestamp.valueOf(genericUtility.getValidDateString(pricelistValidUpto, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
// logic merge by cpatil on 12/06/12 start
// logic merge by cpatil on 12/06/12 start
PList = new HashMap();
PList.put("price_list",pricelistMrp.trim());
PList.put("item_code",pricelistItemCode.trim());
PList.put("unit",pricelistUnit.trim().trim());
PList.put("list_type",pricelistListype.trim());
PList.put("slab_no",slabNo);
PList.put("eff_from",effFrom);
PList.put("valid_upto",validUpto);
PList.put("lot_no__from",pricelistLotNoF.trim());
PList.put("lot_no__to",pricelistLotNoTo.trim());
PList.put("min_qty",minQty);
PList.put("max_qty",maxQty);
PList.put("rate",pricelistRateDoub);
PList.put("rate_type",pricelistRateype);
PList.put("min_rate",minRate);
PList.put("max_rate",maxRate);
PList.put("order_type",pricelistOrderType);
PList.put("chg_ref_no",pricelistChgRefNo);
PList.put("price_list__parent",pricelistParent);
PList.put("calc_basis",pricelistCalcBasis);
PList.put("ref_no",pricelistRefNo);
PList.put("ref_no_old",pricelistRefNOld);
System.out.println("lot_no__from@@"+PList.get("lot_no__from"));
System.out.println("lot_no__to@@"+PList.get("lot_no__to"));
System.out.println("item_code@@"+PList.get("item_code"));
System.out.println("item_code@@"+itemCode);
System.out.println("price_list@@"+PList.get("price_list"));
System.out.println("price_list@@"+PriceList);
PricelistGen.add(PList);
System.out.println("@@@@@@@@@@@@@Price list@@@@@@@@@@@@@@@@"+PricelistGen);
System.out.println("@@@@@@@@@@@@PList@@@@@@@@@@@@@"+PList);
//PricelistGen.add(PList);
//System.out.println("@@@@@@@@@@@@@Price list@@@@@@@@@@@@@@@@"+PricelistGen);
String str1=AuroExpPricelist(PList, PricelistGen, conn, xtraParams);
System.out.println("function@@"+str1);
sql = "SELECT count( 1 ) from pricelist where "
+ " PRICE_LIST = ? "
......@@ -179,8 +260,11 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
chkPlrs = null;
System.out.println("@@@@@@ plCount["+plCount+"]");
if(plCount > 0)
{
sql = "update pricelist set "
{/*
String str=insertPricelist(PList, PricelistGen, conn, xtraParams);
System.out.println("function@@"+str);
*/
/*sql = "update pricelist set "
+" valid_upto = ? "
+" where price_list = ? "
+" AND item_code = ? "
......@@ -213,7 +297,7 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
dateOverpstmt.close();
dateOverpstmt = null;
/*
sql = "update pricelist set "
+" valid_upto = ? "
+" where price_list = ? "
......@@ -273,7 +357,7 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
dtlpstmt.close();
dtlpstmt = null;
double rate = calculateRate( pricelistRateDoub, pricelstGencst, pricelstGenChrgRet, pricelstGenChrgBill, pricelstGenMargRet );
double rateCalc = calculateRate( pricelistRateDoub, pricelstGencst, pricelstGenChrgRet, pricelstGenChrgBill, pricelstGenMargRet );
sql = "SELECT count( 1 ) from pricelist where "
+" PRICE_LIST = ? "
......@@ -307,7 +391,9 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
java.sql.Date effectFrom = java.sql.Date.valueOf( sdf.format( calender.getTime() ) );
Timestamp effectFromTS = Timestamp.valueOf(genericUtility.getValidDateString(effectFrom.toString(), genericUtility.getDBDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
/*String str=insertPricelist( PList, PricelistGen, conn, xtraParams);
System.out.println("function_test@@"+str);
*/
/* // commented by cpatil beacause code shifted above i.e. before pricelist_gen_hdr sql
sql = "update pricelist set "
......@@ -413,6 +499,7 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
insPriceListPStmt.setString(24, pricelistRefNOld != null ? pricelistRefNOld.trim() : "");
updtCnt = insPriceListPStmt.executeUpdate();
System.out.println("updtCnt@@@"+updtCnt);
flag = false;
insPriceListPStmt.close();
insPriceListPStmt = null;
......@@ -425,14 +512,16 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
int updt = upDtPlPStmt.executeUpdate();
upDtPlPStmt.close();
upDtPlPStmt = null; */
//retString = "VTSUCCSS";
retString = "VTSUCCSS";
}
pstmt.close();
pstmt = null;
// } // added for testing
retString = "VTSUCCSS";
}
//retString = "VTSUCCSS";
}
catch (Exception e)
{
......@@ -539,4 +628,1256 @@ public class PriceListPos extends ValidatorEJB implements PriceListPosLocal, Pri
}
return timestamp;
}
private String AuroExpPricelist(HashMap PList,ArrayList PricelistGen, Connection conn, String xtraParams) throws RemoteException, ITMException
{
PreparedStatement pstmtSql ,pstmtInsert= null;
ResultSet rs = null;
String dbName = "";
String sql = "";
String retString = "", LotNoFrom1="" ;
String errCode="",AutoExpire="",LotFrBrow="",LotNoToBrow="",LotNoFrom="",OldLotNo="",Set="",NewStr="",edioption="";
//char OrigStr="";
int DayDiff=0;
java.sql.Timestamp ValidUpTo=null,EffDate=null;
int LineNo=0,RowCount=0,Count=0,OldLen=0;
int 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,sizeCnt=0;
java.sql.Timestamp ChgDate=null,efffromdt=null,validupto=null;
java.sql.Timestamp chgDate = null,efffrom=null,today=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="",OrigStr="";
int cnt1=0,UpdCnt=0,recCnt=0;
String LotNoFroma[] = null, LotNoToa[]=null;
char left1=0,left2=0,left3 = 0,left4=0;
int updCnt = 0;
char left=0;
String mid1="",mid2="",mid3="",mid4="";
String mid="";
java.text.SimpleDateFormat sdf = null;
String lotnofrom="",lotnoto1="",userId="",termId="";
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");
PricelistGen.add(PList);
System.out.println("List size is"+PricelistGen);
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);
efffrom=(java.sql.Timestamp)PList.get("eff_from");
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");
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");
System.out.println("plist@@"+plist);
//SELECT COUNT(1) FROM pricelist WHERE PRICE_LIST=? AND ITEM_CODE=?;
sql="SELECT COUNT(1) FROM pricelist WHERE PRICE_LIST=? AND ITEM_CODE=?";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1,plist);
pstmtSql.setString(2,itemcode);
rs = pstmtSql.executeQuery();
while(rs.next())
{
recCnt=rs.getInt(1);
}
System.out.println("recCnt@@"+recCnt);
pstmtSql.close();
pstmtSql=null;
rs.close();
rs=null;
sql=null;
if(recCnt==0)
{
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, (Double)PList.get("slab_no"));//maxrate1=(Double)PList.get("slab_no");
pstmtInsert.setTimestamp(6, efffrom);
pstmtInsert.setTimestamp(7, ValidUpTo);
pstmtInsert.setString(8,lotnofrom);//lotnofr)
pstmtInsert.setString(9, lotnoto1);//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();
System.out.println("NewRecord@@Inserted"+UpdCnt);
pstmtInsert.close();
pstmtInsert = null;
}
sql="select count(1) from pricelist where price_list=? and item_code=? and unit=? and list_type=? and EFF_FROM not in ( ? ) ";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1,plist);
pstmtSql.setString(2,itemcode);
pstmtSql.setString(3,unit);
pstmtSql.setString(4,listtype);
pstmtSql.setTimestamp(5, efffrom);
rs = pstmtSql.executeQuery();
while(rs.next())
{
sizeCnt=rs.getInt(1);
}
System.out.println("sizeCnt@@"+sizeCnt);
pstmtSql.close();
pstmtSql=null;
rs.close();
rs=null;
sql=null;
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=? and unit=? and list_type=? and EFF_FROM not in ( ? ) ";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1,plist);
pstmtSql.setString(2,itemcode);
pstmtSql.setString(3,unit);
pstmtSql.setString(4,listtype);
pstmtSql.setTimestamp(5, efffrom);
rs = pstmtSql.executeQuery();
for (Ctr =0; Ctr < sizeCnt; 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");
System.out.println("Lots Number from brow window"+LotFrBrow);
LotNoToBrow=rs.getString("lot_no__to");
System.out.println("Lots Number from brow window"+LotNoToBrow);
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,efffrom);
System.out.println("check"+DayDiff);
/* if(DayDiff<=0 )
{
System.out.println("In if condition@@@@@");
*/
System.out.println("lotnofrom@@"+lotnofrom+"LotFrBrow@@"+LotFrBrow);
System.out.println("lotnoto1@@"+lotnoto1+"LotNoToBrow@@"+LotNoToBrow);
System.out.println("MinQtyBrow@@"+MinQtyBrow+"minqty@@"+minqty);
System.out.println("MaxQtyBrow@@"+MaxQtyBrow+"maxqty@@"+maxqty);
/*
* if((DayDiff<=0 )&& (LotFrBrow.equals( lotnofrom)|| lotnofrom.equalsIgnoreCase(LotFrBrow)) && (LotNoToBrow.equals(lotnoto1)|| LotNoToBrow.equalsIgnoreCase(lotnoto1) ) && (MinQtyBrow==minqty)&& (MaxQtyBrow==maxqty))
{
*/
if((DayDiff<=0 ))
{
System.out.println("DayDiff@indaycondition@@"+DayDiff);
if((LotFrBrow.trim().equals( lotnofrom.trim())|| lotnofrom.trim().equalsIgnoreCase(LotFrBrow.trim())))
{
System.out.println("iNcONDITION@@lotnofrom@@"+lotnofrom+"LotFrBrow@@"+LotFrBrow);
if((LotNoToBrow.trim().equals(lotnoto1.trim())|| LotNoToBrow.trim().equalsIgnoreCase(lotnoto1.trim()) ))
{
System.out.println("iNcONDITION@@lotnofrom@@"+lotnofrom+"LotFrBrow@@"+LotFrBrow);
if((MinQtyBrow==minqty))
{
System.out.println("iNcONDITION@@MinQtyBrow@@"+MinQtyBrow+"minqty@@"+minqty);
if((MaxQtyBrow==maxqty))
{
System.out.println("iNcONDITION@@MaxQtyBrow@@"+MaxQtyBrow+"maxqty@@"+maxqty);
//System.out.println("In if condition@@@@@");
System.out.println("In if condition ######");
ValidUpTo=utilMethods.RelativeDate((java.sql.Timestamp)PList.get("eff_from"), -1 );
System.out.println("ValidUpTo@@@@@"+ValidUpTo);
if( dbName.equalsIgnoreCase("db2"))
{
validupto=(ValidUpTo);
System.out.println("Valid upto date is:"+ValidUpTo);
System.out.println("Converted Valid Upto Date is:"+validupto);
sql="update pricelist set valid_upto = ? , chg_user =?,chg_term = ?,chg_date = ? where price_list =? and item_code = ? and unit = ? and list_type = ? and slab_no = ? and EFF_FROM not in ( ? ) ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, validupto);
pstmtSql.setString(2, userId);
pstmtSql.setString(3, termId);
pstmtSql.setTimestamp(4, chgDate);
pstmtSql.setString(5, plist);
pstmtSql.setString(6, itemcode);
pstmtSql.setString(7, unit);
pstmtSql.setString(8, listtype);
pstmtSql.setDouble(9, SlabNo);
pstmtSql.setTimestamp(10, efffrom);
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 = ? , chg_user =?,chg_term = ?,chg_date = ? where price_list =? and item_code = ? and unit = ? and list_type = ? and slab_no = ? and EFF_FROM not in ( ? ) ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, ValidUpTo);
pstmtSql.setString(2, userId);
pstmtSql.setString(3, termId);
pstmtSql.setTimestamp(4, chgDate);
pstmtSql.setString(5, plist);
pstmtSql.setString(6, itemcode);
pstmtSql.setString(7, unit);
pstmtSql.setString(8, listtype);
pstmtSql.setDouble(9, SlabNo);
pstmtSql.setTimestamp(10, efffrom);
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)
{
String s2=LotNoFrom.trim();
System.out.println("Lotnumber "+s2.length());
left=0;
char right= s2.charAt(s2.length()-1);
int diff3=0;
String original="", result = "",result2="";
int length = LotNoFrom.length();
/*System.out.println("insert in count");
Len=LotNoFrom.trim().length();
Ctr=1;
String s2=LotNoFrom.trim();
//String chekStr=LotNoFrom.trim();
*/
System.out.println("s22222222222222"+s2);
//char right= s2.charAt(s2.length()-1);
System.out.println("right s22222222222222"+right);
for ( int i = length - 1 ; i >= 0 ; i-- )
{
Character character = LotNoFrom.charAt(i);
System.out.println("Char"+character);
boolean flag = isNumber(character);
if(!flag)
{
result = result + LotNoFrom.charAt(i);
break;
}
System.out.println("result"+result);
cnt1++;
System.out.println("Count is"+cnt1);
}
System.out.println("Result of entered string is: "+result);
System.out.println("Count is:::"+cnt1);
int testOrginal=0;
int sub=0;
testOrginal=length-cnt1;
System.out.println("testOrginal["+testOrginal+"]");
String testSub1=LotNoFrom.substring(0,testOrginal);
System.out.println("testSub1::-["+testSub1+"]");
int testSub=testSub1.length();
System.out.println("testSub"+testSub);
String testSub2=LotNoFrom.substring(s2.length()-cnt1);
System.out.println("testSub2::-"+testSub2);
sub=Integer.parseInt(testSub2);
int u2=testSub2.length();
int OrgSub=sub-1;
String v1=String.valueOf(OrgSub);
int v2=v1.length();
System.out.println("V2:"+v2);
int z=u2-v2;
System.out.println("z:"+z);
if(z!=0)
{
for(int s3=0;s3<z;s3++)
{
System.out.println("For loop if ");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}
int q=NewStr.length();
String a2=Integer.toString(OrgSub);
System.out.println("NewStr"+NewStr);
LotNoFrom = testSub1.trim()+NewStr.trim()+a2 ;
System.out.println("LotNoFrom1@@@@LotNoFrom@@@@:"+LotNoFrom);
sql="update pricelist set lot_no__to = ? , chg_user =?,chg_term = ?,chg_date = ? 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 >= ? and EFF_FROM not in ( ? ) ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setString(1,LotNoFrom);
pstmtSql.setString(2, userId);
pstmtSql.setString(3, termId);
pstmtSql.setTimestamp(4, chgDate);
pstmtSql.setString(5, plist);
pstmtSql.setString(6, itemcode);
pstmtSql.setString(7, unit);
pstmtSql.setString(8,listtype);
pstmtSql.setString(9, lotnofrom);
pstmtSql.setString(10, lotnoto1);//NEW UPDATE//OLD-lotnofrom
pstmtSql.setDouble(11, minqty);
pstmtSql.setDouble(12, maxqty);
pstmtSql.setTimestamp(13, efffrom);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated@@@@@@@@------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
}
//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");
System.out.println("Reference Number old is:"+refNoold);
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.trim());
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.trim());
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.setString(1, plist);
pstmtSql.setString(2, itemcode);
pstmtSql.setString(3, unit);
pstmtSql.setString(4, lotnofrom.trim());
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, minqty);
pstmtSql.setDouble(7, maxqty);
pstmtSql.setString(8, refNoold);
rs = pstmtSql.executeQuery();
if (rs.next())
{
slabno=rs.getDouble(1);
efffromdt=rs.getTimestamp(2);
LotNoFrom=rs.getString(3);
System.out.println("LotNoFrom@@"+LotNoFrom);
}
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.setString(1, plist);
pstmtSql.setString(2, itemcode);
pstmtSql.setString(3, unit);
pstmtSql.setString(4, lotnofrom.trim());
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, minqty);
pstmtSql.setDouble(7, maxqty);
//pstmtSql.setString(8, refNoold);
rs = pstmtSql.executeQuery();
if (rs.next())
{
slabno=rs.getDouble(1);
efffromdt=rs.getTimestamp(2);
LotNoFrom=rs.getString(3);
System.out.println("LotNoFrom@@"+LotNoFrom);
//refNoold=rs.getString(8);
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
}
LotNoFrom=LotNoFrom.trim();
ValidUpTo=utilMethods.RelativeDate((efffromdt), -1 );
System.out.println("insert in count");
System.out.println("insert in count");
/*Len=LotNoFrom.trim().length();
Ctr=1;
*/
System.out.println("@@LotNoFrom@@@@@"+LotNoFrom);
String s2=LotNoFrom.trim();
System.out.println("Lotnumber "+s2.length());
left=0;
char right= s2.charAt(LotNoFrom.length()-1);
int diff3=0,cntt=0;
String original="", result = "",result2="";
int length = LotNoFrom.trim().length();
System.out.println("s22222222222222"+s2.trim());
//char right= s2.charAt(s2.length()-1);
System.out.println("right s22222222222222"+right);
for ( int i = length - 1 ; i >= 0 ; i-- )
{
Character character = LotNoFrom.charAt(i);
System.out.println("Char"+character);
boolean flag = isNumber(character);
if(!flag)
{
result = result + LotNoFrom.charAt(i);
break;
}
System.out.println("result"+result);
cntt++;
System.out.println("Count is"+cntt);
}
System.out.println("Result of entered string is: "+result);
System.out.println("Count is:::"+cntt);
int testOrginal=0;
int sub=0;
testOrginal=length-cntt;
System.out.println("testOrginal["+testOrginal+"]");
String testSub1=LotNoFrom.substring(0,testOrginal)==null?"":LotNoFrom.substring(0,testOrginal).trim();
System.out.println("testSub1::-["+testSub1+"]");
int testSub=testSub1.length();
System.out.println("testSub"+testSub);
String testSub21=LotNoFrom.substring(LotNoFrom.length()-cntt);
System.out.println("testSub2::-"+testSub21);
sub=Integer.parseInt(testSub21);
// System.out.println("SUB@@@"+sub);
int u2=testSub21.length();
int OrgSub=sub-1;
String v1=String.valueOf(OrgSub);
int v2=v1.length();
System.out.println("V2:"+v2);
int z=u2-v2;
System.out.println("z:"+z);
if(z!=0)
{
for(int s3=0;s3<z;s3++)
{
System.out.println("For loop if ");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}
int q=NewStr.length();
String a2=Integer.toString(OrgSub);
System.out.println("NewStr"+NewStr);
LotNoFrom = testSub1.trim()+NewStr.trim()+a2 ;
System.out.println("LotNoFrom1@@@@LotNoFrom@@@@:"+LotNoFrom);
if( dbName.equalsIgnoreCase("db2"))
{
validupto=(ValidUpTo);
if(refNoold !=null && refNoold.trim().length() > 0)
{
sql="update pricelist set valid_upto = ? ,lot_no__to = ? , chg_user =?,chg_term = ?,chg_date = ? where price_list = ? and item_code = ? and unit =? and list_type = ? and min_qty >= ? and max_qty <= ? and slab_no = ? and ref_no =? and EFF_FROM not in ( ? ) ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, validupto);
pstmtSql.setString(2, LotNoFrom);
pstmtSql.setString(3, userId);
pstmtSql.setString(4, termId);
pstmtSql.setTimestamp(5, chgDate);
pstmtSql.setString(6, plist);
pstmtSql.setString(7, itemcode);
pstmtSql.setString(8, unit);
pstmtSql.setString(9, listtype);
pstmtSql.setDouble(10, minqty);
pstmtSql.setDouble(11, maxqty);
pstmtSql.setDouble(12, SlabNo);
pstmtSql.setString(13, refNoold);
pstmtSql.setTimestamp(14, efffrom);
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 = ? , chg_user =?,chg_term = ?,chg_date = ? 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 and EFF_FROM not in ( ? ) ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, ValidUpTo);
pstmtSql.setString(2, LotNoFrom);
pstmtSql.setString(3, userId);
pstmtSql.setString(4, termId);
pstmtSql.setTimestamp(5, chgDate);
pstmtSql.setString(6, plist);
pstmtSql.setString(7, itemcode);
pstmtSql.setString(8, unit);
pstmtSql.setString(9, listtype);
pstmtSql.setDouble(10, minqty);
pstmtSql.setDouble(11, maxqty);
pstmtSql.setDouble(12, SlabNo);
pstmtSql.setTimestamp(13, efffrom);
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 = ? , chg_user =?,chg_term = ?,chg_date = ? where price_list = ? and item_code = ? and unit =? and list_type = ? and min_qty >= ? and max_qty <= ? and slab_no = ? and ref_no =? and EFF_FROM not in ( ? ) ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1,ValidUpTo);
pstmtSql.setString(2, LotNoFrom);
pstmtSql.setString(3, userId);
pstmtSql.setString(4, termId);
pstmtSql.setTimestamp(5, chgDate);
pstmtSql.setString(6, plist);
pstmtSql.setString(7, itemcode);
pstmtSql.setString(8, unit);
pstmtSql.setString(9, listtype);
pstmtSql.setDouble(10, minqty);
pstmtSql.setDouble(11, maxqty);
pstmtSql.setDouble(12, SlabNo);
pstmtSql.setString(13, refNoold);
pstmtSql.setTimestamp(14,efffrom);
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 = ? , chg_user =?,chg_term = ?,chg_date = ? 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 and EFF_FROM not in ( ? ) ";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, ValidUpTo);
pstmtSql.setString(2, LotNoFrom);
pstmtSql.setString(3, userId);
pstmtSql.setString(4, termId);
pstmtSql.setTimestamp(5, chgDate);
pstmtSql.setString(6, plist);
pstmtSql.setString(7, itemcode);
pstmtSql.setString(8, unit);
pstmtSql.setString(9, listtype);
pstmtSql.setDouble(10, minqty);
pstmtSql.setDouble(11, maxqty);
pstmtSql.setDouble(12, SlabNo);
pstmtSql.setTimestamp(13,efffrom);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated11111111111------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
}
}
}
//split the batch if the entered batch no is already existing in the master pricelist
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;
System.out.println("Recode Found@@@@@@@@@@@@@"+recordfound);
currentlotnofrtemp = currentlotnofr;
currentlotnototemp= currentlotnoto;
/*
Len=currentlotnofr.trim().length();
Ctr =1;
OrigStr = "";
Set ="";
NewStr ="";
New = 0;
String s2=LotNoFrom.trim();
System.out.println("@@@@@x"+s2);
String y=currentlotnofr.trim();
System.out.println("@@@@@x"+y);
if(s2.length()<y.length())
{
char right3= y.charAt(y.length()-1);
if(Character.isDigit(right3) )
{
//do
//{
if(Character.isDigit(right3))
{
left=y.charAt(0);
System.out.println("left :::::::::::"+left);
if(left =='0')
{
if(y.length()>2 )
{
mid=y.substring(2);
System.out.println("middle ::::::::::::"+mid);
Set=Set + '0';
}
}
else
{
OldLen = currentlotnofr.trim().length();
System.out.println("OldLen@@@@@@@"+OldLen);
New = OldLen - 1;
System.out.println("New@@@@@@@"+New);
//String new1=Integer.toString(New);
System.out.println("NewLen@@@@@@@"+NewLen);
if(OldLen != New);
{int diff3=(int) (OldLen - New);
System.out.println("Old Length"+OldLen);
System.out.println("New"+New);
System.out.println("Diff"+diff3);
if(s2.length() <= 2 )
{
if( Character.isDigit(left ))
{
for(int s3=0;s3<diff3;s3++)
{
System.out.println("For loop if ");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}
}
else
{
for(int s3=0;s3<diff3;s3++)
{
System.out.println("For loop else condition");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}}
}
}
else
{
OrigStr = Character.toString(left);
Set = Set + OrigStr;
LotNoFrom = ( mid+1);
}
Ctr++;
//}while(Ctr <= Len);
// lotnoto = Set + trim(ls_NewStr) +string(ll_New)
//ls_lot_no__fr = ls_next_lot_no_fr
if(New==0)
{
LotNoFrom = Set +NewStr.trim();
}
else
{
int length = LotNoFrom.length();
String result = "";
for (int i = 0; i < length; i++)
{
Character character = LotNoFrom.charAt(i);
if (Character.isDigit(character))
{
result += character;
}
}
int u=Integer.parseInt(result);
System.out.println("u"+u);
int v=u-1;
System.out.println("v"+v);
String Conv=String.valueOf(v);
int o=Conv.length();
System.out.println("O:"+o);
int p=NewStr.length();
System.out.println("p:"+p);
int toat=o+p;
String a2=Integer.toString(v);
String e=s2.substring(0, s2.length()-toat);
System.out.println("e"+e);
System.out.println("NewStr"+NewStr);
LotNoFrom = e.trim()+NewStr.trim()+a2 ;
System.out.println("LotNoFrom1@@@@@@@@:"+LotNoFrom);
}
}
}
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();
OldLen = currentlotnoto.trim().length();
System.out.println("OldLen@@@@@@@"+OldLen);
New = OldLen - 1;
System.out.println("New@@@@@@@"+New);
//String new1=Integer.toString(New);
System.out.println("NewLen@@@@@@@"+NewLen);
if(OldLen != NewLen);
{int diff3=(int) (OldLen - New);
System.out.println("Old Length"+OldLen);
System.out.println("New"+New);
System.out.println("Diff"+diff3);
if(y.length() <= 2 )
{
if( Character.isDigit(left ))
{
for(int s3=0;s3<diff3;s3++)
{
System.out.println("For loop if ");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}
}
else
{
for(int s3=0;s3<diff3;s3++)
{
System.out.println("For loop else condition");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}}
}
}
else
{ OrigStr = Character.toString(left4);
Set = Set + OrigStr;
LotNoFrom = (mid4+ 1);
}
Ctr++;
// }while(Ctr <= Len1);
// 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;
if(New==0)
{
currentlotnoto = Set +NewStr.trim();
}
else
{
int length = currentlotnoto.length();
String result = "";
for (int i = 0; i < length; i++)
{
Character character = currentlotnoto.charAt(i);
if (Character.isDigit(character))
{
result += character;
}
}
int u=Integer.parseInt(result);
System.out.println("u"+u);
int v=u-1;
System.out.println("v"+v);
String Conv=String.valueOf(v);
int o=Conv.length();
System.out.println("O:"+o);
int p1=NewStr.length();
System.out.println("p:"+p1);
int toat=o+p1;
String a2=Integer.toString(v);
String e=y.substring(0, y.length()-toat);
System.out.println("e"+e);
System.out.println("NewStr"+NewStr);
String currentlotnoto1 = e.trim()+NewStr.trim()+a2 ;
System.out.println("LotNoFrom1@@@@@@@@:"+currentlotnoto1);
}
}
}*/
/* 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, efffrom);
pstmtInsert.setTimestamp(7, ValidUpTo);
pstmtInsert.setString(8,lotnofrom);
pstmtInsert.setString(9, lotnoto1);
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("LINE NO@@@"+LineNo);
System.out
.println("Record found@@@@@@@@@@@@@"+recordfound);
today=new Timestamp(System.currentTimeMillis());
ChgDate = today;
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,lotnofrom);//lotnofr)
pstmtInsert.setString(9, lotnoto1);//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;
}
private static boolean isNumber(Character character)
{
boolean flag= false;
try
{
double num = Double.parseDouble(""+character);
flag = true;
return flag;
}
catch( Exception e)
{
return flag;
}
}
}
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