package cn.com.poc.humanResource;

import cn.com.gsst.dify_client.DifyClientFactory;
import cn.com.gsst.dify_client.DifyWorkflowClient;
import cn.com.gsst.dify_client.enums.ResponseMode;
import cn.com.gsst.dify_client.model.workflow.WorkflowRunRequest;
import cn.com.gsst.dify_client.model.workflow.WorkflowRunResponse;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.DateUtils;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.human_resources.aggregate.HumanResourceService;
import cn.com.poc.human_resources.entity.BizHumanResourcePositionEntity;
import cn.com.poc.human_resources.entity.BizHumanResourceResumeEntity;
import cn.com.poc.human_resources.query.ResumeContentQueryItem;
import cn.com.poc.human_resources.service.BizHumanResourcePositionService;
import cn.com.poc.human_resources.service.BizHumanResourceResumeContentService;
import cn.com.poc.human_resources.service.BizHumanResourceResumeService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author alex.yao
 * @date 2025/9/28
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers = SingleContextInitializer.class)
@WebAppConfiguration
public class HumanResourceTest {

    @Resource
    private HumanResourceService humanResourceService;

    @Resource
    private BizHumanResourceResumeContentService bizHumanResourceResumeContentService;

    @Test
    public void test_uploadResume() throws Exception {
        String fileURL = "https://gsst-modellink-prod.gz.bcebos.com/data/20250928/1759049361707.pdf";
        String postion = "java实习生";
        Long userId = 0L;
        System.out.println(humanResourceService.uploadResume(fileURL, 1L, userId));
    }


    @Test
    public void test_searchByResumeContent() {
        Long positionId = 8L;
        String query = "Java";
        List<ResumeContentQueryItem> resumeContentQueryItems =
                bizHumanResourceResumeContentService.searchByResumeContent(query, positionId);
        System.out.println(resumeContentQueryItems.size());
    }


    @Test
    public void test_retrievalSearchResume() throws Exception {
        Long positionId = 8L;
        Long userId = 197L;
        List<Long> resumeIds = Arrays.asList(30L);
        String requirements = "有Java开发经验;本科及以上;计算机二级;女生";

        List<BizHumanResourceResumeEntity> resourceResumeEntities =
                humanResourceService.retrievalSearchResume(userId, requirements, positionId, resumeIds);
        System.out.println(JsonUtils.serialize(resourceResumeEntities));

    }
}
