This commit is contained in:
sxu 2024-11-04 13:30:42 +08:00
parent 574a5fe3e3
commit 5a4dadcb1d
31 changed files with 2509 additions and 0 deletions

134
bonus-modules/data/pom.xml Normal file
View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bonus</groupId>
<artifactId>bonus</artifactId>
<version>24.10.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.bonus</groupId>
<artifactId>data</artifactId>
<description>
bonus-modules-data数据模块
</description>
<!-- <properties>-->
<!-- <maven.compiler.source>17</maven.compiler.source>-->
<!-- <maven.compiler.target>17</maven.compiler.target>-->
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
<!-- </properties>-->
<dependencies>
<!--加密依赖包-->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>${jasypt-spring-boot-starter.version}</version>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- bonus Common DataSource -->
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-datasource</artifactId>
</dependency>
<!-- bonus Common DataScope -->
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-datascope</artifactId>
</dependency>
<!-- bonus Common Log -->
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-log</artifactId>
</dependency>
<!-- bonus Common Swagger -->
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>com.bonus</groupId>
<artifactId>bonus-common-biz</artifactId>
<version>24.10.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,35 @@
package com.bonus.data;
import com.bonus.common.security.annotation.EnableCustomConfig;
import com.bonus.common.security.annotation.EnableRyFeignClients;
import com.bonus.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
* 系统模块
*
* @author bonus
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class DataApplication
{
public static void main(String[] args)
{
SpringApplication.run(DataApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 基础模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}

View File

@ -0,0 +1,42 @@
package com.bonus.data.config;
import com.bonus.data.service.WatherWarnService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import javax.annotation.PostConstruct;
/**
* 系统定时任务处理器
* @author 黑子
*/
@Slf4j
@EnableScheduling
@Configuration
public class SystemScheduleConfig {
@Autowired
WatherWarnService service;
/**
* 自动获取预警数据
*/
@Scheduled(cron = "0 0/30 * * * ?")
@PostConstruct
private void updateWeather(){
service.getCityWather();
}
/**
* 自动更新边带状态
*/
@Scheduled(cron = "0 0/10 * * * ?")
private void updateBdStatus(){
service.updateBdStatus();
}
}

View File

@ -0,0 +1,114 @@
package com.bonus.data.controller;
import com.alibaba.fastjson2.JSONObject;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.data.entity.*;
import com.bonus.data.service.DataCenterService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 边带记录设备表(tb_bd_device_record)表控制层
*
* @author ma_sh
*/
@RestController
@RequestMapping("/data")
@Slf4j
public class DataCenterController extends BaseController {
@Autowired
private DataCenterService service;
/**
* 设备数据同步
* @return
*/
@PostMapping("/uploadDevStatus")
public AjaxResult uploadDevStatus(@RequestBody String obj){
try{
return service.uploadDevStatus(obj);
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error("数据解析异常");
}
/**
* 传感器数据同步
* @return
*/
@PostMapping("/uploadCgqData")
public AjaxResult uploadCgqData(@RequestBody String obj){
return service.uploadCgqData(obj);
}
/**
* 基础沉降上报数据
* @return
*/
@PostMapping("/uploadCjData")
public AjaxResult uploadCjData(@RequestBody String obj){
return service.uploadCjData(obj);
}
/**
* 室外环境检测 上报数据
* @return
*/
@PostMapping("/uploadSwHjData")
public AjaxResult uploadSwHjData(@RequestBody String obj){
return service.uploadSwHjData(obj);
}
/**
* 有限空间 数据上报
* @param obj
* @return
*/
@PostMapping("/uploadYxkjData")
public AjaxResult uploadYxkjData(@RequestBody String obj){
return service.uploadYxkjData(obj);
}
/**
* 拉力传感器-数据上报
* @param obj
* @return
*/
@PostMapping("/uploadLlCgqData")
public AjaxResult uploadLlCgqData(@RequestBody String obj){
return service.uploadLlCgqData(obj);
}
/**
* 智能手环数据上报
* @param obj
* @return
*/
@PostMapping("/uploadZnshData")
public AjaxResult uploadZnshData(@RequestBody String obj){
return service.uploadZnshData(obj);
}
/**
* 安全帽数据上报
* @param obj 设备数据
*/
@PostMapping("/uploadSafetyHatData")
public AjaxResult uploadSafetyHatData(@RequestBody String obj){
return service.uploadSafetyHatData(obj);
}
}

View File

@ -0,0 +1,60 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* 传感器数据
* @author 黑子
*/
@Data
public class CgqInfoDataVo {
/**
* id
*/
private String id;
/**
* 电量
*/
private String capacity;
/**
* 电池告警阈值
*/
private String alarmThreshold;
/**
* angle_x
*/
private String angleX;
/**
* 角度 Y
*/
private String angleY;
private String angleZ;
/**
* 端设备出厂标识
*/
private String nodeId;
/**
* 平台注册端设备主键
*/
private String deviceId;
/**
* 设备模型
*/
private String model;
/**
* 服务id
*/
private String serviceId;
/**
* 数据采集时间
*/
private String dataTime;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,54 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* 沉降数据解析实体类
* @author 黑子
*/
@Data
public class CjDataVo {
private String id;
/**
* 当前测量值单位:mm
*/
private String subsideData;
/**
* 实时变化值单位:mm
*/
private String realSubsideData;
/**
* 累加值 单位:mm
*/
private String accSubsideData;
/**
* 混凝土基础沉降单位:mm
*/
private String settlementFoundation;
/**
* 是否混凝土默认0 不是1 是混凝土
*/
private String isConcrete;
/**
* 端设备出厂标识
*/
private String nodeId;
/**
* 设备id
*/
private String deviceId;
/**
* 模型id
*/
private String model;
/**
* 服务id
*/
private String serviceId;
private String dataTime;
private String remark;
}

View File

@ -0,0 +1,79 @@
package com.bonus.data.entity;
import com.bonus.common.core.utils.DateUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
//import static com.oracle.jrockit.jfr.ContentType.Timestamp;
/**
* @author 黑子
* 设备检测属性值
*/
@Data
@AllArgsConstructor
public class DevAttributeVo {
private String id;
private String devName;
private String devType;
private String devId;
private String jcName;
private String jcValue;
private String jcUnit;
private String relCode;
/**
* 是否告警
*/
private String isWarn;
/**
* 检测时间
*/
private String jcTime;
private String devJson;
private String attributeId;
private String mergerId;
public DevAttributeVo(String devId,String devJson,String devName,String devType, String jcName, String jcValue, String jcUnit, String relCode, String isWarn, String jcTime, String mergerId) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long timestamp = Long.parseLong(jcTime);
Date date = new Date(timestamp);
String formattedDate = sdf.format(date);
this.devId = devId;
this.devJson = devJson;
this.devName = devName;
this.devType = devType;
this.jcName = jcName;
this.jcValue = jcValue;
this.jcUnit = jcUnit;
this.relCode = relCode;
this.isWarn = isWarn;
this.jcTime = formattedDate;
this.mergerId = mergerId;
}
public DevAttributeVo(String devId,String devName,String devType, String jcName, String jcValue, String isWarn, String jcTime) {
this.devId = devId;
this.devName = devName;
this.devType = devType;
this.jcName = jcName;
this.jcValue = jcValue;
this.isWarn = isWarn;
this.jcTime = jcTime;
}
}

View File

@ -0,0 +1,87 @@
package com.bonus.data.entity;
import lombok.Data;
import java.io.Serializable;
/**
* 设备基础信息
* @author 黑子
*/
@Data
public class DevInfoVo implements Serializable {
/**
* 边带id
*/
private String bdId;
/**
* 级联编码
*/
private String relType;
/**
* 设备id
*/
private String id;
/**
* 设备编码
*/
private String deviceCode;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备类型
*/
private String deviceType;
/**
* 工程名称
*/
private String deviceProjectName;
/**
* 设备工程编码
*/
private String deviceProjectCode;
/**
* 设备负责人
*/
private String deviceFuzeren;
/**
* 设备绑定状态1 绑定0 未绑定
*/
private String bangdingState;
/**
* 设备在线状态1在线0离线
*/
private String deviceOnlineState;
/**
* 设备故障状态1故障0正常
*/
private String deviceFailureState;
/**
* 设备告警状态1告警0正常
*/
private String deviceAlarmState;
/**
* 设备出场日期
*/
private String deviceManuDate;
/**
* 设备厂商
*/
private String deviceFactory;
/**
* 更新时间
*/
private String updateTime;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,22 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* 设备实体类
* @author 黑子
*/
@Data
public class DeviceVo {
private String devId;
private String devName;
private String devType;
private String proName;
private String proCode;
}

View File

@ -0,0 +1,50 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* 拉力传感器
* @author 黑子
*/
@Data
public class LlgcqDataVo {
private String id;
/**
* 电量
*/
private String capacity;
/**
* 告警阈值
*/
private String alarmThreshold;
/**
* 拉力
*/
private String tractionData;
/**
* 端设备出厂标识
*/
private String nodeId;
/**
* 平台注册端设备主键
*/
private String deviceId;
/**
* 设备模型
*/
private String model;
/**
* 服务 ID
*/
private String serviceId;
/**
* 数据监测时间
*/
private String dataTime;
private String remark;
}

View File

@ -0,0 +1,54 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.data.entity
* @CreateTime: 2024-09-23 17:41
* @Description: 安全帽监测数据
*/
@Data
public class SafetyHatVo {
private String id;
// 设备编码
private String deviceCode;
// 经度
private String lon;
// 纬度
private String lat;
/**
* 海拔高度
*/
private String altitude;
/**
* 端设备出厂标识
*/
private String nodeId;
/**
* 平台注册端设备主键
*/
private String deviceId;
/**
* 设备模型
*/
private String model;
/**
* 服务 ID
*/
private String serviceId;
/**
* 数据监测时间
*/
private String dataTime;
private String remark;
}

View File

@ -0,0 +1,83 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* @author 黑子
* 室外环境 数据
*/
@Data
public class SwhjDataVo {
private String id;
/**
* 0.5µm 粒子数个单位:/m³
*/
private String grain05;
/**
* 1.0µm 粒子数单位:/m³
*/
private String grain10;
/**
* 5.0µm 粒子数单位:/m³
*/
private String grain50;
/**
* PM25 单位:μg/m3
*/
private String pm25;
/**
* PM10 单位:μg/m3
*/
private String pm10;
/**
* 风向
*/
private String windDirection;
/**
* 风速 单位:m/s
*/
private String windForce;
/**
* 温度
*/
private String airTemperature;
/**
* 湿度 单位:%rh
*/
private String humidity;
/**
* 微正压 单位:Pa
*/
private String positivePressure;
/**
* 端设备出厂标识
*/
private String nodeId;
/**
* 平台注册端设备主键
*/
private String deviceId;
/**
* 设备模型
*/
private String model;
/**
* 服务 ID
*/
private String serviceId;
/**
* 噪声
*/
private String noise;
/**
* 数据监测时间
*/
private String dataTime;
private String remark;
}

View File

@ -0,0 +1,115 @@
package com.bonus.data.entity;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
*系统 预警配置数据
* @author 黑子
*/
@Data
public class WarnConfigVo implements Serializable {
/**
* 主键
*/
private Long id;
/**
* 类型(来源码表-设备类型)
*/
private Integer configuType;
/**
* 类型(来源码表-设备类型)
*/
private String typeName;
/**
* 配置名称
*/
private String configName;
/**
* 阈值1-max
*/
private BigDecimal configVal1Max;
/**
* 阈值1-min
*/
private BigDecimal configVal1Min;
/**
*
*/
private String configVal1Str;
/**
* 阈值2-max
*/
private BigDecimal configVal2Max;
/**
* 阈值2-min
*/
private BigDecimal configVal2Min;
private String configVal2Str;
private BigDecimal configVal3Max;
private BigDecimal configVal3Min;
private String configVal3Str;
private BigDecimal configVal4Max;
private BigDecimal configVal4Min;
private String configVal4Str;
private BigDecimal configVal5Max;
private BigDecimal configVal5Min;
private String configVal5Str;
private BigDecimal configVal6Max;
private BigDecimal configVal6Min;
private String configVal6Str;
private Integer delFlag;
private Date createTime;
private Integer createUser;
private Date updateTime;
private Integer updateUser;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,36 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* 系统设备告警表
* @author 黑子
*/
@Data
public class WarnVo {
private String id;
private String warnTime;
private String warnContent;
private String warnType;
private String devId;
private String proId;
private String proCode;
private String remarks;
public WarnVo(String warnTime, String warnContent, String warnType, String devId, String proCode, String remarks) {
this.warnTime = warnTime;
this.warnContent = warnContent;
this.warnType = warnType;
this.devId = devId;
this.proCode = proCode;
this.remarks = remarks;
}
}

View File

@ -0,0 +1,39 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* 天气预警实体类
* @author 黑子
*/
@Data
public class WatherVo {
private String city;
private String createTime;
private String content;
private String type;
private String level;
private String province;
private String day;
public WatherVo(String city, String createTime, String content, String type, String level, String province, String day) {
this.city = city;
this.createTime = createTime;
this.content = content;
this.type = type;
this.level = level;
this.province = province;
this.day = day;
}
}

View File

@ -0,0 +1,58 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* 有限空间 实体类
* @author 黑子
*/
@Data
public class YxkjDataVo {
/**
* 含氧量
*/
private String oxygen;
/**
* 一氧化碳
*/
private String carbonMonoxide;
/**
* 可燃气体
*/
private String combustible;
/**
* 硫化氢
*/
private String hydrothion;
/**
* 硫化氢
*/
private String nodeId;
/**
* 设备id
*/
private String deviceId;
/**
* 模块
*/
private String model;
/**
* 服务id
*/
private String serviceId;
/**
* 时间
*/
private String dataTime;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,86 @@
package com.bonus.data.entity;
import lombok.Data;
/**
* 智能手环实体类
* @author 黑子
*/
@Data
public class ZnshDataVo {
private String id;
/**
* 相对坐标-x
*
*/
private String posX;
/**
* 相对坐标-y
*
*/
private String posY;
/**
* 经度
*/
private String latitude;
/**
* 维度
*/
private String longitude;
/**
* 心率值
*/
private String heartRateValue;
/**
* 血氧值
*/
private String bloodOxygenValue;
/**
* 血压值
*/
private String bloodPressureValue;
/**
* 体温值
*/
private String bodyTempValue;
/**
* pressure
*/
private String pressure;
/**
* 海拔
*/
private String altitude;
/**
*绑定人S
*/
private String idCard;
/**
* 人员名称
*/
private String personName;
/**
* 端设备出厂标识
*/
private String nodeId;
/**
* 平台注册端设备主键
*/
private String deviceId;
/**
* 设备模型
*/
private String model;
/**
* 服务 ID
*/
private String serviceId;
/**
* 数据监测时间
*/
private String dataTime;
private String remark;
}

View File

@ -0,0 +1,109 @@
package com.bonus.data.mapper;
import com.bonus.data.entity.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author 黑子
* 数据中心 接口层
*/
@Repository
public interface DataCenterMapper {
/**
* 查询级联设备id
* @param vo
* @return
*/
int getDevInfoNum(DevInfoVo vo);
/**
*更新设备数据
* @param vo
* @return
*/
int updateDevInfo(DevInfoVo vo);
/**
* 新增设备数据
* @param vo
* @return
*/
int insertDevInfo(DevInfoVo vo);
/**
* 查询系统设备id
* @param relId
* @param bdId
* @return
*/
DeviceVo getDevInfoId(@Param("relId") String relId,@Param("bdId") String bdId);
/**
* 依据设备id 及级联编码 拆线呢检测数据
* @param vo
* @return
*/
String getAttribute(DevAttributeVo vo);
/**
* 更新数据
* @param vo
*/
void updateAttribute(DevAttributeVo vo);
/**
* 查询 数据
* @param vo
*/
void insertAttribute(DevAttributeVo vo);
/**
* 依据设备id 查询设备告警配置
* @param devId
* @return
*/
WarnConfigVo getDevWarnConfig(@Param("devId") String devId);
/**
* 插入数据记录
* @param vo
*/
void insertRecordData(DevAttributeVo vo);
/**
* 更新设备采集数据值
* @param devId
* @param devJson
*/
void updateDevData(@Param("devId") String devId, @Param("devJson") String devJson);
/**
* 通过边带编码 查询设备边带id
* @param edgeId
* @return
*/
String getDevBdData(@Param("edgeId") String edgeId);
/**
* 查询本系统设备类型
* @param vo
* @return
*/
Integer getDevTypeId(DevInfoVo vo);
/**
* 新增告警数据
* @param vo
*/
void insertWarn(WarnVo vo);
/**
* 更新边带状态
* @param bdId
*/
void updateBdStatus(@Param("bdId") String bdId);
}

View File

@ -0,0 +1,30 @@
package com.bonus.data.mapper;
import com.bonus.data.entity.WatherVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
/**
* 天气接口处理
* @author 黑子
*/
@Repository
public interface WatherMapper {
/**
* 删除当天数据
* @param day
*/
void delWatherWrn(@Param("day") String day);
/**
*更新数据
* @param date
*/
void replaceWather(WatherVo date);
/**
* 更新边带状态
*/
void updateBdStatus();
}

View File

@ -0,0 +1,67 @@
package com.bonus.data.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.data.entity.*;
import java.util.List;
/**
* @author 黑子
*/
public interface DataCenterService {
/**
* 设备基础信息上传
* @param obj
* @return
*/
AjaxResult uploadDevStatus(String obj);
/**
* 传感器数据采集同步
* @param obj
* @return
*/
AjaxResult uploadCgqData(String obj);
/**
* 沉降数据采集
* @param obj
* @return
*/
AjaxResult uploadCjData(String obj);
/**
* 安全帽监测--数据采集
* @param obj
* @return
*/
AjaxResult uploadSafetyHatData(String obj);
/**
* 室外环境检测-数据采集
* @param obj
* @return
*/
AjaxResult uploadSwHjData(String obj);
/**
* 有限空间数据采集
* @param obj
* @return
*/
AjaxResult uploadYxkjData(String obj);
/**
* 拉力传感器 数据采集
* @param obj
* @return
*/
AjaxResult uploadLlCgqData(String obj);
/**
* 智能手环数据采集
* @param obj
* @return
*/
AjaxResult uploadZnshData(String obj);
}

View File

@ -0,0 +1,698 @@
package com.bonus.data.service;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.nacos.common.utils.UuidUtils;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.data.entity.*;
import com.bonus.data.mapper.DataCenterMapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
/**
* @author 黑子
* 数据中心处理曾
*/
@Service
@Slf4j
public class DataCenterServiceImpl implements DataCenterService{
@Autowired
private DataCenterMapper mapper;
@Override
public AjaxResult uploadDevStatus(String obj) {
AtomicReference<String> msg= new AtomicReference<>("数据上传成功!");
try{
JSONObject jsonObject = JSONObject.parseObject(obj);
Object edgeId=jsonObject.get("edgeId");
log.info("设备数据数据-->{}",obj);
List<DevInfoVo> list = jsonObject.getList("list",DevInfoVo.class);
if(ObjectUtils.isNotEmpty(edgeId)){
String bdId = mapper.getDevBdData(edgeId.toString());
if(StringUtils.isNotEmpty(bdId)){
if (StringUtils.isNotEmpty(list)) {
mapper.updateBdStatus(bdId);
list.forEach(vo->{
vo.setBdId(bdId);
vo.setRelType(vo.getDeviceType());
Integer devType=mapper.getDevTypeId(vo);
if(devType!=null && devType!=0){
vo.setDeviceType(devType.toString());
}
int nums = mapper.getDevInfoNum(vo);
if (nums > 0) {
//是否更新
int num = mapper.updateDevInfo(vo);
if(num<1){
msg.set("存在数据更新失败!");
}
}else{
int num=mapper.insertDevInfo(vo);
if(num<1){
msg.set("设备上传失败,请联系管理员!");
}
}
});
}
}else{
msg.set("边带设备未注册!");
}
}
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.success(msg.get());
}
/**
* 传感器数据采集同步
* @param obj
* @return
*/
@Override
public AjaxResult uploadCgqData(String obj) {
AtomicReference<String> msg= new AtomicReference<>("数据上传成功!");
try{
JSONObject jsonObject = JSONObject.parseObject(obj);
log.info("传感器数据-->{}",obj);
Object edgeId=jsonObject.get("edgeId");
String bdId;
if(ObjectUtils.isNotEmpty(edgeId)){
bdId=edgeId.toString();
} else {
bdId = "999";
}
List<CgqInfoDataVo> list = jsonObject.getList("list",CgqInfoDataVo.class);
ObjectMapper objectMapper=new ObjectMapper();
List<DevAttributeVo> attributeVos=new ArrayList<>();
if (StringUtils.isNotEmpty(list)) {
list.forEach(vo->{
//先找到系统设备id
DeviceVo deviceVo=mapper.getDevInfoId(vo.getDeviceId(),bdId);
if(ObjectUtils.isNotEmpty(deviceVo) && StringUtils.isNotEmpty(deviceVo.getDevId())){
mapper.updateBdStatus(bdId);
String json="";
try {
json = objectMapper.writeValueAsString(vo);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
String devId= deviceVo.getDevId();
log.info("设备注册系统id---->{}",devId);
WarnConfigVo config=mapper.getDevWarnConfig(devId);
String mergerId= UuidUtils.generateUuid().toUpperCase().replaceAll("-","");
attributeVos.clear();
DevAttributeVo devAttributeVo=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"电池电量",vo.getCapacity(),"%","capacity","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo);
DevAttributeVo devAttributeVo2=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"角度X",vo.getAngleX(),"°","angle_x",isWarn(config,vo.getAngleX(),1,deviceVo,"角度X"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo2);
DevAttributeVo devAttributeVo3=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"角度Y",vo.getAngleY(),"°","angle_y",isWarn(config,vo.getAngleY(),1,deviceVo,"角度Y"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo3);
DevAttributeVo devAttributeVo4=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"角度Z",vo.getAngleZ(),"°","angle_z",isWarn(config,vo.getAngleZ(),1,deviceVo,"角度Z"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo4);
//更新/新增设备检测信息及记录
insertOrAddDevAttribute(attributeVos);
//更新设备采集数据json
mapper.updateDevData(devId,json);
}else{
log.info("设备未注册------>{}",vo.getDeviceId());
msg.set("设备未注册!");
}
});
}
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error(msg.get());
}
@Override
public AjaxResult uploadCjData(String obj) {
int code = 1;
try{
JSONObject jsonObject = JSONObject.parseObject(obj);
log.info("沉降数据-->{}",obj);
List<CjDataVo> list = jsonObject.getList("list",CjDataVo.class);
Object edgeId=jsonObject.get("edgeId");
String bdId;
if(ObjectUtils.isNotEmpty(edgeId)){
bdId=edgeId.toString();
} else {
bdId = "999";
}
ObjectMapper objectMapper=new ObjectMapper();
List<DevAttributeVo> attributeVos=new ArrayList<>();
if (StringUtils.isNotEmpty(list)) {
for (CjDataVo vo : list) {//先找到系统设备id
DeviceVo deviceVo = mapper.getDevInfoId(vo.getDeviceId(), bdId);
if (ObjectUtils.isNotEmpty(deviceVo) && StringUtils.isNotEmpty(deviceVo.getDevId())) {
mapper.updateBdStatus(bdId);
String json = "";
try {
json = objectMapper.writeValueAsString(vo);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
String devId = deviceVo.getDevId();
log.info("设备注册系统id---->{}", devId);
// WarnConfigVo config=mapper.getDevWarnConfig(devId);
String mergerId = UuidUtils.generateUuid().toUpperCase().replaceAll("-", "");
attributeVos.clear();
DevAttributeVo devAttributeVo = new DevAttributeVo(devId, json, deviceVo.getDevName(), deviceVo.getDevType(), "测量值", vo.getSubsideData(), "mm", "subside_data", "0", vo.getDataTime(), mergerId);
attributeVos.add(devAttributeVo);
DevAttributeVo devAttributeVo2 = new DevAttributeVo(devId, json, deviceVo.getDevName(), deviceVo.getDevType(), "变化值", vo.getRealSubsideData(), "mm", "real_subside_data", "0", vo.getDataTime(), mergerId);
attributeVos.add(devAttributeVo2);
DevAttributeVo devAttributeVo3 = new DevAttributeVo(devId, json, deviceVo.getDevName(), deviceVo.getDevType(), "累加值", vo.getAccSubsideData(), "mm", "acc_subside_data", "0", vo.getDataTime(), mergerId);
attributeVos.add(devAttributeVo3);
DevAttributeVo devAttributeVo4 = new DevAttributeVo(devId, json, deviceVo.getDevName(), deviceVo.getDevType(), "基础沉降", vo.getSettlementFoundation(), "mm", "settlement_foundation", "0", vo.getDataTime(), mergerId);
attributeVos.add(devAttributeVo4);
//更新/新增设备检测信息及记录
insertOrAddDevAttribute(attributeVos);
//更新设备采集数据json
mapper.updateDevData(devId, json);
} else {
log.info("设备未注册------>{}", vo.getDeviceId());
code = 0;
}
}
}
}catch (Exception e){
log.error(e.toString(),e);
}
return code == 1 ? AjaxResult.success("设备上传成功") : AjaxResult.error("设备未注册");
}
/**
* 安全帽监测--数据采集
*
* @param obj
* @return
*/
@Override
public AjaxResult uploadSafetyHatData(String obj) {
AtomicReference<String> msg= new AtomicReference<>("数据上传成功!");
try {
JSONObject jsonObject = JSONObject.parseObject(obj);
log.info("安全帽感知设备数据-->{}",obj);
List<SafetyHatVo> list = jsonObject.getList("list",SafetyHatVo.class);
ObjectMapper objectMapper = new ObjectMapper();
List<DevAttributeVo> safetyHatVos = new ArrayList<>();
Object edgeId = jsonObject.get("edgeId");
String bdId;
if (ObjectUtils.isNotEmpty(edgeId)){
bdId = edgeId.toString();
} else {
bdId = "99999";
}
if (StringUtils.isNotEmpty(list)) {
list.forEach(vo->{
//先找到系统设备id
DeviceVo deviceVo = mapper.getDevInfoId(vo.getDeviceId(),bdId);
if(ObjectUtils.isNotEmpty(deviceVo) && StringUtils.isNotEmpty(deviceVo.getDevId())){
mapper.updateBdStatus(bdId);
String json;
try {
json = objectMapper.writeValueAsString(vo);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
String devId = deviceVo.getDevId();
log.info("设备注册系统id---->{}",devId);
// WarnConfigVo config = mapper.getDevWarnConfig(devId);
String mergerId= UuidUtils.generateUuid().toUpperCase().replaceAll("-","");
safetyHatVos.clear();
DevAttributeVo devAttributeVo = new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"经度",vo.getLon(),"","hat_lon","0",vo.getDataTime(),mergerId);
safetyHatVos.add(devAttributeVo);
DevAttributeVo devAttributeVo2 = new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"纬度",vo.getLat(),"","hat_lat","0",vo.getDataTime(),mergerId);
safetyHatVos.add(devAttributeVo2);
//更新/新增设备检测信息及记录
insertOrAddDevAttribute(safetyHatVos);
mapper.updateDevData(devId,json);
}else{
log.info("设备未注册------>{}",vo.getDeviceId());
msg.set("设备未注册!");
}
});
}
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error(msg.get());
}
@Override
public AjaxResult uploadSwHjData(String obj) {
AtomicReference<String> msg= new AtomicReference<>("数据上传成功!");
try{
JSONObject jsonObject = JSONObject.parseObject(obj);
log.info("室外环境检测数据-->{}",obj);
List<SwhjDataVo> list = jsonObject.getList("list",SwhjDataVo.class);
ObjectMapper objectMapper=new ObjectMapper();
List<DevAttributeVo> attributeVos=new ArrayList<>();
Object edgeId=jsonObject.get("edgeId");
String bdId;
if(ObjectUtils.isNotEmpty(edgeId)){
bdId=edgeId.toString();
} else {
bdId = "999";
}
if (StringUtils.isNotEmpty(list)) {
list.forEach(vo->{
//先找到系统设备id
DeviceVo deviceVo=mapper.getDevInfoId(vo.getDeviceId(),bdId);
if(ObjectUtils.isNotEmpty(deviceVo) && StringUtils.isNotEmpty(deviceVo.getDevId())){
mapper.updateBdStatus(bdId);
String json="";
try {
json = objectMapper.writeValueAsString(vo);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
String devId= deviceVo.getDevId();
log.info("设备注册系统id---->{}",devId);
WarnConfigVo config=mapper.getDevWarnConfig(devId);
String mergerId= UuidUtils.generateUuid().toUpperCase().replaceAll("-","");
attributeVos.clear();
DevAttributeVo devAttributeVo=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"0.5µm粒子数个",vo.getGrain05(),"","grain_05","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo);
DevAttributeVo devAttributeVo2=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"1.0µm粒子数",vo.getGrain10(),"","grain_10","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo2);
DevAttributeVo devAttributeVo3=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"5.0µm粒子数",vo.getGrain50(),"","grain_50","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo3);
DevAttributeVo devAttributeVo4=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"pm2.5",vo.getPm25(),"μg/m3","pm25",isWarn(config,vo.getPm25(),2,deviceVo,"pm2.5"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo4);
DevAttributeVo devAttributeVo5=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"pm10",vo.getPm10(),"μg/m3","pm10",isWarn(config,vo.getPm10(),3,deviceVo,"pm10"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo5);
DevAttributeVo devAttributeVo6=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"噪声",vo.getNoise(),"db","noise",isWarn(config,vo.getNoise(),4,deviceVo,"噪声"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo6);
DevAttributeVo devAttributeVo7=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"风向",vo.getWindDirection(),"","wind_direction","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo7);
DevAttributeVo devAttributeVo8=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"风速",vo.getWindForce(),"m/s","wind_force","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo8);
DevAttributeVo devAttributeVo9=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"温度",vo.getAirTemperature(),"°C","air_Temperature",isWarn(config,vo.getAirTemperature(),5,deviceVo,"温度"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo9);
DevAttributeVo devAttributeVo10=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"湿度",vo.getHumidity(),"%rh","humidity",isWarn(config,vo.getHumidity(),6,deviceVo,"湿度"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo10);
DevAttributeVo devAttributeVo11=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"微正压",vo.getPositivePressure(),"Pa","positive_pressure","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo11);
//更新/新增设备检测信息及记录
insertOrAddDevAttribute(attributeVos);
//更新设备采集数据json
mapper.updateDevData(devId,json);
}else{
log.info("设备未注册------>{}",vo.getDeviceId());
msg.set("设备未注册!");
}
});
}
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error(msg.get());
}
@Override
public AjaxResult uploadYxkjData(String obj) {
AtomicReference<String> msg= new AtomicReference<>("数据上传成功!");
try{
JSONObject jsonObject = JSONObject.parseObject(obj);
log.info("有限空间数据-->{}",obj);
List<YxkjDataVo> list = jsonObject.getList("list",YxkjDataVo.class);
ObjectMapper objectMapper=new ObjectMapper();
List<DevAttributeVo> attributeVos=new ArrayList<>();
Object edgeId=jsonObject.get("edgeId");
String bdId;
if(ObjectUtils.isNotEmpty(edgeId)){
bdId=edgeId.toString();
} else {
bdId = "999";
}
if (StringUtils.isNotEmpty(list)) {
list.forEach(vo->{
//先找到系统设备id
DeviceVo deviceVo=mapper.getDevInfoId(vo.getDeviceId(),bdId);
if(ObjectUtils.isNotEmpty(deviceVo) && StringUtils.isNotEmpty(deviceVo.getDevId())){
mapper.updateBdStatus(bdId);
String json="";
try {
json = objectMapper.writeValueAsString(vo);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
String devId= deviceVo.getDevId();
log.info("设备注册系统id---->{}",devId);
WarnConfigVo config=mapper.getDevWarnConfig(devId);
String mergerId= UuidUtils.generateUuid().toUpperCase().replaceAll("-","");
attributeVos.clear();
DevAttributeVo devAttributeVo=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"含氧量",vo.getOxygen(),"%VOL","oxygen",isWarn(config,vo.getOxygen(),7,deviceVo,"含氧量"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo);
DevAttributeVo devAttributeVo2=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"一氧化碳",vo.getCarbonMonoxide(),"ppm","carbon_monoxide",isWarn(config,vo.getCarbonMonoxide(),8,deviceVo,"一氧化碳"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo2);
DevAttributeVo devAttributeVo3=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"可燃气体",vo.getCombustible(),"%LEL","combustible",isWarn(config,vo.getCombustible(),9,deviceVo,"可燃气体"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo3);
DevAttributeVo devAttributeVo4=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"硫化氢",vo.getHydrothion(),"ppm","hydrothion",isWarn(config,vo.getHydrothion(),10,deviceVo,"硫化氢"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo4);
//更新/新增设备检测信息及记录
insertOrAddDevAttribute(attributeVos);
mapper.updateDevData(devId,json);
}else{
log.info("设备未注册------>{}",vo.getDeviceId());
msg.set("设备未注册!");
}
});
}
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error(msg.get());
}
@Override
public AjaxResult uploadLlCgqData(String obj) {
AtomicReference<String> msg= new AtomicReference<>("数据上传成功!");
try{
JSONObject jsonObject = JSONObject.parseObject(obj);
log.info("拉力传感器数据-->{}",obj);
List<LlgcqDataVo> list = jsonObject.getList("list",LlgcqDataVo.class);
ObjectMapper objectMapper=new ObjectMapper();
List<DevAttributeVo> attributeVos=new ArrayList<>();
Object edgeId=jsonObject.get("edgeId");
String bdId;
if(ObjectUtils.isNotEmpty(edgeId)){
bdId=edgeId.toString();
} else {
bdId = "999";
}
if (StringUtils.isNotEmpty(list)) {
list.forEach(vo->{
//先找到系统设备id
DeviceVo deviceVo=mapper.getDevInfoId(vo.getDeviceId(),bdId);
if(ObjectUtils.isNotEmpty(deviceVo) && StringUtils.isNotEmpty(deviceVo.getDevId())){
mapper.updateBdStatus(bdId);
String json="";
try {
json = objectMapper.writeValueAsString(vo);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
String devId= deviceVo.getDevId();
log.info("设备注册系统id---->{}",devId);
WarnConfigVo config=mapper.getDevWarnConfig(devId);
String mergerId= UuidUtils.generateUuid().toUpperCase().replaceAll("-","");
attributeVos.clear();
DevAttributeVo devAttributeVo=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"电量",vo.getCapacity(),"%VOL","capacity","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo);
DevAttributeVo devAttributeVo2=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"拉力",vo.getTractionData(),"/KN","traction_data",isWarn(config,vo.getTractionData(),11,deviceVo,"拉力"),vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo2);
//更新/新增设备检测信息及记录
insertOrAddDevAttribute(attributeVos);
mapper.updateDevData(devId,json);
}else{
log.info("设备未注册------>{}",vo.getDeviceId());
msg.set("设备未注册!");
}
});
}
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error(msg.get());
}
@Override
public AjaxResult uploadZnshData(String obj) {
AtomicReference<String> msg= new AtomicReference<>("数据上传成功!");
try{
JSONObject jsonObject = JSONObject.parseObject(obj);
log.info("只能手环数据-->{}",obj);
List<ZnshDataVo> list = jsonObject.getList("list",ZnshDataVo.class);
ObjectMapper objectMapper=new ObjectMapper();
List<DevAttributeVo> attributeVos=new ArrayList<>();
Object edgeId=jsonObject.get("edgeId");
String bdId;
if(ObjectUtils.isNotEmpty(edgeId)){
bdId=edgeId.toString();
} else {
bdId = "999";
}
if (StringUtils.isNotEmpty(list)) {
list.forEach(vo->{
//先找到系统设备id
DeviceVo deviceVo=mapper.getDevInfoId(vo.getDeviceId(),bdId);
if(ObjectUtils.isNotEmpty(deviceVo) && StringUtils.isNotEmpty(deviceVo.getDevId())){
mapper.updateBdStatus(bdId);
String json="";
try {
json = objectMapper.writeValueAsString(vo);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
String devId= deviceVo.getDevId();
log.info("设备注册系统id---->{}",devId);
// WarnConfigVo config=mapper.getDevWarnConfig(devId);
String mergerId= UuidUtils.generateUuid().toUpperCase().replaceAll("-","");
attributeVos.clear();
DevAttributeVo devAttributeVo=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"相对坐标x",vo.getPosX(),"","pos_x","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo);
DevAttributeVo devAttributeVo2=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"相对坐标y",vo.getPosY(),"","pos_y","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo2);
DevAttributeVo devAttributeVo3=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"纬度",vo.getLatitude(),"","latitude","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo3);
DevAttributeVo devAttributeVo4=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"经度",vo.getLongitude(),"","longitude","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo4);
DevAttributeVo devAttributeVo5=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"心率",vo.getHeartRateValue(),"","heart_rate_value","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo5);
DevAttributeVo devAttributeVo6=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"血氧",vo.getBloodOxygenValue(),"","blood_oxygen_value","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo6);
DevAttributeVo devAttributeVo7=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"血压",vo.getBloodPressureValue(),"","blood_pressure_value","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo7);
DevAttributeVo devAttributeVo8=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"体温",vo.getBodyTempValue(),"","body_temp_value","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo8);
DevAttributeVo devAttributeVo9=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"气压",vo.getPressure(),"","pressure","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo9);
DevAttributeVo devAttributeVo10=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"海拔",vo.getAltitude(),"","altitude","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo10);
DevAttributeVo devAttributeVo11=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"身份证号码",vo.getIdCard(),"","id_card","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo11);
DevAttributeVo devAttributeVo12=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"人员名称",vo.getPersonName(),"","person_name","0",vo.getDataTime(),mergerId);
attributeVos.add(devAttributeVo12);
//更新/新增设备检测信息及记录
insertOrAddDevAttribute(attributeVos);
mapper.updateDevData(devId,json);
}else{
log.info("设备未注册------>{}",vo.getDeviceId());
msg.set("设备未注册!");
}
});
}
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error(msg.get());
}
/**
* 数据插入/更新
* @param list
*/
@Async
public void insertOrAddDevAttribute(List<DevAttributeVo> list){
try{
if (StringUtils.isNotEmpty(list)) {
list.forEach(vo->{
String id=mapper.getAttribute(vo);
if(StringUtils.isNotEmpty(id)){
vo.setAttributeId(id);
mapper.updateAttribute(vo);
}else{
mapper.insertAttribute(vo);
}
//插入数据记录
mapper.insertRecordData(vo);
});
}
}catch (Exception e){
log.error(e.toString(),e);
}
}
/**
* 判断是否告警
* @return
*/
public String isWarn(WarnConfigVo config,String val,int type ,DeviceVo deviceVo,String warn){
try{
if(ObjectUtils.isNotEmpty(config) && type==1 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal1Max();
BigDecimal min=config.getConfigVal1Min();
BigDecimal value=new BigDecimal(val);
//设备告警
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"倾角异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}
if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"倾角异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==2 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal4Max();
BigDecimal min=config.getConfigVal4Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"PM2.5异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"PM2.5异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==3 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal5Max();
BigDecimal min=config.getConfigVal5Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"PM10异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"PM10异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==4 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal3Max();
BigDecimal min=config.getConfigVal3Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"噪声异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"噪声异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==5 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal1Max();
BigDecimal min=config.getConfigVal1Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"温度异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"温度异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==6 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal2Max();
BigDecimal min=config.getConfigVal2Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"湿度异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"湿度异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==7 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal1Max();
BigDecimal min=config.getConfigVal1Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"含氧量异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"含氧量异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==8 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal2Max();
BigDecimal min=config.getConfigVal2Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"一氧化碳异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"一氧化碳异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==9 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal3Max();
BigDecimal min=config.getConfigVal3Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"可燃气体异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"可燃气体异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==10 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal4Max();
BigDecimal min=config.getConfigVal4Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"硫化氢异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"硫化氢异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}else if(ObjectUtils.isNotEmpty(config) && type==11 && ObjectUtils.isNotEmpty(val)){
BigDecimal max=config.getConfigVal4Max();
BigDecimal min=config.getConfigVal4Min();
BigDecimal value=new BigDecimal(val);
if(max.compareTo(value)<0){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"拉力异常",warn+"超出阈值",DateUtils.getTime());
return "1";
}else if(min.compareTo(value)>0 ){
insertWarn(deviceVo.getDevId(),deviceVo.getProCode(),"拉力异常",warn+"低于阈值",DateUtils.getTime());
return "1";
}
}
}catch (Exception e){
log.error(e.toString(),e);
}
return "0";
}
/**
* 设备告警数据插入
* @param devId
* @param
* @param warnType
* @param warnContent
* @param warnTime
*/
public void insertWarn(String devId,String proCode,String warnType,String warnContent,String warnTime){
try{
WarnVo vo=new WarnVo(warnTime,warnContent,warnType,devId,proCode,"");
mapper.insertWarn(vo);
}catch (Exception e){
log.error(e.toString(),e);
}
}
}

View File

@ -0,0 +1,195 @@
package com.bonus.data.service;
import cn.hutool.core.date.DateTime;
import com.alibaba.fastjson2.JSON;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.data.entity.WatherVo;
import com.bonus.data.mapper.WatherMapper;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
* 天气预警抓取
*/
@Service
public class WatherWarnService {
private static final Logger log = LoggerFactory.getLogger(WatherWarnService.class);
/**
* 搜索城市
*/
// static String CITY = "合肥市@阜阳市@安庆市@滁州市@六安市@宿州市@宣城市@芜湖市@池州市@淮南市@黄山市@蚌埠市@亳州市@淮北市@铜陵市@马鞍山市";
static String CITY ="";
/**
* 所有城市灾害预警列表
*/
final static String ALL_CITY_URL = "http://product.weather.com.cn/alarm/grepalarm_cn.php";
/**
* 搜索城市灾害预警数据页面
*/
final static String VALUE_URL = "http://product.weather.com.cn/alarm/webdata/";
/**
* 时间戳
*/
static long TIME_STAMP = System.currentTimeMillis();
@Autowired
private WatherMapper mapper;
/**
* 数据信息接口
* @param
*/
public void getCityWather(){
try{
String url = ALL_CITY_URL + "?_=" + TIME_STAMP;
String allWarningCity = getWarnCityList(url);
if (allWarningCity == null) {
return;
}
List<List<String>> data = getCityLists(allWarningCity);
List<String> citys=Arrays.asList(CITY.split("@"));
for (String city:citys) {
String realUrl = getSearchCityUrl(data,city);
if (realUrl == null || "".equals(realUrl)) {
mapper.delWatherWrn(DateUtils.getDate());
} else {
String wholeUrl = VALUE_URL + realUrl + "?_=" + TIME_STAMP;
Map<String, String> map = dealNewUrl(wholeUrl);
System.out.println("预警内容: "+map.get("ISSUECONTENT")+"类型:"+map.get("SIGNALTYPE")+"等级:"+map.get("SIGNALLEVEL"));
String time=map.get("ISSUETIME");//时间
String content=map.get("ISSUECONTENT").split("(预警信息来源")[0];
String type=map.get("SIGNALTYPE")+"预警";
String level=map.get("SIGNALLEVEL");
String prov=map.get("PROVINCE");
WatherVo vo=new WatherVo(prov,time,content,type,level,prov,DateUtils.getDate());
mapper.replaceWather(vo);
}
}
}catch (Exception e){
log.error(e.toString(),e);
}
}
/**
* 处理所有城市灾害列表页面
*
* @param url
* @return
*/
public static String getWarnCityList(String url) {
String allWeatherInfo = null;
CloseableHttpClient client;
client = HttpClientBuilder.create().build();
HttpGet get = new HttpGet(url);
RequestConfig config = RequestConfig.custom()
.setConnectTimeout(10*1000) //连接超时时间
.setConnectionRequestTimeout(6000) //从连接池中取的连接的最长时间
.setSocketTimeout(2*60*1000) //数据传输的超时时间
.build();
get.setConfig(config);
HttpResponse response;
try {
response = client.execute(get);
if (response != null) {
HttpEntity entity = response.getEntity();
allWeatherInfo = EntityUtils.toString(entity, "UTF-8");
} else {
System.out.println("全国所有城市都没有预警或者中国预警网错误");
}
} catch (IOException e) {
e.printStackTrace();
}
return allWeatherInfo;
}
/**
* 获得城市列表
* @param allWeatherInfo
* @return
*/
private static List<List<String>> getCityLists(String allWeatherInfo) {
String[] split = allWeatherInfo.split("=");
String value = split[1];
String substring = value.substring(0, value.length() - 1);
Map<String, List<List<String>>> jsonMap = JSON.parseObject(substring, Map.class);
return jsonMap.get("data");
}
/**
* 得到搜索城市的url
*
* @param data
* @return
*/
public static String getSearchCityUrl(List<List<String>> data, String city) {
String realUrl = "";
List<List<String>> sortedList = data.stream()
.filter(strings -> strings.get(0).contains(city))
.sorted(Comparator.comparing(s -> s.get(0).length()))
.limit(1)
.collect(Collectors.toList());
if (sortedList.isEmpty()) {
return realUrl;
}
realUrl = sortedList.get(0).get(1);
return realUrl;
}
/**
* 访问城市url
*
* @param url
* @return
*/
public static Map<String, String> dealNewUrl(String url) {
Map<String, String> map=new HashMap<>(16);
CloseableHttpClient client;
client = HttpClients.createDefault();
HttpGet get = new HttpGet(url);
HttpResponse response;
try {
response = client.execute(get);
HttpEntity entity = response.getEntity();
if (entity != null) {
String string = EntityUtils.toString(entity, "UTF-8");
// System.out.println("搜索城市数据: " + string);
String[] split = string.split("=");
String s = split[1];
map = JSON.parseObject(s, Map.class);
}
} catch (IOException e) {
e.printStackTrace();
}
return map;
}
public void updateBdStatus() {
try{
mapper.updateBdStatus();
}catch (Exception e){
log.error(e.toString());
}
}
}

View File

@ -0,0 +1,10 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ __ _ _
(_) / _|(_)| |
_ __ _ _ ___ _ _ _ ______ | |_ _ | | ___
| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \
| | | |_| || (_) || |_| || | | | | || || __/
|_| \__,_| \___/ \__, ||_| |_| |_||_| \___|
__/ |
|___/

View File

@ -0,0 +1,30 @@
# Tomcat
server:
port: 18988
# Spring
spring:
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
namespace: sgzb_bns
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
namespace: sgzb_bns
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
#加密组件
jasypt:
encryptor:
password: Encrypt
#sourceUrl:
#sourceUser:
#sourcePassword:

View File

@ -0,0 +1,8 @@
# Spring
spring:
application:
# 应用名称
name: bonus-data
profiles:
# 环境配置
active: sgzb_bns_local

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/bonus-data" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.bonus" level="debug" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>

View File

@ -0,0 +1,117 @@
<?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.bonus.data.mapper.DataCenterMapper">
<!--设备数据插入 缺少边带id-->
<insert id="insertDevInfo" parameterType="com.bonus.data.entity.DevInfoVo">
insert into tb_device(
dev_type, dev_code, dev_name,
dev_status,dev_warn, del_flag,
dev_err, dev_factory, remark, pro_name,
pro_code, rel_id,bd_id,rel_type
)values
(#{deviceType},#{deviceCode},#{deviceName},
#{deviceOnlineState},#{deviceAlarmState},0,
#{deviceFailureState},#{deviceFactory},#{remark},#{deviceProjectName},
#{deviceProjectCode},#{id},#{bdId},#{relType}
)
</insert>
<insert id="insertAttribute" keyProperty="attributeId" useGeneratedKeys="true">
insert into tb_dev_attribute(
dev_id,jc_name,jc_value,jc_unit,rel_code,is_warn,jc_time,del_flag
)values (#{devId},#{jcName},#{jcValue},#{jcUnit},#{relCode},#{isWarn},#{jcTime},0)
</insert>
<!--数据记录存储-->
<insert id="insertRecordData">
insert into tb_dev_data_record(
dev_json, dev_id,dev_name,attribute_id,
attribute_name, attribute_val, merger_id,
is_warn, create_time, dev_type)
values (#{devJson},#{devId},#{devName},#{attributeId},
#{jcName},#{jcValue},#{mergerId},#{isWarn},now(),#{devType})
</insert>
<insert id="updateDevData">
replace into tb_dev_data(
dev_id,dev_data,sys_time
)VALUES (#{devId},#{devJson},now())
</insert>
<insert id="insertWarn">
INSERT INTO tb_warn(
warn_time,warn_content,
warn_type, dev_id, state,
pro_code, remarks
)values (#{warnTime},#{warnContent},#{warnType},#{devId},0,#{proId},#{remarks})
</insert>
<!--更新设备信息-->
<update id="updateDevInfo">
update tb_device set
dev_type=#{deviceType}, dev_code=#{deviceCode},dev_name=#{deviceName},
dev_status= #{deviceOnlineState},dev_warn=#{deviceAlarmState},
dev_err= #{deviceFailureState}, dev_factory=#{deviceFactory}, remark=#{remark},
pro_name=#{deviceProjectCode},
pro_code=#{deviceProjectCode},
rel_type=#{relType}
where rel_id=#{id} and bd_id=#{bdId}
</update>
<!--数据采集同步-->
<update id="updateAttribute">
update tb_dev_attribute set
jc_value=#{jcValue},jc_time=#{jcTime},is_warn=#{isWarn}
where id=#{attributeId}
</update>
<!--更新边带状态-->
<update id="updateBdStatus" >
update tb_bd_device_record
set dev_status='1',status_time=now()
WHERE dev_code=#{bdId}
</update>
<!--依据级联id查询数据是否存在-->
<select id="getDevInfoNum" resultType="java.lang.Integer">
select count(1)
from tb_device
where rel_id=#{id} AND del_flag=0 and bd_id=#{bdId}
</select>
<!--查询接入边带设备ID-->
<select id="getDevInfoId" resultType="com.bonus.data.entity.DeviceVo">
select td.id devId, td.dev_name devName, td.dev_type devType,td.pro_name proName,td.pro_code proCode
from tb_device td
LEFT JOIN tb_bd_device_record bdr on td.bd_id=bdr.id
LEFT JOIN tb_bd_record tbr on bdr.record_id=tbr.id
where tbr.audit_status=1 AND td.del_flag=0
and bdr.dev_code=#{bdId} and td.rel_id=#{relId}
limit 1
</select>
<select id="getAttribute" resultType="java.lang.String">
select id
from tb_dev_attribute
where del_flag=0 and dev_id=#{devId} and rel_code=#{relCode}
</select>
<!--查询设备配置阈值信息-->
<select id="getDevWarnConfig" resultType="com.bonus.data.entity.WarnConfigVo">
select twc.config_val1_max configVal1Max,twc.config_val1_min configVal1Min,
twc.config_val2_max configVal2Max,twc.config_val2_min configVal2Min,
twc.config_val3_max configVal3Max,twc.config_val3_min configVal3Min,
twc.config_val4_max configVal4Max,twc.config_val4_min configVal4Min,
twc.config_val5_max configVal5Max,twc.config_val5_min configVal5Min,
twc.config_val6_max configVal6Max,twc.config_val6_min configVal6Min
from tb_device td
left join tb_warn_config twc on td.config_id=twc.id and twc.del_flag=0
where td.id=#{devId} and td.del_flag=0
</select>
<select id="getDevBdData" resultType="java.lang.String">
select bdr.id
from tb_bd_device_record bdr
LEFT JOIN tb_bd_record tbr on tbr.id = bdr.record_id
where tbr.audit_status = 1 and bdr.dev_code = #{edgeId}
</select>
<select id="getDevTypeId" resultType="java.lang.Integer">
select dict_code
FROM sys_dict_data
WHERE dict_type='dev_type'
and status=0
and dict_value LIKE CONCAT("%",#{relType},',',"%")
</select>
</mapper>

View File

@ -0,0 +1,22 @@
<?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.bonus.data.mapper.WatherMapper">
<insert id="replaceWather">
replace into t_warn_prediction(
city, create_time, content,
type, level, is_accecpt, state,
is_xf, cs_val, province, day
)values (#{city},#{createTime},#{content},#{type},#{level},0,0,0,0,#{province},#{day})
</insert>
<update id="updateBdStatus">
update tb_bd_device_record
set dev_status='0'
WHERE TIMESTAMPDIFF(HOUR, status_time, NOW()) >= 1 and dev_status='1'
</update>
<delete id="delWatherWrn">
delete from t_warn_prediction
where day like CONCAT('%',#{day},'%')
</delete>
</mapper>

View File

@ -247,6 +247,7 @@
<module>bonus-modules</module>
<module>bonus-common-biz</module>
<module>bonus-modules/base</module>
<module>bonus-modules/data</module>
</modules>
<packaging>pom</packaging>