jiapeng %!s(int64=7) %!d(string=hace) años
padre
commit
e7621e713e

+ 529 - 442
src/main/java/com/ekexiu/portal/dao/DemandDao.java

@ -1,27 +1,32 @@
1 1
package com.ekexiu.portal.dao;
2 2

3 3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
6 4
import java.sql.SQLException;
7
import java.util.ArrayList;
8
import java.util.Collections;
9 5
import java.util.List;
10 6

7
import org.jfw.apt.annotation.DefaultValue;
11 8
import org.jfw.apt.annotation.Nullable;
12 9
import org.jfw.apt.orm.annotation.dao.Column;
13 10
import org.jfw.apt.orm.annotation.dao.DAO;
14 11
import org.jfw.apt.orm.annotation.dao.method.From;
12
import org.jfw.apt.orm.annotation.dao.method.IncludeFixSet;
15 13
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
14
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
15
import org.jfw.apt.orm.annotation.dao.method.Where;
16 16
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
17
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
17 18
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
18 19
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
19 20
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
21
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
20 22
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
23
import org.jfw.apt.orm.annotation.dao.param.GroupSqlColumn;
24
import org.jfw.apt.orm.annotation.dao.param.In;
25
import org.jfw.apt.orm.annotation.dao.param.LessThan;
21 26
import org.jfw.apt.orm.annotation.dao.param.Set;
22 27
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
28
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
23 29
import org.jfw.util.PageQueryResult;
24
import org.jfw.util.exception.JfwBaseException;
25 30

26 31
import com.ekexiu.portal.po.Demand;
27 32

@ -30,457 +35,539 @@ public abstract class DemandDao {
30 35
	@Insert
31 36
	public abstract int insert(Connection con,Demand demand)throws SQLException;
32 37
	
38
	@Update
39
	@Where("STATE IN ('0','1')")
40
	public abstract int update(Connection con,Demand demand) throws SQLException;
41
	
42
	
33 43
	@UpdateWith
44
	@Where("STATE IN ('0','1')")
45
	@SetSentence("STATE='3'")
46
	@IncludeFixSet
34 47
	@From(Demand.class)
35
	public abstract int updateDemandStatus(Connection con,String demandId,@Set String demandStatus,@Set String closeTime)throws SQLException;
48
	public abstract int close(Connection con,String id,@Set String modifier)throws SQLException;
36 49
	
37
	@SelectOne
38
	@Nullable
39
	public abstract Demand queryOne(Connection con,String demandId)throws SQLException;
50
	@UpdateWith
51
	@Where("STATE IN ('0','1')")
52
	@SetSentence("STATE='3'")
53
	@IncludeFixSet
54
	@From(Demand.class)
55
	public abstract int closeByCreator(Connection con,String creator,@Set String modifier)throws SQLException;
40 56
	
41
	@QueryVal
42
	@Column(handlerClass=IntHandler.class,value="COUNT(1)")
57
	
58
	
59
	
60
	@UpdateWith
61
	@Where("STATE IN ('0','1')")
62
	@SetSentence("STATE='2'")
63
	@IncludeFixSet
64
	@From(Demand.class)
65
	public abstract int over(Connection con,String id,@Set String modifier)throws SQLException;
66
	
67
	@UpdateWith
68
	@Where("STATE IN ('0','1')")
69
	@SetSentence("STATE='1'")
70
	@IncludeFixSet
71
	@From(Demand.class)
72
	public abstract int defer(Connection con,String id,@Set String modifier,@Set String invalidDay)throws SQLException;
73
	
74
	
75
	
76
	@UpdateWith
77
	@Where("STATE ='1'")
78
	@SetSentence("STATE='0'")
43 79
	@From(Demand.class)
44
	public abstract int queryCountByStatus(Connection con,String demander,String demandStatus)throws SQLException, JfwBaseException;
80
	public abstract int invalid(Connection con,@LessThan String invalidDay)throws SQLException;
81
	
45 82
	
46 83
	@QueryVal
47 84
	@Column(handlerClass=IntHandler.class,value="COUNT(1)")
48 85
	@From(Demand.class)
49
	public abstract int queryCountStatus(Connection con,String demandStatus)throws SQLException, JfwBaseException;
86
	@DefaultValue("0")
87
	public abstract int cnt(Connection con,@Nullable @In String[] state,@Nullable String creator,@Nullable String orgId)throws SQLException;
88
	
89
	@SelectOne
90
	@Nullable
91
	public abstract Demand query(Connection con,String id)throws SQLException;
92
	@SelectOne
93
	@Nullable
94
	public abstract Demand query(Connection con,long shareId)throws SQLException;
50 95
	
51 96
	@SelectList
52
	@OrderBy("ORDER BY CREATE_TIME DESC")
53
	public abstract List<Demand> queryForOrg(Connection con,String orgId)throws SQLException;
54
	
55
	@SelectList
56
	@OrderBy("ORDER BY CREATE_TIME DESC")
57
	public abstract List<Demand> queryByDemander(Connection con,String demander)throws SQLException;
97
	public abstract List<Demand> query(Connection con,@In String[] id)throws SQLException;
58 98
	
59
	public PageQueryResult<Demand> pageQueryByDemander(Connection con,String demander,String demandStatus,int sortType,int pageSize,int pageNo) throws SQLException{
60
        int total = 0;
61
        PageQueryResult<Demand> queryResult = new PageQueryResult<Demand>();
62
        int index = 1;
63
        boolean hasDemandStatus = null != demandStatus;
64
        StringBuilder sql = new StringBuilder();
65
        sql.append(" WHERE DEMANDER = ?");
66
        if(hasDemandStatus){
67
            sql.append(" AND DEMAND_STATUS = ?");
68
        }
69
        StringBuilder whereSql = sql;
70
        sql = new StringBuilder();
71
        sql.append("SELECT COUNT(1) FROM DEMAND");
72
        sql.append(whereSql);
73
        PreparedStatement ps = con.prepareStatement(sql.toString());
74
        try{
75
            ps.setString(index++,demander);
76
            if(hasDemandStatus){
77
                ps.setString(index++,demandStatus);
78
            }
79
            queryResult.setPageSize(pageSize);
80
            ResultSet rs = ps.executeQuery();
81
            try{
82
                rs.next();
83
                total = rs.getInt(1);
84
            }finally{
85
                try{rs.close();}catch(Exception e1){}
86
            }
87
        }finally{
88
            try{ps.close();}catch(Exception e2){}
89
        }
90
        queryResult.setTotal(total);
91
        if(0== total){
92
        	queryResult.setPageNo(1);
93
        	queryResult.setData(Collections.<Demand>emptyList());
94
            return queryResult;
95
        }
96
        index = 1;
97
        boolean firstPage = (1 == pageNo);
98
        if(firstPage){
99
        	queryResult.setPageNo(1);
100
            sql = new StringBuilder();
101
            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME FROM DEMAND");
102
            sql.append(whereSql);
103
            sql.append(" ORDER BY CREATE_TIME");
104
            if(sortType == 0){
105
            	sql.append(" DESC ");
106
            }
107
            sql.append(" LIMIT ").append(pageSize);
108
        }else{
109
            int pageNumber = total / pageSize;
110
            if(total % pageSize != 0){
111
                ++pageNumber;
112
            }
113
            if(pageNo > pageNumber){
114
                pageNo = pageNumber;
115
            }
116
            queryResult.setPageNo(pageNo);
117
            --pageNo;
118
            int offset = (pageNo * pageSize);
119
            sql = new StringBuilder();
120
            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME FROM DEMAND");
121
            sql.append(whereSql);
122
            sql.append(" ORDER BY CREATE_TIME");
123
            if(sortType == 0){
124
            	sql.append(" DESC ");
125
            }
126
            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
127
        }
128
        ps = con.prepareStatement(sql.toString());
129
        try{
130
            ps.setString(index++,demander);
131
            if(hasDemandStatus){
132
                ps.setString(index++,demandStatus);
133
            }
134
            ResultSet rs = ps.executeQuery();
135
            try{
136
                List<Demand> demands = new ArrayList<Demand>();
137
                queryResult.setData(demands);
138
                int size = 0;
139
                while((size<pageSize) && rs.next()){
140
                    ++size;
141
                    Demand demand =  new Demand();
142
                    demand.setDemandId(rs.getString(1));
143
                    demand.setDemander(rs.getString(2));
144
                    demand.setDemandAim(rs.getString(3));
145
                    demand.setDemandType(rs.getString(4));
146
                    demand.setDemandTitle(rs.getString(5));
147
                    String demandContent = rs.getString(6);
148
                    if(rs.wasNull()){
149
                    	demandContent = null;
150
                    }
151
                    demand.setDemandContent(demandContent);
152
                    demand.setDemandStatus(rs.getString(7));
153
                    String closeTime = rs.getString(8);
154
                    if(rs.wasNull()){
155
                    	closeTime = null;
156
                    }
157
                    demand.setCloseTime(closeTime);
158
                    demand.setOrderKey(rs.getLong(9));
159
                    demand.setCreateTime(rs.getString(10));
160
                    demands.add(demand);
161
                }
162
                return queryResult;
163
            }finally{
164
                try{rs.close();}catch(Exception e3){}
165
            }
166
        }finally{
167
            try{ps.close();}catch(Exception e4){}
168
        }
169
    }
99
	@UpdateWith
100
	@From(Demand.class)
101
	@SetSentence("PAGE_VIEWS=PAGE_VIEWS+1")
102
	public abstract int incPageViews(Connection con,String id)throws SQLException;
103
	
104
	
105
	
106
	@PageSelect
107
	@OrderBy(" ORDER BY STATE ASC,CREATE_TIME DESC")
108
	public abstract PageQueryResult<Demand> pageQuery(Connection con,@Nullable @In String[] state,@Nullable String creator,@Nullable String orgId,int pageSize,int pageNo) throws SQLException;
109
	
110
	
111
	@PageSelect
112
	@OrderBy(" ORDER BY CREATE_TIME DESC")
113
	public abstract PageQueryResult<Demand> pageQuery(Connection con,@GroupSqlColumn(value={"TITLE LIKE ?","DESCP LIKE ?"},handlerClass=StringHandler.class,isAnd=false ,force =false)  @Nullable String key,int pageSize,int pageNo) throws SQLException;
114
	
115

170 116
	
171
	public PageQueryResult<Demand> pageQuery(Connection con,String demandStatus,String demandAim,int sortType,int pageSize,int pageNo) throws SQLException{
172
        int total = 0;
173
        PageQueryResult<Demand> queryResult = new PageQueryResult<Demand>();
174
        int index = 1;
175
        boolean hasDemandAim = null != demandAim;
176
        StringBuilder sql = new StringBuilder();
177
        sql.append(" WHERE DEMAND_STATUS = ?");
178
        if(hasDemandAim){
179
            sql.append(" AND DEMAND_AIM = ?");
180
        }
181
        StringBuilder whereSql = sql;
182
        sql = new StringBuilder();
183
        sql.append("SELECT COUNT(1) FROM DEMAND");
184
        if(whereSql.length()>0){
185
            sql.append(whereSql);
186
        }
187
        PreparedStatement ps = con.prepareStatement(sql.toString());
188
        try{
189
        	ps.setString(index++, demandStatus);
190
            if(hasDemandAim){
191
                ps.setString(index++,demandAim);
192
            }
193
            queryResult.setPageSize(pageSize);
194
            ResultSet rs = ps.executeQuery();
195
            try{
196
                rs.next();
197
                total = rs.getInt(1);
198
            }finally{
199
                try{rs.close();}catch(Exception e1){}
200
            }
201
        }finally{
202
            try{ps.close();}catch(Exception e2){}
203
        }
204
        queryResult.setTotal(total);
205
        if(0== total){
206
        	queryResult.setPageNo(1);
207
        	queryResult.setData(Collections.<Demand>emptyList());
208
            return queryResult;
209
        }
210
        index = 1;
211
        boolean firstPage = (1 == pageNo);
212
        if(firstPage){
213
        	queryResult.setPageNo(1);
214
            sql = new StringBuilder();
215
            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME,ORG_ID FROM DEMAND");
216
            if(whereSql.length()>0){
217
                sql.append(whereSql);
218
            }
219
            sql.append(" ORDER BY CREATE_TIME");
220
            if(sortType == 0){
221
            	sql.append(" DESC ");
222
            }
223
            sql.append(" LIMIT ").append(pageSize);
224
        }else{
225
            int pageNum = total / pageSize;
226
            if(total % pageSize != 0){
227
                ++pageNum;
228
            }
229
            if(pageNo > pageNum){
230
                pageNo = pageNum;
231
            }
232
            queryResult.setPageNo(pageNo);
233
            --pageNo;
234
            int offset = (pageNo * pageSize);
235
            sql = new StringBuilder();
236
            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME,ORG_ID FROM DEMAND");
237
            if(whereSql.length()>0){
238
                sql.append(whereSql);
239
            }
240
            sql.append(" ORDER BY CREATE_TIME");
241
            if(sortType == 0){
242
            	sql.append(" DESC ");
243
            }
244
            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
245
        }
246
        ps = con.prepareStatement(sql.toString());
247
        try{
248
        	ps.setString(index++, demandStatus);
249
            if(hasDemandAim){
250
                ps.setString(index++,demandAim);
251
            }
252
            ResultSet rs = ps.executeQuery();
253
            try{
254
                List<Demand> demands = new ArrayList<Demand>();
255
                queryResult.setData(demands);
256
                int size = 0;
257
                while((size<pageSize) && rs.next()){
258
                    ++size;
259
                    Demand demand =  new Demand();
260
                    demand.setDemandId(rs.getString(1));
261
                    demand.setDemander(rs.getString(2));
262
                    demand.setDemandAim(rs.getString(3));
263
                    demand.setDemandType(rs.getString(4));
264
                    demand.setDemandTitle(rs.getString(5));
265
                    String demandContent = rs.getString(6);
266
                    if(rs.wasNull()){
267
                        demandContent = null;
268
                    }
269
                    demand.setDemandContent(demandContent);
270
                    demand.setDemandStatus(rs.getString(7));
271
                    String closeTime = rs.getString(8);
272
                    if(rs.wasNull()){
273
                    	closeTime = null;
274
                    }
275
                    demand.setCloseTime(closeTime);
276
                    demand.setOrderKey(rs.getLong(9));
277
                    demand.setCreateTime(rs.getString(10));
278
                    String orgId = rs.getString(11);
279
                    if(rs.wasNull()){
280
                    	orgId = null;
281
                    }
282
                    demand.setOrgId(orgId);
283
                    demands.add(demand);
284
                }
285
                return queryResult;
286
            }finally{
287
                try{rs.close();}catch(Exception e3){}
288
            }
289
        }finally{
290
            try{ps.close();}catch(Exception e4){}
291
        }
292
    }
293 117
	
294
	public PageQueryResult<Demand> pageQueryOrg(Connection con,String orgId,String demandStatus,int sortType,int pageSize,int pageNo) throws SQLException{
295
        int total = 0;
296
        PageQueryResult<Demand> queryResult = new PageQueryResult<Demand>();
297
        int index = 1;
298
        boolean hasDemandStatus = null != demandStatus;
299
        StringBuilder sql = new StringBuilder();
300
        sql.append(" WHERE DEMAND_TYPE = '2' AND ORG_ID = ? ");
301
        if(hasDemandStatus){
302
            sql.append(" AND DEMAND_STATUS = ?");
303
        }
304
        StringBuilder whereSql = sql;
305
        sql = new StringBuilder();
306
        sql.append("SELECT COUNT(1) FROM DEMAND");
307
        if(whereSql.length()>0){
308
            sql.append(whereSql);
309
        }
310
        PreparedStatement ps = con.prepareStatement(sql.toString());
311
        try{
312
        	ps.setString(index++, orgId);
313
            if(hasDemandStatus){
314
                ps.setString(index++,demandStatus);
315
            }
316
            queryResult.setPageSize(pageSize);
317
            ResultSet rs = ps.executeQuery();
318
            try{
319
                rs.next();
320
                total = rs.getInt(1);
321
            }finally{
322
                try{rs.close();}catch(Exception e1){}
323
            }
324
        }finally{
325
            try{ps.close();}catch(Exception e2){}
326
        }
327
        queryResult.setTotal(total);
328
        if(0== total){
329
        	queryResult.setPageNo(1);
330
        	queryResult.setData(Collections.<Demand>emptyList());
331
            return queryResult;
332
        }
333
        index = 1;
334
        boolean firstPage = (1 == pageNo);
335
        if(firstPage){
336
        	queryResult.setPageNo(1);
337
            sql = new StringBuilder();
338
            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME,ORG_ID FROM DEMAND");
339
            if(whereSql.length()>0){
340
                sql.append(whereSql);
341
            }
342
            sql.append(" ORDER BY CREATE_TIME");
343
            if(sortType == 0){
344
            	sql.append(" DESC ");
345
            }
346
            sql.append(" LIMIT ").append(pageSize);
347
        }else{
348
            int pageNum = total / pageSize;
349
            if(total % pageSize != 0){
350
                ++pageNum;
351
            }
352
            if(pageNo > pageNum){
353
                pageNo = pageNum;
354
            }
355
            queryResult.setPageNo(pageNo);
356
            --pageNo;
357
            int offset = (pageNo * pageSize);
358
            sql = new StringBuilder();
359
            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME,ORG_ID FROM DEMAND");
360
            if(whereSql.length()>0){
361
                sql.append(whereSql);
362
            }
363
            sql.append(" ORDER BY CREATE_TIME");
364
            if(sortType == 0){
365
            	sql.append(" DESC ");
366
            }
367
            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
368
        }
369
        ps = con.prepareStatement(sql.toString());
370
        try{
371
        	ps.setString(index++, orgId);
372
            if(hasDemandStatus){
373
                ps.setString(index++,demandStatus);
374
            }
375
            ResultSet rs = ps.executeQuery();
376
            try{
377
                List<Demand> demands = new ArrayList<Demand>();
378
                queryResult.setData(demands);
379
                int size = 0;
380
                while((size<pageSize) && rs.next()){
381
                    ++size;
382
                    Demand demand =  new Demand();
383
                    demand.setDemandId(rs.getString(1));
384
                    demand.setDemander(rs.getString(2));
385
                    demand.setDemandAim(rs.getString(3));
386
                    demand.setDemandType(rs.getString(4));
387
                    demand.setDemandTitle(rs.getString(5));
388
                    String demandContent = rs.getString(6);
389
                    if(rs.wasNull()){
390
                        demandContent = null;
391
                    }
392
                    demand.setDemandContent(demandContent);
393
                    demand.setDemandStatus(rs.getString(7));
394
                    String closeTime = rs.getString(8);
395
                    if(rs.wasNull()){
396
                    	closeTime = null;
397
                    }
398
                    demand.setCloseTime(closeTime);
399
                    demand.setOrderKey(rs.getLong(9));
400
                    demand.setCreateTime(rs.getString(10));
401
                    String orgid = rs.getString(11);
402
                    if(rs.wasNull()){
403
                    	orgid = null;
404
                    }
405
                    demand.setOrgId(orgid);
406
                    demands.add(demand);
407
                }
408
                return queryResult;
409
            }finally{
410
                try{rs.close();}catch(Exception e3){}
411
            }
412
        }finally{
413
            try{ps.close();}catch(Exception e4){}
414
        }
415
    }
416 118
	
417
	public List<Demand> queryByStatus(Connection con,String demandStatus,String demandAim,String subject,String industry,String createTime,long orderKey,int rows,int sortType) throws SQLException{
418
        StringBuilder sql = new StringBuilder();
419
        sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,ORDER_KEY,CREATE_TIME FROM DEMAND ");
420
        boolean hasDemandAim = null != demandAim;
421
        boolean hasSubject = null !=subject;
422
        boolean hasIndustry = null != industry;
423
        sql.append(" WHERE DEMAND_STATUS = ? AND ORDER_KEY < ? AND CREATE_TIME < ? ");
424
        if(hasDemandAim){
425
        	sql.append(" AND DEMAND_AIM = ? ");
426
        }
427
        if(hasSubject){
428
        	sql.append(" AND DEMAND_ID IN (SELECT DEMAND_ID FROM DEMAND_SUB_OR_INDUS WHERE SUB_OR_INDUS LIKE ?) ");
429
        }
430
        if(hasIndustry){
431
        	sql.append(" AND DEMAND_ID IN (SELECT DEMAND_ID FROM DEMAND_SUB_OR_INDUS WHERE SUB_OR_INDUS LIKE ?) ");
432
        }
433
        sql.append(" ORDER BY CREATE_TIME ");
434
        if(sortType == 0){
435
        	sql.append(" DESC ");
436
        }
437
        sql.append(" ,ORDER_KEY ");
438
        if(sortType == 0){
439
        	sql.append(" DESC ");
440
        }
441
        sql.append(" LIMIT ").append(rows);
442
        int index = 1;
443
        PreparedStatement ps = con.prepareStatement(sql.toString());
444
        try{
445
        	ps.setString(index++, demandStatus);
446
            ps.setLong(index++,orderKey);
447
            ps.setString(index++,createTime);
448
            if(hasDemandAim){
449
            	ps.setString(index++,demandAim);
450
            }
451
            if(hasSubject){
452
            	ps.setString(index++,subject);
453
            }
454
            if(hasIndustry){
455
            	ps.setString(index++,industry);
456
            }
457
            ResultSet rs = ps.executeQuery();
458
            try{
459
                List<Demand> demands = new ArrayList<Demand>();
460
                while(rs.next()){
461
                    Demand demand =  new Demand();
462
                    demand.setDemandId(rs.getString(1));
463
                    demand.setDemander(rs.getString(2));
464
                    demand.setDemandAim(rs.getString(3));
465
                    demand.setDemandType(rs.getString(4));
466
                    demand.setDemandTitle(rs.getString(5));
467
                    String content = rs.getString(6);
468
                    if(rs.wasNull()){
469
                    	content = null;
470
                    }
471
                    demand.setDemandContent(content);
472
                    demand.setDemandStatus(rs.getString(7));
473
                    demand.setOrderKey(rs.getLong(8));
474
                    demand.setCreateTime(rs.getString(9));
475
                    demands.add(demand);
476
                }
477
                return demands;
478
            }finally{
479
                try{rs.close();}catch(Exception e1){}
480
            }
481
        }finally{
482
            try{ps.close();}catch(Exception e2){}
483
        }
484
    }
119
//	
120
//	@UpdateWith
121
//	@From(Demand.class)
122
//	public abstract int updateDemandStatus(Connection con,String demandId,@Set String demandStatus,@Set String closeTime)throws SQLException;
123
//	
124
//	@SelectOne
125
//	@Nullable
126
//	public abstract Demand queryOne(Connection con,String demandId)throws SQLException;
127
//	
128
//	@QueryVal
129
//	@Column(handlerClass=IntHandler.class,value="COUNT(1)")
130
//	@From(Demand.class)
131
//	public abstract int queryCountByStatus(Connection con,String demander,String demandStatus)throws SQLException, JfwBaseException;
132
//	
133
//	@QueryVal
134
//	@Column(handlerClass=IntHandler.class,value="COUNT(1)")
135
//	@From(Demand.class)
136
//	public abstract int queryCountStatus(Connection con,String demandStatus)throws SQLException, JfwBaseException;
137
//	
138
//	@SelectList
139
//	@OrderBy("ORDER BY CREATE_TIME DESC")
140
//	public abstract List<Demand> queryForOrg(Connection con,String orgId)throws SQLException;
141
//	
142
//	@SelectList
143
//	@OrderBy("ORDER BY CREATE_TIME DESC")
144
//	public abstract List<Demand> queryByDemander(Connection con,String demander)throws SQLException;
145
//	
146
//	public PageQueryResult<Demand> pageQueryByDemander(Connection con,String demander,String demandStatus,int sortType,int pageSize,int pageNo) throws SQLException{
147
//        int total = 0;
148
//        PageQueryResult<Demand> queryResult = new PageQueryResult<Demand>();
149
//        int index = 1;
150
//        boolean hasDemandStatus = null != demandStatus;
151
//        StringBuilder sql = new StringBuilder();
152
//        sql.append(" WHERE DEMANDER = ?");
153
//        if(hasDemandStatus){
154
//            sql.append(" AND DEMAND_STATUS = ?");
155
//        }
156
//        StringBuilder whereSql = sql;
157
//        sql = new StringBuilder();
158
//        sql.append("SELECT COUNT(1) FROM DEMAND");
159
//        sql.append(whereSql);
160
//        PreparedStatement ps = con.prepareStatement(sql.toString());
161
//        try{
162
//            ps.setString(index++,demander);
163
//            if(hasDemandStatus){
164
//                ps.setString(index++,demandStatus);
165
//            }
166
//            queryResult.setPageSize(pageSize);
167
//            ResultSet rs = ps.executeQuery();
168
//            try{
169
//                rs.next();
170
//                total = rs.getInt(1);
171
//            }finally{
172
//                try{rs.close();}catch(Exception e1){}
173
//            }
174
//        }finally{
175
//            try{ps.close();}catch(Exception e2){}
176
//        }
177
//        queryResult.setTotal(total);
178
//        if(0== total){
179
//        	queryResult.setPageNo(1);
180
//        	queryResult.setData(Collections.<Demand>emptyList());
181
//            return queryResult;
182
//        }
183
//        index = 1;
184
//        boolean firstPage = (1 == pageNo);
185
//        if(firstPage){
186
//        	queryResult.setPageNo(1);
187
//            sql = new StringBuilder();
188
//            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME FROM DEMAND");
189
//            sql.append(whereSql);
190
//            sql.append(" ORDER BY CREATE_TIME");
191
//            if(sortType == 0){
192
//            	sql.append(" DESC ");
193
//            }
194
//            sql.append(" LIMIT ").append(pageSize);
195
//        }else{
196
//            int pageNumber = total / pageSize;
197
//            if(total % pageSize != 0){
198
//                ++pageNumber;
199
//            }
200
//            if(pageNo > pageNumber){
201
//                pageNo = pageNumber;
202
//            }
203
//            queryResult.setPageNo(pageNo);
204
//            --pageNo;
205
//            int offset = (pageNo * pageSize);
206
//            sql = new StringBuilder();
207
//            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME FROM DEMAND");
208
//            sql.append(whereSql);
209
//            sql.append(" ORDER BY CREATE_TIME");
210
//            if(sortType == 0){
211
//            	sql.append(" DESC ");
212
//            }
213
//            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
214
//        }
215
//        ps = con.prepareStatement(sql.toString());
216
//        try{
217
//            ps.setString(index++,demander);
218
//            if(hasDemandStatus){
219
//                ps.setString(index++,demandStatus);
220
//            }
221
//            ResultSet rs = ps.executeQuery();
222
//            try{
223
//                List<Demand> demands = new ArrayList<Demand>();
224
//                queryResult.setData(demands);
225
//                int size = 0;
226
//                while((size<pageSize) && rs.next()){
227
//                    ++size;
228
//                    Demand demand =  new Demand();
229
//                    demand.setDemandId(rs.getString(1));
230
//                    demand.setDemander(rs.getString(2));
231
//                    demand.setDemandAim(rs.getString(3));
232
//                    demand.setDemandType(rs.getString(4));
233
//                    demand.setDemandTitle(rs.getString(5));
234
//                    String demandContent = rs.getString(6);
235
//                    if(rs.wasNull()){
236
//                    	demandContent = null;
237
//                    }
238
//                    demand.setDemandContent(demandContent);
239
//                    demand.setDemandStatus(rs.getString(7));
240
//                    String closeTime = rs.getString(8);
241
//                    if(rs.wasNull()){
242
//                    	closeTime = null;
243
//                    }
244
//                    demand.setCloseTime(closeTime);
245
//                    demand.setOrderKey(rs.getLong(9));
246
//                    demand.setCreateTime(rs.getString(10));
247
//                    demands.add(demand);
248
//                }
249
//                return queryResult;
250
//            }finally{
251
//                try{rs.close();}catch(Exception e3){}
252
//            }
253
//        }finally{
254
//            try{ps.close();}catch(Exception e4){}
255
//        }
256
//    }
257
//	
258
//	public PageQueryResult<Demand> pageQuery(Connection con,String demandStatus,String demandAim,int sortType,int pageSize,int pageNo) throws SQLException{
259
//        int total = 0;
260
//        PageQueryResult<Demand> queryResult = new PageQueryResult<Demand>();
261
//        int index = 1;
262
//        boolean hasDemandAim = null != demandAim;
263
//        StringBuilder sql = new StringBuilder();
264
//        sql.append(" WHERE DEMAND_STATUS = ?");
265
//        if(hasDemandAim){
266
//            sql.append(" AND DEMAND_AIM = ?");
267
//        }
268
//        StringBuilder whereSql = sql;
269
//        sql = new StringBuilder();
270
//        sql.append("SELECT COUNT(1) FROM DEMAND");
271
//        if(whereSql.length()>0){
272
//            sql.append(whereSql);
273
//        }
274
//        PreparedStatement ps = con.prepareStatement(sql.toString());
275
//        try{
276
//        	ps.setString(index++, demandStatus);
277
//            if(hasDemandAim){
278
//                ps.setString(index++,demandAim);
279
//            }
280
//            queryResult.setPageSize(pageSize);
281
//            ResultSet rs = ps.executeQuery();
282
//            try{
283
//                rs.next();
284
//                total = rs.getInt(1);
285
//            }finally{
286
//                try{rs.close();}catch(Exception e1){}
287
//            }
288
//        }finally{
289
//            try{ps.close();}catch(Exception e2){}
290
//        }
291
//        queryResult.setTotal(total);
292
//        if(0== total){
293
//        	queryResult.setPageNo(1);
294
//        	queryResult.setData(Collections.<Demand>emptyList());
295
//            return queryResult;
296
//        }
297
//        index = 1;
298
//        boolean firstPage = (1 == pageNo);
299
//        if(firstPage){
300
//        	queryResult.setPageNo(1);
301
//            sql = new StringBuilder();
302
//            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME,ORG_ID FROM DEMAND");
303
//            if(whereSql.length()>0){
304
//                sql.append(whereSql);
305
//            }
306
//            sql.append(" ORDER BY CREATE_TIME");
307
//            if(sortType == 0){
308
//            	sql.append(" DESC ");
309
//            }
310
//            sql.append(" LIMIT ").append(pageSize);
311
//        }else{
312
//            int pageNum = total / pageSize;
313
//            if(total % pageSize != 0){
314
//                ++pageNum;
315
//            }
316
//            if(pageNo > pageNum){
317
//                pageNo = pageNum;
318
//            }
319
//            queryResult.setPageNo(pageNo);
320
//            --pageNo;
321
//            int offset = (pageNo * pageSize);
322
//            sql = new StringBuilder();
323
//            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME,ORG_ID FROM DEMAND");
324
//            if(whereSql.length()>0){
325
//                sql.append(whereSql);
326
//            }
327
//            sql.append(" ORDER BY CREATE_TIME");
328
//            if(sortType == 0){
329
//            	sql.append(" DESC ");
330
//            }
331
//            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
332
//        }
333
//        ps = con.prepareStatement(sql.toString());
334
//        try{
335
//        	ps.setString(index++, demandStatus);
336
//            if(hasDemandAim){
337
//                ps.setString(index++,demandAim);
338
//            }
339
//            ResultSet rs = ps.executeQuery();
340
//            try{
341
//                List<Demand> demands = new ArrayList<Demand>();
342
//                queryResult.setData(demands);
343
//                int size = 0;
344
//                while((size<pageSize) && rs.next()){
345
//                    ++size;
346
//                    Demand demand =  new Demand();
347
//                    demand.setDemandId(rs.getString(1));
348
//                    demand.setDemander(rs.getString(2));
349
//                    demand.setDemandAim(rs.getString(3));
350
//                    demand.setDemandType(rs.getString(4));
351
//                    demand.setDemandTitle(rs.getString(5));
352
//                    String demandContent = rs.getString(6);
353
//                    if(rs.wasNull()){
354
//                        demandContent = null;
355
//                    }
356
//                    demand.setDemandContent(demandContent);
357
//                    demand.setDemandStatus(rs.getString(7));
358
//                    String closeTime = rs.getString(8);
359
//                    if(rs.wasNull()){
360
//                    	closeTime = null;
361
//                    }
362
//                    demand.setCloseTime(closeTime);
363
//                    demand.setOrderKey(rs.getLong(9));
364
//                    demand.setCreateTime(rs.getString(10));
365
//                    String orgId = rs.getString(11);
366
//                    if(rs.wasNull()){
367
//                    	orgId = null;
368
//                    }
369
//                    demand.setOrgId(orgId);
370
//                    demands.add(demand);
371
//                }
372
//                return queryResult;
373
//            }finally{
374
//                try{rs.close();}catch(Exception e3){}
375
//            }
376
//        }finally{
377
//            try{ps.close();}catch(Exception e4){}
378
//        }
379
//    }
380
//	
381
//	public PageQueryResult<Demand> pageQueryOrg(Connection con,String orgId,String demandStatus,int sortType,int pageSize,int pageNo) throws SQLException{
382
//        int total = 0;
383
//        PageQueryResult<Demand> queryResult = new PageQueryResult<Demand>();
384
//        int index = 1;
385
//        boolean hasDemandStatus = null != demandStatus;
386
//        StringBuilder sql = new StringBuilder();
387
//        sql.append(" WHERE DEMAND_TYPE = '2' AND ORG_ID = ? ");
388
//        if(hasDemandStatus){
389
//            sql.append(" AND DEMAND_STATUS = ?");
390
//        }
391
//        StringBuilder whereSql = sql;
392
//        sql = new StringBuilder();
393
//        sql.append("SELECT COUNT(1) FROM DEMAND");
394
//        if(whereSql.length()>0){
395
//            sql.append(whereSql);
396
//        }
397
//        PreparedStatement ps = con.prepareStatement(sql.toString());
398
//        try{
399
//        	ps.setString(index++, orgId);
400
//            if(hasDemandStatus){
401
//                ps.setString(index++,demandStatus);
402
//            }
403
//            queryResult.setPageSize(pageSize);
404
//            ResultSet rs = ps.executeQuery();
405
//            try{
406
//                rs.next();
407
//                total = rs.getInt(1);
408
//            }finally{
409
//                try{rs.close();}catch(Exception e1){}
410
//            }
411
//        }finally{
412
//            try{ps.close();}catch(Exception e2){}
413
//        }
414
//        queryResult.setTotal(total);
415
//        if(0== total){
416
//        	queryResult.setPageNo(1);
417
//        	queryResult.setData(Collections.<Demand>emptyList());
418
//            return queryResult;
419
//        }
420
//        index = 1;
421
//        boolean firstPage = (1 == pageNo);
422
//        if(firstPage){
423
//        	queryResult.setPageNo(1);
424
//            sql = new StringBuilder();
425
//            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME,ORG_ID FROM DEMAND");
426
//            if(whereSql.length()>0){
427
//                sql.append(whereSql);
428
//            }
429
//            sql.append(" ORDER BY CREATE_TIME");
430
//            if(sortType == 0){
431
//            	sql.append(" DESC ");
432
//            }
433
//            sql.append(" LIMIT ").append(pageSize);
434
//        }else{
435
//            int pageNum = total / pageSize;
436
//            if(total % pageSize != 0){
437
//                ++pageNum;
438
//            }
439
//            if(pageNo > pageNum){
440
//                pageNo = pageNum;
441
//            }
442
//            queryResult.setPageNo(pageNo);
443
//            --pageNo;
444
//            int offset = (pageNo * pageSize);
445
//            sql = new StringBuilder();
446
//            sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,CLOSE_TIME,ORDER_KEY,CREATE_TIME,ORG_ID FROM DEMAND");
447
//            if(whereSql.length()>0){
448
//                sql.append(whereSql);
449
//            }
450
//            sql.append(" ORDER BY CREATE_TIME");
451
//            if(sortType == 0){
452
//            	sql.append(" DESC ");
453
//            }
454
//            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
455
//        }
456
//        ps = con.prepareStatement(sql.toString());
457
//        try{
458
//        	ps.setString(index++, orgId);
459
//            if(hasDemandStatus){
460
//                ps.setString(index++,demandStatus);
461
//            }
462
//            ResultSet rs = ps.executeQuery();
463
//            try{
464
//                List<Demand> demands = new ArrayList<Demand>();
465
//                queryResult.setData(demands);
466
//                int size = 0;
467
//                while((size<pageSize) && rs.next()){
468
//                    ++size;
469
//                    Demand demand =  new Demand();
470
//                    demand.setDemandId(rs.getString(1));
471
//                    demand.setDemander(rs.getString(2));
472
//                    demand.setDemandAim(rs.getString(3));
473
//                    demand.setDemandType(rs.getString(4));
474
//                    demand.setDemandTitle(rs.getString(5));
475
//                    String demandContent = rs.getString(6);
476
//                    if(rs.wasNull()){
477
//                        demandContent = null;
478
//                    }
479
//                    demand.setDemandContent(demandContent);
480
//                    demand.setDemandStatus(rs.getString(7));
481
//                    String closeTime = rs.getString(8);
482
//                    if(rs.wasNull()){
483
//                    	closeTime = null;
484
//                    }
485
//                    demand.setCloseTime(closeTime);
486
//                    demand.setOrderKey(rs.getLong(9));
487
//                    demand.setCreateTime(rs.getString(10));
488
//                    String orgid = rs.getString(11);
489
//                    if(rs.wasNull()){
490
//                    	orgid = null;
491
//                    }
492
//                    demand.setOrgId(orgid);
493
//                    demands.add(demand);
494
//                }
495
//                return queryResult;
496
//            }finally{
497
//                try{rs.close();}catch(Exception e3){}
498
//            }
499
//        }finally{
500
//            try{ps.close();}catch(Exception e4){}
501
//        }
502
//    }
503
//	
504
//	public List<Demand> queryByStatus(Connection con,String demandStatus,String demandAim,String subject,String industry,String createTime,long orderKey,int rows,int sortType) throws SQLException{
505
//        StringBuilder sql = new StringBuilder();
506
//        sql.append("SELECT DEMAND_ID,DEMANDER,DEMAND_AIM,DEMAND_TYPE,DEMAND_TITLE,DEMAND_CONTENT,DEMAND_STATUS,ORDER_KEY,CREATE_TIME FROM DEMAND ");
507
//        boolean hasDemandAim = null != demandAim;
508
//        boolean hasSubject = null !=subject;
509
//        boolean hasIndustry = null != industry;
510
//        sql.append(" WHERE DEMAND_STATUS = ? AND ORDER_KEY < ? AND CREATE_TIME < ? ");
511
//        if(hasDemandAim){
512
//        	sql.append(" AND DEMAND_AIM = ? ");
513
//        }
514
//        if(hasSubject){
515
//        	sql.append(" AND DEMAND_ID IN (SELECT DEMAND_ID FROM DEMAND_SUB_OR_INDUS WHERE SUB_OR_INDUS LIKE ?) ");
516
//        }
517
//        if(hasIndustry){
518
//        	sql.append(" AND DEMAND_ID IN (SELECT DEMAND_ID FROM DEMAND_SUB_OR_INDUS WHERE SUB_OR_INDUS LIKE ?) ");
519
//        }
520
//        sql.append(" ORDER BY CREATE_TIME ");
521
//        if(sortType == 0){
522
//        	sql.append(" DESC ");
523
//        }
524
//        sql.append(" ,ORDER_KEY ");
525
//        if(sortType == 0){
526
//        	sql.append(" DESC ");
527
//        }
528
//        sql.append(" LIMIT ").append(rows);
529
//        int index = 1;
530
//        PreparedStatement ps = con.prepareStatement(sql.toString());
531
//        try{
532
//        	ps.setString(index++, demandStatus);
533
//            ps.setLong(index++,orderKey);
534
//            ps.setString(index++,createTime);
535
//            if(hasDemandAim){
536
//            	ps.setString(index++,demandAim);
537
//            }
538
//            if(hasSubject){
539
//            	ps.setString(index++,subject);
540
//            }
541
//            if(hasIndustry){
542
//            	ps.setString(index++,industry);
543
//            }
544
//            ResultSet rs = ps.executeQuery();
545
//            try{
546
//                List<Demand> demands = new ArrayList<Demand>();
547
//                while(rs.next()){
548
//                    Demand demand =  new Demand();
549
//                    demand.setDemandId(rs.getString(1));
550
//                    demand.setDemander(rs.getString(2));
551
//                    demand.setDemandAim(rs.getString(3));
552
//                    demand.setDemandType(rs.getString(4));
553
//                    demand.setDemandTitle(rs.getString(5));
554
//                    String content = rs.getString(6);
555
//                    if(rs.wasNull()){
556
//                    	content = null;
557
//                    }
558
//                    demand.setDemandContent(content);
559
//                    demand.setDemandStatus(rs.getString(7));
560
//                    demand.setOrderKey(rs.getLong(8));
561
//                    demand.setCreateTime(rs.getString(9));
562
//                    demands.add(demand);
563
//                }
564
//                return demands;
565
//            }finally{
566
//                try{rs.close();}catch(Exception e1){}
567
//            }
568
//        }finally{
569
//            try{ps.close();}catch(Exception e2){}
570
//        }
571
//    }
485 572
	
486 573
}

+ 0 - 16
src/main/java/com/ekexiu/portal/dao/DemandSubOrIndusDao.java

@ -1,16 +0,0 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
8

9
import com.ekexiu.portal.po.DemandSubOrIndus;
10

11
@DAO
12
public abstract class DemandSubOrIndusDao {
13
	@Insert
14
	public abstract int insert(Connection con,DemandSubOrIndus demandSubOrIndus)throws SQLException;
15
	
16
}

+ 4 - 0
src/main/java/com/ekexiu/portal/dao/PaperAuthorDao.java

@ -33,4 +33,8 @@ public interface PaperAuthorDao {
33 33
	
34 34
	
35 35
	
36
	@UpdateWith
37
	@From(PaperAuthor.class)
38
	@SetSentence("PROFESSOR_ID='################################'")
39
	int cAss(Connection con,String professorId)throws SQLException;
36 40
}

+ 5 - 0
src/main/java/com/ekexiu/portal/dao/PatentAuthorDao.java

@ -29,4 +29,9 @@ public interface PatentAuthorDao {
29 29
	@From(PatentAuthor.class)
30 30
	@SetSentence("PROFESSOR_ID='################################'")
31 31
	int update(Connection con,String patentId,String professorId)throws SQLException;
32
	
33
	@UpdateWith
34
	@From(PatentAuthor.class)
35
	@SetSentence("PROFESSOR_ID='################################'")
36
	int cAss(Connection con,String professorId)throws SQLException;
32 37
}

+ 4 - 0
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

@ -73,6 +73,10 @@ public abstract class ProfessorDao {
73 73
		}
74 74
	}
75 75

76
	@UpdateWith
77
	@From(Professor.class)
78
	public abstract int updateOrg(Connection con,@Set String orgId,String id)throws SQLException;
79

76 80
	@SelectOne
77 81
	@Nullable
78 82
	public abstract Professor query(Connection con, long shareId) throws SQLException;

+ 58 - 0
src/main/java/com/ekexiu/portal/job/DemandInvalidJob.java

@ -0,0 +1,58 @@
1
package com.ekexiu.portal.job;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import javax.sql.DataSource;
7

8
import org.jfw.apt.annotation.Autowrie;
9
import org.jfw.apt.annotation.Bean;
10
import org.jfw.util.DateUtil;
11
import org.jfw.util.jdbc.JdbcUtil;
12

13
import com.ekexiu.portal.dao.DemandDao;
14

15
@Bean
16
public class DemandInvalidJob implements Runnable {
17
	@Autowrie("dataSource")
18
	private DataSource dataSource;
19
	@Autowrie
20
	private DemandDao demandDao;
21

22
	private String lastDay;
23

24
	synchronized private void hand() {
25
		String cday = DateUtil.formatDate(System.currentTimeMillis());
26
		if (!cday.equals(lastDay)) {
27
			try {
28
				Connection con = this.dataSource.getConnection();
29
				try {
30
					boolean ac = con.getAutoCommit();
31
					try {
32
						con.setAutoCommit(false);
33
						try {
34
							demandDao.invalid(con, cday);
35
							con.commit();
36
							lastDay = cday;
37
						} catch (SQLException se) {
38
							JdbcUtil.rollback(con);
39
							throw se;
40
						}
41
					} finally {
42
						con.setAutoCommit(ac);
43
					}
44
				} finally {
45
					JdbcUtil.close(con);
46
				}
47

48
			} catch (Throwable thr) {
49
			}
50
		}
51
	}
52

53
	@Override
54
	public void run() {
55
		this.hand();
56
	}
57

58
}

+ 4 - 1
src/main/java/com/ekexiu/portal/job/TaskJob.java

@ -31,6 +31,8 @@ public class TaskJob implements AfterBeanFactory {
31 31
		final WeixinService weixin =(WeixinService)bf.getBean("com_ekexiu_portal_service_WeixinService");
32 32
		final PushService pushService =(PushService)bf.getBean("com_ekexiu_push_service_PushService");
33 33
		
34
		DemandInvalidJob dij = (DemandInvalidJob)bf.getBean("com_ekexiu_portal_job_DemandInvalidJob");
35
		
34 36
		long delayTime = tje.getDelayTime();
35 37
		long task = getTimeMillis(tje.getTaskTime());
36 38
		long taskTime = task - System.currentTimeMillis();
@ -67,7 +69,8 @@ public class TaskJob implements AfterBeanFactory {
67 69
			public void run() {
68 70
				pushService.refresh();				
69 71
			}
70
		}, 0, 2,TimeUnit.SECONDS);
72
		}, 0, 2,TimeUnit.SECONDS);		
73
		service.scheduleAtFixedRate(dij, 0, 5,TimeUnit.MINUTES);
71 74
	}
72 75
	private static long getTimeMillis(String time) {  
73 76
	    try {  

+ 164 - 76
src/main/java/com/ekexiu/portal/po/Demand.java

@ -4,89 +4,169 @@ import org.jfw.apt.orm.annotation.entry.Column;
4 4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5 5
import org.jfw.apt.orm.annotation.entry.Table;
6 6
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
7
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
8
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
7 9
import org.jfw.apt.orm.core.enums.DE;
8 10

9 11
import com.ekexiu.portal.basepo.CreateTimeSupported;
10
import com.ekexiu.portal.pojo.EditOrganization;
11
import com.ekexiu.portal.pojo.EditProfessor;
12
import com.ekexiu.portal.basepo.ModifyTimeSupported;
12 13

13 14
@Table
14
@PrimaryKey("demandId")
15
public class Demand implements CreateTimeSupported {
16
	private String demandId;
17
	private String demander;
18
	private String demandAim;
19
	private String demandType;
20
	private String demandTitle;
21
	private String demandContent;
22
	private String demandStatus;
23
	private String createTime;
24
	private String closeTime;
25
	private long orderKey;
15
@PrimaryKey("id")
16
public class Demand implements CreateTimeSupported,ModifyTimeSupported {
17
	private String id;
18
	private String title;
19
	private String province;
20
	private String city;
21
	private String cost;
22
	private String duration;
23
	private String invalidDay;
24
	private String contactNum;
25
	
26
	private String state;
26 27
	private String orgId;
27
	private EditProfessor professor;
28
	private EditOrganization organization;
28
	private String modifier;
29
	private String creator;
30
	private String createTime;
31
	private String modifyTime;
32
	private String descp;
29 33
	
30
	public EditProfessor getProfessor() {
31
		return professor;
32
	}
33
	public void setProfessor(EditProfessor professor) {
34
		this.professor = professor;
35
	}
36
	public EditOrganization getOrganization() {
37
		return organization;
38
	}
39
	public void setOrganization(EditOrganization organization) {
40
		this.organization = organization;
41
	}
34
	
35
	private long pageViews;
36
	private long shareId;
37
	
38
	/**
39
	 * id 主键
40
	 * @return
41
	 */
42 42
	@Column(DE.id_32)
43
	public String getDemandId() {
44
		return demandId;
43
	public String getId() {
44
		return id;
45
	}
46
	public void setId(String id) {
47
		this.id = id;
48
	}
49
	/**
50
	 * 需求主题
51
	 * @return
52
	 */
53
	@Column(dbType="TEXT",handlerClass=StringHandler.class,insertable=true,nullable=false,queryable=true,renewable=false)
54
	public String getTitle() {
55
		return title;
56
	}
57
	public void setTitle(String title) {
58
		this.title = title;
59
	}
60
	/**
61
	 * 所在省份
62
	 * @return
63
	 */
64
	@Column(DE.text_de)
65
	public String getProvince() {
66
		return province;
67
	}
68
	public void setProvince(String province) {
69
		this.province = province;
70
	}
71
	/**
72
	 * 所在省份
73
	 * @return
74
	 */
75
	@Column(DE.Text_de)
76
	public String getCity() {
77
		return city;
45 78
	}
46
	public void setDemandId(String demandId) {
47
		this.demandId = demandId;
79
	public void setCity(String city) {
80
		this.city = city;
48 81
	}
49
	@Column(DE.id_32)
50
	public String getDemander() {
51
		return demander;
82
	/**
83
	 * 费用预算
84
	 * @return
85
	 */
86
	@Column(DE.singleChar)
87
	public String getCost() {
88
		return cost;
52 89
	}
53
	public void setDemander(String demander) {
54
		this.demander = demander;
90
	public void setCost(String cost) {
91
		this.cost = cost;
55 92
	}
93
	/**
94
	 * 预期时长 
95
	 * @return
96
	 */
56 97
	@Column(DE.singleChar)
57
	public String getDemandAim() {
58
		return demandAim;
98
	public String getDuration() {
99
		return duration;
100
	}
101
	public void setDuration(String duration) {
102
		this.duration = duration;
103
	}
104
	/**
105
	 * 有效期
106
	 * @return
107
	 */
108
	@Column(DE.date_de)
109
	public String getInvalidDay() {
110
		return invalidDay;
59 111
	}
60
	public void setDemandAim(String demandAim) {
61
		this.demandAim = demandAim;
112
	public void setInvalidDay(String invalidDay) {
113
		this.invalidDay = invalidDay;
62 114
	}
115

116
	/**
117
	 * 联系电话
118
	 * @return
119
	 */
120
	@Column(DE.text_de)
121
	public String getContactNum() {
122
		return contactNum;
123
	}
124
	public void setContactNum(String contactNum) {
125
		this.contactNum = contactNum;
126
	}
127
	/**
128
	 * 状态  0:过期的,1:发布中的 2:完成的 3:关闭的,
129
	 * @return
130
	 */
63 131
	@Column(DE.singleChar)
64
	public String getDemandType() {
65
		return demandType;
132
	public String getState() {
133
		return state;
66 134
	}
67
	public void setDemandType(String demandType) {
68
		this.demandType = demandType;
135
	public void setState(String state) {
136
		this.state = state;
69 137
	}
70
	@Column(DE.string_de)
71
	public String getDemandTitle() {
72
		return demandTitle;
138
	/**
139
	 * 发布人发布时所在机构ID
140
	 * @return
141
	 */
142
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(32)",insertable=true,nullable=false,queryable=true,renewable=false)
143
	public String getOrgId() {
144
		return orgId;
73 145
	}
74
	public void setDemandTitle(String demandTitle) {
75
		this.demandTitle = demandTitle;
146
	public void setOrgId(String orgId) {
147
		this.orgId = orgId;
76 148
	}
77
	@Column(DE.Text_de)
78
	public String getDemandContent() {
79
		return demandContent;
149
	/**
150
	 * 最后修改人
151
	 * @return
152
	 */
153
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(32)",insertable=true,nullable=false,queryable=true,renewable=true)	
154
	public String getModifier() {
155
		return modifier;
80 156
	}
81
	public void setDemandContent(String demandContent) {
82
		this.demandContent = demandContent;
157
	public void setModifier(String modifier) {
158
		this.modifier = modifier;
83 159
	}
84
	@Column(DE.singleChar)
85
	public String getDemandStatus() {
86
		return demandStatus;
160
	/**
161
	 * 发布人ID
162
	 * @return
163
	 */
164
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(32)",insertable=true,nullable=false,queryable=true,renewable=false)	
165
	public String getCreator() {
166
		return creator;
87 167
	}
88
	public void setDemandStatus(String demandStatus) {
89
		this.demandStatus = demandStatus;
168
	public void setCreator(String creator) {
169
		this.creator = creator;
90 170
	}
91 171
	public String getCreateTime() {
92 172
		return createTime;
@ -94,26 +174,34 @@ public class Demand implements CreateTimeSupported {
94 174
	public void setCreateTime(String createTime) {
95 175
		this.createTime = createTime;
96 176
	}
97
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(14)",insertable=true,nullable=true,queryable=true,renewable=false)
98
	public String getCloseTime() {
99
		return closeTime;
177
	public String getModifyTime() {
178
		return modifyTime;
100 179
	}
101
	public void setCloseTime(String closeTime) {
102
		this.closeTime = closeTime;
180
	public void setModifyTime(String modifyTime) {
181
		this.modifyTime = modifyTime;
103 182
	}
104
	@Column(DE.long_de)
105
	public long getOrderKey() {
106
		return orderKey;
183
	/**
184
	 * 内容
185
	 */
186
	@Column(handlerClass=StringHandler.class,dbType="TEXT",insertable=true,nullable=false,renewable=true,queryable=true)
187
	public String getDescp() {
188
		return descp;
107 189
	}
108
	public void setOrderKey(long orderKey) {
109
		this.orderKey = orderKey;
190
	public void setDescp(String descp) {
191
		this.descp = descp;
110 192
	}
111
	@Column(value=DE.id_32,nullable=true)
112
	public String getOrgId() {
113
		return orgId;
193
	@Column(handlerClass=LongHandler.class,dbType="INT8",fixSqlValueWithInsert="0",insertable=true,nullable=false,renewable=false,queryable=true)
194
	public long getPageViews() {
195
		return pageViews;
114 196
	}
115
	public void setOrgId(String orgId) {
116
		this.orgId = orgId;
197
	public void setPageViews(long pageViews) {
198
		this.pageViews = pageViews;
199
	}
200
	@Column(DE.bigSerial)
201
	public long getShareId() {
202
		return shareId;
203
	}
204
	public void setShareId(long shareId) {
205
		this.shareId = shareId;
117 206
	}
118
	
119 207
}

+ 0 - 43
src/main/java/com/ekexiu/portal/po/DemandSubOrIndus.java

@ -1,43 +0,0 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
@Table
9
@PrimaryKey("id")
10
public class DemandSubOrIndus{
11
	private String id;
12
	private int sort;
13
	private String subOrIndus;
14
	private String demandId;
15
	@Column(DE.id_32)
16
	public String getId() {
17
		return id;
18
	}
19
	public void setId(String id) {
20
		this.id = id;
21
	}
22
	@Column(DE.int_de)
23
	public int getSort() {
24
		return sort;
25
	}
26
	public void setSort(int sort) {
27
		this.sort = sort;
28
	}
29
	@Column(DE.string_de)
30
	public String getSubOrIndus() {
31
		return subOrIndus;
32
	}
33
	public void setSubOrIndus(String subOrIndus) {
34
		this.subOrIndus = subOrIndus;
35
	}
36
	@Column(DE.id_32)
37
	public String getDemandId() {
38
		return demandId;
39
	}
40
	public void setDemandId(String demandId) {
41
		this.demandId = demandId;
42
	}
43
}

+ 148 - 165
src/main/java/com/ekexiu/portal/service/DemandService.java

@ -2,8 +2,6 @@ package com.ekexiu.portal.service;
2 2

3 3
import java.sql.Connection;
4 4
import java.sql.SQLException;
5
import java.text.SimpleDateFormat;
6
import java.util.Date;
7 5
import java.util.List;
8 6

9 7
import org.jfw.apt.annotation.Autowrie;
@ -13,212 +11,197 @@ import org.jfw.apt.web.annotation.Path;
13 11
import org.jfw.apt.web.annotation.operate.Get;
14 12
import org.jfw.apt.web.annotation.operate.Post;
15 13
import org.jfw.apt.web.annotation.param.JdbcConn;
14
import org.jfw.apt.web.annotation.param.RequestParam;
16 15
import org.jfw.util.PageQueryResult;
17 16
import org.jfw.util.StringUtil;
18
import org.jfw.util.exception.JfwBaseException;
19 17

20 18
import com.ekexiu.portal.dao.DemandDao;
21
import com.ekexiu.portal.dao.DemandSubOrIndusDao;
22
import com.ekexiu.portal.dao.ProfessorDao;
23 19
import com.ekexiu.portal.po.Demand;
24
import com.ekexiu.portal.po.DemandSubOrIndus;
25
import com.ekexiu.portal.pojo.EditProfessor;
26 20

27 21
@Path("/demand")
28 22
public class DemandService {
29
	public static final String MAX_CREATETIME="9";
30
	
23
	public static final String MAX_CREATETIME = "9";
24

31 25
	@Autowrie
32 26
	private DemandDao demandDao;
33
	@Autowrie
34
	private DemandSubOrIndusDao demandSubOrIndusDao;
35
	@Autowrie
36
	private ProfessorDao professorDao;
37
	@Autowrie
38
	private ImageService imageService;
39
	@Autowrie
40
	private OrgService orgService;
41
	@Autowrie
42
	private GrowthLogService growthLogService;
43
	
27

44 28
	public DemandDao getDemandDao() {
45 29
		return demandDao;
46 30
	}
31

47 32
	public void setDemandDao(DemandDao demandDao) {
48 33
		this.demandDao = demandDao;
49 34
	}
50
	public DemandSubOrIndusDao getDemandSubOrIndusDao() {
51
		return demandSubOrIndusDao;
52
	}
53
	public void setDemandSubOrIndusDao(DemandSubOrIndusDao demandSubOrIndusDao) {
54
		this.demandSubOrIndusDao = demandSubOrIndusDao;
55
	}
56
	public ProfessorDao getProfessorDao() {
57
		return professorDao;
58
	}
59
	public void setProfessorDao(ProfessorDao professorDao) {
60
		this.professorDao = professorDao;
61
	}
62
	public ImageService getImageService() {
63
		return imageService;
64
	}
65
	public void setImageService(ImageService imageService) {
66
		this.imageService = imageService;
67
	}
68
	public OrgService getOrgService() {
69
		return orgService;
70
	}
71
	public void setOrgService(OrgService orgService) {
72
		this.orgService = orgService;
73
	}
74
	public GrowthLogService getGrowthLogService() {
75
		return growthLogService;
76
	}
77
	public void setGrowthLogService(GrowthLogService growthLogService) {
78
		this.growthLogService = growthLogService;
79
	}
80
	
35

36
	/**
37
	 * 发布需求
38
	 * @param con
39
	 * @param demand  
40
	 * @throws SQLException
41
	 */
81 42
	@Post
82 43
	@Path
83
	public void insert(@JdbcConn(true) Connection con,Demand demand,@Nullable String[] args)throws SQLException{
44
	public String  insert(@JdbcConn(true) Connection con,@RequestParam(excludeFields={"id","state","createTime","modifyTime","shareId","pageViews","modifier"})  Demand demand)throws SQLException{
84 45
		String demandId = StringUtil.buildUUID();
85
		demand.setDemandId(demandId);
86
		demand.setDemandStatus("1");
87
		demand.setOrderKey(System.nanoTime());
46
		demand.setId(demandId);
47
		demand.setState("1");
48
		if(demand.getCost()==null){
49
			demand.setCost("0");
50
		}
51
		if(demand.getDuration()==null){
52
			demand.setDuration("0");
53
		}
54
		demand.setModifier(demand.getCreator());
88 55
		this.demandDao.insert(con, demand);
89
		if(args != null){
90
			for (int i = 0; i < args.length; i++) {
91
				DemandSubOrIndus subOrIndus = new DemandSubOrIndus();
92
				subOrIndus.setId(StringUtil.buildUUID());
93
				subOrIndus.setSort(i+1);
94
				subOrIndus.setSubOrIndus(args[i]);
95
				subOrIndus.setDemandId(demandId);
96
				this.demandSubOrIndusDao.insert(con, subOrIndus);
97
			}
56
		return demandId;
57
	}
58

59
	/**
60
	 * 修改需求
61
	 * @param con
62
	 * @param demand
63
	 * @throws SQLException
64
	 */
65
	@Post
66
	@Path("/modify")
67
	public boolean update(@JdbcConn(true) Connection con,@RequestParam(excludeFields={"state","createTime","modifyTime","title","descp","orgId","creator","pageViews","shareId"}) Demand demand)throws SQLException{
68
		if(demand.getCost()==null){
69
			demand.setCost("0");
70
		}
71
		if(demand.getDuration()==null){
72
			demand.setDuration("0");
98 73
		}
99
//		if("1".equals(demand.getDemandType())){
100
//			//发布个人需求给发布者增加积分
101
//			this.growthLogService.addProDemand(con, demand.getDemander());
102
//		}else if("2".equals(demand.getDemandType())){
103
//			//发布企业需求给发布者增加积分
104
//			this.growthLogService.addOrgDemand(con, demand.getDemander());
105
//		}
74
		demand.setState("1");
75
		return this.demandDao.update(con, demand)>0;	
106 76
	}
107
	
77
	/**
78
	 * 完成需求
79
	 * @param con
80
	 * @param id  需求ID
81
	 * @param uid 操作用户ID
82
	 * @return
83
	 * @throws SQLException
84
	 */
85
	@Post
86
	@Path("/over")
87
	public boolean over(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
88
		return this.demandDao.over(con, id, uid)>0;
89
	}
90
	/**
91
	 * 关闭需求
92
	 * @param con
93
	 * @param id 需求ID
94
	 * @param uid 需求ID
95
	 * @return
96
	 * @throws SQLException
97
	 */
108 98
	@Post
109 99
	@Path("/close")
110
	public void closeDemand(@JdbcConn(true) Connection con,String demandId)throws SQLException{
111
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
112
		String closeTime = sdf.format(new Date());
113
		//更新需求状态为关闭-0
114
		this.demandDao.updateDemandStatus(con, demandId, "0", closeTime);
100
	public boolean close(@JdbcConn(true) Connection con,String id,String uid)throws SQLException{
101
		return this.demandDao.close(con, id, uid)>0;
115 102
	}
116
	
117
	@Get
118
	@Path("/queryOne")
119
	public Demand queryOne(@JdbcConn Connection con,String demandId)throws SQLException{
120
		Demand demand = this.demandDao.queryOne(con, demandId);
121
		EditProfessor professor = this.professorDao.queryBaseInfo(con, demand.getDemander());
122
		if(professor != null){
123
			professor.setHasHeadImage(this.imageService.hasProfessorImage(demand.getDemander()));
124
		}
125
		demand.setProfessor(professor);
126
		if(demand.getOrgId() != null){
127
			demand.setOrganization(this.orgService.query(con, demand.getOrgId()));
128
		}
129
		return demand;
103
	/**
104
	 * 延期需求
105
	 * @param con
106
	 * @param id 需求ID
107
	 * @param uid 操作用户ID
108
	 * @param day 延期日期 YYYYMMD
109
	 * @return
110
	 * @throws SQLException
111
	 */
112
	@Post
113
	@Path("/defer")
114
	public boolean defer(@JdbcConn(true) Connection con,String id,String uid,String day)throws SQLException{
115
		return this.demandDao.defer(con, id,uid,day)>0;
130 116
	}
131
	
132 117
	/**
133
	 * 查询我发布中的需求总数
118
	 * 增加浏览量
134 119
	 * @param con
135
	 * @param demander 发布者ID
136
	 * @return 返回状态发布中的需求总数
120
	 * @param id 需求ID
137 121
	 * @throws SQLException
138
	 * @throws JfwBaseException 
139 122
	 */
140
	@Get
141
	@Path("/queryMyPublish")
142
	public int queryMyPublish(@JdbcConn Connection con,String demander)throws SQLException, JfwBaseException{
143
		return this.demandDao.queryCountByStatus(con, demander, "1");
123
	@Post
124
	@Path("/incPageViews")
125
	public void incPageViews(@JdbcConn(true) Connection con,String id)throws SQLException{
126
		this.demandDao.incPageViews(con, id);
144 127
	}
145
	
128
	/**
129
	 * 查询需求数量
130
	 * @param con
131
	 * @param state  需求状态
132
	 * @param uid    发布者ID
133
	 * @param oid   发布者发布时机构ID
134
	 * @return
135
	 * @throws SQLException
136
	 */
146 137
	@Get
147
	@Path("/queryPublish")
148
	public int queryPublish(@JdbcConn Connection con)throws SQLException, JfwBaseException{
149
		return this.demandDao.queryCountStatus(con, "1");
138
	@Path("/qc")
139
	public int queryCount(@JdbcConn Connection con,@Nullable String[] state,@Nullable String uid,@Nullable String oid)throws SQLException{
140
		return this.demandDao.cnt(con, state, uid,oid);
150 141
	}
151
	
142
	/**
143
	 * 查询需求
144
	 * @param con
145
	 * @param id  需求ID
146
	 * @return
147
	 * @throws SQLException
148
	 */
152 149
	@Get
153
	@Path("/qaForOrg")
154
	public List<Demand> queryForOrg(@JdbcConn Connection con,String orgId)throws SQLException{
155
		return this.demandDao.queryForOrg(con, orgId);
150
	@Path("/qo")
151
	public Demand queryOne(@JdbcConn Connection con, String id)throws SQLException{
152
		return this.demandDao.query(con, id);
156 153
	}
157
	
154
	/**
155
	 * 根据分享ID 查询需求
156
	 * @param con
157
	 * @param id 分享ID
158
	 * @return
159
	 * @throws SQLException
160
	 */
158 161
	@Get
159
	@Path("/byDemander")
160
	public List<Demand> queryByDemander(@JdbcConn Connection con,String demander)throws SQLException{
161
		List<Demand> demands = this.demandDao.queryByDemander(con, demander);
162
		return demands;
162
	@Path("/byShareId")
163
	public Demand queryByShareId(@JdbcConn Connection con ,long id)throws SQLException{
164
		return this.demandDao.query(con, id);
163 165
	}
164
	
166
	/**
167
	 * 查询需求列表
168
	 * @param con
169
	 * @param id 需求ID 数组
170
	 * @return
171
	 * @throws SQLException
172
	 */
165 173
	@Get
166
	@Path("/pqDemander")
167
	public PageQueryResult<Demand> pageQueryByDemander(@JdbcConn Connection con,String demander,@Nullable String demandStatus,
168
			@DefaultValue("0") int sortType,@DefaultValue("5") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
169
		return this.demandDao.pageQueryByDemander(con, demander, demandStatus, sortType, pageSize, pageNo);
174
	@Path("/qm")
175
	public List<Demand> queryOne(@JdbcConn Connection con, String[] id)throws SQLException{
176
		return this.demandDao.query(con, id);
170 177
	}
171
	
178
	/**
179
	 * 分页查询需求(按状态及发布时间排序)
180
	 * @param con
181
	 * @param state
182
	 * @param uid
183
	 * @param oid
184
	 * @return
185
	 * @throws SQLException
186
	 */
172 187
	@Get
173 188
	@Path("/pq")
174
	public PageQueryResult<Demand> pageQuery(@JdbcConn Connection con,@Nullable String demandAim,
175
			@DefaultValue("0") int sortType,@DefaultValue("5") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
176
		PageQueryResult<Demand> queryResult = this.demandDao.pageQuery(con, "1", demandAim, sortType, pageSize, pageNo);
177
		List<Demand> demands = queryResult.getData();
178
		for (Demand demand : demands) {
179
			EditProfessor professor = this.professorDao.queryBaseInfo(con, demand.getDemander());
180
			if(professor != null){
181
				professor.setHasHeadImage(this.imageService.hasProfessorImage(demand.getDemander()));
182
			}
183
			demand.setProfessor(professor);
184
		}
185
		queryResult.setData(demands);
186
		return queryResult;
187
	}
188
	
189
	@Get
190
	@Path("/pqOrg")
191
	public PageQueryResult<Demand> pageQueryOrg(@JdbcConn Connection con,String orgId,@Nullable String demandStatus,
192
			@DefaultValue("0") int sortType,@DefaultValue("5") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
193
		PageQueryResult<Demand> queryResult = this.demandDao.pageQueryOrg(con, orgId, demandStatus, sortType, pageSize, pageNo);
194
		List<Demand> demands = queryResult.getData();
195
		for (Demand demand : demands) {
196
			EditProfessor professor = this.professorDao.queryBaseInfo(con, demand.getDemander());
197
			if(professor != null){
198
				professor.setHasHeadImage(this.imageService.hasProfessorImage(demand.getDemander()));
199
			}
200
			demand.setProfessor(professor);
201
		}
202
		queryResult.setData(demands);
203
		return queryResult;
189
	public PageQueryResult<Demand> query(@JdbcConn Connection con,@Nullable String[] state,@Nullable String uid,@Nullable String oid,@DefaultValue("1") int pageNo,@DefaultValue("5") int pageSize)throws SQLException{
190
		return this.demandDao.pageQuery(con, state, uid, oid,pageSize,pageNo);
204 191
	}
205 192
	
193
	/**
194
	 * 分页查询需求(按发布时间排序)
195
	 * @param con
196
	 * @param state
197
	 * @param uid
198
	 * @param oid
199
	 * @return
200
	 * @throws SQLException
201
	 */
206 202
	@Get
207
	@Path("/ql")
208
	public List<Demand> queryByStatus(@JdbcConn Connection con,@Nullable String demandAim,@Nullable String subject,
209
			@Nullable String industry,@DefaultValue("com.ekexiu.portal.service.DemandService.MAX_CREATETIME") String createTime,
210
			@DefaultValue("Long.MAX_VALUE") long orderKey,@DefaultValue("20") int rows,@DefaultValue("0") int sortType)throws SQLException{
211
		if(subject != null) subject = "%"+subject+"%";
212
		if(industry != null) industry = "%"+industry+"%";
213
		List<Demand> demands = this.demandDao.queryByStatus(con, "1", demandAim, subject, industry, createTime, orderKey, rows, sortType);
214
		for (Demand demand : demands) {
215
			EditProfessor professor = this.professorDao.queryBaseInfo(con, demand.getDemander());
216
			if(professor != null){
217
				professor.setHasHeadImage(this.imageService.hasProfessorImage(demand.getDemander()));
218
			}
219
			demand.setProfessor(professor);
220
		}
221
		return demands;
203
	@Path("/search")
204
	public PageQueryResult<Demand> query(@JdbcConn Connection con,@Nullable String key,@DefaultValue("1") int pageNo,@DefaultValue("5") int pageSize)throws SQLException{
205
		return this.demandDao.pageQuery(con, key==null?key:("%"+key+"%"),pageSize,pageNo);
222 206
	}
223

224 207
}

+ 0 - 1
src/main/java/com/ekexiu/portal/service/PpaperService.java

@ -20,7 +20,6 @@ import com.ekexiu.portal.dao.PpaperDao;
20 20
import com.ekexiu.portal.po.PaperAgree;
21 21
import com.ekexiu.portal.po.PaperAuthor;
22 22
import com.ekexiu.portal.po.Ppaper;
23
import com.ekexiu.portal.po.Ppatent;
24 23
import com.ekexiu.portal.pojo.AssedPaper;
25 24

26 25
@Path("/ppaper")

+ 122 - 36
src/main/java/com/ekexiu/portal/service/ProfessorService.java

@ -30,12 +30,15 @@ import org.jfw.util.StringUtil;
30 30
import org.jfw.util.jdbc.JdbcUtil;
31 31

32 32
import com.ekexiu.portal.dao.ArticleDao;
33
import com.ekexiu.portal.dao.DemandDao;
33 34
import com.ekexiu.portal.dao.HonorDao;
34 35
import com.ekexiu.portal.dao.ImageDao;
35 36
import com.ekexiu.portal.dao.OrgDao;
36 37
import com.ekexiu.portal.dao.OrgResStaffDao;
38
import com.ekexiu.portal.dao.PaperAuthorDao;
37 39
import com.ekexiu.portal.dao.PaperDao;
38 40
import com.ekexiu.portal.dao.PartTimeJobDao;
41
import com.ekexiu.portal.dao.PatentAuthorDao;
39 42
import com.ekexiu.portal.dao.PatentDao;
40 43
import com.ekexiu.portal.dao.ProfessorDao;
41 44
import com.ekexiu.portal.dao.ProfessorEduBgDao;
@ -98,10 +101,41 @@ public class ProfessorService {
98 101
	private ProjectDao projectDao;
99 102
	@Autowrie
100 103
	private OrgResStaffDao orgResStaffDao;
104
	@Autowrie
105
	private PatentAuthorDao patentAuthorDao;
106
	@Autowrie
107
	private PaperAuthorDao paperAuthorDao;
101 108

102 109
	@Autowrie
103 110
	private KeyWordService keyWordService;
104 111

112
	@Autowrie
113
	private DemandDao demandDao;
114

115
	public DemandDao getDemandDao() {
116
		return demandDao;
117
	}
118

119
	public void setDemandDao(DemandDao demandDao) {
120
		this.demandDao = demandDao;
121
	}
122

123
	public PatentAuthorDao getPatentAuthorDao() {
124
		return patentAuthorDao;
125
	}
126

127
	public void setPatentAuthorDao(PatentAuthorDao patentAuthorDao) {
128
		this.patentAuthorDao = patentAuthorDao;
129
	}
130

131
	public PaperAuthorDao getPaperAuthorDao() {
132
		return paperAuthorDao;
133
	}
134

135
	public void setPaperAuthorDao(PaperAuthorDao paperAuthorDao) {
136
		this.paperAuthorDao = paperAuthorDao;
137
	}
138

105 139
	public KeyWordService getKeyWordService() {
106 140
		return keyWordService;
107 141
	}
@ -317,6 +351,26 @@ public class ProfessorService {
317 351
		return professor.getId();
318 352
	}
319 353

354
	@Post
355
	@Path("/org")
356
	public boolean updateOrgid(@JdbcConn(true) Connection con, String id, String name) throws SQLException, IOException {
357
		Professor p = this.professorDao.query(con, id);
358
		if (p != null) {
359
			String oid = this.orgService.createOrganization(con, name);
360
			String old = p.getOrgId();
361
			if (!oid.equals(old)) {
362
				this.professorDao.updateOrg(con, oid, id);
363
				if (old != null) {
364
					this.professorDao.updateOrgAuth(con, id, "0");
365
					this.demandDao.closeByCreator(con,id, id);
366
					this.orgResStaffDao.deletePro(con, id);
367
				}
368
				return true;
369
			}
370
		}
371
		return false;
372
	}
373

320 374
	@Put
321 375
	@Path
322 376
	public void update(@JdbcConn(true) Connection con, @RequestBody EditProfessor professor) throws SQLException, IOException {
@ -326,7 +380,23 @@ public class ProfessorService {
326 380
			} else {
327 381
				professor.setOrgId(this.orgService.createOrganization(con, professor.getOrgName()));
328 382
			}
329
		this.professorDao.update(con, professor);
383
		Professor op = this.professorDao.query(con, professor.getId());
384

385
		String old_oid = op.getOrgId();
386
		String new_oid = professor.getOrgId();
387

388
		if (this.professorDao.update(con, professor) > 0) {
389
			if (!professor.getName().equals(op.getName())) {
390
				this.paperAuthorDao.cAss(con, professor.getId());
391
				this.patentAuthorDao.cAss(con, professor.getId());
392
			}
393
			if (old_oid != null && (!old_oid.equals(new_oid))) {
394
				this.professorDao.updateOrgAuth(con, op.getId(), "0");
395
				this.demandDao.closeByCreator(con, op.getId(), op.getId());
396
				this.orgResStaffDao.deletePro(con, op.getId());
397
			}
398
		}
399
		;
330 400
	}
331 401

332 402
	@Post
@ -338,7 +408,22 @@ public class ProfessorService {
338 408
			} else {
339 409
				professor.setOrgId(this.orgService.createOrganization(con, professor.getOrgName()));
340 410
			}
341
		this.professorDao.update(con, professor);
411
		Professor op = this.professorDao.query(con, professor.getId());
412

413
		String old_oid = op.getOrgId();
414
		String new_oid = professor.getOrgId();
415
		if (this.professorDao.update(con, professor) > 0) {
416
			if (!professor.getName().equals(op.getName())) {
417
				this.paperAuthorDao.cAss(con, professor.getId());
418
				this.patentAuthorDao.cAss(con, professor.getId());
419
			}
420
			if (old_oid != null && (!old_oid.equals(new_oid))) {
421
				this.professorDao.updateOrgAuth(con, op.getId(), "0");
422
				this.demandDao.closeByCreator(con, op.getId(), op.getId());
423
				this.orgResStaffDao.deletePro(con, op.getId());
424
			}
425
		}
426
		;
342 427
	}
343 428

344 429
	@Get
@ -734,6 +819,7 @@ public class ProfessorService {
734 819

735 820
	/**
736 821
	 * 增加用户浏览量
822
	 * 
737 823
	 * @param con
738 824
	 * @param id
739 825
	 * @throws SQLException
@ -743,56 +829,56 @@ public class ProfessorService {
743 829
	public void incPageViews(@JdbcConn(true) Connection con, String id) throws SQLException {
744 830
		this.professorDao.incPageViews(con, id);
745 831
	}
746
	
832

747 833
	@Get
748 834
	@Path("/ralateProfessors")
749
	public List<Professor> ralateArticles(@JdbcConn Connection con,String professorId,@DefaultValue("5") int rows)throws SQLException{
835
	public List<Professor> ralateArticles(@JdbcConn Connection con, String professorId, @DefaultValue("5") int rows) throws SQLException {
750 836
		String[] ids = this.professorDao.queryProfessorIdWithSameKeyWord(con, professorId, rows);
751
		if(ids!=null){
752
			 List<Professor> ret = this.professorDao.query(con,ids);
753
			 return ret;
837
		if (ids != null) {
838
			List<Professor> ret = this.professorDao.query(con, ids);
839
			return ret;
754 840
		}
755
		return Collections.<Professor>emptyList();
841
		return Collections.<Professor> emptyList();
756 842
	}
757
	
843

758 844
	@Get
759 845
	@Path("/coadjutant")
760
	public List<Map<String,Object>> queryCoadjutant(@JdbcConn Connection con,String id,@DefaultValue("5") int rows)throws SQLException{
761
		PreparedStatement ps = con.prepareStatement("SELECT professor_id,SUM (patent_count) patent_count,	SUM (paper_count) paper_count, "+
762
	    "SUM (tc) tc FROM ((SELECT professor_id,COUNT (1) patent_count,0 paper_count,COUNT (1) tc FROM patent_author WHERE patent_id IN ("+
763
		"SELECT DISTINCT patent_id FROM patent_author WHERE professor_id = ? ) AND professor_id <> ? AND professor_id <> '################################' "+
764
		"GROUP BY professor_id) UNION ALL (SELECT professor_id,0 patent_count,COUNT (1) paper_count,COUNT (1) tc	FROM paper_author WHERE paper_id IN (	SELECT DISTINCT "+
765
		"paper_id FROM paper_author WHERE professor_id = ? ) AND professor_id <>?  AND professor_id <> '################################' GROUP BY professor_id ) "
766
		+") _T_ GROUP BY professor_id ORDER BY tc DESC LIMIT ?");
767
		try{
768
			ps.setString(1,id);
769
			ps.setString(2,id);
770
			ps.setString(3,id);
771
			ps.setString(4,id);
772
			ps.setInt(5,rows);
846
	public List<Map<String, Object>> queryCoadjutant(@JdbcConn Connection con, String id, @DefaultValue("5") int rows) throws SQLException {
847
		PreparedStatement ps = con.prepareStatement("SELECT professor_id,SUM (patent_count) patent_count,	SUM (paper_count) paper_count, "
848
				+ "SUM (tc) tc FROM ((SELECT professor_id,COUNT (1) patent_count,0 paper_count,COUNT (1) tc FROM patent_author WHERE patent_id IN ("
849
				+ "SELECT DISTINCT patent_id FROM patent_author WHERE professor_id = ? ) AND professor_id <> ? AND professor_id <> '################################' "
850
				+ "GROUP BY professor_id) UNION ALL (SELECT professor_id,0 patent_count,COUNT (1) paper_count,COUNT (1) tc	FROM paper_author WHERE paper_id IN (	SELECT DISTINCT "
851
				+ "paper_id FROM paper_author WHERE professor_id = ? ) AND professor_id <>?  AND professor_id <> '################################' GROUP BY professor_id ) "
852
				+ ") _T_ GROUP BY professor_id ORDER BY tc DESC LIMIT ?");
853
		try {
854
			ps.setString(1, id);
855
			ps.setString(2, id);
856
			ps.setString(3, id);
857
			ps.setString(4, id);
858
			ps.setInt(5, rows);
773 859
			ResultSet rs = ps.executeQuery();
774
			try{
775
				List<Map<String,Object>> ret = new ArrayList<Map<String,Object>>();
776
				while(rs.next()){
777
					Map<String,Object> row = new HashMap<String,Object>();
860
			try {
861
				List<Map<String, Object>> ret = new ArrayList<Map<String, Object>>();
862
				while (rs.next()) {
863
					Map<String, Object> row = new HashMap<String, Object>();
778 864
					ret.add(row);
779
					row.put("professorId",rs.getString(1));
780
					row.put("patentCount",rs.getInt(2));
781
					row.put("paperCount",rs.getInt(3));
865
					row.put("professorId", rs.getString(1));
866
					row.put("patentCount", rs.getInt(2));
867
					row.put("paperCount", rs.getInt(3));
782 868
				}
783 869
				return ret;
784
			}finally{
870
			} finally {
785 871
				JdbcUtil.close(rs);
786 872
			}
787
		}finally{
873
		} finally {
788 874
			JdbcUtil.close(ps);
789 875
		}
790 876
	}
791
	
792
//	
793
//	
794
//	@Get
795
//	@Path("/articleRef")
877

878
	//
879
	//
880
	// @Get
881
	// @Path("/articleRef")
796 882

797 883
	public static void main(String[] args) throws Exception {
798 884
		// Connection con =

+ 43 - 1
src/main/resources/database.sql

@ -2021,7 +2021,49 @@ COMMENT ON COLUMN discover_banner.modify_time IS '修改时间';
2021 2021
COMMENT ON COLUMN discover_banner.modifier IS '最后修改人ID';
2022 2022
COMMENT ON COLUMN discover_banner.create_time IS '创建时间';
2023 2023
COMMENT ON COLUMN discover_banner.creator IS '创建人ID';
2024
COMMENT ON COLUMN public.discover_banner.location IS '显示位置';
2024
COMMENT ON COLUMN discover_banner.location IS '显示位置';
2025

2026
  --- modify begin at version 2.0
2027
  drop table DEMAND_SUB_OR_INDUS;
2028
  drop table DEMAND;
2029
  CREATE TABLE DEMAND (
2030
  	ID CHAR(32) NOT NULL,
2031
  	TITLE TEXT NOT NULL,
2032
  	PROVINCE TEXT NOT NULL,
2033
  	CITY TEXT,
2034
  	COST CHAR(1) NOT NULL,
2035
  	DURATION CHAR(1) NOT NULL,
2036
  	INVALID_DAY CHAR(8) NOT NULL,
2037
  	CONTACT_NUM TEXT NOT NULL,
2038
  	STATE CHAR(1) NOT NULL,
2039
  	ORG_ID CHAR(32) NOT NULL,
2040
  	MODIFIER CHAR(32) NOT NULL,
2041
  	CREATOR CHAR(32) NOT NULL,
2042
  	DESCP TEXT NOT NULL,
2043
  	PAGE_VIEWS INT8 NOT NULL,
2044
  	SHARE_ID bigserial NOT NULL,
2045
  	CREATE_TIME CHAR(14) NOT NULL,
2046
  	MODIFY_TIME CHAR(14) NOT NULL);
2047
ALTER TABLE DEMAND ADD PRIMARY KEY (ID);
2048

2049
COMMENT ON TABLE DEMAND IS '需求';
2050
COMMENT ON COLUMN  DEMAND.ID          IS '需求ID';
2051
COMMENT ON COLUMN  DEMAND.TITLE       IS '主题';
2052
COMMENT ON COLUMN  DEMAND.PROVINCE    IS '省份';
2053
COMMENT ON COLUMN  DEMAND.CITY        IS '城市';
2054
COMMENT ON COLUMN  DEMAND.COST        IS '费用预算';
2055
COMMENT ON COLUMN  DEMAND.DURATION    IS '预计时长';
2056
COMMENT ON COLUMN  DEMAND.INVALID_DAY IS '有效期';
2057
COMMENT ON COLUMN  DEMAND.CONTACT_NUM IS '联系电话';
2058
COMMENT ON COLUMN  DEMAND.STATE       IS '状态';
2059
COMMENT ON COLUMN  DEMAND.ORG_ID      IS '发布人发布时机构ID';
2060
COMMENT ON COLUMN  DEMAND.MODIFIER    IS '最后修改人';
2061
COMMENT ON COLUMN  DEMAND.CREATOR     IS '发布人';
2062
COMMENT ON COLUMN  DEMAND.DESCP       IS '内容';
2063
COMMENT ON COLUMN  DEMAND.PAGE_VIEWS  IS '浏览量';
2064
COMMENT ON COLUMN  DEMAND.SHARE_ID    IS '分享ID';
2065
COMMENT ON COLUMN  DEMAND.CREATE_TIME IS '发布时间';
2066
COMMENT ON COLUMN  DEMAND.MODIFY_TIME IS '最后修改时间,=完成时间 =关闭时间';
2025 2067

2026 2068

2027 2069