16 changed files with 303 additions and 17 deletions
@ -0,0 +1,218 @@ |
|||||
|
package com.qs.serve.modules.tbs.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.qs.serve.common.model.annotation.LimitSubmit; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.BudgetLogOptFlag; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.*; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRegion2; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
||||
|
import com.qs.serve.modules.bms.service.BmsRegion2Service; |
||||
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
||||
|
import com.qs.serve.modules.sys.entity.SysUser; |
||||
|
import com.qs.serve.modules.sys.service.SysDeleteLogService; |
||||
|
import com.qs.serve.modules.sys.service.SysPostUserService; |
||||
|
import com.qs.serve.modules.sys.service.SysUserService; |
||||
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
||||
|
import com.qs.serve.modules.tbs.common.util.TbsBudgetLogBuildUtil; |
||||
|
import com.qs.serve.modules.tbs.entity.*; |
||||
|
import com.qs.serve.modules.tbs.entity.bo.TbsActivityBo; |
||||
|
import com.qs.serve.modules.tbs.entity.bo.TbsCostApplyActivityBo; |
||||
|
import com.qs.serve.modules.tbs.entity.bo.TbsCostApplyBo; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsActNotMatchAmtCenterGoods; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetScheduleWithAmount; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsCostBudgetRelateInfo; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsCostErrorBudgetDTO; |
||||
|
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.TbsCostApplyVo; |
||||
|
import com.qs.serve.modules.tbs.mapper.TbsBudgetLogMapper; |
||||
|
import com.qs.serve.modules.tbs.mapper.TbsCostApplyMapper; |
||||
|
import com.qs.serve.modules.tbs.service.*; |
||||
|
import com.qs.serve.modules.tbs.service.impl.TbsCostApplyOperationServiceImpl; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 预算 费用申请 |
||||
|
* @author YenHex |
||||
|
* @since 2022-11-08 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("tbs/costTest") |
||||
|
public class TbsCostApplyTestController { |
||||
|
|
||||
|
private TbsCostApplyPart1Service costApplyPart1Service; |
||||
|
private TbsCostContractService costContractService; |
||||
|
private TbsCostApplyService tbsCostApplyService; |
||||
|
private TbsActivityService tbsActivityService; |
||||
|
private TbsActivityTemplateService tbsActivityTemplateService; |
||||
|
private TbsActivityCenterGoodsService tbsActivityCenterGoodsService; |
||||
|
private BmsSupplierService bmsSupplierService; |
||||
|
private final TbsBudgetLogMapper tbsBudgetLogMapper; |
||||
|
private BmsRegion2Service region2Service; |
||||
|
private SysUserService sysUserService; |
||||
|
private TbsBudgetApplicationService budgetApplicationService; |
||||
|
private TbsBudgetService tbsBudgetService; |
||||
|
private SysPostUserService postUserService; |
||||
|
private TbsCostApplyOperationServiceImpl tbsCostApplyOperationServiceImpl; |
||||
|
private TbsBudgetMatchApplication tbsBudgetMatchApplication; |
||||
|
private TbsBudgetCostItemService tbsBudgetCostItemService; |
||||
|
private TbsBudgetLogService tbsBudgetLogService; |
||||
|
private TbsScheduleItemBudgetService tbsScheduleItemBudgetService; |
||||
|
private SysDeleteLogService deleteLogService; |
||||
|
private TbsCostApplyMapper tbsCostApplyMapper; |
||||
|
private TbsCostChangeInfoService tbsCostChangeInfoService; |
||||
|
private TbsBudgetCostItemService budgetCostItemService; |
||||
|
private TbsBudgetLogService budgetLogService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 重写适配预算 |
||||
|
* @param costApplyId |
||||
|
* @return |
||||
|
*/ |
||||
|
public R<?> rebuildCost(Long costApplyId){ |
||||
|
|
||||
|
TbsCostApply costApply = tbsCostApplyService.getById(costApplyId); |
||||
|
|
||||
|
TbsBudgetTableResultVo resultVo = tbsBudgetMatchApplication.getMatchResult(costApplyId ,false); |
||||
|
|
||||
|
List<TbsActivity> activityList = tbsActivityService.listByCostApplyId(costApplyId); |
||||
|
|
||||
|
SysUser sysUser = sysUserService.getById(costApply.getUserId()); |
||||
|
|
||||
|
// 未命中预算
|
||||
|
List<TbsCostUnItem> costUnItems = new ArrayList<>(); |
||||
|
// 所有记录情况
|
||||
|
List<TbsBudgetCostItem> allBudgetItem = new ArrayList<>(); |
||||
|
// 命中的预算
|
||||
|
List<TbsBudgetLog> budgetLogList = new ArrayList<>(); |
||||
|
|
||||
|
Map<Long, TbsScheduleItemBudget> matchItemBudgetsMap = resultVo.getMatchItemBudgetsMap(); |
||||
|
for (TbsActivityCenterGoods centerGoods : resultVo.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){ |
||||
|
return R.error(); |
||||
|
} |
||||
|
budgetCostItemService.saveBatch(allBudgetItem); |
||||
|
|
||||
|
if(CollectionUtil.isNotEmpty(budgetLogList)){ |
||||
|
budgetLogService.saveBatch(budgetLogList); |
||||
|
} |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
Loading…
Reference in new issue