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
<?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.FacilityArchivesMapper">
 
    <resultMap type="FacilityArchives" id="FacilityArchivesResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="facilityName"    column="facility_name"    />
        <result property="facilityType"    column="facility_type"    />
        <result property="branchFactory"    column="branch_factory"    />
        <result property="istallationLocationn"    column="installation_location"    />
        <result property="facilityGrade"    column="facility_grade"    />
        <result property="ratedPower"    column="rated_power"    />
        <result property="productionDate"    column="production_date"    />
        <result property="putrunDate"    column="putrun_date"    />
        <result property="manufacturer"    column="manufacturer"    />
        <result property="personCharge"    column="person_charge"    />
        <result property="technicalData"    column="technical_data"    />
        <result property="startTime"    column="start_time"    />
        <result property="checkCycle"    column="check_cycle"    />
        <result property="reminderCycle"    column="reminder_cycle"    />
        <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="pointFlag"    column="point_flag"    />
    </resultMap>
 
    <sql id="selectFacilityArchivesVo">
        select id, code, facility_name, facility_type, branch_factory, installation_location, facility_grade, rated_power, production_date, putrun_date, manufacturer, person_charge, technical_data, start_time, check_cycle, reminder_cycle, remark, create_time, create_by, update_time, update_by,point_flag,(start_time+check_cycle-reminder_cycle)&lt;=current_date as txflage from facility_archives
    </sql>
 
    <select id="selectFacilityArchivesList" parameterType="FacilityArchives" resultMap="FacilityArchivesResult">
        <include refid="selectFacilityArchivesVo"/>
        <where>
            <if test="code != null  and code != ''"> and code like concat('%', #{code}, '%')</if>
            <if test="facilityName != null  and facilityName != ''"> and facility_name like concat('%', #{facilityName}, '%')</if>
            <if test="manufacturer != null  and manufacturer != ''"> and manufacturer like concat('%', #{manufacturer}, '%')</if>
            <if test="facilityType != null  and facilityType != ''"> and facility_type = #{facilityType}</if>
            <if test="branchFactory != null  and branchFactory != ''"> and branch_factory = #{branchFactory}</if>
            <if test="istallationLocationn != null  and istallationLocationn != ''"> and installation_location like concat('%', #{istallationLocationn}, '%')</if>
            <if test="facilityGrade != null  and facilityGrade != ''"> and facility_grade = #{facilityGrade}</if>
            <if test="ratedPower != null  and ratedPower != ''"> and to_number(rated_power,'9999999999') >= to_number(#{ratedPower},'9999999999')</if>
        </where>
        order by code
    </select>
 
    <select id="selectFacilityArchivesById" parameterType="String" resultMap="FacilityArchivesResult">
        <include refid="selectFacilityArchivesVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertFacilityArchives" parameterType="FacilityArchives">
        insert into facility_archives
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">id,</if>
            <if test="code != null  and code != ''">code,</if>
            <if test="facilityName != null  and facilityName != ''">facility_name,</if>
            <if test="facilityType != null  and facilityType != ''">facility_type,</if>
            <if test="branchFactory != null  and branchFactory != ''">branch_factory,</if>
            <if test="istallationLocationn != null  and istallationLocationn != ''">installation_location,</if>
            <if test="facilityGrade != null  and facilityGrade != ''">facility_grade,</if>
            <if test="ratedPower != null  and ratedPower != ''">rated_power,</if>
            <if test="productionDate != null ">production_date,</if>
            <if test="putrunDate != null ">putrun_date,</if>
            <if test="manufacturer != null  and manufacturer != ''">manufacturer,</if>
            <if test="personCharge != null  and personCharge != ''">person_charge,</if>
            <if test="technicalData != null  and technicalData != ''">technical_data,</if>
            <if test="startTime != null ">start_time,</if>
            <if test="checkCycle != null ">check_cycle,</if>
            <if test="reminderCycle != null ">reminder_cycle,</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="pointFlag != null  and pointFlag != ''">point_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">#{id},</if>
            <if test="code != null  and code != ''">#{code},</if>
            <if test="facilityName != null  and facilityName != ''">#{facilityName},</if>
            <if test="facilityType != null  and facilityType != ''">#{facilityType},</if>
            <if test="branchFactory != null  and branchFactory != ''">#{branchFactory},</if>
            <if test="istallationLocationn != null  and istallationLocationn != ''">#{istallationLocationn},</if>
            <if test="facilityGrade != null  and facilityGrade != ''">#{facilityGrade},</if>
            <if test="ratedPower != null  and ratedPower != ''">#{ratedPower},</if>
            <if test="productionDate != null ">#{productionDate},</if>
            <if test="putrunDate != null ">#{putrunDate},</if>
            <if test="manufacturer != null  and manufacturer != ''">#{manufacturer},</if>
            <if test="personCharge != null  and personCharge != ''">#{personCharge},</if>
            <if test="technicalData != null  and technicalData != ''">#{technicalData},</if>
            <if test="startTime != null ">#{startTime},</if>
            <if test="checkCycle != null ">#{checkCycle},</if>
            <if test="reminderCycle != null ">#{reminderCycle},</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="pointFlag != null  and pointFlag != ''">#{pointFlag},</if>
         </trim>
    </insert>
 
    <update id="updateFacilityArchives" parameterType="FacilityArchives">
        update facility_archives
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null  and code != ''">code = #{code},</if>
            <if test="facilityName != null  and facilityName != ''">facility_name = #{facilityName},</if>
            <if test="facilityType != null  and facilityType != ''">facility_type = #{facilityType},</if>
            <if test="branchFactory != null  and branchFactory != ''">branch_factory = #{branchFactory},</if>
            <if test="istallationLocationn != null  and istallationLocationn != ''">installation_location = #{istallationLocationn},</if>
            <if test="facilityGrade != null  and facilityGrade != ''">facility_grade = #{facilityGrade},</if>
            <if test="ratedPower != null  and ratedPower != ''">rated_power = #{ratedPower},</if>
            <if test="productionDate != null ">production_date = #{productionDate},</if>
            <if test="putrunDate != null ">putrun_date = #{putrunDate},</if>
            <if test="manufacturer != null  and manufacturer != ''">manufacturer = #{manufacturer},</if>
            <if test="personCharge != null  and personCharge != ''">person_charge = #{personCharge},</if>
            <if test="technicalData != null  and technicalData != ''">technical_data = #{technicalData},</if>
            <if test="startTime != null ">start_time = #{startTime},</if>
            <if test="checkCycle != null ">check_cycle = #{checkCycle},</if>
            <if test="reminderCycle != null ">reminder_cycle = #{reminderCycle},</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="pointFlag != null  and pointFlag != ''">point_flag = #{pointFlag},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteFacilityArchivesById" parameterType="String">
        delete from facility_archives where id = #{id}
    </delete>
 
    <delete id="deleteFacilityArchivesByIds" parameterType="String">
        delete from facility_archives where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
 
    <update id="resetFacilityArchivesByIds" parameterType="String" >
        update facility_archives
        set start_time = NOW()
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
 
    <select id="selectFacilityArchivesByCode" parameterType="FacilityArchives" resultMap="FacilityArchivesResult">
        <include refid="selectFacilityArchivesVo"/>
        where code = #{code}
        <if test="id != null  and id != ''"> and id != #{id} or id is null</if>
    </select>
    <select id="excelFacilityArchivesList" parameterType="FacilityArchives" resultMap="FacilityArchivesResult">
        select id, code, facility_name, fun_getDiceData('facility_type',facility_type) as facility_type,
        fun_getDiceData('branch_factory',branch_factory) as branch_factory, installation_location,
        fun_getDiceData('facility_grade',facility_grade) as facility_grade, rated_power, to_char(production_date,'YYYY-MM-DD') as  production_date,
        to_char(putrun_date,'YYYY-MM-DD') as putrun_date, manufacturer, person_charge,
          technical_data, start_time, check_cycle, reminder_cycle, remark, create_time, create_by,
           update_time, update_by
        from facility_archives
        <where>
            <if test="code != null  and code != ''"> and code like concat('%', #{code}, '%')</if>
            <if test="facilityName != null  and facilityName != ''"> and facility_name like concat('%', #{facilityName}, '%')</if>
            <if test="manufacturer != null  and manufacturer != ''"> and manufacturer like concat('%', #{manufacturer}, '%')</if>
            <if test="facilityType != null  and facilityType != ''"> and facility_type = #{facilityType}</if>
            <if test="branchFactory != null  and branchFactory != ''"> and branch_factory = #{branchFactory}</if>
            <if test="istallationLocationn != null  and istallationLocationn != ''"> and installation_location like concat('%', #{istallationLocationn}, '%')</if>
            <if test="facilityGrade != null  and facilityGrade != ''"> and facility_grade = #{facilityGrade}</if>
            <if test="ratedPower != null  and ratedPower != ''"> and to_number(rated_power,'9999999999') >= #{ratedPower}</if>
        </where>
        order by code
    </select>
</mapper>