Commit 4183b965 by 汪志阳

fix:睡眠时间计算

parent 97525de9
...@@ -12,7 +12,7 @@ import java.util.TreeMap; ...@@ -12,7 +12,7 @@ import java.util.TreeMap;
* @description * @description
* @createDate 2024-01-24-16:38 * @createDate 2024-01-24-16:38
*/ */
public interface TestLogService { public interface DeviceLogService {
void save(Map<String, List<DeviceInfoContentBreathe>> minuteMap); void save(Map<String, List<DeviceInfoContentBreathe>> minuteMap);
...@@ -20,5 +20,5 @@ public interface TestLogService { ...@@ -20,5 +20,5 @@ public interface TestLogService {
TreeMap<String, AnalysisVO> getData(); TreeMap<String, AnalysisVO> getData();
void fillDefaultData(TreeMap<String, AnalysisVO> statisticsMap); void fillDefaultData(TreeMap<String, AnalysisVO> statisticsMap,Integer month, Integer day);
} }
...@@ -9,7 +9,7 @@ import com.makeit.exception.BusinessException; ...@@ -9,7 +9,7 @@ import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.auth.PlatOrgMapper; import com.makeit.mapper.platform.auth.PlatOrgMapper;
import com.makeit.module.iot.vo.analysis.AnalysisVO; import com.makeit.module.iot.vo.analysis.AnalysisVO;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe; import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.service.platform.elder.TestLogService; import com.makeit.service.platform.elder.DeviceLogService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -26,7 +26,7 @@ import java.util.stream.Collectors; ...@@ -26,7 +26,7 @@ import java.util.stream.Collectors;
* @createDate 2024-01-24-16:38 * @createDate 2024-01-24-16:38
*/ */
@Service @Service
public class TestLogServiceImpl implements TestLogService { public class DeviceLogServiceImpl implements DeviceLogService {
@Resource @Resource
private PlatOrgMapper platOrgMapper; private PlatOrgMapper platOrgMapper;
...@@ -80,7 +80,7 @@ public class TestLogServiceImpl implements TestLogService { ...@@ -80,7 +80,7 @@ public class TestLogServiceImpl implements TestLogService {
TreeMap<String, AnalysisVO> result = new TreeMap<>(); TreeMap<String, AnalysisVO> result = new TreeMap<>();
collect1.forEach(result::put); collect1.forEach(result::put);
getDayMinute().forEach(minute -> { getDayMinute(1,10).forEach(minute -> {
boolean key = result.containsKey(minute); boolean key = result.containsKey(minute);
if (!key) { if (!key) {
AnalysisVO analysisVO = buildDefaultData(minute); AnalysisVO analysisVO = buildDefaultData(minute);
...@@ -91,9 +91,9 @@ public class TestLogServiceImpl implements TestLogService { ...@@ -91,9 +91,9 @@ public class TestLogServiceImpl implements TestLogService {
} }
public static List<String> getDayMinute() { public static List<String> getDayMinute(Integer month, Integer day) {
List<String> list = Lists.newArrayList(); List<String> list = Lists.newArrayList();
LocalDateTime now = LocalDateTime.of(2024, 1, 9, 8, 0); LocalDateTime now = LocalDateTime.of(2024, month, day - 1, 8, 0);
for (int i = 0; i < 24; i++) { for (int i = 0; i < 24; i++) {
int hour = now.getHour(); int hour = now.getHour();
for (int j = 0; j < 60; j++) { for (int j = 0; j < 60; j++) {
...@@ -107,8 +107,8 @@ public class TestLogServiceImpl implements TestLogService { ...@@ -107,8 +107,8 @@ public class TestLogServiceImpl implements TestLogService {
@Override @Override
public void fillDefaultData(TreeMap<String, AnalysisVO> statisticsMap) { public void fillDefaultData(TreeMap<String, AnalysisVO> statisticsMap, Integer month, Integer day) {
List<String> dayMinute = getDayMinute(); List<String> dayMinute = getDayMinute(month, day);
dayMinute.forEach(minute -> { dayMinute.forEach(minute -> {
boolean key = statisticsMap.containsKey(minute); boolean key = statisticsMap.containsKey(minute);
if (!key) { if (!key) {
......
...@@ -57,8 +57,7 @@ ...@@ -57,8 +57,7 @@
</insert> </insert>
<select id="getData" resultType="com.makeit.module.iot.vo.analysis.AnalysisVO"> <select id="getData" resultType="com.makeit.module.iot.vo.analysis.AnalysisVO">
select * from device_minute_info where created_time >= '2024-01-09 23:40' select * from device_minute_info where device_id = '1732647368962203650' order by created_time
and created_time &lt; '2024-01-10 08:00' and device_id = '1732647368962203650' order by created_time
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment