whycxzp
2025-03-19 2b610635b0da111bb7349a2248b76b5786307c31
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
82
83
84
85
86
87
<?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.BattLithiumTestDataInfMapper">
    <resultMap id="staticTinf" type="BattLithiumTestDataInf">
        <id property="num" column="num"></id>
        <result property="devId" column="dev_id"></result>
        <result property="testType" column="test_type"></result>
        <result property="devType" column="dev_type"></result>
    </resultMap>
    <select id="getDevTinf" resultMap="staticTinf">
        select num,dev_id,test_type,floor(dev_id/100000000) as dev_type from db_lithium_testdata.tb_batttestdata_inf
        <where>
            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="uid!=null">
                    and uid=#{uid}
                </if>
            </where>
            )
        </where>
    </select>
    <select id="getDevTinfByYear" resultMap="staticTinf">
        select num,dev_id,test_type,floor(dev_id/100000000) as dev_type from db_lithium_testdata.tb_batttestdata_inf
        <where>
            EXTRACT (YEAR from test_starttime)= EXTRACT (YEAR from NOW())
            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="uid!=null">
                    and uid=#{uid}
                </if>
            </where>
            )
        </where>
    </select>
    <select id="getDevTinfByMonth" resultMap="staticTinf">
        select num,dev_id,test_type,floor(dev_id/100000000) as dev_type from db_lithium_testdata.tb_batttestdata_inf
        <where>
            DATE_FORMAT(test_starttime,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
            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="uid!=null">
                    and uid=#{uid}
                </if>
            </where>
            )
        </where>
    </select>
    <resultMap id="staticTinfWeek" type="BattLithiumTestDataInf">
        <id property="num" column="num"></id>
        <result property="devId" column="dev_id"></result>
        <result property="testType" column="test_type"></result>
        <result property="devType" column="dev_type"></result>
        <result property="weekDay" column="week_day"></result>
    </resultMap>
    <select id="getDevTinfByWeek"  resultMap="staticTinfWeek">
        select num,dev_id,test_type,floor(dev_id/100000000) as dev_type,DATE_FORMAT(test_starttime, '%Y-%m-%d') AS week_day
        from db_lithium_testdata.tb_batttestdata_inf
        <where>
            DATE_SUB(CURDATE(), INTERVAL 6 DAY) &lt;= DATE(test_starttime)
            and floor(dev_id/100000000)=#{type}
            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="uid!=null">
                    and uid=#{uid}
                </if>
            </where>
            )
        </where>
    </select>
    <select id="getTinfById" resultType="com.whyc.pojo.db_lithium_testdata.BattLithiumTestDataInf">
        select *
        from db_lithium_testdata.tb_batttestdata_inf
        <where>
        and test_type=#{type}
        and dev_id=#{devId}
        </where>
        order by test_starttime desc
    </select>
</mapper>