From 5fd42cb9cdc8ad4e5c1f7276722fcd0e95e8d1a9 Mon Sep 17 00:00:00 2001 From: snehal-gothe Date: Thu, 14 Jul 2022 15:57:56 +0530 Subject: [PATCH 1/5] adding changes for bulk demand for advance --- .../consumer/DemandGenerationConsumer.java | 19 ++++++++++---- .../repository/WSCalculationDao.java | 5 ++-- .../repository/WSCalculationDaoImpl.java | 13 +++++++--- .../builder/WSCalculatorQueryBuilder.java | 4 +-- .../DemandListSchedulerRowMapper.java | 26 +++++++++++++++++++ .../wscalculation/service/DemandService.java | 9 ++++--- .../service/WSCalculationServiceImpl.java | 2 +- 7 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/rowmapper/DemandListSchedulerRowMapper.java 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 1caa7154e..f94e4ddef 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 @@ -281,9 +281,9 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t .atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); - List connectionNos = waterCalculatorDao.getNonMeterConnectionsList(tenantId, dayStartTime, dayEndTime); + Map connectionNos = waterCalculatorDao.getNonMeterConnectionsList(tenantId, dayStartTime, dayEndTime); - List meteredConnectionNos = waterCalculatorDao.getConnectionsNoList(tenantId, + Map meteredConnectionNos = waterCalculatorDao.getConnectionsNoList(tenantId, WSCalculationConstant.meteredConnectionType); @@ -300,13 +300,22 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t String assessmentYear = estimationService.getAssessmentYear(); ArrayList failedConnectionNos = new ArrayList(); - for (String connectionNo : connectionNos) { + for (Map.Entry entry : connectionNos.entrySet()) { + String connectionNo = entry.getKey(); CalculationCriteria calculationCriteria = CalculationCriteria.builder().tenantId(tenantId) .assessmentYear(assessmentYear).connectionNo(connectionNo).from(dayStartTime).to(dayEndTime).build(); List calculationCriteriaList = new ArrayList<>(); calculationCriteriaList.add(calculationCriteria); - CalculationReq calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) - .requestInfo(requestInfo).isconnectionCalculation(true).build(); + CalculationReq calculationReq = null; + if(entry.getValue().equalsIgnoreCase("waterConnection-advance")) { + calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) + .requestInfo(requestInfo).isconnectionCalculation(true).isAdvanceCalculation(true).build(); + } + else { + calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) + .requestInfo(requestInfo).isconnectionCalculation(true).build(); + } + Map masterMap = mDataService.loadMasterData(calculationReq.getRequestInfo(), calculationReq.getCalculationCriteria().get(0).getTenantId()); diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/WSCalculationDao.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/WSCalculationDao.java index 6eac8bc87..a85dba038 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/WSCalculationDao.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/WSCalculationDao.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Set; import org.egov.wscalculation.web.models.MeterConnectionRequest; @@ -22,14 +23,14 @@ public interface WSCalculationDao { int isMeterReadingConnectionExist(List ids); - List getConnectionsNoList(String tenantId, String connectionType); + Map getConnectionsNoList(String tenantId, String connectionType); List getTenantId(); int isBillingPeriodExists(String connectionNo, String billingPeriod); Boolean isDemandExists(String tenantId, Long bilingDate,Long endTime, Set connectionNos); - List getNonMeterConnectionsList(String tenantId, Long dayStartTime, Long dayEndTime); + Map getNonMeterConnectionsList(String tenantId, Long dayStartTime, Long dayEndTime); Boolean isConnectionExists(String tenantId, Long startTime, Long endTime, Set connectionNos); 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..2c41165b5 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 @@ -4,10 +4,12 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import org.egov.wscalculation.producer.WSCalculationProducer; import org.egov.wscalculation.repository.builder.WSCalculatorQueryBuilder; +import org.egov.wscalculation.repository.rowmapper.DemandListSchedulerRowMapper; import org.egov.wscalculation.repository.rowmapper.DemandSchedulerRowMapper; import org.egov.wscalculation.repository.rowmapper.MeterReadingCurrentReadingRowMapper; import org.egov.wscalculation.repository.rowmapper.MeterReadingRowMapper; @@ -42,6 +44,9 @@ public class WSCalculationDaoImpl implements WSCalculationDao { @Autowired private DemandSchedulerRowMapper demandSchedulerRowMapper; + + @Autowired + private DemandListSchedulerRowMapper demandListSchedulerRowMapper; @Value("${egov.meterservice.createmeterconnection}") private String createMeterConnection; @@ -125,19 +130,19 @@ public ArrayList searchConnectionNos(String connectionType, String tenan } @Override - public List getConnectionsNoList(String tenantId, String connectionType) { + public Map 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); + return jdbcTemplate.query(query, preparedStatement.toArray(), demandListSchedulerRowMapper); } @Override - public List getNonMeterConnectionsList(String tenantId, Long dayStartTime, Long dayEndTime) { + public Map 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); + return jdbcTemplate.query(query, preparedStatement.toArray(), demandListSchedulerRowMapper); } @Override 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 548e84092..fcb3ee3c4 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 @@ -35,7 +35,7 @@ public class WSCalculatorQueryBuilder { private final static String connectionNoWaterConnectionSearchQuery = "SELECT conn.connectionNo as connectionno FROM eg_ws_service wc INNER JOIN eg_ws_connection conn ON wc.connection_id = conn.id "; - private static final String connectionNoListQuery = "SELECT distinct(conn.connectionno) FROM eg_ws_connection conn INNER JOIN eg_ws_service ws ON conn.id = ws.connection_id"; + private static final String connectionNoListQuery = "SELECT distinct(conn.connectionno),conn.consumertype FROM eg_ws_connection conn INNER JOIN eg_ws_service ws ON conn.id = ws.connection_id"; private static final String distinctTenantIdsCriteria = "SELECT distinct(tenantid) FROM eg_ws_connection ws"; @@ -43,7 +43,7 @@ public class WSCalculatorQueryBuilder { private static final String PREVIOUS_BILLING_CYCLE_CONNECTION = " select count(*) from eg_ws_connection "; - private static final String nonmeteredConnectionList = " select distinct(conn.connectionno) from eg_ws_connection conn join eg_ws_service ws on conn.id=ws.connection_id where ws.connectiontype='Non_Metered' and conn.status not IN ('Inactive') and conn.connectionno not in ( select distinct(consumercode) from egbs_demand_v1 d where d.businessservice='WS' "; + private static final String nonmeteredConnectionList = " select distinct(conn.connectionno),conn.consumertype from eg_ws_connection conn join eg_ws_service ws on conn.id=ws.connection_id where ws.connectiontype='Non_Metered' and conn.status not IN ('Inactive') and conn.connectionno not in ( select distinct(consumercode) from egbs_demand_v1 d where d.businessservice='WS' "; public String getDistinctTenantIds() { return distinctTenantIdsCriteria; diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/rowmapper/DemandListSchedulerRowMapper.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/rowmapper/DemandListSchedulerRowMapper.java new file mode 100644 index 000000000..e3df33a65 --- /dev/null +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/rowmapper/DemandListSchedulerRowMapper.java @@ -0,0 +1,26 @@ +package org.egov.wscalculation.repository.rowmapper; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.ResultSetExtractor; +import org.springframework.stereotype.Component; + +@Component +public class DemandListSchedulerRowMapper implements ResultSetExtractor> { + + @Override + public Map extractData(ResultSet rs) throws SQLException, DataAccessException { + Map connectionAndConsumerTypeLists = new HashMap<>(); + + while (rs.next()) { + connectionAndConsumerTypeLists.put(rs.getString("connectionno"), rs.getString("consumertype")); + } + return connectionAndConsumerTypeLists; + } +} \ No newline at end of file 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 99b216e4d..9e0be7a21 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 @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Function; +import java.util.stream.Collector; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; @@ -894,11 +895,11 @@ public void generateBulkDemandForTenantId(BulkDemand bulkDemand) { Long dayEndTime = LocalDateTime.of(toDate.getYear(), toDate.getMonth(), toDate.getDayOfMonth(), 23, 59, 59, 999000000) .atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); - List connectionNos = waterCalculatorDao.getNonMeterConnectionsList(tenantId, dayStartTime, dayEndTime);; - Set connectionSet = connectionNos.stream().collect(Collectors.toSet()); - + Map connectionNosAndConsumerTypes = waterCalculatorDao.getNonMeterConnectionsList(tenantId, dayStartTime, dayEndTime);; - if( connectionNos.size() == 0) { + Set connectionSet = connectionNosAndConsumerTypes.keySet().stream().collect(Collectors.toSet()); + + if( connectionNosAndConsumerTypes.size() == 0) { List allConnections = waterCalculatorDao.searchConnectionNos(WSCalculationConstant.nonMeterdConnection, tenantId); throw new CustomException("NO_CONNECTIONS_TO_GENERATE_DEMANDS", "Zero Demands Generated Successfully, "+ allConnections.size() +" connections already have demands in this billing cycle!"); 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 3fb77d6f2..6b75ad49c 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 @@ -152,7 +152,7 @@ public List getCalculation(CalculationReq request) { */ public List bulkDemandGeneration(CalculationReq request, Map masterMap) { List calculations = getCalculations(request, masterMap); - demandService.generateDemand(request.getRequestInfo(), calculations, masterMap, true, false, false); + demandService.generateDemand(request.getRequestInfo(), calculations, masterMap, true, false, request.getIsAdvanceCalculation()); return calculations; } From 98ec4e66e3c53ec3d96fdde46011cec099c80e81 Mon Sep 17 00:00:00 2001 From: snehal-gothe Date: Thu, 14 Jul 2022 16:03:00 +0530 Subject: [PATCH 2/5] adding changes for bulk demand for advance --- .../egov/wscalculation/consumer/DemandGenerationConsumer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f94e4ddef..db99b893c 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 @@ -313,7 +313,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t } else { calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) - .requestInfo(requestInfo).isconnectionCalculation(true).build(); + .requestInfo(requestInfo).isconnectionCalculation(true).isAdvanceCalculation(false).build(); } From 1b59567b2a32da7746c3f0388ddd78a34752d982 Mon Sep 17 00:00:00 2001 From: snehal-gothe Date: Fri, 15 Jul 2022 13:54:28 +0530 Subject: [PATCH 3/5] bulk demand changes --- .../egov/wscalculation/consumer/DemandGenerationConsumer.java | 2 +- .../repository/builder/WSCalculatorQueryBuilder.java | 4 ++-- .../repository/rowmapper/DemandListSchedulerRowMapper.java | 2 +- 3 files changed, 4 insertions(+), 4 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 db99b893c..61bcd1fb2 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 List calculationCriteriaList = new ArrayList<>(); calculationCriteriaList.add(calculationCriteria); CalculationReq calculationReq = null; - if(entry.getValue().equalsIgnoreCase("waterConnection-advance")) { + if(entry.getValue().equalsIgnoreCase("advance")) { calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) .requestInfo(requestInfo).isconnectionCalculation(true).isAdvanceCalculation(true).build(); } 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 fcb3ee3c4..9396bd68e 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 @@ -35,7 +35,7 @@ public class WSCalculatorQueryBuilder { private final static String connectionNoWaterConnectionSearchQuery = "SELECT conn.connectionNo as connectionno FROM eg_ws_service wc INNER JOIN eg_ws_connection conn ON wc.connection_id = conn.id "; - private static final String connectionNoListQuery = "SELECT distinct(conn.connectionno),conn.consumertype FROM eg_ws_connection conn INNER JOIN eg_ws_service ws ON conn.id = ws.connection_id"; + private static final String connectionNoListQuery = "SELECT distinct(conn.connectionno),conn.paymenttype FROM eg_ws_connection conn INNER JOIN eg_ws_service ws ON conn.id = ws.connection_id"; private static final String distinctTenantIdsCriteria = "SELECT distinct(tenantid) FROM eg_ws_connection ws"; @@ -43,7 +43,7 @@ public class WSCalculatorQueryBuilder { private static final String PREVIOUS_BILLING_CYCLE_CONNECTION = " select count(*) from eg_ws_connection "; - private static final String nonmeteredConnectionList = " select distinct(conn.connectionno),conn.consumertype from eg_ws_connection conn join eg_ws_service ws on conn.id=ws.connection_id where ws.connectiontype='Non_Metered' and conn.status not IN ('Inactive') and conn.connectionno not in ( select distinct(consumercode) from egbs_demand_v1 d where d.businessservice='WS' "; + private static final String nonmeteredConnectionList = " select distinct(conn.connectionno),conn.paymenttype from eg_ws_connection conn join eg_ws_service ws on conn.id=ws.connection_id where ws.connectiontype='Non_Metered' and conn.status not IN ('Inactive') and conn.connectionno not in ( select distinct(consumercode) from egbs_demand_v1 d where d.businessservice='WS' "; public String getDistinctTenantIds() { return distinctTenantIdsCriteria; diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/rowmapper/DemandListSchedulerRowMapper.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/rowmapper/DemandListSchedulerRowMapper.java index e3df33a65..47db9cafb 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/rowmapper/DemandListSchedulerRowMapper.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/repository/rowmapper/DemandListSchedulerRowMapper.java @@ -19,7 +19,7 @@ public Map extractData(ResultSet rs) throws SQLException, DataAc Map connectionAndConsumerTypeLists = new HashMap<>(); while (rs.next()) { - connectionAndConsumerTypeLists.put(rs.getString("connectionno"), rs.getString("consumertype")); + connectionAndConsumerTypeLists.put(rs.getString("connectionno"), rs.getString("paymenttype")); } return connectionAndConsumerTypeLists; } From 3f172bedfc40562264528cc4ce1540bc0cfe4b8b Mon Sep 17 00:00:00 2001 From: snehal-gothe Date: Mon, 18 Jul 2022 19:02:21 +0530 Subject: [PATCH 4/5] bulk changes --- .../consumer/DemandGenerationConsumer.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 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 61bcd1fb2..3eb5d7dda 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 @@ -306,15 +306,11 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t .assessmentYear(assessmentYear).connectionNo(connectionNo).from(dayStartTime).to(dayEndTime).build(); List calculationCriteriaList = new ArrayList<>(); calculationCriteriaList.add(calculationCriteria); - CalculationReq calculationReq = null; - if(entry.getValue().equalsIgnoreCase("advance")) { - calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) - .requestInfo(requestInfo).isconnectionCalculation(true).isAdvanceCalculation(true).build(); - } - else { - calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) + + + CalculationReq calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) .requestInfo(requestInfo).isconnectionCalculation(true).isAdvanceCalculation(false).build(); - } + Map masterMap = mDataService.loadMasterData(calculationReq.getRequestInfo(), From 4edfa7cea07a9636e7d2621d1d25c7027b3f04ec Mon Sep 17 00:00:00 2001 From: snehal-gothe Date: Tue, 19 Jul 2022 10:35:17 +0530 Subject: [PATCH 5/5] bulkd demand changes --- .../consumer/DemandGenerationConsumer.java | 16 +++++++++++++--- .../wscalculation/service/DemandService.java | 12 +++++++----- .../wscalculation/service/EstimationService.java | 14 ++++++++++++-- .../service/WSCalculationServiceImpl.java | 8 ++++---- .../wscalculation/web/models/CalculationReq.java | 3 +++ 5 files changed, 39 insertions(+), 14 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 3eb5d7dda..2217e87bc 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,9 +307,19 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t List calculationCriteriaList = new ArrayList<>(); calculationCriteriaList.add(calculationCriteria); - - CalculationReq calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) - .requestInfo(requestInfo).isconnectionCalculation(true).isAdvanceCalculation(false).build(); + CalculationReq calculationReq = null; + if(entry.getValue().equalsIgnoreCase("advance")) { + calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) + .requestInfo(requestInfo).isconnectionCalculation(true).isAdvanceCalculation(false). + isAdvanceDemand(true).build(); + + + } + else { + calculationReq = CalculationReq.builder().calculationCriteria(calculationCriteriaList) + .requestInfo(requestInfo).isconnectionCalculation(true).isAdvanceCalculation(false). + isAdvanceDemand(false).build(); + } 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 9e0be7a21..7766d7799 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 @@ -142,7 +142,7 @@ public class DemandService { * generated or updated */ public List generateDemand(RequestInfo requestInfo, List calculations, - Map masterMap, boolean isForConnectionNo, boolean isWSUpdateSMS, boolean isAdvance) { + Map masterMap, boolean isForConnectionNo, boolean isWSUpdateSMS, boolean isAdvance, boolean isAdvanceDemand) { @SuppressWarnings("unchecked") Map financialYearMaster = (Map) masterMap .get(WSCalculationConstant.BILLING_PERIOD); @@ -189,7 +189,7 @@ public List generateDemand(RequestInfo requestInfo, List ca } List createdDemands = new ArrayList<>(); if (!CollectionUtils.isEmpty(createCalculations)) - createdDemands = createDemand(requestInfo, createCalculations, masterMap, isForConnectionNo, isWSUpdateSMS,isAdvance); + createdDemands = createDemand(requestInfo, createCalculations, masterMap, isForConnectionNo, isWSUpdateSMS,isAdvance,isAdvanceDemand); if (!CollectionUtils.isEmpty(updateCalculations)) createdDemands = updateDemandForCalculation(requestInfo, updateCalculations, fromDate, toDate, @@ -205,7 +205,7 @@ public List generateDemand(RequestInfo requestInfo, List ca * @return Returns list of demands */ private List createDemand(RequestInfo requestInfo, List calculations, - Map masterMap, boolean isForConnectionNO, boolean isWSUpdateSMS, boolean isAdvance) { + Map masterMap, boolean isForConnectionNO, boolean isWSUpdateSMS, boolean isAdvance, boolean isAdvanceDemand) { List demands = new LinkedList<>(); List smsRequests = new LinkedList<>(); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("d/MM/uuuu"); @@ -315,9 +315,11 @@ private List createDemand(RequestInfo requestInfo, List cal } } } - log.info("Demand Object" + demands.toString()); - List demandRes = demandRepository.saveDemand(requestInfo, demands); + log.info("Demand Object" + demands.toString()); + List demandRes = demandRepository.saveDemand(requestInfo, demands); + + return demandRes; } 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 36b6db9dc..ed666f75d 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 @@ -129,13 +129,23 @@ private List getEstimatesForTax(Map waterCh if(!isAdvanceCalculation) { if(connection.getArrears()!=null) { - estimates.add(TaxHeadEstimate.builder().taxHeadCode(isconnectionCalculation ? WSCalculationConstant.WS_CHARGE :WSCalculationConstant.WS_CHARGE_ARREAR) - .estimateAmount(waterCharge.get("arrears").setScale(2, 2)).build()); + if(isconnectionCalculation) { + estimates.add(TaxHeadEstimate.builder().taxHeadCode(WSCalculationConstant.WS_CHARGE) + .estimateAmount(waterCharge.get("waterCharge").setScale(2, 2)).build()); + }else { + estimates.add(TaxHeadEstimate.builder().taxHeadCode(WSCalculationConstant.WS_CHARGE_ARREAR) + .estimateAmount(waterCharge.get("arrears").setScale(2, 2)).build()); + } + } if(connection.getPenalty()!=null) { estimates.add(TaxHeadEstimate.builder().taxHeadCode(isconnectionCalculation ? WSCalculationConstant.WS_CHARGE :WSCalculationConstant.WS_PENALTY) .estimateAmount(waterCharge.get("penalty").setScale(2, 2)).build()); } + else { + estimates.add(TaxHeadEstimate.builder().taxHeadCode(WSCalculationConstant.WS_CHARGE) + .estimateAmount(waterCharge.get("waterCharge").setScale(2, 2)).build()); + } }else { estimates.add(TaxHeadEstimate.builder().taxHeadCode(isconnectionCalculation ? WSCalculationConstant.WS_CHARGE :WSCalculationConstant.ADVANCE_COLLECTION) .estimateAmount(waterCharge.get("advance").setScale(2, 2)).build()); 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 6b75ad49c..f6a875b08 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 @@ -134,10 +134,10 @@ public List getCalculation(CalculationReq request) { if(request.getIsAdvanceCalculation() != null && request.getIsAdvanceCalculation().booleanValue()) { demandService.generateDemand(request.getRequestInfo(), calculations, masterMap, - request.getIsconnectionCalculation(), isWSUpdateSMS, request.getIsAdvanceCalculation()); + request.getIsconnectionCalculation(), isWSUpdateSMS, request.getIsAdvanceCalculation(), false); }else { demandService.generateDemand(request.getRequestInfo(), calculations, masterMap, - request.getIsconnectionCalculation(), isWSUpdateSMS, false); + request.getIsconnectionCalculation(), isWSUpdateSMS, false, false); } unsetWaterConnection(calculations); return calculations; @@ -152,7 +152,7 @@ public List getCalculation(CalculationReq request) { */ public List bulkDemandGeneration(CalculationReq request, Map masterMap) { List calculations = getCalculations(request, masterMap); - demandService.generateDemand(request.getRequestInfo(), calculations, masterMap, true, false, request.getIsAdvanceCalculation()); + demandService.generateDemand(request.getRequestInfo(), calculations, masterMap, true, false, request.getIsAdvanceCalculation(), request.getIsAdvanceDemand()); return calculations; } @@ -267,7 +267,7 @@ List getCalculations(CalculationReq request, Map ma List calculations = new ArrayList<>(request.getCalculationCriteria().size()); for (CalculationCriteria criteria : request.getCalculationCriteria()) { Map estimationMap = null; - if(request.getIsAdvanceCalculation() == null) { + if(request.getIsAdvanceCalculation() == null || (!request.getIsAdvanceCalculation().booleanValue())) { estimationMap = estimationService.getEstimationMap(criteria, request.getRequestInfo(), masterMap,request.getIsconnectionCalculation(),false); }else { diff --git a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/web/models/CalculationReq.java b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/web/models/CalculationReq.java index 19cc1401e..e254e915f 100644 --- a/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/web/models/CalculationReq.java +++ b/municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/web/models/CalculationReq.java @@ -43,6 +43,9 @@ public class CalculationReq { private Boolean isconnectionCalculation; private Boolean isAdvanceCalculation; + + private Boolean isAdvanceDemand; + @Valid @NotNull