1.首页统计数量添加过去 7 天建联统计

This commit is contained in:
2025-10-17 15:13:08 +08:00
parent a7582cb558
commit 2145c51814
7 changed files with 29 additions and 15 deletions

View File

@@ -160,8 +160,8 @@ public class EmployeeHostsController {
@PostMapping("/employeeCompleteBarChart") @PostMapping("/employeeCompleteBarChart")
@Operation(summary = "获得员工的建联柱状图数据") @Operation(summary = "获得员工的建联柱状图数据")
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')") @PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
public CommonResult<List<CompletedRateVO>> getEmployeeCompleteBarChart(@RequestBody List<Long> userId) { public CommonResult<List<CompletedRateVO>> getEmployeeCompleteBarChart(@RequestBody EmployeeCompleteBarChartReqVO reqVO) {
return success(employeeHostsService.getEmployeeHostsCompleteBarChart(userId)); return success(employeeHostsService.getEmployeeHostsCompleteBarChart(reqVO.getUserId(),reqVO.getDays()));
} }
} }

View File

@@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo;
import lombok.Data;
import java.util.List;
/*
* @author: ziin
* @date: 2025/10/17 14:55
*/
@Data
public class EmployeeCompleteBarChartReqVO {
private List<Long> userId;
private Integer days;
}

View File

@@ -34,5 +34,5 @@ public interface EmployeeHostsMapper extends BaseMapperX<EmployeeHostsDO> {
CompletedRateVO selectEmployeeHostsWithOperationStatus(@Param("userId") Long userId); CompletedRateVO selectEmployeeHostsWithOperationStatus(@Param("userId") Long userId);
List<CompletedRateVO> selectEmployeeHostsCompleteBarChart(List<Long> list); List<CompletedRateVO> selectEmployeeHostsCompleteBarChart(@Param("list") List<Long> list, @Param("days") Integer days);
} }

View File

@@ -67,5 +67,5 @@ public interface EmployeeHostsService {
CompletedRateVO getEmployeeHostsCompleteWithSelf(@Valid Long userId); CompletedRateVO getEmployeeHostsCompleteWithSelf(@Valid Long userId);
List<CompletedRateVO> getEmployeeHostsCompleteBarChart(@Valid List<Long> userId); List<CompletedRateVO> getEmployeeHostsCompleteBarChart(@Valid List<Long> userId,Integer days);
} }

View File

@@ -181,9 +181,9 @@ public class EmployeeHostsServiceImpl implements EmployeeHostsService {
} }
@Override @Override
public List<CompletedRateVO> getEmployeeHostsCompleteBarChart(List<Long> userIdList) { public List<CompletedRateVO> getEmployeeHostsCompleteBarChart(List<Long> userIdList, Integer days) {
List<CompletedRateVO> dbList = employeeHostsMapper.selectEmployeeHostsCompleteBarChart(userIdList); List<CompletedRateVO> dbList = employeeHostsMapper.selectEmployeeHostsCompleteBarChart(userIdList,days);
try { try {

View File

@@ -418,21 +418,20 @@
<select id="selectEmployeeHostsCompleteBarChart" <select id="selectEmployeeHostsCompleteBarChart"
resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO"> resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO">
SELECT SELECT
user_id as userId, user_id AS userId,
COUNT(DISTINCT COUNT(DISTINCT
CASE WHEN operation_status = 1 THEN hosts_id END) AS finishedNum CASE WHEN operation_status = 1 THEN hosts_id END) AS finishedNum
FROM FROM server_employee_hosts
server_employee_hosts WHERE deleted = 0
WHERE
deleted = 0
AND operation_status = 1 AND operation_status = 1
AND DATE(update_time) = CURDATE() <!-- 日期范围:今天或过去 7 天(含今天) -->
<if test="list != null and list.size() != 0"> AND update_time >= DATE_SUB(CURDATE(), INTERVAL #{days,jdbcType=INTEGER} - 1 DAY)
<if test="list != null and list.size() > 0">
AND user_id IN AND user_id IN
<foreach collection="list" item="user_id" open="(" separator="," close=")"> <foreach collection="list" item="user_id" open="(" separator="," close=")">
#{user_id} #{user_id}
</foreach> </foreach>
</if> </if>
group by user_id GROUP BY user_id
</select> </select>
</mapper> </mapper>

View File

@@ -3,7 +3,7 @@ spring:
name: yudao-server name: yudao-server
profiles: profiles:
active: local active: dev
main: main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。