-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 2.8 release code * sewerage code added
- Loading branch information
Showing
2,026 changed files
with
159,497 additions
and
13,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,5 @@ public Action addRolesItem(String rolesItem) { | |
this.roles.add(rolesItem); | ||
return this; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...es/billing-service/src/main/java/org/egov/demand/consumer/BulkBillGenerationConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package org.egov.demand.consumer; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.egov.demand.model.BulkBillGenerator; | ||
import org.egov.demand.model.Demand; | ||
import org.egov.demand.model.GenerateBillCriteria; | ||
import org.egov.demand.model.MigrationCount; | ||
import org.egov.demand.service.BillServicev2; | ||
import org.egov.demand.service.DemandService; | ||
import org.egov.demand.web.contract.DemandRequest; | ||
import org.egov.tracer.kafka.CustomKafkaTemplate; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.kafka.annotation.KafkaListener; | ||
import org.springframework.kafka.support.KafkaHeaders; | ||
import org.springframework.messaging.handler.annotation.Header; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Service | ||
@Slf4j | ||
public class BulkBillGenerationConsumer { | ||
|
||
@Autowired | ||
private DemandService demandService; | ||
|
||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
@Autowired | ||
private BillServicev2 billService; | ||
|
||
@Autowired | ||
private CustomKafkaTemplate<String, Object> kafkaTemplate; | ||
|
||
@KafkaListener(topics = { "${kafka.topics.bulk.bill.generation}" }) | ||
public void processMessage(Map<String, Object> consumerRecord, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) { | ||
|
||
log.debug("key:" + topic + ":" + "value:" + consumerRecord); | ||
|
||
BulkBillGenerator billGenerator = objectMapper.convertValue(consumerRecord, BulkBillGenerator.class); | ||
DemandRequest request = DemandRequest.builder() | ||
.requestInfo(billGenerator.getRequestInfo()) | ||
.demands(billGenerator.getCreateDemands()) | ||
.build(); | ||
|
||
log.info(" Billing-bulkbill-consumer-batch log for batch : " + billGenerator.getMigrationCount().getOffset() | ||
+ " with no of records " + billGenerator.getCreateDemands().size()); | ||
|
||
try { | ||
demandService.create(request); | ||
} catch (Exception e) { | ||
logError(" Demand creation ", e.getMessage(), billGenerator.getMigrationCount()); | ||
} | ||
|
||
request.setDemands(billGenerator.getUpdateDemands()); | ||
try { | ||
if (!CollectionUtils.isEmpty(billGenerator.getUpdateDemands())) | ||
demandService.updateAsync(request, null); | ||
} catch (Exception e) { | ||
logError(" Demand update ", e.getMessage(), billGenerator.getMigrationCount()); | ||
} | ||
|
||
Set<String> consumerCodes = billGenerator.getCreateDemands() | ||
.stream() | ||
.map(Demand::getConsumerCode) | ||
.collect(Collectors.toSet()); | ||
String tenantId = billGenerator.getCreateDemands().get(0).getTenantId(); | ||
String businessService = billGenerator.getCreateDemands().get(0).getBusinessService(); | ||
|
||
GenerateBillCriteria genBillCriteria = GenerateBillCriteria.builder() | ||
.consumerCode(consumerCodes) | ||
.businessService(businessService) | ||
.tenantId(tenantId) | ||
.build(); | ||
|
||
try { | ||
billService.generateBill(genBillCriteria, billGenerator.getRequestInfo()); | ||
} catch (Exception e) { | ||
logError(" Bill Gen ", e.getMessage(), billGenerator.getMigrationCount()); | ||
} | ||
|
||
MigrationCount migrationCount = billGenerator.getMigrationCount(); | ||
migrationCount.setAuditTime(System.currentTimeMillis()); | ||
migrationCount.setMessage("prcoess succeded in billing service"); | ||
kafkaTemplate.send(migrationCount.getAuditTopic(), billGenerator.getMigrationCount()); | ||
} | ||
|
||
private void logError(String process, String message, MigrationCount bulkBillCount) { | ||
bulkBillCount.setAuditTime(System.currentTimeMillis()); | ||
bulkBillCount.setMessage("prcoess failed in billing service during "+ process + " with error message : " + message); | ||
kafkaTemplate.send(bulkBillCount.getAuditTopic(), bulkBillCount); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
business-services/billing-service/src/main/java/org/egov/demand/model/BulkBillGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.egov.demand.model; | ||
|
||
import java.util.List; | ||
|
||
import org.egov.common.contract.request.RequestInfo; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class BulkBillGenerator { | ||
|
||
private RequestInfo requestInfo; | ||
|
||
private List<Demand> createDemands; | ||
|
||
private List<Demand> updateDemands; | ||
|
||
private MigrationCount migrationCount; | ||
} |
Oops, something went wrong.