|
@ -10,15 +10,22 @@ import java.util.Collections;
|
10
|
10
|
import java.util.List;
|
11
|
11
|
|
12
|
12
|
import org.jfw.apt.annotation.Autowrie;
|
|
13
|
import org.jfw.apt.annotation.DefaultValue;
|
13
|
14
|
import org.jfw.apt.annotation.Nullable;
|
|
15
|
import org.jfw.apt.orm.annotation.dao.Column;
|
14
|
16
|
import org.jfw.apt.orm.annotation.dao.DAO;
|
15
|
17
|
import org.jfw.apt.orm.annotation.dao.method.From;
|
|
18
|
import org.jfw.apt.orm.annotation.dao.method.Where;
|
16
|
19
|
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
|
17
|
20
|
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
|
|
21
|
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
|
18
|
22
|
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
|
19
|
23
|
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
|
20
|
24
|
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
|
|
25
|
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
|
21
|
26
|
import org.jfw.apt.orm.annotation.dao.param.Set;
|
|
27
|
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
|
|
28
|
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
|
22
|
29
|
import org.jfw.util.PageQueryResult;
|
23
|
30
|
|
24
|
31
|
import com.ekexiu.portal.po.Image;
|
|
@ -30,7 +37,7 @@ import com.ekexiu.portal.po.Resource;
|
30
|
37
|
public abstract class OperationDao {
|
31
|
38
|
@Autowrie
|
32
|
39
|
private ImageDao imageDao;
|
33
|
|
|
|
40
|
|
34
|
41
|
public ImageDao getImageDao() {
|
35
|
42
|
return imageDao;
|
36
|
43
|
}
|
|
@ -41,833 +48,907 @@ public abstract class OperationDao {
|
41
|
48
|
|
42
|
49
|
@Insert
|
43
|
50
|
public abstract int insert(Connection con, Operation operation) throws SQLException;
|
44
|
|
|
|
51
|
|
45
|
52
|
@Update
|
46
|
53
|
public abstract int update(Connection con, Operation operation) throws SQLException;
|
47
|
|
|
|
54
|
|
48
|
55
|
@UpdateWith
|
49
|
56
|
@From(Operation.class)
|
50
|
57
|
public abstract int updateDetailDemand(Connection con, String operationId, @Set String detailDemand) throws SQLException;
|
51
|
|
|
|
58
|
|
52
|
59
|
@UpdateWith
|
53
|
60
|
@From(Operation.class)
|
54
|
61
|
public abstract int updateOperationStatus(Connection con, String operationId, @Set int operationStatus) throws SQLException;
|
55
|
|
|
|
62
|
|
56
|
63
|
@UpdateWith
|
57
|
64
|
@From(Operation.class)
|
58
|
65
|
public abstract int updateDeliverTime(Connection con, String operationId, @Set String deliverTime) throws SQLException;
|
59
|
|
|
|
66
|
|
60
|
67
|
@UpdateWith
|
61
|
68
|
@From(Operation.class)
|
62
|
69
|
public abstract int updateDealTime(Connection con, String operationId, @Set String dealTime) throws SQLException;
|
63
|
|
|
|
70
|
|
64
|
71
|
@UpdateWith
|
65
|
72
|
@From(Operation.class)
|
66
|
73
|
public abstract int updatePayMethod(Connection con, String operationId, @Set String payMethod) throws SQLException;
|
67
|
|
|
|
74
|
|
68
|
75
|
/**
|
69
|
76
|
* 查询有多少资源合作正在进行
|
|
77
|
*
|
70
|
78
|
* @param con
|
71
|
|
* @param professorId 登陆者ID
|
|
79
|
* @param professorId
|
|
80
|
* 登陆者ID
|
72
|
81
|
* @return 返回正在合作的资源申请数量
|
73
|
82
|
* @throws SQLException
|
74
|
83
|
*/
|
75
|
|
public int queryOnGoingOper(Connection con, @Nullable String professorId) throws SQLException {
|
76
|
|
String sql = " SELECT COUNT(1) FROM OPERATION O WHERE (OPERATION_STATUS IN (1,2,3,7)) "
|
77
|
|
+ " AND (O.RESOURCE_ID IN (SELECT R.RESOURCE_ID FROM RESOURCE R WHERE R.PROFESSOR_ID = ?) "
|
78
|
|
+ " OR O.DEMAND_ID = ?) ";
|
|
84
|
@QueryVal
|
|
85
|
@Column(value = "COUNT(1)", handlerClass = IntHandler.class)
|
|
86
|
@From(Operation.class)
|
|
87
|
@Where("OPERATION_STATUS IN (1,2,3,7)")
|
|
88
|
@DefaultValue("0")
|
|
89
|
public abstract int queryOnGoingOper(Connection con,
|
|
90
|
@Nullable @GroupSqlColumn(value = { "RESOURCE_ID IN (SELECT R.RESOURCE_ID FROM RESOURCE R WHERE R.PROFESSOR_ID = ?)",
|
|
91
|
"DEMAND_ID = ?" }, handlerClass = StringHandler.class, isAnd = false) String professorId)
|
|
92
|
throws SQLException;
|
|
93
|
|
|
94
|
|
|
95
|
public Operation query(Connection con, String operationId) throws SQLException {
|
|
96
|
int index = 1;
|
|
97
|
String sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,"
|
|
98
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
|
99
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE "
|
|
100
|
+ " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID " + " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
|
101
|
+ " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID " + " WHERE OPERATION_ID = ?";
|
79
|
102
|
PreparedStatement ps = con.prepareStatement(sql);
|
80
|
|
ps.setString(1, professorId);
|
81
|
|
ps.setString(2, professorId);
|
82
|
|
ResultSet rs = ps.executeQuery();
|
83
|
|
rs.next();
|
84
|
|
int count = rs.getInt(1);
|
85
|
|
return count;
|
|
103
|
try {
|
|
104
|
ps.setString(index++, operationId);
|
|
105
|
ResultSet rs = ps.executeQuery();
|
|
106
|
try {
|
|
107
|
if (rs.next()) {
|
|
108
|
Operation operation = new Operation();
|
|
109
|
operation.setReplyNotes(rs.getString(1));
|
|
110
|
operation.setCreateTime(rs.getString(2));
|
|
111
|
operation.setOperationId(rs.getString(3));
|
|
112
|
operation.setOperationStatus(rs.getInt(4));
|
|
113
|
Professor professor = new Professor();
|
|
114
|
professor.setId(rs.getString(5));
|
|
115
|
operation.setDetailDemand(rs.getString(6));
|
|
116
|
operation.setDeliverTime(rs.getString(7));
|
|
117
|
Resource resource = new Resource();
|
|
118
|
resource.setResourceId(rs.getString(8));
|
|
119
|
operation.setDealPrice(rs.getBigDecimal(9));
|
|
120
|
operation.setDealTime(rs.getString(10));
|
|
121
|
operation.setPayMethod(rs.getString(11));
|
|
122
|
professor.setName(rs.getString(12));
|
|
123
|
operation.setProfessor(professor);
|
|
124
|
resource.setResourceName(rs.getString(13));
|
|
125
|
Professor professor2 = new Professor();
|
|
126
|
professor2.setId(rs.getString(14));
|
|
127
|
professor2.setName(rs.getString(15));
|
|
128
|
resource.setProfessor(professor2);
|
|
129
|
operation.setResource(resource);
|
|
130
|
operation.setApplysquare(rs.getString(16));
|
|
131
|
return operation;
|
|
132
|
} else {
|
|
133
|
return null;
|
|
134
|
}
|
|
135
|
} finally {
|
|
136
|
try {
|
|
137
|
rs.close();
|
|
138
|
} catch (Exception e1) {
|
|
139
|
}
|
|
140
|
}
|
|
141
|
} finally {
|
|
142
|
try {
|
|
143
|
ps.close();
|
|
144
|
} catch (Exception e2) {
|
|
145
|
}
|
|
146
|
}
|
86
|
147
|
}
|
87
|
|
|
88
|
|
public Operation query(Connection con,String operationId) throws SQLException{
|
89
|
|
int index = 1;
|
90
|
|
String sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,"
|
91
|
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
92
|
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE "
|
93
|
|
+ " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
94
|
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
95
|
|
+ " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID "
|
96
|
|
+ " WHERE OPERATION_ID = ?";
|
97
|
|
PreparedStatement ps = con.prepareStatement(sql);
|
98
|
|
try{
|
99
|
|
ps.setString(index++,operationId);
|
100
|
|
ResultSet rs = ps.executeQuery();
|
101
|
|
try{
|
102
|
|
if(rs.next()){
|
103
|
|
Operation operation = new Operation();
|
104
|
|
operation.setReplyNotes(rs.getString(1));
|
105
|
|
operation.setCreateTime(rs.getString(2));
|
106
|
|
operation.setOperationId(rs.getString(3));
|
107
|
|
operation.setOperationStatus(rs.getInt(4));
|
108
|
|
Professor professor = new Professor();
|
109
|
|
professor.setId(rs.getString(5));
|
110
|
|
operation.setDetailDemand(rs.getString(6));
|
111
|
|
operation.setDeliverTime(rs.getString(7));
|
112
|
|
Resource resource = new Resource();
|
113
|
|
resource.setResourceId(rs.getString(8));
|
114
|
|
operation.setDealPrice(rs.getBigDecimal(9));
|
115
|
|
operation.setDealTime(rs.getString(10));
|
116
|
|
operation.setPayMethod(rs.getString(11));
|
117
|
|
professor.setName(rs.getString(12));
|
118
|
|
operation.setProfessor(professor);
|
119
|
|
resource.setResourceName(rs.getString(13));
|
120
|
|
Professor professor2 = new Professor();
|
121
|
|
professor2.setId(rs.getString(14));
|
122
|
|
professor2.setName(rs.getString(15));
|
123
|
|
resource.setProfessor(professor2);
|
124
|
|
operation.setResource(resource);
|
125
|
|
operation.setApplysquare(rs.getString(16));
|
126
|
|
return operation;
|
127
|
|
}else{
|
128
|
|
return null;
|
129
|
|
}
|
130
|
|
}finally{
|
131
|
|
try{rs.close();}catch(Exception e1){}
|
132
|
|
}
|
133
|
|
}finally{
|
134
|
|
try{ps.close();}catch(Exception e2){}
|
135
|
|
}
|
136
|
|
}
|
137
|
|
|
138
|
|
public List<Operation> query(Connection con) throws SQLException{
|
139
|
|
String sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,"
|
140
|
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
141
|
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE "
|
142
|
|
+ " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
143
|
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
144
|
|
+ " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
|
145
|
|
PreparedStatement ps = con.prepareStatement(sql);
|
146
|
|
try{
|
147
|
|
ResultSet rs = ps.executeQuery();
|
148
|
|
try{
|
149
|
|
List<Operation> operations = new ArrayList<Operation>();
|
150
|
|
while(rs.next()){
|
151
|
|
Operation operation = new Operation();
|
152
|
|
operation.setReplyNotes(rs.getString(1));
|
153
|
|
operation.setCreateTime(rs.getString(2));
|
154
|
|
operation.setOperationId(rs.getString(3));
|
155
|
|
operation.setOperationStatus(rs.getInt(4));
|
156
|
|
Professor professor = new Professor();
|
157
|
|
professor.setId(rs.getString(5));
|
158
|
|
operation.setDetailDemand(rs.getString(6));
|
159
|
|
operation.setDeliverTime(rs.getString(7));
|
160
|
|
Resource resource = new Resource();
|
161
|
|
resource.setResourceId(rs.getString(8));
|
162
|
|
operation.setDealPrice(rs.getBigDecimal(9));
|
163
|
|
operation.setDealTime(rs.getString(10));
|
164
|
|
operation.setPayMethod(rs.getString(11));
|
165
|
|
professor.setName(rs.getString(12));
|
166
|
|
operation.setProfessor(professor);
|
167
|
|
resource.setResourceName(rs.getString(13));
|
168
|
|
Professor professor2 = new Professor();
|
169
|
|
professor2.setId(rs.getString(14));
|
170
|
|
professor2.setName(rs.getString(15));
|
171
|
|
resource.setProfessor(professor2);
|
172
|
|
operation.setResource(resource);
|
173
|
|
operation.setApplysquare(rs.getString(16));
|
174
|
|
operations.add(operation);
|
175
|
|
}
|
176
|
|
return operations;
|
177
|
|
}finally{
|
178
|
|
try{rs.close();}catch(Exception e1){}
|
179
|
|
}
|
180
|
|
}finally{
|
181
|
|
try{ps.close();}catch(Exception e2){}
|
182
|
|
}
|
183
|
|
}
|
184
|
|
|
|
148
|
|
|
149
|
public List<Operation> query(Connection con) throws SQLException {
|
|
150
|
String sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,"
|
|
151
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
|
152
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE "
|
|
153
|
+ " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID " + " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
|
154
|
+ " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
|
|
155
|
PreparedStatement ps = con.prepareStatement(sql);
|
|
156
|
try {
|
|
157
|
ResultSet rs = ps.executeQuery();
|
|
158
|
try {
|
|
159
|
List<Operation> operations = new ArrayList<Operation>();
|
|
160
|
while (rs.next()) {
|
|
161
|
Operation operation = new Operation();
|
|
162
|
operation.setReplyNotes(rs.getString(1));
|
|
163
|
operation.setCreateTime(rs.getString(2));
|
|
164
|
operation.setOperationId(rs.getString(3));
|
|
165
|
operation.setOperationStatus(rs.getInt(4));
|
|
166
|
Professor professor = new Professor();
|
|
167
|
professor.setId(rs.getString(5));
|
|
168
|
operation.setDetailDemand(rs.getString(6));
|
|
169
|
operation.setDeliverTime(rs.getString(7));
|
|
170
|
Resource resource = new Resource();
|
|
171
|
resource.setResourceId(rs.getString(8));
|
|
172
|
operation.setDealPrice(rs.getBigDecimal(9));
|
|
173
|
operation.setDealTime(rs.getString(10));
|
|
174
|
operation.setPayMethod(rs.getString(11));
|
|
175
|
professor.setName(rs.getString(12));
|
|
176
|
operation.setProfessor(professor);
|
|
177
|
resource.setResourceName(rs.getString(13));
|
|
178
|
Professor professor2 = new Professor();
|
|
179
|
professor2.setId(rs.getString(14));
|
|
180
|
professor2.setName(rs.getString(15));
|
|
181
|
resource.setProfessor(professor2);
|
|
182
|
operation.setResource(resource);
|
|
183
|
operation.setApplysquare(rs.getString(16));
|
|
184
|
operations.add(operation);
|
|
185
|
}
|
|
186
|
return operations;
|
|
187
|
} finally {
|
|
188
|
try {
|
|
189
|
rs.close();
|
|
190
|
} catch (Exception e1) {
|
|
191
|
}
|
|
192
|
}
|
|
193
|
} finally {
|
|
194
|
try {
|
|
195
|
ps.close();
|
|
196
|
} catch (Exception e2) {
|
|
197
|
}
|
|
198
|
}
|
|
199
|
}
|
|
200
|
|
185
|
201
|
/**
|
186
|
202
|
* 搜索当前用户的所有资源申请(包括申请别人和别人申请自己的)
|
|
203
|
*
|
187
|
204
|
* @param con
|
188
|
|
* @param id 登录用户ID
|
|
205
|
* @param id
|
|
206
|
* 登录用户ID
|
189
|
207
|
* @param pageSize
|
190
|
208
|
* @param pageNo
|
191
|
209
|
* @return 返回所有资源申请记录(包括申请别人和别人申请自己的)
|
192
|
210
|
* @throws SQLException
|
193
|
211
|
*/
|
194
|
|
public PageQueryResult<Operation> queryPro(Connection con, @Nullable String id,int pageSize,int pageNo) throws SQLException{
|
195
|
|
int total = 0;
|
196
|
|
PageQueryResult<Operation> queryResult = new PageQueryResult<Operation>();
|
197
|
|
int index = 1;
|
198
|
|
boolean hasId = null != id;
|
199
|
|
StringBuilder sql = new StringBuilder();
|
200
|
|
if(hasId){
|
201
|
|
sql.append(" WHERE O.RESOURCE_ID IN (SELECT R.RESOURCE_ID FROM RESOURCE R WHERE R.PROFESSOR_ID = ?) OR (O.DEMAND_ID = ?) ");
|
202
|
|
}
|
203
|
|
StringBuilder whereSql = sql;
|
204
|
|
sql = new StringBuilder();
|
205
|
|
sql.append(" SELECT COUNT(1) FROM OPERATION O ");
|
206
|
|
if(whereSql.length()>0){
|
207
|
|
sql.append(whereSql);
|
208
|
|
}
|
209
|
|
PreparedStatement ps = con.prepareStatement(sql.toString());
|
210
|
|
try{
|
211
|
|
if(hasId){
|
212
|
|
ps.setString(index++,id);
|
213
|
|
ps.setString(index++,id);
|
214
|
|
}
|
215
|
|
queryResult.setPageSize(pageSize);
|
216
|
|
ResultSet rs = ps.executeQuery();
|
217
|
|
try{
|
218
|
|
rs.next();
|
219
|
|
total = rs.getInt(1);
|
220
|
|
}finally{
|
221
|
|
try{rs.close();}catch(Exception e1){}
|
222
|
|
}
|
223
|
|
}finally{
|
224
|
|
try{ps.close();}catch(Exception e2){}
|
225
|
|
}
|
226
|
|
queryResult.setTotal(total);
|
227
|
|
if(0== total){
|
228
|
|
queryResult.setPageNo(1);
|
229
|
|
queryResult.setData(Collections.<Operation>emptyList());
|
230
|
|
return queryResult;
|
231
|
|
}
|
232
|
|
index = 1;
|
233
|
|
boolean firstPage = (1 == pageNo);
|
234
|
|
if(firstPage){
|
235
|
|
queryResult.setPageNo(1);
|
236
|
|
sql = new StringBuilder();
|
237
|
|
sql.append("SELECT REPLY_NOTES,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,"
|
238
|
|
+ " DETAIL_DEMAND,DELIVER_TIME,O.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,"
|
239
|
|
+ " O.CREATE_TIME,R.RESOURCE_NAME,SUPPORTED_SERVICES,R.DESCP,R.PROFESSOR_ID,P1.NAME,P2.NAME "
|
240
|
|
+ " FROM OPERATION O LEFT JOIN RESOURCE R ON O.RESOURCE_ID = R.RESOURCE_ID "
|
241
|
|
+ " LEFT JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
242
|
|
+ " LEFT JOIN PROFESSOR P2 ON R.PROFESSOR_ID = P2.ID");
|
243
|
|
if(whereSql.length()>0){
|
244
|
|
sql.append(whereSql);
|
245
|
|
}
|
246
|
|
sql.append(" ORDER BY O.CREATE_TIME DESC ");
|
247
|
|
sql.append(" LIMIT ").append(pageSize);
|
248
|
|
}else{
|
249
|
|
int pageNum = total / pageSize;
|
250
|
|
if(total % pageSize != 0){
|
251
|
|
++pageNum;
|
252
|
|
}
|
253
|
|
if(pageNo > pageNum){
|
254
|
|
pageNo = pageNum;
|
255
|
|
}
|
256
|
|
queryResult.setPageNo(pageNo);
|
257
|
|
--pageNo;
|
258
|
|
int offset = (pageNo * pageSize);
|
259
|
|
sql = new StringBuilder();
|
260
|
|
sql.append("SELECT REPLY_NOTES,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,"
|
261
|
|
+ " DETAIL_DEMAND,DELIVER_TIME,O.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,"
|
262
|
|
+ " O.CREATE_TIME,R.RESOURCE_NAME,SUPPORTED_SERVICES,R.DESCP,R.PROFESSOR_ID,P1.NAME,P2.NAME "
|
263
|
|
+ " FROM OPERATION O LEFT JOIN RESOURCE R ON O.RESOURCE_ID = R.RESOURCE_ID "
|
264
|
|
+ " LEFT JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
265
|
|
+ " LEFT JOIN PROFESSOR P2 ON R.PROFESSOR_ID = P2.ID");
|
266
|
|
if(whereSql.length()>0){
|
267
|
|
sql.append(whereSql);
|
268
|
|
}
|
269
|
|
sql.append(" ORDER BY O.CREATE_TIME DESC ");
|
270
|
|
sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
|
271
|
|
}
|
272
|
|
ps = con.prepareStatement(sql.toString());
|
273
|
|
try{
|
274
|
|
if(hasId){
|
275
|
|
ps.setString(index++,id);
|
276
|
|
ps.setString(index++,id);
|
277
|
|
}
|
278
|
|
ResultSet rs = ps.executeQuery();
|
279
|
|
try{
|
280
|
|
List<Operation> operations = new ArrayList<Operation>();
|
281
|
|
queryResult.setData(operations);
|
282
|
|
int size = 0;
|
283
|
|
while((size<pageSize) && rs.next()){
|
284
|
|
++size;
|
285
|
|
Operation operation = new Operation();
|
286
|
|
String replyNotes = rs.getString(1);
|
287
|
|
if(rs.wasNull()){
|
288
|
|
replyNotes = null;
|
289
|
|
}
|
290
|
|
operation.setReplyNotes(replyNotes);
|
291
|
|
String applysqare = rs.getString(2);
|
292
|
|
if(rs.wasNull()){
|
293
|
|
applysqare = null;
|
294
|
|
}
|
295
|
|
operation.setApplysquare(applysqare);
|
296
|
|
operation.setOperationId(rs.getString(3));
|
297
|
|
operation.setOperationStatus(rs.getInt(4));
|
298
|
|
Professor professor = new Professor();
|
299
|
|
professor.setId(rs.getString(5));
|
300
|
|
operation.setDetailDemand(rs.getString(6));
|
301
|
|
operation.setDeliverTime(rs.getString(7));
|
302
|
|
Resource resource = new Resource();
|
303
|
|
resource.setResourceId(rs.getString(8));
|
304
|
|
BigDecimal dealPrice = rs.getBigDecimal(9);
|
305
|
|
if(rs.wasNull()){
|
306
|
|
dealPrice = null;
|
307
|
|
}
|
308
|
|
operation.setDealPrice(dealPrice);
|
309
|
|
String dealTime = rs.getString(10);
|
310
|
|
if(rs.wasNull()){
|
311
|
|
dealTime = null;
|
312
|
|
}
|
313
|
|
operation.setDealTime(dealTime);
|
314
|
|
String payMethod = rs.getString(11);
|
315
|
|
if(rs.wasNull()){
|
316
|
|
payMethod = null;
|
317
|
|
}
|
318
|
|
operation.setPayMethod(payMethod);
|
319
|
|
operation.setCreateTime(rs.getString(12));
|
320
|
|
resource.setResourceName(rs.getString(13));
|
321
|
|
resource.setSupportedServices(rs.getString(14));
|
322
|
|
resource.setDescp(rs.getString(15));
|
323
|
|
List<Image> images = this.imageDao.queryRes(con, resource.getResourceId());
|
324
|
|
resource.setImages(images);
|
325
|
|
Professor professor2 = new Professor();
|
326
|
|
professor2.setId(rs.getString(16));
|
327
|
|
professor.setName(rs.getString(17));
|
328
|
|
operation.setProfessor(professor);
|
329
|
|
professor2.setName(rs.getString(18));
|
330
|
|
resource.setProfessor(professor2);
|
331
|
|
operation.setResource(resource);
|
332
|
|
operations.add(operation);
|
333
|
|
}
|
334
|
|
return queryResult;
|
335
|
|
}finally{
|
336
|
|
try{rs.close();}catch(Exception e3){}
|
337
|
|
}
|
338
|
|
}finally{
|
339
|
|
try{ps.close();}catch(Exception e4){}
|
340
|
|
}
|
341
|
|
}
|
342
|
|
|
|
212
|
public PageQueryResult<Operation> queryPro(Connection con, @Nullable String id, int pageSize, int pageNo) throws SQLException {
|
|
213
|
int total = 0;
|
|
214
|
PageQueryResult<Operation> queryResult = new PageQueryResult<Operation>();
|
|
215
|
int index = 1;
|
|
216
|
boolean hasId = null != id;
|
|
217
|
StringBuilder sql = new StringBuilder();
|
|
218
|
if (hasId) {
|
|
219
|
sql.append(" WHERE O.RESOURCE_ID IN (SELECT R.RESOURCE_ID FROM RESOURCE R WHERE R.PROFESSOR_ID = ?) OR (O.DEMAND_ID = ?) ");
|
|
220
|
}
|
|
221
|
StringBuilder whereSql = sql;
|
|
222
|
sql = new StringBuilder();
|
|
223
|
sql.append(" SELECT COUNT(1) FROM OPERATION O ");
|
|
224
|
if (whereSql.length() > 0) {
|
|
225
|
sql.append(whereSql);
|
|
226
|
}
|
|
227
|
PreparedStatement ps = con.prepareStatement(sql.toString());
|
|
228
|
try {
|
|
229
|
if (hasId) {
|
|
230
|
ps.setString(index++, id);
|
|
231
|
ps.setString(index++, id);
|
|
232
|
}
|
|
233
|
queryResult.setPageSize(pageSize);
|
|
234
|
ResultSet rs = ps.executeQuery();
|
|
235
|
try {
|
|
236
|
rs.next();
|
|
237
|
total = rs.getInt(1);
|
|
238
|
} finally {
|
|
239
|
try {
|
|
240
|
rs.close();
|
|
241
|
} catch (Exception e1) {
|
|
242
|
}
|
|
243
|
}
|
|
244
|
} finally {
|
|
245
|
try {
|
|
246
|
ps.close();
|
|
247
|
} catch (Exception e2) {
|
|
248
|
}
|
|
249
|
}
|
|
250
|
queryResult.setTotal(total);
|
|
251
|
if (0 == total) {
|
|
252
|
queryResult.setPageNo(1);
|
|
253
|
queryResult.setData(Collections.<Operation> emptyList());
|
|
254
|
return queryResult;
|
|
255
|
}
|
|
256
|
index = 1;
|
|
257
|
boolean firstPage = (1 == pageNo);
|
|
258
|
if (firstPage) {
|
|
259
|
queryResult.setPageNo(1);
|
|
260
|
sql = new StringBuilder();
|
|
261
|
sql.append("SELECT REPLY_NOTES,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,"
|
|
262
|
+ " DETAIL_DEMAND,DELIVER_TIME,O.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,"
|
|
263
|
+ " O.CREATE_TIME,R.RESOURCE_NAME,SUPPORTED_SERVICES,R.DESCP,R.PROFESSOR_ID,P1.NAME,P2.NAME "
|
|
264
|
+ " FROM OPERATION O LEFT JOIN RESOURCE R ON O.RESOURCE_ID = R.RESOURCE_ID " + " LEFT JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
|
265
|
+ " LEFT JOIN PROFESSOR P2 ON R.PROFESSOR_ID = P2.ID");
|
|
266
|
if (whereSql.length() > 0) {
|
|
267
|
sql.append(whereSql);
|
|
268
|
}
|
|
269
|
sql.append(" ORDER BY O.CREATE_TIME DESC ");
|
|
270
|
sql.append(" LIMIT ").append(pageSize);
|
|
271
|
} else {
|
|
272
|
int pageNum = total / pageSize;
|
|
273
|
if (total % pageSize != 0) {
|
|
274
|
++pageNum;
|
|
275
|
}
|
|
276
|
if (pageNo > pageNum) {
|
|
277
|
pageNo = pageNum;
|
|
278
|
}
|
|
279
|
queryResult.setPageNo(pageNo);
|
|
280
|
--pageNo;
|
|
281
|
int offset = (pageNo * pageSize);
|
|
282
|
sql = new StringBuilder();
|
|
283
|
sql.append("SELECT REPLY_NOTES,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,"
|
|
284
|
+ " DETAIL_DEMAND,DELIVER_TIME,O.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,"
|
|
285
|
+ " O.CREATE_TIME,R.RESOURCE_NAME,SUPPORTED_SERVICES,R.DESCP,R.PROFESSOR_ID,P1.NAME,P2.NAME "
|
|
286
|
+ " FROM OPERATION O LEFT JOIN RESOURCE R ON O.RESOURCE_ID = R.RESOURCE_ID " + " LEFT JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
|
287
|
+ " LEFT JOIN PROFESSOR P2 ON R.PROFESSOR_ID = P2.ID");
|
|
288
|
if (whereSql.length() > 0) {
|
|
289
|
sql.append(whereSql);
|
|
290
|
}
|
|
291
|
sql.append(" ORDER BY O.CREATE_TIME DESC ");
|
|
292
|
sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
|
|
293
|
}
|
|
294
|
ps = con.prepareStatement(sql.toString());
|
|
295
|
try {
|
|
296
|
if (hasId) {
|
|
297
|
ps.setString(index++, id);
|
|
298
|
ps.setString(index++, id);
|
|
299
|
}
|
|
300
|
ResultSet rs = ps.executeQuery();
|
|
301
|
try {
|
|
302
|
List<Operation> operations = new ArrayList<Operation>();
|
|
303
|
queryResult.setData(operations);
|
|
304
|
int size = 0;
|
|
305
|
while ((size < pageSize) && rs.next()) {
|
|
306
|
++size;
|
|
307
|
Operation operation = new Operation();
|
|
308
|
String replyNotes = rs.getString(1);
|
|
309
|
if (rs.wasNull()) {
|
|
310
|
replyNotes = null;
|
|
311
|
}
|
|
312
|
operation.setReplyNotes(replyNotes);
|
|
313
|
String applysqare = rs.getString(2);
|
|
314
|
if (rs.wasNull()) {
|
|
315
|
applysqare = null;
|
|
316
|
}
|
|
317
|
operation.setApplysquare(applysqare);
|
|
318
|
operation.setOperationId(rs.getString(3));
|
|
319
|
operation.setOperationStatus(rs.getInt(4));
|
|
320
|
Professor professor = new Professor();
|
|
321
|
professor.setId(rs.getString(5));
|
|
322
|
operation.setDetailDemand(rs.getString(6));
|
|
323
|
operation.setDeliverTime(rs.getString(7));
|
|
324
|
Resource resource = new Resource();
|
|
325
|
resource.setResourceId(rs.getString(8));
|
|
326
|
BigDecimal dealPrice = rs.getBigDecimal(9);
|
|
327
|
if (rs.wasNull()) {
|
|
328
|
dealPrice = null;
|
|
329
|
}
|
|
330
|
operation.setDealPrice(dealPrice);
|
|
331
|
String dealTime = rs.getString(10);
|
|
332
|
if (rs.wasNull()) {
|
|
333
|
dealTime = null;
|
|
334
|
}
|
|
335
|
operation.setDealTime(dealTime);
|
|
336
|
String payMethod = rs.getString(11);
|
|
337
|
if (rs.wasNull()) {
|
|
338
|
payMethod = null;
|
|
339
|
}
|
|
340
|
operation.setPayMethod(payMethod);
|
|
341
|
operation.setCreateTime(rs.getString(12));
|
|
342
|
resource.setResourceName(rs.getString(13));
|
|
343
|
resource.setSupportedServices(rs.getString(14));
|
|
344
|
resource.setDescp(rs.getString(15));
|
|
345
|
List<Image> images = this.imageDao.queryRes(con, resource.getResourceId());
|
|
346
|
resource.setImages(images);
|
|
347
|
Professor professor2 = new Professor();
|
|
348
|
professor2.setId(rs.getString(16));
|
|
349
|
professor.setName(rs.getString(17));
|
|
350
|
operation.setProfessor(professor);
|
|
351
|
professor2.setName(rs.getString(18));
|
|
352
|
resource.setProfessor(professor2);
|
|
353
|
operation.setResource(resource);
|
|
354
|
operations.add(operation);
|
|
355
|
}
|
|
356
|
return queryResult;
|
|
357
|
} finally {
|
|
358
|
try {
|
|
359
|
rs.close();
|
|
360
|
} catch (Exception e3) {
|
|
361
|
}
|
|
362
|
}
|
|
363
|
} finally {
|
|
364
|
try {
|
|
365
|
ps.close();
|
|
366
|
} catch (Exception e4) {
|
|
367
|
}
|
|
368
|
}
|
|
369
|
}
|
|
370
|
|
343
|
371
|
/**
|
344
|
372
|
* 分页按资源申请者ID查资源申请
|
|
373
|
*
|
345
|
374
|
* @param con
|
346
|
|
* @param demandId 资源申请者ID
|
347
|
|
* @param pageSize 每页记录数
|
348
|
|
* @param pageNo 当前页码
|
|
375
|
* @param demandId
|
|
376
|
* 资源申请者ID
|
|
377
|
* @param pageSize
|
|
378
|
* 每页记录数
|
|
379
|
* @param pageNo
|
|
380
|
* 当前页码
|
349
|
381
|
* @return 返回该用户ID申请的所有资源
|
350
|
382
|
* @throws SQLException
|
351
|
383
|
*/
|
352
|
|
public PageQueryResult<Operation> queryDemPage(Connection con,String demandId,int pageSize,int pageNo) throws SQLException{
|
353
|
|
int total = 0;
|
354
|
|
PageQueryResult<Operation> queryResult = new PageQueryResult<Operation>();
|
355
|
|
int index = 1;
|
356
|
|
String sql = null;
|
357
|
|
sql = " WHERE OPERATION.DEMAND_ID = ? ";
|
358
|
|
String whereSql = sql;
|
359
|
|
sql = "SELECT COUNT(1) FROM OPERATION";
|
360
|
|
sql = sql + whereSql;
|
361
|
|
PreparedStatement ps = con.prepareStatement(sql);
|
362
|
|
try{
|
363
|
|
ps.setString(index++,demandId);
|
364
|
|
queryResult.setPageSize(pageSize);
|
365
|
|
ResultSet rs = ps.executeQuery();
|
366
|
|
try{
|
367
|
|
rs.next();
|
368
|
|
total = rs.getInt(1);
|
369
|
|
}finally{
|
370
|
|
try{rs.close();}catch(Exception e1){}
|
371
|
|
}
|
372
|
|
}finally{
|
373
|
|
try{ps.close();}catch(Exception e2){}
|
374
|
|
}
|
375
|
|
queryResult.setTotal(total);
|
376
|
|
if(0== total){
|
377
|
|
queryResult.setPageNo(1);
|
378
|
|
queryResult.setData(Collections.<Operation>emptyList());
|
379
|
|
return queryResult;
|
380
|
|
}
|
381
|
|
index = 1;
|
382
|
|
boolean firstPage = (1 == pageNo);
|
383
|
|
if(firstPage){
|
384
|
|
queryResult.setPageNo(1);
|
385
|
|
sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,"
|
386
|
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
387
|
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME "
|
388
|
|
+ " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
389
|
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
390
|
|
+ " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
|
391
|
|
sql = sql + whereSql;
|
392
|
|
sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
|
393
|
|
sql = sql + " LIMIT " + pageSize;
|
394
|
|
}else{
|
395
|
|
int pageNum = total / pageSize;
|
396
|
|
if(total % pageSize != 0){
|
397
|
|
++pageNum;
|
398
|
|
}
|
399
|
|
if(pageNo > pageNum){
|
400
|
|
pageNo = pageNum;
|
401
|
|
}
|
402
|
|
queryResult.setPageNo(pageNo);
|
403
|
|
--pageNo;
|
404
|
|
int offset = (pageNo * pageSize);
|
405
|
|
sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,"
|
406
|
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
407
|
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME "
|
408
|
|
+ " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
409
|
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
410
|
|
+ " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
|
411
|
|
sql = sql + whereSql;
|
412
|
|
sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
|
413
|
|
sql = sql + " LIMIT " + pageSize+ " OFFSET "+ offset;
|
414
|
|
}
|
415
|
|
ps = con.prepareStatement(sql);
|
416
|
|
try{
|
417
|
|
ps.setString(index++,demandId);
|
418
|
|
ResultSet rs = ps.executeQuery();
|
419
|
|
try{
|
420
|
|
List<Operation> operations = new ArrayList<Operation>();
|
421
|
|
queryResult.setData(operations);
|
422
|
|
int size = 0;
|
423
|
|
while((size<pageSize) && rs.next()){
|
424
|
|
++size;
|
425
|
|
Operation operation = new Operation();
|
426
|
|
String replyNotes = rs.getString(1);
|
427
|
|
if(rs.wasNull()){
|
428
|
|
replyNotes = null;
|
429
|
|
}
|
430
|
|
operation.setReplyNotes(replyNotes);
|
431
|
|
operation.setCreateTime(rs.getString(2));
|
432
|
|
String applysquare = rs.getString(3);
|
433
|
|
if(rs.wasNull()){
|
434
|
|
applysquare = null;
|
435
|
|
}
|
436
|
|
operation.setApplysquare(applysquare);
|
437
|
|
operation.setOperationId(rs.getString(4));
|
438
|
|
operation.setOperationStatus(rs.getInt(5));
|
439
|
|
Professor professor = new Professor();
|
440
|
|
professor.setId(rs.getString(6));
|
441
|
|
operation.setDetailDemand(rs.getString(7));
|
442
|
|
operation.setDeliverTime(rs.getString(8));
|
443
|
|
Resource resource = new Resource();
|
|
384
|
public PageQueryResult<Operation> queryDemPage(Connection con, String demandId, int pageSize, int pageNo) throws SQLException {
|
|
385
|
int total = 0;
|
|
386
|
PageQueryResult<Operation> queryResult = new PageQueryResult<Operation>();
|
|
387
|
int index = 1;
|
|
388
|
String sql = null;
|
|
389
|
sql = " WHERE OPERATION.DEMAND_ID = ? ";
|
|
390
|
String whereSql = sql;
|
|
391
|
sql = "SELECT COUNT(1) FROM OPERATION";
|
|
392
|
sql = sql + whereSql;
|
|
393
|
PreparedStatement ps = con.prepareStatement(sql);
|
|
394
|
try {
|
|
395
|
ps.setString(index++, demandId);
|
|
396
|
queryResult.setPageSize(pageSize);
|
|
397
|
ResultSet rs = ps.executeQuery();
|
|
398
|
try {
|
|
399
|
rs.next();
|
|
400
|
total = rs.getInt(1);
|
|
401
|
} finally {
|
|
402
|
try {
|
|
403
|
rs.close();
|
|
404
|
} catch (Exception e1) {
|
|
405
|
}
|
|
406
|
}
|
|
407
|
} finally {
|
|
408
|
try {
|
|
409
|
ps.close();
|
|
410
|
} catch (Exception e2) {
|
|
411
|
}
|
|
412
|
}
|
|
413
|
queryResult.setTotal(total);
|
|
414
|
if (0 == total) {
|
|
415
|
queryResult.setPageNo(1);
|
|
416
|
queryResult.setData(Collections.<Operation> emptyList());
|
|
417
|
return queryResult;
|
|
418
|
}
|
|
419
|
index = 1;
|
|
420
|
boolean firstPage = (1 == pageNo);
|
|
421
|
if (firstPage) {
|
|
422
|
queryResult.setPageNo(1);
|
|
423
|
sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,"
|
|
424
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
|
425
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME " + " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
|
426
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID " + " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
|
|
427
|
sql = sql + whereSql;
|
|
428
|
sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
|
|
429
|
sql = sql + " LIMIT " + pageSize;
|
|
430
|
} else {
|
|
431
|
int pageNum = total / pageSize;
|
|
432
|
if (total % pageSize != 0) {
|
|
433
|
++pageNum;
|
|
434
|
}
|
|
435
|
if (pageNo > pageNum) {
|
|
436
|
pageNo = pageNum;
|
|
437
|
}
|
|
438
|
queryResult.setPageNo(pageNo);
|
|
439
|
--pageNo;
|
|
440
|
int offset = (pageNo * pageSize);
|
|
441
|
sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,"
|
|
442
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
|
443
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME " + " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
|
444
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID " + " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
|
|
445
|
sql = sql + whereSql;
|
|
446
|
sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
|
|
447
|
sql = sql + " LIMIT " + pageSize + " OFFSET " + offset;
|
|
448
|
}
|
|
449
|
ps = con.prepareStatement(sql);
|
|
450
|
try {
|
|
451
|
ps.setString(index++, demandId);
|
|
452
|
ResultSet rs = ps.executeQuery();
|
|
453
|
try {
|
|
454
|
List<Operation> operations = new ArrayList<Operation>();
|
|
455
|
queryResult.setData(operations);
|
|
456
|
int size = 0;
|
|
457
|
while ((size < pageSize) && rs.next()) {
|
|
458
|
++size;
|
|
459
|
Operation operation = new Operation();
|
|
460
|
String replyNotes = rs.getString(1);
|
|
461
|
if (rs.wasNull()) {
|
|
462
|
replyNotes = null;
|
|
463
|
}
|
|
464
|
operation.setReplyNotes(replyNotes);
|
|
465
|
operation.setCreateTime(rs.getString(2));
|
|
466
|
String applysquare = rs.getString(3);
|
|
467
|
if (rs.wasNull()) {
|
|
468
|
applysquare = null;
|
|
469
|
}
|
|
470
|
operation.setApplysquare(applysquare);
|
|
471
|
operation.setOperationId(rs.getString(4));
|
|
472
|
operation.setOperationStatus(rs.getInt(5));
|
|
473
|
Professor professor = new Professor();
|
|
474
|
professor.setId(rs.getString(6));
|
|
475
|
operation.setDetailDemand(rs.getString(7));
|
|
476
|
operation.setDeliverTime(rs.getString(8));
|
|
477
|
Resource resource = new Resource();
|
444
|
478
|
resource.setResourceId(rs.getString(9));
|
445
|
|
BigDecimal dealPrice = rs.getBigDecimal(10);
|
446
|
|
if(rs.wasNull()){
|
447
|
|
dealPrice = null;
|
448
|
|
}
|
449
|
|
operation.setDealPrice(dealPrice);
|
450
|
|
String dealTime = rs.getString(11);
|
451
|
|
if(rs.wasNull()){
|
452
|
|
dealTime = null;
|
453
|
|
}
|
454
|
|
operation.setDealTime(dealTime);
|
455
|
|
String payMethod = rs.getString(12);
|
456
|
|
if(rs.wasNull()){
|
457
|
|
payMethod = null;
|
458
|
|
}
|
459
|
|
operation.setPayMethod(payMethod);
|
460
|
|
professor.setName(rs.getString(13));
|
461
|
|
operation.setProfessor(professor);
|
|
479
|
BigDecimal dealPrice = rs.getBigDecimal(10);
|
|
480
|
if (rs.wasNull()) {
|
|
481
|
dealPrice = null;
|
|
482
|
}
|
|
483
|
operation.setDealPrice(dealPrice);
|
|
484
|
String dealTime = rs.getString(11);
|
|
485
|
if (rs.wasNull()) {
|
|
486
|
dealTime = null;
|
|
487
|
}
|
|
488
|
operation.setDealTime(dealTime);
|
|
489
|
String payMethod = rs.getString(12);
|
|
490
|
if (rs.wasNull()) {
|
|
491
|
payMethod = null;
|
|
492
|
}
|
|
493
|
operation.setPayMethod(payMethod);
|
|
494
|
professor.setName(rs.getString(13));
|
|
495
|
operation.setProfessor(professor);
|
462
|
496
|
resource.setResourceName(rs.getString(14));
|
463
|
497
|
Professor professor2 = new Professor();
|
464
|
|
professor2.setId(rs.getString(15));
|
465
|
|
professor2.setName(rs.getString(16));
|
466
|
|
resource.setProfessor(professor2);
|
|
498
|
professor2.setId(rs.getString(15));
|
|
499
|
professor2.setName(rs.getString(16));
|
|
500
|
resource.setProfessor(professor2);
|
467
|
501
|
operation.setResource(resource);
|
468
|
502
|
operations.add(operation);
|
469
|
|
}
|
470
|
|
return queryResult;
|
471
|
|
}finally{
|
472
|
|
try{rs.close();}catch(Exception e3){}
|
473
|
|
}
|
474
|
|
}finally{
|
475
|
|
try{ps.close();}catch(Exception e4){}
|
476
|
|
}
|
477
|
|
}
|
478
|
|
|
|
503
|
}
|
|
504
|
return queryResult;
|
|
505
|
} finally {
|
|
506
|
try {
|
|
507
|
rs.close();
|
|
508
|
} catch (Exception e3) {
|
|
509
|
}
|
|
510
|
}
|
|
511
|
} finally {
|
|
512
|
try {
|
|
513
|
ps.close();
|
|
514
|
} catch (Exception e4) {
|
|
515
|
}
|
|
516
|
}
|
|
517
|
}
|
|
518
|
|
479
|
519
|
/**
|
480
|
520
|
* 分页按资源ID查资源申请,返回资申请人姓名和资源名称
|
|
521
|
*
|
481
|
522
|
* @param con
|
482
|
|
* @param resourceId 资源ID
|
483
|
|
* @param pageSize 每页记录数
|
484
|
|
* @param pageNo 当前页码
|
|
523
|
* @param resourceId
|
|
524
|
* 资源ID
|
|
525
|
* @param pageSize
|
|
526
|
* 每页记录数
|
|
527
|
* @param pageNo
|
|
528
|
* 当前页码
|
485
|
529
|
* @return 返回当前资源ID下的所有资源申请记录
|
486
|
530
|
* @throws SQLException
|
487
|
531
|
*/
|
488
|
|
public PageQueryResult<Operation> queryResPage(Connection con,String resourceId,int pageSize,int pageNo) throws SQLException{
|
489
|
|
int total = 0;
|
490
|
|
PageQueryResult<Operation> queryResult = new PageQueryResult<Operation>();
|
491
|
|
int index = 1;
|
492
|
|
String sql = null;
|
493
|
|
sql = " WHERE OPERATION.RESOURCE_ID = ? ";
|
494
|
|
String whereSql = sql;
|
495
|
|
sql = "SELECT COUNT(1) FROM OPERATION";
|
496
|
|
sql = sql + whereSql;
|
497
|
|
PreparedStatement ps = con.prepareStatement(sql);
|
498
|
|
try{
|
499
|
|
ps.setString(index++,resourceId);
|
500
|
|
queryResult.setPageSize(pageSize);
|
501
|
|
ResultSet rs = ps.executeQuery();
|
502
|
|
try{
|
503
|
|
rs.next();
|
504
|
|
total = rs.getInt(1);
|
505
|
|
}finally{
|
506
|
|
try{rs.close();}catch(Exception e1){}
|
507
|
|
}
|
508
|
|
}finally{
|
509
|
|
try{ps.close();}catch(Exception e2){}
|
510
|
|
}
|
511
|
|
queryResult.setTotal(total);
|
512
|
|
if(0== total){
|
513
|
|
queryResult.setPageNo(1);
|
514
|
|
queryResult.setData(Collections.<Operation>emptyList());
|
515
|
|
return queryResult;
|
516
|
|
}
|
517
|
|
index = 1;
|
518
|
|
boolean firstPage = (1 == pageNo);
|
519
|
|
if(firstPage){
|
520
|
|
queryResult.setPageNo(1);
|
521
|
|
sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION.OPERATION_ID,OPERATION_STATUS,"
|
522
|
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
523
|
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME "
|
524
|
|
+ " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
525
|
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
526
|
|
+ " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID ";
|
527
|
|
sql = sql + whereSql;
|
528
|
|
sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
|
529
|
|
sql = sql + " LIMIT " + pageSize;
|
530
|
|
}else{
|
531
|
|
int pageNum = total / pageSize;
|
532
|
|
if(total % pageSize != 0){
|
533
|
|
++pageNum;
|
534
|
|
}
|
535
|
|
if(pageNo > pageNum){
|
536
|
|
pageNo = pageNum;
|
537
|
|
}
|
538
|
|
queryResult.setPageNo(pageNo);
|
539
|
|
--pageNo;
|
540
|
|
int offset = (pageNo * pageSize);
|
541
|
|
sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION.OPERATION_ID,OPERATION_STATUS,"
|
542
|
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
543
|
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME "
|
544
|
|
+ " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
545
|
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
546
|
|
+ " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
|
547
|
|
sql = sql + whereSql;
|
548
|
|
sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
|
549
|
|
sql = sql + " LIMIT " + pageSize+ " OFFSET "+ offset;
|
550
|
|
}
|
551
|
|
ps = con.prepareStatement(sql);
|
552
|
|
try{
|
553
|
|
ps.setString(index++,resourceId);
|
554
|
|
ResultSet rs = ps.executeQuery();
|
555
|
|
try{
|
556
|
|
List<Operation> operations = new ArrayList<Operation>();
|
557
|
|
queryResult.setData(operations);
|
558
|
|
int size = 0;
|
559
|
|
while((size<pageSize) && rs.next()){
|
560
|
|
++size;
|
561
|
|
Operation operation = new Operation();
|
562
|
|
String replyNotes = rs.getString(1);
|
563
|
|
if(rs.wasNull()){
|
564
|
|
replyNotes = null;
|
565
|
|
}
|
566
|
|
operation.setReplyNotes(replyNotes);
|
567
|
|
operation.setCreateTime(rs.getString(2));
|
568
|
|
String applyaquare = rs.getString(3);
|
569
|
|
if(rs.wasNull()){
|
570
|
|
applyaquare = null;
|
571
|
|
}
|
572
|
|
operation.setApplysquare(applyaquare);
|
573
|
|
operation.setOperationId(rs.getString(4));
|
574
|
|
operation.setOperationStatus(rs.getInt(5));
|
575
|
|
Professor professor = new Professor();
|
576
|
|
professor.setId(rs.getString(6));
|
577
|
|
operation.setDetailDemand(rs.getString(7));
|
578
|
|
operation.setDeliverTime(rs.getString(8));
|
579
|
|
Resource resource = new Resource();
|
|
532
|
public PageQueryResult<Operation> queryResPage(Connection con, String resourceId, int pageSize, int pageNo) throws SQLException {
|
|
533
|
int total = 0;
|
|
534
|
PageQueryResult<Operation> queryResult = new PageQueryResult<Operation>();
|
|
535
|
int index = 1;
|
|
536
|
String sql = null;
|
|
537
|
sql = " WHERE OPERATION.RESOURCE_ID = ? ";
|
|
538
|
String whereSql = sql;
|
|
539
|
sql = "SELECT COUNT(1) FROM OPERATION";
|
|
540
|
sql = sql + whereSql;
|
|
541
|
PreparedStatement ps = con.prepareStatement(sql);
|
|
542
|
try {
|
|
543
|
ps.setString(index++, resourceId);
|
|
544
|
queryResult.setPageSize(pageSize);
|
|
545
|
ResultSet rs = ps.executeQuery();
|
|
546
|
try {
|
|
547
|
rs.next();
|
|
548
|
total = rs.getInt(1);
|
|
549
|
} finally {
|
|
550
|
try {
|
|
551
|
rs.close();
|
|
552
|
} catch (Exception e1) {
|
|
553
|
}
|
|
554
|
}
|
|
555
|
} finally {
|
|
556
|
try {
|
|
557
|
ps.close();
|
|
558
|
} catch (Exception e2) {
|
|
559
|
}
|
|
560
|
}
|
|
561
|
queryResult.setTotal(total);
|
|
562
|
if (0 == total) {
|
|
563
|
queryResult.setPageNo(1);
|
|
564
|
queryResult.setData(Collections.<Operation> emptyList());
|
|
565
|
return queryResult;
|
|
566
|
}
|
|
567
|
index = 1;
|
|
568
|
boolean firstPage = (1 == pageNo);
|
|
569
|
if (firstPage) {
|
|
570
|
queryResult.setPageNo(1);
|
|
571
|
sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION.OPERATION_ID,OPERATION_STATUS,"
|
|
572
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
|
573
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME " + " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
|
574
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID " + " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID ";
|
|
575
|
sql = sql + whereSql;
|
|
576
|
sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
|
|
577
|
sql = sql + " LIMIT " + pageSize;
|
|
578
|
} else {
|
|
579
|
int pageNum = total / pageSize;
|
|
580
|
if (total % pageSize != 0) {
|
|
581
|
++pageNum;
|
|
582
|
}
|
|
583
|
if (pageNo > pageNum) {
|
|
584
|
pageNo = pageNum;
|
|
585
|
}
|
|
586
|
queryResult.setPageNo(pageNo);
|
|
587
|
--pageNo;
|
|
588
|
int offset = (pageNo * pageSize);
|
|
589
|
sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION.OPERATION_ID,OPERATION_STATUS,"
|
|
590
|
+ " DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,"
|
|
591
|
+ " PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME " + " FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
|
592
|
+ " INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID " + " INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
|
|
593
|
sql = sql + whereSql;
|
|
594
|
sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
|
|
595
|
sql = sql + " LIMIT " + pageSize + " OFFSET " + offset;
|
|
596
|
}
|
|
597
|
ps = con.prepareStatement(sql);
|
|
598
|
try {
|
|
599
|
ps.setString(index++, resourceId);
|
|
600
|
ResultSet rs = ps.executeQuery();
|
|
601
|
try {
|
|
602
|
List<Operation> operations = new ArrayList<Operation>();
|
|
603
|
queryResult.setData(operations);
|
|
604
|
int size = 0;
|
|
605
|
while ((size < pageSize) && rs.next()) {
|
|
606
|
++size;
|
|
607
|
Operation operation = new Operation();
|
|
608
|
String replyNotes = rs.getString(1);
|
|
609
|
if (rs.wasNull()) {
|
|
610
|
replyNotes = null;
|
|
611
|
}
|
|
612
|
operation.setReplyNotes(replyNotes);
|
|
613
|
operation.setCreateTime(rs.getString(2));
|
|
614
|
String applyaquare = rs.getString(3);
|
|
615
|
if (rs.wasNull()) {
|
|
616
|
applyaquare = null;
|
|
617
|
}
|
|
618
|
operation.setApplysquare(applyaquare);
|
|
619
|
operation.setOperationId(rs.getString(4));
|
|
620
|
operation.setOperationStatus(rs.getInt(5));
|
|
621
|
Professor professor = new Professor();
|
|
622
|
professor.setId(rs.getString(6));
|
|
623
|
operation.setDetailDemand(rs.getString(7));
|
|
624
|
operation.setDeliverTime(rs.getString(8));
|
|
625
|
Resource resource = new Resource();
|
580
|
626
|
resource.setResourceId(rs.getString(9));
|
581
|
|
BigDecimal dealPrice = rs.getBigDecimal(10);
|
582
|
|
if(rs.wasNull()){
|
583
|
|
dealPrice = null;
|
584
|
|
}
|
585
|
|
operation.setDealPrice(dealPrice);
|
586
|
|
String dealTime = rs.getString(11);
|
587
|
|
if(rs.wasNull()){
|
588
|
|
dealTime = null;
|
589
|
|
}
|
590
|
|
operation.setDealTime(dealTime);
|
591
|
|
String payMethod = rs.getString(12);
|
592
|
|
if(rs.wasNull()){
|
593
|
|
payMethod = null;
|
594
|
|
}
|
595
|
|
operation.setPayMethod(payMethod);
|
596
|
|
professor.setName(rs.getString(13));
|
597
|
|
operation.setProfessor(professor);
|
|
627
|
BigDecimal dealPrice = rs.getBigDecimal(10);
|
|
628
|
if (rs.wasNull()) {
|
|
629
|
dealPrice = null;
|
|
630
|
}
|
|
631
|
operation.setDealPrice(dealPrice);
|
|
632
|
String dealTime = rs.getString(11);
|
|
633
|
if (rs.wasNull()) {
|
|
634
|
dealTime = null;
|
|
635
|
}
|
|
636
|
operation.setDealTime(dealTime);
|
|
637
|
String payMethod = rs.getString(12);
|
|
638
|
if (rs.wasNull()) {
|
|
639
|
payMethod = null;
|
|
640
|
}
|
|
641
|
operation.setPayMethod(payMethod);
|
|
642
|
professor.setName(rs.getString(13));
|
|
643
|
operation.setProfessor(professor);
|
598
|
644
|
resource.setResourceName(rs.getString(14));
|
599
|
645
|
Professor professor2 = new Professor();
|
600
|
|
professor2.setId(rs.getString(15));
|
601
|
|
professor2.setName(rs.getString(16));
|
602
|
|
resource.setProfessor(professor2);
|
|
646
|
professor2.setId(rs.getString(15));
|
|
647
|
professor2.setName(rs.getString(16));
|
|
648
|
resource.setProfessor(professor2);
|
603
|
649
|
operation.setResource(resource);
|
604
|
650
|
operations.add(operation);
|
605
|
|
}
|
606
|
|
return queryResult;
|
607
|
|
}finally{
|
608
|
|
try{rs.close();}catch(Exception e3){}
|
609
|
|
}
|
610
|
|
}finally{
|
611
|
|
try{ps.close();}catch(Exception e4){}
|
612
|
|
}
|
613
|
|
}
|
614
|
|
|
|
651
|
}
|
|
652
|
return queryResult;
|
|
653
|
} finally {
|
|
654
|
try {
|
|
655
|
rs.close();
|
|
656
|
} catch (Exception e3) {
|
|
657
|
}
|
|
658
|
}
|
|
659
|
} finally {
|
|
660
|
try {
|
|
661
|
ps.close();
|
|
662
|
} catch (Exception e4) {
|
|
663
|
}
|
|
664
|
}
|
|
665
|
}
|
|
666
|
|
615
|
667
|
@SelectList
|
616
|
668
|
public abstract List<Operation> queryResourceId(Connection con, String resourceId) throws SQLException;
|
617
|
|
|
|
669
|
|
618
|
670
|
@DeleteWith
|
619
|
671
|
@From(Operation.class)
|
620
|
672
|
public abstract int delete(Connection con, String operationId) throws SQLException;
|
621
|
|
|
|
673
|
|
622
|
674
|
/**
|
623
|
675
|
* 获取当前资源申请的状态值。
|
|
676
|
*
|
624
|
677
|
* @param con
|
625
|
|
* @param operationId 资源申请ID
|
|
678
|
* @param operationId
|
|
679
|
* 资源申请ID
|
626
|
680
|
* @return 返回资源申请状态值
|
627
|
681
|
* @throws SQLException
|
628
|
682
|
*/
|
629
|
|
public int queryOper(Connection con, String operationId) throws SQLException{
|
|
683
|
public int queryOper(Connection con, String operationId) throws SQLException {
|
630
|
684
|
String sql = "SELECT OPERATION_STATUS FROM OPERATION WHERE OPERATION_ID = ?";
|
631
|
685
|
PreparedStatement ps = con.prepareStatement(sql);
|
632
|
686
|
try {
|
633
|
687
|
ps.setString(1, operationId);
|
634
|
688
|
ResultSet rs = ps.executeQuery();
|
635
|
|
try{
|
|
689
|
try {
|
636
|
690
|
rs.next();
|
637
|
691
|
return rs.getInt(1);
|
638
|
|
}finally{
|
639
|
|
try{rs.close();}catch(Exception e1){}
|
640
|
|
}
|
641
|
|
}finally{
|
642
|
|
try{ps.close();}catch(Exception e2){}
|
643
|
|
}
|
|
692
|
} finally {
|
|
693
|
try {
|
|
694
|
rs.close();
|
|
695
|
} catch (Exception e1) {
|
|
696
|
}
|
|
697
|
}
|
|
698
|
} finally {
|
|
699
|
try {
|
|
700
|
ps.close();
|
|
701
|
} catch (Exception e2) {
|
|
702
|
}
|
|
703
|
}
|
|
704
|
}
|
|
705
|
|
|
706
|
public int deleteDem(Connection con, String operationId, String demandId) throws SQLException {
|
|
707
|
int index = 1;
|
|
708
|
String sql = "DELETE FROM OPERATION WHERE OPERATION_STATUS = 1 AND DEMAND_ID = ? AND OPERATION_ID = ?";
|
|
709
|
PreparedStatement ps = con.prepareStatement(sql);
|
|
710
|
try {
|
|
711
|
ps.setString(index++, demandId);
|
|
712
|
ps.setString(index++, operationId);
|
|
713
|
return ps.executeUpdate();
|
|
714
|
} finally {
|
|
715
|
try {
|
|
716
|
ps.close();
|
|
717
|
} catch (Exception e) {
|
|
718
|
}
|
|
719
|
}
|
644
|
720
|
}
|
645
|
|
|
646
|
|
public int deleteDem(Connection con,String operationId,String demandId) throws SQLException{
|
647
|
|
int index = 1;
|
648
|
|
String sql = "DELETE FROM OPERATION WHERE OPERATION_STATUS = 1 AND DEMAND_ID = ? AND OPERATION_ID = ?";
|
649
|
|
PreparedStatement ps = con.prepareStatement(sql);
|
650
|
|
try{
|
651
|
|
ps.setString(index++,demandId);
|
652
|
|
ps.setString(index++,operationId);
|
653
|
|
return ps.executeUpdate();
|
654
|
|
}finally{
|
655
|
|
try{ps.close();}catch(Exception e){}
|
656
|
|
}
|
657
|
|
}
|
658
|
|
|
|
721
|
|
659
|
722
|
/**
|
660
|
723
|
* 分页查询资源申请 多条件模糊查询
|
|
724
|
*
|
661
|
725
|
* @param con
|
662
|
|
* @param professorName 申请人姓名
|
663
|
|
* @param resourceName 资源名称
|
664
|
|
* @param firstTime 申请时间 查询初试时间
|
665
|
|
* @param lastTime 申请时间 查询结束时间
|
666
|
|
* @param lowPrice 成交价格 查询较低价格
|
667
|
|
* @param highPrice 成交时间 查询较高价格
|
668
|
|
* @param pageSize 每页记录数
|
669
|
|
* @param pageNo 当前页码
|
|
726
|
* @param professorName
|
|
727
|
* 申请人姓名
|
|
728
|
* @param resourceName
|
|
729
|
* 资源名称
|
|
730
|
* @param firstTime
|
|
731
|
* 申请时间 查询初试时间
|
|
732
|
* @param lastTime
|
|
733
|
* 申请时间 查询结束时间
|
|
734
|
* @param lowPrice
|
|
735
|
* 成交价格 查询较低价格
|
|
736
|
* @param highPrice
|
|
737
|
* 成交时间 查询较高价格
|
|
738
|
* @param pageSize
|
|
739
|
* 每页记录数
|
|
740
|
* @param pageNo
|
|
741
|
* 当前页码
|
670
|
742
|
* @return
|
671
|
743
|
* @throws SQLException
|
672
|
744
|
*/
|
673
|
|
public PageQueryResult<Operation> queryPage(Connection con,String professorName,String resourceName,String firstTime,String lastTime,java.math.BigDecimal lowPrice,java.math.BigDecimal highPrice,int pageSize,int pageNo) throws SQLException{
|
674
|
|
int total = 0;
|
675
|
|
PageQueryResult<Operation> queryResult = new PageQueryResult<Operation>();
|
676
|
|
int index = 1;
|
677
|
|
boolean hasProName = null != professorName;
|
678
|
|
boolean hasResName = null != resourceName;
|
679
|
|
boolean hasFirstTime = null != firstTime;
|
680
|
|
boolean hasLastTime = null != lastTime;
|
681
|
|
boolean hasLowPrice = null != lowPrice;
|
682
|
|
boolean hasHighPrice = null != highPrice;
|
683
|
|
StringBuilder sql = new StringBuilder();
|
684
|
|
boolean hasWhere = true;
|
685
|
|
if(hasProName){
|
686
|
|
hasWhere = false;
|
687
|
|
sql.append(" WHERE DEMAND_ID (SELECT PROFESSOR.PROFESSOR.ID FROM PROFESSOR WHERE PROFESSOR.NAME LIKE ?)");
|
688
|
|
}
|
689
|
|
if(hasResName){
|
690
|
|
if(hasWhere){
|
691
|
|
hasWhere = false;
|
692
|
|
sql.append(" WHERE OPERATION.RESOURCE_ID IN (SELECT RESOURCE.RESOURCE_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)");
|
693
|
|
}else{
|
694
|
|
sql.append(" OR OPERATION.RESOURCE_ID IN (SELECT RESOURCE.RESOURCE_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)");
|
695
|
|
}
|
696
|
|
}
|
697
|
|
if(hasFirstTime){
|
698
|
|
if(hasWhere){
|
699
|
|
hasWhere = false;
|
700
|
|
sql.append(" WHERE OPERATION.CREATE_TIME > ?");
|
701
|
|
}else{
|
702
|
|
sql.append(" AND OPERATION.CREATE_TIME > ?");
|
703
|
|
}
|
704
|
|
}
|
705
|
|
if(hasLastTime){
|
706
|
|
if(hasWhere){
|
707
|
|
hasWhere = false;
|
708
|
|
sql.append(" WHERE OPERATION.CREATE_TIME <= ?");
|
709
|
|
}else{
|
710
|
|
sql.append(" AND OPERATION.CREATE_TIME <= ?");
|
711
|
|
}
|
712
|
|
}
|
713
|
|
if(hasLowPrice){
|
714
|
|
if(hasWhere){
|
715
|
|
hasWhere = false;
|
716
|
|
sql.append(" WHERE DEAL_PRICE > ?");
|
717
|
|
}else{
|
718
|
|
sql.append(" AND DEAL_PRICE > ?");
|
719
|
|
}
|
720
|
|
}
|
721
|
|
if(hasHighPrice){
|
722
|
|
if(hasWhere){
|
723
|
|
hasWhere = false;
|
724
|
|
sql.append(" WHERE DEAL_PRICE <= ?");
|
725
|
|
}else{
|
726
|
|
sql.append(" AND DEAL_PRICE <= ?");
|
727
|
|
}
|
728
|
|
}
|
729
|
|
StringBuilder whereSql = sql;
|
730
|
|
sql = new StringBuilder();
|
731
|
|
sql.append("SELECT COUNT(1) FROM OPERATION");
|
732
|
|
if(whereSql.length()>0){
|
733
|
|
sql.append(whereSql);
|
734
|
|
}
|
735
|
|
PreparedStatement ps = con.prepareStatement(sql.toString());
|
736
|
|
try{
|
737
|
|
if(hasProName){
|
738
|
|
ps.setString(index++,professorName);
|
739
|
|
}
|
740
|
|
if(hasResName){
|
741
|
|
ps.setString(index++,resourceName);
|
742
|
|
}
|
743
|
|
if(hasFirstTime){
|
744
|
|
ps.setString(index++,firstTime);
|
745
|
|
}
|
746
|
|
if(hasLastTime){
|
747
|
|
ps.setString(index++,lastTime);
|
748
|
|
}
|
749
|
|
if(hasLowPrice){
|
750
|
|
ps.setBigDecimal(index++,lowPrice);
|
751
|
|
}
|
752
|
|
if(hasHighPrice){
|
753
|
|
ps.setBigDecimal(index++,highPrice);
|
754
|
|
}
|
755
|
|
queryResult.setPageSize(pageSize);
|
756
|
|
ResultSet rs = ps.executeQuery();
|
757
|
|
try{
|
758
|
|
rs.next();
|
759
|
|
total = rs.getInt(1);
|
760
|
|
}finally{
|
761
|
|
try{rs.close();}catch(Exception e1){}
|
762
|
|
}
|
763
|
|
}finally{
|
764
|
|
try{ps.close();}catch(Exception e2){}
|
765
|
|
}
|
766
|
|
queryResult.setTotal(total);
|
767
|
|
if(0== total){
|
768
|
|
queryResult.setPageNo(1);
|
769
|
|
queryResult.setData(Collections.<Operation>emptyList());
|
770
|
|
return queryResult;
|
771
|
|
}
|
772
|
|
index = 1;
|
773
|
|
boolean firstPage = (1 == pageNo);
|
774
|
|
if(firstPage){
|
775
|
|
queryResult.setPageNo(1);
|
776
|
|
sql = new StringBuilder();
|
777
|
|
sql.append("SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,"
|
778
|
|
+ " DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,"
|
779
|
|
+ " P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE "
|
780
|
|
+ " FROM OPERATION LEFT JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
781
|
|
+ " LEFT JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
782
|
|
+ " LEFT JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID");
|
783
|
|
if(whereSql.length()>0){
|
784
|
|
sql.append(whereSql);
|
785
|
|
}
|
786
|
|
sql.append(" ORDER BY OPERATION.CREATE_TIME");
|
787
|
|
sql.append(" LIMIT ").append(pageSize);
|
788
|
|
}else{
|
789
|
|
int pageNum = total / pageSize;
|
790
|
|
if(total % pageSize != 0){
|
791
|
|
++pageNum;
|
792
|
|
}
|
793
|
|
if(pageNo > pageNum){
|
794
|
|
pageNo = pageNum;
|
795
|
|
}
|
796
|
|
queryResult.setPageNo(pageNo);
|
797
|
|
--pageNo;
|
798
|
|
int offset = (pageNo * pageSize);
|
799
|
|
sql = new StringBuilder();
|
800
|
|
sql.append("SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,"
|
801
|
|
+ " DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,"
|
802
|
|
+ " P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE "
|
803
|
|
+ " FROM OPERATION LEFT JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
804
|
|
+ " LEFT JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID "
|
805
|
|
+ " LEFT JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID");
|
806
|
|
if(whereSql.length()>0){
|
807
|
|
sql.append(whereSql);
|
808
|
|
}
|
809
|
|
sql.append(" ORDER BY OPERATION.CREATE_TIME");
|
810
|
|
sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
|
811
|
|
}
|
812
|
|
ps = con.prepareStatement(sql.toString());
|
813
|
|
try{
|
814
|
|
if(hasProName){
|
815
|
|
ps.setString(index++,professorName);
|
816
|
|
}
|
817
|
|
if(hasResName){
|
818
|
|
ps.setString(index++,resourceName);
|
819
|
|
}
|
820
|
|
if(hasFirstTime){
|
821
|
|
ps.setString(index++,firstTime);
|
822
|
|
}
|
823
|
|
if(hasLastTime){
|
824
|
|
ps.setString(index++,lastTime);
|
825
|
|
}
|
826
|
|
if(hasLowPrice){
|
827
|
|
ps.setBigDecimal(index++,lowPrice);
|
828
|
|
}
|
829
|
|
if(hasHighPrice){
|
830
|
|
ps.setBigDecimal(index++,highPrice);
|
831
|
|
}
|
832
|
|
ResultSet rs = ps.executeQuery();
|
833
|
|
try{
|
834
|
|
List<Operation> operations = new ArrayList<Operation>();
|
835
|
|
queryResult.setData(operations);
|
836
|
|
int size = 0;
|
837
|
|
while((size<pageSize) && rs.next()){
|
838
|
|
++size;
|
839
|
|
Operation operation = new Operation();
|
840
|
|
operation.setReplyNotes(rs.getString(1));
|
841
|
|
operation.setCreateTime(rs.getString(2));
|
842
|
|
operation.setOperationId(rs.getString(3));
|
843
|
|
operation.setOperationStatus(rs.getInt(4));
|
844
|
|
Professor professor = new Professor();
|
845
|
|
professor.setId(rs.getString(5));
|
846
|
|
operation.setDetailDemand(rs.getString(6));
|
847
|
|
operation.setDeliverTime(rs.getString(7));
|
848
|
|
Resource resource = new Resource();
|
849
|
|
resource.setResourceId(rs.getString(8));
|
850
|
|
operation.setDealPrice(rs.getBigDecimal(9));
|
851
|
|
operation.setDealTime(rs.getString(10));
|
852
|
|
operation.setPayMethod(rs.getString(11));
|
853
|
|
professor.setName(rs.getString(12));
|
854
|
|
operation.setProfessor(professor);
|
855
|
|
resource.setResourceName(rs.getString(13));
|
856
|
|
Professor professor2 = new Professor();
|
857
|
|
professor2.setId(rs.getString(14));
|
858
|
|
professor2.setName(rs.getString(15));
|
859
|
|
resource.setProfessor(professor2);
|
860
|
|
operation.setResource(resource);
|
861
|
|
operation.setApplysquare(rs.getString(16));
|
862
|
|
operations.add(operation);
|
863
|
|
}
|
864
|
|
return queryResult;
|
865
|
|
}finally{
|
866
|
|
try{rs.close();}catch(Exception e3){}
|
867
|
|
}
|
868
|
|
}finally{
|
869
|
|
try{ps.close();}catch(Exception e4){}
|
870
|
|
}
|
871
|
|
}
|
872
|
|
|
|
745
|
public PageQueryResult<Operation> queryPage(Connection con, String professorName, String resourceName, String firstTime, String lastTime,
|
|
746
|
java.math.BigDecimal lowPrice, java.math.BigDecimal highPrice, int pageSize, int pageNo) throws SQLException {
|
|
747
|
int total = 0;
|
|
748
|
PageQueryResult<Operation> queryResult = new PageQueryResult<Operation>();
|
|
749
|
int index = 1;
|
|
750
|
boolean hasProName = null != professorName;
|
|
751
|
boolean hasResName = null != resourceName;
|
|
752
|
boolean hasFirstTime = null != firstTime;
|
|
753
|
boolean hasLastTime = null != lastTime;
|
|
754
|
boolean hasLowPrice = null != lowPrice;
|
|
755
|
boolean hasHighPrice = null != highPrice;
|
|
756
|
StringBuilder sql = new StringBuilder();
|
|
757
|
boolean hasWhere = true;
|
|
758
|
if (hasProName) {
|
|
759
|
hasWhere = false;
|
|
760
|
sql.append(" WHERE DEMAND_ID (SELECT PROFESSOR.PROFESSOR.ID FROM PROFESSOR WHERE PROFESSOR.NAME LIKE ?)");
|
|
761
|
}
|
|
762
|
if (hasResName) {
|
|
763
|
if (hasWhere) {
|
|
764
|
hasWhere = false;
|
|
765
|
sql.append(" WHERE OPERATION.RESOURCE_ID IN (SELECT RESOURCE.RESOURCE_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)");
|
|
766
|
} else {
|
|
767
|
sql.append(" OR OPERATION.RESOURCE_ID IN (SELECT RESOURCE.RESOURCE_ID FROM RESOURCE WHERE RESOURCE_NAME LIKE ?)");
|
|
768
|
}
|
|
769
|
}
|
|
770
|
if (hasFirstTime) {
|
|
771
|
if (hasWhere) {
|
|
772
|
hasWhere = false;
|
|
773
|
sql.append(" WHERE OPERATION.CREATE_TIME > ?");
|
|
774
|
} else {
|
|
775
|
sql.append(" AND OPERATION.CREATE_TIME > ?");
|
|
776
|
}
|
|
777
|
}
|
|
778
|
if (hasLastTime) {
|
|
779
|
if (hasWhere) {
|
|
780
|
hasWhere = false;
|
|
781
|
sql.append(" WHERE OPERATION.CREATE_TIME <= ?");
|
|
782
|
} else {
|
|
783
|
sql.append(" AND OPERATION.CREATE_TIME <= ?");
|
|
784
|
}
|
|
785
|
}
|
|
786
|
if (hasLowPrice) {
|
|
787
|
if (hasWhere) {
|
|
788
|
hasWhere = false;
|
|
789
|
sql.append(" WHERE DEAL_PRICE > ?");
|
|
790
|
} else {
|
|
791
|
sql.append(" AND DEAL_PRICE > ?");
|
|
792
|
}
|
|
793
|
}
|
|
794
|
if (hasHighPrice) {
|
|
795
|
if (hasWhere) {
|
|
796
|
hasWhere = false;
|
|
797
|
sql.append(" WHERE DEAL_PRICE <= ?");
|
|
798
|
} else {
|
|
799
|
sql.append(" AND DEAL_PRICE <= ?");
|
|
800
|
}
|
|
801
|
}
|
|
802
|
StringBuilder whereSql = sql;
|
|
803
|
sql = new StringBuilder();
|
|
804
|
sql.append("SELECT COUNT(1) FROM OPERATION");
|
|
805
|
if (whereSql.length() > 0) {
|
|
806
|
sql.append(whereSql);
|
|
807
|
}
|
|
808
|
PreparedStatement ps = con.prepareStatement(sql.toString());
|
|
809
|
try {
|
|
810
|
if (hasProName) {
|
|
811
|
ps.setString(index++, professorName);
|
|
812
|
}
|
|
813
|
if (hasResName) {
|
|
814
|
ps.setString(index++, resourceName);
|
|
815
|
}
|
|
816
|
if (hasFirstTime) {
|
|
817
|
ps.setString(index++, firstTime);
|
|
818
|
}
|
|
819
|
if (hasLastTime) {
|
|
820
|
ps.setString(index++, lastTime);
|
|
821
|
}
|
|
822
|
if (hasLowPrice) {
|
|
823
|
ps.setBigDecimal(index++, lowPrice);
|
|
824
|
}
|
|
825
|
if (hasHighPrice) {
|
|
826
|
ps.setBigDecimal(index++, highPrice);
|
|
827
|
}
|
|
828
|
queryResult.setPageSize(pageSize);
|
|
829
|
ResultSet rs = ps.executeQuery();
|
|
830
|
try {
|
|
831
|
rs.next();
|
|
832
|
total = rs.getInt(1);
|
|
833
|
} finally {
|
|
834
|
try {
|
|
835
|
rs.close();
|
|
836
|
} catch (Exception e1) {
|
|
837
|
}
|
|
838
|
}
|
|
839
|
} finally {
|
|
840
|
try {
|
|
841
|
ps.close();
|
|
842
|
} catch (Exception e2) {
|
|
843
|
}
|
|
844
|
}
|
|
845
|
queryResult.setTotal(total);
|
|
846
|
if (0 == total) {
|
|
847
|
queryResult.setPageNo(1);
|
|
848
|
queryResult.setData(Collections.<Operation> emptyList());
|
|
849
|
return queryResult;
|
|
850
|
}
|
|
851
|
index = 1;
|
|
852
|
boolean firstPage = (1 == pageNo);
|
|
853
|
if (firstPage) {
|
|
854
|
queryResult.setPageNo(1);
|
|
855
|
sql = new StringBuilder();
|
|
856
|
sql.append("SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,"
|
|
857
|
+ " DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,"
|
|
858
|
+ " P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE " + " FROM OPERATION LEFT JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
|
859
|
+ " LEFT JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID " + " LEFT JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID");
|
|
860
|
if (whereSql.length() > 0) {
|
|
861
|
sql.append(whereSql);
|
|
862
|
}
|
|
863
|
sql.append(" ORDER BY OPERATION.CREATE_TIME");
|
|
864
|
sql.append(" LIMIT ").append(pageSize);
|
|
865
|
} else {
|
|
866
|
int pageNum = total / pageSize;
|
|
867
|
if (total % pageSize != 0) {
|
|
868
|
++pageNum;
|
|
869
|
}
|
|
870
|
if (pageNo > pageNum) {
|
|
871
|
pageNo = pageNum;
|
|
872
|
}
|
|
873
|
queryResult.setPageNo(pageNo);
|
|
874
|
--pageNo;
|
|
875
|
int offset = (pageNo * pageSize);
|
|
876
|
sql = new StringBuilder();
|
|
877
|
sql.append("SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,"
|
|
878
|
+ " DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,"
|
|
879
|
+ " P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE " + " FROM OPERATION LEFT JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID "
|
|
880
|
+ " LEFT JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID " + " LEFT JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID");
|
|
881
|
if (whereSql.length() > 0) {
|
|
882
|
sql.append(whereSql);
|
|
883
|
}
|
|
884
|
sql.append(" ORDER BY OPERATION.CREATE_TIME");
|
|
885
|
sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
|
|
886
|
}
|
|
887
|
ps = con.prepareStatement(sql.toString());
|
|
888
|
try {
|
|
889
|
if (hasProName) {
|
|
890
|
ps.setString(index++, professorName);
|
|
891
|
}
|
|
892
|
if (hasResName) {
|
|
893
|
ps.setString(index++, resourceName);
|
|
894
|
}
|
|
895
|
if (hasFirstTime) {
|
|
896
|
ps.setString(index++, firstTime);
|
|
897
|
}
|
|
898
|
if (hasLastTime) {
|
|
899
|
ps.setString(index++, lastTime);
|
|
900
|
}
|
|
901
|
if (hasLowPrice) {
|
|
902
|
ps.setBigDecimal(index++, lowPrice);
|
|
903
|
}
|
|
904
|
if (hasHighPrice) {
|
|
905
|
ps.setBigDecimal(index++, highPrice);
|
|
906
|
}
|
|
907
|
ResultSet rs = ps.executeQuery();
|
|
908
|
try {
|
|
909
|
List<Operation> operations = new ArrayList<Operation>();
|
|
910
|
queryResult.setData(operations);
|
|
911
|
int size = 0;
|
|
912
|
while ((size < pageSize) && rs.next()) {
|
|
913
|
++size;
|
|
914
|
Operation operation = new Operation();
|
|
915
|
operation.setReplyNotes(rs.getString(1));
|
|
916
|
operation.setCreateTime(rs.getString(2));
|
|
917
|
operation.setOperationId(rs.getString(3));
|
|
918
|
operation.setOperationStatus(rs.getInt(4));
|
|
919
|
Professor professor = new Professor();
|
|
920
|
professor.setId(rs.getString(5));
|
|
921
|
operation.setDetailDemand(rs.getString(6));
|
|
922
|
operation.setDeliverTime(rs.getString(7));
|
|
923
|
Resource resource = new Resource();
|
|
924
|
resource.setResourceId(rs.getString(8));
|
|
925
|
operation.setDealPrice(rs.getBigDecimal(9));
|
|
926
|
operation.setDealTime(rs.getString(10));
|
|
927
|
operation.setPayMethod(rs.getString(11));
|
|
928
|
professor.setName(rs.getString(12));
|
|
929
|
operation.setProfessor(professor);
|
|
930
|
resource.setResourceName(rs.getString(13));
|
|
931
|
Professor professor2 = new Professor();
|
|
932
|
professor2.setId(rs.getString(14));
|
|
933
|
professor2.setName(rs.getString(15));
|
|
934
|
resource.setProfessor(professor2);
|
|
935
|
operation.setResource(resource);
|
|
936
|
operation.setApplysquare(rs.getString(16));
|
|
937
|
operations.add(operation);
|
|
938
|
}
|
|
939
|
return queryResult;
|
|
940
|
} finally {
|
|
941
|
try {
|
|
942
|
rs.close();
|
|
943
|
} catch (Exception e3) {
|
|
944
|
}
|
|
945
|
}
|
|
946
|
} finally {
|
|
947
|
try {
|
|
948
|
ps.close();
|
|
949
|
} catch (Exception e4) {
|
|
950
|
}
|
|
951
|
}
|
|
952
|
}
|
|
953
|
|
873
|
954
|
}
|