1.1.10 把项目计划阶段的回款关联从字典字段改为回款阶段主键(后端 SQL联表、多页面前端与合同回款逻辑)

dev
yinq 1 month ago
parent 2f58c71125
commit 35f68d7584

@ -56,9 +56,9 @@ public class ErpProjectPlanStage extends TenantEntity {
private Date planEndTime;
/**
*
* ID base_payment_stage.payment_stage_id
*/
private String collectionStage;
private Long paymentStageId;
/**
* (%)
@ -125,6 +125,11 @@ public class ErpProjectPlanStage extends TenantEntity {
*/
private BigDecimal actualRepaymentAmount;
/**
* (%)
*/
private BigDecimal actualRepaymentRate;
/**
*
*/

@ -55,9 +55,9 @@ public class ErpProjectPlanStageBo extends BaseEntity {
private Date planEndTime;
/**
*
* ID base_payment_stage.payment_stage_id
*/
private String collectionStage;
private Long paymentStageId;
/**
* (%)
@ -124,6 +124,11 @@ public class ErpProjectPlanStageBo extends BaseEntity {
*/
private BigDecimal actualRepaymentAmount;
/**
* (%)
*/
private BigDecimal actualRepaymentRate;
/**
*
*/

@ -15,6 +15,9 @@ public class ContractCollectionStageDetailVo {
private Long contractId;
private Long paymentStageId;
private String stageName;
/**
* base_payment_stage.collection_stage/
*/
private String collectionStage;
private BigDecimal paymentPercentage;
@ -23,12 +26,22 @@ public class ContractCollectionStageDetailVo {
private String paymentDescription;
/**
* collectionStage
* payment_stage_id
*/
private Long planStageId;
private Long repaymentRate;
/**
*
*/
private Long repaymentAmount;
private Date receivableDate;
private BigDecimal actualRepaymentAmount;
/**
* (%) erp_project_plan_stage
*/
private BigDecimal actualRepaymentRate;
private Long collectionConfirmUserId;
private Date collectionConfirmTime;
private String collectionConfirmStatus;

@ -69,11 +69,16 @@ public class ErpProjectPlanStageVo implements Serializable {
private Date planEndTime;
/**
*
* ID base_payment_stage.payment_stage_id
*/
@ExcelProperty(value = "回款阶段")
@ExcelDictFormat(dictType = " collection_stage")
private String collectionStage;
@ExcelProperty(value = "付款节点ID")
private Long paymentStageId;
/**
* base_payment_stage.stage_name
*/
@ExcelProperty(value = "回款阶段名称")
private String paymentStageName;
/**
* (%)
@ -154,6 +159,12 @@ public class ErpProjectPlanStageVo implements Serializable {
@ExcelProperty(value = "实际回款金额")
private BigDecimal actualRepaymentAmount;
/**
* (%)
*/
@ExcelProperty(value = "实际回款比例(%)")
private BigDecimal actualRepaymentRate;
/**
*
*/

@ -12,6 +12,7 @@ import org.dromara.common.mybatis.annotation.DataPermission;
import org.dromara.oa.erp.domain.ErpProjectPlan;
import org.dromara.oa.erp.domain.bo.ErpProjectPlanBo;
import org.dromara.oa.erp.domain.vo.ContractCollectionPageVo;
import org.dromara.oa.erp.domain.vo.ContractCollectionStageDetailVo;
import org.dromara.oa.erp.domain.vo.ErpProjectPlanVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
@ -139,5 +140,10 @@ public interface ErpProjectPlanMapper extends BaseMapperPlus<ErpProjectPlan, Erp
Page<ContractCollectionPageVo> selectContractCollectionPage(@Param("page") Page<ContractCollectionPageVo> page,
@Param("bo") ErpProjectPlanBo bo);
/**
* + +
* payment_stage_id payment_stage_id
*/
List<ContractCollectionStageDetailVo> selectContractCollectionStageDetail(@Param("projectPlanId") Long projectPlanId);
}

@ -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);
}
/**

@ -10,6 +10,7 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.dromara.oa.base.domain.BasePaymentStage;
import org.dromara.oa.erp.domain.bo.ErpProjectPlanStageBo;
import org.dromara.oa.erp.domain.vo.ErpProjectPlanStageVo;
import org.dromara.oa.erp.domain.ErpProjectPlanStage;
@ -73,13 +74,15 @@ public class ErpProjectPlanStageServiceImpl implements IErpProjectPlanStageServi
Map<String, Object> params = bo.getParams();
MPJLambdaWrapper<ErpProjectPlanStage> lqw = JoinWrappers.lambda(ErpProjectPlanStage.class)
.selectAll(ErpProjectPlanStage.class)
.selectAs(BasePaymentStage::getStageName, ErpProjectPlanStageVo::getPaymentStageName)
.leftJoin(BasePaymentStage.class, BasePaymentStage::getPaymentStageId, ErpProjectPlanStage::getPaymentStageId)
.eq(ErpProjectPlanStage::getDelFlag, "0")
.eq(bo.getProjectId() != null, ErpProjectPlanStage::getProjectId, bo.getProjectId())
.eq(bo.getProjectPlanId() != null, ErpProjectPlanStage::getProjectPlanId, bo.getProjectPlanId())
.eq(StringUtils.isNotBlank(bo.getProjectPhases()), ErpProjectPlanStage::getProjectPhases, bo.getProjectPhases())
.eq(bo.getPlanStartTime() != null, ErpProjectPlanStage::getPlanStartTime, bo.getPlanStartTime())
.eq(bo.getPlanEndTime() != null, ErpProjectPlanStage::getPlanEndTime, bo.getPlanEndTime())
.eq(StringUtils.isNotBlank(bo.getCollectionStage()), ErpProjectPlanStage::getCollectionStage, bo.getCollectionStage())
.eq(bo.getPaymentStageId() != null, ErpProjectPlanStage::getPaymentStageId, bo.getPaymentStageId())
.eq(bo.getRepaymentRate() != null, ErpProjectPlanStage::getRepaymentRate, bo.getRepaymentRate())
.eq(bo.getRepaymentAmount() != null, ErpProjectPlanStage::getRepaymentAmount, bo.getRepaymentAmount())
.eq(bo.getRepaymentTime() != null, ErpProjectPlanStage::getRepaymentTime, bo.getRepaymentTime())

@ -7,7 +7,6 @@
</resultMap>
<resultMap type="org.dromara.oa.erp.domain.vo.ContractCollectionPageVo" id="ContractCollectionPageResult">
</resultMap>
<select id="selectCustomErpProjectPlanVoList" resultMap="ErpProjectPlanResult">
select t.project_plan_id,
t.tenant_id,
@ -405,5 +404,44 @@
order by p.create_time desc
</select>
<!-- 合同回款阶段明细:计划阶段 payment_stage_id 与合同付款节点 payment_stage_id 关联 -->
<select id="selectContractCollectionStageDetail" resultType="org.dromara.oa.erp.domain.vo.ContractCollectionStageDetailVo">
select pm.payment_method_id,
pm.contract_id,
pm.payment_stage_id,
bps.stage_name,
bps.collection_stage,
pm.payment_percentage,
pm.payment_amount,
pm.payment_deadline,
pm.payment_description,
ps.plan_stage_id,
ps.repayment_rate,
ps.repayment_amount,
ps.receivable_date,
ps.actual_repayment_amount,
case
when ps.plan_stage_id is null then null
when ps.actual_repayment_rate is not null then ps.actual_repayment_rate
when ps.repayment_amount is null or ps.repayment_amount = 0 then 0
else round(ifnull(ps.actual_repayment_amount, 0) * 100 / ps.repayment_amount, 2)
end as actual_repayment_rate,
ps.collection_confirm_user_id,
ps.collection_confirm_time,
ps.collection_confirm_status,
ps.collection_confirm_remark
from erp_project_plan pp
inner join erp_contract_payment_method pm
on pm.contract_id = pp.contract_id and pm.del_flag = '0'
left join base_payment_stage bps on bps.payment_stage_id = pm.payment_stage_id
left join erp_project_plan_stage ps
on ps.project_plan_id = pp.project_plan_id
and ps.del_flag = '0'
and ps.payment_stage_id is not null
and ps.payment_stage_id = pm.payment_stage_id
where pp.project_plan_id = #{projectPlanId}
and pp.del_flag = '0'
order by pm.sort_order asc
</select>
</mapper>

@ -7,7 +7,7 @@
</resultMap>
<select id="selectCustomErpProjectPlanStageVoList" resultMap="ErpProjectPlanStageResult">
select plan_stage_id, tenant_id, project_id, project_plan_id, project_phases, plan_start_time, plan_end_time, collection_stage, repayment_rate, repayment_amount, repayment_time, delay_day, receivable_date, reasons_explanation, schedule_remark, real_start_time, real_end_time, sort_order, remark, active_flag, actual_repayment_amount, collection_confirm_user_id, collection_confirm_time, collection_confirm_status, collection_confirm_remark, del_flag, create_dept, create_by, create_time, update_by, update_time from erp_project_plan_stage t
select plan_stage_id, tenant_id, project_id, project_plan_id, project_phases, plan_start_time, plan_end_time, payment_stage_id, repayment_rate, repayment_amount, repayment_time, delay_day, receivable_date, reasons_explanation, schedule_remark, real_start_time, real_end_time, sort_order, remark, active_flag, actual_repayment_amount, collection_confirm_user_id, collection_confirm_time, collection_confirm_status, collection_confirm_remark, del_flag, create_dept, create_by, create_time, update_by, update_time from erp_project_plan_stage t
<where>
<if test="ew != null and ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
@ -17,14 +17,14 @@
<!-- 根据ID查询详情 -->
<select id="selectCustomErpProjectPlanStageVoById" resultMap="ErpProjectPlanStageResult">
select plan_stage_id, tenant_id, project_id, project_plan_id, project_phases, plan_start_time, plan_end_time, collection_stage, repayment_rate, repayment_amount, repayment_time, delay_day, receivable_date, reasons_explanation, schedule_remark, real_start_time, real_end_time, sort_order, remark, active_flag, actual_repayment_amount, collection_confirm_user_id, collection_confirm_time, collection_confirm_status, collection_confirm_remark, del_flag, create_dept, create_by, create_time, update_by, update_time
select plan_stage_id, tenant_id, project_id, project_plan_id, project_phases, plan_start_time, plan_end_time, payment_stage_id, repayment_rate, repayment_amount, repayment_time, delay_day, receivable_date, reasons_explanation, schedule_remark, real_start_time, real_end_time, sort_order, remark, active_flag, actual_repayment_amount, collection_confirm_user_id, collection_confirm_time, collection_confirm_status, collection_confirm_remark, del_flag, create_dept, create_by, create_time, update_by, update_time
from erp_project_plan_stage t
where t.plan_stage_id = #{planStageId}
</select>
<!-- 批量查询 - 根据ID列表 -->
<select id="selectCustomErpProjectPlanStageVoByIds" resultMap="ErpProjectPlanStageResult">
select plan_stage_id, tenant_id, project_id, project_plan_id, project_phases, plan_start_time, plan_end_time, collection_stage, repayment_rate, repayment_amount, repayment_time, delay_day, receivable_date, reasons_explanation, schedule_remark, real_start_time, real_end_time, sort_order, remark, active_flag, actual_repayment_amount, collection_confirm_user_id, collection_confirm_time, collection_confirm_status, collection_confirm_remark, del_flag, create_dept, create_by, create_time, update_by, update_time
select plan_stage_id, tenant_id, project_id, project_plan_id, project_phases, plan_start_time, plan_end_time, payment_stage_id, repayment_rate, repayment_amount, repayment_time, delay_day, receivable_date, reasons_explanation, schedule_remark, real_start_time, real_end_time, sort_order, remark, active_flag, actual_repayment_amount, collection_confirm_user_id, collection_confirm_time, collection_confirm_status, collection_confirm_remark, del_flag, create_dept, create_by, create_time, update_by, update_time
from erp_project_plan_stage t
where t.plan_stage_id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
@ -44,7 +44,7 @@
<!-- 分页查询(带自定义条件) -->
<select id="selectCustomErpProjectPlanStageVoPage" resultMap="ErpProjectPlanStageResult">
select plan_stage_id, tenant_id, project_id, project_plan_id, project_phases, plan_start_time, plan_end_time, collection_stage, repayment_rate, repayment_amount, repayment_time, delay_day, receivable_date, reasons_explanation, schedule_remark, real_start_time, real_end_time, sort_order, remark, active_flag, actual_repayment_amount, collection_confirm_user_id, collection_confirm_time, collection_confirm_status, collection_confirm_remark, del_flag, create_dept, create_by, create_time, update_by, update_time
select plan_stage_id, tenant_id, project_id, project_plan_id, project_phases, plan_start_time, plan_end_time, payment_stage_id, repayment_rate, repayment_amount, repayment_time, delay_day, receivable_date, reasons_explanation, schedule_remark, real_start_time, real_end_time, sort_order, remark, active_flag, actual_repayment_amount, collection_confirm_user_id, collection_confirm_time, collection_confirm_status, collection_confirm_remark, del_flag, create_dept, create_by, create_time, update_by, update_time
from erp_project_plan_stage t
<where>
<if test="ew != null and ew.sqlSegment != null and ew.sqlSegment != ''">
@ -68,7 +68,7 @@
plan_end_time,
collection_stage,
payment_stage_id,
repayment_rate,
@ -127,7 +127,7 @@
#{item.planEndTime},
#{item.collectionStage},
#{item.paymentStageId},
#{item.repaymentRate},
@ -197,8 +197,8 @@
<if test="item.planEndTime != null">
plan_end_time = #{item.planEndTime},
</if>
<if test="item.collectionStage != null and item.collectionStage != ''">
collection_stage = #{item.collectionStage},
<if test="item.paymentStageId != null">
payment_stage_id = #{item.paymentStageId},
</if>
<if test="item.repaymentRate != null">
repayment_rate = #{item.repaymentRate},

Loading…
Cancel
Save