whycxzp
2025-06-10 73bb5617e6aeb4ee8f7dfd4ad54b61d477969d86
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
<?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.whyc.mapper.DevLithiumAlarmDataMapper">
    <resultMap type="com.whyc.pojo.db_alarm.DevLithiumAlarmData" id="almDev">
        <id column="num" property="num"/>
        <result column="dev_id" property="devId"/>
        <result column="alm_id" property="almId"/>
        <result column="alm_signal_id" property="almSignalId"/>
        <result column="alm_starttime" property="almStarttime"/>
        <result column="alm_value" property="almValue"/>
        <result column="alm_is_confirmed" property="almIsConfirmed"/>
        <result column="confirmed_uid" property="confirmedUid"/>
        <result column="confirmed_time" property="confirmedTime"/>
        <result column="alm_endtime" property="almEndtime"/>
        <result column="alm_cleared_type" property="almClearedType"/>
        <!-- 它是用于指定从表方的引用实体属性的 -->
        <association property="devInf" javaType="DevLithiumInf"
                     select="selectDinf"
                     column="dev_id">
        </association>
    </resultMap>
 
    <select id="getDevAlmInf" resultMap="almDev">
        select * from db_alarm.tb_devalarm_data
        <where>
            <if test="dto.devId!=null">
                and dev_id=#{dto.devId}
            </if>
            <if test="dto.devType!=null">
                and  FLOOR(dev_id/100000000)=#{dto.devType}
            </if>
            <if test="dto.almId!=null">
                and alm_id=#{dto.almId}
            </if>
            <if test="dto.startTime!=null">
                and alm_starttime>=#{dto.startTime}
            </if>
            <if test="dto.endTime!=null">
                and alm_starttime&lt;=#{dto.endTime}
            </if>
            and dev_id in (
            SELECT distinct dev_id from db_user.tb_battgroup_baojigroup,db_user.tb_battgroup_usr
            <where>
                tb_battgroup_baojigroup.baoji_group_id=tb_battgroup_usr.baoji_group_id
                <if test="dto.uid!=null">
                    and uid=#{dto.uid}
                </if>
            </where>
            )
            order by alm_starttime desc
        </where>
    </select>
    <select id="selectDinf" resultType="DevLithiumInf" parameterType="int" >
        select * from db_lithium_ram_db.tb_dev_inf where dev_id = #{dev_id}
    </select>
    <select id="getPopup" resultMap="almDev">
        select * from db_alarm.tb_devalarm_data
        <where>
            alm_is_confirmed=0
            and dev_id in (
            SELECT distinct dev_id from db_user.tb_battgroup_baojigroup,db_user.tb_battgroup_usr
            where
                tb_battgroup_baojigroup.baoji_group_id=tb_battgroup_usr.baoji_group_id
                and uid=#{uid}
            )
        </where>
        order by alm_starttime desc
    </select>
 
</mapper>