diff --git a/README.en.md b/README.en.md index 27ef5db860b1c7b7ed220298460308756e46b004..1e4b7f408ea8df84e202e2ce092e8096679aecc1 100644 --- a/README.en.md +++ b/README.en.md @@ -1,14 +1,20 @@ ## Online experience -####   Computer online experience: [https://report.anji-plus.com/](https://report.anji-plus.com/ "链接")  account:guest password:guest -####   Online documents: [https://report.anji-plus.com/report-doc/](https://report.anji-plus.com/report-doc/ "doc")
-####   issues: [https://gitee.com/anji-plus/report/issues](https://gitee.com/anji-plus/report/issues "issue") + +####   Computer online experience: [https://ajreport.beliefteam.cn/](https://ajreport.beliefteam.cn/ "链接")  account:guest password:guest + +####   Online documents: [https://ajreport.beliefteam.cn/report-doc/](https://ajreport.beliefteam.cn/report-doc/ "doc")
+ +####   issues: [https://gitee.com/anji-plus/report/issues](https://gitee.com/anji-plus/report/issues "issue") ## Function overview -####   Component introduction -   (AJ-Report)is a visual drag edit, intuitive, cool, with a sense of science and technology chart tool full open source project. -The built-in basic functions include data source, data set, report management, and some screenshots of the project are shown below.。
+####   Component introduction + +   (AJ-Report)is a visual drag edit, intuitive, cool, with a sense of science and technology chart tool full +open source project. +The built-in basic functions include data source, data set, report management, and some screenshots of the project are +shown below.。
## Packaging directory @@ -26,6 +32,7 @@ The built-in basic functions include data source, data set, report management, a ``` ## System directory + ``` ├── doc │ ├── docs @@ -40,11 +47,12 @@ The built-in basic functions include data source, data set, report management, a ├── README.md ``` - ## Short term plan -####   Enrich more chart components + +####   Enrich more chart components ## technical support + If you have any questions, please submit to [Issue](https://gitee.com/anji-plus/report/issues) #### Open source is not easy, please, star ☺ diff --git a/README.md b/README.md index 4e3ffc8a1b8d8ddb8ad53f7582647bbb74d6bf4b..173f5170750bbdb7057ad743d3877b2ab4c7683d 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ ## 在线体验 -####   [在线体验](https://report.anji-plus.com/index.html "链接"): https://report.anji-plus.com/index.html  体验账号:guest 密码:guest +####   [在线体验](https://ajreport.beliefteam.cn/index.html "链接"): https://ajreport.beliefteam.cn/index.html  体验账号:guest 密码:guest -####   [在线文档](https://report.anji-plus.com/report-doc/ "doc"): https://report.anji-plus.com/report-doc/
+####   [在线文档](https://ajreport.beliefteam.cn/report-doc/ "doc"): https://ajreport.beliefteam.cn/report-doc/
####   [在线提问](https://gitee.com/anji-plus/report/issues "issue"): https://gitee.com/anji-plus/report/issues
@@ -23,10 +23,8 @@    大屏设计(AJ-Report)是一个可视化拖拽编辑的,直观,酷炫,具有科技感的图表工具全开源项目。 内置的基础功能包括数据源,数据集,报表管理,项目部分截图如下。
![操作](https://images.gitee.com/uploads/images/2021/0703/094742_c0243f70_1728982.gif "2021-07-03_09-43-50.gif") - -![视频](https://report.anji-plus.com/report-doc/static/Rhea.mp4)
- -**[更多社区大屏案例](https://report.anji-plus.com/report-doc/guide/bigScreenCase.html)**
+![视频](https://ajreport.beliefteam.cn/report-doc/static/Rhea.mp4)
+**[更多社区大屏案例](https://ajreport.beliefteam.cn/report-doc/guide/bigScreenCase.html)**
## 数据流程图 @@ -91,7 +89,28 @@ - [vuedraggable](https://github.com/SortableJS/Vue.Draggable/): 是一款基于Sortable.js实现的vue拖拽插件。 - [luckysheet](https://gitee.com/mengshukeji/Luckysheet): Luckysheet ,一款纯前端类似excel的在线表格,功能强大、配置简单、完全开源。 -## 编译打包 +## 部署方式 + +**注意版本兼容性**
+源码 doc -> docs -> guide 目录下即所有文档
+ +### 发行版部署 + +``` +下载最新发行版,解压 +cd aj-report-xxxx +vim conf/bootstrap.yml 修改数据库连接等信息 +sh bin/start.sh Linux启动 +bin/start.bat Windows修改第4行的JAVA_HOME后(去掉rem注释),双击启动 + +启动后访问 +http://serverip:9095 +用户名密码:admin/123456 + +登陆后修改"数据源->mysql数据源"用户名密码 +``` + +### 源码编译部署 在Linux上先准备好maven、node.js、jdk @@ -113,21 +132,23 @@ bin/start.bat Windows修改第4行的JAVA_HOME后(去掉rem注释),双击启 启动后访问 http://serverip:9095 +用户名密码:admin/123456 + +登陆后修改"数据源->mysql数据源"用户名密码 ``` -**[运行环境参考文档](https://report.anji-plus.com/report-doc/guide/quicklyDevelop.html)**
+**[运行环境参考文档](https://ajreport.beliefteam.cn/report-doc/guide/quicklyDevelop.html)**
-**[源码编译部署参考文档](https://report.anji-plus.com/report-doc/guide/quicklySource.html)**
+**[源码编译部署参考文档](https://ajreport.beliefteam.cn/report-doc/guide/quicklySource.html)**
-**[发行版部署参考文档](https://report.anji-plus.com/report-doc/guide/quicklyDistribution.html)**
+**[发行版部署参考文档](https://ajreport.beliefteam.cn/report-doc/guide/quicklyDistribution.html)**
-**[前后端分离部署参考文档](https://report.anji-plus.com/report-doc/guide/quicklySeparate.html)**
+**[前后端分离部署参考文档](https://ajreport.beliefteam.cn/report-doc/guide/quicklySeparate.html)**
## 操作手册 新建数据源(重置mysql数据源) --> 新建数据集(编写sql) --> 新建大屏(设计大屏)
- -**[在线文档](https://report.anji-plus.com/report-doc/guide/datasource.html)** +**[在线文档](https://ajreport.beliefteam.cn/report-doc/guide/datasource.html)** ## SQL初始化 @@ -140,14 +161,13 @@ sql文件的目录在:report-core --> src --> main --> resources -- > db.migra 希望你们的logo出现在此,[请点此Issue进行登记](https://gitee.com/anji-plus/report/issues/I3ZXT4) ,我们将优先进行技术支持
- + - - -
- - - + + +
+ + ## 未来计划 @@ -169,8 +189,7 @@ sql文件的目录在:report-core --> src --> main --> resources -- > db.migra - openJdk - Jdk 11 - Mysql 8.0(8.0.23/26版本没有问题,8.0.21版本存在问题) - -**[常见问题](https://report.anji-plus.com/report-doc/guide/question.html)** + **[常见问题](https://ajreport.beliefteam.cn/report-doc/guide/question.html)** ## 商业授权 @@ -183,12 +202,13 @@ AJ-Report使用[Apache2.0开源协议](http://www.apache.org/licenses/LICENSE-2. - 在二次开发后商业发布的产品中,使用了多个开源软件,则必须包含一个Notice文件,在Notice文件中需要带有AJ-Report LICENSE。你可以在Notice中增加自己的许可,但不可以表现为对AJ-Report LICENSE构成更改。 -如果您需要商业化增值服务,请加下面的微信沟通。 +如果您需要商业化增值服务,请加下面的微信沟通,并直接说明来意。 ## 技术支持 **如有问题,请提交 [Issue](https://gitee.com/anji-plus/report/issues)
** -个人企业微信:
+个人企业微信:加微信进群备注 AJ-Report 或者 Report
+如果不是为了进群,请直接说明来意,每天加群的都很多,企微也是我们自己的工作企微,会有很多消息会被刷下去,如果半天没有回复你,请发送多次
#### 开源不易,劳烦各位star ☺ diff --git a/doc/docs/guide/README.md b/doc/docs/guide/README.md index 6af10628a8224b30774eeae023a811a3cc45cd4c..ef54e6f99c9784f12d03d63d52cced68996fba82 100644 --- a/doc/docs/guide/README.md +++ b/doc/docs/guide/README.md @@ -10,7 +10,7 @@ ## 在线体验 -####   [在线体验](https://report.anji-plus.com/index.html "链接"): https://report.anji-plus.com/index.html  体验账号:guest 密码:guest +####   [在线体验](https://ajreport.beliefteam.cn/index.html "链接"): https://ajreport.beliefteam.cn/index.html  体验账号:guest 密码:guest ####   [在线提问](https://gitee.com/anji-plus/report/issues "issue"): https://gitee.com/anji-plus/report/issues
diff --git a/doc/docs/guide/bigScreenCase.md b/doc/docs/guide/bigScreenCase.md index e9accfd9a8fac275dc7b2a47d16f81fa9ef7cb90..88e92c1bd2b9894787564c7bcdab13ed1214b273 100644 --- a/doc/docs/guide/bigScreenCase.md +++ b/doc/docs/guide/bigScreenCase.md @@ -1,22 +1,22 @@ ## 案例一 由社区 **[~无痕~@tengzhouboy](https://gitee.com/tengzhouboy)** 提供
-[AJ-Report分享链接](https://report.anji-plus.com/index.html#/aj/mtwbjPot)
+[AJ-Report分享链接](https://ajreport.beliefteam.cn/index.html#/aj/mtwbjPot)
![img.png](../picture/bigScreenCase/img.png)
## 案例二 由社区 **[心瘾丶 @yi_shan_liu](https://gitee.com/yi_shan_liu)** 提供
-[AJ-Report分享链接](https://report.anji-plus.com/index.html#/aj/hkBJgLW0)
+[AJ-Report分享链接](https://ajreport.beliefteam.cn/index.html#/aj/hkBJgLW0)
![img1](../picture/bigScreenCase/img1.png)
-[AJ-Report分享链接](https://report.anji-plus.com/index.html#/aj/Hgfi4pj5)
+[AJ-Report分享链接](https://ajreport.beliefteam.cn/index.html#/aj/Hgfi4pj5)
![img2](../picture/bigScreenCase/img2.png)
-[AJ-Report分享链接](https://report.anji-plus.com/index.html#/aj/zJa5Wwey)
+[AJ-Report分享链接](https://ajreport.beliefteam.cn/index.html#/aj/zJa5Wwey)
![img3](../picture/bigScreenCase/img3.png)
-[AJ-Report分享链接](https://report.anji-plus.com/index.html#/aj/D0cpO4re)
+[AJ-Report分享链接](https://ajreport.beliefteam.cn/index.html#/aj/D0cpO4re)
![img4](../picture/bigScreenCase/img4.png)
\ No newline at end of file diff --git a/doc/docs/guide/briefUsing.md b/doc/docs/guide/briefUsing.md index 089a9210db880d5f5274d1f85653b6a3a7fbd418..c5a1d33fee1b7b68e46b47f484d49fc89fc2ac54 100644 --- a/doc/docs/guide/briefUsing.md +++ b/doc/docs/guide/briefUsing.md @@ -1,9 +1,9 @@ 希望你们的logo出现在此,[请点此Issue进行登记](https://gitee.com/anji-plus/report/issues/I3ZXT4)
- + - - - -
- \ No newline at end of file + + + +
+ \ No newline at end of file diff --git a/doc/docs/guide/question.md b/doc/docs/guide/question.md index 3721505d9defcc8334e1595030ed0907284087e0..0eb8ba976c4bb6d00f2611dd0222236287b08098 100644 --- a/doc/docs/guide/question.md +++ b/doc/docs/guide/question.md @@ -12,7 +12,7 @@
-## 版本问题:[开发环境参考](https://report.anji-plus.com/report-doc/guide/quicklyDevelop.html) +## 版本问题:[开发环境参考](https://ajreport.beliefteam.cn/report-doc/guide/quicklyDevelop.html) - 底层数据库为Mysql8.0+时,flyway执行SQL报错
- Node.js是V16版本时 npm install失败
diff --git a/report-core/pom.xml b/report-core/pom.xml index 423b3b0529dc192a118e43e61af4a812554bf537..4c89c99fc8d1687ae235fb2628218650bdd086cd 100644 --- a/report-core/pom.xml +++ b/report-core/pom.xml @@ -151,6 +151,12 @@ poi-ooxml-schemas 4.1.2 + + + com.sap.cloud.db.jdbc + ngdbc + 2.3.62 + diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/controller/AccessRoleController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/controller/AccessRoleController.java index 5614a308a942313f979db988a904069a624f932a..5d3ab2fc06d715b364856060eb211a0981c202a6 100755 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/controller/AccessRoleController.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/controller/AccessRoleController.java @@ -2,30 +2,30 @@ package com.anjiplus.template.gaea.business.modules.accessrole.controller; import com.anji.plus.gaea.annotation.Permission; -import com.anji.plus.gaea.annotation.AccessKey; import com.anji.plus.gaea.bean.ResponseBean; -import com.anji.plus.gaea.bean.TreeNode; import com.anji.plus.gaea.curd.controller.GaeaBaseController; import com.anji.plus.gaea.curd.service.GaeaBaseService; import com.anji.plus.gaea.holder.UserContentHolder; -import com.anji.plus.gaea.utils.GaeaBeanUtils; -import com.anji.plus.gaea.utils.GaeaUtils; -import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole; -import com.anjiplus.template.gaea.business.modules.accessrole.service.AccessRoleService; import com.anjiplus.template.gaea.business.modules.accessrole.controller.dto.AccessRoleDto; import com.anjiplus.template.gaea.business.modules.accessrole.controller.param.AccessRoleParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole; +import com.anjiplus.template.gaea.business.modules.accessrole.service.AccessRoleService; import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -import java.util.List; import java.util.Map; /** -* @desc 角色管理 controller -* @author 木子李·De -* @date 2019-02-17 08:50:14.136 -**/ + * @author 木子李·De + * @desc 角色管理 controller + * @date 2019-02-17 08:50:14.136 + **/ @RestController @Api(tags = "角色管理管理") @RequestMapping("/accessRole") @@ -52,23 +52,51 @@ public class AccessRoleController extends GaeaBaseController { + +} \ No newline at end of file diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRoleReport.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRoleReport.java new file mode 100644 index 0000000000000000000000000000000000000000..7df4a7b485bf7ebbeed751827450d2f6a3600816 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/dao/entity/AccessRoleReport.java @@ -0,0 +1,42 @@ +package com.anjiplus.template.gaea.business.modules.accessrole.dao.entity; + +import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.Date; + +/** + * @Author: Magic_yuan + * @Date: 2022/5/5 14:59 + */ +@TableName(keepGlobalPrefix=true, value="access_role_report") +@Data +public class AccessRoleReport extends GaeaBaseEntity { + + /** + * 角色编码 + */ + private String roleCode; + + /** + * 报表编码 + */ + private String reportCode; + + @TableField(exist = false) + private String createBy; + + @TableField(exist = false) + private Date createTime; + + @TableField(exist = false) + private String updateBy; + + @TableField(exist = false) + private Date updateTime; + + @TableField(exist = false) + private Integer version; +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/AccessRoleService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/AccessRoleService.java index 639fd1a25471ec41b8deca9669856db24c2f4739..5bd47cf9dc45193584a9cfcc44d0d67ad38dddbb 100755 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/AccessRoleService.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/AccessRoleService.java @@ -1,24 +1,23 @@ package com.anjiplus.template.gaea.business.modules.accessrole.service; -import com.anji.plus.gaea.bean.ResponseBean; +import com.anji.plus.gaea.curd.service.GaeaBaseService; import com.anjiplus.template.gaea.business.modules.accessrole.controller.dto.AccessRoleDto; -import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole; import com.anjiplus.template.gaea.business.modules.accessrole.controller.param.AccessRoleParam; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.anji.plus.gaea.curd.service.GaeaBaseService; +import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRole; import java.util.Map; /** -* @desc AccessRole 角色管理服务接口 -* @author 木子李·De -* @date 2019-02-17 08:50:14.136 -**/ + * @author 木子李·De + * @desc AccessRole 角色管理服务接口 + * @date 2019-02-17 08:50:14.136 + **/ public interface AccessRoleService extends GaeaBaseService { - /** 查询某角色的权限树 + /** + * 查询某角色的权限树 + * * @param roleCode 被操作的对象 * @param operator 当前登录者 * @return @@ -26,9 +25,22 @@ public interface AccessRoleService extends GaeaBaseService -* @date 2019-02-17 08:50:14.136 -**/ + * @author 木子李·De + * @desc AccessRole 角色管理服务实现 + * @date 2019-02-17 08:50:14.136 + **/ @Service public class AccessRoleServiceImpl implements AccessRoleService { @@ -37,12 +42,89 @@ public class AccessRoleServiceImpl implements AccessRoleService { @Autowired private AccessRoleAuthorityMapper accessRoleAuthorityMapper; + @Autowired + private AccessRoleReportMapper accessRoleReportMapper; + @Autowired private AccessAuthorityService accessAuthorityService; + @Autowired + private ReportService reportService; + @Override public GaeaBaseMapper getMapper() { - return accessRoleMapper; + return accessRoleMapper; + } + + + @Override + public Map authorityReportTree(String roleCode, String operator) { + Map result = new HashMap(); + + // 菜单按钮树 + List reportList = reportService.findAll(); + List parentNodes = new ArrayList<>(); + TreeNode screenNode = new TreeNode(); + screenNode.setLabel("大屏报表"); + screenNode.setId("screen"); + TreeNode excelNod = new TreeNode(); + excelNod.setLabel("Excel报表"); + excelNod.setId("excel"); + for (Report report : reportList) { + TreeNode tempNode = new TreeNode(); + tempNode.setLabel(report.getReportName()); + tempNode.setId(report.getReportCode()); + if (StringUtils.equalsIgnoreCase(report.getReportType(), "report_screen")) { + if (screenNode.getChildren() == null) { + screenNode.setChildren(new ArrayList<>()); + } + screenNode.getChildren().add(tempNode); + } else { + if (excelNod.getChildren() == null) { + excelNod.setChildren(new ArrayList<>()); + } + excelNod.getChildren().add(tempNode); + } + } + + parentNodes.add(screenNode); + parentNodes.add(excelNod); + + List accessRoleReportList = accessRoleReportMapper.selectList(Wrappers.lambdaQuery().eq(AccessRoleReport::getRoleCode, roleCode)); + List checkedKeys = accessRoleReportList.stream() + .map(accessRoleReport -> accessRoleReport.getReportCode()).distinct().collect(Collectors.toList()); + + result.put("treeData", parentNodes); + result.put("checkedKeys", checkedKeys); + return result; + } + + + @Override + public Boolean saveRoleReportTree(AccessRoleDto accessRoleDto) { + // 校验 + String roleCode = accessRoleDto.getRoleCode(); + List authorityList = accessRoleDto.getAuthorityList(); + if (StringUtils.isBlank(roleCode)) { + throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, roleCode); + } + if (authorityList == null || authorityList.isEmpty()) { + throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, authorityList); + } + + // 先清除该角色已保存的报表权限 + accessRoleReportMapper.delete(Wrappers.lambdaUpdate().eq(AccessRoleReport::getRoleCode, roleCode)); + + // 保存勾选的报表权限 + List accessRoleReports = new ArrayList<>(); + for (String reportCode : authorityList) { + AccessRoleReport accessRoleReport = new AccessRoleReport(); + accessRoleReport.setRoleCode(roleCode); + accessRoleReport.setReportCode(reportCode); + accessRoleReports.add(accessRoleReport); + } + accessRoleReportMapper.insertBatch(accessRoleReports); + return true; } @Override @@ -72,10 +154,10 @@ public class AccessRoleServiceImpl implements AccessRoleService { // 校验 String roleCode = accessRoleDto.getRoleCode(); List authorityList = accessRoleDto.getAuthorityList(); - if(StringUtils.isBlank(roleCode)){ + if (StringUtils.isBlank(roleCode)) { throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, roleCode); } - if(authorityList == null || authorityList.isEmpty()){ + if (authorityList == null || authorityList.isEmpty()) { throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, authorityList); } @@ -86,7 +168,7 @@ public class AccessRoleServiceImpl implements AccessRoleService { // 保存勾选的权限(菜单和按钮) authorityList.stream().forEach(authorityStr -> { - if(!authorityStr.contains("_")){ + if (!authorityStr.contains("_")) { return; } String[] array = authorityStr.split("_"); diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java index 0485a2945f8039f61fe895b05adb5cf1a415d254..2dcfc9fd4623ae86aa578e358ec64a8adfc4b550 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/datasource/service/impl/DataSourceServiceImpl.java @@ -1,6 +1,7 @@ package com.anjiplus.template.gaea.business.modules.datasource.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.anji.plus.gaea.constant.BaseOperationEnum; @@ -23,6 +24,7 @@ import com.anjiplus.template.gaea.business.util.JdbcConstants; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -144,6 +146,13 @@ public class DataSourceServiceImpl implements DataSourceService { public long total(DataSourceDto sourceDto, DataSetDto dto) { //区分数据类型 String sourceType = sourceDto.getSourceType(); + + String driverName = JSON.parseObject(sourceDto.getSourceConfig()).getString("driverName"); + if (StringUtils.equalsIgnoreCase(driverName, "com.sap.db.jdbc.Driver")) { + return sapHanaTotal(sourceDto, dto); + } + + switch (sourceType) { case JdbcConstants.ELASTIC_SEARCH_SQL: return 0; @@ -155,6 +164,30 @@ public class DataSourceServiceImpl implements DataSourceService { } + + /** + * 获取Sap Hana count 和添加limit分页信息 + * + * @param sourceDto + * @param dto + * @return + */ + public long sapHanaTotal(DataSourceDto sourceDto, DataSetDto dto) { + String dynSentence = sourceDto.getDynSentence(); + String sql = "select count(1) as count from (" + dynSentence + ") as gaeaExecute"; + sourceDto.setDynSentence(sql); + List result = execute(sourceDto); + + //sql 拼接 limit 分页信息 + int pageNumber = Integer.parseInt(dto.getContextData().getOrDefault("pageNumber", "1").toString()); + int pageSize = Integer.parseInt(dto.getContextData().getOrDefault("pageSize", "10").toString()); + String sqlLimit = " limit " + pageSize + " offset " + (pageNumber - 1) * pageSize; + sourceDto.setDynSentence(dynSentence.concat(sqlLimit)); + log.info("当前total:{}, 添加分页参数,sql语句:{}", JSONObject.toJSONString(result), sourceDto.getDynSentence()); + return result.get(0).getLongValue("COUNT"); + } + + /** * 获取mysql count 和添加limit分页信息 * @param sourceDto diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/controller/ReportController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/controller/ReportController.java index 6269e7d0d06e4dca9ab4bd35d9fcd4e4a726b4f7..b74e89947e2b2a2345b2110154ce044d60cd9d71 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/controller/ReportController.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/controller/ReportController.java @@ -5,10 +5,14 @@ import com.anji.plus.gaea.annotation.log.GaeaAuditLog; import com.anji.plus.gaea.bean.ResponseBean; import com.anji.plus.gaea.curd.controller.GaeaBaseController; import com.anji.plus.gaea.curd.service.GaeaBaseService; +import com.anji.plus.gaea.utils.GaeaBeanUtils; import com.anjiplus.template.gaea.business.modules.report.controller.dto.ReportDto; import com.anjiplus.template.gaea.business.modules.report.controller.param.ReportParam; import com.anjiplus.template.gaea.business.modules.report.dao.entity.Report; import com.anjiplus.template.gaea.business.modules.report.service.ReportService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; @@ -16,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * TODO * @@ -46,6 +52,20 @@ public class ReportController extends GaeaBaseController wrapper = reportService.getWrapper(param); + wrapper.in("report_code", reportService.getReportListByRoles()); + IPage iPage = reportService.page(param, wrapper); + List records = iPage.getRecords(); + List list = GaeaBeanUtils.copyList(records, ReportDto.class); + this.pageResultHandler(list); + Page pageDto = new Page(); + pageDto.setCurrent(iPage.getCurrent()).setRecords(list).setPages(iPage.getPages()).setTotal(iPage.getTotal()).setSize(iPage.getSize()); + return this.responseSuccessWithData(pageDto); + } + @DeleteMapping("/delReport") @Permission(code = "delete", name = "删除") @GaeaAuditLog(pageTitle = "删除") diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/ReportService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/ReportService.java index a09efd080957c1af9a6b0788017bb1f42f980a09..747ce04fb1a97af9b681656ba9bc2bab08584192 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/ReportService.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/ReportService.java @@ -5,8 +5,9 @@ import com.anjiplus.template.gaea.business.modules.report.controller.dto.ReportD import com.anjiplus.template.gaea.business.modules.report.controller.param.ReportParam; import com.anjiplus.template.gaea.business.modules.report.dao.entity.Report; +import java.util.List; + /** - * * @author chenkening * @date 2021/3/26 10:35 */ @@ -16,7 +17,14 @@ public interface ReportService extends GaeaBaseService { /** * 下载次数+1 + * * @param reportCode */ void downloadStatistics(String reportCode); + + /** + * 根据角色ID集合获取报表集合 + * + */ + List getReportListByRoles(); } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/impl/ReportServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/impl/ReportServiceImpl.java index e5b32704b6901e127cb09314ce47b7c8f60c06a0..43bd4750ef318c4cadb176c8a7a1c4f95e197c12 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/impl/ReportServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/report/service/impl/ReportServiceImpl.java @@ -3,15 +3,23 @@ package com.anjiplus.template.gaea.business.modules.report.service.impl; import com.anji.plus.gaea.constant.BaseOperationEnum; import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; import com.anji.plus.gaea.exception.BusinessException; +import com.anji.plus.gaea.holder.UserContentHolder; +import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleReportMapper; +import com.anjiplus.template.gaea.business.modules.accessrole.dao.entity.AccessRoleReport; +import com.anjiplus.template.gaea.business.modules.accessuser.dao.AccessUserRoleMapper; +import com.anjiplus.template.gaea.business.modules.accessuser.dao.entity.AccessUserRole; import com.anjiplus.template.gaea.business.modules.report.controller.dto.ReportDto; import com.anjiplus.template.gaea.business.modules.report.dao.ReportMapper; import com.anjiplus.template.gaea.business.modules.report.dao.entity.Report; import com.anjiplus.template.gaea.business.modules.report.service.ReportService; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.stream.Collectors; + /** - * * @author chenkening * @date 2021/3/26 10:35 */ @@ -21,11 +29,24 @@ public class ReportServiceImpl implements ReportService { @Autowired private ReportMapper reportMapper; + @Autowired + private AccessUserRoleMapper accessUserRoleMapper; + + @Autowired + private AccessRoleReportMapper accessRoleReportMapper; + @Override public GaeaBaseMapper getMapper() { return reportMapper; } + @Override + public List getReportListByRoles() { + List roleList = accessUserRoleMapper.selectList(Wrappers.lambdaQuery().eq(AccessUserRole::getLoginName, UserContentHolder.getContext().getUsername())).stream().map(accessUserRole -> accessUserRole.getRoleCode()).distinct().collect(Collectors.toList()); + List accessRoleReportList = accessRoleReportMapper.selectList(Wrappers.lambdaQuery().in(AccessRoleReport::getRoleCode, roleList)); + return accessRoleReportList.stream() + .map(accessRoleReport -> accessRoleReport.getReportCode()).distinct().collect(Collectors.toList()); + } @Override public void delReport(ReportDto reportDto) { @@ -46,7 +67,7 @@ public class ReportServiceImpl implements ReportService { Long downloadCount = report.getDownloadCount(); if (null == downloadCount) { downloadCount = 0L; - }else { + } else { downloadCount++; } report.setDownloadCount(downloadCount); diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java index 865dd7dd0eb26d880745b574a1ede404191a1765..627457f5e2b69ae8c9e17114d95740b115247899 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java @@ -23,7 +23,6 @@ import com.anjiplus.template.gaea.business.modules.reportexcel.dao.ReportExcelMa import com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity.ReportExcel; import com.anjiplus.template.gaea.business.modules.reportexcel.service.ReportExcelService; import com.anjiplus.template.gaea.business.modules.reportexcel.util.CellType; -import com.anjiplus.template.gaea.business.modules.reportexcel.util.XlsSheetUtil; import com.anjiplus.template.gaea.business.modules.reportexcel.util.XlsUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.commons.lang3.StringUtils; @@ -34,8 +33,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; /** * TODO @@ -125,7 +131,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { // 数据集解析 String jsonStr = analysisReportData(reportExcelDto); reportExcelDto.setJsonStr(jsonStr); -// reportExcelDto.setTotal(jsonObject.getJSONObject("rows").size()); + //reportExcelDto.setTotal(jsonObject.getJSONObject("rows").size()); return reportExcelDto; } @@ -138,7 +144,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { ReportExcelDto report = detailByReportCode(reportCode); reportExcelDto.setJsonStr(report.getJsonStr()); String jsonStr = analysisReportData(reportExcelDto); - List lists=(List ) JSON.parse(jsonStr); + List lists = (List) JSON.parse(jsonStr); OutputStream out; try { String fileId = UUID.randomUUID().toString(); @@ -175,7 +181,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { if (dbObjectList != null && dbObjectList.size() > 0) { for (int x = 0; x < dbObjectList.size(); x++) { - analysisSheetCellData(dbObjectList.get(x), setParam); + analysisSheetCellData(dbObjectList.get(x), setParam, reportExcelDto); } } //fastjson $ref 循环引用 @@ -230,7 +236,6 @@ public class ReportExcelServiceImpl implements ReportExcelService { } - } } @@ -248,7 +253,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { * * @param dbObject */ - private void analysisSheetCellData(JSONObject dbObject, String setParam) { + private void analysisSheetCellData(JSONObject dbObject, String setParam, ReportExcelDto reportExcelDto) { //清空data值 dbObject.remove("data"); //celldata是一个一维数组 @@ -257,31 +262,32 @@ public class ReportExcelServiceImpl implements ReportExcelService { celldata.addAll((List) dbObject.get("celldata")); //整理celldata数据,转换为map格式,方便后续使用单元格位置获取对应的cell对象 - Map cellDataMap = cellDataList2Map(celldata); + Map cellDataMap = cellDataList2Map(celldata); //清除原有的数据 dbObject.getJSONArray("celldata").clear(); //获取配置项中的合并属性 JSONObject merge = dbObject.getJSONObject("config").getJSONObject("merge"); - if(merge != null) merge.clear(); + if (merge != null) merge.clear(); //定义存储每一列动态扩展的行数 - Map colAddCntMap = new HashMap<>(); + Map colAddCntMap = new HashMap<>(); // 遍历已存在的单元格,查看是否存在动态参数 for (int i = 0; i < celldata.size(); i++) { //单元格对象 JSONObject cellObj = celldata.get(i); //fastjson深拷贝问题 String cellStr = cellObj.toJSONString(); - analysisCellData(cellObj,setParam,colAddCntMap,cellStr,merge, dbObject,cellDataMap); + analysisCellData(cellObj, setParam, colAddCntMap, cellStr, merge, dbObject, cellDataMap, reportExcelDto); } } } /** * 开始解析并渲染 cellData + * * @param cellObject */ - public void analysisCellData(JSONObject cellObject,String setParam,Map colAddCntMap,String cellStr, - JSONObject merge,JSONObject dbObject,Map cellDataMap){ + public void analysisCellData(JSONObject cellObject, String setParam, Map colAddCntMap, String cellStr, + JSONObject merge, JSONObject dbObject, Map cellDataMap, ReportExcelDto reportExcelDto) { //获取行号 Integer cellR = cellObject.getInteger("r"); //获取列数 @@ -290,7 +296,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { int cnt = colAddCntMap.get(cellC) == null ? 0 : colAddCntMap.get(cellC); //获取单元格类型 CellType cellType = getCellType(cellObject); - switch (cellType){ + switch (cellType) { case BLACK: //空数据单元格不处理 break; @@ -299,17 +305,18 @@ public class ReportExcelServiceImpl implements ReportExcelService { //处理动态单元格 String v = cellObject.getJSONObject("v").getString("v"); DataSetDto dataSet = getDataSet(v, setParam); - handleDynamicCellObject(dataSet,v,cellStr,cnt,cellR,cellC,merge,dbObject,colAddCntMap); + handleDynamicCellObject(dataSet, v, cellStr, cnt, cellR, cellC, merge, dbObject, colAddCntMap, reportExcelDto); break; default: //处理静态单元格 - handleStaticCellObject(cellStr,dbObject,cnt,cellR,cellC,cellDataMap,setParam,merge,colAddCntMap,cellType); + handleStaticCellObject(cellStr, dbObject, cnt, cellR, cellC, cellDataMap, setParam, merge, colAddCntMap, cellType); break; } } /** * 处理动态数据单元格自动扩展 + * * @param dataSet * @param v * @param cellStr @@ -320,13 +327,14 @@ public class ReportExcelServiceImpl implements ReportExcelService { * @param dbObject * @param colAddCntMap */ - public void handleDynamicCellObject(DataSetDto dataSet,String v,String cellStr,int cnt,int r,int c, - JSONObject merge,JSONObject dbObject,Map colAddCntMap){ + public void handleDynamicCellObject(DataSetDto dataSet, String v, String cellStr, int cnt, int r, int c, + JSONObject merge, JSONObject dbObject, Map colAddCntMap, ReportExcelDto reportExcelDto) { //获取动态数据 OriginalDataDto originalDataDto = dataSetService.getData(dataSet); + reportExcelDto.setTotal(originalDataDto.getTotal()); List cellDynamicData = originalDataDto.getData(); - if(cellDynamicData != null){ + if (cellDynamicData != null) { //循环数据赋值 for (int j = 0; j < cellDynamicData.size(); j++) { //新增的行数据 @@ -337,25 +345,25 @@ public class ReportExcelServiceImpl implements ReportExcelService { //转字符串,解决深拷贝问题 JSONObject addCellData = JSONObject.parseObject(cellStr); - addCellData.put("r", cnt + r + j); //行数增加 + addCellData.put("r", cnt + r + j); //行数增加 addCellData.put("c", c); addCellData.getJSONObject("v").put("v", replace); addCellData.getJSONObject("v").put("m", replace); JSONObject cellMc = addCellData.getJSONObject("v").getJSONObject("mc"); //判断是否是合并单元格 - if(null != cellMc){ + if (null != cellMc) { //处理合并单元格 Integer rs = cellMc.getInteger("rs"); - cellMc.put("r", cnt + r + rs*j); //行数增加 + cellMc.put("r", cnt + r + rs * j); //行数增加 cellMc.put("c", c); - addCellData.put("r", cnt + r + rs*j); + addCellData.put("r", cnt + r + rs * j); //合并单元格需要处理config.merge - merge.put(cellMc.getString("r")+"_"+cellMc.getString("c"),cellMc); + merge.put(cellMc.getString("r") + "_" + cellMc.getString("c"), cellMc); //处理单元格扩展之后此列扩展的总行数 - colAddCntMap.put(c,cnt + rs * cellDynamicData.size() - 1); - }else{ + colAddCntMap.put(c, cnt + rs * cellDynamicData.size() - 1); + } else { //处理单元格扩展之后此列扩展的总行数 - colAddCntMap.put(c,cnt + cellDynamicData.size() - 1); + colAddCntMap.put(c, cnt + cellDynamicData.size() - 1); } dbObject.getJSONArray("celldata").add(addCellData); } @@ -364,6 +372,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { /** * 处理静态单元格数据 + * * @param cellStr * @param dbObject * @param cnt @@ -375,49 +384,49 @@ public class ReportExcelServiceImpl implements ReportExcelService { * @param colAddCntMap * @param cellType */ - public void handleStaticCellObject(String cellStr,JSONObject dbObject,int cnt,int r,int c, - Map cellDataMap,String setParam, - JSONObject merge,Map colAddCntMap,CellType cellType){ + public void handleStaticCellObject(String cellStr, JSONObject dbObject, int cnt, int r, int c, + Map cellDataMap, String setParam, + JSONObject merge, Map colAddCntMap, CellType cellType) { //转字符串,解决深拷贝问题 JSONObject addCellData = JSONObject.parseObject(cellStr); int rows = 0; - switch(cellType){ + switch (cellType) { case STATIC: case STATIC_MERGE: //静态不扩展单元格只需要初始化位置就可以 - initCellPosition(addCellData,cnt,merge); + initCellPosition(addCellData, cnt, merge); break; case STATIC_AUTO: //获取静态单元格右侧动态单元格的总行数 - rows = getRightDynamicCellRows(addCellData,cellDataMap,setParam,rows,cellType); - initCellPosition(addCellData,cnt,merge); - if(rows > 1){ + rows = getRightDynamicCellRows(addCellData, cellDataMap, setParam, rows, cellType); + initCellPosition(addCellData, cnt, merge); + if (rows > 1) { //需要把这个静态扩展单元格 改变为 静态合并扩展单元格,就是增加合并属性 mc 以及merge配置 JSONObject mc = new JSONObject(); - mc.put("rs",rows); - mc.put("cs",1); - mc.put("r",addCellData.getIntValue("r")); - mc.put("c",addCellData.getIntValue("c")); - addCellData.getJSONObject("v").put("mc",mc); + mc.put("rs", rows); + mc.put("cs", 1); + mc.put("r", addCellData.getIntValue("r")); + mc.put("c", addCellData.getIntValue("c")); + addCellData.getJSONObject("v").put("mc", mc); //合并单元格需要处理config.merge - merge.put((mc.getInteger("r")) + "_" + mc.getString("c"),mc); + merge.put((mc.getInteger("r")) + "_" + mc.getString("c"), mc); //处理单元格扩展之后此列扩展的总行数 - colAddCntMap.put(c,cnt + rows - 1); + colAddCntMap.put(c, cnt + rows - 1); } break; case STATIC_MERGE_AUTO: //获取静态单元格右侧动态单元格的总行数 - rows = getRightDynamicCellRows(addCellData,cellDataMap,setParam,rows,cellType); - initCellPosition(addCellData,cnt,merge); - if(rows > 0){ + rows = getRightDynamicCellRows(addCellData, cellDataMap, setParam, rows, cellType); + initCellPosition(addCellData, cnt, merge); + if (rows > 0) { //需要修改单元格mc中的rs JSONObject cellMc = addCellData.getJSONObject("v").getJSONObject("mc"); int addCnt = cellMc.getInteger("rs"); - cellMc.put("rs",rows); + cellMc.put("rs", rows); //合并单元格需要处理config.merge - merge.put((cellMc.getInteger("r")) + "_" + cellMc.getString("c"),cellMc); + merge.put((cellMc.getInteger("r")) + "_" + cellMc.getString("c"), cellMc); //处理单元格扩展之后此列扩展的总行数 - colAddCntMap.put(c,cnt + rows - addCnt); + colAddCntMap.put(c, cnt + rows - addCnt); } break; } @@ -426,31 +435,34 @@ public class ReportExcelServiceImpl implements ReportExcelService { /** * 初始化单元格位置,主要是这一列已经动态增加的行数 + * * @param addCellData * @param cnt * @param merge */ - public void initCellPosition(JSONObject addCellData,int cnt,JSONObject merge){ + public void initCellPosition(JSONObject addCellData, int cnt, JSONObject merge) { addCellData.put("r", cnt + addCellData.getInteger("r"));//行数增加 //是否是合并单元格 JSONObject mc = addCellData.getJSONObject("v").getJSONObject("mc"); - if(mc != null){ - mc.put("r",addCellData.getInteger("r")); - initCellMerge(merge,mc); + if (mc != null) { + mc.put("r", addCellData.getInteger("r")); + initCellMerge(merge, mc); } } /** * 初始化单元格合并属性的行数 + * * @param merge * @param mc */ - public void initCellMerge(JSONObject merge,JSONObject mc){ - merge.put((mc.getInteger("r"))+"_"+mc.getString("c"),mc); + public void initCellMerge(JSONObject merge, JSONObject mc) { + merge.put((mc.getInteger("r")) + "_" + mc.getString("c"), mc); } /** * 获取合并单元格右侧的动态扩展行数,用来设置当前单元格的实际 + * * @param addCellData * @param cellDataMap * @param setParam @@ -458,18 +470,18 @@ public class ReportExcelServiceImpl implements ReportExcelService { * @param cellType * @return */ - public int getRightDynamicCellRows(JSONObject addCellData,Map cellDataMap,String setParam,int sumRows,CellType cellType){ + public int getRightDynamicCellRows(JSONObject addCellData, Map cellDataMap, String setParam, int sumRows, CellType cellType) { //1、获取此单元格右侧关联的所有单元格 - List rightCellList = getRightDynamicCell(addCellData,cellDataMap,cellType); + List rightCellList = getRightDynamicCell(addCellData, cellDataMap, cellType); //2、循环获取每个单元格的扩展行数 for (JSONObject rightCell : rightCellList) { //首先判断这个单元格是否也是【静态扩展单元格】 CellType rightCellType = getCellType(rightCell); - switch (rightCellType){ + switch (rightCellType) { case STATIC_AUTO: case STATIC_MERGE_AUTO: //递归查找 - sumRows = getRightDynamicCellRows(rightCell,cellDataMap,setParam,sumRows,rightCellType); + sumRows = getRightDynamicCellRows(rightCell, cellDataMap, setParam, sumRows, rightCellType); break; case BLACK: case STATIC: @@ -479,11 +491,11 @@ public class ReportExcelServiceImpl implements ReportExcelService { sumRows += rightCell.getJSONObject("v").getJSONObject("mc").getInteger("rs"); break; default: - List cellDynamicData = getDynamicDataList(rightCell.getJSONObject("v").getString("v"),setParam); - if(cellDynamicData != null && cellDynamicData.size() > 1){ + List cellDynamicData = getDynamicDataList(rightCell.getJSONObject("v").getString("v"), setParam); + if (cellDynamicData != null && cellDynamicData.size() > 1) { int size = cellDynamicData.size(); sumRows += size; - }else{ + } else { sumRows++; } break; @@ -494,12 +506,13 @@ public class ReportExcelServiceImpl implements ReportExcelService { /** * 获取扩展单元格右侧相邻的所有单元格实体 + * * @param addCellData * @param cellDataMap * @param cellType * @return */ - public List getRightDynamicCell(JSONObject addCellData,Map cellDataMap,CellType cellType){ + public List getRightDynamicCell(JSONObject addCellData, Map cellDataMap, CellType cellType) { //静态数据合并单元格需要根据右侧的单元格进行自动向下扩展 //1、先获取右侧一列的关联的单元格,根据自身的位置,以及自己合并的合并的信息推断 //如果自己位置是 2,5,并且本身合并 行数2,列数3,则需要推断出两个单元格的位置 @@ -508,7 +521,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { Integer cellC = addCellData.getInteger("c"); Integer cellRs = 0; Integer cellCs = 0; - switch (cellType){ + switch (cellType) { case STATIC_AUTO: cellRs = 1; cellCs = 1; @@ -519,11 +532,11 @@ public class ReportExcelServiceImpl implements ReportExcelService { break; } List rightCells = new ArrayList<>(); - for(int nums = 0;nums < cellRs;nums++){ + for (int nums = 0; nums < cellRs; nums++) { int r = cellR + nums; int c = cellC + cellCs; String key = r + "," + c; - if(cellDataMap.containsKey(key)){ + if (cellDataMap.containsKey(key)) { JSONObject cellData = cellDataMap.get(r + "," + c); rightCells.add(cellData); } @@ -533,48 +546,50 @@ public class ReportExcelServiceImpl implements ReportExcelService { /** * 判断单元格类型 + * * @param cellObject * @return */ - public CellType getCellType(JSONObject cellObject){ + public CellType getCellType(JSONObject cellObject) { JSONObject cellV1 = cellObject.getJSONObject("v"); if (null != cellV1 && cellV1.containsKey("v") && StringUtils.isNotBlank(cellV1.getString("v"))) { String cellV2 = cellObject.getJSONObject("v").getString("v"); String auto = cellObject.getJSONObject("v").getString("auto"); JSONObject mc = cellObject.getJSONObject("v").getJSONObject("mc"); - if(cellV2.contains("#{") && cellV2.contains("}") ){ + if (cellV2.contains("#{") && cellV2.contains("}")) { //动态单元格 - if(mc != null){ + if (mc != null) { return CellType.DYNAMIC_MERGE; - }else{ + } else { return CellType.DYNAMIC; } - }else{ + } else { //静态单元格 - if(mc != null && "1".equals(auto)){ + if (mc != null && "1".equals(auto)) { return CellType.STATIC_MERGE_AUTO; - }else { - if("1".equals(auto)){ + } else { + if ("1".equals(auto)) { return CellType.STATIC_AUTO; - }else if(mc != null){ + } else if (mc != null) { return CellType.STATIC_MERGE; - }else{ + } else { return CellType.STATIC; } } } - }else{ + } else { return CellType.BLACK; } } /** * list转为map结构,方便使用行列号查找对应cell对象 + * * @param cellDataList * @return */ - public Map cellDataList2Map(List cellDataList){ - Map cellDataMap = new HashMap<>(); + public Map cellDataList2Map(List cellDataList) { + Map cellDataMap = new HashMap<>(); for (JSONObject cellData : cellDataList) { String r = cellData.getString("r"); String c = cellData.getString("c"); @@ -585,6 +600,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { /** * 解析 #{xxxx.xxxxx} 数据 + * * @param v * @return */ @@ -598,7 +614,7 @@ public class ReportExcelServiceImpl implements ReportExcelService { String substring = v.substring(start, end); if (substring.contains(".")) { String[] split = substring.split("\\."); - dto.setSetCode( split[0]); + dto.setSetCode(split[0]); dto.setFieldLabel(split[1]); getContextData(setParam, dto); return dto; @@ -610,27 +626,29 @@ public class ReportExcelServiceImpl implements ReportExcelService { /** * 获取单元格对应的动态数据集 + * * @param v * @param setParam * @return */ - private List getDynamicDataList(String v, String setParam){ - if(StringUtils.isNotBlank(v)){ - DataSetDto dataSet = getDataSet(v,setParam); - if(dataSet != null){ + private List getDynamicDataList(String v, String setParam) { + if (StringUtils.isNotBlank(v)) { + DataSetDto dataSet = getDataSet(v, setParam); + if (dataSet != null) { OriginalDataDto originalDataDto = dataSetService.getData(dataSet); List cellDynamicData = originalDataDto.getData(); return cellDynamicData; - }else{ + } else { return null; } - }else{ + } else { return null; } } /** * 动态参数替换 + * * @param setParam * @param dto */ diff --git a/report-core/src/main/resources/db/migration/V1.0.15__create_role_report.sql b/report-core/src/main/resources/db/migration/V1.0.15__create_role_report.sql new file mode 100644 index 0000000000000000000000000000000000000000..bda12c7f2ac423258b440fc7080dc50a6c156671 --- /dev/null +++ b/report-core/src/main/resources/db/migration/V1.0.15__create_role_report.sql @@ -0,0 +1,7 @@ +DROP TABLE IF EXISTS `access_role_report`; +CREATE TABLE `access_role_report` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', + `role_code` varchar(32) COLLATE utf8_bin NOT NULL COMMENT '角色名称', + `report_code` varchar(64) COLLATE utf8_bin NOT NULL COMMENT '报表编码', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC COMMENT='运营角色报表关联表'; \ No newline at end of file diff --git a/report-ui/src/api/accessRole.js b/report-ui/src/api/accessRole.js index 0c0a4a4951730e42df8e20e95b2e8537192bdcfd..eff5046949fd8c5551075dc84a2b28303044ad8b 100755 --- a/report-ui/src/api/accessRole.js +++ b/report-ui/src/api/accessRole.js @@ -46,6 +46,8 @@ export function accessRoleAuthorityTree (roleCode) { }) } + + export function saveAuthorityTree (data) { return request({ url: 'accessRole/saveAuthorityTree', @@ -55,4 +57,19 @@ export function saveAuthorityTree (data) { } -export default { accessRoleList, accessRoleAdd, accessRoleDeleteBatch, accessRoleUpdate, accessRoleDetail, accessRoleAuthorityTree, saveAuthorityTree } +export function authorityReportTree (roleCode) { + return request({ + url: 'accessRole/authorityReportTree/' + roleCode, + method: 'get', + }) +} + +export function saveAuthorityReportTree (data) { + return request({ + url: 'accessRole/saveAuthorityReportTree', + method: 'post', + data + }) +} + +export default { accessRoleList, accessRoleAdd, accessRoleDeleteBatch, accessRoleUpdate, accessRoleDetail, accessRoleAuthorityTree, saveAuthorityTree, authorityReportTree, saveAuthorityReportTree } diff --git a/report-ui/src/views/accessRole/components/RoleReport.vue b/report-ui/src/views/accessRole/components/RoleReport.vue new file mode 100644 index 0000000000000000000000000000000000000000..bd13a3c464aa4e3bf0b22559ad77fcc5edbe84eb --- /dev/null +++ b/report-ui/src/views/accessRole/components/RoleReport.vue @@ -0,0 +1,92 @@ + + + diff --git a/report-ui/src/views/accessRole/index.vue b/report-ui/src/views/accessRole/index.vue index 3e762e23133fc52484856e5e76f97ddf580ab362..ada32f8f085c2e12862fc77ae493965020b3ef63 100755 --- a/report-ui/src/views/accessRole/index.vue +++ b/report-ui/src/views/accessRole/index.vue @@ -13,8 +13,12 @@ type="text" @click="handleOpenDialogSetAuthorityForRole(props)" v-permission="'roleManage:grantAuthority'" - >分配权限 + >分配权限 + 关联报表 @@ -35,15 +44,18 @@ import { accessRoleDetail } from "@/api/accessRole"; import RoleAuthority from "@/views/accessRole/components/RoleAuthority"; +import RoleReport from "@/views/accessRole/components/RoleReport"; export default { name: "AccessRole", components: { - RoleAuthority: RoleAuthority + RoleAuthority: RoleAuthority, + RoleReport: RoleReport }, data() { return { // 选中一个角色,点设定权限时,弹出对话框 dialogVisibleSetAuthorityForRole: false, + dialogVisibleSetReportForRole: false, roleCode: "", // 页面渲染使用 @@ -202,6 +214,10 @@ export default { handleOpenDialogSetAuthorityForRole(props) { this.roleCode = props.msg.roleCode; this.dialogVisibleSetAuthorityForRole = true; + }, + handleOpenDialogSetReportForRole(props) { + this.roleCode = props.msg.roleCode; + this.dialogVisibleSetReportForRole = true; } } }; diff --git a/report-ui/src/views/bigscreenDesigner/designer/index.vue b/report-ui/src/views/bigscreenDesigner/designer/index.vue index 53365880c09fda3f4ad4c4df921aec0b6af01883..a72a81c9bb80ac1314690d08e814069dc542d2f4 100644 --- a/report-ui/src/views/bigscreenDesigner/designer/index.vue +++ b/report-ui/src/views/bigscreenDesigner/designer/index.vue @@ -140,36 +140,6 @@ -
{ - if(el.name == 'width'){ - el.value = this.bigscreenWidth - }else if(el.name == 'height'){ - el.value = this.bigscreenHeight + if (el.name == "width") { + el.value = this.bigscreenWidth; + } else if (el.name == "height") { + el.value = this.bigscreenHeight; } - newSetup.push(el) + newSetup.push(el); }); - this.widgetOptions.setup = newSetup + this.widgetOptions.setup = newSetup; } else { for (let i = 0; i < this.widgets.length; i++) { if (this.widgetIndex == i) { @@ -964,7 +934,7 @@ export default { border: 1px solid #3a4659; background: #282a30; } - .tools-item-text{ + .tools-item-text { } } } diff --git a/report-ui/src/views/bigscreenDesigner/designer/tools/configure/widget-iframe.js b/report-ui/src/views/bigscreenDesigner/designer/tools/configure/widget-iframe.js index a38ba9832fe8e97167fbb676a421575f83fde500..8aa78f08b85cbc57c17d02ab0d7804b292f47562 100644 --- a/report-ui/src/views/bigscreenDesigner/designer/tools/configure/widget-iframe.js +++ b/report-ui/src/views/bigscreenDesigner/designer/tools/configure/widget-iframe.js @@ -1,6 +1,6 @@ /* * @Descripttion: iframe json - * @version: + * @version: * @Author: qianlishi * @Date: 2021-08-29 07:17:55 * @LastEditors: qianlishi @@ -28,7 +28,7 @@ export const widgetIframe = { name: 'iframeAdress', required: false, placeholder: '', - value: 'https://report.anji-plus.com/index.html', + value: 'https://ajreport.beliefteam.cn/index.html', }, ], // 数据 diff --git a/report-ui/src/views/bigscreenDesigner/designer/tools/index.js b/report-ui/src/views/bigscreenDesigner/designer/tools/index.js index 805318696bc3ee81df00d7a6c383dc14dff80e93..40c3974dd502bd6ed4eb7b206ece6f6db113be39 100644 --- a/report-ui/src/views/bigscreenDesigner/designer/tools/index.js +++ b/report-ui/src/views/bigscreenDesigner/designer/tools/index.js @@ -1,6 +1,6 @@ /* * @Descripttion: 主文件 - * @version: + * @version: * @Author: qianlishi * @Date: 2021-08-29 06:43:07 * @LastEditors: qianlishi @@ -59,7 +59,7 @@ const screenConfig = { name: 'backgroundImage', required: false, placeholder: '', - value: 'https://report.anji-plus.com/file/download/bf566e48-ccad-40e1-8ee9-228427e5466b', + value: 'https://ajreport.beliefteam.cn/file/download/bf566e48-ccad-40e1-8ee9-228427e5466b', }, ], data: [], diff --git a/report-ui/src/views/bigscreenDesigner/designer/widget/line/widgetLineCompareChart.vue b/report-ui/src/views/bigscreenDesigner/designer/widget/line/widgetLineCompareChart.vue index b7c057e61ca9d5bb2ae51774935d1a523e221968..e71d3b6cc35fbad93054d2c83182ddceb99f7621 100644 --- a/report-ui/src/views/bigscreenDesigner/designer/widget/line/widgetLineCompareChart.vue +++ b/report-ui/src/views/bigscreenDesigner/designer/widget/line/widgetLineCompareChart.vue @@ -533,9 +533,9 @@ export default { const legend = this.options.legend; legend.show = optionsSetup.isShowLegend; legend.left = optionsSetup.lateralPosition; - legend.top = optionsSetup.longitudinalPosition == "top" ? 0 : "auto"; + legend.top = optionsSetup.longitudinalPosition; legend.bottom = - optionsSetup.longitudinalPosition == "bottom" ? 0 : "auto"; + optionsSetup.longitudinalPosition; legend.orient = optionsSetup.layoutFront; legend.textStyle = { color: optionsSetup.lengedColor, @@ -543,6 +543,25 @@ export default { }; legend.itemWidth = optionsSetup.lengedWidth; }, + // 图例名称设置 + setOptionsLegendName(name){ + const optionsSetup = this.optionsSetup; + const series = this.options.series; + const legendName = optionsSetup.legendName; + // 图例没有手动写则显示原值,写了则显示新值 + if (null == legendName || legendName == '') { + for (let i = 0; i < name.length; i++) { + series[i].name = name[i]; + } + this.options.legend['data'] = name; + }else { + const arr = legendName.split('|'); + for (let i = 0; i < arr.length; i++) { + series[i].name = arr[i]; + } + this.options.legend['data'] = arr + } + }, // 颜色修改、宽度修改 setOptionsColor() { const optionsSetup = this.optionsSetup; @@ -591,19 +610,20 @@ export default { let xAxisList = []; let yAxisList = []; let arrayList = []; + const legendName = []; for (const i in val) { - xAxisList[i] = val[i].axis - yAxisList[i] = val[i].name + xAxisList[i] = val[i].axis; + yAxisList[i] = val[i].name; } - xAxisList = this.setUnique(xAxisList) - yAxisList = this.setUnique(yAxisList) + xAxisList = this.setUnique(xAxisList); + yAxisList = this.setUnique(yAxisList); for (const i in yAxisList) { - const data = new Array(yAxisList.length).fill(0) + const data = new Array(yAxisList.length).fill(0); for (const j in xAxisList) { for (const k in val) { if (val[k].name == yAxisList[i]) { if (val[k].axis == xAxisList[j]) { - data[j] = val[k].data + data[j] = val[k].data; } } } @@ -612,13 +632,16 @@ export default { name: yAxisList[i], data: data }) + legendName.push(yAxisList[i]); } - this.options.series[0]['name'] = arrayList[0].name - this.options.series[0]['data'] = arrayList[0].data - this.options.series[1]['name'] = arrayList[1].name - this.options.series[1]['data'] = arrayList[1].data - this.options.xAxis[0]['data'] = xAxisList - this.options.xAxis[1]['data'] = xAxisList + this.options.series[0]['name'] = arrayList[0].name; + this.options.series[0]['data'] = arrayList[0].data; + this.options.series[1]['name'] = arrayList[1].name; + this.options.series[1]['data'] = arrayList[1].data; + this.options.xAxis[0]['data'] = xAxisList; + this.options.xAxis[1]['data'] = xAxisList; + this.options.legend['data'] = legendName; + this.setOptionsLegendName(legendName); }, // 动态数据 dynamicDataFn(val, refreshTime, optionsSetup) { @@ -639,14 +662,19 @@ export default { }); }, renderingFn(optionsSetup, val) { - this.options.xAxis[0]['data'] = val.xAxis - this.options.xAxis[1]['data'] = val.xAxis + const legendName = []; + this.options.xAxis[0]['data'] = val.xAxis; + this.options.xAxis[1]['data'] = val.xAxis; if (val.series[0].type == "line") { - this.options.series[0]['name'] = val.series[0].name - this.options.series[0]['data'] = val.series[0].data - this.options.series[1]['name'] = val.series[1].name - this.options.series[1]['data'] = val.series[1].data + this.options.series[0]['name'] = val.series[0].name; + this.options.series[0]['data'] = val.series[0].data; + this.options.series[1]['name'] = val.series[1].name; + this.options.series[1]['data'] = val.series[1].data; + legendName.push(val.series[0].name); + legendName.push(val.series[1].name); } + this.options.legend['data'] = legendName; + this.setOptionsLegendName(legendName); } } }; diff --git a/report-ui/src/views/excelreport/viewer/index.vue b/report-ui/src/views/excelreport/viewer/index.vue index b94dd9a92f0c426cd061dd965ec31be60a0d9931..7aed447bd9d55c83b7133d9f0f1ceaa429d11a24 100644 --- a/report-ui/src/views/excelreport/viewer/index.vue +++ b/report-ui/src/views/excelreport/viewer/index.vue @@ -23,25 +23,32 @@

表格查询

+

{{ item.name }}

+
+
查询
-
+
@@ -57,6 +64,10 @@ export default { return { options: {}, sheet: {}, + total: 0, + loading: false, + currentPage4: 1, + pageSize: 100, reportId: null, reportCode: null, reportName: null, @@ -70,15 +81,27 @@ export default { }; }, mounted() { + this.loading = true; this.preview(); }, created() { this.reportCode = this.$route.query.reportCode; }, methods: { + handleSizeChange(val){ + this.pageSize = val; + this.currentPage4 = 1; + this.searchPreview(); + }, + handleCurrentChange(val){ + this.currentPage4 = val; + this.searchPreview(); + }, async searchPreview() { + this.loading = true; const arr = this.toObject(this.tableData2); this.params.setParam = JSON.stringify(arr); + //每次都重新加载需要改成刷新 this.preview(); }, @@ -86,6 +109,7 @@ export default { this.excelData = {}; this.params.reportCode = this.reportCode; const { code, data } = await preview(this.params); + this.loading = false; if (code != 200) return; this.reportName = JSON.parse(data.jsonStr).name; // 渲染查询表单 @@ -101,6 +125,7 @@ export default { } this.tableData2 = extendArry; + this.total = data.total; this.excelData = data.jsonStr; this.sheetData = data == null ? [{}] : JSON.parse(data.jsonStr); // console.log(this.excelData) @@ -132,8 +157,17 @@ export default { for (const key in objfirst) { const newObj = {}; objfirst[key].map(ev => { + console.log(ev.name); + if(ev.name == 'pageSize'){ + ev.value = this.pageSize; + } + + if(ev.name == 'pageNumber'){ + ev.value = this.currentPage4; + } Object.assign(newObj, { [ev.name]: ev.value }); }); + objSecond[key] = newObj; } return objSecond; diff --git a/report-ui/src/views/layout/components/Sidebar/index.vue b/report-ui/src/views/layout/components/Sidebar/index.vue index 9e3111205792883e34fd0ac3d60c5c0b2f8722a8..44442209a20e657f2045d23dc2c5293c0e1f19db 100644 --- a/report-ui/src/views/layout/components/Sidebar/index.vue +++ b/report-ui/src/views/layout/components/Sidebar/index.vue @@ -3,7 +3,7 @@
- V0.9.6 + V0.9.6.1