6 changed files with 165 additions and 9 deletions
@ -0,0 +1,18 @@ |
|||||
|
package com.qs.serve.modules.tbs.entity.dto; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/7/21 |
||||
|
*/ |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
public class TbsCenterGoodsGroupDTO { |
||||
|
|
||||
|
String targetType; |
||||
|
|
||||
|
String targetId; |
||||
|
|
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.qs.serve.modules.tbs.mapper; |
||||
|
|
||||
|
import com.qs.serve.modules.tbs.entity.TbsActivityCenterGoods; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/7/21 |
||||
|
*/ |
||||
|
public interface TbsBudgetMatchMapper { |
||||
|
|
||||
|
/** |
||||
|
* 通过TbsActivityCenterGoods获取匹配条件的预算 |
||||
|
* @param centerGoods |
||||
|
* @return |
||||
|
*/ |
||||
|
List<TbsScheduleItemBudget> getTbsScheduleItemsByCenterGoods(@Param("query") TbsActivityCenterGoods centerGoods); |
||||
|
|
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
<?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"/> |
||||
|
</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, |
||||
|
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.opt_type 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) 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) 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 ( |
||||
|
<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> |
Loading…
Reference in new issue