12 changed files with 505 additions and 0 deletions
@ -0,0 +1,5 @@ |
|||||
|
|
||||
|
update tbs_budget_condition set brand_id = SUBSTRING_INDEX(target_level_path_ids,'_',1) |
||||
|
|
||||
|
update tbs_budget set center_combo = concat(center_type,'_',center_id) |
||||
|
|
@ -0,0 +1,73 @@ |
|||||
|
package com.qs.serve.modules.bir.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.util.CollectionUtil; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsSchedule; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsScheduleItem; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsScheduleItemBudgetIdDto; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsScheduleItemWithAmount; |
||||
|
import com.qs.serve.modules.tbs.entity.so.TbsScheduleItemSearch; |
||||
|
import com.qs.serve.modules.tbs.mapper.TbsScheduleItemBudget2Mapper; |
||||
|
import com.qs.serve.modules.tbs.mapper.TbsScheduleItemMapper; |
||||
|
import com.qs.serve.modules.tbs.mapper.TbsScheduleMapper; |
||||
|
import com.qs.serve.modules.tbs.service.TbsScheduleItemBudgetService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/12/27 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("bir/budget") |
||||
|
public class BirBudgetScheduleController { |
||||
|
|
||||
|
private final TbsScheduleItemBudgetService scheduleItemBudgetService; |
||||
|
private final TbsScheduleItemBudget2Mapper scheduleItemBudget2Mapper; |
||||
|
private final TbsScheduleItemMapper tbsScheduleItemMapper; |
||||
|
private final TbsScheduleMapper tbsScheduleMapper; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 查询周期使用情况 |
||||
|
* @param query |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/budgetItemUsedList") |
||||
|
public R<List<TbsScheduleItemWithAmount>> queryBudgetItemUsed(TbsScheduleItemSearch query){ |
||||
|
query.initCenterCombo(); |
||||
|
List<TbsScheduleItemBudgetIdDto> scheduleItemBudgetIdDtoList = scheduleItemBudget2Mapper.listItemBudgetIds(query); |
||||
|
List<Long> scheduleItemIds = scheduleItemBudgetIdDtoList.stream().map(TbsScheduleItemBudgetIdDto::getScheduleItemId).collect(Collectors.toList()); |
||||
|
if(CollectionUtil.isEmpty(scheduleItemIds)){ |
||||
|
return R.ok(); |
||||
|
} |
||||
|
List<TbsScheduleItem> scheduleItemList = tbsScheduleItemMapper.selectBatchIds(scheduleItemIds); |
||||
|
List<TbsSchedule> scheduleList = tbsScheduleMapper.selectList(new QueryWrapper<>()); |
||||
|
List<TbsScheduleItemWithAmount> scheduleItemWithAmounts = scheduleItemBudgetService.listScheduleItemAmountByIds(scheduleItemBudgetIdDtoList); |
||||
|
for (TbsScheduleItemWithAmount itemWithAmount : scheduleItemWithAmounts) { |
||||
|
for (TbsScheduleItem scheduleItem : scheduleItemList) { |
||||
|
if(itemWithAmount.getScheduleItemId().equals(scheduleItem.getId())){ |
||||
|
itemWithAmount.setScheduleItemName(scheduleItem.getItemName()); |
||||
|
for (TbsSchedule schedule : scheduleList) { |
||||
|
if(schedule.getId().equals(scheduleItem.getScheduleId())){ |
||||
|
itemWithAmount.setScheduleName(schedule.getName()); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return R.ok(scheduleItemWithAmounts); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.qs.serve.modules.tbs.entity.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/29 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class TbsScheduleItemBudgetIdDto { |
||||
|
|
||||
|
Long scheduleItemId; |
||||
|
|
||||
|
Long scheduleItemBudgetId; |
||||
|
|
||||
|
} |
@ -0,0 +1,63 @@ |
|||||
|
package com.qs.serve.modules.tbs.entity.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/29 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class TbsScheduleItemWithAmount { |
||||
|
|
||||
|
/** |
||||
|
* 周期项ID |
||||
|
*/ |
||||
|
Long scheduleItemId; |
||||
|
|
||||
|
String scheduleName; |
||||
|
|
||||
|
String scheduleItemName; |
||||
|
|
||||
|
/** |
||||
|
* 预算总额 |
||||
|
*/ |
||||
|
BigDecimal finalAmt = BigDecimal.ZERO; |
||||
|
|
||||
|
/** |
||||
|
* 当前占用中的预算 |
||||
|
*/ |
||||
|
BigDecimal allUsingAmt = BigDecimal.ZERO; |
||||
|
|
||||
|
/** |
||||
|
* 申请中的预算占用 |
||||
|
*/ |
||||
|
BigDecimal allCheckingAmt = BigDecimal.ZERO; |
||||
|
|
||||
|
/** |
||||
|
* 费用申请-申请中的预算 |
||||
|
*/ |
||||
|
BigDecimal costUsingAmt = BigDecimal.ZERO; |
||||
|
|
||||
|
/** |
||||
|
* 费用申请-申请中的预算 |
||||
|
*/ |
||||
|
BigDecimal costCheckingAmt = BigDecimal.ZERO; |
||||
|
|
||||
|
/** |
||||
|
* 政策-申请中的预算 |
||||
|
*/ |
||||
|
BigDecimal policyUsingAmt = BigDecimal.ZERO; |
||||
|
|
||||
|
/** |
||||
|
* 政策-申请中的预算 |
||||
|
*/ |
||||
|
BigDecimal policyCheckingAmt = BigDecimal.ZERO; |
||||
|
|
||||
|
/** |
||||
|
* 剩余预算(预算总额-当前占用的预算) |
||||
|
*/ |
||||
|
BigDecimal surplusAmt = BigDecimal.ZERO; |
||||
|
|
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
package com.qs.serve.modules.tbs.entity.so; |
||||
|
|
||||
|
import com.qs.serve.common.util.CollectionUtil; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/12/27 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class TbsScheduleItemSearch { |
||||
|
|
||||
|
/** |
||||
|
* 成本中心组合值列表,格式:centerType_centerId |
||||
|
*/ |
||||
|
private List<String> centerCombos; |
||||
|
|
||||
|
/** |
||||
|
* 周期ID |
||||
|
*/ |
||||
|
private List<String> scheduleItemIds; |
||||
|
|
||||
|
/** |
||||
|
* 品牌ID |
||||
|
*/ |
||||
|
private List<Long> brandIds; |
||||
|
|
||||
|
/** |
||||
|
* 成本中心列表 |
||||
|
*/ |
||||
|
private List<CenterItem> centerList; |
||||
|
|
||||
|
@Data |
||||
|
public static class CenterItem{ |
||||
|
|
||||
|
private String centerType; |
||||
|
|
||||
|
private String centerId; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 调整数据结构 |
||||
|
*/ |
||||
|
public void initCenterCombo(){ |
||||
|
if(CollectionUtil.isNotEmpty(centerList)){ |
||||
|
this.centerCombos = centerList.stream().map(a-> a.getCenterType()+"_"+a.getCenterId()).collect(Collectors.toList()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
package com.qs.serve.modules.tbs.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogPreAmount; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogWithAmount; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsScheduleItemBudgetAmount; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsScheduleItemBudgetIdDto; |
||||
|
import com.qs.serve.modules.tbs.entity.so.TbsScheduleItemSearch; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.apache.ibatis.annotations.Select; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 预算考核期项 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2022-11-08 |
||||
|
*/ |
||||
|
public interface TbsScheduleItemBudget2Mapper extends BaseMapper<TbsScheduleItemBudget> { |
||||
|
|
||||
|
/** |
||||
|
* 查询TbsScheduleItemBudget.id |
||||
|
* @param query |
||||
|
* @return |
||||
|
*/ |
||||
|
List<TbsScheduleItemBudgetIdDto> listItemBudgetIds(@Param("query") TbsScheduleItemSearch query); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 统计Schedule金额 |
||||
|
* @param ids scheduleItemIds |
||||
|
* @param optNumbers 包含 |
||||
|
* @return |
||||
|
*/ |
||||
|
@InterceptorIgnore(tenantLine = "true") |
||||
|
List<TbsBudgetLogWithAmount> getSumAmtInList(@Param("selectIds") List<Long> ids,@Param("optNumbers")List<Integer> optNumbers); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 统计Schedule金额 |
||||
|
* @param ids scheduleItemIds |
||||
|
* @param optNumbers 不包含 |
||||
|
* @return |
||||
|
*/ |
||||
|
@InterceptorIgnore(tenantLine = "true") |
||||
|
List<TbsBudgetLogWithAmount> getSumAmtNotInList(@Param("selectIds") List<Long> ids,@Param("optNumbers")List<Integer> optNumbers); |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 统计审批中的政策,占用多少的预算 |
||||
|
* @param ids |
||||
|
* @param optNumbers |
||||
|
* @return |
||||
|
*/ |
||||
|
@InterceptorIgnore(tenantLine = "true") |
||||
|
List<TbsBudgetLogWithAmount> getPolicyCheckingList(@Param("selectIds") List<Long> ids,@Param("optNumbers")List<Integer> optNumbers); |
||||
|
|
||||
|
/** |
||||
|
* 统计审批中的费用,占用多少的预算 |
||||
|
* @param ids |
||||
|
* @param optNumbers |
||||
|
* @return |
||||
|
*/ |
||||
|
@InterceptorIgnore(tenantLine = "true") |
||||
|
List<TbsBudgetLogWithAmount> getCostCheckingList(@Param("selectIds") List<Long> ids,@Param("optNumbers")List<Integer> optNumbers); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,118 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.qs.serve.modules.tbs.mapper.TbsScheduleItemBudget2Mapper"> |
||||
|
|
||||
|
|
||||
|
<select id="listItemBudgetIds" resultType="com.qs.serve.modules.tbs.entity.dto.TbsScheduleItemBudgetIdDto"> |
||||
|
SELECT |
||||
|
tbs_schedule_item_budget.id as schedule_item_budget_id, |
||||
|
tbs_schedule_item_budget.schedule_item_id |
||||
|
FROM `tbs_schedule_item_budget` |
||||
|
LEFT JOIN tbs_budget on tbs_schedule_item_budget.budget_id = tbs_budget.id |
||||
|
LEFT JOIN tbs_budget_condition on tbs_budget_condition.budget_id = tbs_budget.id |
||||
|
where |
||||
|
tbs_schedule_item_budget.del_flag = 0 |
||||
|
and tbs_budget.del_flag = 0 |
||||
|
and tbs_budget.budget_state = 1 |
||||
|
<if test="query.centerCombos != null and query.centerCombos.size > 0"> |
||||
|
and tbs_budget.center_combo in |
||||
|
<foreach collection="query.centerCombos" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
</if> |
||||
|
<if test="query.centerCombos != null and query.centerCombos.size > 0"> |
||||
|
and |
||||
|
( |
||||
|
tbs_budget.condition_flag = 0 or tbs_budget_condition.brand_id in |
||||
|
<foreach collection="query.brandIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
) |
||||
|
</if> |
||||
|
and tbs_schedule_item_budget.schedule_item_id in |
||||
|
<foreach collection="query.scheduleItemIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
group by tbs_schedule_item_budget.id |
||||
|
</select> |
||||
|
|
||||
|
<select id="getSumAmtInList" resultType="com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogWithAmount"> |
||||
|
select |
||||
|
schedule_item_id as id, |
||||
|
sum(amount) as amt |
||||
|
from tbs_budget_log |
||||
|
where |
||||
|
del_flag = 0 and opt_type in |
||||
|
<foreach collection="optNumbers" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
AND schedule_item_budget_id in |
||||
|
<foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
group by schedule_item_id |
||||
|
</select> |
||||
|
|
||||
|
<select id="getSumAmtNotInList" resultType="com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogWithAmount"> |
||||
|
select |
||||
|
schedule_item_id as id, |
||||
|
sum(amount) as amt |
||||
|
from tbs_budget_log |
||||
|
where |
||||
|
del_flag = 0 and opt_type not in |
||||
|
<foreach collection="optNumbers" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
AND schedule_item_budeget_id in |
||||
|
<foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
group by schedule_item_id |
||||
|
</select> |
||||
|
|
||||
|
<select id="getPolicyCheckingList" resultType="com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogWithAmount"> |
||||
|
select |
||||
|
schedule_item_id as id, |
||||
|
sum(amount) as amt |
||||
|
from tbs_budget_log |
||||
|
left join tzc_policy on tbs_budget_log.policy_id = tzc_policy.id |
||||
|
where |
||||
|
tbs_budget_log.policy_id is not null |
||||
|
and tzc_policy.policy_status = 1 |
||||
|
and tbs_budget_log.del_flag = 0 |
||||
|
and tzc_policy.del_flag = 0 |
||||
|
and opt_type in |
||||
|
<foreach collection="optNumbers" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
AND schedule_item_budeget_id in |
||||
|
<foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
group by schedule_item_id |
||||
|
</select> |
||||
|
|
||||
|
<select id="getCostCheckingList" resultType="com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogWithAmount"> |
||||
|
select |
||||
|
schedule_item_id as id, |
||||
|
sum(amount) as amt |
||||
|
from tbs_budget_log |
||||
|
left join tbs_cost_apply on tbs_budget_log.cost_apply_id = tbs_cost_apply.id |
||||
|
where |
||||
|
tbs_budget_log.cost_apply_id is not null |
||||
|
and tbs_cost_apply.charge_state = 1 |
||||
|
and tbs_budget_log.del_flag = 0 |
||||
|
and tbs_cost_apply.del_flag = 0 |
||||
|
and opt_type in |
||||
|
<foreach collection="optNumbers" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
AND schedule_item_budeget_id in |
||||
|
<foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
group by schedule_item_id |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
|
|
Loading…
Reference in new issue