| | |
| | | import com.ruoyi.production.dto.ProductWorkOrderDto; |
| | | import com.ruoyi.production.mapper.ProductOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductInputMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductOutputMapper; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | |
| | | @Autowired |
| | | private HomeMapper homeMapper; |
| | | |
| | | @Autowired |
| | | private ProductionProductOutputMapper productionProductOutputMapper; |
| | | |
| | | @Override |
| | | public HomeBusinessDto business() { |
| | | // æå»ºç»æ |
| | |
| | | YearMonth currentMonth = YearMonth.from(now); |
| | | // å建LambdaQueryWrapper |
| | | LambdaQueryWrapper<SalesLedger> salesLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | salesLedgerLambdaQueryWrapper.ge(SalesLedger::getEntryDate, currentMonth.atDay(1).atStartOfDay()) // 大äºçäºæ¬æç¬¬ä¸å¤© |
| | | 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)) { |
| | |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductMapperLambdaQueryWrapper = new LambdaQueryWrapper<SalesLedgerProduct>(); |
| | | salesLedgerProductMapperLambdaQueryWrapper.eq(SalesLedgerProduct::getType, 1) |
| | | .in(SalesLedgerProduct::getSalesLedgerId, salesLedgers.stream().map(SalesLedger::getId).collect(Collectors.toList())); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(salesLedgerProductMapperLambdaQueryWrapper); |
| | | .in(SalesLedgerProduct::getSalesLedgerId, |
| | | salesLedgers.stream().map(SalesLedger::getId).collect(Collectors.toList())); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper |
| | | .selectList(salesLedgerProductMapperLambdaQueryWrapper); |
| | | // æªå¼ç¥¨éé¢ |
| | | BigDecimal noInvoiceAmountTotal = salesLedgerProducts.stream().map(SalesLedgerProduct::getNoInvoiceAmount) |
| | | .filter(Objects::nonNull) |
| | |
| | | } |
| | | // å建LambdaQueryWrapper |
| | | LambdaQueryWrapper<PurchaseLedger> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.ge(PurchaseLedger::getEntryDate, currentMonth.atDay(1).atStartOfDay()) // 大äºçäºæ¬æç¬¬ä¸å¤© |
| | | queryWrapper.ge(PurchaseLedger::getEntryDate, currentMonth.atDay(1).atStartOfDay()) // 大äºçäºæ¬æç¬¬ä¸å¤© |
| | | .lt(PurchaseLedger::getEntryDate, currentMonth.plusMonths(1).atDay(1).atStartOfDay()); // å°äºä¸æç¬¬ä¸å¤© |
| | | // æ§è¡æ¥è¯¢å¹¶è®¡ç®æ»å |
| | | List<PurchaseLedger> purchaseLedgers = purchaseLedgerMapper.selectList(queryWrapper); |
| | | if (!CollectionUtils.isEmpty(purchaseLedgers)) { |
| | | LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductMapperLambdaQueryWrapperCopy = new LambdaQueryWrapper<SalesLedgerProduct>(); |
| | | salesLedgerProductMapperLambdaQueryWrapperCopy.eq(SalesLedgerProduct::getType, 2) |
| | | .in(SalesLedgerProduct::getSalesLedgerId, purchaseLedgers.stream().map(PurchaseLedger::getId).collect(Collectors.toList())); |
| | | List<SalesLedgerProduct> salesLedgerProductsCopy = salesLedgerProductMapper.selectList(salesLedgerProductMapperLambdaQueryWrapperCopy); |
| | | .in(SalesLedgerProduct::getSalesLedgerId, |
| | | purchaseLedgers.stream().map(PurchaseLedger::getId).collect(Collectors.toList())); |
| | | List<SalesLedgerProduct> salesLedgerProductsCopy = salesLedgerProductMapper |
| | | .selectList(salesLedgerProductMapperLambdaQueryWrapperCopy); |
| | | // å计ååéé¢ |
| | | BigDecimal receiveAmount = purchaseLedgers.stream() |
| | | .map(PurchaseLedger::getContractAmount) |
| | |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | homeBusinessDto.setMonthPurchaseMoney(receiveAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto.setMonthPurchaseHaveMoney(unReceiptPaymentAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto |
| | | .setMonthPurchaseHaveMoney(unReceiptPaymentAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | } |
| | | // ç»è®¡åºå |
| | | BigDecimal stockQuantityTotal = stockInventoryMapper.selectTotal(); |
| | | homeBusinessDto.setInventoryNum(stockQuantityTotal.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | |
| | | |
| | | // è·åå½å¤©å
¥åºæ°é |
| | | BigDecimal bigDecimal = stockInventoryMapper.selectTotalByDate(LocalDate.now()); |
| | |
| | | // è·åæ¬å¨å¨æ¥ |
| | | LocalDate endOfWeek = today.with(DayOfWeek.SUNDAY); |
| | | List<SalesLedger> salesLedgers1 = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>() |
| | | .ge(SalesLedger::getEntryDate, startOfWeek) // 大äºçäºæ¬å¨å¨ä¸ |
| | | .ge(SalesLedger::getEntryDate, startOfWeek) // 大äºçäºæ¬å¨å¨ä¸ |
| | | .lt(SalesLedger::getEntryDate, endOfWeek.plusDays(1))); // ä¿®æ¹ï¼ä½¿ç¨ lt å¹¶å ä¸ä¸å¤©æ¥å
å«å¨æ¥ |
| | | BigDecimal weekContractAmount = salesLedgers1.stream().map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | |
| | | LocalDate lastYearStartOfWeek = today.minusYears(1).with(DayOfWeek.MONDAY); |
| | | LocalDate lastYearEndOfWeek = today.minusYears(1).with(DayOfWeek.SUNDAY); |
| | | List<SalesLedger> salesLedgers2 = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>() |
| | | .ge(SalesLedger::getEntryDate, lastYearStartOfWeek) // 大äºçäºå»å¹´æ¬å¨å¨ä¸ |
| | | .ge(SalesLedger::getEntryDate, lastYearStartOfWeek) // 大äºçäºå»å¹´æ¬å¨å¨ä¸ |
| | | .lt(SalesLedger::getEntryDate, lastYearEndOfWeek.plusDays(1))); // ä¿®æ¹ï¼ä½¿ç¨ lt å¹¶å ä¸ä¸å¤©æ¥å
å«å¨æ¥ |
| | | BigDecimal lastYearWeekContractAmount = salesLedgers2.stream().map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | |
| | | 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"))); |
| | | 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<SalesLedger> salesLedgers3 = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>() |
| | | .ge(SalesLedger::getEntryDate, today) // 大äºçäºä»å¤© |
| | | .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) // 大äºçäºæ¨å¤© |
| | | .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 = todayContractAmount.subtract(lastYearYesterdayContractAmount); // ä¿®æ¹ï¼ä½¿ç¨ todayContractAmount è䏿¯ yesterdayContractAmount |
| | | BigDecimal subtract1 = todayContractAmount.subtract(lastYearYesterdayContractAmount); // ä¿®æ¹ï¼ä½¿ç¨ |
| | | // todayContractAmount è䏿¯ |
| | | // yesterdayContractAmount |
| | | // æ¥ç¯æ¯ |
| | | String chain = ""; |
| | | if (subtract1.compareTo(BigDecimal.ZERO) == 0 || lastYearYesterdayContractAmount.compareTo(BigDecimal.ZERO) == 0) { |
| | | if (subtract1.compareTo(BigDecimal.ZERO) == 0 |
| | | || lastYearYesterdayContractAmount.compareTo(BigDecimal.ZERO) == 0) { |
| | | chain = "0.00"; |
| | | } else { |
| | | chain = String.format("%.2f", subtract1.divide(lastYearYesterdayContractAmount, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); |
| | | chain = String.format("%.2f", subtract1.divide(lastYearYesterdayContractAmount, 2, RoundingMode.HALF_UP) |
| | | .multiply(new BigDecimal("100"))); |
| | | } |
| | | |
| | | |
| | | AnalysisCustomerContractAmountsDto analysisCustomerContractAmountsDto = new AnalysisCustomerContractAmountsDto(); |
| | | // ä¿®æ¹ï¼å°ååéé¢ä¿ç两ä½å°æ° |
| | |
| | | analysisCustomerContractAmountsDto.setYny(weekYny); |
| | | analysisCustomerContractAmountsDto.setChain(chain); |
| | | |
| | | Map<String, BigDecimal> collect = salesLedgers.stream().collect(Collectors.groupingBy(SalesLedger::getCustomerName, Collectors.reducing(BigDecimal.ZERO, |
| | | SalesLedger::getContractAmount, BigDecimal::add))); |
| | | Map<String, BigDecimal> collect = salesLedgers.stream() |
| | | .collect(Collectors.groupingBy(SalesLedger::getCustomerName, Collectors.reducing(BigDecimal.ZERO, |
| | | SalesLedger::getContractAmount, BigDecimal::add))); |
| | | List<MapDto> mapDtos = new ArrayList<>(); |
| | | collect.forEach((k, v) -> { |
| | | MapDto mapDto = new MapDto(); |
| | |
| | | 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")))); |
| | | 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() { |
| | |
| | | approveProcessLambdaQueryWrapper.eq(ApproveProcess::getApproveDelete, 0) |
| | | .eq(ApproveProcess::getApproveUserCurrentId, loginUser.getUserId()) |
| | | .ne(ApproveProcess::getApproveStatus, 2); |
| | | // .eq(ApproveProcess::getTenantId, loginUser.getTenantId()); |
| | | // .eq(ApproveProcess::getTenantId, loginUser.getTenantId()); |
| | | List<ApproveProcess> approveProcesses = approveProcessMapper.selectList(approveProcessLambdaQueryWrapper); |
| | | if (CollectionUtils.isEmpty(approveProcesses)) { |
| | | approveProcesses = new ArrayList<>(); |
| | |
| | | a.setApproveTypeName(ApproveTypeEnum.getNameByCode(a.getApproveType())); |
| | | } |
| | | }); |
| | | // // æ¥è¯¢æªé¢ç¨å³ä¿è®°å½ |
| | | // 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); //staff_join_leave_record表被å é¤ |
| | | // 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); |
| | | // } |
| | | // } |
| | | |
| | | // // æ¥è¯¢æªé¢ç¨å³ä¿è®°å½ |
| | | // 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); |
| | | // //staff_join_leave_record表被å é¤ |
| | | // 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); |
| | | // BigDecimal receivableMoney = |
| | | // salesLedgers.stream().map(SalesLedger::getContractAmount).reduce(BigDecimal.ZERO, |
| | | // BigDecimal::add); |
| | | BigDecimal receivableMoney = sumAmount(salesLedgers, SalesLedger::getContractAmount); |
| | | // åºä» |
| | | List<PurchaseLedger> procurementRecords = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>() |
| | | // .ge(PurchaseLedger::getEntryDate, startDate) |
| | | // .lt(PurchaseLedger::getEntryDate, endDate) |
| | | ); |
| | | // BigDecimal payableMoney = procurementRecords.stream().map(PurchaseLedger::getContractAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | List<PurchaseLedger> procurementRecords = purchaseLedgerMapper |
| | | .selectList(new LambdaQueryWrapper<PurchaseLedger>() |
| | | // .ge(PurchaseLedger::getEntryDate, startDate) |
| | | // .lt(PurchaseLedger::getEntryDate, endDate) |
| | | ); |
| | | // BigDecimal payableMoney = |
| | | // procurementRecords.stream().map(PurchaseLedger::getContractAmount).reduce(BigDecimal.ZERO, |
| | | // BigDecimal::add); |
| | | BigDecimal payableMoney = sumAmount(procurementRecords, PurchaseLedger::getContractAmount); |
| | | // 颿¶ |
| | | 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); |
| | | // BigDecimal advanceMoney = |
| | | // receiptPayments.stream().map(ReceiptPayment::getReceiptPaymentAmount).reduce(BigDecimal.ZERO, |
| | | // BigDecimal::add); |
| | | BigDecimal advanceMoney = sumAmount(receiptPayments, ReceiptPayment::getReceiptPaymentAmount); |
| | | // é¢ä» |
| | | List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new LambdaQueryWrapper<PaymentRegistration>() |
| | | // .ge(PaymentRegistration::getPaymentDate, startDate) |
| | | // .lt(PaymentRegistration::getPaymentDate, endDate) |
| | | ); |
| | | // BigDecimal prepayMoney = paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper |
| | | .selectList(new LambdaQueryWrapper<PaymentRegistration>() |
| | | // .ge(PaymentRegistration::getPaymentDate, startDate) |
| | | // .lt(PaymentRegistration::getPaymentDate, endDate) |
| | | ); |
| | | // BigDecimal prepayMoney = |
| | | // paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, |
| | | // BigDecimal::add); |
| | | BigDecimal prepayMoney = sumAmount(paymentRegistrations, PaymentRegistration::getCurrentPaymentAmount); |
| | | StatisticsReceivablePayableDto statisticsReceivablePayableDto = new StatisticsReceivablePayableDto(); |
| | | statisticsReceivablePayableDto.setPayableMoney(payableMoney.subtract(prepayMoney)); |
| | |
| | | Long aLong1 = deviceRepairMapper.selectCount(new LambdaQueryWrapper<DeviceRepair>() |
| | | .eq(DeviceRepair::getStatus, 0) |
| | | .eq(DeviceRepair::getRepairName, SecurityUtils.getLoginUser().getNickName())); |
| | | return new HashMap<String, Object>() {{ |
| | | put("approveTodo", aLong); |
| | | put("deviceRepairTodo", aLong1); |
| | | }}; |
| | | return new HashMap<String, Object>() { |
| | | { |
| | | put("approveTodo", aLong); |
| | | put("deviceRepairTodo", aLong1); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | @Override |
| | |
| | | ProductOrderDto orderDto = new ProductOrderDto(); |
| | | orderDto.setStartTime(LocalDateTime.now().minusMonths(1)); |
| | | orderDto.setEndTime(LocalDateTime.now()); |
| | | List<ProductOrderDto> productOrderDtos = productOrderMapper.pageProductOrder(new Page<>(1, -1), orderDto).getRecords(); |
| | | List<ProductOrderDto> productOrderDtos = productOrderMapper.pageProductOrder(new Page<>(1, -1), orderDto) |
| | | .getRecords(); |
| | | productionProgressDto.setCompletedOrderDetails(productOrderDtos); |
| | | long totalCount = productOrderDtos.size(); |
| | | long count = productOrderDtos.stream().filter(productOrderDto -> productOrderDto.getCompleteQuantity().compareTo(productOrderDto.getQuantity()) >= 0).count(); |
| | | long count2 = productOrderDtos.stream().filter(productOrderDto -> productOrderDto.getCompleteQuantity().compareTo(BigDecimal.ZERO) == 0).count(); |
| | | long count = productOrderDtos.stream().filter( |
| | | productOrderDto -> productOrderDto.getCompleteQuantity().compareTo(productOrderDto.getQuantity()) >= 0) |
| | | .count(); |
| | | long count2 = productOrderDtos.stream() |
| | | .filter(productOrderDto -> productOrderDto.getCompleteQuantity().compareTo(BigDecimal.ZERO) == 0) |
| | | .count(); |
| | | productionProgressDto.setTotalOrderCount(totalCount); |
| | | productionProgressDto.setCompletedOrderCount(count); |
| | | productionProgressDto.setUncompletedOrderCount(count2); |
| | |
| | | ProductWorkOrderDto workOrder = new ProductWorkOrderDto(); |
| | | workOrder.setPlanStartTime(LocalDate.now().minusMonths(1)); |
| | | workOrder.setPlanEndTime(LocalDate.now()); |
| | | List<ProductWorkOrderDto> productWorkOrders = productWorkOrderMapper.pageProductWorkOrder(new Page<>(1, -1), workOrder).getRecords(); |
| | | List<ProductWorkOrderDto> productWorkOrders = productWorkOrderMapper |
| | | .pageProductWorkOrder(new Page<>(1, -1), workOrder).getRecords(); |
| | | long sum = productWorkOrders.stream() |
| | | .filter(productWorkOrder -> productWorkOrder.getPlanQuantity().compareTo(productWorkOrder.getCompleteQuantity()) > 0) |
| | | .filter(productWorkOrder -> productWorkOrder.getPlanQuantity() |
| | | .compareTo(productWorkOrder.getCompleteQuantity()) > 0) |
| | | .map(ProductWorkOrder::getPlanQuantity) |
| | | .mapToLong(BigDecimal::longValue) |
| | | .sum(); |
| | | if (sum == 0) return null; |
| | | productionTurnoverDto.setTotalOrderCount(sum);//æ»å¨å¶åæ°é |
| | | productionTurnoverDto.setAverageTurnoverDays(BigDecimal.valueOf(sum).divide(BigDecimal.valueOf(ChronoUnit.DAYS.between(LocalDateTime.now().minusMonths(1), LocalDateTime.now())), 2, RoundingMode.HALF_UP)); |
| | | if (sum == 0) |
| | | return null; |
| | | productionTurnoverDto.setTotalOrderCount(sum);// æ»å¨å¶åæ°é |
| | | productionTurnoverDto.setAverageTurnoverDays(BigDecimal.valueOf(sum).divide( |
| | | BigDecimal.valueOf(ChronoUnit.DAYS.between(LocalDateTime.now().minusMonths(1), LocalDateTime.now())), 2, |
| | | RoundingMode.HALF_UP)); |
| | | long completeQuantity = productWorkOrders.stream() |
| | | .filter(productWorkOrder -> productWorkOrder.getCompleteQuantity().compareTo(productWorkOrder.getPlanQuantity()) >= 0) |
| | | .filter(productWorkOrder -> productWorkOrder.getCompleteQuantity() |
| | | .compareTo(productWorkOrder.getPlanQuantity()) >= 0) |
| | | .map(ProductWorkOrder::getCompleteQuantity) |
| | | .mapToLong(BigDecimal::longValue) |
| | | .sum(); |
| | | productionTurnoverDto.setTurnoverEfficiency(BigDecimal.valueOf(completeQuantity).divide(BigDecimal.valueOf(sum), 2, RoundingMode.HALF_UP)); |
| | | productionTurnoverDto.setTurnoverEfficiency( |
| | | BigDecimal.valueOf(completeQuantity).divide(BigDecimal.valueOf(sum), 2, RoundingMode.HALF_UP)); |
| | | Map<String, List<ProductWorkOrderDto>> map = productWorkOrders.stream() |
| | | .filter(productWorkOrder -> productWorkOrder.getPlanQuantity().compareTo(productWorkOrder.getCompleteQuantity()) > 0) |
| | | .filter(productWorkOrder -> productWorkOrder.getPlanQuantity() |
| | | .compareTo(productWorkOrder.getCompleteQuantity()) > 0) |
| | | .collect(Collectors.groupingBy(ProductWorkOrderDto::getProcessName)); |
| | | List<String> strings = new ArrayList<>(); |
| | | List<Long> processQuantityDetails = new ArrayList<>(); |
| | | map.entrySet().stream().forEach(entry -> { |
| | | String key = entry.getKey(); |
| | | long completeSum = entry.getValue().stream().map(ProductWorkOrderDto::getCompleteQuantity).mapToLong(BigDecimal::longValue).sum(); |
| | | long completeSum = entry.getValue().stream().map(ProductWorkOrderDto::getCompleteQuantity) |
| | | .mapToLong(BigDecimal::longValue).sum(); |
| | | strings.add(key); |
| | | processQuantityDetails.add(completeSum); |
| | | }); |
| | |
| | | LocalDateTime currentMonthEnd = currentMonth.atEndOfMonth().atTime(23, 59, 59); |
| | | LocalDateTime prevMonthEnd = prevMonth.atEndOfMonth().atTime(23, 59, 59); |
| | | |
| | | // æ»å·¥ä½äººå |
| | | // æ»å·¥ä½äººå |
| | | Long currentStaff = countStaff(currentMonthEnd); |
| | | Long prevStaff = countStaff(prevMonthEnd); |
| | | dto.setTotalStaff(currentStaff); |
| | | dto.setStaffGrowthRate(calculateMoM(currentStaff, prevStaff)); |
| | | |
| | | // æ»å®¢æ·æ° |
| | | // æ»å®¢æ·æ° |
| | | Long currentCustomers = countCustomers(currentMonthEnd); |
| | | Long prevCustomers = countCustomers(prevMonthEnd); |
| | | dto.setTotalCustomer(currentCustomers); |
| | | dto.setCustomerGrowthRate(calculateMoM(currentCustomers, prevCustomers)); |
| | | |
| | | // æ»ä¾åºåæ° |
| | | // æ»ä¾åºåæ° |
| | | Long currentSuppliers = countSuppliers(currentMonthEnd); |
| | | Long prevSuppliers = countSuppliers(prevMonthEnd); |
| | | dto.setTotalSupplier(currentSuppliers); |
| | |
| | | .le(StaffOnJob::getCreateTime, dateTime)); |
| | | return sysUserCount + staffCountItem; |
| | | } |
| | | |
| | | |
| | | private Long countCustomers(LocalDateTime dateTime) { |
| | | return customerMapper.selectCount(new LambdaQueryWrapper<Customer>() |
| | |
| | | queryWrapper.select("supplier_name", "SUM(contract_amount) as total_amount") |
| | | .ge("entry_date", startDate) |
| | | .le("entry_date", endDate) |
| | | // .ne("approval_status", 3) |
| | | // .ne("approval_status", 3) |
| | | .groupBy("supplier_name") |
| | | .orderByDesc("total_amount") |
| | | .last("LIMIT 5"); |
| | |
| | | String dayName = d.getMonthValue() + "/" + d.getDayOfMonth(); |
| | | BigDecimal sum = list.stream() |
| | | .filter(l -> l.getEntryDate() != null) |
| | | .filter(l -> l.getEntryDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().equals(d)) |
| | | .filter(l -> l.getEntryDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate() |
| | | .equals(d)) |
| | | .map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | |
| | | for (Map<String, Object> map : maps) { |
| | | CustomerContributionRankingDto rankingDto = new CustomerContributionRankingDto(); |
| | | rankingDto.setCustomerName(map.get("customer_name").toString()); |
| | | rankingDto.setTotalAmount(map.get("total_amount") != null ? new BigDecimal(map.get("total_amount").toString()) : BigDecimal.ZERO); |
| | | rankingDto |
| | | .setTotalAmount(map.get("total_amount") != null ? new BigDecimal(map.get("total_amount").toString()) |
| | | : BigDecimal.ZERO); |
| | | result.add(rankingDto); |
| | | } |
| | | return result; |
| | |
| | | String lastMonthEnd = lastMonth.with(TemporalAdjusters.lastDayOfMonth()).format(dtf); |
| | | |
| | | // éå® |
| | | int currentSales = salesLedgerProductMapper.selectProductCountByTypeAndDate(1, currentMonthStart, currentMonthNow); |
| | | int currentSales = salesLedgerProductMapper.selectProductCountByTypeAndDate(1, currentMonthStart, |
| | | currentMonthNow); |
| | | int lastSales = salesLedgerProductMapper.selectProductCountByTypeAndDate(1, lastMonthStart, lastMonthEnd); |
| | | |
| | | // éè´ |
| | | int currentPurchase = salesLedgerProductMapper.selectProductCountByTypeAndDate(2, currentMonthStart, currentMonthNow); |
| | | int currentPurchase = salesLedgerProductMapper.selectProductCountByTypeAndDate(2, currentMonthStart, |
| | | currentMonthNow); |
| | | int lastPurchase = salesLedgerProductMapper.selectProductCountByTypeAndDate(2, lastMonthStart, lastMonthEnd); |
| | | |
| | | // å¨å |
| | |
| | | String startDate = now.minusDays(6).toString(); |
| | | String endDate = now.toString(); |
| | | |
| | | List<Map<String, Object>> inCounts = stockInventoryMapper.selectDailyStockInCounts(rootCategoryId, startDate, endDate + " 23:59:59"); |
| | | List<Map<String, Object>> inCounts = stockInventoryMapper.selectDailyStockInCounts(rootCategoryId, startDate, |
| | | endDate + " 23:59:59"); |
| | | |
| | | List<Map<String, Object>> outCounts = stockInventoryMapper.selectDailyStockOutCounts(rootCategoryId, startDate, endDate + " 23:59:59"); |
| | | List<Map<String, Object>> outCounts = stockInventoryMapper.selectDailyStockOutCounts(rootCategoryId, startDate, |
| | | endDate + " 23:59:59"); |
| | | |
| | | Map<LocalDate, BigDecimal> inMap = inCounts.stream() |
| | | .collect(Collectors.toMap( |
| | | m -> ((java.sql.Date) m.get("date")).toLocalDate(), |
| | | m -> (BigDecimal) m.get("count"), |
| | | BigDecimal::add |
| | | )); |
| | | BigDecimal::add)); |
| | | |
| | | Map<LocalDate, BigDecimal> outMap = outCounts.stream() |
| | | .collect(Collectors.toMap( |
| | | m -> ((java.sql.Date) m.get("date")).toLocalDate(), |
| | | m -> (BigDecimal) m.get("count"), |
| | | BigDecimal::add |
| | | )); |
| | | BigDecimal::add)); |
| | | |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private AccountIncomeMapper accountIncomeMapper; |
| | | |
| | | |
| | | public List<Map<String, Object>> incomeExpenseAnalysis(Integer type) { |
| | | |
| | |
| | | // 2. æ¥è¯¢æ°æ® |
| | | List<IncomeExpenseAnalysisDto> incomeList = accountIncomeMapper.selectIncomeStats(startStr, endStr, dateFormat); |
| | | |
| | | // List<IncomeExpenseAnalysisDto> purchaseList = |
| | | // purchaseLedgerMapper.selectPurchaseStats(startStr, endStr, dateFormat); |
| | | // List<IncomeExpenseAnalysisDto> purchaseList = |
| | | // purchaseLedgerMapper.selectPurchaseStats(startStr, endStr, dateFormat); |
| | | |
| | | List<IncomeExpenseAnalysisDto> expenseList = accountExpenseMapper.selectAccountExpenseStats(startStr, endStr, dateFormat); |
| | | List<IncomeExpenseAnalysisDto> expenseList = accountExpenseMapper.selectAccountExpenseStats(startStr, endStr, |
| | | dateFormat); |
| | | |
| | | // 3. 转 Mapï¼èªå¨åå¹¶ï¼ |
| | | Map<String, BigDecimal> incomeMap = incomeList.stream() |
| | |
| | | IncomeExpenseAnalysisDto::getAmount, |
| | | BigDecimal::add)); |
| | | |
| | | // Map<String, BigDecimal> purchaseMap = purchaseList.stream() |
| | | // .collect(Collectors.toMap( |
| | | // IncomeExpenseAnalysisDto::getDateStr, |
| | | // IncomeExpenseAnalysisDto::getAmount, |
| | | // BigDecimal::add)); |
| | | // Map<String, BigDecimal> purchaseMap = purchaseList.stream() |
| | | // .collect(Collectors.toMap( |
| | | // IncomeExpenseAnalysisDto::getDateStr, |
| | | // IncomeExpenseAnalysisDto::getAmount, |
| | | // BigDecimal::add)); |
| | | |
| | | Map<String, BigDecimal> expenseMap = expenseList.stream() |
| | | .collect(Collectors.toMap( |
| | |
| | | item.put("income", income.setScale(2, RoundingMode.HALF_UP)); |
| | | |
| | | // æ¯åº = éè´ + è´¢å¡æ¯åº |
| | | // BigDecimal purchase = purchaseMap.getOrDefault(dateStr, BigDecimal.ZERO); |
| | | // BigDecimal purchase = purchaseMap.getOrDefault(dateStr, BigDecimal.ZERO); |
| | | BigDecimal expense = expenseMap.getOrDefault(dateStr, BigDecimal.ZERO); |
| | | // BigDecimal totalExpense = purchase.add(expense); |
| | | // BigDecimal totalExpense = purchase.add(expense); |
| | | BigDecimal totalExpense = expense; |
| | | |
| | | item.put("expense", totalExpense.setScale(2, RoundingMode.HALF_UP)); |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<MapDto> profitTrendAnalysis() { |
| | |
| | | String startStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | String endStr = endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | |
| | | // List<IncomeExpenseAnalysisDto> incomeList = salesLedgerMapper.selectIncomeStats(startStr, endStr, dateFormat); |
| | | // List<IncomeExpenseAnalysisDto> incomeList = |
| | | // salesLedgerMapper.selectIncomeStats(startStr, endStr, dateFormat); |
| | | List<IncomeExpenseAnalysisDto> incomeList = new ArrayList<>(); |
| | | List<IncomeExpenseAnalysisDto> purchaseList = purchaseLedgerMapper.selectPurchaseStats(startStr, endStr, dateFormat); |
| | | List<IncomeExpenseAnalysisDto> expenseList = accountExpenseMapper.selectAccountExpenseStats(startStr, endStr, dateFormat); |
| | | List<IncomeExpenseAnalysisDto> purchaseList = purchaseLedgerMapper.selectPurchaseStats(startStr, endStr, |
| | | dateFormat); |
| | | List<IncomeExpenseAnalysisDto> expenseList = accountExpenseMapper.selectAccountExpenseStats(startStr, endStr, |
| | | dateFormat); |
| | | |
| | | Map<String, BigDecimal> incomeMap = incomeList.stream().collect(Collectors.toMap(IncomeExpenseAnalysisDto::getDateStr, IncomeExpenseAnalysisDto::getAmount, BigDecimal::add)); |
| | | Map<String, BigDecimal> purchaseMap = purchaseList.stream().collect(Collectors.toMap(IncomeExpenseAnalysisDto::getDateStr, IncomeExpenseAnalysisDto::getAmount, BigDecimal::add)); |
| | | Map<String, BigDecimal> expenseMap = expenseList.stream().collect(Collectors.toMap(IncomeExpenseAnalysisDto::getDateStr, IncomeExpenseAnalysisDto::getAmount, BigDecimal::add)); |
| | | Map<String, BigDecimal> incomeMap = incomeList.stream().collect(Collectors |
| | | .toMap(IncomeExpenseAnalysisDto::getDateStr, IncomeExpenseAnalysisDto::getAmount, BigDecimal::add)); |
| | | Map<String, BigDecimal> purchaseMap = purchaseList.stream().collect(Collectors |
| | | .toMap(IncomeExpenseAnalysisDto::getDateStr, IncomeExpenseAnalysisDto::getAmount, BigDecimal::add)); |
| | | Map<String, BigDecimal> expenseMap = expenseList.stream().collect(Collectors |
| | | .toMap(IncomeExpenseAnalysisDto::getDateStr, IncomeExpenseAnalysisDto::getAmount, BigDecimal::add)); |
| | | |
| | | List<MapDto> result = new ArrayList<>(); |
| | | |
| | |
| | | BigDecimal income = incomeMap.getOrDefault(month, BigDecimal.ZERO); |
| | | |
| | | BigDecimal purchase = purchaseMap.getOrDefault(month, BigDecimal.ZERO); |
| | | income = BigDecimal.ZERO; |
| | | income = BigDecimal.ZERO; |
| | | BigDecimal expense = expenseMap.getOrDefault(month, BigDecimal.ZERO); |
| | | BigDecimal totalExpense = purchase.add(expense); |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public MonthlyIncomeDto monthlyIncome() { |
| | | MonthlyIncomeDto dto = new MonthlyIncomeDto(); |
| | |
| | | |
| | | MonthlyExpenditureDto dto = new MonthlyExpenditureDto(); |
| | | |
| | | // 彿æ¶é´èå´ |
| | | // 彿æ¶é´èå´ |
| | | LocalDate now = LocalDate.now(); |
| | | YearMonth currentMonth = YearMonth.from(now); |
| | | LocalDateTime startOfMonth = currentMonth.atDay(1).atStartOfDay(); |
| | | LocalDateTime endOfMonth = currentMonth.atEndOfMonth().atTime(23, 59, 59); |
| | | |
| | | // éè´å°è´¦ï¼type = 2ï¼ |
| | | // éè´å°è´¦ï¼type = 2ï¼ |
| | | LambdaQueryWrapper<SalesLedgerProduct> purchaseWrapper = new LambdaQueryWrapper<>(); |
| | | purchaseWrapper.eq(SalesLedgerProduct::getType, 2); |
| | | purchaseWrapper.ge(SalesLedgerProduct::getRegisterDate, startOfMonth); |
| | | purchaseWrapper.le(SalesLedgerProduct::getRegisterDate, endOfMonth); |
| | | |
| | | List<SalesLedgerProduct> purchaseProducts = |
| | | salesLedgerProductMapper.selectList(purchaseWrapper); |
| | | List<SalesLedgerProduct> purchaseProducts = salesLedgerProductMapper.selectList(purchaseWrapper); |
| | | |
| | | BigDecimal rawMaterialCost = BigDecimal.ZERO; // åææææ¬ |
| | | BigDecimal paidAmount = BigDecimal.ZERO; // 已仿¬¾éé¢ |
| | | BigDecimal pendingAmount = BigDecimal.ZERO; // å¾
仿¬¾éé¢ |
| | | BigDecimal rawMaterialCost = BigDecimal.ZERO; // åææææ¬ |
| | | BigDecimal paidAmount = BigDecimal.ZERO; // 已仿¬¾éé¢ |
| | | BigDecimal pendingAmount = BigDecimal.ZERO; // å¾
仿¬¾éé¢ |
| | | |
| | | if (!CollectionUtils.isEmpty(purchaseProducts)) { |
| | | for (SalesLedgerProduct p : purchaseProducts) { |
| | |
| | | } |
| | | } |
| | | |
| | | // å
¶ä»è´¹ç¨ |
| | | // å
¶ä»è´¹ç¨ |
| | | LambdaQueryWrapper<AccountExpense> expenseWrapper = new LambdaQueryWrapper<>(); |
| | | expenseWrapper.ge(AccountExpense::getExpenseDate, |
| | | java.sql.Date.valueOf(currentMonth.atDay(1))); |
| | | expenseWrapper.le(AccountExpense::getExpenseDate, |
| | | java.sql.Date.valueOf(currentMonth.atEndOfMonth())); |
| | | |
| | | List<AccountExpense> expenses = |
| | | accountExpenseMapper.selectList(expenseWrapper); |
| | | List<AccountExpense> expenses = accountExpenseMapper.selectList(expenseWrapper); |
| | | |
| | | BigDecimal otherExpense = BigDecimal.ZERO; |
| | | if (!CollectionUtils.isEmpty(expenses)) { |
| | |
| | | } |
| | | } |
| | | |
| | | // æåº¦æ»æ¯åº |
| | | // BigDecimal monthlyExpenditure = rawMaterialCost.add(otherExpense); |
| | | // æåº¦æ»æ¯åº |
| | | // BigDecimal monthlyExpenditure = rawMaterialCost.add(otherExpense); |
| | | BigDecimal monthlyExpenditure = otherExpense; |
| | | dto.setMonthlyExpenditure(monthlyExpenditure); |
| | | |
| | |
| | | salesWrapper.ge(SalesLedgerProduct::getRegisterDate, startOfMonth); |
| | | salesWrapper.le(SalesLedgerProduct::getRegisterDate, endOfMonth); |
| | | |
| | | List<SalesLedgerProduct> salesProducts = |
| | | salesLedgerProductMapper.selectList(salesWrapper); |
| | | List<SalesLedgerProduct> salesProducts = salesLedgerProductMapper.selectList(salesWrapper); |
| | | |
| | | BigDecimal revenue = BigDecimal.ZERO; |
| | | if (!CollectionUtils.isEmpty(salesProducts)) { |
| | |
| | | } |
| | | } |
| | | |
| | | // æ¯å©æ¶¦ & 婿¶¦ç |
| | | // æ¯å©æ¶¦ & 婿¶¦ç |
| | | if (revenue.compareTo(BigDecimal.ZERO) > 0) { |
| | | |
| | | // æ¯å©æ¶¦ = é宿¶å
¥ - åææææ¬ |
| | |
| | | return dto; |
| | | } |
| | | |
| | | @Autowired |
| | | private ProductionProductInputMapper productionProductInputMapper; |
| | | |
| | | @Override |
| | | public List<InputOutputAnalysisDto> inputOutputAnalysis(Integer type) { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate startDate; |
| | | |
| | | switch (type) { |
| | | case 1: // å¨ |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | break; |
| | | case 2: // æ |
| | | startDate = today.withDayOfMonth(1); |
| | | break; |
| | | case 3: // å£åº¦ |
| | | int currentMonth = today.getMonthValue(); |
| | | int startMonth = ((currentMonth - 1) / 3) * 3 + 1; |
| | | startDate = LocalDate.of(today.getYear(), startMonth, 1); |
| | | break; |
| | | default: |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | break; |
| | | } |
| | | |
| | | LocalDate endDate = today.plusDays(1); |
| | | |
| | | String startStr = startDate.atStartOfDay() |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | String endStr = endDate.atStartOfDay() |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | List<Map<String, Object>> inputList = productionProductInputMapper.selectInputStats(startStr, endStr); |
| | | List<Map<String, Object>> outputList = productionProductOutputMapper.selectDailyOutputStats(startStr, endStr); |
| | | |
| | | Map<String, InputOutputAnalysisDto> dateMap = new HashMap<>(); |
| | | |
| | | if (!CollectionUtils.isEmpty(inputList)) { |
| | | for (Map<String, Object> map : inputList) { |
| | | String date = (String) map.get("date"); |
| | | if (date == null) |
| | | continue; |
| | | InputOutputAnalysisDto dto = dateMap.getOrDefault(date, new InputOutputAnalysisDto()); |
| | | dto.setDate(date); |
| | | BigDecimal qty = (BigDecimal) map.get("quantity"); |
| | | dto.setInputSum(dto.getInputSum() != null ? dto.getInputSum().add(qty) : qty); |
| | | dateMap.put(date, dto); |
| | | } |
| | | } |
| | | |
| | | if (!CollectionUtils.isEmpty(outputList)) { |
| | | for (Map<String, Object> map : outputList) { |
| | | String date = (String) map.get("date"); |
| | | if (date == null) |
| | | continue; |
| | | InputOutputAnalysisDto dto = dateMap.getOrDefault(date, new InputOutputAnalysisDto()); |
| | | dto.setDate(date); |
| | | BigDecimal qty = (BigDecimal) map.get("quantity"); |
| | | dto.setOutputSum(dto.getOutputSum() != null ? dto.getOutputSum().add(qty) : qty); |
| | | dateMap.put(date, dto); |
| | | } |
| | | } |
| | | |
| | | dateMap.values().forEach(dto -> { |
| | | if (dto.getInputSum() == null) |
| | | dto.setInputSum(BigDecimal.ZERO); |
| | | if (dto.getOutputSum() == null) |
| | | dto.setOutputSum(BigDecimal.ZERO); |
| | | }); |
| | | |
| | | return dateMap.values().stream() |
| | | .sorted(Comparator.comparing(InputOutputAnalysisDto::getDate)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public List<MapDto> processOutputAnalysis(Integer type) { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate startDate; |
| | | LocalDate endDate = today; |
| | | |
| | | switch (type) { |
| | | case 1: // å¨ |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | break; |
| | | case 2: // æ |
| | | startDate = today.withDayOfMonth(1); |
| | | break; |
| | | case 3: // å£åº¦ |
| | | int currentMonth = today.getMonthValue(); |
| | | int startMonth = ((currentMonth - 1) / 3) * 3 + 1; |
| | | startDate = LocalDate.of(today.getYear(), startMonth, 1); |
| | | break; |
| | | default: |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | break; |
| | | } |
| | | |
| | | ProductWorkOrderDto queryDto = new ProductWorkOrderDto(); |
| | | queryDto.setPlanStartTime(startDate); |
| | | queryDto.setPlanEndTime(endDate); |
| | | |
| | | List<ProductWorkOrderDto> list = productWorkOrderMapper.pageProductWorkOrder(new Page<>(1, -1), queryDto) |
| | | .getRecords(); |
| | | |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | Map<String, BigDecimal> processOutputMap = list.stream() |
| | | .filter(item -> item.getProcessName() != null && item.getCompleteQuantity() != null) |
| | | .collect(Collectors.groupingBy( |
| | | ProductWorkOrderDto::getProcessName, |
| | | Collectors.reducing(BigDecimal.ZERO, |
| | | ProductWorkOrderDto::getCompleteQuantity, |
| | | BigDecimal::add))); |
| | | |
| | | BigDecimal total = processOutputMap.values().stream() |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | if (BigDecimal.ZERO.compareTo(total) == 0) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | List<MapDto> result = new ArrayList<>(); |
| | | processOutputMap.forEach((name, value) -> { |
| | | MapDto dto = new MapDto(); |
| | | dto.setName(name); |
| | | dto.setValue(value.stripTrailingZeros().toPlainString()); |
| | | |
| | | BigDecimal rate = value |
| | | .divide(total, 4, RoundingMode.HALF_UP) |
| | | .multiply(new BigDecimal("100")); |
| | | |
| | | dto.setRate(rate.setScale(2, RoundingMode.HALF_UP) + "%"); |
| | | result.add(dto); |
| | | }); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<WorkOrderEfficiencyDto> workOrderEfficiencyAnalysis(Integer type) { |
| | | |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate startDate; |
| | | LocalDate endDate = today; |
| | | |
| | | switch (type) { |
| | | case 1: // å¨ |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | break; |
| | | case 2: // æ |
| | | startDate = today.withDayOfMonth(1); |
| | | break; |
| | | case 3: // å£åº¦ |
| | | int currentMonth = today.getMonthValue(); |
| | | int startMonth = ((currentMonth - 1) / 3) * 3 + 1; |
| | | startDate = LocalDate.of(today.getYear(), startMonth, 1); |
| | | break; |
| | | default: |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | break; |
| | | } |
| | | |
| | | String startStr = startDate.atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | String endStr = endDate.atTime(LocalTime.MAX).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | List<ProductWorkOrderDto> startList = productWorkOrderMapper.selectWorkOrderStartStats(startStr, endStr); |
| | | |
| | | List<com.ruoyi.production.dto.ProductionProductOutputDto> outputList = productionProductOutputMapper |
| | | .selectOutputStats(startStr, endStr); |
| | | |
| | | Map<String, WorkOrderEfficiencyDto> dateMap = new HashMap<>(); |
| | | |
| | | if (!CollectionUtils.isEmpty(startList)) { |
| | | for (ProductWorkOrderDto item : startList) { |
| | | if (item.getPlanStartTime() != null) { |
| | | String date = item.getPlanStartTime().toString(); |
| | | WorkOrderEfficiencyDto dto = dateMap.getOrDefault(date, new WorkOrderEfficiencyDto()); |
| | | dto.setDate(date); |
| | | BigDecimal qty = item.getPlanQuantity() != null ? item.getPlanQuantity() : BigDecimal.ZERO; |
| | | dto.setStartQuantity(dto.getStartQuantity() != null ? dto.getStartQuantity().add(qty) : qty); |
| | | dateMap.put(date, dto); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // å®å·¥æ°éåè¯åç |
| | | if (!CollectionUtils.isEmpty(outputList)) { |
| | | for (com.ruoyi.production.dto.ProductionProductOutputDto item : outputList) { |
| | | if (item.getCreateTime() != null) { |
| | | String date = item.getCreateTime().toLocalDate().toString(); |
| | | WorkOrderEfficiencyDto dto = dateMap.getOrDefault(date, new WorkOrderEfficiencyDto()); |
| | | dto.setDate(date); |
| | | |
| | | BigDecimal finishQty = item.getQuantity() != null ? item.getQuantity() : BigDecimal.ZERO; |
| | | BigDecimal scrapQty = item.getScrapQty() != null ? item.getScrapQty() : BigDecimal.ZERO; |
| | | |
| | | dto.setFinishQuantity( |
| | | dto.getFinishQuantity() != null ? dto.getFinishQuantity().add(finishQty) : finishQty); |
| | | } |
| | | } |
| | | |
| | | Map<String, BigDecimal> scrapMap = outputList.stream() |
| | | .filter(i -> i.getCreateTime() != null) |
| | | .collect(Collectors.groupingBy( |
| | | i -> i.getCreateTime().toLocalDate().toString(), |
| | | Collectors.reducing(BigDecimal.ZERO, |
| | | i -> i.getScrapQty() != null ? i.getScrapQty() : BigDecimal.ZERO, |
| | | BigDecimal::add))); |
| | | |
| | | Map<String, BigDecimal> finishMap = outputList.stream() |
| | | .filter(i -> i.getCreateTime() != null) |
| | | .collect(Collectors.groupingBy( |
| | | i -> i.getCreateTime().toLocalDate().toString(), |
| | | Collectors.reducing(BigDecimal.ZERO, |
| | | i -> i.getQuantity() != null ? i.getQuantity() : BigDecimal.ZERO, |
| | | BigDecimal::add))); |
| | | |
| | | finishMap.forEach((date, qty) -> { |
| | | WorkOrderEfficiencyDto dto = dateMap.getOrDefault(date, new WorkOrderEfficiencyDto()); |
| | | dto.setDate(date); |
| | | dto.setFinishQuantity(qty); |
| | | dateMap.put(date, dto); |
| | | }); |
| | | |
| | | dateMap.forEach((date, dto) -> { |
| | | BigDecimal finish = dto.getFinishQuantity() != null ? dto.getFinishQuantity() : BigDecimal.ZERO; |
| | | BigDecimal scrap = scrapMap.getOrDefault(date, BigDecimal.ZERO); |
| | | BigDecimal total = finish.add(scrap); |
| | | |
| | | if (total.compareTo(BigDecimal.ZERO) > 0) { |
| | | BigDecimal rate = finish.divide(total, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) |
| | | .setScale(2, RoundingMode.HALF_UP); |
| | | dto.setYieldRate(rate.toString()); |
| | | } else { |
| | | dto.setYieldRate("0.00"); |
| | | } |
| | | |
| | | if (dto.getStartQuantity() == null) |
| | | dto.setStartQuantity(BigDecimal.ZERO); |
| | | if (dto.getFinishQuantity() == null) |
| | | dto.setFinishQuantity(BigDecimal.ZERO); |
| | | }); |
| | | } |
| | | |
| | | dateMap.values().forEach(dto -> { |
| | | if (dto.getStartQuantity() == null) |
| | | dto.setStartQuantity(BigDecimal.ZERO); |
| | | if (dto.getFinishQuantity() == null) |
| | | dto.setFinishQuantity(BigDecimal.ZERO); |
| | | if (dto.getYieldRate() == null) |
| | | dto.setYieldRate("0.00"); |
| | | }); |
| | | |
| | | return dateMap.values().stream() |
| | | .sorted(Comparator.comparing(WorkOrderEfficiencyDto::getDate)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Autowired |
| | | private com.ruoyi.production.mapper.SalesLedgerProductionAccountingMapper salesLedgerProductionAccountingMapper; |
| | | |
| | | @Override |
| | | public List<MapDto> productionAccountingAnalysis(Integer type) { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate startDate; |
| | | LocalDate endDate = today; |
| | | |
| | | switch (type) { |
| | | case 1: // å¨ |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | break; |
| | | case 2: // æ |
| | | startDate = today.withDayOfMonth(1); |
| | | break; |
| | | case 3: // å£åº¦ |
| | | int currentMonth = today.getMonthValue(); |
| | | int startMonth = ((currentMonth - 1) / 3) * 3 + 1; |
| | | startDate = LocalDate.of(today.getYear(), startMonth, 1); |
| | | break; |
| | | default: |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | break; |
| | | } |
| | | |
| | | String startStr = startDate.atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | String endStr = endDate.atTime(LocalTime.MAX).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | |
| | | List<Map<String, Object>> wagesList = salesLedgerProductionAccountingMapper.selectDailyWagesStats(startStr, |
| | | endStr); |
| | | |
| | | if (CollectionUtils.isEmpty(wagesList)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | List<MapDto> result = new ArrayList<>(); |
| | | for (Map<String, Object> map : wagesList) { |
| | | MapDto dto = new MapDto(); |
| | | dto.setName((String) map.get("date")); |
| | | BigDecimal wages = (BigDecimal) map.get("wages"); |
| | | dto.setValue(wages != null ? wages.toString() : "0"); |
| | | result.add(dto); |
| | | } |
| | | |
| | | result.sort(Comparator.comparing(MapDto::getName)); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<MapDto> orderCount() { |
| | | LocalDate now = LocalDate.now(); |
| | | |
| | | String currentStart = now.withDayOfMonth(1).atStartOfDay() |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | String currentEnd = now.atTime(LocalTime.MAX).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | LocalDate lastMonthDate = now.minusMonths(1); |
| | | String lastStart = lastMonthDate.withDayOfMonth(1).atStartOfDay() |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | String lastEnd = lastMonthDate.withDayOfMonth(lastMonthDate.lengthOfMonth()).atTime(LocalTime.MAX) |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | int currentCreated = productOrderMapper.countCreated(currentStart, currentEnd); |
| | | int lastCreated = productOrderMapper.countCreated(lastStart, lastEnd); |
| | | MapDto createdDto = createOrderCountDto("çäº§è®¢åæ°", currentCreated, lastCreated); |
| | | |
| | | int currentCompleted = productOrderMapper.countCompleted(currentStart, currentEnd); |
| | | int lastCompleted = productOrderMapper.countCompleted(lastStart, lastEnd); |
| | | MapDto completedDto = createOrderCountDto("å·²å®æè®¢åæ°", currentCompleted, lastCompleted); |
| | | |
| | | int currentPending = productOrderMapper.countPending(currentStart, currentEnd); |
| | | int lastPending = productOrderMapper.countPending(lastStart, lastEnd); |
| | | MapDto pendingDto = createOrderCountDto("å¾
çäº§è®¢åæ°", currentPending, lastPending); |
| | | |
| | | return Arrays.asList(createdDto, completedDto, pendingDto); |
| | | } |
| | | |
| | | private MapDto createOrderCountDto(String name, int current, int last) { |
| | | MapDto dto = new MapDto(); |
| | | dto.setName(name); |
| | | dto.setValue(String.valueOf(current)); |
| | | |
| | | BigDecimal currentVal = new BigDecimal(current); |
| | | BigDecimal lastVal = new BigDecimal(last); |
| | | |
| | | if (lastVal.compareTo(BigDecimal.ZERO) == 0) { |
| | | dto.setRate(currentVal.compareTo(BigDecimal.ZERO) > 0 ? "100" : "0"); |
| | | } else { |
| | | // (Current - Last) / Last * 100 |
| | | BigDecimal diff = currentVal.subtract(lastVal); |
| | | BigDecimal rate = diff.divide(lastVal, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(0, |
| | | RoundingMode.HALF_UP); |
| | | dto.setRate(rate.toString()); |
| | | } |
| | | return dto; |
| | | } |
| | | |
| | | } |