Commit 8fb7ec0a authored by ssalve's avatar ssalve

Sarita: Done changes to validate already allocated data on 16 JAN 2018

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195857 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0f46ed6a
...@@ -250,9 +250,21 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -250,9 +250,21 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
}*/ }*/
} }
} }
System.out.println("Site Code is ==="+siteCode +"----- AND -----"+"Period Code is ===="+prdCode); System.out.println("Site Code is ==="+siteCode +"----- AND -----"+"Period Code is ===="+prdCode);
sql = "select count(*) as count from resource_cons where site_code=? and prd_code=?"; String retStr = checkData(siteCode , prdCode , conn);
System.out.println("Returned String is ===" +retStr);
if("error".equalsIgnoreCase(retStr))
{
errCode = "INVPRDSTCD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
//Added and Commented by sarita on 07 DECEMBER 2018 [START]
/* sql = "select count(*) as count from resource_cons where site_code=? and prd_code=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode); pstmt.setString(1,siteCode);
pstmt.setString(2,prdCode); pstmt.setString(2,prdCode);
...@@ -267,18 +279,15 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -267,18 +279,15 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(rs != null)
{
rs.close();
rs = null;
}
if(cnt > 0) if(cnt > 0)
{ {
errCode = "INVPRDSTCD"; errCode = "INVPRDSTCD";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }*/
//Added and Commented by sarita on 07 DECEMBER 2018 [END]
}//end of case1 }//end of case1
break; break;
...@@ -618,6 +627,10 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -618,6 +627,10 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
int cnt=0; int cnt=0;
double allocPercent=0; double allocPercent=0;
String effFrom = "", validUpto = "";//Added by sarita on 31 MAY 2018 String effFrom = "", validUpto = "";//Added by sarita on 31 MAY 2018
//Added by sarita on 07DEC2018[START]
String acctCodeDta = "", costctrDta = "";
int chkAllocDataCnt = 0;
//Added by sarita on 07DEC2018[END]
try try
{ {
conn = getConnection(); conn = getConnection();
...@@ -874,7 +887,16 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -874,7 +887,16 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
while(rs.next()) while(rs.next())
{ {
//Added by sarita to skip already allocated data on 07-DECEMBER-2018 [START]
acctCodeDta = rs.getString("acct_code");
costctrDta = rs.getString("cctr_code__from");
chkAllocDataCnt = checkAllocatedData(siteCode,acctCodeDta,costctrDta,fromDateTimestamp,toDateTimestamp,conn);
System.out.println("Data Existed in Resource_cons for SiteCode["+siteCode+"]\t AccountCode["+acctCodeDta+"]\t CostCenterCode["+costctrDta+"]\t FromDate["+fromDateTimestamp+"]\t ToDate["+toDateTimestamp+"] id === ["+chkAllocDataCnt+"]");
if(chkAllocDataCnt == 1)
{
continue;
}
//Added by sarita to skip already allocated data on 07-DECEMBER-2018 [END]
dataMap = new HashMap(); dataMap = new HashMap();
dataMap.put("tran_id", rs.getString("tran_id")); dataMap.put("tran_id", rs.getString("tran_id"));
dataMap.put("cctr_code__from", rs.getString("cctr_code__from")); dataMap.put("cctr_code__from", rs.getString("cctr_code__from"));
...@@ -893,7 +915,6 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -893,7 +915,6 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
dataMap.put("valid_upto", rs.getString("valid_upto")); dataMap.put("valid_upto", rs.getString("valid_upto"));
//Added by sarita on 31-MAY-2018 [END] //Added by sarita on 31-MAY-2018 [END]
cosAllocationList.add(dataMap); cosAllocationList.add(dataMap);
} }
if(pstmt != null) if(pstmt != null)
...@@ -1276,7 +1297,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -1276,7 +1297,7 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
tempMap.put("alloc_amt", allocAmt); tempMap.put("alloc_amt", allocAmt);
accontsList.add(tempMap); accontsList.add(tempMap);
} }
//Add by Ajay on 02/05/2018:START //Add by Ajay on 02/05/2018:START
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
...@@ -2064,6 +2085,214 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote ...@@ -2064,6 +2085,214 @@ public class CostCtrAllocIC extends ValidatorEJB implements CostCtrAllocICRemote
return resultActNum; return resultActNum;
} }
//Added by sarita on 07DECEMBER2018 [START]
private int checkAllocatedData(String siteCode,String acctCodeDta,String cctrCodeDta, Timestamp fromDateTimestamp,Timestamp toDateTimestamp,Connection conn) throws ITMException
{
int dtCnt = 0;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null ;
try
{
sql = " Select count(*) as cnt "
+ " from resource_cons "
+ " where site_code = ? "
+ " AND acct_code = ? "
+ " AND cctr_code = ? "
+ " AND from_date <= ? "
+ " AND to_date >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,acctCodeDta);
pstmt.setString(3,cctrCodeDta);
pstmt.setTimestamp(4,fromDateTimestamp);
pstmt.setTimestamp(5,toDateTimestamp);
rs = pstmt.executeQuery();
if(rs.next())
{
dtCnt = rs.getInt("cnt"); System.out.println("[COUNT IS ["+dtCnt+"]");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Inside Method [checkAllocatedData] "+e);
e.printStackTrace();
throw new ITMException(e);
}
return dtCnt;
}
public String checkData(String siteCode , String prdCode,Connection conn) throws ITMException
{
String sql = "", sql1 = "";
PreparedStatement pstmt = null , pstmt1 = null;
ResultSet rs = null , rs1 = null ;
String siteCodeCostAlloc = "" , acctCodeCostAlloc = "", cctrCodeCostAlloc = "";
Timestamp fromDateCostAlloc = null , toDateCostAlloc = null , fromDateBase = null , toDateBase = null;;
int matchRecords = 0 , noMatchRecords = 0 , totRcds = 0;
String record = "" , retString = "";
HashMap<String,Integer> totRecords = new HashMap<String,Integer>();
try
{
System.out.println("**** Inside Method checkData *****");
sql = "select fr_date , to_date from period where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
fromDateBase = rs.getTimestamp("fr_date");
toDateBase = rs.getTimestamp("to_date"); System.out.println("fromDateBase ["+fromDateBase+"] \t toDateBase ["+toDateBase+"]");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "select site_code, "
+ "acct_code, "
+ "cctr_code__from, "
+ "eff_from ,"
+ "valid_upto "
+ "from costalloc_bas "
+ "where site_code = ? "
+ "and eff_from <= ? "
+ "and valid_upto >= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setTimestamp(2,fromDateBase);
pstmt.setTimestamp(3,toDateBase);
rs = pstmt.executeQuery();
while(rs.next())
{
totRcds++;
siteCodeCostAlloc = rs.getString("site_code");
acctCodeCostAlloc = rs.getString("acct_code");
cctrCodeCostAlloc = rs.getString("cctr_code__from");
fromDateCostAlloc = rs.getTimestamp("eff_from");
toDateCostAlloc = rs.getTimestamp("valid_upto");
System.out.println("11siteCodeCostAlloc["+siteCodeCostAlloc+"]\t acctCodeCostAlloc["+acctCodeCostAlloc+"]\t cctrCodeCostAlloc["+cctrCodeCostAlloc+"]\t fromDateCostAlloc["+fromDateCostAlloc+"]\t toDateCostAlloc["+toDateCostAlloc+"]");
sql1 = " Select count(*) as cnt "
+ " from resource_cons "
+ " where site_code = ? "
+ " AND acct_code = ? "
+ " AND cctr_code = ? "
+ " AND from_date <= ? "
+ " AND to_date >= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,siteCodeCostAlloc);
pstmt1.setString(2,acctCodeCostAlloc);
pstmt1.setString(3,cctrCodeCostAlloc);
pstmt1.setTimestamp(4,fromDateCostAlloc);
pstmt1.setTimestamp(5,toDateCostAlloc);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
record = checkNull(rs1.getString("cnt"));
if("1".equalsIgnoreCase(record))
{
if(totRecords.containsKey("match_record"))
{
totRecords.put("match_record", totRecords.get("match_record")+1);
}
else
{
totRecords.put("match_record", matchRecords+1);
}
}
else
{
if(totRecords.containsKey("no_match_record"))
{
totRecords.put("no_match_record", totRecords.get("no_match_record")+1);
}
else
{
totRecords.put("no_match_record", noMatchRecords+1);
}
}
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("totRcds["+totRcds+"]\t HashMap ["+totRecords+"]\t ");
if(!totRecords.isEmpty())
{
matchRecords = checkIntNull(String.valueOf(totRecords.get("match_record")));
noMatchRecords = checkIntNull(String.valueOf(totRecords.get("no_match_record")));
System.out.println("matchRecords["+matchRecords+"]\t noMatchRecords["+noMatchRecords+"]");
if(totRcds == (matchRecords + noMatchRecords) && (noMatchRecords == 0))
{
retString = "error"; // All records allocated..
return retString;
}
else
{
retString = "success"; // All records are not yet allocated..
return retString;
}
}
System.out.println("Total Records ["+totRcds+"] \t HashTable ["+totRecords+"]");
System.out.println("siteCodeBas ["+siteCodeCostAlloc+"] \t acctCodeBas ["+acctCodeCostAlloc+"] \t cctrCodeBas ["+cctrCodeCostAlloc+"] \t fromDateBase ["+fromDateCostAlloc+"] \t toDateBase["+toDateCostAlloc+"]");
}
catch(Exception e)
{
System.out.println("Inside Method [checkData] "+e);
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
private int checkIntNull(String str)
{
if ("null".equals(str) || str == null || str.trim().length() == 0) {
return 0;
} else {
return Integer.parseInt(str);
}
}
//Added by sarita on 07DECEMBER2018 [START]
}//end of class CostCtrAllocIC }//end of class CostCtrAllocIC
......
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