add:首页看板
This commit is contained in:
@@ -7,6 +7,8 @@ import com.boge.modules.knowledge.service.dto.KnowledgeQueryDTO;
|
|||||||
import com.boge.modules.knowledge.service.dto.KnowledgeVO;
|
import com.boge.modules.knowledge.service.dto.KnowledgeVO;
|
||||||
import com.boge.modules.knowledge.service.entity.KnowledgeEntity;
|
import com.boge.modules.knowledge.service.entity.KnowledgeEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 知识文档Service
|
* 知识文档Service
|
||||||
*
|
*
|
||||||
@@ -86,4 +88,12 @@ public interface KnowledgeService extends IService<KnowledgeEntity> {
|
|||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
void unpublishKnowledge(Long id, Long userId);
|
void unpublishKnowledge(Long id, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最近的知识库列表
|
||||||
|
*
|
||||||
|
* @param limit 限制数量
|
||||||
|
* @return 知识库列表
|
||||||
|
*/
|
||||||
|
List<KnowledgeEntity> getRecentKnowledgeList(Integer limit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import com.boge.modules.knowledge.service.entity.KnowledgeEntity;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 知识文档Mapper
|
* 知识文档Mapper
|
||||||
*
|
*
|
||||||
@@ -54,4 +56,12 @@ public interface KnowledgeMapper extends BaseMapper<KnowledgeEntity> {
|
|||||||
* @param id 知识ID
|
* @param id 知识ID
|
||||||
*/
|
*/
|
||||||
void decreaseLikeCount(@Param("id") Long id);
|
void decreaseLikeCount(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最近的知识库列表
|
||||||
|
*
|
||||||
|
* @param limit 限制数量
|
||||||
|
* @return 知识库列表
|
||||||
|
*/
|
||||||
|
List<KnowledgeEntity> getRecentKnowledgeList(@Param("limit") Integer limit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 知识文档Service实现类
|
* 知识文档Service实现类
|
||||||
@@ -163,4 +164,9 @@ public class KnowledgeServiceImpl extends ServiceImpl<KnowledgeMapper, Knowledge
|
|||||||
knowledge.setUpdateTime(new Date());
|
knowledge.setUpdateTime(new Date());
|
||||||
this.updateById(knowledge);
|
this.updateById(knowledge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KnowledgeEntity> getRecentKnowledgeList(Integer limit) {
|
||||||
|
return baseMapper.getRecentKnowledgeList(limit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,75 @@
|
|||||||
package com.boge.modules.screen;
|
package com.boge.modules.screen;
|
||||||
|
|
||||||
import com.boge.common.utils.R;
|
import com.boge.common.utils.R;
|
||||||
import com.boge.modules.price.entity.PriceEntity;
|
import com.boge.common.utils.ShiroUtils;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import com.boge.modules.knowledge.service.KnowledgeService;
|
||||||
|
import com.boge.modules.knowledge.service.entity.KnowledgeEntity;
|
||||||
|
import com.boge.modules.sys.entity.SysUserEntity;
|
||||||
|
import com.boge.modules.tickets.service.TicketsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("screen")
|
@RequestMapping("screen")
|
||||||
public class ScreenController {
|
public class ScreenController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TicketsService ticketsService;
|
||||||
|
@Autowired
|
||||||
|
private KnowledgeService knowledgeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页数据接口
|
||||||
|
*/
|
||||||
|
@RequestMapping("/homeData")
|
||||||
|
public R homeData(){
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
|
// 获取当前年份
|
||||||
|
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||||
|
|
||||||
|
// 1. 年度工单统计(全部工单/未完成工单)
|
||||||
|
Map<String, Object> yearStats = ticketsService.getYearTicketsStats(currentYear);
|
||||||
|
result.put("yearStats", yearStats);
|
||||||
|
|
||||||
|
// 2. 近七日每天工单量统计
|
||||||
|
List<Map<String, Object>> sevenDaysStats = ticketsService.getLastSevenDaysStats();
|
||||||
|
result.put("sevenDaysStats", sevenDaysStats);
|
||||||
|
|
||||||
|
// 3. 客户工单数量TOP10
|
||||||
|
List<Map<String, Object>> topTenClients = ticketsService.getTopTenClientStats();
|
||||||
|
result.put("topTenClients", topTenClients);
|
||||||
|
|
||||||
|
// 4. 获取最近20条知识库
|
||||||
|
List<KnowledgeEntity> knowledgeList = knowledgeService.getRecentKnowledgeList(20);
|
||||||
|
result.put("knowledgeList", knowledgeList);
|
||||||
|
|
||||||
|
// 5. 获取当前登录用户信息
|
||||||
|
SysUserEntity user = ShiroUtils.getUserEntity();
|
||||||
|
if (user != null) {
|
||||||
|
Map<String, Object> userInfo = new HashMap<>();
|
||||||
|
userInfo.put("username", user.getUsername());
|
||||||
|
userInfo.put("nickname", user.getNickname());
|
||||||
|
userInfo.put("email", user.getEmail());
|
||||||
|
result.put("userInfo", userInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 获取各类型工单数量
|
||||||
|
Map<String, Object> ticketsCounts = new HashMap<>();
|
||||||
|
ticketsCounts.put("myInitiate", ticketsService.getTicketsCountByType("1")); // 我的发起
|
||||||
|
ticketsCounts.put("myTodo", ticketsService.getTicketsCountByType("2")); // 我的待办
|
||||||
|
ticketsCounts.put("myFinished", ticketsService.getTicketsCountByType("3")); // 我的完成
|
||||||
|
result.put("ticketsCounts", ticketsCounts);
|
||||||
|
|
||||||
|
return R.ok().put("data", result);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/info")
|
@RequestMapping("/info")
|
||||||
//@RequiresPermissions("flow:contract:info")
|
//@RequiresPermissions("flow:contract:info")
|
||||||
public R info(){
|
public R info(){
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import com.boge.modules.tickets.dto.TicketsDTO;
|
|||||||
import com.boge.modules.tickets.entity.TicketsEntity;
|
import com.boge.modules.tickets.entity.TicketsEntity;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -19,4 +23,23 @@ public interface TicketsDao extends BaseMapper<TicketsEntity> {
|
|||||||
TicketsDTO getTicketsDTOById(String ticketsId);
|
TicketsDTO getTicketsDTOById(String ticketsId);
|
||||||
|
|
||||||
String selectByProcessInstance(String processInstance);
|
String selectByProcessInstance(String processInstance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年度工单统计
|
||||||
|
* @param year 年份
|
||||||
|
* @return Map包含totalCount(总数)和unfinishedCount(未完成数)
|
||||||
|
*/
|
||||||
|
Map<String, Object> getYearTicketsStats(@Param("year") Integer year);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 近七日每天工单量统计
|
||||||
|
* @return List<Map> 包含date和count
|
||||||
|
*/
|
||||||
|
List<Map<String, Object>> getLastSevenDaysStats();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户工单数量TOP10
|
||||||
|
* @return List<Map> 包含clientName和ticketCount
|
||||||
|
*/
|
||||||
|
List<Map<String, Object>> getTopTenClientStats();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.boge.common.utils.PageUtils;
|
import com.boge.common.utils.PageUtils;
|
||||||
import com.boge.modules.tickets.dto.TicketsDTO;
|
import com.boge.modules.tickets.dto.TicketsDTO;
|
||||||
import com.boge.modules.tickets.entity.TicketsEntity;
|
import com.boge.modules.tickets.entity.TicketsEntity;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,5 +27,31 @@ public interface TicketsService extends IService<TicketsEntity> {
|
|||||||
void saveTicket(TicketsEntity tickets);
|
void saveTicket(TicketsEntity tickets);
|
||||||
|
|
||||||
void initiate(String ticketsId);
|
void initiate(String ticketsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年度工单统计
|
||||||
|
* @param year 年份
|
||||||
|
* @return Map包含totalCount(总数)和unfinishedCount(未完成数)
|
||||||
|
*/
|
||||||
|
Map<String, Object> getYearTicketsStats(Integer year);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 近七日每天工单量统计
|
||||||
|
* @return List<Map> 包含date和count
|
||||||
|
*/
|
||||||
|
List<Map<String, Object>> getLastSevenDaysStats();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户工单数量TOP10
|
||||||
|
* @return List<Map> 包含clientName和ticketCount
|
||||||
|
*/
|
||||||
|
List<Map<String, Object>> getTopTenClientStats();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据类型获取工单数量
|
||||||
|
* @param type 类型:1-我的发起,2-我的待办,3-我的完成
|
||||||
|
* @return 工单数量
|
||||||
|
*/
|
||||||
|
Integer getTicketsCountByType(String type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.boge.modules.sys.service.SysUserRoleService;
|
|||||||
import com.boge.modules.sys.service.impl.SysUserServiceImpl;
|
import com.boge.modules.sys.service.impl.SysUserServiceImpl;
|
||||||
import com.boge.modules.tickets.dto.TicketsDTO;
|
import com.boge.modules.tickets.dto.TicketsDTO;
|
||||||
import com.boge.modules.tickets.enums.TicketUserEnums;
|
import com.boge.modules.tickets.enums.TicketUserEnums;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.flowable.common.engine.api.FlowableException;
|
import org.flowable.common.engine.api.FlowableException;
|
||||||
import org.flowable.engine.IdentityService;
|
import org.flowable.engine.IdentityService;
|
||||||
@@ -150,4 +151,42 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
|
|||||||
return tickets;
|
return tickets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getYearTicketsStats(Integer year) {
|
||||||
|
return ticketsDao.getYearTicketsStats(year);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getLastSevenDaysStats() {
|
||||||
|
return ticketsDao.getLastSevenDaysStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getTopTenClientStats() {
|
||||||
|
return ticketsDao.getTopTenClientStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getTicketsCountByType(String type) {
|
||||||
|
SysUserEntity loginUser = ShiroUtils.getUserEntity();
|
||||||
|
QueryWrapper<TicketsEntity> queryWrapper = new QueryWrapper<>();
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(loginUser)) {
|
||||||
|
if (TicketsTypeEnums.ASSIGN.getCode().equals(type)) {
|
||||||
|
// 我的发起
|
||||||
|
queryWrapper.eq("create_user", loginUser.getUsername());
|
||||||
|
} else if (TicketsTypeEnums.TO_BE_DONE.getCode().equals(type)) {
|
||||||
|
// 我的待办
|
||||||
|
queryWrapper.eq("assign_user_id", loginUser.getUserId())
|
||||||
|
.eq("status", TicketsStatusEnums.REJECT.getCode());
|
||||||
|
} else if (TicketsTypeEnums.FINISH.getCode().equals(type)) {
|
||||||
|
// 我的完成
|
||||||
|
queryWrapper.eq("assign_user_id", loginUser.getUserId())
|
||||||
|
.eq("status", TicketsStatusEnums.FINISH.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.count(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,4 +146,29 @@
|
|||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<!-- 获取最近的知识库列表 -->
|
||||||
|
<select id="getRecentKnowledgeList" resultType="com.boge.modules.knowledge.service.entity.KnowledgeEntity">
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
summary,
|
||||||
|
category_id,
|
||||||
|
author_id,
|
||||||
|
cover_image,
|
||||||
|
view_count,
|
||||||
|
like_count,
|
||||||
|
collect_count,
|
||||||
|
status,
|
||||||
|
publish_time,
|
||||||
|
is_top,
|
||||||
|
tags,
|
||||||
|
create_time,
|
||||||
|
update_time
|
||||||
|
FROM knowledge
|
||||||
|
WHERE status = 'PUBLISHED'
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
LIMIT #{limit}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -29,5 +29,38 @@
|
|||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 年度工单统计 -->
|
||||||
|
<select id="getYearTicketsStats" resultType="java.util.HashMap">
|
||||||
|
SELECT
|
||||||
|
COUNT(*) as totalCount,
|
||||||
|
SUM(CASE WHEN status != 3 THEN 1 ELSE 0 END) as unfinishedCount
|
||||||
|
FROM sys_tickets
|
||||||
|
WHERE YEAR(create_time) = #{year}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 近七日每天工单量统计 -->
|
||||||
|
<select id="getLastSevenDaysStats" resultType="java.util.HashMap">
|
||||||
|
SELECT
|
||||||
|
DATE_FORMAT(create_time, '%Y-%m-%d') as date,
|
||||||
|
COUNT(*) as count
|
||||||
|
FROM sys_tickets
|
||||||
|
WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)
|
||||||
|
GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
|
||||||
|
ORDER BY date ASC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 客户工单数量TOP10 -->
|
||||||
|
<select id="getTopTenClientStats" resultType="java.util.HashMap">
|
||||||
|
SELECT
|
||||||
|
c.client_name as clientName,
|
||||||
|
COUNT(t.tickets_id) as ticketCount
|
||||||
|
FROM sys_tickets t
|
||||||
|
LEFT JOIN sys_client c ON t.client_id = c.client_id
|
||||||
|
WHERE c.client_name IS NOT NULL
|
||||||
|
GROUP BY t.client_id, c.client_name
|
||||||
|
ORDER BY ticketCount DESC
|
||||||
|
LIMIT 10
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user