|
@@ -306,47 +306,54 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
String responsibilityCode = accountShare.getResponsibilityCode();
|
|
|
List<CostCostingGroup> costingGroups = map.get(responsibilityCode);
|
|
|
if (CollUtil.isEmpty(costingGroups)) {
|
|
|
- return BigDecimal.ZERO;
|
|
|
- }
|
|
|
- BigDecimal costAmount = BigDecimal.ZERO;
|
|
|
- List<Allocation> all = new ArrayList<>();
|
|
|
- if (!costList.isEmpty()) {
|
|
|
- all = costList.stream().filter(i -> i.getTargetResponsibilityCode().equals(responsibilityCode)).collect(Collectors.toList());
|
|
|
- }
|
|
|
- // 计算方式 0是合并计算 1是分开计算
|
|
|
- if (calcType == 0) {
|
|
|
- costAmount = costingGroups.stream().map(CostCostingGroup::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- if (!all.isEmpty()) {
|
|
|
-
|
|
|
- BigDecimal bigDecimal = all.stream()
|
|
|
- .map(Allocation::getAmount)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
-
|
|
|
- if (Objects.nonNull(bigDecimal)) {
|
|
|
- costAmount = costAmount.add(bigDecimal);
|
|
|
- }
|
|
|
+ List<Allocation> all = costList.stream().filter(i -> i.getTargetResponsibilityCode().equals(responsibilityCode)).collect(Collectors.toList());
|
|
|
+ if (CollUtil.isEmpty(all) || isShareCost == 0) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
}
|
|
|
-
|
|
|
+ BigDecimal reduce = all.stream().map(Allocation::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ return reduce;
|
|
|
} else {
|
|
|
- if (StrUtil.isBlank(accountingCodes)) {
|
|
|
- return BigDecimal.ZERO;
|
|
|
+ BigDecimal costAmount = BigDecimal.ZERO;
|
|
|
+ List<Allocation> all = new ArrayList<>();
|
|
|
+ if (!costList.isEmpty()) {
|
|
|
+ all = costList.stream().filter(i -> i.getTargetResponsibilityCode().equals(responsibilityCode)).collect(Collectors.toList());
|
|
|
}
|
|
|
-
|
|
|
- ArrayList<String> accountCodes = CollUtil.newArrayList(accountingCodes.split(StrUtil.COMMA));
|
|
|
- List<CostCostingGroup> costGroups = costingGroups.stream().filter(i -> accountCodes.contains(i.getAccountCode())).collect(Collectors.toList());
|
|
|
- costAmount = costGroups.stream().map(CostCostingGroup::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- if (isShareCost == 1) {
|
|
|
+ // 计算方式 0是合并计算 1是分开计算
|
|
|
+ if (calcType == 0) {
|
|
|
+ costAmount = costingGroups.stream().map(CostCostingGroup::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
if (!all.isEmpty()) {
|
|
|
+
|
|
|
BigDecimal bigDecimal = all.stream()
|
|
|
.map(Allocation::getAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
if (Objects.nonNull(bigDecimal)) {
|
|
|
costAmount = costAmount.add(bigDecimal);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (StrUtil.isBlank(accountingCodes)) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<String> accountCodes = CollUtil.newArrayList(accountingCodes.split(StrUtil.COMMA));
|
|
|
+ List<CostCostingGroup> costGroups = costingGroups.stream().filter(i -> accountCodes.contains(i.getAccountCode())).collect(Collectors.toList());
|
|
|
+ costAmount = costGroups.stream().map(CostCostingGroup::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ if (isShareCost == 1) {
|
|
|
+ if (!all.isEmpty()) {
|
|
|
+ BigDecimal bigDecimal = all.stream()
|
|
|
+ .map(Allocation::getAmount)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ if (Objects.nonNull(bigDecimal)) {
|
|
|
+ costAmount = costAmount.add(bigDecimal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ return costAmount;
|
|
|
}
|
|
|
- return costAmount;
|
|
|
}
|
|
|
|
|
|
|