getDict.jsp 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
  2. <%@ page import="cn.sinobest.framework.util.Util,cn.sinobest.framework.util.ConfUtil,cn.sinobest.framework.security.SecurityDes,
  3. cn.sinobest.framework.service.json.JSONUtilities,cn.sinobest.framework.comm.Environment,cn.sinobest.framework.service.bigdict.DictSort"%>
  4. <%
  5. String dictName = request.getParameter("dictName");
  6. String whereCls = request.getParameter("whereCls")==null?"":(String)request.getParameter("whereCls");
  7. //System.out.println("where-----------------------"+whereCls);
  8. String dsId = (String)Util.nvl(request.getParameter("dsId"),"");
  9. String dictStr = "{}";
  10. if (!Util.isEmpty(dictName)) {
  11. if(dictName.equals("DICT_VERSION")){
  12. dictStr = ConfUtil.getSysParam("DICT_VERSION","1");
  13. }else{
  14. List<String[]> dict = null;
  15. Map<String, Map<String, String>> dicts = null;
  16. if (dictName.indexOf('@') != -1) {
  17. String[] value = dictName.split("\\@");
  18. if (value[1] != null && !value[1].trim().equals("")) {
  19. String subcode = "";
  20. String qSubCode = value[1].toUpperCase();
  21. dicts = ConfUtil.getSubDict(value[0],value[1]);
  22. }
  23. } else if (dictName.startsWith("dyndict_")){
  24. if (Util.isEmpty(whereCls)) {
  25. whereCls = "1=1";
  26. dicts = ConfUtil.getDynDict(dictName, whereCls, dsId);
  27. }else if("null".equals(whereCls)){
  28. dicts = ConfUtil.getDynDict(dictName, whereCls, dsId);
  29. }else{
  30. if(Environment.isEncryptWhere()){
  31. String wherekey = (String) request.getSession(true).getAttribute("whereCls_key");
  32. if(!Util.isEmpty(wherekey)){
  33. try{
  34. SecurityDes de = new SecurityDes();
  35. whereCls = de.des(wherekey, de.HexTostring(whereCls), false);
  36. de = null;
  37. Util.validateQueryStringSafty(whereCls);
  38. dicts = ConfUtil.getDynDict(dictName, whereCls, dsId);
  39. }catch(Exception e){
  40. }
  41. }
  42. }else{
  43. dicts = ConfUtil.getDynDict(dictName, whereCls, dsId);
  44. }
  45. }
  46. } else {
  47. dicts = ConfUtil.getDict(dictName);
  48. // if(dicts != null) {
  49. // dict = new ArrayList<String[]>(dicts.size());;
  50. // for (Map.Entry<String,Map<String,String>> entry : dicts.entrySet()) {
  51. // dict.add(new String[]{entry.getKey(),entry.getValue().get("ITEMCODE"),entry.getValue().get("AAA103")});
  52. // }
  53. // }
  54. }
  55. //System.out.println("dictName:"+dictName);
  56. //System.out.println("whereCls:"+whereCls);
  57. if (dicts != null) {
  58. dict = new ArrayList<String[]>(dicts.size());
  59. for (Map.Entry<String,Map<String,String>> entry : dicts.entrySet()) {
  60. dict.add(new String[]{entry.getKey(),entry.getValue().get("ITEMCODE"),entry.getValue().get("AAA103"),
  61. entry.getValue().get("SUBCODE")});
  62. }
  63. //如果whereCls配置了排序语句,则按照whereCls配置排序
  64. if(whereCls.toUpperCase().indexOf("ORDER")<=-1)Collections.sort(dict,DictSort.DICTSORTOR);
  65. dictStr = new JSONUtilities().parseObject(dict).toString();
  66. }
  67. }
  68. }
  69. out.println(dictStr);
  70. %>