燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-11-29 9a8c8a90c7c01b6bc770d4be5baeff72c058468c
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?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.mapper.XlsReportMapper">
    <select id="selectReportCount" resultType="java.lang.Integer">
        select count(*)
        from xls_report
        <where>
            1 = 1
            <if test="type != null">
                and type = #{type}
            </if>
            <if test="start != null">
                and create_time >= #{start}
            </if>
            <if test="end != null">
                and create_time &lt;= #{end}
            </if>
        </where>
    </select>
 
    <!-- 分页查询报告 -->
    <select id="selectReportByPage" resultType="com.yssh.entity.xls.XlsReport">
        select *
        from xls_report
        <where>
            1 = 1
            <if test="type != null">
                and type = #{type}
            </if>
            <if test="start != null">
                and create_time >= #{start}
            </if>
            <if test="end != null">
                and create_time &lt;= #{end}
            </if>
        </where>
        order by create_time desc
        limit #{limit} offset #{offset}
    </select>
 
    <!-- 根据ID查询报告 -->
    <select id="selectById" resultType="com.yssh.entity.xls.XlsReport">
        select *
        from xls_report
        where id = #{id};
    </select>
 
    <!-- 报告是否存在 -->
    <select id="reportExists" resultType="java.lang.Integer">
        select count(*)
        from xls_report
        where type = #{type} and name = #{name}
    </select>
 
    <!-- 插入报告 -->
    <insert id="insertReport" parameterType="com.yssh.entity.xls.XlsReport">
       insert into xls_report
       (name, type, path, create_time)
       values
       (#{name}, #{type}, #{path}, #{createTime})
    </insert>
 
    <!-- 查询日均值 -->
    <select id="selectDayAvg" resultType="java.lang.Double">
        select ifnull(round(avg(value), 2), 0)
        from yssh_qxsh
        where time like #{time} and name = #{name};
    </select>
 
    <!-- 查询累计值 -->
    <select id="selectAccumulate" resultType="java.lang.Double">
        select ifnull(round(avg(value), 2), 0)
        from yssh_qxsh
        where time between #{start} and #{end} and name = #{name};
    </select>
 
    <!-- 查询年累计值 -->
    <select id="selectYearAccumulate" resultType="java.lang.Double">
        select ifnull(round(avg(value), 2), 0)
        from yssh_qxsh
        where time like #{time} and name = #{name};
    </select>
 
    <!-- 根据时间查询溯源 -->
    <select id="selectSuYuanByTime" resultType="com.yssh.entity.SuYuan700">
        select *
        from suyuan_46
        where su_yuan_id = #{id} and create_time between #{start} and #{end}
        order by create_time;
    </select>
 
    <!-- 根据时间段查询溯源 -->
    <select id="selectSuYuanByStartAndEnd" resultType="com.yssh.entity.SuYuan700">
        select *
        from suyuan_46
        where su_yuan_id = #{id} and date_format(create_time, '%Y%m%d%H') in (
            select time
            from yssh_qxsh
            where value > #{yjz} and name = #{name} and time between #{start} and #{end}
        );
    </select>
</mapper>