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/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/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 5c3a15489..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 @@ -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(), @@ -192,12 +192,12 @@ 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() + /*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. @@ -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; @@ -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,11 +284,16 @@ 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(); + Map masterMap = mDataService.loadMasterData(requestInfo, + tenantId); + + 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) .assessmentYear(assessmentYear).connectionNo(connectionNo).from(dayStartTime).to(dayEndTime).build(); @@ -310,7 +313,13 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t failedConnectionNos.add(connectionNo); continue; } - + HashMap genarateDemandData = new HashMap(); + genarateDemandData.put("calculationReq", calculationReq); + genarateDemandData.put("billingCycle",billingCycle); + genarateDemandData.put("masterMap",masterMap); + genarateDemandData.put("isSendMessage",isSendMessage); + genarateDemandData.put("tenantId",tenantId); + /* * List demands = demandService.searchDemand(tenantId, consumerCodes, * previousFromDate.getTimeInMillis(), previousToDate.getTimeInMillis(), @@ -318,18 +327,44 @@ 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); - } + log.info("sending generate demand for connection no :"+connectionNo); + producer.push(config.getWsGenerateDemandBulktopic(),genarateDemandData); - } catch (Exception e) { - System.out.println("Got the exception while genating the demands:" + e); - failedConnectionNos.add(connectionNo); + } + 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()); } } - System.out.println("demand Failed event Messages to the GP users "); - if (isSendMessage && failedConnectionNos.size() > 0) { + 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(); ActionItem actionItem = ActionItem.builder().actionUrl(actionLink).build(); @@ -344,7 +379,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()); @@ -477,7 +512,24 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t } }); + }*/ + } + + public void generateDemandInBulk(CalculationReq calculationReq, String billingCycle, Map masterMap, + boolean isSendMessage,String tenantId) { + log.info("masterMap:"+masterMap); + try { + if(!tenantId.equals(config.getSmsExcludeTenant())) { + generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage); + } + + } 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()); + } + } /** @@ -513,9 +565,8 @@ 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) { - log.info("Billing master data values for non metered connection:: {}", messageData); Map billingMasterData; BulkDemand bulkDemand; boolean isSendMessage = false; @@ -533,10 +584,29 @@ 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}" }) + public void generateDemandInBulkListner(HashMap messageData) { + 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,masterMap,isSendMessage,tenantId); + } + } 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(); 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); 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..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 @@ -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(); } @@ -273,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(); } 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..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 @@ -78,10 +78,23 @@ public Map getEstimationMap(CalculationCriteria criteria, RequestI Map billingSlabMaster = new HashMap<>(); Map timeBasedExemptionMasterMap = new HashMap<>(); ArrayList billingSlabIds = new ArrayList<>(); - billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER, + 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 + 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, @@ -189,7 +202,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 +212,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 +284,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 17572ec9c..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,6 +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 Calculationn"); if(request.getIsAdvanceCalculation() == null || (!request.getIsAdvanceCalculation().booleanValue())) { estimationMap = estimationService.getEstimationMap(criteria, request.getRequestInfo(), masterMap,request.getIsconnectionCalculation(),false); @@ -317,7 +343,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); 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