| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * åè大æ°çæµæ°æ® |
| | | * @TableName air_data_nong_geng |
| | | */ |
| | | @TableName(value ="air_data_nong_geng") |
| | | @Data |
| | | public class AirDataNongGeng implements Serializable { |
| | | /** |
| | | * 主é®ID |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 设å¤macå°å |
| | | */ |
| | | private String mac; |
| | | |
| | | /** |
| | | * åªå£° |
| | | */ |
| | | private BigDecimal noise; |
| | | |
| | | /** |
| | | * ç¡«åæ°¢ |
| | | */ |
| | | private BigDecimal hydrogenSulfide; |
| | | |
| | | /** |
| | | * SO2 æµåº¦ |
| | | */ |
| | | private BigDecimal so2; |
| | | |
| | | /** |
| | | * NO2 æµåº¦ |
| | | */ |
| | | private BigDecimal no2; |
| | | |
| | | /** |
| | | * CO æµåº¦ |
| | | */ |
| | | private BigDecimal co; |
| | | |
| | | /** |
| | | * o3 æµåº¦ |
| | | */ |
| | | private BigDecimal o3; |
| | | |
| | | /** |
| | | * pm2.5 æµåº¦ |
| | | */ |
| | | private BigDecimal pm2point5; |
| | | |
| | | /** |
| | | * pm10 |
| | | */ |
| | | private BigDecimal pm10; |
| | | |
| | | /** |
| | | * ç©ºæ°æ¸©åº¦ |
| | | */ |
| | | private BigDecimal airTemperature; |
| | | |
| | | /** |
| | | * ç©ºæ°æ¹¿åº¦ |
| | | */ |
| | | private BigDecimal airHumidity; |
| | | |
| | | /** |
| | | * 大æ°å强 |
| | | */ |
| | | private BigDecimal airPressure; |
| | | |
| | | /** |
| | | * é£å |
| | | */ |
| | | private BigDecimal windDirection; |
| | | |
| | | /** |
| | | * é£é |
| | | */ |
| | | private BigDecimal windSpeed; |
| | | |
| | | /** |
| | | * ååéé¨é |
| | | */ |
| | | private BigDecimal tenRainfallMin; |
| | | |
| | | /** |
| | | * è¾å° |
| | | */ |
| | | private BigDecimal radiation; |
| | | |
| | | /** |
| | | * å
ç
§ |
| | | */ |
| | | private BigDecimal illumination; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | 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_nong_geng |
| | | */ |
| | | @TableName(value ="air_equipment_nong_geng") |
| | | @Data |
| | | public class AirEquipmentNongGeng implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | |
| | | /** |
| | | * MACå°å |
| | | */ |
| | | private String mac; |
| | | |
| | | /** |
| | | * æ¥å
¥æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.AirDataNongGeng; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.AirDataNongGeng |
| | | */ |
| | | @Mapper |
| | | public interface AirDataNongGengMapper extends BaseMapper<AirDataNongGeng> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.AirEquipmentNongGeng; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.AirEquipmentNongGeng |
| | | */ |
| | | @Mapper |
| | | public interface AirEquipmentNongGengMapper extends BaseMapper<AirEquipmentNongGeng> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.sandu.ximon.dao.mapper.AirDataNongGengMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.AirDataNongGeng"> |
| | | <id property="id" column="id" jdbcType="BIGINT"/> |
| | | <result property="mac" column="mac" jdbcType="VARCHAR"/> |
| | | <result property="noise" column="noise" jdbcType="DECIMAL"/> |
| | | <result property="hydrogenSulfide" column="hydrogen_sulfide" jdbcType="DECIMAL"/> |
| | | <result property="so2" column="so2" jdbcType="DECIMAL"/> |
| | | <result property="no2" column="no2" jdbcType="DECIMAL"/> |
| | | <result property="co" column="co" jdbcType="DECIMAL"/> |
| | | <result property="o3" column="o3" jdbcType="DECIMAL"/> |
| | | <result property="pm2point5" column="pm2point5" jdbcType="DECIMAL"/> |
| | | <result property="pm10" column="pm10" jdbcType="DECIMAL"/> |
| | | <result property="airTemperature" column="air_temperature" jdbcType="DECIMAL"/> |
| | | <result property="airHumidity" column="air_humidity" jdbcType="DECIMAL"/> |
| | | <result property="airPressure" column="air_pressure" jdbcType="DECIMAL"/> |
| | | <result property="windDirection" column="wind_direction" jdbcType="DECIMAL"/> |
| | | <result property="windSpeed" column="wind_speed" jdbcType="DECIMAL"/> |
| | | <result property="tenRainfallMin" column="ten_rainfall_min" jdbcType="DECIMAL"/> |
| | | <result property="radiation" column="radiation" jdbcType="DECIMAL"/> |
| | | <result property="illumination" column="illumination" jdbcType="DECIMAL"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,mac,noise, |
| | | hydrogen_sulfide,so2,no2, |
| | | co,o3,pm2point5, |
| | | pm10,air_temperature,air_humidity, |
| | | air_pressure,wind_direction,wind_speed, |
| | | ten_rainfall_min,radiation,illumination, |
| | | create_time |
| | | </sql> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.sandu.ximon.dao.mapper.AirEquipmentNongGengMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.AirEquipmentNongGeng"> |
| | | <id property="id" column="id" jdbcType="BIGINT"/> |
| | | <result property="mac" column="mac" jdbcType="VARCHAR"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,mac,create_time |
| | | </sql> |
| | | </mapper> |
| | |
| | | public ResponseVO<Object> updataAirEquipmentInfo(@RequestBody List<String> listMac) { |
| | | AirDataReqInnerFrame airDataReqInnerFrame = new AirDataReqInnerFrame(); |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(), airDataReqInnerFrame); |
| | | // WrapResponseCommonFrame<A5AtmosphereHeartbeatReportInnerFrame> wrapResponseCommonFrame = |
| | | // MainBoardInvokeSyncService.getInstance().sendRRPC(listMac.get(0), a5Frame, A5AtmosphereHeartbeatReportInnerFrame.class); |
| | | System.out.println(a5Frame + " --------a5Frame"); |
| | | |
| | | List<String> success = new ArrayList<>(); |
| | | List<String> failed = new ArrayList<>(); |
| | |
| | | listMac.parallelStream().forEach(macStr -> { |
| | | try { |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(macStr, a5Frame); |
| | | // //æµè¯ç¨ç |
| | | // String s = "{\"connectType\":\"FE\",\"crc32\":\"8685DF1B\",\"functionCode\":\"A5\",\"orderType\":\"84\",\"payload\":\"F0010022FFFF0101016666640000000000000000419D000000360089000000000002019300008CA14C69\",\"payloadLength\":\"002A\",\"validate\":true}"; |
| | | // CommonFrame commonFrame1 = JSON.parseObject(s, CommonFrame.class); |
| | | // AirDataProcessor.getInstance().process("a1JsfPG4iKW",macStr,commonFrame1); |
| | | AirDataProcessor.getInstance().process("a1JsfPG4iKW",macStr,commonFrame); |
| | | System.out.println(commonFrame + " -----------commonFrame"); |
| | | AirDataProcessor.getInstance().process("a1JsfPG4iKW", macStr, commonFrame); |
| | | if (commonFrame != null) { |
| | | success.add(macStr); |
| | | } else { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | /** |
| | | * @author ZZQ |
| | | * @date 2022/4/24 17:36 |
| | | */ |
| | | |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.manager.iot.amqp.processor.AirDataProcessor; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A5Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.AirDataNewReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.AirDataReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * å¤§æ°æ°æ® |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/v1/admin/airdata_nonggeng") |
| | | public class AirDataNongGengController { |
| | | |
| | | @PostMapping("/updateAirEquipmentInfo") |
| | | public ResponseVO<Object> updataAirEquipmentInfo(@RequestBody List<String> listMac) { |
| | | AirDataNewReqInnerFrame airDataNewReqInnerFrame = new AirDataNewReqInnerFrame(); |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(), airDataNewReqInnerFrame); |
| | | System.out.println(a5Frame + " --------a5Frame"); |
| | | |
| | | List<String> success = new ArrayList<>(); |
| | | List<String> failed = new ArrayList<>(); |
| | | listMac.parallelStream().forEach(macStr -> { |
| | | try { |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(macStr, a5Frame); |
| | | System.out.println(commonFrame + " -----------commonFrame"); |
| | | AirDataProcessor.getInstance().process("a1JsfPG4iKW", macStr, commonFrame); |
| | | if (commonFrame != null) { |
| | | success.add(macStr); |
| | | } else { |
| | | failed.add(macStr); |
| | | } |
| | | } catch (Exception e) { |
| | | failed.add(macStr); |
| | | } |
| | | }); |
| | | |
| | | Map<String, List> resultMap = new HashMap<>(); |
| | | resultMap.put("success", success); |
| | | resultMap.put("failed", failed); |
| | | return ResponseUtil.success(resultMap); |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereNewHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5AtmosphereReportEnum; |
| | | import com.sandu.ximon.admin.service.AirDataNongGengService; |
| | | import com.sandu.ximon.admin.service.AirDataService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | |
| | | |
| | | // SpringContextHolder.getBean(LightService.class).saveLight(deviceName,heartbeatReportInnerFrame.getHeartBeatDataPackage()); |
| | | |
| | | } else if (A5AtmosphereReportEnum.HeartBeat_Data_Nong_Geng.getCode().equals(functionCode)) { |
| | | log.info("å¿è·³ç¸åºââå¤§æ°æ°æ®(åè)"); |
| | | A5AtmosphereNewHeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5AtmosphereNewHeartbeatReportInnerFrame().transformFrame(frame.getPayload()); |
| | | log.info(heartbeatReportInnerFrame.toString()); |
| | | |
| | | SpringContextHolder.getBean(AirDataNongGengService.class).saveReportData(deviceName, heartbeatReportInnerFrame.getHeartBeatDataPackage()); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | private String crc32; |
| | | /** |
| | | * CRCæ ¡éª 4 |
| | | */ |
| | | private String crc16; |
| | | /** |
| | | * æ¯å¦éè¿CRCæ ¡éª |
| | | */ |
| | | private boolean isValidate; |
| | |
| | | } |
| | | Integer type = 0; |
| | | this.deviceType = hex.substring(0, 4); |
| | | if(this.deviceType.equals(DeviceType.SENSOR_V1.getType())) { |
| | | if (this.deviceType.equals(DeviceType.SENSOR_V1.getType())) { |
| | | type = 1; |
| | | } |
| | | this.moduleWarmUpStatusFlag = hex.substring(4, 6); |
| | | this.temperature = Double.parseDouble( |
| | | parseVal(hex,6,8) |
| | | parseVal(hex, 6, 8) |
| | | + "." |
| | | + parseVal(hex,8,10) |
| | | + parseVal(hex, 8, 10) |
| | | ); |
| | | this.humidity = Double.parseDouble( |
| | | parseVal(hex,10,12) |
| | | parseVal(hex, 10, 12) |
| | | + "." |
| | | + parseVal(hex,12,14) |
| | | + parseVal(hex, 12, 14) |
| | | ); |
| | | this.windSpeed = parseVal(hex,14,18) * .1; |
| | | this.windDirection = parseVal(hex,18,22) * .1; |
| | | this.pressure = parseVal(hex,22,26); |
| | | this.lightIntensity = parseVal(hex,26,32); |
| | | this.noise = parseVal(hex,32, 36); |
| | | this.pm25 = parseVal(hex,36, 40); |
| | | this.pm10 = parseVal(hex,40,44); |
| | | this.tsp = parseVal(hex,44,48); |
| | | this.windSpeed = parseVal(hex, 14, 18) * .1; |
| | | this.windDirection = parseVal(hex, 18, 22) * .1; |
| | | this.pressure = parseVal(hex, 22, 26); |
| | | this.lightIntensity = parseVal(hex, 26, 32); |
| | | this.noise = parseVal(hex, 32, 36); |
| | | this.pm25 = parseVal(hex, 36, 40); |
| | | this.pm10 = parseVal(hex, 40, 44); |
| | | this.tsp = parseVal(hex, 44, 48); |
| | | |
| | | /** |
| | | * 以ä¸åºåçæ¬ |
| | | */ |
| | | if(type.equals(1)) { |
| | | this.ech2o = parseVal(hex,48, 52); |
| | | this.tvoc = parseVal(hex,52, 56); |
| | | this.co2 = parseVal(hex,56, 60); |
| | | if (type.equals(1)) { |
| | | this.ech2o = parseVal(hex, 48, 52); |
| | | this.tvoc = parseVal(hex, 52, 56); |
| | | this.co2 = parseVal(hex, 56, 60); |
| | | } else { |
| | | this.so2 = parseVal(hex,48, 52); |
| | | this.ech2o = parseVal(hex,48, 52); |
| | | this.tvoc = parseVal(hex,52, 56); |
| | | this.no2 = parseVal(hex,52, 56); |
| | | this.co = parseVal(hex,56, 60); |
| | | this.co2 = parseVal(hex,56, 60); |
| | | this.so2 = parseVal(hex, 48, 52); |
| | | this.ech2o = parseVal(hex, 48, 52); |
| | | this.tvoc = parseVal(hex, 52, 56); |
| | | this.no2 = parseVal(hex, 52, 56); |
| | | this.co = parseVal(hex, 56, 60); |
| | | this.co2 = parseVal(hex, 56, 60); |
| | | } |
| | | |
| | | this.o3 = parseVal(hex,60, 62); |
| | | this.fluoride = parseVal(hex,62, 64); |
| | | this.o3 = parseVal(hex, 60, 62); |
| | | this.fluoride = parseVal(hex, 62, 64); |
| | | |
| | | return this; |
| | | } |
| | | |
| | | private Integer parseVal (String frame, int start, int end) { |
| | | return Integer.parseInt(frame.substring(start,end),16); |
| | | private Integer parseVal(String frame, int start, int end) { |
| | | return Integer.parseInt(frame.substring(start, end), 16); |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.report; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.IResponseInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC16Utils; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author ZZQ |
| | | * @date 2022/4/25 10:55 |
| | | */ |
| | | @Data |
| | | public class A5AtmosphereNewHeartbeatReportInnerFrame extends BaseResponseInnerFrame<A5AtmosphereNewHeartbeatReportInnerFrame> { |
| | | //ff03200241000000000000000000000009000a198a186327b8000c000000000000000b8c35c1cad6bf |
| | | private HeartBeatDataPackage heartBeatDataPackage; |
| | | |
| | | @Override |
| | | public A5AtmosphereNewHeartbeatReportInnerFrame transformFrame(String hex) { |
| | | // é¿åº¦ä¸ä¸è´æ¶ï¼è¿ånull |
| | | if (StrUtil.isBlank(hex)) { |
| | | return null; |
| | | } |
| | | //æ ¡éª |
| | | hex = hex.replaceAll(" ", ""); |
| | | if (hex.length() < 74) { |
| | | return null; |
| | | } |
| | | |
| | | // MQTTéä¿¡æ¹å¼(1) |
| | | setConnectType(hex.substring(0, 2)); |
| | | // åè½ç (1) |
| | | setFunctionCode(hex.substring(2, 4)); |
| | | // è´è·é¿åº¦(2) |
| | | setPayloadLength(hex.substring(4, 6)); |
| | | |
| | | |
| | | String heartBeatData = hex.substring(0, hex.length() - 4); |
| | | HeartBeatDataPackage heartBeatDataPackage = new HeartBeatDataPackage(); |
| | | heartBeatDataPackage.transformFrame(heartBeatData); |
| | | setHeartBeatDataPackage(heartBeatDataPackage); |
| | | |
| | | setCrc16(hex.substring(hex.length() - 4)); |
| | | // æ ¡éªCRC32 |
| | | String frame = hex.substring(0, hex.length() - 4); |
| | | this.setValidate(getCrc16().equals(CRC16Utils.getCRC16(frame))); |
| | | return this; |
| | | } |
| | | |
| | | @Data |
| | | public static class HeartBeatDataPackage implements IResponseInnerFrame<HeartBeatDataPackage> { |
| | | //("åªå£°") |
| | | private BigDecimal noise; |
| | | //("ç¡«åæ°¢") |
| | | private BigDecimal hydrogenSulfide; |
| | | //("SO2 æµåº¦") |
| | | private BigDecimal so2; |
| | | //("NO2 æµåº¦") |
| | | private BigDecimal no2; |
| | | //("CO æµåº¦") |
| | | private BigDecimal co; |
| | | //("O3 æµåº¦") |
| | | private BigDecimal o3; |
| | | //("PM2.5 æµåº¦") |
| | | private BigDecimal pm2point5; |
| | | //("PM10") |
| | | private BigDecimal pm10; |
| | | //("ç©ºæ°æ¸©åº¦") |
| | | private BigDecimal airTemperature; |
| | | //("ç©ºæ°æ¹¿åº¦") |
| | | private BigDecimal airHumidity; |
| | | //("大æ°å强") |
| | | private BigDecimal airPressure; |
| | | //("é£é") |
| | | private BigDecimal windSpeed; |
| | | //("é£å") |
| | | private BigDecimal windDirection; |
| | | //("10 åéé¨é") |
| | | private BigDecimal tenRainfallMin; |
| | | //("è¾å°") |
| | | private BigDecimal radiation; |
| | | //("å
ç
§") |
| | | private BigDecimal illumination; |
| | | |
| | | @Override |
| | | public HeartBeatDataPackage transformFrame(String hex) { |
| | | //ff 03 20 0241000000000000000000000009000a198a186327b8000c000000000000000b8c35c1ca(åèå¼) |
| | | // 0241 0000 0000 0000 0000 0000 0009 000a 198a 1863 27b8 000c 0000 0000 0000 000b 8c35 c1ca |
| | | |
| | | //åªå£° |
| | | this.noise = BigDecimal.valueOf(parseVal(hex, 6, 10) / 10.0); |
| | | //ç¡«åæ°¢ |
| | | this.hydrogenSulfide = BigDecimal.valueOf(parseVal(hex, 10, 14) / 1.0); |
| | | //SO2 æµåº¦ |
| | | this.so2 = BigDecimal.valueOf(parseVal(hex, 14, 18) / 1.0); |
| | | //NO2 æµåº¦ |
| | | this.no2 = BigDecimal.valueOf(parseVal(hex, 18, 22) / 1.0); |
| | | //CO æµåº¦ |
| | | this.co = BigDecimal.valueOf(parseVal(hex, 22, 26) / 1.0); |
| | | //O3 æµåº¦ |
| | | this.o3 = BigDecimal.valueOf(parseVal(hex, 26, 30) / 1.0); |
| | | //PM2.5 æµåº¦ |
| | | this.pm2point5 = BigDecimal.valueOf(parseVal(hex, 30, 34) / 1.0); |
| | | //PM10 æµåº¦ |
| | | this.pm10 = BigDecimal.valueOf(parseVal(hex, 34, 38) / 1.0); |
| | | //ç©ºæ°æ¸©åº¦ |
| | | this.airTemperature = BigDecimal.valueOf(parseVal(hex, 38, 42) / 100.0 - 40); |
| | | //ç©ºæ°æ¹¿åº¦ |
| | | this.airHumidity = BigDecimal.valueOf(parseVal(hex, 42, 46) / 100.0); |
| | | //大æ°å强 |
| | | this.airPressure = BigDecimal.valueOf(parseVal(hex, 46, 50) / 10.0); |
| | | //é£é |
| | | this.windSpeed = BigDecimal.valueOf(parseVal(hex, 50, 54) / 100.0); |
| | | //é£å |
| | | this.windDirection = BigDecimal.valueOf(parseVal(hex, 54, 58) / 10.0); |
| | | //10 åéé¨é |
| | | this.tenRainfallMin = BigDecimal.valueOf(parseVal(hex, 58, 62) / 10.0); |
| | | //è¾å° |
| | | this.radiation = BigDecimal.valueOf(parseVal(hex, 62, 66) / 1.0); |
| | | //å
ç
§ |
| | | this.illumination = BigDecimal.valueOf(parseVal(hex, 66, 70) / 100.0); |
| | | return this; |
| | | } |
| | | |
| | | private Integer parseVal(String frame, int start, int end) { |
| | | return Integer.parseInt(frame.substring(start, end), 16); |
| | | } |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.request; |
| | | |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.IRequestInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.NewAtmoFunctionCode; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC16Utils; |
| | | |
| | | /** |
| | | * @Author ZZQ |
| | | * @Date 2022/4/24 |
| | | */ |
| | | |
| | | public class AirDataNewReqInnerFrame implements IRequestInnerFrame { |
| | | |
| | | // private final String payload; |
| | | // private final String functionCode = DataTransportOrderType.LightTimer.getCode(); |
| | | // private final String payloadLength; |
| | | |
| | | |
| | | public AirDataNewReqInnerFrame() { |
| | | } |
| | | |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = NewAtmoFunctionCode.NewQueryHeartBeat.getCode(); |
| | | String payloadLength = "0000"; |
| | | String payload = "0010"; |
| | | |
| | | String frame = MQTTConnectTypeEnum.NONG_GENG_SYSTEM_ADDRESS.getCode() + functionCode + payloadLength + payload; |
| | | return frame.toUpperCase() + CRC16Utils.getCRC16(frame.toUpperCase()); |
| | | } |
| | | |
| | | } |
| | |
| | | public enum A5AtmosphereReportEnum { |
| | | // 䏿¥å¿è·³å
|
| | | HeartBeat_Data("01"), |
| | | HeartBeat_Data_Nong_Geng("03") |
| | | ; |
| | | |
| | | |
| | |
| | | package com.sandu.ximon.admin.manager.iot.rrpc.enums; |
| | | |
| | | /** |
| | | * 大æ°åè½ç |
| | | * 大æ°åè½ç ï¼å¸æ¢¦èªç ï¼ |
| | | */ |
| | | public enum AtmoFunctionCode { |
| | | /** |
| | | * 大æ°å¼å§ |
| | | */ |
| | | // æ¥è¯¢å¿è·³å
|
| | | QueryHeartBeat("01"), |
| | | // æ¥è¯¢å¿è·³å
æ¶é´ |
| | |
| | | SettingHeartBeatTime("11"), |
| | | // 大æ°è®¾å¤å¿è·³å
åå¨(设å¤ç¶æ)) |
| | | AIR_HEARTBEAT("air_heartbeat"); |
| | | /** |
| | | * 大æ°ç»æï¼å¸æ¢¦èªç ï¼ |
| | | */ |
| | | |
| | | private String code; |
| | | |
| | |
| | | return code; |
| | | } |
| | | |
| | | AtmoFunctionCode(String code){ |
| | | AtmoFunctionCode(String code) { |
| | | this.code = code; |
| | | } |
| | | } |
| | |
| | | package com.sandu.ximon.admin.manager.iot.rrpc.enums; |
| | | |
| | | /** |
| | | * MQTTéä¿¡æ¹å¼ |
| | | * (å导ç ) |
| | | * |
| | | * @author chenjiantian |
| | | */ |
| | | public enum MQTTConnectTypeEnum { |
| | |
| | | */ |
| | | ASYNCHRONOUS("F0"), |
| | | /** |
| | | * åè大æ°è¯·æ±ç³»ç»å°å |
| | | */ |
| | | NONG_GENG_SYSTEM_ADDRESS("FF"), |
| | | /** |
| | | * 广æ |
| | | */ |
| | | BROADCAST("FA"); |
| | | |
| | | MQTTConnectTypeEnum(String code){ |
| | | MQTTConnectTypeEnum(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.rrpc.enums; |
| | | |
| | | /** |
| | | * 大æ°åè½ç (åè) |
| | | */ |
| | | public enum NewAtmoFunctionCode { |
| | | |
| | | /** |
| | | * æ°çç大æ°å¼å§ |
| | | */ |
| | | // æ¥è¯¢å¿è·³å
|
| | | NewQueryHeartBeat("03"), |
| | | // æ¥è¯¢å¿è·³å
æ¶é´ |
| | | NewQueryHeartBeatTime("06"); |
| | | |
| | | |
| | | /** |
| | | * æ°çç大æ°ç»æ |
| | | */ |
| | | private String code; |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | NewAtmoFunctionCode(String code) { |
| | | this.code = code; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.rrpc.util; |
| | | |
| | | /** |
| | | * @author ZZQ |
| | | * @date 2022/4/24 15:08 |
| | | */ |
| | | public class CRC16Utils { |
| | | static byte[] crc16_tab_h = {(byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, |
| | | (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, |
| | | (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, |
| | | (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, |
| | | (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x01, (byte) 0xC0, (byte) 0x80, (byte) 0x41, (byte) 0x00, (byte) 0xC1, (byte) 0x81, (byte) 0x40}; |
| | | |
| | | static byte[] crc16_tab_l = {(byte) 0x00, (byte) 0xC0, (byte) 0xC1, (byte) 0x01, (byte) 0xC3, (byte) 0x03, (byte) 0x02, (byte) 0xC2, (byte) 0xC6, (byte) 0x06, (byte) 0x07, (byte) 0xC7, (byte) 0x05, (byte) 0xC5, (byte) 0xC4, (byte) 0x04, (byte) 0xCC, (byte) 0x0C, (byte) 0x0D, (byte) 0xCD, (byte) 0x0F, (byte) 0xCF, (byte) 0xCE, (byte) 0x0E, (byte) 0x0A, (byte) 0xCA, (byte) 0xCB, (byte) 0x0B, (byte) 0xC9, (byte) 0x09, (byte) 0x08, (byte) 0xC8, (byte) 0xD8, (byte) 0x18, (byte) 0x19, (byte) 0xD9, (byte) 0x1B, (byte) 0xDB, (byte) 0xDA, (byte) 0x1A, (byte) 0x1E, (byte) 0xDE, (byte) 0xDF, (byte) 0x1F, (byte) 0xDD, (byte) 0x1D, (byte) 0x1C, (byte) 0xDC, (byte) 0x14, (byte) 0xD4, (byte) 0xD5, (byte) 0x15, (byte) 0xD7, (byte) 0x17, (byte) 0x16, (byte) 0xD6, (byte) 0xD2, (byte) 0x12, |
| | | (byte) 0x13, (byte) 0xD3, (byte) 0x11, (byte) 0xD1, (byte) 0xD0, (byte) 0x10, (byte) 0xF0, (byte) 0x30, (byte) 0x31, (byte) 0xF1, (byte) 0x33, (byte) 0xF3, (byte) 0xF2, (byte) 0x32, (byte) 0x36, (byte) 0xF6, (byte) 0xF7, (byte) 0x37, (byte) 0xF5, (byte) 0x35, (byte) 0x34, (byte) 0xF4, (byte) 0x3C, (byte) 0xFC, (byte) 0xFD, (byte) 0x3D, (byte) 0xFF, (byte) 0x3F, (byte) 0x3E, (byte) 0xFE, (byte) 0xFA, (byte) 0x3A, (byte) 0x3B, (byte) 0xFB, (byte) 0x39, (byte) 0xF9, (byte) 0xF8, (byte) 0x38, (byte) 0x28, (byte) 0xE8, (byte) 0xE9, (byte) 0x29, (byte) 0xEB, (byte) 0x2B, (byte) 0x2A, (byte) 0xEA, (byte) 0xEE, (byte) 0x2E, (byte) 0x2F, (byte) 0xEF, (byte) 0x2D, (byte) 0xED, (byte) 0xEC, (byte) 0x2C, (byte) 0xE4, (byte) 0x24, (byte) 0x25, (byte) 0xE5, (byte) 0x27, (byte) 0xE7, |
| | | (byte) 0xE6, (byte) 0x26, (byte) 0x22, (byte) 0xE2, (byte) 0xE3, (byte) 0x23, (byte) 0xE1, (byte) 0x21, (byte) 0x20, (byte) 0xE0, (byte) 0xA0, (byte) 0x60, (byte) 0x61, (byte) 0xA1, (byte) 0x63, (byte) 0xA3, (byte) 0xA2, (byte) 0x62, (byte) 0x66, (byte) 0xA6, (byte) 0xA7, (byte) 0x67, (byte) 0xA5, (byte) 0x65, (byte) 0x64, (byte) 0xA4, (byte) 0x6C, (byte) 0xAC, (byte) 0xAD, (byte) 0x6D, (byte) 0xAF, (byte) 0x6F, (byte) 0x6E, (byte) 0xAE, (byte) 0xAA, (byte) 0x6A, (byte) 0x6B, (byte) 0xAB, (byte) 0x69, (byte) 0xA9, (byte) 0xA8, (byte) 0x68, (byte) 0x78, (byte) 0xB8, (byte) 0xB9, (byte) 0x79, (byte) 0xBB, (byte) 0x7B, (byte) 0x7A, (byte) 0xBA, (byte) 0xBE, (byte) 0x7E, (byte) 0x7F, (byte) 0xBF, (byte) 0x7D, (byte) 0xBD, (byte) 0xBC, (byte) 0x7C, (byte) 0xB4, (byte) 0x74, |
| | | (byte) 0x75, (byte) 0xB5, (byte) 0x77, (byte) 0xB7, (byte) 0xB6, (byte) 0x76, (byte) 0x72, (byte) 0xB2, (byte) 0xB3, (byte) 0x73, (byte) 0xB1, (byte) 0x71, (byte) 0x70, (byte) 0xB0, (byte) 0x50, (byte) 0x90, (byte) 0x91, (byte) 0x51, (byte) 0x93, (byte) 0x53, (byte) 0x52, (byte) 0x92, (byte) 0x96, (byte) 0x56, (byte) 0x57, (byte) 0x97, (byte) 0x55, (byte) 0x95, (byte) 0x94, (byte) 0x54, (byte) 0x9C, (byte) 0x5C, (byte) 0x5D, (byte) 0x9D, (byte) 0x5F, (byte) 0x9F, (byte) 0x9E, (byte) 0x5E, (byte) 0x5A, (byte) 0x9A, (byte) 0x9B, (byte) 0x5B, (byte) 0x99, (byte) 0x59, (byte) 0x58, (byte) 0x98, (byte) 0x88, (byte) 0x48, (byte) 0x49, (byte) 0x89, (byte) 0x4B, (byte) 0x8B, (byte) 0x8A, (byte) 0x4A, (byte) 0x4E, (byte) 0x8E, (byte) 0x8F, (byte) 0x4F, (byte) 0x8D, (byte) 0x4D, |
| | | (byte) 0x4C, (byte) 0x8C, (byte) 0x44, (byte) 0x84, (byte) 0x85, (byte) 0x45, (byte) 0x87, (byte) 0x47, (byte) 0x46, (byte) 0x86, (byte) 0x82, (byte) 0x42, (byte) 0x43, (byte) 0x83, (byte) 0x41, (byte) 0x81, (byte) 0x80, (byte) 0x40}; |
| | | |
| | | /** |
| | | * 计ç®CRC16æ ¡éª å¯¹å¤çæ¥å£ |
| | | * |
| | | * @param hex éè¦è®¡ç®çæ°ç» |
| | | * @return CRC16æ ¡éªå¼ |
| | | */ |
| | | public static String getCRC16(String hex) { |
| | | byte[] data = SupplementUtils.hexStringToBytes(hex); |
| | | return reversalCRC16(calcCrc16(data, 0, data.length)); |
| | | } |
| | | |
| | | /** |
| | | * 计ç®CRC16æ ¡éª |
| | | * |
| | | * @param data éè¦è®¡ç®çæ°ç» |
| | | * @param offset èµ·å§ä½ç½® |
| | | * @param len é¿åº¦ |
| | | * @return CRC16æ ¡éªå¼ |
| | | */ |
| | | public static int calcCrc16(byte[] data, int offset, int len) { |
| | | return calcCrc16(data, offset, len, 0xffff); |
| | | } |
| | | |
| | | /** |
| | | * 计ç®CRC16æ ¡éª |
| | | * |
| | | * @param data éè¦è®¡ç®çæ°ç» |
| | | * @param offset èµ·å§ä½ç½® |
| | | * @param len é¿åº¦ |
| | | * @param preval ä¹åçæ ¡éªå¼ |
| | | * @return CRC16æ ¡éªå¼ |
| | | */ |
| | | public static int calcCrc16(byte[] data, int offset, int len, int preval) { |
| | | int ucCRCHi = (preval & 0xff00) >> 8; |
| | | int ucCRCLo = preval & 0x00ff; |
| | | int iIndex; |
| | | for (int i = 0; i < len; ++i) { |
| | | iIndex = (ucCRCLo ^ data[offset + i]) & 0x00ff; |
| | | ucCRCLo = ucCRCHi ^ crc16_tab_h[iIndex]; |
| | | ucCRCHi = crc16_tab_l[iIndex]; |
| | | } |
| | | return ((ucCRCHi & 0x00ff) << 8) | (ucCRCLo & 0x00ff) & 0xffff; |
| | | } |
| | | |
| | | /** |
| | | * å°è®¡ç®çCRCå¼ è½¬æ¢ä¸ºå ç©ºæ ¼ç æ¯å¦ ï¼ crcå¼ä¸º A30A -> A3 0A |
| | | * |
| | | * @param res |
| | | * @return |
| | | */ |
| | | public static String getCrc(int res) { |
| | | String format = String.format("%04x", res); |
| | | String substring = format.substring(0, 2); |
| | | String substring1 = format.substring(2, 4); |
| | | return substring.concat(" ").concat(substring1).concat(" "); |
| | | } |
| | | /** |
| | | * ä¸å ç©ºæ ¼ï¼åªå¯¹æ¢é«ä½ä½ |
| | | * */ |
| | | public static String reversalCRC16(int res) { |
| | | String format = String.format("%04x", res); |
| | | String substring = format.substring(0, 2); |
| | | String substring1 = format.substring(2, 4); |
| | | return substring1.concat(substring); |
| | | } |
| | | } |
| | |
| | | return hex; |
| | | } |
| | | |
| | | /** åå
è¿å¶è½¬æ¢æåèæ°ç» */ |
| | | public static byte[] hexStringToBytes(String hexString) { |
| | | if (hexString == null || hexString.equals("")) { |
| | | return null; |
| | | } |
| | | hexString = hexString.toUpperCase(); // åå
è¿å¶è½¬å¤§å忝 |
| | | int length = hexString.length() / 2; // è·ååå
è¿å¶çé¿åº¦ï¼2个å符为ä¸ä¸ªåå
è¿å¶ |
| | | char[] hexChars = hexString.toCharArray(); |
| | | byte[] d = new byte[length]; |
| | | for (int i = 0; i < length; i++) { |
| | | int pos = i * 2; |
| | | d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); |
| | | } |
| | | return d; |
| | | } |
| | | |
| | | /** char转byte */ |
| | | private static byte charToByte(char c) { |
| | | return (byte) "0123456789ABCDEF".indexOf(c); |
| | | } |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereNewHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.AtmoFunctionCode; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.dao.domain.AirData; |
| | | import com.sandu.ximon.dao.domain.AirDataNongGeng; |
| | | import com.sandu.ximon.dao.domain.AirEquipment; |
| | | import com.sandu.ximon.dao.domain.AirEquipmentNongGeng; |
| | | import com.sandu.ximon.dao.mapper.AirDataNongGengMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * å¤§æ°æ°æ®ï¼åè硬件 |
| | | * |
| | | * @author ZZQ |
| | | * @date 2022/4/25 14:16 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class AirDataNongGengService extends BaseServiceImpl<AirDataNongGengMapper, AirDataNongGeng> { |
| | | private final AirEquipmentNongGengService airEquipmentNongGengService; |
| | | |
| | | /** |
| | | * ä¿å䏿¥å¤§æ°å¿è·³æ°æ® |
| | | * |
| | | * @return æ¯å¦æå |
| | | */ |
| | | public boolean saveReportData(String deviceName, A5AtmosphereNewHeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) { |
| | | |
| | | AirDataNongGeng airDataNongGeng = new AirDataNongGeng(); |
| | | BeanUtils.copyProperties(heartBeatDataPackage, airDataNongGeng); |
| | | airDataNongGeng.setMac(deviceName); |
| | | |
| | | //å°è®¾å¤ä¿¡æ¯æ·»å å°å¤§æ°è®¾å¤è¡¨ |
| | | AirEquipmentNongGeng airEquipmentNongGeng = new AirEquipmentNongGeng(); |
| | | airEquipmentNongGeng.setId(airDataNongGeng.getId()); |
| | | airEquipmentNongGeng.setMac(airDataNongGeng.getMac()); |
| | | airEquipmentNongGeng.setCreateTime(airDataNongGeng.getCreateTime()); |
| | | airEquipmentNongGengService.addAirEquipment(airEquipmentNongGeng); |
| | | |
| | | // //åç¼å |
| | | // RedisUtils.getBean().set(AtmoFunctionCode.AIR_HEARTBEAT.getCode() + deviceName, heartBeatDataPackage, 300L); |
| | | |
| | | return save(airDataNongGeng); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.dao.domain.AirEquipment; |
| | | import com.sandu.ximon.dao.domain.AirEquipmentNongGeng; |
| | | import com.sandu.ximon.dao.mapper.AirEquipmentNongGengMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author ZZQ |
| | | * @date 2022/4/25 14:43 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class AirEquipmentNongGengService extends BaseServiceImpl<AirEquipmentNongGengMapper, AirEquipmentNongGeng> { |
| | | /** |
| | | * æ·»å 大æ°è®¾å¤æ°æ® |
| | | * |
| | | * @return |
| | | */ |
| | | public void addAirEquipment(AirEquipmentNongGeng airEquipmentNongGeng) { |
| | | AirEquipmentNongGeng one = getOne(Wrappers.lambdaQuery(AirEquipmentNongGeng.class).eq(AirEquipmentNongGeng::getMac, airEquipmentNongGeng.getMac())); |
| | | if (one == null) { |
| | | save(airEquipmentNongGeng); |
| | | } |
| | | } |
| | | } |