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

fixed formula datasource issues ----> next step is fixed report datasource display issue

parent 9c4fd097
...@@ -124,6 +124,8 @@ public interface DataSourceMapper extends MyVatMapper { ...@@ -124,6 +124,8 @@ public interface DataSourceMapper extends MyVatMapper {
void clearDataSourceDetailWithPeriod(@Param("period") Integer period); void clearDataSourceDetailWithPeriod(@Param("period") Integer period);
void clearCellDataSourceDataWithPeriod(@Param("period") Integer period);
void clearCellDataWithPeriod(@Param("exceptReportTemplateIDs") String exceptReportTemplateIDs,@Param("period")Integer period); void clearCellDataWithPeriod(@Param("exceptReportTemplateIDs") String exceptReportTemplateIDs,@Param("period")Integer period);
void clearReportWithPeriod(Integer period); void clearReportWithPeriod(Integer period);
......
...@@ -85,6 +85,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -85,6 +85,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
formulaContext.setProjectID(project.getID()); formulaContext.setProjectID(project.getID());
formulaContext.setYear(project.getYear()); formulaContext.setYear(project.getYear());
formulaContext.setOrganizationID(project.getOrganizationID()); formulaContext.setOrganizationID(project.getOrganizationID());
formulaContext.setIfRound(true);
addFunctionsToWorkbook(newWorkbook, formulaContext); addFunctionsToWorkbook(newWorkbook, formulaContext);
int sheetCount = newWorkbook.getNumberOfSheets(); int sheetCount = newWorkbook.getNumberOfSheets();
...@@ -182,11 +183,11 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -182,11 +183,11 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
periodFormulaBlockMapper.updateReportId(reportID, cellTemplateConfigIds, period); periodFormulaBlockMapper.updateReportId(reportID, cellTemplateConfigIds, period);
} }
PeriodFormulaBlockExample periodFormulaBlockExample2 = new PeriodFormulaBlockExample();
periodFormulaBlockExample2.createCriteria().andCellTemplateIdEqualTo(templateID);
List<PeriodFormulaBlock> periodFormulaBlocks = periodFormulaBlockMapper.selectByExample(periodFormulaBlockExample2);
for (PeriodCellTemplateConfig periodCellTemplateConfig : periodCellTemplateConfigs) { for (PeriodCellTemplateConfig periodCellTemplateConfig : periodCellTemplateConfigs) {
PeriodFormulaBlockExample periodFormulaBlockExample2 = new PeriodFormulaBlockExample();
periodFormulaBlockExample2.createCriteria().andCellTemplateIdEqualTo(periodCellTemplateConfig.getCellTemplateId());
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);
...@@ -381,9 +382,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -381,9 +382,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","GZSD"};
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),new GZSD(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);
......
...@@ -108,13 +108,16 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -108,13 +108,16 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
if (templateGroupID != null && templateGroupID != 0) { if (templateGroupID != null && templateGroupID != 0) {
// 先进行数据清理,包括period开头的所有报表配置表 条件Period // 先进行数据清理,包括period开头的所有报表配置表 条件Period
dataSourceMapper.clearFormulaBlockWithPeriod(period); dataSourceMapper.clearFormulaBlockWithPeriod(period);
dataSourceMapper.clearTaxRuleSettingWithPeriod(period); //todo: reopen it later
//dataSourceMapper.clearTaxRuleSettingWithPeriod(period);
dataSourceMapper.clearCellTemplateWithPeriod(period, strExceptTemplateIDs); dataSourceMapper.clearCellTemplateWithPeriod(period, strExceptTemplateIDs);
dataSourceMapper.clearCellTemplateConfigWithPeriod(period, strExceptTemplateIDs); dataSourceMapper.clearCellTemplateConfigWithPeriod(period, strExceptTemplateIDs);
dataSourceMapper.clearTemplateWithPeriod(period, strExceptTemplateIDs); dataSourceMapper.clearTemplateWithPeriod(period, strExceptTemplateIDs);
dataSourceMapper.clearTaxPayerReportWithPeriod(period); //todo: reopen it later
dataSourceMapper.clearDataSourceWithPeriod(period); //dataSourceMapper.clearTaxPayerReportWithPeriod(period);
dataSourceMapper.clearCellDataSourceDataWithPeriod(period);
dataSourceMapper.clearDataSourceDetailWithPeriod(period); dataSourceMapper.clearDataSourceDetailWithPeriod(period);
dataSourceMapper.clearDataSourceWithPeriod(period);
dataSourceMapper.clearCellDataWithPeriod(strExceptTemplateIDs, period); dataSourceMapper.clearCellDataWithPeriod(strExceptTemplateIDs, period);
dataSourceMapper.clearReportWithPeriod(period); dataSourceMapper.clearReportWithPeriod(period);
......
...@@ -71,7 +71,7 @@ public class GZSD extends FunctionBase implements FreeRefFunction { ...@@ -71,7 +71,7 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
Optional<PeriodTaxRuleSetting> matchedRule = taxRuleSettings.stream().filter(a -> a.getIsDefault() != Constant.IsDefault.Yes).findFirst(); Optional<PeriodTaxRuleSetting> matchedRule = taxRuleSettings.stream().filter(a -> a.getIsDefault() != Constant.IsDefault.Yes).findFirst();
if (!matchedRule.isPresent()) { if (!matchedRule.isPresent()) {
matchedRule = Optional.ofNullable(taxRuleSettings.get(0)); matchedRule = Optional.ofNullable(taxRuleSettings.size()>0?taxRuleSettings.get(0):null);
if (!matchedRule.isPresent()) { if (!matchedRule.isPresent()) {
return NumberEval.ZERO; return NumberEval.ZERO;
...@@ -94,7 +94,7 @@ public class GZSD extends FunctionBase implements FreeRefFunction { ...@@ -94,7 +94,7 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
formulaDataSourceDto.setName(nf.format(matchedRule.get().getTaxRate())); formulaDataSourceDto.setName(nf.format(matchedRule.get().getTaxRate()));
dataSourceDtoList.add(formulaDataSourceDto); dataSourceDtoList.add(formulaDataSourceDto);
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSourceDtoList), Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSourceDtoList),
FormulaDataSourceDetailType.FormulaDataSourceDto, val,formulaContext.getPeriod(), FormulaDataSourceDetailType.FormulaDataSourceDto, val, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupID()); formulaContext.getReportTemplateGroupID());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, val, dataSourceId); saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, val, dataSourceId);
return new NumberEval(val.doubleValue()); return new NumberEval(val.doubleValue());
......
...@@ -504,10 +504,13 @@ ...@@ -504,10 +504,13 @@
DELETE FROM period_tax_payer_report_rule WHERE period=#{period,jdbcType=INTEGER}; DELETE FROM period_tax_payer_report_rule WHERE period=#{period,jdbcType=INTEGER};
</delete> </delete>
<delete id="clearDataSourceWithPeriod"> <delete id="clearDataSourceWithPeriod">
DELETE d FROM data_source d JOIN period_formula_block f ON d.id = f.data_source_id WHERE f.period = #{period,jdbcType=INTEGER}; DELETE d FROM data_source d WHERE d.period = #{period,jdbcType=INTEGER};
</delete> </delete>
<delete id="clearDataSourceDetailWithPeriod"> <delete id="clearDataSourceDetailWithPeriod">
DELETE d FROM data_source_detail d JOIN period_formula_block f ON d.data_source_id = f.data_source_id WHERE f.period = #{period,jdbcType=INTEGER}; DELETE d FROM data_source_detail d JOIN data_source f ON d.data_source_id = f.id WHERE f.period = #{period,jdbcType=INTEGER};
</delete>
<delete id="clearCellDataSourceDataWithPeriod">
DELETE d FROM cell_data_source d JOIN data_source f ON d.data_source_id = f.id WHERE f.period = #{period,jdbcType=INTEGER};
</delete> </delete>
<delete id="clearCellDataWithPeriod"> <delete id="clearCellDataWithPeriod">
DELETE c FROM cell_data c join report r on c.report_id=r.id where r.period = #{period,jdbcType=INTEGER}; DELETE c FROM cell_data c join report r on c.report_id=r.id where r.period = #{period,jdbcType=INTEGER};
......
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