Commit 7cf27511 authored by dpingle's avatar dpingle

* Change done in Employee Bond confirmation.

EmpBondDefConfirm.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@213802 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4c195373
package ibase.webitm.ejb.adm.adv;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.adm.HRLogWriter;
//import ibase.webitm.ejb.adm.TransIDGenerator;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.utility.GenericUtility;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.rmi.RemoteException;
......@@ -43,6 +48,15 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
ITMDBAccessEJB itmdbAccess=new ITMDBAccessEJB();
String retString = "",errString="";
String sql = "",empcode="",confirmed="";
// Modified by Dipesh P on [17/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
String empCode = "",tranIdBond= "", tranIdPvouch="", adCode="", keyString="";
String xmlValues = "" ,lsEmpSite = "" ,lsEmpCode = "", refSerBond = "", userId = "";
int lineNoPvouch= 0 ;
ResultSet rs1 = null;
PreparedStatement pstmt1 = null;
// Modified by Dipesh P on [17/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
double bondamt=0.0;
int lineno=0,bondprd=0,updCnt=0;
......@@ -58,17 +72,57 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
try
{
loginEmpCode = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverValidator");
// Modified by Dipesh P on [17/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
userId = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (userId == null || userId.trim().length() == 0)
{
userId = "SYSTEM";
}
/*ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverValidator");*/
conn=getConnection();
conn.setAutoCommit(false);
sql = "SELECT CONFIRMED FROM EMPLOYEE_BOND_DEF WHERE TRAN_ID = ?";
sql = "select Key_String, ref_ser from transetup where tran_window = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "w_employee_bond");
rs = pstmt.executeQuery();
if(rs.next())
{
keyString = rs.getString("Key_String");
refSerBond = rs.getString("ref_ser");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (keyString == null || keyString.trim().length() == 0 || refSerBond == null || refSerBond.trim().length() == 0)
{
errString = itmdbAccess.getErrorString("", "VTEBNDDEF51", "", "", conn);
conn.rollback();
return errString;
}
// Modified by Dipesh P on [17/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
//sql = "SELECT CONFIRMED FROM EMPLOYEE_BOND_DEF WHERE TRAN_ID = ?";
sql = "SELECT CONFIRMED , EMP_CODE , TRAN_ID__BOND , TRAN_ID__PVOUCH , LINE_NO__PVOUCH , AD_CODE FROM EMPLOYEE_BOND_DEF WHERE TRAN_ID = ? FOR UPDATE NOWAIT ";// Modified by Dipesh P on [17/12/2019] [CCF No: IT2018-015][Request ID: A19ISUN011]
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if( rs.next() )
{
confirmed =rs.getString("CONFIRMED")==null ? "":rs.getString("CONFIRMED");
// Modified by Dipesh P on [17/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
empCode =rs.getString("EMP_CODE")==null ? "":rs.getString("EMP_CODE");
tranIdBond =rs.getString("TRAN_ID__BOND")==null ? "":rs.getString("TRAN_ID__BOND");
tranIdPvouch =rs.getString("TRAN_ID__PVOUCH")==null ? "":rs.getString("TRAN_ID__PVOUCH");
lineNoPvouch =rs.getInt("LINE_NO__PVOUCH");
adCode =rs.getString("AD_CODE")==null ? "":rs.getString("AD_CODE");
// Modified by Dipesh P on [17/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
}
if( pstmt != null )
{
......@@ -81,11 +135,37 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
rs = null;
}
if( confirmed != null && confirmed.equalsIgnoreCase("Y") )
{
{
errString = itmdbAccess.getErrorString("", "AEBCONF", "", "", conn);
conn.rollback();
return errString;
}
// Modified by Dipesh P on [17/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
if (tranIdBond == null || tranIdBond.trim().length() == 0)
{
xmlValues = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + lsEmpSite + "</site_code>";
xmlValues = xmlValues + "<emp_code>" + empCode + "</emp_code>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :[" + xmlValues + "]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, userId, CommonConstants.DB_NAME);
tranIdBond = tg.generateTranSeqID(refSerBond, "tran_id", keyString, conn);
tg = null;
System.out.println("Generated Tran ID of Bond ::[" + tranIdBond + "]");
if (tranIdBond == null || tranIdBond.trim().length() == 0)
{
errString = itmdbAccess.getErrorString("", "VTTRANID", "", "", conn);
conn.rollback();
return errString;
}
}
// Modified by Dipesh P on [17/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
// Modified by Piyush on 16/07/2015 [To establish join between header and detail]
/*
sql="select ed.tran_id,e.emp_code,ed.line_no,ed.bond_amt,ed.bond_prd from employee_bond_def_det ed,employee_bond_def e "+
......@@ -97,12 +177,11 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
sql="select ed.tran_id,e.emp_code,ed.line_no,ed.bond_amt,ed.bond_prd from employee_bond_def_det ed,employee_bond_def e "+
" where e.tran_id = ed.tran_id and e.tran_id=?";
*/
ResultSet rs1 = null;
/*ResultSet rs1 = null;
PreparedStatement pstmt1 = null;
*/
/*
while(rs.next())
{
......@@ -129,15 +208,21 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
pstmt1.setString(1, tranId);
rs1 = pstmt1.executeQuery();
sql="update employee_bond set bond_amt = ?,bond_prd = ? where line_no = ? and emp_code = ?";
// Modified by Dipesh P on [17/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
//sql="update employee_bond set bond_amt = ?,bond_prd = ? where line_no = ? and emp_code = ?";
sql="update employee_bond set bond_amt = ?,bond_prd = ? where line_no = ? and emp_code = ? and tran_id = ?";
pstmt = conn.prepareStatement(sql);
sqlInsert = "Insert into employee_bond ( EMP_CODE , LINE_NO , BOND_PRD , BOND_AMT) values ( ? , ? , ? , ? )";
//sqlInsert = "Insert into employee_bond ( EMP_CODE , LINE_NO , BOND_PRD , BOND_AMT) values ( ? , ? , ? , ? )";
sqlInsert = "Insert into employee_bond ( EMP_CODE , LINE_NO , BOND_PRD , BOND_AMT , TRAN_ID , TRAN_ID__PVOUCH , LINE_NO__PVOUCH , AD_CODE) values ( ? , ? , ? , ? , ? , ? , ? , ?)";
pstmtInsert = conn.prepareStatement(sqlInsert);
sqlMaxLineNo="select max(line_no) as max_line_no from employee_bond where emp_code = ? ";
//sqlMaxLineNo="select max(line_no) as max_line_no from employee_bond where emp_code = ? ";
sqlMaxLineNo="select max(line_no) as max_line_no from employee_bond where emp_code = ? and tran_id = ?";
pstmtMax = conn.prepareStatement(sqlMaxLineNo);
// Modified by Dipesh P on [17/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
int totUpdCnt = 0;
while(rs1.next())
......@@ -156,14 +241,27 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
//For Obtaining the available maximum line number for inserting into the master
pstmtMax.setString(1, empcode);
// Modified by Dipesh P on [17/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
pstmtMax.setString(2, tranIdBond);
// Modified by Dipesh P on [17/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
rsMax = pstmtMax.executeQuery();
pstmtMax.clearParameters();
// Modified by Dipesh P on [19/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
//pstmtMax.clearParameters();
// Modified by Dipesh P on [19/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
while(rsMax.next())
{
maxLineNumber = rsMax.getInt("max_line_no");
}
// Modified by Dipesh P on [19/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
if (rsMax != null)
{
rsMax.close();
rsMax = null;
}
pstmtMax.clearParameters();
// Modified by Dipesh P on [19/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
if(maxLineNumber == 0)
{
......@@ -171,9 +269,9 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
System.out.println("Setting maxLine Number value as [1]");
maxLineNumber = 1;
}else
{
maxLineNumber = maxLineNumber + 1;
}
{
maxLineNumber = maxLineNumber + 1;
}
System.out.println("Available Max Line Number for inserting data :["+ maxLineNumber +"]");
......@@ -184,12 +282,24 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
pstmtInsert.setInt(3, bondprd);
pstmtInsert.setDouble(4, bondamt);
// Modified by Dipesh P on [19/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
pstmtInsert.setString(5, tranIdBond);
pstmtInsert.setString(6, tranIdPvouch);
pstmtInsert.setInt(7, lineNoPvouch);
pstmtInsert.setString(8, adCode);
// Modified by Dipesh P on [19/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
insertCnt = pstmtInsert.executeUpdate();
totUpdCnt = totUpdCnt + insertCnt;
System.out.println("Value of insertCnt is : ["+insertCnt+"]");
// Modified by Dipesh P on [19/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
pstmtInsert.clearParameters();
// Modified by Dipesh P on [19/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
}else
{//For updating values if line Number is not zero
}
else
{
//For updating values if line Number is not zero
System.out.println("*** Line Number is found to be "+ lineno +" ***");
......@@ -198,6 +308,10 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
pstmt.setInt(3, lineno);
pstmt.setString(4,empcode);
// Modified by Dipesh P on [19/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
pstmt.setString(5,tranIdBond);
// Modified by Dipesh P on [19/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
updCnt = pstmt.executeUpdate();
totUpdCnt = totUpdCnt + updCnt;
......@@ -207,11 +321,11 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
//Modified by Rahul Shenoy on 14/08/2015 [Inserting where line_no__ref is 0 and updating when it is not 0 to the Employee_Bond table]
}
if ( rsMax != null )
/*if ( rsMax != null )
{
rsMax.close();
rsMax = null;
}
}*/
if ( rs1 != null )
{
......@@ -269,14 +383,20 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
if (totUpdCnt > 0 && updcnt1 >0 )
{
retString=new ITMDBAccessEJB().getErrorString("", "VCONFSUC", "", "", conn);
// Modified by Dipesh P on [19/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
//retString=new ITMDBAccessEJB().getErrorString("", "VCONFSUC", "", "", conn);
retString=itmdbAccess.getErrorString("", "VCONFSUC", "", "", conn);
// Modified by Dipesh P on [19/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
conn.commit();
System.out.println("Bond amount and bond period updated successfully.......");
}else
{
retString=new ITMDBAccessEJB().getErrorString("", "VCONFUSUC", "", "", conn);
// Modified by Dipesh P on [19/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
// retString=new ITMDBAccessEJB().getErrorString("", "VCONFUSUC", "", "", conn);
retString=itmdbAccess.getErrorString("", "VCONFUSUC", "", "", conn);
// Modified by Dipesh P on [19/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
conn.rollback();
System.out.println("Not Updated Bond amount and bond period........");
}
......@@ -299,6 +419,32 @@ public class EmpBondDefConfirm extends ActionHandlerEJB implements EmpBondDefCon
{
try
{
// Modified by Dipesh P on [19/12/2019]Start [CCF No: IT2018-015][Request ID: A19ISUN011]
if ( rs1 != null )
{
rs1.close();
rs1 = null;
}
if( pstmtInsert != null )
{
pstmtInsert.close();
pstmtInsert = null;
}
if( pstmtMax != null )
{
pstmtMax.close();
pstmtMax = null;
}
if( pstmt1 != null )
{
pstmt1.close();
pstmt1 = null;
}
// Modified by Dipesh P on [19/12/2019]End [CCF No: IT2018-015][Request ID: A19ISUN011]
if(pstmt != null)
{
pstmt.close();
......
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