|
@@ -1,6 +1,8 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ruoyi.common.exception.base.BaseException;
|
|
|
import com.ruoyi.system.domain.*;
|
|
@@ -8,11 +10,15 @@ import com.ruoyi.system.dto.SiteRealTimeDTO;
|
|
|
import com.ruoyi.system.mapper.*;
|
|
|
import com.ruoyi.system.service.ReportDataService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -47,6 +53,9 @@ public class ReportDataServiceImpl implements ReportDataService {
|
|
|
@Resource
|
|
|
private TaskResultMapper taskResultMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BerthingTimeConfigMapper berthingTimeConfigMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public CarPosition carLocation(Long siteId){
|
|
|
return carPositionMapper.queryBysiteId(siteId);
|
|
@@ -69,9 +78,45 @@ public class ReportDataServiceImpl implements ReportDataService {
|
|
|
}
|
|
|
siteRealTimeDTO.setSiteName(siteInfo.getSiteName());
|
|
|
//查询状态
|
|
|
+ TaskResult taskResult = taskResultMapper.queryBySiteIdOne(siteId);
|
|
|
+ if (taskResult == null){
|
|
|
+ siteRealTimeDTO.setSiteStatus(null);
|
|
|
+ siteRealTimeDTO.setNextTime(null);
|
|
|
+ }else {
|
|
|
+ siteRealTimeDTO.setSiteStatus(taskResult.getStatus()==0?"1":"0");
|
|
|
+ //计算下次测量时间 取当前水位匹配测流时间策略
|
|
|
+ WaterLevel waterLevel = waterLevelMapper.queryBySiteId(siteId);
|
|
|
+ if (waterLevel == null){
|
|
|
+ siteRealTimeDTO.setNextTime(null);
|
|
|
+ }else {
|
|
|
+ //查询测流时间策略
|
|
|
+ BerthingTimeConfig berthingTimeConfig = berthingTimeConfigMapper.queryByWlevel(waterLevel.getWaterlevel());
|
|
|
+ if (berthingTimeConfig == null){
|
|
|
+ siteRealTimeDTO.setNextTime(null);
|
|
|
+ }else {
|
|
|
+ // 当前时间
|
|
|
+ LocalTime currentTime = LocalTime.now();
|
|
|
+ //计算下次测量时间
|
|
|
+ JSONArray timeSlots = JSONUtil.parseArray(berthingTimeConfig.getTimes());
|
|
|
+ List<LocalTime> parsedTimeSlots = timeSlots.stream()
|
|
|
+ .map(ReportDataServiceImpl::parseTime)
|
|
|
+ .toList();
|
|
|
+
|
|
|
+ // 查找当前时间之后的第一个时间段
|
|
|
+ LocalTime nextTimeSlot = parsedTimeSlots.stream()
|
|
|
+ .filter(time -> time.isAfter(currentTime))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (nextTimeSlot != null) {
|
|
|
+ System.out.println("下一个时间是: " + nextTimeSlot.format(DateTimeFormatter.ofPattern("HH:mm")));
|
|
|
+ } else {
|
|
|
+ System.out.println("没有找到下一个时间,所有时间都已过去");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- //计算下次测量时间
|
|
|
-
|
|
|
+ }
|
|
|
return siteRealTimeDTO;
|
|
|
}
|
|
|
|
|
@@ -107,5 +152,9 @@ public class ReportDataServiceImpl implements ReportDataService {
|
|
|
return measureUploadMapper.queryBySiteIdTime(siteId,createTime);
|
|
|
}
|
|
|
|
|
|
+ private static LocalTime parseTime(Object timeStr) {
|
|
|
+ return LocalTime.parse(timeStr.toString(), DateTimeFormatter.ofPattern("HH:mm"));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|