燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-06-06 4a4179b19501059168bd2d725bf6294708c99ec3
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
<?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.VocValsMapper">
    <resultMap id="selectMap" type="com.yssh.entity.VocVals">
        <id property="id" column="id" />
        <result property="x" column="x" />
        <result property="y" column="y" />
        <result property="val" column="val" />
        <result property="createTime" column="create_time" />
        <result property="addr" column="addr" />
    </resultMap>
 
    <select id="selectByTime" resultMap="selectMap">
        select a.x, a.y, format(a.val, 2) "val", b.addr
        from voc_vals a inner join voc_addr b
        on a.x = b.x and a.y = b.y
        where date_format(a.create_time, '%Y%m%d%H') = ${time}
            and a.val > (select jcyj from alert_config);
    </select>
 
    <select id="countByTime" resultType="java.lang.Integer">
        select count(*)
        from voc_vals
        where date_format(create_time, '%Y%m%d%H') = ${time};
    </select>
 
    <select id="selectCoords" resultType="com.yssh.entity.VocCoords">
        select x, y, addr
        from voc_addr
        <where>
            1 = 1
            <if test="x != null">
                and x = ${x}
            </if>
            <if test="y != null">
                and y = ${y}
            </if>
        </where>
    </select>
 
    <insert id="insert" parameterType="com.yssh.entity.VocVals" useGeneratedKeys="false" keyProperty="id">
        insert into voc_vals (id, x, y, val, create_time) values
        (${id}, ${x}, ${y}, ${val}, ${createTime});
    </insert>
 
    <insert id="inserts" parameterType="com.yssh.entity.VocVals" useGeneratedKeys="false" keyProperty="id">
        insert into voc_vals (id, x, y, val, create_time) values
        <foreach collection="list" item="item" index="index" separator=",">
            (${item.id}, #{item.x},#{item.y},#{item.val},#{item.createTime})
        </foreach>
    </insert>
 
    <delete id="deleteLastYear">
        delete from voc_vals
        where create_time &lt; date_sub(now(), interval 1 year);
    </delete>
 
    <delete id="deleteByTime">
        delete from voc_vals
        where date_format(create_time, '%Y%m%d%H') = ${time};
    </delete>
</mapper>