Commit 472dc359 authored by frank.xa.zhang's avatar frank.xa.zhang

fixed report generate issue

parent f69410c1
......@@ -26,10 +26,10 @@ public class ReportController {
@RequestMapping(value = "updateConfig/{projectId}/{ifDeleteManualDataSource}/{period}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto updateConfig(@PathVariable String projectId, @PathVariable Boolean ifDeleteManualDataSource, @PathVariable Integer period, @RequestParam String generator) {
// return reportService.updateConfig(projectId, period, ifDeleteManualDataSource, generator);
OperationResultDto operationResultDto = new OperationResultDto();
operationResultDto.setResult(true);
return operationResultDto;
return reportService.updateConfig(projectId, period, ifDeleteManualDataSource, generator);
// OperationResultDto operationResultDto = new OperationResultDto();
// operationResultDto.setResult(true);
// return operationResultDto;
}
@RequestMapping(value = "generateByTotal/{projectId}/{ifDeleteManualDataSource}/{period}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
......
......@@ -7,6 +7,7 @@ import org.apache.poi.ss.formula.udf.AggregatingUDFFinder;
import org.apache.poi.ss.formula.udf.DefaultUDFFinder;
import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -275,7 +276,16 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
dataSource.setId(distributedIDService.nextId());
dataSource.setColumnIndex(colNum - 1);
dataSource.setRowIndex(rowNum - 1);
dataSource.setAmount(new BigDecimal(cell.getNumericCellValue()));
if (((XSSFCell) cell).getRawValue() != "#VALUE!") {
dataSource.setAmount(new BigDecimal(
((XSSFCell) cell).getRawValue() != null ?
((XSSFCell) cell).getRawValue()
: (StringUtils.isNotBlank(cell.getStringCellValue())) ?
cell.getStringCellValue()
: Double.toString(cell.getNumericCellValue())));
} else {
dataSource.setAmount(new BigDecimal("0.0"));
}
dataSource.setName("ReportDataSource");
dataSource.setDescription(findStr);
dataSource.setCreateTime(createTime);
......@@ -309,8 +319,14 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
if (sheet.getRow(tempPeriodCellTemplate.get().getRowIndex()) != null
&& sheet.getRow(tempPeriodCellTemplate.get().getRowIndex())
.getCell(tempPeriodCellTemplate.get().getColumnIndex()) != null) {
data = Double.toString(sheet.getRow(tempPeriodCellTemplate.get().getRowIndex())
.getCell(tempPeriodCellTemplate.get().getColumnIndex()).getNumericCellValue());
Cell cell = sheet.getRow(tempPeriodCellTemplate.get().getRowIndex())
.getCell(tempPeriodCellTemplate.get().getColumnIndex());
data = ((XSSFCell) cell).getRawValue();
// if (cell.getCellTypeEnum().equals(CellType.NUMERIC)||cell.getCellTypeEnum().equals(CellType.FORMULA)) {
// data = Double.toString(cell.getNumericCellValue());
// } else {
// data = cell.getStringCellValue();
// }
} else {
data = EMPTY;
}
......
......@@ -640,6 +640,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
updateCellValueForDataSourceChange(cellDataSource.getCellDataId(), new BigDecimal("0"), data.getAmount());
dataSourceMapper.insertSelective(dataSourceModel);
cellDataSourceMapper.insertSelective(cellDataSource);
dataSourceExtendDtos = dataSourceMapper.getManualDataSource(data.getCellId());
}
//todo: update the reference cell's data, such as if formula is ND(1)+A2,
......@@ -677,7 +678,12 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
dataSource.setUpdateBy("admin");
dataSource.setUpdateTime(new Date());
dataSourceMapper.updateByPrimaryKeySelective(dataSource);
if(!cellData.getData().equals("#VALUE!")) {
cellData.setData(new BigDecimal(cellData.getData()).add(changeValue).toString());
}
else{
cellData.setData(new BigDecimal("0.0").add(changeValue).toString());
}
//cellData.setFormulaExp(cellData.getData());
cellData.setUpdateTime(new Date());
cellDataMapper.updateByPrimaryKeySelective(cellData);
......
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