add
gdg
2021-01-06 626028e5865122c43d97156d2cb221b751e5f18d
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
<?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.nanometer.smartlab.dao.SysLaboratoryContainerDao">
  <resultMap id="SysLaboratoryContainer" type="com.nanometer.smartlab.entity.SysLaboratoryContainer">
    <id property="id" column="id"/>
    <result property="laboratoryId" column="laboratory_id"></result>
    <result property="type" column="type"></result>
    <result property="name" column="name"></result>
    <result property="containerCode" column="container_code"></result>
    <result property="infoCode" column="info_code"></result>
    <result property="structure" column="structure"></result>
    <result property="name" column="name"></result>
    <result property="validFlag" column="valid_flag" typeHandler="com.nanometer.smartlab.entity.handler.ValidFlagHandler"></result>
    <result property="createTime" column="create_time"></result>
    <result property="updateTime" column="update_time"></result>
    <result property="laboratoryName" column="laboratoryName"></result>
    <result property="controllerName" column="controllerName"></result>
    <result property="laboratoryType" column="laboratoryType"></result>
    <result property="characterLeft" column="character_left"></result>
    <result property="characterRight" column="character_right"></result>
    <result property="controllerCode" column="controller_code"></result>
  </resultMap>
 
  <update id="updateInfo" parameterType="java.util.Map">
    update sys_laboratory_container set temp=#{temp},humidity=#{humidity},voc1=#{voc1},flag=#{flag} where id=#{containerId}
  </update>
 
  <select id="getSysLaboratoryContainerInfoList" parameterType="java.util.Map"  resultMap="SysLaboratoryContainer" >
    select container_code,name,valid_flag,type,character_left,character_right from sys_laboratory_container where update_time >= #{startTime} and #{endTime} > update_time
  </select>
 
  <select id="getSysLaboratoryContainer" parameterType="java.lang.String"  resultMap="SysLaboratoryContainer" >
    select su.*,ss.name as laboratoryName, ss.type as laboratoryType ,su.project_id projectId from sys_laboratory_container as su
    left join sys_laboratory as ss on su.laboratory_id = ss.id
    where su.id = #{id} and su.valid_flag = 1
  </select>
 
  <select id="getSysLaboratoryContainerByContainerCode" parameterType="java.lang.String" resultMap="SysLaboratoryContainer">
    select * from sys_laboratory_container
    where container_code = #{containerCode} and valid_flag = 1
  </select>
 
  <select id="updateSysLabContainer" parameterType="java.util.Map" >
    update sys_laboratory_container slc
    set slc.controller_code = #{code}
    WHERE  slc.controller_code =  (
    SELECT  sc.controller_code
    from sys_controller sc
    WHERE sc.id = #{id}
    and sc.valid_flag = 1)
    and slc.valid_flag  = 1
  </select>
 
  <select id="getSysLaboratoryContainerList" parameterType="java.util.Map" resultMap="SysLaboratoryContainer">
    select su.*,ss.name as laboratoryName, ss.type as laboratoryType,sc.controller_name as controllerName,su.project_id as projectId  from sys_laboratory_container as su
    left join sys_laboratory as ss on su.laboratory_id = ss.id
    left join sys_controller sc on sc.controller_code=su.controller_code
    where su.valid_flag = 1
    AND sc.valid_flag = 1
    AND ss.valid_flag = 1
    <if test="laboratoryType != null and laboratoryType != ''">
      and ss.type = #{laboratoryType}
    </if>
    <if test="laboratoryId != null and laboratoryId != ''">
      and ss.id = #{laboratoryId}
    </if>
    <if test="laboratoryName != null and laboratoryName != ''">
      and ss.name like #{laboratoryName}
    </if>
    order by ss.name ASC,sc.controller_name,su.container_code,su.name
    <if test="first != null and pageSize != null">
      limit #{first}, #{pageSize}
    </if>
  </select>
 
 
  <select id="exportExcelList" parameterType="java.util.Map" resultType="java.util.Map">
    SELECT
    bm2.meta_value labType,
    sl.NAME labName,
    sc.controller_name controlName,
    slc.container_code containerCode,
    bm1.meta_value containerType ,
    slc.info_code infoCode ,
    bm3.meta_value structure,
    slc.`name` name
    FROM
    sys_laboratory_container slc
    LEFT JOIN base_meta bm1 ON bm1.id = slc.type
    LEFT JOIN sys_laboratory sl ON sl.id = slc.laboratory_id
    LEFT JOIN base_meta bm2 ON bm2.id = sl.type
    LEFT JOIN sys_controller sc ON slc.controller_code = sc.controller_code
    LEFT JOIN base_meta bm3 on bm3.id = slc.structure
    WHERE
    slc.valid_flag = 1
    AND sc.valid_flag = 1
    AND sl.valid_flag = 1
    <if test="type != null and type != ''">
     and sl.type = #{type}
    </if>
    <if test="name != null and name != ''">
      and sl.name like concat("%",#{name},"%")
    </if>
    order by sl.name ASC,sc.controller_name,slc.container_code,slc.name
 
  </select>
 
  <select id="getSysLaboratoryContainerTotalCount" parameterType="java.util.Map" resultType="int">
    select count(1) from sys_laboratory_container as su
    left join sys_laboratory as ss on su.laboratory_id = ss.id
    left join sys_controller sc on sc.controller_code=su.controller_code
    where su.valid_flag = 1
    AND sc.valid_flag = 1
    AND ss.valid_flag = 1
    <if test="laboratoryType != null and laboratoryType != ''">
      and ss.type = #{laboratoryType}
    </if>
    <if test="laboratoryId != null and laboratoryId != ''">
      and ss.id = #{laboratoryId}
    </if>
    <if test="laboratoryName != null and laboratoryName != ''">
      and ss.name like #{laboratoryName}
    </if>
    <if test="containerCode != null and containerCode != ''">
      and su.container_code = #{containerCode}
    </if>
    <if test="editId != null and editId != ''">
      and su.id != #{editId}
    </if>
  </select>
 
  <insert id="insertSysLaboratoryContainer" parameterType="com.nanometer.smartlab.entity.SysLaboratoryContainer">
    insert into sys_laboratory_container(id, laboratory_id, type, container_code, info_code, structure, name, valid_flag, character_left, character_right, create_time, update_time, controller_code,project_id)
    values (#{id}, #{laboratoryId}, #{type}, #{containerCode}, #{infoCode}, #{structure}, #{name}, 1, #{characterLeft}, #{characterRight}, now(), now(), #{controllerCode},#{projectId})
  </insert>
 
  <update id="updateSysLaboratoryContainer" parameterType="com.nanometer.smartlab.entity.SysLaboratoryContainer">
    update sys_laboratory_container set laboratory_id=#{laboratoryId}, type=#{type}, container_code=#{containerCode}, info_code=#{infoCode},
    structure=#{structure}, name=#{name}, character_left=#{characterLeft}, character_right=#{characterRight},controller_code=#{controllerCode},
    update_time=now(),project_id = #{projectId}
    where id=#{id}
  </update>
 
  <update id="deleteSysLaboratoryContainers" parameterType="java.util.List">
    update sys_laboratory_container set valid_flag=0, update_time=now()
    where id in
    <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
      #{item}
    </foreach>
  </update>
  <update id="updateSLContainerUser" parameterType="com.nanometer.smartlab.entity.SysLaboratoryContainer">
    update sys_user u
    left join sys_laboratory l on l.department = u.department
    SET u.update_time = now()
    where l.id = #{laboratoryId}
  </update>
 
    <update id="updateSysLaboratoryContainerForInterface" parameterType="com.nanometer.smartlab.entity.SysLaboratoryContainer">
    update sys_laboratory_container set laboratory_id=#{laboratoryId}, type=#{type},
    info_code=#{infoCode}, structure=#{structure}, name=#{name}, character_left=#{characterLeft}, character_right=#{characterRight},
    update_time=#{updateTime}, controller_code = #{controllerCode}, valid_flag = #{validFlag}
    where id=#{id} and update_time &lt; #{updateTime}
  </update>
 
  <select id="getSysLaboratoryContainerByContainerCodes" parameterType="java.util.List" resultMap="SysLaboratoryContainer">
    select * from sys_laboratory_container
    where container_code in
    <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
      #{item}
    </foreach>
  </select>
 
  <update id="updateSysLaboratoryContainerClearControllerCode" parameterType="java.lang.String" >
    update sys_laboratory_container set
    controller_code=null
    where controller_code=#{controllerCode}
  </update>
 
  <select id="getSysLaboratoryContainerByControllerCode" parameterType="java.lang.String" resultMap="SysLaboratoryContainer">
    select * from sys_laboratory_container
    where controller_code = #{controllerCode}
  </select>
 
  <update id="invalidSysLaboratoryContainer" parameterType="com.nanometer.smartlab.entity.SysLaboratoryContainer">
    update sys_laboratory_container set valid_flag= 0 , update_time = #{updateTime}
    where id=#{id} and update_time &lt; #{updateTime}
  </update>
 
 
  <select id="getContainerPersonInCharge" parameterType="java.lang.String" resultType="java.util.Map">
    SELECT slc.container_code containCode,su.name name,su.phone phone,
CONCAT(sl.location1,"-",sl.location2) location
 
FROM sys_laboratory_container slc
LEFT JOIN sys_laboratory sl on sl.id = slc.laboratory_id
LEFT JOIN sys_user su on su.department = sl.department
LEFT JOIN base_role br on br.id = su.role_id
WHERE slc.container_code = #{containerCode}
and su.valid_flag =1
and br.`name` = '实验负责人'
  </select>
 
 
 
 
  <select id="selectLocationByContainerCode" parameterType="java.lang.String" resultType="java.util.Map">
     SELECT
  CONCAT(sl.location1,"-",sl.location2) location,sl.bar_code barCode
 
  FROM sys_laboratory_container slc
  LEFT JOIN sys_laboratory sl on sl.id = slc.laboratory_id
  WHERE slc.container_code = #{containerCode}
  and slc.valid_flag = 1
  </select>
 
</mapper>