| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.AccountReportDto; |
| | | import com.ruoyi.account.bean.dto.DeviceTypeDetail; |
| | | import com.ruoyi.account.bean.dto.DeviceTypeDistributionVO; |
| | | import com.ruoyi.account.mapper.BorrowInfoMapper; |
| | | import com.ruoyi.account.pojo.BorrowInfo; |
| | | import com.ruoyi.account.bean.vo.AccountReportVo; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.account.service.AccountingService; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | |
| | | @Service |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | public class AccountingServiceImpl { |
| | | public class AccountingServiceImpl implements AccountingService { |
| | | |
| | | private final DeviceLedgerMapper deviceLedgerMapper; |
| | | private final BorrowInfoMapper borrowInfoMapper; |
| | | private final CustomStorageMapper customStorageMapper; |
| | | private final ProcurementRecordMapper procurementRecordMapper; |
| | | private final ProcurementRecordOutMapper procurementRecordOutMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult total(Integer year) { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("deprAmount",0); // 折旧金额 |
| | |
| | | map.put("netValue",reduce.subtract(total)); |
| | | } |
| | | // 负债 |
| | | LambdaQueryWrapper<BorrowInfo> borrowInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | borrowInfoLambdaQueryWrapper.like(BorrowInfo::getCreateTime,year) |
| | | .eq(BorrowInfo::getStatus,1); |
| | | List<BorrowInfo> borrowInfos = borrowInfoMapper.selectList(borrowInfoLambdaQueryWrapper); |
| | | if(CollectionUtils.isNotEmpty(borrowInfos)){ |
| | | BigDecimal reduce = borrowInfos.stream() |
| | | .map(BorrowInfo::getBorrowAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | map.put("debt",reduce); |
| | | } |
| | | map.put("debt",BigDecimal.ZERO); |
| | | |
| | | // 库存资产 |
| | | LambdaQueryWrapper<ProcurementRecordStorage> procurementRecordStorageLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | procurementRecordStorageLambdaQueryWrapper.like(ProcurementRecordStorage::getCreateTime,year); |
| | |
| | | return totalDepreciation.setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deviceTypeDistribution(Integer year) { |
| | | // 2. 组装返回VO |
| | | DeviceTypeDistributionVO vo = new DeviceTypeDistributionVO(); |
| | |
| | | return AjaxResult.success(vo); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult calculateDepreciation(Page page, Integer year) { |
| | | LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | deviceLedgerLambdaQueryWrapper.like(DeviceLedger::getCreateTime,year) |
| | |
| | | } |
| | | return AjaxResult.success(deviceLedgerIPage); |
| | | } |
| | | |
| | | @Override |
| | | public AccountReportVo getAccountStatementDetailsByMonth(AccountReportDto accountReportDto) { |
| | | AccountReportVo accountReportVo = new AccountReportVo(); |
| | | //总营收=收款单总金额 |
| | | //总收入笔数=收款单总笔数 |
| | | List<AccountSalesCollection> accountSalesCollections = accountSalesCollectionMapper.selectList(Wrappers.<AccountSalesCollection>lambdaQuery() |
| | | .between(AccountSalesCollection::getCollectionDate, accountReportDto.getEntryDateStart(), accountReportDto.getEntryDateEnd())); |
| | | accountReportVo.setTotalIncome(accountSalesCollections.stream().map(AccountSalesCollection::getCollectionAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | accountReportVo.setIncomeNumber(accountSalesCollections.size()); |
| | | //总支出=付款单总金额 |
| | | //总支出笔数=付款单总笔数 |
| | | List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList(Wrappers.<AccountPurchasePayment>lambdaQuery() |
| | | .between(AccountPurchasePayment::getPaymentDate, accountReportDto.getEntryDateStart(), accountReportDto.getEntryDateEnd())); |
| | | accountReportVo.setTotalExpense(accountPurchasePayments.stream().map(AccountPurchasePayment::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | accountReportVo.setExpenseNumber(accountPurchasePayments.size()); |
| | | //净利润=总营收-总支出 |
| | | accountReportVo.setNetRevenue(accountReportVo.getTotalIncome().subtract(accountReportVo.getTotalExpense())); |
| | | return accountReportVo; |
| | | } |
| | | } |