-
Notifications
You must be signed in to change notification settings - Fork 20
Develop #797
Develop #797
Changes from all commits
97df349
2581ecc
a676686
6b35ee8
370fb9f
1fe1efb
a3028b4
0d7ae0f
7ac1b31
95bac77
a081c68
57f1da3
2e378d7
84c182e
5c04bbe
f47749b
3504cdd
f87fb13
44cf702
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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.*; | ||||||||||||||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updates to service implementation are correct. Consider using method references in the stream operation for better readability. - searchResult.stream().forEach(demand -> {
+ searchResult.forEach(demand -> { Also applies to: 73-135 Committable suggestion
Suggested change
|
||||||||||||||
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; | ||||||||||||||
|
@@ -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 | ||||||||||||||
*/ | ||||||||||||||
|
@@ -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); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
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") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the - @JsonProperty("WsDemandChangeAuditRequest")
+ @JsonProperty("wsDemandChangeAuditRequest") Committable suggestion
Suggested change
|
||||||
private WsDemandChangeAuditRequest wsDemandChangeAuditRequest; | ||||||
} |
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve exception handling by logging the exception details.
This change aligns with the PR's objective to improve exception handling by including the exception itself in the message, rather than just printing it to the console. This will help in better debugging and maintaining the logs.
Committable suggestion
Consider rethrowing the exception or handling it more comprehensively.
This change would allow the exception to be handled or logged by the caller, providing more flexibility in managing errors and aligning with the PR's focus on improved exception handling.
Add type and null checks to prevent potential
ClassCastException
orNullPointerException
.This change ensures that the message data is of the expected type and contains all required keys, thus preventing runtime exceptions and aligning with best practices for robust and secure code.
Committable suggestion
Refactor to improve readability and maintainability.
Refactoring this method to use a context object for passing parameters can simplify the method signature and improve readability. This change also helps in managing the method's complexity by encapsulating the parameters in a single object.