bug修复
This commit is contained in:
parent
f229c20acd
commit
e72943f627
@ -75,6 +75,8 @@ public class DischargingPlatformCurrentData implements Serializable {
|
|||||||
@ApiModelProperty(value = "Y倾角")
|
@ApiModelProperty(value = "Y倾角")
|
||||||
private java.lang.String yDipAngle;
|
private java.lang.String yDipAngle;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "携稳id")
|
||||||
|
private Long xiewenId;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@ApiModelProperty(value = "是否有报警,0否,1是")
|
@ApiModelProperty(value = "是否有报警,0否,1是")
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<select id="selectDischargingPlatformDevList"
|
<select id="selectDischargingPlatformDevList"
|
||||||
resultType="com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev">
|
resultType="com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev">
|
||||||
SELECT w1.*,
|
SELECT w1.*,
|
||||||
IFNULL(((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=10 then 1 else 0 end)),0)
|
IFNULL(((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=30 then 1 else 0 end)),0)
|
||||||
devOnline
|
devOnline
|
||||||
from discharging_platform_dev w1
|
from discharging_platform_dev w1
|
||||||
where w1.project_sn=#{projectSn}
|
where w1.project_sn=#{projectSn}
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<select id="selectDischargingPlatformDevListByPage"
|
<select id="selectDischargingPlatformDevListByPage"
|
||||||
resultType="com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev">
|
resultType="com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev">
|
||||||
SELECT w1.*,
|
SELECT w1.*,
|
||||||
IFNULL(((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=10 then 1 else 0 end)),0)
|
IFNULL(((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=30 then 1 else 0 end)),0)
|
||||||
devOnline
|
devOnline
|
||||||
from discharging_platform_dev w1
|
from discharging_platform_dev w1
|
||||||
where w1.project_sn=#{d.projectSn}
|
where w1.project_sn=#{d.projectSn}
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<select id="selectDischargingDevCount" resultType="java.util.Map" parameterType="map">
|
<select id="selectDischargingDevCount" resultType="java.util.Map" parameterType="map">
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(1) devNum,
|
COUNT(1) devNum,
|
||||||
IFNULL(SUM((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=10 then 1 else 0 end)),0)
|
IFNULL(SUM((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(real_time))/60)<=30 then 1 else 0 end)),0)
|
||||||
devOnline
|
devOnline
|
||||||
FROM discharging_platform_dev de INNER JOIN project a ON de.project_sn=a.project_sn
|
FROM discharging_platform_dev de INNER JOIN project a ON de.project_sn=a.project_sn
|
||||||
INNER JOIN company cp ON a.company_sn=cp.company_sn
|
INNER JOIN company cp ON a.company_sn=cp.company_sn
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
package com.zhgd.xmgl.modules.discharging.service;
|
package com.zhgd.xmgl.modules.discharging.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||||
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
|
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
|
||||||
import com.zhgd.xmgl.base.entity.vo.TrendVo;
|
import com.zhgd.xmgl.base.entity.vo.TrendVo;
|
||||||
import com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformCurrentData;
|
import com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformCurrentData;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev;
|
||||||
import com.zhgd.xmgl.modules.discharging.entity.vo.CountDischargingPlatformCurrentDataVo;
|
import com.zhgd.xmgl.modules.discharging.entity.vo.CountDischargingPlatformCurrentDataVo;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -33,4 +34,7 @@ public interface IDischargingPlatformCurrentDataService extends IService<Dischar
|
|||||||
CountDischargingPlatformCurrentDataVo countDischargingPlatformCurrentData(HashMap<String, Object> paramMap);
|
CountDischargingPlatformCurrentDataVo countDischargingPlatformCurrentData(HashMap<String, Object> paramMap);
|
||||||
|
|
||||||
List<TrendVo> countLoad(HashMap<String, Object> paramMap);
|
List<TrendVo> countLoad(HashMap<String, Object> paramMap);
|
||||||
|
|
||||||
|
public void addAlarms(DischargingPlatformCurrentData dischargingPlatformCurrentData, DischargingPlatformDev dev);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,6 +66,14 @@ public class DischargingPlatformCurrentDataServiceImpl extends ServiceImpl<Disch
|
|||||||
}
|
}
|
||||||
dischargingPlatformCurrentData.setProjectSn(dev.getProjectSn());
|
dischargingPlatformCurrentData.setProjectSn(dev.getProjectSn());
|
||||||
dischargingPlatformCurrentDataMapper.insert(dischargingPlatformCurrentData);
|
dischargingPlatformCurrentDataMapper.insert(dischargingPlatformCurrentData);
|
||||||
|
DischargingPlatformDev dischargingPlatformDev = new DischargingPlatformDev();
|
||||||
|
dischargingPlatformDev.setId(dev.getId());
|
||||||
|
dischargingPlatformDev.setRealTime(new Date());
|
||||||
|
dischargingPlatformDevMapper.updateById(dischargingPlatformDev);
|
||||||
|
addAlarms(dischargingPlatformCurrentData, dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAlarms(DischargingPlatformCurrentData dischargingPlatformCurrentData, DischargingPlatformDev dev) {
|
||||||
//添加报警信息
|
//添加报警信息
|
||||||
if (dischargingPlatformCurrentData.getIsAlarm() != null && dischargingPlatformCurrentData.getIsAlarm() == 1) {
|
if (dischargingPlatformCurrentData.getIsAlarm() != null && dischargingPlatformCurrentData.getIsAlarm() == 1) {
|
||||||
Integer alarmLevel = dischargingPlatformCurrentData.getAlarmLevel();
|
Integer alarmLevel = dischargingPlatformCurrentData.getAlarmLevel();
|
||||||
@ -112,11 +120,6 @@ public class DischargingPlatformCurrentDataServiceImpl extends ServiceImpl<Disch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DischargingPlatformDev dischargingPlatformDev = new DischargingPlatformDev();
|
|
||||||
dischargingPlatformDev.setId(dev.getId());
|
|
||||||
dischargingPlatformDev.setRealTime(new Date());
|
|
||||||
dischargingPlatformDevMapper.updateById(dischargingPlatformDev);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,11 +6,13 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.gexin.fastjson.JSON;
|
import com.gexin.fastjson.JSON;
|
||||||
import com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformCurrentData;
|
import com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformCurrentData;
|
||||||
import com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev;
|
import com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev;
|
||||||
import com.zhgd.xmgl.modules.discharging.mapper.DischargingPlatformCurrentDataMapper;
|
import com.zhgd.xmgl.modules.discharging.mapper.DischargingPlatformCurrentDataMapper;
|
||||||
import com.zhgd.xmgl.modules.discharging.mapper.DischargingPlatformDevMapper;
|
import com.zhgd.xmgl.modules.discharging.mapper.DischargingPlatformDevMapper;
|
||||||
|
import com.zhgd.xmgl.modules.discharging.service.IDischargingPlatformCurrentDataService;
|
||||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||||
import com.zhgd.xmgl.task.dto.DischargingPlatformCurrentDataDto;
|
import com.zhgd.xmgl.task.dto.DischargingPlatformCurrentDataDto;
|
||||||
@ -41,6 +43,8 @@ public class DischargingPlatformCurrentDataTask {
|
|||||||
DischargingPlatformDevMapper dischargingPlatformDevMapper;
|
DischargingPlatformDevMapper dischargingPlatformDevMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectMapper projectMapper;
|
private ProjectMapper projectMapper;
|
||||||
|
@Autowired
|
||||||
|
private IDischargingPlatformCurrentDataService dischargingPlatformCurrentDataService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private XiwonUtil xiwonUtil;
|
private XiwonUtil xiwonUtil;
|
||||||
@ -79,12 +83,16 @@ public class DischargingPlatformCurrentDataTask {
|
|||||||
// 设备sn
|
// 设备sn
|
||||||
String devSn = dev.getDevSn();
|
String devSn = dev.getDevSn();
|
||||||
log.info("doGetDischargingPlatformCurrentData设备sn:{}", devSn);
|
log.info("doGetDischargingPlatformCurrentData设备sn:{}", devSn);
|
||||||
|
DischargingPlatformCurrentData newestData = dischargingPlatformCurrentDataMapper.selectOne(
|
||||||
|
new LambdaQueryWrapper<DischargingPlatformCurrentData>().eq(DischargingPlatformCurrentData::getDevSn, devSn)
|
||||||
|
.orderByDesc(DischargingPlatformCurrentData::getXiewenId).last("limit 1"));
|
||||||
// 请求参数
|
// 请求参数
|
||||||
Map<String, Object> map = new HashMap<>(4);
|
Map<String, Object> map = new HashMap<>(4);
|
||||||
map.put("pageSize", "10");
|
map.put("pageSize", "10");
|
||||||
map.put("pageNum", "1");
|
map.put("pageNum", "1");
|
||||||
map.put("startTime", DateUtil.formatDateTime(DateUtil.offsetMinute(now, -5)));
|
if (newestData != null && newestData.getXiewenId() != null) {
|
||||||
map.put("endTime", DateUtil.formatDateTime(now));
|
map.put("dataId", newestData.getXiewenId());
|
||||||
|
}
|
||||||
JSONObject realTimeData = xiwonUtil.postForm("/unloading/realTimeData", project.getXiwonAppId(), project.getXiwonAppSecret(), map, JSONObject.class, (() -> {
|
JSONObject realTimeData = xiwonUtil.postForm("/unloading/realTimeData", project.getXiwonAppId(), project.getXiwonAppSecret(), map, JSONObject.class, (() -> {
|
||||||
map.put("deviceSn", devSn);
|
map.put("deviceSn", devSn);
|
||||||
return map;
|
return map;
|
||||||
@ -93,28 +101,26 @@ public class DischargingPlatformCurrentDataTask {
|
|||||||
Integer code = realTimeData.getInteger("code");
|
Integer code = realTimeData.getInteger("code");
|
||||||
// code校验是否成功请求
|
// code校验是否成功请求
|
||||||
if (code == HttpStatus.OK.value()) {
|
if (code == HttpStatus.OK.value()) {
|
||||||
|
dev.setRealTime(new Date());
|
||||||
|
dischargingPlatformDevMapper.updateById(dev);
|
||||||
|
|
||||||
JSONArray dataArray = realTimeData.getJSONArray("data");
|
JSONArray dataArray = realTimeData.getJSONArray("data");
|
||||||
if (CollUtil.isNotEmpty(dataArray)) {
|
if (CollUtil.isNotEmpty(dataArray)) {
|
||||||
DischargingPlatformDev platformDev = dischargingPlatformDevMapper.selectOne(new LambdaQueryWrapper<DischargingPlatformDev>()
|
|
||||||
.eq(DischargingPlatformDev::getDevSn, devSn));
|
|
||||||
if (platformDev == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 解析请求到的参数,保存到我们的数据库
|
// 解析请求到的参数,保存到我们的数据库
|
||||||
for (Object o : dataArray) {
|
for (Object o : dataArray) {
|
||||||
DischargingPlatformCurrentDataDto dto = BeanUtil.toBean(o, DischargingPlatformCurrentDataDto.class);
|
DischargingPlatformCurrentDataDto dto = BeanUtil.toBean(o, DischargingPlatformCurrentDataDto.class);
|
||||||
DischargingPlatformCurrentData data = new DischargingPlatformCurrentData();
|
DischargingPlatformCurrentData data = new DischargingPlatformCurrentData();
|
||||||
data.setDevSn(devSn);
|
data.setDevSn(devSn);
|
||||||
data.setProjectSn(platformDev.getProjectSn());
|
data.setProjectSn(dev.getProjectSn());
|
||||||
data.setReciveTime(dto.getCreateTime());
|
data.setReciveTime(dto.getCreateTime());
|
||||||
data.setLoading(String.valueOf(dto.getRealLoad() / 1000.0));
|
data.setLoading(String.valueOf(dto.getRealLoad() / 1000.0));
|
||||||
data.setDisplacement(null);
|
data.setDisplacement(null);
|
||||||
data.setXDipAngle(String.valueOf(dto.getInclinationX() / 10.0));
|
data.setXDipAngle(String.valueOf(dto.getInclinationX() / 10.0));
|
||||||
data.setYDipAngle(String.valueOf(dto.getInclinationY() / 10.0));
|
data.setYDipAngle(String.valueOf(dto.getInclinationY() / 10.0));
|
||||||
|
data.setXiewenId(dto.getId());
|
||||||
dischargingPlatformCurrentDataMapper.insert(data);
|
dischargingPlatformCurrentDataMapper.insert(data);
|
||||||
|
|
||||||
platformDev.setRealTime(new Date());
|
dischargingPlatformCurrentDataService.addAlarms(data, dev);
|
||||||
dischargingPlatformDevMapper.updateById(platformDev);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info("设备sn:{},当前无数据!", devSn);
|
log.info("设备sn:{},当前无数据!", devSn);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user