From 5345649f252d227eec5e1939eb7762fbfc0d1079 Mon Sep 17 00:00:00 2001 From: wans <747101512@qq.com> Date: Wed, 5 Jan 2022 18:01:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DefaultHomePageAppController.java | 127 ++++++ .../defaulthomepage/IDefaultHomePageDao.java | 27 ++ src/main/resources/application-prod.yml | 2 +- src/main/resources/application-test.yml | 1 + .../default-home-page-mapper.xml | 67 +++ src/main/resources/static/default.html | 385 ++++++++++++++++++ 6 files changed, 608 insertions(+), 1 deletion(-) create mode 100644 src/main/java/cn/com/tenlion/knowledgelibrary/controller/app/defaulthomepage/DefaultHomePageAppController.java create mode 100644 src/main/java/cn/com/tenlion/knowledgelibrary/dao/defaulthomepage/IDefaultHomePageDao.java create mode 100644 src/main/resources/mybatis/mapper/defaulthomepage/default-home-page-mapper.xml create mode 100644 src/main/resources/static/default.html diff --git a/src/main/java/cn/com/tenlion/knowledgelibrary/controller/app/defaulthomepage/DefaultHomePageAppController.java b/src/main/java/cn/com/tenlion/knowledgelibrary/controller/app/defaulthomepage/DefaultHomePageAppController.java new file mode 100644 index 0000000..b0d8554 --- /dev/null +++ b/src/main/java/cn/com/tenlion/knowledgelibrary/controller/app/defaulthomepage/DefaultHomePageAppController.java @@ -0,0 +1,127 @@ +package cn.com.tenlion.knowledgelibrary.controller.app.defaulthomepage; + +import cn.com.tenlion.knowledgelibrary.dao.defaulthomepage.IDefaultHomePageDao; +import ink.wgink.common.base.DefaultBaseController; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.login.oauth2.client.service.department.IDepartmentService; +import ink.wgink.module.dictionary.pojo.dtos.DataDTO; +import ink.wgink.module.dictionary.service.IDataService; +import ink.wgink.pojo.dtos.department.DepartmentDTO; +import ink.wgink.util.date.DateUtil; +import lombok.experimental.var; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.sound.midi.Soundbank; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author xwangs + * @create 2022-01-04 16:00 + * @description + */ +@RestController +@RequestMapping(ISystemConstant.APP_PREFIX + "/default-home-page") +public class DefaultHomePageAppController extends DefaultBaseController { + + @Autowired + private IDefaultHomePageDao defaultHomePageDao; + @Autowired + private IDataService dataService; + @Autowired + private IDepartmentService departmentService; + + @GetMapping("release/home-page-count") + public Object homePageCount(){ + Map params = requestParams(); + // 知识库总量 + Integer libraryCount = defaultHomePageDao.countKnowledgeLib(params); + // 上报待审量 + params.clear(); + params.put("passType", 1); + Integer reportPassCount = defaultHomePageDao.countReport(params); + // 版本纠错 + Integer correctionCount = defaultHomePageDao.countKnowledgeCorrection(params); + // 知识收藏 + Integer collectCount = defaultHomePageDao.countKnowledgeCollect(params); + // 知识浏览量 + Integer viewCount = defaultHomePageDao.countView(params); + params.clear(); + params.put("count1", libraryCount); + params.put("count2", reportPassCount); + params.put("count3", correctionCount); + params.put("count4", collectCount); + params.put("count5", viewCount); + return params; + } + + @GetMapping("release/day-view-line") + public Object dayViewLine(){ + Map param = requestParams(); + List dayList = new ArrayList<>(); + List counts = new ArrayList<>(); + for(int i = 0; i < 7; i++){ + String queryDay = DateUtil.getBeforeDate(i,"yyyy-MM-dd"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + Date parse = sdf.parse(queryDay); + sdf = new SimpleDateFormat("M月d日"); + dayList.add(0,sdf.format(parse)); + } catch (ParseException e) { + dayList.add(0, queryDay); + } + param.clear(); + param.put("viewTime", queryDay); + Integer count = defaultHomePageDao.countView(param); + counts.add(0, count); + } + param.clear(); + param.put("dayList", dayList); + param.put("counts", counts); + return param; + } + + @GetMapping("release/knowledge-category") + public Object knowledgeCategory(){ + Map params = requestParams(); + List dataDTOS = dataService.listByParentId("f4e6212e-55d1-41a8-a217-1a2874fe2cb1"); + List categoryNames = new ArrayList<>(); + List counts = new ArrayList<>(); + for(DataDTO item : dataDTOS){ + params.clear(); + params.put("category", item.getDataId()); + Integer count = defaultHomePageDao.countKnowledgeLib(params); + categoryNames.add(item.getDataName()); + counts.add(count); + } + params.clear(); + params.put("categoryNames", categoryNames); + params.put("counts", counts); + return params; + } + + @GetMapping("release/dept-knowledge") + public Object deptKnowledge(){ + Map params = requestParams(); + List> knowledgeList = defaultHomePageDao.deptKnowLedgeGroup(params); + List deptNames = new ArrayList<>(); + List counts = new ArrayList<>(); + for (Map item : knowledgeList){ + DepartmentDTO sourceDept = departmentService.get(item.get("sourceDept").toString()); + deptNames.add(sourceDept.getDepartmentName()); + counts.add(Integer.parseInt(item.get("counts").toString())); + } + params.clear(); + params.put("deptNames", deptNames); + params.put("counts", counts); + return params; + } + +} diff --git a/src/main/java/cn/com/tenlion/knowledgelibrary/dao/defaulthomepage/IDefaultHomePageDao.java b/src/main/java/cn/com/tenlion/knowledgelibrary/dao/defaulthomepage/IDefaultHomePageDao.java new file mode 100644 index 0000000..bb04ef9 --- /dev/null +++ b/src/main/java/cn/com/tenlion/knowledgelibrary/dao/defaulthomepage/IDefaultHomePageDao.java @@ -0,0 +1,27 @@ +package cn.com.tenlion.knowledgelibrary.dao.defaulthomepage; + +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +/** + * @author xwangs + * @create 2022-01-05 11:02 + * @description + */ +@Repository +public interface IDefaultHomePageDao { + + Integer countKnowledgeLib(Map params); + + Integer countReport(Map params); + + Integer countKnowledgeCorrection(Map params); + + Integer countKnowledgeCollect(Map params); + + Integer countView(Map params); + + List> deptKnowLedgeGroup(Map params); +} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index a6a0f67..9cbda6c 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -4,7 +4,7 @@ server: url: http://${server.ip}:37210/library system-title: 知识库系统 system-sub-title: 知识库 - #default-index-page: + default-home-page: default.html nav-page: ${api-path.user-center-2} servlet: context-path: /library diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 3655754..2a80471 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -3,6 +3,7 @@ server: url: http://192.168.0.109:9000/library system-title: 知识库系统 system-sub-title: 知识库系统 + default-home-page: default.html servlet: context-path: /library nav-page: http://192.168.0.155:7011/usercenter diff --git a/src/main/resources/mybatis/mapper/defaulthomepage/default-home-page-mapper.xml b/src/main/resources/mybatis/mapper/defaulthomepage/default-home-page-mapper.xml new file mode 100644 index 0000000..c255b69 --- /dev/null +++ b/src/main/resources/mybatis/mapper/defaulthomepage/default-home-page-mapper.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/default.html b/src/main/resources/static/default.html new file mode 100644 index 0000000..dfacff9 --- /dev/null +++ b/src/main/resources/static/default.html @@ -0,0 +1,385 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+ 知识库总量 + + + +
+
+

0

+
+
+
+
+
+
+ 上报待审 + + + +
+
+

0

+
+
+
+
+
+
+ 版本纠错 + + + +
+
+

0

+
+
+
+
+
+
+ 知识收藏量 + + + +
+
+

0

+
+
+
+
+
+
+
+
+ 知识浏览量 + + + +
+
+

0

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + \ No newline at end of file