欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

flashchart图表DEMO,flashchartdemo,/****获取数据的方法

来源: javaer 分享于  点击 14583 次 点评:193

flashchart图表DEMO,flashchartdemo,/****获取数据的方法


/****获取数据的方法(实际就是自己拼装JSON)**/public String GetchartData1(String id, int timetype,String time1,String time2) {        try{            ResultSet JHSet=new ResultSet();            String JHSql="select orgname,topOrgId from lbipdbstatic where toporgid ='"+id+"'";            JHSet = Global.getInstance().getDataSource().ExecuteSQL(JHSql);            ChartSql chartsql=new ChartSql();            if (JHSet != null && JHSet.getSize() != 0) {                String orgname=JHSet.GetCellValue(0, "orgname");                String date1=DateFunc.getCurrentDateString().substring(0, 10);                Date date=new Date();                String startdate=null;                String startdate1=null;                String enddate=null;                String enddate1=null;                String types=null;        if(timetype==2){//月                 String fist=DateFunc.getMonthStart(Integer.parseInt(date1.split("-")[0]), date.getMonth()+1);                  startdate =fist+" 00:00:00";                  startdate1=fist+" 23:59:59";                  enddate = DateFunc.getCurrentDateString().substring(0, 10)+" 00:00:00";                  enddate1 = DateFunc.getCurrentDateString().substring(0, 10)+" 23:59:59";                   types="本月";        }else if(timetype==1){//周              Date first=DateFunc.getFirstOfWeekOneDate(date);              Date zhouyi=DateFunc.nDaysAfterOneDate(first, 2);              startdate =DateFunc.getDateString(zhouyi).substring(0, 10)+" 00:00:00";              startdate1 =DateFunc.getDateString(zhouyi).substring(0, 10)+" 23:59:59";              enddate = DateFunc.getCurrentDateString().substring(0, 10)+" 00:00:00";              enddate1 = DateFunc.getCurrentDateString().substring(0, 10)+" 23:59:59";              types="本周";        }else if(timetype==3){//季度              Date first=DateFunc.getDateFromString(getLastSeasonEnd(), "yyyy-MM-dd");              Date jichu=DateFunc.nDaysAfterOneDate(first, 2);              startdate =DateFunc.getDateString(jichu).substring(0, 10)+" 00:00:00";              startdate1 =DateFunc.getDateString(jichu).substring(0, 10)+" 23:59:59";              enddate = DateFunc.getCurrentDateString().substring(0, 10)+" 00:00:00";              enddate1 = DateFunc.getCurrentDateString().substring(0, 10)+" 23:59:59";              types="本季度";        }else if(timetype==4){//指定              startdate =time1.substring(0, 10)+" 00:00:00";              startdate1 =time1.substring(0, 10)+" 23:59:59";              enddate = time2.substring(0, 10)+" 00:00:00";              enddate1 = time2.substring(0, 10)+" 23:59:59";              types=time1+"到"+time2;        }        String sql = null;        String sql1 = null;        if(startdate!=null && enddate!=null){                sql = "select  bsdocument as \\"报送公文\\" " +                ", cbdocument as \\"承办公文\\" , cuibdocument as \\"被催办公文\\" , hongpsum as \\"红牌\\", huangpsum as \\"黄牌\\" " +                ", jjdocument as \\"急件公文\\", waitetodo as \\"待办公文\\"" +                "  from lbipdbstatic where orgname='"+orgname+"' and TO_CHAR(staticdate,'yyyy-mm-dd hh24:mi:ss') >= '"+                startdate +"' and TO_CHAR(staticdate,'yyyy-mm-dd hh24:mi:ss') <= '" + startdate1 + "'";                sql1 = "select  bsdocument as \\"报送公文\\" " +                ", cbdocument as \\"承办公文\\" , cuibdocument as \\"被催办公文\\" , hongpsum as \\"红牌\\", huangp as \\"黄牌\\" " +                ", jjdocument as \\"急件公文\\", waitetodo as \\"待办公文\\"" +                "  from lbipdbstatic where orgname='"+orgname+"' and TO_CHAR(staticdate,'yyyy-mm-dd hh24:mi:ss') >= '"+                enddate +"' and TO_CHAR(staticdate,'yyyy-mm-dd hh24:mi:ss') <= '" + enddate1 + "'";        }          String names[]= new String[]{"报送公文","承办公文","被催办公文","红牌","黄牌","急件公文","待办公文"};        ResultSet rs = Global.getInstance().getDataSource().ExecuteSQL(sql);        ResultSet rs1 = Global.getInstance().getDataSource().ExecuteSQL(sql1);        String[][] data = new String[8][2];         for(int i=0;i<7;i++){             int max=0;             int min=0;             if(rs!=null){                 min=Integer.parseInt(rs.GetCell(0, i));             }             if(rs1!=null){                 max=Integer.parseInt(rs1.GetCell(0, i));             }             data[i][0]=names[i];             if((timetype==4&&!time1.equals(time2))||timetype!=4){                 data[i][1]=(max-min)+"";             }else{                 data[i][1]=max+"";             }         }        String  title="["+startdate.substring(0, 10).split("-")[1]+"月"+startdate.substring(0, 10).split("-")[2]+"日"+"到";        String  title1=enddate.substring(0, 10).split("-")[1]+"月"+enddate.substring(0, 10).split("-")[2]+"日"+"]";         data[7][0]=orgname+types+"公文统计"+title+title1;         int result=0;            for  (int i=0;i<7;i++){                result = Math.max(result,Integer.parseInt(data[i][1]));            }            data[7][1]=result+"";               int hongp=chartsql.getHonggpsums(orgname, startdate, enddate1);            int huangp=chartsql.getHuangpsums(orgname, startdate, enddate1);        return ChartJson.getInstance().getChart2(data,hongp,huangp);            }        }catch (Exception e){            Global.getInstance().LogError(this, e);            return null;        }        return null;    }/****数据实现方法**/public String getChart2(String[][] data,int hongp,int huangp) {        int ymax = Integer.parseInt(data[7][1]);        JBarChart barchart = new JBarChart();        BarValue[] values = new BarValue[7];        List<Object> xLabel = new ArrayList<Object>();        for (int j = 0; j < 7; j++) {            if(j==3){                BarValue bar = new BarValue();                bar.setBottom(0.0);                bar.setTop(hongp);                bar.setTip(data[j][0] + ":" + hongp + "件");                bar.setColour(colors[this.getRamdom(14)]);                values[j] = bar;                xLabel.add(data[j][0]);            }else if(j==4){                BarValue bar = new BarValue();                bar.setBottom(0.0);                bar.setTop(huangp);                bar.setTip(data[j][0] + ":" + huangp + "件");                bar.setColour(colors[this.getRamdom(14)]);                values[j] = bar;                xLabel.add(data[j][0]);            }else{                BarValue bar = new BarValue();                Double value = Double.valueOf(data[j][1]);                bar.setBottom(0.0);                bar.setTop(value);                bar.setTip(data[j][0] + ":" + value.shortValue() + "件");                bar.setColour(colors[this.getRamdom(14)]);                values[j] = bar;                xLabel.add(data[j][0]);            }        }        XAxis labels = new XAxis();        labels.setLabelList(xLabel);        barchart.addBars(values);        YAxis yAxis = new YAxis();        yAxis.setMax(ymax);        yAxis.setMin(0);        yAxis.setSteps(Math.floor(ymax / 9));        barchart.setyAxis(yAxis);        barchart.setTitle(data[7][0]);        barchart.setxAxis(labels);        return barchart.toJSONString();    }}//该片段来自于http://byrx.net
相关栏目:

用户点评