/**
* 出入库类型枚举
*/
public enum viewField {
qianshouruQuantity(1, null), // 1.签收入库
tuihuoruQuantity(2, 7), // 2.退货入库
shangyangruQuantity(3, 10),// 3.上样入库
xiayangruQuantity(3, 11),// 4.下样入库
diaoboruQuantity(3, 12),//5.调拨入库
panyingruQuantity(2, 13),//6.盘盈入库
qitaruQuantity(2, 22),//7.其它入库/期初调整
lingshouchuQuantity(9, 1),//8.零售出库
dianshangchuQuantity(9, 2),//9.电商出库
shangyangchuQuantity(9, 3),//10.上样出库
xiayangchuQuantity(9, 4),//11.下样出库
diaobochuQuantity(9, 5),//12.调拨出库
pankuichuQuantity(1, 6),//13.盘亏出库
qitachuQuantity(1, 14);//14.其他出库
private Integer billType; // 枚举value字段
private Integer outinType; // 枚举value字段
viewField(Integer billType, Integer outinType) { // 构造初始化赋值
this.billType = billType;
this.outinType = outinType;
}
public Integer getBillType() {
return billType;
}
public void setBillType(Integer billType) {
this.billType = billType;
}
public Integer getOutinType() {
return outinType;
}
public void setOutinType(Integer outinType) {
this.outinType = outinType;
}
public static viewField getViewField(String viewField) {
try {
return valueOf(viewField);
} catch (Exception e) {
throw new RuntimeException("查询出入库参数错误:" + viewField);
}
}
}
使用枚举
列:
String field="qianshouruQuantity";//签收查看
Map map = new HashMap();
map.put("beginDate", entity.getBeginDate());
List<ProductSummaryViewResultEntity> retList = null;
ViewField viewField = ViewField.getViewField(field);
switch (viewField) {
case qianshouruQuantity:
//1.签收查看
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case tuihuoruQuantity:
//2.退货入库
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case shangyangruQuantity:
//3.上样入库
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case xiayangruQuantity:
//4.下样入库
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case diaoboruQuantity:
//5.调拨入库
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case panyingruQuantity:
//6.盘点调整
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case qitaruQuantity:
//7.其它入库-其它入库/期初调整
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case lingshouchuQuantity:
//零售出库
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case dianshangchuQuantity:
//电商任务
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
retList = productSummaryMapper.getOutinStorageDetailList(map);
break;
case shangyangchuQuantity:
//上样出库
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case xiayangchuQuantity:
//下样出库
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
//获取下样出库对应的下样入库类型
ViewField viewFieldOther2 = ProductSummaryService.ViewField.xiayangruQuantity;
map.put("billTypeOther", viewFieldOther2.billType);
map.put("outinTypeOther", viewFieldOther2.outinType);
break;
case pankuichuQuantity:
//其它出库-盘点调整
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
case qitachuQuantity:
//其它出库/借出
map.put("billType", viewField.billType);
map.put("outinType", viewField.outinType);
break;
default:
throw new ServiceException("没有对应的出入库详情:" + entity.getViewField());
}