Commit ec6ec56c authored by zhkwei's avatar zhkwei

CIT--ZC公式完善

parent 0ec02f5a
......@@ -56,16 +56,20 @@ public class ZC extends FunctionBase implements FreeRefFunction {
int curYear = formulaContext.getYear() + year;
// String dbName =
// SpringContextUtil.projectDao.getDbNameWithYearAndOrgId(formulaContext.getOrganizationId(), curYear);
List<AssetDetailDataSourceDto> dataSource = new ArrayList<>();
BigDecimal totalData = new BigDecimal("0");
try {
List<CitAssetDetailResultDto> assetDetailResultDtos =
SpringContextUtil.assetsListMapper.getCitAssetDetialResult(assetType, assetDetailType);
List<AssetDetailDataSourceDto> dataSource = new ArrayList<>();
if(assetDetailResultDtos != null&&assetDetailResultDtos.size()>0){
System.out.println(assetDetailResultDtos.size());
}
for (CitAssetDetailResultDto x : assetDetailResultDtos) {
AssetDetailDataSourceDto assetDetailDataSourceDto = new AssetDetailDataSourceDto();
assetDetailDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode());
assetDetailDataSourceDto.setAssetNumber(x.getAssetsList().getAssetGroupName());
assetDetailDataSourceDto.setAssetGroupName(x.getAssetDetailGroup().getDetailGroupName());
assetDetailDataSourceDto.setAssetDetailGroupName(x.getAssetDetailGroup().getDetailGroupName());
assetDetailDataSourceDto.setAccountAcquisitionValue(FormulaHelper.roundValue(x.getAssetsList().getAccountAcquisitionValue(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setAccountMonthDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getAccountMonthDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setAccountYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
......@@ -90,7 +94,6 @@ public class ZC extends FunctionBase implements FreeRefFunction {
.thenComparing(AssetDetailDataSourceDto::getAssetDetailGroupName))
.collect(Collectors.toList());
BigDecimal totalData = new BigDecimal("0");
switch (dataType) {
case 1:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountAcquisitionValue().doubleValue()).sum());
......@@ -127,10 +130,17 @@ public class ZC extends FunctionBase implements FreeRefFunction {
default:
break;
}
}catch (Exception e){
e.printStackTrace();
logger.error("计算ZC公式报错");
return new NumberEval(0);
}finally {
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.AssetDetailDataSourceDto,
totalData, formulaContext.getPeriod(), formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
saveFormulaBlock(0, ec, formulaExpression, totalData, dataSourceId, formulaContext.getProjectId());
}
return new NumberEval(totalData.doubleValue());
}
}
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