|  |  | @ -1,214 +1,219 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | //import java.sql.*;
 |  |  |  | import java.sql.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //import org.junit.Test;
 |  |  |  | import org.junit.Test; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //import java.sql.*;
 |  |  |  | import java.sql.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | import java.time.LocalDateTime; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //import org.junit.Test;
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | import org.junit.Test; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //public class DML {
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | import java.util.Random; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    // 使用相对路径
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    private static final String URL = "jdbc:sqlite:db/dbuml.db3";
 |  |  |  | public class DML { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     // 使用相对路径
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     private static final String URL = "jdbc:sqlite:db/dbuml.db3"; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    @Test
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    public void createInboundTable() {
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        try (Connection conn = DriverManager.getConnection(URL);
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //             Statement stmt = conn.createStatement()) {
 |  |  |  |     @Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     public void createInboundTable() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |         try (Connection conn = DriverManager.getConnection(URL); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            String sql = "CREATE TABLE IF NOT EXISTS warehouse (" +
 |  |  |  |              Statement stmt = conn.createStatement()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "id TEXT PRIMARY KEY NOT NULL," +
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "goods_id TEXT NOT NULL," +
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "quantity INTEGER NOT NULL," +
 |  |  |  |             String sql = "CREATE TABLE IF NOT EXISTS warehouse (" + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "supplier TEXT," +
 |  |  |  |                     "id TEXT PRIMARY KEY NOT NULL," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "inbound_time TIMESTAMP," +
 |  |  |  |                     "goods_id TEXT NOT NULL," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "operator TEXT," +
 |  |  |  |                     "quantity INTEGER NOT NULL," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "remark TEXT" +
 |  |  |  |                     "supplier TEXT," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    ");";
 |  |  |  |                     "inbound_time TIMESTAMP," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |                     "operator TEXT," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            stmt.execute(sql);
 |  |  |  |                     "remark TEXT" + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("仓库数据表创建成功");
 |  |  |  |                     ");"; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        } catch (Exception e) {
 |  |  |  |             stmt.execute(sql); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            e.printStackTrace();
 |  |  |  |             System.out.println("仓库数据表创建成功"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        }
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    }
 |  |  |  |         } catch (Exception e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             e.printStackTrace(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    @Test
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    public void createLogTable() {
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        try (Connection conn = DriverManager.getConnection(URL);
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //             Statement stmt = conn.createStatement()) {
 |  |  |  |     @Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     public void createLogTable() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 创建操作日志数据表
 |  |  |  |         try (Connection conn = DriverManager.getConnection(URL); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            String sql = "CREATE TABLE IF NOT EXISTS operation_logs (" +
 |  |  |  |              Statement stmt = conn.createStatement()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "id TEXT PRIMARY KEY NOT NULL," +   //日志id
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "operation_type TEXT NOT NULL," +  // 操作类型(入库、出库、修改等)
 |  |  |  |             // 创建操作日志数据表
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "operation_target TEXT NOT NULL," + // 操作对象(货物ID或名称)
 |  |  |  |             String sql = "CREATE TABLE IF NOT EXISTS operation_logs (" + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "operator TEXT," +                 // 操作人
 |  |  |  |                     "id TEXT PRIMARY KEY NOT NULL," +   //日志id
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "operation_time TIMESTAMP," +      // 操作时间
 |  |  |  |                     "operation_type TEXT NOT NULL," +  // 操作类型(入库、出库、修改等)
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "details TEXT" +                   // 操作详情
 |  |  |  |                     "operation_target TEXT NOT NULL," + // 操作对象(货物ID或名称)
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    ");";
 |  |  |  |                     "operator TEXT," +                 // 操作人
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |                     "operation_time TIMESTAMP," +      // 操作时间
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            stmt.execute(sql);
 |  |  |  |                     "details TEXT" +                   // 操作详情
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("日志数据表创建成功");
 |  |  |  |                     ");"; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        } catch (Exception e) {
 |  |  |  |             stmt.execute(sql); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            e.printStackTrace();
 |  |  |  |             System.out.println("日志数据表创建成功"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        }
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    }
 |  |  |  |         } catch (Exception e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             e.printStackTrace(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    @Test
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    public void clearTable() {
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        try (Connection conn = DriverManager.getConnection(URL);
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //             Statement stmt = conn.createStatement()) {
 |  |  |  |     @Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     public void clearTable() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            String sql = "DELETE FROM warehouse";
 |  |  |  |         try (Connection conn = DriverManager.getConnection(URL); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            int result = stmt.executeUpdate(sql);
 |  |  |  |              Statement stmt = conn.createStatement()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("已清空数据表,删除了 " + result + " 条记录");
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             String sql = "DELETE FROM warehouse"; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        } catch (SQLException e) {
 |  |  |  |             int result = stmt.executeUpdate(sql); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            e.printStackTrace();
 |  |  |  |             System.out.println("已清空数据表,删除了 " + result + " 条记录"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        }
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    }  //清空指定数据表数据
 |  |  |  |         } catch (SQLException e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    @Test
 |  |  |  |             e.printStackTrace(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    public void dropTable() {
 |  |  |  |         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        try (Connection conn = DriverManager.getConnection(URL);
 |  |  |  |     }  //清空指定数据表数
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //             Statement stmt = conn.createStatement()) {
 |  |  |  |     @Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     public void dropTable() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 删除表的SQL 语句
 |  |  |  |         try (Connection conn = DriverManager.getConnection(URL); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            String sql = "DROP TABLE IF EXISTS inbound_records";
 |  |  |  |              Statement stmt = conn.createStatement()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 执行 SQL 语句
 |  |  |  |             // 删除表的SQL 语句
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            stmt.execute(sql);
 |  |  |  |             String sql = "DROP TABLE IF EXISTS inbound_records"; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println(" 表删除成功");
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             // 执行 SQL 语句
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        } catch (SQLException e) {
 |  |  |  |             stmt.execute(sql); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            e.printStackTrace();
 |  |  |  |             System.out.println(" 表删除成功"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        }
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    }  //删除指定数据表
 |  |  |  |         } catch (SQLException e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             e.printStackTrace(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    @Test
 |  |  |  |         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    public void showCurrentStock() {
 |  |  |  |     }  //删除指定数据表
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        try (Connection conn = DriverManager.getConnection(URL);
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //             Statement stmt = conn.createStatement()) {
 |  |  |  |     @Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     public void showCurrentStock() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 查询每个商品的当前库存(入库减去出库)
 |  |  |  |         try (Connection conn = DriverManager.getConnection(URL); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            String sql = "SELECT goods_id, SUM(quantity) as current_stock " +
 |  |  |  |              Statement stmt = conn.createStatement()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        "FROM warehouse " +
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        "GROUP BY goods_id";
 |  |  |  |             // 查询每个商品的当前库存(入库减去出库)
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            ResultSet rs = stmt.executeQuery(sql);
 |  |  |  |             String sql = "SELECT goods_id, SUM(quantity) as current_stock " + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |                         "FROM warehouse " + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 打印表头
 |  |  |  |                         "GROUP BY goods_id"; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("===================== 当前库存状态 =====================");
 |  |  |  |             ResultSet rs = stmt.executeQuery(sql); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.printf("%-20s %-15s%n", "货物名称", "当前库存");
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("===================================================");
 |  |  |  |             // 打印表头
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             System.out.println("===================== 当前库存状态 ====================="); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 打印数据
 |  |  |  |             System.out.printf("%-20s %-15s%n", "货物名称", "当前库存"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            while (rs.next()) {
 |  |  |  |             System.out.println("==================================================="); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                System.out.printf("%-20s %-15d%n",
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        rs.getString("goods_id"),
 |  |  |  |             // 打印数据
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        rs.getInt("current_stock")
 |  |  |  |             while (rs.next()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                );
 |  |  |  |                 System.out.printf("%-20s %-15d%n", | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            }
 |  |  |  |                         rs.getString("goods_id"), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("===================================================");
 |  |  |  |                         rs.getInt("current_stock") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |                 ); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        } catch (SQLException e) {
 |  |  |  |             } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            e.printStackTrace();
 |  |  |  |             System.out.println("==================================================="); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        }
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    }
 |  |  |  |         } catch (SQLException e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             e.printStackTrace(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    @Test
 |  |  |  |         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    public void showAllTransactions() {
 |  |  |  |     } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        try (Connection conn = DriverManager.getConnection(URL);
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //             Statement stmt = conn.createStatement()) {
 |  |  |  |     @Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     public void showAllTransactions() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 查询所有出入库记录
 |  |  |  |         try (Connection conn = DriverManager.getConnection(URL); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            String sql = "SELECT *, " +
 |  |  |  |              Statement stmt = conn.createStatement()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        "CASE WHEN quantity > 0 THEN '入库' ELSE '出库' END as type " +
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        "FROM warehouse " +
 |  |  |  |             // 查询所有出入库记录
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        "ORDER BY inbound_time DESC";
 |  |  |  |             String sql = "SELECT *, " + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            ResultSet rs = stmt.executeQuery(sql);
 |  |  |  |                         "CASE WHEN quantity > 0 THEN '入库' ELSE '出库' END as type " + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |                         "FROM warehouse " + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 打印表头
 |  |  |  |                         "ORDER BY inbound_time DESC"; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("===================== 出入库记录 =====================");
 |  |  |  |             ResultSet rs = stmt.executeQuery(sql); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.printf("%-15s %-15s %-8s %-8s %-15s %-25s%n",
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "单号", "货物名称", "数量", "类型", "供应商", "时间");
 |  |  |  |             // 打印表头
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("===================================================");
 |  |  |  |             System.out.println("===================== 出入库记录 ====================="); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             System.out.printf("%-15s %-15s %-8s %-8s %-15s %-25s%n", | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 打印数据
 |  |  |  |                     "单号", "货物名称", "数量", "类型", "供应商", "时间"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            while (rs.next()) {
 |  |  |  |             System.out.println("==================================================="); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                System.out.printf("%-15s %-15s %-8d %-8s %-15s %-25s%n",
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        rs.getString("id"),
 |  |  |  |             // 打印数据
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        rs.getString("goods_id"),
 |  |  |  |             while (rs.next()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        Math.abs(rs.getInt("quantity")),
 |  |  |  |                 System.out.printf("%-15s %-15s %-8d %-8s %-15s %-25s%n", | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        rs.getString("type"),
 |  |  |  |                         rs.getString("id"), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        rs.getString("supplier"),
 |  |  |  |                         rs.getString("goods_id"), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                        rs.getString("inbound_time")
 |  |  |  |                         Math.abs(rs.getInt("quantity")), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                );
 |  |  |  |                         rs.getString("type"), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            }
 |  |  |  |                         rs.getString("supplier"), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("===================================================");
 |  |  |  |                         rs.getString("inbound_time") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |                 ); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        } catch (SQLException e) {
 |  |  |  |             } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            e.printStackTrace();
 |  |  |  |             System.out.println("==================================================="); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        }
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    }
 |  |  |  |         } catch (SQLException e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             e.printStackTrace(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    @Test
 |  |  |  |         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    public void deleteOutboundRecord() {
 |  |  |  |     } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        try (Connection conn = DriverManager.getConnection(URL);
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //             Statement stmt = conn.createStatement()) {
 |  |  |  |     @Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     public void deleteOutboundRecord() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 删除出库记录的SQL语句
 |  |  |  |         try (Connection conn = DriverManager.getConnection(URL); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            String sql = "DELETE FROM warehouse WHERE id = ?";
 |  |  |  |              Statement stmt = conn.createStatement()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            try (PreparedStatement pstmt = conn.prepareStatement(sql)) {
 |  |  |  |             // 删除出库记录的SQL语句
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                // 这里可以设置要删除的记录ID
 |  |  |  |             String sql = "DELETE FROM warehouse WHERE id = ?"; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                pstmt.setString(1, "要删除的记录ID");
 |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                int result = pstmt.executeUpdate();
 |  |  |  |             try (PreparedStatement pstmt = conn.prepareStatement(sql)) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |                 // 这里可以设置要删除的记录ID
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                if (result > 0) {
 |  |  |  |                 pstmt.setString(1, "要删除的记录ID");   | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    System.out.println("出库记录删除成功");
 |  |  |  |                 int result = pstmt.executeUpdate(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                } else {
 |  |  |  |                  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    System.out.println("未找到要删除的记录");
 |  |  |  |                 if (result > 0) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                }
 |  |  |  |                     System.out.println("出库记录删除成功"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            }
 |  |  |  |                 } else { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |                     System.out.println("未找到要删除的记录"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        } catch (SQLException e) {
 |  |  |  |                 } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            e.printStackTrace();
 |  |  |  |             } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("删除出库记录失败:" + e.getMessage());
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        }
 |  |  |  |         } catch (SQLException e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    }
 |  |  |  |             e.printStackTrace(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |             System.out.println("删除出库记录失败:" + e.getMessage()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    @Test
 |  |  |  |         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    public void createOperationLogsTable() {
 |  |  |  |     } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        try (Connection conn = DriverManager.getConnection(URL);
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //             Statement stmt = conn.createStatement()) {
 |  |  |  |     @Test | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |     public void createOperationLogsTable() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 删除已存在的表
 |  |  |  |         try (Connection conn = DriverManager.getConnection(URL); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            stmt.execute("DROP TABLE IF EXISTS operation_logs");
 |  |  |  |              Statement stmt = conn.createStatement()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            // 创建新表
 |  |  |  |             // 删除已存在的表
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            String sql = "CREATE TABLE operation_logs (" +
 |  |  |  |             stmt.execute("DROP TABLE IF EXISTS operation_logs"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "id TEXT PRIMARY KEY NOT NULL," +
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "operation_type TEXT NOT NULL," +
 |  |  |  |             // 创建新表
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "operation_target TEXT NOT NULL," +
 |  |  |  |             String sql = "CREATE TABLE operation_logs (" + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "operator TEXT NOT NULL," +
 |  |  |  |                     "id TEXT PRIMARY KEY NOT NULL," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "operation_time TEXT NOT NULL," +
 |  |  |  |                     "operation_type TEXT NOT NULL," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    "details TEXT" +
 |  |  |  |                     "operation_target TEXT NOT NULL," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //                    ")";
 |  |  |  |                     "operator TEXT NOT NULL," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  |                     "operation_time TEXT NOT NULL," + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            stmt.execute(sql);
 |  |  |  |                     "details TEXT" + | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            System.out.println("操作日志表创建成功");
 |  |  |  |                     ")"; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        } catch (SQLException e) {
 |  |  |  |             stmt.execute(sql); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //            e.printStackTrace();
 |  |  |  |             System.out.println("操作日志表创建成功"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //        }
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //    }
 |  |  |  |         } catch (SQLException e) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //}
 |  |  |  |             e.printStackTrace(); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } |