Commit c20e2c73 authored by sanashaikh's avatar sanashaikh

Sana S: Added on 01/10/2019

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@208692 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 97a2af72
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.utility.E12GenericUtility;
import javax.ejb.Stateless;
@Stateless
//Created by Sana S on 24/09/2019 [start]
public class PayrollProcess extends ProcessEJB implements PayrollProcessLocal,PayrollProcessRemote
{
Connection con = null;
String sql = "";
E12GenericUtility e12GenericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDbAcess = new ITMDBAccessEJB();
UtilMethods utilMethod = new UtilMethods();
@Override
public String process() throws RemoteException, ITMException {
return null;
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
Document detailDom = null;
Document headerDom = null;
String retStr = "";
Connection con=null;
try
{
con=getConnection();
System.out.println("xmlString[process]::::::::::;;;"+xmlString);
System.out.println("xmlString2[process]::::::::::;;;"+xmlString2);
System.out.println("windowName[process]::::::::::;;;"+windowName);
System.out.println("xtraParams[process]:::::::::;;;"+xtraParams);
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = e12GenericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = e12GenericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
}
retStr = process(headerDom, detailDom, windowName, xtraParams,con);
System.out.print("retStr:"+retStr);
}
catch (Exception e)
{
e.printStackTrace();
}
return retStr;
}
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams,Connection con) throws RemoteException,ITMException
{
String fromEmp="", toEmp="", fromPrd="", toPrd="", fromSite="", toSite="";
String procFrom="", procTo="", remarks="", userId="";
PreparedStatement pstmt = null;
ResultSet rs = null;
ArrayList<String> EmpCodeList = new ArrayList<>();
int rowCnt=0;
String errorStr = "";
int Cnt = 0;
String ls_base="";
try
{
con=getConnection();
System.out.println("Inside try of PayrollRemarksProcIC process method.......");
userId = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
fromEmp = checkNull(e12GenericUtility.getColumnValue("emp_code__fr", headerDom));
toEmp = checkNull(e12GenericUtility.getColumnValue("emp_code__to", headerDom));
fromPrd = checkNull(e12GenericUtility.getColumnValue("prd_code__fr", headerDom));
toPrd = checkNull(e12GenericUtility.getColumnValue("prd_code__to", headerDom));
fromSite = checkNull(e12GenericUtility.getColumnValue("site_code__fr", headerDom));
toSite = checkNull(e12GenericUtility.getColumnValue("site_code__to", headerDom));
procFrom = checkNull(e12GenericUtility.getColumnValue("proc_group__from", headerDom));
procTo = checkNull(e12GenericUtility.getColumnValue("proc_group__to", headerDom));
remarks = checkNull(e12GenericUtility.getColumnValue("remarks", headerDom));
if(fromEmp.trim() == null || fromEmp.trim().length() == 0)
{
fromEmp = "0";
}
if(toEmp.trim() == null || toEmp.trim().length() == 0)
{
toEmp = "ZZ";
}
if(fromSite.trim() == null || fromSite.trim().length() == 0)
{
fromSite = "0";
}
if(toSite.trim() == null || toSite.trim().length() == 0)
{
toSite = "ZZZZZ";
}
if(procFrom.trim() == null || procFrom.trim().length() == 0)
{
procFrom = "0";
}
if(procTo.trim() == null || procTo.trim().length() == 0)
{
procTo = "ZZZZZ";
}
sql = " select a.emp_code from payroll a, employee b where "
+ "a.emp_code = b.emp_code and "
+ "a.prd_code between ? and ? and "
+ "a.emp_code between ? and ? and "
+ "a.site_code__pay between ? and ? and "
+ "b.proc_group between ? and ? and "
+ "a.voucher_no is null order by a.emp_code";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, fromPrd);
pstmt.setString(2, toPrd);
pstmt.setString(3, fromEmp);
pstmt.setString(4, toEmp);
pstmt.setString(5, fromSite);
pstmt.setString(6, toSite);
pstmt.setString(7, procFrom);
pstmt.setString(8, procTo);
rs = pstmt.executeQuery();
while(rs.next())
{
rowCnt++;
EmpCodeList.add(checkNull(rs.getString("emp_code")));
System.out.println("EmpCodeList == > "+EmpCodeList);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.print("EmpCodeList:"+EmpCodeList.size());
for(int i = 0; i < EmpCodeList.size(); i++)
{
sql = "explain plan for update payroll set remarks = ? where "
+ "prd_code between ? and ? and "
+ "emp_code = ? ";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, remarks);
pstmt.setString(2, fromPrd);
pstmt.setString(3, toPrd);
pstmt.setString(4, EmpCodeList.get(i));
rs = pstmt.executeQuery();
while(rs.next())
{
Cnt++;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
System.out.print("Cnt:"+Cnt);
if(ls_base.trim().length() > 0)
{
con.rollback();
errorStr = itmDbAcess.getErrorString("", "", userId, "", con);
return errorStr;
}
else
{
con.commit();
errorStr = itmDbAcess.getErrorString("", "VPSUCC1", userId, "", con);
return errorStr;
}
}
catch (Exception e)
{
System.out.println("Exception in PayrollRemarksProcIC.process() "+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
errorStr = e.getMessage();
e.printStackTrace();
throw new ITMException(e);
}
}
//return errorStr;
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
else
{
input =input.trim();
}
return input;
}
}
//Created by Sana S on 24/09/2019 [end]
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