package com.zy.asrs.wms.asrs.entity.enums;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.zy.asrs.framework.common.SpringUtils;
|
import com.zy.asrs.framework.exception.CoolException;
|
import com.zy.asrs.wms.asrs.entity.LocType;
|
import com.zy.asrs.wms.asrs.service.LocTypeService;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
public enum LocBindType {
|
|
HEIGHT("locTypeHeight", "高低类型"),
|
WEIGHT("locTypeWeight", "宽窄类型"),
|
;
|
|
|
public String flag;
|
public String desc;
|
|
LocBindType(String flag, String desc) {
|
this.flag = flag;
|
this.desc = desc;
|
}
|
|
public long val() {
|
LocTypeService service = SpringUtils.getBean(LocTypeService.class);
|
LocType locType = service.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, flag));
|
if (locType == null) {
|
throw new CoolException("LocType Error!");
|
}
|
return locType.getId();
|
}
|
|
public List<Long> list() {
|
LocTypeService service = SpringUtils.getBean(LocTypeService.class);
|
LocType locType = service.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, flag));
|
if (locType == null) {
|
throw new CoolException("LocType Error!");
|
}
|
|
List<LocType> list = service.list(new LambdaQueryWrapper<LocType>().eq(LocType::getParentId, locType.getId()));
|
ArrayList<Long> longs = new ArrayList<>();
|
for (LocType type : list) {
|
longs.add(type.getId());
|
}
|
|
if (longs.isEmpty()) {
|
throw new CoolException("LocType Error!");
|
}
|
return longs;
|
}
|
|
public static LocBindType get(String flag) {
|
for (LocBindType value : LocBindType.values()) {
|
if (flag.equals(value.flag)) {
|
return value;
|
}
|
}
|
return null;
|
}
|
|
|
}
|