工作日志统计记录-按用户分组查询优化
优化了工作日志统计记录的查询逻辑,按用户分组时不再依赖特定的姓名和部门名称字段。重构了数据库映射, 将查询结果映射为更通用的LogStatisticsDetailsVO对象,从而提高了代码的复用性和维护性。
This commit is contained in:
parent
abef64022e
commit
82fab6cf68
@ -7,10 +7,4 @@ import lombok.Data;
|
||||
@Data
|
||||
public class LogStatisticsGroupByUserVO extends LogStatisticsDetailsVO {
|
||||
|
||||
@Schema(description = "姓名")
|
||||
private String nickName;
|
||||
|
||||
@Schema(description = "部门名称")
|
||||
private String deptName;
|
||||
|
||||
}
|
||||
|
@ -91,5 +91,5 @@ public interface LogStatisticsMapper extends BaseMapperX<LogStatisticsDO> {
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<LogStatisticsGroupByUserVO> getStatisticsGroupByUser(@Param("dto") LogStatisticsDetailsListGroupByUserDTO dto);
|
||||
List<LogStatisticsDetailsVO> getStatisticsGroupByUser(@Param("dto") LogStatisticsDetailsListGroupByUserDTO dto);
|
||||
}
|
||||
|
@ -407,12 +407,12 @@ public class LogStatisticsServiceImpl implements LogStatisticsService {
|
||||
}
|
||||
dto.setDateList(dateList);
|
||||
// 获取到所有数据 然后在java代码中分组
|
||||
List<LogStatisticsGroupByUserVO> vos = logStatisticsMapper.getStatisticsGroupByUser(dto);
|
||||
List<LogStatisticsDetailsVO> vos = logStatisticsMapper.getStatisticsGroupByUser(dto);
|
||||
// 根据用户id/部门id分组
|
||||
Map<String, List<LogStatisticsGroupByUserVO>> map = vos.stream().collect(Collectors.groupingBy(a -> a.getUserId() + "_" + a.getDeptId() + "_" + a.getType()));
|
||||
for (Map.Entry<String, List<LogStatisticsGroupByUserVO>> entry : map.entrySet()) {
|
||||
Map<String, List<LogStatisticsDetailsVO>> map = vos.stream().collect(Collectors.groupingBy(a -> a.getUserId() + "_" + a.getDeptId() + "_" + a.getType()));
|
||||
for (Map.Entry<String, List<LogStatisticsDetailsVO>> entry : map.entrySet()) {
|
||||
LogStatisticsDetailsListGroupByUserVO vo = new LogStatisticsDetailsListGroupByUserVO();
|
||||
vo.setNickName(entry.getValue().get(0).getNickName());
|
||||
vo.setNickName(entry.getValue().get(0).getNickname());
|
||||
vo.setDeptName(entry.getValue().get(0).getDeptName());
|
||||
vo.setType(entry.getValue().get(0).getType());
|
||||
vo.setShould(entry.getValue().size());
|
||||
|
@ -152,7 +152,7 @@
|
||||
</where>
|
||||
</select>
|
||||
<select id="getStatisticsGroupByUser"
|
||||
resultType="cn.iocoder.yudao.module.system.controller.admin.worklog.vo.statisticsrecord.LogStatisticsGroupByUserVO">
|
||||
resultType="cn.iocoder.yudao.module.system.controller.admin.worklog.vo.statistics.LogStatisticsDetailsVO">
|
||||
SELECT
|
||||
a.nickname as nickName,
|
||||
c.`name` as deptName,
|
||||
|
Loading…
Reference in New Issue
Block a user