f7e27590a2c98a1d14de6ce61daf7867c39532ed.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. package com.sinosoft.cm.chart.util;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import org.apache.commons.logging.Log;
  6. import org.apache.commons.logging.LogFactory;
  7. import com.sinosoft.cm.chart.service.SystemDataSourceChartServiceImpl;
  8. import flex.messaging.io.ArrayList;
  9. public class SystemDataSourceChartFactory {
  10. public final static String XLT_SUM="xianlutiaozha";
  11. public final static String DG_SOU_SUN_LEI_XING_AND_SUM="shousunleixing";
  12. public final static String DG_SOU_SUN_ZHU_PEI_SUM= "shousunzhupei";
  13. public final static String DG_SOU_SUN_BY_LEVEL="shousunbylevel";
  14. private static SystemDataSourceChartFactory cf=new SystemDataSourceChartFactory();
  15. private static final Log log = LogFactory.getLog(SystemDataSourceChartServiceImpl.class);
  16. private SystemDataSourceChartFactory() {
  17. }
  18. public static SystemDataSourceChartFactory getChartFactory(){
  19. if(cf==null){
  20. cf=new SystemDataSourceChartFactory();
  21. }
  22. return cf;
  23. }
  24. /**
  25. * 获取数据的汇众数据
  26. * @param charType
  27. * @param map
  28. * @return
  29. */
  30. public static Map<String,String> getMakeData(String charType,Map<String,String> map){
  31. cf=getChartFactory();
  32. if("xianlutiaozha".equals(charType.trim())){
  33. return cf.getMakeXianlutiaozha(map);
  34. }else if("shousunleixing".equals(charType.trim())){
  35. return cf.getMakeSheBeiShouSunType(map);
  36. }else if("shousunzhupei".equals(charType.trim())){
  37. return cf.getMakeSheBeiShouSun(map);
  38. }else if("shousunbylevel".equals(charType.trim())){
  39. return cf.getMakeSheBeiShouSunByLevel(map);
  40. }
  41. return null;
  42. }
  43. /*
  44. *
  45. * ROUTE_DMJTD_LJSDXLTZQK
  46. * {LJSDXLTZ_TZZS1,500KV线路跳闸总数},
  47. * {LJSDXLTZ_CHCG1,500KV线路重合成功}, {LJSDXLTZ_QSCG1,500KV线路强送成功},
  48. * {LJSDXLTZ_YJGZYS1,500KV线路永久故障已送}, {LJSDXLTZ_WHFTS1,500KV线路未恢复条数},
  49. *
  50. * {LJSDXLTZ_TZZS2,220KV线路跳闸总数}, {LJSDXLTZ_CHCG2,220KV线路重合成功},
  51. * {LJSDXLTZ_QSCG2,220KV线路强送成功}, {LJSDXLTZ_YJGZYS2,220KV线路永久故障已送},
  52. * {LJSDXLTZ_WHFTS2,220KV线路未恢复条数},
  53. *
  54. * {LJSDXLTZ_TZZS3,110KV线路跳闸总数},
  55. * {LJSDXLTZ_CHCG3,110KV线路重合成功}, {LJSDXLTZ_QSCG3,110KV线路强送成功},
  56. * {LJSDXLTZ_YJGZYS3,110KV线路永久故障已送},
  57. * {LJSDXLTZ_WHFTS3,110KV线路未恢复条数},
  58. *
  59. * {LJSDXLTZ_TZZS4,35KV线路跳闸总数}, {LJSDXLTZ_WHFTS4,35KV线路未恢复条数},
  60. *
  61. * {LJSDXLTZ_TZZS5,10KV线路跳闸总数}, {LJSDXLTZ_WHFTS5,10KV线路未恢复条数}, {COLUMN_1,0},
  62. * {COLUMN_2,0}, {COLUMN_3,0}, {COLUMN_4,0}, {COLUMN_5,0}, {COLUMN_6,0}
  63. */
  64. private Map<String,String> getMakeXianlutiaozha(Map<String,String> map){
  65. Map<String,String> makeMap=new HashMap<String, String>();
  66. makeMap.put("sum", "LJSDXLTZ_TZZS1-LJSDXLTZ_TZZS2-LJSDXLTZ_TZZS3-LJSDXLTZ_TZZS4-LJSDXLTZ_TZZS5");
  67. makeMap.put("unsum", "LJSDXLTZ_WHFTS1-LJSDXLTZ_WHFTS2-LJSDXLTZ_WHFTS3-LJSDXLTZ_WHFTS4-LJSDXLTZ_TZZS5");
  68. return getMakeData(map,makeMap,"-");
  69. }
  70. /**
  71. * PRESSURE_LOSS_ONE,NO_RECOVER_ONE, -----500kV线路
  72. * PRESSURE_LOSS_ONE,NO_RECOVER_TWO, -----220kV线路
  73. * PRESSURE_LOSS_ONE,NO_RECOVER_THREE, -----110kV线路
  74. * PRESSURE_LOSS_ONE,NO_RECOVER_FOUR -----35kV线路
  75. */
  76. /**
  77. *获取变电站停运汇总数据
  78. * @param map
  79. * @return
  80. */
  81. private Map<String,String> getMakeBianDianZhanTingYun(Map<String,String> map){
  82. Map<String,String> makeMap=new HashMap<String, String>();
  83. makeMap.put("sum", "PRESSURE_LOSS_ONE-PRESSURE_LOSS_TWO-PRESSURE_LOSS_THREE-PRESSURE_LOSS_FOUR");
  84. makeMap.put("unsum", "NO_RECOVER_ONE-NO_RECOVER_TWO-NO_RECOVER_THREE-NO_RECOVER_FOUR");
  85. return getMakeData(map,makeMap,"-");
  86. }
  87. /**
  88. * PLON_DAOTA_500, PLON_BIANXING_500, UNRECOVER_500, ------500kV倒杆变现未恢复
  89. * PLON_DAOTA_220,PLON_BIANXING_220, UNRECOVER_220, ------220kV倒杆变现未恢复
  90. * PLON_DAOTA_110,PLON_BIANXING_110,DUANGAN_110,DAOGAN_110,DIANGAN_QIGNXIE_110, UNRECOVER_110, ------110倒塌断杆倾斜变形未恢复
  91. * PLON_DAOTA_35,PLON_BIANXING_35,DUANGAN_35,DAOGAN_35,DIANGAN_QIGNXIE_35, UNRECOVER_35, ------35倒塌断杆倾斜变形未恢复
  92. * PLON_DAOTA_10,PLON_BIANXING_10,DUANGAN_10,DAOGAN_10,DIANGAN_QIGNXIE_10, UNRECOVER_10, ------10倒塌断杆倾斜变形未恢复
  93. * DAUNGAN_DIYA,DAOGAN_DIYA,QINGGAN_DIYA, UNRECOVER_DIYA ------低压断杆倒杆倾斜未恢复
  94. */
  95. /**
  96. * 获取设备受损汇总数据
  97. * @param map
  98. * @return
  99. */
  100. private Map<String,String> getMakeSheBeiShouSunType(Map<String,String> map){
  101. Map<String,String> makeMap=new HashMap<String, String>();
  102. makeMap.put("tietadaota", "PLON_DAOTA_500-PLON_DAOTA_220"
  103. + "-PLON_DAOTA_110-PLON_DAOTA_35"
  104. + "-PLON_DAOTA_10");
  105. makeMap.put("tietabianxing", "PLON_BIANXING_500-PLON_BIANXING_220-PLON_BIANXING_110-PLON_BIANXING_35-PLON_BIANXING_10");
  106. makeMap.put("duangan", "DUANGAN_110-DUANGAN_35-DUANGAN_10"
  107. + "-DAUNGAN_DIYA");
  108. makeMap.put("daogan", "DAOGAN_110-DAOGAN_35-DAOGAN_10-DAOGAN_DIYA");
  109. makeMap.put("dianganqinxie", "DIANGAN_QIGNXIE_110-DIANGAN_QIGNXIE_35"
  110. + "-DIANGAN_QIGNXIE_10"
  111. + "-QINGGAN_DIYA");
  112. makeMap.put("sum", "PLON_DAOTA_500-PLON_BIANXING_500"
  113. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  114. + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  115. + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
  116. + "-PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  117. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  118. makeMap.put("unsum", "UNRECOVER_500-UNRECOVER_220-UNRECOVER_110-UNRECOVER_35-UNRECOVER_10-UNRECOVER_DIYA");
  119. return getMakeData(map,makeMap,"-");
  120. }
  121. /**
  122. * 获取设备受损汇总数据
  123. * @param map
  124. * @return
  125. */
  126. /**
  127. * PLON_DAOTA_500,PLON_BIANXING_500, UNRECOVER_500, ------500kV倒杆变现未恢复
  128. * PLON_DAOTA_220,PLON_BIANXING_220, UNRECOVER_220, ------220kV倒杆变现未恢复
  129. * PLON_DAOTA_110,PLON_BIANXING_110, DUANGAN_110,DAOGAN_110,DIANGAN_QIGNXIE_110, UNRECOVER_110, ------110倒塌断杆倾斜变形未恢复
  130. * PLON_DAOTA_35,PLON_BIANXING_35,DUANGAN_35,DAOGAN_35,DIANGAN_QIGNXIE_35, UNRECOVER_35, ------35倒塌断杆倾斜变形未恢复
  131. * PLON_DAOTA_10,PLON_BIANXING_10,DUANGAN_10,DAOGAN_10,DIANGAN_QIGNXIE_10, UNRECOVER_10, ------10倒塌断杆倾斜变形未恢复
  132. * DAUNGAN_DIYA,DAOGAN_DIYA,QINGGAN_DIYA, UNRECOVER_DIYA ------低压断杆倒杆倾斜未恢复
  133. */
  134. private Map<String,String> getMakeSheBeiShouSun(Map<String,String> map){
  135. Map<String,String> makeMap=new HashMap<String, String>();
  136. makeMap.put("sum", "PLON_DAOTA_500-PLON_BIANXING_500"
  137. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  138. + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  139. + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
  140. + "-PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  141. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  142. makeMap.put("unsum", "UNRECOVER_500-UNRECOVER_220-UNRECOVER_110-UNRECOVER_35-UNRECOVER_10-UNRECOVER_DIYA");
  143. makeMap.put("main", "PLON_DAOTA_500-PLON_BIANXING_500"
  144. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  145. + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  146. + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35");
  147. makeMap.put("help", "PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  148. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  149. makeMap.put("tieta", "PLON_DAOTA_500-PLON_BIANXING_500"
  150. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  151. + "-PLON_DAOTA_110-PLON_BIANXING_110"
  152. + "-PLON_DAOTA_35-PLON_BIANXING_35"
  153. + "-PLON_DAOTA_10-PLON_BIANXING_10");
  154. makeMap.put("diangan", "DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  155. + "-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
  156. + "-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  157. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  158. return getMakeData(map,makeMap,"-");
  159. }
  160. /**
  161. * PLON_DAOTA_500,PLON_BIANXING_500, UNRECOVER_500, ------500kV倒杆变现未恢复
  162. * PLON_DAOTA_220,PLON_BIANXING_220, UNRECOVER_220, ------220kV倒杆变现未恢复
  163. * PLON_DAOTA_110,PLON_BIANXING_110, DUANGAN_110,DAOGAN_110,DIANGAN_QIGNXIE_110, UNRECOVER_110, ------110倒塌断杆倾斜变形未恢复
  164. * PLON_DAOTA_35,PLON_BIANXING_35,DUANGAN_35,DAOGAN_35,DIANGAN_QIGNXIE_35, UNRECOVER_35, ------35倒塌断杆倾斜变形未恢复
  165. * PLON_DAOTA_10,PLON_BIANXING_10,DUANGAN_10,DAOGAN_10,DIANGAN_QIGNXIE_10, UNRECOVER_10, ------10倒塌断杆倾斜变形未恢复
  166. * DAUNGAN_DIYA,DAOGAN_DIYA,QINGGAN_DIYA, UNRECOVER_DIYA ------低压断杆倒杆倾斜未恢复
  167. */
  168. private Map<String,String> getMakeSheBeiShouSunByLevel(Map<String,String> map){
  169. Map<String,String> makeMap=new HashMap<String, String>();
  170. makeMap.put("sum", "PLON_DAOTA_500-PLON_BIANXING_500"
  171. + "-PLON_DAOTA_220-PLON_BIANXING_220"
  172. + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
  173. + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
  174. + "-PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
  175. + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  176. makeMap.put("unsum", "UNRECOVER_500-UNRECOVER_220-UNRECOVER_110-UNRECOVER_35-UNRECOVER_10-UNRECOVER_DIYA");
  177. makeMap.put("five", "PLON_DAOTA_500-PLON_BIANXING_500");
  178. makeMap.put("two", "PLON_DAOTA_220-PLON_BIANXING_220");
  179. makeMap.put("one", "PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110");
  180. makeMap.put("three", "PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35");
  181. makeMap.put("ten", "PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10");
  182. makeMap.put("diya", "DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
  183. return getMakeData(map,makeMap,"-");
  184. }
  185. /**
  186. TQ_TD_COUNT,TQ_UNRECOVERED, ----台区停电数
  187. YH_TD_COUNT,YH_UNRECOVERED, ----用户停电数
  188. TJYH_TD_COUNT,TJYH_UNRECOVERED, ----特级用户停电数
  189. YJYH_TD_COUNT,YJYH_UNRECOVERED, ----一级用户停电数
  190. EJYH_TD_COUNT,EJYH_UNRECOVERED, ----二级用户停电数
  191. ENERGY_LOSS
  192. */
  193. /**
  194. * 获取设备受损汇总数据
  195. * @param map
  196. * @return
  197. */
  198. private Map<String,String> getYongHuTingDian(Map<String,String> map){
  199. Map<String,String> makeMap=new HashMap<String, String>();
  200. makeMap.put("sum", "TJYH_TD_COUNT-YJYH_TD_COUNT-EJYH_TD_COUNT");
  201. makeMap.put("unsum", "TJYH_UNRECOVERED-YJYH_UNRECOVERED-EJYH_UNRECOVERED");
  202. return getMakeData(map,makeMap,"-");
  203. }
  204. /**
  205. * 获取处理之后的数据
  206. * @param mapData 需要处理的数据
  207. * @param labelMap 需要处理数据的标签
  208. * @param sprate 标签的分隔符
  209. * @return
  210. */
  211. public static Map<String,String> getMakeData(Map<String,String> mapData,Map<String,String> labelMap,String sprate){
  212. cf=getChartFactory();
  213. for(String key:labelMap.keySet()){
  214. String[] sumArr=labelMap.get(key).split(sprate);
  215. Long sum = new Long(0);
  216. for(int index=0,len=sumArr.length;index<len;index++){
  217. log.info(key+"="+sumArr[index]);
  218. String tempKey=sumArr[index];
  219. String tempValue=(mapData.get(sumArr[index]));
  220. sum+=cf.getLong(tempValue);
  221. }
  222. labelMap.put(key, String.valueOf(sum));
  223. }
  224. return labelMap;
  225. }
  226. public static void main(String[] args) {
  227. Map<String,String> mapLable=new HashMap<String, String>();
  228. mapLable.put("sum","aa -bb -cc");
  229. mapLable.put("unsum","dd1-ee1");
  230. Map map=new HashMap<String, String>();
  231. map.put("aa","1");
  232. map.put("bb","1");
  233. map.put("cc","1");
  234. map.put("dd","2");
  235. map.put("ee","3");
  236. map=getMakeData(map,mapLable,"-");
  237. System.out.println(map);
  238. }
  239. /**
  240. * 获取处理之后的数据
  241. * @param mapData 需要处理的数据
  242. * @param labelMap 需要处理数据的标签
  243. * @param sprate 标签的分隔符
  244. * @return
  245. * @throws Exception
  246. */
  247. public static Map<String,String> getMakeData(Map<String,String> mapData,Map<String,String> labelMap,String sprate,StringMake makeHandle) throws Exception{
  248. for(String key:labelMap.keySet()){
  249. String[] sumArr=labelMap.get(key).split(sprate);
  250. Long sum = new Long(0);
  251. for(int index=0,len=sumArr.length;index<len;index++){
  252. sum+=makeHandle.getInt(mapData.get(sumArr[index]));
  253. // log.info(sumArr[index]+"="+mapData.get(sumArr[index])+"===int="+makeHandle.getInt(mapData.get(sumArr[index]))+"=======sum="+sum);
  254. }
  255. labelMap.put(key, String.valueOf(sum));
  256. }
  257. return labelMap;
  258. }
  259. /**
  260. * 字符粗替换方案
  261. * @param digit
  262. * @return
  263. */
  264. private Long getLong(String digit){
  265. if(null==digit)
  266. return 0l;
  267. if("".equals(digit.trim()))
  268. return 0l;
  269. if(digit.trim().toLowerCase().equals("null"))
  270. return 0l;
  271. /*正则匹配*/
  272. return Long.valueOf(digit);
  273. }
  274. }