updated payload

This commit is contained in:
bishwajeet.rajak committed 2026-10-12 16:22:52 +05:30
1 parent 950b0d1211
commit aa0b36b834
2 files changed
+179 -47

No files matched your search

@@ -123,6 +123,12 @@ public class IpksAmendCustomerRequest {
@JsonProperty("idno2")
private String idno2;
@JsonProperty("idtype3")
private String idtype3;
// @NotBlank(message = "idno2 must not be blank")
@JsonProperty("idno3")
private String idno3;
public String getCustomerType() { return customerType; }
public void setCustomerType(String customerType) { this.customerType = customerType; }
@@ -251,4 +257,23 @@ public String getIdno2() {
public void setIdno2(String idno2) {
this.idno2 = idno2;
}
public String getIdtype3() {
return idtype3;
}
public void setIdtype3(String idtype3) {
this.idtype3 = idtype3;
}
public String getIdno3() {
return idno3;
}
public void setIdno3(String idno3) {
this.idno3 = idno3;
}
}
@@ -158,59 +158,166 @@ public class CbsIntegrationService {
// ------------ Mapping (IpksAmendCustomerRequest -> CustomerData overrides) ------------
private void applyOverrides(IpksAmendCustomerRequest in, CustomerData d) {
set(d::setAcctNum1, in.getBankCif());
// set(d::setCustTyp1, in.getCustomerType());
// set(d::setTitle1, in.getTitle());
set(d::setDfltStr1, in.getFirstName());
// set(d::setDfltStr3, in.getMiddleName());
set(d::setDfltStr2, in.getLastName());
set(d::setDfltStr17, in.getGuardianName());
set(d::setDfltStr19, in.getRelativeCode().substring(0, 1).toUpperCase());
set(d::setDfltStr24, in.getMaritalStatus().substring(0, 1).toUpperCase());
set(d::setDfltStr18, in.getMotherMaidenName());
set(d::setDfltStr4, in.getAddress1());
set(d::setDfltStr5, in.getAddress2());
set(d::setDfltStr6, in.getAddress3());
// set(d::setDfltStr37, in.getBlock());
// set(d::setDfltStr8, in.getPinCode());
// set(d::setDfltStr31, in.getWard());
// set(d::setDfltStr36, in.getDistrict());
// set(d::setDfltStr7, in.getCity());
// set(d::setDfltStr35, in.getState());
// set(d::setDt2, in.getBirthDate());
// set(d::setDfltStr30, in.getMembershipNo());
// set(d::setDfltStr26, in.getFarmerType());
set(d::setDfltStr23, in.getGender());
// set(d::setDfltStr23, in.getReligion());
// set(d::setDfltStr25, in.getCaste());
set(d::setDfltStr12, in.getMobileNo());
// set(d::setDfltStr14, in.getEmailId());
set(d::setCustRisk1, "VYNB".equalsIgnoreCase(in.getBankId()) ? "00" : "02");
// set(d::setDfltStr11, in.getResidentStatus());
set(d::setKycDt, LocalDate.now().format(DateTimeFormatter.ofPattern("ddMMyyyy")));
private void applyOverrides(IpksAmendCustomerRequest in, CustomerData d) {
set(d::setAcctNum1, in.getBankCif());
set(d::setDfltStr1, in.getFirstName());
set(d::setDfltStr2, in.getLastName());
set(d::setDfltStr17, in.getGuardianName());
set(d::setDfltStr19, in.getRelativeCode().substring(0, 1).toUpperCase());
set(d::setDfltStr24, in.getMaritalStatus().substring(0, 1).toUpperCase());
set(d::setDfltStr18, in.getMotherMaidenName());
set(d::setDfltStr4, in.getAddress1());
set(d::setDfltStr5, in.getAddress2());
set(d::setDfltStr6, in.getAddress3());
set(d::setDfltStr23, in.getGender());
set(d::setDfltStr12, in.getMobileNo());
set(d::setCustRisk1, "VYNB".equalsIgnoreCase(in.getBankId()) ? "00" : "02");
set(d::setKycDt, LocalDate.now().format(DateTimeFormatter.ofPattern("ddMMyyyy")));
set(d::setDfltStr41, in.getFatca());
set(d::setDfltStr7, in.getDistrict());
set(d::setDfltStr26, "0101");
set(d::setKycStat, "1");
set(d::setDfltStr35, "44");
// set(d::setCountryCode1, in.getCountry());
set(d::setDfltStr41, in.getFatca());
// ===== LOG =====
log.info("=== REQUEST ID VALUES ===");
log.info("in.getIdtype1(): {} - in.getIdno1(): {}", in.getIdtype1(), in.getIdno1());
log.info("in.getIdtype2(): {} - in.getIdno2(): {}", in.getIdtype2(), in.getIdno2());
log.info("in.getIdtype3(): {} - in.getIdtype3(): {}", in.getIdtype3(), in.getIdno3());
set(d::setIdTyp1, in.getIdtype1());
set(d::setDfltStr13, in.getIdno1());
set(d::setIdTyp2, in.getIdtype2());
set(d::setIdNum2, in.getIdno2());
log.info("=== API-1 ID VALUES (DO NOT TOUCH IdTyp1/DfltStr13) ===");
log.info("IdTyp1 (PRIMARY): {} - DfltStr13: {}", d.getIdTyp1(), d.getDfltStr13());
log.info("IdTyp2: {} - IdNum2: {}", d.getIdTyp2(), d.getIdNum2());
log.info("DfltStr37: {}", d.getDfltStr37());
log.info("DfltStr38: {}", d.getDfltStr38());
// ===== Collect IDs already present in API-1 (for duplicate check) =====
java.util.Set<String> existingNumbers = new java.util.HashSet<>();
set(d::setDt1, "00000000");
set(d::setDt3, "00000000");
set(d::setDt4, "00000000");
set(d::setDt5, "00000000");
set(d::setDt6, "00000000");
set(d::setDt7, "00000000");
set(d::setDfltStr34,"IN");
set(d::setExmptnFld3,"00000000");
set(d::setExmptnFld4,"00000000");
// Slot 1 - PRIMARY (DO NOT OVERRIDE, just track)
if (d.getDfltStr13() != null && !d.getDfltStr13().isEmpty()) {
existingNumbers.add(d.getDfltStr13());
}
// Slot 2
if (d.getIdNum2() != null && !d.getIdNum2().isEmpty()) {
existingNumbers.add(d.getIdNum2());
}
// Slot 3
if (d.getDfltStr37() != null && !d.getDfltStr37().isEmpty()) {
existingNumbers.add(d.getDfltStr37());
}
// Slot 4
if (d.getDfltStr38() != null && !d.getDfltStr38().isEmpty()) {
existingNumbers.add(d.getDfltStr38());
}
log.info("=== API-1 EXISTING NUMBERS: {} ===", existingNumbers);
//===== Build list of IDs from request NOT already present =====
java.util.List<String[]> idsToSet = new java.util.ArrayList<>();
// Check Aadhar
if (in.getIdtype1() != null && !in.getIdtype1().isEmpty()
&& in.getIdno1() != null && !in.getIdno1().isEmpty()
&& !existingNumbers.contains(in.getIdno1())) {
idsToSet.add(new String[]{in.getIdtype1(), in.getIdno1()});
log.info("Aadhar NOT present → Will set: {} - {}", in.getIdtype1(), in.getIdno1());
} else if (in.getIdno1() != null) {
log.info("Aadhar already present → Skip");
}
// Check PAN
if (in.getIdtype2() != null && !in.getIdtype2().isEmpty()
&& in.getIdno2() != null && !in.getIdno2().isEmpty()
&& !existingNumbers.contains(in.getIdno2())) {
idsToSet.add(new String[]{in.getIdtype2(), in.getIdno2()});
log.info("PAN NOT present → Will set: {} - {}", in.getIdtype2(), in.getIdno2());
} else if (in.getIdno2() != null) {
log.info("PAN already present → Skip");
}
// Check Voter
if (in.getIdtype3() != null && !in.getIdtype3().isEmpty()
&& in.getIdno3() != null && !in.getIdno3().isEmpty()
&& !existingNumbers.contains(in.getIdno3())) {
idsToSet.add(new String[]{in.getIdtype3(), in.getIdno3()});
log.info("Voter NOT present → Will set: {} - {}", in.getIdtype3(), in.getIdno3());
} else if (in.getIdno3() != null) {
log.info("Voter already present → Skip");
}
log.info("=== IDs TO SET: {} ===", idsToSet.size());
// ===== Determine slot availability =====
// IdTyp1/DfltStr13 → NEVER OVERRIDE (PRIMARY)
// IdTyp2/IdNum2 → Available if empty OR contains unrelated ID type
// DfltStr37 → Available if empty (number only)
// DfltStr38 → Available if empty (number only)
String[] knownIdTypes = {"61", "07", "06"};
boolean slot2Available = true;
String idTyp2Current = d.getIdTyp2();
if (idTyp2Current != null && !idTyp2Current.isEmpty()) {
// Check if IdTyp2 contains one of our known ID types
for (String known : knownIdTypes) {
if (known.equals(idTyp2Current)) {
// It's a known ID type but check if the number is already tracked
slot2Available = false;
break;
}
}
}
boolean slot37Available = (d.getDfltStr37() == null || d.getDfltStr37().isEmpty());
boolean slot38Available = (d.getDfltStr38() == null || d.getDfltStr38().isEmpty());
log.info("Slot2 (IdTyp2) available: {}", slot2Available);
log.info("Slot37 (DfltStr37) available: {}", slot37Available);
log.info("Slot38 (DfltStr38) available: {}", slot38Available);
// ===== Set the IDs in available slots =====
for (String[] id : idsToSet) {
String idType = id[0];
String idNo = id[1];
// Priority 1: IdTyp2/IdNum2 (has both type and number)
if (slot2Available) {
set(d::setIdTyp2, idType);
set(d::setIdNum2, idNo);
log.info("=== Setting IdTyp2 to {} - {} ===", idType, idNo);
slot2Available = false;
}
// Priority 2: DfltStr37 (only number)
else if (slot37Available) {
set(d::setDfltStr37, idNo);
log.info("=== Setting DfltStr37 to {} (ID Type: {}) ===", idNo, idType);
slot37Available = false;
}
// Priority 3: DfltStr38 (only number)
else if (slot38Available) {
set(d::setDfltStr38, idNo);
log.info("=== Setting DfltStr38 to {} (ID Type: {}) ===", idNo, idType);
slot38Available = false;
}
else {
log.warn("No more slots available for ID: {} - {}", idType, idNo);
}
}
set(d::setDt1, "00000000");
set(d::setDt3, "00000000");
set(d::setDt4, "00000000");
set(d::setDt5, "00000000");
set(d::setDt6, "00000000");
set(d::setDt7, "00000000");
set(d::setDfltStr34,"IN");
set(d::setExmptnFld3,"00000000");
set(d::setExmptnFld4,"00000000");
}
private static void set(Consumer<String> setter, String value) {
if (value != null && !value.isBlank()) {
setter.accept(value.trim());