ustcyc
2025-01-07 de5d55508afd27fb2b47e6d4d6fd9984525c222c
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?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.zhitan.basicdata.mapper.MeterImplementMapper">
 
    <resultMap type="MeterImplement" id="MeterImplementResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="meterName"    column="meter_name"    />
        <result property="meterType"    column="meter_type"    />
        <result property="modelNumber"    column="model_number"    />
        <result property="measureRange"    column="measure_range"    />
        <result property="manufacturer"    column="manufacturer"    />
        <result property="personCharge"    column="person_charge"    />
        <result property="installactionLocation"    column="installaction_location"    />
        <result property="startTime"    column="start_time"    />
        <result property="checkCycle"    column="check_cycle"    />
        <result property="reminderCycle"    column="reminder_cycle"    />
        <result property="meterStatus"    column="meter_status"    />
        <result property="delFlage"    column="del_flage"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="txflage"    column="txflage"    />
        <result property="putrunTime"    column="putrun_time"    />
        <result property="wireDiameter"    column="wire_diameter"    />
        <result property="maxAllowablePower"    column="max_allowable_power"    />
        <result property="gatewayId"    column="gateway_id"    />
        <result property="gatewayName"    column="gateway_name"    />
    </resultMap>
    <resultMap type="MeterImplementExcel" id="MeterImplementResultExcel">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="meterName"    column="meter_name"    />
        <result property="meterType"    column="meter_type"    />
        <result property="modelNumber"    column="model_number"    />
        <result property="measureRange"    column="measure_range"    />
        <result property="manufacturer"    column="manufacturer"    />
        <result property="personCharge"    column="person_charge"    />
        <result property="installactionLocation"    column="installaction_location"    />
        <result property="startTime"    column="start_time"    />
        <result property="checkCycle"    column="check_cycle"    />
        <result property="reminderCycle"    column="reminder_cycle"    />
        <result property="meterStatus"    column="meter_status"    />
        <result property="delFlage"    column="del_flage"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="energyType"    column="energy_type"    />
        <result property="wireDiameter"    column="wire_diameter"    />
        <result property="maxAllowablePower"    column="max_allowable_power"    />
    </resultMap>
    <sql id="selectMeterImplementVo">
        select id,energy_type, code, meter_name, meter_type, model_number, measure_range, manufacturer, person_charge, installaction_location, start_time, check_cycle, reminder_cycle, meter_status, del_flage, remark, putrun_time,create_time, create_by, update_time, update_by,(start_time+check_cycle-reminder_cycle)&lt;=current_date as txflage,wire_diameter,max_allowable_power,gateway_id,gateway_name from meter_implement
    </sql>
 
    <select id="selectMeterImplementList" parameterType="MeterImplement" resultMap="MeterImplementResult">
        <include refid="selectMeterImplementVo"/>
        <where>
            del_flage='N'
            <if test="code != null  and code != ''"> and code like concat('%', #{code}, '%')</if>
            <if test="meterName != null  and meterName != ''"> and meter_name like concat('%', #{meterName}, '%')</if>
            <if test="meterType != null  and meterType != ''"> and meter_type = #{meterType}</if>
            <if test="measureRange != null  and measureRange != ''"> and measure_range like concat('%', #{measureRange}, '%')</if>
            <if test="manufacturer != null  and manufacturer != ''"> and manufacturer like concat('%', #{manufacturer}, '%')</if>
            <if test="installactionLocation != null  and installactionLocation != ''"> and installaction_location like concat('%', #{installactionLocation}, '%')</if>
        </where>
        order by code
    </select>
 
    <select id="exectMeterImplementList" parameterType="MeterImplement" resultMap="MeterImplementResultExcel">
        select id,energy_type, code, meter_name, fun_getDiceData('sys_device_type',meter_status) as meter_type, model_number, measure_range, manufacturer,
        person_charge, installaction_location, to_char(start_time,'YYYY-MM-DD') start_time, check_cycle, reminder_cycle, fun_getDiceData('meter_status',meter_status) as meter_status,
        del_flage, remark, create_time, create_by, update_time, update_by,wire_diameter,max_allowable_power,gateway_name
        from meter_implement
        <where>
            del_flage='N'
            <if test="code != null  and code != ''"> and code like concat('%', #{code}, '%')</if>
            <if test="meterName != null  and meterName != ''"> and meter_name like concat('%', #{meterName}, '%')</if>
            <if test="meterType != null  and meterType != ''"> and meter_type = #{meterType}</if>
            <if test="measureRange != null  and measureRange != ''"> and measure_range like concat('%', #{measureRange}, '%')</if>
            <if test="manufacturer != null  and manufacturer != ''"> and manufacturer like concat('%', #{manufacturer}, '%')</if>
            <if test="installactionLocation != null  and installactionLocation != ''"> and installaction_location like concat('%', #{installactionLocation}, '%')</if>
        </where>
        order by code
    </select>
 
    <select id="selectMeterImplementById" parameterType="String" resultMap="MeterImplementResult">
        <include refid="selectMeterImplementVo"/>
        where id = #{id}
    </select>
 
    <select id="selectMeterImplementByCode" parameterType="MeterImplement" resultMap="MeterImplementResult">
        <include refid="selectMeterImplementVo"/>
        where code = #{code}
        <if test="id != null  and id != ''"> and id != #{id} or id is null</if>
    </select>
 
    <select id="listMeterImplementByIds" resultMap="MeterImplementResult">
        SELECT
            "id",
            energy_type,
            code,
            meter_name,
            meter_type,
            meter_status,
            installaction_location,
            wire_diameter,
            max_allowable_power
        FROM
            "meter_implement"
        WHERE
            id IN
            <foreach collection="meterIdList" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
    </select>
    <select id="selectByNodeIdIndexId" resultType="com.zhitan.basicdata.domain.MeterImplement">
        <include refid="selectMeterImplementVo"/>
         mi
        JOIN node_device nd ON mi.id = nd.device_id
        JOIN node_index ni ON ni.node_id = nd.node_id
        where ni.node_id= #{nodeId} and index_id= #{indexId}
    </select>
 
    <insert id="insertMeterImplement" parameterType="MeterImplement">
        insert into meter_implement
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">id,</if>
            <if test="energyType != null  and energyType != ''">energy_type,</if>
            <if test="code != null  and code != ''">code,</if>
            <if test="meterName != null  and meterName != ''">meter_name,</if>
            <if test="meterType != null  and meterType != ''">meter_type,</if>
            <if test="modelNumber != null  and modelNumber != ''">model_number,</if>
            <if test="measureRange != null  and measureRange != ''">measure_range,</if>
            <if test="manufacturer != null  and manufacturer != ''">manufacturer,</if>
            <if test="personCharge != null  and personCharge != ''">person_charge,</if>
            <if test="installactionLocation != null  and installactionLocation != ''">installaction_location,</if>
            <if test="startTime != null ">start_time,</if>
            <if test="putrunTime != null ">putrun_time,</if>
            <if test="checkCycle != null ">check_cycle,</if>
            <if test="reminderCycle != null ">reminder_cycle,</if>
            <if test="meterStatus != null  and meterStatus != ''">meter_status,</if>
            <if test="delFlage != null  and delFlage != ''">del_flage,</if>
            <if test="remark != null  and remark != ''">remark,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="updateTime != null ">update_time,</if>
            <if test="updateBy != null  and updateBy != ''">update_by,</if>
            <if test="wireDiameter != null  and wireDiameter != ''">wire_diameter,</if>
            <if test="maxAllowablePower != null  and maxAllowablePower != ''">max_allowable_power,</if>
            <if test="gatewayId != null  and gatewayId != ''">gateway_id,</if>
            <if test="gatewayName != null and gatewayName != ''">gateway_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">#{id},</if>
            <if test="energyType != null  and energyType != ''">#{energyType},</if>
            <if test="code != null  and code != ''">#{code},</if>
            <if test="meterName != null  and meterName != ''">#{meterName},</if>
            <if test="meterType != null  and meterType != ''">#{meterType},</if>
            <if test="modelNumber != null  and modelNumber != ''">#{modelNumber},</if>
            <if test="measureRange != null  and measureRange != ''">#{measureRange},</if>
            <if test="manufacturer != null  and manufacturer != ''">#{manufacturer},</if>
            <if test="personCharge != null  and personCharge != ''">#{personCharge},</if>
            <if test="installactionLocation != null  and installactionLocation != ''">#{installactionLocation},</if>
            <if test="startTime != null ">#{startTime},</if>
            <if test="putrunTime != null ">#{putrunTime},</if>
            <if test="checkCycle != null ">#{checkCycle},</if>
            <if test="reminderCycle != null ">#{reminderCycle},</if>
            <if test="meterStatus != null  and meterStatus != ''">#{meterStatus},</if>
            <if test="delFlage != null  and delFlage != ''">#{delFlage},</if>
            <if test="remark != null  and remark != ''">#{remark},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="updateTime != null ">#{updateTime},</if>
            <if test="updateBy != null  and updateBy != ''">#{updateBy},</if>
            <if test="wireDiameter != null  and wireDiameter != ''">#{wire_diameter},</if>
            <if test="maxAllowablePower != null  and maxAllowablePower != ''">#{max_allowable_power},</if>
            <if test="gatewayId != null  and gatewayId != ''">#{gatewayId},</if>
            <if test="gatewayName != null and gatewayName != ''">#{gatewayName},</if>
         </trim>
    </insert>
 
    <update id="updateMeterImplement" parameterType="MeterImplement">
        update meter_implement
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null  and code != ''">code = #{code},</if>
            <if test="energyType != null  and energyType != ''">energy_type = #{energyType},</if>
            <if test="meterName != null  and meterName != ''">meter_name = #{meterName},</if>
            <if test="meterType != null  and meterType != ''">meter_type = #{meterType},</if>
            <if test="modelNumber != null  and modelNumber != ''">model_number = #{modelNumber},</if>
            <if test="measureRange != null  and measureRange != ''">measure_range = #{measureRange},</if>
            <if test="manufacturer != null  and manufacturer != ''">manufacturer = #{manufacturer},</if>
            <if test="personCharge != null  and personCharge != ''">person_charge = #{personCharge},</if>
            <if test="installactionLocation != null  and installactionLocation != ''">installaction_location = #{installactionLocation},</if>
            <if test="startTime != null ">start_time = #{startTime},</if>
            <if test="putrunTime != null ">putrun_time = #{putrunTime},</if>
            <if test="checkCycle != null ">check_cycle = #{checkCycle},</if>
            <if test="reminderCycle != null ">reminder_cycle = #{reminderCycle},</if>
            <if test="meterStatus != null  and meterStatus != ''">meter_status = #{meterStatus},</if>
            <if test="delFlage != null  and delFlage != ''">del_flage = #{delFlage},</if>
            <if test="remark != null  and remark != ''">remark = #{remark},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="updateTime != null ">update_time = #{updateTime},</if>
            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
            <if test="wireDiameter != null  and wireDiameter != ''">wire_diameter = #{wireDiameter},</if>
            <if test="maxAllowablePower != null  and maxAllowablePower != ''">max_allowable_power = #{maxAllowablePower},</if>
            <if test="gatewayId != null and gatewayId != ''">gateway_id = #{gatewayId},</if>
            <if test="gatewayName != null and gatewayName != ''">gateway_name = #{gatewayName},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteMeterImplementById" parameterType="String">
        <!--update meter_implement set del_flage='Y' where id = #{id} 先用物理删除,后期有必要再打开逻辑删除-->
        delete from meter_implement where id = #{id}
    </delete>
 
    <delete id="deleteMeterImplementByIds" parameterType="String">
        <!--update meter_implement set del_flage='Y' where id in 先用物理删除,后期有必要再打开逻辑删除-->
        delete from meter_implement where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
</mapper>