Commit f5ba29bc authored by vvengurlekar's avatar vvengurlekar

EmpLeaveConf.java - changes done for leave updation in leavebal table

EmpLeaveConfLocal.java
EmpLeaveConfRemote.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@188633 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e620585c
...@@ -93,19 +93,34 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -93,19 +93,34 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException, ITMException public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException, ITMException
{
String retString = "";
try
{
retString = confirm( tranId, xtraParams, forcedFlag, 2, conn);
}
catch(Exception e)
{
System.out.println("Exception :EmpLeaveConf :confirm():" + e.getMessage() + ":");
retString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("String Returned from Confirmation :: [" + retString + "]");
return retString;
}
public String confirm( String tranId, String xtraParams, String forcedFlag, int commitFlag, Connection conn) throws RemoteException, ITMException
{ {
System.out.println("--------------confirm method of Empleave -------------"); System.out.println("--------------confirm method of Empleave -------------");
ResultSet rs=null; ResultSet rs=null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String retString = ""; String retString = "";
String errString = "",errCode = ""; String errString = "",errCode = "";
HashMap hMap = new HashMap();
/*Modified by Anjali Rawankar on[22/08/2017][Start] /*Modified by Anjali Rawankar on[22/08/2017][Start]
*[Added for itmDbAccess] *[Added for itmDbAccess]
*/ */
AppConnectParm appConnect = null;
InitialContext initialCtx = null;
//Added & Commented by sarita to use object of ITMDBAccessEJB instead ITMDBAccessLocal on 20 JULY 18.[START] //Added & Commented by sarita to use object of ITMDBAccessEJB instead ITMDBAccessLocal on 20 JULY 18.[START]
//ITMDBAccessLocal itmDBAccess = null; //ITMDBAccessLocal itmDBAccess = null;
ITMDBAccessEJB itmDBAccess = null; ITMDBAccessEJB itmDBAccess = null;
...@@ -157,7 +172,8 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -157,7 +172,8 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
System.out.println("Calling Post Logic "); System.out.println("Calling Post Logic ");
retString = postLogic(tranId, tranId, 2, xtraParams, conn); //retString = postLogic(tranId, tranId, 2, xtraParams, conn); commented and added by Varsha V on 24-Jul-18
retString = postLogic(tranId, tranId, commitFlag, xtraParams, conn);
System.out.println("return Error List of Post Logic :: "+this.errList); System.out.println("return Error List of Post Logic :: "+this.errList);
...@@ -232,14 +248,11 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -232,14 +248,11 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
this.proteusDataSource = null; this.proteusDataSource = null;
this.admCommon = null; this.admCommon = null;
this.utilMethod = null; this.utilMethod = null;
//Added by sarita on 25 JULY 18 [START]
itmDBAccess = null;
//Added by sarita on 25 JULY 18 [END]
} }
System.out.println("Error String Returned from Confirmation :: [" + errString + "]"); System.out.println("Error String Returned from Confirmation :: [" + errString + "]");
return errString; return errString;
} }
private String postLogic (String tranIdFr, String tranIdTo, int commit, String xtraParams, Connection connectionObject) throws RemoteException,ITMException private String postLogic (String tranIdFr, String tranIdTo, int commit, String xtraParams, Connection connectionObject) throws RemoteException,ITMException
{ {
...@@ -614,7 +627,8 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -614,7 +627,8 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
else else
{ {
errCode = leavesApprove(tranId,2,payrollOrVoucher,payrollPeriod,2,connectionObject); //errCode = leavesApprove(tranId,2,payrollOrVoucher,payrollPeriod,2,connectionObject); commented and added by Varsha V on 24-Jul-18
errCode = leavesApprove(tranId,2,payrollOrVoucher,payrollPeriod,commit,connectionObject);
if (errCode != null && errCode.trim().length() > 0) if (errCode != null && errCode.trim().length() > 0)
{ {
isError = true; isError = true;
...@@ -3265,128 +3279,48 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3265,128 +3279,48 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
fVal4 = resultSet.getTimestamp("UPTO_DATE"); fVal4 = resultSet.getTimestamp("UPTO_DATE");
fVal5 = resultSet.getTimestamp("EXP_DATE"); fVal5 = resultSet.getTimestamp("EXP_DATE");
fVal6 = resultSet.getDouble("BAL_DAYS"); fVal6 = resultSet.getDouble("BAL_DAYS");
}
if(resultSet != null) if(noRows > 0)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(noRows > 0)
{
if( ((fVal6 < 0) || (fVal6 == 0 && (fVal3.before(mDate1) || fVal3.equals(mDate1)))))
{
//continue;
}
if(fVal6 < nextBal)
{
updBal = fVal6;
}
else
{
updBal = nextBal;
}
mConDays = updBal;
mEnchDays = 0;
if(museFlag.equals("E"))
{
mConDays = 0;
mEnchDays = updBal;
}
sql2 = "UPDATE LEAVEBAL SET BAL_DAYS= BAL_DAYS - ?,CONS_DAYS = CONS_DAYS + ?,ENCH_DAYS = ENCH_DAYS + ? WHERE EMP_CODE = ? AND LVE_CODE = ? AND EFF_DATE = ? AND UPTO_DATE = ?";
pstmt2 = connectionObject.prepareStatement(sql2);
pstmt2.setDouble(1,updBal );
pstmt2.setDouble(2, mConDays);
pstmt2.setDouble(3,mEnchDays);
pstmt2.setString(4, fVal1);
pstmt2.setString(5, fVal2);
pstmt2.setTimestamp(6, fVal3);
pstmt2.setTimestamp(7, fVal4);
noRows = pstmt2.executeUpdate();
/*Modified by Anjali Rawankar on[20/09/2017][Start]
*[Purpose : Close preparedstatement]
*/
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
if(noRows != 1)
{
errCode = "DS000NR";
this.errList.add(errCode);
this.fldList.add("");
isError = true;
break;
}
/*[Purpose : Close preparedstatement]
* Modified by Anjali Rawankar on[20/09/2017][End]
*/
noRows = 0;
sql3 = "SELECT COUNT(*) AS COUNT FROM EMPLVE_TRACE WHERE TRAN_ID = ? AND EFF_DATE = ? AND UPTO_DATE = ?";
pstmt3 = connectionObject.prepareStatement(sql3);
pstmt3.setString(1, tranId);
pstmt3.setTimestamp(2, fVal3);
pstmt3.setTimestamp(3, fVal4);
resultSet3 = pstmt3.executeQuery();
while(resultSet3.next())
{
mCnt = resultSet3.getInt("COUNT");
}
if(resultSet3 != null)
{
resultSet3.close();
resultSet3 = null;
}
if(pstmt3 != null)
{
pstmt3.close();
pstmt3 = null;
}
if(cfDate == null)
{
cfDate = mDate1;
}
if(fVal3.before(cfDate))
{
cfDate = fVal3;
}
if(mCnt == 0)
{ {
if( ((fVal6 < 0) || (fVal6 == 0 && (fVal3.before(mDate1) || fVal3.equals(mDate1)))))
sql4 = "INSERT INTO EMPLVE_TRACE (TRAN_ID , EMP_CODE, LVE_DATE_FR, LVE_DATE_TO, LVE_CODE,EFF_DATE, UPTO_DATE, LVES_ALLOC) VALUES (?,?,?,?,?,?, ?, ?)"; {
pstmt4 = connectionObject.prepareStatement(sql4); continue;
pstmt4.setString(1, tranId); }
pstmt4.setString(2, mEmp); if(fVal6 < nextBal)
pstmt4.setTimestamp(3, mDate1); {
pstmt4.setTimestamp(4, mDate2); updBal = fVal6;
pstmt4.setString(5, mLveCode); }
pstmt4.setTimestamp(6, fVal3); else
pstmt4.setTimestamp(7, fVal4); {
pstmt4.setDouble(8, updBal); updBal = nextBal;
noRows = pstmt4.executeUpdate(); }
mConDays = updBal;
mEnchDays = 0;
if(museFlag.equals("E"))
{
mConDays = 0;
mEnchDays = updBal;
}
sql2 = "UPDATE LEAVEBAL SET BAL_DAYS= BAL_DAYS - ?,CONS_DAYS = CONS_DAYS + ?,ENCH_DAYS = ENCH_DAYS + ? WHERE EMP_CODE = ? AND LVE_CODE = ? AND EFF_DATE = ? AND UPTO_DATE = ?";
pstmt2 = connectionObject.prepareStatement(sql2);
pstmt2.setDouble(1,updBal );
pstmt2.setDouble(2, mConDays);
pstmt2.setDouble(3,mEnchDays);
pstmt2.setString(4, fVal1);
pstmt2.setString(5, fVal2);
pstmt2.setTimestamp(6, fVal3);
pstmt2.setTimestamp(7, fVal4);
noRows = pstmt2.executeUpdate();
/*Modified by Anjali Rawankar on[20/09/2017][Start] /*Modified by Anjali Rawankar on[20/09/2017][Start]
*[Purpose : Close preparedstatement] *[Purpose : Close preparedstatement]
*/ */
//pstmt4.clearParameters(); if(pstmt2 != null)
if(pstmt4 != null)
{ {
pstmt4.close(); pstmt2.close();
pstmt4 = null; pstmt2 = null;
} }
/*[Purpose : Close preparedstatement]
* Modified by Anjali Rawankar on[20/09/2017][End]
*/
if(noRows != 1) if(noRows != 1)
{ {
errCode = "DS000NR"; errCode = "DS000NR";
...@@ -3395,44 +3329,125 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3395,44 +3329,125 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
isError = true; isError = true;
break; break;
} }
}
else
{
noRows = 0;
sql5 = "UPDATE EMPLVE_TRACE SET LVES_ALLOC = (CASE WHEN LVES_ALLOC IS NULL THEN 0 ELSE LVES_ALLOC END) + ? "
+" WHERE TRAN_ID = ? AND EFF_DATE = ? AND UPTO_DATE = ?";
pstmt5 = connectionObject.prepareStatement(sql5);
pstmt5.setDouble(1, updBal);
pstmt5.setString(2, tranId);
pstmt5.setTimestamp(3, fVal3);
pstmt5.setTimestamp(4, fVal4);
noRows = pstmt5.executeUpdate();
/*Modified by Anjali Rawankar on[20/09/2017][Start]
*[Purpose : Close preparedstatement]
*/
if(pstmt5 != null)
{
pstmt5.close();
pstmt5 = null;
}
/*[Purpose : Close preparedstatement] /*[Purpose : Close preparedstatement]
* Modified by Anjali Rawankar on[20/09/2017][End] * Modified by Anjali Rawankar on[20/09/2017][End]
*/ */
if(noRows != 1) noRows = 0;
sql3 = "SELECT COUNT(*) AS COUNT FROM EMPLVE_TRACE WHERE TRAN_ID = ? AND EFF_DATE = ? AND UPTO_DATE = ?";
pstmt3 = connectionObject.prepareStatement(sql3);
pstmt3.setString(1, tranId);
pstmt3.setTimestamp(2, fVal3);
pstmt3.setTimestamp(3, fVal4);
resultSet3 = pstmt3.executeQuery();
while(resultSet3.next())
{
mCnt = resultSet3.getInt("COUNT");
}
if(resultSet3 != null)
{
resultSet3.close();
resultSet3 = null;
}
if(pstmt3 != null)
{
pstmt3.close();
pstmt3 = null;
}
if(cfDate == null)
{
cfDate = mDate1;
}
if(fVal3.before(cfDate))
{
cfDate = fVal3;
}
if(mCnt == 0)
{
sql4 = "INSERT INTO EMPLVE_TRACE (TRAN_ID , EMP_CODE, LVE_DATE_FR, LVE_DATE_TO, LVE_CODE,EFF_DATE, UPTO_DATE, LVES_ALLOC) VALUES (?,?,?,?,?,?, ?, ?)";
pstmt4 = connectionObject.prepareStatement(sql4);
pstmt4.setString(1, tranId);
pstmt4.setString(2, mEmp);
pstmt4.setTimestamp(3, mDate1);
pstmt4.setTimestamp(4, mDate2);
pstmt4.setString(5, mLveCode);
pstmt4.setTimestamp(6, fVal3);
pstmt4.setTimestamp(7, fVal4);
pstmt4.setDouble(8, updBal);
noRows = pstmt4.executeUpdate();
/*Modified by Anjali Rawankar on[20/09/2017][Start]
*[Purpose : Close preparedstatement]
*/
//pstmt4.clearParameters();
if(pstmt4 != null)
{
pstmt4.close();
pstmt4 = null;
}
/*[Purpose : Close preparedstatement]
* Modified by Anjali Rawankar on[20/09/2017][End]
*/
if(noRows != 1)
{
errCode = "DS000NR";
this.errList.add(errCode);
this.fldList.add("");
isError = true;
break;
}
}
else
{
noRows = 0;
sql5 = "UPDATE EMPLVE_TRACE SET LVES_ALLOC = (CASE WHEN LVES_ALLOC IS NULL THEN 0 ELSE LVES_ALLOC END) + ? "
+" WHERE TRAN_ID = ? AND EFF_DATE = ? AND UPTO_DATE = ?";
pstmt5 = connectionObject.prepareStatement(sql5);
pstmt5.setDouble(1, updBal);
pstmt5.setString(2, tranId);
pstmt5.setTimestamp(3, fVal3);
pstmt5.setTimestamp(4, fVal4);
noRows = pstmt5.executeUpdate();
/*Modified by Anjali Rawankar on[20/09/2017][Start]
*[Purpose : Close preparedstatement]
*/
if(pstmt5 != null)
{
pstmt5.close();
pstmt5 = null;
}
/*[Purpose : Close preparedstatement]
* Modified by Anjali Rawankar on[20/09/2017][End]
*/
if(noRows != 1)
{
errCode = "DS000NR";
this.errList.add(errCode);
this.fldList.add("");
isError = true;
break;
}
}
nextBal = nextBal - updBal;
if(nextBal == 0)
{ {
errCode = "DS000NR";
this.errList.add(errCode);
this.fldList.add("");
isError = true;
break; break;
} }
} }
nextBal = nextBal - updBal;
if(nextBal == 0)
{
//break;
}
} }
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if((errCode != null) && errCode.trim().length() > 0) if((errCode != null) && errCode.trim().length() > 0)
{ {
isError = true; isError = true;
...@@ -4997,9 +5012,9 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4997,9 +5012,9 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
xmlString.append("<status>").append("<![CDATA[" + status + "]]>").append("</status>"); xmlString.append("<status>").append("<![CDATA[" + status + "]]>").append("</status>");
xmlString.append("<status_date>").append("<![CDATA[" + simpledf.format(statusDate) + "]]>").append("</status_date>"); xmlString.append("<status_date>").append("<![CDATA[" + simpledf.format(statusDate) + "]]>").append("</status_date>");
xmlString.append("<remarks>").append("<![CDATA[" + remarks + "]]>").append("</remarks>"); xmlString.append("<remarks>").append("<![CDATA[" + remarks + "]]>").append("</remarks>");
xmlString.append("<appl_date>").append("<![CDATA[" + simpledf.format(applDate) + "]]>").append("</appl_date>"); xmlString.append("<appl_date>").append("<![CDATA[" + (applDate!=null ? simpledf.format(applDate) : applDate) + "]]>").append("</appl_date>");
xmlString.append("<start_time>").append("<![CDATA[" + simpledf.format(StartTime ) + "]]>").append("</start_time>"); xmlString.append("<start_time>").append("<![CDATA[" + (StartTime!=null ? simpledf.format(StartTime ) : StartTime )+ "]]>").append("</start_time>");
xmlString.append("<end_time>").append("<![CDATA[" + simpledf.format(EndTime) + "]]>").append("</end_time>"); xmlString.append("<end_time>").append("<![CDATA[" + (EndTime!=null ? simpledf.format(EndTime) : EndTime) + "]]>").append("</end_time>");
xmlString.append("</Detail1>"); xmlString.append("</Detail1>");
xmlString.append("</header0>\r\n"); xmlString.append("</header0>\r\n");
xmlString.append("</DocumentRoot>\r\n"); xmlString.append("</DocumentRoot>\r\n");
...@@ -5014,4 +5029,4 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -5014,4 +5029,4 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
//Modified by Anjali R. on [28/06/2018][Added overloaded method for getXMLFromDBForEdit with parameter tran_id,conn][End] //Modified by Anjali R. on [28/06/2018][Added overloaded method for getXMLFromDBForEdit with parameter tran_id,conn][End]
} }
\ No newline at end of file
...@@ -17,4 +17,6 @@ public interface EmpLeaveConfLocal extends ActionHandlerLocal ...@@ -17,4 +17,6 @@ public interface EmpLeaveConfLocal extends ActionHandlerLocal
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException; public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException; public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException;
public String confirm( String tranId, String xtraParams, String forcedFlag, int commitFlag, Connection conn) throws RemoteException, ITMException;
} }
...@@ -13,4 +13,5 @@ public interface EmpLeaveConfRemote ...@@ -13,4 +13,5 @@ public interface EmpLeaveConfRemote
{ {
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException; public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException; public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException;
public String confirm( String tranId, String xtraParams, String forcedFlag, int commitFlag, Connection conn) throws RemoteException, ITMException;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment