Commit dd7c8801 authored by HuangBingGui's avatar HuangBingGui
Browse files

no commit message

parent 1119316e
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.echarts.dao;
import com.jeespring.common.persistence.InterfaceBaseDao;
import com.jeespring.modules.echarts.entity.PieClass;
import org.apache.ibatis.annotations.Mapper;
/**
* 班级DAO接口
* @author lgf
* @version 2016-05-26
*/
@Mapper
public interface PieClassDao extends InterfaceBaseDao<PieClass> {
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.echarts.entity;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeespring.common.persistence.AbstractBaseEntity;
import com.jeespring.common.utils.excel.annotation.ExcelField;
/**
* 城市气温Entity
* @author lgf
* @version 2016-06-02
*/
public class ChinaWeatherDataBean extends AbstractBaseEntity<ChinaWeatherDataBean> {
private static final long serialVersionUID = 1L;
private Date datestr; // 日期
private Double beijingMaxTemp; // 北京最高气温
private Double beijingMinTemp; // 北京最低气温
private Double changchunMaxTemp; // 长春最高气温
private Double changchunMinTemp; // 长春最低气温
private Double shenyangMaxTemp; // 沈阳最高气温
private Double shenyangMinTemp; // 沈阳最低气温
private Double haerbinMaxTemp; // 哈尔滨最高气温
private Double haerbinMinTemp; // 哈尔滨最低气温
public ChinaWeatherDataBean() {
super();
}
public ChinaWeatherDataBean(String id){
super(id);
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelField(title="日期", align=2, sort=7)
public Date getDatestr() {
return datestr;
}
public void setDatestr(Date datestr) {
this.datestr = datestr;
}
@ExcelField(title="北京最高气温", align=2, sort=8)
public Double getBeijingMaxTemp() {
return beijingMaxTemp;
}
public void setBeijingMaxTemp(Double beijingMaxTemp) {
this.beijingMaxTemp = beijingMaxTemp;
}
@ExcelField(title="北京最低气温", align=2, sort=9)
public Double getBeijingMinTemp() {
return beijingMinTemp;
}
public void setBeijingMinTemp(Double beijingMinTemp) {
this.beijingMinTemp = beijingMinTemp;
}
@ExcelField(title="长春最高气温", align=2, sort=10)
public Double getChangchunMaxTemp() {
return changchunMaxTemp;
}
public void setChangchunMaxTemp(Double changchunMaxTemp) {
this.changchunMaxTemp = changchunMaxTemp;
}
@ExcelField(title="长春最低气温", align=2, sort=11)
public Double getChangchunMinTemp() {
return changchunMinTemp;
}
public void setChangchunMinTemp(Double changchunMinTemp) {
this.changchunMinTemp = changchunMinTemp;
}
@ExcelField(title="沈阳最高气温", align=2, sort=12)
public Double getShenyangMaxTemp() {
return shenyangMaxTemp;
}
public void setShenyangMaxTemp(Double shenyangMaxTemp) {
this.shenyangMaxTemp = shenyangMaxTemp;
}
@ExcelField(title="沈阳最低气温", align=2, sort=13)
public Double getShenyangMinTemp() {
return shenyangMinTemp;
}
public void setShenyangMinTemp(Double shenyangMinTemp) {
this.shenyangMinTemp = shenyangMinTemp;
}
@ExcelField(title="哈尔滨最高气温", align=2, sort=14)
public Double getHaerbinMaxTemp() {
return haerbinMaxTemp;
}
public void setHaerbinMaxTemp(Double haerbinMaxTemp) {
this.haerbinMaxTemp = haerbinMaxTemp;
}
@ExcelField(title="哈尔滨最低气温", align=2, sort=15)
public Double getHaerbinMinTemp() {
return haerbinMinTemp;
}
public void setHaerbinMinTemp(Double haerbinMinTemp) {
this.haerbinMinTemp = haerbinMinTemp;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.echarts.entity;
import org.hibernate.validator.constraints.Length;
import com.jeespring.common.persistence.AbstractBaseEntity;
import com.jeespring.common.utils.excel.annotation.ExcelField;
/**
* 班级Entity
* @author lgf
* @version 2016-05-26
*/
public class PieClass extends AbstractBaseEntity<PieClass> {
private static final long serialVersionUID = 1L;
private String className; // 班级
private Integer num; // 人数
public PieClass() {
super();
}
public PieClass(String id){
super(id);
}
@Length(min=0, max=64, message="班级长度必须介于 0 和 64 之间")
@ExcelField(title="班级", align=2, sort=7)
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
@ExcelField(title="人数", align=2, sort=8)
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.echarts.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.service.AbstractBaseService;
import com.jeespring.modules.echarts.entity.ChinaWeatherDataBean;
import com.jeespring.modules.echarts.dao.ChinaWeatherDataBeanDao;
/**
* 城市气温Service
* @author lgf
* @version 2016-06-02
*/
@Service
@Transactional(readOnly = true)
public class ChinaWeatherDataBeanService extends AbstractBaseService<ChinaWeatherDataBeanDao, ChinaWeatherDataBean> {
public ChinaWeatherDataBean get(String id) {
return super.get(id);
}
public List<ChinaWeatherDataBean> findList(ChinaWeatherDataBean chinaWeatherDataBean) {
return super.findList(chinaWeatherDataBean);
}
public Page<ChinaWeatherDataBean> findPage(Page<ChinaWeatherDataBean> page, ChinaWeatherDataBean chinaWeatherDataBean) {
return super.findPage(page, chinaWeatherDataBean);
}
@Transactional(readOnly = false)
public void save(ChinaWeatherDataBean chinaWeatherDataBean) {
super.save(chinaWeatherDataBean);
}
@Transactional(readOnly = false)
public void delete(ChinaWeatherDataBean chinaWeatherDataBean) {
super.delete(chinaWeatherDataBean);
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.echarts.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.service.AbstractBaseService;
import com.jeespring.modules.echarts.entity.PieClass;
import com.jeespring.modules.echarts.dao.PieClassDao;
/**
* 班级Service
* @author JeeSpring
* @version 2016-05-26
*/
@Service
@Transactional(readOnly = true)
public class PieClassService extends AbstractBaseService<PieClassDao, PieClass> {
public PieClass get(String id) {
return super.get(id);
}
public List<PieClass> findList(PieClass pieClass) {
return super.findList(pieClass);
}
public Page<PieClass> findPage(Page<PieClass> page, PieClass pieClass) {
return super.findPage(page, pieClass);
}
@Transactional(readOnly = false)
public void save(PieClass pieClass) {
super.save(pieClass);
}
@Transactional(readOnly = false)
public void delete(PieClass pieClass) {
super.delete(pieClass);
}
}
\ No newline at end of file
package com.jeespring.modules.echarts.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.jeespring.common.web.AbstractBaseController;
@Controller
@RequestMapping(value = "${adminPath}/echarts/bar")
public class BarController extends AbstractBaseController {
private static final long serialVersionUID = -6886697421555222670L;
private List<String> xAxisData;
private Map<String,List<Double>> yAxisData;
private Map<String,Integer> yAxisIndex;
@RequestMapping(value = {"index", ""})
public String index( HttpServletRequest request, HttpServletResponse response, Model model) {
//x轴数据
request.setAttribute("xAxisData", getxAxisData());
//y轴数据
request.setAttribute("yAxisData", getyAxisData());
//Y轴双轴情况下的位置定位
request.setAttribute("yAxisIndex", getyAxisIndex());
return "modules/echarts/bar";
}
public List<String> getxAxisData(){
xAxisData = new ArrayList<String>();
xAxisData.add("2015-10-10");
xAxisData.add("2015-10-11");
xAxisData.add("2015-10-12");
xAxisData.add("2015-10-13");
xAxisData.add("2015-10-14");
return xAxisData;
}
public Map<String,List<Double>> getyAxisData(){
Random random = new Random();
yAxisData = new HashMap<String,List<Double>>();
List<Double> data1 = new ArrayList<Double>();
data1.add(random.nextDouble());
data1.add(random.nextDouble());
data1.add(random.nextDouble());
data1.add(random.nextDouble());
data1.add(random.nextDouble());
yAxisData.put("柱状一", data1);
List<Double> data2 = new ArrayList<Double>();
data2.add(random.nextDouble());
data2.add(random.nextDouble());
data2.add(random.nextDouble());
data2.add(random.nextDouble());
data2.add(random.nextDouble());
yAxisData.put("柱状二", data2);
return yAxisData;
}
public Map<String,Integer> getyAxisIndex(){
yAxisIndex = new HashMap<String,Integer>();
yAxisIndex.put("柱状一", 0);
yAxisIndex.put("柱状二", 1);
return yAxisIndex;
}
}
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.echarts.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Lists;
import com.jeespring.common.config.Global;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.utils.DateUtils;
import com.jeespring.common.utils.MyBeanUtils;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.common.utils.excel.ExportExcel;
import com.jeespring.common.utils.excel.ImportExcel;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.modules.echarts.entity.ChinaWeatherDataBean;
import com.jeespring.modules.echarts.service.ChinaWeatherDataBeanService;
/**
* 城市气温Controller
* @author JeeSpring
* @version 2016-05-26
*/
@Controller
@RequestMapping(value = "${adminPath}/echarts/chinaWeatherDataBean")
public class ChinaWeatherDataBeanController extends AbstractBaseController {
@Autowired
private ChinaWeatherDataBeanService chinaWeatherDataBeanService;
@ModelAttribute
public ChinaWeatherDataBean get(@RequestParam(required=false) String id) {
ChinaWeatherDataBean entity = null;
if (StringUtils.isNotBlank(id)){
entity = chinaWeatherDataBeanService.get(id);
}
if (entity == null){
entity = new ChinaWeatherDataBean();
}
return entity;
}
/**
* 城市气温列表页面
*/
@RequiresPermissions("echarts:chinaWeatherDataBean:list")
@RequestMapping(value = {"list", ""})
public String list(ChinaWeatherDataBean chinaWeatherDataBean, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<ChinaWeatherDataBean> page = chinaWeatherDataBeanService.findPage(new Page<ChinaWeatherDataBean>(request, response), chinaWeatherDataBean);
model.addAttribute("page", page);
//折线图列表数据
//X轴的数据
List<String> xAxisData= new ArrayList<String>();
//Y轴的数据
Map<String,List<Double>> yAxisData = new HashMap<String,List<Double>>();
//Y轴双轴情况下的位置定位
Map<String,Integer> yAxisIndex = new HashMap<String,Integer>();
List<ChinaWeatherDataBean> weatherDataList= chinaWeatherDataBeanService.findList(chinaWeatherDataBean);
List<Double> beijingMaxTemp = new ArrayList<Double>();
List<Double> beijingMinTemp = new ArrayList<Double>();
List<Double> changchunMaxTemp = new ArrayList<Double>();
List<Double> changchunMinTemp = new ArrayList<Double>();
List<Double> shenyangMaxTemp = new ArrayList<Double>();
List<Double> shenyangMinTemp = new ArrayList<Double>();
List<Double> haerbinMaxTemp = new ArrayList<Double>();
List<Double> haerbinMinTemp = new ArrayList<Double>();
for(ChinaWeatherDataBean chinaWeatherDataBeanTemp:weatherDataList){
//x轴数据
xAxisData.add(chinaWeatherDataBeanTemp.getDatestr().toLocaleString());
//北京最高温度
beijingMaxTemp.add(chinaWeatherDataBeanTemp.getBeijingMaxTemp());
//北京最低温度
beijingMinTemp.add(chinaWeatherDataBeanTemp.getBeijingMinTemp());
//长春最高温度
changchunMaxTemp.add(chinaWeatherDataBeanTemp.getChangchunMaxTemp());
//长春最高温度
changchunMinTemp.add(chinaWeatherDataBeanTemp.getChangchunMinTemp());
//沈阳最高温度
shenyangMaxTemp.add(chinaWeatherDataBeanTemp.getShenyangMaxTemp());
//沈阳最高温度
shenyangMinTemp.add(chinaWeatherDataBeanTemp.getShenyangMinTemp());
//哈尔滨最高温度
haerbinMaxTemp.add(chinaWeatherDataBeanTemp.getHaerbinMaxTemp());
//哈尔滨最高温度
haerbinMinTemp.add(chinaWeatherDataBeanTemp.getHaerbinMinTemp());
}
//y轴数据
yAxisData.put("北京 最高温度", beijingMaxTemp);
yAxisData.put("北京 最低温度", beijingMinTemp);
yAxisData.put("长春 最高温度", changchunMaxTemp);
yAxisData.put("长春 最低温度", changchunMinTemp);
yAxisData.put("沈阳 最高温度", shenyangMaxTemp);
yAxisData.put("沈阳 最低温度", shenyangMinTemp);
yAxisData.put("哈尔滨 最高温度", haerbinMinTemp);
yAxisData.put("哈尔滨 最低温度", haerbinMinTemp);
//Y轴双轴情况下的位置定位
yAxisIndex.put("北京 最高温度", 0);//0表示Y轴左轴
yAxisIndex.put("长春 最高温度", 0);//0表示Y轴左轴
yAxisIndex.put("沈阳 最高温度", 0);//0表示Y轴左轴
yAxisIndex.put("哈尔滨 最高温度", 0);//0表示Y轴左轴
yAxisIndex.put("北京 最低温度", 1);//1表示Y轴右轴
yAxisIndex.put("长春 最低温度", 1);//1表示Y轴右轴
yAxisIndex.put("沈阳 最低温度", 1);//1表示Y轴右轴
yAxisIndex.put("哈尔滨 最低温度", 1);//1表示Y轴右轴
request.setAttribute("yAxisIndex", yAxisIndex);
request.setAttribute("xAxisData", xAxisData);
request.setAttribute("yAxisData", yAxisData);
return "modules/echarts/chinaWeatherDataBeanList";
}
/**
* 查看,增加,编辑城市气温表单页面
*/
@RequiresPermissions(value={"echarts:chinaWeatherDataBean:view","echarts:chinaWeatherDataBean:add","echarts:chinaWeatherDataBean:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(ChinaWeatherDataBean chinaWeatherDataBean, Model model) {
model.addAttribute("chinaWeatherDataBean", chinaWeatherDataBean);
return "modules/echarts/chinaWeatherDataBeanForm";
}
/**
* 保存城市气温
*/
@RequiresPermissions(value={"echarts:chinaWeatherDataBean:add","echarts:chinaWeatherDataBean:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public String save(ChinaWeatherDataBean chinaWeatherDataBean, Model model, RedirectAttributes redirectAttributes) throws Exception{
if (!beanValidator(model, chinaWeatherDataBean)){
return form(chinaWeatherDataBean, model);
}
if(!chinaWeatherDataBean.getIsNewRecord()){//编辑表单保存
ChinaWeatherDataBean t = chinaWeatherDataBeanService.get(chinaWeatherDataBean.getId());//从数据库取出记录的值
MyBeanUtils.copyBeanNotNull2Bean(chinaWeatherDataBean, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
chinaWeatherDataBeanService.save(t);//保存
}else{//新增表单保存
chinaWeatherDataBeanService.save(chinaWeatherDataBean);//保存
}
addMessage(redirectAttributes, "保存城市气温成功");
return "redirect:"+Global.getAdminPath()+"/echarts/chinaWeatherDataBean/?repage";
}
/**
* 删除城市气温
*/
@RequiresPermissions("echarts:chinaWeatherDataBean:del")
@RequestMapping(value = "delete")
public String delete(ChinaWeatherDataBean chinaWeatherDataBean, RedirectAttributes redirectAttributes) {
chinaWeatherDataBeanService.delete(chinaWeatherDataBean);
addMessage(redirectAttributes, "删除城市气温成功");
return "redirect:"+Global.getAdminPath()+"/echarts/chinaWeatherDataBean/?repage";
}
/**
* 批量删除城市气温
*/
@RequiresPermissions("echarts:chinaWeatherDataBean:del")
@RequestMapping(value = "deleteAll")
public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
String idArray[] =ids.split(",");
for(String id : idArray){
chinaWeatherDataBeanService.delete(chinaWeatherDataBeanService.get(id));
}
addMessage(redirectAttributes, "删除城市气温成功");
return "redirect:"+Global.getAdminPath()+"/echarts/chinaWeatherDataBean/?repage";
}
/**
* 导出excel文件
*/
@RequiresPermissions("echarts:chinaWeatherDataBean:export")
@RequestMapping(value = "export", method=RequestMethod.POST)
public String exportFile(ChinaWeatherDataBean chinaWeatherDataBean, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
String fileName = "城市气温"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<ChinaWeatherDataBean> page = chinaWeatherDataBeanService.findPage(new Page<ChinaWeatherDataBean>(request, response, -1), chinaWeatherDataBean);
new ExportExcel("城市气温", ChinaWeatherDataBean.class).setDataList(page.getList()).write(response, fileName).dispose();
return null;
} catch (Exception e) {
addMessage(redirectAttributes, "导出城市气温记录失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/echarts/chinaWeatherDataBean/?repage";
}
/**
* 导入Excel数据
*/
@RequiresPermissions("echarts:chinaWeatherDataBean:import")
@RequestMapping(value = "import", method=RequestMethod.POST)
public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<ChinaWeatherDataBean> list = ei.getDataList(ChinaWeatherDataBean.class);
for (ChinaWeatherDataBean chinaWeatherDataBean : list){
try{
chinaWeatherDataBeanService.save(chinaWeatherDataBean);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条城市气温记录。");
}
addMessage(redirectAttributes, "已成功导入 "+successNum+" 条城市气温记录"+failureMsg);
} catch (Exception e) {
addMessage(redirectAttributes, "导入城市气温失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/echarts/chinaWeatherDataBean/?repage";
}
/**
* 下载导入城市气温数据模板
*/
@RequiresPermissions("echarts:chinaWeatherDataBean:import")
@RequestMapping(value = "import/template")
public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
String fileName = "城市气温数据导入模板.xlsx";
List<ChinaWeatherDataBean> list = Lists.newArrayList();
new ExportExcel("城市气温数据", ChinaWeatherDataBean.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/echarts/chinaWeatherDataBean/?repage";
}
}
\ No newline at end of file
package com.jeespring.modules.echarts.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.modules.echarts.entity.ChinaWeatherDataBean;
import com.jeespring.modules.echarts.service.ChinaWeatherDataBeanService;
@Controller
@RequestMapping(value = "${adminPath}/echarts/line")
public class LineController extends AbstractBaseController {
private static final long serialVersionUID = -6886697421555222670L;
@Autowired
private ChinaWeatherDataBeanService chinaWeatherDataBeanService;
@RequestMapping(value = {"index", ""})
public String index(ChinaWeatherDataBean chinaWeatherDataBean, HttpServletRequest request, HttpServletResponse response, Model model) {
//X轴的数据
List<String> xAxisData= new ArrayList<String>();
//Y轴的数据
Map<String,List<Double>> yAxisData = new HashMap<String,List<Double>>();
//Y轴双轴情况下的位置定位
Map<String,Integer> yAxisIndex = new HashMap<String,Integer>();
List<ChinaWeatherDataBean> weatherDataList= chinaWeatherDataBeanService.findList(chinaWeatherDataBean);
List<Double> beijingMaxTemp = new ArrayList<Double>();
List<Double> beijingMinTemp = new ArrayList<Double>();
List<Double> changchunMaxTemp = new ArrayList<Double>();
List<Double> changchunMinTemp = new ArrayList<Double>();
List<Double> shenyangMaxTemp = new ArrayList<Double>();
List<Double> shenyangMinTemp = new ArrayList<Double>();
List<Double> haerbinMaxTemp = new ArrayList<Double>();
List<Double> haerbinMinTemp = new ArrayList<Double>();
for(ChinaWeatherDataBean chinaWeatherDataBeanTemp:weatherDataList){
//x轴数据
xAxisData.add(chinaWeatherDataBeanTemp.getDatestr().toLocaleString());
//北京最高温度
beijingMaxTemp.add(chinaWeatherDataBeanTemp.getBeijingMaxTemp());
//北京最低温度
beijingMinTemp.add(chinaWeatherDataBeanTemp.getBeijingMinTemp());
//长春最高温度
changchunMaxTemp.add(chinaWeatherDataBeanTemp.getChangchunMaxTemp());
//长春最高温度
changchunMinTemp.add(chinaWeatherDataBeanTemp.getChangchunMinTemp());
//沈阳最高温度
shenyangMaxTemp.add(chinaWeatherDataBeanTemp.getShenyangMaxTemp());
//沈阳最高温度
shenyangMinTemp.add(chinaWeatherDataBeanTemp.getShenyangMinTemp());
//哈尔滨最高温度
haerbinMaxTemp.add(chinaWeatherDataBeanTemp.getHaerbinMaxTemp());
//哈尔滨最高温度
haerbinMinTemp.add(chinaWeatherDataBeanTemp.getHaerbinMinTemp());
}
//y轴数据
yAxisData.put("北京 最高温度", beijingMaxTemp);
yAxisData.put("北京 最低温度", beijingMinTemp);
yAxisData.put("长春 最高温度", changchunMaxTemp);
yAxisData.put("长春 最低温度", changchunMinTemp);
yAxisData.put("沈阳 最高温度", shenyangMaxTemp);
yAxisData.put("沈阳 最低温度", shenyangMinTemp);
yAxisData.put("哈尔滨 最高温度", haerbinMinTemp);
yAxisData.put("哈尔滨 最低温度", haerbinMinTemp);
//Y轴双轴情况下的位置定位
yAxisIndex.put("北京 最高温度", 0);//0表示Y轴左轴
yAxisIndex.put("长春 最高温度", 0);//0表示Y轴左轴
yAxisIndex.put("沈阳 最高温度", 0);//0表示Y轴左轴
yAxisIndex.put("哈尔滨 最高温度", 0);//0表示Y轴左轴
yAxisIndex.put("北京 最低温度", 1);//1表示Y轴右轴
yAxisIndex.put("长春 最低温度", 1);//1表示Y轴右轴
yAxisIndex.put("沈阳 最低温度", 1);//1表示Y轴右轴
yAxisIndex.put("哈尔滨 最低温度", 1);//1表示Y轴右轴
request.setAttribute("yAxisIndex", yAxisIndex);
request.setAttribute("xAxisData", xAxisData);
request.setAttribute("yAxisData", yAxisData);
return "modules/echarts/line";
}
}
package com.jeespring.modules.echarts.web;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.jeespring.common.web.AbstractBaseController;
@Controller
@RequestMapping(value = "${adminPath}/echarts/linedoublenum")
public class LineDoubleNumController extends AbstractBaseController {
private static final long serialVersionUID = -6886697421555222670L;
private Map<String,Double[][]> axisDataArr;
@RequestMapping(value = {"index", ""})
public String index( HttpServletRequest request, HttpServletResponse response, Model model) {
//x+y轴数据Double[x轴数据][y轴数据]
request.setAttribute("axisDataArr", getaxisDataArr());
return "modules/echarts/lineDoubleNum";
}
public Map<String,Double[][]> getaxisDataArr(){
Random random = new Random();
axisDataArr = new HashMap<String,Double[][]>();
Double[][] data1 = new Double[10][2];
for(int i=0;i<10;i++){
data1[i][0]=i+0.0;
data1[i][1]=random.nextInt(10)+0.0;
}
axisDataArr.put("曲线一", data1);
Double[][] data2 = new Double[10][2];
for(int i=0;i<10;i++){
data2[i][0]=i+1.0;
data2[i][1]=random.nextInt(10)+0.0;
}
axisDataArr.put("曲线二", data2);
return axisDataArr;
}
}
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.echarts.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Lists;
import com.jeespring.common.utils.DateUtils;
import com.jeespring.common.utils.MyBeanUtils;
import com.jeespring.common.config.Global;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.common.utils.excel.ExportExcel;
import com.jeespring.common.utils.excel.ImportExcel;
import com.jeespring.modules.echarts.entity.PieClass;
import com.jeespring.modules.echarts.service.PieClassService;
/**
* 班级Controller
* @author lgf
* @version 2016-05-26
*/
@Controller
@RequestMapping(value = "${adminPath}/echarts/pieClass")
public class PieClassController extends AbstractBaseController {
@Autowired
private PieClassService pieClassService;
@ModelAttribute
public PieClass get(@RequestParam(required=false) String id) {
PieClass entity = null;
if (StringUtils.isNotBlank(id)){
entity = pieClassService.get(id);
}
if (entity == null){
entity = new PieClass();
}
return entity;
}
/**
* 班级列表页面
*/
@RequiresPermissions("echarts:pieClass:list")
@RequestMapping(value = {"list", ""})
public String list(PieClass pieClass, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<PieClass> page = pieClassService.findPage(new Page<PieClass>(request, response), pieClass);
model.addAttribute("page", page);
//生成报表数据
Map<String,Object> orientData = new HashMap<String,Object>();
List<PieClass> list = pieClassService.findList(pieClass);
for(PieClass pie:list){
orientData.put(pie.getClassName(), pie.getNum());
}
model.addAttribute("orientData", orientData);
return "modules/echarts/pieClassList";
}
/**
* 查看,增加,编辑班级表单页面
*/
@RequiresPermissions(value={"echarts:pieClass:view","echarts:pieClass:add","echarts:pieClass:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(PieClass pieClass, Model model) {
model.addAttribute("pieClass", pieClass);
return "modules/echarts/pieClassForm";
}
/**
* 保存班级
*/
@RequiresPermissions(value={"echarts:pieClass:add","echarts:pieClass:edit"},logical=Logical.OR)
@RequestMapping(value = "save")
public String save(PieClass pieClass, Model model, RedirectAttributes redirectAttributes) throws Exception{
if (!beanValidator(model, pieClass)){
return form(pieClass, model);
}
if(!pieClass.getIsNewRecord()){//编辑表单保存
PieClass t = pieClassService.get(pieClass.getId());//从数据库取出记录的值
MyBeanUtils.copyBeanNotNull2Bean(pieClass, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
pieClassService.save(t);//保存
}else{//新增表单保存
pieClassService.save(pieClass);//保存
}
addMessage(redirectAttributes, "保存班级成功");
return "redirect:"+Global.getAdminPath()+"/echarts/pieClass/?repage";
}
/**
* 删除班级
*/
@RequiresPermissions("echarts:pieClass:del")
@RequestMapping(value = "delete")
public String delete(PieClass pieClass, RedirectAttributes redirectAttributes) {
pieClassService.delete(pieClass);
addMessage(redirectAttributes, "删除班级成功");
return "redirect:"+Global.getAdminPath()+"/echarts/pieClass/?repage";
}
/**
* 批量删除班级
*/
@RequiresPermissions("echarts:pieClass:del")
@RequestMapping(value = "deleteAll")
public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
String idArray[] =ids.split(",");
for(String id : idArray){
pieClassService.delete(pieClassService.get(id));
}
addMessage(redirectAttributes, "删除班级成功");
return "redirect:"+Global.getAdminPath()+"/echarts/pieClass/?repage";
}
/**
* 导出excel文件
*/
@RequiresPermissions("echarts:pieClass:export")
@RequestMapping(value = "export", method=RequestMethod.POST)
public String exportFile(PieClass pieClass, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
String fileName = "班级"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<PieClass> page = pieClassService.findPage(new Page<PieClass>(request, response, -1), pieClass);
new ExportExcel("班级", PieClass.class).setDataList(page.getList()).write(response, fileName).dispose();
return null;
} catch (Exception e) {
addMessage(redirectAttributes, "导出班级记录失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/echarts/pieClass/?repage";
}
/**
* 导入Excel数据
*/
@RequiresPermissions("echarts:pieClass:import")
@RequestMapping(value = "import", method=RequestMethod.POST)
public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) {
try {
int successNum = 0;
int failureNum = 0;
StringBuilder failureMsg = new StringBuilder();
ImportExcel ei = new ImportExcel(file, 1, 0);
List<PieClass> list = ei.getDataList(PieClass.class);
for (PieClass pieClass : list){
try{
pieClassService.save(pieClass);
successNum++;
}catch(ConstraintViolationException ex){
failureNum++;
}catch (Exception ex) {
failureNum++;
}
}
if (failureNum>0){
failureMsg.insert(0, ",失败 "+failureNum+" 条班级记录。");
}
addMessage(redirectAttributes, "已成功导入 "+successNum+" 条班级记录"+failureMsg);
} catch (Exception e) {
addMessage(redirectAttributes, "导入班级失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/echarts/pieClass/?repage";
}
/**
* 下载导入班级数据模板
*/
@RequiresPermissions("echarts:pieClass:import")
@RequestMapping(value = "import/template")
public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
String fileName = "班级数据导入模板.xlsx";
List<PieClass> list = Lists.newArrayList();
new ExportExcel("班级数据", PieClass.class, 1).setDataList(list).write(response, fileName).dispose();
return null;
} catch (Exception e) {
addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/echarts/pieClass/?repage";
}
}
\ No newline at end of file
package com.jeespring.modules.echarts.web;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.jeespring.common.web.AbstractBaseController;
@Controller
@RequestMapping(value = "${adminPath}/echarts/pie")
public class PieController extends AbstractBaseController {
private static final long serialVersionUID = 7375363226310112119L;
private Map<String,Object> orientData;
@RequestMapping(value = {"index", ""})
public String index( HttpServletRequest request, HttpServletResponse response, Model model) {
request.setAttribute("orientData", getorientData());
return "modules/echarts/pie";
}
public Map<String,Object> getorientData(){
orientData = new HashMap<String,Object>();
orientData.put("直接访问", 335);
orientData.put("邮件营销", 310);
orientData.put("联盟广告", 234);
orientData.put("视频广告", 135);
orientData.put("搜索引擎", 1548);
return orientData;
}
}
package com.jeespring.modules.echarts.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.jeespring.common.web.AbstractBaseController;
@Controller
@RequestMapping(value = "${adminPath}/echarts/radar")
public class RadarController extends AbstractBaseController {
private static final long serialVersionUID = 7375363226310112119L;
private List<Map<String,Object>> orientData;
@RequestMapping(value = {"index", ""})
public String index( HttpServletRequest request, HttpServletResponse response, Model model) {
request.setAttribute("orientData", getorientData8());
return "modules/echarts/radar";
}
public List<Map<String,Object>> getorientData8(){
orientData = new ArrayList<Map<String,Object>>();
Double[] dataArr1 = new Double[]{0.1*100,0.2*100,0.3*100,0.1*100,0.05*100,0.05*100,0.1*100,0.1*100};
Map<String,Object> mapData1 = new HashMap<String,Object>();
mapData1.put("dataArr", dataArr1);
mapData1.put("title", "玫瑰图1");
orientData.add(mapData1);
Double[] dataArr2 = new Double[]{0.05*100,0.05*100,0.1*100,0.1*100,0.1*100,0.2*100,0.3*100,0.1*100};
Map<String,Object> mapData2 = new HashMap<String,Object>();
mapData2.put("dataArr", dataArr2);
mapData2.put("title", "玫瑰图2");
orientData.add(mapData2);
return orientData;
}
}
package com.jeespring.modules.gen.dao;
import com.jeespring.common.persistence.InterfaceBaseDao;
import org.apache.ibatis.annotations.Mapper;
import com.jeespring.modules.gen.entity.GenTable;
import com.jeespring.modules.gen.entity.GenTableColumn;
import java.util.List;
@Mapper
public interface GenDataBaseDictDao
extends InterfaceBaseDao<GenTableColumn>
{
List<GenTable> findTableList(GenTable paramGenTable);
List<GenTableColumn> findTableColumnList(GenTable paramGenTable);
List<String> findTablePK(GenTable paramGenTable);
}
\ No newline at end of file
package com.jeespring.modules.gen.dao;
import com.jeespring.common.persistence.InterfaceBaseDao;
import org.apache.ibatis.annotations.Mapper;
import com.jeespring.modules.gen.entity.GenScheme;
@Mapper
public interface GenSchemeDao
extends InterfaceBaseDao<GenScheme>
{}
package com.jeespring.modules.gen.dao;
import com.jeespring.common.persistence.InterfaceBaseDao;
import org.apache.ibatis.annotations.Mapper;
import com.jeespring.modules.gen.entity.GenTable;
import com.jeespring.modules.gen.entity.GenTableColumn;
@Mapper
public interface GenTableColumnDao
extends InterfaceBaseDao<GenTableColumn>
{
void deleteByGenTable(GenTable paramGenTable);
}
package com.jeespring.modules.gen.dao;
import com.jeespring.common.persistence.InterfaceBaseDao;
import org.apache.ibatis.annotations.Mapper;
import com.jeespring.modules.gen.entity.GenTable;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface GenTableDao
extends InterfaceBaseDao<GenTable>
{
int buildTable(@Param("sql") String paramString);
}
package com.jeespring.modules.gen.dao;
import com.jeespring.common.persistence.InterfaceBaseDao;
import org.apache.ibatis.annotations.Mapper;
import com.jeespring.modules.gen.entity.GenTemplate;
@Mapper
public interface GenTemplateDao
extends InterfaceBaseDao<GenTemplate>
{}
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:43
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenCategory.java
package com.jeespring.modules.gen.entity;
import com.jeespring.modules.sys.entity.Dict;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="category")
public class GenCategory
extends Dict
{
private static final long serialVersionUID = 1L;
private List<String> template;
private List<String> childTableTemplate;
public static String CATEGORY_REF = "category-ref:";
@XmlElement(name="template")
public List<String> getTemplate()
{
return this.template;
}
public void setTemplate(List<String> template)
{
this.template = template;
}
@XmlElementWrapper(name="childTable")
@XmlElement(name="template")
public List<String> getChildTableTemplate()
{
return this.childTableTemplate;
}
public void setChildTableTemplate(List<String> childTableTemplate)
{
this.childTableTemplate = childTableTemplate;
}
}
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:48
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenConfig.java
package com.jeespring.modules.gen.entity;
import java.io.Serializable;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import com.jeespring.modules.sys.entity.Dict;
@XmlRootElement(name="config")
public class GenConfig
implements Serializable
{
private static final long serialVersionUID = 1L;
private List<GenCategory> categoryList;
private List<Dict> javaTypeList;
private List<Dict> queryTypeList;
private List<Dict> showTypeList;
@XmlElementWrapper(name="category")
@XmlElement(name="category")
public List<GenCategory> getCategoryList()
{
return this.categoryList;
}
public void setCategoryList(List<GenCategory> categoryList)
{
this.categoryList = categoryList;
}
@XmlElementWrapper(name="javaType")
@XmlElement(name="dict")
public List<Dict> getJavaTypeList()
{
return this.javaTypeList;
}
public void setJavaTypeList(List<Dict> javaTypeList)
{
this.javaTypeList = javaTypeList;
}
@XmlElementWrapper(name="queryType")
@XmlElement(name="dict")
public List<Dict> getQueryTypeList()
{
return this.queryTypeList;
}
public void setQueryTypeList(List<Dict> queryTypeList)
{
this.queryTypeList = queryTypeList;
}
@XmlElementWrapper(name="showType")
@XmlElement(name="dict")
public List<Dict> getShowTypeList()
{
return this.showTypeList;
}
public void setShowTypeList(List<Dict> showTypeList)
{
this.showTypeList = showTypeList;
}
}
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:53
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenScheme.java
package com.jeespring.modules.gen.entity;
import com.jeespring.common.persistence.AbstractBaseEntity;
import org.hibernate.validator.constraints.Length;
public class GenScheme
extends AbstractBaseEntity<GenScheme>
{
private static final long serialVersionUID = 1L;
private String name;
private String category;
private String packageName;
private String moduleName;
private String subModuleName;
private String functionName;
private String functionNameSimple;
private String functionAuthor;
private GenTable genTable;
private String flag;
private Boolean replaceFile;
public GenScheme() {}
public GenScheme(String id)
{
super(id);
}
@Length(min=1, max=200)
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
public String getPackageName()
{
return this.packageName;
}
public void setPackageName(String packageName)
{
this.packageName = packageName;
}
public String getModuleName()
{
return this.moduleName;
}
public void setModuleName(String moduleName)
{
this.moduleName = moduleName;
}
public String getSubModuleName()
{
return this.subModuleName;
}
public void setSubModuleName(String subModuleName)
{
this.subModuleName = subModuleName;
}
public String getCategory()
{
return this.category;
}
public void setCategory(String category)
{
this.category = category;
}
public String getFunctionName()
{
return this.functionName;
}
public void setFunctionName(String functionName)
{
this.functionName = functionName;
}
public String getFunctionNameSimple()
{
return this.functionNameSimple;
}
public void setFunctionNameSimple(String functionNameSimple)
{
this.functionNameSimple = functionNameSimple;
}
public String getFunctionAuthor()
{
return this.functionAuthor;
}
public void setFunctionAuthor(String functionAuthor)
{
this.functionAuthor = functionAuthor;
}
public GenTable getGenTable()
{
return this.genTable;
}
public void setGenTable(GenTable genTable)
{
this.genTable = genTable;
}
public String getFlag()
{
return this.flag;
}
public void setFlag(String flag)
{
this.flag = flag;
}
public Boolean getReplaceFile()
{
return this.replaceFile;
}
public void setReplaceFile(Boolean replaceFile)
{
this.replaceFile = replaceFile;
}
}
Supports Markdown
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