package cn.cslg.pas.service.upLoadPatent;

import cn.cslg.pas.common.model.vo.UploadParamsVO;
import cn.cslg.pas.common.model.vo.UploadSettingVO;
import cn.cslg.pas.common.utils.UploadPatentBatchUtil;
import cn.cslg.pas.domain.PatentData;
import org.apache.poi.ss.usermodel.PictureData;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 将专利源数据转换为专利VO实体类业务层
 *
 * @Author chenyu
 * @Date 2023/5/31
 */
@Service
public class ExcuteDataToVOService {

    /**
     * 将Eccel文件指定行专利数据装配转换为专利实体类
     *
     * @param patentData 专利数据
     * @param jsonData   数据源配置
     * @return 返回专利实体类
     */
    public UploadParamsVO fileToPatentVO(PatentData patentData, List<UploadSettingVO.Column> jsonData) {
        //取出专利内容数据（除了摘要附图），（key：表头如 "公开（公告）号"  value：表头对应内容如 "CN1307082B"）
        Map<Object, Object> patentMap = patentData.getMap();
        //取出专利摘要附图
        PictureData pictureData = patentData.getPictureData();

        //专利基础数据装配（与数据源配置文件对象进行匹配装载）
        UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(patentMap, jsonData);
        uploadParamsVO.setPictureData(pictureData);
        return uploadParamsVO;
    }

}
