Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.njcn.device.pq.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
@@ -9,18 +8,13 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.device.pq.enums.DeviceResponseEnum;
|
||||
import com.njcn.device.pq.pojo.bo.BaseLineInfo;
|
||||
import com.njcn.device.pq.mapper.*;
|
||||
import com.njcn.device.pq.pojo.dto.*;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
|
||||
import com.njcn.device.pq.pojo.po.Device;
|
||||
import com.njcn.device.pq.pojo.po.Line;
|
||||
import com.njcn.device.pq.pojo.po.LineDetail;
|
||||
import com.njcn.device.pq.pojo.po.Overlimit;
|
||||
import com.njcn.device.pq.pojo.param.OnlineRateParam;
|
||||
import com.njcn.device.pq.pojo.po.*;
|
||||
import com.njcn.device.pq.pojo.vo.*;
|
||||
import com.njcn.device.pq.mapper.DeviceMapper;
|
||||
import com.njcn.device.pq.mapper.LineDetailMapper;
|
||||
import com.njcn.device.pq.mapper.LineMapper;
|
||||
import com.njcn.device.pq.service.LineService;
|
||||
import com.njcn.device.pq.service.impl.GeneralDeviceService;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
@@ -36,8 +30,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
@@ -63,6 +55,7 @@ public class LineController extends BaseController {
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final RStatIntegrityDMapper integrityDMapper;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getLineDetailData")
|
||||
@@ -419,4 +412,13 @@ public class LineController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, count, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("/getOnIntegrityByIds")
|
||||
@ApiOperation("监测点数据完整率(谐波专用)")
|
||||
@ApiImplicitParam(name = "param", value = "参数实体", required = true)
|
||||
public HttpResult<List<RStatIntegrityVO>> getOnIntegrityByIds(@RequestBody OnlineRateParam param) {
|
||||
String methodDescribe = getMethodDescribe("getOnlineRateByDevIds");
|
||||
List<RStatIntegrityVO> onIntegrityByIds = integrityDMapper.getOnIntegrityByIds(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,onIntegrityByIds,methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,13 @@ import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pq.mapper.OnlineRateMapper;
|
||||
import com.njcn.device.pq.mapper.RStatOnlinerateDMapper;
|
||||
import com.njcn.device.pq.pojo.param.OnlineRateParam;
|
||||
import com.njcn.device.pq.pojo.param.TerminalOnlineRateDataParam;
|
||||
import com.njcn.device.pq.pojo.po.OnlineRate;
|
||||
import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
|
||||
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
|
||||
import com.njcn.device.pq.pojo.vo.TerminalOnlineRateDataVO;
|
||||
import com.njcn.device.pq.service.TerminalOnlineRateDataService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -37,6 +42,8 @@ public class TerminalOnlineRateDataController extends BaseController {
|
||||
|
||||
private final TerminalOnlineRateDataService terminalOnlineRateDataService;
|
||||
|
||||
private final RStatOnlinerateDMapper onlineRateMapper;
|
||||
|
||||
/**
|
||||
* 终端在线率列表
|
||||
*/
|
||||
@@ -49,4 +56,15 @@ public class TerminalOnlineRateDataController extends BaseController {
|
||||
List<TerminalOnlineRateDataVO> onlineRateData = terminalOnlineRateDataService.getOnlineRateData(terminalOnlineRateDataParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,onlineRateData,methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getOnlineRateByDevIds")
|
||||
@ApiOperation("终端在线率(谐波专用)")
|
||||
@ApiImplicitParam(name = "param", value = "参数实体", required = true)
|
||||
public HttpResult<List<RStatOnlinerateVO>> getOnlineRateByDevIds(@RequestBody OnlineRateParam param) {
|
||||
String methodDescribe = getMethodDescribe("getOnlineRateByDevIds");
|
||||
List<RStatOnlinerateVO> onlineRateByDevIds = onlineRateMapper.getOnlineRateByDevIds(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,onlineRateByDevIds,methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.njcn.device.pq.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pq.pojo.param.OnlineRateParam;
|
||||
import com.njcn.device.pq.pojo.po.LineDataIntegrity;
|
||||
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
|
||||
import com.njcn.device.pq.pojo.vo.RStatIntegrityVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,4 +27,13 @@ public interface RStatIntegrityDMapper extends BaseMapper<RStatIntegrityD> {
|
||||
* @date 2023/3/29
|
||||
*/
|
||||
List<LineDataIntegrity> getLineIntegrityRate(@Param("lineIds")List<String> lineIds,@Param("startTime")String startTime,@Param("endTime")String endTime);
|
||||
|
||||
/***
|
||||
* 监测点完整性
|
||||
* @author wr
|
||||
* @date 2023-04-03 10:10
|
||||
* @param param
|
||||
* @return List<OnlineRate>
|
||||
*/
|
||||
List<RStatIntegrityVO> getOnIntegrityByIds(@Param("param") OnlineRateParam param);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,13 @@ package com.njcn.device.pq.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pq.pojo.param.OnlineRateParam;
|
||||
import com.njcn.device.pq.pojo.po.OnlineRate;
|
||||
import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
|
||||
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -14,4 +20,12 @@ import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
|
||||
*/
|
||||
public interface RStatOnlinerateDMapper extends BaseMapper<RStatOnlinerateD> {
|
||||
|
||||
/***
|
||||
* 获取设备在线率
|
||||
* @author wr
|
||||
* @date 2023-04-03 10:10
|
||||
* @param param
|
||||
* @return List<OnlineRate>
|
||||
*/
|
||||
List<RStatOnlinerateVO> getOnlineRateByDevIds(@Param("param") OnlineRateParam param);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.device.pq.mapper.TerminalOnlineRateDataMapper">
|
||||
<mapper namespace="com.njcn.device.pq.mapper.RStatIntegrityDMapper">
|
||||
|
||||
<select id="getLineIntegrityRate" resultType="LineDataIntegrity">
|
||||
select line_index lineId,avg(real_time/due_time) integrityData
|
||||
@@ -12,4 +12,27 @@
|
||||
and time_id between #{startTime} and #{endTime}
|
||||
group by line_index
|
||||
</select>
|
||||
|
||||
<select id="getOnIntegrityByIds" resultType="com.njcn.device.pq.pojo.vo.RStatIntegrityVO">
|
||||
SELECT
|
||||
line_index AS lineIndex,
|
||||
sum( real_time )/ sum( due_time )* 100 AS integrityRate
|
||||
FROM
|
||||
r_stat_integrity_d
|
||||
<where>
|
||||
<if test="param!=null and param.ids != null and param.ids.size > 0">
|
||||
AND Dev_Id IN
|
||||
<foreach collection='param.ids' item='item' index="index" open='(' separator=',' close=')'>
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test=" param.startTime != null and param.startTime !=''">
|
||||
AND time_id >= #{param.startTime}
|
||||
</if>
|
||||
<if test="param.endTime != null and param.endTime != ''">
|
||||
AND time_id <= #{param.endTime}
|
||||
</if>
|
||||
</where>
|
||||
group by line_index ;
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.device.pq.mapper.RStatOnlinerateDMapper">
|
||||
<select id="getOnlineRateByDevIds" resultType="com.njcn.device.pq.pojo.vo.RStatOnlinerateVO">
|
||||
select
|
||||
dev_index,
|
||||
sum(online_min)/(sum(online_min) + sum(offline_min))*100 as online_rate
|
||||
from r_stat_onlinerate_d
|
||||
<where>
|
||||
<if test="param!=null and param.ids != null and param.ids.size > 0">
|
||||
AND Dev_Id IN
|
||||
<foreach collection='param.ids' item='item' index="index" open='(' separator=',' close=')'>
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test=" param.startTime != null and param.startTime !=''">
|
||||
AND time_id >= #{param.startTime}
|
||||
</if>
|
||||
<if test="param.endTime != null and param.endTime != ''">
|
||||
AND time_id <= #{param.endTime}
|
||||
</if>
|
||||
</where>
|
||||
group by dev_index ;
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,12 +1,18 @@
|
||||
package com.njcn.device.pq.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.njcn.device.pq.mapper.OnlineRateMapper;
|
||||
import com.njcn.device.pq.mapper.RStatIntegrityDMapper;
|
||||
import com.njcn.device.pq.mapper.RStatOnlinerateDMapper;
|
||||
import com.njcn.device.pq.pojo.param.OnlineRateParam;
|
||||
import com.njcn.device.pq.pojo.param.PulicTimeParam;
|
||||
import com.njcn.device.pq.pojo.param.PulicTimeStatisParam;
|
||||
import com.njcn.device.pq.pojo.vo.CommunicateStatisticsVO;
|
||||
import com.njcn.device.pq.pojo.vo.CommunicateVO;
|
||||
import com.njcn.device.pq.pojo.vo.DeviceOnlineDataVO;
|
||||
import com.njcn.device.pq.pojo.po.LineDataIntegrity;
|
||||
import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
|
||||
import com.njcn.device.pq.pojo.vo.*;
|
||||
import com.njcn.device.pq.service.CommunicateService;
|
||||
import com.njcn.device.pq.service.IRStatOnlinerateDService;
|
||||
import com.njcn.device.pq.service.LineService;
|
||||
import com.njcn.device.pq.utils.PublicDateUtil;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
@@ -36,6 +42,9 @@ public class CommunicateServiceImpl implements CommunicateService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final RStatOnlinerateDMapper onlinerateDMapper;
|
||||
private final RStatIntegrityDMapper integrityDMapper;
|
||||
|
||||
@Override
|
||||
public CommunicateVO getComFlagInfoData(PulicTimeParam pulicTimeParam) {
|
||||
//根据监测点id获取终端状态信息
|
||||
@@ -49,11 +58,11 @@ public class CommunicateServiceImpl implements CommunicateService {
|
||||
String devId = lineService.getLineIdByDevId(pulicTimeStatisParam.getId());
|
||||
List<Float> floatList = new ArrayList<>();
|
||||
List<Float> floats = new ArrayList<>();
|
||||
floatList.add(getCondition(pulicTimeStatisParam.getId(), pulicTimeStatisParam.getSearchBeginTime(), pulicTimeStatisParam.getSearchEndTime(), 0) * 100);
|
||||
floats.add(getCondition(devId, pulicTimeStatisParam.getSearchBeginTime(), pulicTimeStatisParam.getSearchEndTime(), 1) * 100);
|
||||
floatList.add( getCondition(pulicTimeStatisParam.getId(), pulicTimeStatisParam.getSearchBeginTime(), pulicTimeStatisParam.getSearchEndTime(), 0) );
|
||||
floats.add( getCondition(devId, pulicTimeStatisParam.getSearchBeginTime(), pulicTimeStatisParam.getSearchEndTime(), 1) );
|
||||
if (StringUtils.isNotBlank(pulicTimeStatisParam.getPeriodBeginTime()) && StringUtils.isNotBlank(pulicTimeStatisParam.getPeriodEndTime())) {
|
||||
floatList.add(getCondition(pulicTimeStatisParam.getId(), pulicTimeStatisParam.getPeriodBeginTime(), pulicTimeStatisParam.getPeriodEndTime(), 0) * 100);
|
||||
floats.add(getCondition(devId, pulicTimeStatisParam.getPeriodBeginTime(), pulicTimeStatisParam.getPeriodEndTime(), 1) * 100);
|
||||
floatList.add( getCondition(pulicTimeStatisParam.getId(), pulicTimeStatisParam.getPeriodBeginTime(), pulicTimeStatisParam.getPeriodEndTime(), 0) );
|
||||
floats.add( getCondition(devId, pulicTimeStatisParam.getPeriodBeginTime(), pulicTimeStatisParam.getPeriodEndTime(), 1) );
|
||||
}
|
||||
communicateStatisticsVO.setOnlineRateData(floats);
|
||||
communicateStatisticsVO.setIntegrityData(floatList);
|
||||
@@ -83,7 +92,7 @@ public class CommunicateServiceImpl implements CommunicateService {
|
||||
if (floatList == 0) {
|
||||
inter.setOnlineRate(3.14159f);
|
||||
} else {
|
||||
inter.setOnlineRate(Float.parseFloat(decimalFormat.format(floatList * 100)));
|
||||
inter.setOnlineRate(Float.parseFloat(decimalFormat.format(floatList)));
|
||||
}
|
||||
deviceOnlineDataList.add(inter);
|
||||
}
|
||||
@@ -122,35 +131,61 @@ public class CommunicateServiceImpl implements CommunicateService {
|
||||
*/
|
||||
private Float getCondition(String lineList, String startTime, String endTime, Integer state) {
|
||||
final Float[] resultList = {0.0f};
|
||||
//组装sql语句
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(TIME + " >= '").append(startTime).append(START_TIME).append("' and ").append(TIME).append(" <= '").append(endTime).append(END_TIME).append("' and (");
|
||||
//sql语句
|
||||
String sql = "";
|
||||
if (state == 0) {
|
||||
stringBuilder.append(LINE_ID + "='").append(lineList).append("')");
|
||||
sql = "SELECT SUM(" + REAL + ")/SUM(" + DUE + ") AS integrity FROM pqs_integrity WHERE " + stringBuilder.toString() + " group by " + LINE_ID + " tz('Asia/Shanghai')";
|
||||
} else {
|
||||
stringBuilder.append(DEV_INDEX + "='").append(lineList).append("')");
|
||||
sql = "SELECT SUM(" + ONLINE_MIN + ")/(SUM(" + OFFLINE_MIN + ")+SUM(" + ONLINE_MIN + ")) AS onlineRate FROM pqs_onlinerate WHERE " + stringBuilder.toString() + " group by " + DEV_INDEX + " tz('Asia/Shanghai')";
|
||||
OnlineRateParam param=new OnlineRateParam();
|
||||
param.setIds(Arrays.asList(lineList));
|
||||
param.setStartTime( DateUtil.beginOfDay(DateUtil.parse(startTime)).toString());
|
||||
param.setEndTime( DateUtil.endOfDay(DateUtil.parse(endTime)).toString());
|
||||
if(state == 0){
|
||||
//在线率
|
||||
List<RStatOnlinerateVO> onlineRateByDevIds = onlinerateDMapper.getOnlineRateByDevIds(param);
|
||||
if (CollUtil.isNotEmpty(onlineRateByDevIds)) {
|
||||
onlineRateByDevIds.forEach(po -> {
|
||||
//数据完整性 保留四位小数
|
||||
resultList[0] = po.getOnlineRate() == null ? null : BigDecimal.valueOf(Float.parseFloat(po.getOnlineRate().toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
});
|
||||
}
|
||||
}else{
|
||||
//数据完整率
|
||||
List<RStatIntegrityVO> onIntegrityByIds = integrityDMapper.getOnIntegrityByIds(param);
|
||||
if (CollUtil.isNotEmpty(onIntegrityByIds)) {
|
||||
onIntegrityByIds.forEach(po -> {
|
||||
//数据完整性 保留四位小数
|
||||
resultList[0] = po.getIntegrityRate() == null ? null : BigDecimal.valueOf(Float.parseFloat(po.getIntegrityRate().toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
});
|
||||
}
|
||||
}
|
||||
//结果集
|
||||
QueryResult result = influxDbUtils.query(sql);
|
||||
//处理结果集
|
||||
List<QueryResult.Series> list = result.getResults().get(0).getSeries();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(po -> {
|
||||
List<List<Object>> valueList = po.getValues();
|
||||
if (!CollectionUtils.isEmpty(valueList)) {
|
||||
for (List<Object> value : valueList) {
|
||||
//数据完整性 保留四位小数
|
||||
resultList[0] = value.get(1) == null ? null : BigDecimal.valueOf(Float.parseFloat(value.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return resultList[0];
|
||||
|
||||
//
|
||||
// //组装sql语句
|
||||
// StringBuilder stringBuilder = new StringBuilder();
|
||||
// stringBuilder.append(TIME + " >= '").append(startTime).append(START_TIME).append("' and ").append(TIME).append(" <= '").append(endTime).append(END_TIME).append("' and (");
|
||||
// //sql语句
|
||||
// String sql = "";
|
||||
// if (state == 0) {
|
||||
// stringBuilder.append(LINE_ID + "='").append(lineList).append("')");
|
||||
// sql = "SELECT SUM(" + REAL + ")/SUM(" + DUE + ") AS integrity FROM pqs_integrity WHERE " + stringBuilder.toString() + " group by " + LINE_ID + " tz('Asia/Shanghai')";
|
||||
// } else {
|
||||
// stringBuilder.append(DEV_INDEX + "='").append(lineList).append("')");
|
||||
// sql = "SELECT SUM(" + ONLINE_MIN + ")/(SUM(" + OFFLINE_MIN + ")+SUM(" + ONLINE_MIN + ")) AS onlineRate FROM pqs_onlinerate WHERE " + stringBuilder.toString() + " group by " + DEV_INDEX + " tz('Asia/Shanghai')";
|
||||
// }
|
||||
// //结果集
|
||||
// QueryResult result = influxDbUtils.query(sql);
|
||||
// //处理结果集
|
||||
// List<QueryResult.Series> list = result.getResults().get(0).getSeries();
|
||||
// if (!CollectionUtils.isEmpty(list)) {
|
||||
// list.forEach(po -> {
|
||||
// List<List<Object>> valueList = po.getValues();
|
||||
// if (!CollectionUtils.isEmpty(valueList)) {
|
||||
// for (List<Object> value : valueList) {
|
||||
// //数据完整性 保留四位小数
|
||||
// resultList[0] = value.get(1) == null ? null : BigDecimal.valueOf(Float.parseFloat(value.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// return resultList[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user