Commit edbb5168 authored by arawankar's avatar arawankar

FinCommon.java

-Locking implemented in fincommon ,as suggested by Manoharan sir.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@194445 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d45aea93
...@@ -53,9 +53,20 @@ public class FinCommon ...@@ -53,9 +53,20 @@ public class FinCommon
double advAmount = 0.0; double advAmount = 0.0;
double crAmtBase = 0.0; double crAmtBase = 0.0;
double drAmtBase = 0.0; double drAmtBase = 0.0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try try
{ {
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
//Modified by Anjali R. on [11/12/2018][To take database name][End]
System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString()); System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString());
stmt = conn.createStatement(); stmt = conn.createStatement();
java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString())); java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString()));
...@@ -207,6 +218,62 @@ public class FinCommon ...@@ -207,6 +218,62 @@ public class FinCommon
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? "
+ "AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL (updlock) WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ?"
+ " AND CCTR_CODE = ?"
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
pstmt.setString(3, finEntity);
pstmt.setString(4, siteCode);
pstmt.setString(5, sundryType);
pstmt.setString(6, sundryCode);
pstmt.setString(7,acctCode );
pstmt.setString(8, cctrCode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
errCode = "VTLCKERR";
return (errCode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), " sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? ))," + "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
...@@ -339,6 +406,61 @@ public class FinCommon ...@@ -339,6 +406,61 @@ public class FinCommon
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? "
+ "AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL (updlock) WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? "
+ "AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ?"
+ " AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ?"
+ " AND CCTR_CODE = ?"
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, closePrd);
pstmt.setString(3, finEntity);
pstmt.setString(4, siteCode);
pstmt.setString(5, sundryType);
pstmt.setString(6, sundryCode);
pstmt.setString(7,acctCode );
pstmt.setString(8, cctrCode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
errCode = "VTLCKERR";
return (errCode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), " sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? ))," + "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
...@@ -436,9 +558,25 @@ public class FinCommon ...@@ -436,9 +558,25 @@ public class FinCommon
double lc_cramt_b = 0; double lc_cramt_b = 0;
double lc_dramt_b = 0; double lc_dramt_b = 0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
ITMDBAccessEJB itmDbAccess = null;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try try
{ {
System.out.println("Inside acctbalOpnUpd...."+acctbalMap.toString()); System.out.println("Inside acctbalOpnUpd...."+acctbalMap.toString());
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
itmDbAccess = new ITMDBAccessEJB();
//Modified by Anjali R. on [11/12/2018][To take database name][End]
stmt = conn.createStatement(); stmt = conn.createStatement();
String acctVar_contactcode = (String)acctbalMap.get("contact_code"); String acctVar_contactcode = (String)acctbalMap.get("contact_code");
String acctVar_finentity = (String)acctbalMap.get("fin_entity"); String acctVar_finentity = (String)acctbalMap.get("fin_entity");
...@@ -450,14 +588,14 @@ public class FinCommon ...@@ -450,14 +588,14 @@ public class FinCommon
String userId = (String)acctbalMap.get("user_id"); String userId = (String)acctbalMap.get("user_id");
String acctPrd = (String)acctbalMap.get("acct_prd"); String acctPrd = (String)acctbalMap.get("acct_prd");
String chgTerm = (String)acctbalMap.get("chg_term"); //Added by poonam on 28-07-16 for chg_term from map String chgTerm = (String)acctbalMap.get("chg_term"); //Added by poonam on 28-07-16 for chg_term from map
System.out.println("chgTerm in sundrybalOpnUpd"+chgTerm); System.out.println("chgTerm in sundrybalOpnUpd"+chgTerm);
if(chgTerm == null || chgTerm.trim().length() == 0) if(chgTerm == null || chgTerm.trim().length() == 0)
{ {
chgTerm = "SYSTEM" ; chgTerm = "SYSTEM" ;
} }
if (acctVar_cctrcode == null) if (acctVar_cctrcode == null)
{ {
acctVar_cctrcode = " "; acctVar_cctrcode = " ";
...@@ -494,8 +632,8 @@ public class FinCommon ...@@ -494,8 +632,8 @@ public class FinCommon
{ {
// check for current period // check for current period
sql ="SELECT COUNT(1) FROM ACCTBAL WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE ='"+prdCode+"' AND "+ sql ="SELECT COUNT(1) FROM ACCTBAL WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE ='"+prdCode+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"' AND SITE_CODE ='"+acctVar_sitecode+"' AND ACCT_CODE = '"+acctVar_acctcode+"' "+ "FIN_ENTITY = '"+acctVar_finentity+"' AND SITE_CODE ='"+acctVar_sitecode+"' AND ACCT_CODE = '"+acctVar_acctcode+"' "+
"AND CCTR_CODE ='"+acctVar_cctrcode+"'"; "AND CCTR_CODE ='"+acctVar_cctrcode+"'";
stmt = conn.createStatement(); stmt = conn.createStatement();
rs = stmt.executeQuery(sql); rs = stmt.executeQuery(sql);
if (rs.next()) if (rs.next())
...@@ -504,7 +642,7 @@ public class FinCommon ...@@ -504,7 +642,7 @@ public class FinCommon
} }
rs.close(); rs = null; rs.close(); rs = null;
stmt.close(); stmt = null; stmt.close(); stmt = null;
System.out.println("For Period 000000 ll_cnt : " + ll_cnt); System.out.println("For Period 000000 ll_cnt : " + ll_cnt);
}//try }//try
catch(SQLException se) catch(SQLException se)
...@@ -514,7 +652,7 @@ public class FinCommon ...@@ -514,7 +652,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//retString = se.getMessage(); //retString = se.getMessage();
retString = getErrorMessage(se, ""); retString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return retString; return retString;
} }
if (ll_cnt == 0 ) if (ll_cnt == 0 )
...@@ -523,9 +661,9 @@ public class FinCommon ...@@ -523,9 +661,9 @@ public class FinCommon
{ {
// add record for current period // add record for current period
sql="INSERT INTO ACCTBAL (ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE,"+ sql="INSERT INTO ACCTBAL (ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE,"+
"ACCT_CODE, CCTR_CODE, CURR_CODE__AC, DR_AMT, CR_AMT,"+ "ACCT_CODE, CCTR_CODE, CURR_CODE__AC, DR_AMT, CR_AMT,"+
"DR_AMT__BASE, CR_AMT__BASE, CHG_DATE, CHG_USER, CHG_TERM) "+ "DR_AMT__BASE, CR_AMT__BASE, CHG_DATE, CHG_USER, CHG_TERM) "+
"VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )"; "VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acctPrd); pstmt.setString(1,acctPrd);
pstmt.setString(2,prdCode); pstmt.setString(2,prdCode);
...@@ -551,11 +689,11 @@ public class FinCommon ...@@ -551,11 +689,11 @@ public class FinCommon
{ {
System.out.println("SQLException []:acctbalOpnUpd()[Excuting Query Failed]" + sql +se.getMessage()); System.out.println("SQLException []:acctbalOpnUpd()[Excuting Query Failed]" + sql +se.getMessage());
se.printStackTrace(); se.printStackTrace();
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//retString = se.getMessage(); //retString = se.getMessage();
retString = getErrorMessage(se, ""); retString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return retString; return retString;
} }
} }
...@@ -563,11 +701,61 @@ public class FinCommon ...@@ -563,11 +701,61 @@ public class FinCommon
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, prdCode);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
retString = itmDbAccess.getErrorString("", "VTLCKERR", userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+ sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+
"WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+prdCode+"' AND "+ "WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+prdCode+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"' AND SITE_CODE = '"+acctVar_sitecode+"' AND "+ "FIN_ENTITY = '"+acctVar_finentity+"' AND SITE_CODE = '"+acctVar_sitecode+"' AND "+
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'"; "ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,acctVar_dramt); pstmt.setDouble(1,acctVar_dramt);
pstmt.setDouble(2,acctVar_cramt); pstmt.setDouble(2,acctVar_cramt);
...@@ -588,7 +776,7 @@ public class FinCommon ...@@ -588,7 +776,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//retString = se.getMessage(); //retString = se.getMessage();
retString = getErrorMessage(se, ""); retString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return retString; return retString;
} }
} }
...@@ -598,7 +786,7 @@ public class FinCommon ...@@ -598,7 +786,7 @@ public class FinCommon
{ {
// check for closing balance // check for closing balance
sql="SELECT COUNT(1) FROM ACCTBAL WHERE ACCT_PRD = '"+acctPrd+"'AND PRD_CODE ='"+closePrd+"' AND "+ sql="SELECT COUNT(1) FROM ACCTBAL WHERE ACCT_PRD = '"+acctPrd+"'AND PRD_CODE ='"+closePrd+"' AND "+
" FIN_ENTITY ='"+acctVar_finentity+"' AND SITE_CODE = '"+acctVar_sitecode+"' AND ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'"; " FIN_ENTITY ='"+acctVar_finentity+"' AND SITE_CODE = '"+acctVar_sitecode+"' AND ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
System.out.println("Closing count sql [" + sql + "]"); System.out.println("Closing count sql [" + sql + "]");
System.out.println("Closing acctPrd [" + acctPrd + "]"); System.out.println("Closing acctPrd [" + acctPrd + "]");
...@@ -615,7 +803,7 @@ public class FinCommon ...@@ -615,7 +803,7 @@ public class FinCommon
} }
rs.close(); rs = null; rs.close(); rs = null;
stmt.close(); stmt = null; stmt.close(); stmt = null;
System.out.println("For Period zzzzzz ll_cnt : " + ll_cnt); System.out.println("For Period zzzzzz ll_cnt : " + ll_cnt);
} }
}//try }//try
...@@ -627,15 +815,15 @@ public class FinCommon ...@@ -627,15 +815,15 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//retString = se.getMessage(); //retString = se.getMessage();
retString = getErrorMessage(se, ""); retString = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return retString; return retString;
} }
if(ll_cnt == 0) if(ll_cnt == 0)
{ {
// insert a record for closing balance // insert a record for closing balance
sql="INSERT INTO ACCTBAL (ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE,ACCT_CODE, CCTR_CODE, CURR_CODE__AC, DR_AMT, CR_AMT,"+ sql="INSERT INTO ACCTBAL (ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE,ACCT_CODE, CCTR_CODE, CURR_CODE__AC, DR_AMT, CR_AMT,"+
" DR_AMT__BASE, CR_AMT__BASE, CHG_DATE, CHG_USER, CHG_TERM)"+ " DR_AMT__BASE, CR_AMT__BASE, CHG_DATE, CHG_USER, CHG_TERM)"+
" VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )"; " VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acctPrd); pstmt.setString(1,acctPrd);
pstmt.setString(2,closePrd); pstmt.setString(2,closePrd);
...@@ -656,19 +844,70 @@ public class FinCommon ...@@ -656,19 +844,70 @@ public class FinCommon
int cnt = pstmt.executeUpdate(); int cnt = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("INSERTED IN ACCTBAL FOR CLOSING BALANCE : " + cnt); System.out.println("INSERTED IN ACCTBAL FOR CLOSING BALANCE : " + cnt);
if(cnt<1) if(cnt<1)
{ {
ls_errcode = "DS000"; ls_errcode = "DS000";
break; break;
} }
} }
else else
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select DR_AMT,CR_AMT,DR_AMT__BASE,CR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctPrd);
pstmt.setString(2, closePrd);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
System.out.println("sql--["+sql+"]");
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
retString = itmDbAccess.getErrorString("", "VTLCKERR", userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update closing in acctbal // update closing in acctbal
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+ sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )), CHG_DATE = ?, CHG_USER = ?, CHG_TERM = ? "+
"WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+closePrd+"' AND "+ "WHERE ACCT_PRD = '"+acctPrd+"' AND PRD_CODE = '"+closePrd+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"'AND SITE_CODE ='"+acctVar_sitecode+"'AND "+ "FIN_ENTITY = '"+acctVar_finentity+"'AND SITE_CODE ='"+acctVar_sitecode+"'AND "+
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'"; "ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,acctVar_dramt); pstmt.setDouble(1,acctVar_dramt);
...@@ -681,8 +920,8 @@ public class FinCommon ...@@ -681,8 +920,8 @@ public class FinCommon
pstmt.setString(7,chgTerm); //Changed by poonam on 28-07-16 for chg_term from map pstmt.setString(7,chgTerm); //Changed by poonam on 28-07-16 for chg_term from map
int cnt = pstmt.executeUpdate(); int cnt = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA pstmt.close(); pstmt = null; // ADDED BY ALKA
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt); System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt);
if(cnt<1) if(cnt<1)
{ {
ls_errcode = "DS000"; ls_errcode = "DS000";
break; break;
...@@ -702,7 +941,7 @@ public class FinCommon ...@@ -702,7 +941,7 @@ public class FinCommon
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
} }
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return retString; return retString;
} }
catch(Exception e) catch(Exception e)
...@@ -718,7 +957,7 @@ public class FinCommon ...@@ -718,7 +957,7 @@ public class FinCommon
try try
{ {
acctbalMap.clear(); acctbalMap.clear();
// ADDED BY ALKA // ADDED BY ALKA
if (rs != null) if (rs != null)
{ {
rs.close(); rs = null; rs.close(); rs = null;
...@@ -727,7 +966,7 @@ public class FinCommon ...@@ -727,7 +966,7 @@ public class FinCommon
{ {
pstmt.close(); pstmt = null; pstmt.close(); pstmt = null;
} }
// END ADDED BY ALKA // END ADDED BY ALKA
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -737,7 +976,7 @@ public class FinCommon ...@@ -737,7 +976,7 @@ public class FinCommon
return retString; return retString;
} }
} }
return retString; return retString;
}//acctbalOpnUpd() }//acctbalOpnUpd()
/** /**
...@@ -775,8 +1014,21 @@ public class FinCommon ...@@ -775,8 +1014,21 @@ public class FinCommon
double lc_cramt_b = 0.0; double lc_cramt_b = 0.0;
double lc_dramt_b = 0.0; double lc_dramt_b = 0.0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try try
{ {
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
//Modified by Anjali R. on [11/12/2018][To take database name][End]
System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString()); System.out.println("In SUNDRY-BAL !!!!!!!!!!!!!!!!!!!!!!!!!!"+sundrybalMap.toString());
stmt = conn.createStatement(); stmt = conn.createStatement();
java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString())); java.sql.Timestamp ld_postdate = java.sql.Timestamp.valueOf((sundrybalMap.get("tran_date").toString()));
...@@ -802,7 +1054,7 @@ public class FinCommon ...@@ -802,7 +1054,7 @@ public class FinCommon
if(ls_cctr_upd.trim().equals("NULLFOUND")) if(ls_cctr_upd.trim().equals("NULLFOUND"))
{ {
ls_errcode = "VSENVAR1"; ls_errcode = "VSENVAR1";
return (ls_errcode); return (ls_errcode);
} }
else if((!ls_cctr_upd.trim().equalsIgnoreCase("Y")) && (!ls_cctr_upd.trim().equalsIgnoreCase("N"))) else if((!ls_cctr_upd.trim().equalsIgnoreCase("Y")) && (!ls_cctr_upd.trim().equalsIgnoreCase("N")))
{ {
...@@ -848,7 +1100,7 @@ public class FinCommon ...@@ -848,7 +1100,7 @@ public class FinCommon
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(!rs.next()) if(!rs.next())
{ ls_errcode = "VMDATANF"; { ls_errcode = "VMDATANF";
break; break;
} }
else else
{ {
...@@ -866,7 +1118,7 @@ public class FinCommon ...@@ -866,7 +1118,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage(); //ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, ""); ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ; return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End //Added by poonam on 28-07-16 for exception handling:End
} }
...@@ -874,9 +1126,9 @@ public class FinCommon ...@@ -874,9 +1126,9 @@ public class FinCommon
{ {
// look for opening balance record // look for opening balance record
sql = "SELECT COUNT(1) FROM SUNDRYBAL " sql = "SELECT COUNT(1) FROM SUNDRYBAL "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_openprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' " + "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_openprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' " + "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'"; + "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
rs = stmt.executeQuery(sql); rs = stmt.executeQuery(sql);
if (rs.next()) if (rs.next())
...@@ -891,9 +1143,9 @@ public class FinCommon ...@@ -891,9 +1143,9 @@ public class FinCommon
{ {
// add record for opening balance // add record for opening balance
sqlnstr = "INSERT INTO SUNDRYBAL ( ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE, SUNDRY_TYPE, " sqlnstr = "INSERT INTO SUNDRYBAL ( ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE, SUNDRY_TYPE, "
+ "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, " + "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, "
+ "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) " + "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )"; + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sqlnstr); pstmt = conn.prepareStatement(sqlnstr);
pstmt.setString(1,ls_acctprd); pstmt.setString(1,ls_acctprd);
...@@ -920,10 +1172,10 @@ public class FinCommon ...@@ -920,10 +1172,10 @@ public class FinCommon
count = pstmt.executeUpdate(); count = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA pstmt.close(); pstmt = null; // ADDED BY ALKA
if(count<1) if(count<1)
{ {
ls_errcode = "DS000"; ls_errcode = "DS000";
break; break;
} }
System.out.println("NO. OF RECORDS INSERTED FOR OPENING PERIODE.. "+count); System.out.println("NO. OF RECORDS INSERTED FOR OPENING PERIODE.. "+count);
}//try }//try
catch(SQLException se) catch(SQLException se)
...@@ -934,7 +1186,7 @@ public class FinCommon ...@@ -934,7 +1186,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage(); //ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, ""); ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
System.out.println("ls_errcode11 28-07-16"+ls_errcode); System.out.println("ls_errcode11 28-07-16"+ls_errcode);
return ls_errcode ; return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End //Added by poonam on 28-07-16 for exception handling:End
...@@ -949,7 +1201,7 @@ public class FinCommon ...@@ -949,7 +1201,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage(); //ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, ""); ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
System.out.println("ls_errcode12 28-07-16"+ls_errcode); System.out.println("ls_errcode12 28-07-16"+ls_errcode);
return ls_errcode ; return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End //Added by poonam on 28-07-16 for exception handling:End
...@@ -959,9 +1211,9 @@ public class FinCommon ...@@ -959,9 +1211,9 @@ public class FinCommon
{ {
// check for current period // check for current period
sql = "SELECT COUNT(1) FROM SUNDRYBAL " sql = "SELECT COUNT(1) FROM SUNDRYBAL "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_prdcode +"' AND FIN_ENTITY = '"+ ls_finentity +"' " + "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_prdcode +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' " + "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'"; + "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
stmt = conn.createStatement(); // Added as stmt is closed and asigned null above - Piyush - 26/03/08 stmt = conn.createStatement(); // Added as stmt is closed and asigned null above - Piyush - 26/03/08
rs = stmt.executeQuery(sql); rs = stmt.executeQuery(sql);
...@@ -980,7 +1232,7 @@ public class FinCommon ...@@ -980,7 +1232,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage(); //ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, ""); ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ; return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End //Added by poonam on 28-07-16 for exception handling:End
} }
...@@ -990,11 +1242,11 @@ public class FinCommon ...@@ -990,11 +1242,11 @@ public class FinCommon
{ {
// add record for current period // add record for current period
sqlnstr = "INSERT INTO SUNDRYBAL ( ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE, SUNDRY_TYPE, " sqlnstr = "INSERT INTO SUNDRYBAL ( ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE, SUNDRY_TYPE, "
+ "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, " + "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, "
+ "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) " + "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )"; + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sqlnstr); pstmt = conn.prepareStatement(sqlnstr);
pstmt.setString(1,ls_acctprd); pstmt.setString(1,ls_acctprd);
pstmt.setString(2,ls_prdcode); pstmt.setString(2,ls_prdcode);
pstmt.setString(3,ls_finentity); pstmt.setString(3,ls_finentity);
...@@ -1019,10 +1271,10 @@ public class FinCommon ...@@ -1019,10 +1271,10 @@ public class FinCommon
count = pstmt.executeUpdate(); count = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA pstmt.close(); pstmt = null; // ADDED BY ALKA
if(count<1) if(count<1)
{ {
ls_errcode = "DS000"; ls_errcode = "DS000";
break; break;
} }
System.out.println("NO. OF RECORDS INSERTED FOR CURRENT PERIODE.. "+count); System.out.println("NO. OF RECORDS INSERTED FOR CURRENT PERIODE.. "+count);
}//try }//try
catch(SQLException se) catch(SQLException se)
...@@ -1033,7 +1285,7 @@ public class FinCommon ...@@ -1033,7 +1285,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage(); //ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, ""); ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ; return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End //Added by poonam on 28-07-16 for exception handling:End
} }
...@@ -1042,13 +1294,61 @@ public class FinCommon ...@@ -1042,13 +1294,61 @@ public class FinCommon
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL (updlock)WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_prdcode);
pstmt.setString(3, ls_finentity);
pstmt.setString(4, ls_sitecode);
pstmt.setString(5, ls_sundrytype);
pstmt.setString(6, ls_sundrycode);
pstmt.setString(7, ls_acctcode);
pstmt.setString(8, ls_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
return (ls_errcode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), " sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? ))," + "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
+ "ADV_AMT = (ADV_AMT + ( ? )),CHG_DATE = ? ,CHG_USER = ? ,CHG_TERM = ? " + "ADV_AMT = (ADV_AMT + ( ? )),CHG_DATE = ? ,CHG_USER = ? ,CHG_TERM = ? "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_prdcode +"' AND FIN_ENTITY = '"+ ls_finentity +"' " + "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_prdcode +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' " + "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'"; + "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
pstmt = conn.prepareStatement(sqlUpd); pstmt = conn.prepareStatement(sqlUpd);
pstmt.setDouble(1,lc_cramt); pstmt.setDouble(1,lc_cramt);
...@@ -1064,10 +1364,10 @@ public class FinCommon ...@@ -1064,10 +1364,10 @@ public class FinCommon
count = pstmt.executeUpdate(); count = pstmt.executeUpdate();
pstmt.close(); pstmt = null; // ADDED BY ALKA pstmt.close(); pstmt = null; // ADDED BY ALKA
if(count<1) if(count<1)
{ {
ls_errcode = "DS000"; ls_errcode = "DS000";
break; break;
} }
System.out.println("NO. OF RECORDS UPDATED FOR CURRENT PERIODE... "+count); System.out.println("NO. OF RECORDS UPDATED FOR CURRENT PERIODE... "+count);
}//try }//try
catch(SQLException se) catch(SQLException se)
...@@ -1078,7 +1378,7 @@ public class FinCommon ...@@ -1078,7 +1378,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage(); //ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, ""); ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ; return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End //Added by poonam on 28-07-16 for exception handling:End
} }
...@@ -1087,9 +1387,9 @@ public class FinCommon ...@@ -1087,9 +1387,9 @@ public class FinCommon
{ {
// check for closing balance // check for closing balance
sql = "SELECT COUNT(1) FROM SUNDRYBAL " sql = "SELECT COUNT(1) FROM SUNDRYBAL "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_closeprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' " + "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_closeprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' " + "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'"; + "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
stmt = conn.createStatement(); // Added as stmt is closed and asigned null above - Piyush - 26/03/08 stmt = conn.createStatement(); // Added as stmt is closed and asigned null above - Piyush - 26/03/08
rs = stmt.executeQuery(sql); rs = stmt.executeQuery(sql);
...@@ -1108,7 +1408,7 @@ public class FinCommon ...@@ -1108,7 +1408,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage(); //ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, ""); ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ; return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End //Added by poonam on 28-07-16 for exception handling:End
} }
...@@ -1118,11 +1418,11 @@ public class FinCommon ...@@ -1118,11 +1418,11 @@ public class FinCommon
{ {
// add record for closing period // add record for closing period
sqlnstr = "INSERT INTO SUNDRYBAL ( ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE, SUNDRY_TYPE, " sqlnstr = "INSERT INTO SUNDRYBAL ( ACCT_PRD, PRD_CODE, FIN_ENTITY, SITE_CODE, SUNDRY_TYPE, "
+ "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, " + "SUNDRY_CODE, ACCT_CODE, CCTR_CODE, CR_AMT, DR_AMT, CURR_CODE__AC, CR_AMT__BASE, "
+ "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) " + "DR_AMT__BASE, ADV_AMT, CONTACT_CODE, CHG_DATE, CHG_USER, CHG_TERM ) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )"; + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
pstmt = conn.prepareStatement(sqlnstr); pstmt = conn.prepareStatement(sqlnstr);
pstmt.setString(1,ls_acctprd); pstmt.setString(1,ls_acctprd);
pstmt.setString(2,ls_closeprd); pstmt.setString(2,ls_closeprd);
pstmt.setString(3,ls_finentity); pstmt.setString(3,ls_finentity);
...@@ -1146,11 +1446,11 @@ public class FinCommon ...@@ -1146,11 +1446,11 @@ public class FinCommon
count = pstmt.executeUpdate(); count = pstmt.executeUpdate();
if(count<1) if(count<1)
{ {
ls_errcode = "DS000"; ls_errcode = "DS000";
break; break;
} }
//Added by Varsha V for closing resultset on 19-04-2018 //Added by Varsha V for closing resultset on 19-04-2018
if(pstmt !=null) if(pstmt !=null)
{ {
pstmt.close(); pstmt.close();
...@@ -1166,22 +1466,71 @@ public class FinCommon ...@@ -1166,22 +1466,71 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage(); //ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, ""); ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ; return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End //Added by poonam on 28-07-16 for exception handling:End
} }
}//if }//if
else else
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL (updlock)WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from SUNDRYBAL WHERE ACCT_PRD = ? AND PRD_CODE = ? AND FIN_ENTITY = ? AND SITE_CODE = ? AND SUNDRY_TYPE = ? AND SUNDRY_CODE = ? AND ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_closeprd);
pstmt.setString(3, ls_finentity);
pstmt.setString(4, ls_sitecode);
pstmt.setString(5, ls_sundrytype);
pstmt.setString(6, ls_sundrycode);
pstmt.setString(7, ls_acctcode);
pstmt.setString(8, ls_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
return (ls_errcode);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), " sqlUpd = "UPDATE SUNDRYBAL SET CR_AMT = (CR_AMT + ( ? )), DR_AMT = (DR_AMT + ( ? )), "
+ "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? ))," + "CR_AMT__BASE = (CR_AMT__BASE + ( ? )),DR_AMT__BASE = (DR_AMT__BASE + ( ? )),"
+ "ADV_AMT = (ADV_AMT + ( ? )),CHG_DATE = ? ,CHG_USER = ? ,CHG_TERM = ? " + "ADV_AMT = (ADV_AMT + ( ? )),CHG_DATE = ? ,CHG_USER = ? ,CHG_TERM = ? "
+ "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_closeprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' " + "WHERE ACCT_PRD = '"+ ls_acctprd +"' AND PRD_CODE = '"+ ls_closeprd +"' AND FIN_ENTITY = '"+ ls_finentity +"' "
+ "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' " + "AND SITE_CODE = '"+ ls_sitecode +"' AND SUNDRY_TYPE = '"+ ls_sundrytype +"' AND SUNDRY_CODE = '"+ ls_sundrycode +"' "
+ "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'"; + "AND ACCT_CODE = '"+ ls_acctcode +"' AND CCTR_CODE = '"+ ls_cctrcode +"'";
pstmt = conn.prepareStatement(sqlUpd); pstmt = conn.prepareStatement(sqlUpd);
pstmt.setDouble(1,lc_cramt); pstmt.setDouble(1,lc_cramt);
...@@ -1196,11 +1545,11 @@ public class FinCommon ...@@ -1196,11 +1545,11 @@ public class FinCommon
pstmt.setString(8,chgTerm);//Added by poonam on 28-07-16 for chg_term from map pstmt.setString(8,chgTerm);//Added by poonam on 28-07-16 for chg_term from map
count = pstmt.executeUpdate(); count = pstmt.executeUpdate();
if(count<1) if(count<1)
{ {
ls_errcode = "DS000"; ls_errcode = "DS000";
break; break;
} }
//Added by Varsha V for closing resultset on 19-04-2018 //Added by Varsha V for closing resultset on 19-04-2018
if(pstmt !=null) if(pstmt !=null)
{ {
pstmt.close(); pstmt.close();
...@@ -1216,7 +1565,7 @@ public class FinCommon ...@@ -1216,7 +1565,7 @@ public class FinCommon
//Modified by Varsha V to change msg descr on 30-04-18 //Modified by Varsha V to change msg descr on 30-04-18
//ls_errcode = se.getMessage(); //ls_errcode = se.getMessage();
ls_errcode = getErrorMessage(se, ""); ls_errcode = getErrorMessage(se, "");
//Ended by Varsha V to change msg descr on 30-04-18 //Ended by Varsha V to change msg descr on 30-04-18
return ls_errcode ; return ls_errcode ;
//Added by poonam on 28-07-16 for exception handling:End //Added by poonam on 28-07-16 for exception handling:End
} }
...@@ -1287,9 +1636,23 @@ public class FinCommon ...@@ -1287,9 +1636,23 @@ public class FinCommon
double ll_cnt = 0; double ll_cnt = 0;
double lc_cramt_b = 0; double lc_cramt_b = 0;
double lc_dramt_b = 0; double lc_dramt_b = 0;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
String dbName = "";
double drAmtt = 0.0;
double crAmtt = 0.0 ;
double drAmtBaset = 0.0;
double crAmtBaseT = 0.0 ;
ITMDBAccessEJB itmdbAccess = null;
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
try try
{ {
//Modified by Anjali R. on [11/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName--["+dbName+"]");
itmdbAccess = new ITMDBAccessEJB();
//Modified by Anjali R. on [11/12/2018][To take database name][End]
System.out.println("Inside acctbalMap......"+acctbalMap.toString()); System.out.println("Inside acctbalMap......"+acctbalMap.toString());
stmt = conn.createStatement(); stmt = conn.createStatement();
String acctVar_contactcode = (String)acctbalMap.get("contact_code"); String acctVar_contactcode = (String)acctbalMap.get("contact_code");
...@@ -1506,8 +1869,59 @@ public class FinCommon ...@@ -1506,8 +1869,59 @@ public class FinCommon
} }
else else
{ {
try try
{ {
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? ";
}
else
{
sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
+ "and ACCT_CODE = ? AND CCTR_CODE = ? "
+ "for update nowait";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_acctprd);
pstmt.setString(2, ls_prdcode);
pstmt.setString(3, acctVar_finentity);
pstmt.setString(4, acctVar_sitecode);
pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
retString = itmdbAccess.getErrorString("", ls_errcode, userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update existing record ( also update advance ) // update existing record ( also update advance )
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+ sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+
"WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_prdcode+"' AND "+ "WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_prdcode+"' AND "+
...@@ -1617,29 +2031,79 @@ public class FinCommon ...@@ -1617,29 +2031,79 @@ public class FinCommon
else else
{ {
try{ //poonam try{ //poonam
// update closing in acctbal //Modified by Anjali R. on [11/12/2018][Locking to be implemented][Start]
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+ if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
"WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_closeprd+"' AND "+ {
"FIN_ENTITY = '"+acctVar_finentity+"'AND SITE_CODE ='"+acctVar_sitecode+"'AND "+ sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'"; + "and ACCT_CODE = ? AND CCTR_CODE = ? for update";
pstmt = conn.prepareStatement(sql); }
pstmt.setDouble(1,acctVar_dramt); else if("mssql".equalsIgnoreCase(dbName))
pstmt.setDouble(2,acctVar_cramt); {
pstmt.setDouble(3,lc_dramt_base); sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL (updlock) where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
pstmt.setDouble(4,lc_cramt_base); + "and ACCT_CODE = ? AND CCTR_CODE = ? ";
int cnt = pstmt.executeUpdate(); }
//Added by Varsha V for closing resultset on 19-04-2018 else
if(pstmt !=null) {
{ sql = "select CR_AMT,DR_AMT,CR_AMT__BASE,DR_AMT__BASE from ACCTBAL where ACCT_PRD = ? and PRD_CODE = ? and FIN_ENTITY = ? AND SITE_CODE = ?"
pstmt.close(); + "and ACCT_CODE = ? AND CCTR_CODE = ? "
pstmt = null; + "for update nowait";
} }
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt); pstmt = conn.prepareStatement(sql);
if(cnt<1) pstmt.setString(1, ls_acctprd);
{ pstmt.setString(2, ls_closeprd);
ls_errcode = "DS000"; pstmt.setString(3, acctVar_finentity);
break; pstmt.setString(4, acctVar_sitecode);
} pstmt.setString(5, acctVar_acctcode);
pstmt.setString(6, acctVar_cctrcode);
rs = pstmt.executeQuery();
if(rs.next())
{
drAmtt = rs.getDouble("DR_AMT");
crAmtt = rs.getDouble("CR_AMT");
drAmtBaset = rs.getDouble("DR_AMT__BASE");
crAmtBaseT = rs.getDouble("CR_AMT__BASE");
}
else
{
ls_errcode = "VTLCKERR";
retString = itmdbAccess.getErrorString("", ls_errcode, userId,"",conn);
return (retString);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [11/12/2018][Locking to be implemented][End]
// update closing in acctbal
sql="UPDATE ACCTBAL SET DR_AMT = (DR_AMT + ( ? )), CR_AMT = (CR_AMT + ( ? )), DR_AMT__BASE = (DR_AMT__BASE + ( ? )), CR_AMT__BASE = (CR_AMT__BASE + ( ? )) "+
"WHERE ACCT_PRD = '"+ls_acctprd+"' AND PRD_CODE = '"+ls_closeprd+"' AND "+
"FIN_ENTITY = '"+acctVar_finentity+"'AND SITE_CODE ='"+acctVar_sitecode+"'AND "+
"ACCT_CODE = '"+acctVar_acctcode+"' AND CCTR_CODE = '"+acctVar_cctrcode+"'";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,acctVar_dramt);
pstmt.setDouble(2,acctVar_cramt);
pstmt.setDouble(3,lc_dramt_base);
pstmt.setDouble(4,lc_cramt_base);
int cnt = pstmt.executeUpdate();
//Added by Varsha V for closing resultset on 19-04-2018
if(pstmt !=null)
{
pstmt.close();
pstmt = null;
}
System.out.println("NO. OF RECORDS UPDATED IN ACCTBAL...(CLOSING)" + cnt);
if(cnt<1)
{
ls_errcode = "DS000";
break;
}
} }
catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start catch(SQLException se)//Added by poonam on 28-07-16 for exception handling:Start
{ {
...@@ -2054,8 +2518,8 @@ public class FinCommon ...@@ -2054,8 +2518,8 @@ public class FinCommon
if(!"NULLFOUND".equalsIgnoreCase(var_value)) if(!"NULLFOUND".equalsIgnoreCase(var_value))
{ {
//Modified by Anjali R. on[21/09/2018][End] //Modified by Anjali R. on[21/09/2018][End]
if(var_value.equals("Y")) if(var_value.equals("Y"))
{ {
sql ="SELECT STD_EXRT FROM CURRENCY WHERE CURR_CODE = '"+as_curr_code.trim()+"'"; sql ="SELECT STD_EXRT FROM CURRENCY WHERE CURR_CODE = '"+as_curr_code.trim()+"'";
...@@ -2065,7 +2529,7 @@ public class FinCommon ...@@ -2065,7 +2529,7 @@ public class FinCommon
{ {
lc_exch_rate = rs1.getDouble(1); lc_exch_rate = rs1.getDouble(1);
} }
// stmt.close(); stmt = null; // stmt.close(); stmt = null;
rs1.close(); rs1 = null; rs1.close(); rs1 = null;
} }
else else
......
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