liukangdong
2024-12-03 8dcbe3d898f6c60ef3226095d994ca8953bf5f6d
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractRevenueServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.business.impl;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
@@ -29,10 +30,7 @@
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -66,6 +64,10 @@
    @Autowired
    private SystemUserMapper systemUserMapper;
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Override
@@ -112,8 +114,10 @@
        ywContractRevenue.setContractId(ywContractBill.getContractId());
        //根据收支情况 更新账单数据
        //查询当前账单下 已支付的费用
        List<YwContractRevenue> ywContractRevenueList = ywContractRevenueMapper.selectList(new QueryWrapper<YwContractRevenue>().lambda().eq(YwContractRevenue::getIsdeleted,Constants.ZERO)
        List<YwContractRevenue> ywContractRevenueList = ywContractRevenueMapper.selectList(new QueryWrapper<YwContractRevenue>()
                .lambda().eq(YwContractRevenue::getIsdeleted,Constants.ZERO)
                .eq(YwContractRevenue::getStatus,Constants.ZERO)
                .eq(YwContractRevenue::getBillId,ywContractRevenue.getBillId())
        );
        //已支付金额
        BigDecimal payTotal = BigDecimal.ZERO;
@@ -147,14 +151,14 @@
            //待支付的流水 如果为收入 则比对 金额值  如果是支出 则获取绝对值 进行对比
            if(Constants.equalsInteger(ywContractRevenue.getRevenueType(),Constants.ZERO)){
                //如果支付金额 大于 待支付金额 则提示异常 如果支付金额小于 待支付金额 则状态不变化 其他状态 异常
                if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())>Constants.ZERO){
                if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())<Constants.ZERO){
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"请输入正确的金额!");
                }else if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())==Constants.ZERO){
                    ywContractBill.setPayStatus(Constants.ONE);
                }
            }else{
                waitPayTotal = waitPayTotal.abs();
                if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())>Constants.ZERO){
                if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())<Constants.ZERO){
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"请输入正确的金额!");
                }else if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())==Constants.ZERO){
                    ywContractBill.setPayStatus(Constants.ONE);
@@ -230,14 +234,36 @@
                        .selectAs(YwContract::getCode,YwContractRevenue::getContractCode)
                        .selectAs(YwCustomer::getName,YwContractRevenue::getCustomerName)
                        .selectAs(SystemUser::getRealname,YwContractRevenue::getRealname)
                        .selectAs(YwAccount::getTitle,YwContractRevenue::getAccountTitle)
                        .leftJoin(YwContractBill.class,YwContractBill::getId,YwContractRevenue::getBillId)
                        .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
                        .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
                        .leftJoin(SystemUser.class,SystemUser::getId,YwContractRevenue::getCreator)
                        .leftJoin(YwAccount.class,YwAccount::getId,YwContractRevenue::getAccountId)
                        .eq(YwContractRevenue::getId,id)
        );
       this.getRecordData(ywContractRevenue);
        //附件数据
        List<Multifile> multifileList = multifileMapper.selectJoinList(Multifile.class,new MPJLambdaWrapper<Multifile>()
                .selectAll(Multifile.class)
                .selectAs(SystemUser::getRealname,Multifile::getUserName)
                .leftJoin(SystemUser.class,SystemUser::getId,Multifile::getCreator)
                .eq(Multifile::getObjId,id)
                .eq(Multifile::getIsdeleted,Constants.ZERO)
                .eq(Multifile::getObjType,Constants.MultiFile.FN_CONTRACT_REVENUE_FILE.getKey()));
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){
            String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode()
                    +systemDictDataBiz.queryByCode(Constants.FTP,Constants.YW_CONTRACT_BILL).getCode();
            for (Multifile multifile:multifileList) {
                if(StringUtils.isNotBlank(multifile.getFileurl())){
                    multifile.setFileurlFull(path + multifile.getFileurl());
                }
            }
            ywContractRevenue.setMultifileList(multifileList);
        }
        return ywContractRevenue;
    }
@@ -289,11 +315,11 @@
        if(Objects.isNull(ywContract)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        if(Constants.equalsInteger(ywContract.getStatus(),Constants.THREE)){
        if(Constants.equalsInteger(ywContract.getStatus(),Constants.FOUR)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合同状态已流转,无法操作");
        }
        if(Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.ONE)
            || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.TWO)){
            || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.FIVE)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"账单状态已流转,无法操作");
        }
        //查询账单下 所有的账单
@@ -345,7 +371,7 @@
    public List<YwContractRevenue> findList(YwContractRevenue ywContractRevenue) {
        List<YwContractRevenue> ywContractRevenueList = ywContractRevenueMapper.selectJoinList(YwContractRevenue.class,new MPJLambdaWrapper<YwContractRevenue>()
                .selectAll(YwContractRevenue.class)
                .selectAs(YwCustomer::getName,YwContractRevenue::getCustomerNme)
                .selectAs(YwCustomer::getName,YwContractRevenue::getCustomerName)
                .leftJoin(YwContract.class,YwContract::getId,YwContractRevenue::getContractId)
                .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
                .eq(YwContractRevenue::getStatus,Constants.ZERO)
@@ -363,6 +389,7 @@
        IPage<YwContractRevenue> iPage = ywContractRevenueMapper.selectJoinPage(page,YwContractRevenue.class,
                queryWrapper.selectAll(YwContractRevenue.class)
                        .selectAs(YwContractBill::getCode,YwContractRevenue::getBillCode)
                        .selectAs(YwContractBill::getType,YwContractRevenue::getBillType)
                         .selectAs(YwContract::getCode,YwContractRevenue::getContractCode)
                        .selectAs(YwCustomer::getName,YwContractRevenue::getCustomerName)
                        .selectAs(SystemUser::getRealname,YwContractRevenue::getRealname)
@@ -371,8 +398,8 @@
                        .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
                        .leftJoin(SystemUser.class,SystemUser::getId,YwContractRevenue::getCreator)
                        .eq(YwContractRevenue::getIsdeleted,Constants.ZERO)
                        .like(Objects.nonNull(model)&&StringUtils.isNotBlank(model.getCustomerNme()),
                                YwCustomer::getName,model.getCustomerNme())
                        .like(Objects.nonNull(model)&&StringUtils.isNotBlank(model.getCustomerName()),
                                YwCustomer::getName,model.getCustomerName())
                        .eq(Objects.nonNull(model)&&Objects.nonNull(model.getPayType()),
                                YwContractRevenue::getPayType,model.getPayType())
                        .eq(Objects.nonNull(model)&&Objects.nonNull(model.getRevenueType()),
@@ -386,25 +413,39 @@
        for (YwContractRevenue ywContractRevenue:iPage.getRecords()) {
            //楼宇名称
            List<YwContractRoom> ywContractRoomList = ywContractRevenue.getYwContractRoomList();
            StringBuilder roomPathName = new StringBuilder();
            for (YwContractRoom ywContractRoom:ywContractRoomList) {
                if(StringUtils.isNotBlank(ywContractRoom.getProjectName())){
                    roomPathName.append(ywContractRoom.getProjectName()+"/");
            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractRoomList)){
                StringBuilder roomPathName = new StringBuilder();
                for (YwContractRoom ywContractRoom:ywContractRoomList) {
                    if(Constants.equalsInteger(ywContractRevenue.getBillType(),Constants.ZERO)){
                        if(!(Constants.equalsInteger(ywContractRevenue.getContractId(),ywContractRoom.getContractId())
                        && Constants.equalsInteger(ywContractRoom.getType(),Constants.ZERO))){
                            continue;
                        }
                    }else{
                        if(!(Constants.equalsInteger(ywContractRevenue.getBillId(),ywContractRoom.getContractId())
                                && Constants.equalsInteger(ywContractRoom.getType(),Constants.ONE))){
                            continue;
                        }
                    }
                    if(StringUtils.isNotBlank(ywContractRoom.getProjectName())){
                        roomPathName.append(ywContractRoom.getProjectName()+"/");
                    }
                    if(StringUtils.isNotBlank(ywContractRoom.getBuildingName())){
                        roomPathName.append(ywContractRoom.getBuildingName()+"/");
                    }
                    if(StringUtils.isNotBlank(ywContractRoom.getFloorName())){
                        roomPathName.append(ywContractRoom.getFloorName()+"/");
                    }
                    if(StringUtils.isNotBlank(ywContractRoom.getRoomName())){
                        roomPathName.append(ywContractRoom.getRoomName());
                    }
                    if(StringUtils.isNotBlank(roomPathName)){
                        roomPathName.append(";");
                    }
                }
                if(StringUtils.isNotBlank(ywContractRoom.getBuildingName())){
                    roomPathName.append(ywContractRoom.getBuildingName()+"/");
                }
                if(StringUtils.isNotBlank(ywContractRoom.getFloorName())){
                    roomPathName.append(ywContractRoom.getFloorName()+"/");
                }
                if(StringUtils.isNotBlank(ywContractRoom.getRoomName())){
                    roomPathName.append(ywContractRoom.getRoomName());
                }
                if(StringUtils.isNotBlank(roomPathName)){
                    roomPathName.append(";");
                }
                ywContractRevenue.setRoomPathName(roomPathName.toString());
            }
            ywContractRevenue.setRoomPathName(roomPathName.toString());
        }
        return PageData.from(iPage);
    }
@@ -415,24 +456,30 @@
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractRevenueList)){
            //获取所有数据
            List<Integer> billIdList = ywContractRevenueList.stream().map(i->i.getBillId()).collect(Collectors.toList());
            List<Integer> contractIdList = ywContractRevenueList.stream().map(i->i.getContractId()).collect(Collectors.toList());
            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(billIdList)){
                List<YwContractRoom> ywContractRoomList  = ywContractRoomMapper.selectJoinList(YwContractRoom.class,new MPJLambdaWrapper<YwContractRoom>()
                        .selectAll(YwContractRoom.class)
                        .selectAs(YwProject::getName,YwRoom::getProjectName)
                        .selectAs(YwFloor::getName,YwRoom::getFloorName)
                        .selectAs(YwBuilding::getName,YwRoom::getBuildingName)
                        .selectAs(YwRoom::getName,YwContractRoom::getRoomName)
                        .selectAs(YwRoom::getCode,YwContractRoom::getRoomName)
                        .leftJoin(YwRoom.class,YwRoom::getId,YwContractRoom::getRoomId)
                        .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor)
                        .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
                        .leftJoin(YwBuilding.class,YwBuilding::getId,YwRoom::getBuildingId)
                        .in(YwContractRoom::getContractId,billIdList)
                        .eq(YwContractRoom::getType,Constants.ONE)
                        .and(i->i.in(YwContractRoom::getContractId,billIdList).eq(YwContractRoom::getType,Constants.ONE)
                                .or().in(YwContractRoom::getContractId,contractIdList).eq(YwContractRoom::getType,Constants.ZERO)
                        )
//                        .in(YwContractRoom::getContractId,billIdList)
//                        .eq(YwContractRoom::getType,Constants.ONE)
                );
                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractRoomList)){
                    for (YwContractRevenue ywContractRevenue:ywContractRevenueList) {
                        ywContractRevenue.setYwContractRoomList(
                                ywContractRoomList.stream().filter(i->Constants.equalsInteger(i.getContractId(),ywContractRevenue.getBillId())).collect(Collectors.toList())
                                ywContractRoomList.stream().filter(i->
                                        Constants.equalsInteger(i.getContractId(),ywContractRevenue.getBillId())||Constants.equalsInteger(i.getContractId(),ywContractRevenue.getContractId()))
                                        .collect(Collectors.toList())
                        );
                    }
                }