Explorar el Código

2021/7/7 室内环境数据

yinhao hace 4 años
padre
commit
796b4c4a3b
Se han modificado 24 ficheros con 993 adiciones y 284 borrados
  1. 21 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/config/FeignLogConfig.java
  2. 69 69
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/controller/HuimvDeviceController.java
  3. 20 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/dao/DeviceDataDao.java
  4. 57 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/entity/DeviceDataEntity.java
  5. 67 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/entity/IndoorEnvironmentEntity.java
  6. 1 1
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/entity/WarningInfoEntity.java
  7. 35 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/enums/CmdEnum.java
  8. 32 6
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/feign/ManagementFeignService.java
  9. 21 21
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/service/DeviceUpDataService.java
  10. 47 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/service/HandleDataPackageService.java
  11. 122 124
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/service/impl/DeviceUpDataServiceImpl.java
  12. 97 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/service/impl/HandleDataPackageServiceImpl.java
  13. 146 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/ClientDataPacketServiceImpl.java
  14. 22 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/IClientDataPacketService.java
  15. 44 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/Server.java
  16. 80 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/ServerThread.java
  17. 83 0
      huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/TcpSendAndRecv.java
  18. 6 0
      huimv-smart-datacollection/src/main/resources/application-dev.yml
  19. 2 4
      huimv-smart-management/src/main/java/com/huimv/management/entity/DrinkingWaterEntity.java
  20. 4 14
      huimv-smart-management/src/main/java/com/huimv/management/entity/IndoorEnvironmentEntity.java
  21. 8 36
      huimv-smart-management/src/main/java/com/huimv/management/entity/vo/IndoorEnvironmentVo.java
  22. 1 1
      huimv-smart-management/src/main/java/com/huimv/management/entity/vo/WarningInfoVo.java
  23. 4 8
      huimv-smart-management/src/main/resources/mapper/management/IndoorEnvironmentDao.xml
  24. 4 0
      renren-fast/pom.xml

+ 21 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/config/FeignLogConfig.java

@@ -0,0 +1,21 @@
+package com.huimv.datacollection.config;
+
+import feign.Logger;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class FeignLogConfig {
+
+    /**
+     * NONE: 不记录
+     * BASIC: 记录基本的请求行,响应状态码
+     * HEADERS: 记录响应的头信息
+     * FULL: 记录完整的请求和响应的数据
+     * @return
+     */
+    @Bean
+    public Logger.Level level(){
+        return Logger.Level.FULL;
+    }
+}

+ 69 - 69
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/controller/HuimvDeviceController.java

@@ -1,69 +1,69 @@
-package com.huimv.datacollection.controller;
-
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.huimv.datacollection.service.DeviceUpDataService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-
-/**
- * <p>
- * 慧牧环控设备
- * </p>
- *
- * @author yinhao
- * @version 1.0
- * @date 2021/7/5 15:13
- */
-@Slf4j
-@RestController
-@RequestMapping(value = "/deviceData", method = RequestMethod.POST)
-public class HuimvDeviceController {
-
-
-    @Autowired
-    private DeviceUpDataService deviceUpDataService;
-
-
-    @RequestMapping(value = "/deviceChange", method = {RequestMethod.GET, RequestMethod.POST})
-    public void deviceUpAndDown(HttpServletRequest request, HttpServletResponse response) {
-        DateTime date = DateUtil.date();
-        log.info("开始时间------>" + date);
-
-        StringBuffer result = new StringBuffer();
-        BufferedReader br = null;
-        try {
-            br = new BufferedReader(new InputStreamReader(request.getInputStream(), StandardCharsets.UTF_8));
-            String temp;
-            while ((temp = br.readLine()) != null) {
-                result.append(temp);
-            }
-            JSONObject jsonData = JSONObject.parseObject(result.toString());
-            deviceUpDataService.saveDeviceUpData(jsonData);
-
-        } catch (IOException e) {
-            log.error(e.getMessage(), e);
-            //关闭字符输入流
-        } finally {
-            if (br != null) {
-                try {
-                    br.close();
-                } catch (IOException e) {
-                    log.error(e.getMessage(), e);
-                }
-            }
-
-        }
-    }
-}
+//package com.huimv.datacollection.controller;
+//
+//import cn.hutool.core.date.DateTime;
+//import cn.hutool.core.date.DateUtil;
+//import com.alibaba.fastjson.JSONObject;
+//import com.huimv.datacollection.service.DeviceUpDataService;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//import org.springframework.web.bind.annotation.RequestMethod;
+//import org.springframework.web.bind.annotation.RestController;
+//
+//import javax.servlet.http.HttpServletRequest;
+//import javax.servlet.http.HttpServletResponse;
+//import java.io.BufferedReader;
+//import java.io.IOException;
+//import java.io.InputStreamReader;
+//import java.nio.charset.StandardCharsets;
+//
+///**
+// * <p>
+// * 慧牧环控设备
+// * </p>
+// *
+// * @author yinhao
+// * @version 1.0
+// * @date 2021/7/5 15:13
+// */
+//@Slf4j
+//@RestController
+//@RequestMapping(value = "/deviceData", method = RequestMethod.POST)
+//public class HuimvDeviceController {
+//
+//
+//    @Autowired
+//    private DeviceUpDataService deviceUpDataService;
+//
+//
+//    @RequestMapping(value = "/deviceChange", method = {RequestMethod.GET, RequestMethod.POST})
+//    public void deviceUpAndDown(HttpServletRequest request, HttpServletResponse response) {
+//        DateTime date = DateUtil.date();
+//        log.info("开始时间------>" + date);
+//
+//        StringBuffer result = new StringBuffer();
+//        BufferedReader br = null;
+//        try {
+//            br = new BufferedReader(new InputStreamReader(request.getInputStream(), StandardCharsets.UTF_8));
+//            String temp;
+//            while ((temp = br.readLine()) != null) {
+//                result.append(temp);
+//            }
+//            JSONObject jsonData = JSONObject.parseObject(result.toString());
+//            deviceUpDataService.saveDeviceUpData(jsonData);
+//
+//        } catch (IOException e) {
+//            log.error(e.getMessage(), e);
+//            //关闭字符输入流
+//        } finally {
+//            if (br != null) {
+//                try {
+//                    br.close();
+//                } catch (IOException e) {
+//                    log.error(e.getMessage(), e);
+//                }
+//            }
+//
+//        }
+//    }
+//}

+ 20 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/dao/DeviceDataDao.java

@@ -0,0 +1,20 @@
+package com.huimv.datacollection.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.huimv.datacollection.entity.DeviceDataEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * <p>
+ * 设备数据包
+ * </p>
+ *
+ * @author yinhao
+ * @date 2021/7/7 17:14
+ */
+@Mapper
+@Repository
+public interface DeviceDataDao extends BaseMapper<DeviceDataEntity> {
+
+}

+ 57 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/entity/DeviceDataEntity.java

@@ -0,0 +1,57 @@
+package com.huimv.datacollection.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * <p>
+ * 设备数据包
+ * </p>
+ *
+ * @author yinhao
+ * @date 2021/7/7 16:42
+ */
+@Data
+@TableName("dc_device_data")
+public class DeviceDataEntity {
+
+    /**
+     * 主键
+     */
+    @TableId
+    private Integer id;
+    /**
+     * 命令头
+     */
+    private String cmdHeader;
+    /**
+     * 机器id
+     */
+    private String jqId;
+    /**
+     * 命令类型
+     */
+    private Integer cmdType;
+    /**
+     * 序号
+     */
+    private Integer sequence;
+    /**
+     * 数值
+     */
+    private Double value;
+    /**
+     * 时间
+     */
+    private String time;
+    /**
+     * 校验
+     */
+    private Integer verify;
+    /**
+     * 命令尾
+     */
+    private String cmdEnd;
+
+}

+ 67 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/entity/IndoorEnvironmentEntity.java

@@ -0,0 +1,67 @@
+package com.huimv.datacollection.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 室内环境信息实体类
+ *
+ * @author yinhao
+ * @version 1.0
+ * @date 2021-05-07 15:32:42
+ */
+@Data
+@TableName("mgt_indoor_environment")
+public class IndoorEnvironmentEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * id
+     */
+    @TableId
+    private Integer id;
+
+    /**
+     * 牧场id
+     */
+    private Integer farmId;
+    /**
+     * 豬舍id
+     */
+    private Integer pigstyId;
+    /**
+     * 类型
+     */
+    private Integer type;
+    /**
+     * 数值
+     */
+    private Double value;
+    /**
+     * 采集时间
+     */
+    private Date collectTime;
+
+    /**
+     * 异常状态 0.正常 1.异常
+     */
+    private Boolean abnormalStatus;
+    /**
+     * 删除状态 0正常 其他:已删除
+     */
+    @TableLogic
+    private Integer deleted;
+    /**
+     * 创建时间
+     */
+    @TableField(fill = FieldFill.INSERT)
+    private Date gmtCreate;
+    /**
+     * 修改时间
+     */
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Date gmtModified;
+
+}

+ 1 - 1
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/entity/WarningInfoEntity.java

@@ -29,7 +29,7 @@ public class WarningInfoEntity implements Serializable {
 	/**
 	 * 当前日期
 	 */
-	@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GTM+8")
+	//@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GTM+8")
 	private Date nowDate;
 	/**
 	 * 牧场id

+ 35 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/enums/CmdEnum.java

@@ -0,0 +1,35 @@
+package com.huimv.datacollection.enums;
+
+/**
+ * <p>
+ * 命令类型枚举
+ * </p>
+ *
+ * @author yinhao
+ * @date 2021/7/8 9:28
+ */
+public enum CmdEnum {
+
+    /**
+     * 温度
+     */
+    TEMPERATURE("7"),
+    /**
+     * 湿度
+     */
+    HUMIDITY("8"),
+    /**
+     * 氨气
+     */
+    GAS("9");
+
+    private String typeNum;
+
+    CmdEnum(String typeNum) {
+        this.typeNum = typeNum;
+    }
+
+    public String getTypeNum() {
+        return typeNum;
+    }
+}

+ 32 - 6
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/feign/ManagementFeignService.java

@@ -1,6 +1,8 @@
 package com.huimv.datacollection.feign;
 
 import com.huimv.common.utils.R;
+import com.huimv.datacollection.config.FeignLogConfig;
+import com.huimv.datacollection.entity.IndoorEnvironmentEntity;
 import com.huimv.datacollection.entity.WarningInfoEntity;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -18,15 +20,39 @@ import java.util.Map;
  * @author yinhao
  * @date 2021/7/6 9:24
  */
-@FeignClient(value = "huimv-smart-management")
+@FeignClient(value = "huimv-smart-management",configuration = FeignLogConfig.class)
 public interface ManagementFeignService {
 
-    @GetMapping("/management/thresholdManagement/selectByType/{type}")
-    Map<String,Double> selectByType(@PathVariable("type") Short type);
-
+    /**
+     * 设备信息
+     * @param deviceId
+     * @return
+     */
     @GetMapping("/management/device/info/{deviceId}")
-    R info(@PathVariable("deviceId") String deviceId);
+    R deviceInfo(@PathVariable("deviceId") String deviceId);
 
+    /**
+     * 根据类型查询阈值
+     *
+     * @param type
+     * @return
+     */
+    @GetMapping("/management/thresholdManagement/selectByType/{type}")
+    Map<String, Double> selectByType(@PathVariable("type") Short type);
+
+    /**
+     * 保存报警信息
+     * @param warningInfo
+     * @return
+     */
     @PostMapping("/management/warningInfo/save")
-    R save(@RequestBody WarningInfoEntity warningInfo);
+    R saveWarningInfo(@RequestBody WarningInfoEntity warningInfo);
+
+    /**
+     * 保存室内环境数据
+     * @param indoorEnvironment
+     * @return
+     */
+    @PostMapping("/management/indoorEnvironment/save")
+    R saveIndoorEnvironment(@RequestBody IndoorEnvironmentEntity indoorEnvironment);
 }

+ 21 - 21
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/service/DeviceUpDataService.java

@@ -1,21 +1,21 @@
-package com.huimv.datacollection.service;
-
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.huimv.datacollection.entity.DeviceUpDataEntity;
-
-/**
- * <p>
- *
- * </p>
- *
- * @author yinhao
- * @date 2021/7/5 16:06
- */
-public interface DeviceUpDataService extends IService<DeviceUpDataEntity> {
-    /**
-     * 保存设备上传数据
-     * @param jsonData
-     */
-    void saveDeviceUpData(JSONObject jsonData);
-}
+//package com.huimv.datacollection.service;
+//
+//import com.alibaba.fastjson.JSONObject;
+//import com.baomidou.mybatisplus.extension.service.IService;
+//import com.huimv.datacollection.entity.DeviceUpDataEntity;
+//
+///**
+// * <p>
+// *
+// * </p>
+// *
+// * @author yinhao
+// * @date 2021/7/5 16:06
+// */
+//public interface DeviceUpDataService extends IService<DeviceUpDataEntity> {
+//    /**
+//     * 保存设备上传数据
+//     * @param jsonData
+//     */
+//    void saveDeviceUpData(JSONObject jsonData);
+//}

+ 47 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/service/HandleDataPackageService.java

@@ -0,0 +1,47 @@
+package com.huimv.datacollection.service;
+
+import com.huimv.datacollection.entity.IndoorEnvironmentEntity;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 数据包处理service
+ * </p>
+ *
+ * @author yinhao
+ * @date 2021/7/7 17:30
+ */
+public interface HandleDataPackageService {
+
+    /**
+     * 温度处理
+     *
+     * @param indoorEnvironmentEntity
+     * @param value
+     * @param farmId
+     * @param pigstyId
+     * @param map
+     */
+    void handleTemperature(IndoorEnvironmentEntity indoorEnvironmentEntity, Double value, Integer farmId, Integer pigstyId, Map<String, Double> map);
+
+    /**
+     * 湿度处理
+     * @param indoorEnvironmentEntity
+     * @param value
+     * @param farmId
+     * @param pigstyId
+     * @param map
+     */
+    void handleHumidity(IndoorEnvironmentEntity indoorEnvironmentEntity, double value, Integer farmId, Integer pigstyId, Map<String, Double> map);
+
+    /**
+     * 氨气处理
+     * @param indoorEnvironmentEntity
+     * @param value
+     * @param farmId
+     * @param pigstyId
+     * @param map
+     */
+    void handleGas(IndoorEnvironmentEntity indoorEnvironmentEntity, double value, Integer farmId, Integer pigstyId, Map<String, Double> map);
+}

+ 122 - 124
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/service/impl/DeviceUpDataServiceImpl.java

@@ -1,124 +1,122 @@
-package com.huimv.datacollection.service.impl;
-
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.huimv.common.exception.RRException;
-import com.huimv.common.utils.MathUtil;
-import com.huimv.common.utils.R;
-import com.huimv.datacollection.dao.DeviceUpDataDao;
-import com.huimv.datacollection.entity.DeviceEntity;
-import com.huimv.datacollection.entity.DeviceUpDataEntity;
-import com.huimv.datacollection.entity.WarningInfoEntity;
-import com.huimv.datacollection.feign.ManagementFeignService;
-import com.huimv.datacollection.service.DeviceUpDataService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.Map;
-
-/**
- * <p>
- * 设备数据上传和报警
- * </p>
- *
- * @author yinhao
- * @date 2021/7/5 16:12
- */
-@Service("deviceUpDataServiceImpl")
-public class DeviceUpDataServiceImpl extends ServiceImpl<DeviceUpDataDao, DeviceUpDataEntity> implements DeviceUpDataService {
-
-    @Autowired
-    ManagementFeignService managementFeignService;
-
-    @Override
-    public void saveDeviceUpData(JSONObject jsonData) {
-        String productId = jsonData.getString("productId");
-        String deviceId = jsonData.getString("deviceId");
-        long timestamp = jsonData.getLong("timestamp");
-        String upDataDate = DateUtil.date(timestamp).toString();
-        String serviceId = jsonData.getString("serviceId");
-        String imsi = jsonData.getString("IMSI");
-        String imei = jsonData.getString("IMEI");
-        String deviceType = jsonData.getString("deviceType");
-        String messageType = jsonData.getString("messageType");
-        String protocol = jsonData.getString("protocol");
-        String tenantId = jsonData.getString("tenantId");
-        JSONObject businessDataJo = jsonData.getJSONObject("payload");
-        int dataVer = businessDataJo.getInteger("VER");
-        int dataTime = businessDataJo.getInteger("TIME");
-        int dataTemp = businessDataJo.getInteger("TEMP");
-        int dataStc = businessDataJo.getInteger("STC");
-        int dataRssi = businessDataJo.getInteger("RSSI");
-        int dataHumi = businessDataJo.getInteger("HUMI");
-        int dataBat = businessDataJo.getInteger("BAT");
-        DeviceUpDataEntity deviceUpdataEntity = new DeviceUpDataEntity();
-        deviceUpdataEntity.setProductId(productId);
-        deviceUpdataEntity.setDeviceId(deviceId);
-        deviceUpdataEntity.setTimestamp(upDataDate);
-        deviceUpdataEntity.setServiceId(serviceId);
-        deviceUpdataEntity.setImei(imei);
-        deviceUpdataEntity.setImsi(imsi);
-        deviceUpdataEntity.setDeviceType(deviceType);
-        deviceUpdataEntity.setMessageType(messageType);
-        deviceUpdataEntity.setProtocol(protocol);
-        deviceUpdataEntity.setDataVer(dataVer);
-        deviceUpdataEntity.setDataTime(dataTime);
-        deviceUpdataEntity.setDataTemp(dataTemp);
-        deviceUpdataEntity.setDataStc(dataStc);
-        deviceUpdataEntity.setDataRssi(dataRssi);
-        deviceUpdataEntity.setDataHumi(dataHumi);
-        deviceUpdataEntity.setDataBat(dataBat);
-        deviceUpdataEntity.setTenantId(tenantId);
-        double dataTempConvert = MathUtil.formatDecimalNumber(dataTemp * 0.1, 1);
-        deviceUpdataEntity.setDataTempConvert(dataTempConvert);
-        double dataHumiConvert = MathUtil.formatDecimalNumber(dataHumi * 0.1, 1);
-        deviceUpdataEntity.setDataHumiConvert(dataHumiConvert);
-        deviceUpdataEntity.setDataBatConvert(MathUtil.formatDecimalNumber(dataBat * 0.01, 1));
-        save(deviceUpdataEntity);
-
-
-        Map<String, Double> map = managementFeignService.selectByType((short) 1);
-        Double highTemp = map.get("高温");
-        double highTempThreshold = highTemp == null ? 40.0 : highTemp;
-        Double lowTemp = map.get("低温");
-        double lowTempThreshold = lowTemp == null ? 15.0 : lowTemp;
-
-        if (dataTempConvert > highTempThreshold) {
-            insertWarningInfo(deviceId, dataTempConvert, "高温");
-        } else if (dataTempConvert < lowTempThreshold) {
-            insertWarningInfo(deviceId, dataTempConvert, "低温");
-
-        }
-        Double highHumidity = map.get("湿度过高");
-        double highHumidityThreshold = highHumidity == null ? 80.0 : highHumidity;
-        Double lowHumidity = map.get("湿度过低");
-        double lowHumidityThreshold = lowHumidity == null ? 30.0 : lowHumidity;
-        if (dataHumiConvert > highHumidityThreshold) {
-            insertWarningInfo(deviceId,dataHumiConvert,"湿度过高");
-        } else if (dataHumiConvert < lowHumidityThreshold) {
-            insertWarningInfo(deviceId,dataHumiConvert,"湿度过低");
-        }
-
-
-    }
-
-    private void insertWarningInfo(String deviceId, double nowValue, String warningType) {
-        DeviceEntity deviceInfo = (DeviceEntity) managementFeignService.info(deviceId).get("device");
-        WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
-        DateTime date = DateUtil.date();
-        warningInfoEntity.setNowDate(date);
-        warningInfoEntity.setFarmId(deviceInfo.getFarmId());
-        warningInfoEntity.setPigstyId(deviceInfo.getPigstyId());
-        warningInfoEntity.setWarningType(warningType);
-        warningInfoEntity.setBelongTo((short) 1);
-        warningInfoEntity.setNowValue(nowValue);
-        warningInfoEntity.setWarningTime(date);
-
-        managementFeignService.save(warningInfoEntity);
-
-    }
-
-
-}
+//package com.huimv.datacollection.service.impl;
+//
+//import cn.hutool.core.date.DateTime;
+//import cn.hutool.core.date.DateUtil;
+//import com.alibaba.fastjson.JSONObject;
+//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+//import com.huimv.common.utils.MathUtil;
+//import com.huimv.datacollection.dao.DeviceUpDataDao;
+//import com.huimv.datacollection.entity.DeviceEntity;
+//import com.huimv.datacollection.entity.DeviceUpDataEntity;
+//import com.huimv.datacollection.entity.WarningInfoEntity;
+//import com.huimv.datacollection.feign.ManagementFeignService;
+//import com.huimv.datacollection.service.DeviceUpDataService;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//
+//import java.util.Map;
+//
+///**
+// * <p>
+// * 设备数据上传和报警
+// * </p>
+// *
+// * @author yinhao
+// * @date 2021/7/5 16:12
+// */
+//@Service("deviceUpDataServiceImpl")
+//public class DeviceUpDataServiceImpl extends ServiceImpl<DeviceUpDataDao, DeviceUpDataEntity> implements DeviceUpDataService {
+//
+//    @Autowired
+//    ManagementFeignService managementFeignService;
+//
+//    @Override
+//    public void saveDeviceUpData(JSONObject jsonData) {
+//        String productId = jsonData.getString("productId");
+//        String deviceId = jsonData.getString("deviceId");
+//        long timestamp = jsonData.getLong("timestamp");
+//        String upDataDate = DateUtil.date(timestamp).toString();
+//        String serviceId = jsonData.getString("serviceId");
+//        String imsi = jsonData.getString("IMSI");
+//        String imei = jsonData.getString("IMEI");
+//        String deviceType = jsonData.getString("deviceType");
+//        String messageType = jsonData.getString("messageType");
+//        String protocol = jsonData.getString("protocol");
+//        String tenantId = jsonData.getString("tenantId");
+//        JSONObject businessDataJo = jsonData.getJSONObject("payload");
+//        int dataVer = businessDataJo.getInteger("VER");
+//        int dataTime = businessDataJo.getInteger("TIME");
+//        int dataTemp = businessDataJo.getInteger("TEMP");
+//        int dataStc = businessDataJo.getInteger("STC");
+//        int dataRssi = businessDataJo.getInteger("RSSI");
+//        int dataHumi = businessDataJo.getInteger("HUMI");
+//        int dataBat = businessDataJo.getInteger("BAT");
+//        DeviceUpDataEntity deviceUpdataEntity = new DeviceUpDataEntity();
+//        deviceUpdataEntity.setProductId(productId);
+//        deviceUpdataEntity.setDeviceId(deviceId);
+//        deviceUpdataEntity.setTimestamp(upDataDate);
+//        deviceUpdataEntity.setServiceId(serviceId);
+//        deviceUpdataEntity.setImei(imei);
+//        deviceUpdataEntity.setImsi(imsi);
+//        deviceUpdataEntity.setDeviceType(deviceType);
+//        deviceUpdataEntity.setMessageType(messageType);
+//        deviceUpdataEntity.setProtocol(protocol);
+//        deviceUpdataEntity.setDataVer(dataVer);
+//        deviceUpdataEntity.setDataTime(dataTime);
+//        deviceUpdataEntity.setDataTemp(dataTemp);
+//        deviceUpdataEntity.setDataStc(dataStc);
+//        deviceUpdataEntity.setDataRssi(dataRssi);
+//        deviceUpdataEntity.setDataHumi(dataHumi);
+//        deviceUpdataEntity.setDataBat(dataBat);
+//        deviceUpdataEntity.setTenantId(tenantId);
+//        double dataTempConvert = MathUtil.formatDecimalNumber(dataTemp * 0.1, 1);
+//        deviceUpdataEntity.setDataTempConvert(dataTempConvert);
+//        double dataHumiConvert = MathUtil.formatDecimalNumber(dataHumi * 0.1, 1);
+//        deviceUpdataEntity.setDataHumiConvert(dataHumiConvert);
+//        deviceUpdataEntity.setDataBatConvert(MathUtil.formatDecimalNumber(dataBat * 0.01, 1));
+//        save(deviceUpdataEntity);
+//
+//
+//        Map<String, Double> map = managementFeignService.selectByType((short) 1);
+//        Double highTemp = map.get("高温");
+//        double highTempThreshold = highTemp == null ? 40.0 : highTemp;
+//        Double lowTemp = map.get("低温");
+//        double lowTempThreshold = lowTemp == null ? 15.0 : lowTemp;
+//
+//        if (dataTempConvert > highTempThreshold) {
+//            insertWarningInfo(deviceId, dataTempConvert, "高温");
+//        } else if (dataTempConvert < lowTempThreshold) {
+//            insertWarningInfo(deviceId, dataTempConvert, "低温");
+//
+//        }
+//        Double highHumidity = map.get("湿度过高");
+//        double highHumidityThreshold = highHumidity == null ? 80.0 : highHumidity;
+//        Double lowHumidity = map.get("湿度过低");
+//        double lowHumidityThreshold = lowHumidity == null ? 30.0 : lowHumidity;
+//        if (dataHumiConvert > highHumidityThreshold) {
+//            insertWarningInfo(deviceId,dataHumiConvert,"湿度过高");
+//        } else if (dataHumiConvert < lowHumidityThreshold) {
+//            insertWarningInfo(deviceId,dataHumiConvert,"湿度过低");
+//        }
+//
+//
+//    }
+//
+//    private void insertWarningInfo(String deviceId, double nowValue, String warningType) {
+//        DeviceEntity deviceInfo = JSONObject.parseObject(JSONObject.toJSONString(managementFeignService.deviceInfo(deviceId).get("device")), DeviceEntity.class);
+//        WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
+//        DateTime date = DateUtil.date();
+//        warningInfoEntity.setNowDate(DateUtil.beginOfDay(date));
+//        warningInfoEntity.setFarmId(deviceInfo.getFarmId());
+//        warningInfoEntity.setPigstyId(deviceInfo.getPigstyId());
+//        warningInfoEntity.setWarningType(warningType);
+//        warningInfoEntity.setBelongTo((short) 1);
+//        warningInfoEntity.setNowValue(nowValue);
+//        warningInfoEntity.setWarningTime(date);
+//
+//        managementFeignService.saveWarningInfo(warningInfoEntity);
+//
+//    }
+//
+//
+//}

+ 97 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/service/impl/HandleDataPackageServiceImpl.java

@@ -0,0 +1,97 @@
+package com.huimv.datacollection.service.impl;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.huimv.datacollection.entity.IndoorEnvironmentEntity;
+import com.huimv.datacollection.entity.WarningInfoEntity;
+import com.huimv.datacollection.feign.ManagementFeignService;
+import com.huimv.datacollection.service.HandleDataPackageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 数据包处理serviceImpl
+ * </p>
+ *
+ * @author yinhao
+ * @date 2021/7/7 17:36
+ */
+@Service
+public class HandleDataPackageServiceImpl implements HandleDataPackageService {
+
+    @Autowired
+    private ManagementFeignService managementFeignService;
+
+    @Override
+    public void handleTemperature(IndoorEnvironmentEntity indoorEnvironmentEntity, Double value, Integer farmId, Integer pigstyId, Map<String, Double> map) {
+        //获取室内阈值信息
+        Double highTemp = map.get("高温");
+        double highTempThreshold = highTemp == null ? 40.0 : highTemp;
+        Double lowTemp = map.get("低温");
+        double lowTempThreshold = lowTemp == null ? 15.0 : lowTemp;
+
+        if (value > highTempThreshold) {
+            WarningInfoEntity warningInfoEntity = createWarningInfo(farmId, pigstyId, value);
+            indoorEnvironmentEntity.setAbnormalStatus(true);
+            insertWarningInfo(warningInfoEntity, "高温");
+        } else if (value < lowTempThreshold) {
+            indoorEnvironmentEntity.setAbnormalStatus(true);
+            WarningInfoEntity warningInfoEntity = createWarningInfo(farmId, pigstyId, value);
+            insertWarningInfo(warningInfoEntity, "低温");
+        }
+
+        managementFeignService.saveIndoorEnvironment(indoorEnvironmentEntity);
+    }
+
+    @Override
+    public void handleHumidity(IndoorEnvironmentEntity indoorEnvironmentEntity, double value, Integer farmId, Integer pigstyId, Map<String, Double> map) {
+        Double highHumidity = map.get("湿度过高");
+        double highHumidityThreshold = highHumidity == null ? 90.0 : highHumidity;
+        Double lowHumidity = map.get("湿度过低");
+        double lowHumidityThreshold = lowHumidity == null ? 25.0 : lowHumidity;
+
+        if (value > highHumidityThreshold) {
+            WarningInfoEntity warningInfoEntity = createWarningInfo(farmId, pigstyId, value);
+            indoorEnvironmentEntity.setAbnormalStatus(true);
+            insertWarningInfo(warningInfoEntity, "湿度过高");
+        } else if (value < lowHumidityThreshold) {
+            indoorEnvironmentEntity.setAbnormalStatus(true);
+            WarningInfoEntity warningInfoEntity = createWarningInfo(farmId, pigstyId, value);
+            insertWarningInfo(warningInfoEntity, "湿度过低");
+        }
+
+        managementFeignService.saveIndoorEnvironment(indoorEnvironmentEntity);
+    }
+
+    @Override
+    public void handleGas(IndoorEnvironmentEntity indoorEnvironmentEntity, double value, Integer farmId, Integer pigstyId, Map<String, Double> map) {
+        Double highPpm = map.get("氨气浓度过高");
+        double highPpmThreshold = highPpm == null ? 50.0 : highPpm;
+
+        if (value > highPpmThreshold) {
+            WarningInfoEntity warningInfoEntity = createWarningInfo(farmId, pigstyId, value);
+            indoorEnvironmentEntity.setAbnormalStatus(true);
+            insertWarningInfo(warningInfoEntity, "氨气浓度过高");
+        }
+    }
+
+    private void insertWarningInfo(WarningInfoEntity warningInfoEntity, String warningType) {
+        warningInfoEntity.setWarningType(warningType);
+        warningInfoEntity.setBelongTo((short) 1);
+        managementFeignService.saveWarningInfo(warningInfoEntity);
+    }
+
+    private WarningInfoEntity createWarningInfo(Integer farmId, Integer pigstyId, Double value) {
+        WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
+        DateTime date = DateUtil.date();
+        warningInfoEntity.setNowDate(DateUtil.beginOfDay(date));
+        warningInfoEntity.setFarmId(farmId);
+        warningInfoEntity.setPigstyId(pigstyId);
+        warningInfoEntity.setNowValue(value);
+        warningInfoEntity.setWarningTime(date);
+        return warningInfoEntity;
+    }
+}

+ 146 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/ClientDataPacketServiceImpl.java

@@ -0,0 +1,146 @@
+package com.huimv.datacollection.tcp;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.common.exception.RRException;
+import com.huimv.datacollection.dao.DeviceDataDao;
+import com.huimv.datacollection.entity.DeviceDataEntity;
+import com.huimv.datacollection.entity.DeviceEntity;
+import com.huimv.datacollection.entity.IndoorEnvironmentEntity;
+import com.huimv.datacollection.enums.CmdEnum;
+import com.huimv.datacollection.feign.ManagementFeignService;
+import com.huimv.datacollection.service.HandleDataPackageService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @author yinhao
+ * @version 1.0
+ * @date 2021/07/07 15:07:00
+ **/
+@Service
+@Slf4j
+public class ClientDataPacketServiceImpl implements IClientDataPacketService {
+
+    @Autowired
+    private DeviceDataDao deviceDataDao;
+
+    @Autowired
+    private ManagementFeignService managementFeignService;
+
+    @Autowired
+    private HandleDataPackageService handleDataPackageService;
+
+    @Override
+    public String handleClientSendPacket(String clientMessageTxt) {
+
+        if (clientMessageTxt == null || clientMessageTxt.isEmpty()) {
+            log.error("本地提交数据包为空.");
+            return null;
+        }
+
+        String matcher = "[+]";
+        String[] clientMessageArray = clientMessageTxt.split(matcher);
+        String cmd = clientMessageArray[2];
+        log.info("本次执行命令>>" + cmd);
+
+        DeviceDataEntity deviceDataEntity = new DeviceDataEntity();
+        deviceDataEntity.setCmdHeader(clientMessageArray[0]);
+        String jqId = clientMessageArray[1];
+        deviceDataEntity.setJqId(jqId);
+        deviceDataEntity.setCmdType(Integer.parseInt(clientMessageArray[2]));
+        deviceDataEntity.setSequence(Integer.parseInt(clientMessageArray[3]));
+        Double value = null;
+        if (CmdEnum.TEMPERATURE.getTypeNum().equals(cmd) || CmdEnum.HUMIDITY.getTypeNum().equals(cmd)) {
+            value = new BigDecimal(clientMessageArray[4]).divide(new BigDecimal("10")).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+        } else if (CmdEnum.GAS.getTypeNum().equals(cmd)) {
+            value = Double.parseDouble(clientMessageArray[4]);
+        }
+        if (value == null) {
+            throw new RRException("传入数据包的数据字段为空,请检查!");
+        }
+        deviceDataEntity.setValue(value);
+        deviceDataEntity.setTime(clientMessageArray[5]);
+        deviceDataEntity.setVerify(Integer.parseInt(clientMessageArray[6]));
+        deviceDataEntity.setCmdEnd(clientMessageArray[7]);
+        deviceDataDao.insert(deviceDataEntity);
+
+        //获取设备信息并校验
+        String deviceJson = JSONObject.toJSONString(managementFeignService.deviceInfo(jqId).get("device"));
+        DeviceEntity deviceEntity = JSONObject.parseObject(deviceJson, DeviceEntity.class);
+        if (deviceEntity == null) {
+            throw new RRException("没有获取到设备信息,请联系管理员!");
+        }
+        //保存室内环境数据
+        IndoorEnvironmentEntity indoorEnvironmentEntity = new IndoorEnvironmentEntity();
+        Integer farmId = deviceEntity.getFarmId();
+        indoorEnvironmentEntity.setFarmId(farmId);
+        Integer pigstyId = deviceEntity.getPigstyId();
+        indoorEnvironmentEntity.setPigstyId(pigstyId);
+        indoorEnvironmentEntity.setValue(value);
+        indoorEnvironmentEntity.setCollectTime(new Date());
+
+        Map<String, Double> map = managementFeignService.selectByType((short) 1);
+        switch (deviceDataEntity.getCmdType()) {
+            case 7:
+                indoorEnvironmentEntity.setType(1);
+                handleDataPackageService.handleTemperature(indoorEnvironmentEntity, value, farmId, pigstyId, map);
+                break;
+            case 8:
+                indoorEnvironmentEntity.setType(2);
+                handleDataPackageService.handleHumidity(indoorEnvironmentEntity, value, farmId, pigstyId, map);
+                break;
+            case 9:
+                indoorEnvironmentEntity.setType(3);
+                handleDataPackageService.handleGas(indoorEnvironmentEntity, value, farmId, pigstyId, map);
+                break;
+            default:
+                break;
+        }
+//        int cmdNum = Integer.parseInt(cmd);
+//
+//
+//        StringBuilder echoResultSb = new StringBuilder();
+        // 校验后边再做;
+//        if (Integer.parseInt(cmd) == 1) {
+//            // 绑定序列号返回的设备id
+//            return sendPackageService.getDeviceId(clientMessageArray);
+//        } else if (Integer.parseInt(cmd) == 2) {
+//            // 处理获取服务器时间
+//            return sendPackageService.getServerDateTime(clientMessageArray);
+//        } else if (Integer.parseInt(cmd) == 3) {
+//            // 处理心跳包
+//            return sendPackageService.getHeartbeatBag(clientMessageArray);
+//        } else if (Integer.parseInt(cmd) == 4) {
+//            // 处理温度上传
+//            return receivePackageSerivce.handleEartagTemperature(clientMessageArray);
+//        } else if (Integer.parseInt(cmd) == 5) {
+//            // 处理湿度上传
+//            return receivePackageSerivce.handleEartagDampness(clientMessageArray);
+//        } else if (Integer.parseInt(cmd) == 6) {
+//            // 处理耳标数据
+//            System.out.println("处理耳标数据");
+//            System.out.println(clientMessageTxt);
+//            return receivePackageSerivce.handleEartagData(clientMessageArray).toString();
+//
+//        } else {
+//            log.error("出错:当前命令cmd>>[" + cmd + "]未做任何处理.");
+//            return null;
+//        }
+        return null;
+    }
+
+
+    @Override
+    public void interfaceTest(){
+        Map<String, Double> map = managementFeignService.selectByType((short) 1);
+        System.out.println(map);
+
+    }
+
+
+}

+ 22 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/IClientDataPacketService.java

@@ -0,0 +1,22 @@
+package com.huimv.datacollection.tcp;
+
+import java.text.ParseException;
+
+/**
+ * @author yinhao
+ * @version 1.0
+ * @date 2021/07/07 15:06:00
+ */
+public interface IClientDataPacketService {
+
+    /**
+     * 解析客户端数据包
+     * @param clientMessage
+     * @return
+     * @throws ParseException
+     */
+    String handleClientSendPacket(String clientMessage) throws ParseException;
+
+    void interfaceTest() throws ParseException;
+
+}

+ 44 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/Server.java

@@ -0,0 +1,44 @@
+package com.huimv.datacollection.tcp;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+@Component
+public class Server implements CommandLineRunner {
+
+    @Autowired
+    private IClientDataPacketService iClientDataPacketService;
+
+    @Override
+    public void run(String... args) throws Exception {
+        try {
+
+            // 初始化服务端socket连接, 并监听8888端口的socket请求
+            ServerSocket serverSocket = new ServerSocket(8888);
+
+            System.out.println("****** I am Server, now begin to wait the client ******");
+
+            int count = 0;
+
+            // 处理socket请求
+            Socket socket = null;
+            while (true) {
+                socket = serverSocket.accept();
+                ServerThread serverThread = new ServerThread(socket, iClientDataPacketService);
+                System.out.println("client host address is: " + socket.getInetAddress().getHostAddress());
+                serverThread.start();
+                count++;
+                System.out.println("now client count is: " + count);
+
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 80 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/ServerThread.java

@@ -0,0 +1,80 @@
+package com.huimv.datacollection.tcp;
+
+
+
+import java.io.*;
+import java.net.Socket;
+import java.text.ParseException;
+
+/**
+ * @author yinhao
+ * @version 1.0
+ * @date 2021/07/07 17:32
+ */
+public class ServerThread extends Thread {
+
+    private Socket socket;
+
+    private IClientDataPacketService iClientDataPacketService;
+
+    public ServerThread(Socket socket, IClientDataPacketService iClientDataPacketService) {
+        this.socket = socket;
+        this.iClientDataPacketService = iClientDataPacketService;
+    }
+
+    @Override
+    public void run() {
+        InputStream inputStream = null;
+        InputStreamReader inputStreamReader = null;
+        BufferedReader bufferedReader = null;
+        OutputStream outputStream = null;
+        PrintWriter printWriter = null;
+
+        try {
+
+            // server接收消息
+            inputStream = socket.getInputStream();
+            byte[] b = new byte[1024];
+            inputStream.read(b);
+            String packet = new String(b);
+            packet = packet.trim();
+
+            // 处理数据包
+//             String ss = iClientDataPacketService.handleClientSendPacket(packet);
+             iClientDataPacketService.interfaceTest();
+
+//            outputStream = socket.getOutputStream();
+//            outputStream.write(ss.getBytes());
+//            socket.shutdownInput();
+
+        } catch (IOException | ParseException e) {
+            e.printStackTrace();
+        } finally {
+            // 关闭资源
+            try {
+
+                if (printWriter != null) {
+                    printWriter.close();
+                }
+                if (outputStream != null) {
+                    outputStream.close();
+
+                }
+                if (bufferedReader != null) {
+                    bufferedReader.close();
+                }
+                if (inputStreamReader != null) {
+                    inputStreamReader.close();
+                }
+                if (inputStream != null) {
+                    inputStream.close();
+                }
+                if (socket != null) {
+                    socket.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 83 - 0
huimv-smart-datacollection/src/main/java/com/huimv/datacollection/tcp/TcpSendAndRecv.java

@@ -0,0 +1,83 @@
+package com.huimv.datacollection.tcp;
+
+import java.io.*;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author yinhao
+ * @date 2021/7/7 9:55
+ */
+public class TcpSendAndRecv {
+
+
+    public static void main(String[] args) {
+        //先开启接收端的线程
+        new Thread(new DD()).start();
+        //在开启发送端的线程
+        new Thread(new TT()).start();
+
+
+    }
+}
+
+class TT implements Runnable {
+
+    @Override
+    public void run() {
+        try {
+            //创建一个socket绑定的端口和地址为:9977,本机。
+            Socket s = new Socket("localhost", 9977);
+            //获取到输出流
+            OutputStream oos = s.getOutputStream();
+            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(oos));
+            System.out.print("发送端:");
+            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+            String line = null;
+            while ((line = br.readLine()) != null) {
+                bw.write(line);
+                bw.flush();
+                //将内容写到控制台
+            }
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+
+    }
+
+}
+
+class DD implements Runnable {
+
+    @Override
+    public void run() {
+        try {
+            //创建一个serversocket其端口与发送端的端口是一样的
+            ServerSocket ss = new ServerSocket(9977);
+            //侦听并接受到此套接字的连接,返回一个socket对象
+            Socket s = ss.accept();
+            //获取到输入流
+            InputStream is = s.getInputStream();
+            BufferedReader br = new BufferedReader(new InputStreamReader(is));
+            //接收收到的数据
+            byte[] buf = new byte[1024];
+            int line = 0;
+            while ((line = is.read(buf)) != -1) {
+                //将接收到的数据在控制台输出
+                System.out.println("接收端" + new String(buf, 0, line));
+            }
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+
+    }
+
+}

+ 6 - 0
huimv-smart-datacollection/src/main/resources/application-dev.yml

@@ -100,3 +100,9 @@ mybatis-plus:
     jdbc-type-for-null: 'null'
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
+feign:
+  client:
+    config:
+      default:
+        connectTimeout: 10000
+        readTimeout: 600000

+ 2 - 4
huimv-smart-management/src/main/java/com/huimv/management/entity/DrinkingWaterEntity.java

@@ -1,9 +1,6 @@
 package com.huimv.management.entity;
 
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
@@ -19,6 +16,7 @@ import java.util.Date;
  * @date 2021/6/11 10:34
  */
 @Data
+@TableName("mgt_drinking_water")
 public class DrinkingWaterEntity implements Serializable {
     private static final long serialVersionUID = 7480204097308252507L;
 

+ 4 - 14
huimv-smart-management/src/main/java/com/huimv/management/entity/IndoorEnvironmentEntity.java

@@ -18,7 +18,6 @@ import java.util.Date;
 @TableName("mgt_indoor_environment")
 public class IndoorEnvironmentEntity implements Serializable {
     private static final long serialVersionUID = 1L;
-
     /**
      * id
      */
@@ -34,22 +33,13 @@ public class IndoorEnvironmentEntity implements Serializable {
      */
     private Integer pigstyId;
     /**
-     * 日期
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
-    private Date date;
-    /**
-     * 温度
-     */
-    private Double temperature;
-    /**
-     * 湿度
+     * 类型
      */
-    private Double humidity;
+    private Integer type;
     /**
-     * 气体
+     * 数值
      */
-    private String airQuality;
+    private Double value;
     /**
      * 采集时间
      */

+ 8 - 36
huimv-smart-management/src/main/java/com/huimv/management/entity/vo/IndoorEnvironmentVo.java

@@ -29,12 +29,6 @@ public class IndoorEnvironmentVo implements Serializable {
     @TableId
     private Integer id;
     /**
-     * 日期
-     */
-    @Excel(name = "日期", width = 15, format = "yyyy-MM-dd")
-    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
-    private Date date;
-    /**
      * 牧场id
      */
     private Integer farmId;
@@ -53,43 +47,21 @@ public class IndoorEnvironmentVo implements Serializable {
     @Excel(name = "猪舍名称", width = 15)
     private String pigstyName;
     /**
-     * 温度
+     * 类型
+     * 1. 温度
+     * 2. 湿度
+     * 3. 氨气
      */
-    @Excel(name = "温度")
-    private Double temperature;
+    @Excel(name = "类型")
+    private Integer type;
     /**
      * 湿度
      */
-    @Excel(name = "湿度")
-    private Double humidity;
-    /**
-     * 气体
-     */
-    @Excel(name = "空气质量指数")
-    private String airQuality;
+    @Excel(name = "数值")
+    private Double value;
     /**
      * 采集时间
      */
     @Excel(name = "采集时间", width = 20, format = "HH:mm:ss")
     private Date collectTime;
-
-//    /**
-//     * 异常状态 0.正常 1.异常
-//     */
-//    private Boolean abnormalStatus;
-//    /**
-//     * 删除状态 0正常 其他:已删除
-//     */
-//    @TableLogic
-//    private Integer deleted;
-//    /**
-//     * 创建时间
-//     */
-//    @TableField(fill = FieldFill.INSERT)
-//    private Date gmtCreate;
-//    /**
-//     * 修改时间
-//     */
-//    @TableField(fill = FieldFill.INSERT_UPDATE)
-//    private Date gmtModified;
 }

+ 1 - 1
huimv-smart-management/src/main/java/com/huimv/management/entity/vo/WarningInfoVo.java

@@ -26,7 +26,7 @@ public class WarningInfoVo implements Serializable {
     /**
      * 当前日期
      */
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GTM+8")
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
     private Date nowDate;
     /**
      * 牧场id

+ 4 - 8
huimv-smart-management/src/main/resources/mapper/management/IndoorEnvironmentDao.xml

@@ -7,10 +7,8 @@
     <resultMap type="com.huimv.management.entity.IndoorEnvironmentEntity" id="indoorEnvironmentMap">
         <result property="id" column="id"/>
         <result property="pigstyId" column="pigsty_id"/>
-        <result property="temperature" column="temperature"/>
-        <result property="humidity" column="humidity"/>
-        <result property="airQuality" column="gas"/>
-        <result property="date" column="date"/>
+        <result property="type" column="type"/>
+        <result property="value" column="value"/>
         <result property="collectTime" column="collect_time"/>
         <result property="deleted" column="deleted"/>
         <result property="gmtCreate" column="gmt_create"/>
@@ -21,14 +19,12 @@
     <select id="page" resultType="com.huimv.management.entity.vo.IndoorEnvironmentVo">
         SELECT
           env.id,
-          env.date,
           env.farm_id,
           farm.name farmName,
           env.pigsty_id,
           pigsty.number pigstyName,
-          env.temperature,
-          env.humidity,
-          env.air_quality,
+          env.type,
+          env.value,
           env.collect_time
         FROM mgt_indoor_environment env
           JOIN mgt_farm farm ON env.farm_id = farm.id

+ 4 - 0
renren-fast/pom.xml

@@ -60,6 +60,10 @@
                     <groupId>com.baomidou</groupId>
                     <artifactId>mybatis-plus-boot-starter</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>org.springframework.cloud</groupId>
+                    <artifactId>spring-cloud-loadbalancer</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
         <dependency>