Commit ec6ec56c authored by zhkwei's avatar zhkwei

CIT--ZC公式完善

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