Commit 8e7fed59 authored by frank.xa.zhang's avatar frank.xa.zhang

fixed formula cell data can't display issue

parent eb111dbe
...@@ -243,7 +243,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -243,7 +243,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
List<PeriodFormulaBlock> periodFormulaBlocks = periodFormulaBlockMapper.selectByExample(periodFormulaBlockExample2); List<PeriodFormulaBlock> periodFormulaBlocks = periodFormulaBlockMapper.selectByExample(periodFormulaBlockExample2);
//TODO:如果formula 为 ND(100) +ND(22) ,需要使用正则表达式拆分出自定义公式,然后根据自定义公式取formulablock 的数据进行替换 //TODO:如果formula 为 ND(100) +ND(22) ,需要使用正则表达式拆分出自定义公式,然后根据自定义公式取formulablock 的数据进行替换
String regex = "[A-Z]*\\([A-Za-z0-9\\\"\\,\\.\\u4e00-\\u9fa5\\%]*\\)"; String regex = "[A-Z]*\\([\\-A-Za-z0-9\\\"\\,\\.\\u4e00-\\u9fa5\\%]*\\)";
Pattern p = Pattern.compile(regex); Pattern p = Pattern.compile(regex);
String sourceFormula = periodCellTemplateConfig.getFormula(); String sourceFormula = periodCellTemplateConfig.getFormula();
String resultFormula = periodCellTemplateConfig.getFormula(); String resultFormula = periodCellTemplateConfig.getFormula();
...@@ -348,7 +348,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -348,7 +348,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
} else { } else {
data = EMPTY; data = EMPTY;
} }
cellData.setData(data); cellData.setData(new BigDecimal(data).toString());
PeriodFormulaBlockExample periodFormulaBlockExample = new PeriodFormulaBlockExample(); PeriodFormulaBlockExample periodFormulaBlockExample = new PeriodFormulaBlockExample();
periodFormulaBlockExample.createCriteria().andPeriodEqualTo(period) periodFormulaBlockExample.createCriteria().andPeriodEqualTo(period)
.andCellTemplateIdEqualTo(tempPeriodCellTemplate.get().getCellTemplateId()); .andCellTemplateIdEqualTo(tempPeriodCellTemplate.get().getCellTemplateId());
......
...@@ -213,7 +213,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -213,7 +213,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
for (CellTemplateConfig cellTemplateConfig : cellTemplateConfigList) { for (CellTemplateConfig cellTemplateConfig : cellTemplateConfigList) {
i++; i++;
Long startTime = System.currentTimeMillis(); Long startTime = System.currentTimeMillis();
logger.debug("cellTemplateConfig copy start: " + startTime); //logger.debug("cellTemplateConfig copy start: " + startTime);
PeriodCellTemplateConfig periodCellTemplateConfig = new PeriodCellTemplateConfig(); PeriodCellTemplateConfig periodCellTemplateConfig = new PeriodCellTemplateConfig();
CommonUtils.copyProperties(cellTemplateConfig, periodCellTemplateConfig); CommonUtils.copyProperties(cellTemplateConfig, periodCellTemplateConfig);
periodCellTemplateConfig.setId(distributedIDService.nextId()); periodCellTemplateConfig.setId(distributedIDService.nextId());
...@@ -252,7 +252,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -252,7 +252,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
} }
} }
periodCellTemplateConfigList.add(periodCellTemplateConfig); periodCellTemplateConfigList.add(periodCellTemplateConfig);
logger.debug("cellTemplateConfig copy end,used time: " + (System.currentTimeMillis() - startTime) + " ms"); //logger.debug("cellTemplateConfig copy end,used time: " + (System.currentTimeMillis() - startTime) + " ms");
} }
logger.debug("cellTemplateConfigs copy end,used: " + (System.currentTimeMillis() - startTimeOut) + " ms, copy: " + i + " items"); logger.debug("cellTemplateConfigs copy end,used: " + (System.currentTimeMillis() - startTimeOut) + " ms, copy: " + i + " items");
......
...@@ -15,11 +15,10 @@ import pwc.taxtech.atms.vat.entity.DataSourceDetail; ...@@ -15,11 +15,10 @@ import pwc.taxtech.atms.vat.entity.DataSourceDetail;
import pwc.taxtech.atms.vat.entity.PeriodFormulaBlock; import pwc.taxtech.atms.vat.entity.PeriodFormulaBlock;
import pwc.taxtech.atms.vat.service.impl.FormulaAgent; import pwc.taxtech.atms.vat.service.impl.FormulaAgent;
import javax.tools.JavaCompiler;
import java.lang.reflect.Array;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FunctionBase { public class FunctionBase {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(this.getClass());
...@@ -131,12 +130,23 @@ public class FunctionBase { ...@@ -131,12 +130,23 @@ public class FunctionBase {
dataSource.setPeriod(period); dataSource.setPeriod(period);
SpringContextUtil.dataSourceMapper.insertSelective(dataSource); SpringContextUtil.dataSourceMapper.insertSelective(dataSource);
for (Object obj : dataSourceList) { for (Object obj : dataSourceList) {
DataSourceDetail dataSourceDetail = new DataSourceDetail(); if (obj.getClass()==java.util.ArrayList.class) {
dataSourceDetail.setId(SpringContextUtil.distributedIDService.nextId()); for (Object obj2 : (ArrayList<Object>)obj) {
dataSourceDetail.setDataSourceId(dataSourceID); DataSourceDetail dataSourceDetail = new DataSourceDetail();
dataSourceDetail.setDataSourceType(formulaDataSourceDetailType.getCode()); dataSourceDetail.setId(SpringContextUtil.distributedIDService.nextId());
dataSourceDetail.setItemValue(JSON.toJSONString(obj)); dataSourceDetail.setDataSourceId(dataSourceID);
SpringContextUtil.dataSourceDetailMapper.insertSelective(dataSourceDetail); dataSourceDetail.setDataSourceType(formulaDataSourceDetailType.getCode());
dataSourceDetail.setItemValue(JSON.toJSONString(obj2));
SpringContextUtil.dataSourceDetailMapper.insertSelective(dataSourceDetail);
}
} else {
DataSourceDetail dataSourceDetail = new DataSourceDetail();
dataSourceDetail.setId(SpringContextUtil.distributedIDService.nextId());
dataSourceDetail.setDataSourceId(dataSourceID);
dataSourceDetail.setDataSourceType(formulaDataSourceDetailType.getCode());
dataSourceDetail.setItemValue(JSON.toJSONString(obj));
SpringContextUtil.dataSourceDetailMapper.insertSelective(dataSourceDetail);
}
} }
return dataSourceID; return dataSourceID;
} }
......
...@@ -150,21 +150,21 @@ public class JXFP extends FunctionBase implements FreeRefFunction { ...@@ -150,21 +150,21 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
double val = dataSource.stream().mapToDouble(a -> a.getAmount().doubleValue()).sum(); double val = dataSource.stream().mapToDouble(a -> a.getAmount().doubleValue()).sum();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource), Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.InputInvoiceDataSourceDto, FormulaDataSourceDetailType.InputInvoiceDataSourceDto,
BigDecimal.valueOf(val),period,formulaContext.getReportTemplateGroupID()); BigDecimal.valueOf(val),formulaContext.getPeriod(),formulaContext.getReportTemplateGroupID());
saveFormulaBlock(period, ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId); saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId);
return new NumberEval(val); return new NumberEval(val);
} else if (resultType == 1) { } else if (resultType == 1) {
double val = dataSource.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum(); double val = dataSource.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource), Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.InputInvoiceDataSourceDto, FormulaDataSourceDetailType.InputInvoiceDataSourceDto,
BigDecimal.valueOf(val),period,formulaContext.getReportTemplateGroupID()); BigDecimal.valueOf(val),formulaContext.getPeriod(),formulaContext.getReportTemplateGroupID());
saveFormulaBlock(period, ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId); saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId);
return new NumberEval(val); return new NumberEval(val);
} else if (resultType == 2) { } else if (resultType == 2) {
double val = dataSource.size(); double val = dataSource.size();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource), Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.InputInvoiceDataSourceDto, FormulaDataSourceDetailType.InputInvoiceDataSourceDto,
BigDecimal.valueOf(val),period,formulaContext.getReportTemplateGroupID()); BigDecimal.valueOf(val),formulaContext.getPeriod(),formulaContext.getReportTemplateGroupID());
saveFormulaBlock(period, ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId); saveFormulaBlock(period, ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId);
return new NumberEval(val); return new NumberEval(val);
} }
......
...@@ -958,7 +958,7 @@ CREATE TABLE IF NOT EXISTS `DBKeyword_ProjectDbName`.`data_source_detail` ( ...@@ -958,7 +958,7 @@ CREATE TABLE IF NOT EXISTS `DBKeyword_ProjectDbName`.`data_source_detail` (
`id` bigint(18) unsigned NOT NULL, `id` bigint(18) unsigned NOT NULL,
`data_source_id` bigint(18) unsigned NOT NULL DEFAULT '0', `data_source_id` bigint(18) unsigned NOT NULL DEFAULT '0',
`data_source_type` int(11) unsigned NOT NULL DEFAULT '0', `data_source_type` int(11) unsigned NOT NULL DEFAULT '0',
`item_value` varchar(500) NOT NULL DEFAULT '', `item_value` varchar(1000) NOT NULL DEFAULT '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
......
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