Jelajahi Sumber

普通员工页面:CODE1-10进度数据抓取

wangggziwen 9 bulan lalu
induk
melakukan
9023fe9391

+ 107 - 0
rc-admin/src/main/java/com/ruoyi/web/controller/rc/TAuditController.java

@@ -1,6 +1,9 @@
 package com.ruoyi.web.controller.rc;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
@@ -59,6 +62,110 @@ public class TAuditController extends BaseController
     @Autowired
     private ITProgressService tProgressService;
 
+    /**
+     * 查询首页柱状图数据
+     */
+    @GetMapping("/bar")
+    public AjaxResult getBar() {
+        TAudit audit = new TAudit();
+        audit.setDeptId(getLoginUser().getDeptId().toString());
+        TAudit latest = tAuditService.selectTAuditLatest(audit);
+        if(latest != null) {
+            HashMap<String, String> map = new HashMap<String, String>();
+            int code0Count = 0;
+            int code1Count = 0;
+            int code2Count = 0;
+            int code3Count = 0;
+            int code4Count = 0;
+            int code5Count = 0;
+            int code6Count = 0;
+            int code7Count = 0;
+            int code8Count = 0;
+            int code9Count = 0;
+            int code0CompleteCount = 0;
+            int code1CompleteCount = 0;
+            int code2CompleteCount = 0;
+            int code3CompleteCount = 0;
+            int code4CompleteCount = 0;
+            int code5CompleteCount = 0;
+            int code6CompleteCount = 0;
+            int code7CompleteCount = 0;
+            int code8CompleteCount = 0;
+            int code9CompleteCount = 0;
+            BigDecimal code0CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            BigDecimal code1CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            BigDecimal code2CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            BigDecimal code3CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            BigDecimal code4CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            BigDecimal code5CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            BigDecimal code6CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            BigDecimal code7CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            BigDecimal code8CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            BigDecimal code9CompleteProgress = new BigDecimal(BigInteger.ZERO);
+            Long auditId = latest.getId();
+            TChapter chapter = new TChapter();
+            chapter.setAuditId(auditId);
+            List<TChapter> tChapters = tChapterService.selectTChapterList(chapter);
+            for (TChapter tChapter : tChapters) {
+                String code = tChapter.getCode();
+                char firstChar = code.charAt(0);
+                TQuestionnaire questionnaire = new TQuestionnaire();
+                questionnaire.setChapterId(tChapter.getId());
+                List<TQuestionnaire> tQuestionnaires = tQuestionnaireService.selectTQuestionnaireList(questionnaire);
+                for (TQuestionnaire tQuestionnaire : tQuestionnaires) {
+                    boolean flag = "1".equals(tQuestionnaire.getCompletionStatus());
+                    switch (firstChar) {
+                        case '0': code0Count++; if (flag) {code0CompleteCount++;} break;
+                        case '1': code1Count++; if (flag) {code1CompleteCount++;} break;
+                        case '2': code2Count++; if (flag) {code2CompleteCount++;} break;
+                        case '3': code3Count++; if (flag) {code3CompleteCount++;} break;
+                        case '4': code4Count++; if (flag) {code4CompleteCount++;} break;
+                        case '5': code5Count++; if (flag) {code5CompleteCount++;} break;
+                        case '6': code6Count++; if (flag) {code6CompleteCount++;} break;
+                        case '7': code7Count++; if (flag) {code7CompleteCount++;} break;
+                        case '8': code8Count++; if (flag) {code8CompleteCount++;} break;
+                        case '9': code9Count++; if (flag) {code9CompleteCount++;} break;
+                    }
+                }
+            }
+
+            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);}
+            if (code3Count != 0) {code3CompleteProgress = new BigDecimal(code3CompleteCount).divide(new BigDecimal(code3Count), 4, BigDecimal.ROUND_HALF_UP);}
+            if (code4Count != 0) {code4CompleteProgress = new BigDecimal(code4CompleteCount).divide(new BigDecimal(code4Count), 4, BigDecimal.ROUND_HALF_UP);}
+            if (code5Count != 0) {code5CompleteProgress = new BigDecimal(code5CompleteCount).divide(new BigDecimal(code5Count), 4, BigDecimal.ROUND_HALF_UP);}
+            if (code6Count != 0) {code6CompleteProgress = new BigDecimal(code6CompleteCount).divide(new BigDecimal(code6Count), 4, BigDecimal.ROUND_HALF_UP);}
+            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());
+            map.put("code3", code3CompleteProgress.toString());
+            map.put("code4", code4CompleteProgress.toString());
+            map.put("code5", code5CompleteProgress.toString());
+            map.put("code6", code6CompleteProgress.toString());
+            map.put("code7", code7CompleteProgress.toString());
+            map.put("code8", code8CompleteProgress.toString());
+            map.put("code9", code9CompleteProgress.toString());
+
+            return success(map);
+        } else {
+            return success();
+        }
+    }
+
+    /**
+     * 查询首页饼图数据
+     */
+    @GetMapping("/pie")
+    public AjaxResult getPie() {
+
+        return success();
+    }
+
     /**
      * 查询当前登录用户所在部门最近一次审计记录
      */

+ 1 - 1
ruoyi-ui/.env.development

@@ -6,7 +6,7 @@ ENV = 'development'
 
 # 若依管理系统/开发环境
 # VUE_APP_BASE_API = '/dev-api'
-VUE_APP_BASE_API = 'http://localhost:8094'
+VUE_APP_BASE_API = 'http://43.143.92.79:8094'
 
 
 # 路由懒加载

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

@@ -1,5 +1,13 @@
 import request from '@/utils/request'
 
+// 查询首页柱状图数据
+export function getBar() {
+  return request({
+    url: '/rc/audit/bar',
+    method: 'get'
+  })
+}
+
 // 查询当前登录用户所在部门最近一次审计记录
 export function getCurrent() {
   return request({

+ 64 - 15
ruoyi-ui/src/views/home2.vue

@@ -44,7 +44,7 @@
 </template>
 
 <script>
-import { getCurrent } from "@/api/rc/audit";
+import { getCurrent, getBar } from "@/api/rc/audit";
 import { getDept } from "@/api/system/dept";
 
 export default {
@@ -61,45 +61,45 @@ export default {
       preAuditTimeCountDown: null,
       capsuleConfig: {
         data: [
+          {
+            name: 'CODE 0',
+            value: null
+          },
           {
             name: 'CODE 1',
-            value: 67
+            value: null
           },
           {
             name: 'CODE 2',
-            value: 67
+            value: null
           },
           {
             name: 'CODE 3',
-            value: 67
+            value: null
           },
           {
             name: 'CODE 4',
-            value: 67
+            value: null
           },
           {
             name: 'CODE 5',
-            value: 23
+            value: null
           },
           {
             name: 'CODE 6',
-            value: 55
+            value: null
           },
           {
             name: 'CODE 7',
-            value: 98
+            value: null
           },
           {
             name: 'CODE 8',
-            value: 98
+            value: null
           },
           {
             name: 'CODE 9',
-            value: 98
-          },
-          {
-            name: 'CODE 10',
-            value: 98
+            value: null
           },
         ],
         unit: '%',
@@ -116,7 +116,7 @@ export default {
             endAngle: Math.PI * 1.5,
             arcLineWidth: 25,
             data: [
-              { name: 'itemA', value: 75, gradient: ['#03c2fd', '#1ed3e5', '#2fded6'] }
+              { name: 'itemA', value: 0, gradient: ['#03c2fd', '#1ed3e5', '#2fded6'] }
             ],
             axisLabel: {
               show: false
@@ -167,6 +167,55 @@ export default {
         }
       }
     });
+    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: {
     getString1(date) {

+ 1 - 1
ruoyi-ui/vue.config.js

@@ -35,7 +35,7 @@ module.exports = {
     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://localhost:8094`,
+        target: `http://43.143.92.79:8094`,
         changeOrigin: true,
         pathRewrite: {
           ['^' + process.env.VUE_APP_BASE_API]: ''