dao/src/main/java/com/sandu/ximon/dao/domain/AirEquipment.java
@@ -4,43 +4,147 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import java.time.LocalDateTime; import lombok.Data; /** * 大气设备 * * @TableName air_equipment */ @TableName(value = "air_equipment") @TableName(value ="air_equipment") @Data public class AirEquipment implements Serializable { /** * * */ @TableId(type = IdType.AUTO) private Long id; /** * 接入时间 */ private LocalDateTime createTime; /** * MAC地址 * MAC地址灯杆 */ private String mac; /** * 大气mac * MAC地址大气 */ private String airMac; @TableField(exist = false) private Integer state; /** * 设备型号 */ private String deviceType; /** * 模块预热状态标志 */ private String moduleWarmUpStatusFlag; /** * 温度值 */ private Integer temperature; /** * 湿度值 */ private Integer humidity; /** * 风速 */ private Integer windSpeed; /** * 风向 */ private Integer windDirection; /** * 风力 */ private Integer windPower; /** * 大气压 */ private Integer pressure; /** * 光强 */ private Integer lightIntensity; /** * 噪音 */ private Integer noise; /** * pm25 */ private Integer pm25; /** * PM10 */ private Integer pm10; /** * 总悬浮颗粒物TSP */ private Integer tsp; /** * 雨量 */ private Integer rain; /** * SO2二氧化硫相对值 */ private Integer so2; /** * 甲醛相对值 */ private Integer ech2o; /** * NO2二氧化氮 */ private Integer no2; /** * TVOC */ private Integer tvoc; /** * CO一氧化碳 */ private Integer co; /** * 二氧化碳 */ private Integer co2; /** * O3臭氧 */ private Integer o3; /** * F氟化物 */ private Integer fluoride; /** * 接入时间 */ private LocalDateTime createTime; @TableField(exist = false) private static final long serialVersionUID = 1L; dao/src/main/resources/mapper/AirEquipmentMapper.xml
@@ -5,17 +5,33 @@ <mapper namespace="com.sandu.ximon.dao.mapper.AirEquipmentMapper"> <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.AirEquipment"> <id property="id" column="id" jdbcType="BIGINT"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="mac" column="mac" jdbcType="VARCHAR"/> <result property="airMac" column="air_mac" jdbcType="VARCHAR"/> <id property="id" column="id" jdbcType="BIGINT"/> <result property="mac" column="mac" jdbcType="VARCHAR"/> <result property="airMac" column="air_mac" jdbcType="VARCHAR"/> <result property="deviceType" column="device_type" jdbcType="VARCHAR"/> <result property="moduleWarmUpStatusFlag" column="module_warm_up_status_flag" jdbcType="VARCHAR"/> <result property="temperature" column="temperature" jdbcType="INTEGER"/> <result property="humidity" column="humidity" jdbcType="INTEGER"/> <result property="windSpeed" column="wind_speed" jdbcType="INTEGER"/> <result property="windDirection" column="wind_direction" jdbcType="INTEGER"/> <result property="windPower" column="wind_power" jdbcType="INTEGER"/> <result property="pressure" column="pressure" jdbcType="INTEGER"/> <result property="lightIntensity" column="light_intensity" jdbcType="INTEGER"/> <result property="noise" column="noise" jdbcType="INTEGER"/> <result property="pm25" column="pm25" jdbcType="INTEGER"/> <result property="pm10" column="PM10" jdbcType="INTEGER"/> <result property="tsp" column="tsp" jdbcType="INTEGER"/> <result property="rain" column="rain" jdbcType="INTEGER"/> <result property="so2" column="so2" jdbcType="INTEGER"/> <result property="ech2o" column="ech2o" jdbcType="INTEGER"/> <result property="no2" column="no2" jdbcType="INTEGER"/> <result property="tvoc" column="tvoc" jdbcType="INTEGER"/> <result property="co" column="co" jdbcType="INTEGER"/> <result property="co2" column="co2" jdbcType="INTEGER"/> <result property="o3" column="o3" jdbcType="INTEGER"/> <result property="fluoride" column="fluoride" jdbcType="INTEGER"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> </resultMap> <sql id="Base_Column_List"> id,belong_to,equipment_state, create_time,user_id,light_pole_id, mac </sql> <select id="listAirEquipmentByIds" resultType="com.sandu.ximon.dao.bo.AirEquipmentBo"> SELECT ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/amqp/processor/AirDataProcessor.java
@@ -35,12 +35,10 @@ if (A5AtmosphereReportEnum.HeartBeat_Data.getCode().equals(functionCode)) { log.info("心跳相应——大气数据"); A5AtmosphereHeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5AtmosphereHeartbeatReportInnerFrame().transformFrame(frame.getPayload()); log.info(heartbeatReportInnerFrame.toString()); SpringContextHolder.getBean(AirDataService.class).saveReportData(deviceName, heartbeatReportInnerFrame.getHeartBeatDataPackage()); // SpringContextHolder.getBean(LightService.class).saveLight(deviceName,heartbeatReportInnerFrame.getHeartBeatDataPackage()); if(heartbeatReportInnerFrame != null){ log.info(heartbeatReportInnerFrame.toString()); SpringContextHolder.getBean(AirDataService.class).saveReportData(deviceName, heartbeatReportInnerFrame.getHeartBeatDataPackage()); } } else if (A5AtmosphereReportEnum.HeartBeat_Data_Nong_Geng.getCode().equals(functionCode)) { log.info("心跳相应——大气数据(农耕)"); A5AtmosphereNewHeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5AtmosphereNewHeartbeatReportInnerFrame().transformFrame(frame.getPayload()); ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5AtmosphereHeartbeatReportInnerFrame.java
@@ -27,10 +27,11 @@ @Override public A5AtmosphereHeartbeatReportInnerFrame transformFrame(String hex) { // 长度不一致时,返回null //TODO if (StrUtil.isBlank(hex)) { if (StrUtil.isBlank(hex) || hex.length() < 26 || hex.substring(18).length() % 8 != 0) { System.out.println("数据校验异常!"); return null; } // MQTT通信方式(1) setConnectType(hex.substring(0, 2)); // 功能码(1) @@ -132,11 +133,8 @@ } //设备型号 Integer type = 0; this.deviceType = hex.substring(0, 4); if (this.deviceType.equals(DeviceType.SENSOR_V1.getType())) { type = 1; } //模块预热状态标志 this.moduleWarmUpStatusFlag = hex.substring(4, 6); @@ -206,7 +204,7 @@ } } else if ("00".equals(sub.substring(4, 6))) { //360度款风向仪 this.windDirection = parseVal(sub, 4, 8) * .1 + "℃"; this.windDirection = parseVal(sub, 4, 8) * .1 + "度"; } break; //风力 @@ -287,18 +285,4 @@ } } public enum DeviceType { SENSOR_V1("0101"); private String type; DeviceType(String type) { this.type = type; } public String getType() { return type; } } } ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/request/AtmosphereModifiedDataReqInnerFrame.java
@@ -1,5 +1,6 @@ package com.sandu.ximon.admin.manager.iot.frame.inner.request; import com.sandu.common.execption.BusinessException; import com.sandu.ximon.admin.manager.iot.frame.inner.IRequestInnerFrame; import com.sandu.ximon.admin.manager.iot.rrpc.enums.AtmoFunctionCode; import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; @@ -84,11 +85,10 @@ functionCode = AtmoFunctionCode.Setting_Data_Correction_windDirection.getCode(); //TODO break; //设置数据修正值-风力 case "风力": functionCode = AtmoFunctionCode.Setting_Data_Correction_windPower.getCode(); //TODO break; // //设置数据修正值-风力 // case "风力": // functionCode = AtmoFunctionCode.Setting_Data_Correction_windPower.getCode(); // throw new BusinessException("风力不需要设置数据修正值!"); //设置数据修正值-气压 case "气压": functionCode = AtmoFunctionCode.Setting_Data_Correction_airPressure.getCode(); ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/enums/AtmoFunctionCode.java
@@ -19,8 +19,8 @@ Reboot("10"), // 设置心跳包间隔 SettingHeartBeatTime("11"), //设置地址 SettingAddress("12"), // //设置地址 // SettingAddress("12"), //传感器功能开关 SensorSwitch("13"), //设置数据修正值-温度 ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirDataService.java
@@ -52,7 +52,57 @@ AirEquipment airEquipment = new AirEquipment(); airEquipment.setId(airData.getId()); airEquipment.setMac(airData.getDeviceMac()); // airEquipment.setCreateTime(airData.getCreateTime()); airEquipment.setDeviceType(heartBeatDataPackage.getDeviceType()); airEquipment.setModuleWarmUpStatusFlag(heartBeatDataPackage.getModuleWarmUpStatusFlag()); //温度传感器 airEquipment.setTemperature(heartBeatDataPackage.getTemperature() != null ? 1 : 0); //湿度传感器 airEquipment.setHumidity(heartBeatDataPackage.getHumidity() != null ? 1 : 0); //风速传感器 airEquipment.setWindSpeed(heartBeatDataPackage.getWindSpeed() != null ? 1 : 0); //风向传感器 if (heartBeatDataPackage.getWindDirection() == null) { airEquipment.setWindDirection(0); } else if (heartBeatDataPackage.getWindDirection().contains("度")) { //360度传感器 airEquipment.setWindDirection(2); } else { //八向仪传感器 airEquipment.setWindDirection(1); } //风力传感器 airEquipment.setWindPower(heartBeatDataPackage.getWindPower() != null ? 1 : 0); //气压传感器 airEquipment.setPressure(heartBeatDataPackage.getPressure() != null ? 1 : 0); //光强传感器 airEquipment.setLightIntensity(heartBeatDataPackage.getLightIntensity() != null ? 1 : 0); //噪音传感器 airEquipment.setNoise(heartBeatDataPackage.getNoise() != null ? 1 : 0); //PM25传感器 airEquipment.setPm25(heartBeatDataPackage.getPm25() != null ? 1 : 0); //PM10传感器 airEquipment.setPm10(heartBeatDataPackage.getPm10() != null ? 1 : 0); //TSP传感器 airEquipment.setTsp(heartBeatDataPackage.getTsp() != null ? 1 : 0); //雨量传感器 airEquipment.setRain(heartBeatDataPackage.getRain() != null ? 1 : 0); //SO2传感器 airEquipment.setSo2(heartBeatDataPackage.getSo2() != null ? 1 : 0); //甲醛传感器 airEquipment.setEch2o(heartBeatDataPackage.getEch2o() != null ? 1 : 0); //NO2传感器 airEquipment.setNo2(heartBeatDataPackage.getNo2() != null ? 1 : 0); //TVOC传感器 airEquipment.setTvoc(heartBeatDataPackage.getTvoc() != null ? 1 : 0); //CO传感器 airEquipment.setCo(heartBeatDataPackage.getCo() != null ? 1 : 0); //CO2传感器 airEquipment.setCo2(heartBeatDataPackage.getCo2() != null ? 1 : 0); //03传感器 airEquipment.setO3(heartBeatDataPackage.getO3() != null ? 1 : 0); //氟化物传感器 airEquipment.setFluoride(heartBeatDataPackage.getFluoride() != null ? 1 : 0); airEquipmentService.addAirEquipment(airEquipment); //存缓存心跳包 ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentService.java
@@ -75,9 +75,7 @@ */ public void addAirEquipment(AirEquipment airEquipment) { AirEquipment one = getOne(Wrappers.lambdaQuery(AirEquipment.class).eq(AirEquipment::getMac, airEquipment.getMac())); // //存储设备状态到缓存 // RedisUtils.getBean().set(AtmoFunctionCode.AIR_EQUIPMENT_STATE.getCode() + airEquipment.getMac() // , 1, 300L); if (one == null) { save(airEquipment); /** ximon-admin/src/main/resources/application-local.yml
@@ -39,7 +39,7 @@ enable: true listenter: isOpen: false isOpen: true minio: endpoint: 47.106.172.9 ximon-admin/src/test/java/com/sandu/ximon/admin/AdminApplicationTests.java
@@ -36,7 +36,8 @@ System.out.println(strings); } public static void main(String[] args) { @Test void jisuan() { BigDecimal value1 = new BigDecimal("1"); BigDecimal value2 = new BigDecimal("10"); String value; @@ -95,7 +96,7 @@ } System.out.println("...................................."); int a = Integer.valueOf((int) (subtract * 100)/100); int a = Integer.valueOf((int) (subtract * 100) / 100); System.out.println(z); if (subtract > 0) { @@ -105,7 +106,12 @@ value = hex10To16(-a + 32768); System.out.println(value); } } public static void main(String[] args) { String hex = "sssssssss"; System.out.println(hex.substring(6)); System.out.println(hex.substring(6).length() % 8); }