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

Commit

Permalink
Browse files Browse the repository at this point in the history
…seva into ISTE-141
  • Loading branch information
Hari-egov committed May 28, 2024
2 parents 4e4ad1f + 27abfaf commit f89216f
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,10 @@ public class WSCalculationConfiguration {

@Value("${sms.exclude.tenant}")
private String smsExcludeTenant;


@Value("${is.save.demand.audit.enabled}")
private boolean isSaveDemandAuditEnabled;

@Value("${egov.save.demand.audit.from.wscal}")
private String saveDemandAudit;
}
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t
}

} catch (Exception e) {
System.out.println("Got the exception while genating the demands:" + connectionNo);
System.out.println("Got the exception while genating the demands:" + e);
failedConnectionNos.add(connectionNo);
}
}
Expand Down Expand Up @@ -462,14 +462,12 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t
String msgLink = config.getNotificationUrl() + config.getGpUserDemandLink();

for (OwnerInfo userInfo : userDetailResponse.getUser()) {
log.info("USER NUMBER:" + userInfo.getMobileNumber() + " USER ROLE:" + userInfo.getRoles());
if (userInfo.getName() != null) {
mobileNumberIdMap.put(userInfo.getMobileNumber(), userInfo.getName());
} else {
mobileNumberIdMap.put(userInfo.getMobileNumber(), userInfo.getUserName());
}
}
log.info("MOBILENUMBER MAPPINNG USERROLE:" +mobileNumberIdMap);
mobileNumberIdMap.entrySet().stream().forEach(map -> {
String msg = demandMessage.get(WSCalculationConstant.MSG_KEY);
msg = msg.replace("{ownername}", map.getValue());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.egov.wscalculation.repository;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

@Component
@Slf4j
@Repository
public class DemandAuditSeqBuilder {

@Autowired
private JdbcTemplate jdbcTemplate;

public static final String SELECT_NEXT_SEQUENCE_USER = "select nextval('seq_eg_ws_demand_auditchange')";

public Long getNextSequence() {
return jdbcTemplate.queryForObject(SELECT_NEXT_SEQUENCE_USER, Long.class);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.egov.wscalculation.config.WSCalculationConfiguration;
import org.egov.wscalculation.constants.WSCalculationConstant;
import org.egov.wscalculation.producer.WSCalculationProducer;
import org.egov.wscalculation.repository.DemandAuditSeqBuilder;
import org.egov.wscalculation.repository.DemandRepository;
import org.egov.wscalculation.repository.ServiceRequestRepository;
import org.egov.wscalculation.repository.WSCalculationDao;
Expand All @@ -51,26 +52,8 @@
import org.egov.wscalculation.util.WSCalculationUtil;
import org.egov.wscalculation.validator.WSCalculationValidator;
import org.egov.wscalculation.validator.WSCalculationWorkflowValidator;
import org.egov.wscalculation.web.models.BulkDemand;
import org.egov.wscalculation.web.models.Calculation;
import org.egov.wscalculation.web.models.Category;
import org.egov.wscalculation.web.models.Demand;
import org.egov.wscalculation.web.models.*;
import org.egov.wscalculation.web.models.Demand.StatusEnum;
import org.egov.wscalculation.web.models.DemandDetail;
import org.egov.wscalculation.web.models.DemandDetailAndCollection;
import org.egov.wscalculation.web.models.DemandPenaltyResponse;
import org.egov.wscalculation.web.models.DemandRequest;
import org.egov.wscalculation.web.models.DemandResponse;
import org.egov.wscalculation.web.models.GetBillCriteria;
import org.egov.wscalculation.web.models.OwnerInfo;
import org.egov.wscalculation.web.models.Property;
import org.egov.wscalculation.web.models.Recipient;
import org.egov.wscalculation.web.models.RequestInfoWrapper;
import org.egov.wscalculation.web.models.SMSRequest;
import org.egov.wscalculation.web.models.TaxHeadEstimate;
import org.egov.wscalculation.web.models.TaxPeriod;
import org.egov.wscalculation.web.models.WaterConnection;
import org.egov.wscalculation.web.models.WaterConnectionRequest;
import org.egov.wscalculation.web.models.users.UserDetailResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -147,6 +130,9 @@ public class DemandService {
@Autowired
private EstimationService estimationService;

@Autowired
private DemandAuditSeqBuilder demandAuditSeqBuilder;

/**
* Creates or updates Demand
*
Expand Down Expand Up @@ -285,6 +271,22 @@ private List<Demand> createDemand(RequestInfo requestInfo, List<Calculation> cal
.businessService(businessService).status(StatusEnum.valueOf("ACTIVE")).billExpiryTime(expiryDate)
.build());
}

if(config.isSaveDemandAuditEnabled()){
demands.stream().forEach(demand -> {
Long id = demandAuditSeqBuilder.getNextSequence();
WsDemandChangeAuditRequest wsDemandChangeAuditRequest = WsDemandChangeAuditRequest.builder().id(id).
consumercode(demand.getConsumerCode()).
tenant_id(demand.getTenantId()).
status(demand.getStatus().toString()).
action("CREATE DEMAND BULK").
data(demand).
createdby(requestInfo.getUserInfo().getUuid()).
createdtime(System.currentTimeMillis()).build();
WsDemandChangeAuditRequestWrapper wsDemandChangeAuditRequestWrapper = WsDemandChangeAuditRequestWrapper.builder().wsDemandChangeAuditRequest(wsDemandChangeAuditRequest).build();
producer.push(config.getSaveDemandAudit(), wsDemandChangeAuditRequestWrapper);
});
}
demandRes = demandRepository.saveDemand(requestInfo, demands);
finalDemandRes.addAll(demandRes);

Expand Down Expand Up @@ -887,6 +889,21 @@ public List<Demand> updateDemands(GetBillCriteria getBillCriteria, RequestInfoWr
// Call demand update in bulk to update the interest or penalty
if(!isGetPenaltyEstimate) {
if(demandsToBeUpdated.size() > 0) {
if(config.isSaveDemandAuditEnabled()){
demandsToBeUpdated.stream().forEach(demand -> {
Long id = demandAuditSeqBuilder.getNextSequence();
WsDemandChangeAuditRequest wsDemandChangeAuditRequest = WsDemandChangeAuditRequest.builder().id(id).
consumercode(demand.getConsumerCode()).
tenant_id(demand.getTenantId()).
status(demand.getStatus().toString()).
action("UPDATE DEMAND GET PENALTY/UPDATE API").
data(demand).
createdby(demand.getAuditDetails().getCreatedBy()).
createdtime(demand.getAuditDetails().getLastModifiedTime()).build();
WsDemandChangeAuditRequestWrapper wsDemandChangeAuditRequestWrapper = WsDemandChangeAuditRequestWrapper.builder().wsDemandChangeAuditRequest(wsDemandChangeAuditRequest).build();
producer.push(config.getSaveDemandAudit(), wsDemandChangeAuditRequestWrapper);
});
}
DemandRequest request = DemandRequest.builder().demands(demandsToBeUpdated).requestInfo(requestInfo).build();
repository.fetchResult(utils.getUpdateDemandUrl(), request);
return res.getDemands();
Expand Down Expand Up @@ -946,6 +963,22 @@ private List<Demand> updateDemandForCalculation(RequestInfo requestInfo, List<Ca
.tenantId(calculation.getTenantId()).build());
});
demands.add(demand);
//TODO: write logic to enter in new table
if(config.isSaveDemandAuditEnabled()){
demands.stream().forEach(dem -> {
Long id = demandAuditSeqBuilder.getNextSequence();
WsDemandChangeAuditRequest wsDemandChangeAuditRequest = WsDemandChangeAuditRequest.builder().id(id).
consumercode(dem.getConsumerCode()).
tenant_id(dem.getTenantId()).
status(dem.getStatus().toString()).
action("UPDATE DEMAND BULK").
data(dem).
createdby(dem.getAuditDetails().getCreatedBy()).
createdtime(dem.getAuditDetails().getLastModifiedTime()).build();
WsDemandChangeAuditRequestWrapper wsDemandChangeAuditRequestWrapper = WsDemandChangeAuditRequestWrapper.builder().wsDemandChangeAuditRequest(wsDemandChangeAuditRequest).build();
producer.push(config.getSaveDemandAudit(), wsDemandChangeAuditRequestWrapper);
});
}
demandRes = demandRepository.updateDemand(requestInfo, demands);
finalDemandRes.addAll(demandRes);
List<String> billNumbers = fetchBill(demands, waterConnectionRequest.getRequestInfo());
Expand Down Expand Up @@ -1375,6 +1408,21 @@ public int compare(Demand d1, Demand d2) {
}

log.info("Updated Demand Details " + demands.toString());
if(config.isSaveDemandAuditEnabled()){
demands.stream().forEach(demand -> {
Long id = demandAuditSeqBuilder.getNextSequence();
WsDemandChangeAuditRequest wsDemandChangeAuditRequest = WsDemandChangeAuditRequest.builder().id(id).
consumercode(demand.getConsumerCode()).
tenant_id(demand.getTenantId()).
status(demand.getStatus().toString()).
action("UPDATE DEMAND APPLYADHOCTAX").
data(demand).
createdby(demand.getAuditDetails().getCreatedBy()).
createdtime(demand.getAuditDetails().getLastModifiedTime()).build();
WsDemandChangeAuditRequestWrapper wsDemandChangeAuditRequestWrapper = WsDemandChangeAuditRequestWrapper.builder().wsDemandChangeAuditRequest(wsDemandChangeAuditRequest).build();
producer.push(config.getSaveDemandAudit(), wsDemandChangeAuditRequestWrapper);
});
}
demandRepository.updateDemand(requestInfo, demands);
return calculations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,9 @@
import org.egov.wscalculation.config.WSCalculationConfiguration;
import org.egov.wscalculation.constants.WSCalculationConstant;
import org.egov.wscalculation.producer.WSCalculationProducer;
import org.egov.wscalculation.web.models.AdhocTaxReq;
import org.egov.wscalculation.web.models.BulkDemand;
import org.egov.wscalculation.web.models.Calculation;
import org.egov.wscalculation.web.models.CalculationCriteria;
import org.egov.wscalculation.web.models.CalculationReq;
import org.egov.wscalculation.web.models.Demand;
import org.egov.wscalculation.repository.DemandAuditSeqBuilder;
import org.egov.wscalculation.web.models.*;
import org.egov.wscalculation.web.models.Demand.StatusEnum;
import org.egov.wscalculation.web.models.GetBillCriteria;
import org.egov.wscalculation.web.models.TaxHeadCategory;
import org.egov.wscalculation.web.models.Property;
import org.egov.wscalculation.web.models.RequestInfoWrapper;
import org.egov.wscalculation.web.models.TaxHeadEstimate;
import org.egov.wscalculation.web.models.TaxHeadMaster;
import org.egov.wscalculation.web.models.WaterConnection;
import org.egov.wscalculation.web.models.WaterConnectionRequest;
import org.egov.wscalculation.web.models.enums.Status;
import org.egov.wscalculation.repository.DemandRepository;
import org.egov.wscalculation.repository.ServiceRequestRepository;
Expand Down Expand Up @@ -82,6 +70,9 @@ public class WSCalculationServiceImpl implements WSCalculationService {
@Autowired
private WSCalculationConfiguration config;

@Autowired
private DemandAuditSeqBuilder demandAuditSeqBuilder;

/**
* Get CalculationReq and Calculate the Tax Head on Water Charge And Estimation Charge
*/
Expand Down Expand Up @@ -127,6 +118,21 @@ public List<Calculation> getCalculation(CalculationReq request) {
.getWaterConnection().getPreviousReadingDate().longValue())) {
searchResult.get(0).setStatus(StatusEnum.CANCELLED);
isWSUpdateSMS = true;
if(config.isSaveDemandAuditEnabled()){
searchResult.stream().forEach(demand -> {
Long id = demandAuditSeqBuilder.getNextSequence();
WsDemandChangeAuditRequest wsDemandChangeAuditRequest = WsDemandChangeAuditRequest.builder().id(id).
consumercode(demand.getConsumerCode()).
tenant_id(demand.getTenantId()).
status(demand.getStatus().toString()).
action("GET CALCULATION UPDATE").
data(demand).
createdby(demand.getAuditDetails().getCreatedBy()).
createdtime(demand.getAuditDetails().getLastModifiedTime()).build();
WsDemandChangeAuditRequestWrapper wsDemandChangeAuditRequestWrapper = WsDemandChangeAuditRequestWrapper.builder().wsDemandChangeAuditRequest(wsDemandChangeAuditRequest).build();
wsCalculationProducer.push(config.getSaveDemandAudit(), wsDemandChangeAuditRequestWrapper);
});
}
demandRepository.updateDemand(request.getRequestInfo(), searchResult);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.egov.wscalculation.web.models;

import lombok.*;

import java.util.Map;

import static org.apache.commons.lang3.StringUtils.isNotEmpty;


@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
public class WsDemandChangeAuditRequest {
private Long id;
private String consumercode;
private String tenant_id;
private String status;
private String action;
private Object data;
private String createdby;
private Long createdtime;
public boolean isValid() {

return isNotEmpty(consumercode);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.egov.wscalculation.web.models;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.*;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
public class WsDemandChangeAuditRequestWrapper {

@JsonProperty("WsDemandChangeAuditRequest")
private WsDemandChangeAuditRequest wsDemandChangeAuditRequest;
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,7 @@ sms.demand.enabled: true
sms.payment.link.enabled: true
sms.bill.download.enabled: true
sms.exclude.tenant="pb.testing"

#SAVE DEMAND AUDIT FROM WS_SERVICE
is.save.demand.audit.enabled= true
egov.save.demand.audit.from.wscal= save-ws-demand-change-audit
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE IF NOT EXISTS eg_ws_demand_auditchange (
id bigint NOT NULL,
consumercode VARCHAR(30) NOT NULL,
tenant_id VARCHAR(50),
status VARCHAR(50),
action VARCHAR(100),
data JSONB,
createdby VARCHAR(250),
createdtime bigint

);
CREATE SEQUENCE seq_eg_ws_demand_auditchange
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE eg_ws_demand_auditchange ADD CONSTRAINT eg_ws_demand_auditchange_pkey PRIMARY KEY (id);

0 comments on commit f89216f

Please sign in to comment.