Parcourir la source

Merge remote-tracking branch 'origin/master'

csg6 il y a 10 mois
Parent
commit
0da8b81226

+ 20 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/controller/PostAssessmentRatingController.java

@@ -5,6 +5,7 @@ import java.util.Date;
5 5
 import java.util.List;
6 6
 import javax.servlet.http.HttpServletResponse;
7 7
 
8
+import com.ruoyi.common.annotation.Anonymous;
8 9
 import org.springframework.security.access.prepost.PreAuthorize;
9 10
 import org.springframework.beans.factory.annotation.Autowired;
10 11
 import org.springframework.web.bind.annotation.GetMapping;
@@ -180,4 +181,23 @@ public class PostAssessmentRatingController extends BaseController {
180 181
     public AjaxResult getProblemByDeptId(@PathVariable Long deptId) {
181 182
         return success(postAssessmentRatingService.getProblemByDeptId(deptId));
182 183
     }
184
+
185
+
186
+
187
+
188
+    /**
189
+     * 根据部门查询问题
190
+     */
191
+    @ApiOperation("根据部门查询问题")
192
+
193
+    @ApiImplicitParams({
194
+            @ApiImplicitParam(name = "type", value = "类型1 年度 2 季度 3 月度", dataType = "String", dataTypeClass = Integer.class),
195
+            @ApiImplicitParam(name = "year", value = "年份", dataType = "String", dataTypeClass = String.class)
196
+    })
197
+    @GetMapping("/{type}/{year}")
198
+    @Anonymous
199
+    public AjaxResult assessmentstatistics(@PathVariable("type") Integer type,@PathVariable("year") String year) {
200
+        return success(postAssessmentRatingService.assessmentstatistics(type,year));
201
+    }
202
+
183 203
 }

+ 18 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/mapper/PostCheckedProblemMapper.java

@@ -2,10 +2,22 @@ package com.ruoyi.postCheck.mapper;
2 2
 
3 3
 import java.math.BigDecimal;
4 4
 import java.util.List;
5
+import java.util.Map;
6
+
5 7
 import com.ruoyi.postCheck.domain.PostCheckedProblem;
6 8
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
7 9
 import com.ruoyi.postCheck.domain.problemStatistics.ProblemNumberBase;
8 10
 import com.ruoyi.postCheck.domain.tools.ProblemCategory;
11
+import org.apache.ibatis.annotations.MapKey;
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
9 21
 
10 22
 /**
11 23
  * 岗检问题表Mapper接口
@@ -72,4 +84,10 @@ public interface PostCheckedProblemMapper extends BaseMapper<PostCheckedProblem>
72 84
      * @return
73 85
      */
74 86
     List<ProblemCategory> problemCategoryByAttribute();
87
+    @MapKey("YEAR")
88
+    Map<String, Object> getYearStatistics(String year);
89
+    @MapKey("QUARTER")
90
+    Map<String, Object> getQuarterStatistics(String year);
91
+    @MapKey("MONTH")
92
+    Map<String, Object> getMonthStatistics(String year);
75 93
 }

+ 4 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/service/IPostAssessmentRatingService.java

@@ -1,6 +1,8 @@
1 1
 package com.ruoyi.postCheck.service;
2 2
 
3 3
 import java.util.List;
4
+import java.util.Map;
5
+
4 6
 import com.ruoyi.postCheck.domain.PostAssessmentRating;
5 7
 import com.baomidou.mybatisplus.extension.service.IService;
6 8
 import com.ruoyi.postCheck.domain.PostCheckedProblem;
@@ -71,4 +73,6 @@ public interface IPostAssessmentRatingService extends IService<PostAssessmentRat
71 73
     public int deletePostAssessmentRatingById(Long id);
72 74
 
73 75
     List<PostCheckedProblem> getProblemByDeptId(Long id);
76
+
77
+    Map<String,Object> assessmentstatistics(Integer type, String year);
74 78
 }

+ 12 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/service/impl/PostAssessmentRatingServiceImpl.java

@@ -4,6 +4,7 @@ import java.math.BigDecimal;
4 4
 import java.math.RoundingMode;
5 5
 import java.util.ArrayList;
6 6
 import java.util.Comparator;
7
+import java.util.HashMap;
7 8
 import java.util.List;
8 9
 import java.util.Map;
9 10
 import java.util.Optional;
@@ -203,4 +204,15 @@ public class PostAssessmentRatingServiceImpl extends ServiceImpl<PostAssessmentR
203 204
             .eq(PostCheckedProblem::getCheckedDeptId,id)
204 205
         );
205 206
     }
207
+
208
+    @Override
209
+    public Map<String, Object> assessmentstatistics(Integer type, String year) {
210
+        if (type == 1)
211
+            return postCheckedProblemMapper.getYearStatistics(year);
212
+        if (type == 2)
213
+            return postCheckedProblemMapper.getQuarterStatistics(year);;
214
+        if (type == 3)
215
+            return postCheckedProblemMapper.getMonthStatistics(year);;
216
+        return new HashMap<>();
217
+    }
206 218
 }

+ 142 - 0
ruoyi-postcheck/src/main/resources/mapper/postCheck/PostCheckedProblemMapper.xml

@@ -359,4 +359,146 @@
359 359
         GROUP BY problem_attribute
360 360
         ORDER BY t1.problem_attribute
361 361
     </select>
362
+
363
+    <select id="getQuarterStatistics" resultType="java.util.Map">
364
+        SELECT "QUARTER",IFNULL(sum(num), '0') "num"
365
+        FROM (SELECT t."QUARTER", (t."sum" - t."two" - t."one") / "total" AS "num"
366
+              FROM (SELECT EXTRACT(
367
+                                   QUARTER
368
+                                   FROM
369
+                                   pp."create_time"
370
+                               )       "QUARTER",
371
+                           sum(pr."full_score"),
372
+                           COUNT(0)    total,
373
+                           SUM(CASE
374
+                               pp."problem_level"
375
+                                   WHEN 2 THEN pr."problem_level_two"
376
+                                   ELSE '0'
377
+                               END) AS "two",
378
+                           sum(CASE
379
+                               pp."problem_level"
380
+                                   WHEN 1 THEN pr."problem_level_one"
381
+                                   ELSE '0'
382
+                               END) AS "one"
383
+                    FROM "public"."post_checked_problem" pp
384
+                             INNER JOIN "public"."post_assessment_rules" pr ON
385
+                                pp."duty_type" = pr."duty_type"
386
+                            AND pr."type" = 1
387
+                    WHERE to_date(pp."create_time", 'YYYY') = to_date(#{year}, 'YYYY')
388
+                    GROUP BY EXTRACT(
389
+                                     QUARTER
390
+                                     FROM
391
+                                     pp."create_time"
392
+                                 )) t
393
+              union all
394
+              SELECT EXTRACT(
395
+                             QUARTER
396
+                             FROM
397
+                             "create_time"
398
+                         ) AS                        "QUARTER",
399
+                     sum("by_dept_score") / count(0) "num"
400
+
401
+              FROM "public"."post_assessment_rating_other_info"
402
+              WHERE to_date("create_time", 'YYYY') = to_date(#{year}, 'YYYY')
403
+              GROUP BY EXTRACT(
404
+                               QUARTER
405
+                               FROM
406
+                               "create_time"
407
+                           )) a
408
+        GROUP BY a."QUARTER"
409
+    </select>
410
+
411
+    <select id="getYearStatistics" resultType="java.util.Map">
412
+        SELECT "YEAR",IFNULL(sum(num), '0') "num"
413
+        FROM (SELECT t."YEAR", (t."sum" - t."two" - t."one") / "total" AS "num"
414
+              FROM (SELECT EXTRACT(
415
+                                   YEAR
416
+                                   FROM
417
+                                   pp."create_time"
418
+                               )       "YEAR",
419
+                           sum(pr."full_score"),
420
+                           COUNT(0)    total,
421
+                           SUM(CASE
422
+                               pp."problem_level"
423
+                                   WHEN 2 THEN pr."problem_level_two"
424
+                                   ELSE '0'
425
+                               END) AS "two",
426
+                           sum(CASE
427
+                               pp."problem_level"
428
+                                   WHEN 1 THEN pr."problem_level_one"
429
+                                   ELSE '0'
430
+                               END) AS "one"
431
+                    FROM "public"."post_checked_problem" pp
432
+                             INNER JOIN "public"."post_assessment_rules" pr ON
433
+                                pp."duty_type" = pr."duty_type"
434
+                            AND pr."type" = 1
435
+                    GROUP BY EXTRACT(
436
+                                     YEAR
437
+                                     FROM
438
+                                     pp."create_time"
439
+                                 )) t
440
+              union all
441
+              SELECT EXTRACT(
442
+                             YEAR
443
+                             FROM
444
+                             "create_time"
445
+                         ) AS                        "YEAR",
446
+                     sum("by_dept_score") / count(0) "num"
447
+
448
+              FROM "public"."post_assessment_rating_other_info"
449
+              GROUP BY EXTRACT(
450
+                               YEAR
451
+                               FROM
452
+                               "create_time"
453
+                           )) a
454
+        GROUP BY a."YEAR"
455
+    </select>
456
+
457
+    <select id="getMonthStatistics" resultType="java.util.Map">
458
+        SELECT "MONTH", IFNULL(sum(num), '0') "num"
459
+        FROM (SELECT t."MONTH", (t."sum" - t."two" - t."one") / "total" AS "num"
460
+              FROM (SELECT EXTRACT(
461
+                                   MONTH
462
+                                   FROM
463
+                                   pp."create_time"
464
+                               )       "MONTH",
465
+                           sum(pr."full_score"),
466
+                           COUNT(0)    total,
467
+                           SUM(CASE
468
+                               pp."problem_level"
469
+                                   WHEN 2 THEN pr."problem_level_two"
470
+                                   ELSE '0'
471
+                               END) AS "two",
472
+                           sum(CASE
473
+                               pp."problem_level"
474
+                                   WHEN 1 THEN pr."problem_level_one"
475
+                                   ELSE '0'
476
+                               END) AS "one"
477
+                    FROM "public"."post_checked_problem" pp
478
+                             INNER JOIN "public"."post_assessment_rules" pr ON
479
+                                pp."duty_type" = pr."duty_type"
480
+                            AND pr."type" = 1
481
+                    WHERE to_date(pp."create_time", 'YYYY') = to_date(#{year}, 'YYYY')
482
+                    GROUP BY EXTRACT(
483
+                                     MONTH
484
+                                     FROM
485
+                                     pp."create_time"
486
+                                 )) t
487
+              union all
488
+              SELECT EXTRACT(
489
+                             MONTH
490
+                             FROM
491
+                             "create_time"
492
+                         ) AS                        "MONTH",
493
+                     sum("by_dept_score") / count(0) "num"
494
+
495
+              FROM "public"."post_assessment_rating_other_info"
496
+              WHERE to_date("create_time", 'YYYY') = to_date(#{year}, 'YYYY')
497
+              GROUP BY EXTRACT(
498
+                               MONTH
499
+                               FROM
500
+                               "create_time"
501
+                           )) a
502
+        GROUP BY a."MONTH"
503
+    </select>
362 504
 </mapper>