190aa3631021e200f69be0376f2d9ff596a1dacc.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. package com.sinosoft.cm.chart.util;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import flex.messaging.io.ArrayList;
  6. public class ChartFactory {
  7. private static ChartFactory cf=new ChartFactory();
  8. private ChartFactory() {
  9. }
  10. public static ChartFactory getChartFactory(){
  11. if(cf==null){
  12. cf=new ChartFactory();
  13. }
  14. return cf;
  15. }
  16. /**
  17. * 获取数据的汇众数据
  18. * @param charType
  19. * @param map
  20. * @return
  21. */
  22. public static Map<String,String> getMakeData(String charType,Map<String,String> map){
  23. cf=getChartFactory();
  24. if("xianlutiaozha".equals(charType.trim())){
  25. return cf.getMakeXianlutiaozha(map);
  26. }else if("biandianzhantingyun".equals(charType.trim())){
  27. return cf.getMakeBianDianZhanTingYun(map);
  28. }else if("shebeisousun".equals(charType.trim())){
  29. return cf.getMakeSheBeiShouSun(map);
  30. }else if("shebeisousuntype".equals(charType.trim())){
  31. return cf.getMakeSheBeiShouSunType(map);
  32. }else if("shebeisousunlevel".equals(charType.trim())){
  33. return cf.getMakeSheBeiShouSunByLevel(map);
  34. }else if("yonghutingdian".equals(charType.trim())){
  35. return cf.getYongHuTingDian(map);
  36. }else if("yonghutingdianf".equals(charType.trim())){
  37. return cf.getYongHuTingDianFloat(map);
  38. }
  39. return null;
  40. }
  41. public static String getTabelName(String tabelName){
  42. Map<String,String> map=new HashMap<String, String>();
  43. map.put("xianLuTiaoZha","ROUTE_OFLINE_DETAIL");
  44. map.put("bianDianZhanTingYun","BDZ_XQ_DETAIL");
  45. map.put("sheBeiShouSun","XLDG_XQ_DETAIL");
  46. map.put("zhongYaoYongHu","TDQK_XQ_DETAIL");
  47. map.put("yingJiRenYuanTouRu","YJZY_XQ_DETAIL");
  48. return getTabelName(tabelName);
  49. }
  50. /* {"state":"SUCCESS","total":1,"rows":[{"TRIP_OUT_TWO":"842",
  51. "FD_OBJECTID":"338145700760612400113623100000",
  52. "UPDATEDATE":"0","REMARK_ONE":"","COMP_ID":"0",
  53. "DEPT_NAME":"0","TRIP_OUT_FOUR":"812",
  54. "TRIP_OUT_FIVE":"752","REMARK_THREE":"",
  55. "NO_RECOVER_FIVE":"91",
  56. "TRIP_OUT_TOTAL_ONE":"58","WARNING_NUMBER":"防风防汛-F-2016-5"
  57. ,"NO_RECOVER_FOUR":"109","REMARK_TWO":"","NO_RECOVER_TWO":"51",
  58. "NO_RECOVER_ONE":"88","DATA_TYPE":"0","TRIP_OUT_TOTAL_TWO":"51","COLUMN_4":"0",
  59. "COLUMN_3":"0","NO_RECOVER_THREE":"109","TRIP_OUT_TOTAL_THREE":"47","APPEAR_TIME":"2016-03-03 20:24:35","PARENT_NAME":"广东电网公司",
  60. "TRIP_OUT_THREE":"700","TRIP_OUT_ONE":"778","REPORT_TYPE":"1",
  61. "LOSS_LOAD":"81","PARENT_ID":"11","REPORT_ID":"778145700786871220000079100000"}]}*/
  62. /**
  63. * 获取线路跳闸的汇总数据
  64. * @param map
  65. * @return
  66. */
  67. private Map<String,String> getMakeXianlutiaozha(Map<String,String> map){
  68. Map<String,String> makeMap=new HashMap<String, String>();
  69. makeMap.put("sum", "TRIP_OUT_ONE-TRIP_OUT_TWO-TRIP_OUT_THREE-TRIP_OUT_FOUR-TRIP_OUT_FIVE");
  70. makeMap.put("unsum", "NO_RECOVER_ONE-NO_RECOVER_TWO-NO_RECOVER_THREE-NO_RECOVER_FOUR-NO_RECOVER_FIVE");
  71. return getMakeData(map,makeMap,"-");
  72. }
  73. /**
  74. * PRESSURE_LOSS_ONE,NO_RECOVER_ONE, -----500kV线路
  75. * PRESSURE_LOSS_ONE,NO_RECOVER_TWO, -----220kV线路
  76. * PRESSURE_LOSS_ONE,NO_RECOVER_THREE, -----110kV线路
  77. * PRESSURE_LOSS_ONE,NO_RECOVER_FOUR -----35kV线路
  78. */
  79. /**
  80. *获取变电站停运汇总数据
  81. * @param map
  82. * @return
  83. */
  84. private Map<String,String> getMakeBianDianZhanTingYun(Map<String,String> map){
  85. Map<String,String> makeMap=new HashMap<String, String>();
  86. //makeMap.put("sum", "SHIYAZUO_500KV-SHIYAZUO_220KV-SHIYAZUO_35KV");
  87. //makeMap.put("unsum", "WEIHUIFUZUO_500KV-WEIHUIFUZUO_220KV-WEIHUIFUZUO_35KV");
  88. makeMap.put("sum", "SHIYAZUO_500KV-SHIYAZUO_220KV-SHIYAZUO_110KV-SHIYAZUO_35KV");
  89. makeMap.put("unsum", "WEIHUIFUZUO_500KV-WEIHUIFUZUO_220KV-WEIHUIFUZUO_110KV-WEIHUIFUZUO_35KV");
  90. return getMakeData(map,makeMap,"-");
  91. }
  92. /**
  93. * PLON_DAOTA_500, PLON_BIANXING_500, UNRECOVER_500, ------500kV倒杆变现未恢复
  94. * PLON_DAOTA_220,PLON_BIANXING_220, UNRECOVER_220, ------220kV倒杆变现未恢复
  95. * PLON_DAOTA_110,PLON_BIANXING_110,DUANGAN_110,DAOGAN_110,DIANGAN_QIGNXIE_110, UNRECOVER_110, ------110倒塌断杆倾斜变形未恢复
  96. * PLON_DAOTA_35,PLON_BIANXING_35,DUANGAN_35,DAOGAN_35,DIANGAN_QIGNXIE_35, UNRECOVER_35, ------35倒塌断杆倾斜变形未恢复
  97. * PLON_DAOTA_10,PLON_BIANXING_10,DUANGAN_10,DAOGAN_10,DIANGAN_QIGNXIE_10, UNRECOVER_10, ------10倒塌断杆倾斜变形未恢复
  98. * DAUNGAN_DIYA,DAOGAN_DIYA,QINGGAN_DIYA, UNRECOVER_DIYA ------低压断杆倒杆倾斜未恢复
  99. */
  100. /**
  101. * 获取设备受损汇总数据
  102. * @param map
  103. * @return
  104. */
  105. private Map<String,String> getMakeSheBeiShouSunType(Map<String,String> map){
  106. Map<String,String> makeMap=new HashMap<String, String>();
  107. makeMap.put("tietadaota", "PLON_DAOTA_500-PLON_DAOTA_220"
  108. + "-PLON_DAOTA_110-PLON_DAOTA_35"
  109. + "-PLON_DAOTA_10");
  110. makeMap.put("tietabianxing", "PLON_BIANXING_500-PLON_BIANXING_220-PLON_BIANXING_110-PLON_BIANXING_35-PLON_BIANXING_10");
  111. makeMap.put("duangan", "DUANGAN_110-DUANGAN_35-DUANGAN_10"
  112. + "-DAUNGAN_DIYA");
  113. makeMap.put("daogan", "DAOGAN_110-DAOGAN_35-DAOGAN_10-DAOGAN_DIYA");
  114. makeMap.put("dianganqinxie", "DIANGAN_QIGNXIE_110-DIANGAN_QIGNXIE_35"
  115. + "-DIANGAN_QIGNXIE_10"
  116. + "-QINGGAN_DIYA");
  117. makeMap.put("sum", "PLON_DAOTA_500-PLON_BIANXING_500"
  118. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  119. + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  120. + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
  121. + "-PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  122. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  123. makeMap.put("unsum", "UNRECOVER_500-UNRECOVER_220-UNRECOVER_110-UNRECOVER_35-UNRECOVER_10-UNRECOVER_DIYA");
  124. return getMakeData(map,makeMap,"-");
  125. }
  126. /**
  127. * 获取设备受损汇总数据
  128. * @param map
  129. * @return
  130. */
  131. /**
  132. * PLON_DAOTA_500,PLON_BIANXING_500, UNRECOVER_500, ------500kV倒杆变现未恢复
  133. * PLON_DAOTA_220,PLON_BIANXING_220, UNRECOVER_220, ------220kV倒杆变现未恢复
  134. * PLON_DAOTA_110,PLON_BIANXING_110, DUANGAN_110,DAOGAN_110,DIANGAN_QIGNXIE_110, UNRECOVER_110, ------110倒塌断杆倾斜变形未恢复
  135. * PLON_DAOTA_35,PLON_BIANXING_35,DUANGAN_35,DAOGAN_35,DIANGAN_QIGNXIE_35, UNRECOVER_35, ------35倒塌断杆倾斜变形未恢复
  136. * PLON_DAOTA_10,PLON_BIANXING_10,DUANGAN_10,DAOGAN_10,DIANGAN_QIGNXIE_10, UNRECOVER_10, ------10倒塌断杆倾斜变形未恢复
  137. * DAUNGAN_DIYA,DAOGAN_DIYA,QINGGAN_DIYA, UNRECOVER_DIYA ------低压断杆倒杆倾斜未恢复
  138. */
  139. private Map<String,String> getMakeSheBeiShouSun(Map<String,String> map){
  140. Map<String,String> makeMap=new HashMap<String, String>();
  141. makeMap.put("sum", "PLON_DAOTA_500-PLON_BIANXING_500"
  142. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  143. + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  144. + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
  145. + "-PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  146. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  147. makeMap.put("unsum", "UNRECOVER_500-UNRECOVER_220-UNRECOVER_110-UNRECOVER_35-UNRECOVER_10-UNRECOVER_DIYA");
  148. makeMap.put("main", "PLON_DAOTA_500-PLON_BIANXING_500"
  149. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  150. + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  151. + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35");
  152. makeMap.put("help", "PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  153. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  154. makeMap.put("tieta", "PLON_DAOTA_500-PLON_BIANXING_500"
  155. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  156. + "-PLON_DAOTA_110-PLON_BIANXING_110"
  157. + "-PLON_DAOTA_35-PLON_BIANXING_35"
  158. + "-PLON_DAOTA_10-PLON_BIANXING_10");
  159. makeMap.put("diangan", "DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  160. + "-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
  161. + "-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  162. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  163. return getMakeData(map,makeMap,"-");
  164. }
  165. /**
  166. * PLON_DAOTA_500,PLON_BIANXING_500, UNRECOVER_500, ------500kV倒杆变现未恢复
  167. * PLON_DAOTA_220,PLON_BIANXING_220, UNRECOVER_220, ------220kV倒杆变现未恢复
  168. * PLON_DAOTA_110,PLON_BIANXING_110, DUANGAN_110,DAOGAN_110,DIANGAN_QIGNXIE_110, UNRECOVER_110, ------110倒塌断杆倾斜变形未恢复
  169. * PLON_DAOTA_35,PLON_BIANXING_35,DUANGAN_35,DAOGAN_35,DIANGAN_QIGNXIE_35, UNRECOVER_35, ------35倒塌断杆倾斜变形未恢复
  170. * PLON_DAOTA_10,PLON_BIANXING_10,DUANGAN_10,DAOGAN_10,DIANGAN_QIGNXIE_10, UNRECOVER_10, ------10倒塌断杆倾斜变形未恢复
  171. * DAUNGAN_DIYA,DAOGAN_DIYA,QINGGAN_DIYA, UNRECOVER_DIYA ------低压断杆倒杆倾斜未恢复
  172. */
  173. private Map<String,String> getMakeSheBeiShouSunByLevel(Map<String,String> map){
  174. Map<String,String> makeMap=new HashMap<String, String>();
  175. makeMap.put("sum", "PLON_DAOTA_500-PLON_BIANXING_500"
  176. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  177. + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  178. + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
  179. + "-PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  180. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  181. makeMap.put("unsum", "UNRECOVER_500-UNRECOVER_220-UNRECOVER_110-UNRECOVER_35-UNRECOVER_10-UNRECOVER_DIYA");
  182. makeMap.put("five", "PLON_DAOTA_500-PLON_BIANXING_500");
  183. makeMap.put("two", "PLON_DAOTA_220-PLON_BIANXING_220");
  184. makeMap.put("one", "PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110");
  185. makeMap.put("three", "PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35");
  186. makeMap.put("ten", "PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10");
  187. makeMap.put("diya", "DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  188. return getMakeData(map,makeMap,"-");
  189. }
  190. /**
  191. TQ_TD_COUNT,TQ_UNRECOVERED, ----台区停电数
  192. YH_TD_COUNT,YH_UNRECOVERED, ----用户停电数
  193. TJYH_TD_COUNT,TJYH_UNRECOVERED, ----特级用户停电数
  194. YJYH_TD_COUNT,YJYH_UNRECOVERED, ----一级用户停电数
  195. EJYH_TD_COUNT,EJYH_UNRECOVERED, ----二级用户停电数
  196. ENERGY_LOSS
  197. */
  198. /**
  199. * 获取设备受损汇总数据
  200. * @param map
  201. * @return
  202. */
  203. private Map<String,String> getYongHuTingDian(Map<String,String> map){
  204. Map<String,String> makeMap=new HashMap<String, String>();
  205. makeMap.put("sum", "TJYH_TD_COUNT-YJYH_TD_COUNT-EJYH_TD_COUNT");
  206. makeMap.put("unsum", "TJYH_UNRECOVERED-YJYH_UNRECOVERED-EJYH_UNRECOVERED");
  207. return getMakeData(map,makeMap,"-");
  208. }
  209. private Map<String,String> getYongHuTingDianFloat(Map<String,String> map){
  210. Map<String,String> makeMap=new HashMap<String, String>();
  211. makeMap.put("sum", "TJYH_TD_COUNT-YJYH_TD_COUNT-EJYH_TD_COUNT");
  212. makeMap.put("unsum", "TJYH_UNRECOVERED-YJYH_UNRECOVERED-EJYH_UNRECOVERED");
  213. return getMakeDataFloat(map,makeMap,"-");
  214. }
  215. public static Map<String,String> getMakeDataFloat(Map<String,String> mapData,Map<String,String> labelMap,String sprate){
  216. cf=getChartFactory();
  217. for(String key:labelMap.keySet()){
  218. String[] sumArr=labelMap.get(key).split(sprate);
  219. Float sum = new Float(0);
  220. for(int index=0,len=sumArr.length;index<len;index++){
  221. sum+=cf.getFloat(mapData.get(sumArr[index]));
  222. //log.info(sumArr[index]+"="+mapData.get(sumArr[index])+"===int="+cf.getInt(mapData.get(sumArr[index]))+"=======sum="+sum);
  223. }
  224. labelMap.put(key, String.valueOf(sum));
  225. }
  226. return labelMap;
  227. }
  228. /**
  229. * 获取处理之后的数据
  230. * @param mapData 需要处理的数据
  231. * @param labelMap 需要处理数据的标签
  232. * @param sprate 标签的分隔符
  233. * @return
  234. */
  235. public static Map<String,String> getMakeData(Map<String,String> mapData,Map<String,String> labelMap,String sprate){
  236. cf=getChartFactory();
  237. for(String key:labelMap.keySet()){
  238. String[] sumArr=labelMap.get(key).split(sprate);
  239. Float sum = new Float(0);
  240. for(int index=0,len=sumArr.length;index<len;index++){
  241. sum+=cf.getFloat(mapData.get(sumArr[index]));
  242. //log.info(sumArr[index]+"="+mapData.get(sumArr[index])+"===int="+cf.getInt(mapData.get(sumArr[index]))+"=======sum="+sum);
  243. }
  244. labelMap.put(key, String.valueOf(sum));
  245. }
  246. return labelMap;
  247. }
  248. /**
  249. * 获取处理之后的数据
  250. * @param mapData 需要处理的数据
  251. * @param labelMap 需要处理数据的标签
  252. * @param sprate 标签的分隔符
  253. * @return
  254. * @throws Exception
  255. */
  256. public static Map<String,String> getMakeData(Map<String,String> mapData,Map<String,String> labelMap,String sprate,StringMake makeHandle) throws Exception{
  257. for(String key:labelMap.keySet()){
  258. String[] sumArr=labelMap.get(key).split(sprate);
  259. Long sum = new Long(0);
  260. for(int index=0,len=sumArr.length;index<len;index++){
  261. sum+=makeHandle.getInt(mapData.get(sumArr[index]));
  262. // log.info(sumArr[index]+"="+mapData.get(sumArr[index])+"===int="+makeHandle.getInt(mapData.get(sumArr[index]))+"=======sum="+sum);
  263. }
  264. labelMap.put(key, String.valueOf(sum));
  265. }
  266. return labelMap;
  267. }
  268. /**
  269. * 字符粗替换方案
  270. * @param digit
  271. * @return
  272. */
  273. private Long getLong(String digit){
  274. if("".equals(digit.trim()))
  275. return 0l;
  276. if(digit.trim().toLowerCase().equals("null"))
  277. return 0l;
  278. if(digit==null)
  279. return 0l;
  280. /*正则匹配*/
  281. return Long.valueOf(digit);
  282. }
  283. /**
  284. * 字符粗替换方案
  285. * @param digit
  286. * @return
  287. */
  288. private Float getFloat(String digit){
  289. if("".equals(digit.trim()))
  290. return 0.0f;
  291. if(digit.trim().toLowerCase().equals("null"))
  292. return 0.0f;
  293. if(digit==null)
  294. return 0.0f;
  295. /*正则匹配*/
  296. return Float.valueOf(digit);
  297. }
  298. }