package com.ximai.mes.pro.schedule.strategy;

import cn.hutool.core.util.NumberUtil;
import com.ximai.mes.pro.schedule.Equipment;
import com.ximai.mes.pro.schedule.IOperationTimeCalculator;
import com.ximai.mes.pro.schedule.TaskSchedulingContext;

import java.util.List;

/**
 * 根据工序要求设备功能点评估设备，在满足工序功能点基础上，设备功能点越少，越优先匹配
 * NumberUtil.max(10-N, 0)
 * N=设备已有功能点
 *
 */
public class EvaluateEquipmentFunction implements EvaluateEquipment{
    @Override
    public double evaluate(TaskSchedulingContext context, IOperationTimeCalculator.OperationTimePlan operationTimePlan
            , List<TaskSchedulingContext.TaskSchedulingResultContext> scheduleResult) {
        int functionCount = 0;
        Equipment.EquipmentFunction equipmentFunction = context.getEquipment().getEquipmentFunction();
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForEdgeOpening())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForPasteComposite())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForThermalComposite())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForLabeling())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForBuckleUp())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForCreasing())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForOrgan())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForThermalCutting())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForThermalSelfFusion())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForMolarTooth())){
            functionCount++;
        }
        if("Y".equalsIgnoreCase(equipmentFunction.getSacmForSlitting())){
            functionCount++;
        }
        return NumberUtil.max(10-functionCount, 0);
    }

    @Override
    public int weight() {
        return 1;
    }

}
