修改首页默认页面

This commit is contained in:
wans 2022-01-05 18:01:14 +08:00
parent 587b932098
commit 5345649f25
6 changed files with 608 additions and 1 deletions

View File

@ -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<String, Object> 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<String, Object> param = requestParams();
List<String> dayList = new ArrayList<>();
List<Integer> 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<String, Object> params = requestParams();
List<DataDTO> dataDTOS = dataService.listByParentId("f4e6212e-55d1-41a8-a217-1a2874fe2cb1");
List<String> categoryNames = new ArrayList<>();
List<Integer> 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<String, Object> params = requestParams();
List<Map<String, Object>> knowledgeList = defaultHomePageDao.deptKnowLedgeGroup(params);
List<String> deptNames = new ArrayList<>();
List<Integer> counts = new ArrayList<>();
for (Map<String, Object> 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;
}
}

View File

@ -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<String, Object> params);
Integer countReport(Map<String, Object> params);
Integer countKnowledgeCorrection(Map<String, Object> params);
Integer countKnowledgeCollect(Map<String, Object> params);
Integer countView(Map<String, Object> params);
List<Map<String, Object>> deptKnowLedgeGroup(Map<String, Object> params);
}

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.tenlion.knowledgelibrary.dao.defaulthomepage.IDefaultHomePageDao">
<select id="countKnowledgeLib" parameterType="map" resultType="int">
SELECT
count(*) counts
FROM
t_knowledge_lib
WHERE
is_delete = '0'
<if test="category != null">
AND category = #{category}
</if>
</select>
<select id="countReport" parameterType="map" resultType="int">
SELECT
count(*) counts
FROM
t_knowledge_report
WHERE
is_delete = '0'
<if test="passType != null">
AND pass_type = #{passType}
</if>
</select>
<select id="countKnowledgeCorrection" parameterType="map" resultType="int">
SELECT
count(*) counts
FROM
t_knowledge_correction
WHERE
is_delete = '0'
</select>
<select id="countKnowledgeCollect" parameterType="map" resultType="int">
SELECT
count(*) counts
FROM
t_knowledge_collect
</select>
<select id="countView" parameterType="map" resultType="int">
SELECT
count(*) counts
FROM
t_knowledge_page_views
WHERE
is_delete = '0'
<if test="viewTime != null">
AND view_time LIKE CONCAT(#{viewTime}, '%');
</if>
</select>
<select id="deptKnowLedgeGroup" parameterType="map" resultType="map">
SELECT
source_dept sourceDept,
count(*) counts
FROM
t_knowledge_lib
WHERE
is_delete = '0'
GROUP BY source_dept
</select>
</mapper>

View File

@ -0,0 +1,385 @@
<!DOCTYPE html>
<html>
<head>
<base href="/library/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
<div class="layui-row">
<div class="layui-col-sm12 layui-col-md12 layui-col-space10">
<div class="layui-col-md7 layui-col-sm12">
<div class="layui-row layui-col-space10">
<div class="layui-col-sm3 layui-col-md3">
<div class="layui-card">
<div class="layui-card-header">
知识库总量
<span class="layui-badge layui-bg-blue layuiadmin-badge">
<i class="layui-inline fa fa-book"></i>
</span>
</div>
<div class="layui-card-body layuiadmin-card-list">
<p id="count1" class="layuiadmin-big-font">0</p>
</div>
</div>
</div>
<div class="layui-col-sm3 layui-col-md3">
<div class="layui-card">
<div class="layui-card-header">
上报待审
<span class="layui-badge layui-bg-orange layuiadmin-badge">
<i class="layui-inline fa fa-gavel"></i>
</span>
</div>
<div class="layui-card-body layuiadmin-card-list">
<p id="count2" class="layuiadmin-big-font">0</p>
</div>
</div>
</div>
<div class="layui-col-sm3 layui-col-md3">
<div class="layui-card">
<div class="layui-card-header">
版本纠错
<span class="layui-badge layui-bg-red layuiadmin-badge">
<i class="layui-inline fa fa-bolt"></i>
</span>
</div>
<div class="layui-card-body layuiadmin-card-list">
<p id="count3" class="layuiadmin-big-font">0</p>
</div>
</div>
</div>
<div class="layui-col-sm3 layui-col-md3">
<div class="layui-card">
<div class="layui-card-header">
知识收藏量
<span class="layui-badge layui-bg-green layuiadmin-badge">
<i class="layui-inline fa fa-star-half-o"></i>
</span>
</div>
<div class="layui-card-body layuiadmin-card-list">
<p id="count4" class="layuiadmin-big-font">0</p>
</div>
</div>
</div>
</div>
<div class="layui-row layui-col-space10">
<div class="layui-col-sm3 layui-col-md3">
<div class="layui-card" style="height: 191px">
<div class="layui-card-header">
知识浏览量
<span class="layui-badge layui-bg-gray layuiadmin-badge">
<i class="layui-inline fa fa-eye"></i>
</span>
</div>
<div class="layui-card-body layuiadmin-card-list">
<p id="count5" class="layuiadmin-big-font">0</p>
</div>
</div>
</div>
<div class="layui-col-sm12 layui-col-md9">
<div class="layui-card">
<div class="layui-card-body">
<div id="viewLineChart" style="width: 100%; height: 170px;"></div>
</div>
</div>
</div>
</div>
</div>
<div class="layui-col-sm12 layui-col-md5">
<div class="layui-col-sm12">
<div class="layui-card">
<div class="layui-card-body">
<div id="knowledgeCategoryChart" style="width: 100%; height: 302px;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="layui-row" style="padding-top: 5px">
<div class="layui-col-sm12 layui-col-md12 layui-col-space10">
<div class="layui-col-sm4 layui-col-md4">
<div class="layui-card">
<div class="layui-card-body">
<div id="deptKnowledgeChart" style="width: 100%; height: 400px;"></div>
</div>
</div>
</div>
<div class="layui-col-sm4 layui-col-md4">
<div class="layui-card">
<div class="layui-card-body">
<div id="educationChart" style="width: 100%; height: 400px;"></div>
</div>
</div>
</div>
<div class="layui-col-sm4 layui-col-md4">
<div class="layui-card">
<div class="layui-card-body">
<div id="nationChart" style="width: 100%; height: 400px;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="assets/js/vendor/echarts/echarts.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'animate-numbers'], function() {
var $ = layui.$;
var genderAgeChart;
var areaChart;
var educationChart;
var nationChart;
function initData(){
getAllCategoryPopulation();
initViewLineChart();
initKnowledgeCategoryChart();
initDeptKnowledgeChart();
/*initAreaChart();
initEducationChart();
nationChart();*/
}
initData();
function getAllCategoryPopulation(){
top.restAjax.get(top.restAjax.path('app/default-home-page/release/home-page-count', []), {}, null, function(code, data) {
$('#count1').html(data.count1);
$('#count2').html(data.count2);
$('#count3').html(data.count3);
$('#count4').html(data.count4);
$('#count5').html(data.count5);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
function initKnowledgeCategoryChart (){
top.restAjax.get(top.restAjax.path('app/default-home-page/release/knowledge-category', []), {}, null, function(code, data) {
areaChart = echarts.init(document.getElementById('knowledgeCategoryChart'));
areaChart.setOption({
title: {
text: '主题分类'
},
color : ['#0082ff'],
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
show: true,
},
xAxis: {
type: 'category',
axisLabel : {
rotate: -30,
},
data: data.categoryNames,
},
yAxis: {
type: 'value'
},
series: [
{
data: data.counts,
type: 'bar'
}
]
});
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
function initDeptKnowledgeChart (){
top.restAjax.get(top.restAjax.path('app/default-home-page/release/dept-knowledge', []), {}, null, function(code, data) {
areaChart = echarts.init(document.getElementById('deptKnowledgeChart'));
areaChart.setOption({
title: {
text: '知识上报情况'
},
color : ['#ffa235'],
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
show: true,
},
xAxis: {
type: 'category',
axisLabel : {
rotate: -30,
},
data: data.deptNames,
},
yAxis: {
type: 'value'
},
series: [
{
data: data.counts,
type: 'bar'
}
]
});
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
function initViewLineChart () {
top.restAjax.get(top.restAjax.path('app/default-home-page/release/day-view-line', []), {}, null, function(code, data) {
genderAgeChart = echarts.init(document.getElementById('viewLineChart'));
genderAgeChart.setOption({
title: {
text: '近期访问情况'
},
color: ['#1899a2', '#a2298c', '#0082ff'],
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
show: true,
},
xAxis: {
type: 'category',
boundaryGap: false,
data: data.dayList
},
yAxis: {
type: 'value'
},
series: [{
data: data.counts,
type: 'line',
areaStyle: {}
}]
});
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
function initEducationChart(){
top.restAjax.get(top.restAjax.path('app/default-home-page/release/get-education', []), {}, null, function(code, data) {
educationChart = echarts.init(document.getElementById('educationChart'));
educationChart.setOption({
title: {
text: '学历教育情况'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
boundaryGap: [0, 0.01]
},
yAxis: {
type: 'category',
data: data.educationName
},
series: [
{
type: 'bar',
data: data.counts
}
]
});
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
function nationChart() {
top.restAjax.get(top.restAjax.path('app/default-home-page/release/get-nation', []), {}, null, function(code, data) {
var chartData = [];
for(var i = 0; i < data.counts.length; i++){
var param = {
name : data.nationName[i],
value : data.counts[i]
}
chartData.push(param);
}
console.log(chartData);
nationChart = echarts.init(document.getElementById('nationChart'));
nationChart.setOption({
title: {
text: '民族分布情况',
left: 'left'
},
tooltip: {
trigger: 'item',
formatter: '{b} : {c} ({d}%)'
},
series: [
{
type: 'pie',
radius: [20, 140],
center: ['50%', '50%'],
roseType: 'area',
itemStyle: {
borderRadius: 5
},
data: chartData
}
]
});
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
});
</script>
</body>
</html>