无关风月
2025-02-28 005e6b4740292ab02b262356e4b34bcad3527ab0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TContractServiceImpl.java
@@ -1,5 +1,7 @@
package com.ruoyi.system.service.impl;
import com.aizuda.bpm.engine.entity.FlwHisTask;
import com.aizuda.bpm.mybatisplus.mapper.FlwHisTaskMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.common.basic.PageInfo;
@@ -28,6 +30,7 @@
import com.ruoyi.system.vo.CheckAcceptRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -36,6 +39,7 @@
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
/**
 * <p>
@@ -59,6 +63,8 @@
    private TContractMapper contractMapper;
    @Autowired
    private StateProcessTemplateService stateProcessTemplateService;
    @Autowired
    private FlwHisTaskMapper flwHisTaskMapper;
    @Override
    public PageInfo<TContract> contractList(TContractQuery query) {
@@ -80,6 +86,12 @@
        for (TContract tContract : list) {
            tContract.setPayType(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CONTRACT_PAY_TYPE,tContract.getPayType()));
            tContract.setStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CONTRACT_STATUS,tContract.getStatus()));
            FlwHisTask flwHisTask = flwHisTaskMapper.selectOne(new LambdaQueryWrapper<FlwHisTask>()
                    .like(FlwHisTask::getVariable, tContract.getId())
                    .last("LIMIT 1"));
            if (Objects.nonNull(flwHisTask)){
                tContract.setInstanceId(flwHisTask.getInstanceId());
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
@@ -184,7 +196,7 @@
        variable.put("projectId", dto.getId());
        processStartBO.setVariable(variable);
        //开启工作流程
        stateProcessTemplateService.start(processStartBO);
        stateProcessTemplateService.startApplet(processStartBO);
        List<TContractRentType> contractRentTypes = contractRentTypeService.list();
        // 生成第一笔账单
@@ -254,7 +266,9 @@
                rentBill.setEndTime(contract.getEndTime());
            }else{
                rentBill.setEndTime(contract.getFirstPayTime().plusMonths(contract.getPayType().equals("1")? 1:contract.getPayType().equals("2")? 3:12));
                LocalDateTime firstPayTime1 = contract.getFirstPayTime();
                // 将firstPayTime1的日设置为当月最后一天
                rentBill.setEndTime(firstPayTime1.with(TemporalAdjusters.lastDayOfMonth()));
            }
            // 不走递增递减
            long allDays = ChronoUnit.DAYS.between(contract.getFirstPayTime(), rentBill.getEndTime());
@@ -290,7 +304,7 @@
            while(beforeBill.getEndTime().plusMonths(contract.getPayType().equals("1")? 1:contract.getPayType().equals("2")? 3:12).isBefore(contract.getEndTime())){
                    beforeBill.setEndTime(beforeBill.getEndTime().plusMonths(contract.getPayType().equals("1")? 1:contract.getPayType().equals("2")? 3:12));
                    TBill tBill = new TBill();
                    tBill.setContractId(contract.getId());
                    tBill.setContractNumber(contract.getContractNumber());
@@ -463,7 +477,7 @@
                        tBill.setPayFeesStatus("2");
                        tBill.setBillType("1");
                        tBill.setStartTime(beforeBill.getEndTime().plusDays(1));
                        tBill.setEndTime(contract.getEndTime());
                        tBill.setEndTime(beforeBill.getEndTime().plusMonths(contract.getPayType().equals("1")? 1:contract.getPayType().equals("2")? 3:12));
                    }
                    billMapper.insert(tBill);
                }
@@ -650,7 +664,7 @@
            tBill.setPayFeesStatus("1");
            tBill.setBillType("1");
            tBill.setStartTime(beforeBill.getEndTime().plusDays(1));
            tBill.setEndTime(beforeBill.getEndTime().plusMonths(contract.getPayType().equals("1")? 1:contract.getPayType().equals("2")? 3:12));
            tBill.setEndTime(contract.getEndTime());
            billService.save(tBill);
        }