From 85b707a90522c06270fc7fa686d8134101fdb538 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Wed, 5 Jun 2024 11:53:03 +0530 Subject: [PATCH 01/17] ISTE-44: Added new topic to genearte bill per consumercode --- .../config/WSCalculationConfiguration.java | 3 + .../consumer/DemandGenerationConsumer.java | 72 ++++++++++++++----- .../src/main/resources/application.properties | 5 +- 3 files changed, 62 insertions(+), 18 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/config/WSCalculationConfiguration.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/config/WSCalculationConfiguration.java index 574e235bc..a466bdb3e 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/config/WSCalculationConfiguration.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/config/WSCalculationConfiguration.java @@ -267,4 +267,7 @@ public class WSCalculationConfiguration { @Value("${egov.update.demand.add.penalty}") private String updateAddPenaltytopic; + + @Value("${ws.generate.demand.bulk}") + private String wsGenerateDemandBulktopic; } diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 5c3a15489..5118aac25 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -291,6 +291,8 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t String assessmentYear = estimationService.getAssessmentYear(); ArrayList failedConnectionNos = new ArrayList(); + + for (String connectionNo : connectionNos) { CalculationCriteria calculationCriteria = CalculationCriteria.builder().tenantId(tenantId) .assessmentYear(assessmentYear).connectionNo(connectionNo).from(dayStartTime).to(dayEndTime).build(); @@ -305,12 +307,18 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t if (!waterCalculatorDao.isDemandExists(tenantId, previousFromDate.getTimeInMillis(), previousToDate.getTimeInMillis(), consumerCodes) && !waterCalculatorDao.isConnectionExists(tenantId, previousFromDate.getTimeInMillis(), - previousToDate.getTimeInMillis(), consumerCodes)) { + previousToDate.getTimeInMillis(), consumerCodes)) { log.warn("this connection doen't have the demand in previous billing cycle :" + connectionNo); failedConnectionNos.add(connectionNo); continue; } - + HashMap genarateDemandData = new HashMap(); + genarateDemandData.put("calculationReq", calculationReq); + genarateDemandData.put("masterMap", masterMap); + genarateDemandData.put("billingCycle",billingCycle); + genarateDemandData.put("isSendMessage",isSendMessage); + genarateDemandData.put("tenantId",tenantId); + /* * List demands = demandService.searchDemand(tenantId, consumerCodes, * previousFromDate.getTimeInMillis(), previousToDate.getTimeInMillis(), @@ -318,18 +326,10 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t * log.warn("this connection doen't have the demand in previous billing cycle :" * + connectionNo ); continue; } */ - try { - if(!tenantId.equals(config.getSmsExcludeTenant())) { - generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage); - } + producer.push(config.getWsGenerateDemandBulktopic(),genarateDemandData); - } catch (Exception e) { - System.out.println("Got the exception while genating the demands:" + e); - failedConnectionNos.add(connectionNo); - } } - System.out.println("demand Failed event Messages to the GP users "); - if (isSendMessage && failedConnectionNos.size() > 0) { + /* if (isSendMessage && failedConnectionNos.size() > 0) { List actionItems = new ArrayList<>(); String actionLink = config.getBulkDemandFailedLink(); ActionItem actionItem = ActionItem.builder().actionUrl(actionLink).build(); @@ -344,7 +344,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t WSCalculationConstant.GENERATE_DEMAND_EVENT, tenantId); String messages = failedMessage.get(WSCalculationConstant.MSG_KEY); messages = messages.replace("{BILLING_CYCLE}", LocalDate.now().getMonth().toString()); - + additionals.put("localizationCode", WSCalculationConstant.GENERATE_DEMAND_EVENT); HashMap attributes = new HashMap(); attributes.put("{BILLING_CYCLE}", LocalDate.now().getMonth().toString()); @@ -362,7 +362,8 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t util.sendEventNotification(eventReq); } - } else { + } + else { System.out.println("Event Messages to the users"); List items = new ArrayList<>(); String demandActionLink = config.getBulkDemandLink(); @@ -386,7 +387,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t message = message.replace("{billing cycle}", billingCycle); int nmSize = connectionNos.size() - failedConnectionNos.size(); message = message.replace("{X}", String.valueOf(nmSize)); // this should be x- failed - // connections count + // connections count message = message.replace("{X/X+Y}", String.valueOf(nmSize) + "/" + String.valueOf(size)); message = message.replace("{Y}", String.valueOf(meteredConnectionNos.size())); additionals.put("localizationCode", WSCalculationConstant.NEW_BULK_DEMAND_EVENT); @@ -467,17 +468,30 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t msg = msg.replace("{LINK}", msgLink); System.out.println("Demand GP USER SMS1::" + msg); - if(!map.getKey().equals(config.getPspclVendorNumber())) { + if (!map.getKey().equals(config.getPspclVendorNumber())) { SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(msg) .tenantid(tenantId) .category(Category.TRANSACTION).build(); - if(config.isSmsForDemandEnable()) { + if (config.isSmsForDemandEnable()) { producer.push(config.getSmsNotifTopic(), smsRequest); } } }); + }*/ + } + + public void generateDemandInBulk(CalculationReq calculationReq,Map masterMap, String billingCycle, + boolean isSendMessage,String tenantId) { + try { + if(!tenantId.equals(config.getSmsExcludeTenant())) { + generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage); + } + + } catch (Exception e) { + System.out.println("Got the exception while genating the demands:" + e); } + } /** @@ -539,4 +553,28 @@ public void updateAddPenalty(HashMap messageData) { demandService.updateDemandAddPenalty(demandRequest.getRequestInfo(), demandRequest.getDemands()); } + @KafkaListener(topics = { + "${ws.generate.demand.bulk}" }, containerFactory = "kafkaListenerContainerFactory") + public void generateDemandInBulkListner(HashMap messageData) { + log.info("genarate Demand in Bulk data values for non metered connection:: {}", messageData); + /*HashMap genarateDemandData = new HashMap(); + genarateDemandData.put("calculationReq", calculationReq); + genarateDemandData.put("masterMap", masterMap); + genarateDemandData.put("billingCycle",billingCycle); + genarateDemandData.put("isSendMessage",isSendMessage); + genarateDemandData.put("tenantId",tenantId);*/ + Map masterMap; + CalculationReq calculationReq; + String billingCycle ; + boolean isSendMessage = true; + String tenantId=""; + HashMap genarateDemandData = (HashMap) messageData; + masterMap = (Map) genarateDemandData.get("masterMap"); + calculationReq = mapper.convertValue(genarateDemandData.get("calculationReq"), CalculationReq.class); + billingCycle= (String) genarateDemandData.get("billingCycle"); + isSendMessage= (boolean) genarateDemandData.get("isSendMessage"); + tenantId=(String) genarateDemandData.get("tenantId"); + generateDemandInBulk(calculationReq,masterMap,billingCycle,isSendMessage,tenantId); + } + } diff --git a/municipal-services/ws-calculator/src/main/resources/application.properties b/municipal-services/ws-calculator/src/main/resources/application.properties index 299db91e8..b1fd3f568 100644 --- a/municipal-services/ws-calculator/src/main/resources/application.properties +++ b/municipal-services/ws-calculator/src/main/resources/application.properties @@ -154,4 +154,7 @@ egov.save.demand.audit.from.wscal= save-ws-demand-change-audit penalty.start.threshold.time= 10000000 penalty.applicable.in.days= 10 is.penalty.feature.enable= true -egov.update.demand.add.penalty= egov-update-demand-add-penalty \ No newline at end of file +egov.update.demand.add.penalty= egov-update-demand-add-penalty + +#GenareteDemndINBulk +ws.generate.demand.bulk=ws-generate-demand-bulk \ No newline at end of file From b27d9bb8c69f2ad0b7205a877aa8f5151040fa6a Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Wed, 5 Jun 2024 15:43:59 +0530 Subject: [PATCH 02/17] ISTE-44: Added new topic to genearte bill per consumercode --- .../consumer/DemandGenerationConsumer.java | 13 +++++++------ .../service/WSCalculationServiceImpl.java | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 5118aac25..02bf7ca78 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -307,7 +307,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t if (!waterCalculatorDao.isDemandExists(tenantId, previousFromDate.getTimeInMillis(), previousToDate.getTimeInMillis(), consumerCodes) && !waterCalculatorDao.isConnectionExists(tenantId, previousFromDate.getTimeInMillis(), - previousToDate.getTimeInMillis(), consumerCodes)) { + previousToDate.getTimeInMillis(), consumerCodes)) { log.warn("this connection doen't have the demand in previous billing cycle :" + connectionNo); failedConnectionNos.add(connectionNo); continue; @@ -362,8 +362,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t util.sendEventNotification(eventReq); } - } - else { + } else { System.out.println("Event Messages to the users"); List items = new ArrayList<>(); String demandActionLink = config.getBulkDemandLink(); @@ -387,7 +386,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t message = message.replace("{billing cycle}", billingCycle); int nmSize = connectionNos.size() - failedConnectionNos.size(); message = message.replace("{X}", String.valueOf(nmSize)); // this should be x- failed - // connections count + // connections count message = message.replace("{X/X+Y}", String.valueOf(nmSize) + "/" + String.valueOf(size)); message = message.replace("{Y}", String.valueOf(meteredConnectionNos.size())); additionals.put("localizationCode", WSCalculationConstant.NEW_BULK_DEMAND_EVENT); @@ -468,11 +467,11 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t msg = msg.replace("{LINK}", msgLink); System.out.println("Demand GP USER SMS1::" + msg); - if (!map.getKey().equals(config.getPspclVendorNumber())) { + if(!map.getKey().equals(config.getPspclVendorNumber())) { SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(msg) .tenantid(tenantId) .category(Category.TRANSACTION).build(); - if (config.isSmsForDemandEnable()) { + if(config.isSmsForDemandEnable()) { producer.push(config.getSmsNotifTopic(), smsRequest); } } @@ -490,6 +489,8 @@ public void generateDemandInBulk(CalculationReq calculationReq,Map getCalculation(CalculationReq request) { */ public List bulkDemandGeneration(CalculationReq request, Map masterMap) { List calculations = getCalculations(request, masterMap); + log.info("Calculation inside bulkDemandGeneration:"+calculations); demandService.generateDemand(request.getRequestInfo(), calculations, masterMap, true, false, request.getIsAdvanceCalculation()); return calculations; } From 9ee880d6af3d056d550e658d1ea0578fdc669518 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Wed, 5 Jun 2024 16:36:36 +0530 Subject: [PATCH 03/17] ISTE-44: Added new topic to genearte bill per consumercode --- .../consumer/DemandGenerationConsumer.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 02bf7ca78..aaaf621d6 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -564,8 +564,8 @@ public void generateDemandInBulkListner(HashMap messageData) { genarateDemandData.put("billingCycle",billingCycle); genarateDemandData.put("isSendMessage",isSendMessage); genarateDemandData.put("tenantId",tenantId);*/ - Map masterMap; - CalculationReq calculationReq; + Map masterMap = null; + CalculationReq calculationReq= new CalculationReq(); String billingCycle ; boolean isSendMessage = true; String tenantId=""; @@ -575,6 +575,13 @@ public void generateDemandInBulkListner(HashMap messageData) { billingCycle= (String) genarateDemandData.get("billingCycle"); isSendMessage= (boolean) genarateDemandData.get("isSendMessage"); tenantId=(String) genarateDemandData.get("tenantId"); + log.info("masterMap :"+masterMap); + if(!masterMap.isEmpty()) { + log.info("CalculationAttribute:"+masterMap.get("CalculationAttribute")); + } + log.info("calculationReq :"+calculationReq); + log.info("tenantId :"+tenantId); + log.info("billingCycle :"+billingCycle); generateDemandInBulk(calculationReq,masterMap,billingCycle,isSendMessage,tenantId); } From f208420cdc644006b77ab94fa3c871428da240ff Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 6 Jun 2024 11:56:08 +0530 Subject: [PATCH 04/17] ISTE-44: Added new topic to genearte bill per consumercode --- .../consumer/DemandGenerationConsumer.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index aaaf621d6..3706f2457 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -565,24 +565,26 @@ public void generateDemandInBulkListner(HashMap messageData) { genarateDemandData.put("isSendMessage",isSendMessage); genarateDemandData.put("tenantId",tenantId);*/ Map masterMap = null; + Map masterMapDemandGen = new HashMap<>(); CalculationReq calculationReq= new CalculationReq(); String billingCycle ; boolean isSendMessage = true; String tenantId=""; HashMap genarateDemandData = (HashMap) messageData; masterMap = (Map) genarateDemandData.get("masterMap"); + for(Map.Entry res : masterMap.entrySet()) { + masterMapDemandGen.put(String.valueOf(res.getKey()), (Object)res.getValue()); + } calculationReq = mapper.convertValue(genarateDemandData.get("calculationReq"), CalculationReq.class); billingCycle= (String) genarateDemandData.get("billingCycle"); isSendMessage= (boolean) genarateDemandData.get("isSendMessage"); tenantId=(String) genarateDemandData.get("tenantId"); - log.info("masterMap :"+masterMap); - if(!masterMap.isEmpty()) { - log.info("CalculationAttribute:"+masterMap.get("CalculationAttribute")); - } + log.info("masterMap :"+masterMapDemandGen); + log.info("calculationReq :"+calculationReq); log.info("tenantId :"+tenantId); log.info("billingCycle :"+billingCycle); - generateDemandInBulk(calculationReq,masterMap,billingCycle,isSendMessage,tenantId); + generateDemandInBulk(calculationReq,masterMapDemandGen,billingCycle,isSendMessage,tenantId); } } From 4501001b356496b42c0d7871bd2618920211ba69 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 6 Jun 2024 12:24:49 +0530 Subject: [PATCH 05/17] ISTE-44: Added new topic to genearte bill per consumercode --- .../consumer/DemandGenerationConsumer.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 3706f2457..939714963 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -480,8 +480,10 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t }*/ } - public void generateDemandInBulk(CalculationReq calculationReq,Map masterMap, String billingCycle, + public void generateDemandInBulk(CalculationReq calculationReq, String billingCycle, boolean isSendMessage,String tenantId) { + Map masterMap = mDataService.loadMasterData(calculationReq.getRequestInfo(), + tenantId); try { if(!tenantId.equals(config.getSmsExcludeTenant())) { generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage); @@ -564,27 +566,20 @@ public void generateDemandInBulkListner(HashMap messageData) { genarateDemandData.put("billingCycle",billingCycle); genarateDemandData.put("isSendMessage",isSendMessage); genarateDemandData.put("tenantId",tenantId);*/ - Map masterMap = null; - Map masterMapDemandGen = new HashMap<>(); CalculationReq calculationReq= new CalculationReq(); String billingCycle ; boolean isSendMessage = true; String tenantId=""; HashMap genarateDemandData = (HashMap) messageData; - masterMap = (Map) genarateDemandData.get("masterMap"); - for(Map.Entry res : masterMap.entrySet()) { - masterMapDemandGen.put(String.valueOf(res.getKey()), (Object)res.getValue()); - } calculationReq = mapper.convertValue(genarateDemandData.get("calculationReq"), CalculationReq.class); billingCycle= (String) genarateDemandData.get("billingCycle"); isSendMessage= (boolean) genarateDemandData.get("isSendMessage"); tenantId=(String) genarateDemandData.get("tenantId"); - log.info("masterMap :"+masterMapDemandGen); log.info("calculationReq :"+calculationReq); log.info("tenantId :"+tenantId); log.info("billingCycle :"+billingCycle); - generateDemandInBulk(calculationReq,masterMapDemandGen,billingCycle,isSendMessage,tenantId); + generateDemandInBulk(calculationReq,billingCycle,isSendMessage,tenantId); } } From b8172fba33f6c195b83bc003fdbaa678326c0e38 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 6 Jun 2024 13:04:58 +0530 Subject: [PATCH 06/17] ISTE-44: Added new topic to genearte bill per consumercode --- .../consumer/DemandGenerationConsumer.java | 15 ++------------- .../repository/ServiceRequestRepository.java | 2 -- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 939714963..158615608 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -192,7 +192,7 @@ private void generateDemandInBatch(CalculationReq request, Map m wsCalulationWorkflowValidator.applicationValidation(request.getRequestInfo(), criteria.getTenantId(), criteria.getConnectionNo(), genratedemand); } - System.out.println("Calling Bulk Demand generation"); + System.out.println("Calling Bulk Demand generation connection Number" + request.getCalculationCriteria().get(0).getConnectionNo()); wSCalculationServiceImpl.bulkDemandGeneration(request, masterMap); String connectionNoStrings = request.getCalculationCriteria().stream() .map(criteria -> criteria.getConnectionNo()).collect(Collectors.toSet()).toString(); @@ -491,7 +491,7 @@ public void generateDemandInBulk(CalculationReq calculationReq, String billingCy } catch (Exception e) { System.out.println("Got the exception while genating the demands:" + e); - log.info("Errro :"+e.getStackTrace()); + log.info("Errro in Apllication no :"+calculationReq.getCalculationCriteria().get(0).getConnectionNo()); } @@ -559,13 +559,6 @@ public void updateAddPenalty(HashMap messageData) { @KafkaListener(topics = { "${ws.generate.demand.bulk}" }, containerFactory = "kafkaListenerContainerFactory") public void generateDemandInBulkListner(HashMap messageData) { - log.info("genarate Demand in Bulk data values for non metered connection:: {}", messageData); - /*HashMap genarateDemandData = new HashMap(); - genarateDemandData.put("calculationReq", calculationReq); - genarateDemandData.put("masterMap", masterMap); - genarateDemandData.put("billingCycle",billingCycle); - genarateDemandData.put("isSendMessage",isSendMessage); - genarateDemandData.put("tenantId",tenantId);*/ CalculationReq calculationReq= new CalculationReq(); String billingCycle ; boolean isSendMessage = true; @@ -575,10 +568,6 @@ public void generateDemandInBulkListner(HashMap messageData) { billingCycle= (String) genarateDemandData.get("billingCycle"); isSendMessage= (boolean) genarateDemandData.get("isSendMessage"); tenantId=(String) genarateDemandData.get("tenantId"); - - log.info("calculationReq :"+calculationReq); - log.info("tenantId :"+tenantId); - log.info("billingCycle :"+billingCycle); generateDemandInBulk(calculationReq,billingCycle,isSendMessage,tenantId); } diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/ServiceRequestRepository.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/ServiceRequestRepository.java index 1c9abbd97..2e3558f8c 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/ServiceRequestRepository.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/ServiceRequestRepository.java @@ -23,9 +23,7 @@ public class ServiceRequestRepository { public Object fetchResult(StringBuilder uri, Object request) { mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); Object response = null; - log.debug("URI: " + uri); try { - log.debug("Request: " + mapper.writeValueAsString(request)); response = restTemplate.postForObject(uri.toString(), request, Map.class); } catch (HttpClientErrorException e) { log.error("External Service threw an Exception: ", e); From 52827ee2d5e23d2d491e4e6d081660cf48a18b35 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 6 Jun 2024 14:10:09 +0530 Subject: [PATCH 07/17] ISTE-44: Added new topic to genearte bill per consumercode --- .../egov/wscalculation/consumer/DemandGenerationConsumer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 158615608..b8b9f695f 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -484,6 +484,7 @@ public void generateDemandInBulk(CalculationReq calculationReq, String billingCy boolean isSendMessage,String tenantId) { Map masterMap = mDataService.loadMasterData(calculationReq.getRequestInfo(), tenantId); + log.info("Master map:" + masterMap); try { if(!tenantId.equals(config.getSmsExcludeTenant())) { generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage); From bd289b0808975fe6963417706b943d9a6da1920f Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 6 Jun 2024 15:08:13 +0530 Subject: [PATCH 08/17] removed most log line to debug demannd slowness --- .../consumer/DemandGenerationConsumer.java | 11 ++++------ .../repository/WSCalculationDaoImpl.java | 12 ---------- .../builder/WSCalculatorQueryBuilder.java | 3 +-- .../wscalculation/service/DemandService.java | 22 +------------------ .../service/EstimationService.java | 3 --- .../service/MasterDataService.java | 1 - .../service/WSCalculationServiceImpl.java | 1 - 7 files changed, 6 insertions(+), 47 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index b8b9f695f..ac631d5d1 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -272,8 +272,6 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t List connectionNos = waterCalculatorDao.getNonMeterConnectionsList(tenantId, dayStartTime, dayEndTime); - List meteredConnectionNos = waterCalculatorDao.getConnectionsNoList(tenantId, - WSCalculationConstant.meteredConnectionType); Calendar previousFromDate = Calendar.getInstance(); @@ -286,12 +284,13 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t previousToDate.add(Calendar.MONTH, -1); int max = previousToDate.getActualMaximum(Calendar.DAY_OF_MONTH); previousToDate.set(Calendar.DAY_OF_MONTH, max); - Map masterMap = mDataService.loadMasterData(requestInfo, - tenantId); - String assessmentYear = estimationService.getAssessmentYear(); ArrayList failedConnectionNos = new ArrayList(); + log.info("connectionNos" + connectionNos.size()); + log.info("connectionNos" + connectionNos); + log.info("dayStartTime:"+dayStartTime); + log.info("dayEndTime"+dayEndTime); for (String connectionNo : connectionNos) { CalculationCriteria calculationCriteria = CalculationCriteria.builder().tenantId(tenantId) @@ -314,7 +313,6 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t } HashMap genarateDemandData = new HashMap(); genarateDemandData.put("calculationReq", calculationReq); - genarateDemandData.put("masterMap", masterMap); genarateDemandData.put("billingCycle",billingCycle); genarateDemandData.put("isSendMessage",isSendMessage); genarateDemandData.put("tenantId",tenantId); @@ -533,7 +531,6 @@ private Recipient getRecepient(RequestInfo requestInfo, String tenantId) { @KafkaListener(topics = { "${egov.generate.bulk.demand.manually.topic}" }, containerFactory = "kafkaListenerContainerFactory") public void generateBulkDemandForULB(HashMap messageData) { - log.info("Billing master data values for non metered connection:: {}", messageData); Map billingMasterData; BulkDemand bulkDemand; boolean isSendMessage = false; diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/WSCalculationDaoImpl.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/WSCalculationDaoImpl.java index 892ef1305..adf1d8476 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/WSCalculationDaoImpl.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/WSCalculationDaoImpl.java @@ -67,8 +67,6 @@ public List searchMeterReadings(MeterReadingSearchCriteria criteri String query = queryBuilder.getSearchQueryString(criteria, preparedStatement); if (query == null) return Collections.emptyList(); - log.debug("Query: " + query); - log.debug("Prepared Statement" + preparedStatement.toString()); return jdbcTemplate.query(query, preparedStatement.toArray(), meterReadingRowMapper); } @@ -78,8 +76,6 @@ public List searchCurrentMeterReadings(MeterReadingSearchCriteria String query = queryBuilder.getCurrentReadingConnectionQuery(criteria, preparedStatement); if (query == null) return Collections.emptyList(); - log.debug("Query: " + query); - log.debug("Prepared Statement" + preparedStatement.toString()); return jdbcTemplate.query(query, preparedStatement.toArray(), currentMeterReadingRowMapper); } @@ -94,7 +90,6 @@ public int isMeterReadingConnectionExist(List ids) { Set connectionIds = new HashSet<>(ids); List preparedStatement = new ArrayList<>(); String query = queryBuilder.getNoOfMeterReadingConnectionQuery(connectionIds, preparedStatement); - log.debug("Query: " + query); return jdbcTemplate.queryForObject(query, preparedStatement.toArray(), Integer.class); } @@ -104,7 +99,6 @@ public ArrayList searchTenantIds() { String query = queryBuilder.getTenantIdConnectionQuery(); if (query == null) return tenantIds; - log.debug("Query: " + query); tenantIds = (ArrayList) jdbcTemplate.queryForList(query, String.class); return tenantIds; } @@ -117,8 +111,6 @@ public ArrayList searchConnectionNos(String connectionType, String tenan tenantId); if (query == null) return connectionNos; - log.info("Query: " + query); - connectionNos = (ArrayList) jdbcTemplate.query(query, preparedStatement.toArray(), demandSchedulerRowMapper); return connectionNos; @@ -128,7 +120,6 @@ public ArrayList searchConnectionNos(String connectionType, String tenan public List getConnectionsNoList(String tenantId, String connectionType) { List preparedStatement = new ArrayList<>(); String query = queryBuilder.getConnectionNumberList(tenantId, connectionType, preparedStatement); - log.info("water " + connectionType + " connection list : " + query); return jdbcTemplate.query(query, preparedStatement.toArray(), demandSchedulerRowMapper); } @@ -136,14 +127,12 @@ public List getConnectionsNoList(String tenantId, String connectionType) public List getNonMeterConnectionsList(String tenantId, Long dayStartTime, Long dayEndTime) { List preparedStatement = new ArrayList<>(); String query = queryBuilder.getNonMeteredConnectionsList(tenantId, dayStartTime, dayEndTime, preparedStatement); - log.info("water NMconnection list query: " + query); return jdbcTemplate.query(query, preparedStatement.toArray(), demandSchedulerRowMapper); } @Override public List getTenantId() { String query = queryBuilder.getDistinctTenantIds(); - log.info("Tenant Id's List Query : " + query); return jdbcTemplate.queryForList(query, String.class); } @@ -151,7 +140,6 @@ public List getTenantId() { public int isBillingPeriodExists(String connectionNo, String billingPeriod) { List preparedStatement = new ArrayList<>(); String query = queryBuilder.isBillingPeriodExists(connectionNo, billingPeriod, preparedStatement); - log.info("Is BillingPeriod Exits Query: " + query); return jdbcTemplate.queryForObject(query, preparedStatement.toArray(), Integer.class); } diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/builder/WSCalculatorQueryBuilder.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/builder/WSCalculatorQueryBuilder.java index 476db7821..79fb53dbd 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/builder/WSCalculatorQueryBuilder.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/builder/WSCalculatorQueryBuilder.java @@ -247,8 +247,7 @@ public String previousBillingCycleDemandQuery(Set connectionNos, String } if(!CollectionUtils.isEmpty(preparedStmtList)) builder.append("and status not IN ('CANCELLED')"); - - System.out.println("Final query ::" + builder.toString()); + return builder.toString(); } diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java index fa8082c80..11104a17f 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java @@ -312,7 +312,6 @@ private List createDemand(RequestInfo requestInfo, List cal sendDownloadBillSMSNotification(requestInfo,tenantId,owner,waterConnectionRequest,property,demandDetails,consumerCode,demands,isForConnectionNO,businessService,billCycle,billNumbers,paymentDueDate,totalAmount); } } - log.info("Demand Object" + demands.toString()); return finalDemandRes; @@ -332,21 +331,18 @@ private void sendPaymentSMSNotification(RequestInfo requestInfo, String tenantId .replace("$tenantId", property.getTenantId()) .replace("$businessService", businessService) .replace("$connectionType", connectionType); - log.info("Payment Link ::: " + actionLinkPayment); + String messageString = localizationMessage.get(WSCalculationConstant.MSG_KEY); BigDecimal totalAmount = fetchTotalBillAmount(demands,requestInfo); - System.out.println("Localization message::" + messageString); if (!StringUtils.isEmpty(messageString) && isForConnectionNO) { - log.info("Demand Object" + demands.toString()); messageString = messageString.replace("{ownername}", owner.getName()); messageString = messageString.replace("{billamount}",totalAmount.toString()); messageString = messageString.replace("{Date}", paymentDueDate); messageString = messageString.replace("{connectionno}", consumerCode); messageString = messageString.replace("{PAY_LINK}", getShortenedUrl(actionLinkPayment)); - System.out.println("payment genaration Message1::" + messageString); SMSRequest sms = SMSRequest.builder().mobileNumber(owner.getMobileNumber()).message(messageString).tenantid(tenantId) .category(Category.TRANSACTION).build(); @@ -374,9 +370,6 @@ private void sendDownloadBillSMSNotification(RequestInfo requestInfo, String ten //System.out.println("Localization message get bill::" + messageString); //System.out.println("isForConnectionNO:" + isForConnectionNO); if (!StringUtils.isEmpty(messageString) && isForConnectionNO) { - log.info("Demand Object get bill" + demands.toString()); - log.info("requestInfo get Bill" + requestInfo); - log.info("bill number get bill size :" + billNumbers.size()); if (totalamount!=null && billNumbers.size() > 0 && totalamount.signum()>0) { actionLink = actionLink.replace("$billNumber", billNumbers.get(0)); messageString = messageString.replace("{ownername}", owner.getName()); @@ -430,11 +423,7 @@ private void sendPaymentAndBillSMSNotification(RequestInfo requestInfo, String t BigDecimal totalAmount = fetchTotalBillAmount(demands, requestInfo); String messageString = localizationMessage.get(WSCalculationConstant.MSG_KEY); - System.out.println("Localization message get payment and bill::" + messageString); if (!StringUtils.isEmpty(messageString) && isForConnectionNO) { - log.info("Demand Object get payment and bill" + demands.toString()); - log.info("requestInfo get Bill and Payment::" +requestInfo); - log.info("Bill Number get payment and bill:: " + billNumbers.toString()); if (billNumbers.size() > 0) { actionBillLink = actionBillLink.replace("$billNumber", billNumbers.get(0)); } @@ -463,13 +452,10 @@ public BigDecimal fetchTotalBillAmount(List demandResponse, RequestInfo Object result = serviceRequestRepository.fetchResult( calculatorUtils.getFetchBillURL(demand.getTenantId(), demand.getConsumerCode()), RequestInfoWrapper.builder().requestInfo(requestInfo).build()); - log.debug("response from fetch bill total bill: " + mapper.writeValueAsString(result)); List> jsonOutput = JsonPath.read(result, "$.Bill"); - log.info("Bill Response totalAMount fetch:: " + result); log.info(mapper.writeValueAsString(jsonOutput)); totalAmount=new BigDecimal(jsonOutput.get(0).get("totalAmount").toString()); //totalAmount = new BigDecimal(JsonPath.read(result, "$.Bill[0].totalAmount").toString()); - log.info("Bill Response totalAMount:: " + result); HashMap billResponse = new HashMap<>(); @@ -1409,7 +1395,6 @@ public int compare(Demand d1, Demand d2) { demands.add(demand); } - log.info("Updated Demand Details " + demands.toString()); if(config.isSaveDemandAuditEnabled()){ demands.stream().forEach(demand -> { Long id = demandAuditSeqBuilder.getNextSequence(); @@ -1447,7 +1432,6 @@ public DemandPenaltyResponse getPenaltyDetails(@Valid GetBillCriteria getBillCri } public boolean isOnlinePaymentAllowed(RequestInfo requestInfo, String tenantId) { - log.info("inside online payment allowed method"); List masterDetails = new ArrayList<>(); MasterDetail masterDetail =new MasterDetail("BusinessService",WSCalculationConstant.FILTER_PAYMENT_METHOD_SEARCH); masterDetails.add(masterDetail); @@ -1457,12 +1441,8 @@ public boolean isOnlinePaymentAllowed(RequestInfo requestInfo, String tenantId) MdmsCriteria mdmsCriteria = MdmsCriteria.builder().tenantId(tenantId) .moduleDetails(moduleDetails) .build(); - log.info("mdmscrtiteria:::"+mdmsCriteria.getTenantId()); - log.info("mdmscrtiteria::::::"+mdmsCriteria.getModuleDetails().get(0).getModuleName()); - log.info("mdmscrtiteria:::::::::"+mdmsCriteria.getModuleDetails().get(0)); Map paymentMasterData = calculatorUtils.getAllowedPaymentForTenantId(tenantId,mdmsCriteria,requestInfo); List paymentModesNotAllowed = (List) paymentMasterData.get(WSCalculationConstant.Payment_Modes_Not_Allowed); - log.info("size::" +paymentModesNotAllowed.size()); if(paymentModesNotAllowed.contains("ONLINE")) return false; else diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java index d8244a524..062661bf8 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java @@ -189,7 +189,6 @@ public BigDecimal getWaterEstimationCharge(WaterConnection waterConnection, Calc throw new CustomException("INVALID_BILLING_SLAB", "More than one billing slab found"); billingSlabIds.add(billingSlabs.get(0).getId()); - log.debug(" Billing Slab Id For Water Charge Calculation ---> " + billingSlabIds.toString()); // WaterCharge Calculation Double totalUOM = getUnitOfMeasurement(waterConnection, calculationAttribute, criteria); @@ -200,7 +199,6 @@ public BigDecimal getWaterEstimationCharge(WaterConnection waterConnection, Calc //For metered connection calculation on graded fee slab //For Non metered connection calculation on normal connection BigDecimal totUOM = new BigDecimal(totalUOM); - log.debug("totalUOM" + totalUOM.toString()); if (isRangeCalculation(calculationAttribute)) { if (waterConnection.getConnectionType().equalsIgnoreCase(WSCalculationConstant.meteredConnectionType)) { for (Slab slab : billSlab.getSlabs()) { @@ -273,7 +271,6 @@ private List getSlabsFiltered(WaterConnection waterConnection, List Property property = wSCalculationUtil.getProperty( WaterConnectionRequest.builder().waterConnection(waterConnection).requestInfo(requestInfo).build()); // get billing Slab - log.debug(" the slabs count : " + billingSlabs.size()); //final String buildingType = (property.getUsageCategory() != null) ? property.getUsageCategory().split("\\.")[0]: ""; //TODO:FIX ME : here before we passing buildingtype as UsageCategory from proerty response . but while creating property usagecategoty is residentialeven when we are creating commercial connection. Hennce we have change this to proertytype final String buildingType = (property.getPropertyType() != null) ? property.getPropertyType().split("\\.")[0]: ""; diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/MasterDataService.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/MasterDataService.java index 21b57a322..0c7fae191 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/MasterDataService.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/MasterDataService.java @@ -200,7 +200,6 @@ public Map> getFinancialYear(RequestInfo requestInfo @SuppressWarnings("unchecked") public Map enrichBillingPeriod(CalculationCriteria criteria, ArrayList mdmsResponse, Map masterMap,boolean isconnectionCalculation) { - log.info("Billing Frequency Map {}", mdmsResponse.toString()); Map master = new HashMap<>(); for (Object o : mdmsResponse) { if ((((Map) o).get(WSCalculationConstant.ConnectionType).toString()) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java index 80c9b6d36..790e95cc1 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java @@ -318,7 +318,6 @@ public void jobScheduler() { @SuppressWarnings("unchecked") public void getBillingPeriod(ArrayList mdmsResponse, RequestInfo requestInfo, String tenantId) { - log.info("Billing Frequency Map" + mdmsResponse.toString()); Map master = (Map) mdmsResponse.get(0); LocalDateTime demandStartingDate = LocalDateTime.now(); Long demandGenerateDateMillis = (Long) master.get(WSCalculationConstant.Demand_Generate_Date_String); From 1078201a09d9a453b79dee98c961049051fbde7b Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Thu, 6 Jun 2024 15:55:22 +0530 Subject: [PATCH 09/17] removed most log line to debug demannd slowness --- .../wscalculation/consumer/BillingNotificationConsumer.java | 1 - .../egov/wscalculation/consumer/DemandGenerationConsumer.java | 3 ++- .../repository/builder/WSCalculatorQueryBuilder.java | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/BillingNotificationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/BillingNotificationConsumer.java index 6fe1a0d9b..0eef79917 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/BillingNotificationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/BillingNotificationConsumer.java @@ -25,7 +25,6 @@ public class BillingNotificationConsumer { */ @KafkaListener(topics = { "${kafka.topics.billgen.topic}" }) public void listen(final HashMap record, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) { - log.info("Consuming record: " + record); // paymentService.process(record, topic); } } diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index ac631d5d1..72864fe69 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -324,6 +324,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t * log.warn("this connection doen't have the demand in previous billing cycle :" * + connectionNo ); continue; } */ + log.info("sending generate demand for connection no :"+connectionNo); producer.push(config.getWsGenerateDemandBulktopic(),genarateDemandData); } @@ -482,7 +483,6 @@ public void generateDemandInBulk(CalculationReq calculationReq, String billingCy boolean isSendMessage,String tenantId) { Map masterMap = mDataService.loadMasterData(calculationReq.getRequestInfo(), tenantId); - log.info("Master map:" + masterMap); try { if(!tenantId.equals(config.getSmsExcludeTenant())) { generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage); @@ -566,6 +566,7 @@ public void generateDemandInBulkListner(HashMap messageData) { billingCycle= (String) genarateDemandData.get("billingCycle"); isSendMessage= (boolean) genarateDemandData.get("isSendMessage"); tenantId=(String) genarateDemandData.get("tenantId"); + log.info("got generate demand call for :"+calculationReq.getCalculationCriteria().get(0).getConnectionNo()); generateDemandInBulk(calculationReq,billingCycle,isSendMessage,tenantId); } diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/builder/WSCalculatorQueryBuilder.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/builder/WSCalculatorQueryBuilder.java index 79fb53dbd..fb4d4a95d 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/builder/WSCalculatorQueryBuilder.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/builder/WSCalculatorQueryBuilder.java @@ -272,7 +272,6 @@ public String previousBillingCycleConnectionQuery(Set connectionNos, Str builder.append(" tenantId =? "); preparedStmtList.add(tenantId); } - System.out.println("Final conn query ::" + builder.toString()); return builder.toString(); } From 79564850d47db7c261262a54601c43055232cfa6 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 7 Jun 2024 11:02:22 +0530 Subject: [PATCH 10/17] added log line to debug demannd slowness --- .../wscalculation/consumer/DemandGenerationConsumer.java | 5 +++-- .../org/egov/wscalculation/repository/DemandRepository.java | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 72864fe69..919eec10d 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -194,10 +194,10 @@ private void generateDemandInBatch(CalculationReq request, Map m } System.out.println("Calling Bulk Demand generation connection Number" + request.getCalculationCriteria().get(0).getConnectionNo()); wSCalculationServiceImpl.bulkDemandGeneration(request, masterMap); - String connectionNoStrings = request.getCalculationCriteria().stream() + /*String connectionNoStrings = request.getCalculationCriteria().stream() .map(criteria -> criteria.getConnectionNo()).collect(Collectors.toSet()).toString(); StringBuilder str = new StringBuilder("Demand generated Successfully. For records : ") - .append(connectionNoStrings); + .append(connectionNoStrings);*/ // producer.push(errorTopic, request); // remove the try catch or throw the exception to the previous method to catch it. @@ -557,6 +557,7 @@ public void updateAddPenalty(HashMap messageData) { @KafkaListener(topics = { "${ws.generate.demand.bulk}" }, containerFactory = "kafkaListenerContainerFactory") public void generateDemandInBulkListner(HashMap messageData) { + log.info("got generate demand call"); CalculationReq calculationReq= new CalculationReq(); String billingCycle ; boolean isSendMessage = true; diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/DemandRepository.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/DemandRepository.java index f157c7057..fb26456e6 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/DemandRepository.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/DemandRepository.java @@ -50,6 +50,7 @@ public List saveDemand(RequestInfo requestInfo, List demands){ StringBuilder url = new StringBuilder(config.getBillingServiceHost()); url.append(config.getDemandCreateEndPoint()); DemandRequest request = new DemandRequest(requestInfo,demands); + log.info("Creating demand for consumer code: "+request.getDemands().get(0).getConsumerCode()); Object result = serviceRequestRepository.fetchResult(url, request); try{ return mapper.convertValue(result,DemandResponse.class).getDemands(); @@ -69,6 +70,7 @@ public List updateDemand(RequestInfo requestInfo, List demands){ StringBuilder url = new StringBuilder(config.getBillingServiceHost()); url.append(config.getDemandUpdateEndPoint()); DemandRequest request = new DemandRequest(requestInfo,demands); + log.info("Updating demand for consumer code: "+request.getDemands().get(0).getConsumerCode()); Object result = serviceRequestRepository.fetchResult(url, request); try{ return mapper.convertValue(result,DemandResponse.class).getDemands(); From c36c84b8e7ad895b1c55918aaa2023fc465e3a23 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 7 Jun 2024 12:12:53 +0530 Subject: [PATCH 11/17] ISTE-44: remove KafkaConfiguration --- .../egov/wscalculation/config/KafkaConfiguration.java | 2 +- .../consumer/DemandGenerationConsumer.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/config/KafkaConfiguration.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/config/KafkaConfiguration.java index af627729c..447cb5242 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/config/KafkaConfiguration.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/config/KafkaConfiguration.java @@ -12,7 +12,7 @@ import org.springframework.kafka.core.DefaultKafkaConsumerFactory; import org.springframework.kafka.listener.ContainerProperties.AckMode; -@Configuration +//@Configuration public class KafkaConfiguration { @Autowired diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 919eec10d..97f13bbf9 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -141,7 +141,7 @@ public void listen(final List> records) { * @param records failed batch processing */ @KafkaListener(topics = { - "${persister.demand.based.dead.letter.topic.batch}" }, containerFactory = "kafkaListenerContainerFactory") + "${persister.demand.based.dead.letter.topic.batch}" }) public void listenDeadLetterTopic(final List> records) { CalculationReq calculationReq = mapper.convertValue(records.get(0).getPayload(), CalculationReq.class); Map masterMap = mDataService.loadMasterData(calculationReq.getRequestInfo(), @@ -208,7 +208,7 @@ private void generateDemandInBatch(CalculationReq request, Map m * @param tenantId TenantId for getting master data. */ @KafkaListener(topics = { - "${egov.wscal.bulk.demand.schedular.topic}" }, containerFactory = "kafkaListenerContainerFactory") + "${egov.wscal.bulk.demand.schedular.topic}" }) public void generateDemandForTenantId(HashMap messageData) { String tenantId; RequestInfo requestInfo; @@ -529,7 +529,7 @@ private Recipient getRecepient(RequestInfo requestInfo, String tenantId) { @SuppressWarnings("unchecked") @KafkaListener(topics = { - "${egov.generate.bulk.demand.manually.topic}" }, containerFactory = "kafkaListenerContainerFactory") + "${egov.generate.bulk.demand.manually.topic}" }) public void generateBulkDemandForULB(HashMap messageData) { Map billingMasterData; BulkDemand bulkDemand; @@ -548,14 +548,14 @@ public void generateBulkDemandForULB(HashMap messageData) { } @KafkaListener(topics = { - "${egov.update.demand.add.penalty}" }, containerFactory = "kafkaListenerContainerFactory") + "${egov.update.demand.add.penalty}" }) public void updateAddPenalty(HashMap messageData) { DemandRequest demandRequest = mapper.convertValue(messageData, DemandRequest.class); demandService.updateDemandAddPenalty(demandRequest.getRequestInfo(), demandRequest.getDemands()); } @KafkaListener(topics = { - "${ws.generate.demand.bulk}" }, containerFactory = "kafkaListenerContainerFactory") + "${ws.generate.demand.bulk}" }) public void generateDemandInBulkListner(HashMap messageData) { log.info("got generate demand call"); CalculationReq calculationReq= new CalculationReq(); From 4843e4aeb19da46e76e2c91c3aa55fed3f1c6663 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 7 Jun 2024 15:32:06 +0530 Subject: [PATCH 12/17] ISTE-44: added send notification to collectionn user in demand gen --- .../consumer/DemandGenerationConsumer.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 97f13bbf9..6b46bdf2e 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -328,6 +328,39 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t producer.push(config.getWsGenerateDemandBulktopic(),genarateDemandData); } + HashMap demandMessage = util.getLocalizationMessage(requestInfo, + WSCalculationConstant.mGram_Consumer_NewDemand, tenantId); + HashMap gpwscMap = util.getLocalizationMessage(requestInfo, tenantId, tenantId); + UserDetailResponse userDetailResponse = userService.getUserByRoleCodes(requestInfo, + Arrays.asList("COLLECTION_OPERATOR"), tenantId); + Map mobileNumberIdMap = new LinkedHashMap<>(); + String msgLink = config.getNotificationUrl() + config.getGpUserDemandLink(); + for (OwnerInfo userInfo : userDetailResponse.getUser()) { + if (userInfo.getName() != null) { + mobileNumberIdMap.put(userInfo.getMobileNumber(), userInfo.getName()); + } else { + mobileNumberIdMap.put(userInfo.getMobileNumber(), userInfo.getUserName()); + } + } + mobileNumberIdMap.entrySet().stream().forEach(map -> { + String msg = demandMessage.get(WSCalculationConstant.MSG_KEY); + msg = msg.replace("{ownername}", map.getValue()); + msg = msg.replace("{villagename}", + (gpwscMap != null && !StringUtils.isEmpty(gpwscMap.get(WSCalculationConstant.MSG_KEY))) + ? gpwscMap.get(WSCalculationConstant.MSG_KEY) + : tenantId); + msg = msg.replace("{billingcycle}", billingCycle); + msg = msg.replace("{LINK}", msgLink); + if(!map.getKey().equals(config.getPspclVendorNumber())) { + SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(msg) + .tenantid(tenantId) + .category(Category.TRANSACTION).build(); + if(config.isSmsForDemandEnable()) { + producer.push(config.getSmsNotifTopic(), smsRequest); + } + } + + }); /* if (isSendMessage && failedConnectionNos.size() > 0) { List actionItems = new ArrayList<>(); String actionLink = config.getBulkDemandFailedLink(); From 9cdc577d081e03fe1e0682204512307090367069 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 7 Jun 2024 16:34:49 +0530 Subject: [PATCH 13/17] ISTE-44: added send notification to collectionn user in demand gen --- .../consumer/DemandGenerationConsumer.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 6b46bdf2e..f536f3ae8 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -286,6 +286,8 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t previousToDate.set(Calendar.DAY_OF_MONTH, max); String assessmentYear = estimationService.getAssessmentYear(); ArrayList failedConnectionNos = new ArrayList(); + Map masterMap = mDataService.loadMasterData(requestInfo, + tenantId); log.info("connectionNos" + connectionNos.size()); log.info("connectionNos" + connectionNos); @@ -314,6 +316,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t HashMap genarateDemandData = new HashMap(); genarateDemandData.put("calculationReq", calculationReq); genarateDemandData.put("billingCycle",billingCycle); + genarateDemandData.put("masterMap",masterMap); genarateDemandData.put("isSendMessage",isSendMessage); genarateDemandData.put("tenantId",tenantId); @@ -512,10 +515,9 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t }*/ } - public void generateDemandInBulk(CalculationReq calculationReq, String billingCycle, + public void generateDemandInBulk(CalculationReq calculationReq, String billingCycle, Map masterMap, boolean isSendMessage,String tenantId) { - Map masterMap = mDataService.loadMasterData(calculationReq.getRequestInfo(), - tenantId); + log.info("masterMap:"+masterMap); try { if(!tenantId.equals(config.getSmsExcludeTenant())) { generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage); @@ -590,18 +592,20 @@ public void updateAddPenalty(HashMap messageData) { @KafkaListener(topics = { "${ws.generate.demand.bulk}" }) public void generateDemandInBulkListner(HashMap messageData) { - log.info("got generate demand call"); CalculationReq calculationReq= new CalculationReq(); + Map masterMap = new HashMap<>(); String billingCycle ; boolean isSendMessage = true; String tenantId=""; HashMap genarateDemandData = (HashMap) messageData; + masterMap = (Map) genarateDemandData.get("masterMap"); calculationReq = mapper.convertValue(genarateDemandData.get("calculationReq"), CalculationReq.class); billingCycle= (String) genarateDemandData.get("billingCycle"); isSendMessage= (boolean) genarateDemandData.get("isSendMessage"); tenantId=(String) genarateDemandData.get("tenantId"); + log.info("got generate demand call for :"+calculationReq.getCalculationCriteria().get(0).getConnectionNo()); - generateDemandInBulk(calculationReq,billingCycle,isSendMessage,tenantId); + generateDemandInBulk(calculationReq,billingCycle,masterMap,isSendMessage,tenantId); } } From 38d925631cfccc96c050aa52beb8513cc7ac93ac Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 7 Jun 2024 16:41:27 +0530 Subject: [PATCH 14/17] ISTE-44: added master map to outside call --- .../java/org/egov/wscalculation/service/EstimationService.java | 2 ++ .../egov/wscalculation/service/WSCalculationServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java index 062661bf8..7b6c38f30 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java @@ -78,6 +78,8 @@ public Map getEstimationMap(CalculationCriteria criteria, RequestI Map billingSlabMaster = new HashMap<>(); Map timeBasedExemptionMasterMap = new HashMap<>(); ArrayList billingSlabIds = new ArrayList<>(); + log.info("masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER):"+masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER)); + log.info("masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)" +masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)); billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER, (JSONArray) masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER)); billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java index 790e95cc1..82211b087 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java @@ -158,7 +158,6 @@ public List getCalculation(CalculationReq request) { */ public List bulkDemandGeneration(CalculationReq request, Map masterMap) { List calculations = getCalculations(request, masterMap); - log.info("Calculation inside bulkDemandGeneration:"+calculations); demandService.generateDemand(request.getRequestInfo(), calculations, masterMap, true, false, request.getIsAdvanceCalculation()); return calculations; } @@ -274,6 +273,7 @@ List getCalculations(CalculationReq request, Map ma List calculations = new ArrayList<>(request.getCalculationCriteria().size()); for (CalculationCriteria criteria : request.getCalculationCriteria()) { Map estimationMap = null; + log.info("Innside get Calculation"); if(request.getIsAdvanceCalculation() == null || (!request.getIsAdvanceCalculation().booleanValue())) { estimationMap = estimationService.getEstimationMap(criteria, request.getRequestInfo(), masterMap,request.getIsconnectionCalculation(),false); From 0b7ea35308c92f5a077bddad3c03774a2109b544 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 7 Jun 2024 17:21:54 +0530 Subject: [PATCH 15/17] ISTE-44: added master map to outside call --- .../consumer/DemandGenerationConsumer.java | 1 + .../wscalculation/service/EstimationService.java | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index f536f3ae8..94995c078 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -524,6 +524,7 @@ public void generateDemandInBulk(CalculationReq calculationReq, String billingCy } } catch (Exception e) { + e.printStackTrace(); System.out.println("Got the exception while genating the demands:" + e); log.info("Errro in Apllication no :"+calculationReq.getCalculationCriteria().get(0).getConnectionNo()); diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java index 7b6c38f30..37d57d946 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java @@ -80,10 +80,21 @@ public Map getEstimationMap(CalculationCriteria criteria, RequestI ArrayList billingSlabIds = new ArrayList<>(); log.info("masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER):"+masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER)); log.info("masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)" +masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)); - billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER, + // Convert and assign WC_BILLING_SLAB_MASTER + ArrayList wcBillingSlabList = (ArrayList) masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER); + JSONArray wcBillingSlabArray = new JSONArray(); + wcBillingSlabArray.addAll(wcBillingSlabList); + billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER, wcBillingSlabArray); + // Convert and assign CALCULATION_ATTRIBUTE_CONST + ArrayList calculationAttributeList = (ArrayList) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST); + JSONArray calculationAttributeArray = new JSONArray(); + calculationAttributeArray.addAll(calculationAttributeList); + billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, calculationAttributeArray); + + /*billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER, (JSONArray) masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER)); billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, - (JSONArray) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)); + (JSONArray) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST));*/ // timeBasedExemptionMasterMap.put(WSCalculationConstant.WC_WATER_CESS_MASTER, // (JSONArray) (masterData.getOrDefault(WSCalculationConstant.WC_WATER_CESS_MASTER, null))); // mDataService.setWaterConnectionMasterValues(requestInfo, tenantId, From f323cc9dd59843a0320807b3a00841b3ae702b82 Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 7 Jun 2024 17:36:27 +0530 Subject: [PATCH 16/17] ISTE-44: added master map to outside call --- .../wscalculation/consumer/DemandGenerationConsumer.java | 4 ++-- .../org/egov/wscalculation/service/EstimationService.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index 94995c078..aa2e9a0e5 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -517,10 +517,10 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t public void generateDemandInBulk(CalculationReq calculationReq, String billingCycle, Map masterMap, boolean isSendMessage,String tenantId) { - log.info("masterMap:"+masterMap); + Map masterMapDemand = (Map) masterMap; try { if(!tenantId.equals(config.getSmsExcludeTenant())) { - generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage); + generateDemandInBatch(calculationReq, masterMapDemand, billingCycle, isSendMessage); } } catch (Exception e) { diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java index 37d57d946..f154930b9 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java @@ -80,7 +80,7 @@ public Map getEstimationMap(CalculationCriteria criteria, RequestI ArrayList billingSlabIds = new ArrayList<>(); log.info("masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER):"+masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER)); log.info("masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)" +masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)); - // Convert and assign WC_BILLING_SLAB_MASTER + /*// Convert and assign WC_BILLING_SLAB_MASTER ArrayList wcBillingSlabList = (ArrayList) masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER); JSONArray wcBillingSlabArray = new JSONArray(); wcBillingSlabArray.addAll(wcBillingSlabList); @@ -89,12 +89,12 @@ public Map getEstimationMap(CalculationCriteria criteria, RequestI ArrayList calculationAttributeList = (ArrayList) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST); JSONArray calculationAttributeArray = new JSONArray(); calculationAttributeArray.addAll(calculationAttributeList); - billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, calculationAttributeArray); + billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, calculationAttributeArray);*/ - /*billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER, + billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER, (JSONArray) masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER)); billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, - (JSONArray) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST));*/ + (JSONArray) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)); // timeBasedExemptionMasterMap.put(WSCalculationConstant.WC_WATER_CESS_MASTER, // (JSONArray) (masterData.getOrDefault(WSCalculationConstant.WC_WATER_CESS_MASTER, null))); // mDataService.setWaterConnectionMasterValues(requestInfo, tenantId, From c301ef05c0de860105e704a606ee5ef4db60c1ee Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Fri, 7 Jun 2024 17:44:52 +0530 Subject: [PATCH 17/17] ISTE-44: added master map to outside call --- .../consumer/DemandGenerationConsumer.java | 4 +-- .../service/EstimationService.java | 8 ++--- .../service/WSCalculationServiceImpl.java | 33 ++++++++++++++++--- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java index aa2e9a0e5..94995c078 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/consumer/DemandGenerationConsumer.java @@ -517,10 +517,10 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t public void generateDemandInBulk(CalculationReq calculationReq, String billingCycle, Map masterMap, boolean isSendMessage,String tenantId) { - Map masterMapDemand = (Map) masterMap; + log.info("masterMap:"+masterMap); try { if(!tenantId.equals(config.getSmsExcludeTenant())) { - generateDemandInBatch(calculationReq, masterMapDemand, billingCycle, isSendMessage); + generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage); } } catch (Exception e) { diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java index f154930b9..37d57d946 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java @@ -80,7 +80,7 @@ public Map getEstimationMap(CalculationCriteria criteria, RequestI ArrayList billingSlabIds = new ArrayList<>(); log.info("masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER):"+masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER)); log.info("masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)" +masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)); - /*// Convert and assign WC_BILLING_SLAB_MASTER + // Convert and assign WC_BILLING_SLAB_MASTER ArrayList wcBillingSlabList = (ArrayList) masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER); JSONArray wcBillingSlabArray = new JSONArray(); wcBillingSlabArray.addAll(wcBillingSlabList); @@ -89,12 +89,12 @@ public Map getEstimationMap(CalculationCriteria criteria, RequestI ArrayList calculationAttributeList = (ArrayList) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST); JSONArray calculationAttributeArray = new JSONArray(); calculationAttributeArray.addAll(calculationAttributeList); - billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, calculationAttributeArray);*/ + billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, calculationAttributeArray); - billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER, + /*billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER, (JSONArray) masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER)); billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, - (JSONArray) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)); + (JSONArray) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST));*/ // timeBasedExemptionMasterMap.put(WSCalculationConstant.WC_WATER_CESS_MASTER, // (JSONArray) (masterData.getOrDefault(WSCalculationConstant.WC_WATER_CESS_MASTER, null))); // mDataService.setWaterConnectionMasterValues(requestInfo, tenantId, diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java index 82211b087..e31c6dd2d 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/WSCalculationServiceImpl.java @@ -10,6 +10,8 @@ import java.util.Map; import java.util.stream.Collectors; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import org.egov.common.contract.request.RequestInfo; import org.egov.common.contract.request.User; import org.egov.mdms.model.MdmsCriteriaReq; @@ -73,6 +75,9 @@ public class WSCalculationServiceImpl implements WSCalculationService { @Autowired private DemandAuditSeqBuilder demandAuditSeqBuilder; + @Autowired + ObjectMapper mapper; + /** * Get CalculationReq and Calculate the Tax Head on Water Charge And Estimation Charge */ @@ -196,10 +201,28 @@ public Calculation getCalculation(RequestInfo requestInfo, CalculationCriteria c String tenantId = null != property.getTenantId() ? property.getTenantId() : criteria.getTenantId(); - @SuppressWarnings("unchecked") - Map taxHeadCategoryMap = ((List) masterMap + + /*Map taxHeadCategoryMap = ((List) masterMap .get(WSCalculationConstant.TAXHEADMASTER_MASTER_KEY)).stream() - .collect(Collectors.toMap(TaxHeadMaster::getCode, TaxHeadMaster::getCategory, (OldValue, NewValue) -> NewValue)); + .collect(Collectors.toMap(TaxHeadMaster::getCode, TaxHeadMaster::getCategory, (OldValue, NewValue) -> NewValue));* + + */ + Map taxHeadCategoryMap; + try { + // Deserialize the list + List taxHeadMasters = mapper.convertValue( + masterMap.get(WSCalculationConstant.TAXHEADMASTER_MASTER_KEY), + new TypeReference>() {} + ); + // Convert to Map + taxHeadCategoryMap = taxHeadMasters.stream() + .collect(Collectors.toMap(TaxHeadMaster::getCode, TaxHeadMaster::getCategory, (oldValue, newValue) -> newValue)); + // Output for verification + System.out.println(taxHeadCategoryMap); + } catch (Exception e) { + e.printStackTrace(); + throw new CustomException(); + } BigDecimal taxAmt = BigDecimal.ZERO; BigDecimal waterCharge = BigDecimal.ZERO; @@ -256,10 +279,12 @@ public Calculation getCalculation(RequestInfo requestInfo, CalculationCriteria c } BigDecimal totalAmount = taxAmt.add(penalty).add(rebate).add(exemption).add(waterCharge).add(fee).add(advance); + return Calculation.builder().totalAmount(totalAmount).taxAmount(taxAmt).penalty(penalty).exemption(exemption) .charge(waterCharge).advance(advance).fee(fee).waterConnection(waterConnection).rebate(rebate).tenantId(tenantId) .taxHeadEstimates(estimates).billingSlabIds(billingSlabIds).connectionNo(criteria.getConnectionNo()).applicationNO(criteria.getApplicationNo()) .build(); + } @@ -273,7 +298,7 @@ List getCalculations(CalculationReq request, Map ma List calculations = new ArrayList<>(request.getCalculationCriteria().size()); for (CalculationCriteria criteria : request.getCalculationCriteria()) { Map estimationMap = null; - log.info("Innside get Calculation"); + log.info("Innside get Calculationn"); if(request.getIsAdvanceCalculation() == null || (!request.getIsAdvanceCalculation().booleanValue())) { estimationMap = estimationService.getEstimationMap(criteria, request.getRequestInfo(), masterMap,request.getIsconnectionCalculation(),false);