123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- package com.sinosoft.cm.chart.util;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import flex.messaging.io.ArrayList;
- public class ChartFactory {
- private static ChartFactory cf=new ChartFactory();
- private ChartFactory() {
-
- }
- public static ChartFactory getChartFactory(){
- if(cf==null){
- cf=new ChartFactory();
- }
- return cf;
- }
- /**
- * 获取数据的汇众数据
- * @param charType
- * @param map
- * @return
- */
- public static Map<String,String> getMakeData(String charType,Map<String,String> map){
- cf=getChartFactory();
- if("xianlutiaozha".equals(charType.trim())){
- return cf.getMakeXianlutiaozha(map);
- }else if("biandianzhantingyun".equals(charType.trim())){
- return cf.getMakeBianDianZhanTingYun(map);
- }else if("shebeisousun".equals(charType.trim())){
- return cf.getMakeSheBeiShouSun(map);
- }else if("shebeisousuntype".equals(charType.trim())){
- return cf.getMakeSheBeiShouSunType(map);
- }else if("shebeisousunlevel".equals(charType.trim())){
- return cf.getMakeSheBeiShouSunByLevel(map);
- }else if("yonghutingdian".equals(charType.trim())){
- return cf.getYongHuTingDian(map);
- }else if("yonghutingdianf".equals(charType.trim())){
- return cf.getYongHuTingDianFloat(map);
- }
- return null;
- }
-
- public static String getTabelName(String tabelName){
- Map<String,String> map=new HashMap<String, String>();
- map.put("xianLuTiaoZha","ROUTE_OFLINE_DETAIL");
- map.put("bianDianZhanTingYun","BDZ_XQ_DETAIL");
- map.put("sheBeiShouSun","XLDG_XQ_DETAIL");
- map.put("zhongYaoYongHu","TDQK_XQ_DETAIL");
- map.put("yingJiRenYuanTouRu","YJZY_XQ_DETAIL");
- return getTabelName(tabelName);
-
- }
-
-
-
- /* {"state":"SUCCESS","total":1,"rows":[{"TRIP_OUT_TWO":"842",
- "FD_OBJECTID":"338145700760612400113623100000",
- "UPDATEDATE":"0","REMARK_ONE":"","COMP_ID":"0",
- "DEPT_NAME":"0","TRIP_OUT_FOUR":"812",
- "TRIP_OUT_FIVE":"752","REMARK_THREE":"",
- "NO_RECOVER_FIVE":"91",
- "TRIP_OUT_TOTAL_ONE":"58","WARNING_NUMBER":"防风防汛-F-2016-5"
- ,"NO_RECOVER_FOUR":"109","REMARK_TWO":"","NO_RECOVER_TWO":"51",
- "NO_RECOVER_ONE":"88","DATA_TYPE":"0","TRIP_OUT_TOTAL_TWO":"51","COLUMN_4":"0",
- "COLUMN_3":"0","NO_RECOVER_THREE":"109","TRIP_OUT_TOTAL_THREE":"47","APPEAR_TIME":"2016-03-03 20:24:35","PARENT_NAME":"广东电网公司",
- "TRIP_OUT_THREE":"700","TRIP_OUT_ONE":"778","REPORT_TYPE":"1",
- "LOSS_LOAD":"81","PARENT_ID":"11","REPORT_ID":"778145700786871220000079100000"}]}*/
- /**
- * 获取线路跳闸的汇总数据
- * @param map
- * @return
- */
- private Map<String,String> getMakeXianlutiaozha(Map<String,String> map){
- Map<String,String> makeMap=new HashMap<String, String>();
- makeMap.put("sum", "TRIP_OUT_ONE-TRIP_OUT_TWO-TRIP_OUT_THREE-TRIP_OUT_FOUR-TRIP_OUT_FIVE");
- makeMap.put("unsum", "NO_RECOVER_ONE-NO_RECOVER_TWO-NO_RECOVER_THREE-NO_RECOVER_FOUR-NO_RECOVER_FIVE");
- return getMakeData(map,makeMap,"-");
- }
-
- /**
- * PRESSURE_LOSS_ONE,NO_RECOVER_ONE, -----500kV线路
- * PRESSURE_LOSS_ONE,NO_RECOVER_TWO, -----220kV线路
- * PRESSURE_LOSS_ONE,NO_RECOVER_THREE, -----110kV线路
- * PRESSURE_LOSS_ONE,NO_RECOVER_FOUR -----35kV线路
- */
-
- /**
- *获取变电站停运汇总数据
- * @param map
- * @return
- */
- private Map<String,String> getMakeBianDianZhanTingYun(Map<String,String> map){
- Map<String,String> makeMap=new HashMap<String, String>();
- //makeMap.put("sum", "SHIYAZUO_500KV-SHIYAZUO_220KV-SHIYAZUO_35KV");
- //makeMap.put("unsum", "WEIHUIFUZUO_500KV-WEIHUIFUZUO_220KV-WEIHUIFUZUO_35KV");
- makeMap.put("sum", "SHIYAZUO_500KV-SHIYAZUO_220KV-SHIYAZUO_110KV-SHIYAZUO_35KV");
- makeMap.put("unsum", "WEIHUIFUZUO_500KV-WEIHUIFUZUO_220KV-WEIHUIFUZUO_110KV-WEIHUIFUZUO_35KV");
- return getMakeData(map,makeMap,"-");
- }
-
-
- /**
- * PLON_DAOTA_500, PLON_BIANXING_500, UNRECOVER_500, ------500kV倒杆变现未恢复
- * PLON_DAOTA_220,PLON_BIANXING_220, UNRECOVER_220, ------220kV倒杆变现未恢复
- * PLON_DAOTA_110,PLON_BIANXING_110,DUANGAN_110,DAOGAN_110,DIANGAN_QIGNXIE_110, UNRECOVER_110, ------110倒塌断杆倾斜变形未恢复
- * PLON_DAOTA_35,PLON_BIANXING_35,DUANGAN_35,DAOGAN_35,DIANGAN_QIGNXIE_35, UNRECOVER_35, ------35倒塌断杆倾斜变形未恢复
- * PLON_DAOTA_10,PLON_BIANXING_10,DUANGAN_10,DAOGAN_10,DIANGAN_QIGNXIE_10, UNRECOVER_10, ------10倒塌断杆倾斜变形未恢复
- * DAUNGAN_DIYA,DAOGAN_DIYA,QINGGAN_DIYA, UNRECOVER_DIYA ------低压断杆倒杆倾斜未恢复
- */
- /**
- * 获取设备受损汇总数据
- * @param map
- * @return
- */
- private Map<String,String> getMakeSheBeiShouSunType(Map<String,String> map){
- Map<String,String> makeMap=new HashMap<String, String>();
- makeMap.put("tietadaota", "PLON_DAOTA_500-PLON_DAOTA_220"
- + "-PLON_DAOTA_110-PLON_DAOTA_35"
- + "-PLON_DAOTA_10");
- makeMap.put("tietabianxing", "PLON_BIANXING_500-PLON_BIANXING_220-PLON_BIANXING_110-PLON_BIANXING_35-PLON_BIANXING_10");
- makeMap.put("duangan", "DUANGAN_110-DUANGAN_35-DUANGAN_10"
- + "-DAUNGAN_DIYA");
- makeMap.put("daogan", "DAOGAN_110-DAOGAN_35-DAOGAN_10-DAOGAN_DIYA");
- makeMap.put("dianganqinxie", "DIANGAN_QIGNXIE_110-DIANGAN_QIGNXIE_35"
- + "-DIANGAN_QIGNXIE_10"
- + "-QINGGAN_DIYA");
- makeMap.put("sum", "PLON_DAOTA_500-PLON_BIANXING_500"
- + "-PLON_DAOTA_220-PLON_BIANXING_220"
- + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
- + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
- + "-PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
- + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
- makeMap.put("unsum", "UNRECOVER_500-UNRECOVER_220-UNRECOVER_110-UNRECOVER_35-UNRECOVER_10-UNRECOVER_DIYA");
- return getMakeData(map,makeMap,"-");
- }
-
- /**
- * 获取设备受损汇总数据
- * @param map
- * @return
- */
- /**
- * PLON_DAOTA_500,PLON_BIANXING_500, UNRECOVER_500, ------500kV倒杆变现未恢复
- * PLON_DAOTA_220,PLON_BIANXING_220, UNRECOVER_220, ------220kV倒杆变现未恢复
- * PLON_DAOTA_110,PLON_BIANXING_110, DUANGAN_110,DAOGAN_110,DIANGAN_QIGNXIE_110, UNRECOVER_110, ------110倒塌断杆倾斜变形未恢复
-
- * PLON_DAOTA_35,PLON_BIANXING_35,DUANGAN_35,DAOGAN_35,DIANGAN_QIGNXIE_35, UNRECOVER_35, ------35倒塌断杆倾斜变形未恢复
- * PLON_DAOTA_10,PLON_BIANXING_10,DUANGAN_10,DAOGAN_10,DIANGAN_QIGNXIE_10, UNRECOVER_10, ------10倒塌断杆倾斜变形未恢复
- * DAUNGAN_DIYA,DAOGAN_DIYA,QINGGAN_DIYA, UNRECOVER_DIYA ------低压断杆倒杆倾斜未恢复
- */
- private Map<String,String> getMakeSheBeiShouSun(Map<String,String> map){
- Map<String,String> makeMap=new HashMap<String, String>();
- makeMap.put("sum", "PLON_DAOTA_500-PLON_BIANXING_500"
- + "-PLON_DAOTA_220-PLON_BIANXING_220"
- + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
- + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
- + "-PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
- + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
- makeMap.put("unsum", "UNRECOVER_500-UNRECOVER_220-UNRECOVER_110-UNRECOVER_35-UNRECOVER_10-UNRECOVER_DIYA");
- makeMap.put("main", "PLON_DAOTA_500-PLON_BIANXING_500"
- + "-PLON_DAOTA_220-PLON_BIANXING_220"
- + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
- + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35");
- makeMap.put("help", "PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
- + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
- makeMap.put("tieta", "PLON_DAOTA_500-PLON_BIANXING_500"
- + "-PLON_DAOTA_220-PLON_BIANXING_220"
- + "-PLON_DAOTA_110-PLON_BIANXING_110"
- + "-PLON_DAOTA_35-PLON_BIANXING_35"
- + "-PLON_DAOTA_10-PLON_BIANXING_10");
- makeMap.put("diangan", "DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
- + "-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
- + "-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
- + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
-
- return getMakeData(map,makeMap,"-");
- }
- /**
- * PLON_DAOTA_500,PLON_BIANXING_500, UNRECOVER_500, ------500kV倒杆变现未恢复
- * PLON_DAOTA_220,PLON_BIANXING_220, UNRECOVER_220, ------220kV倒杆变现未恢复
- * PLON_DAOTA_110,PLON_BIANXING_110, DUANGAN_110,DAOGAN_110,DIANGAN_QIGNXIE_110, UNRECOVER_110, ------110倒塌断杆倾斜变形未恢复
-
- * PLON_DAOTA_35,PLON_BIANXING_35,DUANGAN_35,DAOGAN_35,DIANGAN_QIGNXIE_35, UNRECOVER_35, ------35倒塌断杆倾斜变形未恢复
- * PLON_DAOTA_10,PLON_BIANXING_10,DUANGAN_10,DAOGAN_10,DIANGAN_QIGNXIE_10, UNRECOVER_10, ------10倒塌断杆倾斜变形未恢复
- * DAUNGAN_DIYA,DAOGAN_DIYA,QINGGAN_DIYA, UNRECOVER_DIYA ------低压断杆倒杆倾斜未恢复
- */
- private Map<String,String> getMakeSheBeiShouSunByLevel(Map<String,String> map){
- Map<String,String> makeMap=new HashMap<String, String>();
- makeMap.put("sum", "PLON_DAOTA_500-PLON_BIANXING_500"
- + "-PLON_DAOTA_220-PLON_BIANXING_220"
- + "-PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110"
- + "-PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35"
- + "-PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10"
- + "-DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
- makeMap.put("unsum", "UNRECOVER_500-UNRECOVER_220-UNRECOVER_110-UNRECOVER_35-UNRECOVER_10-UNRECOVER_DIYA");
- makeMap.put("five", "PLON_DAOTA_500-PLON_BIANXING_500");
- makeMap.put("two", "PLON_DAOTA_220-PLON_BIANXING_220");
- makeMap.put("one", "PLON_DAOTA_110-PLON_BIANXING_110-DUANGAN_110-DAOGAN_110-DIANGAN_QIGNXIE_110");
- makeMap.put("three", "PLON_DAOTA_35-PLON_BIANXING_35-DUANGAN_35-DAOGAN_35-DIANGAN_QIGNXIE_35");
- makeMap.put("ten", "PLON_DAOTA_10-PLON_BIANXING_10-DUANGAN_10-DAOGAN_10-DIANGAN_QIGNXIE_10");
- makeMap.put("diya", "DAUNGAN_DIYA-DAOGAN_DIYA-QINGGAN_DIYA");
-
- return getMakeData(map,makeMap,"-");
- }
-
- /**
- TQ_TD_COUNT,TQ_UNRECOVERED, ----台区停电数
- YH_TD_COUNT,YH_UNRECOVERED, ----用户停电数
- TJYH_TD_COUNT,TJYH_UNRECOVERED, ----特级用户停电数
- YJYH_TD_COUNT,YJYH_UNRECOVERED, ----一级用户停电数
- EJYH_TD_COUNT,EJYH_UNRECOVERED, ----二级用户停电数
- ENERGY_LOSS
- */
-
- /**
- * 获取设备受损汇总数据
- * @param map
- * @return
- */
- private Map<String,String> getYongHuTingDian(Map<String,String> map){
- Map<String,String> makeMap=new HashMap<String, String>();
- makeMap.put("sum", "TJYH_TD_COUNT-YJYH_TD_COUNT-EJYH_TD_COUNT");
- makeMap.put("unsum", "TJYH_UNRECOVERED-YJYH_UNRECOVERED-EJYH_UNRECOVERED");
- return getMakeData(map,makeMap,"-");
- }
-
- private Map<String,String> getYongHuTingDianFloat(Map<String,String> map){
- Map<String,String> makeMap=new HashMap<String, String>();
- makeMap.put("sum", "TJYH_TD_COUNT-YJYH_TD_COUNT-EJYH_TD_COUNT");
- makeMap.put("unsum", "TJYH_UNRECOVERED-YJYH_UNRECOVERED-EJYH_UNRECOVERED");
- return getMakeDataFloat(map,makeMap,"-");
- }
-
- public static Map<String,String> getMakeDataFloat(Map<String,String> mapData,Map<String,String> labelMap,String sprate){
- cf=getChartFactory();
- for(String key:labelMap.keySet()){
- String[] sumArr=labelMap.get(key).split(sprate);
- Float sum = new Float(0);
- for(int index=0,len=sumArr.length;index<len;index++){
- sum+=cf.getFloat(mapData.get(sumArr[index]));
- //log.info(sumArr[index]+"="+mapData.get(sumArr[index])+"===int="+cf.getInt(mapData.get(sumArr[index]))+"=======sum="+sum);
- }
- labelMap.put(key, String.valueOf(sum));
- }
-
- return labelMap;
- }
-
- /**
- * 获取处理之后的数据
- * @param mapData 需要处理的数据
- * @param labelMap 需要处理数据的标签
- * @param sprate 标签的分隔符
- * @return
- */
- public static Map<String,String> getMakeData(Map<String,String> mapData,Map<String,String> labelMap,String sprate){
- cf=getChartFactory();
- for(String key:labelMap.keySet()){
- String[] sumArr=labelMap.get(key).split(sprate);
- Float sum = new Float(0);
- for(int index=0,len=sumArr.length;index<len;index++){
- sum+=cf.getFloat(mapData.get(sumArr[index]));
- //log.info(sumArr[index]+"="+mapData.get(sumArr[index])+"===int="+cf.getInt(mapData.get(sumArr[index]))+"=======sum="+sum);
- }
- labelMap.put(key, String.valueOf(sum));
- }
-
- return labelMap;
- }
-
- /**
- * 获取处理之后的数据
- * @param mapData 需要处理的数据
- * @param labelMap 需要处理数据的标签
- * @param sprate 标签的分隔符
- * @return
- * @throws Exception
- */
- public static Map<String,String> getMakeData(Map<String,String> mapData,Map<String,String> labelMap,String sprate,StringMake makeHandle) throws Exception{
-
- for(String key:labelMap.keySet()){
- String[] sumArr=labelMap.get(key).split(sprate);
- Long sum = new Long(0);
- for(int index=0,len=sumArr.length;index<len;index++){
- sum+=makeHandle.getInt(mapData.get(sumArr[index]));
- // log.info(sumArr[index]+"="+mapData.get(sumArr[index])+"===int="+makeHandle.getInt(mapData.get(sumArr[index]))+"=======sum="+sum);
- }
- labelMap.put(key, String.valueOf(sum));
- }
- return labelMap;
- }
-
-
-
- /**
- * 字符粗替换方案
- * @param digit
- * @return
- */
- private Long getLong(String digit){
- if("".equals(digit.trim()))
- return 0l;
- if(digit.trim().toLowerCase().equals("null"))
- return 0l;
- if(digit==null)
- return 0l;
- /*正则匹配*/
- return Long.valueOf(digit);
- }
-
- /**
- * 字符粗替换方案
- * @param digit
- * @return
- */
- private Float getFloat(String digit){
- if("".equals(digit.trim()))
- return 0.0f;
- if(digit.trim().toLowerCase().equals("null"))
- return 0.0f;
- if(digit==null)
- return 0.0f;
- /*正则匹配*/
- return Float.valueOf(digit);
- }
-
-
- }
|