Commit ec6ec56c authored by zhkwei's avatar zhkwei

CIT--ZC公式完善

parent 0ec02f5a
......@@ -56,81 +56,91 @@ public class ZC extends FunctionBase implements FreeRefFunction {
int curYear = formulaContext.getYear() + year;
// String dbName =
// SpringContextUtil.projectDao.getDbNameWithYearAndOrgId(formulaContext.getOrganizationId(), curYear);
List<CitAssetDetailResultDto> assetDetailResultDtos =
SpringContextUtil.assetsListMapper.getCitAssetDetialResult(assetType, assetDetailType);
List<AssetDetailDataSourceDto> dataSource = new ArrayList<>();
for (CitAssetDetailResultDto x : assetDetailResultDtos) {
AssetDetailDataSourceDto assetDetailDataSourceDto = new AssetDetailDataSourceDto();
assetDetailDataSourceDto.setResultType(KeyValueConfigResultType.Accounting.getCode());
assetDetailDataSourceDto.setAssetNumber(x.getAssetsList().getAssetGroupName());
assetDetailDataSourceDto.setAssetGroupName(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));
assetDetailDataSourceDto.setAccountTotalepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getAccountTotalDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setYearEndValue(FormulaHelper.roundValue(x.getAssetsList().getYearEndValue(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setTaxMonthDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxMonthDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setTaxToCurrentYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxToCurrentYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setTaxCurrentYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxCurrentYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
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);
}
BigDecimal totalData = new BigDecimal("0");
try {
List<CitAssetDetailResultDto> assetDetailResultDtos =
SpringContextUtil.assetsListMapper.getCitAssetDetialResult(assetType, assetDetailType);
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));
assetDetailDataSourceDto.setAccountTotalepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getAccountTotalDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setYearEndValue(FormulaHelper.roundValue(x.getAssetsList().getYearEndValue(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setTaxMonthDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxMonthDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setTaxToCurrentYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxToCurrentYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
assetDetailDataSourceDto.setTaxCurrentYearDepreciationAmount(FormulaHelper.roundValue(x.getAssetsList().getTaxCurrentYearDepreciationAmount(), KeyValueConfigResultType.Accounting, null, formulaContext));
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()
.sorted(Comparator.comparing(AssetDetailDataSourceDto::getAssetGroupName)
.thenComparing(AssetDetailDataSourceDto::getAssetDetailGroupName))
.collect(Collectors.toList());
dataSource = dataSource.stream()
.sorted(Comparator.comparing(AssetDetailDataSourceDto::getAssetGroupName)
.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());
break;
case 2:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountYearDepreciationAmount().doubleValue()).sum());
break;
case 3:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountTotalepreciationAmount().doubleValue()).sum());
break;
case 4:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountMonthDepreciationAmount().doubleValue()).sum());
break;
case 5:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getYearEndValue().doubleValue()).sum());
break;
case 6:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxMonthDepreciationAmount().doubleValue()).sum());
break;
case 7:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxToCurrentYearDepreciationAmount().doubleValue()).sum());
break;
case 8:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxCurrentYearDepreciationAmount().doubleValue()).sum());
break;
case 9:
dataSource = dataSource.stream().filter(a -> a.getIsRetain() != null && a.getIsRetain()).collect(Collectors.toList());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTotalDifferenceAmount().doubleValue()).sum());
break;
case 10:
dataSource = dataSource.stream().filter(a -> a.getIsRetain() != null && a.getIsRetain()).collect(Collectors.toList());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getYearDifferenceAmount().doubleValue()).sum());
break;
default:
break;
switch (dataType) {
case 1:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountAcquisitionValue().doubleValue()).sum());
break;
case 2:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountYearDepreciationAmount().doubleValue()).sum());
break;
case 3:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountTotalepreciationAmount().doubleValue()).sum());
break;
case 4:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getAccountMonthDepreciationAmount().doubleValue()).sum());
break;
case 5:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getYearEndValue().doubleValue()).sum());
break;
case 6:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxMonthDepreciationAmount().doubleValue()).sum());
break;
case 7:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxToCurrentYearDepreciationAmount().doubleValue()).sum());
break;
case 8:
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTaxCurrentYearDepreciationAmount().doubleValue()).sum());
break;
case 9:
dataSource = dataSource.stream().filter(a -> a.getIsRetain() != null && a.getIsRetain()).collect(Collectors.toList());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getTotalDifferenceAmount().doubleValue()).sum());
break;
case 10:
dataSource = dataSource.stream().filter(a -> a.getIsRetain() != null && a.getIsRetain()).collect(Collectors.toList());
totalData = new BigDecimal(dataSource.stream().mapToDouble(a -> a.getYearDifferenceAmount().doubleValue()).sum());
break;
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());
}
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