package cn.com.qmth.examcloud.tool.service.exam_record_data_audit;

import cn.com.qmth.examcloud.tool.config.SysProperty;
import cn.com.qmth.examcloud.tool.entity.TaskEntity;
import cn.com.qmth.examcloud.tool.service.CommonService;
import cn.com.qmth.examcloud.tool.service.TaskService;
import cn.com.qmth.examcloud.tool.utils.HttpHelper;
import cn.com.qmth.examcloud.tool.vo.user.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

@Component
public class ExamRecordDataAuditTask implements TaskService {

    private final static Logger log = LoggerFactory.getLogger(ExamRecordDataAuditTask.class);

    @Autowired
    private SysProperty sysProperty;

    @Autowired
    private CommonService commonService;

    @Override
    public void start(TaskEntity task) {
        // this.execute(loginUser, task);
    }

    /**
     * 将某些考试记录重审为违纪
     */
    public void execute(User loginUser) {
        Set<Long> examRecordDataIds = new HashSet<>();
        // examRecordDataIds.add(52801472L);
        // examRecordDataIds.add(52796160L);
        // examRecordDataIds.add(52794061L);
        // examRecordDataIds.add(52791705L);
        // examRecordDataIds.add(52801046L);
        // examRecordDataIds.add(52793413L);

        String url = loginUser.getServerUrl() + "/api/ecs_oe_admin/exam/audit/redoAudit";

        Map<String, String> headers = new HashMap<>();
        headers.put("key", loginUser.getKey());
        headers.put("token", loginUser.getToken());

        Map<String, Object> params = new HashMap<>();
        params.put("examRecordDataIds", examRecordDataIds);
        params.put("illegallyTypeId", 6L);// 违纪ID，通过页面查询获取
        params.put("disciplineDetail", "sys");// 选填
        params.put("isPass", false);// 审核是否通过
        params.put("skip", true);

        String result = HttpHelper.post(url, headers, params);
        log.info(result);
    }

}
