package com.fs.app.controller;


import com.fs.ad.enums.AdUploadType;
import com.fs.ad.service.IAdHtmlClickLogService;
import com.fs.common.annotation.DataSource;
import com.fs.common.core.domain.R;
import com.fs.common.enums.DataSourceType;
import com.fs.common.utils.PubFun;
import com.fs.qw.result.QwFilterSopCustomersResult;
import com.fs.sop.domain.QwSop;
import com.fs.sop.domain.QwSopTempContent;
import com.fs.sop.domain.QwSopTempDay;
import com.fs.sop.mapper.QwSopMapper;
import com.fs.sop.mapper.QwSopTempContentMapper;
import com.fs.sop.mapper.QwSopTempDayMapper;
import com.fs.sop.params.QwSopTagsParam;
import com.fs.sop.service.IQwSopService;
import com.fs.sop.service.IQwSopTempContentService;
import com.fs.sop.service.IQwSopTempDayService;
import com.fs.sop.service.IQwSopTempVoiceService;
import com.fs.voice.utils.StringUtil;
import io.swagger.annotations.Api;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


@Slf4j
@RestController
@AllArgsConstructor
@Ignore
@RequestMapping(value="/qw/voice")
public class VoiceController {

//    private final IQwSopTempDayService qwSopTempDayService;
//    private final QwSopTempContentMapper qwSopTempContentMapper;
//    private final IQwSopTempVoiceService qwSopTempVoiceService;
//    private final QwSopMapper qwSopMapper;
//
//    @GetMapping("/synchronousTemp")
//    @DataSource(DataSourceType.SOP)
//    public void synchronousTemp(Long dayId){
//        QwSopTempDay day = qwSopTempDayService.getById(dayId);
//        List<QwSopTempContent> contents = qwSopTempContentMapper.listByTempAndDay(day.getTempId(), dayId);
//        new Thread(() -> qwSopTempVoiceService.synchronousTemp(contents, day)).start();
//    }
//
//    @GetMapping("/synchronousSop")
//    public void synchronousSop(String sopId){
//        QwSop qwSop = qwSopMapper.selectQwSopById(sopId);
//        QwSopTagsParam qwSopTagsParam = new QwSopTagsParam();
//        //成员筛选
//        if (!StringUtil.strIsNullOrEmpty(qwSop.getQwUserIds())){
//            qwSopTagsParam.setUserIdsSelectList(Arrays.asList( qwSop.getQwUserIds().split(",")));
//        }
//
//        //标过滤类型
//        qwSopTagsParam.setFilterType(qwSop.getFilterType());
//
//
//        //标签
//        if (!StringUtil.strIsNullOrEmpty(qwSop.getTags())){
//            qwSopTagsParam.setTagsIdsSelectList(Arrays.asList(qwSop.getTags().split(",")));
//        }
//
//        //排除标签
//        String excludeTags = qwSop.getExcludeTags();
//        if (!StringUtil.strIsNullOrEmpty(excludeTags)){
//            qwSopTagsParam.setOutTagsIdsSelectList(Arrays.asList(excludeTags.split(",")));
//        }
//        qwSopTagsParam.setCropId(qwSop.getCorpId());
//
//        // 查询符合条件的客户
////                            List<QwFilterSopCustomersResult> qwFilterSopCustomersResults = qwSopMapper.selectFilterQwSopCustomersTest(qwSopTagsParam);
//        List<QwFilterSopCustomersResult> qwFilterSopCustomersResults = qwSopMapper.selectFilterQwSopCustomers(qwSopTagsParam);
//        List<List<Long>> companyUserIds = PubFun.listToNewList(qwFilterSopCustomersResults.stream().filter(e -> e.getCuCompanyId() != null && e.getCompanyId() != null).collect(Collectors.toList()), e -> Arrays.asList(e.getCuCompanyUserId(), e.getCuCompanyId()));
//        new Thread(() -> qwSopTempVoiceService.synchronous(sopId, companyUserIds)).start();
//    }

}
