Commit cfc7cd62 authored by vvengurlekar's avatar vvengurlekar

AdmCommon Committed

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@206778 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3d0b4982
...@@ -19,12 +19,17 @@ import java.sql.SQLException; ...@@ -19,12 +19,17 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
// Modified By Hemlata on [11/11/2014] To update org_structure and org_struc_trace on postsave[Start] // Modified By Hemlata on [11/11/2014] To update org_structure and org_struc_trace on postsave[Start]
import java.util.Date; import java.util.Date;
// Modified by Vishal Thakur on 04-07-2017 [Migration from PB to JAVA for Employee Leave][Start] // Modified by Vishal Thakur on 04-07-2017 [Migration from PB to JAVA for Employee Leave][Start]
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.w3c.dom.CDATASection; import org.w3c.dom.CDATASection;
import org.w3c.dom.Document; import org.w3c.dom.Document;
...@@ -585,7 +590,7 @@ public class AdmCommon ...@@ -585,7 +590,7 @@ public class AdmCommon
TransIDGenerator tg = new TransIDGenerator(XMLString, userId, CommonConstants.DB_NAME); TransIDGenerator tg = new TransIDGenerator(XMLString, userId, CommonConstants.DB_NAME);
tranID = tg.generateTranSeqID("PAYARR", "tran_id", keyString, conn); tranID = tg.generateTranSeqID("PAYARR", "tran_id", keyString, conn);
System.out.println("Transaction Id Generated [tranID] :: "+tranID); System.out.println("Transaction Id Generated [tranID] :: "+tranID);
if (tranID.equalsIgnoreCase("ERROR")) if(tranID.equalsIgnoreCase("ERROR"))
{ {
errCode = "VTTRANID"; errCode = "VTTRANID";
break; break;
...@@ -3415,8 +3420,6 @@ public class AdmCommon ...@@ -3415,8 +3420,6 @@ public class AdmCommon
} }
return ret; return ret;
} }
//Added by Azhar K. on[08-07-2019][Start]
public Timestamp gfLastDate(Timestamp mdate) throws ITMException public Timestamp gfLastDate(Timestamp mdate) throws ITMException
{ {
Timestamp retDate = null; Timestamp retDate = null;
...@@ -3460,7 +3463,7 @@ public class AdmCommon ...@@ -3460,7 +3463,7 @@ public class AdmCommon
return retDate; return retDate;
} }
public double gfGetRndAmt(double unrAmt, String rndOff, double rndTo) throws ITMException /*public double gfGetRndAmt(double unrAmt, String rndOff, double rndTo) throws ITMException
{ {
double rndAmt = 0; double rndAmt = 0;
double lcMultiply = 1; double lcMultiply = 1;
...@@ -3535,7 +3538,7 @@ public class AdmCommon ...@@ -3535,7 +3538,7 @@ public class AdmCommon
return rndAmt; return rndAmt;
} }
//Added by Azhar K. on[08-07-2019][End] //Added by Azhar K. on[08-07-2019][End]
*/
//Modified by Azhar on [27-July-2019][To resolve the issue of job_id][Start] //Modified by Azhar on [27-July-2019][To resolve the issue of job_id][Start]
public HashMap gfGetHrBackgroundJobid(HashMap hrBackGrndJobId,Connection logConn) throws ITMException public HashMap gfGetHrBackgroundJobid(HashMap hrBackGrndJobId,Connection logConn) throws ITMException
...@@ -3642,4 +3645,1861 @@ public class AdmCommon ...@@ -3642,4 +3645,1861 @@ public class AdmCommon
tempNode = null; tempNode = null;
}//End of Method setNodeValue }//End of Method setNodeValue
//Added by sarita on setNodeValue method on 14 AUG 2019 [END] //Added by sarita on setNodeValue method on 14 AUG 2019 [END]
//Added by Varsha V on 05-07-19
public String gfCalcPropDays(String cPaysite, String cCadre, String cGrade, String prdCode, String empCode, HashMap calcPropDays, String xtraParams, Connection conn) throws ITMException, SQLException
{
System.out.println("Calling gfCalcPropDays(String cPaysite, String cCadre, String cGrade, String prdCode, String empCode, HashMap calcPropDays, String xtraParams, Connection conn) of AdmCommon");
ResultSet resultSet = null;
PreparedStatement pstmt = null;
String sql = "";
Timestamp frDateTm = null, toDateTm = null;
String calcProp = "", errorCode = "", woffInPropdays = "", holidayInPropdays = "", holTblNo = "", propAd = "", todayDateStr = "", userId = "", termId = "";
HashMap strHolData = null;
HashMap holDataMap = null, holDataMapInner = null;
long propDays = 0;
int cntWoff = 0, count = 0, updateCount = 0;
Timestamp holDateTm = null, todatDateTm = null;
UtilMethods utilMethods = new UtilMethods();
E12GenericUtility genericUtility = new E12GenericUtility();
SimpleDateFormat sdf = null;
Set<String> keySet = null;
SimpleDateFormat sdfInyyyyMMdd = new SimpleDateFormat("yyyyMMdd");
try
{
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
do {
sql = "select fr_date, to_date from period where code = :as_prdcode";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
frDateTm = resultSet.getTimestamp("fr_date");
toDateTm = resultSet.getTimestamp("to_date");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
int month = utilMethods.month(frDateTm);
if(calcPropDays.get("calcprop") != null && calcPropDays.get("calcprop").toString().trim().length() > 0)
{
calcProp = calcPropDays.get("calcprop").toString();
}
else
{
calcProp = checkNull(getAdmEnv(cPaysite, cCadre, cGrade, "CALCPROPDAYS", frDateTm, conn));
if(calcProp.equalsIgnoreCase("NULLFOUND"))
{
break;
}
else if(utilMethods.left(calcProp, 4).equalsIgnoreCase("ERR"))
{
errorCode = utilMethods.mid(calcProp , 5);
break;
}
}
if(calcProp == null || !(calcProp.trim().equalsIgnoreCase("Y")))
{
break;
}
if(calcPropDays.get("woffinpropdays") != null && calcPropDays.get("woffinpropdays").toString().trim().length() > 0)
{
woffInPropdays = calcPropDays.get("woffinpropdays").toString();
}
else
{
woffInPropdays = checkNull(getAdmEnv(cPaysite, cCadre, cGrade, "WOFFINPROPDAYS", frDateTm, conn));
if(woffInPropdays.equalsIgnoreCase("NULLFOUND"))
{
break;
}
else if(utilMethods.left(woffInPropdays, 4).equalsIgnoreCase("ERR"))
{
errorCode = utilMethods.mid(woffInPropdays , 5);
break;
}
holidayInPropdays = checkNull(getAdmEnv(cPaysite, cCadre, cGrade, "HOLINPROPDAYS", frDateTm, conn));
if(holidayInPropdays.equalsIgnoreCase("NULLFOUND"))
{
break;
}
else if(utilMethods.left(holidayInPropdays, 4).equalsIgnoreCase("ERR"))
{
errorCode = utilMethods.mid(holidayInPropdays , 5);
break;
}
}
if(woffInPropdays == null || !(woffInPropdays.trim().equalsIgnoreCase("N")))
{
woffInPropdays = "Y";
}
propDays = utilMethods.DaysAfter(frDateTm, toDateTm)+1;
if(woffInPropdays.equalsIgnoreCase("N"))
{
sql = "select hol_tblno from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
holTblNo = resultSet.getString("hol_tblno");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(holTblNo == null || holTblNo.trim().length() == 0)
{
sql = "select hol_tblno from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, cPaysite);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
holTblNo = resultSet.getString("hol_tblno");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(holTblNo == null || holTblNo.trim().length() == 0)
{
errorCode = "VMHOL1";
break;
}
}
strHolData = gfGetHols(empCode, frDateTm, toDateTm, holTblNo, conn);
String errorCodeHol = strHolData.get("errorcode").toString();
if(errorCodeHol != null && errorCodeHol.trim().length() > 0)
{
errorCode = errorCodeHol;
break;
}
strHolData =(HashMap) strHolData.get("holiday");
holDataMap = new HashMap();
if(woffInPropdays.equalsIgnoreCase("N") && !(holidayInPropdays.equalsIgnoreCase("N")))
{
keySet = null;
keySet = strHolData.keySet();
for(String key : keySet)
{
if(key.contains("W"))
{
holDataMap.put(key, strHolData.get(key));
}
}
}
else if(!(woffInPropdays.equalsIgnoreCase("N")) && holidayInPropdays.equalsIgnoreCase("N"))
{
keySet = null;
keySet = strHolData.keySet();
for(String key : keySet)
{
if(key.contains("H"))
{
holDataMap.put(key, strHolData.get(key));
}
}
}
count = holDataMap.size();
if(count > 0)
{
keySet = null;
keySet = holDataMap.keySet();
holDataMapInner = new HashMap();
for(String key : keySet)
{
if(key.contains("W"))
{
holDataMapInner.put(key, holDataMap.get(key));
}
}
sql = "select hol_date from holiday where hol_tblno = ? "
+ "and hol_date between ? and ? and hol_type = 'H'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNo);
pstmt.setTimestamp(2, frDateTm);
pstmt.setTimestamp(3, toDateTm);
resultSet = pstmt.executeQuery();
while(resultSet.next()) {
holDateTm = resultSet.getTimestamp("hol_date");
String dateInyyyyMMdd = sdfInyyyyMMdd.format(holDateTm);
keySet = null;
keySet = holDataMapInner.keySet();
for(String key : keySet)
{
if(key.contains(dateInyyyyMMdd))
{
cntWoff = cntWoff + 1;
}
}
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
count = count - cntWoff;
propDays = propDays - count;
}
propAd = getEnv("999999", "PROP_DAYS_AD", conn);
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
todayDateStr = sdf.format(new java.util.Date());
todatDateTm = Timestamp.valueOf(genericUtility.getValidDateString(todayDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(propAd != null && propAd.trim().length() > 0 && propAd.equalsIgnoreCase("NULLFOUND"))
{
count = 0;
sql = "select count(*) as cnt from employee_mthad where emp_code = ? " +
" and month_code = ? and ad_code = ? and eff_date <= ? " +
" and exp_date >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setInt(2, month);
pstmt.setString(3, propAd);
pstmt.setTimestamp(4, frDateTm);
pstmt.setTimestamp(5, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
count = resultSet.getInt("cnt");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(count > 1)
{
errorCode = "VPPROPDY1";
}
else if(count == 1)
{
updateCount = 0;
sql = "update employee_mthad set amount = ? , " +
" type = 'F' , prop_yn = 'N' , ref_type = 'O' , chg_date = ? , chg_user = ? ," +
" chg_term = ? where emp_code = ? and month_code = ? and ad_code = ? " +
" and eff_date <= ? and exp_date >= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setLong(1, propDays);
pstmt.setTimestamp(2, todatDateTm);
pstmt.setString(3, userId);
pstmt.setString(4, termId);
pstmt.setString(5, empCode);
pstmt.setInt(6, month);
pstmt.setString(7, propAd);
pstmt.setTimestamp(8, frDateTm);
pstmt.setTimestamp(9, toDateTm);
updateCount = pstmt.executeUpdate();
if(updateCount != 1)
{
errorCode = "DS000NR";
}
}
else
{
updateCount = 0;
sql = "insert into employee_mthad( emp_code, month_code, ad_code, eff_date, exp_date, type, amount, prop_yn, " +
"chg_date , chg_user , chg_term , ref_type ) " +
"values(?, ?, ?, ?, ?, 'F', ?, 'N', ?, ?, ?, 'O')";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setInt(2, month);
pstmt.setString(3, propAd);
pstmt.setTimestamp(4, frDateTm);
pstmt.setTimestamp(5, toDateTm);
pstmt.setLong(6, propDays);
pstmt.setTimestamp(7, todatDateTm);
pstmt.setString(8, userId);
pstmt.setString(9, termId);
updateCount = pstmt.executeUpdate();
if(updateCount != 1)
{
errorCode = "DS000NR";
}
}
}
}while(true);
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("Error code in gfCalcPropDays : "+errorCode);
return errorCode;
}
public double gfGetProp(String periodCode, String empCode, String cadre, String grade, String paysite, String paytable, String setDefault, Connection conn) throws ITMException, SQLException
{
System.out.println("Calling gfGetProp(String periodCode, String empCode, String cadre, String grade, String paysite, String paytable, String setDefault, Connection conn) of AdmCommon");
ResultSet resultSet = null;
PreparedStatement pstmt = null;
int monthCode = 0;
String sql = "";
UtilMethods utilMethods = new UtilMethods();
Timestamp frDateTm = null, toDateTm = null;
String lsAd = "", errorCode = "";
int count = 0;
double amount = 0;
try {
monthCode = Integer.parseInt(checkInt(utilMethods.mid(periodCode, 5, 2)));
if(setDefault == null)
{
setDefault = "N";
}
// Piyush - 26/08/2019.Start
else if(setDefault.trim().equalsIgnoreCase("Y"))
{
setDefault = "Y";
}
else
{
setDefault = "N";
}
// Piyush - 26/08/2019.End
sql = "select fr_date, to_date from period where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
frDateTm = resultSet.getTimestamp("fr_date");
toDateTm = resultSet.getTimestamp("to_date");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
lsAd = getEnv("999999", "PROP_DAYS_AD", conn);
// Piyush - 26/08/2019
// if(lsAd != null && lsAd.trim().length() > 0 && lsAd.equalsIgnoreCase("NULLFOUND"))
if(lsAd != null && lsAd.trim().length() > 0 && !lsAd.equalsIgnoreCase("NULLFOUND"))
{
do {
sql = "select count(*) as count from employee_mthad where emp_code = ? " +
" and month_code = ? and ad_code = ? and eff_date <= ? " +
" and exp_date >= ? and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setInt(2, monthCode);
pstmt.setString(3, lsAd);
pstmt.setTimestamp(4, frDateTm);
pstmt.setTimestamp(5, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
count = resultSet.getInt("count");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(count > 1)
{
errorCode = "VPPROPDY1~tMultiple Rows Found In Employee_Mthad Table For Employee Code : " + empCode + " For Period Code : " + periodCode;
break;
}
else if(count == 1)
{
sql = "select amount from employee_mthad where emp_code = ? and month_code = ? and ad_code = ? " +
" and eff_date <= ? and exp_date >= ? and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setInt(2, monthCode);
pstmt.setString(3, lsAd);
pstmt.setTimestamp(4, frDateTm);
pstmt.setTimestamp(5, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
amount = resultSet.getDouble("amount");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
break;
}
count = 0;
sql = "select count(*) as count from grade_mthad where pay_table = ? " +
" and grade_code = ? and month_code = ? and ad_code = ? and eff_date <= ? and exp_date >= ? " +
" and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, paytable);
pstmt.setString(2, grade);
pstmt.setInt(3, monthCode);
pstmt.setString(4, lsAd);
pstmt.setTimestamp(5, frDateTm);
pstmt.setTimestamp(6, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
count = resultSet.getInt("count");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(count > 1)
{
errorCode = "VPPROPDY1 ~t Multiple Rows Found In Grade_Mthad Table For Grade Code : " + grade + " For Period Code : " + periodCode;
break;
}
else if(count == 1)
{
sql = "select amount from grade_mthad where pay_table = ? and grade_code = ? " +
" and month_code = ? and ad_code = ? and eff_date <= ? and exp_date >= ? and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, paytable);
pstmt.setString(2, grade);
pstmt.setInt(3, monthCode);
pstmt.setString(4, lsAd);
pstmt.setTimestamp(5, frDateTm);
pstmt.setTimestamp(6, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
amount = resultSet.getDouble("amount");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
break;
}
count = 0;
sql = "select count(*) as count from cadre_mthad where pay_table = ? and cadre_code = ? and month_code = ? " +
" and ad_code = ? and eff_date <= ? and exp_date >= ? and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, paytable);
pstmt.setString(2, cadre);
pstmt.setInt(3, monthCode);
pstmt.setString(4, lsAd);
pstmt.setTimestamp(5, frDateTm);
pstmt.setTimestamp(6, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
count = resultSet.getInt("count");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(count > 1)
{
errorCode = "VPPROPDY1 ~t Multiple Rows Found In Cadre_Mthad Table For Cadre Code : " + cadre + " For Period Code : " + periodCode;
break;
}
else if(count == 1)
{
sql = "select amount from cadre_mthad where pay_table = ? and cadre_code = ? and month_code = ? " +
" and ad_code = ? and eff_date <= ? and exp_date >= ? and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, paytable);
pstmt.setString(2, cadre);
pstmt.setInt(3, monthCode);
pstmt.setString(4, lsAd);
pstmt.setTimestamp(5, frDateTm);
pstmt.setTimestamp(6, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
amount = resultSet.getDouble("amount");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
break;
}
count = 0;
sql = "select count(*) as count from employee_ad where emp_code = ? and ad_code = ? and eff_date <= ? and exp_date >= ? " +
" and confirmed = 'Y' and type='F' and amount is not null";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, lsAd);
pstmt.setTimestamp(3, frDateTm);
pstmt.setTimestamp(4, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
count = resultSet.getInt("count");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(count > 1)
{
errorCode = "VPPROPDY1 ~t Multiple Rows Found In Employee_ad Table For Employee Code : " + empCode + " For Period Code : " + periodCode;
break;
}
else if(count == 1)
{
sql = "select amount from employee_ad where emp_code = ? and ad_code = ? and eff_date <= ? and exp_date >= ? " +
" and confirmed = 'Y' and type='F' and amount is not null";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, lsAd);
pstmt.setTimestamp(3, frDateTm);
pstmt.setTimestamp(4, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
amount = resultSet.getDouble("amount");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
break;
}
count = 0;
sql = "select count(*) as count from grade_ad where pay_table = ? and grade_code = ? and ad_code = ? and eff_date <= ? " +
" and exp_date >= ? and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, paytable);
pstmt.setString(2, grade);
pstmt.setString(3, lsAd);
pstmt.setTimestamp(4, frDateTm);
pstmt.setTimestamp(5, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
count = resultSet.getInt("count");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(count > 1)
{
errorCode = "VPPROPDY1 ~t Multiple Rows Found In Grade_ad Table For Grade Code : " + grade + " For Period Code : " + periodCode;
break;
}
else if(count == 1)
{
sql = "select amount from grade_ad where pay_table = ? and grade_code = ? and ad_code = ? and eff_date <= ? " +
" and exp_date >= ? and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, paytable);
pstmt.setString(2, grade);
pstmt.setString(3, lsAd);
pstmt.setTimestamp(4, frDateTm);
pstmt.setTimestamp(5, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
amount = resultSet.getDouble("amount");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
break;
}
count = 0;
sql = "select count(*) as count from cadre_ad where pay_table = ? and cadre_code = ? and ad_code = ? and eff_date <= ? " +
" and exp_date >= ? and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, paytable);
pstmt.setString(2, cadre);
pstmt.setString(3, lsAd);
pstmt.setTimestamp(4, frDateTm);
pstmt.setTimestamp(5, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
count = resultSet.getInt("count");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(count > 1)
{
errorCode = "VPPROPDY1 ~t Multiple Rows Found In Cadre_ad Table For Cadre Code : " + cadre + " For Period Code : " + periodCode;
break;
}
else if(count == 1)
{
sql = "select amount from cadre_ad where pay_table = ? and cadre_code = ? and ad_code = ? and eff_date <= ? " +
" and exp_date >= ? and amount is not null and type = 'F'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, paytable);
pstmt.setString(2, cadre);
pstmt.setString(3, lsAd);
pstmt.setTimestamp(4, frDateTm);
pstmt.setTimestamp(5, toDateTm);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
amount = resultSet.getDouble("amount");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
break;
}
break;
}while(true);
}
if(errorCode != null && errorCode.trim().length() > 0)
{
amount = -1;
}
else if(amount <= 0)
{
amount = 0;
String lsReturn = getEnv(periodCode, "PROP_DAYS_"+paysite.toUpperCase(), conn);
if(lsReturn == null || lsReturn.equalsIgnoreCase("NULLFOUND"))
{
amount = 0;
if(setDefault.equalsIgnoreCase("Y"))
{
lsReturn = getEnv(periodCode, "PROP_DAYS", conn);
if(lsReturn == null || lsReturn.equalsIgnoreCase("NULLFOUND"))
{
lsReturn = getEnv("999999", "PROP_DAYS", conn);
if(lsReturn != null && lsReturn.trim().length() > 0 && !(lsReturn.equalsIgnoreCase("NULLFOUND")))
{
try
{
amount = Double.parseDouble(checkInt(lsReturn));
}
catch (Exception e1)
{
amount = 0;
}
}
}
else
{
try
{
amount = Double.parseDouble(checkInt(lsReturn));
}
catch (Exception e1)
{
amount = 0;
}
}
}
}
else
{
try
{
amount = Double.parseDouble(checkInt(lsReturn));
}
catch (Exception e1)
{
amount = 0;
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("amount in gfGetProp:: "+amount);
return amount;
}
public LinkedHashMap gfGetStatStanPayTable(String deptCode, String siteCode, String stanCodeHQ, String payTable, Connection conn) throws ITMException, SQLException
{
System.out.println("Calling gfGetStatStanPayTable(String deptCode, String siteCode, String stanCodeHQ, String payTable, Connection conn) of AdmCommon");
ResultSet resultSet = null;
PreparedStatement pstmt = null;
String lsStateCodeHQ = "" , lsPayTable = "";
String sql = "";
LinkedHashMap returnMap = new LinkedHashMap();
int retVal = 0;
try {
if(stanCodeHQ != null && stanCodeHQ.trim().length() > 0)
{
try
{
sql = "select state_code from station where stan_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, stanCodeHQ);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
lsStateCodeHQ = checkNull(resultSet.getString("state_code"));
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "select pay_table from site_stan_paytbl where site_code = ? and state_code = ? and stan_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, lsStateCodeHQ);
pstmt.setString(3, stanCodeHQ);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
lsPayTable = resultSet.getString("pay_table");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("value of pay_table in site_stan_paytbl :: ["+lsPayTable+"]");
if(lsPayTable == null || lsPayTable.trim().length() == 0)
{
sql = "select pay_table from site_stan_paytbl where site_code = ? and state_code = ? and stan_code = ' '";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, lsStateCodeHQ);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
lsPayTable = resultSet.getString("pay_table");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("value of pay_table in site_stan_paytbl :: ["+lsPayTable+"]");
}
}
catch (Exception e) {
retVal = -1;
}
}
if(retVal != -1)
{
if(lsPayTable == null || lsPayTable.trim().length() == 0)
{
try {
sql = "select pay_table from department where dept_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, deptCode);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
lsPayTable = resultSet.getString("pay_table");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("value of pay_table in department :: ["+lsPayTable+"]");
if(lsPayTable == null || lsPayTable.trim().length() == 0)
{
sql = "select pay_table from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
lsPayTable = resultSet.getString("pay_table");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("value of pay_table in Site :: ["+lsPayTable+"]");
if(lsPayTable == null)
{
retVal = -1;
}
}
}
catch (Exception e) {
retVal = -1;
}
}
}
returnMap.put("globalPayTable",lsPayTable);
returnMap.put("retVal",retVal);
System.out.println("Value of returnMap in gfGetStatStanPayTable:: ["+returnMap+"]");
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("returnMap in gfGetStatStanPayTable:: "+returnMap);
return returnMap;
}
public HashMap gfGetHols(String empCode, Timestamp frDateTm, Timestamp toDateTm, String holTblNo, Connection conn) throws ITMException, SQLException
{
System.out.println("Calling gfGetHols(String empCode, Timestamp frDateTm, Timestamp toDateTm, String holTblNo, Connection conn) of AdmCommon");
ResultSet resultSet = null;
PreparedStatement pstmt = null;
String sql = "", holTblNoFr = "", holTblNoTo = "", holTblNo1 = "";
Timestamp effDateTm = null, tempFr = null, tempTo = null, tempFr1 = null, tempTo1 = null;
int count = 0;
String flag = "";
HashMap holData = null;
HashMap holDataAll = new HashMap();
HashMap holDataAll1 = new HashMap();
HashMap returnMap = new HashMap();
UtilMethods utilMethods = new UtilMethods();
String errorCode = "";
int cnt = 0;
Timestamp holDate = null;
String holType = "";
String holDateStr = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Set<String> keySet = null;
try {
do {
sql = "select count(*) as count from emp_employ_events where emp_code = ? and trans_type = 'H' and confirmed = 'Y'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
resultSet = pstmt.executeQuery();
if(resultSet.next()) {
count = resultSet.getInt("count");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
flag = "N";
if(count == 0)
{
sql = "SELECT hol_date, hol_type, no_days, hol_tblno FROM holiday WHERE (( hol_tblno = ? ) AND " +
"( hol_date between ? and ? ) AND (hol_type = 'W')) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNo);
pstmt.setTimestamp(2, frDateTm);
pstmt.setTimestamp(3, toDateTm);
resultSet = pstmt.executeQuery();
while(resultSet.next()) {
holData = new HashMap();
holDate = resultSet.getTimestamp("hol_date");
holDateStr = sdf.format(holDate);
holType = checkNull(resultSet.getString("hol_type"));
holData.put("hol_date", holDate);
holData.put("hol_type", holType);
holData.put("no_days", checkInt(resultSet.getString("no_days")));
holData.put("hol_tblno", checkNull(resultSet.getString("hol_tblno")));
holDataAll.put(holDateStr+"-"+holType, holData);
cnt++;
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("holDataAll map :: ["+holDataAll+"]");
}
else
{
sql = "select hol_tblno__fr ,hol_tblno__to, eff_date from emp_employ_events where emp_code = ? " +
" and trans_type = 'H' and confirmed = 'Y' order by eff_date asc ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
resultSet = pstmt.executeQuery();
cnt = 0;
while(resultSet.next()) {
holTblNoFr = checkNull(resultSet.getString("hol_tblno__fr"));
holTblNoTo = checkNull(resultSet.getString("hol_tblno__to"));
effDateTm = resultSet.getTimestamp("eff_date");
tempFr = frDateTm;
do {
if(count == 1)
{
if(effDateTm.after(frDateTm))
{
tempFr = frDateTm;
Date toDate = new Date(toDateTm.getTime());
Date effDate = new Date(effDateTm.getTime());
if((toDate.before(effDate)) || (toDate.equals(effDate)))
{
flag = "Y";
tempTo = new Timestamp(utilMethods.RelativeDate(effDate, -1).getTime());
sql = "SELECT hol_date, hol_type, no_days, hol_tblno FROM holiday WHERE (( hol_tblno = ? ) AND " +
"( hol_date between ? and ? ) AND (hol_type = 'W')) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNoFr);
pstmt.setTimestamp(2, frDateTm);
pstmt.setTimestamp(3, toDateTm);
resultSet = pstmt.executeQuery();
while(resultSet.next()) {
holData = new HashMap();
holDate = resultSet.getTimestamp("hol_date");
holDateStr = sdf.format(holDate);
holType = checkNull(resultSet.getString("hol_type"));
holData.put("hol_date", holDate);
holData.put("hol_type", holType);
holData.put("no_days", checkInt(resultSet.getString("no_days")));
holData.put("hol_tblno", checkNull(resultSet.getString("hol_tblno")));
holDataAll1.put(holDateStr+"-"+holType, holData);
cnt++;
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added for rowscopy
System.out.println("holDataAll1::::"+holDataAll1);
keySet = null;
keySet = holDataAll1.keySet();
for(String key : keySet)
{
holDataAll.put(key, holDataAll1.get(key));
}
}
else
{
tempTo = new Timestamp(utilMethods.RelativeDate(effDate, -1).getTime());
sql = "SELECT hol_date, hol_type, no_days, hol_tblno FROM holiday WHERE (( hol_tblno = ? ) AND " +
"( hol_date between ? and ? ) AND (hol_type = 'W')) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNoFr);
pstmt.setTimestamp(2, frDateTm);
pstmt.setTimestamp(3, tempTo);
resultSet = pstmt.executeQuery();
while(resultSet.next()) {
holData = new HashMap();
holDate = resultSet.getTimestamp("hol_date");
holDateStr = sdf.format(holDate);
holType = checkNull(resultSet.getString("hol_type"));
holData.put("hol_date", holDate);
holData.put("hol_type", holType);
holData.put("no_days", checkInt(resultSet.getString("no_days")));
holData.put("hol_tblno", checkNull(resultSet.getString("hol_tblno")));
holDataAll1.put(holDateStr+"-"+holType, holData);
cnt++;
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added for rowscopy
System.out.println("holDataAll1::::"+holDataAll1);
keySet = null;
keySet = holDataAll1.keySet();
for(String key : keySet)
{
holDataAll.put(key, holDataAll1.get(key));
}
}
tempFr1 = effDateTm;
tempTo1 = toDateTm;
holTblNo1 = holTblNoTo;
}
else
{
tempFr1 = frDateTm;
tempTo1 = toDateTm;
holTblNo1 = holTblNoTo;
}
}
else
{
Date tempFrDate1 = new Date(tempFr1.getTime());
Date toDate = new Date(toDateTm.getTime());
Date FrDate = new Date(frDateTm.getTime());
Date effDate = new Date(effDateTm.getTime());
if(tempFrDate1.before(toDate) || tempFrDate1.equals(toDate))
{
flag = "Y";
if(effDate.after(FrDate) || effDate.equals(FrDate))
{
tempFr = tempFr1;
if(effDate.before(toDate) || effDate.equals(toDate))
{
tempTo = new Timestamp(utilMethods.RelativeDate(effDate, -1).getTime());
}
else
{
tempTo = toDateTm;
}
}
if(tempTo != null)
{
if(tempTo.after(frDateTm))
{
if(holTblNo1 == null || holTblNo1.length() == 0)
{
holTblNo1 = holTblNoFr;
}
sql = "SELECT hol_date, hol_type, no_days, hol_tblno FROM holiday WHERE (( hol_tblno = ? ) AND " +
"( hol_date between ? and ? ) AND (hol_type = 'W')) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNo1);
pstmt.setTimestamp(2, tempFr);
pstmt.setTimestamp(3, tempTo);
resultSet = pstmt.executeQuery();
while(resultSet.next()) {
holData = new HashMap();
holDate = resultSet.getTimestamp("hol_date");
holDateStr = sdf.format(holDate);
holType = checkNull(resultSet.getString("hol_type"));
holData.put("hol_date", holDate);
holData.put("hol_type", holType);
holData.put("no_days", checkInt(resultSet.getString("no_days")));
holData.put("hol_tblno", checkNull(resultSet.getString("hol_tblno")));
holDataAll1.put(holDateStr+"-"+holType, holData);
cnt++;
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added for rowscopy
System.out.println("holDataAll1::::"+holDataAll1);
keySet = null;
keySet = holDataAll1.keySet();
for(String key : keySet)
{
holDataAll.put(key, holDataAll1.get(key));
}
}
if(effDateTm.before(frDateTm))
{
tempFr1 = frDateTm;
holTblNo1 = holTblNoTo;
if(effDate.after(toDate) || effDate.equals(toDate))
{
tempTo1 = toDateTm;
}
else
{
tempTo1 = effDateTm;
}
}
else
{
tempFr1 = effDateTm;
holTblNo1 = holTblNoTo;
if(effDate.after(toDate) || effDate.equals(toDate))
{
tempTo1 = toDateTm;
break;
}
else
{
tempTo1 = effDateTm;
}
}
}
}
else
{
break;
}
}
}while(true);
Date toDate = new Date(toDateTm.getTime());
Date effDate = new Date(effDateTm.getTime());
if((effDate.after(toDate) || effDate.equals(toDate)) || flag.equalsIgnoreCase("N"))
{
if(effDateTm.after(frDateTm) && flag.equalsIgnoreCase("Y"))
{
sql = "SELECT hol_date, hol_type, no_days, hol_tblno FROM holiday WHERE (( hol_tblno = ? ) AND " +
"( hol_date between ? and ? ) AND (hol_type = 'W')) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNo1);
pstmt.setTimestamp(2, tempTo1);
pstmt.setTimestamp(3, toDateTm);
resultSet = pstmt.executeQuery();
while(resultSet.next()) {
holData = new HashMap();
holDate = resultSet.getTimestamp("hol_date");
holDateStr = sdf.format(holDate);
holType = checkNull(resultSet.getString("hol_type"));
holData.put("hol_date", holDate);
holData.put("hol_type", holType);
holData.put("no_days", checkInt(resultSet.getString("no_days")));
holData.put("hol_tblno", checkNull(resultSet.getString("hol_tblno")));
holDataAll1.put(holDateStr+"-"+holType, holData);
cnt++;
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added for rowscopy
System.out.println("holDataAll1::::"+holDataAll1);
keySet = null;
keySet = holDataAll1.keySet();
for(String key : keySet)
{
holDataAll.put(key, holDataAll1.get(key));
}
}
else
{
if(tempTo1.before(toDateTm))
{
tempTo1 = toDateTm;
}
sql = "SELECT hol_date, hol_type, no_days, hol_tblno FROM holiday WHERE (( hol_tblno = ? ) AND " +
"( hol_date between ? and ? ) AND (hol_type = 'W')) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, holTblNo1);
pstmt.setTimestamp(2, tempFr1);
pstmt.setTimestamp(3, tempTo1);
resultSet = pstmt.executeQuery();
while(resultSet.next()) {
holData = new HashMap();
holDate = resultSet.getTimestamp("hol_date");
holDateStr = sdf.format(holDate);
holType = checkNull(resultSet.getString("hol_type"));
holData.put("hol_date", holDate);
holData.put("hol_type", holType);
holData.put("no_days", checkInt(resultSet.getString("no_days")));
holData.put("hol_tblno", checkNull(resultSet.getString("hol_tblno")));
holDataAll1.put(holDateStr+"-"+holType, holData);
cnt++;
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added for rowscopy
System.out.println("holDataAll1::::"+holDataAll1);
keySet = null;
keySet = holDataAll1.keySet();
for(String key : keySet)
{
holDataAll.put(key, holDataAll1.get(key));
}
}
}
}
}
break;
}while(true);
returnMap.put("holiday", holDataAll);
returnMap.put("errorcode", errorCode);
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("returnMap in gfGetHols:: "+returnMap);
return returnMap;
}
public String checkInt(String input)
{
if (input == null || "null".equalsIgnoreCase(input))
{
input= "0";
}
return input.trim();
}
//Ended by Varsha V on 05-07-19
//Added by Varsha V on 17-07-19
public LinkedHashMap gfGetResSqlNvo(String sqlstr, String msqlinput, HashMap dwobject, String winName, ArrayList envVarStr, ArrayList envVarDate, ArrayList envVarNum, Connection conn) throws ITMException, SQLException
{
System.out.println("Calling gfGetResSqlNvo(String sqlstr, String msqlinput, HashMap dwobject, String winName, ArrayList envVarStr, ArrayList envVarDate, ArrayList envVarNum, Connection conn) of AdmCommon");
PreparedStatement pstmt = null;
ResultSet rs = null;
String[] sqlInput;
String errorCode = "";
int counter = 0;
String input = "", inputType = "";
Timestamp localTm = null;
E12GenericUtility genericUtility = new E12GenericUtility();
double outputSql = 0;
LinkedHashMap returnMap = new LinkedHashMap();
try
{
pstmt = conn.prepareStatement(sqlstr);
sqlInput = msqlinput.split(",");
if(sqlInput.length == 0)
{
errorCode = "CONFERR";
}
else
{
for(int ctr = 0; ctr < sqlInput.length; ctr++)
{
counter++;
input = sqlInput[ctr];
if(input != null && input.trim().length() > 0)
{
Object obj = dwobject.get(input);
inputType = getHashMapValType(obj);
if(inputType.contains("String"))
{
pstmt.setString(counter, obj.toString());
}
else if(inputType.contains("Double"))
{
pstmt.setDouble(counter, Double.parseDouble(checkInt(obj.toString())));
}
else if(inputType.contains("Integer"))
{
pstmt.setInt(counter, Integer.parseInt(checkInt(obj.toString())));
}
else if(inputType.contains("Timestamp") || inputType.contains("Date"))
{
localTm = Timestamp.valueOf(genericUtility.getValidDateString(obj.toString(), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())+" 00:00:00.0");
pstmt.setTimestamp(counter, localTm);
}
else
{
errorCode = "CONFIGUREERR";
}
}
}
rs = pstmt.executeQuery();
String resultType = rs.getMetaData().getColumnTypeName(1);
if(resultType.equalsIgnoreCase("NUMBER"))
{
if(rs.next())
{
outputSql = rs.getDouble(1);
}
}
else
{
errorCode = "CONFIGUREERR";
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
returnMap.put("errorcode", errorCode);
returnMap.put("value", outputSql);
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("returnMap in gfGetResSqlNvo:: "+returnMap);
return returnMap;
}
public String getHashMapValType(Object obj) throws ITMException
{
Class cls = null;
String type = "";
try
{
if(obj != null)
{
cls = obj.getClass();
type = cls.getName();
}
else
{
type = "";
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return type;
}
public LinkedHashMap gfSetEnvVarNvo(String prdCode, String className, ArrayList envVarStr, ArrayList envVarDate, ArrayList envVarNum, Connection conn) throws ITMException, SQLException
{
System.out.println("Calling gfSetEnvVarNvo(String prdCode, String className, ArrayList envVarStr, ArrayList envVarDate, ArrayList envVarNum, Connection conn) of AdmCommon");
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String varType = "", varValue = "", varSubs = "";
Timestamp localTm = null;
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
LinkedHashMap returnMap = new LinkedHashMap();
try
{
sql = "select var_value, var_type, var_subs from payrparm where prd_code = ? and var_subs > 0";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
rs = pstmt.executeQuery();
while(rs.next()){
varType = checkNull(rs.getString("var_type"));
varValue = rs.getString("var_value");
varSubs = checkNull(rs.getString("var_subs"));
if("S".equalsIgnoreCase(varType) || "C".equalsIgnoreCase(varType))
{
envVarStr.add(varValue);
}
else if("D".equalsIgnoreCase(varType))
{
if(varValue != null && varValue.trim().length() > 0)
{
localTm = new Timestamp(sdf.parse(varValue).getTime());
}
envVarDate.add(localTm);
}
else if("N".equalsIgnoreCase(varType))
{
envVarNum.add(Double.parseDouble(checkInt(varValue)));
}
}
returnMap.put("envVarStr", envVarStr);
returnMap.put("envVarDate", envVarDate);
returnMap.put("envVarNum", envVarNum);
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("returnMap in gfSetEnvVarNvo:: "+returnMap);
return returnMap;
}
//Ended by Varsha V on 17-07-19
//Added by Jaffar for interest calculation [Start]
public double gbfCalcInterest(String mintterm, double mnoDays, double mintPerc, double mbalAmt,Connection conn) throws ITMException
{
System.out.println("Calling gbfCalcInterest(String mintterm, double mnoDays, double mintPerc, double mbalAmt,Connection conn) of AdmCommon");
//Connection conn = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
String lsMethod = "";
double lcAmount = 0.0;
try
{
System.out.println("Inside gbfCalcInterest method of AdmCommon");
sql = "select cal_base from interestterm where int_term = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mintterm);
rs = pstmt.executeQuery();
if(rs.next())
{
lsMethod = checkNull(rs.getString("cal_base"));
System.out.println("sql = "+sql+" "+mintterm+" \nls_method is == "+lsMethod);
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if("R".equalsIgnoreCase(lsMethod) || "E".equalsIgnoreCase(lsMethod))
{
lcAmount = mbalAmt * ( mintPerc / 100 ) * ( mnoDays / 365 );
System.out.println("lc_amount = "+lcAmount);
}
else
{
return -1;
}
}
catch (Exception e)
{
System.out.println("Exception in InterestProcess gbf_emploan_int_proc "+ e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
System.out.println("lcAmount ======= > "+lcAmount);
return Math.round(lcAmount);
}
//Added by Jaffar for interest calculation [End]
//Added by Jaffar for sorting Map[Start]
public static Map sortMap(HashMap argMap)
{
TreeMap treeMap = new TreeMap();
treeMap.putAll(argMap);
Map retMap = new HashMap();
retMap.putAll(treeMap);
return retMap;
}
//Added by Jaffar [End]
public double gfGetRndAmt(double unrAmt, String rndOff, double rndTo) throws ITMException
{
System.out.println("Calling gfGetRndAmt(double unrAmt, String rndOff, double rndTo) of AdmCommon");
double retVal = 0;
double lcMultiply = 1;
UtilMethods utilMethods = new UtilMethods();
try
{
if(unrAmt < 0)
{
lcMultiply = -1;
unrAmt = Math.abs(unrAmt);
}
else if(unrAmt == 0)
{
return unrAmt;
}
else if("N".equalsIgnoreCase(rndOff))
{
return unrAmt;
}
else if(rndTo == 0) {
return unrAmt;
}
if("X".equalsIgnoreCase(rndOff))
{
if(utilMethods.mod(unrAmt, rndTo) > 0)
{
retVal = unrAmt - utilMethods.mod(unrAmt, rndTo) + rndTo;
}
else
{
retVal = unrAmt;
}
}
else if("P".equalsIgnoreCase(rndOff))
{
retVal = unrAmt - utilMethods.mod(unrAmt, rndTo);
}
else if("R".equalsIgnoreCase(rndOff))
{
if(utilMethods.mod(unrAmt, rndTo) < rndTo/2)
{
retVal = unrAmt - utilMethods.mod(unrAmt, rndTo);
}
else
{
retVal = unrAmt - utilMethods.mod(unrAmt, rndTo) + rndTo;
}
}
else
{
retVal = unrAmt;
}
retVal = retVal * lcMultiply;
}
catch(Exception e)
{
throw new ITMException(e);
}
System.out.println("retVal in gfGetRndAmt:: "+retVal);
return retVal;
}
public double gfGetSlabAmt(String adcode, Timestamp mdate, String slabopt, double slabamt, double baseamt, Connection conn) throws SQLException, ITMException
{
System.out.println("Calling gfGetSlabAmt(String adcode, Timestamp mdate, String slabopt, double slabamt, double baseamt, Connection conn) of AdmCommon");
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
double mminbamt = 0d;
double mmaxbamt = 0d;
double mamount = 0d;
double mminamt = 0d;
double mmaxamt = 0d;
String type = "";
double retval = 0;
double applyamt = 0d;
try
{
sql = "select min_base_amt, max_base_amt,amount,type,min_amt,max_amt from ad_slabs where ad_code = ? and eff_date <= ? " +
"and exp_date >= ? order by slab_no";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, adcode);
pstmt.setTimestamp(2, mdate);
pstmt.setTimestamp(3, mdate);
rs = pstmt.executeQuery();
while(rs.next())
{
mminbamt = rs.getDouble("min_base_amt");
mmaxbamt = rs.getDouble("max_base_amt");
mamount = rs.getDouble("amount");
type = rs.getString("type");
mminamt = rs.getDouble("min_amt");
mmaxamt = rs.getDouble("max_amt");
applyamt = baseamt;
do {
if(slabopt.equalsIgnoreCase("D"))
{
if(slabamt >= mminbamt && slabamt <= mmaxbamt)
{
if("P".equalsIgnoreCase(type))
{
retval = applyamt * mamount / 100;
}
else
{
retval = mamount;
}
if(mminamt > 0 && retval < mminamt)
retval = mminamt;
if(mmaxamt > 0 && retval > mmaxamt)
retval = mmaxamt;
break;
}
}
else
{
if(mmaxbamt <= slabamt)
{
if("P".equalsIgnoreCase(type))
{
retval = retval + ((mmaxbamt - mminbamt+1) * mamount / 100);
}
else
{
retval = retval + mamount;
}
applyamt = applyamt - (mmaxbamt - mminbamt + 1);
}
else if(mminbamt <= slabamt)
{
if("P".equalsIgnoreCase(type))
{
retval = retval + (applyamt * mamount / 100);
}
else
{
retval = retval + mamount;
}
break;
}
else
{
break;
}
}
}while(true);
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("retval in gfGetSlabAmt:: "+retval);
return retval;
}
} }
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