Jelajahi Sumber

添加路灯接口

邵洋 1 tahun lalu
induk
melakukan
cc8c1eec1a

+ 30 - 6
lamp-service/src/main/java/com/zksy/lamp/controller/TestController.java

@@ -1,9 +1,12 @@
 package com.zksy.lamp.controller;
 
 import com.zksy.lamp.server.ExecutionServer;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -18,15 +21,36 @@ import org.springframework.web.bind.annotation.RestController;
 public class TestController {
     @Autowired
     private ExecutionServer server;
-    @GetMapping("/a")
-    public String test(){
-        String data = "AT+STACH1=1\r\n";
+    @GetMapping("/firstRelay")
+    @ApiOperation(value = "第一路继电器闭合、断开", notes = "第一路继电器闭合、断开")
+    public String firstRelay(@ApiParam(value = "第一路继电器(0-断开,1-闭合)",required = true)
+                       @RequestParam(value = "value") Integer value){
+        String data = "AT+STACH1="+value+"\r\n";
         String msg = server.ExecutionData(data);
         return msg;
     }
-    @GetMapping("/b")
-    public String testb(){
-        String data = "AT+STACH1=0\r\n";
+    @GetMapping("/secondRelay")
+    @ApiOperation(value = "第二路继电器闭合、断开", notes = "第二路继电器闭合、断开")
+    public String secondRelay(@ApiParam(value = "第二路继电器(0-断开,1-闭合)",required = true)
+                                  @RequestParam(value = "value") Integer value){
+        String data = "AT+STACH2="+value+"\r\n";
+        String msg = server.ExecutionData(data);
+        return msg;
+    }
+
+    @GetMapping("/timingOn")
+    @ApiOperation(value = "定时开启", notes = "定时开启")
+    public String timingOn(@ApiParam(value = "定时开启时间,时:分:秒,示例:17:00:00",required = true)
+                              @RequestParam(value = "value") String value){
+        String data = "AT+AUTOCONT=2,task1,[CYC:1],[T:3,0|1|2|3|4|5|6,"+value+"],[DO:0,1,1,100000,100000,1000000],[N:1,0]\r\n";
+        String msg = server.ExecutionData(data);
+        return msg;
+    }
+    @GetMapping("/timedShutdown")
+    @ApiOperation(value = "定时关闭", notes = "定时关闭")
+    public String timedShutdown(@ApiParam(value = "定时关闭时间,时:分:秒,示例:06:00:00",required = true)
+                           @RequestParam(value = "value") String value){
+        String data = "AT+AUTOCONT=2,task2,[CYC:1],[T:3,0|1|2|3|4|5|6,"+value+"],[DO:0,1,0,100000,100000,1000000],[N:1,0]\r\n";
         String msg = server.ExecutionData(data);
         return msg;
     }