Parcourir la source

自定义报表-基础版本-新增-001

guarantee-lsq il y a 2 ans
Parent
commit
b99e57d06f

+ 107 - 0
platform-dao/src/main/java/com/platform/dao/dto/customize/CustomizeReportDTO.java

@@ -0,0 +1,107 @@
+package com.platform.dao.dto.customize;
+
+import com.platform.common.bean.BaseDTO;
+import com.platform.common.validation.group.UpdateGroup;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.*;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.time.LocalDate;
+
+/**
+ * @Description 自定义报表DTO
+ * @Author xc
+ * @Date 2022-04-15 10:26:43
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+public class CustomizeReportDTO extends BaseDTO implements Serializable {
+
+    /**
+     *
+     */
+    @NotNull(groups = {UpdateGroup.class}, message = "ID不能为空")
+    private String id;
+    /**
+     * 自定义报表名称
+     */
+    private String name;
+    /**
+     * 图形类别
+     */
+    private Integer echartType;
+    /**
+     * 报表检索条件
+     */
+    private String parameter;
+    /**
+     * 报表接口类型
+     */
+    private Integer interType;
+    /**
+     * sql语句
+     */
+    private String sqlVal;
+    /**
+     * 表格展示字段
+     */
+    private String columns;
+    /**
+     * 自定义报表状态
+     */
+    private Integer status;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     *
+     */
+    private String createdUserId;
+    /**
+     *
+     */
+    private String updateUserId;
+    /**
+     *
+     */
+    private String createdUserName;
+    /**
+     *
+     */
+    private String updateUserName;
+    /**
+     *
+     */
+    private LocalDateTime createdTime;
+    /**
+     * 开始
+     */
+    private LocalDateTime createdTimeStart;
+    /**
+     * 结束
+     */
+    private LocalDateTime createdTimeEnd;
+    /**
+     *
+     */
+    private LocalDateTime updateTime;
+    /**
+     * 开始
+     */
+    private LocalDateTime updateTimeStart;
+    /**
+     * 结束
+     */
+    private LocalDateTime updateTimeEnd;
+    /**
+     * 关键字
+     */
+    private String keyword;
+
+}

+ 93 - 0
platform-dao/src/main/java/com/platform/dao/entity/customize/CustomizeReport.java

@@ -0,0 +1,93 @@
+package com.platform.dao.entity.customize;
+
+import lombok.Data;
+
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.time.LocalDate;
+import lombok.experimental.Accessors;
+import com.platform.common.bean.DataScope;
+import javax.persistence.Transient;
+
+/**
+ * @Description 自定义报表实体类
+ * @Author xc
+ * @Date 2022-04-15 10:26:43
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@Table(name = "t_customize_report")
+public class CustomizeReport implements Serializable{
+
+    /**
+     * 
+     */
+        @Id
+    private String id;
+    /**
+     * 自定义报表名称
+     */
+    private String name;
+    /**
+     * 图形类别
+     */
+    private Integer echartType;
+    /**
+     * 报表检索条件
+     */
+    private String parameter;
+    /**
+     * 报表接口类型
+     */
+    private Integer interType;
+    /**
+     * sql语句
+     */
+    private String sqlVal;
+    /**
+     * 表格展示字段
+     */
+    private String columns;
+    /**
+     * 自定义报表状态
+     */
+    private Integer status;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 
+     */
+    private String createdUserId;
+    /**
+     * 
+     */
+    private String updateUserId;
+    /**
+     * 
+     */
+    private String createdUserName;
+    /**
+     * 
+     */
+    private String updateUserName;
+    /**
+     * 
+     */
+    private LocalDateTime createdTime;
+    /**
+     * 
+     */
+    private LocalDateTime updateTime;
+
+   /**
+    * 数据权限
+    */
+    @Transient
+    private DataScope dataScope;
+
+}

+ 26 - 0
platform-dao/src/main/java/com/platform/dao/mapper/customize/CustomizeReportMapper.java

@@ -0,0 +1,26 @@
+package com.platform.dao.mapper.customize;
+
+import com.platform.dao.dto.customize.CustomizeReportDTO;
+import com.platform.dao.config.MyMapper;
+import com.platform.dao.entity.customize.CustomizeReport;
+import com.platform.dao.vo.query.customize.CustomizeReportVO;
+import org.springframework.stereotype.Component;
+import java.util.List;
+
+
+/**
+ * @Description 自定义报表 mapper
+ * @Author xc
+ * @Date 2022-04-15 10:26:43
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Component
+public interface CustomizeReportMapper extends MyMapper<CustomizeReport> {
+    /**
+     * 分页查询
+     * @param dto
+     * @return
+     */
+    List<CustomizeReportVO> selectList(CustomizeReportDTO dto);
+
+}

+ 111 - 0
platform-dao/src/main/java/com/platform/dao/vo/export/customize/ExportCustomizeReportVO.java

@@ -0,0 +1,111 @@
+package com.platform.dao.vo.export.customize;
+
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.time.LocalDate;
+
+/**
+ * @Description 自定义报表导出VO
+ * @Author xc
+ * @Date 2022-04-15 10:26:43
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+public class ExportCustomizeReportVO implements Serializable {
+
+    /**
+   * 
+   */
+  @Excel(name = "", orderNum = "1")
+  private String id;
+
+    /**
+   * 自定义报表名称
+   */
+  @Excel(name = "自定义报表名称", orderNum = "2")
+  private String name;
+
+    /**
+   * 图形类别
+   */
+  @Excel(name = "图形类别", orderNum = "3")
+  private Integer echartType;
+
+    /**
+   * 报表检索条件
+   */
+  @Excel(name = "报表检索条件", orderNum = "4")
+  private String parameter;
+
+    /**
+   * 报表接口类型
+   */
+  @Excel(name = "报表接口类型", orderNum = "5")
+  private Integer interType;
+
+    /**
+   * sql语句
+   */
+  @Excel(name = "sql语句", orderNum = "6")
+  private String sql;
+
+    /**
+   * 表格展示字段
+   */
+  @Excel(name = "表格展示字段", orderNum = "7")
+  private String columns;
+
+    /**
+   * 自定义报表状态
+   */
+  @Excel(name = "自定义报表状态", orderNum = "8")
+  private Integer status;
+
+    /**
+   * 备注
+   */
+  @Excel(name = "备注", orderNum = "9")
+  private String remark;
+
+    /**
+   * 
+   */
+  @Excel(name = "", orderNum = "10")
+  private String createdUserId;
+
+    /**
+   * 
+   */
+  @Excel(name = "", orderNum = "11")
+  private String updateUserId;
+
+    /**
+   * 
+   */
+  @Excel(name = "", orderNum = "12")
+  private String createdUserName;
+
+    /**
+   * 
+   */
+  @Excel(name = "", orderNum = "13")
+  private String updateUserName;
+
+    /**
+   * 
+   */
+  @Excel(name = "", orderNum = "14")
+  private LocalDateTime createdTime;
+
+    /**
+   * 
+   */
+  @Excel(name = "", orderNum = "15")
+  private LocalDateTime updateTime;
+
+  
+}

+ 88 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/customize/CustomizeReportVO.java

@@ -0,0 +1,88 @@
+package com.platform.dao.vo.query.customize;
+
+import lombok.Data;
+import com.platform.common.bean.BaseVO;
+import com.platform.common.bean.BaseDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.*;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.time.LocalDate;
+
+/**
+ * @Description 自定义报表VO结果类
+ * @Author xc
+ * @Date 2022-04-15 10:26:43
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+public class CustomizeReportVO extends BaseVO implements Serializable {
+
+    /**
+     *
+     */
+    private String id;
+    /**
+     * 自定义报表名称
+     */
+    private String name;
+    /**
+     * 图形类别
+     */
+    private Integer echartType;
+    /**
+     * 报表检索条件
+     */
+    private String parameter;
+    /**
+     * 报表接口类型
+     */
+    private Integer interType;
+    /**
+     * sql语句
+     */
+    private String sqlVal;
+    /**
+     * 表格展示字段
+     */
+    private String columns;
+    /**
+     * 自定义报表状态
+     */
+    private Integer status;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     *
+     */
+    private String createdUserId;
+    /**
+     *
+     */
+    private String updateUserId;
+    /**
+     *
+     */
+    private String createdUserName;
+    /**
+     *
+     */
+    private String updateUserName;
+    /**
+     *
+     */
+    private LocalDateTime createdTime;
+    /**
+     *
+     */
+    private LocalDateTime updateTime;
+
+
+}

+ 101 - 0
platform-dao/src/main/resources/mapper/customize/CustomizeReportMapper.xml

@@ -0,0 +1,101 @@
+<?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="com.platform.dao.mapper.customize.CustomizeReportMapper">
+    <sql id="Base_Column_List">
+                             report.id,
+                                     report.name,
+                                     report.echart_type,
+                                     report.parameter,
+                                     report.inter_type,
+                                     report.sql_val,
+                                     report.columns,
+                                     report.status,
+                                     report.remark,
+                                     report.created_user_id,
+                                     report.update_user_id,
+                                     report.created_user_name,
+                                     report.update_user_name,
+                                     report.created_time,
+                                     report.update_time
+                        </sql>
+    <sql id="Ref_Column_List">
+                                                                         report.name,
+                                     report.echart_type,
+                                     report.parameter,
+                                     report.inter_type,
+                                     report.sql_val,
+                                     report.columns,
+                                     report.status,
+                                     report.remark,
+                                                                                                                                                                                                                                                                                                </sql>
+    <sql id="List_Condition">
+        <if test="id != null and id != ''">
+            and report.id = #{id}
+        </if>
+        <if test="name != null and name != ''">
+            and report.name = #{name}
+        </if>
+        <if test="echartType != null">
+            and report.echart_type = #{echartType}
+        </if>
+        <if test="parameter != null">
+            and report.parameter = #{parameter}
+        </if>
+        <if test="interType != null">
+            and report.inter_type = #{interType}
+        </if>
+        <if test="sqlVal != null">
+            and report.sql_val = #{sqlVal}
+        </if>
+        <if test="columns != null">
+            and report.columns = #{columns}
+        </if>
+        <if test="status != null">
+            and report.status = #{status}
+        </if>
+        <if test="remark != null and remark != ''">
+            and report.remark = #{remark}
+        </if>
+        <if test="createdUserId != null and createdUserId != ''">
+            and report.created_user_id = #{createdUserId}
+        </if>
+        <if test="updateUserId != null and updateUserId != ''">
+            and report.update_user_id = #{updateUserId}
+        </if>
+        <if test="createdUserName != null and createdUserName != ''">
+            and report.created_user_name = #{createdUserName}
+        </if>
+        <if test="updateUserName != null and updateUserName != ''">
+            and report.update_user_name = #{updateUserName}
+        </if>
+        <if test="createdTimeStart != null">
+            and report.created_time <![CDATA[>=]]>; #{createdTimeStart}
+        </if>
+        <if test="createdTimeEnd != null">
+            and report.created_time <![CDATA[<=]]> #{createdTimeEnd}
+        </if>
+        <if test="createdTime != null">
+            and report.created_time = #{createdTime}
+        </if>
+        <if test="updateTimeStart != null">
+            and report.update_time <![CDATA[>=]]>; #{updateTimeStart}
+        </if>
+        <if test="updateTimeEnd != null">
+            and report.update_time <![CDATA[<=]]> #{updateTimeEnd}
+        </if>
+        <if test="updateTime != null">
+            and report.update_time = #{updateTime}
+        </if>
+        <if test="keyword != null and keyword != ''">
+            and report.id like concat(concat('%',#{keyword}),'%')
+        </if>
+    </sql>
+    <select id="selectList" parameterType="com.platform.dao.dto.customize.CustomizeReportDTO"
+            resultType="com.platform.dao.vo.query.customize.CustomizeReportVO">
+        select report.*
+        from t_customize_report as report
+        <where>
+            <include refid="List_Condition"/>
+        </where>
+    </select>
+</mapper>

+ 139 - 0
platform-rest/src/main/java/com/platform/rest/controller/customize/CustomizeReportController.java

@@ -0,0 +1,139 @@
+package com.platform.rest.controller.customize;
+
+import com.platform.common.util.R;
+import com.platform.dao.dto.customize.CustomizeReportDTO;
+import com.platform.dao.entity.customize.CustomizeReport;
+import com.platform.service.customize.CustomizeReportService;
+import com.platform.dao.util.ExcelUtil;
+import com.platform.dao.vo.export.customize.ExportCustomizeReportVO;
+import com.platform.dao.vo.query.customize.CustomizeReportVO;
+import com.platform.common.util.BeanConverterUtil;
+import com.platform.common.validation.group.AddGroup;
+import com.platform.common.validation.group.UpdateGroup;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import lombok.AllArgsConstructor;
+import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.rest.log.annotation.SysLog;
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @Description 自定义报表 控制器
+ * @Author xc
+ * @Date 2022-04-15 10:26:43
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/customize/reports")
+public class CustomizeReportController {
+
+  private final  CustomizeReportService customizeReportService;
+
+  /**
+   * 通过id查询单条记录
+   *
+   * @param id 主键
+   * @return R
+   */
+  @GetMapping("/{id}")
+  public R<CustomizeReport> getById(@PathVariable("id") String id){
+      return new R<>(customizeReportService.getModelById(id));
+  }
+
+  /**
+   * 新增记录
+   *
+   * @param customizeReportDTO 自定义报表DTO
+   * @return R
+   */
+  @SysLog("新增自定义报表")
+  @PostMapping
+  @PreAuthorize("@pms.hasPermission('customize-reports-add')")
+  public R save(@Validated({AddGroup.class}) @RequestBody CustomizeReportDTO customizeReportDTO) {
+      return new R<>(customizeReportService.saveModelByDTO(customizeReportDTO));
+  }
+
+  /**
+   * 修改记录
+   *
+   * @param customizeReportDTO 自定义报表DTO
+   * @return R
+   */
+  @SysLog("修改自定义报表")
+  @PutMapping("/{id}")
+  @PreAuthorize("@pms.hasPermission('customize-reports-edit')")
+  public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody CustomizeReportDTO customizeReportDTO) {
+      customizeReportService.modModelByDTO(customizeReportDTO);
+      return new R<>();
+  }
+
+  /**
+   * 通过id删除一条记录
+   *
+   * @param id 主键
+   * @return R
+   */
+  @SysLog("删除自定义报表")
+  @DeleteMapping("/{id}")
+  @PreAuthorize("@pms.hasPermission('customize-reports-del')")
+  public R removeById(@PathVariable String id){
+    customizeReportService.deleteByPrimaryKey(id);
+    return new R<>();
+  }
+
+    /**
+     * 批量记录
+     *
+     * @param ids 主键
+     * @return R
+     */
+    @SysLog("批量删除自定义报表")
+    @DeleteMapping("")
+    @PreAuthorize("@pms.hasPermission('customize-reports-del')")
+    public R removeIds(@RequestBody List<String> ids){
+        customizeReportService.batchDelete(ids);
+        return new R<>();
+    }
+
+  /**
+   * 获取分页
+   *
+   * @param pageNum 当前页码
+   * @param pageSize 每页条数
+   * @param customizeReportDTO 自定义报表DTO
+   * @return R
+   */
+  @GetMapping("/page")
+  public R<AbstractPageResultBean<CustomizeReportVO>> query(CustomizeReportDTO customizeReportDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
+      return new R<>(customizeReportService.selectPageList(customizeReportDTO, pageNum, pageSize));
+  }
+
+  /**
+   * 获取列表
+   *
+   * @param customizeReportDTO 自定义报表DTO
+   * @return R
+   */
+  @GetMapping("")
+  public R query(CustomizeReportDTO customizeReportDTO) {
+      return new R<>(customizeReportService.getModelListByDTO(customizeReportDTO));
+  }
+
+  /**
+     * 自定义报表导出
+     *
+     * @param customizeReportDTO 自定义报表DTO
+     * @return R
+     */
+  @GetMapping("/export")
+  @SysLog("自定义报表导出")
+  @PreAuthorize("@pms.hasPermission('customize-reports-export')")
+  public void export(HttpServletResponse response, CustomizeReportDTO customizeReportDTO) {
+    List<CustomizeReport> list = customizeReportService.getModelListByDTO(customizeReportDTO);
+    ExcelUtil.exportResponseDict(response, ExportCustomizeReportVO.class, BeanConverterUtil.copyListProperties(list, ExportCustomizeReportVO.class), "自定义报表");
+  }
+
+}

+ 34 - 0
platform-service/src/main/java/com/platform/service/customize/CustomizeReportService.java

@@ -0,0 +1,34 @@
+package com.platform.service.customize;
+
+import com.platform.dao.vo.query.customize.CustomizeReportVO;
+import com.platform.dao.dto.customize.CustomizeReportDTO;
+import com.platform.dao.entity.customize.CustomizeReport;
+import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.service.base.IBaseService;
+import java.util.List;
+
+/**
+ * @Description 自定义报表 service
+ * @Author xc
+ * @Date 2022-04-15 10:26:43
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+public interface CustomizeReportService extends IBaseService<CustomizeReport, CustomizeReportDTO> {
+
+   /**
+    * 批量删除
+    *
+    * @param ids :
+    * @return :
+    */
+    int batchDelete(List<String> ids);
+
+    /**
+     * 分页查询
+     * @param record
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    AbstractPageResultBean<CustomizeReportVO> selectPageList(CustomizeReportDTO record, int pageNum, int pageSize);
+}

+ 48 - 0
platform-service/src/main/java/com/platform/service/customize/impl/CustomizeReportServiceImpl.java

@@ -0,0 +1,48 @@
+package com.platform.service.customize.impl;
+import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.dao.bean.MyPage;
+import com.github.pagehelper.PageHelper;
+import com.platform.dao.vo.query.customize.CustomizeReportVO;
+import com.platform.dao.dto.customize.CustomizeReportDTO;
+import com.platform.dao.entity.customize.CustomizeReport;
+import com.platform.dao.mapper.customize.CustomizeReportMapper;
+import com.platform.service.customize.CustomizeReportService;
+import org.springframework.stereotype.Service;
+import com.platform.service.base.impl.BaseServiceImpl;
+import tk.mybatis.mapper.weekend.Weekend;
+import tk.mybatis.mapper.weekend.WeekendCriteria;
+import lombok.AllArgsConstructor;
+
+import java.util.List;
+
+/**
+ * @Description 自定义报表 service 实现类
+ * @Author xc
+ * @Date 2022-04-15 10:26:43
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@AllArgsConstructor
+@Service("customizeReportService")
+public class CustomizeReportServiceImpl extends BaseServiceImpl<CustomizeReportMapper, CustomizeReport, CustomizeReportDTO> implements CustomizeReportService {
+
+    @Override
+    public int batchDelete(List<String> ids) {
+        Weekend<CustomizeReport> weekend = new Weekend<>(CustomizeReport.class);
+        WeekendCriteria<CustomizeReport, Object> weekendCriteria = weekend.weekendCriteria();
+        weekendCriteria.andIn(CustomizeReport::getId, ids);
+        mapper.deleteByExample(weekend);
+        return 1;
+    }
+
+    @Override
+    public AbstractPageResultBean<CustomizeReportVO> selectPageList(CustomizeReportDTO record, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        return new MyPage(mapper.selectList(record));
+    }
+
+    @Override
+    public AbstractPageResultBean<CustomizeReport> selectPageInfo(CustomizeReportDTO record, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        return new MyPage(mapper.selectList(record));
+    }
+}