1.管理能查看到员工今日建联数量
This commit is contained in:
@@ -149,8 +149,6 @@ public class EmployeeHostsController {
|
|||||||
return success(employeeHostsService.getEmployeeHostsCompleteWithSelf(userId));
|
return success(employeeHostsService.getEmployeeHostsCompleteWithSelf(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/self_complete")
|
@GetMapping("/self_complete")
|
||||||
@Operation(summary = "获得自己的建联率")
|
@Operation(summary = "获得自己的建联率")
|
||||||
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
|
@PreAuthorize("@ss.hasPermission('server:employee-hosts:selfquery')")
|
||||||
@@ -158,4 +156,12 @@ public class EmployeeHostsController {
|
|||||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||||
return success(employeeHostsService.getEmployeeHostsCompleteWithSelf(loginUserId));
|
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;
|
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author: ziin
|
* @author: ziin
|
||||||
* @date: 2025/8/6 15:13
|
* @date: 2025/8/6 15:13
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
@Schema(description = "管理后台 - 员工建联完成率")
|
@Schema(description = "管理后台 - 员工建联完成率")
|
||||||
public class CompletedRateVO {
|
public class CompletedRateVO {
|
||||||
private Long userId;
|
private Long userId;
|
||||||
private Integer finishedNum;
|
private Integer finishedNum;
|
||||||
private Integer UnfinishedNum;
|
private Integer UnfinishedNum;
|
||||||
private Integer totalNum;
|
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);
|
void batchUpdate(ArrayList<EmployeeHostsDO> employeeHostsDOS);
|
||||||
|
|
||||||
CompletedRateVO selectEmployeeHostsWithOperationStatus(@Param("userId") Long userId);
|
CompletedRateVO selectEmployeeHostsWithOperationStatus(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
List<CompletedRateVO> selectEmployeeHostsCompleteBarChart(List<Long> list);
|
||||||
}
|
}
|
||||||
@@ -66,4 +66,6 @@ public interface EmployeeHostsService {
|
|||||||
void batchUpdateEmployeeHosts(List<EmployeeHostsSaveReqVO> updateReqVOList);
|
void batchUpdateEmployeeHosts(List<EmployeeHostsSaveReqVO> updateReqVOList);
|
||||||
|
|
||||||
CompletedRateVO getEmployeeHostsCompleteWithSelf(@Valid Long userId);
|
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 javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@@ -178,5 +180,22 @@ public class EmployeeHostsServiceImpl implements EmployeeHostsService {
|
|||||||
return employeeHostsMapper.selectEmployeeHostsWithOperationStatus(userId);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,54 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- 使用 IGNORE 关键字忽略重复插入 -->
|
<!-- 使用 IGNORE 关键字忽略重复插入 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id,
|
||||||
|
hosts_id,
|
||||||
|
user_id,
|
||||||
|
hosts_level,
|
||||||
|
hosts_coins,
|
||||||
|
invitation_type,
|
||||||
|
online_fans,
|
||||||
|
fans,
|
||||||
|
fllowernum,
|
||||||
|
yesterday_coins,
|
||||||
|
country,
|
||||||
|
hosts_kind,
|
||||||
|
operation_status,
|
||||||
|
remake,
|
||||||
|
`uid`,
|
||||||
|
tenant_id,
|
||||||
|
flag,
|
||||||
|
create_time,
|
||||||
|
update_time,
|
||||||
|
creator,
|
||||||
|
updater,
|
||||||
|
deleted
|
||||||
|
</sql>
|
||||||
|
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="hosts_id" property="hostsId"/>
|
||||||
|
<result column="user_id" property="userId"/>
|
||||||
|
<result column="hosts_level" property="hostsLevel"/>
|
||||||
|
<result column="hosts_coins" property="hostsCoins"/>
|
||||||
|
<result column="invitation_type" property="invitationType"/>
|
||||||
|
<result column="online_fans" property="onlineFans"/>
|
||||||
|
<result column="fans" property="fans"/>
|
||||||
|
<result column="fllowernum" property="fllowernum"/>
|
||||||
|
<result column="yesterday_coins" property="yesterdayCoins"/>
|
||||||
|
<result column="country" property="country"/>
|
||||||
|
<result column="hosts_kind" property="hostsKind"/>
|
||||||
|
<result column="operation_status" property="operationStatus"/>
|
||||||
|
<result column="remake" property="remake"/>
|
||||||
|
<result column="uid" property="uid"/>
|
||||||
|
<result column="tenant_id" property="tenantId"/>
|
||||||
|
<result column="flag" property="flag"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
<result column="creator" property="creator"/>
|
||||||
|
<result column="updater" property="updater"/>
|
||||||
|
<result column="deleted" property="deleted"/>
|
||||||
|
</resultMap>
|
||||||
<insert id="insertIgnore" parameterType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO">
|
<insert id="insertIgnore" parameterType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO">
|
||||||
INSERT IGNORE INTO server_employee_hosts
|
INSERT IGNORE INTO server_employee_hosts
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
@@ -364,4 +412,23 @@
|
|||||||
</if>
|
</if>
|
||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectEmployeeHostsCompleteBarChart"
|
||||||
|
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
|
||||||
|
FROM
|
||||||
|
server_employee_hosts
|
||||||
|
WHERE
|
||||||
|
deleted = 0
|
||||||
|
AND operation_status = 1
|
||||||
|
AND DATE(update_time) = CURDATE()
|
||||||
|
<if test="list != null and list.size() != 0">
|
||||||
|
AND user_id IN
|
||||||
|
<foreach collection="list" item="user_id" open="(" separator="," close=")">
|
||||||
|
#{user_id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user