package com.njcn.prepare.executor;

import com.njcn.device.biz.pojo.dto.DeptGetBusBarDTO;
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
import com.njcn.prepare.harmonic.service.mysql.dim.IRDimVoltageDService;
import com.njcn.prepare.harmonic.service.mysql.dim.IRDimVoltageMService;
import com.njcn.prepare.harmonic.service.mysql.dim.IRDimVoltageYService;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import lombok.RequiredArgsConstructor;

/**
 * pqs
 *
 * @author xuyang
 * @date 2023/11/27
 */
@LiteflowComponent
@RequiredArgsConstructor
public class BusBarExecutor extends BaseExecutor{
    private final IRDimVoltageDService irDimVoltageDService;
    private final IRDimVoltageMService irDimVoltageMService;
    private final IRDimVoltageYService irDimVoltageYService;

    @LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "rBusbarVoltage", nodeType = NodeTypeEnum.COMMON)
    public boolean rBusbarVoltageAccess(NodeComponent bindCmp) {
        return isAccess(bindCmp);
    }
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rBusbarVoltage", nodeType = NodeTypeEnum.COMMON)
    public void rBusbarVoltageProcess(NodeComponent bindCmp) {
        String tag = bindCmp.getTag();
        CalculatedParam<DeptGetBusBarDTO> calculatedParam = bindCmp.getRequestData();
        if (tag.equalsIgnoreCase("r_dim_voltage_d")) {
            //日表
            irDimVoltageDService.busbarVoltageD(calculatedParam);
        } else if (tag.equalsIgnoreCase("r_dim_voltage_m")) {
            //数据补招不执行非日表算法
            if (!calculatedParam.isRepair()) {
                //月表
                irDimVoltageMService.busbarVoltageM(calculatedParam);
            }
        }else if (tag.equalsIgnoreCase("r_dim_voltage_y")) {
            //数据补招不执行非日表算法
            if (!calculatedParam.isRepair()) {
                //年表
                irDimVoltageYService.busbarVoltageY(calculatedParam);
            }
        }
    }

}
