package com.njcn.prepare.executor;

import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenDTO;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
import com.njcn.prepare.harmonic.service.mysql.dim.IRDimBusGlobalDService;
import com.njcn.prepare.harmonic.service.mysql.dim.IRDimObjEventDService;
import com.njcn.prepare.harmonic.service.mysql.dim.IRDimObjEventMService;
import com.njcn.prepare.harmonic.service.mysql.dim.IRDimObjEventYService;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept;
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;

import java.util.List;
import java.util.Objects;

/**
 * pqs
 *
 * @author cdf
 * @date 2023/11/17
 */
@LiteflowComponent
@RequiredArgsConstructor
public class PmsDimExecutor extends BaseExecutor{

    private final DeptFeignClient deptFeignClient;

    private final CommTerminalGeneralClient commTerminalGeneralClient;
    private final IRDimObjEventDService irDimObjEventDService;
    private final IRDimObjEventMService irDimObjEventMService;
    private final IRDimObjEventYService irDimObjEventYService;

    private final IRDimBusGlobalDService irDimBusGlobalDService;

    @LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "dimBusGlobalAccess", nodeType = NodeTypeEnum.COMMON)
    public boolean dimBusGlobalAccess(NodeComponent bindCmp) {
        return isAccess(bindCmp);
    }
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "dimBusGlobalAccess", nodeType = NodeTypeEnum.COMMON)
    public void dimBusGlobalProcess(NodeComponent bindCmp) {
        String tag = bindCmp.getTag();
        CalculatedParam calculatedParam = bindCmp.getRequestData();
        if (Objects.equals(tag,"r_dim_bus_global_d")){
            //日表
            irDimBusGlobalDService.globalCalBusBarDay(calculatedParam);
        } else if (Objects.equals(tag,"r_dim_bus_global_m")) {
            //数据补招不执行非日表算法
            if (!calculatedParam.isRepair()) {
                //月表
                //irDimBusGlobalDService.globalCalBusBarMonth(calculatedParam);
            }
        } else if (Objects.equals(tag,"r_dim_bus_global_y")) {
            //数据补招不执行非日表算法
            if (!calculatedParam.isRepair()) {
                //季表
                irDimBusGlobalDService.globalCalBusBarDay(calculatedParam);
            }
        }
        irDimBusGlobalDService.globalCalBusBarDay(bindCmp.getRequestData());
    }

    /********************************************算法负责人:xy***********************************************************/
    @LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "rDimObjEvent", nodeType = NodeTypeEnum.COMMON)
    public boolean rDimObjEventAccess(NodeComponent bindCmp) {
        return isAccess(bindCmp);
    }
    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rDimObjEvent", nodeType = NodeTypeEnum.COMMON)
    public void rDimObjEventProcess(NodeComponent bindCmp) {
        String tag = bindCmp.getTag();
        CalculatedParam<DeptGetChildrenDTO> calculatedParam = bindCmp.getRequestData();
        if (tag.equalsIgnoreCase("r_dim_obj_event_d")) {
            //日表
            irDimObjEventDService.eventUserRatio(calculatedParam);
        } else if (tag.equalsIgnoreCase("r_dim_obj_event_m")) {
            //数据补招不执行非日表算法
            if (!calculatedParam.isRepair()) {
                //月表
                irDimObjEventMService.eventUserRatioM(calculatedParam);
            }
        }else if (tag.equalsIgnoreCase("r_dim_obj_event_y")) {
            //数据补招不执行非日表算法
            if (!calculatedParam.isRepair()) {
                //年表
                irDimObjEventYService.eventUserRatioY(calculatedParam);
            }
        }
    }
    /*********************************************结束******************************************************************/

}
