南昌市物联网技防平台-后台
Administrator
2021-04-08 2c2b1ab406d3049a0e69fff01e3daade5cbe90ea
预警数量统计接口修改,新增按时间条件查询条件,违禁品统计接口修改
5 files modified
201 ■■■■ changed files
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/mapper/AlarmMapper.xml 117 ●●●●● patch | view | raw | blame | history
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/service/impl/AlarmServiceImpl.java 47 ●●●● patch | view | raw | blame | history
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/vo/AlarmVO.java 1 ●●●● patch | view | raw | blame | history
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java 26 ●●●● patch | view | raw | blame | history
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/vo/ConditionVo.java 10 ●●●●● patch | view | raw | blame | history
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/mapper/AlarmMapper.xml
@@ -80,6 +80,20 @@
        <if test="alarm.endTime!=null and alarm.endTime!=''">
            and a.alarmTime&lt;=#{alarm.endTime}
        </if>
        <if test="alarm.timeDesc!=null and alarm.timeDesc!=''">
            <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>
        and a.waringType IN("紧急求救")
@@ -296,10 +310,14 @@
    <!--查询当天警情总数-->
    <select id="selectAlarmCount" resultType="java.lang.Integer">
        SELECT count(*) FROM `sys_alarm`
            where
        where
        waringType = '紧急求救'
            and
        to_days(alarmTime) = to_days(curdate())
        <if test="conditionVo.status==0">
            and to_days(alarmTime) = to_days(curdate())
        </if>
        <if test="conditionVo.startTime!=null and conditionVo.startTime!='' and conditionVo.endTime!=null and conditionVo.endTime!=''">
            and alarmTime between #{conditionVo.startTime} and #{conditionVo.endTime}
        </if>
    </select>
@@ -332,46 +350,26 @@
         order by a.click_date asc
    </select>
    <!--查询警情当前时间段内每天的数据-->
    <select id="selectTimeAlarmData" resultType="java.lang.Integer">
       select a.days, ifnull(count,0) count from
            (
                SELECT @date := DATE_ADD( @date, INTERVAL + 1 DAY ) days FROM
                (
                    SELECT @date := DATE_ADD( #{conditionVo.startTime}, INTERVAL - 1 DAY ) FROM sys_date
                ) time
                    WHERE to_days( @date ) &lt; to_days( #{conditionVo.endTime} )
            ) a
            left join
            (
            select DATE_FORMAT(alarmTime,'%Y-%m-%d') as datetime, count(*) as count from sys_alarm
            where waringType = '紧急求救'
            group by DATE_FORMAT(alarmTime,'%Y-%m-%d')
            ) b
            on
            a.days = b.datetime
    </select>
<!--    &lt;!&ndash;查询本日,本周,本月 主动报警的数量&ndash;&gt;-->
<!--    <select id="selectAlarmSum" resultType="java.util.HashMap">-->
<!--        select sa.alarmType name,IFNULL(sb.count, 0) value from (select alarmType from sys_alarm GROUP BY alarmType) sa-->
<!--        left join-->
<!--        ( select alarmType,count(*) count from sys_alarm-->
<!--        where 1=1-->
<!--        <if test="conditionVo.status==0">-->
<!--            and to_days(alarmTime) = to_days(now())-->
<!--        </if>-->
<!--        <if test="conditionVo.status==1">-->
<!--            and YEARWEEK(date_format(alarmTime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)-->
<!--        </if>-->
<!--        <if test="conditionVo.status==2">-->
<!--            and date_format(alarmTime,'%Y%m') = date_format(now(),'%Y%m')-->
<!--        </if>-->
<!--        group by alarmType-->
<!--        ) sb-->
<!--        on-->
<!--        sa.alarmType = sb.alarmType-->
<!--    </select>-->
    <!--    &lt;!&ndash;查询本日,本周,本月 主动报警的数量&ndash;&gt;-->
    <!--    <select id="selectAlarmSum" resultType="java.util.HashMap">-->
    <!--        select sa.alarmType name,IFNULL(sb.count, 0) value from (select alarmType from sys_alarm GROUP BY alarmType) sa-->
    <!--        left join-->
    <!--        ( select alarmType,count(*) count from sys_alarm-->
    <!--        where 1=1-->
    <!--        <if test="conditionVo.status==0">-->
    <!--            and to_days(alarmTime) = to_days(now())-->
    <!--        </if>-->
    <!--        <if test="conditionVo.status==1">-->
    <!--            and YEARWEEK(date_format(alarmTime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)-->
    <!--        </if>-->
    <!--        <if test="conditionVo.status==2">-->
    <!--            and date_format(alarmTime,'%Y%m') = date_format(now(),'%Y%m')-->
    <!--        </if>-->
    <!--        group by alarmType-->
    <!--        ) sb-->
    <!--        on-->
    <!--        sa.alarmType = sb.alarmType-->
    <!--    </select>-->
    <!--查询本日,本周,本月 主动报警的数量-->
    <select id="selectAlarmSum" resultType="java.util.HashMap">
@@ -409,13 +407,13 @@
    <select id="queryPoliceTime" resultType="java.util.HashMap">
        SELECT
            a.alarmPeople,
            a.alarmId,
            max( a.jjTime ) AS jjTime
        a.alarmPeople,
        a.alarmId,
        max( a.jjTime ) AS jjTime
        FROM
            sys_alarm a
        sys_alarm a
        WHERE
            1 =1
        1 =1
        <if test="policeIdArr!=null and policeIdArr.size>0">
            and alarmId in
@@ -493,28 +491,5 @@
        ) b
        on
        a.days = b.datetime
    </select>
    <!--查询本年所有月份的预警数量-->
    <select id="queryYearAlarm" resultType="java.util.HashMap">
        <if test="childList!=null and childList.size>0">
            <foreach collection="childList" index="index" item="item" open="" separator="union all" close="">
                SELECT
                #{item} as month,count(ce.id) as count
                FROM
                sys_alarm as ce
                WHERE
                YEAR ( alarmTime ) = date_format(now(),'%Y%')
                AND MONTH ( alarmTime ) = #{item}
                AND waringType = "紧急求救"
                AND deviceNumber = #{deviceNumber}
            </foreach>
        </if>
    </select>
</mapper>
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/service/impl/AlarmServiceImpl.java
@@ -228,30 +228,31 @@
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }else {
                long nowTime = new Date().getTime();
                try {
                    long alarmTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(alarm.getAlarmTime()).getTime();
                    //0-5分钟
                    if (nowTime-alarmTime>0 && nowTime-alarmTime<AlarmTimeConstant.FIVE_TIME){
                        count05+=1;
                    }
                    //5-10分钟
                    if (nowTime-alarmTime>=AlarmTimeConstant.FIVE_TIME && nowTime-alarmTime<AlarmTimeConstant.TEN_TIME){
                        count0510+=1;
                    }
                    //10-30分钟
                    if (nowTime-alarmTime>=AlarmTimeConstant.TEN_TIME && nowTime-alarmTime<AlarmTimeConstant.THIRTY_TIME){
                        count1030+=1;
                    }
                    //30分钟以上
                    if (nowTime-alarmTime>=AlarmTimeConstant.THIRTY_TIME){
                        count30+=1;
                    }
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
//            else {
//                long nowTime = new Date().getTime();
//                try {
//                    long alarmTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(alarm.getAlarmTime()).getTime();
//                    //0-5分钟
//                    if (nowTime-alarmTime>0 && nowTime-alarmTime<AlarmTimeConstant.FIVE_TIME){
//                        count05+=1;
//                    }
//                    //5-10分钟
//                    if (nowTime-alarmTime>=AlarmTimeConstant.FIVE_TIME && nowTime-alarmTime<AlarmTimeConstant.TEN_TIME){
//                        count0510+=1;
//                    }
//                    //10-30分钟
//                    if (nowTime-alarmTime>=AlarmTimeConstant.TEN_TIME && nowTime-alarmTime<AlarmTimeConstant.THIRTY_TIME){
//                        count1030+=1;
//                    }
//                    //30分钟以上
//                    if (nowTime-alarmTime>=AlarmTimeConstant.THIRTY_TIME){
//                        count30+=1;
//                    }
//                } catch (ParseException e) {
//                    e.printStackTrace();
//                }
//            }
        }
        //封装数据
        list.add(count05);
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/vo/AlarmVO.java
@@ -49,4 +49,5 @@
    private String twoId;
    private String threeId;
    private String deptId;
    private String timeDesc;
}
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/service/impl/ParcelServiceImpl.java
@@ -237,16 +237,26 @@
        //获取包裹数据
        List<Object> parcelData = getParcelData(conditionVo, PARCEL_URL, PARCEL_KEY, PARCEL_SECRET);
        if (null!=parcelData) {
            //查询当天的包裹总数
            Integer dangerCount = null;
            Integer contrabandCount = null;
            conditionVo.setStatus(0);
            if (conditionVo.getStatus() == 0) {
            //声明包裹和物品数量
            Integer dangerCount = 0;
            Integer contrabandCount = 0;
            if (null!=conditionVo.getStartTime()){
                for (Object object : parcelData) {
                    //取出list里面的值转为map
                    Map<String, Object> objectMap = (Map<String, Object>) object;
                    dangerCount = Integer.parseInt(objectMap.get("dangerCount").toString()); //违禁包裹数量
                    contrabandCount = Integer.parseInt(objectMap.get("contrabandCount").toString()); //违禁物品数量
                    dangerCount += Integer.parseInt(objectMap.get("dangerCount").toString()); //违禁包裹数量
                    contrabandCount += Integer.parseInt(objectMap.get("contrabandCount").toString()); //违禁物品数量
                }
            }else {
                //查询当天的包裹总数
                conditionVo.setStatus(0);
                if (conditionVo.getStatus() == 0) {
                    for (Object object : parcelData) {
                        //取出list里面的值转为map
                        Map<String, Object> objectMap = (Map<String, Object>) object;
                        dangerCount = Integer.parseInt(objectMap.get("dangerCount").toString()); //违禁包裹数量
                        contrabandCount = Integer.parseInt(objectMap.get("contrabandCount").toString()); //违禁物品数量
                    }
                }
            }
            //封装数据
@@ -387,8 +397,10 @@
     */
    @Override
    public Object getParcelkindDetailPage(ConditionVo conditionVo) {
        System.out.println("conditionVo = " + conditionVo);
        //获取违禁品数据
        String result = getParcelDataPageList(conditionVo, PARCEL_KIND_URL, PARCEL_KEY, PARCEL_SECRET).get("result").toString();
        System.out.println("result = " + result);
        if (null!=result) {
            return JSONObject.parse(result);
        }
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/parcel/vo/ConditionVo.java
@@ -44,4 +44,14 @@
     * 分页记录数
     */
    private Integer pageSize;
    /**
     * 预警确认时间描述
     */
    private String timeDesc;
    /**
     * 预警时间分布
     */
    private Integer timeNum;
}