YYC
2023-06-19 589c4d5ba3b5477164cbd07aefca2438303e598a
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?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.ld.igds.phone35.mapper.Phone35Mapper">
 
    <!-- 根据仓库获取气体信息 -->
    <select id="getGasByDepot" resultType="com.ld.igds.phone35.dto.DtoPhoneGas" parameterType="java.lang.String">
        SELECT
        d.ID_ as depotId,
        d.NAME_ as depotName,
        g.PER_CO2_ as perCo2,
        g.PER_O2_ as perO2,
        g.PER_PH3_ as perPh3,
        g.PER_N2_ as perN2,
        g.RECEIVE_DATE_ as receiveDate,
        g.CHECK_USER_ as checkUser
        FROM d_depot d
        LEFT JOIN
        (SELECT * FROM(SELECT DISTINCT * from d_gas ORDER BY RECEIVE_DATE_ DESC) a GROUP BY DEPOT_ID_) g
        ON d.ID_ = g.DEPOT_ID_
        WHERE
        d.COMPANY_ID_ = #{companyId}
        <if test="deptId != null and deptId != ''">AND d.DEPT_ID_ = #{deptId}</if>
        ORDER BY d.ID_
    </select>
 
    <!-- 根据仓库获取虫害信息 -->
    <select id="getPestByDepot" resultType="com.ld.igds.phone35.dto.DtoPhonePest" parameterType="java.lang.String">
        SELECT
        d.ID_ as depotId,
        d.NAME_ as depotName,
        d.DEPOT_STATUS_ as depotStatus,
        g.PEST_MAX_ as pestNum,
        g.REMARK_ as isPest,
        g.RECEIVE_DATE_ as receiveDate
        FROM d_depot d
        LEFT JOIN
        (SELECT * FROM(SELECT DISTINCT * from d_pest ORDER BY RECEIVE_DATE_ DESC) a GROUP BY DEPOT_ID_) g
        ON d.ID_ = g.DEPOT_ID_
        WHERE
        d.COMPANY_ID_ = #{companyId}
        <if test="deptId != null and deptId != ''">AND d.DEPT_ID_ = #{deptId}</if>
        ORDER BY d.ID_
    </select>
    <!--实时配电-->
    <select id="getRealEnergyByDept" resultType="com.ld.igds.phone35.dto.Dto5501" parameterType="java.lang.String">
        SELECT d.ID_ as depotId,
        d.NAME_ as depotName,
        d.DEPOT_TYPE_ as depotType,
        e.UA_ as ua,
        e.UB_ as ub,
        e.UC_ as uc,
        e.IA_ as ia,
        e.IB_ as ib,
        e.IC_ as ic,
        e.UPDATE_TIME_ as updateTime
        FROM d_depot d
        LEFT JOIN d_energy e
        ON d.ID_ = e.DEPOT_ID_
        WHERE d.COMPANY_ID_ = #{companyId}
        <if test="deptId != null and deptId != ''">AND d.DEPT_ID_ = #{deptId}</if>
        ORDER BY d.ID_
    </select>
    <!--警告记录-->
    <select id="getWarnByDept" resultType="com.ld.igds.phone35.dto.DtoWarn"
            parameterType="com.ld.igds.phone35.param.Phone35DepotCommonParam">
        SELECT w.ID_ as id,
        w.NAME_ as name,
        w.TYPE_ as type,
        w.BIZ_TYPE_ as bizType,
        w.LEVEL_ as level,
        w.STATUS_ as status,
        w.TIME_ as `time`,
        w.INFO_ as info,
        w.DEPOT_ID_ as depotId,
        w.REMARK_ as remark
        FROM D_M_WARN_INFO w
        WHERE w.COMPANY_ID_ = #{param.companyId}
        <if test="param.deptId != null and param.deptId != ''">AND w.DEPT_ID_ = #{param.deptId}</if>
        <if test="param.startTime != null and param.endTime != null">AND w.TIME_ between #{param.startTime} and
            #{param.endTime}
        </if>
    </select>
    <!--警告处理-->
    <update id="updateWarn">
        UPDATE D_M_WARN_INFO
        <set>
            <if test="param.status != null and param.status != ''">STATUS_ = #{param.status},</if>
            <if test="param.remark != null and param.remark != ''">REMARK_ = #{param.remark},</if>
            <if test="param.completeUser != null and param.completeUser != ''">COMPLETE_USER_ = #{param.completeUser},
            </if>
        </set>
        WHERE ID_ = #{param.id}
    </update>
    <!--远程抄表-->
    <select id="getMeter" resultType="com.ld.igds.phone35.dto.DtoEnergy">
        SELECT EP_INC_ AS epSum,
        EQ_INC_ AS eqSum,
        ES_INC_ AS esSum,
        DEPOT_ID_ AS depotId,
        UPDATE_TIME_ AS updateTime
        FROM D_ENERGY
        <where>
            <if test="param.companyId != null and param.companyId != ''">AND COMPANY_ID_ = #{param.companyId}</if>
            <if test="param.startTime != null and param.endTime != null">AND UPDATE_TIME_ between #{param.startTime}
                and
                #{param.endTime}
            </if>
        </where>
        ORDER BY UPDATE_TIME_ desc
    </select>
    <!-- 仓库能耗查询-->
    <select id="getEnergy" resultType="com.ld.igds.phone35.dto.DtoEnergy">
        SELECT EP_INC_ AS epSum,
        EQ_INC_ AS eqSum,
        ES_INC_ AS esSum,
        ES_ AS es,
        DEPOT_ID_ AS depotId,
        UPDATE_TIME_ AS updateTime
        FROM D_ENERGY
        <where>
            <if test="param.companyId != null and param.companyId != ''">AND COMPANY_ID_ = #{param.companyId}</if>
            <if test="param.depotId != null and param.depotId != ''">AND DEPOT_ID_ = #{param.depotId}</if>
            <if test="param.startTime != null">AND
                UPDATE_TIME_ <![CDATA[ > ]]>#{param.startTime,jdbcType=TIMESTAMP}
            </if>
            <if test="param.endTime != null">AND
                UPDATE_TIME_ <![CDATA[ < ]]>#{param.endTime,jdbcType=TIMESTAMP}
            </if>
        </where>
        ORDER BY UPDATE_TIME_ desc
    </select>
    <!-- 电子巡更记录-->
    <select id="getPatrol" resultType="com.ld.igds.phone35.dto.DtoPatrol">
        SELECT ID_ AS id,
        USER_NAME_ AS userName,
        LONGITUDE_ As longitude,
        LATITUDE_ AS latitude,
        IMG_NAME_ AS imgName,
        CREATE_TIME_ AS createTime
        FROM D_SEC_PATROL_RECORD
        <where>
            <if test="param.id != null and param.id != ''">AND ID_ = #{param.id}</if>
            <if test="param.companyId != null and param.companyId != ''">AND COMPANY_ID_ = #{param.companyId}</if>
            <if test="param.deptId != null and param.deptId != ''">AND DEPT_ID_ = #{param.deptId}</if>
            <if test="param.startTime != null and param.endTime != null">AND CREATE_TIME_ between #{param.startTime}
                and #{param.endTime}
            </if>
        </where>
    </select>
 
    <insert id="addPatrolRecord">
        INSERT INTO D_SEC_PATROL_RECORD
        (ID_,
         COMPANY_ID_,
         DEPT_ID_,
         USER_NAME_,
         CREATE_TIME_,
         LONGITUDE_,
         LATITUDE_,
         IMG_NAME_)
        VALUES (#{param.id},
                #{param.companyId},
                #{param.deptId},
                #{param.userName},
                #{param.createTime},
                #{param.longitude},
                #{param.latitude},
                #{param.imgName})
    </insert>
    <!--    监控设备列表-->
    <select id="getCamera" resultType="com.ld.igds.phone35.dto.DtoVideo">
 
        SELECT ID_        AS id,
               TYPE_      AS type,
               PLAY_TYPE_ AS playType,
               NAME_      AS name
        FROM D_SEC_CAMERA
        WHERE COMPANY_ID_ = #{param.companyId}
          AND DEPT_ID_ = #{param.deptId}
    </select>
</mapper>