Commit 9e00d47d authored by sjarande's avatar sjarande

ES3 source files merged in head from cvs branch 5-12-146-5

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@165263 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0181e987
package ibase.webitm.ejb.dis;
/**
* @author Saurabh Jarande[19/07/17]
* This component is used for validating AWACS process.
*
*/
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class AwacsToES3IC extends ValidatorEJB implements AwacsToES3ICRemote,AwacsToES3ICLocal {
E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String editFlag,String xtraParams) throws RemoteException
{
System.out.println("In wfValData");
Document currDom = null, hdrDom = null, allDom = null;
String errString = "";
try
{
System.out.println("currFrmXmlStr..." + currFrmXmlStr);
System.out.println("hdrFrmXmlStr..." + hdrFrmXmlStr);
System.out.println("allFrmXmlStr..." + allFrmXmlStr);
if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0))
{
currDom = parseString(currFrmXmlStr);
}
if ((hdrFrmXmlStr != null) && (hdrFrmXmlStr.trim().length() != 0))
{
hdrDom = parseString(hdrFrmXmlStr);
}
if ((allFrmXmlStr != null) && (allFrmXmlStr.trim().length() != 0))
{
allDom = parseString(allFrmXmlStr);
}
errString = validate(currDom, hdrDom, allDom, objContext, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :"+this.getClass().getSimpleName()+"[wfValData] : ==>\n" + e.getMessage());
}
return errString;
}
public String validate(Document currDom, Document hdrDom, Document allDom,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{
System.out.println("In validate Data");
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
int noOfChilds = 0, currentFormNo = 0, cnt = 0, prdCnt=0, invDivisionCnt=0 , custCnt=0 , genCnt=0 , awcsCnt=0 , orgCustCnt=0 , orgCustCnt1 =0;
String errString = "",errorType = "",errCode = "", childNodeName = "", custCode="",prdCode="",sql="",prdTblNo="";
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
ConnDriver connDriver = null;
Node childNode = null;
ArrayList <String> opPrdList = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
try
{
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
System.out.println("************xtraParams*************" + xtraParams);
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("**************loginCode************" + userId);
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
NodeList parentList = currDom.getElementsByTagName("Detail"+ currentFormNo);
NodeList childList = null;
System.out.println("hdrDom..." + hdrDom.toString());
switch (currentFormNo)
{
case 1:
{
childList = parentList.item(0).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item(ctr);
if (childNode.getNodeType() != 1)
{
continue;
}
childNodeName = childNode.getNodeName();
System.out.println("Editflag =" + editFlag);
System.out.println("parentList = " + parentList);
System.out.println("childList = " + childList);
if ("prd_code".equalsIgnoreCase(childNodeName) )
{
prdCode = checkNull(genericUtility.getColumnValue("prd_code", currDom));
if(prdCode==null || prdCode.trim().length()==0)
{
errList.add("VMNULLPRD");//Invalid-Period can not be blank
errFields.add(childNodeName.toLowerCase());
//break;
}
else
{
sql=" SELECT COUNT(*) AS COUNT FROM PERIOD WHERE CODE=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode);
rs = pstmt.executeQuery();
if (rs.next())
{
prdCnt = rs.getInt(1);
}
callPstRs(pstmt, rs);
if(prdCnt == 0)
{
errList.add("VMINVPRD");//INVALID PRD CODE
errFields.add(childNodeName.toLowerCase());
//break;
}
else
{
sql=" SELECT SUBSTR(PRD_TBLNO,5,10) AS ITEM_SER FROM PERIOD_TBL WHERE PRD_CODE=? AND PRD_CLOSED='Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode);
rs = pstmt.executeQuery();
while (rs.next())
{
prdTblNo = rs.getString(1);
opPrdList.add(prdTblNo);
invDivisionCnt++;
}
callPstRs(pstmt, rs);
if(invDivisionCnt > 0)
{
errList.add("VMINVPRDCL");//Closed division
errFields.add(childNodeName.toLowerCase());
//break;
}
}
}
}
if ("cust_code".equalsIgnoreCase(childNodeName) )
{
custCode = checkNull(genericUtility.getColumnValue("cust_code", currDom));
prdCode = checkNull(genericUtility.getColumnValue("prd_code", currDom));
if(custCode==null || custCode.trim().length()==0)
{
errList.add("VPBLKCUSCD");//Invalid-Customer code can not be blank
errFields.add(childNodeName.toLowerCase());
//break;
}
else
{
sql=" SELECT COUNT(*) AS COUNT FROM CUSTOMER WHERE CUST_CODE=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
custCnt = rs.getInt(1);
}
callPstRs(pstmt, rs);
if(custCnt == 0)
{
//INVALID CUSTOMER
errList.add("VPINVCSCDM");
errFields.add(childNodeName.toLowerCase());
//break;
}
else
{
sql=" SELECT COUNT(*) FROM ORG_STRUCTURE_CUST WHERE CUST_CODE=? AND VERSION_ID = (SELECT FN_GET_VERSION_ID FROM DUAL) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
orgCustCnt = rs.getInt(1);
}
callPstRs(pstmt, rs);
if(orgCustCnt==0)
{
// does not exist
errList.add("VPINVCSOG");
errFields.add(childNodeName.toLowerCase());
//break;
}
else
{
sql=" SELECT COUNT(*) FROM ORG_STRUCTURE_CUST WHERE CUST_CODE=? AND VERSION_ID = (SELECT FN_GET_VERSION_ID FROM DUAL) and source = 'A' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
orgCustCnt1 = rs.getInt(1);
}
callPstRs(pstmt, rs);
if(orgCustCnt1 == 0 )
{
//not awacs cust
errList.add("VPINVCSOGA");
errFields.add(childNodeName.toLowerCase());
//break;
}
else
{
sql=" SELECT COUNT(*) FROM CUST_STOCK WHERE CUST_CODE=? AND PRD_CODE=? AND POS_CODE IS NULL AND CONFIRMED = 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode);
pstmt.setString(2,prdCode);
rs = pstmt.executeQuery();
if (rs.next())
{
awcsCnt = rs.getInt(1);
}
callPstRs(pstmt, rs);
if(awcsCnt == 0)
{
//transactions already created
errList.add("VTNULLRCD");
errFields.add(childNodeName.toLowerCase());
//break;
}
else
{
sql=" SELECT COUNT(*) FROM CUST_STOCK WHERE CUST_CODE=? AND PRD_CODE=? AND POS_CODE IS NOT NULL ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode);
pstmt.setString(2,prdCode);
rs = pstmt.executeQuery();
if (rs.next())
{
genCnt = rs.getInt(1);
}
callPstRs(pstmt, rs);
if(genCnt > 0)
{
//transactions already created
errList.add("VPINVCSCDA");
errFields.add(childNodeName.toLowerCase());
//break;
}
}
}
}
}
}
}
}
}
break;
}
int errListSize = errList.size();
cnt = 0;
String errFldName = "";
if ((errList != null) && (errListSize > 0))
{
for (cnt = 0; cnt < errListSize; cnt++)
{
errCode = (String) errList.get(cnt);
errFldName = (String) errFields.get(cnt);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode);
if(opPrdList.size()>0 && errString.length() > 0 )
{
String begPart = errString.substring( 0, errString.indexOf("]]></description>") );
String mainStr="";
for(int i=0;i<opPrdList.size();i++)
{
mainStr=mainStr+ opPrdList.get(i)+",";
}
String endPart=errString.substring( errString.indexOf("]]></description>"), errString.length() );
mainStr=" Following Divisions are closed :: "+mainStr.substring(0,mainStr.length()-1);
errString = begPart+mainStr + endPart;
}
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........." + errStringXml);
errString = "";
}
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer("");
}
errString = errStringXml.toString();
}
catch (Exception e)
{
System.out.println("Exception in "+this.getClass().getSimpleName()+" == >"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
callPstRs(pstmt, rs);
if (conn != null && !conn.isClosed())
{
conn.close();
}
}
catch (Exception e)
{
System.out.println("Exception :"+this.getClass().getSimpleName()+":wfValData :==>\n" + e.getMessage());
throw new ITMException(e);
}
}
return errString;
}
public void callPstRs(PreparedStatement pstmt, ResultSet rs)
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
private String checkNull(String inputVal)
{
try{
inputVal = inputVal==null? "" : inputVal.trim();
}catch(Exception e){
e.printStackTrace();
}
return inputVal;
}
private String errorType(Connection conn, String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while (rs.next()){
msgType = rs.getString("MSG_TYPE");
}
callPstRs(pstmt, rs);
}
catch (Exception ex)
{
ex.printStackTrace();
}
return msgType;
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface AwacsToES3ICLocal
{
public String wfValData(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) throws RemoteException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface AwacsToES3ICRemote {
public String wfValData(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) throws RemoteException;
}
package ibase.webitm.ejb.dis;
/**
* @author Saurabh Jarande[19/07/17]
* This component is used for creating ES3 transactions from AWACS data uploaded by CFA.
*
*/
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterDataStatefulLocal;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.dis.adv.CustStockGWTConf;
import ibase.webitm.utility.ITMException;
import java.io.File;
import java.io.FileWriter;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class AwacsToES3Prc extends ProcessEJB implements AwacsToES3PrcLocal,AwacsToES3PrcRemote {
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException
{
Document detailDom = null, headerDom = null;
String retStr = "";
System.out.println("windowName[process]::::::::::;;;" + windowName);
System.out.println("xtraParams[process]:::::::::;;;" + xtraParams);
try
{
System.out.println("xmlString[process]::::::::::;;;" + xmlString);
if (xmlString != null && xmlString.trim().length() != 0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
}
System.out.println("xmlString2[process]::::::::::;;;" + xmlString2);
if (xmlString2 != null && xmlString2.trim().length() != 0) {
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :"+this.getClass().getName()+" :process(String xmlString, String xmlString2, String windowName, String xtraParams):"+ e.getMessage() + ":");
e.printStackTrace();
retStr = e.getMessage();
}
return retStr;
}
public String process(Document headerDom, Document detailDom,String windowName, String xtraParams) throws RemoteException,ITMException
{
String errString = "",sql="",prdCode="",custCode="",prdCodeDom="",custCodeDom="",toDateStr="",fromDateStr="",
itemSer="",posCode="",empCode="",tranIdParent="",tranIdDel="";
Date tranDate=null;
Connection conn = null;
PreparedStatement pstmt = null,pstmt1=null;
ResultSet rs = null,rs1=null;
SimpleDateFormat sdf=null;
HashMap<String,String> invMap = new HashMap<String,String>();
HashMap<String,Integer> itemMap = new HashMap<String,Integer>();
String loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
String chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
String chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
UserInfoBean userInfo = new UserInfoBean();
userInfo.setLoginCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
userInfo.setEmpCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
userInfo.setSiteCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
userInfo.setEntityCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "entityCode"));
userInfo.setProfileId(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "profileId"));
userInfo.setUserType(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "userType"));
userInfo.setRemoteHost(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
prdCodeDom = checkNull(genericUtility.getColumnValue("prd_code", headerDom));
custCodeDom = checkNull(genericUtility.getColumnValue("cust_code", headerDom));
sql=" SELECT TRAN_ID FROM CUST_STOCK WHERE PRD_CODE=? AND POS_CODE IS NOT NULL AND TRAN_ID__PARENT IS NOT NULL " +
" AND TRAN_ID__PARENT NOT IN(SELECT TRAN_ID FROM CUST_STOCK WHERE PRD_CODE=? AND POS_CODE IS NULL AND CONFIRMED = 'Y' )";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodeDom);
pstmt.setString(2, prdCodeDom);
rs = pstmt.executeQuery();
while(rs.next())
{
tranIdDel=checkNull(rs.getString("tran_id"));
System.out.println("tranIdDel::::"+tranIdDel);
sql="DELETE FROM CUST_STOCK WHERE TRAN_ID=?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, tranIdDel);
int i=pstmt1.executeUpdate();
if(pstmt1!=null)
{
pstmt1.close();
pstmt1=null;
}
if(i>0)
{
sql="DELETE FROM CUST_STOCK_INV WHERE TRAN_ID=?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, tranIdDel);
pstmt1.executeUpdate();
}
if(pstmt1!=null)
{
pstmt1.close();
pstmt1=null;
}
}
callPstRs(pstmt, rs);
sql=" SELECT FR_DATE,TO_DATE FROM PERIOD WHERE CODE=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodeDom);
rs = pstmt.executeQuery();
if(rs.next())
{
fromDateStr=sdf.format(rs.getDate("FR_DATE"));
toDateStr=sdf.format(rs.getDate("TO_DATE"));
}
System.out.println("fromDateStr:::"+fromDateStr+":::toDateStr:::"+toDateStr);
callPstRs(pstmt, rs);
sql = " SELECT TRAN_ID,TRAN_DATE,CUST_CODE,PRD_CODE FROM CUST_STOCK WHERE CUST_CODE=? AND PRD_CODE=? AND POS_CODE IS NULL AND CONFIRMED = 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCodeDom);
pstmt.setString(2, prdCodeDom);
rs = pstmt.executeQuery();
if(rs.next())
{
tranIdParent=checkNull(rs.getString("tran_id"));
tranDate=rs.getDate("tran_date");
custCode=checkNull(rs.getString("cust_code"));
prdCode=checkNull(rs.getString("prd_code"));
invMap=getInvoiceDetails(tranIdParent,conn);
sql=" SELECT A.TABLE_NO,A.POS_CODE,A.CUST_CODE,A.EMP_CODE FROM "+
" (SELECT ROW_NUMBER() OVER (PARTITION BY C.TABLE_NO ORDER BY C.TABLE_NO) RN,C.POS_CODE,C.CUST_CODE,A.EMP_CODE,A.TABLE_NO "+
" FROM ORG_STRUCTURE A INNER JOIN ORG_STRUCTURE_CUST C ON A.VERSION_ID=C.VERSION_ID AND A.TABLE_NO=C.TABLE_NO AND A.POS_CODE=C.POS_CODE "+
" WHERE A.VERSION_ID = (SELECT FN_GET_VERSION_ID FROM DUAL) AND C.CUST_CODE= ? AND C.SOURCE = 'A' "+
" )A WHERE A.RN=1 ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, custCode);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
itemSer=checkNull(rs1.getString("TABLE_NO"));
posCode=checkNull(rs1.getString("POS_CODE"));
custCode=checkNull(rs1.getString("CUST_CODE"));
empCode=checkNull(rs1.getString("EMP_CODE"));
itemMap.clear();
itemMap=getItemDetails(tranIdParent,itemSer,conn);
System.out.println("itemMap::::"+itemMap.toString());
errString=awacsGenProcess(itemSer,posCode,custCode,empCode,prdCode,tranIdParent,tranDate,loginSiteCode,fromDateStr,toDateStr,invMap,itemMap,chgUser,chgTerm,xtraParams,userInfo,conn);
}
callPstRs(pstmt1, rs1);
}
callPstRs(pstmt, rs);
}// try end
catch (Exception e)
{
try{
System.out.println("Exception :"+this.getClass().getName()+":process(String xmlString2, String xmlString2, String windowName, String xtraParams):"+ e.getMessage() + ":");
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("", "VTES3GENF", "","", conn);
conn.rollback();
}
catch(Exception ex)
{
ex.printStackTrace();
}
throw new ITMException(e);
}
finally
{
System.out.println("IN ["+this.getClass().getName()+"]>> Closing Connection....");
try {
if(errString==null || errString.trim().length()==0)
{
errString = itmDBAccessEJB.getErrorString("", "VTES3GENS", "","", conn);
}
else
{
errString = itmDBAccessEJB.getErrorString("", "VTES3GENF", "","", conn);
}
if (conn != null)
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
errString = e.getMessage();
e.printStackTrace();
return errString;
}
}
System.out.println("Error Message=>" + errString);
return errString;
}// END OF PROCESS(2)
private HashMap<String, Integer> getItemDetails(String tranIdParent,String itemSer,Connection conn)
{
HashMap<String,Integer> itemMap = new HashMap<String,Integer>();
String sql="",itemCode="",itemSerHd="";
int clStock=0;
PreparedStatement pstmt=null;
ResultSet rs =null;
try
{
itemSerHd=getItemSerList(itemSer, conn);
sql=" SELECT ITEM_CODE,CL_STOCK,OP_STOCK FROM CUST_STOCK_DET WHERE TRAN_ID = ? AND ITEM_SER in ("+itemSerHd+") ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdParent);
//pstmt.setString(2, itemSerHd);
rs = pstmt.executeQuery();
while(rs.next())
{
itemCode=checkNull(rs.getString("ITEM_CODE"));
clStock=rs.getInt("CL_STOCK");
if(clStock <= 0)
{
clStock=0;
}
itemMap.put(itemCode, clStock);
}
}
catch (Exception e)
{
e.printStackTrace();
itemMap=null;
}
return itemMap;
}
public String getItemSerList(String itemser, Connection conn)
{
String itemSerGrpValue="",itemSerSplit="",resultItemSer="";
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
try
{
sql= " select distinct item_ser from" +
"(select item_ser from itemser where grp_code=? " +
"union all " +
"select item_ser from itemser where item_ser=?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemser);
pstmt.setString(2, itemser);
rs = pstmt.executeQuery();
while(rs.next())
{
itemSerGrpValue=checkNull(rs.getString("item_ser")).trim();
itemSerSplit=itemSerSplit+"'"+itemSerGrpValue+"',";
}
rs.close();
rs = null;
pstmt.close();
resultItemSer = itemSerSplit.substring(0, itemSerSplit.length() - 1);
System.out.println("resultItemSer>>>>>"+resultItemSer);
}
catch(Exception exception)
{
exception.printStackTrace();
try
{
throw new ITMException( exception );
} catch (ITMException e)
{
e.printStackTrace();
}
}
return resultItemSer;
}
private HashMap<String, String> getInvoiceDetails(String tranIdParent,Connection conn)
{
HashMap<String,String> invMap = new HashMap<String,String>();
String sql="",invoiceId="",dlvFlg="";
PreparedStatement pstmt=null;
ResultSet rs =null;
try
{
sql=" SELECT INVOICE_ID,DLV_FLG FROM CUST_STOCK_INV WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdParent);
rs = pstmt.executeQuery();
while(rs.next())
{
invoiceId=checkNull(rs.getString("INVOICE_ID"));
dlvFlg=checkNull(rs.getString("DLV_FLG"));
invMap.put(invoiceId , dlvFlg);
}
}
catch (Exception e)
{
e.printStackTrace();
invMap=null;
}
return invMap;
}
private String awacsGenProcess(String itemSer, String posCode,String custCode, String empCode, String prdCode,String tranIdParent, Date tranDate, String loginSiteCode,
String fromDateStr, String toDateStr,HashMap invMap,HashMap itemMap, String chgUser, String chgTerm, String xtraParams,UserInfoBean userInfo, Connection conn)
{
boolean result=false;
CustStockGWTIC custStockGWTIC =new CustStockGWTIC();
CustStockGWTConf confTran=new CustStockGWTConf();
ArrayList<String>logList=null;
String xmlInEditMode="",xmlInEditMode2="",xmlInEditMode3="",sql="",orderType="",custType="",tranIdLast="",tranId="",
sysDate="",logDate="",countryCode="",xmlDetail2="",xmlParseStr="",retString="",retString1="",errString="",
custStockItemDetails="",custStockInvDetails="";
StringBuffer xmlBuff=null;
SimpleDateFormat sdf=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
int custCount = 0;
try
{
custCount=isCustExist(prdCode,custCode,itemSer,pstmt,rs,conn);
if(custCount==0)
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
logDate= sdf.format(Calendar.getInstance().getTime());
sysDate = sdf.format(Calendar.getInstance().getTime());
logList=new ArrayList<String>();
xmlInEditMode = getHeaderXML(userInfo,"1","2");
xmlInEditMode2 = getHeaderXML(userInfo,"2","1");
xmlInEditMode3 = getHeaderXML(userInfo,"3","1");
System.out.println("xmlInEditMode:::"+ xmlInEditMode);
System.out.println("xmlInEditMode2>>>>"+xmlInEditMode2);
System.out.println("xmlInEditMode3>>>>"+xmlInEditMode3);
StringBuffer xmlDetail1 = new StringBuffer();
sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode );
rs = pstmt.executeQuery();
if(rs.next())
{
countryCode = checkNull(rs.getString("count_code")).trim();
System.out.println("countryCode >>> :"+countryCode);
}
callPstRs(pstmt, rs);
sql= " select order_type,cust_type from customer where cust_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
orderType=checkNull(rs.getString("order_type"));
custType=checkNull(rs.getString("cust_type"));
}
callPstRs(pstmt, rs);
tranIdLast=getTranIdLast(orderType, itemSer, custCode,conn);
System.out.println("tranIdLast>>>"+tranIdLast+">>orderType>>>"+orderType+"custType>>>"+custType);
Document detailDom1 = genericUtility.parseString(xmlInEditMode);
NodeList parentNodeList1 = detailDom1.getElementsByTagName("Detail1");
Node parentNode1 = parentNodeList1.item(0);
NodeList childNodeList1 = parentNode1.getChildNodes();
int childNodeListLength1 = childNodeList1.getLength();
for (int ctr = 0; ctr < childNodeListLength1; ctr++)
{
Node childNode1 = childNodeList1.item(ctr);
String childNodeName1 = childNode1.getNodeName().trim();
if ("tran_id".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(tranId);
} else if ("tran_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(sysDate);
} else if ("cust_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(custCode);
} else if ("item_ser".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(itemSer);
} else if ("order_type".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(orderType);
} else if ("from_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(fromDateStr);
} else if ("to_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(toDateStr);
} else if ("site_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(loginSiteCode);
} else if ("tran_id__last".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(tranIdLast);
} else if ("tran_id__parent".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(tranIdParent);
} else if ("stmt_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(sysDate);
} else if ("confirmed".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("N");
} else if ("status".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("O");
} else if ("cust_type".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(custType);
} else if ("prd_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(prdCode);
} else if ("missing_inserted".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("Y");
} else if ("adm_chk".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("N");
} else if ("login_poscode".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(posCode);
} else if ("pos_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(posCode);
} else if ("emp_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(empCode);
} else if ("country_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(countryCode);
} else if ("edit_status".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("A");
} else if ("sale_per".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(empCode);
} else if ("chg_user".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgUser);
} else if ("chg_term".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgTerm);
} else if ("chg_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(sysDate);
} else if ("add_user".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgUser);
} else if ("add_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(sysDate);
} else if ("add_term".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgTerm);
}
}//for loop end
xmlDetail1 = xmlDetail1.append(genericUtility.serializeDom(detailDom1));
//header details end
System.out.println("xmlDetail1 final>>>>"+xmlDetail1.toString());
custStockInvDetails=custStockGWTIC.itemChanged("", xmlDetail1.toString(), xmlDetail1.toString(), "2", "itm_default", "A", xtraParams,"awacs_to_es3_prc",invMap);
System.out.println("custStockInvDetails>>>>"+custStockInvDetails);
if(custStockInvDetails.contains("Detail2"))
{
xmlDetail2=custStockInvDetails.substring(custStockInvDetails.indexOf("<Detail2"), custStockInvDetails.lastIndexOf("</Detail2>")+10);
System.out.println("xmlDetail2>>>"+xmlDetail2);
xmlBuff = new StringBuffer();
xmlBuff.append(xmlDetail1.substring(0,xmlDetail1.indexOf("</Header0>")));
xmlBuff.append(xmlDetail2);
xmlBuff.append(xmlDetail1.substring(xmlDetail1.indexOf("</Header0>")));
xmlParseStr = xmlBuff.toString();
xmlBuff = null;
System.out.println(":::xmlParseStr::with Invoice:" + xmlParseStr);
custStockItemDetails=custStockGWTIC.itemChanged(xmlInEditMode3, xmlParseStr, xmlParseStr, "3", "itm_default", "A", xtraParams,"awacs_to_es3_prc",itemMap);
}
else
{
xmlParseStr = xmlDetail1.toString();
System.out.println(":::xmlParseStr::without Invoice:" + xmlParseStr);
custStockItemDetails=custStockGWTIC.itemChanged(xmlInEditMode3, xmlParseStr, xmlParseStr, "3", "itm_default", "A", xtraParams,"awacs_to_es3_prc",itemMap);
}
System.out.println("custStockItemDetails>>>>>"+custStockItemDetails);
String xmlDetail3=custStockItemDetails.substring(custStockItemDetails.indexOf("<Detail3"), custStockItemDetails.lastIndexOf("</Detail3>")+10);
System.out.println("xmlDetail3>>>>"+xmlDetail3);
xmlBuff = new StringBuffer();
xmlBuff.append(xmlParseStr.substring(0,xmlParseStr.indexOf("<Header0>") + 9));
xmlBuff.append("<objName><![CDATA[").append("secondory_sale_gwt_wiz_dummy").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(true).append("]]></taxInFocus>");
xmlBuff.append(xmlParseStr.substring(xmlParseStr.indexOf("<Header0>") + 9,xmlParseStr.indexOf("</Header0>")));
xmlBuff.append(xmlDetail3);
xmlBuff.append(xmlParseStr.substring(xmlParseStr.indexOf("</Header0>")));
String xmlParseStrFinal = xmlBuff.toString();
xmlBuff = null;
System.out.println("xmlParseStrFinal>>>>"+xmlParseStrFinal);
retString=saveData(xmlParseStrFinal, conn, userInfo);
System.out.println("retString>>>>"+retString);
if (retString.toUpperCase().indexOf("SUCCESS") > -1)
{
conn.commit();
String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
String newTranIdGen = arrayForTranId[1].substring(0, endIndex);
if(newTranIdGen!=null && newTranIdGen.trim().length()>0)
{
retString1=confTran.submit(newTranIdGen, xtraParams, "");
System.out.println("retString1>>>"+retString1);
if (retString1.toUpperCase().indexOf("VTSUBM1") > -1)
{
errString = "Confirmed Transaction "+newTranIdGen+" Created for Customer code >>"+custCode+" of Position code >>"+posCode+" and Employee code >>"+empCode;
logList.add(errString);
errString=null;
result=true;
}
else
{
result=false;
}
}
}
else
{
String description = "";
Document parseString = genericUtility.parseString(retString);
NodeList nlErrorTag = null;
nlErrorTag = parseString.getElementsByTagName("error");
if (nlErrorTag.getLength() <= 0)
{
nlErrorTag = parseString.getElementsByTagName("Error");
}
for (int err = 0; err < nlErrorTag.getLength(); err++)
{
Node itemNode = nlErrorTag.item(err);
NamedNodeMap errorAttributes = itemNode.getAttributes();
Node errorTypeNode = errorAttributes.getNamedItem("type");
Node errorIdNode = errorAttributes.getNamedItem("type");
String errorType = errorTypeNode.getTextContent();
String errorId = errorIdNode.getTextContent();
NodeList childNodeListErr = itemNode.getChildNodes();
for (int k = 0; k < childNodeListErr.getLength(); k++)
{
Node childNodeErr = childNodeListErr.item(k);
if ("description".equalsIgnoreCase(childNodeErr.getNodeName()))
{
description = childNodeErr.getFirstChild().getNodeValue();
}
}
if ("W".equals(errorType)) {
errString = "Warnings: " + errorId + " : " + description;
}
else
{
errString = "Errors: " + errorId + " : " + description;
}
logList.add(errString);
}
}
System.out.println("result>>>"+result);
}
}
catch (Exception e)
{
e.printStackTrace();
result=false;
logList.add(e.getMessage());
}
finally
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
writeLog(this.getClass().getSimpleName()+"_"+custCode+"_"+prdCode, logList,logDate);
return errString;
}
private void callPstRs(PreparedStatement pstmt, ResultSet rs) {
try {
if(pstmt!=null)
{
pstmt.close();
pstmt =null;
}
if(rs!=null)
{
rs.close();
rs =null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
private String checkNull(String input)
{
input = input==null ? "" : input.trim();
return input;
}
private String saveData(String xmlString, Connection conn,UserInfoBean userInfo) throws Exception
{
String retString = "";
InitialContext ctx = null;
MasterStatefulLocal masterStateful = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString:::::" + xmlString);
retString = masterStateful.processRequest(userInfo, xmlString,true, conn);
System.out.println("ProcessRequest::::::" + retString);
}
catch (Exception e)
{
System.out.println("Exception: EJBName ["+ getClass().getSimpleName() + "] -method [saveData]");
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
private String getHeaderXML(UserInfoBean userInfo,String formNo,String pagContext) throws Exception
{
InitialContext ctx = null;
String retString = "";
MasterDataStatefulLocal masterStateful = null;
AppConnectParm appConnect = new AppConnectParm();
try{
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterDataStatefulLocal) ctx.lookup("ibase/MasterDataStatefulEJB/local");
retString=masterStateful.getBlankDomForAdd("secondory_sale_gwt_wiz", formNo, pagContext, null, userInfo.toString(), "");
}catch(Exception e)
{
e.printStackTrace();
}
return retString;
}
private void writeLog(String fileName, ArrayList<String> logList,String logDate)
{
String jBossHome = CommonConstants.JBOSSHOME;
FileWriter localFileWriter = null;
try {
if(logList.size()>0){
File logDir = new File(jBossHome + File.separator+ "log" + File.separator + "AwacsToEs3GenProcLog");
if (!logDir.exists()) {
logDir.mkdirs();
}
localFileWriter = new FileWriter(new File(jBossHome + File.separator + "log" + File.separator + "AwacsToEs3GenProcLog" + File.separator + fileName + ".log"), true);
localFileWriter.write("Log for AWACS to Seondary Sales Generation Process for date::"+logDate+" \n");
for(int i=0;i<logList.size();i++)
{
localFileWriter.write((logList.get(i)).toString()+"\n");
}
localFileWriter.write("\n\n");
localFileWriter.flush();
localFileWriter.close();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
private int isCustExist(String prdCode, String custCode, String itemSer, PreparedStatement pstmt, ResultSet rs, Connection conn)
{
String sql="";
int custCntr=0;
try
{
sql=" select count(*) as count from cust_stock where cust_code=? and item_ser=? and prd_code=? and pos_code is not null ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemSer);
pstmt.setString(3, prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
custCntr = rs.getInt("count");
}
callPstRs(pstmt, rs);
System.out.println("custCntr>>>>>"+custCntr);
}
catch(SQLException e)
{
e.printStackTrace();
System.out.println("custCnt SQLException"+e);
}
finally
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
return custCntr;
}
private String getTranIdLast(String orderType, String itemSer,String custCode,Connection conn)
{
String sql="",tranIdLast="";
PreparedStatement pstmt=null;
ResultSet rs=null;
Timestamp toDateLast=null;
try
{
sql = " SELECT max(to_date) as to_date FROM CUST_STOCK WHERE CUST_CODE = ? " +
" AND ITEM_SER = ? and order_type=? and pos_code is not null and confirmed='Y' and status='S' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemSer);
pstmt.setString(3, orderType);
rs = pstmt.executeQuery();
if (rs.next())
{
toDateLast = rs.getTimestamp("to_date");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = " SELECT max(tran_id) as oldTranId FROM CUST_STOCK WHERE CUST_CODE = ? " +
" AND ITEM_SER = ? and order_type=? and pos_code is not null and confirmed='Y' and status='S' and to_date=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemSer);
pstmt.setString(3, orderType);
pstmt.setTimestamp(4, toDateLast);
rs = pstmt.executeQuery();
if (rs.next())
{
tranIdLast = checkNull(rs.getString("oldTranId"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
return tranIdLast;
}
}// END OF EJB
\ No newline at end of file
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ProcessLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface AwacsToES3PrcLocal extends ProcessLocal{
public String process(String arg0, String arg1, String arg2, String arg3) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ProcessRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface AwacsToES3PrcRemote extends ProcessRemote{
public String process(String arg0, String arg1, String arg2, String arg3) throws RemoteException, ITMException;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import java.rmi.RemoteException; import java.rmi.RemoteException;
//import javax.ejb.EJBObject; import java.util.HashMap;
import org.w3c.dom.*; //import javax.ejb.EJBObject;
import javax.xml.parsers.*; import org.w3c.dom.*;
import javax.xml.parsers.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; //added for ejb3 import ibase.webitm.utility.ITMException;
@Local // added for ejb3 import javax.ejb.Local; //added for ejb3
@Local // added for ejb3
public interface CustStockGWTICLocal extends ValidatorLocal//, EJBObject
{ public interface CustStockGWTICLocal extends ValidatorLocal//, EJBObject
public String wfValData() throws RemoteException,ITMException; {
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, 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(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; //Method override for external transaction generation process Added by saurabh[27/03/17|Start]
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams,String objName) throws RemoteException,ITMException;
//Method override for external transaction generation process Added by saurabh[27/03/17|End]
//Method override for external transaction generation process for AWACS Added by saurabh[24/07/17|Start]
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams,String objName,HashMap dataMap) throws RemoteException,ITMException;
//Method override for external transaction generation process for AWACS Added by saurabh[24/07/17|End]
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
} }
\ No newline at end of file
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import java.rmi.RemoteException; import java.rmi.RemoteException;
//import javax.ejb.EJBObject; import java.util.HashMap;
import org.w3c.dom.*; //import javax.ejb.EJBObject;
import javax.xml.parsers.*; import org.w3c.dom.*;
import javax.xml.parsers.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3 import ibase.webitm.utility.ITMException;
@Remote // added for ejb3 import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface CustStockGWTICRemote extends ValidatorRemote//, EJBObject
{ public interface CustStockGWTICRemote extends ValidatorRemote//, EJBObject
public String wfValData() throws RemoteException,ITMException; {
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException; public String wfValData() throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException; public String wfValData(Document dom, Document dom1, 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 wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String itemChanged() 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() throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, 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(String xmlString, String xmlString1, 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;
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException; public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException;
//Method override for external transaction generation process Added by saurabh[27/03/17|Start]
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams,String objName) throws RemoteException,ITMException;
//Method override for external transaction generation process Added by saurabh[27/03/17|End]
//Method override for external transaction generation process for AWACS Added by saurabh[24/07/17|Start]
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams,String objName,HashMap dataMap) throws RemoteException,ITMException;
//Method override for external transaction generation process for AWACS Added by saurabh[24/07/17|End]
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
} }
\ No newline at end of file
/** /**
* @author CustStockGWTPostSave written for itemchange issue on closing stock by Saurabh Jarande [16/02/17] * @author CustStockGWTPostSave written for itemchange issue on closing stock by Saurabh Jarande [16/02/17]
* *
*/ */
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.sys.UtilMethods; import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection; import java.rmi.RemoteException;
import java.sql.PreparedStatement; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.PreparedStatement;
import java.sql.Timestamp; import java.sql.ResultSet;
import java.text.DecimalFormat; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Date;
import java.util.Date;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@Stateless
@Stateless public class CustStockGWTPostSave extends ValidatorEJB implements CustStockGWTPostSaveLocal,CustStockGWTPostSaveRemote {
public class CustStockGWTPostSave extends ValidatorEJB implements CustStockGWTPostSaveLocal,CustStockGWTPostSaveRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException {
{ System.out.println("------------ postSave method called-111111111----------------CustStockGWTPostSave : ");
System.out.println("------------ postSave method called-111111111----------------CustStockGWTPostSave : "); System.out.println("tranId111--->>["+tranId+"]");
System.out.println("tranId111--->>["+tranId+"]"); System.out.println("xml String--->>["+xmlString+"]");
System.out.println("xml String--->>["+xmlString+"]"); Document dom = null;
Document dom = null; String errString="";
String errString=""; try
try {
{ if (xmlString != null && xmlString.trim().length() > 0)
if (xmlString != null && xmlString.trim().length() > 0) {
{ dom = parseString(xmlString);
dom = parseString(xmlString); errString = postSave(dom,tranId,xtraParams,conn);
errString = postSave(dom,tranId,xtraParams,conn); }
}
}
} catch(Exception e)
catch(Exception e) {
{ System.out.println("Exception : CustStockGWTPostSave.java : postSave : ==>\n"+e.getMessage());
System.out.println("Exception : CustStockGWTPostSave.java : postSave : ==>\n"+e.getMessage()); throw new ITMException(e);
throw new ITMException(e); }
} return errString;
return errString; }
} public String postSave(Document dom,String tranId,String xtraParams,Connection conn) throws ITMException, RemoteException
public String postSave(Document dom,String tranId,String xtraParams,Connection conn) throws ITMException, RemoteException {
{ System.out.println("in CustStockGWTPostSave tran_id---->>["+tranId+"]");
System.out.println("in CustStockGWTPostSave tran_id---->>["+tranId+"]"); ResultSet rs=null;
ResultSet rs=null; PreparedStatement pstmt=null;
PreparedStatement pstmt=null; String sql="";
String sql=""; String errString = "",isValidCust="";
String errString = ""; String invoiceId="",invoiceIdList="",selectedInvList="";
String invoiceId="",invoiceIdList="",selectedInvList=""; ITMDBAccessEJB itmDBAccessEJB=new ITMDBAccessEJB();
ibase.utility.E12GenericUtility genericUtility = null; try
genericUtility = new ibase.utility.E12GenericUtility(); {
ITMDBAccessEJB itmDBAccessEJB=new ITMDBAccessEJB(); sql="select invoice_id from cust_stock_inv where tran_id=? and dlv_flg='Y' and ref_ser='S-INV' ";
try pstmt = conn.prepareStatement(sql);
{ pstmt.setString(1,tranId);
sql="select invoice_id from cust_stock_inv where tran_id=? and dlv_flg='Y' and ref_ser='S-INV' "; rs = pstmt.executeQuery( );
pstmt = conn.prepareStatement(sql); while( rs.next() )
pstmt.setString(1,tranId); {
rs = pstmt.executeQuery( ); invoiceId = rs.getString("invoice_id");
while( rs.next() ) invoiceIdList = invoiceIdList + "'"+invoiceId.trim() + "',";
{ }
invoiceId = rs.getString("invoice_id"); callPstRs(pstmt, rs);
invoiceIdList = invoiceIdList + "'"+invoiceId.trim() + "',"; if(invoiceIdList.trim().length() > 0)
} {
callPstRs(pstmt, rs); selectedInvList = invoiceIdList.substring(0,invoiceIdList.length() - 1);
if(invoiceIdList.trim().length() > 0) }
{ else
selectedInvList = invoiceIdList.substring(0,invoiceIdList.length() - 1); {
} selectedInvList = "' '";
else }
{ System.out.println("selectedInvList>>>>"+selectedInvList);
selectedInvList = "' '"; //Added by saurabh for duplicate customer validation[10/03/17|Start]
} isValidCust =checkValidCust(tranId,conn);
System.out.println("selectedInvList>>>>"+selectedInvList); if(isValidCust== null || isValidCust.trim().length()==0)
errString =updateCustStockDet(dom,tranId,selectedInvList,conn); {
System.out.println("errString>>>>"+errString); errString =updateCustStockDet(dom,tranId,selectedInvList,conn);
} }
catch(Exception e) else
{ {
e.printStackTrace(); errString=isValidCust;
System.out.println("Exception ::"+e.getMessage()); }
errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn); System.out.println("errString>>>>"+errString);
} //Added by saurabh for duplicate customer validation[10/03/17|End]
finally }
{ catch(Exception e)
try {
{ e.printStackTrace();
System.out.println(">>>>>In finally errString:"+errString); System.out.println("Exception ::"+e.getMessage());
errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn);
if(errString != null && errString.trim().length()>0 ) }
{ finally
errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn); {
} try
} {
catch(Exception e) System.out.println(">>>>>In finally errString:"+errString);
{
System.out.println("Exception : "+e); if(errString != null && errString.trim().length()>0 )
e.printStackTrace(); {
} //errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn);
} return errString;
return errString; }
} }
catch(Exception e)
{
private String updateCustStockDet(Document dom,String tranId,String selectedInvList, Connection conn) throws RemoteException, ITMException System.out.println("Exception : "+e);
{ e.printStackTrace();
// TODO Auto-generated method stub }
E12GenericUtility genericUtility =new E12GenericUtility(); }
String errString=""; return errString;
PreparedStatement pstmt,pstmt1,pstmt2=null; }
ResultSet rs,rs1,rs2 =null;
String clStockInp="",itemCode1="",custCodeDom="",itemSerHd="",orderType="",itemSerHeaderSplit="",calCriItemSerStr=""; //Added by saurabh for duplicate customer validation[10/03/17|Start]
String invoiceMonths="",fromdate="",todate="",sql="",priceList="",sysDate="",tarnIdLast=""; private String checkValidCust(String tranId, Connection conn) {
int invoiceMonthsPrevious=0,UpdCnt=0; // TODO Auto-generated method stub
double rcpQtmDom=0,rcpReplQtmDom=0,rcpFreeQtmDom=0,retQtyDom=0,retQtyFreeDom=0,opStkDom=0,rateOld=0,rateOrgOld=0,rcpValue=0,replValue=0,retValue=0,rcpFreeValue=0; String sql="",custCodeDom="",itemSerHd="",prdCode="",errString="";
double clStock=0,formulaValue=0,rateStd=0,quantityStd=0,closingValue=0,rateAll=0,calRate=0,closingRate=0,grossSecondaryQty=0,netSecondarySalesValue=0,grossSecondarySalesValue=0,grossSecondaryRate=0,salesQtyCal=0; int custCnt=0;
boolean isClStockInt=false,isItemSerLocal=false; PreparedStatement pstmt=null;
Timestamp thirdMonthDay=null,prdFromoDateTmstmp=null,prdtoDateTmstmp=null; ResultSet rs=null;
ArrayList calCriItemSerList=null; ITMDBAccessEJB itmDBAccessEJB =new ITMDBAccessEJB();
ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon(); try
UtilMethods utlmethd = new UtilMethods(); {
Date currentDate = new Date(); sql="select cust_code,item_ser,prd_code from cust_stock where tran_id=? ";
ITMDBAccessEJB itmDBAccessEJB =new ITMDBAccessEJB(); pstmt = conn.prepareStatement(sql);
try pstmt.setString(1, tranId);
{ rs = pstmt.executeQuery();
invoiceMonths = dist.getDisparams("999999","INVOICE_MONTHS",conn); if(rs.next())
System.out.println("invoiceMonths.." + invoiceMonths); {
if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0) ) custCodeDom = rs.getString("cust_code");
{ itemSerHd = rs.getString("item_ser");
invoiceMonthsPrevious=-3; prdCode = rs.getString("prd_code");
}else }
{ callPstRs(pstmt, rs);
invoiceMonthsPrevious=Integer.parseInt(invoiceMonths);
} sql=" select count(*) as count from cust_stock where cust_code=? and item_ser=? and prd_code=? and tran_id!=? and pos_code is not null ";
System.out.println("invoiceMonthsPrevious>>>>>"+invoiceMonthsPrevious); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCodeDom);
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat()); pstmt.setString(2, itemSerHd);
sysDate = sdf2.format(currentDate.getTime()); pstmt.setString(3, prdCode);
calCriItemSerStr = dist.getDisparams("999999","CAL_CRIT_ITEMSER",conn); pstmt.setString(4, tranId);
if (("NULLFOUND".equalsIgnoreCase(calCriItemSerStr) || calCriItemSerStr == null || calCriItemSerStr.trim().length() == 0) ) rs = pstmt.executeQuery();
{ if (rs.next())
isItemSerLocal=false; {
}else custCnt = rs.getInt("count");
{ }
calCriItemSerList= new ArrayList(Arrays.asList(calCriItemSerStr.split(","))); callPstRs(pstmt, rs);
}
System.out.println("isItemSer@@@@@@@after>>>>"+isItemSerLocal); if(custCnt>0)
{
sql=" select d.item_code,d.cl_stock,d.purc_rcp,d.purc_rcp__repl,d.purc_rcp__free,d.purc_ret,d.purc_ret__repl,d.op_stock," + errString = itmDBAccessEJB.getErrorString("", "VMINVPRDCU","", "", conn);
" c.cust_code,c.tran_id__last, " + }
" d.rcp_val,d.rcp_repl_val,d.ret_val,d.rcp_free_val,c.item_ser,c.order_type,c.from_date,c.to_date " + else
" from cust_stock_det d,cust_stock c" + {
" where d.tran_id=c.tran_id " + errString="";
" and d.cl_value=0 and d.rate=0 and d.cl_stock>0 and d.tran_id=? "; }
pstmt = conn.prepareStatement(sql); }
pstmt.setString(1,tranId); catch(Exception e)
rs = pstmt.executeQuery(); {
while(rs.next()) errString = e.getMessage();
{ }
itemCode1=checkNull(rs.getString("item_code")); return errString;
clStockInp=checkNull(rs.getString("cl_stock")); }
rcpQtmDom=rs.getDouble("purc_rcp"); //Added by saurabh for duplicate customer validation[10/03/17|End]
rcpReplQtmDom=rs.getDouble("purc_rcp__repl");
rcpFreeQtmDom=rs.getDouble("purc_rcp__free"); private String updateCustStockDet(Document dom,String tranId,String selectedInvList, Connection conn) throws RemoteException, ITMException
retQtyDom=rs.getDouble("purc_ret"); {
retQtyFreeDom=rs.getDouble("purc_ret__repl"); // TODO Auto-generated method stub
opStkDom=rs.getDouble("op_stock"); E12GenericUtility genericUtility =new E12GenericUtility();
custCodeDom=checkNull(rs.getString("cust_code")); String errString="";
tarnIdLast=checkNull(rs.getString("tran_id__last")); PreparedStatement pstmt,pstmt1 = null;
rcpValue=rs.getDouble("rcp_val"); ResultSet rs,rs1 =null;
replValue=rs.getDouble("rcp_repl_val"); String clStockInp="",itemCode1="",custCodeDom="",itemSerHd="";
retValue=rs.getDouble("ret_val"); String invoiceMonths="",sql="",priceList="",sysDate="",tarnIdLast="";
rcpFreeValue=rs.getDouble("rcp_free_val"); String calEnablePrice="",calPriceDivision="";
itemSerHd = checkNull(rs.getString("item_ser")); int invoiceMonthsPrevious=0,UpdCnt=0;
orderType = checkNull(rs.getString("order_type")); double rcpQtmDom=0,rcpReplQtmDom=0,rcpFreeQtmDom=0,retQtyDom=0,retQtyFreeDom=0,opStkDom=0,rateOld=0,rcpValue=0,replValue=0,retValue=0,rcpFreeValue=0;
prdFromoDateTmstmp = rs.getTimestamp("from_date"); double clStock=0,formulaValue=0,rateStd=0,quantityStd=0,closingValue=0,
prdtoDateTmstmp = rs.getTimestamp("to_date"); rateAll=0,closingRate=0,grossSecondaryQty=0,netSecondarySalesValue=0,grossSecondarySalesValue=0,
grossSecondaryRate=0,salesQtyCal=0,clValOld=0,clStkOld=0,opValDom=0;
boolean isClStockInt=false,isItemSerLocal=false;
if(tarnIdLast.length()>0){ Timestamp thirdMonthDay=null,prdFromoDateTmstmp=null,prdtoDateTmstmp=null;
sql = " select CASE WHEN rate IS NULL THEN 0 ELSE rate END as rate," + //ArrayList calCriItemSerList=null;
" CASE WHEN rate__org IS NULL THEN 0 ELSE rate__org END as rate__org from " + ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon();
" cust_stock_det where tran_id=? and item_code=? "; UtilMethods utlmethd = new UtilMethods();
pstmt1 = conn.prepareStatement(sql); Date currentDate = new Date();
pstmt1.setString(1, tarnIdLast); ITMDBAccessEJB itmDBAccessEJB =new ITMDBAccessEJB();
pstmt1.setString(2, itemCode1); try
rs1 = pstmt1.executeQuery(); {
if (rs1.next()) invoiceMonths = dist.getDisparams("999999","INVOICE_MONTHS",conn);
{ System.out.println("invoiceMonths.." + invoiceMonths);
rateOld = Double.parseDouble(rs1.getString("rate")); if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0) )
rateOrgOld = Double.parseDouble(rs1.getString("rate__org")); {
} invoiceMonthsPrevious=-3;
callPstRs(pstmt1, rs1); }else
} {
invoiceMonthsPrevious=Integer.parseInt(invoiceMonths);
}
System.out.println("prdFromoDateTmstmp :"+prdFromoDateTmstmp); System.out.println("invoiceMonthsPrevious>>>>>"+invoiceMonthsPrevious);
System.out.println("prdtoDateTmstmp :"+prdtoDateTmstmp);
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(calCriItemSerStr.trim().length()>0)
{ /*calCriItemSerStr = dist.getDisparams("999999","CAL_CRIT_ITEMSER",conn);
System.out.println("calCriItemSerList.contains(itemSerHd.trim())"+calCriItemSerList.contains(itemSerHd.trim())); if (("NULLFOUND".equalsIgnoreCase(calCriItemSerStr) || calCriItemSerStr == null || calCriItemSerStr.trim().length() == 0) )
if(calCriItemSerList.contains(itemSerHd.trim())) {
{ isItemSerLocal=false;
System.out.println("Inside ItemSer true::::["+calCriItemSerList.contains(itemSerHd.trim())+"]"); }else
isItemSerLocal=true; {
} calCriItemSerList= new ArrayList(Arrays.asList(calCriItemSerStr.split(",")));
else{ }
System.out.println("Inside ItemSer false::::["+calCriItemSerList.contains(itemSerHd.trim())+"]"); System.out.println("isItemSer@@@@@@@after>>>>"+isItemSerLocal);*/
isItemSerLocal=false;
} sql=" select d.item_code,d.cl_stock,d.purc_rcp,d.purc_rcp__repl,d.purc_rcp__free,d.purc_ret,d.purc_ret__repl,d.op_stock,d.op_value, " +
} " c.cust_code,c.tran_id__last, " +
else " d.rcp_val,d.rcp_repl_val,d.ret_val,d.rcp_free_val,c.item_ser,c.order_type,c.from_date,c.to_date " +
{ " from cust_stock_det d,cust_stock c" +
System.out.println("isItemSer:::::"+isItemSerLocal); " where d.tran_id=c.tran_id " +
} //" and d.cl_value=0 and d.rate=0 and d.cl_stock>0 and d.tran_id=? ";
" and d.tran_id=? ";
itemSerHd=getItemSerList(itemSerHd,conn); pstmt = conn.prepareStatement(sql);
itemSerHeaderSplit=itemSerHd; pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
isClStockInt= isValidDouble(clStockInp); while(rs.next())
System.out.println("isClStockInt>>>>>>"+isClStockInt); {
if(isClStockInt && Double.parseDouble(clStockInp)>=0) sysDate = sdf2.format(currentDate.getTime());
{ itemCode1=checkNull(rs.getString("item_code"));
System.out.println("clStockInp :" + clStockInp); clStockInp=checkNull(rs.getString("cl_stock"));
if (clStockInp != null) rcpQtmDom=rs.getDouble("purc_rcp");
{ rcpReplQtmDom=rs.getDouble("purc_rcp__repl");
clStock = Math.round(Double.parseDouble(clStockInp)); rcpFreeQtmDom=rs.getDouble("purc_rcp__free");
} else retQtyDom=rs.getDouble("purc_ret");
{ retQtyFreeDom=rs.getDouble("purc_ret__repl");
clStock = 0.0; opStkDom=rs.getDouble("op_stock");
} opValDom=rs.getDouble("op_value");
System.out.println("opStkDom :" + opStkDom); custCodeDom=checkNull(rs.getString("cust_code"));
System.out.println("rcpQtmDom :" + rcpQtmDom); tarnIdLast=checkNull(rs.getString("tran_id__last"));
System.out.println("rcpReplQtmDom :" + rcpReplQtmDom); rcpValue=rs.getDouble("rcp_val");
System.out.println("retQtyDom :" + retQtyDom); replValue=rs.getDouble("rcp_repl_val");
System.out.println("retQtyFreeDom :" + retQtyFreeDom); retValue=rs.getDouble("ret_val");
System.out.println("rcpFreeQtmDom :" + rcpFreeQtmDom); rcpFreeValue=rs.getDouble("rcp_free_val");
System.out.println("clStock :" + clStock); itemSerHd = checkNull(rs.getString("item_ser"));
formulaValue=clStock; System.out.println("@S@itemSerHd"+itemSerHd+"]");
System.out.println("formulaValue@@@@@@>>>"+formulaValue); //orderType = checkNull(rs.getString("order_type"));
System.out.println("isItemSer>>>>>"+isItemSerLocal); prdFromoDateTmstmp = rs.getTimestamp("from_date");
prdtoDateTmstmp = rs.getTimestamp("to_date");
if(!isItemSerLocal)
{ rateOld=0;//rateOrgOld=0;
/*invoiceMonths = dist.getDisparams("999999","INVOICE_MONTHS",conn); clValOld=0;clStkOld=0;//added 140617
System.out.println("invoiceMonths.." + invoiceMonths); if(tarnIdLast.length()>0){
if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0) ) sql = " select CASE WHEN rate IS NULL THEN 0 ELSE rate END as rate," +
{ " CASE WHEN rate__org IS NULL THEN 0 ELSE rate__org END as rate__org," +
invoiceMonthsPrevious=-3; " NVL(cl_value,0) as cl_value ," +
}else " NVL(cl_stock,0) as cl_stock from " +
{ " cust_stock_det where tran_id=? and item_code=? ";
invoiceMonthsPrevious=Integer.parseInt(invoiceMonths); pstmt1 = conn.prepareStatement(sql);
} pstmt1.setString(1, tarnIdLast);
System.out.println("invoiceMonthsPrevious>>>>>"+invoiceMonthsPrevious); pstmt1.setString(2, itemCode1);
*/ rs1 = pstmt1.executeQuery();
thirdMonthDay= utlmethd.AddMonths(prdFromoDateTmstmp, invoiceMonthsPrevious); if (rs1.next())
System.out.println("thirdMonthDay>>>>>>"+thirdMonthDay); {
rateOld = Double.parseDouble(rs1.getString("rate"));
closingValue=0; //rateOrgOld = Double.parseDouble(rs1.getString("rate__org"));
clValOld = Double.parseDouble(rs1.getString("cl_value"));
sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,itrc.quantity__stduom as ,itrc.quantity__stduom,inv.tran_date " + clStkOld = Double.parseDouble(rs1.getString("cl_stock"));
"FROM invoice_trace itrc,invoice inv WHERE itrc.item_code=? " + }
"and itrc.invoice_id=inv.invoice_id and inv.tran_date>=? " + callPstRs(pstmt1, rs1);
"and inv.tran_date<=? AND itrc.rate__stduom >0.001 and inv.cust_code=? " + }
" ORDER BY inv.tran_date DESC";
pstmt1 = conn.prepareStatement(sql); if(clStkOld>0)
pstmt1.setString(1,itemCode1); {
pstmt1.setTimestamp(2,thirdMonthDay); opStkDom=clStkOld;
pstmt1.setTimestamp(3,prdtoDateTmstmp); }
pstmt1.setString(4, custCodeDom ); System.out.println("prdFromoDateTmstmp :"+prdFromoDateTmstmp);
rs1 = pstmt1.executeQuery( ); System.out.println("prdtoDateTmstmp :"+prdtoDateTmstmp);
while(rs1.next())
{ /*if(calCriItemSerStr.trim().length()>0)
rateStd = rs1.getDouble("rate__stduom" ); {
quantityStd = rs1.getDouble("quantity__stduom" ); System.out.println("calCriItemSerList.contains(itemSerHd.trim())"+calCriItemSerList.contains(itemSerHd.trim()));
System.out.println("rateStd :"+rateStd); if(calCriItemSerList.contains(itemSerHd.trim()))
System.out.println("quantityStd :"+quantityStd); {
if(formulaValue>=quantityStd) System.out.println("Inside ItemSer true::::["+calCriItemSerList.contains(itemSerHd.trim())+"]");
{ isItemSerLocal=true;
closingValue=closingValue+ quantityStd*rateStd; }
System.out.println("closing value"+closingValue); else{
formulaValue=formulaValue-quantityStd; System.out.println("Inside ItemSer false::::["+calCriItemSerList.contains(itemSerHd.trim())+"]");
} isItemSerLocal=false;
else }
{ }
closingValue=closingValue+ formulaValue*rateStd; else
formulaValue=0; {
System.out.println("closing value>>>>"+closingValue); System.out.println("isItemSer:::::"+isItemSerLocal);
} }*/
closingValue=getRequiredDcml(closingValue,3);
if(formulaValue == 0) //itemSerHd=getItemSerList(itemSerHd,conn);
{ System.out.println("@S@ Group item series::"+itemSerHd);
break; //itemSerHeaderSplit=itemSerHd;
}
} isClStockInt= isValidDouble(clStockInp);
callPstRs(pstmt1, rs1); System.out.println("isClStockInt>>>>>>"+isClStockInt);
System.out.println("closingValue>>>>>>"+closingValue); if(isClStockInt && Double.parseDouble(clStockInp)>=0)
System.out.println("formulaValue>>>>>>"+formulaValue); {
if(formulaValue>0) System.out.println("clStockInp :" + clStockInp);
{ if (clStockInp != null)
sql = "select price_list from customer where cust_code =? "; {
pstmt1 = conn.prepareStatement(sql); clStock = Math.round(Double.parseDouble(clStockInp));
pstmt1.setString(1, custCodeDom ); } else
rs1 = pstmt1.executeQuery(); {
if (rs1.next()) clStock = 0.0;
{ }
priceList = checkNull(rs1.getString("price_list")); System.out.println("opStkDom :" + opStkDom);
System.out.println("priceList edit :" + priceList); System.out.println("rcpQtmDom :" + rcpQtmDom);
} System.out.println("rcpReplQtmDom :" + rcpReplQtmDom);
callPstRs(pstmt1, rs1); System.out.println("retQtyDom :" + retQtyDom);
//Added by saurabh to get rate from DDF_PICK_MAX_RATE fuction[18/10/16|Start] System.out.println("retQtyFreeDom :" + retQtyFreeDom);
sysDate = genericUtility.getValidDateString( sysDate , getApplDateFormat() , getDBDateFormat()); System.out.println("rcpFreeQtmDom :" + rcpFreeQtmDom);
sql = "SELECT DDF_PICK_MAX_SLAB_RATE( ?, TO_DATE( ? , ? ), ? ) FROM DUAL "; System.out.println("clStock :" + clStock);
pstmt1 = conn.prepareStatement( sql ); formulaValue=clStock;
pstmt1.setString( 1, priceList ); System.out.println("formulaValue@@@@@@>>>"+formulaValue);
pstmt1.setString( 2, sysDate ); System.out.println("isItemSer>>>>>"+isItemSerLocal);
pstmt1.setString( 3, getDBDateFormat() );
pstmt1.setString( 4, itemCode1 ); //if(!isItemSerLocal)
rs1 = pstmt1.executeQuery(); //{
if (rs1.next()) /*invoiceMonths = dist.getDisparams("999999","INVOICE_MONTHS",conn);
{ System.out.println("invoiceMonths.." + invoiceMonths);
rateAll = rs1.getDouble(1); if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0) )
System.out.println("rateAll-----------> [" +rateAll+ "]"); {
} invoiceMonthsPrevious=-3;
callPstRs(pstmt1, rs1); }else
rateAll=getRequiredDcml(rateAll,3); {
//Added by saurabh to get rate from DDF_PICK_MAX_RATE fuction[18/10/16|end] invoiceMonthsPrevious=Integer.parseInt(invoiceMonths);
System.out.println("rateAll>>>>>"+rateAll); }
closingValue=closingValue+formulaValue*rateAll; System.out.println("invoiceMonthsPrevious>>>>>"+invoiceMonthsPrevious);
closingValue=getRequiredDcml(closingValue,3); */
//Modified by santosh to set priceList(14/SEP/2017).[START]
} calEnablePrice = dist.getDisparams("999999","ENABLE_SPEC_PRICELIST",conn);
}else calPriceDivision = dist.getDisparams("999999","SPEC_PRICELIST",conn);
{ System.out.println("calEnablePrice["+calEnablePrice+"]calPriceDivision["+calPriceDivision+"]");
calRate=getOpeningRate(invoiceMonthsPrevious,orderType,itemSerHeaderSplit,selectedInvList,rcpQtmDom,itemCode1,prdtoDateTmstmp,prdFromoDateTmstmp,custCodeDom,conn); if (("NULLFOUND".equalsIgnoreCase(calEnablePrice) || calEnablePrice == null || calEnablePrice.trim().length() == 0) )
calRate=getRequiredDcml(calRate,3); {
closingValue=clStock*calRate; calEnablePrice="N";
} }
if(clStock>0) if (("NULLFOUND".equalsIgnoreCase(calPriceDivision) || calPriceDivision == null || calPriceDivision.trim().length() == 0) )
{ {
closingRate=closingValue/clStock; calEnablePrice="N";
}else }
{ System.out.println("calEnablePrice["+calEnablePrice+"]calPriceDivision["+calPriceDivision+"]");
closingRate=0.0; //Modified by santosh to set priceList(14/SEP/2017).[END]
} thirdMonthDay= utlmethd.AddMonths(prdFromoDateTmstmp, invoiceMonthsPrevious);
closingRate=getRequiredDcml(closingRate,3); System.out.println("thirdMonthDay>>>>>>"+thirdMonthDay);
formulaValue=0;grossSecondaryQty=0;netSecondarySalesValue=0;grossSecondarySalesValue=0;salesQtyCal=0; closingValue=0;
grossSecondaryQty=opStkDom+rcpQtmDom+rcpReplQtmDom+rcpFreeQtmDom-retQtyDom-clStock; sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,itrc.quantity__stduom as quantity__stduom,inv.tran_date " +
System.out.println("grossSecondaryQty>>>>"+grossSecondaryQty); "FROM invoice_trace itrc,invoice inv WHERE itrc.item_code=? " +
System.out.println("closingRate@@@@@@@@@"+closingRate); "and itrc.invoice_id=inv.invoice_id and inv.tran_date>=? " +
System.out.println("grossSecondaryQty>>>>>>"+grossSecondaryQty); "and inv.tran_date<=? AND itrc.rate__stduom >0.001 and inv.cust_code=? " +
System.out.println("formulaValue>>>>>"+formulaValue); " ORDER BY inv.tran_date DESC";
System.out.println("opStkDom>>>"+opStkDom+">>rateOld>>>"+rateOld); pstmt1 = conn.prepareStatement(sql);
System.out.println("rcpValue>>>"+rcpValue+">>replValue>>>"+replValue); pstmt1.setString(1,itemCode1);
System.out.println("retValue>>>"+retValue+">>closingValue>>>"+closingValue); pstmt1.setTimestamp(2,thirdMonthDay);
System.out.println("rcpFreeValue>>>>"+rcpFreeValue); pstmt1.setTimestamp(3,prdtoDateTmstmp);
netSecondarySalesValue=(opStkDom*rateOld)+rcpValue+replValue-retValue-closingValue; pstmt1.setString(4, custCodeDom );
netSecondarySalesValue=getRequiredDcml(netSecondarySalesValue,3); rs1 = pstmt1.executeQuery( );
System.out.println("netSecondarySalesValue>>>>>>>"+netSecondarySalesValue); while(rs1.next())
grossSecondarySalesValue=(opStkDom*rateOrgOld)+rcpValue+replValue+rcpFreeValue-retValue-closingValue; {
grossSecondarySalesValue=getRequiredDcml(grossSecondarySalesValue,3); rateStd = rs1.getDouble("rate__stduom" );
System.out.println("grossSecondarySalesValue>>>>"+grossSecondarySalesValue); quantityStd = rs1.getDouble("quantity__stduom" );
System.out.println("rateStd :"+rateStd);
if(grossSecondaryQty>0) System.out.println("quantityStd :"+quantityStd);
{ if(formulaValue>=quantityStd)
grossSecondaryRate = grossSecondarySalesValue / grossSecondaryQty; {
}else closingValue=closingValue+ quantityStd*rateStd;
{ System.out.println("closing value"+closingValue);
grossSecondaryRate=0.0; formulaValue=formulaValue-quantityStd;
} }
grossSecondaryRate=getRequiredDcml(grossSecondaryRate,3); else
System.out.println("grossSecondaryRate>>>"+grossSecondaryRate); {
salesQtyCal = opStkDom + (rcpQtmDom + rcpReplQtmDom) - (retQtyDom + retQtyFreeDom) - clStock; closingValue=closingValue+ formulaValue*rateStd;
System.out.println("salesQtyCal :" + salesQtyCal); formulaValue=0;
System.out.println("closing value>>>>"+closingValue);
}
sql =" update cust_stock_det set sales=? ,rate=? ,rate__org=? ,sales__org=? ,cl_value=? ,sales_value=? ,op_value=? where tran_id=? and item_code=? "; closingValue=getRequiredDcml(closingValue,3);
pstmt1 = conn.prepareStatement(sql); if(formulaValue == 0)
pstmt1.setDouble(1, salesQtyCal );//sales {
pstmt1.setDouble(2, closingRate );//rate break;
pstmt1.setDouble(3, grossSecondaryRate );//rate__org }
pstmt1.setDouble(4, grossSecondaryQty );//sales__org }
pstmt1.setDouble(5, closingValue );//cl_value callPstRs(pstmt1, rs1);
pstmt1.setDouble(6, netSecondarySalesValue );//sales_value System.out.println("closingValue>>>>>>"+closingValue);
pstmt1.setDouble(7, getRequiredDcml((opStkDom*rateOld),3) );//op_value System.out.println("formulaValue>>>>>>"+formulaValue);
pstmt1.setString(8, tranId); if(formulaValue>0)
pstmt1.setString(9, itemCode1); {
UpdCnt = pstmt1.executeUpdate(); //Modified by santosh to set priceList(14/SEP/2017).[START]
if(UpdCnt>0) if("Y".equalsIgnoreCase(calEnablePrice))
{ {
System.out.println("No of record updated:"+UpdCnt+" for tranId>>"+tranId+">>>itemCode1"+itemCode1); if("BR".equalsIgnoreCase(itemSerHd))
} {
if (pstmt1 != null) priceList = calPriceDivision.substring(calPriceDivision.indexOf(",")+1,calPriceDivision.length());
{ System.out.println("@S@priceList for division ::BR:: ["+priceList+"]");
pstmt1.close(); }
pstmt1 = null; else
} {
} priceList= calPriceDivision.substring(0,calPriceDivision.indexOf(","));
System.out.println("@S@priceList for all divisions ["+priceList+"]");
} }
callPstRs(pstmt, rs); }
else
} {
catch(Exception e) sql = "select price_list from customer where cust_code =? ";
{ pstmt1 = conn.prepareStatement(sql);
e.printStackTrace(); pstmt1.setString(1, custCodeDom );
//errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn); rs1 = pstmt1.executeQuery();
errString=e.getMessage(); if (rs1.next())
} {
finally priceList = checkNull(rs1.getString("price_list"));
{ System.out.println("priceList edit :" + priceList);
try }
{ callPstRs(pstmt1, rs1);
System.out.println(">>>In finally errString:"+errString); }
if( errString != null && errString.trim().length()>0 ) //Modified by santosh to set priceList(14/SEP/2017).[END]
{ //Added by saurabh to get rate from DDF_PICK_MAX_RATE fuction[18/10/16|Start]
errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn); sysDate = genericUtility.getValidDateString( sysDate , getApplDateFormat() , getDBDateFormat());
} sql = "SELECT DDF_PICK_MAX_SLAB_RATE( ?, TO_DATE( ? , ? ), ? ) FROM DUAL ";
} pstmt1 = conn.prepareStatement( sql );
catch(Exception e) pstmt1.setString( 1, priceList );
{ pstmt1.setString( 2, sysDate);
e.printStackTrace(); pstmt1.setString( 3, getDBDateFormat() );
errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn); pstmt1.setString( 4, itemCode1 );
} rs1 = pstmt1.executeQuery();
if (rs1.next())
} {
return errString; rateAll = rs1.getDouble(1);
} System.out.println("rateAll-----------> [" +rateAll+ "]");
}
private double getOpeningRate(int invoiceMonthsPrevious,String orderType,String itemSerHeaderSplit,String selectedInvList ,double rcpQtyDom,String itemCode, Timestamp prdtoDateTmstmp,Timestamp prdFromoDateTmstmp, String custCode, Connection conn) throws ITMException callPstRs(pstmt1, rs1);
{ rateAll=getRequiredDcml(rateAll,3);
E12GenericUtility genericUtility =new E12GenericUtility(); //Added by saurabh to get rate from DDF_PICK_MAX_RATE fuction[18/10/16|end]
UtilMethods utlmethd = new UtilMethods(); System.out.println("rateAll>>>>>"+rateAll);
ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon(); closingValue=closingValue+formulaValue*rateAll;
String invoiceMonths="",sql=""; closingValue=getRequiredDcml(closingValue,3);
String sysDatetemp="",priceList="";
//int invoiceMonthsPrevious=0; }
Timestamp thirdMonthDay=null; /*}else
double openingRate=0.0; {
PreparedStatement pstmt = null,pstmt1 = null; calRate=getOpeningRate(invoiceMonthsPrevious,orderType,itemSerHeaderSplit,selectedInvList,rcpQtmDom,itemCode1,prdtoDateTmstmp,prdFromoDateTmstmp,custCodeDom,conn);
ResultSet rs = null,rs1 = null; calRate=getRequiredDcml(calRate,3);
String sysDate=""; closingValue=clStock*calRate;
try }*/
{ closingRate=0;
Date currentDate = new Date(); if(clStock>0)
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat()); {
sysDatetemp = sdf2.format(currentDate.getTime()); closingRate=closingValue/clStock;
}else
if(rcpQtyDom > 0) {
{ closingRate=0.0;
sql = " SELECT itrace.RATE__STDUOM as RATE__STDUOM FROM" + }
" invoice invoice,invoice_trace itrace ,item item " + closingRate=getRequiredDcml(closingRate,3);
" where invoice.invoice_id=itrace.invoice_id and itrace.item_code=item.item_code AND invoice.cust_code = ? " +
" and item.item_ser in ("+itemSerHeaderSplit+") "+ formulaValue=0;grossSecondaryQty=0;netSecondarySalesValue=0;grossSecondarySalesValue=0;salesQtyCal=0;
" AND itrace.RATE__STDUOM>0.001 "+
" and itrace.item_code = ? " + grossSecondaryQty=opStkDom+rcpQtmDom+rcpReplQtmDom+rcpFreeQtmDom-retQtyDom-clStock;
"and itrace.invoice_id in("+selectedInvList+") ORDER BY invoice.tran_date DESC " ; System.out.println("grossSecondaryQty>>>>"+grossSecondaryQty);
pstmt = conn.prepareStatement(sql); System.out.println("closingRate@@@@@@@@@"+closingRate);
pstmt.setString(1,custCode ); System.out.println("grossSecondaryQty>>>>>>"+grossSecondaryQty);
pstmt.setString(2, itemCode ); System.out.println("formulaValue>>>>>"+formulaValue);
rs = pstmt.executeQuery( ); System.out.println("opStkDom>>>"+opStkDom+">>rateOld>>>"+rateOld);
if( rs.next() ) System.out.println("rcpValue>>>"+rcpValue+">>replValue>>>"+replValue);
{ System.out.println("retValue>>>"+retValue+">>closingValue>>>"+closingValue);
openingRate = rs.getDouble("RATE__STDUOM" ); System.out.println("rcpFreeValue>>>>"+rcpFreeValue);
System.out.println("openingRate>>>>>> :"+openingRate); if(clValOld>0)
} {
callPstRs(pstmt, rs); netSecondarySalesValue=(clValOld)+rcpValue+replValue-retValue-closingValue;
} }
else else
{ {
/*invoiceMonths = dist.getDisparams("999999", "INVOICE_MONTHS", conn); netSecondarySalesValue=(opValDom)+rcpValue+replValue-retValue-closingValue;
System.out.println("invoiceMonths>>>>.." + invoiceMonths); }
if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0)) netSecondarySalesValue=getRequiredDcml(netSecondarySalesValue,3);
{ System.out.println("netSecondarySalesValue>>>>>>>"+netSecondarySalesValue);
invoiceMonthsPrevious = -3; if(clValOld>0)
} else {
{ grossSecondarySalesValue=(clValOld)+rcpValue+replValue+rcpFreeValue-retValue-closingValue;
invoiceMonthsPrevious = Integer.parseInt(invoiceMonths); }
} else
System.out.println("invoiceMonthsPrevious>>>>>" + invoiceMonthsPrevious);*/ {
thirdMonthDay = utlmethd.AddMonths(prdFromoDateTmstmp, invoiceMonthsPrevious); grossSecondarySalesValue=(opValDom)+rcpValue+replValue+rcpFreeValue-retValue-closingValue;
System.out.println("thirdMonthDay from method>>>>>>" + thirdMonthDay); }
grossSecondarySalesValue=getRequiredDcml(grossSecondarySalesValue,3);
sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,inv.tran_date " + System.out.println("grossSecondarySalesValue>>>>"+grossSecondarySalesValue);
"FROM invoice_trace itrc,invoice inv WHERE itrc.item_code=? " +
"and itrc.invoice_id=inv.invoice_id and inv.tran_date>=? " + if(grossSecondaryQty>0)
"and inv.tran_date<=? AND itrc.rate__stduom >0.001 and inv.cust_code=? " + {
" ORDER BY inv.tran_date DESC"; grossSecondaryRate = grossSecondarySalesValue / grossSecondaryQty;
pstmt = conn.prepareStatement(sql); }else
pstmt.setString(1, itemCode); {
pstmt.setTimestamp(2, thirdMonthDay); grossSecondaryRate=0.0;
pstmt.setTimestamp(3, prdtoDateTmstmp); }
pstmt.setString(4, custCode); grossSecondaryRate=getRequiredDcml(grossSecondaryRate,3);
rs = pstmt.executeQuery(); System.out.println("grossSecondaryRate>>>"+grossSecondaryRate);
if (rs.next()) salesQtyCal = opStkDom + (rcpQtmDom + rcpReplQtmDom) - (retQtyDom + retQtyFreeDom) - clStock;
{ System.out.println("salesQtyCal :" + salesQtyCal);
openingRate = rs.getDouble("rate__stduom"); if(grossSecondaryRate<0)
System.out.println("openingRate>>>>>> :" + openingRate); {
grossSecondaryRate=0;
} }
callPstRs(pstmt, rs);
if (openingRate == 0) sql =" update cust_stock_det set sales=? ,rate=? ,rate__org=? ,sales__org=? ,cl_value=? ,sales_value=? ,op_value=? where tran_id=? and item_code=? ";
{ pstmt1 = conn.prepareStatement(sql);
sql = "select price_list from customer where cust_code =? "; pstmt1.setDouble(1, salesQtyCal );//sales
pstmt1 = conn.prepareStatement(sql); pstmt1.setDouble(2, closingRate );//rate
pstmt1.setString(1, custCode); pstmt1.setDouble(3, grossSecondaryRate );//rate__org
rs1 = pstmt1.executeQuery(); pstmt1.setDouble(4, grossSecondaryQty );//sales__org
if (rs1.next()) pstmt1.setDouble(5, closingValue );//cl_value
{ pstmt1.setDouble(6, netSecondarySalesValue );//sales_value
priceList = checkNull(rs1.getString("price_list")); if(clValOld>0){
System.out.println("priceList edit :" + priceList); pstmt1.setDouble(7, getRequiredDcml((clValOld),3) );//op_value
} }
callPstRs(pstmt1, rs1); else
sysDate = genericUtility.getValidDateString( sysDatetemp , getApplDateFormat() , getDBDateFormat()); {
sql = "SELECT DDF_PICK_MAX_SLAB_RATE( ?, TO_DATE( ? , ? ), ? ) FROM DUAL "; pstmt1.setDouble(7, getRequiredDcml((opValDom),3) );//op_value
pstmt1 = conn.prepareStatement( sql ); }
pstmt1.setString( 1, priceList ); pstmt1.setString(8, tranId);
pstmt1.setString( 2, sysDate ); pstmt1.setString(9, itemCode1);
pstmt1.setString( 3, getDBDateFormat() ); UpdCnt = pstmt1.executeUpdate();
pstmt1.setString( 4, itemCode ); if(UpdCnt>0)
rs1 = pstmt1.executeQuery(); {
if (rs1.next()) System.out.println("No of record updated:"+UpdCnt+" for tranId>>"+tranId+">>>itemCode1"+itemCode1);
{ }
openingRate = rs1.getDouble(1); if (pstmt1 != null)
System.out.println("openingRate-----------> [" +openingRate+ "]"); {
} pstmt1.close();
callPstRs(pstmt1, rs1); pstmt1 = null;
} }
} }
}catch(Exception exception) }
{ callPstRs(pstmt, rs);
exception.printStackTrace();
throw new ITMException( exception ); }
} catch(Exception e)
System.out.println("return openingRate>>>>"+openingRate); {
return openingRate; e.printStackTrace();
} errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn);
public String getItemSerList(String itemser, Connection conn) //errString=e.getMessage();
{ }
String itemSerGrpValue="",itemSerSplit="",resultItemSer=""; finally
PreparedStatement pstmt = null; {
ResultSet rs = null; try
String sql = null; {
try System.out.println(">>>In finally errString:"+errString);
{ if( errString != null && errString.trim().length()>0 )
sql= " select distinct item_ser from" + {
"(select item_ser from itemser where grp_code=? " + //errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn);
"union all " + return errString;
"select item_ser from itemser where item_ser=?) "; }
}
pstmt = conn.prepareStatement(sql); catch(Exception e)
pstmt.setString(1, itemser); {
pstmt.setString(2, itemser); e.printStackTrace();
rs = pstmt.executeQuery(); errString = itmDBAccessEJB.getErrorString("", "VTICFAIL","", "", conn);
while(rs.next()) }
{
itemSerGrpValue=checkNull(rs.getString("item_ser")).trim(); }
itemSerSplit=itemSerSplit+"'"+itemSerGrpValue+"',"; return errString;
} }
callPstRs(pstmt, rs);
resultItemSer = itemSerSplit.substring(0, itemSerSplit.length() - 1); /*private double getOpeningRate(int invoiceMonthsPrevious,String orderType,String itemSerHeaderSplit,String selectedInvList ,double rcpQtyDom,String itemCode, Timestamp prdtoDateTmstmp,Timestamp prdFromoDateTmstmp, String custCode, Connection conn) throws ITMException
System.out.println("resultItemSer>>>>>"+resultItemSer); {
} E12GenericUtility genericUtility =new E12GenericUtility();
catch(Exception exception) UtilMethods utlmethd = new UtilMethods();
{ ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon();
exception.printStackTrace(); String invoiceMonths="",sql="";
try String sysDatetemp="",priceList="";
{ //int invoiceMonthsPrevious=0;
throw new ITMException( exception ); Timestamp thirdMonthDay=null;
} catch (ITMException e) double openingRate=0.0;
{ PreparedStatement pstmt = null,pstmt1 = null;
e.printStackTrace(); ResultSet rs = null,rs1 = null;
} String sysDate="";
} try
return resultItemSer; {
} Date currentDate = new Date();
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
public boolean isValidDouble(String number) throws ITMException, Exception sysDatetemp = sdf2.format(currentDate.getTime());
{
if(rcpQtyDom > 0)
Boolean isReult = true; {
double amount=0.0; sql = " SELECT itrace.RATE__STDUOM as RATE__STDUOM FROM" +
try " invoice invoice,invoice_trace itrace ,item item " +
{ " where invoice.invoice_id=itrace.invoice_id and itrace.item_code=item.item_code AND invoice.cust_code = ? " +
amount = Double.parseDouble(number); " and item.item_ser in ("+itemSerHeaderSplit+") "+
System.out.println("amount>>>>>>>>"+amount); " AND itrace.RATE__STDUOM>0.001 "+
" and itrace.item_code = ? " +
} catch (NumberFormatException e) "and itrace.invoice_id in("+selectedInvList+") ORDER BY invoice.tran_date DESC " ;
{ pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode );
isReult = false; pstmt.setString(2, itemCode );
} rs = pstmt.executeQuery( );
return isReult; if( rs.next() )
{
} openingRate = rs.getDouble("RATE__STDUOM" );
System.out.println("openingRate>>>>>> :"+openingRate);
public double getRequiredDcml(double actVal, int prec) }
{ callPstRs(pstmt, rs);
double value=0.0; }
String fmtStr = "############0"; else
if (prec > 0) {
{ invoiceMonths = dist.getDisparams("999999", "INVOICE_MONTHS", conn);
fmtStr = fmtStr + "." + "000000000".substring(0, prec); System.out.println("invoiceMonths>>>>.." + invoiceMonths);
} if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0))
DecimalFormat decFormat = new DecimalFormat(fmtStr); {
if(decFormat.format(actVal) != null && decFormat.format(actVal).trim().length() > 0 ) invoiceMonthsPrevious = -3;
{ } else
value=Double.parseDouble(decFormat.format(actVal)); {
}else invoiceMonthsPrevious = Integer.parseInt(invoiceMonths);
{ }
value=0.00; System.out.println("invoiceMonthsPrevious>>>>>" + invoiceMonthsPrevious);
} thirdMonthDay = utlmethd.AddMonths(prdFromoDateTmstmp, invoiceMonthsPrevious);
return value; System.out.println("thirdMonthDay from method>>>>>>" + thirdMonthDay);
}
sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,inv.tran_date " +
private String checkNull(String input) "FROM invoice_trace itrc,invoice inv WHERE itrc.item_code=? " +
{ "and itrc.invoice_id=inv.invoice_id and inv.tran_date>=? " +
return input == null ? "" : input.trim(); "and inv.tran_date<=? AND itrc.rate__stduom >0.001 and inv.cust_code=? " +
} " ORDER BY inv.tran_date DESC";
pstmt = conn.prepareStatement(sql);
public void callPstRs(PreparedStatement pstmt, ResultSet rs) pstmt.setString(1, itemCode);
{ pstmt.setTimestamp(2, thirdMonthDay);
try pstmt.setTimestamp(3, prdtoDateTmstmp);
{ pstmt.setString(4, custCode);
if (pstmt != null) rs = pstmt.executeQuery();
{ if (rs.next())
pstmt.close(); {
pstmt = null; openingRate = rs.getDouble("rate__stduom");
} System.out.println("openingRate>>>>>> :" + openingRate);
if (rs != null)
{ }
rs.close(); callPstRs(pstmt, rs);
rs = null; if (openingRate == 0)
} {
} sql = "select price_list from customer where cust_code =? ";
catch (Exception e) pstmt1 = conn.prepareStatement(sql);
{ pstmt1.setString(1, custCode);
e.printStackTrace(); rs1 = pstmt1.executeQuery();
} if (rs1.next())
} {
} priceList = checkNull(rs1.getString("price_list"));
System.out.println("priceList edit :" + priceList);
}
callPstRs(pstmt1, rs1);
sysDate = genericUtility.getValidDateString( sysDatetemp , getApplDateFormat() , getDBDateFormat());
sql = "SELECT DDF_PICK_MAX_SLAB_RATE( ?, TO_DATE( ? , ? ), ? ) FROM DUAL ";
pstmt1 = conn.prepareStatement( sql );
pstmt1.setString( 1, priceList );
pstmt1.setString( 2, sysDate );
pstmt1.setString( 3, getDBDateFormat() );
pstmt1.setString( 4, itemCode );
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
openingRate = rs1.getDouble(1);
System.out.println("openingRate-----------> [" +openingRate+ "]");
}
callPstRs(pstmt1, rs1);
}
}
}catch(Exception exception)
{
exception.printStackTrace();
throw new ITMException( exception );
}
System.out.println("return openingRate>>>>"+openingRate);
return openingRate;
}*/
public String getItemSerList(String itemser, Connection conn)
{
String itemSerGrpValue="",itemSerSplit="",resultItemSer="";
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
try
{
sql= " select distinct item_ser from" +
"(select item_ser from itemser where grp_code=? " +
"union all " +
"select item_ser from itemser where item_ser=?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemser);
pstmt.setString(2, itemser);
rs = pstmt.executeQuery();
while(rs.next())
{
itemSerGrpValue=checkNull(rs.getString("item_ser")).trim();
itemSerSplit=itemSerSplit+"'"+itemSerGrpValue+"',";
}
callPstRs(pstmt, rs);
resultItemSer = itemSerSplit.substring(0, itemSerSplit.length() - 1);
System.out.println("resultItemSer>>>>>"+resultItemSer);
}
catch(Exception exception)
{
exception.printStackTrace();
try
{
throw new ITMException( exception );
} catch (ITMException e)
{
e.printStackTrace();
}
}
return resultItemSer;
}
public boolean isValidDouble(String number) throws ITMException, Exception
{
Boolean isReult = true;
double amount=0.0;
try
{
amount = Double.parseDouble(number);
System.out.println("amount>>>>>>>>"+amount);
} catch (NumberFormatException e)
{
isReult = false;
}
return isReult;
}
public double getRequiredDcml(double actVal, int prec)
{
double value=0.0;
String fmtStr = "############0";
if (prec > 0)
{
fmtStr = fmtStr + "." + "000000000".substring(0, prec);
}
DecimalFormat decFormat = new DecimalFormat(fmtStr);
if(decFormat.format(actVal) != null && decFormat.format(actVal).trim().length() > 0 )
{
value=Double.parseDouble(decFormat.format(actVal));
}else
{
value=0.00;
}
return value;
}
private String checkNull(String input)
{
return input == null ? "" : input.trim();
}
public void callPstRs(PreparedStatement pstmt, ResultSet rs)
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal; import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.sql.Connection; import java.sql.Connection;
import javax.ejb.Local; import javax.ejb.Local;
@Local @Local
public interface CustStockGWTPostSaveLocal extends ValidatorLocal { public interface CustStockGWTPostSaveLocal extends ValidatorLocal {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException; public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
} }
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote; import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.sql.Connection; import java.sql.Connection;
import javax.ejb.Remote; import javax.ejb.Remote;
@Remote @Remote
public interface CustStockGWTPostSaveRemote extends ValidatorRemote { public interface CustStockGWTPostSaveRemote extends ValidatorRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException; public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
} }
/******************************************************** /********************************************************
Title : CustStockGWTWizIC[D15ESUN013] Title : CustStockGWTWizIC[D15ESUN013]
Date : 09/03/16 Date : 09/03/16
Developer: Chandrashekar Developer: Chandrashekar
********************************************************/ ********************************************************/
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import javax.ejb.Stateless; import javax.ejb.Stateless;
@Stateless @Stateless
public class CustStockGWTWizIC extends ValidatorEJB implements CustStockGWTWizICLocal,CustStockGWTWizICRemote //implements SessionBean public class CustStockGWTWizIC extends ValidatorEJB implements CustStockGWTWizICLocal,CustStockGWTWizICRemote //implements SessionBean
{ {
E12GenericUtility genericUtility= new E12GenericUtility(); E12GenericUtility genericUtility= new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{ {
String errString = ""; String errString = "";
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
try try
{ {
if (xmlString != null && xmlString.trim().length() > 0 ) if (xmlString != null && xmlString.trim().length() > 0 )
{ {
dom = parseString(xmlString); dom = parseString(xmlString);
System.out.println("xmlString["+xmlString+"]"); System.out.println("xmlString["+xmlString+"]");
} }
if (xmlString1 != null && xmlString1.trim().length() > 0 ) if (xmlString1 != null && xmlString1.trim().length() > 0 )
{ {
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
System.out.println("xmlString1["+xmlString1+"]"); System.out.println("xmlString1["+xmlString1+"]");
} }
if (xmlString2 != null && xmlString2.trim().length() > 0 ) if (xmlString2 != null && xmlString2.trim().length() > 0 )
{ {
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
System.out.println("xmlString2["+xmlString2+"]"); System.out.println("xmlString2["+xmlString2+"]");
} }
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams); errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception : [CustStockGWTWizIC][wfValData( String, String )] :==>\n" + e.getMessage()); System.out.println("Exception : [CustStockGWTWizIC][wfValData( String, String )] :==>\n" + e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
return(errString); return(errString);
} }
public String wfValData(Document dom, Document dom1, Document dom2, 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
{ {
String childNodeName = null; String childNodeName = null;
String errString = ""; String errString = "";
String errCode = ""; String errCode = "";
String userId = "",lineNo="",sales=""; String userId = "",lineNo="",sales="";
String errorType = ""; String errorType = "";
String itemCode=""; String itemCode="";
int cnt = 0; int cnt = 0;
int ctr=0; int ctr=0;
int childNodeListLength; int childNodeListLength;
double secSales=0.0; double secSales=0.0;
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
ArrayList<String> errList = new ArrayList<String>(); ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null ; PreparedStatement pstmt = null ;
ResultSet rs = null; ResultSet rs = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
int currentFormNo =0; int currentFormNo =0;
SimpleDateFormat dateFormat2 = null; SimpleDateFormat dateFormat2 = null;
String dummyProduct=""; String dummyProduct="";
ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon(); ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon();
try try
{ dateFormat2 = new SimpleDateFormat(genericUtility.getApplDateFormat()); { dateFormat2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("@@@@@@@@ wfvaldata called"); System.out.println("@@@@@@@@ wfvaldata called");
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver = null; connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
if(objContext != null && objContext.trim().length()>0) if(objContext != null && objContext.trim().length()>0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
System.out.println("currentFormNo>>>>>"+currentFormNo); System.out.println("currentFormNo>>>>>"+currentFormNo);
switch(currentFormNo) switch(currentFormNo)
{ {
case 3: case 3:
System.out.println("Case 3::::::dom2 >>>>"+genericUtility.serializeDom(dom2)); System.out.println("Case 3::::::dom2 >>>>"+genericUtility.serializeDom(dom2));
parentNodeList = dom2.getElementsByTagName("Detail3"); parentNodeList = dom2.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) for(ctr = 0; ctr < childNodeListLength; ctr++)
{ {
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
//Added by saurabh[04/01/17] //Added by saurabh[04/01/17]
if(childNodeName.equals("attribute")) if(childNodeName.equals("attribute"))
{ {
String updateFlag = ""; String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue(); updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
System.out.println("updateFlag>>>"+updateFlag); System.out.println("updateFlag>>>"+updateFlag);
if ("D".equalsIgnoreCase(updateFlag)) if ("D".equalsIgnoreCase(updateFlag))
{ {
System.out.println("Break from here as the record is deleted"); System.out.println("Break from here as the record is deleted");
break; break;
} }
} }
//Added by saurabh[04/01/17] //Added by saurabh[04/01/17]
if (childNodeName.equalsIgnoreCase("item_code")) if (childNodeName.equalsIgnoreCase("item_code"))
{ {
itemCode = this.genericUtility.getColumnValue("item_code", dom); itemCode = this.genericUtility.getColumnValue("item_code", dom);
lineNo = this.genericUtility.getColumnValue("line_no", dom); lineNo = this.genericUtility.getColumnValue("line_no", dom);
System.out.println("itemCode>>>>>>" + itemCode); System.out.println("itemCode>>>>>>" + itemCode);
if (itemCode == null || itemCode.trim().length() == 0) if (itemCode == null || itemCode.trim().length() == 0)
{ {
System.out.println("Error : No data found in item details"); System.out.println("Error : No data found in item details");
errCode = "VTEMTITM"; errCode = "VTEMTITM";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
else else
{ {
errCode = isExist("item", "item_code", itemCode, conn); errCode = isExist("item", "item_code", itemCode, conn);
if ("FALSE".equalsIgnoreCase(errCode)) if ("FALSE".equalsIgnoreCase(errCode))
{ {
errCode = "VMITMNOTEX"; errCode = "VMITMNOTEX";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
}else }else
{ {
dummyProduct = dist.getDisparams("999999","DUMMY_PRODUCT",conn); dummyProduct = dist.getDisparams("999999","DUMMY_PRODUCT",conn);
if (("NULLFOUND".equalsIgnoreCase(dummyProduct) || dummyProduct == null || dummyProduct.trim().length() == 0) ) if (("NULLFOUND".equalsIgnoreCase(dummyProduct) || dummyProduct == null || dummyProduct.trim().length() == 0) )
{ {
System.out.println("Disparm not defined for dummy item!!!!"); System.out.println("Disparm not defined for dummy item!!!!");
if("FALSE".equalsIgnoreCase(isFrequent(itemCode,conn))) if("FALSE".equalsIgnoreCase(isFrequent(itemCode,conn)))
{ {
errCode = "VMFRITMCHK"; errCode = "VMFRITMCHK";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
else else
{ {
if(!dummyProduct.trim().equalsIgnoreCase(itemCode.trim())){ if(!dummyProduct.trim().equalsIgnoreCase(itemCode.trim())){
if("FALSE".equalsIgnoreCase(isFrequent(itemCode,conn))) if("FALSE".equalsIgnoreCase(isFrequent(itemCode,conn)))
{ {
errCode = "VMFRITMCHK"; errCode = "VMFRITMCHK";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
} }
if (isDulplicateFrmDom(dom2,itemCode,lineNo)) if (isDulplicateFrmDom(dom2,itemCode,lineNo))
{ {
errCode = "VTDUPITMCD"; errCode = "VTDUPITMCD";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
} }
} }
/*if (childNodeName.equalsIgnoreCase("sales")) /*if (childNodeName.equalsIgnoreCase("sales"))
{ {
sales = this.genericUtility.getColumnValue("sales", dom); sales = this.genericUtility.getColumnValue("sales", dom);
if(sales != null && sales.trim().length()>0) if(sales != null && sales.trim().length()>0)
{ {
secSales = Double.parseDouble(sales); secSales = Double.parseDouble(sales);
} }
else else
{ {
secSales = 0.0; secSales = 0.0;
} }
if(secSales < 0) if(secSales < 0)
{ {
errCode = "VTSALNEG"; errCode = "VTSALNEG";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
System.out.println("Secondary sales is negitive"); System.out.println("Secondary sales is negitive");
} }
}*/ }*/
}// end for }// end for
break; // case 1 end break; // case 1 end
} }
int errListSize = errList.size(); int errListSize = errList.size();
cnt = 0; cnt = 0;
String errFldName = null; String errFldName = null;
if(errList != null && errListSize > 0) if(errList != null && errListSize > 0)
{ {
for(cnt = 0; cnt < errListSize; cnt ++) for(cnt = 0; cnt < errListSize; cnt ++)
{ {
errCode = errList.get(cnt); errCode = errList.get(cnt);
errFldName = errFields.get(cnt); errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode); System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId); errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode); errorType = errorType(conn , errCode);
if(errString.length() > 0) if(errString.length() > 0)
{ {
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>")); String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>")); bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); errStringXml.append(bifurErrString);
errString = ""; errString = "";
} }
if(errorType.equalsIgnoreCase("E")) if(errorType.equalsIgnoreCase("E"))
{ {
break; break;
} }
} }
errList.clear(); errList.clear();
errList = null; errList = null;
errFields.clear(); errFields.clear();
errFields = null; errFields = null;
errStringXml.append("</Errors> </Root> \r\n"); errStringXml.append("</Errors> </Root> \r\n");
} }
else else
{ {
errStringXml = new StringBuffer(""); errStringXml = new StringBuffer("");
} }
} }
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
{ {
try try
{ {
if(conn != null) if(conn != null)
{ {
if(rs != null) if(rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if(pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
conn.close(); conn.close();
} }
conn = null; conn = null;
} }
catch(Exception d) catch(Exception d)
{ {
d.printStackTrace(); d.printStackTrace();
throw new ITMException(d); throw new ITMException(d);
} }
} }
errString = errStringXml.toString(); errString = errStringXml.toString();
return errString; return errString;
} }
//end of validation //end of validation
private String checkNull(String input) private String checkNull(String input)
{ {
if(input == null) if(input == null)
{ {
input = ""; input = "";
} }
return input; return input;
} }
private String errorType(Connection conn , String errorCode) throws ITMException private String errorType(Connection conn , String errorCode) throws ITMException
{ {
String msgType = ""; String msgType = "";
PreparedStatement pstmt = null ; PreparedStatement pstmt = null ;
ResultSet rs = null; ResultSet rs = null;
try try
{ {
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?"; String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode); pstmt.setString(1,errorCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
msgType = rs.getString("MSG_TYPE"); msgType = rs.getString("MSG_TYPE");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
catch(Exception ex) catch(Exception ex)
{ {
ex.printStackTrace(); ex.printStackTrace();
throw new ITMException(ex); throw new ITMException(ex);
} }
finally finally
{ {
try try
{ {
if(rs != null) if(rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if(pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
return msgType; return msgType;
} }
private String isExist(String table, String field, String value,Connection conn) throws SQLException private String isExist(String table, String field, String value,Connection conn) throws SQLException
{ {
String sql = "",retStr=""; String sql = "",retStr="";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null ;
int cnt=0; int cnt=0;
sql = " SELECT COUNT(1) FROM "+ table + " WHERE " + field + " = ? "; sql = " SELECT COUNT(1) FROM "+ table + " WHERE " + field + " = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value); pstmt.setString(1,value);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if( cnt > 0) if( cnt > 0)
{ {
retStr = "TRUE"; retStr = "TRUE";
} }
if( cnt == 0 ) if( cnt == 0 )
{ {
retStr = "FALSE"; retStr = "FALSE";
} }
System.out.println("@@@@ isexist["+value+"]:::["+retStr+"]:::["+cnt+"]"); System.out.println("@@@@ isexist["+value+"]:::["+retStr+"]:::["+cnt+"]");
return retStr; return retStr;
} }
private boolean isDulplicateFrmDom(Document dom,String itemCode, String lineNo) throws ITMException private boolean isDulplicateFrmDom(Document dom,String itemCode, String lineNo) throws ITMException
{ {
NodeList parentList = null; NodeList parentList = null;
NodeList childList = null; NodeList childList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
String lineNoDom = ""; String lineNoDom = "";
boolean isDulplicate = false; boolean isDulplicate = false;
String itemCodeDom= ""; String itemCodeDom= "";
System.out.println("---inside isDulplicateFrmDom--"); System.out.println("---inside isDulplicateFrmDom--");
try try
{ {
parentList = dom.getElementsByTagName("Detail3"); parentList = dom.getElementsByTagName("Detail3");
int parentNodeListLength = parentList.getLength(); int parentNodeListLength = parentList.getLength();
//System.out.println("parentNodeListLength>>>>>>>"+parentNodeListLength); //System.out.println("parentNodeListLength>>>>>>>"+parentNodeListLength);
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr-- ) for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr-- )
{ {
parentNode = parentList.item(prntCtr-1); parentNode = parentList.item(prntCtr-1);
childList = parentNode.getChildNodes(); childList = parentNode.getChildNodes();
//System.out.println("childList length>>>"+childList.getLength()); //System.out.println("childList length>>>"+childList.getLength());
for (int ctr = childList.getLength(); ctr >= 0; ctr--) for (int ctr = childList.getLength(); ctr >= 0; ctr--)
//for (int ctr = 0; ctr < childList.getLength(); ctr++) //for (int ctr = 0; ctr < childList.getLength(); ctr++)
{ {
childNode = childList.item(ctr); childNode = childList.item(ctr);
//System.out.println("childNode>>>"+childNode); //System.out.println("childNode>>>"+childNode);
if(childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute")) if(childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute"))
{ {
String updateFlag = ""; String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue(); updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
if (updateFlag.equalsIgnoreCase("D")) if (updateFlag.equalsIgnoreCase("D"))
{ {
System.out.println("Break from here as the record is deleted"); System.out.println("Break from here as the record is deleted");
break; break;
} }
} }
if ( childNode != null && childNode.getFirstChild() != null && if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("line_no") ) childNode.getNodeName().equalsIgnoreCase("line_no") )
{ {
lineNoDom = childNode.getFirstChild().getNodeValue().trim(); lineNoDom = childNode.getFirstChild().getNodeValue().trim();
System.out.println("lineNo["+lineNo.trim()+"]lineNoDom["+lineNoDom+"]"); System.out.println("lineNo["+lineNo.trim()+"]lineNoDom["+lineNoDom+"]");
if (lineNo.trim().equalsIgnoreCase(lineNoDom)) if (lineNo.trim().equalsIgnoreCase(lineNoDom))
{ {
System.out.println("Break from here as line No match"); System.out.println("Break from here as line No match");
break; break;
} }
} }
if ( childNode != null && childNode.getFirstChild() != null && if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("item_code") ) childNode.getNodeName().equalsIgnoreCase("item_code") )
{ {
itemCodeDom = childNode.getFirstChild().getNodeValue().trim(); itemCodeDom = childNode.getFirstChild().getNodeValue().trim();
} }
//System.out.println("itemCodeDom loop"+itemCodeDom); //System.out.println("itemCodeDom loop"+itemCodeDom);
} }
System.out.println("itemCodeDom>>>>"+itemCodeDom+"@@@@@@itemCode>>>"+itemCode); System.out.println("itemCodeDom>>>>"+itemCodeDom+"@@@@@@itemCode>>>"+itemCode);
if (itemCode.trim().equalsIgnoreCase(itemCodeDom.trim())) if (itemCode.trim().equalsIgnoreCase(itemCodeDom.trim()))
{ {
isDulplicate = true; isDulplicate = true;
break; break;
} }
}//for loop }//for loop
}catch(Exception e) }catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
finally finally
{ {
try try
{ {
} }
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
System.out.println("isDulplicate>>>>>> ["+isDulplicate+"]"); System.out.println("isDulplicate>>>>>> ["+isDulplicate+"]");
return isDulplicate; return isDulplicate;
} }
//Commented by saurabh 040117 //Commented by saurabh 040117
private String isFrequent( String itemCode,Connection conn) throws SQLException private String isFrequent( String itemCode,Connection conn) throws SQLException
{ {
String sql = "",retStr=""; String sql = "",retStr="";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null ;
int cnt=0; int cnt=0;
sql = " SELECT COUNT(1) FROM item WHERE item_code = ? and item_usage='F' ";//Added by saurabh[22/12/16] sql = " SELECT COUNT(1) FROM item WHERE item_code = ? and item_usage='F' ";//Added by saurabh[22/12/16]
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode); pstmt.setString(1,itemCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if( cnt > 0) if( cnt > 0)
{ {
retStr = "TRUE"; retStr = "TRUE";
} }
if( cnt == 0 ) if( cnt == 0 )
{ {
retStr = "FALSE"; retStr = "FALSE";
} }
System.out.println("@@@@ isexist["+itemCode+"]:::["+retStr+"]:::["+cnt+"]"); System.out.println("@@@@ isexist["+itemCode+"]:::["+retStr+"]:::["+cnt+"]");
return retStr; return retStr;
} }
//Commented by saurabh 040117 //Commented by saurabh 040117
} }
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import java.rmi.RemoteException; import java.rmi.RemoteException;
//import javax.ejb.EJBObject; //import javax.ejb.EJBObject;
import org.w3c.dom.*; import org.w3c.dom.*;
import javax.xml.parsers.*; import javax.xml.parsers.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import javax.ejb.Local; //added for ejb3 import javax.ejb.Local; //added for ejb3
@Local // added for ejb3 @Local // added for ejb3
public interface CustStockGWTWizICLocal extends ValidatorLocal//, EJBObject public interface CustStockGWTWizICLocal extends ValidatorLocal//, EJBObject
{ {
public String wfValData() throws RemoteException,ITMException; public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
} }
\ No newline at end of file
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import java.rmi.RemoteException; import java.rmi.RemoteException;
//import javax.ejb.EJBObject; //import javax.ejb.EJBObject;
import org.w3c.dom.*; import org.w3c.dom.*;
import javax.xml.parsers.*; import javax.xml.parsers.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3 import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3 @Remote // added for ejb3
public interface CustStockGWTWizICRemote extends ValidatorRemote//, EJBObject public interface CustStockGWTWizICRemote extends ValidatorRemote//, EJBObject
{ {
public String wfValData() throws RemoteException,ITMException; public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException; public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException; public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
} }
\ No newline at end of file
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import javax.ejb.Stateless; import javax.ejb.Stateless;
...@@ -23,7 +23,7 @@ import org.w3c.dom.NodeList; ...@@ -23,7 +23,7 @@ import org.w3c.dom.NodeList;
@Stateless @Stateless
public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDataICLocal { public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDataICLocal {
GenericUtility genericUtility = GenericUtility.getInstance(); E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String editFlag,String xtraParams) throws RemoteException public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String editFlag,String xtraParams) throws RemoteException
{ {
...@@ -61,14 +61,11 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -61,14 +61,11 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
public String validate(Document currDom, Document hdrDom, Document allDom,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException public String validate(Document currDom, Document hdrDom, Document allDom,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{ {
System.out.println("In validate Data"); System.out.println("In validate Data");
GenericUtility genericUtility = GenericUtility.getInstance();
ArrayList<String> errList = new ArrayList<String>(); ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>();
ArrayList<String> errCustList = new ArrayList<String>();
int count = 0; int count = 0;
String errString = ""; String errString = "", errorType = "", errCode = "",custCode="";
String errorType = "";
String errCode = "";
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String childNodeName = ""; String childNodeName = "";
String sql = ""; String sql = "";
...@@ -80,8 +77,12 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -80,8 +77,12 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
int cnt = 0; int cnt = 0;
ConnDriver connDriver = null; ConnDriver connDriver = null;
Node childNode = null; Node childNode = null;
String table_no="",prd_code=""; String itemSer="",prdCode="",fromDateDom="",toDateDom="";
java.sql.Timestamp toDate=null,fromDate=null;
ArrayList<String> custArray=null;
int divCount=0;
try { try {
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("************xtraParams*************" + xtraParams); System.out.println("************xtraParams*************" + xtraParams);
connDriver = new ConnDriver(); connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
...@@ -116,20 +117,20 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -116,20 +117,20 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
System.out.println("childList = " + childList); System.out.println("childList = " + childList);
if ("prd_code".equalsIgnoreCase(childNodeName) ) if ("prd_code".equalsIgnoreCase(childNodeName) )
{ {
prd_code = checkNull(genericUtility.getColumnValue("prd_code", currDom)); prdCode = checkNull(genericUtility.getColumnValue("prd_code", currDom));
if(prd_code==null || prd_code.trim().length()==0) if(prdCode==null || prdCode.trim().length()==0)
{ {
errList.add("VTNULLPC");//Invalid-Division can not be blank errList.add("VTNULLPC");//Invalid-Division can not be blank
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
break; break;
} }
} }
if ("table_no".equalsIgnoreCase(childNodeName) ) if ("item_ser".equalsIgnoreCase(childNodeName) )
{ {
table_no = checkNull(genericUtility.getColumnValue("table_no", currDom)); itemSer = checkNull(genericUtility.getColumnValue("item_ser", currDom));
prd_code = checkNull(genericUtility.getColumnValue("prd_code", currDom)); prdCode = checkNull(genericUtility.getColumnValue("prd_code", currDom));
if(table_no==null || table_no.trim().length()==0) if(itemSer==null || itemSer.trim().length()==0)
{ {
errList.add("VTNULLDV");//Invalid-Division can not be blank errList.add("VTNULLDV");//Invalid-Division can not be blank
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
...@@ -139,8 +140,8 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -139,8 +140,8 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
{ {
sql = "SELECT COUNT(*) AS COUNT FROM CUST_STOCK WHERE item_ser = ? and prd_code=? and pos_code is not null "; sql = "SELECT COUNT(*) AS COUNT FROM CUST_STOCK WHERE item_ser = ? and prd_code=? and pos_code is not null ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, table_no); pstmt.setString(1, itemSer);
pstmt.setString(2, prd_code); pstmt.setString(2, prdCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
...@@ -155,6 +156,157 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -155,6 +156,157 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
} }
} }
} }
if ("from_date".equalsIgnoreCase(childNodeName) )
{
fromDateDom = checkNull(genericUtility.getColumnValue("from_date", currDom));
if(fromDateDom==null || fromDateDom.trim().length()==0)
{
errList.add("VPBLKFRDT");
errFields.add(childNodeName.toLowerCase());
break;
}
}
if ("to_date".equalsIgnoreCase(childNodeName) )
{
fromDateDom = checkNull(genericUtility.getColumnValue("from_date", currDom));
toDateDom = checkNull(genericUtility.getColumnValue("to_date", currDom));
if(toDateDom==null || toDateDom.trim().length()==0)
{
errList.add("VPBLKTODT");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
fromDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(fromDateDom, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
toDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(toDateDom, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("fromDate>>>>"+fromDate+"toDate::::"+toDate);
if(toDate.before(fromDate))
{
errList.add("INVTODT");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
if ("cust_code".equalsIgnoreCase(childNodeName) )
{
itemSer = checkNull(genericUtility.getColumnValue("item_ser", currDom));
prdCode = checkNull(genericUtility.getColumnValue("prd_code", currDom));
custCode = checkNull(genericUtility.getColumnValue("cust_code", currDom));
fromDateDom = checkNull(genericUtility.getColumnValue("from_date", currDom));
toDateDom = checkNull(genericUtility.getColumnValue("to_date", currDom));
fromDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(fromDateDom, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
toDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(toDateDom, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(custCode==null || custCode.trim().length()==0)
{
errList.add("VPBLKCUSCD");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
if (!custCode.matches("[A-Za-z0-9, ]*"))
{
errList.add("VPINVCCDS");
errFields.add(childNodeName.toLowerCase());
break;
}
if(custCode.contains(","))
{
custArray= new ArrayList<String>(Arrays.asList(custCode.split(",")));
for (int i=0;i<custArray.size();i++)
{
sql = "SELECT COUNT(*) AS COUNT FROM CUSTOMER WHERE CUST_CODE=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custArray.get(i));
rs = pstmt.executeQuery();
if (rs.next())
{
divCount = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("divCount: " + divCount);
if (divCount == 0)
{
errCustList.add(custArray.get(i));
errList.add("VPINVCSCDM");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM CUST_STOCK WHERE CUST_CODE=? AND PRD_CODE=? AND ITEM_SER=? AND TRAN_DATE BETWEEN ? AND ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custArray.get(i));
pstmt.setString(2, prdCode);
pstmt.setString(3, itemSer);
pstmt.setTimestamp(4, fromDate);
pstmt.setTimestamp(5, toDate);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("Count: " + count);
if (count == 0)
{
errCustList.add(custArray.get(i));
errList.add("VPINVCSCD");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM CUSTOMER WHERE CUST_CODE=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
divCount = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("divCount: " + divCount);
if (divCount == 0)
{
errCustList.add(custCode);
errList.add("VPINVCSCDM");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM CUST_STOCK WHERE CUST_CODE=? AND PRD_CODE=? AND ITEM_SER=? AND TRAN_DATE BETWEEN ? AND ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, itemSer);
pstmt.setTimestamp(4, fromDate);
pstmt.setTimestamp(5, toDate);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("Count: " + count);
if (count == 0)
{
errCustList.add(custCode);
errList.add("VPINVCSCD");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
}
} }
} }
...@@ -172,6 +324,19 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -172,6 +324,19 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
errFldName = (String) errFields.get(cnt); errFldName = (String) errFields.get(cnt);
errString = getErrorString(errFldName, errCode, userId); errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode); errorType = errorType(conn, errCode);
if(errCustList.size()>0 && errString.length() > 0 )
{
String begPart = errString.substring( 0, errString.indexOf("]]></description>") );
String mainStr="";
for(int i=0;i<errCustList.size();i++)
{
mainStr=mainStr+ errCustList.get(i)+",";
}
String endPart=errString.substring( errString.indexOf("]]></description>"), errString.length() );
mainStr=" Following customers are invalid :: "+mainStr.substring(0,mainStr.length()-1);
errString = begPart+mainStr + endPart;
}
if (errString.length() > 0) if (errString.length() > 0)
{ {
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>")); String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
...@@ -189,13 +354,10 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -189,13 +354,10 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
errList = null; errList = null;
errFields.clear(); errFields.clear();
errFields = null; errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer("");
} }
errStringXml.append("</Errors></Root>\r\n");
errString = errStringXml.toString(); errString = errStringXml.toString();
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -235,7 +397,6 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -235,7 +397,6 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
Document hdrDom = null; Document hdrDom = null;
Document allDom = null; Document allDom = null;
String errString = null; String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try try
{ {
if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0)) if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0))
...@@ -270,8 +431,7 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -270,8 +431,7 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
String childNodeName = null; String childNodeName = null;
Connection conn = null; Connection conn = null;
StringBuffer valueXmlString = new StringBuffer(); StringBuffer valueXmlString = new StringBuffer();
Date sysdate=null; String fromDateDom="";
String asOnDate="";
try try
{ {
try { try {
...@@ -285,7 +445,6 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -285,7 +445,6 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDispDateFormat());
if ((objContext != null) && (objContext.trim().length() > 0)) if ((objContext != null) && (objContext.trim().length() > 0))
{ {
...@@ -315,18 +474,22 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat ...@@ -315,18 +474,22 @@ public class Es3HDataIC extends ValidatorEJB implements Es3HDataICRemote,Es3HDat
if (currentColumn.equalsIgnoreCase("itm_default")) if (currentColumn.equalsIgnoreCase("itm_default"))
{ {
/*String sql="select sysdate from dual"; valueXmlString.append("<prd_code>").append("<![CDATA[]]>").append("</prd_code>\r\n");
PreparedStatement pstmt = conn.prepareStatement(sql); valueXmlString.append("<item_ser>").append("<![CDATA[]]>").append("</item_ser>\r\n");
ResultSet rs = pstmt.executeQuery(); valueXmlString.append("<from_date>").append("").append("</from_date>\r\n");
if (rs.next()) valueXmlString.append("<to_date>").append("").append("</to_date>\r\n");
valueXmlString.append("<cust_code>").append("<![CDATA[]]>").append("</cust_code>\r\n");
}
else if(currentColumn.equalsIgnoreCase("from_date"))
{
fromDateDom = checkNull(genericUtility.getColumnValue("from_date", currDom));
if(fromDateDom!=null && fromDateDom.trim().length()>0){
valueXmlString.append("<to_date>").append(fromDateDom).append("</to_date>\r\n");
}
else
{ {
sysdate = rs.getDate(1); valueXmlString.append("<to_date>").append("").append("</to_date>\r\n");
} }
callPstRs(pstmt,rs);
asOnDate=sdf.format(sysdate).toString();
valueXmlString.append("<chg_date>").append(asOnDate).append("</chg_date>\r\n");*/
valueXmlString.append("<table_no>").append("").append("</table_no>\r\n");
valueXmlString.append("<prd_code>").append("").append("</prd_code>\r\n");
} }
valueXmlString.append("</Detail1>\r\n"); valueXmlString.append("</Detail1>\r\n");
......
...@@ -14,9 +14,6 @@ import java.sql.ResultSet; ...@@ -14,9 +14,6 @@ import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
...@@ -31,10 +28,6 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -31,10 +28,6 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
Connection conn = null; Connection conn = null;
String loginCode = null;
StringBuffer retBuf = null;
String errorString = null;
public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException
{ {
...@@ -80,8 +73,8 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -80,8 +73,8 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
Node childNode = null; Node childNode = null;
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null, pstmt3 = null; PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null, pstmt3 = null;
ResultSet rs = null, rs1 = null, rs2 = null, rs3 = null; ResultSet rs = null, rs1 = null, rs2 = null, rs3 = null;
String sql = "", tranId = "", itemCode = "", invoiceId = "", dlvFlag = ""; String sql = "", tranId = "", itemCode = "", invoiceId = "", dlvFlag = "",fromDateStr="",custCodeDom="",toDateStr="";
int sreturnCnt = 0; //int sreturnCnt = 0;
double retQty = 0, retRate = 0,retDiscnt=0,totalRetVal=0; double retQty = 0, retRate = 0,retDiscnt=0,totalRetVal=0;
double recptRetQty = 0, recptRetVal = 0; double recptRetQty = 0, recptRetVal = 0;
double recptReplQty = 0, recptReplVal = 0; double recptReplQty = 0, recptReplVal = 0;
...@@ -94,30 +87,32 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -94,30 +87,32 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
double FreeQty = 0, freeValue = 0; double FreeQty = 0, freeValue = 0;
double recptFreeQty = 0, recptFreeValue = 0; double recptFreeQty = 0, recptFreeValue = 0;
double transitFreeQty = 0, transitFreeValue = 0; double transitFreeQty = 0, transitFreeValue = 0;
String lineType = ""; String lineType = "",calEnablePrice="",calPriceDivision="",checkItemSer="";
double billRetQtyBonusQty = 0, billRetQtyBonusVal = 0,replNetVal=0,totalInvAmt=0,netAmtRet=0,netAmtRep=0; double billRetQtyBonusQty = 0, billRetQtyBonusVal = 0,totalInvAmt=0,netAmtRet=0,netAmtRep=0;//,replNetVal=0;
Timestamp prdFromoDateTmstmp = null, prdtoDateTmstmp = null; Timestamp prdFromoDateTmstmp = null, prdtoDateTmstmp = null;
String custCode = ""; String custCode = "";
double rateStd = 0, quantityStd = 0, formulaValue = 0, closingValue = 0,retQtyFreeDom=0; double rateStd = 0, quantityStd = 0, formulaValue = 0, closingValue = 0,retQtyFreeDom=0;
String priceList = "",tranIdLast=""; String priceList = "",tranIdLast="";
String sysDate = ""; //String sysDate = "";
String invoiceMonths = "",table_no="",prd_code="",invoiceIdList="",selectedInvList=""; String invoiceMonths = "",itemSer="",prdCode="";//,invoiceIdList="",selectedInvList="";
int invoiceMonthsPrevious = 0,retCnt=0,chkCnt=0; int invoiceMonthsPrevious = 0,retCnt=0,chkCnt=0;
Timestamp thirdMonthDay = null; Timestamp thirdMonthDay = null;
Date currentDate = new Date(); //Date currentDate = new Date();
String calCriItemSerStr="", refSer = ""; String refSer = "";// ,calCriItemSerStr="";
double priceListRate = 0, clStock = 0,opStkDom=0,grossSecondaryQty=0,netSecondarySalesValue=0,grossSecondarySalesValue=0; double priceListRate = 0, clStock = 0,opStkDom=0,grossSecondaryQty=0,netSecondarySalesValue=0,grossSecondarySalesValue=0;
double closingRate = 0,UpdCnt=0,grossSecondaryRate=0,salesQtyCal=0,rcpQtmDom=0; double closingRate = 0,UpdCnt=0,grossSecondaryRate=0,salesQtyCal=0;//,rcpQtmDom=0;
double clStockLast=0.0,rateOld=0.0,rateOrgOld=0.0,opValue=0.0,calRate=0.0; double clStockLast=0.0,rateOld=0.0,rateOrgOld=0.0,opValue=0.0;//,calRate=0.0;
boolean isItemSerLocal=false,isItemFound=false; boolean isItemFound=false;//,isItemSerLocal=false;
ArrayList<String> calCriItemSerList=null; //ArrayList<String> calCriItemSerList=null;
ClosingStockBean closingStockBean=null; ClosingStockBean closingStockBean=null;
HashMap<String,ClosingStockBean> closingStockMap=null; HashMap<String,ClosingStockBean> closingStockMap=null;
UtilMethods utlmethd = new UtilMethods(); UtilMethods utlmethd = new UtilMethods();
ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon(); ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon();
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode"); String loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
String chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
HashSet<String> invoiceItemSet=null; HashSet<String> invoiceItemSet=null;
String invoiceItemKey=""; String invoiceItemKey="";
Timestamp fromDate=null,toDate=null;
try { try {
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
...@@ -128,7 +123,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -128,7 +123,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
} }
try { try {
calCriItemSerStr = dist.getDisparams("999999","CAL_CRIT_ITEMSER",conn); /*calCriItemSerStr = dist.getDisparams("999999","CAL_CRIT_ITEMSER",conn);
System.out.println("calCriItemSerStr.." + calCriItemSerStr); System.out.println("calCriItemSerStr.." + calCriItemSerStr);
System.out.println("isItemSer@@@@@@@before>>>>"+isItemSerLocal); System.out.println("isItemSer@@@@@@@before>>>>"+isItemSerLocal);
if (("NULLFOUND".equalsIgnoreCase(calCriItemSerStr) || calCriItemSerStr == null || calCriItemSerStr.trim().length() == 0) ) if (("NULLFOUND".equalsIgnoreCase(calCriItemSerStr) || calCriItemSerStr == null || calCriItemSerStr.trim().length() == 0) )
...@@ -140,7 +135,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -140,7 +135,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
calCriItemSerList= new ArrayList<String>(Arrays.asList(calCriItemSerStr.split(","))); calCriItemSerList= new ArrayList<String>(Arrays.asList(calCriItemSerStr.split(",")));
isItemSerLocal=false; isItemSerLocal=false;
System.out.println("isItemSer@@Chk>>>>"+isItemSerLocal); System.out.println("isItemSer@@Chk>>>>"+isItemSerLocal);
} }*/
invoiceMonths = dist.getDisparams("999999","INVOICE_MONTHS", conn); invoiceMonths = dist.getDisparams("999999","INVOICE_MONTHS", conn);
System.out.println("invoiceMonths.." + invoiceMonths); System.out.println("invoiceMonths.." + invoiceMonths);
...@@ -154,9 +149,8 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -154,9 +149,8 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
} }
// thirdMonthDay= utlmethd.AddMonths(prdtoDateTmstmp, -3); // thirdMonthDay= utlmethd.AddMonths(prdtoDateTmstmp, -3);
System.out.println("invoiceMonthsPrevious>>>>>"+ invoiceMonthsPrevious); System.out.println("invoiceMonthsPrevious>>>>>"+ invoiceMonthsPrevious);
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat()); //sysDate = sdf2.format(currentDate.getTime());
sysDate = sdf2.format(currentDate.getTime());
parentNodeList = headerDom.getElementsByTagName("Detail1"); parentNodeList = headerDom.getElementsByTagName("Detail1");
parentNodeListLength = parentNodeList.getLength(); parentNodeListLength = parentNodeList.getLength();
...@@ -177,35 +171,77 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -177,35 +171,77 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
System.out.println("childNodeList.item(childRow) : "+ childNode); System.out.println("childNodeList.item(childRow) : "+ childNode);
System.out.println("childNode Name : "+childNode.getNodeName()+" value::"+childNode.getNodeValue()); System.out.println("childNode Name : "+childNode.getNodeName()+" value::"+childNode.getNodeValue());
if("table_no".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null) if("item_ser".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{ {
table_no=childNode.getFirstChild().getNodeValue(); itemSer=childNode.getFirstChild().getNodeValue();
table_no= table_no==null ? "" : table_no.trim(); itemSer= itemSer==null ? "" : itemSer.trim();
} }
if("prd_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null) if("prd_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{ {
prd_code=childNode.getFirstChild().getNodeValue(); prdCode=childNode.getFirstChild().getNodeValue();
prd_code= prd_code==null ? "" : prd_code.trim(); prdCode= prdCode==null ? "" : prdCode.trim();
} }
//Two additional filters added to run process as per tran date and cust code which will avoid unnesscary update [25/07/17|Start]
if("from_date".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
fromDateStr=childNode.getFirstChild().getNodeValue();
fromDateStr= fromDateStr==null ? "" : fromDateStr.trim();
}
if("to_date".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
toDateStr=childNode.getFirstChild().getNodeValue();
toDateStr= toDateStr==null ? "" : toDateStr.trim();
}
if("cust_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
custCodeDom=childNode.getFirstChild().getNodeValue();
custCodeDom= custCodeDom==null ? "" : custCodeDom.trim();
}
//Two additional filters added to run process as per tran date and cust code which will avoid unnesscary update [25/07/17|End]
} }
} }
if(calCriItemSerList.contains(table_no.trim())) if(custCodeDom!=null && custCodeDom.trim().length()>0)
{
custCodeDom="'"+custCodeDom+"'";
if(custCodeDom.contains(",")){
custCodeDom = custCodeDom.replaceAll(",", "','");
}
}
fromDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(fromDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
toDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(toDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("custCode::::"+custCode+":::fromDate::::"+fromDate+":::toDate::::"+toDate);
/*if(calCriItemSerList.contains(itemSer.trim()))
{ {
System.out.println("Inside ItemSer true::::["+calCriItemSerList.contains(table_no.trim())+"]"); System.out.println("Inside ItemSer true::::["+calCriItemSerList.contains(itemSer.trim())+"]");
isItemSerLocal=true; isItemSerLocal=true;
} }
else else
{ {
System.out.println("Inside ItemSer false::::["+calCriItemSerList.contains(table_no.trim())+"]"); System.out.println("Inside ItemSer false::::["+calCriItemSerList.contains(itemSer.trim())+"]");
isItemSerLocal=false; isItemSerLocal=false;
}*/
//Modified by santosh to set priceList(14/SEP/2017).[START]
calEnablePrice = dist.getDisparams("999999","ENABLE_SPEC_PRICELIST",conn);
calPriceDivision = dist.getDisparams("999999","SPEC_PRICELIST",conn);
System.out.println("calEnablePrice["+calEnablePrice+"]calPriceDivision["+calPriceDivision+"]");
if (("NULLFOUND".equalsIgnoreCase(calEnablePrice) || calEnablePrice == null || calEnablePrice.trim().length() == 0) )
{
calEnablePrice="N";
} }
if (("NULLFOUND".equalsIgnoreCase(calPriceDivision) || calPriceDivision == null || calPriceDivision.trim().length() == 0) )
sql = "select tran_id,from_date,to_date,cust_code,tran_id__last from cust_stock where pos_code is not null and prd_code=? AND ITEM_SER=?"; {
calEnablePrice="N";
}
System.out.println("calEnablePrice["+calEnablePrice+"]calPriceDivision["+calPriceDivision+"]");
//Modified by santosh to set priceList(14/SEP/2017).[END]
sql = " select tran_id,from_date,to_date,cust_code,tran_id__last,item_ser from cust_stock where pos_code is not null and prd_code=? AND ITEM_SER=? " +
" and tran_date between ? and ? and cust_code in ("+custCodeDom+") ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prd_code); pstmt.setString(1, prdCode);
pstmt.setString(2, table_no); pstmt.setString(2, itemSer);
pstmt.setTimestamp(3, fromDate);
pstmt.setTimestamp(4, toDate);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
...@@ -214,23 +250,41 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -214,23 +250,41 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
prdtoDateTmstmp = rs.getTimestamp("to_date"); prdtoDateTmstmp = rs.getTimestamp("to_date");
custCode = checkNull(rs.getString("cust_code")); custCode = checkNull(rs.getString("cust_code"));
tranIdLast = checkNull(rs.getString("tran_id__last")); tranIdLast = checkNull(rs.getString("tran_id__last"));
checkItemSer = checkNull(rs.getString("item_ser"));
System.out.println("tranId>>"+tranId+" prdFromoDateTmstmp>>"+prdFromoDateTmstmp+" prdtoDateTmstmp>>"+prdtoDateTmstmp+" custCode>>"+custCode); System.out.println("tranId>>"+tranId+" prdFromoDateTmstmp>>"+prdFromoDateTmstmp+" prdtoDateTmstmp>>"+prdtoDateTmstmp+" custCode>>"+custCode);
//Modified by saurabh[13/02/17|Start] //Modified by saurabh[13/02/17|Start]
thirdMonthDay = utlmethd.AddMonths(prdFromoDateTmstmp,invoiceMonthsPrevious); thirdMonthDay = utlmethd.AddMonths(prdFromoDateTmstmp,invoiceMonthsPrevious);
System.out.println("thirdMonthDay>>>>>>" + thirdMonthDay); System.out.println("thirdMonthDay>>>>>>" + thirdMonthDay);
//Modified by santosh to set priceList(14/SEP/2017).[START]
sql = "select price_list from customer where cust_code =? "; if("Y".equalsIgnoreCase(calEnablePrice))
pstmt1 = conn.prepareStatement(sql); {
pstmt1.setString(1, custCode); if("BR".equalsIgnoreCase(checkItemSer))
rs1 = pstmt1.executeQuery(); {
if (rs1.next()) { priceList = calPriceDivision.substring(calPriceDivision.indexOf(",")+1,calPriceDivision.length());
priceList = checkNull(rs1.getString("price_list")); System.out.println("@S@priceList["+priceList+"]");
System.out.println("priceList edit :" + priceList); }
else
{
priceList= calPriceDivision.substring(0,calPriceDivision.indexOf(","));
System.out.println("@S@priceList["+priceList+"]");
}
} }
rs1.close(); else
rs1 = null; {
pstmt1.close(); sql = "select price_list from customer where cust_code =? ";
pstmt1 = null; pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, custCode);
rs1 = pstmt1.executeQuery();
if (rs1.next()) {
priceList = checkNull(rs1.getString("price_list"));
System.out.println("priceList edit :" + priceList);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
//Modified by santosh to set priceList(14/SEP/2017).[END]
closingStockMap=new HashMap<String, ClosingStockBean>(); closingStockMap=new HashMap<String, ClosingStockBean>();
sql = " select item_code,cl_stock,CASE WHEN rate IS NULL THEN 0 ELSE rate END as rate," + sql = " select item_code,cl_stock,CASE WHEN rate IS NULL THEN 0 ELSE rate END as rate," +
" CASE WHEN rate__org IS NULL THEN 0 ELSE rate__org END as rate__org from " + " CASE WHEN rate__org IS NULL THEN 0 ELSE rate__org END as rate__org from " +
...@@ -340,15 +394,15 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -340,15 +394,15 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
{ {
isItemFound=false; isItemFound=false;
netAmt=0;netAmtRet=0;netAmtRep=0; netAmt=0;netAmtRet=0;netAmtRep=0;
sreturnCnt = 0; //sreturnCnt = 0;
invoiceId = checkNull(rs2.getString("invoice_id")); invoiceId = checkNull(rs2.getString("invoice_id"));
dlvFlag = checkNull(rs2.getString("dlv_flg")); dlvFlag = checkNull(rs2.getString("dlv_flg"));
refSer = checkNull(rs2.getString("ref_ser")); refSer = checkNull(rs2.getString("ref_ser"));
System.out.println("invoiceId>>>"+invoiceId+">>dlvFlag>>>"+dlvFlag+">>refSer>>"+refSer); System.out.println("invoiceId>>>"+invoiceId+">>dlvFlag>>>"+dlvFlag+">>refSer>>"+refSer);
if("Y".equalsIgnoreCase(dlvFlag)) /*if("Y".equalsIgnoreCase(dlvFlag))
{ {
invoiceIdList = invoiceIdList + "'"+invoiceId.trim() + "',"; invoiceIdList = invoiceIdList + "'"+invoiceId.trim() + "',";
} }*/
/*sql = "SELECT tran_id FROM sreturn WHERE tran_id='"+invoiceId+"'"; /*sql = "SELECT tran_id FROM sreturn WHERE tran_id='"+invoiceId+"'";
pstmt3 = conn.prepareStatement(sql); pstmt3 = conn.prepareStatement(sql);
...@@ -557,16 +611,16 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -557,16 +611,16 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
pstmt2.close(); pstmt2.close();
pstmt2 = null; pstmt2 = null;
if(invoiceIdList.trim().length() > 0) /*if(invoiceIdList.trim().length() > 0)
{ {
selectedInvList = invoiceIdList.substring(0,invoiceIdList.length() - 1); selectedInvList = invoiceIdList.substring(0,invoiceIdList.length() - 1);
} }*/
/* if(clStock>0) /* if(clStock>0)
{*/ {*/
formulaValue=clStock; formulaValue=clStock;
if(!isItemSerLocal) //if(!isItemSerLocal)
{ //{
System.out.println("formulaValue>>"+formulaValue); System.out.println("formulaValue>>"+formulaValue);
sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,itrc.quantity__stduom as quantity__stduom,inv.tran_date " sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,itrc.quantity__stduom as quantity__stduom,inv.tran_date "
...@@ -657,8 +711,8 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -657,8 +711,8 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
closingValue = closingValue + formulaValue * priceListRate; closingValue = closingValue + formulaValue * priceListRate;
closingValue = getRequiredDcml(closingValue, 3);//cl_value closingValue = getRequiredDcml(closingValue, 3);//cl_value
} }
}else //}else
{ /*{
if(recptInvQty > 0) if(recptInvQty > 0)
{ {
...@@ -688,7 +742,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -688,7 +742,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
} }
else else
{ {
/*invoiceMonths = dist.getDisparams("999999", "INVOICE_MONTHS", conn); invoiceMonths = dist.getDisparams("999999", "INVOICE_MONTHS", conn);
System.out.println("invoiceMonths>>>>.." + invoiceMonths); System.out.println("invoiceMonths>>>>.." + invoiceMonths);
if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0)) if (("NULLFOUND".equalsIgnoreCase(invoiceMonths) || invoiceMonths == null || invoiceMonths.trim().length() == 0))
{ {
...@@ -699,7 +753,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -699,7 +753,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
} }
System.out.println("invoiceMonthsPrevious>>>>>" + invoiceMonthsPrevious); System.out.println("invoiceMonthsPrevious>>>>>" + invoiceMonthsPrevious);
thirdMonthDay = utlmethd.AddMonths(prdFromoDateTmstmp, invoiceMonthsPrevious); thirdMonthDay = utlmethd.AddMonths(prdFromoDateTmstmp, invoiceMonthsPrevious);
System.out.println("thirdMonthDay from method>>>>>>" + thirdMonthDay);*/ System.out.println("thirdMonthDay from method>>>>>>" + thirdMonthDay);
sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,inv.tran_date " + sql = "SELECT inv.invoice_id,itrc.rate__stduom as rate__stduom,inv.tran_date " +
"FROM invoice_trace itrc,invoice inv WHERE itrc.invoice_id=inv.invoice_id " + "FROM invoice_trace itrc,invoice inv WHERE itrc.invoice_id=inv.invoice_id " +
...@@ -723,7 +777,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -723,7 +777,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
pstmt = null; pstmt = null;
if (calRate == 0) if (calRate == 0)
{ {
/*sql = "select price_list from customer where cust_code =? "; sql = "select price_list from customer where cust_code =? ";
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, custCode); pstmt1.setString(1, custCode);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
...@@ -735,7 +789,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -735,7 +789,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
rs1.close(); rs1.close();
rs1 = null; rs1 = null;
pstmt1.close(); pstmt1.close();
pstmt1 = null;*/ pstmt1 = null;
//Commented by Manoj dtd 26/10/2016 //Commented by Manoj dtd 26/10/2016
//openingRate = discmn.pickRate(priceList, sysDatetemp, itemCode, conn); //openingRate = discmn.pickRate(priceList, sysDatetemp, itemCode, conn);
//Changed by Manoj dtd 26/10/2016 //Changed by Manoj dtd 26/10/2016
...@@ -743,9 +797,9 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -743,9 +797,9 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
sql = "SELECT DDF_PICK_MAX_SLAB_RATE( ?, SYSDATE , ? ) FROM DUAL "; sql = "SELECT DDF_PICK_MAX_SLAB_RATE( ?, SYSDATE , ? ) FROM DUAL ";
pstmt1 = conn.prepareStatement( sql ); pstmt1 = conn.prepareStatement( sql );
pstmt1.setString( 1, priceList ); pstmt1.setString( 1, priceList );
/*pstmt1.setString( 2, sysDate ); pstmt1.setString( 2, sysDate );
pstmt1.setString( 3, genericUtility.getDBDateFormat() ); pstmt1.setString( 3, genericUtility.getDBDateFormat() );
*/pstmt1.setString( 2, itemCode ); pstmt1.setString( 2, itemCode );
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
if (rs1.next()) if (rs1.next())
{ {
...@@ -766,7 +820,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -766,7 +820,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
} }
calRate=getRequiredDcml(calRate,3); calRate=getRequiredDcml(calRate,3);
closingValue=getRequiredDcml(clStock*calRate,3); closingValue=getRequiredDcml(clStock*calRate,3);
} }*/
if (clStock > 0) if (clStock > 0)
{ {
closingRate = closingValue / clStock; closingRate = closingValue / clStock;
...@@ -803,7 +857,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -803,7 +857,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
netSecondarySalesValue=getRequiredDcml(netSecondarySalesValue,3);//sales_value netSecondarySalesValue=getRequiredDcml(netSecondarySalesValue,3);//sales_value
System.out.println("netSecondarySalesValue>>>>>"+netSecondarySalesValue); System.out.println("netSecondarySalesValue>>>>>"+netSecondarySalesValue);
grossSecondarySalesValue=(opStkDom*rateOrgOld)+recptInvValue+recptReplVal+recptFreeValue-recptRetVal-closingValue; grossSecondarySalesValue=(opStkDom*rateOld)+recptInvValue+recptReplVal+recptFreeValue-recptRetVal-closingValue;
grossSecondarySalesValue=getRequiredDcml(grossSecondarySalesValue,3); grossSecondarySalesValue=getRequiredDcml(grossSecondarySalesValue,3);
System.out.println("grossSecondarySalesValue>>>>>"+grossSecondarySalesValue); System.out.println("grossSecondarySalesValue>>>>>"+grossSecondarySalesValue);
...@@ -814,7 +868,14 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -814,7 +868,14 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
{ {
grossSecondaryRate=0.0; grossSecondaryRate=0.0;
} }
grossSecondaryRate=getRequiredDcml(grossSecondaryRate,3);//rate__org if(grossSecondaryRate<0)
{
grossSecondaryRate=0.0;
}
else
{
grossSecondaryRate=getRequiredDcml(grossSecondaryRate,3);//rate__org
}
System.out.println("grossSecondaryRate>>>"+grossSecondaryRate); System.out.println("grossSecondaryRate>>>"+grossSecondaryRate);
//End by chandrashekar on 29-dec-2015 //End by chandrashekar on 29-dec-2015
salesQtyCal = opStkDom + (recptInvQty + recptReplQty) - (recptRetQty + retQtyFreeDom) - clStock;//sales salesQtyCal = opStkDom + (recptInvQty + recptReplQty) - (recptRetQty + retQtyFreeDom) - clStock;//sales
...@@ -835,7 +896,8 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -835,7 +896,8 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
" transit_repl_val=? , transit_free_val=? , " + " transit_repl_val=? , transit_free_val=? , " +
" purc_rcp=? ,purc_rcp__repl=? ,purc_rcp__free=? ,purc_ret=? ,purc_ret__free=? , " + " purc_rcp=? ,purc_rcp__repl=? ,purc_rcp__free=? ,purc_ret=? ,purc_ret__free=? , " +
" transit_qty=? ,transit_qty__repl=? ,transit_qty__free=? ," + " transit_qty=? ,transit_qty__repl=? ,transit_qty__free=? ," +
" sales=? ,rate=? ,rate__org=? ,sales__org=? ,cl_value=? ,sales_value=? ,op_value=? ,primary_sales=? " + " sales=? ,rate=? ,rate__org=? ,sales__org=? ,cl_value=? ,sales_value=? ,op_value=? ,primary_sales=? ,op_stock=? , " +
" CHG_DATE=SYSDATE ,CHG_TERM=? ,CHG_USER=? " +
" where tran_id=? and item_code=? "; " where tran_id=? and item_code=? ";
pstmt2 = conn.prepareStatement(sql); pstmt2 = conn.prepareStatement(sql);
pstmt2.setDouble(1, recptInvValue);//rcp_val pstmt2.setDouble(1, recptInvValue);//rcp_val
...@@ -862,8 +924,11 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -862,8 +924,11 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
pstmt2.setDouble(22, netSecondarySalesValue );//sales_value pstmt2.setDouble(22, netSecondarySalesValue );//sales_value
pstmt2.setDouble(23, opValue );//op_value pstmt2.setDouble(23, opValue );//op_value
pstmt2.setDouble(24, primarySalesAll );//primary_sales pstmt2.setDouble(24, primarySalesAll );//primary_sales
pstmt2.setString(25, tranId); pstmt2.setDouble(25, opStkDom );//op_stock
pstmt2.setString(26, itemCode); pstmt2.setString(26, chgTerm);
pstmt2.setString(27, loginCode);
pstmt2.setString(28, tranId);
pstmt2.setString(29, itemCode);
UpdCnt = pstmt2.executeUpdate(); UpdCnt = pstmt2.executeUpdate();
if(UpdCnt>0) if(UpdCnt>0)
{ {
...@@ -921,7 +986,6 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -921,7 +986,6 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
errString = itmDBAccessEJB.getErrorString("", "VTES3RLBCK","", "", conn); errString = itmDBAccessEJB.getErrorString("", "VTES3RLBCK","", "", conn);
conn.rollback(); conn.rollback();
} }
retBuf = null;
if (conn != null) if (conn != null)
{ {
conn.close(); conn.close();
...@@ -941,13 +1005,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -941,13 +1005,7 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
private String checkNull(String input) private String checkNull(String input)
{ {
if (input == null) { input = input==null ? "" : input.trim();
input = "";
}
else
{
input = input.trim();
}
return input; return input;
} }
...@@ -991,7 +1049,5 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es ...@@ -991,7 +1049,5 @@ public class Es3HDataUpdPrc extends ProcessEJB implements Es3HDataUpdPrcLocal,Es
public void setOpeningRateOrg(double openingRateOrg) { public void setOpeningRateOrg(double openingRateOrg) {
this.openingRateOrg = openingRateOrg; this.openingRateOrg = openingRateOrg;
} }
} }
}// END OF EJB }// END OF EJB
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/******************************************************** /********************************************************
Title : BankGauranteeLocal [F15DSUN018] Title : BankGauranteeLocal [F15DSUN018]
Date : 22/JUL/15 Date : 22/JUL/15
Developer: Pankaj R. Developer: Pankaj R.
********************************************************/ ********************************************************/
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import org.w3c.dom.*; import org.w3c.dom.*;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3 import javax.ejb.Local; // added for ejb3
@Local // added for ejb3 @Local // added for ejb3
public interface PrdTableGenICLocal extends ValidatorLocal public interface PrdTableGenICLocal extends ValidatorLocal
{ {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String 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(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; public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
} }
/******************************************************** /********************************************************
Title : BankGauranteeRemote [F15DSUN018] Title : BankGauranteeRemote [F15DSUN018]
Date : 22/JUL/15 Date : 22/JUL/15
Developer: Pankaj R. Developer: Pankaj R.
********************************************************/ ********************************************************/
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import org.w3c.dom.*; import org.w3c.dom.*;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3 import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3 @Remote // added for ejb3
public interface PrdTableGenICRemote extends ValidatorRemote public interface PrdTableGenICRemote extends ValidatorRemote
{ {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException; public String 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(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; 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; package ibase.webitm.ejb.dis;
import org.w3c.dom.*; import org.w3c.dom.*;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
//import ibase.utility.GenericUtility; //import ibase.utility.GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator; import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import javax.ejb.Stateless; import javax.ejb.Stateless;
@Stateless @Stateless
public class PrdTableGenPostSave extends ValidatorEJB implements PrdTableGenPostSaveLocal,PrdTableGenPostSaveRemote { public class PrdTableGenPostSave extends ValidatorEJB implements PrdTableGenPostSaveLocal,PrdTableGenPostSaveRemote {
//E12GenericUtility genericUtility = new E12GenericUtility(); //E12GenericUtility genericUtility = new E12GenericUtility();
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{ {
System.out.println("------------ postSave method called-111111111----------------PrdTableGenPostSave : "); System.out.println("------------ postSave method called-111111111----------------PrdTableGenPostSave : ");
System.out.println("tranId111--->>["+tranId+"]"); System.out.println("tranId111--->>["+tranId+"]");
System.out.println("xml String--->>["+xmlString+"]"); System.out.println("xml String--->>["+xmlString+"]");
Document dom = null; Document dom = null;
String errString=""; String errString="";
try try
{ {
if (xmlString != null && xmlString.trim().length() > 0) if (xmlString != null && xmlString.trim().length() > 0)
{ {
dom = parseString(xmlString); dom = parseString(xmlString);
errString = postSave(dom,tranId,xtraParams,conn); errString = postSave(dom,tranId,xtraParams,conn);
} }
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception : PrdTableGenPostSave.java : postSave : ==>\n"+e.getMessage()); System.out.println("Exception : PrdTableGenPostSave.java : postSave : ==>\n"+e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
return errString; return errString;
} }
public String postSave(Document dom,String tranId,String xtraParams,Connection conn) throws ITMException public String postSave(Document dom,String tranId,String xtraParams,Connection conn) throws ITMException
{ {
System.out.println("in PrdTableGenPostSave tran_id---->>["+tranId+"]"); System.out.println("in PrdTableGenPostSave tran_id---->>["+tranId+"]");
ResultSet rs=null; ResultSet rs=null;
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
SimpleDateFormat sdf =null; SimpleDateFormat sdf =null;
Timestamp currDate = null,fromDate=null,tooDate=null,entryStartDtTimestmp=null,entryEndDtTimestmp=null; Timestamp currDate = null,fromDate=null,tooDate=null,entryStartDtTimestmp=null,entryEndDtTimestmp=null;
String sql="",errorString=""; String sql="",errorString="";
String prdCode="",prdTblNo="",frDate="",toDate="",prdClose=""; String prdCode="",prdTblNo="",frDate="",toDate="",prdClose="";
String entryStartDt="",entryEndDt=""; String entryStartDt="",entryEndDt="";
String chgUser="",chgTerm=""; String chgUser="",chgTerm="";
String errString = ""; String errString = "";
String selectedValue = "",status="",isChanged=""; String selectedValue = "",status="",isChanged="";
int cnt=0,updateCount=0,detCnt=0; int cnt=0,updateCount=0,detCnt=0;
ITMDBAccessEJB itmDBAccessEJB = null; ITMDBAccessEJB itmDBAccessEJB = null;
boolean value=false; boolean value=false;
ibase.utility.E12GenericUtility genericUtility = null; ibase.utility.E12GenericUtility genericUtility = null;
genericUtility = new ibase.utility.E12GenericUtility(); genericUtility = new ibase.utility.E12GenericUtility();
boolean isSelect=false; boolean isSelect=false;
try try
{ {
itmDBAccessEJB = new ITMDBAccessEJB(); itmDBAccessEJB = new ITMDBAccessEJB();
chgUser =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode")); chgUser =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
chgTerm =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm")); chgTerm =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm"));
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new Timestamp(System.currentTimeMillis()); currDate = new Timestamp(System.currentTimeMillis());
System.out.println("TimeStamp>>>>>>>>>>"+currDate); System.out.println("TimeStamp>>>>>>>>>>"+currDate);
NodeList hdrDommList = dom.getElementsByTagName("Detail2"); NodeList hdrDommList = dom.getElementsByTagName("Detail2");
System.out.println("hdrDommList==="+hdrDommList); System.out.println("hdrDommList==="+hdrDommList);
System.out.println("len===["+hdrDommList.getLength()+"]"); System.out.println("len===["+hdrDommList.getLength()+"]");
if(hdrDommList.getLength()==0 ) if(hdrDommList.getLength()==0 )
{ {
System.out.println(">No Data Selected"+isSelect); System.out.println(">No Data Selected"+isSelect);
errString = itmDBAccessEJB.getErrorString("","VTNODATA","","",conn); errString = itmDBAccessEJB.getErrorString("","VTNODATA","","",conn);
return errString; return errString;
} }
for (int dtlCtr = 0; dtlCtr < hdrDommList.getLength(); dtlCtr++) for (int dtlCtr = 0; dtlCtr < hdrDommList.getLength(); dtlCtr++)
{ {
Node detailListNode = hdrDommList.item(dtlCtr); Node detailListNode = hdrDommList.item(dtlCtr);
NodeList detail2List= detailListNode.getChildNodes(); NodeList detail2List= detailListNode.getChildNodes();
// System.out.println("@@@@@@@@@node name[" + detailListNode.getNodeName()+"]"); // System.out.println("@@@@@@@@@node name[" + detailListNode.getNodeName()+"]");
System.out.println("detailListNode===="+detailListNode); System.out.println("detailListNode===="+detailListNode);
if("Detail2".equalsIgnoreCase(detailListNode.getNodeName())) if("Detail2".equalsIgnoreCase(detailListNode.getNodeName()))
{ {
System.out.println("detail2List===="+detail2List); System.out.println("detail2List===="+detail2List);
// System.out.println("@@@@inside detail4----------------"); // System.out.println("@@@@inside detail4----------------");
for (int cntr = 0; cntr < detail2List.getLength(); cntr++) for (int cntr = 0; cntr < detail2List.getLength(); cntr++)
{ {
Node detail2Node = detail2List.item(cntr); Node detail2Node = detail2List.item(cntr);
System.out.println("detail2Node===="+detail2Node); System.out.println("detail2Node===="+detail2Node);
if(detail2Node != null && detail2Node.getNodeName().equalsIgnoreCase("attribute")) if(detail2Node != null && detail2Node.getNodeName().equalsIgnoreCase("attribute"))
{ {
System.out.println("Check for selected Value######"); System.out.println("Check for selected Value######");
selectedValue = detail2Node.getAttributes().getNamedItem("selected").getNodeValue(); selectedValue = detail2Node.getAttributes().getNamedItem("selected").getNodeValue();
System.out.println("selectedValue=========="+selectedValue); System.out.println("selectedValue=========="+selectedValue);
System.out.println("Check for STATUS Value######"); System.out.println("Check for STATUS Value######");
status = detail2Node.getAttributes().getNamedItem("status").getNodeValue(); status = detail2Node.getAttributes().getNamedItem("status").getNodeValue();
System.out.println("status=========="+status); System.out.println("status=========="+status);
System.out.println("Check for IS_CHANGE Value######"); System.out.println("Check for IS_CHANGE Value######");
isChanged = detail2Node.getAttributes().getNamedItem("IS_CHANGE").getNodeValue(); isChanged = detail2Node.getAttributes().getNamedItem("IS_CHANGE").getNodeValue();
System.out.println("isChanged=========="+isChanged); System.out.println("isChanged=========="+isChanged);
} }
if("prd_code".equalsIgnoreCase( detail2Node.getNodeName())) if("prd_code".equalsIgnoreCase( detail2Node.getNodeName()))
{ {
if( detail2List.item(cntr).getFirstChild() != null) if( detail2List.item(cntr).getFirstChild() != null)
{ {
prdCode = detail2List.item(cntr).getFirstChild().getNodeValue(); prdCode = detail2List.item(cntr).getFirstChild().getNodeValue();
} }
else else
{ {
prdCode= ""; prdCode= "";
} }
} }
if("prd_tblno".equalsIgnoreCase( detail2Node.getNodeName())) if("prd_tblno".equalsIgnoreCase( detail2Node.getNodeName()))
{ {
if( detail2List.item(cntr).getFirstChild() != null) if( detail2List.item(cntr).getFirstChild() != null)
{ {
prdTblNo = detail2List.item(cntr).getFirstChild().getNodeValue(); prdTblNo = detail2List.item(cntr).getFirstChild().getNodeValue();
} }
else else
{ {
prdTblNo= ""; prdTblNo= "";
} }
} }
if("fr_date".equalsIgnoreCase( detail2Node.getNodeName())) if("fr_date".equalsIgnoreCase( detail2Node.getNodeName()))
{ {
if( detail2List.item(cntr).getFirstChild() != null) if( detail2List.item(cntr).getFirstChild() != null)
{ {
frDate = detail2List.item(cntr).getFirstChild().getNodeValue(); frDate = detail2List.item(cntr).getFirstChild().getNodeValue();
} }
else else
{ {
frDate= ""; frDate= "";
} }
} }
if("to_date".equalsIgnoreCase( detail2Node.getNodeName())) if("to_date".equalsIgnoreCase( detail2Node.getNodeName()))
{ {
if( detail2List.item(cntr).getFirstChild() != null) if( detail2List.item(cntr).getFirstChild() != null)
{ {
toDate = detail2List.item(cntr).getFirstChild().getNodeValue(); toDate = detail2List.item(cntr).getFirstChild().getNodeValue();
} }
else else
{ {
toDate= ""; toDate= "";
} }
} }
if("prd_closed".equalsIgnoreCase( detail2Node.getNodeName())) if("prd_closed".equalsIgnoreCase( detail2Node.getNodeName()))
{ {
if( detail2List.item(cntr).getFirstChild() != null) if( detail2List.item(cntr).getFirstChild() != null)
{ {
prdClose = detail2List.item(cntr).getFirstChild().getNodeValue(); prdClose = detail2List.item(cntr).getFirstChild().getNodeValue();
} }
else else
{ {
prdClose= ""; prdClose= "";
} }
} }
if("entry_start_dt".equalsIgnoreCase( detail2Node.getNodeName())) if("entry_start_dt".equalsIgnoreCase( detail2Node.getNodeName()))
{ {
if( detail2List.item(cntr).getFirstChild() != null) if( detail2List.item(cntr).getFirstChild() != null)
{ {
entryStartDt = detail2List.item(cntr).getFirstChild().getNodeValue(); entryStartDt = detail2List.item(cntr).getFirstChild().getNodeValue();
} }
else else
{ {
entryStartDt= ""; entryStartDt= "";
} }
} }
if("entry_end_dt".equalsIgnoreCase( detail2Node.getNodeName())) if("entry_end_dt".equalsIgnoreCase( detail2Node.getNodeName()))
{ {
if( detail2List.item(cntr).getFirstChild() != null) if( detail2List.item(cntr).getFirstChild() != null)
{ {
entryEndDt = detail2List.item(cntr).getFirstChild().getNodeValue(); entryEndDt = detail2List.item(cntr).getFirstChild().getNodeValue();
} }
else else
{ {
entryEndDt= ""; entryEndDt= "";
} }
} }
} }
System.out.println("@@@@ctr["+dtlCtr+"]Period code["+prdCode+"]-Period table Code["+prdTblNo+"]-from date["+frDate+"]To Date["+toDate+"]period closed["+prdClose+"]@@@"); System.out.println("@@@@ctr["+dtlCtr+"]Period code["+prdCode+"]-Period table Code["+prdTblNo+"]-from date["+frDate+"]To Date["+toDate+"]period closed["+prdClose+"]@@@");
if(frDate!=null && frDate.trim().length()>0 ) if(frDate!=null && frDate.trim().length()>0 )
{ {
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(frDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0"); fromDate = Timestamp.valueOf(genericUtility.getValidDateString(frDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as fromDate@@@@@@@==="+fromDate); System.out.println("Date to be set as fromDate@@@@@@@==="+fromDate);
} }
if(toDate!=null && toDate.trim().length()>0 ) if(toDate!=null && toDate.trim().length()>0 )
{ {
tooDate = Timestamp.valueOf(genericUtility.getValidDateString(toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0"); tooDate = Timestamp.valueOf(genericUtility.getValidDateString(toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as tooDate @@@@@@@==="+tooDate); System.out.println("Date to be set as tooDate @@@@@@@==="+tooDate);
} }
if(entryStartDt != null) if(entryStartDt != null)
{ {
entryStartDtTimestmp = Timestamp.valueOf(genericUtility.getValidDateString(entryStartDt, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0"); entryStartDtTimestmp = Timestamp.valueOf(genericUtility.getValidDateString(entryStartDt, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
} }
if(entryStartDt != null) if(entryStartDt != null)
{ {
entryEndDtTimestmp = Timestamp.valueOf(genericUtility.getValidDateString(entryEndDt, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0"); entryEndDtTimestmp = Timestamp.valueOf(genericUtility.getValidDateString(entryEndDt, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
} }
System.out.println("isSelect============"+isSelect); System.out.println("isSelect============"+isSelect);
if("N".equalsIgnoreCase(status)) if("N".equalsIgnoreCase(status))
{ {
System.out.println("selected Value for record===="+selectedValue); System.out.println("selected Value for record===="+selectedValue);
sql="select count(1) from period_tbl where prd_code= ? and prd_tblno= ?"; sql="select count(1) from period_tbl where prd_code= ? and prd_tblno= ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, prdCode); pstmt.setString(1, prdCode);
pstmt.setString(2, prdTblNo); pstmt.setString(2, prdTblNo);
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
cnt = rs.getInt(1); cnt = rs.getInt(1);
System.out.println("CNT==="+cnt); System.out.println("CNT==="+cnt);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt==0) if(cnt==0)
{ {
System.out.println("New Exist@@@@@@@"); System.out.println("New Exist@@@@@@@");
sql="Insert into period_tbl (PRD_CODE,PRD_TBLNO,FR_DATE,TO_DATE,PRD_CLOSED,CHG_DATE,CHG_USER,CHG_TERM,ADD_DATE,ADD_USER,ADD_TERM,ENTRY_START_DT,ENTRY_END_DT ) " + sql="Insert into period_tbl (PRD_CODE,PRD_TBLNO,FR_DATE,TO_DATE,PRD_CLOSED,CHG_DATE,CHG_USER,CHG_TERM,ADD_DATE,ADD_USER,ADD_TERM,ENTRY_START_DT,ENTRY_END_DT ) " +
"values (?,?,?,?,?,?,?,?,?,?,?,?,?)"; "values (?,?,?,?,?,?,?,?,?,?,?,?,?)";
System.out.println("header sql :"+sql); System.out.println("header sql :"+sql);
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode); pstmt.setString(1,prdCode);
pstmt.setString(2,prdTblNo); pstmt.setString(2,prdTblNo);
pstmt.setTimestamp(3,fromDate); pstmt.setTimestamp(3,fromDate);
pstmt.setTimestamp(4,tooDate); pstmt.setTimestamp(4,tooDate);
pstmt.setString(5,prdClose); pstmt.setString(5,prdClose);
pstmt.setTimestamp(6,currDate); pstmt.setTimestamp(6,currDate);
pstmt.setString(7,chgUser); pstmt.setString(7,chgUser);
pstmt.setString(8,chgTerm); pstmt.setString(8,chgTerm);
pstmt.setTimestamp(9,currDate); pstmt.setTimestamp(9,currDate);
pstmt.setString(10,chgUser); pstmt.setString(10,chgUser);
pstmt.setString(11,chgTerm); pstmt.setString(11,chgTerm);
pstmt.setTimestamp(12,entryStartDtTimestmp);//Added by chandra shekar on 15-feb-2016 pstmt.setTimestamp(12,entryStartDtTimestmp);//Added by chandra shekar on 15-feb-2016
pstmt.setTimestamp(13,entryEndDtTimestmp);//Added by chandra shekar on 15-feb-2016 pstmt.setTimestamp(13,entryEndDtTimestmp);//Added by chandra shekar on 15-feb-2016
detCnt = pstmt.executeUpdate(); detCnt = pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("Insert Count==="+detCnt); System.out.println("Insert Count==="+detCnt);
} }
else else
{ {
System.out.println("Record Exist@@@@@@@"); System.out.println("Record Exist@@@@@@@");
sql = "update period_tbl set FR_DATE= ? ,TO_DATE=?, PRD_CLOSED=?,CHG_DATE=?,CHG_USER=?,CHG_TERM=?, " + sql = "update period_tbl set FR_DATE= ? ,TO_DATE=?, PRD_CLOSED=?,CHG_DATE=?,CHG_USER=?,CHG_TERM=?, " +
" ENTRY_START_DT=?,ENTRY_END_DT=? where prd_code= ? and prd_tblno= ? "; " ENTRY_START_DT=?,ENTRY_END_DT=? where prd_code= ? and prd_tblno= ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,fromDate); pstmt.setTimestamp(1,fromDate);
pstmt.setTimestamp(2,tooDate); pstmt.setTimestamp(2,tooDate);
pstmt.setString(3,prdClose); pstmt.setString(3,prdClose);
pstmt.setTimestamp(4,currDate); pstmt.setTimestamp(4,currDate);
pstmt.setString(5,chgUser); pstmt.setString(5,chgUser);
pstmt.setString(6,chgTerm); pstmt.setString(6,chgTerm);
pstmt.setTimestamp(7,entryStartDtTimestmp);//Added by chandra shekar on 15-feb-2016 pstmt.setTimestamp(7,entryStartDtTimestmp);//Added by chandra shekar on 15-feb-2016
pstmt.setTimestamp(8,entryEndDtTimestmp);//Added by chandra shekar on 15-feb-2016 pstmt.setTimestamp(8,entryEndDtTimestmp);//Added by chandra shekar on 15-feb-2016
pstmt.setString(9,prdCode); pstmt.setString(9,prdCode);
pstmt.setString(10,prdTblNo); pstmt.setString(10,prdTblNo);
updateCount = pstmt.executeUpdate(); updateCount = pstmt.executeUpdate();
System.out.println("no of row update: "+updateCount); System.out.println("no of row update: "+updateCount);
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(detCnt>0 ||updateCount>0) if(detCnt>0 ||updateCount>0)
{ {
System.out.println(">>The selected transaction is confirmed"); System.out.println(">>The selected transaction is confirmed");
isSelect=true; isSelect=true;
errString=""; errString="";
//errString = itmDBAccessEJB.getErrorString("","VTCONSUCF","","",conn); //errString = itmDBAccessEJB.getErrorString("","VTCONSUCF","","",conn);
} }
}//end }//end
else if(!isSelect ) else if(!isSelect )
{ {
System.out.println(">No Data Selected"+isSelect); System.out.println(">No Data Selected"+isSelect);
errString = itmDBAccessEJB.getErrorString("","VTNODATA","","",conn); errString = itmDBAccessEJB.getErrorString("","VTNODATA","","",conn);
} }
} }
} }
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception ::"+e.getMessage()); System.out.println("Exception ::"+e.getMessage());
errString = genericUtility.createErrorString(e); errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
{ {
try try
{ {
System.out.println(">>>>>In finally errString:"+errString); System.out.println(">>>>>In finally errString:"+errString);
if(errString == null || errString.trim().length() == 0) if(errString == null || errString.trim().length() == 0)
{ {
conn.commit(); conn.commit();
} }
else else
{ {
conn.rollback(); conn.rollback();
} }
/* if(errString != null && errString.trim().length() > 0) /* if(errString != null && errString.trim().length() > 0)
{ {
if(errString.indexOf("VTCONSUCF") > -1) if(errString.indexOf("VTCONSUCF") > -1)
{ {
conn.commit(); conn.commit();
System.out.println("Commit Completed"); System.out.println("Commit Completed");
} }
else else
{ {
conn.rollback(); conn.rollback();
} }
}*/ }*/
if(rs != null) if(rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if(pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
//conn.close(); //conn.close();
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception : "+e);e.printStackTrace(); System.out.println("Exception : "+e);e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
return errString; return errString;
} }
private String checkNull( String input ) private String checkNull( String input )
{ {
if (input == null ) if (input == null )
{ {
input = ""; input = "";
} }
return input; return input;
}//end of }//end of
} }
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal; import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.sql.Connection; import java.sql.Connection;
import javax.ejb.Local; import javax.ejb.Local;
@Local @Local
public interface PrdTableGenPostSaveLocal extends ValidatorLocal { public interface PrdTableGenPostSaveLocal extends ValidatorLocal {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException; public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
} }
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote; import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.sql.Connection; import java.sql.Connection;
import javax.ejb.Remote; import javax.ejb.Remote;
@Remote @Remote
public interface PrdTableGenPostSaveRemote extends ValidatorRemote { public interface PrdTableGenPostSaveRemote extends ValidatorRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException; public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) 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.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class PrimarySalesConsolidationIC extends ValidatorEJB implements PrimarySalesConsolidationICLocal , PrimarySalesConsolidationICRemote
{
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String editFlag,String xtraParams) throws RemoteException
{
System.out.println("In wfValData");
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = "";
try
{
System.out.println("currFrmXmlStr..." + currFrmXmlStr);
System.out.println("hdrFrmXmlStr..." + hdrFrmXmlStr);
System.out.println("allFrmXmlStr..." + allFrmXmlStr);
if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0))
{
currDom = parseString(currFrmXmlStr);
}
if ((hdrFrmXmlStr != null) && (hdrFrmXmlStr.trim().length() != 0))
{
hdrDom = parseString(hdrFrmXmlStr);
}
if ((allFrmXmlStr != null) && (allFrmXmlStr.trim().length() != 0))
{
allDom = parseString(allFrmXmlStr);
}
errString = wfValData(currDom, hdrDom, allDom, objContext, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception : [PrimarySalesConsolidationIC][wfValData(String currFrmXmlStr)] : ==>\n" + e.getMessage());
}
return errString;
}
public String wfValData(Document currDom, Document hdrDom, Document allDom,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{
E12GenericUtility genericUtility= new E12GenericUtility();
String errString = "" , loginSiteCode = "" , userId ="" , isPrdClosed = "",overWrite="" ;
String childNodeName = "";
String sql = "";
int noOfChilds = 0;
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
int currentFormNo = 0;
int cnt = 0,count=0,unConfCnt=0,excnt=0;
ConnDriver connDriver = null;
Node childNode = null;
String itemSer="" , prdCode = "" ,maxPrdCode="" ,countryCode="" ;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try {
System.out.println("************xtraParams*************" + xtraParams);
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
System.out.println("In wfValData PrimarySalesConsolidationIC :::");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"));
System.out.println("**************loginCode************" + userId);
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
NodeList parentList = currDom.getElementsByTagName("Detail"+ currentFormNo);
NodeList childList = null;
System.out.println("hdrDom..." + hdrDom.toString());
switch (currentFormNo)
{
case 1:
{
childList = parentList.item(0).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item(ctr);
if (childNode.getNodeType() != 1)
{
continue;
}
childNodeName = childNode.getNodeName();
System.out.println("Editflag =" + editFlag);
System.out.println("parentList = " + parentList);
System.out.println("childList = " + childList);
if ("item_ser".equalsIgnoreCase(childNodeName))
{
itemSer = genericUtility.getColumnValue("item_ser", currDom);
System.out.println("wfValData>>itemSer>>"+itemSer);
if(itemSer == null || itemSer.trim().length()==0 )
{
errString = itmDBAccessEJB.getErrorString("item_ser","VMNULLDIV",userId);
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM ITEMSER WHERE ITEM_SER = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errString = itmDBAccessEJB.getErrorString("item_ser","VTINVDIV",userId);
break;
}
}
}
else if ("overwrite".equalsIgnoreCase(childNodeName))
{
overWrite = genericUtility.getColumnValue("overwrite", currDom);
System.out.println("wfValData>>overWrite>>"+overWrite);
if("N".equalsIgnoreCase(overWrite))
{
sql = " SELECT COUNT(*) AS COUNT FROM SALES_CONSOLIDATION WHERE PRD_CODE = ? AND ITEM_SER=? AND SOURCE='S' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, itemSer);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("COUNT");
}
if(count > 0)
{
errString = itmDBAccessEJB.getErrorString("prd_code","VTDATA",userId);
break ;
}
}
}
else if ("prd_code".equalsIgnoreCase(childNodeName))
{
prdCode = genericUtility.getColumnValue("prd_code", currDom);
itemSer = genericUtility.getColumnValue("item_ser", currDom);
sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode );
rs = pstmt.executeQuery();
if(rs.next())
{
countryCode = checkNull(rs.getString("count_code")).trim();
System.out.println("countryCode >>> :"+countryCode);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("wfValData>>prdCode>>"+prdCode+">>itemSer"+itemSer);
if(prdCode == null || prdCode.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("prd_code","VMNULLPRD ",userId);
break ;
}
else
{
sql = " SELECT COUNT(*) FROM PERIOD A , PERIOD_TBL B WHERE A.CODE = B.PRD_CODE AND B.PRD_CODE = ? and B.PRD_TBLNO= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode);
pstmt.setString(2,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
System.out.println("Error :Period not exist in period_tbl master ");
errString = itmDBAccessEJB.getErrorString("","VMINVPRDTB",userId);
break ;
}
else
{
sql = "SELECT B.PRD_CLOSED FROM PERIOD A , PERIOD_TBL B WHERE A.CODE = B.PRD_CODE AND B.PRD_CODE = ? and B.PRD_TBLNO= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode.trim());
pstmt.setString(2,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
isPrdClosed = rs.getString("PRD_CLOSED");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if("N".equalsIgnoreCase(isPrdClosed))
{
errString = itmDBAccessEJB.getErrorString("","VMPRDNCL",userId);
break ;
}
else
{
sql="select max(prd_code) from period_tbl where PRD_TBLNO=? and PRD_CLOSED='Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
maxPrdCode = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(!prdCode.equalsIgnoreCase(maxPrdCode))
{
//max period check
errString = itmDBAccessEJB.getErrorString("","VTINVPCD",userId);
break ;
}
else
{
sql = " SELECT COUNT(*) AS COUNT FROM SALES_FACT WHERE PRD_CODE = ? and ITEM_SER=? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2,itemSer);
rs = pstmt.executeQuery();
if(rs.next())
{
excnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (excnt == 0)
{
System.out.println("No record found ");
errString = itmDBAccessEJB.getErrorString("","VTNULLRCD",userId);
break ;
}
}
}
}
}
}
}
}
break;
}
}
catch (Exception e)
{
System.out.println("Exception in "+this.getClass().getSimpleName()+" == >");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if ((conn != null) && (!conn.isClosed()))
conn.close();
}
catch (Exception e)
{
System.out.println("Exception :"+this.getClass().getSimpleName()+":wfValData :==>\n" + e.getMessage());
throw new ITMException(e);
}
}
return errString;
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
System.out.println("XmlString :::::::::: "+xmlString);
System.out.println("XmlString1 :::::::::: "+xmlString1);
System.out.println("XmlString2 :::::::::: "+xmlString2);
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
System.out.println("Dom ::::::: "+dom);
}
if (xmlString1 != null && xmlString1.trim().length() > 0) {
dom1 = parseString(xmlString1);
System.out.println("Dom1 ::::::: "+dom1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0) {
dom2 = parseString(xmlString2);
System.out.println("Dom2 ::::::: "+dom2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext,currentColumn, editFlag, xtraParams);
} catch (Exception e) {
System.out.println("Exception : [SalesConsolidation] :==>\n"+ e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document currDom, Document hdrDom, Document allDom,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException
{
E12GenericUtility genericUtility= new E12GenericUtility();
int currentFormNo = 0;
StringBuffer valueXmlString = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null, columnValue = "",maxPrdCode="",itemSer="",sql="",countryCode="",loginSiteCode="";
int ctr = 0, childNodeListLength = 0 ;
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = null;
try
{
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
currentColumn = checkNull(currentColumn);
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"));
switch (currentFormNo)
{
case 1:
{
System.out.println("Inside Case 1 Of Itemchange");
parentNodeList = currDom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
/*do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr++;
}while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));*/
System.out.println(" currentColumn : "+ currentColumn);
System.out.println("current form::::::::::::" + currentFormNo);
if ( "itm_default".equalsIgnoreCase(currentColumn))
{
valueXmlString.append("<prd_code>").append("").append("</prd_code>");
valueXmlString.append("<item_ser>").append("").append("</item_ser>");
valueXmlString.append("<overwrite>").append("<![CDATA[N]]>").append("</overwrite>");
}
else if ("item_ser".equalsIgnoreCase(currentColumn))
{
itemSer = checkNull(genericUtility.getColumnValue("item_ser", currDom));
System.out.println("itemSer>>>"+itemSer);
if(itemSer.trim().length()>0){
sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode );
rs = pstmt.executeQuery();
if(rs.next())
{
countryCode = checkNull(rs.getString("count_code")).trim();
System.out.println("countryCode >>> :"+countryCode);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql="select max(prd_code) from period_tbl where PRD_TBLNO=? and PRD_CLOSED='Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
maxPrdCode = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(maxPrdCode.length()>0)
{
valueXmlString.append("<prd_code>").append("<![CDATA[" + maxPrdCode + "]]>").append("</prd_code>");
}
else
{
valueXmlString.append("<prd_code>").append("<![CDATA[]]>").append("</prd_code>");
}
}
else
{
valueXmlString.append("<prd_code>").append("<![CDATA[]]>").append("</prd_code>");
}
}
valueXmlString.append("</Detail1>\r\n");
}
break;
}
}
catch (Exception e)
{
try
{
e.printStackTrace();
throw new ITMException(e);
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
}
finally
{
try {
if (conn != null) {
conn.close();
conn = null;
}
if(rs != null )
{
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
valueXmlString.append("</Root>\r\n");
return valueXmlString.toString();
}
private String checkNull(String input)
{
return input == null ? "" : input.trim();
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface PrimarySalesConsolidationICLocal 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 currDom, Document hdrDom, Document allDom,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface PrimarySalesConsolidationICRemote 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 currDom, Document hdrDom, Document allDom,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.ProcessEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
@Stateless
public class PrimarySalesConsolidationPrc extends ProcessEJB implements PrimarySalesConsolidationPrcLocal , PrimarySalesConsolidationPrcRemote
{
E12GenericUtility genericUtility= new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
@Override
public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException
{
String rtStr = "";
Document dom = null;
Document dom2 = null;
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = genericUtility.parseString(xmlString);
System.out.println("Process Dom::::::::::::::::"+dom );
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
dom2 = genericUtility.parseString(xmlString2);
System.out.println("Process Dom2::::::::::::::::"+dom2 );
}
rtStr = process(dom, dom2, windowName, xtraParams);
} catch (Exception e) {
System.out.println("::::"+this.getClass().getSimpleName()+"::processDataString" + e.getMessage());
e.printStackTrace();
}
return rtStr;
}
@Override
public String process(Document dom, Document dom2, String windowName,String xtraParams) throws RemoteException, ITMException {
String errString = "", prdCode = "" , itemSer = "" , tranId = "" , loginSiteCode = "" , sql = "" , sql1 = "" , userId = "" ,
unit = "" , empCode = "" , posCode = "" , custCode = "" , itemCode = "" , versionId = ""
, stanCode = "" , terrCode = "" , terrDescr = "" ,countryCode = "";
double netSalesQty=0.0,netSalesVal=0.0,lycmSalesQty=0.0,lycmSalesVal=0.0;
Connection conn=null;
int cnt = 0 , updCnt = 0 ;
String chgTerm="",chgUser="",overWrite="";
PreparedStatement pstmt = null , pstmt1 = null;
ResultSet rs = null , rs1 = null;
Timestamp frDate = null , toDate = null ;
System.out.println("Current DOM [" + genericUtility.serializeDom(dom) + "]");
System.out.println("Header DOM [" + genericUtility.serializeDom(dom2) + "]");
java.sql.Date sysDate=null;
try {
System.out.println("In process Sales Consolidation:::");
userId = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "userID"));
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"));
prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom));
itemSer = checkNull(genericUtility.getColumnValue("item_ser", dom));
overWrite = checkNull(genericUtility.getColumnValue("overwrite", dom));
System.out.println("prdCode>>>"+prdCode+">>itemSer>>"+itemSer+">>overWrite>>"+overWrite);
System.out.println("userId : "+userId);
System.out.println("xtraParams ::: "+xtraParams);
ConnDriver con = new ConnDriver();
conn = con.getConnectDB("DriverITM");
sql1 = "select sysdate from dual";
pstmt = conn.prepareStatement(sql1);
rs = pstmt.executeQuery();
if (rs.next()) {
sysDate = rs.getDate(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode );
rs = pstmt.executeQuery();
if(rs.next())
{
countryCode = checkNull(rs.getString("count_code")).trim();
System.out.println("countryCode >>> :"+countryCode);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = " SELECT FR_DATE,TO_DATE FROM PERIOD_TBL WHERE PRD_CODE=? AND PRD_TBLNO=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
frDate = rs.getTimestamp("FR_DATE");
toDate = rs.getTimestamp("TO_DATE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("frDate :::"+frDate+">>toDate :::"+toDate);
sql = "SELECT VERSION_ID FROM VERSION WHERE EFF_FROM < = ? AND VALID_UPTO > = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, frDate);
pstmt.setTimestamp(2, toDate);
rs = pstmt.executeQuery();
if(rs.next())
{
versionId = checkNull(rs.getString("VERSION_ID"));
System.out.println("versionId ::: "+versionId);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if("Y".equalsIgnoreCase(overWrite)){
cnt=0;
sql = "DELETE FROM SALES_CONSOLIDATION WHERE PRD_CODE = ? AND ITEM_SER=? AND SOURCE='S'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, itemSer);
cnt=pstmt.executeUpdate();
System.out.println("Delete count>>"+cnt);
pstmt.close();
pstmt = null;
}
System.out.println("Inserting data ");
sql=" SELECT S.CUST_CODE,S.PRD_CODE,S.ITEM_CODE,S.ITEM_SER,S.STAN_CODE,S.NET_SALES_QTY,S.NET_SALES_VAL,S.LYCM_SALES_QTY,S.LYCM_SALES_VAL,CS.POS_CODE,CS.EMP_CODE " +
" FROM SALES_FACT S LEFT OUTER JOIN CUST_STOCK CS ON CS.PRD_CODE=S.PRD_CODE AND CS.CUST_CODE=S.CUST_CODE AND CS.ITEM_SER=S.ITEM_SER " +
" WHERE S.PRD_CODE=? AND S.ITEM_SER=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, itemSer);
rs = pstmt.executeQuery();
while(rs.next())
{
custCode = checkNull(rs.getString("CUST_CODE"));
prdCode = checkNull(rs.getString("PRD_CODE"));
itemCode = checkNull(rs.getString("ITEM_CODE"));
itemSer = checkNull(rs.getString("ITEM_SER"));
stanCode = checkNull(rs.getString("STAN_CODE"));
netSalesQty = rs.getDouble("NET_SALES_QTY");
netSalesVal = rs.getDouble("NET_SALES_VAL");
lycmSalesQty = rs.getDouble("LYCM_SALES_QTY");
lycmSalesVal = rs.getDouble("LYCM_SALES_VAL");
posCode = checkNull(rs.getString("POS_CODE"));
empCode = checkNull(rs.getString("EMP_CODE"));
System.out.println("prdCode ::: "+prdCode+">>custCode ::: "+custCode);
System.out.println("itemSer ::: "+itemSer+">>itemCode ::: "+itemCode);
System.out.println("stanCode ::: "+stanCode);
System.out.println("netSalesQty ::: "+netSalesQty+">>netSalesVal ::: "+netSalesVal);
System.out.println("lycmSalesQty ::: "+lycmSalesQty+">>lycmSalesVal ::: "+lycmSalesVal);
System.out.println("posCode :::"+posCode+">>empCode :::"+empCode);
unit="";terrCode="";terrDescr="";
sql1="select UNIT from item where item_code=?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, itemCode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
unit = checkNull(rs1.getString("UNIT"));
}
System.out.println("unit>>"+unit);
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
sql1 = " SELECT A.POOL_CODE , B.LEVEL_CODE , B.LEVEL_DESCR FROM ORG_STRUCTURE A , HIERARCHY " +
" B WHERE A.POOL_CODE = B.LEVEL_CODE AND A.VERSION_ID = ? AND A.POS_CODE = ? AND A.TABLE_NO = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, versionId);
pstmt1.setString(2, posCode);
pstmt1.setString(3, itemSer);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
terrCode = checkNull(rs1.getString("LEVEL_CODE"));
terrDescr = checkNull(rs1.getString("LEVEL_DESCR"));
System.out.println("terrCode ::: "+terrCode+ " terrDescr :::: "+terrDescr);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
SalesConsolidationPrc scp =new SalesConsolidationPrc();
tranId=scp.generateTranIDForSalesConsolidationProcess("sales_consolidate", loginSiteCode, itemSer, conn);
sql1="insert into SALES_CONSOLIDATION(TRAN_ID,TRAN_DATE,CUST_CODE,PRD_CODE,TERR_CODE,TERR_DESCR,VERSION_ID,POS_CODE," +
"EMP_CODE,SOURCE,ITEM_CODE,UNIT,ITEM_SER,ITEM_SER_NEW,STAN_CODE,STAN_CODE_NEW," +
"NET_SALES_QTY,NET_SALES_VAL,LYCM_SALES_QTY,LYCM_SALES_VAL," +
"ADD_DATE,ADD_USER,ADD_TERM,CHG_DATE,CHG_USER,CHG_TERM)" +
"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
pstmt1.setDate(2, sysDate);
pstmt1.setString(3, custCode);
pstmt1.setString(4, prdCode);
pstmt1.setString(5, terrCode);
pstmt1.setString(6, terrDescr);
pstmt1.setString(7, versionId);
pstmt1.setString(8, posCode);
pstmt1.setString(9, empCode);
pstmt1.setString(10, "S");
pstmt1.setString(11, itemCode);
pstmt1.setString(12, unit);
pstmt1.setString(13, itemSer);
pstmt1.setString(14, itemSer);
pstmt1.setString(15, stanCode);
pstmt1.setString(16, stanCode);
pstmt1.setDouble(17, netSalesQty);
pstmt1.setDouble(18, netSalesVal);
pstmt1.setDouble(19, lycmSalesQty);
pstmt1.setDouble(20, lycmSalesVal);
pstmt1.setDate(21, sysDate);
pstmt1.setString(22, chgUser);
pstmt1.setString(23, chgTerm);
pstmt1.setDate(24, sysDate);
pstmt1.setString(25, chgUser);
pstmt1.setString(26, chgTerm);
updCnt = pstmt1.executeUpdate();
if(updCnt>0)
{
errString="";
System.out.println("Data inserted!!!");
}
else
{
System.out.println("Data insertion fail!!!");
errString = itmDBAccessEJB.getErrorString("", "VTDATAFAIL", "","", conn);
}
pstmt1.close();
pstmt1= null;
}
rs.close();
rs=null;
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
System.out.println("::::Exception::::"+this.getClass().getSimpleName()+":::::" + e.getMessage());
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("", "VTDATAFAIL", "","", conn);
}
finally
{
try
{
if (errString == null || errString.trim().length()==0)
{
System.out.println("Connection Commited");
errString = itmDBAccessEJB.getErrorString("", "VTDATASUCC","", "", conn);
conn.commit();
}
else
{
errString = itmDBAccessEJB.getErrorString("", "VTDATAFAIL","", "", conn);
}
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();
}
}
return errString;
}
private String checkNull(String input)
{
return input == null ? "" : input.trim();
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ProcessLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface PrimarySalesConsolidationPrcLocal extends ProcessLocal {
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ProcessRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface PrimarySalesConsolidationPrcRemote extends ProcessRemote{
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class SalesConsolidateIC extends ValidatorEJB implements SalesConsolidateICLocal , SalesConsolidateICRemote{
E12GenericUtility genericUtility= new E12GenericUtility();
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String editFlag,String xtraParams) throws RemoteException
{
System.out.println("In wfValData");
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = "";
try
{
System.out.println("currFrmXmlStr..." + currFrmXmlStr);
System.out.println("hdrFrmXmlStr..." + hdrFrmXmlStr);
System.out.println("allFrmXmlStr..." + allFrmXmlStr);
if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0))
{
currDom = parseString(currFrmXmlStr);
}
if ((hdrFrmXmlStr != null) && (hdrFrmXmlStr.trim().length() != 0))
{
hdrDom = parseString(hdrFrmXmlStr);
}
if ((allFrmXmlStr != null) && (allFrmXmlStr.trim().length() != 0))
{
allDom = parseString(allFrmXmlStr);
}
errString = wfValData(currDom, hdrDom, allDom, objContext, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception : [SalesConsolidateIC][wfValData(String currFrmXmlStr)] : ==>\n" + e.getMessage());
}
return errString;
}
public String wfValData(Document currDom, Document hdrDom, Document allDom,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
int count = 0;
String errString = "" , loginSiteCode = "" , userId ="" , errCode = "" , errorType = "" ;
String custCode = "" , itemCode = "" , unit = "" , posCode = "" , versionId = "" , terrCode = "" , empCode = "" ;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String childNodeName = "";
String sql = "";
int noOfChilds = 0;
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
int currentFormNo = 0;
int cnt = 0;
ConnDriver connDriver = null;
Node childNode = null;
String itemSer="" , prdCode = "" ;
System.out.println("Current DOM [" + genericUtility.serializeDom(currDom) + "]");
System.out.println("Header DOM [" + genericUtility.serializeDom(hdrDom) + "]");
System.out.println("Dom All [" + genericUtility.serializeDom(allDom) + "]");
try {
System.out.println("************xtraParams*************" + xtraParams);
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
//conn = getConnection();
System.out.println("In wfValData Secondary Sales Consolidate:::");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"));
System.out.println("**************loginCode************" + userId);
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
NodeList parentList = currDom.getElementsByTagName("Detail1");
NodeList childList = null;
System.out.println("hdrDom..." + hdrDom.toString());
switch (currentFormNo)
{
case 1:
{
childList = parentList.item(0).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item(ctr);
if (childNode.getNodeType() != 1)
{
continue;
}
childNodeName = childNode.getNodeName();
System.out.println("Editflag =" + editFlag);
System.out.println("parentList = " + parentList);
System.out.println("childList = " + childList);
if("cust_code".equalsIgnoreCase(childNodeName))
{
custCode = genericUtility.getColumnValue("cust_code", currDom);
System.out.println("CustCode :::::: "+custCode);
if(custCode == null || custCode.trim().length() == 0)
{
errList.add("VTNULLCUST");
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM CUSTOMER WHERE CUST_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VTERRCUST");
errFields.add(childNodeName.toLowerCase());
}
}
}
else if ("prd_code".equalsIgnoreCase(childNodeName))
{
prdCode = genericUtility.getColumnValue("prd_code", currDom);
System.out.println("Period Code :::::::: "+prdCode);
if(prdCode==null || prdCode.trim().length()==0)
{
errList.add("VMNULLPRD");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM PERIOD WHERE CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VTERRPRD");
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("emp_code".equalsIgnoreCase(childNodeName))
{
empCode = genericUtility.getColumnValue("emp_code", currDom);
System.out.println("empCode :::::: "+empCode);
if(empCode == null || empCode.trim().length() == 0)
{
errList.add("VTEMPNUL");
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VTERREMP");
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("item_ser".equalsIgnoreCase(childNodeName))
{
itemSer = genericUtility.getColumnValue("item_ser", currDom);
System.out.println("itemSer ::::::: "+itemSer);
if(itemSer == null || itemSer.trim().length()==0 )
{
errList.add("VMNULLSER");
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM ITEMSER WHERE ITEM_SER = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VTINVDIV");
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("version_id".equalsIgnoreCase(childNodeName))
{
versionId = checkNull(genericUtility.getColumnValue("version_id", currDom));
posCode = genericUtility.getColumnValue("pos_code", currDom);
itemSer = genericUtility.getColumnValue("item_ser", currDom);
System.out.println("versionId :::::: "+versionId);
if(versionId == null || versionId.length() == 0 )
{
errList.add("VTNULVERID");
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM VERSION WHERE VERSION_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, versionId);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VTERRVERID");
errFields.add(childNodeName.toLowerCase());
}
else
{
System.out.println("posCode :::::: "+posCode);
System.out.println("itemSer :::::: "+itemSer);
if(posCode != null && itemSer != null)
{
sql = "SELECT COUNT(*) AS COUNT FROM ORG_STRUCTURE WHERE VERSION_ID = ? AND POS_CODE = ? AND TABLE_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, versionId);
pstmt.setString(2, posCode);
pstmt.setString(3, itemSer);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VTNULLRCD");
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
else if("terr_code".equalsIgnoreCase(childNodeName))
{
terrCode = checkNull(genericUtility.getColumnValue("terr_code", currDom));
versionId = checkNull(genericUtility.getColumnValue("version_id", currDom));
itemSer = checkNull(genericUtility.getColumnValue("item_ser", currDom));
System.out.println("terrCode>>"+terrCode+">>versionId>>"+versionId+">>itemSer"+itemSer);
System.out.println("terrCode :::::: "+terrCode);
if(terrCode == null || terrCode.trim().length() == 0)
{
errList.add("VTNULTERR");
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM HIERARCHY WHERE LEVEL_CODE = ? AND VERSION_ID=? AND TABLE_NO=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, terrCode);
pstmt.setString(2, versionId);
pstmt.setString(3, itemSer);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VTNERRTERR");
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("item_code".equalsIgnoreCase(childNodeName))
{
itemCode = genericUtility.getColumnValue("item_code", currDom);
System.out.println("itemCode :::::: "+itemCode);
if(itemCode == null || itemCode.trim().length() == 0)
{
errList.add("VTNULLITCD");
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM ITEM WHERE ITEM_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VTERRITCD");
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("unit".equalsIgnoreCase(childNodeName))
{
unit = genericUtility.getColumnValue("unit", currDom);
System.out.println("unit :::::: "+unit);
if(unit == null || unit.trim().length() == 0)
{
errList.add("VTUNTNUL");
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM ITEM WHERE UNIT = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unit);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VTUNTINV");
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
break;
}
int errListSize = errList.size();
cnt = 0;
String errFldName = "";
if ((errList != null) && (errListSize > 0))
{
for (cnt = 0; cnt < errListSize; cnt++)
{
errCode = (String) errList.get(cnt);
errFldName = (String) errFields.get(cnt);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........." + errStringXml);
errString = "";
}
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer("");
}
errString = errStringXml.toString();
}
catch (Exception e)
{
System.out.println("Exception in "+this.getClass().getSimpleName()+" == >");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if ((conn != null) && (!conn.isClosed()))
conn.close();
}
catch (Exception e)
{
System.out.println("Exception :"+this.getClass().getSimpleName()+":wfValData :==>\n" + e.getMessage());
throw new ITMException(e);
}
}
return errString;
}
private String errorType(Connection conn, String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while (rs.next())
msgType = rs.getString("MSG_TYPE");
}
catch (Exception ex)
{
ex.printStackTrace();
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return msgType;
}
private String checkNull(String input)
{
return input == null ? "" : input.trim();
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
System.out.println("XmlString :::::::::: "+xmlString);
System.out.println("XmlString1 :::::::::: "+xmlString1);
System.out.println("XmlString2 :::::::::: "+xmlString2);
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
System.out.println("Dom ::::::: "+dom);
}
if (xmlString1 != null && xmlString1.trim().length() > 0) {
dom1 = parseString(xmlString1);
System.out.println("Dom1 ::::::: "+dom1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0) {
dom2 = parseString(xmlString2);
System.out.println("Dom2 ::::::: "+dom2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext,currentColumn, editFlag, xtraParams);
} catch (Exception e) {
System.out.println("Exception : [SalesConsolidate] :==>\n"+ e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException
{
int currentFormNo = 0;
StringBuffer valueXmlString = null;
String chgDate = "" , chgUser = "" , chgTerm = "";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null, columnValue = "";
int ctr = 0, childNodeListLength = 0 ;
String empCode = "" , tranDate = "" , unit="", custName = "" , empName="" , custCode = "" , itemCode = "" , terrCode="" , terrDescr="" , itemDescr = "" , sql = "";
String versionId="",itemSer="";
Timestamp sysDate = null ;
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = null;
try {
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf1.format(currentDate.getTime());
sysDate = Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())
+ " 00:00:00.0");
System.out.println("Current DOM [" + genericUtility.serializeDom(dom) + "]");
System.out.println("Header DOM [" + genericUtility.serializeDom(dom1) + "]");
System.out.println("Dom All [" + genericUtility.serializeDom(dom2) + "]");
System.out.println("CURRENT COLUMN:::::" + currentColumn);
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
java.util.Date currDate = new java.util.Date();
chgDate = sdf.format(currDate);
System.out.println("chgDate...[" + chgDate + "");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
tranDate = sdf.format(currDate);
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
currentColumn = checkNull(currentColumn).trim();
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("Driver");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
switch (currentFormNo) {
case 1:
{
System.out.println("Inside Case 1 Of Itemchange");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
do {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn)) {
if (childNode.getFirstChild() != null) {
columnValue = childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
} while (ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("current form::::::::::::" + currentFormNo);
if ( "itm_default".equalsIgnoreCase(currentColumn))
{
valueXmlString.append("<chg_date>").append("<![CDATA[" + chgDate + "]]>").append("</chg_date>");
valueXmlString.append("<chg_term>").append("<![CDATA[" + chgTerm + "]]>").append("</chg_term>");
valueXmlString.append("<chg_user>").append("<![CDATA[" + chgUser + "]]>").append("</chg_user>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + tranDate + "]]>").append("</tran_date>");
}
else if("emp_code".equalsIgnoreCase(currentColumn))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
System.out.println("empCode ::::: "+empCode);
if( empCode.length() > 0 )
{
sql = " SELECT EMP_FNAME||' '||EMP_MNAME||' '||EMP_LNAME AS EMP_NAME FROM EMPLOYEE WHERE EMP_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
empName = checkNull(rs.getString("EMP_NAME"));
System.out.println("empName :" +empName );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<emp_name>").append("<![CDATA[" + empName + "]]>").append("</emp_name>");
}
else
{
valueXmlString.append("<emp_name>").append("<![CDATA[]]>").append("</emp_name>");
}
}
else if ("cust_code".equalsIgnoreCase(currentColumn))
{
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
System.out.println("custCode ::::: "+custCode);
if( custCode.length() > 0 )
{
sql = " SELECT CUST_NAME FROM CUSTOMER WHERE CUST_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
custName = checkNull(rs.getString("CUST_NAME"));
System.out.println("custName :" +custName );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<cust_name>").append("<![CDATA[" + custName + "]]>").append("</cust_name>");
}
else
{
valueXmlString.append("<cust_name>").append("<![CDATA[]]>").append("</cust_name>");
}
}
else if ("item_code".equalsIgnoreCase(currentColumn))
{
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
System.out.println("itemCode ::::: "+itemCode);
if( itemCode.length() > 0 )
{
sql = " SELECT DESCR,UNIT FROM ITEM WHERE ITEM_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
itemDescr = checkNull(rs.getString("DESCR"));
unit = checkNull(rs.getString("UNIT"));
System.out.println("itemDescr :" +itemDescr );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
}
else
{
valueXmlString.append("<item_descr>").append("<![CDATA[]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA[]]>").append("</unit>");
}
}
else if("terr_code".equalsIgnoreCase(currentColumn))
{
terrCode = checkNull(genericUtility.getColumnValue("terr_code", dom));
versionId = checkNull(genericUtility.getColumnValue("version_id", dom));
itemSer = checkNull(genericUtility.getColumnValue("item_ser", dom));
System.out.println("terrCode>>"+terrCode+">>versionId>>"+versionId+">>itemSer"+itemSer);
if(terrCode.length()>0){
sql = "SELECT LEVEL_DESCR FROM HIERARCHY WHERE LEVEL_CODE =? AND VERSION_ID=? AND TABLE_NO=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, terrCode);
pstmt.setString(2, versionId);
pstmt.setString(3, itemSer);
rs = pstmt.executeQuery();
if(rs.next())
{
terrDescr = checkNull(rs.getString("LEVEL_DESCR"));
}
System.out.println("terrCode ::: "+terrCode+ " terrDescr :::: "+terrDescr);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<terr_descr>").append("<![CDATA["+terrDescr+"]]>").append("</terr_descr>");
}
else
{
valueXmlString.append("<terr_descr>").append("<![CDATA[]]>").append("</terr_descr>");
}
}
}
valueXmlString.append("</Detail1>");
break;
}
} catch (Exception e) {
try {
e.printStackTrace();
throw new ITMException(e);
} catch (Exception ex) {
ex.printStackTrace();
throw new ITMException(ex);
}
} finally {
try {
if (conn != null) {
conn.close();
conn = null;
}
if(rs != null )
{
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
valueXmlString.append("</Root>\r\n");
return valueXmlString.toString();
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface SalesConsolidateICLocal extends ValidatorLocal{
public String wfValData(String currXmlDataStr, String hdrXmlDataStr, String allXmlDataStr, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document currDom, Document hdrDom, Document allDom, 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 ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface SalesConsolidateICRemote extends ValidatorRemote{
public String wfValData(String currXmlDataStr, String hdrXmlDataStr, String allXmlDataStr, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document currDom, Document hdrDom, Document allDom, 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 java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class SalesConsolidationIC extends ValidatorEJB implements SalesConsolidationICLocal , SalesConsolidationICRemote
{
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String editFlag,String xtraParams) throws RemoteException
{
System.out.println("In wfValData");
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = "";
try
{
System.out.println("currFrmXmlStr..." + currFrmXmlStr);
System.out.println("hdrFrmXmlStr..." + hdrFrmXmlStr);
System.out.println("allFrmXmlStr..." + allFrmXmlStr);
if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0))
{
currDom = parseString(currFrmXmlStr);
}
if ((hdrFrmXmlStr != null) && (hdrFrmXmlStr.trim().length() != 0))
{
hdrDom = parseString(hdrFrmXmlStr);
}
if ((allFrmXmlStr != null) && (allFrmXmlStr.trim().length() != 0))
{
allDom = parseString(allFrmXmlStr);
}
errString = wfValData(currDom, hdrDom, allDom, objContext, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception : [SalesConsolidationIC][wfValData(String currFrmXmlStr)] : ==>\n" + e.getMessage());
}
return errString;
}
public String wfValData(Document currDom, Document hdrDom, Document allDom,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{
E12GenericUtility genericUtility= new E12GenericUtility();
String errString = "" , loginSiteCode = "" , userId ="" , isPrdClosed = "",overWrite="" ;
String childNodeName = "";
String sql = "";
int noOfChilds = 0;
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
int currentFormNo = 0;
int cnt = 0,count=0,unConfCnt=0,excnt=0;
ConnDriver connDriver = null;
Node childNode = null;
String itemSer="" , prdCode = "" ,maxPrdCode="" ,countryCode="" ;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try {
System.out.println("************xtraParams*************" + xtraParams);
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
System.out.println("In wfValData SalesConsolidationIC :::");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"));
System.out.println("**************loginCode************" + userId);
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
NodeList parentList = currDom.getElementsByTagName("Detail"+ currentFormNo);
NodeList childList = null;
System.out.println("hdrDom..." + hdrDom.toString());
switch (currentFormNo)
{
case 1:
{
childList = parentList.item(0).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item(ctr);
if (childNode.getNodeType() != 1)
{
continue;
}
childNodeName = childNode.getNodeName();
System.out.println("Editflag =" + editFlag);
System.out.println("parentList = " + parentList);
System.out.println("childList = " + childList);
if ("item_ser".equalsIgnoreCase(childNodeName))
{
itemSer = genericUtility.getColumnValue("item_ser", currDom);
System.out.println("wfValData>>itemSer>>"+itemSer);
if(itemSer == null || itemSer.trim().length()==0 )
{
errString = itmDBAccessEJB.getErrorString("item_ser","VMNULLDIV",userId);
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM ITEMSER WHERE ITEM_SER = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count: " + count);
if (count == 0)
{
errString = itmDBAccessEJB.getErrorString("item_ser","VTINVDIV",userId);
break;
}
}
}
else if ("overwrite".equalsIgnoreCase(childNodeName))
{
overWrite = genericUtility.getColumnValue("overwrite", currDom);
System.out.println("wfValData>>overWrite>>"+overWrite);
if("N".equalsIgnoreCase(overWrite))
{
sql = " SELECT COUNT(*) AS COUNT FROM SALES_CONSOLIDATION WHERE PRD_CODE = ? AND ITEM_SER=? AND SOURCE='E' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, itemSer);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("COUNT");
}
if(count > 0)
{
errString = itmDBAccessEJB.getErrorString("prd_code","VTDATA",userId);
break ;
}
}
}
else if ("prd_code".equalsIgnoreCase(childNodeName))
{
prdCode = genericUtility.getColumnValue("prd_code", currDom);
itemSer = genericUtility.getColumnValue("item_ser", currDom);
sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode );
rs = pstmt.executeQuery();
if(rs.next())
{
countryCode = checkNull(rs.getString("count_code")).trim();
System.out.println("countryCode >>> :"+countryCode);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("wfValData>>prdCode>>"+prdCode+">>itemSer"+itemSer);
if(prdCode == null || prdCode.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("prd_code","VMNULLPRD ",userId);
break ;
}
else
{
sql = " SELECT COUNT(*) FROM PERIOD A , PERIOD_TBL B WHERE A.CODE = B.PRD_CODE AND B.PRD_CODE = ? and B.PRD_TBLNO= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode);
pstmt.setString(2,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
System.out.println("Error :Period not exist in period_tbl master ");
errString = itmDBAccessEJB.getErrorString("","VMINVPRDTB",userId);
break ;
}
else
{
sql = "SELECT B.PRD_CLOSED FROM PERIOD A , PERIOD_TBL B WHERE A.CODE = B.PRD_CODE AND B.PRD_CODE = ? and B.PRD_TBLNO= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode.trim());
pstmt.setString(2,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
isPrdClosed = rs.getString("PRD_CLOSED");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if("N".equalsIgnoreCase(isPrdClosed))
{
errString = itmDBAccessEJB.getErrorString("","VMPRDNCL",userId);
break ;
}
else
{
sql="select max(prd_code) from period_tbl where PRD_TBLNO=? and PRD_CLOSED='Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
maxPrdCode = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(!prdCode.equalsIgnoreCase(maxPrdCode))
{
//max period check
errString = itmDBAccessEJB.getErrorString("","VTINVPCD",userId);
break ;
}
else
{
sql = " SELECT COUNT(*) AS COUNT FROM CUST_STOCK A JOIN CUST_STOCK_DET B ON A.TRAN_ID = B.TRAN_ID " +
" JOIN CUSTOMER D ON D.CUST_CODE = A.CUST_CODE WHERE A.PRD_CODE = ? and A.ITEM_SER=? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2,itemSer);
rs = pstmt.executeQuery();
if(rs.next())
{
excnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (excnt >= 0)
{
sql = "SELECT COUNT(*) AS COUNT FROM CUST_STOCK WHERE PRD_CODE = ? AND ITEM_SER=? AND STATUS='O' AND CONFIRMED='N'" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2,itemSer);
rs = pstmt.executeQuery();
if(rs.next())
{
unConfCnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(unConfCnt>0)
{
System.out.println("Unconfirmed records found ");
errString = itmDBAccessEJB.getErrorString("","VTINVRCD",userId);
break ;
}
}
else
{
System.out.println("No record found ");
errString = itmDBAccessEJB.getErrorString("","VTNULLRCD",userId);
break ;
}
}
}
}
}
}
}
}
break;
}
}
catch (Exception e)
{
System.out.println("Exception in "+this.getClass().getSimpleName()+" == >");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if ((conn != null) && (!conn.isClosed()))
conn.close();
}
catch (Exception e)
{
System.out.println("Exception :"+this.getClass().getSimpleName()+":wfValData :==>\n" + e.getMessage());
throw new ITMException(e);
}
}
return errString;
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
System.out.println("XmlString :::::::::: "+xmlString);
System.out.println("XmlString1 :::::::::: "+xmlString1);
System.out.println("XmlString2 :::::::::: "+xmlString2);
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
System.out.println("Dom ::::::: "+dom);
}
if (xmlString1 != null && xmlString1.trim().length() > 0) {
dom1 = parseString(xmlString1);
System.out.println("Dom1 ::::::: "+dom1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0) {
dom2 = parseString(xmlString2);
System.out.println("Dom2 ::::::: "+dom2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext,currentColumn, editFlag, xtraParams);
} catch (Exception e) {
System.out.println("Exception : [SalesConsolidation] :==>\n"+ e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document currDom, Document hdrDom, Document allDom,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException
{
E12GenericUtility genericUtility= new E12GenericUtility();
int currentFormNo = 0;
StringBuffer valueXmlString = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null, columnValue = "",maxPrdCode="",itemSer="",sql="",countryCode="",loginSiteCode="";
int ctr = 0, childNodeListLength = 0 ;
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = null;
try
{
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
currentColumn = checkNull(currentColumn);
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"));
switch (currentFormNo)
{
case 1:
{
System.out.println("Inside Case 1 Of Itemchange");
parentNodeList = currDom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr++;
}while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
System.out.println(" currentColumn : "+ currentColumn);
System.out.println("current form::::::::::::" + currentFormNo);
if ( "itm_default".equalsIgnoreCase(currentColumn))
{
valueXmlString.append("<prd_code>").append("").append("</prd_code>");
valueXmlString.append("<item_ser>").append("").append("</item_ser>");
valueXmlString.append("<overwrite>").append("<![CDATA[N]]>").append("</overwrite>");
}
else if ("item_ser".equalsIgnoreCase(currentColumn))
{
itemSer = checkNull(genericUtility.getColumnValue("item_ser", currDom));
System.out.println("itemSer>>>"+itemSer);
if(itemSer.trim().length()>0){
sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode );
rs = pstmt.executeQuery();
if(rs.next())
{
countryCode = checkNull(rs.getString("count_code")).trim();
System.out.println("countryCode >>> :"+countryCode);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql="select max(prd_code) from period_tbl where PRD_TBLNO=? and PRD_CLOSED='Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
maxPrdCode = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(maxPrdCode.length()>0)
{
valueXmlString.append("<prd_code>").append("<![CDATA[" + maxPrdCode + "]]>").append("</prd_code>");
}
else
{
valueXmlString.append("<prd_code>").append("<![CDATA[]]>").append("</prd_code>");
}
}
else
{
valueXmlString.append("<prd_code>").append("<![CDATA[]]>").append("</prd_code>");
}
}
valueXmlString.append("</Detail1>\r\n");
}
break;
}
}
catch (Exception e)
{
try
{
e.printStackTrace();
throw new ITMException(e);
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
}
finally
{
try {
if (conn != null) {
conn.close();
conn = null;
}
if(rs != null )
{
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
valueXmlString.append("</Root>\r\n");
return valueXmlString.toString();
}
private String checkNull(String input)
{
return input == null ? "" : input.trim();
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface SalesConsolidationICLocal 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 currDom, Document hdrDom, Document allDom,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface SalesConsolidationICRemote 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 currDom, Document hdrDom, Document allDom,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class SalesConsolidationPrc extends ProcessEJB implements SalesConsolidationPrcLocal , SalesConsolidationPrcRemote
{
E12GenericUtility genericUtility= new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
@Override
public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException
{
String rtStr = "";
Document dom = null;
Document dom2 = null;
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = genericUtility.parseString(xmlString);
System.out.println("Process Dom::::::::::::::::"+dom );
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
dom2 = genericUtility.parseString(xmlString2);
System.out.println("Process Dom2::::::::::::::::"+dom2 );
}
rtStr = process(dom, dom2, windowName, xtraParams);
} catch (Exception e) {
System.out.println("::::"+this.getClass().getSimpleName()+"::processDataString" + e.getMessage());
e.printStackTrace();
}
return rtStr;
}
@Override
public String process(Document dom, Document dom2, String windowName,String xtraParams) throws RemoteException, ITMException {
String errString = "", userID = "", prdCode = "" , itemSer = "" , tranId = "" , loginSiteCode = "" , sql = "" , sql1 = "" , userId = "" , xmlInEditMode = "" ,
unit = "" , empCode = "" , posCode = "" , custCode = "" , itemCode = "" , tranDateStr = "" , retString = "" , xmlParseStr = "" , versionId = ""
, stanCode = "" , stanCodeNew = "" , terrCode = "" , terrDescr = "" , lastYrPrdCode = "";
double opStock = 0.0 , clStock = 0.0 , OpValue = 0.0 , clValue = 0.0 , sales = 0.0 , salesValue = 0.0 , rcpBillQty = 0.0 , rcpBillVal = 0.0 , tranBillQty = 0.0,
tranBillVal = 0.0 , retQty = 0.0 , retVal = 0.0 , tranRepQty = 0.0 , tranRepVal = 0.0 , tranBonusQty = 0.0 , lastYrsSale = 0.0 , lastYrsSaleVal = 0.0
, tranBonusVal = 0.0 , rcpBonusQty = 0.0 ,rcpBonusVal=0.0, rcpRplQty = 0.0 , rcpRplVal = 0.0 , grossQty = 0.0 , grossRate=0.0 , grossVal = 0.0;
Connection conn=null;
int ctr = 0 , count = 0 , cnt = 0 , updCnt = 0 , period = 0;
String chgTerm="",chgUser="",overWrite="",countryCode="";
PreparedStatement pstmt = null , pstmt1 = null;
ResultSet rs = null , rs1 = null;
Timestamp tranDate = null , frDate = null , toDate = null ;
StringBuffer xmlBuff = null;
System.out.println("Current DOM [" + genericUtility.serializeDom(dom) + "]");
System.out.println("Header DOM [" + genericUtility.serializeDom(dom2) + "]");
java.sql.Date sysDate=null;
try {
System.out.println("In process Sales Consolidation:::");
userId = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "userID"));
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"));
prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom));
itemSer = checkNull(genericUtility.getColumnValue("item_ser", dom));
overWrite = checkNull(genericUtility.getColumnValue("overwrite", dom));
System.out.println("prdCode>>>"+prdCode+">>itemSer>>"+itemSer+">>overWrite>>"+overWrite);
System.out.println("userId : "+userId);
System.out.println("xtraParams ::: "+xtraParams);
ConnDriver con = new ConnDriver();
conn = con.getConnectDB("DriverITM");
sql1 = "select sysdate from dual";
pstmt = conn.prepareStatement(sql1);
rs = pstmt.executeQuery();
if (rs.next()) {
sysDate = rs.getDate(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode );
rs = pstmt.executeQuery();
if(rs.next())
{
countryCode = checkNull(rs.getString("count_code")).trim();
System.out.println("countryCode >>> :"+countryCode);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = " SELECT FR_DATE,TO_DATE FROM PERIOD_TBL WHERE PRD_CODE=? AND PRD_TBLNO=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
frDate = rs.getTimestamp("FR_DATE");
toDate = rs.getTimestamp("TO_DATE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("frDate :::"+frDate+">>toDate :::"+toDate);
sql = "SELECT VERSION_ID FROM VERSION WHERE EFF_FROM < = ? AND VALID_UPTO > = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, frDate);
pstmt.setTimestamp(2, toDate);
rs = pstmt.executeQuery();
if(rs.next())
{
versionId = checkNull(rs.getString("VERSION_ID"));
System.out.println("versionId ::: "+versionId);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if("Y".equalsIgnoreCase(overWrite)){
cnt=0;
sql = "DELETE FROM SALES_CONSOLIDATION WHERE PRD_CODE = ? AND ITEM_SER=? AND SOURCE='E'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, itemSer);
cnt=pstmt.executeUpdate();
System.out.println("Delete count>>"+cnt);
pstmt.close();
pstmt = null;
}
System.out.println("Inserting data ");
sql = " SELECT A.TRAN_ID , A.TRAN_DATE , A.PRD_CODE, A.FROM_DATE , A.TO_DATE , A.CUST_CODE , A.POS_CODE , A.ITEM_SER , A.EMP_CODE , B.ITEM_CODE , B.UNIT , B.OP_STOCK, B.OP_VALUE , " +
" B.PURC_RCP , B.RCP_VAL , B.TRANSIT_QTY , B.TRANSIT_BILL_VAL , B.PURC_RCP__REPL , B.RCP_REPL_VAL , B.TRANSIT_QTY__REPL , B.TRANSIT_REPL_VAL," +
" B.CL_STOCK , B.CL_VALUE , B.PURC_RET , B.RET_VAL , B.SALES , B.SALES_VALUE , B.PURC_RCP__FREE , B.RCP_FREE_VAL , B.TRANSIT_QTY__FREE," +
" B.TRANSIT_FREE_VAL , B.SALES__ORG , B.RATE__ORG , D.STAN_CODE FROM CUST_STOCK A JOIN CUST_STOCK_DET B ON A.TRAN_ID = B.TRAN_ID " +
" JOIN CUSTOMER D ON D.CUST_CODE = A.CUST_CODE WHERE A.PRD_CODE = ? AND A.ITEM_SER=? AND A.POS_CODE IS NOT NULL " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, itemSer);
rs = pstmt.executeQuery();
while(rs.next())
{
prdCode = checkNull(rs.getString("PRD_CODE"));
custCode = checkNull(rs.getString("CUST_CODE"));
itemSer = checkNull(rs.getString("ITEM_SER"));
empCode = checkNull(rs.getString("EMP_CODE"));
posCode = checkNull(rs.getString("POS_CODE"));
itemCode = checkNull(rs.getString("ITEM_CODE"));
frDate = rs.getTimestamp("FROM_DATE");
toDate = rs.getTimestamp("TO_DATE");
unit = checkNull(rs.getString("UNIT"));
stanCode = checkNull(rs.getString("STAN_CODE"));
opStock = rs.getDouble("OP_STOCK");
OpValue = rs.getDouble("OP_VALUE");
rcpBillQty = rs.getDouble("PURC_RCP");
rcpBillVal = rs.getDouble("RCP_VAL");
tranBillQty = rs.getDouble("TRANSIT_QTY");
tranBillVal = rs.getDouble("TRANSIT_BILL_VAL");
rcpRplQty = rs.getDouble("PURC_RCP__REPL");
rcpRplVal = rs.getDouble("RCP_REPL_VAL");
tranRepQty = rs.getDouble("TRANSIT_QTY__REPL");
tranRepVal = rs.getDouble("TRANSIT_REPL_VAL");
clStock = rs.getDouble("CL_STOCK");
clValue = rs.getDouble("CL_VALUE");
retQty = rs.getDouble("PURC_RET");
retVal = rs.getDouble("RET_VAL");
sales = rs.getDouble("SALES");
salesValue = rs.getDouble("SALES_VALUE");
grossQty = rs.getDouble("SALES__ORG");
grossRate = rs.getDouble("RATE__ORG");
rcpBonusQty = rs.getDouble("PURC_RCP__FREE");
rcpBonusVal = rs.getDouble("RCP_FREE_VAL");
tranBonusQty = rs.getDouble("TRANSIT_QTY__FREE");
tranBonusVal = rs.getDouble("TRANSIT_FREE_VAL");
cnt ++ ;
grossVal=0.0;
grossVal = grossQty*grossRate;
System.out.println("grossVal :::::::: "+grossVal);
System.out.println("grossQty :::::::: "+grossQty);
System.out.println("prdCode ::: "+prdCode);
System.out.println("custCode ::: "+custCode);
System.out.println("itemSer ::: "+itemSer);
System.out.println("empCode ::: "+empCode);
System.out.println("posCode ::: "+posCode);
System.out.println("itemCode ::: "+itemCode);
System.out.println("unit ::: "+unit);
System.out.println("stanCode ::: "+stanCode);
System.out.println("frDate ::: "+frDate);
System.out.println("toDate ::: "+toDate);
/*versionId="";
sql1 = "SELECT VERSION_ID FROM VERSION WHERE EFF_FROM < = ? AND VALID_UPTO > = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1, frDate);
pstmt1.setTimestamp(2, toDate);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
versionId = checkNull(rs1.getString("VERSION_ID"));
System.out.println("versionId ::: "+versionId);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;*/
terrCode="";terrDescr="";
sql1 = " SELECT A.POOL_CODE , B.LEVEL_CODE , B.LEVEL_DESCR FROM ORG_STRUCTURE A , HIERARCHY " +
" B WHERE A.POOL_CODE = B.LEVEL_CODE AND A.VERSION_ID = ? AND A.POS_CODE = ? AND A.TABLE_NO = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, versionId);
pstmt1.setString(2, posCode);
pstmt1.setString(3, itemSer);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
terrCode = checkNull(rs1.getString("LEVEL_CODE"));
terrDescr = checkNull(rs1.getString("LEVEL_DESCR"));
System.out.println("terrCode ::: "+terrCode+ " terrDescr :::: "+terrDescr);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
lastYrsSale=0.0;lastYrsSaleVal=0.0;
period = Integer.parseInt(prdCode);
period = period - 100;
System.out.println("period :::: "+period);
lastYrPrdCode = period+"";
System.out.println("lastYrPrdCode :::: "+lastYrPrdCode);
sql1 = " SELECT B.SALES , B.SALES_VALUE FROM CUST_STOCK A , CUST_STOCK_DET B WHERE A.TRAN_ID = B.TRAN_ID AND " +
" A.CUST_CODE = ? AND B.ITEM_CODE = ? AND A.ITEM_SER = ? AND A.PRD_CODE = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, custCode);
pstmt1.setString(2, itemCode);
pstmt1.setString(3, itemSer);
pstmt1.setString(4, lastYrPrdCode.trim());
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
lastYrsSale = rs.getDouble("SALES");
lastYrsSaleVal = rs.getDouble("SALES_VALUE");
System.out.println("lastYrPrdCode ::::: "+lastYrPrdCode+"lastYrsSale ::: "+lastYrsSale+ "lastYrsSaleVal :::: "+lastYrsSaleVal);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
lastYrPrdCode = "";
tranId=generateTranIDForSalesConsolidationProcess("sales_consolidate",loginSiteCode,itemSer,conn);
sql1="insert into SALES_CONSOLIDATION(TRAN_ID,TRAN_DATE,CUST_CODE,PRD_CODE,TERR_CODE,TERR_DESCR,VERSION_ID,POS_CODE," +
"EMP_CODE,SOURCE,ITEM_CODE,UNIT,ITEM_SER,ITEM_SER_NEW,STAN_CODE,STAN_CODE_NEW," +
"OP_STOCK,OP_VALUE,PURC_RCP,PUR_VALUE,TRANSIT_QTY,TRANSIT_BILL_VAL,PURC_RCP__REPL,RCP_REPL_VAL,TRANSIT_QTY__REPL," +
"TRANSIT_REPL_VAL,CL_STOCK,CL_VALUE,PURC_RET,RET_VAL,SALES,SALES_VALUE," +
"PURC_RCP__FREE,RCP_FREE_VAL,TRANSIT_QTY__FREE,TRANSIT_FREE_VAL,GROSS_SALES_QTY,GROSS_SALES_VAL," +
//"NET_SALES_QTY,NET_SALES_VAL,LYCM_SALES_QTY,LYCM_SALES_VAL," +
"LYSLS_SALES_QTY,LYSLS_SALES_VAL," +
//"REMARKS1,REMARKS2,REMARKS3,REMARKS4," +
"ADD_DATE,ADD_USER,ADD_TERM,CHG_DATE,CHG_USER,CHG_TERM)" +
"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
pstmt1.setDate(2, sysDate);
pstmt1.setString(3, custCode);
pstmt1.setString(4, prdCode);
pstmt1.setString(5, terrCode);
pstmt1.setString(6, terrDescr);
pstmt1.setString(7, versionId);
pstmt1.setString(8, posCode);
pstmt1.setString(9, empCode);
pstmt1.setString(10, "E");
pstmt1.setString(11, itemCode);
pstmt1.setString(12, unit);
pstmt1.setString(13, itemSer);
pstmt1.setString(14, itemSer);
pstmt1.setString(15, stanCode);
pstmt1.setString(16, stanCode);
pstmt1.setDouble(17, opStock);
pstmt1.setDouble(18, OpValue);
pstmt1.setDouble(19, rcpBillQty);
pstmt1.setDouble(20, rcpBillVal);
pstmt1.setDouble(21, tranBillQty);
pstmt1.setDouble(22, tranBillVal);
pstmt1.setDouble(23, rcpRplQty);
pstmt1.setDouble(24, rcpRplVal);
pstmt1.setDouble(25, tranRepQty);
pstmt1.setDouble(26, tranRepVal);
pstmt1.setDouble(27, clStock);
pstmt1.setDouble(28, clValue);
pstmt1.setDouble(29, retQty);
pstmt1.setDouble(30, retVal);
pstmt1.setDouble(31, sales);
pstmt1.setDouble(32, salesValue);
pstmt1.setDouble(33, rcpBonusQty);
pstmt1.setDouble(34, rcpBonusVal);
pstmt1.setDouble(35, tranBonusQty);
pstmt1.setDouble(36, tranBonusVal);
pstmt1.setDouble(37, grossQty);
pstmt1.setDouble(38, grossVal);//
//NET_SALES_QTY,NET_SALES_VAL,LYCM_SALES_QTY,LYCM_SALES_VAL,
pstmt1.setDouble(39, lastYrsSale);
pstmt1.setDouble(40, lastYrsSaleVal);
//REMARKS1,REMARKS2,REMARKS3,REMARKS4,
pstmt1.setDate(41, sysDate);
pstmt1.setString(42, chgUser);
pstmt1.setString(43, chgTerm);
pstmt1.setDate(44, sysDate);
pstmt1.setString(45, chgUser);
pstmt1.setString(46, chgTerm);
updCnt = pstmt1.executeUpdate();
if(updCnt>0)
{
errString="";
System.out.println("Data inserted!!!");
}
else
{
System.out.println("Data insertion fail!!!");
errString = itmDBAccessEJB.getErrorString("", "VTDATAFAIL", "","", conn);
}
pstmt1.close();
pstmt1= null;
}
rs.close();
rs=null;
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
System.out.println("::::Exception::::"+this.getClass().getSimpleName()+":::::" + e.getMessage());
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("", "VTDATAFAIL", "","", conn);
}
finally
{
try
{
if (errString == null || errString.trim().length()==0)
{
System.out.println("Connection Commited");
errString = itmDBAccessEJB.getErrorString("", "VTDATASUCC","", "", conn);
conn.commit();
}
else
{
errString = itmDBAccessEJB.getErrorString("", "VTDATAFAIL","", "", conn);
}
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();
}
}
return errString;
}
public String generateTranIDForSalesConsolidationProcess(String objName,String loginSiteCode,String itemSer,Connection conn) throws ITMException
{
String retString = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String keyString = "", refSer = "",sysDate="";
E12GenericUtility genericUtility =new E12GenericUtility();
try
{
SimpleDateFormat sdf= new SimpleDateFormat(genericUtility.getApplDateFormat());
sysDate = sdf.format(new java.util.Date());
System.out.println("SalesConsolidationProcess-ES3 :: objName =>"+objName);
HashMap<String, String> transetupMap = new HashMap<String, String>();
transetupMap = getTransetupMap("w_"+objName, conn);
keyString = (String)transetupMap.get("key_string");
refSer = (String)transetupMap.get("ref_ser");
String xmlValues = "";
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<TRAN_ID></TRAN_ID>";
xmlValues = xmlValues + "<TRAN_DATE>"+sysDate+"</TRAN_DATE>";
xmlValues = xmlValues + "<SITE_CODE>"+loginSiteCode+"</SITE_CODE>";
xmlValues = xmlValues + "<ITEM_SER>"+itemSer+"</ITEM_SER>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues for Sales Consolidation :["+xmlValues+"]");
System.out.println("keyString>>>>"+keyString+">>>refSer>>>"+refSer);
TransIDGenerator tranIdGenerator = new TransIDGenerator(xmlValues, "SYSTEM", CommonConstants.DB_NAME);
String tranIdGenerated = tranIdGenerator.generateTranSeqID(refSer, "tran_id", keyString, conn);
System.out.println("tranIdGenerated for SalesConsolidationProcess-ES3 => "+tranIdGenerated);
retString = tranIdGenerated;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
return retString;
}
private HashMap<String, String> getTransetupMap(String winName, Connection conn) throws ITMException
{
String keyString = "";
String refSer = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
HashMap<String, String> transetupMap = null;
try
{
sql = "SELECT KEY_STRING, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, winName);
rs = pstmt.executeQuery();
if(rs.next())
{
keyString = rs.getString("KEY_STRING") ;
refSer = rs.getString("REF_SER");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("ITWizardBean :: getKeyString :: keyString =>"+keyString);
System.out.println("ITWizardBean :: getKeyString :: refSer =>"+refSer);
transetupMap = new HashMap<String, String>();
transetupMap.put("key_string", keyString);
transetupMap.put("ref_ser", refSer);
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
return transetupMap;
}
private String checkNull(String input)
{
return input == null ? "" : input.trim();
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ProcessLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface SalesConsolidationPrcLocal extends ProcessLocal {
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ProcessRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface SalesConsolidationPrcRemote extends ProcessRemote{
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
/**
* @author Saurabh Jarande[24/03/17]
* This component is used to create Secondary sales transactions by process after Period closed.
*
*/
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -20,11 +25,10 @@ import org.w3c.dom.Node; ...@@ -20,11 +25,10 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
@Stateless @Stateless
public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,SecSalesGenIcLocal { public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,SecSalesGenIcLocal
{
GenericUtility genericUtility = GenericUtility.getInstance(); E12GenericUtility genericUtility =new E12GenericUtility();
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String editFlag,String xtraParams) throws RemoteException
{ {
System.out.println("In wfValData"); System.out.println("In wfValData");
Document currDom = null; Document currDom = null;
...@@ -52,7 +56,8 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S ...@@ -52,7 +56,8 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println("Exception : [SecSalesGenIc][wfValData(String currFrmXmlStr)] : ==>\n" + e.getMessage()); System.out.println("::::Exception::::"+this.getClass().getSimpleName()+":::::" + e.getMessage());
throw new ITMException(e);
} }
return errString; return errString;
} }
...@@ -60,32 +65,22 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S ...@@ -60,32 +65,22 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S
public String validate(Document currDom, Document hdrDom, Document allDom,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException public String validate(Document currDom, Document hdrDom, Document allDom,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{ {
System.out.println("In validate Data"); System.out.println("In validate Data");
GenericUtility genericUtility = GenericUtility.getInstance();
ArrayList<String> errList = new ArrayList<String>(); ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>();
int count = 0;
String errString = "";
String errorType = "";
String errCode = "";
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String childNodeName = ""; int noOfChilds = 0,excnt=0,currentFormNo = 0,cnt = 0, count = 0;
String sql = "";
int noOfChilds = 0;
ResultSet rs = null; ResultSet rs = null;
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
int currentFormNo = 0;
int cnt = 0;
ConnDriver connDriver = null; ConnDriver connDriver = null;
Node childNode = null; Node childNode = null;
Timestamp frDate=null,toDate=null; Timestamp frDate=null,toDate=null;
String itemSer="",prdCode="",loginSiteCode = "",countryCode="",isPrdClosed=""; String errString = "", errorType = "", errCode = "",maxPrdCode="", itemSer="",prdCode="",
loginSiteCode = "",countryCode="",isPrdClosed="",childNodeName = "", sql = "";
try { try {
System.out.println("************xtraParams*************" + xtraParams); System.out.println("************xtraParams*************" + xtraParams);
connDriver = new ConnDriver(); connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
System.out.println("In wfValData Distribution receipt:::");
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode")); loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"));
System.out.println("**************loginCode************" + userId); System.out.println("**************loginCode************" + userId);
...@@ -114,29 +109,18 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S ...@@ -114,29 +109,18 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S
System.out.println("Editflag =" + editFlag); System.out.println("Editflag =" + editFlag);
System.out.println("parentList = " + parentList); System.out.println("parentList = " + parentList);
System.out.println("childList = " + childList); System.out.println("childList = " + childList);
if ("prd_code".equalsIgnoreCase(childNodeName) ) if ("item_ser".equalsIgnoreCase(childNodeName))
{
prdCode = checkNull(genericUtility.getColumnValue("prd_code", currDom));
if(prdCode==null || prdCode.trim().length()==0)
{
errList.add("VTNULLPCG");//Invalid-Period code can not be blank
errFields.add(childNodeName.toLowerCase());
break;
}
}
if ("item_ser".equalsIgnoreCase(childNodeName) )
{ {
itemSer = checkNull(genericUtility.getColumnValue("item_ser", currDom)); itemSer = genericUtility.getColumnValue("item_ser", currDom);
prdCode = checkNull(genericUtility.getColumnValue("prd_code", currDom)); System.out.println("wfValData>>itemSer>>"+itemSer);
if(itemSer==null || itemSer.trim().length()==0) if(itemSer == null || itemSer.trim().length()==0 )
{ {
errList.add("VTNULLDVG");//Invalid-Division can not be blank errList.add("VMNULLDIV");
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
break; break;
} }
else if(itemSer!=null || itemSer.trim().length()>0) else
{ {
sql = "SELECT COUNT(*) AS COUNT FROM ITEMSER WHERE ITEM_SER = ? "; sql = "SELECT COUNT(*) AS COUNT FROM ITEMSER WHERE ITEM_SER = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer); pstmt.setString(1, itemSer);
...@@ -152,33 +136,42 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S ...@@ -152,33 +136,42 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S
System.out.println("Count: " + count); System.out.println("Count: " + count);
if (count == 0) if (count == 0)
{ {
errList.add("VTINVDVG");//Invalid-Division Does not exist errList.add("VTINVDIV");
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
break; break;
} }
}
sql= "select count_code from state where " + }
"state_code in (select state_code from site where site_code=?)"; else if ("prd_code".equalsIgnoreCase(childNodeName))
pstmt = conn.prepareStatement(sql); {
pstmt.setString(1, loginSiteCode ); prdCode = genericUtility.getColumnValue("prd_code", currDom);
rs = pstmt.executeQuery(); itemSer = genericUtility.getColumnValue("item_ser", currDom);
if(rs.next()) sql= "select count_code from state where " +
{ "state_code in (select state_code from site where site_code=?)";
countryCode = checkNull(rs.getString("count_code")).trim(); pstmt = conn.prepareStatement(sql);
System.out.println("countryCode >>> :"+countryCode); pstmt.setString(1, loginSiteCode );
} rs = pstmt.executeQuery();
rs.close(); if(rs.next())
rs = null; {
pstmt.close(); countryCode = checkNull(rs.getString("count_code")).trim();
pstmt = null; System.out.println("countryCode >>> :"+countryCode);
}
sql = "select count(*) from period_appl a,period_tbl b " + rs.close();
"where a.ref_code=a.prd_tblno and a.prd_tblno=b.prd_tblno " + rs = null;
" AND b.prd_code = ? " + pstmt.close();
"and b.prd_tblno=? " + pstmt = null;
"AND case when a.type is null then 'X' else a.type end='S' "; System.out.println("wfValData>>prdCode>>"+prdCode+">>itemSer"+itemSer);
if(prdCode == null || prdCode.trim().length() == 0)
{
errList.add("VMNULLPRD");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = " SELECT COUNT(*) FROM PERIOD A , PERIOD_TBL B WHERE A.CODE = B.PRD_CODE AND B.PRD_CODE = ? and B.PRD_TBLNO= ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode.trim()); pstmt.setString(1,prdCode);
pstmt.setString(2,countryCode+"_"+itemSer.trim()); pstmt.setString(2,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
...@@ -192,70 +185,90 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S ...@@ -192,70 +185,90 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S
if (cnt == 0) if (cnt == 0)
{ {
System.out.println("Error :Period not exist in period_tbl master "); System.out.println("Error :Period not exist in period_tbl master ");
errCode = "VTINVPCG"; errList.add("VMINVPRDTB");
errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
break;
} }
else else
{ {
sql = "select b.FR_DATE as FR_DATE,b.TO_DATE as TO_DATE " + sql = " SELECT B.PRD_CLOSED,B.FR_DATE,B.TO_DATE FROM PERIOD A , PERIOD_TBL B " +
",b.entry_start_dt as entry_start_dt" + " WHERE A.CODE = B.PRD_CODE AND B.PRD_CODE = ? and B.PRD_TBLNO= ? ";
",b.entry_end_dt as entry_end_dt ,b.prd_closed" +
" from period_appl a,period_tbl b " +
"where a.ref_code=a.prd_tblno and a.prd_tblno=b.prd_tblno " +
" AND b.prd_code = ? " +
"and b.prd_tblno=? " +
"AND case when a.type is null then 'X' else a.type end='S' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode.trim()); pstmt.setString(1,prdCode.trim());
pstmt.setString(2,countryCode+"_"+itemSer.trim()); pstmt.setString(2,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
isPrdClosed = rs.getString("PRD_CLOSED");
frDate=rs.getTimestamp("FR_DATE"); frDate=rs.getTimestamp("FR_DATE");
toDate=rs.getTimestamp("TO_DATE"); toDate=rs.getTimestamp("TO_DATE");
isPrdClosed = rs.getString("prd_closed");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if("N".equalsIgnoreCase(isPrdClosed)) if("N".equalsIgnoreCase(isPrdClosed))
{ {
errCode = "VMPRDNCL"; errList.add("VMPRDNCL");
errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
break;
} }
} else
{
} sql="select max(prd_code) from period_tbl where PRD_TBLNO=? and PRD_CLOSED='Y' ";
if((itemSer!=null || itemSer.trim().length()>0) && (prdCode!=null || prdCode.trim().length()>0))
{
sql = "SELECT count(*) FROM" +
" (SELECT POS_CODE,CUST_CODE FROM ORG_STRUCTURE_CUST WHERE VERSION_ID = (SELECT FN_GET_VERSION_ID FROM DUAL) AND TABLE_NO= ? " +
" AND EFF_DATE < ? AND VALID_UPTO > ? and case when source is null then 'Y' else source end <> 'A' " +
" MINUS " +
" SELECT POS_CODE,CUST_CODE FROM CUST_STOCK WHERE PRD_CODE = ? AND POS_CODE IS NOT NULL AND ITEM_SER = ? ) ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer); pstmt.setString(1,countryCode+"_"+itemSer.trim());
pstmt.setTimestamp(2, frDate);
pstmt.setTimestamp(3, toDate);
pstmt.setString(4, prdCode);
pstmt.setString(5, itemSer);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if(rs.next())
{ {
count = rs.getInt(1); maxPrdCode = rs.getString(1);
} }
System.out.println("Count: " + count); rs.close();
if (count == 0) rs = null;
{ pstmt.close();
errList.add("VTINVSELG");//Record Not found pstmt = null;
errFields.add(childNodeName.toLowerCase()); if(!prdCode.equalsIgnoreCase(maxPrdCode))
break; {
//max period check
errList.add("VTINVPCD");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = " SELECT COUNT(*) AS COUNT FROM ( " +
" SELECT C.CUST_CODE FROM ORG_STRUCTURE A ,ORG_STRUCTURE_CUST C " +
" WHERE A.VERSION_ID=C.VERSION_ID AND A.TABLE_NO=C.TABLE_NO AND A.POS_CODE=C.POS_CODE " +
" AND C.VERSION_ID = (SELECT FN_GET_VERSION_ID FROM DUAL) AND C.TABLE_NO= ? " +
" AND C.EFF_DATE <= ? AND C.VALID_UPTO >= ? AND CASE WHEN C.SOURCE IS NULL THEN 'Y' ELSE C.SOURCE END <> 'A' " +
" MINUS " +
" SELECT CUST_CODE FROM CUST_STOCK WHERE PRD_CODE = ? AND POS_CODE IS NOT NULL AND ITEM_SER = ? ) " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
pstmt.setTimestamp(2, frDate);
pstmt.setTimestamp(3, toDate);
pstmt.setString(4, prdCode);
pstmt.setString(5, itemSer);
rs = pstmt.executeQuery();
if(rs.next())
{
excnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (excnt == 0)
{
System.out.println("No record found ");
errList.add("VTNULLRCD");
errFields.add(childNodeName.toLowerCase());
break;
}
}
} }
}
} }
} }
}//for }//for
...@@ -278,7 +291,7 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S ...@@ -278,7 +291,7 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>")); String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>")); bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); errStringXml.append(bifurErrString);
System.out.println("errStringXml .........." + errStringXml); System.out.println("cc" + errStringXml);
errString = ""; errString = "";
} }
if (errorType.equalsIgnoreCase("E")) if (errorType.equalsIgnoreCase("E"))
...@@ -308,9 +321,21 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S ...@@ -308,9 +321,21 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S
{ {
try try
{ {
callPstRs(pstmt, rs); if (conn != null)
if ((conn != null) && (!conn.isClosed())) {
conn.close(); conn.close();
conn = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -321,6 +346,174 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S ...@@ -321,6 +346,174 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S
return errString; return errString;
} }
public String itemChanged(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = null;
try
{
if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0))
{
currDom = genericUtility.parseString(currFrmXmlStr);
System.out.println("currFrmXmlStr : " + currFrmXmlStr);
}
if ((hdrFrmXmlStr != null) && (hdrFrmXmlStr.trim().length() != 0))
{
hdrDom = genericUtility.parseString(hdrFrmXmlStr);
System.out.println("hdrFrmXmlStr : " + hdrFrmXmlStr);
}
if ((allFrmXmlStr != null) && (allFrmXmlStr.trim().length() != 0))
{
allDom = genericUtility.parseString(allFrmXmlStr);
System.out.println("allFrmXmlStr : " + allFrmXmlStr);
}
errString = itemChanged(currDom, hdrDom, allDom, objContext,currentColumn, editFlag, xtraParams);
System.out.println("ErrString :" + errString);
}
catch (Exception e)
{
System.out.println("Exception :"+this.getClass().getSimpleName()+":itemChanged :==>\n" + e.getMessage());
errString = genericUtility.createErrorString(e);
throw new ITMException(e);
}
return errString;
}
public String itemChanged(Document currDom, Document hdrDom,Document allDom, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
int currentFormNo = 0;
String childNodeName = null;
int ctr = 0;
int childNodeListLength = 0;
Connection conn = null;
StringBuffer valueXmlString = new StringBuffer();
String itemSer="",sql="",countryCode="",maxPrdCode="";
PreparedStatement pstmt=null;
ResultSet rs=null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>");
valueXmlString.append(editFlag).append("</editFlag>\r\n</Header>\r\n");
System.out.println("currentFormNo-------*************** = "+ currentFormNo);
switch (currentFormNo)
{
case 1:
parentNodeList = currDom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr++;
}while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
System.out.println(" currentColumn : "+ currentColumn);
if ( "itm_default".equalsIgnoreCase(currentColumn))
{
valueXmlString.append("<prd_code>").append("").append("</prd_code>");
valueXmlString.append("<item_ser>").append("").append("</item_ser>");
}
else if ("item_ser".equalsIgnoreCase(currentColumn))
{
itemSer = checkNull(genericUtility.getColumnValue("item_ser", currDom));
System.out.println("itemSer>>>"+itemSer);
if(itemSer.trim().length()>0)
{
sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode );
rs = pstmt.executeQuery();
if(rs.next())
{
countryCode = checkNull(rs.getString("count_code")).trim();
System.out.println("countryCode >>> :"+countryCode);
}
callPstRs(pstmt, rs);
sql="select max(prd_code) from period_tbl where PRD_TBLNO=? and PRD_CLOSED='Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
maxPrdCode = checkNull(rs.getString(1));
}
callPstRs(pstmt, rs);
if(maxPrdCode.length()>0)
{
valueXmlString.append("<prd_code>").append("<![CDATA[" + maxPrdCode + "]]>").append("</prd_code>");
}
else
{
valueXmlString.append("<prd_code>").append("<![CDATA[]]>").append("</prd_code>");
}
}
else
{
valueXmlString.append("<prd_code>").append("<![CDATA[]]>").append("</prd_code>");
}
}
valueXmlString.append("</Detail1>\r\n");
}
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception :"+this.getClass().getSimpleName()+":itemChanged :==>\n" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
conn.close();
conn = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
throw new ITMException(e);
}
}
valueXmlString.append("</Root>\r\n");
System.out.println("\n****ValueXmlString :" + valueXmlString.toString()+ ":********");
return valueXmlString.toString();
}
public void callPstRs(PreparedStatement pstmt, ResultSet rs) public void callPstRs(PreparedStatement pstmt, ResultSet rs)
{ {
...@@ -359,39 +552,14 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S ...@@ -359,39 +552,14 @@ public class SecSalesGenIc extends ValidatorEJB implements SecSalesGenIcRemote,S
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode); pstmt.setString(1, errorCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next()){
msgType = rs.getString("MSG_TYPE"); msgType = rs.getString("MSG_TYPE");
}
callPstRs(pstmt, rs);
} }
catch (Exception ex) catch (Exception ex)
{ {
ex.printStackTrace(); ex.printStackTrace();
try
{
callPstRs(pstmt, rs);
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
callPstRs(pstmt, rs);
}
catch (Exception e)
{
e.printStackTrace();
}
}
finally
{
try
{
callPstRs(pstmt, rs);
}
catch (Exception e)
{
e.printStackTrace();
}
} }
return msgType; return msgType;
} }
......
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import javax.ejb.Local; import javax.ejb.Local;
@Local @Local
public interface SecSalesGenIcLocal public interface SecSalesGenIcLocal extends ValidatorLocal
{ {
public abstract String wfValData(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) throws RemoteException; public String wfValData(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) throws RemoteException,ITMException;
public String itemChanged(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException;
} }
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import javax.ejb.Remote; import javax.ejb.Remote;
@Remote @Remote
public interface SecSalesGenIcRemote { public interface SecSalesGenIcRemote extends ValidatorRemote
public abstract String wfValData(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) throws RemoteException; {
public String wfValData(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) throws RemoteException,ITMException;
public String itemChanged(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException;
} }
...@@ -6,8 +6,10 @@ import ibase.utility.CommonConstants; ...@@ -6,8 +6,10 @@ import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean; import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterDataStatefulLocal;
import ibase.webitm.ejb.MasterStatefulLocal; import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ProcessEJB; import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.dis.adv.CustStockGWTConf;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.io.File; import java.io.File;
...@@ -16,6 +18,7 @@ import java.rmi.RemoteException; ...@@ -16,6 +18,7 @@ import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -29,14 +32,212 @@ import org.w3c.dom.NamedNodeMap; ...@@ -29,14 +32,212 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
/**
* @author Saurabh Jarande[24/03/17]
* This component is used to create Secondary sales transactions by process after Period closed.
*
*/
@Stateless @Stateless
public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,SecSalesGenPrcRemote { public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,SecSalesGenPrcRemote
{
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
Connection conn = null; public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException, ITMException
String loginCode = null; {
String errorString = null; String rtStr = "";
static String jBossHome = CommonConstants.JBOSSHOME; Document dom = null;
Document dom2 = null;
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
dom = genericUtility.parseString(xmlString2);
}
rtStr = getData(dom, dom2, windowName, xtraParams);
} catch (Exception e) {
System.out.println("::::"+this.getClass().getSimpleName()+"::getDataString" + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return rtStr;
}
@Override
public String getData(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException, ITMException
{
String errString = "";
String sql = "";
StringBuffer retTabSepStrBuff = new StringBuffer();
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null,rs1 = null;
Connection conn = null;
String custCode="",custName="",prdCode="",sysDate="",itemSer="",countryCode="",empCode="",empName="",posCode="",blacklisted="",posCodeDescr="";
Timestamp frDate=null,toDate=null;
SimpleDateFormat sdf=null;
String loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
try {
ConnDriver con = new ConnDriver();
conn = con.getConnectDB("DriverITM");
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("In getdata Station update process:::");
prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom));
itemSer = checkNull(genericUtility.getColumnValue("item_ser", dom));
sysDate = sdf.format(Calendar.getInstance().getTime());
retTabSepStrBuff.append("<?xml version=\"1.0\"?>\r\n<DocumentRoot>\r\n<description>Datawindow Root</description>\r\n<group0>\r\n<description>Group0 description</description>\r\n<Header0>\r\n<description>Header0 members</description>\r\n");
sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode );
rs = pstmt.executeQuery();
if(rs.next())
{
countryCode = checkNull(rs.getString("count_code")).trim();
System.out.println("countryCode >>> :"+countryCode);
}
callPstRs(pstmt, rs);
sql = "select b.FR_DATE as FR_DATE,b.TO_DATE as TO_DATE " +
" from period_appl a,period_tbl b " +
"where a.ref_code=a.prd_tblno and a.prd_tblno=b.prd_tblno " +
" AND b.prd_code = ? " +
"and b.prd_tblno=? " +
"AND case when a.type is null then 'X' else a.type end='S' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode.trim());
pstmt.setString(2,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
frDate=rs.getTimestamp("FR_DATE");
toDate=rs.getTimestamp("TO_DATE");
}
callPstRs(pstmt, rs);
/*sql = " SELECT POS_CODE,CUST_CODE,EMP_CODE FROM " +
" (SELECT C.POS_CODE,C.CUST_CODE,A.EMP_CODE FROM ORG_STRUCTURE A ,ORG_STRUCTURE_CUST C " +
" WHERE A.VERSION_ID=C.VERSION_ID AND A.TABLE_NO=C.TABLE_NO AND A.POS_CODE=C.POS_CODE " +
" AND C.VERSION_ID = (SELECT FN_GET_VERSION_ID FROM DUAL) AND C.TABLE_NO= ? " +
" AND C.EFF_DATE < ? AND C.VALID_UPTO > ? AND CASE WHEN C.SOURCE IS NULL THEN 'Y' ELSE C.SOURCE END <> 'A' " +
" MINUS " +
" SELECT POS_CODE,CUST_CODE,EMP_CODE FROM CUST_STOCK WHERE PRD_CODE = ? AND POS_CODE IS NOT NULL AND ITEM_SER = ? ) ";
*/
sql=" SELECT A.POS_CODE,A.CUST_CODE,A.EMP_CODE FROM " +
" (SELECT ROW_NUMBER() OVER (PARTITION BY C.CUST_CODE ORDER BY C.CUST_CODE) RN,C.POS_CODE,C.CUST_CODE,A.EMP_CODE " +
" FROM ORG_STRUCTURE A INNER JOIN ORG_STRUCTURE_CUST C " +
" ON A.VERSION_ID=C.VERSION_ID AND A.TABLE_NO=C.TABLE_NO AND A.POS_CODE=C.POS_CODE " +
" INNER JOIN " +
" (SELECT D.CUST_CODE FROM ORG_STRUCTURE B ,ORG_STRUCTURE_CUST D " +
" WHERE B.VERSION_ID=D.VERSION_ID AND B.TABLE_NO=D.TABLE_NO AND B.POS_CODE=D.POS_CODE " +
" AND D.VERSION_ID = (SELECT FN_GET_VERSION_ID FROM DUAL) AND D.TABLE_NO= ? " +
" AND D.EFF_DATE <= ? AND D.VALID_UPTO >= ? AND CASE WHEN D.SOURCE IS NULL THEN 'Y' ELSE D.SOURCE END <> 'A' " +
" MINUS " +
" SELECT CUST_CODE FROM CUST_STOCK WHERE PRD_CODE = ? AND POS_CODE IS NOT NULL AND ITEM_SER = ? " +
" ) B " +
" ON C.CUST_CODE = B.CUST_CODE WHERE C.VERSION_ID = (SELECT FN_GET_VERSION_ID FROM DUAL) AND C.TABLE_NO= ? " +
" ) A WHERE A.RN = 1 ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
pstmt.setTimestamp(2, frDate);
pstmt.setTimestamp(3, toDate);
pstmt.setString(4, prdCode);
pstmt.setString(5, itemSer);
pstmt.setString(6, itemSer);
rs = pstmt.executeQuery();
while(rs.next()) {
posCode = checkNull(rs.getString("POS_CODE"));
custCode = checkNull(rs.getString("CUST_CODE"));
empCode = checkNull(rs.getString("EMP_CODE"));
custName="";blacklisted="";empName="";posCodeDescr="";
sql="SELECT CUST_NAME,BLACK_LISTED FROM CUSTOMER WHERE CUST_CODE=? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, custCode);
rs1 = pstmt1.executeQuery();
if(rs1.next()){
custName = checkNull(rs1.getString("CUST_NAME"));
blacklisted = checkNull(rs1.getString("BLACK_LISTED"));
}
callPstRs(pstmt1, rs1);
sql="SELECT EMP_FNAME||' '||EMP_LNAME||' '||EMP_LNAME AS EMP_NAME FROM EMPLOYEE WHERE EMP_CODE=? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, empCode);
rs1 = pstmt1.executeQuery();
if(rs1.next()){
empName = checkNull(rs1.getString("EMP_NAME"));
}
callPstRs(pstmt1, rs1);
sql="SELECT DESCR FROM ORG_STRUCTURE WHERE POS_CODE=? AND TABLE_NO=? AND VERSION_ID=(SELECT FN_GET_VERSION_ID FROM DUAL) ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, posCode);
pstmt1.setString(2, itemSer);
rs1 = pstmt1.executeQuery();
if(rs1.next()){
posCodeDescr = checkNull(rs1.getString("DESCR"));
}
callPstRs(pstmt1, rs1);
retTabSepStrBuff.append("<Detail2>\r\n");
retTabSepStrBuff.append("<cust_code>").append("<![CDATA["+custCode+"]]>").append("</cust_code>\r\n");
retTabSepStrBuff.append("<cust_name>").append("<![CDATA["+custName+"]]>").append("</cust_name>\r\n");
retTabSepStrBuff.append("<blacklisted>").append("<![CDATA["+blacklisted+"]]>").append("</blacklisted>\r\n");
retTabSepStrBuff.append("<item_ser>").append("<![CDATA["+itemSer+"]]>").append("</item_ser>\r\n");
retTabSepStrBuff.append("<pos_code>").append("<![CDATA["+posCode+"]]>").append("</pos_code>\r\n");
retTabSepStrBuff.append("<pos_code_descr>").append("<![CDATA["+posCodeDescr+"]]>").append("</pos_code_descr>\r\n");
retTabSepStrBuff.append("<from_date>").append("<![CDATA["+sdf.format(frDate)+"]]>").append("</from_date>\r\n");
retTabSepStrBuff.append("<to_date>").append("<![CDATA["+sdf.format(toDate)+"]]>").append("</to_date>\r\n");
retTabSepStrBuff.append("<stmt_date>").append("<![CDATA["+sysDate+"]]>").append("</stmt_date>\r\n");
retTabSepStrBuff.append("<emp_code>").append("<![CDATA["+empCode+"]]>").append("</emp_code>\r\n");
retTabSepStrBuff.append("<emp_name>").append("<![CDATA["+empName+"]]>").append("</emp_name>\r\n");
retTabSepStrBuff.append("<prd_code>").append("<![CDATA["+prdCode+"]]>").append("</prd_code>\r\n");
retTabSepStrBuff.append("</Detail2>\r\n");
}
callPstRs(pstmt, rs);
retTabSepStrBuff.append("</Header0>\r\n");
retTabSepStrBuff.append("</group0>\r\n");
retTabSepStrBuff.append("</DocumentRoot>\r\n");
errString = retTabSepStrBuff.toString();
}
catch (Exception e)
{
e.printStackTrace();
System.out.println(":::::"+this.getClass().getSimpleName()+":::::" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
conn.close();
conn = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (Exception e)
{
errString = e.getMessage();
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException
{ {
...@@ -45,7 +246,6 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se ...@@ -45,7 +246,6 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se
String retStr = ""; String retStr = "";
System.out.println("windowName[process]::::::::::;;;" + windowName); System.out.println("windowName[process]::::::::::;;;" + windowName);
System.out.println("xtraParams[process]:::::::::;;;" + xtraParams); System.out.println("xtraParams[process]:::::::::;;;" + xtraParams);
try try
{ {
System.out.println("xmlString[process]::::::::::;;;" + xmlString); System.out.println("xmlString[process]::::::::::;;;" + xmlString);
...@@ -63,30 +263,25 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se ...@@ -63,30 +263,25 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println("Exception :SecSalesGenPrc :process(String xmlString, String xmlString2, String windowName, String xtraParams):"+ e.getMessage() + ":"); System.out.println(":::::"+this.getClass().getSimpleName()+":::::" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retStr = e.getMessage(); throw new ITMException(e);
} }
return retStr; return retStr;
}// END OF PROCESS (1) }// END OF PROCESS (1)
public String process(Document headerDom, Document detailDom,String windowName, String xtraParams) throws RemoteException,ITMException public String process(Document headerDom, Document detailDom,String windowName, String xtraParams) throws RemoteException,ITMException
{ {
int parentNodeListLength = 0; ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
int childNodeListLength = 0; Connection conn = null;
int parentNodeListLength = 0, childNodeListLength = 0;
String childNodeName = ""; String childNodeName = "";
NodeList parentNodeList = null; NodeList parentNodeList = null,childNodeList = null;
NodeList childNodeList = null; Node parentNode = null, childNode = null;
Node parentNode = null; boolean result=false;
Node childNode = null; int custCount=0;
String errString="",sql="",tranId="",tranIdLast="",spCode="",loginPositionCode="",orderType="",custType="",logDate=""; String errString="",itemSer="",prdCode="",custCode="",posCode="",empCode="",
PreparedStatement pstmt=null,pstmt1=null; ResultSet rs=null,rs1=null; fromDateStr="",toDateStr="",stmtDateStr="";
String itemSer="",prdCode="",posCodeL4="",custCode="",countryCode="",retString = "",sysDate="",xmlInEditMode="";
Timestamp frDate=null,toDate=null;
SimpleDateFormat sdf=null,sdflog=null;
CustStockGWTIC custStockGWTIC =new CustStockGWTIC();
StringBuffer xmlBuff=null;
ArrayList<String> logList=null;
String loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"); String loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
String chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId"); String chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
String chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode"); String chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
...@@ -99,46 +294,207 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se ...@@ -99,46 +294,207 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se
userInfo.setProfileId(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "profileId")); userInfo.setProfileId(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "profileId"));
userInfo.setUserType(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "userType")); userInfo.setUserType(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "userType"));
userInfo.setRemoteHost(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId")); userInfo.setRemoteHost(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
try {
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); try
sdflog = new SimpleDateFormat(genericUtility.getApplDateTimeFormat()); {
sysDate = sdf.format(Calendar.getInstance().getTime());
logDate= sdflog.format(Calendar.getInstance().getTime());
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
} catch (Exception e) {
System.out.println("Exception :SecSalesGenPrc :ejbCreate :==>" + e); parentNodeList = detailDom.getElementsByTagName("Detail2");
e.printStackTrace();
}
try
{
parentNodeList = headerDom.getElementsByTagName("Detail1");
parentNodeListLength = parentNodeList.getLength(); parentNodeListLength = parentNodeList.getLength();
System.out.println("::::::parentNodeListLength["+parentNodeListLength+"]"); System.out.println("::::::parentNodeListLength["+parentNodeListLength+"]");
for (int i = 0; i < parentNodeListLength; i++) {
for (int i = 0; i < parentNodeListLength; i++)
{
parentNode = parentNodeList.item(i); parentNode = parentNodeList.item(i);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength : "+childNodeListLength+" childNodeList : "+childNodeList); System.out.println("childNodeListLength : "+childNodeListLength+" childNodeList : "+childNodeList);
for (int childRow = 0; childRow < childNodeListLength; childRow++) for (int childRow = 0; childRow < childNodeListLength; childRow++)
{ {
childNode = childNodeList.item(childRow); childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
System.out.println("childNodeList.item(childRow) : "+ childNode); System.out.println("childNodeList.item(childRow) : "+ childNode);
System.out.println("childNode Name : "+childNode.getNodeName()+" value::"+childNode.getNodeValue()); System.out.println("childNode Name : "+childNode.getNodeName()+" value::"+childNode.getNodeValue());
if("cust_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
custCode=checkNull(childNode.getFirstChild().getNodeValue());
}
if("item_ser".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null) if("item_ser".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{ {
itemSer=checkNull(childNode.getFirstChild().getNodeValue()); itemSer=checkNull(childNode.getFirstChild().getNodeValue());
} }
if("pos_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
posCode=checkNull(childNode.getFirstChild().getNodeValue());
}
if("from_date".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
fromDateStr=checkNull(childNode.getFirstChild().getNodeValue());
}
if("to_date".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
toDateStr=checkNull(childNode.getFirstChild().getNodeValue());
}
if("stmt_date".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
stmtDateStr=checkNull(childNode.getFirstChild().getNodeValue());
}
if("emp_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
empCode=checkNull(childNode.getFirstChild().getNodeValue());
}
if("prd_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null) if("prd_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{ {
prdCode=checkNull(childNode.getFirstChild().getNodeValue()); prdCode=checkNull(childNode.getFirstChild().getNodeValue());
} }
} }
custCount=isCustExist(prdCode,custCode,itemSer,conn);
if(custCount==0)
{
result = pendTranGenProcess(xtraParams,loginSiteCode,chgUser,chgTerm,prdCode,custCode,itemSer,posCode,fromDateStr,toDateStr,stmtDateStr,empCode,userInfo,conn);
System.out.println("result>>"+result);
}
else
{
errString = itmDBAccessEJB.getErrorString("", "VMINVPRDCU", "","", conn);
return errString;
}
} }
System.out.println("result>>"+result);
if(result)
{
errString = itmDBAccessEJB.getErrorString("", "VTES3GENS", "","", conn);
}
else
{
errString = itmDBAccessEJB.getErrorString("", "VTES3GENF", "","", conn);
}
}// try end
catch (Exception e)
{
try
{
System.out.println("inside");
errString = itmDBAccessEJB.getErrorString("", "VTES3GENF","", "", conn);
conn.rollback();
}
catch (Exception d)
{
System.out.println("Exception : SecSalesGenPrc =>"+ d.toString());
d.printStackTrace();
}
e.printStackTrace();
System.out.println(":::::"+this.getClass().getSimpleName()+":::::" + e.getMessage());
throw new ITMException(e);
}
finally
{
System.out.println("In finally....");
try
{
if (conn != null)
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
errString = e.getMessage();
e.printStackTrace();
return errString;
}
}
System.out.println("Error Message=>" + errString);
return errString;
}// END OF PROCESS(2)
private int isCustExist(String prdCode, String custCode, String itemSer,Connection conn)
{
// TODO Auto-generated method stub
String sql="";
PreparedStatement pstmt=null;
ResultSet rs=null;
int custCntr=0;
try
{
sql=" select count(*) as count from cust_stock where cust_code=? and item_ser=? and prd_code=? and pos_code is not null ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemSer);
pstmt.setString(3, prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
custCntr = rs.getInt("count");
}
callPstRs(pstmt, rs);
System.out.println("custCntr>>>>>"+custCntr);
}
catch(SQLException e)
{
e.printStackTrace();
System.out.println("custCnt SQLException"+e);
}
finally
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
return custCntr;
}
private boolean pendTranGenProcess(String xtraParams,String loginSiteCode,String chgUser,String chgTerm,String prdCode,String custCode,String itemSer, String posCode,String fromDateStr, String toDateStr, String stmtDateStr,String empCode,UserInfoBean userInfo,Connection conn)
{
boolean result=false;
CustStockGWTIC custStockGWTIC =new CustStockGWTIC();
CustStockGWTConf confTran=new CustStockGWTConf();
ArrayList<String>logList=null;
String xmlInEditMode="",xmlInEditMode2="",xmlInEditMode3="",sql="",orderType="",custType="",tranIdLast="",tranId="",
sysDate="",logDate="",countryCode="",xmlDetail2="",xmlParseStr="",retString="",retString1="",errString="",
custStockItemDetails="",custStockInvDetails="";
StringBuffer xmlBuff=null;
SimpleDateFormat sdf=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
logDate= sdf.format(Calendar.getInstance().getTime());
sysDate = sdf.format(Calendar.getInstance().getTime());
logList=new ArrayList<String>();
xmlInEditMode = getHeaderXML(userInfo,"1","2");
xmlInEditMode2 = getHeaderXML(userInfo,"2","1");
xmlInEditMode3 = getHeaderXML(userInfo,"3","1");
System.out.println("xmlInEditMode:::"+ xmlInEditMode);
System.out.println("xmlInEditMode2>>>>"+xmlInEditMode2);
System.out.println("xmlInEditMode3>>>>"+xmlInEditMode3);
StringBuffer xmlDetail1 = new StringBuffer();
sql= "select count_code from state where " + sql= "select count_code from state where " +
"state_code in (select state_code from site where site_code=?)"; "state_code in (select state_code from site where site_code=?)";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -151,319 +507,252 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se ...@@ -151,319 +507,252 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se
} }
callPstRs(pstmt, rs); callPstRs(pstmt, rs);
sql = "select b.FR_DATE as FR_DATE,b.TO_DATE as TO_DATE " + sql= " select order_type,cust_type from customer where cust_code=? ";
" from period_appl a,period_tbl b " +
"where a.ref_code=a.prd_tblno and a.prd_tblno=b.prd_tblno " +
" AND b.prd_code = ? " +
"and b.prd_tblno=? " +
"AND case when a.type is null then 'X' else a.type end='S' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode.trim()); pstmt.setString(1, custCode);
pstmt.setString(2,countryCode+"_"+itemSer.trim());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
frDate=rs.getTimestamp("FR_DATE"); orderType=checkNull(rs.getString("order_type"));
toDate=rs.getTimestamp("TO_DATE"); custType=checkNull(rs.getString("cust_type"));
} }
callPstRs(pstmt, rs); callPstRs(pstmt, rs);
logList=new ArrayList<String>(); tranIdLast=getTranIdLast(orderType, itemSer, custCode,conn);
xmlInEditMode = getHeaderXML(userInfo,"1"); System.out.println("tranIdLast>>>"+tranIdLast+">>orderType>>>"+orderType+"custType>>>"+custType);
System.out.println("xmlInEditMode:::"+ xmlInEditMode); Document detailDom1 = genericUtility.parseString(xmlInEditMode);
NodeList parentNodeList1 = detailDom1.getElementsByTagName("Detail1");
sql = " SELECT POS_CODE,CUST_CODE,EMP_CODE FROM " + Node parentNode1 = parentNodeList1.item(0);
" (SELECT C.POS_CODE,C.CUST_CODE,A.EMP_CODE FROM ORG_STRUCTURE A ,ORG_STRUCTURE_CUST C " + NodeList childNodeList1 = parentNode1.getChildNodes();
" WHERE A.VERSION_ID=C.VERSION_ID AND A.TABLE_NO=C.TABLE_NO AND A.POS_CODE=C.POS_CODE " + int childNodeListLength1 = childNodeList1.getLength();
" AND C.VERSION_ID = (SELECT FN_GET_VERSION_ID FROM DUAL) AND C.TABLE_NO= ? " + for (int ctr = 0; ctr < childNodeListLength1; ctr++)
" AND C.EFF_DATE < ? AND C.VALID_UPTO > ? AND CASE WHEN C.SOURCE IS NULL THEN 'Y' ELSE C.SOURCE END <> 'A' " + {
" MINUS " + Node childNode1 = childNodeList1.item(ctr);
" SELECT POS_CODE,CUST_CODE,EMP_CODE FROM CUST_STOCK WHERE PRD_CODE = ? AND POS_CODE IS NOT NULL AND ITEM_SER = ? ) "; String childNodeName1 = childNode1.getNodeName().trim();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer); if ("tran_id".equalsIgnoreCase(childNodeName1)) {
pstmt.setTimestamp(2, frDate); childNode1.setTextContent(tranId);
pstmt.setTimestamp(3, toDate); } else if ("tran_date".equalsIgnoreCase(childNodeName1)) {
pstmt.setString(4, prdCode); childNode1.setTextContent(sysDate);
pstmt.setString(5, itemSer); } else if ("cust_code".equalsIgnoreCase(childNodeName1)) {
rs = pstmt.executeQuery(); childNode1.setTextContent(custCode);
while(rs.next()) } else if ("item_ser".equalsIgnoreCase(childNodeName1)) {
{ childNode1.setTextContent(itemSer);
posCodeL4 = checkNull(rs.getString("POS_CODE")); } else if ("order_type".equalsIgnoreCase(childNodeName1)) {
custCode = checkNull(rs.getString("CUST_CODE")); childNode1.setTextContent(orderType);
spCode=rs.getString("EMP_CODE"); } else if ("from_date".equalsIgnoreCase(childNodeName1)) {
System.out.println("posCodeL4>>>"+posCodeL4+">>custCode>>"+custCode+"Employee code>>"+spCode); childNode1.setTextContent(fromDateStr);
loginPositionCode=posCodeL4; } else if ("to_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(toDateStr);
} else if ("site_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(loginSiteCode);
} else if ("tran_id__last".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(tranIdLast);
} else if ("stmt_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(sysDate);
} else if ("confirmed".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("N");
} else if ("status".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("O");
} else if ("cust_type".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(custType);
} else if ("prd_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(prdCode);
} else if ("missing_inserted".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("Y");
} else if ("adm_chk".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("N");
} else if ("login_poscode".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(posCode);
} else if ("pos_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(posCode);
} else if ("emp_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(empCode);
} else if ("country_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(countryCode);
} else if ("edit_status".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("A");
} else if ("sale_per".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(empCode);
} else if ("chg_user".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgUser);
} else if ("chg_term".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgTerm);
} else if ("chg_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(sysDate);
} else if ("add_user".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgUser);
} else if ("add_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(sysDate);
} else if ("add_term".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgTerm);
}
}//for loop end
xmlDetail1 = xmlDetail1.append(genericUtility.serializeDom(detailDom1));
//header details end
System.out.println("xmlDetail1 final>>>>"+xmlDetail1.toString());
custStockInvDetails=custStockGWTIC.itemChanged("", xmlDetail1.toString(), xmlDetail1.toString(), "2", "itm_default", "A", xtraParams);
System.out.println("custStockInvDetails>>>>"+custStockInvDetails);
if(custStockInvDetails.contains("Detail2"))
{
xmlDetail2=custStockInvDetails.substring(custStockInvDetails.indexOf("<Detail2"), custStockInvDetails.lastIndexOf("</Detail2>")+10);
System.out.println("xmlDetail2>>>"+xmlDetail2);
xmlBuff = new StringBuffer();
xmlBuff.append(xmlDetail1.substring(0,xmlDetail1.indexOf("</Header0>")));
xmlBuff.append(xmlDetail2);
xmlBuff.append(xmlDetail1.substring(xmlDetail1.indexOf("</Header0>")));
xmlParseStr = xmlBuff.toString();
xmlBuff = null;
System.out.println(":::xmlParseStr::with Invoice:" + xmlParseStr);
custStockItemDetails=custStockGWTIC.itemChanged(xmlInEditMode3, xmlParseStr, xmlParseStr, "3", "itm_default", "A", xtraParams,"sec_sale_gen_prc");
}
else
{
//xmlDetail2=xmlInEditMode2.substring(xmlInEditMode2.indexOf("<Detail2"), xmlInEditMode2.lastIndexOf("</Detail2>")+10);
//System.out.println("xmlDetail2>>>>>"+xmlDetail2);
//xmlBuff = new StringBuffer();
//xmlBuff.append(xmlDetail1.substring(0,xmlDetail1.indexOf("</Header0>")));
//xmlBuff.append(xmlDetail2);
//xmlBuff.append(xmlDetail1.substring(xmlDetail1.indexOf("</Header0>")));
xmlParseStr = xmlDetail1.toString();
//xmlBuff = null;
System.out.println(":::xmlParseStr::without Invoice:" + xmlParseStr);
custStockItemDetails=custStockGWTIC.itemChanged(xmlInEditMode3, xmlParseStr, xmlParseStr, "3", "itm_default", "A", xtraParams,"sec_sale_gen_prc");
}
//String custStockItemDetails=custStockGWTIC.itemChanged(xmlInEditMode3, xmlParseStr, xmlParseStr, "3", "itm_default", "A", xtraParams,"sec_sale_gen_prc");
System.out.println("custStockItemDetails>>>>>"+custStockItemDetails);
String xmlDetail3=custStockItemDetails.substring(custStockItemDetails.indexOf("<Detail3"), custStockItemDetails.lastIndexOf("</Detail3>")+10);
System.out.println("xmlDetail3>>>>"+xmlDetail3);
xmlBuff = new StringBuffer();
xmlBuff.append(xmlParseStr.substring(0,xmlParseStr.indexOf("<Header0>") + 9));
xmlBuff.append("<objName><![CDATA[").append("secondory_sale_gwt_wiz_dummy").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(true).append("]]></taxInFocus>");
xmlBuff.append(xmlParseStr.substring(xmlParseStr.indexOf("<Header0>") + 9,xmlParseStr.indexOf("</Header0>")));
xmlBuff.append(xmlDetail3);
xmlBuff.append(xmlParseStr.substring(xmlParseStr.indexOf("</Header0>")));
StringBuffer xmlDetail1 = new StringBuffer(); String xmlParseStrFinal = xmlBuff.toString();
//Set Custstock header details xmlBuff = null;
sql= " select order_type,cust_type from customer where cust_code=? "; System.out.println("xmlParseStrFinal>>>>"+xmlParseStrFinal);
pstmt1 = conn.prepareStatement(sql); retString=saveData(xmlParseStrFinal, conn, userInfo);
pstmt1.setString(1, custCode); System.out.println("retString>>>>"+retString);
rs1 = pstmt1.executeQuery();
if(rs1.next()) if (retString.toUpperCase().indexOf("SUCCESS") > -1)
{
conn.commit();
String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
String newTranIdGen = arrayForTranId[1].substring(0, endIndex);
if(newTranIdGen!=null && newTranIdGen.trim().length()>0)
{
retString1=confTran.submit(newTranIdGen, xtraParams, "");
System.out.println("retString1>>>"+retString1);
if (retString1.toUpperCase().indexOf("VTSUBM1") > -1)
{ {
orderType=checkNull(rs1.getString("order_type")); errString = "Confirmed Transaction "+newTranIdGen+" Created for Customer code >>"+custCode+" of Position code >>"+posCode+" and Employee code >>"+empCode;
custType=checkNull(rs1.getString("cust_type")); logList.add(errString);
errString=null;
result=true;
} }
callPstRs(pstmt1, rs1); else
tranIdLast=getTranIdLast(prdCode, orderType, itemSer, custCode);
System.out.println("tranIdLast>>>"+tranIdLast+">>orderType>>>"+orderType+"custType>>>"+custType);
Document detailDom1 = genericUtility.parseString(xmlInEditMode);
NodeList parentNodeList1 = detailDom1.getElementsByTagName("Detail1");
Node parentNode1 = parentNodeList1.item(0);
NodeList childNodeList1 = parentNode1.getChildNodes();
int childNodeListLength1 = childNodeList1.getLength();
for (int ctr = 0; ctr < childNodeListLength1; ctr++)
{ {
Node childNode1 = childNodeList1.item(ctr); result=false;
String childNodeName1 = childNode1.getNodeName().trim(); }
}
if ("tran_id".equalsIgnoreCase(childNodeName1)) { }
childNode1.setTextContent(tranId); else
} else if ("tran_date".equalsIgnoreCase(childNodeName1)) { {
childNode1.setTextContent(sysDate); String description = "";
} else if ("cust_code".equalsIgnoreCase(childNodeName1)) { Document parseString = genericUtility.parseString(retString);
childNode1.setTextContent(custCode); NodeList nlErrorTag = null;
} else if ("item_ser".equalsIgnoreCase(childNodeName1)) { nlErrorTag = parseString.getElementsByTagName("error");
childNode1.setTextContent(itemSer); if (nlErrorTag.getLength() <= 0)
} else if ("order_type".equalsIgnoreCase(childNodeName1)) { {
childNode1.setTextContent(orderType); nlErrorTag = parseString.getElementsByTagName("Error");
} else if ("from_date".equalsIgnoreCase(childNodeName1)) { }
childNode1.setTextContent(sdf.format(frDate).toString()); for (int err = 0; err < nlErrorTag.getLength(); err++)
} else if ("to_date".equalsIgnoreCase(childNodeName1)) { {
childNode1.setTextContent(sdf.format(toDate).toString()); Node itemNode = nlErrorTag.item(err);
} else if ("site_code".equalsIgnoreCase(childNodeName1)) { NamedNodeMap errorAttributes = itemNode.getAttributes();
childNode1.setTextContent(loginSiteCode); Node errorTypeNode = errorAttributes.getNamedItem("type");
} else if ("tran_id__last".equalsIgnoreCase(childNodeName1)) { Node errorIdNode = errorAttributes.getNamedItem("type");
childNode1.setTextContent(tranIdLast); String errorType = errorTypeNode.getTextContent();
} else if ("stmt_date".equalsIgnoreCase(childNodeName1)) { String errorId = errorIdNode.getTextContent();
childNode1.setTextContent(sysDate); NodeList childNodeListErr = itemNode.getChildNodes();
} else if ("confirmed".equalsIgnoreCase(childNodeName1)) { for (int k = 0; k < childNodeListErr.getLength(); k++)
childNode1.setTextContent("N");
} else if ("status".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("O");
} else if ("cust_type".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(custType);
} else if ("prd_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(prdCode);
} else if ("missing_inserted".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("Y");
} else if ("adm_chk".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("N");
} else if ("login_poscode".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(loginPositionCode);
} else if ("pos_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(posCodeL4);
} else if ("emp_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(spCode);
} else if ("country_code".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(countryCode);
} else if ("edit_status".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent("A");
} else if ("sale_per".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(spCode);
} else if ("chg_user".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgUser);
} else if ("chg_term".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgTerm);
} else if ("chg_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(sysDate);
} else if ("add_user".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgUser);
} else if ("add_date".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(sysDate);
} else if ("add_term".equalsIgnoreCase(childNodeName1)) {
childNode1.setTextContent(chgTerm);
}
}//for loop end
xmlDetail1 = xmlDetail1.append(genericUtility.serializeDom(detailDom1));
//header details end
System.out.println("xmlDetail1 final>>>>"+xmlDetail1.toString());
String custStockInvDetails=custStockGWTIC.itemChanged("", xmlDetail1.toString(), xmlDetail1.toString(), "2", "itm_default", "A", xtraParams);
System.out.println("custStockInvDetails>>>>"+custStockInvDetails);
if(custStockInvDetails.contains("Detail2"))
{ {
String xmlDetail2=custStockInvDetails.substring(custStockInvDetails.indexOf("<Detail2"), custStockInvDetails.lastIndexOf("</Detail2>")+10); Node childNodeErr = childNodeListErr.item(k);
System.out.println("xmlDetail2>>>"+xmlDetail2); if ("description".equalsIgnoreCase(childNodeErr.getNodeName()))
xmlBuff = new StringBuffer();
xmlBuff.append(xmlDetail1.substring(0,xmlDetail1.indexOf("</Header0>")));
xmlBuff.append(xmlDetail2);
xmlBuff.append(xmlDetail1.substring(xmlDetail1.indexOf("</Header0>")));
String xmlParseStr = xmlBuff.toString();
xmlBuff = null;
System.out.println(":::xmlParseStr:::" + xmlParseStr);
String custStockItemDetails=custStockGWTIC.itemChanged("", xmlParseStr, xmlParseStr, "3", "itm_default", "A", xtraParams);
System.out.println("custStockItemDetails>>>>>"+custStockItemDetails);
if(custStockItemDetails.contains("Detail3"))
{ {
String xmlDetail3=custStockItemDetails.substring(custStockItemDetails.indexOf("<Detail3"), custStockItemDetails.lastIndexOf("</Detail3>")+10); description = childNodeErr.getFirstChild().getNodeValue();
System.out.println("xmlDetail3>>>>"+xmlDetail3);
xmlBuff = new StringBuffer();
xmlBuff.append(xmlParseStr.substring(0,xmlParseStr.indexOf("<Header0>") + 9));
xmlBuff.append("<objName><![CDATA[").append("secondory_sale_gwt_wiz_dummy").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(true).append("]]></taxInFocus>");
xmlBuff.append(xmlParseStr.substring(xmlParseStr.indexOf("<Header0>") + 9,xmlParseStr.indexOf("</Header0>")));
xmlBuff.append(xmlDetail3);
xmlBuff.append(xmlParseStr.substring(xmlParseStr.indexOf("</Header0>")));
String xmlParseStrFinal = xmlBuff.toString();
xmlBuff = null;
System.out.println("xmlParseStrFinal>>>>"+xmlParseStrFinal);
retString=saveData(xmlParseStrFinal, conn, userInfo);
System.out.println("retString>>>>"+retString);
if (retString.toUpperCase().indexOf("SUCCESS") > -1)
{
conn.commit();
String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
String newTranIdGen = arrayForTranId[1].substring(0, endIndex);
if(newTranIdGen!=null && newTranIdGen.trim().length()>0)
{
String sql1 = "update cust_stock set confirmed = 'Y',status='S' where tran_id = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, newTranIdGen);
int count = pstmt1.executeUpdate();
System.out.println("Count:::" + count);
if (count > 0) {
conn.commit();
errString = "Confirmed Transaction "+newTranIdGen+" Created for Customer code >>"+custCode+" of Position code >>"+posCodeL4+" and Employee code >>"+spCode;
logList.add(errString);
errString=null;
}
if (pstmt1 != null) {
pstmt1.close();
pstmt1 = null;
}
}
} }
else }
{
String description = "";
Document parseString = genericUtility.parseString(retString);
NodeList nlErrorTag = null;
nlErrorTag = parseString.getElementsByTagName("error");
if (nlErrorTag.getLength() <= 0)
{
nlErrorTag = parseString.getElementsByTagName("Error");
}
for (int err = 0; err < nlErrorTag.getLength(); err++)
{
Node itemNode = nlErrorTag.item(err);
NamedNodeMap errorAttributes = itemNode.getAttributes();
Node errorTypeNode = errorAttributes.getNamedItem("type");
Node errorIdNode = errorAttributes.getNamedItem("type");
String errorType = errorTypeNode.getTextContent();
String errorId = errorIdNode.getTextContent();
NodeList childNodeListErr = itemNode.getChildNodes();
for (int k = 0; k < childNodeListErr.getLength(); k++)
{
Node childNodeErr = childNodeListErr.item(k);
if ("description".equalsIgnoreCase(childNodeErr.getNodeName()))
{
description = childNodeErr.getFirstChild().getNodeValue();
}
}
if ("W".equals(errorType)) { if ("W".equals(errorType)) {
errString = "Warnings: " + errorId + " : " + description; errString = "Warnings: " + errorId + " : " + description;
}
else
{
errString = "Errors: " + errorId + " : " + description;
}
logList.add(errString);
}
}
}
else
{
errString="No items present for available invoices of Customer >>"+custCode+" of Position code >>"+posCodeL4+" and Employee code>>"+spCode;
logList.add(errString);
errString=null;
}
} }
else else
{ {
errString="No invoices present for Customer >>"+custCode+" of Position code >>"+posCodeL4+" and Employee code>>"+spCode; errString = "Errors: " + errorId + " : " + description;
logList.add(errString);
errString=null;
} }
logList.add(errString);
} }
callPstRs(pstmt, rs); }
writeLog(this.getClass().getSimpleName()+"_"+itemSer+"_"+prdCode, logList,logDate); System.out.println("result>>>"+result);
//end }
}// try end catch(Exception e)
catch (Exception e)
{ {
try result=false;
{ logList.add(e.getMessage());
System.out.println("inside");
errString = itmDBAccessEJB.getErrorString("", "VTES3GENF","", "", conn);
conn.rollback();
}
catch (Exception d)
{
System.out.println("Exception : SecSalesGenPrc =>"+ d.toString());
d.printStackTrace();
}
e.printStackTrace();
} }
finally finally
{ {
System.out.println("In finally...."); try
try { {
if (errString == null || errString.trim().length()==0) { if (pstmt != null)
System.out.println("Connection Commited");
errString = itmDBAccessEJB.getErrorString("", "VTES3GENS","", "", conn);
conn.commit();
}
else
{ {
errString = itmDBAccessEJB.getErrorString("", "VTES3GENF","", "", conn); pstmt.close();
pstmt = null;
} }
if (conn != null) if (rs != null)
{ {
conn.close(); rs.close();
conn = null; rs = null;
} }
} }
catch (Exception e) catch (SQLException e)
{ {
errString = e.getMessage();
e.printStackTrace(); e.printStackTrace();
return errString;
} }
} }
System.out.println("Error Message=>" + errString); writeLog(this.getClass().getSimpleName()+"_"+itemSer+"_"+prdCode, logList,logDate);
return errString; return result;
}// END OF PROCESS(2) }
private String getHeaderXML(UserInfoBean userInfo,String formNo) throws Exception { private String getHeaderXML(UserInfoBean userInfo,String formNo,String pagContext) throws Exception
{
InitialContext ctx = null; InitialContext ctx = null;
String retString = ""; String retString = "";
MasterStatefulLocal masterStateful = null; MasterDataStatefulLocal masterStateful = null;
AppConnectParm appConnect = new AppConnectParm(); AppConnectParm appConnect = new AppConnectParm();
try{ try{
ctx = new InitialContext(appConnect.getProperty()); ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local"); masterStateful = (MasterDataStatefulLocal) ctx.lookup("ibase/MasterDataStatefulEJB/local");
masterStateful.setUserInfo(userInfo); retString=masterStateful.getBlankDomForAdd("secondory_sale_gwt_wiz", formNo, pagContext, null, userInfo.toString(), "");
retString = checkNull(masterStateful.getDetailXMLDomString("secondory_sale_gwt_wiz", formNo, "A","", "", true));
}catch(Exception e) }catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
...@@ -471,7 +760,8 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se ...@@ -471,7 +760,8 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se
return retString; return retString;
} }
private String saveData(String xmlString, Connection conn,UserInfoBean userInfo) throws Exception { private String saveData(String xmlString, Connection conn,UserInfoBean userInfo) throws Exception
{
String retString = ""; String retString = "";
InitialContext ctx = null; InitialContext ctx = null;
MasterStatefulLocal masterStateful = null; MasterStatefulLocal masterStateful = null;
...@@ -496,7 +786,7 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se ...@@ -496,7 +786,7 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se
return retString; return retString;
} }
private String getTranIdLast(String prdCode,String orderType, String itemSer,String custCode) private String getTranIdLast(String orderType, String itemSer,String custCode,Connection conn)
{ {
String sql="",tranIdLast=""; String sql="",tranIdLast="";
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
...@@ -504,7 +794,6 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se ...@@ -504,7 +794,6 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se
Timestamp toDateLast=null; Timestamp toDateLast=null;
try try
{ {
//Added by saurabh 17/01/17 as per discussion with Manoj Sir.--Start
sql = " SELECT max(to_date) as to_date FROM CUST_STOCK WHERE CUST_CODE = ? " + sql = " SELECT max(to_date) as to_date FROM CUST_STOCK WHERE CUST_CODE = ? " +
" AND ITEM_SER = ? and order_type=? and pos_code is not null and confirmed='Y' and status='S' "; " AND ITEM_SER = ? and order_type=? and pos_code is not null and confirmed='Y' and status='S' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -542,6 +831,26 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se ...@@ -542,6 +831,26 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se
{ {
e.printStackTrace(); e.printStackTrace();
} }
finally
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
return tranIdLast; return tranIdLast;
} }
...@@ -573,6 +882,7 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se ...@@ -573,6 +882,7 @@ public class SecSalesGenPrc extends ProcessEJB implements SecSalesGenPrcLocal,Se
private void writeLog(String fileName, ArrayList<String> logList,String logDate) private void writeLog(String fileName, ArrayList<String> logList,String logDate)
{ {
String jBossHome = CommonConstants.JBOSSHOME;
FileWriter localFileWriter = null; FileWriter localFileWriter = null;
try { try {
File logDir = new File(jBossHome + File.separator+ "log" + File.separator + "SecSalesGenProcLog"); File logDir = new File(jBossHome + File.separator+ "log" + File.separator + "SecSalesGenProcLog");
......
...@@ -9,5 +9,6 @@ import javax.ejb.Local; ...@@ -9,5 +9,6 @@ import javax.ejb.Local;
@Local @Local
public interface SecSalesGenPrcLocal extends ProcessLocal{ public interface SecSalesGenPrcLocal extends ProcessLocal{
public abstract String process(String arg0, String arg1, String arg2, String arg3) throws RemoteException, ITMException; public String getData(String arg0, String arg1, String arg2, String arg3) throws RemoteException ,ITMException;
public String process(String arg0, String arg1, String arg2, String arg3) throws RemoteException, ITMException;
} }
...@@ -9,5 +9,6 @@ import javax.ejb.Remote; ...@@ -9,5 +9,6 @@ import javax.ejb.Remote;
@Remote @Remote
public interface SecSalesGenPrcRemote extends ProcessRemote{ public interface SecSalesGenPrcRemote extends ProcessRemote{
public abstract String process(String arg0, String arg1, String arg2, String arg3) throws RemoteException, ITMException; public String getData(String arg0, String arg1, String arg2, String arg3) throws RemoteException ,ITMException;
public String process(String arg0, String arg1, String arg2, String arg3) throws RemoteException, ITMException;
} }
...@@ -76,14 +76,13 @@ public class SecSalesSubIC extends ValidatorEJB implements SecSalesSubICLocal , ...@@ -76,14 +76,13 @@ public class SecSalesSubIC extends ValidatorEJB implements SecSalesSubICLocal ,
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
int currentFormNo = 0; int currentFormNo = 0;
int cnt = 0; int cnt = 0;
//ConnDriver connDriver = null; ConnDriver connDriver = null;
Node childNode = null; Node childNode = null;
String itemSer="" , prdCode = "" ; String itemSer="" , prdCode = "" ;
try { try {
System.out.println("************xtraParams*************" + xtraParams); System.out.println("************xtraParams*************" + xtraParams);
//connDriver = new ConnDriver(); connDriver = new ConnDriver();
conn = getConnection(); conn = connDriver.getConnectDB("DriverITM");
//conn = connDriver.getConnectDB("DriverITM");
System.out.println("In wfValData Secondary Sales Submit:::"); System.out.println("In wfValData Secondary Sales Submit:::");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode")); loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"));
......
...@@ -68,9 +68,9 @@ public class SecSalesSubPrc extends ProcessEJB implements SecSalesSubPrcLocal , ...@@ -68,9 +68,9 @@ public class SecSalesSubPrc extends ProcessEJB implements SecSalesSubPrcLocal ,
int cnt=0; int cnt=0;
try { try {
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDispDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDispDateFormat());
//ConnDriver con = new ConnDriver(); ConnDriver con = new ConnDriver();
//conn = con.getConnectDB("DriverITM"); conn = con.getConnectDB("DriverITM");
conn = getConnection();
itemSer = checkNull(genericUtility.getColumnValue("item_ser", dom)); itemSer = checkNull(genericUtility.getColumnValue("item_ser", dom));
prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom)); prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom));
System.out.println("itemSer ::::::::"+itemSer + " prdCode :::::::: " +prdCode); System.out.println("itemSer ::::::::"+itemSer + " prdCode :::::::: " +prdCode);
......
/*
* Component created by saurabh[12/07/16] for new station code update process for flat table.
*
* */
package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class StanCodeUpdIC extends ValidatorEJB implements StanCodeUpdICRemote,StanCodeUpdICLocal {
E12GenericUtility genericUtility=new E12GenericUtility();
public String wfValData(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String editFlag,String xtraParams) throws RemoteException,ITMException
{
System.out.println("In wfValData");
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = "";
try
{
System.out.println("currFrmXmlStr..." + currFrmXmlStr);
System.out.println("hdrFrmXmlStr..." + hdrFrmXmlStr);
System.out.println("allFrmXmlStr..." + allFrmXmlStr);
if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0))
{
currDom = parseString(currFrmXmlStr);
}
if ((hdrFrmXmlStr != null) && (hdrFrmXmlStr.trim().length() != 0))
{
hdrDom = parseString(hdrFrmXmlStr);
}
if ((allFrmXmlStr != null) && (allFrmXmlStr.trim().length() != 0))
{
allDom = parseString(allFrmXmlStr);
}
errString = wfValData(currDom, hdrDom, allDom, objContext, editFlag, xtraParams);
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public String wfValData(Document currDom, Document hdrDom, Document allDom,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{
System.out.println("In validate Data");
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
int count = 0;
String errString = "",errorType = "",errCode = "",childNodeName = "",sql = "";
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
int noOfChilds = 0;
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
int currentFormNo = 0;
int cnt = 0,divCount=0,totalCount=0;
ConnDriver connDriver = null;
Node childNode = null;
String prdCodeFrom="",prdCodeTo="",custCode="";
ArrayList<String> custArray=null;
ArrayList<String> errCustList=new ArrayList<String>();
try {
System.out.println("************xtraParams*************" + xtraParams);
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
System.out.println("In wfValData Distribution receipt:::");
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("**************loginCode************" + userId);
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
NodeList parentList = currDom.getElementsByTagName("Detail"+ currentFormNo);
NodeList childList = null;
System.out.println("hdrDom..." + hdrDom.toString());
switch (currentFormNo)
{
case 1:
{
childList = parentList.item(0).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item(ctr);
if (childNode.getNodeType() != 1)
{
continue;
}
childNodeName = childNode.getNodeName();
System.out.println("Editflag =" + editFlag);
System.out.println("parentList = " + parentList);
System.out.println("childList = " + childList);
if ("prd_code_from".equalsIgnoreCase(childNodeName) )
{
prdCodeFrom = checkNull(genericUtility.getColumnValue("prd_code_from", currDom));
if(prdCodeFrom==null || prdCodeFrom.trim().length()==0)
{
errList.add("VPBLKPRCDF");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM SALES_CONSOLIDATION WHERE PRD_CODE = ? AND SOURCE='E' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodeFrom);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VPINVPRCDF");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
else if ("prd_code_to".equalsIgnoreCase(childNodeName) )
{
prdCodeTo = checkNull(genericUtility.getColumnValue("prd_code_to", currDom));
if(prdCodeTo==null || prdCodeTo.trim().length()==0)
{
errList.add("VPBLKPRCDT");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM SALES_CONSOLIDATION WHERE PRD_CODE = ? AND SOURCE='E' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodeTo);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("Count: " + count);
if (count == 0)
{
errList.add("VPINVPRCDT");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
else if ("cust_code".equalsIgnoreCase(childNodeName) )
{
custCode = checkNull(genericUtility.getColumnValue("cust_code", currDom));
prdCodeFrom = checkNull(genericUtility.getColumnValue("prd_code_from", currDom));
prdCodeTo = checkNull(genericUtility.getColumnValue("prd_code_to", currDom));
if(custCode==null || custCode.trim().length()==0)
{
errList.add("VPBLKCUSCD");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
if (!custCode.matches("[A-Za-z0-9, ]*"))
{
errList.add("VPINVCCDS");
errFields.add(childNodeName.toLowerCase());
break;
}
if(custCode.contains(","))
{
custArray= new ArrayList<String>(Arrays.asList(custCode.split(",")));
for (int i=0;i<custArray.size();i++)
{
sql = "SELECT COUNT(*) AS COUNT FROM CUSTOMER WHERE CUST_CODE=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custArray.get(i));
rs = pstmt.executeQuery();
if (rs.next())
{
divCount = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("divCount: " + divCount);
if (divCount == 0)
{
errCustList.add(custArray.get(i));
errList.add("VPINVCSCDM");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM SALES_CONSOLIDATION WHERE CUST_CODE=? AND SOURCE='E' AND PRD_CODE BETWEEN ? AND ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custArray.get(i));
pstmt.setString(2, prdCodeFrom);
if(prdCodeTo.length()>0){
pstmt.setString(3, prdCodeTo);
}
else
{
pstmt.setString(3, prdCodeFrom);
}
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("Count: " + count);
if (count == 0)
{
errCustList.add(custArray.get(i));
errList.add("VPINVCUSCD");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM CUSTOMER WHERE CUST_CODE=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
divCount = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("divCount: " + divCount);
if (divCount == 0)
{
errCustList.add(custCode);
errList.add("VPINVCSCDM");
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM SALES_CONSOLIDATION WHERE CUST_CODE=? AND SOURCE='E' AND PRD_CODE BETWEEN ? AND ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, prdCodeFrom);
if(prdCodeTo.length()>0){
pstmt.setString(3, prdCodeTo);
}
else
{
pstmt.setString(3, prdCodeFrom);
}
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("Count: " + count);
if (count == 0)
{
errCustList.add(custCode);
errList.add("VPINVCUSCD");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
if((custCode!=null && custCode.trim().length()>0)&&(prdCodeFrom!=null && prdCodeFrom.trim().length()>0))
{
if(custCode.contains(",")){
custCode=custCode.replaceAll(",", "','");
}
sql = "SELECT COUNT(*) AS COUNT " +
" FROM SALES_CONSOLIDATION SC, CUSTOMER C, STATION ST WHERE SC.CUST_CODE = C.CUST_CODE AND ST.STAN_CODE = C.STAN_CODE AND " +
" ST.STAN_CODE <> SC.STAN_CODE_NEW AND SC.SOURCE='E' AND SC.PRD_CODE BETWEEN ? AND ? AND SC.CUST_CODE IN ('"+custCode+"')";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodeFrom);
if(prdCodeTo.length()>0){
pstmt.setString(2, prdCodeTo);
}else{
pstmt.setString(2, prdCodeFrom);
}
rs = pstmt.executeQuery();
while(rs.next()) {
totalCount = rs.getInt("COUNT");
}
callPstRs(pstmt, rs);
System.out.println("totalCount: " + totalCount);
if (totalCount == 0)
{
errList.add("VTNODATAFF");
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
}
break;
}
int errListSize = errList.size();
cnt = 0;
String errFldName = "";
if ((errList != null) && (errListSize > 0))
{
for (cnt = 0; cnt < errListSize; cnt++)
{
errCode = (String) errList.get(cnt);
errFldName = (String) errFields.get(cnt);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode);
if(errCustList.size()>0 && errString.length() > 0 )
{
String begPart = errString.substring( 0, errString.indexOf("]]></description>") );
String mainStr="";
for(int i=0;i<errCustList.size();i++)
{
mainStr=mainStr+ errCustList.get(i)+",";
}
String endPart=errString.substring( errString.indexOf("]]></description>"), errString.length() );
mainStr=" Following customers are invalid :: "+mainStr.substring(0,mainStr.length()-1);
errString = begPart+mainStr + endPart;
}
if(errString.length() > 0 )
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........." + errStringXml);
errString = "";
}
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer("");
}
errString = errStringXml.toString();
}
catch (Exception e)
{
System.out.println("Exception in "+this.getClass().getSimpleName()+" == >");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
callPstRs(pstmt, rs);
if ((conn != null) && (!conn.isClosed())){
conn.close();
}
}
catch (Exception e)
{
System.out.println("Exception :"+this.getClass().getSimpleName()+":wfValData :==>\n" + e.getMessage());
throw new ITMException(e);
}
}
return errString;
}
public String itemChanged(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = null;
try
{
if ((currFrmXmlStr != null) && (currFrmXmlStr.trim().length() != 0))
{
currDom = genericUtility.parseString(currFrmXmlStr);
System.out.println("currFrmXmlStr : " + currFrmXmlStr);
}
if ((hdrFrmXmlStr != null) && (hdrFrmXmlStr.trim().length() != 0))
{
hdrDom = genericUtility.parseString(hdrFrmXmlStr);
System.out.println("hdrFrmXmlStr : " + hdrFrmXmlStr);
}
if ((allFrmXmlStr != null) && (allFrmXmlStr.trim().length() != 0))
{
allDom = genericUtility.parseString(allFrmXmlStr);
System.out.println("allFrmXmlStr : " + allFrmXmlStr);
}
errString = itemChanged(currDom, hdrDom, allDom, objContext,currentColumn, editFlag, xtraParams);
System.out.println("ErrString :" + errString);
}
catch (Exception e)
{
System.out.println("Exception :"+this.getClass().getSimpleName()+":itemChanged :==>\n" + e.getMessage());
errString = genericUtility.createErrorString(e);
}
return errString;
}
public String itemChanged(Document currDom, Document hdrDom,Document allDom, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
int currentFormNo = 0;
String childNodeName = null;
int ctr = 0;
int childNodeListLength = 0;
Connection conn = null;
StringBuffer valueXmlString = new StringBuffer();
String prdCodeFrom="";
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>");
valueXmlString.append(editFlag).append("</editFlag>\r\n</Header>\r\n");
System.out.println("currentFormNo-------*************** = "+ currentFormNo);
switch (currentFormNo)
{
case 1:
System.out.println("currentFormNo-------*************** = "+ currentFormNo);
parentNodeList = currDom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr++;
}while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
System.out.println(" currentColumn : "+ currentColumn);
if (currentColumn.equalsIgnoreCase("itm_default"))
{
valueXmlString.append("<prd_code_from>").append("").append("</prd_code_from>\r\n");
valueXmlString.append("<prd_code_to>").append("").append("</prd_code_to>\r\n");
valueXmlString.append("<cust_code>").append("").append("</cust_code>\r\n");
}
else if(currentColumn.equalsIgnoreCase("prd_code_from"))
{
prdCodeFrom = checkNull(genericUtility.getColumnValue("prd_code_from", currDom));
if(prdCodeFrom.length()>0)
{
valueXmlString.append("<prd_code_to>").append("<![CDATA["+checkNull(prdCodeFrom)+"]]>").append("</prd_code_to>\r\n");
}
else
{
valueXmlString.append("<prd_code_to>").append("").append("</prd_code_to>\r\n");
}
}
valueXmlString.append("</Detail1>\r\n");
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
valueXmlString.append("</Root>\r\n");
System.out.println("\n****ValueXmlString :" + valueXmlString.toString()+ ":********");
return valueXmlString.toString();
}
public static boolean isNumeric(String str)
{
try
{
int d = Integer.parseInt(str);
}
catch (NumberFormatException nfe)
{
return false;
}
return true;
}
private String errorType(Connection conn, String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while (rs.next()){
msgType = rs.getString("MSG_TYPE");
}
callPstRs(pstmt, rs);
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
callPstRs(pstmt, rs);
}
catch (Exception e)
{
e.printStackTrace();
}
}
return msgType;
}
public void callPstRs(PreparedStatement pstmt, ResultSet rs)
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
private String checkNull(String inputVal)
{
inputVal = inputVal == null ? "" : inputVal.trim();
return inputVal;
}
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface StanCodeUpdICLocal extends ValidatorLocal
{
public String wfValData(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) throws RemoteException,ITMException;
public String itemChanged(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface StanCodeUpdICRemote extends ValidatorRemote
{
public String wfValData(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6) throws RemoteException,ITMException;
public String itemChanged(String currFrmXmlStr, String hdrFrmXmlStr,String allFrmXmlStr, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException;
}
/*
* Component created by saurabh[07/07/16] for new station code update process for flat table.
* */
package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class StanCodeUpdPrc extends ProcessEJB implements StanCodeUpdPrcRemote, StanCodeUpdPrcLocal {
E12GenericUtility genericUtility =new E12GenericUtility();
@Override
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException, ITMException {
String rtStr = "";
Document dom = null;
Document dom2 = null;
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
dom = genericUtility.parseString(xmlString2);
}
rtStr = getData(dom, dom2, windowName, xtraParams);
} catch (Exception e) {
System.out.println("::::"+this.getClass().getSimpleName()+"::getDataString" + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return rtStr;
}
@Override
public String getData(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException, ITMException
{
String errString = "";
String sql = "";
StringBuffer retTabSepStrBuff = new StringBuffer();
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn = null;
String prdCodeFromDom="",prdCodeToDom="",custCodeDom="";
String custCode="",custName="",prdCode="",itemSer="",stanCode="",stanCodeNew="",salesValue="",tranId="";
int cnt=0;
try {
ConnDriver con = new ConnDriver();
conn = con.getConnectDB("DriverITM");
System.out.println("In getdata Station update process:::");
prdCodeFromDom = checkNull(genericUtility.getColumnValue("prd_code_from", dom));
prdCodeToDom = checkNull(genericUtility.getColumnValue("prd_code_to", dom));
custCodeDom = checkNull(genericUtility.getColumnValue("cust_code", dom));
if(custCodeDom.contains(",")){
custCodeDom=custCodeDom.replaceAll(",", "','");
}
retTabSepStrBuff.append("<?xml version=\"1.0\"?>\r\n<DocumentRoot>\r\n<description>Datawindow Root</description>\r\n<group0>\r\n<description>Group0 description</description>\r\n<Header0>\r\n<description>Header0 members</description>\r\n");
sql = "SELECT SC.CUST_CODE, C.CUST_NAME, SC.PRD_CODE, SC.ITEM_SER, SC.STAN_CODE, ST.STAN_CODE AS STAN_CODE_NEW, SC.SALES_VALUE, SC.TRAN_ID " +
" FROM SALES_CONSOLIDATION SC, CUSTOMER C, STATION ST WHERE SC.CUST_CODE = C.CUST_CODE AND ST.STAN_CODE = C.STAN_CODE AND " +
" ST.STAN_CODE <> SC.STAN_CODE_NEW AND SC.SOURCE='E' AND SC.PRD_CODE BETWEEN ? AND ? AND SC.CUST_CODE IN ('"+custCodeDom+"')";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodeFromDom);
if(prdCodeToDom.length()>0){
pstmt.setString(2, prdCodeToDom);
}else{
pstmt.setString(2, prdCodeFromDom);
}
rs = pstmt.executeQuery();
while(rs.next()) {
custCode = checkNull(rs.getString("CUST_CODE"));
custName = checkNull(rs.getString("CUST_NAME"));
prdCode = checkNull(rs.getString("PRD_CODE"));
itemSer = checkNull(rs.getString("ITEM_SER"));
stanCode = checkNull(rs.getString("STAN_CODE"));
stanCodeNew = checkNull(rs.getString("STAN_CODE_NEW"));
salesValue = checkNull(rs.getString("SALES_VALUE"));
tranId = checkNull(rs.getString("TRAN_ID"));
cnt++;
retTabSepStrBuff.append("<Detail2>\r\n");
retTabSepStrBuff.append("<cust_code>").append("<![CDATA["+custCode+"]]>").append("</cust_code>\r\n");
retTabSepStrBuff.append("<cust_name>").append("<![CDATA["+custName+"]]>").append("</cust_name>\r\n");
retTabSepStrBuff.append("<prd_code>").append("<![CDATA["+prdCode+"]]>").append("</prd_code>\r\n");
retTabSepStrBuff.append("<item_ser>").append("<![CDATA["+itemSer+"]]>").append("</item_ser>\r\n");
retTabSepStrBuff.append("<stan_code>").append("<![CDATA["+stanCode+"]]>").append("</stan_code>\r\n");
retTabSepStrBuff.append("<stan_code_new>").append("<![CDATA["+stanCodeNew+"]]>").append("</stan_code_new>\r\n");
retTabSepStrBuff.append("<sales_value>").append("<![CDATA["+salesValue+"]]>").append("</sales_value>\r\n");
retTabSepStrBuff.append("<tran_id>").append("<![CDATA["+tranId+"]]>").append("</tran_id>\r\n");
retTabSepStrBuff.append("</Detail2>\r\n");
}
retTabSepStrBuff.append("</Header0>\r\n");
retTabSepStrBuff.append("</group0>\r\n");
retTabSepStrBuff.append("</DocumentRoot>\r\n");
errString = retTabSepStrBuff.toString();
callPstRs(pstmt, rs);
} catch (Exception e) {
e.printStackTrace();
System.out.println(":::::"+this.getClass().getSimpleName()+":::::" + e.getMessage());
throw new ITMException(e);
} finally {
try {
conn.close();
conn = null;
} catch (Exception e) {
errString = e.getMessage();
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
@Override
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException, ITMException {
String rtStr = "";
Document dom = null;
Document dom2 = null;
System.out.println("xmlString: "+xmlString);
System.out.println("xmlString2: "+xmlString2);
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
dom2 = genericUtility.parseString(xmlString2);
}
rtStr = process(dom, dom2, windowName, xtraParams);
} catch (Exception e) {
System.out.println("::::"+this.getClass().getSimpleName()+"::processString" + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return rtStr;
}
@Override
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException, ITMException {
String errString = "";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn=null;
int childNodeListLength = 0, parentNodeListLength = 0;
String childNodeName = "";
boolean result=false;
String custCode="",custName="",prdCode="",itemSer="",stanCode="",stanCodeNew="",salesValue="",tranId="";
String chgTerm="",chgUser="",selectedCheck="";
try {
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
System.out.println("In process pricelist:::");
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
parentNodeList = dom2.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
if(parentNodeListLength == 0)
{
errString = itmDBAccessEJB.getErrorString("","VPSELONERD","","",conn);
return errString;
}
System.out.println("::::::parentNodeListLength["+parentNodeListLength+"]");
for (int i = 0; i < parentNodeListLength; i++)
{
parentNode = parentNodeList.item(i);
System.out.println("parentNodeList>>>>>"+parentNodeList.item(i));
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength : "+childNodeListLength+" childNodeList : "+childNodeList);
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
System.out.println("childNodeList.item(childRow) : "+ childNode);
System.out.println("childNode Name : "+childNode.getNodeName()+" value::"+childNode.getNodeValue());
if("cust_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
custCode=checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("custCode>>>>>>>"+custCode);
}
else if("cust_name".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
custName=checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("custName>>>>>>>"+custName);
}
else if("prd_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
prdCode=checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("prdCode>>>>>>>"+prdCode);
}
else if("item_ser".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
itemSer=checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("itemSer>>>>>>>"+itemSer);
}
else if("stan_code".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
stanCode=checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("stanCode>>>>>>>"+stanCode);
}
else if("stan_code_new".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
stanCodeNew=checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("stanCodeNew>>>>>>>"+stanCodeNew);
}
else if("sales_value".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
salesValue=checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("salesValue>>>>>>>"+salesValue);
}
else if("tran_id".equalsIgnoreCase(childNodeName) && childNode.getFirstChild()!=null)
{
tranId=checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("tranId>>>>>>>"+tranId);
}
}
System.out.println("tranId>>>"+tranId+">>stanCodeNew>>"+stanCodeNew);
result=updateData(tranId,stanCodeNew,chgTerm,chgUser, conn);
if (!result) {
conn.rollback();
errString = itmDBAccessEJB.getErrorString("", "VTDATAFAIL", "","", conn);
}
else
{
conn.commit();
}
}
if (result) {
//conn.commit();
errString = itmDBAccessEJB.getErrorString("", "VTDATASUCC", "","", conn);
}
else
{
errString = itmDBAccessEJB.getErrorString("", "VTDATAFAIL", "","", conn);
}
} catch (Exception e) {
System.out.println("::::Exception::::"+this.getClass().getSimpleName()+":::::" + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public boolean updateData(String tranId,String stanCodeNew,String chgTerm,String chgUser,Connection conn)
{
String sql = null;
PreparedStatement pstmt = null;
int upd = 0;
try
{
sql = "UPDATE SALES_CONSOLIDATION set STAN_CODE_NEW=?,CHG_DATE=SYSDATE,CHG_TERM=?,CHG_USER=? where tran_id=?";
System.out.println("upd sql............." + sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, stanCodeNew);
pstmt.setString(2, chgTerm);
pstmt.setString(3, chgUser);
pstmt.setString(4, tranId);
upd = pstmt.executeUpdate();
System.out.println("upd count::::"+upd);
pstmt.close();
pstmt = null;
}
catch (Exception ex)
{
ex.printStackTrace();
upd=0;
}
if (upd == 0){
return false;
}
else{
return true;
}
}
public void callPstRs(PreparedStatement pstmt, ResultSet rs)
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
private String checkNull(String input)
{
input = input == null ? "" : input.trim();
return input;
}
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ProcessLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface StanCodeUpdPrcLocal extends ProcessLocal
{
public String getData(String arg0, String arg1, String arg2, String arg3) throws RemoteException ,ITMException ;
public String process(String arg0, String arg1, String arg2, String arg3) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ProcessRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface StanCodeUpdPrcRemote extends ProcessRemote
{
public String getData(String arg0, String arg1, String arg2, String arg3) throws RemoteException ,ITMException ;
public String process(String arg0, String arg1, String arg2, String arg3) throws RemoteException, ITMException;
}
...@@ -32,34 +32,60 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo ...@@ -32,34 +32,60 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo
public String submit(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException public String submit(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{ {
System.out.println(">>>>>>>>>>>>>>>>>>CustStockGWTConf submit called>>>>>>>>>>>>>>>>>>>"); System.out.println(">>>>>>>>>>>>>>>>>>CustStockGWTConf submit called>>>>>>>>>>>>>>>>>>>");
String sql = "",status="",confirmed=""; String sql = "",status="",confirmed="",sql1="",sql2="";
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null;
PreparedStatement pstmt2 = null;
String errString = null; String errString = null;
ResultSet rs = null; ResultSet rs = null;
ResultSet rs1 = null;
ResultSet rs2 = null;
String methodName = ""; String methodName = "";
String compName = ""; String compName = "";
String retString = ""; String retString = "";
String serviceCode = ""; String serviceCode = "";
String serviceURI = ""; String serviceURI = "";
String actionURI = ""; String actionURI = "";
int cnt = 0; String missingInserted="",transitUpdate="",loginEmpCode="",userId="",empCode="";
String transitFlag="",siteCode="",custCode="",totclValue="",totSalesValue="",tranType="",stockMode="";
String lineNo="",invoiceId="",itemCode="";
double transitQty=0.0,invoiceQty=0.0,clStock=0.0;
int cnt = 0,cnfCnt=0;
Timestamp currDate = null,tranDate=null;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
E12GenericUtility genericUtility= new E12GenericUtility();
try try
{ {
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("loginEmpCode>>>>"+loginEmpCode+">>>userId>>>"+userId);
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
currDate = java.sql.Timestamp.valueOf(sdf1.format(new java.util.Date()).toString() + " 00:00:00.0");
System.out.println("currDate>>>>"+currDate);
ConnDriver connDriver = null; ConnDriver connDriver = null;
connDriver = new ConnDriver(); connDriver = new ConnDriver();
//Changes and Commented By Bhushan on 09-06-2016 :START conn = connDriver.getConnectDB("DriverITM");
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
conn.setAutoCommit(false); conn.setAutoCommit(false);
sql="select emp_code from users where code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if(rs.next())
{
empCode = rs.getString("emp_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("empCode>>>>>"+empCode);
if (tranId != null && tranId.trim().length() > 0) if (tranId != null && tranId.trim().length() > 0)
{ {
System.out.println("tranId>>>["+tranId+"]"); System.out.println("tranId>>>["+tranId+"]");
sql = " select status,confirmed from cust_stock where tran_id = ? "; sql = " select status,confirmed,missing_inserted, transit_update from cust_stock where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -67,6 +93,8 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo ...@@ -67,6 +93,8 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo
{ {
status = rs.getString("status"); status = rs.getString("status");
confirmed = rs.getString("confirmed"); confirmed = rs.getString("confirmed");
missingInserted = rs.getString("missing_inserted");
transitUpdate = rs.getString("transit_update");
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -75,6 +103,165 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo ...@@ -75,6 +103,165 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo
System.out.println("status>>>>>>>>"+status); System.out.println("status>>>>>>>>"+status);
if(!"Y".equalsIgnoreCase(confirmed) && !"S".equalsIgnoreCase(status)) if(!"Y".equalsIgnoreCase(confirmed) && !"S".equalsIgnoreCase(status))
{ {
//start added by chandrashekar on 31-dec-2015
if(!"Y".equalsIgnoreCase(missingInserted))
{
errString = itmDBAccessLocal.getErrorString("", "VTMISSITEM", "");
return errString;
}
if(transitUpdate == null || transitUpdate.trim().length()==0 || "N".equalsIgnoreCase(transitUpdate))
{
sql = " select transit_flag, site_code, cust_code, tran_date, tot_cl_value, tot_sales_value,tran_type" +
" from cust_stock where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
transitFlag = rs.getString("transit_flag");
siteCode = rs.getString("site_code");
custCode = rs.getString("cust_code");
tranDate = rs.getTimestamp("tran_date");
totclValue = rs.getString("tot_cl_value");
totSalesValue = rs.getString("tot_sales_value");
tranType = rs.getString("tran_type");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = " SELECT VAR_VALUE FROM DISPARM WHERE PRD_CODE = '999999' AND VAR_NAME = 'CUST_STOCK_MODE'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
stockMode = checkNull(rs.getString("VAR_VALUE"));
System.out.println("stockMode :" + stockMode);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(stockMode == null || "NULLFOUND".equalsIgnoreCase(stockMode)|| stockMode.trim().length()==0)
{
stockMode="S";
}
if(transitFlag == null || transitFlag.trim().length()==0)
{
transitFlag="N";
}
if("S".equalsIgnoreCase(tranType))
{
sql = "Select line_no, item_code, transit_qty, cl_stock, sales,op_stock, purc_rcp," +
" adj_qty, purc_ret, adhoc_repl_qty, unit " +
"From cust_stock_det Where tran_id = ? " +
"and case when transit_qty is null then 0 else transit_qty end = 0";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while (rs.next())
{
lineNo = rs.getString("line_no");
clStock = rs.getDouble("cl_stock");
transitQty = rs.getDouble("transit_qty");
itemCode = rs.getString("item_code");
System.out.println("itemcode@@@@@@>>"+itemCode);
sql1 = "update cust_stock_det set original_cl_stock = ? "
+ "where tran_id = ? and line_no = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setDouble(1, clStock);
pstmt1.setString(2, tranId);
pstmt1.setString(3, lineNo);
cnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
if (transitQty == 0)
{
sql1 = "Select invoice_id From cust_stock_inv Where tran_id = ? and dlv_flg = 'N'";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
rs1 = pstmt1.executeQuery();
while (rs1.next())
{
invoiceId = checkNull(rs1.getString("invoice_id"));
System.out.println("invoiceId :" + invoiceId);
sql2 = "Select sum(quantity__stduom) as invoice_qty From "
+ "invdet Where invoice_id = ? " + "and item_code = ? ";
pstmt2 = conn.prepareStatement(sql2);
pstmt2.setString(1, invoiceId);
pstmt2.setString(2, itemCode);
rs2 = pstmt2.executeQuery();
if (rs2.next())
{
invoiceQty = rs2.getDouble("invoice_qty");
System.out.println("invoiceQty :" + invoiceQty);
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
transitQty = transitQty + invoiceQty;
}// invoice loop
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
if (transitQty != 0)
{
sql = "update cust_stock_det set transit_qty = ? "
+ " where tran_id = ? "
+ " and line_no = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setDouble(1, transitQty);
pstmt1.setString(2, tranId);
pstmt1.setString(3, lineNo);
cnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
}
}//cust_stock_det loop
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "update cust_stock set transit_upd_flag = 'Y' where tran_id = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, tranId);
cnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
}
}
sql = " update cust_stock set confirmed = 'Y', conf_date = ?, emp_code__aprv = ?,status = 'S' " +
" where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, currDate);
//pstmt.setString(2, loginEmpCode);//empCode
pstmt.setString(2, empCode);
pstmt.setString(3, tranId);
cnfCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if (cnfCnt>0)
{
conn.commit();
errString = itmDBAccessLocal.getErrorString("", "VTSUBM1", "");
}
//End added by chandrashekar on 31-dec-2015
/*
methodName = "gbf_post"; methodName = "gbf_post";
actionURI = "http://NvoServiceurl.org/" + methodName; actionURI = "http://NvoServiceurl.org/" + methodName;
...@@ -87,18 +274,6 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo ...@@ -87,18 +274,6 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo
compName = rs.getString("COMP_NAME"); compName = rs.getString("COMP_NAME");
} }
System.out.println(">>>cust stock confirmation serviceCode = " + serviceCode + " compName " + compName); System.out.println(">>>cust stock confirmation serviceCode = " + serviceCode + " compName " + compName);
// Changed by Manish on 01/04/16 for max cursor issue [start]
if (pstmt != null)
{
pstmt.close();
pstmt=null;
}
if (rs !=null)
{
rs.close();
rs=null;
}
// Changed by Manish on 01/04/16 for max cursor issue [end]
sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? "; sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, serviceCode); pstmt.setString(1, serviceCode);
...@@ -108,18 +283,6 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo ...@@ -108,18 +283,6 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo
serviceURI = rs.getString("SERVICE_URI"); serviceURI = rs.getString("SERVICE_URI");
} }
System.out.println(">>>cust stock confirmation serviceURI = " + serviceURI + " compName = " + compName); System.out.println(">>>cust stock confirmation serviceURI = " + serviceURI + " compName = " + compName);
// Changed by Manish on 01/04/16 for max cursor issue [start]
if (pstmt != null)
{
pstmt.close();
pstmt=null;
}
if (rs !=null)
{
rs.close();
rs=null;
}
// Changed by Manish on 01/04/16 for max cursor issue [end]
Service service = new Service(); Service service = new Service();
Call call = (Call) service.createCall(); Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI)); call.setTargetEndpointAddress(new java.net.URL(serviceURI));
...@@ -157,7 +320,7 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo ...@@ -157,7 +320,7 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo
conn.commit(); conn.commit();
} }
} }*///commented by chandrashekar on 04-01-2016
}else }else
{ {
errString = itmDBAccessLocal.getErrorString("", "VTINVSUB2", ""); errString = itmDBAccessLocal.getErrorString("", "VTINVSUB2", "");
...@@ -233,10 +396,7 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo ...@@ -233,10 +396,7 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo
ConnDriver connDriver = null; ConnDriver connDriver = null;
connDriver = new ConnDriver(); connDriver = new ConnDriver();
//Changes and Commented By Bhushan on 09-06-2016 :START conn = connDriver.getConnectDB("DriverITM");
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
conn.setAutoCommit(false); conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0) if (tranId != null && tranId.trim().length() > 0)
...@@ -323,5 +483,12 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo ...@@ -323,5 +483,12 @@ public class CustStockGWTConf extends ActionHandlerEJB implements CustStockGWTCo
return errString; return errString;
} }
private String checkNull(String input)
{
if (input == null)
{
input="";
}
return input;
}
} }
\ No newline at end of file
/******************************************************** /********************************************************
Title : CustStockGWTConfLocal[D15ESUN013] Title : CustStockGWTConfLocal[D15ESUN013]
Date : 27/10/15 Date : 27/10/15
Developer: Chandrashekar Developer: Chandrashekar
********************************************************/ ********************************************************/
package ibase.webitm.ejb.dis.adv; package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException; import java.rmi.RemoteException;
//import javax.ejb.EJBObject; //import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal; import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3 import javax.ejb.Local; // added for ejb3
@Local // added for ejb3 @Local // added for ejb3
public interface CustStockGWTConfLocal extends ActionHandlerLocal public interface CustStockGWTConfLocal extends ActionHandlerLocal
{ {
public String submit(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException; public String submit(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String open(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException; public String open(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
} }
/******************************************************** /********************************************************
Title : CustStockGWTConfRemote[D15ESUN013] Title : CustStockGWTConfRemote[D15ESUN013]
Date : 27/10/15 Date : 27/10/15
Developer: Chandrashekar Developer: Chandrashekar
********************************************************/ ********************************************************/
package ibase.webitm.ejb.dis.adv; package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3 import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3 @Remote // added for ejb3
public interface CustStockGWTConfRemote extends ActionHandlerRemote public interface CustStockGWTConfRemote extends ActionHandlerRemote
{ {
public String submit(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException; public String submit(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String open(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException; public String open(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment