package com.baichuanxin.openrestapi.service.impl;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baichuanxin.openrestapi.common.OnlineTaskConstant;
import com.baichuanxin.openrestapi.common.utils.OnlineTaskUtil;
import com.baichuanxin.openrestapi.dao.mapper.SelfRecruitmentFilingMapper;
import com.baichuanxin.openrestapi.dao.mapper.ShareholderMapper;
import com.baichuanxin.openrestapi.dtos.SecurityServicekDto;
import com.baichuanxin.openrestapi.dtos.ShareholderDto;
import com.baichuanxin.openrestapi.entity.Notice;
import com.baichuanxin.openrestapi.entity.SecurityServicek;
import com.baichuanxin.openrestapi.entity.SelfRecruitmentFiling;
import com.baichuanxin.openrestapi.entity.Shareholder;
import com.baichuanxin.openrestapi.service.TaskInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class ShareholderTaskInfoServiceImpl extends ServiceImpl<ShareholderMapper, Shareholder> implements TaskInfoService {
    @Override
    public boolean saveTaskInfo(Notice notice) {
        return false;
    }

    @Override
    public List<String> returnTaskResult(List<Notice> noticeList) {
        return null;
    }

    public boolean saveOtherInfo(String taskId,List<ShareholderDto> shareholderDtos,String topId) {
        List<Shareholder> shareholders = new ArrayList<>();
        int  i = 0 ;
        for (ShareholderDto shareholderDto : shareholderDtos) {

            Shareholder convert = shareholderDto.convert(taskId);
            convert.setItemTopid(topId);
            convert.setId(StrUtil.join("--",StrUtil.join("",taskId,i),OnlineTaskConstant.SHARE_HOLDER));
            ++i;
            shareholders.add(convert);
        }
        return this.saveBatch(shareholders);
    }

}
