|
@ -3,21 +3,23 @@ package com.qs.serve.modules.tbs.service.impl; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.qs.serve.common.model.dto.R; |
|
|
import com.qs.serve.common.model.dto.R; |
|
|
import com.qs.serve.common.util.Assert; |
|
|
import com.qs.serve.common.util.*; |
|
|
import com.qs.serve.common.util.AuthContextUtils; |
|
|
|
|
|
import com.qs.serve.common.util.DateUtils; |
|
|
|
|
|
import com.qs.serve.common.util.JsonUtil; |
|
|
|
|
|
import com.qs.serve.common.util.model.DateFormatString; |
|
|
import com.qs.serve.common.util.model.DateFormatString; |
|
|
|
|
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|
|
|
|
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
|
|
import com.qs.serve.modules.seeyon.entity.BaseCreateProcessBo; |
|
|
import com.qs.serve.modules.seeyon.entity.BaseCreateProcessBo; |
|
|
import com.qs.serve.modules.seeyon.service.SeeYonService; |
|
|
import com.qs.serve.modules.seeyon.service.SeeYonService; |
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
import com.qs.serve.modules.sys.service.SysUserService; |
|
|
import com.qs.serve.modules.sys.service.SysUserService; |
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
import com.qs.serve.modules.tbs.common.TbsSeeYonConst; |
|
|
import com.qs.serve.modules.tbs.common.TbsSeeYonConst; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.TbsBudget; |
|
|
import com.qs.serve.modules.tbs.entity.TbsBudgetCostItem; |
|
|
import com.qs.serve.modules.tbs.entity.TbsBudgetCostItem; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.TbsBudgetLog; |
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult; |
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult; |
|
|
import com.qs.serve.modules.tbs.service.TbsBudgetApplicationService; |
|
|
import com.qs.serve.modules.tbs.service.TbsBudgetApplicationService; |
|
|
import com.qs.serve.modules.tbs.service.TbsBudgetCostItemService; |
|
|
import com.qs.serve.modules.tbs.service.TbsBudgetCostItemService; |
|
|
|
|
|
import com.qs.serve.modules.tbs.service.TbsBudgetLogService; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
@ -31,6 +33,7 @@ import java.util.ArrayList; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 费用申请 服务实现类 |
|
|
* 费用申请 服务实现类 |
|
@ -42,8 +45,10 @@ import java.util.Map; |
|
|
@AllArgsConstructor |
|
|
@AllArgsConstructor |
|
|
public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsCostApply> implements TbsCostApplyService { |
|
|
public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsCostApply> implements TbsCostApplyService { |
|
|
|
|
|
|
|
|
|
|
|
private BmsSupplierService supplierService; |
|
|
private TbsBudgetApplicationService budgetApplicationService; |
|
|
private TbsBudgetApplicationService budgetApplicationService; |
|
|
private TbsBudgetCostItemService budgetCostItemService; |
|
|
private TbsBudgetCostItemService budgetCostItemService; |
|
|
|
|
|
private TbsBudgetLogService budgetLogService; |
|
|
private SysUserService sysUserService; |
|
|
private SysUserService sysUserService; |
|
|
private SeeYonService seeYonService; |
|
|
private SeeYonService seeYonService; |
|
|
|
|
|
|
|
@ -55,6 +60,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
&&!tbsCostApply.getChargeState().equals(TbsCostApplyState.State_4_refused.getCode())){ |
|
|
&&!tbsCostApply.getChargeState().equals(TbsCostApplyState.State_4_refused.getCode())){ |
|
|
Assert.throwEx("操作失败,申请费用状态不支持"); |
|
|
Assert.throwEx("操作失败,申请费用状态不支持"); |
|
|
} |
|
|
} |
|
|
|
|
|
BmsSupplier supplier = supplierService.getById(tbsCostApply.getSupplierId()); |
|
|
TbsBudgetCostResult result = budgetApplicationService.buildBudgetCostResult(tbsCostApply.getId(),true,false); |
|
|
TbsBudgetCostResult result = budgetApplicationService.buildBudgetCostResult(tbsCostApply.getId(),true,false); |
|
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
|
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
|
|
sysUser.checkSyAccount(); |
|
|
sysUser.checkSyAccount(); |
|
@ -94,6 +100,62 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
allBudgetItem.addAll(result.getBudgetMatchList()); |
|
|
allBudgetItem.addAll(result.getBudgetMatchList()); |
|
|
allBudgetItem.addAll(result.getBudgetUnMatchList()); |
|
|
allBudgetItem.addAll(result.getBudgetUnMatchList()); |
|
|
budgetCostItemService.saveBatch(allBudgetItem); |
|
|
budgetCostItemService.saveBatch(allBudgetItem); |
|
|
|
|
|
//保存预算使用日志
|
|
|
|
|
|
List<TbsBudgetLog> budgetLogList = new ArrayList<>(); |
|
|
|
|
|
List<TbsBudget> budgetList = result.getBudgetList(); |
|
|
|
|
|
for (TbsBudgetCostItem item : allBudgetItem) { |
|
|
|
|
|
//排除不匹配预算的项
|
|
|
|
|
|
if(item.getBudgetId().equals(0L)){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
TbsBudget budget = null; |
|
|
|
|
|
for (TbsBudget tbsBudget : budgetList) { |
|
|
|
|
|
if(item.getBudgetId().equals(tbsBudget.getId())){ |
|
|
|
|
|
budget = tbsBudget; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(budget==null){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
TbsBudgetLog budgetLog = new TbsBudgetLog(); |
|
|
|
|
|
budgetLog.setBudgetId(item.getBudgetId()); |
|
|
|
|
|
budgetLog.setBudgetCode(budget.getBudgetCode()); |
|
|
|
|
|
budgetLog.setOptType(2); |
|
|
|
|
|
budgetLog.setOptUserId(sysUser.getId()); |
|
|
|
|
|
budgetLog.setOptUserCode(sysUser.getCode()); |
|
|
|
|
|
budgetLog.setOptUserName(sysUser.getName()); |
|
|
|
|
|
budgetLog.setAmount(item.getCenterGoodsAmount()); |
|
|
|
|
|
budgetLog.setScheduleId(item.getScheduleId()); |
|
|
|
|
|
budgetLog.setScheduleItemId(item.getScheduleItemId()); |
|
|
|
|
|
//budgetLog.setItemName();
|
|
|
|
|
|
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.setSupplierId(Long.parseLong(supplier.getId())); |
|
|
|
|
|
budgetLog.setSupplierCode(supplier.getCode()); |
|
|
|
|
|
budgetLog.setSupplierName(supplier.getName()); |
|
|
|
|
|
budgetLog.setActivityId(item.getActivityId()); |
|
|
|
|
|
budgetLog.setActivityCode(item.getActivityCode()); |
|
|
|
|
|
budgetLog.setCostApplyId(costApply.getId()); |
|
|
|
|
|
budgetLog.setCostApplyCode(costApply.getCode()); |
|
|
|
|
|
budgetLog.setCostApplyTheme(costApply.getChargeTheme()); |
|
|
|
|
|
budgetLog.setTargetType(item.getTargetType()); |
|
|
|
|
|
budgetLog.setTargetId(item.getTargetId()); |
|
|
|
|
|
budgetLog.setTargetCode(item.getTargetCode()); |
|
|
|
|
|
budgetLog.setTargetName(item.getTargetName()); |
|
|
|
|
|
budgetLog.setTargetLevelPathIds(item.getTargetLevelPathIds()); |
|
|
|
|
|
budgetLog.setTargetLevelPathNames(item.getTargetLevelPathNames()); |
|
|
|
|
|
budgetLogList.add(budgetLog); |
|
|
|
|
|
} |
|
|
|
|
|
if(CollectionUtil.isNotEmpty(budgetLogList)){ |
|
|
|
|
|
budgetLogService.saveBatch(budgetLogList); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|