Commit e938a3d0 authored by steurwadkar's avatar steurwadkar

F17ABAS001 GST API integration wizard source code commit

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@165102 ce508802-f39f-4f6c-b175-0d175dae99d5
parent da685ed9
...@@ -212,6 +212,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -212,6 +212,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
String loginCode = "", chgTerm = "", callStatus = "", responseId = "", responseJsonStr= ""; String loginCode = "", chgTerm = "", callStatus = "", responseId = "", responseJsonStr= "";
ArrayList<String> tranIdList = new ArrayList<String>(); ArrayList<String> tranIdList = new ArrayList<String>();
ArrayList<HashMap<String,String>> getGstrDataList = new ArrayList<HashMap<String,String>>();
ArrayList<String> byPassSectionList = new ArrayList<String>();
APICallData apiCallData = null; APICallData apiCallData = null;
boolean isDataLogged = false; boolean isDataLogged = false;
...@@ -592,6 +594,45 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -592,6 +594,45 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
System.out.println("tranIdList.size()["+tranIdList.size()+"]"); System.out.println("tranIdList.size()["+tranIdList.size()+"]");
} }
if("GETINV".equalsIgnoreCase(action))
{
sql = " SELECT TRAN_ID, RESPONSE_ID, CALL_DATE,CALL_TYPE"
+ " FROM API_CALL_LOG"
+ " WHERE SITE_CODE = ? AND REC_TYPE = ? AND PRD_CODE = ?"
+ " AND CALL_STATUS = ? AND CALL_TYPE LIKE '%GET%' AND RESPONSE_ID IS NOT NULL"
+ " ORDER BY CALL_DATE DESC";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, "4");
pstmt.setString(3, periodCode);
pstmt.setString(4, "0");
rs = pstmt.executeQuery();
while(rs.next())
{
HashMap<String,String> tempHMap = new HashMap<String,String>();
tempHMap.put("api_tranid", rs.getString("TRAN_ID"));
tempHMap.put("token", rs.getString("RESPONSE_ID"));
String tempStr = rs.getString("CALL_TYPE");
String section = tempStr.substring(tempStr.indexOf("_")+1);
tempHMap.put("section", section);
byPassSectionList.add(section);
getGstrDataList.add(tempHMap);
}
if(rs!=null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
}
if(authToken != null && authToken.trim().length() > 0 && authSEK != null) if(authToken != null && authToken.trim().length() > 0 && authSEK != null)
{ {
if("GSTR1".equalsIgnoreCase(returnsType)) if("GSTR1".equalsIgnoreCase(returnsType))
...@@ -621,7 +662,20 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -621,7 +662,20 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
{ {
if("GETINV".equalsIgnoreCase(action)) if("GETINV".equalsIgnoreCase(action))
{ {
retString = downloadGstr2AData(siteCode, xtraParams, conn); if(getGstrDataList.size() > 0)
{
for(HashMap<String,String> eachDataHamp : getGstrDataList)
{
String sectionName = eachDataHamp.get("section");
JSONObject dataJSONObject = new JSONObject();
dataJSONObject.put("token", eachDataHamp.get("token"));
dataJSONObject.put("est", "");
dataJSONObject.put("api_tranid", eachDataHamp.get("api_tranid"));
retString = getDataFromFileServer("4", dataJSONObject, sectionName, xtraParams, conn);
}
}
retString = downloadGstr2AData(siteCode, xtraParams, byPassSectionList, conn);
} }
} }
else if("GSTR2".equalsIgnoreCase(returnsType)) else if("GSTR2".equalsIgnoreCase(returnsType))
...@@ -3389,7 +3443,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -3389,7 +3443,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
} }
return retString; return retString;
}*/ }*/
private String downloadGstr2AData(String siteCode, String xtraParams, Connection conn) throws ITMException private String downloadGstr2AData(String siteCode, String xtraParams, ArrayList<String> byPassSectionList, Connection conn) throws ITMException
{ {
String retString = ""; String retString = "";
String errMsg = "", gspAuthString = "", gspAuthSignature = ""; String errMsg = "", gspAuthString = "", gspAuthSignature = "";
...@@ -3404,6 +3458,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -3404,6 +3458,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm"); chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
for(String action : gstr2Section) for(String action : gstr2Section)
{
if(byPassSectionList != null && !byPassSectionList.contains(action))
{ {
System.out.println("calling for ["+action+"]"); System.out.println("calling for ["+action+"]");
long timeStamp = new Timestamp().getDateTime(); long timeStamp = new Timestamp().getDateTime();
...@@ -3441,7 +3497,6 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -3441,7 +3497,6 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
JSONObject getGstr2InvoicesRespObj = getGstr2InvoicesResp.getBody().getObject(); JSONObject getGstr2InvoicesRespObj = getGstr2InvoicesResp.getBody().getObject();
if(getGstr2InvoicesRespObj.has("data") && getGstr2InvoicesRespObj.has("rek")) if(getGstr2InvoicesRespObj.has("data") && getGstr2InvoicesRespObj.has("rek"))
{ {
callStatus = "1";
String gstr2InvoicesData = getGstr2InvoicesRespObj.getString("data"); String gstr2InvoicesData = getGstr2InvoicesRespObj.getString("data");
String gstr2InvoicesRek = getGstr2InvoicesRespObj.getString("rek"); String gstr2InvoicesRek = getGstr2InvoicesRespObj.getString("rek");
...@@ -3456,10 +3511,13 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -3456,10 +3511,13 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
if(gstr2InvoiceJsonObj.has("est") && gstr2InvoiceJsonObj.has("token")) if(gstr2InvoiceJsonObj.has("est") && gstr2InvoiceJsonObj.has("token"))
{ {
callStatus = "0";
responseId = gstr2InvoiceJsonObj.getString("token");
retString = getDataFromFileServer("4", gstr2InvoiceJsonObj, action, xtraParams, conn); retString = getDataFromFileServer("4", gstr2InvoiceJsonObj, action, xtraParams, conn);
} }
else else
{ {
callStatus = "1";
if("B2B".equalsIgnoreCase(action)) if("B2B".equalsIgnoreCase(action))
{ {
insertB2BInvoiceData(stateCode, periodCode, siteCode, gstr2InvoiceJsonObj, xtraParams, conn); insertB2BInvoiceData(stateCode, periodCode, siteCode, gstr2InvoiceJsonObj, xtraParams, conn);
...@@ -3511,7 +3569,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -3511,7 +3569,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
apiCallData.setChgTerm(chgTerm); apiCallData.setChgTerm(chgTerm);
apiCallDataList.add(apiCallData); apiCallDataList.add(apiCallData);
}
} }
} }
catch(Exception e) catch(Exception e)
...@@ -4428,6 +4486,13 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -4428,6 +4486,13 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
String transactionId = "", gspAuthString = "", gspAuthSignature = ""; String transactionId = "", gspAuthString = "", gspAuthSignature = "";
String siteCode = "", loginCode = "", chgTerm = "", responseId = "", responseJsonStr = "", callStatus = ""; String siteCode = "", loginCode = "", chgTerm = "", responseId = "", responseJsonStr = "", callStatus = "";
String sep = File.separator; String sep = File.separator;
String sql = "", apiTranId = "";
PreparedStatement pstmt = null;
Connection localConn = null;
int updateCnt = 0;
boolean isError = false;
try try
{ {
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"); siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
...@@ -4518,7 +4583,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -4518,7 +4583,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
if(tempJsonObj.has("ul")) if(tempJsonObj.has("ul"))
{ {
String fileUrl = tempJsonObj.getString("ul"); String fileUrl = tempJsonObj.getString("ul");
fileUrl = BASE_API_URL + fileUrl; fileUrl = FILEDET_URL + fileUrl;
System.out.println("fileUrl["+fileUrl+"]"); System.out.println("fileUrl["+fileUrl+"]");
URL url = new URL(fileUrl); URL url = new URL(fileUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
...@@ -4590,6 +4655,26 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -4590,6 +4655,26 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
} }
} }
} }
if(dataJSONObject.has("api_tranid"))
{
apiTranId = dataJSONObject.getString("api_tranid");
sql = "UPDATE API_CALL_LOG SET CALL_STATUS = ? WHERE TRAN_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "1");
pstmt.setString(2, apiTranId);
updateCnt = pstmt.executeUpdate();
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
System.out.println("api call log update["+updateCnt+"] apiTranId["+apiTranId+"]");
}
} }
else else
{ {
...@@ -4623,6 +4708,27 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -4623,6 +4708,27 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
retString = "<data_error><![CDATA["+errMsg+"]]></data_error>"; retString = "<data_error><![CDATA["+errMsg+"]]></data_error>";
} }
} }
if(dataJSONObject.has("api_tranid"))
{
localConn = getConnection();
apiTranId = dataJSONObject.getString("api_tranid");
sql = "UPDATE API_CALL_LOG SET CALL_STATUS = ? WHERE TRAN_ID = ?";
pstmt = localConn.prepareStatement(sql);
pstmt.setString(1, "1");
pstmt.setString(2, apiTranId);
updateCnt = pstmt.executeUpdate();
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
System.out.println("api call log update["+updateCnt+"] apiTranId["+apiTranId+"]");
}
} }
APICallData apiCallData = new APICallData(); APICallData apiCallData = new APICallData();
...@@ -4644,10 +4750,45 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi ...@@ -4644,10 +4750,45 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
} }
catch(Exception e) catch(Exception e)
{ {
isError = true;
System.out.println("GSTDataSubmitWizPos.getDataFromFileServer()["+e.getMessage()+"]"); System.out.println("GSTDataSubmitWizPos.getDataFromFileServer()["+e.getMessage()+"]");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
finally
{
try
{
if(isError)
{
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(localConn!=null)
{
localConn.rollback();
}
}
else
{
localConn.commit();
}
if(localConn!=null && !localConn.isClosed())
{
localConn.close();
localConn = null;
}
}
catch(SQLException se)
{
System.out.println("GSTDataSubmitWizPos.getDataFromFileServer().finally["+se.getMessage()+"]");
se.printStackTrace();
throw new ITMException(se);
}
}
System.out.println("final retString["+retString+"]"); System.out.println("final retString["+retString+"]");
return retString; return retString;
} }
......
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