Browse Source

拼接匹配规则

v1.0
Yen 2 years ago
parent
commit
2915ec393e
  1. 51
      src/main/java/com/qs/serve/modules/tbs/common/util/TbsBudgetLogBuildUtil.java
  2. 3
      src/main/java/com/qs/serve/modules/tbs/entity/TbsCostApply.java
  3. 25
      src/main/java/com/qs/serve/modules/tbs/entity/vo/TbsBudgetTableResultVo.java
  4. 19
      src/main/java/com/qs/serve/modules/tbs/service/TbsBudgetMatchApplication.java
  5. 7
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java
  6. 154
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java
  7. 6
      src/main/resources/mapper/tbs/TbsBudgetMatchMapper.xml
  8. 8
      src/main/resources/mapper/tbs/TbsScheduleItemBudgetMapper.xml

51
src/main/java/com/qs/serve/modules/tbs/common/util/TbsBudgetLogBuildUtil.java

@ -101,6 +101,57 @@ public class TbsBudgetLogBuildUtil {
return budgetLog; return budgetLog;
} }
/**
* 费用申请相关
* @param optType
* @param sysUser
* @param costApply
* @param item
* @param centerGoods
* @param amount
* @param activity
* @return
*/
public static TbsBudgetLog buildTbsBudgetLog(BudgetLogOptFlag optType, SysUser sysUser, TbsCostApply costApply, TbsScheduleItemBudget item, TbsActivityCenterGoods centerGoods, BigDecimal amount, TbsActivity activity) {
TbsBudgetLog budgetLog = new TbsBudgetLog();
budgetLog.setBudgetId(item.getBudgetId());
budgetLog.setBudgetCode(item.getBudgetCode());
budgetLog.setOptType(optType.getCode());
budgetLog.setOptUserId(sysUser.getId());
budgetLog.setOptUserCode(sysUser.getCode());
budgetLog.setOptUserName(sysUser.getName());
budgetLog.setAmount(buildAmount(amount,optType));
budgetLog.setScheduleId(item.getScheduleId());
budgetLog.setScheduleItemId(item.getScheduleItemId());
budgetLog.setScheduleItemBudgetId(centerGoods.getScheduleItemBudgetId());
budgetLog.setItemName(item.getItemName());
budgetLog.setStartDate(centerGoods.getActStartDate().atStartOfDay());
budgetLog.setEndDate(centerGoods.getActEndDate().atStartOfDay());
budgetLog.setSubjectId(centerGoods.getSubjectId());
budgetLog.setSubjectCode(centerGoods.getSubjectCode());
budgetLog.setSubjectName(centerGoods.getSubjectName());
budgetLog.setCenterId(centerGoods.getCenterId());
budgetLog.setCenterCode(centerGoods.getCenterCode());
budgetLog.setCenterName(centerGoods.getCenterName());
budgetLog.setCenterType(centerGoods.getCenterType());
budgetLog.setSupplierId(centerGoods.getSupplierId());
budgetLog.setSupplierCode(centerGoods.getSupplierCode());
budgetLog.setSupplierName(centerGoods.getSupplierName());
budgetLog.setActivityId(centerGoods.getActivityId());
budgetLog.setActivityCode(centerGoods.getActivityCode());
budgetLog.setActivityTheme(activity.getActTitle());
budgetLog.setCostApplyId(costApply.getId());
budgetLog.setCostApplyCode(costApply.getCode());
budgetLog.setCostApplyTheme(costApply.getChargeTheme());
budgetLog.setTargetType(centerGoods.getTargetType());
budgetLog.setTargetId(centerGoods.getTargetId());
budgetLog.setTargetCode(centerGoods.getTargetCode());
budgetLog.setTargetName(centerGoods.getTargetName());
budgetLog.setTargetLevelPathIds(centerGoods.getTargetLevelPathIds());
budgetLog.setTargetLevelPathNames(centerGoods.getTargetLevelPathNames());
return budgetLog;
}
/** /**
* 政策相关 * 政策相关
* @param optType * @param optType

3
src/main/java/com/qs/serve/modules/tbs/entity/TbsCostApply.java

@ -63,6 +63,9 @@ public class TbsCostApply implements Serializable {
@Length(max = 255,message = "备注长度不能超过255字") @Length(max = 255,message = "备注长度不能超过255字")
private String remark; private String remark;
/** 匹配规则类型 */
private Integer matchType;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)

25
src/main/java/com/qs/serve/modules/tbs/entity/vo/TbsBudgetTableResultVo.java

@ -0,0 +1,25 @@
package com.qs.serve.modules.tbs.entity.vo;
import com.qs.serve.modules.tbs.entity.TbsActivity;
import com.qs.serve.modules.tbs.entity.TbsActivityCenterGoods;
import com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* @author YenHex
* @since 2022/12/6
*/
@Data
public class TbsBudgetTableResultVo {
private TbsBudgetTableVo tableVo;
private List<TbsActivityCenterGoods> activityCenterGoodsList;
private Map<Long, TbsScheduleItemBudget> matchItemBudgetsMap;
}

19
src/main/java/com/qs/serve/modules/tbs/service/TbsBudgetMatchApplication.java

@ -6,10 +6,12 @@ import com.qs.serve.modules.tbs.entity.TbsActivity;
import com.qs.serve.modules.tbs.entity.TbsActivityCenterGoods; import com.qs.serve.modules.tbs.entity.TbsActivityCenterGoods;
import com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget; import com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget;
import com.qs.serve.modules.tbs.entity.dto.TbsCenterGoodsGroupDTO; import com.qs.serve.modules.tbs.entity.dto.TbsCenterGoodsGroupDTO;
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableResultVo;
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo; import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo;
import com.qs.serve.modules.tbs.mapper.TbsBudgetMatchMapper; import com.qs.serve.modules.tbs.mapper.TbsBudgetMatchMapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -29,7 +31,7 @@ public class TbsBudgetMatchApplication {
private final TbsActivityService activityService; private final TbsActivityService activityService;
private final TbsBudgetMatchMapper budgetMatchMapper; private final TbsBudgetMatchMapper budgetMatchMapper;
public TbsBudgetTableVo buildResultTable(Long costApplyId){ public TbsBudgetTableResultVo getMatchResult(Long costApplyId,boolean buildTable){
List<TbsActivity> activityList = activityService.listByCostApplyId(costApplyId); List<TbsActivity> activityList = activityService.listByCostApplyId(costApplyId);
Map<Long,TbsActivity> activityMap = new HashMap<>(activityList.size()); Map<Long,TbsActivity> activityMap = new HashMap<>(activityList.size());
for (TbsActivity activity : activityList) { for (TbsActivity activity : activityList) {
@ -63,7 +65,19 @@ public class TbsBudgetMatchApplication {
} }
} }
} }
//TODO 拼接Table,要重新设计显示内容 TbsBudgetTableResultVo resultVo = new TbsBudgetTableResultVo();
resultVo.setActivityCenterGoodsList(activityCenterGoodsList);
resultVo.setMatchItemBudgetsMap(matchItemBudgetsMap);
if(buildTable){
//拼接Table,要重新设计显示内容
TbsBudgetTableVo tableVo = buildTbsBudgetTableVo(activityMap, activityCenterGoodsList, matchItemBudgetsMap);
resultVo.setTableVo(tableVo);
}
return resultVo;
}
@NotNull
private TbsBudgetTableVo buildTbsBudgetTableVo(Map<Long, TbsActivity> activityMap, List<TbsActivityCenterGoods> activityCenterGoodsList, Map<Long, TbsScheduleItemBudget> matchItemBudgetsMap) {
List<TbsBudgetTableVo.TopTheadHeader> topTheadHeaderList = new ArrayList<>(); List<TbsBudgetTableVo.TopTheadHeader> topTheadHeaderList = new ArrayList<>();
List<TbsBudgetTableVo.TableValue> tableValueList = new ArrayList<>(); List<TbsBudgetTableVo.TableValue> tableValueList = new ArrayList<>();
List<TbsBudgetTableVo.LeftTheadHeader> leftTheadHeaderList = new ArrayList<>(); List<TbsBudgetTableVo.LeftTheadHeader> leftTheadHeaderList = new ArrayList<>();
@ -118,7 +132,6 @@ public class TbsBudgetMatchApplication {
tableData.setTableValueList(tableValueList); tableData.setTableValueList(tableValueList);
tableData.setTopTheadHeaderList(topTheadHeaderList); tableData.setTopTheadHeaderList(topTheadHeaderList);
tableData.setLeftTheadHeaderList(leftTheadHeaderList); tableData.setLeftTheadHeaderList(leftTheadHeaderList);
//TODO 关联通用数据
return tableData; return tableData;
} }

7
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java

@ -27,6 +27,7 @@ import com.qs.serve.modules.tbs.common.TbsGoodsType;
import com.qs.serve.modules.tbs.entity.*; import com.qs.serve.modules.tbs.entity.*;
import com.qs.serve.modules.tbs.entity.bo.*; import com.qs.serve.modules.tbs.entity.bo.*;
import com.qs.serve.modules.tbs.mapper.TbsActivityTemplateMapper; import com.qs.serve.modules.tbs.mapper.TbsActivityTemplateMapper;
import com.qs.serve.modules.tbs.mapper.TbsCostApplyMapper;
import com.qs.serve.modules.tbs.service.*; import com.qs.serve.modules.tbs.service.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -58,8 +59,8 @@ public class TbsActivityServiceImpl extends ServiceImpl<TbsActivityMapper,TbsAct
private final TbsActivityChannelService activityChannelService; private final TbsActivityChannelService activityChannelService;
private final TbsActivityChannelPointService activityChannelPointService; private final TbsActivityChannelPointService activityChannelPointService;
private final TbsActivityTemplateMapper activityTemplateMapper; private final TbsActivityTemplateMapper activityTemplateMapper;
private final TbsCostApplyMapper costApplyMapper;
private final TbsActivitySlottingFeeService activitySlottingFeeService; private final TbsActivitySlottingFeeService activitySlottingFeeService;
private final TbsCostApplyService costApplyService;
private final TbsCenterDtoService tbsCenterDtoService; private final TbsCenterDtoService tbsCenterDtoService;
private final BmsSubjectFormMapper subjectFormMapper; private final BmsSubjectFormMapper subjectFormMapper;
@ -87,7 +88,7 @@ public class TbsActivityServiceImpl extends ServiceImpl<TbsActivityMapper,TbsAct
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void modify(TbsActivityBo activityBo) { public void modify(TbsActivityBo activityBo) {
TbsCostApply costApply = costApplyService.getById(activityBo.getCostApplyId()); TbsCostApply costApply = costApplyMapper.selectById(activityBo.getCostApplyId());
if(!costApply.getChargeState().equals(TbsCostApplyState.State_0_unPublish.getCode()) if(!costApply.getChargeState().equals(TbsCostApplyState.State_0_unPublish.getCode())
&&!costApply.getChargeState().equals(TbsCostApplyState.State_4_refused.getCode())){ &&!costApply.getChargeState().equals(TbsCostApplyState.State_4_refused.getCode())){
Assert.throwEx("因费用状态不支持编辑!!"); Assert.throwEx("因费用状态不支持编辑!!");
@ -333,7 +334,7 @@ public class TbsActivityServiceImpl extends ServiceImpl<TbsActivityMapper,TbsAct
costApplyParam.setTotalActivityAmount(totalCostAmount); costApplyParam.setTotalActivityAmount(totalCostAmount);
costApplyParam.setTotalActivityPreAmount(totalCostAmount2); costApplyParam.setTotalActivityPreAmount(totalCostAmount2);
costApplyParam.setTotalActivityPreNotAmount(totalCostAmount3); costApplyParam.setTotalActivityPreNotAmount(totalCostAmount3);
costApplyService.updateById(costApplyParam); costApplyMapper.updateById(costApplyParam);
} }
/** /**

154
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java

@ -47,6 +47,8 @@ import com.qs.serve.modules.tbs.entity.dto.TbsCenterGoodBirDTO;
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult; import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult;
import com.qs.serve.modules.tbs.entity.dto.TbsContractCostSubItem; import com.qs.serve.modules.tbs.entity.dto.TbsContractCostSubItem;
import com.qs.serve.modules.tbs.entity.dto.TbsCostSubItem; import com.qs.serve.modules.tbs.entity.dto.TbsCostSubItem;
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableResultVo;
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo;
import com.qs.serve.modules.tbs.mapper.*; import com.qs.serve.modules.tbs.mapper.*;
import com.qs.serve.modules.tbs.service.*; import com.qs.serve.modules.tbs.service.*;
import com.qs.serve.modules.vtb.common.VtbVerificationState; import com.qs.serve.modules.vtb.common.VtbVerificationState;
@ -109,6 +111,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
private VtbVerificationMapper verificationMapper; private VtbVerificationMapper verificationMapper;
private SysAttachService sysAttachService; private SysAttachService sysAttachService;
private BirCenterRateService centerRateService; private BirCenterRateService centerRateService;
private TbsBudgetMatchApplication tbsBudgetMatchApplication;
@ -257,18 +260,29 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
if(supplier.getCostFlag().equals(0)){ if(supplier.getCostFlag().equals(0)){
Assert.throwEx("["+supplier.getName()+"]无投放费用权限"); Assert.throwEx("["+supplier.getName()+"]无投放费用权限");
} }
TbsBudgetCostResult result = budgetApplicationService.buildBudgetCostResult(tbsCostApply.getId(),true,false);
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId());
sysUser.checkSyAccount(); sysUser.checkSyAccount();
Map<String, Object> data = new HashMap<>(10);
//匹配方式的result
TbsBudgetCostResult result0 = null;
TbsBudgetTableResultVo result1 = null;
//TODO 加载匹配方式
Integer matchType = tbsCostApply.getMatchType();
if(matchType.equals(0)){
result0 = budgetApplicationService.buildBudgetCostResult(tbsCostApply.getId(),true,false);
}else if (matchType.equals(1)){
//新的匹配方式
result1 = tbsBudgetMatchApplication.getMatchResult(tbsCostApply.getId(),false);
}
//恢复绑定 //恢复绑定
this.releaseCost(tbsCostApply.getId(),0); this.releaseCost(tbsCostApply.getId(),0);
Map<String, Object> data = new HashMap<>(10);
if(tbsCostApply.getContractFlag()!=null&&tbsCostApply.getContractFlag().equals(1)){ if(tbsCostApply.getContractFlag()!=null&&tbsCostApply.getContractFlag().equals(1)){
//创建协议的费用申请Data //创建协议的费用申请Data
this.buildContractApplyData(id, tbsCostApply, activityList, payConditions, supplier, sysUser, data); this.buildContractApplyData(id, tbsCostApply, activityList, payConditions, supplier, sysUser, data);
}else { }else {
//创建通用的费用申请Data //创建通用的费用申请Data
this.buildCommonApplyData(id, tbsCostApply, activityList, supplier, result, sysUser, data); this.buildCommonApplyData(id, tbsCostApply, activityList, supplier,sysUser, data);
} }
//修改申请编码 //修改申请编码
String templateCode = tbsCostApply.getContractFlag().equals(1) String templateCode = tbsCostApply.getContractFlag().equals(1)
@ -301,19 +315,129 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
//移除历史记录 //移除历史记录
budgetCostItemService.removeByCostApplyId(costApply.getId()); budgetCostItemService.removeByCostApplyId(costApply.getId());
//保存无命中条件的预算 //保存无命中条件的预算
if(CollectionUtil.isNotEmpty(result.getBudgetUnMatchList())){ List<TbsBudgetLog> budgetLogList = null;
List<TbsCostUnItem> costUnItems = result.getBudgetUnMatchList().stream() if (matchType.equals(0)){
if(CollectionUtil.isNotEmpty(result0.getBudgetUnMatchList())){
List<TbsCostUnItem> costUnItems = result0.getBudgetUnMatchList().stream()
.map(obj-> CopierUtil.copy(obj,new TbsCostUnItem())).collect(Collectors.toList()); .map(obj-> CopierUtil.copy(obj,new TbsCostUnItem())).collect(Collectors.toList());
tbsCostUnItemService.saveBatch(costUnItems); tbsCostUnItemService.saveBatch(costUnItems);
} }
//重新保存 //重新保存
List<TbsBudgetCostItem> allBudgetItem = new ArrayList<>(); List<TbsBudgetCostItem> allBudgetItem = new ArrayList<>();
allBudgetItem.addAll(result.getBudgetMatchList()); allBudgetItem.addAll(result0.getBudgetMatchList());
allBudgetItem.addAll(result.getBudgetUnMatchList()); allBudgetItem.addAll(result0.getBudgetUnMatchList());
budgetCostItemService.saveBatch(allBudgetItem); budgetCostItemService.saveBatch(allBudgetItem);
//TODO 无匹配的预算item保存到 TbsCostUnItem
//保存预算使用日志 //保存预算使用日志
List<TbsBudgetLog> budgetLogList = saveBudgetLog(result, sysUser, costApply, result.getBudgetMatchList(),result.getActivityList()); budgetLogList = saveBudgetLog(result0.getBudgetList(), sysUser, costApply, result0.getBudgetMatchList(),result0.getActivityList());
}else if (matchType.equals(1)){
// 未命中预算
List<TbsCostUnItem> costUnItems = new ArrayList<>();
// 所有记录情况
List<TbsBudgetCostItem> allBudgetItem = new ArrayList<>();
// 命中的预算
budgetLogList = new ArrayList<>();
Map<Long, TbsScheduleItemBudget> matchItemBudgetsMap = result1.getMatchItemBudgetsMap();
for (TbsActivityCenterGoods centerGoods : result1.getActivityCenterGoodsList()) {
TbsBudgetCostItem costItem = new TbsBudgetCostItem();
costItem.setCenterGoodsCode(centerGoods.getCenterGoodsCode());
costItem.setCostApplyId(centerGoods.getCostApplyId());
costItem.setActivityId(centerGoods.getActivityId());
costItem.setActivityCode(centerGoods.getActivityCode());
costItem.setSupplierId(centerGoods.getSupplierId());
costItem.setSupplierCode(centerGoods.getSupplierCode());
costItem.setSupplierName(centerGoods.getSupplierName());
costItem.setSubjectId(centerGoods.getSubjectId());
costItem.setSubjectCode(centerGoods.getSubjectCode());
costItem.setSubjectName(centerGoods.getSubjectName());
costItem.setCenterType(centerGoods.getCenterType());
costItem.setCenterId(centerGoods.getCenterId());
costItem.setCenterCode(centerGoods.getCenterCode());
costItem.setCenterName(centerGoods.getCenterName());
costItem.setCenterAmount(centerGoods.getCenterAmount());
costItem.setCenterRate(centerGoods.getCenterRate());
costItem.setCenterGoodsAmount(centerGoods.getCenterGoodsAmount());
costItem.setCenterGoodsRate(centerGoods.getCenterGoodsRate());
costItem.setTargetType(centerGoods.getTargetType());
costItem.setTargetId(centerGoods.getTargetId());
costItem.setTargetCode(centerGoods.getTargetCode());
costItem.setTargetName(centerGoods.getTargetName());
costItem.setTargetLevelPathIds(centerGoods.getTargetLevelPathIds());
costItem.setTargetLevelPathNames(centerGoods.getTargetLevelPathNames());
costItem.setActStartDate(centerGoods.getActStartDate());
costItem.setActEndDate(centerGoods.getActEndDate());
costItem.setPreStartDate(centerGoods.getPreStartDate());
costItem.setPreEndDate(centerGoods.getPreEndDate());
costItem.setPreCheckDate(centerGoods.getPreCheckDate());
costItem.setCenterGoodItemId(centerGoods.getId());
if(centerGoods.getScheduleItemBudgetId()==null){
TbsCostUnItem costUnItem = new TbsCostUnItem();
costUnItem.setCostApplyId(centerGoods.getCostApplyId());
costUnItem.setActivityId(centerGoods.getActivityId());
costUnItem.setActivityCode(centerGoods.getActivityCode());
costUnItem.setSubjectId(centerGoods.getSubjectId());
costUnItem.setSubjectCode(centerGoods.getSubjectCode());
costUnItem.setSubjectName(centerGoods.getSubjectName());
costUnItem.setCenterType(centerGoods.getCenterType());
costUnItem.setCenterId(centerGoods.getCenterId());
costUnItem.setCenterCode(centerGoods.getCenterCode());
costUnItem.setCenterName(centerGoods.getCenterName());
costUnItem.setAmount(centerGoods.getCenterGoodsAmount());
costUnItem.setTargetType(centerGoods.getTargetType());
costUnItem.setTargetId(centerGoods.getTargetId());
costUnItem.setTargetCode(centerGoods.getTargetCode());
costUnItem.setTargetName(centerGoods.getTargetName());
costUnItem.setTargetLevelPathIds(centerGoods.getTargetLevelPathIds());
costUnItem.setTargetLevelPathNames(centerGoods.getTargetLevelPathNames());
costUnItem.setActStartDate(centerGoods.getActStartDate());
costUnItem.setActEndDate(centerGoods.getActEndDate());
costUnItem.setPreStartDate(centerGoods.getPreStartDate());
costUnItem.setPreEndDate(centerGoods.getPreEndDate());
costUnItem.setPreCheckDate(centerGoods.getPreCheckDate());
costUnItem.setSupplierId(centerGoods.getSupplierId());
costUnItem.setSupplierCode(centerGoods.getSupplierCode());
costUnItem.setSupplierName(centerGoods.getSupplierName());
costUnItems.add(costUnItem);
costItem.setBudgetId(0L);
costItem.setScheduleId(0L);
costItem.setScheduleItemId(0L);
costItem.setScheduleItemAmount(BigDecimal.ZERO);
costItem.setScheduleItemAmountUsed(BigDecimal.ZERO);
costItem.setScheduleItemAmountApply(BigDecimal.ZERO);
costItem.setScheduleItemBudgetId(0L);
}else {
TbsScheduleItemBudget itemBudget = matchItemBudgetsMap.get(centerGoods.getScheduleItemBudgetId());
TbsActivity currActivity = null;
for (TbsActivity activity : activityList) {
if(centerGoods.getActivityId().equals(activity.getId())){
currActivity = activity;
}
}
TbsBudgetLog budgetLog = TbsBudgetLogBuildUtil.buildTbsBudgetLog(BudgetLogOptFlag.State_1,sysUser, costApply, itemBudget, centerGoods,centerGoods.getCenterGoodsAmount(),currActivity);
budgetLogList.add(budgetLog);
costItem.setBudgetId(itemBudget.getBudgetId());
costItem.setScheduleId(itemBudget.getScheduleId());
costItem.setScheduleItemId(itemBudget.getScheduleItemId());
costItem.setScheduleItemName(itemBudget.getItemName());
costItem.setScheduleItemAmount(itemBudget.getFinalBudgetAmount());
costItem.setScheduleItemAmountUsed(itemBudget.getUsedBudgetAmount());
costItem.setScheduleItemAmountApply(itemBudget.getUnUsedBudgetAmount());
costItem.setScheduleItemBudgetId(itemBudget.getId());
}
allBudgetItem.add(costItem);
//保存
if(costUnItems.size() > 0){
tbsCostUnItemService.saveBatch(costUnItems);
}
budgetCostItemService.saveBatch(allBudgetItem);
}
}
if(tbsCostApply.getChargeState().equals(TbsCostApplyState.State_0_unPublish.getCode())){ if(tbsCostApply.getChargeState().equals(TbsCostApplyState.State_0_unPublish.getCode())){
if(CollectionUtil.isNotEmpty(budgetLogList)){ if(CollectionUtil.isNotEmpty(budgetLogList)){
budgetLogService.saveBatch(budgetLogList); budgetLogService.saveBatch(budgetLogList);
@ -539,7 +663,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
data.put("sub", subList); data.put("sub", subList);
} }
private void buildCommonApplyData(String id, TbsCostApply tbsCostApply, List<TbsActivity> activityList, BmsSupplier supplier, TbsBudgetCostResult result, SysUser sysUser, Map<String, Object> data) { private void buildCommonApplyData(String id, TbsCostApply tbsCostApply, List<TbsActivity> activityList, BmsSupplier supplier ,SysUser sysUser, Map<String, Object> data) {
String actTitles = activityList.stream().map(TbsActivity::getActTitle).collect(Collectors.joining("; ")); String actTitles = activityList.stream().map(TbsActivity::getActTitle).collect(Collectors.joining("; "));
data.put("costApplyCode", tbsCostApply.getCode()); data.put("costApplyCode", tbsCostApply.getCode());
data.put("applyUserCode", sysUser.getCode()); data.put("applyUserCode", sysUser.getCode());
@ -589,7 +713,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
List<Object> subList = new ArrayList<>(); List<Object> subList = new ArrayList<>();
//创建子表数据 //创建子表数据
try { try {
this.buildSubList(result, tbsActivityCenters, subjectNames, subList); this.buildSubList(tbsActivityCenters, subjectNames, subList);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -654,12 +778,11 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
/** /**
* 创建子表数据 * 创建子表数据
* @param result
* @param tbsActivityCenters * @param tbsActivityCenters
* @param subjectNames * @param subjectNames
* @param subList * @param subList
*/ */
private void buildSubList(TbsBudgetCostResult result, List<TbsActivityCenter> tbsActivityCenters, List<String> subjectNames, List<Object> subList) { private void buildSubList(List<TbsActivityCenter> tbsActivityCenters, List<String> subjectNames, List<Object> subList) {
for (String subjectName : subjectNames) { for (String subjectName : subjectNames) {
subList.add(new TbsCostSubItem.Subject(subjectName)); subList.add(new TbsCostSubItem.Subject(subjectName));
} }
@ -676,14 +799,13 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
/** /**
* 保存预算使用日志 * 保存预算使用日志
* @param result * @param budgetList
* @param sysUser * @param sysUser
* @param costApply * @param costApply
* @param allBudgetItem * @param allBudgetItem
*/ */
private List<TbsBudgetLog> saveBudgetLog(TbsBudgetCostResult result, SysUser sysUser, TbsCostApply costApply, List<TbsBudgetCostItem> allBudgetItem, List<TbsActivity> activityList) { private List<TbsBudgetLog> saveBudgetLog(List<TbsBudget> budgetList, SysUser sysUser, TbsCostApply costApply, List<TbsBudgetCostItem> allBudgetItem, List<TbsActivity> activityList) {
List<TbsBudgetLog> budgetLogList = new ArrayList<>(); List<TbsBudgetLog> budgetLogList = new ArrayList<>();
List<TbsBudget> budgetList = result.getBudgetList();
for (TbsBudgetCostItem item : allBudgetItem) { for (TbsBudgetCostItem item : allBudgetItem) {
//排除不匹配预算的项 //排除不匹配预算的项
if(item.getBudgetId().equals(0L)){ if(item.getBudgetId().equals(0L)){

6
src/main/resources/mapper/tbs/TbsBudgetMatchMapper.xml

@ -42,13 +42,13 @@
left join tbs_budget tb on tsib.budget_id = tb.id 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 tbs_budget_condition tbc on tbc.budget_id = tb.id
left join 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 (select sum(tbg.amount) amt,tbg.schedule_item_budget_id from tbs_budget_log tbg where tbg.opt_type and tbg.del_flag = 0 GROUP BY tbg.schedule_item_budget_id) temp_tbg1
on temp_tbg1.schedule_item_budget_id = tsib.id on temp_tbg1.schedule_item_budget_id = tsib.id
left join 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 (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 on temp_tbg2.schedule_item_budget_id = tsib.id
left join 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 (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 on temp_tbg3.schedule_item_budget_id = tsib.id
where 1=1 where 1=1
AND (tb.subject_id = 0 OR tb.subject_id = #{query.subjectId} ) AND (tb.subject_id = 0 OR tb.subject_id = #{query.subjectId} )

8
src/main/resources/mapper/tbs/TbsScheduleItemBudgetMapper.xml

@ -78,7 +78,8 @@
`tbs_cost_apply` `tbs_cost_apply`
ON `tbs_budget_log` .cost_apply_id = tbs_cost_apply.id ON `tbs_budget_log` .cost_apply_id = tbs_cost_apply.id
WHERE WHERE
`tbs_budget_log`.budget_id in `tbs_budget_log`.del_flag = 0
and `tbs_budget_log`.budget_id in
<foreach collection="budgetIds" item ="selectId" index="i" open="(" close=")" separator=","> <foreach collection="budgetIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId} #{selectId}
</foreach> </foreach>
@ -122,7 +123,8 @@
`tzc_policy` `tzc_policy`
ON `tbs_budget_log`.policy_id = tzc_policy.id ON `tbs_budget_log`.policy_id = tzc_policy.id
WHERE WHERE
`tbs_budget_log`.budget_id in `tbs_budget_log`.del_flag = 0
and `tbs_budget_log`.budget_id in
<foreach collection="budgetIds" item ="selectId" index="i" open="(" close=")" separator=","> <foreach collection="budgetIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId} #{selectId}
</foreach> </foreach>
@ -151,7 +153,7 @@
sum(amount) as amt sum(amount) as amt
from tbs_budget_log from tbs_budget_log
where where
opt_type in (0,2,3) del_flag = 0 and opt_type in (0,2,3)
AND schedule_item_budget_id in AND schedule_item_budget_id in
<foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=","> <foreach collection="selectIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId} #{selectId}

Loading…
Cancel
Save