| | |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.home.dto.*; |
| | | import com.ruoyi.home.service.HomeService; |
| | | import com.ruoyi.lavorissue.mapper.LavorIssueMapper; |
| | | import com.ruoyi.lavorissue.pojo.LaborIssue; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | |
| | | private PaymentRegistrationMapper paymentRegistrationMapper; |
| | | |
| | | @Autowired |
| | | private LavorIssueMapper lavorIssueMapper; |
| | | |
| | | @Autowired |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | @Override |
| | |
| | | BigDecimal noInvoiceAmountTotal = salesLedgerProducts.stream().map(SalesLedgerProduct::getNoInvoiceAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | homeBusinessDto.setMonthSaleMoney(contractAmount); |
| | | homeBusinessDto.setMonthSaleHaveMoney(noInvoiceAmountTotal); |
| | | homeBusinessDto.setMonthSaleMoney(contractAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto.setMonthSaleHaveMoney(noInvoiceAmountTotal.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | // 创建LambdaQueryWrapper |
| | | LambdaQueryWrapper<PurchaseLedger> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.ge(PurchaseLedger::getEntryDate, currentMonth.atDay(1).atStartOfDay()) // 大于等于本月第一天 |
| | |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | homeBusinessDto.setMonthPurchaseMoney(receiveAmount); |
| | | homeBusinessDto.setMonthPurchaseHaveMoney(unReceiptPaymentAmount); |
| | | homeBusinessDto.setInventoryNum(stock); |
| | | homeBusinessDto.setTodayInventoryNum(stockAmount1); |
| | | homeBusinessDto.setMonthPurchaseMoney(receiveAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto.setMonthPurchaseHaveMoney(unReceiptPaymentAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto.setInventoryNum(stock.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto.setTodayInventoryNum(stockAmount1.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | return homeBusinessDto; |
| | | } |
| | | |
| | |
| | | LocalDate endOfWeek = today.with(DayOfWeek.SUNDAY); |
| | | List<SalesLedger> salesLedgers1 = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>() |
| | | .ge(SalesLedger::getEntryDate, startOfWeek) // 大于等于本周周一 |
| | | .gt(SalesLedger::getEntryDate, endOfWeek)); |
| | | .lt(SalesLedger::getEntryDate, endOfWeek.plusDays(1))); // 修改:使用 lt 并加上一天来包含周日 |
| | | BigDecimal weekContractAmount = salesLedgers1.stream().map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | |
| | | LocalDate lastYearEndOfWeek = today.minusYears(1).with(DayOfWeek.SUNDAY); |
| | | List<SalesLedger> salesLedgers2 = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>() |
| | | .ge(SalesLedger::getEntryDate, lastYearStartOfWeek) // 大于等于去年本周周一 |
| | | .gt(SalesLedger::getEntryDate, lastYearEndOfWeek)); |
| | | .lt(SalesLedger::getEntryDate, lastYearEndOfWeek.plusDays(1))); // 修改:使用 lt 并加上一天来包含周日 |
| | | BigDecimal lastYearWeekContractAmount = salesLedgers2.stream().map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | |
| | | LocalDate yesterday = today.minusDays(1); |
| | | LocalDate plusDays = today.plusDays(1); |
| | | List<SalesLedger> salesLedgers3 = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>() |
| | | .ge(SalesLedger::getEntryDate, today) // 大于等于昨天 |
| | | .lt(SalesLedger::getEntryDate, plusDays)); |
| | | BigDecimal yesterdayContractAmount = salesLedgers3.stream().map(SalesLedger::getContractAmount) |
| | | .ge(SalesLedger::getEntryDate, today) // 大于等于今天 |
| | | .lt(SalesLedger::getEntryDate, plusDays)); // 修改:使用 lt 并加上一天来包含当天 |
| | | BigDecimal todayContractAmount = salesLedgers3.stream().map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | List<SalesLedger> salesLedgers4 = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>() |
| | | .ge(SalesLedger::getEntryDate, yesterday) // 大于等于去年昨天 |
| | | .lt(SalesLedger::getEntryDate, today)); |
| | | .ge(SalesLedger::getEntryDate, yesterday) // 大于等于昨天 |
| | | .lt(SalesLedger::getEntryDate, today)); // 修改:使用 lt 而不是 gt |
| | | BigDecimal lastYearYesterdayContractAmount = salesLedgers4.stream().map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal subtract1 = yesterdayContractAmount.subtract(lastYearYesterdayContractAmount); |
| | | BigDecimal subtract1 = todayContractAmount.subtract(lastYearYesterdayContractAmount); // 修改:使用 todayContractAmount 而不是 yesterdayContractAmount |
| | | // 日环比 |
| | | String chain = ""; |
| | | if(subtract1.compareTo(BigDecimal.ZERO) == 0 || lastYearYesterdayContractAmount.compareTo(BigDecimal.ZERO) == 0){ |
| | |
| | | |
| | | |
| | | AnalysisCustomerContractAmountsDto analysisCustomerContractAmountsDto = new AnalysisCustomerContractAmountsDto(); |
| | | analysisCustomerContractAmountsDto.setSum(contractAmount); |
| | | // 修改:将合同金额保留两位小数 |
| | | analysisCustomerContractAmountsDto.setSum(contractAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | analysisCustomerContractAmountsDto.setYny(weekYny); |
| | | analysisCustomerContractAmountsDto.setChain(chain); |
| | | |
| | |
| | | collect.forEach((k,v)->{ |
| | | MapDto mapDto = new MapDto(); |
| | | mapDto.setName(k); |
| | | mapDto.setValue(v); |
| | | // 修改:将金额值保留两位小数 |
| | | mapDto.setValue(v.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | if(contractAmount.compareTo(new BigDecimal(0)) == 0){ |
| | | mapDto.setRate("0"); |
| | | }else{ |
| | |
| | | analysisCustomerContractAmountsDto.setItem(mapDtos); |
| | | return analysisCustomerContractAmountsDto; |
| | | } |
| | | |
| | | @Override |
| | | public AnalysisCustomerContractAmountsDto analysisSupplierContractAmounts() { |
| | | List<PurchaseLedger> purchaseLedgers = purchaseLedgerMapper.selectList(null); |
| | | // 合计合同金额 |
| | | BigDecimal contractAmount = purchaseLedgers.stream().map(PurchaseLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 计算周同比 |
| | | // 获取当前时间 |
| | | LocalDate today = LocalDate.now(); |
| | | |
| | | // 获取本周周一 |
| | | LocalDate startOfWeek = today.with(DayOfWeek.MONDAY); |
| | | |
| | | // 获取本周周日 |
| | | LocalDate endOfWeek = today.with(DayOfWeek.SUNDAY); |
| | | List<PurchaseLedger> purchaseLedgers1 = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .ge(PurchaseLedger::getEntryDate, startOfWeek) // 大于等于本周周一 |
| | | .lt(PurchaseLedger::getEntryDate, endOfWeek.plusDays(1))); // 使用 lt 并加上一天来包含周日 |
| | | BigDecimal weekContractAmount = purchaseLedgers1.stream().map(PurchaseLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 获取去年本周时间 |
| | | LocalDate lastYearStartOfWeek = today.minusYears(1).with(DayOfWeek.MONDAY); |
| | | LocalDate lastYearEndOfWeek = today.minusYears(1).with(DayOfWeek.SUNDAY); |
| | | List<PurchaseLedger> purchaseLedgers2 = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .ge(PurchaseLedger::getEntryDate, lastYearStartOfWeek) // 大于等于去年本周周一 |
| | | .lt(PurchaseLedger::getEntryDate, lastYearEndOfWeek.plusDays(1))); // 使用 lt 并加上一天来包含周日 |
| | | BigDecimal lastYearWeekContractAmount = purchaseLedgers2.stream().map(PurchaseLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal subtract = weekContractAmount.subtract(lastYearWeekContractAmount); |
| | | String weekYny = ""; |
| | | // 周同比 |
| | | if(subtract.compareTo(BigDecimal.ZERO) == 0 || lastYearWeekContractAmount.compareTo(BigDecimal.ZERO) == 0){ |
| | | weekYny = "0.00"; |
| | | }else{ |
| | | weekYny = String.format("%.2f", subtract.divide(lastYearWeekContractAmount, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); |
| | | } |
| | | |
| | | // 计算日环比 |
| | | LocalDate yesterday = today.minusDays(1); |
| | | LocalDate plusDays = today.plusDays(1); |
| | | List<PurchaseLedger> purchaseLedgers3 = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .ge(PurchaseLedger::getEntryDate, today) // 大于等于今天 |
| | | .lt(PurchaseLedger::getEntryDate, plusDays)); // 使用 lt 并加上一天来包含当天 |
| | | BigDecimal todayContractAmount = purchaseLedgers3.stream().map(PurchaseLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | List<PurchaseLedger> purchaseLedgers4 = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .ge(PurchaseLedger::getEntryDate, yesterday) // 大于等于昨天 |
| | | .lt(PurchaseLedger::getEntryDate, today)); // 使用 lt |
| | | BigDecimal yesterdayContractAmount = purchaseLedgers4.stream().map(PurchaseLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal subtract1 = todayContractAmount.subtract(yesterdayContractAmount); |
| | | // 日环比 |
| | | String chain = ""; |
| | | if(subtract1.compareTo(BigDecimal.ZERO) == 0 || yesterdayContractAmount.compareTo(BigDecimal.ZERO) == 0){ |
| | | chain = "0.00"; |
| | | }else{ |
| | | chain = String.format("%.2f", subtract1.divide(yesterdayContractAmount, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); |
| | | } |
| | | |
| | | AnalysisCustomerContractAmountsDto analysisCustomerContractAmountsDto = new AnalysisCustomerContractAmountsDto(); |
| | | // 将合同金额保留两位小数 |
| | | analysisCustomerContractAmountsDto.setSum(contractAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | analysisCustomerContractAmountsDto.setYny(weekYny); |
| | | analysisCustomerContractAmountsDto.setChain(chain); |
| | | |
| | | // 按供应商名称分组统计 |
| | | Map<String, BigDecimal> collect = purchaseLedgers.stream().collect(Collectors.groupingBy(PurchaseLedger::getSupplierName, Collectors.reducing(BigDecimal.ZERO, |
| | | PurchaseLedger::getContractAmount, BigDecimal::add))); |
| | | List<MapDto> mapDtos = new ArrayList<>(); |
| | | collect.forEach((k,v)->{ |
| | | MapDto mapDto = new MapDto(); |
| | | mapDto.setName(k); |
| | | // 将金额值保留两位小数 |
| | | mapDto.setValue(v.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | if(contractAmount.compareTo(new BigDecimal(0)) == 0){ |
| | | mapDto.setRate("0"); |
| | | }else{ |
| | | mapDto.setRate(String.format("%.2f", v.divide(contractAmount, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")))); |
| | | } |
| | | mapDtos.add(mapDto); |
| | | }); |
| | | analysisCustomerContractAmountsDto.setItem(mapDtos); |
| | | return analysisCustomerContractAmountsDto; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public QualityStatisticsDto qualityStatistics() { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ApproveProcess> todos() { |
| | | public List<ApproveProcess> todos() throws ParseException { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | LambdaQueryWrapper<ApproveProcess> approveProcessLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | approveProcessLambdaQueryWrapper.eq(ApproveProcess::getApproveDelete, 0) |
| | | .eq(ApproveProcess::getApproveUserCurrentId, loginUser.getUserId()) |
| | | .ne(ApproveProcess::getApproveStatus, 2) |
| | | .eq(ApproveProcess::getTenantId, loginUser.getTenantId()); |
| | | return approveProcessMapper.selectList(approveProcessLambdaQueryWrapper); |
| | | List<ApproveProcess> approveProcesses = approveProcessMapper.selectList(approveProcessLambdaQueryWrapper); |
| | | if(CollectionUtils.isEmpty(approveProcesses)){ |
| | | approveProcesses = new ArrayList<>(); |
| | | } |
| | | // 查询未领用劳保记录 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | LaborIssue laborIssue1 = new LaborIssue(); |
| | | laborIssue1.setAdoptedDate(new Date()); |
| | | laborIssue1.setIssueDate(sdf.parse(sdf.format(new Date()))); |
| | | List<LaborIssue> laborIssues = lavorIssueMapper.list(laborIssue1); |
| | | if(!CollectionUtils.isEmpty(laborIssues)){ |
| | | for (LaborIssue laborIssue : laborIssues) { |
| | | ApproveProcess approveProcess = new ApproveProcess(); |
| | | approveProcess.setApproveId(laborIssue.getOrderNo()); |
| | | approveProcess.setApproveDeptName(sysDeptMapper.selectDeptById(loginUser.getTenantId()).getDeptName()); |
| | | approveProcess.setApproveTime(laborIssue.getIssueDate()); |
| | | approveProcess.setApproveReason(laborIssue.getDictTypeName() + "-" + laborIssue.getDictName() + "超时未领取"); |
| | | approveProcesses.add(approveProcess); |
| | | } |
| | | } |
| | | return approveProcesses; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | // 应收 |
| | | List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>() |
| | | .ge(SalesLedger::getEntryDate, startDate) |
| | | .lt(SalesLedger::getEntryDate, endDate) |
| | | // .ge(SalesLedger::getEntryDate, startDate) |
| | | // .lt(SalesLedger::getEntryDate, endDate) |
| | | ); |
| | | BigDecimal receivableMoney = salesLedgers.stream().map(SalesLedger::getContractAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 应付 |
| | | List<PurchaseLedger> procurementRecords = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .ge(PurchaseLedger::getEntryDate, startDate) |
| | | .lt(PurchaseLedger::getEntryDate, endDate) |
| | | // .ge(PurchaseLedger::getEntryDate, startDate) |
| | | // .lt(PurchaseLedger::getEntryDate, endDate) |
| | | ); |
| | | BigDecimal payableMoney = procurementRecords.stream().map(PurchaseLedger::getContractAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 预收 |
| | | List<ReceiptPayment> receiptPayments = receiptPaymentMapper.selectList(new LambdaQueryWrapper<ReceiptPayment>() |
| | | .ge(ReceiptPayment::getReceiptPaymentDate, startDate) |
| | | .lt(ReceiptPayment::getReceiptPaymentDate, endDate)); |
| | | // .ge(ReceiptPayment::getReceiptPaymentDate, startDate) |
| | | // .lt(ReceiptPayment::getReceiptPaymentDate, endDate) |
| | | ); |
| | | BigDecimal advanceMoney = receiptPayments.stream().map(ReceiptPayment::getReceiptPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 预付 |
| | | List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new LambdaQueryWrapper<PaymentRegistration>() |
| | | .ge(PaymentRegistration::getPaymentDate, startDate) |
| | | .lt(PaymentRegistration::getPaymentDate, endDate)); |
| | | // .ge(PaymentRegistration::getPaymentDate, startDate) |
| | | // .lt(PaymentRegistration::getPaymentDate, endDate) |
| | | ); |
| | | BigDecimal prepayMoney = paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | StatisticsReceivablePayableDto statisticsReceivablePayableDto = new StatisticsReceivablePayableDto(); |
| | | statisticsReceivablePayableDto.setPayableMoney(payableMoney); |
| | | statisticsReceivablePayableDto.setReceivableMoney(receivableMoney); |
| | | statisticsReceivablePayableDto.setPayableMoney(payableMoney.subtract(prepayMoney)); |
| | | statisticsReceivablePayableDto.setReceivableMoney(receivableMoney.subtract(advanceMoney)); |
| | | statisticsReceivablePayableDto.setAdvanceMoney(advanceMoney); |
| | | statisticsReceivablePayableDto.setPrepayMoney(prepayMoney); |
| | | |