Skip to content

Commit

Permalink
added changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sriranjan Srivastava authored and Sriranjan Srivastava committed Feb 29, 2024
2 parents 44900b4 + 2b2e85a commit 5fdecaf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public ResponseEntity<AuthResponse> search(@Valid @RequestBody RequestInfo reque
return new ResponseEntity<>(authResponse,HttpStatus.OK);
}

@RequestMapping(value = {"/authorization/url/citizen"}, method = RequestMethod.POST )
public ResponseEntity<AuthResponse> searchForcitizen(@Valid @RequestBody RequestInfo requestInfo,@RequestParam("module") String module) throws NoSuchAlgorithmException
{
AuthResponse authResponse=new AuthResponse();
URI redirectionURL=userService.getRedirectionURL(module,authResponse);
authResponse.setRedirectURL(redirectionURL.toString());
log.info("Redirection URL"+redirectionURL.toString());
return new ResponseEntity<>(authResponse,HttpStatus.OK);
}


@RequestMapping(value = "/token", method = RequestMethod.POST)
public ResponseEntity<TokenResponse> getToken(@Valid @RequestBody TokenRequest tokenRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public List<MeterReading> createMeterReadingBulk(MeterConnectionRequest meterCon
}
if(mr.getStatus()==null) mr.setStatus("Meter Reading entered successfully");
}
meterReadingOutput.add(meterReadingsList.get(0));
meterReadingOutput.add(mr);

}
return meterReadingOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public Boolean validateMeterReadingBulk(RequestInfo requestInfo,MeterReading met

// Future Billing Period Check
validateBillingPeriod(meterReading.getBillingPeriod());
String errorMessage="";
List<WaterConnection> waterConnectionList = calculationUtil.getWaterConnection(requestInfo,
meterReading.getConnectionNo(), meterReading.getTenantId());
WaterConnection connection = null;
Expand All @@ -135,10 +135,13 @@ public Boolean validateMeterReadingBulk(RequestInfo requestInfo,MeterReading met
}

if (meterReading.getGenerateDemand() && connection == null) {
errorMessage=errorMessage.concat("Invalid water connection number");
errorMap.put("INVALID_METER_READING_CONNECTION_NUMBER", "Invalid water connection number");
}
if (connection != null
&& !WSCalculationConstant.meteredConnectionType.equalsIgnoreCase(connection.getConnectionType())) {
errorMessage=errorMessage.equalsIgnoreCase("")?errorMessage.concat("Meter reading can not be create for :").concat(connection.getConnectionType()).concat(" connection"):errorMessage.concat(", Meter reading can not be create for :").concat(connection.getConnectionType()).concat(" connection");

errorMap.put("INVALID_WATER_CONNECTION_TYPE",
"Meter reading can not be create for : " + connection.getConnectionType() + " connection");
}
Expand All @@ -150,42 +153,60 @@ public Boolean validateMeterReadingBulk(RequestInfo requestInfo,MeterReading met
if (!CollectionUtils.isEmpty(previousMeterReading)) {
Double currentMeterReading = previousMeterReading.get(0).getCurrentReading();
if (meterReading.getCurrentReading() < currentMeterReading) {

errorMessage=errorMessage.equalsIgnoreCase("")?errorMessage.concat("Current meter reading has to be greater than the past last readings in the meter reading!"):errorMessage.concat(", Current meter reading has to be greater than the past last readings in the meter reading!");

errorMap.put("INVALID_METER_READING_CONNECTION_NUMBER",
"Current meter reading has to be greater than the past last readings in the meter reading!");
}
}

if (meterReading.getCurrentReading() < meterReading.getLastReading()) {
errorMessage=errorMessage.equalsIgnoreCase("")?errorMessage.concat("Current Meter Reading cannot be less than last meter reading"):
errorMessage.concat(", Current Meter Reading cannot be less than last meter reading");

errorMap.put("INVALID_METER_READING_LAST_READING",
"Current Meter Reading cannot be less than last meter reading");
}

if (StringUtils.isEmpty(meterReading.getMeterStatus())) {
errorMessage=errorMessage.equalsIgnoreCase("")?errorMessage.concat("Meter status can not be null"):
errorMessage.concat(", Meter status can not be null");
errorMap.put("INVALID_METER_READING_STATUS", "Meter status can not be null");
}

if (isUpdate && (meterReading.getCurrentReading() == null)) {
errorMessage=errorMessage.equalsIgnoreCase("")?errorMessage.concat("Current Meter Reading cannot be update without current meter reading"):
errorMessage.concat(", Current Meter Reading cannot be update without current meter reading");
errorMap.put("INVALID_CURRENT_METER_READING",
"Current Meter Reading cannot be update without current meter reading");
}

if (isUpdate && !StringUtils.isEmpty(meterReading.getId())) {
int n = wSCalculationDao.isMeterReadingConnectionExist(Arrays.asList(meterReading.getId()));
if (n > 0) {
errorMessage=errorMessage.equalsIgnoreCase("")?errorMessage.concat("Meter reading Id already present"):
errorMessage.concat(", Meter reading Id already present");
errorMap.put("INVALID_METER_READING_CONNECTION", "Meter reading Id already present");
}
}
if (StringUtils.isEmpty(meterReading.getBillingPeriod())) {
errorMessage=errorMessage.equalsIgnoreCase("")?errorMessage.concat("Meter Reading cannot be updated without billing period"):
errorMessage.concat(", Meter Reading cannot be updated without billing period");
errorMap.put("INVALID_BILLING_PERIOD", "Meter Reading cannot be updated without billing period");
}

int billingPeriodNumber = wSCalculationDao.isBillingPeriodExists(meterReading.getConnectionNo(),
meterReading.getBillingPeriod());
if (billingPeriodNumber > 0)
{
errorMessage=errorMessage.equalsIgnoreCase("")?errorMessage.concat("Billing Period Already Exists"):
errorMessage.concat(", Billing Period Already Exists");

errorMap.put("INVALID_METER_READING_BILLING_PERIOD", "Billing Period Already Exists");

}
if (!errorMap.isEmpty()) {
meterReading.setStatus(errorMap.toString());
meterReading.setStatus(errorMessage);
return false;
}

Expand Down

0 comments on commit 5fdecaf

Please sign in to comment.