e1e02a5c 张雷

奥体项目时间粒度修改

1 个父辈 af6e5325
......@@ -949,7 +949,9 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
if(dataList.size()>0){
for (Map<String, Object> map:dataList) {
EchartResult echartResult = new EchartResult();
echartResult.setName(map.get("time").toString());
String datatime = map.get("time").toString();
datatime = datatime.substring(5,16);
echartResult.setName(datatime);
if("p".equals(type)){
if(map.get(wList.get(0).getMonitorId())==null){
echartResult.setValue("");
......@@ -962,7 +964,9 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}else if("f".equals(type)){
for (WhatStructData whatStructData:wList) {
EchartResult eResult = new EchartResult();
eResult.setName(map.get("time").toString());
String dtime = map.get("time").toString();
dtime = dtime.substring(5,16);
eResult.setName(dtime);
if(whatStructData.getMonitorId()==null){
eResult.setValue("");
}else{
......@@ -1593,7 +1597,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
String timeType = inputQueryParams.getTimeType();
if("today".equals(timeType)){
timeStep = "hour";
start = endDate + " 00:00:00";
start = get24DateTime(new Date());
end = endDate + " 23:59:59";
}else if("week".equals(timeType)){
timeStep = "hour";
......@@ -1638,6 +1642,13 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
for (Map.Entry<String, Object> entry : bmap.entrySet()) {
if("time".equals(entry.getKey())){
time = entry.getValue().toString();
if("today".equals(timeType)){
time = time.substring(11,16);
}else if("week".equals(timeType)){
time = time.substring(5,16);
}else{
time = time.substring(5,10);
}
}
}
for (Map.Entry<String, Object> entry : bmap.entrySet()) {
......@@ -1658,6 +1669,13 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
for (Map.Entry<String, Object> entry : bmap.entrySet()) {
if("time".equals(entry.getKey())){
time = entry.getValue().toString();
if("today".equals(timeType)){
time = time.substring(11,16);
}else if("week".equals(timeType)){
time = time.substring(5,16);
}else{
time = time.substring(5,10);
}
}
}
for (Map.Entry<String, Object> entry : bmap.entrySet()) {
......@@ -1677,6 +1695,22 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
return map;
}
public String get24DateTime(Date currentDate){
// 创建 Calendar 对象,并设置为当前时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate);
// 往前推 24 小时
calendar.add(Calendar.HOUR_OF_DAY, -24);
// 获取推算后的时间
Date previousDate = calendar.getTime();
// 格式化时间为 "yyyy-MM-dd" 形式
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedDate = dateFormat.format(previousDate);
// System.out.println("当前时间: " + dateFormat.format(currentDate));
// System.out.println("往前 24 小时的时间: " + formattedDate);
return formattedDate;
}
@Override
public List<EchartResult> getHistoryTrendsByDate(InputQueryParams inputQueryParams) {
List<EchartResult> list = new ArrayList<>();
......@@ -1700,7 +1734,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
String timeType = inputQueryParams.getTimeType();
if("today".equals(timeType)){
timeStep = "hour";
start = endDate + " 00:00:00";
start = get24DateTime(new Date());
end = endDate + " 23:59:59";
}else if("week".equals(timeType)){
timeStep = "hour";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!