From 0257400b7c42c8143f32dae8e4bffbe90a890f1f Mon Sep 17 00:00:00 2001
From: linpf <807878712@qq.com>
Date: 星期四, 16 十二月 2021 17:59:52 +0800
Subject: [PATCH] 更改

---
 src/main/java/api/controller/WeatherController.java        |    2 
 src/main/java/api/dao/SinglelampDataDao.java               |   28 ++++
 src/main/java/api/service/LampService.java                 |   56 ++++++++
 /dev/null                                                  |    0 
 target/classes/application.yml                             |    1 
 src/main/java/api/controller/LampController.java           |   78 +++++++++++
 src/main/java/api/bean/SinglelampDataEntity.java           |   55 +++++++
 src/main/java/api/controller/SinglelampDataController.java |   83 +++++++++++
 src/main/java/api/service/SinglelampDataServer.java        |   55 +++++++
 pom.xml                                                    |   19 ++
 src/main/resources/application.yml                         |    1 
 11 files changed, 376 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 0b3489a..b1c43a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -131,6 +131,23 @@
             <artifactId>spring-boot-configuration-processor</artifactId>
             <optional>true</optional>
         </dependency>
+        <!--MP渚濊禆-->
+       <!-- <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.0.7.1</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.baomidou</groupId>
+                    <artifactId>mybatis-plus-generator</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus</artifactId>
+            <version>3.0.7.1</version>
+        </dependency>-->
     </dependencies>
 
     <dependencyManagement>
@@ -207,4 +224,4 @@
             </plugin>
         </plugins>
     </build>
-</project>
\ No newline at end of file
+</project>
diff --git a/src/main/java/api/bean/SinglelampDataEntity.java b/src/main/java/api/bean/SinglelampDataEntity.java
new file mode 100644
index 0000000..7fcbf74
--- /dev/null
+++ b/src/main/java/api/bean/SinglelampDataEntity.java
@@ -0,0 +1,55 @@
+package api.bean;
+
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author van
+ * @version 1.0
+ * msg锛歁QTT涓插彛锛孋AT1 鍗曠伅鏁版嵁 瀹炰綋绫�
+ * @date 2021/12/13 15:19
+ */
+
+@Data
+public class SinglelampDataEntity  implements Serializable {
+    private Integer singlelampDataId;
+    //鐏潌id
+    private Long streetlightId;
+    //鐏潌mac
+    private String mac;
+    //鐏潌鍚�
+    private String streetlightName;
+    //  鏁版嵁鏃堕棿
+    private String dataTime;
+    //  璁惧娓╁害
+    private Double deviceTemperature;
+    //  浜害鐧惧垎姣�
+    private Integer lightPercent;
+    //  鐢电綉鐢靛帇
+    private Double gridVol;
+    //  鐢电綉鐢垫祦
+    private Double gridCur;
+    //  璧吂
+    private Double hertz;
+    //  鍔熺巼鍥犵礌
+    private Double powerFactor;
+    //  鏈夊姛鍔熺巼
+    private Double activePower;
+    //  鏃犲姛鍔熺巼
+    private Double reactivePower;
+    //  鏈�杩戜竴娆′寒鐏椂闂�
+    private Long recentlyLightSec;
+    private String recentlyLightSecStr;
+    //  绱浜伅鏃堕棿
+    private Long totalLightTime;
+    private String totalLightTimeStr;
+    //  鏈�杩戜竴娆$敤鐢电數閲�
+    private Double recentlyUsingPower;
+    //  绱鐢ㄧ數鐢甸噺
+    private Double totalUsingPower;
+    // 鍒涘缓鏃堕棿
+    private Date createTime;
+}
diff --git a/src/main/java/api/controller/LampController.java b/src/main/java/api/controller/LampController.java
new file mode 100644
index 0000000..0acc4ee
--- /dev/null
+++ b/src/main/java/api/controller/LampController.java
@@ -0,0 +1,78 @@
+package api.controller;
+
+import api.bean.LampEntity;
+import api.bean.ReqParams;
+import api.dao.LampDao;
+import api.result.Msg;
+import api.service.AccessService;
+import api.service.LampService;
+import com.github.pagehelper.PageInfo;
+import com.google.common.util.concurrent.RateLimiter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author van
+ * @version 1.0
+ * msg锛氬崟鐏暟鎹帶鍒跺眰
+ * @date 2021/11/2 15:04
+ */
+@RestController
+@RequestMapping("/lamp")
+public class LampController {
+
+    @Autowired
+    private AccessService accessService;
+    @Autowired
+    private LampService lampService;
+
+    RateLimiter rateLimiter = RateLimiter.create(10.0);
+
+    @RequestMapping(value = "/list",method = RequestMethod.POST)
+    public Msg list(@RequestBody ReqParams reqParams){
+        rateLimiter.acquire(1);
+        if (reqParams.getLimit()>50){
+            return Msg.error("limit exception!!!");
+        }
+        Long userId = accessService.getUserId(reqParams.getAccessToken());
+
+        if(userId == null){
+            return Msg.error("server exception!!!");
+        }
+
+        PageInfo<LampEntity> info = lampService.selectList(userId,reqParams);
+
+        Map data = new HashMap();
+
+        data.put("total",info.getTotal());
+        data.put("list",info.getList());
+
+        return Msg.ok().put("data",data);
+
+    }
+    @RequestMapping(value ="/info",method = RequestMethod.POST)
+    public Msg info(@RequestBody ReqParams reqParams){
+        rateLimiter.acquire(1);
+        if (reqParams.getLimit()>50){
+            return Msg.error("limit exception!!!");
+        }
+        Long userId = accessService.getUserId(reqParams.getAccessToken());
+
+        if(userId == null){
+            return Msg.error("server exception!!!");
+        }
+
+        PageInfo<LampEntity> info = lampService.selectByStreetlightId(reqParams);
+
+        Map data = new HashMap();
+
+        data.put("total",info.getTotal());
+        data.put("list",info.getList());
+
+        return Msg.ok().put("data",data);
+    }
+
+}
diff --git a/src/main/java/api/controller/SinglelampDataController.java b/src/main/java/api/controller/SinglelampDataController.java
new file mode 100644
index 0000000..48e689b
--- /dev/null
+++ b/src/main/java/api/controller/SinglelampDataController.java
@@ -0,0 +1,83 @@
+package api.controller;
+
+import api.bean.LampEntity;
+import api.bean.ReqParams;
+import api.bean.SinglelampDataEntity;
+import api.result.Msg;
+import api.service.AccessService;
+import api.service.LampService;
+import api.service.SinglelampDataServer;
+import com.github.pagehelper.PageInfo;
+import com.google.common.util.concurrent.RateLimiter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author van
+ * @version 1.0
+ * msg锛歁QTT鍜孋AT1鍗曠伅鎺у埗
+ * @date 2021/12/13 15:26
+ */
+@RestController
+@RequestMapping("/singlelampData")
+public class SinglelampDataController {
+
+    @Autowired
+    private AccessService accessService;
+    @Autowired
+    private SinglelampDataServer singlelampDataServer;
+
+    RateLimiter rateLimiter = RateLimiter.create(10.0);
+
+    @RequestMapping(value = "/list",method = RequestMethod.POST)
+    public Msg list(@RequestBody ReqParams reqParams){
+        rateLimiter.acquire(1);
+        if (reqParams.getLimit()>50){
+            return Msg.error("limit exception!!!");
+        }
+        Long userId = accessService.getUserId(reqParams.getAccessToken());
+
+        if(userId == null){
+            return Msg.error("server exception!!!");
+        }
+        reqParams.toString();
+
+        PageInfo<SinglelampDataEntity> info = singlelampDataServer.selectList(userId,reqParams);
+
+        Map data = new HashMap();
+
+        data.put("total",info.getTotal());
+        data.put("list",info.getList());
+
+        return Msg.ok().put("data",data);
+
+    }
+    @RequestMapping(value ="/info",method = RequestMethod.POST)
+    public Msg info(@RequestBody ReqParams reqParams){
+        rateLimiter.acquire(1);
+        if (reqParams.getLimit()>50){
+            return Msg.error("limit exception!!!");
+        }
+        Long userId = accessService.getUserId(reqParams.getAccessToken());
+
+        if(userId == null){
+            return Msg.error("server exception!!!");
+        }
+
+        PageInfo<SinglelampDataEntity> info = singlelampDataServer.selectByStreetlightId(reqParams);
+
+        Map data = new HashMap();
+
+        data.put("total",info.getTotal());
+        data.put("list",info.getList());
+
+        return Msg.ok().put("data",data);
+    }
+
+}
diff --git a/src/main/java/api/controller/WeatherController.java b/src/main/java/api/controller/WeatherController.java
index c3d9203..5e4ee61 100644
--- a/src/main/java/api/controller/WeatherController.java
+++ b/src/main/java/api/controller/WeatherController.java
@@ -36,7 +36,7 @@
     public Msg list(@RequestBody ReqParams reqParams){
         rateLimiter.acquire(1);
         if(reqParams.getLimit() > 50){
-            return Msg.error("limit exception");
+            return Msg.error("limit exception!!!");
         }
 
         Long userId = accessService.getUserId(reqParams.getAccessToken());
diff --git a/src/main/java/api/dao/SinglelampDataDao.java b/src/main/java/api/dao/SinglelampDataDao.java
new file mode 100644
index 0000000..cf7b541
--- /dev/null
+++ b/src/main/java/api/dao/SinglelampDataDao.java
@@ -0,0 +1,28 @@
+package api.dao;
+
+import api.bean.LampEntity;
+import api.bean.SinglelampDataEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @author van
+ * @version 1.0
+ * msg锛�
+ * @date 2021/12/16 15:56
+ */
+
+@Mapper
+@Repository
+public interface SinglelampDataDao {
+    /**瓒呯骇绠$悊鍛樻煡鎵惧叏閮�*/
+    List<SinglelampDataEntity> selectAll();
+    /**鏅�氱鐞嗗憳鎸夊叕鍙告煡鎵�*/
+    List<SinglelampDataEntity> selectByCompany(Long userId);
+    /**鐢ㄦ埛鏌ユ壘*/
+    //List<SinglelampDataEntity> selectByUserId(Long userId);
+    /**鍗曚釜鐏潌鏁版嵁*/
+    List<SinglelampDataEntity> selectByStreetlightId(String mac);
+}
diff --git a/src/main/java/api/service/LampService.java b/src/main/java/api/service/LampService.java
new file mode 100644
index 0000000..69627d3
--- /dev/null
+++ b/src/main/java/api/service/LampService.java
@@ -0,0 +1,56 @@
+package api.service;
+
+import api.bean.LampEntity;
+import api.bean.ReqParams;
+import api.bean.WeatherEntity;
+import api.dao.LampDao;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author van
+ * @version 1.0
+ * msg锛氬崟鐏暟鎹�
+ * @date 2021/11/2 10:24
+ */
+@Service("lampService")
+public class LampService {
+    @Autowired
+    private AccessService accessService;
+    @Autowired
+    private LampDao lampDao;
+    public PageInfo<LampEntity> selectList(Long userId, ReqParams reqParams){
+        Long roleId = accessService.getRoleId(userId);
+
+        if(roleId == null || roleId == 0){
+            return null;
+        }
+
+        List<LampEntity> list = null;
+
+        if(roleId.longValue() == 1 ){
+            PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
+            list = lampDao.selectAll();
+        }else if (roleId.longValue() == 2){
+            PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
+            list = lampDao.selectByCompany(userId);
+        }else if (roleId.longValue() == 3){
+            PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
+            list = lampDao.selectByUserId(userId);
+        }
+        PageInfo<LampEntity> page = new PageInfo<>(list);
+        return page;
+
+}
+
+    public PageInfo<LampEntity> selectByStreetlightId(ReqParams reqParams) {
+        PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
+        List<LampEntity> list = lampDao.selectByStreetlightId(reqParams.getLightId());
+        PageInfo<LampEntity> page = new PageInfo<>(list);
+        return page;
+    }
+}
diff --git a/src/main/java/api/service/SinglelampDataServer.java b/src/main/java/api/service/SinglelampDataServer.java
new file mode 100644
index 0000000..ae13165
--- /dev/null
+++ b/src/main/java/api/service/SinglelampDataServer.java
@@ -0,0 +1,55 @@
+package api.service;
+
+import api.bean.ReqParams;
+import api.bean.SinglelampDataEntity;
+import api.dao.SinglelampDataDao;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author van
+ * @version 1.0
+ * msg锛�
+ * @date 2021/12/16 15:14
+ */
+@Service("singlelampDataServer")
+public class SinglelampDataServer {
+
+    @Autowired
+    private AccessService accessService;
+    @Autowired
+    private SinglelampDataDao singlelampDao;
+
+    public PageInfo<SinglelampDataEntity> selectList(Long userId, ReqParams reqParams) {
+        Long roleId = accessService.getRoleId(userId);
+
+        if(roleId == null || roleId == 0){
+            return null;
+        }
+
+        List<SinglelampDataEntity> list = null;
+
+        if(roleId.longValue() == 1 ){
+            PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
+            list = singlelampDao.selectAll();
+        }else if (roleId.longValue() == 2 || roleId.longValue() == 3){
+            PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
+            list = singlelampDao.selectByCompany(userId);
+        }
+        PageInfo<SinglelampDataEntity> page = new PageInfo<>(list);
+        return page;
+
+    }
+
+    public PageInfo<SinglelampDataEntity> selectByStreetlightId(ReqParams reqParams) {
+        PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
+        List<SinglelampDataEntity> list = singlelampDao.selectByStreetlightId(reqParams.getMac());
+        PageInfo<SinglelampDataEntity> page = new PageInfo<>(list);
+        return page;
+    }
+
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 0bb9b16..73e3b74 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -6,6 +6,7 @@
 mybatis:
   configuration:
     map-underscore-to-camel-case: true
+  mapper-locations: classpath*:/mapper/*.xml
 
 
 spring:
diff --git a/target/classes/application.yml b/target/classes/application.yml
index 0bb9b16..73e3b74 100644
--- a/target/classes/application.yml
+++ b/target/classes/application.yml
@@ -6,6 +6,7 @@
 mybatis:
   configuration:
     map-underscore-to-camel-case: true
+  mapper-locations: classpath*:/mapper/*.xml
 
 
 spring:
diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties
deleted file mode 100644
index 63b5f62..0000000
--- a/target/maven-archiver/pom.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-version=1.0-SNAPSHOT
-groupId=wog
-artifactId=wog
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
deleted file mode 100644
index acd95e6..0000000
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
+++ /dev/null
@@ -1,12 +0,0 @@
-api\dao\AccessDao.class
-api\service\WeatherService.class
-api\service\AccessService.class
-api\result\Msg.class
-api\utils\httpClient.class
-api\bean\AccessEntity.class
-api\APIApplication.class
-api\bean\ReqParams.class
-api\dao\WeatherDao.class
-api\controller\WeatherController.class
-api\bean\WeatherEntity.class
-api\controller\AccessController.class
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
deleted file mode 100644
index 5d106c2..0000000
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
+++ /dev/null
@@ -1,12 +0,0 @@
-D:\api\src\main\java\api\bean\ReqParams.java
-D:\api\src\main\java\api\controller\WeatherController.java
-D:\api\src\main\java\api\dao\AccessDao.java
-D:\api\src\main\java\api\service\WeatherService.java
-D:\api\src\main\java\api\service\AccessService.java
-D:\api\src\main\java\api\APIApplication.java
-D:\api\src\main\java\api\bean\WeatherEntity.java
-D:\api\src\main\java\api\dao\WeatherDao.java
-D:\api\src\main\java\api\result\Msg.java
-D:\api\src\main\java\api\bean\AccessEntity.java
-D:\api\src\main\java\api\controller\AccessController.java
-D:\api\src\main\java\api\utils\httpClient.java
diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
deleted file mode 100644
index e69de29..0000000
--- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
+++ /dev/null
diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
deleted file mode 100644
index e69de29..0000000
--- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
+++ /dev/null
diff --git a/target/wog-1.0-SNAPSHOT.jar.original b/target/wog-1.0-SNAPSHOT.jar.original
deleted file mode 100644
index 29f5a8a..0000000
--- a/target/wog-1.0-SNAPSHOT.jar.original
+++ /dev/null
Binary files differ

--
Gitblit v1.9.3