|
@ -5,10 +5,13 @@ import com.qs.serve.common.model.annotation.SysLog; |
|
|
import com.qs.serve.common.model.dto.PageVo; |
|
|
import com.qs.serve.common.model.dto.PageVo; |
|
|
import com.qs.serve.common.model.dto.R; |
|
|
import com.qs.serve.common.model.dto.R; |
|
|
import com.qs.serve.common.model.enums.BizType; |
|
|
import com.qs.serve.common.model.enums.BizType; |
|
|
|
|
|
import com.qs.serve.common.model.enums.BudgetLogOptFlag; |
|
|
import com.qs.serve.common.model.enums.SystemModule; |
|
|
import com.qs.serve.common.model.enums.SystemModule; |
|
|
import com.qs.serve.common.util.PageUtil; |
|
|
import com.qs.serve.common.util.PageUtil; |
|
|
import com.qs.serve.common.util.CopierUtil; |
|
|
import com.qs.serve.common.util.CopierUtil; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget; |
|
|
import com.qs.serve.modules.tbs.mapper.TbsBudgetLogMapper; |
|
|
import com.qs.serve.modules.tbs.mapper.TbsBudgetLogMapper; |
|
|
|
|
|
import com.qs.serve.modules.tbs.service.TbsScheduleItemBudgetService; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.ibatis.annotations.Param; |
|
|
import org.apache.ibatis.annotations.Param; |
|
@ -20,6 +23,7 @@ import com.qs.serve.modules.tbs.service.TbsBudgetLogService; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 预算 预算日志 |
|
|
* 预算 预算日志 |
|
@ -34,6 +38,8 @@ public class TbsBudgetLogController { |
|
|
|
|
|
|
|
|
private TbsBudgetLogService tbsBudgetLogService; |
|
|
private TbsBudgetLogService tbsBudgetLogService; |
|
|
private TbsBudgetLogMapper tbsBudgetLogMapper; |
|
|
private TbsBudgetLogMapper tbsBudgetLogMapper; |
|
|
|
|
|
private TbsScheduleItemBudgetService tbsScheduleItemBudgetService; |
|
|
|
|
|
private TbsBudgetLogService budgetLogService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 翻页 |
|
|
* 翻页 |
|
@ -56,9 +62,36 @@ public class TbsBudgetLogController { |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@GetMapping("/getItemAmount") |
|
|
@GetMapping("/getItemAmount") |
|
|
public R<?> getAmount(Long budgetId,Long itemId){ |
|
|
public R<TbsScheduleItemBudget> getAmount(Long budgetId,Long itemId){ |
|
|
BigDecimal amount = tbsBudgetLogMapper.countBudgetItemAmount(budgetId,itemId); |
|
|
LambdaQueryWrapper<TbsScheduleItemBudget> lqw = new LambdaQueryWrapper<>(); |
|
|
return R.ok(amount); |
|
|
lqw.eq(TbsScheduleItemBudget::getBudgetId,budgetId); |
|
|
|
|
|
lqw.eq(TbsScheduleItemBudget::getScheduleItemId,itemId); |
|
|
|
|
|
List<TbsScheduleItemBudget> tbsScheduleItemBudgetList = tbsScheduleItemBudgetService.list(lqw); |
|
|
|
|
|
|
|
|
|
|
|
Optional<TbsScheduleItemBudget> optional = tbsScheduleItemBudgetList.stream().findFirst(); |
|
|
|
|
|
if(optional.isPresent()){ |
|
|
|
|
|
TbsScheduleItemBudget a = optional.get(); |
|
|
|
|
|
LambdaQueryWrapper<TbsBudgetLog> lqwLog = new LambdaQueryWrapper<>(); |
|
|
|
|
|
lqwLog.eq(TbsBudgetLog::getScheduleItemBudgetId,a.getId()); |
|
|
|
|
|
lqwLog.eq(TbsBudgetLog::getBudgetId,budgetId); |
|
|
|
|
|
List<TbsBudgetLog> tbsBudgetLogList = budgetLogService.list(lqwLog); |
|
|
|
|
|
// a.setBudgetLogList(tbsBudgetLogList);
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal finalBudgetAmount = tbsBudgetLogList.stream().filter(b-> BudgetLogOptFlag.getFinalBudgetOptFlag().contains(b.getOptType())).map(TbsBudgetLog::getAmount) |
|
|
|
|
|
.reduce(BigDecimal.ZERO,BigDecimal::add); |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal usedBudgetAmount = tbsBudgetLogList.stream().filter(b->!BudgetLogOptFlag.getFinalBudgetOptFlag().contains(b.getOptType())).map(TbsBudgetLog::getAmount) |
|
|
|
|
|
.reduce(BigDecimal.ZERO,BigDecimal::add); |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal unUsedBudgetAmount = tbsBudgetLogList.stream().map(TbsBudgetLog::getAmount) |
|
|
|
|
|
.reduce(BigDecimal.ZERO,BigDecimal::add); |
|
|
|
|
|
|
|
|
|
|
|
a.setFinalBudgetAmount(finalBudgetAmount); |
|
|
|
|
|
a.setUnUsedBudgetAmount(unUsedBudgetAmount); |
|
|
|
|
|
a.setUsedBudgetAmount(usedBudgetAmount); |
|
|
|
|
|
return R.ok(a); |
|
|
|
|
|
} |
|
|
|
|
|
return R.ok(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|