燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-05-19 da8328c2f9d836b14f08a65f7b29b98fa09283f2
1
已修改3个文件
37 ■■■■ 文件已修改
src/main/java/com/yssh/dao/QxshMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/utils/DateUtils.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapping/QxshMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/dao/QxshMapper.java
@@ -2,6 +2,7 @@
import com.yssh.entity.Qxsh;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -15,4 +16,6 @@
    public List<Qxsh> selectByTime(String time);
    public List<Qxsh> selectMonthTop10(String time);
    public List<Qxsh> select3Hours(@Param("times") List<String> times);
}
src/main/java/com/yssh/utils/DateUtils.java
@@ -3,10 +3,7 @@
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;
@@ -177,6 +174,23 @@
        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;
    }
    
    /**
     */
src/main/resources/mapping/QxshMapper.xml
@@ -9,10 +9,20 @@
    </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>