| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | |
| | | |
| | | @Override |
| | | public HomeBusinessDto business() { |
| | | // 构建结果 |
| | | HomeBusinessDto homeBusinessDto = new HomeBusinessDto(); |
| | | LocalDate now = LocalDate.now(); |
| | | YearMonth currentMonth = YearMonth.from(now); |
| | | // 创建LambdaQueryWrapper |
| | |
| | | salesLedgerLambdaQueryWrapper.ge(SalesLedger::getEntryDate, currentMonth.atDay(1).atStartOfDay()) // 大于等于本月第一天 |
| | | .lt(SalesLedger::getEntryDate, currentMonth.plusMonths(1).atDay(1).atStartOfDay()); // 小于下月第一天 |
| | | List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(salesLedgerLambdaQueryWrapper); |
| | | if(CollectionUtils.isEmpty(salesLedgers)){ |
| | | return homeBusinessDto; |
| | | } |
| | | // 合计合同金额 |
| | | BigDecimal contractAmount = salesLedgers.stream().map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | |
| | | BigDecimal noInvoiceAmountTotal = salesLedgerProducts.stream().map(SalesLedgerProduct::getNoInvoiceAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | homeBusinessDto.setMonthSaleMoney(contractAmount); |
| | | homeBusinessDto.setMonthSaleHaveMoney(noInvoiceAmountTotal); |
| | | // 创建LambdaQueryWrapper |
| | | LambdaQueryWrapper<PurchaseLedger> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.ge(PurchaseLedger::getEntryDate, currentMonth.atDay(1).atStartOfDay()) // 大于等于本月第一天 |
| | |
| | | |
| | | // 执行查询并计算总和 |
| | | List<PurchaseLedger> purchaseLedgers = purchaseLedgerMapper.selectList(queryWrapper); |
| | | if(CollectionUtils.isEmpty(purchaseLedgers)){ |
| | | return homeBusinessDto; |
| | | } |
| | | |
| | | LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductMapperLambdaQueryWrapperCopy = new LambdaQueryWrapper<SalesLedgerProduct>(); |
| | | salesLedgerProductMapperLambdaQueryWrapper.eq(SalesLedgerProduct::getType, 2) |
| | |
| | | .map(ProcurementRecordStorage::getInboundNum) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 构建结果 |
| | | HomeBusinessDto homeBusinessDto = new HomeBusinessDto(); |
| | | homeBusinessDto.setMonthSaleMoney(contractAmount); |
| | | homeBusinessDto.setMonthSaleHaveMoney(noInvoiceAmountTotal); |
| | | |
| | | homeBusinessDto.setMonthPurchaseMoney(receiveAmount); |
| | | homeBusinessDto.setMonthPurchaseHaveMoney(unReceiptPaymentAmount); |
| | | homeBusinessDto.setInventoryNum(stock); |
| | | homeBusinessDto.setTodayInventoryNum(stockAmount1); |
| | | |
| | | return homeBusinessDto; |
| | | } |
| | | |