package com.fzzy.igds.constant; import java.util.HashMap; import java.util.Map; import java.util.Set; /** * @Description 粮食性质枚举 * @Author CZT * @Date 2025/11/25 14:29 */ public class FoodVariety { /** * 用于存放粮食品种code -name */ public static Map mapFoodVariety = new HashMap<>(); /** * 根据名称找编码 * * @param msg * @return */ public static String getCode(String msg) { Set keys = mapFoodVariety.keySet(); if (null == keys || keys.isEmpty()) return msg; for (String key : keys) { if (mapFoodVariety.get(key).equals(msg)) { return key; } } return msg; } /** * 根据编码找名称 * @param code * @return */ public static String getMsg(String code) { if (null == code) return "未配置"; return mapFoodVariety.get(code); } }