|
|
|
|
@ -22,7 +22,6 @@ import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
|
|
import org.dromara.oa.erp.constant.ProjectCategoryConstant;
|
|
|
|
|
import org.dromara.oa.base.domain.BasePaymentStage;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpContractPaymentMethod;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpProjectPlan;
|
|
|
|
|
import org.dromara.oa.erp.domain.ErpProjectPlanStage;
|
|
|
|
|
import org.dromara.oa.erp.domain.bo.ErpProjectPlanBo;
|
|
|
|
|
@ -31,7 +30,6 @@ import org.dromara.oa.erp.domain.vo.ContractCollectionPageVo;
|
|
|
|
|
import org.dromara.oa.erp.domain.vo.ContractCollectionStageDetailVo;
|
|
|
|
|
import org.dromara.oa.erp.domain.vo.ErpProjectPlanStageVo;
|
|
|
|
|
import org.dromara.oa.erp.domain.vo.ErpProjectPlanVo;
|
|
|
|
|
import org.dromara.oa.erp.mapper.ErpContractPaymentMethodMapper;
|
|
|
|
|
import org.dromara.oa.erp.mapper.ErpProjectPlanMapper;
|
|
|
|
|
import org.dromara.oa.erp.mapper.ErpProjectPlanStageMapper;
|
|
|
|
|
import org.dromara.oa.erp.service.IErpProjectPlanService;
|
|
|
|
|
@ -44,6 +42,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@ -63,7 +62,6 @@ public class ErpProjectPlanServiceImpl implements IErpProjectPlanService {
|
|
|
|
|
private final ErpProjectPlanMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
private final ErpProjectPlanStageMapper planStageMapper;
|
|
|
|
|
private final ErpContractPaymentMethodMapper contractPaymentMethodMapper;
|
|
|
|
|
|
|
|
|
|
@DubboReference(timeout = 30000)
|
|
|
|
|
private RemoteWorkflowService remoteWorkflowService;
|
|
|
|
|
@ -87,8 +85,11 @@ public class ErpProjectPlanServiceImpl implements IErpProjectPlanService {
|
|
|
|
|
// 查询项目计划阶段列表
|
|
|
|
|
MPJLambdaWrapper<ErpProjectPlanStage> lqw = JoinWrappers.lambda(ErpProjectPlanStage.class)
|
|
|
|
|
.selectAll(ErpProjectPlanStage.class)
|
|
|
|
|
.selectAs(BasePaymentStage::getStageName, ErpProjectPlanStageVo::getPaymentStageName)
|
|
|
|
|
.leftJoin(BasePaymentStage.class, BasePaymentStage::getPaymentStageId, ErpProjectPlanStage::getPaymentStageId)
|
|
|
|
|
.eq("t.del_flag", "0")
|
|
|
|
|
.eq(projectPlanId != null, ErpProjectPlanStage::getProjectPlanId, projectPlanId);
|
|
|
|
|
.eq(projectPlanId != null, ErpProjectPlanStage::getProjectPlanId, projectPlanId)
|
|
|
|
|
.orderByAsc(ErpProjectPlanStage::getSortOrder);
|
|
|
|
|
List<ErpProjectPlanStageVo> planStageList = planStageMapper.selectVoList(lqw);
|
|
|
|
|
projectPlanVo.setPlanStageList(planStageList);
|
|
|
|
|
return projectPlanVo;
|
|
|
|
|
@ -371,6 +372,8 @@ public class ErpProjectPlanServiceImpl implements IErpProjectPlanService {
|
|
|
|
|
public List<ErpProjectPlanStageVo> queryCollectionStageList(Long projectPlanId) {
|
|
|
|
|
MPJLambdaWrapper<ErpProjectPlanStage> lqw = JoinWrappers.lambda(ErpProjectPlanStage.class)
|
|
|
|
|
.selectAll(ErpProjectPlanStage.class)
|
|
|
|
|
.selectAs(BasePaymentStage::getStageName, ErpProjectPlanStageVo::getPaymentStageName)
|
|
|
|
|
.leftJoin(BasePaymentStage.class, BasePaymentStage::getPaymentStageId, ErpProjectPlanStage::getPaymentStageId)
|
|
|
|
|
.eq("t.del_flag", "0")
|
|
|
|
|
.eq(ErpProjectPlanStage::getProjectPlanId, projectPlanId)
|
|
|
|
|
.orderByAsc(ErpProjectPlanStage::getSortOrder);
|
|
|
|
|
@ -388,6 +391,7 @@ public class ErpProjectPlanServiceImpl implements IErpProjectPlanService {
|
|
|
|
|
}
|
|
|
|
|
stage.setReceivableDate(bo.getReceivableDate());
|
|
|
|
|
stage.setActualRepaymentAmount(bo.getActualRepaymentAmount());
|
|
|
|
|
stage.setActualRepaymentRate(calcActualRepaymentRate(bo.getActualRepaymentAmount(), stage.getRepaymentAmount()));
|
|
|
|
|
stage.setCollectionConfirmRemark(bo.getCollectionConfirmRemark());
|
|
|
|
|
stage.setCollectionConfirmUserId(LoginHelper.getUserId());
|
|
|
|
|
stage.setCollectionConfirmTime(new Date());
|
|
|
|
|
@ -415,6 +419,24 @@ public class ErpProjectPlanServiceImpl implements IErpProjectPlanService {
|
|
|
|
|
return planStageMapper.updateById(stage) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 计算 实际回款比例(%) = 实际回款金额 / 预计回款金额 * 100
|
|
|
|
|
*
|
|
|
|
|
* @param actualRepaymentAmount 实际回款金额
|
|
|
|
|
* @param repaymentAmount 预计回款金额
|
|
|
|
|
*/
|
|
|
|
|
private BigDecimal calcActualRepaymentRate(BigDecimal actualRepaymentAmount, Long repaymentAmount) {
|
|
|
|
|
BigDecimal actual = actualRepaymentAmount == null ? BigDecimal.ZERO : actualRepaymentAmount;
|
|
|
|
|
BigDecimal expected = repaymentAmount == null ? BigDecimal.ZERO : BigDecimal.valueOf(repaymentAmount);
|
|
|
|
|
if (expected.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
return actual
|
|
|
|
|
.divide(expected, 6, RoundingMode.HALF_UP)
|
|
|
|
|
.multiply(BigDecimal.valueOf(100))
|
|
|
|
|
.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TableDataInfo<ContractCollectionPageVo> queryContractCollectionPage(ErpProjectPlanBo bo, PageQuery pageQuery) {
|
|
|
|
|
Page<ContractCollectionPageVo> result = baseMapper.selectContractCollectionPage(pageQuery.build(), bo);
|
|
|
|
|
@ -423,54 +445,7 @@ public class ErpProjectPlanServiceImpl implements IErpProjectPlanService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ContractCollectionStageDetailVo> queryContractCollectionStageDetail(Long projectPlanId) {
|
|
|
|
|
ErpProjectPlan plan = baseMapper.selectById(projectPlanId);
|
|
|
|
|
if (plan == null || plan.getContractId() == null) {
|
|
|
|
|
return List.of();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MPJLambdaWrapper<ErpContractPaymentMethod> contractStageLqw = JoinWrappers.lambda(ErpContractPaymentMethod.class)
|
|
|
|
|
.selectAs(ErpContractPaymentMethod::getPaymentMethodId, ContractCollectionStageDetailVo::getPaymentMethodId)
|
|
|
|
|
.selectAs(ErpContractPaymentMethod::getContractId, ContractCollectionStageDetailVo::getContractId)
|
|
|
|
|
.selectAs(ErpContractPaymentMethod::getPaymentStageId, ContractCollectionStageDetailVo::getPaymentStageId)
|
|
|
|
|
.selectAs(BasePaymentStage::getStageName, ContractCollectionStageDetailVo::getStageName)
|
|
|
|
|
.selectAs(BasePaymentStage::getCollectionStage, ContractCollectionStageDetailVo::getCollectionStage)
|
|
|
|
|
.selectAs(ErpContractPaymentMethod::getPaymentPercentage, ContractCollectionStageDetailVo::getPaymentPercentage)
|
|
|
|
|
.selectAs(ErpContractPaymentMethod::getPaymentAmount, ContractCollectionStageDetailVo::getPaymentAmount)
|
|
|
|
|
.selectAs(ErpContractPaymentMethod::getPaymentDeadline, ContractCollectionStageDetailVo::getPaymentDeadline)
|
|
|
|
|
.selectAs(ErpContractPaymentMethod::getPaymentDescription, ContractCollectionStageDetailVo::getPaymentDescription)
|
|
|
|
|
.leftJoin(BasePaymentStage.class, BasePaymentStage::getPaymentStageId, ErpContractPaymentMethod::getPaymentStageId)
|
|
|
|
|
.eq(ErpContractPaymentMethod::getContractId, plan.getContractId())
|
|
|
|
|
.eq(ErpContractPaymentMethod::getDelFlag, "0")
|
|
|
|
|
.orderByAsc(ErpContractPaymentMethod::getSortOrder);
|
|
|
|
|
List<ContractCollectionStageDetailVo> contractStages = contractPaymentMethodMapper.selectJoinList(ContractCollectionStageDetailVo.class, contractStageLqw);
|
|
|
|
|
|
|
|
|
|
List<ErpProjectPlanStage> planStages = planStageMapper.selectList(
|
|
|
|
|
JoinWrappers.lambda(ErpProjectPlanStage.class)
|
|
|
|
|
.eq(ErpProjectPlanStage::getProjectPlanId, projectPlanId)
|
|
|
|
|
.eq(ErpProjectPlanStage::getDelFlag, "0")
|
|
|
|
|
);
|
|
|
|
|
// erp_project_plan_stage.collection_stage 实际存的是 paymentStageId(字符串)
|
|
|
|
|
Map<String, ErpProjectPlanStage> planStageMap = planStages.stream()
|
|
|
|
|
.filter(i -> StringUtils.isNotBlank(i.getCollectionStage()))
|
|
|
|
|
.collect(Collectors.toMap(ErpProjectPlanStage::getCollectionStage, i -> i, (a, b) -> a));
|
|
|
|
|
|
|
|
|
|
contractStages.forEach(item -> {
|
|
|
|
|
if (item.getPaymentStageId() == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ErpProjectPlanStage matched = planStageMap.get(String.valueOf(item.getPaymentStageId()));
|
|
|
|
|
if (matched != null) {
|
|
|
|
|
item.setPlanStageId(matched.getPlanStageId());
|
|
|
|
|
item.setRepaymentRate(matched.getRepaymentRate());
|
|
|
|
|
item.setReceivableDate(matched.getReceivableDate());
|
|
|
|
|
item.setActualRepaymentAmount(matched.getActualRepaymentAmount());
|
|
|
|
|
item.setCollectionConfirmUserId(matched.getCollectionConfirmUserId());
|
|
|
|
|
item.setCollectionConfirmTime(matched.getCollectionConfirmTime());
|
|
|
|
|
item.setCollectionConfirmStatus(matched.getCollectionConfirmStatus());
|
|
|
|
|
item.setCollectionConfirmRemark(matched.getCollectionConfirmRemark());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return contractStages;
|
|
|
|
|
return baseMapper.selectContractCollectionStageDetail(projectPlanId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|