|
|
@ -10,9 +10,12 @@ import com.anji.plus.gaea.exception.BusinessException;
|
|
|
|
import com.anji.plus.gaea.utils.GaeaAssert;
|
|
|
|
import com.anji.plus.gaea.utils.GaeaAssert;
|
|
|
|
import com.anji.plus.gaea.utils.GaeaBeanUtils;
|
|
|
|
import com.anji.plus.gaea.utils.GaeaBeanUtils;
|
|
|
|
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
|
|
|
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
|
|
|
|
|
|
|
import com.anjiplus.template.gaea.business.enums.ExportTypeEnum;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.DataSetDto;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.DataSetDto;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.OriginalDataDto;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.dataset.controller.dto.OriginalDataDto;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.dataset.service.DataSetService;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.dataset.service.DataSetService;
|
|
|
|
|
|
|
|
import com.anjiplus.template.gaea.business.modules.file.dao.GaeaFileMapper;
|
|
|
|
|
|
|
|
import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.report.dao.ReportMapper;
|
|
|
|
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.dao.entity.Report;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.reportexcel.controller.dto.ReportExcelDto;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.reportexcel.controller.dto.ReportExcelDto;
|
|
|
@ -20,14 +23,17 @@ import com.anjiplus.template.gaea.business.modules.reportexcel.dao.ReportExcelMa
|
|
|
|
import com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity.ReportExcel;
|
|
|
|
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.service.ReportExcelService;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.reportexcel.util.XlsSheetUtil;
|
|
|
|
import com.anjiplus.template.gaea.business.modules.reportexcel.util.XlsSheetUtil;
|
|
|
|
|
|
|
|
import com.anjiplus.template.gaea.business.modules.reportexcel.util.XlsUtil;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -51,6 +57,15 @@ public class ReportExcelServiceImpl implements ReportExcelService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ReportMapper reportMapper;
|
|
|
|
private ReportMapper reportMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${customer.file.dist-path:''}")
|
|
|
|
|
|
|
|
private String dictPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${customer.file.downloadPath:''}")
|
|
|
|
|
|
|
|
private String fileDownloadPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private GaeaFileMapper gaeaFileMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public GaeaBaseMapper<ReportExcel> getMapper() {
|
|
|
|
public GaeaBaseMapper<ReportExcel> getMapper() {
|
|
|
@ -115,7 +130,33 @@ public class ReportExcelServiceImpl implements ReportExcelService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Boolean exportExcel(ReportExcelDto reportExcelDto) {
|
|
|
|
public Boolean exportExcel(ReportExcelDto reportExcelDto) {
|
|
|
|
|
|
|
|
String reportCode = reportExcelDto.getReportCode();
|
|
|
|
|
|
|
|
String exportType = reportExcelDto.getExportType();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exportType.equals(ExportTypeEnum.GAEA_TEMPLATE_EXCEL)) {
|
|
|
|
|
|
|
|
String jsonStr = analysisReportData(reportExcelDto);
|
|
|
|
|
|
|
|
List<JSONObject> lists=(List<JSONObject> ) JSON.parse(jsonStr);
|
|
|
|
|
|
|
|
OutputStream out = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String fileId = UUID.randomUUID().toString();
|
|
|
|
|
|
|
|
String filePath = dictPath + File.separator + fileId + ".xlsx";
|
|
|
|
|
|
|
|
String urlPath = fileDownloadPath + java.io.File.separator + fileId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GaeaFile gaeaFile = new GaeaFile();
|
|
|
|
|
|
|
|
gaeaFile.setFilePath(filePath);
|
|
|
|
|
|
|
|
gaeaFile.setFileId(fileId);
|
|
|
|
|
|
|
|
gaeaFile.setUrlPath(urlPath);
|
|
|
|
|
|
|
|
gaeaFile.setFileType("xlsx");
|
|
|
|
|
|
|
|
gaeaFile.setFileInstruction(reportCode + ".xlsx");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out = new FileOutputStream(filePath);
|
|
|
|
|
|
|
|
XlsUtil.exportXlsFile(out, true, lists);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gaeaFileMapper.insert(gaeaFile);
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
logger.error("导出失败", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|