|
|
@ -1,10 +1,8 @@ |
|
|
|
package com.demo.t20230704; |
|
|
|
|
|
|
|
import com.demo.cost.TbsMapper; |
|
|
|
import com.demo.cost.entity.JslTbsActivity; |
|
|
|
import com.demo.cost.entity.JslTbsBudgetCostItem; |
|
|
|
import com.demo.cost.entity.JslVtbFundFlow; |
|
|
|
import com.demo.cost.entity.XltCheckCostItem; |
|
|
|
import com.demo.cost.entity.*; |
|
|
|
import com.demo.jsl.entity.user.JslUser; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import org.junit.Test; |
|
|
|
import org.noear.wood.DbContext; |
|
|
@ -22,14 +20,15 @@ public class SyncNotCheckMain { |
|
|
|
|
|
|
|
/** 查询未完成的活动 */ |
|
|
|
String sql_cost_not_do_cancel = "select " + |
|
|
|
" cost.charge_theme, "+ |
|
|
|
" act.* "+ |
|
|
|
" from tbs_activity act " + |
|
|
|
" left join tbs_cost_apply cost on act.cost_apply_id = cost.id " + |
|
|
|
" where cost.vtb_sync=2 and cost.do_cancel_flag = 0 " + |
|
|
|
" where cost.vtb_sync=2 and cost.do_cancel_flag !=2 " + |
|
|
|
" order by cost_apply_id"; |
|
|
|
|
|
|
|
/** 更新已完成的 */ |
|
|
|
String sql_update_do_cancel = "update tbs_cost_apply set do_cancel_flag = 1 where id = ?"; |
|
|
|
String sql_update_do_cancel = "update tbs_cost_apply set do_cancel_flag = 2 where id = ?"; |
|
|
|
|
|
|
|
/** 查询销路通的不予核销记录 */ |
|
|
|
String sql_xlt_check_cost = |
|
|
@ -53,10 +52,11 @@ public class SyncNotCheckMain { |
|
|
|
/** 统计活动的不予核销 */ |
|
|
|
String sql_sum_release = "SELECT sum(used_amount) FROM `vtb_fund_flow` where activity_id = ? and fund_type = 'release'"; |
|
|
|
|
|
|
|
|
|
|
|
//删除历史记录
|
|
|
|
String del_fund_flow = "delete from vtb_fund_flow where remark = 'byCancel_1' and activity_id = ?"; |
|
|
|
|
|
|
|
String del_budget_log = "delete from tbs_budget_log where remark = 'byCancel_1' and activity_id = ?"; |
|
|
|
|
|
|
|
@Test |
|
|
|
@SneakyThrows |
|
|
|
public void doMain(){ |
|
|
@ -73,7 +73,12 @@ public class SyncNotCheckMain { |
|
|
|
List<XltCheckCostItem> checkCostItemList = xltDbContext.sql(sql_xlt_check_cost,tbsActivity.getActivityCode()).getList(XltCheckCostItem.class); |
|
|
|
for (XltCheckCostItem costItem : checkCostItemList) { |
|
|
|
|
|
|
|
String sql_budget_cost_item = "select * from tbs_budget_cost_item where activity_id = ?"; |
|
|
|
String sql_budget_cost_item = "select" + |
|
|
|
" tbs_budget.budget_code," + |
|
|
|
" tbs_budget_cost_item.*" + |
|
|
|
" from tbs_budget_cost_item" + |
|
|
|
" left join tbs_budget on tbs_budget_cost_item.budget_id = tbs_budget.id " + |
|
|
|
" where tbs_budget_cost_item.activity_id = ?"; |
|
|
|
JslTbsBudgetCostItem currCostItem = jslDbContext.sql(sql_budget_cost_item, tbsActivity.getId()).getItem(JslTbsBudgetCostItem.class); |
|
|
|
if(currCostItem==null||currCostItem.getId()==null){ |
|
|
|
System.out.println("没有命中核销的费用编码:"+ tbsActivity.getCostCode()); |
|
|
@ -82,6 +87,7 @@ public class SyncNotCheckMain { |
|
|
|
|
|
|
|
//删除历史记录
|
|
|
|
jslDbContext.sql(del_fund_flow,tbsActivity.getId()).execute(); |
|
|
|
jslDbContext.sql(del_budget_log,tbsActivity.getId()).execute(); |
|
|
|
//添加不再支付记录
|
|
|
|
BigDecimal amt = costItem.getApplyAmt(); |
|
|
|
JslVtbFundFlow fundFlow = new JslVtbFundFlow(); |
|
|
@ -119,6 +125,9 @@ public class SyncNotCheckMain { |
|
|
|
fundFlow.setRemark("byCancel_1"); |
|
|
|
jslDbContext.table("vtb_fund_flow").setEntity(fundFlow).insert(); |
|
|
|
|
|
|
|
JslTbsBudgetLog budgetLog = this.buildTbsBudgetLog(4,currCostItem,amt, tbsActivity); |
|
|
|
budgetLog.setTenantId("001"); |
|
|
|
jslDbContext.table("tbs_budget_log").setEntity(budgetLog).insert(); |
|
|
|
|
|
|
|
BigDecimal totalRes = BigDecimal.ZERO; |
|
|
|
Object val = jslDbContext.sql(sql_sum_release,tbsActivity.getId()).getValue(); |
|
|
@ -135,7 +144,6 @@ public class SyncNotCheckMain { |
|
|
|
updAct.setReleaseAmount(totalRes); |
|
|
|
updAct.setId(tbsActivity.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
jslDbContext.sql(sql_update_do_cancel,actList.get(0).getCostApplyId()).execute(); |
|
|
|
System.out.println("完成"+count+"/"+totalCost+":CostApplyId="+actList.get(0).getCostApplyId()); |
|
|
@ -144,4 +152,58 @@ public class SyncNotCheckMain { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 费用申请相关 |
|
|
|
* @param optType |
|
|
|
* @param item |
|
|
|
* @param amount |
|
|
|
* @param activity |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public JslTbsBudgetLog buildTbsBudgetLog(Integer optType, JslTbsBudgetCostItem item, BigDecimal amount, Activity0704 activity) { |
|
|
|
BigDecimal amountAmt = amount; |
|
|
|
if(amountAmt.compareTo(BigDecimal.ZERO)<=0){ |
|
|
|
amountAmt = amountAmt.negate(); |
|
|
|
} |
|
|
|
JslTbsBudgetLog budgetLog = new JslTbsBudgetLog(); |
|
|
|
budgetLog.setBudgetId(item.getBudgetId()); |
|
|
|
budgetLog.setBudgetCode(item.getBudgetCode()); |
|
|
|
budgetLog.setOptType(optType); |
|
|
|
budgetLog.setOptUserId("0"); |
|
|
|
budgetLog.setOptUserCode("0"); |
|
|
|
budgetLog.setOptUserName("系统导入"); |
|
|
|
budgetLog.setAmount(amountAmt); |
|
|
|
budgetLog.setScheduleId(item.getScheduleId()); |
|
|
|
budgetLog.setScheduleItemId(item.getScheduleItemId()); |
|
|
|
budgetLog.setScheduleItemBudgetId(item.getScheduleItemBudgetId()); |
|
|
|
budgetLog.setItemName(item.getScheduleItemName()); |
|
|
|
budgetLog.setStartDate(item.getActStartDate().atStartOfDay()); |
|
|
|
budgetLog.setEndDate(item.getActEndDate().atStartOfDay()); |
|
|
|
budgetLog.setSubjectId(item.getSubjectId()); |
|
|
|
budgetLog.setSubjectCode(item.getSubjectCode()); |
|
|
|
budgetLog.setSubjectName(item.getSubjectName()); |
|
|
|
budgetLog.setCenterId(item.getCenterId()); |
|
|
|
budgetLog.setCenterCode(item.getCenterCode()); |
|
|
|
budgetLog.setCenterName(item.getCenterName()); |
|
|
|
budgetLog.setCenterType(item.getCenterType()); |
|
|
|
budgetLog.setSupplierId(item.getSupplierId()); |
|
|
|
budgetLog.setSupplierCode(item.getSupplierCode()); |
|
|
|
budgetLog.setSupplierName(item.getSupplierName()); |
|
|
|
budgetLog.setActivityId(item.getActivityId()); |
|
|
|
budgetLog.setActivityCode(item.getActivityCode()); |
|
|
|
budgetLog.setActivityTheme(activity.getActTitle()); |
|
|
|
budgetLog.setCostApplyId(activity.getCostApplyId()); |
|
|
|
budgetLog.setCostApplyCode(activity.getCostCode()); |
|
|
|
budgetLog.setCostApplyTheme(activity.getCostTheme()); |
|
|
|
budgetLog.setTargetType(item.getTargetType()); |
|
|
|
budgetLog.setTargetId(item.getTargetId()); |
|
|
|
budgetLog.setTargetCode(item.getTargetCode()); |
|
|
|
budgetLog.setTargetName(item.getTargetName()); |
|
|
|
budgetLog.setTargetLevelPathIds(item.getTargetLevelPathIds()); |
|
|
|
budgetLog.setTargetLevelPathNames(item.getTargetLevelPathNames()); |
|
|
|
budgetLog.setRemark("byCancel_1"); |
|
|
|
return budgetLog; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|