DictUtil.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package cn.com.lzt.common.util;
  2. import java.util.List;
  3. import org.apache.commons.lang.xwork.StringUtils;
  4. import org.jeecgframework.core.util.ApplicationContextUtil;
  5. import org.jeecgframework.core.util.MutiLangUtil;
  6. import org.jeecgframework.web.system.pojo.base.TSType;
  7. import org.jeecgframework.web.system.service.SystemService;
  8. /**
  9. * 字典code-name转换工具类
  10. * */
  11. public class DictUtil {
  12. public static String formatToTypeName(String value,String typeGroupCode) {
  13. String[] values = value.split(",");
  14. String names = "";
  15. List<TSType> types = ApplicationContextUtil.getContext().getBean(SystemService.class).getTypesByGroupcodeFromCache(typeGroupCode.toLowerCase());//ResourceUtil.allTypes.get(typeGroupCode.toLowerCase());
  16. if(types != null) {
  17. String name = "";
  18. for(String valueN:values) {
  19. for(TSType type: types) {
  20. if(type.getTypecode().equals(valueN)) {
  21. name = type.getTypename();
  22. name = MutiLangUtil.doMutiLang(name,null);
  23. names += name+",";
  24. break;
  25. }
  26. }
  27. }
  28. }
  29. if(StringUtils.isNotBlank(names)) {
  30. return names.substring(0, names.length() - 1);
  31. }
  32. return names;
  33. }
  34. }