Raod 3 years ago
parent 4fda028a29
commit d05efd4082

@ -38,23 +38,6 @@
<artifactId>spring-cloud-context</artifactId>
</dependency>
<!--模板引擎-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.anjiplus.template.gaea</groupId>-->
<!-- <artifactId>template-gaea-generator</artifactId>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
@ -98,31 +81,16 @@
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.22</version>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<!--kudu impala驱动-->
<dependency>
<groupId>owinfo</groupId>
<artifactId>impalajdbc41</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/ImpalaJDBC41.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>1.2.1</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
</exclusion>
</exclusions>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency>
</dependencies>

@ -5,11 +5,6 @@ import com.anjiplus.template.gaea.business.modules.report.controller.dto.ReportD
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.anjiplus.template.gaea.business.modules.reportexcel.dao.ReportExcelMapper;
import com.anjiplus.template.gaea.business.modules.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;
@ -22,13 +17,9 @@ import org.springframework.stereotype.Service;
@Service
public class ReportServiceImpl implements ReportService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private ReportMapper reportMapper;
@Autowired
private ReportExcelMapper reportExcelMapper;
@Override
public GaeaBaseMapper<Report> getMapper() {
return reportMapper;
@ -38,8 +29,5 @@ public class ReportServiceImpl implements ReportService {
@Override
public void delReport(ReportDto reportDto) {
deleteById(reportDto.getId());
QueryWrapper<ReportExcel> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("report_code" , reportDto.getReportCode());
reportExcelMapper.delete(queryWrapper);
}
}

@ -1,97 +0,0 @@
package com.anjiplus.template.gaea.business.modules.reportexcel.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.code.ResponseCode;
import com.anji.plus.gaea.curd.controller.GaeaBaseController;
import com.anji.plus.gaea.curd.service.GaeaBaseService;
import com.anjiplus.template.gaea.business.modules.reportexcel.controller.dto.ReportExcelDto;
import com.anjiplus.template.gaea.business.modules.reportexcel.controller.param.ReportExcelParam;
import com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity.ReportExcel;
import com.anjiplus.template.gaea.business.modules.reportexcel.service.ReportExcelService;
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;
/**
* @author chenkening
* @date 2021/4/13 15:12
*/
@RestController
@Api(tags = "报表表格管理")
@RequestMapping("/reportExcel")
public class ReportExcelController extends GaeaBaseController<ReportExcelParam, ReportExcel, ReportExcelDto> {
@Autowired
private ReportExcelService reportExcelService;
@Override
public GaeaBaseService<ReportExcelParam, ReportExcel> getService() {
return reportExcelService;
}
@Override
public ReportExcel getEntity() {
return new ReportExcel();
}
@Override
public ReportExcelDto getDTO() {
return new ReportExcelDto();
}
@GetMapping("/detailByReportCode/{reportCode}")
@Permission(
code = "DETAIL",
name = "详情"
)
@GaeaAuditLog(
pageTitle = "详情"
)
public ResponseBean detailByReportCode(@PathVariable String reportCode) {
ReportExcelDto reportExcelDto = reportExcelService.detailByReportCode(reportCode);
return ResponseBean.builder().data(reportExcelDto).build();
}
@PostMapping("/preview")
@Permission(
code = "DETAIL",
name = "预览"
)
@GaeaAuditLog(
pageTitle = "预览"
)
public ResponseBean preview(@RequestBody ReportExcelDto reportExcelDto) {
ReportExcelDto result = reportExcelService.preview(reportExcelDto);
return ResponseBean.builder().data(result).build();
}
@PostMapping("/exportExcel")
@Permission(
code = "IMPORT",
name = "导出"
)
@GaeaAuditLog(
pageTitle = "报表导出"
)
public ResponseBean exportExcel(@RequestBody ReportExcelDto reportExcelDto) {
return ResponseBean.builder().code(ResponseCode.SUCCESS_CODE)
.data(reportExcelService.exportExcel(reportExcelDto))
.message("导出成功,请稍后在下载中心查看").build();
}
// @PostMapping("/exportPdf")
// public ResponseBean exportPdf(@RequestBody ReportExcelDto reportExcelDto) {
// reportExcelService.exportPdf(reportExcelDto);
// return ResponseBean.builder().code(ResponseCode.SUCCESS_CODE)
// .build();
// }
}

@ -1,43 +0,0 @@
package com.anjiplus.template.gaea.business.modules.reportexcel.controller.dto;
import com.anji.plus.gaea.curd.dto.GaeaBaseDTO;
import lombok.Data;
import java.io.Serializable;
/**
* @author chenkening
* @date 2021/4/13 15:12
*/
@Data
public class ReportExcelDto extends GaeaBaseDTO implements Serializable {
/** 报表名称 */
private String reportName;
/** 报表编码 */
private String reportCode;
/**数据集编码,以|分割*/
private String setCodes;
/** 分组 */
private String reportGroup;
/** 数据集查询参数 */
private String setParam;
/** 报表json字符串 */
private String jsonStr;
/** 报表类型 */
private String reportType;
/** 数据总计 */
private long total;
/**导出类型*/
private String exportType;
}

@ -1,18 +0,0 @@
package com.anjiplus.template.gaea.business.modules.reportexcel.controller.param;
import com.anji.plus.gaea.curd.params.PageParam;
import lombok.Data;
import java.io.Serializable;
/**
* @author chenkening
* @date 2021/4/13 15:12
*/
@Data
public class ReportExcelParam extends PageParam implements Serializable{
}

@ -1,11 +0,0 @@
package com.anjiplus.template.gaea.business.modules.reportexcel.dao;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity.ReportExcel;
/**
* @author chenkening
* @date 2021/4/13 15:11
*/
public interface ReportExcelMapper extends GaeaBaseMapper<ReportExcel> {
}

@ -1,33 +0,0 @@
package com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity;
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author chenkening
* @date 2021/4/13 15:11
*/
@TableName(value="gaea_report_excel")
@Data
public class ReportExcel extends GaeaBaseEntity {
@ApiModelProperty(value = "报表编码")
private String reportCode;
@ApiModelProperty(value = "数据集编码,以|分割")
private String setCodes;
@ApiModelProperty(value = "数据集查询参数")
private String setParam;
@ApiModelProperty(value = "报表json字符串")
private String jsonStr;
@ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG")
private Integer enableFlag;
@ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG")
private Integer deleteFlag;
}

@ -1,39 +0,0 @@
package com.anjiplus.template.gaea.business.modules.reportexcel.service;
import com.anji.plus.gaea.curd.service.GaeaBaseService;
import com.anjiplus.template.gaea.business.modules.reportexcel.controller.dto.ReportExcelDto;
import com.anjiplus.template.gaea.business.modules.reportexcel.controller.param.ReportExcelParam;
import com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity.ReportExcel;
/**
* TODO
*
* @author chenkening
* @date 2021/4/13 15:14
*/
public interface ReportExcelService extends GaeaBaseService<ReportExcelParam, ReportExcel> {
/**
*
* @param reportCode
* @return
*/
ReportExcelDto detailByReportCode(String reportCode);
/**
*
* @param reportExcelDto
* @return
*/
ReportExcelDto preview(ReportExcelDto reportExcelDto);
/**
* excel
* @param reportExcelDto
* @return
*/
Boolean exportExcel(ReportExcelDto reportExcelDto);
// Boolean exportPdf(ReportExcelDto reportExcelDto);
}

@ -1,146 +0,0 @@
package com.anjiplus.template.gaea.business.modules.reportexcel.service.impl;
import com.alibaba.fastjson.JSONObject;
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.export.enums.ExportTypeEnum;
import com.anji.plus.gaea.export.utils.ExportUtil;
import com.anji.plus.gaea.export.vo.ExportOperation;
import com.anji.plus.gaea.holder.UserContentHolder;
import com.anji.plus.gaea.utils.GaeaAssert;
import com.anji.plus.gaea.utils.GaeaBeanUtils;
import com.anjiplus.template.gaea.business.code.ResponseCode;
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.reportexcel.controller.dto.ReportExcelDto;
import com.anjiplus.template.gaea.business.modules.reportexcel.dao.ReportExcelMapper;
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.ReportUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
/**
* TODO
*
* @author chenkening
* @date 2021/4/13 15:14
*/
@Service
public class ReportExcelServiceImpl implements ReportExcelService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private ReportExcelMapper reportExcelMapper;
@Autowired
private ThreadPoolTaskExecutor threadPoolExportExecutor;
@Autowired
private ReportMapper reportMapper;
@Value("${file.dist-path:''}")
private String dictPath;
@Autowired
private ReportUtil reportUtil;
@Override
public GaeaBaseMapper<ReportExcel> getMapper() {
return reportExcelMapper;
}
@Override
public ReportExcelDto detailByReportCode(String reportCode) {
QueryWrapper<ReportExcel> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("report_code" , reportCode);
ReportExcel reportExcel = reportExcelMapper.selectOne(queryWrapper);
if(reportExcel != null){
ReportExcelDto dto = new ReportExcelDto();
BeanUtils.copyProperties(reportExcel , dto);
return dto;
}
return null;
}
/**
*
*
* @param entity
* @param operationEnum
* @throws BusinessException
*/
@Override
public void processBeforeOperation(ReportExcel entity, BaseOperationEnum operationEnum) throws BusinessException {
if (operationEnum.equals(BaseOperationEnum.INSERT)) {
String reportCode = entity.getReportCode();
ReportExcel report = this.selectOne("report_code", reportCode);
if (null != report) {
this.deleteById(report.getId());
}
}
}
/**
*
*/
@Override
public ReportExcelDto preview(ReportExcelDto reportExcelDto) {
// 根据id查询 报表详情
ReportExcel reportExcel = selectOne("report_code", reportExcelDto.getReportCode());
QueryWrapper<Report> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("report_code" , reportExcelDto.getReportCode());
Report report = reportMapper.selectOne(queryWrapper);
GaeaAssert.notNull(reportExcel, ResponseCode.RULE_CONTENT_NOT_EXIST, "reportExcel");
String setParam = reportExcelDto.getSetParam();
GaeaBeanUtils.copyAndFormatter(reportExcel , reportExcelDto);
if(StringUtils.isNotBlank(setParam)){
reportExcelDto.setSetParam(setParam);
}
reportExcelDto.setReportName(report.getReportName());
JSONObject jsonObject = reportUtil.reportParse(reportExcelDto);
reportExcelDto.setJsonStr(JSONObject.toJSONString(jsonObject));
reportExcelDto.setTotal(jsonObject.getJSONObject("rows").size());
return reportExcelDto;
}
@Override
public Boolean exportExcel(ReportExcelDto reportExcelDto) {
ExportOperation exportOperation = new ExportOperation();
//指明导出数据查询到结果开始时间
exportOperation.setResultStartTime(LocalDateTime.now());
ReportExcelDto result = preview(reportExcelDto);
//指明导出数据查询到结果结束时间
exportOperation.setResultEndTime(LocalDateTime.now());
//指明导出数据查询到结果条数
exportOperation.setResultSize(result.getTotal());
//指明采用什么模式导出
exportOperation.setExportType(StringUtils.isBlank(reportExcelDto.getExportType())
? ExportTypeEnum.GAEA_TEMPLATE_EXCEL.getCodeValue() : reportExcelDto.getExportType());
//设置导出的文件名
exportOperation.setFileTitle(result.getReportName());
//设置导出的文件存放目录
exportOperation.setFilePath(dictPath);
//设置导出的数据jsonStr
exportOperation.setJsonStr(result.getJsonStr());
//保存当前操作人
exportOperation.setCreaterUsername(UserContentHolder.getContext().getUsername());
//调用盖亚组件实现导出文件
threadPoolExportExecutor.execute(() -> {
ExportUtil.getInstance().exportByFilePathSimple(exportOperation, null);
});
return true;
}
}

@ -1,22 +0,0 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.anjiplus.template.gaea.business.modules.reportexcel.dao.ReportExcelMapper">
<resultMap type="com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity.ReportExcel" id="ReportMap">
<!--jdbcType="{column.columnType}"-->
<result property="id" column="id" />
<result property="reportCode" column="report_code" />
<result property="setCods" column="set_codes" />
<result property="setParam" column="set_param" />
<result property="jsonStr" column="json_str" />
<result property="enableFlag" column="enable_flag" />
<result property="deleteFlag" column="delete_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="version" column="version" />
</resultMap>
</mapper>

@ -4,6 +4,6 @@ const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
// BASE_API: '"http://127.0.0.1:9095"'
BASE_API: '"http://10.108.26.197:9095"'
BASE_API: '"http://127.0.0.1:9095"'
// BASE_API: '"http://10.108.26.197:9095"'
})

Loading…
Cancel
Save