package neatlogic.module.report.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import neatlogic.framework.common.dto.BasePageVo;
import neatlogic.framework.dao.plugin.PageRowBounds;
import neatlogic.framework.dto.RestVo;
import neatlogic.framework.report.exception.ReportParamNameRepeatsException;
import neatlogic.framework.report.exception.TableNotFoundInReportException;
import neatlogic.framework.sqlrunner.SqlInfo;
import neatlogic.framework.sqlrunner.SqlRunner;
import neatlogic.framework.util.RestUtil;
import neatlogic.framework.util.excel.ExcelBuilder;
import neatlogic.framework.util.excel.SheetBuilder;
import neatlogic.module.report.config.ReportConfig;
import neatlogic.module.report.dao.mapper.ReportInstanceMapper;
import neatlogic.module.report.dao.mapper.ReportMapper;
import neatlogic.module.report.dto.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class ReportServiceImpl implements ReportService {
Logger logger = LoggerFactory.getLogger(ReportServiceImpl.class);
@Resource
private ReportMapper reportMapper;
@Resource
private ReportInstanceMapper reportInstanceMapper;
@Resource
private DataSource dataSource;
private Connection getConnection() throws SQLException {
return dataSource.getConnection();
}
@Override
public ReportVo getReportDetailById(Long reportId) {
ReportVo reportVo = reportMapper.getReportById(reportId);
if (reportVo != null) {
reportVo.setParamList(reportMapper.getReportParamByReportId(reportId));
List<ReportAuthVo> reportAuthList = reportMapper.getReportAuthByReportId(reportVo.getId());
reportVo.setReportAuthList(reportAuthList);
}
return reportVo;
}
private Object getRemoteResult(RestVo restVo) {
String result = RestUtil.sendPostRequest(restVo);
try {
return JSON.parse(result);
} catch (Exception ex) {
return result;
}
}
/**
* 查询报表实例的表格显示列配置
*
* @param reportInstanceId 报表实例id
* @return 结果集
*/
@Override
public Map<String, List<String>> getShowColumnsMap(Long reportInstanceId) {
Map<String, List<String>> showColumnsMap = new HashMap<>();
/* 查询表格显示列配置 */
List<ReportInstanceTableColumnVo> columnList = reportInstanceMapper.getReportInstanceTableColumnList(reportInstanceId);
if (CollectionUtils.isNotEmpty(columnList)) {
/* 根据tableId分组 */
Map<String, List<ReportInstanceTableColumnVo>> columnMap = columnList.stream().collect(Collectors.groupingBy(ReportInstanceTableColumnVo::getTableId));
/* 根据sort排序并取出字段名,组装成tableId与字段列表的map */
for (Map.Entry<String, List<ReportInstanceTableColumnVo>> entry : columnMap.entrySet()) {
List<String> columns = entry.getValue().stream().sorted(Comparator.comparing(ReportInstanceTableColumnVo::getSort)).map(ReportInstanceTableColumnVo::getColumn).collect(Collectors.toList());
showColumnsMap.put(entry.getKey(), columns);
}
}
return showColumnsMap;
}
private List<Map<String, Object>> selectTableColumns(Map<String, List<String>> showColumnsMap, SelectVo select, List<Map<String, Object>> tmpList) {
List<String> showColumnList = showColumnsMap.get(select.getId());
/* 筛选表格显示列 */
for (Map<String, Object> map : tmpList) {
map.entrySet().removeIf(stringObjectEntry -> !showColumnList.contains(stringObjectEntry.getKey()));
}
/* 排序 */
List<Map<String, Object>> sqList = new ArrayList<>();
for (Map<String, Object> map : tmpList) {
Map<String, Object> _map = new LinkedHashMap<>();
for (String s : showColumnList) {
_map.put(s, map.get(s));
}
sqList.add(_map);
}
return sqList;
}
private List<Map<String, Object>> selectTableColumns(List<String> showColumnList, List<Map<String, Object>> tmpList) {
/* 筛选表格显示列 */
for (Map<String, Object> map : tmpList) {
map.entrySet().removeIf(stringObjectEntry -> !showColumnList.contains(stringObjectEntry.getKey()));
}
/* 排序 */
List<Map<String, Object>> sqList = new ArrayList<>();
for (Map<String, Object> map : tmpList) {
Map<String, Object> _map = new LinkedHashMap<>();
for (String s : showColumnList) {
_map.put(s, map.get(s));
}
sqList.add(_map);
}
return sqList;
}
private Map<String, List> wrapResultMapToMap(ResultMapVo resultMapVo, Map<String, Object> result, Map<String, List> returnMap) {
StringBuilder key = new StringBuilder();
List<Map<String, Object>> resultList = null;
if (resultMapVo.getGroupByList() != null && resultMapVo.getGroupByList().size() > 0) {
for (int i = 0; i < resultMapVo.getGroupByList().size(); i++) {
key.append(result.get(resultMapVo.getGroupByList().get(i)));
if (i < resultMapVo.getGroupByList().size() - 1) {
key.append("-");
}
}
} else {
return null;
}
Map<String, Object> newResult = new HashMap<>();
if (!key.toString().equals("") && returnMap.containsKey(key.toString())) {
resultList = returnMap.get(key.toString());
} else {
resultList = new ArrayList<>();
returnMap.put(key.toString(), resultList);
}
// Iterator<Map.Entry<String, Object>> iter =
// result.entrySet().iterator();
for (String str : resultMapVo.getPropertyList()) {
newResult.put(str, result.get(str));
}
resultList.add(newResult);
return returnMap;
}
/**
* 判断这一条数据是否已经存在
*
* @param resultMapVo 结果数据
* @param resultList 结果数据
* @param result 结果数据
* @param checkMap 中途结果
* @return 结果
*/
private Boolean isExists(ResultMapVo resultMapVo, List<Map<String, Object>> resultList, Map<String, Object> result, Map<String, Map<String, Object>> checkMap) {
boolean isExists = false;
StringBuilder key = new StringBuilder();
if (resultList == null) {
resultList = new ArrayList<Map<String, Object>>();
}
if (resultMapVo.getGroupByList() != null && resultMapVo.getGroupByList().size() > 0) {
for (int i = 0; i < resultMapVo.getGroupByList().size(); i++) {
key.append(result.get(resultMapVo.getGroupByList().get(i)));
if (i < resultMapVo.getGroupByList().size() - 1) {
key.append("-");
}
}
} else if (resultMapVo.getPropertyList() != null && resultMapVo.getPropertyLi
没有合适的资源?快使用搜索试试~ 我知道了~
基于Java的报表模块,支持自定义SQL和报表模板 -2025
共107个文件
java:86个
xml:9个
png:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 149 浏览量
2025-01-03
11:36:31
上传
评论
收藏 707KB ZIP 举报
温馨提示
基于Java的报表模块,支持自定义SQL和报表模板。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java的报表模块,支持自定义SQL和报表模板 -2025 (107个子文件)
ReportServiceImpl.java 36KB
ReportXmlUtil.java 30KB
JfreeChartUtil.java 13KB
DrawStackedBarLineH.java 12KB
DrawBarLineH.java 11KB
ReportSendJob.java 10KB
ReportFreemarkerUtil.java 10KB
ReportImportApi.java 10KB
ReportSendJobSaveApi.java 9KB
DrawPagination.java 9KB
DrawTable.java 9KB
DrawStackedBarH.java 9KB
GetReportApi.java 8KB
ShowReportDetailApi.java 8KB
DrawStackedBar.java 7KB
ReportInstanceVo.java 7KB
GetReportInstanceApi.java 7KB
ExportReportDetailApi.java 7KB
SaveReportInstanceApi.java 7KB
GetReportTableApi.java 7KB
DrawBar.java 6KB
SqlUtilTestApi.java 6KB
DrawBarH.java 5KB
SaveReportApi.java 5KB
ReportDataBuilder.java 5KB
ReportListApi.java 5KB
DrawPie.java 5KB
ReportInstanceListApi.java 5KB
MatrixReportParamDependencyHandler.java 5KB
ReportVo.java 5KB
DrawLine.java 5KB
ReportSendJobSearchApi.java 5KB
ReportSendJobGetApi.java 5KB
ReportSendJobVo.java 4KB
SelectVo.java 4KB
ReportExportApi.java 4KB
ReportSendJobAuditSearchApi.java 4KB
ReportSendJobStatusUpdateApi.java 4KB
SaveReportStatementApi.java 4KB
SearchReportApi.java 4KB
ReportSendJobDeleteApi.java 4KB
SaveReportBlackWhiteListApi.java 3KB
UpdateReportInstanceActiveApi.java 3KB
ReportInstanceDeleteApi.java 3KB
DeleteReportApi.java 3KB
SearchReportBlackWhiteListApi.java 3KB
SearchReportInstanceApi.java 3KB
GetReportTypeApi.java 3KB
SearchReportStatementApi.java 3KB
UpdateReportActiveApi.java 3KB
ReportSortFilter.java 3KB
ToggleReportStatementActiveApi.java 3KB
SearchDistrictDataApi.java 3KB
GetReportStatementApi.java 2KB
ReportParamVo.java 2KB
DeleteReportStatementApi.java 2KB
GetReportBlackWhiteListApi.java 2KB
ResultMapVo.java 2KB
ReportTypeVo.java 2KB
ReportMapper.java 2KB
ReportSendJobMapper.java 2KB
ResetDatasourceJobStatusStartupHandler.java 2KB
StatementResourceFileHandler.java 2KB
ReportInstanceMapper.java 2KB
ReportAuthVo.java 2KB
REPORT_ADMIN.java 1KB
REPORT_STATEMENT_MODIFY.java 1KB
ReportInstanceAuthVo.java 1KB
ReportSendJobRelationVo.java 1KB
BlackWhiteType.java 1KB
ActionType.java 1KB
REPORT_TEMPLATE_MODIFY.java 1KB
ReportConfigMapper.java 1KB
ReportStatementMapper.java 1KB
ReportService.java 1KB
ReportInstanceTableColumnVo.java 1KB
ReportDataMapper.java 994B
ReportInstanceServiceImpl.java 923B
ReportReceiverVo.java 921B
ReportConfig.java 860B
ReportTableMapper.java 799B
test.java 775B
REPORT_MODIFY.java 650B
ReportSendJobAuditVo.java 595B
REPORT_BASE.java 423B
ReportInstanceService.java 212B
img6.png 144KB
img4.png 91KB
img5.png 77KB
img.png 68KB
img2.png 58KB
img1.png 53KB
img3.png 52KB
origin_gitee.sh 1KB
origin_gitlab.sh 1KB
autotag.sh 1KB
ddl.sql 11KB
ReportMapper.xml 11KB
ReportSendJobMapper.xml 11KB
ReportInstanceMapper.xml 6KB
共 107 条
- 1
- 2
资源评论
薪薪代码
- 粉丝: 3w+
- 资源: 555
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 【岗位说明】生物科技有限公司员工岗位职责.doc
- 【岗位说明】省中医院药材挑选岗位操作规程.doc
- 【岗位说明】外科护士长岗位说明书.doc
- 【岗位说明】药房药店最新岗位职责.doc
- 【岗位说明】药剂师中药师岗位职责.doc
- 【岗位说明】医美机构市场部人员岗位职责说明书.doc
- 【岗位说明】医疗投资集团组织结构及各岗位说明.doc
- 【岗位说明】医疗器械经营企业各岗位职责.doc
- 【岗位说明】医药行业制度制药公司市场部岗位职责范本.doc
- 【岗位说明】医院信息科岗位职责说明.doc
- 【岗位说明】责任护士岗位说明书.doc
- 【岗位说明】执业药师及药师岗位职责.doc
- 【岗位说明】制药企业岗位职责制.doc
- 【岗位说明】用药咨询药师职责.doc
- 【岗位说明】中草药煎药人员岗位职责.doc
- 【岗位说明】中药处理岗位操作规程.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功