6 changed files with 389 additions and 5 deletions
@ -0,0 +1,67 @@ |
|||||
|
package com.qs.serve.modules.tbs.entity.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/29 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class TbsBudgetWithAmount { |
||||
|
|
||||
|
/** |
||||
|
* 周期项ID |
||||
|
*/ |
||||
|
String budgetId; |
||||
|
|
||||
|
String budgetName; |
||||
|
|
||||
|
String centerId; |
||||
|
|
||||
|
String centerName; |
||||
|
|
||||
|
String centerType; |
||||
|
|
||||
|
/** |
||||
|
* 预算总额 |
||||
|
*/ |
||||
|
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,65 @@ |
|||||
|
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.TbsBudgetLog; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsCostApply; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogWithAmount; |
||||
|
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 org.apache.ibatis.annotations.Update; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 预算日志 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2023-01-05 |
||||
|
*/ |
||||
|
public interface TbsBudgetLog2Mapper extends BaseMapper<TbsBudgetLog> { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 统计budget金额 |
||||
|
* @param ids budgetId |
||||
|
* @param optNumbers 包含 |
||||
|
* @return |
||||
|
*/ |
||||
|
@InterceptorIgnore(tenantLine = "true") |
||||
|
List<TbsBudgetLogWithAmount> getSumAmtInList(@Param("selectIds") List<Long> ids, @Param("optNumbers")List<Integer> optNumbers); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 统计budget金额 |
||||
|
* @param ids budget_id |
||||
|
* @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.TbsBudgetLog2Mapper"> |
||||
|
|
||||
|
|
||||
|
<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.brandIds != null and query.brandIds.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 |
||||
|
budget_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_budget_id in |
||||
|
<foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
group by budget_id |
||||
|
</select> |
||||
|
|
||||
|
<select id="getSumAmtNotInList" resultType="com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogWithAmount"> |
||||
|
select |
||||
|
budget_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_budget_id in |
||||
|
<foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
group by budget_id |
||||
|
</select> |
||||
|
|
||||
|
<select id="getPolicyCheckingList" resultType="com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogWithAmount"> |
||||
|
select |
||||
|
tbs_budget_log.budget_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_budget_id in |
||||
|
<foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
group by tbs_budget_log.budget_id |
||||
|
</select> |
||||
|
|
||||
|
<select id="getCostCheckingList" resultType="com.qs.serve.modules.tbs.entity.dto.TbsBudgetLogWithAmount"> |
||||
|
select |
||||
|
tbs_budget_log.budget_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_budget_id in |
||||
|
<foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
group by tbs_budget_log.budget_id |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
|
|
Loading…
Reference in new issue