Commit 4a0d1575 authored by arawankar's avatar arawankar

-Changes made in below component.

EmpLeaveConf.java
-Added updated method of leaveRule2.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@189491 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f82f5811
...@@ -772,6 +772,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -772,6 +772,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
try try
{ {
System.out.println("------Inside leaveChkGeneral---");
lveYrFr = utilMethod.year(mlveDt); lveYrFr = utilMethod.year(mlveDt);
lveYrTo = utilMethod.year(mlveDt); lveYrTo = utilMethod.year(mlveDt);
do do
...@@ -1380,16 +1381,25 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -1380,16 +1381,25 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
isError = true; isError = true;
break; break;
} }
if(payable.equals("Y")) //Modified by Anjali R. on [20/08/2018][Check equal ignore case while comparing two strings][Start]
//if(payable.equals("Y"))
System.out.println("payable--["+payable+"]");
if("Y".equalsIgnoreCase(payable))
//Modified by Anjali R. on [20/08/2018][Check equal ignore case while comparing two strings][End]
{ {
errCode = ""; errCode = "";
System.out.println("nvoNo--["+nvoNo+"]");
if(nvoNo == 1) if(nvoNo == 1)
{ {
errCode = leaveRules1(memp, mLeave, mPrd, mlveDt,mlvedtTo, mNoDays , tranId,connectionObject); errCode = leaveRules1(memp, mLeave, mPrd, mlveDt,mlvedtTo, mNoDays , tranId,connectionObject);
} }
else if(nvoNo == 2) else if(nvoNo == 2)
{ {
errCode = leaveRules2(memp, mLeave, mlveDt, mlvedtTo,connectionObject ); //Modified by Anjali R. on[20/08/2018][Added updated method of leaves rule 2][Start]
//errCode = leaveRules2(memp, mLeave, mlveDt, mlvedtTo,connectionObject );
errCode = leaveRules2(memp, mLeave, mlveDt, mlvedtTo,tranId,connectionObject );
System.out.println("errCode from leaveRules2---["+errCode+"]");
//Modified by Anjali R. on[20/08/2018][Added updated method of leaves rule 2][End]
} }
if(errCode != null && errCode.trim().length() > 0) if(errCode != null && errCode.trim().length() > 0)
{ {
...@@ -1423,7 +1433,6 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -1423,7 +1433,6 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
return errCode; return errCode;
} }
private String leaveRules1(String empCode,String lveCode,String prdCode,java.sql.Timestamp leaveFromDate ,java.sql.Timestamp leaveToDate,double noDays,String tranId, Connection connectionObject) throws RemoteException,ITMException private String leaveRules1(String empCode,String lveCode,String prdCode,java.sql.Timestamp leaveFromDate ,java.sql.Timestamp leaveToDate,double noDays,String tranId, Connection connectionObject) throws RemoteException,ITMException
{ {
...@@ -1648,8 +1657,443 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -1648,8 +1657,443 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
return errCode; return errCode;
} }
//Added by Anjali R. on [20/AUG/2018][Added updated leaveRules2 method][Start]
private String leaveRules2 (String empCode, String lveCode, java.sql.Timestamp lvedt, java.sql.Timestamp lvedtTo,String tranId ,Connection conn) throws RemoteException,ITMException, SQLException
{
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql1 = "";
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
String sql2 = "";
PreparedStatement pstmt2 = null;
ResultSet rs2 = null;
HashMap hmap = new HashMap();
String errCode = "";
String lveTblno = "";
String canCombine = "";
String holTblNo = "";
String tempHolTblNo = "";
String holType = "";
String lve = "";
String prevLveEnd = "";
String payable = "";
String canCombine1 = "";
String leaveStart = "";
String leaveEnd = "";
String nextLveStart = "";
java.sql.Timestamp temp1 = null;
Timestamp to = null;
Timestamp fr = null;
boolean isError = false;
AdmCommon admCommon = null;
try
{
admCommon = new AdmCommon();
hmap = getLvetbl(empCode, lveTblno, conn);
System.out.println("hmap--["+hmap.size()+"]");
errCode = (String)hmap.get("ERRORCODE");
System.out.println("errCode---["+errCode+"]");
if (errCode != null && errCode.trim().length() > 0)
{
this.errList.add(errCode);
this.fldList.add("");
isError = true;
return errCode;
}
lveTblno = (String)hmap.get("LEAVETABLE");
System.out.println("lveTblno---["+lveTblno+"]");
//Added by Anjali R. To get leaves start and leaves end[Start]
sql = "select leave_ends,leave_starts from empleave where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
leaveStart = checkNull(rs.getString("leave_starts"));
leaveEnd = checkNull(rs.getString("leave_ends"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added by Anjali R. To get leaves start and leaves end[End]
sql = "select (case when can_combine is null then 'N' else can_combine end ) as can_combine"+
" from lvetable where lve_code = ? and lve_tblno = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lveCode);
pstmt.setString(2, lveTblno);
rs = pstmt.executeQuery();
while(rs.next())
{
canCombine = checkNull(rs.getString("can_combine"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
temp1 = lvedt;
temp1 = utilMethod.RelativeDate(temp1, -1);
System.out.println("temp1--["+temp1+"]");
sql = "select fn_get_holtblno(?,?) from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, temp1);
rs = pstmt.executeQuery();
while(rs.next())
{
holTblNo = checkNull(rs.getString(1));
}
System.out.println("holTblNo---["+holTblNo+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
tempHolTblNo = utilMethod.mid(holTblNo, 1,5);
System.out.println("tempHolTblNo---["+tempHolTblNo+"]");
if("DS000".equalsIgnoreCase(tempHolTblNo))
{
errCode = tempHolTblNo ;
return errCode;
}
holType = admCommon.scanHolWoffFordate(empCode, holTblNo, temp1,conn);
System.out.println("holType---["+holType+"]");
if(holType != null && holType.trim().length() > 0)
{
System.out.println("utilMethod.pos(holType, \"HW\")--["+utilMethod.pos(holType, "HW")+"]");
if(utilMethod.pos(holType, "HW") == 0 )
{
errCode = holType;
return errCode;
}
}
else
{
errCode = "";
return errCode;
}
System.out.println("errCode--1800["+errCode+"]");
if(errCode != null && errCode.trim().length() >0)
{
return errCode;
}
sql = "select lve_date_to,lve_code,leave_ends from empleave where emp_code = ? "+
" and lve_date_to >= ? and lve_date_to <= ? " +
" and status <> 'C' and tran_id <> ? " +
" and use_flag = 'C' order by lve_date_to desc";
pstmt = conn.prepareStatement(sql);
sql1 = "select payable from leaves where lve_code = ?";
pstmt1 = conn.prepareStatement(sql1);
sql2 = "select (case when can_combine is null then 'N' else can_combine end ) as combine from lvetable " +
" where lve_code = ? and lve_tblno = ?";
pstmt2 = conn.prepareStatement(sql2);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, temp1);
pstmt.setTimestamp(3, lvedt);
pstmt.setString(4, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
fr = rs.getTimestamp("lve_date_to");
lve = checkNull(rs.getString("lve_code"));
nextLveStart = checkNull(rs.getString("leave_ends"));
pstmt.setString(1, lve);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
payable = checkNull(rs1.getString("payable"));
}
System.out.println("payable---["+payable+"]");
pstmt1.clearParameters();
canCombine1 = "N";
if("Y".equalsIgnoreCase(payable))
{
pstmt2.setString(1, lve);
pstmt2.setString(2, lveTblno);
rs2 = pstmt2.executeQuery();
while(rs2.next())
{
canCombine1 = checkNull(rs2.getString("combine"));
}
pstmt2.clearParameters();
System.out.println("canCombine1---["+canCombine1+"]canCombine--["+canCombine+"]");
if("N".equalsIgnoreCase(canCombine) && "N".equalsIgnoreCase(canCombine1))
{
System.out.println("to--["+to+"]lvedt--["+lvedt+"]");
if(to.equals(lvedt) || utilMethod.DaysAfter(to, lvedt) == 1 && "E".equalsIgnoreCase(prevLveEnd) && "B".equalsIgnoreCase(leaveStart))
{
errCode = "VTLVE20";
}
else if("E".equalsIgnoreCase(prevLveEnd) && "B".equalsIgnoreCase(leaveStart))
{
errCode = "VTLVECHK1";
}
}
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(rs2 != null)
{
rs2.close();
rs2 = null;
}
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
if(errCode != null && errCode.trim().length() > 0)
{
return errCode;
}
temp1 = null;
temp1 = lvedtTo;
temp1 = utilMethod.RelativeDate(temp1,1);
System.out.println("temp1--["+temp1+"]");
sql = "select fn_get_holtblno(?,?) from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, temp1);
rs = pstmt.executeQuery();
while(rs.next())
{
lveTblno = checkNull(rs.getString(1));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
holType = admCommon.scanHolWoffFordate(empCode, lveTblno, temp1 ,conn);
System.out.println("holType--["+holType+"]");
if(holType != null && holType.trim().length() > 0)
{
if(utilMethod.pos(holType , "HW") == 0)
{
errCode = holType;
}
}
if(errCode != null && errCode.trim().length() > 0)
{
return errCode;
}
sql = "select lve_date_fr,lve_code,leave_starts from empleave where emp_code = ? " +
" and lve_date_fr >= ? and lve_date_fr <= ? " +
" and status <> 'C' and tran_id <> ? and use_flag = 'C' order by lve_date_fr";
pstmt = conn.prepareStatement(sql);
sql1 = "select payable from leaves where lve_code = ?";
pstmt1 = conn.prepareStatement(sql1);
sql2 = "select (case when can_combine is null then 'N' else can_combine end ) as combine from lvetable " +
" where lve_code = ? and lve_tblno = ?";
pstmt2 = conn.prepareStatement(sql2);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, lvedtTo);
pstmt.setTimestamp(3, temp1);
pstmt.setString(4, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
fr = rs.getTimestamp("lve_date_fr");
lve = checkNull(rs.getString("lve_code"));
nextLveStart = checkNull(rs.getString("leave_starts"));
pstmt.setString(1, lve);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
payable = checkNull(rs1.getString("payable"));
}
System.out.println("payable---["+payable+"]");
pstmt1.clearParameters();
canCombine1 = "N";
if("Y".equalsIgnoreCase(payable))
{
pstmt2.setString(1, lve);
pstmt2.setString(2, lveTblno);
rs2 = pstmt2.executeQuery();
while(rs2.next())
{
canCombine1 = checkNull(rs2.getString("combine"));
}
pstmt2.clearParameters();
if("N".equalsIgnoreCase(canCombine) && "N".equalsIgnoreCase(canCombine1))
{
if(to.equals(lvedtTo) || utilMethod.DaysAfter(lvedtTo, fr) == 1 && "E".equalsIgnoreCase(leaveEnd) && "B".equalsIgnoreCase(nextLveStart))
{
errCode = "VTLVE20";
}
else if("E".equalsIgnoreCase(leaveEnd) && "B".equalsIgnoreCase(nextLveStart))
{
errCode = "VTLVECHK1";
}
}
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(rs2 != null)
{
rs2.close();
rs2 = null;
}
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
System.out.println("errCode ###--["+errCode+"]");
if(errCode != null && errCode.trim().length() > 0)
{
return errCode;
}
}
catch(Exception e)
{
conn.rollback();
System.out.println("Exception from leave rule2--["+ e.getMessage() +"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(rs2 != null)
{
rs2.close();
rs2 = null;
}
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
}
catch(Exception e)
{
System.out.println("Exception in leaves rule 2 finally block===["+ e.getMessage() +"]");
e.printStackTrace();
throw new ITMException(e);
}
}
return errCode;
}
//Added by Anjali R. on [20/AUG/2018][Added updated leaveRules2 method][End]
private String leaveRules2 (String empCode, String lveCode, java.sql.Timestamp lvedt, java.sql.Timestamp lvedtTo, Connection conn) throws RemoteException,ITMException //Modfied by Anjali R. on [20/08/2018][Mthod name change leavesRule2 to leaveRules2_old .this method has old implementation]
private String leaveRules2_old (String empCode, String lveCode, java.sql.Timestamp lvedt, java.sql.Timestamp lvedtTo, Connection conn) throws RemoteException,ITMException
{ {
long cnt = 0,totLvedays = 0; long cnt = 0,totLvedays = 0;
......
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