hecheng 3 vuotta sitten
vanhempi
commit
971ff17a1f

+ 172 - 131
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHardwareMapper.xml

@@ -1,93 +1,124 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zd.laboratory.mapper.LabHardwareMapper">
 
     <resultMap type="com.zd.laboratory.domain.LabHardware" id="LabHardwareResult">
-        <result property="id"    column="id"    />
-        <result property="name"    column="name"    />
-        <result property="factory"    column="factory"    />
-        <result property="type"    column="type"    />
-        <result property="pcType"    column="pcType"    />
-        <result property="macAdd"    column="mac_add"    />
-        <result property="subjectId"    column="subject_id"    />
-        <result property="deptId"    column="dept_id"    />
-        <result property="deptName"    column="dept_name"    />
-        <result property="operate"    column="operate"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="userId"    column="user_id"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="remark"    column="remark"    />
-        <result property="functionStatus"    column="function_status"    />
-        <result property="hardwareNum"    column="hardware_num"    />
-        <result property="relayCode"    column="relay_code"    />
-        <result property="bit"    column="bit"    />
-        <result property="hardwareType"    column="hardware_type"    />
-        <result property="configName"    column="config_name"    />
-        <result property="configStatus"    column="config_status"    />
-        <result property="operateTime"    column="operate_time"    />
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="factory" column="factory"/>
+        <result property="type" column="type" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
+        <result property="pcType" column="pcType"/>
+        <result property="macAdd" column="mac_add"/>
+        <result property="subjectId" column="subject_id"/>
+        <result property="deptId" column="dept_id"/>
+        <result property="deptName" column="dept_name"/>
+        <result property="operate" column="operate" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
+        <result property="createTime" column="create_time"/>
+        <result property="userId" column="user_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="remark" column="remark"/>
+        <result property="functionStatus" column="function_status"/>
+        <result property="hardwareNum" column="hardware_num"/>
+        <result property="relayCode" column="relay_code"/>
+        <result property="bit" column="bit"/>
+        <result property="hardwareType" column="hardware_type"/>
+        <result property="configName" column="config_name"/>
+        <result property="configStatus" column="config_status"/>
+        <result property="operateTime" column="operate_time"/>
         <result property="ipAddress" column="ip_address"/>
         <result property="port" column="port"/>
         <result property="uniformPower" column="uniform_power"/>
         <result property="sessionIndex" column="session_index"/>
         <result property="channels" column="channels"/>
         <result property="lockId" column="lock_id"/>
-        <result property="joinCabinet"    column="join_cabinet"    />
+        <result property="joinCabinet" column="join_cabinet"/>
         <result property="deviceStatus" column="device_status"/>
         <result property="manufacturerType" column="manufacturer_type"/>
     </resultMap>
 
     <resultMap type="com.zd.laboratory.domain.vo.LabHardwareVO" id="LabHardwareVOResult">
-        <result property="subjectName"    column="subject_name"    />
+        <result property="subjectName" column="subject_name"/>
+        <result property="type" column="type" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
+        <result property="operate" column="operate" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
     </resultMap>
 
     <sql id="selectLabHardwareVo">
-        select xx.*,  hp.horizontal_axis as horizontalAxis, hp.vertical_axis as verticalAxis,ifnull(ct.cabinet_name,'未关联') cabinetName from (select
-          he.id,
-          he.name,
-          he.factory,
-          he.type,
-          he.pc_type,
-          he.mac_add,
-          he.subject_id,
-          he.function_status,
-          (select s.name from lab_subject s where s.id = he.subject_id) subject_name,
-          (select d.dept_name from sys_dept d,lab_subject s where s.dept_id = d.dept_id and s.id = he.subject_id) dept_name,
-          (select d.dept_id from sys_dept d,lab_subject s where s.dept_id = d.dept_id and s.id = he.subject_id) dept_id,
-          he.operate,
-          he.create_time,
-          he.user_id,
-          he.create_by,
-          he.update_time,
-          he.update_by,
-          he.hardware_num,
-          he.remark,
-          he.config_name,
-          he.config_status,
-          he.ip_address,
-          he.`port`,
-          he.uniform_power,
-          he.session_index,
-          he.channels,
-          he.hardware_type,
-          he.relay_code,
-          he.bit,
-          CONCAT((SELECT st.name FROM lab_subject st WHERE st.id = he.subject_id),'-',(SELECT dt.dept_name FROM sys_dept
-          dt,lab_subject st WHERE dt.dept_id = st.build_id AND st.id = he.subject_id),
-          '-',(SELECT bg.name FROM lab_building bg,lab_subject st WHERE bg.id = st.floor_id AND st.id = he.subject_id),
-          '-',(SELECT slt.room FROM lab_subject_layout slt,lab_subject st WHERE slt.id = st.layout_id AND st.id = he.subject_id)) posi,
-          stc.ring_time, stc.deal_time,he.operate_time,he.join_cabinet joinCabinetId,he.join_cabinet_time joinCabinetTime,he.lock_id lockId,
-          he.device_status deviceStatus,he.manufacturer_type manufacturerType
-          from
-          lab_hardware he LEFT JOIN hxp_smart_terminal_config stc ON he.id = stc.terminal_id
-          )xx left join lab_subject_hardware_position hp on hp.hard_id = xx.id
-          left join hxp_cabinet ct on ct.id = xx.joinCabinetId
+        select xx.*,
+               hp.horizontal_axis as          horizontalAxis,
+               hp.vertical_axis   as          verticalAxis,
+               ifnull(ct.cabinet_name, '未关联') cabinetName
+        from (select he.id,
+                     he.name,
+                     he.factory,
+                     he.type,
+                     he.pc_type,
+                     he.mac_add,
+                     he.subject_id,
+                     he.function_status,
+                     (select s.name from lab_subject s where s.id = he.subject_id) subject_name,
+                     (select d.dept_name
+                      from sys_dept d,
+                           lab_subject s
+                      where s.dept_id = d.dept_id
+                        and s.id = he.subject_id)                                  dept_name,
+                     (select d.dept_id
+                      from sys_dept d,
+                           lab_subject s
+                      where s.dept_id = d.dept_id
+                        and s.id = he.subject_id)                                  dept_id,
+                     he.operate,
+                     he.create_time,
+                     he.user_id,
+                     he.create_by,
+                     he.update_time,
+                     he.update_by,
+                     he.hardware_num,
+                     he.remark,
+                     he.config_name,
+                     he.config_status,
+                     he.ip_address,
+                     he.`port`,
+                     he.uniform_power,
+                     he.session_index,
+                     he.channels,
+                     he.hardware_type,
+                     he.relay_code,
+                     he.bit,
+                     CONCAT((SELECT st.name FROM lab_subject st WHERE st.id = he.subject_id), '-', (SELECT dt.dept_name
+                                                                                                    FROM sys_dept dt,
+                                                                                                         lab_subject st
+                                                                                                    WHERE dt.dept_id = st.build_id
+                                                                                                      AND st.id = he.subject_id),
+                            '-', (SELECT bg.name
+                                  FROM lab_building bg,
+                                       lab_subject st
+                                  WHERE bg.id = st.floor_id
+                                    AND st.id = he.subject_id),
+                            '-', (SELECT slt.room
+                                  FROM lab_subject_layout slt,
+                                       lab_subject st
+                                  WHERE slt.id = st.layout_id
+                                    AND st.id = he.subject_id))                    posi,
+                     stc.ring_time,
+                     stc.deal_time,
+                     he.operate_time,
+                     he.join_cabinet                                               joinCabinetId,
+                     he.join_cabinet_time                                          joinCabinetTime,
+                     he.lock_id                                                    lockId,
+                     he.device_status                                              deviceStatus,
+                     he.manufacturer_type                                          manufacturerType
+              from lab_hardware he
+                       LEFT JOIN hxp_smart_terminal_config stc ON he.id = stc.terminal_id) xx
+                 left join lab_subject_hardware_position hp on hp.hard_id = xx.id
+                 left join hxp_cabinet ct on ct.id = xx.joinCabinetId
     </sql>
 
-    <select id="selectLabHardwareStatusByRelay" parameterType="com.zd.laboratory.domain.LabHardware" resultType="com.zd.laboratory.domain.LabHardware">
+    <select id="selectLabHardwareStatusByRelay" parameterType="com.zd.laboratory.domain.LabHardware"
+            resultType="com.zd.laboratory.domain.LabHardware">
         select
         id,
         subject_id,
@@ -98,36 +129,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from
         lab_hardware
         <where>
-            <if test="relayCode != null "> and relay_code = #{relayCode}</if>
-            <if test="hardwareNum != null" > and hardware_num = #{hardwareNum}</if>
+            <if test="relayCode != null ">and relay_code = #{relayCode}</if>
+            <if test="hardwareNum != null">and hardware_num = #{hardwareNum}</if>
         </where>
     </select>
 
 
-    <select id="selectLabHardwareList" parameterType="com.zd.laboratory.domain.LabHardware" resultMap="LabHardwareVOResult">
+    <select id="selectLabHardwareList" parameterType="com.zd.laboratory.domain.LabHardware"
+            resultMap="LabHardwareVOResult">
         <include refid="selectLabHardwareVo"/>
         <where>
-            <if test="ipAddress != null "> and xx.ip_address = #{ipAddress}</if>
-            <if test="deviceStatus != null "> and xx.deviceStatus = #{deviceStatus}</if>
-            <if test="subjectId != null "> and xx.subject_id = #{subjectId}</if>
+            <if test="ipAddress != null ">and xx.ip_address = #{ipAddress}</if>
+            <if test="deviceStatus != null ">and xx.deviceStatus = #{deviceStatus}</if>
+            <if test="subjectId != null ">and xx.subject_id = #{subjectId}</if>
             <if test="deptId != null ">
-                AND (xx.dept_id = #{deptId} OR xx.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
+                AND (xx.dept_id = #{deptId} OR xx.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE
+                find_in_set(#{deptId},
                 ancestors) ))
             </if>
-            <if test="hardwareNum != null and hardwareNum != ''" > and xx.hardware_num = #{hardwareNum}</if>
-            <if test="relayCode != null and relayCode != ''" > and xx.relay_code = #{relayCode}</if>
-            <if test="type != null "> and xx.type = #{type}</if>
-            <if test="operate != null "> and (xx.operate = #{operate} or xx.operate is null)</if>
+            <if test="hardwareNum != null and hardwareNum != ''">and xx.hardware_num = #{hardwareNum}</if>
+            <if test="relayCode != null and relayCode != ''">and xx.relay_code = #{relayCode}</if>
+            <if test="type != null ">and xx.type = #{type}</if>
+            <if test="operate != null ">and (xx.operate = #{operate} or xx.operate is null)</if>
             <if test="searchValue != null  and searchValue != ''">
                 and (xx.hardware_num like concat('%',#{searchValue},'%')
+                or
+                xx.subject_name like concat('%',#{searchValue},'%')
+                <if test="type == @com.zd.common.core.enums.HardwareTypeEnum@AI_CABINETLOCK ">
                     or
-                    xx.subject_name like concat('%',#{searchValue},'%')
-                    <if test="type == @com.zd.common.core.enums.HardwareTypeEnum@AI_CABINETLOCK ">
-                        or
-                        xx.name like concat('%',#{searchValue},'%')
-                        or
-                        ct.cabinet_name like concat('%',#{searchValue},'%')
-                    </if>
+                    xx.name like concat('%',#{searchValue},'%')
+                    or
+                    ct.cabinet_name like concat('%',#{searchValue},'%')
+                </if>
                 )
             </if>
             <if test="ids != null ">
@@ -163,12 +196,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
-    <select id="selectLabHardwareById"  resultMap="LabHardwareVOResult">
+    <select id="selectLabHardwareById" resultMap="LabHardwareVOResult">
         <include refid="selectLabHardwareVo"/>
         where xx.id = #{id}
     </select>
-<!--   通过实验室ids查询设备 -->
-    <select id="selectLabHardwareBySubIds"  resultMap="LabHardwareResult">
+    <!--   通过实验室ids查询设备 -->
+    <select id="selectLabHardwareBySubIds" resultMap="LabHardwareResult">
         <include refid="selectLabHardwareVo"/>
         where xx.subject_id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
@@ -186,9 +219,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         lh.hardware_num deviceId,
         labs.id labId,
         labs.name labName
-        FROM  `lab_hardware` lh
+        FROM `lab_hardware` lh
         INNER JOIN `lab_subject` labs ON lh.`subject_id`=labs.`id`
-        INNER JOIN  lab_building lb ON lb.`id`=labs.`floor_id`
+        INNER JOIN lab_building lb ON lb.`id`=labs.`floor_id`
         <where>
             <if test="deptId != null and deptId != ''">
                 and labs.build_id = #{deptId}
@@ -196,12 +229,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null ">
                 and lb.type = #{type}
             </if>
-                and lh.`type`=4 AND lh.`hardware_num` IS NOT NULL
+            and lh.`type`=4 AND lh.`hardware_num` IS NOT NULL
         </where>
 
     </select>
 
-    <select id="selectLabHardwareListBySubject" parameterType="com.zd.laboratory.domain.LabHardware" resultType="com.zd.laboratory.domain.LabHardware">
+    <select id="selectLabHardwareListBySubject" parameterType="com.zd.laboratory.domain.LabHardware"
+            resultType="com.zd.laboratory.domain.LabHardware">
         select
         id,
         name,
@@ -230,14 +264,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from
         lab_hardware
         <where>
-            <if test="subjectId != null "> and subject_id = #{subjectId}</if>
-            <if test="type != null" > and type = #{type}</if>
+            <if test="subjectId != null ">and subject_id = #{subjectId}</if>
+            <if test="type != null">and type = #{type}</if>
         </where>
     </select>
 
     <select id="selectStatistics" resultType="java.util.Map">
 
-        select xx.type, xx.operate operate, count(1) AS count from (SELECT h.`type`,IFNULL(h.operate,0) operate FROM `lab_hardware` h
+        select xx.type, xx.operate operate, count(1) AS count from (SELECT h.`type`,IFNULL(h.operate,0) operate FROM
+        `lab_hardware` h
         INNER JOIN lab_subject s ON s.id = h.subject_id
         <where>
             <!-- 数据范围过滤 -->
@@ -248,27 +283,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
-    <select id="getHardwareListBySubId" parameterType="com.zd.laboratory.domain.vo.LabHardwareVO" resultType="com.zd.laboratory.domain.LabHardware">
+    <select id="getHardwareListBySubId" parameterType="com.zd.laboratory.domain.vo.LabHardwareVO"
+            resultType="com.zd.laboratory.domain.LabHardware">
         SELECT h.* FROM lab_subject s INNER JOIN lab_hardware h ON s.`id` = h.`subject_id`
         <where>
-        h.`type` = 0
-        <if test="pcType != null ">
-            and h.pc_type = #{pcType}
-        </if>
-        <if test="deptId != null and deptId != '' ">
-            AND (s.dept_id = #{deptId} OR s.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
-            ancestors) ))
-        </if>
-        <if test="subjectIds != null ">
-            and s.`id` IN
-            <foreach item="subId" collection="subjectIds" open="(" separator="," close=")">
-                #{subId}
-            </foreach>
-        </if>
+            h.`type` = 0
+            <if test="pcType != null ">
+                and h.pc_type = #{pcType}
+            </if>
+            <if test="deptId != null and deptId != '' ">
+                AND (s.dept_id = #{deptId} OR s.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE
+                find_in_set(#{deptId},
+                ancestors) ))
+            </if>
+            <if test="subjectIds != null ">
+                and s.`id` IN
+                <foreach item="subId" collection="subjectIds" open="(" separator="," close=")">
+                    #{subId}
+                </foreach>
+            </if>
         </where>
     </select>
 
-    <select id="selectNewLabHardwareBySubIds"  resultMap="LabHardwareResult">
+    <select id="selectNewLabHardwareBySubIds" resultMap="LabHardwareResult">
         <include refid="selectLabHardwareVo"/>
         where xx.subject_id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
@@ -278,10 +315,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
-    <select id="selectLabHardwareByCabinetList" parameterType="com.zd.laboratory.domain.LabHardware" resultMap="LabHardwareVOResult">
+    <select id="selectLabHardwareByCabinetList" parameterType="com.zd.laboratory.domain.LabHardware"
+            resultMap="LabHardwareVOResult">
         <include refid="selectLabHardwareVo"/>
         <where>
-            <if test="type != null "> and xx.type = #{type}</if>
+            <if test="type != null ">and xx.type = #{type}</if>
             <if test="joinCabinet != null ">
                 and ct.id = #{joinCabinet}
             </if>
@@ -297,7 +335,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by xx.create_time desc
     </select>
 
-    <insert id="insertLabHardware" parameterType="com.zd.laboratory.domain.LabHardware" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertLabHardware" parameterType="com.zd.laboratory.domain.LabHardware" useGeneratedKeys="true"
+            keyProperty="id">
         insert into lab_hardware
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="id != null">id,</if>
@@ -407,36 +446,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </trim>
         where id = #{id}
     </update>
-<!--   更新设备继电器状态 -->
+    <!--   更新设备继电器状态 -->
     <update id="updateLabHardwareRelayCodeStatus" parameterType="com.zd.laboratory.domain.LabHardware">
         update lab_hardware
         set operate = #{operate}
         where
-            relay_code = #{relayCode}
-            <if test="bit != null">and `bit` = #{bit}</if>
+        relay_code = #{relayCode}
+        <if test="bit != null">and `bit` = #{bit}</if>
 
     </update>
     <!--   通用更新状态 -->
     <update id="updateLabHardwareStatus" parameterType="com.zd.laboratory.domain.LabHardware">
         update lab_hardware
-            set operate = #{operate}
-        where
-        hardware_num = #{hardwareNum}
+        set operate = #{operate}
+        where hardware_num = #{hardwareNum}
     </update>
     <update id="updateLabHardwareStatusById" parameterType="com.zd.laboratory.domain.LabHardware">
         update lab_hardware
-            set operate = #{operate}
-        where
-        id = #{id}
+        set operate = #{operate}
+        where id = #{id}
     </update>
 
-    <delete id="deleteLabHardwareById" >
-        delete from lab_hardware where id = #{id}
+    <delete id="deleteLabHardwareById">
+        delete
+        from lab_hardware
+        where id = #{id}
     </delete>
 
     <update id="setLock" parameterType="com.zd.laboratory.domain.vo.LabHardwareVO">
         update lab_hardware
-          set operate_time = #{operateTime}
+        set operate_time = #{operateTime}
         where id in
         <foreach item="id" collection="ids" open="(" separator="," close=")">
             #{id}
@@ -451,20 +490,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <!-- 根据设备类型查询-->
-    <select id="selectNewLabHardwareByTypes"  parameterType="com.zd.laboratory.domain.vo.LabHardwareVO" resultType="com.zd.laboratory.domain.LabHardware">
+    <select id="selectNewLabHardwareByTypes" parameterType="com.zd.laboratory.domain.vo.LabHardwareVO"
+            resultType="com.zd.laboratory.domain.LabHardware">
         <include refid="selectLabHardwareVo"/>
         where xx.type in
         <foreach item="id" collection="ids" open="(" separator="," close=")">
             #{id}
         </foreach>
-        <if test="subjectId != null "> and subject_id = #{subjectId}</if>
+        <if test="subjectId != null ">and subject_id = #{subjectId}</if>
         order by create_time
     </select>
 
 
     <update id="setLockJoinCabinet" parameterType="com.zd.laboratory.domain.LabHardware">
         update lab_hardware
-        set join_cabinet = #{joinCabinet},join_cabinet_time = #{joinCabinetTime}
+        set join_cabinet      = #{joinCabinet},
+            join_cabinet_time = #{joinCabinetTime}
         where id = #{id}
     </update>
 </mapper>

+ 1 - 1
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHazardSubjectRelationMapper.xml

@@ -8,7 +8,7 @@
         <result property="id" column="id"/>
         <result property="hazardId" column="hazard_id"/>
 <!--        <result property="containerId" column="container_id"/>-->
-        <result property="hazardType" column="hazard_type" />
+        <result property="hazardType" column="hazard_type" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler" />
         <result property="hazardId" column="hazard_id"/>
         <result property="subjectId" column="subject_id"/>
         <result property="identify" column="identify"/>

+ 85 - 73
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSensorMapper.xml

@@ -5,98 +5,104 @@
 <mapper namespace="com.zd.laboratory.mapper.LabSensorMapper">
 
     <resultMap type="com.zd.laboratory.domain.LabSensor" id="LabSensorResult">
-        <result property="id"    column="id"    />
-        <result property="name"    column="name"    />
-        <result property="factory"    column="factory"    />
-        <result property="type"    column="type"    />
-        <result property="gatewayId"    column="gateway_id"    />
-        <result property="senseData"    column="sense_data"    />
-        <result property="dataUpper"    column="data_upper"    />
-        <result property="dataLower"    column="data_lower"    />
-        <result property="macAdd"    column="mac_add"    />
-        <result property="subjectId"    column="subject_id"    />
-        <result property="deptId"    column="dept_id"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="deptName"    column="dept_name"    />
-        <result property="userId"    column="user_id"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="remark"    column="remark"    />
-        <result property="routeNum"    column="route_num"    />
-        <result property="senseState"    column="sense_state"    />
-        <result property="configName"    column="config_name"    />
-        <result property="configStatus"    column="config_status"    />
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="factory" column="factory"/>
+        <result property="type" column="type" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
+        <result property="gatewayId" column="gateway_id"/>
+        <result property="senseData" column="sense_data"/>
+        <result property="dataUpper" column="data_upper"/>
+        <result property="dataLower" column="data_lower"/>
+        <result property="macAdd" column="mac_add"/>
+        <result property="subjectId" column="subject_id"/>
+        <result property="deptId" column="dept_id"/>
+        <result property="createTime" column="create_time"/>
+        <result property="deptName" column="dept_name"/>
+        <result property="userId" column="user_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="remark" column="remark"/>
+        <result property="routeNum" column="route_num"/>
+        <result property="senseState" column="sense_state" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
+        <result property="configName" column="config_name"/>
+        <result property="configStatus" column="config_status"/>
 
     </resultMap>
 
     <resultMap type="com.zd.laboratory.domain.vo.LabSensorVO" id="LabSensorVOResult">
-        <result property="subjectName"    column="subject_name"    />
+        <result property="subjectName" column="subject_name"/>
     </resultMap>
 
-<!--   select id, name, factory, type, sense_data, data_upper, data_lower, mac_add, subject_id, dept_id, create_time, dept_name, user_id, create_by, update_time, update_by, remark from lab_sensor-->
+    <!--   select id, name, factory, type, sense_data, data_upper, data_lower, mac_add, subject_id, dept_id, create_time, dept_name, user_id, create_by, update_time, update_by, remark from lab_sensor-->
     <sql id="selectLabSensorVo">
-    select xx.* from(
-    SELECT
-          id,
-          NAME,
-          factory,
-          TYPE,
-          gateway_id,
-          sense_data,
-          data_upper,
-          data_lower,
-          sense_state,
-          mac_add,
-          subject_id,
-          route_num,
-          config_name,
-          config_status,
-          (SELECT s.name FROM lab_subject s WHERE s.id = subject_id) subject_name,
-          (SELECT d.dept_id FROM sys_dept d,lab_subject s WHERE s.dept_id = d.dept_id AND s.id = subject_id) dept_id,
-          (SELECT d.dept_name FROM sys_dept d,lab_subject s WHERE s.dept_id = d.dept_id AND s.id = subject_id) dept_name,
-          create_time,
-          user_id,
-          create_by,
-          update_time,
-          update_by,
-          remark
-        FROM
-          lab_sensor
-      )xx
+        select xx.*
+        from (SELECT id,
+                     NAME,
+                     factory,
+                     TYPE,
+                     gateway_id,
+                     sense_data,
+                     data_upper,
+                     data_lower,
+                     sense_state,
+                     mac_add,
+                     subject_id,
+                     route_num,
+                     config_name,
+                     config_status,
+                     (SELECT s.name FROM lab_subject s WHERE s.id = subject_id) subject_name,
+                     (SELECT d.dept_id
+                      FROM sys_dept d,
+                           lab_subject s
+                      WHERE s.dept_id = d.dept_id
+                        AND s.id = subject_id)                                  dept_id,
+                     (SELECT d.dept_name
+                      FROM sys_dept d,
+                           lab_subject s
+                      WHERE s.dept_id = d.dept_id
+                        AND s.id = subject_id)                                  dept_name,
+                     create_time,
+                     user_id,
+                     create_by,
+                     update_time,
+                     update_by,
+                     remark
+              FROM lab_sensor) xx
     </sql>
 
     <select id="selectLabSensorList" parameterType="com.zd.laboratory.domain.LabSensor" resultMap="LabSensorVOResult">
         <include refid="selectLabSensorVo"/>
         <where>
-            <if test="name != null  and name != ''"> and xx.name like concat('%', #{name}, '%')</if>
-            <if test="factory != null  and factory != ''"> and xx.factory = #{factory}</if>
-            <if test="type != null "> and xx.type = #{type}</if>
-            <if test="gatewayId != null and gatewayId!='' "> and xx.gateway_id = #{gatewayId}</if>
-            <if test="senseState != null "> and xx.sense_state = #{senseState}</if>
-            <if test="senseData != null "> and xx.sense_data = #{senseData}</if>
-            <if test="dataUpper != null "> and xx.data_upper = #{dataUpper}</if>
-            <if test="dataLower != null "> and xx.data_lower = #{dataLower}</if>
-            <if test="macAdd != null  and macAdd != ''"> and xx.mac_add = #{macAdd}</if>
-            <if test="subjectId != null "> and xx.subject_id = #{subjectId}</if>
+            <if test="name != null  and name != ''">and xx.name like concat('%', #{name}, '%')</if>
+            <if test="factory != null  and factory != ''">and xx.factory = #{factory}</if>
+            <if test="type != null ">and xx.type = #{type}</if>
+            <if test="gatewayId != null and gatewayId!='' ">and xx.gateway_id = #{gatewayId}</if>
+            <if test="senseState != null ">and xx.sense_state = #{senseState}</if>
+            <if test="senseData != null ">and xx.sense_data = #{senseData}</if>
+            <if test="dataUpper != null ">and xx.data_upper = #{dataUpper}</if>
+            <if test="dataLower != null ">and xx.data_lower = #{dataLower}</if>
+            <if test="macAdd != null  and macAdd != ''">and xx.mac_add = #{macAdd}</if>
+            <if test="subjectId != null ">and xx.subject_id = #{subjectId}</if>
             <if test="deptId != null ">
-                AND (xx.dept_id = #{deptId} OR xx.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
+                AND (xx.dept_id = #{deptId} OR xx.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE
+                find_in_set(#{deptId},
                 ancestors) ))
             </if>
-            <if test="deptName != null  and deptName != ''"> and xx.dept_name like concat('%', #{deptName}, '%')</if>
-            <if test="userId != null "> and xx.user_id = #{userId}</if>
+            <if test="deptName != null  and deptName != ''">and xx.dept_name like concat('%', #{deptName}, '%')</if>
+            <if test="userId != null ">and xx.user_id = #{userId}</if>
             <!-- 数据范围过滤 -->
             ${params.dataScope}
         </where>
         order by id desc
     </select>
 
-    <select id="selectLabSensorById"  resultMap="LabSensorResult">
+    <select id="selectLabSensorById" resultMap="LabSensorResult">
         <include refid="selectLabSensorVo"/>
         where id = #{id}
     </select>
     <!--   通过实验室ids查询设备 -->
-    <select id="selectSensorBySubIds"  resultMap="LabSensorResult">
+    <select id="selectSensorBySubIds" resultMap="LabSensorResult">
         SELECT
         id,
         NAME,
@@ -139,12 +145,16 @@
     </select>
 
     <select id="selectSensorCountBySubIds" resultType="java.lang.Integer">
-        select count(sx.id) from lab_sensor sx
-        inner join lab_subject s on s.id = sx.subject_id
-        where sx.subject_id=#{subjectId}
+        select count(sx.id)
+        from lab_sensor sx
+                 inner join lab_subject s on s.id = sx.subject_id
+        where sx.subject_id = #{subjectId}
     </select>
     <select id="selectHardWareList" resultType="com.zd.laboratory.domain.LabHardware">
-        SELECT subject_id  FROM  `lab_hardware` WHERE relay_code=#{gatewayNum} LIMIT 1
+        SELECT subject_id
+        FROM `lab_hardware`
+        WHERE relay_code = #{gatewayNum}
+        LIMIT 1
     </select>
 
     <insert id="insertLabSensor" parameterType="com.zd.laboratory.domain.LabSensor">
@@ -275,8 +285,10 @@
         </where>
     </update>
 
-    <delete id="deleteLabSensorById" >
-        delete from lab_sensor where id = #{id}
+    <delete id="deleteLabSensorById">
+        delete
+        from lab_sensor
+        where id = #{id}
     </delete>
 
     <delete id="deleteLabSensorByIds">