package com.laq.chart.dao.impl;
import com.laq.bean.ResultData;
import com.laq.chart.dao.EChartDao;
import com.laq.chart.model.EChart;
import com.laq.chart.model.EChartSeries;
import com.laq.common.util.BigDecimalUtils;
import com.laq.common.util.BigDecimalUtils.NumericZoom;
import com.laq.common.util.DateUtils;
import com.laq.dao.DaoException;
import com.laq.dao.impl.AbstractDao;
import com.joyintech.jupiter.workflow.commons.utils.CommonUtil;
import oracle.jdbc.OracleTypes;
import org.hibernate.HibernateException;
import org.hibernate.JDBCException;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* EChartDaoImpl EChart图表
*
* @author laq
* @version 1.0
* @since 2022-11
*/
@SuppressWarnings("all")
public class EChartDaoImpl extends AbstractDao implements EChartDao {
@Override
public ResultData callProcedure_CHART_DB_TERM_RATE(EChart eChart) throws DaoException {
String methodName = "callProcedure_CHART_DB_TERM_RATE";
info(methodName, "图表-折线图 param[eChart]:" + eChart);
ResultData resultData = new ResultData();
resultData.setSuccess(false);
try {
// 获取数据集合-形式可自行选择
CallableStatement statement = this.getSession().connection().prepareCall("{call PROC_CHART_DB_TERM_RATE(?,?,?)}");
if (CommonUtil.isNotEmpty(eChart.getDatePoint())) {
statement.setDate(1, new java.sql.Date(eChart.getDatePoint().getTime()));
} else {
statement.setDate(1, null);
}
statement.registerOutParameter(2, OracleTypes.CURSOR);
statement.registerOutParameter(3, OracleTypes.CURSOR);
statement.execute();
ResultSet rs1 = (ResultSet) statement.getObject(2);
ResultSet rs2 = (ResultSet) statement.getObject(3);
// x轴
Map<String, Object> xAxis = new HashMap<>();
List<String> xAxisData = new ArrayList<>();
while (rs1 != null && rs1.next()) {
xAxisData.add(DateUtils.formatDateString(rs1.getDate("cdate")));// 日期
}
xAxis.put("type", "category");
xAxis.put("data", xAxisData);
eChart.setxAxis(xAxis);
// legend 属性
Map<String, Object> legend = new HashMap<>();
legend.put("orient", "vertical");
legend.put("left", "right");
legend.put("right", "50");
eChart.setLegend(legend);
// y轴
Map<String, Object> yAxis = new HashMap<>();
Map<String, Object> axisLabel = new HashMap<>();
axisLabel.put("formatter", "{value} %");
yAxis.put("type", "value");
yAxis.put("axisLabel", axisLabel);
eChart.setyAxis(yAxis);
// series数据组
List<EChartSeries> eChartSeriesList = new ArrayList<>();// 线合集
EChartSeries eChartSeries = new EChartSeries();// 一条线
List<String> seriesData = new ArrayList<>();// 线上点
String name = "";
while (rs2 != null && rs2.next()) {
if (CommonUtil.isEmpty(name)) {// 初次进入
name = rs2.getString("termtype");
}
else if (name.equals(rs2.getString("termtype"))) {// 同一条线name相同
} else {// 当线发生变更时,将当前线放入图表
eChartSeries.setName(name);// 类型
eChartSeries.setType("line");
eChartSeries.setData(seriesData);// 线上点集合
eChartSeriesList.add(eChartSeries);// 加上线
seriesData = new ArrayList<>();
eChartSeries = new EChartSeries();
name = rs2.getString("termtype");
}
// 追加线上的点
seriesData.add(BigDecimalUtils.formatNumeric(rs2.getBigDecimal("weightrate"), NumericZoom.Percent, 4));// 权重利率
}
// 最后一组名称已经不会再变化
eChartSeries.setName(name);// 类型
eChartSeries.setType("line");
eChartSeries.setData(seriesData);// 线上点集合
eChartSeriesList.add(eChartSeries);// 加上线
eChart.setEChartSeriesList(eChartSeriesList);
resultData.setObject(eChart);
resultData.setSuccess(true);
resultData.setResultMessage("调用 " + methodName + " 成功");
} catch (JDBCException ex) {
error(methodName, "Error call proc By Param Query method " + methodName, ex);
throw new DaoException(DaoException.ERROR_GENERIC_JDBC_EXCEPTION, ex);
} catch (HibernateException ex) {
error(methodName, "Error call proc Param Query method " + methodName, ex);
throw new DaoException(DaoException.ERROR_HIBERNATE, ex);
} catch (IllegalStateException ex) {
error(methodName, "Error call proc Param Query method " + methodName, ex);
throw new DaoException(DaoException.ERROR_UNKNOWN_EXCEPTION, ex);
} catch (SQLException ex) {
error(methodName, "Error call proc Param Query method " + methodName, ex);
throw new DaoException(DaoException.ERROR_SQL_GRAMMAR_EXCEPTION, ex);
} catch (Exception e) {
resultData.setSuccess(false);
resultData.setResultMessage("调用 " + methodName + " 异常");
error(methodName, e.getMessage());
e.printStackTrace();
}
return resultData;
}
@Override
public ResultData callProcedure_CHART_RZJE(EChart eChart) throws DaoException {
String methodName = "callProcedure_CHART_RZJE";
info(methodName, "图表-柱状图 param[eChart]:" + eChart);
ResultData resultData = new ResultData();
resultData.setSuccess(false);
try {
// 获取数据集合-形式可自行选择
CallableStatement statement = this.getSession().connection().prepareCall("{call PROC_CHART_RZJE(?,?,?)}");
if (CommonUtil.isNotEmpty(eChart.getDatePoint())) {
statement.setDate(1, new java.sql.Date(eChart.getDatePoint().getTime()));
} else {
statement.setDate(1, null);
}
statement.registerOutParameter(2, OracleTypes.CURSOR);
statement.registerOutParameter(3, OracleTypes.CURSOR);
statement.execute();
ResultSet rs1 = (ResultSet) statement.getObject(2);
ResultSet rs2 = (ResultSet) statement.getObject(3);
// legend 属性
Map<String, Object> legend = new HashMap<>();
legend.put("orient", "vertical");
legend.put("left", "right");
legend.put("right", "0");
eChart.setLegend(legend);
// x轴
Map<String, Object> xAxis = new HashMap<>();
List<String> xAxisData = new ArrayList<>();
while (rs1 != null && rs1.next()) {
xAxisData.add(rs1.getString("datename"));// 日期
}
xAxis.put("type", "category");
xAxis.put("data", xAxisData);
eChart.setxAxis(xAxis);
// y轴
Map<String, Object> yAxis = new HashMap<>();
Map<String, Object> axisLabel = new HashMap<>();
axisLabel.put("formatter", "{value} 亿元");
yAxis.put("type", "value");
yAxis.put("axisLabel", axisLabel);
eChart.setyAxis(yAxis);
// series数据组
List<EChartSeries> eChartSeriesList = new ArrayList<>();// 线合集
EChartSeries eChartSeries = new EChartSeries();// 一条线
List<String> seriesData = new ArrayList<>();// 线上点
String name = "";
while (rs2 != null && rs2.next()) {
if (CommonUtil.isEmpty(name)) {// 初次进入
name = rs2.getString("termtype");
}
else if (name.equals(rs2.getString("termtype"))) {// 同一条线name相同
} else {// 当线发生变更时,将当前线放入图表
eChartSeries.setName(name);// 类型
eChartSeries.setType("bar");
eChartSeries.setStack("rzje");// 堆叠组
eChartSeries.setData(seriesData);// 线上点集合
eChartSeriesList.add(eChartSeries);// 加上线
seriesData = new ArrayList<>();
eChartSeries = new EChartSeries();
name = rs2.getString("termtype");
}
// 追加线上的点
seriesData.add(BigDecimalUtils.formatNumeric(rs2.getBigDecimal("dealamt"), NumericZoom.Billion, 4).replace(",", ""));// 交易金额
}
// 最后一组名称已经不会再变化
eChartSeries.setName(name);// 类
没有合适的资源?快使用搜索试试~ 我知道了~
Javaweb JavaScript EChart 图表插件 echarts.min.js 与与后台交互等资源
共13个文件
js:7个
java:4个
jsp:2个
需积分: 0 3 下载量 20 浏览量
2023-03-22
11:07:54
上传
评论
收藏 2.17MB ZIP 举报
温馨提示
Javaweb JavaScript EChart 图表插件 echarts.min.js 与与后台交互等资源
资源推荐
资源详情
资源评论
收起资源包目录
echarts.zip (13个子文件)
manylinechart.jsp 5KB
echarts.min.5.4.1.js 1.3MB
echarts.min.5.2.0.js 1.33MB
barchart.jsp 4KB
echarts.min.4.0.0.js 912KB
echarts.min.4.9.0.js 1023KB
echarts.js 3.26MB
EChart.java 3KB
echarts.min.5.0.0.js 1.28MB
EChartDao.java 771B
EChartSeries.java 4KB
echarts.min.js 1023KB
EChartDaoImpl.java 9KB
共 13 条
- 1
资源评论
Raphael-laq
- 粉丝: 10
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功