bug修复
This commit is contained in:
parent
f229c20acd
commit
e72943f627
@ -75,6 +75,8 @@ public class DischargingPlatformCurrentData implements Serializable {
|
||||
@ApiModelProperty(value = "Y倾角")
|
||||
private java.lang.String yDipAngle;
|
||||
|
||||
@ApiModelProperty(value = "携稳id")
|
||||
private Long xiewenId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "是否有报警,0否,1是")
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<select id="selectDischargingPlatformDevList"
|
||||
resultType="com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev">
|
||||
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
|
||||
from discharging_platform_dev w1
|
||||
where w1.project_sn=#{projectSn}
|
||||
@ -13,7 +13,7 @@
|
||||
<select id="selectDischargingPlatformDevListByPage"
|
||||
resultType="com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev">
|
||||
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
|
||||
from discharging_platform_dev w1
|
||||
where w1.project_sn=#{d.projectSn}
|
||||
@ -22,7 +22,7 @@
|
||||
<select id="selectDischargingDevCount" resultType="java.util.Map" parameterType="map">
|
||||
SELECT
|
||||
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
|
||||
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
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package com.zhgd.xmgl.modules.discharging.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
|
||||
import com.zhgd.xmgl.base.entity.vo.TrendVo;
|
||||
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 java.util.HashMap;
|
||||
@ -15,7 +16,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @Description: 卸料平台-实时数据
|
||||
* @author: pds
|
||||
* @date: 2021-04-21
|
||||
* @date: 2021-04-21
|
||||
* @version: V1.0
|
||||
*/
|
||||
public interface IDischargingPlatformCurrentDataService extends IService<DischargingPlatformCurrentData> {
|
||||
@ -33,4 +34,7 @@ public interface IDischargingPlatformCurrentDataService extends IService<Dischar
|
||||
CountDischargingPlatformCurrentDataVo countDischargingPlatformCurrentData(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());
|
||||
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) {
|
||||
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
|
||||
|
||||
@ -6,11 +6,13 @@ import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformCurrentData;
|
||||
import com.zhgd.xmgl.modules.discharging.entity.DischargingPlatformDev;
|
||||
import com.zhgd.xmgl.modules.discharging.mapper.DischargingPlatformCurrentDataMapper;
|
||||
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.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.task.dto.DischargingPlatformCurrentDataDto;
|
||||
@ -41,6 +43,8 @@ public class DischargingPlatformCurrentDataTask {
|
||||
DischargingPlatformDevMapper dischargingPlatformDevMapper;
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
@Autowired
|
||||
private IDischargingPlatformCurrentDataService dischargingPlatformCurrentDataService;
|
||||
|
||||
@Resource
|
||||
private XiwonUtil xiwonUtil;
|
||||
@ -79,12 +83,16 @@ public class DischargingPlatformCurrentDataTask {
|
||||
// 设备sn
|
||||
String devSn = dev.getDevSn();
|
||||
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.put("pageSize", "10");
|
||||
map.put("pageNum", "1");
|
||||
map.put("startTime", DateUtil.formatDateTime(DateUtil.offsetMinute(now, -5)));
|
||||
map.put("endTime", DateUtil.formatDateTime(now));
|
||||
if (newestData != null && newestData.getXiewenId() != null) {
|
||||
map.put("dataId", newestData.getXiewenId());
|
||||
}
|
||||
JSONObject realTimeData = xiwonUtil.postForm("/unloading/realTimeData", project.getXiwonAppId(), project.getXiwonAppSecret(), map, JSONObject.class, (() -> {
|
||||
map.put("deviceSn", devSn);
|
||||
return map;
|
||||
@ -93,28 +101,26 @@ public class DischargingPlatformCurrentDataTask {
|
||||
Integer code = realTimeData.getInteger("code");
|
||||
// code校验是否成功请求
|
||||
if (code == HttpStatus.OK.value()) {
|
||||
dev.setRealTime(new Date());
|
||||
dischargingPlatformDevMapper.updateById(dev);
|
||||
|
||||
JSONArray dataArray = realTimeData.getJSONArray("data");
|
||||
if (CollUtil.isNotEmpty(dataArray)) {
|
||||
DischargingPlatformDev platformDev = dischargingPlatformDevMapper.selectOne(new LambdaQueryWrapper<DischargingPlatformDev>()
|
||||
.eq(DischargingPlatformDev::getDevSn, devSn));
|
||||
if (platformDev == null) {
|
||||
return;
|
||||
}
|
||||
// 解析请求到的参数,保存到我们的数据库
|
||||
for (Object o : dataArray) {
|
||||
DischargingPlatformCurrentDataDto dto = BeanUtil.toBean(o, DischargingPlatformCurrentDataDto.class);
|
||||
DischargingPlatformCurrentData data = new DischargingPlatformCurrentData();
|
||||
data.setDevSn(devSn);
|
||||
data.setProjectSn(platformDev.getProjectSn());
|
||||
data.setProjectSn(dev.getProjectSn());
|
||||
data.setReciveTime(dto.getCreateTime());
|
||||
data.setLoading(String.valueOf(dto.getRealLoad() / 1000.0));
|
||||
data.setDisplacement(null);
|
||||
data.setXDipAngle(String.valueOf(dto.getInclinationX() / 10.0));
|
||||
data.setYDipAngle(String.valueOf(dto.getInclinationY() / 10.0));
|
||||
data.setXiewenId(dto.getId());
|
||||
dischargingPlatformCurrentDataMapper.insert(data);
|
||||
|
||||
platformDev.setRealTime(new Date());
|
||||
dischargingPlatformDevMapper.updateById(platformDev);
|
||||
dischargingPlatformCurrentDataService.addAlarms(data, dev);
|
||||
}
|
||||
} else {
|
||||
log.info("设备sn:{},当前无数据!", devSn);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user