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.
67 lines
3.6 KiB
67 lines
3.6 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.TbsBudgetMatchMapper">
|
|
|
|
<resultMap id="tbsScheduleItemBudgetMap" type="com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget" >
|
|
<result property="id" column="id"/>
|
|
<result property="scheduleId" column="schedule_id"/>
|
|
<result property="scheduleItemId" column="schedule_item_id"/>
|
|
<result property="itemName" column="item_name"/>
|
|
<result property="startDate" column="start_date"/>
|
|
<result property="endDate" column="end_date"/>
|
|
<result property="budgetId" column="budget_id"/>
|
|
<result property="budgetAmount" column="budget_amount"/>
|
|
<result property="preDispatchAmount" column="pre_dispatch_amount"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="finalBudgetAmount" column="final_budget_amount"/>
|
|
<result property="usedBudgetAmount" column="used_budget_amount"/>
|
|
<result property="unUsedBudgetAmount" column="un_used_budget_amount"/>
|
|
<result property="budgetConditionFlag" column="budget_condition_flag"/>
|
|
<result property="budgetSubjectId" column="subject_id"/>
|
|
<result property="conditionGoodsIds" column="condition_goods_ids"/>
|
|
<result property="budgetName" column="budget_name"/>
|
|
<result property="budgetCode" column="budget_code"/>
|
|
</resultMap>
|
|
|
|
|
|
<select id="getTbsScheduleItemsByCenterGoods"
|
|
resultType="com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget">
|
|
select
|
|
tsib.*,
|
|
temp_tbg1.amt un_used_budget_amount,
|
|
temp_tbg2.amt final_budget_amount,
|
|
temp_tbg3.amt used_budget_amount,
|
|
tb.condition_flag budget_condition_flag,
|
|
tb.subject_id subject_id,
|
|
tb.budget_code budget_name,
|
|
tb.budget_number budget_code,
|
|
tbc.target_level_path_ids condition_goods_ids
|
|
from tbs_schedule_item_budget tsib
|
|
left join tbs_budget tb on tsib.budget_id = tb.id
|
|
left join tbs_budget_condition tbc on tbc.budget_id = tb.id
|
|
left join
|
|
(select sum(tbg.amount) amt,tbg.schedule_item_budget_id from tbs_budget_log tbg where tbg.del_flag = 0 GROUP BY tbg.schedule_item_budget_id) temp_tbg1
|
|
on temp_tbg1.schedule_item_budget_id = tsib.id
|
|
left join
|
|
(select sum(tbg2.amount) amt,tbg2.schedule_item_budget_id from tbs_budget_log tbg2 where tbg2.opt_type in(0,2,3) and tbg2.del_flag = 0 GROUP BY tbg2.schedule_item_budget_id) temp_tbg2
|
|
on temp_tbg2.schedule_item_budget_id = tsib.id
|
|
left join
|
|
(select sum(tbg3.amount) amt,tbg3.schedule_item_budget_id from tbs_budget_log tbg3 where tbg3.opt_type not in(0,2,3) and tbg3.del_flag = 0 GROUP BY tbg3.schedule_item_budget_id) temp_tbg3
|
|
on temp_tbg3.schedule_item_budget_id = tsib.id
|
|
where 1=1
|
|
AND (tb.subject_id = 0 OR tb.subject_id = #{query.subjectId} )
|
|
AND tb.center_id = #{query.centerId}
|
|
AND tb.center_type = #{query.centerType}
|
|
AND tb.budget_state = 1
|
|
AND tsib.start_date <= #{query.actStartDate}
|
|
AND tsib.end_date >= #{query.actEndDate}
|
|
|
|
AND ( tb.condition_flag =0 or
|
|
<foreach collection="query.queryGoodsGroups" item ="item" index="i" open="(" close=")" separator="or">
|
|
( tbc.target_type=#{item.targetType} and tbc.target_id = #{item.targetId} )
|
|
</foreach>
|
|
)
|
|
</select>
|
|
</mapper>
|
|
|