Skip to content

Commit 6971d6e

Browse files
sriranjan-ssriranjan-s
sriranjan-s
authored and
sriranjan-s
committed
reverted code changes
1 parent 937c8db commit 6971d6e

File tree

20 files changed

+423
-155
lines changed

20 files changed

+423
-155
lines changed

business-services/billing-service/src/main/java/org/egov/demand/service/BillServicev2.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ public BillResponseV2 fetchBill(GenerateBillCriteria billCriteria, RequestInfoWr
239239
log.info( "If bills are empty" +bills.size());
240240
//if(!billCriteria.getBusinessService().equalsIgnoreCase("WS") && !billCriteria.getBusinessService().equalsIgnoreCase("SW"))
241241
//if(!billCriteria.getBusinessService().equalsIgnoreCase("SW"))
242+
if(!billCriteria.getBusinessService().equalsIgnoreCase("BPA.NC_SAN_FEE"))
242243
updateDemandsForexpiredBillDetails(billCriteria.getBusinessService(), billCriteria.getConsumerCode(), billCriteria.getTenantId(), requestInfoWrapper);
243244
return generateBill(billCriteria, requestInfo);
244245
}
@@ -379,7 +380,7 @@ public BillResponseV2 generateBill(GenerateBillCriteria billCriteria, RequestInf
379380
consumerCodes.addAll(billCriteria.getConsumerCode());
380381

381382
DemandCriteria demandCriteria=new DemandCriteria();
382-
if(billCriteria.getBusinessService().equalsIgnoreCase("WS") || billCriteria.getBusinessService().equalsIgnoreCase("SW"))
383+
if(billCriteria.getBusinessService().equalsIgnoreCase("WS") || billCriteria.getBusinessService().equalsIgnoreCase("SW") || billCriteria.getBusinessService().equalsIgnoreCase("BPA.NC_SAN_FEE"))
383384
demandCriteria = DemandCriteria.builder()
384385
.status(org.egov.demand.model.Demand.StatusEnum.ACTIVE.toString())
385386
.businessService(billCriteria.getBusinessService())
@@ -761,4 +762,4 @@ public static List<String> getOwnerFieldsPlainAccessList() {
761762
return ownerPlainRequestFieldsList;
762763
}
763764

764-
}
765+
}

core-services/egov-workflow-v2/src/main/java/org/egov/wf/repository/EscalationRepository.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
import org.springframework.jdbc.core.SingleColumnRowMapper;
99
import org.springframework.stereotype.Component;
1010

11+
import lombok.extern.slf4j.Slf4j;
12+
1113
import java.util.ArrayList;
1214
import java.util.LinkedList;
1315
import java.util.List;
1416

1517
@Component
18+
@Slf4j
1619
public class EscalationRepository {
1720

1821

@@ -43,6 +46,8 @@ public List<String> getBusinessIds(EscalationSearchCriteria criteria){
4346
else {
4447
query = queryBuilder.getEscalationQuery(criteria, preparedStmtList);
4548
}
49+
log.info("query is"+query);
50+
log.info("params are " +preparedStmtList.toString());
4651
List<String> businessIds = jdbcTemplate.query(query, preparedStmtList.toArray(), new SingleColumnRowMapper<>(String.class));
4752
return businessIds;
4853

@@ -67,4 +72,4 @@ public List<String> getBusinessSMSIds(EscalationSearchCriteria criteria,List<Str
6772
}
6873

6974

70-
}
75+
}

core-services/egov-workflow-v2/src/main/java/org/egov/wf/repository/querybuilder/EscalationQueryBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public String getEscalationQuery(EscalationSearchCriteria criteria, List<Object>
4343
preparedStmtList.add(criteria.getStatus());
4444

4545
if(criteria.getStateSlaExceededBy() != null){
46-
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime - wf.statesla > ? ");
46+
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime > ? ");
4747
preparedStmtList.add(criteria.getStateSlaExceededBy());
4848
}
4949

5050
if(criteria.getBusinessSlaExceededBy() != null){
51-
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime - wf.businessservicesla > ? ");
51+
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime > ? ");
5252
preparedStmtList.add(criteria.getBusinessSlaExceededBy());
5353
}
5454

@@ -92,7 +92,7 @@ public String getEscalationQueryFiltered(EscalationSearchCriteria criteria,List<
9292
}
9393

9494
if(criteria.getBusinessSlaExceededBy() != null){
95-
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime - wf.businessservicesla > ? ");
95+
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime > ? ");
9696
preparedStmtList.add(criteria.getBusinessSlaExceededBy());
9797
}
9898

@@ -134,4 +134,4 @@ public String getSMSQueryFiltered(EscalationSearchCriteria criteria,List<String>
134134
}
135135

136136

137-
}
137+
}

core-services/egov-workflow-v2/src/main/java/org/egov/wf/service/EscalationService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ private void processEscalation(RequestInfo requestInfo, Escalation escalation, L
123123
Integer numberOfBusinessIds = businessIds.size();
124124
Integer batchSize = config.getEscalationBatchSize();
125125

126+
log.info("Records to process"+numberOfBusinessIds);
127+
126128
for(int i = 0; i < numberOfBusinessIds; i = i + batchSize){
127129

128130
// Processing the businessIds in batches
@@ -249,4 +251,4 @@ private void triggerSMS(RequestInfo requestInfo, Escalation escalation, List<Str
249251
}
250252

251253

252-
}
254+
}

core-services/egov-workflow-v2/src/test/java/org/egov/wf/repository/querybuilder/EscalationQueryBuilderTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ void testGetEscalationQuery() {
3535
"select businessId from ( SELECT *,RANK () OVER (PARTITION BY businessId ORDER BY createdtime DESC)"
3636
+ " rank_number FROM eg_wf_processinstance_v2 WHERE businessservice = ? AND tenantid= ? ) wf WHERE"
3737
+ " rank_number = 1 AND wf.status = ? AND (select extract(epoch from current_timestamp)) * 1000 -"
38-
+ " wf.createdtime - wf.statesla > ? AND (select extract(epoch from current_timestamp)) * 1000 -"
39-
+ " wf.createdtime - wf.businessservicesla > ? ",
38+
+ " wf.createdtime > ? AND (select extract(epoch from current_timestamp)) * 1000 -"
39+
+ " wf.createdtime > ? ",
4040
this.escalationQueryBuilder.getEscalationQuery(escalationSearchCriteria, objectList));
4141
verify(escalationSearchCriteria, atLeast(1)).getBusinessSlaExceededBy();
4242
verify(escalationSearchCriteria, atLeast(1)).getStateSlaExceededBy();
@@ -60,7 +60,7 @@ void testGetEscalationQuerywithstatesla() {
6060
"select businessId from ( SELECT *,RANK () OVER (PARTITION BY businessId ORDER BY createdtime DESC)"
6161
+ " rank_number FROM eg_wf_processinstance_v2 WHERE businessservice = ? AND tenantid= ? ) wf WHERE"
6262
+ " rank_number = 1 AND wf.status = ? AND (select extract(epoch from current_timestamp)) * 1000 -"
63-
+ " wf.createdtime - wf.statesla > ? ",
63+
+ " wf.createdtime > ? ",
6464
this.escalationQueryBuilder.getEscalationQuery(escalationSearchCriteria, objectList));
6565
verify(escalationSearchCriteria).getBusinessSlaExceededBy();
6666
verify(escalationSearchCriteria, atLeast(1)).getStateSlaExceededBy();
@@ -83,7 +83,7 @@ void testGetEscalationQuerywithbusinessservicesla() {
8383
"select businessId from ( SELECT *,RANK () OVER (PARTITION BY businessId ORDER BY createdtime DESC)"
8484
+ " rank_number FROM eg_wf_processinstance_v2 WHERE businessservice = ? AND tenantid= ? ) wf WHERE"
8585
+ " rank_number = 1 AND wf.status = ? AND (select extract(epoch from current_timestamp)) * 1000 -"
86-
+ " wf.createdtime - wf.businessservicesla > ? ",
86+
+ " wf.createdtime > ? ",
8787
this.escalationQueryBuilder.getEscalationQuery(escalationSearchCriteria, objectList));
8888
verify(escalationSearchCriteria, atLeast(1)).getBusinessSlaExceededBy();
8989
verify(escalationSearchCriteria).getStateSlaExceededBy();
@@ -93,4 +93,3 @@ void testGetEscalationQuerywithbusinessservicesla() {
9393
assertEquals(4, objectList.size());
9494
}
9595
}
96-

dx-services/requester-services-dx/src/main/java/org/egov/dx/service/eSignService.java

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,43 @@
88
import java.net.HttpURLConnection;
99
import java.net.URL;
1010
import java.net.URLDecoder;
11-
import java.nio.charset.StandardCharsets;
12-
import java.nio.file.Files;
13-
import java.nio.file.Paths;
1411
import java.util.ArrayList;
1512
import java.util.Base64;
1613
import javax.servlet.ServletException;
1714
import javax.servlet.http.HttpServletRequest;
1815
import javax.servlet.http.HttpServletResponse;
19-
import javax.validation.Valid;
2016
import javax.xml.xpath.XPath;
2117
import javax.xml.xpath.XPathFactory;
2218

2319
import org.egov.dx.util.Configurations;
2420
import org.egov.dx.util.Utilities;
25-
21+
import org.egov.dx.web.models.FileResponse;
2622
import org.egov.dx.web.models.RequestInfoWrapper;
2723
import org.springframework.beans.factory.annotation.Autowired;
24+
import org.springframework.http.HttpHeaders;
2825
import org.springframework.http.HttpStatus;
2926
import org.springframework.http.ResponseEntity;
3027
import org.springframework.stereotype.Service;
3128
import org.springframework.web.client.RestTemplate;
29+
import org.springframework.web.util.UriComponentsBuilder;
3230
import org.w3c.dom.Document;
3331

3432
import com.emudhra.esign.ReturnDocument;
3533
import com.emudhra.esign.eSign;
3634
import com.emudhra.esign.eSignInput;
3735
import com.emudhra.esign.eSignInputBuilder;
3836
import com.emudhra.esign.eSignServiceReturn;
37+
import com.google.gson.Gson;
3938

39+
import lombok.extern.slf4j.Slf4j;
40+
import okhttp3.MediaType;
41+
import okhttp3.MultipartBody;
42+
import okhttp3.OkHttpClient;
43+
import okhttp3.Request;
44+
import okhttp3.RequestBody;
4045

4146
@Service
47+
@Slf4j
4248
public class eSignService {
4349

4450
@Autowired
@@ -85,7 +91,7 @@ public String processPDF(RequestInfoWrapper requestInfoWrapper) throws IOExcepti
8591
.setSignedBy("Manvi") //(mandatory)
8692
.setCoSign(true)
8793
.setAppearanceType(eSign.AppearanceType.StandardSignature)
88-
.setPageTobeSigned(eSign.PageTobeSigned.Even)
94+
.setPageTobeSigned(eSign.PageTobeSigned.First)
8995
.setCoordinates(eSign.Coordinates.TopLeft)
9096
.build();
9197

@@ -118,6 +124,9 @@ public String getEsignedPDF(HttpServletRequest request, HttpServletResponse resp
118124
InputStream xmlStream;
119125
String xml = "";
120126
String txnref = null;
127+
byte[] signedBytes = null;
128+
String pdfPath=null;
129+
121130
try {
122131
// Get response from gateway
123132
xmlStream = request.getInputStream();
@@ -127,21 +136,20 @@ public String getEsignedPDF(HttpServletRequest request, HttpServletResponse resp
127136

128137
String txn = new String(java.util.Base64.getDecoder().decode(txns.getBytes()));
129138
String[] strArr = txn.split("\\|");
130-
String txnid = strArr[0];
131-
132-
eSign eSign = new eSign(configurations.getLicenceFile(), configurations.getPfxPath(), configurations.getPfxPassword(), configurations.getPfxAllias());
133-
eSignServiceReturn returnService = eSign.getStatus(txnid);
134-
xml = returnService.getResponseXML();
139+
String txnId = strArr[0];
140+
141+
String xmlString = URLDecoder.decode(txnref);
142+
xml = xmlString.split("&XML=")[1];
135143

136144
Document doc = Utilities.convertStringToDocument(xml);
137145

138146
XPath xPath = XPathFactory.newInstance().newXPath();
139147
String status = Utilities.GetXpathValue(xPath, "/EsignResp/@status", doc);
140-
String txnId = Utilities.GetXpathValue(xPath, "/EsignResp/@txn", doc);
141-
148+
txnId = Utilities.GetXpathValue(xPath, "/EsignResp/@txn", doc);
142149
if ("1".equals(status)) {
143150

144151
// complete signing
152+
eSign eSign = new eSign(configurations.getLicenceFile(), configurations.getPfxPath(), configurations.getPfxPassword(), configurations.getPfxAllias());
145153
eSignServiceReturn serviceReturn = eSign.getSigedDocument(xml, configurations.getTempFolder() + File.separator + txnId + ".sig");
146154

147155
// To convert signed pdf from base 64 encoded string to pdf file
@@ -150,8 +158,10 @@ public String getEsignedPDF(HttpServletRequest request, HttpServletResponse resp
150158
int i = 0;
151159
for (ReturnDocument returnDocument : returnDocuments) {
152160
String pdfBase64 = returnDocument.getSignedDocument();
153-
byte[] signedBytes = esign.text.pdf.codec.Base64.decode(pdfBase64);
154-
String pdfPath = configurations.getOutputFolder() + File.separator + txnId + "_" + i + ".pdf";
161+
System.out.println("Print" +pdfBase64);
162+
signedBytes = esign.text.pdf.codec.Base64.decode(pdfBase64);
163+
pdfPath = configurations.getOutputFolder() + File.separator + txnId + "_" + i + ".pdf";
164+
//String pdfPath = configurations.getS3Bucket() + File.separator + txnId + "_" + i + ".pdf";
155165
try (FileOutputStream fos = new FileOutputStream(pdfPath)) {
156166
fos.write(signedBytes);
157167
}
@@ -162,10 +172,31 @@ public String getEsignedPDF(HttpServletRequest request, HttpServletResponse resp
162172
} catch (Exception e) {
163173
e.printStackTrace();
164174
}
165-
return ("Document Signed and saved successfully");
166175

176+
177+
OkHttpClient client = new OkHttpClient().newBuilder()
178+
.build();
179+
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
180+
.addFormDataPart("tenantId","pg")
181+
.addFormDataPart("module","TL")
182+
.addFormDataPart("file",pdfPath,
183+
RequestBody.create(MediaType.parse("application/pdf"),
184+
new File(pdfPath)))
185+
.build();
186+
Request request1 = new Request.Builder()
187+
.url("https://upyog-test.niua.org/filestore/v1/files")
188+
.method("POST", body)
189+
.addHeader("Content-Type", "multipart/form-data; boundary=----WebKitFormBoundaryf04Aqi5zqaexyYxK")
190+
.build();
191+
192+
String responsee = client.newCall(request1).execute().body().string();
193+
log.info(responsee);
194+
Gson gson = new Gson();
195+
FileResponse files = gson.fromJson(responsee , FileResponse.class);
196+
197+
return files.getFiles().get(0).getFileStoreId();
167198

168199
}
169200

170201

171-
}
202+
}

dx-services/requester-services-dx/src/main/java/org/egov/dx/util/Configurations.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,16 @@ public class Configurations {
9090
@Value("${esign.outputfolder}")
9191
private String outputFolder;
9292

93-
}
93+
@Value("${esign.UIURL}")
94+
private String uIURL;
95+
96+
// @Value("${esign.tlredirecturl}")
97+
// private String tlRedirectUrl;
98+
99+
// @Value("${eSign.s3bucket}")
100+
// private String s3Bucket;
101+
//
102+
// @Value("${api.documenthost}")
103+
// private String documentHost;
104+
105+
}

dx-services/requester-services-dx/src/main/java/org/egov/dx/web/controller/EsignController.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,31 @@
4040

4141
package org.egov.dx.web.controller;
4242

43+
import java.io.ByteArrayInputStream;
4344
import java.io.IOException;
4445
import java.net.URISyntaxException;
4546

4647
import javax.servlet.ServletException;
4748
import javax.servlet.http.HttpServletRequest;
4849
import javax.servlet.http.HttpServletResponse;
4950
import javax.validation.Valid;
50-
51+
import org.springframework.http.MediaType;
5152
import org.egov.common.contract.request.RequestInfo;
5253
import org.egov.dx.service.eSignService;
54+
import org.egov.dx.util.Configurations;
5355
import org.egov.dx.web.models.ResponseInfoFactory;
5456
import org.egov.dx.web.models.RequestInfoWrapper;
5557
import org.springframework.beans.factory.annotation.Autowired;
58+
import org.springframework.http.HttpHeaders;
5659
import org.springframework.http.HttpStatus;
5760
import org.springframework.http.ResponseEntity;
5861
import org.springframework.web.bind.annotation.RequestBody;
5962
import org.springframework.web.bind.annotation.RequestMapping;
6063
import org.springframework.web.bind.annotation.RequestParam;
6164
import org.springframework.web.bind.annotation.RestController;
65+
import org.springframework.web.multipart.MultipartFile;
66+
import org.springframework.web.util.UriComponentsBuilder;
67+
6268

6369
import lombok.extern.slf4j.Slf4j;
6470

@@ -76,6 +82,9 @@ public class EsignController {
7682
@Autowired
7783
eSignService esignService;
7884

85+
@Autowired
86+
Configurations configurations;
87+
7988
@RequestMapping("/process")
8089
public ResponseEntity<String> processPDF(@Valid @RequestBody RequestInfoWrapper requestInfoWrapper) throws URISyntaxException {
8190
try {
@@ -86,13 +95,25 @@ public ResponseEntity<String> processPDF(@Valid @RequestBody RequestInfoWrapper
8695
}
8796
}
8897
@RequestMapping("/redirect")
89-
public ResponseEntity<String> getEsignedPDF(HttpServletRequest request, HttpServletResponse response) throws ServletException {
98+
public ResponseEntity<Object> getEsignedPDF(HttpServletRequest request, HttpServletResponse response) throws ServletException {
9099
try {
91-
String responseUrl = esignService.getEsignedPDF( request, response);
92-
return new ResponseEntity<>(responseUrl, HttpStatus.OK);
100+
//byte[] byteArray = esignService.getEsignedPDF( request, response);
101+
102+
String ff = esignService.getEsignedPDF( request, response);
103+
104+
HttpHeaders httpHeaders = new HttpHeaders();
105+
// httpHeaders.add(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=report.pdf");
106+
// httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PDF_VALUE);
107+
StringBuilder redirectURL = new StringBuilder();
108+
redirectURL.append(configurations.getUIURL()+"?filestore="+ff);
109+
httpHeaders.setLocation(UriComponentsBuilder.fromHttpUrl(redirectURL.toString())
110+
.queryParams(null).build().encode().toUri());
111+
return new ResponseEntity<>(httpHeaders, HttpStatus.FOUND);
112+
113+
93114
} catch (IOException e) {
94-
return new ResponseEntity<>("Error processing PDF: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
115+
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
95116
}
96117
}
97118
}
98-
119+

0 commit comments

Comments
 (0)