Browse Source

no message

master
parent
commit
7d6e26d292
6 changed files with 133 additions and 13 deletions
  1. +23
    -1
      src/main/java/com/ffii/lioner/modules/lioner/client/entity/Client.java
  2. +21
    -0
      src/main/java/com/ffii/lioner/modules/lioner/client/req/UpdateClientReq.java
  3. +3
    -3
      src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfMergeService.java
  4. +62
    -4
      src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java
  5. +17
    -5
      src/main/java/com/ffii/lioner/modules/lioner/pdf/web/PdfController.java
  6. +7
    -0
      src/main/resources/db/changelog/changes/36_client_add_real_est.sql/01_add_field_real.sql

+ 23
- 1
src/main/java/com/ffii/lioner/modules/lioner/client/entity/Client.java View File

@@ -223,6 +223,12 @@ public class Client extends BaseEntity<Long>{
@Column
private String netBusinessInterestLast;

@Column
private String realEstateCurrent;

@Column
private String realEstateLast;

@Column
private String personalPropertiesCurrent;

@@ -804,7 +810,7 @@ public class Client extends BaseEntity<Long>{
public void setNetBusinessInterestLast(String netBusinessInterestLast) {
this.netBusinessInterestLast = netBusinessInterestLast;
}
public String getPersonalPropertiesCurrent() {
return personalPropertiesCurrent;
}
@@ -1204,5 +1210,21 @@ public class Client extends BaseEntity<Long>{
public void setPhone1Code(String phone1Code) {
this.phone1Code = phone1Code;
}

public String getRealEstateCurrent() {
return realEstateCurrent;
}

public void setRealEstateCurrent(String realEstateCurrent) {
this.realEstateCurrent = realEstateCurrent;
}

public String getRealEstateLast() {
return realEstateLast;
}

public void setRealEstateLast(String realEstateLast) {
this.realEstateLast = realEstateLast;
}
}


+ 21
- 0
src/main/java/com/ffii/lioner/modules/lioner/client/req/UpdateClientReq.java View File

@@ -2,6 +2,7 @@ package com.ffii.lioner.modules.lioner.client.req;

import java.time.LocalDate;

import jakarta.persistence.Column;
import jakarta.validation.constraints.Size;

public class UpdateClientReq {
@@ -152,6 +153,10 @@ public class UpdateClientReq {

String otherNonLiquidLast;

String realEstateCurrent;

String realEstateLast;

String personalLoansCurrent;

String personalLoansLast;
@@ -1084,5 +1089,21 @@ public class UpdateClientReq {
this.corAddressPostalCode = corAddressPostalCode;
}

public String getRealEstateCurrent() {
return realEstateCurrent;
}

public void setRealEstateCurrent(String realEstateCurrent) {
this.realEstateCurrent = realEstateCurrent;
}

public String getRealEstateLast() {
return realEstateLast;
}

public void setRealEstateLast(String realEstateLast) {
this.realEstateLast = realEstateLast;
}


}

+ 3
- 3
src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfMergeService.java View File

@@ -122,7 +122,7 @@ public class PdfMergeService {
final int MLFNA_REP_PAGE = 4;

final int SLFNA_REP_PAGE = 5;
final int SLAPP_REP_PAGE = 16;
final int SLAPP_REP_PAGE = 17;
final int SLGII_REP_PAGE = 13;

// --- STEP 1: Flatten PDF A and get the modified bytes ---
@@ -281,8 +281,8 @@ public class PdfMergeService {

// UPDATED CONSTANTS FOR NEW REQUIREMENTS
final int MLB03S_REP_PAGE_A = 13;
final int SLAPP_REP_START_A = 18;
final int SLAPP_REP_END_A = 19;
final int SLAPP_REP_START_A = 19;
final int SLAPP_REP_END_A = 20;
final int SLAPP_REP_COUNT_B = 2;
final int SLGII_REP_START_A = 15;
final int SLGII_REP_END_A = 16;


+ 62
- 4
src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java View File

@@ -21,6 +21,7 @@ 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;
@@ -391,7 +392,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
} else if("SLAPP".equals(formCode)){
SLAPP_checkBox(form2, commonField);
} else if("HSBCA31".equals(formCode)){
HSBCA31_checkBox(form2, commonField);
HSBCA31_checkBox(form2, commonField, client);
} else if ("SLGII".equals(formCode)) {
SLGII_checkBox(form2, commonField);
}
@@ -1182,6 +1183,15 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "email", commonField.getEmail());
setValueIfPresent(form, "occupation", commonField.getOccupationTitle());
*/
if(client != null && client.getConsultantId() != null){
Consultant consultant = consultantService.find(Long.valueOf(client.getConsultantId())).orElseThrow();

if(consultant.getName() != null){
setValueIfPresent(form, "s Names", consultant.getName());
}
}
setValueIfPresent(form, "Policy No", commonField.getOthers().get("SLAppPolicyNo"));
setValueIfPresent(form, "age", commonField.getOthers().get("SLAppAge"));

setValueIfPresent(form, "name", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
setValueIfPresent(form, "date_of_birth", commonField.getDateOfBirth());
@@ -1341,6 +1351,13 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

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

if(consultant.getName() != null){
setValueIfPresent(form, "inter1", consultant.getName());
}
}
setValueIfPresent(form, "1_1_surname", client.getLastname());
setValueIfPresent(form, "1_1_given_name", client.getFirstname());
@@ -1705,6 +1722,10 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "Text173_1", StringUtils.trimToNull(StringUtils.trimToEmpty(StringUtils.trimToEmpty(commonField.getOthers().get("empNatureA")) + " " + StringUtils.trimToEmpty(commonField.getOthers().get("empNatureB")))));
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())));
/* Page2 End */
/* Page3 Start */
//setValueIfPresent(form, "undefined_51", commonField.getContactNo());
@@ -1777,6 +1798,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

setValueIfPresent(form, "fill_4114", formatNum(client.getCashDepositsCurrent()));
setValueIfPresent(form, "fill_4215", formatNum(client.getCashDepositsLast()));
setValueIfPresent(form, "fill_4916", formatNum(client.getRealEstateCurrent()));
setValueIfPresent(form, "fill_5017", formatNum(client.getRealEstateLast()));
setValueIfPresent(form, "fill_5318", formatNum(client.getPersonalPropertiesCurrent()));
setValueIfPresent(form, "fill_5419", formatNum(client.getPersonalPropertiesLast()));
setValueIfPresent(form, "fill_5720", formatNum(client.getInvestmentsCurrent()));
@@ -1831,11 +1854,27 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
}

private void HSBCA31_checkBox(PDAcroForm form2, CommonField commonField){
private void HSBCA31_checkBox(PDAcroForm form2, CommonField commonField, Client client){
/* Page1 Start */
setValueIfPresent(form2, "Checkk Box6", commonField.getGenderMale());
setValueIfPresent(form2, "Check kBox7", commonField.getGenderFemale());

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

if(!"".equals(StringUtils.trimToEmpty(client.getPhone1Code()))){
if("852".equals(client.getPhone1Code()) || "+852".equals(client.getPhone1Code())){
setValueIfPresent(form2, "Check Box12_2", "Yes");
}else if("1".equals(client.getPhone1Code()) || "+1".equals(client.getPhone1Code())){
setValueIfPresent(form2, "Check Box13_2", "Yes");
}else if("86".equals(client.getPhone1Code()) || "+86".equals(client.getPhone1Code())){
setValueIfPresent(form2, "Check Box14_2", "Yes");
}else{
setValueIfPresent(form2, "Check Box15_2", "Yes");
}
}
if(form2.getField("Text1") != null && form2.getField("Text1").getValueAsString() != null && !form2.getField("Text1").getValueAsString().isBlank()
&& ("HK".equals(commonField.getCountryOfIssue().toUpperCase())
|| "HONG KONG".equals(commonField.getCountryOfIssue().toUpperCase())
@@ -1900,6 +1939,12 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "Check Box74", commonField.getOthers().get("formMedical"));
setValueIfPresent(form2, "Check Box75", commonField.getOthers().get("formNonMedical"));
/* Page7 End */
/* Page8 Start */
if("Yes".equals(commonField.getFna_c3a_single_pay())){
setValueIfPresent(form2, "Check Box1a01", "Yes");
}
/* Page8 End */
/* Page9 Start */
setValueIfPresent(form2, "Check Box72_1a", commonField.getOthers().get("appyOtherInsuranceYes"));
setValueIfPresent(form2, "Check Box73_1", commonField.getOthers().get("appyOtherInsuranceNo"));
@@ -2363,8 +2408,10 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

setValueIfPresent(form, "7_2c_cash", formatNum(client.getCashDepositsCurrent()));
setValueIfPresent(form, "7_2c_cash_24", formatNum(client.getCashDepositsLast()));
setValueIfPresent(form, "7_2c_real", formatNum(client.getPersonalPropertiesCurrent()));
setValueIfPresent(form, "7_2c_real_24", formatNum(client.getPersonalPropertiesLast()));
setValueIfPresent(form, "7_2c_high", formatNum(client.getPersonalPropertiesCurrent()));
setValueIfPresent(form, "7_2c_high_24", formatNum(client.getPersonalPropertiesLast()));
setValueIfPresent(form, "7_2c_real", formatNum(client.getRealEstateCurrent()));
setValueIfPresent(form, "7_2c_real_24", formatNum(client.getRealEstateLast()));
setValueIfPresent(form, "7_2c_stocks", formatNum(client.getInvestmentsCurrent()));
setValueIfPresent(form, "7_2c_stocks_24", formatNum(client.getInvestmentsLast()));
setValueIfPresent(form, "7_2c_business", formatNum(client.getNetBusinessInterestCurrent()));
@@ -3631,6 +3678,9 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void SLAPP(String fieldName, String fieldValue, CommonField commonField,PDAcroForm acroForm){
switch (fieldName) {
/* Page1 Start */
case "policyNo" -> commonField.getOthers().put("SLAppPolicyNo", "611" + fieldValue);
case "1_6_last" -> commonField.getOthers().put("SLAppAge", fieldValue);

case "1_2_name_ch" -> commonField.setNameChi(fieldValue);
case "ch1_4_m" -> commonField.setGenderMale(fieldValue);
@@ -4579,6 +4629,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
+ " ff.remarks, "
+ " f.filename, "
+ " c.clientCode, "
+ " c.lastname, "
+ " c.firstname, "
+ " t.name as templateName, "
+ " t.remarks AS formCode, "
+ " fb.bytes AS blobValue "
@@ -4621,6 +4673,9 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressCity()))){
value += StringUtils.trimToEmpty(client.getCrAddressCity()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressPostalCode()))){
value += StringUtils.trimToEmpty(client.getCrAddressPostalCode()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressCountry()))){
value += StringUtils.trimToEmpty(client.getCrAddressCountry()) + " ";
}
@@ -4655,6 +4710,9 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
if(!"".equals(StringUtils.trimToEmpty(client.getCorAddressCity()))){
value += StringUtils.trimToEmpty(client.getCorAddressCity()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCorAddressPostalCode()))){
value += StringUtils.trimToEmpty(client.getCorAddressPostalCode()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCorAddressCountry()))){
value += StringUtils.trimToEmpty(client.getCorAddressCountry()) + " ";
}


+ 17
- 5
src/main/java/com/ffii/lioner/modules/lioner/pdf/web/PdfController.java View File

@@ -29,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
import com.ffii.core.response.RecordsRes;
import com.ffii.core.utils.CriteriaArgsBuilder;
import com.ffii.core.utils.Params;
import com.ffii.core.utils.StringUtils;
import com.ffii.lioner.modules.lioner.entity.FileBlob;
import com.ffii.lioner.modules.lioner.pdf.service.PdfMergeService;
import com.ffii.lioner.modules.lioner.pdf.service.PdfService;
@@ -156,8 +157,12 @@ public class PdfController {
logger.info("XXXXXXXXXXXXXXX getFlatPdfByFilledFormId START XXXXXXXXXXXXXX");
// --- 1. Fetch Data & Set up Variables ---
Map<String, Object> d = pdfService.getFilledFormPdf(id);
String formCode = (String) d.get("formCode");
String filename = formCode + "-" + id + ".pdf";
String templateName = (String) d.get("templateName");
String lastname = StringUtils.trimToEmpty((String) d.get("lastname"));
String firstname = StringUtils.trimToEmpty((String) d.get("firstname"));
lastname = lastname.replaceAll("\\s+", "");
firstname = firstname.replaceAll("\\s+", "");
String filename = lastname + firstname + "-" + templateName + ".pdf";

Long fileId = Optional.ofNullable(d.get("fileId"))
.map(val -> ((Integer) val).longValue())
@@ -179,7 +184,8 @@ public class PdfController {
// --- 4. Build ResponseEntity ---
HttpHeaders headers = new HttpHeaders();
// Use attachment for download, or inline for display in browser
headers.setContentDispositionFormData("attachment", filename);
headers.add("Access-Control-Expose-Headers", "Content-Disposition");
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"");
headers.setContentType(MediaType.APPLICATION_PDF);
headers.setContentLength(finalPdfBytes.length);

@@ -233,7 +239,12 @@ public class PdfController {
// --- 1. Fetch Data & Set up Variables ---
Map<String, Object> d = pdfService.getFilledFormPdf(id);
String formCode = (String) d.get("formCode");
String filename = formCode + "-" + id + ".pdf";
String templateName = (String) d.get("templateName");
String lastname = StringUtils.trimToEmpty((String) d.get("lastname"));
String firstname = StringUtils.trimToEmpty((String) d.get("firstname"));
lastname = lastname.replaceAll("\\s+", "");
firstname = firstname.replaceAll("\\s+", "");
String filename = lastname + firstname + "-" + templateName + ".pdf";

Long fileId = Optional.ofNullable(d.get("fileId"))
.map(val -> ((Integer) val).longValue())
@@ -286,7 +297,8 @@ public class PdfController {
// --- 4. Build ResponseEntity ---
HttpHeaders headers = new HttpHeaders();
// Use attachment for download, or inline for display in browser
headers.setContentDispositionFormData("attachment", filename);
headers.add("Access-Control-Expose-Headers", "Content-Disposition");
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"");
headers.setContentType(MediaType.APPLICATION_PDF);
headers.setContentLength(finalPdfBytes.length);



+ 7
- 0
src/main/resources/db/changelog/changes/36_client_add_real_est.sql/01_add_field_real.sql View File

@@ -0,0 +1,7 @@
--liquibase formatted sql

--changeset vin:add realEstate

ALTER TABLE `lionerdb`.`client`
ADD COLUMN `realEstateCurrent` VARCHAR(30) NULL AFTER `corAddressPostalCode`,
ADD COLUMN `realEstateLast` VARCHAR(30) NULL AFTER `realEstateCurrent`;

Loading…
Cancel
Save