jiapeng 7 ans auparavant
Parent
commit
90a5369d6f
1 fichiers modifiés avec 1035 ajouts et 922 suppressions
  1. 1035 922
      src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

+ 1035 - 922
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

47
public abstract class ProfessorDao {
47
public abstract class ProfessorDao {
48
	@Insert
48
	@Insert
49
	public abstract int insert(Connection con, Professor professor) throws SQLException;
49
	public abstract int insert(Connection con, Professor professor) throws SQLException;
50
	
50

51
	@UpdateWith
51
	@UpdateWith
52
	@From(Professor.class)
52
	@From(Professor.class)
53
	@SetSentence("PAGE_VIEWS = PAGE_VIEWS + 1")
53
	@SetSentence("PAGE_VIEWS = PAGE_VIEWS + 1")
54
	public abstract int incPageViews(Connection con,String id)throws SQLException;
54
	public abstract int incPageViews(Connection con, String id) throws SQLException;
55

55

56
	@Update
56
	@Update
57
	public abstract int update(Connection con, Professor professor) throws SQLException;
57
	public abstract int update(Connection con, Professor professor) throws SQLException;
58
	
59
	public int updateScoreValue(Connection con,String id,Integer scoreValue)throws SQLException{
58

59
	public int updateScoreValue(Connection con, String id, Integer scoreValue) throws SQLException {
60
		String sql = "UPDATE PROFESSOR SET SCORE_VALUE = SCORE_VALUE + " + scoreValue + " WHERE ID = '" + id + "'";
60
		String sql = "UPDATE PROFESSOR SET SCORE_VALUE = SCORE_VALUE + " + scoreValue + " WHERE ID = '" + id + "'";
61
		PreparedStatement ps = con.prepareStatement(sql);
61
		PreparedStatement ps = con.prepareStatement(sql);
62
		try{
62
		try {
63
			return ps.executeUpdate();
63
			return ps.executeUpdate();
64
		}finally{
65
			try{ps.close();}catch(Exception e){}
64
		} finally {
65
			try {
66
				ps.close();
67
			} catch (Exception e) {
68
			}
66
		}
69
		}
67
	}
70
	}
68
	
69
	public int updateGrowthValue(Connection con,String id,Integer growthValue)throws SQLException{
71

72
	public int updateGrowthValue(Connection con, String id, Integer growthValue) throws SQLException {
70
		String sql = "UPDATE PROFESSOR SET GROWTH_VALUE = GROWTH_VALUE + " + growthValue + " WHERE ID = '" + id + "'";
73
		String sql = "UPDATE PROFESSOR SET GROWTH_VALUE = GROWTH_VALUE + " + growthValue + " WHERE ID = '" + id + "'";
71
		PreparedStatement ps = con.prepareStatement(sql);
74
		PreparedStatement ps = con.prepareStatement(sql);
72
		try{
75
		try {
73
			return ps.executeUpdate();
76
			return ps.executeUpdate();
74
		}finally{
75
			try{ps.close();}catch(Exception e){}
77
		} finally {
78
			try {
79
				ps.close();
80
			} catch (Exception e) {
81
			}
76
		}
82
		}
77
	}
83
	}
78
	
84

79
	@SelectOne
85
	@SelectOne
80
	@Nullable
86
	@Nullable
81
	public abstract Professor query(Connection con,long shareId)throws SQLException;
82
	
87
	public abstract Professor query(Connection con, long shareId) throws SQLException;
88

83
	@UpdateWith
89
	@UpdateWith
84
	@From(Professor.class)
90
	@From(Professor.class)
85
	public abstract int updatePhone(Connection con, String id, @Set String phone) throws SQLException;
91
	public abstract int updatePhone(Connection con, String id, @Set String phone) throws SQLException;
86
	
92

87
	@UpdateWith
93
	@UpdateWith
88
	@From(Professor.class)
94
	@From(Professor.class)
89
	public abstract int updateEmail(Connection con, String id, @Set String email) throws SQLException;
95
	public abstract int updateEmail(Connection con, String id, @Set String email) throws SQLException;
90
	
96

91
	@UpdateWith
97
	@UpdateWith
92
	@From(Professor.class)
98
	@From(Professor.class)
93
	public abstract int updateSortFirst(Connection con, String id, @Set Integer sortFirst) throws SQLException;
99
	public abstract int updateSortFirst(Connection con, String id, @Set Integer sortFirst) throws SQLException;
94
	
100

95
	@UpdateWith
101
	@UpdateWith
96
	@From(Professor.class)
102
	@From(Professor.class)
97
	public abstract int updateAuthentication(Connection con, String id, @Set Integer authentication, 
98
			@Set Integer authType, @Set Integer authStatus) throws SQLException;
99
	
103
	public abstract int updateAuthentication(Connection con, String id, @Set Integer authentication, @Set Integer authType, @Set Integer authStatus)
104
			throws SQLException;
105

100
	@UpdateWith
106
	@UpdateWith
101
	@From(Professor.class)
107
	@From(Professor.class)
102
	public abstract int updateAuthType(Connection con, String id, @Set Integer authType) throws SQLException;
108
	public abstract int updateAuthType(Connection con, String id, @Set Integer authType) throws SQLException;
103
	
109

104
	@UpdateWith
110
	@UpdateWith
105
	@From(Professor.class)
111
	@From(Professor.class)
106
	public abstract int updateAuthentication(Connection con, String id, @Set Integer authentication) throws SQLException;
112
	public abstract int updateAuthentication(Connection con, String id, @Set Integer authentication) throws SQLException;
107
	
113

108
	@UpdateWith
114
	@UpdateWith
109
	@From(Professor.class)
115
	@From(Professor.class)
110
	public abstract int updateAuthStatus(Connection con, String id, @Set Integer authStatus) throws SQLException;
116
	public abstract int updateAuthStatus(Connection con, String id, @Set Integer authStatus) throws SQLException;
111
	
117

112
	@UpdateWith
118
	@UpdateWith
113
	@From(Professor.class)
119
	@From(Professor.class)
114
	public abstract int updateAuthStatusExpert(Connection con,String id,@Set Integer authStatusExpert)throws SQLException;
115
	
120
	public abstract int updateAuthStatusExpert(Connection con, String id, @Set Integer authStatusExpert) throws SQLException;
121

116
	@UpdateWith
122
	@UpdateWith
117
	@From(Professor.class)
123
	@From(Professor.class)
118
	public abstract int updateOrgAuth(Connection con,String id,@Set String orgAuth)throws SQLException;
119
	
124
	public abstract int updateOrgAuth(Connection con, String id, @Set String orgAuth) throws SQLException;
125

120
	@UpdateWith
126
	@UpdateWith
121
	@From(Professor.class)
127
	@From(Professor.class)
122
	public abstract int updateStarLevel(Connection con, String id, @Set BigDecimal starLevel) throws SQLException;
128
	public abstract int updateStarLevel(Connection con, String id, @Set BigDecimal starLevel) throws SQLException;
123
	
129

124
	@UpdateWith
130
	@UpdateWith
125
	@From(Professor.class)
131
	@From(Professor.class)
126
	public abstract int updateConsultCount(Connection con, String id, @Set Integer consultCount) throws SQLException;
132
	public abstract int updateConsultCount(Connection con, String id, @Set Integer consultCount) throws SQLException;
136
	@UpdateWith
142
	@UpdateWith
137
	@From(Professor.class)
143
	@From(Professor.class)
138
	public abstract int updateIndustry(Connection con, String id, @Set String industry) throws SQLException;
144
	public abstract int updateIndustry(Connection con, String id, @Set String industry) throws SQLException;
139
	
145

140
	@UpdateWith
146
	@UpdateWith
141
	@From(Professor.class)
147
	@From(Professor.class)
142
	public abstract int updateAddress(Connection con, String id, @Set String address) throws SQLException;
148
	public abstract int updateAddress(Connection con, String id, @Set String address) throws SQLException;
143
	
149

144
	@UpdateWith
150
	@UpdateWith
145
	@From(Professor.class)
151
	@From(Professor.class)
146
	public abstract int updateProvince(Connection con, String id, @Set String province) throws SQLException;
152
	public abstract int updateProvince(Connection con, String id, @Set String province) throws SQLException;
147
	
153

148
	@UpdateWith
154
	@UpdateWith
149
	@From(Professor.class)
155
	@From(Professor.class)
150
	public abstract int updateStarAvg(Connection con, String id, @Set BigDecimal starAvg) throws SQLException;
156
	public abstract int updateStarAvg(Connection con, String id, @Set BigDecimal starAvg) throws SQLException;
151
	
157

152
	@UpdateWith
158
	@UpdateWith
153
	@From(Professor.class)
159
	@From(Professor.class)
154
	public abstract int updateScorePercent(Connection con,String id,@Set String scorePercent)throws SQLException;
155
	
160
	public abstract int updateScorePercent(Connection con, String id, @Set String scorePercent) throws SQLException;
161

156
	/**
162
	/**
157
	 * 查用户总数
163
	 * 查用户总数
164
	 * 
158
	 * @param con
165
	 * @param con
159
	 * @return
166
	 * @return
160
	 * @throws SQLException
167
	 * @throws SQLException
161
	 */
168
	 */
162
	@QueryVal
169
	@QueryVal
163
	@Column(handlerClass=IntHandler.class,value={"COUNT(1)"})
170
	@Column(handlerClass = IntHandler.class, value = { "COUNT(1)" })
164
	@From(Professor.class)
171
	@From(Professor.class)
165
	@DefaultValue("0")
172
	@DefaultValue("0")
166
	public abstract int queryCount(Connection con)throws SQLException;
167
	
173
	public abstract int queryCount(Connection con) throws SQLException;
174

168
	/**
175
	/**
169
	 * 查询积分值低于scoreValue的用户总数
176
	 * 查询积分值低于scoreValue的用户总数
177
	 * 
170
	 * @param con
178
	 * @param con
171
	 * @param scoreValue 积分值
179
	 * @param scoreValue
180
	 *            积分值
172
	 * @return
181
	 * @return
173
	 * @throws SQLException
182
	 * @throws SQLException
174
	 */
183
	 */
175
	@QueryVal
184
	@QueryVal
176
	@Column(handlerClass=IntHandler.class,value={"COUNT(1)"})
185
	@Column(handlerClass = IntHandler.class, value = { "COUNT(1)" })
177
	@From(Professor.class)
186
	@From(Professor.class)
178
	@DefaultValue("0")
187
	@DefaultValue("0")
179
	public abstract int queryCountLessThan(Connection con,@LessThan int scoreValue)throws SQLException;
180
	
188
	public abstract int queryCountLessThan(Connection con, @LessThan int scoreValue) throws SQLException;
189

181
	@SelectList
190
	@SelectList
182
	public abstract List<Professor> queryList(Connection con)throws SQLException;
183
	
184
	public List<EditProfessor> queryInvite(Connection con, String id) throws SQLException{
191
	public abstract List<Professor> queryList(Connection con) throws SQLException;
192

193
	public List<EditProfessor> queryInvite(Connection con, String id) throws SQLException {
185
		int index = 1;
194
		int index = 1;
186
        String sql = "SELECT OFFICE,ADDRESS,ORG_ID,O.NAME,TITLE,AUTHENTICATION,P.AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_AUTH,P.SHARE_ID "
187
        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION O ON P.ORG_ID=O.ID "
188
        		+ " INNER JOIN LUSER L ON P.ID=L.ID WHERE L.INVITER_ID = ? ORDER BY P.CREATE_TIME DESC,P.ID";
189
        PreparedStatement ps = con.prepareStatement(sql);
190
        try{
191
        	ps.setString(index++,id);
192
            ResultSet rs = ps.executeQuery();
193
            try{
194
                List<EditProfessor> professors = new ArrayList<EditProfessor>();
195
                while(rs.next()){
196
                	EditProfessor professor =  new EditProfessor();
197
                    String office = rs.getString(1);
198
                    if(rs.wasNull()){
199
                    	office = null;
200
                    }
201
                    professor.setOffice(office);
202
                    String address = rs.getString(2);
203
                    if(rs.wasNull()){
204
                    	address = null;
205
                    }
206
                    professor.setAddress(address);
207
                    Organization organization = new Organization();
208
                    String orgId = rs.getString(3);
209
                    if(rs.wasNull()){
210
                    	orgId = null;
211
                    }
212
                    organization.setId(orgId);
213
                    String orgName = rs.getString(4);
214
                    if(rs.wasNull()){
215
                    	orgName = null;
216
                    }
217
                    organization.setName(orgName);
218
                    professor.setOrganization(organization);
219
                    professor.setTitle(rs.getString(5));
220
                    Integer auth = rs.getInt(6);
221
                    if(rs.wasNull()){
222
                    	auth = null;
223
                    }
224
                    professor.setAuthentication(auth);
225
                    professor.setAuthType(rs.getInt(7));
226
                    professor.setAuthStatus(rs.getInt(8));
227
                    professor.setId(rs.getString(9));
228
                    professor.setName(rs.getString(10));
229
                    professor.setOrgAuth(rs.getString(11));
230
                    professor.setShareId(rs.getLong(12));
231
                    professors.add(professor);
232
                }
233
                return professors;
234
            }finally{
235
                try{rs.close();}catch(Exception e1){}
236
            }
237
        }finally{
238
            try{ps.close();}catch(Exception e2){}
239
        }
240
    }
241
	
195
		String sql = "SELECT OFFICE,ADDRESS,ORG_ID,O.NAME,TITLE,AUTHENTICATION,P.AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_AUTH,P.SHARE_ID "
196
				+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION O ON P.ORG_ID=O.ID "
197
				+ " INNER JOIN LUSER L ON P.ID=L.ID WHERE L.INVITER_ID = ? ORDER BY P.CREATE_TIME DESC,P.ID";
198
		PreparedStatement ps = con.prepareStatement(sql);
199
		try {
200
			ps.setString(index++, id);
201
			ResultSet rs = ps.executeQuery();
202
			try {
203
				List<EditProfessor> professors = new ArrayList<EditProfessor>();
204
				while (rs.next()) {
205
					EditProfessor professor = new EditProfessor();
206
					String office = rs.getString(1);
207
					if (rs.wasNull()) {
208
						office = null;
209
					}
210
					professor.setOffice(office);
211
					String address = rs.getString(2);
212
					if (rs.wasNull()) {
213
						address = null;
214
					}
215
					professor.setAddress(address);
216
					Organization organization = new Organization();
217
					String orgId = rs.getString(3);
218
					if (rs.wasNull()) {
219
						orgId = null;
220
					}
221
					organization.setId(orgId);
222
					String orgName = rs.getString(4);
223
					if (rs.wasNull()) {
224
						orgName = null;
225
					}
226
					organization.setName(orgName);
227
					professor.setOrganization(organization);
228
					professor.setTitle(rs.getString(5));
229
					Integer auth = rs.getInt(6);
230
					if (rs.wasNull()) {
231
						auth = null;
232
					}
233
					professor.setAuthentication(auth);
234
					professor.setAuthType(rs.getInt(7));
235
					professor.setAuthStatus(rs.getInt(8));
236
					professor.setId(rs.getString(9));
237
					professor.setName(rs.getString(10));
238
					professor.setOrgAuth(rs.getString(11));
239
					professor.setShareId(rs.getLong(12));
240
					professors.add(professor);
241
				}
242
				return professors;
243
			} finally {
244
				try {
245
					rs.close();
246
				} catch (Exception e1) {
247
				}
248
			}
249
		} finally {
250
			try {
251
				ps.close();
252
			} catch (Exception e2) {
253
			}
254
		}
255
	}
256

242
	/**
257
	/**
243
	 * 查询用户的认证状态。
258
	 * 查询用户的认证状态。
259
	 * 
244
	 * @param con
260
	 * @param con
245
	 * @param id
261
	 * @param id
246
	 * @return 返回认证类型 用户类型 实名认证状态和专家认证状态
262
	 * @return 返回认证类型 用户类型 实名认证状态和专家认证状态
247
	 * @throws SQLException
263
	 * @throws SQLException
248
	 */
264
	 */
249
	public Professor queryAuth(Connection con, String id) throws SQLException{
265
	public Professor queryAuth(Connection con, String id) throws SQLException {
250
		int index = 1;
266
		int index = 1;
251
		String sql = " SELECT AUTHENTICATION,AUTH_TYPE,AUTH_STATUS,AUTH_STATUS_EXPERT,ORG_AUTH FROM PROFESSOR WHERE ID = ? ";
267
		String sql = " SELECT AUTHENTICATION,AUTH_TYPE,AUTH_STATUS,AUTH_STATUS_EXPERT,ORG_AUTH FROM PROFESSOR WHERE ID = ? ";
252
		PreparedStatement ps = con.prepareStatement(sql);
268
		PreparedStatement ps = con.prepareStatement(sql);
253
		try{
254
            ps.setString(index++,id);
255
            ResultSet rs = ps.executeQuery();
256
            try{
257
                if(rs.next()){
258
                	Professor professor = new Professor();
259
                	Integer auth = rs.getInt(1);
260
                    if(rs.wasNull()){
261
                    	auth = null;
262
                    }
263
                    professor.setAuthentication(auth);
264
                    professor.setAuthType(rs.getInt(2));
265
                    professor.setAuthStatus(rs.getInt(3));
266
                    professor.setAuthStatusExpert(rs.getInt(4));
267
                    professor.setOrgAuth(rs.getString(5));
268
                    return professor;
269
                }else{
270
                    return null;
271
                }
272
            }finally{
273
                try{rs.close();}catch(Exception e1){}
274
            }
275
        }finally{
276
            try{ps.close();}catch(Exception e2){}
277
        }
269
		try {
270
			ps.setString(index++, id);
271
			ResultSet rs = ps.executeQuery();
272
			try {
273
				if (rs.next()) {
274
					Professor professor = new Professor();
275
					Integer auth = rs.getInt(1);
276
					if (rs.wasNull()) {
277
						auth = null;
278
					}
279
					professor.setAuthentication(auth);
280
					professor.setAuthType(rs.getInt(2));
281
					professor.setAuthStatus(rs.getInt(3));
282
					professor.setAuthStatusExpert(rs.getInt(4));
283
					professor.setOrgAuth(rs.getString(5));
284
					return professor;
285
				} else {
286
					return null;
287
				}
288
			} finally {
289
				try {
290
					rs.close();
291
				} catch (Exception e1) {
292
				}
293
			}
294
		} finally {
295
			try {
296
				ps.close();
297
			} catch (Exception e2) {
298
			}
299
		}
278
	}
300
	}
279
	
301

280
	/**
302
	/**
281
	 * 查询专家基本信息接口
303
	 * 查询专家基本信息接口
304
	 * 
282
	 * @param con
305
	 * @param con
283
	 * @param id 专家ID
306
	 * @param id
307
	 *            专家ID
284
	 * @return 返回专家基本信息
308
	 * @return 返回专家基本信息
285
	 * @throws SQLException
309
	 * @throws SQLException
286
	 */
310
	 */
287
	public EditProfessor queryBaseInfo(Connection con, String id) throws SQLException {
311
	public EditProfessor queryBaseInfo(Connection con, String id) throws SQLException {
288
		int index = 1;
312
		int index = 1;
289
        String sql = "SELECT P.OFFICE,P.DEPARTMENT,P.TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,"
290
        		+ " P.ID,P.NAME,P.ADDRESS,P.ORG_AUTH,ORGANIZATION.NAME,P.ORG_ID,P.SCORE_PERCENT,P.SHARE_ID,P.PHONE,P.EMAIL,P.PROVINCE"
291
        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.ID = ?";
292
        PreparedStatement ps = con.prepareStatement(sql);
293
        try{
294
            ps.setString(index++,id);
295
            ResultSet rs = ps.executeQuery();
296
            try{
297
                if(rs.next()){
298
                	EditProfessor professor = new EditProfessor();
299
                	String office = rs.getString(1);
300
                	if(rs.wasNull()){
301
                		office = null;
302
                	}
303
                    professor.setOffice(office);
304
                    String depart = rs.getString(2);
305
                    if(rs.wasNull()){
306
                    	depart = null;
307
                	}
308
                    professor.setDepartment(depart);
309
                    String title = rs.getString(3);
310
                    if(rs.wasNull()){
311
                    	title = null;
312
                	}
313
                    professor.setTitle(title);
314
                    Integer auth = rs.getInt(4);
315
                    if(rs.wasNull()){
316
                    	auth = null;
317
                    }
318
                    professor.setAuthentication(auth);
319
                    professor.setAuthType(rs.getInt(5));
320
                    professor.setAuthStatus(rs.getInt(6));
321
                    professor.setId(rs.getString(7));
322
                    professor.setName(rs.getString(8));
323
                    String address = rs.getString(9);
324
                    if(rs.wasNull()){
325
                    	address = null;
326
                	}
327
                    professor.setAddress(address);
328
                    professor.setOrgAuth(rs.getString(10));
329
                    String orgName = rs.getString(11);
330
                    if(rs.wasNull()){
331
                    	orgName = null;
332
                    }
333
                    professor.setOrgName(orgName);
334
                    String orgId = rs.getString(12);
335
                    if(rs.wasNull()){
336
                    	orgId = null;
337
                    }
338
                    professor.setOrgId(orgId);
339
                    String scorePercent = rs.getString(13);
340
                    if(rs.wasNull()){
341
                    	scorePercent = null;
342
                    }
343
                    professor.setScorePercent(scorePercent);
344
                    professor.setShareId(rs.getLong(14));
345
                    String phone = rs.getString(15);
346
                    if(rs.wasNull()){
347
                    	phone = null;
348
                    }
349
                    professor.setPhone(phone);
350
                    String email = rs.getString(16);
351
                    if(rs.wasNull()){
352
                    	email = null;
353
                    }
354
                    professor.setEmail(email);
355
                    String province = rs.getString(17);
356
                    if(rs.wasNull()){
357
                    	province = null;
358
                    }
359
                    professor.setProvince(province);
360
                    
361
                    return professor;
362
                }else{
363
                    return null;
364
                }
365
            }finally{
366
                try{rs.close();}catch(Exception e1){}
367
            }
368
        }finally{
369
            try{ps.close();}catch(Exception e2){}
370
        }
313
		String sql = "SELECT P.OFFICE,P.DEPARTMENT,P.TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,"
314
				+ " P.ID,P.NAME,P.ADDRESS,P.ORG_AUTH,ORGANIZATION.NAME,P.ORG_ID,P.SCORE_PERCENT,P.SHARE_ID,P.PHONE,P.EMAIL,P.PROVINCE"
315
				+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.ID = ?";
316
		PreparedStatement ps = con.prepareStatement(sql);
317
		try {
318
			ps.setString(index++, id);
319
			ResultSet rs = ps.executeQuery();
320
			try {
321
				if (rs.next()) {
322
					EditProfessor professor = new EditProfessor();
323
					String office = rs.getString(1);
324
					if (rs.wasNull()) {
325
						office = null;
326
					}
327
					professor.setOffice(office);
328
					String depart = rs.getString(2);
329
					if (rs.wasNull()) {
330
						depart = null;
331
					}
332
					professor.setDepartment(depart);
333
					String title = rs.getString(3);
334
					if (rs.wasNull()) {
335
						title = null;
336
					}
337
					professor.setTitle(title);
338
					Integer auth = rs.getInt(4);
339
					if (rs.wasNull()) {
340
						auth = null;
341
					}
342
					professor.setAuthentication(auth);
343
					professor.setAuthType(rs.getInt(5));
344
					professor.setAuthStatus(rs.getInt(6));
345
					professor.setId(rs.getString(7));
346
					professor.setName(rs.getString(8));
347
					String address = rs.getString(9);
348
					if (rs.wasNull()) {
349
						address = null;
350
					}
351
					professor.setAddress(address);
352
					professor.setOrgAuth(rs.getString(10));
353
					String orgName = rs.getString(11);
354
					if (rs.wasNull()) {
355
						orgName = null;
356
					}
357
					professor.setOrgName(orgName);
358
					String orgId = rs.getString(12);
359
					if (rs.wasNull()) {
360
						orgId = null;
361
					}
362
					professor.setOrgId(orgId);
363
					String scorePercent = rs.getString(13);
364
					if (rs.wasNull()) {
365
						scorePercent = null;
366
					}
367
					professor.setScorePercent(scorePercent);
368
					professor.setShareId(rs.getLong(14));
369
					String phone = rs.getString(15);
370
					if (rs.wasNull()) {
371
						phone = null;
372
					}
373
					professor.setPhone(phone);
374
					String email = rs.getString(16);
375
					if (rs.wasNull()) {
376
						email = null;
377
					}
378
					professor.setEmail(email);
379
					String province = rs.getString(17);
380
					if (rs.wasNull()) {
381
						province = null;
382
					}
383
					professor.setProvince(province);
384

385
					return professor;
386
				} else {
387
					return null;
388
				}
389
			} finally {
390
				try {
391
					rs.close();
392
				} catch (Exception e1) {
393
				}
394
			}
395
		} finally {
396
			try {
397
				ps.close();
398
			} catch (Exception e2) {
399
			}
400
		}
401
	}
402

403
	public List<EditProfessor> queryByName(Connection con, String name, int total) throws SQLException {
404
		int index = 1;
405
		String sql = "SELECT P.OFFICE,P.DEPARTMENT,P.TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,P.ADDRESS,P.ORG_AUTH,ORGANIZATION.NAME,P.ORG_ID,P.SCORE_PERCENT,P.SHARE_ID "
406
				+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.NAME LIKE ? ORDER BY P.SCORE_PERCENT DESC LIMIT " + total;
407
		PreparedStatement ps = con.prepareStatement(sql);
408
		try {
409
			ps.setString(index++, name);
410
			ResultSet rs = ps.executeQuery();
411
			try {
412
				List<EditProfessor> editProfessors = new ArrayList<EditProfessor>();
413
				while (rs.next()) {
414
					EditProfessor professor = new EditProfessor();
415
					String office = rs.getString(1);
416
					if (rs.wasNull()) {
417
						office = null;
418
					}
419
					professor.setOffice(office);
420
					String depart = rs.getString(2);
421
					if (rs.wasNull()) {
422
						depart = null;
423
					}
424
					professor.setDepartment(depart);
425
					String title = rs.getString(3);
426
					if (rs.wasNull()) {
427
						title = null;
428
					}
429
					professor.setTitle(title);
430
					Integer auth = rs.getInt(4);
431
					if (rs.wasNull()) {
432
						auth = null;
433
					}
434
					professor.setAuthentication(auth);
435
					professor.setAuthType(rs.getInt(5));
436
					professor.setAuthStatus(rs.getInt(6));
437
					professor.setId(rs.getString(7));
438
					professor.setName(rs.getString(8));
439
					String address = rs.getString(9);
440
					if (rs.wasNull()) {
441
						address = null;
442
					}
443
					professor.setAddress(address);
444
					professor.setOrgAuth(rs.getString(10));
445
					String orgName = rs.getString(11);
446
					if (rs.wasNull()) {
447
						orgName = null;
448
					}
449
					professor.setOrgName(orgName);
450
					String orgId = rs.getString(12);
451
					if (rs.wasNull()) {
452
						orgId = null;
453
					}
454
					professor.setOrgId(orgId);
455
					String scorePercent = rs.getString(13);
456
					if (rs.wasNull()) {
457
						scorePercent = null;
458
					}
459
					professor.setScorePercent(scorePercent);
460
					professor.setShareId(rs.getLong(14));
461
					editProfessors.add(professor);
462
				}
463
				return editProfessors;
464
			} finally {
465
				try {
466
					rs.close();
467
				} catch (Exception e1) {
468
				}
469
			}
470
		} finally {
471
			try {
472
				ps.close();
473
			} catch (Exception e2) {
474
			}
475
		}
476
	}
477

478
	/**
479
	 * 查询专家基本信息+星级+咨询次数的接口
480
	 * 
481
	 * @param con
482
	 * @param id
483
	 *            专家ID
484
	 * @return 返回专家基本信息+星级+咨询次数
485
	 * @throws SQLException
486
	 */
487
	public EditProfessor queryEditBaseInfo(Connection con, String id) throws SQLException {
488
		int index = 1;
489
		String sql = "SELECT P.OFFICE,P.DEPARTMENT,P.TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,"
490
				+ " P.ID,P.NAME,P.ADDRESS,P.STAR_LEVEL,P.CONSULT_COUNT,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID "
491
				+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.ID = ?";
492
		PreparedStatement ps = con.prepareStatement(sql);
493
		try {
494
			ps.setString(index++, id);
495
			ResultSet rs = ps.executeQuery();
496
			try {
497
				if (rs.next()) {
498
					EditProfessor professor = new EditProfessor();
499
					String office = rs.getString(1);
500
					if (rs.wasNull()) {
501
						office = null;
502
					}
503
					professor.setOffice(office);
504
					String depart = rs.getString(2);
505
					if (rs.wasNull()) {
506
						depart = null;
507
					}
508
					professor.setDepartment(depart);
509
					String title = rs.getString(3);
510
					if (rs.wasNull()) {
511
						title = null;
512
					}
513
					professor.setTitle(title);
514
					Integer auth = rs.getInt(4);
515
					if (rs.wasNull()) {
516
						auth = null;
517
					}
518
					professor.setAuthentication(auth);
519
					professor.setAuthType(rs.getInt(5));
520
					professor.setAuthStatus(rs.getInt(6));
521
					professor.setId(rs.getString(7));
522
					professor.setName(rs.getString(8));
523
					String address = rs.getString(9);
524
					if (rs.wasNull()) {
525
						address = null;
526
					}
527
					professor.setAddress(address);
528
					professor.setStarLevel(rs.getBigDecimal(10));
529
					professor.setConsultCount(rs.getInt(11));
530
					professor.setOrgAuth(rs.getString(12));
531
					String orgName = rs.getString(13);
532
					if (rs.wasNull()) {
533
						orgName = null;
534
					}
535
					professor.setOrgName(orgName);
536
					professor.setShareId(rs.getLong(14));
537
					return professor;
538
				} else {
539
					return null;
540
				}
541
			} finally {
542
				try {
543
					rs.close();
544
				} catch (Exception e1) {
545
				}
546
			}
547
		} finally {
548
			try {
549
				ps.close();
550
			} catch (Exception e2) {
551
			}
552
		}
553
	}
554

555
	@SelectOne
556
	@Nullable
557
	public abstract Professor queryOne(Connection con, String id) throws SQLException;
558

559
	public Professor query(Connection con, String id) throws SQLException {
560
		int index = 1;
561
		String sql = "SELECT P.OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,P.DEPARTMENT,ORG_ID,P.TITLE,AUTHENTICATION,AUTH_TYPE,"
562
				+ "P.AUTH_STATUS,P.ID,P.NAME,P.DESCP,P.CREATE_TIME,P.MODIFY_TIME,P.PHONE,P.EMAIL,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID "
563
				+ "FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.ID = ?";
564
		PreparedStatement ps = con.prepareStatement(sql);
565
		try {
566
			ps.setString(index++, id);
567
			ResultSet rs = ps.executeQuery();
568
			try {
569
				if (rs.next()) {
570
					Professor professor = new Professor();
571
					String office = rs.getString(1);
572
					if (rs.wasNull()) {
573
						office = null;
574
					}
575
					professor.setOffice(office);
576
					String subject = rs.getString(2);
577
					if (rs.wasNull()) {
578
						subject = null;
579
					}
580
					professor.setSubject(subject);
581
					String industry = rs.getString(3);
582
					if (rs.wasNull()) {
583
						industry = null;
584
					}
585
					professor.setIndustry(industry);
586
					String address = rs.getString(4);
587
					if (rs.wasNull()) {
588
						address = null;
589
					}
590
					professor.setAddress(address);
591
					String department = rs.getString(5);
592
					if (rs.wasNull()) {
593
						department = null;
594
					}
595
					professor.setDepartment(department);
596
					Organization organization = new Organization();
597
					String orgId = rs.getString(6);
598
					if (rs.wasNull()) {
599
						orgId = null;
600
					}
601
					organization.setId(orgId);
602
					String title = rs.getString(7);
603
					if (rs.wasNull()) {
604
						title = null;
605
					}
606
					professor.setTitle(title);
607
					Integer auth = rs.getInt(8);
608
					if (rs.wasNull()) {
609
						auth = null;
610
					}
611
					professor.setAuthentication(auth);
612
					professor.setAuthType(rs.getInt(9));
613
					professor.setAuthStatus(rs.getInt(10));
614
					professor.setId(rs.getString(11));
615
					professor.setName(rs.getString(12));
616
					String descp = rs.getString(13);
617
					if (rs.wasNull()) {
618
						descp = null;
619
					}
620
					professor.setDescp(descp);
621
					professor.setCreateTime(rs.getString(14));
622
					professor.setModifyTime(rs.getString(15));
623
					String phone = rs.getString(16);
624
					if (rs.wasNull()) {
625
						phone = null;
626
					}
627
					professor.setPhone(phone);
628
					String email = rs.getString(17);
629
					if (rs.wasNull()) {
630
						email = null;
631
					}
632
					professor.setEmail(email);
633
					professor.setOrgAuth(rs.getString(18));
634
					String orgName = rs.getString(19);
635
					if (rs.wasNull()) {
636
						orgName = null;
637
					}
638
					organization.setName(orgName);
639
					professor.setOrganization(organization);
640
					professor.setShareId(rs.getLong(20));
641
					return professor;
642
				} else {
643
					return null;
644
				}
645
			} finally {
646
				try {
647
					rs.close();
648
				} catch (Exception e1) {
649
				}
650
			}
651
		} finally {
652
			try {
653
				ps.close();
654
			} catch (Exception e2) {
655
			}
656
		}
657
	}
658

659
	public List<Professor> query(Connection con) throws SQLException {
660
		String sql = "SELECT OFFICE,P.SUBJECT,P.INDUSTRY,P.PROVINCE,P.ADDRESS,DEPARTMENT,ORG_ID,organization.NAME AS ONAME,"
661
				+ " TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME AS PNAME,P.DESCP,P.CREATE_TIME,P.MODIFY_TIME,P.ORG_AUTH,P.SHARE_ID "
662
				+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=organization.ID ORDER BY ONAME,P.ID";
663
		PreparedStatement ps = con.prepareStatement(sql);
664
		try {
665
			ResultSet rs = ps.executeQuery();
666
			try {
667
				List<Professor> professors = new ArrayList<Professor>();
668
				while (rs.next()) {
669
					Professor professor = new Professor();
670
					String office = rs.getString(1);
671
					if (rs.wasNull()) {
672
						office = null;
673
					}
674
					professor.setOffice(office);
675
					String subject = rs.getString(2);
676
					if (rs.wasNull()) {
677
						subject = null;
678
					}
679
					professor.setSubject(subject);
680
					String industry = rs.getString(3);
681
					if (rs.wasNull()) {
682
						industry = null;
683
					}
684
					professor.setIndustry(industry);
685
					String province = rs.getString(4);
686
					if (rs.wasNull()) {
687
						province = null;
688
					}
689
					professor.setProvince(province);
690
					String address = rs.getString(5);
691
					if (rs.wasNull()) {
692
						address = null;
693
					}
694
					professor.setAddress(address);
695
					professor.setDepartment(rs.getString(6));
696
					Organization organization = new Organization();
697
					String orgId = rs.getString(7);
698
					if (rs.wasNull()) {
699
						orgId = null;
700
					}
701
					organization.setId(orgId);
702
					String orgName = rs.getString(8);
703
					if (rs.wasNull()) {
704
						orgName = null;
705
					}
706
					organization.setName(orgName);
707
					professor.setOrganization(organization);
708
					professor.setTitle(rs.getString(9));
709
					Integer auth = rs.getInt(10);
710
					if (rs.wasNull()) {
711
						auth = null;
712
					}
713
					professor.setAuthentication(auth);
714
					professor.setAuthType(rs.getInt(11));
715
					professor.setAuthStatus(rs.getInt(12));
716
					professor.setId(rs.getString(13));
717
					professor.setName(rs.getString(14));
718
					String descp = rs.getString(15);
719
					if (rs.wasNull()) {
720
						descp = null;
721
					}
722
					professor.setDescp(descp);
723
					professor.setCreateTime(rs.getString(16));
724
					professor.setModifyTime(rs.getString(17));
725
					professor.setOrgAuth(rs.getString(18));
726
					professor.setShareId(rs.getLong(19));
727
					professors.add(professor);
728
				}
729
				return professors;
730
			} finally {
731
				try {
732
					rs.close();
733
				} catch (Exception e1) {
734
				}
735
			}
736
		} finally {
737
			try {
738
				ps.close();
739
			} catch (Exception e2) {
740
			}
741
		}
742
	}
743

744
	public PageQueryResult<EditProfessor> queryPage(Connection con, String orgId, String orgAuth, int pageSize, int pageNo) throws SQLException {
745
		int total = 0;
746
		PageQueryResult<EditProfessor> queryResult = new PageQueryResult<EditProfessor>();
747
		int index = 1;
748
		boolean hasOrgAuth = null != orgAuth;
749
		String sql = null;
750
		sql = " WHERE ORG_ID = ? ";
751
		if (hasOrgAuth) {
752
			sql = sql + " AND ORG_AUTH = ?";
753
		}
754
		String whereSql = sql;
755
		sql = "SELECT COUNT(1) FROM PROFESSOR";
756
		sql = sql + whereSql;
757
		PreparedStatement ps = con.prepareStatement(sql);
758
		try {
759
			ps.setString(index++, orgId);
760
			if (hasOrgAuth) {
761
				ps.setString(index++, orgAuth);
762
			}
763
			queryResult.setPageSize(pageSize);
764
			ResultSet rs = ps.executeQuery();
765
			try {
766
				rs.next();
767
				total = rs.getInt(1);
768
			} finally {
769
				try {
770
					rs.close();
771
				} catch (Exception e1) {
772
				}
773
			}
774
		} finally {
775
			try {
776
				ps.close();
777
			} catch (Exception e2) {
778
			}
779
		}
780
		queryResult.setTotal(total);
781
		if (0 == total) {
782
			queryResult.setPageNo(1);
783
			queryResult.setData(Collections.<EditProfessor> emptyList());
784
			return queryResult;
785
		}
786
		index = 1;
787
		boolean firstPage = (1 == pageNo);
788
		if (firstPage) {
789
			queryResult.setPageNo(1);
790
			sql = "SELECT OFFICE,DEPARTMENT,TITLE,AUTHENTICATION,AUTH_TYPE,AUTH_STATUS,ID,NAME,ADDRESS,ORG_AUTH,SHARE_ID FROM PROFESSOR";
791
			sql = sql + whereSql;
792
			sql = sql + " ORDER BY AUTH_TYPE DESC,ID";
793
			sql = sql + " LIMIT " + pageSize;
794
		} else {
795
			int pageNum = total / pageSize;
796
			if (total % pageSize != 0) {
797
				++pageNum;
798
			}
799
			if (pageNo > pageNum) {
800
				pageNo = pageNum;
801
			}
802
			queryResult.setPageNo(pageNo);
803
			--pageNo;
804
			int offset = (pageNo * pageSize);
805
			sql = "SELECT OFFICE,DEPARTMENT,TITLE,AUTHENTICATION,AUTH_TYPE,AUTH_STATUS,ID,NAME,ADDRESS,ORG_AUTH FROM PROFESSOR";
806
			sql = sql + whereSql;
807
			sql = sql + " ORDER BY AUTH_TYPE DESC,ID";
808
			sql = sql + " LIMIT " + pageSize + " OFFSET " + offset;
809
		}
810
		ps = con.prepareStatement(sql);
811
		try {
812
			ps.setString(index++, orgId);
813
			if (hasOrgAuth) {
814
				ps.setString(index++, orgAuth);
815
			}
816
			ResultSet rs = ps.executeQuery();
817
			try {
818
				List<EditProfessor> professors = new ArrayList<EditProfessor>();
819
				queryResult.setData(professors);
820
				int size = 0;
821
				while ((size < pageSize) && rs.next()) {
822
					++size;
823
					EditProfessor professor = new EditProfessor();
824
					String office = rs.getString(1);
825
					if (rs.wasNull()) {
826
						office = null;
827
					}
828
					professor.setOffice(office);
829
					String depart = rs.getString(2);
830
					if (rs.wasNull()) {
831
						depart = null;
832
					}
833
					professor.setDepartment(depart);
834
					String title = rs.getString(3);
835
					if (rs.wasNull()) {
836
						title = null;
837
					}
838
					professor.setTitle(title);
839
					Integer auth = rs.getInt(4);
840
					if (rs.wasNull()) {
841
						auth = null;
842
					}
843
					professor.setAuthentication(auth);
844
					professor.setAuthType(rs.getInt(5));
845
					professor.setAuthStatus(rs.getInt(6));
846
					professor.setId(rs.getString(7));
847
					professor.setName(rs.getString(8));
848
					String address = rs.getString(9);
849
					if (rs.wasNull()) {
850
						address = null;
851
					}
852
					professor.setAddress(address);
853
					professor.setOrgAuth(rs.getString(10));
854
					professor.setShareId(rs.getLong(11));
855
					professors.add(professor);
856
				}
857
				return queryResult;
858
			} finally {
859
				try {
860
					rs.close();
861
				} catch (Exception e3) {
862
				}
863
			}
864
		} finally {
865
			try {
866
				ps.close();
867
			} catch (Exception e4) {
868
			}
869
		}
371
	}
870
	}
372
	
373
	public List<EditProfessor> queryByName(Connection con,String name,int total) throws SQLException{
374
        int index = 1;
375
        String sql = "SELECT P.OFFICE,P.DEPARTMENT,P.TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,P.ADDRESS,P.ORG_AUTH,ORGANIZATION.NAME,P.ORG_ID,P.SCORE_PERCENT,P.SHARE_ID "
376
        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.NAME LIKE ? ORDER BY P.SCORE_PERCENT DESC LIMIT " + total;
377
        PreparedStatement ps = con.prepareStatement(sql);
378
        try{
379
            ps.setString(index++,name);
380
            ResultSet rs = ps.executeQuery();
381
            try{
382
                List<EditProfessor> editProfessors = new ArrayList<EditProfessor>();
383
                while(rs.next()){
384
                	EditProfessor professor =  new EditProfessor();
385
                	String office = rs.getString(1);
386
                	if(rs.wasNull()){
387
                		office = null;
388
                	}
389
                    professor.setOffice(office);
390
                    String depart = rs.getString(2);
391
                    if(rs.wasNull()){
392
                    	depart = null;
393
                	}
394
                    professor.setDepartment(depart);
395
                    String title = rs.getString(3);
396
                    if(rs.wasNull()){
397
                    	title = null;
398
                	}
399
                    professor.setTitle(title);
400
                    Integer auth = rs.getInt(4);
401
                    if(rs.wasNull()){
402
                    	auth = null;
403
                    }
404
                    professor.setAuthentication(auth);
405
                    professor.setAuthType(rs.getInt(5));
406
                    professor.setAuthStatus(rs.getInt(6));
407
                    professor.setId(rs.getString(7));
408
                    professor.setName(rs.getString(8));
409
                    String address = rs.getString(9);
410
                    if(rs.wasNull()){
411
                    	address = null;
412
                	}
413
                    professor.setAddress(address);
414
                    professor.setOrgAuth(rs.getString(10));
415
                    String orgName = rs.getString(11);
416
                    if(rs.wasNull()){
417
                    	orgName = null;
418
                    }
419
                    professor.setOrgName(orgName);
420
                    String orgId = rs.getString(12);
421
                    if(rs.wasNull()){
422
                    	orgId = null;
423
                    }
424
                    professor.setOrgId(orgId);
425
                    String scorePercent = rs.getString(13);
426
                    if(rs.wasNull()){
427
                    	scorePercent = null;
428
                    }
429
                    professor.setScorePercent(scorePercent);
430
                    professor.setShareId(rs.getLong(14));
431
                    editProfessors.add(professor);
432
                }
433
                return editProfessors;
434
            }finally{
435
                try{rs.close();}catch(Exception e1){}
436
            }
437
        }finally{
438
            try{ps.close();}catch(Exception e2){}
439
        }
440
    }
441
	
442
	/**
443
	 * 查询专家基本信息+星级+咨询次数的接口
444
	 * @param con
445
	 * @param id 专家ID
446
	 * @return 返回专家基本信息+星级+咨询次数
447
	 * @throws SQLException
448
	 */
449
	public EditProfessor queryEditBaseInfo(Connection con, String id) throws SQLException {
871

872
	public List<EditProfessor> queryByOrg(Connection con, String orgId, String orgAuth) throws SQLException {
450
		int index = 1;
873
		int index = 1;
451
        String sql = "SELECT P.OFFICE,P.DEPARTMENT,P.TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,"
452
        		+ " P.ID,P.NAME,P.ADDRESS,P.STAR_LEVEL,P.CONSULT_COUNT,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID "
453
        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.ID = ?";
454
        PreparedStatement ps = con.prepareStatement(sql);
455
        try{
456
            ps.setString(index++,id);
457
            ResultSet rs = ps.executeQuery();
458
            try{
459
                if(rs.next()){
460
                	EditProfessor professor = new EditProfessor();
461
                	String office = rs.getString(1);
462
                	if(rs.wasNull()){
463
                		office = null;
464
                	}
465
                    professor.setOffice(office);
466
                    String depart = rs.getString(2);
467
                	if(rs.wasNull()){
468
                		depart = null;
469
                	}
470
                    professor.setDepartment(depart);
471
                    String title = rs.getString(3);
472
                	if(rs.wasNull()){
473
                		title = null;
474
                	}
475
                    professor.setTitle(title);
476
                    Integer auth = rs.getInt(4);
477
                    if(rs.wasNull()){
478
                    	auth = null;
479
                    }
480
                    professor.setAuthentication(auth);
481
                    professor.setAuthType(rs.getInt(5));
482
                    professor.setAuthStatus(rs.getInt(6));
483
                    professor.setId(rs.getString(7));
484
                    professor.setName(rs.getString(8));
485
                    String address = rs.getString(9);
486
                	if(rs.wasNull()){
487
                		address = null;
488
                	}
489
                    professor.setAddress(address);
490
                    professor.setStarLevel(rs.getBigDecimal(10));
491
                    professor.setConsultCount(rs.getInt(11));
492
                    professor.setOrgAuth(rs.getString(12));
493
                    String orgName = rs.getString(13);
494
                    if(rs.wasNull()){
495
                    	orgName = null;
496
                    }
497
                    professor.setOrgName(orgName);
498
                    professor.setShareId(rs.getLong(14));
499
                    return professor;
500
                }else{
501
                    return null;
502
                }
503
            }finally{
504
                try{rs.close();}catch(Exception e1){}
505
            }
506
        }finally{
507
            try{ps.close();}catch(Exception e2){}
508
        }
874
		boolean hasOrgAuth = null != orgAuth;
875
		StringBuilder sql = new StringBuilder();
876
		sql.append("SELECT OFFICE,DEPARTMENT,TITLE,AUTHENTICATION,AUTH_TYPE,AUTH_STATUS,ID,NAME,ADDRESS,ORG_AUTH,SHARE_ID FROM PROFESSOR");
877
		sql.append(" WHERE ORG_ID = ?");
878
		if (hasOrgAuth) {
879
			sql.append(" AND ORG_AUTH = ?");
880
		}
881
		sql.append(" ORDER BY AUTH_TYPE DESC,ID");
882
		PreparedStatement ps = con.prepareStatement(sql.toString());
883
		try {
884
			ps.setString(index++, orgId);
885
			if (hasOrgAuth) {
886
				ps.setString(index++, orgAuth);
887
			}
888
			ResultSet rs = ps.executeQuery();
889
			try {
890
				List<EditProfessor> professors = new ArrayList<EditProfessor>();
891
				while (rs.next()) {
892
					EditProfessor professor = new EditProfessor();
893
					String office = rs.getString(1);
894
					if (rs.wasNull()) {
895
						office = null;
896
					}
897
					professor.setOffice(office);
898
					String depart = rs.getString(2);
899
					if (rs.wasNull()) {
900
						depart = null;
901
					}
902
					professor.setDepartment(depart);
903
					String title = rs.getString(3);
904
					if (rs.wasNull()) {
905
						title = null;
906
					}
907
					professor.setTitle(title);
908
					Integer auth = rs.getInt(4);
909
					if (rs.wasNull()) {
910
						auth = null;
911
					}
912
					professor.setAuthentication(auth);
913
					professor.setAuthType(rs.getInt(5));
914
					professor.setAuthStatus(rs.getInt(6));
915
					professor.setId(rs.getString(7));
916
					professor.setName(rs.getString(8));
917
					String address = rs.getString(9);
918
					if (rs.wasNull()) {
919
						address = null;
920
					}
921
					professor.setAddress(address);
922
					professor.setOrgAuth(rs.getString(10));
923
					professor.setShareId(rs.getLong(11));
924
					professors.add(professor);
925
				}
926
				return professors;
927
			} finally {
928
				try {
929
					rs.close();
930
				} catch (Exception e1) {
931
				}
932
			}
933
		} finally {
934
			try {
935
				ps.close();
936
			} catch (Exception e2) {
937
			}
938
		}
509
	}
939
	}
510
	
511
	@SelectOne
512
	@Nullable
513
	public abstract Professor queryOne(Connection con, String id) throws SQLException;
514
	
515
	public Professor query(Connection con, String id) throws SQLException{
516
        int index = 1;
517
        String sql = "SELECT P.OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,P.DEPARTMENT,ORG_ID,P.TITLE,AUTHENTICATION,AUTH_TYPE,"
518
        		+ "P.AUTH_STATUS,P.ID,P.NAME,P.DESCP,P.CREATE_TIME,P.MODIFY_TIME,P.PHONE,P.EMAIL,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID "
519
        		+ "FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.ID = ?";
520
        PreparedStatement ps = con.prepareStatement(sql);
521
        try{
522
            ps.setString(index++,id);
523
            ResultSet rs = ps.executeQuery();
524
            try{
525
                if(rs.next()){
526
                    Professor professor = new Professor();
527
                    String office = rs.getString(1);
528
                    if(rs.wasNull()){
529
                    	office = null;
530
                    }
531
                    professor.setOffice(office);
532
                    String subject = rs.getString(2);
533
                    if(rs.wasNull()){
534
                    	subject = null;
535
                    }
536
                    professor.setSubject(subject);
537
                    String industry = rs.getString(3);
538
                    if(rs.wasNull()){
539
                    	industry = null;
540
                    }
541
                    professor.setIndustry(industry);
542
                    String address = rs.getString(4);
543
                    if(rs.wasNull()){
544
                    	address = null;
545
                    }
546
                    professor.setAddress(address);
547
                    String department = rs.getString(5);
548
                    if(rs.wasNull()){
549
                    	department = null;
550
                    }
551
                    professor.setDepartment(department);
552
                    Organization organization = new Organization();
553
                    String orgId = rs.getString(6);
554
                    if(rs.wasNull()){
555
                    	orgId = null;
556
                    }
557
                    organization.setId(orgId);
558
                    String title = rs.getString(7);
559
                    if(rs.wasNull()){
560
                    	title = null;
561
                    }
562
                    professor.setTitle(title);
563
                    Integer auth = rs.getInt(8);
564
                    if(rs.wasNull()){
565
                    	auth = null;
566
                    }
567
                    professor.setAuthentication(auth);
568
                    professor.setAuthType(rs.getInt(9));
569
                    professor.setAuthStatus(rs.getInt(10));
570
                    professor.setId(rs.getString(11));
571
                    professor.setName(rs.getString(12));
572
                    String descp = rs.getString(13);
573
                    if(rs.wasNull()){
574
                    	descp = null;
575
                    }
576
                    professor.setDescp(descp);
577
                    professor.setCreateTime(rs.getString(14));
578
                    professor.setModifyTime(rs.getString(15));
579
                    String phone = rs.getString(16);
580
                    if(rs.wasNull()){
581
                    	phone = null;
582
                    }
583
                    professor.setPhone(phone);
584
                    String email = rs.getString(17);
585
                    if(rs.wasNull()){
586
                    	email = null;
587
                    }
588
                    professor.setEmail(email);
589
                    professor.setOrgAuth(rs.getString(18));
590
                    String orgName = rs.getString(19);
591
                    if(rs.wasNull()){
592
                    	orgName = null;
593
                    }
594
                    organization.setName(orgName);
595
                    professor.setOrganization(organization);
596
                    professor.setShareId(rs.getLong(20));
597
                    return professor;
598
                }else{
599
                    return null;
600
                }
601
            }finally{
602
                try{rs.close();}catch(Exception e1){}
603
            }
604
        }finally{
605
            try{ps.close();}catch(Exception e2){}
606
        }
607
    }
608

940

609
	public List<Professor> query(Connection con) throws SQLException{
610
        String sql = "SELECT OFFICE,P.SUBJECT,P.INDUSTRY,P.PROVINCE,P.ADDRESS,DEPARTMENT,ORG_ID,organization.NAME AS ONAME,"
611
        		+ " TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME AS PNAME,P.DESCP,P.CREATE_TIME,P.MODIFY_TIME,P.ORG_AUTH,P.SHARE_ID "
612
        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=organization.ID ORDER BY ONAME,P.ID";
613
        PreparedStatement ps = con.prepareStatement(sql);
614
        try{
615
            ResultSet rs = ps.executeQuery();
616
            try{
617
                List<Professor> professors = new ArrayList<Professor>();
618
                while(rs.next()){
619
                    Professor professor =  new Professor();
620
                    String office = rs.getString(1);
621
                    if(rs.wasNull()){
622
                    	office = null;
623
                    }
624
                    professor.setOffice(office);
625
                    String subject = rs.getString(2);
626
                    if(rs.wasNull()){
627
                    	subject = null;
628
                    }
629
                    professor.setSubject(subject);
630
                    String industry = rs.getString(3);
631
                    if(rs.wasNull()){
632
                    	industry = null;
633
                    }
634
                    professor.setIndustry(industry);
635
                    String province = rs.getString(4);
636
                    if(rs.wasNull()){
637
                    	province = null;
638
                    }
639
                    professor.setProvince(province);
640
                    String address = rs.getString(5);
641
                    if(rs.wasNull()){
642
                    	address = null;
643
                    }
644
                    professor.setAddress(address);
645
                    professor.setDepartment(rs.getString(6));
646
                    Organization organization = new Organization();
647
                    String orgId = rs.getString(7);
648
                    if(rs.wasNull()){
649
                    	orgId = null;
650
                    }
651
                    organization.setId(orgId);
652
                    String orgName = rs.getString(8);
653
                    if(rs.wasNull()){
654
                    	orgName = null;
655
                    }
656
                    organization.setName(orgName);
657
                    professor.setOrganization(organization);
658
                    professor.setTitle(rs.getString(9));
659
                    Integer auth = rs.getInt(10);
660
                    if(rs.wasNull()){
661
                    	auth = null;
662
                    }
663
                    professor.setAuthentication(auth);
664
                    professor.setAuthType(rs.getInt(11));
665
                    professor.setAuthStatus(rs.getInt(12));
666
                    professor.setId(rs.getString(13));
667
                    professor.setName(rs.getString(14));
668
                    String descp = rs.getString(15);
669
                    if(rs.wasNull()){
670
                    	descp = null;
671
                    }
672
                    professor.setDescp(descp);
673
                    professor.setCreateTime(rs.getString(16));
674
                    professor.setModifyTime(rs.getString(17));
675
                    professor.setOrgAuth(rs.getString(18));
676
                    professor.setShareId(rs.getLong(19));
677
                    professors.add(professor);
678
                }
679
                return professors;
680
            }finally{
681
                try{rs.close();}catch(Exception e1){}
682
            }
683
        }finally{
684
            try{ps.close();}catch(Exception e2){}
685
        }
686
    }
687
	
688
	public PageQueryResult<EditProfessor> queryPage(Connection con,String orgId,String orgAuth,int pageSize,int pageNo) throws SQLException{
689
        int total = 0;
690
        PageQueryResult<EditProfessor> queryResult = new PageQueryResult<EditProfessor>();
691
        int index = 1;
692
        boolean hasOrgAuth = null != orgAuth;
693
        String sql = null;
694
        sql = " WHERE ORG_ID = ? ";
695
        if(hasOrgAuth){
696
            sql = sql + " AND ORG_AUTH = ?";
697
        }
698
        String whereSql = sql;
699
        sql = "SELECT COUNT(1) FROM PROFESSOR";
700
        sql = sql + whereSql;
701
        PreparedStatement ps = con.prepareStatement(sql);
702
        try{
703
            ps.setString(index++,orgId);
704
            if(hasOrgAuth){
705
            	ps.setString(index++,orgAuth);
706
            }
707
            queryResult.setPageSize(pageSize);
708
            ResultSet rs = ps.executeQuery();
709
            try{
710
                rs.next();
711
                total = rs.getInt(1);
712
            }finally{
713
                try{rs.close();}catch(Exception e1){}
714
            }
715
        }finally{
716
            try{ps.close();}catch(Exception e2){}
717
        }
718
        queryResult.setTotal(total);
719
        if(0== total){
720
            queryResult.setPageNo(1);
721
            queryResult.setData(Collections.<EditProfessor>emptyList());
722
            return queryResult;
723
        }
724
        index = 1;
725
        boolean firstPage = (1 == pageNo);
726
        if(firstPage){
727
            queryResult.setPageNo(1);
728
            sql = "SELECT OFFICE,DEPARTMENT,TITLE,AUTHENTICATION,AUTH_TYPE,AUTH_STATUS,ID,NAME,ADDRESS,ORG_AUTH,SHARE_ID FROM PROFESSOR";
729
            sql = sql + whereSql;
730
            sql = sql + " ORDER BY AUTH_TYPE DESC,ID";
731
            sql = sql + " LIMIT " + pageSize;
732
        }else{
733
            int pageNum = total / pageSize;
734
            if(total % pageSize != 0){
735
                ++pageNum;
736
            }
737
            if(pageNo > pageNum){
738
                pageNo = pageNum;
739
            }
740
            queryResult.setPageNo(pageNo);
741
            --pageNo;
742
            int offset = (pageNo * pageSize);
743
            sql = "SELECT OFFICE,DEPARTMENT,TITLE,AUTHENTICATION,AUTH_TYPE,AUTH_STATUS,ID,NAME,ADDRESS,ORG_AUTH FROM PROFESSOR";
744
            sql = sql + whereSql;
745
            sql = sql + " ORDER BY AUTH_TYPE DESC,ID";
746
            sql = sql + " LIMIT " + pageSize+ " OFFSET " + offset;
747
        }
748
        ps = con.prepareStatement(sql);
749
        try{
750
            ps.setString(index++,orgId);
751
            if(hasOrgAuth){
752
            	ps.setString(index++,orgAuth);
753
            }
754
            ResultSet rs = ps.executeQuery();
755
            try{
756
                List<EditProfessor> professors = new ArrayList<EditProfessor>();
757
                queryResult.setData(professors);
758
                int size = 0;
759
                while((size<pageSize) && rs.next()){
760
                    ++size;
761
                    EditProfessor professor =  new EditProfessor();
762
                    String office = rs.getString(1);
763
                	if(rs.wasNull()){
764
                		office = null;
765
                	}
766
                    professor.setOffice(office);
767
                    String depart = rs.getString(2);
768
                    if(rs.wasNull()){
769
                    	depart = null;
770
                	}
771
                    professor.setDepartment(depart);
772
                    String title = rs.getString(3);
773
                    if(rs.wasNull()){
774
                    	title = null;
775
                	}
776
                    professor.setTitle(title);
777
                    Integer auth = rs.getInt(4);
778
                    if(rs.wasNull()){
779
                    	auth = null;
780
                    }
781
                    professor.setAuthentication(auth);
782
                    professor.setAuthType(rs.getInt(5));
783
                    professor.setAuthStatus(rs.getInt(6));
784
                    professor.setId(rs.getString(7));
785
                    professor.setName(rs.getString(8));
786
                    String address = rs.getString(9);
787
                    if(rs.wasNull()){
788
                    	address = null;
789
                	}
790
                    professor.setAddress(address);
791
                    professor.setOrgAuth(rs.getString(10));
792
                    professor.setShareId(rs.getLong(11));
793
                    professors.add(professor);
794
                }
795
                return queryResult;
796
            }finally{
797
                try{rs.close();}catch(Exception e3){}
798
            }
799
        }finally{
800
            try{ps.close();}catch(Exception e4){}
801
        }
802
    }
803
	
804
	public List<EditProfessor> queryByOrg(Connection con,String orgId,String orgAuth) throws SQLException{
805
        int index = 1;
806
        boolean hasOrgAuth = null != orgAuth;
807
        StringBuilder sql = new StringBuilder();
808
        sql.append("SELECT OFFICE,DEPARTMENT,TITLE,AUTHENTICATION,AUTH_TYPE,AUTH_STATUS,ID,NAME,ADDRESS,ORG_AUTH,SHARE_ID FROM PROFESSOR");
809
        sql.append(" WHERE ORG_ID = ?");
810
        if(hasOrgAuth){
811
            sql.append(" AND ORG_AUTH = ?");
812
        }
813
        sql.append(" ORDER BY AUTH_TYPE DESC,ID");
814
        PreparedStatement ps = con.prepareStatement(sql.toString());
815
        try{
816
            ps.setString(index++,orgId);
817
            if(hasOrgAuth){
818
                ps.setString(index++,orgAuth);
819
            }
820
            ResultSet rs = ps.executeQuery();
821
            try{
822
                List<EditProfessor> professors = new ArrayList<EditProfessor>();
823
                while(rs.next()){
824
                	EditProfessor professor = new EditProfessor();
825
                	String office = rs.getString(1);
826
                	if(rs.wasNull()){
827
                		office = null;
828
                	}
829
                    professor.setOffice(office);
830
                    String depart = rs.getString(2);
831
                    if(rs.wasNull()){
832
                    	depart = null;
833
                	}
834
                    professor.setDepartment(depart);
835
                    String title = rs.getString(3);
836
                    if(rs.wasNull()){
837
                    	title = null;
838
                	}
839
                    professor.setTitle(title);
840
                    Integer auth = rs.getInt(4);
841
                    if(rs.wasNull()){
842
                    	auth = null;
843
                    }
844
                    professor.setAuthentication(auth);
845
                    professor.setAuthType(rs.getInt(5));
846
                    professor.setAuthStatus(rs.getInt(6));
847
                    professor.setId(rs.getString(7));
848
                    professor.setName(rs.getString(8));
849
                    String address = rs.getString(9);
850
                    if(rs.wasNull()){
851
                    	address = null;
852
                	}
853
                    professor.setAddress(address);
854
                    professor.setOrgAuth(rs.getString(10));
855
                    professor.setShareId(rs.getLong(11));
856
                    professors.add(professor);
857
                }
858
                return professors;
859
            }finally{
860
                try{rs.close();}catch(Exception e1){}
861
            }
862
        }finally{
863
            try{ps.close();}catch(Exception e2){}
864
        }
865
    }
866
	
867
	/**
941
	/**
868
	 * 查询所有专家的咨询星级和咨询完成次数
942
	 * 查询所有专家的咨询星级和咨询完成次数
943
	 * 
869
	 * @param con
944
	 * @param con
870
	 * @return
945
	 * @return
871
	 * @throws SQLException
946
	 * @throws SQLException
872
	 */
947
	 */
873
	public List<Professor> queryStar(Connection con) throws SQLException{
948
	public List<Professor> queryStar(Connection con) throws SQLException {
874
		String sql = "SELECT ID,STAR_LEVEL,CONSULT_COUNT FROM PROFESSOR ";
949
		String sql = "SELECT ID,STAR_LEVEL,CONSULT_COUNT FROM PROFESSOR ";
875
        PreparedStatement ps = con.prepareStatement(sql);
876
        try{
877
            ResultSet rs = ps.executeQuery();
878
            try{
879
                List<Professor> professors = new ArrayList<Professor>();
880
                while(rs.next()){
881
                    Professor professor =  new Professor();
882
                    professor.setId(rs.getString(1));
883
                    professor.setStarLevel(rs.getBigDecimal(2));
884
                    professor.setConsultCount(rs.getInt(3));
885
                    professors.add(professor);
886
                }
887
                return professors;
888
            }finally{
889
                try{rs.close();}catch(Exception e1){}
890
            }
891
        }finally{
892
            try{ps.close();}catch(Exception e2){}
893
        }
950
		PreparedStatement ps = con.prepareStatement(sql);
951
		try {
952
			ResultSet rs = ps.executeQuery();
953
			try {
954
				List<Professor> professors = new ArrayList<Professor>();
955
				while (rs.next()) {
956
					Professor professor = new Professor();
957
					professor.setId(rs.getString(1));
958
					professor.setStarLevel(rs.getBigDecimal(2));
959
					professor.setConsultCount(rs.getInt(3));
960
					professors.add(professor);
961
				}
962
				return professors;
963
			} finally {
964
				try {
965
					rs.close();
966
				} catch (Exception e1) {
967
				}
968
			}
969
		} finally {
970
			try {
971
				ps.close();
972
			} catch (Exception e2) {
973
			}
974
		}
894
	}
975
	}
895

976

896
	/**
977
	/**
897
	 * 查询所有专家咨询星级的最大值
978
	 * 查询所有专家咨询星级的最大值
979
	 * 
898
	 * @param con
980
	 * @param con
899
	 * @return
981
	 * @return
900
	 * @throws SQLException
982
	 * @throws SQLException
901
	 */
983
	 */
902
	@QueryVal
984
	@QueryVal
903
	@Column(handlerClass=BigDecimalHandler.class,value={"MAX(STAR_LEVEL)"})
985
	@Column(handlerClass = BigDecimalHandler.class, value = { "MAX(STAR_LEVEL)" })
904
	@From(Professor.class)
986
	@From(Professor.class)
905
	public abstract BigDecimal queryBigStar(Connection con)throws SQLException, JfwBaseException;
906
	
987
	public abstract BigDecimal queryBigStar(Connection con) throws SQLException, JfwBaseException;
988

907
	/**
989
	/**
908
	 * 查询所有专家咨询星级的最小值
990
	 * 查询所有专家咨询星级的最小值
991
	 * 
909
	 * @param con
992
	 * @param con
910
	 * @return
993
	 * @return
911
	 * @throws SQLException
994
	 * @throws SQLException
912
	 */
995
	 */
913
	@QueryVal
996
	@QueryVal
914
	@Column(handlerClass=BigDecimalHandler.class,value={"MIN(STAR_LEVEL)"})
997
	@Column(handlerClass = BigDecimalHandler.class, value = { "MIN(STAR_LEVEL)" })
915
	@From(Professor.class)
998
	@From(Professor.class)
916
	public abstract BigDecimal querySmallStar(Connection con)throws SQLException, JfwBaseException;
917
	
999
	public abstract BigDecimal querySmallStar(Connection con) throws SQLException, JfwBaseException;
1000

918
	/**
1001
	/**
919
	 * 查询所有专家咨询次数的最大值
1002
	 * 查询所有专家咨询次数的最大值
1003
	 * 
920
	 * @param con
1004
	 * @param con
921
	 * @return
1005
	 * @return
922
	 * @throws SQLException
1006
	 * @throws SQLException
923
	 */
1007
	 */
924
	@QueryVal
1008
	@QueryVal
925
	@Column(handlerClass=BigDecimalHandler.class,value={"MAX(CONSULT_COUNT)"})
1009
	@Column(handlerClass = BigDecimalHandler.class, value = { "MAX(CONSULT_COUNT)" })
926
	@From(Professor.class)
1010
	@From(Professor.class)
927
	public abstract BigDecimal queryBigConsult(Connection con)throws SQLException, JfwBaseException;
928
	
1011
	public abstract BigDecimal queryBigConsult(Connection con) throws SQLException, JfwBaseException;
1012

929
	/**
1013
	/**
930
	 * 查询所有专家咨询次数的最小值
1014
	 * 查询所有专家咨询次数的最小值
1015
	 * 
931
	 * @param con
1016
	 * @param con
932
	 * @return
1017
	 * @return
933
	 * @throws SQLException
1018
	 * @throws SQLException
934
	 */
1019
	 */
935
	@QueryVal
1020
	@QueryVal
936
	@Column(handlerClass=BigDecimalHandler.class,value={"MIN(CONSULT_COUNT)"})
1021
	@Column(handlerClass = BigDecimalHandler.class, value = { "MIN(CONSULT_COUNT)" })
937
	@From(Professor.class)
1022
	@From(Professor.class)
938
	public abstract BigDecimal querySmallConsult(Connection con)throws SQLException, JfwBaseException;
939
	
1023
	public abstract BigDecimal querySmallConsult(Connection con) throws SQLException, JfwBaseException;
1024

940
	@Nullable
1025
	@Nullable
941
	@QueryOne
1026
	@QueryOne
942
	@From(Professor.class)
1027
	@From(Professor.class)
957

1042

958
	/**
1043
	/**
959
	 * 首页搜索热门专家
1044
	 * 首页搜索热门专家
1045
	 * 
960
	 * @param con
1046
	 * @param con
961
	 * @return 返回8个热门专家,按咨询星级排序
1047
	 * @return 返回8个热门专家,按咨询星级排序
962
	 * @throws SQLException
1048
	 * @throws SQLException
1001
			queryResult.setPageNo(1);
1087
			queryResult.setPageNo(1);
1002
			sql = new StringBuilder();
1088
			sql = new StringBuilder();
1003
			sql.append("SELECT OFFICE,P.ADDRESS,TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_ID,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID"
1089
			sql.append("SELECT OFFICE,P.ADDRESS,TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_ID,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID"
1004
	        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=ORGANIZATION.ID ");
1090
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=ORGANIZATION.ID ");
1005
			if (whereSql.length() > 0) {
1091
			if (whereSql.length() > 0) {
1006
				sql.append(whereSql);
1092
				sql.append(whereSql);
1007
			}
1093
			}
1020
			int offset = (pageNo * pageSize);
1106
			int offset = (pageNo * pageSize);
1021
			sql = new StringBuilder();
1107
			sql = new StringBuilder();
1022
			sql.append("SELECT OFFICE,P.ADDRESS,TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_ID,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID"
1108
			sql.append("SELECT OFFICE,P.ADDRESS,TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_ID,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID"
1023
	        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=ORGANIZATION.ID ");
1109
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=ORGANIZATION.ID ");
1024
			if (whereSql.length() > 0) {
1110
			if (whereSql.length() > 0) {
1025
				sql.append(whereSql);
1111
				sql.append(whereSql);
1026
			}
1112
			}
1034
				List<EditProfessor> professors = new ArrayList<EditProfessor>();
1120
				List<EditProfessor> professors = new ArrayList<EditProfessor>();
1035
				queryResult.setData(professors);
1121
				queryResult.setData(professors);
1036
				while (rs.next()) {
1122
				while (rs.next()) {
1037
					EditProfessor professor =  new EditProfessor();
1038
                    String office = rs.getString(1);
1039
                    if(rs.wasNull()){
1040
                    	office = null;
1041
                    }
1042
                    professor.setOffice(office);
1043
                    String address = rs.getString(2);
1044
                    if(rs.wasNull()){
1045
                    	address = null;
1046
                    }
1047
                    professor.setAddress(address);
1048
                    String title = rs.getString(3);
1049
                    if(rs.wasNull()){
1050
                    	title = null;
1051
                    }
1052
                    professor.setTitle(title);
1053
                    Integer auth = rs.getInt(4);
1054
                    if(rs.wasNull()){
1055
                    	auth = null;
1056
                    }
1057
                    professor.setAuthentication(auth);
1058
                    professor.setAuthType(rs.getInt(5));
1059
                    professor.setAuthStatus(rs.getInt(6));
1060
                    professor.setId(rs.getString(7));
1061
                    professor.setName(rs.getString(8));
1062
                    professor.setOrgId(rs.getString(9));
1063
                    professor.setOrgAuth(rs.getString(10));
1064
                    String orgName = rs.getString(11);
1065
                    if(rs.wasNull()){
1066
                    	orgName = null;
1067
                    }
1068
                    professor.setOrgName(orgName);
1069
                    professor.setShareId(rs.getLong(12));
1070
                    professors.add(professor);
1123
					EditProfessor professor = new EditProfessor();
1124
					String office = rs.getString(1);
1125
					if (rs.wasNull()) {
1126
						office = null;
1127
					}
1128
					professor.setOffice(office);
1129
					String address = rs.getString(2);
1130
					if (rs.wasNull()) {
1131
						address = null;
1132
					}
1133
					professor.setAddress(address);
1134
					String title = rs.getString(3);
1135
					if (rs.wasNull()) {
1136
						title = null;
1137
					}
1138
					professor.setTitle(title);
1139
					Integer auth = rs.getInt(4);
1140
					if (rs.wasNull()) {
1141
						auth = null;
1142
					}
1143
					professor.setAuthentication(auth);
1144
					professor.setAuthType(rs.getInt(5));
1145
					professor.setAuthStatus(rs.getInt(6));
1146
					professor.setId(rs.getString(7));
1147
					professor.setName(rs.getString(8));
1148
					professor.setOrgId(rs.getString(9));
1149
					professor.setOrgAuth(rs.getString(10));
1150
					String orgName = rs.getString(11);
1151
					if (rs.wasNull()) {
1152
						orgName = null;
1153
					}
1154
					professor.setOrgName(orgName);
1155
					professor.setShareId(rs.getLong(12));
1156
					professors.add(professor);
1071
				}
1157
				}
1072
				return queryResult;
1158
				return queryResult;
1073
			} finally {
1159
			} finally {
1083
			}
1169
			}
1084
		}
1170
		}
1085
	}
1171
	}
1086
	
1172

1087
	/**
1173
	/**
1088
	 * APP专家搜索列表分页多条件查询
1174
	 * APP专家搜索列表分页多条件查询
1175
	 * 
1089
	 * @param con
1176
	 * @param con
1090
	 * @param key
1177
	 * @param key
1091
	 * @param subject 学术领域
1092
	 * @param industry 应用行业
1093
	 * @param province 所在省份
1094
	 * @param address 所在城市
1095
	 * @param authentication 是否认证
1096
	 * @param pageSize 
1178
	 * @param subject
1179
	 *            学术领域
1180
	 * @param industry
1181
	 *            应用行业
1182
	 * @param province
1183
	 *            所在省份
1184
	 * @param address
1185
	 *            所在城市
1186
	 * @param authentication
1187
	 *            是否认证
1188
	 * @param pageSize
1097
	 * @param pageNo
1189
	 * @param pageNo
1098
	 * @return 按搜索条件返回专家列表  按咨询星级排序
1190
	 * @return 按搜索条件返回专家列表 按咨询星级排序
1099
	 * @throws SQLException
1191
	 * @throws SQLException
1100
	 */
1192
	 */
1101
	public PageQueryResult<EditProfessor> queryAPP(Connection con, @Nullable String key, String subject, String industry, 
1102
			String province, String address, Integer authType, int pageSize, int pageNo) throws SQLException {
1193
	public PageQueryResult<EditProfessor> queryAPP(Connection con, @Nullable String key, String subject, String industry, String province, String address,
1194
			Integer authType, int pageSize, int pageNo) throws SQLException {
1103
		PageQueryResult<EditProfessor> queryResult = new PageQueryResult<EditProfessor>();
1195
		PageQueryResult<EditProfessor> queryResult = new PageQueryResult<EditProfessor>();
1104
		StringBuilder sql = new StringBuilder();
1196
		StringBuilder sql = new StringBuilder();
1105
		boolean hasKey = null != key;
1197
		boolean hasKey = null != key;
1106
		if (hasKey) {
1198
		if (hasKey) {
1107
			sql.append(" WHERE (( P.ID IN (SELECT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)) "
1199
			sql.append(" WHERE (( P.ID IN (SELECT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)) "
1108
				+ " OR (ORG_ID IN(SELECT ORGANIZATION.ID FROM ORGANIZATION WHERE ORGANIZATION.NAME LIKE ?)) "
1109
				+ " OR ( P.NAME LIKE ?) OR (P.SUBJECT LIKE ?) OR (P.INDUSTRY LIKE ?) OR (P.PROVINCE LIKE ?) OR (P.ADDRESS LIKE ?) "
1110
				+ " OR P.ID IN (SELECT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?) "
1111
				+ " OR P.ID IN (SELECT PROFESSOR_ID FROM ARTICLE WHERE ARTICLE_TITLE LIKE ?) "
1112
				+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM PATENT WHERE NAME LIKE ?)) OR (P.DEPARTMENT LIKE ?))");
1200
					+ " OR (ORG_ID IN(SELECT ORGANIZATION.ID FROM ORGANIZATION WHERE ORGANIZATION.NAME LIKE ?)) "
1201
					+ " OR ( P.NAME LIKE ?) OR (P.SUBJECT LIKE ?) OR (P.INDUSTRY LIKE ?) OR (P.PROVINCE LIKE ?) OR (P.ADDRESS LIKE ?) "
1202
					+ " OR P.ID IN (SELECT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?) "
1203
					+ " OR P.ID IN (SELECT PROFESSOR_ID FROM ARTICLE WHERE ARTICLE_TITLE LIKE ?) "
1204
					+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM PATENT WHERE NAME LIKE ?)) OR (P.DEPARTMENT LIKE ?))");
1113
		}
1205
		}
1114
		boolean hasSubject = null != subject;
1206
		boolean hasSubject = null != subject;
1115
		boolean hasIndustry = null != industry;
1207
		boolean hasIndustry = null != industry;
1197
			queryResult.setPageNo(1);
1289
			queryResult.setPageNo(1);
1198
			sql = new StringBuilder();
1290
			sql = new StringBuilder();
1199
			sql.append("SELECT OFFICE,P.ADDRESS,TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_ID,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID"
1291
			sql.append("SELECT OFFICE,P.ADDRESS,TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_ID,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID"
1200
	        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=ORGANIZATION.ID ");
1292
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=ORGANIZATION.ID ");
1201
			if (whereSql.length() > 0) {
1293
			if (whereSql.length() > 0) {
1202
				sql.append(whereSql);
1294
				sql.append(whereSql);
1203
			}
1295
			}
1216
			int offset = (pageNo * pageSize);
1308
			int offset = (pageNo * pageSize);
1217
			sql = new StringBuilder();
1309
			sql = new StringBuilder();
1218
			sql.append("SELECT OFFICE,P.ADDRESS,TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_ID,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID"
1310
			sql.append("SELECT OFFICE,P.ADDRESS,TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,ORG_ID,P.ORG_AUTH,ORGANIZATION.NAME,P.SHARE_ID"
1219
	        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=ORGANIZATION.ID ");
1311
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID=ORGANIZATION.ID ");
1220
			if (whereSql.length() > 0) {
1312
			if (whereSql.length() > 0) {
1221
				sql.append(whereSql);
1313
				sql.append(whereSql);
1222
			}
1314
			}
1258
				List<EditProfessor> professors = new ArrayList<EditProfessor>();
1350
				List<EditProfessor> professors = new ArrayList<EditProfessor>();
1259
				queryResult.setData(professors);
1351
				queryResult.setData(professors);
1260
				while (rs.next()) {
1352
				while (rs.next()) {
1261
					EditProfessor professor =  new EditProfessor();
1262
                    String office = rs.getString(1);
1263
                    if(rs.wasNull()){
1264
                    	office = null;
1265
                    }
1266
                    professor.setOffice(office);
1267
                    String addr = rs.getString(2);
1268
                    if(rs.wasNull()){
1269
                    	addr = null;
1270
                    }
1271
                    professor.setAddress(addr);
1272
                    String title = rs.getString(3);
1273
                    if(rs.wasNull()){
1274
                    	title = null;
1275
                    }
1276
                    professor.setTitle(title);
1277
                    Integer auth = rs.getInt(4);
1278
                    if(rs.wasNull()){
1279
                    	auth = null;
1280
                    }
1281
                    professor.setAuthentication(auth);
1282
                    professor.setAuthType(rs.getInt(5));
1283
                    professor.setAuthStatus(rs.getInt(6));
1284
                    professor.setId(rs.getString(7));
1285
                    professor.setName(rs.getString(8));
1286
                    professor.setOrgId(rs.getString(9));
1287
                    professor.setOrgAuth(rs.getString(10));
1288
                    String orgName = rs.getString(11);
1289
                    if(rs.wasNull()){
1290
                    	orgName = null;
1291
                    }
1292
                    professor.setOrgName(orgName);
1293
                    professor.setShareId(rs.getLong(12));
1294
                    professors.add(professor);
1353
					EditProfessor professor = new EditProfessor();
1354
					String office = rs.getString(1);
1355
					if (rs.wasNull()) {
1356
						office = null;
1357
					}
1358
					professor.setOffice(office);
1359
					String addr = rs.getString(2);
1360
					if (rs.wasNull()) {
1361
						addr = null;
1362
					}
1363
					professor.setAddress(addr);
1364
					String title = rs.getString(3);
1365
					if (rs.wasNull()) {
1366
						title = null;
1367
					}
1368
					professor.setTitle(title);
1369
					Integer auth = rs.getInt(4);
1370
					if (rs.wasNull()) {
1371
						auth = null;
1372
					}
1373
					professor.setAuthentication(auth);
1374
					professor.setAuthType(rs.getInt(5));
1375
					professor.setAuthStatus(rs.getInt(6));
1376
					professor.setId(rs.getString(7));
1377
					professor.setName(rs.getString(8));
1378
					professor.setOrgId(rs.getString(9));
1379
					professor.setOrgAuth(rs.getString(10));
1380
					String orgName = rs.getString(11);
1381
					if (rs.wasNull()) {
1382
						orgName = null;
1383
					}
1384
					professor.setOrgName(orgName);
1385
					professor.setShareId(rs.getLong(12));
1386
					professors.add(professor);
1295
				}
1387
				}
1296
				return queryResult;
1388
				return queryResult;
1297
			} finally {
1389
			} finally {
1307
			}
1399
			}
1308
		}
1400
		}
1309
	}
1401
	}
1310
	
1402

1311
	/**
1403
	/**
1312
	 * 分页查询专家基础信息,多条件查询专家列表。
1404
	 * 分页查询专家基础信息,多条件查询专家列表。
1405
	 * 
1313
	 * @param con
1406
	 * @param con
1314
	 * @param key 搜索信息
1315
	 * @param subject 学术领域
1316
	 * @param industry 应用行业
1317
	 * @param address 所在城市
1318
	 * @param pageSize 
1407
	 * @param key
1408
	 *            搜索信息
1409
	 * @param subject
1410
	 *            学术领域
1411
	 * @param industry
1412
	 *            应用行业
1413
	 * @param address
1414
	 *            所在城市
1415
	 * @param pageSize
1319
	 * @param pageNo
1416
	 * @param pageNo
1320
	 * @return 返回专家信息列表
1417
	 * @return 返回专家信息列表
1321
	 * @throws SQLException
1418
	 * @throws SQLException
1322
	 */
1419
	 */
1323
	public PageQueryResult<EditProfessor> queryEditBaseInfo(Connection con, @Nullable String key, String subject, 
1324
			String industry, String address, Integer authType, int pageSize, int pageNo) throws SQLException {
1420
	public PageQueryResult<EditProfessor> queryEditBaseInfo(Connection con, @Nullable String key, String subject, String industry, String address,
1421
			Integer authType, int pageSize, int pageNo) throws SQLException {
1325
		PageQueryResult<EditProfessor> queryResult = new PageQueryResult<EditProfessor>();
1422
		PageQueryResult<EditProfessor> queryResult = new PageQueryResult<EditProfessor>();
1326
		StringBuilder sql = new StringBuilder();
1423
		StringBuilder sql = new StringBuilder();
1327
		boolean hasKey = null != key;
1424
		boolean hasKey = null != key;
1328
		if (hasKey) {
1425
		if (hasKey) {
1329
//			sql.append("((NAME LIKE ?) OR")
1330
//			.append("(ORG_ID IN (SELECT ID FROM FROM ORGANIZATION WHERE NAME LIKE ?)) OR")
1331
//			.append("( DEPARTMENT LIKE ?) OR")
1332
//			.append("( DESCP LIKE ?) OR")
1333
//			.append("( SUBJECT LIKE ? ) OR")
1334
//			.append("( INDUSTRY LIKE ? ) OR")
1335
//			.append("(ID IN (SELECT DISTINCT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)) OR")
1336
//			.append("(ID IN (SELECT DISTINCT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)) OR")
1337
//			.append("(ID IN (SELECT DISTINCT PROFESSOR_ID FROM ARTICLE WHERE ARTICLE_TITLE LIKE ?)) OR")
1338
//			.append("(ID IN ) OR ")
1339
//			
1340
//			   .append("");
1341
			
1342
			
1343
			sql.append(" WHERE ((P.ID IN (SELECT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)) "
1344
					+ " OR (ORG_ID IN(SELECT ORGANIZATION.ID FROM ORGANIZATION WHERE ORGANIZATION.NAME LIKE ?)) "
1345
					+ " OR (P.NAME LIKE ?) OR (P.SUBJECT LIKE ?) OR (P.INDUSTRY LIKE ?) OR (P.ADDRESS LIKE ?)"
1346
					+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)) "
1347
					+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM ARTICLE WHERE ARTICLE_TITLE LIKE ?)) "
1348
					+ " OR (P.ID IN (SELECT PROFESSOR_ID FROM PATENT WHERE NAME LIKE ?)) OR (P.DEPARTMENT LIKE ?) )");
1426
			sql.append("((P.NAME LIKE ?) OR")
1427
					.append("(O.NAME LIKE ?)) OR")
1428
					.append("( P.DEPARTMENT LIKE ?) OR")
1429
					.append("( P.DESCP LIKE ?) OR")
1430
					.append("( P.SUBJECT LIKE ? ) OR")
1431
					.append("( P.INDUSTRY LIKE ? ) OR")
1432
					.append("(P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM RESEARCH_AREA WHERE CAPTION LIKE ?)) OR")
1433
					.append("(P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)) OR")
1434
					.append("(P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM ARTICLE WHERE ARTICLE_TITLE LIKE ?)) OR")
1435
					.append("(P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM PAPER_AUTHOR WHERE PAPER_ID IN (SELECT ID FROM PPAPER WHERE NAME LIKE '%'))) OR ")
1436
					.append("(P.ID IN (SELECT DISTINCT PROFESSOR_ID FROM PATENT_AUTHOR WHERE PATENT_ID IN (SELECT ID FROM PPATENT WHERE NAME LIKE '%')))")
1437
					.append(")");
1438
			//
1439
			//
1440
			// sql.append(" WHERE ((P.ID IN (SELECT PROFESSOR_ID FROM
1441
			// RESEARCH_AREA WHERE CAPTION LIKE ?)) "
1442
			// + " OR (ORG_ID IN(SELECT ORGANIZATION.ID FROM ORGANIZATION WHERE
1443
			// ORGANIZATION.NAME LIKE ?)) "
1444
			// + " OR (P.NAME LIKE ?) OR (P.SUBJECT LIKE ?) OR (P.INDUSTRY LIKE
1445
			// ?) OR (P.ADDRESS LIKE ?)"
1446
			// + " OR (P.ID IN (SELECT PROFESSOR_ID FROM RESOURCE WHERE
1447
			// RESOURCE_NAME LIKE ?)) "
1448
			// + " OR (P.ID IN (SELECT PROFESSOR_ID FROM ARTICLE WHERE
1449
			// ARTICLE_TITLE LIKE ?)) "
1450
			// + " OR (P.ID IN (SELECT PROFESSOR_ID FROM PATENT WHERE NAME LIKE
1451
			// ?)) OR (P.DEPARTMENT LIKE ?) )");
1349
		}
1452
		}
1350
		boolean hasSubject = null != subject;
1453
		boolean hasSubject = null != subject;
1351
		boolean hasIndustry = null != industry;
1454
		boolean hasIndustry = null != industry;
1352
		boolean hasAddress = null != address;
1455
		boolean hasAddress = null != address;
1353
		boolean hasAuthType = null != authType;
1456
		boolean hasAuthType = null != authType;
1354
		if (hasSubject) {
1457
		if (hasSubject) {
1355
			sql.append(sql.length() > 0 ? " AND " : " WHERE ").append("(P.SUBJECT LIKE ?)");
1458
			sql.append(sql.length() > 0 ? " AND " : " WHERE ").append("(SUBJECT LIKE ?)");
1356
		}
1459
		}
1357
		if (hasIndustry) {
1460
		if (hasIndustry) {
1358
			sql.append(sql.length() > 0 ? " AND " : " WHERE ").append("(P.INDUSTRY LIKE ?)");
1461
			sql.append(sql.length() > 0 ? " AND " : " WHERE ").append("(INDUSTRY LIKE ?)");
1359
		}
1462
		}
1360
		if (hasAddress) {
1463
		if (hasAddress) {
1361
			sql.append(sql.length() > 0 ? " AND " : " WHERE ").append("(P.ADDRESS LIKE ?)");
1464
			sql.append(sql.length() > 0 ? " AND " : " WHERE ").append("(ADDRESS LIKE ?)");
1362
		}
1465
		}
1363
		if (hasAuthType) {
1466
		if (hasAuthType) {
1364
			sql.append(sql.length() > 0 ? " AND " : " WHERE ").append("(P.AUTH_TYPE = ?)");
1467
			sql.append(sql.length() > 0 ? " AND " : " WHERE ").append("(AUTH_TYPE = ?)");
1365
		}
1468
		}
1366

1469

1367
		StringBuilder whereSql = sql;
1470
		StringBuilder whereSql = sql;
1368
		sql = new StringBuilder();
1471
		sql = new StringBuilder();
1369
		sql.append("SELECT COUNT(1) FROM PROFESSOR P");
1472
		sql.append("SELECT COUNT(1) FROM PROFESSOR P LEFT JOIN ORGANIZATION O ON P.ORG_ID=O.ID ");
1370
		if (whereSql.length() > 0) {
1473
		if (whereSql.length() > 0) {
1371
			sql.append(whereSql);
1474
			sql.append(whereSql);
1372
		}
1475
		}
1385
				ps.setString(paramIndex++, key);
1488
				ps.setString(paramIndex++, key);
1386
				ps.setString(paramIndex++, key);
1489
				ps.setString(paramIndex++, key);
1387
				ps.setString(paramIndex++, key);
1490
				ps.setString(paramIndex++, key);
1491
				ps.setString(paramIndex++, key);
1388
			}
1492
			}
1389
			if (hasSubject) {
1493
			if (hasSubject) {
1390
				ps.setString(paramIndex++, subject);
1494
				ps.setString(paramIndex++, subject);
1425
		if (1 == pageNo) {
1529
		if (1 == pageNo) {
1426
			queryResult.setPageNo(1);
1530
			queryResult.setPageNo(1);
1427
			sql = new StringBuilder();
1531
			sql = new StringBuilder();
1428
			sql.append("SELECT OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,DEPARTMENT,ORGANIZATION.NAME,TITLE,"
1429
					+ " AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,STAR_LEVEL,CONSULT_COUNT,P.ORG_AUTH,P.SHARE_ID "
1430
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON ORG_ID=ORGANIZATION.ID ");
1532
			sql.append("SELECT P.OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,DEPARTMENT,ORGANIZATION.NAME,TITLE,"
1533
					+ " AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,STAR_LEVEL,CONSULT_COUNT,P.ORG_AUTH,P.SHARE_ID,P.SORT_FIRST "
1534
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION O ON P.ORG_ID=O.ID ");
1431
			if (whereSql.length() > 0) {
1535
			if (whereSql.length() > 0) {
1432
				sql.append(whereSql);
1536
				sql.append(whereSql);
1433
			}
1537
			}
1446
			int offset = (pageNo * pageSize);
1550
			int offset = (pageNo * pageSize);
1447
			sql = new StringBuilder();
1551
			sql = new StringBuilder();
1448
			sql.append("SELECT OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,DEPARTMENT,ORGANIZATION.NAME,TITLE,"
1552
			sql.append("SELECT OFFICE,P.SUBJECT,P.INDUSTRY,P.ADDRESS,DEPARTMENT,ORGANIZATION.NAME,TITLE,"
1449
					+ " AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,STAR_LEVEL,CONSULT_COUNT,P.ORG_AUTH,P.SHARE_ID "
1450
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON ORG_ID=ORGANIZATION.ID ");
1553
					+ " AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,STAR_LEVEL,CONSULT_COUNT,P.ORG_AUTH,P.SHARE_ID,P.SORT_FIRST "
1554
					+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION O ON P.ORG_ID=O.ID ");
1451
			if (whereSql.length() > 0) {
1555
			if (whereSql.length() > 0) {
1452
				sql.append(whereSql);
1556
				sql.append(whereSql);
1453
			}
1557
			}
1487
				while (rs.next()) {
1591
				while (rs.next()) {
1488
					EditProfessor professor = new EditProfessor();
1592
					EditProfessor professor = new EditProfessor();
1489
					String office = rs.getString(1);
1593
					String office = rs.getString(1);
1490
                    if(rs.wasNull()){
1491
                    	office = null;
1492
                    }
1493
                    professor.setOffice(office);
1494
                    String subj = rs.getString(2);
1495
                    if(rs.wasNull()){
1496
                    	subj = null;
1497
                    }
1594
					if (rs.wasNull()) {
1595
						office = null;
1596
					}
1597
					professor.setOffice(office);
1598
					String subj = rs.getString(2);
1599
					if (rs.wasNull()) {
1600
						subj = null;
1601
					}
1498
					professor.setSubject(subj);
1602
					professor.setSubject(subj);
1499
					String indus = rs.getString(3);
1603
					String indus = rs.getString(3);
1500
					if(rs.wasNull()){
1604
					if (rs.wasNull()) {
1501
						indus = null;
1605
						indus = null;
1502
					}
1606
					}
1503
					professor.setIndustry(indus);
1607
					professor.setIndustry(indus);
1504
					String addr = rs.getString(4);
1608
					String addr = rs.getString(4);
1505
					if(rs.wasNull()){
1609
					if (rs.wasNull()) {
1506
						addr = null;
1610
						addr = null;
1507
					}
1611
					}
1508
					professor.setAddress(addr);
1612
					professor.setAddress(addr);
1509
					String depart = rs.getString(5);
1613
					String depart = rs.getString(5);
1510
					if(rs.wasNull()){
1614
					if (rs.wasNull()) {
1511
						depart = null;
1615
						depart = null;
1512
					}
1616
					}
1513
					professor.setDepartment(depart);
1617
					professor.setDepartment(depart);
1514
					String orgName = rs.getString(6);
1618
					String orgName = rs.getString(6);
1515
					if(rs.wasNull()){
1619
					if (rs.wasNull()) {
1516
						orgName = null;
1620
						orgName = null;
1517
					}
1621
					}
1518
					professor.setOrgName(orgName);
1622
					professor.setOrgName(orgName);
1519
					String title = rs.getString(7);
1623
					String title = rs.getString(7);
1520
					if(rs.wasNull()){
1624
					if (rs.wasNull()) {
1521
						title = null;
1625
						title = null;
1522
					}
1626
					}
1523
					professor.setTitle(title);
1627
					professor.setTitle(title);
1524
					Integer auth = rs.getInt(8);
1628
					Integer auth = rs.getInt(8);
1525
                    if(rs.wasNull()){
1526
                    	auth = null;
1527
                    }
1528
                    professor.setAuthentication(auth);
1629
					if (rs.wasNull()) {
1630
						auth = null;
1631
					}
1632
					professor.setAuthentication(auth);
1529
					professor.setAuthType(rs.getInt(9));
1633
					professor.setAuthType(rs.getInt(9));
1530
					professor.setAuthStatus(rs.getInt(10));
1634
					professor.setAuthStatus(rs.getInt(10));
1531
					professor.setId(rs.getString(11));
1635
					professor.setId(rs.getString(11));
1550
			}
1654
			}
1551
		}
1655
		}
1552
	}
1656
	}
1553
	
1657

1554
	public PageQueryResult<Professor> query(Connection con, @Nullable String key, String subject, String industry, String address, int pageSize, int pageNo)
1658
	public PageQueryResult<Professor> query(Connection con, @Nullable String key, String subject, String industry, String address, int pageSize, int pageNo)
1555
			throws SQLException {
1659
			throws SQLException {
1556

1660

1700
					}
1804
					}
1701
					professor.setIndustry(industry2);
1805
					professor.setIndustry(industry2);
1702
					String addr = rs.getString(4);
1806
					String addr = rs.getString(4);
1703
					if(rs.wasNull()){
1807
					if (rs.wasNull()) {
1704
						addr = null;
1808
						addr = null;
1705
					}
1809
					}
1706
					professor.setAddress(addr);
1810
					professor.setAddress(addr);
1707
					String depart = rs.getString(5);
1811
					String depart = rs.getString(5);
1708
					if(rs.wasNull()){
1812
					if (rs.wasNull()) {
1709
						depart = null;
1813
						depart = null;
1710
					}
1814
					}
1711
					professor.setDepartment(depart);
1815
					professor.setDepartment(depart);
1712
					Organization organization = new Organization();
1816
					Organization organization = new Organization();
1713
					String orgId = rs.getString(6);
1817
					String orgId = rs.getString(6);
1714
                    if(rs.wasNull()){
1715
                    	orgId = null;
1716
                    }
1717
                    organization.setId(orgId);
1718
                    String orgName = rs.getString(7);
1719
                    if(rs.wasNull()){
1720
                    	orgName = null;
1721
                    }
1722
                    organization.setName(orgName);
1818
					if (rs.wasNull()) {
1819
						orgId = null;
1820
					}
1821
					organization.setId(orgId);
1822
					String orgName = rs.getString(7);
1823
					if (rs.wasNull()) {
1824
						orgName = null;
1825
					}
1826
					organization.setName(orgName);
1723
					professor.setOrganization(organization);
1827
					professor.setOrganization(organization);
1724
					String title = rs.getString(8);
1828
					String title = rs.getString(8);
1725
					if(rs.wasNull()){
1829
					if (rs.wasNull()) {
1726
						title = null;
1830
						title = null;
1727
					}
1831
					}
1728
					professor.setTitle(title);
1832
					professor.setTitle(title);
1729
					Integer auth = rs.getInt(9);
1833
					Integer auth = rs.getInt(9);
1730
                    if(rs.wasNull()){
1731
                    	auth = null;
1732
                    }
1733
                    professor.setAuthentication(auth);
1834
					if (rs.wasNull()) {
1835
						auth = null;
1836
					}
1837
					professor.setAuthentication(auth);
1734
					professor.setId(rs.getString(10));
1838
					professor.setId(rs.getString(10));
1735
					professor.setName(rs.getString(11));
1839
					professor.setName(rs.getString(11));
1736
					String descp = rs.getString(12);
1840
					String descp = rs.getString(12);
1758
			}
1862
			}
1759
		}
1863
		}
1760
	}
1864
	}
1761
	
1762
	public PageQueryResult<UserInfo> queryUserInfo(Connection con,String key,String address,Integer authType,String orgName,Integer activeState,int pageSize,int pageNo) throws SQLException{
1865

1866
	public PageQueryResult<UserInfo> queryUserInfo(Connection con, String key, String address, Integer authType, String orgName, Integer activeState,
1867
			int pageSize, int pageNo) throws SQLException {
1763
		PageQueryResult<UserInfo> queryResult = new PageQueryResult<UserInfo>();
1868
		PageQueryResult<UserInfo> queryResult = new PageQueryResult<UserInfo>();
1764
		StringBuilder sql = new StringBuilder();
1869
		StringBuilder sql = new StringBuilder();
1765
		boolean hasKey = null != key;
1870
		boolean hasKey = null != key;
1902
				while (rs.next()) {
2007
				while (rs.next()) {
1903
					UserInfo userInfo = new UserInfo();
2008
					UserInfo userInfo = new UserInfo();
1904
					String office = rs.getString(1);
2009
					String office = rs.getString(1);
1905
                    if(rs.wasNull()){
1906
                    	office = null;
1907
                    }
1908
                    userInfo.setOffice(office);
1909
                    String subj = rs.getString(2);
1910
                    if(rs.wasNull()){
1911
                    	subj = null;
1912
                    }
1913
                    userInfo.setSubject(subj);
2010
					if (rs.wasNull()) {
2011
						office = null;
2012
					}
2013
					userInfo.setOffice(office);
2014
					String subj = rs.getString(2);
2015
					if (rs.wasNull()) {
2016
						subj = null;
2017
					}
2018
					userInfo.setSubject(subj);
1914
					String indus = rs.getString(3);
2019
					String indus = rs.getString(3);
1915
					if(rs.wasNull()){
2020
					if (rs.wasNull()) {
1916
						indus = null;
2021
						indus = null;
1917
					}
2022
					}
1918
					userInfo.setIndustry(indus);
2023
					userInfo.setIndustry(indus);
1919
					String addr = rs.getString(4);
2024
					String addr = rs.getString(4);
1920
					if(rs.wasNull()){
2025
					if (rs.wasNull()) {
1921
						addr = null;
2026
						addr = null;
1922
					}
2027
					}
1923
					userInfo.setAddress(addr);
2028
					userInfo.setAddress(addr);
1924
					String depart = rs.getString(5);
2029
					String depart = rs.getString(5);
1925
					if(rs.wasNull()){
2030
					if (rs.wasNull()) {
1926
						depart = null;
2031
						depart = null;
1927
					}
2032
					}
1928
					userInfo.setDepartment(depart);
2033
					userInfo.setDepartment(depart);
1929
					String org = rs.getString(6);
2034
					String org = rs.getString(6);
1930
					if(rs.wasNull()){
2035
					if (rs.wasNull()) {
1931
						org = null;
2036
						org = null;
1932
					}
2037
					}
1933
					userInfo.setOrgName(org);
2038
					userInfo.setOrgName(org);
1934
					String title = rs.getString(7);
2039
					String title = rs.getString(7);
1935
					if(rs.wasNull()){
2040
					if (rs.wasNull()) {
1936
						title = null;
2041
						title = null;
1937
					}
2042
					}
1938
					userInfo.setTitle(title);
2043
					userInfo.setTitle(title);
1939
					Integer auth = rs.getInt(8);
2044
					Integer auth = rs.getInt(8);
1940
					if(rs.wasNull()){
2045
					if (rs.wasNull()) {
1941
						auth = null;
2046
						auth = null;
1942
					}
2047
					}
1943
					userInfo.setAuthentication(auth);
2048
					userInfo.setAuthentication(auth);
1948
					userInfo.setEmail(rs.getString(13));
2053
					userInfo.setEmail(rs.getString(13));
1949
					userInfo.setPhone(rs.getString(14));
2054
					userInfo.setPhone(rs.getString(14));
1950
					userInfo.setActiveTime(rs.getString(15));
2055
					userInfo.setActiveTime(rs.getString(15));
1951
					userInfo.setActiveState(!(rs.getString(15)==null));
2056
					userInfo.setActiveState(!(rs.getString(15) == null));
1952
					userInfo.setOrgAuth(rs.getString(16));
2057
					userInfo.setOrgAuth(rs.getString(16));
1953
					userInfo.setShareId(rs.getLong(17));
2058
					userInfo.setShareId(rs.getLong(17));
1954
					userInfos.add(userInfo);
2059
					userInfos.add(userInfo);
1967
			}
2072
			}
1968
		}
2073
		}
1969
	}
2074
	}
1970
	public String[] queryProfessorIdWithSameKeyWord(Connection con,String id,int rows)throws SQLException{
2075

2076
	public String[] queryProfessorIdWithSameKeyWord(Connection con, String id, int rows) throws SQLException {
1971
		List<String> ret = new ArrayList<String>();
2077
		List<String> ret = new ArrayList<String>();
1972
		String sql = "select id,count(1) sort from pro_key_word where kw in (select kw from pro_key_word where id=?) and id <>? group by id order by sort desc limit ?";
2078
		String sql = "select id,count(1) sort from pro_key_word where kw in (select kw from pro_key_word where id=?) and id <>? group by id order by sort desc limit ?";
1973
		PreparedStatement ps = con.prepareStatement(sql);
2079
		PreparedStatement ps = con.prepareStatement(sql);
1974
		try{
2080
		try {
1975
			ps.setString(1, id);
2081
			ps.setString(1, id);
1976
			ps.setString(2, id);
2082
			ps.setString(2, id);
1977
			ps.setInt(3, rows);
2083
			ps.setInt(3, rows);
1978
			ResultSet rs = ps.executeQuery();
2084
			ResultSet rs = ps.executeQuery();
1979
			try{
1980
				while(rs.next()){
2085
			try {
2086
				while (rs.next()) {
1981
					ret.add(rs.getString(1));
2087
					ret.add(rs.getString(1));
1982
				}
2088
				}
1983
			}finally{
1984
				try{rs.close();}catch(Exception e1){}
2089
			} finally {
2090
				try {
2091
					rs.close();
2092
				} catch (Exception e1) {
2093
				}
2094
			}
2095
		} finally {
2096
			try {
2097
				ps.close();
2098
			} catch (Exception e2) {
1985
			}
2099
			}
1986
		}finally{
1987
			try{ps.close();}catch(Exception e2){}
1988
		}
2100
		}
1989
		return ret.isEmpty()?null:ret.toArray(new String[ret.size()]);		
2101
		return ret.isEmpty() ? null : ret.toArray(new String[ret.size()]);
1990
	}
2102
	}
2103

1991
	@SelectList
2104
	@SelectList
1992
	public abstract List<Professor> query(Connection con,@In String[] id)throws SQLException; 
2105
	public abstract List<Professor> query(Connection con, @In String[] id) throws SQLException;
1993
}
2106
}