Commit 2173e45e authored by Ketan Patil's avatar Ketan Patil

Update src/ibase/webitm/ejb/phizzy/PhyziiCommentApiSch.java,...

Update src/ibase/webitm/ejb/phizzy/PhyziiCommentApiSch.java, src/ibase/webitm/ejb/phizzy/PhyziiIC.java, src/ibase/webitm/ejb/phizzy/PhyziiICLocal.java, src/ibase/webitm/ejb/phizzy/PhyziiICRemote.java, src/ibase/webitm/ejb/phizzy/PhyziiPaymentPushApiSch.java, src/ibase/webitm/ejb/phizzy/PhyziiPosSave.java, src/ibase/webitm/ejb/phizzy/PhyziiPosSaveLocal.java, src/ibase/webitm/ejb/phizzy/PhyziiPosSaveRemote.java, src/ibase/webitm/ejb/phizzy/PhyziiPushApiSch.java, src/ibase/webitm/ejb/phizzy/AutomaticPaymentNewSCH.java, src/ibase/webitm/ejb/phizzy/PhyziiPushApiSch2.java, src/ibase/webitm/ejb/phizzy/VoucherPrintingScheduler.java, src/ibase/webitm/ejb/phizzy/PhyzziAcknowledgementSch.java, src/ibase/webitm/ejb/phizzy/PhyziiPullApiSch.java, src/ibase/webitm/ejb/phizzy/FinCommon.java files
parent 79e50173
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
package ibase.webitm.ejb.phizzy;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.URL;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import javax.lang.model.element.Element;
import javax.naming.InitialContext;
import org.json.JSONArray;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseException;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.Messages;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONObject;
//import ibase.planner.utility.ITMException;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseException;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
public class PhyziiCommentApiSch extends ValidatorEJB implements Schedule {
@Override
public String schedulePriority(String wrkflwPriority) throws Exception {
System.out.println("schedulePriority..1");
return "";
}
public String schedule(HashMap map) throws Exception {
System.out.println("schedulePriority..2");
return "";
}
public String schedule(String scheduleParamXML) throws ITMException, Exception {
String flag = "PWC";
String reultString = "";
try {
System.out.println("schedulePriority..3");
reultString = update(scheduleParamXML, flag);
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
return reultString;
}
public String update(String scheduleParamXML, String flag) throws BaseException, Exception
{
System.out.println("inside method ===>");
ibase.utility.UserInfoBean userInfo = null;
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null,pstmt1=null;
String selectQuery = "";
String sql="";
String cont = "";
int cnt=0;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
userInfo = new UserInfoBean(scheduleParamXML);
String transDB = userInfo.getTransDB();
String loginCode = userInfo.getLoginCode();
System.out.println(
"get TransDB & login code connection in updateStatus : " + transDB + "::loginCode::" + loginCode);
if (transDB != null && transDB.trim().length() > 0) { conn =
connDriver.getConnectDB(transDB); }
else { conn = connDriver.getConnectDB("DriverITM");
}
if (conn == null) { conn = connDriver.getConnectDB("DriverITM"); } connDriver
= null; conn.setAutoCommit(false);
FinCommon disCom1 = new FinCommon();
String fizzSkApiName = disCom1.getFinparams("999999", "FIZZ_SK_API_NAME_PAY", conn);
String fizzSkApiKey = disCom1.getFinparams("999999", "FIZZ_SK_API_KEY_PAY", conn);
String fizzSkApiCtype = disCom1.getFinparams("999999", "FIZZ_SK_API_CTYPE", conn);
String fizzSkApiComment = disCom1.getFinparams("999999", "FIZZ_SK_API_PUSH_COMMENT", conn);
String fizzSkApiIp = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_IP", conn);
String fizzSkProxyPort = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_PORT", conn);
final String fizzSkProxyUname = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_UNAME", conn);
final String fizzSkProxyPass = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_PASS", conn);
/*
* conn = connDriver.getConnectDB("DriverITM"); conn.setAutoCommit(false);
*/
userInfo = new ibase.utility.UserInfoBean();
selectQuery = "select EXPENSE_UNIQUE_ID,VOUCH_NO, DDF_GET_COMMENTS('M-VOUC',VOUCH_NO) as COMMENT from Phyzii_metis_track_hdr where error_flag in ('P') GROUP BY EXPENSE_UNIQUE_ID,VOUCH_NO HAVING FN_GET_COMMENTS_CNT (VOUCH_NO) > 0";
pstmt = conn.prepareStatement(selectQuery);
//pstmt.setString(1, "P");
//pstmt.setString(2, "Y");
rs = pstmt.executeQuery();
System.out.println("rs===>"+rs);
while (rs.next())
{
System.out.println("IN WHILE");
String expenseUniqueId = checkNull(rs.getString("EXPENSE_UNIQUE_ID"));
System.out.println("uniqueid==> "+expenseUniqueId);
String tranIdVoucher= checkNull(rs.getString("VOUCH_NO"));
String comment= checkNull(rs.getString("COMMENT"));
System.out.println("VOUCH_NOnew=vijay====> "+tranIdVoucher);
System.out.println("VOUCH_NOnew=vijay====> "+comment);
if(comment.trim().length() > 0) {
String query="";
query="[{ " +
" \"EXPENSE_UNIQUE_ID\": \""+expenseUniqueId+"\", " +
" \"DOCNO\": \""+tranIdVoucher+"\", " +
" \"COMMENT\": \""+comment+"\" }]";
System.out.println("Retrival json::"+query);
//String urlStr=fizzSkApiPuSH;
URL url = new URL(fizzSkApiComment);
System.out.println("@S@ url using %20["+url+"]");
System.out.println("Start iteration of response==>" + new java.sql.Timestamp(System.currentTimeMillis()));
int proxyPortInt = 0;
if (!fizzSkProxyPort.equalsIgnoreCase("NULLFOUND")) {
proxyPortInt = Integer.parseInt(fizzSkProxyPort);
}
if (fizzSkProxyPort.equalsIgnoreCase("NULLFOUND")) {
proxyPortInt = 8080;
}
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(fizzSkApiIp, proxyPortInt));
HttpURLConnection conn7 = (HttpURLConnection) url.openConnection(proxy);
System.out.println("Test++");
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication(fizzSkProxyUname, fizzSkProxyPass.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
System.out.println("Verify++");
conn7.setDoOutput(true);
conn7.setRequestMethod("POST");
conn7.setUseCaches(false);
conn7.setRequestProperty(fizzSkApiName.trim(), fizzSkApiKey.trim());
conn7.setRequestProperty("Content-Type", fizzSkApiCtype.trim());
try {
conn7.connect();
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
System.out.println("After Try & catch");
try
{
System.out.println("In OutputStream block");
OutputStream os = conn7.getOutputStream();
os.write(query.getBytes());
os.flush();
System.out.println("After OutputStream flush");
}
catch (Exception e)
{
System.out.println( "Exception - "+ e.getMessage() );
e.printStackTrace();
}
System.out.println( "URL: "+ url );
System.out.println( "ResponseCode: "+ conn7.getResponseCode() );
System.out.println( "ResponseMessage Ketan: "+ conn7.getResponseMessage() );
if(conn7.getResponseCode()==200) {
System.out.println("IN KETTTTTAN");
String sql1 = "update PHYZII_METIS_TRACK_HDR set comment_flag='Y' where EXPENSE_UNIQUE_ID=? and vouch_no=?";
System.out.println("==>inside SQL" + sql1);
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, expenseUniqueId);
pstmt1.setString(2, tranIdVoucher);
cnt = pstmt1.executeUpdate();
if (cnt > 0) {
conn.commit();
System.out.println("misc voucher inserted successfully" + sql);
}else {
System.out.println("No Update");
}
if (pstmt1 != null) {
if (!pstmt1.isClosed()) {
pstmt1.close();
}
pstmt1 = null;
}
}
}
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
catch (Exception e)
{
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
return "";
}
private String checkNull(String input) {
if (input == null) {
input = "";
}
return input.trim();
}
}
package ibase.webitm.ejb.phizzy;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
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.ejb.fin.FinCommon;
import ibase.webitm.utility.ITMException;
public class PhyziiIC extends ValidatorEJB implements PhyziiICLocal, PhyziiICRemote
{
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 PriSecSalesConsolidationIC 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 : [PriSecSalesConsolidationIC][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 empCode="" , prdCode = "" ,maxPrdCode="" ,countryCode="", accPeriod="" ,versionId="",prdCodeFrm="",prdCodeTo="";
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try {
System.out.println("************xtraParams*************" + xtraParams);
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
System.out.println("In wfValData PriSecSalesConsolidationIC :::");
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 ("emp_no".equalsIgnoreCase(childNodeName))
{
empCode = genericUtility.getColumnValue("emp_no", currDom);
System.out.println("wfValData>>itemSer>>"+empCode);
if(empCode == null || empCode.trim().length()==0 )
{
errString = itmDBAccessEJB.getErrorString("emp_no","VMNULLEMP",userId);
break;
}
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)
{
errString = itmDBAccessEJB.getErrorString("emp_no","VTINVEMP",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;
}
private String checkNull(String str)
{
if(str == null)
{
return "";
}
else
{
return str ;
}
}
}
/********************************************************
Title : AdjIssueICLocal[D16ASUN021]
Date : 29/04/16
Developer: Chandrashekar
********************************************************/
package ibase.webitm.ejb.phizzy;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface PhyziiICLocal 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 objCotext, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : AdjIssueICRemote[D16ASUN021]
Date : 29/04/16
Developer: Chandrashekar
********************************************************/
package ibase.webitm.ejb.phizzy;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
import ibase.webitm.ejb.ValidatorRemote;// added for ejb3
@Remote // added for ejb3
public interface PhyziiICRemote 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;
}
\ No newline at end of file
package ibase.webitm.ejb.phizzy;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.URL;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import javax.lang.model.element.Element;
import javax.naming.InitialContext;
import org.json.JSONArray;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseException;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.Messages;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONObject;
//import ibase.planner.utility.ITMException;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseException;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
public class PhyziiPaymentPushApiSch extends ValidatorEJB implements Schedule {
@Override
public String schedulePriority(String wrkflwPriority) throws Exception {
System.out.println("schedulePriority..1");
return "";
}
public String schedule(HashMap map) throws Exception {
System.out.println("schedulePriority..2");
return "";
}
public String schedule(String scheduleParamXML) throws ITMException, Exception {
String flag = "PWC";
String reultString = "";
try {
System.out.println("schedulePriority..3");
reultString = update(scheduleParamXML, flag);
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
return reultString;
}
public String update(String scheduleParamXML, String flag) throws BaseException, Exception
{
System.out.println("inside method ===>");
ibase.utility.UserInfoBean userInfo = null;
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null,pstmt1=null;
String selectQuery = "";
String sql="";
String cont = "";
int cnt=0;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
userInfo = new UserInfoBean(scheduleParamXML);
String transDB = userInfo.getTransDB();
String loginCode = userInfo.getLoginCode();
System.out.println(
"get TransDB & login code connection in updateStatus : " + transDB + "::loginCode::" + loginCode);
if (transDB != null && transDB.trim().length() > 0) { conn =
connDriver.getConnectDB(transDB); }
else { conn = connDriver.getConnectDB("DriverITM");
}
if (conn == null) { conn = connDriver.getConnectDB("DriverITM"); } connDriver
= null; conn.setAutoCommit(false);
FinCommon disCom1 = new FinCommon();
String fizzSkApiName = disCom1.getFinparams("999999", "FIZZ_SK_API_NAME_PAY", conn);
String fizzSkApiKey = disCom1.getFinparams("999999", "FIZZ_SK_API_KEY_PAY", conn);
String fizzSkApiCtype = disCom1.getFinparams("999999", "FIZZ_SK_API_CTYPE", conn);
String fizzSkApiPush = disCom1.getFinparams("999999", "FIZZ_SK_API_PUSH_PAY", conn);
String fizzSkApiIp = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_IP", conn);
String fizzSkProxyPort = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_PORT", conn);
final String fizzSkProxyUname = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_UNAME", conn);
final String fizzSkProxyPass = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_PASS", conn);
/*
* conn = connDriver.getConnectDB("DriverITM"); conn.setAutoCommit(false);
*/
userInfo = new ibase.utility.UserInfoBean();
selectQuery = "SELECT VOUCH_NO,DDF_GET_PAYDET(VOUCH_NO,'T') as PAY_NO,DDF_GET_PAYDET(VOUCH_NO,'D') as PAY_DATE,DDF_GET_PAYDET(VOUCH_NO,'A') as PAY_AMT FROM PHYZII_METIS_TRACK_HDR WHERE ERROR_FLAG ='P' AND VOUCH_no is not null and (pay_flag !='Y' or vouch_flag is null)";
pstmt = conn.prepareStatement(selectQuery);
//pstmt.setString(1, "P");
//pstmt.setString(2, "Y");
rs = pstmt.executeQuery();
System.out.println("rs===>"+rs);
while (rs.next())
{
System.out.println("IN WHILE");
String expenseUniqueId = checkNull(rs.getString("EXPENSE_UNIQUE_ID"));
System.out.println("uniqueid==> "+expenseUniqueId);
String tranIdVoucher= checkNull(rs.getString("VOUCH_NO"));
String tranIdPayment= checkNull(rs.getString("PAY_NO"));
String tranIdPaymentDt= checkNull(rs.getString("PAY_DATE"));
String tranIdPaymentAmt= checkNull(rs.getString("PAY_AMT"));
System.out.println("VOUCH_NOnew=vijay====> "+tranIdVoucher);
System.out.println("VOUCH_NOnew=vijay====> "+tranIdPayment);
System.out.println("VOUCH_NOnew=vijay====> "+tranIdPaymentDt);
System.out.println("VOUCH_NOnew=vijay====> "+tranIdPaymentAmt);
if(tranIdPayment.trim().length() > 0) {
String query="";
query="[{ " +
" \"EXPENSE_UNIQUE_ID\": \""+expenseUniqueId+"\", " +
" \"PAYMENTID\": \""+tranIdPayment+"\", " +
" \"DOCNO\": \""+tranIdVoucher+"\", " +
" \"BANKNAME\": \""+""+"\", " +
" \"PAYMENTDT\": \""+tranIdPaymentDt+"\", " +
" \"PAYAMT\": \""+tranIdPaymentAmt+"\", " +
" \"ADVADJAMT\": \""+"NA"+"\", " +
" \"CANCEL_ID\": \""+"NA"+"\", " +
" \"FLAG\": \""+"I"+"\" " +"\" }]";
System.out.println("Retrival json::"+query);
//String urlStr=fizzSkApiPuSH;
URL url = new URL(fizzSkApiPush);
System.out.println("@S@ url using %20["+url+"]");
System.out.println("Start iteration of response==>" + new java.sql.Timestamp(System.currentTimeMillis()));
int proxyPortInt = 0;
if (!fizzSkProxyPort.equalsIgnoreCase("NULLFOUND")) {
proxyPortInt = Integer.parseInt(fizzSkProxyPort);
}
if (fizzSkProxyPort.equalsIgnoreCase("NULLFOUND")) {
proxyPortInt = 8080;
}
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(fizzSkApiIp, proxyPortInt));
HttpURLConnection conn7 = (HttpURLConnection) url.openConnection(proxy);
System.out.println("Test++");
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication(fizzSkProxyUname, fizzSkProxyPass.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
System.out.println("Verify++");
conn7.setDoOutput(true);
conn7.setRequestMethod("POST");
conn7.setUseCaches(false);
conn7.setRequestProperty(fizzSkApiName.trim(), fizzSkApiKey.trim());
conn7.setRequestProperty("Content-Type", fizzSkApiCtype.trim());
try {
conn7.connect();
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
System.out.println("After Try & catch");
try
{
System.out.println("In OutputStream block");
OutputStream os = conn7.getOutputStream();
os.write(query.getBytes());
os.flush();
System.out.println("After OutputStream flush");
}
catch (Exception e)
{
System.out.println( "Exception - "+ e.getMessage() );
e.printStackTrace();
}
System.out.println( "URL: "+ url );
System.out.println( "ResponseCode: "+ conn7.getResponseCode() );
System.out.println( "ResponseMessage Ketan: "+ conn7.getResponseMessage() );
if(conn7.getResponseCode()==200) {
System.out.println("IN KETTTTTAN");
String sql1 = "update PHYZII_METIS_TRACK_HDR set pay_flag='Y',payment_id= ? where EXPENSE_UNIQUE_ID=? and vouch_no=?";
System.out.println("==>inside SQL" + sql1);
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranIdPayment);
pstmt1.setString(2, expenseUniqueId);
pstmt1.setString(3, tranIdVoucher);
cnt = pstmt1.executeUpdate();
if (cnt > 0) {
conn.commit();
System.out.println("misc voucher inserted successfully" + sql);
}else {
System.out.println("No Update");
}
if (pstmt1 != null) {
if (!pstmt1.isClosed()) {
pstmt1.close();
}
pstmt1 = null;
}
}
}
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
catch (Exception e)
{
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
return "";
}
private String checkNull(String input) {
if (input == null) {
input = "";
}
return input.trim();
}
}
package ibase.webitm.ejb.phizzy;
import ibase.ejb.E12EMAILComp;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseLogger;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.UnAllocatedDocEJBLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.io.File;
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.Calendar;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Session Bean implementation class MarketingBillPosEJB
*/
@Stateless
public class PhyziiPosSave extends ValidatorEJB implements PhyziiPosSaveRemote, PhyziiPosSaveLocal
{
E12GenericUtility genericUtility = new E12GenericUtility();
String errString = "" ;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
/**
* Default constructor.
*/
public PhyziiPosSave()
{
// TODO Auto-generated constructor stub
}
@Override
public String postSave(String xmlStringAll, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException
{
Document dom = null;
String retString="";
//By VALLABH KADAM.
String suppCode="",porderNo="",billNo="",reasonCodes="",voucherNo="",status="", sundryType = "", sundryCode = "", docType = "";// Added by parikshit on 15/02/16 [added docType variable - F15KSUN007 ]
int cnt=0,cnt1=0;
Timestamp billDate=null,billRcvDate=null;
PreparedStatement pstmt1=null,pstmt2=null,pstmt3=null,pstmt=null;
ResultSet rs1=null,rs2=null,rs3=null,rs=null;
String sql1="",sql2="",sql3="",sql="";
String transDB="";
String chgUser="";
String loginEmpCode="";
String loginSiteCode="";
ibase.utility.UserInfoBean userInfo=null;
String empCode="";
// By VALLABH KADAM.
System.out.println("PostSave Action Called:::"+ xmlStringAll);
System.out.println("PostSave editFlag:::"+ editFlag);
try
{
dom = genericUtility.parseString(xmlStringAll);
userInfo = new ibase.utility.UserInfoBean();
System.out.println("xtraParams>>>>" + xtraParams);
String userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
String termId = getValueFromXTRA_PARAMS(xtraParams, "termId");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
userInfo.setEmpCode(loginEmpCode);
userInfo.setRemoteHost(termId);
userInfo.setSiteCode(loginSiteCode);
userInfo.setLoginCode(userId);
userInfo.setEntityCode(loginEmpCode);
// if ( editFlag.equalsIgnoreCase( "A" ) )
// {
// String objName = checkNull(getObjNameFromDom(dom, "objName","1"));
//
// tranId = checkNull(genericUtility.getColumnValue("tran_id",dom, "1"));
// String billDocId = checkNull(genericUtility.getColumnValue("bill_doc_id",dom, "1"));
// empCode= checkNull(genericUtility.getColumnValue("emp_code",dom, "1"));
// System.out.println("billDocId>>> " +billDocId);
// System.out.println("objName = ["+ objName +"] tranId = ["+ tranId +"] billDocId = ["+ billDocId +"] userId = ["+ userId +"]");
//
// if ( empCode != null && empCode.trim().length() > 0)
//// {
//// int countCovid=0;
//// int countPassport=0;
//// int countPhoto=0;
//// int countPan=0;
//// int countElig=0;
////
//// sql="UPDATE PHYZII_METIS_TRACK_HDR SET ERROR_FLAG = ?,STATUS = ? WHERE TRAN_ID = ?";
//// System.out.println("==>inside SQL"+ sql);
////
//// pstmt1 = conn.prepareStatement(sql);
//// pstmt1.setString(1, "U");
//// pstmt1.setString(1, "");
//// pstmt1.setString(3, tranId);
////
//// cnt = pstmt1.executeUpdate();
//// {
//// countCovid = rs.getInt("cnt");
////
//// }
//// System.out.println("transDB = " + transDB);
//// if(rs != null)
//// {
//// rs.close();
//// rs= null;
//// }
//// if(pstmt != null)
//// {
//// pstmt.close();
//// pstmt = null;
//// }
//// if(countCovid == 0) {
//// errString = itmDBAccessEJB.getErrorString("emp_code","VTCOVIDCNT",userId);
//// return errString;
////
//// }
////
////
//// }
// }
tranId = checkNull(genericUtility.getColumnValue("tran_id",dom, "1"));
System.out.println("tranId==>"+tranId);
sql="UPDATE PHYZII_METIS_TRACK_HDR SET ERROR_FLAG = ?,STATUS = ? WHERE TRAN_ID = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, "U");
pstmt1.setString(1, "");
pstmt1.setString(3, tranId);
int count=pstmt1.executeUpdate();
System.out.println("post count---->String>["+count+"]");
if(count > 0) {
conn.commit();
}
}
catch(Exception e) {
e.printStackTrace();
}
return "";
}
private String getObjNameFromDom( Document dom, String attribute, String objContext ) throws RemoteException,ITMException
{
NodeList detailList = null;
Node currDetail = null;
String objName = "";
int detailListLength = 0;
try
{
detailList = dom.getElementsByTagName("Detail"+objContext);
detailListLength = detailList.getLength();
for (int ctr = 0; ctr < detailListLength; ctr++)
{
currDetail = detailList.item(ctr);
objName = currDetail.getAttributes().getNamedItem(attribute).getNodeValue();
}
}
catch ( Exception e )
{
throw new ITMException(e);
}
System.out.println("objName =["+objName+"]");
return objName;
}
private String checkNull(String input)
{
if (input == null || "null".equalsIgnoreCase(input))
{
input= "";
}
return input.trim();
}
}
package ibase.webitm.ejb.phizzy;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Local;
@Local
public interface PhyziiPosSaveLocal extends ValidatorLocal
{
public String postSave(String xmlStringAll, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.phizzy;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Remote;// added for ejb3
//public interface AdjIssPos extends ValidatorRemote, EJBObject //commented for ejb3
import ibase.webitm.ejb.ValidatorRemote;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
@Remote // added for ejb3
public interface PhyziiPosSaveRemote extends ValidatorRemote
{
public String postSave(String xmlStringAll, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException,ITMException;
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
package ibase.webitm.ejb.phizzy;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.URL;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import javax.lang.model.element.Element;
import javax.naming.InitialContext;
import org.json.JSONArray;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseException;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.Messages;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONObject;
//import ibase.planner.utility.ITMException;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseException;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
public class PhyziiPushApiSch extends ValidatorEJB implements Schedule {
@Override
public String schedulePriority(String wrkflwPriority) throws Exception {
System.out.println("schedulePriority..1");
return "";
}
public String schedule(HashMap map) throws Exception {
System.out.println("schedulePriority..2");
return "";
}
public String schedule(String scheduleParamXML) throws ITMException, Exception {
String flag = "PWC";
String reultString = "";
try {
System.out.println("schedulePriority..3");
reultString = update(scheduleParamXML, flag);
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
return reultString;
}
public String update(String scheduleParamXML, String flag) throws BaseException, Exception
{
System.out.println("inside method ===>");
ibase.utility.UserInfoBean userInfo = null;
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null,pstmt1=null;
String selectQuery = "";
String sql="";
String cont = "";
int cnt=0;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
userInfo = new UserInfoBean(scheduleParamXML);
String transDB = userInfo.getTransDB();
String loginCode = userInfo.getLoginCode();
System.out.println(
"get TransDB & login code connection in updateStatus : " + transDB + "::loginCode::" + loginCode);
if (transDB != null && transDB.trim().length() > 0) { conn =
connDriver.getConnectDB(transDB); }
else { conn = connDriver.getConnectDB("DriverITM");
}
if (conn == null) { conn = connDriver.getConnectDB("DriverITM"); } connDriver
= null; conn.setAutoCommit(false);
FinCommon disCom1 = new FinCommon();
String fizzSkApiName = disCom1.getFinparams("999999", "FIZZ_SK_API_NAME", conn);
String fizzSkApiKey = disCom1.getFinparams("999999", "FIZZ_SK_API_KEY", conn);
String fizzSkApiCtype = disCom1.getFinparams("999999", "FIZZ_SK_API_CTYPE", conn);
String fizzSkApiPush = disCom1.getFinparams("999999", "FIZZ_SK_API_PUSH", conn);
String fizzSkApiIp = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_IP", conn);
String fizzSkProxyPort = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_PORT", conn);
final String fizzSkProxyUname = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_UNAME", conn);
final String fizzSkProxyPass = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_PASS", conn);
/*
* conn = connDriver.getConnectDB("DriverITM"); conn.setAutoCommit(false);
*/
userInfo = new ibase.utility.UserInfoBean();
selectQuery = "select VOUCH_NO,EXPENSE_UNIQUE_ID from PHYZII_METIS_TRACK_HDR where ERROR_FLAG='P' and (vouch_flag !='Y' or vouch_flag is null)";
pstmt = conn.prepareStatement(selectQuery);
//pstmt.setString(1, "P");
//pstmt.setString(2, "Y");
rs = pstmt.executeQuery();
System.out.println("rs===>"+rs);
while (rs.next())
{
System.out.println("IN WHILE");
String expenseUniqueId = checkNull(rs.getString("EXPENSE_UNIQUE_ID"));
System.out.println("uniqueid==> "+expenseUniqueId);
String tranIdVoucher= checkNull(rs.getString("VOUCH_NO"));
System.out.println("VOUCH_NOnew=vijay====> "+tranIdVoucher);
String query="";
query="[{ " +
" \"EXPENSE_UNIQUE_ID\": \""+expenseUniqueId+"\", " +
" \"DOCNO\": \""+tranIdVoucher+"\", " +
" \"Status\": \""+"SUCCESS"+"\", " +
" \"Message\": \""+tranIdVoucher+" ==> SUCCESSFULLY CREATED."+"\" }]";
System.out.println("Retrival json::"+query);
//String urlStr=fizzSkApiPuSH;
URL url = new URL(fizzSkApiPush);
System.out.println("@S@ url using %20["+url+"]");
System.out.println("Start iteration of response==>" + new java.sql.Timestamp(System.currentTimeMillis()));
int proxyPortInt = 0;
if (!fizzSkProxyPort.equalsIgnoreCase("NULLFOUND")) {
proxyPortInt = Integer.parseInt(fizzSkProxyPort);
}
if (fizzSkProxyPort.equalsIgnoreCase("NULLFOUND")) {
proxyPortInt = 8080;
}
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(fizzSkApiIp, proxyPortInt));
HttpURLConnection conn7 = (HttpURLConnection) url.openConnection(proxy);
System.out.println("Test++");
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication(fizzSkProxyUname, fizzSkProxyPass.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
System.out.println("Verify++");
conn7.setDoOutput(true);
conn7.setRequestMethod("POST");
conn7.setUseCaches(false);
conn7.setRequestProperty(fizzSkApiName.trim(), fizzSkApiKey.trim());
conn7.setRequestProperty("Content-Type", fizzSkApiCtype.trim());
try {
conn7.connect();
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
System.out.println("After Try & catch");
try
{
System.out.println("In OutputStream block");
OutputStream os = conn7.getOutputStream();
os.write(query.getBytes());
os.flush();
System.out.println("After OutputStream flush");
}
catch (Exception e)
{
System.out.println( "Exception - "+ e.getMessage() );
e.printStackTrace();
}
System.out.println( "URL: "+ url );
System.out.println( "ResponseCode: "+ conn7.getResponseCode() );
System.out.println( "ResponseMessage Ketan: "+ conn7.getResponseMessage() );
if(conn7.getResponseCode()==200) {
System.out.println("IN KETTTTTAN");
String sql1 = "update PHYZII_METIS_TRACK_HDR set vouch_flag='Y' where EXPENSE_UNIQUE_ID=? and vouch_no=?";
System.out.println("==>inside SQL" + sql1);
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, expenseUniqueId);
pstmt1.setString(2, tranIdVoucher);
cnt = pstmt1.executeUpdate();
if (cnt > 0) {
conn.commit();
System.out.println("misc voucher inserted successfully" + sql);
}else {
System.out.println("No Update");
}
if (pstmt1 != null) {
if (!pstmt1.isClosed()) {
pstmt1.close();
}
pstmt1 = null;
}
}
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
catch (Exception e)
{
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
return "";
}
private String checkNull(String input) {
if (input == null) {
input = "";
}
return input.trim();
}
}
package ibase.webitm.ejb.phizzy;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.URL;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import javax.lang.model.element.Element;
import javax.naming.InitialContext;
import org.json.JSONArray;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseException;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.Messages;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONObject;
//import ibase.planner.utility.ITMException;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseException;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
public class PhyziiPushApiSch2 extends ValidatorEJB implements Schedule {
@Override
public String schedulePriority(String wrkflwPriority) throws Exception {
System.out.println("schedulePriority..1");
return "";
}
public String schedule(HashMap map) throws Exception {
System.out.println("schedulePriority..2");
return "";
}
public String schedule(String scheduleParamXML) throws ITMException, Exception {
String flag = "PWC";
String reultString = "";
try {
System.out.println("schedulePriority..3");
reultString = update(scheduleParamXML, flag);
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
return reultString;
}
public String update(String scheduleParamXML, String flag) throws BaseException, Exception
{
System.out.println("inside method ===>");
ibase.utility.UserInfoBean userInfo = null;
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null,pstmt1=null;
String selectQuery = "";
String sql="";
String cont = "";
int cnt=0;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
userInfo = new UserInfoBean(scheduleParamXML);
String transDB = userInfo.getTransDB();
String loginCode = userInfo.getLoginCode();
System.out.println(
"get TransDB & login code connection in updateStatus : " + transDB + "::loginCode::" + loginCode);
if (transDB != null && transDB.trim().length() > 0) { conn =
connDriver.getConnectDB(transDB); }
else { conn = connDriver.getConnectDB("DriverITM");
}
if (conn == null) { conn = connDriver.getConnectDB("DriverITM"); } connDriver
= null; conn.setAutoCommit(false);
/*
* conn = connDriver.getConnectDB("DriverITM"); conn.setAutoCommit(false);
*/
userInfo = new ibase.utility.UserInfoBean();
String expenseUniqueId = "0000000079";
System.out.println("uniqueid==> "+expenseUniqueId);
String tranIdVoucher= "006XFNBW94";
System.out.println("VOUCH_NOnew=vijay====> "+tranIdVoucher);
String query="";
query="[{ " +
" \"EXPENSE_UNIQUE_ID\": \""+expenseUniqueId+"\", " +
" \"DOCNO\": \""+tranIdVoucher+"\", " +
" \"Status\": \""+"SUCCESS"+"\", " +
" \"Message\": \""+tranIdVoucher+" ==> SUCCESSFULLY CREATED."+"\" }]";
System.out.println("Retrival json::"+query);
FinCommon disCom1 = new FinCommon();
String fizzSkApiName = disCom1.getFinparams("999999", "FIZZ_SK_API_NAME", conn);
String fizzSkApiKey = disCom1.getFinparams("999999", "FIZZ_SK_API_KEY", conn);
String fizzSkApiCtype = disCom1.getFinparams("999999", "FIZZ_SK_API_CTYPE", conn);
String fizzSkApiPull = disCom1.getFinparams("999999", "FIZZ_SK_API_PULL", conn);
String fizzSkApiIp = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_IP", conn);
String fizzSkProxyPort = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_PORT", conn);
final String fizzSkProxyUname = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_UNAME", conn);
final String fizzSkProxyPass = disCom1.getFinparams("999999", "FIZZ_SK_PROXY_PASS", conn);
//String urlStr="http://dev1.cirrius.in/CommonIntegrationAPI/Expense/ExpenseDataAck";
String urlStr="http://apiintegration.cirrius.in/CommonIntegrationAPI/Expense/ExpenseDataAck";
URL url = new URL(urlStr);
System.out.println("@S@ url using %20["+url+"]");
System.out.println("Start iteration of response==>" + new java.sql.Timestamp(System.currentTimeMillis()));
int proxyPortInt = 0;
if (!fizzSkProxyPort.equalsIgnoreCase("NULLFOUND")) {
proxyPortInt = Integer.parseInt(fizzSkProxyPort);
}
if (fizzSkProxyPort.equalsIgnoreCase("NULLFOUND")) {
proxyPortInt = 8080;
}
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(fizzSkApiIp, proxyPortInt));
HttpURLConnection conn7 = (HttpURLConnection) url.openConnection(proxy);
System.out.println("Test++");
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication(fizzSkProxyUname, fizzSkProxyPass.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
System.out.println("Verify++");
conn7.setDoOutput(true);
conn7.setRequestMethod("POST");
conn7.setUseCaches(false);
//conn7.setRequestProperty(fizzSkApiName.trim(), fizzSkApiKey.trim());
conn7.setRequestProperty(fizzSkApiName.trim(), "Q0hD");
conn7.setRequestProperty("Content-Type", fizzSkApiCtype.trim());
try {
conn7.connect();
} catch (Exception e) {
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
System.out.println("After Try & catch");
try
{
System.out.println("In OutputStream block");
OutputStream os = conn7.getOutputStream();
os.write(query.getBytes());
os.flush();
System.out.println("After OutputStream flush");
}
catch (Exception e)
{
System.out.println( "Exception - "+ e.getMessage() );
e.printStackTrace();
}
System.out.println( "URL: "+ url );
System.out.println( "ResponseCode: "+ conn7.getResponseCode() );
System.out.println( "ResponseMessage Ketan: "+ conn7.getResponseMessage() );
/*
* if(conn7.getResponseCode()==200) {
*
* String sql1 =
* "update PHYZII_METIS_TRACK_HDR set vouch_flag='Y' where EXPENSE_UNIQUE_ID=? and vouch_no=?"
* ; System.out.println("==>inside SQL" + sql1); pstmt1 =
* conn.prepareStatement(sql1); pstmt1.setString(1, expenseUniqueId);
* pstmt1.setString(2, tranIdVoucher); cnt = pstmt1.executeUpdate(); if (cnt >
* 0) { conn.commit(); System.out.println("misc voucher inserted successfully" +
* sql); } if (pstmt1 != null) { if (!pstmt1.isClosed()) { pstmt1.close(); }
* pstmt1 = null; } }
*/
}
catch (Exception e)
{
System.out.println("Exception - " + e.getMessage());
e.printStackTrace();
}
return "";
}
private String checkNull(String input) {
if (input == null) {
input = "";
}
return input.trim();
}
}
package ibase.webitm.ejb.phizzy;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.naming.InitialContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import org.apache.commons.io.FileUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.json.JSONArray;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.logging.SimpleFormatter;
import java.util.logging.XMLFormatter;
//import EasyXLS.ExcelAutoFormat;
//import EasyXLS.ExcelDocument;
//import EasyXLS.Constants.Styles;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.EMail;
import ibase.utility.MailInfo;
//import ibase.webitm.ejb.fin.servlet.ITMDBAccessEJB;
//import ibase.webitm.ejb.fin.servlet.UserInfoBean;
//import ibase.webitm.reports.utility.JasperReportGenerator;
//import ibase.webitm.reports.utility.ResourceConstants;
//import ibase.webitm.reports.utility.XSDParser;
import ibase.webitm.utility.ITMException;
public class PhyzziAcknowledgementSch implements Schedule {
String mailAddress = "";
private InitialContext ctx;
private ServletContext servletContext;
private ServletConfig servletConfig;
private E12GenericUtility genericUtility;
// private ITMDBAccessEJB itmDBAccess;
private String className = getClass().getSimpleName().toString();
private String fileDirectory;
private String filePath;
private String fileName;
private FileOutputStream fileOutputStream;
private XSSFWorkbook excelWorkbook;
private XSSFSheet excelSheet;
private FileHandler loggerFileHandler;
private Set<String> adCodeList;
private Set<String> vaildAdCodeList;
String sheetName = "Phyzii";
// private UserInfoBean userInfo = null;
private Calendar calendar = Calendar.getInstance();
private Logger myLogger = Logger.getLogger(getClass().getSimpleName().toString());
@Override
public String schedule(HashMap arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String schedule(String arg0) throws Exception {
System.out.println("Inside schedule abc.... " + arg0);
return this.performOp(arg0);
}
@Override
public String schedulePriority(String arg0) throws Exception {
// TODO Auto-generated method stub
System.out.println("Inside schedule priority ..........." + arg0);
return this.performOp(arg0);
}
public String performOp(String scheduleParamXML) throws ITMException {
System.out.println("Inside schedule performOp ..........." + scheduleParamXML);
String retString = "";
Connection conn = null;
boolean isError = false;
try {
// printLog("STDOUT","ReportCreationScheduler : performOp => Scheduler
// Started");
// printLog("STDOUT","ReportCreationScheduler : performOp : =>" +
// scheduleParamXML);
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("APPVIS");
// conn = getConnection();
retString = performOp(scheduleParamXML, conn);
} catch (Exception e) {
isError = true;
e.printStackTrace();
throw new ITMException(e);
} finally {
try {
if (conn != null) {
if (isError) {
conn.rollback();
} else {
conn.commit();
}
conn.close();
conn = null;
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
return retString;
}
public String performOp(String scheduleParamXML, Connection conn) throws ITMException, Exception {
int i1 =0;
// String[] header1 = {" Expence Unique Id "," Doc No "," Doc Date "," Status "};
String[] header1= null;
// Object excelCell = null ;
// String[] header1 = {" Expence Unique Id "," Doc No "," Doc Date "," Status "};
ArrayList<String> header2 = new ArrayList<String>();
String headColumnName ="";
ResultSetMetaData rsmd= null;
int i = 1;
System.out.println("Inside main method schedule performOp ..........." + scheduleParamXML);
// ExcelDocument workbook = new ExcelDocument();
String retString = "";
String sql = "", objName = "", argumentString = "", jrxmlName = "", sqlGrp1 = "";
String sqlExpr = "", sqlExpr1 = "", sqlExpr2 = "", sqlExpr3 = "", sqlExpr4 = "", sqlExpr5 = "", sqlExpr6 = "",
errfilePath = "",transDb="";
String compSql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
ArrayList<String> objtNamelist = new ArrayList<String>();
String objtNames = "";
String stateCode = "", reportGroup = null;
ibase.utility.UserInfoBean userInfo = null;
E12GenericUtility genericUtility = new E12GenericUtility();
ArrayList<Object> valueContainer = new ArrayList<Object>();
boolean mailSent = false;
String transInfo = "";
// Added By Amit Shrivastava on 04/16/19 for create a variable [Start]
String mailFormat = "";
// Added By Amit Shrivastava on 04/16/19 for create a variable [End]
System.out.println("scheduler xml content:" + scheduleParamXML);
// String
// reportGroup=scheduleParamXML.substring(scheduleParamXML.indexOf("<reportGroup>")+22,
// scheduleParamXML.indexOf("</reportGroup>")-3);
String newMyStr ="";
int rowExcel = 1;
// int excelCell = 1;
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
try {
userInfo = new ibase.utility.UserInfoBean(scheduleParamXML);
Document dom = genericUtility.parseString(scheduleParamXML);
// Dom related stuff goes here.....
NodeList paramList = dom.getElementsByTagName("SCHEDULE");
Node currDetail = null;
int noOfParam = paramList.getLength();
NodeList parentNodeList = null, childNodeList = null;
Node parentNode = null, childNode = null;
String DisparmSites = "";
int childNodeListLength = 0;
String childNodeName = null;
int index = 0;
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName != null && !"#text".equalsIgnoreCase(childNodeName)) {
if (ctr == 0) {
transDb = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("transDb::" + transDb);
}
else if(ctr==1) {
sqlGrp1=checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("sqlGrp1::"+sqlGrp1); } //Added By amit
// SHrivasatava on 04/06/19 for get the maol format value [Start] else
/*
* if(ctr==2) { mailFormat=checkNull(childNode.getFirstChild().getNodeValue());
* System.out.println("@ MailFormat::"+mailFormat); }
*/
// Added By amit SHrivasatava on 04/06/19 for get the maol format value [end]
}
}
if (sqlGrp1.equalsIgnoreCase("PHYZ") || sqlGrp1.equalsIgnoreCase("PHYZ1") || sqlGrp1.equalsIgnoreCase("PHYZ2") || sqlGrp1.equalsIgnoreCase("PHYZ3") )
{
System.out.println("inside if for EXCEL creation===>>> "+sqlGrp1);
sql = "select line_no,sql_expr,sql_input,sql_expr1,sql_expr2,sql_expr3,sql_expr4,"
+ " sql_expr5,sql_expr6 from tax_bal_grp_det where bal_group=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sqlGrp1);
rs = pstmt.executeQuery();
while (rs.next()) {
sqlExpr = checkNull(rs.getString("sql_expr"));
sqlExpr1 = checkNull(rs.getString("sql_expr1"));
sqlExpr2 = checkNull(rs.getString("sql_expr2"));
sqlExpr3 = checkNull(rs.getString("sql_expr3"));
sqlExpr4 = checkNull(rs.getString("sql_expr4"));
sqlExpr5 = checkNull(rs.getString("sql_expr5"));
sqlExpr6 = checkNull(rs.getString("sql_expr6"));
objtNames = checkNull(rs.getString("sql_input"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
/* START >> To track exception 20/11/20 */
if (sqlExpr != null || sqlExpr1 != null || sqlExpr2 != null || sqlExpr3 != null || sqlExpr5 != null
|| sqlExpr6 != null) {
compSql = sqlExpr + " " + sqlExpr1 + " " + sqlExpr2 + " " + sqlExpr3 + " " + sqlExpr4 + " " + sqlExpr5
+ " " + sqlExpr6;
System.out.println("Combine SQL Inside if::::" + compSql);
}
System.out.println("Combine SQL outside if::::" + compSql);
/* END */
System.out.println("compSql" );
//new added
pstmt=conn.prepareStatement(compSql);
rs=pstmt.executeQuery();
rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
for ( i = 1; i <= columnCount; i++ )
{
headColumnName = rsmd.getColumnName(i);
System.out.println("headColumnName "+headColumnName);
header2.add(headColumnName);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//new ended
header1 = new String[header2.size()];
for ( i1 = 0; i1 < header2.size(); i1++)
{
header1[i1] = header2.get(i1);
System.out.println("header1[i1] " +header1[i1]);
}
System.out.println("header2 "+header2);
for (String k : header1) {
System.out.println("header1 "+k);
System.out.println("okno");
}
//new ended
if(compSql!=null && compSql.trim().length() > 0 )
{
System.out.println("inside compSql");
pstmt=conn.prepareStatement(compSql,java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_UPDATABLE);
rs=pstmt.executeQuery();
System.out.println("compSql executed");
//header row added to excel
System.out.println(className+">>>> if compSql creating workbook and adding header started");
createExcelWorkBook();
createExcelSheet(sheetName);
addExcelHeaderRow(header1);
System.out.println(className+">>>> if compSql creating workbook and adding header done");
//ended
}
System.out.println("sqlGrp1 "+sqlGrp1);
//first sql group[START]
if (sqlGrp1.equalsIgnoreCase("PHYZ"))
{
System.out.println("inside if "+sqlGrp1);
while(rs.next())
{
System.out.println("inside while "+sqlGrp1);
jsonObject.put("EXPENSE_UNIQUE_ID", checkNull(rs.getString("EXPENSE_UNIQUE_ID")).trim());
jsonObject.put("DOC_NO", checkNull(rs.getString("DOC_NO")).trim());
jsonObject.put("DOC_DATE", checkNull(rs.getString("DOC_DATE")).trim());
jsonObject.put("STATUS", checkNull(rs.getString("STATUS")).trim());
jsonArray.put(jsonObject);
System.out.println("jsonArray==== "+jsonArray.put(jsonObject));
if (jsonObject != null)
{
System.out.println("inside====jsonObject");
System.out.println(className+">>>> if jsonObject != null addExcelRow rowId ="+rowExcel+" started");
Object[] excelCell = {jsonObject.get("EXPENSE_UNIQUE_ID"),jsonObject.get("DOC_NO"),jsonObject.get("DOC_DATE"),jsonObject.get("STATUS")};
addExcelRow(rowExcel,excelCell);
rowExcel++;
System.out.println(className+">>>> if userAction = DW addExcelRow rowId ="+rowExcel+" ended");
System.out.println("excelCell---->>> "+excelCell);
}
}
}
//first sql group[END]
// ========================================XXXXXXXXXXXXXXXXXXXX==============================================
//SECOND sql group[START]
if (sqlGrp1.equalsIgnoreCase("PHYZ1"))
{
System.out.println("inside if "+sqlGrp1);
while(rs.next())
{
System.out.println("inside while "+sqlGrp1);
jsonObject.put("EXPENSE_UNIQUE_ID", checkNull(rs.getString("EXPENSE_UNIQUE_ID")).trim());
jsonObject.put("DOC_NO", checkNull(rs.getString("DOC_NO")).trim());
jsonObject.put("DOC_DATE", checkNull(rs.getString("DOC_DATE")).trim());
jsonObject.put("DOC_DUE_DATE", checkNull(rs.getString("DOC_DUE_DATE")).trim());
jsonObject.put("PAYMENT_ID", checkNull(rs.getString("PAYMENT_ID")).trim());
jsonObject.put("PAYMENT_DATE", checkNull(rs.getString("PAYMENT_DATE")).trim());
jsonObject.put("PAY_MODE", checkNull(rs.getString("PAY_MODE")).trim());
jsonObject.put("BANK_NAME", checkNull(rs.getString("BANK_NAME")).trim());
jsonObject.put("NET_AMT", checkNull(rs.getString("NET_AMT")).trim());
jsonObject.put("PAY_AMT", checkNull(rs.getString("PAY_AMT")).trim());
jsonObject.put("EMP_CODE", checkNull(rs.getString("EMP_CODE")).trim());
jsonObject.put("PHZYII_EMP_NO", checkNull(rs.getString("PHZYII_EMP_NO")).trim());
jsonObject.put("ADV_AMT", checkNull(rs.getString("ADV_AMT")).trim());
jsonArray.put(jsonObject);
System.out.println("jsonArray==== "+jsonArray.put(jsonObject));
if (jsonObject != null)
{
System.out.println("inside====jsonObject");
System.out.println(className+">>>> if jsonObject != null addExcelRow rowId ="+rowExcel+" started");
Object[] excelCell = {jsonObject.get("EXPENSE_UNIQUE_ID"),jsonObject.get("DOC_NO") ,jsonObject.get("DOC_DATE") ,jsonObject.get("DOC_DUE_DATE") ,jsonObject.get("PAYMENT_ID") ,jsonObject.get("PAYMENT_DATE") ,jsonObject.get("PAY_MODE") ,jsonObject.get("BANK_NAME") ,jsonObject.get("NET_AMT"),jsonObject.get("PAY_AMT") ,jsonObject.get("EMP_CODE") ,jsonObject.get("PHZYII_EMP_NO") ,jsonObject.get("ADV_AMT") };
addExcelRow(rowExcel,excelCell);
rowExcel++;
System.out.println(className+">>>> if userAction = DW addExcelRow rowId ="+rowExcel+" ended");
System.out.println("excelCell---->>> "+excelCell);
}
}
}
//SECOND sql group[END]
// ========================================XXXXXXXXXXXXXXXXXXXX==============================================
//THIRD sql group[START]
if (sqlGrp1.equalsIgnoreCase("PHYZ2"))
{
System.out.println("inside if "+sqlGrp1);
while(rs.next())
{
System.out.println("inside while "+sqlGrp1);
jsonObject.put("PHYZI_TRAN_ID", checkNull(rs.getString("PHYZI_TRAN_ID")).trim());
jsonObject.put("DOC_NO", checkNull(rs.getString("DOC_NO")).trim());
jsonObject.put("DOC_DATE", checkNull(rs.getString("DOC_DATE")).trim());
jsonObject.put("DOC_DUE_DATE", checkNull(rs.getString("DOC_DUE_DATE")).trim());
jsonObject.put("ADV_DOC_NO", checkNull(rs.getString("ADV_DOC_NO")).trim());
jsonObject.put("TOT_AMT", checkNull(rs.getString("TOT_AMT")).trim());
jsonObject.put("ADV_ADJ_AMT", checkNull(rs.getString("ADV_ADJ_AMT")).trim());
jsonObject.put("NET_AMT", checkNull(rs.getString("NET_AMT")).trim());
jsonArray.put(jsonObject);
System.out.println("jsonArray==== "+jsonArray.put(jsonObject));
if (jsonObject != null)
{
System.out.println("inside====jsonObject");
System.out.println(className+">>>> if jsonObject != null addExcelRow rowId ="+rowExcel+" started");
Object[] excelCell = {jsonObject.get("PHYZI_TRAN_ID"),jsonObject.get("DOC_NO") ,jsonObject.get("DOC_DATE") ,jsonObject.get("DOC_DUE_DATE") ,jsonObject.get("ADV_DOC_NO") ,jsonObject.get("TOT_AMT") ,jsonObject.get("ADV_ADJ_AMT") ,jsonObject.get("NET_AMT")};
addExcelRow(rowExcel,excelCell);
rowExcel++;
System.out.println(className+">>>> if userAction = DW addExcelRow rowId ="+rowExcel+" ended");
System.out.println("excelCell---->>> "+excelCell);
}
}
}
//THIRD sql group[END]
// ========================================XXXXXXXXXXXXXXXXXXXX==============================================
//fourth sql group[START]
if (sqlGrp1.equalsIgnoreCase("PHYZ3"))
{
System.out.println("inside if "+sqlGrp1);
while(rs.next())
{
System.out.println("inside while "+sqlGrp1);
jsonObject.put("PHYZI_TRAN_ID", checkNull(rs.getString("PHYZI_TRAN_ID")).trim());
jsonObject.put("DOC_NO", checkNull(rs.getString("DOC_NO")).trim());
jsonObject.put("COMMENTS", checkNull(rs.getString("COMMENTS")).trim());
jsonArray.put(jsonObject);
System.out.println("jsonArray==== "+jsonArray.put(jsonObject));
if (jsonObject != null)
{
System.out.println("inside====jsonObject");
System.out.println(className+">>>> if jsonObject != null addExcelRow rowId ="+rowExcel+" started");
Object[] excelCell = {jsonObject.get("PHYZI_TRAN_ID"),jsonObject.get("DOC_NO"),jsonObject.get("COMMENTS")};
addExcelRow(rowExcel,excelCell);
rowExcel++;
System.out.println(className+">>>> if userAction = DW addExcelRow rowId ="+rowExcel+" ended");
System.out.println("excelCell---->>> "+excelCell);
}
}
}
//fourth sql group[END]
String customResponse = createExcel("Phyzii");
System.out.println("customResponse---->>> "+customResponse);
}
else
{
System.out.println("[[ EXCEPTION IN PHYZII ]] NOT IN SQLGROUP PHYZ // PHYZ1 // PHYZ2 // PHYZ3 AND PUTTED SQLGROUP IS====> " +sqlGrp1);
}
}
catch (SQLException e1) {
System.out.println("Error_Code::::" + e1.getErrorCode());
System.out.println(e1);
String err = String.valueOf(e1.getErrorCode());
printLog("STDERR", "GENERIC REPORTS :: FAIL_SQL ==>" + compSql);
printLog("STDERR", "GENERIC REPORTS :: FAIL_SQL ==>" + e1);
} catch (Exception e) {
throw new Exception(e);
} finally {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
}
return retString;
}
/**
* @param title
* @param msg This method is used for printing the logs in log file
*/
private void printLog(String title, String msg) {
String logFile = "";
String logDir = "";
File logFileDir = null;
FileWriter fileWriter = null;
try {
String logFileName = "";
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
logFileName = "ReportScheduler_" + sdf.format(new Date());
System.out.println("Inside the print log method");
logDir = CommonConstants.JBOSSHOME + File.separator + "applnlog" + File.separator + "ReportScheduler_";
System.out.println("Log direction: " + logDir);
logFileDir = new File(logDir);
if (!logFileDir.exists()) {
logFileDir.mkdirs();
}
logFile = logDir + File.separator + logFileName + ".log";
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
java.util.Date now = new java.util.Date();
String strDate = sdfDate.format(now);
fileWriter = new FileWriter(logFile, true);
fileWriter.write("\r\n");
fileWriter.write("[ERROR] " + msg);
} catch (Exception ex) {
ex.printStackTrace();
printLog("STDERR", ex);
printLog("STDOUT", "Inside Exception [getLog]>>" + ex.toString());
} finally {
try {
if (fileWriter != null) {
fileWriter.flush();
fileWriter.close();
}
} catch (Exception e) {
e.printStackTrace();
printLog("STDERR", e);
}
}
}
private void printLog(String maildId, String tranId, String fileName, boolean mailSent) {
String logFile = "";
String logDir = "";
File logFileDir = null;
FileWriter fileWriter = null;
try {
String logFileName = "";
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
logFileName = "ReportScheduler_" + sdf.format(new Date());
System.out.println("Inside the print log method");
logDir = CommonConstants.JBOSSHOME + File.separator + "applnlog" + File.separator + "ReportScheduler_";
System.out.println("Log direction: " + logDir);
logFileDir = new File(logDir);
if (!logFileDir.exists()) {
logFileDir.mkdirs();
}
logFile = logDir + File.separator + logFileName + ".log";
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
java.util.Date now = new java.util.Date();
String strDate = sdfDate.format(now);
fileWriter = new FileWriter(logFile, true);
fileWriter.write("\r\n");
if (mailSent) {
fileWriter.write("Succesfully Sent mail to [" + tranId + "] " + "With File Name" + " [" + fileName
+ "] on Mail Id " + "[" + maildId + "]");
} else {
fileWriter.write("Mail is not Sent to [" + tranId + "] " + "With File Name" + " [" + fileName
+ "] on Mail Id " + "[" + maildId + "]");
}
} catch (Exception ex) {
ex.printStackTrace();
printLog("STDERR", ex);
printLog("STDOUT", "Inside Exception [getLog]>>" + ex.toString());
} finally {
try {
if (fileWriter != null) {
fileWriter.flush();
fileWriter.close();
}
} catch (Exception e) {
e.printStackTrace();
printLog("STDERR", e);
}
}
}
private void printLog(String title, Exception e) {
try {
StringWriter strError = new StringWriter();
e.printStackTrace(new PrintWriter(strError));
String err = strError.toString();
printLog(title, err);
} catch (Exception ex) {
ex.printStackTrace();
printLog("STDERR", "Inside Exception [getLog]>>" + ex.toString());
}
}
private String checkNull(String input) {
if (input == null) {
input = "";
}
return input.trim();
}
// Send mail method will send the mail to stockiest person
// Comment by amit shrivastava on 04/06/19 [start]
/*
* public boolean sendMail(String reportFilePath, String transInfo)throws
* ITMException
*/
public boolean sendMail(String reportFilePath, String transInfo, String mailFormat) throws ITMException
/// Comment by amit shrivastava on 04/06/19 [end]
{
boolean sentMail = false;
String lineNo = "1";
String emailType = "page";
StringBuffer valueXmlString = null;
String retValue = "";
try {
valueXmlString = new StringBuffer("<ROOT>");
/*
* valueXmlString = new StringBuffer("<ROOT><TRANS_INFO>");
* valueXmlString.append("<OBJ_NAME>").append("<![CDATA[" + "" +
* "]]>").append("</OBJ_NAME>");
* valueXmlString.append("<REF_SER>").append("<![CDATA[" + "" +
* "]]>").append("</REF_SER>");
* valueXmlString.append("<REF_ID>").append("<![CDATA[" + "" +
* "]]>").append("</REF_ID>");
* valueXmlString.append("<LINE_NO>").append("<![CDATA[" + lineNo +
* "]]>").append("</LINE_NO>"); valueXmlString.append("</TRANS_INFO>");
*
* valueXmlString.append("<MAIL>");
* valueXmlString.append("<EMAIL_TYPE>").append("<![CDATA[" + emailType +
* "]]>").append("</EMAIL_TYPE>");
* valueXmlString.append("<ENTITY_CODE>").append("<![CDATA[" + "SUN" +
* "]]>").append("</ENTITY_CODE>");
* valueXmlString.append("<ENTITY_TYPE>").append("<![CDATA[" + "" +
* "]]>").append("</ENTITY_TYPE>");
* valueXmlString.append("<FORMAT_CODE>").append("<![CDATA[" + "E"
* +"]]>").append("</FORMAT_CODE>");
* valueXmlString.append("<TO_ADD>").append("<![CDATA[" +mailAddress
* +"]]>").append("</TO_ADD>");
* valueXmlString.append("<CC_ADD>").append("<![CDATA[" +
* mailAddress+"]]>").append("</CC_ADD>");
* valueXmlString.append("<SUBJECT>").append("<![CDATA[" + "Reports"
* +"]]>").append("</SUBJECT>");
* valueXmlString.append("<BODY_TEXT>").append("<![CDATA[" + "PFA of Report(s)"
* +"]]>").append("</BODY_TEXT>");
* valueXmlString.append("<MESSAGE>").append("<![CDATA[" + "PFA of Report(s)"
* +"]]>").append("</MESSAGE>");
* valueXmlString.append("<XML_DATA_FILE_PATH>").append("<![CDATA[" +
* reportFilePath + "]]>").append("</XML_DATA_FILE_PATH>");
* valueXmlString.append("</MAIL>"); valueXmlString.append("</ROOT>");
*/
// valueXmlString.append("<ROOT>");
valueXmlString.append("<MAILINFO>");
valueXmlString.append("<EMAIL_TYPE>").append("page").append("</EMAIL_TYPE>");
// Added By amit Shrivastava on 04/06/19 for add mail format in send mail
// method.[Start]
if (mailFormat != null && mailFormat.trim().length() > 0) {
valueXmlString.append("<FORMAT_CODE>").append("<![CDATA[" + mailFormat + "]]>")
.append("</FORMAT_CODE>");
} else {
valueXmlString.append("<FORMAT_CODE>").append("<![CDATA[GEN_REPORT]]>").append("</FORMAT_CODE>");
}
/*
* valueXmlString.append("<FORMAT_CODE>").append("<![CDATA[GEN_REPORT]]>").
* append("</FORMAT_CODE>");
*/
// Added By amit Shrivastava on 04/06/19 for add mail format in send mail
// method.[End]
// commInfo.append("<TO_ADD>").append("<![CDATA[" + emailTo +
// "]]>").append("</TO_ADD>");
valueXmlString.append("<XML_DATA_FILE_PATH>").append("<![CDATA[" + reportFilePath + "]]>")
.append("</XML_DATA_FILE_PATH>");
valueXmlString.append("</MAILINFO>");
valueXmlString.append("<XML_DATA>").append(transInfo).append("</XML_DATA>");
valueXmlString.append("</ROOT>");
String mailDomStr = valueXmlString.toString();
System.out.println("@@## [Generic Report] :sendMail mailDomStr :-->" + mailDomStr);
EMail email = new EMail();
MailInfo info = new MailInfo();
retValue = email.sendMail(mailDomStr, "ITM");
if ("S".equalsIgnoreCase(retValue)) {
// printLog("STDOUT","ReportCreationScheduler : sendMail => Mail sent
// successfully" );
sentMail = true;
}
System.out.println("[Pdf] mail delivered successfully");
} catch (ITMException itme) {
System.out.println("@@## ITMException [[Generic Report]] :sendMail :sendMail :sendMail() :==>\n");
throw itme;
} catch (Exception e) {
System.out.println("Exception :[[Generic Report]] :sendMail() :==>\n" + e.getMessage());
throw new ITMException(e);
}
return sentMail;
}
/**
* boolean method which will check whether string contains mail address or not
*/
public boolean checkEmailAddress(String emailValue) {
Pattern pattern = Pattern.compile("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}");
Matcher mat = pattern.matcher(emailValue);
return mat.matches();
}
public static boolean checkDateFormat(String strDate) {
Pattern pattern = Pattern.compile("[0-9]{1,2}-[a-zA-Z]{3}-[0-9]{4}");
Matcher mat = pattern.matcher(strDate);
return mat.matches();
}
public boolean checkDatePattern(String strDate) {
SimpleDateFormat sdfrmt = new SimpleDateFormat("dd-MMM-yyyy");
sdfrmt.setLenient(false);
/*
* Create Date object parse the string into date
*/
Pattern pattern = Pattern.compile("\\d{2}-\\d{3}-\\d{4}");
Matcher mat = pattern.matcher(strDate);
System.out.println("mat==>" + mat);
try {
Date javaDate = sdfrmt.parse(strDate);
System.out.println(strDate + " is valid date format");
SimpleDateFormat sdfrmt1 = new SimpleDateFormat("dd/MM/yy");
String strDate1 = sdfrmt1.format(javaDate);
System.out.println("Converted String: " + strDate1);
} catch (ParseException e) {
System.out.println(strDate + " is Invalid Date format");
e.printStackTrace();
}
return true;
}
private String getDomString(String emailIdPer) throws ITMException {
String retString = "";
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
try {
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB();
// changes done by sangita n
SimpleDateFormat sdfOutput = new SimpleDateFormat("dd-MM-yyyy");
// SimpleDateFormat sdfOutput = new SimpleDateFormat(getApplDateFormat());
java.sql.Date currentDate = null;
String sqlCurrDate = "select sysdate from dual ";
PreparedStatement pstmt1 = conn.prepareStatement(sqlCurrDate);
ResultSet rSet = pstmt1.executeQuery();
if (rSet.next()) {
currentDate = rSet.getDate(1);
}
makeNullPstmtAndRs(pstmt1, rSet);
String retDateStr = sdfOutput.format(currentDate);
System.out.println(" add current date retDateStr>>>>>" + retDateStr);
// changes done by sangita n
valueXmlString.append("<ROOT>");
valueXmlString.append("<Detail1>");
valueXmlString.append("<email_id_cust>").append("<![CDATA[" + emailIdPer + "]]>")
.append("</email_id_cust>");
valueXmlString.append("<curr_date><![CDATA[").append(checkNull(retDateStr)).append("]]></curr_date>");
valueXmlString.append("</Detail1>");
valueXmlString.append("</ROOT>");
retString = valueXmlString.toString();
} catch (Exception e) {
e.printStackTrace();
printLog("ERROR", e);
}
return retString;
}
// chages done by sangita
public void makeNullPstmtAndRs(PreparedStatement pstmt, ResultSet rs) {
try {
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (rs != null) {
rs.close();
rs = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
boolean isWorkbookNotEmpty(String fileName) {
boolean isNotEmpty = false;
try {
FileInputStream fileInputStream = new FileInputStream(new File(fileName));
Workbook wb = WorkbookFactory.create(fileInputStream);
for (int i = 0; i < wb.getNumberOfSheets(); i++) {
isNotEmpty = isSheetNotEmpty(wb.getSheetAt(i));
System.out.println("Sheet " + i + " has data: " + isNotEmpty);
if (isNotEmpty) {
return isNotEmpty;
// break;
}
}
} catch (Exception e) {
System.out.println("Exception occur in isWorkbookEmpty(). exception is " + e.getMessage());
e.printStackTrace();
return false;
}
return isNotEmpty;
}
boolean isSheetNotEmpty(Sheet sheet) {
Iterator rows = sheet.rowIterator();
while (rows.hasNext()) {
Row row = (Row) rows.next();
Iterator cells = row.cellIterator();
while (cells.hasNext()) {
Cell cell = (Cell) cells.next();
if (!cell.getStringCellValue().isEmpty()) {
return true;
}
}
}
return false;
}
private String createExcel(String tableName)
{
System.out.println("inside creating excel");
String response = "";
try
{
// SimpleDateFormat dateFormat = new SimpleDateFormat(genericUtility.getDBDateFormat());
fileDirectory = CommonConstants.JBOSSHOME+File.separator+"Phyzii"+File.separator+"PhyziiExcel";
File dir = new File(fileDirectory);
if(!dir.exists())
{
dir.mkdirs();
}
calendar.setTime(new Timestamp(System.currentTimeMillis()));
// fileName = tableName+"#"+dateFormat.format(calendar.getTime())+"#"+checkDigit(calendar.get(Calendar.HOUR))
// +"-"+checkDigit(calendar.get(Calendar.MINUTE))+"-"+checkDigit(calendar.get(Calendar.SECOND))+".xlsx";//xls //"Pan"
fileName = tableName+"#"+"#"+checkDigit(calendar.get(Calendar.HOUR))
+"-"+checkDigit(calendar.get(Calendar.MINUTE))+"-"+checkDigit(calendar.get(Calendar.SECOND))+".xlsx";
filePath = fileDirectory +File.separator+ fileName;
System.out.println(className+" filePath>>>> "+filePath);
fileOutputStream = new FileOutputStream(filePath);
autoSizeColumns(excelWorkbook);
excelWorkbook.write(fileOutputStream);
response = "Downloaded Successfully!!!!";
}
catch (Exception e)
{
myLogger.log(Level.SEVERE, " createExcel Mtd An Exception Was Thrown ", e);
System.out.println(className+" Exception "+e.getMessage());
response = className+" Exception "+e.getMessage();
e.printStackTrace();
}
return response;
}
private String checkDigit(int input)
{
String result = Integer.toString(input);
if (result.length() == 1)
{
result = "0"+result;
}
return result.trim();
}
public void autoSizeColumns(XSSFWorkbook workbook)
{
int numberOfSheets = workbook.getNumberOfSheets();
for (int i = 0; i < numberOfSheets; i++)
{
XSSFSheet sheet = workbook.getSheetAt(i);
if (sheet.getPhysicalNumberOfRows() > 0)
{
XSSFRow row = sheet.getRow(sheet.getFirstRowNum());
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext())
{
Cell cell = cellIterator.next();
int columnIndex = cell.getColumnIndex();
sheet.autoSizeColumn(columnIndex);
}
}
}
}
private void addExcelRow(int row,Object[] cellVal)
{
System.out.println("cellVal "+cellVal);
try
{
System.out.println("starting addExcelRow ");
XSSFRow rowHeader = excelSheet.createRow((short)row);
System.out.println("starting addExcelRow Data ");
for(int i = 0; i < cellVal.length; i++)
{
if(cellVal[i] instanceof String)
{
System.out.println("inside if");
rowHeader.createCell(i).setCellValue((String)cellVal[i]);
}
else if(cellVal[i] instanceof Integer)
{
System.out.println("inside else if");
rowHeader.createCell(i).setCellValue((Integer)cellVal[i]);
}
}
System.out.println("creating for addExcelRow CellStyle ");
XSSFCellStyle style = excelWorkbook.createCellStyle();
XSSFFont font = excelWorkbook.createFont();
font.setFontName("Arial");//XSSFFont.DEFAULT_FONT_NAME
font.setFontHeightInPoints((short)10);
font.setBold(false);
style.setFont(font);
System.out.println("started for addExcelRow style ");
for(int j = 0; j < cellVal.length; j++)
{
rowHeader.getCell(j).setCellStyle(style);
}
System.out.println("ended addExcelRow ");
}
catch (Exception e)
{
myLogger.log(Level.SEVERE, " addExcelRowException Mtd An Exception Was Thrown ", e);
System.out.println(className+" addExcelRowException :- "+e);
e.printStackTrace();
}
}
private void createExcelWorkBook()
{
excelWorkbook = new XSSFWorkbook();
}
private void createExcelSheet(String sheetName)
{
int index = excelWorkbook.getSheetIndex(sheetName);
if (index == -1)
{
excelSheet = excelWorkbook.createSheet(sheetName);
}
else
{
excelSheet = excelWorkbook.getSheet(sheetName);
}
}
private void addExcelHeaderRow(String[] header)
{
try
{
System.out.println("starting addExcelHeaderRow ");
XSSFRow rowHeader = excelSheet.createRow((short)0);
System.out.println("starting addExcelHeaderRow Data ");
for(int i = 0; i < header.length; i++)
{
rowHeader.createCell(i).setCellValue(header[i]);
}
System.out.println("creating for addExcelHeaderRow CellStyle ");
XSSFCellStyle style = excelWorkbook.createCellStyle();
XSSFFont font = excelWorkbook.createFont();
font.setFontName("Arial");//XSSFFont.DEFAULT_FONT_NAME
font.setFontHeightInPoints((short)10);
font.setBold(true);
style.setFont(font);
System.out.println("started for addExcelHeaderRow style ");
for(int j = 0; j<header.length; j++)
{
rowHeader.getCell(j).setCellStyle(style);
//excelSheet.setColumnWidth(j, 25 * 256);
}
System.out.println("ended addExcelHeaderRow ");
}
catch (Exception e)
{
myLogger.log(Level.SEVERE, " addExcelHeaderRowException Mtd An Exception Was Thrown ", e);
System.out.println(className+" addExcelHeaderRowException :- "+e);
e.printStackTrace();
}
}
}
package ibase.webitm.ejb.phizzy;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.reports.utility.JasperReportGenerator;
import ibase.webitm.reports.utility.ResourceConstants;
import ibase.webitm.reports.utility.XSDParser;
import java.io.File;
import java.io.FileWriter;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.TreeMap;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@SuppressWarnings({ "rawtypes" })
public class VoucherPrintingScheduler implements Schedule {
E12GenericUtility genericUtility = new E12GenericUtility();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");
String logPath = CommonConstants.JBOSSHOME + File.separator + this.getClass().getSimpleName();
@Override
public String schedule(String scheduleParamXML) throws Exception {
UserInfoBean userInfo = new UserInfoBean(scheduleParamXML);
String fromDateStr="",toDateStr="",fromTranId="",toTranId="",userFrom="",userTo="",aprvFrom="",aprvTo="";
String loginCode = checkNull(userInfo.getLoginCode());
String lsiteCode = checkNull(userInfo.getSiteCode());
String errString = "", printerName = "",siteCode="";
//this.userInfoXml = scheduleParamXML;
//userInfo = new UserInfoBean(this.userInfoXml);
String transDB = userInfo.getTransDB();
System.out.println("get TransDB connection in updateStatus : " + transDB);
Connection conn=null;
ConnDriver driver = new ConnDriver();
//conn = driver.getConnectDB("DriverITM");
if ((transDB != null) && (transDB.trim().length() > 0))
{
conn = driver.getConnectDB(transDB);
}
NodeList parentNodeList = null,childNodeList = null;
Node parentNode = null,childNode = null;
int childNodeListLength = 0;
String childNodeName = null;
Document dom=genericUtility.parseString(scheduleParamXML);
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength>>> "+ childNodeListLength);
for(int ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
{
if(ctr==0)
{
siteCode = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("siteCode>>>>>"+ siteCode);
System.out.println("childNodeListLength>>> "+ childNodeListLength);
}
else if(ctr==1)
{
fromDateStr = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("fromDateStr>>>>>"+ fromDateStr);
}
else if(ctr==2)
{
toDateStr = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("toDateStr>>>>>"+ toDateStr);
}
else if(ctr==3)
{
fromTranId = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("fromTranId>>>>>"+ fromTranId);
}
else if(ctr==4)
{
toTranId = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("fromTranId>>>>>"+ toTranId);
}
else if(ctr==5)
{
userFrom = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("userFrom>>>>>"+ userFrom);
}
else if(ctr==6)
{
userTo = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("userTo>>>>>"+ userTo);
}
else if(ctr==7)
{
aprvFrom = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("aprvFrom>>>>>"+ aprvFrom);
}
else if(ctr==8)
{
aprvTo = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("aprvTo>>>>>"+ aprvTo);
}
}
System.out.println("ctrFinal>>>>"+ ctr);
}
/*
* FinCommon finUtil = new FinCommon(); String hol_tblno =
* finUtil.getFinparams("999999", "VOU_PRNT_HOL_TBLNO", conn);
* if("NULLFOUND".equalsIgnoreCase(hol_tblno)) { errString =
* "Please define 'HBL_TBLNO' value in finparm for period '999999' and var_name 'VOU_PRNT_HOL_TBLNO' for considering Holiday table to look for holiday list"
* ; writeLog(this.getClass().getSimpleName(), errString); return ""; }
* printerName = finUtil.getFinparams("999999", "VOU_PRNT_PRNTR_NAME", conn);
* if("NULLFOUND".equalsIgnoreCase(printerName)) { errString =
* "Please define value in finparm for period '999999' and var_name 'VOU_PRNT_PRNTR_NAME' for considering Printer for printing voucher"
* ; writeLog(this.getClass().getSimpleName(), errString); return ""; }
*
* boolean isHoliday = getHolidayForToday(hol_tblno, conn); if(isHoliday) {
* errString = "Scheduler not running for date (dd-MMM-yy): " +
* sdf.format(Calendar.getInstance().getTime());
* writeLog(this.getClass().getSimpleName(), errString); return ""; } else
*/ {
SimpleDateFormat sdfReport = new SimpleDateFormat(genericUtility.getApplDateFormat());
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
Date yesterday = new Date(cal.getTimeInMillis());
String toDate = sdfReport.format(yesterday);
// String fromDate = sdfReport.format(getPreviousWorkingDate(yesterday, hol_tblno, conn));
System.out.println("fromDate ::: " + fromDateStr + " ::: toDate ::: " + toDate);
// fromDate = "01/01/13";
// toDate = "01/05/13";
System.out.println("fromDate ::: " + fromDateStr + " ::: toDate ::: " + toDateStr);
// String objName = "d_field_staff_exp_claim_vr";
String objName = "d_misc_voucher_summary_gst";
System.out.println("objName ::: " + objName);
System.out.println("userName ::: " + loginCode);
// printerName = "jbnbasehp4thflr";
// printerName = checkNull(getPrinterName(conn));
if(printerName.length() > 0) {
//printVoucher(objName, loginCode, siteCode, fromDate, toDate, printerName, conn);
// printVoucher(objName, loginCode, siteCode, fromDateStr, toDateStr, printerName, conn);
}
printVoucher(objName, loginCode, siteCode, fromDateStr, toDateStr,fromTranId,toTranId,userFrom,userTo,aprvFrom,aprvTo, printerName, conn,userInfo);
//String fromDateStr="",toDateStr="",fromTranId="",toTranId="",userFrom="",userTo="",aprvFrom="",aprvTo="";
}
return "";
}
private String checkNull(String value) {
return value = value == null ? "" : value.trim();
}
private Date getPreviousWorkingDate(Date yesterday, String hol_tblno, Connection conn) {
String sql = "";
PreparedStatement ps = null;
ResultSet rs = null;
Date retValue = null;
try {
sql = "select fn_get_previous_working_date(?, ?) as previous from dual";
ps = conn.prepareStatement(sql);
ps.setString(1, hol_tblno);
ps.setDate(2, yesterday);
rs = ps.executeQuery();
if(rs.next()) {
retValue = rs.getDate("previous");
}
} catch (SQLException e) {
retValue = yesterday;
} finally {
try {
rs.close();
rs = null;
ps.close();
ps = null;
} catch (Exception e) {
e.printStackTrace();
}
}
return retValue;
}
private boolean getHolidayForToday(String hol_tblno, Connection conn) {
String sql = "";
PreparedStatement ps = null;
ResultSet rs = null;
Date today = null;
boolean retValue = false;
try {
sql = "select hol_tblno from holiday where hol_tblno = ? and hol_date = ?";
ps = conn.prepareStatement(sql);
today = new Date(Calendar.getInstance().getTimeInMillis());
ps.setString(1, hol_tblno);
ps.setDate(2, today);
rs = ps.executeQuery();
if(rs.next()) {
retValue = true;
}
} catch (SQLException e) {
retValue = false;
} finally {
try {
rs.close();
rs = null;
ps.close();
ps = null;
} catch (Exception e) {
e.printStackTrace();
}
}
return retValue;
}
private void writeLog(String fileName, String errString) {
File logFilePath = new File(logPath);
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy kk:mm:ss,SSS");
System.out.println("logFilePath:::" + logFilePath);
if(!logFilePath.exists()){
logFilePath.mkdir();
}
File logFile = new File(logFilePath + File.separator + fileName + ".log");
FileWriter localFileWriter = null;
try {
localFileWriter = new FileWriter(logFile, true);
localFileWriter.write("[LOG at "+sdf.format(Calendar.getInstance().getTime()) + "]" + errString);
localFileWriter.write("\n");
localFileWriter.flush();
localFileWriter.close();
} catch (Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings("unchecked")
public void printVoucher(String objName, String loginCode , String siteCode, String fromDate, String toDate,
String fromTranId,String toTranId,String userFrom,String userTo,String aprvFrom,String aprvTo,
String printerName, Connection conn, UserInfoBean userInfo) {
try {
SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MMM-yy");
String outputFilename = loginCode+"_"+sdf1.format(System.currentTimeMillis());
TreeMap argMap = null;
String argumentString ="<Arguments>" +
"<Argument id=\"as_site\" name=\"as_site\">" +
"<argType>java.lang.String</argType>" +
"<value>"+ siteCode +"</value>" +
"</Argument>" +
"<Argument id=\"as_trandate_fr\" name=\"as_trandate_fr\">" +
"<argType>java.util.Date</argType>" +
"<value>"+ fromDate +"</value>" +
"</Argument>" +
"<Argument id=\"as_trandate_to\" name=\"as_trandate_to\">" +
"<argType>java.util.Date</argType>" +
"<value>"+ toDate +"</value>" +
"</Argument>" +
"<Argument id=\"frmtranid\" name=\"frmtranid\">" +
"<argType>java.lang.String</argType>" +
"<value>"+fromTranId+"</value>" +
"</Argument>" +
"<Argument id=\"tomtranid\" name=\"tomtranid\">" +
"<argType>java.lang.String</argType>" +
"<value>"+toTranId+"</value>" +
"</Argument>" +
"<Argument id=\"as_user_fr\" name=\"as_user_fr\">" +
"<argType>java.lang.String</argType>" +
"<value>"+userFrom+"</value>" +
"</Argument>" +
"<Argument id=\"as_user_to\" name=\"as_user_to\">" +
"<argType>java.lang.String</argType>" +
"<value>"+userTo+"</value>" +
"</Argument>" +
"<Argument id=\"as_emp_aprv_fr\" name=\"as_emp_aprv_fr\">" +
"<argType>java.lang.String</argType>" +
"<value>"+aprvFrom+"</value>" +
"</Argument>" +
"<Argument id=\"as_emp_aprv_to\" name=\"as_emp_aprv_to\">" +
"<argType>java.lang.String</argType>" +
"<value>"+aprvTo+"</value>" +
"</Argument>" +
"<Argument id=\"report_save_type\" name=\"report_save_type\">" +
"<argType>java.lang.String</argType>" +
"<value>NATIVE</value>" +
"</Argument>" +
"<Argument id=\"data_source\" name=\"data_source\">" +
"<argType>java.lang.String</argType>" +
"<value>SQL</value>" +
"</Argument>" +
"</Arguments>";
System.out.println("argumentString:::"+argumentString);
XSDParser xsdParser = new XSDParser(objName);
System.out.println(":::::::::::::xsd parsed:::::::::::::");
JasperReportGenerator jasperReport = new JasperReportGenerator(userInfo);
System.out.println("after generating report");
argMap = jasperReport.createArgMap(argumentString);
argMap.put("report_save_type", "PDF");
System.out.println("argMap:::" + argMap + "\nxsdParser:::" + xsdParser + "\nuserName:::" + loginCode + "\noutputFilename:::" + outputFilename);
System.out.println("@V@ Printer name :- ["+printerName+"]");
System.out.println("@V@ objName name :- ["+objName+"]");
System.out.println("@V@ argumentString name :- ["+argumentString+"]");
System.out.println("@V@ loginCode name :- ["+loginCode+"]");
jasperReport.createReport(objName, argMap, xsdParser, loginCode, outputFilename);
//TODO Print Report
System.out.println("Sending Report to Print:: @@@Tajuddin " + printerName);
String reportOutputFileName = jasperReport.getOutputFileName();
System.out.println("reportOutputFileName:::"+reportOutputFileName);
reportOutputFileName = reportOutputFileName == null ? "" : reportOutputFileName.trim();
if(reportOutputFileName.length() > 0){
reportOutputFileName = ResourceConstants.REPORTDESTINATION + File.separator + loginCode + File.separator + outputFilename + ".pdf";
// File f = new File(reportOutputFileName);
// String fs = f.getAbsolutePath();
// int index = fs.indexOf(File.separator + "bin");
// System.out.println("fs:::"+fs);
// String path = fs.substring(0, index);
//
// System.out.println("file path:::" + path);
// System.out.println("Output file name" + reportOutputFileName);
//TODO save report to Voucher Folder
File orignalFile= new File(reportOutputFileName);
File reportSavePath = new File(logPath +File.separator + "Voucher");
if(!reportSavePath.exists()){
reportSavePath.mkdir();
}
File detFile= new File(reportSavePath.getAbsolutePath()+File.separator+outputFilename+".pdf");
orignalFile.renameTo(detFile);
// argMap = null;
//
// argMap = jasperReport.createArgMap(argumentString);
// argMap.put("report_save_type", "NATIVE");
/*
* try { jasperReport.printReport(objName, argumentString, loginCode,
* printerName, 1, conn); } catch (Exception e) { String errString =
* "Printing voucher fail for loginCode["+loginCode+"] siteCode["+siteCode+"],"
* + "fromDate["+fromDate+"], toDate["
* +toDate+"], empCodeFrom [00], empCodeTo[ZZ]. Please use same retreival from Metis to check."
* ; writeLog(this.getClass().getSimpleName(), errString); }
*/
} else {
String errString = "Printing voucher fail for loginCode["+loginCode+"] siteCode["+siteCode+"]," +
"fromDate["+fromDate+"], toDate["+toDate+"], empCodeFrom [00], empCodeTo[ZZ]";
writeLog(this.getClass().getSimpleName(), errString);
}
} catch(Exception e) {
String errString = "Printing voucher fail for loginCode["+loginCode+"] siteCode["+siteCode+"]," +
"fromDate["+fromDate+"], toDate["+toDate+"], empCodeFrom [00], empCodeTo[ZZ]. Please use same retreival from Metis to check.";
writeLog(this.getClass().getSimpleName(), errString);
}
finally {
System.out.println("In finally block of printVoucher");
}
}
@Override
public String schedulePriority(String arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String schedule(HashMap arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
}
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