package jnpf.cultivate.mock;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import jnpf.cultivate.service.CultivateIdentifyApplyService;
import jnpf.cultivate.service.FtbCultivateExamService;
import jnpf.enums.cultivate.ApplySourceEnum;
import jnpf.model.cultivate.dto.identify.IdentifyApplySaveDto;
import jnpf.model.cultivate.req.exam.SaveExamReq;
import jnpf.permission.vo.v2.user.UserBoundVO;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@UtilityClass
public class CultivateMockUtils {

    String practicalAppraisalMockData = "{\"tableId\":\"712666643662366213\",\"beIdentifyUserId\":\"712295601244726981\",\"identifyUserId\":\"712295601399916229\",\"appraisalResults\":1,\"beIdentifyOrgId\":\"712278038133597893\",\"beIdentifyPostId\":\"665102345222415301\",\"beIdentifyPostRankId\":\"1895297695136899073\"}";

    /**
     * 实操鉴定模拟数据
     */
    public static void mockPracticalAppraisal(String userId, UserBoundVO usersBoundData, CultivateIdentifyApplyService applyService) {
        IdentifyApplySaveDto req = JSON.parseObject(practicalAppraisalMockData, IdentifyApplySaveDto.class);
        req.setSource(ApplySourceEnum.SDFQ.getCode());
        req.setBeIdentifyUserId(userId);
        req.setBeIdentifyOrgId(usersBoundData.getOrganizeId());
        req.setBeIdentifyPostId(usersBoundData.getPositionId());
        req.setBeIdentifyPostRankId(usersBoundData.getGradeId());
        req.setAppraisalResults(0);
        if (!req.getBeIdentifyUserId().equals(req.getIdentifyUserId())) {
            try {
                applyService.applyDataSave(req);
            } catch (Exception e){
                log.error("实操鉴定模拟数据保存失败：{}", e.getMessage());
            }
        }
    }

    String customExaminationMockData = "{\"examName\":\"企业文化考试\",\"paperId\":\"1943126977902878721\",\"examType\":1,\"id\":null,\"postAndPositionList\":[],\"examlimitation\":0,\"examTime\":3600,\"passType\":1,\"passMark\":60,\"excellentType\":1,\"excellentMark\":80,\"description\":\"\",\"reviewer\":\"1\",\"reviewerAppoint\":\"712295601399916229\",\"reviewerRole\":\"\",\"examMemberId\":\"712307395245893253\",\"reviewerAppointList\":[],\"makeUpCount\":null,\"waterMark\":0,\"cutScreen\":0,\"maxCutScreenCount\":0,\"screenshot\":0,\"copyAndPaste\":0,\"openOverTime\":0,\"overTime\":null,\"allowSelectDetail\":0,\"allowChangeLastQuestion\":0,\"reExamFrequencyType\":null,\"reExamFrequencyNum\":null,\"examQuestionRandom\":0,\"reviewerAppointListConfig\":[{\"userId\":\"712295601399916229\",\"userName\":\"运营总监·演示\",\"orgName\":\"东大路店\",\"orgId\":\"712278038133597893\",\"positionId\":\"665101627140792261\",\"positionName\":\"运营总监\",\"rankId\":\"1895296977056915458\",\"rankName\":\"初级\"}]}";

    /**
     * 自定义考试
     */
    public static void mockCustomExamination(String userId,  UserBoundVO usersBoundData, FtbCultivateExamService examService) {
        SaveExamReq req = JSON.parseObject(customExaminationMockData, SaveExamReq.class);
        req.setExamMemberId(userId);
        req.setExamName("企业文化考试-" + usersBoundData.getUserName()+ IdWorker.getId());
        try {
            examService.insertData(req);
        } catch (Exception e){
            log.error("自定义考试模拟数据保存失败：{}", e.getMessage());
        }
    }

}
