Commit 56555de0 authored by Administrator's avatar Administrator

Merge remote-tracking branch 'origin/master'

parents cd2a8bb9 fdd9e7b5
......@@ -30,6 +30,11 @@ public interface RgDataMapper extends BaseMapper<RgData> {
@Select(value = "SELECT SUM(a.rainfall)as rainfall ,a.time FROM (select * from tb_rg_data ${ew.customSqlSegment})a GROUP BY a.time")
List<RgData> imgList(@Param("ew") Wrapper wrapper);
@Select(value = "SELECT SUM(a.rainfall)as rainfall ,a.time FROM (select * from tb_rg_data ${ew.customSqlSegment})a GROUP BY DATE_FORMAT( a.time, '%y-%m' )")
List<RgData> imgListGroupByMonth(@Param("ew") Wrapper wrapper);
List<RgData> imgListGroupByHour(@Param("ew") Wrapper wrapper,@Param("hour") int hour);
List<RgData> week(String start, String end, String sensorid);
}
package me.zhengjie.gemho.service.data.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
......@@ -302,9 +303,9 @@ public class RgDataServiceImpl extends ServiceImpl<RgDataMapper, RgData> impleme
//计算差值
Double aDouble = Double.valueOf(record.getRainfall());
Double aDouble1 = Double.valueOf(record.getJcvalue());
Double difference = aDouble-aDouble1;
Double difference = aDouble - aDouble1;
double v = (difference < 0) ? -difference : difference;
record.setDifference(String.format("%.2f",v));
record.setDifference(String.format("%.2f", v));
}
}
}
......@@ -337,28 +338,35 @@ public class RgDataServiceImpl extends ServiceImpl<RgDataMapper, RgData> impleme
QueryWrapper<RgData> rgDataQueryWrapper = new QueryWrapper<>();
ServiceUtil.rgImgQuery(rgDataQueryWrapper, dataQueryCriteria);
List<RgData> rgData = rgDataMapper.imgList(rgDataQueryWrapper);
System.out.println(JSONObject.toJSONString(rgData));
Integer hours = dataQueryCriteria.getHours();
if (hours != null) {
if (!ObjectUtils.isEmpty(rgData)) {
List<RgData> rgData1 = new ArrayList<>();
for (int i = 0; i < rgData.size(); i += hours) {
RgData rgData2 = new RgData();
Double result = 0.0;
int i1 = rgData.size() - i;
if (i1 >= hours) {
for (int j = i; j < i + hours; j++) {
result += rgData.get(j).getRainfall();
}
} else {
for (int j = i; j < i + i1; j++) {
result += rgData.get(j).getRainfall();
if (hours != 720) {
/* if (!ObjectUtils.isEmpty(rgData)) {
List<RgData> rgData1 = new ArrayList<>();
for (int i = 0; i < rgData.size(); i += hours) {
RgData rgData2 = new RgData();
Double result = 0.0;
int i1 = rgData.size() - i;
if (i1 >= hours) {
for (int j = i; j < i + hours; j++) {
result += rgData.get(j).getRainfall();
}
} else {
for (int j = i; j < i + i1; j++) {
result += rgData.get(j).getRainfall();
}
}
rgData2.setTime(rgData.get(i).getTime());
rgData2.setRainfall(result);
rgData1.add(rgData2);
}
rgData2.setTime(rgData.get(i).getTime());
rgData2.setRainfall(result);
rgData1.add(rgData2);
}
rgData = rgData1;
rgData = rgData1;
}*/
rgData = rgDataMapper.imgListGroupByHour(rgDataQueryWrapper,hours);
}
else {
rgData = rgDataMapper.imgListGroupByMonth(rgDataQueryWrapper);
}
}
//获取编码-名
......
......@@ -466,11 +466,11 @@ public class ServiceUtil {
//正序倒序
String sort = dataQueryCriteria.getSort();
String s = sort.split(",")[1];
if (s.equals("desc")) {
/* if (s.equals("desc")) {
queryWrapper.orderByDesc("time");
} else {
queryWrapper.orderByAsc("time");
}
}*/
}
......
......@@ -39,4 +39,15 @@
GROUP BY
DATE_FORMAT( time, '%Y-%m-%d' )
</select>
<select id="imgListGroupByHour" resultType="me.zhengjie.gemho.entity.data.RgData">
SELECT SUM(rainfall) as rainfall,
time
FROM
`tb_rg_data`
${ew.customSqlSegment}
GROUP BY
date ( time ),
CEILING( (HOUR ( time )+1) / #{hour} )
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment