奥体项目时间粒度修改
正在显示
1 个修改的文件
包含
38 行增加
和
4 行删除
... | @@ -949,7 +949,9 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { | ... | @@ -949,7 +949,9 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { |
949 | if(dataList.size()>0){ | 949 | if(dataList.size()>0){ |
950 | for (Map<String, Object> map:dataList) { | 950 | for (Map<String, Object> map:dataList) { |
951 | EchartResult echartResult = new EchartResult(); | 951 | EchartResult echartResult = new EchartResult(); |
952 | echartResult.setName(map.get("time").toString()); | 952 | String datatime = map.get("time").toString(); |
953 | datatime = datatime.substring(5,16); | ||
954 | echartResult.setName(datatime); | ||
953 | if("p".equals(type)){ | 955 | if("p".equals(type)){ |
954 | if(map.get(wList.get(0).getMonitorId())==null){ | 956 | if(map.get(wList.get(0).getMonitorId())==null){ |
955 | echartResult.setValue(""); | 957 | echartResult.setValue(""); |
... | @@ -962,7 +964,9 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { | ... | @@ -962,7 +964,9 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { |
962 | }else if("f".equals(type)){ | 964 | }else if("f".equals(type)){ |
963 | for (WhatStructData whatStructData:wList) { | 965 | for (WhatStructData whatStructData:wList) { |
964 | EchartResult eResult = new EchartResult(); | 966 | EchartResult eResult = new EchartResult(); |
965 | eResult.setName(map.get("time").toString()); | 967 | String dtime = map.get("time").toString(); |
968 | dtime = dtime.substring(5,16); | ||
969 | eResult.setName(dtime); | ||
966 | if(whatStructData.getMonitorId()==null){ | 970 | if(whatStructData.getMonitorId()==null){ |
967 | eResult.setValue(""); | 971 | eResult.setValue(""); |
968 | }else{ | 972 | }else{ |
... | @@ -1593,7 +1597,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { | ... | @@ -1593,7 +1597,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { |
1593 | String timeType = inputQueryParams.getTimeType(); | 1597 | String timeType = inputQueryParams.getTimeType(); |
1594 | if("today".equals(timeType)){ | 1598 | if("today".equals(timeType)){ |
1595 | timeStep = "hour"; | 1599 | timeStep = "hour"; |
1596 | start = endDate + " 00:00:00"; | 1600 | start = get24DateTime(new Date()); |
1597 | end = endDate + " 23:59:59"; | 1601 | end = endDate + " 23:59:59"; |
1598 | }else if("week".equals(timeType)){ | 1602 | }else if("week".equals(timeType)){ |
1599 | timeStep = "hour"; | 1603 | timeStep = "hour"; |
... | @@ -1638,6 +1642,13 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { | ... | @@ -1638,6 +1642,13 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { |
1638 | for (Map.Entry<String, Object> entry : bmap.entrySet()) { | 1642 | for (Map.Entry<String, Object> entry : bmap.entrySet()) { |
1639 | if("time".equals(entry.getKey())){ | 1643 | if("time".equals(entry.getKey())){ |
1640 | time = entry.getValue().toString(); | 1644 | time = entry.getValue().toString(); |
1645 | if("today".equals(timeType)){ | ||
1646 | time = time.substring(11,16); | ||
1647 | }else if("week".equals(timeType)){ | ||
1648 | time = time.substring(5,16); | ||
1649 | }else{ | ||
1650 | time = time.substring(5,10); | ||
1651 | } | ||
1641 | } | 1652 | } |
1642 | } | 1653 | } |
1643 | for (Map.Entry<String, Object> entry : bmap.entrySet()) { | 1654 | for (Map.Entry<String, Object> entry : bmap.entrySet()) { |
... | @@ -1658,6 +1669,13 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { | ... | @@ -1658,6 +1669,13 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { |
1658 | for (Map.Entry<String, Object> entry : bmap.entrySet()) { | 1669 | for (Map.Entry<String, Object> entry : bmap.entrySet()) { |
1659 | if("time".equals(entry.getKey())){ | 1670 | if("time".equals(entry.getKey())){ |
1660 | time = entry.getValue().toString(); | 1671 | time = entry.getValue().toString(); |
1672 | if("today".equals(timeType)){ | ||
1673 | time = time.substring(11,16); | ||
1674 | }else if("week".equals(timeType)){ | ||
1675 | time = time.substring(5,16); | ||
1676 | }else{ | ||
1677 | time = time.substring(5,10); | ||
1678 | } | ||
1661 | } | 1679 | } |
1662 | } | 1680 | } |
1663 | for (Map.Entry<String, Object> entry : bmap.entrySet()) { | 1681 | for (Map.Entry<String, Object> entry : bmap.entrySet()) { |
... | @@ -1677,6 +1695,22 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { | ... | @@ -1677,6 +1695,22 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { |
1677 | return map; | 1695 | return map; |
1678 | } | 1696 | } |
1679 | 1697 | ||
1698 | public String get24DateTime(Date currentDate){ | ||
1699 | // 创建 Calendar 对象,并设置为当前时间 | ||
1700 | Calendar calendar = Calendar.getInstance(); | ||
1701 | calendar.setTime(currentDate); | ||
1702 | // 往前推 24 小时 | ||
1703 | calendar.add(Calendar.HOUR_OF_DAY, -24); | ||
1704 | // 获取推算后的时间 | ||
1705 | Date previousDate = calendar.getTime(); | ||
1706 | // 格式化时间为 "yyyy-MM-dd" 形式 | ||
1707 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
1708 | String formattedDate = dateFormat.format(previousDate); | ||
1709 | // System.out.println("当前时间: " + dateFormat.format(currentDate)); | ||
1710 | // System.out.println("往前 24 小时的时间: " + formattedDate); | ||
1711 | return formattedDate; | ||
1712 | } | ||
1713 | |||
1680 | @Override | 1714 | @Override |
1681 | public List<EchartResult> getHistoryTrendsByDate(InputQueryParams inputQueryParams) { | 1715 | public List<EchartResult> getHistoryTrendsByDate(InputQueryParams inputQueryParams) { |
1682 | List<EchartResult> list = new ArrayList<>(); | 1716 | List<EchartResult> list = new ArrayList<>(); |
... | @@ -1700,7 +1734,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { | ... | @@ -1700,7 +1734,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService { |
1700 | String timeType = inputQueryParams.getTimeType(); | 1734 | String timeType = inputQueryParams.getTimeType(); |
1701 | if("today".equals(timeType)){ | 1735 | if("today".equals(timeType)){ |
1702 | timeStep = "hour"; | 1736 | timeStep = "hour"; |
1703 | start = endDate + " 00:00:00"; | 1737 | start = get24DateTime(new Date()); |
1704 | end = endDate + " 23:59:59"; | 1738 | end = endDate + " 23:59:59"; |
1705 | }else if("week".equals(timeType)){ | 1739 | }else if("week".equals(timeType)){ |
1706 | timeStep = "hour"; | 1740 | timeStep = "hour"; | ... | ... |
-
请 注册 或 登录 后发表评论