提交 6c3d9c8c authored 作者: 张龙发's avatar 张龙发

技术等级情况柱状图代码提交

上级 acdd7cf2
...@@ -79,4 +79,16 @@ public class ZhtjGljsdjqkController extends BaseController { ...@@ -79,4 +79,16 @@ public class ZhtjGljsdjqkController extends BaseController {
return new R<>(zhtjGljsdjqkService.removeById(id)); return new R<>(zhtjGljsdjqkService.removeById(id));
} }
/**
* 公路技术等级情况Echarts信息
* @param year 年份
* @return
*/
@GetMapping("/chartinfo")
public R getZhtjGljsdjqkztqkChartInfo(String year,String type) {
System.out.print("year :"+year+", type: "+type);
year = "2017";
type = "1";
return new R<>(zhtjGljsdjqkService.getZhtjGljsdjqkztqkEchartData(year,type));
}
} }
package com.elephant.framework.galaxy.aroad.module.zhtj.service; package com.elephant.framework.galaxy.aroad.module.zhtj.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.elephant.framework.galaxy.aroad.module.system.vo.echarts.BarEchartsVo;
import com.elephant.framework.galaxy.aroad.module.zhtj.entity.ZhtjGljsdjqk; import com.elephant.framework.galaxy.aroad.module.zhtj.entity.ZhtjGljsdjqk;
/** /**
...@@ -10,5 +11,10 @@ import com.elephant.framework.galaxy.aroad.module.zhtj.entity.ZhtjGljsdjqk; ...@@ -10,5 +11,10 @@ import com.elephant.framework.galaxy.aroad.module.zhtj.entity.ZhtjGljsdjqk;
* @date 2019-03-11 17:24:55 * @date 2019-03-11 17:24:55
*/ */
public interface ZhtjGljsdjqkService extends IService<ZhtjGljsdjqk> { public interface ZhtjGljsdjqkService extends IService<ZhtjGljsdjqk> {
/**
* 根据年份查询公路通车/养护里程列表
*
* @return Echarts格式数据
*/
BarEchartsVo getZhtjGljsdjqkztqkEchartData(String year, String type);
} }
package com.elephant.framework.galaxy.aroad.module.zhtj.service.impl; package com.elephant.framework.galaxy.aroad.module.zhtj.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elephant.framework.galaxy.aroad.module.system.vo.echarts.BarEchartsVo;
import com.elephant.framework.galaxy.aroad.module.system.vo.echarts.BarSeriesVo;
import com.elephant.framework.galaxy.aroad.module.zhtj.entity.ZhtjGljsdjqk; import com.elephant.framework.galaxy.aroad.module.zhtj.entity.ZhtjGljsdjqk;
import com.elephant.framework.galaxy.aroad.module.zhtj.mapper.ZhtjGljsdjqkMapper; import com.elephant.framework.galaxy.aroad.module.zhtj.mapper.ZhtjGljsdjqkMapper;
import com.elephant.framework.galaxy.aroad.module.zhtj.service.ZhtjGljsdjqkService; import com.elephant.framework.galaxy.aroad.module.zhtj.service.ZhtjGljsdjqkService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** /**
* 综合统计_公路技术等级情况 * 综合统计_公路技术等级情况
* *
...@@ -13,6 +22,69 @@ import org.springframework.stereotype.Service; ...@@ -13,6 +22,69 @@ import org.springframework.stereotype.Service;
* @date 2019-03-11 17:24:55 * @date 2019-03-11 17:24:55
*/ */
@Service @Service
@AllArgsConstructor
public class ZhtjGljsdjqkServiceImpl extends ServiceImpl<ZhtjGljsdjqkMapper, ZhtjGljsdjqk> implements ZhtjGljsdjqkService { public class ZhtjGljsdjqkServiceImpl extends ServiceImpl<ZhtjGljsdjqkMapper, ZhtjGljsdjqk> implements ZhtjGljsdjqkService {
private final ZhtjGljsdjqkMapper zgtjgljsdjqkMapper;
/**
* 根据年份查询公路通车/养护里程列表
*
* @return Echarts格式数据
*/
@Override
public BarEchartsVo getZhtjGljsdjqkztqkEchartData(String year, String type) {
BarEchartsVo echartsVo = new BarEchartsVo();
List<ZhtjGljsdjqk> dataList = zgtjgljsdjqkMapper.selectList(Wrappers.<ZhtjGljsdjqk>query().lambda().
eq(ZhtjGljsdjqk::getYear, year).eq(ZhtjGljsdjqk::getType, type));
echartsVo.setTitle("各市技术等级情况图");
echartsVo.setSubTitle("计量单位:公里");
List<String> legend = new ArrayList<>(Arrays.asList("高速","一级","二级","三级","四级","等外"));
echartsVo.setLegendData(legend);
List<String> xAxis = new ArrayList<>();
List<BarSeriesVo> series = new ArrayList<>();
for (String leg : legend) {
BarSeriesVo barSeriesVo = new BarSeriesVo();
barSeriesVo.setName(leg);
barSeriesVo.setType("bar");
barSeriesVo.setStack("总量");
JSONObject json = new JSONObject();
JSONObject json_in = new JSONObject();
json_in.put("show", false);
json_in.put("position", "insideRight");
json.put("normal",json_in);
barSeriesVo.setLabel(json);
List<Double> data = new ArrayList<>();
for (int i = 0; i < dataList.size(); i++) {
ZhtjGljsdjqk temp = dataList.get(i);
if("合计".equals(temp.getArea())){
continue;
}
if(xAxis.size()<17){
xAxis.add(temp.getArea());
}
if("高速".equals(leg)){
data.add(temp.getHighRoad());
} else if("一级".equals(leg)) {
data.add(temp.getFirstRoad());
} else if("二级".equals(leg)) {
data.add(temp.getSecondRoad());
} else if("三级".equals(leg)) {
data.add(temp.getThreeRoad());
} else if("四级".equals(leg)) {
data.add(temp.getFourRoad());
} else if("等外".equals(leg)) {
data.add(temp.getOtherRoad());
}
barSeriesVo.setData(data);
}
series.add(barSeriesVo);
}
echartsVo.setXAxisData(xAxis);
echartsVo.setSeries(series);
return echartsVo;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论