南昌市物联网技防平台-后台
Administrator
2021-08-27 16abd944c4331a31e99c28564c9b8a31bfbbfefc
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/mapper/AlarmMapper.xml
@@ -33,23 +33,41 @@
        <result column="cid" property="cid"/>
        <result column="vaddress" property="vaddress"/>
        <result column="aaddress" property="aaddress"/>
        <result column="uids" property="uids"/>
        <result column="securityArr" property="securityArr"/>
        <result column="securityId" property="securityId"/>
        <result column="baname" property="baname"/>
        <result column="baid" property="baid"/>
        <result column="deviceName" property="deviceName"/>
        <result column="baphone" property="baphone"/>
        <result column="manufacturers" property="manufacturers"/>
        <result column="alarmlb" property="alarmlb"/>
        <result column="alarmbs" property="alarmbs"/>
    </resultMap>
    <!-- 通用查询映射结果 -->
    <resultMap id="alarmonline" type="org.springblade.jfpt.alarm.vo.AlarmVO">
        <id column="alarmPeople" property="alarmPeople"/>
        <result column="alarmId" property="alarmId"/>
        <result column="phoneNumber" property="phoneNumber"/>
    </resultMap>
    <select id="selectAlarmPage" resultMap="alarmResultMap">
        select
        a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.bz,
        a.deviceNumber,a.region,a.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,a.province,a.city,a.cid,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
        e.stype,
        e.oneId,
        e.twoId,
        e.threeId,
        e.deptId,
        e.channelNumber from sys_alarm a
        LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber
        where 1=1
    <!-- 通用查询映射结果 -->
    <resultMap id="userResultMap" type="org.springblade.system.user.entity.User">
        <result column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="phone" property="phone"/>
        <result column="online_status" property="online_status"/>
        <result column="work_status" property="work_status"/>
    </resultMap>
    <sql id="alarmCondition">
        <if test="alarm.id!=null">
            and a.id = #{alarm.id}
        </if>
        <if test="alarm.alarmbs!=null">
            and a.alarmbs = #{alarm.alarmbs}
        </if>
        <if test="alarm.jtype!=null">
            and a.jtype like concat('%',#{alarm.jtype},'%')
        </if>
@@ -60,25 +78,83 @@
            and a.galarmPeople like concat('%',#{alarm.galarmPeople},'%')
        </if>
        <if test="alarm.district!=null">
            and a.district like concat('%',#{alarm.district},'%')
            and e.district like concat('%',#{alarm.district},'%')
        </if>
        <if test="alarm.province!=null">
            and a.province like concat('%',#{alarm.province},'%')
            and e.province like concat('%',#{alarm.province},'%')
        </if>
        <if test="alarm.city!=null">
            and a.city like concat('%',#{alarm.city},'%')
            and e.city like concat('%',#{alarm.city},'%')
        </if>
        <if test="alarm.level!=null">
            and a.level like concat('%',#{alarm.level},'%')
        </if>
        <if test="alarm.waringType!=null">
        <if test="alarm.waringType!=null and alarm.waringType!='undefined'">
            and a.waringType like concat('%',#{alarm.waringType},'%')
        </if>
        <if test="alarm.beginTime!=null and alarm.beginTime!=''">
        <if test="alarm.beginTime!=null and alarm.beginTime!='' and alarm.beginTime!='undefined'">
            and a.alarmTime&gt;=#{alarm.beginTime}
        </if>
        <if test="alarm.endTime!=null and alarm.endTime!=''">
        <if test="alarm.endTime!=null and alarm.endTime!='' and alarm.endTime!='undefined'">
            and a.alarmTime&lt;=#{alarm.endTime}
        </if>
        <if test="alarm.timeDesc!=null and alarm.timeDesc!='' and alarm.timeDesc!='undefined'">
            <if test="alarm.timeDesc=='30分钟以上'">
                and czTime-alarmTime>1800
            </if>
            <if test="alarm.timeDesc=='10-30分钟'">
                and czTime-alarmTime>600 and czTime-alarmTime &lt;1800
            </if>
            <if test="alarm.timeDesc=='5-10分钟'">
                and czTime-alarmTime>300 and czTime-alarmTime &lt;600
            </if>
            <if test="alarm.timeDesc=='小于5分钟'">
                and czTime-alarmTime>0 and czTime-alarmTime &lt;300
            </if>
            <if test="alarm.timeDesc=='0-2'">
                and hour(alarmTime)>=0 and hour(alarmTime) &lt;2
            </if>
            <if test="alarm.timeDesc=='2-4'">
                and hour(alarmTime)>=2 and hour(alarmTime) &lt;4
            </if>
            <if test="alarm.timeDesc=='4-6'">
                and hour(alarmTime)>=4 and hour(alarmTime) &lt;6
            </if>
            <if test="alarm.timeDesc=='6-8'">
                and hour(alarmTime)>=6 and hour(alarmTime) &lt;8
            </if>
            <if test="alarm.timeDesc=='8-10'">
                and hour(alarmTime)>=8 and hour(alarmTime) &lt;10
            </if>
            <if test="alarm.timeDesc=='10-12'">
                and hour(alarmTime)>=10 and hour(alarmTime) &lt;12
            </if>
            <if test="alarm.timeDesc=='12-14'">
                and hour(alarmTime)>=12 and hour(alarmTime) &lt;14
            </if>
            <if test="alarm.timeDesc=='14-16'">
                and hour(alarmTime)>=14 and hour(alarmTime) &lt;16
            </if>
            <if test="alarm.timeDesc=='16-18'">
                and hour(alarmTime)>=16 and hour(alarmTime) &lt;18
            </if>
            <if test="alarm.timeDesc=='18-20'">
                and hour(alarmTime)>=18 and hour(alarmTime) &lt;20
            </if>
            <if test="alarm.timeDesc=='20-22'">
                and hour(alarmTime)>=20 and hour(alarmTime) &lt;22
            </if>
            <if test="alarm.timeDesc=='22-24'">
                and hour(alarmTime)>=22 and hour(alarmTime) &lt;24
            </if>
        </if>
    </sql>
    <sql id="alarmConditionPie">
        <if test="alarm.beginTime!=null and alarm.beginTime!=''">
            and DATE_FORMAT(a.alarmTime,'%Y-%m-%d')&gt;=#{alarm.beginTime}
        </if>
        <if test="alarm.endTime!=null and alarm.endTime!=''">
            and DATE_FORMAT(a.alarmTime,'%Y-%m-%d')&lt;=#{alarm.endTime}
        </if>
        <if test="alarm.timeDesc!=null and alarm.timeDesc!=''">
            <if test="alarm.timeDesc=='30分钟以上'">
@@ -93,18 +169,264 @@
            <if test="alarm.timeDesc=='小于5分钟'">
                and czTime-alarmTime>0 and czTime-alarmTime &lt;300
            </if>
            <if test="alarm.timeDesc=='0-2'">
                and hour(alarmTime)>=0 and hour(alarmTime) &lt;2
            </if>
            <if test="alarm.timeDesc=='2-4'">
                and hour(alarmTime)>=2 and hour(alarmTime) &lt;4
            </if>
            <if test="alarm.timeDesc=='4-6'">
                and hour(alarmTime)>=4 and hour(alarmTime) &lt;6
            </if>
            <if test="alarm.timeDesc=='6-8'">
                and hour(alarmTime)>=6 and hour(alarmTime) &lt;8
            </if>
            <if test="alarm.timeDesc=='8-10'">
                and hour(alarmTime)>=8 and hour(alarmTime) &lt;10
            </if>
            <if test="alarm.timeDesc=='10-12'">
                and hour(alarmTime)>=10 and hour(alarmTime) &lt;12
            </if>
            <if test="alarm.timeDesc=='12-14'">
                and hour(alarmTime)>=12 and hour(alarmTime) &lt;14
            </if>
            <if test="alarm.timeDesc=='14-16'">
                and hour(alarmTime)>=14 and hour(alarmTime) &lt;16
            </if>
            <if test="alarm.timeDesc=='16-18'">
                and hour(alarmTime)>=16 and hour(alarmTime) &lt;18
            </if>
            <if test="alarm.timeDesc=='18-20'">
                and hour(alarmTime)>=18 and hour(alarmTime) &lt;20
            </if>
            <if test="alarm.timeDesc=='20-22'">
                and hour(alarmTime)>=20 and hour(alarmTime) &lt;22
            </if>
            <if test="alarm.timeDesc=='22-24'">
                and hour(alarmTime)>=22 and hour(alarmTime) &lt;24
            </if>
        </if>
    </sql>
    <select id="selectAlarmPage" resultMap="alarmResultMap">
        select
        a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.content,a.waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,
        a.securityArr,a.securityId,a.alarmlb,a.alarmbs,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
        e.stype,
        e.oneId,
        e.twoId,
        e.threeId,
        e.deptId,
        e.manufacturers,
        e.street as place,
        e.channelNumber,
        u.name as baname,
        u.id as baid,
        u.phone as baphone
        from sys_alarm a
        LEFT JOIN
        sys_equipment e on e.deviceNumber=a.deviceNumber
        LEFT JOIN jfpth.blade_user u ON u.id = a.securityId
        where 1=1
        <include refid="alarmCondition"></include>
        and a.waringType IN("紧急求救")
        ORDER BY
        a.jtype ASC,
        a.alarmTime DESC
    </select>
    <select id="selectazPage" resultMap="alarmResultMap">
        SELECT
        *
        FROM
            sys_alarm
        WHERE
            1 = 1
            <if test="alarm.district!=null">
                and district like concat('%',#{alarm.district},'%')
            </if>
            <if test="alarm.province!=null">
                and province like concat('%',#{alarm.province},'%')
            </if>
            <if test="alarm.city!=null">
                and city like concat('%',#{alarm.city},'%')
            </if>
            <if test="alarm.alarmPeople!=null">
                and alarmPeople like concat('%',#{alarm.alarmPeople},'%')
            </if>
            <if test="alarm.jtype!=null">
                and jtype = #{alarm.jtype}
            </if>
            AND waringType IN ( "安装任务" )
        ORDER BY
            jtype ASC,
            alarmTime DESC
    </select>
    <select id="getChartData" resultType="java.util.Map">
        SELECT
            COUNT( * ) AS value,
            "未安装" as name
        FROM
            sys_alarm
        WHERE
            1 = 1
        <if test="beginTime!=null and beginTime!=''">
            and alarmTime&gt;=#{beginTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and alarmTime&lt;=#{endTime}
        </if>
            AND jtype = 0
            AND waringType IN ( "安装任务" ) UNION ALL
        SELECT
            COUNT( * ) AS value,
            "已安装" as name
        FROM
            sys_alarm
        WHERE
            1 = 1
        <if test="beginTime!=null and beginTime!=''">
            and alarmTime&gt;=#{beginTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and alarmTime&lt;=#{endTime}
        </if>
            AND jtype = 2
            AND waringType IN ( "安装任务" )
    </select>
    <select id="getChartDataAlarm" resultType="java.util.Map">
        SELECT
            COUNT( * ) AS
        value
            ,
            "未处理" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
        <if test="beginTime!=null and beginTime!=''">
            and alarmTime&gt;=#{beginTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and alarmTime&lt;=#{endTime}
        </if>
            AND jtype = 0
            AND waringType IN ( "紧急求救" ) UNION ALL
        SELECT
            COUNT( * ) AS
        value
            ,
            "处理中" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
        <if test="beginTime!=null and beginTime!=''">
            and alarmTime&gt;=#{beginTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and alarmTime&lt;=#{endTime}
        </if>
            AND jtype = 1
            AND waringType IN ( "紧急求救" )
            UNION ALL
        SELECT
            COUNT( * ) AS
        value
            ,
            "已处理" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
        <if test="beginTime!=null and beginTime!=''">
            and alarmTime&gt;=#{beginTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and alarmTime&lt;=#{endTime}
        </if>
            AND jtype = 2
            AND waringType IN ( "紧急求救" )
    </select>
    <select id="getChartDataAlarmBs" resultType="java.util.Map">
        SELECT
            COUNT( * ) AS
        value
            ,
            "一般警情" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
        <if test="beginTime!=null and beginTime!=''">
            and alarmTime&gt;=#{beginTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and alarmTime&lt;=#{endTime}
        </if>
            AND alarmbs = 0
            AND waringType IN ( "紧急求救" ) UNION ALL
        SELECT
            COUNT( * ) AS
        value
            ,
            "误报警情" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
        <if test="beginTime!=null and beginTime!=''">
            and alarmTime&gt;=#{beginTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and alarmTime&lt;=#{endTime}
        </if>
            AND alarmbs = 1
            AND waringType IN ( "紧急求救" )
            UNION ALL
        SELECT
            COUNT( * ) AS
        value
            ,
            "严重警情" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
        <if test="beginTime!=null and beginTime!=''">
            and alarmTime&gt;=#{beginTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and alarmTime&lt;=#{endTime}
        </if>
            AND alarmbs = 2
            AND waringType IN ( "紧急求救" )
    </select>
    <select id="listAll" resultMap="alarmResultMap">
       select a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,
        a.deviceNumber,a.region,a.district, a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,a.province,a.city,a.cid,a.vaddress
        a.deviceNumber,a.region,e.district, a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,a.vaddress
         from sys_alarm a LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber
    </select>
@@ -124,7 +446,7 @@
        a.deviceNumber,
        a.vaddress,
        a.region,
        a.district,
        e.district,
        a.alarmId,
        a.czTime,
        a.bz,
@@ -212,9 +534,9 @@
        a.waringType,
        a.deviceNumber,
        a.region,
        a.district,
        a.province,
        a.city,
        e.district,
        e.province,
        e.city,
        a.alarmId,
        a.rname,
        a.LEVEL,
@@ -267,40 +589,55 @@
    <select id="selectListSe" resultMap="alarmResultMap">
        SELECT
        a.id,
        a.alarmType,
        a.alarmPeople,
        a.alarmTime,
        a.galarmPeople,
        a.sex,
        a.phoneNumber,
        a.place,
        a.content,
        a.waringType,
        a.deviceNumber,
        a.region,
        a.district,
        a.alarmId,
        a.LEVEL,
        a.jd,
        a.cid,
        a.wd,
        a.jtype,
        a.rname,
        e.serialNumber,
        a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,"一键求助" as waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
        e.stype,
        e.oneId,
        e.twoId,
        e.threeId,
        e.deptId,
        a.alarmlb,
        e.manufacturers,
        e.channelNumber,
        jfpth.blade_region.`name` as addvnm
        FROM
        sys_alarm a LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber LEFT JOIN jfpth.blade_region on jfpth.blade_region.`code`=a.district where
        DATE_FORMAT(alarmTime,'%Y-%m-%d') &gt;=#{beginTime} and DATE_FORMAT(alarmTime,'%Y-%m-%d') &lt;=#{endTime} and a.waringType NOT IN("系统测试","主机重新上电") ORDER BY alarmTime desc
        sys_alarm a
        LEFT JOIN sys_equipment e
        on
        e.deviceNumber=a.deviceNumber
        LEFT JOIN
        jfpth.blade_region
        on
        jfpth.blade_region.`code`=a.district
        where
        DATE_FORMAT(alarmTime,'%Y-%m-%d') &gt;=#{beginTime}
        and DATE_FORMAT(alarmTime,'%Y-%m-%d') &lt;=#{endTime}
        and a.waringType  IN("紧急求救")
        ORDER BY
        a.jtype ASC,
        a.alarmTime DESC
    </select>
    <update id="updateJtype">
        update sys_alarm SET jtype=#{jtype},bz=#{bz} where id=#{id}
        update sys_alarm SET jtype=#{jtype}
        <if test="bz!=null and bz!=''">
            ,bz=#{bz}
        </if>
        <if test="securityArr!=null and securityArr!=''">
            ,securityArr =#{securityArr}
        </if>
        <if test="bs!=null and bs!=''">
            ,alarmbs =#{bs}
        </if>
        where id=#{id}
    </update>
    <update id="updatePoliceStatus">
@@ -399,16 +736,17 @@
    </select>
    <select id="queryPolice" resultType="java.util.HashMap">
    <select id="queryPolice" resultMap="userResultMap">
        SELECT * FROM jfpth.blade_user WHERE is_deleted != '1' and role_id ="1372092102682521602"
    </select>
    <select id="queryPoliceTime" resultType="java.util.HashMap">
    <select id="queryPoliceTime" resultMap="alarmonline">
        SELECT
        a.alarmPeople,
        a.alarmId,
        a.phoneNumber,
        max( a.jjTime ) AS jjTime
        FROM
        sys_alarm a
@@ -423,7 +761,8 @@
        </if>
        GROUP BY
        a.alarmPeople,
        a.alarmId
        a.alarmId,
        a.phoneNumber
        ORDER BY
        jjTime
        LIMIT 1
@@ -449,8 +788,72 @@
        AND role_id = "1370562810882502657"
    </select>
    <select id="getAlarm" resultMap="alarmResultMap">
        select
        a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.content,a.waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,
        a.securityArr,a.securityId,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
        e.stype,
        e.oneId,
        e.twoId,
        e.deviceName,
        e.threeId,
        e.deptId,
        e.street as place,
        e.channelNumber
        FROM
        sys_alarm a
        LEFT JOIN sys_equipment e ON e.deviceNumber = a.deviceNumber
        WHERE
        <if test="alarm.securityArr!=null and alarm.securityArr!=''">
            (securityId = "" or securityId IS NULL)
            AND jtype != 2
            AND securityArr LIKE concat('%',#{alarm.securityArr},'%')
        </if>
        <if test="alarm.id!=null and alarm.id!=''">
            a.id = #{alarm.id}
        </if>
    </select>
    <select id="getAlarming" resultMap="alarmResultMap">
        select
        a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.content,a.waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,
        a.securityArr,a.securityId,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
        e.stype,
        e.oneId,
        e.twoId,
        e.threeId,
        e.deviceName,
        e.deptId,
        e.street as place,
        e.channelNumber
        FROM
            sys_alarm a
            LEFT JOIN sys_equipment e ON e.deviceNumber = a.deviceNumber
        WHERE
            securityId =#{alarm.securityId} and jtype != 2
    </select>
    <update id="setAlarm">
        update sys_alarm SET securityId=#{alarm.securityId} where id=#{alarm.id}
    </update>
    <update id="updateVaddress">
        update sys_alarm SET vaddress=#{vaddress} where id=#{jid}
    </update>
    <update id="updateAaddress">
        update sys_alarm SET aaddress=#{aaddress} where id=#{jid}
    </update>
@@ -491,6 +894,7 @@
        ) b
        on
        a.days = b.datetime
        order by days
    </select>
@@ -516,4 +920,36 @@
    </select>
    <!--查询符合条件的数据并导出-->
    <select id="exportAlarm" resultType="org.springblade.common.entity.AlarmExcel">
        select
        a.id, "一键求助" as
        alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone
        from sys_alarm a
        LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber
        where 1=1
        <include refid="alarmCondition"></include>
        and a.waringType IN("紧急求救")
        ORDER BY
        a.jtype ASC,
        a.alarmTime DESC
    </select>
    <!--获取实时警情图表统计数据-->
    <select id="getAlarmPie" resultType="org.springblade.common.entity.ReportReturnData">
        select if(1=1,"一键求助",0) type,ifnull(count(*),0) count from sys_alarm
        where waringType="紧急求救"
        <include refid="alarmConditionPie"></include>
    </select>
    <!--查询未处理及处理中的警情总数量-->
    <select id="selectEqCount" resultType="Integer">
        SELECT ifnull(count(*),0) count  FROM `sys_alarm`
        where deviceNumber = #{deviceNumber}
        and jtype!=2
    </select>
</mapper>