| @@ -28,8 +28,11 @@ import com.ffii.core.support.AbstractBaseEntityService; | |||||
| import com.ffii.core.support.JdbcDao; | import com.ffii.core.support.JdbcDao; | ||||
| import com.ffii.core.utils.BeanUtils; | import com.ffii.core.utils.BeanUtils; | ||||
| import com.ffii.lioner.modules.common.service.AuditLogService; | import com.ffii.lioner.modules.common.service.AuditLogService; | ||||
| import com.ffii.lioner.modules.lioner.client.entity.Client; | |||||
| import com.ffii.lioner.modules.lioner.client.service.ClientService; | |||||
| import com.ffii.lioner.modules.lioner.commonField.entity.CommonField; | import com.ffii.lioner.modules.lioner.commonField.entity.CommonField; | ||||
| import com.ffii.lioner.modules.lioner.commonField.service.CommonFieldService; | import com.ffii.lioner.modules.lioner.commonField.service.CommonFieldService; | ||||
| import com.ffii.lioner.modules.lioner.pdf.entity.Consultant; | |||||
| import com.ffii.lioner.modules.lioner.pdf.entity.Pdf; | import com.ffii.lioner.modules.lioner.pdf.entity.Pdf; | ||||
| import com.ffii.lioner.modules.lioner.pdf.entity.PdfRepository; | import com.ffii.lioner.modules.lioner.pdf.entity.PdfRepository; | ||||
| import com.ffii.lioner.modules.lioner.pdf.req.UpdatePdfReq; | import com.ffii.lioner.modules.lioner.pdf.req.UpdatePdfReq; | ||||
| @@ -54,13 +57,17 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||||
| private FileService fileService; | private FileService fileService; | ||||
| private TemplateService templateService; | private TemplateService templateService; | ||||
| private CommonFieldService commonFieldService; | private CommonFieldService commonFieldService; | ||||
| private ClientService clientService; | |||||
| private ConsultantService consultantService; | |||||
| public PdfService(JdbcDao jdbcDao, PdfRepository repository, AuditLogService auditLogService, FileService fileService, | public PdfService(JdbcDao jdbcDao, PdfRepository repository, AuditLogService auditLogService, FileService fileService, | ||||
| TemplateService templateService, CommonFieldService commonFieldService) { | |||||
| TemplateService templateService, ClientService clientService, ConsultantService consultantService, CommonFieldService commonFieldService) { | |||||
| super(jdbcDao, repository); | super(jdbcDao, repository); | ||||
| this.auditLogService = auditLogService; | this.auditLogService = auditLogService; | ||||
| this.fileService = fileService; | this.fileService = fileService; | ||||
| this.templateService = templateService; | this.templateService = templateService; | ||||
| this.clientService = clientService; | |||||
| this.consultantService = consultantService; | |||||
| this.commonFieldService = commonFieldService; | this.commonFieldService = commonFieldService; | ||||
| } | } | ||||
| @@ -221,6 +228,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||||
| if (sourcePdf == null) { sourcePdf = template; } | if (sourcePdf == null) { sourcePdf = template; } | ||||
| byte[] sourcePdfBytes = (byte[])sourcePdf.get("blobValue"); | byte[] sourcePdfBytes = (byte[])sourcePdf.get("blobValue"); | ||||
| String formCode = (String)template.get("remarks"); | String formCode = (String)template.get("remarks"); | ||||
| Client client = clientService.find(clientId).orElseThrow(); | |||||
| //byte[] modifiedPdfBytes = pdfBytes; | //byte[] modifiedPdfBytes = pdfBytes; | ||||
| @@ -331,6 +339,16 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||||
| setValueIfPresent(form, "fill_56", commonField.getFna_c2b_amount()); | setValueIfPresent(form, "fill_56", commonField.getFna_c2b_amount()); | ||||
| /* Page9 End */ | /* Page9 End */ | ||||
| if(client != null && client.getConsultantId() != null){ | |||||
| Consultant consultant = consultantService.find(Long.valueOf(client.getConsultantId())).orElseThrow(); | |||||
| if(consultant.getName() != null){ | |||||
| setValueIfPresent(form, "Name of Appointed Representative", consultant.getName()); | |||||
| } | |||||
| } | |||||
| setValueIfPresent(form, "Name of Client", commonField.getName()); | |||||
| } 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 */ | /* Page1 Start */ | ||||
| @@ -386,6 +404,18 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||||
| /* Page6 Start */ | /* Page6 Start */ | ||||
| setValueIfPresent(form, "fna_d_desc", commonField.getFna_d_desc()); | setValueIfPresent(form, "fna_d_desc", commonField.getFna_d_desc()); | ||||
| /* Page6 End */ | /* Page6 End */ | ||||
| if(client != null && client.getConsultantId() != null){ | |||||
| Consultant consultant = consultantService.find(Long.valueOf(client.getConsultantId())).orElseThrow(); | |||||
| if(consultant.getName() != null){ | |||||
| setValueIfPresent(form, "fna_name_intermediary", consultant.getName()); | |||||
| } | |||||
| } | |||||
| setValueIfPresent(form, "fna_name_policyowner", commonField.getName()); | |||||
| } 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 */ | /* Page1 Start */ | ||||
| @@ -438,6 +468,15 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||||
| /* Page5 End */ | /* Page5 End */ | ||||
| if(client != null && client.getConsultantId() != null){ | |||||
| Consultant consultant = consultantService.find(Long.valueOf(client.getConsultantId())).orElseThrow(); | |||||
| if(consultant.getName() != null){ | |||||
| setValueIfPresent(form, "undefined_6", consultant.getName()); | |||||
| } | |||||
| } | |||||
| setValueIfPresent(form, "fill_1_2", commonField.getName()); | |||||
| } else if("MLFNA_EN".equals(formCode)){ // This is ML FNA EN | } else if("MLFNA_EN".equals(formCode)){ // This is ML FNA EN | ||||
| /* | /* | ||||
| * /* Page1 Start */ | * /* Page1 Start */ | ||||
| @@ -459,6 +498,16 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||||
| /* Page3 Start */ | /* Page3 Start */ | ||||
| /* Page3 End */ | /* Page3 End */ | ||||
| if(client != null && client.getConsultantId() != null){ | |||||
| Consultant consultant = consultantService.find(Long.valueOf(client.getConsultantId())).orElseThrow(); | |||||
| if(consultant.getName() != null){ | |||||
| setValueIfPresent(form, "Full Name of Advisor", consultant.getName()); | |||||
| } | |||||
| } | |||||
| setValueIfPresent(form, "Full Name of Applicants", commonField.getName()); | |||||
| } else if("SLFNA_EN".equals(formCode)){ // This is SL FNA EN | } else if("SLFNA_EN".equals(formCode)){ // This is SL FNA EN | ||||
| /* | /* | ||||
| @@ -509,6 +558,16 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||||
| } | } | ||||
| /* special fields end */ | /* special fields end */ | ||||
| if(client != null && client.getConsultantId() != null){ | |||||
| Consultant consultant = consultantService.find(Long.valueOf(client.getConsultantId())).orElseThrow(); | |||||
| if(consultant.getName() != null){ | |||||
| setValueIfPresent(form, "consultant_name_and_num", consultant.getName()); | |||||
| } | |||||
| } | |||||
| setValueIfPresent(form, "applicant_name", commonField.getName()); | |||||
| } | } | ||||