package com.ruoyi.project.business.service.impl;

import static java.util.stream.Collectors.groupingBy;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Pair;
import com.google.common.collect.Lists;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.importExcel.excel.helper.BasicTableInfoHelper;
import com.ruoyi.common.importExcel.excel.tempInfo.PriceFromInfoHelper;
import com.ruoyi.common.importExcel.utils.ExcelUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.business.domain.TpAreaBasicPrice;
import com.ruoyi.project.business.domain.TpElevatorModel;
import com.ruoyi.project.business.domain.TpParaSelectItem;
import com.ruoyi.project.business.domain.vo.parabar.ElParabarDetailVO;
import com.ruoyi.project.business.domain.vo.parabar.ElParabarDetailValueVO;
import com.ruoyi.project.business.domain.vo.parabar.ElParabarVO;
import com.ruoyi.project.business.domain.vo.paramSelectItem.AreaElevatorModelParaVO;
import com.ruoyi.project.business.domain.vo.paramSelectItem.AreaParaSelectItemVo;
import com.ruoyi.project.business.domain.vo.paramSelectItem.ElevatorModeParamlVo;
import com.ruoyi.project.business.domain.vo.paramSelectItem.TabsVo;
import com.ruoyi.project.business.domain.vo.paramSelectItem.TpAreaBasicPriceVo;
import com.ruoyi.project.business.domain.vo.paramSelectItem.TpElevatorModelVo;
import com.ruoyi.project.business.domain.vo.paramSelectItem.TransferParam;
import com.ruoyi.project.business.domain.vo.quotation.EleCategoryVO;
import com.ruoyi.project.business.domain.vo.quotation.EleDecorateConfigVO;
import com.ruoyi.project.business.domain.vo.quotation.EleParamOptionVO;
import com.ruoyi.project.business.domain.vo.quotation.EleParamVO;
import com.ruoyi.project.business.domain.vo.quotation.EleconfigVO;
import com.ruoyi.project.business.dto.TpElevatorModelDto;
import com.ruoyi.project.business.enums.DelFlagEnum;
import com.ruoyi.project.business.enums.InputTypeEnum;
import com.ruoyi.project.business.enums.ParamTypeEnum;
import com.ruoyi.project.business.enums.StatusEnum;
import com.ruoyi.project.business.mapper.*;
import com.ruoyi.project.business.service.ITpElevatorModelService;
import com.ruoyi.project.business.service.ITpParabarService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-25
 */
@Service
public class TpElevatorModelServiceImpl implements ITpElevatorModelService {

    @Resource
    private TpElevatorModelMapper tpElevatorModelMapper;

    @Resource
    private TpParaSelectItemMapper tpParaSelectItemMapper;

    @Resource
    private TpAreaElevatorModelParaMapper tpAreaElevatorModelParaMapper;

    @Resource
    private TpAreaParaSelectItemMapper tpAreaParaSelectItemMapper;

    @Resource
    private TpAreaParaStandardMapper tpAreaParaStandardMapper;
    @Resource
    private TpAreaBasicPriceMapper tpAreaBasicPriceMapper;
    @Resource
    private TpCaseElevatorMapper tpCaseElevatorMapper;
    @Resource
    private TpParaValidationElevatorMapper tpParaValidationElevatorMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public TpElevatorModel selectTpElevatorModelById(Long id) {
        return tpElevatorModelMapper.selectTpElevatorModelById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param tpElevatorModel 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<TpElevatorModel> selectTpElevatorModelList(TpElevatorModel tpElevatorModel) {
        return tpElevatorModelMapper.selectTpElevatorModelList(tpElevatorModel);
    }

    @Override
    public List<TpElevatorModelDto> listForComponents(TpElevatorModelDto param) {
        return tpElevatorModelMapper.listForComponents(param);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param tpElevatorModel 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertTpElevatorModel(TpElevatorModel tpElevatorModel) {
        tpElevatorModel.setCreateTime(DateUtils.getNowDate());
        return tpElevatorModelMapper.insertTpElevatorModel(tpElevatorModel);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param tpElevatorModel 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateTpElevatorModel(TpElevatorModel tpElevatorModel) {
        tpElevatorModel.setUpdateTime(DateUtils.getNowDate());
        return tpElevatorModelMapper.updateTpElevatorModel(tpElevatorModel);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTpElevatorModelByIds(Long[] ids) {
        //删除共需删除4张表
        //梯形表 参数表 参数选项表 以及默认参数值表
        //只能删除一个
        Long elevatorModelId = ids[0];
        // todo 删除是否存在校验 待添加
        //验证是否被规则校验使用
        int validationNum = tpParaValidationElevatorMapper.getValidationCount(elevatorModelId);
        if(validationNum>0){
            //返回无法删除
//            throw new ServiceException(MessageUtils.message("common.hasValidation"));
            throw new ServiceException("该梯型存在规则校验数据，无法删除！");
        }
        //验证是否被参数联动使用
        int caseNum = tpCaseElevatorMapper.getCount(elevatorModelId);
        if(caseNum>0){
            //返回无法删除
//            throw new ServiceException(MessageUtils.message("common.hasCase"));
            throw new ServiceException("该梯型存在参数联动数据，无法删除！");
        }

        //删除参数表
        int i = tpAreaElevatorModelParaMapper.deleteTpAreaElevatorByElevatorModelId(elevatorModelId);
        i += tpAreaParaSelectItemMapper.deleteTpAreaParaSelectItemByElevatorModelId(elevatorModelId);
        i += tpAreaParaStandardMapper.deleteTpAreaParaStandardByElevatorModelId(elevatorModelId);
        return tpElevatorModelMapper.deleteTpElevatorModelByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTpElevatorModelById(Long id) {
        return tpElevatorModelMapper.deleteTpElevatorModelById(id);
    }

    @Override
    public int updateParaStatus(TpElevatorModel tpElevatorModel) {
        if ("1".equals(tpElevatorModel.getStatus())) {
            int usedCount = 0;
            // todo 查询此数据是否可以停用或删除
            // usedCount = tpElevatorModelMapper.checkParaChangeAllowed(tpParaLibrary.getId());
            if (usedCount > 0) {
                throw new ServiceException(MessageUtils.message("paraLibrary.usingMessage"));
                //                throw new ServiceException("该参数正在使用中，请确认！");
            }
        }
        tpElevatorModel.setUpdateTime(DateUtils.getNowDate());
        tpElevatorModel.setUpdateBy(SecurityUtils.getUserId() + "");
        return tpElevatorModelMapper.updateTpElevatorModel(tpElevatorModel);
    }

    @Override
    public List<TpElevatorModel> selectTpElevatorModelListNew(TpElevatorModelVo tpElevatorModel) {
        tpElevatorModel.setDelFlag(DelFlagEnum.NORMAL.getValue());
        return tpElevatorModelMapper.selectTpElevatorModelListNew(tpElevatorModel);
    }

    @Override
    public List<TpElevatorModel> listNewAll(TpElevatorModelVo tpElevatorModel) {
        tpElevatorModel.setStatus(StatusEnum.ENABLE.getCode());
        tpElevatorModel.setDelFlag(DelFlagEnum.NORMAL.getValue());
        return tpElevatorModelMapper.selectTpElevatorModelListNew(tpElevatorModel);
    }

    @Override
    public ElevatorModeParamlVo selectTpElevatorModelParamById(Long id) {
        return tpElevatorModelMapper.selectTpElevatorModelParamById(id);
    }

    @Override
    public ElevatorModeParamlVo selectTpElevatorModelParamSelectItemById(Long id) {
        ElevatorModeParamlVo item = new ElevatorModeParamlVo();
        TpElevatorModel model = tpElevatorModelMapper.selectTpElevatorModelById(id);
        BeanUtils.copyProperties(model, item);
        List<AreaElevatorModelParaVO> list = tpElevatorModelMapper.selectTpElevatorModelParamSelectItemById(id);
        //查询全部的选项\
        TpParaSelectItem param = new TpParaSelectItem();
        List<TpParaSelectItem> allselect = tpParaSelectItemMapper.selectTpParaSelectItemList(param);
        Locale locale = LocaleContextHolder.getLocale();
        String language = locale.getLanguage();

        //设置每个参数的选项opt
        for (AreaElevatorModelParaVO modelPara : list) {
            List<TransferParam> optList = new ArrayList<>();
            Long ids = modelPara.getParaId();
            List<TpParaSelectItem> paraselect = allselect.stream()
                .filter(it -> it.getParaId().equals(ids))
                .collect(Collectors.toList());
            for (TpParaSelectItem opt : paraselect) {
                TransferParam transferParam = new TransferParam();
                transferParam.setDisabled(false);
                transferParam.setKey(opt.getId());
                String label = "";
                switch (language) {
                    case "zh":
                        label = opt.getLabel();
                        break;
                    case "en":
                        label = opt.getLabelUS();
                        break;
                    case "es":
                        label = opt.getLabelES();
                        break;
                    case "ru":
                        label = opt.getLabelRU();
                        break;
                }
                transferParam.setLabel(label);
                optList.add(transferParam);
            }
            modelPara.setParaSelectListOpt(optList);
            if (!ObjectUtils.isEmpty(modelPara.getSelectItemList())) {
                List<Long> selectItems = modelPara.getSelectItemList().stream()
                    .map(AreaParaSelectItemVo::getParaSelectItemId).collect(Collectors.toList());
                modelPara.setParaAreaSelectList(selectItems);
            } else {
                List<Long> res = new ArrayList<>();
                modelPara.setParaAreaSelectList(res);
            }
        }

        //根据paraCategory分组
        Map<String, List<AreaElevatorModelParaVO>> tabs = list.stream()
            .collect(groupingBy(AreaElevatorModelParaVO::getParaCategory));
        List<TabsVo> vos = new ArrayList<>();
        for (String paraCategory : tabs.keySet()) {
            List<AreaElevatorModelParaVO> tempPara = tabs.get(paraCategory);
            TabsVo vo = new TabsVo();
            vo.setParaCategory(paraCategory);
            vo.setParaSelect(tempPara);
            vos.add(vo);
        }
        item.setTabsList(vos);

        return item;
    }

    @Override
    public ElevatorModeParamlVo selectTpElevatorModelParamStantById(Long id) {
        ElevatorModeParamlVo item = new ElevatorModeParamlVo();
        TpElevatorModel model = tpElevatorModelMapper.selectTpElevatorModelById(id);
        BeanUtils.copyProperties(model, item);
        //查询所有参数可选项以及默认数据
        List<AreaElevatorModelParaVO> list = tpElevatorModelMapper.selectTpElevatorModelParamSelectItemAllById(id);
        //根据paraCategory分组
        Map<String, List<AreaElevatorModelParaVO>> tabs = list.stream()
                .sorted(Comparator.comparing(AreaElevatorModelParaVO::getSort))
            .collect(groupingBy(AreaElevatorModelParaVO::getParaCategory));
        List<TabsVo> vos = new ArrayList<>();
        for (String paraCategory : tabs.keySet()) {
            List<AreaElevatorModelParaVO> tempPara = tabs.get(paraCategory);
            TabsVo vo = new TabsVo();
            vo.setParaCategory(paraCategory);
            vo.setParaSelect(tempPara);
            vos.add(vo);
        }
        item.setTabsList(vos);
        return item;
    }

    @Resource
    private ITpParabarService iTpParabarService;

    @Override
    public EleconfigVO selectTpElevatorModelParamOption(Long id) {
        EleconfigVO eleconfigVO = new EleconfigVO();
        List<EleCategoryVO> categoryVOList = new ArrayList<>();
        // 普通参数
        ElevatorModeParamlVo elevatorModeParamlVo = tpElevatorModelMapper.selectTpElevatorModelParamOptionById(id);
        // 参数包
        List<ElParabarVO> parabarList = iTpParabarService.getParabarConfigByElevatorModelId(id);
        // 过滤非装潢参数包
        List<ElParabarVO> undecorateParabarList = parabarList.stream()
            .filter(parabar -> "0".equals(parabar.getDecorateFlag()))
            .collect(Collectors.toList());
        // 给参数包设置 参数类别
        fillParaCategory(undecorateParabarList);
        // 参数包转map  Key：paramCategory  value：ElParabarVO
        Map<String, List<ElParabarVO>> parabarMap = undecorateParabarList.stream()
            .collect(groupingBy(ElParabarVO::getParaCategory));
        // 参数包配置值转map  Key：paraCode  value：paraValue
        Map<String, Pair<Long, Long>> codeValueMap = convert2CodeValueMap(undecorateParabarList);

        if (ObjectUtils.isNotEmpty(elevatorModeParamlVo) && CollUtil.isNotEmpty(elevatorModeParamlVo.getParaSelect())) {
            // 根据类别分组
            Map<String, List<AreaElevatorModelParaVO>> categoryMap = elevatorModeParamlVo.getParaSelect().stream()
                .collect(groupingBy(AreaElevatorModelParaVO::getParaCategory));
            // 遍历类别
            for (Map.Entry<String, List<AreaElevatorModelParaVO>> entry : categoryMap.entrySet()) {
                String paraCategory = entry.getKey();
                List<AreaElevatorModelParaVO> value = entry.getValue();
                List<ElParabarVO> elParabarVOS = parabarMap.get(paraCategory);
                List<EleParamVO> eleParamVOList = new ArrayList<>();
                // ++++++++++++++参数包 start
                if (CollUtil.isNotEmpty(elParabarVOS)) {
                    // 遍历参数
                    for (ElParabarVO paraVO : elParabarVOS) {
                        // 如果是下拉矿，遍历参数选项
                        List<EleParamOptionVO> paramOptionVOList = new ArrayList<>();
                        List<ElParabarDetailVO> paramList = paraVO.getParamList();
                        if (CollUtil.isNotEmpty(paramList)) {
                            for (ElParabarDetailVO parabarDetailVO : paramList) {
                                EleParamOptionVO paramOptionVO = EleParamOptionVO.builder()
                                    .label(parabarDetailVO.getParabarDetailName())
                                    .labelUS(parabarDetailVO.getParabarDetailNameUS())
                                    .labelES(parabarDetailVO.getParabarDetailNameES())
                                    .labelRU(parabarDetailVO.getParabarDetailNameRU())
                                    .isShow(true)
                                    .value(parabarDetailVO.getId().toString())
                                    .parabarDetailValueList(parabarDetailVO.getParamOptionList())
                                    .build();
                                paramOptionVOList.add(paramOptionVO);
                            }
                        }
                        EleParamVO paramVO = EleParamVO.builder()
                            .paramType(ParamTypeEnum.BAR.getCode())
                            .label(paraVO.getParabarName())
                            .labelUS(paraVO.getParabarNameUS())
                            .labelES(paraVO.getParabarNameES())
                            .labelRU(paraVO.getParabarNameRU())
                            .paraCode(paraVO.getId().toString())
                            .inputType(InputTypeEnum.SELECT.getCode())
                            .isShow(true)
                            // .defaultValue(null)
                            // .defaultId(null)
                            // .finalValue(null)
                            .paramOptionList(paramOptionVOList)
                            .build();
                        eleParamVOList.add(paramVO);
                    }
                }
                // ++++++++++++++参数包 end

                // 参数排序
                value = value.stream().sorted(Comparator.comparingLong(AreaElevatorModelParaVO::getSort))
                    .collect(Collectors.toList());

                // 遍历参数
                for (AreaElevatorModelParaVO paraVO : value) {
                    // 如果是下拉矿，遍历参数选项
                    List<EleParamOptionVO> paramOptionVOList = new ArrayList<>();
                    List<AreaParaSelectItemVo> selectItemList = paraVO.getSelectItemList();
                    if (CollUtil.isNotEmpty(selectItemList)) {
                        for (AreaParaSelectItemVo paramItem : selectItemList) {
                            EleParamOptionVO paramOptionVO = EleParamOptionVO.builder()
                                .label(paramItem.getLabel())
                                .labelUS(paramItem.getLabelUS())
                                .labelES(paramItem.getLabelES())
                                .labelRU(paramItem.getLabelRU())
                                .isShow(true)
                                .value(paramItem.getParaSelectItemValue())
                                .build();
                            paramOptionVOList.add(paramOptionVO);
                        }
                    }

                    // 参数包的值覆盖默认参数，参数类型变更,状态改为不可见
                    String defaultValue = paraVO.getParaDefaultValue();
                    String paramType = ParamTypeEnum.NORMAL.getCode();
                    Pair<Long, Long> pair = codeValueMap.get(paraVO.getParaCode());
                    Long parabarId = null;
                    Long parabarDetailId = null;
                    Boolean isShow = true;
                    if (Objects.nonNull(pair)) {
                        defaultValue = null;
                        paramType = ParamTypeEnum.BAR_PARAM.getCode();
                        isShow = false;
                        parabarId = pair.getKey();
                        parabarDetailId = pair.getValue();
                    }
                    // 非报价参数隐藏
                    if (StatusEnum.DISABLE.getCode().equals(paraVO.getIsQuotation())) {
                        isShow = false;
                    }

                    EleParamVO paramVO = EleParamVO.builder()
                        .paramType(paramType)
                        .parabarId(parabarId)
                        .parabarDetailId(parabarDetailId)
                        .label(paraVO.getParaName())
                        .labelUS(paraVO.getParaNameUS())
                        .labelES(paraVO.getParaNameES())
                        .labelRU(paraVO.getParaNameRU())
                        .paraCode(paraVO.getParaCode())
                        .inputType(paraVO.getInputType())
                        .defaultValue(defaultValue)
                        .defaultId(String.valueOf(paraVO.getParaDefaultId()))
                        .finalValue(defaultValue)
                        .isShow(isShow)
                        .enabled(true)
                        .paramOptionList(paramOptionVOList)
                        .build();
                    eleParamVOList.add(paramVO);
                }
                // 参数包逻辑
                Boolean categoryIsShow = eleParamVOList.stream().anyMatch(EleParamVO::getIsShow);
                // 参数大类的类别都相同
                AreaElevatorModelParaVO areaElevatorModelParaVO = value.get(0);

                EleCategoryVO eleCategoryVO = EleCategoryVO.builder()
                    .paraCategory(areaElevatorModelParaVO.getParaCategory())
                    .label(areaElevatorModelParaVO.getParaCategoryLabel())
                    .labelUS(areaElevatorModelParaVO.getParaCategoryLabelUS())
                    .labelRU(areaElevatorModelParaVO.getParaCategoryLabelRU())
                    .labelES(areaElevatorModelParaVO.getParaCategoryLabelES())
                    .isShow(categoryIsShow)
                    .enabled(true)
                    .paramList(eleParamVOList).build();
                categoryVOList.add(eleCategoryVO);
            }
            eleconfigVO.setCategoryList(categoryVOList);
        }
        // 装潢包参数组装
        List<ElParabarVO> decorateParabarList = parabarList.stream()
            .filter(parabar -> "1".equals(parabar.getDecorateFlag()))
            .collect(Collectors.toList());

        if (CollUtil.isNotEmpty(decorateParabarList)) {
            List<EleDecorateConfigVO> decorateConfigVOList = new ArrayList<>();
            for (ElParabarVO elParabarVO : decorateParabarList) {
                for (ElParabarDetailVO elParabarDetailVO : elParabarVO.getParamList()) {
                    List<EleParamVO> paramList = new ArrayList<>();
                    for (ElParabarDetailValueVO elParabarDetailValueVO : elParabarDetailVO.getParamOptionList()) {
                        List<EleParamOptionVO> paramOptionVOList = new ArrayList<>();
                        EleParamOptionVO paramOptionVO = EleParamOptionVO.builder()
                            .label(elParabarDetailValueVO.getParamOptionLabel())
                            .labelUS(elParabarDetailValueVO.getParamOptionLabelUS())
                            .labelES(elParabarDetailValueVO.getParamOptionLabelES())
                            .labelRU(elParabarDetailValueVO.getParamOptionLabelRU())
                            // .isShow(true)
                            .value(elParabarDetailValueVO.getParaValue())
                            .build();
                        paramOptionVOList.add(paramOptionVO);

                        EleParamVO paramVO = EleParamVO.builder()
                            // .paramType(elParabarDetailValueVO.get)
                            .parabarId(elParabarVO.getId())
                            .parabarDetailId(elParabarDetailVO.getId())
                            .label(elParabarDetailValueVO.getParaName())
                            .labelUS(elParabarDetailValueVO.getParaNameUS())
                            .labelES(elParabarDetailValueVO.getParaNameES())
                            .labelRU(elParabarDetailValueVO.getParaNameRU())
                            .paraCode(elParabarDetailValueVO.getParaCode())
                            .inputType(elParabarDetailValueVO.getInputType())
                            // .defaultValue(defaultValue)
                            // .defaultId(String.valueOf(paraVO.getParaDefaultId()))
                            .finalValue(elParabarDetailValueVO.getParaValue())
                            .paramOptionList(paramOptionVOList)
                            .build();
                        paramList.add(paramVO);
                    }
                    EleDecorateConfigVO build = EleDecorateConfigVO.builder()
                        .url(elParabarDetailVO.getUrl())
                        .parabarId(elParabarVO.getId())
                        .parabarDetailId(elParabarDetailVO.getId())
                        .paramList(paramList)
                        .build();
                    decorateConfigVOList.add(build);
                }
            }
            eleconfigVO.setEleDecorateConfigList(decorateConfigVOList);
        }
        return eleconfigVO;
    }

    @Override
    public ExcelUtils.UploadResult<PriceFromInfoHelper> checkPriceFormImport(BasicTableInfoHelper basicTableInfoHelper, List<PriceFromInfoHelper> list) {

        return ExcelUtils.checkData(list, it -> {
            List<String> businessErrors = Lists.newArrayList();
            if(StringUtils.isEmpty(it.getDefaultPara())){
                businessErrors.add("编码不为空");
            }
            //todo 执行验证及其他操作
            return businessErrors;
        });
    }

    @Override
    public ElevatorModeParamlVo selectTpElevatorModelJGBById(Long id) {
        ElevatorModeParamlVo item = new ElevatorModeParamlVo();
        TpElevatorModel model = tpElevatorModelMapper.selectTpElevatorModelById(id);
        BeanUtils.copyProperties(model, item);

        //设置基础价格
        TpAreaBasicPriceVo areaBase = new TpAreaBasicPriceVo();
        TpAreaBasicPrice tpAreaBasicPrice = new TpAreaBasicPrice();
        tpAreaBasicPrice.setElevatorModelId(id);
        List<TpAreaBasicPriceVo> baseList =  tpAreaBasicPriceMapper.getTpAreaBasicPriceList(tpAreaBasicPrice);
        item.setBaseData(baseList);

        // todo 设置选配项目

        return item;
    }

    private List<ElParabarVO> falseData() {
        List<String> urls = Arrays.asList("https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg",
            "https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg",
            "https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg",
            "https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg",
            "https://fuss10.elemecdn.com/d/e6/c4d93a3805b3ce3f323f7974e6f78jpeg.jpeg",
            "https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg",
            "https://fuss10.elemecdn.com/2/11/6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg");

        List<ElParabarVO> elParabarVOS = new ArrayList<>();
        ElParabarVO elParabarVO = new ElParabarVO();
        List<ElParabarDetailVO> paramList = new ArrayList<>();
        for (int i = 0; i < urls.size(); i++) {
            ElParabarDetailVO elParabarDetailVO = new ElParabarDetailVO();
            elParabarDetailVO.setUrl(urls.get(i));
            elParabarDetailVO.setId(Long.valueOf(i + ""));
            ElParabarDetailValueVO elParabarDetailValueVO = new ElParabarDetailValueVO();
            elParabarDetailValueVO.setParabarId(72L);
            elParabarDetailValueVO.setParaName("扶手样式（左）" + i);
            elParabarDetailValueVO.setParaNameES("扶手样式（左）" + i);
            elParabarDetailValueVO.setParaNameUS("扶手样式（左）" + i);
            elParabarDetailValueVO.setParaNameRU("扶手样式（左）" + i);
            elParabarDetailValueVO.setParaCode("FSYSZ");
            elParabarDetailValueVO.setParaValue("100");
            elParabarDetailValueVO.setParamOptionLabel("KASKDK_ASJKDJ");
            elParabarDetailValueVO.setParamOptionLabelES("KASKDK_ASJKDJ");
            elParabarDetailValueVO.setParamOptionLabelUS("KASKDK_ASJKDJ");
            elParabarDetailValueVO.setParamOptionLabelRU("KASKDK_ASJKDJ");
            elParabarDetailVO.setParamOptionList(Arrays.asList(elParabarDetailValueVO));
            paramList.add(elParabarDetailVO);
        }
        elParabarVO.setId(72L);
        elParabarVO.setParamList(paramList);
        elParabarVOS.add(elParabarVO);
        return elParabarVOS;
    }

    private Map<String, Pair<Long, Long>> convert2CodeValueMap(List<ElParabarVO> parabarList) {
        Map<String, Pair<Long, Long>> codeValueMap = new HashMap<>();
        for (ElParabarVO parabarVO : parabarList) {
            for (ElParabarDetailVO elParabarDetailVO : parabarVO.getParamList()) {
                elParabarDetailVO.getParamOptionList().forEach(item -> {
                    codeValueMap.put(item.getParaCode(), Pair.of(parabarVO.getId(), elParabarDetailVO.getId()));
                });
            }
        }
        return codeValueMap;
    }

    private void fillParaCategory(List<ElParabarVO> parabarList) {
        if (CollUtil.isNotEmpty(parabarList)) {
            for (ElParabarVO parabarVO : parabarList) {
                parabarVO.setParaCategory(
                    parabarVO.getParamList().get(0).getParamOptionList().get(0).getParaCategory());
            }
        }
    }

}
