Commit ec6ec56c authored by zhkwei's avatar zhkwei

CIT--ZC公式完善

parent 0ec02f5a
...@@ -56,81 +56,91 @@ public class ZC extends FunctionBase implements FreeRefFunction { ...@@ -56,81 +56,91 @@ 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<CitAssetDetailResultDto> assetDetailResultDtos =
SpringContextUtil.assetsListMapper.getCitAssetDetialResult(assetType, assetDetailType);
List<AssetDetailDataSourceDto> dataSource = new ArrayList<>(); List<AssetDetailDataSourceDto> dataSource = new ArrayList<>();
for (CitAssetDetailResultDto x : assetDetailResultDtos) { BigDecimal totalData = new BigDecimal("0");
AssetDetailDataSourceDto assetDetailDataSourceDto = new AssetDetailDataSourceDto(); try {
assetDetailDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode()); List<CitAssetDetailResultDto> assetDetailResultDtos =
assetDetailDataSourceDto.setAssetNumber(x.getAssetsList().getAssetGroupName()); SpringContextUtil.assetsListMapper.getCitAssetDetialResult(assetType, assetDetailType);
assetDetailDataSourceDto.setAssetGroupName(x.getAssetDetailGroup().getDetailGroupName()); if(assetDetailResultDtos != null&&assetDetailResultDtos.size()>0){
assetDetailDataSourceDto.setAccountAcquisitionValue(FormulaHelper.roundValue(x.getAssetsList().getAccountAcquisitionValue(), KeyValueConfigResultType.Accounting, null, formulaContext)); System.out.println(assetDetailResultDtos.size());
assetDetailDataSourceDto.setAccountMonthDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getAccountMonthDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); }
assetDetailDataSourceDto.setAccountYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); for (CitAssetDetailResultDto x : assetDetailResultDtos) {
assetDetailDataSourceDto.setAccountTotalepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getAccountTotalDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); AssetDetailDataSourceDto assetDetailDataSourceDto = new AssetDetailDataSourceDto();
assetDetailDataSourceDto.setYearEndValue(FormulaHelper.roundValue(x.getAssetsList().getYearEndValue(), KeyValueConfigResultType.Accounting, null, formulaContext)); assetDetailDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode());
assetDetailDataSourceDto.setTaxMonthDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxMonthDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); assetDetailDataSourceDto.setAssetNumber(x.getAssetsList().getAssetGroupName());
assetDetailDataSourceDto.setTaxToCurrentYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxToCurrentYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); assetDetailDataSourceDto.setAssetGroupName(x.getAssetDetailGroup().getDetailGroupName());
assetDetailDataSourceDto.setTaxCurrentYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxCurrentYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); assetDetailDataSourceDto.setAssetDetailGroupName(x.getAssetDetailGroup().getDetailGroupName());
assetDetailDataSourceDto.setTotalDifferenceAmount(FormulaHelper.roundValue(x.getAssetsList().getTotalDifferenceAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); assetDetailDataSourceDto.setAccountAcquisitionValue(FormulaHelper.roundValue(x.getAssetsList().getAccountAcquisitionValue(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setYearDifferenceAmount(FormulaHelper.roundValue(x.getAssetsList().getYearDifferenceAmount(), KeyValueConfigResultType.Accounting, null, formulaContext)); assetDetailDataSourceDto.setAccountMonthDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getAccountMonthDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setDepreciationPeriod(x.getAssetsList().getDepreciationPeriod()); assetDetailDataSourceDto.setAccountYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setTaxDepreciationPeriod(x.getAssetsList().getTaxDepreciationPeriod()); assetDetailDataSourceDto.setAccountTotalepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getAccountTotalDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setIsRetain(x.getAssetsList().getIsRetain()==0?false:true); assetDetailDataSourceDto.setYearEndValue(FormulaHelper.roundValue(x.getAssetsList().getYearEndValue(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setDataType(dataType); assetDetailDataSourceDto.setTaxMonthDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxMonthDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setName(Constant.DataSourceName.AssetListDataSource); assetDetailDataSourceDto.setTaxToCurrentYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxToCurrentYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setOperationType(EnumOperationType.Single.getCode()); assetDetailDataSourceDto.setTaxCurrentYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxCurrentYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
dataSource.add(assetDetailDataSourceDto); assetDetailDataSourceDto.setTotalDifferenceAmount(FormulaHelper.roundValue(x.getAssetsList().getTotalDifferenceAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
} assetDetailDataSourceDto.setYearDifferenceAmount(FormulaHelper.roundValue(x.getAssetsList().getYearDifferenceAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setDepreciationPeriod(x.getAssetsList().getDepreciationPeriod());
assetDetailDataSourceDto.setTaxDepreciationPeriod(x.getAssetsList().getTaxDepreciationPeriod());
assetDetailDataSourceDto.setIsRetain(x.getAssetsList().getIsRetain()==0?false:true);
assetDetailDataSourceDto.setDataType(dataType);
assetDetailDataSourceDto.setName(Constant.DataSourceName.AssetListDataSource);
assetDetailDataSourceDto.setOperationType(EnumOperationType.Single.getCode());
dataSource.add(assetDetailDataSourceDto);
}
dataSource = dataSource.stream() dataSource = dataSource.stream()
.sorted(Comparator.comparing(AssetDetailDataSourceDto::getAssetGroupName) .sorted(Comparator.comparing(AssetDetailDataSourceDto::getAssetGroupName)
.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()); break;
break; case 2:
case 2: totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountYearDepreciationAmount().doubleValue()).sum());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountYearDepreciationAmount().doubleValue()).sum()); break;
break; case 3:
case 3: totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountTotalepreciationAmount().doubleValue()).sum());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountTotalepreciationAmount().doubleValue()).sum()); break;
break; case 4:
case 4: totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountMonthDepreciationAmount().doubleValue()).sum());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountMonthDepreciationAmount().doubleValue()).sum()); break;
break; case 5:
case 5: totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getYearEndValue().doubleValue()).sum());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getYearEndValue().doubleValue()).sum()); break;
break; case 6:
case 6: totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxMonthDepreciationAmount().doubleValue()).sum());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxMonthDepreciationAmount().doubleValue()).sum()); break;
break; case 7:
case 7: totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxToCurrentYearDepreciationAmount().doubleValue()).sum());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxToCurrentYearDepreciationAmount().doubleValue()).sum()); break;
break; case 8:
case 8: totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxCurrentYearDepreciationAmount().doubleValue()).sum());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxCurrentYearDepreciationAmount().doubleValue()).sum()); break;
break; case 9:
case 9: dataSource = dataSource.stream().filter(a -> a.getIsRetain() != null && a.getIsRetain()).collect(Collectors.toList());
dataSource = dataSource.stream().filter(a -> a.getIsRetain() != null && a.getIsRetain()).collect(Collectors.toList()); totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTotalDifferenceAmount().doubleValue()).sum());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTotalDifferenceAmount().doubleValue()).sum()); break;
break; case 10:
case 10: dataSource = dataSource.stream().filter(a -> a.getIsRetain() != null && a.getIsRetain()).collect(Collectors.toList());
dataSource = dataSource.stream().filter(a -> a.getIsRetain() != null && a.getIsRetain()).collect(Collectors.toList()); totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getYearDifferenceAmount().doubleValue()).sum());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getYearDifferenceAmount().doubleValue()).sum()); break;
break; default:
default: break;
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());
} }
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()); 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