[UCOD][23]- onboarding/digital/UcoCustomerAccount #6

Merged
naeem.ullah merged 1 commits from UCOD-23 into UCO-PRE-PRODUCTION-2026 2 days ago

@ -58,16 +58,16 @@ public class UcoAccountService {
customerProfile = customerProfileRepository.findCustomerProfileByCmpEmailAndPorOrgacode(porOrgacode, acntTypeValue); customerProfile = customerProfileRepository.findCustomerProfileByCmpEmailAndPorOrgacode(porOrgacode, acntTypeValue);
} }
if (Objects.isNull(customerProfile)) { if (Objects.isNull(customerProfile)) {
throw new AccountDoesntExistsException(); throw new AccountDoesntExistsException();
} }
List<UcoAccount> ucoAccountList= ucoAccountRepository.findUcoAccountByCmpCustcode(porOrgacode, customerProfile.getCmpCustcode()); List<UcoAccount> ucoAccountList= ucoAccountRepository.findUcoAccountByCmpCustcode(porOrgacode, customerProfile.getCmpCustcode());
List<AccountInquiryResponse> accountInquiryResponseList = new ArrayList<>(); List<AccountInquiryResponse> accountInquiryResponseList = new ArrayList<>();
ucoAccountList.stream().forEach(account ->{; ucoAccountList.stream().forEach(account ->{;
accountInquiryResponseList.add( AccountInquiryResponse.builder().mbmBkmsnumber(account.getId().getMbmBkmsnumber()) accountInquiryResponseList.add( AccountInquiryResponse.builder().mbmBkmsnumber(account.getId().getMbmBkmsnumber())
.mbmBkmstitle(account.getMbmBkmstitle()) .mbmBkmstitle(account.getMbmBkmstitle())
.pcrCurrshort(account.getPcrCurrshort()) .pcrCurrshort(account.getPcrCurrshort())
.pcrCurrcode(account.getPcrCurrcode()) .pcrCurrcode(account.getPcrCurrcode())
.pcrCurrdesc(account.getPcrCurrdesc()) .pcrCurrdesc(account.getPcrCurrdesc())
.build()); .build());
}); });
return accountInquiryResponseList; return accountInquiryResponseList;
@ -191,39 +191,42 @@ public class UcoAccountService {
} }
}); });
} }
String accountNumber = webClientDeposit.createUcoAccount(JsonToString(Map.of("payload",preparePayloadForAccount(customerProfile,addAccountRequestModel.getTitle()), String accountNumber = webClientDeposit.createUcoAccount(JsonToString(Map.of("payload",preparePayloadForAccount(customerProfile,addAccountRequestModel.getTitle(), addAccountRequestModel.getDmpProdcode()),
"uniqueConstraints",List.of(List.of(String.valueOf(addAccountRequestModel.getDmpProdcode()))))),UCOURI.UCO_CUSTOMER_ACCOUNT,porOrgacode); "uniqueConstraints",List.of(List.of(String.valueOf(addAccountRequestModel.getDmpProdcode()))))),UCOURI.UCO_CUSTOMER_ACCOUNT,porOrgacode);
saveCustomerAccountDetails(porOrgacode,customerProfile.getCmpCustcode(),accountNumber); saveCustomerAccountDetails(porOrgacode,customerProfile.getCmpCustcode(),accountNumber);
} }
public void saveCustomerAccountDetails(String porOrgacode, String cmpCustcode,String accountNumber){ public void saveCustomerAccountDetails(String porOrgacode, String cmpCustcode,String accountNumber){
fetchdepositAccountFromCiihive(porOrgacode, cmpCustcode).stream().forEach(k -> { fetchdepositAccountFromCiihive(porOrgacode, cmpCustcode).stream().forEach(k -> {
if(k.getMbmBkmsnumber().equals(accountNumber)){ if(k.getMbmBkmsnumber().equals(accountNumber)){
UcoAccount ucoAccount = UcoAccount.builder() UcoAccount ucoAccount = UcoAccount.builder()
.id(new AccountId(k.getPorOrgacode(), k.getMbmBkmsnumber())) .id(new AccountId(k.getPorOrgacode(), k.getMbmBkmsnumber()))
.dmpProdcode(k.getDmpProdcode()) .dmpProdcode(k.getDmpProdcode())
.mbmBkmstitle(k.getMbmBkmstitle()) .mbmBkmstitle(k.getMbmBkmstitle())
.pcrCurrdesc(k.getPcrCurrdesc()) .pcrCurrdesc(k.getPcrCurrdesc())
.cmpCustcode(k.getCmpCustcode()) .cmpCustcode(k.getCmpCustcode())
.pcrCurrcode(k.getPcrCurrcode()) .pcrCurrcode(k.getPcrCurrcode())
.pcrCurrshort(k.getPcrCurrshort()) .pcrCurrshort(k.getPcrCurrshort())
.mbmBkmsclosed(k.isMbmBkmsclosed()) .mbmBkmsclosed(k.isMbmBkmsclosed())
.mbmBkmsopendate(LocalDate.now()) .mbmBkmsopendate(LocalDate.now())
.sgtLasttrandate(LocalDate.now()) .sgtLasttrandate(LocalDate.now())
.build(); .build();
ucoAccountRepository.save(ucoAccount); ucoAccountRepository.save(ucoAccount);
} }
}); });
} }
public String preparePayloadForAccount(CustomerProfile customerProfile,String title){
Map<String,Object> jsonMap = new HashMap<>(); public String preparePayloadForAccount(CustomerProfile customerProfile, String title, String dmpProdcode) {
System.out.println(customerProfile);
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("SUS_USERCODE", "01"); jsonMap.put("SUS_USERCODE", "01");
jsonMap.put("CMP_CUSTCODE",customerProfile.getCmpCustcode()); jsonMap.put("CMP_CUSTCODE", customerProfile.getCmpCustcode());
jsonMap.put("CMP_FULLNAME", title); jsonMap.put("CMP_FULLNAME", title);
jsonMap.put("PLC_LOCACODE", "2003"); jsonMap.put("PLC_LOCACODE", "0010");
jsonMap.put("workFlowStage", "BN_WF_CP_AUTHORIZATION"); jsonMap.put("workFlowStage", "BN_WF_CP_AUTHORIZATION");
jsonMap.put("PCT_CSTYCODE", "I"); jsonMap.put("PCT_CSTYCODE", "I");
jsonMap.put("POR_ORGACODE", customerProfile.getPorOrgacode()); jsonMap.put("POR_ORGACODE", customerProfile.getPorOrgacode());
jsonMap.put("DMP_PRODCODE", dmpProdcode);
List<Map<String, Object>> workFlowLog = new ArrayList<>(); List<Map<String, Object>> workFlowLog = new ArrayList<>();
Map<String, Object> logEntry = new HashMap<>(); Map<String, Object> logEntry = new HashMap<>();
logEntry.put("susUsercode", "01"); logEntry.put("susUsercode", "01");
@ -249,9 +252,10 @@ public void saveCustomerAccountDetails(String porOrgacode, String cmpCustcode,St
Map<String, Object> createdDateMap = new HashMap<>(); Map<String, Object> createdDateMap = new HashMap<>();
createdDateMap.put("$date", new Date()); createdDateMap.put("$date", new Date());
jsonMap.put("@_CREATEDATE", createdDateMap); jsonMap.put("@_CREATEDATE", createdDateMap);
return JsonToString(jsonMap); return JsonToString(jsonMap);
} }
public String JsonToString(Object jsonMap){
public String JsonToString(Object jsonMap) {
try { try {
return this.objectMapper.writeValueAsString(jsonMap); return this.objectMapper.writeValueAsString(jsonMap);
} catch (JsonProcessingException var3) { } catch (JsonProcessingException var3) {

@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.mfsys.comm.exception.ApplicationException; import com.mfsys.comm.exception.ApplicationException;
import com.mfsys.comm.exception.ApplicationExceptionMapper; import com.mfsys.comm.exception.ApplicationExceptionMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -14,6 +15,7 @@ import reactor.core.publisher.Mono;
import java.io.IOException; import java.io.IOException;
@Service @Service
@Slf4j
public class WebClientDepositService { public class WebClientDepositService {
private final WebClient webClientDeposit; private final WebClient webClientDeposit;
@ -70,6 +72,9 @@ public class WebClientDepositService {
return response.getBody(); return response.getBody();
} catch (WebClientResponseException e) { } catch (WebClientResponseException e) {
ApplicationExceptionMapper.APIError errorDetails = parseErrorDetails(e); ApplicationExceptionMapper.APIError errorDetails = parseErrorDetails(e);
log.error("UCO Error Status: {}", e.getStatusCode());
log.error("UCO Error Body: {}", e.getResponseBodyAsString());
log.error("UCO Request Headers: {}", e.getRequest().getHeaders());
throw new ApplicationException(porgaCode, errorDetails.getErrorCode(), errorDetails.getArguments()); throw new ApplicationException(porgaCode, errorDetails.getErrorCode(), errorDetails.getArguments());
} }
} }

Loading…
Cancel
Save