diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java index b98086ce..2f145e71 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java @@ -2,6 +2,7 @@ package com.zc.business.mapper; import java.util.List; import com.zc.business.domain.DcMeteorologicalDetectorData; +import com.zc.business.domain.MdDeviceData; /** * 气象检测器数据Mapper接口 @@ -44,12 +45,12 @@ public interface DcMeteorologicalDetectorDataMapper int updateDcMeteorologicalDetectorData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData); /** - * 中间库新增气象检测器数据 + * 中间库新增设备数据 * - * @param dcMeteorologicalDetectorData 气象检测器数据 + * @param mdDeviceData 气象检测器数据 * @return 结果 */ - Boolean insertIntermediateWarehouseData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData); + Boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData); /** * 中间库修改气象检测器数据 diff --git a/zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java b/zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java index 110da462..955d4308 100644 --- a/zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java +++ b/zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java @@ -1,9 +1,11 @@ package com.zc.business.message.device.listener; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.google.gson.JsonObject; import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcMeteorologicalDetectorData; +import com.zc.business.domain.MdDeviceData; import com.zc.business.enums.IotProductEnum; import com.zc.business.service.IDcMeteorologicalDetectorDataService; import com.zc.common.core.redis.stream.RedisStream; @@ -17,6 +19,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -53,8 +56,31 @@ public class DevicePropertyReportListener implements StreamListener expands = new HashMap<>(); + expands.put("rainFall",meteorologicalDetectorData.getRainfall()); //雨量 + expands.put("windSpeed",meteorologicalDetectorData.getWindSpeed()); //风速 + expands.put("windDirection",meteorologicalDetectorData.getWindDirection()); //风向 + expands.put("temperature",meteorologicalDetectorData.getTemperature()); //大气温度 + expands.put("humidity",meteorologicalDetectorData.getHumidity()); //大气湿度 + expands.put("airPressure",meteorologicalDetectorData.getAtmosphericPressure()); //数字气压 + expands.put("wet",meteorologicalDetectorData.getWetSlipperyCoefficient()); //湿滑 + expands.put("rainXingTai",meteorologicalDetectorData.getPrecipitationType()); //雨量降水形态 + expands.put("visibility",meteorologicalDetectorData.getVisibility()); //能见度 + expands.put("pathContactLu",meteorologicalDetectorData.getRoadSurfaceTemperature()); //路面温度 + expands.put("pathContactBing",meteorologicalDetectorData.getFreezingPointTemperature()); //冰点温度 + expands.put("pathContactYan",meteorologicalDetectorData.getSalinityValue()); //路面盐度 + expands.put("pathContactZhuang",meteorologicalDetectorData.getRemoteRoadSurfaceStatus()); //路面状况 + + mdDeviceData.setExpands(JSONObject.toJSONString(expands)); + + meteorologicalDetectorDataService.insertMiddleDatabaseDeviceData(mdDeviceData); } else if (IotProductEnum.ONE_STOP_PRODUCT.value().equals(productId)){ //交调 diff --git a/zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java b/zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java index 481967f4..a33ba0a0 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java @@ -2,6 +2,7 @@ package com.zc.business.service; import java.util.List; import com.zc.business.domain.DcMeteorologicalDetectorData; +import com.zc.business.domain.MdDeviceData; /** * 气象检测器数据Service接口 @@ -36,12 +37,12 @@ public interface IDcMeteorologicalDetectorDataService int insertDcMeteorologicalDetectorData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData); /** - * 中间库新增气象检测器数据 + * 中间库新增设备数据 * - * @param dcMeteorologicalDetectorData 气象检测器数据 + * @param mdDeviceData 气象检测器数据 * @return 结果 */ - boolean insertIntermediateWarehouseData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData); + boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData); /** * 修改气象检测器数据 diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java index c1d3d4da..3df559f3 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java @@ -5,6 +5,7 @@ import java.util.List; import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.enums.DataSourceType; import com.zc.business.domain.DcDevice; +import com.zc.business.domain.MdDeviceData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.zc.business.mapper.DcMeteorologicalDetectorDataMapper; @@ -60,19 +61,16 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica } /** - * 中间库新增气象检测器数据 + * 中间库新增设备数据 * - * @param dcMeteorologicalDetectorData 气象检测器数据 + * @param mdDeviceData 气象检测器数据 * @return 结果 */ @DataSource(value = DataSourceType.SLAVE)//切换数据源 @Override - public boolean insertIntermediateWarehouseData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData) + public boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData) { - if (!dcMeteorologicalDetectorDataMapper.updateIntermediateWarehouseData(dcMeteorologicalDetectorData)){ - return dcMeteorologicalDetectorDataMapper.insertIntermediateWarehouseData(dcMeteorologicalDetectorData); - } - return false; + return dcMeteorologicalDetectorDataMapper.insertMiddleDatabaseDeviceData(mdDeviceData); } /** diff --git a/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml index 673e82f7..5d91cad2 100644 --- a/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml @@ -146,26 +146,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - - insert into meteorological_detector_data + + insert into device_data - device_id, - temperature, - humidity, - precipitation_type, - rainfall, - road_surface_status, - water_film_thickness, - update_time + devNo, + devType, + `timeStamp`, + expands, + CreatorUserId, + LastModificationTime, + LastModifierUserId, + IsDeleted, + DeleterUserId, + DeletionTime, + CreationTime - #{iotDeviceId}, - #{temperature}, - #{humidity}, - #{precipitationType}, - #{rainfall}, - #{roadSurfaceStatus}, - #{waterFilmThickness}, + #{devNo}, + #{devType}, + #{timeStamp}, + #{expands}, + #{creatorUserId}, + #{lastModificationTime}, + #{isDeleted}, + #{deleterUserId}, + #{deletionTime}, current_date