Compare commits
No commits in common. "3853ca919bfe493dec5f44dbe324ccaa0be4d1ba" and "1e23001c50913582926b2b22277e4d18b2644207" have entirely different histories.
3853ca919b
...
1e23001c50
|
@ -11,15 +11,9 @@ package com.ruoyi.iot.conf;
|
||||||
public class HzApiConf {
|
public class HzApiConf {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IOT配电箱数据获取HOST&&华筑
|
* IOT配电箱数据获取HOST
|
||||||
*/
|
*/
|
||||||
public static String IOT_POWER_HOST = "http://api.1357.cn/hz-condition-monitor";
|
public static String IOT_POWER_HOST = "http://api.1357.cn/hz-condition-monitor";
|
||||||
|
|
||||||
/**
|
|
||||||
* IOT配电箱数据获取HOST&&萨达
|
|
||||||
*/
|
|
||||||
public static String SD_IOT_POWER_HOST = "https://api.e.v1.i-sada.net";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标养室获取数据HOST
|
* 标养室获取数据HOST
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -42,10 +42,6 @@ public class IotDeviceInfo extends BaseEntity
|
||||||
|
|
||||||
private String hzTenantId;
|
private String hzTenantId;
|
||||||
private String hzProjectId;
|
private String hzProjectId;
|
||||||
private String factoryName;
|
|
||||||
private String companyName;
|
|
||||||
private String projectName;
|
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -125,30 +121,6 @@ public class IotDeviceInfo extends BaseEntity
|
||||||
this.hzProjectId = hzProjectId;
|
this.hzProjectId = hzProjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactoryName() {
|
|
||||||
return factoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFactoryName(String factoryName) {
|
|
||||||
this.factoryName = factoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCompanyName() {
|
|
||||||
return companyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCompanyName(String companyName) {
|
|
||||||
this.companyName = companyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProjectName() {
|
|
||||||
return projectName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProjectName(String projectName) {
|
|
||||||
this.projectName = projectName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import cn.hutool.http.HttpRequest;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.HttpUtils;
|
import com.ruoyi.common.utils.HttpUtils;
|
||||||
import com.ruoyi.iot.conf.HzApiConf;
|
import com.ruoyi.iot.conf.HzApiConf;
|
||||||
|
@ -47,6 +46,7 @@ import java.util.*;
|
||||||
@Component("gainHzDataTask")
|
@Component("gainHzDataTask")
|
||||||
public class GainHzDataTask {
|
public class GainHzDataTask {
|
||||||
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(GainHzDataTask.class);
|
private static final Logger log = LoggerFactory.getLogger(GainHzDataTask.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -61,6 +61,7 @@ public class GainHzDataTask {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IStandardCuringRoomDeviceService iStandardCuringRoomDeviceService;
|
private IStandardCuringRoomDeviceService iStandardCuringRoomDeviceService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IEnvironmentService environmentService;
|
private IEnvironmentService environmentService;
|
||||||
|
|
||||||
|
@ -72,7 +73,6 @@ public class GainHzDataTask {
|
||||||
|
|
||||||
public static Boolean[] warrning = new Boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
|
public static Boolean[] warrning = new Boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
|
||||||
public static Boolean[] warrning1 = new Boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
|
public static Boolean[] warrning1 = new Boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
|
||||||
public static Boolean[] warrning_power_sd = new Boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPowerData() {
|
public void getPowerData() {
|
||||||
|
@ -87,7 +87,6 @@ public class GainHzDataTask {
|
||||||
iotDeviceInfo.setDeviceName("配电箱");
|
iotDeviceInfo.setDeviceName("配电箱");
|
||||||
List<IotDeviceInfo> iotDeviceInfos = iIotDeviceInfoService.selectIotDeviceInfoList(iotDeviceInfo);
|
List<IotDeviceInfo> iotDeviceInfos = iIotDeviceInfoService.selectIotDeviceInfoList(iotDeviceInfo);
|
||||||
iotDeviceInfos.forEach(item -> {
|
iotDeviceInfos.forEach(item -> {
|
||||||
if(Objects.equals("华筑",item.getFactoryName())){
|
|
||||||
if(item.getHzTenantId() != null && item.getHzProjectId() != null) {
|
if(item.getHzTenantId() != null && item.getHzProjectId() != null) {
|
||||||
JSONObject body = new JSONObject();
|
JSONObject body = new JSONObject();
|
||||||
body.put("tenantId", item.getHzTenantId());
|
body.put("tenantId", item.getHzTenantId());
|
||||||
|
@ -162,109 +161,6 @@ public class GainHzDataTask {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iotPowers.size() > 0) {
|
|
||||||
iotPowerService.batchInsertPower(iotPowers);
|
|
||||||
}
|
|
||||||
if (iotWarningInfos.size() > 0) {
|
|
||||||
iotWarningInfoService.batchInsertWarning(iotWarningInfos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(Objects.equals("华筑",item.getFactoryName())){
|
|
||||||
String res_str = HttpRequest.get(HzApiConf.SD_IOT_POWER_HOST + "/metric/box/"+item.getDeviceId())
|
|
||||||
.execute().body();
|
|
||||||
JSONObject res = JSONObject.parseObject(res_str).getJSONObject("result");
|
|
||||||
// 电能检测数据
|
|
||||||
JSONObject metric = res.getJSONObject("metric");
|
|
||||||
// 温度检测数据
|
|
||||||
JSONArray temperatures = res.getJSONArray("temperatures");
|
|
||||||
// 漏电检测数据
|
|
||||||
JSONArray leakages = res.getJSONArray("leakages");
|
|
||||||
// 报警数据
|
|
||||||
JSONObject ticketStatus = res.getJSONObject("ticketStatus");
|
|
||||||
List<IotPower> iotPowers = new ArrayList<>(16);
|
|
||||||
List<IotWarningInfo> iotWarningInfos = new ArrayList<>(16);
|
|
||||||
IotPower iotPower = new IotPower();
|
|
||||||
iotPower.setUid(item.getDeviceId());
|
|
||||||
iotPower.setTime(DateUtils.getNowDate());
|
|
||||||
BigDecimal power = metric.getBigDecimal("power_a").add(metric.getBigDecimal("power_b")).add(metric.getBigDecimal("power_c"));
|
|
||||||
iotPower.setPower(power.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP));
|
|
||||||
int leak = 0;
|
|
||||||
for (int i = 0; i < leakages.size(); i++) {
|
|
||||||
JSONObject leakage = leakages.getJSONObject(i);
|
|
||||||
if(Convert.toInt(leakage.get("leakage"),0)>leak){
|
|
||||||
leak = leakage.getInteger("leakage");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iotPower.setLeak(BigDecimal.valueOf(leak));
|
|
||||||
iotPower.setC1(BigDecimal.valueOf(metric.getFloat("current_a")));
|
|
||||||
iotPower.setC2(BigDecimal.valueOf(metric.getFloat("current_b")));
|
|
||||||
iotPower.setC3(BigDecimal.valueOf(metric.getFloat("current_c")));
|
|
||||||
iotPower.setV1(BigDecimal.valueOf(metric.getFloat("voltage_a")));
|
|
||||||
iotPower.setV2(BigDecimal.valueOf(metric.getFloat("voltage_b")));
|
|
||||||
iotPower.setV3(BigDecimal.valueOf(metric.getFloat("voltage_c")));
|
|
||||||
BigDecimal data = temperatures.getJSONObject(0).getBigDecimal("temperature");
|
|
||||||
iotPower.setT1(data);
|
|
||||||
iotPower.setT2(data);
|
|
||||||
iotPower.setT3(data);
|
|
||||||
iotPower.setT4(data);
|
|
||||||
|
|
||||||
// 预警数据
|
|
||||||
if (t % 2 == 0 && !warrning_power_sd[t]) {
|
|
||||||
warrning_power_sd = new Boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
|
|
||||||
warrning_power_sd[t] = true;
|
|
||||||
|
|
||||||
if(ticketStatus.getInteger("is_blackout")>0){
|
|
||||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
|
||||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
|
||||||
iotWarningInfo.setType("断电预警");
|
|
||||||
iotWarningInfo.setContent("设备触发断电,请排查异常情况");
|
|
||||||
iotWarningInfo.setCreateTime(new Date());
|
|
||||||
iotWarningInfos.add(iotWarningInfo);
|
|
||||||
}
|
|
||||||
if(ticketStatus.getInteger("is_smoke")>0){
|
|
||||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
|
||||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
|
||||||
iotWarningInfo.setType("烟感报警");
|
|
||||||
iotWarningInfo.setContent("设备烟感报警,请排查异常情况");
|
|
||||||
iotWarningInfo.setCreateTime(new Date());
|
|
||||||
iotWarningInfos.add(iotWarningInfo);
|
|
||||||
}
|
|
||||||
if(ticketStatus.getInteger("is_overload")>0){
|
|
||||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
|
||||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
|
||||||
iotWarningInfo.setType("过载报警");
|
|
||||||
iotWarningInfo.setContent("设备过载报警,请排查异常情况");
|
|
||||||
iotWarningInfo.setCreateTime(new Date());
|
|
||||||
iotWarningInfos.add(iotWarningInfo);
|
|
||||||
}
|
|
||||||
if(ticketStatus.getInteger("is_disconnect")>0){
|
|
||||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
|
||||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
|
||||||
iotWarningInfo.setType("断开报警");
|
|
||||||
iotWarningInfo.setContent("设备断开报警,请排查异常情况");
|
|
||||||
iotWarningInfo.setCreateTime(new Date());
|
|
||||||
iotWarningInfos.add(iotWarningInfo);
|
|
||||||
}
|
|
||||||
if(ticketStatus.getInteger("is_overheat")>0){
|
|
||||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
|
||||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
|
||||||
iotWarningInfo.setType(" 高温报警");
|
|
||||||
iotWarningInfo.setContent("设备高温报警,请排查异常情况");
|
|
||||||
iotWarningInfo.setCreateTime(new Date());
|
|
||||||
iotWarningInfos.add(iotWarningInfo);
|
|
||||||
}
|
|
||||||
if(ticketStatus.getInteger("is_leakage")>0){
|
|
||||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
|
||||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
|
||||||
iotWarningInfo.setType(" 漏电报警");
|
|
||||||
iotWarningInfo.setContent("设备漏电报警,请排查异常情况");
|
|
||||||
iotWarningInfo.setCreateTime(new Date());
|
|
||||||
iotWarningInfos.add(iotWarningInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
iotPowers.add(iotPower);
|
|
||||||
|
|
||||||
if (iotPowers.size() > 0) {
|
if (iotPowers.size() > 0) {
|
||||||
iotPowerService.batchInsertPower(iotPowers);
|
iotPowerService.batchInsertPower(iotPowers);
|
||||||
}
|
}
|
||||||
|
@ -273,6 +169,7 @@ public class GainHzDataTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,20 +1,43 @@
|
||||||
package com.ruoyi.iot.task;
|
package com.ruoyi.iot.task;
|
||||||
|
|
||||||
|
import cc.casually.htmlParse.http.*;
|
||||||
|
import cc.casually.htmlParse.util.HttpUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.message.MessageOneUtil;
|
import com.ruoyi.common.message.MessageOneUtil;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.iot.conf.HzApiConf;
|
||||||
|
import com.ruoyi.iot.domain.IotPower;
|
||||||
|
import com.ruoyi.iot.domain.IotWarningInfo;
|
||||||
|
import com.ruoyi.iot.domain.StandardCuringRoomDevice;
|
||||||
|
import com.ruoyi.iot.service.IIotPowerService;
|
||||||
|
import com.ruoyi.iot.service.IIotWarningInfoService;
|
||||||
|
import com.ruoyi.iot.service.IStandardCuringRoomDeviceService;
|
||||||
import com.ruoyi.system.mapper.MeasureDeviceMapper;
|
import com.ruoyi.system.mapper.MeasureDeviceMapper;
|
||||||
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
import com.ruoyi.utils.HttpUtils;
|
import com.ruoyi.utils.HttpUtils;
|
||||||
|
import com.ruoyi.weixin.domain.Environment;
|
||||||
import com.ruoyi.weixin.mapper.ConcreteStrengthDataMapper;
|
import com.ruoyi.weixin.mapper.ConcreteStrengthDataMapper;
|
||||||
|
import com.ruoyi.weixin.mapper.EnvironmentMapper;
|
||||||
|
import com.ruoyi.weixin.service.IEnvironmentService;
|
||||||
import org.apache.commons.collections.map.HashedMap;
|
import org.apache.commons.collections.map.HashedMap;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.protocol.HTTP;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 混凝土强度数据拉取定时任务
|
* 混凝土强度数据拉取定时任务
|
||||||
|
|
|
@ -14,13 +14,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="typeName" column="type_name" />
|
<result property="typeName" column="type_name" />
|
||||||
<result property="hzTenantId" column="hz_tenant_id" />
|
<result property="hzTenantId" column="hz_tenant_id" />
|
||||||
<result property="hzProjectId" column="hz_project_id" />
|
<result property="hzProjectId" column="hz_project_id" />
|
||||||
<result property="factoryName" column="factory_name" />
|
|
||||||
<result property="companyName" column="company_name" />
|
|
||||||
<result property="projectName" column="project_name" />
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectIotDeviceInfoVo">
|
<sql id="selectIotDeviceInfoVo">
|
||||||
select id, device_id, device_name, state, project_id, points, type_name, hz_tenant_id, hz_project_id, factory_name, company_name, project_name from iot_device_info
|
select id, device_id, device_name, state, project_id, points,type_name,hz_tenant_id,hz_project_id from iot_device_info
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectIotDeviceInfoList" parameterType="IotDeviceInfo" resultMap="IotDeviceInfoResult">
|
<select id="selectIotDeviceInfoList" parameterType="IotDeviceInfo" resultMap="IotDeviceInfoResult">
|
||||||
|
@ -32,7 +29,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="projectId != null "> and project_id = #{projectId}</if>
|
<if test="projectId != null "> and project_id = #{projectId}</if>
|
||||||
<if test="points != null "> and points = #{points}</if>
|
<if test="points != null "> and points = #{points}</if>
|
||||||
<if test="typeName != null "> and type_name = #{typeName}</if>
|
<if test="typeName != null "> and type_name = #{typeName}</if>
|
||||||
<if test="factoryName != null and factoryName != ''"> and factory_name = #{factoryName}</if>
|
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue