Browse Source

气象检测数据插入中间库

develop
lau572 9 months ago
parent
commit
9225098670
  1. 194
      zc-business/src/main/java/com/zc/business/domain/MdDeviceData.java
  2. 16
      zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java
  3. 24
      zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java
  4. 5
      zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java
  5. 8
      zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java
  6. 24
      zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java
  7. 13
      zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java
  8. 55
      zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java
  9. 43
      zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml
  10. 36
      zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

194
zc-business/src/main/java/com/zc/business/domain/MdDeviceData.java

@ -0,0 +1,194 @@
package com.zc.business.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
/**
* @Description 中间库设备数据
*
* @author liuwenge
* @date 2024/2/20 17:30
*/
public class MdDeviceData {
/** 主键 */
private Long id;
/** 设备编号 */
@Excel(name = "设备编号")
private String devNo;
/** 设备类型 */
@Excel(name = "设备类型")
private String devType;
/** 时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date timeStamp;
/** 自定义字段 */
@Excel(name = "自定义字段")
private String expands;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date creationTime;
/** 创建人 */
@Excel(name = "创建人")
private String creatorUserId;
/** 最后修改时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "最后修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date lastModificationTime;
/** 最后修改人 */
@Excel(name = "最后修改人")
private Long lastModifierUserId;
/** 是否删除 */
@Excel(name = "是否删除")
private Integer isDeleted;
/** 删除人 */
@Excel(name = "删除人")
private Long deleterUserId;
/** 删除时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "删除时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date deletionTime;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setDevNo(String devNo)
{
this.devNo = devNo;
}
public String getDevNo()
{
return devNo;
}
public String getDevType() {
return devType;
}
public void setDevType(String devType) {
this.devType = devType;
}
public void setTimeStamp(Date timeStamp)
{
this.timeStamp = timeStamp;
}
public Date getTimeStamp()
{
return timeStamp;
}
public void setExpands(String expands)
{
this.expands = expands;
}
public String getExpands()
{
return expands;
}
public void setCreationTime(Date creationTime)
{
this.creationTime = creationTime;
}
public Date getCreationTime()
{
return creationTime;
}
public void setCreatorUserId(String creatorUserId)
{
this.creatorUserId = creatorUserId;
}
public String getCreatorUserId()
{
return creatorUserId;
}
public void setLastModificationTime(Date lastModificationTime)
{
this.lastModificationTime = lastModificationTime;
}
public Date getLastModificationTime()
{
return lastModificationTime;
}
public void setLastModifierUserId(Long lastModifierUserId)
{
this.lastModifierUserId = lastModifierUserId;
}
public Long getLastModifierUserId()
{
return lastModifierUserId;
}
public void setIsDeleted(Integer isDeleted)
{
this.isDeleted = isDeleted;
}
public Integer getIsDeleted()
{
return isDeleted;
}
public void setDeleterUserId(Long deleterUserId)
{
this.deleterUserId = deleterUserId;
}
public Long getDeleterUserId()
{
return deleterUserId;
}
public void setDeletionTime(Date deletionTime)
{
this.deletionTime = deletionTime;
}
public Date getDeletionTime()
{
return deletionTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("devNo", getDevNo())
.append("timeStamp", getTimeStamp())
.append("expands", getExpands())
.append("creationTime", getCreationTime())
.append("creatorUserId", getCreatorUserId())
.append("lastModificationTime", getLastModificationTime())
.append("lastModifierUserId", getLastModifierUserId())
.append("isDeleted", getIsDeleted())
.append("deleterUserId", getDeleterUserId())
.append("deletionTime", getDeletionTime())
.toString();
}
}

16
zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java

@ -44,22 +44,6 @@ public interface DcMeteorologicalDetectorDataMapper
*/
int updateDcMeteorologicalDetectorData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData);
/**
* 中间库新增设备数据
*
* @param mdDeviceData 气象检测器数据
* @return 结果
*/
Boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData);
/**
* 中间库修改气象检测器数据
*
* @param dcMeteorologicalDetectorData 气象检测器数据
* @return 结果
*/
Boolean updateIntermediateWarehouseData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData);
/**
* 删除气象检测器数据
*

24
zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java

@ -0,0 +1,24 @@
package com.zc.business.mapper;
import com.zc.business.domain.DcBoardReleaseLog;
import com.zc.business.domain.MdDeviceData;
import java.util.List;
/**
* 中间库Mapper接口
*
* @author ruoyi
* @date 2024-01-05
*/
public interface MiddleDatabaseMapper
{
/**
* 中间库新增设备数据
*
* @param mdDeviceData 气象检测器数据
* @return 结果
*/
Boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData);
}

5
zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java

@ -8,6 +8,7 @@ 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.business.service.IMiddleDatabaseService;
import com.zc.common.core.redis.stream.RedisStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -39,6 +40,8 @@ public class DevicePropertyReportListener implements StreamListener<String, Obje
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Autowired
private IDcMeteorologicalDetectorDataService meteorologicalDetectorDataService;
@Autowired
private IMiddleDatabaseService middleDatabaseService;
@Override
public void onMessage(ObjectRecord<String, String> message) {
@ -80,7 +83,7 @@ public class DevicePropertyReportListener implements StreamListener<String, Obje
mdDeviceData.setExpands(JSONObject.toJSONString(expands));
meteorologicalDetectorDataService.insertMiddleDatabaseDeviceData(mdDeviceData);
middleDatabaseService.insertMiddleDatabaseDeviceData(mdDeviceData);
} else if (IotProductEnum.ONE_STOP_PRODUCT.value().equals(productId)){
//交调

8
zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java

@ -36,14 +36,6 @@ public interface IDcMeteorologicalDetectorDataService
*/
int insertDcMeteorologicalDetectorData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData);
/**
* 中间库新增设备数据
*
* @param mdDeviceData 气象检测器数据
* @return 结果
*/
boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData);
/**
* 修改气象检测器数据
*

24
zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java

@ -0,0 +1,24 @@
package com.zc.business.service;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcBoardPublish;
import com.zc.business.domain.MdDeviceData;
/**
* 中间库Service接口
*
* @author ruoyi
* @date 2024-01-03
*/
public interface IMiddleDatabaseService
{
/**
* 中间库新增设备数据
*
* @param mdDeviceData 气象检测器数据
* @return 结果
*/
boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData);
}

13
zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java

@ -60,19 +60,6 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica
return dcMeteorologicalDetectorDataMapper.insertDcMeteorologicalDetectorData(dcMeteorologicalDetectorData);
}
/**
* 中间库新增设备数据
*
* @param mdDeviceData 气象检测器数据
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData)
{
return dcMeteorologicalDetectorDataMapper.insertMiddleDatabaseDeviceData(mdDeviceData);
}
/**
* 修改气象检测器数据
*

55
zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java

@ -0,0 +1,55 @@
package com.zc.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.zc.business.controller.DcDeviceController;
import com.zc.business.domain.DcBoardPublish;
import com.zc.business.domain.DcBoardReleaseLog;
import com.zc.business.domain.MdDeviceData;
import com.zc.business.mapper.DcBoardReleaseLogMapper;
import com.zc.business.mapper.MiddleDatabaseMapper;
import com.zc.business.service.IDcBoardService;
import com.zc.business.service.IMiddleDatabaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 中间库Service业务层处理
*
* @author ruoyi
* @date 2024-01-03
*/
@Service
public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
@Autowired
private MiddleDatabaseMapper middleDatabaseMapper;
@Autowired
private DcDeviceController deviceController;
/**
* 中间库新增设备数据
*
* @param mdDeviceData 气象检测器数据
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData)
{
return middleDatabaseMapper.insertMiddleDatabaseDeviceData(mdDeviceData);
}
}

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

@ -146,49 +146,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<insert id="insertMiddleDatabaseDeviceData" parameterType="MdDeviceData" useGeneratedKeys="true" keyProperty="id">
insert into device_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<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="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>
<update id="updateIntermediateWarehouseData" parameterType="DcMeteorologicalDetectorData">
update meteorological_detector_data
<trim prefix="SET" suffixOverrides=",">
<if test="temperature != null">temperature = #{temperature},</if>
<if test="humidity != null">humidity = #{humidity},</if>
<if test="precipitationType != null">precipitation_type = #{precipitationType},</if>
<if test="rainfall != null">rainfall = #{rainfall},</if>
<if test="roadSurfaceStatus != null">road_surface_status = #{roadSurfaceStatus},</if>
<if test="waterFilmThickness != null">water_film_thickness = #{waterFilmThickness},</if>
update_time = current_date
</trim>
where device_id = #{iotDeviceId}
</update>
<delete id="deleteDcMeteorologicalDetectorDataById" parameterType="Long">
delete from dc_meteorological_detector_data where id = #{id}
</delete>

36
zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

@ -0,0 +1,36 @@
<?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.zc.business.mapper.MiddleDatabaseMapper">
<insert id="insertMiddleDatabaseDeviceData" parameterType="MdDeviceData" useGeneratedKeys="true" keyProperty="id">
insert into device_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<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="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>
</mapper>
Loading…
Cancel
Save