@ -32,9 +32,12 @@ import com.qs.serve.modules.tbs.entity.bo.*;
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.TbsBudgetScheduleWithAmount ;
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.TbsCostBudgetRelateInfo ;
import com.qs.serve.modules.tbs.entity.dto.TbsCostErrorBudgetDTO ;
import com.qs.serve.modules.tbs.entity.vo.CtpAffairVo ;
import com.qs.serve.modules.tbs.entity.vo.CtpAffairVo ;
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo ;
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo ;
import com.qs.serve.modules.tbs.entity.vo.TbsCostApplyVo ;
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.* ;
import com.qs.serve.modules.tbs.service.impl.TbsCostApplyOperationServiceImpl ;
import com.qs.serve.modules.tbs.service.impl.TbsCostApplyOperationServiceImpl ;
import lombok.AllArgsConstructor ;
import lombok.AllArgsConstructor ;
@ -65,6 +68,7 @@ public class TbsCostApplyController {
private TbsCostApplyService tbsCostApplyService ;
private TbsCostApplyService tbsCostApplyService ;
private TbsActivityService tbsActivityService ;
private TbsActivityService tbsActivityService ;
private TbsActivityTemplateService tbsActivityTemplateService ;
private TbsActivityTemplateService tbsActivityTemplateService ;
private TbsActivityCenterGoodsService tbsActivityCenterGoodsService ;
private final TbsActivityGoodsService activityGoodsService ;
private final TbsActivityGoodsService activityGoodsService ;
private final TbsActivitySubjectService activitySubjectService ;
private final TbsActivitySubjectService activitySubjectService ;
private final TbsActivityCenterService activityCenterService ;
private final TbsActivityCenterService activityCenterService ;
@ -72,6 +76,7 @@ public class TbsCostApplyController {
private final TbsActivityChannelService activityChannelService ;
private final TbsActivityChannelService activityChannelService ;
private final TbsActivityChannelPointService activityChannelPointService ;
private final TbsActivityChannelPointService activityChannelPointService ;
private BmsSupplierService bmsSupplierService ;
private BmsSupplierService bmsSupplierService ;
private final TbsBudgetLogMapper tbsBudgetLogMapper ;
private BmsRegion2Service region2Service ;
private BmsRegion2Service region2Service ;
private SysUserService sysUserService ;
private SysUserService sysUserService ;
private TbsBudgetApplicationService budgetApplicationService ;
private TbsBudgetApplicationService budgetApplicationService ;
@ -83,6 +88,7 @@ public class TbsCostApplyController {
private TbsBudgetLogService tbsBudgetLogService ;
private TbsBudgetLogService tbsBudgetLogService ;
private TbsScheduleItemBudgetService tbsScheduleItemBudgetService ;
private TbsScheduleItemBudgetService tbsScheduleItemBudgetService ;
private SysDeleteLogService deleteLogService ;
private SysDeleteLogService deleteLogService ;
private TbsCostApplyMapper tbsCostApplyMapper ;
/ * *
/ * *
@ -524,11 +530,110 @@ public class TbsCostApplyController {
return R . ok ( ) ;
return R . ok ( ) ;
}
}
public R < ? > dealCostBudget ( Long costApplyId ) {
@GetMapping ( "rebuildBudgetLog" )
public void dealCostBudget ( Long costApplyId ) {
List < TbsCostErrorBudgetDTO > costErrorBudgetDTOList = tbsCostApplyMapper . selectCostErrorBudgetDTO ( ) ;
for ( TbsCostErrorBudgetDTO budgetDTO : costErrorBudgetDTOList ) {
rebuildBudgetLog ( budgetDTO . getId ( ) ) ;
}
}
/ * *
* 方法不可行
* /
@Deprecated
//@GetMapping("rebuildBudgetLog2")
public void dealCostBudget2 ( ) {
List < TbsCostErrorBudgetDTO > costErrorBudgetDTOList = new ArrayList < > ( ) ;
costErrorBudgetDTOList . add ( new TbsCostErrorBudgetDTO ( ) ) ;
//List<TbsCostErrorBudgetDTO> costErrorBudgetDTOList = tbsCostApplyMapper.selectCostErrorBudgetDTO();
for ( TbsCostErrorBudgetDTO budgetDTO : costErrorBudgetDTOList ) {
//Long costApplyId = budgetDTO.getId();
Long costApplyId = 115356L ;
//BigDecimal diff = budgetDTO.getTotalActivityAmount().subtract(budgetDTO.getSumBudget());
// if(diff.abs().compareTo(BigDecimal.ONE)<0){
LambdaQueryWrapper < TbsBudgetLog > logLqw = new LambdaQueryWrapper < > ( ) ;
logLqw . eq ( TbsBudgetLog : : getCostApplyId , costApplyId ) ;
logLqw . lt ( TbsBudgetLog : : getOptType , 7 ) ;
List < TbsBudgetLog > budgetLogList = tbsBudgetLogMapper . selectList ( logLqw ) ;
List < TbsBudgetCostItem > budgetCostItemList = tbsBudgetCostItemService . listByCostApplyId ( costApplyId ) ;
if ( budgetCostItemList . size ( ) = = budgetLogList . size ( ) ) {
for ( TbsBudgetLog budgetLog : budgetLogList ) {
for ( TbsBudgetCostItem costItem : budgetCostItemList ) {
if ( budgetLog . getActivityId ( ) . equals ( costItem . getActivityId ( ) )
& & budgetLog . getSubjectId ( ) . equals ( costItem . getSubjectId ( ) )
& & budgetLog . getCenterType ( ) . equals ( costItem . getCenterType ( ) )
& & budgetLog . getCenterId ( ) . equals ( costItem . getCenterId ( ) )
& & budgetLog . getTargetId ( ) . equals ( costItem . getTargetId ( ) )
& & budgetLog . getScheduleItemBudgetId ( ) . equals ( costItem . getScheduleItemBudgetId ( ) )
) {
budgetLog . setAmount ( costItem . getCenterGoodsAmount ( ) . negate ( ) ) ;
tbsBudgetLogMapper . updateById ( budgetLog ) ;
}
}
}
// }
}
return ;
}
}
public void rebuildBudgetLog ( Long costApplyId ) {
TbsCostApply costApply = tbsCostApplyMapper . selectById ( costApplyId ) ;
//调整center_goods和budget_log之间的占用
//调整center_goods和budget_log之间的占用
BigDecimal centerGoodsTotal = tbsCostApplyMapper . sumCostCenterGoodsAmount ( costApplyId ) ;
BigDecimal costAmt = costApply . getTotalActivityAmount ( ) ;
//判断合计金额与预算是否有差距过大
boolean diffCostCenterGoods = costAmt . subtract ( centerGoodsTotal ) . intValue ( ) ! = 0 ;
if ( diffCostCenterGoods ) {
log . error ( "{}金额错误" , costApply . getId ( ) ) ;
return ;
}
BigDecimal costAmountBudget = tbsCostApplyMapper . sumCostAmountBudget ( costApplyId ) ;
//改方法支持审批完成时回调更新
//判断合计金额与预算是否有差距过大
return R . ok ( ) ;
boolean diffCostBudget = costAmt . subtract ( costAmountBudget ) . intValue ( ) ! = 0 ;
if ( diffCostBudget ) {
//判断是否有释放,没有直接清理(后续可修改为全部清理)
LambdaQueryWrapper < TbsBudgetLog > budgetLogRmLqw = new LambdaQueryWrapper < > ( ) ;
budgetLogRmLqw . eq ( TbsBudgetLog : : getCostApplyId , costApply . getId ( ) ) ;
budgetLogRmLqw . ne ( TbsBudgetLog : : getOptType , 1 ) ;
tbsBudgetLogMapper . delete ( budgetLogRmLqw ) ;
LambdaQueryWrapper < TbsBudgetLog > budgetLogLqw = new LambdaQueryWrapper < > ( ) ;
budgetLogLqw . eq ( TbsBudgetLog : : getCostApplyId , costApply . getId ( ) ) ;
budgetLogLqw . eq ( TbsBudgetLog : : getOptType , 1 ) ;
List < TbsBudgetLog > budgetLogList = tbsBudgetLogMapper . selectList ( budgetLogLqw ) ;
List < TbsActivityCenterGoods > activityCenterGoodsList = tbsActivityCenterGoodsService . listByCostApplyId ( costApplyId ) ;
List < Long > updateLogIdsList = new ArrayList < > ( ) ;
updateLogIdsList . add ( 0L ) ;
for ( TbsActivityCenterGoods centerGoods : activityCenterGoodsList ) {
for ( TbsBudgetLog budgetLog : budgetLogList ) {
if ( budgetLog . getActivityId ( ) . equals ( centerGoods . getActivityId ( ) )
& & budgetLog . getSubjectId ( ) . equals ( centerGoods . getSubjectId ( ) )
& & budgetLog . getCenterType ( ) . equals ( centerGoods . getCenterType ( ) )
& & budgetLog . getCenterId ( ) . equals ( centerGoods . getCenterId ( ) )
& & budgetLog . getTargetId ( ) . equals ( centerGoods . getTargetId ( ) )
) {
budgetLog . setAmount ( centerGoods . getCenterGoodsAmount ( ) . negate ( ) ) ;
tbsBudgetLogMapper . updateById ( budgetLog ) ;
updateLogIdsList . add ( budgetLog . getId ( ) ) ;
break ;
}
}
}
budgetLogLqw . notIn ( TbsBudgetLog : : getId , updateLogIdsList ) ;
tbsBudgetLogMapper . delete ( budgetLogLqw ) ;
}
}
}
}
}