You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
4.8 KiB

<?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>