1.添加员工完成率接口

This commit is contained in:
2025-08-06 19:53:30 +08:00
parent e4827a8b15
commit 62299502dd
6 changed files with 57 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@@ -126,4 +127,20 @@ public class EmployeeHostsController {
return success(BeanUtils.toBean(pageResult, EmployeeHostsRespVO.class));
}
@GetMapping("/employeeComplete")
@Operation(summary = "获得员工的建联率")
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
public CommonResult<CompletedRateVO> getEmployeeHostsComplete(@Valid Long userId) {
return success(employeeHostsService.getEmployeeHostsCompleteWithSelf(userId));
}
@GetMapping("/self_complete")
@Operation(summary = "获得自己的建联率")
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
public CommonResult<CompletedRateVO> getEmployeeHostsCompleteWithSelf() {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
return success(employeeHostsService.getEmployeeHostsCompleteWithSelf(loginUserId));
}
}

View File

@@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/*
* @author: ziin
* @date: 2025/8/6 15:13
*/
@Data
@Schema(description = "管理后台 - 员工建联完成率")
public class CompletedRateVO {
private Long userId;
private Integer finishedNum;
private Integer UnfinishedNum;
private Integer totalNum;
}

View File

@@ -32,4 +32,5 @@ public interface EmployeeHostsMapper extends BaseMapperX<EmployeeHostsDO> {
void batchUpdate(ArrayList<EmployeeHostsDO> employeeHostsDOS);
CompletedRateVO selectEmployeeHostsWithOperationStatus(@Param("userId") Long userId);
}

View File

@@ -64,4 +64,6 @@ public interface EmployeeHostsService {
PageResult<EmployeeHostsDO> getEmployeeHostsPageWithSelf(@Valid EmployeeHostsPageReqVO pageReqVO);
void batchUpdateEmployeeHosts(List<EmployeeHostsSaveReqVO> updateReqVOList);
CompletedRateVO getEmployeeHostsCompleteWithSelf(@Valid Long userId);
}

View File

@@ -155,4 +155,10 @@ public class EmployeeHostsServiceImpl implements EmployeeHostsService {
employeeHostsMapper.batchUpdate(employeeHostsDOS);
}
@Override
public CompletedRateVO getEmployeeHostsCompleteWithSelf(Long userId) {
return employeeHostsMapper.selectEmployeeHostsWithOperationStatus(userId);
}
}

View File

@@ -326,4 +326,18 @@
</foreach>
</update>
<select id="selectEmployeeHostsWithOperationStatus"
resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO">
SELECT
user_id AS userId,
SUM(CASE WHEN operation_status = 1 THEN 1 ELSE 0 END) AS finishedNum,
SUM(CASE WHEN operation_status = 0 THEN 1 ELSE 0 END) AS unfinishedNum,
COUNT(*) AS totalNum
FROM server_employee_hosts
WHERE deleted = 0
<if test="userId != null">
AND user_id = #{userId}
</if>
GROUP BY user_id
</select>
</mapper>