| | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.capital.domain.CapitalAccountMoney; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import me.zhengjie.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.capital.repository.CapitalAccountMoneyRepository; |
| | | import me.zhengjie.modules.capital.service.CapitalAccountMoneyService; |
| | |
| | | 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.util.List; |
| | | import java.util.Map; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(CapitalAccountMoneyQueryCriteria criteria, Pageable pageable){ |
| | | if (criteria.getAccountYear() != null && !"".equals(criteria.getAccountYear())) { |
| | | criteria.setAccountYear(DateUtil.internationalTimeToChinaTime(criteria.getAccountYear()).substring(0,4)); |
| | | } |
| | | Page<CapitalAccountMoney> page = capitalAccountMoneyRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | return PageUtil.toPage(page.map(capitalAccountMoneyMapper::toDto)); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 关联年度资金现金流账户 |
| | | * @return |
| | | */ |
| | | public CapitalAccountMoneyDto relevanceCapitalAccountMoney() { |
| | | // 当前系统时间 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 年度资金账户(现金流)检索类 |
| | | CapitalAccountMoneyQueryCriteria criteria = new CapitalAccountMoneyQueryCriteria(); |
| | | criteria.setAccountYear(DateUtil.getYear(calendar)); |
| | | // 查询年度资金账户(现金流) |
| | | List<CapitalAccountMoneyDto> capitalAccountMoneyDtoList = capitalAccountMoneyMapper.toDto(capitalAccountMoneyRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | // 判断年度资金账户(现金流) |
| | | if (capitalAccountMoneyDtoList.size() == 0) { |
| | | throw new BadRequestException("没有找到对应的年度资金现金流账户!"); |
| | | } else if (capitalAccountMoneyDtoList.size() > 1) { |
| | | throw new BadRequestException("找到多条对应的年度资金现金流账户!"); |
| | | } |
| | | return capitalAccountMoneyDtoList.get(0); |
| | | } |
| | | |
| | | /** |
| | | * 关联年度资金现金流账户(增加金额) |
| | | * @param capitalAccountMoneyDto |
| | | * @param amount |
| | | */ |
| | | public void relevanceCapitalAccountMoneyAdd(CapitalAccountMoneyDto capitalAccountMoneyDto, BigDecimal amount) { |
| | | // 账户金额 |
| | | BigDecimal accountAmount = capitalAccountMoneyDto.getAccountAmount(); |
| | | accountAmount = accountAmount.add(amount); |
| | | capitalAccountMoneyDto.setAccountAmount(accountAmount); |
| | | // 保存 |
| | | capitalAccountMoneyRepository.save(capitalAccountMoneyMapper.toEntity(capitalAccountMoneyDto)); |
| | | } |
| | | |
| | | /** |
| | | * 关联年度资金现金流账户(减少金额) |
| | | * @param capitalAccountMoneyDto |
| | | * @param amount |
| | | */ |
| | | public void relevanceCapitalAccountMoneySubtract(CapitalAccountMoneyDto capitalAccountMoneyDto, BigDecimal amount) { |
| | | // 账户金额 |
| | | BigDecimal accountAmount = capitalAccountMoneyDto.getAccountAmount(); |
| | | accountAmount = accountAmount.subtract(amount); |
| | | capitalAccountMoneyDto.setAccountAmount(accountAmount); |
| | | // 保存 |
| | | capitalAccountMoneyRepository.save(capitalAccountMoneyMapper.toEntity(capitalAccountMoneyDto)); |
| | | } |
| | | } |