| | |
| | | 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 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; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | |
| | | private PaymentRegistrationMapper paymentRegistrationMapper; |
| | | |
| | | @Autowired |
| | | private LavorIssueMapper lavorIssueMapper; |
| | | |
| | | @Autowired |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | @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.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()) // 大于等于本月第一天 |
| | |
| | | |
| | | // 执行查询并计算总和 |
| | | 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); |
| | | |
| | | 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{ |
| | |
| | | return analysisCustomerContractAmountsDto; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public QualityStatisticsDto qualityStatistics() { |
| | | // 获取一周数据 |
| | | // 获取当前时间 |
| | | // 获取近四个月数据(往前推三个月,共4个完整月份) |
| | | LocalDate today = LocalDate.now(); |
| | | // 获取本周周一 |
| | | LocalDate startOfWeek = today.with(DayOfWeek.MONDAY); |
| | | // 获取本周周日 |
| | | LocalDate endOfWeek = today.with(DayOfWeek.SUNDAY); |
| | | LambdaQueryWrapper<QualityInspect> qualityInspectLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | qualityInspectLambdaQueryWrapper.ge(QualityInspect::getCheckTime, startOfWeek) |
| | | .gt(QualityInspect::getCheckTime, endOfWeek); |
| | | List<QualityInspect> qualityInspects = qualityStatisticsMapper.selectList(qualityInspectLambdaQueryWrapper); |
| | | // 定义日期格式化器(用于显示“年月”格式) |
| | | DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM"); |
| | | |
| | | QualityStatisticsDto qualityStatisticsDto = new QualityStatisticsDto(); |
| | | qualityStatisticsDto.setSupplierNum(qualityInspects.stream().filter(item -> item.getInspectType().equals(0)).map(QualityInspect::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | qualityStatisticsDto.setProcessNum(qualityInspects.stream().filter(item -> item.getInspectType().equals(1)).map(QualityInspect::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | qualityStatisticsDto.setFactoryNum(qualityInspects.stream().filter(item -> item.getInspectType().equals(2)).map(QualityInspect::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | List<QualityStatisticsItem> qualityStatisticsItems = new ArrayList<>(); |
| | | for (int j = 1; j < 8; j++) { |
| | | LocalDate endTime = startOfWeek.plusDays(j); |
| | | LocalDate startTime = endTime.minusDays(1); |
| | | QualityStatisticsItem qualityStatisticsItem = new QualityStatisticsItem(); |
| | | qualityStatisticsItem.setDate(startTime.toString()); |
| | | qualityStatisticsItem.setSupplierNum(qualityInspects.stream() |
| | | .filter(item -> item.getInspectType().equals(0) && "不合格".equals(item.getCheckResult()) |
| | | && (startTime.isEqual(item.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()) || startTime.isAfter(item.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())) |
| | | && endTime.isBefore(item.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())) |
| | | |
| | | BigDecimal supplierNum = new BigDecimal(0); |
| | | BigDecimal factoryNum = new BigDecimal(0); |
| | | BigDecimal processNum = new BigDecimal(0); |
| | | // 循环4次,分别统计近4个月的数据(当前月、前1个月、前2个月、前3个月) |
| | | for (int i = 3; i >= 0; i--) { |
| | | // 计算当前循环对应的月份(i=0:当前月,i=1:前1个月,以此类推) |
| | | LocalDate currentMonth = today.minusMonths(i); |
| | | // 当月的开始日期(每月1号) |
| | | LocalDate monthStart = currentMonth.withDayOfMonth(1); |
| | | // 当月的结束日期(每月最后一天) |
| | | LocalDate monthEnd = currentMonth.withDayOfMonth(currentMonth.lengthOfMonth()); |
| | | |
| | | // 构建当月的查询条件(如果想一次性查全4个月数据再内存筛选,可优化为先查全再循环筛选) |
| | | LambdaQueryWrapper<QualityInspect> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.ge(QualityInspect::getCheckTime, monthStart) |
| | | .le(QualityInspect::getCheckTime, monthEnd); // 筛选当月数据 |
| | | List<QualityInspect> monthInspects = qualityStatisticsMapper.selectList(queryWrapper); |
| | | BigDecimal reduce = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(0)) |
| | | .map(QualityInspect::getQuantity) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ); |
| | | qualityStatisticsItem.setFactoryNum(qualityInspects.stream() |
| | | .filter(item -> item.getInspectType().equals(1) && "不合格".equals(item.getCheckResult()) |
| | | && (startTime.isEqual(item.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()) || startTime.isAfter(item.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())) |
| | | && endTime.isBefore(item.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | supplierNum = supplierNum.add(reduce); |
| | | BigDecimal reduce1 = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(1)) |
| | | .map(QualityInspect::getQuantity) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ); |
| | | qualityStatisticsItem.setProcessNum(qualityInspects.stream() |
| | | .filter(item -> item.getInspectType().equals(2) && "不合格".equals(item.getCheckResult()) |
| | | && (startTime.isEqual(item.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()) || startTime.isAfter(item.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())) |
| | | && endTime.isBefore(item.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | processNum= processNum.add(reduce1); |
| | | BigDecimal reduce2 = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(2)) |
| | | .map(QualityInspect::getQuantity) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | qualityStatisticsItems.add(qualityStatisticsItem); |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | factoryNum = factoryNum.add(reduce2); |
| | | |
| | | // 构建当月统计项 |
| | | QualityStatisticsItem item = new QualityStatisticsItem(); |
| | | item.setDate(monthStart.format(monthFormatter)); // 日期显示为“年月”(如 2025-10) |
| | | |
| | | // 1. 供应商检验(类型0)- 合格数量 |
| | | BigDecimal supplierQualified = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(0) |
| | | && "合格".equals(inspect.getCheckResult())) |
| | | .map(QualityInspect::getQuantity) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | item.setSupplierNum(supplierQualified); |
| | | |
| | | // 2. 工序检验(类型1)- 合格数量 |
| | | BigDecimal processQualified = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(1) |
| | | && "合格".equals(inspect.getCheckResult())) |
| | | .map(QualityInspect::getQuantity) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | item.setProcessNum(processQualified); |
| | | |
| | | // 3. 工厂检验(类型2)- 合格数量 |
| | | BigDecimal factoryQualified = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(2) |
| | | && "合格".equals(inspect.getCheckResult())) |
| | | .map(QualityInspect::getQuantity) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | item.setFactoryNum(factoryQualified); |
| | | |
| | | qualityStatisticsItems.add(item); |
| | | } |
| | | // 统计近4个月总数据(所有月份汇总) |
| | | qualityStatisticsDto.setProcessNum(processNum); |
| | | qualityStatisticsDto.setSupplierNum(supplierNum); |
| | | qualityStatisticsDto.setFactoryNum(factoryNum); |
| | | qualityStatisticsDto.setItem(qualityStatisticsItems); |
| | | |
| | | return qualityStatisticsDto; |
| | | } |
| | | |
| | | @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); |
| | | |
| | | return statisticsReceivablePayableDto; |
| | | } |
| | | |
| | | @Override |
| | | public QualityProductQualifiedRateDto qualityProductQualifiedRate() { |
| | | QualityProductQualifiedRateDto qualityProductQualifiedRateDto = new QualityProductQualifiedRateDto(); |
| | | List<QualityInspect> qualityInspects = qualityStatisticsMapper.selectList(null); |
| | | if(!CollectionUtils.isEmpty(qualityInspects)){ |
| | | // 原材料合格率 |
| | | long rawwMaterialCount = qualityInspects.stream().filter(qualityInspect -> qualityInspect.getInspectType() == 0).count(); |
| | | long count = qualityInspects.stream().filter(qualityInspect -> "合格".equals(qualityInspect.getCheckResult()) && qualityInspect.getInspectType() == 0).count(); |
| | | if(count > 0){ |
| | | qualityProductQualifiedRateDto.setRawMaterialQualifiedRate(new BigDecimal(rawwMaterialCount) |
| | | .divide(new BigDecimal( count), 4, RoundingMode.HALF_UP) |
| | | .multiply(BigDecimal.valueOf(100.0))); |
| | | } |
| | | // 过程合格率 |
| | | long processCount = qualityInspects.stream().filter(qualityInspect -> qualityInspect.getInspectType() == 1).count(); |
| | | long countOne = qualityInspects.stream().filter(qualityInspect -> "合格".equals(qualityInspect.getCheckResult()) && qualityInspect.getInspectType() == 1).count(); |
| | | if(countOne > 0){ |
| | | qualityProductQualifiedRateDto.setProcessQualifiedRate(new BigDecimal(processCount) |
| | | .divide(new BigDecimal( countOne), 4, RoundingMode.HALF_UP) |
| | | .multiply(BigDecimal.valueOf(100.0))); |
| | | } |
| | | // 出厂合格率 |
| | | long factoryCount = qualityInspects.stream().filter(qualityInspect -> qualityInspect.getInspectType() == 2).count(); |
| | | long countTwo = qualityInspects.stream().filter(qualityInspect -> "合格".equals(qualityInspect.getCheckResult()) && qualityInspect.getInspectType() == 2).count(); |
| | | if(countTwo > 0){ |
| | | qualityProductQualifiedRateDto.setFactoryQualifiedRate(new BigDecimal(factoryCount) |
| | | .divide(new BigDecimal( countTwo), 4, RoundingMode.HALF_UP) |
| | | .multiply(BigDecimal.valueOf(100.0))); |
| | | } |
| | | } |
| | | // 库存周转率统计当月出库(使用)的物料总数量÷平均的库存物料总数量×100%。) |
| | | // 获取当前月 |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate startDate = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDate endDate = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | // 获取当前月出库(使用)的物料总数量 |
| | | List<ProcurementRecordOut> procurementRecordOuts = procurementRecordOutMapper.selectList(new LambdaQueryWrapper<ProcurementRecordOut>() |
| | | .ge(ProcurementRecordOut::getCreateTime, startDate) |
| | | .lt(ProcurementRecordOut::getCreateTime, endDate)); |
| | | // 获取当前月入库的物料总数量 |
| | | List<ProcurementRecordStorage> procurementRecordStorages = procurementRecordStorageMapper.selectList(new LambdaQueryWrapper<ProcurementRecordStorage>() |
| | | .ge(ProcurementRecordStorage::getCreateTime, startDate) |
| | | .lt(ProcurementRecordStorage::getCreateTime, endDate)); |
| | | BigDecimal reduce = procurementRecordOuts.stream() |
| | | .map(ProcurementRecordOut::getInboundNum) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal reduceOne = procurementRecordStorages.stream() |
| | | .map(ProcurementRecordStorage::getInboundNum) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if(reduce.compareTo(BigDecimal.ZERO) > 0){ |
| | | qualityProductQualifiedRateDto.setInventoryTurnoverRate(reduceOne.divide(reduce, 4, RoundingMode.HALF_UP) |
| | | .multiply(BigDecimal.valueOf(100.0))); |
| | | } |
| | | |
| | | return qualityProductQualifiedRateDto; |
| | | } |
| | | } |