Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #853 from egovernments/ISTE-224
Browse files Browse the repository at this point in the history
Iste 224
  • Loading branch information
pradeepkumarcm-egov authored Jul 8, 2024
2 parents 942a461 + 5fada65 commit 7968a86
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
@Repository
public class WaterDaoImpl implements WaterDao {

@Autowired
private DemandNotGeneratedRowMapper demandNotGeneratedRowMapper;

@Autowired
private InactiveConsumerReportRowMapper inactiveConsumerReportRowMapper;
@Autowired
Expand Down Expand Up @@ -665,4 +668,18 @@ public List<InactiveConsumerReportData> getInactiveConsumerReport(Long monthStar
inactiveConsumerReportList=jdbcTemplate.query(inactive_consumer_query.toString(), preparedStatement.toArray(),inactiveConsumerReportRowMapper);
return inactiveConsumerReportList;
}

public List<ConsumersDemandNotGenerated> getConsumersByPreviousMeterReading(Long previousMeterReading, String tenantId)
{
StringBuilder query=new StringBuilder(wsQueryBuilder.DEMAND_NOT_GENERATED_QUERY);

List<Object> preparedStatement=new ArrayList<>();
preparedStatement.add(tenantId);
preparedStatement.add(previousMeterReading);
preparedStatement.add(tenantId);

log.info("Query for consumer demand not generated "+ query +" prepared statement "+ preparedStatement);
List<ConsumersDemandNotGenerated> consumersDemandNotGeneratedList=jdbcTemplate.query(query.toString(),preparedStatement.toArray(),demandNotGeneratedRowMapper);
return consumersDemandNotGeneratedList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ public class WsQueryBuilder {
+ " connectionno IN (SELECT distinct connectionno FROM eg_ws_connection WHERE status='Inactive' AND"
+ " lastmodifiedtime >= ? AND lastmodifiedtime <= ? AND tenantid=?) "
+ " order by connectionno,lastmodifiedtime desc";

public static final String DEMAND_NOT_GENERATED_QUERY="select distinct conn.connectionno as connectionno from eg_ws_connection conn " +
"INNER JOIN eg_ws_service wc ON wc.connection_id = conn.id WHERE conn.status='Active' " +
"AND conn.tenantid=? and wc.connectiontype='Non_Metered' and conn.previousreadingdate=? and connectionno NOT IN " +
"(select distinct consumercode from egbs_demand_v1 d inner join egbs_demanddetail_v1 dd on dd.demandid = d.id " +
"where dd.taxheadcode='10101' and d.status ='ACTIVE' and d.businessservice='WS' and " +
"d.tenantid=?) order by connectionno;";

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.egov.waterconnection.repository.rowmapper;

import org.egov.waterconnection.web.models.ConsumersDemandNotGenerated;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.stereotype.Component;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

@Component
public class DemandNotGeneratedRowMapper implements ResultSetExtractor<List<ConsumersDemandNotGenerated>> {
@Override
public List<ConsumersDemandNotGenerated> extractData(ResultSet resultSet) throws SQLException, DataAccessException {
List<ConsumersDemandNotGenerated> consumersDemandNotGeneratedList=new ArrayList<>();
while(resultSet.next())
{
ConsumersDemandNotGenerated consumersDemandNotGenerated=new ConsumersDemandNotGenerated();
consumersDemandNotGenerated.setConsumerCode(resultSet.getString("connectionno"));
consumersDemandNotGeneratedList.add(consumersDemandNotGenerated);
}
return consumersDemandNotGeneratedList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ List<CollectionReportData> collectionReport(String paymentStartDate, String paym

List<InactiveConsumerReportData> inactiveConsumerReport(String monthStartDate,String monthEndDate,String tenantId, @Valid Integer offset, @Valid Integer limit, RequestInfo requestInfo);

WaterConnectionResponse getConsumersWithDemandNotGenerated(String previousMeterReading, String tenantId,RequestInfo requestInfo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -842,4 +842,24 @@ public List<InactiveConsumerReportData> inactiveConsumerReport(String monthStart
List<InactiveConsumerReportData> inactiveConsumerReport=waterDaoImpl.getInactiveConsumerReport(monthStartDateTime,mothEndDateTime,tenantId,offset,limit);
return inactiveConsumerReport;
}

@Override
public WaterConnectionResponse getConsumersWithDemandNotGenerated(String previousMeterReading, String tenantId ,RequestInfo requestInfo)
{
Long previousReadingEpoch;
try {
previousReadingEpoch = Long.parseLong(previousMeterReading);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid format for previousMeterReading. Expected a timestamp in milliseconds.", e);
}

List<ConsumersDemandNotGenerated> list=waterDaoImpl.getConsumersByPreviousMeterReading(previousReadingEpoch,tenantId);
Set<String> connectionNo=new HashSet<>();
for(ConsumersDemandNotGenerated connection:list)
{
connectionNo.add(connection.getConsumerCode());
}
SearchCriteria criteria=SearchCriteria.builder().connectionNoSet(connectionNo).tenantId(tenantId).build();
return search(criteria,requestInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,13 @@ public ResponseEntity<WaterConnectionByDemandGenerationDateResponse> countWCbyDe
return new ResponseEntity<>(response, HttpStatus.OK);
}

@PostMapping("/consumers/demand-not-generated")
public ResponseEntity<WaterConnectionResponse> getConsumersWithDemandNotGenerated(@Valid @RequestBody RequestInfoWrapper requestInfoWrapper,@RequestParam(value="previousMeterReading") String previousMeterReading,@RequestParam (value="tenantId") String tenantId)
{
WaterConnectionResponse response= waterService.getConsumersWithDemandNotGenerated(previousMeterReading,tenantId,requestInfoWrapper.getRequestInfo());
response.setResponseInfo(
responseInfoFactory.createResponseInfoFromRequestInfo(requestInfoWrapper.getRequestInfo(), true));
return new ResponseEntity<>(response, HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.egov.waterconnection.web.models;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class ConsumersDemandNotGenerated {
private String consumerCode;
}

0 comments on commit 7968a86

Please sign in to comment.