|
|
@ -3,6 +3,8 @@ package com.ruoyi.code.rtudata.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
import com.ruoyi.code.camera.domain.ChartData; |
|
|
|
|
|
|
|
import com.ruoyi.code.camera.domain.YcData; |
|
|
|
import com.ruoyi.code.rtudata.domain.RtuData; |
|
|
|
import com.ruoyi.code.rtudata.domain.RtuData; |
|
|
|
import com.ruoyi.code.rtudata.mapper.RtuDataMapper; |
|
|
|
import com.ruoyi.code.rtudata.mapper.RtuDataMapper; |
|
|
|
import com.ruoyi.code.rtudata.service.IRtuDataService; |
|
|
|
import com.ruoyi.code.rtudata.service.IRtuDataService; |
|
|
@ -11,6 +13,8 @@ import com.ruoyi.common.utils.Query; |
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
@ -43,4 +47,49 @@ public class RtuDataServiceImpl extends ServiceImpl<RtuDataMapper, RtuData> impl |
|
|
|
return R.ok().put("data", list); |
|
|
|
return R.ok().put("data", list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Map<String, Object> getChart(Map<String, Object> params) { |
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
List<String> legend = new ArrayList<>(); |
|
|
|
|
|
|
|
List<ChartData> series = new ArrayList<>(); |
|
|
|
|
|
|
|
List<Integer> sids = baseMapper.getSids(params); |
|
|
|
|
|
|
|
for (Integer sid : sids) { |
|
|
|
|
|
|
|
params.put("sid", sid); |
|
|
|
|
|
|
|
// 图表的数据
|
|
|
|
|
|
|
|
ChartData chartData = getChartOptionData(params); |
|
|
|
|
|
|
|
if (chartData != null) { |
|
|
|
|
|
|
|
series.add(chartData); |
|
|
|
|
|
|
|
legend.add(chartData.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
map.put("legend",legend); |
|
|
|
|
|
|
|
map.put("series",series); |
|
|
|
|
|
|
|
return map; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ChartData getChartOptionData(Map<String, Object> params){ |
|
|
|
|
|
|
|
ChartData data = null; |
|
|
|
|
|
|
|
List<YcData> dataList = baseMapper.selectWaterData(params); |
|
|
|
|
|
|
|
if(dataList != null && dataList.size()>0){ |
|
|
|
|
|
|
|
data = new ChartData(); |
|
|
|
|
|
|
|
data.setId(dataList.get(0).getId()); |
|
|
|
|
|
|
|
data.setName(dataList.get(0).getStnm()); |
|
|
|
|
|
|
|
String item = (String) params.get("item"); |
|
|
|
|
|
|
|
if (item.contains("降水量")){ |
|
|
|
|
|
|
|
data.setType("bar"); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
data.setType("line"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
data.setData(formatChartData(dataList)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Object> formatChartData(List<YcData> dataList){ |
|
|
|
|
|
|
|
List<Object> objs = new ArrayList<>(); |
|
|
|
|
|
|
|
for (int j = 0 ; j< dataList.size() ; j++){ |
|
|
|
|
|
|
|
objs.add(new Object[]{dataList.get(j).getClock()*1000,dataList.get(j).getValue()}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return objs; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|