/*
 * 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 GJB548C13Executor extends BaseExecutor implements IExperimentReviewRuleExecutor {
    @Override
    public String getProcessType() {
        return ExperimentReviewProcessType.GJB548C;
    }

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

    /**
     * 13
     *
     * 未使用干冰保存
     *
     * 可能高估器件的抗辐射性能
     *
     * 氧化物陷阱电荷在干冰条件下退火减弱
     *
     * 未使用干冰保存的适用范围：如果应用环境比干冰环境温度低，采用应用环境温度进行保存
     *
     * 在退火过程的备注中，有“保存”字段但是没有“干冰”字段，启动这条评定建议
     *
     * @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;

        List<ExperimentAnnealProcess> experimentAnnealProcessList = experimentAnnealProcessService.getByExperimentId(experiment.getId());

        for (ExperimentAnnealProcess experimentAnnealProcess : experimentAnnealProcessList) {
            String comment = experimentAnnealProcess.getComment();
            if (StringUtils.contains(comment, "保存") && !StringUtils.contains(comment, "干冰")) {
                condition1 = true;
                break;
            }
        }
        if (condition1) {
            return ExperimentReviewResultEnum.HIGH;
        }
        return ExperimentReviewResultEnum.ITEM_PASS;
    }
}