From bf6f3d9254a0c5aaa03150f218d20f3ee8e44af6 Mon Sep 17 00:00:00 2001 From: Foming Date: Tue, 22 Jun 2021 14:14:11 +0800 Subject: [PATCH] report --- .../data/report/constant/ExpConstant.java | 25 ++++++++ .../report/controller/ReportController.java | 60 +++++++++++++++++++ .../data/report/controller/dto/ReportDto.java | 44 ++++++++++++++ .../report/controller/param/ReportParam.java | 30 ++++++++++ .../modules/data/report/dao/ReportMapper.java | 13 ++++ .../data/report/dao/entity/Report.java | 41 +++++++++++++ .../data/report/service/ReportService.java | 17 ++++++ .../service/impl/ReportServiceImpl.java | 45 ++++++++++++++ 8 files changed, 275 insertions(+) create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/constant/ExpConstant.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/ReportController.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/dto/ReportDto.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/param/ReportParam.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/dao/ReportMapper.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/dao/entity/Report.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/service/ReportService.java create mode 100644 report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/service/impl/ReportServiceImpl.java diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/constant/ExpConstant.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/constant/ExpConstant.java new file mode 100644 index 00000000..86d674fe --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/constant/ExpConstant.java @@ -0,0 +1,25 @@ +package com.anjiplus.template.gaea.business.modules.data.report.constant; + + +import java.util.ArrayList; +import java.util.List; + +/** + * + */ +public class ExpConstant { + + public static final String[] FUNCTION = new String[]{"=SUM(", "=AVERAGE(", "=MAX(", "=MIN(", "=IF(", "=AND(", "=OR(", "=CONCAT("}; + + public static List getExpFunction(String e) { + List counts = new ArrayList<>(); + for (int i = 0; i < FUNCTION.length; i++) { + if(e.contains(FUNCTION[i])){ + counts.add(i); + } + } + + return counts; + } + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/ReportController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/ReportController.java new file mode 100644 index 00000000..b1c7db76 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/ReportController.java @@ -0,0 +1,60 @@ +package com.anjiplus.template.gaea.business.modules.data.report.controller; + +import com.anji.plus.gaea.annotation.Permission; +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.anjiplus.template.gaea.business.modules.data.report.controller.dto.ReportDto; +import com.anjiplus.template.gaea.business.modules.data.report.controller.param.ReportParam; +import com.anjiplus.template.gaea.business.modules.data.report.dao.entity.Report; +import com.anjiplus.template.gaea.business.modules.data.report.service.ReportService; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * TODO + * + * @author chenkening + * @date 2021/3/26 10:19 + */ +@RestController +@Api(tags = "报表数据管理") +@RequestMapping("/report") +public class ReportController extends GaeaBaseController { + + @Autowired + private ReportService reportService; + + @Override + public GaeaBaseService getService() { + return reportService; + } + + @Override + public Report getEntity() { + return new Report(); + } + + @Override + public ReportDto getDTO() { + return new ReportDto(); + } + + @DeleteMapping("/delReport") + @Permission( + code = "DELETE", + name = "删除" + ) + @GaeaAuditLog( + pageTitle = "删除" + ) + public ResponseBean delReport(@RequestBody ReportDto reportDto) { + reportService.delReport(reportDto); + return ResponseBean.builder().build(); + } +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/dto/ReportDto.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/dto/ReportDto.java new file mode 100644 index 00000000..98003946 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/dto/ReportDto.java @@ -0,0 +1,44 @@ +package com.anjiplus.template.gaea.business.modules.data.report.controller.dto; + +import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; +import lombok.Data; + +import java.io.Serializable; + +/** + * TODO + * + * @author chenkening + * @date 2021/3/26 10:34 + */ +@Data +public class ReportDto extends GaeaBaseDTO implements Serializable { + + /** 报表名称 */ + private String reportName; + + /** 报表编码 */ + private String reportCode; + + /**数据集编码,以|分割*/ + private String setCodes; + + /** 分组 */ + private String reportGroup; + + /** 备注 */ + private String reportDesc; + + /** 数据集查询参数 */ + private String setParam; + + /** 报表json字符串 */ + private String jsonStr; + + /** 报表类型 */ + private String reportType; + + /** 数据总计 */ + private long total; + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/param/ReportParam.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/param/ReportParam.java new file mode 100644 index 00000000..4017f41f --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/controller/param/ReportParam.java @@ -0,0 +1,30 @@ +package com.anjiplus.template.gaea.business.modules.data.report.controller.param; + +import com.anji.plus.gaea.annotation.Query; +import com.anji.plus.gaea.constant.QueryEnum; +import com.anji.plus.gaea.curd.params.PageParam; +import lombok.Data; + +import java.io.Serializable; + +/** + * TODO + * + * @author chenkening + * @date 2021/3/26 10:40 + */ +@Data +public class ReportParam extends PageParam implements Serializable{ + + /** 报表名称 */ + @Query(QueryEnum.LIKE) + private String reportName; + + /** 报表编码 */ + @Query(QueryEnum.LIKE) + private String reportCode; + + /** 报表类型 */ + @Query(QueryEnum.EQ) + private String reportType; +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/dao/ReportMapper.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/dao/ReportMapper.java new file mode 100644 index 00000000..e9e2e567 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/dao/ReportMapper.java @@ -0,0 +1,13 @@ +package com.anjiplus.template.gaea.business.modules.data.report.dao; + +import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; +import com.anjiplus.template.gaea.business.modules.data.report.dao.entity.Report; + +/** + * TODO + * + * @author chenkening + * @date 2021/3/26 10:19 + */ +public interface ReportMapper extends GaeaBaseMapper { +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/dao/entity/Report.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/dao/entity/Report.java new file mode 100644 index 00000000..b60b8a78 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/dao/entity/Report.java @@ -0,0 +1,41 @@ +package com.anjiplus.template.gaea.business.modules.data.report.dao.entity; + +import com.anji.plus.gaea.annotation.Unique; +import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; +import com.anjiplus.template.gaea.common.RespCommonCode; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * TODO + * + * @author chenkening + * @date 2021/3/26 10:20 + */ +@TableName(value="gaea_report") +@Data +public class Report extends GaeaBaseEntity { + + @ApiModelProperty(value = "名称") + private String reportName; + + @ApiModelProperty(value = "报表编码") + @Unique(code = RespCommonCode.REPORT_CODE_ISEXIST) + private String reportCode; + + @ApiModelProperty(value = "分组") + private String reportGroup; + + @ApiModelProperty(value = "报表描述") + private String reportDesc; + + @ApiModelProperty(value = "报表类型") + private String reportType; + + @ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG") + private Integer enableFlag; + + @ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG") + private Integer deleteFlag; +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/service/ReportService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/service/ReportService.java new file mode 100644 index 00000000..9afca1f0 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/service/ReportService.java @@ -0,0 +1,17 @@ +package com.anjiplus.template.gaea.business.modules.data.report.service; + +import com.anji.plus.gaea.curd.service.GaeaBaseService; +import com.anjiplus.template.gaea.business.modules.data.report.controller.dto.ReportDto; +import com.anjiplus.template.gaea.business.modules.data.report.controller.param.ReportParam; +import com.anjiplus.template.gaea.business.modules.data.report.dao.entity.Report; + +/** + * TODO + * + * @author chenkening + * @date 2021/3/26 10:35 + */ +public interface ReportService extends GaeaBaseService { + + void delReport(ReportDto reportDto); +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/service/impl/ReportServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/service/impl/ReportServiceImpl.java new file mode 100644 index 00000000..34104887 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/data/report/service/impl/ReportServiceImpl.java @@ -0,0 +1,45 @@ +package com.anjiplus.template.gaea.business.modules.data.report.service.impl; + +import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; +import com.anjiplus.template.gaea.business.modules.data.report.controller.dto.ReportDto; +import com.anjiplus.template.gaea.business.modules.data.report.dao.ReportMapper; +import com.anjiplus.template.gaea.business.modules.data.report.dao.entity.Report; +import com.anjiplus.template.gaea.business.modules.data.report.service.ReportService; +import com.anjiplus.template.gaea.business.modules.data.reportexcel.dao.ReportExcelMapper; +import com.anjiplus.template.gaea.business.modules.data.reportexcel.dao.entity.ReportExcel; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * TODO + * + * @author chenkening + * @date 2021/3/26 10:35 + */ +@Service +public class ReportServiceImpl implements ReportService { + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + @Autowired + private ReportMapper reportMapper; + + @Autowired + private ReportExcelMapper reportExcelMapper; + + @Override + public GaeaBaseMapper getMapper() { + return reportMapper; + } + + + @Override + public void delReport(ReportDto reportDto) { + deleteById(reportDto.getId()); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("report_code" , reportDto.getReportCode()); + reportExcelMapper.delete(queryWrapper); + } +}