Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #900 from egovernments/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pradeepkumarcm-egov authored Aug 9, 2024
2 parents 7a3e5a1 + 4373e28 commit eeaf673
Show file tree
Hide file tree
Showing 82 changed files with 3,863 additions and 752 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ public class AggregatedDemandDetailResponse {

private BigDecimal currentmonthTotalDue;

private BigDecimal currentmonthRoundOff;

private BigDecimal totalAreas;

private BigDecimal totalAreasWithPenalty;

private BigDecimal totalAreasRoundOff;

private BigDecimal netdue;

private BigDecimal netDueWithPenalty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,19 +720,29 @@ public int compare(Demand d1, Demand d2) {
BigDecimal netdue = BigDecimal.ZERO;
BigDecimal netDueWithPenalty = BigDecimal.ZERO;
BigDecimal totalApplicablePenalty =BigDecimal.ZERO;
BigDecimal currentmonthRoundOff=BigDecimal.ZERO;
BigDecimal totalAreasRoundOff=BigDecimal.ZERO;

currentmonthBill = currentMonthDemandDetailList.stream()
.filter(dd -> dd.getTaxHeadMasterCode().equals("10101")) // filter by taxHeadCode
.map(dd -> dd.getTaxAmount().subtract(dd.getCollectionAmount())) // map to the balance between taxAmount and collectedAmount
.reduce(BigDecimal.ZERO, BigDecimal::add);

currentmonthRoundOff = currentMonthDemandDetailList.stream()
.filter(dd -> dd.getTaxHeadMasterCode().equals("WS_Round_Off")) // filter by taxHeadCode
.map(dd -> dd.getTaxAmount().subtract(dd.getCollectionAmount())) // map to the balance between taxAmount and collectedAmount
.reduce(BigDecimal.ZERO, BigDecimal::add);
log.info("currentmonthRoundOff::::"+currentmonthRoundOff);

log.info("currentMonthDemandDetailList::::"+currentMonthDemandDetailList);
currentMonthPenalty = currentMonthDemandDetailList.stream()
.filter(dd -> dd.getTaxHeadMasterCode().equals("WS_TIME_PENALTY")) // filter by taxHeadCode
.map(dd -> dd.getTaxAmount().subtract(dd.getCollectionAmount())) // map to the balance between taxAmount and collectedAmount
.reduce(BigDecimal.ZERO, BigDecimal::add);
log.info("currentMonthDemandDetailListafter::::"+currentMonthDemandDetailList);
log.info("currentMonthPenalty" + currentMonthPenalty);
currentmonthTotalDue = currentmonthBill.add(currentMonthPenalty);
currentmonthTotalDue = currentmonthBill.add(currentMonthPenalty).add(currentmonthRoundOff);
log.info("currentmonthTotalDue" + currentmonthTotalDue);
if(currentMonthPenalty.equals(BigDecimal.ZERO)) {
List<MasterDetail> masterDetails = new ArrayList<>();
MasterDetail masterDetail = new MasterDetail("Penalty", "[?(@)]");
Expand All @@ -759,7 +769,13 @@ public int compare(Demand d1, Demand d2) {


//Tax headcode for WScharges,legacypenalty,legacyarea
List<String> taxHeadCodesToFilterWithoutPenalty = Arrays.asList("10102", "10201", "10101");
List<String> taxHeadCodesToFilterWithoutPenalty = Arrays.asList("10102", "10201", "10101","WS_Round_Off");

// Initialize the variable for the sum of taxAmount - collectedAmount specifically for WS_Round_Off
totalAreasRoundOff = remainingMonthDemandDetailList.stream()
.filter(dd -> "WS_Round_Off".equals(dd.getTaxHeadMasterCode())) // Filter specifically for WS_Round_Off
.map(dd -> dd.getTaxAmount().subtract(dd.getCollectionAmount())) // Calculate taxAmount - collectedAmount
.reduce(BigDecimal.ZERO, BigDecimal::add); // Sum all results

// Initialize the variable for the sum of taxAmount - collectedAmount for the filtered tax head codes
totalAreas = remainingMonthDemandDetailList.stream()
Expand Down Expand Up @@ -799,7 +815,7 @@ public int compare(Demand d1, Demand d2) {
if(remainingAdvance !=BigDecimal.ZERO && currentmonthBill !=BigDecimal.ZERO && advanceAdjusted.equals(BigDecimal.ZERO)) {
}

netdue = currentmonthBill.add(totalAreas).add(remainingAdvance);
netdue = currentmonthBill.add(totalAreas).add(remainingAdvance).add(currentmonthRoundOff);
netDueWithPenalty = currentmonthTotalDue.add(totalAreasWithPenalty).add(remainingAdvance);

//BigDecimal currentMonthBill
Expand All @@ -808,8 +824,10 @@ public int compare(Demand d1, Demand d2) {
.currentmonthBill(currentmonthBill)
.currentMonthPenalty(currentMonthPenalty)
.currentmonthTotalDue(currentmonthTotalDue)
.currentmonthRoundOff(currentmonthRoundOff)
.totalAreas(totalAreas)
.totalAreasWithPenalty(totalAreasWithPenalty)
.totalAreasRoundOff(totalAreasRoundOff)
.netdue(netdue)
.netDueWithPenalty(netDueWithPenalty)
.advanceAdjusted(advanceAdjusted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

import javax.net.ssl.*;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

@SpringBootApplication
@ComponentScan(basePackages = { "org.egov.hrms", "org.egov.hrms.web.controllers" , "org.egov.hrms.config"})
@Import(TracerConfiguration.class)
Expand All @@ -76,7 +80,36 @@ public ObjectMapper getObjectMapper() {
return objectMapper;
}

public static void trustSelfSignedSSL() {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException {
}

public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException {
}

public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
ctx.init(null, new TrustManager[]{tm}, null);
SSLContext.setDefault(ctx);

// Disable hostname verification
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
return true;
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}

public static void main(String[] args) {
trustSelfSignedSSL();
SpringApplication.run(EgovEmployeeApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,39 @@ public class PropertiesManager {

@Value("${egov.hrms.max.pagination.limit}")
public Integer hrmsMaxLimit;

// FuzzyConfigs
@Value("${hrms.search.pagination.default.limit}")
public Long defaultLimit;

@Value("${hrms.search.pagination.default.offset}")
public Long defaultOffset;

@Value("${hrms.search.pagination.max.search.limit}")
public Long searchLimit;

@Value("${hrms.search.pagination.max.search.limit}")
private Long maxSearchLimit;

@Value("${hrms.fuzzy.search.is.wildcard}")
private Boolean isSearchWildcardBased;

@Value("${hrms.search.name.fuziness}")
private String nameFuziness;

// es configs
@Value("${elasticsearch.host}")
private String esHost;

@Value("${hrms.es.index}")
private String esPTIndex;

@Value("${elasticsearch.search.endpoint}")
private String esSearchEndpoint;

@Value("${egov.es.username}")
private String userName;

@Value("${egov.es.password}")
private String password;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package org.egov.hrms.repository;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.egov.hrms.config.PropertiesManager;
import org.egov.hrms.web.contract.EmployeeSearchCriteria;
import org.egov.tracer.model.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Repository;
import org.springframework.web.client.RestTemplate;

import java.util.Base64;
import java.util.List;

@Slf4j
@Repository
public class ElasticSearchRepository {
private PropertiesManager config;

private FuzzySearchQueryBuilder queryBuilder;

private RestTemplate restTemplate;

private ObjectMapper mapper;

@Autowired
public ElasticSearchRepository(PropertiesManager config, FuzzySearchQueryBuilder queryBuilder, RestTemplate restTemplate, ObjectMapper mapper) {
this.config = config;
this.queryBuilder = queryBuilder;
this.restTemplate = restTemplate;
this.mapper = mapper;
}

public Object fuzzySearchEmployees(EmployeeSearchCriteria criteria, List<String> uuids) {


String url = getESURL();

String searchQuery = queryBuilder.getFuzzySearchQuery(criteria, uuids);

HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", getESEncodedCredentials());
headers.setContentType(MediaType.APPLICATION_JSON);
log.info("Headers: " + headers.toString());
HttpEntity<String> requestEntity = new HttpEntity<>(searchQuery, headers);
ResponseEntity response = null;
try {
response = restTemplate.postForEntity(url, requestEntity, Object.class);

} catch (Exception e) {
e.printStackTrace();
throw new CustomException("ES_ERROR","Failed to fetch data from ES");
}

return response.getBody();

}


/**
* Generates elasticsearch search url from application properties
*
* @return
*/
private String getESURL() {

StringBuilder builder = new StringBuilder(config.getEsHost());
builder.append(config.getEsPTIndex());
builder.append(config.getEsSearchEndpoint());

return builder.toString();
}

public String getESEncodedCredentials() {
String credentials = config.getUserName() + ":" + config.getPassword();
byte[] credentialsBytes = credentials.getBytes();
byte[] base64CredentialsBytes = Base64.getEncoder().encode(credentialsBytes);
return "Basic " + new String(base64CredentialsBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public String paginationClause(EmployeeSearchCriteria criteria, StringBuilder bu
pagination = pagination.replace("$offset", "0");

if(null != criteria.getLimit()){
Integer limit = criteria.getLimit() + criteria.getOffset();
Long limit = criteria.getLimit() + criteria.getOffset();
pagination = pagination.replace("$limit", limit.toString());
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public List<Employee> fetchEmployees(EmployeeSearchCriteria criteria, RequestInf
return employees;
}

private List<String> fetchEmployeesforAssignment(EmployeeSearchCriteria criteria, RequestInfo requestInfo) {
public List<String> fetchEmployeesforAssignment(EmployeeSearchCriteria criteria, RequestInfo requestInfo) {
List<String> employeesIds = new ArrayList<>();
List <Object> preparedStmtList = new ArrayList<>();
String query = queryBuilder.getAssignmentSearchQuery(criteria, preparedStmtList);
Expand Down
Loading

0 comments on commit eeaf673

Please sign in to comment.