diff --git a/bonus-modules/data/pom.xml b/bonus-modules/data/pom.xml new file mode 100644 index 0000000..8898a4f --- /dev/null +++ b/bonus-modules/data/pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + com.bonus + bonus + 24.10.0-SNAPSHOT + ../../pom.xml + + + com.bonus + data + + + bonus-modules-data数据模块 + + + + + + + + + + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + ${jasypt-spring-boot-starter.version} + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.bonus + bonus-common-datasource + + + + + com.bonus + bonus-common-datascope + + + + + com.bonus + bonus-common-log + + + + + com.bonus + bonus-common-swagger + + + com.google.guava + guava + 30.0-jre + compile + + + + org.springframework.boot + spring-boot-starter-mail + + + com.bonus + bonus-common-biz + 24.10.0-SNAPSHOT + compile + + + junit + junit + test + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + \ No newline at end of file diff --git a/bonus-modules/data/src/main/java/com/bonus/data/DataApplication.java b/bonus-modules/data/src/main/java/com/bonus/data/DataApplication.java new file mode 100644 index 0000000..d1de4b7 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/DataApplication.java @@ -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" + + " ''-' `'-' `-..-' "); + } +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/config/SystemScheduleConfig.java b/bonus-modules/data/src/main/java/com/bonus/data/config/SystemScheduleConfig.java new file mode 100644 index 0000000..b93f0b2 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/config/SystemScheduleConfig.java @@ -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(); + } +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/controller/DataCenterController.java b/bonus-modules/data/src/main/java/com/bonus/data/controller/DataCenterController.java new file mode 100644 index 0000000..21f6303 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/controller/DataCenterController.java @@ -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); + } +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/CgqInfoDataVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/CgqInfoDataVo.java new file mode 100644 index 0000000..fd7d33a --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/CgqInfoDataVo.java @@ -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; + + +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/CjDataVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/CjDataVo.java new file mode 100644 index 0000000..fa6c65e --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/CjDataVo.java @@ -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; +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/DevAttributeVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/DevAttributeVo.java new file mode 100644 index 0000000..4e08482 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/DevAttributeVo.java @@ -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; + } +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/DevInfoVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/DevInfoVo.java new file mode 100644 index 0000000..e0b05a9 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/DevInfoVo.java @@ -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; +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/DeviceVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/DeviceVo.java new file mode 100644 index 0000000..bcf1775 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/DeviceVo.java @@ -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; + +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/LlgcqDataVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/LlgcqDataVo.java new file mode 100644 index 0000000..1e28cb3 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/LlgcqDataVo.java @@ -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; +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/SafetyHatVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/SafetyHatVo.java new file mode 100644 index 0000000..cc9f53f --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/SafetyHatVo.java @@ -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; +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/SwhjDataVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/SwhjDataVo.java new file mode 100644 index 0000000..948f164 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/SwhjDataVo.java @@ -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; + + + + +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/WarnConfigVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/WarnConfigVo.java new file mode 100644 index 0000000..1d911ce --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/WarnConfigVo.java @@ -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; +} \ No newline at end of file diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/WarnVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/WarnVo.java new file mode 100644 index 0000000..16488cd --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/WarnVo.java @@ -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; + } +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/WatherVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/WatherVo.java new file mode 100644 index 0000000..f920e0e --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/WatherVo.java @@ -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; + } +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/YxkjDataVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/YxkjDataVo.java new file mode 100644 index 0000000..b70eb59 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/YxkjDataVo.java @@ -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; + +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/entity/ZnshDataVo.java b/bonus-modules/data/src/main/java/com/bonus/data/entity/ZnshDataVo.java new file mode 100644 index 0000000..e688882 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/entity/ZnshDataVo.java @@ -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; +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/mapper/DataCenterMapper.java b/bonus-modules/data/src/main/java/com/bonus/data/mapper/DataCenterMapper.java new file mode 100644 index 0000000..87b639d --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/mapper/DataCenterMapper.java @@ -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); +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/mapper/WatherMapper.java b/bonus-modules/data/src/main/java/com/bonus/data/mapper/WatherMapper.java new file mode 100644 index 0000000..9694182 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/mapper/WatherMapper.java @@ -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(); +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterService.java b/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterService.java new file mode 100644 index 0000000..41b8f36 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterService.java @@ -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); +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterServiceImpl.java b/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterServiceImpl.java new file mode 100644 index 0000000..103823c --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/service/DataCenterServiceImpl.java @@ -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 msg= new AtomicReference<>("数据上传成功!"); + try{ + JSONObject jsonObject = JSONObject.parseObject(obj); + Object edgeId=jsonObject.get("edgeId"); + log.info("设备数据数据-->{}",obj); + List 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 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 list = jsonObject.getList("list",CgqInfoDataVo.class); + ObjectMapper objectMapper=new ObjectMapper(); + List 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 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 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 msg= new AtomicReference<>("数据上传成功!"); + try { + JSONObject jsonObject = JSONObject.parseObject(obj); + log.info("安全帽感知设备数据-->{}",obj); + List list = jsonObject.getList("list",SafetyHatVo.class); + ObjectMapper objectMapper = new ObjectMapper(); + List 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 msg= new AtomicReference<>("数据上传成功!"); + try{ + JSONObject jsonObject = JSONObject.parseObject(obj); + log.info("室外环境检测数据-->{}",obj); + List list = jsonObject.getList("list",SwhjDataVo.class); + ObjectMapper objectMapper=new ObjectMapper(); + List 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(),"m³","grain_05","0",vo.getDataTime(),mergerId); + attributeVos.add(devAttributeVo); + DevAttributeVo devAttributeVo2=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"1.0µm粒子数",vo.getGrain10(),"m³","grain_10","0",vo.getDataTime(),mergerId); + attributeVos.add(devAttributeVo2); + DevAttributeVo devAttributeVo3=new DevAttributeVo(devId,json,deviceVo.getDevName(),deviceVo.getDevType(),"5.0µm粒子数",vo.getGrain50(),"m³","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 msg= new AtomicReference<>("数据上传成功!"); + try{ + JSONObject jsonObject = JSONObject.parseObject(obj); + log.info("有限空间数据-->{}",obj); + List list = jsonObject.getList("list",YxkjDataVo.class); + ObjectMapper objectMapper=new ObjectMapper(); + List 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 msg= new AtomicReference<>("数据上传成功!"); + try{ + JSONObject jsonObject = JSONObject.parseObject(obj); + log.info("拉力传感器数据-->{}",obj); + List list = jsonObject.getList("list",LlgcqDataVo.class); + ObjectMapper objectMapper=new ObjectMapper(); + List 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 msg= new AtomicReference<>("数据上传成功!"); + try{ + JSONObject jsonObject = JSONObject.parseObject(obj); + log.info("只能手环数据-->{}",obj); + List list = jsonObject.getList("list",ZnshDataVo.class); + ObjectMapper objectMapper=new ObjectMapper(); + List 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 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); + } + } +} diff --git a/bonus-modules/data/src/main/java/com/bonus/data/service/WatherWarnService.java b/bonus-modules/data/src/main/java/com/bonus/data/service/WatherWarnService.java new file mode 100644 index 0000000..052e673 --- /dev/null +++ b/bonus-modules/data/src/main/java/com/bonus/data/service/WatherWarnService.java @@ -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> data = getCityLists(allWarningCity); + List 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 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> getCityLists(String allWeatherInfo) { + String[] split = allWeatherInfo.split("="); + String value = split[1]; + String substring = value.substring(0, value.length() - 1); + Map>> jsonMap = JSON.parseObject(substring, Map.class); + return jsonMap.get("data"); + } + + /** + * 得到搜索城市的url + * + * @param data + * @return + */ + public static String getSearchCityUrl(List> data, String city) { + String realUrl = ""; + List> 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 dealNewUrl(String url) { + Map 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()); + } + } +} diff --git a/bonus-modules/data/src/main/resources/banner.txt b/bonus-modules/data/src/main/resources/banner.txt new file mode 100644 index 0000000..27cacb9 --- /dev/null +++ b/bonus-modules/data/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + _ __ _ _ + (_) / _|(_)| | + _ __ _ _ ___ _ _ _ ______ | |_ _ | | ___ +| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \ +| | | |_| || (_) || |_| || | | | | || || __/ +|_| \__,_| \___/ \__, ||_| |_| |_||_| \___| + __/ | + |___/ \ No newline at end of file diff --git a/bonus-modules/data/src/main/resources/bootstrap-sgzb_bns_local.yml b/bonus-modules/data/src/main/resources/bootstrap-sgzb_bns_local.yml new file mode 100644 index 0000000..c999eb2 --- /dev/null +++ b/bonus-modules/data/src/main/resources/bootstrap-sgzb_bns_local.yml @@ -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: \ No newline at end of file diff --git a/bonus-modules/data/src/main/resources/bootstrap.yml b/bonus-modules/data/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..0d905c8 --- /dev/null +++ b/bonus-modules/data/src/main/resources/bootstrap.yml @@ -0,0 +1,8 @@ +# Spring +spring: + application: + # 应用名称 + name: bonus-data + profiles: + # 环境配置 + active: sgzb_bns_local diff --git a/bonus-modules/data/src/main/resources/logback.xml b/bonus-modules/data/src/main/resources/logback.xml new file mode 100644 index 0000000..ef09ad2 --- /dev/null +++ b/bonus-modules/data/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/bonus-modules/data/src/main/resources/mapper/data/DataCenterMapper.xml b/bonus-modules/data/src/main/resources/mapper/data/DataCenterMapper.xml new file mode 100644 index 0000000..646fb32 --- /dev/null +++ b/bonus-modules/data/src/main/resources/mapper/data/DataCenterMapper.xml @@ -0,0 +1,117 @@ + + + + + + + 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 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 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}) + + + replace into tb_dev_data( + dev_id,dev_data,sys_time + )VALUES (#{devId},#{devJson},now()) + + + INSERT INTO tb_warn( + warn_time,warn_content, + warn_type, dev_id, state, + pro_code, remarks + )values (#{warnTime},#{warnContent},#{warnType},#{devId},0,#{proId},#{remarks}) + + + + 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 tb_dev_attribute set + jc_value=#{jcValue},jc_time=#{jcTime},is_warn=#{isWarn} + where id=#{attributeId} + + + + update tb_bd_device_record + set dev_status='1',status_time=now() + WHERE dev_code=#{bdId} + + + + + + + + + + + + + \ No newline at end of file diff --git a/bonus-modules/data/src/main/resources/mapper/data/WatherMapper.xml b/bonus-modules/data/src/main/resources/mapper/data/WatherMapper.xml new file mode 100644 index 0000000..391d464 --- /dev/null +++ b/bonus-modules/data/src/main/resources/mapper/data/WatherMapper.xml @@ -0,0 +1,22 @@ + + + + + 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}) + + + + update tb_bd_device_record + set dev_status='0' + WHERE TIMESTAMPDIFF(HOUR, status_time, NOW()) >= 1 and dev_status='1' + + + delete from t_warn_prediction + where day like CONCAT('%',#{day},'%') + + + \ No newline at end of file diff --git a/bonus-modules/data/src/main/resources/template/TbPeopleTemplate.xlsx b/bonus-modules/data/src/main/resources/template/TbPeopleTemplate.xlsx new file mode 100644 index 0000000..d98e7e6 Binary files /dev/null and b/bonus-modules/data/src/main/resources/template/TbPeopleTemplate.xlsx differ diff --git a/bonus-modules/data/src/main/resources/template/TbProPowerTemplate.xlsx b/bonus-modules/data/src/main/resources/template/TbProPowerTemplate.xlsx new file mode 100644 index 0000000..d4e1f3a Binary files /dev/null and b/bonus-modules/data/src/main/resources/template/TbProPowerTemplate.xlsx differ diff --git a/pom.xml b/pom.xml index a4b8f35..68cc1b0 100644 --- a/pom.xml +++ b/pom.xml @@ -247,6 +247,7 @@ bonus-modules bonus-common-biz bonus-modules/base + bonus-modules/data pom