diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/GaeaExportController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/GaeaExportController.java new file mode 100644 index 00000000..d5206167 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/GaeaExportController.java @@ -0,0 +1,74 @@ +package com.anjiplus.template.gaea.business.modules.export.controller; + +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.export.controller.dto.GaeaExportDTO; +import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportParam; +import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportQueryParam; +import com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport; +import com.anjiplus.template.gaea.business.modules.export.service.GaeaExportService; +import com.anji.plus.gaea.export.vo.ExportOperation; +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.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.stream.Collectors; + +/** + * 导出中心(GaeaExport)实体类 + * + * @author makejava + * @since 2021-02-07 17:12:31 + */ +@RestController +@RequestMapping("/export") +@Api(value = "/export", tags = "导出中心") +public class GaeaExportController extends GaeaBaseController { + @Autowired + private GaeaExportService gaeaExportService; + + @Override + public GaeaBaseService getService() { + return gaeaExportService; + } + + @Override + public GaeaExport getEntity() { + return new GaeaExport(); + } + + @Override + public GaeaExportDTO getDTO() { + return new GaeaExportDTO(); + } + + @PostMapping("/queryAdvanceExport") + @GaeaAuditLog(pageTitle = "高级查询") + public ResponseBean queryExportInfo(@RequestBody GaeaExportQueryParam param) { + Page exportList=gaeaExportService.getExportListPage(param); + List list = exportList.getRecords().stream() + .map(entity -> GaeaBeanUtils.copyAndFormatter(entity, getDTO())) + .collect(Collectors.toList()); + Page pageDto = new Page<>(); + pageDto.setCurrent(exportList.getCurrent()); + pageDto.setRecords(list); + pageDto.setPages(exportList.getPages()); + pageDto.setTotal(exportList.getTotal()); + pageDto.setSize(exportList.getSize()); + return responseSuccessWithData(pageDto); + } + + @PostMapping("/saveExportLog") + public Boolean export(@RequestBody ExportOperation exportOperation) { + return gaeaExportService.saveExportLog(exportOperation); + } + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/dto/GaeaExportDTO.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/dto/GaeaExportDTO.java new file mode 100644 index 00000000..b608ee91 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/dto/GaeaExportDTO.java @@ -0,0 +1,144 @@ +package com.anjiplus.template.gaea.business.modules.export.controller.dto; + +import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDateTime; +import java.util.Date; + +/** + * 导出中心(GaeaExport)实体类 + * + * @author makejava + * @since 2021-02-07 17:12:25 + */ +@ApiModel(value = "导出中心") +public class GaeaExportDTO extends GaeaBaseDTO { + /** + * 文件在t_file中的id,前端传它来读流接口显示,http://auth/file/download/fileId + */ + @ApiModelProperty(value = "文件在t_file中的id,前端传它来读流接口显示,http://auth/file/download/fileId") + private String fileId; + /** + * 文件标题,比如:对账单报表6月份报表 + */ + @ApiModelProperty(value = "文件标题,比如:对账单报表6月份报表") + private String fileTitle; + /** + * 导出前,查询的数据开始时间 + */ + @ApiModelProperty(value = "导出前,查询的数据开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime resultStartTime; + /** + * 导出前,查询的数据结束时间 + */ + @ApiModelProperty(value = "导出前,查询的数据结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime resultEndTime; + /** + * 导出查询结果,数据总条数 + */ + @ApiModelProperty(value = "导出查询结果,数据总条数") + private Long resultSize; + /** + * 文件导出触发时间 + */ + @ApiModelProperty(value = "文件导出触发时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime fileCreateTime; + /** + * 文件生成完成时间 + */ + @ApiModelProperty(value = "文件生成完成时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime fileFinishTime; + /** + * 文件状态,creating生成中,success生成成功,failed生成失败 + */ + @ApiModelProperty(value = "文件状态,creating生成中,success生成成功,failed生成失败") + private String fileStatus; + /** + * 备注 + */ + @ApiModelProperty(value = "备注") + private String remark; + + public String getFileId() { + return fileId; + } + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getFileTitle() { + return fileTitle; + } + + public void setFileTitle(String fileTitle) { + this.fileTitle = fileTitle; + } + + + + public Long getResultSize() { + return resultSize; + } + + public void setResultSize(Long resultSize) { + this.resultSize = resultSize; + } + + public LocalDateTime getResultStartTime() { + return resultStartTime; + } + + public void setResultStartTime(LocalDateTime resultStartTime) { + this.resultStartTime = resultStartTime; + } + + public LocalDateTime getResultEndTime() { + return resultEndTime; + } + + public void setResultEndTime(LocalDateTime resultEndTime) { + this.resultEndTime = resultEndTime; + } + + public LocalDateTime getFileCreateTime() { + return fileCreateTime; + } + + public void setFileCreateTime(LocalDateTime fileCreateTime) { + this.fileCreateTime = fileCreateTime; + } + + public LocalDateTime getFileFinishTime() { + return fileFinishTime; + } + + public void setFileFinishTime(LocalDateTime fileFinishTime) { + this.fileFinishTime = fileFinishTime; + } + + public String getFileStatus() { + return fileStatus; + } + + public void setFileStatus(String fileStatus) { + this.fileStatus = fileStatus; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportParam.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportParam.java new file mode 100644 index 00000000..bafb04ec --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportParam.java @@ -0,0 +1,26 @@ +package com.anjiplus.template.gaea.business.modules.export.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.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 导出中心(GaeaExport)param + * + * @author makejava + * @since 2021-02-07 17:12:26 + */ +@Getter +@Setter +public class GaeaExportParam extends PageParam implements Serializable { + /** + * 文件标题 + */ + @Query(QueryEnum.LIKE) + private String fileTitle; +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportQueryParam.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportQueryParam.java new file mode 100644 index 00000000..dd5eb2ee --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/controller/param/GaeaExportQueryParam.java @@ -0,0 +1,23 @@ +package com.anjiplus.template.gaea.business.modules.export.controller.param; + +import com.anjiplus.template.gaea.common.dto.BaseQueryBO; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 功能描述: + * + * @Author: peiyanni + * @Date: 2021/2/20 12:49 + */ +@Setter +@Getter +public class GaeaExportQueryParam extends BaseQueryBO implements Serializable{ + + /** + * 文件标题 + */ + private String fileTitle; +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/GaeaExportMapper.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/GaeaExportMapper.java new file mode 100644 index 00000000..df67e390 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/GaeaExportMapper.java @@ -0,0 +1,30 @@ +package com.anjiplus.template.gaea.business.modules.export.dao; + +import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportQueryParam; +import com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 导出中心(GaeaExport)Mapper + * + * @author makejava + * @since 2021-02-07 17:12:16 + */ +@Mapper +public interface GaeaExportMapper extends GaeaBaseMapper { + /** + * 导出信息的高级查询 + * @param page + * @param bo + * @param wrapper + * @return + */ + List queryExportInfo(Page page, @Param("bo") GaeaExportQueryParam bo, @Param(Constants.WRAPPER) QueryWrapper wrapper); +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/entity/GaeaExport.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/entity/GaeaExport.java new file mode 100644 index 00000000..632153fd --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/dao/entity/GaeaExport.java @@ -0,0 +1,126 @@ +package com.anjiplus.template.gaea.business.modules.export.dao.entity; + +import com.anji.plus.gaea.annotation.Formatter; +import com.baomidou.mybatisplus.annotation.TableName; +import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 导出中心(GaeaExport)实体类 + * + * @author peiyanni + * @since 2021-02-07 17:12:14 + */ +@TableName("gaea_export") +public class GaeaExport extends GaeaBaseEntity implements Serializable { + /** + * 文件在t_file中的id,前端传它来读流接口显示,http://auth/file/download/fileId + */ + private String fileId; + /** + * 文件标题,比如:对账单报表6月份报表 + */ + private String fileTitle; + /** + * 导出前,查询的数据开始时间 + */ + private LocalDateTime resultStartTime; + /** + * 导出前,查询的数据结束时间 + */ + private LocalDateTime resultEndTime; + /** + * 导出查询结果,数据总条数 + */ + private Long resultSize; + /** 文件导出触发时间 */ + private LocalDateTime fileCreateTime; + + /** 文件生成完成时间 */ + private LocalDateTime fileFinishTime; + /** + * 文件状态,creating生成中,success生成成功,failed生成失败 + */ + @Formatter(dictCode="FILE_STATUS",targetField = "fileStatus") + private String fileStatus; + /** + * 备注 + */ + private String remark; + + public String getFileId() { + return fileId; + } + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getFileTitle() { + return fileTitle; + } + + public void setFileTitle(String fileTitle) { + this.fileTitle = fileTitle; + } + + public LocalDateTime getResultStartTime() { + return resultStartTime; + } + + public LocalDateTime getResultEndTime() { + return resultEndTime; + } + + public LocalDateTime getFileFinishTime() { + return fileFinishTime; + } + + public void setFileFinishTime(LocalDateTime fileFinishTime) { + this.fileFinishTime = fileFinishTime; + } + + public Long getResultSize() { + return resultSize; + } + + public void setResultSize(Long resultSize) { + this.resultSize = resultSize; + } + + public void setResultStartTime(LocalDateTime resultStartTime) { + this.resultStartTime = resultStartTime; + } + + public void setResultEndTime(LocalDateTime resultEndTime) { + this.resultEndTime = resultEndTime; + } + + public LocalDateTime getFileCreateTime() { + return fileCreateTime; + } + + public void setFileCreateTime(LocalDateTime fileCreateTime) { + this.fileCreateTime = fileCreateTime; + } + + public String getFileStatus() { + return fileStatus; + } + + public void setFileStatus(String fileStatus) { + this.fileStatus = fileStatus; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/GaeaExportService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/GaeaExportService.java new file mode 100644 index 00000000..7d02207e --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/GaeaExportService.java @@ -0,0 +1,32 @@ +package com.anjiplus.template.gaea.business.modules.export.service; + +import com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport; +import com.anji.plus.gaea.export.vo.ExportOperation; +import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportParam; +import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportQueryParam; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.anji.plus.gaea.curd.service.GaeaBaseService; + +/** + * 导出中心(GaeaExport)Service + * + * @author peiyanni + * @since 2021-02-07 17:12:22 + */ +public interface GaeaExportService extends GaeaBaseService { + /** + * 导出中心-高级查询 + * 需要 QueryWrapper 类型的动态参数,用来进行获取组装好的QueryWrapper对象 + * @param queryParam + * @return + */ + Page getExportListPage(GaeaExportQueryParam queryParam, QueryWrapper ...qe); + + /** + * 导出操作,保存导出日志信息到表Gaea_export + * @param exportOperation + * @return + */ + Boolean saveExportLog(ExportOperation exportOperation); +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/impl/GaeaExportServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/impl/GaeaExportServiceImpl.java new file mode 100644 index 00000000..e3fb8e92 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/export/service/impl/GaeaExportServiceImpl.java @@ -0,0 +1,73 @@ +package com.anjiplus.template.gaea.business.modules.export.service.impl; + +import com.anjiplus.template.gaea.business.modules.export.dao.GaeaExportMapper; +import com.anjiplus.template.gaea.business.modules.export.dao.entity.GaeaExport; +import com.anjiplus.template.gaea.business.modules.export.service.GaeaExportService; +import com.anjiplus.template.gaea.business.modules.file.dao.GaeaFileMapper; +import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile; +import com.anji.plus.gaea.export.vo.ExportOperation; +import com.anjiplus.template.gaea.business.modules.export.controller.param.GaeaExportQueryParam; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.anjiplus.template.gaea.common.aop.GaeaQuery; +import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +/** + * 导出中心(GaeaExport)ServiceImpl + * + * @author makejava + * @since 2021-02-07 17:12:24 + */ +@Service +public class GaeaExportServiceImpl implements GaeaExportService { + @Autowired + private GaeaExportMapper gaeaExportMapper; + @Autowired + private GaeaFileMapper gaeaFileMapper; + + @Override + public GaeaBaseMapper getMapper() { + return gaeaExportMapper; + } + + + @Override + @GaeaQuery + public Page getExportListPage(GaeaExportQueryParam queryParam, QueryWrapper... qe) { + Page page = new Page<>(queryParam.getPageNumber(), queryParam.getPageSize()); + QueryWrapper queryWrapper = (null != qe && qe.length > 0) ? qe[0] : null; + List gaeaExports = gaeaExportMapper.queryExportInfo(page, queryParam, queryWrapper); + page.setRecords(gaeaExports); + return page; + } + + @Override + @Transactional + public Boolean saveExportLog(ExportOperation exportOperation) { + //需要保存两张表数据 gaea_file ,gaea_export数据 + Date nowDate = new Date(); + GaeaFile gaeaFile = new GaeaFile(); + gaeaFile.setFileId(exportOperation.getFileId()); + gaeaFile.setFilePath(exportOperation.getFilePath()); + gaeaFile.setCreateBy(exportOperation.getCreaterUsername()); + gaeaFile.setCreateTime(nowDate); + gaeaFile.setUpdateBy(exportOperation.getCreaterUsername()); + gaeaFile.setUpdateTime(nowDate); + gaeaFileMapper.insert(gaeaFile); + GaeaExport export = new GaeaExport(); + BeanUtils.copyProperties(exportOperation, export); + export.setCreateBy(exportOperation.getCreaterUsername()); + export.setCreateTime(nowDate); + export.setUpdateBy(exportOperation.getCreaterUsername()); + export.setUpdateTime(nowDate); + gaeaExportMapper.insert(export); + return true; + } +}