From d81cfcbd5623ef1a96ff7bdb811d1428feb0a730 Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Thu, 19 Dec 2024 10:43:56 +0530 Subject: [PATCH 01/11] Added configurability for recomputing attendance for muster roll update --- .../java/org/egov/config/MusterRollServiceConfiguration.java | 3 +++ .../src/main/java/org/egov/service/MusterRollService.java | 2 +- backend/muster-roll/src/main/resources/application.properties | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java index 1c84630a17..0b3b16cdb6 100644 --- a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java +++ b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java @@ -127,6 +127,9 @@ public class MusterRollServiceConfiguration { @Value("${works.contract.service.code}") private String contractServiceCode; + @Value("${musterroll.update.recompute.attendance.enabled:true}") + private boolean recomputeAttendanceEnabled; + @PostConstruct public void initialize() { TimeZone.setDefault(TimeZone.getTimeZone(timeZone)); diff --git a/backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java b/backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java index 34ff246e74..9147b09295 100644 --- a/backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java +++ b/backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java @@ -270,7 +270,7 @@ private MusterRoll fetchExistingMusterRoll(MusterRoll musterRoll) { * @return */ private boolean isComputeAttendance (MusterRoll musterRoll) { - if (musterRoll.getAdditionalDetails() != null) { + if (config.isRecomputeAttendanceEnabled() && musterRoll.getAdditionalDetails() != null) { try { JsonNode node = mapper.readTree(mapper.writeValueAsString(musterRoll.getAdditionalDetails())); if (node.findValue(COMPUTE_ATTENDENSE) != null && StringUtils.isNotBlank(node.findValue(COMPUTE_ATTENDENSE).textValue())) { diff --git a/backend/muster-roll/src/main/resources/application.properties b/backend/muster-roll/src/main/resources/application.properties index 5d8bbfe492..d95dc6a82a 100644 --- a/backend/muster-roll/src/main/resources/application.properties +++ b/backend/muster-roll/src/main/resources/application.properties @@ -116,3 +116,6 @@ works.bankaccounts.search.endpoint=/bankaccount-service/bankaccount/v1/_search #-----------Contract service code------------# works.contract.service.code=WORKS-CONTRACT + +#-----------Muster roll update api config------------# +musterroll.update.recompute.attendance.enabled=true From e50e62cb98f68f0fb95e25ab7baf363bfd60607d Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Fri, 20 Dec 2024 17:09:50 +0530 Subject: [PATCH 02/11] added build configs for health muster roll --- build/build-config.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/build-config.yml b/build/build-config.yml index c8f2b4670a..fff9fd2fac 100644 --- a/build/build-config.yml +++ b/build/build-config.yml @@ -42,6 +42,13 @@ config: image-name: "muster-roll" - work-dir: "backend/muster-roll/src/main/resources/db" image-name: "muster-roll-db" + - name: "builds/digit-works/backend/muster-roll" + build: + - work-dir: "backend/muster-roll" + dockerfile: "build/maven-java17/Dockerfile" + image-name: "health-muster-roll" + - work-dir: "backend/muster-roll/src/main/resources/db" + image-name: "health-muster-roll-db" - name: "builds/digit-works/backend/estimates" build: - work-dir: "backend/estimates" From d49fcf08b7f6fe778cad34914e35bdcc3e713dbf Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Mon, 23 Dec 2024 15:56:14 +0530 Subject: [PATCH 03/11] Revert "added build configs for health muster roll" This reverts commit e50e62cb98f68f0fb95e25ab7baf363bfd60607d. --- build/build-config.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build/build-config.yml b/build/build-config.yml index fff9fd2fac..c8f2b4670a 100644 --- a/build/build-config.yml +++ b/build/build-config.yml @@ -42,13 +42,6 @@ config: image-name: "muster-roll" - work-dir: "backend/muster-roll/src/main/resources/db" image-name: "muster-roll-db" - - name: "builds/digit-works/backend/muster-roll" - build: - - work-dir: "backend/muster-roll" - dockerfile: "build/maven-java17/Dockerfile" - image-name: "health-muster-roll" - - work-dir: "backend/muster-roll/src/main/resources/db" - image-name: "health-muster-roll-db" - name: "builds/digit-works/backend/estimates" build: - work-dir: "backend/estimates" From 4a5d4a8a41306668ba7898048315ecc2fc1fdda0 Mon Sep 17 00:00:00 2001 From: Harish S <119594385+Harish-egov@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:55:18 +0530 Subject: [PATCH 04/11] Update build-config.yml --- build/build-config.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/build-config.yml b/build/build-config.yml index c8f2b4670a..cc8e08871c 100644 --- a/build/build-config.yml +++ b/build/build-config.yml @@ -42,6 +42,13 @@ config: image-name: "muster-roll" - work-dir: "backend/muster-roll/src/main/resources/db" image-name: "muster-roll-db" + - name: "builds/digit-works/backend/health-muster-roll" + build: + - work-dir: "backend/muster-roll" + dockerfile: "build/maven/Dockerfile" + image-name: "health-muster-roll" + - work-dir: "backend/muster-roll/src/main/resources/db" + image-name: "health-muster-roll-db" - name: "builds/digit-works/backend/estimates" build: - work-dir: "backend/estimates" From 718729d988fe3d42445db4eeda1d5608d58fe821 Mon Sep 17 00:00:00 2001 From: Harish S <119594385+Harish-egov@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:57:31 +0530 Subject: [PATCH 05/11] Update build-config.yml --- build/build-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build-config.yml b/build/build-config.yml index cc8e08871c..538423934d 100644 --- a/build/build-config.yml +++ b/build/build-config.yml @@ -45,7 +45,7 @@ config: - name: "builds/digit-works/backend/health-muster-roll" build: - work-dir: "backend/muster-roll" - dockerfile: "build/maven/Dockerfile" + dockerfile: "build/maven-java17/Dockerfile" image-name: "health-muster-roll" - work-dir: "backend/muster-roll/src/main/resources/db" image-name: "health-muster-roll-db" From 8d584bd2ee256191e36d40c0b23ea047288fe54b Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Thu, 26 Dec 2024 16:02:29 +0530 Subject: [PATCH 06/11] Muster role service changes for validation, search and skills --- .../MusterRollServiceConfiguration.java | 21 ++++++++++++ .../querybuilder/MusterRollQueryBuilder.java | 4 +++ .../org/egov/util/MusterRollServiceUtil.java | 23 +++++++++++-- .../src/main/java/org/egov/util/UserUtil.java | 34 +++++++++++-------- .../egov/validator/MusterRollValidator.java | 2 +- .../controllers/MusterRollApiController.java | 9 ++++- .../web/models/MusterRollSearchCriteria.java | 3 ++ .../web/models/MusterRollSearchRequest.java | 21 ++++++++++++ .../src/main/resources/application.properties | 2 ++ 9 files changed, 101 insertions(+), 18 deletions(-) create mode 100644 backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchRequest.java diff --git a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java index 0b3b16cdb6..7c2a363636 100644 --- a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java +++ b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java @@ -130,6 +130,27 @@ public class MusterRollServiceConfiguration { @Value("${musterroll.update.recompute.attendance.enabled:true}") private boolean recomputeAttendanceEnabled; + @Value("${musterroll.individual.entry.roles.enabled:false}") + private boolean individualEntryRolesEnabled; + + @Value("${musterroll.validate.start.date.monday.enabled:true}") + private boolean validateStartDateMondayEnabled; + + @Value("${egov.user.host}") + private String userHost; + + @Value("${egov.user.context.path}") + private String userContextPath; + + @Value("${egov.user.create.path}") + private String userCreateEndpoint; + + @Value("${egov.user.search.path}") + private String userSearchEndpoint; + + @Value("${egov.user.update.path}") + private String userUpdateEndpoint; + @PostConstruct public void initialize() { TimeZone.setDefault(TimeZone.getTimeZone(timeZone)); diff --git a/backend/muster-roll/src/main/java/org/egov/repository/querybuilder/MusterRollQueryBuilder.java b/backend/muster-roll/src/main/java/org/egov/repository/querybuilder/MusterRollQueryBuilder.java index 6a1058a3c8..f19cbfe6e6 100644 --- a/backend/muster-roll/src/main/java/org/egov/repository/querybuilder/MusterRollQueryBuilder.java +++ b/backend/muster-roll/src/main/java/org/egov/repository/querybuilder/MusterRollQueryBuilder.java @@ -84,6 +84,10 @@ private StringBuilder prepareSearchQuery(MusterRollSearchCriteria searchCriteria addClauseIfRequired(preparedStmtList, queryBuilder); queryBuilder.append(" muster.attendance_register_id=? "); preparedStmtList.add(searchCriteria.getRegisterId()); + } else if (searchCriteria.getRegisterIds() != null && !searchCriteria.getRegisterIds().isEmpty()) { + addClauseIfRequired(preparedStmtList, queryBuilder); + queryBuilder.append(" muster.attendance_register_id IN (").append(createQuery(searchCriteria.getRegisterIds())).append(")"); + addToPreparedStatement(preparedStmtList, searchCriteria.getRegisterIds()); } else if (registerIds != null && !registerIds.isEmpty()) { addClauseIfRequired(preparedStmtList, queryBuilder); queryBuilder.append(" muster.attendance_register_id IN (").append(createQuery(registerIds)).append(")"); diff --git a/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java b/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java index 0d150e8e43..345d5e5a2e 100644 --- a/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java +++ b/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java @@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.egov.common.contract.request.RequestInfo; +import org.egov.common.contract.request.Role; +import org.egov.common.contract.user.UserDetailResponse; import org.egov.common.models.individual.Identifier; import org.egov.common.models.individual.Individual; import org.egov.common.models.individual.Skill; @@ -29,6 +31,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -42,14 +45,19 @@ public class MusterRollServiceUtil { private final RestTemplate restTemplate; + private final UserUtil userUtil; + private final MusterRollServiceConfiguration config; private static final String SKILL_CODE = "skillCode"; + private static final String ROLES = "roles"; + @Autowired - public MusterRollServiceUtil(ObjectMapper mapper, RestTemplate restTemplate, MusterRollServiceConfiguration config) { + public MusterRollServiceUtil(ObjectMapper mapper, RestTemplate restTemplate, UserUtil userUtil, MusterRollServiceConfiguration config) { this.mapper = mapper; this.restTemplate = restTemplate; - this.config = config; + this.userUtil = userUtil; + this.config = config; } /** @@ -140,6 +148,17 @@ public void populateAdditionalDetails(Object mdmsData, IndividualEntry individua } } + if(config.isIndividualEntryRolesEnabled()) { + UserDetailResponse userDetailResponse = userUtil.searchUsersByIndividualIds(Collections.singletonList(individualEntry.getId())); + List roles = userDetailResponse.getUser().stream().findFirst() + .orElseThrow(() -> new CustomException( + "MusterRollServiceUtil::populateAdditionalDetails::USER SEARCH ERROR", + "No user found for the individual id " + individualEntry.getId()) + ) + .getRoles().stream().map(Role::getCode).toList(); + additionalDetails.put(ROLES, roles); + } + try { individualEntry.setAdditionalDetails(mapper.readValue(additionalDetails.toString(), Object.class)); } catch (IOException e) { diff --git a/backend/muster-roll/src/main/java/org/egov/util/UserUtil.java b/backend/muster-roll/src/main/java/org/egov/util/UserUtil.java index ee51c870e8..716fc00371 100644 --- a/backend/muster-roll/src/main/java/org/egov/util/UserUtil.java +++ b/backend/muster-roll/src/main/java/org/egov/util/UserUtil.java @@ -4,10 +4,11 @@ import org.egov.common.contract.request.Role; import org.egov.common.contract.request.User; import org.egov.common.contract.user.UserDetailResponse; +import org.egov.common.contract.user.UserSearchRequest; +import org.egov.config.MusterRollServiceConfiguration; import org.egov.repository.ServiceRequestRepository; import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.text.ParseException; @@ -20,26 +21,20 @@ @Component public class UserUtil { + private final ObjectMapper mapper; - private ObjectMapper mapper; + private final ServiceRequestRepository serviceRequestRepository; - private ServiceRequestRepository serviceRequestRepository; + private final MusterRollServiceConfiguration config; - @Value("${egov.user.create.path}") - private String userCreateEndpoint; - - @Value("${egov.user.search.path}") - private String userSearchEndpoint; - - @Value("${egov.user.update.path}") - private String userUpdateEndpoint; private static final String LAST_MODIFIED_DATE = "lastModifiedDate"; private static final String PWD_EXPIRY_DATE = "pwdExpiryDate"; @Autowired - public UserUtil(ObjectMapper mapper, ServiceRequestRepository serviceRequestRepository) { + public UserUtil(ObjectMapper mapper, ServiceRequestRepository serviceRequestRepository, MusterRollServiceConfiguration config) { this.mapper = mapper; this.serviceRequestRepository = serviceRequestRepository; + this.config = config; } /** @@ -52,9 +47,9 @@ public UserUtil(ObjectMapper mapper, ServiceRequestRepository serviceRequestRepo public UserDetailResponse userCall(Object userRequest, StringBuilder uri) { String dobFormat = null; - if (uri.toString().contains(userSearchEndpoint) || uri.toString().contains(userUpdateEndpoint)) + if (uri.toString().contains(config.getUserSearchEndpoint()) || uri.toString().contains(config.getUserUpdateEndpoint())) dobFormat = "yyyy-MM-dd"; - else if (uri.toString().contains(userCreateEndpoint)) + else if (uri.toString().contains(config.getUserCreateEndpoint())) dobFormat = "dd/MM/yyyy"; try { LinkedHashMap responseMap = (LinkedHashMap) serviceRequestRepository.fetchResult(uri, userRequest); @@ -65,6 +60,17 @@ else if (uri.toString().contains(userCreateEndpoint)) } } + public UserDetailResponse searchUsersByIndividualIds(List individualIds) { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder + .append(config.getUserHost()) + .append(config.getUserContextPath()) + .append(config.getUserSearchEndpoint()); + UserSearchRequest userSearchRequest = new UserSearchRequest(); + userSearchRequest.setUuid(individualIds); + return userCall(userSearchRequest, stringBuilder); + } + /** * Parses date formats to long for all users in responseMap diff --git a/backend/muster-roll/src/main/java/org/egov/validator/MusterRollValidator.java b/backend/muster-roll/src/main/java/org/egov/validator/MusterRollValidator.java index 8a5d84e45e..fb40749c4a 100644 --- a/backend/muster-roll/src/main/java/org/egov/validator/MusterRollValidator.java +++ b/backend/muster-roll/src/main/java/org/egov/validator/MusterRollValidator.java @@ -180,7 +180,7 @@ private void validateCreateMusterRollRequest(MusterRoll musterRoll) { //Check if the startDate is Monday - UI sends the epoch time in IST LocalDate startDate = Instant.ofEpochMilli(musterRoll.getStartDate().longValue()).atZone(ZoneId.of(serviceConfiguration.getTimeZone())).toLocalDate(); - if (startDate.getDayOfWeek() != DayOfWeek.MONDAY) { + if (serviceConfiguration.isValidateStartDateMondayEnabled() && startDate.getDayOfWeek() != DayOfWeek.MONDAY) { throw new CustomException("START_DATE_MONDAY","StartDate should be Monday"); } musterRoll.setStartDate(new BigDecimal(startDate.atStartOfDay(ZoneId.of(serviceConfiguration.getTimeZone())).toInstant().toEpochMilli())); diff --git a/backend/muster-roll/src/main/java/org/egov/web/controllers/MusterRollApiController.java b/backend/muster-roll/src/main/java/org/egov/web/controllers/MusterRollApiController.java index 5cbed9ef0b..ba83e9160e 100644 --- a/backend/muster-roll/src/main/java/org/egov/web/controllers/MusterRollApiController.java +++ b/backend/muster-roll/src/main/java/org/egov/web/controllers/MusterRollApiController.java @@ -10,6 +10,7 @@ import org.egov.web.models.MusterRollRequest; import org.egov.web.models.MusterRollResponse; import org.egov.web.models.MusterRollSearchCriteria; +import org.egov.web.models.MusterRollSearchRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -58,11 +59,17 @@ public ResponseEntity musterRollV1CreatePost(@ApiParam(value } @RequestMapping(value = "/_search", method = RequestMethod.POST) - public ResponseEntity attendanceV1SearchPOST(@Valid @RequestBody RequestInfoWrapper requestInfoWrapper, @Valid @ModelAttribute MusterRollSearchCriteria searchCriteria) { + public ResponseEntity musterRollV1SearchPOST(@Valid @RequestBody RequestInfoWrapper requestInfoWrapper, @Valid @ModelAttribute MusterRollSearchCriteria searchCriteria) { MusterRollResponse musterRollResponse = musterRollService.searchMusterRolls(requestInfoWrapper, searchCriteria); return new ResponseEntity(musterRollResponse, HttpStatus.OK); } + @RequestMapping(value = "/v2/_search", method = RequestMethod.POST) + public ResponseEntity musterRollV2SearchPOST(@Valid @RequestBody MusterRollSearchRequest request) { + MusterRollResponse musterRollResponse = musterRollService.searchMusterRolls(request, request.getMusterRoll()); + return new ResponseEntity(musterRollResponse, HttpStatus.OK); + } + @RequestMapping(value = "/_update", method = RequestMethod.POST) public ResponseEntity musterRollV1UpdatePost(@ApiParam(value = "Request object to update the muster roll", required = true) @Valid @RequestBody MusterRollRequest body) { MusterRollRequest musterRollRequest = musterRollService.updateMusterRoll(body); diff --git a/backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchCriteria.java b/backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchCriteria.java index f0e66ea2c3..b1c5ee659a 100644 --- a/backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchCriteria.java +++ b/backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchCriteria.java @@ -31,6 +31,9 @@ public class MusterRollSearchCriteria { @JsonProperty("registerId") private String registerId; + @JsonProperty("registerIds") + private List registerIds; + @JsonProperty("fromDate") private BigDecimal fromDate; diff --git a/backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchRequest.java b/backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchRequest.java new file mode 100644 index 0000000000..feb477ccbb --- /dev/null +++ b/backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchRequest.java @@ -0,0 +1,21 @@ +package org.egov.web.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.egov.common.contract.models.RequestInfoWrapper; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class MusterRollSearchRequest extends RequestInfoWrapper { + @JsonProperty("musterRoll") + @NotNull(message = "Muster Roll is mandatory") + @Valid + private MusterRollSearchCriteria musterRoll = null; +} diff --git a/backend/muster-roll/src/main/resources/application.properties b/backend/muster-roll/src/main/resources/application.properties index d95dc6a82a..95fabcf5d5 100644 --- a/backend/muster-roll/src/main/resources/application.properties +++ b/backend/muster-roll/src/main/resources/application.properties @@ -119,3 +119,5 @@ works.contract.service.code=WORKS-CONTRACT #-----------Muster roll update api config------------# musterroll.update.recompute.attendance.enabled=true +musterroll.individual.entry.roles.enabled=false +musterroll.validate.start.date.monday.enabled=true From 38f9691edb1a22bf10da1af3f6151007dd6b61d7 Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Thu, 26 Dec 2024 17:05:07 +0530 Subject: [PATCH 07/11] Added configurable bank account for muster roll health --- .../MusterRollServiceConfiguration.java | 3 ++ .../org/egov/service/CalculationService.java | 51 ++++++++++--------- .../src/main/resources/application.properties | 1 + 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java index 7c2a363636..da0530bd91 100644 --- a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java +++ b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java @@ -136,6 +136,9 @@ public class MusterRollServiceConfiguration { @Value("${musterroll.validate.start.date.monday.enabled:true}") private boolean validateStartDateMondayEnabled; + @Value("${musterroll.add.bank.account.details.enabled:true}") + private boolean addBankAccountDetails; + @Value("${egov.user.host}") private String userHost; diff --git a/backend/muster-roll/src/main/java/org/egov/service/CalculationService.java b/backend/muster-roll/src/main/java/org/egov/service/CalculationService.java index 2439dd0c9a..1a59f7c2e0 100644 --- a/backend/muster-roll/src/main/java/org/egov/service/CalculationService.java +++ b/backend/muster-roll/src/main/java/org/egov/service/CalculationService.java @@ -114,7 +114,6 @@ public void createAttendance(MusterRollRequest musterRollRequest, boolean isCrea //Add all absentee individualIds as well individualIds.addAll(absenteesList.stream().map(entry-> entry.getIndividualId()).collect(Collectors.toSet())); List individuals = fetchIndividualDetails(individualIds, musterRollRequest.getRequestInfo(),musterRoll.getTenantId(),musterRoll); - List bankAccounts = fetchBankaccountDetails(individualIds, musterRollRequest.getRequestInfo(),musterRoll.getTenantId()); for (Map.Entry> entry : individualExitAttendanceMap.entrySet()) { IndividualEntry individualEntry = new IndividualEntry(); @@ -197,29 +196,33 @@ public void createAttendance(MusterRollRequest musterRollRequest, boolean isCrea individualEntries.add(individualEntry); } - // Loop through and set individual and bank account details - for (IndividualEntry entry : individualEntries) { - - // Set individual details in additionalDetails - if (!CollectionUtils.isEmpty(individuals) /* && !CollectionUtils.isEmpty(bankAccounts) */) { - Individual individual = individuals.stream() - .filter(ind -> ind.getId().equalsIgnoreCase(entry.getIndividualId())).findFirst() - .orElse(null); - BankAccount bankAccount = bankAccounts.stream() - .filter(account -> account.getReferenceId().equalsIgnoreCase(entry.getIndividualId())) - .findFirst().orElse(null); - - if (individual != null /* && bankAccount != null */) { - setAdditionalDetails(entry, individualEntriesFromRequest, mdmsV2Data, individual, - bankAccount, isCreate); - } else { - log.info( - "CalculationService::createAttendance::No match found in individual and bank account service for the individual id from attendance log - " - + entry.getIndividualId()); - } - - } - } + if(config.isAddBankAccountDetails()) { + List bankAccounts = fetchBankaccountDetails(individualIds, musterRollRequest.getRequestInfo(),musterRoll.getTenantId()); + // Loop through and set individual and bank account details + for (IndividualEntry entry : individualEntries) { + + // Set individual details in additionalDetails + if (!CollectionUtils.isEmpty(individuals) /* && !CollectionUtils.isEmpty(bankAccounts) */) { + Individual individual = individuals.stream() + .filter(ind -> ind.getId().equalsIgnoreCase(entry.getIndividualId())).findFirst() + .orElse(null); + BankAccount bankAccount = bankAccounts.stream() + .filter(account -> account.getReferenceId().equalsIgnoreCase(entry.getIndividualId())) + .findFirst().orElse(null); + + if (individual != null /* && bankAccount != null */) { + setAdditionalDetails(entry, individualEntriesFromRequest, mdmsV2Data, individual, + bankAccount, isCreate); + } else { + log.info( + "CalculationService::createAttendance::No match found in individual and bank account service for the individual id from attendance log - " + + entry.getIndividualId()); + } + + } + } + } + musterRoll.setIndividualEntries(individualEntries); log.debug("CalculationService::createAttendance::Individuals::size::"+musterRoll.getIndividualEntries().size()); diff --git a/backend/muster-roll/src/main/resources/application.properties b/backend/muster-roll/src/main/resources/application.properties index 95fabcf5d5..5220339e06 100644 --- a/backend/muster-roll/src/main/resources/application.properties +++ b/backend/muster-roll/src/main/resources/application.properties @@ -121,3 +121,4 @@ works.contract.service.code=WORKS-CONTRACT musterroll.update.recompute.attendance.enabled=true musterroll.individual.entry.roles.enabled=false musterroll.validate.start.date.monday.enabled=true +musterroll.add.bank.account.details.enabled=true From 47c753fa3dd4b8c8b063d315e1972d5b48abdc5d Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Thu, 26 Dec 2024 17:17:08 +0530 Subject: [PATCH 08/11] Fixed test case failure --- .../test/java/org/egov/validator/MusterRollValidatorTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/muster-roll/src/test/java/org/egov/validator/MusterRollValidatorTest.java b/backend/muster-roll/src/test/java/org/egov/validator/MusterRollValidatorTest.java index 89ded1ba23..11ce333991 100644 --- a/backend/muster-roll/src/test/java/org/egov/validator/MusterRollValidatorTest.java +++ b/backend/muster-roll/src/test/java/org/egov/validator/MusterRollValidatorTest.java @@ -47,6 +47,7 @@ void setUp() throws Exception { lenient().when(mdmsUtils.mDMSCall(any(MusterRollRequest.class), any(String.class))).thenReturn(mdmsResponse); lenient().when(serviceConfiguration.getTimeZone()).thenReturn("Asia/Kolkata"); + lenient().when(serviceConfiguration.isValidateStartDateMondayEnabled()).thenReturn(true); } From d8c3d628820fe98e8452b70251bf5ae551647a57 Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Fri, 27 Dec 2024 13:19:06 +0530 Subject: [PATCH 09/11] Added logic to update attendance register on approval of muster roll --- .../MusterRollServiceConfiguration.java | 5 ++ .../org/egov/service/MusterRollService.java | 13 ++++ .../egov/util/MusterRollServiceConstants.java | 1 + .../org/egov/util/MusterRollServiceUtil.java | 30 +++++++- .../egov/web/models/AttendanceRegister.java | 6 ++ .../web/models/AttendanceRegisterRequest.java | 71 +++++++++++++++++++ .../src/main/resources/application.properties | 2 + 7 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegisterRequest.java diff --git a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java index da0530bd91..8ae2241f21 100644 --- a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java +++ b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java @@ -80,6 +80,8 @@ public class MusterRollServiceConfiguration { private String attendanceLogEndpoint; @Value("${works.attendance.register.search.endpoint}") private String attendanceRegisterEndpoint; + @Value("${works.attendance.register.update.endpoint}") + private String attendanceRegisterUpdateEndpoint; @Value("${works.attendance.register.search.limit}") private String attendanceRegisterSearchLimit; @@ -139,6 +141,9 @@ public class MusterRollServiceConfiguration { @Value("${musterroll.add.bank.account.details.enabled:true}") private boolean addBankAccountDetails; + @Value("${musterroll.update.attendance.register.payment.status.enabled:true}") + private boolean updateAttendanceRegisterPaymentStatusEnabled; + @Value("${egov.user.host}") private String userHost; diff --git a/backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java b/backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java index 9147b09295..ffc0c5297d 100644 --- a/backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java +++ b/backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.stream.Collectors; +import static org.egov.util.MusterRollServiceConstants.ACTION_APPROVE; import static org.egov.util.MusterRollServiceConstants.STATUS_APPROVED; @Service @@ -211,6 +212,18 @@ public MusterRollRequest updateMusterRoll(MusterRollRequest musterRollRequest) { calculationService.updateAttendance(musterRollRequest,mdmsData); } workflowService.updateWorkflowStatus(musterRollRequest); + if(config.isUpdateAttendanceRegisterPaymentStatusEnabled() && musterRollRequest.getWorkflow().getAction().equals(ACTION_APPROVE)) { + AttendanceRegisterResponse attendanceRegisterResponse = musterRollServiceUtil + .fetchAttendanceRegister(musterRollRequest.getMusterRoll(), musterRollRequest.getRequestInfo()); + List attendanceRegisters = attendanceRegisterResponse.getAttendanceRegister(); + if(attendanceRegisters == null || attendanceRegisters.isEmpty()) { + log.error("No attendance registers found to update the status"); + throw new CustomException("MusterRollService::updateMusterRoll::updateAttendanceRegister", "No attendance registers found to update the status"); + } + AttendanceRegister attendanceRegister = attendanceRegisters.get(0); + attendanceRegister.setPaymentStatus(STATUS_APPROVED); + musterRollServiceUtil.updateAttendanceRegister(attendanceRegister, musterRollRequest.getRequestInfo()); + } musterRollProducer.push(serviceConfiguration.getUpdateMusterRollTopic(), musterRollRequest); try { diff --git a/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceConstants.java b/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceConstants.java index f35a0da604..56c928adf5 100644 --- a/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceConstants.java +++ b/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceConstants.java @@ -15,6 +15,7 @@ public class MusterRollServiceConstants { public static final String ENTRY_EVENT = "ENTRY"; public static final String EXIT_EVENT = "EXIT"; public static final String STATUS_APPROVED = "APPROVED"; + public static final String ACTION_APPROVE = "APPROVE"; public static final String TENANT_ID = "tenantId"; public static final String CONTRACT_NUMBER = "contractNumber"; public static final String REQUEST_INFO = "RequestInfo"; diff --git a/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java b/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java index 345d5e5a2e..9bdac55677 100644 --- a/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java +++ b/backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java @@ -16,6 +16,7 @@ import org.egov.common.models.individual.Skill; import org.egov.config.MusterRollServiceConfiguration; import org.egov.tracer.model.CustomException; +import org.egov.tracer.model.ServiceCallException; import org.egov.web.models.*; import org.egov.works.services.common.models.bankaccounts.BankAccount; import org.egov.works.services.common.models.bankaccounts.BankAccountDetails; @@ -32,10 +33,11 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; -import static org.egov.util.MusterRollServiceConstants.*; @Component @Slf4j @@ -285,4 +287,30 @@ public AttendanceRegisterResponse fetchAttendanceRegister(MusterRoll musterRoll, } return attendanceRegisterResponse; } + + public AttendanceRegisterResponse updateAttendanceRegister(AttendanceRegister attendanceRegister, RequestInfo requestInfo) { + log.info("updateAttendanceRegister::Update attendance register with tenantId::" + attendanceRegister.getTenantId() + + " and register ID: " + attendanceRegister.getId()); + + StringBuilder uri = new StringBuilder(); + uri.append(config.getAttendanceLogHost()).append(config.getAttendanceRegisterUpdateEndpoint()); + + AttendanceRegisterResponse response = null; + + AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequest.builder() + .attendanceRegister(Collections.singletonList(attendanceRegister)) + .requestInfo(requestInfo) + .build(); + try { + response = restTemplate.postForObject(uri.toString(), attendanceRegisterRequest, AttendanceRegisterResponse.class); + } catch (HttpClientErrorException e) { + throw new ServiceCallException(e.getResponseBodyAsString()); + } catch (Exception e) { + Map map = new HashMap<>(); + map.put(e.getCause().getClass().getName(), e.getMessage()); + throw new CustomException(map); + } + + return response; + } } diff --git a/backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegister.java b/backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegister.java index 04c58ec780..fad9d4d84e 100644 --- a/backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegister.java +++ b/backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegister.java @@ -59,6 +59,12 @@ public class AttendanceRegister { @JsonProperty("additionalDetails") private Object additionalDetails = null; + @JsonProperty("localityCode") + private String localityCode; + + @JsonProperty("paymentStatus") + private String paymentStatus; + public AttendanceRegister addStaffItem(StaffPermission staffItem) { if (this.staff == null) { diff --git a/backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegisterRequest.java b/backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegisterRequest.java new file mode 100644 index 0000000000..e90ab6cc11 --- /dev/null +++ b/backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegisterRequest.java @@ -0,0 +1,71 @@ +package org.egov.web.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.egov.common.contract.request.RequestInfo; + +public class AttendanceRegisterRequest { + @JsonProperty("RequestInfo") + private RequestInfo requestInfo = null; + @JsonProperty("attendanceRegister") + private List attendanceRegister = null; + + public static AttendanceRegisterRequestBuilder builder() { + return new AttendanceRegisterRequestBuilder(); + } + + public RequestInfo getRequestInfo() { + return this.requestInfo; + } + + public List getAttendanceRegister() { + return this.attendanceRegister; + } + + @JsonProperty("RequestInfo") + public void setRequestInfo(final RequestInfo requestInfo) { + this.requestInfo = requestInfo; + } + + @JsonProperty("attendanceRegister") + public void setAttendanceRegister(final List attendanceRegister) { + this.attendanceRegister = attendanceRegister; + } + + public AttendanceRegisterRequest(final RequestInfo requestInfo, final List attendanceRegister) { + this.requestInfo = requestInfo; + this.attendanceRegister = attendanceRegister; + } + + public AttendanceRegisterRequest() { + } + + public static class AttendanceRegisterRequestBuilder { + private RequestInfo requestInfo; + private List attendanceRegister; + + AttendanceRegisterRequestBuilder() { + } + + @JsonProperty("RequestInfo") + public AttendanceRegisterRequestBuilder requestInfo(final RequestInfo requestInfo) { + this.requestInfo = requestInfo; + return this; + } + + @JsonProperty("attendanceRegister") + public AttendanceRegisterRequestBuilder attendanceRegister(final List attendanceRegister) { + this.attendanceRegister = attendanceRegister; + return this; + } + + public AttendanceRegisterRequest build() { + return new AttendanceRegisterRequest(this.requestInfo, this.attendanceRegister); + } + + public String toString() { + return "AttendanceRegisterRequest.AttendanceRegisterRequestBuilder(requestInfo=" + this.requestInfo + ", attendanceRegister=" + this.attendanceRegister + ")"; + } + } +} + diff --git a/backend/muster-roll/src/main/resources/application.properties b/backend/muster-roll/src/main/resources/application.properties index 5220339e06..e7695ddf8a 100644 --- a/backend/muster-roll/src/main/resources/application.properties +++ b/backend/muster-roll/src/main/resources/application.properties @@ -89,6 +89,7 @@ egov.localization.search.endpoint=/localization/messages/v1/_search works.attendance.log.host=https://unified-dev.digit.org works.attendance.log.search.endpoint=/attendance/log/v1/_search works.attendance.register.search.endpoint=/attendance/v1/_search +works.attendance.register.update.endpoint=/attendance/v1/_update works.attendance.register.search.limit=100 #--------------Contract Service---------------------# @@ -122,3 +123,4 @@ musterroll.update.recompute.attendance.enabled=true musterroll.individual.entry.roles.enabled=false musterroll.validate.start.date.monday.enabled=true musterroll.add.bank.account.details.enabled=true +musterroll.update.attendance.register.payment.status.enabled:false From 7547e8ef4a5de53feba264f9b1622e3cb39ef9c5 Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Fri, 27 Dec 2024 13:20:58 +0530 Subject: [PATCH 10/11] minor fix --- backend/muster-roll/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/muster-roll/src/main/resources/application.properties b/backend/muster-roll/src/main/resources/application.properties index e7695ddf8a..acea94c792 100644 --- a/backend/muster-roll/src/main/resources/application.properties +++ b/backend/muster-roll/src/main/resources/application.properties @@ -123,4 +123,4 @@ musterroll.update.recompute.attendance.enabled=true musterroll.individual.entry.roles.enabled=false musterroll.validate.start.date.monday.enabled=true musterroll.add.bank.account.details.enabled=true -musterroll.update.attendance.register.payment.status.enabled:false +musterroll.update.attendance.register.payment.status.enabled=false From 55af80bebfc7c3b8ad4e33cc938c7b1b64149fa6 Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Fri, 27 Dec 2024 14:58:53 +0530 Subject: [PATCH 11/11] changed notification to be configurable --- .../java/org/egov/config/MusterRollServiceConfiguration.java | 3 +++ .../src/main/java/org/egov/service/NotificationService.java | 1 + 2 files changed, 4 insertions(+) diff --git a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java index 8ae2241f21..880aef0276 100644 --- a/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java +++ b/backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java @@ -107,6 +107,9 @@ public class MusterRollServiceConfiguration { @Value("${kafka.topics.notification.sms}") private String smsNotificationTopic; + @Value("${notification.sms.enabled:false}") + private boolean sendNotificationEnabled; + //Expense Service @Value("${works.expense.calculator.host}") private String expenseCalculatorServiceHost; diff --git a/backend/muster-roll/src/main/java/org/egov/service/NotificationService.java b/backend/muster-roll/src/main/java/org/egov/service/NotificationService.java index 3766b940d2..7e756d03b8 100644 --- a/backend/muster-roll/src/main/java/org/egov/service/NotificationService.java +++ b/backend/muster-roll/src/main/java/org/egov/service/NotificationService.java @@ -42,6 +42,7 @@ public NotificationService(MusterRollProducer musterRollProducer, NotificationUt */ public void sendNotificationToCBO(MusterRollRequest musterRollRequest){ String action = musterRollRequest.getWorkflow().getAction(); + if(!config.isSendNotificationEnabled()) return; if(action.equalsIgnoreCase(WF_SEND_BACK_TO_CBO_CODE) || action.equalsIgnoreCase(WF_APPROVE_CODE)) { Map cboDetails = notificationUtil.getCBOContactPersonDetails(musterRollRequest); String amount = notificationUtil.getExpenseAmount(musterRollRequest);