|  |  |  | 
|---|
|  |  |  | import com.zy.acs.manager.manager.entity.AgvModel; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.service.AgvModelService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.EnumMap; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public enum AgvModelType { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CTU_BOX_TRANSPORT_AGV, | 
|---|
|  |  |  | 
|---|
|  |  |  | AgvModelType() { | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final Map<AgvModelType, Long> cache = new EnumMap<>(AgvModelType.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public long val() { | 
|---|
|  |  |  | AgvModelService service = SpringUtils.getBean(AgvModelService.class); | 
|---|
|  |  |  | AgvModel agvModel = service.selectByType(this.toString()); | 
|---|
|  |  |  | if (agvModel == null) { | 
|---|
|  |  |  | throw new BusinessException("AgvModelType Error!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return agvModel.getId(); | 
|---|
|  |  |  | return cache.computeIfAbsent(this, key -> { | 
|---|
|  |  |  | AgvModelService service = SpringUtils.getBean(AgvModelService.class); | 
|---|
|  |  |  | AgvModel agvModel = service.selectByType(this.toString()); | 
|---|
|  |  |  | if (agvModel == null) { | 
|---|
|  |  |  | throw new BusinessException("AgvModelType Error!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return agvModel.getId(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|