2955d4f1670422da74152ce613d519afb002afe9.svn-base 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. package com.sinosoft.am.count.dao;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import javax.ws.rs.core.Context;
  7. import org.apache.log4j.Logger;
  8. import com.persistence.service.PersistenceFactory;
  9. import com.persistence.service.SysPersistence;
  10. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  11. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  12. public class AmyjyanCountDao1 {
  13. SysModel sysmodel = ModelFactory.getSysmodel();
  14. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  15. StringBuffer json = new StringBuffer();
  16. private Logger log = Logger.getLogger(this.getClass());
  17. /**
  18. * 获取可编辑动态表头
  19. *
  20. * @param REPORT_NAME
  21. * @return
  22. */
  23. public String getEditColumnsName(String REPORT_TABLE_NAME,String column1) {
  24. String result = "";
  25. String lenth ="";
  26. String[]arr1=null;
  27. StringBuffer cols=new StringBuffer();
  28. String [] columnTemp = column1.split(",");
  29. int length = columnTemp.length;
  30. String sql = "";
  31. if(length!=0){
  32. lenth =100/(column1.split(",").length)+"%";
  33. arr1=column1.split(",");
  34. for(int k=0;k<arr1.length;k++){
  35. cols.append("'"+arr1[k]+"',");
  36. }
  37. if (cols.lastIndexOf(",") > -1) {
  38. cols.deleteCharAt(cols.lastIndexOf(","));
  39. }
  40. sql = "select REPORT_TABLE_NAME,TABLE_HEAD,TABLE_COLUMN,COLUMN_NAME,REPORT_NAME,is_count from EMC_AM_TONGJITABLE where is_del='0' and REPORT_TABLE_NAME='"
  41. + REPORT_TABLE_NAME + "' and table_column in("+cols.toString()+") order by fd_objectid";
  42. }else{
  43. sql = "select REPORT_TABLE_NAME,TABLE_HEAD,TABLE_COLUMN,COLUMN_NAME,REPORT_NAME,is_count from EMC_AM_TONGJITABLE where is_del='0' and REPORT_TABLE_NAME='"
  44. + REPORT_TABLE_NAME + "' order by fd_objectid";
  45. }
  46. try {
  47. List<String[]> tempList = persistence.getSearchResult(99, sql.toString());
  48. String title = "";
  49. StringBuffer json = new StringBuffer();
  50. List<String> list = new ArrayList<String>();
  51. Map<String, String> jsonMap = new HashMap<String, String>();
  52. //if("10".equals(REPORT_TABLE_NAME)){
  53. json.append("[");
  54. json.append("{");
  55. if("ECM_AM_EMERGENCY_TEAM".equals(REPORT_TABLE_NAME)|| "EMC_AM_GENERATOR_CAR".equals(REPORT_TABLE_NAME) || "EMC_AM_GENERATOR".equals(REPORT_TABLE_NAME) ||"EMC_AM_EXTEMAL_RESOURCES".equals(REPORT_TABLE_NAME)){
  56. json.append("\"display\":\"" + "供电局" + "\",");
  57. }else{
  58. json.append("\"display\":\"" + "所属单位" + "\",");
  59. }
  60. json.append("\"name\":\"" + "name" + "\",");
  61. json.append("\"width\":\"" + "150px" + "\",");
  62. json.append("\"frozen\":" + "true" + ",");
  63. json.append("\"render\":addStatus" + ",");
  64. json.append("\"maxWidth\":\"" + "150px" + "\",");
  65. json.append("\"id\":\"name\"");
  66. json.append("},");
  67. json.append("{");
  68. json.append("\"hide\":" + "true" + ",");
  69. json.append("\"name\":\"" + "FD_OBJECTID" + "\"");
  70. json.append("},");
  71. for (int i = 0; i < tempList.size(); i++) {
  72. String[] arr = tempList.get(i);
  73. String table_head = arr[1];
  74. String column = arr[2];
  75. title = arr[4];
  76. String isCount = arr[5];
  77. String column_name = arr[3];
  78. if ("".equals(table_head)||table_head==null) {
  79. jsonMap.put(column, column + "|" + column_name+"|"+isCount);
  80. list.add("|"+column);
  81. } else {
  82. if (list.contains(table_head)) {
  83. String value = jsonMap.get(table_head);
  84. jsonMap.put(table_head, value + ";" + column + "|" + column_name+"|"+isCount);
  85. } else {
  86. jsonMap.put(table_head, column + "|" + column_name+"|"+isCount);
  87. list.add(table_head);
  88. }
  89. }
  90. }
  91. for (int i = 0; i < list.size(); i++) {
  92. String table_head = list.get(i);
  93. if(table_head.startsWith("|")){
  94. String cotent=jsonMap.get(table_head.split("[|]")[1]);
  95. String isCount=cotent.split("[|]")[2];
  96. json.append("{");
  97. json.append("\"display\":\"" + cotent.split("[|]")[1] + "\",");
  98. json.append("\"name\":\"" + cotent.split("[|]")[0] + "\",");
  99. json.append("\"isCount\":\"" +isCount + "\",");
  100. // json.append("\"showTitle\":true,");
  101. json.append("\"render\":showMsger,");
  102. json.append("\"width\":\""+"10%"+"\",");
  103. json.append("\"editor\":" + "{ \"type\": \"text\"}");
  104. json.append("},");
  105. }else{
  106. String content = jsonMap.get(table_head);
  107. String[] arr = content.split(";");
  108. json.append("{");
  109. json.append("\"display\":\"" + table_head + "\",");
  110. json.append("\"columns\":" + "[" + "");
  111. for (int j = 0; j < arr.length; j++) {
  112. String column = arr[j].split("[|]")[0];
  113. String column_name = arr[j].split("[|]")[1];
  114. String isCount=arr[j].split("[|]")[2];
  115. int len=column_name.length()*17;
  116. json.append("{");
  117. json.append("\"display\":\"" + column_name + "\",");
  118. json.append("\"name\":\"" + column + "\",");
  119. // json.append("\"showTitle\":true,");
  120. json.append("\"isCount\":\"" + isCount + "\",");
  121. json.append("\"render\":showMsger,");
  122. json.append("\"width\":\""+lenth+"\",");
  123. if ("0".equals(isCount)||"1".equals(isCount)) {
  124. json.append("\"editor\":"
  125. + "{ \"type\": \"text\",\"inputMode\":\"positiveDecimal\"}");
  126. json.append("},");
  127. } else {
  128. json.append("\"editor\":" + "{ \"type\": \"text\"}");
  129. json.append("},");
  130. }
  131. }
  132. if (json.lastIndexOf(",") > -1) {
  133. json.deleteCharAt(json.lastIndexOf(","));
  134. }
  135. json.append("]");
  136. json.append("},");
  137. }
  138. }
  139. if (json.lastIndexOf(",") > -1) {
  140. json.deleteCharAt(json.lastIndexOf(","));
  141. }
  142. json.append("]");
  143. StringBuffer sb = new StringBuffer();
  144. log.info(sb.toString());
  145. result = sb.toString();
  146. result=json.toString();
  147. } catch (Exception e) {
  148. e.printStackTrace();
  149. }
  150. log.info("=========================="+result);
  151. return result;
  152. }
  153. }