Browse Source

集成ureport工具

syh 5 years ago
parent
commit
ef6ceaf210
17 changed files with 739 additions and 3 deletions
  1. 17 0
      jeecg-boot-module-system/pom.xml
  2. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 141 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/MySQLProvider.java
  4. 35 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/PropertiesConfig.java
  5. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/ServletConfig.java
  6. 41 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/UReportConfig.java
  7. 34 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/UreportDataSource.java
  8. 248 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UReportFileController.java
  9. 57 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/UReportFile.java
  10. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/UReportFileMapper.java
  11. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/UReportFileMapper.xml
  12. 52 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IUReportFileService.java
  13. 56 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/UReportFileServiceImpl.java
  14. 5 1
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  15. 5 1
      jeecg-boot-module-system/src/main/resources/application-test.yml
  16. 1 1
      jeecg-boot-module-system/src/main/resources/application.yml
  17. 4 0
      jeecg-boot-module-system/src/main/resources/ureport.properties

+ 17 - 0
jeecg-boot-module-system/pom.xml

@@ -119,6 +119,23 @@
             <version>2.0.2</version>
             <version>2.0.2</version>
             <scope>compile</scope>
             <scope>compile</scope>
         </dependency>
         </dependency>
+        <dependency>
+            <groupId>com.bstek.ureport</groupId>
+            <artifactId>ureport2-console</artifactId>
+            <version>2.2.9</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>3.17</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>3.17</version>
+        </dependency>
     </dependencies>
     </dependencies>
 
 
     <build>
     <build>

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -143,6 +143,9 @@ public class ShiroConfig {
 		//爬虫接口
 		//爬虫接口
 		filterChainDefinitionMap.put("/graphql/video", "anon");
 		filterChainDefinitionMap.put("/graphql/video", "anon");
 		filterChainDefinitionMap.put("/ks/web/test", "anon");
 		filterChainDefinitionMap.put("/ks/web/test", "anon");
+
+        filterChainDefinitionMap.put("/ureport/**", "anon");
+
 		// 添加自己的过滤器并且取名为jwt
 		// 添加自己的过滤器并且取名为jwt
 		Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
 		Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
 		filterMap.put("jwt", new JwtFilter());
 		filterMap.put("jwt", new JwtFilter());

+ 141 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/MySQLProvider.java

@@ -0,0 +1,141 @@
+package org.jeecg.config.ureport;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.bstek.ureport.exception.ReportException;
+import com.bstek.ureport.provider.report.ReportFile;
+import com.bstek.ureport.provider.report.ReportProvider;
+import lombok.Setter;
+import org.jeecg.modules.ctop.entity.UReportFile;
+import org.jeecg.modules.ctop.service.IUReportFileService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+@Setter
+public class MySQLProvider implements ReportProvider {
+
+    /**
+     * 存储器名称
+     */
+    private static final String NAME = "mysql-provider";
+
+    /**
+     * 报表文件名前缀
+     */
+    private String prefix = "mysql:";
+
+    /**
+     * 是否禁用
+     */
+    private boolean disabled = false;
+
+    @Autowired
+    private IUReportFileService reportFileService;
+
+    /**
+     * 根据报表名加载报表文件
+     *
+     * @param file 报表名称
+     * @return 返回的InputStream
+     */
+    @Override
+    public InputStream loadReport(String file) {
+        UReportFile reportFile = reportFileService.getReportFileByName(getCorrectName(file));
+        ByteArrayInputStream stream = null;
+        if (ObjectUtil.isNotEmpty(reportFile)) {
+            try {
+                stream = new ByteArrayInputStream(reportFile.getContent().getBytes());
+            } catch (Exception e) {
+                throw new ReportException(e);
+            }
+        }
+        return stream;
+    }
+
+    /**
+     * 根据报表名,删除指定的报表文件
+     *
+     * @param file 报表名称
+     */
+    @Override
+    public void deleteReport(String file) {
+        reportFileService.removeReportFileByName(getCorrectName(file));
+    }
+
+    /**
+     * 获取所有的报表文件
+     *
+     * @return 返回报表文件列表
+     */
+    @Override
+    public List<ReportFile> getReportFiles() {
+        List<UReportFile> list = reportFileService.listAllReportFile();
+        List<ReportFile> reportList = new ArrayList<>();
+        for (UReportFile file : list) {
+            reportList.add(new ReportFile(file.getName(), file.getUpdateTime()));
+        }
+        return reportList;
+    }
+
+    /**
+     * 保存报表文件
+     *
+     * @param file    报表名称
+     * @param content 报表的XML内容
+     */
+    @Override
+    public void saveReport(String file, String content) {
+        file = getCorrectName(file);
+        UReportFile reportFile = reportFileService.getReportFileByName(file);
+        if (ObjectUtil.isEmpty(reportFile)) {
+            reportFile = new UReportFile();
+            reportFile.setName(file);
+            reportFile.setContent(content);
+            reportFileService.save(reportFile);
+        } else {
+            reportFile.setContent(content);
+            reportFileService.updateReportFile(reportFile);
+        }
+    }
+
+    /**
+     * @return 返回存储器名称
+     */
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+    /**
+     * @return 返回是否禁用
+     */
+    @Override
+    public boolean disabled() {
+        return disabled;
+    }
+
+    /**
+     * @return 返回报表文件名前缀
+     */
+    @Override
+    public String getPrefix() {
+        return prefix;
+    }
+
+    /**
+     * 获取没有前缀的文件名
+     *
+     * @param name 报表名称
+     */
+    private String getCorrectName(String name) {
+        if (name.startsWith(prefix)) {
+            name = name.substring(prefix.length());
+        }
+        return name;
+    }
+}

+ 35 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/PropertiesConfig.java

@@ -0,0 +1,35 @@
+package org.jeecg.config.ureport;
+
+import com.bstek.ureport.UReportPropertyPlaceholderConfigurer;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+@Slf4j
+@Configuration
+@ConditionalOnBean(UReportConfig.class)
+public class PropertiesConfig extends UReportPropertyPlaceholderConfigurer implements InitializingBean {
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        // 将配置追加到UReport的配置类中
+        setProperties(loadProperties());
+    }
+
+    /**
+     * 加载配置文件
+     */
+    private Properties loadProperties() throws IOException {
+        ClassPathResource classPathResource = new ClassPathResource("ureport.properties");
+        InputStream inputStream = classPathResource.getInputStream();
+        Properties properties = new Properties();
+        properties.load(inputStream);
+        return properties;
+    }
+}

+ 20 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/ServletConfig.java

@@ -0,0 +1,20 @@
+package org.jeecg.config.ureport;
+
+import com.bstek.ureport.console.UReportServlet;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.ImportResource;
+
+import javax.servlet.Servlet;
+
+@Configuration
+@ImportResource("classpath:ureport-console-context.xml")
+public class ServletConfig {
+
+    @Bean
+    public ServletRegistrationBean<Servlet> buildUReportServlet() {
+        return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*");
+    }
+}
+

+ 41 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/UReportConfig.java

@@ -0,0 +1,41 @@
+package org.jeecg.config.ureport;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Data
+@Slf4j
+@Configuration
+@ConfigurationProperties("ureport")
+public class UReportConfig {
+    /**
+     * 文件名前缀,用于标识不同的存储器存储的文件
+     * 否则在查看文件列表的时候只能看到其中一个存储器的文件
+     */
+    private String metaPrefix = "meta:";
+    private String fullPrefix = "full:";
+
+    /**
+     * 是否禁用DBMetaReportProvider
+     */
+    private boolean disableDBMetaProvider = false;
+
+    /**
+     * 是否禁用DBFullReportProvider
+     */
+    private boolean disableDBFullProvider = false;
+
+    /**
+     * 是否禁用FileReportProvider
+     */
+    private boolean disableFileProvider = false;
+
+    /**
+     * 报表模板文件存储路径
+     */
+    private String fileStoreDir = "ureportfiles";
+
+}
+

+ 34 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ureport/UreportDataSource.java

@@ -0,0 +1,34 @@
+package org.jeecg.config.ureport;
+
+import com.bstek.ureport.definition.datasource.BuildinDatasource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+@Component
+@Slf4j
+public class UreportDataSource implements BuildinDatasource {
+    private static final String NAME = "MyDataSource";
+    @Autowired
+    private DataSource dataSource;
+
+    @Override
+    public String name() {
+        return NAME;
+    }
+
+    @Override
+    public Connection getConnection() {
+        try {
+            return dataSource.getConnection();
+        } catch (SQLException e) {
+            log.error("Ureport 数据源 获取连接失败!");
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 248 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UReportFileController.java

@@ -0,0 +1,248 @@
+package org.jeecg.modules.ctop.controller;
+
+import com.alibaba.fastjson.JSON;
+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 io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.ctop.entity.UReportFile;
+import org.jeecg.modules.ctop.service.IUReportFileService;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 报表文件存储
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-01-15
+ */
+@Slf4j
+@Api(tags = "报表文件存储")
+@RestController
+@RequestMapping("/ctop/uReportFile")
+public class UReportFileController {
+    @Autowired
+    private IUReportFileService uReportFileService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param uReportFile
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "报表文件存储-分页列表查询")
+    @ApiOperation(value = "报表文件存储-分页列表查询", notes = "报表文件存储-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<UReportFile>> queryPageList(UReportFile uReportFile,
+                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                    HttpServletRequest req) {
+        Result<IPage<UReportFile>> result = new Result<IPage<UReportFile>>();
+        QueryWrapper<UReportFile> queryWrapper = QueryGenerator.initQueryWrapper(uReportFile, req.getParameterMap());
+        Page<UReportFile> page = new Page<UReportFile>(pageNo, pageSize);
+        IPage<UReportFile> pageList = uReportFileService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param uReportFile
+     * @return
+     */
+    @AutoLog(value = "报表文件存储-添加")
+    @ApiOperation(value = "报表文件存储-添加", notes = "报表文件存储-添加")
+    @PostMapping(value = "/add")
+    public Result<UReportFile> add(@RequestBody UReportFile uReportFile) {
+        Result<UReportFile> result = new Result<UReportFile>();
+        try {
+            uReportFileService.save(uReportFile);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param uReportFile
+     * @return
+     */
+    @AutoLog(value = "报表文件存储-编辑")
+    @ApiOperation(value = "报表文件存储-编辑", notes = "报表文件存储-编辑")
+    @PutMapping(value = "/edit")
+    public Result<UReportFile> edit(@RequestBody UReportFile uReportFile) {
+        Result<UReportFile> result = new Result<UReportFile>();
+        UReportFile uReportFileEntity = uReportFileService.getById(uReportFile.getId());
+        if (uReportFileEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = uReportFileService.updateById(uReportFile);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "报表文件存储-通过id删除")
+    @ApiOperation(value = "报表文件存储-通过id删除", notes = "报表文件存储-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            uReportFileService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "报表文件存储-批量删除")
+    @ApiOperation(value = "报表文件存储-批量删除", notes = "报表文件存储-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<UReportFile> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<UReportFile> result = new Result<UReportFile>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.uReportFileService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "报表文件存储-通过id查询")
+    @ApiOperation(value = "报表文件存储-通过id查询", notes = "报表文件存储-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<UReportFile> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<UReportFile> result = new Result<UReportFile>();
+        UReportFile uReportFile = uReportFileService.getById(id);
+        if (uReportFile == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(uReportFile);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<UReportFile> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                UReportFile uReportFile = JSON.parseObject(deString, UReportFile.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(uReportFile, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<UReportFile> pageList = uReportFileService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "报表文件存储列表");
+        mv.addObject(NormalExcelConstants.CLASS, UReportFile.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("报表文件存储列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<UReportFile> listUReportFiles = ExcelImportUtil.importExcel(file.getInputStream(), UReportFile.class, params);
+                uReportFileService.saveBatch(listUReportFiles);
+                return Result.ok("文件导入成功!数据行数:" + listUReportFiles.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 57 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/UReportFile.java

@@ -0,0 +1,57 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 报表文件存储
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-01-15
+ */
+@Data
+@TableName("ureport_file")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ureport_file对象", description = "报表文件存储")
+public class UReportFile {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 报表名称
+     */
+    @Excel(name = "报表名称", width = 15)
+    @ApiModelProperty(value = "报表名称")
+    private String name;
+    /**
+     * 报表内容
+     */
+    @Excel(name = "报表内容", width = 15)
+    @ApiModelProperty(value = "报表内容")
+    private String content;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+}

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/UReportFileMapper.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ctop.entity.UReportFile;
+
+/**
+ * 报表文件存储
+ *
+ * @author: jeecg-boot
+ * @date: 2020-01-15
+ * @cersion: V1.0
+ */
+public interface UReportFileMapper extends BaseMapper<UReportFile> {
+
+}

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/UReportFileMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.ctop.mapper.UReportFileMapper">
+
+</mapper>

+ 52 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IUReportFileService.java

@@ -0,0 +1,52 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.UReportFile;
+
+import java.util.List;
+
+/**
+ * 报表文件存储
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-01-15
+ */
+public interface IUReportFileService extends IService<UReportFile> {
+    /**
+     * 根据报表名称检查报表是否存在
+     *
+     * @param name 报表名称
+     */
+    boolean checkExistByName(String name);
+
+    /**
+     * 根据报表名称查询报表
+     *
+     * @param name 报表名称
+     */
+    UReportFile getReportFileByName(String name);
+
+    /**
+     * 查询全部报表
+     */
+    List<UReportFile> listAllReportFile();
+
+    /**
+     * 根据报表名称删除报表
+     *
+     * @param name 报表名称
+     */
+    boolean removeReportFileByName(String name);
+
+
+    /**
+     * 保存报表
+     */
+    boolean saveReportFile(UReportFile entity);
+
+    /**
+     * 更新报表
+     */
+    boolean updateReportFile(UReportFile entity);
+}

+ 56 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/UReportFileServiceImpl.java

@@ -0,0 +1,56 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ctop.entity.UReportFile;
+import org.jeecg.modules.ctop.mapper.UReportFileMapper;
+import org.jeecg.modules.ctop.service.IUReportFileService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 报表文件存储
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-01-15
+ */
+@Service
+public class UReportFileServiceImpl extends ServiceImpl<UReportFileMapper, UReportFile> implements IUReportFileService {
+
+    @Override
+    public boolean checkExistByName(String name) {
+        UReportFile file = this.getReportFileByName(name);
+        return null != file;
+    }
+
+    @Override
+    public UReportFile getReportFileByName(String name) {
+        QueryWrapper<UReportFile> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("name", name).orderByDesc("id").last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+
+    @Override
+    public List<UReportFile> listAllReportFile() {
+        return this.list();
+    }
+
+    @Override
+    public boolean removeReportFileByName(String name) {
+        QueryWrapper<UReportFile> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("name", name);
+        return this.remove(queryWrapper);
+    }
+
+    @Override
+    public boolean saveReportFile(UReportFile entity) {
+        return this.save(entity);
+    }
+
+    @Override
+    public boolean updateReportFile(UReportFile entity) {
+        return this.updateById(entity);
+    }
+}

+ 5 - 1
jeecg-boot-module-system/src/main/resources/application-prod.yml

@@ -65,6 +65,10 @@ spring:
   autoconfigure:
   autoconfigure:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
   datasource:
+    url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    username: hcst
+    password: test@20190531
+    driver-class-name: com.mysql.jdbc.Driver
     druid:
     druid:
       stat-view-servlet:
       stat-view-servlet:
         loginUsername: admin
         loginUsername: admin
@@ -161,4 +165,4 @@ oss:
   replace:
   replace:
     replace-value: oss-cn-beijing-internal
     replace-value: oss-cn-beijing-internal
     replace-old-value: oss-cn-beijing
     replace-old-value: oss-cn-beijing
-    download: /mnt/file/video/
+    download: /mnt/file/video/

+ 5 - 1
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -64,6 +64,10 @@ spring:
   autoconfigure:
   autoconfigure:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
   datasource:
+    url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    username: hcst
+    password: test@20190531
+    driver-class-name: com.mysql.jdbc.Driver
     druid:
     druid:
       stat-view-servlet:
       stat-view-servlet:
         enabled: true
         enabled: true
@@ -165,4 +169,4 @@ oss:
   replace:
   replace:
     replace-value: oss-cn-beijing-internal
     replace-value: oss-cn-beijing-internal
     replace-old-value: oss-cn-beijing
     replace-old-value: oss-cn-beijing
-    download: /mnt/file/video/
+    download: /mnt/file/video/

+ 1 - 1
jeecg-boot-module-system/src/main/resources/application.yml

@@ -6,4 +6,4 @@ swagger:
   basic:
   basic:
     enable: true
     enable: true
     username: jeecg
     username: jeecg
-    password: jeecg1314
+    password: jeecg1314

+ 4 - 0
jeecg-boot-module-system/src/main/resources/ureport.properties

@@ -0,0 +1,4 @@
+ureport.disableHttpSessionReportCache=false
+ureport.disableFileProvider=true
+ureport.fileStoreDir=/WEB-INF/ureportfiles
+ureport.debug=true