123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- package com.sinosoft.cm.chart.util;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import com.sinosoft.cm.chart.service.SystemDataSourceChartServiceImpl;
- import flex.messaging.io.ArrayList;
- public class SystemDataSourceChartFactory {
- public final static String XLT_SUM="xianlutiaozha";
- public final static String DG_SOU_SUN_LEI_XING_AND_SUM="shousunleixing";
- public final static String DG_SOU_SUN_ZHU_PEI_SUM= "shousunzhupei";
- public final static String DG_SOU_SUN_BY_LEVEL="shousunbylevel";
- private static SystemDataSourceChartFactory cf=new SystemDataSourceChartFactory();
- private static final Log log = LogFactory.getLog(SystemDataSourceChartServiceImpl.class);
- private SystemDataSourceChartFactory() {
-
- }
- public static SystemDataSourceChartFactory getChartFactory(){
- if(cf==null){
- cf=new SystemDataSourceChartFactory();
- }
- 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("shousunleixing".equals(charType.trim())){
- return cf.getMakeSheBeiShouSunType(map);
- }else if("shousunzhupei".equals(charType.trim())){
- return cf.getMakeSheBeiShouSun(map);
- }else if("shousunbylevel".equals(charType.trim())){
- return cf.getMakeSheBeiShouSunByLevel(map);
- }
-
- return null;
- }
-
- /*
- *
- * ROUTE_DMJTD_LJSDXLTZQK
- * {LJSDXLTZ_TZZS1,500KV线路跳闸总数},
- * {LJSDXLTZ_CHCG1,500KV线路重合成功}, {LJSDXLTZ_QSCG1,500KV线路强送成功},
- * {LJSDXLTZ_YJGZYS1,500KV线路永久故障已送}, {LJSDXLTZ_WHFTS1,500KV线路未恢复条数},
- *
- * {LJSDXLTZ_TZZS2,220KV线路跳闸总数}, {LJSDXLTZ_CHCG2,220KV线路重合成功},
- * {LJSDXLTZ_QSCG2,220KV线路强送成功}, {LJSDXLTZ_YJGZYS2,220KV线路永久故障已送},
- * {LJSDXLTZ_WHFTS2,220KV线路未恢复条数},
- *
- * {LJSDXLTZ_TZZS3,110KV线路跳闸总数},
- * {LJSDXLTZ_CHCG3,110KV线路重合成功}, {LJSDXLTZ_QSCG3,110KV线路强送成功},
- * {LJSDXLTZ_YJGZYS3,110KV线路永久故障已送},
- * {LJSDXLTZ_WHFTS3,110KV线路未恢复条数},
- *
- * {LJSDXLTZ_TZZS4,35KV线路跳闸总数}, {LJSDXLTZ_WHFTS4,35KV线路未恢复条数},
- *
- * {LJSDXLTZ_TZZS5,10KV线路跳闸总数}, {LJSDXLTZ_WHFTS5,10KV线路未恢复条数}, {COLUMN_1,0},
- * {COLUMN_2,0}, {COLUMN_3,0}, {COLUMN_4,0}, {COLUMN_5,0}, {COLUMN_6,0}
- */
- private Map<String,String> getMakeXianlutiaozha(Map<String,String> map){
- Map<String,String> makeMap=new HashMap<String, String>();
- makeMap.put("sum", "LJSDXLTZ_TZZS1-LJSDXLTZ_TZZS2-LJSDXLTZ_TZZS3-LJSDXLTZ_TZZS4-LJSDXLTZ_TZZS5");
- makeMap.put("unsum", "LJSDXLTZ_WHFTS1-LJSDXLTZ_WHFTS2-LJSDXLTZ_WHFTS3-LJSDXLTZ_WHFTS4-LJSDXLTZ_TZZS5");
- 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", "PRESSURE_LOSS_ONE-PRESSURE_LOSS_TWO-PRESSURE_LOSS_THREE-PRESSURE_LOSS_FOUR");
- makeMap.put("unsum", "NO_RECOVER_ONE-NO_RECOVER_TWO-NO_RECOVER_THREE-NO_RECOVER_FOUR");
- 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,"-");
- }
-
-
-
- /**
- * 获取处理之后的数据
- * @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);
- Long sum = new Long(0);
- for(int index=0,len=sumArr.length;index<len;index++){
- log.info(key+"="+sumArr[index]);
- String tempKey=sumArr[index];
- String tempValue=(mapData.get(sumArr[index]));
- sum+=cf.getLong(tempValue);
- }
- labelMap.put(key, String.valueOf(sum));
- }
-
- return labelMap;
- }
-
-
- public static void main(String[] args) {
- Map<String,String> mapLable=new HashMap<String, String>();
- mapLable.put("sum","aa -bb -cc");
- mapLable.put("unsum","dd1-ee1");
- Map map=new HashMap<String, String>();
- map.put("aa","1");
- map.put("bb","1");
- map.put("cc","1");
- map.put("dd","2");
- map.put("ee","3");
- map=getMakeData(map,mapLable,"-");
- System.out.println(map);
-
- }
-
- /**
- * 获取处理之后的数据
- * @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(null==digit)
- return 0l;
- if("".equals(digit.trim()))
- return 0l;
- if(digit.trim().toLowerCase().equals("null"))
- return 0l;
- /*正则匹配*/
- return Long.valueOf(digit);
- }
-
-
- }
|