Browse Source

增加冒烟告警查询接口

wanxinliang 2 years ago
parent
commit
36efd58f75

+ 1 - 1
src/main/java/com/template/api/BookingControllerAPI.java

@@ -41,7 +41,7 @@ public interface BookingControllerAPI {
     @ApiOperation(value = "评分百分比", notes = "评分百分比", httpMethod = "GET")
     CommonResult getCommentAvg();
 
-    
+
     @GetMapping(value = "/getCommentInfo")
     @ApiOperation(value = "评分详情", notes = "评分详情", httpMethod = "GET")
     CommonResult getCommentInfo(String name,String startTime,String endTime,String flag,int pageNum,int pageSize);

+ 28 - 0
src/main/java/com/template/api/WarmSmokeControllerAPI.java

@@ -0,0 +1,28 @@
+package com.template.api;
+
+import com.template.model.result.CommonResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @Author: binguo
+ * @Date: 2023/3/30 星期四 17:28
+ * @Description: com.video.api
+ * @Version: 1.0
+ */
+@RequestMapping("/api/toiletBase")
+@Api(tags = {"WarmSmokeController"}, value = "厕所接口")
+public interface WarmSmokeControllerAPI {
+
+
+    @GetMapping("/getWarmSmokeByPlace")
+    @ApiOperation(value = "根据地址查询烟雾报警", notes = "根据地址查询烟雾报警", httpMethod = "GET")
+    CommonResult getWarmSmokeByPlace(String place);
+
+    @GetMapping("/getWarmSmokeCount")
+    @ApiOperation(value = "查询烟雾报警数量", notes = "查询烟雾报警数量", httpMethod = "GET")
+    CommonResult getWarmSmokeCount();
+
+}

+ 60 - 0
src/main/java/com/template/controller/WarmSmokeController.java

@@ -0,0 +1,60 @@
+package com.template.controller;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.template.annotation.PassToken;
+import com.template.api.ToiletBaseControllerAPI;
+import com.template.api.WarmSmokeControllerAPI;
+import com.template.mapper.ToiletBaseMapper;
+import com.template.mapper.WarmSmokeMapper;
+import com.template.model.result.CommonResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2023-03-30
+ */
+@RestController
+public class WarmSmokeController implements WarmSmokeControllerAPI {
+
+
+    @Value("${diseaseRightUrl}")
+    String url;
+
+    @Autowired
+    private WarmSmokeMapper warmSmokeMapper;
+
+
+    @Override
+    @PassToken
+    public CommonResult getWarmSmokeByPlace(String place) {
+        List<Map<String, String>> warmSmokeByPlace = warmSmokeMapper.getWarmSmokeByPlace(place);
+        if (warmSmokeByPlace.isEmpty()){
+            return CommonResult.ok("查询为空",warmSmokeByPlace);
+        }
+        return CommonResult.ok(warmSmokeByPlace);
+    }
+
+    @Override
+    @PassToken
+    public CommonResult getWarmSmokeCount() {
+        List<Map<String, String>> warmSmokeCount = warmSmokeMapper.getWarmSmokeCount();
+        if (warmSmokeCount.isEmpty()){
+            return CommonResult.ok("查询为空",warmSmokeCount);
+        }
+        return CommonResult.ok(warmSmokeCount);
+    }
+}
+

+ 24 - 0
src/main/java/com/template/mapper/WarmSmokeMapper.java

@@ -0,0 +1,24 @@
+package com.template.mapper;
+
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+@Repository
+@Mapper
+public interface WarmSmokeMapper {
+
+
+    @Select("SELECT * FROM disease_command.`warning_of_smoke_record` WHERE handle_status =1\n" +
+            "AND place=#{place}")
+    List<Map<String,String>> getWarmSmokeByPlace(@Param("place") String place);
+
+    @Select("SELECT place,COUNT(1) count FROM disease_command.`warning_of_smoke_record` WHERE handle_status =1\n" +
+            "GROUP BY place ")
+    List<Map<String,String>> getWarmSmokeCount();
+}