浏览代码

no message

master
父节点
当前提交
ee183a8e48
共有 3 个文件被更改,包括 62 次插入25 次删除
  1. +9
    -2
      src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfMergeService.java
  2. +51
    -23
      src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java
  3. +2
    -0
      src/main/java/com/ffii/lioner/modules/lioner/pdf/web/PdfController.java

+ 9
- 2
src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfMergeService.java 查看文件

@@ -280,7 +280,9 @@ public class PdfMergeService {
public byte[] mergePdf2sItext7(String formCode, byte[] pdfABytes, byte[] pdfBBytes) throws IOException {

// UPDATED CONSTANTS FOR NEW REQUIREMENTS
final int MLB03S_REP_PAGE_A = 13;
final int MLB03S_REP_START_A = 12;
final int MLB03S_REP_END_A = 13;
final int MLB03S_REP_COUNT_B = 2;
final int SLAPP_REP_START_A = 19;
final int SLAPP_REP_END_A = 20;
final int SLAPP_REP_COUNT_B = 2;
@@ -339,6 +341,10 @@ public class PdfMergeService {
repStartA = SLGII_REP_START_A;
repEndA = SLGII_REP_END_A;
repCountB = SLGII_REP_COUNT_B;
} else if ("MLB03S".equals(formCode)) {
repStartA = MLB03S_REP_START_A;
repEndA = MLB03S_REP_END_A;
repCountB = MLB03S_REP_COUNT_B;
}

if (repStartA != -1 && totalPagesA >= repEndA) {
@@ -368,6 +374,7 @@ public class PdfMergeService {
}
// --- Single Page Replacement Forms (MLB03S) ---
/*
} else if ("MLB03S".equals(formCode) && totalPagesA >= MLB03S_REP_PAGE_A) {
// A. Copy pages 1 up to 11 (MLB03S_REP_PAGE_A - 1)
@@ -391,7 +398,7 @@ public class PdfMergeService {
if (totalPagesA > MLB03S_REP_PAGE_A) {
merger.merge(docA, MLB03S_REP_PAGE_A + 1, totalPagesA);
}
*/
} else {
// Default: Copy all pages from docA
merger.merge(docA, 1, totalPagesA);


+ 51
- 23
src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java 查看文件

@@ -21,7 +21,6 @@ import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
import org.apache.pdfbox.pdmodel.interactive.form.PDButton;
import org.apache.pdfbox.pdmodel.interactive.form.PDField;
import org.checkerframework.checker.units.qual.s;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@@ -1726,8 +1725,24 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "fill_16_2", commonField.getOthers().get("empPosition"));
setValueIfPresent(form, "fill_17_1", commonField.getOthers().get("empCompanyAddress"));

setValueIfPresent(form, "fill_17_3", StringUtils.trimToEmpty(StringUtils.trimToEmpty(commonField.getTaxPin1()) + StringUtils.trimToEmpty(commonField.getTaxPin2()) + StringUtils.trimToEmpty(commonField.getTaxPin3())));
setValueIfPresent(form, "fill_0004", StringUtils.trimToEmpty(StringUtils.trimToEmpty(commonField.getTaxResidency1()) + StringUtils.trimToEmpty(commonField.getTaxResidency2()) + StringUtils.trimToEmpty(commonField.getTaxResidency3())));
String taxId = "";
String taxCountry = "";

if(!"".equals(StringUtils.trimToEmpty(commonField.getTaxPin1()))){
taxId += StringUtils.trimToEmpty(commonField.getTaxPin1()) + " ";
taxCountry += StringUtils.trimToEmpty(commonField.getTaxResidency1()) + "";
}
if(!"".equals(StringUtils.trimToEmpty(commonField.getTaxPin2()))){
taxId += StringUtils.trimToEmpty(commonField.getTaxPin2()) + " ";
taxCountry += StringUtils.trimToEmpty(commonField.getTaxResidency2()) + "";
}
if(!"".equals(StringUtils.trimToEmpty(commonField.getTaxPin3()))){
taxId += StringUtils.trimToEmpty(commonField.getTaxPin3()) + " ";
taxCountry += StringUtils.trimToEmpty(commonField.getTaxResidency3()) + "";
}

setValueIfPresent(form, "fill_17_3", StringUtils.trimToEmpty(taxId));
setValueIfPresent(form, "fill_0004", StringUtils.trimToEmpty(taxCountry));
/* Page2 End */
/* Page3 Start */
@@ -1862,7 +1877,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "Checkk Box6", commonField.getGenderMale());
setValueIfPresent(form2, "Check kBox7", commonField.getGenderFemale());

if(!"".equals(client.getCrAddressPostalCode())){
if(!"".equals(client.getCrAddressCity())){
setValueIfPresent(form2, "Check Box10", "Yes");
}

@@ -1997,7 +2012,15 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
}

private void MLB03S_textBox(PdfAcroForm form, CommonField commonField, Client client){
/* Page1 Start */
/* Page1 Start */
if(client != null && client.getConsultantId() != null){
Consultant consultant = consultantService.find(Long.valueOf(client.getConsultantId())).orElseThrow();

if(consultant.getName() != null){
setValueIfPresent(form, "BranchName", consultant.getName());
}
}

setValueIfPresent(form, "SurName1", StringUtils.trimToEmpty(client.getLastname()));
setValueIfPresent(form, "GivenName1", StringUtils.trimToEmpty(client.getFirstname()));

@@ -2080,26 +2103,31 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "male", commonField.getGenderMale());
setValueIfPresent(form2, "female", commonField.getGenderFemale());
if("HONG KONG".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "HK".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "HONGKONG".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "HK SAR".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "HKSAR".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "香港".equals(commonField.getPlaceOfBirth().toUpperCase())){
setValueIfPresent(form2, "hk", "Yes");
}
if("HONG KONG".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "MACAU".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "澳門".equals(commonField.getPlaceOfBirth().toUpperCase())){
setValueIfPresent(form2, "macau", "Yes");
if(!"".equals(StringUtils.trimToEmpty(commonField.getPlaceOfBirth()))
|| !"".equals(commonField.getCountryOfCitizenship())){
if("HONG KONG".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "HK".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "HONGKONG".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "HK SAR".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "HKSAR".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "香港".equals(commonField.getPlaceOfBirth().toUpperCase())){
setValueIfPresent(form2, "hk", "Yes");
}else if("MACAU".equals(commonField.getPlaceOfBirth().toUpperCase())
|| "澳門".equals(commonField.getPlaceOfBirth().toUpperCase())){
setValueIfPresent(form2, "macau", "Yes");
}else{
setValueIfPresent(form2, "Checkbox_Location1", "Yes");
}
}

setValueIfPresent(form2, "Checkbox_ID11", commonField.getOthers().get("hkidPerm"));
setValueIfPresent(form2, "Checkbox_ID12", commonField.getOthers().get("hkidNon"));
logger.info("##### prcId:" +commonField.getOthers().get("prcId"));
setValueIfPresent(form2, "Checkbox_ID14", commonField.getOthers().get("prcId"));
setValueIfPresent(form2, "Checkbox_ID16", commonField.getOthers().get("passportYes"));
setValueIfPresent(form2, "Checkbox_ID17", commonField.getOthers().get("othersId"));
if(!"Yes".equals(commonField.getOthers().get("hkidPerm"))){
setValueIfPresent(form2, "Checkbox_ID12", commonField.getOthers().get("hkidNon"));
setValueIfPresent(form2, "Checkbox_ID14", commonField.getOthers().get("prcId"));
setValueIfPresent(form2, "Checkbox_ID16", commonField.getOthers().get("passportYes"));
setValueIfPresent(form2, "Checkbox_ID17", commonField.getOthers().get("othersId"));
}
setValueIfPresent(form2, "Checkbox_Y", commonField.getTobarccoYes());
setValueIfPresent(form2, "Checkbox_N", commonField.getTobarccoNo());
@@ -3044,8 +3072,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "fill_10_7" -> commonField.getOthers().put("replaceInsuranceDesc", fieldValue);
/* Page7 End */
/* Page8 Start */
case "toggle_1_4" -> commonField.getOthers().put("usPerson", fieldValue);
case "toggle_2_3" -> commonField.getOthers().put("usPersonNot", fieldValue);
case "toggle_2_3" -> commonField.getOthers().put("usPerson", fieldValue);
case "toggle_1_4" -> commonField.getOthers().put("usPersonNot", fieldValue);
case "employed" -> commonField.setEmployed(fieldValue);
case "homemaker" -> commonField.setHomemaker(fieldValue);


+ 2
- 0
src/main/java/com/ffii/lioner/modules/lioner/pdf/web/PdfController.java 查看文件

@@ -244,6 +244,8 @@ public class PdfController {
String firstname = StringUtils.trimToEmpty((String) d.get("firstname"));
lastname = lastname.replaceAll("\\s+", "");
firstname = firstname.replaceAll("\\s+", "");
lastname = lastname.replaceAll("[^a-zA-Z0-9]", "");
firstname = firstname.replaceAll("[^a-zA-Z0-9]", "");
String filename = lastname + firstname + "-" + templateName + ".pdf";

Long fileId = Optional.ofNullable(d.get("fileId"))


正在加载...
取消
保存