523096025 2 vuotta sitten
vanhempi
commit
cbb676aea5
59 muutettua tiedostoa jossa 939 lisäystä ja 33 poistoa
  1. 31 0
      beeboxs/pom.xml
  2. 2 0
      beeboxs/src/main/java/com/huimv/beeboxs/BeeboxsApplication.java
  3. 1 1
      beeboxs/src/main/java/com/huimv/beeboxs/config/InterceptorConfig.java
  4. 1 2
      beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveBaseBeehiveController.java
  5. 21 1
      beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveBaseStationController.java
  6. 7 0
      beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveBeehiveController.java
  7. 20 0
      beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveWarningController.java
  8. 85 0
      beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveWeightController.java
  9. 106 4
      beeboxs/src/main/java/com/huimv/beeboxs/controller/LoginController.java
  10. 138 11
      beeboxs/src/main/java/com/huimv/beeboxs/controller/OpenCotroller.java
  11. 1 0
      beeboxs/src/main/java/com/huimv/beeboxs/dahuaVideo/util/HttpSend.java
  12. 2 0
      beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveBaseBeehive.java
  13. 6 0
      beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveBaseStation.java
  14. 6 0
      beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveBeehive.java
  15. 4 1
      beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveBeehiveOut.java
  16. 3 1
      beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveStation.java
  17. 55 0
      beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveWarning.java
  18. 57 0
      beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveWeight.java
  19. 39 0
      beeboxs/src/main/java/com/huimv/beeboxs/entity/dto/ExcelDto.java
  20. 15 0
      beeboxs/src/main/java/com/huimv/beeboxs/entity/dto/HiveBaseBeeStationDao.java
  21. 30 1
      beeboxs/src/main/java/com/huimv/beeboxs/entity/vo/HiveBaseStationVo.java
  22. 22 0
      beeboxs/src/main/java/com/huimv/beeboxs/entity/vo/OpenDto.java
  23. 16 0
      beeboxs/src/main/java/com/huimv/beeboxs/mapper/HiveWarningMapper.java
  24. 16 0
      beeboxs/src/main/java/com/huimv/beeboxs/mapper/HiveWeightMapper.java
  25. 3 0
      beeboxs/src/main/java/com/huimv/beeboxs/service/IHiveBaseStationService.java
  26. 4 0
      beeboxs/src/main/java/com/huimv/beeboxs/service/IHiveBeehiveService.java
  27. 16 0
      beeboxs/src/main/java/com/huimv/beeboxs/service/IHiveWarningService.java
  28. 20 0
      beeboxs/src/main/java/com/huimv/beeboxs/service/IHiveWeightService.java
  29. 3 1
      beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveBaseBeehiveServiceImpl.java
  30. 27 7
      beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveBaseStationServiceImpl.java
  31. 73 1
      beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveBeehiveServiceImpl.java
  32. 20 0
      beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveWarningServiceImpl.java
  33. 54 0
      beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveWeightServiceImpl.java
  34. 2 1
      beeboxs/src/main/resources/application-dev.yml
  35. 15 0
      beeboxs/src/main/resources/mapper/HiveWarningMapper.xml
  36. 16 0
      beeboxs/src/main/resources/mapper/HiveWeightMapper.xml
  37. 2 1
      beeboxs/target/classes/application-dev.yml
  38. BIN
      beeboxs/target/classes/com/huimv/beeboxs/BeeboxsApplication.class
  39. BIN
      beeboxs/target/classes/com/huimv/beeboxs/common/utils/AirQualityIndexUtil.class
  40. BIN
      beeboxs/target/classes/com/huimv/beeboxs/config/InterceptorConfig.class
  41. BIN
      beeboxs/target/classes/com/huimv/beeboxs/controller/HiveBaseBeehiveController.class
  42. BIN
      beeboxs/target/classes/com/huimv/beeboxs/controller/HiveBaseStationController.class
  43. BIN
      beeboxs/target/classes/com/huimv/beeboxs/controller/HiveBeehiveController.class
  44. BIN
      beeboxs/target/classes/com/huimv/beeboxs/controller/LoginController.class
  45. BIN
      beeboxs/target/classes/com/huimv/beeboxs/controller/OpenCotroller.class
  46. BIN
      beeboxs/target/classes/com/huimv/beeboxs/dahuaVideo/controller/SetDahuaAccountToFarmInfoController.class
  47. BIN
      beeboxs/target/classes/com/huimv/beeboxs/dahuaVideo/util/HttpSend.class
  48. BIN
      beeboxs/target/classes/com/huimv/beeboxs/entity/BaseHiveFarm.class
  49. BIN
      beeboxs/target/classes/com/huimv/beeboxs/entity/HiveBaseBeehive.class
  50. BIN
      beeboxs/target/classes/com/huimv/beeboxs/entity/HiveBeehive.class
  51. BIN
      beeboxs/target/classes/com/huimv/beeboxs/entity/HiveBeehiveOut.class
  52. BIN
      beeboxs/target/classes/com/huimv/beeboxs/entity/HiveStation.class
  53. BIN
      beeboxs/target/classes/com/huimv/beeboxs/entity/dto/HiveBaseBeeStationDao.class
  54. BIN
      beeboxs/target/classes/com/huimv/beeboxs/entity/vo/HiveBaseStationVo.class
  55. BIN
      beeboxs/target/classes/com/huimv/beeboxs/service/IHiveBaseStationService.class
  56. BIN
      beeboxs/target/classes/com/huimv/beeboxs/service/IHiveBeehiveService.class
  57. BIN
      beeboxs/target/classes/com/huimv/beeboxs/service/impl/HiveBaseBeehiveServiceImpl.class
  58. BIN
      beeboxs/target/classes/com/huimv/beeboxs/service/impl/HiveBaseStationServiceImpl.class
  59. BIN
      beeboxs/target/classes/com/huimv/beeboxs/service/impl/HiveBeehiveServiceImpl.class

+ 31 - 0
beeboxs/pom.xml

@@ -73,6 +73,11 @@
             <version>5.7.11</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>4.1.2</version>
+        </dependency>
+        <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>
             <version>3.4.2</version>
@@ -87,6 +92,21 @@
             <artifactId>mybatis-plus-generator</artifactId>
             <version>3.2.0</version>
         </dependency>
+        <dependency>
+            <groupId>com.huimv.bee</groupId>
+            <artifactId>org</artifactId>
+            <scope>system</scope>
+            <version>0.0.1</version>
+            <systemPath>${project.basedir}/lib/commons-httpclient-3.1.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>com.huimv.bee1</groupId>
+            <artifactId>org1</artifactId>
+            <scope>system</scope>
+            <version>0.0.2</version>
+            <systemPath>${project.basedir}/lib/commons-io-1.3.2.jar</systemPath>
+        </dependency>
+
     </dependencies>
 
     <build>
@@ -94,6 +114,17 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <includeSystemScope>true</includeSystemScope>
+                </configuration>
+            </plugin>
+
+
+            <!--在这里修改版本-->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.4.3</version>
             </plugin>
         </plugins>
     </build>

+ 2 - 0
beeboxs/src/main/java/com/huimv/beeboxs/BeeboxsApplication.java

@@ -3,9 +3,11 @@ package com.huimv.beeboxs;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 @SpringBootApplication
 @MapperScan("com.huimv.beeboxs.mapper")
+@EnableScheduling
 public class BeeboxsApplication {
       //ceshi001
     public static void main(String[] args) {

+ 1 - 1
beeboxs/src/main/java/com/huimv/beeboxs/config/InterceptorConfig.java

@@ -21,6 +21,6 @@ public class InterceptorConfig implements WebMvcConfigurer {
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(jwtInterceptor()).
-                excludePathPatterns("/admin/my/*","/hive/token");
+                excludePathPatterns("/admin/my/*","/hive/*");
     }
 }

+ 1 - 2
beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveBaseBeehiveController.java

@@ -38,10 +38,9 @@ public class HiveBaseBeehiveController {
 
 
     @PostMapping("/update")
-    public Result update(@RequestBody HiveBaseBeehive hiveBaseBeehive){
+    public Result update(@RequestBody HiveBaseBeehive hiveBaseBeehive)  {
         hiveBaseBeehive.setBindingDate(new Date());
 
-
         HiveBaseStation hex = baseStationService.getOne(new QueryWrapper<HiveBaseStation>().eq("ap_uid_hex", hiveBaseBeehive.getApUidHex()));
 
         hiveBaseBeehive.setFarmId(hex.getFarmId());

+ 21 - 1
beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveBaseStationController.java

@@ -1,15 +1,22 @@
 package com.huimv.beeboxs.controller;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.huimv.beeboxs.common.utils.Result;
+import com.huimv.beeboxs.entity.HiveBaseBeehive;
 import com.huimv.beeboxs.entity.HiveBaseStation;
 import com.huimv.beeboxs.entity.vo.HiveBaseStationVo;
 import com.huimv.beeboxs.service.IBaseHiveFarmService;
+import com.huimv.beeboxs.service.IHiveBaseBeehiveService;
 import com.huimv.beeboxs.service.IHiveBaseStationService;
+import com.huimv.beeboxs.service.IHiveBeehiveService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -30,6 +37,8 @@ public class HiveBaseStationController {
 
     @Autowired
     private IBaseHiveFarmService baseHiveFarmService;
+    @Autowired
+    private IHiveBaseBeehiveService beehiveService;
 
     @PostMapping("/list")
     public Result page(@RequestBody Map map){
@@ -49,11 +58,13 @@ public class HiveBaseStationController {
 
         return baseStationService.listAll(map);
     }
-
+    @Transactional
     @PostMapping("/update")
     public Result update(@RequestBody HiveBaseStationVo hiveBaseStationVo){
 
 
+        HiveBaseStation byId = baseStationService.getById(hiveBaseStationVo.getId());
+
         HiveBaseStation hiveBaseStation = new HiveBaseStation();
         hiveBaseStation.setId(hiveBaseStationVo.getId());
         Integer farmIds = hiveBaseStationVo.getFarmIds();
@@ -62,6 +73,15 @@ public class HiveBaseStationController {
         hiveBaseStation.setFarmName(farmName);
         hiveBaseStation.setBindingDate(new Date());
         baseStationService.updateById(hiveBaseStation);
+
+        List<HiveBaseBeehive> ap_uid_hex = beehiveService.list(new QueryWrapper<HiveBaseBeehive>().eq("ap_uid_hex", byId.getApUidHex()));
+        for (HiveBaseBeehive apUidHex : ap_uid_hex) {
+            apUidHex.setApUidHex("");
+            apUidHex.setFarmId(-1);
+            beehiveService.updateById(apUidHex);
+        }
+
+
         return new Result(10000,"绑定成功",true);
     }
 

+ 7 - 0
beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveBeehiveController.java

@@ -6,6 +6,9 @@ import com.huimv.beeboxs.service.IHiveBeehiveService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileNotFoundException;
 import java.util.Map;
 
 /**
@@ -29,5 +32,9 @@ public class HiveBeehiveController {
 
         return beehiveService.searchList(map);
     }
+    @PostMapping("/listExcel")
+    public void listExcel(@RequestBody Map map , HttpServletResponse response)   {
+        beehiveService.listExcel(map,response);
+    }
 
 }

+ 20 - 0
beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveWarningController.java

@@ -0,0 +1,20 @@
+package com.huimv.beeboxs.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author author
+ * @since 2022-08-29
+ */
+@RestController
+@RequestMapping("/hive-warning")
+public class HiveWarningController {
+
+}

+ 85 - 0
beeboxs/src/main/java/com/huimv/beeboxs/controller/HiveWeightController.java

@@ -0,0 +1,85 @@
+package com.huimv.beeboxs.controller;
+
+
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.beeboxs.common.utils.Result;
+import com.huimv.beeboxs.entity.HiveBaseBeehive;
+import com.huimv.beeboxs.entity.HiveBeehive;
+import com.huimv.beeboxs.entity.HiveBeehiveStatus;
+import com.huimv.beeboxs.entity.HiveWeight;
+import com.huimv.beeboxs.service.IHiveBaseBeehiveService;
+import com.huimv.beeboxs.service.IHiveBeehiveService;
+import com.huimv.beeboxs.service.IHiveWeightService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author author
+ * @since 2022-04-28
+ */
+@RestController
+@RequestMapping("/hiveWeight")
+@CrossOrigin
+public class HiveWeightController {
+
+    @Autowired
+    IHiveBeehiveService beehiveService;
+
+    @Autowired
+    IHiveBaseBeehiveService baseBeehiveService;
+
+    @Autowired
+    IHiveWeightService weightService;
+
+    @PostMapping("/list")
+    public Result page(@RequestBody Map map){
+
+        return weightService.searchList(map);
+    }
+
+
+//    @Scheduled(cron = "0 0 6 * * ? ")
+    public void  saveWeight(){
+        System.out.println("start");
+        List<HiveBaseBeehive> type = baseBeehiveService.list(new QueryWrapper<HiveBaseBeehive>().eq("type", 2));
+
+        List<HiveWeight> hiveWeights = new ArrayList<HiveWeight>();
+        for (HiveBaseBeehive hiveBaseBeehive : type) {
+            HiveWeight hiveWeight = new HiveWeight();
+
+            HiveWeight weightEntity = weightService.getOne(new QueryWrapper<HiveWeight>().eq("ap_uid_hex", hiveBaseBeehive.getApUidHex()).orderByDesc("id").last("limit 1"));
+
+            hiveWeight.setApUidHex(hiveBaseBeehive.getApUidHex());
+            hiveWeight.setFarmId(hiveBaseBeehive.getFarmId());
+            hiveWeight.setUidHex(hiveBaseBeehive.getUidHex());
+            hiveWeight.setUpdateTime(new Date());
+            hiveWeight.setWeight(hiveBaseBeehive.getWeight());
+
+            String increment = hiveBaseBeehive.getWeight();
+            if (ObjectUtil.isNotEmpty(weightEntity)){
+
+                increment = (Double.parseDouble(hiveBaseBeehive.getWeight() )- Double.parseDouble(weightEntity.getWeight()))+"";
+            }
+            hiveWeight.setIncrement(increment);
+
+
+
+            hiveWeights.add(hiveWeight);
+        }
+
+        weightService.saveBatch(hiveWeights);
+    }
+
+
+}

+ 106 - 4
beeboxs/src/main/java/com/huimv/beeboxs/controller/LoginController.java

@@ -1,14 +1,23 @@
 package com.huimv.beeboxs.controller;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.beeboxs.common.exception.ExceptionEnum;
 import com.huimv.beeboxs.common.exception.MiException;
 import com.huimv.beeboxs.common.token.TokenSign;
 import com.huimv.beeboxs.common.utils.Result;
 import com.huimv.beeboxs.common.utils.ResultCode;
 import com.huimv.beeboxs.common.utils.VerifyUtil;
+import com.huimv.beeboxs.entity.HiveBaseBeehive;
+import com.huimv.beeboxs.entity.HiveBaseStation;
 import com.huimv.beeboxs.entity.SysAccountMultilevel;
+import com.huimv.beeboxs.entity.vo.HiveBaseStationVo;
+import com.huimv.beeboxs.service.IBaseHiveFarmService;
+import com.huimv.beeboxs.service.IHiveBaseBeehiveService;
+import com.huimv.beeboxs.service.IHiveBaseStationService;
 import com.huimv.beeboxs.service.ILoginService;
 import com.huimv.beeboxs.session.AccessToken;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
@@ -16,6 +25,8 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
@@ -105,12 +116,103 @@ public class LoginController {
     }
 
     //测试-token
-    @PostMapping(value = "/getToken")
-    public String getToken(HttpServletRequest req)  {
-        String token =  TokenSign.sign("superbeeboxs",1,null);
-        return  token;
+//    @PostMapping(value = "/getToken")
+//    public String getToken(HttpServletRequest req)  {
+//        String token =  TokenSign.sign("superbeeboxs",1,null);
+//        return  token;
+//    }
+    @Autowired
+    private IHiveBaseStationService baseStationService;
+
+    @Autowired
+    private IBaseHiveFarmService baseHiveFarmService;
+
+    @Autowired
+    private IHiveBaseBeehiveService baseBeehiveService;
+
+    @Autowired
+    private IBaseHiveFarmService farmService;
+
+    @GetMapping("/updateStation")
+    public Result updateStation(@RequestParam(name ="id") String id,
+                                @RequestParam(name ="farmIds") Integer farmIds){
+
+        HiveBaseStation auh = baseStationService.getOne(new QueryWrapper<HiveBaseStation>().eq("ap_uid_hex", id));
+        if (ObjectUtil.isEmpty(auh)){
+            return new Result(10001,"该基站未启用,请联系管理员",false);
+        }
+        Integer farmId = auh.getFarmId();
+        if (ObjectUtil.isNotEmpty(farmId) && farmId >0 ){
+            return new Result(10001,"该基站已绑定牧场",false);
+        }
+
+        String farmName = baseHiveFarmService.getById(farmIds).getFarmName();
+        auh.setFarmId(farmIds);
+        auh.setFarmName(farmName);
+        auh.setBindingDate(new Date());
+        baseStationService.updateById(auh);
+        return new Result(10000,"绑定成功",true);
     }
 
+    @GetMapping("/updateBeehive")
+    public Result update(@RequestParam(name ="id") String id,
+                         @RequestParam(name ="apUidHex") String apUidHex,
+                         @RequestParam(name ="type") Integer type){
+
+        HiveBaseBeehive uh = baseBeehiveService.getOne(new QueryWrapper<HiveBaseBeehive>().eq("uid_hex", id));
+
+        if (type == 1){
+            if (ObjectUtil.isEmpty(uh)){
+                return new Result(10001,"蜂场环境传感器未启用,请联系管理员",false);
+            }
+            String farmId = uh.getApUidHex();
+            if (StringUtils.isNotEmpty(farmId) ){
+                return new Result(10001,"蜂场环境传感器已绑定基站",false);
+            }
+        }
+        HiveBaseStation hex = baseStationService.getOne(new QueryWrapper<HiveBaseStation>().eq("ap_uid_hex", apUidHex));
+
 
+        if (type == 2){
+            if (ObjectUtil.isEmpty(uh)){
+                return new Result(10001,"蜂箱智能终端未启用,请联系管理员",false);
+            }
+            String farmId = uh.getApUidHex();
+            if (StringUtils.isNotEmpty(farmId) ){
+                return new Result(10001,"蜂箱智能终端已绑定基站",false);
+            }
+        }
+        uh.setType(type);
+
+        uh.setBindingDate(new Date());
+
+        uh.setFarmId(hex.getFarmId());
+        uh.setApUidHex(apUidHex);
+        uh.setApName(hex.getApName());
+        baseBeehiveService.updateById(uh);
+        if (type == 1){
+            return new Result(10000,"蜂场环境传感器绑定成功",true);
+        }else {
+            return new Result(10000,"蜂箱智能终端绑定成功",true);
+        }
 
+    }
+
+
+    @GetMapping("/getFarm")
+    public Result getFarm(){
+
+        return  new Result(ResultCode.SUCCESS,farmService.list());
+    }
+    @GetMapping("/listAllStation")
+    public Result listAll(@RequestParam(name ="current") Integer current,
+                          @RequestParam(name ="pageSize") Integer pageSize,
+                          @RequestParam(name ="farmId") Integer farmId){
+        Map map = new HashMap();
+        map.put("current",current);
+        map.put("pageSize",pageSize);
+        map.put("farmId",farmId);
+
+        return baseStationService.listAll(map);
+    }
 }

+ 138 - 11
beeboxs/src/main/java/com/huimv/beeboxs/controller/OpenCotroller.java

@@ -1,19 +1,19 @@
 package com.huimv.beeboxs.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.beeboxs.common.token.TokenSign;
 import com.huimv.beeboxs.common.utils.Result;
 import com.huimv.beeboxs.common.utils.ResultCode;
-import com.huimv.beeboxs.entity.SysAccountMultilevel;
-import com.huimv.beeboxs.service.ILoginService;
+import com.huimv.beeboxs.entity.*;
+import com.huimv.beeboxs.entity.vo.OpenDto;
+import com.huimv.beeboxs.service.*;
 import com.huimv.beeboxs.session.AccessToken;
+import org.apache.commons.lang.StringUtils;
 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;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.Date;
+import java.util.*;
 
 @RestController
 @RequestMapping("/hive")
@@ -22,8 +22,85 @@ public class OpenCotroller {
     @Autowired
     ILoginService iLoginService;
 
+    @Autowired
+    IHiveBaseStationService baseStation;
+
+    @Autowired
+    IHiveBaseBeehiveService baseBeehiveService;
+    @Autowired
+    IBaseHiveFarmService baseHiveFarmService;
+
+    @Autowired
+    IHiveWarningService hiveWarningService;
+
+    @PostMapping("/getHiveWarning")
+    public  Result getHiveWarning(@RequestBody Map<String,String> map){
+        String areaId = map.get("areaId");
+        if (StringUtils.isBlank(areaId)){
+            return new Result(ResultCode.SUCCESS,null);
+        }
+        List<BaseHiveFarm> location = baseHiveFarmService.list(new QueryWrapper<BaseHiveFarm>().like("location", areaId));
+        List<Integer> farmIds = new ArrayList<>();
+        for (BaseHiveFarm baseHiveFarm : location) {
+            farmIds.add( baseHiveFarm.getId());
+        }
+        List endList = new ArrayList();
+        List<HiveWarning> list = hiveWarningService.list(new QueryWrapper<HiveWarning>().in("farm_id", farmIds).orderByDesc("event_time").last("LIMIT 10"));
+        for (HiveWarning hiveWarning : list) {
+            String deviceIdHex = hiveWarning.getDeviceIdHex();
+            HiveBaseBeehive uidHex = baseBeehiveService.getOne(new QueryWrapper<HiveBaseBeehive>().eq("uid_hex", deviceIdHex));
+
+            OpenDto openDto = new OpenDto();
+            openDto.setContent(hiveWarning.getMsgType());
+            openDto.setDeviceName(uidHex.getTagName());
+            openDto.setEventTime(hiveWarning.getEventTime());
+            openDto.setEventType(hiveWarning.getEventType());
+            endList.add(openDto);
+        }
+
+        return new Result(ResultCode.SUCCESS,endList);
+    }
+
+    @PostMapping("/getHiveCount")
+    public  Result getHiveCount(@RequestBody Map<String,String> map){
+        String areaId = map.get("areaId");
+        if (StringUtils.isBlank(areaId)){
+            Map endMap = new HashMap();
+            endMap.put("stationNum",0);
+            endMap.put("onStationNum",0);
+            endMap.put("offStationNum",0);
+
+
+            return new Result(ResultCode.SUCCESS,endMap);
+        }
+        List<BaseHiveFarm> location = baseHiveFarmService.list(new QueryWrapper<BaseHiveFarm>().like("location", areaId));
+        List<Integer> farmIds = new ArrayList<>();
+        for (BaseHiveFarm baseHiveFarm : location) {
+            farmIds.add( baseHiveFarm.getId());
+        }
+        QueryWrapper<HiveBaseBeehive> wrapper = new QueryWrapper<>();
+        wrapper.in("farm_id",farmIds);
+        wrapper.eq("type",2);
+
+        int stationNum = baseBeehiveService.count(wrapper);
+
+        wrapper.eq("tag_state",0);
+        int onStationNum = baseBeehiveService.count(wrapper);
+
+
+        Map endMap = new HashMap();
+        endMap.put("stationNum",stationNum);
+        endMap.put("onStationNum",onStationNum);
+        endMap.put("offStationNum",stationNum -onStationNum);
+
+
+        return new Result(ResultCode.SUCCESS,endMap);
+    }
+
+
+
     @GetMapping("/token")
-    public  Result test(@RequestParam(name = "account") String account,
+    public  Result token(@RequestParam(name = "account") String account,
                         @RequestParam(name = "password") String password,
                         HttpServletRequest req){
 
@@ -55,10 +132,60 @@ public class OpenCotroller {
     }
 
     @GetMapping("/station/list")
-    public  Result test(@RequestParam(name = "pageNo") String pageNo,
+    public  Result stationList(@RequestParam(name = "pageNo") String pageNo,
                         @RequestParam(name = "pageSize") String pageSize,
-                        @RequestParam(name = "netstatus") String netstatus){
+                        @RequestParam(name = "netstatus") String netstatus,
+                        HttpServletRequest req){
+        String farmIds = TokenSign.getFarmIds(req);
+        if (StringUtils.isNotBlank(farmIds)){
+            String[] split = farmIds.split(",");
+
+           return baseStation.openPage(pageNo,pageSize,netstatus,split);
+
+        }else {
+            return new Result(10001,"账号未绑定牧场",false);
+        }
+    }
+
+    @GetMapping("/station/data/{id}")
+    public  Result stationData(@RequestParam(name = "stationId",required = false) String stationId,
+                        @PathVariable("id") String id){
+
+        if (StringUtils.isNotBlank(stationId)){
+
+            return new Result(ResultCode.SUCCESS,  baseStation.getOne(new QueryWrapper<HiveBaseStation>().eq("ap_uid_hex",stationId)));
+        }else {
+            return new Result(10001,"该基站不存在",false);
+        }
+    }
+
 
-return new Result(ResultCode.SUCCESS,null);
+    //获取某个基站下蜂箱列表接口
+    @GetMapping("/beehive/list/{stationId}")
+    public  Result beehiveList( @PathVariable("stationId") String stationId){
+
+
+        if (StringUtils.isNotBlank(stationId)){
+
+            return new Result(ResultCode.SUCCESS,  baseBeehiveService.list(new QueryWrapper<HiveBaseBeehive>().eq("ap_uid_hex",stationId)));
+        }else {
+            return new Result(10001,"该基站不存在",false);
+        }
     }
+
+    //获取某个蜂箱详细数据接口
+    @GetMapping("/beehive/data/{beehiveId}")
+    public  Result beehiveData( @PathVariable("beehiveId") String beehiveId){
+
+
+        if (StringUtils.isNotBlank(beehiveId)){
+
+            return new Result(ResultCode.SUCCESS,  baseBeehiveService.getOne(new QueryWrapper<HiveBaseBeehive>().eq("uid_hex",beehiveId)));
+        }else {
+            return new Result(10001,"该基站不存在",false);
+        }
+    }
+
+
+
 }

+ 1 - 0
beeboxs/src/main/java/com/huimv/beeboxs/dahuaVideo/util/HttpSend.java

@@ -66,6 +66,7 @@ public class HttpSend {
         paramString.append("nonce:").append(nonce).append(",");
         paramString.append("appSecret:").append(CONST.SECRET);
 
+
         String sign = "";
         // 计算MD5得值
         try {

+ 2 - 0
beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveBaseBeehive.java

@@ -141,4 +141,6 @@ public class HiveBaseBeehive implements Serializable {
     private Integer beeStatus3;
 
     private Integer beeStatus4;
+    private Integer type;
+    private String  weight;
 }

+ 6 - 0
beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveBaseStation.java

@@ -108,4 +108,10 @@ public class HiveBaseStation implements Serializable {
     private String channelName;
 
 
+
+
+
+
+
+
 }

+ 6 - 0
beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveBeehive.java

@@ -76,6 +76,12 @@ public class HiveBeehive implements Serializable {
     private String humi;
 
     /**
+     * 重量
+     */
+    private String weight;
+
+
+    /**
      * 上传时间
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")

+ 4 - 1
beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveBeehiveOut.java

@@ -59,7 +59,10 @@ public class HiveBeehiveOut implements Serializable {
      * 信号强度
      */
     private String rssi;
-
+    /**
+     * 重量
+     */
+    private String weight;
     /**
      * 状态
      */

+ 3 - 1
beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveStation.java

@@ -9,6 +9,7 @@ import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
+import java.util.Date;
 
 /**
  * <p>
@@ -87,7 +88,7 @@ public class HiveStation implements Serializable {
     /**
      * 日期
      */
-    private LocalDateTime createDate;
+    private Date createDate;
 
     /**
      * 牧场id
@@ -95,4 +96,5 @@ public class HiveStation implements Serializable {
     private Integer farmId;
 
 
+
 }

+ 55 - 0
beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveWarning.java

@@ -0,0 +1,55 @@
+package com.huimv.beeboxs.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author author
+ * @since 2022-08-29
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("hive_warning")
+public class HiveWarning implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private Integer farmId;
+
+    private String msgType;
+
+    /**
+     * 设备ID,8位16进制
+     */
+    private String deviceIdHex;
+
+    /**
+     * 事件类型: 0标签上线 1标签下线 2网关上线 3网关下线
+     */
+    private String eventType;
+
+    /**
+     * 事件发生时间
+     */
+    @JsonFormat(pattern = "MM-dd HH:mm",timezone = "GMT+8")
+    private Date eventTime;
+
+
+}

+ 57 - 0
beeboxs/src/main/java/com/huimv/beeboxs/entity/HiveWeight.java

@@ -0,0 +1,57 @@
+package com.huimv.beeboxs.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author author
+ * @since 2022-04-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("hive_weight")
+public class HiveWeight implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String weight;
+
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+    private Date updateTime;
+
+    /**
+     * 标签ID
+     */
+    private String uidHex;
+
+    /**
+     * 网关ID
+     */
+    private String apUidHex;
+
+    private Integer farmId;
+
+    /**
+     * 增量
+     */
+    private String increment;
+
+
+}

+ 39 - 0
beeboxs/src/main/java/com/huimv/beeboxs/entity/dto/ExcelDto.java

@@ -0,0 +1,39 @@
+package com.huimv.beeboxs.entity.dto;
+
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class ExcelDto {
+    private Integer serial;
+    /**
+     * 温度
+     */
+    private String temp;
+
+    /**
+     * 湿度
+     */
+    private String humi;
+    /**
+     * 拓展字段 2
+     */
+    private String other1;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date uploadTime;
+
+    /**
+     * 室外温度
+     */
+    private String tempOut;
+
+
+    /**
+     * 室外湿度
+     */
+    private String humiOut;
+
+}

+ 15 - 0
beeboxs/src/main/java/com/huimv/beeboxs/entity/dto/HiveBaseBeeStationDao.java

@@ -71,4 +71,19 @@ public class HiveBaseBeeStationDao {
 
     private Integer offBeeBoxNum;
 
+
+    /**
+     * 摄像头ID
+     */
+    private String deviceId;
+
+    /**
+     * 通道ID
+     */
+    private String channelId;
+
+    /**
+     * 通道ID
+     */
+    private String channelName;
 }

+ 30 - 1
beeboxs/src/main/java/com/huimv/beeboxs/entity/vo/HiveBaseStationVo.java

@@ -2,6 +2,8 @@ package com.huimv.beeboxs.entity.vo;
 
 import lombok.Data;
 
+import java.util.Date;
+
 @Data
 public class HiveBaseStationVo {
     private Integer id;
@@ -59,18 +61,45 @@ public class HiveBaseStationVo {
      */
     private Integer farmIds;
 
-    
+
     /**
      * 云台编号
      */
     private String cameraId ;
+    /**
+     * 通道ID
+     */
+    private String channelId;
 
+    /**
+     * 通道ID
+     */
+    private String channelName;
     
     /**
      * 云台通道
      */
     private String cameraChannelId;
 
+    /**
+     * 牧场id
+     */
+    private Date bindingDate;
+
+
+    /**
+     * 牧场id
+     */
+    private String  farmName;
+
+
+    /**
+     * 牧场id
+     */
+    private String  deviceId;
+
+
+
 
 
 }

+ 22 - 0
beeboxs/src/main/java/com/huimv/beeboxs/entity/vo/OpenDto.java

@@ -0,0 +1,22 @@
+package com.huimv.beeboxs.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class OpenDto {
+
+    @JsonFormat(pattern = "MM-dd HH:mm",timezone = "GMT+8")
+    private Date eventTime;
+
+
+    private String eventType;
+
+
+    private String content;
+
+
+    private String deviceName;
+}

+ 16 - 0
beeboxs/src/main/java/com/huimv/beeboxs/mapper/HiveWarningMapper.java

@@ -0,0 +1,16 @@
+package com.huimv.beeboxs.mapper;
+
+import com.huimv.beeboxs.entity.HiveWarning;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author author
+ * @since 2022-08-29
+ */
+public interface HiveWarningMapper extends BaseMapper<HiveWarning> {
+
+}

+ 16 - 0
beeboxs/src/main/java/com/huimv/beeboxs/mapper/HiveWeightMapper.java

@@ -0,0 +1,16 @@
+package com.huimv.beeboxs.mapper;
+
+import com.huimv.beeboxs.entity.HiveWeight;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author author
+ * @since 2022-04-28
+ */
+public interface HiveWeightMapper extends BaseMapper<HiveWeight> {
+
+}

+ 3 - 0
beeboxs/src/main/java/com/huimv/beeboxs/service/IHiveBaseStationService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.huimv.beeboxs.common.utils.Result;
 import com.huimv.beeboxs.entity.HiveBaseStation;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -21,4 +22,6 @@ public interface IHiveBaseStationService extends IService<HiveBaseStation> {
     Result listAll(Map map);
 
     Result listCount(Map map);
+
+    Result openPage(String pageNo, String pageSize, String netstatus, String[] split);
 }

+ 4 - 0
beeboxs/src/main/java/com/huimv/beeboxs/service/IHiveBeehiveService.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.huimv.beeboxs.common.utils.Result;
 import com.huimv.beeboxs.entity.HiveBeehive;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileNotFoundException;
 import java.util.Map;
 
 /**
@@ -17,4 +19,6 @@ import java.util.Map;
 public interface IHiveBeehiveService extends IService<HiveBeehive> {
 
     Result searchList(Map map);
+
+    void listExcel(Map map, HttpServletResponse response)  ;
 }

+ 16 - 0
beeboxs/src/main/java/com/huimv/beeboxs/service/IHiveWarningService.java

@@ -0,0 +1,16 @@
+package com.huimv.beeboxs.service;
+
+import com.huimv.beeboxs.entity.HiveWarning;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author author
+ * @since 2022-08-29
+ */
+public interface IHiveWarningService extends IService<HiveWarning> {
+
+}

+ 20 - 0
beeboxs/src/main/java/com/huimv/beeboxs/service/IHiveWeightService.java

@@ -0,0 +1,20 @@
+package com.huimv.beeboxs.service;
+
+import com.huimv.beeboxs.common.utils.Result;
+import com.huimv.beeboxs.entity.HiveWeight;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Map;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author author
+ * @since 2022-04-28
+ */
+public interface IHiveWeightService extends IService<HiveWeight> {
+
+    Result searchList(Map map);
+}

+ 3 - 1
beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveBaseBeehiveServiceImpl.java

@@ -44,6 +44,7 @@ public class HiveBaseBeehiveServiceImpl extends ServiceImpl<HiveBaseBeehiveMappe
         QueryWrapper<HiveBaseBeehive> wrapper = new QueryWrapper<>();
 
         wrapper.eq("farm_id",farmId);
+        wrapper.eq("type",2);
         wrapper.eq(StringUtils.isNotBlank(apUidHex),"ap_uid_hex",apUidHex);
         Page<HiveBaseBeehive> page = this.page(new Page<>(current, pageSize),wrapper);
 
@@ -72,12 +73,13 @@ public class HiveBaseBeehiveServiceImpl extends ServiceImpl<HiveBaseBeehiveMappe
         QueryWrapper<HiveBaseBeehive> wrapper = new QueryWrapper<>();
         wrapper.eq("farm_id",farmId);
         wrapper.eq(StringUtils.isNotBlank(apUidHex),"ap_uid_hex",apUidHex);
-
+        wrapper.eq("type",2);
         HashMap<String, Object> endMap = new HashMap<>();
         int stationNum = this.count(wrapper);
 
 
         wrapper.eq("tag_state",0);
+
         int onStationNum = this.count(wrapper);
 
         endMap.put("onStationNum",onStationNum);

+ 27 - 7
beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveBaseStationServiceImpl.java

@@ -12,13 +12,11 @@ import com.huimv.beeboxs.entity.dto.HiveBaseBeeStationDao;
 import com.huimv.beeboxs.mapper.HiveBaseStationMapper;
 import com.huimv.beeboxs.service.IHiveBaseBeehiveService;
 import com.huimv.beeboxs.service.IHiveBaseStationService;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * <p>
@@ -52,8 +50,11 @@ public class HiveBaseStationServiceImpl extends ServiceImpl<HiveBaseStationMappe
         }
         QueryWrapper<HiveBaseStation> wrapper = new QueryWrapper<>();
 
+
         wrapper.eq("farm_id",farmId);
-        Page<HiveBaseStation> page = this.page(new Page<>(current, pageSize));
+
+
+        Page<HiveBaseStation> page = this.page(new Page<>(current, pageSize),wrapper);
 
         List<HiveBaseStation> records = page.getRecords();
         List list = new ArrayList();
@@ -63,12 +64,14 @@ public class HiveBaseStationServiceImpl extends ServiceImpl<HiveBaseStationMappe
             String apUidHex = record.getApUidHex();
             QueryWrapper<HiveBaseBeehive> hiveBaseBeehiveQueryWrapper = new QueryWrapper<>();
             hiveBaseBeehiveQueryWrapper.eq("ap_uid_hex",apUidHex);
+            hiveBaseBeehiveQueryWrapper.eq("type",2);
             //总数
             hiveBaseStationVo.setBeeBoxNum(  baseBeehiveService.count(hiveBaseBeehiveQueryWrapper));
             hiveBaseBeehiveQueryWrapper.eq("tag_state",1);
             hiveBaseStationVo.setOffBeeBoxNum(  baseBeehiveService.count(hiveBaseBeehiveQueryWrapper));
 
             hiveBaseBeehiveQueryWrapper.clear();
+            hiveBaseBeehiveQueryWrapper.eq("type",2);
             hiveBaseBeehiveQueryWrapper.eq("ap_uid_hex",apUidHex).eq("tag_state",0);
             hiveBaseStationVo.setOnBeeBoxNum(  baseBeehiveService.count(hiveBaseBeehiveQueryWrapper));
             list.add(hiveBaseStationVo);
@@ -82,6 +85,8 @@ public class HiveBaseStationServiceImpl extends ServiceImpl<HiveBaseStationMappe
 
         Integer current =  (Integer)map.get("current");
         Integer pageSize =   (Integer) map.get("pageSize");
+//        Integer farmId =   (Integer) map.get("farmId");
+
 
         if (current == null || current <1 ){
             current =1;
@@ -90,8 +95,8 @@ public class HiveBaseStationServiceImpl extends ServiceImpl<HiveBaseStationMappe
             pageSize =10;
         }
         QueryWrapper<HiveBaseStation> wrapper = new QueryWrapper<>();
-
-        Page<HiveBaseStation> page = this.page(new Page<>(current, pageSize));
+//        wrapper.eq("farm_id",farmId);
+        Page<HiveBaseStation> page = this.page(new Page<>(current, pageSize),wrapper);
         return new Result(ResultCode.SUCCESS,page);
     }
 
@@ -114,4 +119,19 @@ public class HiveBaseStationServiceImpl extends ServiceImpl<HiveBaseStationMappe
 
         return new Result(ResultCode.SUCCESS,endMap);
     }
+
+    @Override
+    public Result openPage(String pageNo, String pageSize, String netstatus, String[] split) {
+        QueryWrapper<HiveBaseStation> wrapper = new QueryWrapper<>();
+
+        wrapper.eq(StringUtils.isNotBlank(netstatus),"ap_state",netstatus);
+
+
+        wrapper.in("farm_id", Arrays.stream(split));
+
+        Page<HiveBaseStation> hiveBaseStationPage = new Page<>(Integer.parseInt(pageNo),Integer.parseInt(pageSize));
+
+
+        return new Result(ResultCode.SUCCESS,this.page( hiveBaseStationPage,wrapper));
+    }
 }

+ 73 - 1
beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveBeehiveServiceImpl.java

@@ -1,15 +1,23 @@
 package com.huimv.beeboxs.service.impl;
 
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.huimv.beeboxs.common.utils.Result;
 import com.huimv.beeboxs.common.utils.ResultCode;
 import com.huimv.beeboxs.entity.HiveBeehive;
+import com.huimv.beeboxs.entity.dto.ExcelDto;
 import com.huimv.beeboxs.mapper.HiveBeehiveMapper;
 import com.huimv.beeboxs.service.IHiveBeehiveService;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,6 +33,8 @@ public class HiveBeehiveServiceImpl extends ServiceImpl<HiveBeehiveMapper, HiveB
 
     @Override
     public Result searchList(Map map) {
+
+//        String.format("%.2f",maxWater);
         String startDate = (String)map.get("startDate");
         String endDate = (String)map.get("endDate");
         String hiveId = (String)map.get("hiveId");
@@ -38,7 +48,69 @@ public class HiveBeehiveServiceImpl extends ServiceImpl<HiveBeehiveMapper, HiveB
 
         wrapper.ge(StringUtils.isNotBlank(startDate),"create_date",startDate);
         wrapper.le(StringUtils.isNotBlank(endDate),"create_date",endDate);
+        List<HiveBeehive> list = this.list(wrapper);
+//        for (HiveBeehive hiveBeehive : list) {
+//
+//            Double humi = Double.parseDouble(hiveBeehive.getHumi());
+//            double random = Math.random()*2;
+//            if (humi >55.0){
+//                hiveBeehive.setHumi(String.format("%.2f",47+random));
+//            }
+//
+//        }
+        return new Result(ResultCode.SUCCESS,list);
+    }
+
+    @Override
+    public void listExcel(Map map, HttpServletResponse response)   {
+        String startDate = (String)map.get("startDate");
+        String endDate = (String)map.get("endDate");
+        String hiveId = (String)map.get("hiveId");
+
+        QueryWrapper<HiveBeehive> wrapper = new QueryWrapper<>();
+
+        wrapper.eq("hive_id",hiveId);
+
+        wrapper.ge(StringUtils.isNotBlank(startDate),"create_date",startDate);
+        wrapper.le(StringUtils.isNotBlank(endDate),"create_date",endDate);
+        List<HiveBeehive> list = this.list(wrapper);
+
+        List<ExcelDto> excelDtos = new ArrayList<>();
+        for (int  i = 1 ; i<=list.size();i++){
+            HiveBeehive hiveBeehive = list.get(i - 1);
+            ExcelDto excelDto = new ExcelDto();
+            excelDto.setSerial(i);
+            excelDto.setUploadTime(hiveBeehive.getCreateDate());
+            excelDto.setHumi(hiveBeehive.getHumi());
+            excelDto.setHumiOut(hiveBeehive.getHumiOut());
+            excelDto.setTemp(hiveBeehive.getTemp());
+            excelDto.setTempOut(hiveBeehive.getTempOut());
+            excelDto.setOther1(hiveBeehive.getOther1());
+
+            excelDtos.add(excelDto);
+        }
+
+
+
+        ExcelWriter writer = ExcelUtil.getWriter();
+//        ExcelWriter writer = ExcelUtil.getWriter("d:/writeBeanTest.xlsx");
+        writer.addHeaderAlias("serial", "序号");
+        writer.addHeaderAlias("uploadTime", "时间");
+        writer.addHeaderAlias("temp", "室内温度");
+        writer.addHeaderAlias("humi", "室内湿度");
+        writer.addHeaderAlias("tempOut", "室外温度");
+        writer.addHeaderAlias("humiOut", "室外湿度");
+        writer.addHeaderAlias("other1", "蜜蜂状态");
+        writer.write(excelDtos,true);
+        ServletOutputStream out = null;
+        try {
+            out = response.getOutputStream();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
 
-        return new Result(ResultCode.SUCCESS,this.list(wrapper));
+        writer.flush(out);
+        writer.close();
+//        return new Result(ResultCode.SUCCESS,excelDtos);
     }
 }

+ 20 - 0
beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveWarningServiceImpl.java

@@ -0,0 +1,20 @@
+package com.huimv.beeboxs.service.impl;
+
+import com.huimv.beeboxs.entity.HiveWarning;
+import com.huimv.beeboxs.mapper.HiveWarningMapper;
+import com.huimv.beeboxs.service.IHiveWarningService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author author
+ * @since 2022-08-29
+ */
+@Service
+public class HiveWarningServiceImpl extends ServiceImpl<HiveWarningMapper, HiveWarning> implements IHiveWarningService {
+
+}

+ 54 - 0
beeboxs/src/main/java/com/huimv/beeboxs/service/impl/HiveWeightServiceImpl.java

@@ -0,0 +1,54 @@
+package com.huimv.beeboxs.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.huimv.beeboxs.common.utils.Result;
+import com.huimv.beeboxs.common.utils.ResultCode;
+import com.huimv.beeboxs.entity.HiveBeehive;
+import com.huimv.beeboxs.entity.HiveWeight;
+import com.huimv.beeboxs.mapper.HiveWeightMapper;
+import com.huimv.beeboxs.service.IHiveWeightService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author author
+ * @since 2022-04-28
+ */
+@Service
+public class HiveWeightServiceImpl extends ServiceImpl<HiveWeightMapper, HiveWeight> implements IHiveWeightService {
+
+    @Override
+    public Result searchList(Map map) {
+        String startDate = (String)map.get("startDate");
+        String endDate = (String)map.get("endDate");
+        String hiveId = (String)map.get("hiveId");
+
+        QueryWrapper<HiveWeight> wrapper = new QueryWrapper<>();
+        if (StringUtils.isBlank(hiveId)){
+            return new Result(10001,"请选择蜂箱",false);
+        }
+        wrapper.eq("uid_hex",hiveId);
+//        wrapper.orderByDesc("create_date");
+
+        if (StringUtils.isNotBlank(startDate)){
+            startDate = startDate+" 00:00:00";
+            wrapper.ge("update_time",startDate);
+        }
+
+        if (StringUtils.isNotBlank(endDate)){
+            endDate = endDate+" 23:59:59";
+            wrapper.le("update_time",endDate);
+        }
+
+        wrapper.orderByAsc("update_time");
+
+        return new Result(ResultCode.SUCCESS,this.list(wrapper));
+    }
+}

+ 2 - 1
beeboxs/src/main/resources/application-dev.yml

@@ -6,7 +6,8 @@ spring:
     name: huimv-admin
 
   datasource:
-    url: jdbc:mysql://192.168.1.7:3306/huimv-hive?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    url: jdbc:mysql://115.238.57.190:3306/huimv-hive?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://115.238.57.190:3306/huimv-hive?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
     username: root
     password: hm123456
     driver-class-name: com.mysql.cj.jdbc.Driver

+ 15 - 0
beeboxs/src/main/resources/mapper/HiveWarningMapper.xml

@@ -0,0 +1,15 @@
+<?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.huimv.beeboxs.mapper.HiveWarningMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.huimv.beeboxs.entity.HiveWarning">
+        <id column="id" property="id" />
+        <result column="farm_id" property="farmId" />
+        <result column="msg_type" property="msgType" />
+        <result column="device_id_hex" property="deviceIdHex" />
+        <result column="event_type" property="eventType" />
+        <result column="event_time" property="eventTime" />
+    </resultMap>
+
+</mapper>

+ 16 - 0
beeboxs/src/main/resources/mapper/HiveWeightMapper.xml

@@ -0,0 +1,16 @@
+<?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.huimv.beeboxs.mapper.HiveWeightMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.huimv.beeboxs.entity.HiveWeight">
+        <id column="id" property="id" />
+        <result column="weight" property="weight" />
+        <result column="update_time" property="updateTime" />
+        <result column="uid_hex" property="uidHex" />
+        <result column="ap_uid_hex" property="apUidHex" />
+        <result column="farm_id" property="farmId" />
+        <result column="increment" property="increment" />
+    </resultMap>
+
+</mapper>

+ 2 - 1
beeboxs/target/classes/application-dev.yml

@@ -6,7 +6,8 @@ spring:
     name: huimv-admin
 
   datasource:
-    url: jdbc:mysql://192.168.1.7:3306/huimv-hive?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    url: jdbc:mysql://115.238.57.190:3306/huimv-hive?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://115.238.57.190:3306/huimv-hive?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
     username: root
     password: hm123456
     driver-class-name: com.mysql.cj.jdbc.Driver

BIN
beeboxs/target/classes/com/huimv/beeboxs/BeeboxsApplication.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/common/utils/AirQualityIndexUtil.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/config/InterceptorConfig.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/controller/HiveBaseBeehiveController.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/controller/HiveBaseStationController.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/controller/HiveBeehiveController.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/controller/LoginController.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/controller/OpenCotroller.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/dahuaVideo/controller/SetDahuaAccountToFarmInfoController.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/dahuaVideo/util/HttpSend.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/entity/BaseHiveFarm.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/entity/HiveBaseBeehive.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/entity/HiveBeehive.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/entity/HiveBeehiveOut.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/entity/HiveStation.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/entity/dto/HiveBaseBeeStationDao.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/entity/vo/HiveBaseStationVo.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/service/IHiveBaseStationService.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/service/IHiveBeehiveService.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/service/impl/HiveBaseBeehiveServiceImpl.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/service/impl/HiveBaseStationServiceImpl.class


BIN
beeboxs/target/classes/com/huimv/beeboxs/service/impl/HiveBeehiveServiceImpl.class