yaozc
2023-04-28 bdf99bb9ab8b0250c073e85e4d676c3c745aed8b
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/capitalFlow/service/impl/CapitalFlowExpendServiceImpl.java
@@ -15,12 +15,13 @@
*/
package me.zhengjie.modules.capitalFlow.service.impl;
import me.zhengjie.modules.capital.service.dto.CapitalAccountCompanyDto;
import me.zhengjie.modules.capital.service.dto.CapitalAccountMoneyDto;
import me.zhengjie.modules.capital.service.impl.CapitalAccountCompanyServiceImpl;
import me.zhengjie.modules.capital.service.impl.CapitalAccountMoneyServiceImpl;
import me.zhengjie.modules.capitalFlow.domain.CapitalFlowExpend;
import me.zhengjie.modules.capitalFlow.service.dto.CapitalFlowDto;
import me.zhengjie.modules.system.service.dto.SysCompanyDto;
import me.zhengjie.modules.system.service.impl.SysCompanyServiceImpl;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.capitalFlow.repository.CapitalFlowExpendRepository;
import me.zhengjie.modules.capitalFlow.service.CapitalFlowExpendService;
@@ -31,17 +32,12 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.function.Function;
/**
@@ -57,7 +53,8 @@
    private final CapitalFlowExpendRepository capitalFlowExpendRepository;
    private final CapitalFlowExpendMapper capitalFlowExpendMapper;
    private final CapitalFlowServiceImpl capitalFlowServiceImpl;
    private final SysCompanyServiceImpl sysCompanyServiceImpl;
    private final CapitalAccountMoneyServiceImpl capitalAccountMoneyServiceImpl;
    private final CapitalAccountCompanyServiceImpl capitalAccountCompanyServiceImpl;
    @Override
    public Map<String,Object> queryAll(CapitalFlowExpendQueryCriteria criteria, Pageable pageable){
@@ -139,8 +136,80 @@
    private String flowName(CapitalFlowExpend resources) {
        // 查询资金流水数据
        CapitalFlowDto capitalFlowDto = capitalFlowServiceImpl.findById(resources.getFlowId());
        // 查询公司数据
        SysCompanyDto sysCompanyDto = sysCompanyServiceImpl.findById(capitalFlowDto.getCompanyId());
        return new SimpleDateFormat("yyyy-MM").format(capitalFlowDto.getFlowYearMonth()) + " - " + sysCompanyDto.getLabel();
        // 查询年度账号数据
        CapitalAccountCompanyDto capitalAccountCompanyDto = capitalAccountCompanyServiceImpl.findById(capitalFlowDto.getAccountCompanyId());
        return new SimpleDateFormat("yyyy-MM").format(capitalFlowDto.getFlowYearMonth()) + " - " + capitalAccountCompanyDto.getAccountName();
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void flowableCreate(String accountType, String title, BigDecimal amount) {
        // 关联年度资金现金流账户
        CapitalAccountMoneyDto capitalAccountMoneyDto = capitalAccountMoneyServiceImpl.relevanceCapitalAccountMoney();
        // 关联年度资金现金流账户(减少金额)
        capitalAccountMoneyServiceImpl.relevanceCapitalAccountMoneySubtract(capitalAccountMoneyDto, amount);
        // 关联年度资金公司流账户
        CapitalAccountCompanyDto capitalAccountCompanyDto = capitalAccountCompanyServiceImpl.relevanceCapitalAccountCompany(accountType);
        // 关联年度资金公司流账户(减少金额)
        capitalAccountCompanyServiceImpl.relevanceCapitalAccountCompanySubtract(capitalAccountCompanyDto, amount);
        // 关联月度资金公司流账户
        CapitalFlowDto capitalFlowDto = capitalFlowServiceImpl.relevanceCapitalFlow(capitalAccountCompanyDto.getId());
        // 关联资金流水支出(增加金额)
        relevanceCapitalFlowExpendAdd(capitalFlowDto.getId(), title, amount);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void flowableDelete(String accountType, String title, BigDecimal amount) {
        // 关联年度资金现金流账户
        CapitalAccountMoneyDto capitalAccountMoneyDto = capitalAccountMoneyServiceImpl.relevanceCapitalAccountMoney();
        // 关联年度资金现金流账户(增加金额)
        capitalAccountMoneyServiceImpl.relevanceCapitalAccountMoneyAdd(capitalAccountMoneyDto, amount);
        // 关联年度资金公司流账户
        CapitalAccountCompanyDto capitalAccountCompanyDto = capitalAccountCompanyServiceImpl.relevanceCapitalAccountCompany(accountType);
        // 关联年度资金公司流账户(增加金额)
        capitalAccountCompanyServiceImpl.relevanceCapitalAccountCompanyAdd(capitalAccountCompanyDto, amount);
        // 关联月度资金公司流账户
        CapitalFlowDto capitalFlowDto = capitalFlowServiceImpl.relevanceCapitalFlow(capitalAccountCompanyDto.getId());
        // 关联资金流水支出(减少金额)
        relevanceCapitalFlowExpendSubtract(capitalFlowDto.getId(), title, amount);
    }
    /**
     * 关联资金流水支出(增加金额)
     * @param capitalFlowId
     * @param title
     * @param amount
     */
    public void relevanceCapitalFlowExpendAdd(Long capitalFlowId, String title, BigDecimal amount) {
        // 临时金额
        BigDecimal tempAmount = new BigDecimal(0);
        tempAmount = tempAmount.add(amount);
        // 流水支出实体类
        CapitalFlowExpend capitalFlowExpend = new CapitalFlowExpend();
        capitalFlowExpend.setFlowId(capitalFlowId);
        capitalFlowExpend.setTitle(title);
        capitalFlowExpend.setAmount(tempAmount);
        // 保存
        capitalFlowExpendRepository.save(capitalFlowExpend);
    }
    /**
     * 关联资金流水支出(减少金额)
     * @param capitalFlowId
     * @param title
     * @param amount
     */
    public void relevanceCapitalFlowExpendSubtract(Long capitalFlowId, String title, BigDecimal amount) {
        // 临时金额
        BigDecimal tempAmount = new BigDecimal(0);
        tempAmount = tempAmount.subtract(amount);
        // 流水支出实体类
        CapitalFlowExpend capitalFlowExpend = new CapitalFlowExpend();
        capitalFlowExpend.setFlowId(capitalFlowId);
        capitalFlowExpend.setTitle(title);
        capitalFlowExpend.setAmount(tempAmount);
        // 保存
        capitalFlowExpendRepository.save(capitalFlowExpend);
    }
}