Commit e6495005 authored by frank.xa.zhang's avatar frank.xa.zhang

add key value formula to report for calculate

parent 3e33988f
...@@ -135,6 +135,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -135,6 +135,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
//todo:后面单独处理kv的公式 //todo:后面单独处理kv的公式
if (StringUtils.isNotBlank(v.getFormula()) && !v.getFormula().contains("@")) { if (StringUtils.isNotBlank(v.getFormula()) && !v.getFormula().contains("@")) {
cell.setCellFormula(v.getFormula()); cell.setCellFormula(v.getFormula());
//kv 公式处理
} else if (v.getFormula().startsWith("@")) {
cell.setCellFormula(v.getKeyValueParsedFormula());
} }
}); });
} }
...@@ -203,7 +206,6 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -203,7 +206,6 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
periodFormulaBlockExample.createCriteria().andPeriodEqualTo(period) periodFormulaBlockExample.createCriteria().andPeriodEqualTo(period)
.andCellTemplateIdEqualTo(tempPeriodCellTemplate.get().getCellTemplateId()); .andCellTemplateIdEqualTo(tempPeriodCellTemplate.get().getCellTemplateId());
//todo: 这里可能一个单元格不止一个公式,需要根据公式的内容来进行替换具体的解析公式 //todo: 这里可能一个单元格不止一个公式,需要根据公式的内容来进行替换具体的解析公式
Optional<PeriodFormulaBlock> periodFormulaBlock = Optional<PeriodFormulaBlock> periodFormulaBlock =
periodFormulaBlockMapper.selectByExample(periodFormulaBlockExample).stream().findFirst(); periodFormulaBlockMapper.selectByExample(periodFormulaBlockExample).stream().findFirst();
...@@ -277,9 +279,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -277,9 +279,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
* @param workbook 工作簿 * @param workbook 工作簿
*/ */
private void addFunctionsToWorkbook(Workbook workbook, FormulaContext formulaContext) { private void addFunctionsToWorkbook(Workbook workbook, FormulaContext formulaContext) {
String[] functionNames = {"SGSR", "FSJZ", "ND", "BB","XXFP"}; String[] functionNames = {"SGSR", "FSJZ", "ND", "BB", "XXFP"};
FreeRefFunction[] functionImpls = {new SGSR(formulaContext), new FSJZ(formulaContext), new ND(formulaContext), FreeRefFunction[] functionImpls = {new SGSR(formulaContext), new FSJZ(formulaContext), new ND(formulaContext),
new BB(formulaContext),new XXFP(formulaContext)}; new BB(formulaContext), new XXFP(formulaContext)};
UDFFinder udfs = new DefaultUDFFinder(functionNames, functionImpls); UDFFinder udfs = new DefaultUDFFinder(functionNames, functionImpls);
UDFFinder udfToolpack = new AggregatingUDFFinder(udfs); UDFFinder udfToolpack = new AggregatingUDFFinder(udfs);
workbook.addToolPack(udfToolpack); workbook.addToolPack(udfToolpack);
......
...@@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder; import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.constant.enums.EnumServiceType; import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dao.KeyValueConfigMapper;
import pwc.taxtech.atms.dto.OperationResultDto; import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.*; import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.entitiy.*; import pwc.taxtech.atms.entitiy.*;
...@@ -200,6 +201,15 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -200,6 +201,15 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
periodCellTemplateConfig.setValidationDescription(cellTemplateConfig.getValidationDescription()); periodCellTemplateConfig.setValidationDescription(cellTemplateConfig.getValidationDescription());
periodCellTemplateConfig.setVoucherKeyword(cellTemplateConfig.getVoucherKeyword()); periodCellTemplateConfig.setVoucherKeyword(cellTemplateConfig.getVoucherKeyword());
periodCellTemplateConfig.setCellTemplateConfigId(cellTemplateConfig.getId()); periodCellTemplateConfig.setCellTemplateConfigId(cellTemplateConfig.getId());
if (cellTemplateConfig.getFormula().startsWith("@")) {
//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);
} }
......
...@@ -80,5 +80,7 @@ public class VatAbstractService { ...@@ -80,5 +80,7 @@ public class VatAbstractService {
public FormulaAgent formulaAgent; public FormulaAgent formulaAgent;
@Autowired @Autowired
public CellCommentMapper cellCommentMapper; public CellCommentMapper cellCommentMapper;
@Autowired
public KeyValueConfigMapper keyValueConfigMapper;
} }
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