Java超市收银系统(八、数据导入)

news2024/9/23 23:23:25

引言

        当选择1时,程序读取 “商品信息.xls” 文件,将所有数据存放于product集合中,然后将集合中的所有数据增加到商品表中,增加的时候要检查每条记录的条形码在商品表中是否存在,若存在,则不需要增加到数据库中,所有数据增加完毕后,显示“成功从excel文件导入XXX条商品数据”,返回子菜单。

        当选择2时,程序读取 “商品信息.xls” 文件,将所有数据存放于product集合中,然后将集合中的所有数据增加到商品表中,增加的时候要检查每条记录的条形码在商品表中是否存在,若存在,则不需要增加。

功能实现

第三方库导入

        jxl包导入,用于实现对excel处理。从Maven仓库中下载jar文件,之前的数据库连接mysql同样如此,也要下载jar包。Maven仓库链接如下:

​​​​​​Maven Repository: Search/Browse/Explore (mvnrepository.com)

在搜索栏搜索mysql和jxl:

点击合适版本进入,点击jar自动下载对应包:

将jar添加到idea编译器中,最后点击OK:

导入功能

        ok,相信前面博客的dao、vo、util已经讲的很明白了,我们重点来看ui中Driver函数的实现。

public static void main(String[] args) {
    while(true) {
        System.out.println("===****超市商品管理维护====");
        System.out.println("1、从excel中导入数据");
        System.out.println("2、从文本文件导入数据");
        System.out.println("3、返回主菜单");
        System.out.println("请选择(1-3):");
        Scanner scanner = new Scanner(System.in);
        int choice = scanner.nextInt();
        switch (choice) {
            case 1:
                inputExcel();
                break;
            case 2:
                inputTxt();
                break;
            case 3:
                System.out.println("返回主菜单");
                break;
            default:
                System.out.println("错误");
        }
    }
}
  • 这个方法在一个无限循环中显示菜单,让用户选择要执行的操作。
  • 根据用户的选择,程序调用不同的方法来处理数据导入。
private static void inputExcel() {
    File file = new File("D:\\1111111111111111111111111\\数据导入\\excel\\商品信息.xls");
    List<Product> productList = new ArrayList<>();

    try {
        FileInputStream fis = new FileInputStream(file);
        Workbook workbook = Workbook.getWorkbook(fis);

        // 获取第一个工作表
        Sheet sheet = workbook.getSheet(0);

        // 循环访问行
        for (int i = 1; i < sheet.getRows(); i++) { // 跳过表头(假设第一行是表头)
            String barCode = sheet.getCell(0, i).getContents();
            String productName = sheet.getCell(1, i).getContents();
            String priceStr = sheet.getCell(2, i).getContents(); // 读取价格字符串
            String supply = sheet.getCell(3, i).getContents();

            float price;
            try {
                price = Float.parseFloat(priceStr);
            } catch (NumberFormatException e) {
                System.err.println("发现无效的价格数据:" + priceStr);
                continue; // 跳过无效的数据行
            }

            // 检查具有相同条形码的产品是否已存在
            Product existingProduct = ProductDAO.queryByBarcode(barCode);
            if (existingProduct == null) {
                Product product = new Product(barCode, productName, price, supply);
                productList.add(product);
            }
        }

        // 将产品插入数据库
        int count = 0;
        for (Product product : productList) {
            boolean success = ProductDAO.insert(product);
            if (success) {
                count++;
            }
        }

        System.out.println("成功插入了 " + count + " 个产品到数据库中。");

    } catch (IOException | BiffException e) {
        e.printStackTrace();
    }
}
  • 该方法从指定路径的Excel文件中读取数据。
  • 跳过表头(第一行是表头),然后逐行读取商品信息。
  • 解析价格并检查商品是否已存在数据库中,如果不存在,则将商品信息添加到产品列表中。
  • 最后,将产品列表中的商品信息插入数据库,并显示成功插入的数量。

 

private static void inputTxt() {
    List<Product> productList = new ArrayList<>();
    String filePath = "D:\\1111111111111111111111111\\数据导入\\txt\\商品信息.txt";

    try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {

        // 读取并丢弃前两行
        String line = reader.readLine(); // 第一行
        if (line != null) {
            line = reader.readLine(); // 第二行
        }

        while ((line = reader.readLine()) != null) {
            String[] parts = line.split("\t"); // 使用制表符作为分隔符
            if (parts.length == 4) {
                String barCode = parts[0];
                String productName = parts[1];
                String price = parts[2];
                String supply = parts[3];

                // 检查条形码是否已存在
                if (ProductDAO.queryByBarcode(barCode) == null) {
                    Product product = new Product(barCode, productName, Float.parseFloat(price), supply);
                    productList.add(product);
                }
            } else {
                System.out.println("文本文件格式错误:" + line);
            }
        }
    } catch (IOException e) {
        throw new RuntimeException("无法读取文本文件", e);
    }

    // 将 productList 中的商品信息插入数据库
    int successfulInsertions = 0;
    for (Product product : productList) {
        if (ProductDAO.insert(product)) { // 插入商品信息
            successfulInsertions++;
        }
    }

    System.out.println("成功从文本文件导入 " + successfulInsertions + " 条商品数据");
}
  • 该方法从指定路径的文本文件中读取数据。
  • 跳过前两行,然后逐行读取商品信息。
  • 根据制表符(\t)分隔字段,并检查商品是否已存在数据库中,如果不存在,则将商品信息添加到产品列表中。
  • 最后,将产品列表中的商品信息插入数据库,并显示成功导入的数量。

        这个程序提供了一个命令行界面,通过选择菜单选项,用户可以从Excel或文本文件中导入商品数据,并将数据插入到数据库中。它包含了基本的错误处理和数据验证,以确保导入过程的正确性。 

结果展示

相关导入excel和txt文件如下:

导入前数据库:

 导入后数据库更新:

完整代码

ui—Driver

package ui;

import dao.ProductDAO;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import vo.Product;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Driver {
    public static void main(String[] args) {
        while(true) {
            System.out.println("===****超市商品管理维护====");
            System.out.println("1、从excel中导入数据");
            System.out.println("2、从文本文件导入数据");
            System.out.println("3、返回主菜单");
            System.out.println("请选择(1-3):");
            Scanner scanner = new Scanner(System.in);
            int choice = scanner.nextInt();
            switch (choice) {
                case 1:
                    inputExcel();
                    break;
                case 2:
                    inputTxt();
                    break;
                case 3:
                    System.out.println("返回主菜单");
                    break;
                default:
                    System.out.println("错误");

            }
        }
    }

    private static void inputExcel() {
        //Scanner scanner = new Scanner(System.in);
        //System.out.println("请输入要导入的 Excel 文件路径:");
        //String filePath = scanner.nextLine();
        File file = new File("D:\\1111111111111111111111111\\数据导入\\excel\\商品信息.xls");
        List<Product> productList = new ArrayList<>();

        try {
            FileInputStream fis = new FileInputStream(file);
             Workbook workbook = Workbook.getWorkbook(fis);

            // 获取第一个工作表
            Sheet sheet = workbook.getSheet(0);

            // 循环访问行
            for (int i = 1; i < sheet.getRows(); i++) { // 跳过表头(假设第一行是表头)
                String barCode = sheet.getCell(0, i).getContents();
                String productName = sheet.getCell(1, i).getContents();
                String priceStr = sheet.getCell(2, i).getContents(); // 读取价格字符串
                String supply = sheet.getCell(3, i).getContents();

                float price;
                try {
                    price = Float.parseFloat(priceStr);
                } catch (NumberFormatException e) {
                    System.err.println("发现无效的价格数据:" + priceStr);
                    continue; // 跳过无效的数据行
                }

                // 检查具有相同条形码的产品是否已存在
                Product existingProduct = ProductDAO.queryByBarcode(barCode);
                if (existingProduct == null) {
                    Product product = new Product(barCode, productName, price, supply);
                    productList.add(product);
                }
            }

            // 将产品插入数据库
            int count = 0;
            for (Product product : productList) {
                boolean success = ProductDAO.insert(product);
                if (success) {
                    count++;
                }
            }

            System.out.println("成功插入了 " + count + " 个产品到数据库中。");

        } catch (IOException | BiffException e) {
            e.printStackTrace();
        }
    }

    private static void inputTxt() {
        List<Product> productList = new ArrayList<>();
        String filePath = "D:\\1111111111111111111111111\\数据导入\\txt\\商品信息.txt";

        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {

            // 读取并丢弃前两行
            String line = reader.readLine(); // 第一行
            if (line != null) {
                line = reader.readLine(); // 第二行
            }

            while ((line = reader.readLine()) != null) {
                String[] parts = line.split("\t"); // 使用制表符作为分隔符
                if (parts.length == 4) {
                    String barCode = parts[0];
                    String productName = parts[1];
                    String price = parts[2];
                    String supply = parts[3];

                    // 检查条形码是否已存在
                    if (ProductDAO.queryByBarcode(barCode) == null) {
                        Product product = new Product(barCode, productName, Float.parseFloat(price), supply);
                        productList.add(product);
                    }
                } else {
                    System.out.println("文本文件格式错误:" + line);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException("无法读取文本文件", e);
        }

        // 将 productList 中的商品信息插入数据库
        int successfulInsertions = 0;
        for (Product product : productList) {
            if (ProductDAO.insert(product)) { // 插入商品信息
                successfulInsertions++;
            }
        }

        System.out.println("成功从文本文件导入 " + successfulInsertions + " 条商品数据");
    }
}

vo—Product

package vo;

public class Product {
    private String barCode;
    private String productName;
    private float price;
    private String supply;

    public Product() {
    }

    public Product(String barCode, String productName, float price, String supply) {
        this.barCode = barCode;
        this.productName = productName;
        this.price = price;
        this.supply = supply;
    }

    public String getBarCode() {
        return barCode;
    }

    public void setBarCode(String barCode) {
        this.barCode = barCode;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public String getSupply() {
        return supply;
    }

    public void setSupply(String supply) {
        this.supply = supply;
    }
}

dao—ProductDAO

package dao;

import util.DBUtil;
import vo.Product;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ProductDAO {
    public static Product queryByBarcode(String barcode) {
        Connection con = null;
        PreparedStatement pst = null;
        ResultSet rs = null;
        Product product = null;
        try {
            con = DBUtil.getConnection();
            String sql = "SELECT * FROM t_shangping WHERE tiaoma = ?";
            pst = con.prepareStatement(sql);
            pst.setString(1, barcode);
            rs = pst.executeQuery();
            if (rs.next()) {
                product = new Product();
                product.setBarCode(rs.getString("tiaoma"));
                product.setProductName(rs.getString("mingcheng"));
                product.setPrice(rs.getFloat("danjia"));
                product.setSupply(rs.getString("gongyingshang"));
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            DBUtil.close(con, pst);
        }
        return product;
    }

    public static boolean insert(Product product) {
        Connection con = null;
        PreparedStatement pst = null;
        boolean success = false;
        try {
            con = DBUtil.getConnection();
            String sql = "INSERT INTO t_shangping (tiaoma, mingcheng, danjia, gongyingshang) VALUES (?, ?, ?, ?)";
            pst = con.prepareStatement(sql);
            pst.setString(1, product.getBarCode());
            pst.setString(2, product.getProductName());
            pst.setFloat(3, product.getPrice());
            pst.setString(4, product.getSupply());
            int rowsAffected = pst.executeUpdate();
            if (rowsAffected > 0) {
                success = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(con, pst);
        }
        return success;
    }

}

util—DBUtil

package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class DBUtil {

    //驱动加载,只需执行一次
    static{
        String driveName = "com.mysql.cj.jdbc.Driver";
        try {
            Class.forName(driveName);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    //获取链接
    public static Connection getConnection(){
        String url = "jdbc:mysql://localhost:3306/sale?useUnicode=true&characterEncoding=utf-8";
        String user = "root";
        String password = "123456";
        Connection con = null;
        try {
            con = DriverManager.getConnection(url,user,password);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return con;
    }

    //关闭资源
    public static void close(Connection con, PreparedStatement pst){
        if(con!=null) {
            try {
                con.close();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
        if(pst!=null) {
            try {
                pst.close();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
    }

}

mysql

/*
Navicat MySQL Data Transfer
 
Source Server         : localhost_3306
Source Server Version : 80032
Source Host           : localhost:3306
Source Database       : xiaoshou
 
Target Server Type    : MYSQL
Target Server Version : 80032
File Encoding         : 65001
 
Date: 2023-05-11 10:27:07
*/
 
SET FOREIGN_KEY_CHECKS=0;
use sale;
-- ----------------------------
-- Table structure for t_shangping
-- ----------------------------
DROP TABLE IF EXISTS `t_shangping`;
CREATE TABLE `t_shangping` (
  `tiaoma` varchar(255) NOT NULL,
  `mingcheng` varchar(255) DEFAULT NULL,
  `danjia` decimal(10,2) DEFAULT NULL,
  `gongyingshang` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`tiaoma`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
select * from t_shangping;
 
-- ----------------------------
-- Records of t_shangping
-- ----------------------------
INSERT INTO `t_shangping` VALUES ('100001', '手机', '4500.00', '华为');
INSERT INTO `t_shangping` VALUES ('100002', '鼠标', '61.00', '华为');
INSERT INTO `t_shangping` VALUES ('100003', '矿泉水', '2.50', '农夫山泉');
INSERT INTO `t_shangping` VALUES ('100004', '香烟', '20.00', '武汉卷烟厂');
INSERT INTO `t_shangping` VALUES ('100005', '牙膏', '4.50', '中华牙膏厂');
INSERT INTO `t_shangping` VALUES ('200001', '电脑', '4300.00', 'dell');
INSERT INTO `t_shangping` VALUES ('200002', '小明同学', '5.50', '武汉饮料集团');
 
-- ----------------------------
-- Table structure for t_shouyinmingxi
-- ----------------------------
DROP TABLE IF EXISTS `t_shouyinmingxi`;
CREATE TABLE `t_shouyinmingxi` (
  `liushuihao` varchar(255) NOT NULL,
  `tiaoma` varchar(255) DEFAULT NULL,
  `mingcheng` varchar(255) DEFAULT NULL,
  `danjia` decimal(10,0) DEFAULT NULL,
  `shuliang` int DEFAULT NULL,
  `shouyinyuan` varchar(255) DEFAULT NULL,
  `xiaoshoushijian` datetime DEFAULT NULL,
  PRIMARY KEY (`liushuihao`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
select * from t_shouyinmingxi;
-- ----------------------------
-- Records of t_shouyinmingxi
-- ----------------------------
 
-- ----------------------------
-- Table structure for t_yonghu
-- ----------------------------
DROP TABLE IF EXISTS `t_yonghu`;
CREATE TABLE `t_yonghu` (
  `yonghuming` varchar(255) NOT NULL,
  `mima` varchar(255) DEFAULT NULL,
  `xingming` varchar(255) DEFAULT NULL,
  `juese` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`yonghuming`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
select * from t_yonghu;
-- ----------------------------
-- Records of t_yonghu
-- ----------------------------
INSERT INTO `t_yonghu` VALUES ('mk', 'mk123', '明空', '管理员');
INSERT INTO `t_yonghu` VALUES ('jx', 'jx123', '瑾熙', '收银员');

相关其他功能实现请参考前面的博客

Java超市收银系统(一、用户登录)_java商超收银系统-CSDN博客

Java超市收银系统(二、用户权限)-CSDN博客

Java超市收银系统(三、密码修改)-CSDN博客

Java超市收银系统(四、收银功能)_java超市系统-CSDN博客

Java超市收银系统(五、收银统计)-CSDN博客

Java超市收银系统(六、商品增加和修改)-CSDN博客

Java超市收银系统(七、商品修改和删除)-CSDN博客

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2046489.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

tortoisegit下载及其使用流程

下载 官方下载链接&#xff1a;Download – TortoiseGit – Windows Shell Interface to Git 选择适合自己的电脑位数的版本&#xff1a;一般64的兼容32的 按照就不介绍了怎么开心怎么来&#xff0c;本篇暂时为了支持一位粉丝的疑惑 安装的话没有特殊配置暂不介绍&#xff0c…

Dbeaver连接达梦数据库教程(图文版)

本章教程&#xff0c;主要介绍如何用Dbeaver连接国产达梦数据库。 达梦数据库Docker部署教程参考&#xff1a;https://yang-roc.blog.csdn.net/article/details/141158807 一、Dbeaver安装包下载 下载Dbeaver&#xff1a;https://dbeaver.io/ 在这里就不演示安装过程了&#xf…

GPU驱动的大规模静态物件渲染

GPU Driven 的静态物件渲染&#xff0c;听起来很高级&#xff0c;其实具体操作很简单&#xff0c;基础就是直接调用 Graphics.DrawMeshInstancedIndirect 这个 Unity 内置接口就可以了。但我们项目对这个流程做了一些优化&#xff0c;使得支持的实体数量有大幅提升。 这套系统主…

海南云亿商务咨询有限公司引领抖音电商新潮流

在当今这个数字化时代&#xff0c;电商行业如日中天&#xff0c;而抖音作为短视频与社交电商完美融合的典范&#xff0c;正以前所未有的速度改变着人们的购物习惯和消费模式。在这片充满机遇与挑战的蓝海中&#xff0c;海南云亿商务咨询有限公司凭借其敏锐的市场洞察力和专业的…

【算法/学习】:flood算法

✨ 君子坐而论道&#xff0c;少年起而行之 &#x1f30f; &#x1f4c3;个人主页&#xff1a;island1314 &#x1f525;个人专栏&#xff1a;算法学习 &#x1f680; 欢迎关注&#xff1a;&#x1f44d;点赞 &…

鸿蒙交互事件开发01——点击/拖拽/触摸事件

如果你也对鸿蒙开发感兴趣&#xff0c;加入“Harmony自习室”吧&#xff01;扫描下方名片&#xff0c;关注公众号&#xff0c;公众号更新更快&#xff0c;同时也有更多学习资料和技术讨论群。 1 概 述 事件是人机交互的基础&#xff0c;鸿蒙开发中&#xff0c;事件分…

EmguCV学习笔记 VB.Net 2.1 颜色空间和颜色

版权声明&#xff1a;本文为博主原创文章&#xff0c;转载请在显著位置标明本文出处以及作者网名&#xff0c;未经作者允许不得用于商业目的。 EmguCV学习笔记目录 Vb.net EmguCV学习笔记目录 C# 笔者的博客网址&#xff1a;VB.Net-CSDN博客 教程相关说明以及如何获得pdf教程…

威胁组织伪造Loom,Mac用户警惕AMOS窃取软件威胁

近期&#xff0c;一个复杂且可能与神秘威胁组织“Crazy Evil”有关联的网络犯罪活动&#xff0c;已将注意力转向了Mac用户群体。该组织利用广受欢迎的屏幕录制工具Loom作为掩护&#xff0c;悄无声息地传播着臭名远扬的AMOS数据窃取软件。Moonlock Lab的安全研究员们揭开了这一阴…

【数据结构与算法 | 图篇】拓扑排序

1. 概念 拓扑排序是是一种针对有向无环图进行的排序方法。它将图中所有顶点排成一个线性序列&#xff0c;使得对于图中的每一条有向边(u, v)&#xff0c;顶点u在序列中都出现在顶点v之前。 适用范围&#xff1a; 拓扑排序只适用于有向无环图。 结果非唯一&#xff1a; 对于…

阿里云ubuntu系统安装mysql8.0

一、安装mysql8.0 1.已安装其他版本的mysql&#xff0c;需要删除 若没有不需要此操作 1 #卸载MySQL5.7版本 2 apt remove -y mysql-client5.7* mysql-community-server5.7* 4 # 卸载5.7的仓库信息 5 dpkg-l | grep mysql | awk iprint $2} | xargs dpkg -P2.更新仓库 apt u…

FASTSPEECH 2论文阅读

FASTSPEECH 2: FAST AND HIGH-QUALITY END-TOEND TEXT TO SPEECH 现状 非自回归模型可以在质量相当的情况下显著快于先前的自回归模型合成模型。但FastSpeech模型训练依赖与自回归教师模型进行时长预测&#xff08;提供更多的信息作为输入&#xff09;和知识蒸馏&#xff08;…

【开端】Java中判断一个对象是否是空内容

一、绪论 在Java中&#xff0c;我们常常使用的到的就是封装&#xff0c;为什么要封装&#xff0c;封装有什么好处。首先在系统开发过程中&#xff0c;其实很多功能和场景都共性的。那么为了避免重复造轮子&#xff0c;我们这时就使用到了封装。封装可以一次造轮子&#xff0c;无…

数据集搜索

1. 数据集和数据集的分类 数据集是一组数据的集合&#xff0c;通常用于机器学习、统计分析、数据挖掘等领域&#xff0c;帮助算法训练、模型验证和评估。可以是各种形式的数据&#xff0c;如表格、图像、机器学习相关的文件等。 根据在机器学习中的应用&#xff0c;数据集可以…

1. MongoDB概念解析

1. 概念解析 在 MongoDB 中基本的概念是文档、集合、数据库。 SQL 术语/概念MongoDB 术语/概念解释/说明databasedatabase数据库tablecollection数据库表/集合rowdocument数据记录行/文档columnfield数据字段/域indexindex索引table joins表连接,MongoDB不支持primary keypri…

1.3 数据库的发展历史与演变

欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;欢迎订阅相关专栏&#xff1a; 工&#x1f497;重&#x1f497;hao&#x1f497;&#xff1a;野老杂谈 ⭐️ 全网最全IT互联网公司面试宝典&#xff1a;收集整理全网各大IT互联网公司技术、项目、HR面试真题.…

鸿萌数据恢复服务: 如何修复 SQL Server 数据库错误 829?

天津鸿萌科贸发展有限公司从事数据安全服务二十余年&#xff0c;致力于为各领域客户提供专业的数据恢复、数据备份、网络及终端数据安全等解决方案与服务。 同时&#xff0c;鸿萌是众多国际主流数据恢复软件(Stellar、UFS、R-Studio、ReclaiMe Pro 等)的授权代理商&#xff0c…

pandas 笔记crosstab

用来计算两个&#xff08;或更多&#xff09;因子的交叉表&#xff08;即频率表、列联表或透视表&#xff09;。这个功能特别适用于统计分析和数据探索阶段&#xff0c;帮助理解不同变量之间的关系 1 基本用法 pd.crosstab(index, columns, valuesNone, rownamesNone, colnam…

基于UE5和ROS2的激光雷达+深度RGBD相机小车的仿真指南(二)---ROS2与UE5进行图像数据传输

前言 本系列教程旨在使用UE5配置一个具备激光雷达深度摄像机的仿真小车&#xff0c;并使用通过跨平台的方式进行ROS2和UE5仿真的通讯&#xff0c;达到小车自主导航的目的。本教程默认有ROS2导航及其gazebo仿真相关方面基础&#xff0c;Nav2相关的学习教程可以参考本人的其他博…

HarmonyOS-MPChart以X轴或y轴为区间设置不同颜色

本文是基于鸿蒙三方库mpchart OpenHarmony-SIG/ohos-MPChart 的使用&#xff0c;以X轴为区间设置不同的曲线颜色。 mpchart本身的绘制功能是不支持不同区间颜色不同的曲线的&#xff0c;那么当我们的需求曲线根据x轴的刻度区间绘制不同颜色&#xff0c;就需要自定义绘制方法了。…

LVS (Linux virual server)

LVS简介 LVS&#xff08;Linux Virtual Server&#xff09;是一个基于Linux平台的开源负载均衡系统。它通过将多个服务器组成一个虚拟服务器集群&#xff0c;实现了高效的负载均衡和流量分发。 LVS的核心思想是利用IP负载均衡技术和内容请求分发机制&a…