1.管理能查看到员工今日建联数量
This commit is contained in:
@@ -149,8 +149,6 @@ public class EmployeeHostsController {
|
||||
return success(employeeHostsService.getEmployeeHostsCompleteWithSelf(userId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/self_complete")
|
||||
@Operation(summary = "获得自己的建联率")
|
||||
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
|
||||
@@ -158,4 +156,12 @@ public class EmployeeHostsController {
|
||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
return success(employeeHostsService.getEmployeeHostsCompleteWithSelf(loginUserId));
|
||||
}
|
||||
|
||||
@PostMapping("/employeeCompleteBarChart")
|
||||
@Operation(summary = "获得员工的建联柱状图数据")
|
||||
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
|
||||
public CommonResult<List<CompletedRateVO>> getEmployeeCompleteBarChart(@RequestBody List<Long> userId) {
|
||||
return success(employeeHostsService.getEmployeeHostsCompleteBarChart(userId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,26 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/6 15:13
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "管理后台 - 员工建联完成率")
|
||||
public class CompletedRateVO {
|
||||
private Long userId;
|
||||
private Integer finishedNum;
|
||||
private Integer UnfinishedNum;
|
||||
private Integer totalNum;
|
||||
|
||||
public CompletedRateVO(Long userId, int i) {
|
||||
this.userId = userId;
|
||||
this.finishedNum = i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,4 +33,6 @@ public interface EmployeeHostsMapper extends BaseMapperX<EmployeeHostsDO> {
|
||||
void batchUpdate(ArrayList<EmployeeHostsDO> employeeHostsDOS);
|
||||
|
||||
CompletedRateVO selectEmployeeHostsWithOperationStatus(@Param("userId") Long userId);
|
||||
|
||||
List<CompletedRateVO> selectEmployeeHostsCompleteBarChart(List<Long> list);
|
||||
}
|
||||
@@ -66,4 +66,6 @@ public interface EmployeeHostsService {
|
||||
void batchUpdateEmployeeHosts(List<EmployeeHostsSaveReqVO> updateReqVOList);
|
||||
|
||||
CompletedRateVO getEmployeeHostsCompleteWithSelf(@Valid Long userId);
|
||||
|
||||
List<CompletedRateVO> getEmployeeHostsCompleteBarChart(@Valid List<Long> userId);
|
||||
}
|
||||
@@ -25,6 +25,8 @@ import org.springframework.validation.annotation.Validated;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@@ -178,5 +180,22 @@ public class EmployeeHostsServiceImpl implements EmployeeHostsService {
|
||||
return employeeHostsMapper.selectEmployeeHostsWithOperationStatus(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompletedRateVO> getEmployeeHostsCompleteBarChart(List<Long> userIdList) {
|
||||
|
||||
List<CompletedRateVO> dbList = employeeHostsMapper.selectEmployeeHostsCompleteBarChart(userIdList);
|
||||
|
||||
// 2. 转 Map,key 是 userId
|
||||
Map<Long, CompletedRateVO> dbMap = dbList.stream()
|
||||
.collect(Collectors.toMap(CompletedRateVO::getUserId, Function.identity()));
|
||||
|
||||
// 3. 组装结果
|
||||
List<CompletedRateVO> result = userIdList.stream()
|
||||
.map(userId -> dbMap.getOrDefault(userId, new CompletedRateVO(userId, 0))) // 缺数据补0
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user