This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
234 additions
and
15 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
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
95 changes: 95 additions & 0 deletions
95
...ices/vendor/src/main/java/org/egov/vendor/repository/rowmapper/VendorReportRowMapper.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,95 @@ | ||
package org.egov.vendor.repository.rowmapper; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.egov.vendor.service.UserService; | ||
import org.egov.vendor.web.model.VendorReportData; | ||
import org.egov.vendor.web.model.user.User; | ||
import org.egov.vendor.web.model.user.UserDetailResponse; | ||
import org.egov.vendor.web.model.user.UserSearchRequest; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
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.*; | ||
import java.util.stream.Collectors; | ||
|
||
@Component | ||
@Slf4j | ||
public class VendorReportRowMapper implements ResultSetExtractor<List<VendorReportData>> | ||
{ | ||
@Autowired | ||
private ObjectMapper mapper; | ||
@Autowired | ||
private UserService userService; | ||
|
||
@Override | ||
public List<VendorReportData> extractData(ResultSet resultSet) throws SQLException, DataAccessException { | ||
List<VendorReportData> vendorReportDataList=new ArrayList<>(); | ||
|
||
while(resultSet.next()) | ||
{ | ||
VendorReportData vendorReportData=new VendorReportData(); | ||
vendorReportData.setVendor_name(resultSet.getString("name")); | ||
vendorReportData.setBill_id(resultSet.getString("challanno")); | ||
vendorReportData.setUuid(resultSet.getString("owner_uuid")); | ||
vendorReportData.setType_of_expense(resultSet.getString("type_of_expense")); | ||
vendorReportDataList.add(vendorReportData); | ||
} | ||
if(!vendorReportDataList.isEmpty()) | ||
{ | ||
enrichVendorHolderDetails(vendorReportDataList); | ||
} | ||
return vendorReportDataList; | ||
} | ||
|
||
private void enrichVendorHolderDetails(List<VendorReportData> vendorReportDataList) | ||
{ | ||
Set<String> lastModifiedByUuid= new HashSet<>(); | ||
|
||
for(VendorReportData vendorReportData:vendorReportDataList) | ||
{ | ||
lastModifiedByUuid.add(vendorReportData.getUuid()); | ||
} | ||
|
||
UserSearchRequest userSearchRequest=new UserSearchRequest(); | ||
userSearchRequest.setUuid((new ArrayList<>(lastModifiedByUuid))); | ||
|
||
log.info(userSearchRequest.getUuid().toString()); | ||
|
||
UserDetailResponse userDetailResponse = userService.getUser(userSearchRequest); | ||
|
||
log.info(userDetailResponse.getUser().toString()); | ||
|
||
enrichConnectionHolderInfo(userDetailResponse, vendorReportDataList); | ||
|
||
} | ||
|
||
private void enrichConnectionHolderInfo(UserDetailResponse userDetailResponse, List<VendorReportData> vendorReportDataList) | ||
{ | ||
List<User> connectionHolderInfos = userDetailResponse.getUser(); | ||
Map<String, User> userIdToConnectionHolderMap = new HashMap<>(); | ||
if(connectionHolderInfos.isEmpty()) | ||
{ | ||
return; | ||
} | ||
connectionHolderInfos.forEach(user -> userIdToConnectionHolderMap.put(user.getUuid(), user)); | ||
|
||
log.info(userIdToConnectionHolderMap.toString()); | ||
|
||
// vendorReportDataList.forEach(vendorReportData-> vendorReportData.setMobile_no(userIdToConnectionHolderMap.get(vendorReportData.getUuid()).getMobileNumber())); | ||
|
||
vendorReportDataList.forEach(vendorReportData -> { | ||
User connection = userIdToConnectionHolderMap.get(vendorReportData.getUuid()); | ||
if (connection != null) { | ||
vendorReportData.setMobile_no(connection.getMobileNumber()); | ||
} else { | ||
log.warn("User not found for UUID: " + vendorReportData.getUuid()); | ||
} | ||
}); | ||
|
||
} | ||
} |
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
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
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
31 changes: 31 additions & 0 deletions
31
municipal-services/vendor/src/main/java/org/egov/vendor/web/model/VendorReportData.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,31 @@ | ||
package org.egov.vendor.web.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class VendorReportData { | ||
|
||
@JsonProperty("tenantId") | ||
private String tenantId; | ||
|
||
@JsonProperty("vendor_name") | ||
private String vendor_name; | ||
|
||
@JsonProperty("mobile_no") | ||
private String mobile_no; | ||
|
||
@JsonProperty("type_of_expense") | ||
private String type_of_expense; | ||
|
||
@JsonProperty("bill_id") | ||
private String bill_id; | ||
|
||
@JsonProperty("owner_uuid") | ||
private String uuid; | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
municipal-services/vendor/src/main/java/org/egov/vendor/web/model/VendorReportResponse.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,17 @@ | ||
package org.egov.vendor.web.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Builder; | ||
import org.egov.common.contract.response.ResponseInfo; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
public class VendorReportResponse { | ||
|
||
@JsonProperty("VendorReportData") | ||
private List<VendorReportData> VendorReportData; | ||
|
||
@JsonProperty("requestInfo") | ||
private ResponseInfo responseInfo = null; | ||
} |