forked from upyog/UPYOG
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request upyog#32 from BimalKumarNiua/niua-dev
Niua dev
- Loading branch information
Showing
7 changed files
with
245 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...t-services/src/main/resources/db/migration/main/V20243005102355__asset_niuadeployment.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- Create ENUM types | ||
--CREATE TYPE public.asset_classification AS ENUM ('MOVABLE', 'IMMOVABLE'); | ||
--CREATE TYPE public.parent_type AS ENUM ('LAND', 'BUILDING', 'SERVICE','OTHER'); | ||
|
||
--ALTER TABLE eg_asset_assetdetails DROP COLUMN action; | ||
|
||
--ALTER TABLE eg_asset_auditdetails DROP COLUMN action; | ||
|
||
--ALTER TABLE eg_asset_auditdetails ADD COLUMN remarks character varying(256); | ||
ALTER TABLE eg_asset_auditdetails ALTER COLUMN additionaldetails TYPE JSONB; |
147 changes: 147 additions & 0 deletions
147
municipal-services/inbox/src/main/java/org/egov/inbox/service/AssetInboxFilterService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
package org.egov.inbox.service; | ||
|
||
import com.jayway.jsonpath.JsonPath; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.egov.common.contract.request.RequestInfo; | ||
import org.egov.inbox.repository.ServiceRequestRepository; | ||
import org.egov.inbox.web.model.InboxSearchCriteria; | ||
import org.egov.inbox.web.model.workflow.ProcessInstanceSearchCriteria; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.util.CollectionUtils; | ||
import org.springframework.util.ObjectUtils; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.egov.inbox.util.AssetConstants.*; | ||
|
||
|
||
@Slf4j | ||
@Service | ||
public class AssetInboxFilterService { | ||
|
||
@Value("${egov.user.host}") | ||
private String userHost; | ||
|
||
@Value("${egov.user.search.path}") | ||
private String userSearchEndpoint; | ||
|
||
@Value("${egov.searcher.host}") | ||
private String searcherHost; | ||
|
||
@Value("${egov.searcher.asset.search.path}") | ||
private String assetInboxSearcherEndpoint; | ||
|
||
@Value("${egov.searcher.asset.search.desc.path}") | ||
private String assetInboxSearcherDescEndpoint; | ||
|
||
@Autowired | ||
private RestTemplate restTemplate; | ||
|
||
@Autowired | ||
private ServiceRequestRepository serviceRequestRepository; | ||
|
||
public List<String> fetchApplicationNumbersFromSearcher(InboxSearchCriteria criteria, HashMap<String, String> StatusIdNameMap, RequestInfo requestInfo){ | ||
List<String> applicationNumbers = new ArrayList<>(); | ||
HashMap moduleSearchCriteria = criteria.getModuleSearchCriteria(); | ||
ProcessInstanceSearchCriteria processCriteria = criteria.getProcessSearchCriteria(); | ||
Boolean isSearchResultEmpty = false; | ||
List<String> userUUIDs = new ArrayList<>(); | ||
Boolean isMobileNumberPresent = false; | ||
|
||
if(moduleSearchCriteria.containsKey(MOBILE_NUMBER_PARAM)){ | ||
isMobileNumberPresent = true; | ||
} | ||
if(isMobileNumberPresent) { | ||
String tenantId = criteria.getTenantId(); | ||
String mobileNumber = String.valueOf(moduleSearchCriteria.get(MOBILE_NUMBER_PARAM)); | ||
userUUIDs = fetchUserUUID(mobileNumber, requestInfo, tenantId); | ||
Boolean isUserPresentForGivenMobileNumber = CollectionUtils.isEmpty(userUUIDs) ? false : true; | ||
isSearchResultEmpty = !isMobileNumberPresent || !isUserPresentForGivenMobileNumber; | ||
if(isSearchResultEmpty){ | ||
return new ArrayList<>(); | ||
} | ||
} | ||
|
||
|
||
if(!isSearchResultEmpty){ | ||
Object result = null; | ||
|
||
Map<String, Object> searcherRequest = new HashMap<>(); | ||
Map<String, Object> searchCriteria = new HashMap<>(); | ||
|
||
searchCriteria.put(TENANT_ID_PARAM,criteria.getTenantId()); | ||
searchCriteria.put(BUSINESS_SERVICE_PARAM, processCriteria.getBusinessService()); | ||
|
||
if(moduleSearchCriteria.containsKey(LOCALITY_PARAM)){ | ||
searchCriteria.put(LOCALITY_PARAM, moduleSearchCriteria.get(LOCALITY_PARAM)); | ||
} | ||
if(moduleSearchCriteria.containsKey(ASSET_APPLICATION_NUMBER_PARAM)) { | ||
searchCriteria.put(ASSET_APPLICATION_NUMBER_PARAM, moduleSearchCriteria.get(ASSET_APPLICATION_NUMBER_PARAM)); | ||
} | ||
|
||
// Accomodating process search criteria in searcher request | ||
if(!ObjectUtils.isEmpty(processCriteria.getAssignee())){ | ||
searchCriteria.put(ASSIGNEE_PARAM, processCriteria.getAssignee()); | ||
} | ||
if(!ObjectUtils.isEmpty(processCriteria.getStatus())){ | ||
searchCriteria.put(STATUS_PARAM, processCriteria.getStatus()); | ||
}else{ | ||
if(StatusIdNameMap.values().size() > 0) { | ||
if(CollectionUtils.isEmpty(processCriteria.getStatus())) { | ||
searchCriteria.put(STATUS_PARAM, StatusIdNameMap.keySet()); | ||
} | ||
} | ||
} | ||
|
||
// Paginating searcher results | ||
searchCriteria.put(OFFSET_PARAM, criteria.getOffset()); | ||
searchCriteria.put(NO_OF_RECORDS_PARAM, criteria.getLimit()); | ||
moduleSearchCriteria.put(LIMIT_PARAM, criteria.getLimit()); | ||
|
||
searcherRequest.put(REQUESTINFO_PARAM, requestInfo); | ||
searcherRequest.put(SEARCH_CRITERIA_PARAM, searchCriteria); | ||
|
||
StringBuilder uri = new StringBuilder(); | ||
if(moduleSearchCriteria.containsKey(SORT_ORDER_PARAM) && moduleSearchCriteria.get(SORT_ORDER_PARAM).equals(DESC_PARAM)){ | ||
uri.append(searcherHost).append(assetInboxSearcherDescEndpoint); | ||
}else { | ||
uri.append(searcherHost).append(assetInboxSearcherEndpoint); | ||
} | ||
result = restTemplate.postForObject(uri.toString(), searcherRequest, Map.class); | ||
applicationNumbers = JsonPath.read(result, "$.Asset.*.applicationno"); | ||
|
||
} | ||
return applicationNumbers; | ||
} | ||
|
||
|
||
private List<String> fetchUserUUID(String mobileNumber, RequestInfo requestInfo, String tenantId) { | ||
StringBuilder uri = new StringBuilder(); | ||
uri.append(userHost).append(userSearchEndpoint); | ||
Map<String, Object> userSearchRequest = new HashMap<>(); | ||
userSearchRequest.put("RequestInfo", requestInfo); | ||
userSearchRequest.put("tenantId", tenantId); | ||
userSearchRequest.put("userType", "EMPLOYEE"); | ||
userSearchRequest.put("mobileNumber", mobileNumber); | ||
List<String> userUuids = new ArrayList<>(); | ||
try { | ||
Object user = serviceRequestRepository.fetchResult(uri, userSearchRequest); | ||
if(null != user) { | ||
//log.info(user.toString()); | ||
userUuids = JsonPath.read(user, "$.user.*.uuid"); | ||
}else { | ||
log.error("Service returned null while fetching user for mobile number - " + mobileNumber); | ||
} | ||
}catch(Exception e) { | ||
log.error("Exception while fetching user for mobile number - " + mobileNumber); | ||
log.error("Exception trace: ", e); | ||
} | ||
return userUuids; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
municipal-services/inbox/src/main/java/org/egov/inbox/util/AssetConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.egov.inbox.util; | ||
|
||
public class AssetConstants { | ||
|
||
public static final String ASSET = "asset-services"; | ||
public static final String MOBILE_NUMBER_PARAM = "mobileNumber"; | ||
public static final String BUSINESS_SERVICE_PARAM = "businessservice"; | ||
public static final String TENANT_ID_PARAM = "tenantId"; | ||
public static final String LOCALITY_PARAM = "locality"; | ||
public static final String ASSET_APPLICATION_NUMBER_PARAM = "applicationNo"; | ||
public static final String ASSIGNEE_PARAM = "assignee"; | ||
public static final String STATUS_PARAM = "status"; | ||
public static final String OFFSET_PARAM = "offset"; | ||
public static final String NO_OF_RECORDS_PARAM = "noOfRecords"; | ||
public static final String LIMIT_PARAM = "limit"; | ||
public static final String ACKNOWLEDGEMENT_IDS_PARAM = "acknowledgementIds"; | ||
public static final String REQUESTINFO_PARAM = "RequestInfo"; | ||
public static final String SEARCH_CRITERIA_PARAM = "searchCriteria"; | ||
public static final String USERID_PARAM = "userid"; | ||
public static final String SORT_ORDER_PARAM = "sortOrder"; | ||
public static final String DESC_PARAM = "DESC"; | ||
|
||
|
||
} |
Oops, something went wrong.