修改员工导出bug及大屏睡眠人数

This commit is contained in:
wanghao
2026-01-05 15:22:16 +08:00
parent fb699c5227
commit de888296d9
5 changed files with 32 additions and 4 deletions
@@ -5,7 +5,9 @@ import com.renkang.watch.entity.WatchStatUserInfoDaySleep;
import com.renkang.watch.vo.UserData.res.sleep.WatchDataSleepRes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
@@ -28,4 +30,9 @@ public interface WatchStatUserInfoDaySleepMapper extends BaseMapper<WatchStatUse
void insertStat(WatchStatUserInfoDaySleep watchStatUserInfoDaySleep);
void updateStat(WatchStatUserInfoDaySleep watchStatUserInfoDaySleep);
Integer countDistinctUser(@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("orgCode") String orgCode);
}
@@ -43,6 +43,7 @@
and data_date &lt;= DATE(#{endTime})
</select>
<insert id="insertStat">
insert into watch_stat_user_info_day_sleep(id, user_id, long_count, long_duration_max, long_duration_min,
long_duration_total, short_count, short_duration_max, short_duration_min,
@@ -127,4 +128,14 @@
where stat.user_id = #{userId,jdbcType=VARCHAR}
and stat.data_date = #{dataDate,jdbcType=DATE};
</update>
<select id="countDistinctUser" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT user_id)
FROM watch_stat_user_info_day_sleep
WHERE data_date BETWEEN #{startDate} AND #{endDate}
AND user_id IS NOT NULL
<if test="orgCode != null and orgCode != ''">
AND org_code LIKE CONCAT(#{orgCode},'%')
</if>
</select>
</mapper>
@@ -1,5 +1,6 @@
package com.renkang.watch.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
@@ -1053,10 +1054,12 @@ public class WatchDataServiceImpl extends ServiceImpl<WatchDataMapper, WatchData
if (!StrUtil.isNotBlank(dto.getType())) {
ExceptionAssertsUtil.fail("时间不能为空");
}
Date startDate = dateByType(dto.getType(),false);
Date endDate = dateByType(dto.getType(),true);
//调用之前的接口查询柱状图数据
List<BigScreenSleepVo> sleepInfo = getSleep(dto);
//todo 查询存在睡眠数据的人数
vo.setPeopleSum(0);
Integer userCount = watchStatUserInfoDaySleepMapper.countDistinctUser(startDate, endDate, dto.getOrgCode());
vo.setPeopleSum(userCount == null ? 0 : userCount);
vo.setSleepInfo(sleepInfo);
return vo;
}