package org.jeecg.modules.yx.util;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.web.dto.RecommendMajorDTO;
import org.jeecg.modules.yx.constant.YxConstant;
import org.jeecg.modules.yx.entity.YxHistoryMajorEnroll;
import org.jeecg.modules.yx.entity.YxHistoryScoreControlLine;
import org.jeecg.modules.yx.entity.YxUserScore;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

/**
 * @Description 分数计算工具1
 * @Author ZhouWenTao
 * @Date 2023/11/9 13:30
 */
public class ScoreUtil {
    public static String getNowYear() {
        // 获取当前年
        return YxConstant.nowYear;
    }

    /**
     * 用于计算成绩时用到的历年时间
     *
     * @return
     */
    public static List<String> getCalOldYears() {
        return YxConstant.oldYearList;
    }

    /**
     * 用于列表上显示历年信息
     *
     * @return
     */
    public static List<String> getShowOldYears() {
        return YxConstant.showOldYearList;
    }

    /**
     * 计算 往年分数差之和 (往年的录取线-省控线)
     *
     * @param historyMajorEnrollList 往年录取分数
     * @return 往年分数差
     */
    public static BigDecimal computeHistoryMajorEnrollScoreLineDifference(List<YxHistoryMajorEnroll> historyMajorEnrollList) {
        BigDecimal sum = new BigDecimal("0");
        if (CollectionUtils.isEmpty(historyMajorEnrollList)) {
            return sum;
        }
        int yearNum = 0;
        BigDecimal controlLine = null;//文科-省控线
        BigDecimal admissionLine = null;//文科-录取线
        for (YxHistoryMajorEnroll yxHistoryMajorEnroll : historyMajorEnrollList) {
            controlLine = yxHistoryMajorEnroll.getControlLine();
            admissionLine = yxHistoryMajorEnroll.getAdmissionLine();
            sum = sum.add(admissionLine.subtract(controlLine));//录取线-省控线
            yearNum++;
        }
        /*if (wenFlag) {
            //文科生
        }else{
            //理科生
            BigDecimal scienceControlLine=null;//理科-省控线
            BigDecimal scienceAdmissionLine=null;//理科-录取线
            for (YxHistoryMajorEnroll yxHistoryMajorEnroll : historyMajorEnrollList) {
                scienceControlLine = yxHistoryMajorEnroll.getScienceControlLine();
                scienceAdmissionLine = yxHistoryMajorEnroll.getScienceAdmissionLine();
                sum=sum.add(scienceAdmissionLine.subtract(scienceControlLine));//录取线-省控线
                yearNum++;
            }
        }*/
        return sum;
    }

    /**
     * 计算历年录取分差（录取线 - 省控线），并返回平均分差
     *
     * @param rulesEnrollProbability 当前录取方式（如"文过专排"）
     * @param historyMajorEnrollList 历年录取数据
     * @return Map<String, Object> 包含平均分差（scoreDifference）
     */
    public static Map<String, Object> computeHistoryMajorEnrollScoreLineDifferenceWithRulesEnrollProbability(
            String rulesEnrollProbability,
            String probabilityOperator,
            List<YxHistoryMajorEnroll> historyMajorEnrollList) {
        // 1. 提前返回空结果，避免后续空指针
        if (CollectionUtils.isEmpty(historyMajorEnrollList)) {
            return Collections.singletonMap("scoreDifference", BigDecimal.ZERO);
        }
        // 2. 使用更高效的累加方式（避免频繁BigDecimal运算）
        BigDecimal sum = BigDecimal.ZERO;
        int validYearCount = 0;
        for (YxHistoryMajorEnroll enrollData : historyMajorEnrollList) {
            BigDecimal admissionLine = enrollData.getAdmissionLine();
            BigDecimal controlLine = enrollData.getControlLine();
            // 3. 跳过无效数据（录取线≤0）
            if (admissionLine.signum() <= 0) {
                continue;
            }
            // 4. 计算当前年份分差（录取线 - 省控线）
            BigDecimal currentDiff = admissionLine.subtract(controlLine);
            // 5. 特殊逻辑：高职高专（非体育类）需计算分差率（分差/省控线）
            boolean isVocationalCollege = "高职高专".equals(enrollData.getBatch());
            boolean isSportsMajor = "体育类".equals(enrollData.getMajorType());
            if(isSportsMajor){
                if("2024".equals(enrollData.getYear()) && !"专过文排".equals(enrollData.getRulesEnrollProbability())
                        && !"文过专排".equals(enrollData.getRulesEnrollProbability())) {
                    currentDiff = currentDiff.multiply(YxConstant.bigDecimal7p5);
                }else if("2024".equals(enrollData.getYear()) && "文过专排".equals(enrollData.getRulesEnrollProbability())) {
                    currentDiff = currentDiff.multiply(YxConstant.bigDecimal5);
                }else if("2023".equals(enrollData.getYear())) {
                    continue; // 26年 体育不看23年数据
                }else if(rulesEnrollProbability.equals(enrollData.getRulesEnrollProbability())){
                    currentDiff = admissionLine.subtract(controlLine);
                    sum = sum.add(currentDiff);
                    validYearCount++;
                    continue;
                }
            }else
            // 6. 非高职高专 or 体育类：检查录取方式是否一致  validYearCount >= 1 &&
            // !rulesEnrollProbability.equals(enrollData.getRulesEnrollProbability()) &&
            if (!probabilityOperator.equals(enrollData.getProbabilityOperator())) {
                continue; // 录取方式不一致，跳过
            }



            sum = sum.add(currentDiff);
            validYearCount++;
        }

        // 7. 计算平均分差（避免除零错误）
        BigDecimal averageDiff = validYearCount > 0
                ? sum.divide(new BigDecimal(validYearCount), 4, RoundingMode.HALF_UP)
                : BigDecimal.ZERO;

        return Collections.singletonMap("scoreDifference", averageDiff);
    }


    /**
     * 根据 当前年一致的录取方式，计算 往年分数差之和 (往年的录取线-省控线)
     */
    public static Map<String, Object> computeHistoryMajorEnrollScoreLineDifferenceWithRulesEnrollProbability_old(String rulesEnrollProbability, List<YxHistoryMajorEnroll> historyMajorEnrollList) {
        BigDecimal sum = new BigDecimal("0");//历年分差之和
        BigDecimal nowSum = new BigDecimal("0");
        Map<String, Object> data = new LinkedHashMap<>();
        data.put("scoreDifference", sum);
        if (CollectionUtils.isEmpty(historyMajorEnrollList)) {
            return data;
        }
        int yearNum = 0;
        BigDecimal controlLine = null;//文科-省控线
        BigDecimal admissionLine = null;//文科-录取线
        for (YxHistoryMajorEnroll yxHistoryMajorEnroll : historyMajorEnrollList) {
            controlLine = yxHistoryMajorEnroll.getControlLine();
            admissionLine = yxHistoryMajorEnroll.getAdmissionLine();
            // 如果录取分数线(admissionLine)小于等于0，就直接跳过当前循环，处理下一条数据
            if (admissionLine.compareTo(YxConstant.bigDecimal0) <= 0) {
                continue;
            }
            nowSum = admissionLine.subtract(controlLine);
            if (!"高职高专".equals(yxHistoryMajorEnroll.getBatch()) || "体育类".equals(yxHistoryMajorEnroll.getMajorType())) {
                if (yearNum >= 1 && !yxHistoryMajorEnroll.getRulesEnrollProbability().equals(rulesEnrollProbability)) {
                    //如果仅两年的录取原则一样，后面的不一样，不使用较旧的分数
                    continue;
                }
            } else {
                //体育之外的，如果是高职高专
                //将 分差/省控线
                nowSum = nowSum.divide(yxHistoryMajorEnroll.getControlLine(), 6, RoundingMode.HALF_UP);
            }
            sum = sum.add(nowSum);//录取线-省控线
            yearNum++;
        }
        if (yearNum != 0) {
            BigDecimal divide = sum.divide(new BigDecimal(yearNum), 4, RoundingMode.HALF_UP);
            data.put("scoreDifference", divide);
        }
        return data;
    }


    /**
     * 判断批次是否有权限计算
     *
     * @param nowBatch   当前成绩批次
     * @param majorBatch 专业批次
     */
    public static boolean hasComputeEnrollProbabilityPermissions(String nowBatch, String majorBatch) {
        if (StringUtils.isBlank(nowBatch) || StringUtils.isBlank(majorBatch)) {
            return false;
        }
        return true;
    }

    /**
     * 删除末尾的0
     *
     * @param input 文*0.05756700+专*0.1254200
     * @return 文*0.057567+专*0.12542
     */
    public static String replaceLastZeroChar(String input) {
        if (StringUtils.isBlank(input)) {
            return null;
        }
        input = input.replaceAll("(\\d+\\.\\d*?)0+(\\D|$)", "$1$2");
        input = input.replace("1.", "1").replace("文0.+", "");
        if (YxConstant.w1z1.equals(input) || YxConstant.w1jiaz1.equals(input)) {
            return "文+专";
        }
        return input;
    }

    public static BigDecimal decimal004 = new BigDecimal("0.04");
    public static BigDecimal decimal0067 = new BigDecimal("0.067");
    public static BigDecimal decimal0093 = new BigDecimal("0.093");
    public static BigDecimal decimal0133 = new BigDecimal("0.133");
    public static BigDecimal decimal02 = new BigDecimal("0.2");
    public static BigDecimal decimal03 = new BigDecimal("0.3");
    public static BigDecimal decimal0333 = new BigDecimal("0.333");

    public static BigDecimal decimal04 = new BigDecimal("0.4");
    public static BigDecimal decimal0467 = new BigDecimal("0.467");
    public static BigDecimal decimal05 = new BigDecimal("0.5");

    public static BigDecimal decimal06 = new BigDecimal("0.6");
    public static BigDecimal decimal0667 = new BigDecimal("0.667");


    public static BigDecimal decimal07 = new BigDecimal("0.7");

    public static BigDecimal decimal1 = new BigDecimal("1");


    /**
     * 折合 分数成绩 旧版
     *
     * @param rulesEnrollProbability 分数折合方式(专过文排/文过专排/文+专/专7文3/专5文5/专3文7)
     * @param culturalScore          文化成绩
     * @param professionalScore      专业成绩
     * @return 折合成绩
     */
    /*
    public static BigDecimal convertIntoScore(String rulesEnrollProbability, BigDecimal culturalScore, BigDecimal professionalScore) {
        BigDecimal score = new BigDecimal(0);
        if (rulesEnrollProbability == null || culturalScore == null || professionalScore == null) {
            return score;
        }
        switch (rulesEnrollProbability) {
            case "专过文排":
                score = culturalScore.multiply(decimal0133);
                break;
            case "文过专排":
                score = professionalScore.multiply(decimal0667);
                break;
            case "专7文3":
                score = culturalScore.multiply(decimal004).add(professionalScore.multiply(decimal0467));
                break;
            case "文5专5":
            case "专5文5":
                score = culturalScore.multiply(decimal0067).add(professionalScore.multiply(decimal0333));
                break;
            case "专3文7":
                score = culturalScore.multiply(decimal0093).add(professionalScore.multiply(decimal02));
                break;
            case "文+专":
            default:
                score = culturalScore.add(professionalScore);
                break;
        }
        score = score.divide(decimal1, 4, RoundingMode.HALF_UP);
        return score;
    }
*/

    /**
     * 转换主项成绩
     * 如果需要使用专业子项成绩时，则返回对应需要的分数
     * 如果需要主项成绩，则使用主项成绩分数
     */
    public static BigDecimal convertProfessionalCategoryMaster(YxUserScore activeCurrentUserScore, String operator, String professionalCategoryChildren) {
        String professionalCategory = activeCurrentUserScore.getProfessionalCategory();
        if (StringUtils.isNotBlank(professionalCategoryChildren)) {
            //当前有子项专业
            if ("音乐".equals(professionalCategory)) {
                if ("器乐".contains(professionalCategoryChildren)) {

                } else if ("声乐".contains(professionalCategoryChildren)) {

                }
            }
        }
        //使用主项成绩
        return activeCurrentUserScore.getProfessionalScore();
    }

    public static BigDecimal convertIntoScore(String rulesEnrollProbability, BigDecimal culturalScore, BigDecimal professionalScore, String operator) {
        BigDecimal score = new BigDecimal(0);
        if (rulesEnrollProbability == null || culturalScore == null || professionalScore == null) {
            return score;
        }

        try {
            if (StringUtils.isNotBlank(operator)) {
                score = new BigDecimal("0");
                String[] operators = operator.split("\\+");
                String[] split = null;
                for (String d : operators) {
                    split = d.split("\\*");
                    if (split[0].contains("文")) {
                        score = score.add(culturalScore.multiply(new BigDecimal(split[1])));
                    } else {
                        score = score.add(professionalScore.multiply(new BigDecimal(split[1])));
                    }
                }
            }
            score = score.divide(decimal1, 4, RoundingMode.HALF_UP);
        }catch (Exception e){
            throw new RuntimeException("计算分数出错: "+ rulesEnrollProbability +":"+ operator);
        }
        return score;
    }

    /**
     * 折合 分数成绩
     *
     * @param rulesEnrollProbability 分数折合方式(专过文排/文过专排/文+专/专7文3/专5文5/专3文7)
     * @param firstLevelDiscipline   一级学科
     * @param culturalScore          文化成绩
     * @param professionalScore      专业成绩
     * @param operator               运算符
     * @return 折合成绩
     */
    public static BigDecimal convertIntoScore(String rulesEnrollProbability, BigDecimal culturalScore, BigDecimal professionalScore, String firstLevelDiscipline, String operator) {
        BigDecimal score = new BigDecimal(0);
        if (rulesEnrollProbability == null || culturalScore == null || professionalScore == null) {
            return score;
        }

        if (StringUtils.isNotBlank(operator)) {
            score = new BigDecimal("0");
            String[] operators = operator.split("\\+");
            for (String d : operators) {
                String[] split = d.split("\\*");
                if (split[0].contains("文")) {
                    score = score.add(culturalScore.multiply(new BigDecimal(split[1])));
                } else {
                    score = score.add(professionalScore.multiply(new BigDecimal(split[1])));
                }
            }
        } else {
            switch (rulesEnrollProbability) {
                case "专过文排":
                    score = "1722224567122784257".equals(firstLevelDiscipline) ? culturalScore.multiply(decimal0133) : culturalScore;
                    break;
                case "文过专排":
                    score = "1722224567122784257".equals(firstLevelDiscipline) ? professionalScore.multiply(decimal0667) : professionalScore;
                    break;
                case "专7文3":
                    if ("1722224567122784257".equals(firstLevelDiscipline)) {
                        score = culturalScore.multiply(decimal004).add(professionalScore.multiply(decimal0467));
                    } else {
                        score = culturalScore.multiply(decimal07).add(professionalScore.multiply(decimal03));
                    }
                    break;
                case "文5专5":
                case "专5文5":
                    if ("1722224567122784257".equals(firstLevelDiscipline)) {
                        score = culturalScore.multiply(decimal0067).add(professionalScore.multiply(decimal0333));
                    } else {
                        score = culturalScore.multiply(decimal05).add(professionalScore.multiply(decimal05));
                    }
                    break;
                case "专3文7":
                    if ("1722224567122784257".equals(firstLevelDiscipline)) {
                        score = culturalScore.multiply(decimal0093).add(professionalScore.multiply(decimal02));
                    } else {
                        score = culturalScore.multiply(decimal07).add(professionalScore.multiply(decimal03));
                    }
                    break;
                case "专6文4":
                    if ("1722224567122784257".equals(firstLevelDiscipline)) {
                        score = culturalScore.multiply(decimal0093).add(professionalScore.multiply(decimal02));
                    } else {
                        score = culturalScore.multiply(decimal04).add(professionalScore.multiply(decimal06));
                    }
                    break;
                case "文+专":
                    score = culturalScore.add(professionalScore);
                    break;
                case "文过专排主科":
                    //主项成绩 *0.
                    score = professionalScore.multiply(decimal05);
                    break;
                default:
                    if (operator == null) {
                        score = culturalScore.add(professionalScore);
                    } else {
                        //System.out.println(operator);
                        score = new BigDecimal("0");
                        String[] operators = operator.split("\\+");
                        for (String d : operators) {
                            String[] split = d.split("\\*");
                            if (split[0].contains("文")) {
                                score = score.add(culturalScore.multiply(new BigDecimal(split[1])));
                            } else {
                                score = score.add(professionalScore.multiply(new BigDecimal(split[1])));
                            }
                        }
                    }
                    break;
            }
        }
        score = score.divide(decimal1, 4, RoundingMode.HALF_UP);
        return score;
    }

    /**
     * 折合 专业省控线
     *
     * @param rulesEnrollProbability 分数折合方式(专过文排/文过专排/文+专/专7文3/专5文5/专3文7)
     * @param controlLine            原省控线
     * @param specialControlLine     原专业分
     * @param operator               运算符
     * @return 折合省控线
     */
    public static BigDecimal covertIntoControlLine(String rulesEnrollProbability, BigDecimal controlLine, BigDecimal specialControlLine, String firstLevelDiscipline, String operator) {
        BigDecimal provincialControlLine = null;
        if (StringUtils.isNotBlank(operator)) {
            provincialControlLine = new BigDecimal("0");
            String[] operators = operator.split("\\+");
            for (String d : operators) {
                String[] split = d.split("\\*");
                if (split[0].contains("文")) {
                    provincialControlLine = provincialControlLine.add(controlLine.multiply(new BigDecimal(split[1])));
                } else {
                    provincialControlLine = provincialControlLine.add(specialControlLine.multiply(new BigDecimal(split[1])));
                }
            }
        } else {
            switch (rulesEnrollProbability) {
                case "专过文排":
                    provincialControlLine = controlLine.multiply(decimal0133);
                    provincialControlLine = "1722224567122784257".equals(firstLevelDiscipline) ? controlLine.multiply(decimal0133) : controlLine;
                    break;
                case "文过专排":
                    provincialControlLine = "1722224567122784257".equals(firstLevelDiscipline) ? specialControlLine.multiply(decimal0667) : specialControlLine;
                    break;
                case "专7文3":
                    if ("1722224567122784257".equals(firstLevelDiscipline)) {
                        provincialControlLine = controlLine.multiply(decimal004).add(specialControlLine.multiply(decimal0467));
                    } else {
                        provincialControlLine = controlLine.multiply(decimal07).add(specialControlLine.multiply(decimal03));
                    }
                    break;
                case "文5专5":
                case "专5文5":
                    if ("1722224567122784257".equals(firstLevelDiscipline)) {
                        provincialControlLine = controlLine.multiply(decimal0067).add(specialControlLine.multiply(decimal0333));
                    } else {
                        provincialControlLine = controlLine.multiply(decimal05).add(specialControlLine.multiply(decimal05));
                    }
                    break;
                case "专3文7":
                    if ("1722224567122784257".equals(firstLevelDiscipline)) {
                        provincialControlLine = controlLine.multiply(decimal0093).add(specialControlLine.multiply(decimal02));
                    } else {
                        provincialControlLine = controlLine.multiply(decimal07).add(specialControlLine.multiply(decimal03));
                    }
                    break;
                case "专6文4":
                    if ("1722224567122784257".equals(firstLevelDiscipline)) {
                        provincialControlLine = controlLine.multiply(decimal0093).add(specialControlLine.multiply(decimal02));
                    } else {
                        provincialControlLine = controlLine.multiply(decimal04).add(specialControlLine.multiply(decimal06));
                    }
                    break;
                case "文+专":
                    provincialControlLine = controlLine.add(specialControlLine);
                    break;
                default:
                    if (operator == null) {
                        provincialControlLine = controlLine.add(specialControlLine);
                    } else {
                        provincialControlLine = new BigDecimal("0");
                        String[] operators = operator.split("\\+");
                        for (String d : operators) {
                            String[] split = d.split("\\*");
                            if (split[0].contains("文")) {
                                provincialControlLine = provincialControlLine.add(controlLine.multiply(new BigDecimal(split[1])));
                            } else {
                                provincialControlLine = provincialControlLine.add(specialControlLine.multiply(new BigDecimal(split[1])));
                            }
                        }
                    }
            }
        }
        provincialControlLine = provincialControlLine.divide(decimal1, 4, RoundingMode.HALF_UP);
        return provincialControlLine;
    }

    /**
     * 转换成绩为分数批次段
     *
     * @param culturalScore     文化成绩
     * @param professionalScore 专业成绩
     * @return
     */
    public static String conversionScoreBatch(BigDecimal culturalScore, BigDecimal professionalScore, List<YxHistoryScoreControlLine> historyScoreControlLineList) {
        double wenScore = culturalScore.doubleValue();
        double zhuanScore = professionalScore.doubleValue();
        String batch = "高职高专";

        if (CollectionUtils.isNotEmpty(historyScoreControlLineList)) {
            for (YxHistoryScoreControlLine yxHistoryScoreControlLine : historyScoreControlLineList) {
                if (culturalScore.compareTo(yxHistoryScoreControlLine.getCulturalScore()) >= 0 && professionalScore.compareTo(yxHistoryScoreControlLine.getSpecialScore()) >= 0) {
                    batch = yxHistoryScoreControlLine.getBatch();
                    break;
                }
            }
        }
        return batch;
    }


    /**
     * 判断是否过省控线
     *
     * @param rulesEnrollProbability 录取方式
     * @param culturalScore          当前文化分
     * @param professionalScore      当前专业分
     * @param culturalControlLine    当前文化省控线
     * @param specialControlLine     当前专业省控线
     * @return true/false 过/没过
     */
    public static boolean crossingControlLine(String rulesEnrollProbability, BigDecimal culturalScore, BigDecimal professionalScore, BigDecimal culturalControlLine, BigDecimal specialControlLine) {
        if (YxConstant.culturalControlLineGuo.equals(rulesEnrollProbability)) {
            return culturalScore.compareTo(culturalControlLine) >= 0;
        } else if (YxConstant.specialControlLineGuo.equals(rulesEnrollProbability)) {
            return professionalScore.compareTo(specialControlLine) >= 0;
        } else if (YxConstant.culturalControlLineGuo2.equals(rulesEnrollProbability)) {
            return culturalScore.compareTo(specialControlLine) >= 0;
        }
        return culturalScore.compareTo(culturalControlLine) >= 0 && professionalScore.compareTo(specialControlLine) >= 0;
//        return true;
    }

    /**
     * 将专业类别转为 子类别
     */
    public static List<String> checkProfessionalCategoryToChildrenList(String professionalCategoryChildren) {
        if (StringUtils.isNotBlank(professionalCategoryChildren)) {
            return Arrays.asList(professionalCategoryChildren.split(","));
        }
        return null;
    }

    /**
     * 其他录取要求
     *
     * @param professionalScore
     * @param activeCurrentUserScore
     * @param recommendMajorDTO
     * @return
     */
    public static boolean otherScoreJudge(BigDecimal professionalScore, YxUserScore activeCurrentUserScore, RecommendMajorDTO recommendMajorDTO) {
        if (recommendMajorDTO != null) {
//            //语文成绩判断
//            if (recommendMajorDTO.getChineseScoreLimitation() != null && (activeCurrentUserScore.getChineseScore() == null || activeCurrentUserScore.getChineseScore().compareTo(recommendMajorDTO.getChineseScoreLimitation()) < 0)) {
//                return false;
//            }
            //外语成绩判断
            if (recommendMajorDTO.getEnglishScoreLimitation() != null && (activeCurrentUserScore.getEnglishScore() == null || activeCurrentUserScore.getEnglishScore().compareTo(recommendMajorDTO.getEnglishScoreLimitation()) < 0)) {
                return false;
            }
            //文化成绩判断
            if (recommendMajorDTO.getCulturalScoreLimitation() != null && (activeCurrentUserScore.getCulturalScore() == null || activeCurrentUserScore.getCulturalScore().compareTo(recommendMajorDTO.getCulturalScoreLimitation()) < 0)) {
                return false;
            }
            if (StringUtils.isNotBlank(recommendMajorDTO.getMajorType()) && "音乐类".equals(recommendMajorDTO.getMajorType()) && StringUtils.isNotBlank(recommendMajorDTO.getMajorTypeChild())) {
                if ("音乐表演".equals(recommendMajorDTO.getMajorTypeChild())) {
                    if ("器乐".equals(recommendMajorDTO.getMainSubjects())) {
                        //统考成绩判断
                        if (recommendMajorDTO.getProfessionalScoreLimitation() != null && (activeCurrentUserScore.getYybyqy() == null || activeCurrentUserScore.getYybyqy().compareTo(recommendMajorDTO.getProfessionalScoreLimitation()) < 0)) {
                            return false;
                        }
                    }else{
                        //统考成绩判断
                        if (recommendMajorDTO.getProfessionalScoreLimitation() != null && (activeCurrentUserScore.getYybysy() == null || activeCurrentUserScore.getYybysy().compareTo(recommendMajorDTO.getProfessionalScoreLimitation()) < 0)) {
                            return false;
                        }
                    }
                } else {
                    //统考成绩判断
                    if (recommendMajorDTO.getProfessionalScoreLimitation() != null && (activeCurrentUserScore.getYyjy() == null || activeCurrentUserScore.getYyjy().compareTo(recommendMajorDTO.getProfessionalScoreLimitation()) < 0)) {
                        return false;
                    }
                }
            }else if (StringUtils.isNotBlank(recommendMajorDTO.getMajorType()) && "表演类".equals(recommendMajorDTO.getMajorType()) && StringUtils.isNotBlank(recommendMajorDTO.getMajorTypeChild())) {
                if ("服装表演".equals(recommendMajorDTO.getMajorTypeChild())) {
                    //统考成绩判断
                    if (recommendMajorDTO.getProfessionalScoreLimitation() != null && (activeCurrentUserScore.getFzby() == null || activeCurrentUserScore.getFzby().compareTo(recommendMajorDTO.getProfessionalScoreLimitation()) < 0)) {
                        return false;
                    }
                }else if ("戏剧影视表演".equals(recommendMajorDTO.getMajorTypeChild())) {
                    //统考成绩判断
                    if (recommendMajorDTO.getProfessionalScoreLimitation() != null && (activeCurrentUserScore.getXjysby() == null || activeCurrentUserScore.getXjysby().compareTo(recommendMajorDTO.getProfessionalScoreLimitation()) < 0)) {
                        return false;
                    }
                } else {
                    //统考成绩判断
                    if (recommendMajorDTO.getProfessionalScoreLimitation() != null && (activeCurrentUserScore.getXjysdy() == null || activeCurrentUserScore.getXjysdy().compareTo(recommendMajorDTO.getProfessionalScoreLimitation()) < 0)) {
                        return false;
                    }
                }
            } else{
                // 其他专业
                //统考成绩判断
                if (recommendMajorDTO.getProfessionalScoreLimitation() != null && (activeCurrentUserScore.getProfessionalScore() == null || activeCurrentUserScore.getProfessionalScore().compareTo(recommendMajorDTO.getProfessionalScoreLimitation()) < 0)) {
                    return false;
                }
            }

        }
        return true;
    }

    /**
     * 统一计算录取率方法
     *
     * @param nowYearDiff          当前年分差
     * @param historyThreeYearDiff 去年分差
     * @return 录取率
     */
    public static BigDecimal commonCheckEnrollProbability(BigDecimal nowYearDiff, BigDecimal historyThreeYearDiff) {
        BigDecimal enrollProbability = null;
        if (nowYearDiff.compareTo(YxConstant.bigDecimal0) == 0 && historyThreeYearDiff.compareTo(YxConstant.bigDecimal0) > 0) {
            //当前年的分差为0，去年分差不为0： 75/去年的线差
            enrollProbability = YxConstant.bigDecimal75.divide(historyThreeYearDiff, 4, RoundingMode.HALF_UP);
        } else if (nowYearDiff.compareTo(YxConstant.bigDecimal0) == 0 && historyThreeYearDiff.compareTo(YxConstant.bigDecimal0) <= 0) {
            //当前年分差为0，去年分差为0
            enrollProbability = YxConstant.bigDecimal50;//录取率50
        } else if (nowYearDiff.compareTo(YxConstant.bigDecimal0) > 0 && historyThreeYearDiff.compareTo(YxConstant.bigDecimal0) <= 0) {
            //当前年分差不为0，去年分差为0：默认去年的分差为1 .multiply(YxConstant.bigDecimal075)
            enrollProbability = nowYearDiff.multiply(YxConstant.bigDecimal100).multiply(YxConstant.bigDecimal075);
        } else if (nowYearDiff.compareTo(YxConstant.bigDecimal0) < 0 && historyThreeYearDiff.compareTo(YxConstant.bigDecimal0) <= 0) {
            enrollProbability = YxConstant.bigDecimal0;
        } else {
            //当前年分差不为0，去年分差也不为0：（当前年分差/去年分差）*0.75
            enrollProbability = nowYearDiff.divide(historyThreeYearDiff, 4, RoundingMode.HALF_UP).multiply(YxConstant.bigDecimal100);
            //录取率*0.75
            enrollProbability = enrollProbability.multiply(YxConstant.bigDecimal075);
        }
        return enrollProbability;
    }

    public static BigDecimal commonCheckEnrollProbabilityBeilv(BigDecimal enrollProbability) {
        if (enrollProbability.compareTo(YxConstant.bigDecimal150) > 0) {
            enrollProbability = YxConstant.bigDecimal95x;
        } else if (enrollProbability.compareTo(YxConstant.bigDecimal100) > 0) {
            enrollProbability = YxConstant.bigDecimal85x;
        } else if (enrollProbability.compareTo(YxConstant.bigDecimal0) <= 0) {
            enrollProbability = YxConstant.bigDecimal0;
        }
        return enrollProbability;
    }

}
