| | |
| | | |
| | | import com.yssh.entity.Qxsh; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | public List<Qxsh> selectByTime(String time); |
| | | |
| | | public List<Qxsh> selectMonthTop10(String time); |
| | | |
| | | public List<Qxsh> select3Hours(@Param("times") List<String> times); |
| | | } |
| | |
| | | import java.lang.management.ManagementFactory; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | |
| | |
| | | calendar.add(dateType, day); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | public static List<String> get3Hours() { |
| | | List<String> times = new ArrayList<>(); |
| | | SimpleDateFormat ymdh = new SimpleDateFormat(YYYYMMDDHH); |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.HOUR_OF_DAY, 1); |
| | | |
| | | for (int i = 0; i < 3; i++) { |
| | | calendar.add(Calendar.HOUR_OF_DAY, -1); |
| | | String time = ymdh.format(calendar.getTime()); |
| | | // times.add(time); |
| | | times.add(0, time); |
| | | } |
| | | |
| | | return times; |
| | | } |
| | | |
| | | /** |
| | | */ |
| | |
| | | </select> |
| | | |
| | | <select id="selectMonthTop10" resultType="com.yssh.entity.Qxsh"> |
| | | select id, name, format(value, 2) "value", time |
| | | select id, name, format(value, 3) "value", time |
| | | from yssh_qxsh |
| | | where time like #{time} and name like 'AI-%' |
| | | order by value desc |
| | | limit 10; |
| | | </select> |
| | | |
| | | <select id="select3Hours" resultType="com.yssh.entity.Qxsh"> |
| | | select id, name, format(value, 3) "value", time |
| | | from yssh_qxsh |
| | | where name like 'AI-%' and time in |
| | | <foreach collection="times" item="time" open="(" separator="," close=")"> |
| | | #{time} |
| | | </foreach> |
| | | order by name, time; |
| | | </select> |
| | | </mapper> |