Răsfoiți Sursa

first commit

xiongzhu 7 ani în urmă
părinte
comite
bfdbdc3e6a

+ 10 - 0
migrate.sql

@@ -0,0 +1,10 @@
+
+ALTER TABLE modelinfo ADD sort int DEFAULT 0 NULL;
+
+CREATE TABLE sharerecord
+(
+    id int PRIMARY KEY,
+    phone varchar(255),
+    code varchar(255)
+);
+ALTER TABLE sharerecord COMMENT = '分享记录';

+ 189 - 204
src/main/java/dbconnection/DbConnection.java

@@ -7,236 +7,221 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.sql.*;
 import javax.sql.rowset.CachedRowSet;
-import com.sun.rowset.CachedRowSetImpl;
-
-public class DbConnection{
-	
-	public Connection conn = null;
-	public String LastError;
-	
-	private java.text.SimpleDateFormat f = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-	
-	public static String getPara(String ParaName) 
-	{
-		String FileName="DBConfig.property";
-		Properties prop= new Properties();
-		try
-		{
-			InputStream is = DbConnection.class.getResourceAsStream(FileName);
-			prop.load(is);
-			if(is!=null) is.close();
-		}
-		catch(Exception e) {
-			return "Error!";
-		}
-		return prop.getProperty(ParaName);
-	}
-	
-	public static boolean isDebug(){
-		if (getPara("Debug").equals("true")){
-			return true;
-		}else{
-			return false;
-		}
-	}
-	
-	public Connection getConn(){
-		if (getPara("ConnectType").equals("jndi")){
-			return getConnByJndi();
-		}else{
-			return getConnByDriver();
-		}
-	}
-	
-	
-    public Connection getConnByJndi(){
-    	try{
-    		Context ctx=new InitialContext();
-		  	DataSource ds=(DataSource)ctx.lookup("java:comp/env/"+getPara("JndiName"));
-		  	conn = ds.getConnection();
-		}catch(Exception e){
-			e.printStackTrace();
-		}
+
+public class DbConnection {
+
+    public Connection conn = null;
+    public String     LastError;
+
+    private java.text.SimpleDateFormat f = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    public static String getPara(String ParaName) {
+        String     FileName = "DBConfig.properties";
+        Properties prop     = new Properties();
+        try {
+            InputStream is = DbConnection.class.getClassLoader().getResourceAsStream(FileName);
+            prop.load(is);
+            if (is != null) is.close();
+        } catch (Exception e) {
+            return "Error!";
+        }
+        return prop.getProperty(ParaName);
+    }
+
+    public static boolean isDebug() {
+        if (getPara("Debug").equals("true")) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public Connection getConn() {
+        if (getPara("ConnectType").equals("jndi")) {
+            return getConnByJndi();
+        } else {
+            return getConnByDriver();
+        }
+    }
+
+
+    public Connection getConnByJndi() {
+        try {
+            Context    ctx = new InitialContext();
+            DataSource ds  = (DataSource) ctx.lookup("java:comp/env/" + getPara("JndiName"));
+            conn = ds.getConnection();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         return conn;
     }
-	
-	
-	public Connection getConnByDriver() {
-		try{
-		    Class.forName("com.mysql.jdbc.Driver");
-			conn = DriverManager.getConnection(getPara("MySQLURL"));
-		}catch(Exception e){
-			e.printStackTrace();
-		}
-		return conn;
-	}
-
-    public CachedRowSet executeQuery(String sql){
-    	LastError = "";
-        ResultSet rs = null;
+
+
+    public Connection getConnByDriver() {
+        try {
+            Class.forName("com.mysql.jdbc.Driver");
+            conn = DriverManager.getConnection(getPara("MySQLURL"));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return conn;
+    }
+
+    public CachedRowSet executeQuery(String sql) {
+        LastError = "";
+        ResultSet    rs  = null;
         CachedRowSet crs = null;
-        try{
-        	if (conn==null||conn.isClosed()){
-        		getConn();
-        	}
+        try {
+            if (conn == null || conn.isClosed()) {
+                getConn();
+            }
             Statement stmt = conn.createStatement(1005, 1007);
-            if (isDebug()){
-            	System.out.println(f.format(new java.util.Date())+":"+sql);
+            if (isDebug()) {
+                System.out.println(f.format(new java.util.Date()) + ":" + sql);
             }
             rs = stmt.executeQuery(sql);
-            crs = new CachedRowSetImpl();
+            crs = new FixedCachedRowSetImpl();
             crs.populate(rs);
 
-        }catch(SQLException ex){
-        	LastError = ex.getMessage();
-        	System.out.println(f.format(new java.util.Date())+":"+sql);
-        	ex.printStackTrace();
-        }finally{
-        	try
-			{
-				conn.close();
-			}
-			catch (SQLException e)
-			{
-				e.printStackTrace();
-			}
+        } catch (SQLException ex) {
+            LastError = ex.getMessage();
+            System.out.println(f.format(new java.util.Date()) + ":" + sql);
+            ex.printStackTrace();
+        } finally {
+            try {
+                conn.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
         }
         return crs;
     }
-    
-    public int executeUpdate(String sql){
-    	LastError = "";
-    	if (sql==null || sql.trim().equals("")){
-    		return -1;
-    	}
-        Statement stmt = null;
-        int Number = -1;
-        try{
-        	if (conn==null||conn.isClosed()){
-        		getConn();
-        	}
+
+    public int executeUpdate(String sql) {
+        LastError = "";
+        if (sql == null || sql.trim().equals("")) {
+            return -1;
+        }
+        Statement stmt   = null;
+        int       Number = -1;
+        try {
+            if (conn == null || conn.isClosed()) {
+                getConn();
+            }
             stmt = conn.createStatement();
             Number = stmt.executeUpdate(sql);
             // update by gongbaolei for getGeneratedKeys
             // �õ�����ӻ��߸��µ����ID
-            if(Number > 0){
-	            ResultSet rs = stmt.getGeneratedKeys();
-	            while(rs.next()){
-	            	Number = rs.getInt(1);
-	            }
-	            if(rs!= null){
-	            	rs.close();
-	            	rs = null;
-	            }
-            }
-            if (isDebug()){
-            	System.out.println(f.format(new java.util.Date())+":"+sql);
-            }
-        }catch(Exception ex){
-        	LastError = ex.getMessage();
-        	System.out.println(f.format(new java.util.Date())+":"+sql);
-        	ex.printStackTrace();
-        }finally{
-        	try
-			{
-				conn.close();
-			}
-			catch (SQLException e)
-			{
-				e.printStackTrace();
-			}
+            if (Number > 0) {
+                ResultSet rs = stmt.getGeneratedKeys();
+                while (rs.next()) {
+                    Number = rs.getInt(1);
+                }
+                if (rs != null) {
+                    rs.close();
+                    rs = null;
+                }
+            }
+            if (isDebug()) {
+                System.out.println(f.format(new java.util.Date()) + ":" + sql);
+            }
+        } catch (Exception ex) {
+            LastError = ex.getMessage();
+            System.out.println(f.format(new java.util.Date()) + ":" + sql);
+            ex.printStackTrace();
+        } finally {
+            try {
+                conn.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
         }
         return Number;
     }
-    
-    public boolean executeUpdate(String sqls[]){
-    	LastError = "";
-        Statement stmt = null;
-        boolean result = false;
+
+    public boolean executeUpdate(String sqls[]) {
+        LastError = "";
+        Statement stmt   = null;
+        boolean   result = false;
         try {
-	    	if (conn==null||conn.isClosed()){
-	    		getConn();
-	    	}
-			conn.setAutoCommit(false);
-	        for(int i =0; i<sqls.length ; i++){
-	        	if(null != sqls[i]&& !sqls[i].equals("")){
-		            stmt = conn.createStatement();
-		            if (isDebug()){
-		            	System.out.println(f.format(new java.util.Date())+":"+sqls[i]);
-		            }
-		            stmt.executeUpdate(sqls[i]);
-		        }
-	        }
-        	result = true;
-		    conn.commit();
+            if (conn == null || conn.isClosed()) {
+                getConn();
+            }
+            conn.setAutoCommit(false);
+            for (int i = 0; i < sqls.length; i++) {
+                if (null != sqls[i] && !sqls[i].equals("")) {
+                    stmt = conn.createStatement();
+                    if (isDebug()) {
+                        System.out.println(f.format(new java.util.Date()) + ":" + sqls[i]);
+                    }
+                    stmt.executeUpdate(sqls[i]);
+                }
+            }
+            result = true;
+            conn.commit();
         } catch (SQLException e) {
-        	result = false;
-        	LastError = e.getMessage();
-			e.printStackTrace();
-			try{
-				conn.rollback();
-			}catch (SQLException e2) {
-			}
-		}
-        try{
-        	conn.setAutoCommit(true);
-		}catch (SQLException e2) {
-			e2.printStackTrace();
-		}finally{
-        	try
-			{
-				conn.close();
-			}
-			catch (SQLException e)
-			{
-				e.printStackTrace();
-			}
+            result = false;
+            LastError = e.getMessage();
+            e.printStackTrace();
+            try {
+                conn.rollback();
+            } catch (SQLException e2) {
+            }
+        }
+        try {
+            conn.setAutoCommit(true);
+        } catch (SQLException e2) {
+            e2.printStackTrace();
+        } finally {
+            try {
+                conn.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
         }
         return result;
     }
-    
-
-    public int executeParamUpdate(String sql,  String[] params){
-    	if (sql==null || sql.trim().equals("")){
-    		return -1;
-    	}
-    	PreparedStatement  pstmt = null;
-        int Number = -1;
-        try{
-        	if (conn==null||conn.isClosed()){
-        		getConn();
-        	}
-        	
+
+
+    public int executeParamUpdate(String sql, String[] params) {
+        if (sql == null || sql.trim().equals("")) {
+            return -1;
+        }
+        PreparedStatement pstmt  = null;
+        int               Number = -1;
+        try {
+            if (conn == null || conn.isClosed()) {
+                getConn();
+            }
+
             pstmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
-            for(int i = 0; i < params.length; i++){
-            	pstmt.setString(i+1, params[i]); 
+            for (int i = 0; i < params.length; i++) {
+                pstmt.setString(i + 1, params[i]);
             }
             Number = pstmt.executeUpdate();
-            if(Number > 0){
-	            ResultSet rs = pstmt.getGeneratedKeys();
-	            while(rs.next()){
-	            	Number = rs.getInt(1);
-	            }
-	            if(rs!= null){
-	            	rs.close();
-	            	rs = null;
-	            }
-            }            
-            if (isDebug()){
-            	System.out.println(f.format(new java.util.Date())+":"+sql);
-            }
-        }catch(Exception ex){
-        	System.out.println(f.format(new java.util.Date())+":"+sql);
-        	ex.printStackTrace();
-        }finally{
-        	try{
-				conn.close();
-			}
-			catch (SQLException e)
-			{
-				e.printStackTrace();
-			}
+            if (Number > 0) {
+                ResultSet rs = pstmt.getGeneratedKeys();
+                while (rs.next()) {
+                    Number = rs.getInt(1);
+                }
+                if (rs != null) {
+                    rs.close();
+                    rs = null;
+                }
+            }
+            if (isDebug()) {
+                System.out.println(f.format(new java.util.Date()) + ":" + sql);
+            }
+        } catch (Exception ex) {
+            System.out.println(f.format(new java.util.Date()) + ":" + sql);
+            ex.printStackTrace();
+        } finally {
+            try {
+                conn.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
         }
         return Number;
-    }    
+    }
 }

+ 314 - 0
src/main/java/dbconnection/FixedCachedRowSetImpl.java

@@ -0,0 +1,314 @@
+package dbconnection;
+
+import java.math.BigDecimal;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Ref;
+import java.sql.SQLException;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Hashtable;
+
+import javax.sql.rowset.RowSetMetaDataImpl;
+
+import com.sun.rowset.CachedRowSetImpl;
+
+public class FixedCachedRowSetImpl extends CachedRowSetImpl {
+
+    private static final long serialVersionUID = -9067504047398250113L;
+    private RowSetMetaDataImpl RowSetMD;
+
+    public FixedCachedRowSetImpl() throws SQLException {
+        super();
+    }
+
+    public FixedCachedRowSetImpl(Hashtable env) throws SQLException {
+        super(env);
+    }
+
+    private int getColIdxByName(String name) throws SQLException {
+        RowSetMD = (RowSetMetaDataImpl) this.getMetaData();
+        int cols = RowSetMD.getColumnCount();
+
+        for (int i = 1; i <= cols; ++i) {
+            String colName = RowSetMD.getColumnLabel(i);
+            if (colName != null) if (name.equalsIgnoreCase(colName))
+                return (i);
+            else
+                continue;
+        }
+        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalcolnm").toString());
+    }
+
+    @Override
+    public Collection<?> toCollection(String column) throws SQLException {
+        return toCollection(getColIdxByName(column));
+    }
+
+    @Override
+    public String getString(String columnName) throws SQLException {
+        return getString(getColIdxByName(columnName));
+    }
+
+    @Override
+    public boolean getBoolean(String columnName) throws SQLException {
+        return getBoolean(getColIdxByName(columnName));
+    }
+
+    @Override
+    public byte getByte(String columnName) throws SQLException {
+        return getByte(getColIdxByName(columnName));
+    }
+
+    @Override
+    public short getShort(String columnName) throws SQLException {
+        return getShort(getColIdxByName(columnName));
+    }
+
+    @Override
+    public int getInt(String columnName) throws SQLException {
+        return getInt(getColIdxByName(columnName));
+    }
+
+    @Override
+    public long getLong(String columnName) throws SQLException {
+        return getLong(getColIdxByName(columnName));
+    }
+
+    @Override
+    public float getFloat(String columnName) throws SQLException {
+        return getFloat(getColIdxByName(columnName));
+    }
+
+    @Override
+    public double getDouble(String columnName) throws SQLException {
+        return getDouble(getColIdxByName(columnName));
+    }
+
+    @Override
+    public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
+        return getBigDecimal(getColIdxByName(columnName), scale);
+    }
+
+    @Override
+    public byte[] getBytes(String columnName) throws SQLException {
+        return getBytes(getColIdxByName(columnName));
+    }
+
+    @Override
+    public java.sql.Date getDate(String columnName) throws SQLException {
+        return getDate(getColIdxByName(columnName));
+    }
+
+    @Override
+    public java.sql.Time getTime(String columnName) throws SQLException {
+        return getTime(getColIdxByName(columnName));
+    }
+
+    @Override
+    public java.sql.Timestamp getTimestamp(String columnName) throws SQLException {
+        return getTimestamp(getColIdxByName(columnName));
+    }
+
+    @Override
+    public java.io.InputStream getAsciiStream(String columnName) throws SQLException {
+        return getAsciiStream(getColIdxByName(columnName));
+
+    }
+
+    @Override
+    public java.io.InputStream getUnicodeStream(String columnName) throws SQLException {
+        return getUnicodeStream(getColIdxByName(columnName));
+    }
+
+    @Override
+    public java.io.InputStream getBinaryStream(String columnName) throws SQLException {
+        return getBinaryStream(getColIdxByName(columnName));
+    }
+
+    @Override
+    public Object getObject(String columnName) throws SQLException {
+        return getObject(getColIdxByName(columnName));
+    }
+
+    @Override
+    public int findColumn(String columnName) throws SQLException {
+        return getColIdxByName(columnName);
+    }
+
+    @Override
+    public java.io.Reader getCharacterStream(String columnName) throws SQLException {
+        return getCharacterStream(getColIdxByName(columnName));
+    }
+
+    @Override
+    public BigDecimal getBigDecimal(String columnName) throws SQLException {
+        return getBigDecimal(getColIdxByName(columnName));
+    }
+
+    @Override
+    public boolean columnUpdated(String columnName) throws SQLException {
+        return columnUpdated(getColIdxByName(columnName));
+    }
+
+    @Override
+    public void updateNull(String columnName) throws SQLException {
+        updateNull(getColIdxByName(columnName));
+    }
+
+    @Override
+    public void updateBoolean(String columnName, boolean x) throws SQLException {
+        updateBoolean(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateByte(String columnName, byte x) throws SQLException {
+        updateByte(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateShort(String columnName, short x) throws SQLException {
+        updateShort(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateInt(String columnName, int x) throws SQLException {
+        updateInt(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateLong(String columnName, long x) throws SQLException {
+        updateLong(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateFloat(String columnName, float x) throws SQLException {
+        updateFloat(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateDouble(String columnName, double x) throws SQLException {
+        updateDouble(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException {
+        updateBigDecimal(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateString(String columnName, String x) throws SQLException {
+        updateString(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateBytes(String columnName, byte x[]) throws SQLException {
+        updateBytes(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateDate(String columnName, java.sql.Date x) throws SQLException {
+        updateDate(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateTime(String columnName, java.sql.Time x) throws SQLException {
+        updateTime(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateTimestamp(String columnName, java.sql.Timestamp x) throws SQLException {
+        updateTimestamp(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public void updateAsciiStream(String columnName, java.io.InputStream x, int length) throws SQLException {
+        updateAsciiStream(getColIdxByName(columnName), x, length);
+    }
+
+    @Override
+    public void updateBinaryStream(String columnName, java.io.InputStream x, int length) throws SQLException {
+        updateBinaryStream(getColIdxByName(columnName), x, length);
+    }
+
+    @Override
+    public void updateCharacterStream(String columnName, java.io.Reader reader, int length) throws SQLException {
+        updateCharacterStream(getColIdxByName(columnName), reader, length);
+    }
+
+    @Override
+    public void updateObject(String columnName, Object x, int scale) throws SQLException {
+        updateObject(getColIdxByName(columnName), x, scale);
+    }
+
+    @Override
+    public void updateObject(String columnName, Object x) throws SQLException {
+        updateObject(getColIdxByName(columnName), x);
+    }
+
+    @Override
+    public Object getObject(String columnName, java.util.Map<String, Class<?>> map) throws SQLException {
+        return getObject(getColIdxByName(columnName), map);
+    }
+
+    @Override
+    public Ref getRef(String colName) throws SQLException {
+        return getRef(getColIdxByName(colName));
+    }
+
+    @Override
+    public Blob getBlob(String colName) throws SQLException {
+        return getBlob(getColIdxByName(colName));
+    }
+
+    @Override
+    public Clob getClob(String colName) throws SQLException {
+        return getClob(getColIdxByName(colName));
+    }
+
+    @Override
+    public Array getArray(String colName) throws SQLException {
+        return getArray(getColIdxByName(colName));
+    }
+
+    @Override
+    public java.sql.Date getDate(String columnName, Calendar cal) throws SQLException {
+        return getDate(getColIdxByName(columnName), cal);
+    }
+
+    @Override
+    public java.sql.Time getTime(String columnName, Calendar cal) throws SQLException {
+        return getTime(getColIdxByName(columnName), cal);
+    }
+
+    @Override
+    public java.sql.Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException {
+        return getTimestamp(getColIdxByName(columnName), cal);
+    }
+
+    @Override
+    public void updateRef(String columnName, java.sql.Ref ref) throws SQLException {
+        updateRef(getColIdxByName(columnName), ref);
+    }
+
+    @Override
+    public void updateClob(String columnName, Clob c) throws SQLException {
+        updateClob(getColIdxByName(columnName), c);
+    }
+
+    @Override
+    public void updateBlob(String columnName, Blob b) throws SQLException {
+        updateBlob(getColIdxByName(columnName), b);
+    }
+
+    @Override
+    public void updateArray(String columnName, Array a) throws SQLException {
+        updateArray(getColIdxByName(columnName), a);
+    }
+
+    @Override
+    public java.net.URL getURL(String columnName) throws SQLException {
+        return getURL(getColIdxByName(columnName));
+    }
+}

+ 1 - 1
src/main/java/system/DBRecordsPack.java

@@ -42,7 +42,7 @@ public class DBRecordsPack {
 			    		iPos = fieldValue.indexOf("00:00:00");
 			    		if (iPos>0) fieldValue = fieldValue.substring(0, iPos);
 			    	}
-			    	tmpJson.put( metaData.getColumnName(i).toLowerCase(), fieldValue );
+			    	tmpJson.put( metaData.getColumnLabel(i).toLowerCase(), fieldValue );
 			    }
 			    jsonList.add(tmpJson);
 			  }

+ 0 - 15
src/main/java/system/GetID.java

@@ -135,14 +135,6 @@ public class GetID
 		}
 	}
 	
-	  /**
-	 * Method replace.
-	 * ���ַ��ڵ�ָ���ַ��滻Ϊ�µ��ַ�
-	 * @param strSc Դ�ַ�
-	 * @param oldStr ���滻���ַ�
-	 * @param newStr �滻�ɵ��ַ�
-	 * @return String �������ַ�
-	 */
 	public static String replace(String strSc, String oldStr, String newStr) {
 		String ret = strSc + "";
 		if (ret != null && oldStr != null && newStr != null) {
@@ -163,13 +155,6 @@ public class GetID
 		return ret;
 	}
 	
-	 /**
-	 * Method countSeparator.
-	 * ����һ���ַ��зָ���ַ��ĸ���
-	 * @param strSc Դ�ַ�
-	 * @param separator �ָ���ַ�
-	 * @return int �ָ���ַ��ĸ���
-	 */
 	public static int countSeparator(String strSc, String separator) {
 		int count = 0;
 		if (strSc != null && separator != null) {

+ 2 - 2
src/main/java/system/Security.java

@@ -5,13 +5,13 @@ import java.sql.ResultSet;
 
 public class Security
 {
-	//新方法屏蔽原来的方面
+	//鏂版柟娉曞睆钄藉師鏉ョ殑鏂归潰
     public int popedom(String employeeid, String modelid)
     {
     	return 1;
     }
 	
-    //原来的方法
+    //鍘熸潵鐨勬柟娉�
     public int popedom(String employeeid, String modelid, String xx)
     {
         try

+ 21 - 37
src/main/java/util/Base64Image.java

@@ -9,61 +9,45 @@ import java.io.OutputStream;
 import sun.misc.BASE64Decoder;
 import sun.misc.BASE64Encoder;
 
-public class Base64Image 
-{
-    public static void main(String[] args)
-    {
+public class Base64Image {
+    public static void main(String[] args) {
         String strImg = GetImageStr();
-        GenerateImage(strImg,"");
+        GenerateImage(strImg, "");
     }
-    
-    public static String GetImageStr()
-    {//��ͼƬ�ļ�ת��Ϊ�ֽ������ַ����������Base64���봦��
-        String imgFile = "d:\\111.jpg";//�����ͼƬ
-        InputStream in = null;
-        byte[] data = null;
-        //��ȡͼƬ�ֽ�����
-        try 
-        {
-            in = new FileInputStream(imgFile);        
+
+    public static String GetImageStr() {
+        String      imgFile = "d:\\111.jpg";
+        InputStream in      = null;
+        byte[]      data    = null;
+        try {
+            in = new FileInputStream(imgFile);
             data = new byte[in.available()];
             in.read(data);
             in.close();
-        } 
-        catch (IOException e) 
-        {
+        } catch (IOException e) {
             e.printStackTrace();
         }
-        //���ֽ�����Base64����
         BASE64Encoder encoder = new BASE64Encoder();
-        return encoder.encode(data);//����Base64�������ֽ������ַ�
+        return encoder.encode(data);
     }
-    
-    public static boolean GenerateImage(String imgStr,String savePath)
-    {//���ֽ������ַ����Base64���벢���ͼƬ
-        if (imgStr == null) //ͼ�����Ϊ��
+
+    public static boolean GenerateImage(String imgStr, String savePath) {
+        if (imgStr == null)
             return false;
         BASE64Decoder decoder = new BASE64Decoder();
-        try 
-        {
-            //Base64����
+        try {
             byte[] b = decoder.decodeBuffer(imgStr);
-            for(int i=0;i<b.length;++i)
-            {
-                if(b[i]<0)
-                {//�����쳣���
-                    b[i]+=256;
+            for (int i = 0; i < b.length; ++i) {
+                if (b[i] < 0) {
+                    b[i] += 256;
                 }
             }
-            //���jpegͼƬ
-            OutputStream out = new FileOutputStream(savePath);    
+            OutputStream out = new FileOutputStream(savePath);
             out.write(b);
             out.flush();
             out.close();
             return true;
-        } 
-        catch (Exception e) 
-        {
+        } catch (Exception e) {
             return false;
         }
     }

+ 89 - 122
src/main/java/util/CommentUtils.java

@@ -13,42 +13,36 @@ import java.util.Map.Entry;
 
 import javax.servlet.http.HttpServletRequest;
 
-public class CommentUtils
-{
-   
-    
-    public static String ratioTransform(double money) {  
-        BigDecimal moneyDev = new BigDecimal(money).setScale(2,  
-                RoundingMode.HALF_UP);  
-  
-        return moneyDev.toString();  
-    }  
+public class CommentUtils {
+
+
+    public static String ratioTransform(double money) {
+        BigDecimal moneyDev = new BigDecimal(money).setScale(2,
+                                                             RoundingMode.HALF_UP);
+
+        return moneyDev.toString();
+    }
+
     @SuppressWarnings("unchecked")
-    public static Map<String, Object> requestToHashMap(HttpServletRequest request)
-    {
-        
+    public static Map<String, Object> requestToHashMap(HttpServletRequest request) {
+
         // String agent = request.getParameter("agent");
-        
-         String agent = request.getHeader("user-agent");
-         
-         Map<String, String[]> map = request.getParameterMap();
-        
-        Iterator<Entry<String,  String[]>> iterator = map.entrySet().iterator();
-        Map<String, Object> map_params = new HashMap<String, Object>();
-        while (iterator.hasNext())
-        {
-            Entry<String,  String[]> entry = iterator.next();
-            String key = entry.getKey();
-            String value = entry.getValue()[0];
+
+        String agent = request.getHeader("user-agent");
+
+        Map<String, String[]> map = request.getParameterMap();
+
+        Iterator<Entry<String, String[]>> iterator   = map.entrySet().iterator();
+        Map<String, Object>               map_params = new HashMap<>();
+        while (iterator.hasNext()) {
+            Entry<String, String[]> entry = iterator.next();
+            String                  key   = entry.getKey();
+            String                  value = entry.getValue()[0];
             //StringUtils.isNotEmpty(agent) && 
-            if(agent!=null &&agent.equals("android"))
-            {
-                
-            }
-            else
-            {
-                if (value != null)
-                {
+            if (agent != null && agent.equals("android")) {
+
+            } else {
+                if (value != null) {
                     /*try
                     {
                         value = new String(value.getBytes("ISO-8859-1"), "utf-8");
@@ -59,152 +53,125 @@ public class CommentUtils
                     }*/
                 }
             }
-           
+
             map_params.put(key.toLowerCase(), value);
-            
+
         }
-        if (map != null)
-        {
+        if (map != null) {
             printMap(map);
         }
 
         return map_params;
-        
+
     }
-    
+
     /**
-     * 
      * �?�? Copyright udit<br>
      * �?�? 方法描述<br>
      * �?�?�? 曾宝 zbmax001@126.com<br>
      * 创建时间:2015-11-2<br>
      * 版本号: 1.0 <br>
      */
-    public static String getRandomNumFive()
-    {
-        String base = "0123456789";
-        int base_length = base.length();
-        StringBuffer sb = new StringBuffer(6);
-        for (int i = 0; i < 6; i++)
-        {
+    public static String getRandomNumFive() {
+        String       base        = "0123456789";
+        int          base_length = base.length();
+        StringBuffer sb          = new StringBuffer(6);
+        for (int i = 0; i < 6; i++) {
             sb.append(base.charAt(new Random().nextInt(base_length)));
         }
         return sb.toString();
     }
-    
+
     /**
      * 打印参数
-     * 
+     *
      * @param map
      */
-    public static void printMap(Map<String,  String[]> map)
-    {
-        if (map == null)
-        {
+    public static void printMap(Map<String, String[]> map) {
+        if (map == null) {
             throw new RuntimeException("printParament map is null");
         }
-        
-        Iterator<Entry<String,  String[]>> iterator = map.entrySet().iterator();
-        while (iterator.hasNext())
-        {
-            Entry<String,  String[]> entry = iterator.next();
-            String key = entry.getKey();
-            Object value = entry.getValue();
-            if (value instanceof Object[])
-            {
-              //  System.out.println("key:" + key);
+
+        Iterator<Entry<String, String[]>> iterator = map.entrySet().iterator();
+        while (iterator.hasNext()) {
+            Entry<String, String[]> entry = iterator.next();
+            String                  key   = entry.getKey();
+            Object                  value = entry.getValue();
+            if (value != null) {
+                //  System.out.println("key:" + key);
                 printArray(value);
-            }
-            else
-            {
-               // System.out.println("key:" + key + "  value:" + value);
+            } else {
+                // System.out.println("key:" + key + "  value:" + value);
             }
         }
-        
+
     }
-    
+
     /**
      * 打印数组
-     * 
+     *
      * @param value
      */
-    private static void printArray(Object value)
-    {
-        
-        if (value == null)
-        {
+    private static void printArray(Object value) {
+
+        if (value == null) {
             throw new RuntimeException("printArray value is null");
         }
-        if (value instanceof String[])
-        {
-            for (String s : (String[])value)
-            {
-               // System.out.println("s:" + s);
+        if (value instanceof String[]) {
+            for (String s : (String[]) value) {
+                // System.out.println("s:" + s);
             }
         }
     }
-    
-    public static <T> void printList_Bean(List<T> mlist)
-    {
-        if (mlist == null)
-        {
+
+    public static <T> void printList_Bean(List<T> mlist) {
+        if (mlist == null) {
             throw new RuntimeException("printList_Bean list is null");
         }
-        for (int i = 0; mlist != null && i < mlist.size(); i++)
-        {
+        for (int i = 0; mlist != null && i < mlist.size(); i++) {
             T t = mlist.get(i);
-            
+
             printBean(t);
         }
-        
+
     }
-    
-    public static <T> void printBean(T t)
-    {
-        if (t == null)
-        {
+
+    public static <T> void printBean(T t) {
+        if (t == null) {
             throw new RuntimeException("printBean t is null");
         }
         Class cls_t = t.getClass();
-        
+
         Field[] fs = cls_t.getDeclaredFields();
-        
-        for (int j = 0; fs != null && j < fs.length; j++)
-        {
+
+        for (int j = 0; fs != null && j < fs.length; j++) {
             Field field = fs[j];
             field.setAccessible(true);
-            try
-            {
+            try {
                 Object obj_field = field.get(t);
-                
+
                 String name = field.getName();
-             //   System.out.println("name:" + name + "  value:" + (obj_field == null ? "null" : obj_field));
-                
-            }
-            catch (IllegalArgumentException e)
-            {
+                //   System.out.println("name:" + name + "  value:" + (obj_field == null ? "null" : obj_field));
+
+            } catch (IllegalArgumentException e) {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
-            }
-            catch (IllegalAccessException e)
-            {
+            } catch (IllegalAccessException e) {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
-            
+
         }
-        
+
+    }
+
+
+    public static boolean isEmpty(List l) {
+        return (l == null) || (l.isEmpty());
+    }
+
+    public static boolean isEmpty(Object[] objs) {
+        return (objs == null) || (objs.length == 0);
     }
 
-  
-    public static boolean isEmpty(List l)                                              
-    {                                                                                  
-      return (l == null) || (l.isEmpty());                                             
-    }                                                                                  
-                                                                                       
-    public static boolean isEmpty(Object[] objs)                                       
-    {                                                                                  
-      return (objs == null) || (objs.length == 0);                                     
-    }    
-    
 }

+ 8 - 8
src/main/resources/DBConfig.property → src/main/resources/DBConfig.properties

@@ -1,8 +1,8 @@
-Debug=false
-
-#driver| jndi
-ConnectType=driver
-MySQLURL=jdbc:mysql://118.190.49.85:3306/thmodeltest?user=root&password=qscm123!@#&useUnicode=true&characterEncoding=utf-8
-
-
-
+Debug=false
+
+#driver| jndi
+ConnectType=driver
+MySQLURL=jdbc:mysql://118.190.49.85:3306/thmodeltest?user=root&password=qscm123!@#&useUnicode=true&characterEncoding=utf-8
+
+
+

+ 1 - 1
src/main/webapp/css/style.css

@@ -93,7 +93,7 @@ textarea{height:80px; background:none;}
 .kv-item .choose .text{float:left;padding-left:5px;*padding-left:5px;white-space:nowrap;}
 .kv-item .choose input[type=radio],.kv-item .choose input[type=checkbox]{position:relative;*position:static;float:left;margin-right:-16px;}
 /*下拉框样式*/
-.iselect-wrapper{position:relative;width:370px;height:28px;padding:0 20px 0 5px;line-height:28px;border-width:1px;border-style:solid;border-left-color:#c5c5c5;border-top-color:#c5c5c5;border-right-color:#e0e0e0;border-bottom-color:#e0e0e0;background:url(../img/skin_/select_normal.png) no-repeat right center #fff;}
+.iselect-wrapper{display: inline-block;position:relative;width:370px;height:28px;padding:0 20px 0 5px;line-height:28px;border-width:1px;border-style:solid;border-left-color:#c5c5c5;border-top-color:#c5c5c5;border-right-color:#e0e0e0;border-bottom-color:#e0e0e0;background:url(../img/skin_/select_normal.png) no-repeat right center #fff;}
 .iselect-wrapper:hover{background:url(../img/skin_/select_hover.png) no-repeat right center #fff;}
 .iselect-wrapper .iselect{position:absolute;top:-2px;*top:3px;left:-1px;opacity:0;filter:alpha(opacity=0);outline:0 none;z-index:2;}
 /*一段区域数值输入(比如时间段,数字段等)*/

+ 80 - 84
src/main/webapp/login.jsp

@@ -1,10 +1,10 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
-<jsp:useBean id="db" class="dbconnection.DbConnection" scope="page" />
+<jsp:useBean id="db" class="dbconnection.DbConnection" scope="page"/>
 <%@ page language="java" import="java.sql.*,util.*" %>
-<%@ page contentType="text/html;charset=utf-8"%>
+<%@ page contentType="text/html;charset=utf-8" %>
 <%@ page language="java" import="biz.*" %>
-<% 
+    <%
 	String path = request.getContextPath();
 	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
     javax.sql.rowset.CachedRowSet rs = null;
@@ -75,102 +75,98 @@
 	}
 
 %>
-	
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
+>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta http-equiv="X-UA-Compatible" content="IE=emulateIE9" />
-<link rel="stylesheet" type="text/css" href="css/style.css" />
-<link rel="stylesheet" type="text/css" href="css/skin_/login.css" />
-<script type="text/javascript" src="js/jquery.js"></script>
-<script type="text/javascript" src="js/jquery.select.js"></script>
-<script type="text/javascript" src="js/udit.js"></script>
-<title>千模网系统用户登录</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE9"/>
+    <link rel="stylesheet" type="text/css" href="css/style.css"/>
+    <link rel="stylesheet" type="text/css" href="css/skin_/login.css"/>
+    <script type="text/javascript" src="js/jquery.js"></script>
+    <script type="text/javascript" src="js/jquery.select.js"></script>
+    <script type="text/javascript" src="js/udit.js"></script>
+    <title>千模网系统用户登录</title>
 </head>
 
 <body>
 <div id="container">
     <form name="loginForm" method="post">
-	    <div id="bd">
-		    	<div id="main">
-		        	<div class="login-box">
-		                <div id="logo"></div>
-		                <h1></h1>
-		                <div class="input username">
-		                    <label for="userName">用户名</label>
-		                    <span></span>
-		                    <input type="text" id="username" name="username" value="<%=username%>"  />
-		                </div>
-		                <div class="input psw" id="psw">
-		                    <label for="password">密&nbsp;&nbsp;&nbsp;&nbsp;码</label>
-		                    <span></span>
-		                    <input type="password" id="password" name="userPwd"/>
-		                </div>
-		          </div>
-		          <div id="btn" class="loginButton">
-		            <input name="button" type="button" class="button" value="登录" onclick="javascript:loginclick();"  />
-		          </div>
-		      </div>
-	    </div>
-   </form> 
+        <div id="bd">
+            <div id="main">
+                <div class="login-box">
+                    <div id="logo"></div>
+                    <h1></h1>
+                    <div class="input username">
+                        <label for="userName">用户名</label>
+                        <span></span>
+                        <input type="text" id="username" name="username" value="<%=username%>"/>
+                    </div>
+                    <div class="input psw" id="psw">
+                        <label for="password">密&nbsp;&nbsp;&nbsp;&nbsp;码</label>
+                        <span></span>
+                        <input type="password" id="password" name="userPwd"/>
+                    </div>
+                </div>
+                <div id="btn" class="loginButton">
+                    <input name="button" type="button" class="button" value="登录" onclick="javascript:loginclick();"/>
+                </div>
+            </div>
+        </div>
+    </form>
 </div>
 </body>
 <script type="text/javascript">
 
-	var height = $(window).height() > 445 ? $(window).height() : 445;
-	$("#container").height(height);
-	var bdheight = ($(window).height() - $('#bd').height()) / 2 - 20;
-	$('#bd').css('padding-top', bdheight);
-	$(window).resize(function(e) {
+    var height = $(window).height() > 445 ? $(window).height() : 445;
+    $("#container").height(height);
+    var bdheight = ($(window).height() - $('#bd').height()) / 2 - 20;
+    $('#bd').css('padding-top', bdheight);
+    $(window).resize(function (e) {
         var height = $(window).height() > 445 ? $(window).height() : 445;
-		$("#container").height(height);
-		var bdheight = ($(window).height() - $('#bd').height()) / 2 - 20;
-		$('#bd').css('padding-top', bdheight);
+        $("#container").height(height);
+        var bdheight = ($(window).height() - $('#bd').height()) / 2 - 20;
+        $('#bd').css('padding-top', bdheight);
     });
-    
-	$('select').select();
-	$("#username").val( getCookie("username") );
-	
-	$('#password').bind('keypress',function(event)
-	{ 
-         if(event.keyCode == 13)      
-             loginclick();  
+
+    $('select').select();
+    $("#username").val(getCookie("username"));
+
+    $('#password').bind('keypress', function (event) {
+        if (event.keyCode == 13)
+            loginclick();
     });
-    	
-	function loginclick() 
-	{
-	    username = loginForm.username.value;
-	    userPwd = loginForm.userPwd.value;
-	    if ( username==""){
-	        $("#username").focus();
-	        alert("请输入用户名!");
-	        return false;
-	    }
-	    if ( userPwd==""){
-	        $("#password").focus();
-	        alert("请输入密码!");
-	        return false;
-	    }
-       
+
+    function loginclick() {
+        username = loginForm.username.value;
+        userPwd = loginForm.userPwd.value;
+        if (username == "") {
+            $("#username").focus();
+            alert("请输入用户名!");
+            return false;
+        }
+        if (userPwd == "") {
+            $("#password").focus();
+            alert("请输入密码!");
+            return false;
+        }
+
         $.post("<%=basePath%>login.jsp?operator=dologin",
-    		{
-    		  username: username,
-    		  userPwd: userPwd
-    		},
-           function(data,status)
-           {
-             if (data == "success")
-             {
-               setCookie("username", username, 7);
-               window.location.href = "main.jsp";
-             }
-             else 
-             {
-              	alert(data);
-             }
-           }     
-          );  
+            {
+                username: username,
+                userPwd: userPwd
+            },
+            function (data, status) {
+                if (data == "success") {
+                    setCookie("username", username, 7);
+                    window.location.href = "main.jsp";
+                }
+                else {
+                    alert(data);
+                }
+            }
+        );
     };
 </script>
 </html>

+ 249 - 260
src/main/webapp/member/query_jinjiren.jsp

@@ -1,123 +1,117 @@
 <%@ page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
-<%request.setCharacterEncoding("utf-8");%>  
+<%request.setCharacterEncoding("utf-8");%>
 <%@ page language="java" import="java.sql.*,java.util.Arrays" %>
-<%@ page language="java" import="java.util.*, util.*"  %>
-<%@ page language="java" import="system.*"  %>
-<%@ page language="java" import="util.*"  %>
+<%@ page language="java" import="java.util.*, util.*" %>
+<%@ page language="java" import="system.*" %>
+<%@ page language="java" import="util.*" %>
 <%@ page language="java" import="biz.*" %>
-<%@ page language="java" import="net.sf.json.JSONObject"  %>
-<jsp:useBean id="db" class="dbconnection.DbConnection" scope="page" />
+<%@ page language="java" import="net.sf.json.JSONObject" %>
+<jsp:useBean id="db" class="dbconnection.DbConnection" scope="page"/>
 <%
-  String path = request.getContextPath();
-  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
-  String Sess_BrokerPK = ExtendString.getDBStr( (String)session.getAttribute("BrokerPK") );
-  String userpk   = ExtendString.getDBStr( (String)session.getAttribute("userpk"));
-  String username = ExtendString.getDBStr( (String)session.getAttribute("username"));
-  String MembType = ExtendString.getDBStr( (String)session.getAttribute("MembType")); 
-  String IsAdmin  = ExtendString.getDBStr( (String)session.getAttribute("IsAdmin"));
-  String sess_MemberPK= ExtendString.getDBStr( (String)session.getAttribute("MemberPK"));
-  String sess_JiGouPK = ExtendString.getDBStr( (String)session.getAttribute("JiGouPK"));
-	
-  int items_per_page = 10;
-  javax.sql.rowset.CachedRowSet rs = null;
-  String operator = ExtendString.getDBStr( request.getParameter("operator") );
-  String superpk =  ExtendString.getDBStr( request.getParameter("superpk") ); //机构BrokerInfor.pk
-  String sql;
-  int rownum =0;
-  if (superpk.equals("")) superpk = "-1";
-  if (sess_JiGouPK.length()==0) sess_JiGouPK = "-1";
-  out.clear();
-  if (operator.equals("query") )
-  {
-    int PageIndex = Integer.parseInt( request.getParameter("PageIndex") );
-    String keyword = ExtendString.getDBStr( request.getParameter("keyword") );
-    
-    String BaseSQL = "select a.pk as brokepk, a.MemberPK, b.Tel, a.Name, a.addr, a.intro, a.linkMan, "+
-        			 "		 a.IsAdmin, a.Auth, b.MembType, b.Area, a.superPK, C.Name as AreaName, b.Phone, "+
-        			 "       d.Name as jigouname, b.qrcode, "+
-        			 "       CAST(FORMAT(a.ratio_V,0) as char) as ratio_V, "+
-        			 "       CAST(FORMAT(a.ratio_S,0) as char) as ratio_S, "+
-        			 "       CAST(FORMAT(a.ratio_L,0) as char) as ratio_L, "+
-        			 "       CAST(FORMAT(a.ratio_R,0) as char) as ratio_R, "+
-        			 "       DATE_FORMAT(b.MDate,'%Y-%m-%d %H:%i:%s') as MDate, "+
-        			 "       (Select count(*) From ModelInfo X, memberinfo Y where X.BrokePK = A.PK and X.memberpk=Y.PK and IfNull(Y.identify,'')<>'删除' ) as ModelCount "+        			 
-        			 "from BrokerInfor a inner Join MemberInfo b on a.MemberPK = b.PK  "+
-             		 "	   Left Join (select PK, Name from datatypeinfo where typeName ='地区') C on b.Area = C.PK "+
-             		 "     Left Join BrokerInfor d on a.superPK = d.pk "+
-        			 "where b.MembType = "+thmodel.MEMTYPE_JinJiRen+"  ";
-    //平台帐号可以查询所有经纪人,其它只能查看本机构(+下属机构)的经纪人
-    if (MembType.equals( thmodel.MEMTYPE_PingTai ) )
-    {
-    	//无需添加条件
-    }
-    else if ( MembType.equals( thmodel.MEMTYPE_JiGou) || MembType.equals( thmodel.MEMTYPE_JinJiRen) )
-    	BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s or a.superPK=%s ",sess_JiGouPK, sess_JiGouPK );
-    else //应该不会发生
-    	BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s ",Sess_BrokerPK );
-    
-	if (keyword.length()>0)
-	{
-		BaseSQL += String.format(" and (b.Tel like '%%%s%%' or a.Name like '%%%s%%' or  d.Name like '%%%s%%') ",
-								keyword, keyword, keyword );
-	}
-    BaseSQL = BaseSQL + "Order by b.MDate Desc ";
-             
-    if (PageIndex == -1)
-      sql =BaseSQL+"  LIMIT 0, " + String.valueOf(items_per_page);
-    else
-      sql = BaseSQL+" LIMIT " +String.valueOf(items_per_page * PageIndex )
-             +","+String.valueOf(items_per_page);
- 
-    List<JSONObject> jsonList = DBRecordsPack.Pack( db, sql );
-    if (PageIndex == -1)
-    {
-      rs = db.executeQuery("Select Count(*) C from ("+BaseSQL+") as t_cc ");
-      if ( (rs!=null) && rs.next() )
-      {
-        JSONObject jsonObj =  new JSONObject();
-  	    jsonObj.put("result","CachedRowSet");
-	    jsonObj.put("recordcount", rs.getInt(1) );
-	    jsonObj.put("pageindex", 0);
-	    jsonList.add( jsonObj );
-	  }
-    }
+    String path = request.getContextPath();
+    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
+    String Sess_BrokerPK = ExtendString.getDBStr((String) session.getAttribute("BrokerPK"));
+    String userpk = ExtendString.getDBStr((String) session.getAttribute("userpk"));
+    String username = ExtendString.getDBStr((String) session.getAttribute("username"));
+    String MembType = ExtendString.getDBStr((String) session.getAttribute("MembType"));
+    String IsAdmin = ExtendString.getDBStr((String) session.getAttribute("IsAdmin"));
+    String sess_MemberPK = ExtendString.getDBStr((String) session.getAttribute("MemberPK"));
+    String sess_JiGouPK = ExtendString.getDBStr((String) session.getAttribute("JiGouPK"));
+
+    int items_per_page = 10;
+    javax.sql.rowset.CachedRowSet rs = null;
+    String operator = ExtendString.getDBStr(request.getParameter("operator"));
+    String superpk = ExtendString.getDBStr(request.getParameter("superpk")); //机构BrokerInfor.pk
+    String sql;
+    int rownum = 0;
+    if (superpk.equals("")) superpk = "-1";
+    if (sess_JiGouPK.length() == 0) sess_JiGouPK = "-1";
     out.clear();
-    out.print(jsonList);
-    return;
-  }
-  
+    if (operator.equals("query")) {
+        int    PageIndex = Integer.parseInt(request.getParameter("PageIndex"));
+        String keyword   = ExtendString.getDBStr(request.getParameter("keyword"));
+
+        String BaseSQL = "select a.pk as brokepk, a.MemberPK, b.Tel, a.Name, a.addr, a.intro, a.linkMan, " +
+                "		 a.IsAdmin, a.Auth, b.MembType, b.Area, a.superPK, C.Name as AreaName, b.Phone, " +
+                "       d.Name as jigouname, b.qrcode, " +
+                "       CAST(FORMAT(a.ratio_V,0) as char) as ratio_V, " +
+                "       CAST(FORMAT(a.ratio_S,0) as char) as ratio_S, " +
+                "       CAST(FORMAT(a.ratio_L,0) as char) as ratio_L, " +
+                "       CAST(FORMAT(a.ratio_R,0) as char) as ratio_R, " +
+                "       DATE_FORMAT(b.MDate,'%Y-%m-%d %H:%i:%s') as MDate, " +
+                "       (Select count(*) From ModelInfo X, memberinfo Y where X.BrokePK = A.PK and X.memberpk=Y.PK and IfNull(Y.identify,'')<>'删除' ) as ModelCount " +
+                "from BrokerInfor a inner Join MemberInfo b on a.MemberPK = b.PK  " +
+                "	   Left Join (select PK, Name from datatypeinfo where typeName ='地区') C on b.Area = C.PK " +
+                "     Left Join BrokerInfor d on a.superPK = d.pk " +
+                "where b.MembType = " + thmodel.MEMTYPE_JinJiRen + "  ";
+        //平台帐号可以查询所有经纪人,其它只能查看本机构(+下属机构)的经纪人
+        if (MembType.equals(thmodel.MEMTYPE_PingTai)) {
+            //无需添加条件
+        } else if (MembType.equals(thmodel.MEMTYPE_JiGou) || MembType.equals(thmodel.MEMTYPE_JinJiRen))
+            BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s or a.superPK=%s ", sess_JiGouPK, sess_JiGouPK);
+        else //应该不会发生
+            BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s ", Sess_BrokerPK);
+
+        if (keyword.length() > 0) {
+            BaseSQL += String.format(" and (b.Tel like '%%%s%%' or a.Name like '%%%s%%' or  d.Name like '%%%s%%') ",
+                                     keyword, keyword, keyword);
+        }
+        BaseSQL = BaseSQL + "Order by b.MDate Desc ";
+
+        if (PageIndex == -1)
+            sql = BaseSQL + "  LIMIT 0, " + String.valueOf(items_per_page);
+        else
+            sql = BaseSQL + " LIMIT " + String.valueOf(items_per_page * PageIndex)
+                    + "," + String.valueOf(items_per_page);
+
+        List<JSONObject> jsonList = DBRecordsPack.Pack(db, sql);
+        if (PageIndex == -1) {
+            rs = db.executeQuery("Select Count(*) C from (" + BaseSQL + ") as t_cc ");
+            if ((rs != null) && rs.next()) {
+                JSONObject jsonObj = new JSONObject();
+                jsonObj.put("result", "CachedRowSet");
+                jsonObj.put("recordcount", rs.getInt(1));
+                jsonObj.put("pageindex", 0);
+                jsonList.add(jsonObj);
+            }
+        }
+        out.clear();
+        out.print(jsonList);
+        return;
+    }
+
 %>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-<base href="<%=basePath %>"/>
-<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css" />
-<link rel="stylesheet" type="text/css" href="<%=basePath%>css/WdatePicker.css" />
-<link rel="stylesheet" type="text/css" href="<%=basePath%>css/skin_/table.css" />
-<link rel="stylesheet" type="text/css" href="<%=basePath%>css/jquery.grid.css" />
-<title>经纪人查询</title>
+    <base href="<%=basePath %>"/>
+    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7"/>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css"/>
+    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/WdatePicker.css"/>
+    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/skin_/table.css"/>
+    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/jquery.grid.css"/>
+    <title>经纪人查询</title>
 </head>
 <body>
 <div id="container">
-	<div id="hd"></div>
+    <div id="hd"></div>
     <div id="bd">
-    	<div id="main">
-        	<div class="search-box ue-clear">
-            	<div class="search-area">
+        <div id="main">
+            <div class="search-box ue-clear">
+                <div class="search-area">
                     <div class="kv-item ue-clear">
                         <label>关键字:</label>
-						<span></span>
-						<input type="text" name="keyword" style="width:200px" placeholder="关键字" />
+                        <span></span>
+                        <input type="text" name="keyword" style="width:200px" placeholder="关键字"/>
                     </div>
                 </div>
                 <div class="search-button">
-				    <span></span>
-                	<input class="button" id="button" type="button" value="搜索一下" onClick="ButtonClick();" />
+                    <span></span>
+                    <input class="button" id="button" type="button" value="搜索一下" onClick="ButtonClick();"/>
                 </div>
-             </div>     	
+            </div>
             <div class="table">
                 <div class="grid"></div>
                 <div class="pagination"></div>
@@ -137,174 +131,169 @@
 <script type="text/javascript" src="<%=basePath%>js/zDrag.js"></script>
 <script type="text/javascript" src="<%=basePath%>js/zDialog.js"></script>
 <script type="text/javascript">
-	$('select').select();
-	var head = [
-			{
-				label:'机构',
-				width: 120,
-				name:'jigouname'	
-			},
-			{
-				label:'帐号',
-				width: 110,
-				name:'Tel'	
-			},
-			{
-				label:'名称',
-				width: 90,
-				name:'Name'	
-			},
-			{
-				label:'电话',
-				width: 110,
-				name:'Phone'	
-			},
-			{
-				label:'视频分成(%)',
-				width: 50,
-				name:'ratio_V'	
-			},
-			{
-				label:'人才服务分成(%)',
-				width: 50,
-				name:'ratio_S'	
-			},
-			{
-				label:'队长分成(%)',
-				width: 80,
-				name:'ratio_L'	
-			},
-			{
-				label:'红包分成(%)',
-				width: 80,
-				name:'ratio_R'	
-			},
-			{
-				label:'模特数',
-				width: 80,
-				name:'ModelCount'	
-			},
-			{
-				label:'邀请码',
-				width: 70	
-			},
-			{
-				label:'注册日期',
-				width: 150,
-				name:'MDate'	
-			}
-			];
-				
-     function SetRowsetInfo( rowCount, CurPage)
-     {
-	    $('.pagination').pagination(rowCount,{
-	          items_per_page: <%=items_per_page %>,
-	          current_page: CurPage,
-		      callback: function(page){
-			             DoQuery(page);	
-		                },
-	          display_msg: false
-	      });	     
-     }
+    $('select').select();
+    var head = [
+        {
+            label: '机构',
+            width: 120,
+            name: 'jigouname'
+        },
+        {
+            label: '帐号',
+            width: 110,
+            name: 'Tel'
+        },
+        {
+            label: '名称',
+            width: 90,
+            name: 'Name'
+        },
+        {
+            label: '电话',
+            width: 110,
+            name: 'Phone'
+        },
+        {
+            label: '视频分成(%)',
+            width: 50,
+            name: 'ratio_V'
+        },
+        {
+            label: '人才服务分成(%)',
+            width: 50,
+            name: 'ratio_S'
+        },
+        {
+            label: '队长分成(%)',
+            width: 80,
+            name: 'ratio_L'
+        },
+        {
+            label: '红包分成(%)',
+            width: 80,
+            name: 'ratio_R'
+        },
+        {
+            label: '模特数',
+            width: 80,
+            name: 'ModelCount'
+        },
+        {
+            label: '邀请码',
+            width: 70
+        },
+        {
+            label: '注册日期',
+            width: 150,
+            name: 'MDate'
+        }
+    ];
+
+    function SetRowsetInfo(rowCount, CurPage) {
+        $('.pagination').pagination(rowCount, {
+            items_per_page: <%=items_per_page %>,
+            current_page: CurPage,
+            callback: function (page) {
+                DoQuery(page);
+            },
+            display_msg: false
+        });
+    }
 
     var tbody = new Array();
-         
+
     //superPK 
-    function DoQuery( PageIndex )
-    {
-      $('.grid').Grid('addLoading');
-      keyword = document.all.keyword.value;
-      $.post("<%=basePath%>member/query_jinjiren.jsp",
-      {
-        operator:"query",
-        keyword: keyword,
-        PageIndex: PageIndex
-      },
-      function(data,status)
-      {
-        var obj =  eval('(' + data + ')');
-        if ( (obj.length == 0) || (obj[0].result!="success") )
-        {
-          $('.grid').Grid('setData', null, head);
-          SetRowsetInfo(1, 0);
-        }
-        else
-        {
-          tbody.length = 0;
-          for (var row=0; row<obj.length; row++)
-          { 
-            if (obj[row].result=="success")
-            {          
-              var fields = [];
-              fields[0] = obj[row].jigouname;
-              fields[1] = obj[row].tel;            
-              fields[2] = obj[row].name;
-              fields[3] = obj[row].phone;
-              fields[4] = obj[row].ratio_v;
-              fields[5] = obj[row].ratio_s;
-              fields[6] = obj[row].ratio_l;
-              fields[7] = obj[row].ratio_r;
-              fields[8] = obj[row].modelcount;
-              fields[9] = obj[row].qrcode;
-              fields[10] = obj[row].mdate;
-              fields[11] = [
-						{label:'模特', brokepk:obj[row].brokepk, memberpk:obj[row].memberpk, onclick: function(){
-					    	doViewModel( this.brokepk, this.memberpk );
-						}}
-						];
-              tbody[row] = fields;
-            }
-            else if (obj[row].result=="CachedRowSet")
+    function DoQuery(PageIndex) {
+        $('.grid').Grid('addLoading');
+        keyword = document.all.keyword.value;
+        $.post("<%=basePath%>member/query_jinjiren.jsp",
             {
-              SetRowsetInfo( obj[row].recordcount, obj[row].pageindex );
-            }            
-          }
-          $('.grid').Grid('setData',tbody, head);
+                operator: "query",
+                keyword: keyword,
+                PageIndex: PageIndex
+            },
+            function (data, status) {
+                var obj = eval('(' + data + ')');
+                if ((obj.length == 0) || (obj[0].result != "success")) {
+                    $('.grid').Grid('setData', null, head);
+                    SetRowsetInfo(1, 0);
+                }
+                else {
+                    tbody.length = 0;
+                    for (var row = 0; row < obj.length; row++) {
+                        if (obj[row].result == "success") {
+                            var fields = [];
+                            fields[0] = obj[row].jigouname;
+                            fields[1] = obj[row].tel;
+                            fields[2] = obj[row].name;
+                            fields[3] = obj[row].phone;
+                            fields[4] = obj[row].ratio_v;
+                            fields[5] = obj[row].ratio_s;
+                            fields[6] = obj[row].ratio_l;
+                            fields[7] = obj[row].ratio_r;
+                            fields[8] = obj[row].modelcount;
+                            fields[9] = obj[row].qrcode;
+                            fields[10] = obj[row].mdate;
+                            fields[11] = [
+                                {
+                                    label: '模特',
+                                    brokepk: obj[row].brokepk,
+                                    memberpk: obj[row].memberpk,
+                                    onclick: function () {
+                                        doViewModel(this.brokepk, this.memberpk);
+                                    }
+                                }
+                            ];
+                            tbody[row] = fields;
+                        }
+                        else if (obj[row].result == "CachedRowSet") {
+                            SetRowsetInfo(obj[row].recordcount, obj[row].pageindex);
+                        }
+                    }
+                    $('.grid').Grid('setData', tbody, head);
+                }
+            });
+    }
+
+    function ButtonClick() {
+        DoQuery(-1);
+    }
+
+    function doViewModel(BrokePK, BMemberPK) {
+        var diag = new zDialog();
+        diag.Top = 20;
+        diag.Width = "90%";
+        diag.Height = "90%";
+        diag.Title = "模特";
+        diag.URL = "<%=basePath%>member/model.jsp?brokepk=" + BrokePK + "&bmemberpk=" + BMemberPK;
+        diag.OnClose = function (zWindow) {
+            if (zWindow.result == 1)
+                DoQuery("", -1);
         }
-      });   
-    }				
+        diag.show();
+    }
+
+    H = $(window).height() - $(".grid").offset().top - 100;
+    if (H < 200) H = 200;
+    $('.grid').Grid({
+        thead: head,
+        tbody: null,
+        height: H,
+        operator: {
+            type: "normal",
+            width: 120
+        }
+    });
 
-	function ButtonClick()
-	{
+    $('.grid').Grid('addLoading');
+    $('.grid').Grid('setData', null, head);
+
+    $(function () {
+        $("#button").css("height", 28);
         DoQuery(-1);
-	}
-	
-	function doViewModel( BrokePK, BMemberPK )
-	{
-		var diag = new zDialog();
-		diag.Top = 20;
-		diag.Width = "90%";
-		diag.Height = "90%";
-		diag.Title = "模特";
-		diag.URL = "<%=basePath%>member/model.jsp?brokepk="+BrokePK+"&bmemberpk="+BMemberPK;
-		diag.OnClose= function(zWindow){ 
-			if ( zWindow.result==1 ) 
-	 	  		DoQuery( "", -1 );
-	  	}	
-		diag.show();	
-	}
-	
-    H = $(window).height() - $(".grid").offset().top -100;
-    if (H<200) H=200;
-	$('.grid').Grid({
-			thead: head,
-			tbody: null,
-			height:H,
-			operator: {
-				type : "normal",
-				width : 120	
-			}
-		});
-	
-	$('.grid').Grid('addLoading');
-	$('.grid').Grid('setData',null, head);
-	
-	$(function(){
-	  $("#button").css("height",28);
-	  DoQuery( -1 ); 	
-	});
+    });
+
 
-	
 </script>
 
 </html>

+ 365 - 306
src/main/webapp/member/query_model.jsp

@@ -1,134 +1,165 @@
 <%@ page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
-<%request.setCharacterEncoding("utf-8");%>  
+<%request.setCharacterEncoding("utf-8");%>
 <%@ page language="java" import="java.sql.*,java.util.Arrays" %>
-<%@ page language="java" import="java.util.*, util.*"  %>
-<%@ page language="java" import="system.*"  %>
-<%@ page language="java" import="util.*"  %>
-<%@ page language="java" import="biz.*"  %>
-<%@ page language="java" import="net.sf.json.JSONObject"  %>
-<jsp:useBean id="db" class="dbconnection.DbConnection" scope="page" />
+<%@ page language="java" import="java.util.*, util.*" %>
+<%@ page language="java" import="system.*" %>
+<%@ page language="java" import="util.*" %>
+<%@ page language="java" import="biz.*" %>
+<%@ page language="java" import="net.sf.json.JSONObject" %>
+<jsp:useBean id="db" class="dbconnection.DbConnection" scope="page"/>
 <%
-  String path = request.getContextPath();
-  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
-  String Sess_BrokerPK = ExtendString.getDBStr( (String)session.getAttribute("BrokerPK") );
-  String userpk   = ExtendString.getDBStr( (String)session.getAttribute("userpk"));
-  String username = ExtendString.getDBStr( (String)session.getAttribute("username"));
-  String MembType = ExtendString.getDBStr( (String)session.getAttribute("MembType")); 
-  String IsAdmin  = ExtendString.getDBStr( (String)session.getAttribute("IsAdmin"));
-  String sess_MemberPK= ExtendString.getDBStr( (String)session.getAttribute("MemberPK"));
-  String sess_JiGouPK = ExtendString.getDBStr( (String)session.getAttribute("JiGouPK"));
-  
-  int items_per_page = 10;
-  javax.sql.rowset.CachedRowSet rs = null;
-  String operator = ExtendString.getDBStr( request.getParameter("operator") );
-  String brokepk  = ExtendString.getDBStr( request.getParameter("brokepk") );   //经纪人PK(BrokerInfor.pk)
-  String BMemberPK= ExtendString.getDBStr( request.getParameter("bmemberpk") ); //经纪人memberpk
-  String sql;  
-  int rownum =0;
-  if (brokepk.equals("")) brokepk = "0";
-  if (BMemberPK.equals("")) BMemberPK = "0";
-  if (sess_JiGouPK.equals("")) sess_JiGouPK="0";
-  
-  out.clear();
-  if (operator.equals("query") )
-  {
-    int PageIndex = Integer.parseInt( request.getParameter("PageIndex") );
-    String keyword = ExtendString.getDBStr( request.getParameter("keyword") );
-    
-    String BaseSQL = "select a.pk as ModelInfopk, a.MemberPK, b.Tel, a.Name, a.Stage, a.LName, b.Phone, a.addr, "+
-        			 "		 b.Area, a.BrokePK, a.BMemberPK, b.qrcode, "+
-        			 "       CAST(FORMAT(a.ratio_R,0) as char) as ratio_R, "+
-        			 "       CAST(FORMAT(a.ratio_V,0) as char) as ratio_V, "+
-        			 "       CAST(FORMAT(a.ratio_S,0) as char) as ratio_S, "+
-        			 "       a.Is_V, a.CardPK, c.CardName, "+
-        			 "       DATE_FORMAT(b.MDate,'%Y-%m-%d %H:%i:%s') as MDate, b.identify, "+
-    				 "      (Select count(*) C From MemberInfo x where x.IntroducerPK = b.pk and X.MembType="+ thmodel.MEMTYPE_HuiYuan +" ) as C_HuiYuan, "+
-    				 "      (Select count(*) C From MemberInfo y where y.IntroducerPK = b.PK and y.MembType="+ thmodel.MEMTYPE_Model +" ) as C_Model "+
-        			 "from ModelInfo a inner Join MemberInfo b on a.MemberPK = b.PK  "+
-        			 "     Left Join ModelCard c on a.CardPK = C.PK "+
-        			 "     Left Join BrokerInfor d on a.BrokePK = d.PK "+
-        			 "where b.MembType = "+thmodel.MEMTYPE_Model+"  and IfNull(b.identify,'')<>'删除'  ";
-    //平台帐号可以查询所有模特,管理员可以查询当前机构下所有模特,其他经纪人只能查看自己的模特
-    if (MembType.equals( thmodel.MEMTYPE_PingTai ) )
-    {
-    	//无需添加条件
-    }
-    else if (MembType.equals( thmodel.MEMTYPE_JiGou ) )
-    	BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s or d.superPK=%s ",sess_JiGouPK, sess_JiGouPK );
-    else if (MembType.equals( thmodel.MEMTYPE_JinJiRen ) )
-    	BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s ",Sess_BrokerPK );
-    else //应该不会发生
-    	BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s ",Sess_BrokerPK );
-System.out.println(BaseSQL);    
-    //
-    if (keyword.length()>0) 
-    	BaseSQL = BaseSQL+ String.format(" and (b.Tel like '%%%s%%' or b.Pet like '%%%s%%' "+
-    							  "	     or a.Name like '%%%s%%' or  a.Stage like '%%%s%%' "+
-    							  "      or b.qrcode like '%%%s%%' ) ",
-    					keyword, keyword, 
-    					keyword, keyword,
-    					keyword );
-    BaseSQL = BaseSQL + "Order by b.MDate Desc ";
-    if (PageIndex == -1)
-      sql =BaseSQL+"  LIMIT 0, " + String.valueOf(items_per_page);
-    else
-      sql = BaseSQL+" LIMIT " +String.valueOf(items_per_page * PageIndex )
-             +","+String.valueOf(items_per_page);
- 
-    List<JSONObject> jsonList = DBRecordsPack.Pack( db, sql );
-    if (PageIndex == -1)
-    {
-      rs = db.executeQuery("Select Count(*) C from ("+BaseSQL+") as t_cc ");
-      if ( (rs!=null) && rs.next() )
-      {
-        JSONObject jsonObj =  new JSONObject();
-  	    jsonObj.put("result","CachedRowSet");
-	    jsonObj.put("recordcount", rs.getInt(1) );
-	    jsonObj.put("pageindex", 0);
-	    jsonList.add( jsonObj );
-	  }
-    }
+    String path = request.getContextPath();
+    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
+    String Sess_BrokerPK = ExtendString.getDBStr((String) session.getAttribute("BrokerPK"));
+    String userpk = ExtendString.getDBStr((String) session.getAttribute("userpk"));
+    String username = ExtendString.getDBStr((String) session.getAttribute("username"));
+    String MembType = ExtendString.getDBStr((String) session.getAttribute("MembType"));
+    String IsAdmin = ExtendString.getDBStr((String) session.getAttribute("IsAdmin"));
+    String sess_MemberPK = ExtendString.getDBStr((String) session.getAttribute("MemberPK"));
+    String sess_JiGouPK = ExtendString.getDBStr((String) session.getAttribute("JiGouPK"));
+
+    int items_per_page = 10;
+    javax.sql.rowset.CachedRowSet rs = null;
+    String operator = ExtendString.getDBStr(request.getParameter("operator"));
+    String brokepk = ExtendString.getDBStr(request.getParameter("brokepk"));   //经纪人PK(BrokerInfor.pk)
+    String BMemberPK = ExtendString.getDBStr(request.getParameter("bmemberpk")); //经纪人memberpk
+    String sql;
+    int rownum = 0;
+    if (brokepk.equals("")) brokepk = "0";
+    if (BMemberPK.equals("")) BMemberPK = "0";
+    if (sess_JiGouPK.equals("")) sess_JiGouPK = "0";
+
     out.clear();
-    out.print(jsonList);
-    return;
-  }
-  
+    if (operator.equals("query")) {
+        int    PageIndex = Integer.parseInt(request.getParameter("PageIndex"));
+        int    Area      = Integer.parseInt(request.getParameter("Area"));
+        String keyword   = ExtendString.getDBStr(request.getParameter("keyword"));
+
+        String BaseSQL = "select a.pk as ModelInfopk, a.MemberPK, b.Tel, a.Name, a.Stage, a.LName, b.Phone, a.addr, " +
+                "		 b.Area, a.BrokePK, a.BMemberPK, b.qrcode, " +
+                "       CAST(FORMAT(a.ratio_R,0) as char) as ratio_R, " +
+                "       CAST(FORMAT(a.ratio_V,0) as char) as ratio_V, " +
+                "       CAST(FORMAT(a.ratio_S,0) as char) as ratio_S, " +
+                "       a.Is_V, a.CardPK, c.CardName, " +
+                "       DATE_FORMAT(b.MDate,'%Y-%m-%d %H:%i:%s') as MDate, b.identify, " +
+                "      (Select count(*) C From MemberInfo x where x.IntroducerPK = b.pk and X.MembType=" + thmodel.MEMTYPE_HuiYuan + " ) as C_HuiYuan, " +
+                "      (Select count(*) C From MemberInfo y where y.IntroducerPK = b.PK and y.MembType=" + thmodel.MEMTYPE_Model + " ) as C_Model, " +
+                "a.sort " +
+                "from ModelInfo a inner Join MemberInfo b on a.MemberPK = b.PK  " +
+                "     Left Join ModelCard c on a.CardPK = C.PK " +
+                "     Left Join BrokerInfor d on a.BrokePK = d.PK " +
+                "where b.MembType = " + thmodel.MEMTYPE_Model + "  and IfNull(b.identify,'')<>'删除'  ";
+        //平台帐号可以查询所有模特,管理员可以查询当前机构下所有模特,其他经纪人只能查看自己的模特
+        if (MembType.equals(thmodel.MEMTYPE_PingTai)) {
+            //无需添加条件
+        } else if (MembType.equals(thmodel.MEMTYPE_JiGou))
+            BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s or d.superPK=%s ", sess_JiGouPK, sess_JiGouPK);
+        else if (MembType.equals(thmodel.MEMTYPE_JinJiRen))
+            BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s ", Sess_BrokerPK);
+        else //应该不会发生
+            BaseSQL = BaseSQL + String.format(" and a.BrokePK = %s ", Sess_BrokerPK);
+        System.out.println(BaseSQL);
+        //
+        if (keyword.length() > 0)
+            BaseSQL = BaseSQL + String.format(" and (b.Tel like '%%%s%%' or b.Pet like '%%%s%%' " +
+                                                      "	     or a.Name like '%%%s%%' or  a.Stage like '%%%s%%' " +
+                                                      "      or b.qrcode like '%%%s%%' ) ",
+                                              keyword, keyword,
+                                              keyword, keyword,
+                                              keyword);
+        if (Area > 0) {
+            BaseSQL += "and b.Area = " + Area + " ";
+        }
+        BaseSQL = BaseSQL + "Order by a.sort desc, b.MDate Desc ";
+
+        if (PageIndex == -1)
+            sql = BaseSQL + "  LIMIT 0, " + String.valueOf(items_per_page);
+        else
+            sql = BaseSQL + " LIMIT " + String.valueOf(items_per_page * PageIndex)
+                    + "," + String.valueOf(items_per_page);
+
+        List<JSONObject> jsonList = DBRecordsPack.Pack(db, sql);
+        if (PageIndex == -1) {
+            rs = db.executeQuery("Select Count(*) C from (" + BaseSQL + ") as t_cc ");
+            if ((rs != null) && rs.next()) {
+                JSONObject jsonObj = new JSONObject();
+                jsonObj.put("result", "CachedRowSet");
+                jsonObj.put("recordcount", rs.getInt(1));
+                jsonObj.put("pageindex", 0);
+                jsonList.add(jsonObj);
+            }
+        }
+        out.clear();
+        out.print(jsonList);
+        return;
+    } else if (operator.equals("updateSort")) {
+        String pk   = request.getParameter("pk");
+        String sort = request.getParameter("sort");
+        sql = "update modelinfo set sort = " + sort + " where PK = " + pk;
+        db.executeUpdate(sql);
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("success", true);
+        out.clear();
+        out.print(jsonObject);
+        return;
+    }
+
 
 %>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-<base href="<%=basePath %>"/>
-<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css" />
-<link rel="stylesheet" type="text/css" href="<%=basePath%>css/WdatePicker.css" />
-<link rel="stylesheet" type="text/css" href="<%=basePath%>css/skin_/table.css" />
-<link rel="stylesheet" type="text/css" href="<%=basePath%>css/jquery.grid.css" />
-<title>模特查询</title>
+    <base href="<%=basePath %>"/>
+    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7"/>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css"/>
+    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/WdatePicker.css"/>
+    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/skin_/table.css"/>
+    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/jquery.grid.css"/>
+    <title>模特查询</title>
 </head>
 <body>
 <div id="container">
-	<div id="hd"></div>
+    <div id="hd"></div>
     <div id="bd">
-    	<div id="main">
-        	<div class="search-box ue-clear">
-            	<div class="search-area">
+        <div id="main">
+            <div class="kv-item">
+                <label>地区:</label> <span></span>
+                <select name="Area" id="Area" class="select">
+                    <option value="0">全部
+                    </option>
+                    <%
+                        sql = "Select PK, Name from datatypeinfo where typeName ='地区' order by OrdID ";
+                        rs = db.executeQuery(sql);
+                        while ((rs != null) && rs.next()) {
+                            String tmpID   = rs.getString("PK");
+                            String tmpName = rs.getString("Name");
+                    %>
+                    <option value="<%=tmpID%>"><%=tmpName%>
+                    </option>
+                    <%
+                        }
+                        if (rs != null) rs.close();
+                    %>
+                </select>
+            </div>
+            <div class="search-box ue-clear">
+                <div class="search-area">
                     <div class="kv-item ue-clear">
                         <label>名称:</label>
-						<span></span>
-						<input type="text" name="keyword" style="width:200px" placeholder="关键字" />
+                        <span></span>
+                        <input type="text" name="keyword" style="width:200px" placeholder="关键字"/>
                     </div>
                 </div>
                 <div class="search-button">
-				    <span></span>
-                	<input class="button" id="button" type="button" value="搜索一下" onClick="ButtonClick();" />
+                    <span></span>
+                    <input class="button" id="button" type="button" value="搜索一下" onClick="ButtonClick();"/>
                 </div>
-             </div>         	
+            </div>
             <div class="table">
                 <div class="grid"></div>
-                
+
                 <div class="pagination"></div>
             </div>
         </div>
@@ -146,212 +177,240 @@ System.out.println(BaseSQL);
 <script type="text/javascript" src="<%=basePath%>js/zDrag.js"></script>
 <script type="text/javascript" src="<%=basePath%>js/zDialog.js"></script>
 <script type="text/javascript">
-	$('select').select();
-	var head = [
-			{
-				label:'帐号',
-				width: 110,
-				name:'Tel'	
-			},
-			{
-				label:'姓名',
-				width: 90,
-				name:'Name'	
-			},
-			{
-				label:'电话',
-				width: 110,
-				name:'Phone'	
-			},
-			{
-				label:'艺名',
-				width: 110,
-				name:'Stage'	
-			},
-			{
-				label:'个性签名',
-				width: 110,
-				name:'LName'	
-			},
-			
-			{
-				label:'红包分成(%)',
-				width: 50,
-				name:'ratio_R'	
-			},
-			{
-				label:'视频分成(%)',
-				width: 50,
-				name:'ratio_V'	
-			},
-			{
-				label:'服务分成(%)',
-				width: 80,
-				name:'ratio_S'	
-			},
-			{
-				label:'是否接受视频聊天',
-				width: 80,
-				name:'Is_V'	
-			},
-			{
-				label:'模卡',
-				width: 80,
-				name:'CardName'	
-			},
-			{
-				label:'推荐用户数',
-				width: 80
-			},
-			{
-				label:'推荐模特数',
-				width: 80
-			},		
-			{
-				label:'邀请码',
-				width: 80
-			},		
-			{
-				label:'注册日期',
-				width: 150,
-				name:'MDate'	
-			}
-			];
-        			 				
-     function SetRowsetInfo( rowCount, CurPage)
-     {
-	    $('.pagination').pagination(rowCount,{
-	          items_per_page: <%=items_per_page %>,
-	          current_page: CurPage,
-		      callback: function(page){
-			             DoQuery(document.all.keyword.value, page);	
-		                },
-	          display_msg: false
-	      });	     
-     }
+    $('select').select();
+    var head = [
+        {
+            label: '帐号',
+            width: 110,
+            name: 'Tel'
+        },
+        {
+            label: '姓名',
+            width: 90,
+            name: 'Name'
+        },
+        {
+            label: '电话',
+            width: 110,
+            name: 'Phone'
+        },
+        {
+            label: '艺名',
+            width: 110,
+            name: 'Stage'
+        },
+        {
+            label: '个性签名',
+            width: 110,
+            name: 'LName'
+        },
+
+        {
+            label: '红包分成(%)',
+            width: 50,
+            name: 'ratio_R'
+        },
+        {
+            label: '视频分成(%)',
+            width: 50,
+            name: 'ratio_V'
+        },
+        {
+            label: '服务分成(%)',
+            width: 80,
+            name: 'ratio_S'
+        },
+        {
+            label: '是否接受视频聊天',
+            width: 80,
+            name: 'Is_V'
+        },
+        {
+            label: '模卡',
+            width: 80,
+            name: 'CardName'
+        },
+        {
+            label: '推荐用户数',
+            width: 80
+        },
+        {
+            label: '推荐模特数',
+            width: 80
+        },
+        {
+            label: '邀请码',
+            width: 80
+        },
+        {
+            label: '注册日期',
+            width: 150,
+            name: 'MDate'
+        },
+        {
+            label: '排序',
+            width: 150,
+            name: 'sort'
+        }
+    ];
+
+    function SetRowsetInfo(rowCount, CurPage) {
+        $('.pagination').pagination(rowCount, {
+            items_per_page: <%=items_per_page %>,
+            current_page: CurPage,
+            callback: function (page) {
+                DoQuery(document.all.keyword.value, page);
+            },
+            display_msg: false
+        });
+    }
 
     var tbody = new Array();
-         
+
     //superPK 
-    function DoQuery(keyword, PageIndex )
+    function DoQuery(keyword, PageIndex) {
+        $('.grid').Grid('addLoading');
+        $.post("<%=basePath%>member/query_model.jsp",
+            {
+                operator: "query",
+                keyword: keyword,
+                PageIndex: PageIndex,
+                Area: Number($('#Area').Grid('addLoading')[0].value)
+            },
+            function (data, status) {
+                var obj = eval('(' + data + ')');
+                if ((obj.length == 0) || (obj[0].result != "success")) {
+                    $('.grid').Grid('setData', null, head);
+                    SetRowsetInfo(1, 0);
+                } else {
+                    tbody.length = 0;
+                    for (var row = 0; row < obj.length; row++) {
+                        if (obj[row].result == "success") {
+                            var fields = [];
+                            fields[0] = obj[row].tel;
+                            fields[1] = obj[row].name;
+                            fields[2] = obj[row].phone;
+                            fields[3] = obj[row].stage;
+                            fields[4] = obj[row].lname;
+                            fields[5] = obj[row].ratio_r;
+                            fields[6] = obj[row].ratio_v;
+                            fields[7] = obj[row].ratio_s;
+                            if (obj[row].is_v == "1")
+                                fields[8] = "是";
+                            else fields[8] = "";
+                            fields[9] = obj[row].cardname;
+                            fields[10] = obj[row].c_huiyuan;
+                            fields[11] = obj[row].c_model;
+                            fields[12] = obj[row].qrcode;
+                            fields[13] = obj[row].mdate;
+                            fields[14] = obj[row].sort;
+                            fields[15] = [
+                                {
+                                    label: '详情',
+                                    modelinfopk: obj[row].modelinfopk,
+                                    memberpk: obj[row].memberpk,
+                                    onclick: function () {
+                                        doViewModel(this.memberpk);
+                                    }
+                                },
+                                {
+                                    label: '邀请列表',
+                                    modelinfopk: obj[row].modelinfopk,
+                                    memberpk: obj[row].memberpk,
+                                    onclick: function () {
+                                        doViewModelList(this.memberpk);
+                                    }
+                                },
+                                {
+                                    label: '排序',
+                                    width: 100,
+                                    modelinfopk: obj[row].modelinfopk,
+                                    memberpk: obj[row].memberpk,
+                                    onclick: function () {
+                                        var sort = prompt("请输入排序数值(数值越大排序越前)");
+                                        sort = Number(sort);
+                                        if (!isNaN(sort)) {
+                                            console.log(this.modelinfopk, sort);
+                                            $.post("<%=basePath%>member/query_model.jsp", {
+                                                operator: "updateSort",
+                                                pk: this.modelinfopk,
+                                                sort: sort
+                                            }, function (data, status) {
+                                                console.log(data);
+                                                if (eval("(" + data + ")").success) {
+                                                    DoQuery(document.all.keyword.value, -1);
+                                                }
+                                            })
+                                        }
+                                    }
+                                }
+                            ];
+                            tbody[row] = fields;
+                        } else if (obj[row].result == "CachedRowSet") {
+                            SetRowsetInfo(obj[row].recordcount, obj[row].pageindex);
+                        }
+                    }
+                    var e = $('.grid');
+                    e.Grid('setData', tbody, head);
+                }
+            });
+    }
+
+    function ButtonClick() {
+        DoQuery(document.all.keyword.value, -1);
+    }
+
+    function doViewModel(memberpk) //查看
     {
-      $('.grid').Grid('addLoading');         
-      $.post("<%=basePath%>member/query_model.jsp",
-      {
-        operator:"query",
-        keyword: keyword,
-        PageIndex: PageIndex
-      },
-      function(data,status)
-      {
-        var obj =  eval('(' + data + ')');
-        if ( (obj.length == 0) || (obj[0].result!="success") )
-        {
-          $('.grid').Grid('setData', null, head);
-          SetRowsetInfo(1, 0);
+        var diag = new zDialog();
+        diag.Width = 500;
+        diag.Height = 500;
+        flag = 0;
+        diag.Title = "查看";
+        diag.URL = "<%=basePath%>member/model_.jsp?brokepk=<%=brokepk%>&bmemberpk=<%=BMemberPK%>&memberpk=" + memberpk + "&flag=" + flag;
+        diag.OnClose = function (zWindow) {
+            if (zWindow.result == 1)
+                DoQuery(-1);
         }
-        else
-        {
-          tbody.length = 0;
-          for (var row=0; row<obj.length; row++)
-          { 
-            if (obj[row].result=="success")
-            {          
-              var fields = [];
-              fields[0] = obj[row].tel;            
-              fields[1] = obj[row].name;
-              fields[2] = obj[row].phone;
-              fields[3] = obj[row].stage;
-              fields[4] = obj[row].lname;
-              fields[5] = obj[row].ratio_r;
-              fields[6] = obj[row].ratio_v;
-              fields[7] = obj[row].ratio_s;
-              if (obj[row].is_v=="1")
-              	fields[8] = "是";
-              else fields[8] = "";
-              fields[9]  = obj[row].cardname;
-              fields[10] = obj[row].c_huiyuan;
-              fields[11] = obj[row].c_model;
-              fields[12] = obj[row].qrcode;
-              fields[13] = obj[row].mdate;
-              fields[14] = [
-						{label:'详情', modelinfopk:obj[row].modelinfopk, memberpk:obj[row].memberpk, onclick: function(){
-					    	doViewModel( this.memberpk );
-						}},
-						{label:'邀请列表', modelinfopk:obj[row].modelinfopk, memberpk:obj[row].memberpk, onclick: function(){
-					    	doViewModelList( this.memberpk );
-						}}
-						
-						];
-              tbody[row] = fields;
-            }
-            else if (obj[row].result=="CachedRowSet")
-            {
-              SetRowsetInfo( obj[row].recordcount, obj[row].pageindex );
-            }            
-          }
-          $('.grid').Grid('setData',tbody, head);
+        diag.show();
+    }
+
+
+    function doViewModelList(introducerpk) {
+        var diag = new zDialog();
+        diag.Top = 20;
+        diag.Width = "90%";
+        diag.Height = "90%";
+        diag.Title = "被邀请人";
+        diag.URL = "<%=basePath%>member/model.jsp?introducerpk=" + introducerpk;
+        diag.OnClose = function (zWindow) {
+            if (zWindow.result == 1)
+                DoQuery("", -1);
         }
-      });   
-    }				
+        diag.show();
+    }
 
-	function ButtonClick()
-	{
-        DoQuery(document.all.keyword.value, -1);
-	}
-	
-	function doViewModel( memberpk ) //查看
-	{
-		var diag = new zDialog();
-		diag.Width = 500;
-		diag.Height = 500;
-		flag = 0;
-		diag.Title = "查看";
-		diag.URL = "<%=basePath%>member/model_.jsp?brokepk=<%=brokepk%>&bmemberpk=<%=BMemberPK%>&memberpk="+memberpk+"&flag="+flag;
-		diag.OnClose= function(zWindow){ 
-			if ( zWindow.result==1 ) 
-	 	  		DoQuery( -1 );
-	  	}	
-		diag.show();		
-	}
+    H = $(window).height() - $(".grid").offset().top - 100;
+    if (H < 200) H = 200;
+    $('.grid').Grid({
+        thead: head,
+        tbody: null,
+        height: H,
+        operator: {
+            type: "normal",
+            width: 140
+        }
+    });
+
+    $('.grid').Grid('addLoading');
+    $('.grid').Grid('setData', null, head);
+
+    $(function () {
+        $("#button").css("height", 28);
+        DoQuery("", -1);
+    });
 
-	
-	function doViewModelList( introducerpk )
-	{
-		var diag = new zDialog();
-		diag.Top = 20;
-		diag.Width = "90%";
-		diag.Height = "90%";
-		diag.Title = "被邀请人";
-		diag.URL = "<%=basePath%>member/model.jsp?introducerpk="+introducerpk;
-		diag.OnClose= function(zWindow){ 
-			if ( zWindow.result==1 ) 
-	 	  		DoQuery( "", -1 );
-	  	}	
-		diag.show();	
-	}
-	
-	H = $(window).height() - $(".grid").offset().top -100;
-    if (H<200) H=200;
-	$('.grid').Grid({
-			thead: head,
-			tbody: null,
-			height:H,
-			operator: {
-				type : "normal",
-				width : 120	
-			}
-		});
-	
-	$('.grid').Grid('addLoading');
-	$('.grid').Grid('setData',null, head);
-	
-	$(function(){
-	  $("#button").css("height",28);
-	  DoQuery("", -1 ); 	
-	});
 
-	
 </script>
 
 </html>