Forráskód Böngészése

RC审计 - 普通员工页面:审计开项完成率数据抓取

wangggziwen 1 éve
szülő
commit
74d4ebc1df

+ 34 - 5
rc-admin/src/main/java/com/ruoyi/web/controller/rc/TAuditController.java

@@ -62,6 +62,9 @@ public class TAuditController extends BaseController
     @Autowired
     private ITProgressService tProgressService;
 
+    @Autowired
+    private ITOpenItemService itOpenItemService;
+
     /**
      * 查询首页柱状图数据
      */
@@ -128,7 +131,6 @@ public class TAuditController extends BaseController
                     }
                 }
             }
-
             if (code0Count != 0) {code0CompleteProgress = new BigDecimal(code0CompleteCount).divide(new BigDecimal(code0Count), 4, BigDecimal.ROUND_HALF_UP);}
             if (code1Count != 0) {code1CompleteProgress = new BigDecimal(code1CompleteCount).divide(new BigDecimal(code1Count), 4, BigDecimal.ROUND_HALF_UP);}
             if (code2Count != 0) {code2CompleteProgress = new BigDecimal(code2CompleteCount).divide(new BigDecimal(code2Count), 4, BigDecimal.ROUND_HALF_UP);}
@@ -139,7 +141,6 @@ public class TAuditController extends BaseController
             if (code7Count != 0) {code7CompleteProgress = new BigDecimal(code7CompleteCount).divide(new BigDecimal(code7Count), 4, BigDecimal.ROUND_HALF_UP);}
             if (code8Count != 0) {code8CompleteProgress = new BigDecimal(code8CompleteCount).divide(new BigDecimal(code8Count), 4, BigDecimal.ROUND_HALF_UP);}
             if (code9Count != 0) {code9CompleteProgress = new BigDecimal(code9CompleteCount).divide(new BigDecimal(code9Count), 4, BigDecimal.ROUND_HALF_UP);}
-
             map.put("code0", code0CompleteProgress.toString());
             map.put("code1", code1CompleteProgress.toString());
             map.put("code2", code2CompleteProgress.toString());
@@ -150,7 +151,6 @@ public class TAuditController extends BaseController
             map.put("code7", code7CompleteProgress.toString());
             map.put("code8", code8CompleteProgress.toString());
             map.put("code9", code9CompleteProgress.toString());
-
             return success(map);
         } else {
             return success();
@@ -162,8 +162,37 @@ public class TAuditController extends BaseController
      */
     @GetMapping("/pie")
     public AjaxResult getPie() {
-
-        return success();
+        int count = 0;
+        int completeCount = 0;
+        BigDecimal progress = new BigDecimal(BigInteger.ZERO);
+        TAudit audit = new TAudit();
+        audit.setDeptId(getLoginUser().getDeptId().toString());
+        TAudit latest = tAuditService.selectTAuditLatest(audit);
+        Long auditId = latest.getId();
+        TChapter chapter = new TChapter();
+        chapter.setAuditId(auditId);
+        List<TChapter> tChapters = tChapterService.selectTChapterList(chapter);
+        for (TChapter tChapter : tChapters) {
+            TQuestionnaire questionnaire = new TQuestionnaire();
+            questionnaire.setChapterId(tChapter.getId());
+            List<TQuestionnaire> tQuestionnaires = tQuestionnaireService.selectTQuestionnaireList(questionnaire);
+            for (TQuestionnaire tQuestionnaire : tQuestionnaires) {
+                TOpenItem openItem = new TOpenItem();
+                openItem.setQuestionnaireId(tQuestionnaire.getId());
+                List<TOpenItem> tOpenItems = itOpenItemService.selectTOpenItemList(openItem);
+                for (TOpenItem tOpenItem : tOpenItems) {
+                    count++;
+                    String status = tOpenItem.getStatus();
+                    if ("4".equals(status)) {
+                        completeCount++;
+                    }
+                }
+            }
+        }
+        if (count != 0) {
+            progress = new BigDecimal(completeCount).divide(new BigDecimal(count), 4, BigDecimal.ROUND_HALF_UP);
+        }
+        return success(progress);
     }
 
     /**

+ 8 - 0
ruoyi-ui/src/api/rc/audit.js

@@ -8,6 +8,14 @@ export function getBar() {
   })
 }
 
+// 查询首页饼图数据
+export function getPie() {
+  return request({
+    url: '/rc/audit/pie',
+    method: 'get'
+  })
+}
+
 // 查询当前登录用户所在部门最近一次审计记录
 export function getCurrent() {
   return request({

+ 119 - 72
ruoyi-ui/src/views/home2.vue

@@ -44,7 +44,7 @@
 </template>
 
 <script>
-import { getCurrent, getBar } from "@/api/rc/audit";
+import { getCurrent, getBar, getPie } from "@/api/rc/audit";
 import { getDept } from "@/api/system/dept";
 
 export default {
@@ -144,80 +144,127 @@ export default {
     }
   },
   created() {
-    getCurrent().then(response => {
-      if (response.data) {
-        let data = response.data;
-        getDept(data.deptId).then(response => {
-          this.deptName = response.data.deptName;
-        });
-        this.auditTime = data.auditTime;
-        this.preAuditTime = data.preAuditTime;
-        let date = new Date();
-        let auditTime = new Date(data.auditTime);
-        let preAuditTime = new Date(data.preAuditTime);
-        this.auditTimeString1 = this.getString1(auditTime);
-        this.auditTimeString2 = this.getString2(auditTime);
-        this.preAuditTimeString1 = this.getString1(preAuditTime);
-        this.preAuditTimeString2 = this.getString2(preAuditTime);
-        if (date <= auditTime) {
-          this.auditTimeCountDown = Math.ceil((auditTime - date) / (1000 * 60 * 60 * 24));
-        }
-        if (date <= preAuditTime) {
-          this.preAuditTimeCountDown = Math.ceil((preAuditTime - date) / (1000 * 60 * 60 * 24));
+    this.getCurrent();
+    this.getBar();
+    this.getPie();
+  },
+  methods: {
+    getCurrent() {
+      getCurrent().then(response => {
+        if (response.data) {
+          let data = response.data;
+          getDept(data.deptId).then(response => {
+            this.deptName = response.data.deptName;
+          });
+          this.auditTime = data.auditTime;
+          this.preAuditTime = data.preAuditTime;
+          let date = new Date();
+          let auditTime = new Date(data.auditTime);
+          let preAuditTime = new Date(data.preAuditTime);
+          this.auditTimeString1 = this.getString1(auditTime);
+          this.auditTimeString2 = this.getString2(auditTime);
+          this.preAuditTimeString1 = this.getString1(preAuditTime);
+          this.preAuditTimeString2 = this.getString2(preAuditTime);
+          if (date <= auditTime) {
+            this.auditTimeCountDown = Math.ceil((auditTime - date) / (1000 * 60 * 60 * 24));
+          }
+          if (date <= preAuditTime) {
+            this.preAuditTimeCountDown = Math.ceil((preAuditTime - date) / (1000 * 60 * 60 * 24));
+          }
         }
-      }
-    });
-    getBar().then(response => {
-      let data = response.data;
-      this.capsuleConfig = {
-        data: [
-          {
-            name: 'CODE 0',
-            value: Math.floor(data.code0 * 100)
-          },
-          {
-            name: 'CODE 1',
-            value: Math.floor(data.code1 * 100)
-          },
-          {
-            name: 'CODE 2',
-            value: Math.floor(data.code2 * 100)
-          },
-          {
-            name: 'CODE 3',
-            value: Math.floor(data.code3 * 100)
-          },
-          {
-            name: 'CODE 4',
-            value: Math.floor(data.code4 * 100)
-          },
-          {
-            name: 'CODE 5',
-            value: Math.floor(data.code5 * 100)
-          },
-          {
-            name: 'CODE 6',
-            value: Math.floor(data.code6 * 100)
-          },
-          {
-            name: 'CODE 7',
-            value: Math.floor(data.code7 * 100)
-          },
-          {
-            name: 'CODE 8',
-            value: Math.floor(data.code8 * 100)
-          },
-          {
-            name: 'CODE 9',
-            value: Math.floor(data.code9 * 100)
-          },
-        ],
+      });
+    },
+    getBar() {
+      getBar().then(response => {
+        let data = response.data;
+        this.capsuleConfig = {
+          data: [
+            {
+              name: 'CODE 0',
+              value: Math.floor(data.code0 * 100)
+            },
+            {
+              name: 'CODE 1',
+              value: Math.floor(data.code1 * 100)
+            },
+            {
+              name: 'CODE 2',
+              value: Math.floor(data.code2 * 100)
+            },
+            {
+              name: 'CODE 3',
+              value: Math.floor(data.code3 * 100)
+            },
+            {
+              name: 'CODE 4',
+              value: Math.floor(data.code4 * 100)
+            },
+            {
+              name: 'CODE 5',
+              value: Math.floor(data.code5 * 100)
+            },
+            {
+              name: 'CODE 6',
+              value: Math.floor(data.code6 * 100)
+            },
+            {
+              name: 'CODE 7',
+              value: Math.floor(data.code7 * 100)
+            },
+            {
+              name: 'CODE 8',
+              value: Math.floor(data.code8 * 100)
+            },
+            {
+              name: 'CODE 9',
+              value: Math.floor(data.code9 * 100)
+            },
+          ],
           unit: '%',
           showValue: true
-      };
-    });
-  },
-  methods: {
+        };
+      });
+    },
+    getPie() {
+      getPie().then(response => {
+        this.pieOption = {
+          title: {
+            text: '审计开项完成率'
+          },
+          series: [
+            {
+              type: 'gauge',
+              startAngle: -Math.PI / 2,
+              endAngle: Math.PI * 1.5,
+              arcLineWidth: 25,
+              data: [
+                { name: 'itemA', value: Math.floor(response.data * 100), gradient: ['#03c2fd', '#1ed3e5', '#2fded6'] }
+              ],
+              axisLabel: {
+                show: false
+              },
+              axisTick: {
+                show: false
+              },
+              pointer: {
+                show: false
+              },
+              dataItemStyle: {
+                lineCap: 'round'
+              },
+              details: {
+                show: true,
+                formatter: '{value}%',
+                style: {
+                  fill: '#1ed3e5',
+                  fontSize: 35
+                }
+              }
+            }
+          ]
+        };
+      });
+    },
     getString1(date) {
       return Number(date.getYear() + 1900) + "年" + Number(date.getMonth() + 1) + "月" + date.getDate() + "日";
     },