Commit 310b7040 authored by neo's avatar neo

[bugfix] add bb log info

parent 022e2975
...@@ -15,6 +15,7 @@ import pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto; ...@@ -15,6 +15,7 @@ import pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto;
import pwc.taxtech.atms.dto.vatdto.CurrentPeriodBo; import pwc.taxtech.atms.dto.vatdto.CurrentPeriodBo;
import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto; import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto;
import pwc.taxtech.atms.exception.Exceptions; import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.exception.FormulaException;
import pwc.taxtech.atms.vat.entity.CellData; import pwc.taxtech.atms.vat.entity.CellData;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -35,8 +36,10 @@ public class BB extends FunctionBase implements FreeRefFunction { ...@@ -35,8 +36,10 @@ public class BB extends FunctionBase implements FreeRefFunction {
try { try {
return wrapExceptionEval(args, ec); return wrapExceptionEval(args, ec);
} catch (Exception e) { } catch (Exception e) {
LOGGER.warn("un expect exception", e); if (e instanceof FormulaException)
e.printStackTrace(); LOGGER.warn("Formula Exception || ", e);
else
e.printStackTrace();
return defaultEval; return defaultEval;
} }
} }
...@@ -46,6 +49,7 @@ public class BB extends FunctionBase implements FreeRefFunction { ...@@ -46,6 +49,7 @@ public class BB extends FunctionBase implements FreeRefFunction {
} }
public BigDecimal bb(BBParasBo bo, OperationEvaluationContext ec) throws Exception { public BigDecimal bb(BBParasBo bo, OperationEvaluationContext ec) throws Exception {
List<Object> ds = new ArrayList<>(); List<Object> ds = new ArrayList<>();
CurrentPeriodBo curPeriod = CurrentPeriodBo.getPeriod(bo.getPeriod().intValue(), formulaContext.getPeriod()); CurrentPeriodBo curPeriod = CurrentPeriodBo.getPeriod(bo.getPeriod().intValue(), formulaContext.getPeriod());
curPeriod.fixedCurYear(getYear(bo.getYear())); curPeriod.fixedCurYear(getYear(bo.getYear()));
...@@ -56,64 +60,66 @@ public class BB extends FunctionBase implements FreeRefFunction { ...@@ -56,64 +60,66 @@ public class BB extends FunctionBase implements FreeRefFunction {
CellTemplatePerGroupDto cellTemplateData = agent.getCellTemplateGroupDto(formulaContext.getReportTemplateGroupID(), CellTemplatePerGroupDto cellTemplateData = agent.getCellTemplateGroupDto(formulaContext.getReportTemplateGroupID(),
formulaContext.getProjectID()).stream().filter(dto -> dto.getRowIndex() == bo.getColumnIndex() - 1 formulaContext.getProjectID()).stream().filter(dto -> dto.getRowIndex() == bo.getColumnIndex() - 1
&& dto.getColumnIndex() == bo.getColumnIndex() - 1).findFirst().get(); && dto.getColumnIndex() == bo.getColumnIndex() - 1).findFirst().get();
BigDecimal cellValue = BigDecimal.ZERO;
MyAsserts.assertNotNull(cellTemplateData, Exceptions.BB_CELL_TEMP_NULL); try {
nullCellDto.fixedWithGroup(cellTemplateData); MyAsserts.assertNotNull(cellTemplateData, Exceptions.BB_CELL_TEMP_NULL);
nullCellDto.fixedWithGroup(cellTemplateData);
// todo: fix datasource name by templateList(neo)
if (curPeriod.getCurPeriod() == -99) { // todo: fix datasource name by templateList(neo)
ds.clear(); if (curPeriod.getCurPeriod() == -99) {
BigDecimal returnEval = defaultBigDecimal; ds.clear();
if (formulaContext.getPeriod() <= 1) { BigDecimal returnEval = defaultBigDecimal;
return defaultBigDecimal; if (formulaContext.getPeriod() <= 1) {
} return defaultBigDecimal;
}
for (int p = 1; p < formulaContext.getPeriod(); p++) {
returnEval = returnEval.add(bb(new BBParasBo(bo, p, curPeriod.getCurYear()), ec)); for (int p = 1; p < formulaContext.getPeriod(); p++) {
returnEval = returnEval.add(bb(new BBParasBo(bo, p, curPeriod.getCurYear()), ec));
}
return returnEval;
} }
return returnEval; bo.disCount();
} String dbName = agent.getPastProjectDbName(curPeriod.getCurYear(),
formulaContext.getOrganizationID());
bo.disCount(); String currentProjectDb = ShardingContextHolder.getDataSourceKey();
String dbName = agent.getPastProjectDbName(curPeriod.getCurYear(), CellData cellData = null;
formulaContext.getOrganizationID()); if (currentProjectDb.equals(dbName)) {
String currentProjectDb = ShardingContextHolder.getDataSourceKey();
CellData cellData = null;
if (currentProjectDb.equals(dbName)) {
cellData = agent.getCellData(cellTemplateData.getReportTemplateID(),
cellTemplateData.getCellTemplateID(), curPeriod.getCurPeriod());
} else {
try {
ShardingContextHolder.setDataSourceKey(dbName);
cellData = agent.getCellData(cellTemplateData.getReportTemplateID(), cellData = agent.getCellData(cellTemplateData.getReportTemplateID(),
cellTemplateData.getCellTemplateID(), curPeriod.getCurPeriod()); cellTemplateData.getCellTemplateID(), curPeriod.getCurPeriod());
} catch (Exception e) { } else {
LOGGER.warn("get data exception with dbName{} currentDb {}", dbName, currentProjectDb, e); try {
throw e; ShardingContextHolder.setDataSourceKey(dbName);
} finally { cellData = agent.getCellData(cellTemplateData.getReportTemplateID(),
ShardingContextHolder.setDataSourceKey(currentProjectDb); cellTemplateData.getCellTemplateID(), curPeriod.getCurPeriod());
} catch (Exception e) {
LOGGER.warn("get data exception with dbName{} currentDb {}", dbName, currentProjectDb, e);
throw e;
} finally {
ShardingContextHolder.setDataSourceKey(currentProjectDb);
}
} }
}
nullCellDto = ReportCellDataSourceDto.extractFromGroup(bo, curPeriod, cellData, cellTemplateData); nullCellDto = ReportCellDataSourceDto.extractFromGroup(bo, curPeriod, cellData, cellTemplateData);
ds.clear(); ds.clear();
ds.add(nullCellDto); ds.add(nullCellDto);
// todo: fix datasource name by templateList(neo) // todo: fix datasource name by templateList(neo)
MyAsserts.assertNotNull(cellData.getData(), Exceptions.BB_CELL_DATA_NULL); MyAsserts.assertNotNull(cellData.getData(), Exceptions.BB_CELL_DATA_NULL);
// cellValue= RoundValue(cellValue, cellDataType)TODO:maybe fixd round by cellDataTyep(KV neo) // cellValue= RoundValue(cellValue, cellDataType)TODO:maybe fixd round by cellDataTyep(KV neo)
BigDecimal cellValue = new BigDecimal(cellData.getData()).setScale(4, cellValue = new BigDecimal(cellData.getData()).setScale(4,
BigDecimal.ROUND_HALF_DOWN); BigDecimal.ROUND_HALF_DOWN);
nullCellDto.setAmount(cellValue);
Long dataSourceID = saveDataSource(ec, ds, FormulaDataSourceDetailType.ReportCellDataSourceDto, LOGGER.debug("cell static value ");
cellValue, curPeriod.getCurPeriod(), formulaContext.getReportTemplateGroupID()); return cellValue;
saveFormulaBlock(curPeriod.getCurPeriod(), ec, bo.expression(curPeriod.getCurPeriod(), curPeriod.getCurYear()), cellValue, dataSourceID); } finally {
nullCellDto.setAmount(cellValue); Long dataSourceID = saveDataSource(ec, ds, FormulaDataSourceDetailType.ReportCellDataSourceDto,
LOGGER.debug("cell static value "); cellValue, curPeriod.getCurPeriod(), formulaContext.getReportTemplateGroupID());
return cellValue; saveFormulaBlock(curPeriod.getCurPeriod(), ec, bo.expression(curPeriod.getCurPeriod(), curPeriod.getCurYear()), cellValue, dataSourceID);
}
} }
} }
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