/*
 * Ant Group
 * Copyright (c) 2004-2025 All Rights Reserved.
 */
package org.jeecg.modules.database.service.executor;

import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.database.constant.ExperimentReviewProcessType;
import org.jeecg.modules.database.constant.ExperimentReviewResultEnum;
import org.jeecg.modules.database.entity.*;
import org.jeecg.modules.database.service.IExperimentReviewRuleExecutor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author lise
 */

@Component
public class ESCC2290005Executor extends BaseExecutor implements IExperimentReviewRuleExecutor {
    @Override
    public String getProcessType() {
        return ExperimentReviewProcessType.ESCC229000;
    }

    @Override
    public int getPriority() {
        return 5;
    }

    /**
     * 7
     *
     * 不需要进行加速退火但进行了加速退火的试验
     *
     * 可能低估器件的抗辐射性能
     *
     * 退火过程中的界面态增长将可能导致元器件的后损伤
     *
     * 不包含MOS单元器件
     *
     * 退火过程中有高温退火（退火温度为100℃识别为室温退火）这个过程；同时在评定流程中询问用户是否需要加速退火，用户选否，启动这条评定建议
     *
     * @param experiment
     * @param sampleInfo
     * @param experimentReview
     * @return
     */
    @Override
    public String execute(Experiment experiment, ExperimentSampleInfo sampleInfo, ExperimentReview experimentReview) {
        experimentService.fetchExperimentDetail(experiment);
        boolean condition1 = false, condition2 = false;
        if (StringUtils.equals(experimentReview.getNeedAnneal(), "N")) {
            condition1 = true;
        }
        List<ExperimentAnnealProcess> experimentAnnealProcessList = experimentAnnealProcessService.getByExperimentId(experiment.getId());
        for (ExperimentAnnealProcess experimentAnnealProcess : experimentAnnealProcessList) {
            if (experimentAnnealProcess.getAnnealTemperature().equals("100")) {
                condition2 = true;
                break;
            }
        }
        if (condition1 && condition2) {
            return ExperimentReviewResultEnum.LOW;
        }
        return ExperimentReviewResultEnum.ITEM_PASS;
    }
}