邱宇豪
2023-11-13 990f794e91ddaae1d8ef6a71b5741c58dfed23ba
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
<?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.thhy.secure.modules.biz.regionInspection.mapper.RegionInspectionMapper">
 
  <insert id="insert">
    insert into t_region_inspection
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="task != null">
        task,
      </if>
      <if test="standard != null">
        standard,
      </if>
      <if test="createUser != null">
        createUser,
      </if>
      <if test="createTime != null">
        createTime,
      </if>
      <if test="updateUser != null">
        updateUser,
      </if>
      <if test="updateTime != null">
        updateTime,
      </if>
      <if test="companyId != null">
        companyId,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="task != null">
        #{task,jdbcType=VARCHAR},
      </if>
      <if test="standard != null">
        #{standard,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null">
        #{updateUser,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=VARCHAR},
      </if>
    </trim>
    on duplicate key update
    <trim suffixOverrides=",">
      <if test="task != null">
        task = #{task,jdbcType=VARCHAR},
      </if>
      <if test="standard != null">
        standard = #{standard,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null">
        createUser = #{createUser,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        createTime = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null">
        updateUser = #{updateUser,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        updateTime = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="companyId != null">
        companyId = #{companyId,jdbcType=VARCHAR},
      </if>
    </trim>
 
  </insert>
 
  <delete id="delete">
    update t_region_inspection set isUse = 0 where id = #{id,jdbcType=VARCHAR}
  </delete>
 
  <select id="selectPageList" resultType="com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionEntity">
    SELECT * FROM (
                          SELECT
                                t.id,
                                t.task,
                                t.standard,
                                t.createUser,
                                t.createTime,
                                t.updateUser,
                                t.updateTime,
                                t.isUse,
                                t.companyId,
                                GROUP_CONCAT(DISTINCT b.real_name ORDER BY b.job_num SEPARATOR '、') realNames,
                                GROUP_CONCAT(DISTINCT b.user_id ORDER BY b.job_num SEPARATOR '、') userIds,
                                GROUP_CONCAT(DISTINCT d.region ORDER BY c.sort SEPARATOR ',') regions,
                                GROUP_CONCAT(DISTINCT d.id ORDER BY c.sort SEPARATOR ',') regionIds
                          FROM t_region_inspection t
                          LEFT JOIN t_region_inspection_user a ON a.regionInspectionId = t.id
                          LEFT JOIN sys_plat_user b ON b.user_id = a.userId
                          LEFT JOIN t_region_inspection_hazard_inform c ON c.regionInspectionId = t.id
                          LEFT JOIN t_region_hazard_inform d ON d.id = c.regionHazardInformId
                          GROUP BY t.id
                          order by  t.createTime desc
                          ) a
        WHERE a.isUse = 1 and a.companyId = #{companyId}
      <if test="realName != null and realName !=''">
        AND a.realNames LIKE CONCAT('%',#{realName},'%')
      </if>
      <if test="task != null and task !=''">
        AND a.task LIKE CONCAT('%',#{task},'%')
      </if>
  </select>
 
  <insert id="insertUser">
    insert into t_region_inspection_user
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="regionInspectionId != null">
        regionInspectionId,
      </if>
      <if test="userId != null">
        userId,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="regionInspectionId != null">
        #{regionInspectionId,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
 
  <delete id="deleteUser">
    delete from  t_region_inspection_user where regionInspectionId = #{regionInspectionId,jdbcType=VARCHAR}
  </delete>
 
  <select id="selectUserList" resultType="com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionUserEntity">
    select * from t_region_inspection_user where regionInspectionId = #{regionInspectionId,jdbcType=VARCHAR}
  </select>
 
  <insert id="insertInspectionHazardInform">
    insert into t_region_inspection_hazard_inform
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="regionInspectionId != null">
        regionInspectionId,
      </if>
      <if test="regionHazardInformId != null">
        regionHazardInformId,
      </if>
      <if test="sort != null">
        sort,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="regionInspectionId != null">
        #{regionInspectionId,jdbcType=VARCHAR},
      </if>
      <if test="regionHazardInformId != null">
        #{regionHazardInformId,jdbcType=VARCHAR},
      </if>
      <if test="sort != null">
        #{sort,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
 
  <delete id="deleteInspectionHazardInform">
    delete from t_region_inspection_hazard_inform where regionInspectionId = #{regionInspectionId,jdbcType=VARCHAR}
  </delete>
</mapper>