Commit 796e1284 authored by ngadkari's avatar ngadkari

added gstin details

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@217527 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8fece895
......@@ -67,8 +67,8 @@
</tr>
<tr>
<td class="highlight rght tdClass" colspan="2">
<div class = "tdDivLft1"> GSTIN/UID </div>
<td class="highlight rght tdClass" colspan="2" style="height: 40px; background:#f7f8fa;"> <!-- backgrounf color added by nandkumar on 25-02-20 -->
<div class = "tdDivLft1"> GSTIN/UID Details </div>
<div class="highlight alignRight" style = "padding-top: 6px;padding-right: 10px;"> <%=custList.get(18)%> </div>
......@@ -76,7 +76,38 @@
<%-- <div class="highlight tdDivRgt1"> <%= %> &nbsp; <%= custList.get(1) %> </div>
--%> </td>
</tr>
<!-- added by nandkumar on 25-02-20 Start -->
<tr>
<td class="highlight rght tdClass" colspan="2">
<div class = "tdDivLft1"> Trade Name </div>
<div class="highlight tdDivRgt1"> <%= custList.get(20) %> </div>
</td>
</tr>
<tr>
<td class="highlight rght tdClass" colspan="2">
<div class = "tdDivLft1"> Registration Date </div>
<div class="highlight tdDivRgt1"> <%= custList.get(19) %> </div>
</td>
</tr>
<tr>
<td class="highlight rght tdClass" colspan="2">
<div class = "tdDivLft1"> Type </div>
<div class="highlight tdDivRgt1"> <%= custList.get(22) %> </div>
</td>
</tr>
<tr>
<td class="highlight rght tdClass" colspan="2">
<div class = "tdDivLft1"> Status </div>
<div class="highlight tdDivRgt1"> <%= custList.get(21) %> </div>
</td>
</tr>
<tr>
<td class="highlight rght tdClass" colspan="2">
<div class = "tdDivLft1"> State </div>
<div class="highlight tdDivRgt1"> <%= custList.get(23) %> </div>
</td>
</tr>
<!-- added by nandkumar on 25-02-20 end -->
<tr>
<td class="highlight rght tdClass" colspan="2" >
<div class = "alignLeft">
......
package ibase.webitm.ejb.dis;
import ibase.utility.CommonConstants;
import ibase.utility.UserInfoBean;
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.utility.ITMException;
import java.io.File;
import java.io.FileInputStream;
import java.security.PrivateKey;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.UUID;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.request.HttpRequest;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import org.json.JSONArray;
import org.json.JSONObject;
public class CustomerDetails extends ValidatorEJB
{
......@@ -28,7 +46,17 @@ public class CustomerDetails extends ValidatorEJB
//Ended by Varsha V on 14-09-18 to seperate subqueries
ArrayList custList = new ArrayList();
boolean isExists = false;
String totalOrdersTillDate = "", openOrders = "";
String totalOrdersTillDate = "", openOrders = "",gstin="";
//added by nandkumar gadkari on 25-02-20
SimpleDateFormat gspTokenTimeFormatter = null;
FinCommon finCommon =null;
AESEncryption aesEncryption =null;
String gspTokenTimeStampFormat="",appKey="",gspPrivateKeyName="",privateKeyPath="",clientId="",BASEURL="",timeStamp="",gspAuthString="",gspAuthSignature="";
GSPSignature gspSignature =null;
PrivateKey aspPrivateKey = null;
String gstrIRNdata="";
byte[] respJsonInBytes=null;
JSONObject gstIRNObj =null,object=null,gstIRNObjAdd=null,gstIRNObjPadd=null;
try
{
conn = getConnection();
......@@ -162,6 +190,172 @@ public class CustomerDetails extends ValidatorEJB
custList.add(checkNull(rs.getString("WAVE_TYPE")));
custList.add(checkNull(rs.getString("PAY_AMOUNT")));
custList.add(checkNull(rs.getString("GST_TAX_REG")));
gstin=rs.getString("GST_TAX_REG");
if(gstin != null && gstin.trim().length() > 0)
{
finCommon = new FinCommon();
aesEncryption = new AESEncryption();
gspTokenTimeStampFormat = finCommon.getFinparams("999999", "GSP_TKN_TIMSTMP_FRMT", conn);
gspTokenTimeFormatter = new SimpleDateFormat(gspTokenTimeStampFormat);
appKey = UUID.randomUUID().toString().replaceAll("-", "");
appKey = appKey.substring(appKey.length() - 32, appKey.length());
gspPrivateKeyName = finCommon.getFinparams("999999", "GSP_PRI_KEY_NAME", conn);
gspSignature = new GSPSignature();
privateKeyPath = CommonConstants.JBOSSHOME + File.separator + "server" + File.separator
+ "default/deploy/ibase.ear/ibase.war/webitm/resource/gst" + File.separator
+ gspPrivateKeyName + ".pem";
clientId = finCommon.getFinparams("999999", "GST_CLIENT_ID", conn);
aspPrivateKey = gspSignature.loadPrivateKey(new FileInputStream(privateKeyPath));
sql = "SELECT SERVICE_CODE, SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE METHOD_NAME = 'EINVOICE_API_URL'";
pstmt1 = conn.prepareStatement(sql);
rs1 = pstmt1.executeQuery();
while (rs1.next()) {
switch (rs1.getString("SERVICE_CODE")) {
case "gstin_detail_url": {
BASEURL = rs1.getString("SERVICE_URI");
}
break;
}
}
if (pstmt1 != null) {
pstmt1.close();
pstmt1 = null;
}
if (rs1 != null) {
rs1.close();
rs1 = null;
}
timeStamp = gspTokenTimeFormatter.format(new Date());
gspAuthString = "v2.0::" + clientId + ":" + appKey + ":" + timeStamp + ":" + gstin + ":";
gspAuthSignature = gspSignature.sign(gspAuthString, aspPrivateKey);
HttpRequest genIRNReq = Unirest.get(BASEURL + gstin)
.header("Content-Type", "application/json")
.header("Gstin", gstin)
.header("X-Asp-Auth-Token", gspAuthString)
.header("X-Asp-Auth-Signature", gspAuthSignature)
.getHttpRequest();
System.out.println("authtoken url[" + genIRNReq.getUrl() + "]");
System.out.println("authtoken method[" + genIRNReq.getHttpMethod() + "]");
System.out.println("authtoken request header[" + genIRNReq.getHeaders() + "]");
HttpResponse<JsonNode> genIRNRes = genIRNReq.asJson();
System.out.println(String.format("authTokenResp Request : Status[%s] Response[%s]",
genIRNRes.getStatus(), genIRNRes.getBody()));
if (genIRNRes.getStatus() == 200) {
object = genIRNRes.getBody().getObject();
if (object.has("data")) {
gstrIRNdata = object.getString("data");
respJsonInBytes = aesEncryption.decodeBase64StringTOByte(gstrIRNdata);
gstIRNObj = new JSONObject(new String(respJsonInBytes));
//System.out.println("rgdt response:" + gstIRNObj.getString("rgdt"));
if(gstIRNObj.has("rgdt"))
{
custList.add(gstIRNObj.getString("rgdt"));//19
}
else
{
custList.add("");
}
//System.out.println("tradeNam response:" + gstIRNObj.getString("tradeNam"));
if(gstIRNObj.has("tradeNam"))
{
custList.add(gstIRNObj.getString("tradeNam"));//20
}
else
{
custList.add("");
}
//System.out.println("sts response:" + gstIRNObj.getString("sts"));
if(gstIRNObj.has("sts"))
{
custList.add(gstIRNObj.getString("sts"));//21
}
else
{
custList.add("");
}
//System.out.println("dty response:" + gstIRNObj.getString("dty"));
if(gstIRNObj.has("dty"))
{
custList.add(gstIRNObj.getString("dty"));//22
}
else
{
custList.add("");
}
if(gstIRNObj.has("pradr"))
{
gstIRNObjPadd = new JSONObject();
gstIRNObjPadd=gstIRNObj.getJSONObject("pradr");
if(gstIRNObjPadd.has("addr"))
{
gstIRNObjAdd = gstIRNObjPadd.getJSONObject("addr");
custList.add(gstIRNObjAdd.getString("stcd"));//23
}
else
{
custList.add("");
}
}
else
{
custList.add("");
}
}
else
{
custList.add("");
custList.add("");
custList.add("");
custList.add("");
custList.add("");
}
}
else
{
custList.add("");
custList.add("");
custList.add("");
custList.add("");
custList.add("");
}
}
else
{
custList.add("");
custList.add("");
custList.add("");
custList.add("");
custList.add("");
}
isExists = true;
}
if(!isExists)
......@@ -185,6 +379,12 @@ public class CustomerDetails extends ValidatorEJB
custList.add("");
custList.add("");
custList.add("");
//added by nandkumar gadkari on 25-02-20
custList.add("");
custList.add("");
custList.add("");
custList.add("");
custList.add("");
}
if (rs != 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