|
@@ -1163,8 +1163,9 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
|
|
|
List<ProjectCostBudget> allPlan = budgetService.getAllPlanByYear(y);
|
|
|
Boolean isBudget = true;
|
|
|
Map<Integer, List<ProjectCostBudget>> allPlanMap = new HashMap<>();
|
|
|
- List<ProjectCostBudget> parentList = new ArrayList<>();
|
|
|
+ Boolean isOtherBudget = true;
|
|
|
if (allPlan != null && allPlan.size() > 0){
|
|
|
+ List<ProjectCostBudget> parentList = new ArrayList<>();
|
|
|
//如果不为空,根据costType分组
|
|
|
allPlanMap = allPlan.parallelStream()
|
|
|
.collect(Collectors.groupingBy(ProjectCostBudget::getCostType));
|
|
@@ -1177,63 +1178,65 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
|
|
|
parentList = budgetService.listByIds(parentIds);
|
|
|
Map<Long, List<ProjectCostBudget>> map = allPlan.parallelStream()
|
|
|
.collect(Collectors.groupingBy(ProjectCostBudget::getParentId));
|
|
|
- //循环父计划,统计子计划
|
|
|
- for (ProjectCostBudget budget : parentList) {
|
|
|
- BigDecimal noStaffCost = budget.getBudgetCountMoney().subtract(budget.getBudgetStaffCost());
|
|
|
- if (noStaffCost.intValue() == 0){
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (map.get(budget.getId()) != null && map.get(budget.getId()).size() > 0){
|
|
|
- List<ProjectCostBudget> budgetList = map.get(budget.getId());
|
|
|
- //有子计划才设置,没子计划证明有值
|
|
|
- //最小计划开始时间
|
|
|
- LocalDate start = LocalDate.MAX;
|
|
|
- //最大计划开始时间
|
|
|
- LocalDate end = LocalDate.MIN;
|
|
|
- //总天数
|
|
|
- BigDecimal total = new BigDecimal(0);
|
|
|
- //开始月工作日
|
|
|
- BigDecimal startDays =new BigDecimal(0);
|
|
|
- //结束月工作日
|
|
|
- BigDecimal endDays =new BigDecimal(0);
|
|
|
- for (ProjectCostBudget costBudget : budgetList) {
|
|
|
- if (costBudget.getPlanStartTime().isBefore(start)){
|
|
|
- start = costBudget.getPlanStartTime();
|
|
|
- }
|
|
|
- if (costBudget.getPlanEndTime().isAfter(end)){
|
|
|
- end = costBudget.getPlanEndTime();
|
|
|
- }
|
|
|
- total = total.add(costBudget.getPlanDays());
|
|
|
- if (costBudget.getPlanIsTwoMonth() == 0){
|
|
|
- //如果开始时间和最小计划时间是一个月,则直接算入开始工作日
|
|
|
- if (start.getMonthValue() == costBudget.getPlanStartTime().getMonthValue()){
|
|
|
- startDays = startDays.add(costBudget.getPlanDays());
|
|
|
- }else {
|
|
|
- //开始时间和最小计划时间不是一个月,算入结束工作日
|
|
|
- endDays = endDays.add(costBudget.getPlanDays());
|
|
|
+ parentList = parentList.stream().filter(l->l.getBudgetCountMoney().subtract(l.getBudgetStaffCost()).intValue() != 0).collect(Collectors.toList());
|
|
|
+ if (parentList != null && parentList.size() > 0) {
|
|
|
+ //循环父计划,统计子计划
|
|
|
+ for (ProjectCostBudget budget : parentList) {
|
|
|
+ BigDecimal noStaffCost = budget.getBudgetCountMoney().subtract(budget.getBudgetStaffCost());
|
|
|
+ if (map.get(budget.getId()) != null && map.get(budget.getId()).size() > 0) {
|
|
|
+ List<ProjectCostBudget> budgetList = map.get(budget.getId());
|
|
|
+ //有子计划才设置,没子计划证明有值
|
|
|
+ //最小计划开始时间
|
|
|
+ LocalDate start = LocalDate.MAX;
|
|
|
+ //最大计划开始时间
|
|
|
+ LocalDate end = LocalDate.MIN;
|
|
|
+ //总天数
|
|
|
+ BigDecimal total = new BigDecimal(0);
|
|
|
+ //开始月工作日
|
|
|
+ BigDecimal startDays = new BigDecimal(0);
|
|
|
+ //结束月工作日
|
|
|
+ BigDecimal endDays = new BigDecimal(0);
|
|
|
+ for (ProjectCostBudget costBudget : budgetList) {
|
|
|
+ if (costBudget.getPlanStartTime().isBefore(start)) {
|
|
|
+ start = costBudget.getPlanStartTime();
|
|
|
+ }
|
|
|
+ if (costBudget.getPlanEndTime().isAfter(end)) {
|
|
|
+ end = costBudget.getPlanEndTime();
|
|
|
}
|
|
|
+ total = total.add(costBudget.getPlanDays());
|
|
|
+ if (costBudget.getPlanIsTwoMonth() == 0) {
|
|
|
+ //如果开始时间和最小计划时间是一个月,则直接算入开始工作日
|
|
|
+ if (start.getMonthValue() == costBudget.getPlanStartTime().getMonthValue()) {
|
|
|
+ startDays = startDays.add(costBudget.getPlanDays());
|
|
|
+ } else {
|
|
|
+ //开始时间和最小计划时间不是一个月,算入结束工作日
|
|
|
+ endDays = endDays.add(costBudget.getPlanDays());
|
|
|
+ }
|
|
|
|
|
|
- }else {
|
|
|
- startDays = startDays.add(costBudget.getPlanStartMonthDays());
|
|
|
- endDays = endDays.add(costBudget.getPlanEndMonthDays());
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ startDays = startDays.add(costBudget.getPlanStartMonthDays());
|
|
|
+ endDays = endDays.add(costBudget.getPlanEndMonthDays());
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- budget.setPlanStartTime(start);
|
|
|
- budget.setPlanEndTime(end);
|
|
|
- budget.setPlanDays(total);
|
|
|
- //如果没跨月
|
|
|
- if (start.getMonthValue() == end.getMonthValue()){
|
|
|
- budget.setPlanIsTwoMonth(0);
|
|
|
- budget.setPlanStartMoney(noStaffCost);
|
|
|
- }else {
|
|
|
- //跨月
|
|
|
- budget.setPlanIsTwoMonth(1);
|
|
|
- BigDecimal decimal = startDays.divide(total, 2, BigDecimal.ROUND_HALF_UP).multiply(noStaffCost);
|
|
|
- budget.setPlanStartMoney(decimal);
|
|
|
- budget.setPlanEndMoney(noStaffCost.subtract(decimal));
|
|
|
+ }
|
|
|
+ budget.setPlanStartTime(start);
|
|
|
+ budget.setPlanEndTime(end);
|
|
|
+ budget.setPlanDays(total);
|
|
|
+ //如果没跨月
|
|
|
+ if (start.getMonthValue() == end.getMonthValue()) {
|
|
|
+ budget.setPlanIsTwoMonth(0);
|
|
|
+ budget.setPlanStartMoney(noStaffCost);
|
|
|
+ } else {
|
|
|
+ //跨月
|
|
|
+ budget.setPlanIsTwoMonth(1);
|
|
|
+ BigDecimal decimal = startDays.divide(total, 2, BigDecimal.ROUND_HALF_UP).multiply(noStaffCost);
|
|
|
+ budget.setPlanStartMoney(decimal);
|
|
|
+ budget.setPlanEndMoney(noStaffCost.subtract(decimal));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ }else {
|
|
|
+ isOtherBudget = false;
|
|
|
}
|
|
|
|
|
|
}else {
|