Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
王兴琳 9 months ago
parent
commit
2114c1b1f6
  1. 194
      zc-business/src/main/java/com/zc/business/domain/MdDeviceData.java
  2. 17
      zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java
  3. 33
      zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java
  4. 7
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java
  5. 33
      zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java
  6. 9
      zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java
  7. 35
      zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java
  8. 17
      zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java
  9. 57
      zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java
  10. 38
      zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml
  11. 40
      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();
}
}

17
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接口
@ -43,22 +44,6 @@ public interface DcMeteorologicalDetectorDataMapper
*/
int updateDcMeteorologicalDetectorData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData);
/**
* 中间库新增气象检测器数据
*
* @param dcMeteorologicalDetectorData 气象检测器数据
* @return 结果
*/
Boolean insertIntermediateWarehouseData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData);
/**
* 中间库修改气象检测器数据
*
* @param dcMeteorologicalDetectorData 气象检测器数据
* @return 结果
*/
Boolean updateIntermediateWarehouseData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData);
/**
* 删除气象检测器数据
*

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

@ -0,0 +1,33 @@
package com.zc.business.mapper;
import com.zc.business.domain.DcBoardReleaseLog;
import com.zc.business.domain.DcDevice;
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);
/**
* 更新中间库设备
*
* @param dcDevice 设备
* @return 结果
*/
boolean updateMiddleDatabaseDevice(DcDevice dcDevice);
}

7
zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

@ -13,6 +13,7 @@ import com.zc.business.enums.WarningStateEnum;
import com.zc.business.enums.WarningSubclassEnum;
import com.zc.business.service.IDcDeviceService;
import com.zc.business.service.IDcWarningService;
import com.zc.business.service.IMiddleDatabaseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -42,6 +43,9 @@ public class DeviceMessageHandler {
@Resource
private IDcWarningService dcWarningService;
@Resource
private IMiddleDatabaseService middleDatabaseService;
@Resource
private RedisCache redisCache;
@ -65,6 +69,9 @@ public class DeviceMessageHandler {
// 批量更新设备状态
dcDeviceService.batchUpdate(dcDevices);
// 批量更新中间库设备状态
middleDatabaseService.updateMiddleDatabaseDevice(dcDevices);
}
/**

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

@ -1,11 +1,14 @@
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.business.service.IMiddleDatabaseService;
import com.zc.common.core.redis.stream.RedisStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -17,6 +20,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;
@ -36,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) {
@ -53,8 +59,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));
middleDatabaseService.insertMiddleDatabaseDeviceData(mdDeviceData);
} else if (IotProductEnum.ONE_STOP_PRODUCT.value().equals(productId)){
//交调

9
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接口
@ -35,14 +36,6 @@ public interface IDcMeteorologicalDetectorDataService
*/
int insertDcMeteorologicalDetectorData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData);
/**
* 中间库新增气象检测器数据
*
* @param dcMeteorologicalDetectorData 气象检测器数据
* @return 结果
*/
boolean insertIntermediateWarehouseData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData);
/**
* 修改气象检测器数据
*

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

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

17
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;
@ -59,22 +60,6 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica
return dcMeteorologicalDetectorDataMapper.insertDcMeteorologicalDetectorData(dcMeteorologicalDetectorData);
}
/**
* 中间库新增气象检测器数据
*
* @param dcMeteorologicalDetectorData 气象检测器数据
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean insertIntermediateWarehouseData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData)
{
if (!dcMeteorologicalDetectorDataMapper.updateIntermediateWarehouseData(dcMeteorologicalDetectorData)){
return dcMeteorologicalDetectorDataMapper.insertIntermediateWarehouseData(dcMeteorologicalDetectorData);
}
return false;
}
/**
* 修改气象检测器数据
*

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

@ -0,0 +1,57 @@
package com.zc.business.service.impl;
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 com.zc.business.mapper.MiddleDatabaseMapper;
import com.zc.business.service.IMiddleDatabaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 中间库Service业务层处理
*
* @author ruoyi
* @date 2024-01-03
*/
@Service
public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
@Autowired
private MiddleDatabaseMapper middleDatabaseMapper;
/**
* 中间库新增设备数据
*
* @param mdDeviceData 气象检测器数据
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData)
{
return middleDatabaseMapper.insertMiddleDatabaseDeviceData(mdDeviceData);
}
/**
* 更新中间库设备
*
* @param listDevice 设备列表
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean updateMiddleDatabaseDevice(List<DcDevice> listDevice)
{
for (DcDevice dcDevice : listDevice) {
middleDatabaseMapper.updateMiddleDatabaseDevice(dcDevice);
}
return true;
}
}

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

@ -146,44 +146,6 @@ 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
<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
</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>
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>

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

@ -0,0 +1,40 @@
<?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>
<update id="updateMiddleDatabaseDevice">
update device set dev_status = #{deviceState} where dev_no = #{iotDeviceId}
</update>
</mapper>
Loading…
Cancel
Save