Commit 85dc97ea authored by neo's avatar neo

[Bugfix] fixed re gen datasource

parent f6a33be1
package pwc.taxtech.atms.vat.service.impl; package pwc.taxtech.atms.vat.service.impl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import jdk.nashorn.internal.runtime.options.Option;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.formula.functions.FreeRefFunction; import org.apache.poi.ss.formula.functions.FreeRefFunction;
...@@ -86,7 +87,8 @@ public class ReportGeneratorImpl { ...@@ -86,7 +87,8 @@ public class ReportGeneratorImpl {
} }
@Transactional @Transactional
public void updateWorkbookCaclsValueToDb(String projectId, Integer period, Workbook workbook, PeriodResources resources, PeriodJob job) { public void updateWorkbookCaclsValueToDb(String projectId, Integer period, Workbook workbook, PeriodResources resources,
Boolean isMergeMunual, PeriodJob job) {
for (int i = 0; i < workbook.getNumberOfSheets(); i++) { for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i); Sheet sheet = workbook.getSheetAt(i);
String code = sheet.getSheetName(); String code = sheet.getSheetName();
...@@ -118,38 +120,8 @@ public class ReportGeneratorImpl { ...@@ -118,38 +120,8 @@ public class ReportGeneratorImpl {
reportMapper.insertSelective(report); reportMapper.insertSelective(report);
List<PeriodCellTemplateConfig> periodCellTemplateConfigs = resources.getPeriodCellTemplateConfigs().stream() List<PeriodCellTemplateConfig> periodCellTemplateConfigs = resources.getPeriodCellTemplateConfigs().stream()
.filter(a -> a.getReportTemplateId().equals(templateId) && a.getDataSourceType().equals(CellDataSourceType.Formula.getCode())) .filter(a -> a.getReportTemplateId().equals(templateId)).collect(Collectors.toList());
.collect(Collectors.toList());
List<PeriodCellTemplateConfig> keyInCellTemplateConfigs = resources.getPeriodCellTemplateConfigs().stream()
.filter(a -> a.getReportTemplateId().equals(templateId) && a.getDataSourceType().equals(CellDataSourceType.KeyIn.getCode()))
.collect(Collectors.toList());
//todo: add manual datasource here,in order to disaplay the manual datasource we need add it first at here.
for (PeriodCellTemplateConfig keyInCellTemplateConfig : keyInCellTemplateConfigs) {
PeriodCellTemplateExample periodCellTemplateExample1 = new PeriodCellTemplateExample();
periodCellTemplateExample1.createCriteria().andCellTemplateIdEqualTo(keyInCellTemplateConfig.getCellTemplateId());
Optional<PeriodCellTemplate> periodCellTemplate = periodCellTemplateMapper.selectByExample(periodCellTemplateExample1).stream().findFirst();
PeriodDataSource dataSource = new PeriodDataSource();
dataSource.setId(distributedIdService.nextId());
if (periodCellTemplate.isPresent()) {
dataSource.setColumnIndex(periodCellTemplate.get().getColumnIndex());
dataSource.setRowIndex(periodCellTemplate.get().getRowIndex());
}
dataSource.setAmount(new BigDecimal("0"));
dataSource.setName("ManualDataSource");
dataSource.setDescription("ManualDataSource");
dataSource.setCreateTime(new Date());
dataSource.setUpdateTime(new Date());
dataSource.setCreateBy("Admin");
dataSource.setUpdateBy("Admin");
dataSource.setPeriod(period);
dataSource.setCellTemplateId(keyInCellTemplateConfig.getCellTemplateId());
dataSource.setType(FormulaDataSourceType.KeyInSource.getCode());
periodDataSourceMapper.insertSelective(dataSource);
}
//update formulablock table reportid field //update formulablock table reportid field
List<Long> cellTemplateConfigIds = periodCellTemplateConfigs.stream() List<Long> cellTemplateConfigIds = periodCellTemplateConfigs.stream()
...@@ -160,6 +132,7 @@ public class ReportGeneratorImpl { ...@@ -160,6 +132,7 @@ public class ReportGeneratorImpl {
} }
for (PeriodCellTemplateConfig periodCellTemplateConfig : periodCellTemplateConfigs) { for (PeriodCellTemplateConfig periodCellTemplateConfig : periodCellTemplateConfigs) {
PeriodFormulaBlockExample periodFormulaBlockExample2 = new PeriodFormulaBlockExample(); PeriodFormulaBlockExample periodFormulaBlockExample2 = new PeriodFormulaBlockExample();
periodFormulaBlockExample2.createCriteria() periodFormulaBlockExample2.createCriteria()
.andProjectIdEqualTo(projectId) .andProjectIdEqualTo(projectId)
...@@ -320,12 +293,13 @@ public class ReportGeneratorImpl { ...@@ -320,12 +293,13 @@ public class ReportGeneratorImpl {
dataSourceExample.createCriteria().andPeriodEqualTo(period).andProjectIdEqualTo(projectId) dataSourceExample.createCriteria().andPeriodEqualTo(period).andProjectIdEqualTo(projectId)
.andCellTemplateIdEqualTo(tempPeriodCellTemplate.get().getCellTemplateId()); .andCellTemplateIdEqualTo(tempPeriodCellTemplate.get().getCellTemplateId());
List<PeriodDataSource> dataSourceList = SpringContextUtil.periodDataSourceMapper.selectByExample(dataSourceExample); List<PeriodDataSource> dataSourceList = SpringContextUtil.periodDataSourceMapper.selectByExample(dataSourceExample);
for (int ii = 0; ii < dataSourceList.size(); ii++) { for (int ii = 0; ii < dataSourceList.size(); ii++) {
PeriodDataSource dataSource = dataSourceList.get(ii); PeriodDataSource dataSource = dataSourceList.get(ii);
if (dataSource.getType().intValue() == 10) {//s手工数据源 if (isMergeMunual && dataSource.getType().intValue() == 10) {
cellData.setData(dataSource.getAmount() + ""); cellData.setData(dataSource.getAmount() + "");
if (dataSourceList.size() == 1) cellData.setFormulaExp(dataSource.getAmount() + "");
} }
PeriodCellDataSource cellDataSource = new PeriodCellDataSource(); PeriodCellDataSource cellDataSource = new PeriodCellDataSource();
cellDataSource.setId(distributedIdService.nextId()); cellDataSource.setId(distributedIdService.nextId());
cellDataSource.setCellTemplateId(tempPeriodCellTemplate.get().getCellTemplateId()); cellDataSource.setCellTemplateId(tempPeriodCellTemplate.get().getCellTemplateId());
...@@ -645,13 +619,13 @@ public class ReportGeneratorImpl { ...@@ -645,13 +619,13 @@ public class ReportGeneratorImpl {
List<PCTEntity> entities = formulaMapToPCT.get(pctStr); List<PCTEntity> entities = formulaMapToPCT.get(pctStr);
StringBuilder result = new StringBuilder("0"); StringBuilder result = new StringBuilder("0");
for (PCTEntity entity : entities) { for (PCTEntity entity : entities) {
if(pctCache.containsKey(entity)){ if (pctCache.containsKey(entity)) {
PCTEntity pct= pctCache.get(entity); PCTEntity pct = pctCache.get(entity);
if(pct.getDsCount()==1&&pct.getAmount()!=null){ if (pct.getDsCount() == 1 && pct.getAmount() != null) {
result.append("+").append(pct.getAmount()); result.append("+").append(pct.getAmount());
}else if(pct.getDsCount()>1&&pct.getAmount()!=null&&!StringUtils.isEmpty(pct.getFormulaExp())){ } else if (pct.getDsCount() > 1 && pct.getAmount() != null && !StringUtils.isEmpty(pct.getFormulaExp())) {
result.append("+").append(pct.getFormulaExp()).append("+").append(pct.getAmount()); result.append("+").append(pct.getFormulaExp()).append("+").append(pct.getAmount());
}else if(pct.getAmount()==null&&!StringUtils.isNotEmpty(pct.getData())){ } else if (pct.getAmount() == null && !StringUtils.isNotEmpty(pct.getData())) {
result.append(pct.getData()); result.append(pct.getData());
} }
} }
......
...@@ -485,7 +485,7 @@ public class ReportServiceImpl { ...@@ -485,7 +485,7 @@ public class ReportServiceImpl {
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
evaluator.evaluateAll(); evaluator.evaluateAll();
reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources, genJob); reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources,isMergeManualData, genJob);
genJob.setStatus(WrapPeriodJobDto.STATUS_END); genJob.setStatus(WrapPeriodJobDto.STATUS_END);
periodJobMapper.updateByPrimaryKey(genJob); periodJobMapper.updateByPrimaryKey(genJob);
......
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