南昌市物联网技防平台-后台
zengh
2021-05-11 47a458ca867f700ad8dfe8bccdbb6bf59ca2d301
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/equipment/mapper/EquipmentMapper.xml
@@ -29,6 +29,8 @@
        <result column="district" property="district"/>
        <result column="state" property="state"/>
        <result column="reason" property="reason"/>
        <result column="jtype" property="jtype"/>
        <result column="manufacturers" property="manufacturers"/>
    </resultMap>
    <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
@@ -75,7 +77,19 @@
        equipment.deptId,
        equipment.addvcd,equipment.pay,equipment.expireTime from sys_equipment equipment
        left join sys_catalog catalog on catalog.eqid = equipment.deviceNumber
        LEFT JOIN (
        SELECT
        count( id ) AS jtype,
        deviceNumber as deviceN
        FROM
        sys_alarm
        WHERE
        waringType = "紧急求救"
        AND jtype = 0
        OR jtype = 1
        GROUP BY
        deviceNumber
        ) alarm ON alarm.deviceN = equipment.deviceNumber
        where 1=1
        <if test="equipment.deviceName!=null">
@@ -118,7 +132,8 @@
    </select>
    <select id="selectDeptPages" resultMap="equipmentResultMap">
        select equipment.id,equipment.deviceName,equipment.deviceNumber,equipment.deviceType,equipment.ownership
        select IF
        ( alarm.jtype IS NULL, 0, 1 ) AS jtype,equipment.id,equipment.deviceName,equipment.deviceNumber,equipment.deviceType,equipment.ownership
        ,equipment.ownerId,equipment.devicestate,equipment.stime,equipment.dtype,equipment.heartbeat,equipment.expireTime,
        equipment.parent_id,equipment.district,equipment.province,equipment.city,equipment.serialNumber,equipment.channelNumber,
        equipment.jd ,
@@ -128,24 +143,33 @@
        equipment.oneContacts,equipment.onePhone,equipment.oneId,
        equipment.twoContacts,equipment.twoPhone,equipment.twoId,
        equipment.ThreeContacts,equipment.ThreePhone,equipment.threeId,
        equipment.deptId,
        equipment.deptId,equipment.manufacturers,
        equipment.addvcd,equipment.pay,equipment.expireTime from sys_equipment equipment
        left join sys_catalog catalog on catalog.eqid = equipment.deviceNumber
        LEFT JOIN (
        SELECT
        count( id ) AS jtype,
        deviceNumber as deviceN
        FROM
        sys_alarm
        WHERE
        waringType = "紧急求救"
        AND jtype = 0
        OR jtype = 1
        GROUP BY
        deviceNumber
        ) alarm ON alarm.deviceN = equipment.deviceNumber
        where 1=1
        <if test="equipment.deviceName!=null">
            and (deviceName like concat('%',#{equipment.deviceName},'%') or deviceNumber like
            concat('%',#{equipment.deviceName},'%'))
        </if>
        <if test="equipment.beginTime!=null and equipment.beginTime!=''">
            and expireTime&gt;=#{equipment.beginTime}
        </if>
        <if test="equipment.endTime!=null and equipment.endTime!=''">
            and expireTime&lt;=#{equipment.endTime}
        </if>
        <if test="equipment.district!=null">
            and district like concat('%',#{equipment.district},'%')
        </if>
@@ -155,31 +179,47 @@
        <if test="equipment.city!=null">
            and city like concat('%',#{equipment.city},'%')
        </if>
        <if test="equipment.manufacturers!=null and equipment.manufacturers!=''">
            and manufacturers = #{equipment.manufacturers}
        </if>
        <if test="equipment.devicestate!=null">
            and devicestate =#{equipment.devicestate}
        </if>
        <if test="equipment.dtype!=null">
            and dtype=#{equipment.dtype}
        </if>
        <if test="dxtype!=null">
            and heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY)
        <if test="dxtype!=null and dxtype == 0">
            and heartbeat &lt; DATE_SUB(NOW(),INTERVAL 1 DAY)  and dtype=0
        </if>
        <if test="childList!=null and childList.size>0">
            and deptId in
            <foreach collection="childList" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        <if test="dxtype!=null and dxtype == 1">
            and heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=1
        </if>
        <if test="dxtype!=null and dxtype == 2">
            and heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=2
        </if>
        <if test="dxtype!=null and dxtype == 3">
            and heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY)  and dtype=3
        </if>
        <if test="pid!=null and pid!=''">
            and deptId like concat('%',#{pid},'%')
        </if>
        order by (
            case
                when dtype=2  then 1
                when dtype=3 then 2
                when dtype=0  then 3
                when dtype=1  then 4
            END)
    </select>
    <!--新增-->
    <insert id="s" parameterType="org.springblade.jfpt.equipment.entity.Equipment">
       INSERT INTO sys_equipment (deviceName,deviceNumber,deviceType,ownership,ownerId,devicestate,stime,coordinate,parent_id,jd,wd,addvcd,street,dtype) VALUES (#{deviceName},#{deviceNumber},#{deviceType},#{ownership},#{yname},#{devicestate},#{stime},POINT(#{jd},#{wd}),#{parentId},#{jd},#{wd},#{addvcd},#{streeName},#{dtype})
       INSERT INTO sys_equipment (deviceName,deviceNumber,deviceType,ownership,ownerId,devicestate,stime,coordinate,parent_id,jd,wd,addvcd,street,dtype,manufacturers) VALUES (#{deviceName},#{deviceNumber},#{deviceType},#{ownership},#{yname},#{devicestate},#{stime},POINT(#{jd},#{wd}),#{parentId},#{jd},#{wd},#{addvcd},#{streeName},#{dtype},#{manufacturers})
    </insert>
    <!--新增-->
    <insert id="saveImg" parameterType="org.springblade.jfpt.equipment.entity.Equipment">
       INSERT INTO sys_depl (deviceName,deviceNumber,contacts,calls,paddress,deploymentTime) VALUES (#{deviceName},#{deviceNumber},#{contacts},#{call},#{paddress},#{deploymentTime})
    </insert>
    <select id="tree" resultMap="treeNodeResultMap">
@@ -187,6 +227,74 @@
    </select>
    <select id="listAll" resultMap="equipmentResultMap">
        SELECT
        IF
        ( alarm.jtype IS NULL, 0, 1 ) AS jtype,
        equipment.id,
        equipment.deviceName,
        equipment.deviceNumber,
        equipment.deviceType,
        equipment.ownership,
        equipment.ownerId,
        equipment.devicestate,
        equipment.stime,
        equipment.dtype,
        equipment.heartbeat,
        equipment.expireTime,
        equipment.parent_id,
        equipment.district,
        equipment.province,
        equipment.city,
        equipment.serialNumber,
        equipment.channelNumber,
        equipment.jd,
        equipment.wd,
        equipment.state,
        equipment.reason,
        equipment.street,
        catalog.pid,
        equipment.oneContacts,
        equipment.onePhone,
        equipment.oneId,
        equipment.twoContacts,
        equipment.twoPhone,
        equipment.twoId,
        equipment.ThreeContacts,
        equipment.ThreePhone,
        equipment.threeId,
        equipment.deptId,
        equipment.addvcd,
        equipment.pay,
        equipment.expireTime
        FROM
        sys_equipment equipment
        LEFT JOIN sys_catalog catalog ON catalog.eqid = equipment.deviceNumber
        LEFT JOIN (
        SELECT
        count( id ) AS jtype,
        deviceNumber as deviceN
        FROM
        sys_alarm
        WHERE
        waringType = "紧急求救"
        AND jtype = 0
        OR jtype = 1
        GROUP BY
        deviceNumber
        ) alarm ON alarm.deviceN = equipment.deviceNumber
        WHERE
        1 =1
        <if test="equipment.deviceName!=null and equipment.deviceName!=''">
            and (
            deviceName like concat('%',#{equipment.deviceName},'%')
            or deviceNumber like concat('%',#{equipment.deviceName},'%')
            or street like concat('%',#{equipment.deviceName},'%')
            )
        </if>
    </select>
    <select id="listAlls" resultMap="equipmentResultMap">
          select equipment.id,equipment.deviceName,equipment.deviceNumber,equipment.deviceType,equipment.ownership
        ,equipment.ownerId,equipment.devicestate,equipment.stime,equipment.dtype,equipment.heartbeat,equipment.expireTime,
        equipment.parent_id,equipment.district,equipment.province,equipment.city,equipment.serialNumber,equipment.channelNumber,
@@ -244,8 +352,9 @@
    <update id="updateOne" parameterType="org.springblade.jfpt.equipment.entity.Equipment">
    update sys_equipment SET deviceName=#{deviceName},deviceNumber=#{deviceNumber},deviceType=#{deviceType},
    ownership=#{ownership},ownerId=#{yname},devicestate=#{devicestate},stime=#{stime},
    coordinate=POINT(#{jd},#{wd}),parent_id=#{parentId},jd=#{jd},wd=#{wd},addvcd=#{addvnm},street=#{streeName},dtype=#{dtype} where id=#{id}
    ownership=#{ownership},ownerId=#{yname},devicestate=#{devicestate},stime=#{stime},coordinate=POINT(#{jd},#{wd}),
    parent_id=#{parentId},jd=#{jd},wd=#{wd},addvcd=#{addvnm},street=#{streeName},dtype=#{dtype},manufacturers=#{manufacturers}
     where id=#{id}
    </update>
    <update id="updataType">
@@ -261,7 +370,7 @@
        SELECT
        dept.deptId,dept.id,dept.deviceName,dept.deviceNumber,dept.deviceType,dept.ownership,
        dept.ownerId,dept.devicestate,dept.stime,dept.district,dept.province,dept.city,
        ST_ASTEXT(dept.coordinate) as coordinate,dept.dtype,dept.expireTime,dept.heartbeat, dept.state,dept.reason,
        ST_ASTEXT(dept.coordinate) as coordinate,dept.dtype,dept.manufacturers,dept.expireTime,dept.heartbeat, dept.state,dept.reason,
        dept.parent_id,dept.jd,dept.wd,dept.street,u.yname,d.addvnm,dept.addvcd,dept.serialNumber,dept.channelNumber,
        dept.oneContacts,dept.onePhone,dept.oneId,
        dept.twoContacts,dept.twoPhone,dept.twoId,
@@ -331,7 +440,67 @@
    </update>
    <update id="updateExstate">
        update sys_equipment SET state=#{state},reason=#{reason}  where deviceNumber=#{deviceNumber}
        update sys_equipment SET dtype=#{dtype},reason=#{reason}  where deviceNumber=#{deviceNumber}
    </update>
    <!--查询设备在线数量-->
    <select id="selectEqCz" resultType="Integer">
        select COUNT(*) from sys_equipment where heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=1
    </select>
    <!--查询设备掉线数量-->
    <select id="selectEqCd" resultType="Integer">
        select COUNT(*) from sys_equipment where heartbeat &lt; DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=0
    </select>
    <!--查询预警设备数量-->
    <select id="selectEqCy" resultType="java.util.HashMap">
        SELECT
            count( id ) AS jtype,
            deviceNumber
        FROM
            sys_alarm
        WHERE
            waringType = "紧急求救"
            AND jtype = 0
            OR jtype = 1
        GROUP BY
            deviceNumber
    </select>
    <!--查询预警设备数量-->
    <select id="selectEqCys" resultType="Integer">
        select COUNT(*) from sys_equipment where heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=2
    </select>
    <!--查询设故障数量-->
    <select id="selectEqCg" resultType="Integer">
        select COUNT(*) from sys_equipment where heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=3
    </select>
    <!--查询所有的设备,不包含故障和警情状态-->
    <select id="selAllEq" resultType="org.springblade.jfpt.equipment.entity.Equipment">
       select id,dtype,heartbeat from sys_equipment where dtype!=2 and dtype!=3
    </select>
    <!--批量更新设备状态改为在线-->
    <update id="updateEqListz" parameterType="java.util.Map">
        UPDATE sys_equipment
            SET dtype = 1
        WHERE id IN
        <foreach collection="equipmentListz" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <!--批量更新设备状态改为离线-->
    <update id="updateEqListl" parameterType="java.util.Map">
        UPDATE sys_equipment
            SET dtype = 0
        WHERE id IN
        <foreach collection="equipmentListl" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
</mapper>