package com.docus.server.report.config;

import com.docus.server.report.util.TableJsonRead;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 应用业务配置
 * @author wyb
 */

public class SdRyReportHandledConfig {
    private final SdRyReportSystem sdRyReportSystem;
    @Data
    private static  class SdRyReportSystem{
        /**
         * 需要阻塞的报告来源系统
         */
        private  List<String> blocking = new ArrayList<>();
        /**
         * 不处理的报告来源系统
         */
        private List<String> notHandled = new ArrayList<>();
    }
    public SdRyReportHandledConfig(){
        TableJsonRead jsonRead = new TableJsonRead();
        this.sdRyReportSystem= jsonRead.Read("data-config", "sdry-report-system.json", SdRyReportSystem.class);
    }
    public  boolean isBlocking(String systemName){
        if(this.sdRyReportSystem!=null){
            List<String> blocking = this.sdRyReportSystem.getBlocking();
            return blocking.contains(systemName);
        }
        return false;
    }

    public  boolean isNotHandled(String systemName){
        if(this.sdRyReportSystem!=null){
            List<String> notHandled = this.sdRyReportSystem.getNotHandled();
            return notHandled.contains(systemName);
        }
        return false;
    }

    public static void main(String[] args) {
        SdRyReportHandledConfig sdRyReportHandledConfig = new SdRyReportHandledConfig();
        System.out.println(sdRyReportHandledConfig.sdRyReportSystem);
        System.out.println(sdRyReportHandledConfig.isNotHandled("lis"));
        System.out.println(sdRyReportHandledConfig.isNotHandled("yx"));
        System.out.println(sdRyReportHandledConfig.isBlocking("yx"));
        System.out.println(sdRyReportHandledConfig.isBlocking("lis"));
    }

}
