shiyunteng
2026-05-25 633a003d232e37c79b7135ccda35eda1c69952c6
feat:统计数据测试调整
13个文件已修改
408 ■■■■ 已修改文件
platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/ContractPaymentSchedule.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/vo/ContractIncomeAnalysisVo.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/vo/ContractPaymentScheduleVo.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/StatisticController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/mapper/ContractMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/StatisticService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractPaymentScheduleProcessServiceImpl.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentConfirmServiceImpl.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentOffsetServiceImpl.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/StatisticServiceImpl.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml 154 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/ContractPaymentSchedule.java
@@ -102,10 +102,10 @@
    @Column(columnDefinition = "datetime comment '收款日期'")
    private Date paymentDate;
    @Schema(description = "收款阶段生效日期(隐性要素 - 履约时间起点,即该节点实际达成的日期)")
    @Schema(description = "收款阶段生效日期(作废 以截止日期为准)")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
    @Column(columnDefinition = "date comment '收款阶段生效日期(履约节点实际达成日期)'")
    @Column(columnDefinition = "date comment '收款阶段生效日期(履约节点实际达成日期) 作废 以截止日期为准'")
    private Date effectiveDate;
    @Schema(description = "收款阶段截止日期")
platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/vo/ContractIncomeAnalysisVo.java
@@ -5,6 +5,8 @@
@Data
public class ContractIncomeAnalysisVo {
    private String compId;
    private String compName;
    private String srMonth1;
platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/vo/ContractPaymentScheduleVo.java
@@ -2,13 +2,11 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
public class ContractPaymentScheduleVo {
@@ -18,6 +16,9 @@
    @Schema(description = "收款阶段名称(显性要素,如:合同签订预付、发货前付款、货到签收付款、调试完成付款、质保金)")
    private String stageName;
    @Schema(description = "收款比例(%,如30表示30%)(显性要素)")
    private BigDecimal paymentRatio;
    @Schema(description = "计划收款金额(根据合同总金额*比例自动计算)")
    private BigDecimal plannedAmount;
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/StatisticController.java
@@ -111,4 +111,13 @@
    public R contractAmountAnalysisByExportBus(@RequestBody AnalysisCommonDTO commonDTO) {
        return statisticService.contractAmountAnalysisByExportBus(commonDTO);
    }
    /**
     * 分销售模式合同金额统计
     * @return R
     */
    @PostMapping("/contractAmountAnalysisBySaleModel")
    public R contractAmountAnalysisBySaleModel(@RequestBody AnalysisCommonDTO commonDTO) {
        return statisticService.contractAmountAnalysisBySaleModel(commonDTO);
    }
}
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/mapper/ContractMapper.java
@@ -54,4 +54,9 @@
                                                                         @Param("tfCompId") Long tfgs,@Param("ymjCompId") Long ymj);
    List<ContractAmountAnalysisCompVo> contractAmountAnalysisByComp(@Param("queryDTO")AnalysisCommonDTO commonDTO,@Param("compId") Long compId);
    List<ContractIncomeAnalysisAreaVo> contractAmountAnalysisBySaleModel(@Param("queryDTO")AnalysisCommonDTO commonDTO
            ,@Param("compIds")List<Long> compIds,@Param("smjCompId") Long smj,
                                                                         @Param("sgbCompId")Long sgb, @Param("jxcCompId")Long jxc,
                                                                         @Param("tfCompId") Long tfgs,@Param("ymjCompId") Long ymj);
}
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/StatisticService.java
@@ -21,4 +21,6 @@
    R contractAmountAnalysisByExportBus(AnalysisCommonDTO commonDTO);
    R contractAmountAnalysisByComp(AnalysisCommonDTO commonDTO);
    R contractAmountAnalysisBySaleModel(AnalysisCommonDTO commonDTO);
}
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractPaymentScheduleProcessServiceImpl.java
@@ -81,17 +81,17 @@
        //更新当前阶段
        if (ObjUtil.isNull(schedule.getEffectiveDate()) && ObjUtil.isNull(schedule.getEffectiveEndDate())) {
            schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays()));
            schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays()));
            contractPaymentScheduleMapper.updateById(schedule);
        }
        //查询是否有之前阶段
        ContractPaymentSchedule beforeSchedule = contractPaymentScheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId())
                .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1"));
        if (ObjUtil.isNotNull(beforeSchedule) && ObjUtil.isNull(beforeSchedule.getEffectiveEndDate())) {
            beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate());
            contractPaymentScheduleMapper.updateById(beforeSchedule);
        }
//        //查询是否有之前阶段
//        ContractPaymentSchedule beforeSchedule = contractPaymentScheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId())
//                .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1"));
//        if (ObjUtil.isNotNull(beforeSchedule) && ObjUtil.isNull(beforeSchedule.getEffectiveEndDate())) {
//            beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate());
//            contractPaymentScheduleMapper.updateById(beforeSchedule);
//        }
        List<ContractOutBound> contractOutBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery().eq(ContractOutBound::getContractId, contract.getId())
                .isNotNull(ContractOutBound::getArrivalTime));
@@ -186,13 +186,11 @@
                        //最后阶段生效时间
                        ContractPaymentSchedule endSchedule = afterSchedule.get(0);
                        if (StrUtil.equals(endSchedule.getStageName(), "质保金")) {
                            endSchedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), endSchedule.getAgreedDays()));
                            endSchedule.setEffectiveEndDate(contract.getExpirationDate());
                            endSchedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), endSchedule.getAgreedDays()));
                            contractPaymentScheduleMapper.updateById(endSchedule);
                            //当前阶段生效时间
                            schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays()));
                            schedule.setEffectiveEndDate(endSchedule.getEffectiveDate());
                            contractPaymentScheduleMapper.updateById(schedule);
//                            schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays()));
//                            contractPaymentScheduleMapper.updateById(schedule);
                            //最后阶段应收
                            PaymentConfirm newConfim = new PaymentConfirm();
                            newConfim.setBusinessType(endSchedule.getStageName() + "应收");
@@ -228,8 +226,8 @@
                        contractMapper.updateById(contract);
                    }
                    if (ArrayUtil.isEmpty(afterSchedule.toArray())) {
                        schedule.setEffectiveEndDate(contract.getExpirationDate());
                        contractPaymentScheduleMapper.updateById(schedule);
//                        schedule.setEffectiveEndDate(contract.getExpirationDate());
//                        contractPaymentScheduleMapper.updateById(schedule);
                        //更新合同下个阶段
                        contract.setNextScheduleName("无");
                        contractMapper.updateById(contract);
@@ -277,12 +275,10 @@
                //最后阶段生效时间
                ContractPaymentSchedule endSchedule = afterSchedule.get(0);
                if (StrUtil.equals(endSchedule.getStageName(), "质保金")) {
                    endSchedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), endSchedule.getAgreedDays()));
                    endSchedule.setEffectiveEndDate(contract.getExpirationDate());
                    endSchedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), endSchedule.getAgreedDays()));
                    contractPaymentScheduleMapper.updateById(endSchedule);
                    //当前阶段生效时间
                    schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays()));
                    schedule.setEffectiveEndDate(endSchedule.getEffectiveDate());
                    schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays()));
                    contractPaymentScheduleMapper.updateById(schedule);
                    //最后阶段应收
                    PaymentConfirm newConfim = new PaymentConfirm();
@@ -319,8 +315,8 @@
                contractMapper.updateById(contract);
            }
            if (ArrayUtil.isEmpty(afterSchedule.toArray())) {
                schedule.setEffectiveEndDate(contract.getExpirationDate());
                contractPaymentScheduleMapper.updateById(schedule);
//                schedule.setEffectiveEndDate(contract.getExpirationDate());
//                contractPaymentScheduleMapper.updateById(schedule);
                //更新合同下个阶段
                contract.setNextScheduleName("无");
                contractMapper.updateById(contract);
@@ -396,7 +392,7 @@
                        ContractPaymentSchedule::getPlannedAmount, ContractPaymentSchedule::getPlannedAmount,
                        ContractPaymentSchedule::getEffectiveEndDate, ContractPaymentSchedule::getPaymentDate,
                        ContractPaymentSchedule::getPaymentStatus, ContractPaymentSchedule::getActualAmount,
                        ContractPaymentSchedule::getAgreedDays)
                        ContractPaymentSchedule::getAgreedDays,ContractPaymentSchedule::getPaymentRatio)
                .select(ContractPaymentScheduleProcess::getProcessDate)
                .leftJoin(ContractPaymentScheduleProcess.class, ContractPaymentScheduleProcess::getScheduleId, ContractPaymentSchedule::getId)
                .eq(ContractPaymentSchedule::getContractId, id)
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java
@@ -97,7 +97,7 @@
                int currentIndex = index.getAndIncrement();
                ContractPaymentSchedule schedule = BeanUtil.copyProperties(contractPaymentScheduleAddDTO, ContractPaymentSchedule.class);
                if (contractPaymentScheduleAddDTO.getStageName().equals("合同签订")){
                    schedule.setEffectiveDate(DateUtil.offsetDay(contract.getSignDate(),contractPaymentScheduleAddDTO.getAgreedDays()));
                    schedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(), contractPaymentScheduleAddDTO.getAgreedDays()));
                }
                if (ObjUtil.isNotNull(schedule.getEffectiveDate())) {
                    if (schedule.getEffectiveDate().before(DateUtil.date())) {
@@ -106,7 +106,11 @@
                        schedule.setFulfillmentStatus(0);
                    }
                }
                if (contractPaymentScheduleAddDTO.getPaymentRatio().compareTo(new BigDecimal("0")) > 0) {
                schedule.setPaymentStatus(0);
                }else {
                    schedule.setPaymentStatus(3);
                }
                schedule.setContractId(contract.getId());
                schedule.setContractName(contract.getContractName());
                schedule.setPlannedAmount(contract.getAmount().multiply(schedule.getPaymentRatio().divide(new BigDecimal("100"))));
@@ -123,7 +127,6 @@
            });
        }
        return R.ok();
@@ -172,6 +175,11 @@
                schedule.setContractName(contract.getContractName());
                schedule.setPlannedAmount(contract.getAmount().multiply(schedule.getPaymentRatio().divide(new BigDecimal("100"))));
                schedule.setStageOrder(currentIndex);
                if (contractPaymentScheduleAddDTO.getPaymentRatio().compareTo(new BigDecimal("0")) > 0) {
                    schedule.setPaymentStatus(0);
                }else {
                    schedule.setPaymentStatus(3);
                }
                contractPaymentScheduleMapper.insert(schedule);
                if (contractPaymentScheduleAddDTO.getStageName().equals("货到签收")){
                    contract.setArrivalScheduleId(schedule.getId());
@@ -267,14 +275,8 @@
            //最后阶段生效时间
            ContractPaymentSchedule endSchedule = afterSchedule.get(0);
            if (StrUtil.equals(endSchedule.getStageName(),"质保金")){
                endSchedule.setEffectiveDate(DateUtil.offsetDay(new Date(),endSchedule.getAgreedDays()));
                endSchedule.setEffectiveEndDate(contract.getExpirationDate());
                contractPaymentScheduleMapper.updateById(endSchedule);
                //第一阶段生效时间
                fitstSchedule.setEffectiveDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays()));
                fitstSchedule.setEffectiveEndDate(endSchedule.getEffectiveDate());
                contractPaymentScheduleMapper.updateById(fitstSchedule);
//                endSchedule.setEffectiveEndDate(DateUtil.offsetDay(new Date(),endSchedule.getAgreedDays()));
//                contractPaymentScheduleMapper.updateById(endSchedule);
                //最后阶段应收
                PaymentConfirm newConfim = new PaymentConfirm();
                newConfim.setBusinessType(endSchedule.getStageName()+"应收");
@@ -305,18 +307,17 @@
        }
        if(ArrayUtil.isNotEmpty(afterSchedule.toArray())&&afterSchedule.size()>1){
            //第一阶段生效时间
            fitstSchedule.setEffectiveDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays()));
            contractPaymentScheduleMapper.updateById(fitstSchedule);
//            fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays()));
//            contractPaymentScheduleMapper.updateById(fitstSchedule);
            //更新合同下个阶段
            contract.setNextScheduleName(afterSchedule.get(0).getStageName());
            baseMapper.updateById(contract);
        }
        //只有当前合同签字阶段
        if(ArrayUtil.isEmpty(afterSchedule.toArray())){
            fitstSchedule.setEffectiveDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays()));
            fitstSchedule.setEffectiveEndDate(contract.getExpirationDate());
            contractPaymentScheduleMapper.updateById(fitstSchedule);
        }
//        if(ArrayUtil.isEmpty(afterSchedule.toArray())){
//            fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays()));
//            contractPaymentScheduleMapper.updateById(fitstSchedule);
//        }
    }
    private void savePaymentConfirm(Contract contract, ContractPaymentSchedule schedule) {
@@ -393,7 +394,8 @@
    public R genCurrentOverdue() {
        List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
                .lt(ContractPaymentSchedule::getEffectiveEndDate, DateUtil.today())
                .ne(ContractPaymentSchedule::getPaymentStatus,"2"));
                .ne(ContractPaymentSchedule::getPaymentStatus, "2")
                .ne(ContractPaymentSchedule::getPaymentStatus,3));
        if (ArrayUtil.isNotEmpty(scheduleList.toArray())){
            scheduleList.stream().forEach(contractPaymentSchedule -> {
                Contract contract = baseMapper.selectById(contractPaymentSchedule.getContractId());
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java
@@ -269,21 +269,21 @@
                    //更新发货前收款生效时间
                    if (ObjUtil.isNull(schedule.getEffectiveDate())) {
                        schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays()));
                        schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays()));
                        //查询是否有后续阶段
                        List<ContractPaymentSchedule> afterSchedule = scheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contractId)
                                .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()));
                        if (ArrayUtil.isEmpty(afterSchedule.toArray())) {
                            schedule.setEffectiveEndDate(contract.getExpirationDate());
                        }
//                        List<ContractPaymentSchedule> afterSchedule = scheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contractId)
//                                .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()));
//                        if (ArrayUtil.isEmpty(afterSchedule.toArray())) {
//                            schedule.setEffectiveEndDate(contract.getExpirationDate());
//                        }
                        scheduleMapper.updateById(schedule);
                        //查询是否有之前阶段
                        ContractPaymentSchedule beforeSchedule = scheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId())
                                .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1"));
                        if (ObjUtil.isNotNull(beforeSchedule)) {
                            beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate());
                            scheduleMapper.updateById(beforeSchedule);
                        }
//                        ContractPaymentSchedule beforeSchedule = scheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId())
//                                .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1"));
//                        if (ObjUtil.isNotNull(beforeSchedule)) {
//                            beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate());
//                            scheduleMapper.updateById(beforeSchedule);
//                        }
                        //更新履约
                        ContractPaymentScheduleProcess contractPaymentScheduleProcess = new ContractPaymentScheduleProcess();
                        contractPaymentScheduleProcess.setContractId(schedule.getContractId());
@@ -291,7 +291,11 @@
                        contractPaymentScheduleProcess.setScheduleId(schedule.getId());
                        contractPaymentScheduleProcess.setScheduleName(schedule.getStageName());
                        contractPaymentScheduleProcess.setProcessDate(addDTO.getOutBoundTime());
                        ContractPaymentScheduleProcess lastProcess = scheduleProcessMapper.selectOne(Wrappers.<ContractPaymentScheduleProcess>lambdaQuery().eq(ContractPaymentScheduleProcess::getContractId, schedule.getContractId())
                                .eq(ContractPaymentScheduleProcess::getScheduleId, schedule.getId()).last("limit 1"));
                        if (ObjUtil.isNull(lastProcess)) {
                        scheduleProcessMapper.insert(contractPaymentScheduleProcess);
                        }
                    }
                    //查询是否有后续阶段
@@ -303,13 +307,11 @@
                        //最后阶段生效时间
                        ContractPaymentSchedule endSchedule = afterSchedule.get(0);
                        if (StrUtil.equals(endSchedule.getStageName(), "质保金")) {
                            endSchedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), endSchedule.getAgreedDays()));
                            endSchedule.setEffectiveEndDate(contract.getExpirationDate());
                            scheduleMapper.updateById(endSchedule);
//                            endSchedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), endSchedule.getAgreedDays()));
//                            scheduleMapper.updateById(endSchedule);
                            //当前阶段生效时间
                            schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays()));
                            schedule.setEffectiveEndDate(endSchedule.getEffectiveDate());
                            scheduleMapper.updateById(schedule);
//                            schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays()));
//                            scheduleMapper.updateById(schedule);
                            //最后阶段应收
                            PaymentConfirm newConfim = new PaymentConfirm();
                            newConfim.setBusinessType(endSchedule.getStageName() + "应收");
@@ -344,8 +346,8 @@
                        contractMapper.updateById(contract);
                    }
                    if (ArrayUtil.isEmpty(afterSchedule.toArray())) {
                        schedule.setEffectiveEndDate(contract.getExpirationDate());
                        scheduleMapper.updateById(schedule);
//                        schedule.setEffectiveEndDate(contract.getExpirationDate());
//                        scheduleMapper.updateById(schedule);
                        //更新合同下个阶段
                        contract.setNextScheduleName("无");
                        contractMapper.updateById(contract);
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentConfirmServiceImpl.java
@@ -120,7 +120,7 @@
                }
                //更新付款阶段付款
                List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
                        .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2)
                        .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3)
                        .orderByAsc(ContractPaymentSchedule::getCreateTime));
                if (ArrayUtil.isNotEmpty(scheduleList.toArray())) {
                    BigDecimal remain = addDTO.getTransationAmount();
@@ -295,7 +295,8 @@
                    break;
                } else {
                    entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal));
                    entity.setTotalAmount(transtionAmount);
                    entity.setReceivableAmount(transtionRemainAmount.multiply(new BigDecimal("-1")));
                    entity.setTotalAmount(transtionRemainAmount);
                    entity.setConfirmTime(payDate);
                    baseMapper.insert(entity);
                    payContractList.add(contract);
@@ -307,6 +308,7 @@
                //更新付款阶段付款
                List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
                        .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2)
                        .ne(ContractPaymentSchedule::getPaymentStatus, 3)
                        .orderByAsc(ContractPaymentSchedule::getCreateTime));
                if (ArrayUtil.isNotEmpty(scheduleList.toArray())) {
                    BigDecimal remain = transtionAmount;
@@ -361,16 +363,18 @@
                //合同所有付款阶段
                List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
                        .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0)
                        );
                        .ne(ContractPaymentSchedule::getPaymentStatus, 3));
                if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())){
                    BigDecimal payTotal = payComScheduleList.stream().map(item->StrUtil.equals(item.getPaymentStatus() + "", "0") ? item.getPlannedAmount() :
                    BigDecimal payTotal = payComScheduleList.stream().map(item->StrUtil.equals(item.getPaymentStatus() + "", "2") ? item.getPlannedAmount() :
                            item.getActualAmount()).reduce(BigDecimal.ZERO,BigDecimal::add);
                    contract.setPaidAmount(payTotal);
                    if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) {
                        contract.setContractStatus(3);
                    }
//                    if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) {
//                        contract.setContractStatus(3);
//                    }
                    contractService.updateById(contract);
                    if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) {
                        contract.setBillingStatus("2");
                        contract.setContractStatus(3);
                        payCompleteContractList.add(contract);
                    }
                    //付款 且 付款未全付
@@ -619,7 +623,7 @@
        payContractList.stream().forEach(contract -> {
            //更新付款阶段付款
            List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
                    .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2)
                    .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3)
                    .orderByAsc(ContractPaymentSchedule::getCreateTime));
            if (ArrayUtil.isNotEmpty(scheduleList.toArray())) {
                BigDecimal remain = transtionAmount;
@@ -673,7 +677,7 @@
            }
            //合同所有付款阶段
            List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
                    .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0)
                    .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0).ne(ContractPaymentSchedule::getPaymentStatus,3)
            );
            if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())){
                BigDecimal payTotal = payComScheduleList.stream().map(item->StrUtil.equals(item.getPaymentStatus() + "", "0") ? item.getPlannedAmount() :
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentOffsetServiceImpl.java
@@ -77,7 +77,7 @@
        //更新付款阶段付款
        List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
                .eq(ContractPaymentSchedule::getContractId,contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus,2)
                .orderByAsc(ContractPaymentSchedule::getCreateTime));
                .ne(ContractPaymentSchedule::getPaymentStatus,3).orderByAsc(ContractPaymentSchedule::getCreateTime));
        if (ArrayUtil.isNotEmpty(scheduleList.toArray())){
            BigDecimal remain = paymentOffset.getOffsetAmount();
            for (ContractPaymentSchedule schedule:scheduleList) {
@@ -135,17 +135,18 @@
        }
        paid = paid.add(paymentOffset.getOffsetAmount());
        contract.setPaidAmount(paid);
        if (paid.compareTo(contract.getAmount())>0){
            contract.setPaidAmount(contract.getAmount());
        if (paid.compareTo(contract.getAmount())==0){
            contract.setBillingStatus("2");
            contract.setContractStatus(3);
        }
        contractService.updateById(contract);
        // 查询所有付款阶段是否都付款完成
        if (ArrayUtil.isNotEmpty(scheduleList.toArray())){
            if (scheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))){
                contract.setContractStatus(3);
                contractService.updateById(contract);
            };
        }
//        if (ArrayUtil.isNotEmpty(scheduleList.toArray())){
//            if (scheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))){
//                contract.setContractStatus(3);
//                contractService.updateById(contract);
//            };
//        }
        return R.ok();
    }
}
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/StatisticServiceImpl.java
@@ -1,9 +1,7 @@
package com.by4cloud.platformx.business.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.by4cloud.platformx.admin.api.entity.SysDept;
import com.by4cloud.platformx.admin.api.entity.SysDictItem;
import com.by4cloud.platformx.admin.api.feign.RemoteDeptService;
import com.by4cloud.platformx.admin.api.feign.RemoteDictService;
@@ -14,16 +12,12 @@
import com.by4cloud.platformx.common.core.util.R;
import com.by4cloud.platformx.common.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
@RequiredArgsConstructor
@@ -75,6 +69,25 @@
        compIds.add(Long.valueOf(ymj));
        compIds.add(Long.valueOf(jxc));
        List<ContractIncomeAnalysisVo> contractIncomeAnalysisVoList = contractMapper.contractIncomeAnalysis(commonDTO,compIds);
        if (ArrayUtil.isNotEmpty(contractIncomeAnalysisVoList.toArray())){
            contractIncomeAnalysisVoList.stream().forEach(contractIncomeAnalysisVo -> {
                if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),sgb)){
                    contractIncomeAnalysisVo.setCompName("石工泵");
                }
                if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),smj)){
                    contractIncomeAnalysisVo.setCompName("石煤机");
                }
                if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),ymj)){
                    contractIncomeAnalysisVo.setCompName("一煤机");
                }
                if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),tfgs)){
                    contractIncomeAnalysisVo.setCompName("通方公司");
                }
                if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),jxc)){
                    contractIncomeAnalysisVo.setCompName("机械厂");
                }
            });
        }
        return R.ok(contractIncomeAnalysisVoList);
    }
@@ -284,4 +297,45 @@
        return R.ok(contractIncomeAnalysisVoList);
    }
    @Override
    public R contractAmountAnalysisBySaleModel(AnalysisCommonDTO commonDTO) {
        R<List<SysDictItem>> r = remoteDictService.getDictByType("sales_model");
        List<SysDictItem> items = r.getData();
        if (ArrayUtil.isEmpty(items.toArray())){
            return R.failed("区域字段获取异常");
        }
        List<Long> compIds = new ArrayList<>();
        compIds.add(Long.valueOf(sgb));
        compIds.add(Long.valueOf(smj));
        compIds.add(Long.valueOf(tfgs));
        compIds.add(Long.valueOf(ymj));
        compIds.add(Long.valueOf(jxc));
        List<ContractIncomeAnalysisAreaVo> contractIncomeAnalysisVoList = items.stream().map(item -> {
            ContractIncomeAnalysisAreaVo analysisAreaVo = new ContractIncomeAnalysisAreaVo();
            analysisAreaVo.setAreaId(item.getItemValue());
            analysisAreaVo.setAreaName(item.getLabel());
            return analysisAreaVo;
        }).collect(Collectors.toList());
        contractMapper.setSession();
        List<ContractIncomeAnalysisAreaVo> statisticList = contractMapper.contractAmountAnalysisBySaleModel(commonDTO
                ,compIds,Long.valueOf(smj),Long.valueOf(sgb),Long.valueOf(jxc),Long.valueOf(tfgs),Long.valueOf(ymj));
        contractIncomeAnalysisVoList.stream().forEach(vo1->{
            statisticList.stream().forEach(vo2->{
                if (StrUtil.equals(vo1.getAreaId(),vo2.getAreaId())){
                    vo1.setJxczb(vo2.getJxczb());
                    vo1.setJxcze(vo2.getJxcze());
                    vo1.setSgbzb(vo2.getSgbzb());
                    vo1.setSgbze(vo2.getSgbze());
                    vo1.setSmjzb(vo2.getSmjzb());
                    vo1.setSmjze(vo2.getSmjze());
                    vo1.setTfzb(vo2.getTfzb());
                    vo1.setTfze(vo2.getTfze());
                    vo1.setYmjzb(vo2.getYmjzb());
                    vo1.setYmjze(vo2.getYmjze());
                }
            });
        });
        return R.ok(contractIncomeAnalysisVoList);
    }
}
platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
@@ -184,7 +184,7 @@
    <select id="contractIncomeAnalysis"
            resultType="com.by4cloud.platformx.business.vo.ContractIncomeAnalysisVo">
        SELECT
            compName,
            compId,
            SUM(CASE WHEN month_num = 1 THEN total_amount ELSE 0 END) AS 'srMonth1',
                SUM(CASE WHEN month_num = 1 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'xhMonth1',
                SUM(CASE WHEN month_num = 1 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth1',
@@ -202,9 +202,9 @@
                SUM(CASE WHEN month_num = 4 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth4',
                SUM(CASE WHEN month_num = 4 AND pay_type = 3 THEN total_amount ELSE 0 END) AS 'qtMonth4',
                SUM(CASE WHEN month_num = 5 THEN total_amount ELSE 0 END) AS 'srMonth5',
                SUM(CASE WHEN month_num = 5 AND pay_type = 0 THEN total_amount ELSE 0 END) AS 'xhMonth5',
                SUM(CASE WHEN month_num = 5 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'cdMonth5',
                SUM(CASE WHEN month_num = 5 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'qtMonth5',
                SUM(CASE WHEN month_num = 5 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'xhMonth5',
                SUM(CASE WHEN month_num = 5 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth5',
                SUM(CASE WHEN month_num = 5 AND pay_type = 3 THEN total_amount ELSE 0 END) AS 'qtMonth5',
                SUM(CASE WHEN month_num = 6 THEN total_amount ELSE 0 END) AS 'srMonth6',
                SUM(CASE WHEN month_num = 6 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'xhMonth6',
                SUM(CASE WHEN month_num = 6 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth6',
@@ -235,7 +235,7 @@
                SUM(CASE WHEN month_num = 12 AND pay_type = 3 THEN total_amount ELSE 0 END) AS 'qtMonth12'
        FROM (
        SELECT
        COALESCE(pc.payee_comp_id, '未知单位') AS compName,
        COALESCE(pc.payee_comp_id, '未知单位') AS compId,
        MONTH(payment_time) AS month_num,
        pay_type,
        COALESCE(payment_amount, 0) AS total_amount
@@ -250,7 +250,7 @@
            #{id}
        </foreach>
             ) AS source_data
        GROUP BY compName
        GROUP BY compId
    </select>
    <select id="contractIncomeAnalysisByComp"
@@ -746,9 +746,11 @@
        SELECT
        SUM( amount )
        FROM
        contract
        contract ct
        WHERE
        party_b_id IN
              ct.del_flag = '0'
        and  ct.supply_attribute = c.supply_attribute
        and ct.party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
@@ -761,9 +763,11 @@
        SELECT
        SUM( amount )
        FROM
        contract
        contract ct
        WHERE
        party_b_id IN
        ct.del_flag = '0'
        and  ct.supply_attribute = c.supply_attribute
        and ct.party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
@@ -776,9 +780,11 @@
        SELECT
        SUM( amount )
        FROM
        contract
        contract ct
        WHERE
        party_b_id IN
        ct.del_flag = '0'
        and  ct.supply_attribute = c.supply_attribute
        and ct.party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
@@ -791,9 +797,11 @@
        SELECT
        SUM( amount )
        FROM
        contract
        contract ct
        WHERE
        party_b_id IN
        ct.del_flag = '0'
        and  ct.supply_attribute = c.supply_attribute
        and ct.party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
@@ -806,9 +814,11 @@
        SELECT
        SUM( amount )
        FROM
        contract
        contract ct
        WHERE
        party_b_id IN
        ct.del_flag = '0'
        and  ct.supply_attribute = c.supply_attribute
        and ct.party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
@@ -818,7 +828,8 @@
        FROM
        contract c
        WHERE
        c.supply_attribute IS NOT NULL
            c.del_flag = '0'
        and c.supply_attribute IS NOT NULL
        AND YEAR ( sign_date ) = #{queryDTO.year}
        GROUP BY
        c.supply_attribute
@@ -888,4 +899,113 @@
        ORDER BY m.month_num
    </select>
    <select id="contractAmountAnalysisBySaleModel"
            resultType="com.by4cloud.platformx.business.vo.ContractIncomeAnalysisAreaVo">
        SELECT
        b.sales_model area_id,
        SUM( CASE WHEN c.party_b_id = #{sgbCompId} THEN c.amount ELSE 0 END ) AS sgbze,
        ROUND(
        SUM( CASE WHEN c.party_b_id = #{sgbCompId} THEN c.amount ELSE 0 END ) / (
        SELECT
        SUM( amount )
        FROM
        contract c, business_customer bc
        WHERE
        bc.id = c.party_a_id
        and c.del_flag = '0'
        and bc.del_flag = '0'
        and bc.sales_model = b.sales_model
        and party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
        ) * 100,
        2
        ) AS sgbzb,
        SUM( CASE WHEN c.party_b_id = #{jxcCompId} THEN c.amount ELSE 0 END ) AS jxcze,
        ROUND(
        SUM( CASE WHEN c.party_b_id = #{jxcCompId} THEN c.amount ELSE 0 END ) / (
        SELECT
        SUM( amount )
        FROM
        contract c, business_customer bc
        WHERE
        bc.id = c.party_a_id
        and c.del_flag = '0'
        and bc.del_flag = '0'
        and bc.sales_model = b.sales_model
        and party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
        ) * 100,
        2
        ) AS jxczb ,
        SUM( CASE WHEN c.party_b_id = #{smjCompId} THEN c.amount ELSE 0 END ) AS smjze,
        ROUND(
        SUM( CASE WHEN c.party_b_id = #{smjCompId} THEN c.amount ELSE 0 END ) / (
        SELECT
        SUM( amount )
        FROM
        contract c, business_customer bc
        WHERE
        bc.id = c.party_a_id
        and c.del_flag = '0'
        and bc.del_flag = '0'
        and bc.sales_model = b.sales_model
        and party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
        ) * 100,
        2
        ) AS smjzb ,
        SUM( CASE WHEN c.party_b_id = #{ymjCompId} THEN c.amount ELSE 0 END ) AS ymjze,
        ROUND(
        SUM( CASE WHEN c.party_b_id = #{ymjCompId} THEN c.amount ELSE 0 END ) / (
        SELECT
        SUM( amount )
        FROM
        contract c, business_customer bc
        WHERE
        bc.id = c.party_a_id
        and c.del_flag = '0'
        and bc.del_flag = '0'
        and bc.sales_model = b.sales_model
        and party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
        ) * 100,
        2
        ) AS ymjzb ,
        SUM( CASE WHEN c.party_b_id = #{tfCompId} THEN c.amount ELSE 0 END ) AS tfze,
        ROUND(
        SUM( CASE WHEN c.party_b_id = #{tfCompId} THEN c.amount ELSE 0 END ) / (
        SELECT
        SUM( amount )
        FROM
        contract c, business_customer bc
        WHERE
        bc.id = c.party_a_id
        and c.del_flag = '0'
        and bc.del_flag = '0'
        and bc.sales_model = b.sales_model
        and party_b_id IN
        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
        ) * 100,
        2
        ) AS tfzb
        FROM
        contract c
        JOIN business_customer b ON c.party_a_id = b.id
        WHERE
        b.sales_model IS NOT NULL
        AND YEAR ( sign_date ) = #{queryDTO.year}
        GROUP BY
        b.sales_model
    </select>
</mapper>