|
|
|
@ -2,6 +2,12 @@ package cn.estsh.i3plus.pojo.base.enumutil;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description :
|
|
|
|
|
* @Reference :
|
|
|
|
@ -2567,7 +2573,7 @@ public class WmsEnumUtil {
|
|
|
|
|
*/
|
|
|
|
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
|
|
|
|
public enum WMS_TRANS_QUAN_STATUS {
|
|
|
|
|
CREATE(1, "创建"), SUCCESS(10, "处理成功"),FAIL(30,"处理失败");
|
|
|
|
|
CREATE(1, "创建"), SUCCESS(10, "处理成功"), FAIL(30, "处理失败");
|
|
|
|
|
|
|
|
|
|
private int value;
|
|
|
|
|
private String description;
|
|
|
|
@ -2702,4 +2708,56 @@ public class WmsEnumUtil {
|
|
|
|
|
return description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Map<String, Object> getEnumByName(String enumName) throws Exception{
|
|
|
|
|
Class innerClazz[] = WmsEnumUtil.class.getDeclaredClasses();// 获取常量类中的所有内部类
|
|
|
|
|
Class<Enum> clazz;
|
|
|
|
|
Enum[] enumConstants;
|
|
|
|
|
|
|
|
|
|
Map<String, Object> enumMap;// 枚举类
|
|
|
|
|
List<Map<String, Object>> values;// 枚举实例【enumName:{“”:},{“”:},{“”:}】
|
|
|
|
|
Map<String, Object> value;// 枚举实例属性
|
|
|
|
|
|
|
|
|
|
Method getValue;
|
|
|
|
|
Method getCode;
|
|
|
|
|
Method getDescription;
|
|
|
|
|
|
|
|
|
|
// 遍历内部类
|
|
|
|
|
String simpleName;//内部类的类名
|
|
|
|
|
for (Class class1 : innerClazz) {
|
|
|
|
|
//获取内部内的类名
|
|
|
|
|
simpleName = class1.getSimpleName();
|
|
|
|
|
if (simpleName.equals(enumName)) {
|
|
|
|
|
// 判断类是不是枚举类
|
|
|
|
|
clazz = (Class<Enum>) Class.forName("cn.estsh.i3plus.pojo.base.enumutil.WmsEnumUtil$" + simpleName);
|
|
|
|
|
|
|
|
|
|
// 枚举类方法初始化
|
|
|
|
|
getCode = null;
|
|
|
|
|
try {
|
|
|
|
|
getCode = clazz.getMethod("getCode");
|
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
|
}
|
|
|
|
|
getValue = clazz.getMethod("getValue");
|
|
|
|
|
getDescription = clazz.getMethod("getDescription");
|
|
|
|
|
|
|
|
|
|
// 获取所有枚举实例
|
|
|
|
|
enumConstants = clazz.getEnumConstants();
|
|
|
|
|
enumMap = new HashMap<>();
|
|
|
|
|
values = new ArrayList<>();
|
|
|
|
|
for (Enum enum1 : enumConstants) {
|
|
|
|
|
value = new HashMap<>();
|
|
|
|
|
value.put("value", getValue.invoke(enum1));
|
|
|
|
|
if (getCode != null) {
|
|
|
|
|
value.put("code", getCode.invoke(enum1));
|
|
|
|
|
}
|
|
|
|
|
value.put("description", getDescription.invoke(enum1));
|
|
|
|
|
values.add(value);
|
|
|
|
|
}
|
|
|
|
|
enumMap.put("enumName", clazz.getSimpleName());
|
|
|
|
|
enumMap.put("valuesList", values);
|
|
|
|
|
return enumMap;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|