|
@@ -5,7 +5,7 @@ import java.io.File; |
|
|
import java.io.FileOutputStream; |
|
|
import java.io.FileOutputStream; |
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
@@ -195,7 +195,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
return file; |
|
|
return file; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Map<String, Object> getTemplate(Long templateId, Long clientId) { |
|
|
|
|
|
|
|
|
public Map<String, Object> getTemplate(Long templateId, Long clientId) throws IOException{ |
|
|
Map<String, Object> template = templateService.loadTemplate(templateId); |
|
|
Map<String, Object> template = templateService.loadTemplate(templateId); |
|
|
|
|
|
|
|
|
byte[] pdfBytes = (byte[])template.get("blobValue"); |
|
|
byte[] pdfBytes = (byte[])template.get("blobValue"); |
|
@@ -204,8 +204,28 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
return template; |
|
|
return template; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public byte[] getTemplateForm(byte[] pdfBytes, Long clientId, Long templateId) { |
|
|
|
|
|
|
|
|
//This included the common fields getting |
|
|
|
|
|
public byte[] getTemplateForm(byte[] pdfBytes, Long templateId, Long clientId) throws IOException { |
|
|
|
|
|
Map<String, Object> template = templateService.loadTemplate(templateId); |
|
|
|
|
|
|
|
|
|
|
|
//Search if there have an old form having the form code |
|
|
|
|
|
Map<String, Object> sourcePdf = templateService.getLastPdfByFormCode((String)template.get("remarks"), clientId); |
|
|
|
|
|
byte[] sourcePdfBytes = (byte[])sourcePdf.get("blobValue"); |
|
|
|
|
|
|
|
|
|
|
|
//byte[] modifiedPdfBytes = pdfBytes; |
|
|
|
|
|
|
|
|
|
|
|
PdfAcroForm sourceForm = null; |
|
|
|
|
|
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(sourcePdfBytes); |
|
|
|
|
|
ByteArrayOutputStream sourceOutputStream = new ByteArrayOutputStream()) { |
|
|
|
|
|
|
|
|
|
|
|
PdfReader sourceReader = new PdfReader(inputStream); |
|
|
|
|
|
PdfWriter sourceWriter = new PdfWriter(sourceOutputStream); |
|
|
|
|
|
PdfDocument sourcePdfDoc = new PdfDocument(sourceReader, sourceWriter); |
|
|
|
|
|
sourceForm = PdfAcroForm.getAcroForm(sourcePdfDoc, true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte[] modifiedPdfBytes = pdfBytes; |
|
|
byte[] modifiedPdfBytes = pdfBytes; |
|
|
|
|
|
|
|
|
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(pdfBytes); |
|
|
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(pdfBytes); |
|
@@ -217,6 +237,30 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); |
|
|
PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); |
|
|
|
|
|
|
|
|
if (form != null) { |
|
|
if (form != null) { |
|
|
|
|
|
|
|
|
|
|
|
/* START of copying the source fields if exist */ |
|
|
|
|
|
if(sourceForm != null){ |
|
|
|
|
|
for (Map.Entry<String, PdfFormField> entry : sourceForm.getFormFields().entrySet()) { |
|
|
|
|
|
PdfFormField sourceField = entry.getValue(); |
|
|
|
|
|
|
|
|
|
|
|
if(sourceField.getFieldName() != null){ |
|
|
|
|
|
String sourceFieldName = sourceField.getFieldName().toUnicodeString(); |
|
|
|
|
|
if(sourceField.getValue() != null){ |
|
|
|
|
|
String sourceFieldValue = sourceField.getValue().toString(); |
|
|
|
|
|
PdfFormField targetField = form.getField(sourceFieldName); |
|
|
|
|
|
|
|
|
|
|
|
if (targetField != null) { |
|
|
|
|
|
targetField.setValue(sourceFieldValue); // Set the value in the target field |
|
|
|
|
|
} else { |
|
|
|
|
|
//System.out.println("Field '" + sourceFieldName + "' from source not found in target PDF."); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
/* END of copying the source fields */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --- START DEBUGGING CODE TO LIST ALL PDF FORM FIELDS --- |
|
|
// --- START DEBUGGING CODE TO LIST ALL PDF FORM FIELDS --- |
|
|
// logger.info("--- Listing all form fields in the PDF (for ID: {}) ---", id); |
|
|
// logger.info("--- Listing all form fields in the PDF (for ID: {}) ---", id); |
|
|
// if (form.getFormFields().isEmpty()) { |
|
|
// if (form.getFormFields().isEmpty()) { |
|
@@ -234,16 +278,14 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
// logger.info("id? " + id); |
|
|
// logger.info("id? " + id); |
|
|
CommonField commonField = commonFieldService.find(commonFieldId).orElse(null); |
|
|
CommonField commonField = commonFieldService.find(commonFieldId).orElse(null); |
|
|
|
|
|
|
|
|
Template template = templateService.find(templateId).orElseThrow(); |
|
|
|
|
|
|
|
|
|
|
|
if(commonField == null){ |
|
|
if(commonField == null){ |
|
|
logger.info("No common field data found for clientId: " + clientId); |
|
|
|
|
|
|
|
|
//logger.info("No common field data found for clientId: " + clientId); |
|
|
// do nothing |
|
|
// do nothing |
|
|
} else { |
|
|
} else { |
|
|
// It's highly recommended to check if the field exists before setting its value |
|
|
// It's highly recommended to check if the field exists before setting its value |
|
|
// This prevents NullPointerExceptions if a field is missing in a template |
|
|
// This prevents NullPointerExceptions if a field is missing in a template |
|
|
//temp using the remarks as form code |
|
|
//temp using the remarks as form code |
|
|
String formCode = (String)template.getRemarks(); |
|
|
|
|
|
|
|
|
String formCode = (String)template.get("remarks"); |
|
|
|
|
|
|
|
|
if("IDA".equals(formCode)){ // This is IDA |
|
|
if("IDA".equals(formCode)){ // This is IDA |
|
|
logger.info("Processing IDA form (ID: 1)"); |
|
|
logger.info("Processing IDA form (ID: 1)"); |
|
@@ -251,20 +293,212 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
setValueIfPresent(form, "fill_7", commonField.getNameChi(), "commonField.getNameChi()"); |
|
|
setValueIfPresent(form, "fill_7", commonField.getNameChi(), "commonField.getNameChi()"); |
|
|
setValueIfPresent(form, "fill_11", commonField.getIdCard(), "commonField.getIdCard()"); |
|
|
setValueIfPresent(form, "fill_11", commonField.getIdCard(), "commonField.getIdCard()"); |
|
|
|
|
|
|
|
|
|
|
|
/* Page1 Start */ |
|
|
|
|
|
setValueIfPresent(form, "gender_m", commonField.getGenderMale(), "commonField.getGenderMale()"); |
|
|
|
|
|
setValueIfPresent(form, "gender_f", commonField.getGenderFemale(), "commonField.getGenderFemale()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "date_dd", commonField.getDdDateOfBirth(), "commonField.getDdDateOfBirth()"); |
|
|
|
|
|
setValueIfPresent(form, "date_mm", commonField.getMmDateOfBirth(), "commonField.getMmDateOfBirth()"); |
|
|
|
|
|
setValueIfPresent(form, "date_yyyy", commonField.getYyyyDateOfBirth(), "commonField.getYyyyDateOfBirth()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_17", commonField.getContactNo(), "commonField.getContactNo()"); |
|
|
|
|
|
setValueIfPresent(form, "edu_pri", commonField.getEduPri(), "commonField.getEduPri()"); |
|
|
|
|
|
setValueIfPresent(form, "edu_sec", commonField.getEduSec(), "commonField.getEduSec()"); |
|
|
|
|
|
setValueIfPresent(form, "edu_post_sec", commonField.getEduPostSec(), "commonField.getEduPostSec()"); |
|
|
|
|
|
/* Page1 End */ |
|
|
|
|
|
/* Page2 Start */ |
|
|
|
|
|
setValueIfPresent(form, "own_income", commonField.getOwn_income(), "commonField.getOwn_income()"); |
|
|
|
|
|
setValueIfPresent(form, "savings", commonField.getSavings(), "commonField.getSavings()"); |
|
|
|
|
|
setValueIfPresent(form, "premium_financing", commonField.getPremium_financing(), "commonField.getPremium_financing()"); |
|
|
|
|
|
setValueIfPresent(form, "others_funds", commonField.getOthers_funds(), "commonField.getOthers_funds()"); |
|
|
|
|
|
setValueIfPresent(form, "others_funds_desc", commonField.getOthers_funds_desc(), "commonField.getOthers_funds_desc()"); |
|
|
|
|
|
/* Page2 End */ |
|
|
|
|
|
/* Page3 Start */ |
|
|
|
|
|
setValueIfPresent(form, "fill_26_4", commonField.getFna_c1a_amount(), "commonField.getFna_c1a_amount()"); |
|
|
|
|
|
/* Page3 End */ |
|
|
|
|
|
/* Page4 Start */ |
|
|
|
|
|
setValueIfPresent(form, "total_asset", commonField.getFna_c2a_amount(), "commonField.getFna_c2a_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_56", commonField.getFna_c2b_amount(), "commonField.getFna_c2b_amount()"); |
|
|
|
|
|
/* Page4 End */ |
|
|
|
|
|
|
|
|
} else if("FNA".equals(formCode)){ // This is FNA |
|
|
} else if("FNA".equals(formCode)){ // This is FNA |
|
|
logger.info("Processing FNA form (ID: 2)"); |
|
|
|
|
|
|
|
|
//logger.info("Processing FNA form (ID: 2)"); |
|
|
|
|
|
/* Page1 Start */ |
|
|
setValueIfPresent(form, "fna_a_name", commonField.getName(), "commonField.getName()"); |
|
|
setValueIfPresent(form, "fna_a_name", commonField.getName(), "commonField.getName()"); |
|
|
setValueIfPresent(form, "fna_a_birth", commonField.getDateOfBirth(), "commonField.getDateOfBirth()"); |
|
|
setValueIfPresent(form, "fna_a_birth", commonField.getDateOfBirth(), "commonField.getDateOfBirth()"); |
|
|
setValueIfPresent(form, "fna_a_occupation", commonField.getOccupation(), "commonField.getOccupation()"); |
|
|
setValueIfPresent(form, "fna_a_occupation", commonField.getOccupation(), "commonField.getOccupation()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_primary", commonField.getEduPri(), "commonField.getEduPri()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_secondary", commonField.getEduSec(), "commonField.getEduSec()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_tertiary", commonField.getEduTer(), "commonField.getEduTer()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_a_tertiary", commonField.getEduTer(), "commonField.getEduTer()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_marital", commonField.getMaritalStatus(), "commonField.getMaritalStatus()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_contact", commonField.getContactNo(), "commonField.getContactNo()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_dependents", commonField.getNoOfDependents(), "commonField.getNoOfDependents()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c1a_amount", commonField.getFna_c1a_amount(), "commonField.getFna_c1a_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1b_amount", commonField.getFna_c1b_amount(), "commonField.getFna_c1b_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1c_1_amount", commonField.getFna_c1c_1_amount(), "commonField.getFna_c1c_1_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1c_2_amount", commonField.getFna_c1c_2_amount(), "commonField.getFna_c1c_2_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1c_3_amount", commonField.getFna_c1c_3_amount(), "commonField.getFna_c1c_3_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1d_amount", commonField.getFna_c1d_amount(), "commonField.getFna_c1d_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2a_amount", commonField.getFna_c2a_amount(), "commonField.getFna_c2a_amount()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c2b_amount", commonField.getFna_c2b_amount(), "commonField.getFna_c2b_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2c_amount", commonField.getFna_c2c_amount(), "commonField.getFna_c2c_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2d_amount", commonField.getFna_c2d_amount(), "commonField.getFna_c2d_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2e_amount", commonField.getFna_c2e_amount(), "commonField.getFna_c2e_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_a", commonField.getFna_b1_a(), "commonField.getFna_b1_a()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_a_amount", commonField.getFna_b1_a_amount(), "commonField.getFna_b1_a_amount()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b1_b", commonField.getFna_b1_b(), "commonField.getFna_b1_b()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1a_4_amount", commonField.getFna_b1a_4_amount(), "commonField.getFna_b1a_4_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_c", commonField.getFna_b1_c(), "commonField.getFna_b1_c()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_d", commonField.getFna_b1_d(), "commonField.getFna_b1_d()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b1_d_year", commonField.getFna_b1_d_year(), "commonField.getFna_b1_d_year()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_d_amount", commonField.getFna_b1_d_amount(), "commonField.getFna_b1_d_amount()"); |
|
|
|
|
|
/* Page1 End */ |
|
|
|
|
|
/* Page2 Start */ |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_e", commonField.getFna_b1_e(), "commonField.getFna_b1_e()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_f", commonField.getFna_b1_f(), "commonField.getFna_b1_f()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_f_other", commonField.getFna_b1_f_other(), "commonField.getFna_b1_f_other()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_f_desc", commonField.getFna_b1_f_desc(), "commonField.getFna_b1_f_desc()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b2_a", commonField.getFna_b2_a(), "commonField.getFna_b2_a()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_b", commonField.getFna_b2_b(), "commonField.getFna_b2_b()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_d", commonField.getFna_b2_d(), "commonField.getFna_b2_d()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_e", commonField.getFna_b2_e(), "commonField.getFna_b2_e()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_f", commonField.getFna_b2_f(), "commonField.getFna_b2_f()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_g", commonField.getFna_b2_g(), "commonField.getFna_b2_g()"); |
|
|
|
|
|
/* Page2 End */ |
|
|
|
|
|
/* Page3 Start */ |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_10", commonField.getFna_c1e_10(), "commonField.getFna_c1e_10()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_10_20", commonField.getFna_c1e_10_20(), "commonField.getFna_c1e_10_20()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_21_30", commonField.getFna_c1e_21_30(), "commonField.getFna_c1e_21_30()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_31_40", commonField.getFna_c1e_31_40(), "commonField.getFna_c1e_31_40()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_41_50", commonField.getFna_c1e_41_50(), "commonField.getFna_c1e_41_50()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_50", commonField.getFna_c1e_50(), "commonField.getFna_c1e_50()"); |
|
|
|
|
|
/* Page3 End */ |
|
|
|
|
|
/* Page4 Start */ |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_10", commonField.getFna_c2f_10(), "commonField.getFna_c2f_10()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_10_20", commonField.getFna_c2f_10_20(), "commonField.getFna_c2f_10_20()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_21_30", commonField.getFna_c2f_21_30(), "commonField.getFna_c2f_21_30()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_31_40", commonField.getFna_c2f_31_40(), "commonField.getFna_c2f_31_40()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_41_50", commonField.getFna_c2f_41_50(), "commonField.getFna_c2f_41_50()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_50", commonField.getFna_c2f_50(), "commonField.getFna_c2f_50()"); |
|
|
|
|
|
/* Page4 End */ |
|
|
|
|
|
/* Page5 End */ |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_2_5", commonField.getFna_c3a_2_5(), "commonField.getFna_c3a_2_5()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_6_10", commonField.getFna_c3a_6_10(), "commonField.getFna_c3a_6_10()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_11_15", commonField.getFna_c3a_11_15(), "commonField.getFna_c3a_11_15()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_16_20", commonField.getFna_c3a_16_20(), "commonField.getFna_c3a_16_20()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_20", commonField.getFna_c3a_20(), "commonField.getFna_c3a_20()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_life", commonField.getFna_c3a_life(), "commonField.getFna_c3a_life()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_single_pay", commonField.getFna_c3a_single_pay(), "commonField.getFna_c3a_single_pay()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_a_retire", commonField.getFna_a_retire(), "commonField.getFna_a_retire()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_salary", commonField.getFna_c3b_salary(), "commonField.getFna_c3b_salary()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_income", commonField.getFna_c3b_income(), "commonField.getFna_c3b_income()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_saving", commonField.getFna_c3b_saving(), "commonField.getFna_c3b_saving()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_investments", commonField.getFna_c3b_investments(), "commonField.getFna_c3b_investments()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_policy", commonField.getFna_c3b_policy(), "commonField.getFna_c3b_policy()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_others", commonField.getFna_c3b_others(), "commonField.getFna_c3b_others()"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_desc", commonField.getFna_c3b_desc(), "commonField.getFna_c3b_desc()"); |
|
|
|
|
|
/* Page5 End */ |
|
|
|
|
|
|
|
|
} else if("HSBCFIN".equals(formCode)){ // This is HSBCFIN |
|
|
} else if("HSBCFIN".equals(formCode)){ // This is HSBCFIN |
|
|
logger.info("Processing HSBCFIN form (ID: 3)"); |
|
|
|
|
|
|
|
|
//logger.info("Processing HSBCFIN form (ID: 3)"); |
|
|
|
|
|
/* Page1 Start */ |
|
|
setValueIfPresent(form, "fill_3", commonField.getName(), "commonField.getName()"); |
|
|
setValueIfPresent(form, "fill_3", commonField.getName(), "commonField.getName()"); |
|
|
setValueIfPresent(form, "fill_4", commonField.getNameChi(), "commonField.getNameChi()"); |
|
|
setValueIfPresent(form, "fill_4", commonField.getNameChi(), "commonField.getNameChi()"); |
|
|
setValueIfPresent(form, "fill_5", commonField.getGender(), "commonField.getGender()"); |
|
|
setValueIfPresent(form, "fill_5", commonField.getGender(), "commonField.getGender()"); |
|
|
setValueIfPresent(form, "fill_6", commonField.getDateOfBirth(), "commonField.getDateOfBirth()"); // Note: fill_6 used here again |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_6", commonField.getDateOfBirth(), "commonField.getDateOfBirth()"); |
|
|
setValueIfPresent(form, "fill_9", commonField.getOccupation(), "commonField.getOccupation()"); |
|
|
setValueIfPresent(form, "fill_9", commonField.getOccupation(), "commonField.getOccupation()"); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_7", commonField.getMaritalStatus(), "commonField.getMaritalStatus()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_8", commonField.getNoOfDependents(), "commonField.getNoOfDependents()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_10", commonField.getContactNo(), "commonField.getContactNo()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "toggle_1", commonField.getEduPri(), "commonField.getEduPri()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_2", commonField.getEduSec(), "commonField.getEduSec()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_3", commonField.getEduPostSec(), "commonField.getEduPostSec()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_3", commonField.getEduTer(), "commonField.getEduTer()"); //it may by filled in IDA edu ter |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_11", NumberUtils.toScaledBigDecimal(NumberUtils.toScaledBigDecimal(commonField.getFna_c1a_amount(), 0, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(12))).toString() , "commonField.getFna_c1a_amount()"); //annual salary |
|
|
|
|
|
setValueIfPresent(form, "fill_12", NumberUtils.toScaledBigDecimal(NumberUtils.toScaledBigDecimal(commonField.getFna_c1b_amount(), 0, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(12))).toString() , "commonField.getFna_c1b_amount()"); //annual salary |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_12a", commonField.getFna_c1c_3_amount(), "commonField.getFna_c1c_3_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_13", commonField.getFna_c1c_3_amount(), "commonField.getFna_c1c_3_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_14", commonField.getFna_c1c_2_amount(), "commonField.getFna_c1c_2_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_16", commonField.getFna_c1d_amount(), "commonField.getFna_c1d_amount()"); |
|
|
|
|
|
/* Page1 End */ |
|
|
|
|
|
/* Page2 Start */ |
|
|
|
|
|
setValueIfPresent(form, "fill_01", commonField.getFna_c2a_amount(), "commonField.getFna_c2a_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_02", commonField.getFna_c2b_amount(), "commonField.getFna_c2b_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_03", commonField.getFna_c2c_amount(), "commonField.getFna_c2c_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_04", commonField.getFna_c2d_amount(), "commonField.getFna_c2d_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_05", commonField.getFna_c2e_amount(), "commonField.getFna_c2e_amount()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "Financial Protection", commonField.getFna_b1_a(), "commonField.getFna_b1_a()"); |
|
|
|
|
|
setValueIfPresent(form, "Preparation", commonField.getFna_b1_b(), "commonField.getFna_b1_b()"); |
|
|
|
|
|
setValueIfPresent(form, "Providing", commonField.getFna_b1_c(), "commonField.getFna_b1_c()"); |
|
|
|
|
|
setValueIfPresent(form, "Saving", commonField.getFna_b1_d(), "commonField.getFna_b1_d()"); |
|
|
|
|
|
setValueIfPresent(form, "Investment", commonField.getFna_b1_e(), "commonField.getFna_b1_e()"); |
|
|
|
|
|
setValueIfPresent(form, "Others", commonField.getFna_b1_f(), "commonField.getFna_b1_f()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_8_2", commonField.getFna_b1_f_other(), "commonField.getFna_b1_f_other()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_8_21", commonField.getFna_b1_f_desc(), "commonField.getFna_b1_f_desc()"); |
|
|
|
|
|
/* Page2 End */ |
|
|
|
|
|
/* Page3 Start */ |
|
|
|
|
|
setValueIfPresent(form, "toggle_91", commonField.getFna_b1_a(), "commonField.getFna_b1_a()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4", commonField.getFna_b1_a_amount(), "commonField.getFna_b1_a_amount()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4b", commonField.getFna_b1_b(), "commonField.getFna_b1_b()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_93", commonField.getFna_b1_d(), "commonField.getFna_b1_d()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4c", commonField.getFna_b1_d_year(), "commonField.getFna_b1_d_year()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4d", commonField.getFna_b1_d_year(), "commonField.getFna_b1_d_year()"); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4e", commonField.getFna_b1_d_amount(), "commonField.getFna_b1_d_amount()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "toggle_4_2", commonField.getFna_b2_a(), "commonField.getFna_b2_a()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_5", commonField.getFna_b2_b(), "commonField.getFna_b2_b()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_6", commonField.getFna_b2_c(), "commonField.getFna_b2_c()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_7", commonField.getFna_b2_d(), "commonField.getFna_b2_d()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_8", commonField.getFna_b2_e(), "commonField.getFna_b2_e()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_9", commonField.getFna_b2_f(), "commonField.getFna_b2_f()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_10", commonField.getFna_b2_g(), "commonField.getFna_b2_g()"); |
|
|
|
|
|
/* Page3 End */ |
|
|
|
|
|
/* Page4 Start */ |
|
|
|
|
|
setValueIfPresent(form, "toggle_1_2", commonField.getFna_c3a_2_5(), "commonField.getFna_c3a_2_5()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_2_2", commonField.getFna_c3a_6_10(), "commonField.getFna_c3a_6_10()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_3_2", commonField.getFna_c3a_11_15(), "commonField.getFna_c3a_11_15()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_4_3", commonField.getFna_c3a_16_20(), "commonField.getFna_c3a_16_20()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_5_2", commonField.getFna_c3a_20(), "commonField.getFna_c3a_20()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_6_2", commonField.getFna_c3a_life(), "commonField.getFna_c3a_life()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_6_2_sum", commonField.getFna_c3a_2_5(), "commonField.getFna_c3a_2_5()"); |
|
|
|
|
|
/* Page4 End */ |
|
|
|
|
|
/* Page5 Start */ |
|
|
|
|
|
setValueIfPresent(form, "toggle_1f", commonField.getFna_c3b_income(), "commonField.getFna_c3b_income()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_1g", commonField.getFna_c3b_saving(), "commonField.getFna_c3b_saving()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_1h", commonField.getFna_c3b_policy(), "commonField.getFna_c3b_policy()"); |
|
|
|
|
|
setValueIfPresent(form, "toggle_1i56", commonField.getFna_c3b_others(), "commonField.getFna_c3b_others()"); |
|
|
|
|
|
setValueIfPresent(form, "Text3", commonField.getFna_c3b_desc(), "commonField.getFna_c3b_desc()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "Check Box6", commonField.getFna_c1e_10(), "commonField.getFna_c1e_10()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box7", commonField.getFna_c1e_10_20(), "commonField.getFna_c1e_10_20()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box8", commonField.getFna_c1e_21_30(), "commonField.getFna_c1e_21_30()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box9", commonField.getFna_c1e_31_40(), "commonField.getFna_c1e_31_40()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box10", commonField.getFna_c1e_41_50(), "commonField.getFna_c1e_41_50()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box11", commonField.getFna_c1e_50(), "commonField.getFna_c1e_50()"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "Check Box12", commonField.getFna_c2f_10(), "commonField.getFna_c2f_10()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box13", commonField.getFna_c2f_10_20(), "commonField.getFna_c2f_10_20()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box14", commonField.getFna_c2f_21_30(), "commonField.getFna_c2f_21_30()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box15", commonField.getFna_c2f_31_40(), "commonField.getFna_c2f_31_40()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box16", commonField.getFna_c2f_41_50(), "commonField.getFna_c2f_41_50()"); |
|
|
|
|
|
setValueIfPresent(form, "Check Box17", commonField.getFna_c2f_50(), "commonField.getFna_c2f_50()"); |
|
|
|
|
|
/* Page5 End */ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// These fields are set unconditionally if commonField is not null |
|
|
// These fields are set unconditionally if commonField is not null |
|
|
// Ensure these fields exist across all your templates or handle them conditionally |
|
|
// Ensure these fields exist across all your templates or handle them conditionally |
|
@@ -280,7 +514,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
|
|
|
|
|
|
pdfDoc.close(); |
|
|
pdfDoc.close(); |
|
|
modifiedPdfBytes = outputStream.toByteArray(); |
|
|
modifiedPdfBytes = outputStream.toByteArray(); |
|
|
logger.info("Modified PDF byte array length: " + modifiedPdfBytes.length); |
|
|
|
|
|
|
|
|
//logger.info("Modified PDF byte array length: " + modifiedPdfBytes.length); |
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
// logger.error("Error processing PDF with iText for ID: " + id, e); |
|
|
// logger.error("Error processing PDF with iText for ID: " + id, e); |
|
@@ -365,8 +599,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
return jdbcDao.queryForInt(sql.toString(), Map.of("name", name)); |
|
|
return jdbcDao.queryForInt(sql.toString(), Map.of("name", name)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//This included the common fields saving |
|
|
//This included the common fields saving |
|
|
public void saveCmField(File file, Pdf record) throws IOException { |
|
|
public void saveCmField(File file, Pdf record) throws IOException { |
|
|
// byte[] pdfBytes = Files.readAllBytes(file.toPath()); |
|
|
// byte[] pdfBytes = Files.readAllBytes(file.toPath()); |
|
@@ -379,11 +611,11 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
PDDocument document = Loader.loadPDF(file); // Changed! |
|
|
PDDocument document = Loader.loadPDF(file); // Changed! |
|
|
PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm(); |
|
|
PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm(); |
|
|
|
|
|
|
|
|
logger.info("acroForm? " + (acroForm != null) ); |
|
|
|
|
|
|
|
|
//logger.info("acroForm? " + (acroForm != null) ); |
|
|
if (acroForm != null) { |
|
|
if (acroForm != null) { |
|
|
//create CommonField if not exists for this client Id |
|
|
//create CommonField if not exists for this client Id |
|
|
Long id = commonFieldService.getByClientId(record.getClientId()); |
|
|
Long id = commonFieldService.getByClientId(record.getClientId()); |
|
|
logger.info("id? " + id); |
|
|
|
|
|
|
|
|
//logger.info("id? " + id); |
|
|
CommonField commonField = null; |
|
|
CommonField commonField = null; |
|
|
if(id > 0){ |
|
|
if(id > 0){ |
|
|
commonField = commonFieldService.find(id).orElse(new CommonField()); |
|
|
commonField = commonFieldService.find(id).orElse(new CommonField()); |
|
@@ -393,7 +625,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
//logger.info("commonField? " + commonField.toString()); |
|
|
//logger.info("commonField? " + commonField.toString()); |
|
|
commonField.setClientId(record.getClientId()); |
|
|
commonField.setClientId(record.getClientId()); |
|
|
|
|
|
|
|
|
logger.info("commonField? " + commonField.getId()); |
|
|
|
|
|
|
|
|
//logger.info("commonField? " + commonField.getId()); |
|
|
// Example: Iterate through fields and print values |
|
|
// Example: Iterate through fields and print values |
|
|
for (PDField field : acroForm.getFields()) { |
|
|
for (PDField field : acroForm.getFields()) { |
|
|
String fieldName = field.getPartialName(); |
|
|
String fieldName = field.getPartialName(); |
|
@@ -403,13 +635,14 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
String formCode = (String)template.get("remarks"); |
|
|
String formCode = (String)template.get("remarks"); |
|
|
|
|
|
|
|
|
if ("IDA".equals(formCode)) { |
|
|
if ("IDA".equals(formCode)) { |
|
|
logger.info("IDA "); |
|
|
|
|
|
|
|
|
//logger.info("IDA "); |
|
|
|
|
|
|
|
|
switch (fieldName) { |
|
|
switch (fieldName) { |
|
|
|
|
|
/* Page1 Start */ |
|
|
case "fill_6" -> commonField.setName(fieldValue); |
|
|
case "fill_6" -> commonField.setName(fieldValue); |
|
|
case "fill_7" -> commonField.setNameChi(fieldValue); |
|
|
case "fill_7" -> commonField.setNameChi(fieldValue); |
|
|
case "fill_11" -> commonField.setIdCard(fieldValue); |
|
|
case "fill_11" -> commonField.setIdCard(fieldValue); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case "gender_m" -> { |
|
|
case "gender_m" -> { |
|
|
commonField.setGenderMale(fieldValue); |
|
|
commonField.setGenderMale(fieldValue); |
|
|
if("on".equals(fieldValue)) { |
|
|
if("on".equals(fieldValue)) { |
|
@@ -431,33 +664,47 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
case "edu_pri" -> commonField.setEduPri(fieldValue); |
|
|
case "edu_pri" -> commonField.setEduPri(fieldValue); |
|
|
case "edu_sec" -> commonField.setEduSec(fieldValue); |
|
|
case "edu_sec" -> commonField.setEduSec(fieldValue); |
|
|
case "edu_post_sec" -> commonField.setEduPostSec(fieldValue); |
|
|
case "edu_post_sec" -> commonField.setEduPostSec(fieldValue); |
|
|
|
|
|
|
|
|
|
|
|
/* Page1 End */ |
|
|
|
|
|
/* Page2 Start */ |
|
|
case "own_income" -> commonField.setOwn_income(fieldValue); |
|
|
case "own_income" -> commonField.setOwn_income(fieldValue); |
|
|
case "savings" -> commonField.setSavings(fieldValue); |
|
|
case "savings" -> commonField.setSavings(fieldValue); |
|
|
case "premium_financing" -> commonField.setPremium_financing(fieldValue); |
|
|
case "premium_financing" -> commonField.setPremium_financing(fieldValue); |
|
|
case "others_funds" -> commonField.setOthers_funds(fieldValue); |
|
|
case "others_funds" -> commonField.setOthers_funds(fieldValue); |
|
|
case "others_funds_desc" -> commonField.setOthers_funds_desc(fieldValue); |
|
|
case "others_funds_desc" -> commonField.setOthers_funds_desc(fieldValue); |
|
|
|
|
|
|
|
|
|
|
|
/* Page2 End */ |
|
|
|
|
|
/* Page3 Start */ |
|
|
|
|
|
case "fill_26_4" -> commonField.setFna_c1a_amount(fieldValue); |
|
|
|
|
|
/* Page3 End */ |
|
|
|
|
|
/* Page4 Start */ |
|
|
|
|
|
case "total_asset" -> commonField.setFna_c2a_amount(fieldValue); |
|
|
|
|
|
case "fill_56" -> commonField.setFna_c2b_amount(fieldValue); |
|
|
|
|
|
/* Page4 End */ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Special logic Start */ |
|
|
//test the concat |
|
|
//test the concat |
|
|
if( ("date_dd".equals(fieldName) || "date_mm".equals(fieldName) || "date_yyyy".equals(fieldName) ) |
|
|
if( ("date_dd".equals(fieldName) || "date_mm".equals(fieldName) || "date_yyyy".equals(fieldName) ) |
|
|
&& commonField.getDdDateOfBirth() != null && commonField.getMmDateOfBirth() != null && commonField.getYyyyDateOfBirth() != null ){ |
|
|
&& commonField.getDdDateOfBirth() != null && commonField.getMmDateOfBirth() != null && commonField.getYyyyDateOfBirth() != null ){ |
|
|
commonField.setDateOfBirth(commonField.getDdDateOfBirth() + "/" + commonField.getMmDateOfBirth() + "/" + commonField.getYyyyDateOfBirth()); |
|
|
commonField.setDateOfBirth(commonField.getDdDateOfBirth() + "/" + commonField.getMmDateOfBirth() + "/" + commonField.getYyyyDateOfBirth()); |
|
|
} |
|
|
} |
|
|
|
|
|
/* Special logic End */ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if("FNA".equals(formCode)){ |
|
|
if("FNA".equals(formCode)){ |
|
|
logger.info("FNA "); |
|
|
|
|
|
|
|
|
//logger.info("FNA "); |
|
|
|
|
|
|
|
|
switch (fieldName) { |
|
|
switch (fieldName) { |
|
|
|
|
|
/* Page1 Start */ |
|
|
case "fna_a_name" -> commonField.setName(fieldValue); |
|
|
case "fna_a_name" -> commonField.setName(fieldValue); |
|
|
case "fna_a_birth" -> commonField.setDateOfBirth(fieldValue); |
|
|
case "fna_a_birth" -> commonField.setDateOfBirth(fieldValue); |
|
|
case "fna_a_occupation" -> commonField.setOccupation(fieldValue); |
|
|
case "fna_a_occupation" -> commonField.setOccupation(fieldValue); |
|
|
|
|
|
|
|
|
|
|
|
case "fna_a_primary" -> commonField.setEduPri(fieldValue); |
|
|
|
|
|
case "fna_a_secondary" -> commonField.setEduSec(fieldValue); |
|
|
case "fna_a_tertiary" -> commonField.setEduTer(fieldValue); |
|
|
case "fna_a_tertiary" -> commonField.setEduTer(fieldValue); |
|
|
|
|
|
|
|
|
case "fna_a_marital" -> commonField.setMaritalStatus(fieldValue); |
|
|
case "fna_a_marital" -> commonField.setMaritalStatus(fieldValue); |
|
|
|
|
|
case "fna_a_contact" -> commonField.setContactNo(fieldValue); |
|
|
case "fna_a_dependents" -> commonField.setNoOfDependents(fieldValue); |
|
|
case "fna_a_dependents" -> commonField.setNoOfDependents(fieldValue); |
|
|
|
|
|
|
|
|
case "fna_c1a_amount" -> commonField.setFna_c1a_amount(fieldValue); |
|
|
case "fna_c1a_amount" -> commonField.setFna_c1a_amount(fieldValue); |
|
@@ -467,6 +714,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
case "fna_c1c_3_amount" -> commonField.setFna_c1c_3_amount(fieldValue); |
|
|
case "fna_c1c_3_amount" -> commonField.setFna_c1c_3_amount(fieldValue); |
|
|
case "fna_c1d_amount" -> commonField.setFna_c1d_amount(fieldValue); |
|
|
case "fna_c1d_amount" -> commonField.setFna_c1d_amount(fieldValue); |
|
|
case "fna_c2a_amount" -> commonField.setFna_c2a_amount(fieldValue); |
|
|
case "fna_c2a_amount" -> commonField.setFna_c2a_amount(fieldValue); |
|
|
|
|
|
|
|
|
case "fna_c2b_amount" -> commonField.setFna_c2b_amount(fieldValue); |
|
|
case "fna_c2b_amount" -> commonField.setFna_c2b_amount(fieldValue); |
|
|
case "fna_c2c_amount" -> commonField.setFna_c2c_amount(fieldValue); |
|
|
case "fna_c2c_amount" -> commonField.setFna_c2c_amount(fieldValue); |
|
|
case "fna_c2d_amount" -> commonField.setFna_c2d_amount(fieldValue); |
|
|
case "fna_c2d_amount" -> commonField.setFna_c2d_amount(fieldValue); |
|
@@ -479,6 +727,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
case "fna_b1_d" -> commonField.setFna_b1_d(fieldValue); |
|
|
case "fna_b1_d" -> commonField.setFna_b1_d(fieldValue); |
|
|
case "fna_b1_d_year" -> commonField.setFna_b1_d_year(fieldValue); |
|
|
case "fna_b1_d_year" -> commonField.setFna_b1_d_year(fieldValue); |
|
|
case "fna_b1_d_amount" -> commonField.setFna_b1_d_amount(fieldValue); |
|
|
case "fna_b1_d_amount" -> commonField.setFna_b1_d_amount(fieldValue); |
|
|
|
|
|
/* Page1 End */ |
|
|
|
|
|
/* Page2 Start */ |
|
|
case "fna_b1_e" -> commonField.setFna_b1_e(fieldValue); |
|
|
case "fna_b1_e" -> commonField.setFna_b1_e(fieldValue); |
|
|
case "fna_b1_f" -> commonField.setFna_b1_f(fieldValue); |
|
|
case "fna_b1_f" -> commonField.setFna_b1_f(fieldValue); |
|
|
case "fna_b1_f_other" -> commonField.setFna_b1_f_other(fieldValue); |
|
|
case "fna_b1_f_other" -> commonField.setFna_b1_f_other(fieldValue); |
|
@@ -490,6 +740,24 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
case "fna_b2_e" -> commonField.setFna_b2_e(fieldValue); |
|
|
case "fna_b2_e" -> commonField.setFna_b2_e(fieldValue); |
|
|
case "fna_b2_f" -> commonField.setFna_b2_f(fieldValue); |
|
|
case "fna_b2_f" -> commonField.setFna_b2_f(fieldValue); |
|
|
case "fna_b2_g" -> commonField.setFna_b2_g(fieldValue); |
|
|
case "fna_b2_g" -> commonField.setFna_b2_g(fieldValue); |
|
|
|
|
|
/* Page2 End */ |
|
|
|
|
|
/* Page3 Start */ |
|
|
|
|
|
case "fna_c1e_10" -> commonField.setFna_c1e_10(fieldValue); |
|
|
|
|
|
case "fna_c1e_10_20" -> commonField.setFna_c1e_10_20(fieldValue); |
|
|
|
|
|
case "fna_c1e_21_30" -> commonField.setFna_c1e_21_30(fieldValue); |
|
|
|
|
|
case "fna_c1e_31_40" -> commonField.setFna_c1e_31_40(fieldValue); |
|
|
|
|
|
case "fna_c1e_41_50" -> commonField.setFna_c1e_41_50(fieldValue); |
|
|
|
|
|
case "fna_c1e_50" -> commonField.setFna_c1e_50(fieldValue); |
|
|
|
|
|
/* Page3 End */ |
|
|
|
|
|
/* Page4 Start */ |
|
|
|
|
|
case "fna_c2f_10" -> commonField.setFna_c2f_10(fieldValue); |
|
|
|
|
|
case "fna_c2f_10_20" -> commonField.setFna_c2f_10_20(fieldValue); |
|
|
|
|
|
case "fna_c2f_21_30" -> commonField.setFna_c2f_21_30(fieldValue); |
|
|
|
|
|
case "fna_c2f_31_40" -> commonField.setFna_c2f_31_40(fieldValue); |
|
|
|
|
|
case "fna_c2f_41_50" -> commonField.setFna_c2f_41_50(fieldValue); |
|
|
|
|
|
case "fna_c2f_50" -> commonField.setFna_c2f_50(fieldValue); |
|
|
|
|
|
/* Page4 End */ |
|
|
|
|
|
/* Page5 End */ |
|
|
case "fna_c3a_2_5" -> commonField.setFna_c3a_2_5(fieldValue); |
|
|
case "fna_c3a_2_5" -> commonField.setFna_c3a_2_5(fieldValue); |
|
|
case "fna_c3a_6_10" -> commonField.setFna_c3a_6_10(fieldValue); |
|
|
case "fna_c3a_6_10" -> commonField.setFna_c3a_6_10(fieldValue); |
|
|
case "fna_c3a_11_15" -> commonField.setFna_c3a_11_15(fieldValue); |
|
|
case "fna_c3a_11_15" -> commonField.setFna_c3a_11_15(fieldValue); |
|
@@ -505,27 +773,16 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
case "fna_c3b_policy" -> commonField.setFna_c3b_policy(fieldValue); |
|
|
case "fna_c3b_policy" -> commonField.setFna_c3b_policy(fieldValue); |
|
|
case "fna_c3b_others" -> commonField.setFna_c3b_others(fieldValue); |
|
|
case "fna_c3b_others" -> commonField.setFna_c3b_others(fieldValue); |
|
|
case "fna_c3b_desc" -> commonField.setFna_c3b_desc(fieldValue); |
|
|
case "fna_c3b_desc" -> commonField.setFna_c3b_desc(fieldValue); |
|
|
case "fna_c1e_10" -> commonField.setFna_c1e_10(fieldValue); |
|
|
|
|
|
case "fna_c1e_10_20" -> commonField.setFna_c1e_10_20(fieldValue); |
|
|
|
|
|
case "fna_c1e_21_30" -> commonField.setFna_c1e_21_30(fieldValue); |
|
|
|
|
|
case "fna_c1e_31_40" -> commonField.setFna_c1e_31_40(fieldValue); |
|
|
|
|
|
case "fna_c1e_41_50" -> commonField.setFna_c1e_41_50(fieldValue); |
|
|
|
|
|
case "fna_c1e_50" -> commonField.setFna_c1e_50(fieldValue); |
|
|
|
|
|
case "fna_c2f_10" -> commonField.setFna_c2f_10(fieldValue); |
|
|
|
|
|
case "fna_c2f_10_20" -> commonField.setFna_c2f_10_20(fieldValue); |
|
|
|
|
|
case "fna_c2f_21_30" -> commonField.setFna_c2f_21_30(fieldValue); |
|
|
|
|
|
case "fna_c2f_31_40" -> commonField.setFna_c2f_31_40(fieldValue); |
|
|
|
|
|
case "fna_c2f_41_50" -> commonField.setFna_c2f_41_50(fieldValue); |
|
|
|
|
|
case "fna_c2f_50" -> commonField.setFna_c2f_50(fieldValue); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Page5 End */ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if("HSBCFIN".equals(formCode)){ |
|
|
if("HSBCFIN".equals(formCode)){ |
|
|
logger.info("HSBCFIN "); |
|
|
|
|
|
|
|
|
//logger.info("HSBCFIN "); |
|
|
|
|
|
|
|
|
switch (fieldName) { |
|
|
switch (fieldName) { |
|
|
|
|
|
/* Page1 Start */ |
|
|
case "fill_3" -> commonField.setName(fieldValue); |
|
|
case "fill_3" -> commonField.setName(fieldValue); |
|
|
case "fill_4" -> commonField.setNameChi(fieldValue); |
|
|
case "fill_4" -> commonField.setNameChi(fieldValue); |
|
|
case "fill_5" -> commonField.setGender(fieldValue); |
|
|
case "fill_5" -> commonField.setGender(fieldValue); |
|
@@ -554,19 +811,19 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
commonField.setFna_c1b_amount( String.valueOf(Math.round(NumberUtils.toDouble(fieldValue)/12)) ); |
|
|
commonField.setFna_c1b_amount( String.valueOf(Math.round(NumberUtils.toDouble(fieldValue)/12)) ); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case "fill_12a" -> commonField.setFna_c1c_3_amount(fieldValue); |
|
|
case "fill_12a" -> commonField.setFna_c1c_3_amount(fieldValue); |
|
|
case "fill_13" -> commonField.setFna_c1c_1_amount(fieldValue); |
|
|
case "fill_13" -> commonField.setFna_c1c_1_amount(fieldValue); |
|
|
case "fill_14" -> commonField.setFna_c1c_2_amount(fieldValue); |
|
|
case "fill_14" -> commonField.setFna_c1c_2_amount(fieldValue); |
|
|
|
|
|
|
|
|
case "fill_16" -> commonField.setFna_c1d_amount(fieldValue); |
|
|
case "fill_16" -> commonField.setFna_c1d_amount(fieldValue); |
|
|
|
|
|
|
|
|
|
|
|
/* Page1 End */ |
|
|
|
|
|
/* Page2 Start */ |
|
|
case "fill_01" -> commonField.setFna_c2a_amount(fieldValue); |
|
|
case "fill_01" -> commonField.setFna_c2a_amount(fieldValue); |
|
|
case "fill_02" -> commonField.setFna_c2b_amount(fieldValue); |
|
|
case "fill_02" -> commonField.setFna_c2b_amount(fieldValue); |
|
|
case "fill_03" -> commonField.setFna_c2c_amount(fieldValue); |
|
|
case "fill_03" -> commonField.setFna_c2c_amount(fieldValue); |
|
|
case "fill_04" -> commonField.setFna_c2d_amount(fieldValue); |
|
|
case "fill_04" -> commonField.setFna_c2d_amount(fieldValue); |
|
|
case "fill_05" -> commonField.setFna_c2e_amount(fieldValue); |
|
|
case "fill_05" -> commonField.setFna_c2e_amount(fieldValue); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case "Financial Protection" -> commonField.setFna_b1_a(fieldValue); |
|
|
case "Financial Protection" -> commonField.setFna_b1_a(fieldValue); |
|
|
case "Preparation" -> commonField.setFna_b1_b(fieldValue); |
|
|
case "Preparation" -> commonField.setFna_b1_b(fieldValue); |
|
|
case "Providing" -> commonField.setFna_b1_c(fieldValue); |
|
|
case "Providing" -> commonField.setFna_b1_c(fieldValue); |
|
@@ -575,21 +832,70 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
case "Others" -> commonField.setFna_b1_f(fieldValue); |
|
|
case "Others" -> commonField.setFna_b1_f(fieldValue); |
|
|
case "fill_8_2" -> commonField.setFna_b1_f_other(fieldValue); |
|
|
case "fill_8_2" -> commonField.setFna_b1_f_other(fieldValue); |
|
|
case "fill_8_21" -> commonField.setFna_b1_f_desc(fieldValue); |
|
|
case "fill_8_21" -> commonField.setFna_b1_f_desc(fieldValue); |
|
|
|
|
|
/* Page2 End */ |
|
|
|
|
|
/* Page3 Start */ |
|
|
|
|
|
case "toggle_91" -> commonField.setFna_b1_a(formCode); |
|
|
|
|
|
case "fill_1_4" -> commonField.setFna_b1_a_amount(formCode); |
|
|
|
|
|
case "fill_1_4b" -> commonField.setFna_b1_b(formCode); |
|
|
|
|
|
case "toggle_93" -> commonField.setFna_b1_d(formCode); |
|
|
|
|
|
case "fill_1_4c" -> commonField.setFna_b1_d_year(formCode); |
|
|
|
|
|
case "fill_1_4d" -> commonField.setFna_b1_d_year(formCode); |
|
|
|
|
|
case "fill_1_4e" -> commonField.setFna_b1_d_amount(formCode); |
|
|
|
|
|
|
|
|
|
|
|
case "toggle_4_2" -> commonField.setFna_b2_a(formCode); |
|
|
|
|
|
case "toggle_5" -> commonField.setFna_b2_b(formCode); |
|
|
|
|
|
case "toggle_6" -> commonField.setFna_b2_c(formCode); |
|
|
|
|
|
case "toggle_7" -> commonField.setFna_b2_d(formCode); |
|
|
|
|
|
case "toggle_8" -> commonField.setFna_b2_e(formCode); |
|
|
|
|
|
case "toggle_9" -> commonField.setFna_b2_f(formCode); |
|
|
|
|
|
case "toggle_10" -> commonField.setFna_b2_g(formCode); |
|
|
|
|
|
/* Page3 End */ |
|
|
|
|
|
/* Page4 Start */ |
|
|
|
|
|
case "toggle_1_2" -> commonField.setFna_c3a_2_5(formCode); |
|
|
|
|
|
case "toggle_2_2" -> commonField.setFna_c3a_6_10(formCode); |
|
|
|
|
|
case "toggle_3_2" -> commonField.setFna_c3a_11_15(formCode); |
|
|
|
|
|
case "toggle_4_3" -> commonField.setFna_c3a_16_20(formCode); |
|
|
|
|
|
case "toggle_5_2" -> commonField.setFna_c3a_20(formCode); |
|
|
|
|
|
case "toggle_6_2" -> commonField.setFna_c3a_life(fieldValue); |
|
|
|
|
|
case "toggle_6_2_sum" -> commonField.setFna_c3a_2_5(formCode); |
|
|
|
|
|
/* Page4 End */ |
|
|
|
|
|
/* Page5 Start */ |
|
|
|
|
|
case "toggle_1f" -> commonField.setFna_c3b_income(formCode); |
|
|
|
|
|
case "toggle_1g" -> commonField.setFna_c3b_saving(formCode); |
|
|
|
|
|
case "toggle_1h" -> commonField.setFna_c3b_policy(formCode); |
|
|
|
|
|
case "toggle_1i56" -> commonField.setFna_c3b_others(formCode); |
|
|
|
|
|
case "Text3" -> commonField.setFna_c3b_desc(formCode); |
|
|
|
|
|
|
|
|
|
|
|
case "Check Box6" -> commonField.setFna_c1e_10(formCode); |
|
|
|
|
|
case "Check Box7" -> commonField.setFna_c1e_10_20(formCode); |
|
|
|
|
|
case "Check Box8" -> commonField.setFna_c1e_21_30(formCode); |
|
|
|
|
|
case "Check Box9" -> commonField.setFna_c1e_31_40(formCode); |
|
|
|
|
|
case "Check Box10" -> commonField.setFna_c1e_41_50(formCode); |
|
|
|
|
|
case "Check Box11" -> commonField.setFna_c1e_50(formCode); |
|
|
|
|
|
|
|
|
|
|
|
case "Check Box12" -> commonField.setFna_c2f_10(formCode); |
|
|
|
|
|
case "Check Box13" -> commonField.setFna_c2f_10_20(formCode); |
|
|
|
|
|
case "Check Box14" -> commonField.setFna_c2f_21_30(formCode); |
|
|
|
|
|
case "Check Box15" -> commonField.setFna_c2f_31_40(formCode); |
|
|
|
|
|
case "Check Box16" -> commonField.setFna_c2f_41_50(formCode); |
|
|
|
|
|
case "Check Box17" -> commonField.setFna_c2f_50(formCode); |
|
|
|
|
|
/* Page5 End */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
logger.info("end Field: " + field.getPartialName() + ", Value: " + field.getValueAsString()); |
|
|
|
|
|
|
|
|
//logger.info("end Field: " + field.getPartialName() + ", Value: " + field.getValueAsString()); |
|
|
// You can save this data to a database, or perform other operations |
|
|
// You can save this data to a database, or perform other operations |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
commonFieldService.save(commonField); |
|
|
commonFieldService.save(commonField); |
|
|
} |
|
|
} |
|
|
logger.info("ended"); |
|
|
|
|
|
|
|
|
//logger.info("ended"); |
|
|
document.close(); |
|
|
document.close(); |
|
|
logger.info("closed"); |
|
|
|
|
|
|
|
|
//logger.info("closed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void setValueIfPresent(PdfAcroForm form, String fieldName, String value, String valueSource) { |
|
|
private void setValueIfPresent(PdfAcroForm form, String fieldName, String value, String valueSource) { |
|
|