Commit dc7f004f authored by steurwadkar's avatar steurwadkar

F17ABAS001 source code commit


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106190 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9631d021
package ibase.webitm.bean.gst;
import java.util.Date;
public class APICallData
{
private String periodCode;
private Date callDate;
private String siteCode;
private String userId;
private String callType;
private String recType;
private int noOfRecords;
private String callStatus;
private String responseId;
private String responseJsonStr;
private String chgUser;
private Date chgDate;
private String chgTerm;
public String getPeriodCode() {
return periodCode;
}
public void setPeriodCode(String periodCode) {
this.periodCode = periodCode;
}
public Date getCallDate() {
return callDate;
}
public void setCallDate(Date callDate) {
this.callDate = callDate;
}
public String getSiteCode() {
return siteCode;
}
public void setSiteCode(String siteCode) {
this.siteCode = siteCode;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getCallType() {
return callType;
}
public void setCallType(String callType) {
this.callType = callType;
}
public String getRecType() {
return recType;
}
public void setRecType(String recType) {
this.recType = recType;
}
public int getNoOfRecords() {
return noOfRecords;
}
public void setNoOfRecords(int noOfRecords) {
this.noOfRecords = noOfRecords;
}
public String getCallStatus() {
return callStatus;
}
public void setCallStatus(String callStatus) {
this.callStatus = callStatus;
}
public String getResponseId() {
return responseId;
}
public void setResponseId(String responseId) {
this.responseId = responseId;
}
public String getResponseJsonStr() {
return responseJsonStr;
}
public void setResponseJsonStr(String responseJsonStr) {
this.responseJsonStr = responseJsonStr;
}
public String getChgUser() {
return chgUser;
}
public void setChgUser(String chgUser) {
this.chgUser = chgUser;
}
public Date getChgDate() {
return chgDate;
}
public void setChgDate(Date chgDate) {
this.chgDate = chgDate;
}
public String getChgTerm() {
return chgTerm;
}
public void setChgTerm(String chgTerm) {
this.chgTerm = chgTerm;
}
}
......@@ -32,11 +32,14 @@ import com.mashape.unirest.http.Unirest;
import com.sun.jmx.snmp.Timestamp;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.bean.gst.APICallData;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.util.gst.AESEncryption;
import ibase.webitm.util.gst.GSPSignature;
import ibase.webitm.util.gst.GSTCommonUtil;
import ibase.webitm.util.gst.PubKeyEncryption;
import ibase.webitm.utility.ITMException;
......@@ -52,7 +55,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
private String GSTR2_URL_V3 = "";
private final String APPLICATION_JSON = "application/json";
private String appKey = "";
InetAddress ipAddress = null;
String ipAddress = "";
private byte[] appKeyInBytes = null;
private String appKeyEncryptedAndCoded = "";
private String clientId = "";
......@@ -63,13 +66,16 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
PrivateKey aspPrivateKey = null;
Connection conn = null;
GSTCommonUtil gstCommonUtil = new GSTCommonUtil();
E12GenericUtility e12GenericUtility = new E12GenericUtility();
@PostConstruct
public void postConstruct()
{
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
try(java.util.Scanner sc = new java.util.Scanner(new java.net.URL("https://api.ipify.org").openStream(), "UTF-8").useDelimiter("\\A"))
{
System.out.println("GSTDataSubmitWizEJB PostConstruct called!");
InputStream pubKeyInpStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("ibase/webitm/resources/gst/GSTN_Public_Key.cer");
......@@ -79,8 +85,8 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
clientSecret = finCommon.getFinparams("999999", "GST_CLIENT_SECRET", conn);
aesEncryption = new AESEncryption();
pubKeyEncryption = new PubKeyEncryption(pubKeyInpStream);
ipAddress = Inet4Address.getLocalHost();
System.out.println("host ipAddress["+ipAddress.getHostAddress()+"]");
ipAddress = sc.next();
System.out.println("host ipAddress["+ipAddress+"]");
gspSignature = new GSPSignature();
String privateKeyPath = "/ibase/webitm/resources/gst/privatekey.pem";
aspPrivateKey = gspSignature.loadPrivateKey(Thread.currentThread().getContextClassLoader().getResourceAsStream(privateKeyPath));
......@@ -209,10 +215,9 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
@Override
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
E12GenericUtility e12genericUtility = new E12GenericUtility();
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
String sql = "", siteCode = "", siteDescr = "", gstinNo = "", userName = "", stateCode = "", stateDescr = "", grossTurnover = "", periodCode = "", currDateStr = "";
String sql = "", siteCode = "", siteDescr = "", gstinNo = "", userName = "", stateCode = "", stateDescr = "", grossTurnover = "", periodCode = "", currDateStr = "", currentYearGrossTurnover = "";
Calendar calendar = new GregorianCalendar();
Connection conn = null;
PreparedStatement pstmt = null;
......@@ -221,7 +226,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
{
System.out.println("Inside GSTDataSubmitWizEJB itemchanged");
conn = getConnection();
siteCode = e12genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
......@@ -246,7 +251,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
appKeyEncryptedAndCoded = pubKeyEncryption.encrypt(appKeyInBytes);
sql = " SELECT S.SITE_CODE, S.SH_DESCR, ST.GST_CODE, ST.DESCR, SR.REF_CODE, SR.REG_NO FROM SITE S, SITEREGNO SR, STATE ST"
+ " WHERE S.SITE_CODE = SR.SITE_CODE AND S.FIN_ENTITY = SR.FIN_ENTITY AND S.STATE_CODE = ST.STATE_CODE AND SR.REF_CODE IN ('GSTIN_NO','GST_UNAME','GST_GT')"
+ " WHERE S.SITE_CODE = SR.SITE_CODE AND S.FIN_ENTITY = SR.FIN_ENTITY AND S.STATE_CODE = ST.STATE_CODE AND SR.REF_CODE IN ('GSTIN_NO','GST_UNAME','GST_GT','GST_CUR_GT')"
+ " AND SR.SITE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
......@@ -267,6 +272,10 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
{
grossTurnover = checkNull(rs.getString("REG_NO"));
}
if("GST_CUR_GT".equalsIgnoreCase(checkNull(rs.getString("REF_CODE"))))
{
currentYearGrossTurnover = checkNull(rs.getString("REG_NO"));
}
stateCode = checkNull(rs.getString("GST_CODE"));
stateDescr = checkNull(rs.getString("DESCR"));
}
......@@ -284,7 +293,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -1);
SimpleDateFormat sdf = new SimpleDateFormat(e12genericUtility.getApplDateFormat());
SimpleDateFormat sdf = new SimpleDateFormat(e12GenericUtility.getApplDateFormat());
currDateStr = sdf.format(calendar.getTime());
......@@ -319,6 +328,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
valueXmlString.append("<state_code><![CDATA[").append(stateCode).append( "]]></state_code>");
valueXmlString.append("<state_descr><![CDATA[").append(stateDescr).append( "]]></state_descr>");
valueXmlString.append("<gross_turnover><![CDATA[").append(grossTurnover).append( "]]></gross_turnover>");
valueXmlString.append("<cur_gross_turnover><![CDATA[").append(currentYearGrossTurnover).append( "]]></cur_gross_turnover>");
valueXmlString.append("<otp><![CDATA[]]></otp>");
valueXmlString.append("<app_key><![CDATA["+appKey+"]]></app_key>");
valueXmlString.append("</Detail1>" );
......@@ -331,20 +341,22 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
String gspAuthString = "", gspAuthSignature = "";
long timeStamp = new Timestamp().getDateTime();
byte[] authSEK = null;
String loginCode = "", chgTerm = "", callStatus = "", responseId = "", responseJsonStr= "", recType = "";
System.out.println(" -------- Inside itemchange case 2222222 ------------ ");
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ))
{
gstinNo = checkNull(e12genericUtility.getColumnValue("gstin", dom1));
periodCode = checkNull(e12genericUtility.getColumnValue("period_code", dom1));
stateCode = checkNull(e12genericUtility.getColumnValue("state_code", dom1));
userName = checkNull(e12genericUtility.getColumnValue("username", dom1));
returnType = checkNull(e12genericUtility.getColumnValue("returns_type", dom1));
action = checkNull(e12genericUtility.getColumnValue("action", dom1));
siteCode = checkNull(e12genericUtility.getColumnValue("site_code", dom1));
gstinNo = checkNull(e12GenericUtility.getColumnValue("gstin", dom1));
periodCode = checkNull(e12GenericUtility.getColumnValue("period_code", dom1));
stateCode = checkNull(e12GenericUtility.getColumnValue("state_code", dom1));
userName = checkNull(e12GenericUtility.getColumnValue("username", dom1));
returnType = checkNull(e12GenericUtility.getColumnValue("returns_type", dom1));
action = checkNull(e12GenericUtility.getColumnValue("action", dom1));
siteCode = checkNull(e12GenericUtility.getColumnValue("site_code", dom1));
if("GSTR1".equalsIgnoreCase(returnType.trim()))
{
recType = "1";
if("SUBMIT".equalsIgnoreCase(action.trim()))
{
boolean isPendingDataFound = false;
......@@ -383,16 +395,28 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
}
}
else if("GSTR2".equalsIgnoreCase(returnType))
{
recType = "2";
}
else if("GSTR3".equalsIgnoreCase(returnType))
{
recType = "3";
}
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
transactionId = UUID.randomUUID().toString().replaceAll("-", "");
appKey = checkNull(e12genericUtility.getColumnValue("app_key", dom1));
appKey = checkNull(e12GenericUtility.getColumnValue("app_key", dom1));
appKeyInBytes = aesEncryption.decodeBase64StringTOByte(appKey);
appKeyEncryptedAndCoded = pubKeyEncryption.encrypt(appKeyInBytes);
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstinNo;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
otp = checkNull(e12genericUtility.getColumnValue("otp", dom1));
otp = checkNull(e12GenericUtility.getColumnValue("otp", dom1));
String encryptedOTP = aesEncryption.encryptEK(otp.getBytes(), appKeyInBytes);
......@@ -407,7 +431,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("state-cd", stateCode)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("txn", transactionId)
.header("app_key", appKeyEncryptedAndCoded)
.header("X-Asp-Auth-Token", gspAuthString)
......@@ -422,6 +446,8 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
JSONObject object = authTokenResp.getBody().getObject();
if (object.has("auth_token") && object.has("sek") && object.has("status_cd") && Objects.equals(object.getString("status_cd"), "1"))
{
callStatus = "1";
responseJsonStr = object.toString();
authToken = object.getString("auth_token");
sek = object.getString("sek");
......@@ -431,7 +457,9 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
}
else
{
callStatus = "2";
JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
if("AUTH4033".equalsIgnoreCase(errorJSON.getString("error_cd")))
{
......@@ -446,26 +474,47 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
}
else if(authTokenResp.getStatus() == 500)
{
errMsg = "Message : Error occurred at GSTN server \nResponse code : 500";
callStatus = "2";
errMsg = "Message : Error occurred at GSTN server \nResponse code : "+authTokenResp.getStatus();
responseJsonStr = errMsg;
errorXML = getError(errMsg, "GSTAPIERR", conn);
}
else
{
callStatus = "2";
JSONObject errorJSON = authTokenResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
errorXML = getError(errMsg, "GSTAPIERR", conn);
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("GET_"+action);
apiCallData.setRecType(recType);
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
if("GSTR1".equalsIgnoreCase(returnType))
{
if("SUBMIT".equalsIgnoreCase(action))
{
retXML += getGstr1Summary(authToken, stateCode, userName, gstinNo, periodCode, authSEK, appKeyEncryptedAndCoded, conn);
retXML += downloadGstr1Data(gstinNo, periodCode, authToken, userName, stateCode, appKeyEncryptedAndCoded, authSEK);
retXML += getGstr1Summary(authToken, stateCode, userName, gstinNo, periodCode, authSEK, appKeyEncryptedAndCoded, xtraParams, conn);
retXML += downloadGstr1Data(gstinNo, periodCode, authToken, userName, stateCode, appKeyEncryptedAndCoded, xtraParams, authSEK);
}
else if("FILE".equalsIgnoreCase(action))
{
retXML += getGstr1Summary(authToken, stateCode, userName, gstinNo, periodCode, authSEK, appKeyEncryptedAndCoded, conn);
retXML += getGstr1Summary(authToken, stateCode, userName, gstinNo, periodCode, authSEK, appKeyEncryptedAndCoded, xtraParams, conn);
}
}
......@@ -656,6 +705,32 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
if("GSTR1".equalsIgnoreCase(returnType))
{
if("SAVE".equalsIgnoreCase(action))
{
sql = "SELECT COUNT(1) AS CNT FROM GST_DATA_HDR WHERE REC_TYPE = '1' AND SUBMIT_STATUS = 'P' AND PRD_CODE = ? AND SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, periodCode);
pstmt.setString(2, loginSiteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
if(rs.getInt("CNT") == 0)
{
errList.add( "VTNOGSDATA" );
errFields.add("returns_type");
}
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
if(rs!=null)
{
rs.close();
rs = null;
}
}
if("SUBMIT".equalsIgnoreCase(action))
{
sql = "SELECT COUNT(1) AS CNT FROM GST_DATA_HDR WHERE REC_TYPE = '1' AND SUBMIT_STATUS = 'T' AND PRD_CODE = ? AND SITE_CODE = ?";
......@@ -681,6 +756,29 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
rs.close();
rs = null;
}
sql = "SELECT COUNT(1) AS CNT FROM GST_DATA_HDR WHERE REC_TYPE = '1' AND SUBMIT_STATUS = 'P' AND PRD_CODE = ? AND SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, periodCode);
pstmt.setString(2, loginSiteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
if(rs.getInt("CNT") > 0)
{
errList.add( "VTPENGSREC" );
errFields.add("returns_type");
}
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
if(rs!=null)
{
rs.close();
rs = null;
}
}
if("FILE".equalsIgnoreCase(action))
{
......@@ -787,7 +885,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
}
@Override
public String handleRequest(HashMap<String, String> reqParamMap) throws ITMException
public String handleRequest(HashMap<String, String> reqParamMap, UserInfoBean userInfo) throws ITMException
{
String retResponseXML = "", action = "";
String sql = "";
......@@ -801,7 +899,8 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
if("GENERATE_OTP".equalsIgnoreCase(action))
{
String userName = "", stateCode = "", gspAuthString = "", gspAuthSignature = "", gstinNo = "";
String userName = "", stateCode = "", gspAuthString = "", gspAuthSignature = "", gstinNo = "", periodCode = "", siteCode = "", recType = "";
String responseId = "", responseJsonStr = "", callStatus = "";
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
long timeStamp = new Timestamp().getDateTime();
......@@ -814,6 +913,21 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
userName = reqParamMap.get("user_name");
stateCode = reqParamMap.get("state_code");
gstinNo = reqParamMap.get("gstin_no");
periodCode = reqParamMap.get("period_code");
siteCode = reqParamMap.get("site_code");
if("GSTR1".equalsIgnoreCase(reqParamMap.get("rec_type")))
{
recType = "1";
}
else if("GSTR2".equalsIgnoreCase(reqParamMap.get("rec_type")))
{
recType = "2";
}
else if("GSTR3".equalsIgnoreCase(reqParamMap.get("rec_type")))
{
recType = "3";
}
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstinNo;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
......@@ -828,7 +942,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("state-cd", stateCode)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("username", userName)
.header("txn", transactionId)
.header("app_key", appKeyEncryptedAndCoded)
......@@ -844,19 +958,42 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
JSONObject object = otpResp.getBody().getObject();
if( object.has("status_cd") && "1".equalsIgnoreCase(object.getString("status_cd")))
{
callStatus = "1";
responseJsonStr = object.toString();
retResponseXML = "<root><message><![CDATA[OTP generated successfuly!]]></message></root>";
}
else
{
callStatus = "2";
JSONObject errorJSON = otpResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
retResponseXML = "<root><message><![CDATA[Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd")+"]]></message></root>";
}
}
else
{
callStatus = "2";
JSONObject errorJSON = otpResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
retResponseXML = "<root><message><![CDATA[Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd")+"]]></message></root>";
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(userInfo.getLoginCode());
apiCallData.setCallType("OTPREQUEST");
apiCallData.setRecType(recType);
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(userInfo.getLoginCode());
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(userInfo.getRemoteHost());
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
else if ("ITEM_CHANGE".equalsIgnoreCase(action))
{
......@@ -941,14 +1078,19 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
System.out.println("final retResonseXML ["+retResponseXML+"]");
return retResponseXML;
}
private String downloadGstr1Data (String gstinNo, String periodCode, String authToken, String userName, String stateCode, String appKeyEncryptedAndCoded, byte[] authSek) throws ITMException
private String downloadGstr1Data (String gstinNo, String periodCode, String authToken, String userName, String stateCode, String appKeyEncryptedAndCoded, String xtraParams, byte[] authSek) throws ITMException
{
StringBuffer retStringBuff = new StringBuffer();
String[] gstr1Section = {"B2B","B2CL","B2CS","CDNR","AT","TXP","NIL","EXP","HSNSUM","CDNUR"};
String gspAuthString = "", gspAuthSignature = "";
String siteCode = "", loginCode = "", chgTerm = "", callStatus = "", responseId = "", responseJsonStr= "";
try
{
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
for(String action : gstr1Section)
{
long timeStamp = new Timestamp().getDateTime();
......@@ -966,7 +1108,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
.header("state-cd", stateCode)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("username", userName)
.header("auth-token", authToken)
.header("app_key", appKeyEncryptedAndCoded)
......@@ -982,6 +1124,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
JSONObject getDataRespObj = getDataResp.getBody().getObject();
if(getDataRespObj.has("data") && getDataRespObj.has("rek"))
{
callStatus = "1";
String getdata = getDataRespObj.getString("data");
String getrek = getDataRespObj.getString("rek");
......@@ -992,6 +1135,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
byte[] getrespJsonInBytes = aesEncryption.decodeBase64StringTOByte(getrespJsoninBase64);
String getjsonData = new String(getrespJsonInBytes);
responseJsonStr = getjsonData;
System.out.println("json response["+getjsonData+"] for ["+action+"]");
if("B2B".equalsIgnoreCase(action))
......@@ -1067,15 +1211,36 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
}
else
{
callStatus = "2";
JSONObject errorJSON = getDataResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
System.out.println("errorJSON["+errorJSON+"]");
}
}
else
{
callStatus = "2";
JSONObject errorJSON = getDataResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
System.out.println("errorJSON["+errorJSON+"]");
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("GET_"+action);
apiCallData.setRecType("1");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
}
catch (Exception e)
......@@ -1087,13 +1252,19 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
System.out.println("final retStringBuff.toSting["+retStringBuff.toString()+"]");
return retStringBuff.toString();
}
private String getGstr1Summary(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSek, String appKeyEncryptedAndCoded, Connection conn) throws ITMException
private String getGstr1Summary(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSek, String appKeyEncryptedAndCoded, String xtraParams, Connection conn) throws ITMException
{
String retString = "";
String errMsg = "", gspAuthString = "", gspAuthSignature = "";
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
String siteCode = "", loginCode = "", chgTerm = "", callStatus = "", responseId = "", responseJsonStr= "";
try
{
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
long timeStamp = new Timestamp().getDateTime();
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
......@@ -1106,7 +1277,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
.header("state-cd", stateCode)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("username", userName)
.header("auth-token", authToken)
.header("app_key", appKeyEncryptedAndCoded)
......@@ -1124,6 +1295,8 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
JSONObject getGstr1SumryRespObj = getGstr1SumryResp.getBody().getObject();
if(getGstr1SumryRespObj.has("data") && getGstr1SumryRespObj.has("rek"))
{
callStatus = "1";
responseJsonStr = getGstr1SumryRespObj.toString();
String gstr1Sumrydata = getGstr1SumryRespObj.getString("data");
String gstr1Sumryrek = getGstr1SumryRespObj.getString("rek");
......@@ -1142,17 +1315,38 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
}
else
{
callStatus = "2";
JSONObject errorJSON = getGstr1SumryResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
else
{
callStatus = "2";
JSONObject errorJSON = getGstr1SumryResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETSUM");
apiCallData.setRecType("1");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
catch(Exception e)
{
......
......@@ -7,6 +7,7 @@ import javax.ejb.Local;
import org.w3c.dom.Document;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
......@@ -17,5 +18,5 @@ public interface GSTDataSubmitWizEJBLocal extends ValidatorLocal
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext,String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String handleRequest(HashMap<String, String> reqParamMap) throws ITMException;
public String handleRequest(HashMap<String, String> reqParamMap, UserInfoBean userInfo) throws ITMException;
}
......@@ -7,6 +7,7 @@ import javax.ejb.Remote;
import org.w3c.dom.Document;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
......@@ -17,5 +18,5 @@ public interface GSTDataSubmitWizEJBRemote extends ValidatorRemote
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext,String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String handleRequest(HashMap<String, String> reqParamMap) throws ITMException;
public String handleRequest(HashMap<String, String> reqParamMap, UserInfoBean userInfo) throws ITMException;
}
......@@ -38,6 +38,7 @@ import com.sun.jmx.snmp.Timestamp;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.bean.gst.APICallData;
import ibase.webitm.bean.gst.AT;
import ibase.webitm.bean.gst.ATA;
import ibase.webitm.bean.gst.B2B;
......@@ -63,6 +64,7 @@ import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.util.gst.AESEncryption;
import ibase.webitm.util.gst.GSPSignature;
import ibase.webitm.util.gst.GSTCommonUtil;
import ibase.webitm.util.gst.PubKeyEncryption;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
......@@ -79,7 +81,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
private String GSTR2_URL_V3 = "";
private final String APPLICATION_JSON = "application/json";
private String appKey = "";
InetAddress ipAddress = null;
String ipAddress = "";
private byte[] appKeyInBytes = null;
private String appKeyEncryptedAndCoded = "";
private String clientId = "";
......@@ -90,7 +92,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
GSPSignature gspSignature;
PrivateKey aspPrivateKey = null;
E12GenericUtility e12GeneticUitlity = null;
E12GenericUtility e12GenericUtility = new E12GenericUtility();
GSTCommonUtil gstCommonUtil = new GSTCommonUtil();
@PostConstruct
public void postConstruct()
......@@ -98,19 +101,18 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
try(java.util.Scanner sc = new java.util.Scanner(new java.net.URL("https://api.ipify.org").openStream(), "UTF-8").useDelimiter("\\A"))
{
System.out.println("GSTDataSubmitWizPos PostConstruct called!");
InputStream pubKeyInpStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("ibase/webitm/resources/gst/GSTN_Public_Key.cer");
conn = getConnection();
e12GeneticUitlity = new E12GenericUtility();
FinCommon finCommon = new FinCommon();
clientId = finCommon.getFinparams("999999", "GST_CLIENT_ID", conn);
clientSecret = finCommon.getFinparams("999999", "GST_CLIENT_SECRET", conn);
aesEncryption = new AESEncryption();
pubKeyEncryption = new PubKeyEncryption(pubKeyInpStream);
ipAddress = Inet4Address.getLocalHost();
System.out.println("host ipAddress["+ipAddress.getHostAddress()+"]");
ipAddress = sc.next();
System.out.println("host ipAddress["+ipAddress+"]");
gspSignature = new GSPSignature();
String privateKeyPath = "/ibase/webitm/resources/gst/privatekey.pem";
aspPrivateKey = gspSignature.loadPrivateKey(Thread.currentThread().getContextClassLoader().getResourceAsStream(privateKeyPath));
......@@ -206,7 +208,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
Document allXMLDom = null;
NodeList detail1NList = null, detail1ChildNList = null, detail2NList = null, detail2ChildNList = null;
String retString = "", nodeName = "", otp = "", stateCode = "", sek = "", returnsType = "", gstin = "", periodCode = "", grossTurnover = "",
action = "", siteCode = "", gspAuthString = "", gspAuthSignature = "";
action = "", siteCode = "", gspAuthString = "", gspAuthSignature = "", currentYearTurnover = "";
byte[] authSEK = null;
try
......@@ -218,7 +220,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
System.out.println("dcrId["+dcrId+"]");
System.out.println("editFlag["+editFlag+"]");
allXMLDom = e12GeneticUitlity.parseString(xmlStringAll);
allXMLDom = e12GenericUtility.parseString(xmlStringAll);
detail1NList = allXMLDom.getElementsByTagName("Detail1");
detail1ChildNList = detail1NList.item(0).getChildNodes();
......@@ -270,6 +272,10 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
{
siteCode = eachDetail1Element.getTextContent();
}
else if("cur_gross_turnover".equalsIgnoreCase(nodeName))
{
currentYearTurnover = eachDetail1Element.getTextContent();
}
}
}
......@@ -330,7 +336,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("state-cd", stateCode)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("txn", transactionId)
.header("app_key", appKeyEncryptedAndCoded)
.header("X-Asp-Auth-Token", gspAuthString)
......@@ -378,22 +384,22 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
{
if("SAVE".equalsIgnoreCase(action))
{
retString = saveGstr1(authToken, siteCode, stateCode, userName, gstin, periodCode, grossTurnover, authSEK, conn);
retString = saveGstr1(authToken, siteCode, stateCode, userName, gstin, periodCode, grossTurnover, currentYearTurnover, authSEK, xtraParams, conn);
}
else if ("RETSUM".equalsIgnoreCase(action) || "FILE".equalsIgnoreCase(action))
{
retString = getGstr1Summary(authToken, stateCode, userName, gstin, periodCode, authSEK, action, conn);
retString = getGstr1Summary(authToken, stateCode, userName, gstin, periodCode, authSEK, action, xtraParams, conn);
}
else if ("SUBMIT".equalsIgnoreCase(action))
{
retString = submitGstr1(authToken, stateCode, userName, gstin, periodCode, authSEK, conn);
retString = submitGstr1(authToken, stateCode, userName, gstin, periodCode, authSEK, xtraParams, conn);
}
}
else if("GSTR2".equalsIgnoreCase(returnsType))
{
if("GETINV".equalsIgnoreCase(action))
{
retString = getGstr2Invoices(authToken, stateCode, userName, gstin, periodCode, siteCode, authSEK, conn);
retString = getGstr2Invoices(authToken, stateCode, userName, gstin, periodCode, siteCode, authSEK, xtraParams, conn);
}
}
}
......@@ -407,13 +413,13 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
return retString;
}
private String saveGstr1(String authToken, String siteCode, String stateCode, String userName, String gstin, String periodCode, String grossTurnover, byte[] authSek, Connection conn) throws ITMException
private String saveGstr1(String authToken, String siteCode, String stateCode, String userName, String gstin, String periodCode, String grossTurnover, String currentYearTurnover, byte[] authSek, String xtraParams, Connection conn) throws ITMException
{
String retString = "", errMsg = "";
String gstr1Data = "", gstr1Rek = "";
String retStatsData = "", retStatsRek = "";
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
int num = 0;
int num = 0, noOfRecords = 0;
boolean isDataFound = false;
......@@ -423,6 +429,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
ResultSet rs = null, lineRs = null, refDataRs = null;
String tranId = "", tranType = "", tranIdRef = "", ctin = "", posStateCode = "";
String loginCode = "", chgTerm = "", callStatus = "", responseId = "", responseJsonStr= "", retStatusCallStatus = "", retStatusResponseJsonStr = "";
ArrayList<String> tranIdList = new ArrayList<String>();
......@@ -476,6 +483,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
while(rs.next())
{
++noOfRecords;
isDataFound = true;
tranId = checkNullandTrim(rs.getString("TRAN_ID"));
tranType = checkNullandTrim(rs.getString("TRAN_TYPE"));
......@@ -765,7 +773,6 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
cdnr = new CDNR();
cdnr.isReverseCharge = false;
cdnr.ctin = ctin;
cdnr.customerFilingStatus = false;//TODO Need to change cfs value hardcoded to false as no information available
cdnr.cdnDetails = cdnDetailsList;
cdnrList.add(cdnr);
......@@ -942,7 +949,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
//tran_type : 31,32 = CDNUR and tran_type : 35,36 = CDNURA
if("CDNUR".equalsIgnoreCase(udfStr1))
{
String reason = "";
String reason = "", customerType = "", refTranType = "";
Calendar calendar = Calendar.getInstance();
calendar.set(2017, 07, 01);
Date gstStartDate = calendar.getTime();
......@@ -1001,7 +1008,44 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
cdnur = new CDNUR();
cdnur.isReverseCharge = false;
cdnur.customerType = "B2CL";//TODO need to change typ value
if(rs.getDate("REF_DATE__INV").after(gstStartDate))
{
refDataSql = "SELECT TRAN_TYPE FROM GST_DATA_HDR WHERE DOC_NO = ? ";
refDataPstmt = conn.prepareStatement(refDataSql);
refDataPstmt.setString(1, checkNullandTrim(rs.getString("REF_ID__INV")));
refDataRs = refDataPstmt.executeQuery();
if(refDataRs.next())
{
refTranType = checkNullandTrim(refDataRs.getString("TRAN_TYPE"));
}
if(refDataPstmt != null)
{
refDataPstmt.close();
refDataPstmt = null;
}
if(refDataRs != null)
{
refDataRs.close();
refDataRs = null;
}
if(refTranType != null && refTranType.trim().length() > 0)
{
if("04".equalsIgnoreCase(refTranType) || "05".equalsIgnoreCase(refTranType))
{
customerType = "B2CL";
}
else if("06".equalsIgnoreCase(refTranType))
{
customerType = "EXPWP";
}
else if("07".equalsIgnoreCase(refTranType))
{
customerType = "EXPWOP";
}
}
}
cdnur.customerType = customerType;
cdnur.cdnNoteType = udfStr2;
cdnur.cdNoteNumber = checkNullandTrim(rs.getString("DOC_NO"));
cdnur.cdNoteDate = rs.getDate("DOC_DATE");
......@@ -1132,33 +1176,12 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
docIssuedList.add(docIssued);*/
//TODO need to change END
/*double currentYearTurnOver = 0.0;
sql = "SELECT SUM(AMOUNT) AS AMOUNT FROM GST_DATA_HDR WHERE REC_TYPE = '1' AND SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
currentYearTurnOver = rs.getDouble("AMOUNT");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}*/
gstr1 = new GSTR1();
gstr1.gstin = gstin;
gstr1.financialPeriod = periodCode;
gstr1.grossTurnOver = Double.valueOf(grossTurnover);
gstr1.currentGrossTurnOver = 20000;//TODO need to calculate
gstr1.currentGrossTurnOver = Double.valueOf(currentYearTurnover);
if(b2bInvoiceList.size() > 0)
{
......@@ -1223,6 +1246,9 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
String gspAuthString = "", gspAuthSignature = "", gspAuthStringRet = "", gspAuthSignatureRet = "";
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(gstr1);
......@@ -1258,7 +1284,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
.header("gstin", gstin)
.header("username", userName)
.header("ret_period", periodCode)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("app_key", appKeyEncryptedAndCoded)
.header("X-Asp-Auth-Token", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
......@@ -1273,6 +1299,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
if(gstr1RespObj.has("data") && gstr1RespObj.has("rek"))
{
callStatus = "1";
gstr1Data = gstr1RespObj.getString("data");
gstr1Rek = gstr1RespObj.getString("rek");
......@@ -1284,6 +1311,9 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
JSONObject Gstr1RespObj = new JSONObject(new String(Gstr1RespJsonInBytes));
String transId = Gstr1RespObj.getString("reference_id");
responseId = transId;
responseJsonStr = Gstr1RespObj.toString();
System.out.println("transId to getStatus["+transId+"]");
while(true)
......@@ -1301,7 +1331,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
.header("state-cd", stateCode)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("username", userName)
.header("auth-token", authToken)
.header("app_key", appKeyEncryptedAndCoded)
......@@ -1333,10 +1363,13 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
if("IP".equalsIgnoreCase((String)retStatsJsonData.get("status_cd")))
{
retStatusCallStatus = "0";
continue;
}
else if("P".equalsIgnoreCase((String)retStatsJsonData.get("status_cd")))
{
retStatusCallStatus = "1";
retStatusResponseJsonStr = (String) retStatsJsonData.get("status_cd");
if(tranIdList.size() > 0)
{
updateSubmissionStatus(tranIdList, conn);
......@@ -1345,20 +1378,26 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
}
else if("PE".equalsIgnoreCase((String)retStatsJsonData.get("status_cd")))
{
retStatusCallStatus = "2";
errMsg = getRetStatusErrMsg(retStatsJsonData);
retStatusResponseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
break;
}
else if("ER".equalsIgnoreCase(retStatsJsonData.getString("status_cd")))
{
retStatusCallStatus = "2";
errMsg = "Message : "+retStatsJsonData.getString("error_msg")+" \nError code : "+retStatsJsonData.getString("errorCd");
retStatusResponseJsonStr = errMsg;
retString = getError(errMsg, "GSTAPIERR", conn);
break;
}
}
else
{
retStatusCallStatus = "2";
JSONObject errorJSON = retStatusResp.getBody().getObject().getJSONObject("error");
retStatusResponseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
break;
......@@ -1366,30 +1405,66 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
}
else
{
retStatusCallStatus = "2";
JSONObject errorJSON = retStatusResp.getBody().getObject().getJSONObject("error");
retStatusResponseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
break;
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETSTATUS");
apiCallData.setRecType("1");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(retStatusCallStatus);
apiCallData.setResponseId("");
apiCallData.setResponseJsonStr(retStatusResponseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
}
else
{
callStatus = "2";
JSONObject errorJSON = gstr1Resp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
else
{
callStatus = "2";
JSONObject errorJSON = gstr1Resp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
else
{
retString = new ITMDBAccessEJB().getErrorString("","VTNOGSDATA","","",conn);
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETSAVE");
apiCallData.setRecType("1");
apiCallData.setNoOfRecords(noOfRecords);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
}
catch (Exception e)
......@@ -1400,13 +1475,19 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
}
return retString;
}
private String getGstr1Summary(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSek, String action, Connection conn) throws ITMException
private String getGstr1Summary(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSek, String action, String xtraParams, Connection conn) throws ITMException
{
String retString = "";
String errMsg = "", gspAuthString = "", gspAuthSignature = "";
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
String loginCode = "", chgTerm = "", siteCode = "", callStatus = "", responseJsonStr = "", retFileCallStatus = "", retFileResponseJsonStr = "";
try
{
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
long timeStamp = new Timestamp().getDateTime();
gspAuthString = clientId + ":" + transactionId + ":" + timeStamp + ":" + gstin;
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
......@@ -1419,7 +1500,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
.header("state-cd", stateCode)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("username", userName)
.header("auth-token", authToken)
.header("app_key", appKeyEncryptedAndCoded)
......@@ -1437,6 +1518,8 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
JSONObject getGstr1SumryRespObj = getGstr1SumryResp.getBody().getObject();
if(getGstr1SumryRespObj.has("data") && getGstr1SumryRespObj.has("rek"))
{
callStatus = "1";
String gstr1Sumrydata = getGstr1SumryRespObj.getString("data");
String gstr1Sumryrek = getGstr1SumryRespObj.getString("rek");
......@@ -1447,7 +1530,9 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
byte[] respJsonInBytes = aesEncryption.decodeBase64StringTOByte(respJsoninBase64);
JSONObject gstr1SumryJsonObj = new JSONObject(new String(respJsonInBytes));
//String jsonData = new String(respJsonInBytes);
responseJsonStr = gstr1SumryJsonObj.toString();
System.out.println(gstr1SumryJsonObj);
if("FILE".equalsIgnoreCase(action))
......@@ -1481,7 +1566,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
.header("state-cd", stateCode)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("username", userName)
.header("auth-token", authToken)
.header("app_key", appKeyEncryptedAndCoded)
......@@ -1499,6 +1584,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
JSONObject fileGstr1RespObj = fileGstr1Resp.getBody().getObject();
if(fileGstr1RespObj.has("data") && fileGstr1RespObj.has("rek"))
{
retFileCallStatus = "1";
String fileGstr1Data = fileGstr1RespObj.getString("data");
String fileGstr1Rek = fileGstr1RespObj.getString("rek");
......@@ -1508,36 +1594,80 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
byte[] fileGstr1JsonInBytes = aesEncryption.decodeBase64StringTOByte(fileGstr1JsoninBase64);
retFileResponseJsonStr = new String(fileGstr1JsonInBytes);
System.out.println(new String(fileGstr1JsonInBytes));
}
else
{
retFileCallStatus = "2";
JSONObject errorJSON = fileGstr1Resp.getBody().getObject().getJSONObject("error");
retFileResponseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
else
{
retFileCallStatus = "2";
JSONObject errorJSON = fileGstr1Resp.getBody().getObject().getJSONObject("error");
retFileResponseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETFILE");
apiCallData.setRecType("1");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(retFileCallStatus);
apiCallData.setResponseId("");
apiCallData.setResponseJsonStr(retFileResponseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
}
else
{
callStatus = "2";
JSONObject errorJSON = getGstr1SumryResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
else
{
callStatus = "2";
JSONObject errorJSON = getGstr1SumryResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETSUM");
apiCallData.setRecType("1");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId("");
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
catch(Exception e)
{
......@@ -1548,14 +1678,20 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
return retString;
}
private String submitGstr1(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSEK, Connection conn) throws ITMException
private String submitGstr1(String authToken, String stateCode, String userName, String gstin, String periodCode, byte[] authSEK, String xtraParams,Connection conn) throws ITMException
{
String retString = "";
String errMsg = "", gspAuthString = "", gspAuthSignature = "";
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
String loginCode = "", chgTerm = "", siteCode = "", callStatus = "", responseJsonStr = "", responseId = "";
try
{
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
String json = "{\"gstin\":\""+gstin+"\",\"ret_period\":\""+periodCode+"\"}";
byte[] jsonBase64 = Base64.getEncoder().encode(json.getBytes());
......@@ -1583,7 +1719,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
.header("state-cd", stateCode)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("username", userName)
.header("auth-token", authToken)
.header("app_key", appKeyEncryptedAndCoded)
......@@ -1602,6 +1738,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
JSONObject gstr1SubmitRespObj = gstr1SubmitResp.getBody().getObject();
if(gstr1SubmitRespObj.has("data") && gstr1SubmitRespObj.has("rek"))
{
callStatus = "1";
String gstr1Submitdata = gstr1SubmitRespObj.getString("data");
String gstr1Submitrek = gstr1SubmitRespObj.getString("rek");
......@@ -1612,22 +1749,44 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
JSONObject gstr1SubmitObj = new JSONObject(new String(respJsonInBytes));
String transId = gstr1SubmitObj.getString("reference_id");
responseId = transId;
responseJsonStr = transId;
System.out.println("transId to getStatus after SUBMIT call["+transId+"]");
}
else
{
callStatus = "2";
JSONObject errorJSON = gstr1SubmitResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
else
{
callStatus = "2";
JSONObject errorJSON = gstr1SubmitResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("RETSUBMIT");
apiCallData.setRecType("1");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
catch(Exception e)
{
......@@ -1638,16 +1797,19 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
return retString;
}
private String getGstr2Invoices(String authToken, String stateCode, String userName, String gstin, String periodCode, String siteCode, byte[] authSEK, Connection conn) throws ITMException
private String getGstr2Invoices(String authToken, String stateCode, String userName, String gstin, String periodCode, String siteCode, byte[] authSEK, String xtraParams, Connection conn) throws ITMException
{
String retString = "";
String errMsg = "", gspAuthString = "", gspAuthSignature = "";
ObjectMapper objectMapper = new ObjectMapper();
String[] gstr2Section = {"B2B","IMPG","IMPS","CDN","NIL","TXLI","TXP","B2BUR","ITCRVSL","CDNUR"};
String transactionId = UUID.randomUUID().toString().replaceAll("-", "");
String loginCode = "", chgTerm = "", callStatus = "", responseJsonStr = "", responseId = "";
try
{
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
for(String action : gstr2Section)
{
System.out.println("calling for ["+action+"]");
......@@ -1663,7 +1825,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
.header("state-cd", stateCode)
.header("clientid", clientId)
.header("client-secret", clientSecret)
.header("ip-usr", ipAddress.getHostAddress())
.header("ip-usr", ipAddress)
.header("username", userName)
.header("auth-token", authToken)
.header("app_key", appKeyEncryptedAndCoded)
......@@ -1681,6 +1843,7 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
JSONObject getGstr2InvoicesRespObj = getGstr2InvoicesResp.getBody().getObject();
if(getGstr2InvoicesRespObj.has("data") && getGstr2InvoicesRespObj.has("rek"))
{
callStatus = "1";
String gstr2InvoicesData = getGstr2InvoicesRespObj.getString("data");
String gstr2InvoicesRek = getGstr2InvoicesRespObj.getString("rek");
......@@ -1690,14 +1853,12 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
byte[] respJsonInBytes = aesEncryption.decodeBase64StringTOByte(respJsoninBase64);
JSONObject gstr2InvoiceJsonObj = new JSONObject(new String(respJsonInBytes));
responseJsonStr = gstr2InvoiceJsonObj.toString();
System.out.println("respJsonInBytes["+new String(respJsonInBytes)+"]");
if("B2B".equalsIgnoreCase(action))
{
/*B2B b2b = objectMapper.readValue(new String(respJsonInBytes), B2B.class);
System.out.println("b2b.ctin["+b2b.ctin+"]");*/
saveB2BInvoiceData(siteCode, gstr2InvoiceJsonObj, conn);
}
......@@ -1705,17 +1866,38 @@ public class GSTDataSubmitWizPos extends ValidatorEJB implements GSTDataSubmitWi
}
else
{
callStatus = "2";
JSONObject errorJSON = getGstr2InvoicesResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
}
else
{
callStatus = "2";
JSONObject errorJSON = getGstr2InvoicesResp.getBody().getObject().getJSONObject("error");
responseJsonStr = errorJSON.toString();
errMsg = "Message : "+errorJSON.getString("message")+" \nError code : "+errorJSON.getString("error_cd");
retString = getError(errMsg, "GSTAPIERR", conn);
}
APICallData apiCallData = new APICallData();
apiCallData.setPeriodCode(periodCode);
apiCallData.setCallDate(new Date());
apiCallData.setSiteCode(siteCode);
apiCallData.setUserId(loginCode);
apiCallData.setCallType("GET_"+action);
apiCallData.setRecType("2");
apiCallData.setNoOfRecords(0);
apiCallData.setCallStatus(callStatus);
apiCallData.setResponseId(responseId);
apiCallData.setResponseJsonStr(responseJsonStr);
apiCallData.setChgUser(loginCode);
apiCallData.setChgDate(new Date());
apiCallData.setChgTerm(chgTerm);
gstCommonUtil.updateAPICallLogHistory(apiCallData, null);
}
}
catch(Exception e)
......
......@@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletResponse;
import ibase.system.config.AppConnectParm;
import ibase.utility.CommonConstants;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.gst.GSTDataSubmitWizEJBRemote;
import ibase.webitm.utility.ITMException;
......@@ -40,6 +41,7 @@ public class GSTDataSubmitWizServlet extends HttpServlet
try
{
UserInfoBean userInfo = (UserInfoBean) request.getSession().getAttribute("USER_INFO");
action = request.getParameter("action");
System.out.println("GSTDataSubmitWizServlet ACTION ["+action+"]");
......@@ -66,7 +68,7 @@ public class GSTDataSubmitWizServlet extends HttpServlet
ctx=getInitialContext();
gstDataSubmitWizRemote = (ibase.webitm.ejb.gst.GSTDataSubmitWizEJBRemote) ctx.lookup("ibase/GSTDataSubmitWizEJB/remote");
responseXML = gstDataSubmitWizRemote.handleRequest(requestParamMap);
responseXML = gstDataSubmitWizRemote.handleRequest(requestParamMap, userInfo);
response.setContentType("text/xml");
......
......@@ -20,7 +20,6 @@ public class CDNRSerializer extends JsonSerializer<CDNR>
{
json.writeStartObject();
json.writeStringField("ctin", cdnr.ctin);
//json.writeStringField("cfs", cdnr.customerFilingStaus?"Y":"N");
json.writeFieldName("nt");
json.writeStartArray();
......
package ibase.webitm.util.gst;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
......@@ -14,9 +10,17 @@ import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.imageio.ImageIO;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.bean.gst.APICallData;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
public class GSTCommonUtil extends ValidatorEJB
{
......@@ -314,6 +318,172 @@ public class GSTCommonUtil extends ValidatorEJB
return retXML;
}
public int updateAPICallLogHistory(APICallData apiCallData, Connection conn) throws ITMException
{
String tranId="";
int insertCnt = 0;
boolean isLocalConnection = false, isError = false;
String insertSql = "";
PreparedStatement pstmt = null;
E12GenericUtility e12GenericUtility = new E12GenericUtility();
try
{
if(conn == null)
{
conn = getConnection();
isLocalConnection = true;
}
tranId = generateTranId("w_gst_api_call", "", "", conn);
insertSql = " INSERT INTO API_CALL_LOG (TRAN_ID, PRD_CODE, CALL_DATE, SITE_CODE, USER_ID, CALL_TYPE, REC_TYPE, NO_OF_RECORDS, CALL_STATUS, RESPONSE_ID, RESPONSE_INFO, CHG_USER, CHG_DATE, CHG_TERM)"
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmt = conn.prepareStatement(insertSql);
pstmt.setString(1, tranId);
pstmt.setString(2, apiCallData.getPeriodCode());
pstmt.setTimestamp(3, java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(apiCallData.getCallDate(), e12GenericUtility.getDBDateTimeFormat())));
pstmt.setString(4, apiCallData.getSiteCode());
pstmt.setString(5, apiCallData.getUserId());
pstmt.setString(6, apiCallData.getCallType());
pstmt.setString(7, apiCallData.getRecType());
pstmt.setInt(8, apiCallData.getNoOfRecords());
pstmt.setString(9, apiCallData.getCallStatus());
pstmt.setString(10, apiCallData.getResponseId());
pstmt.setString(11, apiCallData.getResponseJsonStr());
pstmt.setString(12, apiCallData.getChgUser());
pstmt.setTimestamp(13, java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(apiCallData.getChgDate(), e12GenericUtility.getDBDateTimeFormat())));
pstmt.setString(14, apiCallData.getChgTerm());
insertCnt = pstmt.executeUpdate();
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
isError = true;
System.out.println("GSTCommonUtil.updateAPICallLogHistory()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
if(isLocalConnection)
{
if(isError)
{
conn.rollback();
}
else
{
if(insertCnt > 0)
{
conn.commit();
}
}
if(conn!= null && !conn.isClosed())
{
conn.close();
conn = null;
}
}
}
catch (Exception e)
{
System.out.println("GSTCommonUtil.updateAPICallLogHistory()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
}
return insertCnt;
}
private String generateTranId( String windowName, String siteCode, String tranDateStr, Connection conn )throws ITMException,Exception
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
try
{
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + tranDateStr + "</tran_date>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
return tranId;
}
private static String checkNull(String input)
{
if (input==null)
......
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