qushaowei
2024-03-28 7f2d8230bd6bb29dc18e91a843018113cd6eb4c0
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
<?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="org.jeecg.modules.eam.mapper.InspectionOrderMapper">
 
    <select id="getInspectionOrderList"  parameterType="Map" resultType="Map">
        SELECT
            t1.id,
            t1.num,
            t1.inspection_time as inspectionDate,
            t1.inspection_time as inspectionTime,
            DATEADD(DAY,+7,t1.inspection_time)   as redWarningTime,
            CONVERT(varchar(100), GETDATE(), 20) AS currentDateTime,
            t1.inspection_deadline as inspectionDeadline,
            t1.start_work_condition as startWorkCondition,
            t1.status,
            t5.item_text as statusName,
            t2.id as equipmentId,
            t2.num as equipmentNum,
            t2.name as equipmentName,
            t2.model as equipmentModel,
            t2.specification,
            t2.team_id as teamId,
            t2.use_id as useId,
            t3.id as inspectionCycleId,
            t3.name as inspectionCycleName,
            t3.effective_time as effectiveTime,
            t3.unit as unit,
            t4.id as inspectionStandardId,
            t4.num as inspectionStandardNum,
            t1.create_by as createBy,
            t1.create_time as createTime,
            t6.depart_name as useDepartName,
            t7.name as teamName,
            t4.assign_mode as assignMode,
            t8.item_text as assignModeName,
            t1.inspection_order_uda2 as inspectionUserName,
            t1.actual_end_time as actualEndTime,
            t1.actual_start_time as actualStartTime,
            t1.inspection_order_uda1 AS repairConfirmPerson,
            t1.repair_confirm_date as repairConfirmDate
        FROM
            mom_eam_inspection_order t1
        LEFT JOIN mom_eam_equipment t2 ON t1.equipment_id = t2.id
        left join mom_eam_inspection_cycle t3 on t1.inspection_cycle_id = t3.id
        left join mom_eam_daily_inspection_standard t4 on t1.inspection_standard_id = t4.id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'daily_inspection_standard_status' ) t5 ON t5.item_value = t1.status
        left join sys_depart t6 on t2.use_id = t6.id
        left join mom_base_team t7 on t2.team_id = t7.id
        left join ( SELECT * FROM v_sys_dict WHERE dict_code = 'assign_mode' ) t8 on t8.item_value = t4.assign_mode
        WHERE t1.del_flag = 0 and t2.del_flag = 0 and t3.del_flag = 0 and t4.del_flag = 0
<!--        <if test="params.dailyInspectionStandardId != null and params.dailyInspectionStandardId != ''">-->
<!--            and t1.daily_inspection_standard_id = #{params.dailyInspectionStandardId}-->
<!--        </if>-->
        <if test="params.num != null and params.num != ''">
            and t1.num like concat('%',#{params.num},'%')
        </if>
        <if test="params.equipmentNum != null and params.equipmentNum != ''">
            and t2.num like concat('%',#{params.equipmentNum},'%')
        </if>
        <if test="params.useDepartId != null and params.useDepartId != ''">
            and t2.use_id = #{params.useDepartId}
        </if>
        <if test="params.status != null and params.status != ''">
            and t1.status = #{params.status}
        </if>
        <if test="params.teamId != null and params.teamId != ''">
            and t2.team_id = #{params.teamId}
        </if>
        <if test="params.inspectionStartTime != null">
            and t1.actual_end_time &gt;= #{params.inspectionStartTime}
        </if>
        <if test="params.inspectionEndTime != null">
            and t1.actual_end_time &lt;= #{params.inspectionEndTime}
        </if>
        ORDER BY t1.create_time desc
    </select>
 
    <select id="getInspectionCycleByEqId"  parameterType="Map" resultType="org.jeecg.modules.eam.model.InspectionCycleVo">
        SELECT DISTINCT
            t1.inspection_cycle_id AS value,
            t3.name as text,
            t3.name as title
        FROM
            mom_eam_daily_inspection_standard_detail t1
        LEFT JOIN mom_eam_daily_inspection_standard t2 ON t1.daily_inspection_standard_id = t2.id
        left join mom_eam_inspection_cycle t3 on t1.inspection_cycle_id = t3.id
        where t1.del_flag = '0' and t2.del_flag = '0' and t3.del_flag = '0' and t2.version_status = '2'
        <if test="inspectionStandardId != null and inspectionStandardId != ''">
            and t2.id = #{inspectionStandardId}
        </if>
        <if test="inspectionStandardId == null || inspectionStandardId == ''">
            and t2.id ='-1'
        </if>
    </select>
 
    <select id="getInspectionProjectId"  parameterType="Map" resultType="map">
        SELECT
            t1.id,
            t1.id as inspectionStandardDetailId,
            t1.location,
            t1.photo,
            t1.inspection_project_id as inspectionProjectId,
            t3.num as inspectionProjectNum,
            t3.name as inspectionProjectName,
            t3.detection_standard as detectionStandard,
            t3.acceptability_limit AS acceptabilityLimit,
            t3.inspection_method as inspectionMethod,
            t3.inspection_tool as inspectionTool,
            t4.item_text as inspectionMethodName,
            t5.effective_time as effectiveTime,
            t5.unit
        FROM
            mom_eam_daily_inspection_standard_detail t1
        LEFT JOIN mom_eam_daily_inspection_standard t2 ON t1.daily_inspection_standard_id = t2.id
        left join mom_eam_inspection_project t3 on t1.inspection_project_id = t3.id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'inspection_method' ) t4 ON t4.item_value = t3.inspection_method
        left join mom_eam_inspection_cycle t5 on t1.inspection_cycle_id = t5.id
        where t1.del_flag = '0' and t2.del_flag = '0' and t3.del_flag = '0' and t2.version_status = '2'
        <if test="inspectionStandardId != null and inspectionStandardId != ''">
            and t2.id = #{inspectionStandardId}
        </if>
        <if test="inspectionCycleId != null and inspectionCycleId != ''">
            and t1.inspection_cycle_id = #{inspectionCycleId}
        </if>
    </select>
 
    <select id="getInspectionOrderDetailByOrderId"  parameterType="Map" resultType="map">
        SELECT
            t1.id,
            t2.id AS inspectionStandardDetailId,
            t1.location,
            t1.photo,
            t1.inspection_project_id AS inspectionProjectId,
            t3.num AS inspectionProjectNum,
            t3.name as inspectionProjectName,
            t3.detection_standard AS detectionStandard,
            t3.acceptability_limit AS acceptabilityLimit,
            t3.inspection_method AS inspectionMethod,
            t3.inspection_tool AS inspectionTool,
            t4.item_text AS inspectionMethodName,
            t5.effective_time AS effectiveTime,
            t5.unit
        FROM
            mom_eam_inspection_order_detail t1
        LEFT JOIN mom_eam_daily_inspection_standard_detail t2 ON t1.inspection_standard_detail_id = t2.id
        LEFT JOIN mom_eam_inspection_project t3 ON t1.inspection_project_id = t3.id
        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'inspection_method' ) t4 ON t4.item_value = t3.inspection_method
        LEFT JOIN mom_eam_inspection_cycle t5 ON t2.inspection_cycle_id = t5.id
        where t1.del_flag = '0' and t2.del_flag = '0' and t3.del_flag = '0'  and t5.del_flag = '0'
        <if test="inspectionOrderId != null and inspectionOrderId != ''">
            and t1.inspection_order_id = #{inspectionOrderId}
        </if>
    </select>
 
<!--    <select id="findUserList"  parameterType="Map" resultType="Map">-->
<!--        SELECT-->
<!--            t1.id,-->
<!--            t1.username,-->
<!--            t1.realname,-->
<!--            t3.name as teamName-->
<!--        FROM-->
<!--            sys_user t1-->
<!--        LEFT JOIN mom_base_team_class t2 ON t1.team_class_id = t2.id-->
<!--        left join mom_base_team t3 on t2.team_id = t3.id-->
<!--        where t1.del_flag = 0 and t2.del_flag = 0 and t3.id = #{params.teamId}-->
<!--        <if test="params.num!=null and params.num!= ''">-->
<!--            and t3.num like concat('%',#{params.num},'%')-->
<!--        </if>-->
<!--        <if test="params.username!=null and params.username!= ''">-->
<!--            and t1.username like concat('%',#{params.username},'%')-->
<!--        </if>-->
<!--        <if test="params.realname!=null and params.realname!= ''">-->
<!--            and t1.realname like concat('%',#{params.realname},'%')-->
<!--        </if>-->
<!--        ORDER BY t1.create_time desc-->
<!--    </select>-->
    <select id="findUserList"  parameterType="Map" resultType="Map">
        SELECT
        t1.id,
        t1.username,
        t1.realname
        FROM
        sys_user t1
        where t1.del_flag = 0
        <if test="params.username!=null and params.username!= ''">
            and t1.username like concat('%',#{params.username},'%')
        </if>
        <if test="params.realname!=null and params.realname!= ''">
            and t1.realname like concat('%',#{params.realname},'%')
        </if>
        ORDER BY t1.create_time desc
    </select>
 
    <select id="findDayInspectionProjectList"  parameterType="Map" resultType="Map">
        SELECT
            t4.num as equipmentNum,
            t4.name as equipmentName,
            t3.name,
            t1.detection_standard as detectionStandard,
            t1.inspection_project_result as insResult,
            SUBSTRING ( CONVERT ( VARCHAR ( 10 ), t2.create_time, 120 ), 9, 10 ) as createTime
        FROM
            mom_eam_inspection_order_detail t1
                LEFT JOIN mom_eam_inspection_order t2 ON t1.inspection_order_id = t2.id
                LEFT JOIN mom_eam_inspection_project t3 ON t1.inspection_project_id = t3.id
                LEFT JOIN mom_eam_equipment t4 ON t2.equipment_id = t4.id
                LEFT JOIN mom_eam_inspection_cycle t5 ON t2.inspection_cycle_id = t5.id
                left join (SELECT * FROM v_sys_dict WHERE dict_code = 'inspection_project_result') t6 on t1.inspection_project_result = t6.item_value
        WHERE
            t5.name = '1日'
          AND t4.num = 'HQ1901124'
          AND SUBSTRING ( CONVERT ( VARCHAR ( 10 ), t2.create_time, 120 ), 1, 7 ) = SUBSTRING ( CONVERT ( VARCHAR ( 10 ), GETDATE( ), 120 ), 1, 7 )
          AND t1.inspection_standard_detail_id IN (
            SELECT
                tt2.id
            FROM
                mom_eam_daily_inspection_standard tt1
                    LEFT JOIN mom_eam_daily_inspection_standard_detail tt2 ON tt1.id= tt2.daily_inspection_standard_id
                    LEFT JOIN mom_eam_equipment tt3 ON tt1.equipment_id = tt3.id
                    LEFT JOIN mom_eam_inspection_cycle tt4 ON tt2.inspection_cycle_id = tt4.id
            WHERE
                tt4.name = '1日'
              AND tt3.num = 'HQ1901124'
              AND tt1.version_status = '2'
              AND tt1.del_flag = '0'
        )
    </select>
</mapper>