Wasi/BS-2185-osho
#10
Merged
wasiullah.khan
merged 3 commits from Wasi/BS-2185-osho into dev-pending-20-01-2026 2 weeks ago
@ -0,0 +1,31 @@
|
|||||||
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.InProcessApplicationsRequestDTO;
|
||||||
|
import com.mfsys.aconnect.client.service.InProcessDepositApplicationsService;
|
||||||
|
import com.mfsys.common.configuration.constant.AconnectURI;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class InProcessDepositApplicationsController {
|
||||||
|
|
||||||
|
private final InProcessDepositApplicationsService service;
|
||||||
|
|
||||||
|
public InProcessDepositApplicationsController(
|
||||||
|
InProcessDepositApplicationsService service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.CHECK_INPROCESS_DEPOSIT_APPLICATIONS_URI)
|
||||||
|
public ResponseEntity<String> getInProcessDepositApplications(@RequestBody InProcessApplicationsRequestDTO request,
|
||||||
|
@RequestHeader("Authorization") String token, @RequestHeader("SUS_USERCODE") String susUserCode) {
|
||||||
|
return service.getInProcessDepositApplications(request, token, susUserCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.CHECK_INDIVIDUAL_DEPOSIT_APPLICATIONS_URI)
|
||||||
|
public ResponseEntity<String> getInProcessIndividualDepositApplication(
|
||||||
|
@RequestBody InProcessApplicationsRequestDTO request, @RequestParam("workFlowRefNum") Long workFlowRefNum,
|
||||||
|
@RequestHeader("Authorization") String token, @RequestHeader("SUS_USERCODE") String susUserCode) {
|
||||||
|
return service.getInProcessIndividualDepositApplication(request, workFlowRefNum, token, susUserCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,167 @@
|
|||||||
|
package com.mfsys.aconnect.client.service;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class InProcessDepositApplicationsService {
|
||||||
|
|
||||||
|
@Value("${app.deposit.uri}")
|
||||||
|
private String depositURI;
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate;
|
||||||
|
|
||||||
|
public InProcessDepositApplicationsService(RestTemplate restTemplate) {this.restTemplate = restTemplate;}
|
||||||
|
|
||||||
|
private Map<String, Object> param(String columnName, Object columnValue, String columnType, String conditionType) {
|
||||||
|
return Map.of("columnName", columnName, "columnValue", columnValue,
|
||||||
|
"columnType", columnType, "conditionType", conditionType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> buildWorkflowFilter(InProcessApplicationsRequestDTO req) {
|
||||||
|
List<Object> workflowQueries = new ArrayList<>();
|
||||||
|
|
||||||
|
if (req.isIncludeRegistrationPending()) {
|
||||||
|
workflowQueries.add(Map.of(
|
||||||
|
"params", List.of(
|
||||||
|
param("workFlowStage", "BN_MS_ID_REGISTRATION", "text", "="),
|
||||||
|
param("applicationStatus", "Pending", "text", "=")
|
||||||
|
),
|
||||||
|
"operator", "$and"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (req.isIncludeAuthorizationApproved()) {
|
||||||
|
workflowQueries.add(Map.of(
|
||||||
|
"params", List.of(
|
||||||
|
param("workFlowStage", "BN_MS_ID_AUTHORIZATION", "text", "="),
|
||||||
|
param("applicationStatus", "Approved", "text", "="),
|
||||||
|
param("postProcessCompleted", true, "boolean", "!=")
|
||||||
|
),
|
||||||
|
"operator", "$and"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
workflowQueries.add(Map.of(
|
||||||
|
"params", List.of(
|
||||||
|
param("workFlowStage", "BN_MS_ID_REGISTRATION", "text", "="),
|
||||||
|
param("applicationStatus", "[\"Rejected\",\"Hold\"]", "text", "in")
|
||||||
|
),
|
||||||
|
"operator", "$and"
|
||||||
|
));
|
||||||
|
return Map.of(
|
||||||
|
"nestedQuery", workflowQueries,
|
||||||
|
"operator", "$or"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LazyListRequestDTO buildLazyListPayload(InProcessApplicationsRequestDTO req) {
|
||||||
|
|
||||||
|
List<Object> rootQueries = new ArrayList<>();
|
||||||
|
|
||||||
|
rootQueries.add(Map.of(
|
||||||
|
"params", List.of(
|
||||||
|
param("POR_ORGACODE", req.getPorOrgacode(), "text", "="),
|
||||||
|
param("POR_ORGACODE_ENTRY", req.getPorOrgacode(), "text", "=")
|
||||||
|
),
|
||||||
|
"operator", "$or"
|
||||||
|
));
|
||||||
|
|
||||||
|
rootQueries.add(Map.of(
|
||||||
|
"params", List.of(
|
||||||
|
param("PLC_LOCACODE", "[\"" + req.getPlclocacode() + "\"]", "text", "in"),
|
||||||
|
param("PLC_LOCACODE_ENTRY", "[\"" + req.getPlclocacode() + "\"]", "text", "in")
|
||||||
|
),
|
||||||
|
"operator", "$or"
|
||||||
|
));
|
||||||
|
|
||||||
|
rootQueries.add(buildWorkflowFilter(req));
|
||||||
|
|
||||||
|
LazyListRequestDTO dto = new LazyListRequestDTO();
|
||||||
|
dto.setCollection("BN_WF_ID_DEPOSITACCOUNT");
|
||||||
|
dto.setFilter(Map.of(
|
||||||
|
"nestedQuery", rootQueries,
|
||||||
|
"operator", "$and"
|
||||||
|
));
|
||||||
|
if (req.getLimit() != null) {
|
||||||
|
dto.setLimit(req.getLimit());
|
||||||
|
}
|
||||||
|
dto.setSortBy("{\"workFlowRefNum\":-1}");
|
||||||
|
dto.setIncludeFields(List.of(
|
||||||
|
"MBM_BKMSNUMBER", "DMP_PRODCODE", "CMP_CUSTCODE", "MBM_BKMSTITLE", "workFlowRefNum", "applicationStatus",
|
||||||
|
"workFlowStage", "workFlowLog", "postProcessCompleted", "failureCause", "postProcessInProgress"
|
||||||
|
));
|
||||||
|
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<String> getInProcessDepositApplications(
|
||||||
|
InProcessApplicationsRequestDTO request, String token, String susUserCode) {
|
||||||
|
|
||||||
|
String url = depositURI + "/deposit" + "/mongodb/lazylist";
|
||||||
|
|
||||||
|
LazyListRequestDTO payload = buildLazyListPayload(request);
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", token);
|
||||||
|
headers.set("POR_ORGACODE", request.getPorOrgacode());
|
||||||
|
headers.set("SUS_USERCODE", susUserCode);
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<LazyListRequestDTO> entity = new HttpEntity<>(payload, headers);
|
||||||
|
|
||||||
|
return restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
String.class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<String> getInProcessIndividualDepositApplication(
|
||||||
|
InProcessApplicationsRequestDTO req, Long workFlowRefNum, String token, String susUserCode) {
|
||||||
|
|
||||||
|
String url = depositURI + "/deposit" + "/mongodb/lazylist";
|
||||||
|
|
||||||
|
LazyListRequestDTO dto = buildLazyListPayload(req);
|
||||||
|
|
||||||
|
Map<String, Object> individualFilter = Map.of(
|
||||||
|
"params", List.of(
|
||||||
|
param("workFlowRefNum", workFlowRefNum, "numeric", "=")
|
||||||
|
),
|
||||||
|
"operator", "$and"
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, Object> existingFilter = (Map<String, Object>) dto.getFilter();
|
||||||
|
|
||||||
|
List<Object> nestedQuery = new ArrayList<>((List<Object>) existingFilter.get("nestedQuery"));
|
||||||
|
|
||||||
|
nestedQuery.add(individualFilter);
|
||||||
|
|
||||||
|
dto.setFilter(Map.of("nestedQuery", nestedQuery, "operator", "$and"));
|
||||||
|
|
||||||
|
dto.setLimit(1);
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", token);
|
||||||
|
headers.set("POR_ORGACODE", req.getPorOrgacode());
|
||||||
|
headers.set("SUS_USERCODE", susUserCode);
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
return restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
new HttpEntity<>(dto, headers),
|
||||||
|
String.class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue