cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
package cn.ksource.web.facade.knowledge.knowtj;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import cn.ksource.core.dao.BaseDao;
import cn.ksource.core.dao.SqlParameter;
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.DateUtil;
import cn.ksource.core.util.StringUtil;
import cn.ksource.web.Constants;
 
@Service("knowledgeTjFacade")
public class KnowledgeTjFacadeImpl implements KnowledgeTjFacade {
    
    @Resource
    private BaseDao baseDao;
 
    @Override
    public Map knowCateTjCol(Map<String,String> params) {
        params.put("beginTime", params.get("beginTime")+"000000");
        params.put("endTime", params.get("endTime")+"235959");
        String cateId = params.get("cateId");
        if(!StringUtil.isEmpty(cateId) ){
            String[] cateIds = cateId.split("-");
            params.put("cateId", cateIds[2]);
        }
        List<String> categories = new ArrayList<String>();
        categories.add("新增");
        categories.add("置顶");
        categories.add("精华");
        Map resMap = new HashMap();
        StringBuilder sql = new StringBuilder("SELECT COUNT(ID) FROM KM_LIBRARY WHERE STATE = 1 ");
        
         getsql(params,sql,params.get("type"));
        int allnum = baseDao.queryForInteger(sql.toString(), params);
        StringBuilder sql1 = new StringBuilder("SELECT COUNT(ID) FROM KM_LIBRARY WHERE STATE = 1 ");
        params.put("top", "1");
        getsql(params,sql1,params.get("type"));
        int topnum = baseDao.queryForInteger(sql1.toString(), params);
        StringBuilder sql2 = new StringBuilder("SELECT COUNT(ID) FROM KM_LIBRARY WHERE STATE = 1 ");
        params.put("top", "");
        params.put("jh", "1");
        getsql(params,sql2,params.get("type"));
        int jhnum = baseDao.queryForInteger(sql2.toString(), params);
        
        Map tempMap = new HashMap();
        List<Map> series = new ArrayList<Map>();
        List tempList = new ArrayList();
        tempList.add(allnum);
        tempList.add(topnum);
        tempList.add(jhnum);
        tempMap.put("data", tempList);
        tempMap.put("name", "数量");
        Map data = new HashMap();
        data.put("enabled", true);
        data.put("rotation", 360);
        data.put("color", "#FFFFFF");
        data.put("align", "right");
        data.put("x", 4);
        data.put("y", 10);
        Map style = new HashMap();
        style.put("fontSize", "13px");
        style.put("textShadow", "5 5 3px black");
        data.put("style", style);
        tempMap.put("dataLabels",data);
        series.add(tempMap);
        resMap.put("series", series);
        resMap.put("categories", categories);
        return resMap;
    }
    
    public void getsql(Map<String,String> param,StringBuilder sql,String type){
        String cateId = param.get("cateId");
        String startDate = param.get("beginTime");
        String endDate = param.get("endTime");
        String top = param.get("top");
        String jh = param.get("jh");
        if(!StringUtil.isEmpty(cateId) ){
            
            if("1".equals(type)){
                sql.append(" AND CATEGORY_ID = :cateId ");
            }else if("2".equals(type)){
                sql.append(" AND THIRDLEVEL_ID = :cateId ");
            }else if("3".equals(type)){
                sql.append(" AND THIRD_CATEGORY_ID = :cateId ");
            }
        }
        if(!StringUtil.isEmpty(startDate) ){
            sql.append(" AND CREATE_TIME >= :beginTime ");
        }
        if(!StringUtil.isEmpty(endDate) ){
            sql.append(" AND CREATE_TIME <= :endTime ");
        }
        if(!StringUtil.isEmpty(top) ){
            sql.append(" AND IS_TOP = 1 ");
        }
        if(!StringUtil.isEmpty(jh) ){
            sql.append(" AND IS_ESSENCE = 1 ");
        }
        
    }
 
    @Override
    public Map knowUserTjCol(Map<String, String> params) {
        params.put("beginTime", params.get("beginTime")+"000000");
        params.put("endTime", params.get("endTime")+"235959");
        String cateId = params.get("cateId");
        if(!StringUtil.isEmpty(cateId) ){
            String[] cateIds = cateId.split("-");
            params.put("cateId", cateIds[2]);
        }
        List<String> categories = new ArrayList<String>();
        categories.add("创建");
        categories.add("被顶");
        categories.add("被踩");
        categories.add("置顶");
        categories.add("精华");
        categories.add("编辑");
        Map resMap = new HashMap();
        StringBuilder sql = new StringBuilder("SELECT COUNT(A.ID) FROM KM_LIBRARY A WHERE A.STATE = 1 ");
        getusersql(params,sql);
        int allnum = baseDao.queryForInteger(sql.toString(), params);
        
        StringBuilder sql1 = new StringBuilder("SELECT COUNT(A.ID) FROM KM_LIBRARY A WHERE A.STATE = 1 ");
        params.put("top", "1");
        getusersql(params,sql1);
        int topnum = baseDao.queryForInteger(sql1.toString(), params);
        
        StringBuilder sql2 = new StringBuilder("SELECT COUNT(A.ID) FROM KM_LIBRARY A WHERE A.STATE = 1 ");
        params.put("top", "");
        params.put("jh", "1");
        getusersql(params,sql2);
        int jhnum = baseDao.queryForInteger(sql2.toString(), params);
        
        StringBuilder sqltype = new StringBuilder("SELECT COUNT(C.ID) FROM (SELECT DISTINCT A.ID FROM KM_LIBRARY A,KM_RECORD B WHERE A.STATE = 1 AND A.ID = B.LIBRARY_ID ");
        params.put("type", ConvertUtil.obj2StrBlank(Constants.KM_SCORE_RULE_TYPE_C));
        params.put("top", "");
        params.put("jh", "");
        getusersql(params,sqltype);
        sqltype.append(") C");
        int cainum = baseDao.queryForInteger(sqltype.toString(), params);
        
        StringBuilder sqltype1 = new StringBuilder("SELECT COUNT(C.ID) FROM (SELECT DISTINCT A.ID FROM KM_LIBRARY A,KM_RECORD B WHERE A.STATE = 1 AND A.ID = B.LIBRARY_ID ");
        params.put("type", ConvertUtil.obj2StrBlank(Constants.KM_SCORE_RULE_TYPE_D));
        params.put("top", "");
        params.put("jh", "");
        getusersql(params,sqltype1);
        sqltype1.append(") C");
        int zannum = baseDao.queryForInteger(sqltype1.toString(), params);
        
        StringBuilder sqltype2 = new StringBuilder("SELECT COUNT(C.ID) FROM (SELECT DISTINCT A.ID FROM KM_LIBRARY A,KM_RECORD B WHERE A.STATE = 1 AND A.ID = B.LIBRARY_ID ");
        params.put("type", ConvertUtil.obj2StrBlank(Constants.KM_SCORE_RULE_TYPE_BJ));
        params.put("top", "");
        params.put("jh", "");
        getusersql(params,sqltype2);
        sqltype2.append(") C");
        int editnum = baseDao.queryForInteger(sqltype2.toString(), params);
        
        Map tempMap = new HashMap();
        List<Map> series = new ArrayList<Map>();
        List tempList = new ArrayList();
        tempList.add(allnum);
        tempList.add(zannum);
        tempList.add(cainum);
        tempList.add(topnum);
        tempList.add(jhnum);
        tempList.add(editnum);
        tempMap.put("data", tempList);
        tempMap.put("name", "数量");
        Map data = new HashMap();
        data.put("enabled", true);
        data.put("rotation", 360);
        data.put("color", "#FFFFFF");
        data.put("align", "right");
        data.put("x", 4);
        data.put("y", 10);
        Map style = new HashMap();
        style.put("fontSize", "13px");
        style.put("textShadow", "5 5 3px black");
        data.put("style", style);
        tempMap.put("dataLabels",data);
        series.add(tempMap);
        resMap.put("series", series);
        resMap.put("categories", categories);
        return resMap;
    }
    
    public void getusersql(Map<String,String> param,StringBuilder sql){
        String user_id = param.get("user_id");
        String startDate = param.get("beginTime");
        String endDate = param.get("endTime");
        String type = param.get("type");
        String top = param.get("top");
        String jh = param.get("jh");
        if(!StringUtil.isEmpty(type)){
            if(ConvertUtil.obj2Integer(type) == Constants.KM_SCORE_RULE_TYPE_BJ){
                if(!StringUtil.isEmpty(type) ){
                    sql.append(" AND B.USER_ID = :user_id ");
                }
            }else{
                if(!StringUtil.isEmpty(user_id) ){
                    sql.append(" AND A.CREATE_USER_ID = :user_id ");
                }
            }
        }else{
            if(!StringUtil.isEmpty(user_id) ){
                sql.append(" AND A.CREATE_USER_ID = :user_id ");
            }
        }
        
        if(!StringUtil.isEmpty(startDate) ){
            sql.append(" AND A.CREATE_TIME >= :beginTime ");
        }
        if(!StringUtil.isEmpty(endDate) ){
            sql.append(" AND A.CREATE_TIME <= :endTime ");
        }
        if(!StringUtil.isEmpty(top) ){
            sql.append(" AND A.IS_TOP = 1 ");
        }
        if(!StringUtil.isEmpty(jh) ){
            sql.append(" AND A.IS_ESSENCE = 1 ");
        }
        if(!StringUtil.isEmpty(type) ){
            sql.append(" AND B.TYPE = :type ");
        }
        
    }
 
    @Override
    public Map knowDataTjCol(Map<String, String> params) {
        String beginTime = params.get("beginTime");
        String bfbeginTime = DateUtil.getMonthAdd(-12, beginTime+"01","yyyyMM" );
        List<String> categories = new ArrayList<String>();
        categories.add("01");
        categories.add("02");
        categories.add("03");
        categories.add("04");
        categories.add("05");
        categories.add("06");
        categories.add("07");
        categories.add("08");
        categories.add("09");
        categories.add("10");
        categories.add("11");
        categories.add("12");
        Map resMap = new HashMap();
        
        
        
        List<Map> series = new ArrayList<Map>();
        List tempList = new ArrayList();
        StringBuilder sql = new StringBuilder("SELECT COUNT(ID) AS NUM,DATE_FORMAT(CREATE_TIME,'%m') as TIME FROM KM_LIBRARY WHERE DATE_FORMAT(CREATE_TIME,'%Y') = :time AND STATE = 1  ");
        if("1".equals(params.get("type"))){
            sql.append(" AND CATEGORY_ID IS NOT NULL AND CATEGORY_ID <> ''");
        }else if("2".equals(params.get("type"))){
            sql.append(" AND THIRDLEVEL_ID IS NOT NULL AND THIRDLEVEL_ID <> ''");
        }else if("3".equals(params.get("type"))){
            sql.append(" AND THIRD_CATEGORY_ID IS NOT NULL AND THIRD_CATEGORY_ID <> ''");
        }
        sql.append(" GROUP BY DATE_FORMAT(CREATE_TIME,'%Y%m') ORDER BY DATE_FORMAT(CREATE_TIME, '%Y%m') DESC");
        List<Map> knowList = baseDao.queryForList(sql.toString(),new SqlParameter("time",beginTime));
        Map cacheMap = new HashMap();
        for(Map map:knowList){
            cacheMap.put(map.get("TIME"),map.get("NUM"));
        }
        for(String time:categories){
            if(cacheMap.containsKey(time)){
                tempList.add(cacheMap.get(time));
            }else{
                tempList.add(0);
            }
        }
        Map tempMap = new HashMap();
        tempMap.put("data", tempList);
        tempMap.put("name", beginTime);
        series.add(tempMap);
        
        List bftempList = new ArrayList();
        List<Map> bfknowList = baseDao.queryForList(sql.toString(),new SqlParameter("time",DateUtil.format("yyyy", bfbeginTime)));
        Map cacheMapbf = new HashMap();
        for(Map map:bfknowList){
            cacheMapbf.put(map.get("TIME"),map.get("NUM"));
        }
        for(String time:categories){
            if(cacheMapbf.containsKey(time)){
                bftempList.add(cacheMapbf.get(time));
            }else{
                bftempList.add(0);
            }
        }
        Map tempMap1 = new HashMap();
        tempMap1.put("data", bftempList);
        tempMap1.put("name", DateUtil.format("yyyy", bfbeginTime));
        series.add(tempMap1);
        
        resMap.put("series", series);
        categories = new ArrayList<String>();
        categories.add("1月");
        categories.add("2月");
        categories.add("3月");
        categories.add("4月");
        categories.add("5月");
        categories.add("6月");
        categories.add("7月");
        categories.add("8月");
        categories.add("9月");
        categories.add("10月");
        categories.add("11月");
        categories.add("12月");
        resMap.put("categories", categories);
        return resMap;
    }
 
    @Override
    public List knowcateReportData(Map<String, String> params) {
        
        String startDate = params.get("beginTime");
        String endDate = params.get("endTime");
        params.put("beginTime", startDate+"000000");
        params.put("endTime", endDate+"235959");
        StringBuilder sql = new StringBuilder(" ");
        
        getreportsql( sql, params);
        
        List<Map> knowList = baseDao.queryForList(sql.toString(),params);
        sql = new StringBuilder(" ");
        params.put("top", "1");
        getreportsql( sql, params);
        List<Map> knowtopList = baseDao.queryForList(sql.toString(),params);
        sql = new StringBuilder(" ");
        params.put("top", "");
        params.put("jh", "1");
        getreportsql( sql, params);
        List<Map> knowjhList = baseDao.queryForList(sql.toString(),params);
        
        Map cachetopMap = new HashMap();
        Map cachejhMap = new HashMap();
        for(Map map:knowtopList){
            cachetopMap.put(map.get("CATEGORY_ID"), map.get("NUM"));
        }
        for(Map map:knowjhList){
            cachejhMap.put(map.get("CATEGORY_ID"), map.get("NUM"));
        }
        for(Map map:knowList){
            if(cachetopMap.containsKey(map.get("CATEGORY_ID"))){
                map.put("topnum", cachetopMap.get(map.get("CATEGORY_ID")));
            }else{
                map.put("topnum", 0);
            }
            if(cachejhMap.containsKey(map.get("CATEGORY_ID"))){
                map.put("jhnum", cachejhMap.get(map.get("CATEGORY_ID")));
            }else{
                map.put("jhnum", 0);
            }
        }
        return knowList;
    }
    
    public void getreportsql(StringBuilder sql,Map<String, String> params){
        String startDate = params.get("beginTime");
        String endDate = params.get("endTime");
        sql.append("SELECT COUNT(ID) AS NUM  ");
        if("1".equals(params.get("type"))){
            sql.append(" ,FIRST_KNOWCATEGORY_ID AS CATEGORY_ID,FIRST_KNOWCATEGORY_NAME AS CATEGORY_NAME");
        }else if("2".equals(params.get("type"))){
            sql.append(" ,FIRSTLEVEL_ID AS CATEGORY_ID,FIRSTLEVEL_NAME AS CATEGORY_NAME");
        }else if("3".equals(params.get("type"))){
            sql.append(" ,FIRST_CATEGORY_ID AS CATEGORY_ID,FIRST_CATEGORY_NAME AS CATEGORY_NAME");
        }
        sql.append(" FROM KM_LIBRARY WHERE STATE = 1  ");
        
        if(!StringUtil.isEmpty(startDate) ){
            sql.append(" AND CREATE_TIME >= :beginTime ");
        }
        if(!StringUtil.isEmpty(endDate) ){
            sql.append(" AND CREATE_TIME <= :endTime ");
        }
        
        if(!StringUtil.isEmpty(params.get("top")) ){
            sql.append(" AND IS_TOP = 1 ");
        }
        
        if(!StringUtil.isEmpty(params.get("jh")) ){
            sql.append(" AND IS_ESSENCE = 1 ");
        }
        
        if("1".equals(params.get("type"))){
            sql.append(" AND FIRST_KNOWCATEGORY_ID IS NOT NULL AND FIRST_KNOWCATEGORY_ID <> '' GROUP BY FIRST_KNOWCATEGORY_ID ");
        }else if("2".equals(params.get("type"))){
            sql.append(" AND FIRSTLEVEL_ID IS NOT NULL  AND FIRSTLEVEL_ID <> '' GROUP BY FIRSTLEVEL_ID ");
        }else if("3".equals(params.get("type"))){
            sql.append(" AND FIRST_CATEGORY_ID IS NOT NULL  AND FIRST_CATEGORY_ID <> '' GROUP BY FIRST_CATEGORY_ID ");
        }
        
    }
 
    @Override
    public List knowuserReportData(Map<String, String> params) {
        StringBuilder sqlUser = new StringBuilder("SELECT * FROM GG_USER WHERE ZT = 1 ");
        String name = params.get("name");
        String dj = params.get("dj");
        if(!StringUtil.isEmpty(params.get("name"))){
            sqlUser.append(" AND ZSXM LIKE :name");
            params.put("name", "%"+name+"%");
        }
        
        String sql1 = "SELECT * FROM KM_EXPERT_LEVEL_RULE ORDER BY SCORE ";
        List<Map> list = baseDao.queryForList(sql1);
        Map cacheMap = new HashMap();
        for(Map map:list){
            int score = ConvertUtil.obj2Int(map.get("SCORE"));
            cacheMap.put(map.get("TYPE"),score);
        }
       if(!StringUtil.isEmpty(dj)){
            
            if(ConvertUtil.obj2Integer(dj) == Constants.KM_EXPERT_LEVEL_RULE_TYPE_CJZJ){
                sqlUser.append(" AND KM_SCORE >=:score1 AND KM_SCORE< :score2 ");
                params.put("score1",ConvertUtil.obj2StrBlank(cacheMap.get(Constants.KM_EXPERT_LEVEL_RULE_TYPE_CJZJ)) );
                params.put("score2", ConvertUtil.obj2StrBlank(cacheMap.get(Constants.KM_EXPERT_LEVEL_RULE_TYPE_ZJZJ)));
            }else if(ConvertUtil.obj2Integer(dj) == Constants.KM_EXPERT_LEVEL_RULE_TYPE_ZJZJ){
                sqlUser.append(" AND KM_SCORE >=:score1 AND KM_SCORE< :score2 ");
                params.put("score1",ConvertUtil.obj2StrBlank(cacheMap.get(Constants.KM_EXPERT_LEVEL_RULE_TYPE_ZJZJ)) );
                params.put("score2", ConvertUtil.obj2StrBlank(cacheMap.get(Constants.KM_EXPERT_LEVEL_RULE_TYPE_GJZJ)));
            }else if(ConvertUtil.obj2Integer(dj) == Constants.KM_EXPERT_LEVEL_RULE_TYPE_GJZJ){
                sqlUser.append(" AND KM_SCORE >=:score1 AND KM_SCORE< :score2 ");
                params.put("score1",ConvertUtil.obj2StrBlank(cacheMap.get(Constants.KM_EXPERT_LEVEL_RULE_TYPE_GJZJ)) );
                params.put("score2", ConvertUtil.obj2StrBlank(cacheMap.get(Constants.KM_EXPERT_LEVEL_RULE_TYPE_ZSZJ)));
            }else if(ConvertUtil.obj2Integer(dj) == Constants.KM_EXPERT_LEVEL_RULE_TYPE_ZSZJ){
                sqlUser.append(" AND KM_SCORE >=:score1 ");
                params.put("score1",ConvertUtil.obj2StrBlank(cacheMap.get(Constants.KM_EXPERT_LEVEL_RULE_TYPE_GJZJ)) );
            }
        }
        List<Map> userList = baseDao.queryForList(sqlUser.toString(),params);
        
        String startDate = params.get("beginTime");
        String endDate = params.get("endTime");
        params.put("beginTime", startDate+"000000");
        params.put("endTime", endDate+"235959");
        StringBuilder sql = new StringBuilder(" ");
        getusersql(sql,params);
        List<Map> knowList = baseDao.queryForList(sql.toString(),params);
        sql = new StringBuilder(" ");
        params.put("top", "1");
        getusersql(sql,params);
        List<Map> knowtopList = baseDao.queryForList(sql.toString(),params);
        sql = new StringBuilder(" ");
        params.put("top", "");
        params.put("jh", "1");
        getusersql(sql,params);
        List<Map> knowjhList = baseDao.queryForList(sql.toString(),params);
        
        StringBuilder sql2 = new StringBuilder("SELECT COUNT(C.LIBRARY_ID) AS NUM ,C.USER_ID FROM (SELECT DISTINCT B.LIBRARY_ID,B.USER_ID");
        sql2.append(" FROM KM_LIBRARY A,KM_RECORD B WHERE A.ID = B.LIBRARY_ID AND A.STATE = 1  ");
        if(!StringUtil.isEmpty(startDate) ){
            sql2.append(" AND A.CREATE_TIME >= :beginTime ");
        }
        if(!StringUtil.isEmpty(endDate) ){
            sql2.append(" AND A.CREATE_TIME <= :endTime ");
        }
        sql2.append(" AND B.TYPE = :type )C");
        sql2.append(" GROUP BY C.USER_ID ");
        params.put("type", ConvertUtil.obj2StrBlank(Constants.KM_SCORE_RULE_TYPE_D));
        List<Map> knowzanList = baseDao.queryForList(sql2.toString(),params);
        params.put("type", ConvertUtil.obj2StrBlank(Constants.KM_SCORE_RULE_TYPE_C));
        List<Map> knowcaiList = baseDao.queryForList(sql2.toString(),params);
        params.put("type", ConvertUtil.obj2StrBlank(Constants.KM_SCORE_RULE_TYPE_BJ));
        List<Map> knoweditList = baseDao.queryForList(sql2.toString(),params);
        Map cachetopMap = new HashMap();
        Map cachejhMap = new HashMap();
        Map cachecreateMap = new HashMap();
        Map cachezanMap = new HashMap();
        Map cachecaiMap = new HashMap();
        Map cacheeditMap = new HashMap();
        for(Map map:knowtopList){
            cachetopMap.put(map.get("USER_ID"), map.get("NUM"));
        }
        for(Map map:knowjhList){
            cachejhMap.put(map.get("USER_ID"), map.get("NUM"));
        }
        for(Map map:knowList){
            cachecreateMap.put(map.get("USER_ID"), map.get("NUM"));
        }
        for(Map map:knowzanList){
            cachezanMap.put(map.get("USER_ID"), map.get("NUM"));
        }
        for(Map map:knowcaiList){
            cachecaiMap.put(map.get("USER_ID"), map.get("NUM"));
        }
        for(Map map:knoweditList){
            cacheeditMap.put(map.get("USER_ID"), map.get("NUM"));
        }
        for(Map map:userList){
            if(cachetopMap.containsKey(map.get("ID"))){
                map.put("topnum", cachetopMap.get(map.get("ID")));
            }else{
                map.put("topnum", 0);
            }
            if(cachejhMap.containsKey(map.get("ID"))){
                map.put("jhnum", cachejhMap.get(map.get("ID")));
            }else{
                map.put("jhnum", 0);
            }
            if(cachecreateMap.containsKey(map.get("ID"))){
                map.put("createnum", cachecreateMap.get(map.get("ID")));
            }else{
                map.put("createnum", 0);
            }
            if(cachezanMap.containsKey(map.get("ID"))){
                map.put("zannum", cachezanMap.get(map.get("ID")));
            }else{
                map.put("zannum", 0);
            }
            if(cachecaiMap.containsKey(map.get("ID"))){
                map.put("cainum", cachecaiMap.get(map.get("ID")));
            }else{
                map.put("cainum", 0);
            }
            if(cacheeditMap.containsKey(map.get("ID"))){
                map.put("editnum", cacheeditMap.get(map.get("ID")));
            }else{
                map.put("editnum", 0);
            }
        }
        return userList;
    }
    
    public void getusersql(StringBuilder sql,Map<String, String> params){
        String startDate = params.get("beginTime");
        String endDate = params.get("endTime");
        sql.append("SELECT COUNT(ID) AS NUM ,CREATE_USER_ID AS USER_ID ");
        sql.append(" FROM KM_LIBRARY WHERE STATE = 1  ");
        if(!StringUtil.isEmpty(startDate) ){
            sql.append(" AND CREATE_TIME >= :beginTime ");
            
        }
        if(!StringUtil.isEmpty(endDate) ){
            sql.append(" AND CREATE_TIME <= :endTime ");
            
        }
        
        if(!StringUtil.isEmpty(params.get("top")) ){
            sql.append(" AND IS_TOP = 1 ");
        }
        
        if(!StringUtil.isEmpty(params.get("jh")) ){
            sql.append(" AND IS_ESSENCE = 1 ");
        }
        
        sql.append("GROUP BY CREATE_USER_ID ");
    }
 
    @Override
    public Map knowdataReportData(Map<String, String> params) {
        
        Map result = new HashMap();
        StringBuilder sql = new StringBuilder(" ");
        String year = params.get("year");
        params.put("beginTime", year+"01");
        params.put("endTime", year+"12");
        getdatasql(sql, params);
        int allnum = baseDao.queryForInteger(sql.toString(), params);
        sql = new StringBuilder(" ");
        params.put("beginTime", year+"01");
        params.put("endTime", year+"06");
        getdatasql(sql, params);
        int sbnnum = baseDao.queryForInteger(sql.toString(), params);
        sql = new StringBuilder(" ");
        params.put("beginTime", year+"07");
        params.put("endTime", year+"12");
        getdatasql(sql, params);
        int xbnnum = baseDao.queryForInteger(sql.toString(), params);
        sql = new StringBuilder(" ");
        params.put("beginTime", year+"01");
        params.put("endTime", year+"03");
        getdatasql(sql, params);
        int yjdnum = baseDao.queryForInteger(sql.toString(), params);
        sql = new StringBuilder(" ");
        params.put("beginTime", year+"04");
        params.put("endTime", year+"06");
        getdatasql(sql, params);
        int ejdnum = baseDao.queryForInteger(sql.toString(), params);
        sql = new StringBuilder(" ");
        params.put("beginTime", year+"07");
        params.put("endTime", year+"09");
        getdatasql(sql, params);
        int sjdnum = baseDao.queryForInteger(sql.toString(), params);
        sql = new StringBuilder(" ");
        params.put("beginTime", year+"10");
        params.put("endTime", year+"12");
        getdatasql(sql, params);
        int sijdnum = baseDao.queryForInteger(sql.toString(), params);
        result.put("allnum", allnum);
        result.put("sbnnum", sbnnum);
        result.put("xbnnum", xbnnum);
        result.put("yjdnum", yjdnum);
        result.put("ejdnum", ejdnum);
        result.put("sjdnum", sjdnum);
        result.put("sijdnum", sijdnum);
        return result;
    }
    
    public void getdatasql(StringBuilder sql,Map<String, String> params){
        String startDate = params.get("beginTime");
        String endDate = params.get("endTime");
        sql.append("SELECT COUNT(ID) FROM KM_LIBRARY WHERE STATE = 1 ");
        
        if(!StringUtil.isEmpty(startDate) ){
            sql.append(" AND DATE_FORMAT(CREATE_TIME,'%Y%m') >= :beginTime ");
            
        }
        if(!StringUtil.isEmpty(endDate) ){
            sql.append(" AND DATE_FORMAT(CREATE_TIME,'%Y%m') <= :endTime ");
            
        }
        if("1".equals(params.get("type"))){
            sql.append(" AND FIRST_KNOWCATEGORY_ID IS NOT NULL AND FIRST_KNOWCATEGORY_ID <> ''  ");
        }else if("2".equals(params.get("type"))){
            sql.append(" AND FIRSTLEVEL_ID IS NOT NULL  AND FIRSTLEVEL_ID <> '' ");
        }else if("3".equals(params.get("type"))){
            sql.append(" AND FIRST_CATEGORY_ID IS NOT NULL  AND FIRST_CATEGORY_ID <> ''  ");
        }
        
    }
 
}