Commit 07dd1550 authored by kevin's avatar kevin

#

parent 85955a2c
...@@ -8,7 +8,6 @@ import com.google.common.collect.Lists; ...@@ -8,7 +8,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFCell;
...@@ -20,8 +19,6 @@ import org.springframework.beans.BeanUtils; ...@@ -20,8 +19,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import pwc.taxtech.atms.common.CommonUtils; import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil; import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.message.ErrorMessage; import pwc.taxtech.atms.common.message.ErrorMessage;
...@@ -345,17 +342,15 @@ public class ReportServiceImpl extends BaseService { ...@@ -345,17 +342,15 @@ public class ReportServiceImpl extends BaseService {
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate). andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).
andStatusEqualTo(0); andStatusEqualTo(0);
List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample); List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample);
//先清除数据
InvoiceRecord delRecord = new InvoiceRecord();
delRecord.setRevenueCofId(null);
if (!isMergeManualData) {
delRecord.setModifyRevenueCofId(null);
}
InvoiceRecordExample delExample = new InvoiceRecordExample(); InvoiceRecordExample delExample = new InvoiceRecordExample();
delExample.createCriteria().andProjectIdEqualTo(projectId) delExample.createCriteria().andProjectIdEqualTo(projectId).
.andProjectIdEqualTo(projectId).
andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", ""))); andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", "")));
invoiceRecordMapper.deleteByExample(delExample); if (isMergeManualData) {
invoiceRecordMapper.clearRevenueCof(true, false, delExample);
} else {
invoiceRecordMapper.clearRevenueCof(true, true, delExample);
}
Map<String, Long> map = new HashMap<>(); Map<String, Long> map = new HashMap<>();
for (RevenueTypeMapping mapping : mappingList) { for (RevenueTypeMapping mapping : mappingList) {
if (!map.containsKey(mapping.getContent())) { if (!map.containsKey(mapping.getContent())) {
...@@ -475,12 +470,14 @@ public class ReportServiceImpl extends BaseService { ...@@ -475,12 +470,14 @@ public class ReportServiceImpl extends BaseService {
for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) { for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) {
Row row = sheet.getRow(r); Row row = sheet.getRow(r);
for (int c = row.getFirstCellNum(); c <= row.getLastCellNum(); c++) { for (int c = row.getFirstCellNum(); c <= row.getLastCellNum(); c++) {
Cell cell = row.getCell(c); Cell cell = row.getCell(c);
if (cell == null) { if (cell == null) {
continue;//todo cell == null 如何处理 continue;//todo cell == null 如何处理
} }
if (r <= addRowIndex + 1) { if (r <= addRowIndex + 1) {
if(r == addRowIndex + 1 && c>TaxesCalculateReportEnum.Column.Column_14.getIndex()){
assembleOriginalTemplateData(template,projectId,period,r,c,addRowIndex,cellTemplateList,cellTemplateConfigList);
}else{
String cellId = projectId + template.getId() + period + r + c; String cellId = projectId + template.getId() + period + r + c;
if ((r - 1) >= 0 && (r - 1) < configIds.size()) { if ((r - 1) >= 0 && (r - 1) < configIds.size()) {
cellId += configIds.get(configIds.size() - r); cellId += configIds.get(configIds.size() - r);
...@@ -542,7 +539,26 @@ public class ReportServiceImpl extends BaseService { ...@@ -542,7 +539,26 @@ public class ReportServiceImpl extends BaseService {
if (r > 0 && r <= addRowIndex && hasHandDatas.contains(c)) { if (r > 0 && r <= addRowIndex && hasHandDatas.contains(c)) {
addManualConfig(cellTemplate, cell, now, cellTemplateConfigList); addManualConfig(cellTemplate, cell, now, cellTemplateConfigList);
} }
}
} else { } else {
assembleOriginalTemplateData(template,projectId,period,r,c,addRowIndex,cellTemplateList,cellTemplateConfigList);
}
}
}
List<List<PeriodCellTemplate>> tmpList = CommonUtils.subListWithLen(cellTemplateList, CommonUtils.BATCH_NUM);
// tmpList.forEach(list -> cellTemplateMapper.batchInsert2(list));
tmpList.forEach(list -> periodCellTemplateMapper.batchInsert(list));//todo 批量插入优化
List<List<PeriodCellTemplateConfig>> tmpConfigList = CommonUtils.subListWithLen(cellTemplateConfigList, CommonUtils.BATCH_NUM);
tmpConfigList.forEach(list -> periodCellTemplateConfigMapper.batchInsert(list));
} catch (Exception e) {
logger.error("importTemplateExcelFile error.", e);
throw new ServiceException(ErrorMessage.SystemError);
}
}
public void assembleOriginalTemplateData(Template template, String projectId, Integer period,
Integer r, Integer c, Integer addRowIndex,
List<PeriodCellTemplate> cellTemplateList, List<PeriodCellTemplateConfig> cellTemplateConfigList) {
//查询原来行cell是否有CellTemplate //查询原来行cell是否有CellTemplate
CellTemplateExample cellTemplateExample = new CellTemplateExample(); CellTemplateExample cellTemplateExample = new CellTemplateExample();
cellTemplateExample.createCriteria().andReportTemplateIdEqualTo(template.getId()).andRowIndexEqualTo(r - addRowIndex).andColumnIndexEqualTo(c); cellTemplateExample.createCriteria().andReportTemplateIdEqualTo(template.getId()).andRowIndexEqualTo(r - addRowIndex).andColumnIndexEqualTo(c);
...@@ -610,18 +626,6 @@ public class ReportServiceImpl extends BaseService { ...@@ -610,18 +626,6 @@ public class ReportServiceImpl extends BaseService {
} }
} }
} }
}
}
List<List<PeriodCellTemplate>> tmpList = CommonUtils.subListWithLen(cellTemplateList, CommonUtils.BATCH_NUM);
// tmpList.forEach(list -> cellTemplateMapper.batchInsert2(list));
tmpList.forEach(list -> periodCellTemplateMapper.batchInsert(list));//todo 批量插入优化
List<List<PeriodCellTemplateConfig>> tmpConfigList = CommonUtils.subListWithLen(cellTemplateConfigList, CommonUtils.BATCH_NUM);
tmpConfigList.forEach(list -> periodCellTemplateConfigMapper.batchInsert(list));
} catch (Exception e) {
logger.error("importTemplateExcelFile error.", e);
throw new ServiceException(ErrorMessage.SystemError);
}
}
private void addManualConfig(PeriodCellTemplate cellTemplate, Cell cell, Date now, List<PeriodCellTemplateConfig> list) { private void addManualConfig(PeriodCellTemplate cellTemplate, Cell cell, Date now, List<PeriodCellTemplateConfig> list) {
PeriodCellTemplateConfig configManual = new PeriodCellTemplateConfig(); PeriodCellTemplateConfig configManual = new PeriodCellTemplateConfig();
...@@ -1230,6 +1234,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -1230,6 +1234,7 @@ public class ReportServiceImpl extends BaseService {
} }
private static final Integer specialConsideration = 0;//特殊因素考虑 private static final Integer specialConsideration = 0;//特殊因素考虑
private static final String ebitRate = "1%";//ebit 比率
public List<CellTemplateReferenceDto> getTemplateReferences(int period) { public List<CellTemplateReferenceDto> getTemplateReferences(int period) {
return new ArrayList<>(); return new ArrayList<>();
...@@ -1244,7 +1249,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -1244,7 +1249,7 @@ public class ReportServiceImpl extends BaseService {
OperationResultDto<ReportDataDto> cellData = getCellData(reportId, getProjId(orgId, period)); OperationResultDto<ReportDataDto> cellData = getCellData(reportId, getProjId(orgId, period));
ReportDataDto reportDataDto = new ReportDataDto(); ReportDataDto reportDataDto = new ReportDataDto();
//特殊因素考虑 默认为0 rate 默认为1% //特殊因素考虑 默认为0 rate 默认为1%
EbitDataDto ebitDataDto1 = loadEbitData(orgId, period, specialConsideration, Constant.ebitRate); EbitDataDto ebitDataDto1 = loadEbitData(orgId, period, specialConsideration, ebitRate);
if (cellData.getData() != null) { if (cellData.getData() != null) {
cellData.getData().setEbitData(ebitDataDto1); cellData.getData().setEbitData(ebitDataDto1);
} else { } else {
...@@ -1254,7 +1259,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -1254,7 +1259,7 @@ public class ReportServiceImpl extends BaseService {
return cellData; return cellData;
} }
} else if (operationResultDto1.getData().getEbitData() == null && operationResultDto1.getData().getCellData() != null) { } else if (operationResultDto1.getData().getEbitData() == null && operationResultDto1.getData().getCellData() != null) {
EbitDataDto ebitDataDto1 = loadEbitData(orgId, period, specialConsideration, Constant.ebitRate); EbitDataDto ebitDataDto1 = loadEbitData(orgId, period, specialConsideration, ebitRate);
operationResultDto1.getData().setEbitData(ebitDataDto1); operationResultDto1.getData().setEbitData(ebitDataDto1);
} else { } else {
OperationResultDto<ReportDataDto> cellData = getCellData(reportId, getProjId(orgId, period)); OperationResultDto<ReportDataDto> cellData = getCellData(reportId, getProjId(orgId, period));
...@@ -1295,7 +1300,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -1295,7 +1300,7 @@ public class ReportServiceImpl extends BaseService {
case 40: case 40:
if (ebitCellData1.getData() == null) if (ebitCellData1.getData() == null)
break; break;
ebitDataDto.setEbitRate(ebitCellData1.getData()); ebitDataDto.setEbitRate(Double.parseDouble(ebitCellData1.getData()));
break; break;
case 41: case 41:
if (ebitCellData1.getData() == null) if (ebitCellData1.getData() == null)
...@@ -1305,7 +1310,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -1305,7 +1310,7 @@ public class ReportServiceImpl extends BaseService {
case 42: case 42:
if (ebitCellData1.getData() == null) if (ebitCellData1.getData() == null)
break; break;
ebitDataDto.setSixAddTax(new BigDecimal(ebitCellData1.getData())); ebitDataDto.setSixAddTax(ebitCellData1.getData());
break; break;
case 43: case 43:
if (ebitCellData1.getData() == null) if (ebitCellData1.getData() == null)
...@@ -1558,11 +1563,10 @@ public class ReportServiceImpl extends BaseService { ...@@ -1558,11 +1563,10 @@ public class ReportServiceImpl extends BaseService {
@Resource @Resource
private EbitCellDataMapper ebitCellDataMapper; private EbitCellDataMapper ebitCellDataMapper;
//加载Ebit数据 //加载Ebit数据
public EbitDataDto loadEbitData(String orgId, Integer period, Integer specialConsiderations, String ebitRate) { public EbitDataDto loadEbitData(String orgId, Integer period, Integer specialConsiderations, String ebitRate) {
double rate = 0.1;
BigDecimal spec = new BigDecimal(0); BigDecimal spec = new BigDecimal(0);
double rate = 0.01; //ebitRate
if (!ebitRate.isEmpty()) { if (!ebitRate.isEmpty()) {
int _index = ebitRate.indexOf("%"); int _index = ebitRate.indexOf("%");
spec = new BigDecimal(specialConsiderations); spec = new BigDecimal(specialConsiderations);
...@@ -1586,12 +1590,12 @@ public class ReportServiceImpl extends BaseService { ...@@ -1586,12 +1590,12 @@ public class ReportServiceImpl extends BaseService {
BigDecimal yffy = new BigDecimal(0);//研发费用 BigDecimal yffy = new BigDecimal(0);//研发费用
BigDecimal zcjzss = new BigDecimal(0); //资产减值损失 BigDecimal zcjzss = new BigDecimal(0); //资产减值损失
for (ProfitLossStatement profitLossStatement : profitLossStatements) { for (ProfitLossStatement profitLossStatement : profitLossStatements) {
BigDecimal value = profitLossStatement.getYtdAmt(); BigDecimal value = profitLossStatement.getPeriodAmt();
switch (profitLossStatement.getItemName()) { switch (profitLossStatement.getItemName()) {
case "一、营业收入": case "加:营业外收入":
yysr = value; yysr = value;
break; break;
case "减:营业成本": case "减:营业外支出":
yycb = value; yycb = value;
case "营业税金及附加": case "营业税金及附加":
yysjfj = value; yysjfj = value;
...@@ -1607,14 +1611,26 @@ public class ReportServiceImpl extends BaseService { ...@@ -1607,14 +1611,26 @@ public class ReportServiceImpl extends BaseService {
zcjzss = value; zcjzss = value;
} }
EbitDataDto ebitDataDto = new EbitDataDto(); EbitDataDto ebitDataDto = new EbitDataDto();
BigDecimal subtract = yysr.subtract(yycb).add(yysjfj).add(xsfy).add(glfy).add(yffy).add(zcjzss); BigDecimal subtract = yysr.subtract(yycb).subtract(yysjfj).subtract(xsfy).subtract(glfy).subtract(yffy).subtract(zcjzss);
ebitDataDto.setEbitSubtraction(subtract); ebitDataDto.setEbitSubtraction(subtract);
ebitDataDto.setSpecialFactors(subtract.add(spec)); ebitDataDto.setSpecialFactors(subtract.add(spec));
ebitDataDto.setEbitRate(String.valueOf(rate*100 + "%")); ebitDataDto.setEbitRate(rate);
ebitDataDto.setTransactionAmount(ebitDataDto.getSpecialFactors().multiply(new BigDecimal(ebitDataDto.getEbitRate()))); ebitDataDto.setTransactionAmount(ebitDataDto.getSpecialFactors().multiply(new BigDecimal(ebitDataDto.getEbitRate())));
ebitDataDto.setEbitRate(ebitRate); ebitDataDto.setTransactionAmount(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.06)));
ebitDataDto.setSixAddTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.06)));
ebitDataDto.setTotalAmountTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.16))); ebitDataDto.setTotalAmountTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.16)));
/*//保存
for (int i = 37; i <= 43; i++) {
EbitCellData ebitCellData = new EbitCellData();
ebitCellData.setData(arr[i - 37]);
ebitCellData.setRow(i);
ebitCellData.setCol(3);
ebitCellData.setCreateTime(now);
ebitCellData.setOrganizationId(orgId);
ebitCellData.setPeriod(period);
ebitCellDataMapper.insert(ebitCellData);
}*/
return ebitDataDto; return ebitDataDto;
} }
return null; return null;
...@@ -2315,7 +2331,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -2315,7 +2331,7 @@ public class ReportServiceImpl extends BaseService {
ebitCellData1.setData(operationResultDto.getData().getEbitData().getTransactionAmount().toString()); ebitCellData1.setData(operationResultDto.getData().getEbitData().getTransactionAmount().toString());
ebitCellData1.setRow(i); ebitCellData1.setRow(i);
case 42: case 42:
ebitCellData1.setData(operationResultDto.getData().getEbitData().getSixAddTax().toString()); ebitCellData1.setData(operationResultDto.getData().getEbitData().getSixAddTax());
ebitCellData1.setRow(i); ebitCellData1.setRow(i);
case 43: case 43:
ebitCellData1.setData(operationResultDto.getData().getEbitData().getTotalAmountTax().toString()); ebitCellData1.setData(operationResultDto.getData().getEbitData().getTotalAmountTax().toString());
...@@ -2332,9 +2348,8 @@ public class ReportServiceImpl extends BaseService { ...@@ -2332,9 +2348,8 @@ public class ReportServiceImpl extends BaseService {
@Resource @Resource
private EbitSpreadDataMapper ebitSpreadDataMapper; private EbitSpreadDataMapper ebitSpreadDataMapper;
@Transactional public OperationResultDto spreadToDb(RequestParameterDto.EbitParam ebitParam) {
public synchronized OperationResultDto spreadToDb(HttpServletRequest request, Integer period, String orgId) { try {
/* try {
EbitSpreadDataExample example = new EbitSpreadDataExample(); EbitSpreadDataExample example = new EbitSpreadDataExample();
EbitSpreadDataExample.Criteria criteria = example.createCriteria(); EbitSpreadDataExample.Criteria criteria = example.createCriteria();
EbitSpreadDataExample.Criteria criteria1 = criteria.andOrganizationIdEqualTo(ebitParam.getOrgId()).andPeriodEqualTo(ebitParam.getPeriod()); EbitSpreadDataExample.Criteria criteria1 = criteria.andOrganizationIdEqualTo(ebitParam.getOrgId()).andPeriodEqualTo(ebitParam.getPeriod());
...@@ -2359,29 +2374,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -2359,29 +2374,7 @@ public class ReportServiceImpl extends BaseService {
operationResultDto.error(); operationResultDto.error();
operationResultDto.setResultMsg("spread【json序列化字符串】保存失败"); operationResultDto.setResultMsg("spread【json序列化字符串】保存失败");
return operationResultDto; return operationResultDto;
}*/
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String,MultipartFile> fileMap = multipartRequest.getFileMap();
MultipartFile file = fileMap.get("llb.xlsx");
String fileName = orgId + period + "利润表";
EbitSpreadDataExample example = new EbitSpreadDataExample();
example.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<EbitSpreadData> ebitSpreadData1 = ebitSpreadDataMapper.selectByExample(example);
if(ebitSpreadData1.size() != 0){
didiFileUploadService.delData(ebitSpreadData1.get(0).getFileKey());
ebitSpreadDataMapper.deleteByExample(example);
} }
FileUpload fileUpload = didiFileUploadService.uploadFile(file, fileName, "ebit利润表");
EbitSpreadData ebitSpreadData = new EbitSpreadData();
ebitSpreadData.setPeriod(period);
ebitSpreadData.setOrganizationId(orgId);
ebitSpreadData.setFileKey(fileUpload.getUid());
ebitSpreadData.setFileName(fileName);
ebitSpreadData.setId(idService.nextId());
ebitSpreadDataMapper.insert(ebitSpreadData);
return operationResultDto.success(); return operationResultDto.success();
} }
...@@ -2403,11 +2396,8 @@ public class ReportServiceImpl extends BaseService { ...@@ -2403,11 +2396,8 @@ public class ReportServiceImpl extends BaseService {
* *
* @param requestParameterDto * @param requestParameterDto
*/ */
public void manyExport(RequestParameterDto requestParameterDto, String zipFileName, HttpServletRequest request, HttpServletResponse response) throws Exception { public void manyExport(RequestParameterDto requestParameterDto, String zipFileName, HttpServletRequest request, HttpServletResponse response, String zipPath) throws Exception {
String zipPath = this.getClass().getResource("/").getPath().substring(1) + "zipDir"; try {
String fileName = null;
FileExcelUtil.createFile(zipPath);
/* try {
FileOutputStream out = new FileOutputStream(zipFileName);//要输出的文件名字 FileOutputStream out = new FileOutputStream(zipFileName);//要输出的文件名字
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -2431,9 +2421,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -2431,9 +2421,7 @@ public class ReportServiceImpl extends BaseService {
List<EbitCellData> ebitCellDataList = ebitCellDataMapper.selectByExample(example);//获取当前期间下所有的数据 List<EbitCellData> ebitCellDataList = ebitCellDataMapper.selectByExample(example);//获取当前期间下所有的数据
List<List<EbitCellData>> dataList = Lists.newArrayList(); List<List<EbitCellData>> dataList = Lists.newArrayList();
List<EbitCellData> orgList = ebitCellDataMapper.selectOrgType(requestParameterDto.getPeriod()); List<EbitCellData> orgList = ebitCellDataMapper.selectOrgType(requestParameterDto.getPeriod());
List<EbitCellData> orgTypeList = Lists.newArrayList(); List<EbitCellData> orgTypeList = null;
File file = null;//要生成的Excel文件
List<File> filesList = Lists.newArrayList();
for (int i = 0; i < orgList.size(); i++) { for (int i = 0; i < orgList.size(); i++) {
orgTypeList = Lists.newArrayList(); orgTypeList = Lists.newArrayList();
for (EbitCellData ebitCellData : ebitCellDataList) { for (EbitCellData ebitCellData : ebitCellDataList) {
...@@ -2464,73 +2452,41 @@ public class ReportServiceImpl extends BaseService { ...@@ -2464,73 +2452,41 @@ public class ReportServiceImpl extends BaseService {
} }
} }
inputStream = httpFileService.getUserTemplate(templatePath); inputStream = httpFileService.getUserTemplate(templatePath);
Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheet = workbook.getSheetAt(0);
try { try {
Cell cell = null; Cell cell = null;
List<Workbook> workbooksList = Lists.newArrayList(); List<Workbook> workbooksList = Lists.newArrayList();
for (List<EbitCellData> ebitCellDataList1 : dataList) { for (List<EbitCellData> ebitCellDataList1 : dataList) {
Workbook newworkbook = new XSSFWorkbook(); Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheet1 = newworkbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
if (isSheetEmpty(sheet)) throw new Exception("模板异常"); if (isSheetEmpty(sheet)) throw new Exception("模板异常");
for (EbitCellData ebitCellData : ebitCellDataList1) { for (EbitCellData ebitCellData : ebitCellDataList1) {
loop1:
for (int j = 1, k = sheet.getLastRowNum(); j < k; j++) { for (int j = 1, k = sheet.getLastRowNum(); j < k; j++) {
if (sheet.getRow(j) == null) continue;
for (int m = 1, n = sheet.getRow(j).getLastCellNum(); m < n; m++) { for (int m = 1, n = sheet.getRow(j).getLastCellNum(); m < n; m++) {
cell = sheet.getRow(j).getCell(m); cell = sheet.getRow(j).getCell(m);
if (cell == null) continue; if ("".equals(getCellStringValue(cell)) && ebitCellData.getRow() == j && ebitCellData.getCol() == m) {
if (!"".equals(getCellStringValue(cell)) && ebitCellData.getRow() == j && ebitCellData.getCol() == m) {
cell.setCellValue(ebitCellData.getData()); cell.setCellValue(ebitCellData.getData());
break loop1;
} }
} }
} }
sheet1.getRow(ebitCellData.getRow()).getCell(ebitCellData.getCol()).setCellValue(ebitCellData.getData());
} }
POIUtil.cloneSheetAndStyle(workbook.getSheetAt(0), workbook.createSheet("利润表"),newworkbook);
workbooksList.add(workbook); workbooksList.add(workbook);
//将workbook生成file文件 //将workbook生成file文件
String path = "\\\\zipDir\\\\" + requestParameterDto.getPeriod() + Math.random() + "利润表"; String path = "\\\\zipDir\\\\" + requestParameterDto.getPeriod() + Math.random() + "利润表";
file = FileExcelUtil.generateExcelToPath(workbook, path); FileExcelUtil.downloadZip(request, response, zipFileName, FileExcelUtil.generateExcelToPath(workbook, path), zipPath);
if (file != null)
filesList.add(file);
} }
FileExcelUtil.downloadZip(request, response, zipFileName, filesList, zipPath);
//将workbook转成流
/* ByteArrayOutputStream bos = new ByteArrayOutputStream();
workbook.write(bos);
byte[] barray = bos.toByteArray();
InputStream is = new ByteArrayInputStream(barray);*/
// FileOutputStream fileOut = new FileOutputStream(path);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new Exception(ErrorMessage.SystemError); throw new Exception(ErrorMessage.SystemError);
} }
}*/
EbitSpreadDataExample example = new EbitSpreadDataExample();
example.createCriteria().andPeriodEqualTo(requestParameterDto.getPeriod());
List<EbitSpreadData> ebitSpreadData = ebitSpreadDataMapper.selectByExample(example);
List<File> fileList = Lists.newArrayList();
if (ebitSpreadData.size() == 0)
throw new Exception("没有可导出的数据");
for (int i = 0; i < ebitSpreadData.size(); i++) {
DidiFileIUploadParam fileParam = new DidiFileIUploadParam();
fileParam.setUuids(Arrays.asList(ebitSpreadData.get(i).getFileKey()));
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(fileParam);
String path = null;
if (CollectionUtils.isNotEmpty(uploadDetail.getList())) {
path = uploadDetail.getList().get(0).getViewHttpUrl();
} }
InputStream inputStream = httpFileService.getUserTemplate(path);
Workbook workbook1 = WorkbookFactory.create(inputStream);
fileName = zipPath + "/" + requestParameterDto.getPeriod() + ".xlsx";
fileList.add(FileExcelUtil.generateExcelToPath(workbook1, fileName));
}
String zipPath1 = zipPath + "/sizegang.zip";
FileExcelUtil.downloadZip(request, response, zipFileName, fileList, zipPath1);
//将workbook转成流
/* ByteArrayOutputStream bos = new ByteArrayOutputStream();
workbook.write(bos);
byte[] barray = bos.toByteArray();6
InputStream is = new ByteArrayInputStream(barray);*/
// FileOutputStream fileOut = new FileOutputStream(path);
} }
private String getCellStringValue(Cell cell) { private String getCellStringValue(Cell cell) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment