Browse Source

气象检测数据插入中间库

develop
lau572 9 months ago
parent
commit
5ef39c8f7a
  1. 7
      zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java
  2. 30
      zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java
  3. 7
      zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java
  4. 12
      zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java
  5. 39
      zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml

7
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);
/**
* 中间库修改气象检测器数据

30
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<String, Obje
meteorologicalDetectorData.setIotDeviceId(data.get("deviceId").toString());
meteorologicalDetectorDataService.insertDcMeteorologicalDetectorData(meteorologicalDetectorData);
//设计院中间库
meteorologicalDetectorDataService.insertIntermediateWarehouseData(meteorologicalDetectorData);
//设计院中间库 插入设备数据
MdDeviceData mdDeviceData = new MdDeviceData();
mdDeviceData.setDevNo(meteorologicalDetectorData.getIotDeviceId());
mdDeviceData.setDevType("3");
mdDeviceData.setTimeStamp(new Date());
mdDeviceData.setCreatorUserId("自动存储");
Map<String,Object> 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)){
//交调

7
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);
/**
* 修改气象检测器数据

12
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);
}
/**

39
zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml

@ -146,26 +146,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<insert id="insertIntermediateWarehouseData" parameterType="DcMeteorologicalDetectorData" useGeneratedKeys="true" keyProperty="id">
insert into meteorological_detector_data
<insert id="insertMiddleDatabaseDeviceData" parameterType="MdDeviceData" useGeneratedKeys="true" keyProperty="id">
insert into device_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="iotDeviceId != null">device_id,</if>
<if test="temperature != null">temperature,</if>
<if test="humidity != null">humidity,</if>
<if test="precipitationType != null">precipitation_type,</if>
<if test="rainfall != null">rainfall,</if>
<if test="roadSurfaceStatus != null">road_surface_status,</if>
<if test="waterFilmThickness != null">water_film_thickness,</if>
update_time
<if test="devNo != null">devNo,</if>
<if test="devType != null">devType,</if>
<if test="timeStamp != null">`timeStamp`,</if>
<if test="expands != null">expands,</if>
<if test="creatorUserId != null">CreatorUserId,</if>
<if test="lastModificationTime != null">LastModificationTime,</if>
<if test="lastModifierUserId != null">LastModifierUserId,</if>
<if test="isDeleted != null">IsDeleted,</if>
<if test="deleterUserId != null">DeleterUserId,</if>
<if test="deletionTime != null">DeletionTime,</if>
CreationTime
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="iotDeviceId != null">#{iotDeviceId},</if>
<if test="temperature != null">#{temperature},</if>
<if test="humidity != null">#{humidity},</if>
<if test="precipitationType != null">#{precipitationType},</if>
<if test="rainfall != null">#{rainfall},</if>
<if test="roadSurfaceStatus != null">#{roadSurfaceStatus},</if>
<if test="waterFilmThickness != null">#{waterFilmThickness},</if>
<if test="devNo != null">#{devNo},</if>
<if test="devType != null">#{devType},</if>
<if test="timeStamp != null">#{timeStamp},</if>
<if test="expands != null">#{expands},</if>
<if test="creatorUserId != null">#{creatorUserId},</if>
<if test="lastModificationTime != null">#{lastModificationTime},</if>
<if test="isDeleted != null">#{isDeleted},</if>
<if test="deleterUserId != null">#{deleterUserId},</if>
<if test="deletionTime != null">#{deletionTime},</if>
current_date
</trim>
</insert>

Loading…
Cancel
Save