Bladeren bron

新增 一张图智慧物联 获取设备统计信息接口

zhaiyifei 8 maanden geleden
bovenliggende
commit
5eecb02d1f

+ 54 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/controller/IotScreenController.java

@@ -0,0 +1,54 @@
+package com.yunfeiyun.agmp.iotm.web.controller;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.nlf.calendar.Lunar;
+import com.yunfeiyun.agmp.common.constant.ErrorCode;
+import com.yunfeiyun.agmp.common.core.controller.BaseController;
+import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
+import com.yunfeiyun.agmp.common.exception.BizException;
+import com.yunfeiyun.agmp.common.service.WeatherService;
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotScreenStatReqVo;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotScreenDevStatResVo;
+import com.yunfeiyun.agmp.iotm.web.service.IIotScreenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/iot/screen")
+public class IotScreenController extends BaseController {
+    @Autowired
+    private WeatherService weatherService;
+
+    @Autowired
+    private IIotScreenService iIotScreenService;
+
+    /**
+     * 查询天气信息
+     * */
+
+    @GetMapping("/weather/info")
+    public AjaxResult weatherInfo() {
+        JSONObject result = weatherService.getProjectWeather();
+        if(result == null){
+            throw new BizException(ErrorCode.SYSTEM_ERROR);
+        }
+        Lunar chineseCalendar = new Lunar();
+        result.put("chineseCalendar",chineseCalendar.getMonthInChinese()+"月"+chineseCalendar.getDayInChinese());
+        return success(result);
+    }
+
+    /**
+     * 获取设备统计信息
+     */
+    @PreAuthorize("@ss.hasPermi('iot:screen:dev:stat')")
+    @GetMapping("/dev/stat")
+    public AjaxResult devStat(IotScreenStatReqVo reqVo) {
+        IotScreenDevStatResVo devStatResVo = iIotScreenService.devStat(reqVo);
+        return success(devStatResVo);
+    }
+
+
+}

+ 8 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/reqvo/IotScreenStatReqVo.java

@@ -0,0 +1,8 @@
+package com.yunfeiyun.agmp.iotm.web.domain.reqvo;
+
+import lombok.Data;
+
+@Data
+public class IotScreenStatReqVo {
+    private String tid;
+}

+ 16 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/resvo/IotScreenDevStatResVo.java

@@ -0,0 +1,16 @@
+package com.yunfeiyun.agmp.iotm.web.domain.resvo;
+
+import lombok.Data;
+
+@Data
+public class IotScreenDevStatResVo {
+    private static final long serialVersionUID = 1L;
+
+    private int devNum;
+
+    private int offlineNum;
+
+    private int onlineNum;
+
+    private int warnNum;
+}

+ 11 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/mapper/IotScreenMapper.java

@@ -0,0 +1,11 @@
+package com.yunfeiyun.agmp.iotm.web.mapper;
+
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotScreenStatReqVo;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotScreenDevStatResVo;
+
+public interface IotScreenMapper {
+    /**
+     * 设备统计
+     */
+    public IotScreenDevStatResVo devStat(IotScreenStatReqVo reqVo);
+}

+ 7 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/mapper/IotWarnlogMapper.java

@@ -71,4 +71,11 @@ public interface IotWarnlogMapper {
      * @return 结果
      */
     public int batchUpdateIotWarnlog(List<IotWarnlog> iotWarnlogList);
+
+    /**
+     * 获取告警记录总数
+     * @param reqVo 查询条件
+     * @return 结果
+     */
+    public int getWarnlogCount(IotWarnlogReqVo reqVo);
 }

+ 11 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotScreenService.java

@@ -0,0 +1,11 @@
+package com.yunfeiyun.agmp.iotm.web.service;
+
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotScreenStatReqVo;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotScreenDevStatResVo;
+
+public interface IIotScreenService {
+    /**
+     * 设备统计
+     */
+    public IotScreenDevStatResVo devStat(IotScreenStatReqVo reqVo);
+}

+ 7 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotWarnlogService.java

@@ -81,4 +81,11 @@ public interface IIotWarnlogService {
      */
     public int batchDeal(IotWarnlogBatchDealReqVo reqVo);
 
+    /**
+     * 获取告警记录总数
+     * @param reqVo 查询条件
+     * @return 结果
+     */
+    public int getWarnlogCount(IotWarnlogReqVo reqVo);
+
 }

+ 42 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotScreenServiceImpl.java

@@ -0,0 +1,42 @@
+package com.yunfeiyun.agmp.iotm.web.service.impl;
+
+import com.yunfeiyun.agmp.common.utils.SecurityUtils;
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotScreenStatReqVo;
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotWarnlogReqVo;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotHomeDeviceStatResVo;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotScreenDevStatResVo;
+import com.yunfeiyun.agmp.iotm.web.service.IIotHomeService;
+import com.yunfeiyun.agmp.iotm.web.service.IIotScreenService;
+import com.yunfeiyun.agmp.iotm.web.service.IIotWarnlogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class IotScreenServiceImpl implements IIotScreenService {
+
+    @Autowired
+    private IIotHomeService iIotHomeService;
+
+    @Autowired
+    private IIotWarnlogService iIotWarnlogService;
+    /**
+     * 设备统计
+     *
+     * @param reqVo
+     */
+    @Override
+    public IotScreenDevStatResVo devStat(IotScreenStatReqVo reqVo) {
+        IotHomeDeviceStatResVo iotHomeDeviceStatResVo = iIotHomeService.getDeviceStatusStat();
+
+        IotWarnlogReqVo warnlogReqVo = new IotWarnlogReqVo();
+        warnlogReqVo.setTid(SecurityUtils.getTid());
+        int warnNum = iIotWarnlogService.getWarnlogCount(warnlogReqVo);
+
+        IotScreenDevStatResVo iotScreenDevStatResVo = new IotScreenDevStatResVo();
+        iotScreenDevStatResVo.setDevNum(iotHomeDeviceStatResVo.getDevNum());
+        iotScreenDevStatResVo.setOfflineNum(iotHomeDeviceStatResVo.getOfflineNum());
+        iotScreenDevStatResVo.setOnlineNum(iotHomeDeviceStatResVo.getOnlineNum());
+        iotScreenDevStatResVo.setWarnNum(warnNum);
+        return iotScreenDevStatResVo;
+    }
+}

+ 11 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotWarnlogServiceImpl.java

@@ -254,6 +254,17 @@ public class IotWarnlogServiceImpl implements IIotWarnlogService {
         return 0;
     }
 
+    /**
+     * 获取告警记录总数
+     *
+     * @param reqVo 查询条件
+     * @return 结果
+     */
+    @Override
+    public int getWarnlogCount(IotWarnlogReqVo reqVo) {
+        return iotWarnlogMapper.getWarnlogCount(reqVo);
+    }
+
     public static void main(String[] args)throws Exception{
         try {
 

+ 13 - 0
src/main/resources/mapper/IotScreenMapper.xml

@@ -0,0 +1,13 @@
+<?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.yunfeiyun.agmp.iotm.web.mapper.IotScreenMapper">
+
+
+    <select id="devStat" parameterType="com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotScreenStatReqVo"
+            resultType="com.yunfeiyun.agmp.iotm.web.domain.resvo.IotScreenDevStatResVo">
+
+    </select>
+</mapper>

+ 11 - 0
src/main/resources/mapper/IotWarnlogMapper.xml

@@ -178,4 +178,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
         </where>
     </select>
+
+    <select id="getWarnlogCount" parameterType="IotWarnlogReqVo" resultType="java.lang.Integer">
+        select count(*)
+        from IotWarnlog
+        <where>
+            tid = #{tid}
+            <if test="devtypeBid != null  and devtypeBid != ''"> and devtypeBid = #{devtypeBid}</if>
+            <if test="devBid != null  and devBid != ''"> and devBid = #{devBid}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+        </where>
+    </select>
 </mapper>