|
@ -13,19 +13,13 @@ 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.*; |
|
|
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.*; |
|
|
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.jetbrains.annotations.NotNull; |
|
|
import org.jetbrains.annotations.NotNull; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import com.qs.serve.modules.tbs.entity.TbsCostApply; |
|
|
|
|
|
import com.qs.serve.modules.tbs.service.TbsCostApplyService; |
|
|
|
|
|
import com.qs.serve.modules.tbs.mapper.TbsCostApplyMapper; |
|
|
import com.qs.serve.modules.tbs.mapper.TbsCostApplyMapper; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
@ -46,7 +40,6 @@ import java.util.stream.Collectors; |
|
|
@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 TbsBudgetLogService budgetLogService; |
|
@ -61,7 +54,6 @@ 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 +86,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
costApply.setSyFormId(formId); |
|
|
costApply.setSyFormId(formId); |
|
|
costApply.setChargeState(TbsCostApplyState.State_1_apply.getCode()); |
|
|
costApply.setChargeState(TbsCostApplyState.State_1_apply.getCode()); |
|
|
this.updateById(costApply); |
|
|
this.updateById(costApply); |
|
|
|
|
|
costApply = this.getById(costApply.getId()); |
|
|
//移除历史记录
|
|
|
//移除历史记录
|
|
|
budgetCostItemService.removeByCostApplyId(costApply.getId()); |
|
|
budgetCostItemService.removeByCostApplyId(costApply.getId()); |
|
|
//重新保存
|
|
|
//重新保存
|
|
@ -102,7 +95,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
allBudgetItem.addAll(result.getBudgetUnMatchList()); |
|
|
allBudgetItem.addAll(result.getBudgetUnMatchList()); |
|
|
budgetCostItemService.saveBatch(allBudgetItem); |
|
|
budgetCostItemService.saveBatch(allBudgetItem); |
|
|
//保存预算使用日志
|
|
|
//保存预算使用日志
|
|
|
saveBudgetLog(result, sysUser, costApply, allBudgetItem); |
|
|
saveBudgetLog(result, sysUser, costApply, allBudgetItem,result.getActivityList()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -112,7 +105,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
* @param costApply |
|
|
* @param costApply |
|
|
* @param allBudgetItem |
|
|
* @param allBudgetItem |
|
|
*/ |
|
|
*/ |
|
|
private void saveBudgetLog(TbsBudgetCostResult result, SysUser sysUser, TbsCostApply costApply, List<TbsBudgetCostItem> allBudgetItem) { |
|
|
private void saveBudgetLog(TbsBudgetCostResult result, 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(); |
|
|
List<TbsBudget> budgetList = result.getBudgetList(); |
|
|
for (TbsBudgetCostItem item : allBudgetItem) { |
|
|
for (TbsBudgetCostItem item : allBudgetItem) { |
|
@ -130,7 +123,13 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
if(budget==null){ |
|
|
if(budget==null){ |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
TbsBudgetLog budgetLog = budgetLogService.buildTbsBudgetLog(0,sysUser, costApply, item, budget,item.getCenterGoodsAmount().negate()); |
|
|
TbsActivity currActivity = null; |
|
|
|
|
|
for (TbsActivity activity : activityList) { |
|
|
|
|
|
if(item.getActivityId().equals(activity.getId())){ |
|
|
|
|
|
currActivity = activity; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
TbsBudgetLog budgetLog = budgetLogService.buildTbsBudgetLog(0,sysUser, costApply, item, budget,item.getCenterGoodsAmount().negate(),currActivity); |
|
|
budgetLogList.add(budgetLog); |
|
|
budgetLogList.add(budgetLog); |
|
|
} |
|
|
} |
|
|
if(CollectionUtil.isNotEmpty(budgetLogList)){ |
|
|
if(CollectionUtil.isNotEmpty(budgetLogList)){ |
|
|