PgEnums.java 1.4 KB
package com.skua.modules.threedimensional.enums;

import com.skua.modules.threedimensional.service.IPgService;
import com.skua.modules.threedimensional.service.impl.OtherPgServiceImpl;
import com.skua.modules.threedimensional.service.impl.SZPgServiceImpl;
import com.skua.modules.threedimensional.service.impl.WSCLPgServiceImpl;
import org.apache.commons.lang.StringUtils;

/**
 * @author sonin
 * @date 2021/10/13 19:08
 */
public enum PgEnums {

    SZ("SZ", SZPgServiceImpl.class),
    WSCL("JSLJLL,CSLJLL", WSCLPgServiceImpl.class);

    private String type;
    private Class<? extends IPgService> clazz;

    PgEnums(String type, Class<? extends IPgService> clazz) {
        this.type = type;
        this.clazz = clazz;
    }

    public static Class<? extends IPgService> getClazz(String groupType, String dictIds) {
        Class<? extends IPgService> result = OtherPgServiceImpl.class;
        // 优先从groupType查询
        if (StringUtils.isNotEmpty(groupType)) {
            for (PgEnums item : PgEnums.values()) {
                if (groupType.equals(item.type)) {
                    result = item.clazz;
                    break;
                }
            }
        } else {
            // 再从dictIds查询
            for (PgEnums item : PgEnums.values()) {
                if (dictIds.equals(item.type)) {
                    result = item.clazz;
                    break;
                }
            }
        }
        return result;
    }

}