增加恶臭类表,增加恶臭自动填充逻辑

This commit is contained in:
zhangyue 2026-07-21 16:47:15 +08:00
parent 6e71ec4c38
commit f0b0cc4da9
26 changed files with 1443 additions and 22 deletions

View File

@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
*/ */
public class MybatisPlusGenerator { public class MybatisPlusGenerator {
public static final String database = "jdbc:mysql://8.130.9.244:13306/fx_nsp"; public static final String database = "jdbc:mysql://172.27.17.13:13306/fx_nsp";
public static final String user = "user_fx"; public static final String user = "user_fx";
public static final String passwd = "user_fx"; public static final String passwd = "user_fx";
@ -80,7 +80,7 @@ public class MybatisPlusGenerator {
public static void main(String[] args) { public static void main(String[] args) {
new MybatisPlusGenerator().generator("surv_device_deploy_relay","surv_device_deploy_relaygroup");//指标 new MybatisPlusGenerator().generator("surv_transdata_vocs","surv_transdata_vocs_min");//指标
} }

View File

@ -0,0 +1,21 @@
package com.lanhai.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 恶臭历史数据 前端控制器
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Controller
@RequestMapping("/survHisdataVocs")
public class SurvHisdataVocsController {
}

View File

@ -0,0 +1,21 @@
package com.lanhai.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 恶臭分钟历史数据 前端控制器
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Controller
@RequestMapping("/survHisdataVocsMin")
public class SurvHisdataVocsMinController {
}

View File

@ -0,0 +1,21 @@
package com.lanhai.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 恶臭实时数据 前端控制器
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Controller
@RequestMapping("/survTransdataVocs")
public class SurvTransdataVocsController {
}

View File

@ -0,0 +1,21 @@
package com.lanhai.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 恶臭分钟数据 前端控制器
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Controller
@RequestMapping("/survTransdataVocsMin")
public class SurvTransdataVocsMinController {
}

View File

@ -0,0 +1,207 @@
package com.lanhai.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 恶臭历史数据
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SurvHisdataVocs extends Model<SurvHisdataVocs> {
private static final long serialVersionUID=1L;
/**
* 主键
*/
@TableId(value = "ID", type = IdType.ID_WORKER_STR)
private String id;
/**
* 设备ID
*/
@TableField("DEPLOY_ID")
private String deployId;
/**
* 总挥发性有机物
*/
@TableField("DATA_TVOC")
private String dataTvoc;
/**
* 臭气浓度
*/
@TableField("DATA_OU")
private String dataOu;
/**
* 氨气
*/
@TableField("DATA_NH3")
private String dataNh3;
/**
* 硫化氢
*/
@TableField("DATA_H2S")
private String dataH2s;
/**
* 请求编号
*/
@TableField("DATA_QN")
private String dataQn;
/**
* 访问密码
*/
@TableField("DATA_PW")
private String dataPw;
/**
* CRC校验
*/
@TableField("DATA_END")
private String dataEnd;
/**
* 数据长度
*/
@TableField("DATA_SIZE")
private String dataSize;
/**
* 指令
*/
@TableField("DATA_CN")
private String dataCn;
/**
* 站点ID
*/
@TableField("STATION_ID")
private String stationId;
/**
* 站点编号
*/
@TableField("STATION_CODE")
private String stationCode;
/**
* 设备部署编号
*/
@TableField("DEPLOY_CODE")
private String deployCode;
/**
* 数据更新时间
*/
@TableField("DATA_DATE_TIME")
private LocalDateTime dataDateTime;
/**
* 数据类型;realTime=实时dayTime=日数据month=月数据year=年数据
*/
@TableField("DATA_GATHER_TYPE")
private String dataGatherType;
/**
* 数据时间戳
*/
@TableField("DATA_TIME")
private String dataTime;
/**
* 转储时间
*/
@TableField("TRANS_DATE")
private LocalDateTime transDate;
/**
* 规则类型
*/
@TableField("RULE_TYPE")
private String ruleType;
/**
* 设备名称
*/
@TableField("DEVICE_NAME")
private String deviceName;
/**
* 站点名称
*/
@TableField("STATION_NAME")
private String stationName;
/**
* 租户号
*/
@TableField("TENANT_ID")
private String tenantId;
/**
* 乐观锁
*/
@TableField("RE_VISION")
private Integer reVision;
/**
* 创建人
*/
@TableField("CREATED_BY")
private String createdBy;
/**
* 创建时间
*/
@TableField("CREATE_TIME")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField("UPDATED_BY")
private String updatedBy;
/**
* 逻辑删除
*/
@TableField("IS_DEL")
private Integer isDel;
/**
* 更新时间
*/
@TableField("UPDATED_TIME")
private LocalDateTime updatedTime;
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -0,0 +1,254 @@
package com.lanhai.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 恶臭分钟历史数据
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SurvHisdataVocsMin extends Model<SurvHisdataVocsMin> {
private static final long serialVersionUID=1L;
/**
* 主键
*/
@TableId(value = "ID", type = IdType.ID_WORKER_STR)
private String id;
/**
* 设备ID
*/
@TableField("DEPLOY_ID")
private String deployId;
/**
* 总挥发性有机物分钟最小
*/
@TableField("DATA_TVOC_MIN")
private String dataTvocMin;
/**
* 总挥发性有机物分钟最大
*/
@TableField("DATA_TVOC_MAX")
private String dataTvocMax;
/**
* 总挥发性有机物分钟平均
*/
@TableField("DATA_TVOC_AVG")
private String dataTvocAvg;
/**
* 臭气浓度分钟最小
*/
@TableField("DATA_OU_MIN")
private String dataOuMin;
/**
* 臭气浓度分钟c
*/
@TableField("DATA_OU_MAX")
private String dataOuMax;
/**
* 臭气浓度分钟平均
*/
@TableField("DATA_OU_AVG")
private String dataOuAvg;
/**
* 氨气浓度分钟最小
*/
@TableField("DATA_NH3_MIN")
private String dataNh3Min;
/**
* 氨气浓度分钟最小
*/
@TableField("DATA_NH3_MAX")
private String dataNh3Max;
/**
* 氨气分钟平均
*/
@TableField("DATA_NH3_AVG")
private String dataNh3Avg;
/**
* 硫化氢分钟最大
*/
@TableField("DATA_H2S_MIN")
private String dataH2sMin;
/**
* 硫化氢分钟最小
*/
@TableField("DATA_H2S_MAX")
private String dataH2sMax;
/**
* 硫化氢分钟平均
*/
@TableField("DATA_H2S_AVG")
private String dataH2sAvg;
/**
* 请求编号
*/
@TableField("DATA_QN")
private String dataQn;
/**
* 访问密码
*/
@TableField("DATA_PW")
private String dataPw;
/**
* CRC校验
*/
@TableField("DATA_END")
private String dataEnd;
/**
* 数据长度
*/
@TableField("DATA_SIZE")
private String dataSize;
/**
* 指令
*/
@TableField("DATA_CN")
private String dataCn;
/**
* 站点ID
*/
@TableField("STATION_ID")
private String stationId;
/**
* 站点编号
*/
@TableField("STATION_CODE")
private String stationCode;
/**
* 设备部署编号
*/
@TableField("DEPLOY_CODE")
private String deployCode;
/**
* 数据更新时间
*/
@TableField("DATA_DATE_TIME")
private LocalDateTime dataDateTime;
/**
* 数据类型;realTime=实时dayTime=日数据month=月数据year=年数据
*/
@TableField("DATA_GATHER_TYPE")
private String dataGatherType;
/**
* 数据时间戳
*/
@TableField("DATA_TIME")
private String dataTime;
/**
* 转储时间
*/
@TableField("TRANS_DATE")
private LocalDateTime transDate;
/**
* 规则类型
*/
@TableField("RULE_TYPE")
private String ruleType;
/**
* 设备名称
*/
@TableField("DEVICE_NAME")
private String deviceName;
/**
* 站点名称
*/
@TableField("STATION_NAME")
private String stationName;
/**
* 租户号
*/
@TableField("TENANT_ID")
private String tenantId;
/**
* 乐观锁
*/
@TableField("RE_VISION")
private Integer reVision;
/**
* 创建人
*/
@TableField("CREATED_BY")
private String createdBy;
/**
* 创建时间
*/
@TableField("CREATE_TIME")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField("UPDATED_BY")
private String updatedBy;
/**
* 逻辑删除
*/
@TableField("IS_DEL")
private Integer isDel;
/**
* 更新时间
*/
@TableField("UPDATED_TIME")
private LocalDateTime updatedTime;
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -0,0 +1,200 @@
package com.lanhai.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 恶臭实时数据
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SurvTransdataVocs extends Model<SurvTransdataVocs> {
private static final long serialVersionUID=1L;
/**
* 主键
*/
@TableId(value = "ID", type = IdType.ID_WORKER_STR)
private String id;
/**
* 设备ID
*/
@TableField("DEPLOY_ID")
private String deployId;
/**
* 总挥发性有机物
*/
@TableField("DATA_TVOC")
private String dataTvoc;
/**
* 臭气浓度
*/
@TableField("DATA_OU")
private String dataOu;
/**
* 氨气
*/
@TableField("DATA_NH3")
private String dataNh3;
/**
* 硫化氢
*/
@TableField("DATA_H2S")
private String dataH2s;
/**
* 站点ID
*/
@TableField("STATION_ID")
private String stationId;
/**
* 站点编号
*/
@TableField("STATION_CODE")
private String stationCode;
/**
* 设备部署编号
*/
@TableField("DEPLOY_CODE")
private String deployCode;
/**
* 数据更新时间
*/
@TableField("DATA_DATE_TIME")
private LocalDateTime dataDateTime;
/**
* 数据类型;realTime=实时dayTime=日数据month=月数据year=年数据
*/
@TableField("DATA_GATHER_TYPE")
private String dataGatherType;
/**
* 请求编号
*/
@TableField("DATA_QN")
private String dataQn;
/**
* 访问密码
*/
@TableField("DATA_PW")
private String dataPw;
/**
* CRC校验
*/
@TableField("DATA_END")
private String dataEnd;
/**
* 数据长度
*/
@TableField("DATA_SIZE")
private String dataSize;
/**
* 指令
*/
@TableField("DATA_CN")
private String dataCn;
/**
* 数据时间戳
*/
@TableField("DATA_TIME")
private String dataTime;
/**
* 规则类型
*/
@TableField("RULE_TYPE")
private String ruleType;
/**
* 设备名称
*/
@TableField("DEVICE_NAME")
private String deviceName;
/**
* 站点名称
*/
@TableField("STATION_NAME")
private String stationName;
/**
* 租户号
*/
@TableField("TENANT_ID")
private String tenantId;
/**
* 乐观锁
*/
@TableField("RE_VISION")
private Integer reVision;
/**
* 创建人
*/
@TableField("CREATED_BY")
private String createdBy;
/**
* 创建时间
*/
@TableField("CREATE_TIME")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField("UPDATED_BY")
private String updatedBy;
/**
* 逻辑删除
*/
@TableField("IS_DEL")
private Integer isDel;
/**
* 更新时间
*/
@TableField("UPDATED_TIME")
private LocalDateTime updatedTime;
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -0,0 +1,248 @@
package com.lanhai.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 恶臭分钟数据
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SurvTransdataVocsMin extends Model<SurvTransdataVocsMin> {
private static final long serialVersionUID=1L;
/**
* 主键
*/
@TableId(value = "ID", type = IdType.ID_WORKER_STR)
private String id;
/**
* 设备ID
*/
@TableField("DEPLOY_ID")
private String deployId;
/**
* 总挥发性有机物分钟最小
*/
@TableField("DATA_TVOC_MIN")
private String dataTvocMin;
/**
* 总挥发性有机物分钟最大
*/
@TableField("DATA_TVOC_MAX")
private String dataTvocMax;
/**
* 总挥发性有机物分钟平均
*/
@TableField("DATA_TVOC_AVG")
private String dataTvocAvg;
/**
* 臭气浓度分钟最小
*/
@TableField("DATA_OU_MIN")
private String dataOuMin;
/**
* 臭气浓度分钟c
*/
@TableField("DATA_OU_MAX")
private String dataOuMax;
/**
* 臭气浓度分钟平均
*/
@TableField("DATA_OU_AVG")
private String dataOuAvg;
/**
* 氨气浓度分钟最小
*/
@TableField("DATA_NH3_MIN")
private String dataNh3Min;
/**
* 氨气浓度分钟最小
*/
@TableField("DATA_NH3_MAX")
private String dataNh3Max;
/**
* 氨气分钟平均
*/
@TableField("DATA_NH3_AVG")
private String dataNh3Avg;
/**
* 硫化氢分钟最大
*/
@TableField("DATA_H2S_MIN")
private String dataH2sMin;
/**
* 硫化氢分钟最小
*/
@TableField("DATA_H2S_MAX")
private String dataH2sMax;
/**
* 硫化氢分钟平均
*/
@TableField("DATA_H2S_AVG")
private String dataH2sAvg;
/**
* 请求编号
*/
@TableField("DATA_QN")
private String dataQn;
/**
* 访问密码
*/
@TableField("DATA_PW")
private String dataPw;
/**
* CRC校验
*/
@TableField("DATA_END")
private String dataEnd;
/**
* 数据长度
*/
@TableField("DATA_SIZE")
private String dataSize;
/**
* 指令
*/
@TableField("DATA_CN")
private String dataCn;
/**
* 站点ID
*/
@TableField("STATION_ID")
private String stationId;
/**
* 站点编号
*/
@TableField("STATION_CODE")
private String stationCode;
/**
* 设备部署编号
*/
@TableField("DEPLOY_CODE")
private String deployCode;
/**
* 数据更新时间
*/
@TableField("DATA_DATE_TIME")
private LocalDateTime dataDateTime;
/**
* 数据类型;realTime=实时dayTime=日数据month=月数据year=年数据
*/
@TableField("DATA_GATHER_TYPE")
private String dataGatherType;
/**
* 数据时间戳
*/
@TableField("DATA_TIME")
private String dataTime;
/**
* 规则类型
*/
@TableField("RULE_TYPE")
private String ruleType;
/**
* 设备名称
*/
@TableField("DEVICE_NAME")
private String deviceName;
/**
* 站点名称
*/
@TableField("STATION_NAME")
private String stationName;
/**
* 租户号
*/
@TableField("TENANT_ID")
private String tenantId;
/**
* 乐观锁
*/
@TableField("RE_VISION")
private Integer reVision;
/**
* 创建人
*/
@TableField("CREATED_BY")
private String createdBy;
/**
* 创建时间
*/
@TableField("CREATE_TIME")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField("UPDATED_BY")
private String updatedBy;
/**
* 逻辑删除
*/
@TableField("IS_DEL")
private Integer isDel;
/**
* 更新时间
*/
@TableField("UPDATED_TIME")
private LocalDateTime updatedTime;
@Override
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -0,0 +1,16 @@
package com.lanhai.mapper;
import com.lanhai.entity.SurvHisdataVocs;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 恶臭历史数据 Mapper 接口
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
public interface SurvHisdataVocsMapper extends BaseMapper<SurvHisdataVocs> {
}

View File

@ -0,0 +1,16 @@
package com.lanhai.mapper;
import com.lanhai.entity.SurvHisdataVocsMin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 恶臭分钟历史数据 Mapper 接口
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
public interface SurvHisdataVocsMinMapper extends BaseMapper<SurvHisdataVocsMin> {
}

View File

@ -0,0 +1,16 @@
package com.lanhai.mapper;
import com.lanhai.entity.SurvTransdataVocs;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 恶臭实时数据 Mapper 接口
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
public interface SurvTransdataVocsMapper extends BaseMapper<SurvTransdataVocs> {
}

View File

@ -0,0 +1,16 @@
package com.lanhai.mapper;
import com.lanhai.entity.SurvTransdataVocsMin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 恶臭分钟数据 Mapper 接口
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
public interface SurvTransdataVocsMinMapper extends BaseMapper<SurvTransdataVocsMin> {
}

View File

@ -0,0 +1,5 @@
<?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.lanhai.mapper.SurvHisdataVocsMapper">
</mapper>

View File

@ -0,0 +1,5 @@
<?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.lanhai.mapper.SurvHisdataVocsMinMapper">
</mapper>

View File

@ -0,0 +1,5 @@
<?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.lanhai.mapper.SurvTransdataVocsMapper">
</mapper>

View File

@ -0,0 +1,5 @@
<?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.lanhai.mapper.SurvTransdataVocsMinMapper">
</mapper>

View File

@ -0,0 +1,16 @@
package com.lanhai.service;
import com.lanhai.entity.SurvHisdataVocsMin;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 恶臭分钟历史数据 服务类
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
public interface ISurvHisdataVocsMinService extends IService<SurvHisdataVocsMin> {
}

View File

@ -0,0 +1,20 @@
package com.lanhai.service;
import com.lanhai.entity.SurvDeviceDeploy;
import com.lanhai.entity.SurvHisdataVocs;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lanhai.entity.SurvTransdataVocs;
import com.lanhai.o.iot.task.DataExamineDetail;
/**
* <p>
* 恶臭历史数据 服务类
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
public interface ISurvHisdataVocsService extends IService<SurvHisdataVocs> {
SurvTransdataVocs genDataAuto(SurvDeviceDeploy deploy, DataExamineDetail config);
}

View File

@ -0,0 +1,16 @@
package com.lanhai.service;
import com.lanhai.entity.SurvTransdataVocsMin;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 恶臭分钟数据 服务类
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
public interface ISurvTransdataVocsMinService extends IService<SurvTransdataVocsMin> {
}

View File

@ -0,0 +1,18 @@
package com.lanhai.service;
import com.lanhai.entity.SurvTransdataSoil;
import com.lanhai.entity.SurvTransdataVocs;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 恶臭实时数据 服务类
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
public interface ISurvTransdataVocsService extends IService<SurvTransdataVocs> {
SurvTransdataVocs getOneByDeviceId(String deployId);
}

View File

@ -0,0 +1,20 @@
package com.lanhai.service.Impl;
import com.lanhai.entity.SurvHisdataVocsMin;
import com.lanhai.mapper.SurvHisdataVocsMinMapper;
import com.lanhai.service.ISurvHisdataVocsMinService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 恶臭分钟历史数据 服务实现类
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Service
public class SurvHisdataVocsMinServiceImpl extends ServiceImpl<SurvHisdataVocsMinMapper, SurvHisdataVocsMin> implements ISurvHisdataVocsMinService {
}

View File

@ -0,0 +1,185 @@
package com.lanhai.service.Impl;
import cn.hutool.core.bean.BeanUtil;
import com.lanhai.constant.IotConstants;
import com.lanhai.entity.SurvDeviceDeploy;
import com.lanhai.entity.SurvHisdataVocs;
import com.lanhai.entity.SurvStationInfo;
import com.lanhai.entity.SurvTransdataVocs;
import com.lanhai.mapper.SurvHisdataVocsMapper;
import com.lanhai.o.iot.task.DataExamineDetail;
import com.lanhai.o.iot.task.DataExamineRule;
import com.lanhai.service.ISurvHisdataVocsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanhai.service.ISurvStationInfoService;
import com.lanhai.util.BigDecimalRandomAdjuster;
import com.lanhai.util.DateTimeConverter;
import com.lanhai.util.DateTimeUtils;
import com.lanhai.util.TUtil;
import com.xxl.job.core.context.XxlJobHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* <p>
* 恶臭历史数据 服务实现类
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Service
@Slf4j
public class SurvHisdataVocsServiceImpl extends ServiceImpl<SurvHisdataVocsMapper, SurvHisdataVocs> implements ISurvHisdataVocsService {
@Lazy
@Autowired
private SurvTransdataVocsServiceImpl vocsService;
@Lazy
@Autowired
private ISurvStationInfoService survStationInfoService;
@Override
public SurvTransdataVocs genDataAuto(SurvDeviceDeploy deploy, DataExamineDetail config) {
if(deploy!=null && config!=null) {
if (config.getRules() != null && !config.getRules().isEmpty()) {
String deployCode = deploy.getDeployCode();
try {
SurvTransdataVocs newestData = vocsService.getOneByDeviceId(deploy.getId());
String orgId = null;
if (newestData != null) {
orgId = newestData.getId();
if (newestData.getDataDateTime() != null) {
log.error(newestData.getDataDateTime()+"====================时间检查=============="+new Date());
long secs = DateTimeUtils.getSecondsDiff(newestData.getDataDateTime(), LocalDateTime.now());
if (secs < config.getExamineGap()) {//间隔不足时不生成
log.warn("-------------恶臭设备:{}:{},恶臭间隔为:{}秒,限制时间:{}秒,跳过--------------", deploy.getDeployDes(),deploy.getDeployCode(),secs,config.getExamineGap());
XxlJobHelper.log("--------------恶臭设备:{}:{},恶臭间隔为:{}秒,,限制时间:{}秒,跳过---------------", deploy.getDeployDes(),deploy.getDeployCode(),secs,config.getExamineGap());
return null;
}
}
}
Map<String, DataExamineRule> ruleMap = new HashMap<>();
for (DataExamineRule rule : config.getRules()) {
ruleMap.put(rule.getFields(), rule);
}
SurvHisdataVocs saveEnt = new SurvHisdataVocs();
if (newestData == null) {
newestData = new SurvTransdataVocs();
SurvHisdataVocs hisData = getRecentData(deployCode,config.getHistoryRange());
if(hisData!=null){ //第一逻辑如果有最近的历史数据则使用历史数据作为基准值
XxlJobHelper.log("=====恶臭设备:{}===查询到历史数据,使用历史数据作为基准值==========",deployCode);
BeanUtil.copyProperties(hisData,newestData);
saveEnt.setRuleType(IotConstants.RULE_HISTORY);
}else{//第二逻辑使用预设的标准值
XxlJobHelper.log("=====恶臭设备:{}===使用预设标准值进行生成==========",deployCode);
for (String s : ruleMap.keySet()) {
TUtil.setFieldValue(newestData, s, ruleMap.get(s).getStandard());
}
saveEnt.setRuleType(IotConstants.RULE_PRE);
}
}else{
long dateGap = DateTimeUtils.getDaysDiff(newestData.getDataDateTime(), LocalDateTime.now());
XxlJobHelper.log("======恶臭设备:{}-{}=====恶臭水数据间隔{}天===限制天数:{}====",deploy.getDeployDes(),deploy.getDeployCode(),dateGap,config.getHistoryRange());
if (dateGap > config.getHistoryRange()) {//最新数据已经超过时限范围则使用预设数据
XxlJobHelper.log("xxxx恶臭使用预设数据xxxxx");
for (String s : ruleMap.keySet()) {
TUtil.setFieldValue(newestData, s, ruleMap.get(s).getStandard());
}
saveEnt.setRuleType(IotConstants.RULE_PRE);
}else{
XxlJobHelper.log("xxxx恶臭使用原数据规则类型:{}xxxxx",newestData.getRuleType());
saveEnt.setRuleType(newestData.getRuleType());
}
}
LocalDateTime nowTime = LocalDateTime.now();
saveEnt.setDeployId(deploy.getId());
saveEnt.setDataDateTime(nowTime);
saveEnt.setDataGatherType(IotConstants.MARK_GENDATA);
if(StringUtils.isNotBlank(deploy.getStationCode())){
SurvStationInfo info = survStationInfoService.getByCode(deploy.getStationCode());
if(info!=null){
saveEnt.setStationName(info.getStationName());
saveEnt.setStationId(info.getId());
}
}
saveEnt.setDeployId(deploy.getId());
saveEnt.setStationCode(deploy.getStationCode());
saveEnt.setDeployCode(deploy.getDeployCode());
saveEnt.setDeviceName(deploy.getDeployDes());
saveEnt.setTenantId(deploy.getTenantId());
saveEnt.setTransDate(nowTime);
saveEnt.setReVision(0);
saveEnt.setCreatedBy("ftaskg");
saveEnt.setCreateTime(nowTime);
saveEnt.setUpdatedBy("ftaskg");
saveEnt.setIsDel(0);
saveEnt.setUpdatedTime(nowTime);
//生成数据
for (String key : ruleMap.keySet()) {
DataExamineRule rule = ruleMap.get(key);
String vals = TUtil.getFieldValue(newestData, rule.getFields(), String.class);
if (StringUtils.isNotBlank(vals)) {
BigDecimal fixedRange = new BigDecimal(rule.getFactor());
int scale = rule.getScale();//小数位
String correctVal = BigDecimalRandomAdjuster.randomAdjustByFixedRange(new BigDecimal(vals), fixedRange, scale);
if(correctVal.contains("-") || "0".equals(correctVal)){//如果是负数或0用原来的值
correctVal = vals;
}
TUtil.setFieldValue(saveEnt, rule.getFields(), correctVal);
} else {
log.error("==========恶臭设备:{},编号:{}指标:{}配置错误==============,跳过", deploy.getDeployDes(), deploy.getDeployCode(), rule.getFields());
XxlJobHelper.log("==========恶臭设备:{},编号:{}指标:{}配置错误==============,跳过", deploy.getDeployDes(), deploy.getDeployCode(), rule.getFields());
}
}
save(saveEnt);
BeanUtil.copyProperties(saveEnt, newestData);
newestData.setId(orgId);
newestData.setTenantId(deploy.getTenantId());
newestData.setDataDateTime(nowTime);
newestData.setRuleType(newestData.getRuleType());
newestData.setDataGatherType(newestData.getDataGatherType());
vocsService.saveOrUpdate(newestData);
}catch (Exception e) {
e.printStackTrace();
XxlJobHelper.log(e.getMessage());
log.error(e.getMessage());
}
}
}
return null;
}
private SurvHisdataVocs getRecentData(String deployCode,Integer dayRange) {
LocalDateTime daysAgo = LocalDateTime.now().minusDays(dayRange);
SurvHisdataVocs oldVoc = lambdaQuery()
.eq(SurvHisdataVocs::getDeployCode,deployCode)
.ge(SurvHisdataVocs::getDataDateTime, DateTimeConverter.toDate(daysAgo))
.orderByDesc(SurvHisdataVocs::getDataDateTime)
.last("limit 1")
.one();
return oldVoc;
}
}

View File

@ -0,0 +1,20 @@
package com.lanhai.service.Impl;
import com.lanhai.entity.SurvTransdataVocsMin;
import com.lanhai.mapper.SurvTransdataVocsMinMapper;
import com.lanhai.service.ISurvTransdataVocsMinService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 恶臭分钟数据 服务实现类
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Service
public class SurvTransdataVocsMinServiceImpl extends ServiceImpl<SurvTransdataVocsMinMapper, SurvTransdataVocsMin> implements ISurvTransdataVocsMinService {
}

View File

@ -0,0 +1,29 @@
package com.lanhai.service.Impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lanhai.entity.SurvTransdataSoil;
import com.lanhai.entity.SurvTransdataVocs;
import com.lanhai.mapper.SurvTransdataVocsMapper;
import com.lanhai.service.ISurvTransdataVocsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 恶臭实时数据 服务实现类
* </p>
*
* @author ${author}
* @since 2026-07-21
*/
@Service
public class SurvTransdataVocsServiceImpl extends ServiceImpl<SurvTransdataVocsMapper, SurvTransdataVocs> implements ISurvTransdataVocsService {
@Override
public SurvTransdataVocs getOneByDeviceId(String deployId) {
LambdaQueryWrapper<SurvTransdataVocs> queryWrapper = new LambdaQueryWrapper<SurvTransdataVocs>();
queryWrapper.eq(SurvTransdataVocs::getDeployId,deployId).last("limit 1");
return getOne(queryWrapper);
}
}

View File

@ -14,8 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
@ -30,16 +32,16 @@ public class DataExamineTask {
private ISurvDeviceDeployService deployService; private ISurvDeviceDeployService deployService;
@Autowired @Autowired
private ISurvHisdataOrientwaterService historyOrientwaterService; private ISurvHisdataOrientwaterService historyOrientwaterService;
@Autowired
private ISurvTransdataOrientwaterService orientWaterService;
@Autowired @Autowired
private ISurvHisdataLivestockwaterService historyLiveWaterService; private ISurvHisdataLivestockwaterService historyLiveWaterService;
@Autowired
private ISurvTransdataLivestockwaterService livestockWaterService;
@Autowired @Autowired
private ISurvTaskConfigService taskConfigService; private ISurvTaskConfigService taskConfigService;
@Autowired @Autowired
private ISurvHisdataSoilService soilService; private ISurvHisdataSoilService soilService;
@Autowired
private ISurvHisdataVocsService vocsService;
@XxlJob("DataExamineGather") @XxlJob("DataExamineGather")
public void TaskHandler() throws Exception{ public void TaskHandler() throws Exception{
@ -58,6 +60,7 @@ public class DataExamineTask {
XxlJobHelper.log("配置有误1"); XxlJobHelper.log("配置有误1");
return; return;
} }
List<SurvDeviceDeploy> updDeploy = new ArrayList<>();
for (DataExamineDetail config : dataExamineConfig.getConfigs()) { for (DataExamineDetail config : dataExamineConfig.getConfigs()) {
if(config.getDeployId()==null || config.getDeployId().isEmpty()){ if(config.getDeployId()==null || config.getDeployId().isEmpty()){
XxlJobHelper.log("设备未配置"); XxlJobHelper.log("设备未配置");
@ -80,43 +83,60 @@ public class DataExamineTask {
if(deploy.getDeployType().equals(PollutionConstants.WATER_LIVE)){ if(deploy.getDeployType().equals(PollutionConstants.WATER_LIVE)){
SurvTransdataLivestockwater survTransdataLivestockwater = historyLiveWaterService.genDataAuto(deploy,config); SurvTransdataLivestockwater survTransdataLivestockwater = historyLiveWaterService.genDataAuto(deploy,config);
if(survTransdataLivestockwater!=null){ if(survTransdataLivestockwater!=null){
log.error("----------new设备号:{},生成成功,时间:{}-----------",deploy.getDeployCode(),sdf.format(survTransdataLivestockwater.getDataDateTime())); updDeploy.add(deploy);
log.error("----------new设备号1:{},生成成功,时间:{}-----------",deploy.getDeployCode(),sdf.format(survTransdataLivestockwater.getDataDateTime()));
}else{ }else{
log.error("----------new设备号:{},跳过------------",deploy.getDeployCode()); log.error("----------new设备号1:{},跳过------------",deploy.getDeployCode());
} }
} else if (deploy.getDeployType().equals(PollutionConstants.WATER_ORIENT)) { } else if (deploy.getDeployType().equals(PollutionConstants.WATER_ORIENT)) {
SurvTransdataOrientwater survTransdataOrientwater = historyOrientwaterService.genDataAuto(deploy,config); SurvTransdataOrientwater survTransdataOrientwater = historyOrientwaterService.genDataAuto(deploy,config);
if(survTransdataOrientwater!=null){ if(survTransdataOrientwater!=null){
log.error("----------new设备号:{},生成成功,时间:{}-----------",deploy.getDeployCode(),sdf.format(survTransdataOrientwater.getDataDateTime())); updDeploy.add(deploy);
log.error("----------new设备号2:{},生成成功,时间:{}-----------",deploy.getDeployCode(),sdf.format(survTransdataOrientwater.getDataDateTime()));
}else{ }else{
log.error("----------new设备号:{},跳过------------",deploy.getDeployCode()); log.error("----------new设备号2:{},跳过------------",deploy.getDeployCode());
} }
}else if (deploy.getDeployType().equals(PollutionConstants.WATER_QULITY)) { }else if (deploy.getDeployType().equals(PollutionConstants.WATER_QULITY)) {
SurvTransdataSoil soil = soilService.genDataAuto(deploy,config); SurvTransdataSoil soil = soilService.genDataAuto(deploy,config);
if(soil!=null){ if(soil!=null){
log.error("----------new设备号:{},生成成功,时间:{}-----------",deploy.getDeployCode(),sdf.format(soil.getDataDateTime())); updDeploy.add(deploy);
log.error("----------new设备号3:{},生成成功,时间:{}-----------",deploy.getDeployCode(),sdf.format(soil.getDataDateTime()));
}else{ }else{
log.error("----------new设备号:{},跳过------------",deploy.getDeployCode()); log.error("----------new设备号3:{},跳过------------",deploy.getDeployCode());
}
}else if (deploy.getDeployType().equals(PollutionConstants.STINK)) {//恶臭设备
SurvTransdataVocs vocs = vocsService.genDataAuto(deploy,config);
if(vocs!=null){
updDeploy.add(deploy);
log.error("----------new设备号4:{},生成成功,时间:{}-----------",deploy.getDeployCode(),sdf.format(vocs.getDataDateTime()));
}else{
log.error("----------new设备号4:{},跳过------------",deploy.getDeployCode());
} }
} }
} }
} }
if(!updDeploy.isEmpty()){
List<SurvDeviceDeploy> upds = new ArrayList<>();
for (SurvDeviceDeploy survDeviceDeploy : updDeploy) {
SurvDeviceDeploy ents = new SurvDeviceDeploy();
ents.setId(survDeviceDeploy.getId());
ents.setLastsyncTime(new Date());
upds.add(ents);
}
if(!upds.isEmpty()){
deployService.updateBatchById(upds);
}
}
log.warn("=============更新设备上次同步时间数量:{}==============",updDeploy.size());
XxlJobHelper.log("=============更新设备上次同步时间数量:{}==============",updDeploy.size());
}else { }else {
XxlJobHelper.log("未配置任务执行设置"); XxlJobHelper.log("未配置任务执行设置");
} }
List<String> deviceType = new ArrayList<String>();
deviceType.add(PollutionConstants.WATER_LIVE);
deviceType.add(PollutionConstants.WATER_ORIENT);
//获取所有设备
List<SurvDeviceDeploy> deployList = deployService
.lambdaQuery()
.in(SurvDeviceDeploy::getDeployType,deviceType)
.eq(SurvDeviceDeploy::getRunStatus,0)
.list();
log.warn("=============new查询到设备数量:{}==============",deployList.size());
} catch (Exception e) { } catch (Exception e) {