Browse Source

兼容费用申请和政策的可用预算

contract
Yen 2 years ago
parent
commit
f619a4f743
  1. 18
      src/main/java/com/qs/serve/modules/tbs/entity/TbsBudgetLog.java
  2. 34
      src/main/java/com/qs/serve/modules/tbs/mapper/TbsScheduleItemBudgetMapper.java
  3. 11
      src/main/java/com/qs/serve/modules/tbs/service/TbsBudgetApplicationService.java
  4. 11
      src/main/java/com/qs/serve/modules/tzc/service/TzcPolicyApplication.java

18
src/main/java/com/qs/serve/modules/tbs/entity/TbsBudgetLog.java

@ -175,6 +175,24 @@ public class TbsBudgetLog implements Serializable {
private String activityTheme; private String activityTheme;
/** 政策id */
private Long policyId;
/** 政策编码 */
@Length(max = 30,message = "政策编码长度不能超过30字")
private String policyCode;
/** 政策标题 */
@Length(max = 255,message = "政策标题长度不能超过255字")
private String policyTitle;
/** 政策项id */
private Long policyItemId;
/** 政策项编码 */
@Length(max = 30,message = "政策项编码长度不能超过30字")
private String policyItemCode;
/** 费用申请id */ /** 费用申请id */
private Long costApplyId; private Long costApplyId;

34
src/main/java/com/qs/serve/modules/tbs/mapper/TbsScheduleItemBudgetMapper.java

@ -24,12 +24,19 @@ public interface TbsScheduleItemBudgetMapper extends BaseMapper<TbsScheduleItemB
" LEFT JOIN `tbs_cost_apply` " + " LEFT JOIN `tbs_cost_apply` " +
" ON `tbs_budget_cost_item`.cost_apply_id = `tbs_cost_apply`.id " + " ON `tbs_budget_cost_item`.cost_apply_id = `tbs_cost_apply`.id " +
" WHERE `tbs_cost_apply`.charge_state = 1 OR `tbs_cost_apply`.charge_state = 4 " + " WHERE `tbs_cost_apply`.charge_state = 1 OR `tbs_cost_apply`.charge_state = 4 " +
" AND `tbs_budget_cost_item`.id = #{scheduleItemBudgetId} and `tbs_cost_apply`.id != #{applyId}") " AND `tbs_budget_cost_item`.schedule_item_id = #{scheduleItemBudgetId} and `tbs_cost_apply`.id != #{applyId}")
BigDecimal totalApplyAmount(@Param("scheduleItemBudgetId") Long scheduleItemBudgetId,@Param("applyId") Long applyId); BigDecimal totalApplyAmount(@Param("scheduleItemBudgetId") Long scheduleItemBudgetId,@Param("applyId") Long applyId);
@Select(" SELECT sum(`tbs_budget_cost_item_policy`.policy_item_amount) FROM `tbs_budget_cost_item_policy` " +
" LEFT JOIN `tzc_policy`" +
" ON `tbs_budget_cost_item_policy`.policy_id = `tzc_policy`.id " +
" WHERE `tzc_policy`.policy_status = 1 OR `tzc_policy`.policy_status = 4 " +
" AND `tbs_budget_cost_item_policy`.schedule_item_id = #{scheduleItemBudgetId} and `tzc_policy`.id !=#{policyId};")
BigDecimal totalPolicyAmount(@Param("scheduleItemBudgetId") Long scheduleItemBudgetId,@Param("policyId") Long policyId);
/** /**
* 统计费用申请占用的预算金额 * 统计费用申请占用的预算金额
* 状态:0=未发布1=审批中2=待执行3=完成4-被驳回
* @param budgetId 预算id * @param budgetId 预算id
* @param scheduleItemId 考核期id * @param scheduleItemId 考核期id
* @param applyId 费用申请id(防止驳回后提交重复扣除) * @param applyId 费用申请id(防止驳回后提交重复扣除)
@ -47,10 +54,31 @@ public interface TbsScheduleItemBudgetMapper extends BaseMapper<TbsScheduleItemB
" AND `tbs_budget_log`.schedule_item_id = #{scheduleItemId} " + " AND `tbs_budget_log`.schedule_item_id = #{scheduleItemId} " +
" AND `tbs_cost_apply`.id != #{applyId} " + " AND `tbs_cost_apply`.id != #{applyId} " +
" AND `tbs_cost_apply`.charge_state in (1,2,3) " + " AND `tbs_cost_apply`.charge_state in (1,2,3) " +
" AND opt_type IN (1,4,5,6)") " AND opt_type IN (1,4,5,6,11)")
BigDecimal totalCostAmount(@Param("budgetId") Long budgetId, BigDecimal totalCostAmountByApplyId(@Param("budgetId") Long budgetId,
@Param("scheduleItemId") Long scheduleItemId, @Param("scheduleItemId") Long scheduleItemId,
@Param("applyId") Long applyId); @Param("applyId") Long applyId);
/**
* 统计费用申请占用的预算金额
* 通过状态(0-未提交1-审核中2-已通过待执行3-拒绝4-被驳回5-结束)
* @param budgetId 预算id
* @param scheduleItemId 考核期id
* @param policyId 政策申请id(防止驳回后提交重复扣除)
* @return
*/
@Select("SELECT sum( amount ) FROM `tbs_budget_log` LEFT JOIN `tzc_policy` " +
"ON `tbs_budget_log` .policy_id = tzc_policy.id WHERE `tbs_budget_log`.budget_id = #{budgetId} " +
"AND `tbs_budget_log`.schedule_item_id = #{scheduleItemId} " +
"AND `tzc_policy`.id != #{policyId} " +
"AND `tzc_policy`.policy_status in (1,2,4,5) AND opt_type IN (1,4,5,6,11)")
BigDecimal totalCostAmountByPolicyId(@Param("budgetId") Long budgetId,
@Param("scheduleItemId") Long scheduleItemId,
@Param("policyId") Long policyId);
} }

11
src/main/java/com/qs/serve/modules/tbs/service/TbsBudgetApplicationService.java

@ -221,8 +221,15 @@ public class TbsBudgetApplicationService {
Map<Long,BigDecimal> budgetItemApplyAmountMap = new HashMap<>(scheduleItemList.size()); Map<Long,BigDecimal> budgetItemApplyAmountMap = new HashMap<>(scheduleItemList.size());
for (TbsScheduleItemBudget itemBudget : scheduleItemList) { for (TbsScheduleItemBudget itemBudget : scheduleItemList) {
BigDecimal budgetItemApplyAmount = tbsScheduleItemBudgetMapper.totalApplyAmount(itemBudget.getId(),costApplyId); BigDecimal budgetItemApplyAmount = tbsScheduleItemBudgetMapper.totalApplyAmount(itemBudget.getId(),costApplyId);
budgetItemApplyAmountMap.put(itemBudget.getId(),budgetItemApplyAmount); if(budgetItemApplyAmount==null){
BigDecimal budgetItemAmount = tbsScheduleItemBudgetMapper.totalCostAmount(itemBudget.getBudgetId(),itemBudget.getScheduleItemId(),costApplyId); budgetItemApplyAmount = BigDecimal.ZERO;
}
BigDecimal budgetItemApplyAmount2 = tbsScheduleItemBudgetMapper.totalPolicyAmount(itemBudget.getId(), costApplyId);
if(budgetItemApplyAmount2!=null){
budgetItemApplyAmount.add(budgetItemApplyAmount2);
}
budgetItemApplyAmountMap.put(itemBudget.getId(),budgetItemApplyAmount2);
BigDecimal budgetItemAmount = tbsScheduleItemBudgetMapper.totalCostAmountByApplyId(itemBudget.getBudgetId(),itemBudget.getScheduleItemId(),costApplyId);
//因为结果为负数,需去相反数 //因为结果为负数,需去相反数
budgetItemAmount = budgetItemAmount==null?BigDecimal.ZERO:budgetItemAmount.negate(); budgetItemAmount = budgetItemAmount==null?BigDecimal.ZERO:budgetItemAmount.negate();
budgetItemAmountMap.put(itemBudget.getId(),budgetItemAmount); budgetItemAmountMap.put(itemBudget.getId(),budgetItemAmount);

11
src/main/java/com/qs/serve/modules/tzc/service/TzcPolicyApplication.java

@ -110,13 +110,16 @@ public class TzcPolicyApplication {
//统计费用申请占用金额 //统计费用申请占用金额
Map<Long,BigDecimal> budgetItemApplyAmountMap = new HashMap<>(scheduleItemList.size()); Map<Long,BigDecimal> budgetItemApplyAmountMap = new HashMap<>(scheduleItemList.size());
for (TbsScheduleItemBudget itemBudget : scheduleItemList) { for (TbsScheduleItemBudget itemBudget : scheduleItemList) {
//TODO 需要重新检查这里 BigDecimal budgetItemApplyAmount = tbsScheduleItemBudgetMapper.totalApplyAmount(itemBudget.getId(),0L);
BigDecimal budgetItemApplyAmount = tbsScheduleItemBudgetMapper.totalApplyAmount(itemBudget.getId(),policyId); if(budgetItemApplyAmount==null){
if (budgetItemApplyAmount==null){
budgetItemApplyAmount = BigDecimal.ZERO; budgetItemApplyAmount = BigDecimal.ZERO;
} }
BigDecimal budgetItemApplyAmount2 = tbsScheduleItemBudgetMapper.totalPolicyAmount(itemBudget.getId(), policyId);
if(budgetItemApplyAmount2!=null){
budgetItemApplyAmount.add(budgetItemApplyAmount2);
}
budgetItemApplyAmountMap.put(itemBudget.getId(),budgetItemApplyAmount); budgetItemApplyAmountMap.put(itemBudget.getId(),budgetItemApplyAmount);
BigDecimal budgetItemAmount = tbsScheduleItemBudgetMapper.totalCostAmount(itemBudget.getBudgetId(),itemBudget.getScheduleItemId(),policyId); BigDecimal budgetItemAmount = tbsScheduleItemBudgetMapper.totalCostAmountByPolicyId(itemBudget.getBudgetId(),itemBudget.getScheduleItemId(),policyId);
//因为结果为负数,需去相反数 //因为结果为负数,需去相反数
budgetItemAmount = budgetItemAmount==null?BigDecimal.ZERO:budgetItemAmount.negate(); budgetItemAmount = budgetItemAmount==null?BigDecimal.ZERO:budgetItemAmount.negate();
budgetItemAmountMap.put(itemBudget.getId(),budgetItemAmount); budgetItemAmountMap.put(itemBudget.getId(),budgetItemAmount);

Loading…
Cancel
Save