523096025 2 роки тому
батько
коміт
f0e31cb115

+ 1 - 1
huimv-env-platform/huimv-env-common/src/main/java/com/huimv/env/common/dao/repo/EnvElectricityMeterRepo.java

@@ -13,6 +13,6 @@ public interface EnvElectricityMeterRepo extends JpaRepository<EnvElectricityMet
     @Query(nativeQuery = true,value = "SELECT *  FROM env_electricity_meter WHERE device_code=?1  ORDER BY id DESC LIMIT 1")
     EnvElectricityMeter getOneByMaxId(String deviceCode);
 
-    @Query(nativeQuery = true,value = "SELECT SUM(electricity_meter) total FROM `env_water_meter` WHERE farm_code=?1 AND device_code=?2 AND add_date=?3")
+    @Query(nativeQuery = true,value = "SELECT SUM(electricity_meter) total FROM `env_electricity_meter` WHERE farm_code=?1 AND device_code=?2 AND add_date=?3")
     List<Object[]> getSumElectricityMeter(String farmCode, String deviceCode, Date todayDate);
 }

+ 1 - 0
huimv-env-platform/huimv-env-lamp/src/main/java/com/huimv/env/lamp/server/LampInputServer.java

@@ -57,6 +57,7 @@ public class LampInputServer extends Thread{
                     .childHandler(new ChannelInitializer<SocketChannel>() {
                         @Override
                         protected void initChannel(SocketChannel socketChannel) throws Exception {
+                            System.out.println("连接建立");
                             socketChannel.pipeline().addLast(serverHandler);
                         }
                     });

+ 4 - 0
huimv-env-platform/huimv-env-lamp/src/main/java/com/huimv/env/lamp/server/LampInputServerHandler.java

@@ -92,6 +92,10 @@ public class LampInputServerHandler extends ChannelInboundHandlerAdapter {
     }
 
     @Override
+    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+       log.info("连接断开");
+    }
+    @Override
     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
         if (cause.getMessage().indexOf("Connection reset") != -1) {
             log.info("相关采集器设备正在重启:" + cause.toString());

+ 0 - 1
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/HuimvEnvProduceApplication.java

@@ -24,7 +24,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 //@MapperScan("com.huimv.env.manage.mapper")
 @EntityScan(value = "com.huimv.env.common.dao.entity")
 @EnableJpaRepositories(basePackages = "com.huimv.env.common.dao.repo")
-
 public class HuimvEnvProduceApplication {
     public static void main(String[] args)   {
         SpringApplication.run(HuimvEnvProduceApplication.class, args);

+ 25 - 0
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/controller/DataSourceController.java

@@ -1,12 +1,15 @@
 package com.huimv.env.produce.controller;
 
 
+import cn.hutool.core.util.RandomUtil;
 import com.huimv.common.utils.Result;
+import com.huimv.common.utils.ResultCode;
 import com.huimv.env.produce.service.DataSourceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.text.ParseException;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -23,6 +26,28 @@ public class DataSourceController {
     @Autowired
     private DataSourceService dataSourceService;
 
+
+    //查询
+    @PostMapping("/getLastEnviron")
+    public Result getLastEnviron() {
+        Map map = new HashMap();
+        //ph
+        map.put("phPj","7."+getRandom(0,1000));
+        //cod
+        map.put("hxxylPj","210."+getRandom(0,1000));
+        //总磷
+        map.put("lin","4."+getRandom(0,10));
+        //总氮
+        map.put("dan","11."+getRandom(0,10));
+        //污水流量
+        map.put("water","7."+getRandom(0,1000));
+        //氨氮
+        map.put("ad","0.0"+getRandom(0,100));
+        return new Result(ResultCode.SUCCESS,map);
+    }
+    public static Integer getRandom(Integer min,Integer max){
+        return RandomUtil.randomInt(min, max);
+    }
     //查询
     @PostMapping("/getDataSource")
     public Result getDataSource(@RequestBody Map<String, String> paramsMap) throws ParseException {