package com.jeelowcode.core.framework.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamImport;
import com.jeelowcode.core.framework.entity.ExcelFileDataEntity;
import com.jeelowcode.core.framework.entity.FormEntity;
import com.jeelowcode.core.framework.service.IExcelFileDataService;
import com.jeelowcode.core.framework.service.IExcelImportService;
import com.jeelowcode.core.framework.service.IFormService;
import com.jeelowcode.core.framework.service.IFrameService;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.core.framework.utils.FuncWeb;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.utils.enums.ParamEnum;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.CollectionUtil;
import com.jeelowcode.framework.utils.tool.NumberUtil;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

@Service
public class PersonInfoServiceImpl implements IExcelImportService {

    @Autowired
    private IFrameService frameService;


    @Override
    public void importExcelCheck(ButtonParamImport buttonParam) {

        Map<String, Object> params =new HashMap<>();
        params.put(ParamEnum.PAGE_NO.getCode(),1);
        params.put(ParamEnum.PAGE_SIZE.getCode(),1000);
        IFrameService proxyService = SpringUtils.getBean(IFrameService.class);
        ResultDataModel model = proxyService.getDataList(NumberUtil.toLong("1964207990401785857"), params);

    }

    @Override
    public void importExcelDataUpdate(ButtonParamImport buttonParam) {
//        Map<String, Object> params =new HashMap<>();
//        params.put(ParamEnum.PAGE_NO.getCode(),1);
//        params.put(ParamEnum.PAGE_SIZE.getCode(),1000);
//        IFrameService proxyService = SpringUtils.getBean(IFrameService.class);
//        ResultDataModel model = proxyService.getDataList(NumberUtil.toLong("1964207990401785857"), params);
//        if(CollectionUtil.isNotEmpty(buttonParam.getDataMapList())){
//            for(Map<String, Object> map : buttonParam.getDataMapList()){
//                if(map.containsKey("supplierName")){
//                    Map<String, Object> depMap = model.getRecords().stream().filter(t->t.get("full_name").equals(map.get("supplierName"))).findFirst().orElse(null);
//                    if(Objects.nonNull(depMap)){
//                        map.put("supplierId",depMap.get("id"));
//                    }else {
//                        throw new JeeLowCodeException("供应商："+map.get("supplierName") + "不存在");
//                    }
//                }
//
//                if(map.containsKey("demandName")){
//                    Map<String, Object> depMap = model.getRecords().stream().filter(t->t.get("full_name").equals(map.get("demandName"))).findFirst().orElse(null);
//                    if(Objects.nonNull(depMap)){
//                        map.put("demandId",depMap.get("id"));
//                    }else {
//                        throw new JeeLowCodeException("用人单位："+map.get("demandName") + "不存在");
//                    }
//                }
//            }
//        }
    }
}
