燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-06-09 498718ad129e8a9010e6f2af2fde2f9d4508fd32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yssh.dao.WarningDetailMapper">
    
    <resultMap id="WarningDetailResult" type="com.yssh.entity.WarningDetail">
        <id property="id"    column="id"    />
        <result property="tableName"    column="table_name"    />
        <result property="suYuanId"    column="su_yuan_id"    />
        <result property="locationName"    column="location_name"    />
        <result property="type"    column="type"    />
        <result property="createTime"    column="create_time"    />
        <result property="value"    column="value"    />
    </resultMap>
    
    <resultMap id="WarningVoResult" type="com.yssh.entity.vo.WarningVo">
        <result property="location_name"    column="locationName"    />
        <result property="suYuanId"    column="su_yuan_id"    />
        <result property="value"    column="value"    />
    </resultMap>
    
    <select id="selectWarningDetailByType" resultMap="WarningVoResult">
        SELECT location_name, su_yuan_id, value
        FROM warning_detail
        WHERE date_format(create_time, '%Y%m%d%H%I') &gt;= date_format(NOW(), '%Y%m%d%H%I')
        AND type = #{type}
    </select>
    
    <select id="selectWarningDetailByMap_old" parameterType="java.util.Map" resultMap="WarningVoResult">
        SELECT location_name, su_yuan_id, value
        FROM warning_detail
        WHERE date_format(create_time, '%Y%m%d%H%I%S') &gt;= date_format(#{startTime}, '%Y%m%d%H%I%S')
        AND date_format(create_time, '%Y%m%d%H%I%S') &lt;= date_format(#{endTime}, '%Y%m%d%H%I%S')
        AND type = #{type}
    </select>
 
    <select id="selectWarningDetailByMap" parameterType="java.util.Map" resultMap="WarningVoResult">
        select location_name, su_yuan_id, value
        from warning_detail
        where create_time between #{startTime} and #{endTime} and type = #{type};
    </select>
 
    <select id="selectWarningDayCountByMap_old" parameterType="java.util.Map" resultType="java.util.Map">
        SELECT date_format(create_time,'%Y%m%d') AS createTime, count(id) AS num
        FROM warning_detail
        WHERE date_format(create_time, '%Y%m%d%H%I%S') &gt;= date_format(#{startTime}, '%Y%m%d%H%I%S')
        AND date_format(create_time, '%Y%m%d%H%I%S') &lt;= date_format(#{endTime}, '%Y%m%d%H%I%S')
        AND type = #{type}
        GROUP BY DATE_FORMAT(create_time,'%Y%m%d%')
        ORDER BY create_time ASC
    </select>
    
    <select id="selectWarningDayCountByMap" parameterType="java.util.Map" resultType="java.util.Map">
        with rs as (
              select date_format(create_time, '%Y%m%d') AS ct, id, type
              from warning_detail
              where create_time between #{startTime} and #{endTime} and type = #{type}
        )
        select ct as createTime, count(id) as num
        from rs
        group by ct
        order by ct asc;
    </select>
    
    <insert id="batchInsert">
        INSERT INTO warning_detail (table_name, su_yuan_id, location_name, type, create_time, value)VALUES
        <foreach collection="datas" item="item" separator=",">
            (
                #{item.tableName}, 
                #{item.suYuanId}, 
                #{item.locationName}, 
                #{item.type},
                #{item.createTime},
                #{item.value}
            )
        </foreach>
    </insert>
 
 
</mapper>