Commit a9d15003 authored by neo's avatar neo

[merge] merge confilict

parents 5ee3f338 e3f2030c
...@@ -162,7 +162,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -162,7 +162,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
otherFormulaCells.add(cell); otherFormulaCells.add(cell);
} }
//kv 公式处理 //kv 公式处理
} else if (v.getFormula().startsWith("@")) { } else if (v.getFormula().contains("@")) {
if (StringUtils.isNotBlank(v.getKeyValueParsedFormula())) { if (StringUtils.isNotBlank(v.getKeyValueParsedFormula())) {
cell.setCellFormula(v.getKeyValueParsedFormula()); cell.setCellFormula(v.getKeyValueParsedFormula());
logger.debug("formula:" + v.getKeyValueParsedFormula()); logger.debug("formula:" + v.getKeyValueParsedFormula());
...@@ -337,7 +337,6 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -337,7 +337,6 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
} }
} }
Optional<PeriodCellTemplate> tempPeriodCellTemplate = periodCellTemplateList.stream() Optional<PeriodCellTemplate> tempPeriodCellTemplate = periodCellTemplateList.stream()
.filter(a -> a.getCellTemplateId().equals(periodCellTemplateConfig.getCellTemplateId())) .filter(a -> a.getCellTemplateId().equals(periodCellTemplateConfig.getCellTemplateId()))
.findFirst(); .findFirst();
...@@ -354,6 +353,10 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -354,6 +353,10 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
Cell cell = sheet.getRow(tempPeriodCellTemplate.get().getRowIndex()) Cell cell = sheet.getRow(tempPeriodCellTemplate.get().getRowIndex())
.getCell(tempPeriodCellTemplate.get().getColumnIndex()); .getCell(tempPeriodCellTemplate.get().getColumnIndex());
data = ((XSSFCell) cell).getRawValue(); data = ((XSSFCell) cell).getRawValue();
if (data != null && data.equals("#VALUE!")) {
data = "0.0";
}
//evaluator.evaluate(cell)
// if (cell.getCellTypeEnum().equals(CellType.NUMERIC)||cell.getCellTypeEnum().equals(CellType.FORMULA)) { // if (cell.getCellTypeEnum().equals(CellType.NUMERIC)||cell.getCellTypeEnum().equals(CellType.FORMULA)) {
// data = Double.toString(cell.getNumericCellValue()); // data = Double.toString(cell.getNumericCellValue());
// } else { // } else {
......
...@@ -29,6 +29,8 @@ import java.util.HashMap; ...@@ -29,6 +29,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Component @Component
...@@ -255,14 +257,33 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -255,14 +257,33 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
periodCellTemplateConfig.setCellTemplateConfigId(cellTemplateConfig.getId()); periodCellTemplateConfig.setCellTemplateConfigId(cellTemplateConfig.getId());
periodCellTemplateConfig.setKeyValueParsedFormula(StringUtils.EMPTY); periodCellTemplateConfig.setKeyValueParsedFormula(StringUtils.EMPTY);
if (cellTemplateConfig.getFormula().startsWith("@")) { if (cellTemplateConfig.getFormula().contains("@")) {
//todo: get the keyvalue from table add to keyvalue parsed formula String regex = "@[0-9A-Z.]+";
KeyValueConfigExample keyValueConfigExample = new KeyValueConfigExample(); Pattern pp = Pattern.compile(regex);
keyValueConfigExample.createCriteria().andKeyCodeEqualTo(StringUtils.removeStart(cellTemplateConfig.getFormula(), "@")); Matcher mm = pp.matcher(cellTemplateConfig.getFormula());
Optional<KeyValueConfig> keyValueConfig = keyValueConfigMapper.selectByExample(keyValueConfigExample).stream().findFirst(); String replace_result = cellTemplateConfig.getFormula();
if (keyValueConfig.isPresent()) { Boolean replace = true;
periodCellTemplateConfig.setKeyValueParsedFormula(keyValueConfig.get().getFormula()); while (mm.find()) {
KeyValueConfigExample keyValueConfigExample = new KeyValueConfigExample();
keyValueConfigExample.createCriteria().andKeyCodeEqualTo(StringUtils.removeStart(mm.group(), "@"));
Optional<KeyValueConfig> keyValueConfig = keyValueConfigMapper.selectByExample(keyValueConfigExample).stream().findFirst();
if (keyValueConfig.isPresent() && StringUtils.isNotBlank(keyValueConfig.get().getFormula())) {
replace_result = replace_result.replace(mm.group(), keyValueConfig.get().getFormula());
} else {
replace = false;
}
} }
if (replace) {
periodCellTemplateConfig.setKeyValueParsedFormula(replace_result);
}
//todo: get the keyvalue from table add to keyvalue parsed formula
// KeyValueConfigExample keyValueConfigExample = new KeyValueConfigExample();
// keyValueConfigExample.createCriteria().andKeyCodeEqualTo(StringUtils.removeStart(cellTemplateConfig.getFormula(), "@"));
// Optional<KeyValueConfig> keyValueConfig = keyValueConfigMapper.selectByExample(keyValueConfigExample).stream().findFirst();
// if (keyValueConfig.isPresent()) {
// periodCellTemplateConfig.setKeyValueParsedFormula(keyValueConfig.get().getFormula());
// }
} }
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");
......
...@@ -40,6 +40,8 @@ public class GZSD extends FunctionBase implements FreeRefFunction { ...@@ -40,6 +40,8 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
return null; return null;
} }
BigDecimal decimal_zero = new BigDecimal("0.0");
Integer taxCategory = getIntParam(args[0], ec); Integer taxCategory = getIntParam(args[0], ec);
Integer resultType = getIntParam(args[1], ec); Integer resultType = getIntParam(args[1], ec);
String formulaExpression = "GZSD(" + taxCategory + "," + resultType + ")"; String formulaExpression = "GZSD(" + taxCategory + "," + resultType + ")";
...@@ -74,6 +76,20 @@ public class GZSD extends FunctionBase implements FreeRefFunction { ...@@ -74,6 +76,20 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
matchedRule = Optional.ofNullable(taxRuleSettings.size()>0?taxRuleSettings.get(0):null); matchedRule = Optional.ofNullable(taxRuleSettings.size()>0?taxRuleSettings.get(0):null);
if (!matchedRule.isPresent()) { if (!matchedRule.isPresent()) {
NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMaximumFractionDigits(2);
List<FormulaDataSourceDto> dataSourceDtoList = new ArrayList<>();
FormulaDataSourceDto formulaDataSourceDto = new FormulaDataSourceDto();
formulaDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
formulaDataSourceDto.setType(FormulaDataSourceType.Report.getCode());
formulaDataSourceDto.setResultType(KeyValueConfigResultType.Percentage.getCode());
formulaDataSourceDto.setAmount(decimal_zero);
formulaDataSourceDto.setName(nf.format(decimal_zero));
dataSourceDtoList.add(formulaDataSourceDto);
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSourceDtoList),
FormulaDataSourceDetailType.FormulaDataSourceDto, decimal_zero, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupID());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, decimal_zero, dataSourceId);
return NumberEval.ZERO; return NumberEval.ZERO;
} }
} }
...@@ -102,7 +118,23 @@ public class GZSD extends FunctionBase implements FreeRefFunction { ...@@ -102,7 +118,23 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
//todo: @本期应(实)纳税额 ,@GDZC.BQ.QMYE 这种类型的数据,重新计算,按照keyvalue的配置 //todo: @本期应(实)纳税额 ,@GDZC.BQ.QMYE 这种类型的数据,重新计算,按照keyvalue的配置
//return new NumberEval(matchedRule.get().getTaxBase()); //return new NumberEval(matchedRule.get().getTaxBase());
NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMaximumFractionDigits(2);
List<FormulaDataSourceDto> dataSourceDtoList = new ArrayList<>();
FormulaDataSourceDto formulaDataSourceDto = new FormulaDataSourceDto();
formulaDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
formulaDataSourceDto.setType(FormulaDataSourceType.Report.getCode());
formulaDataSourceDto.setResultType(KeyValueConfigResultType.Percentage.getCode());
formulaDataSourceDto.setAmount(decimal_zero);
formulaDataSourceDto.setName(nf.format(decimal_zero));
dataSourceDtoList.add(formulaDataSourceDto);
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSourceDtoList),
FormulaDataSourceDetailType.FormulaDataSourceDto, decimal_zero, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupID());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, decimal_zero, dataSourceId);
return NumberEval.ZERO;
} }
return NumberEval.ZERO; //return NumberEval.ZERO;
} }
} }
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