1、建立枚举类
public enum billTypeEnum {
INDENT(1, "d_indent", "", "需求单"),
INDENTSQ(21, "p0670", "", "需求申请单"),
QUOTA(2, "d_quota", "1", "配货单"),
SELL(4, "d_sell", "2", "发货单");
@ApiModelProperty(value = "系统单据类型", dataType = "int")
private int systemType;
@ApiModelProperty(value = "主单D/P表名称", dataType = "String")
private String dTableName;
@ApiModelProperty(value = "参照单的系统单据类型,有多种参照单时以','分隔", dataType = "String")
private String czSystemType;
@ApiModelProperty(value = "单据名称", dataType = "String")
private String billName;
billTypeEnum(int systemType, String dTableName, String czSystemType, String billName) {
this.systemType = systemType;
this.dTableName = dTableName;
this.czSystemType = czSystemType;
this.billName = billName;
}
public int getSystemType() {
return systemType;
}
public void setSystemType(int systemType) {
this.systemType = systemType;
}
public String getdTableName() {
return dTableName;
}
public void setdTableName(String dTableName) {
this.dTableName = dTableName;
}
public String getCzSystemType() {
return czSystemType;
}
public void setCzSystemType(String czSystemType) {
this.czSystemType = czSystemType;
}
public String getBillName() {
return billName;
}
public void setBillName(String billName) {
this.billName = billName;
}
}
2、遍历枚举值
// 获取枚举值
billTypeEnum[] values = billTypeEnum.values();
// 遍历枚举
for (int i = 0; i < values.length; i++) {
int systemType = values[i].getSystemType();
if (systemType == billType) {
return values[i];
}
}