35 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Java
		
	
	
		
		
			
		
	
	
			35 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Java
		
	
	
| 
								 | 
							
								package hhwms;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import java.sql.DriverManager;
							 | 
						||
| 
								 | 
							
								import java.sql.ResultSet;
							 | 
						||
| 
								 | 
							
								import java.sql.SQLException;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import com.mysql.jdbc.Connection;
							 | 
						||
| 
								 | 
							
								import com.mysql.jdbc.Statement;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								public class demo {
							 | 
						||
| 
								 | 
							
								    public static void main(String[] args) throws ClassNotFoundException, SQLException {
							 | 
						||
| 
								 | 
							
								    	//1.注册数据库驱动
							 | 
						||
| 
								 | 
							
								    	Class.forName("com.mysql.jdbc.Driver");
							 | 
						||
| 
								 | 
							
								    	Connection conn= (Connection) DriverManager.getConnection("jdbc:mysql://47.100.54.81:53306/lptwms?useUnicode=true&characterEncoding=utf-8&useSSL=true","root","Youchain@56");
							 | 
						||
| 
								 | 
							
								        Statement stat=(Statement) conn.createStatement();
							 | 
						||
| 
								 | 
							
								        String sql=" select GROUP_CONCAT(a.ID) as pickIds ,count(a.ID),a.it "
							 | 
						||
| 
								 | 
							
								        		+ " from (select pt.ID,GROUP_CONCAT(i.ID) as 'it' from pick_ticket pt	"
							 | 
						||
| 
								 | 
							
								        		+ " left join pick_ticket_detail ptd on pt.ID=ptd.PICK_TICKET_ID	"
							 | 
						||
| 
								 | 
							
								        		+ " left join item i on i.ID=ptd.ITEM_ID	"
							 | 
						||
| 
								 | 
							
								        		+ " where i.ISBOM='T'	"
							 | 
						||
| 
								 | 
							
								        		+ " and pt.`STATUS`='OPEN'	"
							 | 
						||
| 
								 | 
							
								        		+ " GROUP BY pt.ID	"
							 | 
						||
| 
								 | 
							
								        		+ " ORDER BY i.ID ASC) as a	GROUP BY a.it ";
							 | 
						||
| 
								 | 
							
								        ResultSet rs=stat.executeQuery(sql);
							 | 
						||
| 
								 | 
							
								        while (rs.next()){
							 | 
						||
| 
								 | 
							
								            String id=rs.getString("pickIds");
							 | 
						||
| 
								 | 
							
								            System.out.println(id);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        rs.close();
							 | 
						||
| 
								 | 
							
								        stat.close();
							 | 
						||
| 
								 | 
							
								        conn.close();
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 |