package com.fjhx.sale.service.sample.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.account.entity.account.po.AccountManagement;
import com.fjhx.account.service.account.AccountManagementService;
import com.fjhx.area.utils.CustomizeAreaUtil;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.common.entity.contract.po.ContractTemplate;
import com.fjhx.common.entity.corporation.po.Corporation;
import com.fjhx.common.enums.FlowStatusEnum1;
import com.fjhx.common.service.contract.ContractTemplateService;
import com.fjhx.common.service.corporation.CorporationService;
import com.fjhx.common.utils.Assert;
import com.fjhx.customer.entity.customer.po.Customer;
import com.fjhx.customer.service.customer.CustomerService;
import com.fjhx.file.entity.FileInfoVo;
import com.fjhx.file.utils.ObsFileUtil;
import com.fjhx.item.entity.product.po.ProductInfo;
import com.fjhx.item.service.product.ProductInfoService;
import com.fjhx.mail.entity.enterprise.po.EnterpriseDomain;
import com.fjhx.mail.entity.enterprise.po.EnterpriseMailbox;
import com.fjhx.mail.entity.personal.po.PersonalMailbox;
import com.fjhx.mail.service.enterprise.EnterpriseDomainService;
import com.fjhx.mail.service.enterprise.EnterpriseMailboxService;
import com.fjhx.mail.service.personal.PersonalMailboxService;
import com.fjhx.sale.entity.contract.vo.ContractProductVo;
import com.fjhx.sale.entity.sample.dto.SampleDto;
import com.fjhx.sale.entity.sample.dto.SampleSelectDto;
import com.fjhx.sale.entity.sample.po.Sample;
import com.fjhx.sale.entity.sample.po.SampleProduct;
import com.fjhx.sale.entity.sample.po.SampleProject;
import com.fjhx.sale.entity.sample.po.SampleShipment;
import com.fjhx.sale.entity.sample.vo.SamplePdfInfoVo;
import com.fjhx.sale.entity.sample.vo.SampleShipmentVo;
import com.fjhx.sale.entity.sample.vo.SampleVo;
import com.fjhx.sale.mapper.sample.SampleMapper;
import com.fjhx.sale.service.sample.SampleProductService;
import com.fjhx.sale.service.sample.SampleProjectService;
import com.fjhx.sale.service.sample.SampleService;
import com.fjhx.sale.service.sample.SampleShipmentService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.ruoyi.framework.config.ThreadPoolConfig;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.utils.UserUtil;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;


/**
 * <p>
 * 样品单表 服务实现类
 * </p>
 *
 * @author
 * @since 2023-05-05
 */
@Service
public class SampleServiceImpl extends ServiceImpl<SampleMapper, Sample> implements SampleService {

    @Qualifier(ThreadPoolConfig.threadPoolTaskExecutor)
    @Autowired
    private ThreadPoolExecutor threadPoolExecutor;


    @Autowired
    private CustomerService customerService;

    @Autowired
    private ProductInfoService productInfoService;
    @Autowired
    private ISysUserService userService;

    @Autowired
    private CorporationService corporationService;
    @Autowired
    private SampleProductService sampleProductService;
    @Autowired
    private SampleProjectService sampleProjectService;
    @Autowired
    private AccountManagementService accountManagementService;
    @Autowired
    private PersonalMailboxService personalMailboxService;
    @Autowired
    private EnterpriseMailboxService enterpriseMailboxService;
    @Autowired
    private EnterpriseDomainService enterpriseDomainService;
    @Autowired
    private SampleShipmentService sampleShipmentService;
    @Autowired
    private ContractTemplateService contractTemplateService;


    /**
     * 分页
     *
     * @param dto
     * @return
     */
    @Override
    public Page<SampleVo> getPage(SampleSelectDto dto) {
        IWrapper<Sample> wrapper = getWrapper();
        wrapper.orderByDesc("t1", Sample::getCreateTime);
        wrapper.between("t1", Sample::getStatus, FlowStatusEnum1.DRAFT.getKey(), FlowStatusEnum1.CANCELLATION.getKey() - 1);
        if (StringUtils.isNotEmpty(dto.getStatus())) {
            wrapper.eq("t1", Sample::getStatus, dto.getStatus());
        }
        if (StringUtils.isNotEmpty(dto.getKeyword())) {
            List<Long> customerIds = customerService.listObject(Customer::getId, q -> q.like(Customer::getName, dto.getKeyword()));
            wrapper.and(q -> q
                    .like("t1", Sample::getCode, dto.getKeyword())
                    .or().in("t1", Sample::getBuyCorporationId, customerIds)
            );
        }
        Page<SampleVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        List<SampleVo> list = page.getRecords();
        if (CollectionUtils.isNotEmpty(list)) {
            List<Long> customerIds = list.stream().map(Sample::getBuyCorporationId).collect(Collectors.toList());
            List<Customer> customerList = customerService.list(Wrappers.<Customer>query().lambda().in(Customer::getId, customerIds));
            Map<Long, List<Customer>> cusMap = customerList.stream().distinct().collect(Collectors.groupingBy(Customer::getId));

            List<Long> ids = list.stream().map(sampleVo -> sampleVo.getId()).collect(Collectors.toList());
            //获取交接单附件
            Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(ids, 1);

            //获取包装附件
            Map<Long, List<FileInfoVo>> packageFileMap = ObsFileUtil.getFileMap(ids, 2);

            for (SampleVo p : list) {
                if (MapUtils.isNotEmpty(cusMap)) {//客户
                    List<Customer> customers = cusMap.getOrDefault(p.getBuyCorporationId(), null);
                    p.setBuyCorporationName(customers == null ? null : customers.get(0).getName());
                    //赋值客户标签
                    p.setTag(customers == null ? null : customers.get(0).getTag());
                }

                //赋值交接单附件
                if (MapUtils.isNotEmpty(fileMap)) {
                    List<FileInfoVo> fileInfoVos = fileMap.get(p.getId());
                    p.setFileInfoVos(fileInfoVos);
                }

                //赋值包装附件信息
                if (MapUtils.isNotEmpty(packageFileMap)) {
                    List<FileInfoVo> packageFileInfoVOList = packageFileMap.get(p.getId());
                    p.setPackageFileInfoVOList(packageFileInfoVOList);
                }

            }


        }


        return page;
    }

    @Override
    public SampleVo detail(Long id) {
        Sample Sample = this.getById(id);
        SampleVo result = BeanUtil.toBean(Sample, SampleVo.class);
        //赋值模板名称
        ContractTemplate contractTemplate = contractTemplateService.getById(result.getContractTemplateId());
        if(ObjectUtil.isNotEmpty(contractTemplate)) {
            result.setContractTemplateName(contractTemplate.getTemplateName());
        }
        // 卖方信息
        Corporation corporation = corporationService.getById(result.getSellCorporationId());
        if (ObjectUtil.isNotEmpty(corporation)) {
            result.setSellCorporationName(corporation.getName());
        }
        //买方信息
        Customer customer = customerService.getById(result.getBuyCorporationId());
        if (ObjectUtil.isNotEmpty(corporation)) {
            result.setSellCorporationName(corporation.getName());
            result.setBuyCorporationName(customer.getName());
        }
        //买方地址信息
        List<Long> areaIdList = Arrays.asList(result.getBuyCountryId(), result.getBuyProvinceId(), result.getBuyCityId());
        Map<Long, String> areaMap = CustomizeAreaUtil.getAreaMapByIds(areaIdList);
        result.setBuyCountryName(areaMap.get(result.getBuyCountryId()));
        result.setBuyProvinceName(areaMap.get(result.getBuyProvinceId()));
        result.setBuyCityName(areaMap.get(result.getBuyCityId()));
        //赋值收款账号
        AccountManagement accountManagement = accountManagementService.getById(result.getShroffAccountId());
        if(ObjectUtil.isNotEmpty(accountManagement)){
            result.setShroffAccountName(accountManagement.getName());
        }

        //赋值产品信息
        List<SampleProduct> sampleProductList = sampleProductService.list(q -> q.eq(SampleProduct::getSampleId, result.getId()));
        result.setSampleProductList(sampleProductList);
        //赋值其他费用
        List<SampleProject> sampleProjectList = sampleProjectService.list(q -> q.eq(SampleProject::getSampleId, result.getId()));
        result.setSampleProjectList(sampleProjectList);
        //赋值出货信息
        List<SampleShipment> sampleShipmentList = sampleShipmentService.list(q -> q.eq(SampleShipment::getSampleId, result.getId()));
        List<SampleShipmentVo> sampleShipmentVos = BeanUtil.copyToList(sampleShipmentList, SampleShipmentVo.class);
        productInfoService.attributeAssign(sampleShipmentVos,SampleShipmentVo::getProductId, (item, productInfo) -> {
            item.setProductCode(productInfo.getCode());
            item.setProductName(productInfo.getName());
        });
        result.setSampleShipmentLists(sampleShipmentVos);
        return result;
    }

    @Override
    public void add(SampleDto sampleDto) {
        this.save(sampleDto);
    }

    @Override
    public void edit(SampleDto sampleDto) {
        this.updateById(sampleDto);
    }

    @Override
    public void delete(Long id) {
        this.removeById(id);
    }

    /**
     * 样品交接单(类型1 为交接单，2为包装指示)
     */
    @Override
    public void sampleHandover(SampleDto dto) {
        ObsFileUtil.editFile(dto.getFileList(), dto.getId(), 1);
        ObsFileUtil.editFile(dto.getPackageFileList(), dto.getId(), 2);
    }

    /**
     * 样品交接单列表
     */
    @Override
    public Page<ContractProductVo> sampleHandoverList(SampleSelectDto dto) {
        IWrapper<Sample> wrapper = getWrapper();
        wrapper.orderByDesc("t1.create_time");
        if (StringUtils.isNotEmpty(dto.getKeyword())) {
            DynamicDataSourceContextHolder.push(SourceConstant.BASE);
            List<SysUser> list = userService.list(Wrappers.<SysUser>lambdaQuery().like(SysUser::getUserName, dto.getKeyword()));
            DynamicDataSourceContextHolder.poll();
            List<Long> userIds = list.stream().map(SysUser::getUserId).collect(Collectors.toList());
            wrapper.and(q -> q
                    .like("t2.`code`", dto.getKeyword())
                    .or().like("t2.`user_name`", dto.getKeyword())
                    .or().in("t2.create_user", userIds)
            );
        }
        wrapper.eq("t2.`status`", 30);
        wrapper.ge("t1.expend_quantity", 0);
        //查询样品交接单列表（只查询有交接单的数据）
        Page<ContractProductVo> page = this.baseMapper.sampleHandoverList(dto.getPage(), wrapper);

        List<ContractProductVo> list = page.getRecords();
        if (CollectionUtils.isNotEmpty(list)) {
            // 赋值产品属性
            productInfoService.attributeAssign(list, ContractProductVo::getProductId, (item, product) -> {
                item.setProductCode(product.getCode());
                item.setProductUnit(product.getUnit());
                item.setProductType(product.getType());
                item.setProductName(product.getName());
                item.setProductSpec(product.getSpec());
                item.setProductCategoryId(product.getProductClassifyId());
            });
            // 赋值客户名称
            customerService.attributeAssign(list, ContractProductVo::getBuyCorporationId, (item, corporation) -> {
                item.setBuyCorporationName(corporation.getName());
            });
            //赋值业务员名称
            UserUtil.assignmentNickName(list, ContractProductVo::getCreateUser, ContractProductVo::setUserName);
        }
        return page;
    }

    @Override
    public SamplePdfInfoVo getSamplePdfInfo(Long id) {
        Assert.notEmpty(id, "样品单id不能为空");
        Sample sample = getById(id);
        Assert.notEmpty(sample, "查询不到样品单信息");

        SamplePdfInfoVo contractPdfInfoVo = new SamplePdfInfoVo();
        setExportSampleInfo(contractPdfInfoVo, sample);
        return contractPdfInfoVo;
    }

    /**
     * 修改数据
     * @param sample
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void updateSample(Sample sample) {
        this.baseMapper.updateSample(sample);
    }

    /**
     * 赋值样品单信息
     */
    private void setExportSampleInfo(SamplePdfInfoVo contractPdfInfoVo, Sample sample) {

        SecurityContext context = SecurityContextHolder.getContext();

        // 赋值卖方公司基本信息
        CompletableFuture<Void> setSellCorporationInfoFuture = CompletableFuture.runAsync(
                () -> {
                    SecurityContextHolder.setContext(context);
                    setSellCorporationInfo(contractPdfInfoVo, sample);
                }, threadPoolExecutor);

        // 赋值买方公司基本信息
        CompletableFuture<Void> setBuyCorporationFuture = CompletableFuture.runAsync(
                () -> {
                    SecurityContextHolder.setContext(context);
                    setBuyCorporation(contractPdfInfoVo, sample);
                }, threadPoolExecutor);

        // 赋值买卖方公司地址
        CompletableFuture<Void> setAreaFuture = CompletableFuture.runAsync(
                () -> {
                    SecurityContextHolder.setContext(context);
                    setArea(contractPdfInfoVo, sample);
                }, threadPoolExecutor);

        // 赋值商品列表信息
        CompletableFuture<Void> setProductListFuture = CompletableFuture.runAsync(
                () -> {
                    SecurityContextHolder.setContext(context);
                    setProductList(contractPdfInfoVo, sample);
                }, threadPoolExecutor);

        // 设置收款账号
        CompletableFuture<Void> setAccountManagementFuture = CompletableFuture.runAsync(
                () -> {
                    SecurityContextHolder.setContext(context);
                    setAccountManagement(contractPdfInfoVo, sample);
                }, threadPoolExecutor);

        // 赋值合同基本信息
        setInfo(contractPdfInfoVo, sample);

        CompletableFuture.allOf(
                setSellCorporationInfoFuture,
                setBuyCorporationFuture,
                setAreaFuture,
                setProductListFuture,
                setAccountManagementFuture
        ).join();

    }


    /**
     * 赋值卖方公司基本信息
     */
    private void setSellCorporationInfo(SamplePdfInfoVo contractPdfInfoVo, Sample sample) {
        // 卖方公司信息
        Corporation corporation = corporationService.getById(sample.getSellCorporationId());
        if (corporation == null) {
            throw new ServiceException("卖方公司信息为空");
        }
        contractPdfInfoVo.setSellCorporationId(sample.getSellCorporationId());
        contractPdfInfoVo.setSellCorporationNameEn(corporation.getNameEn());
        contractPdfInfoVo.setSellCorporationName(corporation.getName());
        contractPdfInfoVo.setSellContactName(sample.getSellContactName());
        contractPdfInfoVo.setSellContactNumber(sample.getSellContactNumber());


        //赋值地址中文信息
        List<Long> areaIdList = Arrays.asList(
                corporation.getCountryId(),
                corporation.getProvinceId(),
                corporation.getCityId()
        );

        Map<Long, String> areaMap = CustomizeAreaUtil.getAreaMapByIds(areaIdList);
        contractPdfInfoVo.setSellCountryName(areaMap.get(corporation.getCountryId()));
        contractPdfInfoVo.setSellProvinceName(areaMap.get(corporation.getProvinceId()));
        contractPdfInfoVo.setSellCityName(areaMap.get(corporation.getCityId()));
        contractPdfInfoVo.setSellDetailedAddress(corporation.getAddress());
        //赋值英文名地址信息
        contractPdfInfoVo.setSellCountryNameEn(corporation.getCountryEnStr());
        contractPdfInfoVo.setSellProvinceNameEn(corporation.getProvinceEnStr());
        contractPdfInfoVo.setSellCityNameEn(corporation.getCityEnStr());
        contractPdfInfoVo.setSellDetailedAddressEn(corporation.getAddressEn());
    }

    /**
     * 赋值买方公司基本信息
     */
    private void setBuyCorporation(SamplePdfInfoVo contractPdfInfoVo, Sample sample) {
        Customer customer = customerService.getById(sample.getBuyCorporationId());
        if (customer == null) {
            throw new ServiceException("买方公司信息为空");
        }
        contractPdfInfoVo.setBuyCorporationId(sample.getBuyCorporationId());
        contractPdfInfoVo.setBuyCorporationName(customer.getName());
        contractPdfInfoVo.setBuyContactName(sample.getBuyContactName());
        contractPdfInfoVo.setBuyContactNumber(sample.getBuyContactNumber());
    }

    /**
     * 赋值买卖公司地址
     */
    private void setArea(SamplePdfInfoVo contractPdfInfoVo, Sample sample) {

        List<Long> areaIdList = Arrays.asList(
                sample.getBuyCountryId(),
                sample.getBuyProvinceId(),
                sample.getBuyCityId()
        );

        Map<Long, String> areaMap = CustomizeAreaUtil.getAreaMapByIds(areaIdList);


//        contractPdfInfoVo.setSellCountryName(sample.getSellCountryName());
//        contractPdfInfoVo.setSellProvinceName(sample.getSellProvinceName());
//        contractPdfInfoVo.setSellCityName(sample.getSellCityName());
//        contractPdfInfoVo.setSellDetailedAddress(sample.getSellAddress());

        contractPdfInfoVo.setBuyCountryName(areaMap.get(sample.getBuyCountryId()));
        contractPdfInfoVo.setBuyProvinceName(areaMap.get(sample.getBuyProvinceId()));
        contractPdfInfoVo.setBuyCityName(areaMap.get(sample.getBuyCityId()));
        contractPdfInfoVo.setBuyDetailedAddress(sample.getBuyAddress());
    }

    /**
     * 赋值合同基本信息
     */
    private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy", Locale.ENGLISH);

    private void setInfo(SamplePdfInfoVo contractPdfInfoVo, Sample sample) {
        contractPdfInfoVo.setContractCode(sample.getCode());
        contractPdfInfoVo.setCreateTimeEn(sdf.format(sample.getCreateTime()));
        contractPdfInfoVo.setTransportRemark(sample.getTransportRemark());
//        contractPdfInfoVo.setTradeMethods(sample.getTradeMethods());
        contractPdfInfoVo.setRemark(sample.getRemark());
        contractPdfInfoVo.setCurrency(sample.getCurrency());
        contractPdfInfoVo.setDeliveryTime(sample.getDeliveryTime());
        contractPdfInfoVo.setTransportMethod(sample.getTransportMethod());
        contractPdfInfoVo.setShroffAccountId(sample.getShroffAccountId());
        contractPdfInfoVo.setAdvanceRatio(sample.getAdvanceRatio());

        //赋值创建人名称
        Map<Long, SysUser> nickNameMapByIds = UserUtil.getMapByIds(Arrays.asList(sample.getCreateUser()));
        SysUser sysUser = nickNameMapByIds.get(sample.getCreateUser());
        contractPdfInfoVo.setCreateUserName(sysUser.getNickName());//中文名
        contractPdfInfoVo.setCreateUserNameEn(sysUser.getNickNameEn());//英文名
        //赋值创建人邮箱地址
        List<EnterpriseMailbox> enterpriseMailboxList = enterpriseMailboxService.list(q -> q.eq(EnterpriseMailbox::getUserId, sample.getCreateUser()));
        String eMailAddress = "";
        if (ObjectUtil.isNotEmpty(enterpriseMailboxList)) {
            //优先获取企业邮箱
            EnterpriseMailbox enterpriseMailbox = enterpriseMailboxList.get(0);
            EnterpriseDomain enterpriseDomain = enterpriseDomainService.getById(enterpriseMailbox.getDomainId());
            eMailAddress = enterpriseMailbox.getMailUserPrefix() + "@" + enterpriseDomain.getDomainName();
        } else {
            List<PersonalMailbox> personalMailboxList = personalMailboxService.list(q -> q.eq(PersonalMailbox::getUserId, sample.getCreateUser()));
            if (ObjectUtil.isNotEmpty(personalMailboxList)) {
                eMailAddress = personalMailboxList.get(0).getMailUser();
            }
        }
        contractPdfInfoVo.setCreateUserEmail(eMailAddress);

    }

    /**
     * 赋值商品列表信息
     */
    private void setProductList(SamplePdfInfoVo contractPdfInfoVo, Sample sample) {

        contractPdfInfoVo.setTotalAmount(sample.getAmount());

        List<SampleProject> sampleProjectList = sampleProjectService.list(q -> q.eq(SampleProject::getSampleId, sample.getId()));
        contractPdfInfoVo.setSampleProjectList(sampleProjectList);

        List<SampleProduct> contractProductList = sampleProductService.list(q -> q.eq(SampleProduct::getSampleId, sample.getId()));
        if (contractProductList.size() == 0) {
            return;
        }

        List<Long> pids = contractProductList.stream().map(SampleProduct::getProductId).collect(Collectors.toList());
        Map<Long, ProductInfo> productInfoMap = productInfoService.mapKEntity(ProductInfo::getId, q -> q.in(ProductInfo::getId, pids));

        List<SamplePdfInfoVo.ProductInfo> productInfoList = contractProductList.stream().map(item -> {
            ProductInfo productInfo = productInfoMap.get(item.getProductId());

            SamplePdfInfoVo.ProductInfo productIndo = new SamplePdfInfoVo.ProductInfo();
            productIndo.setProductId(item.getProductId());
            productIndo.setProductQuantity(item.getQuantity());
            productIndo.setProductPrice(item.getPrice());
            productIndo.setAmount(item.getAmount());
            productIndo.setProductName(item.getProductName());
            productIndo.setProductModel(item.getProductModel());

            if (ObjectUtil.isNotEmpty(productInfo)) {
                productIndo.setProductRemark(productInfo.getRemark());
                productIndo.setProductSpec(productInfo.getSpec());
                JSONObject ehsdJson = JSONObject.parseObject(productInfo.getEhsdJson());
                if (ObjectUtil.isNotEmpty(ehsdJson)) {
                    productIndo.setPackMethod(ehsdJson.getString("packMethod"));
                }
            }

            return productIndo;
        }).collect(Collectors.toList());

        contractPdfInfoVo.setProductInfoList(productInfoList);

        // 产品属性
        productInfoService.attributeAssign(productInfoList, SamplePdfInfoVo.ProductInfo::getProductId, (item, product) -> {
            item.setProductUnit(product.getUnit());
        });

    }

    private void setAccountManagement(SamplePdfInfoVo contractPdfInfoVo, Sample sample) {
//        Long shroffAccountId = sample.getShroffAccountId();
//        AccountManagement accountManagement = accountManagementService.getById(shroffAccountId);
//        if (accountManagement == null) {
//            return;
//        }

//        contractPdfInfoVo.setBeneficiaryName(accountManagement.getBeneficiaryName());
//        contractPdfInfoVo.setBeneficiaryBank(accountManagement.getBeneficiaryBank());
//        contractPdfInfoVo.setBeneficiaryBankAddress(accountManagement.getBeneficiaryBankAddress());
//        contractPdfInfoVo.setBeneficiaryAccountNumber(accountManagement.getBeneficiaryAccountNumber());
//        contractPdfInfoVo.setSwiftCode(accountManagement.getSwiftCode());
//        contractPdfInfoVo.setBeneficiaryAddress(accountManagement.getBeneficiaryAddress());

        contractPdfInfoVo.setBeneficiaryName(sample.getBeneficiaryName());
        contractPdfInfoVo.setBeneficiaryBank(sample.getBeneficiaryBank());
        contractPdfInfoVo.setBeneficiaryBankAddress(sample.getBeneficiaryBankAddress());
        contractPdfInfoVo.setBeneficiaryAccountNumber(sample.getBeneficiaryAccountNumber());
        contractPdfInfoVo.setSwiftCode(sample.getSwiftCode());
        contractPdfInfoVo.setBeneficiaryAddress(sample.getBeneficiaryAddress());
    }

}
