From 58d7b0e12ccd92cf3934f6582b51b5fbcecaa39a Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 09 五月 2024 09:42:41 +0800
Subject: [PATCH] 修改注入方式

---
 springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java |  452 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 420 insertions(+), 32 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java b/springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java
index 6dc8f99..4da549e 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java
@@ -5,59 +5,448 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.springframework.stereotype.Component;
 
-import com.example.springboot.entity.Glass;
+import com.example.springboot.entity.Queue;
+import com.example.springboot.entity.north_glass_buffer1;
+
 @Component
 public class JdbcConnections {
-    /**
+	/**
 	 * 鏁版嵁搴撹繛鎺ュ弬鏁�
 	 * driver,url,username,password
 	 */
-	private static final String DRIVER = "com.mysql.jdbc.Driver";
+	private static final String DRIVER = "com.mysql.cj.jdbc.Driver";
 	private static final String URL = "jdbc:mysql://localhost:3306/canadames";
 	private static final String USERNAME = "root";
 	private static final String PASSWORD = "beibo.123/";
-	
-	private static Connection conn = null;
+
+	private static Connection conns = null;
 	private static PreparedStatement ps = null;
-	private static ResultSet rs = null;
-	
-	public  Glass selectGlass(int glassid) throws SQLException {
-        conn = getConn();
-        Glass glass=new Glass();
-        String sql = "select orderid from glass where glassid=?";
-         ps = conn.prepareStatement(sql);
-         ps.setInt(1, glassid);
-         rs= ps.executeQuery();
-         while (rs.next()) {
-			glass.setOrderId(rs.getString("orderid"));
-         }
-		 conn.close();
-         return glass;
-    }
+	private static ResultSet rss = null;
+
+	public north_glass_buffer1 selectGlass(int glassid) throws SQLException {
+		try {
+			Connection conn = getConn();
+			north_glass_buffer1 glass = new north_glass_buffer1();
+			String sql = "select ordernumber from north_glass_buffer1 where glassid=?";
+			ps = conn.prepareStatement(sql);
+			ps.setInt(1, glassid);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				glass.setordernumber(rs.getString("ordernumber"));
+			}
+			conn.close();
+			return glass;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	public north_glass_buffer1 SelectGlassByGlassIdOrderIdFrameId(String glassid, String orderid, String frameid)
+			throws SQLException {
+
+		try {
+			Connection conn = getConn();
+			north_glass_buffer1 north_glass_buffer1s = new north_glass_buffer1();
+			String sql = "select * from north_glass_buffer1 where barcode=? or ordernumber=? or FrameBarcode=?";
+			ps = conn.prepareStatement(sql);
+			ps.setString(1, glassid);
+			ps.setString(2, orderid);
+			ps.setString(3, frameid);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				north_glass_buffer1s.setId(rs.getInt("Id"));
+				north_glass_buffer1s.setordernumber(rs.getString("ordernumber"));
+				north_glass_buffer1s.setlistnumber(rs.getString("listnumber"));
+				north_glass_buffer1s.setboxnumber(rs.getString("boxnumber"));
+				north_glass_buffer1s.setbarcode(rs.getString("barcode"));
+				north_glass_buffer1s.setglasslength(rs.getDouble("glasslength"));
+				north_glass_buffer1s.setglassheight(rs.getDouble("glassheight"));
+				north_glass_buffer1s.setglasslengthmm(rs.getDouble("glasslength_mm"));
+				north_glass_buffer1s.setglassheightmm(rs.getDouble("glassheight_mm"));
+				north_glass_buffer1s.setitemtype(rs.getString("itemtype"));
+				north_glass_buffer1s.setslotnumber(rs.getString("slotnumber"));
+				north_glass_buffer1s.setdatemodified(rs.getString("datemodified"));
+				north_glass_buffer1s.setdatecreated(rs.getString("datecreated"));
+				north_glass_buffer1s.setFrameBarcode(rs.getString("FrameBarcode"));
+			}
+			conn.close();
+			return north_glass_buffer1s;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	public north_glass_buffer1 SelectGlassByGlassIdOrderIdFrameIdout(String glassid, String orderid, String frameid)
+			throws SQLException {
+		try {
+			Connection conn = getConn();
+			north_glass_buffer1 north_glass_buffer1s = new north_glass_buffer1();
+			String sql = "select * from north_glass_buffer1 where barcode=? or ordernumber=? or FrameBarcode=?";
+			ps = conn.prepareStatement(sql);
+			ps.setString(1, glassid);
+			ps.setString(2, orderid);
+			ps.setString(3, frameid);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				north_glass_buffer1s.setId(rs.getInt("Id"));
+				north_glass_buffer1s.setordernumber(rs.getString("ordernumber"));
+				north_glass_buffer1s.setlistnumber(rs.getString("listnumber"));
+				north_glass_buffer1s.setboxnumber(rs.getString("boxnumber"));
+				north_glass_buffer1s.setbarcode(rs.getString("barcode"));
+				north_glass_buffer1s.setglasslength(rs.getDouble("glasslength"));
+				north_glass_buffer1s.setglassheight(rs.getDouble("glassheight"));
+				north_glass_buffer1s.setglasslengthmm(rs.getDouble("glasslength_mm"));
+				north_glass_buffer1s.setglassheightmm(rs.getDouble("glassheight_mm"));
+				north_glass_buffer1s.setitemtype(rs.getString("itemtype"));
+				north_glass_buffer1s.setslotnumber(rs.getString("slotnumber"));
+				north_glass_buffer1s.setdatemodified(rs.getString("datemodified"));
+				north_glass_buffer1s.setdatecreated(rs.getString("datecreated"));
+				north_glass_buffer1s.setFrameBarcode(rs.getString("FrameBarcode"));
+			}
+			conn.close();
+			return north_glass_buffer1s;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	public north_glass_buffer1 SelectGlassByGlassIdOrderIdFrameIdouts(String glassid, String orderid, String frameid)
+			throws SQLException {
+		try {
+			Connection conn = getConn();
+			north_glass_buffer1 north_glass_buffer1s = new north_glass_buffer1();
+			String sql = "select * from north_glass_buffer1 where barcode=? or ordernumber=? or FrameBarcode=?";
+			ps = conn.prepareStatement(sql);
+			ps.setString(1, glassid);
+			ps.setString(2, orderid);
+			ps.setString(3, frameid);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				north_glass_buffer1s.setId(rs.getInt("Id"));
+				north_glass_buffer1s.setordernumber(rs.getString("ordernumber"));
+				north_glass_buffer1s.setlistnumber(rs.getString("listnumber"));
+				north_glass_buffer1s.setboxnumber(rs.getString("boxnumber"));
+				north_glass_buffer1s.setbarcode(rs.getString("barcode"));
+				north_glass_buffer1s.setglasslength(rs.getDouble("glasslength"));
+				north_glass_buffer1s.setglassheight(rs.getDouble("glassheight"));
+				north_glass_buffer1s.setglasslengthmm(rs.getDouble("glasslength_mm"));
+				north_glass_buffer1s.setglassheightmm(rs.getDouble("glassheight_mm"));
+				north_glass_buffer1s.setitemtype(rs.getString("itemtype"));
+				north_glass_buffer1s.setslotnumber(rs.getString("slotnumber"));
+				north_glass_buffer1s.setdatemodified(rs.getString("datemodified"));
+				north_glass_buffer1s.setdatecreated(rs.getString("datecreated"));
+				north_glass_buffer1s.setFrameBarcode(rs.getString("FrameBarcode"));
+			}
+			conn.close();
+			return north_glass_buffer1s;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	public north_glass_buffer1 SelectGlassByGlassIdOrderIdFrameIdplchold(String glassid, String orderid, String frameid)
+			throws SQLException {
+		try {
+			Connection conn = getConn();
+			north_glass_buffer1 north_glass_buffer1s = new north_glass_buffer1();
+			String sql = "select * from north_glass_buffer1 where barcode=? or ordernumber=? or FrameBarcode=?";
+			ps = conn.prepareStatement(sql);
+			ps.setString(1, glassid);
+			ps.setString(2, orderid);
+			ps.setString(3, frameid);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				north_glass_buffer1s.setId(rs.getInt("Id"));
+				north_glass_buffer1s.setordernumber(rs.getString("ordernumber"));
+				north_glass_buffer1s.setlistnumber(rs.getString("listnumber"));
+				north_glass_buffer1s.setboxnumber(rs.getString("boxnumber"));
+				north_glass_buffer1s.setbarcode(rs.getString("barcode"));
+				north_glass_buffer1s.setglasslength(rs.getDouble("glasslength"));
+				north_glass_buffer1s.setglassheight(rs.getDouble("glassheight"));
+				north_glass_buffer1s.setglasslengthmm(rs.getDouble("glasslength_mm"));
+				north_glass_buffer1s.setglassheightmm(rs.getDouble("glassheight_mm"));
+				north_glass_buffer1s.setitemtype(rs.getString("itemtype"));
+				north_glass_buffer1s.setslotnumber(rs.getString("slotnumber"));
+				north_glass_buffer1s.setdatemodified(rs.getString("datemodified"));
+				north_glass_buffer1s.setdatecreated(rs.getString("datecreated"));
+				north_glass_buffer1s.setFrameBarcode(rs.getString("FrameBarcode"));
+			}
+			conn.close();
+			return north_glass_buffer1s;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	// 鏍规嵁鐜荤拑id锛岃鍗昳d锛岄摑妗唅d鏌ヨ瀹㈡埛鐜荤拑淇℃伅
+	public Queue SelectGlassByGlassIdOrderIdFrameIdQueue(String glassid, String orderid, String frameid)
+			throws SQLException {
+		try {
+			Connection conn = getConn();
+			Queue queue = new Queue();
+			String sql = "select * from north_glass_buffer1 where barcode=? or ordernumber=? or FrameBarcode=?";
+			ps = conn.prepareStatement(sql);
+			ps.setString(1, glassid);
+			ps.setString(2, orderid);
+			ps.setString(3, frameid);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				queue.setid(rs.getInt("Id"));
+				queue.setorderId(rs.getString("ordernumber"));
+				queue.setlistId(rs.getString("listnumber"));
+				queue.setboxId(rs.getString("boxnumber"));
+				queue.setglassId(rs.getString("barcode"));
+				queue.setglasswidthmm(rs.getDouble("glasslength"));
+				queue.setglassheightmm(rs.getDouble("glassheight"));
+				queue.setglasswidth(rs.getDouble("glasslength_mm"));
+				queue.setglassheight(rs.getDouble("glassheight_mm"));
+				// queue.setitemtype(rs.getString("itemtype"));
+				// queue.setslotnumber(rs.getString("slotnumber"));
+				// queue.setdatemodified(rs.getString("datemodified"));
+				// queue.setdatecreated(rs.getString("datecreated"));
+				// queue.setFrameBarcode(rs.getString("FrameBarcode"));
+			}
+			conn.close();
+			return queue;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	// 鏍规嵁鐜荤拑id锛岃鍗昳d锛岄摑妗唅d鏌ヨ瀹㈡埛鐜荤拑淇℃伅
+	public List<north_glass_buffer1> SelectGlassByGlassIdOrderIdFrameIds(String glassid, String orderid, String frameid)
+			throws SQLException {
+		try {
+			Connection conn = getConn();
+			// north_glass_buffer1 glass=new north_glass_buffer1();
+			List<north_glass_buffer1> glass = new ArrayList<north_glass_buffer1>();
+			String sql = "select * from north_glass_buffer1 where position(? in barcode) and position(? in ordernumber) and position(? in FrameBarcode)";
+			ps = conn.prepareStatement(sql);
+			ps.setString(1, glassid);
+			ps.setString(2, orderid);
+			ps.setString(3, frameid);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				north_glass_buffer1 north_glass_buffer1s = new north_glass_buffer1();
+
+				north_glass_buffer1s.setId(rs.getInt("Id"));
+				north_glass_buffer1s.setordernumber(rs.getString("ordernumber"));
+				north_glass_buffer1s.setlistnumber(rs.getString("listnumber"));
+				north_glass_buffer1s.setboxnumber(rs.getString("boxnumber"));
+				north_glass_buffer1s.setbarcode(rs.getString("barcode"));
+				north_glass_buffer1s.setglasslength(rs.getDouble("glasslength"));
+				north_glass_buffer1s.setglassheight(rs.getDouble("glassheight"));
+				north_glass_buffer1s.setglasslengthmm(rs.getDouble("glasslength_mm"));
+				north_glass_buffer1s.setglassheightmm(rs.getDouble("glassheight_mm"));
+				north_glass_buffer1s.setitemtype(rs.getString("itemtype"));
+				north_glass_buffer1s.setslotnumber(rs.getString("slotnumber"));
+				north_glass_buffer1s.setdatemodified(rs.getString("datemodified"));
+				north_glass_buffer1s.setdatecreated(rs.getString("datecreated"));
+				north_glass_buffer1s.setFrameBarcode(rs.getString("FrameBarcode"));
+
+				glass.add(north_glass_buffer1s);
+
+			}
+			conn.close();
+			return glass;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	// 鏍规嵁閾濇id鏌ヨ瀹㈡埛鐜荤拑淇℃伅
+	public List<north_glass_buffer1> SelectGlassByGlassIdOrderIdFrameIdss(String frameid) throws SQLException {
+		try {
+			Connection conn = getConn();
+			// north_glass_buffer1 glass=new north_glass_buffer1();
+			List<north_glass_buffer1> glass = new ArrayList<north_glass_buffer1>();
+			String sql = "select * from north_glass_buffer1 where FrameBarcode=?";
+			ps = conn.prepareStatement(sql);
+			ps.setString(1, frameid);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				north_glass_buffer1 north_glass_buffer1s = new north_glass_buffer1();
+
+				north_glass_buffer1s.setId(rs.getInt("Id"));
+				north_glass_buffer1s.setordernumber(rs.getString("ordernumber"));
+				north_glass_buffer1s.setlistnumber(rs.getString("listnumber"));
+				north_glass_buffer1s.setboxnumber(rs.getString("boxnumber"));
+				north_glass_buffer1s.setbarcode(rs.getString("barcode"));
+				north_glass_buffer1s.setglasslength(rs.getDouble("glasslength"));
+				north_glass_buffer1s.setglassheight(rs.getDouble("glassheight"));
+				north_glass_buffer1s.setglasslengthmm(rs.getDouble("glasslength_mm"));
+				north_glass_buffer1s.setglassheightmm(rs.getDouble("glassheight_mm"));
+				north_glass_buffer1s.setitemtype(rs.getString("itemtype"));
+				north_glass_buffer1s.setslotnumber(rs.getString("slotnumber"));
+				north_glass_buffer1s.setdatemodified(rs.getString("datemodified"));
+				north_glass_buffer1s.setdatecreated(rs.getString("datecreated"));
+				north_glass_buffer1s.setFrameBarcode(rs.getString("FrameBarcode"));
+
+				glass.add(north_glass_buffer1s);
+
+			}
+			conn.close();
+			return glass;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	// 鏍规嵁閾濇id鏌ヨl閾濇鏄惁缈昏浆
+	public String SelectFlipByFrameBarcode(String frameBarcode) throws SQLException {
+		try {
+			Connection conn = getConn();
+			// north_glass_buffer1 glass=new north_glass_buffer1();
+			String flip = "";
+			String sql1 = "select * from north_glass_buffer1_frames where Barcode=? limit 1";
+			ps = conn.prepareStatement(sql1);
+			ps.setString(1, frameBarcode);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				flip = rs.getString("Flip");
+
+			}
+			conn.close();
+			return flip;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	// 鏍规嵁閾濇id鏌ヨ鏄惁閾濇鎽嗘斁
+	public String SelectPositionByFrameBarcode(String frameBarcode) throws SQLException {
+		try {
+			Connection conn = getConn();
+			// north_glass_buffer1 glass=new north_glass_buffer1();
+			String position = "";
+			String sql1 = "select * from north_glass_buffer1_frames where Barcode=? limit 1";
+			ps = conn.prepareStatement(sql1);
+			ps.setString(1, frameBarcode);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				position = rs.getString("flip");
+			}
+			conn.close();
+			return position;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	// 鏍规嵁閾濇id鏌ヨ閾濇瀹�
+	public String SelectFrameLengthByFrameBarcode(String frameBarcode) throws SQLException {
+		try {
+			Connection conn = getConn();
+			// north_glass_buffer1 glass=new north_glass_buffer1();
+			String position = "";
+			String sql1 = "select * from north_glass_buffer1_frames where Barcode=? limit 1";
+			ps = conn.prepareStatement(sql1);
+			ps.setString(1, frameBarcode);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				position = rs.getString("framelength");
+			}
+			conn.close();
+			return position;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	// 鏍规嵁閾濇id鏌ヨ閾濇楂�
+	public String SelectFrameHeightByFrameBarcode(String frameBarcode) throws SQLException {
+		try {
+			Connection conn = getConn();
+			// north_glass_buffer1 glass=new north_glass_buffer1();
+			String position = "";
+			String sql1 = "select * from north_glass_buffer1_frames where Barcode=? limit 1";
+			ps = conn.prepareStatement(sql1);
+			ps.setString(1, frameBarcode);
+			ResultSet rs = ps.executeQuery();
+			while (rs.next()) {
+				position = rs.getString("frameheight");
+			}
+			conn.close();
+			return position;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
 	/**
 	 * 1. 鍔犺浇椹卞姩
-	 * 2. 鑾峰彇杩炴帴	conn
+	 * 2. 鑾峰彇杩炴帴 conn
 	 * 3. 鍒涘缓璇彞 ps
 	 * 4. 鎵ц璇彞 rs
 	 * 5. 澶勭悊缁撴灉
 	 * 6. 鍥炴敹璧勬簮
 	 * 
 	 * 瀹炵幇CRUD
-	 * 	鏇存柊锛�
-	 * 		1澧炲姞
-	 * 		2鍒犻櫎
-	 * 		3淇敼
-	 *  鏌ヨ锛�
-	 *  	1. 鏌ヤ竴涓紝涓�涓璞�
-	 *  	2. 鏌ヤ竴缁勶紝鍋氭垚涓�涓璞″垪琛紝鏌ュ叏閮�
+	 * 鏇存柊锛�
+	 * 1澧炲姞
+	 * 2鍒犻櫎
+	 * 3淇敼
+	 * 鏌ヨ锛�
+	 * 1. 鏌ヤ竴涓紝涓�涓璞�
+	 * 2. 鏌ヤ竴缁勶紝鍋氭垚涓�涓璞″垪琛紝鏌ュ叏閮�
 	 */
 	public static Connection getConn() throws SQLException {
-		Connection conn = null;
-		conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/canadames?serverTimezone=GMT%2B8&characterEncoding=utf-8", "root", "beibo.123/");
-		return conn;
+		try {
+			Connection conn = null;
+			// conn =
+			// DriverManager.getConnection("jdbc:mysql://localhost:3306/canadames?serverTimezone=GMT%2B8&characterEncoding=utf-8",
+			// "root", "beibo.123/");
+			conn = DriverManager.getConnection(
+					"jdbc:mysql://192.168.102.9:3306/production?serverTimezone=GMT%2B8&characterEncoding=utf-8&useSSL=false",
+					"northglass", "n0rthgla55");
+			return conn;
+		} catch (Exception e) {
+			// TODO: handle exception
+			e.printStackTrace();
+			return null;
+		}
+
 	}
 
 	static {
@@ -67,6 +456,5 @@
 			e.printStackTrace();
 		}
 	}
-
 
 }

--
Gitblit v1.8.0